Changeset ddff053 in sasview for guitools


Ignore:
Timestamp:
May 1, 2008 6:43:06 PM (16 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
90640f2
Parents:
bbec827
Message:

making change on fitdialog ..still some bugs

Location:
guitools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • guitools/PlotPanel.py

    rbbec827 rddff053  
    108108        #self.fit_result = Data1D(x=[], y=[],dx=None, dy=None) 
    109109        self.fit_result.name = "Fit" 
    110         self.fit_result.ID = "isFit" 
    111  
     110        self.xmin=0.0 
     111        self.xmax=0.0 
     112        self.xminView=0.0 
     113        self.xmaxView=0.0 
    112114    def onWheel(self, event): 
    113115        """ 
     
    115117        """ 
    116118        ax = event.inaxes 
    117          
    118119        step = event.step 
    119120 
     
    175176            first_item = list.keys()[0] 
    176177            dlg = LinearFit( None, first_item, self.onFitDisplay,self.returnTrans, -1, 'Fitting') 
     178            if (self.xmin !=0.0 )and ( self.xmax !=0.0)\ 
     179                and(self.xminView !=0.0 )and ( self.xmaxView !=0.0): 
     180                dlg.setFitRange(self.xminView,self.xmaxView,self.xmin,self.xmax) 
    177181            dlg.ShowModal()  
    178182 
     
    524528        self.subplot.figure.canvas.draw_idle() 
    525529         
    526     def onFitDisplay(self, tempx,tempy,xmin,xmax): 
     530    def onFitDisplay(self, tempx,tempy,xminView,xmaxView,xmin,xmax): 
    527531        """ 
    528532            Add a new plottable into the graph .In this case this plottable will be used  
     
    535539        list = self.graph.returnPlottable() 
    536540        for item in list: 
    537             item.onFitRange(xmin,xmax) 
     541            item.onFitRange(xminView,xmaxView) 
     542        self.xminView=xminView 
     543        self.xmaxView=xmaxView 
     544        self.xmin= xmin 
     545        self.xmax= xmax 
    538546        # Create new data plottable with result 
    539547        self.fit_result.x =[]  
  • guitools/fitDialog.py

    rbbec827 rddff053  
    1313    #def __init__(self, parent, id, title): 
    1414    def __init__(self, parent, plottable, push_data,transform, id, title): 
    15         wx.Dialog.__init__(self, parent, id, title, size=(450, 300)) 
     15        wx.Dialog.__init__(self, parent, id, title, size=(450, 500)) 
    1616        """ 
    1717            for the fit window 
     
    2323        #dialog self plottable 
    2424        self.plottable = plottable 
    25          
     25        # Receive transformations of x and y 
     26        self.xtrans,self.ytrans= self.transform() 
    2627        #Dialog interface 
    2728        panel = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)    
     
    3839        self.FXmin = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 
    3940        self.FXmax = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 
     41        self.FXminX = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 
     42        self.FXmaxX = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 
    4043        self.PXmin = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 
    4144        self.PXmax = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 
     
    8992        sizer.Add(self.PXmax, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    9093        iy += 1 
     94        ix = 1 
     95        sizer.Add(wx.StaticText(panel, -1,"x transofrmation is: "+self.xtrans ),(iy, ix),(1,1),\ 
     96                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     97        iy += 1 
    9198        ix = 0 
    9299        sizer.Add(wx.StaticText(panel, -1, 'Fit Range'),(iy, ix),(1,1),\ 
     
    97104        ix += 2 
    98105        sizer.Add(self.FXmax, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     106         
     107        #iy += 1 
     108        #ix = 1 
     109        #sizer.Add(wx.StaticText(panel, -1,"x is: "),(iy, ix),(1,1),\ 
     110        #           wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     111        iy += 1 
     112        ix = 0 
     113        sizer.Add(wx.StaticText(panel, -1, 'Fit Range of x'),(iy, ix),(1,1),\ 
     114                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     115        ix += 1 
     116        sizer.Add(self.FXminX, (iy, ix),(1,1),\ 
     117                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     118        ix += 2 
     119        sizer.Add(self.FXmaxX, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    99120        iy += 1 
    100121        ix = 1 
     
    131152            self.FXmin.SetLabel(str(self.mini)) 
    132153            self.FXmax.SetLabel(str(self.maxi)) 
    133              
     154            self.FXminX.SetLabel(str(self.mini)) 
     155            self.FXmaxX.SetLabel(str(self.maxi)) 
     156            self.FXmin.Disable() 
     157            self.FXmax.Disable() 
    134158            self.PXmin.SetValue(str(self.mini)) 
    135159            self.PXmax.SetValue(str(self.maxi)) 
    136160            self.PXmin.Disable() 
    137161            self.PXmax.Disable() 
    138      
     162         
    139163        # new data for the fit  
    140164        #self.file_data1 = Theory1D(x=[], y=[], dy=None) 
     
    153177        tempy=[] 
    154178        tempdy = [] 
    155          
     179        
    156180        #store the values of View in x,y, dx,dy 
    157181        x,y,dx,dy=self.plottable.returnValuesOfView() 
     
    162186        # makes transformation for y as a line to fit 
    163187        if x != []:  
     188             
     189                 
    164190            if(self.checkFitValues(self.FXmin) == True): 
    165191                #Check if the field of Fit Dialog contain values and use the x max and min of the user 
    166                 xmin,xmax = self._checkVal(self.FXmin.GetValue(),self.FXmax.GetValue()) 
     192                xmin,xmax = self._checkVal(self.FXminX.GetValue(),self.FXmaxX.GetValue()) 
     193                 
    167194                xminView=self.floatTransform(xmin) 
    168195                xmaxView=self.floatTransform(xmax) 
    169                  
     196                self.FXmin.SetValue(str(xminView)) 
     197                self.FXmax.SetValue(str(xmaxView)) 
     198                self.FXmin.Disable() 
     199                self.FXmax.Disable() 
    170200                # Store the transformed values of view x, y,dy in variables  before the fit 
    171201                if  self.ytrans.lower() == "log10(y)": 
     
    197227                        
    198228                #Find the fitting parameters 
     229                 
    199230                if (self.xtrans.lower() == "log10(x)"): 
    200231                    chisqr, out, cov = fittings.sansfit(self.model, [self.cstA, self.cstB], 
     
    251282                else:  
    252283                    tempy.append(y_model) 
    253                
    254                 # Create new data plottable with result 
    255                 #self.file_data1.x =[]  
    256                 #self.file_data1.y =[]  
    257                 #self.file_data1.x =tempx   
    258                 #self.file_data1.y =tempy      
    259                 #self.file_data1.dx=None 
    260                 #self.file_data1.dy=None 
    261                 #Load the view with the new values 
    262                 #self.file_data1.reset_view() 
    263                  
    264                 #Send the data to display to the PlotPanel 
    265                 #self.push_data(self.file_data1,xminView,xmaxView) 
    266                 self.push_data(tempx,tempy,xminView,xmaxView) 
     284                
     285                self.push_data(tempx,tempy,xminView,xmaxView,xmin,xmax) 
    267286                 
    268287                # Display the fitting value on the Fit Dialog 
     
    289308        if float(usermin) < float(usermax): 
    290309            if float(usermin) >= float(self.mini) and float(usermin) < float(self.maxi): 
    291                 self.FXmin.SetValue(str(usermin)) 
     310                self.FXminX.SetValue(str(usermin)) 
    292311            else: 
    293                 self.FXmin.SetValue(str(self.mini)) 
     312                self.FXminX.SetValue(str(self.mini)) 
    294313                 
    295314            if float(usermax) > float(self.mini) and float(usermax) <= float(self.maxi): 
    296                 self.FXmax.SetLabel(str(usermax)) 
     315                self.FXmaxX.SetLabel(str(usermax)) 
    297316            else: 
    298                 self.FXmax.SetLabel(str(self.maxi)) 
    299                  
    300             mini =float(self.FXmin.GetValue()) 
    301             maxi =float(self.FXmax.GetValue()) 
     317                self.FXmaxX.SetLabel(str(self.maxi)) 
     318                 
     319            mini =float(self.FXminX.GetValue()) 
     320            maxi =float(self.FXmaxX.GetValue()) 
    302321             
    303322            return mini, maxi 
     
    337356        return flag 
    338357        
    339                  
     358    def setFitRange(self,xmin,xmax,Reelxmin,Reelxmax): 
     359        
     360        self.FXmin.SetValue(str(math.log10(xmin))) 
     361        self.FXmax.SetValue(str(math.log10(xmax))) 
     362         
     363        self.FXmin.SetValue(str(xmin)) 
     364        self.FXmax.SetValue(str(xmax)) 
     365        self.FXminX.SetValue(str(Reelxmin)) 
     366        self.FXmaxX.SetValue(str(Reelxmax)) 
     367         
    340368    
    341369if __name__ == "__main__":  
  • guitools/plottables.py

    rbbec827 rddff053  
    447447        dx = None 
    448448        dy = None 
    449         ID = "" 
     449 
    450450         
    451451        def __init__(self, x=None, y=None, dx=None, dy=None): 
     
    641641        """ 
    642642        self.name = "data" 
    643         self.ID= "" 
    644643        self.x = x 
    645644        self.y = y 
     
    680679        self.y = y 
    681680        self.dy = dy 
    682         self.ID= "" 
    683681        self.xaxis( 'q', 'A') 
    684682        self.yaxis( 'intensity', 'cm') 
Note: See TracChangeset for help on using the changeset viewer.