a binding function for composer double-click

F

fogh

Guest
A double click will either descend into schematic or show properties.

This is the first working code I came up with. The logic is a messy bunch of nested "if" statements, and many improvement could be made. All your contributions will be welcome...

/* _________________________________________________________________________ */
hiSetBindKey( "Schematics" "None<Btn1Down>(2)" "CmDoubleClick()" )
/* _________________________________________________________________________ */
procedure( CmDoubleClick()
/*
Function intended for a key binding to None<Btn1Down>(2).
What to do when doubleclick on something in a schematic:
- when the object under the mouse is an instance whose master has a cellview by the same name as the current cellview, descend it.
- else, bring the property form.

Possible improvements:
- when the object under the mouse belongs to the technology attached to current library, and has a spectre stopview, retrieve the compact model. If possible, get the value of the parameters passed to the model for this instance.
- have the option of not descending into schematics that are in the tech library. Some foundries have devices entered as schematics rather than just a subckt in a model.scs . A simpler criterion can be (library unwritable)&&(I dont belong to group owner)
- better use of use window->viewNameList or schGetEnv("viewNameList"). Should I use gePush or geSwitch instead of schHiDescend ? How does this viewNameList really work? schematic descendTarget string { "query user" | "use viewNameList" }
- if object is a pin or a wire and analog artist is running, try to plot|print the corresponding result. Is is possible to put a stamp-sized waveplot next to the dblclick point ?
- preserve the selection, or restore it on exit.
- export the configurable bits to global vars , or use cds EnvVar's
*/

let(
;;local vars
;nil
(point (objectID nil) currentview window filternothing filteroutshapes envdefaultdescendTarget windowdefaultviewNameList CmStopLibraries)

;;check that it makes sense at all.
when( hiGraphicMode()

;; a permanent list of libraries that should not be switched into
CmStopLibraries=list( "cdsDefTechLib"
"basic"
"US_8ths"
"analogLib"
"functional"
"ahdlLib"
)

;; gather some info
point=hiGetCommandPoint()
currentview=geGetEditCellView()
window = hiGetCurrentWindow()

;;see if there is stg interesting close to this rodent.
;; define 2 filters. We apply the restrictive filter first so that we find "interesting" objects before uninteresting ones.
filternothing="dbobjectp" ;if we didn t need to restrict what kind of objects are queried.
filteroutshapes="CmDoubleClickPointQueryFilterOutShapes"
unless(fboundp('CmDoubleClickPointQueryFilterOutShapes)
filter=lambda((fig)
not(fig~>isShape)
);l
putd( 'CmDoubleClickPointQueryFilterOutShapes filter)
);unless filter func defined

when( objectID=or(gePointQuery(window point filteroutshapes) gePointQuery(window point filternothing) )
;; save the window viewlist and the schematic editor descend mode because we will mess with those.
envdefaultdescendTarget=schGetEnv("descendTarget")
windowdefaultviewNameList=window->viewNameList
;; ...and we already mess with those.
schSetEnv("descendTarget" "use viewNameList")
unless( currentview->viewName==car(parseString(windowdefaultviewNameList))
window->viewNameList=strcat(currentview->viewName " " windowdefaultviewNameList)
);unless
;; there is stg under the mouse, so lets select it.
geDeselectAll()
;geSingleSelectPoint(window nil point) ; the nil in argument#2 stands for partialselection=false
geSelectFigNoFilter(objectID)
;; if its an instance, lets see if we can descend it.
if( objectID~>isAnyInst
then
;DM("is an instance")
if(and(
member(currentview->viewName objectID->master->cell->views~>name) ;;instance master has a schematic view. Can be descended.
not(member(objectID->master->lib->name CmStopLibraries)) ;; not a "forbidden" library
objectID->master->lib != techGetTechFileDdId(techGetTechFile(objectID->master->lib))->lib ;;is not it's own technology.
)
then
DM("is switchable")
if( objectID~>master~>cell~>isWritable
then schHiDescendEdit()
else schHiDescendRead()
);writable
else ;;is an instance but can t be descended, lets pop up properties.
schHiObjectProperty() ;DM("undescendable instance")
);fi is descendable
else ;; is not an instance, lets pop up properties.
schHiObjectProperty() ;DM("not an instance")
);fi is an an instance
;;wether it was an instance or not, we have done stg with what was found under the mouse. Let s clean the mess and leave.
schSetEnv("descendTarget" envdefaultdescendTarget)
window->viewNameList=windowdefaultviewNameList
);when stg is under the mouse
);when dfII is graphic.
;;bye bye.
objectID
);let
);proc
 

Welcome to EDABoard.com

Sponsor

Back
Top