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=========================================================================*/
78#ifndef vtkOrientationMarkerWidget_h
79#define vtkOrientationMarkerWidget_h
80
81#include "vtkInteractionWidgetsModule.h" // For export macro
83
84class vtkActor2D;
85class vtkPolyData;
86class vtkProp;
87class vtkOrientationMarkerWidgetObserver;
88class vtkRenderer;
89
90class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver
91{
92public:
95 void PrintSelf(ostream& os, vtkIndent indent) override;
96
98
101 virtual void SetOrientationMarker(vtkProp* prop);
102 vtkGetObjectMacro(OrientationMarker, vtkProp);
104
108 void SetEnabled(int) override;
109
114 void ExecuteCameraUpdateEvent(vtkObject* o, unsigned long event, void* calldata);
115
117
122 vtkGetMacro(Interactive, vtkTypeBool);
123 vtkBooleanMacro(Interactive, vtkTypeBool);
125
127
132 void SetOutlineColor(double r, double g, double b);
135
137
149 vtkSetVector4Macro(Viewport, double);
150 vtkGetVector4Macro(Viewport, double);
152
154
159 vtkSetClampMacro(Tolerance, int, 1, 10);
160 vtkGetMacro(Tolerance, int);
162
164
168 vtkSetClampMacro(Zoom, double, 0.1, 10.0);
169 vtkGetMacro(Zoom, double);
171
173
177 void Modified() override;
179
181
184 void EndInteraction() override;
186
188
192 void SetShouldConstrainSize(const vtkTypeBool shouldConstrainSize);
193 vtkGetMacro(ShouldConstrainSize, vtkTypeBool);
195
197
203 bool SetSizeConstraintDimensionSizes(const int minDimensionSize, const int maxDimensionSize);
205
207
210 vtkGetMacro(MinDimensionSize, int);
212
214
217 vtkGetMacro(MaxDimensionSize, int);
219
220protected:
223
224 vtkRenderer* Renderer;
225 vtkProp* OrientationMarker;
226 vtkPolyData* Outline;
227 vtkActor2D* OutlineActor;
228
229 unsigned long StartEventObserverId;
230
231 static void ProcessEvents(
232 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
233
234 // ProcessEvents() dispatches to these methods.
235 virtual void OnLeftButtonDown();
236 virtual void OnLeftButtonUp();
237 virtual void OnMouseMove();
238
239 // observer to update the renderer's camera
240 vtkOrientationMarkerWidgetObserver* Observer;
241
242 vtkTypeBool Interactive;
243 int Tolerance;
244 int Moving;
245 double Zoom = 1.0;
246
247 // viewport to position/size this widget
248 double Viewport[4];
249
250 // used to compute relative movements
251 int StartPosition[2];
252
253 // Manage the state of the widget
254 int State;
256 {
257 Outside = 0,
263 AdjustingP4
264 };
265
266 // Whether the min/max size constraints should be applied.
267 vtkTypeBool ShouldConstrainSize = 0;
268 // The minimum dimension size to be allowed for width and height.
269 int MinDimensionSize = 20;
270 // The maximum dimension size to be allowed for width and height.
271 int MaxDimensionSize = 500;
272
273 // use to determine what state the mouse is over, edge1 p1, etc.
274 // returns a state from the WidgetState enum above
275 virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
276
277 // set the cursor to the correct shape based on State argument
278 virtual void SetCursor(int state);
279
280 // adjust the viewport depending on state
281 void MoveWidget(int X, int Y);
282 void ResizeTopLeft(int X, int Y);
283 void ResizeTopRight(int X, int Y);
284 void ResizeBottomLeft(int X, int Y);
285 void ResizeBottomRight(int X, int Y);
286
289
290 // Used to reverse compute the Viewport ivar with respect to the current
291 // renderer viewport
293 // Used to compute and set the viewport on the internal renderer based on the
294 // Viewport ivar. The computed viewport will be with respect to the whole
295 // render window
297
298 // Resize the widget if it is outside of the current size constraints,
299 // or if the widget is not square.
301
302private:
304 void operator=(const vtkOrientationMarkerWidget&) = delete;
305
306 // set up the actors and observers created by this widget
307 void SetupWindowInteraction();
308 // tear down up the actors and observers created by this widget
309 void TearDownWindowInteraction();
310};
311
312#endif
a actor that draws 2D data
Definition: vtkActor2D.h:49
a simple class to control print indentation
Definition: vtkIndent.h:43
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
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:95
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(...)