Changeset a099131 in sasview for src/sas/sasgui/guiframe


Ignore:
Timestamp:
Mar 31, 2017 12:28:20 PM (7 years ago)
Author:
krzywon
Branches:
master, 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, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
f15da54
Parents:
dfa1579
git-author:
Jeff Krzywon <krzywon@…> (03/31/17 12:28:20)
git-committer:
krzywon <krzywon@…> (03/31/17 12:28:20)
Message:

Slicer applied to all data files when slowly stepping through. Need to sync events with batch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_slicer.py

    rdfa1579 ra099131  
    33import wx 
    44import wx.lib.newevent 
     5import time 
    56#from copy import deepcopy 
    67from sas.sasgui.guiframe.events import EVT_SLICER_PARS 
     
    7172            self.bck.Add(title, (1, 0), (1, 2), 
    7273                         flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 
    73             ix = 0 
    7474            iy = 1 
    7575            self.parameters = [] 
     
    147147            self.bck.Add(self.batch_slicer_button, (iy, ix), (1, 1), 
    148148                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
     149            # TODO: Select all button 
    149150            # TODO: Check box for saving file 
    150151            # TODO: append to file information and file type 
     
    198199        :param evt: Event triggering hide/show of the batch slicer parameters 
    199200        """ 
     201        self.parent.parent._data_panel._uncheck_all() 
     202        apply_to_list = [] 
     203        plot_list = [] 
     204        spp = self.parent.parent 
     205        data_panel = spp._data_panel 
     206        data_list = data_panel.list_cb_data 
     207        params = self.parent.slicer.get_params() 
     208        type = self.type_select.GetStringSelection() 
     209 
    200210        # Process each data file individually 
    201211        for item in self.data_list.CheckedStrings: 
    202212            # Get data_id 
    203213            num = len(item) 
    204             spp = self.parent.parent 
    205             data_panel = spp._data_panel 
    206             data_list = data_panel.list_cb_data 
    207214            for key in data_list: 
    208215                loaded_key = (key[:num]) if len(key) > num else key 
     
    210217                    selection = key 
    211218                    break 
     219 
    212220            # Check the data checkbox 
    213221            data_ctrl = data_list[selection][0] 
    214222            self.check_item_and_children(data_ctrl=data_ctrl, check_value=True) 
    215             # Plot all checked data 
    216             data_panel.on_plot() 
    217             panel = plot_mgr = None 
    218             plot_mgrs = spp.plot_panels 
    219             for key, mgr in plot_mgrs.iteritems(): 
    220                 if isinstance(mgr, ModelPanel2D): 
    221                     plot_mgr = mgr 
    222                     break 
    223             if plot_mgr is not None: 
    224                 # TODO: find proper plot window 
    225                 panels = plot_mgr._manager.plot_panels 
    226                 for _, pane in panels.iteritems(): 
    227                     if pane.window_name == item: 
    228                         panel = pane 
    229                 # TODO: apply slicer 
    230                 print(panels) 
    231                 if panel is not None: 
    232                     self._apply_slicer_to_plot(panel) 
    233             # TODO: save file (if desired) 
    234             # TODO: send to fitting (if desired) 
     223            plot_list.append(item) 
     224 
     225        # Plot all checked data 
     226        data_panel.on_plot() 
     227        time.sleep(1.0) 
     228 
     229        # Find loaded 2D data panels 
     230        for key, mgr in spp.plot_panels.iteritems(): 
     231            if mgr.graph.prop['title'] in plot_list: 
     232                apply_to_list.append(mgr) 
     233 
     234        # Apply slicer to selected panels 
     235        for item in apply_to_list: 
     236            self._apply_slicer_to_plot(item, type) 
     237            item.slicer.set_params(params) 
     238            item.slicer.base.update() 
     239 
     240        # TODO: save file (if desired) 
     241        # TODO: send to fitting (if desired) 
    235242 
    236243    def onChangeSlicer(self, evt): 
     
    241248        self._apply_slicer_to_plot(self.parent) 
    242249 
    243     def _apply_slicer_to_plot(self, plot): 
     250    def _apply_slicer_to_plot(self, plot, type=None): 
    244251        """ 
    245252        Apply a slicer to *any* plot window, not just parent window 
     
    247254        :return: 
    248255        """ 
    249         type = self.type_select.GetStringSelection() 
    250         if self.type != type: 
    251             if type == "SectorInteractor": 
    252                 plot.onSectorQ(None) 
    253             elif type == "AnnulusInteractor": 
    254                 plot.onSectorPhi(None) 
    255             elif type == "BoxInteractorX": 
    256                 plot.onBoxavgX(None) 
    257             elif type == "BoxInteractorY": 
    258                 plot.onBoxavgY(None) 
     256        if type is None: 
     257            type = self.type_select.GetStringSelection() 
     258        if type == "SectorInteractor": 
     259            plot.onSectorQ(None) 
     260        elif type == "AnnulusInteractor": 
     261            plot.onSectorPhi(None) 
     262        elif type == "BoxInteractorX": 
     263            plot.onBoxavgX(None) 
     264        elif type == "BoxInteractorY": 
     265            plot.onBoxavgY(None) 
    259266 
    260267    def check_item_and_children(self, data_ctrl, check_value=True): 
    261         self.parent.parent._data_panel.tree_ctrl.CheckItem(data_ctrl, check_value) 
     268        self.parent.parent._data_panel.tree_ctrl.CheckItem(data_ctrl, 
     269                                                           check_value) 
    262270        if data_ctrl.HasChildren(): 
    263271            if check_value and not data_ctrl.IsExpanded(): 
Note: See TracChangeset for help on using the changeset viewer.