VTK  9.1.0
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);
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  vtkSetClampMacro(Zoom, double, 0.1, 10.0);
166  vtkGetMacro(Zoom, double);
168 
170 
174  void Modified() override;
176 
178 
181  void EndInteraction() override;
183 
185 
189  void SetShouldConstrainSize(const vtkTypeBool shouldConstrainSize);
190  vtkGetMacro(ShouldConstrainSize, vtkTypeBool);
192 
194 
200  bool SetSizeConstraintDimensionSizes(const int minDimensionSize, const int maxDimensionSize);
202 
204 
207  vtkGetMacro(MinDimensionSize, int);
209 
211 
214  vtkGetMacro(MaxDimensionSize, int);
216 
217 protected:
220 
221  vtkRenderer* Renderer;
222  vtkProp* OrientationMarker;
223  vtkPolyData* Outline;
224  vtkActor2D* OutlineActor;
225 
226  unsigned long StartEventObserverId;
227 
228  static void ProcessEvents(
229  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
230 
231  // ProcessEvents() dispatches to these methods.
232  virtual void OnLeftButtonDown();
233  virtual void OnLeftButtonUp();
234  virtual void OnMouseMove();
235 
236  // observer to update the renderer's camera
237  vtkOrientationMarkerWidgetObserver* Observer;
238 
239  vtkTypeBool Interactive;
240  int Tolerance;
241  int Moving;
242  double Zoom = 1.0;
243 
244  // viewport to position/size this widget
245  double Viewport[4];
246 
247  // used to compute relative movements
248  int StartPosition[2];
249 
250  // Manage the state of the widget
251  int State;
253  {
254  Outside = 0,
260  AdjustingP4
261  };
262 
263  // Whether the min/max size constraints should be applied.
264  vtkTypeBool ShouldConstrainSize = 0;
265  // The minimum dimension size to be allowed for width and height.
266  int MinDimensionSize = 20;
267  // The maximum dimension size to be allowed for width and height.
268  int MaxDimensionSize = 500;
269 
270  // use to determine what state the mouse is over, edge1 p1, etc.
271  // returns a state from the WidgetState enum above
272  virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
273 
274  // set the cursor to the correct shape based on State argument
275  virtual void SetCursor(int state);
276 
277  // adjust the viewport depending on state
278  void MoveWidget(int X, int Y);
279  void ResizeTopLeft(int X, int Y);
280  void ResizeTopRight(int X, int Y);
281  void ResizeBottomLeft(int X, int Y);
282  void ResizeBottomRight(int X, int Y);
283 
286 
287  // Used to reverse compute the Viewport ivar with respect to the current
288  // renderer viewport
290  // Used to compute and set the viewport on the internal renderer based on the
291  // Viewport ivar. The computed viewport will be with respect to the whole
292  // render window
294 
295  // Resize the widget if it is outside of the current size constraints,
296  // or if the widget is not square.
298 
299 private:
301  void operator=(const vtkOrientationMarkerWidget&) = delete;
302 
303  // set up the actors and observers created by this widget
304  void SetupWindowInteraction();
305  // tear down up the actors and observers created by this widget
306  void TearDownWindowInteraction();
307 };
308 
309 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:40
a simple class to control print indentation
Definition: vtkIndent.h:34
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
abstract base class for most VTK objects
Definition: vtkObject.h:63
2D widget for manipulating a marker prop
void ResizeBottomLeft(int X, int Y)
virtual int ComputeStateBasedOnPosition(int X, int Y, int *pos1, int *pos2)
void SetEnabled(int) override
Enable/disable the widget.
void SetInteractive(vtkTypeBool interact)
Set/get whether to allow this widget to be interactively moved/scaled.
void SetOutlineColor(double r, double g, double b)
Set/get the color of the outline of this widget.
void ResizeTopLeft(int X, int Y)
void ResizeBottomRight(int X, int Y)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void ResizeTopRight(int X, int Y)
static vtkOrientationMarkerWidget * New()
double * GetOutlineColor()
Set/get the color of the outline of this widget.
void ExecuteCameraUpdateEvent(vtkObject *o, unsigned long event, void *calldata)
Callback to keep the camera for the orientation marker up to date with the camera in the parent rende...
virtual void SetCursor(int state)
virtual void SetOrientationMarker(vtkProp *prop)
Set/get the orientation marker to be displayed in this widget.
void MoveWidget(int X, int Y)
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
abstract specification for renderers
Definition: vtkRenderer.h:73
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)