Package Pmv :: Module gridCommands
[hide private]
[frames] | no frames]

Source Code for Module Pmv.gridCommands

  1  ############################################################################# 
  2  # 
  3  # Author: Shanrong Zhao, Ruth HUEY, Michel F. SANNER 
  4  # 
  5  # Copyright: M. Sanner TSRI 2000 
  6  # 
  7  ############################################################################# 
  8   
  9  # 
 10  # $Header: /opt/cvs/python/packages/share1.5/Pmv/gridCommands.py,v 1.26 2006/07/17 22:33:35 sargis Exp $ 
 11  # 
 12  # $Id: gridCommands.py,v 1.26 2006/07/17 22:33:35 sargis Exp $ 
 13  # 
 14   
 15  """ 
 16  This Module implements commands  
 17      to read grid data,  
 18      to visualize isosurfaces, 
 19      to manipulate orthoslices through the isosurfaces... 
 20    
 21  """ 
 22  from ViewerFramework.VFCommand import CommandGUI 
 23  ##  from ViewerFramework.gui import InputFormDescr 
 24  from mglutil.gui.InputForm.Tk.gui import InputFormDescr 
 25   
 26  from mglutil.util.callback import CallBackFunction 
 27   
 28  from Pmv.mvCommand import MVCommand 
 29  import types,string,Tkinter,Numeric, math, os 
 30  import Pmw 
 31   
 32  from DejaVu import Texture 
 33  from DejaVu.extendedSlider import ExtendedSlider 
 34  import Numeric 
 35  from DejaVu.colorTool import Map, RGBRamp, array2DToImage 
 36  from DejaVu.bitPatterns import patternList 
 37   
 38  from Pmv import Grid 
 39   
 40   
41 -class GridReader(MVCommand):
42 """ Command to load grid data files, creating a 'Grid' object 43 \nPackage : Pmv 44 \nModule : GridCommands 45 \nClass : GridReader 46 \nCommand : readGRID 47 \nSynopsis:\n 48 None <--- readGRID(gridFile, **kw) 49 \nRequired Arguments:\n 50 gridFile --- path to the grid data file 51 """ 52 53
54 - def onAddCmdToViewer(self):
55 if not hasattr(self.vf, 'grids'): 56 self.vf.grids={}
57 58
59 - def __call__(self, gridFile, **kw):
60 """None <--- readGRID(gridFile, **kw) 61 \ngridFile --- path to the grid data file""" 62 apply(self.doitWrapper, (gridFile,), kw)
63 64
65 - def doit(self, gridFile):
66 grid = Grid.Grid(gridFile) 67 #NB:a Grid knows its: 68 # array 69 # base 70 # min 71 # max 72 # typecode 73 # name...string.split(str(self.__class__))[0] 74 # and MAYBE: 75 # SPACING=1.0 76 # CENTER= (0.,0.,0.) 77 grid.name = gridFile 78 if self.vf.grids.has_key(gridFile): 79 msg = "grid from " + gridFile + " already present in viewer" 80 self.warningMsg(msg) 81 return 'ERROR' 82 self.vf.grids[gridFile] = grid 83 #one grid, one surface...? 84 grid.srf=None
85 #FIX THIS: what about atType(?) 86 87
88 - def guiCallback(self):
89 """called each time the 'read ->Grid' sequence is pressed""" 90 gridFile = self.vf.askFileOpen(types=[('grid data files', '*.*')], 91 title = 'Grid File:') 92 if gridFile is not None and len(gridFile): 93 self.doitWrapper(gridFile, redraw=0)
94 95 96 gridReaderGuiDescr = {'widgetType':'Menu', 'menuBarName':'menuRoot', 97 'menuButtonName':'Grid', 'menuEntryLabel':'Grid', 98 'menuCascadeName':'read'} 99 100 101 GridReaderGUI = CommandGUI() 102 GridReaderGUI.addMenuCommand('menuRoot', 'Grid', 'Grid', cascadeName='read') 103 104 105 106
107 -class AutoGridReader(MVCommand):
108 """ Command to load autogrid data files, creating an 'AutoGrid' object 109 \nPackage : Pmv 110 \nModule : GridCommands 111 \nClass : AutoGridReader 112 \nCommand : readAUTOGRID 113 \nSynopsis:\n 114 None <- readAUTOGRID(gridFile, **kw) 115 \nRequired Arguments:\n 116 gridFile --- path to the autogrid data file 117 """ 118 119
120 - def onAddCmdToViewer(self):
121 if not hasattr(self.vf, 'grids'): 122 self.vf.grids={}
123 124
125 - def __call__(self, gridFile, **kw):
126 """None <- readAUTOGRID(gridFile, **kw) 127 \ngridFile --- path to the autogrid data file""" 128 apply(self.doitWrapper, (gridFile,), kw)
129 130
131 - def doit(self, gridFile):
132 grid = Grid.AutoGrid(gridFile) 133 curdir = os.getcwd() 134 griddir = os.path.dirname(gridFile) 135 if curdir==griddir: 136 gridFile = os.path.basename(gridFile) 137 grid.name = gridFile 138 #NB:an AutoGrid knows stuff Grid knows AND its: 139 # GRID_PARAMETER_FILE 140 # GRID_DATA_FILE 141 # MACROMOLECULE 142 # SPACING 143 # NELEMENTS 144 # CENTER 145 if self.vf.grids.has_key(gridFile): 146 msg = "grid from " + gridFile + " already present in viewer" 147 self.warningMsg(msg) 148 return 'ERROR' 149 self.vf.grids[gridFile] = grid 150 fname = os.path.basename(gridFile) 151 atType = string.split(fname, '.')[-2] 152 grid.atType = atType 153 #one grid, one surface...? 154 grid.srf=None
155 156
157 - def guiCallback(self):
158 """called each time the 'read ->AutoGrid' sequence is pressed""" 159 gridFile = self.vf.askFileOpen(types=[('autogrid data files', '*.map')], 160 title = 'AutoGrid File:') 161 if gridFile is not None and len(gridFile): 162 self.doitWrapper(gridFile, redraw=0)
163 164 165 autoGridReaderGuiDescr = {'widgetType':'Menu', 'menuBarName':'menuRoot', 166 'menuButtonName':'Grid', 'menuEntryLabel':'AutoGrid', 167 'menuCascadeName':'read'} 168 169 170 AutoGridReaderGUI = CommandGUI() 171 AutoGridReaderGUI.addMenuCommand('menuRoot', 'Grid', 'AutoGrid', cascadeName='read') 172
173 -class DXReader(MVCommand):
174 """ Command to load autogrid data files, creating an 'AutoGrid' object 175 \nPackage : Pmv 176 \nModule : GridCommands 177 \nClass : AutoGridReader 178 \nCommand : readAUTOGRID 179 \nSynopsis:\n 180 None <- readAUTOGRID(gridFile, **kw) 181 \nRequired Arguments:\n 182 gridFile --- path to the autogrid data file 183 """ 184
185 - def onAddCmdToViewer(self):
186 if not hasattr(self.vf, 'grids'): 187 self.vf.grids={}
188 189
190 - def __call__(self, gridFile, **kw):
191 """None <- readAUTOGRID(gridFile, **kw) 192 \ngridFile --- path to the autogrid data file""" 193 apply(self.doitWrapper, (gridFile,), kw)
194 195
196 - def doit(self, gridFile):
197 grid = Grid.DX(gridFile) 198 curdir = os.getcwd() 199 griddir = os.path.dirname(gridFile) 200 if curdir==griddir: 201 gridFile = os.path.basename(gridFile) 202 grid.name = gridFile 203 #NB:an AutoGrid knows stuff Grid knows AND its: 204 # GRID_PARAMETER_FILE 205 # GRID_DATA_FILE 206 # MACROMOLECULE 207 # SPACING 208 # NELEMENTS 209 # CENTER 210 if self.vf.grids.has_key(gridFile): 211 msg = "grid from " + gridFile + " already present in viewer" 212 self.warningMsg(msg) 213 return 'ERROR' 214 self.vf.grids[gridFile] = grid 215 fname = os.path.basename(gridFile) 216 atType = string.split(fname, '.')[-2] 217 grid.atType = atType 218 #one grid, one surface...? 219 grid.srf=None
220 221
222 - def guiCallback(self):
223 """called each time the 'read ->AutoGrid' sequence is pressed""" 224 gridFile = self.vf.askFileOpen(types=[('autogrid data files', '*.dx')], 225 title = 'AutoGrid File:') 226 if gridFile is not None and len(gridFile): 227 self.doitWrapper(gridFile, redraw=0)
228 229 230 DXReaderGUI = CommandGUI() 231 DXReaderGUI.addMenuCommand('menuRoot', 'Grid', 'Open DX', cascadeName='read') 232 233
234 -class DeleteAutoGrid(MVCommand):
235 """ Command to remove an 'AutoGrid' object and its geometries, if any 236 \nPackage : Pmv 237 \nModule : GridCommands 238 \nClass : DeleteAutoGrid 239 \nCommand : deleteAUTOGRID 240 \nSynopsis:\n 241 None <--- deleteAUTOGRID(gridName, **kw) 242 \nRequired Arguments:\n 243 gridName --- key for autogrid_to_delete in self.vf.grids 244 """ 245 246
247 - def onAddCmdToViewer(self):
248 if not hasattr(self.vf, 'grids'): 249 self.vf.grids={}
250 251
252 - def __call__(self, gridName, **kw):
253 """None <- deleteAUTOGRID(gridName, **kw) 254 \ngridName --- key for autogrid_to_delete in self.vf.grids""" 255 if not self.vf.grids.has_key(gridName): 256 msg = gridName + " not found in mv.grids " 257 self.warningMsg(msg) 258 return "ERROR" 259 apply(self.doitWrapper, (gridName,), kw)
260 261
262 - def doit(self, gridName):
263 grid = self.vf.grids.pop(gridName) 264 if hasattr(grid, 'surfaceGUI'): 265 #print "deleting ", gridName, ".surfaceGUI" 266 #the box: 267 #grid.box.Set(protected = False) 268 grid.box.protected = False 269 self.vf.GUI.VIEWER.RemoveObject(grid.box) 270 delattr(grid, 'box') 271 grid.surfaceGUI.delete_all_widgets() 272 delattr(grid, 'surfaceGUI') 273 #what about other guis which might be open? 274 if hasattr(grid, 'sliceGUI'): 275 #print "deleting ", gridName, ".slices" 276 self.vf.getOrthoSlice.Close_cb() 277 for k,v in grid.slices.items(): 278 print " in dimension: ", k 279 for geom in v: 280 #geom.Set(protected = False) 281 geom.protected = False 282 self.vf.GUI.VIEWER.RemoveObject(geom) 283 grid.sliceGUI.delete_all_widgets() 284 delattr(grid, 'slices') 285 #grid.srf.Set(protected = False) 286 if hasattr(grid, 'srf'): 287 #print "deleting ", gridName, ".srf" 288 if grid.srf: 289 grid.srf.protected = False 290 self.vf.GUI.VIEWER.RemoveObject(grid.srf) 291 292 delattr(grid, 'srf') 293 del(grid) 294 #possibly close the guis from cmds (?) 295 self.vf.GUI.VIEWER.Redraw()
296 297
298 - def guiCallback(self):
299 """called each time the 'read ->AutoGrid' sequence is pressed""" 300 objList=[] 301 if len(self.vf.grids.keys())==0: 302 t='no grids currently in viewer' 303 self.warningMsg(t) 304 return 305 for item in self.vf.grids.keys(): 306 if item not in objList: 307 objList.append(item) 308 if len(objList)==0: 309 gridName = objList[0] 310 else: 311 #NEED TO PICK THE GRID.... 312 ifd2 = InputFormDescr(title='Choose Grid') 313 ifd2.append({'widgetType':'ListChooser', 314 'name':'gridObjs', 315 'entries':objList, 316 'wcfg':{'title':'Pick grid', 317 'mode':'single'}, 318 'lbwcfg':{'height':4}, 319 'gridcfg':{'sticky':'wens', 'column':100, 320 'rowspan':10}}) 321 val = self.vf.getUserInput(ifd2) 322 if val is not None and len(val)>0 and len(val['gridObjs'])>0: 323 gridName = val['gridObjs'][0] 324 else: 325 return 326 return self.doitWrapper(gridName, redraw=0)
327 328 329 deleteAutoGridGUIDescr = {'widgetType':'Menu', 'menuBarName':'menuRoot', 330 'menuButtonName':'Grid', 'menuEntryLabel':'AutoGrid', 331 'menuCascadeName':'delete'} 332 333 334 DeleteAutoGridGUI = CommandGUI() 335 DeleteAutoGridGUI.addMenuCommand('menuRoot', 'Grid', 'delete') 336 337 338
339 -class AutoGridIsoSurface(MVCommand):
340 """ Command to create:an isosurface for a 'Grid' object ,a bounding box of the grid,and a GUI to manipulate the srf and the visibility of the box . 341 \nPackage : Pmv 342 \nModule : GridCommands 343 \nClass : AutoGridIsoSurface 344 \nCommand : getIsosurface 345 \nSynopsis:\n 346 None <- getIsosurface(grid, **kw) 347 \nRequired Arguments:\n 348 grid --- grid object 349 """ 350 351
352 - def onAddCmdToViewer(self):
353 self.srfs = {} 354 if not self.vf.commands.has_key('getOrthoSlice'): 355 self.vf.loadCommand('gridCommands', 'getOrthoSlice', 'Pmv', 356 topCommand=0) 357 if not self.vf.commands.has_key('setIsovalue'): 358 self.vf.loadCommand('gridCommands', 'setIsovalue', 'Pmv', 359 topCommand=0)
360 361
362 - def buildForm(self):
363 ifd = self.ifd = InputFormDescr(title = 'Visualize Grids') 364 ifd.append({'widgetType': Tkinter.Label, 365 'text':'Display Map', 366 'wcfg':{'bd':6}, 367 'gridcfg':{'sticky':Tkinter.W}}) 368 ifd.append({'widgetType': Tkinter.Label, 369 'text':'Sampling', 370 'gridcfg':{'sticky':Tkinter.W, 'row':-1,'column':1}}) 371 ifd.append({'widgetType': Tkinter.Label, 372 'text':'IsoValue', 373 'wcfg':{'bd':6}, 374 'gridcfg':{'sticky':Tkinter.W+Tkinter.E, 375 'row':-1,'column':2,'columnspan':2}}) 376 ifd.append({'widgetType': Tkinter.Label, 377 'text':'RenderMode', 378 'wcfg':{'bd':6}, 379 'gridcfg':{'sticky':Tkinter.W, 'row':-1,'column':4}}) 380 ifd.append({'name': 'closeB', 381 'widgetType': Tkinter.Button, 382 'text':'Close', 383 'wcfg':{'bd':4}, 384 'gridcfg':{'sticky':Tkinter.E+Tkinter.W, 'columnspan':6, 'row': 100, 'column':0}, 385 'command':self.Close_cb}) 386 self.form = self.vf.getUserInput(ifd, modal=0, blocking = 0) 387 self.form.root.protocol('WM_DELETE_WINDOW',self.Close_cb)
388 389
390 - def guiCallback(self):
391 objList=[] 392 if len(self.vf.grids.keys())==0: 393 t='no grids currently in viewer' 394 self.warningMsg(t) 395 return 396 for item in self.vf.grids.keys(): 397 if item not in objList and not self.vf.grids[item].srf: 398 objList.append(item) 399 if not hasattr(self, 'ifd'): 400 self.buildForm() 401 else: 402 self.form.deiconify() 403 if len(objList)>0: 404 #NEED TO PICK THE GRID.... 405 ifd2 = InputFormDescr(title='Choose Grid') 406 ifd2.append({'widgetType':'ListChooser', 407 'name':'gridObjs', 408 'entries':objList, 409 'wcfg':{'title':'Pick grid', 410 'mode':'single'}, 411 'lbwcfg':{'height':4}, 412 'gridcfg':{'sticky':'wens', 'column':100, 413 'rowspan':10}}) 414 val = self.vf.getUserInput(ifd2) 415 if val is not None and len(val)>0 and len(val['gridObjs'])>0: 416 filename = val['gridObjs'][0] 417 grid = self.vf.grids[filename] 418 return self.doitWrapper(filename, redraw=1)
419
420 - def Close_cb(self, event=None):
421 self.form.withdraw()
422 423
424 - def __call__(self, grid, **kw):
425 """None <- getIsosurface(grid, **kw) 426 grid --- grid object 427 """ 428 return apply(self.doitWrapper, (grid,), kw)
429 430
431 - def mouseUp(self, grid, event=None):
432 self.vf.setIsovalue(grid.name, grid.surfaceGUI.slider.get())
433 434
435 - def doit(self, grid):
436 if type(grid)==types.StringType: 437 grid = self.vf.grids[grid] 438 if grid.srf: 439 msg= "this grid already has a surface" 440 self.warningMsg(msg) 441 return 'ERROR' 442 if not hasattr(self, 'ifd'): 443 #for the moment, set this grid's srf 444 grid.srf = 1 445 self.guiCallback() 446 grid.srf = None 447 Grid.AutoGridSurfaceGui(grid,self.vf) 448 grid.surfaceGUI.makeIfdEntry(self.ifd,['closeB']) 449 value = grid.surfaceGUI.slider.get() 450 grid.surfaceGUI.slider.draw.bind('<ButtonRelease-1>', CallBackFunction(self.mouseUp, grid), add='+') 451 #grid.surfaceGUI.slider.AddCallback('<ButtonRelease-1>', CallBackFunction(self.mouseUp, grid)) 452 self.vf.GUI.VIEWER.Normalize_cb() 453 return grid
454 455 456 autoGridIsoSurfaceguiDescr = {'widgetType':'Menu', 'menuBarName':'menuRoot', 457 'menuButtonName':'Grid', 'menuEntryLabel':'get surface'} 458 459 460 AutoGridIsoSurfaceGUI = CommandGUI() 461 AutoGridIsoSurfaceGUI.addMenuCommand('menuRoot','Grid', 'get surface') 462 463 464
465 -class SetIsovalue(MVCommand):
466 """command called to log a change in isovalue for a isocontour 467 \nPackage : Pmv 468 \nModule : GridCommands 469 \nClass : SetIsovalue 470 \nCommand : setIsovalue 471 \nSynopsis:\n 472 None <--- setIsovalue(grid, value) 473 \nRequired Arguments:\n 474 grid_name --- AutoGrid.name\n 475 value --- float value of grid.surfaceGUI.slider 476 """ 477
478 - def __call__(self, grid_name, value, **kw):
479 """ None <--- setIsovalue(grid, value) 480 \ngrid_name --- AutoGrid.name 481 \nvalue --- float value of grid.surfaceGUI.slider 482 """ 483 apply(self.doitWrapper, (grid_name, value), kw)
484 485
486 - def doit(self, grid_name, value):
487 if self.vf.grids.has_key(grid_name): 488 grid = self.vf.grids[grid_name] 489 if not hasattr(grid, 'surfaceGUI'): 490 #create it here... 491 self.vf.getIsosurface(grid.name) 492 grid.surfaceGUI.slider.set(value) 493 else: 494 t='grids %s not currently in viewer'%grid_name 495 self.warningMsg(t) 496 return 'ERROR'
497
498 -class GetOrthoSlice(MVCommand):
499 """Allows the user to see a slice through a set of volume data 500 \nPackage : Pmv 501 \nModule : GridCommands 502 \nClass : GetOrthoSlice 503 \nCommand : getOrthoSlice 504 \nSynopsis:\n 505 None <- getOrthoSlice(axis, **kw) 506 """ 507 508
509 - def onAddCmdToViewer(self):
510 self.slices = {} 511 self.axisVars = {} 512 self.vvars = {} 513 self.scales = {}
514 515
516 - def __call__(self, axis, **kw):
517 """None <- getOrthoSlice(axis, **kw) 518 """ 519 apply(self.doitWrapper, (axis,), kw)
520 521
522 - def doit(self, axis):
523 if not hasattr(self, 'ifd'): 524 self.guiCallback() 525 self.addAxisSlice(axis)
526 527
528 - def forgetWidgets(self,grid):
529 if not hasattr(grid, 'widgets'): return 530 for item in grid.widgets: 531 if hasattr(item, 'frame'): item.frame.grid_forget() 532 else: item.grid_forget()
533 534
535 - def gridWidgets(self,grid):
536 if not hasattr(grid, 'widgets'): return 537 for i in range(len(grid.widgets)): 538 if isinstance(grid.widgets[i], ExtendedSlider): 539 grid.widgets[i].frame.grid(grid.gcfgs[i]) 540 else: 541 grid.widgets[i].grid(grid.gcfgs[i])
542 543
544 - def changeGrid(self, event=None):
545 lb=self.ifd.entryByName['gridObjs']['widget'].lb 546 if len(lb.curselection()): 547 gridentry=lb.get(lb.curselection()[0]) 548 newgrid = self.vf.grids[gridentry] 549 for item in self.vf.grids.values(): 550 if hasattr(item, 'widgets'): 551 self.forgetWidgets(item) 552 self.gridWidgets(newgrid) 553 self.showAll.set(0)
554 555
556 - def addAxisSlice(self, axis):
557 lb=self.ifd.entryByName['gridObjs']['widget'].lb 558 if len(lb.curselection()): 559 gridentry=lb.get(lb.curselection()[0]) 560 grid = self.vf.grids[gridentry] 561 if not hasattr(grid, 'surfaceGUI'): 562 if not hasattr(self.vf.getIsosurface, 'ifd'): 563 self.vf.getIsosurface.buildForm() 564 self.vf.getIsosurface(grid) 565 if self.vf.getIsosurface.form.root.winfo_ismapped(): 566 self.vf.getIsosurface.Close_cb() 567 if not hasattr(grid, 'sliceGUI'): 568 Grid.AutoGridSliceGui(grid,self.vf) 569 grid.sliceGUI.makeIfdEntry(axis,self.ifd,[['addX','addY','addZ'],['closeB']]) 570 #need this to make sure the line above finishes before the next 571 print ' ' 572 grid.sliceGUI.addSlice(axis) 573 else: 574 self.warningMsg("Please select a grid,first!")
575 576
577 - def guiCallback(self):
578 objList=[] 579 if len(self.vf.grids.keys())==0: 580 t='no grids currently in viewer' 581 self.warningMsg(t) 582 return 583 for item in self.vf.grids.keys(): 584 if not self.vf.grids[item].srf: 585 continue 586 if item not in objList: 587 objList.append(item) 588 if len(objList)==0: 589 t='no grids with surfaces currently in viewer' 590 self.warningMsg(t) 591 return 592 if not hasattr(self, 'ifd'): 593 self.axisType=Tkinter.StringVar() 594 self.axisType.set('x') 595 self.showAll=Tkinter.IntVar() 596 self.showAll.set(1) 597 ifd = self.ifd = InputFormDescr(title = 'Visualize OrthoSlices') 598 ifd.append({'widgetType':'ListChooser', 599 'name':'gridObjs', 600 'title':"Current Grid:", 601 'entries':objList, 602 'wcfg':{'title':'Current grid', 603 'mode':'single'}, 604 'lbwcfg':{'height':4}, 605 'gridcfg':{'sticky':'w', 'columnspan': 10,'column':0, 606 'rowspan':10}}) 607 ifd.append({'name':'showAll', 608 'widgetType':Tkinter.Checkbutton, 609 'text':'Show all widgets', 610 'variable':self.showAll, 611 'gridcfg':{'sticky':'we', 'row':-1, 612 'column':2, 'columnspan':2}, 613 'command': self.gridAll}) 614 ifd.append({'widgetType': Tkinter.Label, 615 'text':'Display Slice\n(Grid_Axis#)', 616 'wcfg':{'bd':6}, 617 'gridcfg':{'sticky':'w' }}) 618 ifd.append({'widgetType': Tkinter.Label, 619 'text':'Slice Number', 620 'wcfg':{'bd':6}, 621 'gridcfg':{'sticky':'we', 'row':-1, 622 'column':2, 'columnspan':2}}) 623 ifd.append({'name': 'addX', 624 'widgetType': Tkinter.Button, 625 'text':'add x slice', 626 'wcfg':{'bd':4}, 627 'gridcfg':{'sticky':'we', 'row': 99, 'column':0}, 628 'command':CallBackFunction(self.addAxisSlice,'x')}) 629 ifd.append({'name': 'addY', 630 'widgetType': Tkinter.Button, 631 'text':'add y slice', 632 'wcfg':{'bd':4}, 633 'gridcfg':{'sticky':'we', 'row': -1, 'column':1}, 634 'command':CallBackFunction(self.addAxisSlice,'y')}) 635 ifd.append({'name': 'addZ', 636 'widgetType': Tkinter.Button, 637 'text':'add z slice', 638 'wcfg':{'bd':4}, 639 'gridcfg':{'sticky':'we', 'row': -1, 'column':2}, 640 'command':CallBackFunction(self.addAxisSlice,'z')}) 641 ifd.append({'name': 'closeB', 642 'widgetType': Tkinter.Button, 643 'text':'Close', 644 'wcfg':{'bd':4}, 645 'gridcfg':{'sticky':'we', 'columnspan':6, 'row': 100, 'column':0}, 646 'command':self.Close_cb}) 647 self.form = self.vf.getUserInput(ifd, modal=0, blocking = 0) 648 self.form.root.protocol('WM_DELETE_WINDOW',self.Close_cb) 649 self.lb = self.ifd.entryByName['gridObjs']['widget'].lb 650 self.lb.bind('<Double-Button-1>',self.changeGrid) 651 else: 652 if hasattr(self, 'form'): 653 #first update lb here 654 self.lb.delete(0, 'end') 655 for item in objList: 656 self.lb.insert('end', item) 657 self.form.deiconify()
658 659
660 - def gridAll(self):
661 itemList = self.vf.grids.values() 662 if self.showAll.get(): 663 #for item in self.vf.grids.values(): 664 for item in itemList: 665 self.gridWidgets(item) 666 else: 667 for item in itemList: 668 self.forgetWidgets(item)
669 670
671 - def Close_cb(self, event=None):
672 self.form.withdraw()
673 674
675 - def CallBack(self,scalekey,event=None):
676 scale=self.scales[scalekey] 677 val=scale.get() 678 g = scale.grd 679 axis = scale.axis 680 num = int(scale.num[1:]) 681 self.moveSlice(g,axis,int(val), scale.num) 682 self.vf.GUI.VIEWER.Redraw()
683 684 685 getOrthoSliceGuiDescr = {'widgetType':'Menu', 'menuBarName':'menuRoot', 686 'menuButtonName':'Grid', 'menuEntryLabel':'get ortho slice'} 687 688 GetOrthoSliceGUI= CommandGUI() 689 GetOrthoSliceGUI.addMenuCommand('menuRoot','Grid', 'get ortho slice') 690 691 692 commandList = [ 693 {'name':'readAUTOGRID','cmd':AutoGridReader(),'gui':AutoGridReaderGUI}, 694 {'name':'readDX','cmd':DXReader(),'gui':DXReaderGUI}, 695 #{'name':'readGRID','cmd':GridReader(),'gui':GridReaderGUI}, 696 {'name':'getIsosurface','cmd':AutoGridIsoSurface(),'gui':AutoGridIsoSurfaceGUI}, 697 {'name':'getOrthoSlice','cmd':GetOrthoSlice(),'gui':GetOrthoSliceGUI}, 698 {'name':'deleteAUTOGRID','cmd':DeleteAutoGrid(),'gui':DeleteAutoGridGUI}, 699 {'name':'setIsovalue','cmd':SetIsovalue(),'gui':None}, 700 ] 701 702 703
704 -def initModule(vf):
705 706 for dict in commandList: 707 vf.addCommand(dict['cmd'],dict['name'],dict['gui'])
708