source: sasview/guiframe/local_perspectives/plotting/Edge.py @ 65a8b34

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

working on documentation

  • Property mode set to 100644
File size: 4.0 KB
RevLine 
[0d9dae8]1
[b06ef8c]2import math
[0d9dae8]3import wx 
4from copy import deepcopy
5
6from BaseInteractor import _BaseInteractor
7from sans.guicomm.events import NewPlotEvent, StatusEvent,SlicerParameterEvent,EVT_SLICER_PARS
8   
[b06ef8c]9
10
11       
12class RadiusInteractor(_BaseInteractor):
13    """
[d955bf19]14    Select an annulus through a 2D plot
[b06ef8c]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
[356aea78]29        self.move_stop=False
30        self.theta_left=None
31        self.theta_right=None
[b06ef8c]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]
[356aea78]43        self.phi= theta
[b06ef8c]44        self.npts = 20
[2d107b8]45        self.has_move= False
[b06ef8c]46        self.connect_markers([self.line])
47        self.update()
48       
49       
50    def set_layer(self, n):
[d955bf19]51        """
52        """
[b06ef8c]53        self.layernum = n
54        self.update()
55       
56    def clear(self):
[d955bf19]57        """
58        """
[b06ef8c]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]
[d955bf19]67   
[e8c96f5]68    def get_angle(self):
[d955bf19]69        """
70        """
[b06ef8c]71        return self.theta
72       
[e8c96f5]73    def update(self,r1=None, r2=None, theta=None):
[b06ef8c]74        """
75        Draw the new roughness on the graph.
76        """
[d955bf19]77        if r1 != None:
78            self.r1 = r1
79        if r2 != None:
80            self.r2 = r2
[e8c96f5]81        if theta !=None:
82            self.theta= theta
83       
[d955bf19]84        #print "in the edge r1, r2",self.r1,self.r2,math.degrees(self.theta)
[b06ef8c]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])
[356aea78]91       
[b06ef8c]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        """
[e8c96f5]98        self.save_theta= math.atan2(ev.y,ev.x)
99        #self.save_theta= self.theta
[b06ef8c]100        self.base.freeze_axes()
101   
102    def moveend(self, ev):
[d955bf19]103        """
104        """
[2d107b8]105        self.has_move= False
[b06ef8c]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        """
[b98db8c]118        self.theta= math.atan2(y,x)
119        self.has_move= True
[b06ef8c]120        self.base.base.update()
121       
[e8c96f5]122    def set_cursor(self,r_min, r_max, theta):
[d955bf19]123        """
124        """
[e8c96f5]125        self.theta= theta
126        self.r1= r_min
127        self.r2=r_max
[b06ef8c]128        self.update()
129       
130    def get_params(self):
[d955bf19]131        """
132        """
[b06ef8c]133        params = {}
134        params["radius1"] = self.r1
135        params["radius2"] = self.r2
[e8c96f5]136        params["theta"] = self.theta
[b06ef8c]137        return params
138   
139    def set_params(self, params):
[d955bf19]140        """
141        """
142        #print "when here set curcor arc"
[b06ef8c]143        x1 = params["radius1"] 
144        x2 = params["radius2"] 
[e8c96f5]145        theta= params["theta"]
146        self.set_cursor(x1, x2, theta)
[b06ef8c]147       
148   
Note: See TracBrowser for help on using the repository browser.