Changeset 3dc83be in sasview


Ignore:
Timestamp:
Jan 18, 2009 12:20:09 PM (16 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:
a2c38de
Parents:
3f1af74
Message:

Fix model change bug. Models can now be selected from the top menu or the model page menu with the same result. The 2D plot, if enabled, will also be correctly updated.

Location:
sansview/perspectives/fitting
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/fitpanel.py

    r3f1af74 r3dc83be  
    115115        panel.set_manager(self.manager) 
    116116        panel.set_owner(self.event_owner) 
    117         self.nb.AddPage(page=panel,text=page_title,select=True) 
     117        #self.nb.AddPage(page=panel,text=page_title,select=True) 
     118        self.nb.AddPage(page=panel,text="Model",select=True) 
    118119        panel.populate_box( self.model_list_box) 
    119120        self.draw_model_name=page_title 
     
    125126        self.model_page.set_range(qmin, qmax, npts) 
    126127         
    127          
    128     def add_model_page(self,model,description,page_title, qmin=0, qmax=0.1, npts=50): 
     128        # We just created a model page, we are ready to plot the model 
     129        self.manager.draw_model(model, model.name) 
     130         
     131         
     132    def add_model_page(self,model,description,page_title, qmin=0, qmax=0.1, npts=50, topmenu=False): 
    129133        """ 
    130134            Add a model page only one  to display any model selected from the menu or the page combo box. 
     
    141145        if  self.draw_model_name ==None: 
    142146            self._help_add_model_page(model,description,page_title, qmin=qmin, qmax=qmax, npts=npts) 
    143         else: 
    144             if  self.draw_model_name !=page_title:  
    145                 self.onClose(self.model_page, self.model_page_number) 
    146                 self._help_add_model_page(model,description,page_title, qmin=qmin, qmax=qmax, npts=npts) 
    147        
     147        elif topmenu==True: 
     148            self.model_page.select_model(model) 
    148149            
    149150    def get_notebook(self): 
  • sansview/perspectives/fitting/fitting.py

    rcfc68540 r3dc83be  
    642642            name = evt.model.name 
    643643        model=evt.model() 
    644         #name="Model View" 
    645         #print "mon menu",model.name 
    646644        description=model.description 
    647         #self.fit_panel.add_model_page(model,description,name)   
    648      
    649         self.draw_model(model=model,name=name) 
     645         
     646        # Create a model page. If a new page is created, the model 
     647        # will be plotted automatically. If a page already exists, 
     648        # the content will be updated and the plot refreshed 
     649        self.fit_panel.add_model_page(model,description,name,topmenu=True) 
    650650         
    651651    def draw_model(self,model,name ,description=None,enable1D=True, enable2D=False, 
     
    654654             draw model with default data value 
    655655        """ 
    656          
    657         self.fit_panel.add_model_page(model=model,description=model.description,page_title=name, 
    658                                       qmin=qmin, qmax=qmax, npts=qstep)  
    659656        self._draw_model2D(model=model, 
    660657                           description=model.description, 
     
    702699                    new_plot.id ="Model" 
    703700                    new_plot.group_id ="Model" 
     701                     
     702                    # Pass the reset flag to let the plotting event handler 
     703                    # know that we are replacing the whole plot 
    704704                    wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, 
    705                                      title="Analytical model 1D " )) 
     705                                     title="Analytical model 1D ", reset=True )) 
    706706                     
    707707                except: 
     
    742742        print "model draw comptele xmax",theory.xmax 
    743743        wx.PostEvent(self.parent, NewPlotEvent(plot=theory, 
    744                          title="Analytical model 2D %s" %str(model.name))) 
     744                         title="Analytical model 2D %s" %str(model.name), reset=True)) 
    745745          
    746746         
  • sansview/perspectives/fitting/modelpage.py

    rcfc68540 r3dc83be  
    229229        return 0 
    230230     
    231    
    232     
     231    def select_model(self, model): 
     232        """ 
     233            Select a new model 
     234            @param model: model object  
     235        """ 
     236        self.model= model 
     237        self.set_panel(model) 
     238        self._draw_model() 
     239         
     240        # Select the model from the combo box 
     241        items = self.modelbox.GetItems() 
     242        for i in range(len(items)): 
     243            if items[i]==model.__class__.__name__: 
     244                self.modelbox.SetSelection(i) 
     245         
    233246    def _on_select_model(self,event): 
    234247        """ 
     
    245258                self.model= model 
    246259                self.set_panel(model) 
    247                 print "name in model page", name,event.GetString() 
    248260                self.name= name 
    249261                #self.manager.draw_model(model, name) 
Note: See TracChangeset for help on using the changeset viewer.