1 # Copyright (c) 1999-2012 OPEN CASCADE SAS
3 # The content of this file is subject to the Open CASCADE Technology Public
4 # License Version 6.5 (the "License"). You may not use the content of this file
5 # except in compliance with the License. Please obtain a copy of the License
6 # at http://www.opencascade.org and read it completely before using this file.
8 # The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 # main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 # The Original Code and all software distributed under the License is
12 # distributed on an "AS IS" basis, without warranty of any kind, and the
13 # Initial Developer hereby disclaims all such warranties, including without
14 # limitation, any warranties of merchantability, fitness for a particular
15 # purpose or non-infringement. Please see the License for the specific terms
16 # and conditions governing the rights and limitations under the License.
18 ###########################
23 ###########################
25 # Open : double-clic or +
26 # Close : double-clic or -
27 # Refresh tree : close top level and re-open
30 # white : interoperable
31 # white + c : non interoperable
33 # Red : not yet commited in transaction #0
37 proc __update { args } {
42 proc treebrowser { TreeBrowser } {
45 global TREE_LabelStyle
46 global TREE_LabelStyle1
47 global TREE_AttributeStyle
48 global TREE_AttributeStyle1
49 global TREE_AttributeStyle2
54 tixPref:InitFontSet:14Point
56 set TREE_LabelStyle [tixDisplayStyle imagetext \
61 set TREE_LabelStyle1 [tixDisplayStyle imagetext \
64 -foreground SeaGreen2 \
67 set TREE_AttributeStyle [tixDisplayStyle imagetext \
72 set TREE_AttributeStyle1 [tixDisplayStyle imagetext \
78 set TREE_AttributeStyle2 [tixDisplayStyle imagetext \
87 set top [frame $w.thu -bd 1 -relief raised -background Bisque3]
92 set p [tixPanedWindow $top.p -orient horizontal -height 400 -width 700]
93 pack $p -expand yes -fill both -padx 4 -pady 4
95 TREE:Tree:InitTreePanel $TreeBrowser $w $p
96 #TREE:Tree:InitTextPanel $TreeBrowser $w $p
98 tixForm $top -left 2 -top 2 -right %99 -bottom %99
103 ###############################################################################
106 proc TREE:Tree:InitTreePanel { TreeBrowser w p } {
114 set p1 [$p add pane1 -expand 1 -size 700] ; $p1 config -relief flat
115 set tree [tixTree $p1.tree \
116 -opencmd [list TREE:Tree:Open $TreeBrowser $w] \
118 hlist.separator "^" \
119 hlist.font 9x15bold \
120 hlist.background Bisque3 \
121 hlist.foreground Black \
123 pack $p1.tree -expand yes -fill both -padx 4 -pady 4
125 # -browsecmd TREE:Tree:BrowseCmd
126 # Cette option peut etre ajoutee a la commande tixTree,
127 # mais elle declanche l'appel a la procedure a chaque clic ,
128 # double-clic, voire a chaque appui puis relachement de souris!!!
130 # to see different fonts: /usr/openwin/lib/X11/fonts/misc or xlsfonts?
131 # 8x13 8x13bold 9x15 9x15bold
132 # hlist.font 8x13bold
136 set TREE_WINDOWS($w,NAV,tree) $tree
137 set TREE_WINDOWS($w,NAV,hlist) [$tree subwidget hlist]
138 $TREE_WINDOWS($w,NAV,hlist) add ^ \
140 -data [list $TreeBrowser Root]
141 $TREE_WINDOWS($w,NAV,tree) setmode ^ open
144 ###############################################################################
147 proc TREE:Tree:InitTextPanel { TreeBrowser w p } {
154 set p2 [$p add pane2 -expand 4 -size 400] ; $p2 config -relief flat
155 tixScrolledText $p2.st
156 pack $p2.st -expand yes -fill both -padx 4 -pady 4
158 set TREE_WINDOWS($w,NAV,text) [$p2.st subwidget text]
162 $TREE_WINDOWS($w,NAV,text) insert end " Welcome to the QDF browser (Rev #.#)\n"
163 $TREE_WINDOWS($w,NAV,text) insert end "--------------------------------------\n\n"
164 $TREE_WINDOWS($w,NAV,text) insert end "This browser is an easy to use prototype made with Tix technology. We hope it will be usefull for understanding and debugging QDF.\n"
165 $TREE_WINDOWS($w,NAV,text) insert end "\t\t\t\tFID & YAN"
168 ###############################################################################
171 proc TREE:Tree:BrowseCmd { dir } {
174 ###############################################################################
175 # Se positionne sur l'entry pere et update les fenetres.
177 proc FCTREE:Tree:Up { w } {
182 if { [set here [$TREE_WINDOWS($w,NAV,hlist) info anchor]] != {} } {
183 if { [set up [$TREE_WINDOWS($w,NAV,hlist) info parent $here]] != {} } {
184 TREE:Tree:ShowUp $w $up
185 set TREE_GLOBALS(CWD) [lindex [$TREE_WINDOWS($w,NAV,hlist) info data $up] 0]
190 ###############################################################################
191 # Se positionne sur l'entry up sans update (History)
193 proc TREE:Tree:ShowUp { w dir } {
195 #puts "TREE:Tree:ShowUp"
197 $TREE_WINDOWS($w,NAV,hlist) anchor clear
198 $TREE_WINDOWS($w,NAV,hlist) anchor set $dir
199 $TREE_WINDOWS($w,NAV,hlist) selection clear
200 $TREE_WINDOWS($w,NAV,hlist) selection set $dir
201 $TREE_WINDOWS($w,NAV,hlist) see $dir
204 ###############################################################################
207 proc TREE:Tree:Open { TreeBrowser w dir} {
210 #puts "TREE:Tree:Open"
214 if {[$TREE_WINDOWS($w,NAV,hlist) info children $dir] != {}} {
215 # The root branch already exists in hlist.
216 # Clear all its children to force the tree to be updated.
217 foreach kid [$TREE_WINDOWS($w,NAV,hlist) info children $dir] {
218 $TREE_WINDOWS($w,NAV,hlist) delete entry $kid
223 if {[$TREE_WINDOWS($w,NAV,hlist) info children $dir] != {}} {
224 # The branch exists in hlist.
225 foreach kid [$TREE_WINDOWS($w,NAV,hlist) info children $dir] {
226 $TREE_WINDOWS($w,NAV,hlist) show entry $kid
228 set data [$TREE_WINDOWS($w,NAV,hlist) info data $dir]
229 #set loc [lindex $data 0]
231 # The branch is unknown.
234 TREE:Tree:Fill $TreeBrowser $w $dir
239 ###############################################################################
242 proc TREE:Tree:Fill { TreeBrowser w dir } {
246 #puts "TREE:Tree:Fill"
248 set data [$TREE_WINDOWS($w,NAV,hlist) info data $dir]
249 #set loc [lindex $data 0]
250 set type [lindex $data 1]
252 #puts "====================="
257 #puts "====================="
262 TREE:Tree:UpdateRoot $TreeBrowser $w $dir
266 set lab [lindex $data 0]
267 TREE:Tree:UpdateNode $TreeBrowser $w $dir $lab
271 TREE:Tree:terminal $TreeBrowser $w $dir
275 puts "type non reconnu"
280 ###############################################################################
283 proc TREE:Tree:UpdateRoot { TreeBrowser w dir } {
286 global TREE_AttributeStyle
287 global TREE_AttributeStyle1
288 #puts "TREE:Tree:UpdateRoot"
290 foreach nodeItem [split [OpenNode $TreeBrowser ""] "\\" ] {
292 TREE:Tree:DecodeNodeItem $TreeBrowser $w $dir $nodeItem
298 ###############################################################################
301 proc TREE:Tree:UpdateNode { TreeBrowser w dir lab} {
304 global TREE_AttributeStyle
305 global TREE_AttributeStyle1
306 #puts "TREE:Tree:UpdateNode"
308 foreach nodeItem [split [OpenNode $TreeBrowser $lab ] "\\" ] {
310 TREE:Tree:DecodeNodeItem $TreeBrowser $w $dir $nodeItem
315 ###############################################################################
317 # "LabelEntry "Name" DynamicType Executable|Forgotten Failed|Success First|Null [ LabelFather]"
318 proc TREE:Tree:DecodeNodeItem { TreeBrowser w dir nodeItem} {
321 global TREE_AttributeStyle
322 global TREE_AttributeStyle1
323 global TREE_AttributeStyle2
324 #puts "TREE:Tree:DecodeNodeItem"
327 set standardimage [tix getimage file]
328 set forgottenimage [tix getimage maximize]
329 set image $standardimage
331 # Information first split
332 set tmplist [split $nodeItem " "]
333 set labentry [lindex $tmplist 0]
334 set name [lindex $tmplist 1]
335 set type [lindex $tmplist 2]
336 #set exec [lindex $tmplist 3]
337 #set state [lindex $tmplist 4]
338 set children [lindex $tmplist 3]
339 set father [lindex $tmplist 4]
340 set first [lindex $tmplist 5]
341 set next [lindex $tmplist 6]
342 set previous [lindex $tmplist 7]
344 #puts "labentry : $labentry"
347 #puts "state : $state"
349 #puts "children : $children"
350 #puts "father : $father"
351 #puts "first : $first"
353 #puts "previous : $previous"
355 # Label entry , name & Dynamic type.
356 set ll [expr [string length $name] -2]
358 set textname "$labentry [string range $name 1 $ll] $type"
360 set textname "$labentry $type"
363 set locstyle $TREE_AttributeStyle
365 # Executable/Forgotten?
366 #if {$exec == "Forgotten"} {
367 #set textname "$textname $exec"
368 #set locstyle $TREE_AttributeStyle1
369 #set image $forgottenimage
372 # Failed/Success analysis.
373 #if {$state == "Failed"} {
374 #set textname "$textname $state"
375 #set locstyle $TREE_AttributeStyle2
379 if {$father != "Null"} {set textname "$textname Father=$father"}
381 if {$first != "Null"} {set textname "$textname First=$first"}
383 if {$next != "Null"} {set textname "$textname Next=$next"}
385 if {$previous != "Null"} {set textname "$textname Previous=$previous"}
387 $TREE_WINDOWS($w,NAV,hlist) add ${dir}^${labentry} \
388 -itemtype imagetext \
392 -data [list ${labentry} Node]
393 if {$children == "First"} {
394 $TREE_WINDOWS($w,NAV,tree) setmode ${dir}^${labentry} open
396 lappend litm [list $labentry $image]
400 ###############################################################################
403 proc TREE:Tree:terminal { TreeBrowser w dir } {
408 ###############################################################################
411 proc TREE:Tree:DisplayAttribute { TreeBrowser w dir } {
417 ###############################################################################
418 # imprime tout ce qu'il y a dans hli ( Hlist )
420 proc wokDBG { {root {}} } {
423 set w $TREE_GLOBALS(toplevel)
424 set hli $TREE_WINDOWS($w,NAV,hlist)
425 foreach c [$hli info children $root] {
426 puts "$c : data <[$hli info data $c]>"