VTK  9.0.20201030
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 =========================================================================*/
75 #ifndef vtkOrientationMarkerWidget_h
76 #define vtkOrientationMarkerWidget_h
77 
78 #include "vtkInteractionWidgetsModule.h" // For export macro
79 #include "vtkInteractorObserver.h"
80 
81 class vtkActor2D;
82 class vtkPolyData;
83 class vtkProp;
84 class vtkOrientationMarkerWidgetObserver;
85 class vtkRenderer;
86 
87 class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver
88 {
89 public:
92  void PrintSelf(ostream& os, vtkIndent indent) override;
93 
95 
98  virtual void SetOrientationMarker(vtkProp* prop);
99  vtkGetObjectMacro(OrientationMarker, vtkProp);
101 
105  void SetEnabled(int) override;
106 
111  void ExecuteCameraUpdateEvent(vtkObject* o, unsigned long event, void* calldata);
112 
114 
118  void SetInteractive(vtkTypeBool interact);
119  vtkGetMacro(Interactive, vtkTypeBool);
120  vtkBooleanMacro(Interactive, vtkTypeBool);
122 
124 
129  void SetOutlineColor(double r, double g, double b);
130  double* GetOutlineColor() VTK_SIZEHINT(3);
132 
134 
146  vtkSetVector4Macro(Viewport, double);
147  vtkGetVector4Macro(Viewport, double);
149 
151 
156  vtkSetClampMacro(Tolerance, int, 1, 10);
157  vtkGetMacro(Tolerance, int);
159 
161 
165  void Modified() override;
167 
168 protected:
170  ~vtkOrientationMarkerWidget() override;
171 
172  vtkRenderer* Renderer;
173  vtkProp* OrientationMarker;
174  vtkPolyData* Outline;
175  vtkActor2D* OutlineActor;
176 
177  unsigned long StartEventObserverId;
178 
179  static void ProcessEvents(
180  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
181 
182  // ProcessEvents() dispatches to these methods.
183  virtual void OnLeftButtonDown();
184  virtual void OnLeftButtonUp();
185  virtual void OnMouseMove();
186 
187  // observer to update the renderer's camera
188  vtkOrientationMarkerWidgetObserver* Observer;
189 
190  vtkTypeBool Interactive;
191  int Tolerance;
192  int Moving;
193 
194  // viewport to position/size this widget
195  double Viewport[4];
196 
197  // used to compute relative movements
198  int StartPosition[2];
199 
200  // Manage the state of the widget
201  int State;
203  {
204  Outside = 0,
210  AdjustingP4
211  };
212 
213  // use to determine what state the mouse is over, edge1 p1, etc.
214  // returns a state from the WidgetState enum above
215  virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
216 
217  // set the cursor to the correct shape based on State argument
218  virtual void SetCursor(int state);
219 
220  // adjust the viewport depending on state
221  void MoveWidget(int X, int Y);
222  void ResizeTopLeft(int X, int Y);
223  void ResizeTopRight(int X, int Y);
224  void ResizeBottomLeft(int X, int Y);
225  void ResizeBottomRight(int X, int Y);
226 
227  void SquareRenderer();
228  void UpdateOutline();
229 
230  // Used to reverse compute the Viewport ivar with respect to the current
231  // renderer viewport
232  void UpdateViewport();
233  // Used to compute and set the viewport on the internal renderer based on the
234  // Viewport ivar. The computed viewport will be with respect to the whole
235  // render window
236  void UpdateInternalViewport();
237 
238 private:
240  void operator=(const vtkOrientationMarkerWidget&) = delete;
241 
242  // set up the actors and observers created by this widget
243  void SetupWindowInteraction();
244  // tear down up the actors and observers created by this widget
245  void TearDownWindowInteraction();
246 };
247 
248 #endif
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkOrientationMarkerWidget::Translating
Definition: vtkOrientationMarkerWidget.h:206
vtkInteractorObserver
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
Definition: vtkInteractorObserver.h:65
vtkOrientationMarkerWidget::AdjustingP3
Definition: vtkOrientationMarkerWidget.h:209
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkOrientationMarkerWidget::AdjustingP1
Definition: vtkOrientationMarkerWidget.h:207
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:79
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkOrientationMarkerWidget::AdjustingP2
Definition: vtkOrientationMarkerWidget.h:208
vtkInteractorObserver::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:39
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
vtkInteractorObserver.h
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkOrientationMarkerWidget::Inside
Definition: vtkOrientationMarkerWidget.h:205
vtkOrientationMarkerWidget
2D widget for manipulating a marker prop
Definition: vtkOrientationMarkerWidget.h:87
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkOrientationMarkerWidget::WidgetState
WidgetState
Definition: vtkOrientationMarkerWidget.h:202