Changeset df7a7e3 in sasview


Ignore:
Timestamp:
Sep 17, 2012 5:11:50 PM (12 years ago)
Author:
Mathieu Doucet <doucetm@…>
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, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
b71a53b
Parents:
cf7653d3
Message:

merging category branch

Files:
4 added
13 edited

Legend:

Unmodified
Added
Removed
  • fittingview/src/sans/perspectives/fitting/basepage.py

    r2a66329 rdf7a7e3  
    22Base Page for fitting 
    33""" 
     4 
    45import sys 
    56import os 
     
    1011import math 
    1112import string 
     13import cPickle as pickle 
     14import shutil 
     15from collections import defaultdict 
    1216from wx.lib.scrolledpanel import ScrolledPanel 
    1317from sans.guiframe.panel_base import PanelBase 
     
    2226from sans.dataloader.data_info import Source 
    2327from sans.perspectives.fitting.pagestate import PageState 
     28from sans.guiframe.CategoryInstaller import CategoryInstaller 
     29 
     30 
    2431 
    2532(PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() 
     
    130137        self.sld_axes = None 
    131138        self.multi_factor = None 
     139        self.model_name = None 
     140        self.model_dict = {} 
    132141        
    133142        self.disp_cb_dict = {} 
     
    161170        self.disp_list = [] 
    162171        self.disp_name = "" 
     172 
     173        ## category stuff 
     174        self.category_box = None 
     175        self.model_box = None 
    163176         
    164177        ## list of orientation parameters 
     
    213226        ## layout 
    214227        self.set_layout() 
     228 
     229 
    215230     
    216231    def set_index_model(self, index): 
     
    459474        self.model_list_box = page_info.model_list_box 
    460475        ## Data member to store the dispersion object created 
    461         self.populate_box(dict=self.model_list_box) 
     476 
    462477         
    463478    def onContextMenu(self, event): 
     
    562577        self.state.manager = manager 
    563578         
    564     def populate_box(self, dict): 
     579    def populate_box(self, m_dict): 
    565580        """ 
    566581        Store list of model 
     
    569584         
    570585        """ 
    571         self.model_list_box = dict 
    572         self.state.model_list_box = self.model_list_box 
    573         self.initialize_combox() 
    574          
     586        self.model_list_box = m_dict 
     587        # self.state.model_list_box = self.model_list_box 
     588        # self.initialize_combox() 
     589         
     590    def set_model_dictionary(self, model_dict): 
     591        """ 
     592        Store a dictionary linking model name -> model object 
     593 
     594        :param model_dict: dictionary containing list of models 
     595        """ 
     596        self.model_dict = model_dict 
     597 
    575598    def initialize_combox(self): 
    576599        """ 
     
    580603        if self.model_list_box is None: 
    581604            return 
    582         if len(self.model_list_box) > 0: 
    583             self._populate_box(self.formfactorbox, 
    584                                self.model_list_box["Shapes"]) 
    585605        
    586606        if len(self.model_list_box) > 0: 
     
    881901                        self.state.structurecombobox = self.structurebox.\ 
    882902                        GetString(s_select) 
    883             if self.formfactorbox != None: 
    884                 f_select = self.formfactorbox.GetSelection() 
    885                 if f_select > 0: 
    886                         self.state.formfactorcombobox = self.formfactorbox.\ 
    887                         GetString(f_select) 
     903            # if self.formfactorbox != None: 
     904            #     f_select = self.formfactorbox.GetSelection() 
     905            #     if f_select > 0: 
     906            self.state.formfactorcombobox = \ 
     907                self.model_box.GetStringSelection() 
    888908                         
    889909        #save radiobutton state for model selection 
    890         self.state.shape_rbutton = self.shape_rbutton.GetValue() 
    891         self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 
    892         self.state.struct_rbutton = self.struct_rbutton.GetValue() 
    893         self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
     910        # ILL 
     911        # self.state.shape_rbutton = self.shape_rbutton.GetValue() 
     912        # self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 
     913        # self.state.struct_rbutton = self.struct_rbutton.GetValue() 
     914        # self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
    894915         
    895916        self.state.enable2D = copy.deepcopy(self.enable2D) 
     
    10401061        self.disp_list = state.disp_list 
    10411062       
    1042         ## set the state of the radio box 
    1043         self.shape_rbutton.SetValue(state.shape_rbutton) 
    1044         self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton) 
    1045         self.struct_rbutton.SetValue(state.struct_rbutton) 
    1046         self.plugin_rbutton.SetValue(state.plugin_rbutton) 
    1047          
    1048         ## fill model combobox 
    10491063        self._show_combox_helper() 
    1050         #select the current model 
    1051         try: 
    1052             # to support older version 
    1053             formfactor_pos = int(state.formfactorcombobox) 
    1054         except: 
    1055             formfactor_pos = 0 
    1056             for ind_form in range(self.formfactorbox.GetCount()): 
    1057                 if self.formfactorbox.GetString(ind_form) == \ 
    1058                                         state.formfactorcombobox: 
    1059                     formfactor_pos = int(ind_form) 
    1060                     break 
    1061              
    1062         self.formfactorbox.Select(formfactor_pos) 
    1063          
     1064 
     1065        # select the model in the gui 
     1066        self._regenerate_model_dict() 
     1067        if(len(self.by_model_dict[state.formfactorcombobox]) == 0): 
     1068            self.category_box.SetStringSelection('Uncategorized') 
     1069            self.model_box.SetStringSelection(state.formfactorcombobox) 
     1070        else: 
     1071            self.category_box.SetStringSelection(\ 
     1072                self.by_model_dict[state.formfactorcombobox][0] ) 
     1073            self.model_box.SetStringSelection(state.formfactorcombobox) 
     1074         
     1075 
    10641076        try: 
    10651077            # to support older version 
     
    11061118                                                    state.disp_cb_dict[item]) 
    11071119                        # Create the dispersion objects 
    1108                         from sans.models.dispersion_models import ArrayDispersion 
     1120                        from sans.models.dispersion_models \ 
     1121                            import ArrayDispersion 
    11091122                        disp_model = ArrayDispersion() 
    11101123                        if hasattr(state, "values") and \ 
     
    12051218        self.disp_list = state.disp_list 
    12061219       
    1207         ## set the state of the radio box 
    1208         self.shape_rbutton.SetValue(state.shape_rbutton) 
    1209         self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton) 
    1210         self.struct_rbutton.SetValue(state.struct_rbutton) 
    1211         self.plugin_rbutton.SetValue(state.plugin_rbutton) 
    12121220         
    12131221        ## fill model combobox 
    12141222        self._show_combox_helper() 
    12151223        #select the current model 
    1216         try: 
    1217             # to support older version 
    1218             formfactor_pos = int(state.formfactorcombobox) 
    1219         except: 
    1220             formfactor_pos = 0 
    1221             for ind_form in range(self.formfactorbox.GetCount()): 
    1222                 if self.formfactorbox.GetString(ind_form) == \ 
    1223                                                     (state.formfactorcombobox): 
    1224                     formfactor_pos = int(ind_form) 
    1225                     break 
    1226              
    1227         self.formfactorbox.Select(formfactor_pos) 
    1228          
     1224 
     1225 
     1226        self._regenerate_model_dict() 
     1227        if(len(self.by_model_dict[state.formfactorcombobox]) == 0): 
     1228            self.category_box.SetStringSelection('Uncategorized') 
     1229            self.model_box.SetStringSelection(state.formfactorcombobox) 
     1230        else: 
     1231            self.category_box.SetStringSelection(\ 
     1232                self.by_model_dict[state.formfactorcombobox][0] ) 
     1233            self.model_box.SetStringSelection(state.formfactorcombobox) 
     1234 
    12291235        try: 
    12301236            # to support older version 
     
    14261432        save radiobutton containing the type model that can be selected 
    14271433        """ 
    1428         self.state.shape_rbutton = self.shape_rbutton.GetValue() 
    1429         self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 
    1430         self.state.struct_rbutton = self.struct_rbutton.GetValue() 
    1431         self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
     1434        # self.state.shape_rbutton = self.shape_rbutton.GetValue() 
     1435        # self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 
     1436        # self.state.struct_rbutton = self.struct_rbutton.GetValue() 
     1437        # self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
    14321438        self.state.structurecombobox = self.structurebox.GetLabel() 
    1433         self.state.formfactorcombobox = self.formfactorbox.GetLabel() 
     1439        self.state.formfactorcombobox = self.model_box.GetStringSelection() 
    14341440        
    14351441        ## post state to fit panel 
     
    17661772            class_name = model.p_model.__class__ 
    17671773            name = model.p_model.name 
    1768             self.formfactorbox.Clear() 
     1774#            self.formfactorbox.Clear() 
    17691775             
    17701776            for k, list in self.model_list_box.iteritems(): 
    17711777                if k in["P(Q)*S(Q)", "Shapes"] and \ 
    17721778                    class_name in self.model_list_box["Shapes"]: 
    1773                     self.shape_rbutton.SetValue(True) 
     1779#                    self.shape_rbutton.SetValue(True) 
    17741780                    ## fill the form factor list with new model 
    1775                     self._populate_box(self.formfactorbox, 
    1776                                        self.model_list_box["Shapes"]) 
    1777                     items = self.formfactorbox.GetItems() 
    1778                     ## set comboxbox to the selected item 
    1779                     for i in range(len(items)): 
    1780                         if items[i] == str(name): 
    1781                             self.formfactorbox.SetSelection(i) 
    1782                             break 
     1781                    # self._populate_box(self.formfactorbox, 
     1782                    #                    self.model_list_box["Shapes"]) 
     1783                    # items = self.formfactorbox.GetItems() 
     1784                    # ## set comboxbox to the selected item 
     1785                    # for i in range(len(items)): 
     1786                    #     if items[i] == str(name): 
     1787                    #         self.formfactorbox.SetSelection(i) 
     1788                    #         break 
    17831789                    return 
    1784                 elif k == "Shape-Independent": 
    1785                     self.shape_indep_rbutton.SetValue(True) 
    1786                 elif k == "Structure Factors": 
    1787                     self.struct_rbutton.SetValue(True) 
    1788                 elif k == "Multi-Functions": 
    1789                     continue 
    1790                 else: 
    1791                     self.plugin_rbutton.SetValue(True) 
     1790                # elif k == "Shape-Independent": 
     1791                #     self.shape_indep_rbutton.SetValue(True) 
     1792                # elif k == "Structure Factors": 
     1793                #     self.struct_rbutton.SetValue(True) 
     1794                # elif k == "Multi-Functions": 
     1795                #     continue 
     1796                # else: 
     1797                #     self.plugin_rbutton.SetValue(True) 
    17921798                
    1793                 if class_name in list: 
    1794                     ## fill the form factor list with new model 
    1795                     self._populate_box(self.formfactorbox, list) 
    1796                     items = self.formfactorbox.GetItems() 
    1797                     ## set comboxbox to the selected item 
    1798                     for i in range(len(items)): 
    1799                         if items[i] == str(name): 
    1800                             self.formfactorbox.SetSelection(i) 
    1801                             break 
    1802                     break 
    1803         else: 
     1799                # if class_name in list: 
     1800                #     # ## fill the form factor list with new model 
     1801                #     # self._populate_box(self.formfactorbox, list) 
     1802                #     # items = self.formfactorbox.GetItems() 
     1803                #     # ## set comboxbox to the selected item 
     1804                #     # for i in range(len(items)): 
     1805                #     #     if items[i] == str(name): 
     1806                #     #         self.formfactorbox.SetSelection(i) 
     1807                #     #         break 
     1808                #     # break 
     1809                #     else: 
    18041810            ## Select the model from the menu 
    18051811            class_name = model.__class__ 
    18061812            name = model.name 
    1807             self.formfactorbox.Clear() 
    1808             items = self.formfactorbox.GetItems() 
     1813##            self.formfactorbox.Clear() 
     1814#            items = self.formfactorbox.GetItems() 
    18091815     
    18101816            for k, list in self.model_list_box.iteritems(): 
     
    18241830                        self.text2.Disable() 
    18251831                         
    1826                     self.shape_rbutton.SetValue(True) 
     1832#                    self.shape_rbutton.SetValue(True) 
    18271833                    ## fill the form factor list with new model 
    1828                     self._populate_box(self.formfactorbox, 
    1829                                        self.model_list_box["Shapes"]) 
    1830                     items = self.formfactorbox.GetItems() 
    1831                     ## set comboxbox to the selected item 
    1832                     for i in range(len(items)): 
    1833                         if items[i] == str(name): 
    1834                             self.formfactorbox.SetSelection(i) 
    1835                             break 
     1834                    # self._populate_box(self.formfactorbox, 
     1835                    #                    self.model_list_box["Shapes"]) 
     1836                    # items = self.formfactorbox.GetItems() 
     1837                    # ## set comboxbox to the selected item 
     1838                    # for i in range(len(items)): 
     1839                    #     if items[i] == str(name): 
     1840                    #         self.formfactorbox.SetSelection(i) 
     1841                    #         break 
    18361842                    return 
    1837                 elif k == "Shape-Independent": 
    1838                     self.shape_indep_rbutton.SetValue(True) 
    1839                 elif k == "Structure Factors": 
    1840                     self.struct_rbutton.SetValue(True) 
    1841                 elif k == "Multi-Functions": 
    1842                     continue 
    1843                 else: 
    1844                     self.plugin_rbutton.SetValue(True) 
     1843                # elif k == "Shape-Independent": 
     1844                #     self.shape_indep_rbutton.SetValue(True) 
     1845                # elif k == "Structure Factors": 
     1846                #     self.struct_rbutton.SetValue(True) 
     1847                # elif k == "Multi-Functions": 
     1848                #     continue 
     1849                # else: 
     1850                #     self.plugin_rbutton.SetValue(True) 
    18451851                if class_name in list: 
    18461852                    self.structurebox.SetSelection(0) 
     
    18481854                    self.text2.Disable() 
    18491855                    ## fill the form factor list with new model 
    1850                     self._populate_box(self.formfactorbox, list) 
    1851                     items = self.formfactorbox.GetItems() 
     1856                    # self._populate_box(self.formfactorbox, list) 
     1857                    # items = self.formfactorbox.GetItems() 
    18521858                    ## set comboxbox to the selected item 
    1853                     for i in range(len(items)): 
    1854                         if items[i] == str(name): 
    1855                             self.formfactorbox.SetSelection(i) 
    1856                             break 
     1859                    # for i in range(len(items)): 
     1860                    #     if items[i] == str(name): 
     1861                    #         self.formfactorbox.SetSelection(i) 
     1862                    #         break 
    18571863                    break 
    18581864                 
     
    19521958        Fill panel's combo box according to the type of model selected 
    19531959        """ 
    1954         if self.shape_rbutton.GetValue(): 
    1955             ##fill the combobox with form factor list 
    1956             self.structurebox.SetSelection(0) 
    1957             self.structurebox.Disable() 
    1958             self.formfactorbox.Clear() 
    1959             self._populate_box(self.formfactorbox, 
    1960                                self.model_list_box["Shapes"]) 
    1961         if self.shape_indep_rbutton.GetValue(): 
    1962             ##fill the combobox with shape independent  factor list 
    1963             self.structurebox.SetSelection(0) 
    1964             self.structurebox.Disable() 
    1965             self.formfactorbox.Clear() 
    1966             self._populate_box(self.formfactorbox, 
    1967                              self.model_list_box["Shape-Independent"]) 
    1968         if self.struct_rbutton.GetValue(): 
    1969             ##fill the combobox with structure factor list 
    1970             self.structurebox.SetSelection(0) 
    1971             self.structurebox.Disable() 
    1972             self.formfactorbox.Clear() 
    1973             self._populate_box(self.formfactorbox, 
    1974                                self.model_list_box["Structure Factors"]) 
    1975         if self.plugin_rbutton.GetValue(): 
    1976             ##fill the combobox with form factor list 
    1977             self.structurebox.Disable() 
    1978             self.formfactorbox.Clear() 
    1979             self._populate_box(self.formfactorbox, 
    1980                                self.model_list_box["Customized Models"]) 
     1960#         if self.shape_rbutton.GetValue(): 
     1961#             ##fill the combobox with form factor list 
     1962#             self.structurebox.SetSelection(0) 
     1963#             self.structurebox.Disable() 
     1964#             # self.formfactorbox.Clear() 
     1965#             # self._populate_box(self.formfactorbox, 
     1966#             #                    self.model_list_box["Shapes"]) 
     1967#         if self.shape_indep_rbutton.GetValue(): 
     1968#             ##fill the combobox with shape independent  factor list 
     1969#             self.structurebox.SetSelection(0) 
     1970#             self.structurebox.Disable() 
     1971# #            self.formfactorbox.Clear() 
     1972#             self._populate_box(self.formfactorbox, 
     1973#                              self.model_list_box["Shape-Independent"]) 
     1974#         if self.struct_rbutton.GetValue(): 
     1975#             ##fill the combobox with structure factor list 
     1976#             self.structurebox.SetSelection(0) 
     1977#             self.structurebox.Disable() 
     1978#  #           self.formfactorbox.Clear() 
     1979#             self._populate_box(self.formfactorbox, 
     1980#                                self.model_list_box["Structure Factors"]) 
     1981#         if self.plugin_rbutton.GetValue(): 
     1982#             ##fill the combobox with form factor list 
     1983#             self.structurebox.Disable() 
     1984#   #          self.formfactorbox.Clear() 
     1985#             self._populate_box(self.formfactorbox, 
     1986#                                self.model_list_box["Customized Models"]) 
    19811987         
    19821988    def _show_combox(self, event=None): 
     
    19942000        self.Refresh() 
    19952001   
    1996     def _populate_box(self, combobox, list): 
     2002    def _populate_box(self, combobox, model_list): 
    19972003        """ 
    19982004        fill combox box with dict item 
     
    20022008        """ 
    20032009        mlist = [] 
    2004         for models in list: 
     2010        for models in model_list: 
    20052011            model = models() 
    20062012            name = model.__class__.__name__ 
     
    21332139        """ 
    21342140        ## reset dictionary containing reference to dispersion 
     2141        if self.model_name == None: 
     2142            return 
     2143 
    21352144        self._disp_obj_dict = {} 
    21362145        self.disp_cb_dict = {} 
    21372146        self.temp_multi_functional = False 
    2138         f_id = self.formfactorbox.GetCurrentSelection() 
    2139         #For MAC 
    2140         form_factor = None 
    2141         if f_id >= 0: 
    2142             form_factor = self.formfactorbox.GetClientData(f_id) 
     2147 
     2148        form_factor = self.model_dict[self.model_name] 
    21432149 
    21442150        if not form_factor in  self.model_list_box["multiplication"]: 
     
    21542160            self.text2.Enable() 
    21552161             
     2162 
     2163 
    21562164        if form_factor != None: 
    21572165            # set multifactor for Mutifunctional models 
     
    23312339        return flag 
    23322340     
    2333     def _check_value_enter(self, list, modified): 
    2334         """ 
    2335         :param list: model parameter and panel info 
    2336         :Note: each item of the list should be as follow: 
     2341    def _check_value_enter(self, m_list, modified): 
     2342        """ 
     2343        :param m_list: model parameter and panel info 
     2344        :Note: each item of the m_list should be as follow: 
    23372345            item=[check button state, parameter's name, 
    23382346                paramater's value, string="+/-", 
     
    23432351        """ 
    23442352        is_modified = modified 
    2345         if len(list) == 0: 
     2353        if len(m_list) == 0: 
    23462354            return is_modified 
    2347         for item in list: 
     2355        for item in m_list: 
    23482356            #skip angle parameters for 1D 
    23492357            if not self.enable2D: 
     
    28952903        if self.model == None: 
    28962904            name = 'FuncHelp' 
    2897         else: 
    2898             name = self.formfactorbox.GetValue() 
     2905 
    28992906        frame = HelpWindow(None, -1, pageToOpen=model_path) 
    29002907        # If model name exists and model is not a custom model 
    2901         if frame.rhelp.HasAnchor(name) and not self.plugin_rbutton.GetValue(): 
    2902             frame.Show(True) 
    2903             frame.rhelp.ScrollToAnchor(name) 
    2904         else: 
    2905             if self.model != None: 
    2906                 frame.Destroy() 
    2907                 msg = 'Model description:\n' 
    2908                 if str(self.model.description).rstrip().lstrip() == '': 
    2909                     msg += "Sorry, no information is available for this model." 
    2910                 else: 
    2911                     msg += self.model.description + '\n' 
    2912                 info = "Info" 
    2913                 wx.MessageBox(msg, info) 
    2914             else: 
    2915                 frame.Show(True) 
     2908        # if frame.rhelp.HasAnchor(name) and not self.plugin_rbutton.GetValue(): 
     2909        #     frame.Show(True) 
     2910        #     frame.rhelp.ScrollToAnchor(name) 
     2911        # else: 
     2912        #     if self.model != None: 
     2913        #         frame.Destroy() 
     2914        #         msg = 'Model description:\n' 
     2915        #         if str(self.model.description).rstrip().lstrip() == '': 
     2916        #             msg += "Sorry, no information is available for this model." 
     2917        #         else: 
     2918        #             msg += self.model.description + '\n' 
     2919        #         info = "Info" 
     2920        #         wx.MessageBox(msg, info) 
     2921        #     else: 
     2922        #         frame.Show(True) 
    29162923     
    29172924    def on_pd_help_clicked(self, event): 
     
    32903297        return 
    32913298 
     3299    def _read_category_info(self): 
     3300        """ 
     3301        Reads the categories in from file 
     3302        """ 
     3303 
     3304        # # ILL mod starts here - July 2012 kieranrcampbell@gmail.com 
     3305        self.master_category_dict = defaultdict(list) 
     3306        self.by_model_dict = defaultdict(list) 
     3307        self.model_enabled_dict = defaultdict(bool) 
     3308 
     3309        categorization_file = CategoryInstaller.get_user_file() 
     3310 
     3311 
     3312        try: 
     3313            cat_file = open(categorization_file, 'rb') 
     3314                             
     3315            self.master_category_dict = pickle.load(cat_file) 
     3316            self._regenerate_model_dict() 
     3317 
     3318        except IOError: 
     3319            print 'Problem reading in category file.' 
     3320            print 'We even looked for it, made sure it was there.' 
     3321            print 'An existential crisis if there ever was one.' 
     3322 
     3323    def _regenerate_model_dict(self): 
     3324        """ 
     3325        regenerates self.by_model_dict which has each model name as the  
     3326        key and the list of categories belonging to that model 
     3327        along with the enabled mapping 
     3328        """ 
     3329 
     3330        self.by_model_dict = defaultdict(list) 
     3331        for category in self.master_category_dict: 
     3332            for (model,enabled) in self.master_category_dict[category]: 
     3333                self.by_model_dict[model].append(category) 
     3334                self.model_enabled_dict[model] = enabled 
     3335     
     3336    def _populate_listbox(self): 
     3337        """ 
     3338        fills out the category list box 
     3339        """ 
     3340        self._read_category_info() 
     3341 
     3342        self.category_box.Clear() 
     3343        cat_list = sorted(self.master_category_dict.keys()) 
     3344        cat_list.append('Customized') 
     3345 
     3346        for category in cat_list: 
     3347            if category != '': 
     3348                self.category_box.Append(category) 
     3349 
     3350        if self.category_box.GetSelection() == wx.NOT_FOUND: 
     3351            self.category_box.SetSelection(0) 
     3352        else: 
     3353            self.category_box.SetSelection( \ 
     3354                self.category_box.GetSelection()) 
     3355 
     3356        self._on_change_cat(None) 
     3357 
     3358 
     3359    def _on_change_cat(self, event): 
     3360        """ 
     3361        Callback for category change action 
     3362        """ 
     3363        self.model_name = None 
     3364        category = self.category_box.GetStringSelection() 
     3365        if category == None: 
     3366            return 
     3367        self.model_box.Clear() 
     3368 
     3369        if category == 'Customized': 
     3370            for model in self.model_list_box["Customized Models"]: 
     3371                str_m = str(model).split(".")[0] 
     3372                self.model_box.Append(str_m) 
     3373            print 'but not here' 
     3374 
     3375        else: 
     3376            for (model,enabled) in sorted(self.master_category_dict[category], 
     3377                                      key = lambda name: name[0]): 
     3378                if(enabled): 
     3379                    self.model_box.Append(model) 
     3380 
    32923381    def _fill_model_sizer(self, sizer): 
    32933382        """ 
    32943383        fill sizer containing model info 
    32953384        """ 
     3385 
    32963386        ##Add model function Details button in fitpanel. 
    32973387        ##The following 3 lines are for Mac. Let JHC know before modifying... 
     
    33113401        hint = "toggle view of model from 1D to 2D  or 2D to 1D" 
    33123402        self.model_view.SetToolTipString(hint) 
    3313        
    3314         self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes', 
    3315                                              style=wx.RB_GROUP) 
    3316         self.shape_indep_rbutton = wx.RadioButton(self, -1, 
    3317                                                   "Shape-Independent") 
    3318         self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ") 
    3319         self.plugin_rbutton = wx.RadioButton(self, -1, "Customized Models") 
    3320                  
    3321         self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    3322                             id=self.shape_rbutton.GetId()) 
    3323         self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    3324                             id=self.shape_indep_rbutton.GetId()) 
    3325         self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    3326                             id=self.struct_rbutton.GetId()) 
    3327         self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    3328                             id=self.plugin_rbutton.GetId()) 
    3329         #MAC needs SetValue 
    3330         self.shape_rbutton.SetValue(True) 
    3331        
     3403 
     3404         
     3405        # ILL mod starts here - Aug 2012 
     3406 
     3407 
     3408        cat_text = wx.StaticText(self, -1, 'Category') 
     3409        mod_text = wx.StaticText(self, -1, 'Model') 
     3410         
     3411        id = wx.NewId() 
     3412        self.category_box = wx.ListBox(self, size=(150, 100)) 
     3413        self.category_box.Bind(wx.EVT_LISTBOX, self._on_change_cat) 
     3414        self.model_box = wx.ListBox(self, -1, size=(150, 100)) 
     3415        self.model_box.Bind(wx.EVT_LISTBOX, self._on_select_model) 
     3416 
    33323417        sizer_radiobutton = wx.GridSizer(2, 3, 5, 5) 
    3333         sizer_radiobutton.Add(self.shape_rbutton) 
    3334         sizer_radiobutton.Add(self.shape_indep_rbutton) 
    3335         sizer_radiobutton.Add(self.model_view, 1, wx.LEFT, 20) 
    3336         sizer_radiobutton.Add(self.plugin_rbutton) 
    3337         sizer_radiobutton.Add(self.struct_rbutton) 
    3338         sizer_radiobutton.Add(self.model_help, 1, wx.LEFT, 20) 
    3339          
     3418        hbox1 = wx.BoxSizer(wx.HORIZONTAL) 
     3419        hbox2 = wx.BoxSizer(wx.HORIZONTAL) 
     3420        vbox1 = wx.BoxSizer(wx.VERTICAL) 
     3421        vbox2 = wx.BoxSizer(wx.VERTICAL) 
     3422        vbox3 = wx.BoxSizer(wx.VERTICAL) 
     3423 
     3424        vbox1.Add(cat_text, border = 5, flag = wx.EXPAND | wx.ALL) 
     3425        vbox2.Add(mod_text, border=5, flag = wx.EXPAND | wx.ALL) 
     3426        vbox3.Add(self.model_view, flag= wx.ALL | wx.ALIGN_LEFT 
     3427                  , border =5) 
     3428        vbox1.Add(self.category_box, border = 5, flag = wx.EXPAND | wx.ALL) 
     3429        vbox2.Add(self.model_box, flag = wx.EXPAND | wx.ALL, border = 5) 
     3430        vbox3.Add(self.model_help, border = 5,  
     3431                  flag = wx.LEFT | wx.ALIGN_LEFT ) 
     3432 
     3433        hbox1.Add(vbox1, border = 5, flag = wx.EXPAND | wx.ALL) 
     3434        hbox1.Add(vbox2, border = 5, flag = wx.EXPAND | wx.ALL) 
     3435        hbox1.Add(vbox3, border = 5, flag = wx.EXPAND | wx.ALL) 
     3436 
    33403437        sizer_selection = wx.BoxSizer(wx.HORIZONTAL) 
    33413438        mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL) 
    33423439         
    33433440        self.text1 = wx.StaticText(self, -1, "") 
    3344         self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q)") 
     3441        self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q) ") 
    33453442        self.mutifactor_text = wx.StaticText(self, -1, "No. of Shells: ") 
    33463443        self.mutifactor_text1 = wx.StaticText(self, -1, "") 
     
    33483445        self.show_sld_button.Bind(wx.EVT_BUTTON, self._on_show_sld) 
    33493446 
    3350         self.formfactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
    3351         if self.model != None: 
    3352             self.formfactorbox.SetValue(self.model.name) 
    33533447        self.structurebox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
    33543448        self.multifactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
    33553449        self.initialize_combox() 
    3356         wx.EVT_COMBOBOX(self.formfactorbox, -1, self._on_select_model) 
    33573450 
    33583451        wx.EVT_COMBOBOX(self.structurebox, -1, self._on_select_model) 
    33593452        wx.EVT_COMBOBOX(self.multifactorbox, -1, self._on_select_model) 
    33603453        ## check model type to show sizer 
     3454 
     3455        hbox2.Add(self.text2, border = 5, flag = wx.EXPAND | wx.ALL ) 
     3456        hbox2.Add(self.structurebox, border = 5, flag = wx.EXPAND | \ 
     3457                      wx.ALL ) 
     3458         
    33613459        if self.model != None: 
    33623460            self._set_model_sizer_selection(self.model) 
    33633461         
    3364         sizer_selection.Add(self.text1) 
    3365         sizer_selection.Add((5, 5)) 
    3366         sizer_selection.Add(self.formfactorbox) 
    3367         sizer_selection.Add((5, 5)) 
    3368         sizer_selection.Add(self.text2) 
    3369         sizer_selection.Add((5, 5)) 
    3370         sizer_selection.Add(self.structurebox) 
     3462        self._populate_listbox() 
     3463         
    33713464        
    33723465        mutifactor_selection.Add((10, 5)) 
     
    33783471        mutifactor_selection.Add(self.show_sld_button) 
    33793472 
    3380         boxsizer1.Add(sizer_radiobutton) 
     3473        boxsizer1.Add(hbox1, flag = wx.EXPAND) 
     3474        boxsizer1.Add(hbox2, flag = wx.EXPAND) 
    33813475        boxsizer1.Add((10, 10)) 
    3382         boxsizer1.Add(sizer_selection) 
    3383         boxsizer1.Add((10, 10)) 
     3476 
    33843477        boxsizer1.Add(mutifactor_selection) 
    33853478         
  • fittingview/src/sans/perspectives/fitting/fitpage.py

    re4cd34c rdf7a7e3  
    3636    """ 
    3737 
    38     def __init__(self, parent, color='rand'): 
     38    def __init__(self, parent, m_dict, color='rand'): 
    3939        """ 
    4040        Initialization of the Panel 
    4141        """ 
    4242        BasicPage.__init__(self, parent, color=color) 
    43          
     43        self.populate_box(m_dict) 
     44 
    4445        ## draw sizer 
    4546        self._fill_data_sizer() 
     
    6768        #create a default data for an empty panel 
    6869        self.create_default_data() 
    69      
     70 
    7071    def enable_fit_button(self): 
    7172        """ 
     
    10871088        call back for model selection 
    10881089        """ 
     1090        # if we're just clearing the box then do nothing 
     1091        if self.model_box.GetCount() == 0 or \ 
     1092                self.model_box.GetStringSelection() == '': 
     1093            return 
     1094 
     1095 
    10891096        self.Show(False) 
    10901097        copy_flag = False 
    10911098        is_poly_enabled = None 
    10921099        if event != None: 
    1093             if (event.GetEventObject() == self.formfactorbox\ 
    1094                         and self.structurebox.GetLabel() != 'None')\ 
    1095                         or event.GetEventObject() == self.structurebox\ 
    1096                         or event.GetEventObject() == self.multifactorbox: 
    1097                 copy_flag = self.get_copy_params() 
    1098                 is_poly_enabled = self.enable_disp.GetValue() 
    1099  
     1100            # if (event.GetEventObject() == self.formfactorbox\ 
     1101            #             and self.structurebox.GetLabel() != 'None')\ 
     1102            #             or event.GetEventObject() == self.structurebox\ 
     1103            #             or event.GetEventObject() == self.multifactorbox: 
     1104            copy_flag = self.get_copy_params() 
     1105            is_poly_enabled = self.enable_disp.GetValue() 
     1106 
     1107        self.model_name = self.model_box.GetStringSelection() 
    11001108        self._on_select_model_helper() 
    11011109        self.set_model_param_sizer(self.model) 
     
    11161124     
    11171125        self.state.structurecombobox = self.structurebox.GetLabel() 
    1118         self.state.formfactorcombobox = self.formfactorbox.GetLabel() 
     1126        self.state.formfactorcombobox = self.model_box.GetStringSelection() 
    11191127        self.enable_fit_button() 
    11201128        if self.model != None: 
     
    11751183            wx.PostEvent(self.parent, new_event) 
    11761184            #update list of plugins if new plugin is available 
    1177             if self.plugin_rbutton.GetValue(): 
    1178                 temp = self.parent.update_model_list() 
    1179                 if temp: 
    1180                     self.model_list_box = temp 
    1181                     current_val = self.formfactorbox.GetLabel() 
    1182                     pos = self.formfactorbox.GetSelection() 
    1183                     self._show_combox_helper() 
    1184                     self.formfactorbox.SetSelection(pos) 
    1185                     self.formfactorbox.SetValue(current_val) 
     1185            # if self.plugin_rbutton.GetValue(): 
     1186            #     temp = self.parent.update_model_list() 
     1187            #     if temp: 
     1188            #         self.model_list_box = temp 
     1189                    # current_val = self.formfactorbox.GetLabel() 
     1190                    # pos = self.formfactorbox.GetSelection() 
     1191                    # self._show_combox_helper() 
     1192                    # self.formfactorbox.SetSelection(pos) 
     1193                    # self.formfactorbox.SetValue(current_val) 
    11861194            # when select a model only from guictr/button 
    11871195            if is_poly_enabled != None: 
     
    18141822            self.dI_idata.Enable(True) 
    18151823               
    1816             self.formfactorbox.Enable() 
     1824#            self.formfactorbox.Enable() 
    18171825            self.structurebox.Enable() 
    18181826            data_name = self.data.name 
  • fittingview/src/sans/perspectives/fitting/fitpanel.py

    rf32d144 rdf7a7e3  
    4848        self.menu_mng = models.ModelManager() 
    4949        self.model_list_box = self.menu_mng.get_model_list() 
     50        self.model_dictionary = self.menu_mng.get_model_dictionary() 
    5051        #pageClosedEvent = nb.EVT_FLATNOTEBOOK_PAGE_CLOSING 
    5152        self.pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE 
     
    304305                page.set_manager(self._manager) 
    305306 
    306     def set_model_list(self, dict): 
     307    def set_model_list(self, m_dict): 
    307308        """ 
    308309        copy a dictionary of model into its own dictionary 
    309310         
    310         :param dict: dictionnary made of model name as key and model class 
     311        :param m_dict: dictionnary made of model name as key and model class 
    311312        as value 
    312313        """ 
    313         self.model_list_box = dict 
    314          
     314        self.model_list_box = m_dict 
     315         
     316    def set_model_dict(self, m_dict): 
     317        """ 
     318        copy a dictionary of model name -> model object 
     319 
     320        :param m_dict: dictionary linking model name -> model object 
     321        """ 
     322 
    315323    def get_current_page(self): 
    316324        """ 
     
    360368        else: 
    361369        """ 
     370 
    362371        from fitpage import FitPage 
    363         panel = FitPage(parent=self) 
     372        panel = FitPage(parent=self, m_dict = self.model_list_box) 
     373 
    364374        if self.batch_on: 
    365375            self.batch_page_index += 1 
     
    373383        panel.batch_on = self.batch_on 
    374384        panel._set_save_flag(not panel.batch_on) 
    375         panel.populate_box(dict=self.model_list_box) 
     385        panel.set_model_dictionary(self.model_dictionary) 
    376386        panel.set_manager(self._manager) 
    377387        panel.window_caption = caption 
  • fittingview/src/sans/perspectives/fitting/fitting.py

    r162c778 rdf7a7e3  
    5252else: 
    5353    ON_MAC = True 
     54 
    5455 
    5556 
  • fittingview/src/sans/perspectives/fitting/models.py

    rf40f743 rdf7a7e3  
    1818# as the base class of plug-in models. 
    1919from sans.models.pluginmodel import Model1DPlugin 
     20from sans.models.BaseComponent import BaseComponent 
    2021    
    2122PLUGIN_DIR = 'plugin_models' 
     23 
     24def get_model_python_path(): 
     25    return os.path.dirname(__file__) 
    2226 
    2327 
     
    261265        """ 
    262266        """ 
     267        self.model_dictionary = {} 
    263268        self.stored_plugins = {} 
    264269        self._getModelList() 
     
    283288         
    284289        """ 
     290 
     291 
    285292        # regular model names only 
    286293        self.model_name_list = [] 
    287294        from sans.models.SphereModel import SphereModel 
     295        self.model_dictionary[SphereModel.__name__] = SphereModel 
    288296        self.shape_list.append(SphereModel) 
    289297        self.multiplication_factor.append(SphereModel) 
     
    291299         
    292300        from sans.models.BinaryHSModel import BinaryHSModel 
     301        self.model_dictionary[BinaryHSModel.__name__] = BinaryHSModel 
    293302        self.shape_list.append(BinaryHSModel) 
    294303        self.model_name_list.append(BinaryHSModel.__name__) 
    295304                         
    296305        from sans.models.FuzzySphereModel import FuzzySphereModel 
     306        self.model_dictionary[FuzzySphereModel.__name__] = FuzzySphereModel 
    297307        self.shape_list.append(FuzzySphereModel) 
    298308        self.multiplication_factor.append(FuzzySphereModel) 
     
    300310                         
    301311        from sans.models.RaspBerryModel import RaspBerryModel 
     312        self.model_dictionary[RaspBerryModel.__name__] = RaspBerryModel 
    302313        self.shape_list.append(RaspBerryModel) 
    303314        self.model_name_list.append(RaspBerryModel.__name__) 
    304315                 
    305316        from sans.models.CoreShellModel import CoreShellModel 
     317        self.model_dictionary[CoreShellModel.__name__] = CoreShellModel 
    306318        self.shape_list.append(CoreShellModel) 
    307319        self.multiplication_factor.append(CoreShellModel) 
     
    309321         
    310322        from sans.models.Core2ndMomentModel import Core2ndMomentModel 
     323        self.model_dictionary[Core2ndMomentModel.__name__] = Core2ndMomentModel 
    311324        self.shape_list.append(Core2ndMomentModel) 
    312325        self.model_name_list.append(Core2ndMomentModel.__name__) 
    313326         
    314327        from sans.models.CoreMultiShellModel import CoreMultiShellModel 
     328        self.model_dictionary[CoreMultiShellModel.__name__] = CoreMultiShellModel 
    315329        self.shape_list.append(CoreMultiShellModel) 
    316330        self.multiplication_factor.append(CoreMultiShellModel) 
     
    318332 
    319333        from sans.models.VesicleModel import VesicleModel 
     334        self.model_dictionary[VesicleModel.__name__] = VesicleModel 
    320335        self.shape_list.append(VesicleModel) 
    321336        self.multiplication_factor.append(VesicleModel) 
     
    323338         
    324339        from sans.models.MultiShellModel import MultiShellModel 
     340        self.model_dictionary[MultiShellModel.__name__] = MultiShellModel 
    325341        self.shape_list.append(MultiShellModel) 
    326342        self.multiplication_factor.append(MultiShellModel) 
     
    328344         
    329345        from sans.models.OnionExpShellModel import OnionExpShellModel 
     346        self.model_dictionary[OnionExpShellModel.__name__] = OnionExpShellModel 
    330347        self.shape_list.append(OnionExpShellModel) 
    331348        self.multiplication_factor.append(OnionExpShellModel) 
     
    333350                          
    334351        from sans.models.SphericalSLDModel import SphericalSLDModel 
     352        self.model_dictionary[SphericalSLDModel.__name__] = SphericalSLDModel 
    335353        self.shape_list.append(SphericalSLDModel) 
    336354        self.multiplication_factor.append(SphericalSLDModel) 
     
    339357         
    340358        from sans.models.LinearPearlsModel import LinearPearlsModel 
     359        self.model_dictionary[LinearPearlsModel.__name__] = LinearPearlsModel 
    341360        self.shape_list.append(LinearPearlsModel) 
    342361        self.model_name_list.append(LinearPearlsModel.__name__) 
    343362           
    344363        from sans.models.PearlNecklaceModel import PearlNecklaceModel 
     364        self.model_dictionary[PearlNecklaceModel.__name__] = PearlNecklaceModel 
    345365        self.shape_list.append(PearlNecklaceModel) 
    346366        self.model_name_list.append(PearlNecklaceModel.__name__) 
     
    348368         
    349369        from sans.models.CylinderModel import CylinderModel 
     370        self.model_dictionary[CylinderModel.__name__] = CylinderModel 
    350371        self.shape_list.append(CylinderModel) 
    351372        self.multiplication_factor.append(CylinderModel) 
     
    353374         
    354375        from sans.models.CoreShellCylinderModel import CoreShellCylinderModel 
     376        self.model_dictionary[CoreShellCylinderModel.__name__] = CoreShellCylinderModel 
    355377        self.shape_list.append(CoreShellCylinderModel) 
    356378        self.multiplication_factor.append(CoreShellCylinderModel) 
     
    358380         
    359381        from sans.models.CoreShellBicelleModel import CoreShellBicelleModel 
     382        self.model_dictionary[CoreShellBicelleModel.__name__] = CoreShellBicelleModel 
    360383        self.shape_list.append(CoreShellBicelleModel) 
    361384        self.multiplication_factor.append(CoreShellBicelleModel) 
     
    363386                 
    364387        from sans.models.HollowCylinderModel import HollowCylinderModel 
     388        self.model_dictionary[HollowCylinderModel.__name__] = HollowCylinderModel 
    365389        self.shape_list.append(HollowCylinderModel) 
    366390        self.multiplication_factor.append(HollowCylinderModel) 
     
    368392               
    369393        from sans.models.FlexibleCylinderModel import FlexibleCylinderModel 
     394        self.model_dictionary[FlexibleCylinderModel.__name__] = FlexibleCylinderModel 
    370395        self.shape_list.append(FlexibleCylinderModel) 
    371396        self.model_name_list.append(FlexibleCylinderModel.__name__) 
    372397 
    373398        from sans.models.FlexCylEllipXModel import FlexCylEllipXModel 
     399        self.model_dictionary[FlexCylEllipXModel.__name__] = FlexCylEllipXModel 
    374400        self.shape_list.append(FlexCylEllipXModel) 
    375401        self.model_name_list.append(FlexCylEllipXModel.__name__) 
    376402         
    377403        from sans.models.StackedDisksModel import StackedDisksModel 
     404        self.model_dictionary[StackedDisksModel.__name__] = StackedDisksModel 
    378405        self.shape_list.append(StackedDisksModel) 
    379406        self.multiplication_factor.append(StackedDisksModel) 
     
    381408         
    382409        from sans.models.ParallelepipedModel import ParallelepipedModel 
     410        self.model_dictionary[ParallelepipedModel.__name__] = ParallelepipedModel 
    383411        self.shape_list.append(ParallelepipedModel) 
    384412        self.multiplication_factor.append(ParallelepipedModel) 
     
    386414         
    387415        from sans.models.CSParallelepipedModel import CSParallelepipedModel 
     416        self.model_dictionary[CSParallelepipedModel.__name__] = CSParallelepipedModel 
    388417        self.shape_list.append(CSParallelepipedModel) 
    389418        self.multiplication_factor.append(CSParallelepipedModel) 
     
    391420         
    392421        from sans.models.EllipticalCylinderModel import EllipticalCylinderModel 
     422        self.model_dictionary[EllipticalCylinderModel.__name__] = EllipticalCylinderModel 
    393423        self.shape_list.append(EllipticalCylinderModel) 
    394424        self.multiplication_factor.append(EllipticalCylinderModel) 
     
    396426         
    397427        from sans.models.BarBellModel import BarBellModel 
     428        self.model_dictionary[BarBellModel.__name__] = BarBellModel 
    398429        self.shape_list.append(BarBellModel) 
    399430        self.model_name_list.append(BarBellModel.__name__) 
     
    402433         
    403434        from sans.models.CappedCylinderModel import CappedCylinderModel 
     435        self.model_dictionary[CappedCylinderModel.__name__] = CappedCylinderModel 
    404436        self.shape_list.append(CappedCylinderModel) 
    405437        self.model_name_list.append(CappedCylinderModel.__name__) 
     
    408440         
    409441        from sans.models.EllipsoidModel import EllipsoidModel 
     442        self.model_dictionary[EllipsoidModel.__name__] = EllipsoidModel 
    410443        self.shape_list.append(EllipsoidModel) 
    411444        self.multiplication_factor.append(EllipsoidModel) 
     
    413446       
    414447        from sans.models.CoreShellEllipsoidModel import CoreShellEllipsoidModel 
     448        self.model_dictionary[CoreShellEllipsoidModel.__name__] = CoreShellEllipsoidModel 
    415449        self.shape_list.append(CoreShellEllipsoidModel) 
    416450        self.multiplication_factor.append(CoreShellEllipsoidModel) 
     
    418452          
    419453        from sans.models.TriaxialEllipsoidModel import TriaxialEllipsoidModel 
     454        self.model_dictionary[TriaxialEllipsoidModel.__name__] = TriaxialEllipsoidModel 
    420455        self.shape_list.append(TriaxialEllipsoidModel) 
    421456        self.multiplication_factor.append(TriaxialEllipsoidModel) 
     
    423458         
    424459        from sans.models.LamellarModel import LamellarModel 
     460        self.model_dictionary[LamellarModel.__name__] = LamellarModel 
    425461        self.shape_list.append(LamellarModel) 
    426462        self.model_name_list.append(LamellarModel.__name__) 
    427463         
    428464        from sans.models.LamellarFFHGModel import LamellarFFHGModel 
     465        self.model_dictionary[LamellarFFHGModel.__name__] = LamellarFFHGModel 
    429466        self.shape_list.append(LamellarFFHGModel) 
    430467        self.model_name_list.append(LamellarFFHGModel.__name__) 
    431468         
    432469        from sans.models.LamellarPSModel import LamellarPSModel 
     470        self.model_dictionary[LamellarPSModel.__name__] = LamellarPSModel 
    433471        self.shape_list.append(LamellarPSModel) 
    434472        self.model_name_list.append(LamellarPSModel.__name__) 
    435473      
    436474        from sans.models.LamellarPSHGModel import LamellarPSHGModel 
     475        self.model_dictionary[LamellarPSHGModel.__name__] = LamellarPSHGModel 
    437476        self.shape_list.append(LamellarPSHGModel) 
    438477        self.model_name_list.append(LamellarPSHGModel.__name__) 
    439478         
    440479        from sans.models.LamellarPCrystalModel import LamellarPCrystalModel 
     480        self.model_dictionary[LamellarPCrystalModel.__name__] = LamellarPCrystalModel 
    441481        self.shape_list.append(LamellarPCrystalModel) 
    442482        self.model_name_list.append(LamellarPCrystalModel.__name__) 
    443483         
    444484        from sans.models.SCCrystalModel import SCCrystalModel 
     485        self.model_dictionary[SCCrystalModel.__name__] = SCCrystalModel 
    445486        self.shape_list.append(SCCrystalModel) 
    446487        self.model_name_list.append(SCCrystalModel.__name__) 
    447488         
    448489        from sans.models.FCCrystalModel import FCCrystalModel 
     490        self.model_dictionary[FCCrystalModel.__name__] = FCCrystalModel 
    449491        self.shape_list.append(FCCrystalModel) 
    450492        self.model_name_list.append(FCCrystalModel.__name__) 
    451493         
    452494        from sans.models.BCCrystalModel import BCCrystalModel 
     495        self.model_dictionary[BCCrystalModel.__name__] = BCCrystalModel 
    453496        self.shape_list.append(BCCrystalModel) 
    454497        self.model_name_list.append(BCCrystalModel.__name__) 
     
    456499        ## Structure factor 
    457500        from sans.models.SquareWellStructure import SquareWellStructure 
     501        self.model_dictionary[SquareWellStructure.__name__] = SquareWellStructure 
    458502        self.struct_list.append(SquareWellStructure) 
    459503        self.model_name_list.append(SquareWellStructure.__name__) 
    460504         
    461505        from sans.models.HardsphereStructure import HardsphereStructure 
     506        self.model_dictionary[HardsphereStructure.__name__] = HardsphereStructure 
    462507        self.struct_list.append(HardsphereStructure) 
    463508        self.model_name_list.append(HardsphereStructure.__name__) 
    464509          
    465510        from sans.models.StickyHSStructure import StickyHSStructure 
     511        self.model_dictionary[StickyHSStructure.__name__] = StickyHSStructure 
    466512        self.struct_list.append(StickyHSStructure) 
    467513        self.model_name_list.append(StickyHSStructure.__name__) 
    468514         
    469515        from sans.models.HayterMSAStructure import HayterMSAStructure 
     516        self.model_dictionary[HayterMSAStructure.__name__] = HayterMSAStructure 
    470517        self.struct_list.append(HayterMSAStructure) 
    471518        self.model_name_list.append(HayterMSAStructure.__name__) 
     
    474521        ##shape-independent models 
    475522        from sans.models.PowerLawAbsModel import PowerLawAbsModel 
     523        self.model_dictionary[PowerLawAbsModel.__name__] = PowerLawAbsModel 
    476524        self.shape_indep_list.append(PowerLawAbsModel) 
    477525        self.model_name_list.append(PowerLawAbsModel.__name__) 
    478526         
    479527        from sans.models.BEPolyelectrolyte import BEPolyelectrolyte 
     528        self.model_dictionary[BEPolyelectrolyte.__name__] = BEPolyelectrolyte 
    480529        self.shape_indep_list.append(BEPolyelectrolyte) 
    481530        self.model_name_list.append(BEPolyelectrolyte.__name__) 
     
    483532         
    484533        from sans.models.BroadPeakModel import BroadPeakModel 
     534        self.model_dictionary[BroadPeakModel.__name__] = BroadPeakModel 
    485535        self.shape_indep_list.append(BroadPeakModel) 
    486536        self.model_name_list.append(BroadPeakModel.__name__) 
    487537         
    488538        from sans.models.CorrLengthModel import CorrLengthModel 
     539        self.model_dictionary[CorrLengthModel.__name__] = CorrLengthModel 
    489540        self.shape_indep_list.append(CorrLengthModel) 
    490541        self.model_name_list.append(CorrLengthModel.__name__) 
    491542         
    492543        from sans.models.DABModel import DABModel 
     544        self.model_dictionary[DABModel.__name__] = DABModel 
    493545        self.shape_indep_list.append(DABModel) 
    494546        self.model_name_list.append(DABModel.__name__) 
    495547         
    496548        from sans.models.DebyeModel import DebyeModel 
     549        self.model_dictionary[DebyeModel.__name__] = DebyeModel 
    497550        self.shape_indep_list.append(DebyeModel) 
    498551        self.model_name_list.append(DebyeModel.__name__) 
    499552         
    500553        from sans.models.FractalModel import FractalModel 
     554        self.model_dictionary[FractalModel.__name__] = FractalModel 
    501555        self.shape_indep_list.append(FractalModel) 
    502556        self.model_name_list.append(FractalModel.__name__) 
    503557         
    504558        from sans.models.FractalCoreShellModel import FractalCoreShellModel 
     559        self.model_dictionary[FractalCoreShellModel.__name__] = FractalCoreShellModel 
    505560        self.shape_indep_list.append(FractalCoreShellModel) 
    506561        self.model_name_list.append(FractalCoreShellModel.__name__) 
    507562         
    508563        from sans.models.GaussLorentzGelModel import GaussLorentzGelModel 
     564        self.model_dictionary[GaussLorentzGelModel.__name__] = GaussLorentzGelModel 
    509565        self.shape_indep_list.append(GaussLorentzGelModel) 
    510566        self.model_name_list.append(GaussLorentzGelModel.__name__) 
    511567                 
    512568        from sans.models.GuinierModel import GuinierModel 
     569        self.model_dictionary[GuinierModel.__name__] = GuinierModel 
    513570        self.shape_indep_list.append(GuinierModel) 
    514571        self.model_name_list.append(GuinierModel.__name__) 
    515572         
    516573        from sans.models.GuinierPorodModel import GuinierPorodModel 
     574        self.model_dictionary[GuinierPorodModel.__name__] = GuinierPorodModel 
    517575        self.shape_indep_list.append(GuinierPorodModel) 
    518576        self.model_name_list.append(GuinierPorodModel.__name__) 
    519577 
    520578        from sans.models.LorentzModel import LorentzModel 
     579        self.model_dictionary[LorentzModel.__name__] = LorentzModel 
    521580        self.shape_indep_list.append(LorentzModel) 
    522581        self.model_name_list.append(LorentzModel.__name__) 
    523582 
    524583        from sans.models.MassFractalModel import MassFractalModel 
     584        self.model_dictionary[MassFractalModel.__name__] = MassFractalModel 
    525585        self.shape_indep_list.append(MassFractalModel) 
    526586        self.model_name_list.append(MassFractalModel.__name__) 
    527587         
    528588        from sans.models.MassSurfaceFractal import MassSurfaceFractal 
     589        self.model_dictionary[MassSurfaceFractal.__name__] = MassSurfaceFractal 
    529590        self.shape_indep_list.append(MassSurfaceFractal) 
    530591        self.model_name_list.append(MassSurfaceFractal.__name__) 
    531592         
    532593        from sans.models.PeakGaussModel import PeakGaussModel 
     594        self.model_dictionary[PeakGaussModel.__name__] = PeakGaussModel 
    533595        self.shape_indep_list.append(PeakGaussModel) 
    534596        self.model_name_list.append(PeakGaussModel.__name__) 
    535597         
    536598        from sans.models.PeakLorentzModel import PeakLorentzModel 
     599        self.model_dictionary[PeakLorentzModel.__name__] = PeakLorentzModel 
    537600        self.shape_indep_list.append(PeakLorentzModel) 
    538601        self.model_name_list.append(PeakLorentzModel.__name__) 
    539602         
    540603        from sans.models.Poly_GaussCoil import Poly_GaussCoil 
     604        self.model_dictionary[Poly_GaussCoil.__name__] = Poly_GaussCoil 
    541605        self.shape_indep_list.append(Poly_GaussCoil) 
    542606        self.model_name_list.append(Poly_GaussCoil.__name__) 
    543607         
    544608        from sans.models.PolymerExclVolume import PolymerExclVolume 
     609        self.model_dictionary[PolymerExclVolume.__name__] = PolymerExclVolume 
    545610        self.shape_indep_list.append(PolymerExclVolume) 
    546611        self.model_name_list.append(PolymerExclVolume.__name__) 
    547612         
    548613        from sans.models.PorodModel import PorodModel 
     614        self.model_dictionary[PorodModel.__name__] = PorodModel 
    549615        self.shape_indep_list.append(PorodModel) 
    550616        self.model_name_list.append(PorodModel.__name__) 
    551617         
    552618        from sans.models.RPA10Model import RPA10Model 
     619        self.model_dictionary[RPA10Model.__name__] = RPA10Model 
    553620        self.shape_indep_list.append(RPA10Model) 
    554621        self.multi_func_list.append(RPA10Model) 
    555622 
    556623        from sans.models.StarPolymer import StarPolymer 
     624        self.model_dictionary[StarPolymer.__name__] = StarPolymer 
    557625        self.shape_indep_list.append(StarPolymer) 
    558626        self.model_name_list.append(StarPolymer.__name__) 
    559627 
    560628        from sans.models.SurfaceFractalModel import SurfaceFractalModel 
     629        self.model_dictionary[SurfaceFractalModel.__name__] = SurfaceFractalModel 
    561630        self.shape_indep_list.append(SurfaceFractalModel) 
    562631        self.model_name_list.append(SurfaceFractalModel.__name__) 
    563632         
    564633        from sans.models.TeubnerStreyModel import TeubnerStreyModel 
     634        self.model_dictionary[TeubnerStreyModel.__name__] = TeubnerStreyModel 
    565635        self.shape_indep_list.append(TeubnerStreyModel) 
    566636        self.model_name_list.append(TeubnerStreyModel.__name__) 
    567637 
    568638        from sans.models.TwoLorentzianModel import TwoLorentzianModel 
     639        self.model_dictionary[TwoLorentzianModel.__name__] = TwoLorentzianModel 
    569640        self.shape_indep_list.append(TwoLorentzianModel) 
    570641        self.model_name_list.append(TwoLorentzianModel.__name__) 
    571642         
    572643        from sans.models.TwoPowerLawModel import TwoPowerLawModel 
     644        self.model_dictionary[TwoPowerLawModel.__name__] = TwoPowerLawModel 
    573645        self.shape_indep_list.append(TwoPowerLawModel) 
    574646        self.model_name_list.append(TwoPowerLawModel.__name__) 
    575647         
    576648        from sans.models.UnifiedPowerRgModel import UnifiedPowerRgModel 
     649        self.model_dictionary[UnifiedPowerRgModel.__name__] = UnifiedPowerRgModel 
    577650        self.shape_indep_list.append(UnifiedPowerRgModel) 
    578651        self.multi_func_list.append(UnifiedPowerRgModel) 
    579652 
    580653        from sans.models.LineModel import LineModel 
     654        self.model_dictionary[LineModel.__name__] = LineModel 
    581655        self.shape_indep_list.append(LineModel) 
    582656        self.model_name_list.append(LineModel.__name__) 
    583657         
    584658        from sans.models.ReflectivityModel import ReflectivityModel 
     659        self.model_dictionary[ReflectivityModel.__name__] = ReflectivityModel 
    585660        self.shape_indep_list.append(ReflectivityModel) 
    586661        self.multi_func_list.append(ReflectivityModel) 
    587662         
    588663        from sans.models.ReflectivityIIModel import ReflectivityIIModel 
     664        self.model_dictionary[ReflectivityIIModel.__name__] = ReflectivityIIModel 
    589665        self.shape_indep_list.append(ReflectivityIIModel) 
    590666        self.multi_func_list.append(ReflectivityIIModel) 
    591667         
    592668        from sans.models.GelFitModel import GelFitModel 
     669        self.model_dictionary[GelFitModel.__name__] = GelFitModel 
    593670        self.shape_indep_list.append(GelFitModel) 
    594671        self.model_name_list.append(GelFitModel.__name__) 
    595672 
     673        #from sans.models.FractalO_Z import FractalO_Z 
     674        #self.model_dictionary[FractalO_Z.__name__] = FractalO_Z 
     675        #self.shape_indep_list.append(FractalO_Z) 
     676        #self.model_name_list.append(FractalO_Z.__name__) 
     677     
    596678        #Looking for plugins 
    597679        self.stored_plugins = self.findModels() 
     
    792874        if int(evt.GetId()) in self.form_factor_dict.keys(): 
    793875            from sans.models.MultiplicationModel import MultiplicationModel 
     876            self.model_dictionary[MultiplicationModel.__name__] = MultiplicationModel 
    794877            model1, model2 = self.form_factor_dict[int(evt.GetId())] 
    795878            model = MultiplicationModel(model1, model2) 
     
    836919        """ 
    837920        return self.model_name_list 
     921 
     922    def get_model_dictionary(self): 
     923        """ 
     924        return dictionary linking model names to objects 
     925        """ 
     926        return self.model_dictionary 
    838927   
    839928         
     
    873962    def get_model_name_list(self): 
    874963        return self.__modelmanager.get_model_name_list() 
     964 
     965    def get_model_dictionary(self): 
     966        return self.__modelmanager.get_model_dictionary() 
  • pr_inversion/test/test_output.txt

    r3fdb68a rdf7a7e3  
    33#alpha=0.0007 
    44#chi2=836.797 
    5 #elapsed=0.000852108 
     5#elapsed=0.000825167 
    66#qmin=None 
    77#qmax=None 
  • sansguiframe/src/sans/guiframe/__init__.py

    r8c347a6 rdf7a7e3  
    7070    for f in findall(path): 
    7171        data_files.append(('media/guiframe_media', [f])) 
     72    path = get_media_path(media="catdata") 
     73    for f in findall(path): 
     74        data_files.append(('.', [f])) 
     75 
    7276    return data_files 
  • sansguiframe/src/sans/guiframe/events.py

    r643a82a rdf7a7e3  
    3030##color event 
    3131(NewColorEvent, EVT_NEW_COLOR) = wx.lib.newevent.NewEvent() 
     32##change category event 
     33(ChangeCategoryEvent, EVT_CATEGORY) = wx.lib.newevent.NewEvent() 
  • sansguiframe/src/sans/guiframe/gui_manager.py

    rc329f4d rdf7a7e3  
    2525import urllib2 
    2626 
     27from sans.guiframe.events import EVT_CATEGORY 
    2728from sans.guiframe.events import EVT_STATUS 
    2829from sans.guiframe.events import EVT_APPEND_BOOKMARK 
     
    3940from sans.guiframe.data_processor import GridFrame 
    4041from sans.guiframe.events import EVT_NEW_BATCH 
     42from sans.guiframe.CategoryManager import CategoryManager 
    4143from sans.dataloader.loader import Loader 
    4244 
     
    211213        Initialize the Frame object 
    212214        """ 
    213          
     215 
    214216        wx.Frame.__init__(self, parent=parent, title=title, pos=pos, size=size) 
    215217        # title 
     
    319321        self.Bind(EVT_NEW_BATCH, self.on_batch_selection) 
    320322        self.Bind(EVT_NEW_COLOR, self.on_color_selection) 
     323        self.Bind(EVT_CATEGORY, self.on_change_categories) 
    321324        self.setup_custom_conf() 
    322325         
     
    342345                    pass   
    343346         
     347    def on_change_categories(self, evt): 
     348        # ILL 
     349        fitpanel = None 
     350        for item in self.plugins: 
     351            if hasattr(item, "get_panels"): 
     352                if hasattr(item, "fit_panel"): 
     353                    fitpanel = item.fit_panel 
     354 
     355        if fitpanel != None: 
     356            for i in range(0,fitpanel.GetPageCount()): 
     357                fitpanel.GetPage(i)._populate_listbox() 
     358 
     359 
     360 
    344361    def on_set_batch_result(self, data_outputs, data_inputs=None, 
    345362                             plugin_name=""): 
     
    13851402            wx.EVT_MENU(self, id, self._on_preference_menu) 
    13861403             
     1404        id = wx.NewId() 
     1405        self._view_menu.AppendSeparator() 
     1406        self._view_menu.Append(id, 'Category Manager', 'Edit model categories') 
     1407        wx.EVT_MENU(self, id, self._on_category_manager) 
     1408 
    13871409        self._menubar.Append(self._view_menu, '&View')    
    13881410          
     
    13951417        self.batch_frame.Show(True) 
    13961418         
     1419    def _on_category_manager(self, event): 
     1420        CategoryManager(self, -1, 'Model Category Manager') 
     1421 
    13971422    def _on_preference_menu(self, event):      
    13981423        """ 
  • sansview/sansview.py

    r10b3e1e rdf7a7e3  
    1111import os 
    1212import logging 
     13from shutil import copy 
    1314logging.basicConfig(level=logging.INFO, 
    1415                    format='%(asctime)s %(levelname)s %(message)s', 
     
    6768            fitting_plug = module.Plugin() 
    6869            self.gui.add_perspective(fitting_plug) 
    69         except: 
     70        except Exception as inst: 
     71            logging.error("Fitting problems: " + str(inst)) 
    7072            logging.error("%s: could not find Fitting plug-in module"% APP_NAME)  
    7173            logging.error(sys.exc_value)   
     
    101103            logging.error(sys.exc_value)   
    102104 
     105        # initialize category stuff 
     106        user_file = os.path.join(os.path.expanduser("~"), 
     107                                 'serialized_categories.p') 
     108         
     109        if not os.path.isfile(user_file):  
     110            # either first time starting sansview or the 
     111            # user has deleted their category file 
     112            my_dir = os.path.dirname(os.path.abspath(__file__)) 
     113            default_file = os.path.join(my_dir, '..', 
     114                                        'sansmodels', 
     115                                        'default_categories.p' ) 
     116            copy(default_file, user_file) 
     117 
    103118             
    104119        # Add welcome page 
  • sansview/setup_exe.py

    rc329f4d rdf7a7e3  
    1616import os, sys 
    1717import platform 
     18 
    1819 
    1920if len(sys.argv) == 1: 
     
    328329    bundle_option = 3 
    329330 
     331#initialize category stuff 
     332from sans.guiframe.CategoryInstaller import CategoryInstaller 
     333CategoryInstaller.check_install() 
     334 
     335 
     336 
    330337setup( 
    331338    windows=[target_wx_client], 
  • sansview/setup_mac.py

    re558e0b rdf7a7e3  
    9393EXTENSIONS_LIST = find_extension() 
    9494 
     95#initialize category stuff 
     96from sans.guiframe.CategoryInstaller import CategoryInstaller 
     97CategoryInstaller.check_install() 
     98 
     99 
    95100  
    96101plist = dict(CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=EXTENSIONS_LIST, 
  • setup.py

    rc329f4d rdf7a7e3  
    44""" 
    55import sys 
    6  
    76import os 
    87import platform 
     8import shutil 
    99from setuptools import setup, Extension, find_packages 
    1010from distutils.command.build_ext import build_ext 
     11 
     12 
     13 
    1114 
    1215try: 
     
    113116package_dir["sans.guiframe.local_perspectives"] = os.path.join(guiframe_path,  
    114117                                                        "local_perspectives") 
    115 package_data["sans.guiframe"] = ['images/*', 'media/*'] 
     118package_data["sans.guiframe"] = ['images/*',  
     119                                 'media/*',  
     120                                 'default_categories.p'] 
     121 
    116122packages.extend(["sans.guiframe", "sans.guiframe.local_perspectives"]) 
    117123# build local plugin 
     
    279285                  os.path.join(smear_dir, "smearer_module.cpp")] 
    280286 
    281 # compile list of installed models 
    282 installed_model_file = open(os.path.join("sansmodels", 
    283                                          "installed_models.txt"),'w') 
    284 not_models = ['BaseComponent', 
    285               'sans_extension', 
    286               'MulComponent', 
    287               'svn', 
    288               'media', 
    289               'SubComponent', 
    290               '__init__', 
    291               'dispersion_models', 
    292               'AddComponent', 
    293               'qsmearing'] 
    294  
    295 for model in os.listdir(model_dir): 
    296     if not model.rstrip(".py") in not_models: 
    297         installed_model_file.write(model.rstrip(".py") + '\n') 
    298  
    299 installed_model_file.close() 
     287 
     288 
     289 
     290 
    300291 
    301292if os.name=='nt': 
     
    324315         
    325316# SasView 
     317 
    326318package_dir["sans.sansview"] = "sansview" 
    327319package_data['sans.sansview'] = ['images/*', 'media/*', 'test/*'] 
     
    338330    required.extend(['pil']) 
    339331 
    340  
     332# sys.path.append(os.path.join('sansguiframe', 
     333#                              'src', 
     334#                              'sans', 
     335#                              'guiframe')) 
     336 
     337#install category stuff 
     338cat_install_path = os.path.join('sansguiframe', 'src', 
     339                                'sans','guiframe','CategoryInstaller.py') 
     340shutil.copy(cat_install_path, os.getcwd()) 
     341 
     342from CategoryInstaller import CategoryInstaller 
     343CategoryInstaller.check_install(defaultfile = \ 
     344                                    os.path.join('sansguiframe', 
     345                                                 'src', 
     346                                                 'sans', 
     347                                                 'guiframe', 
     348                                                 'default_categories.p'), 
     349                                modelsdir = \ 
     350                                    os.path.join('fittingview', 
     351                                                 'src', 
     352                                                 'sans', 
     353                                                 'perspectives', 
     354                                                 'fitting'),  
     355                                installed_models_dir = \ 
     356                                    os.path.join('sansdataloader', 
     357                                                 'src', 
     358                                                 'sans', 
     359                                                 'dataloader', 
     360                                                 'readers') ) 
    341361 
    342362    
Note: See TracChangeset for help on using the changeset viewer.