source: tol/tolbase/lib/toltk/tolinspe__tolgui.tcl @ 820bb4e

1941-docker-image-to-testdevel
Last change on this file since 820bb4e was e0578ae, checked in by Pedro Gea <pgea@…>, 10 years ago

Refs #1933
Se modifica la definición de las columnas de los ::wtree

+ La del inspector (panel izquierdo): LNodeDef, LNode, Li<Field>
+ La del listado de objetos (panel derecho): RNodeDef, RNode, Ri<Field>

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@7334 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 12.9 KB
Line 
1
2#/////////////////////////////////////////////////////////////////////////////
3proc TclList2SetOfText { lst } {
4#/////////////////////////////////////////////////////////////////////////////
5  set result [ list ]
6  foreach i $lst {
7    lappend result \"[string map {\" \\\"} $i]\"
8  }
9  return "SetOfText([join $result ,])"
10}
11
12#/////////////////////////////////////////////////////////////////////////////
13proc Tol_GetViewPrivateMembers { } {
14#/////////////////////////////////////////////////////////////////////////////
15  set viewOpt 0
16  catch {
17    # no funciona
18    tol::console eval {
19      Real __getViewPrivateMembers_tmp__ =
20      TolConfigManager::Config::Various::View::PrivateMembers;
21    }
22    set x [ lindex [ tol::info variable { Real __getViewPrivateMembers_tmp__ } ] 2 ]
23    tol::console stack release __getViewPrivateMembers_tmp__
24    set viewOpt [ expr { int( $x ) } ]
25   
26  } msg
27  #puts "Tol_GetViewPrivateMembers: $msg"
28  return $viewOpt
29}
30
31#/////////////////////////////////////////////////////////////////////////////
32proc Tol_ObjIsClassOf { obj_addr cls_name } {
33#/////////////////////////////////////////////////////////////////////////////
34  tol::console eval [ string map [ list %A $obj_addr %C $cls_name ] {
35    Real __gui_check__ = IsInstanceOf( GetObjectFromAddress( "%A" ),"%C" )
36  } ]
37  set info [ tol::info variable {Real __gui_check__} ]
38  set x [ lindex $info 2 ]
39  tol::console stack release __gui_check__
40  expr { round($x) }
41}
42
43#/////////////////////////////////////////////////////////////////////////////
44proc Tol_ClassOf { obj_addr } {
45#/////////////////////////////////////////////////////////////////////////////
46  tol::console eval [ string map [ list %A $obj_addr ] {
47    Text __gui_classof__ = {
48      Anything obj = GetObjectFromAddress( "%A" );
49      // WriteLn( "Tol_ClassOf " << Grammar( obj ) );
50      Text If( Grammar( obj ) == "NameBlock", ClassOf( obj ), "" )
51    }
52  } ]
53  set info [ tol::info variable {Text __gui_classof__} ]
54  set x [ string trim [ lindex $info 2 ]  \" ]
55  tol::console stack release __gui_classof__
56  set x
57}
58
59#/////////////////////////////////////////////////////////////////////////////
60proc Tol_ClassOfFromReference { objReference } {
61#/////////////////////////////////////////////////////////////////////////////
62  set addr [ ::tol::info address $objReference ]
63  return [ Tol_ClassOf $addr ]
64}
65
66#/////////////////////////////////////////////////////////////////////////////
67proc Tol_StructOf { obj_addr } {
68#/////////////////////////////////////////////////////////////////////////////
69  set tolcode [ string map [ list %A $obj_addr ]  {
70    Text {
71      Anything obj = GetObjectFromAddress( "%A" );
72      // WriteLn( "Tol_StructOf " << Grammar( obj ) );
73      Text If( Grammar( obj ) == "Set", StructName( obj ), "" )
74    }
75  } ]
76  return [ lindex [ toltcl::eval $tolcode ] 0 ]
77}
78
79#/////////////////////////////////////////////////////////////////////////////
80proc Tol_StructOfFromReference { objReference } {
81#/////////////////////////////////////////////////////////////////////////////
82  # WATCH!!!!
83  # when Tol_StructOfFromReference is invoken on {File xxx} xxx is
84  # decompiled!!!!
85  if { [ llength $objReference ] == 2 &&
86       [ lindex $objReference 0 ] eq "File" } {
87    return ""
88  }
89  set addr [ ::tol::info address $objReference ]
90  return [ Tol_StructOf $addr ]
91}
92
93#/////////////////////////////////////////////////////////////////////////////
94#(pgea) nueva funcion para obtener la informacion de instancia
95proc Tol_InstanceInfo { obj_addr } {
96#/////////////////////////////////////////////////////////////////////////////
97  tol::console eval [ string map [ list %A $obj_addr ] {
98    Text __gui_instanceinfo__ = {
99      Anything __intance__ = GetObjectFromAddress("%A");
100      Text If(ObjectExist("Code", "__intance__::_.get.autodoc.info"),
101        __intance__::_.get.autodoc.info(?), "")
102    }
103  } ]
104  set info [ tol::info variable {Text __gui_instanceinfo__} ]
105  set x [ string trim [ lindex $info 2 ]  \" ]
106  tol::console stack release __gui_instanceinfo__
107  set x
108}
109
110#/////////////////////////////////////////////////////////////////////////////
111#(pgea) nueva funcion para obtener la informacion de instancia
112proc Tol_InstanceInfoFromReference { objReference } {
113#/////////////////////////////////////////////////////////////////////////////
114  set addr [ ::tol::info address $objReference ]
115  return [ Tol_InstanceInfo $addr ]
116}
117
118#/////////////////////////////////////////////////////////////////////////////
119#(pgea) nueva funcion para obtener el contenido de la instancia
120proc Tol_InstanceContent { obj_addr } {
121#/////////////////////////////////////////////////////////////////////////////
122  tol::console eval [ string map [ list %A $obj_addr ] {
123    Text __gui_instancecontent__ = {
124      Anything __intance__ = GetObjectFromAddress("%A");
125      Text If(ObjectExist("Code", "__intance__::_.get.autodoc.content"),
126        __intance__::_.get.autodoc.content(?), "")
127    }
128  } ]
129  set info [ tol::info variable {Text __gui_instancecontent__} ]
130  set x [ string trim [ lindex $info 2 ]  \" ]
131  tol::console stack release __gui_instancecontent__
132  set x
133}
134
135#/////////////////////////////////////////////////////////////////////////////
136#(pgea) nueva funcion para obtener el contenido de la instancia
137proc Tol_InstanceContentFromReference { objReference } {
138#/////////////////////////////////////////////////////////////////////////////
139  set addr [ ::tol::info address $objReference ]
140  return [ Tol_InstanceContent $addr ]
141}
142
143#/////////////////////////////////////////////////////////////////////////////
144proc TolGui_GetMenuEntries { selection idx } {
145#/////////////////////////////////////////////////////////////////////////////
146  #puts "TolGui_GetMenuEntries $selection $idx"
147  array set instances {}
148  array set menu_class {}
149  set i 0
150  foreach obj_info $selection {
151    set tcl_ref [ lindex $obj_info 0 ]
152    set obj_addr [ ::tol::info address $tcl_ref ]
153    if { [ Tol_ObjIsClassOf $obj_addr "GuiTools::@MenuDesc" ] } {
154      set class [ Tol_ClassOf $obj_addr ]
155      lappend instances($class) $obj_addr
156      set name_inst [ lindex $obj_info 1 ]
157      set menu_items [ TolGui_GetObjMenu $obj_addr ]
158      # esto hace que estemos guardando la ultima instancia, asumimos
159      # tambien que todas las instancia tienen la misma espcificacion
160      # de menu
161      if { ![ llength [ array names menu_class $class ] ] || $i == $idx } {
162        set menu_class($class) \
163            [ list $name_inst $obj_addr $menu_items ]
164      }
165    }
166    incr i
167  }
168  set menu_info [ list ]
169  foreach c [ array names instances ] {
170    lappend menu_info [ list $c $menu_class($c) $instances($c) ]
171  }
172  #puts "$menu_info"
173  set menu_info
174}
175
176#/////////////////////////////////////////////////////////////////////////////
177proc TolGui_StoreSetElementsInOZA { object } {
178#/////////////////////////////////////////////////////////////////////////////
179  set saveIn [ tk_getSaveFile -defaultextension .oza \
180                   -parent . -title [ mc "Store OZA" ] \
181                   -filetypes {{oza {.oza}}} ]
182
183  if { $saveIn ne "" } {
184    set addr [ tol::info address $object ]
185    set tolexpr [ string map [ list %a $addr %f $saveIn ] {
186      Real Ois.Store( GetObjectFromAddress( "%a" ), "%f" );
187    } ]
188    toltcl::eval $tolexpr
189  }
190}
191
192#/////////////////////////////////////////////////////////////////////////////
193proc TolGui_StoreSelectionInOZA { selection } {
194#/////////////////////////////////////////////////////////////////////////////
195  set saveIn [ tk_getSaveFile -defaultextension .oza \
196                   -parent . -title [ mc "Store OZA" ] \
197                   -filetypes {{oza {.oza}}} ]
198  if { $saveIn ne "" } {
199    set lst_addr {}
200    foreach r $selection {
201      set a [ tol::info address $r ]
202      lappend lst_addr \"$a\"
203    }
204    set set_addr "\[\[ [join $lst_addr ,] \]\]"
205    set tolexpr [ string map [ list %L $set_addr %f $saveIn ] {
206      Real {
207        Set items = EvalSet( %L, Anything( Text addr ) {
208          Anything GetObjectFromAddress( addr )
209        } );
210        Real Ois.Store( items, "%f" )
211      }
212    } ]
213    toltcl::eval $tolexpr
214  }
215}
216
217#/////////////////////////////////////////////////////////////////////////////
218proc TolGui_InsertEntriesMatrixChart { mm selection } {
219#/////////////////////////////////////////////////////////////////////////////
220  if {  ![ llength $selection ] } {
221    return 0
222  }
223  set lst_addr {}
224  foreach r $selection {
225    set a [ tol::info address $r ]
226    lappend lst_addr \"$a\"
227  }
228  set set_addr "\[\[ [join $lst_addr ,] \]\]"
229  set tolexpr [ string map [ list %L $set_addr ] {
230    Real {
231      Set all_mat = EvalSet( %L, Matrix( Text addr ) {
232        GetObjectFromAddress( addr )
233      } );
234      Real R = Rows( all_mat[1] );
235      Set st = EvalSet( all_mat, Real( Matrix it ) {
236        Real EQ( R, Rows( it ) )
237      } );
238      Real BinGroup( "And", st )
239    }
240  } ]
241  set couldChart [ toltcl::eval $tolexpr ]
242  if { $couldChart } {
243    $mm add command -label [ mc "Draw matrix selection (natural)" ] \
244        -command [ list TolGui_ChartMatrix $selection ]
245  }
246}
247
248#/////////////////////////////////////////////////////////////////////////////
249proc TolGui_ChartMatrix { selection } {
250#/////////////////////////////////////////////////////////////////////////////
251  set lst_addr {}
252  foreach r $selection {
253    set a [ tol::info address $r ]
254    lappend lst_addr \"$a\"
255  }
256  set set_addr "\[\[ [join $lst_addr ,] \]\]"
257  set tolexpr [ string map [ list %L $set_addr ] {
258    Real {
259      Set all_mat = EvalSet( %L, Matrix( Text addr ) {
260        GetObjectFromAddress( addr )
261      } );
262      Set names = Copy( Empty );
263      Set For( 1, Card( all_mat ), Real( Real k ) {
264        Text _n = Name( all_mat[ k ] );
265        Text n = If( _n == "", "unamed", _n );
266        Set Append( names, If( Columns( all_mat[ k ] ) == 1, [[ n ]], {
267          Set For( 1, Columns( all_mat[ k ] ), Text( Real k ) {
268            Text n << "[" << k << "]"
269          } )
270        } ) );
271        Real 1
272      } );
273      Matrix groupMat = BinGroup( "|", all_mat );
274      Text TclChartMatrix( groupMat,
275                           SetOfSet (
276                                     @TclArgSt("-title",    "Matrix Chart" ),
277                                     @TclArgSt("-type"    , "2"            ),
278                                     @TclArgSt("-names",    TxtListTcl(names) ) ) )
279    }
280  } ]
281  toltcl::eval $tolexpr
282}
283
284#/////////////////////////////////////////////////////////////////////////////
285proc TolGui_InsertEntriesFromMenuManager { targetMenu selection } {
286#/////////////////////////////////////////////////////////////////////////////
287  set addrList [ list ]
288  foreach obj_info $selection {
289    set tcl_ref [ lindex $obj_info 0 ]
290    lappend addrList [ ::tol::info address $tcl_ref ]
291  }
292  ::MenuManager::insertEntriesForSelection $targetMenu $addrList
293}
294
295#/////////////////////////////////////////////////////////////////////////////
296proc TolGui_GetObjMenu { obj_addr } {
297#/////////////////////////////////////////////////////////////////////////////
298  set try [ catch {
299    tol::console eval [ string map [ list %A $obj_addr ] {
300      GuiTools::@MenuDesc __aux_menu__ = GetObjectFromAddress("%A");
301      Set __gui_menu_entries__ = __aux_menu__::getMenuEntries(?)
302    } ] } msg ]
303  if { $try } {
304    puts "ERROR TolGui_GetObjMenu : $msg"
305    set result ""
306  } else {
307    set result [ TolObj2TclObj {Set __gui_menu_entries__} ]
308  }
309  tol::console stack release __aux_menu__
310  tol::console stack release __gui_menu_entries__
311  set result
312}
313
314#/////////////////////////////////////////////////////////////////////////////
315proc TolGui_InvokeMethod { method obj_addr } {
316#/////////////////////////////////////////////////////////////////////////////
317  #puts "TolGui_InvokeMethod $method $obj_addr"
318  set try [ catch {
319    tol::console eval [ string map [ list %A $obj_addr %M $method ] {
320      NameBlock __aux_instance__ = GetObjectFromAddress("%A");
321      Real __aux_result__ = __aux_instance__::%M(?)
322    } ] } msg ]
323  if { $try } {
324    puts "ERROR TolGui_InvokeMethod : $msg"
325  }
326  tol::console stack release __aux_instance__
327  tol::console stack release __aux_result__
328}
329
330#/////////////////////////////////////////////////////////////////////////////
331proc TolGui_InvokeGroup { cname function group } {
332#/////////////////////////////////////////////////////////////////////////////
333  set SOA [ TclList2SetOfText $group ]
334  set try [ catch {
335    tol::console eval \
336        [ string map [ list %C $cname %F $function %S $SOA ] {
337          Real __aux_result__ = {
338            Set aux = EvalSet( %S, NameBlock( Text addr ) {
339              NameBlock GetObjectFromAddress( addr )
340            } );
341            Real %C::%F( aux )
342          }
343        } ] } msg ]
344  if { $try } {
345    puts "ERROR TolGui_InvokeGroup : $msg"
346  }
347  tol::console stack release __aux_result__
348}
Note: See TracBrowser for help on using the repository browser.