source: sasview/guiframe/local_perspectives/plotting/SectorSlicer.py @ ec1584e

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since ec1584e was 55a0dc1, checked in by Gervaise Alina <gervyh@…>, 14 years ago

remove reference to guicomm in guiframe

  • Property mode set to 100644
File size: 22.1 KB
RevLine 
[ef0c170]1
2import math
[0d9dae8]3import wx
[32c0841]4#from copy import deepcopy
[0d9dae8]5from BaseInteractor import _BaseInteractor
[55a0dc1]6from sans.guiframe.events import NewPlotEvent
7from sans.guiframe.events import StatusEvent
8from sans.guiframe.events import SlicerParameterEvent
9from sans.guiframe.events import EVT_SLICER_PARS
[4ac8556]10from sans.guiframe.dataFitting import Data1D
[ef0c170]11
[32c0841]12
[ef0c170]13class SectorInteractor(_BaseInteractor):
14    """
[d955bf19]15    Draw a sector slicer.Allow to performQ averaging on data 2D
[ef0c170]16    """
[32c0841]17    def __init__(self, base, axes, color='black', zorder=3):
[ef0c170]18       
19        _BaseInteractor.__init__(self, base, axes, color=color)
[6c0568b]20        ## Class initialization
[ef0c170]21        self.markers = []
[6c0568b]22        self.axes = axes   
23        ## connect the plot to event
[ef0c170]24        self.connect = self.base.connect
25       
[6c0568b]26        ## compute qmax limit to reset the graph     
[32c0841]27        x = math.pow(max(self.base.data2D.xmax, 
28                         math.fabs(self.base.data2D.xmin)), 2)
29        y = math.pow(max(self.base.data2D.ymax, 
30                         math.fabs(self.base.data2D.ymin)), 2)
31        self.qmax = math.sqrt(x + y)
[ef0c170]32        ## Number of points on the plot
[b783024]33        self.nbins = 20
[6c0568b]34        ## Angle of the middle line
[32c0841]35        self.theta2 = math.pi/3
[6c0568b]36        ## Absolute value of the Angle between the middle line and any side line
[32c0841]37        self.phi = math.pi/12
[6c0568b]38        ## Middle line
[32c0841]39        self.main_line = LineInteractor(self, self.base.subplot, color='blue', 
40                                        zorder=zorder, r=self.qmax,
[ef0c170]41                                           theta= self.theta2)
[2dda74ac]42        self.main_line.qmax = self.qmax
[6c0568b]43        ## Right Side line
[32c0841]44        self.right_line = SideInteractor(self, self.base.subplot, color='black',
45                                          zorder=zorder, r=self.qmax,
46                                          phi=-1*self.phi, theta2=self.theta2)
[2dda74ac]47        self.right_line.qmax = self.qmax
[6c0568b]48        ## Left Side line
[32c0841]49        self.left_line = SideInteractor(self, self.base.subplot, color='black',
50                                        zorder=zorder, r=self.qmax,
51                                           phi=self.phi, theta2=self.theta2)
[2dda74ac]52        self.left_line.qmax = self.qmax
[6c0568b]53        ## draw the sector               
[ef0c170]54        self.update()
55        self._post_data()
[6c0568b]56        ## Bind to slice parameter events
[1ce365f8]57        self.base.Bind(EVT_SLICER_PARS, self._onEVT_SLICER_PARS)
[ef0c170]58
59    def _onEVT_SLICER_PARS(self, event):
[6c0568b]60        """
[d955bf19]61        receive an event containing parameters values to reset the slicer
62       
63        :param event: event of type SlicerParameterEvent with params as
64        attribute
65       
[6c0568b]66        """
[32c0841]67        wx.PostEvent(self.base.parent,
68                     StatusEvent(status="SectorSlicer._onEVT_SLICER_PARS"))
[ef0c170]69        event.Skip()
70        if event.type == self.__class__.__name__:
71            self.set_params(event.params)
72            self.base.update()
[d955bf19]73           
[ef0c170]74    def set_layer(self, n):
[6c0568b]75        """
[d955bf19]76         Allow adding plot to the same panel
77         
78        :param n: the number of layer
79       
[6c0568b]80        """
[ef0c170]81        self.layernum = n
82        self.update()
83       
84    def clear(self):
[6c0568b]85        """
[d955bf19]86        Clear the slicer and all connected events related to this slicer
[6c0568b]87        """
[ef0c170]88        self.clear_markers()
89        self.main_line.clear()
90        self.left_line.clear()
91        self.right_line.clear()
[18eba35]92        self.base.connect.clearall()
[d468daa]93        self.base.Unbind(EVT_SLICER_PARS)
[ef0c170]94       
95    def update(self):
96        """
[d955bf19]97        Respond to changes in the model by recalculating the profiles and
98        resetting the widgets.
[ef0c170]99        """
[6c0568b]100        # Update locations 
[32c0841]101        ## Check if the middle line was dragged and
102        #update the picture accordingly     
[ef0c170]103        if self.main_line.has_move:
104            self.main_line.update()
[32c0841]105            self.right_line.update(delta=-self.left_line.phi/2,
106                                    mline=self.main_line.theta)
107            self.left_line.update(delta=self.left_line.phi/2,
108                                   mline=self.main_line.theta)
[6c0568b]109        ## Check if the left side has moved and update the slicer accordingly 
[ef0c170]110        if self.left_line.has_move:
111            self.main_line.update()
[32c0841]112            self.left_line.update(phi=None, delta=None, mline=self.main_line,
113                                  side=True, left=True)
114            self.right_line.update(phi=self.left_line.phi, delta=None,
115                                     mline=self.main_line, side=True,
116                                     left=False, right=True)
117        ## Check if the right side line has moved and
118        #update the slicer accordingly
[ef0c170]119        if self.right_line.has_move:
120            self.main_line.update()
[32c0841]121            self.right_line.update(phi=None, delta=None, mline=self.main_line,
122                                   side=True, left=False, right=True)
123            self.left_line.update(phi=self.right_line.phi, delta=None,
124                                    mline=self.main_line, side=True, left=False)
[d955bf19]125           
[ef0c170]126    def save(self, ev):
127        """
128        Remember the roughness for this layer and the next so that we
129        can restore on Esc.
130        """
131        self.base.freeze_axes()
[6c0568b]132        self.main_line.save(ev)
133        self.right_line.save(ev)
134        self.left_line.save(ev)
[ef0c170]135
136    def _post_data(self, nbins=None):
[6c0568b]137        """
[d955bf19]138        compute sector averaging of data2D into data1D
139       
140        :param nbins: the number of point to plot for the average 1D data
[6c0568b]141        """
142        ## get the data2D to average
[ef0c170]143        data = self.base.data2D
144        # If we have no data, just return
145        if data == None:
146            return
[6c0568b]147        ## Averaging
[ef0c170]148        from DataLoader.manipulations import SectorQ
[6c0568b]149        radius = self.qmax
150        phimin =  -self.left_line.phi + self.main_line.theta
151        phimax = self.left_line.phi + self.main_line.theta
[32c0841]152        if nbins == None:
[1ce365f8]153            nbins = 20
[32c0841]154        sect = SectorQ(r_min=0.0, r_max=radius,
155                        phi_min=phimin + math.pi,
156                        phi_max=phimax + math.pi, nbins=nbins)
[6c0568b]157     
[ef0c170]158        sector = sect(self.base.data2D)
[6c0568b]159        ##Create 1D data resulting from average
[4ac8556]160       
[32c0841]161        if hasattr(sector, "dxl"):
162            dxl = sector.dxl
[ef0c170]163        else:
[32c0841]164            dxl = None
165        if hasattr(sector, "dxw"):
166            dxw = sector.dxw
[ef0c170]167        else:
[32c0841]168            dxw = None
169        new_plot = Data1D(x=sector.x, y=sector.y, dy=sector.dy)
[4ac8556]170        new_plot.dxl = dxl
171        new_plot.dxw = dxw
[32c0841]172        new_plot.name = "SectorQ" + "(" + self.base.data2D.name + ")"
173        new_plot.source = self.base.data2D.source
[8b30e62]174        #new_plot.info=self.base.data2D.info
[ef0c170]175        new_plot.interactive = True
[32c0841]176        new_plot.detector = self.base.data2D.detector
[ef0c170]177        # If the data file does not tell us what the axes are, just assume...
[e23a20c]178        new_plot.xaxis("\\rm{Q}", 'A^{-1}')
[32c0841]179        new_plot.yaxis("\\rm{Intensity} ", "cm^{-1}")
180        new_plot.group_id = "SectorQ" + self.base.data2D.name
181        new_plot.id = "SectorQ" + self.base.data2D.name
182        new_plot.is_data = True
[ef0c170]183        wx.PostEvent(self.base.parent, NewPlotEvent(plot=new_plot,
[32c0841]184                                    title="SectorQ" + self.base.data2D.name))
[ef0c170]185       
186    def moveend(self, ev):
[6c0568b]187        """
[d955bf19]188        Called a dragging motion ends.Get slicer event
[6c0568b]189        """
[ef0c170]190        self.base.thaw_axes()
[6c0568b]191        ## Post parameters
[0d9dae8]192        event = SlicerParameterEvent()
[ef0c170]193        event.type = self.__class__.__name__
194        event.params = self.get_params()
[6c0568b]195        ## Send slicer paramers to plotter2D
[d468daa]196        wx.PostEvent(self.base, event)
[d955bf19]197       
[ef0c170]198    def restore(self):
199        """
200        Restore the roughness for this layer.
201        """
202        self.main_line.restore()
203        self.left_line.restore()
204        self.right_line.restore()
205
206    def move(self, x, y, ev):
207        """
208        Process move to a new position, making sure that the move is allowed.
209        """
210        pass
211       
212    def set_cursor(self, x, y):
[d955bf19]213        """
214        """
[ef0c170]215        pass
216       
217    def get_params(self):
[6c0568b]218        """
[d955bf19]219        Store a copy of values of parameters of the slicer into a dictionary.
220       
221        :return params: the dictionary created
222       
[6c0568b]223        """
[ef0c170]224        params = {}
[6c0568b]225        ## Always make sure that the left and the right line are at phi
226        ## angle of the middle line
[ef0c170]227        if math.fabs(self.left_line.phi) != math.fabs(self.right_line.phi):
[32c0841]228            msg = "Phi left and phi right are different"
229            msg += " %f, %f" % (self.left_line.phi, self.right_line.phi)
230            raise ValueError, msg
[6c0568b]231        params["Phi"] = self.main_line.theta
[1a6ec25]232        params["Delta_Phi"] = math.fabs(self.left_line.phi)
[ef0c170]233        params["nbins"] = self.nbins
234        return params
235   
236    def set_params(self, params):
[6c0568b]237        """
[d955bf19]238        Receive a dictionary and reset the slicer with values contained
239        in the values of the dictionary.
240       
241        :param params: a dictionary containing name of slicer parameters and
[6c0568b]242            values the user assigned to the slicer.
243        """
[1a6ec25]244        main = params["Phi"] 
[32c0841]245        phi = math.fabs(params["Delta_Phi"])
[ef0c170]246        self.nbins = int(params["nbins"])
[32c0841]247        self.main_line.theta = main
[6c0568b]248        ## Reset the slicer parameters
[ef0c170]249        self.main_line.update()
[32c0841]250        self.right_line.update(phi=phi, delta=None, mline=self.main_line,
251                               side=True, right=True)
252        self.left_line.update(phi=phi, delta=None, 
253                              mline=self.main_line, side=True)
[6c0568b]254        ## post the new corresponding data
[ef0c170]255        self._post_data(nbins=self.nbins)
256       
257    def freeze_axes(self):
[d955bf19]258        """
259        """
[ef0c170]260        self.base.freeze_axes()
[d955bf19]261   
[ef0c170]262    def thaw_axes(self):
[d955bf19]263        """
264        """
[ef0c170]265        self.base.thaw_axes()
266
267    def draw(self):
[d955bf19]268        """
269        """
[ef0c170]270        self.base.draw()
271
272       
273class SideInteractor(_BaseInteractor):
274    """
[d955bf19]275    Draw an oblique line
276   
277    :param phi: the phase between the middle line and one side line
278    :param theta2: the angle between the middle line and x- axis
279   
[ef0c170]280    """
[32c0841]281    def __init__(self, base, axes, color='black', zorder=5, r=1.0,
282                 phi=math.pi/4, theta2= math.pi/3):
283        """
284        """
[ef0c170]285        _BaseInteractor.__init__(self, base, axes, color=color)
[6c0568b]286        ## Initialize the class
[ef0c170]287        self.markers = []
288        self.axes = axes
[6c0568b]289        ## compute the value of the angle between the current line and
290        ## the x-axis 
[ef0c170]291        self.save_theta = theta2 + phi
[32c0841]292        self.theta = theta2 + phi
[6c0568b]293        ## the value of the middle line angle with respect to the x-axis
[ef0c170]294        self.theta2 = theta2
[6c0568b]295        ## Radius to find polar coordinates this line's endpoints
[ef0c170]296        self.radius = r
[6c0568b]297        ## phi is the phase between the current line and the middle line
[ef0c170]298        self.phi = phi
[6c0568b]299        ## End points polar coordinates
[32c0841]300        x1 = self.radius * math.cos(self.theta)
301        y1 = self.radius * math.sin(self.theta)
302        x2 = -1 * self.radius * math.cos(self.theta)
303        y2 = -1 * self.radius * math.sin(self.theta)
[6c0568b]304        ## defining a new marker
[7a28ba7]305        try:
[32c0841]306            self.inner_marker = self.axes.plot([x1/2.5], [y1/2.5], linestyle='',
[7a28ba7]307                                          marker='s', markersize=10,
308                                          color=self.color, alpha=0.6,
309                                          pickradius=5, label="pick", 
[32c0841]310                                          # Prefer this to other lines
311                                          zorder=zorder, visible=True)[0]
[7a28ba7]312        except:
[0c218d9]313            self.inner_marker = self.axes.plot([x1/2.5],[y1/2.5], linestyle='',
[7a28ba7]314                                          marker='s', markersize=10,
315                                          color=self.color, alpha=0.6,
[32c0841]316                                          label="pick", visible=True)[0]
317            message  = "\nTHIS PROTOTYPE NEEDS THE LATEST"
318            message += " VERSION OF MATPLOTLIB\n Get the SVN version that"
319            message += " is at least as recent as June 1, 2007"
320            owner = self.base.base.parent
321            wx.PostEvent(owner, 
322                         StatusEvent(status="sectorSlicer: %s" % message))
[6c0568b]323       
324        ## Defining the current line
[32c0841]325        self.line = self.axes.plot([x1, x2], [y1, y2],
[ef0c170]326                                      linestyle='-', marker='',
[32c0841]327                                      color=self.color, visible=True)[0]
[6c0568b]328        ## Flag to differentiate the left line from the right line motion
[32c0841]329        self.left_moving = False
[6c0568b]330        ## Flag to define a motion
[32c0841]331        self.has_move = False
[6c0568b]332        ## connecting markers and draw the picture
[7a28ba7]333        self.connect_markers([self.inner_marker, self.line])
[6c0568b]334       
[ef0c170]335    def set_layer(self, n):
[6c0568b]336        """
[d955bf19]337        Allow adding plot to the same panel
338         
339        :param n: the number of layer
340       
[6c0568b]341        """
[ef0c170]342        self.layernum = n
343        self.update()
344       
345    def clear(self):
[6c0568b]346        """
[d955bf19]347        Clear the slicer and all connected events related to this slicer
[6c0568b]348        """
[ef0c170]349        self.clear_markers()
350        try:
351            self.line.remove()
[7a28ba7]352            self.inner_marker.remove()
[ef0c170]353        except:
354            # Old version of matplotlib
355            for item in range(len(self.axes.lines)):
356                del self.axes.lines[0]
[d955bf19]357   
[6c0568b]358    def update(self, phi=None, delta=None, mline=None,
359               side=False, left= False, right=False):
[ef0c170]360        """
[d955bf19]361        Draw oblique line
362       
363        :param phi: the phase between the middle line and the current line
364        :param delta: phi/2 applied only when the mline was moved
365       
[ef0c170]366        """
367        #print "update left or right ", self.has_move
[32c0841]368        self.left_moving = left
369        theta3 = 0
370        if phi != None:
371            self.phi = phi
372        if delta == None:
[31e3298]373            delta = 0
[7a28ba7]374        if  right:
[32c0841]375            self.phi = -1 * math.fabs(self.phi)
[31e3298]376            #delta=-delta
[7a28ba7]377        else:
[32c0841]378            self.phi = math.fabs(self.phi)
[e23a20c]379        if side:
[32c0841]380            self.theta = mline.theta + self.phi
[31e3298]381                   
[32c0841]382        if mline != None :
383            if delta != 0:
384                self.theta2 = mline + delta
[31e3298]385            else:
386                self.theta2 = mline.theta
[32c0841]387        if delta == 0:
388            theta3 = self.theta + delta
[31e3298]389        else:
[32c0841]390            theta3 = self.theta2 + delta
391        x1 = self.radius * math.cos(theta3)
392        y1 = self.radius * math.sin(theta3)
393        x2 = -1 * self.radius * math.cos(theta3)
394        y2 = -1 * self.radius * math.sin(theta3)
395        self.inner_marker.set(xdata=[x1/2.5], ydata=[y1/2.5])
396        self.line.set(xdata=[x1, x2], ydata=[y1, y2]) 
[ef0c170]397       
398    def save(self, ev):
399        """
400        Remember the roughness for this layer and the next so that we
401        can restore on Esc.
402        """
[32c0841]403        self.save_theta = self.theta
[ef0c170]404        self.base.freeze_axes()
405
406    def moveend(self, ev):
[d955bf19]407        """
408        """
[32c0841]409        self.has_move = False
[ef0c170]410        self.base.moveend(ev)
411           
412    def restore(self):
413        """
414        Restore the roughness for this layer.
415        """
416        self.theta = self.save_theta
417
418    def move(self, x, y, ev):
419        """
420        Process move to a new position, making sure that the move is allowed.
421        """
[32c0841]422        self.theta = math.atan2(y, x)
423        self.has_move = True
[0c218d9]424        #ToDo: Simplify below
[7a28ba7]425        if not self.left_moving:
[32c0841]426            if  self.theta2 - self.theta <= 0 and self.theta2 > 0:
[0c218d9]427                self.restore()
428                return 
[32c0841]429            elif self.theta2 < 0 and self.theta < 0 and \
430                self.theta-self.theta2 >= 0:
[0c218d9]431                self.restore()
432                return                             
[32c0841]433            elif  self.theta2 < 0 and self.theta > 0 and \
434                (self.theta2 + 2 * math.pi - self.theta) >= math.pi/2:
[0c218d9]435                #print "my theta", self.theta
436                self.restore()
437                return 
[32c0841]438            elif  self.theta2 < 0 and self.theta < 0 and \
439                (self.theta2 - self.theta) >= math.pi/2:
[0c218d9]440                #print "my theta", self.theta
[7a28ba7]441                self.restore()
442                return 
[32c0841]443            elif self.theta2 > 0 and (self.theta2-self.theta >= math.pi/2 or \
444                (self.theta2-self.theta >= math.pi/2)):
[0c218d9]445                #print "self theta encore"
[7a28ba7]446                self.restore()
447                return 
448        else:
[0c218d9]449            #print "left move"
[32c0841]450            if  self.theta < 0 and (self.theta + math.pi*2-self.theta2) <= 0:
[7a28ba7]451                self.restore()
452                return 
[32c0841]453            elif self.theta2 < 0 and (self.theta-self.theta2) <= 0:
[0c218d9]454                self.restore()
455                return                             
[32c0841]456            elif  self.theta > 0 and self.theta-self.theta2 <= 0:
[0c218d9]457                #print "my theta", self.theta
458                self.restore()
459                return 
[32c0841]460            elif self.theta-self.theta2 >= math.pi/2 or  \
461                ((self.theta + math.pi * 2 - self.theta2) >= math.pi/2 and \
462                 self.theta < 0 and self.theta2 > 0):
[0c218d9]463                #print "self theta encore"
[7a28ba7]464                self.restore()
465                return 
[0c218d9]466           
[32c0841]467        self.phi = math.fabs(self.theta2 - self.theta)
468        if self.phi > math.pi:
469            self.phi = 2 * math.pi - math.fabs(self.theta2 - self.theta)
[ef0c170]470        self.base.base.update()
471       
472    def set_cursor(self, x, y):
[d955bf19]473        """
474        """
[ef0c170]475        self.move(x, y, None)
476        self.update()
[d955bf19]477   
[ef0c170]478    def get_params(self):
[d955bf19]479        """
480        """
[ef0c170]481        params = {}
482        params["radius"] = self.radius
483        params["theta"] = self.theta
484        return params
485   
486    def set_params(self, params):
[d955bf19]487        """
488        """
[ef0c170]489        x = params["radius"] 
490        self.set_cursor(x, self._inner_mouse_y)
491       
[d955bf19]492
[ef0c170]493class LineInteractor(_BaseInteractor):
494    """
[d955bf19]495    Select an annulus through a 2D plot
[ef0c170]496    """
[32c0841]497    def __init__(self, base, axes, color='black',
498                 zorder=5, r=1.0, theta=math.pi/4):
[d955bf19]499        """
500        """
[ef0c170]501        _BaseInteractor.__init__(self, base, axes, color=color)
[d955bf19]502       
[ef0c170]503        self.markers = []
504        self.axes = axes
505        self.save_theta = theta
506        self.theta= theta
507        self.radius = r
508        self.scale = 10.0
509        # Inner circle
[32c0841]510        x1 = self.radius * math.cos(self.theta)
511        y1 = self.radius * math.sin(self.theta)
512        x2 = -1*self.radius * math.cos(self.theta)
513        y2 = -1*self.radius * math.sin(self.theta)
[7a28ba7]514        try:
515            # Inner circle marker
[32c0841]516            self.inner_marker = self.axes.plot([x1/2.5], [y1/2.5], linestyle='',
[7a28ba7]517                                          marker='s', markersize=10,
518                                          color=self.color, alpha=0.6,
519                                          pickradius=5, label="pick", 
[32c0841]520                                          # Prefer this to other lines
521                                          zorder=zorder, 
[7a28ba7]522                                          visible=True)[0]
523        except:
[32c0841]524            self.inner_marker = self.axes.plot([x1/2.5], [y1/2.5], linestyle='',
[7a28ba7]525                                          marker='s', markersize=10,
526                                          color=self.color, alpha=0.6,
527                                          label="pick", 
528                                          visible=True)[0]
[32c0841]529            message  = "\nTHIS PROTOTYPE NEEDS THE LATEST VERSION"
530            message += " OF MATPLOTLIB\n Get the SVN version that is at"
531            message += " least as recent as June 1, 2007"
532        self.line = self.axes.plot([x1, x2], [y1, y2],
[ef0c170]533                                      linestyle='-', marker='',
[32c0841]534                                      color=self.color, visible=True)[0]
[ef0c170]535        self.npts = 20
[32c0841]536        self.has_move = False
[7a28ba7]537        self.connect_markers([self.inner_marker, self.line])
[ef0c170]538        self.update()
539
540    def set_layer(self, n):
[d955bf19]541        """
542        """
[ef0c170]543        self.layernum = n
544        self.update()
545       
546    def clear(self):
[d955bf19]547        """
548        """
[ef0c170]549        self.clear_markers()
550        try:
[7a28ba7]551            self.inner_marker.remove()
[ef0c170]552            self.line.remove()
553        except:
554            # Old version of matplotlib
555            for item in range(len(self.axes.lines)):
556                del self.axes.lines[0]
[6c0568b]557 
[ef0c170]558    def update(self, theta=None):
559        """
560        Draw the new roughness on the graph.
561        """
[6c0568b]562       
[32c0841]563        if theta != None:
564            self.theta = theta
565        x1 = self.radius * math.cos(self.theta)
566        y1 = self.radius * math.sin(self.theta)
567        x2 = -1 * self.radius * math.cos(self.theta)
568        y2 = -1 * self.radius * math.sin(self.theta)
569       
570        self.inner_marker.set(xdata=[x1/2.5], ydata=[y1/2.5])
571        self.line.set(xdata=[x1, x2], ydata=[y1, y2]) 
[d955bf19]572   
[ef0c170]573    def save(self, ev):
574        """
575        Remember the roughness for this layer and the next so that we
576        can restore on Esc.
577        """
578        self.save_theta= self.theta
579        self.base.freeze_axes()
580
581    def moveend(self, ev):
[d955bf19]582        """
583        """
[32c0841]584        self.has_move = False
[ef0c170]585        self.base.moveend(ev)
586           
587    def restore(self):
588        """
589        Restore the roughness for this layer.
590        """
591        self.theta = self.save_theta
592
593    def move(self, x, y, ev):
594        """
595        Process move to a new position, making sure that the move is allowed.
596        """
[32c0841]597        self.theta = math.atan2(y, x)
598        self.has_move = True
[ef0c170]599        self.base.base.update()
600       
601    def set_cursor(self, x, y):
[d955bf19]602        """
603        """
[ef0c170]604        self.move(x, y, None)
605        self.update()
606       
607    def get_params(self):
[d955bf19]608        """
609        """
[ef0c170]610        params = {}
611        params["radius"] = self.radius
612        params["theta"] = self.theta
613        return params
614   
615    def set_params(self, params):
[d955bf19]616        """
617        """
[ef0c170]618        x = params["radius"] 
619        self.set_cursor(x, self._inner_mouse_y)
[356aea78]620       
Note: See TracBrowser for help on using the repository browser.