- Timestamp:
- Feb 9, 2017 6:07:05 AM (8 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 9a05a8d5
- Parents:
- bda1faa7
- Location:
- src/sas
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/GUITests.py
r3bdbfcc r57b7ee2 26 26 from UnitTesting import BoxSumTest 27 27 from UnitTesting import SlicerModelTest 28 from UnitTesting import SlicerParametersTest 28 29 29 30 def suite(): … … 54 55 unittest.makeSuite(BoxSumTest.BoxSumTest, 'test'), 55 56 unittest.makeSuite(SlicerModelTest.SlicerModelTest, 'test'), 57 unittest.makeSuite(SlicerParametersTest.SlicerParametersTest, 'test'), 56 58 ) 57 59 return unittest.TestSuite(suites) -
src/sas/qtgui/Plotter2D.py
rb789967 r57b7ee2 45 45 # Reference to the current slicer 46 46 self.slicer = None 47 self.slicer_widget = None 47 48 # Create Artist and bind it 48 49 self.connect = BindArtist(self.figure) … … 160 161 self.actionClearSlicer = self.contextMenu.addAction("&Clear Slicer") 161 162 self.actionClearSlicer.triggered.connect(self.onClearSlicer) 162 self.actionEditSlicer = self.contextMenu.addAction("&Edit Slicer Parameters") 163 self.actionEditSlicer.triggered.connect(self.onEditSlicer) 163 if self.slicer.__class__.__name__ != "BoxSumCalculator": 164 self.actionEditSlicer = self.contextMenu.addAction("&Edit Slicer Parameters") 165 self.actionEditSlicer.triggered.connect(self.onEditSlicer) 164 166 self.contextMenu.addSeparator() 165 167 self.actionColorMap = self.contextMenu.addAction("&2D Color Map") … … 213 215 """ 214 216 assert self.slicer 217 # Only show the dialog if not currently shown 218 if self.slicer_widget: 219 return 220 def slicer_closed(): 221 # Need to disconnect the signal!! 222 self.slicer_widget.close_signal.disconnect() 223 # reset slicer_widget on "Edit Slicer Parameters" window close 224 self.slicer_widget = None 215 225 216 226 self.param_model = self.slicer.model() 217 227 # Pass the model to the Slicer Parameters widget 218 228 self.slicer_widget = SlicerParameters(self, model=self.param_model) 219 self. manager.parent.workspace().addWindow(self.slicer_widget)229 self.slicer_widget.close_signal.connect(slicer_closed) 220 230 221 231 self.slicer_widget.show() … … 283 293 self.slicer.update() 284 294 295 # Reset the model on the Edit slicer parameters widget 296 self.param_model = self.slicer.model() 297 if self.slicer_widget: 298 self.slicer_widget.setModel(self.param_model) 299 300 285 301 def onSectorView(self): 286 302 """ … … 288 304 """ 289 305 self.setSlicer(slicer=SectorInteractor) 306 290 307 291 308 def onAnnulusView(self): -
src/sas/qtgui/SlicerParameters.py
rb789967 r57b7ee2 2 2 Allows users to modify the box slicer parameters. 3 3 """ 4 import functools 4 5 from PyQt4 import QtGui 5 6 from PyQt4 import QtCore 7 from PyQt4 import QtWebKit 6 8 7 9 # Local UI … … 13 15 passed from a slicer instance. 14 16 """ 17 close_signal = QtCore.pyqtSignal() 15 18 def __init__(self, parent=None, model=None): 16 19 super(SlicerParameters, self).__init__() … … 31 34 self.lstParams.model().setColumnReadOnly(0, True) 32 35 36 # Specify the validator on the parameter value column. 37 self.lstParams.setItemDelegate(ValidatedItemDelegate()) 38 39 # Display Help on clicking the button 40 self.buttonBox.button(QtGui.QDialogButtonBox.Help).clicked.connect(self.onHelp) 41 42 # Close doesn't trigger closeEvent automatically, so force it 43 self.buttonBox.button(QtGui.QDialogButtonBox.Close).clicked.connect(functools.partial(self.closeEvent,None)) 44 33 45 # Disable row number display 34 46 self.lstParams.verticalHeader().setVisible(False) 47 self.lstParams.setAlternatingRowColors(True) 48 self.lstParams.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding) 35 49 36 # Specify the validator on the parameter value column. 37 self.lstParams.setItemDelegate(ValidatedItemDelegate()) 50 # Header properties for nicer display 51 header = self.lstParams.horizontalHeader() 52 header.setResizeMode(QtGui.QHeaderView.Stretch) 53 header.setStretchLastSection(True) 54 55 56 def setModel(self, model): 57 """ Model setter """ 58 self.model = model 59 self.proxy.setSourceModel(self.model) 60 61 def closeEvent(self, event): 62 """ 63 Overwritten close widget method in order to send the close 64 signal to the parent. 65 """ 66 self.close_signal.emit() 67 if event: 68 event.accept() 69 70 def onHelp(self): 71 """ 72 Display generic data averaging help 73 """ 74 location = "docs/sphinx-docs/build/html" + \ 75 "/user/sasgui/guiframe/graph_help.html#d-data-averaging" 76 self._helpView = QtWebKit.QWebView() 77 self._helpView.load(QtCore.QUrl(location)) 78 self._helpView.show() 79 38 80 39 81 class ProxyModel(QtGui.QIdentityProxyModel): -
src/sas/qtgui/UI/SlicerParametersUI.ui
r3bdbfcc r57b7ee2 28 28 <widget class="QTableView" name="lstParams"/> 29 29 </item> 30 <item row="1" column="0"> 31 <spacer name="verticalSpacer"> 32 <property name="orientation"> 33 <enum>Qt::Vertical</enum> 34 </property> 35 <property name="sizeHint" stdset="0"> 36 <size> 37 <width>20</width> 38 <height>21</height> 39 </size> 40 </property> 41 </spacer> 42 </item> 43 <item row="2" column="1"> 30 <item row="1" column="1"> 44 31 <widget class="QDialogButtonBox" name="buttonBox"> 45 32 <property name="orientation"> … … 47 34 </property> 48 35 <property name="standardButtons"> 49 <set>QDialogButtonBox:: Ok</set>36 <set>QDialogButtonBox::Close|QDialogButtonBox::Help</set> 50 37 </property> 51 38 </widget> -
src/sas/qtgui/run_tests.bat
- Property mode changed from 100755 to 100644
r965fbd8 r57b7ee2 25 25 python -m UnitTesting.BoxSumTest 26 26 python -m UnitTesting.SlicerModelTest 27 python -m UnitTesting.SlicerParametersTest -
src/sas/qtgui/run_tests.sh
r3bdbfcc r57b7ee2 24 24 python -m UnitTesting.BoxSumTest 25 25 python -m UnitTesting.SlicerModelTest 26 python -m UnitTesting.SlicerParametersTest -
src/sas/sasgui/guiframe/local_perspectives/plotting/SectorSlicer.py
r3bdbfcc r57b7ee2 2 2 Sector interactor 3 3 """ 4 import math4 import numpy 5 5 from PyQt4 import QtGui 6 6 from PyQt4 import QtCore … … 11 11 from sas.qtgui.SlicerModel import SlicerModel 12 12 13 MIN_PHI = 0.05 13 14 14 15 class SectorInteractor(_BaseInteractor, SlicerModel): … … 28 29 29 30 # Compute qmax limit to reset the graph 30 x = math.pow(max(self.base.data.xmax,31 math.fabs(self.base.data.xmin)), 2)32 y = math.pow(max(self.base.data.ymax,33 math.fabs(self.base.data.ymin)), 2)34 self.qmax = math.sqrt(x + y)31 x = numpy.power(max(self.base.data.xmax, 32 numpy.fabs(self.base.data.xmin)), 2) 33 y = numpy.power(max(self.base.data.ymax, 34 numpy.fabs(self.base.data.ymin)), 2) 35 self.qmax = numpy.sqrt(x + y) 35 36 # Number of points on the plot 36 37 self.nbins = 20 37 38 # Angle of the middle line 38 self.theta2 = math.pi / 339 self.theta2 = numpy.pi / 3 39 40 # Absolute value of the Angle between the middle line and any side line 40 self.phi = math.pi / 1241 self.phi = numpy.pi / 12 41 42 # Middle line 42 43 self.main_line = LineInteractor(self, self.axes, color='blue', … … 135 136 nbins = 20 136 137 sect = SectorQ(r_min=0.0, r_max=radius, 137 phi_min=phimin + math.pi,138 phi_max=phimax + math.pi, nbins=nbins)138 phi_min=phimin + numpy.pi, 139 phi_max=phimax + numpy.pi, nbins=nbins) 139 140 140 141 sector = sect(self.base.data) … … 209 210 # Always make sure that the left and the right line are at phi 210 211 # angle of the middle line 211 if math.fabs(self.left_line.phi) != math.fabs(self.right_line.phi):212 if numpy.fabs(self.left_line.phi) != numpy.fabs(self.right_line.phi): 212 213 msg = "Phi left and phi right are different" 213 214 msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 214 215 raise ValueError, msg 215 params["Phi [deg]"] = self.main_line.theta * 180 / math.pi216 params["Delta_Phi [deg]"] = math.fabs(self.left_line.phi * 180 / math.pi)216 params["Phi [deg]"] = self.main_line.theta * 180 / numpy.pi 217 params["Delta_Phi [deg]"] = numpy.fabs(self.left_line.phi * 180 / numpy.pi) 217 218 params["nbins"] = self.nbins 218 219 return params … … 226 227 values the user assigned to the slicer. 227 228 """ 228 main = params["Phi [deg]"] * math.pi / 180 229 phi = math.fabs(params["Delta_Phi [deg]"] * math.pi / 180) 229 main = params["Phi [deg]"] * numpy.pi / 180 230 phi = numpy.fabs(params["Delta_Phi [deg]"] * numpy.pi / 180) 231 232 # phi should not be too close. 233 if numpy.fabs(phi) < MIN_PHI: 234 phi = MIN_PHI 235 params["Delta_Phi [deg]"] = MIN_PHI 236 230 237 self.nbins = int(params["nbins"]) 231 238 self.main_line.theta = main … … 241 248 def draw(self): 242 249 """ 250 Redraw canvas 243 251 """ 244 252 self.base.draw() … … 254 262 """ 255 263 def __init__(self, base, axes, color='black', zorder=5, r=1.0, 256 phi= math.pi / 4, theta2=math.pi / 3):264 phi=numpy.pi / 4, theta2=numpy.pi / 3): 257 265 """ 258 266 """ … … 272 280 self.phi = phi 273 281 # End points polar coordinates 274 x1 = self.radius * math.cos(self.theta)275 y1 = self.radius * math.sin(self.theta)276 x2 = -1 * self.radius * math.cos(self.theta)277 y2 = -1 * self.radius * math.sin(self.theta)282 x1 = self.radius * numpy.cos(self.theta) 283 y1 = self.radius * numpy.sin(self.theta) 284 x2 = -1 * self.radius * numpy.cos(self.theta) 285 y2 = -1 * self.radius * numpy.sin(self.theta) 278 286 # Defining a new marker 279 287 self.inner_marker = self.axes.plot([x1 / 2.5], [y1 / 2.5], linestyle='', … … 331 339 delta = 0 332 340 if right: 333 self.phi = -1 * math.fabs(self.phi)341 self.phi = -1 * numpy.fabs(self.phi) 334 342 #delta=-delta 335 343 else: 336 self.phi = math.fabs(self.phi)344 self.phi = numpy.fabs(self.phi) 337 345 if side: 338 346 self.theta = mline.theta + self.phi … … 347 355 else: 348 356 theta3 = self.theta2 + delta 349 x1 = self.radius * math.cos(theta3)350 y1 = self.radius * math.sin(theta3)351 x2 = -1 * self.radius * math.cos(theta3)352 y2 = -1 * self.radius * math.sin(theta3)357 x1 = self.radius * numpy.cos(theta3) 358 y1 = self.radius * numpy.sin(theta3) 359 x2 = -1 * self.radius * numpy.cos(theta3) 360 y2 = -1 * self.radius * numpy.sin(theta3) 353 361 self.inner_marker.set(xdata=[x1 / 2.5], ydata=[y1 / 2.5]) 354 362 self.line.set(xdata=[x1, x2], ydata=[y1, y2]) … … 377 385 Process move to a new position, making sure that the move is allowed. 378 386 """ 379 self.theta = math.atan2(y, x)387 self.theta = numpy.arctan2(y, x) 380 388 self.has_move = True 381 389 if not self.left_moving: … … 388 396 return 389 397 elif self.theta2 < 0 and self.theta > 0 and \ 390 (self.theta2 + 2 * math.pi - self.theta) >= math.pi / 2:398 (self.theta2 + 2 * numpy.pi - self.theta) >= numpy.pi / 2: 391 399 self.restore() 392 400 return 393 401 elif self.theta2 < 0 and self.theta < 0 and \ 394 (self.theta2 - self.theta) >= math.pi / 2:395 self.restore() 396 return 397 elif self.theta2 > 0 and (self.theta2 - self.theta >= math.pi / 2 or \398 (self.theta2 - self.theta >= math.pi / 2)):402 (self.theta2 - self.theta) >= numpy.pi / 2: 403 self.restore() 404 return 405 elif self.theta2 > 0 and (self.theta2 - self.theta >= numpy.pi / 2 or \ 406 (self.theta2 - self.theta >= numpy.pi / 2)): 399 407 self.restore() 400 408 return 401 409 else: 402 if self.theta < 0 and (self.theta + math.pi * 2 - self.theta2) <= 0:410 if self.theta < 0 and (self.theta + numpy.pi * 2 - self.theta2) <= 0: 403 411 self.restore() 404 412 return … … 409 417 self.restore() 410 418 return 411 elif self.theta - self.theta2 >= math.pi / 2 or \412 ((self.theta + math.pi * 2 - self.theta2) >= math.pi / 2 and \419 elif self.theta - self.theta2 >= numpy.pi / 2 or \ 420 ((self.theta + numpy.pi * 2 - self.theta2) >= numpy.pi / 2 and \ 413 421 self.theta < 0 and self.theta2 > 0): 414 422 self.restore() 415 423 return 416 424 417 self.phi = math.fabs(self.theta2 - self.theta)418 if self.phi > math.pi:419 self.phi = 2 * math.pi - math.fabs(self.theta2 - self.theta)425 self.phi = numpy.fabs(self.theta2 - self.theta) 426 if self.phi > numpy.pi: 427 self.phi = 2 * numpy.pi - numpy.fabs(self.theta2 - self.theta) 420 428 self.base.base.update() 421 429 … … 446 454 """ 447 455 def __init__(self, base, axes, color='black', 448 zorder=5, r=1.0, theta= math.pi / 4):456 zorder=5, r=1.0, theta=numpy.pi / 4): 449 457 """ 450 458 """ … … 458 466 self.scale = 10.0 459 467 # Inner circle 460 x1 = self.radius * math.cos(self.theta)461 y1 = self.radius * math.sin(self.theta)462 x2 = -1 * self.radius * math.cos(self.theta)463 y2 = -1 * self.radius * math.sin(self.theta)468 x1 = self.radius * numpy.cos(self.theta) 469 y1 = self.radius * numpy.sin(self.theta) 470 x2 = -1 * self.radius * numpy.cos(self.theta) 471 y2 = -1 * self.radius * numpy.sin(self.theta) 464 472 # Inner circle marker 465 473 self.inner_marker = self.axes.plot([x1 / 2.5], [y1 / 2.5], linestyle='', … … 502 510 if theta != None: 503 511 self.theta = theta 504 x1 = self.radius * math.cos(self.theta)505 y1 = self.radius * math.sin(self.theta)506 x2 = -1 * self.radius * math.cos(self.theta)507 y2 = -1 * self.radius * math.sin(self.theta)512 x1 = self.radius * numpy.cos(self.theta) 513 y1 = self.radius * numpy.sin(self.theta) 514 x2 = -1 * self.radius * numpy.cos(self.theta) 515 y2 = -1 * self.radius * numpy.sin(self.theta) 508 516 509 517 self.inner_marker.set(xdata=[x1 / 2.5], ydata=[y1 / 2.5]) … … 533 541 Process move to a new position, making sure that the move is allowed. 534 542 """ 535 self.theta = math.atan2(y, x)543 self.theta = numpy.arctan2(y, x) 536 544 self.has_move = True 537 545 self.base.base.update()
Note: See TracChangeset
for help on using the changeset viewer.