def __init__(self, scene=None): logging.debug("In Protractor::__init__()") self._status = 0 self._angleWidget = vtk.vtkAngleWidget() self._handle = vtk.vtkPointHandleRepresentation3D() self._representation = vtk.vtkAngleRepresentation2D() self._representation.SetHandleRepresentation(self._handle) self._angleWidget.CreateDefaultRepresentation() self._angleWidget.SetRepresentation(self._representation) self._angleWidget.parent = self self._started = False self._pointColor = self._handle.GetProperty().GetColor() self._lineColor = self._representation.GetRay1().GetProperty().GetColor() self._fontColor = self._representation.GetArc().GetLabelTextProperty().GetColor() self._placePointEvent = self._angleWidget.AddObserver("PlacePointEvent", self._startEvent)
def __init__(self, parent, visualizer, **kws): """ Initialization """ self.x, self.y, self.z = -1, -1, -1 VisualizationModule.__init__(self, parent, visualizer, **kws) self.on = 0 self.renew = 1 self.angleWidget = vtk.vtkAngleWidget() self.obsTag = self.angleWidget.AddObserver("EndInteractionEvent", self.onPlacePoint) self.angleWidget.CreateDefaultRepresentation() self.representation = self.angleWidget.GetRepresentation() self.renderer = self.parent.getRenderer() iactor = self.wxrenwin.GetRenderWindow().GetInteractor() self.angleWidget.SetInteractor(iactor) self.picker = vtk.vtkCellPicker() #self.picker.SetTolerance(0.05) self.filterDesc = "Measure angle in 3D view"
iren.SetRenderWindow(renWin) # Create a test pipeline ss = vtk.vtkSphereSource() mapper = vtk.vtkPolyDataMapper() mapper.SetInput(ss.GetOutput()) actor = vtk.vtkActor() actor.SetMapper(mapper) # Create the widget and its representation handle = vtk.vtkPointHandleRepresentation2D() handle.GetProperty().SetColor(1, 0, 0) rep = vtk.vtkAngleRepresentation2D() rep.SetHandleRepresentation(handle) widget = vtk.vtkAngleWidget() widget.SetInteractor(iren) widget.CreateDefaultRepresentation() widget.SetRepresentation(rep) widget.AddObserver("PlacePointEvent", vtkAngleCallback) widget.AddObserver("InteractionEvent", vtkAngleCallback) # Add the actor to the renderer, set the background and size ren1.AddActor(actor) ren1.SetBackground(0.1, 0.2, 0.4) renWin.SetSize(300, 300) # record events recorder = vtk.vtkInteractorEventRecorder() recorder.SetInteractor(iren)