Changeset 71b25b2 in sasview


Ignore:
Timestamp:
Apr 7, 2017 6:38:01 AM (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:
cac1828
Parents:
982577b
git-author:
Jeff Krzywon <krzywon@…> (04/07/17 06:38:01)
git-committer:
krzywon <krzywon@…> (04/07/17 06:38:01)
Message:

Only save plots associated with selected slicer.

File:
1 edited

Legend:

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

    r982577b r71b25b2  
    99from sas.sasgui.guiframe.events import EVT_SLICER 
    1010from sas.sasgui.guiframe.events import SlicerParameterEvent, SlicerEvent 
    11 from Plotter1D import ModelPanel1D 
    1211from Plotter2D import ModelPanel2D 
    1312from sas.sascalc.dataloader.data_info import Data1D, Data2D 
    1413apply_params, EVT_APPLY_PARAMS = wx.lib.newevent.NewEvent() 
    1514auto_save, EVT_AUTO_SAVE = wx.lib.newevent.NewEvent() 
    16 auto_close, EVT_ON_CLOSE = wx.lib.newevent.NewEvent() 
    1715 
    1816 
     
    5452        self.Bind(EVT_APPLY_PARAMS, self.apply_params_list_and_process) 
    5553        self.Bind(EVT_AUTO_SAVE, self.save_files) 
    56         self.Bind(EVT_ON_CLOSE, self.on_close) 
    5754 
    5855    def onEVT_SLICER(self, event): 
     
    157154            # Checkbox for autosaving data 
    158155            iy += 1 
    159  
    160156            self.auto_save = wx.CheckBox(parent=self, id=wx.NewId(), 
    161157                                         label="Auto save generated 1D:") 
     
    164160                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    165161            iy += 1 
    166             # TODO: Get list of loaded data, not plots - plot again 
    167             # TODO: try/catch block to catch wx._core.PyDeadObjectError (pass) 
    168162            # File browser 
    169163            save_to = "Save files to:" 
     
    178172            # Append to file 
    179173            iy += 1 
    180             default_value = "_{0}".format(self.type) 
     174            default_value = "" 
    181175            for key in params: 
    182                 default_value += "_%d.2" % params[key] 
     176                default_value += "_{0}-".format(key) 
     177                default_value += "{:.5f}".format(params[key]) 
    183178            append_text = "Append to file name:" 
    184179            append = wx.StaticText(self, -1, append_text, style=wx.ALIGN_LEFT) 
     
    279274        event = apply_params(params=params, plot_list=apply_to_list, 
    280275                             auto_save=save, append=append, 
    281                              path=path) 
    282         wx.PostEvent(self, event) 
    283         event = auto_close() 
     276                             path=path, type=type) 
    284277        wx.PostEvent(self, event) 
    285278 
     
    297290        :param type: The type of slicer to apply to the panel 
    298291        """ 
     292        # Skip redrawing the current plot if no change 
     293        if self.parent == plot and self.type == type: 
     294            return 
    299295        if type is None: 
    300296            type = self.type_select.GetStringSelection() 
     
    350346        # Apply parameter list to each plot as desired 
    351347        for item in evt.plot_list: 
    352             item.slicer.set_params(evt.params) 
    353             item.slicer.base.update() 
     348            event = SlicerParameterEvent(type=evt.type, params=evt.params) 
     349            wx.PostEvent(item, event) 
    354350        # Post an event to save each data set to file 
    355351        if evt.auto_save: 
    356352            event = auto_save(append_to_name=evt.append, 
    357353                              file_list=evt.plot_list, 
    358                               path=evt.path) 
     354                              path=evt.path, type=evt.type) 
    359355            wx.PostEvent(self, event) 
    360356 
     
    370366        data_dic = {} 
    371367        append = evt.append_to_name 
     368        names = [] 
     369        convert_dict = {"SectorInteractor": "SectorQ", 
     370                        "AnnulusInteractor": "AnnulusPhi", 
     371                        "BoxInteractorX": "SlabX", 
     372                        "BoxInteractorY": "SlabY"} 
     373        for f_name in evt.file_list: 
     374            names.append(f_name.data2D.label) 
    372375        for key, plot in main_window.plot_panels.iteritems(): 
    373376            if not hasattr(plot, "data2D"): 
    374377                for item in plot.plots: 
    375                     data_dic[item] = plot.plots[item] 
     378                    base = item.replace(convert_dict[evt.type], "") 
     379                    if base in names: 
     380                        data_dic[item] = plot.plots[item] 
    376381        for item, data1d in data_dic.iteritems(): 
    377382            base = item.split(".")[0] 
    378383            save_to = evt.path + "\\" + base + append + ".xml" 
    379384            writer.write(save_to, data1d) 
    380         # TODO: save all files 
    381385 
    382386    def on_auto_save_checked(self, evt=None): 
     
    387391        self.append_name.Enable(self.auto_save.IsChecked()) 
    388392        self.path.Enable(self.auto_save.IsChecked()) 
    389      
    390     def on_close(self, evt=None): 
    391         """ 
    392         Auto close the panel 
    393         """ 
    394         self.Destroy() 
Note: See TracChangeset for help on using the changeset viewer.