source: sasview/guiframe/local_perspectives/plotting/Edge.py @ 6137b150

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 6137b150 was d955bf19, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working on documentation

  • Property mode set to 100644
File size: 4.0 KB
Line 
1
2import math
3import wx 
4from copy import deepcopy
5
6from BaseInteractor import _BaseInteractor
7from sans.guicomm.events import NewPlotEvent, StatusEvent,SlicerParameterEvent,EVT_SLICER_PARS
8   
9
10
11       
12class RadiusInteractor(_BaseInteractor):
13    """
14    Select an annulus through a 2D plot
15    """
16    def __init__(self,base,axes,color='black', zorder=5, arc1=None,arc2=None,
17                 theta=math.pi/8):
18       
19        _BaseInteractor.__init__(self, base, axes, color=color)
20        self.markers = []
21        self.axes = axes
22       
23        self.r1 = arc1.get_radius()
24        self.r2 = arc2.get_radius()
25        #print "radius init", self.r1, self.r2
26        self.theta=theta
27        self.save_theta= theta
28        #self.scale = 10.0
29        self.move_stop=False
30        self.theta_left=None
31        self.theta_right=None
32        self.arc1= arc1
33        self.arc2=arc2
34        #raise "Version error", message
35        x1= self.r1*math.cos(self.theta)
36        y1= self.r1*math.sin(self.theta)
37        x2= self.r2*math.cos(self.theta)
38        y2= self.r2*math.sin(self.theta)
39        self.line = self.axes.plot([x1,x2],[y1,y2],
40                                      linestyle='-', marker='',
41                                      color=self.color,
42                                      visible=True)[0]
43        self.phi= theta
44        self.npts = 20
45        self.has_move= False
46        self.connect_markers([self.line])
47        self.update()
48       
49       
50    def set_layer(self, n):
51        """
52        """
53        self.layernum = n
54        self.update()
55       
56    def clear(self):
57        """
58        """
59        self.clear_markers()
60        try:
61            self.line.remove()
62         
63        except:
64            # Old version of matplotlib
65            for item in range(len(self.axes.lines)):
66                del self.axes.lines[0]
67   
68    def get_angle(self):
69        """
70        """
71        return self.theta
72       
73    def update(self,r1=None, r2=None, theta=None):
74        """
75        Draw the new roughness on the graph.
76        """
77        if r1 != None:
78            self.r1 = r1
79        if r2 != None:
80            self.r2 = r2
81        if theta !=None:
82            self.theta= theta
83       
84        #print "in the edge r1, r2",self.r1,self.r2,math.degrees(self.theta)
85        x1= self.r1*math.cos(self.theta)
86        y1= self.r1*math.sin(self.theta)
87        x2= self.r2*math.cos(self.theta)
88        y2= self.r2*math.sin(self.theta) 
89             
90        self.line.set(xdata=[x1,x2], ydata=[y1,y2])
91       
92 
93    def save(self, ev):
94        """
95        Remember the roughness for this layer and the next so that we
96        can restore on Esc.
97        """
98        self.save_theta= math.atan2(ev.y,ev.x)
99        #self.save_theta= self.theta
100        self.base.freeze_axes()
101   
102    def moveend(self, ev):
103        """
104        """
105        self.has_move= False
106        self.base.moveend(ev)
107           
108    def restore(self):
109        """
110        Restore the roughness for this layer.
111        """
112        self.theta = self.save_theta
113
114    def move(self, x, y, ev):
115        """
116        Process move to a new position, making sure that the move is allowed.
117        """
118        self.theta= math.atan2(y,x)
119        self.has_move= True
120        self.base.base.update()
121       
122    def set_cursor(self,r_min, r_max, theta):
123        """
124        """
125        self.theta= theta
126        self.r1= r_min
127        self.r2=r_max
128        self.update()
129       
130    def get_params(self):
131        """
132        """
133        params = {}
134        params["radius1"] = self.r1
135        params["radius2"] = self.r2
136        params["theta"] = self.theta
137        return params
138   
139    def set_params(self, params):
140        """
141        """
142        #print "when here set curcor arc"
143        x1 = params["radius1"] 
144        x2 = params["radius2"] 
145        theta= params["theta"]
146        self.set_cursor(x1, x2, theta)
147       
148   
Note: See TracBrowser for help on using the repository browser.