Changeset c8536d6c in sasview for src/sas


Ignore:
Timestamp:
Sep 8, 2018 7:32:23 AM (6 years ago)
Author:
GitHub <noreply@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
35e36fd, c0de493
Parents:
3090270 (diff), 01b4877 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Torin Cooper-Bennun <40573959+tcbennun@…> (09/08/18 07:32:23)
git-committer:
GitHub <noreply@…> (09/08/18 07:32:23)
Message:

Merge pull request #174 from SasView?/ESS_GUI_iss1034

SASVIEW-1034: Support for parameters injected into the product model by sasmodels

Location:
src/sas/qtgui
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py

    rb69b549 r01b4877  
    167167    return rows 
    168168 
    169 def addSimpleParametersToModel(parameters, is2D, parameters_original=None, model=None, view=None): 
     169def addSimpleParametersToModel(parameters, is2D, parameters_original=None, model=None, view=None, row_num=None): 
    170170    """ 
    171171    Update local ModelModel with sasmodel parameters (non-dispersed, non-magnetic) 
     
    216216        # Append to the model and use the combobox, if required 
    217217        if None not in (model, view): 
    218             model.appendRow(row) 
     218            if row_num is None: 
     219                model.appendRow(row) 
     220            else: 
     221                model.insertRow(row_num, row) 
     222                row_num += 1 
     223 
    219224            if cbox: 
    220225                view.setIndexWidget(item2.index(), cbox) 
     226 
    221227        rows.append(row) 
    222228 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r3090270 rc8536d6c  
    21022102            return 
    21032103 
     2104        product_params = None 
     2105 
    21042106        if self.kernel_module is None: 
    21052107            # Structure factor is the only selected model; build it and show all its params 
     
    21072109            s_params = self.kernel_module._model_info.parameters 
    21082110            s_params_orig = s_params 
    2109  
    21102111        else: 
    21112112            s_kernel = self.models[structure_factor]() 
     
    21242125            if "radius_effective_mode" in all_param_names: 
    21252126                # Show all parameters 
     2127                # In this case, radius_effective is NOT pruned by sasmodels.product 
    21262128                s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len]) 
    21272129                s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters) 
     2130                product_params = modelinfo.ParameterTable( 
     2131                        self.kernel_module._model_info.parameters.kernel_parameters[p_pars_len+s_pars_len:]) 
    21282132            else: 
    21292133                # Ensure radius_effective is not displayed 
    21302134                s_params_orig = modelinfo.ParameterTable(s_kernel._model_info.parameters.kernel_parameters[1:]) 
    21312135                if "radius_effective" in all_param_names: 
     2136                    # In this case, radius_effective is NOT pruned by sasmodels.product 
    21322137                    s_params = modelinfo.ParameterTable(all_params[p_pars_len+1:p_pars_len+s_pars_len]) 
     2138                    product_params = modelinfo.ParameterTable( 
     2139                            self.kernel_module._model_info.parameters.kernel_parameters[p_pars_len+s_pars_len:]) 
    21332140                else: 
     2141                    # In this case, radius_effective is pruned by sasmodels.product 
    21342142                    s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len-1]) 
     2143                    product_params = modelinfo.ParameterTable( 
     2144                            self.kernel_module._model_info.parameters.kernel_parameters[p_pars_len+s_pars_len-1:]) 
    21352145 
    21362146        # Add heading row 
     
    21402150        # Any renamed parameters are stored as data in the relevant item, for later handling 
    21412151        FittingUtilities.addSimpleParametersToModel( 
    2142                 s_params, 
    2143                 self.is2D, 
    2144                 s_params_orig, 
    2145                 self._model_model, 
    2146                 self.lstParams) 
     2152                parameters=s_params, 
     2153                is2D=self.is2D, 
     2154                parameters_original=s_params_orig, 
     2155                model=self._model_model, 
     2156                view=self.lstParams) 
     2157 
     2158        # Insert product-only params into QModel 
     2159        if product_params: 
     2160            prod_rows = FittingUtilities.addSimpleParametersToModel( 
     2161                    parameters=product_params, 
     2162                    is2D=self.is2D, 
     2163                    parameters_original=None, 
     2164                    model=self._model_model, 
     2165                    view=self.lstParams, 
     2166                    row_num=2) 
     2167 
     2168            # Since this all happens after shells are dealt with and we've inserted rows, fix this counter 
     2169            self._n_shells_row += len(prod_rows) 
    21472170 
    21482171    def haveParamsToFit(self): 
  • 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) 
  • src/sas/qtgui/MainWindow/GuiManager.py

    rf84d793 r339e22b  
    422422        self._workspace.actionExcel.triggered.connect(self.actionExcel) 
    423423        self._workspace.actionLatex.triggered.connect(self.actionLatex) 
    424  
    425424        # View 
    426425        self._workspace.actionShow_Grid_Window.triggered.connect(self.actionShow_Grid_Window) 
     
    452451        self._workspace.actionManage_Custom_Models.triggered.connect(self.actionManage_Custom_Models) 
    453452        self._workspace.actionAddMult_Models.triggered.connect(self.actionAddMult_Models) 
     453        self._workspace.actionEditMask.triggered.connect(self.actionEditMask) 
     454 
    454455        # Window 
    455456        self._workspace.actionCascade.triggered.connect(self.actionCascade) 
     
    781782        self.add_mult_editor.show() 
    782783 
     784    def actionEditMask(self): 
     785 
     786        self.communicate.extMaskEditorSignal.emit() 
     787 
    783788    #============ ANALYSIS ================= 
    784789    def actionFitting(self): 
  • src/sas/qtgui/MainWindow/UI/MainWindowUI.ui

    rdda8f16 r2f14b5d  
    113113    <addaction name="actionManage_Custom_Models"/> 
    114114    <addaction name="actionAddMult_Models"/> 
     115    <addaction name="separator"/> 
     116    <addaction name="actionEditMask"/> 
    115117   </widget> 
    116118   <widget class="QMenu" name="menuWindow"> 
     
    413415   </property> 
    414416  </action> 
     417    <action name="actionEditMask"> 
     418   <property name="text"> 
     419    <string>Edit Mask</string> 
     420   </property> 
     421  </action> 
    415422  <action name="actionCascade"> 
    416423   <property name="text"> 
  • src/sas/qtgui/Perspectives/Fitting/UI/OptionsWidgetUI.ui

    r79bd268 r309fa1b  
    3232        <item row="0" column="1"> 
    3333         <widget class="QLineEdit" name="txtMinRange"> 
     34          <property name="minimumSize"> 
     35           <size> 
     36            <width>80</width> 
     37            <height>0</height> 
     38           </size> 
     39          </property> 
    3440          <property name="toolTip"> 
    3541           <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Minimum value of Q.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
     
    5460        <item row="1" column="1"> 
    5561         <widget class="QLineEdit" name="txtMaxRange"> 
     62          <property name="minimumSize"> 
     63           <size> 
     64            <width>80</width> 
     65            <height>0</height> 
     66           </size> 
     67          </property> 
    5668          <property name="toolTip"> 
    5769           <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Maximum value of Q.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingLogicTest.py

    re752ab8 rbfb5d9e  
    9999        data.name = "boop" 
    100100        data.id = "poop" 
    101         return_data = (data.x,data.y, 7, None, None, 
    102                        0, True, 0.0, 1, data, 
    103                        data, False, None, 
    104                        None, None, None, 
    105                        None, None) 
     101        # Condensed return data (new1DPlot only uses these fields) 
     102        return_data = dict(x = data.x, 
     103                           y = data.y, 
     104                           model = data, 
     105                           data = data) 
     106        # return_data = (data.x,data.y, 7, None, None, 
     107        #                0, True, 0.0, 1, data, 
     108        #                data, False, None, 
     109        #                None, None, None, 
     110        #                None, None) 
    106111 
    107112        new_plot = self.logic.new1DPlot(return_data=return_data, tab_id=0) 
     
    139144        qmin, qmax, npts = self.logic.computeDataRange() 
    140145 
    141         return_data = (x_0, data, 7, data, None, 
    142                         True, 0.0, 1, 0, qmin, qmax, 
    143                         0.1, False, None) 
     146        # Condensed return data (new2DPlot only uses these fields) 
     147        return_data = dict(image = x_0, 
     148                           data = data, 
     149                           page_id = 7, 
     150                           model = data) 
     151        # return_data = (x_0, data, 7, data, None, 
     152        #                 True, 0.0, 1, 0, qmin, qmax, 
     153        #                 0.1, False, None) 
    144154 
    145155        new_plot = self.logic.new2DPlot(return_data=return_data) 
  • src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingOptionsTest.py

    r725d9c06 rbfb5d9e  
    3838        # The combo box 
    3939        self.assertIsInstance(self.widget.cbAlgorithm, QtWidgets.QComboBox) 
    40         self.assertEqual(self.widget.cbAlgorithm.count(), 5) 
     40        self.assertEqual(self.widget.cbAlgorithm.count(), 6) 
    4141        self.assertEqual(self.widget.cbAlgorithm.itemText(0), 'Nelder-Mead Simplex') 
    4242        self.assertEqual(self.widget.cbAlgorithm.itemText(4), 'Levenberg-Marquardt') 
  • src/sas/qtgui/Plotting/Plotter.py

    rc2f3ca2 r0cd98a1  
    182182 
    183183        # Update the list of data sets (plots) in chart 
    184         self.plot_dict[self._data.id] = self.data 
    185  
    186         self.plot_lines[self._data.id] = line 
     184        self.plot_dict[self._data.name] = self.data 
     185 
     186        self.plot_lines[self._data.name] = line 
    187187 
    188188        # Now add the legend with some customizations. 
     
    201201        # refresh canvas 
    202202        self.canvas.draw() 
    203         # This is an important processEvent. 
    204         # This allows charts to be properly updated in order 
    205         # of plots being applied. 
    206         QtWidgets.QApplication.processEvents() 
    207203 
    208204    def createContextMenu(self): 
     
    420416        This effectlvely refreshes the chart with changes to one of its plots 
    421417        """ 
    422         import logging 
    423418        self.removePlot(id) 
    424419        self.plot(data=new_plot) 
  • src/sas/qtgui/Utilities/GuiUtils.py

    r6da3e3d r339e22b  
    265265    # Mask Editor requested 
    266266    maskEditorSignal = QtCore.pyqtSignal(Data2D) 
     267 
     268    #second Mask Editor for external 
     269    extMaskEditorSignal = QtCore.pyqtSignal() 
    267270 
    268271    # Fitting parameter copy to clipboard 
Note: See TracChangeset for help on using the changeset viewer.