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=========================================================================*/
84#ifndef vtkOrientationMarkerWidget_h
85#define vtkOrientationMarkerWidget_h
86
87#include "vtkInteractionWidgetsModule.h" // For export macro
89
90class vtkActor2D;
91class vtkPolyData;
92class vtkProp;
93class vtkOrientationMarkerWidgetObserver;
94class vtkRenderer;
95
96class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver
97{
98public:
101 void PrintSelf(ostream& os, vtkIndent indent) override;
102
104
107 virtual void SetOrientationMarker(vtkProp* prop);
108 vtkGetObjectMacro(OrientationMarker, vtkProp);
110
114 void SetEnabled(int) override;
115
120 void ExecuteCameraUpdateEvent(vtkObject* o, unsigned long event, void* calldata);
121
123
128 vtkGetMacro(Interactive, vtkTypeBool);
129 vtkBooleanMacro(Interactive, vtkTypeBool);
131
133
138 void SetOutlineColor(double r, double g, double b);
141
143
155 vtkSetVector4Macro(Viewport, double);
156 vtkGetVector4Macro(Viewport, double);
158
160
165 vtkSetClampMacro(Tolerance, int, 1, 10);
166 vtkGetMacro(Tolerance, int);
168
170
174 vtkSetClampMacro(Zoom, double, 0.1, 10.0);
175 vtkGetMacro(Zoom, double);
177
179
183 void Modified() override;
185
187
190 void EndInteraction() override;
192
194
198 void SetShouldConstrainSize(const vtkTypeBool shouldConstrainSize);
199 vtkGetMacro(ShouldConstrainSize, vtkTypeBool);
201
203
209 bool SetSizeConstraintDimensionSizes(const int minDimensionSize, const int maxDimensionSize);
211
213
216 vtkGetMacro(MinDimensionSize, int);
218
220
223 vtkGetMacro(MaxDimensionSize, int);
225
226protected:
229
230 vtkRenderer* Renderer;
231 vtkProp* OrientationMarker;
232 vtkPolyData* Outline;
233 vtkActor2D* OutlineActor;
234
235 unsigned long StartEventObserverId;
236
237 static void ProcessEvents(
238 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
239
240 // ProcessEvents() dispatches to these methods.
241 virtual void OnLeftButtonDown();
242 virtual void OnLeftButtonUp();
243 virtual void OnMouseMove();
244
245 // observer to update the renderer's camera
246 vtkOrientationMarkerWidgetObserver* Observer;
247
248 vtkTypeBool Interactive;
249 int Tolerance;
250 int Moving;
251 double Zoom = 1.0;
252
253 // viewport to position/size this widget
254 double Viewport[4];
255
256 // used to compute relative movements
257 int StartPosition[2];
258
259 // Manage the state of the widget
260 int State;
262 {
263 Outside = 0,
269 AdjustingP4
270 };
271
272 // Whether the min/max size constraints should be applied.
273 vtkTypeBool ShouldConstrainSize = 0;
274 // The minimum dimension size to be allowed for width and height.
275 int MinDimensionSize = 20;
276 // The maximum dimension size to be allowed for width and height.
277 int MaxDimensionSize = 500;
278
279 // use to determine what state the mouse is over, edge1 p1, etc.
280 // returns a state from the WidgetState enum above
281 virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
282
283 // set the cursor to the correct shape based on State argument
284 virtual void SetCursor(int state);
285
286 // adjust the viewport depending on state
287 void MoveWidget(int X, int Y);
288 void ResizeTopLeft(int X, int Y);
289 void ResizeTopRight(int X, int Y);
290 void ResizeBottomLeft(int X, int Y);
291 void ResizeBottomRight(int X, int Y);
292
295
296 // Used to reverse compute the Viewport ivar with respect to the current
297 // renderer viewport
299 // Used to compute and set the viewport on the internal renderer based on the
300 // Viewport ivar. The computed viewport will be with respect to the whole
301 // render window
303
304 // Resize the widget if it is outside of the current size constraints,
305 // or if the widget is not square.
307
308private:
310 void operator=(const vtkOrientationMarkerWidget&) = delete;
311
312 // set up the actors and observers created by this widget
313 void SetupWindowInteraction();
314 // tear down up the actors and observers created by this widget
315 void TearDownWindowInteraction();
316};
317
318#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:72
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:66
abstract specification for renderers
Definition: vtkRenderer.h:82
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)