Changeset 305114c in sasview for src


Ignore:
Timestamp:
Sep 14, 2018 8:10:09 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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:
aa88b76
Parents:
86d3207
Message:

Added a warning label to simple and complex constraint widgets,
shown whenever polydisperse parameters are constrained SASVIEW-1042

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
6 edited

Legend:

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

    raed0532 r305114c  
    1313import webbrowser 
    1414 
     15from sas.qtgui.Perspectives.Fitting import FittingUtilities 
    1516import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    1617ALLOWED_OPERATORS = ['=','<','>','>=','<='] 
     
    3233        self.operator = '=' 
    3334 
     35        self.warning = self.lblWarning.text() 
    3436        self.setupData() 
     37        self.setupSignals() 
    3538        self.setupWidgets() 
    36         self.setupSignals() 
    3739        self.setupTooltip() 
    38  
    39         self.setFixedSize(self.minimumSizeHint()) 
    4040 
    4141        # Default focus is on OK 
     
    101101        # Find out the signal source 
    102102        source = self.sender().objectName() 
     103        param1 = self.cbParam1.currentText() 
     104        param2 = self.cbParam2.currentText() 
    103105        if source == "cbParam1": 
    104             self.txtParam.setText(self.tab_names[0] + ":" + self.cbParam1.currentText()) 
     106            self.txtParam.setText(self.tab_names[0] + ":" + param1) 
    105107        else: 
    106             self.txtConstraint.setText(self.tab_names[1] + "." + self.cbParam2.currentText()) 
     108            self.txtConstraint.setText(self.tab_names[1] + "." + param2) 
     109        # Check if any of the parameters are polydisperse 
     110        params_list = [param1, param2] 
     111        all_pars = [tab.model_parameters for tab in self.tabs] 
     112        is2Ds = [tab.is2D for tab in self.tabs] 
     113        txt = "" 
     114        for pars, is2D in zip(all_pars, is2Ds): 
     115            if any([FittingUtilities.isParamPolydisperse(p, pars, is2D) for p in params_list]): 
     116                # no parameters are pd - reset the text to not show the warning 
     117                txt = self.warning 
     118        self.lblWarning.setText(txt) 
     119 
    107120 
    108121    def onOperatorChange(self, index): 
  • src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py

    r1a15ada r305114c  
    781781 
    782782    return output_string 
     783 
     784def isParamPolydisperse(param_name, kernel_params, is2D=False): 
     785    """ 
     786    Simple lookup for polydispersity for the given param name 
     787    """ 
     788    parameters = kernel_params.form_volume_parameters 
     789    if is2D: 
     790        parameters += kernel_params.orientation_parameters 
     791    has_poly = False 
     792    for param in parameters: 
     793        if param.name==param_name and param.polydisperse: 
     794            has_poly = True 
     795            break 
     796    return has_poly 
     797 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r86d3207 r305114c  
    649649        # Create and display the widget for param1 and param2 
    650650        mc_widget = MultiConstraint(self, params=params_list) 
     651        # Check if any of the parameters are polydisperse 
     652        if not np.any([FittingUtilities.isParamPolydisperse(p, self.model_parameters, is2D=self.is2D) for p in params_list]): 
     653            # no parameters are pd - reset the text to not show the warning 
     654            mc_widget.lblWarning.setText("") 
    651655        if mc_widget.exec_() != QtWidgets.QDialog.Accepted: 
    652656            return 
  • src/sas/qtgui/Perspectives/Fitting/MultiConstraint.py

    raed0532 r305114c  
    2828 
    2929        self.setupUi(self) 
    30         self.setFixedSize(self.minimumSizeHint()) 
    3130        self.setModal(True) 
    3231        self.params = params 
  • src/sas/qtgui/Perspectives/Fitting/UI/ComplexConstraintUI.ui

    ra90c9c5 r305114c  
    77    <x>0</x> 
    88    <y>0</y> 
    9     <width>406</width> 
    10     <height>167</height> 
     9    <width>463</width> 
     10    <height>234</height> 
    1111   </rect> 
    1212  </property> 
     
    2121     </property> 
    2222     <layout class="QGridLayout" name="gridLayout"> 
     23      <item row="1" column="0"> 
     24       <layout class="QHBoxLayout" name="horizontalLayout_2"> 
     25        <item> 
     26         <widget class="QLabel" name="txtParam"> 
     27          <property name="sizePolicy"> 
     28           <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> 
     29            <horstretch>0</horstretch> 
     30            <verstretch>0</verstretch> 
     31           </sizepolicy> 
     32          </property> 
     33          <property name="text"> 
     34           <string>param1</string> 
     35          </property> 
     36         </widget> 
     37        </item> 
     38        <item> 
     39         <widget class="QLabel" name="txtOperator"> 
     40          <property name="text"> 
     41           <string>=</string> 
     42          </property> 
     43         </widget> 
     44        </item> 
     45        <item> 
     46         <widget class="QLineEdit" name="txtConstraint"> 
     47          <property name="text"> 
     48           <string/> 
     49          </property> 
     50         </widget> 
     51        </item> 
     52       </layout> 
     53      </item> 
    2354      <item row="0" column="0"> 
    2455       <layout class="QHBoxLayout" name="horizontalLayout"> 
     
    98129       </layout> 
    99130      </item> 
    100       <item row="1" column="0"> 
    101        <spacer name="verticalSpacer"> 
    102         <property name="orientation"> 
    103          <enum>Qt::Vertical</enum> 
    104         </property> 
    105         <property name="sizeHint" stdset="0"> 
    106          <size> 
    107           <width>20</width> 
    108           <height>25</height> 
    109          </size> 
    110         </property> 
    111        </spacer> 
    112       </item> 
    113       <item row="2" column="0"> 
    114        <layout class="QHBoxLayout" name="horizontalLayout_2"> 
    115         <item> 
    116          <widget class="QLabel" name="txtParam"> 
    117           <property name="sizePolicy"> 
    118            <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> 
    119             <horstretch>0</horstretch> 
    120             <verstretch>0</verstretch> 
    121            </sizepolicy> 
    122           </property> 
    123           <property name="text"> 
    124            <string>param1</string> 
    125           </property> 
    126          </widget> 
    127         </item> 
    128         <item> 
    129          <widget class="QLabel" name="txtOperator"> 
    130           <property name="text"> 
    131            <string>=</string> 
    132           </property> 
    133          </widget> 
    134         </item> 
    135         <item> 
    136          <widget class="QLineEdit" name="txtConstraint"> 
    137           <property name="text"> 
    138            <string/> 
    139           </property> 
    140          </widget> 
    141         </item> 
    142        </layout> 
    143       </item> 
    144131     </layout> 
    145132    </widget> 
    146133   </item> 
    147134   <item row="1" column="0"> 
     135    <widget class="QLabel" name="lblWarning"> 
     136     <property name="text"> 
     137      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;Warning! Polydisperse parameter selected.&lt;br/&gt;&lt;/span&gt;Constraints involving polydisperse parameters only apply to&lt;br/&gt;starting values and are nor re-applied during size or angle polydispersity&lt;br/&gt;integrations. To do which requires creating a custom model.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
     138     </property> 
     139    </widget> 
     140   </item> 
     141   <item row="2" column="0"> 
     142    <spacer name="verticalSpacer_2"> 
     143     <property name="orientation"> 
     144      <enum>Qt::Vertical</enum> 
     145     </property> 
     146     <property name="sizeHint" stdset="0"> 
     147      <size> 
     148       <width>20</width> 
     149       <height>9</height> 
     150      </size> 
     151     </property> 
     152    </spacer> 
     153   </item> 
     154   <item row="3" column="0"> 
    148155    <layout class="QHBoxLayout" name="horizontalLayout_3"> 
    149156     <item> 
  • src/sas/qtgui/Perspectives/Fitting/UI/MultiConstraintUI.ui

    ra90c9c5 r305114c  
    1111    <y>0</y> 
    1212    <width>426</width> 
    13     <height>162</height> 
     13    <height>185</height> 
    1414   </rect> 
    1515  </property> 
    1616  <property name="sizePolicy"> 
    17    <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> 
     17   <sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding"> 
    1818    <horstretch>0</horstretch> 
    1919    <verstretch>0</verstretch> 
     
    119119   </item> 
    120120   <item row="2" column="0"> 
     121    <widget class="QLabel" name="lblWarning"> 
     122     <property name="text"> 
     123      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;Warning! &lt;/span&gt;Constraints involving polydisperse parameters only apply to&lt;br/&gt;starting values and are nor re-applied during size or angle polydispersity&lt;br/&gt;integrations. To do which requires creating a custom model.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
     124     </property> 
     125    </widget> 
     126   </item> 
     127   <item row="3" column="0"> 
    121128    <spacer name="verticalSpacer"> 
    122129     <property name="orientation"> 
     
    131138    </spacer> 
    132139   </item> 
    133    <item row="3" column="0"> 
     140   <item row="4" column="0"> 
    134141    <layout class="QHBoxLayout" name="horizontalLayout_2"> 
    135142     <item> 
Note: See TracChangeset for help on using the changeset viewer.