Commit b557c29890e70ba1337cd59bf54b29c7f1d2f11e
1 parent
46f4452a
Exists in
interactor_style
Cleaning unneeded code from data/styles.py
Showing
1 changed file
with
0 additions
and
178 deletions
Show diff stats
invesalius/data/styles.py
... | ... | @@ -584,181 +584,3 @@ class EditorInteractorStyle(DefaultInteractorStyle): |
584 | 584 | elif bounds[4] == bounds[5]: |
585 | 585 | z = bounds[4] |
586 | 586 | return x, y, z |
587 | - | |
588 | - | |
589 | -class ViewerStyle: | |
590 | - def __init__(self): | |
591 | - self.interactor = None | |
592 | - self.style = None | |
593 | - self.render = None | |
594 | - | |
595 | - def SetInteractor(self, interactor): | |
596 | - | |
597 | - # Setting style already defined in VTK | |
598 | - if (self.style is None): | |
599 | - self.style = vtk.vtkInteractorStyle() | |
600 | - #self.style.SetInteractor(interactor) | |
601 | - self.SetStyleConfig() | |
602 | - interactor.SetInteractorStyle(style) | |
603 | - | |
604 | - # Saving data into attributes | |
605 | - self.render = interactor.GetRenderWindow().GetRenderer() | |
606 | - self.interactor = interactor | |
607 | - | |
608 | - # Call events | |
609 | - self.__init_evt() | |
610 | - | |
611 | - def SetStyleConfig(self): | |
612 | - print "calling parent" | |
613 | - pass | |
614 | - | |
615 | - def __init_evt(self): | |
616 | - style = self.style | |
617 | - style.AddObserver("LeftButtonPressEvent", self.OnLeftButtonDown) | |
618 | - style.AddObserver("LeftButtonReleaseEvent", self.OnLeftButtonUp) | |
619 | - style.AddObserver("MiddleButtonPressEvent", self.OnMiddleButtonDown) | |
620 | - style.AddObserver("MiddleButtonReleaseEvent", self.OnMiddleButtonUp) | |
621 | - style.AddObserver("RightButtonPressEvent", self.OnRightButtonDown) | |
622 | - style.AddObserver("RightButtonReleaseEvent", self.OnRightButtonUp) | |
623 | - style.AddObserver("MouseWheelForwardEvent", self.OnScroll) | |
624 | - style.AddObserver("MouseWheelBackwardEvent", self.OnScroll) | |
625 | - | |
626 | - style.AddObserver("MouseMoveEvent",self.OnMouseMove) | |
627 | - | |
628 | - def OnScroll(self, evt, str_evt): | |
629 | - pass | |
630 | - | |
631 | - def OnLeftButtonDown(self, evt, str_evt): | |
632 | - pass | |
633 | - | |
634 | - def OnLeftButtonUp(self, evt, str_evt): | |
635 | - pass | |
636 | - | |
637 | - def OnMiddleButtonDown(self, evt, str_evt): | |
638 | - pass | |
639 | - | |
640 | - def OnMiddleButtonUp(self, evt, str_evt): | |
641 | - pass | |
642 | - | |
643 | - def OnRightButtonDown(self, evt, str_evt): | |
644 | - pass | |
645 | - | |
646 | - def OnRightButtonUp(self, evt, str_evt): | |
647 | - pass | |
648 | - | |
649 | - def OnMouseMove(self, evt, str_evt): | |
650 | - pass | |
651 | - | |
652 | -class ViewerStyleSlice(ViewerStyle): | |
653 | - def __init__(self): | |
654 | - ViewerStyle.__init__(self) | |
655 | - self.orientation = 'AXIAL' | |
656 | - | |
657 | - self.style = vtk.vtkInteractorStyleImage() | |
658 | - self.style.AutoAdjustCameraClippingRangeOn() | |
659 | - | |
660 | - def SetOrientation(self, orientation='AXIAL'): | |
661 | - self.orientation = orientation | |
662 | - | |
663 | - def OnScroll(self, evt, evt_string): | |
664 | - if evt_string == "MouseWheelForwardEvent": | |
665 | - value = 1 | |
666 | - else: # elif evt_string =="MouseWheelBackwardEvent": | |
667 | - value = -1 | |
668 | - ps.Publisher().sendMessage(('Set scroll position', self.orientation), value) | |
669 | - | |
670 | -class ViewerStyleSliceEditor(ViewerStyleSlice): | |
671 | - | |
672 | - def __init__(self): | |
673 | - # FIXME: the idea is not using Slice from here...! | |
674 | - #self.slice_ = slc.Slice() | |
675 | - | |
676 | - self.picker = vtk.vtkCellPicker() # define position where user clicked | |
677 | - | |
678 | - self.mouse_pressed = 0 # define if operation will executed run or not | |
679 | - | |
680 | - self.style = const.OP_ADD # define brush operation .OP_DEL, .OP_THRESH | |
681 | - | |
682 | - | |
683 | - def SetData(self, actor_bounds, imagedata_dimensions): | |
684 | - self.pos_converter = ViewerToImagedataPosConverter(actor_bounds, | |
685 | - imagedata_dimensions, | |
686 | - self.renderer) | |
687 | - | |
688 | - def SetStyleConfig(self): | |
689 | - print "calling son" | |
690 | - | |
691 | - def SetOrientation(self, orient): | |
692 | - pass | |
693 | - | |
694 | - def OnLeftButtonDown(self, evt, str_evt): | |
695 | - self.mouse_pressed = 1 | |
696 | - | |
697 | - def OnLeftButtonUp(self, evt, str_evt): | |
698 | - self.mouse_pressed = 0 | |
699 | - | |
700 | - def OnMouseMove(self, evt, str_evt): | |
701 | - pos = self.interactor.GetEventPosition() | |
702 | - wx = pos[0] | |
703 | - wy = pos[1] | |
704 | - | |
705 | - self.pick.Pick(wx, wy, 0, self.render) | |
706 | - x, y, z = self.picker.GetPickPosition() | |
707 | - | |
708 | - if self.mouse_pressed: | |
709 | - #wx, wy = self.From3dToImagePixel(pos, (x, y, z)) | |
710 | - wx, wy = self.pos_converter.GetImagedataCoordinates(x, y, z) | |
711 | - #self.CircleOperation(wx, wy, self.slice_) # TODO! | |
712 | - ps.Publisher().sendMessage('Update edited imagedata', self.image) | |
713 | - ps.Publisher().sendMessage('Update slice viewer', None) | |
714 | - | |
715 | - # update cursor | |
716 | - self.cursor.SetPosition(x, y, z) | |
717 | - self.cursor.Update() | |
718 | - | |
719 | - obj.OnMouseMove() | |
720 | - | |
721 | - self.interactor.Render() | |
722 | - | |
723 | -class ViewerToImagedataPosConverter(): | |
724 | - def __init__(self, actor_bounds, imagedata_dimensions, renderer): | |
725 | - self.actor_bounds = actor_bounds | |
726 | - self.imagedata_dimensions = imagedata_dimensions | |
727 | - self.renderer = renderer | |
728 | - | |
729 | - def GetImagedataCoordinates(self, picker_position): | |
730 | - x, y, z = picker_position | |
731 | - | |
732 | - c = vtk.vtkCoordinate() | |
733 | - c.SetCoordinateSystemToWorld() | |
734 | - c.SetValue(bounds[::2]) | |
735 | - xi, yi = c.GetComputedViewportValue(self.render) | |
736 | - | |
737 | - c.SetValue(bounds[1::2]) | |
738 | - xf, yf = c.GetComputedViewportValue(self.render) | |
739 | - | |
740 | - c.SetValue(x, y, z) | |
741 | - wx, wy = c.GetComputedViewportValue(self.render) | |
742 | - | |
743 | - wx = wx - xi | |
744 | - wy = wy - yi | |
745 | - | |
746 | - xf = xf - xi | |
747 | - yf = yf - yi | |
748 | - | |
749 | - wx = (wx * self.imagedata_dimensions[0]) / xf | |
750 | - wy = (wy * self.imagedata_dimensions[1]) / yf | |
751 | - | |
752 | - return wx, wy | |
753 | - | |
754 | -################################################################################ | |
755 | - | |
756 | -# style = vtk.vtkInteractorStyleImage() | |
757 | -# style.SetInteractor(interactor) | |
758 | - | |
759 | -# interactor.SetInteractorStyle(style) | |
760 | -# self.style = style | |
761 | - | |
762 | -#self.interactor.SetCursor(cursors.ZOOM_IN_CURSOR) | |
763 | - | |
764 | -################################################################################ | ... | ... |