Changeset 4b71e91 in sasview for src/sas/qtgui/DataExplorer.py
- 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
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.