Changeset 8fa3fb8 in sasview for src/sas/sasgui/guiframe


Ignore:
Timestamp:
Mar 1, 2017 9:46:54 AM (7 years ago)
Author:
butler
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.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
a97aebd
Parents:
cb1e9a5 (diff), 775e0b7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'origin/master' into expandable-de-688

Location:
src/sas/sasgui/guiframe
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/CategoryInstaller.py

    r212bfc2 rddbac66  
    123123        compile it and install 
    124124        :param homefile: Override the default home directory 
    125         :param model_list: List of model names except customized models 
     125        :param model_list: List of model names except those in Plugin Models 
     126               which are user supplied. 
    126127        """ 
    127128        _model_dict = { model.name: model for model in model_list} 
  • src/sas/sasgui/guiframe/customdir.py

    r212bfc2 r73cbeec  
    3434        if not os.path.isfile(config_file): 
    3535            shutil.copyfile(os.path.join(path, "custom_config.py"), config_file) 
     36 
     37        #Adding SAS_OPENCL if it doesn't exist in the config file 
     38        # - to support backcompability 
     39        if not "SAS_OPENCL" in open(config_file).read(): 
     40            open(config_file,"a+").write("SAS_OPENCL = \"None\"\n") 
    3641    except: 
    3742        # Check for data path next to exe/zip file. 
  • src/sas/sasgui/guiframe/dataFitting.py

    r9b6d62d r68adf86  
    1717    """ 
    1818    """ 
    19     def __init__(self, x=None, y=None, dx=None, dy=None): 
     19 
     20    def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None, isSesans=False): 
    2021        """ 
    2122        """ 
     
    2425        if y is None: 
    2526            y = [] 
    26         PlotData1D.__init__(self, x, y, dx, dy) 
    27         LoadData1D.__init__(self, x, y, dx, dy) 
     27        self.isSesans = isSesans 
     28        PlotData1D.__init__(self, x, y, dx, dy, lam, dlam) 
     29        LoadData1D.__init__(self, x, y, dx, dy, lam, dlam, isSesans) 
     30 
    2831        self.id = None 
    2932        self.list_group_id = [] 
     
    3235        self.path = None 
    3336        self.xtransform = None 
     37        if self.isSesans: 
     38            self.xtransform = "x" 
    3439        self.ytransform = None 
     40        if self.isSesans: 
     41            self.ytransform = "y" 
    3542        self.title = "" 
    3643        self.scale = None 
     
    6875        # First, check the data compatibility 
    6976        dy, dy_other = self._validity_check(other) 
    70         result = Data1D(x=[], y=[], dx=None, dy=None) 
     77        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None) 
    7178        result.clone_without_data(length=len(self.x), clone=self) 
    7279        result.copy_from_datainfo(data1d=self) 
     
    115122        # First, check the data compatibility 
    116123        self._validity_check_union(other) 
    117         result = Data1D(x=[], y=[], dx=None, dy=None) 
     124        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None) 
    118125        tot_length = len(self.x) + len(other.x) 
    119126        result = self.clone_without_data(length=tot_length, clone=result) 
     127        if self.dlam == None or other.dlam is None: 
     128            result.dlam = None 
     129        else: 
     130            result.dlam = numpy.zeros(tot_length) 
    120131        if self.dy == None or other.dy is None: 
    121132            result.dy = None 
     
    141152        result.y = numpy.append(self.y, other.y) 
    142153        result.y = result.y[ind] 
     154        result.lam = numpy.append(self.lam, other.lam) 
     155        result.lam = result.lam[ind] 
     156        if result.dlam != None: 
     157            result.dlam = numpy.append(self.dlam, other.dlam) 
     158            result.dlam = result.dlam[ind] 
    143159        if result.dy != None: 
    144160            result.dy = numpy.append(self.dy, other.dy) 
     
    260276        # First, check the data compatibility 
    261277        self._validity_check_union(other) 
    262         result = Data1D(x=[], y=[], dx=None, dy=None) 
     278        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=[]) 
    263279        tot_length = len(self.x)+len(other.x) 
    264280        result.clone_without_data(length=tot_length, clone=self) 
     281        if self.dlam == None or other.dlam is None: 
     282            result.dlam = None 
     283        else: 
     284            result.dlam = numpy.zeros(tot_length) 
    265285        if self.dy == None or other.dy is None: 
    266286            result.dy = None 
     
    285305        result.y = numpy.append(self.y, other.y) 
    286306        result.y = result.y[ind] 
     307        result.lam = numpy.append(self.lam, other.lam) 
     308        result.lam = result.lam[ind] 
    287309        if result.dy != None: 
    288310            result.dy = numpy.append(self.dy, other.dy) 
  • src/sas/sasgui/guiframe/data_manager.py

    rd85c194 r2ffe241  
    6161         
    6262        if issubclass(Data2D, data.__class__): 
    63             new_plot = Data2D(image=None, err_image=None)  
    64         else:  
    65             new_plot = Data1D(x=[], y=[], dx=None, dy=None) 
    66             
     63            new_plot = Data2D(image=None, err_image=None) # For now, isSesans for 2D data is always false 
     64        else: 
     65            new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None, isSesans=data.isSesans) 
     66 
     67 
     68        #elif data.meta_data['loader'] == 'SESANS': 
     69        #    new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None, isSesans=True) 
     70        #else: 
     71        #    new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None) #SESANS check??? 
     72 
    6773        new_plot.copy_from_datainfo(data) 
    6874        data.clone_without_data(clone=new_plot) 
  • src/sas/sasgui/guiframe/gui_manager.py

    rc8e1996 r73cbeec  
    152152SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 
    153153SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 
     154SAS_OPENCL = config.SAS_OPENCL 
    154155if not WELCOME_PANEL_ON: 
    155156    WELCOME_PANEL_SHOW = False 
     
    176177    else: 
    177178        DEFAULT_OPEN_FOLDER = PATH_APP 
     179    SAS_OPENCL = custom_config.SAS_OPENCL 
    178180except: 
    179181    DATALOADER_SHOW = True 
     
    190192    CLEANUP_PLOT = False 
    191193    DEFAULT_OPEN_FOLDER = PATH_APP 
    192  
     194    SAS_OPENCL = None 
    193195DEFAULT_STYLE = config.DEFAULT_STYLE 
    194196 
     
    225227        CHILD_FRAME = wx.Frame 
    226228 
     229#Initiliaze enviromental variable with custom setting but only if variable not set 
     230if SAS_OPENCL and not "SAS_OPENCL" in os.environ: 
     231    os.environ["SAS_OPENCL"] = SAS_OPENCL 
    227232 
    228233class ViewerFrame(PARENT_FRAME): 
     
    19501955                    item, _, _ = value 
    19511956                    item.Check(True) 
    1952             self._data_panel.on_remove(None, False) 
    19531957 
    19541958            wx.PostEvent(self, StatusEvent(status="Loading Project file...")) 
     
    19631967                # Reset to a base state 
    19641968                self._on_reset_state() 
     1969                self._data_panel.on_remove(None, False) 
    19651970                # Load the project file 
    19661971                self.load_state(path=path, is_project=True) 
     
    19901995                wx.PostEvent(self, 
    19911996                             StatusEvent(status="Completed saving.")) 
    1992             except: 
     1997            except Exception: 
    19931998                msg = "Error occurred while saving: " 
     1999                msg += traceback.format_exc() 
    19942000                msg += "To save, the application panel should have a data set.." 
    19952001                wx.PostEvent(self, StatusEvent(status=msg)) 
     
    20402046                logging.warning(msg) 
    20412047                wx.PostEvent(self, StatusEvent(status=msg, info="error")) 
    2042         except: 
     2048        except Exception: 
    20432049            msg = "Error occurred while saving: " 
     2050            msg += traceback.format_exc() 
    20442051            msg += "To save, at least one application panel " 
    20452052            msg += "should have a data set.." 
     
    21022109        Quit the application 
    21032110        """ 
     2111        #IF SAS_OPENCL is set, settings are stored in the custom config file 
     2112        self._write_opencl_config_file() 
    21042113        logging.info(" --- SasView session was closed --- \n") 
    21052114        wx.Exit() 
    21062115        sys.exit() 
     2116 
     2117    def _write_opencl_config_file(self): 
     2118        """ 
     2119        Writes OpenCL settings to custom config file, so they can be remmbered 
     2120        from session to session 
     2121        """ 
     2122        if custom_config is not None: 
     2123            sas_opencl = os.environ.get("SAS_OPENCL",None) 
     2124            new_config_lines = [] 
     2125            config_file = open(custom_config.__file__) 
     2126            config_lines = config_file.readlines() 
     2127            for line in config_lines: 
     2128                if "SAS_OPENCL" in line: 
     2129                    if sas_opencl: 
     2130                        new_config_lines.append("SAS_OPENCL = \""+sas_opencl+"\"") 
     2131                    else: 
     2132                        new_config_lines.append("SAS_OPENCL = None") 
     2133                else: 
     2134                    new_config_lines.append(line) 
     2135            config_file.close() 
     2136 
     2137            #If custom_config is None, settings will not be remmbered 
     2138            new_config_file = open(custom_config.__file__,"w") 
     2139            new_config_file.writelines(new_config_lines) 
     2140            new_config_file.close() 
     2141        else: 
     2142            logging.info("Failed to save OPENCL settings in custom config file") 
     2143 
    21072144 
    21082145    def _check_update(self, event=None): 
     
    24562493                                                group_id=group_id, 
    24572494                                                action='remove')) 
    2458                 # remove res plot: Todo: improve 
    24592495                wx.CallAfter(self._remove_res_plot, new_plot.id) 
    24602496        self._data_manager.delete_data(data_id=data_id, 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py

    r245ae18 r29e872e  
    6565        # context menu 
    6666        self._slicerpop = None 
    67  
    6867        self._available_data = [] 
    6968        self._symbol_labels = self.get_symbol_label() 
     
    732731                self.subplot.set_ylim(y_range) 
    733732                self.subplot.figure.canvas.draw_idle() 
     733                self.is_zoomed = True 
    734734        d.Destroy() 
    735735 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py

    r1a696bf rb2b36932  
    316316 
    317317        slicerpop.AppendSeparator() 
    318         if len(self.data2D.detector) == 1: 
     318        if len(self.data2D.detector) <= 1: 
    319319            item_list = self.parent.get_current_context_menu(self) 
    320320            if (not item_list == None) and (not len(item_list) == 0) and\ 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/plotting.py

    r6ffa0dd rca224b1  
    134134        """ 
    135135        for group_id in self.plot_panels.keys(): 
    136             panel = self.plot_panels[group_id] 
    137             panel.graph.reset() 
    138             self.hide_panel(group_id) 
     136            self.clear_panel_by_id(group_id) 
    139137        self.plot_panels = {} 
    140138 
  • src/sas/sasgui/guiframe/startup_configuration.py

    rd85c194 r73cbeec  
    3131                   'CLEANUP_PLOT':False, 
    3232                   'DEFAULT_PERSPECTIVE':'Fitting', 
    33                    'DEFAULT_OPEN_FOLDER': None} 
     33                   'DEFAULT_OPEN_FOLDER': None, 
     34                   'SAS_OPENCL': None} 
    3435try: 
    3536    CURRENT_STRINGS = {'GUIFRAME_WIDTH':CURRENT.GUIFRAME_WIDTH, 
     
    4546                       'CLEANUP_PLOT':CURRENT.CLEANUP_PLOT, 
    4647                       'DEFAULT_PERSPECTIVE':CURRENT.DEFAULT_PERSPECTIVE, 
    47                        'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDER} 
     48                       'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDER, 
     49                       'SAS_OPENCL': None} 
    4850except: 
    4951    CURRENT_STRINGS = DEFAULT_STRINGS 
  • src/sas/sasgui/guiframe/data_panel.py

    rc8e1996 rcb1e9a5  
    520520        Add a listcrtl in the panel 
    521521        """ 
    522         tree_ctrl_label = wx.StaticText(self, -1, "Data") 
    523         tree_ctrl_label.SetForegroundColour('blue') 
    524         self.tree_ctrl = DataTreeCtrl(parent=self, style=wx.SUNKEN_BORDER) 
     522        # Add splitter 
     523        w, h = self.parent.GetSize() 
     524        splitter = wx.SplitterWindow(self) 
     525        splitter.SetMinimumPaneSize(50) 
     526        splitter.SetSashGravity(1.0) 
     527 
     528        file_sizer = wx.BoxSizer(wx.VERTICAL) 
     529        file_sizer.SetMinSize(wx.Size(w/13, h*2/5)) 
     530        theory_sizer = wx.BoxSizer(wx.VERTICAL) 
     531        theory_sizer.SetMinSize(wx.Size(w/13, h*2/5)) 
     532 
     533        self.tree_ctrl = DataTreeCtrl(parent=splitter, style=wx.SUNKEN_BORDER) 
     534 
    525535        self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) 
    526536        self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_MENU, self.on_right_click_data) 
     
    557567        wx.EVT_MENU(self, self.editmask_id, self.on_edit_data) 
    558568 
    559         tree_ctrl_theory_label = wx.StaticText(self, -1, "Theory") 
    560         tree_ctrl_theory_label.SetForegroundColour('blue') 
    561         self.tree_ctrl_theory = DataTreeCtrl(parent=self, 
     569        self.tree_ctrl_theory = DataTreeCtrl(parent=splitter, 
    562570                                             style=wx.SUNKEN_BORDER) 
    563571        self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKING, 
     
    565573        self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_MENU, 
    566574                                   self.on_right_click_theory) 
    567         self.sizer1.Add(tree_ctrl_label, 0, wx.LEFT, 10) 
    568         self.sizer1.Add(self.tree_ctrl, 1, wx.EXPAND | wx.ALL, 10) 
    569         self.sizer1.Add(tree_ctrl_theory_label, 0,  wx.LEFT, 10) 
    570         self.sizer1.Add(self.tree_ctrl_theory, 1, wx.EXPAND | wx.ALL, 10) 
     575        self.tree_ctrl.InsertItem(self.tree_ctrl.root, -1, " Data") 
     576        self.tree_ctrl_theory.InsertItem(self.tree_ctrl_theory.root, 
     577                                         -1, " Theory") 
     578        splitter.SplitHorizontally(self.tree_ctrl, self.tree_ctrl_theory) 
     579        self.sizer1.Add(splitter, 1, wx.EXPAND | wx.ALL, 10) 
    571580 
    572581    def on_right_click_theory(self, event): 
Note: See TracChangeset for help on using the changeset viewer.