1 """
2 roughness interactor.
3 """
4
5 from reflutils import roughness_color, roughness_pickradius
6 from baseInteractor import BaseInteractor
7
8
9
10
11
13 """
14 Control the roughness of the layers.
15 """
21 BaseInteractor.__init__(self, base, axes, color=color)
22
23 self.layernum = 0
24 self.axes = axes
25
26
27 self.mrough=[self.axes.plot([0],[0.05],
28 linestyle = '',
29 transform = self.xcoords,
30 marker = 's',
31 markersize = 7,
32 color = self.color,
33 alpha = 0.6,
34 pickradius = roughness_pickradius,
35 label = label,
36 zorder = 8,
37 visible = False)[0]
38 for label in ('left rough','right rough')
39 ]
40
41
42 self.lrough=[self.axes.plot([0,0],[0.05,0.05],
43 transform = self.xcoords,
44 linestyle = '-',
45 marker = '',
46 color = self.color,
47 visible = False)[0]
48 for label in ('left lrough','right lrough')
49 ]
50
51 self.markers = self.mrough
52 self.connect_markers(self.markers)
53
54
56 """
57 Set the layer number
58 """
59 self.layernum = n
60 self.update()
61
62
85
86
88 """
89 clear roughness( line and marker) on the graph.
90 """
91 for line in self.lrough:
92 line.remove()
93 self.clear_markers()
94
95
96 - def save(self, event):
97 """
98 Remember the roughness for this layer and the next so that we
99 can restore on Esc.
100 """
101 model = self.base.model
102 self._save_n = self.mrough.index(event.artist)
103
104 self._save_v = model.rough[self.layernum + self._save_n-1]
105
106
107 self.base.freeze_axes()
108
109
112
113
115 """
116 Restore the roughness for this layer.
117 """
118 try:
119 model = self.base.model
120 model.rough[self.layernum + self._save_n] = self._save_v
121 except:
122 pass
123
124
126 """
127 Get the max rough for layer n
128 """
129 model = self.base.model
130 if n == 0 :
131
132
133 return 1000.0
134 else:
135 return model.depth[n]/model.max_rough
136
137
138 - def move(self, x, y, event):
175
176
178 """
179 Get the rough for layer n
180 """
181 try:
182 val = self.base.model.rough[n]
183 except:
184 val = None
185 return val
186
187
189 """
190 Set the rough
191
192 First call move(), so we can directly use the updated data(rough).
193 """
194 n = self.layernum
195 idx = self.mrough.index(event.artist)
196
197 if idx==1:
198 val = self.getRough(n)
199 else:
200 val = self.getRough(n-1)
201
202 if val == None:
203 return
204
205 self.infopanel.updateNLayer( n )
206
207 if idx==1: self.infopanel.updateRRoughValue( val )
208 else: self.infopanel.updateLRoughValue( val )
209
210
212 """
213 Show the rough
214 """
215 n = self.model.find( event.xdata )
216 idx = self.mrough.index(event.artist)
217
218 if idx ==1: self._save_rough_n = n
219 else: self._save_rough_n = n-1
220
221 self.infopanel.updateNLayer( n )
222
223 if idx == 1: self.infopanel.showRRoughValue( )
224 else: self.infopanel.showLRoughValue( )
225