Changes in / [68dc2873:d7adf97] in sasview


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

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Calculators/UnitTesting/SLDCalculatorTest.py

    r144fe21 r9ce69ec  
    8181        self.assertEqual(self.widget.ui.editMolecularFormula.styleSheet(), '') 
    8282        self.assertEqual(self.widget.model.columnCount(), 1) 
    83         self.assertEqual(self.widget.model.rowCount(), 12) 
     83        self.assertEqual(self.widget.model.rowCount(), 11) 
    8484        self.assertEqual(self.widget.sizePolicy().Policy(), QtWidgets.QSizePolicy.Fixed) 
    8585 
    8686    def testSimpleEntry(self): 
    8787        ''' Default compound calculations ''' 
    88  
    89         self.widget.show() 
    9088 
    9189        self.widget.ui.editMassDensity.clear() 
     
    102100 
    103101        # Change mass density 
    104         self.widget.ui.editWavelength.clear() 
    105         self.widget.ui.editWavelength.setText("666.0") 
     102        self.widget.ui.editNeutronWavelength.clear() 
     103        self.widget.ui.editNeutronWavelength.setText("666.0") 
    106104 
    107105        # Send shift-tab to update the molar volume field 
     
    130128 
    131129        # Assure the mass density field is set 
    132         self.assertEqual(self.widget.ui.editNeutronIncXs.text(), '43.4') 
     130        #self.assertEqual(self.widget.ui.editNeutronIncXs.text(), '43.4') 
     131        self.assertEqual(self.widget.ui.editNeutronIncXs.text(), '2.89') 
    133132 
    134133        # Reset the widget 
    135134        self.widget.modelReset() 
    136  
     135        
    137136        self.assertEqual(self.widget.ui.editMolecularFormula.text(), "H2O") 
    138137        self.assertEqual(self.widget.ui.editMassDensity.text(), "1") 
  • src/sas/qtgui/MainWindow/DataExplorer.py

    r855e7ad r9ce69ec  
    598598        Forces display of charts for the given data set 
    599599        """ 
    600         plot_to_show = data_list[0] 
    601         # passed plot is used ONLY to figure out its title, 
    602         # so all the charts related by it can be pulled from  
    603         # the data explorer indices. 
    604         filename = plot_to_show.filename 
    605         self.displayFile(filename=filename, is_data=plot_to_show.is_data, id=id) 
     600        # data_list = [QStandardItem, Data1D/Data2D] 
     601        plot_to_show = data_list[1] 
     602        plot_item = data_list[0] 
     603 
     604        # plots to show 
     605        new_plots = [] 
     606 
     607        # Check if this is merely a plot update 
     608        if self.updatePlot(plot_to_show): 
     609            return 
     610 
     611        # Residuals get their own plot 
     612        if plot_to_show.plot_role == Data1D.ROLE_RESIDUAL: 
     613            plot_to_show.yscale='linear' 
     614            self.plotData([(plot_item, plot_to_show)]) 
     615        elif plot_to_show.plot_role == Data1D.ROLE_DELETABLE: 
     616            # No plot 
     617            return 
     618        else: 
     619            # Plots with main data points on the same chart 
     620            # Get the main data plot 
     621            main_data = GuiUtils.dataFromItem(plot_item.parent()) 
     622            if main_data is None: 
     623                # Try the current item 
     624                main_data = GuiUtils.dataFromItem(plot_item) 
     625            if main_data is not None: 
     626                new_plots.append((plot_item, main_data)) 
     627            new_plots.append((plot_item, plot_to_show)) 
     628 
     629        if new_plots: 
     630            self.plotData(new_plots) 
    606631 
    607632    def addDataPlot2D(self, plot_set, item): 
     
    701726        # old plot data 
    702727        plot_id = str(self.cbgraph.currentText()) 
    703  
    704         assert plot_id in PlotHelper.currentPlots(), "No such plot: %s"%(plot_id) 
     728        try: 
     729            assert plot_id in PlotHelper.currentPlots(), "No such plot: %s"%(plot_id) 
     730        except: 
     731            return 
    705732 
    706733        old_plot = PlotHelper.plotById(plot_id) 
  • src/sas/qtgui/MainWindow/GuiManager.py

    r768387e0 rfc5d2d7f  
    1212from twisted.internet import reactor 
    1313# General SAS imports 
     14from sas import get_local_config, get_custom_config 
    1415from sas.qtgui.Utilities.ConnectionProxy import ConnectionProxy 
    1516from sas.qtgui.Utilities.SasviewLogger import setup_qt_logging 
     
    136137        self.aboutWidget = AboutBox() 
    137138        self.categoryManagerWidget = CategoryManager(self._parent, manager=self) 
    138         self.welcomePanel = WelcomePanel() 
    139139        self.grid_window = None 
    140140        self._workspace.toolBar.setVisible(LocalConfig.TOOLBAR_SHOW) 
     
    241241        perspective_width = perspective_size.width() 
    242242        self._current_perspective.resize(perspective_width, workspace_height-10) 
    243         # Resize the mdi area to match the widget within 
    244         subwindow.resize(subwindow.minimumSizeHint()) 
    245243 
    246244        self._current_perspective.show() 
     
    388386            self.communicate.statusBarUpdateSignal.emit(msg) 
    389387 
    390     def showWelcomeMessage(self): 
     388    def actionWelcome(self): 
    391389        """ Show the Welcome panel """ 
     390        self.welcomePanel = WelcomePanel() 
    392391        self._workspace.workspace.addSubWindow(self.welcomePanel) 
    393392        self.welcomePanel.show() 
     393 
     394    def showWelcomeMessage(self): 
     395        """ Show the Welcome panel, when required """ 
     396        # Assure the welcome screen is requested 
     397        show_welcome_widget = True 
     398        custom_config = get_custom_config() 
     399        if hasattr(custom_config, "WELCOME_PANEL_SHOW"): 
     400            if isinstance(custom_config.WELCOME_PANEL_SHOW, bool): 
     401                show_welcome_widget = custom_config.WELCOME_PANEL_SHOW 
     402            else: 
     403                logging.warning("WELCOME_PANEL_SHOW has invalid value in custom_config.py") 
     404        if show_welcome_widget: 
     405            self.actionWelcome() 
    394406 
    395407    def addCallbacks(self): 
     
    478490        self._workspace.actionAcknowledge.triggered.connect(self.actionAcknowledge) 
    479491        self._workspace.actionAbout.triggered.connect(self.actionAbout) 
     492        self._workspace.actionWelcomeWidget.triggered.connect(self.actionWelcome) 
    480493        self._workspace.actionCheck_for_update.triggered.connect(self.actionCheck_for_update) 
    481494 
  • src/sas/qtgui/MainWindow/UI/MainWindowUI.ui

    r768387e0 rfc5d2d7f  
    148148    <addaction name="separator"/> 
    149149    <addaction name="actionAbout"/> 
     150    <addaction name="actionWelcomeWidget"/> 
     151    <addaction name="separator"/> 
    150152    <addaction name="actionCheck_for_update"/> 
    151153   </widget> 
     
    558560   </property> 
    559561  </action> 
     562  <action name="actionWelcomeWidget"> 
     563   <property name="text"> 
     564    <string>Welcome to SasView</string> 
     565   </property> 
     566  </action> 
    560567 </widget> 
    561568 <resources/> 
  • 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 r9ce69ec  
    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 
     
    18451849        # Show the chart if ready 
    18461850        data_to_show = self.data if self.data_is_loaded else self.model_data 
    1847         if data_to_show is not None: 
    1848             self.communicate.plotRequestedSignal.emit([data_to_show], self.tab_id) 
     1851        # Any models for this page 
     1852        current_index = self.all_data[self.data_index] 
     1853        plots = GuiUtils.plotsFromFilename(self.data.filename, current_index.model()) 
     1854        fitpage_name = "" if id is None else "M"+str(self.tab_id) 
     1855        # Has the fitted data been shown? 
     1856        data_shown = False 
     1857        #for plot in plots: 
     1858        for item, plot in plots.items(): 
     1859            if fitpage_name in plot.name: 
     1860                data_shown = True 
     1861                self.communicate.plotRequestedSignal.emit([item, plot], self.tab_id) 
     1862        if not data_shown: 
     1863            # fit+data has not been shown - show just data 
     1864            self.communicate.plotRequestedSignal.emit([item, data_to_show], self.tab_id) 
    18491865 
    18501866    def onOptionsUpdate(self): 
     
    20762092        self.kernel_module = self.models[model_name]() 
    20772093 
     2094        # Change the model name to a monicker 
     2095        self.kernel_module.name = self.modelName() 
     2096 
    20782097        # Explicitly add scale and background with default values 
    20792098        temp_undo_state = self.undo_supported 
     
    21082127            # Structure factor is the only selected model; build it and show all its params 
    21092128            self.kernel_module = self.models[structure_factor]() 
     2129            self.kernel_module.name = self.modelName() 
    21102130            s_params = self.kernel_module._model_info.parameters 
    21112131            s_params_orig = s_params 
     
    21182138 
    21192139            self.kernel_module = MultiplicationModel(p_kernel, s_kernel) 
     2140            # Modify the name to correspond to shown items 
     2141            self.kernel_module.name = self.modelName() 
    21202142            all_params = self.kernel_module._model_info.parameters.kernel_parameters 
    21212143            all_param_names = [param.name for param in all_params] 
     
    24232445        # Bring the GUI to normal state 
    24242446        self.enableInteractiveElements() 
    2425  
     2447        if return_data is None: 
     2448            self.calculateDataFailed("Results not available.") 
     2449            return 
    24262450        fitted_data = self.logic.new1DPlot(return_data, self.tab_id) 
    24272451        residuals = self.calculateResiduals(fitted_data) 
  • 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 r1738173  
    77    <x>0</x> 
    88    <y>0</y> 
    9     <width>406</width> 
    10     <height>167</height> 
     9    <width>367</width> 
     10    <height>199</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 not re-applied during size or angle polydispersity&lt;br/&gt;integrations. To do so 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/FittingWidgetUI.ui

    ra2e8ea5 rfc5d2d7f  
    77    <x>0</x> 
    88    <y>0</y> 
    9     <width>566</width> 
     9    <width>651</width> 
    1010    <height>646</height> 
    1111   </rect> 
  • src/sas/qtgui/Perspectives/Fitting/UI/MultiConstraintUI.ui

    ra90c9c5 r1738173  
    1010    <x>0</x> 
    1111    <y>0</y> 
    12     <width>426</width> 
    13     <height>162</height> 
     12    <width>369</width> 
     13    <height>201</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! Polydisperse parameter selected.&lt;br/&gt;&lt;/span&gt;Constraints involving polydisperse parameters only apply to&lt;br/&gt;starting values and are not re-applied during size or angle polydispersity&lt;br/&gt;integrations. To do so 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> 
  • src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py

    raed0532 r9ce69ec  
    233233 
    234234        plot_data = GuiUtils.plotsFromCheckedItems(self._manager.filesWidget.model) 
     235        #self.communicate.plotRequestedSignal.emit([item, plot], self.tab_id) 
    235236 
    236237        self._manager.filesWidget.plotData(plot_data) 
     
    347348                extrapolated_data.name = title 
    348349                extrapolated_data.title = title 
     350                extrapolated_data.style = "Line" 
     351                extrapolated_data.has_errors = False 
     352                extrapolated_data.plot_role = Data1D.ROLE_DEFAULT 
    349353 
    350354                # copy labels and units of axes for plotting 
     
    378382                high_out_data.name = title 
    379383                high_out_data.title = title 
     384                high_out_data.style = "Line" 
     385                high_out_data.has_errors = False 
     386                high_out_data.plot_role = Data1D.ROLE_DEFAULT 
    380387 
    381388                # copy labels and units of axes for plotting 
  • src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py

    r68dc2873 r9ce69ec  
    572572            self.prPlot.plot_role = Data1D.ROLE_RESIDUAL 
    573573            GuiUtils.updateModelItemWithPlot(self._data, self.prPlot, title) 
     574            self.communicate.plotRequestedSignal.emit([self._data,self.prPlot], None) 
    574575        if self.dataPlot is not None: 
    575576            title = self.dataPlot.name 
    576577            self.dataPlot.plot_role = Data1D.ROLE_DEFAULT 
     578            self.dataPlot.symbol = "Line" 
     579            self.dataPlot.show_errors = False 
    577580            GuiUtils.updateModelItemWithPlot(self._data, self.dataPlot, title) 
    578         if self.dataPlot is not None or self.prPlot is not None: 
    579             self.communicate.plotRequestedSignal.emit([self.logic.data], None) 
     581            self.communicate.plotRequestedSignal.emit([self._data,self.dataPlot], None) 
    580582        self.enableButtons() 
    581583 
  • src/sas/qtgui/Utilities/GuiUtils.py

    ra54bbf2b r9ce69ec  
    567567    The assumption - data stored in SasView standard, in child 0 
    568568    """ 
    569     return item.child(0).data() 
     569    try: 
     570        data = item.child(0).data() 
     571    except AttributeError: 
     572        data = None 
     573    return data 
    570574 
    571575def openLink(url): 
Note: See TracChangeset for help on using the changeset viewer.