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


Ignore:
Timestamp:
Apr 7, 2017 11:39:57 AM (8 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:
377ca62f
Parents:
71b25b2
git-author:
Jeff Krzywon <krzywon@…> (04/07/17 11:39:57)
git-committer:
krzywon <krzywon@…> (04/07/17 11:39:57)
Message:

Refactor to fix window redraw issues.

File:
1 edited

Legend:

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

    r71b25b2 rcac1828  
    33import wx 
    44import wx.lib.newevent 
    5 import time 
    65from sas.sascalc.dataloader.readers.cansas_reader import Reader 
    76from sas.sasgui.guiframe.events import EVT_SLICER_PARS 
     
    3736        self.auto_save = None 
    3837        self.path = None 
    39         self.type_list = ["SectorInteractor", "AnnulusInteractor", 
    40                           "BoxInteractorX", "BoxInteractorY"] 
    41         self.type_select = wx.ComboBox(parent=self, choices=self.type_list) 
    42         self.append_name = wx.TextCtrl(parent=self, id=wx.NewId(), 
    43                                        name="Append to file name:") 
     38        self.type_list = [] 
     39        self.type_select = None 
     40        self.append_name = None 
    4441        self.data_list = None 
    4542        label = "Right-click on 2D plot for slicer options" 
     
    4946        # Bindings 
    5047        self.parent.Bind(EVT_SLICER, self.onEVT_SLICER) 
    51         self.parent.Bind(EVT_SLICER_PARS, self.onParamChange) 
     48        self.Bind(EVT_SLICER_PARS, self.onParamChange) 
    5249        self.Bind(EVT_APPLY_PARAMS, self.apply_params_list_and_process) 
    5350        self.Bind(EVT_AUTO_SAVE, self.save_files) 
     
    128125            self.bck.Add(text, (iy, ix), (1, 1), 
    129126                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
     127            self.type_list = ["SectorInteractor", "AnnulusInteractor", 
     128                              "BoxInteractorX", "BoxInteractorY"] 
     129            self.type_select = wx.ComboBox(parent=self, choices=self.type_list) 
    130130            self.Bind(wx.EVT_COMBOBOX, self.onChangeSlicer) 
    131131            index = self.type_select.FindString(type) 
     
    174174            default_value = "" 
    175175            for key in params: 
    176                 default_value += "_{0}-".format(key) 
    177                 default_value += "{:.5f}".format(params[key]) 
     176                default_value += "_{0}".format(key).split(" [")[0] 
     177                default_value += "-{:.5f}".format(params[key]) 
    178178            append_text = "Append to file name:" 
    179179            append = wx.StaticText(self, -1, append_text, style=wx.ALIGN_LEFT) 
     180            self.append_name = wx.TextCtrl(parent=self, id=wx.NewId(), 
     181                                           name="Append to file name:") 
    180182            self.append_name.SetValue(default_value) 
    181183            self.append_name.Enable(False) 
     
    246248            # parent here is plotter2D 
    247249            event = SlicerParameterEvent(type=self.type, params=params) 
    248             wx.PostEvent(self, event) 
     250            wx.PostEvent(self.parent, event) 
    249251 
    250252    def on_batch_slicer(self, evt=None): 
    251253        """ 
    252         Method invoked with batch slicing button is pressed 
     254        Method invoked when batch slicing button is pressed 
    253255        :param evt: Event triggering hide/show of the batch slicer parameters 
    254256        """ 
     
    271273 
    272274        # Post an event to apply appropriate slicer params to each slicer 
    273         # Event needed due to how apply_slicer_to_plot works 
    274         event = apply_params(params=params, plot_list=apply_to_list, 
     275        event_params = apply_params(params=params, apply_to_list=apply_to_list, 
    275276                             auto_save=save, append=append, 
    276277                             path=path, type=type) 
    277         wx.PostEvent(self, event) 
     278        wx.PostEvent(self, event_params) 
    278279 
    279280    def onChangeSlicer(self, evt): 
     
    292293        # Skip redrawing the current plot if no change 
    293294        if self.parent == plot and self.type == type: 
     295            return 
     296        # Do not draw a slicer on a 1D plot 
     297        if not isinstance(plot, ModelPanel2D): 
    294298            return 
    295299        if type is None: 
     
    345349        """ 
    346350        # Apply parameter list to each plot as desired 
    347         for item in evt.plot_list: 
     351        for item in evt.apply_to_list: 
    348352            event = SlicerParameterEvent(type=evt.type, params=evt.params) 
    349353            wx.PostEvent(item, event) 
     
    351355        if evt.auto_save: 
    352356            event = auto_save(append_to_name=evt.append, 
    353                               file_list=evt.plot_list, 
     357                              file_list=evt.apply_to_list, 
    354358                              path=evt.path, type=evt.type) 
    355359            wx.PostEvent(self, event) 
     
    380384                        data_dic[item] = plot.plots[item] 
    381385        for item, data1d in data_dic.iteritems(): 
    382             base = item.split(".")[0] 
     386            base = ('.').join(item.split('.')[:-1]) 
    383387            save_to = evt.path + "\\" + base + append + ".xml" 
    384388            writer.write(save_to, data1d) 
Note: See TracChangeset for help on using the changeset viewer.