VTK
vtkOrientationMarkerWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOrientationMarkerWidget.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
69 #ifndef vtkOrientationMarkerWidget_h
70 #define vtkOrientationMarkerWidget_h
71 
72 #include "vtkInteractionWidgetsModule.h" // For export macro
73 #include "vtkInteractorObserver.h"
74 
75 class vtkActor2D;
76 class vtkPolyData;
77 class vtkProp;
78 class vtkOrientationMarkerWidgetObserver;
79 class vtkRenderer;
80 
81 class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver
82 {
83 public:
86  void PrintSelf(ostream& os, vtkIndent indent) override;
87 
89 
92  virtual void SetOrientationMarker(vtkProp *prop);
93  vtkGetObjectMacro(OrientationMarker, vtkProp);
95 
99  void SetEnabled(int) override;
100 
105  void ExecuteCameraUpdateEvent(vtkObject *o, unsigned long event, void *calldata);
106 
108 
112  void SetInteractive(vtkTypeBool state);
113  vtkGetMacro(Interactive, vtkTypeBool);
114  vtkBooleanMacro(Interactive, vtkTypeBool);
116 
118 
123  void SetOutlineColor(double r, double g, double b);
124  double *GetOutlineColor();
126 
128 
140  vtkSetVector4Macro(Viewport, double);
141  vtkGetVector4Macro(Viewport, double);
143 
145 
150  vtkSetClampMacro(Tolerance,int,1,10);
151  vtkGetMacro(Tolerance,int);
153 
155 
159  void Modified() override;
161 
162 protected:
164  ~vtkOrientationMarkerWidget() override;
165 
170 
171  unsigned long StartEventObserverId;
172 
173  static void ProcessEvents(vtkObject *object, unsigned long event,
174  void *clientdata, void *calldata);
175 
176  // ProcessEvents() dispatches to these methods.
177  virtual void OnLeftButtonDown();
178  virtual void OnLeftButtonUp();
179  virtual void OnMouseMove();
180 
181  // observer to update the renderer's camera
182  vtkOrientationMarkerWidgetObserver *Observer;
183 
186  int Moving;
187 
188  // viewport to position/size this widget
189  double Viewport[4];
190 
191  // used to compute relative movements
192  int StartPosition[2];
193 
194  // Manage the state of the widget
195  int State;
197  {
198  Outside = 0,
204  AdjustingP4
205  };
206 
207 
208  // use to determine what state the mouse is over, edge1 p1, etc.
209  // returns a state from the WidgetState enum above
210  virtual int ComputeStateBasedOnPosition(int X, int Y, int *pos1, int *pos2);
211 
212  // set the cursor to the correct shape based on State argument
213  virtual void SetCursor(int state);
214 
215  // adjust the viewport depending on state
216  void MoveWidget(int X, int Y);
217  void ResizeTopLeft(int X, int Y);
218  void ResizeTopRight(int X, int Y);
219  void ResizeBottomLeft(int X, int Y);
220  void ResizeBottomRight(int X, int Y);
221 
222  void SquareRenderer();
223  void UpdateOutline();
224 
225  // Used to reverse compute the Viewport ivar with respect to the current
226  // renderer viewport
227  void UpdateViewport();
228  // Used to compute and set the viewport on the internal renderer based on the
229  // Viewport ivar. The computed viewport will be with respect to the whole
230  // render window
231  void UpdateInternalViewport();
232 
233 private:
235  void operator=(const vtkOrientationMarkerWidget&) = delete;
236 
237  //set up the actors and observers created by this widget
238  void SetupWindowInteraction();
239  //tear down up the actors and observers created by this widget
240  void TearDownWindowInteraction();
241 };
242 
243 #endif
vtkOrientationMarkerWidget::OutlineActor
vtkActor2D * OutlineActor
Definition: vtkOrientationMarkerWidget.h:169
vtkOrientationMarkerWidget::Moving
int Moving
Definition: vtkOrientationMarkerWidget.h:186
vtkOrientationMarkerWidget::OrientationMarker
vtkProp * OrientationMarker
Definition: vtkOrientationMarkerWidget.h:167
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkOrientationMarkerWidget::Translating
Definition: vtkOrientationMarkerWidget.h:200
vtkInteractorObserver
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
Definition: vtkInteractorObserver.h:59
vtkOrientationMarkerWidget::StartEventObserverId
unsigned long StartEventObserverId
Definition: vtkOrientationMarkerWidget.h:171
vtkOrientationMarkerWidget::Renderer
vtkRenderer * Renderer
Definition: vtkOrientationMarkerWidget.h:166
vtkOrientationMarkerWidget::AdjustingP3
Definition: vtkOrientationMarkerWidget.h:203
vtkOrientationMarkerWidget::AdjustingP1
Definition: vtkOrientationMarkerWidget.h:201
vtkInteractorObserver::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkOrientationMarkerWidget::Observer
vtkOrientationMarkerWidgetObserver * Observer
Definition: vtkOrientationMarkerWidget.h:182
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:73
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkOrientationMarkerWidget::AdjustingP2
Definition: vtkOrientationMarkerWidget.h:202
vtkOrientationMarkerWidget::State
int State
Definition: vtkOrientationMarkerWidget.h:195
vtkOrientationMarkerWidget::Interactive
vtkTypeBool Interactive
Definition: vtkOrientationMarkerWidget.h:184
vtkInteractorObserver::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkOrientationMarkerWidget::Tolerance
int Tolerance
Definition: vtkOrientationMarkerWidget.h:185
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:39
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:57
vtkInteractorObserver.h
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkOrientationMarkerWidget::Inside
Definition: vtkOrientationMarkerWidget.h:199
vtkOrientationMarkerWidget
2D widget for manipulating a marker prop
Definition: vtkOrientationMarkerWidget.h:81
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkOrientationMarkerWidget::Outline
vtkPolyData * Outline
Definition: vtkOrientationMarkerWidget.h:168
vtkOrientationMarkerWidget::WidgetState
WidgetState
Definition: vtkOrientationMarkerWidget.h:196