Changeset f0bb711 in sasview


Ignore:
Timestamp:
Oct 19, 2017 6:25:24 AM (7 years ago)
Author:
celinedurniak <celine.durniak@…>
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:
0c468bf
Parents:
d5c5d3d
Message:

Implemented comments from review for Data Operation Panel (ESS-GUI-SasView?-245)

Location:
src/sas/qtgui
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Calculators/DataOperationUtilityPanel.py

    rd5c5d3d rf0bb711  
     1import time 
     2import logging 
     3import re 
     4import copy 
     5 
    16from PyQt4 import QtGui 
    27from PyQt4 import QtCore 
     
    611from sas.qtgui.Plotting.PlotterData import Data2D 
    712from sas.qtgui.Plotting.Plotter2D import Plotter2DWidget 
    8  
    913import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     14 
    1015from UI.DataOperationUtilityUI import Ui_DataOperationUtility 
    11  
    12 import time 
    13 import logging 
    14 import re 
    1516 
    1617BG_WHITE = "background-color: rgb(255, 255, 255);" 
    1718BG_RED = "background-color: rgb(244, 170, 164);" 
     19 
    1820 
    1921class DataOperationUtilityPanel(QtGui.QDialog, Ui_DataOperationUtility): 
     
    3335 
    3436        # To update content of comboboxes with files loaded in DataExplorer 
    35         self.communicator.sendDataToPanel.connect(self.updateCombobox) 
     37        self.communicator.sendDataToPanelSignal.connect(self.updateCombobox) 
    3638 
    3739        # change index of comboboxes 
     
    4547 
    4648        # push buttons 
    47         self.cmdClose.clicked.connect(self.onClose)  # accept) 
     49        self.cmdClose.clicked.connect(self.onClose) 
    4850        self.cmdHelp.clicked.connect(self.onHelp) 
    4951        self.cmdCompute.clicked.connect(self.onCompute) 
     
    5557        self.txtNumber.setValidator(QtGui.QDoubleValidator()) 
    5658 
    57         # Add "?" to initial graphs (when they are still empty) 
    5859        self.layoutOutput = QtGui.QHBoxLayout() 
    5960        self.layoutData1 = QtGui.QHBoxLayout() 
    6061        self.layoutData2 = QtGui.QHBoxLayout() 
    6162 
     63        # Create default layout for initial graphs (when they are still empty) 
    6264        self.newPlot(self.graphOutput, self.layoutOutput) 
    6365        self.newPlot(self.graphData1, self.layoutData1) 
     
    8385            list_datafiles = [] 
    8486 
    85             for id in filenames.keys(): 
    86                 if filenames[id].get_data().title != '': 
     87            for key_id in filenames.keys(): 
     88                if filenames[key_id].get_data().title: 
    8789                    # filenames with titles 
    88                     new_title = filenames[id].get_data().title 
     90                    new_title = filenames[key_id].get_data().title 
    8991                    list_datafiles.append(new_title) 
    9092                    self.list_data_items.append(new_title) 
     
    9294                else: 
    9395                    # filenames without titles by removing time.time() 
    94                     new_title = re.sub('\d{10}\.\d{2}', '', str(id)) 
     96                    new_title = re.sub('\d{10}\.\d{2}', '', str(key_id)) 
    9597                    self.list_data_items.append(new_title) 
    9698                    list_datafiles.append(new_title) 
     
    161163 
    162164    def onSelectOperator(self): 
    163         """ Change GUI when operator changed""" 
     165        """ Change GUI when operator changed """ 
    164166        self.lblOperatorApplied.setText(self.cbOperator.currentText()) 
    165167        self.newPlot(self.graphOutput, self.layoutOutput) 
     
    183185        self.data1 = None 
    184186        self.data2 = None 
     187        self.filenames = None 
     188        self.list_data_items = [] 
    185189 
    186190        self.data1OK = False 
     
    204208            self.data1OK = False 
    205209            self.cmdCompute.setEnabled(False) 
    206             # logging.info('Choose a file for Data1') 
     210            self.onCheckChosenData() 
    207211            return 
    208212 
     
    211215            self.cmdCompute.setEnabled(self.data2OK) 
    212216            self.data1OK = True 
     217            self.onCheckChosenData() 
    213218            # get Data1 
    214             id1 = self._findId(choice_data1) 
    215             self.data1 = self._extractData(id1) 
     219            key_id1 = self._findId(choice_data1) 
     220            self.data1 = self._extractData(key_id1) 
    216221            # plot Data1 
    217222            self.updatePlot(self.graphData1, self.layoutData1, self.data1) 
     
    219224            self.newPlot(self.graphOutput, self.layoutOutput) 
    220225 
     226 
    221227    def onSelectData2(self): 
    222228        """ Plot for selection of Data2 """ 
     
    228234            self.txtNumber.setEnabled(False) 
    229235            self.data2OK = False 
    230             # logging.info('Choose a file or a number for Data2') 
     236            self.onCheckChosenData() 
    231237            return 
    232238 
     
    242248            # plot default for output graph 
    243249            self.newPlot(self.graphOutput, self.layoutOutput) 
     250            self.onCheckChosenData() 
    244251 
    245252        else: 
     
    247254            self.data2OK = True 
    248255            self.txtNumber.setEnabled(False) 
    249             id2 = self._findId(choice_data2) 
    250             self.data2 = self._extractData(id2) 
     256            key_id2 = self._findId(choice_data2) 
     257            self.data2 = self._extractData(key_id2) 
    251258            # plot Data2 
    252259            self.updatePlot(self.graphData2, self.layoutData2, self.data2) 
    253260            # plot default for output graph 
    254261            self.newPlot(self.graphOutput, self.layoutOutput) 
     262            self.onCheckChosenData() 
    255263 
    256264    def onInputCoefficient(self): 
     
    323331        if name_to_check is None or name_to_check == '': 
    324332            self.txtOutputData.setStyleSheet(QtCore.QString(BG_RED)) 
    325             logging.info('no output name') 
     333            logging.info('No output name') 
    326334            return False 
    327335 
    328336        elif name_to_check in self.list_data_items: 
    329337            self.txtOutputData.setStyleSheet(QtCore.QString(BG_RED)) 
    330             logging.info('The Output Data Name already exists') 
     338            logging.info('The Output data name already exists') 
    331339            return False 
    332340 
     
    342350        isinstance(name, basestring) 
    343351 
    344         for id in self.filenames.keys(): 
     352        for key_id in self.filenames.keys(): 
    345353            # data with title 
    346             if self.filenames[id].get_data().title: 
    347                 input = self.filenames[id].get_data().title 
     354            if self.filenames[key_id].get_data().title: 
     355                input = self.filenames[key_id].get_data().title 
    348356            # data without title 
    349357            else: 
    350                 input = str(id) 
     358                input = str(key_id) 
    351359            if name in input: 
    352                 return id 
    353  
    354     def _extractData(self, id): 
     360                return key_id 
     361 
     362    def _extractData(self, key_id): 
    355363        """ Extract data from file with id contained in list of filenames """ 
    356         data_complete = self.filenames[id].get_data() 
     364        data_complete = self.filenames[key_id].get_data() 
    357365        dimension = data_complete.__class__.__name__ 
    358366 
    359         if dimension == 'Data1D': 
    360             data_set = Data1D(x=data_complete.x, 
    361                               y=data_complete.y, 
    362                               dx=data_complete.dx, 
    363                               dy=data_complete.dy) 
    364  
    365         elif dimension == 'Data2D': 
    366             data_set = Data2D(image=data_complete.data, 
    367                               err_image=data_complete.err_data, 
    368                               mask=data_complete.mask, 
    369                               qx_data=data_complete.qx_data, 
    370                               qy_data=data_complete.qy_data, 
    371                               dqx_data=data_complete.dqx_data, 
    372                               dqy_data=data_complete.dqy_data, 
    373                               q_data=data_complete.q_data, 
    374                               xmin=data_complete.xmin, 
    375                               xmax=data_complete.xmax, 
    376                               ymin=data_complete.ymin, 
    377                               ymax=data_complete.ymax, 
    378                               zmin=data_complete.zmin, 
    379                               zmax=data_complete.zmax) 
     367        if dimension in ('Data1D', 'Data2D'): 
     368            return copy.deepcopy(data_complete) 
    380369 
    381370        else: 
    382371            logging.info('Error with data format') 
    383372            return 
    384  
    385         return data_set 
    386373 
    387374    # ######## 
     
    399386 
    400387        layout.setContentsMargins(0, 0, 0, 0) 
    401  
    402         # define default content: '?' 
    403         scene = QtGui.QGraphicsScene() 
    404         scene.addText("?") 
    405  
    406         subgraph = QtGui.QGraphicsView() 
    407         subgraph.setScene(scene) 
    408  
    409         layout.addWidget(subgraph) 
     388        layout.addWidget(self.prepareSubgraphWithData("?")) 
    410389 
    411390        graph.setLayout(layout) 
     
    456435            plotter.ax.tick_params(axis='y', labelsize=8) 
    457436 
    458             plotter.plot(hide_error=True, marker='.', show_legend=False) 
     437            plotter.plot(hide_error=True, marker='.') 
     438            # plotter.legend = None 
    459439 
    460440            plotter.show() 
     
    463443            # display value of coefficient (to be applied to Data1) 
    464444            # in graphData2 
    465             scene = QtGui.QGraphicsScene() 
    466             scene.addText(str(data)) 
    467  
    468             subgraph = QtGui.QGraphicsView() 
    469             subgraph.setScene(scene) 
    470  
    471             layout.addWidget(subgraph) 
     445            layout.addWidget(self.prepareSubgraphWithData(data)) 
    472446 
    473447            graph.setLayout(layout) 
     448 
     449    def prepareSubgraphWithData(self, data): 
     450        """ Create graphics view containing scene with string """ 
     451        scene = QtGui.QGraphicsScene() 
     452        scene.addText(str(data)) 
     453 
     454        subgraph = QtGui.QGraphicsView() 
     455        subgraph.setScene(scene) 
     456 
     457        return subgraph 
  • src/sas/qtgui/Calculators/UI/DataOperationUtilityUI.ui

    rd5c5d3d rf0bb711  
    1212  </property> 
    1313  <property name="sizePolicy"> 
    14    <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> 
     14   <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> 
    1515    <horstretch>0</horstretch> 
    1616    <verstretch>0</verstretch> 
     
    1919  <property name="minimumSize"> 
    2020   <size> 
    21     <width>950</width> 
     21    <width>951</width> 
    2222    <height>425</height> 
    2323   </size> 
     
    2525  <property name="maximumSize"> 
    2626   <size> 
    27     <width>1000</width> 
    28     <height>500</height> 
     27    <width>951</width> 
     28    <height>425</height> 
    2929   </size> 
    3030  </property> 
  • src/sas/qtgui/MainWindow/DataExplorer.py

    rd5c5d3d rf0bb711  
    281281        # Use 'while' so the row count is forced at every iteration 
    282282        deleted_indices = [] 
     283        # deleted_names = [] 
    283284        while ind < self.model.rowCount(): 
    284285            ind += 1 
    285286            item = self.model.item(ind) 
     287 
    286288            if item and item.isCheckable() and item.checkState() == QtCore.Qt.Checked: 
    287289                # Delete these rows from the model 
     290                # deleted_names.append(self.model.item(ind).text()) 
    288291                deleted_indices.append(item) 
     292 
    289293                self.model.removeRow(ind) 
    290294                # Decrement index since we just deleted it 
     
    293297        # Let others know we deleted data 
    294298        self.communicator.dataDeletedSignal.emit(deleted_indices) 
     299 
     300        # update stored_data 
     301        # self.manager.delete_by_name(deleted_names) 
     302 
    295303 
    296304    def deleteTheory(self, event): 
  • src/sas/qtgui/MainWindow/DataManager.py

    rdc5ef15 rf0bb711  
    275275                del self.stored_data[id] 
    276276 
    277  
    278277    def get_by_name(self, name_list=None): 
    279278        """ 
  • src/sas/qtgui/MainWindow/GuiManager.py

    rd5c5d3d rf0bb711  
    534534        """ 
    535535        """ 
    536         self.communicate.sendDataToPanel.emit(self._data_manager.get_all_data()) 
     536        self.communicate.sendDataToPanelSignal.emit(self._data_manager.get_all_data()) 
    537537 
    538538        self.DataOperation.show() 
  • src/sas/qtgui/Plotting/Plotter.py

    rd5c5d3d rf0bb711  
    5858        self.title(title=value.name) 
    5959 
    60     def plot(self, data=None, color=None, marker=None, hide_error=False, show_legend=True): 
     60    def plot(self, data=None, color=None, marker=None, hide_error=False): 
    6161        """ 
    6262        Add a new plot of self._data to the chart. 
     
    145145 
    146146        # Now add the legend with some customizations. 
    147         if show_legend: 
    148             self.legend = ax.legend(loc='upper right', shadow=True) 
    149             if self.legend: 
    150                 self.legend.set_picker(True) 
     147 
     148        self.legend = ax.legend(loc='upper right', shadow=True) 
     149        if self.legend: 
     150            self.legend.set_picker(True) 
    151151 
    152152        # Current labels for axes 
  • src/sas/qtgui/Utilities/GuiUtils.py

    rd5c5d3d rf0bb711  
    144144    # custom open_path 
    145145    open_folder = custom_config.DEFAULT_OPEN_FOLDER 
    146     if open_folder != None and os.path.isdir(open_folder): 
     146    if open_folder is not None and os.path.isdir(open_folder): 
    147147        DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 
    148148    else: 
     
    231231 
    232232    # Send data to Data Operation Utility panel 
    233     sendDataToPanel = QtCore.pyqtSignal(dict) 
     233    sendDataToPanelSignal = QtCore.pyqtSignal(dict) 
    234234 
    235235    # Send result of Data Operation Utility panel to Data Explorer 
     
    528528                has_errors = False 
    529529        if has_errors: 
    530             if data.dx != None and data.dx != []: 
     530            if data.dx is not None and data.dx != []: 
    531531                out.write("<X>   <Y>   <dY>   <dX>\n") 
    532532            else: 
     
    537537        for i in range(len(data.x)): 
    538538            if has_errors: 
    539                 if data.dx != None and data.dx != []: 
     539                if data.dx is not None and data.dx != []: 
    540540                    if  data.dx[i] != None: 
    541541                        out.write("%g  %g  %g  %g\n" % (data.x[i], 
  • src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py

    rd5c5d3d rf0bb711  
    6969            'progressBarUpdateSignal', 
    7070            'activeGraphName', 
    71             'sendDataToPanel', 
     71            'sendDataToPanelSignal', 
    7272            'updateModelFromDataOperationPanelSignal' 
    7373        ] 
Note: See TracChangeset for help on using the changeset viewer.