# A set of routines to find all cells using a specific cell
# Any field may be left blank to wildcard except searchInLibName
# searchInLibName is the name of the library to search the cells in.
# All other parameters specify what kids we are looking for
proc printAllCellsUsingCell { libName cellName viewName searchInLibName searchInPath } {
set closeLib 0
set libId [edbFindLibraryId $searchInLibName $searchInPath]
if { $libId == 0 } {
set libId [edbOpenLibrary $searchInLibName r $searchInPath]
set closeLib 1
}
set rlibs [edbGetRefLibs $libId]
set ronly -1
if { $libName != "" } {
if { [string compare $libName $searchInLibName] == 0 } {
set ronly 0
} else {
set ix 1
foreach rlib $rlibs {
if { [string compare [lAssocFetch $rlib libName] $libName] == 0 } {
set ronly $ix
break
}
incr ix
}
if { $ronly == -1 } {
puts "Library $searchInLibName does not reference library $libName"
if { $closeLib == 1 } { edbCloseLibrary $libId }
return
}
}
}
foreach cTuple [edbGetLibCellIndex $libId -split] {
set cName [lindex $cTuple 0]
set vName [lindex $cTuple 1]
set ver [lindex $cTuple 2]
set cellId [edbFindCellId $libId $cName $vName $ver ]
set closeCell 0
if { $cellId == 0 } {
set cellId [edbOpenCell $libId $cName $vName $ver -mode read]
set closeCell 1
}
edbSeq mid $cellId instmaster {
set data [edbFetchObject $cellId $mid]
set cellChk [lAssocFetch $data cellName]
set viewChk [lAssocFetch $data viewName]
set rname [lAssocFetch $data libName]
set rnum [lAssocFetch $data rLibNum]
if { ($cellName == "" || [string compare $cellChk $cellName] == 0) &&
($viewName == "" || [string compare $viewChk $viewName] == 0) &&
($ronly == -1 || $ronly == $rnum) } {
puts "Cell $cName view $vName references $rname/$cellChk/$viewChk"
}
}
if { $closeCell == 1 } { edbAbortAndCloseCell $cellId }
}
if { $closeLib == 1 } { edbCloseLibrary $libId }
}
proc menuPrintAllCellsUsingCell { } {
set dialogName .findCellParents
toplevel $dialogName
frame $dialogName.but
frame $dialogName.d1
frame $dialogName.d2
frame $dialogName.d3
frame $dialogName.d4
frame $dialogName.d5
wm title $dialogName "Find Parents of a cell"
button $dialogName.ok -text Ok -command "menuEPrintAllCellsUsingCell 1"
button $dialogName.apl -text Apply -command "menuEPrintAllCellsUsingCell 0"
button $dialogName.cancel -text Cancel -command "destroy $dialogName"
label $dialogName.lTitle -text "Search Library"
entry $dialogName.lName
label $dialogName.lpTitle -text "Path"
entry $dialogName.lPath
label $dialogName.sep -text "Look for cell with a (empty implies match any)"
label $dialogName.lsTitle -text "Library Name"
entry $dialogName.lsName
label $dialogName.csTitle -text "Cell Name"
entry $dialogName.csName
label $dialogName.vsTitle -text "View Name"
entry $dialogName.vsName
pack $dialogName.but $dialogName.d1 $dialogName.d2 $dialogName.sep \
$dialogName.d3 $dialogName.d4 $dialogName.d5 \
-anchor w
pack $dialogName.ok $dialogName.apl $dialogName.cancel -side left -in $dialogName.but
pack $dialogName.lTitle $dialogName.lName -side left -in $dialogName.d1
pack $dialogName.lpTitle $dialogName.lPath -side left -in $dialogName.d2
pack $dialogName.lsTitle $dialogName.lsName -side left -in $dialogName.d3
pack $dialogName.csTitle $dialogName.csName -side left -in $dialogName.d4
pack $dialogName.vsTitle $dialogName.vsName -side left -in $dialogName.d5
}
proc menuEPrintAllCellsUsingCell { wipe } {
set dialogName .findCellParents
set lName [$dialogName.lName cget -text]
set lPath [$dialogName.lPath cget -text]
if { $lPath == "" } { set lPath "." }
set lsName [$dialogName.lsName cget -text]
set csName [$dialogName.csName cget -text]
set vsName [$dialogName.vsName cget -text]
printAllCellsUsingCell $lsName $csName $vsName $lName $lPath
if { $wipe } { destroy $dialogName }
}
|