Changeset 63467b6 in sasview


Ignore:
Timestamp:
Sep 27, 2018 2:20:24 AM (6 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
4f8c17f
Parents:
dce68f6
Message:

Improved handling of 2d plot children. Refactored model tree search.

Location:
src/sas/qtgui
Files:
8 edited

Legend:

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

    r428c3b2 r63467b6  
    950950 
    951951        types = (None, Data1D, Data2D) 
    952         assert dimension in types 
     952        if not dimension in types: 
     953            return 
    953954 
    954955        for index in range(model.rowCount()): 
    955956            item = model.item(index) 
    956             if dimension is not None and not isinstance(GuiUtils.dataFromItem(item), dimension): 
    957                 continue 
    958957            if item.isCheckable() and item.checkState() != mode: 
    959                 item.setCheckState(mode) 
    960             # look for all children 
    961             for inner_index in range(item.rowCount()): 
    962                 child = item.child(inner_index) 
    963                 if child.isCheckable() and child.checkState() != mode: 
    964                     child.setCheckState(mode) 
     958                data = item.child(0).data() 
     959                if dimension is None or isinstance(data, dimension): 
     960                    item.setCheckState(mode) 
     961 
     962            items = list(GuiUtils.getChildrenFromItem(item)) 
     963 
     964            for it in items: 
     965                if it.isCheckable() and it.checkState() != mode: 
     966                    data = it.child(0).data() 
     967                    if dimension is None or isinstance(data, dimension): 
     968                        it.setCheckState(mode) 
    965969 
    966970    def selectData(self, index): 
     
    14141418        current_tab_name = model_item.text() 
    14151419        for current_index in range(self.theory_model.rowCount()): 
    1416             #if current_tab_name in self.theory_model.item(current_index).text(): 
    14171420            if current_tab_name == self.theory_model.item(current_index).text(): 
    14181421                self.theory_model.removeRow(current_index) 
    14191422                break 
    1420  
    14211423        # send in the new item 
    14221424        self.theory_model.appendRow(model_item) 
  • src/sas/qtgui/MainWindow/UnitTesting/MainWindowTest.py

    rfa762f4 r63467b6  
    5454        tmp_main.guiManager.showWelcomeMessage() 
    5555        # Assure it is visible and a part of the MdiArea 
    56         self.assertTrue(tmp_main.guiManager.welcomePanel.isVisible()) 
    5756        self.assertEqual(len(tmp_main.workspace.subWindowList()), 2) 
    5857 
  • src/sas/qtgui/Plotting/Plotter2D.py

    rdce68f6 r63467b6  
    284284        new_plot.id = "Circ avg " + self.data.name 
    285285        new_plot.is_data = True 
    286         GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
     286        if self._item.parent() is not None: 
     287            item = self._item.parent() 
     288        GuiUtils.updateModelItemWithPlot(item, new_plot, new_plot.id) 
    287289 
    288290        self.manager.communicator.plotUpdateSignal.emit([new_plot]) 
  • src/sas/qtgui/Plotting/Slicers/AnnulusSlicer.py

    re20870bc r63467b6  
    143143        new_plot.xtransform = "x" 
    144144        new_plot.ytransform = "y" 
    145         GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
     145        item = self._item 
     146        if self._item.parent() is not None: 
     147            item = self._item.parent() 
     148        GuiUtils.updateModelItemWithPlot(item, new_plot, new_plot.id) 
    146149        self.base.manager.communicator.plotUpdateSignal.emit([new_plot]) 
    147150 
  • src/sas/qtgui/Plotting/Slicers/BoxSlicer.py

    re20870bc r63467b6  
    188188        new_plot.id = (self.averager.__name__) + self.base.data.name 
    189189        new_plot.is_data = True 
    190         GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
     190        if self._item.parent() is not None: 
     191            item = self._item.parent() 
     192        GuiUtils.updateModelItemWithPlot(item, new_plot, new_plot.id) 
    191193 
    192194        if self.update_model: 
  • src/sas/qtgui/Plotting/Slicers/SectorSlicer.py

    re20870bc r63467b6  
    167167        new_plot.id = "SectorQ" + self.base.data.name 
    168168        new_plot.is_data = True 
    169         GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
     169        if self._item.parent() is not None: 
     170            item = self._item.parent() 
     171        GuiUtils.updateModelItemWithPlot(item, new_plot, new_plot.id) 
    170172 
    171173        self.base.manager.communicator.plotUpdateSignal.emit([new_plot]) 
  • src/sas/qtgui/Utilities/GuiUtils.py

    r8eea1b1 r63467b6  
    500500    return plot_data 
    501501 
     502def getChildrenFromItem(root): 
     503    """ 
     504    Recursively go down the model item looking for all children 
     505    """ 
     506    def recurse(parent): 
     507        for row in range(parent.rowCount()): 
     508            for column in range(parent.columnCount()): 
     509                child = parent.child(row, column) 
     510                yield child 
     511                if child.hasChildren(): 
     512                    yield from recurse(child) 
     513    if root is not None: 
     514        yield from recurse(root) 
     515 
    502516def plotsFromCheckedItems(model_item): 
    503517    """ 
     
    507521 
    508522    plot_data = [] 
     523 
    509524    # Iterate over model looking for items with checkboxes 
    510525    for index in range(model_item.rowCount()): 
    511526        item = model_item.item(index) 
    512  
    513         # Going 1 level deeper only 
    514         for index_2 in range(item.rowCount()): 
    515             item_2 = item.child(index_2) 
    516             if item_2 and item_2.isCheckable() and item_2.checkState() == QtCore.Qt.Checked: 
    517                 # TODO: assure item type is correct (either data1/2D or Plotter) 
    518                 plot_data.append((item_2, item_2.child(0).data())) 
    519  
    520         if item.isCheckable() and item.checkState() == QtCore.Qt.Checked: 
    521             # TODO: assure item type is correct (either data1/2D or Plotter) 
    522             plot_data.append((item, item.child(0).data())) 
     527        if item and item.isCheckable() and item.checkState() == QtCore.Qt.Checked: 
     528            data = item.child(0).data() 
     529            plot_data.append((item, data)) 
     530 
     531        items = list(getChildrenFromItem(item)) 
     532 
     533        for it in items: 
     534            if it.isCheckable() and it.checkState() == QtCore.Qt.Checked: 
     535                data = it.child(0).data() 
     536                plot_data.append((it, data)) 
    523537 
    524538    return plot_data 
  • src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py

    r57be490 r63467b6  
    195195        # Make sure only the checked data is present 
    196196        # FRIDAY IN 
    197         self.assertIn(test_list0, plot_list[1]) 
     197        self.assertIn(test_list0, plot_list[0]) 
    198198        # SATURDAY IN 
    199         self.assertIn(test_list1, plot_list[0]) 
     199        self.assertIn(test_list1, plot_list[1]) 
    200200        # MONDAY NOT IN 
    201201        self.assertNotIn(test_list2, plot_list[0]) 
Note: See TracChangeset for help on using the changeset viewer.