Commit 3ecbb5f87d2bdd3e343e3db26cc4298285e258fc
1 parent
aefd974a
Exists in
interactor_style
Created a new interactor style to handle angular measurements
Showing
2 changed files
with
39 additions
and
2 deletions
Show diff stats
invesalius/data/styles.py
@@ -223,6 +223,9 @@ class WWWLInteractorStyle(ZoomInteractorStyle): | @@ -223,6 +223,9 @@ class WWWLInteractorStyle(ZoomInteractorStyle): | ||
223 | 223 | ||
224 | 224 | ||
225 | class LinearMeasure(ZoomInteractorStyle): | 225 | class LinearMeasure(ZoomInteractorStyle): |
226 | + """ | ||
227 | + Interactor style responsible for insert linear measures. | ||
228 | + """ | ||
226 | def __init__(self, orientation, slice_data): | 229 | def __init__(self, orientation, slice_data): |
227 | ZoomInteractorStyle.__init__(self) | 230 | ZoomInteractorStyle.__init__(self) |
228 | 231 | ||
@@ -240,15 +243,43 @@ class LinearMeasure(ZoomInteractorStyle): | @@ -240,15 +243,43 @@ class LinearMeasure(ZoomInteractorStyle): | ||
240 | slice_number = self.slice_data.number | 243 | slice_number = self.slice_data.number |
241 | self.picker.Pick(x, y, 0, render) | 244 | self.picker.Pick(x, y, 0, render) |
242 | x, y, z = self.picker.GetPickPosition() | 245 | x, y, z = self.picker.GetPickPosition() |
243 | - print x, y, z | ||
244 | if self.picker.GetViewProp(): | 246 | if self.picker.GetViewProp(): |
245 | - self.render_to_add = self.slice_data.renderer | ||
246 | Publisher.sendMessage("Add measurement point", | 247 | Publisher.sendMessage("Add measurement point", |
247 | ((x, y,z), const.LINEAR, | 248 | ((x, y,z), const.LINEAR, |
248 | ORIENTATIONS[self.orientation], | 249 | ORIENTATIONS[self.orientation], |
249 | slice_number)) | 250 | slice_number)) |
250 | Publisher.sendMessage('Update slice viewer') | 251 | Publisher.sendMessage('Update slice viewer') |
251 | 252 | ||
253 | + | ||
254 | +class AngularMeasure(ZoomInteractorStyle): | ||
255 | + """ | ||
256 | + Interactor style responsible for insert angular measurements. | ||
257 | + """ | ||
258 | + def __init__(self, orientation, slice_data): | ||
259 | + ZoomInteractorStyle.__init__(self) | ||
260 | + | ||
261 | + self.orientation = orientation | ||
262 | + self.slice_data = slice_data | ||
263 | + | ||
264 | + self.picker = vtk.vtkCellPicker() | ||
265 | + | ||
266 | + self.AddObserver("LeftButtonPressEvent", self.OnInsertAngularMeasurePoint) | ||
267 | + | ||
268 | + def OnInsertAngularMeasurePoint(self, obj, evt): | ||
269 | + iren = obj.GetInteractor() | ||
270 | + x,y = iren.GetEventPosition() | ||
271 | + render = iren.FindPokedRenderer(x, y) | ||
272 | + slice_number = self.slice_data.number | ||
273 | + self.picker.Pick(x, y, 0, render) | ||
274 | + x, y, z = self.picker.GetPickPosition() | ||
275 | + if self.picker.GetViewProp(): | ||
276 | + Publisher.sendMessage("Add measurement point", | ||
277 | + ((x, y,z), const.ANGULAR, | ||
278 | + ORIENTATIONS[self.orientation], | ||
279 | + slice_number)) | ||
280 | + Publisher.sendMessage('Update slice viewer') | ||
281 | + | ||
282 | + | ||
252 | class ViewerStyle: | 283 | class ViewerStyle: |
253 | def __init__(self): | 284 | def __init__(self): |
254 | self.interactor = None | 285 | self.interactor = None |
invesalius/data/viewer_slice.py
@@ -211,6 +211,12 @@ class Viewer(wx.Panel): | @@ -211,6 +211,12 @@ class Viewer(wx.Panel): | ||
211 | self.interactor.SetInteractorStyle(style) | 211 | self.interactor.SetInteractorStyle(style) |
212 | self.interactor.Render() | 212 | self.interactor.Render() |
213 | 213 | ||
214 | + elif state == const.STATE_MEASURE_ANGLE: | ||
215 | + style = styles.AngularMeasure(self.orientation, self.slice_data) | ||
216 | + self.style = style | ||
217 | + self.interactor.SetInteractorStyle(style) | ||
218 | + self.interactor.Render() | ||
219 | + | ||
214 | else: | 220 | else: |
215 | self.state = state | 221 | self.state = state |
216 | action = { | 222 | action = { |