Changes in / [9b17efd:551f2bc] in sasview


Ignore:
Location:
src/sas/qtgui
Files:
10 edited

Legend:

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

    r2b8286c r33b3e4d  
    574574        new_plots = [] 
    575575        for item, plot in plots.items(): 
    576             if self.updatePlot(plot) and filename != plot.name: 
     576            if self.updatePlot(plot) or filename not in plot.name: 
    577577                continue 
    578578            # Don't plot intermediate results, e.g. P(Q), S(Q) 
     
    583583            # Don't include plots from different fitpages, but always include the original data 
    584584            if fitpage_name in plot.name or filename == plot.name: 
    585                 # 'sophisticated' test to generate standalone plot for residuals 
    586                 if 'esiduals' in plot.title: 
     585                # Residuals get their own plot 
     586                if plot.plot_role == Data1D.ROLE_RESIDUAL: 
    587587                    plot.yscale='linear' 
    588588                    self.plotData([(item, plot)]) 
     
    686686 
    687687        # Update the active chart list 
    688         #self.active_plots[new_plot.data.id] = new_plot 
     688        self.active_plots[new_plot.data.name] = new_plot 
    689689 
    690690    def appendPlot(self): 
     
    729729        data_id = data.name 
    730730        if data_id in ids_keys: 
    731             self.active_plots[data_id].replacePlot(data_id, data) 
     731            # We have data, let's replace data that needs replacing 
     732            if data.plot_role != Data1D.ROLE_DATA: 
     733                self.active_plots[data_id].replacePlot(data_id, data) 
    732734            return True 
    733735        elif data_id in ids_vals: 
    734             list(self.active_plots.values())[ids_vals.index(data_id)].replacePlot(data_id, data) 
     736            if data.plot_role != Data1D.ROLE_DATA: 
     737                list(self.active_plots.values())[ids_vals.index(data_id)].replacePlot(data_id, data) 
    735738            return True 
    736739        return False 
     
    946949        self.context_menu.addAction(self.actionQuick3DPlot) 
    947950        self.context_menu.addAction(self.actionEditMask) 
     951        #self.context_menu.addSeparator() 
     952        #self.context_menu.addAction(self.actionFreezeResults) 
    948953        self.context_menu.addSeparator() 
    949954        self.context_menu.addAction(self.actionDelete) 
     
    957962        self.actionEditMask.triggered.connect(self.showEditDataMask) 
    958963        self.actionDelete.triggered.connect(self.deleteItem) 
     964        self.actionFreezeResults.triggered.connect(self.freezeSelectedItems) 
    959965 
    960966    def onCustomContextMenu(self, position): 
     
    977983        self.actionQuick3DPlot.setEnabled(is_2D) 
    978984        self.actionEditMask.setEnabled(is_2D) 
     985 
     986        # Freezing 
     987        # check that the selection has inner items 
     988        freeze_enabled = False 
     989        if model_item.parent() is not None: 
     990            freeze_enabled = True 
     991        self.actionFreezeResults.setEnabled(freeze_enabled) 
     992 
    979993        # Fire up the menu 
    980994        self.context_menu.exec_(self.current_view.mapToGlobal(position)) 
     
    11121126        mask_editor.exec_() 
    11131127 
     1128    def freezeItem(self, item=None): 
     1129        """ 
     1130        Freeze given item 
     1131        """ 
     1132        if item is None: 
     1133            return 
     1134        self.model.beginResetModel() 
     1135        new_item = self.cloneTheory(item) 
     1136        self.model.appendRow(new_item) 
     1137        self.model.endResetModel() 
     1138 
     1139    def freezeSelectedItems(self): 
     1140        """ 
     1141        Freeze selected items 
     1142        """ 
     1143        indices = self.treeView.selectedIndexes() 
     1144 
     1145        proxy = self.treeView.model() 
     1146        model = proxy.sourceModel() 
     1147 
     1148        for index in indices: 
     1149            row_index = proxy.mapToSource(index) 
     1150            item_to_copy = model.itemFromIndex(row_index) 
     1151            if item_to_copy and item_to_copy.isCheckable(): 
     1152                self.freezeItem(item_to_copy) 
     1153 
    11141154    def deleteItem(self): 
    11151155        """ 
     
    12721312 
    12731313        # Caption for the theories 
    1274         checkbox_item.setChild(2, QtGui.QStandardItem("THEORIES")) 
     1314        checkbox_item.setChild(2, QtGui.QStandardItem("FIT RESULTS")) 
    12751315 
    12761316        # New row in the model 
  • src/sas/qtgui/MainWindow/DataManager.py

    r4e255d1 ra54bbf2b  
    118118        new_plot.path = path 
    119119        new_plot.list_group_id = [] 
     120        # Assign the plot role to data 
     121        new_plot.plot_role = Data1D.ROLE_DATA 
    120122        ##post data to plot 
    121123        # plot data 
  • src/sas/qtgui/MainWindow/UI/DataExplorerUI.ui

    rf4a6f2c r33b3e4d  
    508508   </property> 
    509509  </action> 
     510  <action name="actionFreezeResults"> 
     511   <property name="text"> 
     512    <string>Freeze Results</string> 
     513   </property> 
     514  </action> 
    510515 </widget> 
    511516 <resources/> 
  • src/sas/qtgui/MainWindow/UI/MainWindowUI.ui

    r2f14b5d r33b3e4d  
    415415   </property> 
    416416  </action> 
    417     <action name="actionEditMask"> 
     417  <action name="actionEditMask"> 
    418418   <property name="text"> 
    419419    <string>Edit Mask</string> 
     
    549549  <action name="actionFreeze_Theory"> 
    550550   <property name="text"> 
    551     <string>Freeze Theory</string> 
     551    <string>Freeze Fit Results</string> 
    552552   </property> 
    553553  </action> 
  • src/sas/qtgui/Perspectives/Fitting/FittingLogic.py

    r61f0c75 ra54bbf2b  
    154154        new_plot.xaxis(_xaxis, _xunit) 
    155155        new_plot.yaxis(_yaxis, _yunit) 
     156 
     157        if component is not None: 
     158            new_plot.plot_role = Data1D.ROLE_DELETABLE #deletable 
    156159 
    157160        return new_plot 
  • src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py

    rf3cc979 r8b745c36  
    128128 
    129129            # Find param in volume_params 
    130             poly_pars = parameters.form_volume_parameters 
     130            poly_pars = copy.deepcopy(parameters.form_volume_parameters) 
    131131            if is2D: 
    132132                poly_pars += parameters.orientation_parameters 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    rf3cc979 r6889ba2  
    273273        self.theory_item = None 
    274274 
     275        # list column widths 
     276        self.lstParamHeaderSizes = {} 
     277 
    275278        # signal communicator 
    276279        self.communicate = self.parent.communicate 
     
    361364        self.lstParams.customContextMenuRequested.connect(self.showModelContextMenu) 
    362365        self.lstParams.setAttribute(QtCore.Qt.WA_MacShowFocusRect, False) 
     366        # Column resize signals 
     367        self.lstParams.header().sectionResized.connect(self.onColumnWidthUpdate) 
     368 
    363369        # Poly model displayed in poly list 
    364370        self.lstPoly.setModel(self._poly_model) 
     
    11081114        self.SASModelToQModel(model, structure_factor) 
    11091115 
     1116        for column, width in self.lstParamHeaderSizes.items(): 
     1117            self.lstParams.setColumnWidth(column, width) 
     1118 
    11101119        # Update plot 
    11111120        self.updateData() 
     
    16691678        self._model_model.itemChanged.connect(self.onMainParamsChange) 
    16701679 
    1671         # Adjust the table cells width. 
    1672         # TODO: find a way to dynamically adjust column width while resized expanding 
    1673         self.lstParams.resizeColumnToContents(0) 
    1674         self.lstParams.resizeColumnToContents(4) 
    1675         self.lstParams.resizeColumnToContents(5) 
    1676         self.lstParams.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 
    1677  
    16781680    def iterateOverPolyModel(self, func): 
    16791681        """ 
     
    20142016            self.magnet_params = {} 
    20152017            self.setMagneticModel() 
    2016  
    2017         # Adjust the table cells width 
    2018         self.lstParams.resizeColumnToContents(0) 
    2019         self.lstParams.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 
    20202018 
    20212019        # Now we claim the model has been loaded 
     
    23422340 
    23432341        # add polydisperse parameters if asked 
    2344         if self.chkPolydispersity.isChecked(): 
     2342        if self.chkPolydispersity.isChecked() and self._poly_model.rowCount() > 0: 
    23452343            for key, value in self.poly_params.items(): 
    23462344                model.setParam(key, value) 
    23472345        # add magnetic params if asked 
    23482346        if self.chkMagnetism.isChecked(): 
    2349             for key, value in self.magnet_params.items(): 
     2347            for key, value in self.magnet_params.items() and self._magnet_model.rowCount() > 0: 
    23502348                model.setParam(key, value) 
    23512349 
     
    24812479        residuals_plot = FittingUtilities.plotResiduals(self.data, weighted_data) 
    24822480        residuals_plot.id = "Residual " + residuals_plot.id 
     2481        residuals_plot.plot_role = Data1D.ROLE_RESIDUAL 
    24832482        self.createNewIndex(residuals_plot) 
    24842483        return residuals_plot 
     
    27262725        fname_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_filename) 
    27272726        self._poly_model.setData(fname_index, fname) 
     2727 
     2728    def onColumnWidthUpdate(self, index, old_size, new_size): 
     2729        """ 
     2730        Simple state update of the current column widths in the  param list 
     2731        """ 
     2732        self.lstParamHeaderSizes[index] = new_size 
    27282733 
    27292734    def setMagneticModel(self): 
  • src/sas/qtgui/Plotting/Plotter2D.py

    rfce6c55 r676a430  
    445445                                        self.ymin, self.ymax)) 
    446446 
    447             cbax = self.figure.add_axes([0.84, 0.2, 0.02, 0.7]) 
     447            cbax = self.figure.add_axes([0.88, 0.2, 0.02, 0.7]) 
    448448 
    449449            # Current labels for axes 
  • src/sas/qtgui/Plotting/PlotterData.py

    rcee5c78 ra54bbf2b  
    1717    """ 
    1818    """ 
     19    ROLE_DATA=0 
     20    ROLE_DEFAULT=1 
     21    ROLE_DELETABLE=2 
     22    ROLE_RESIDUAL=3 
    1923    def __init__(self, x=None, y=None, dx=None, dy=None): 
    2024        """ 
     
    3539        self.title = "" 
    3640        self.scale = None 
     41        # plot_role: 
     42        # 0: data - no reload on param change 
     43        # 1: normal lifecycle (fit) 
     44        # 2: deletable on model change (Q(I), S(I)...) 
     45        # 3: separate chart on Show Plot (residuals) 
     46        self.plot_role = Data1D.ROLE_DEFAULT 
    3747         
    3848    def copy_from_datainfo(self, data1d): 
     
    184194        self.title = "" 
    185195        self.scale = None 
     196        # Always default 
     197        self.plot_role = Data1D.ROLE_DEFAULT 
    186198         
    187199    def copy_from_datainfo(self, data2d): 
  • src/sas/qtgui/Utilities/GuiUtils.py

    r5d28d6b ra54bbf2b  
    322322    assert isinstance(item, QtGui.QStandardItem) 
    323323 
     324    # lists of plots names/ids for all deletable plots on item 
    324325    names = [p.name for p in new_plots if p.name is not None] 
    325326    ids = [p.id for p in new_plots if p.id is not None] 
     
    329330    for index in range(item.rowCount()): 
    330331        plot_item = item.child(index) 
    331         if plot_item.isCheckable(): 
    332             plot_data = plot_item.child(0).data() 
    333             if (plot_data.id is not None) and (plot_data.id not in ids) and (plot_data.name not in names): 
    334                 items_to_delete.append(plot_item) 
     332        if not plot_item.isCheckable(): 
     333            continue 
     334        plot_data = plot_item.child(0).data() 
     335        if (plot_data.id is not None) and \ 
     336            (plot_data.id not in ids) and \ 
     337            (plot_data.name not in names) and \ 
     338            (plot_data.plot_role == Data1D.ROLE_DELETABLE): 
     339            items_to_delete.append(plot_item) 
    335340 
    336341    for plot_item in items_to_delete: 
Note: See TracChangeset for help on using the changeset viewer.