- Timestamp:
- Jul 13, 2016 9:17:58 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:
- 28a84e9
- Parents:
- e3ae090
- Location:
- src/sas/qtgui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/DataExplorer.py
r8cb6cd6 r4b71e91 44 44 self.loader = Loader() 45 45 self.manager = DataManager() 46 self.txt_widget = QtGui.QTextEdit(None) 47 # self.txt_widget = GuiUtils.DisplayWindow() 48 46 49 47 50 # Be careful with twisted threads. … … 65 68 self._helpView = QtWebKit.QWebView() 66 69 67 # Context menu in the treeview68 #self.treeView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)69 #self.actionDataInfo.triggered.connect(self.contextDataInfo)70 #self.treeView.addAction(self.actionDataInfo)71 72 70 # Custom context menu 73 71 self.treeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) 74 72 self.treeView.customContextMenuRequested.connect(self.onCustomContextMenu) 73 self.contextMenu() 75 74 76 75 # Connect the comboboxes … … 612 611 raise Exception, msg 613 612 614 def contextDataInfo(self): 615 """ 616 """ 617 print("contextDataInfo TRIGGERED") 618 pass 613 def contextMenu(self): 614 """ 615 Define actions and layout of the right click context menu 616 """ 617 # Create a custom menu based on actions defined in the UI file 618 self.context_menu = QtGui.QMenu(self) 619 self.context_menu.addAction(self.actionDataInfo) 620 self.context_menu.addAction(self.actionSaveAs) 621 self.context_menu.addAction(self.actionQuickPlot) 622 self.context_menu.addSeparator() 623 self.context_menu.addAction(self.actionQuick3DPlot) 624 self.context_menu.addAction(self.actionEditMask) 625 626 # Define the callbacks 627 self.actionDataInfo.triggered.connect(self.showDataInfo) 628 self.actionSaveAs.triggered.connect(self.saveDataAs) 629 self.actionQuickPlot.triggered.connect(self.quickDataPlot) 630 self.actionQuick3DPlot.triggered.connect(self.quickData3DPlot) 631 self.actionEditMask.triggered.connect(self.showEditDataMask) 619 632 620 633 def onCustomContextMenu(self, position): 621 634 """ 622 """623 print "onCustomContextMenu triggered at point ", position.x(), position.y()635 Show the right-click context menu in the data treeview 636 """ 624 637 index = self.treeView.indexAt(position) 625 638 if index.isValid(): 626 print "VALID CONTEXT MENU" 627 # self.context_menu.exec(self.treeView.mapToGlobal(position)) 639 model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 640 # Find the mapped index 641 orig_index = model_item.isCheckable() 642 if orig_index: 643 # Check the data to enable/disable actions 644 is_2D = isinstance(model_item.child(0).data().toPyObject(), Data2D) 645 self.actionQuick3DPlot.setEnabled(is_2D) 646 self.actionEditMask.setEnabled(is_2D) 647 # Fire up the menu 648 self.context_menu.exec_(self.treeView.mapToGlobal(position)) 649 650 def showDataInfo(self): 651 """ 652 Show a simple read-only text edit with data information. 653 """ 654 index = self.treeView.selectedIndexes()[0] 655 model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 656 data = model_item.child(0).data().toPyObject() 657 if data.__class__.__name__ == "Data1D": 658 text_to_show = GuiUtils.retrieveData1d(data) 659 self.txt_widget.resize(420,600) 660 else: 661 text_to_show = GuiUtils.retrieveData2d(data) 662 self.txt_widget.resize(700,600) 663 664 self.txt_widget.setReadOnly(True) 665 self.txt_widget.setWindowFlags(QtCore.Qt.Window) 666 self.txt_widget.setWindowIcon(QtGui.QIcon(":/res/ball.ico")) 667 self.txt_widget.setWindowTitle("Data Info: %s" % data.filename) 668 self.txt_widget.insertPlainText(text_to_show) 669 670 self.txt_widget.show() 671 vertical_scroll_bar = self.txt_widget.verticalScrollBar() 672 vertical_scroll_bar.triggerAction(QtGui.QScrollBar.SliderToMinimum) 673 674 def saveDataAs(self): 675 """ 676 """ 677 print "saveDataAs" 678 pass 679 680 def quickDataPlot(self): 681 """ 682 """ 683 print "quickDataPlot" 684 pass 685 686 def quickData3DPlot(self): 687 """ 688 """ 689 print "quickData3DPlot" 690 pass 691 692 def showEditDataMask(self): 693 """ 694 """ 695 print "showEditDataMask" 628 696 pass 629 697 -
src/sas/qtgui/GuiUtils.py
r8cb6cd6 r4b71e91 332 332 msg = "Attempt at opening an invalid URL" 333 333 raise AttributeError, msg 334 335 def retrieveData1d(data): 336 """ 337 Retrieve 1D data from file and construct its text 338 representation 339 """ 340 try: 341 xmin = min(data.x) 342 ymin = min(data.y) 343 except: 344 msg = "Unable to find min/max of \n data named %s" % \ 345 data.filename 346 logging.error(msg) 347 raise ValueError, msg 348 349 text = data.__str__() 350 text += 'Data Min Max:\n' 351 text += 'X_min = %s: X_max = %s\n' % (xmin, max(data.x)) 352 text += 'Y_min = %s: Y_max = %s\n' % (ymin, max(data.y)) 353 if data.dy != None: 354 text += 'dY_min = %s: dY_max = %s\n' % (min(data.dy), max(data.dy)) 355 text += '\nData Points:\n' 356 x_st = "X" 357 for index in range(len(data.x)): 358 if data.dy != None and len(data.dy) > index: 359 dy_val = data.dy[index] 360 else: 361 dy_val = 0.0 362 if data.dx != None and len(data.dx) > index: 363 dx_val = data.dx[index] 364 else: 365 dx_val = 0.0 366 if data.dxl != None and len(data.dxl) > index: 367 if index == 0: 368 x_st = "Xl" 369 dx_val = data.dxl[index] 370 elif data.dxw != None and len(data.dxw) > index: 371 if index == 0: 372 x_st = "Xw" 373 dx_val = data.dxw[index] 374 375 if index == 0: 376 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 377 text += "%s \t%s \t%s \t%s \t%s\n" % (index, 378 data.x[index], 379 data.y[index], 380 dy_val, 381 dx_val) 382 return text 383 384 def retrieveData2d(data): 385 """ 386 Retrieve 1D data from file and construct its text 387 representation 388 """ 389 text = data.__str__() 390 text += 'Data Min Max:\n' 391 text += 'I_min = %s\n' % min(data.data) 392 text += 'I_max = %s\n\n' % max(data.data) 393 text += 'Data (First 2501) Points:\n' 394 text += 'Data columns include err(I).\n' 395 text += 'ASCII data starts here.\n' 396 text += "<index> \t<Qx> \t<Qy> \t<I> \t<dI> \t<dQparal> \t<dQperp>\n" 397 di_val = 0.0 398 dx_val = 0.0 399 dy_val = 0.0 400 len_data = len(data.qx_data) 401 for index in xrange(0, len_data): 402 x_val = data.qx_data[index] 403 y_val = data.qy_data[index] 404 i_val = data.data[index] 405 if data.err_data != None: 406 di_val = data.err_data[index] 407 if data.dqx_data != None: 408 dx_val = data.dqx_data[index] 409 if data.dqy_data != None: 410 dy_val = data.dqy_data[index] 411 412 text += "%s \t%s \t%s \t%s \t%s \t%s \t%s\n" % (index, 413 x_val, 414 y_val, 415 i_val, 416 di_val, 417 dx_val, 418 dy_val) 419 # Takes too long time for typical data2d: Break here 420 if index >= 2500: 421 text += ".............\n" 422 break 423 424 return text
Note: See TracChangeset
for help on using the changeset viewer.