diff --git a/invesalius/data/styles.py b/invesalius/data/styles.py index f8e547c..1eabd71 100644 --- a/invesalius/data/styles.py +++ b/invesalius/data/styles.py @@ -77,12 +77,12 @@ class CrossInteractorStyle(RightZoomInteractorStyle): """ Interactor style responsible for the Cross. """ - def __init__(self, orientation, slice_data): + def __init__(self, viewer): RightZoomInteractorStyle.__init__(self) - self.orientation = orientation - self.slice_actor = slice_data.actor - self.slice_data = slice_data + self.orientation = viewer.orientation + self.slice_actor = viewer.slice_data.actor + self.slice_data = viewer.slice_data self.picker = vtk.vtkWorldPointPicker() @@ -183,14 +183,16 @@ class WWWLInteractorStyle(RightZoomInteractorStyle): """ Interactor style responsible for Window Level & Width functionality. """ - def __init__(self, ww, wl): + def __init__(self, viewer): RightZoomInteractorStyle.__init__(self) + self.viewer = viewer + self.last_x = 0 self.last_y = 0 - self.acum_achange_window = ww - self.acum_achange_level = wl + self.acum_achange_window = viewer.slice_.window_width + self.acum_achange_level = viewer.slice_.window_level self.AddObserver("MouseMoveEvent", self.OnWindowLevelMove) self.AddObserver("LeftButtonPressEvent", self.OnWindowLevelClick) @@ -222,16 +224,20 @@ class WWWLInteractorStyle(RightZoomInteractorStyle): iren = obj.GetInteractor() self.last_x, self.last_y = iren.GetLastEventPosition() + self.acum_achange_window = viewer.slice_.window_width + self.acum_achange_level = viewer.slice_.window_level + class LinearMeasureInteractorStyle(RightZoomInteractorStyle): """ Interactor style responsible for insert linear measurements. """ - def __init__(self, orientation, slice_data): + def __init__(self, viewer): RightZoomInteractorStyle.__init__(self) - self.orientation = orientation - self.slice_data = slice_data + self.viewer = viewer + self.orientation = viewer.orientation + self.slice_data = viewer.slice_data self.picker = vtk.vtkCellPicker() @@ -249,18 +255,19 @@ class LinearMeasureInteractorStyle(RightZoomInteractorStyle): ((x, y,z), const.LINEAR, ORIENTATIONS[self.orientation], slice_number)) - Publisher.sendMessage('Update slice viewer') + self.viewer.interactor.Render() class AngularMeasureInteractorStyle(RightZoomInteractorStyle): """ Interactor style responsible for insert angular measurements. """ - def __init__(self, orientation, slice_data): + def __init__(self, viewer): RightZoomInteractorStyle.__init__(self) - self.orientation = orientation - self.slice_data = slice_data + self.viewer = viewer + self.orientation = viewer.orientation + self.slice_data = viewer.slice_data self.picker = vtk.vtkCellPicker() @@ -278,7 +285,7 @@ class AngularMeasureInteractorStyle(RightZoomInteractorStyle): ((x, y,z), const.ANGULAR, ORIENTATIONS[self.orientation], slice_number)) - Publisher.sendMessage('Update slice viewer') + self.viewer.interactor.Render() class PanMoveInteractorStyle(RightZoomInteractorStyle): diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 010e940..6191c8e 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -176,8 +176,7 @@ class Viewer(wx.Panel): def SetInteractorStyle(self, state): if state == const.SLICE_STATE_CROSS: - style = styles.CrossInteractorStyle(self.orientation, - self.slice_data) + style = styles.CrossInteractorStyle(self) self.style = style self.interactor.SetInteractorStyle(style) self.interactor.Render() @@ -197,22 +196,19 @@ class Viewer(wx.Panel): self.on_wl = True self.wl_text.Show() - ww = sl.Slice().window_width - wl = sl.Slice().window_level - - style = styles.WWWLInteractorStyle(ww, wl) + style = styles.WWWLInteractorStyle(self) self.style = style self.interactor.SetInteractorStyle(style) self.interactor.Render() elif state == const.STATE_MEASURE_DISTANCE: - style = styles.LinearMeasureInteractorStyle(self.orientation, self.slice_data) + style = styles.LinearMeasureInteractorStyle(self) self.style = style self.interactor.SetInteractorStyle(style) self.interactor.Render() elif state == const.STATE_MEASURE_ANGLE: - style = styles.AngularMeasureInteractorStyle(self.orientation, self.slice_data) + style = styles.AngularMeasureInteractorStyle(self) self.style = style self.interactor.SetInteractorStyle(style) self.interactor.Render() @@ -263,11 +259,6 @@ class Viewer(wx.Panel): "EnterEvent": self.OnEnterInteractor, "LeaveEvent": self.OnLeaveInteractor }, - const.SLICE_STATE_SCROLL: - { - "MouseMoveEvent": self.OnChangeSliceMove, - "LeftButtonPressEvent": self.OnChangeSliceClick, - }, const.STATE_DEFAULT: { }, @@ -380,32 +371,6 @@ class Viewer(wx.Panel): self.SetWLText(window, level) Publisher.sendMessage('Update all slice') - - def OnChangeSliceMove(self, evt, obj): - if (self.left_pressed): - min = 0 - max = self.slice_.GetMaxSliceNumber(self.orientation) - - if (self.left_pressed): - position = self.interactor.GetLastEventPosition() - scroll_position = self.scroll.GetThumbPosition() - - if (position[1] > self.last_position) and\ - (self.acum_achange_slice > min): - self.acum_achange_slice -= 1 - elif(position[1] < self.last_position) and\ - (self.acum_achange_slice < max): - self.acum_achange_slice += 1 - self.last_position = position[1] - - self.scroll.SetThumbPosition(self.acum_achange_slice) - self.OnScrollBar() - - def OnChangeSliceClick(self, evt, obj): - position = list(self.interactor.GetLastEventPosition()) - self.acum_achange_slice = self.scroll.GetThumbPosition() - self.last_position = position[1] - def OnPanMove(self, evt, obj): mouse_x, mouse_y = self.interactor.GetLastEventPosition() ren = self.interactor.FindPokedRenderer(mouse_x, mouse_y) -- libgit2 0.21.2