Package client :: Package Dock :: Module Transforms
[hide private]
[frames] | no frames]

Source Code for Module client.Dock.Transforms

  1  """ 
  2  Overview 
  3  ======== 
  4  This module provides the specific Dock Widgets used for functions in the Basin Remote's I{Transformation} package. 
  5  These Dock Widget implementations provide an interface for selecting input data and designating output for the 
  6  individual functions. 
  7  """ 
  8   
  9  import PyQt4.QtCore 
 10  import PyQt4.QtGui 
 11   
 12  import Constants 
 13  import DataGuesser 
 14  import Widget 
 15  import Holders 
 16   
17 -class AbstractTransform (Widget.DockWidget):
18 """ 19 Overview 20 ======== 21 This class is essentially a virtual class, in that it really should never be instantiated, but rather 22 further derived into more useful classes. The way in which it works is by creating a generic template 23 that works for virtually all of the transformation fucntions. It does require that the derived versions 24 of this class setup a number of member variables before they use the constructor of AbstractTransform. 25 """ 26
27 - def __init__ (self, parent, bridge):
28 """ 29 Overview 30 ======== 31 This constructor simply sets the type of the package to "Transformation", after which it 32 runs the L{DockWidget<client.Dock.Widget.DockWidget>}'s constructor. 33 """ 34 35 self._type = "Transformation" 36 Widget.DockWidget.__init__ (self, parent, bridge)
37
38 - def _addOptions (self):
39 """ 40 Overview 41 ======== 42 The standard option for an Transform Dock Widget is the "Transform in Place" check box 43 which allows users to designate where their output goes. When it is checked, the output 44 will be directed to the List from which the input came from, otherwise they will be 45 free variables. 46 """ 47 48 box = PyQt4.QtGui.QGroupBox ("Options") 49 layout = PyQt4.QtGui.QVBoxLayout () 50 box.setLayout (layout) 51 52 self.pref = PyQt4.QtGui.QCheckBox ("Transform in Place") 53 layout.addWidget (self.pref) 54 PyQt4.QtCore.QObject.connect (self.pref, PyQt4.QtCore.SIGNAL ("stateChanged (int)"), self.setOutput) 55 return box
56
57 - def _addCommands (self):
58 """ 59 Overview 60 ======== 61 The stanard commands for the Transform Dock Widget are "Transform" and "Clear". "Transform" 62 will actually execute the transformation if possible, and clear will remove any input data 63 the user has already placed in the data holders. 64 """ 65 66 box = PyQt4.QtGui.QGroupBox ("Commands") 67 layout = PyQt4.QtGui.QHBoxLayout (box) 68 69 transformButton = Constants.BQPushButton ("Transform", layout) 70 transformButton.setDefault (True) 71 PyQt4.QtCore.QObject.connect (transformButton, PyQt4.QtCore.SIGNAL ("clicked ()"), self.transform) 72 73 clearButton = Constants.BQPushButton ("Clear", layout) 74 PyQt4.QtCore.QObject.connect (clearButton, PyQt4.QtCore.SIGNAL ("clicked ()"), self.clear) 75 76 return box
77
78 - def _addDataSelection (self):
79 """ 80 """ 81 82 box = PyQt4.QtGui.QGroupBox ("Data Selection") 83 inputDict = {} 84 for key in self._inList: 85 inputDict[key] = [["ATTRIBUTE"], ["_basin.Attribute"]] 86 self.list = Holders.GenericGroupHolder (self._bridge, [["LIST"], ["_basin.List"]], "List", inputDict, self._inList, self._outList) 87 self.list.setEnabled (False) 88 layout = self.list._layout 89 box.setLayout (layout) 90 return box
91
92 - def clear (self):
93 """ 94 Overview 95 ======== 96 This method will clear all user modifiable fields. For input fields this means returning 97 them to None, while for Output fields it returns them to their default values. This is 98 called on successful transform, as well as when the user clicks clear. Finally, it is also 99 called before a data guess is performed, so that there is room for the guesses. 100 """ 101 102 self.list.clear ()
103
104 - def DefaultCheck (self):
105 """ 106 Overview 107 ======== 108 This method has to deal with the preference (General Preferences) regarding where output of 109 functions goes. This setting is stored as a "global" in the bridge, so this method checks 110 the bridge to see whether or not to send output to the parent basin object, or to the 111 free variable viewer. 112 """ 113 114 if self._bridge._inPlace: 115 self.pref.setCheckState (PyQt4.QtCore.Qt.Checked) 116 else: 117 self.pref.setCheckState (PyQt4.QtCore.Qt.Unchecked)
118
119 - def DoubleClicked (self, attr = None):
120 """ 121 Overview 122 ======== 123 This method will take an object and attempt to add it to the data selection of this dock widget. 124 This can be slightly deceiving, as not just double clicking actions can invoke this 125 method. Things such as L{GuessAttributes ()<client.Dock.DataGuesser.GuessAttributes>} will 126 also invoke it since it simulates a double clicking action. 127 128 @param attr: This is the object from either the L{BasinViewer<client.Viewers.BasinViewer>} 129 or L{VariableList<client.Viewers.VariableViewer>} which was double clicked. 130 @type attr: It can be one of many types 131 - L{Alias<client.Viewers.Alias>} 132 - L{Value<client.Viewers.Value>} 133 - L{Region<client.Viewers.Region>} 134 - L{List<client.Viewers.List>} 135 - L{Grid<client.Viewers.Grid>} 136 - L{Attribute<client.Viewers.Attribute>} 137 """ 138 139 if attr == None: 140 return 141 142 if attr.Type () == "ALIAS": 143 attr = attr._item 144 145 if attr.Type () == "ATTRIBUTE" or (attr.Type () == "VALUE" \ 146 and attr._type == "_basin.Attribute"): 147 for holder in self.list._inputHolders: 148 if holder.SetItem (attr, clobber = False) == True: 149 self.DoubleClicked (holder._item._parent) 150 return 151 elif attr.Type () == "LIST": 152 if self.list._parent.text () == "None": 153 self.list._parent.setText (attr._name) 154 self.list._parent._item = attr
155
156 - def setOutput (self, state):
157 """ 158 Overview 159 ======== 160 This method should be called whenever the "Transform in Place" checkbox's value changes. This means 161 it should be hooked up to the QCheckBox's I{void stateChanged (int)} signal. When it is checked, 162 the parent list is required for the data selection, so it is enabled. Naturally, when the check 163 box is unchecked, the parent list will be disabled. Regardless of which state the check box is in, 164 when this method is called the L{guessDefaults<client.Dock.Transforms.AbstractTransform.guessDefaults>} 165 method is always called. 166 167 @param state: The state is the state of the check box when its signal I{void stateChanged (int)} 168 is called. We are only concerned with: 169 0. The check box was unchecked. 170 2. The check box was checked. 171 @type state: int 172 """ 173 174 if state == 0: 175 self.list.setEnabled (False) 176 elif state == 2: 177 self.list.setEnabled (True) 178 self.guessDefaults ()
179
180 - def transform (self):
181 """ 182 Overview 183 ======== 184 This method will attempt to execute the transformation on the data currently in the data selection. 185 First it will make sure you are connected and already in autopx mode. Then, depending on whether 186 the user has selected if they want their data to be transformed in place or not, it will send 187 the correct ipython command to the ipython shell for execution. Afterwards, all of the data 188 selection holders will be cleared. 189 """ 190 191 if not ( self._bridge._connected == True and self._bridge._parallel == True): 192 return False 193 194 if self.pref.checkState () == PyQt4.QtCore.Qt.Unchecked: 195 inAttributes = "" 196 result = self.list.getInAccesses () 197 if result == False: 198 return 199 for attr in result: 200 inAttributes += ", " + str (attr) 201 outAttributes = "" 202 result = self.list.getOutNames () 203 if result == False: 204 return 205 for attr in result: 206 outAttributes += ", " + str (attr) 207 208 commands = [] 209 for out in self.list.getOutNames (): 210 commands.append (str (out) + " = Attribute ()") 211 212 213 commands.append (self._funcName + \ 214 " (" + str (inAttributes[2:]) + str (outAttributes) + ")") 215 self._bridge._ipyShell.BatchCommands (commands, True) 216 elif self.pref.checkState () == PyQt4.QtCore.Qt.Checked: 217 inAttributes = "" 218 result = self.list.getInNames () 219 if result == False: 220 return 221 for attr in result: 222 inAttributes += ", \"" + str (attr) + "\"" 223 outAttributes = "" 224 result = self.list.getOutNames () 225 if result == False: 226 return 227 for attr in result: 228 outAttributes += ", \"" + str (attr) + "\"" 229 230 commands = [] 231 commands.append (self._funcName + \ 232 " (" + str (self.list._parent._item._shellAccess) + \ 233 str (inAttributes) + str (outAttributes) + ")") 234 self._bridge._ipyShell.BatchCommands (commands, True) 235 236 for holder in self.list._inputHolders: 237 holder.clear () 238 for holder in self.list._outputHolders: 239 holder.clear () 240 self.list.clear ()
241
242 - def guessDefaults (self):
243 """ 244 Overview 245 ======== 246 This function will first generate a list of regular expressions based on the 247 input holders for the Transform Dock Widget. From these regular expressions, 248 it will run the Basin Object Tree items through the generated regular expressions, 249 and on a match it will add it to the data selection layout. 250 """ 251 252 guessList = [] 253 for item in self._inList: 254 guessList.append (DataGuesser.GenerateRegExpFromName (item)) 255 DataGuesser.GuessAttributes (self, guessList)
256 257
258 -class Equatorial2XYZ (AbstractTransform):
259 - def __init__ (self, parent, bridge):
260 self._funcName = "equatorial_to_xyz" 261 self._displayName = "Equatorial To Cartesian" 262 self._displayIcon = PyQt4.QtGui.QIcon (Constants.ICON_DIR + "/transformations/etoc.png") 263 self._description = "Everything this function does happens all within one list. Choose three attributes from one list. These are the left-hand attributes. You may name the right-hand ones, then click `Transform`!" 264 self._inList = ["ra", "dec", "r"] 265 self._outList = ["x", "y", "z"] 266 # This constructor will make use of the previously defined variables 267 # not defining them will cause an error 268 AbstractTransform.__init__ (self, parent, bridge)
269 270
271 -class XYZ2Equatorial (AbstractTransform):
272 - def __init__ (self, parent, bridge):
273 self._funcName = "xyz_to_equatorial" 274 self._displayName = "Cartesian To Equatorial" 275 self._displayIcon = PyQt4.QtGui.QIcon (Constants.ICON_DIR + "/transformations/ctoe.png") 276 self._description = "Everything this function does happens all within one list. Choose three attributes from one list. These are the left-hand attributes. You may name the right-hand ones, then click `Transform`!" 277 self._inList = ["x", "y", "z"] 278 self._outList = ["ra", "dec", "r"] 279 # This constructor will make use of the previously defined variables 280 # not defining them will cause an error 281 AbstractTransform.__init__ (self, parent, bridge)
282 283
284 -class Polar2XY (AbstractTransform):
285 - def __init__ (self, parent, bridge):
286 self._funcName = "polar_to_xy" 287 self._displayName = "Polar To Cartesian" 288 self._displayIcon = PyQt4.QtGui.QIcon (Constants.ICON_DIR + "/transformations/ptoc.png") 289 self._description = "Everything this function does happens all within one list. Choose two attributes from one list. These are the left-hand attributes. You may name the right-hand ones, then click `Transform`!" 290 self._inList = ["r", "theta"] 291 self._outList = ["x", "y"] 292 # This constructor will make use of the previously defined variables 293 # not defining them will cause an error 294 AbstractTransform.__init__ (self, parent, bridge)
295 296
297 -class XY2Polar (AbstractTransform):
298 - def __init__ (self, parent, bridge):
299 self._funcName = "xy_to_polar" 300 self._displayName = "Cartesian To Polar" 301 self._displayIcon = PyQt4.QtGui.QIcon (Constants.ICON_DIR + "/transformations/ctop.png") 302 self._description = "Everything this function does happens all within one list. Choose two attributes from one list. These are the left-hand attributes. You may name the right-hand ones, then click `Transform`!:" 303 self._inList = ["x", "y"] 304 self._outList = ["r", "theta"] 305 # This constructor will make use of the previously defined variables 306 # not defining them will cause an error 307 AbstractTransform.__init__ (self, parent, bridge)
308 309
310 -class Spherical2XYZ (AbstractTransform):
311 - def __init__ (self, parent, bridge):
312 self._funcName = "spherical_to_xyz" 313 self._displayName = "Spherical To Cartesian" 314 self._displayIcon = PyQt4.QtGui.QIcon (Constants.ICON_DIR + "/transformations/stoc.png") 315 self._description = "Everything this function does happens all within one list. Choose three attributes from one list. These are the left-hand attributes. You may name the right-hand ones, then click `Transform`!" 316 self._inList = ["rho", "theta", "phi"] 317 self._outList = ["x", "y", "z"] 318 # This constructor will make use of the previously defined variables 319 # not defining them will cause an error 320 AbstractTransform.__init__ (self, parent, bridge)
321 322
323 -class XYZ2Spherical (AbstractTransform):
324 - def __init__ (self, parent, bridge):
325 self._funcName = "xyz_to_spherical" 326 self._displayName = "Cartesian To Spherical" 327 self._displayIcon = PyQt4.QtGui.QIcon (Constants.ICON_DIR + "/transformations/ctos.png") 328 self._description = "Everything this function does happens all within one list. Choose three attributes from one list. These are the left-hand attributes. You may name the right-hand ones, then click `Transform`!" 329 self._inList = ["x", "y", "z"] 330 self._outList = ["rho", "theta", "phi"] 331 # This constructor will make use of the previously defined variables 332 # not defining them will cause an error 333 AbstractTransform.__init__ (self, parent, bridge)
334 335
336 -class Cylindrical2XYZ (AbstractTransform):
337 - def __init__ (self, parent, bridge):
338 self._funcName = "cylindrical_to_xyz" 339 self._displayName = "Cylindrical To Cartesian" 340 self._displayIcon = PyQt4.QtGui.QIcon (Constants.ICON_DIR + "/transformations/cytoc.png") 341 self._description = "Everything this function does happens all within one list. Choose three attributes from one list. These are the left-hand attributes. You may name the right-hand ones, then click `Transform`!" 342 self._inList = ["r", "theta", "z"] 343 self._outList = ["x", "y", "z"] 344 # This constructor will make use of the previously defined variables 345 # not defining them will cause an error 346 AbstractTransform.__init__ (self, parent, bridge)
347 348
349 -class XYZ2Cylindrical (AbstractTransform):
350 - def __init__ (self, parent, bridge):
351 self._funcName = "xyz_to_cylindrical" 352 self._displayName = "Cartesian To Cylindrical" 353 self._displayIcon = PyQt4.QtGui.QIcon (Constants.ICON_DIR + "/transformations/ctocy.png") 354 self._description = "Everything this function does happens all within one list. Choose three attributes from one list. These are the left-hand attributes. You may name the right-hand ones, then click `Transform`!" 355 self._inList = ["x", "y", "z"] 356 self._outList = ["r", "theta", "z"] 357 # This constructor will make use of the previously defined variables 358 # not defining them will cause an error 359 AbstractTransform.__init__ (self, parent, bridge)
360 361
362 -class Convolve (AbstractTransform):
363 - def __init__ (self, parent, bridge):
364 self._displayName = "Convolve" 365 self._displayIcon = PyQt4.QtGui.QIcon (Constants.ICON_DIR + "/transformations/convolve.png") 366 self._description = "This function convolves an attribute with a generic ConvKernel, which assumes a 2D Gaussian, which is 5x5. You may either convolve in the same List or Grid, or make it a free floating variable." 367 self._inList = ["in"] 368 self._outList = ["conv_out"] 369 # This constructor will make use of the previously defined variables 370 # not defining them will cause an error 371 AbstractTransform.__init__ (self, parent, bridge)
372
373 - def guessDefaults (self):
374 guessList = [] 375 DataGuesser.GuessAttributes (self, guessList)
376
377 - def transform (self):
378 if not (self._bridge._connected == True and self._bridge._parallel == True): 379 return False 380 381 attributes = self.list.getInAccesses () 382 attr = "" 383 if attributes != None and len (attributes) == 1: 384 attr += attributes[0] 385 else: 386 return 387 commands = [] 388 if self.pref.checkState () == PyQt4.QtCore.Qt.Unchecked: # Free Floating 389 commands.append (str (self.list._outList[0].text ()) + " = convolve (" + attr + ", CONVOLVE)") 390 elif self.pref.checkState () == PyQt4.QtCore.Qt.Checked: # In Place 391 commands.append (str (self.list._item._shellAccess) + ".add_attribute (\"" + str (self.list._outList[0].text ()) + "\", convolve (" + attr + ", CONVOLVE))") 392 self._bridge._ipyShell.BatchCommands (commands, True) 393 394 for holder in self.list._inList: 395 holder.clear () 396 for holder in self.list._outList: 397 holder.clear () 398 self.list.clear ()
399 400
401 -class FFT (AbstractTransform):
402 - def __init__ (self, parent, bridge):
403 self._displayName = "Fast Fourier Transform" 404 self._displayIcon = PyQt4.QtGui.QIcon (Constants.ICON_DIR + "/transformations/fft.png") 405 self._description = "Everything this function does happens all within one list. Choose one attributes from one list. These are the left-hand attributes. You may name the right-hand ones, then click `Transform`!" 406 self._inList = ["in"] 407 self._outList = ["out"] 408 # This constructor will make use of the previously defined variables 409 # not defining them will cause an error 410 AbstractTransform.__init__ (self, parent, bridge)
411
412 - def guessDefaults (self):
413 return
414
415 - def transform (self):
416 if not ( self._bridge._connected == True and self._bridge._parallel == True): 417 return False 418 419 commands = [] 420 if self.pref.checkState () == PyQt4.QtCore.Qt.Unchecked: # Free Floating 421 commands.append (str (self.list._outList[0].text ()) + " = fft (" + str (self.list._inList[0]._item._shellAccess) + ")") 422 elif self.pref.checkState () == PyQt4.QtCore.Qt.Checked: # In Place 423 commands.append (str (self.list._item._shellAccess) + ".add_attribute (\"" + str (self.list._outList[0].text ()) + "\", fft (" + str (self.list._item._shellAccess) + ".get_attribute (\"" + str (self.list._inList[0].text ()) + "\")))") 424 self._bridge._ipyShell.BatchCommands (commands, True) 425 426 for holder in self.list._inList: 427 holder.clear () 428 for holder in self.list._outList: 429 holder.clear () 430 self.list.clear ()
431 432
433 -class ComputeDensity (AbstractTransform):
434 """ 435 """ 436
437 - def __init__ (self, layout, bridge):
438 self._visitStarted = False 439 self._displayName = "Compute Density" 440 self._displayIcon = PyQt4.QtGui.QIcon (Constants.ICON_DIR + "/transformations/compdens.png") 441 self._description = "This function will take 1, 2, or 3 coordinates along with a mass to compute a density. The density output will be an attribute attached to a Grid called DensOut which is automatically added in place. The output name you enter will be its alias." 442 AbstractTransform.__init__ (self, layout, bridge)
443
444 - def _addOptions (self):
445 return
446
447 - def _addCommands (self):
448 box = PyQt4.QtGui.QGroupBox ("Commands") 449 layout = PyQt4.QtGui.QHBoxLayout (box) 450 451 commandTransform = Constants.BQPushButton ("Transform", layout) 452 PyQt4.QtCore.QObject.connect (commandTransform, PyQt4.QtCore.SIGNAL ("clicked ()"), self.transform) 453 454 commandClear = Constants.BQPushButton ("Clear", layout) 455 PyQt4.QtCore.QObject.connect (commandClear, PyQt4.QtCore.SIGNAL ("clicked ()"), self.clear) 456 457 return box
458
459 - def _addDataSelection (self):
460 box = PyQt4.QtGui.QGroupBox ("Data Selection") 461 layout = PyQt4.QtGui.QVBoxLayout (box) 462 463 self._out = PyQt4.QtGui.QLineEdit ("densOut") 464 outLayout = Constants.BQHBoxLayout (layout) 465 outLayout.addWidget (PyQt4.QtGui.QLabel ("out:")) 466 outLayout.addWidget (self._out) 467 468 self._dataSelection = Holders.ParentListHolder (self._bridge, ["x", "y", "z"]) 469 PyQt4.QtCore.QObject.connect (self._dataSelection._inList[0], PyQt4.QtCore.SIGNAL ("textChanged (const QString&)"), self.setNx) 470 PyQt4.QtCore.QObject.connect (self._dataSelection._inList[1], PyQt4.QtCore.SIGNAL ("textChanged (const QString&)"), self.setNy) 471 PyQt4.QtCore.QObject.connect (self._dataSelection._inList[2], PyQt4.QtCore.SIGNAL ("textChanged (const QString&)"), self.setNz) 472 self._dataSelectionMassDens = Holders.FreeHolderGroup (self._bridge, ["mass"]) 473 474 475 self._nxName = PyQt4.QtGui.QLabel ("nx:") 476 self._nx = PyQt4.QtGui.QLineEdit ("0") 477 self._nx.setEnabled (False) 478 self._nyName = PyQt4.QtGui.QLabel ("ny:") 479 self._ny = PyQt4.QtGui.QLineEdit ("0") 480 self._ny.setEnabled (False) 481 self._nzName = PyQt4.QtGui.QLabel ("nz:") 482 self._nz = PyQt4.QtGui.QLineEdit ("0") 483 self._nz.setEnabled (False) 484 485 self._dataSelection.layout.addWidget (self._nxName, 1, 2, PyQt4.QtCore.Qt.AlignRight) 486 self._dataSelection.layout.addWidget (self._nx, 1, 3, PyQt4.QtCore.Qt.AlignLeft) 487 self._dataSelection.layout.addWidget (self._nyName, 2, 2, PyQt4.QtCore.Qt.AlignRight) 488 self._dataSelection.layout.addWidget (self._ny, 2, 3, PyQt4.QtCore.Qt.AlignLeft) 489 self._dataSelection.layout.addWidget (self._nzName, 3, 2, PyQt4.QtCore.Qt.AlignRight) 490 self._dataSelection.layout.addWidget (self._nz, 3, 3, PyQt4.QtCore.Qt.AlignLeft) 491 492 space = PyQt4.QtGui.QHBoxLayout () 493 self._dataSelectionMassDens.layout.addLayout (space, 0, 2, 1, 2) 494 495 regexp = PyQt4.QtCore.QRegExp ("[0-9]*") 496 validatorX = PyQt4.QtGui.QRegExpValidator (regexp, self._nx) 497 self._nx.setValidator (validatorX) 498 validatorY = PyQt4.QtGui.QRegExpValidator (regexp, self._ny) 499 self._ny.setValidator (validatorY) 500 validatorZ = PyQt4.QtGui.QRegExpValidator (regexp, self._nz) 501 self._nz.setValidator (validatorZ) 502 503 layout.addLayout (self._dataSelection.layout) 504 layout.addLayout (self._dataSelectionMassDens.layout) 505 506 return box
507
508 - def setOutput (self):
509 return
510
511 - def guessDefaults (self):
512 guessList = [] 513 guessList.append (DataGuesser.GenerateRegExpFromName ("X")) 514 guessList.append (DataGuesser.GenerateRegExpFromName ("Y")) 515 guessList.append (DataGuesser.GenerateRegExpFromName ("Z")) 516 guessList.append (DataGuesser.GenerateRegExpFromWord ("MASS")) 517 DataGuesser.GuessAttributes (self, guessList)
518
519 - def transform (self):
520 if not ( self._bridge._connected == True and self._bridge._parallel == True): 521 return False 522 523 mass_dens = self._dataSelectionMassDens.getInNames (False) 524 if len (mass_dens) == 1 and self._out.text () != "" \ 525 and self._dataSelection._item != None: 526 beginning = "compute_density ( " + self._dataSelection._item._shellAccess + ", \"" 527 end = "\", \"" + mass_dens[0] + "\", \"" + str (self._out.text ()) 528 529 vectList = [] 530 for dim in [self._nx, self._ny, self._nz]: 531 if dim.isEnabled () == True: 532 vectList.append (str (dim.text ())) 533 if len (vectList) == 1: 534 vect = "[" + vectList[0] + "]" 535 elif len (vectList) == 2: 536 vect = "[" + vectList[0] + ", " + vectList[1] + "]" 537 elif len (vectList) == 3: 538 vect = "[" + vectList[0] + ", " + vectList[1] + ", " + vectList[2] + "]" 539 else: 540 return 541 542 else: 543 return 544 545 attributes = self._dataSelection.getInNames (False) 546 547 548 if len (attributes) == 3: 549 self._bridge._ipyShell.BatchCommands ([beginning + \ 550 attributes[0] + "\", \"" + attributes[1] + "\", \"" + \ 551 attributes[2] + end + "\", " + vect + ")"], True) 552 elif len (attributes) == 2: 553 self._bridge._ipyShell.BatchCommands ([beginning + \ 554 attributes[0] + "\", \"" + attributes[1] + \ 555 end + "\", " + vect + ", 2)"], True) 556 elif len (attributes) == 1: 557 self._bridge._ipyShell.BatchCommands ([beginning + \ 558 attributes[0] + end + "\", " + vect + ", 1)"], True) 559 560 self.clear ()
561 562
563 - def setNx (self, val):
564 if str (val) == "None": 565 self._nx.setEnabled (False) 566 else: 567 self._nx.setEnabled (True) 568 self._nx.setText ("50")
569
570 - def setNy (self, val):
571 if str (val) == "None": 572 self._ny.setEnabled (False) 573 else: 574 self._ny.setEnabled (True) 575 self._ny.setText ("50")
576
577 - def setNz (self, val):
578 if str (val) == "None": 579 self._nz.setEnabled (False) 580 else: 581 self._nz.setEnabled (True) 582 self._nz.setText ("50")
583
584 - def clear (self):
585 self._dataSelection.clear () 586 for holder in self._dataSelection._inList: 587 holder.clear () 588 for holder in self._dataSelectionMassDens._inList: 589 holder.clear () 590 self._nx.setText ("0") 591 self._ny.setText ("0") 592 self._nz.setText ("0") 593 self._out.setText ("densOut")
594
595 - def DoubleClicked (self, attr):
596 if attr == None: 597 return 598 599 if attr.Type () == "ALIAS": 600 attr = attr._item 601 602 if attr.Type () == "ATTRIBUTE" or (attr.Type () == "VALUE" \ 603 and attr._type == "_basin.Attribute"): 604 if self._dataSelection.isInFull (): 605 if not self._dataSelectionMassDens.isInFull (): 606 for holder in self._dataSelectionMassDens._inList: 607 if holder.SetItem (attr, clobber = False) == True: 608 return 609 610 else: 611 for holder in self._dataSelection._inList: 612 if holder.SetItem (attr, clobber = False) == True: 613 return 614 elif attr.Type () == "LIST": 615 if self._dataSelection.text () == "None": 616 self._dataSelection.setText (attr.text (0)) 617 self._dataSelection._shellAccess = attr._shellAccess
618