Changeset e1e3e09 in sasview


Ignore:
Timestamp:
Apr 21, 2017 6:40:01 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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:
98b13f72
Parents:
9d266d2
Message:

Refactor instrumental smearing tab + make it functional

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
2 added
2 edited

Legend:

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

    r9d266d2 re1e3e09  
    3030from sas.qtgui.Perspectives.Fitting.FittingLogic import FittingLogic 
    3131from sas.qtgui.Perspectives.Fitting import FittingUtilities 
     32from SmearingWidget import SmearingWidget 
    3233 
    3334TAB_MAGNETISM = 4 
     
    9192        self.communicate = self.parent.communicate 
    9293 
     94        # Smearing widget 
     95        layout = QtGui.QGridLayout() 
     96        self.smearing_widget = SmearingWidget(self) 
     97        layout.addWidget(self.smearing_widget)  
     98        #self.tabFitting.removeTab(2) 
     99        self.tabFitting.insertTab(2, self.smearing_widget, "Resolution") 
     100 
    93101        # Define bold font for use in various controls 
    94102        self.boldFont=QtGui.QFont() 
     
    161169        self.logic.data = GuiUtils.dataFromItem(value) 
    162170 
     171        # Overwrite data type descriptor 
     172        self.is2D = True if isinstance(self.logic.data, Data2D) else False 
     173 
    163174        self.data_is_loaded = True 
     175 
     176        # Enable/disable UI components 
     177        self.setEnablementOnDataLoad() 
     178 
     179    def setEnablementOnDataLoad(self): 
     180        """ 
     181        Enable/disable various UI elements based on data loaded 
     182        """ 
    164183        # Tag along functionality 
    165184        self.label.setText("Data loaded from: ") 
     
    173192        self.txtNptsFit.setEnabled(False) 
    174193        self.chkLogData.setEnabled(False) 
     194        # Switch off Data2D control 
     195        self.chk2DView.setEnabled(False) 
     196        self.chk2DView.setVisible(False) 
     197        self.chkMagnetism.setEnabled(True) 
     198 
     199        # Weighting and smearing controls 
     200        if self.is2D: 
     201            #self.slit_smearer.Disable() 
     202            #self.pinhole_smearer.Enable(True) 
     203            #self.default_mask = copy.deepcopy(self.data.mask) 
     204            if self.logic.data.err_data is None or\ 
     205                    numpy.all(err == 1 for err in self.logic.data.err_data) or \ 
     206                    not numpy.any(self.logic.data.err_data): 
     207                self.rbWeighting2.setEnabled(False) 
     208                self.rbWeighting1.setChecked(True) 
     209            else: 
     210                self.rbWeighting2.setEnabled(True) 
     211                self.rbWeighting2.setChecked(True) 
     212        else: 
     213            #self.slit_smearer.Enable(True) 
     214            #self.pinhole_smearer.Enable(True) 
     215            if self.logic.data.dy is None or\ 
     216                    numpy.all(self.logic.data.dy == 1) or\ 
     217                    not numpy.any(self.logic.data.dy): 
     218                self.rbWeighting2.setEnabled(False) 
     219                self.rbWeighting1.setChecked(True) 
     220            else: 
     221                self.rbWeighting2.setEnabled(True) 
     222                self.rbWeighting2.setChecked(True) 
     223 
     224        # Smearing tab 
     225        self.smearing_widget.updateSmearing(self.data) 
    175226 
    176227    def acceptsData(self): 
     
    211262        self.is2D = isChecked 
    212263        # Reload the current model 
    213         self.onSelectModel() 
     264        if self.kernel_module: 
     265            self.onSelectModel() 
    214266 
    215267    def toggleLogData(self, isChecked): 
     
    242294        self.weightingGroup.addButton(self.rbWeighting3) 
    243295        self.weightingGroup.addButton(self.rbWeighting4) 
     296        # Smearing tab 
     297        self.smearing_widget.updateSmearing(self.data) 
    244298 
    245299    def initializeSignals(self): 
     
    251305        self.cbCategory.currentIndexChanged.connect(self.onSelectCategory) 
    252306        self.cbModel.currentIndexChanged.connect(self.onSelectModel) 
    253         self.cbSmearing.currentIndexChanged.connect(self.onSelectSmearing) 
     307        #self.cbSmearing.currentIndexChanged.connect(self.onSelectSmearing) 
    254308        # Checkboxes 
    255309        self.chk2DView.toggled.connect(self.toggle2D) 
     
    266320        self.txtMinRange.editingFinished.connect(self.onMinRange) 
    267321        self.txtMaxRange.editingFinished.connect(self.onMaxRange) 
    268         self.txtSmearUp.editingFinished.connect(self.onSmearUp) 
    269         self.txtSmearDown.editingFinished.connect(self.onSmearDown) 
     322        #self.txtSmearUp.editingFinished.connect(self.onSmearUp) 
     323        #self.txtSmearDown.editingFinished.connect(self.onSmearDown) 
    270324        # Button groups 
    271325        self.weightingGroup.buttonClicked.connect(self.onWeightingChoice) 
     
    717771        # Check the state of the Weighting radio buttons 
    718772        button_id = self.weightingGroup.checkedId() 
     773        # Cast the id to a valid index 
    719774        button_id = abs(button_id + 2) 
    720775        if button_id == 0: 
     776            # No weight added 
    721777            return 
    722778        # Send original data for weighting 
  • src/sas/qtgui/Perspectives/Fitting/UI/FittingWidgetUI.ui

    r9d266d2 re1e3e09  
    561561      </layout> 
    562562     </widget> 
    563      <widget class="QWidget" name="tab_5"> 
    564       <attribute name="title"> 
    565        <string>Resolution</string> 
    566       </attribute> 
    567       <layout class="QGridLayout" name="gridLayout_14"> 
    568        <item row="0" column="0"> 
    569         <widget class="QGroupBox" name="groupBox_4"> 
    570          <property name="title"> 
    571           <string>Instrumental Smearing</string> 
    572          </property> 
    573          <layout class="QGridLayout" name="gridLayout_13"> 
    574           <item row="0" column="0"> 
    575            <widget class="QComboBox" name="cbSmearing"> 
    576             <property name="currentIndex"> 
    577              <number>0</number> 
    578             </property> 
    579             <item> 
    580              <property name="text"> 
    581               <string>None</string> 
    582              </property> 
    583             </item> 
    584             <item> 
    585              <property name="text"> 
    586               <string>Use dQ Data</string> 
    587              </property> 
    588             </item> 
    589             <item> 
    590              <property name="text"> 
    591               <string>Custom Pinhole Smear</string> 
    592              </property> 
    593             </item> 
    594             <item> 
    595              <property name="text"> 
    596               <string>Custom Slit Smear</string> 
    597              </property> 
    598             </item> 
    599            </widget> 
    600           </item> 
    601           <item row="0" column="1"> 
    602            <layout class="QGridLayout" name="gridLayout_11"> 
    603             <item row="0" column="0"> 
    604              <widget class="QLabel" name="lblSmearUp"> 
    605               <property name="text"> 
    606                <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;dQ&lt;span style=&quot; vertical-align:sub;&quot;&gt;low&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
    607               </property> 
    608              </widget> 
    609             </item> 
    610             <item row="0" column="1"> 
    611              <widget class="QLineEdit" name="txtSmearUp"/> 
    612             </item> 
    613             <item row="0" column="2"> 
    614              <widget class="QLabel" name="label_14"> 
    615               <property name="text"> 
    616                <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;à
    617 &lt;span style=&quot; vertical-align:super;&quot;&gt;-1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
    618               </property> 
    619              </widget> 
    620             </item> 
    621             <item row="1" column="0"> 
    622              <widget class="QLabel" name="lblSmearDown"> 
    623               <property name="text"> 
    624                <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;dQ&lt;span style=&quot; vertical-align:sub;&quot;&gt;high&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
    625               </property> 
    626              </widget> 
    627             </item> 
    628             <item row="1" column="1"> 
    629              <widget class="QLineEdit" name="txtSmearDown"/> 
    630             </item> 
    631             <item row="1" column="2"> 
    632              <widget class="QLabel" name="label_15"> 
    633               <property name="text"> 
    634                <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;à
    635 &lt;span style=&quot; vertical-align:super;&quot;&gt;-1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 
    636               </property> 
    637              </widget> 
    638             </item> 
    639            </layout> 
    640           </item> 
    641           <item row="0" column="2"> 
    642            <spacer name="horizontalSpacer_2"> 
    643             <property name="orientation"> 
    644              <enum>Qt::Horizontal</enum> 
    645             </property> 
    646             <property name="sizeHint" stdset="0"> 
    647              <size> 
    648               <width>71</width> 
    649               <height>20</height> 
    650              </size> 
    651             </property> 
    652            </spacer> 
    653           </item> 
    654          </layout> 
    655          <zorder>cbSmearing</zorder> 
    656          <zorder>horizontalSpacer_2</zorder> 
    657         </widget> 
    658        </item> 
    659        <item row="1" column="0"> 
    660         <spacer name="verticalSpacer_2"> 
    661          <property name="orientation"> 
    662           <enum>Qt::Vertical</enum> 
    663          </property> 
    664          <property name="sizeHint" stdset="0"> 
    665           <size> 
    666            <width>20</width> 
    667            <height>340</height> 
    668           </size> 
    669          </property> 
    670         </spacer> 
    671        </item> 
    672       </layout> 
    673      </widget> 
    674563     <widget class="QWidget" name="tab_4"> 
    675564      <attribute name="title"> 
Note: See TracChangeset for help on using the changeset viewer.