Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/MainWindow/DataExplorer.py

    r60d55a7 r0cd98a1  
    4242        # Main model for keeping loaded data 
    4343        self.model = QtGui.QStandardItemModel(self) 
    44  
    4544        # Secondary model for keeping frozen data sets 
    4645        self.theory_model = QtGui.QStandardItemModel(self) 
     
    9897        self.communicator.plotUpdateSignal.connect(self.updatePlot) 
    9998        self.communicator.maskEditorSignal.connect(self.showEditDataMask) 
     99        self.communicator.extMaskEditorSignal.connect(self.extShowEditDataMask) 
    100100 
    101101        self.cbgraph.editTextChanged.connect(self.enableGraphCombo) 
     
    598598        plot2D.plot(plot_set) 
    599599        self.addPlot(plot2D) 
    600         self.active_plots[plot2D.data.id] = plot2D 
     600        self.active_plots[plot2D.data.name] = plot2D 
    601601        #============================================ 
    602602        # Experimental hook for silx charts 
     
    626626                new_plot.plot(plot_set, transform=transform) 
    627627                # active_plots may contain multiple charts 
    628                 self.active_plots[plot_set.id] = new_plot 
     628                self.active_plots[plot_set.name] = new_plot 
    629629            elif isinstance(plot_set, Data2D): 
    630630                self.addDataPlot2D(plot_set, item) 
     
    697697                old_plot.plot() 
    698698                # need this for lookup - otherwise this plot will never update 
    699                 self.active_plots[plot_set.id] = old_plot 
     699                self.active_plots[plot_set.name] = old_plot 
    700700 
    701701    def updatePlot(self, data): 
     
    711711 
    712712        ids_keys = list(self.active_plots.keys()) 
    713         ids_vals = [val.data.id for val in self.active_plots.values()] 
    714  
    715         data_id = data.id 
     713        ids_vals = [val.data.name for val in self.active_plots.values()] 
     714 
     715        data_id = data.name 
    716716        if data_id in ids_keys: 
    717717            self.active_plots[data_id].replacePlot(data_id, data) 
     
    952952        model = proxy.sourceModel() 
    953953 
    954         if index.isValid(): 
    955             model_item = model.itemFromIndex(proxy.mapToSource(index)) 
    956             # Find the mapped index 
    957             orig_index = model_item.isCheckable() 
    958             if orig_index: 
    959                 # Check the data to enable/disable actions 
    960                 is_2D = isinstance(GuiUtils.dataFromItem(model_item), Data2D) 
    961                 self.actionQuick3DPlot.setEnabled(is_2D) 
    962                 self.actionEditMask.setEnabled(is_2D) 
    963                 # Fire up the menu 
    964                 self.context_menu.exec_(self.current_view.mapToGlobal(position)) 
     954        if not index.isValid(): 
     955            return 
     956        model_item = model.itemFromIndex(proxy.mapToSource(index)) 
     957        # Find the mapped index 
     958        orig_index = model_item.isCheckable() 
     959        if not orig_index: 
     960            return 
     961        # Check the data to enable/disable actions 
     962        is_2D = isinstance(GuiUtils.dataFromItem(model_item), Data2D) 
     963        self.actionQuick3DPlot.setEnabled(is_2D) 
     964        self.actionEditMask.setEnabled(is_2D) 
     965        # Fire up the menu 
     966        self.context_menu.exec_(self.current_view.mapToGlobal(position)) 
    965967 
    966968    def showDataInfo(self): 
     
    10591061        self.new_plot.show() 
    10601062 
     1063    def extShowEditDataMask(self): 
     1064        self.showEditDataMask() 
     1065 
    10611066    def showEditDataMask(self, data=None): 
    10621067        """ 
    10631068        Mask Editor for 2D plots 
    10641069        """ 
    1065         if data is None or not isinstance(data, Data2D): 
    1066             index = self.current_view.selectedIndexes()[0] 
    1067             proxy = self.current_view.model() 
    1068             model = proxy.sourceModel() 
    1069             model_item = model.itemFromIndex(proxy.mapToSource(index)) 
    1070  
    1071             data = GuiUtils.dataFromItem(model_item) 
     1070        try: 
     1071            if data is None or not isinstance(data, Data2D): 
     1072                index = self.current_view.selectedIndexes()[0] 
     1073                proxy = self.current_view.model() 
     1074                model = proxy.sourceModel() 
     1075                model_item = model.itemFromIndex(proxy.mapToSource(index)) 
     1076 
     1077                data = GuiUtils.dataFromItem(model_item) 
     1078 
     1079            if data is None or not isinstance(data, Data2D): 
     1080                msg = QtWidgets.QMessageBox() 
     1081                msg.setIcon(QtWidgets.QMessageBox.Information) 
     1082                msg.setText("Error: cannot apply mask. \ 
     1083                                Please select a 2D dataset.") 
     1084                msg.setStandardButtons(QtWidgets.QMessageBox.Cancel) 
     1085                msg.exec_() 
     1086                return 
     1087        except: 
     1088            msg = QtWidgets.QMessageBox() 
     1089            msg.setIcon(QtWidgets.QMessageBox.Information) 
     1090            msg.setText("Error: No dataset selected. \ 
     1091                            Please select a 2D dataset.") 
     1092            msg.setStandardButtons(QtWidgets.QMessageBox.Cancel) 
     1093            msg.exec_() 
     1094            return 
    10721095 
    10731096        mask_editor = MaskEditor(self, data) 
Note: See TracChangeset for help on using the changeset viewer.