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=========================================================================*/
69#ifndef vtkOrientationMarkerWidget_h
70#define vtkOrientationMarkerWidget_h
71
72#include "vtkInteractionWidgetsModule.h" // For export macro
74
75class vtkActor2D;
76class vtkPolyData;
77class vtkProp;
78class vtkOrientationMarkerWidgetObserver;
79class vtkRenderer;
80
81class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver
82{
83public:
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
113 vtkGetMacro(Interactive, vtkTypeBool);
114 vtkBooleanMacro(Interactive, vtkTypeBool);
116
118
123 void SetOutlineColor(double r, double g, double b);
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 vtkSetClampMacro(Zoom, double, 0.1, 10.0);
160 vtkGetMacro(Zoom, double);
162
164
168 void Modified() override;
170
172
175 void EndInteraction() override;
177
179
183 void SetShouldConstrainSize(const vtkTypeBool shouldConstrainSize);
184 vtkGetMacro(ShouldConstrainSize, vtkTypeBool);
186
188
194 bool SetSizeConstraintDimensionSizes(const int minDimensionSize, const int maxDimensionSize);
196
198
201 vtkGetMacro(MinDimensionSize, int);
203
205
208 vtkGetMacro(MaxDimensionSize, int);
210
211protected:
214
215 vtkRenderer* Renderer;
216 vtkProp* OrientationMarker;
217 vtkPolyData* Outline;
218 vtkActor2D* OutlineActor;
219
220 unsigned long StartEventObserverId;
221
222 static void ProcessEvents(
223 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
224
225 // ProcessEvents() dispatches to these methods.
226 virtual void OnLeftButtonDown();
227 virtual void OnLeftButtonUp();
228 virtual void OnMouseMove();
229
230 // observer to update the renderer's camera
231 vtkOrientationMarkerWidgetObserver* Observer;
232
233 vtkTypeBool Interactive;
234 int Tolerance;
235 int Moving;
236 double Zoom = 1.0;
237
238 // viewport to position/size this widget
239 double Viewport[4];
240
241 // used to compute relative movements
242 int StartPosition[2];
243
244 // Manage the state of the widget
245 int State;
247 {
248 Outside = 0,
254 AdjustingP4
255 };
256
257 // Whether the min/max size constraints should be applied.
258 vtkTypeBool ShouldConstrainSize = 0;
259 // The minimum dimension size to be allowed for width and height.
260 int MinDimensionSize = 20;
261 // The maximum dimension size to be allowed for width and height.
262 int MaxDimensionSize = 500;
263
264 // use to determine what state the mouse is over, edge1 p1, etc.
265 // returns a state from the WidgetState enum above
266 virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
267
268 // set the cursor to the correct shape based on State argument
269 virtual void SetCursor(int state);
270
271 // adjust the viewport depending on state
272 void MoveWidget(int X, int Y);
273 void ResizeTopLeft(int X, int Y);
274 void ResizeTopRight(int X, int Y);
275 void ResizeBottomLeft(int X, int Y);
276 void ResizeBottomRight(int X, int Y);
277
280
281 // Used to reverse compute the Viewport ivar with respect to the current
282 // renderer viewport
284 // Used to compute and set the viewport on the internal renderer based on the
285 // Viewport ivar. The computed viewport will be with respect to the whole
286 // render window
288
289 // Resize the widget if it is outside of the current size constraints,
290 // or if the widget is not square.
292
293private:
295 void operator=(const vtkOrientationMarkerWidget&) = delete;
296
297 // set up the actors and observers created by this widget
298 void SetupWindowInteraction();
299 // tear down up the actors and observers created by this widget
300 void TearDownWindowInteraction();
301};
302
303#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:54
2D widget for manipulating a marker prop
double * GetOutlineColor()
Set/get the color of the outline of this widget.
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)
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)
static vtkOrientationMarkerWidget * New()
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:86
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:48
abstract specification for renderers
Definition vtkRenderer.h:64
int vtkTypeBool
Definition vtkABI.h:69
#define VTK_SIZEHINT(...)