- Timestamp:
- Sep 11, 2008 5:13:32 PM (16 years ago)
- 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:
- 388309d
- Parents:
- b30f001
- Location:
- sansview
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/docs/note2.txt
rb30f001 r49b7efa 1 1 1- the combox must contains class.__name__ or model name? 2 2- model plugin need dataplugin 's modules 3 3- sort combox list 4 4- use 2 combo box instead? -
sansview/perspectives/fitting/fitpage.py
r1b07935d r49b7efa 224 224 id=0 225 225 self.model_list_box=dict 226 for item in self.model_list_box.itervalues(): 226 list_name=[] 227 for item in self.model_list_box.itervalues(): 227 228 if hasattr(item, "name"): 228 229 name = item.name 229 230 else: 230 231 name = item.__name__ 231 232 list_name.append(name) 233 list_name.sort() 234 for name in list_name: 232 235 self.modelbox.Insert(name,int(id)) 233 236 id+=1 234 235 wx.EVT_COMBOBOX(self.modelbox,-1, self._on_select_model) 237 wx.EVT_COMBOBOX(self.modelbox,-1, self._on_select_model) 236 238 return 0 237 239 … … 254 256 except: 255 257 raise #ValueError,"model.name is not equal to model class name" 256 257 258 258 259 -
sansview/perspectives/fitting/fitpanel.py
r1c66bc5 r49b7efa 92 92 93 93 94 def add_model_page(self,model, page_title):94 def add_model_page(self,model,description,page_title): 95 95 """ 96 96 Add a model page only one to display any model selected from the menu or the page combo box. … … 101 101 if page_title !=self.draw_model_name or self.draw_model_name ==None: 102 102 from modelpage import ModelPage 103 panel = ModelPage(self.nb,model, -1)103 panel = ModelPage(self.nb,model,description, -1) 104 104 panel.set_manager(self.manager) 105 105 panel.set_owner(self.event_owner) … … 111 111 if self.nb.GetPageText(i)==self.page_name: 112 112 page=self.nb.GetPage(i) 113 page.set_page(model )113 page.set_page(model,description) 114 114 break 115 115 -
sansview/perspectives/fitting/fitting.py
r060b857 r49b7efa 49 49 self.standalone=True 50 50 ## Fit engine 51 self._fit_engine = ' park'51 self._fit_engine = 'scipy' 52 52 # Log startup 53 53 logging.info("Fitting plug-in started") … … 208 208 209 209 """ 210 211 210 try: 212 211 for page, value in self.page_finder.iteritems(): … … 547 546 #name = evt.model.__class__.__name__ 548 547 name="Model View" 549 self.fit_panel.add_model_page(evt.model,name) 550 self.draw_model(evt.model) 548 model=evt.modelinfo.model() 549 description=evt.modelinfo.description 550 self.fit_panel.add_model_page(model,description,name) 551 self.draw_model(model) 551 552 552 553 def draw_model(self,model): -
sansview/perspectives/fitting/modelpage.py
r060b857 r49b7efa 39 39 40 40 41 def __init__(self, parent,model, *args, **kwargs):41 def __init__(self, parent,model,description, *args, **kwargs): 42 42 wx.Panel.__init__(self, parent, *args, **kwargs) 43 43 """ … … 50 50 self.vbox = wx.BoxSizer(wx.VERTICAL) 51 51 self.sizer3 = wx.GridBagSizer(5,5) 52 self.sizer1 = wx.GridBagSizer(5,5) 52 53 self.sizer2 = wx.GridBagSizer(5,5) 53 54 self.modelbox = wx.ComboBox(self, -1) 54 55 id = wx.NewId() 55 56 self.vbox.Add(self.sizer3) 57 self.vbox.Add(self.sizer1) 56 58 self.vbox.Add(self.sizer2) 57 59 ix = 0 58 60 iy = 1 61 59 62 self.sizer3.Add(wx.StaticText(self,-1,'Model'),(iy,ix),(1,1)\ 60 63 , wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) … … 67 70 # model on which the fit would be performed 68 71 self.model=model 69 self.set_panel(model) 72 self.description=description 73 self.set_panel(model,description) 70 74 # preview selected model name 71 75 self.prevmodel_name=model.__class__.__name__ … … 117 121 return 0 118 122 119 def set_page(self, model ):123 def set_page(self, model,description): 120 124 print " modelpage: set_page was called",model 121 125 self.model=model 126 self.description=description 122 127 if hasattr(self.model, "name"): 123 128 name = self.model.name … … 125 130 name = self.model.__class__.__name__ 126 131 self.modelbox.SetValue(name) 127 self.set_panel(self.model )132 self.set_panel(self.model,description) 128 133 self.manager.draw_model(self.model) 129 134 def _on_select_model(self,event): … … 178 183 179 184 180 def set_panel(self,model ):185 def set_panel(self,model,description=None): 181 186 """ 182 187 Build the panel from the model content … … 185 190 186 191 self.sizer2.Clear(True) 192 self.sizer1.Clear(True) 187 193 self.parameters = [] 188 194 self.param_toFit=[] … … 192 198 iy = 1 193 199 ix = 0 194 200 self.cb0 = wx.StaticText(self, -1,'Model Description:') 201 self.sizer1.Add(self.cb0,(iy, ix),(1,1),\ 202 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 203 ix += 1 204 self.cb01 = wx.StaticText(self, -1,str(description)) 205 self.sizer1.Add(self.cb01,(iy, ix),(1,1),\ 206 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 207 ix = 0 208 iy = 1 195 209 self.cb1 = wx.StaticText(self, -1,'Parameters') 196 210 self.sizer2.Add(self.cb1,(iy, ix),(1,1),\ -
sansview/perspectives/fitting/models.py
rb30f001 r49b7efa 5 5 6 6 (ModelEvent, EVT_MODEL) = wx.lib.newevent.NewEvent() 7 class ModelInfo(object): 8 def __init__(self,model,description=None): 9 self.model=model 10 self.description=description 11 def set_description(self, descrition): 12 self.description =str(description) 13 def get_description(self): 14 return self.description 7 15 def log(message): 8 16 print message … … 52 60 ## Dictionary of models 53 61 model_list = {} 62 indep_model_list = {} 54 63 model_list_box = {} 55 64 custom_models={} 56 65 plugins=[] 66 indep_model=[] 57 67 ## Event owner 58 68 event_owner = None … … 68 78 self.model_list = {} 69 79 self.model_list_box = {} 80 model_info="shape-based models" 70 81 from sans.models.CylinderModel import CylinderModel 71 self.model_list[str(wx.NewId())] = CylinderModel82 self.model_list[str(wx.NewId())] = ModelInfo(CylinderModel , model_info) 72 83 73 84 from sans.models.SphereModel import SphereModel 74 self.model_list[str(wx.NewId())] = SphereModel85 self.model_list[str(wx.NewId())] = ModelInfo(SphereModel , model_info) 75 86 76 87 from sans.guitools.LineModel import LineModel 77 self.model_list[str(wx.NewId())] = LineModel 78 self.plugins =findModels() 88 self.model_list[str(wx.NewId())] = ModelInfo(LineModel , model_info) 89 model_info="shape-independent models" 90 from sans.models.Lorentzian import Lorentzian 91 self.indep_model.append( ModelInfo(Lorentzian , model_info) ) 79 92 80 print "models: plugings",self.plugins 93 #Looking for plugins 94 self.plugins = findModels() 95 81 96 return 0 82 97 … … 91 106 @return: the next free event ID following the new menu events 92 107 """ 93 94 108 self._getModelList() 95 109 self.event_owner = event_owner 110 96 111 shape_submenu= wx.Menu() 97 112 indep_submenu = wx.Menu() 98 113 added_models = wx.Menu() 114 99 115 for id_str,value in self.model_list.iteritems(): 100 116 item = self.model_list[id_str] 101 102 name = item.__name__ 117 name = item.model.__name__ 103 118 if hasattr(item, "name"): 104 name = item.name 105 106 self.model_list_box[name] =value 107 108 119 name = item.model.name 120 self.model_list_box[name] =value.model 109 121 shape_submenu.Append(int(id_str), name, name) 110 122 wx.EVT_MENU(event_owner, int(id_str), self._on_model) 111 123 modelmenu.AppendMenu(wx.NewId(), "Shapes...", shape_submenu, "List of shape-based models") 112 modelmenu.AppendMenu(wx.NewId(), "Shape-independent...", indep_submenu, "List of shape-independent models")113 124 114 125 id = wx.NewId() 126 if len(self.indep_model_list) == 0: 127 print "models: self.indep_model",self.indep_model 128 for item in self.indep_model: 129 if item not in self.indep_model_list.values(): 130 self.indep_model_list[str(id)] = item 131 self.model_list[str(id)]=item 132 if hasattr(item, "name"): 133 name = item.model.name 134 else: 135 name = item.model.__name__ 136 indep_submenu.Append(id,name, name) 137 self.model_list_box[name] =item.model 138 wx.EVT_MENU(event_owner, int(id), self._on_model) 139 id = wx.NewId() 140 modelmenu.AppendMenu(wx.NewId(), "Shape-independent...", indep_submenu, "List of shape-independent models") 141 model_info="additional models" 142 id = wx.NewId() 115 143 if len(self.custom_models) == 0: 116 print self.plugins117 144 for item in self.plugins: 118 if item not in self.custom_models. keys():145 if item not in self.custom_models.values(): 119 146 self.custom_models[str(id)] = item 120 self.model_list[str(id)]=item 121 added_models.Append(id, item.name, item.name) 147 148 self.model_list[str(id)]=ModelInfo(item,model_info) 149 if hasattr(item, "name"): 150 name = item.name 151 else: 152 name = item.__name__ 153 added_models.Append(id, name, name) 154 self.model_list_box[name] =item 122 155 wx.EVT_MENU(event_owner, int(id), self._on_model) 123 156 id = wx.NewId() 124 125 126 157 modelmenu.AppendMenu(wx.NewId(),"Added models...", added_models, "List of additional models") 127 128 158 129 159 … … 142 172 #evt = ModelEvent(model=self.model_list[str(evt.GetId())]()) 143 173 144 model = self.model_list[str(evt.GetId())] ()145 evt = ModelEvent(model =model)174 model = self.model_list[str(evt.GetId())] 175 evt = ModelEvent(modelinfo=model) 146 176 wx.PostEvent(self.event_owner, evt) 147 177
Note: See TracChangeset
for help on using the changeset viewer.