VTK  9.3.0
vtkOrientationMarkerWidget.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
72 #ifndef vtkOrientationMarkerWidget_h
73 #define vtkOrientationMarkerWidget_h
74 
75 #include "vtkInteractionWidgetsModule.h" // For export macro
76 #include "vtkInteractorObserver.h"
77 
78 VTK_ABI_NAMESPACE_BEGIN
79 class vtkActor2D;
80 class vtkPolyData;
81 class vtkProp;
82 class vtkOrientationMarkerWidgetObserver;
83 class vtkRenderer;
84 
85 class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver
86 {
87 public:
90  void PrintSelf(ostream& os, vtkIndent indent) override;
91 
93 
96  virtual void SetOrientationMarker(vtkProp* prop);
97  vtkGetObjectMacro(OrientationMarker, vtkProp);
99 
103  void SetEnabled(int) override;
104 
109  void ExecuteCameraUpdateEvent(vtkObject* o, unsigned long event, void* calldata);
110 
112 
116  void SetInteractive(vtkTypeBool interact);
117  vtkGetMacro(Interactive, vtkTypeBool);
118  vtkBooleanMacro(Interactive, vtkTypeBool);
120 
122 
127  void SetOutlineColor(double r, double g, double b);
130 
132 
144  vtkSetVector4Macro(Viewport, double);
145  vtkGetVector4Macro(Viewport, double);
147 
149 
154  vtkSetClampMacro(Tolerance, int, 1, 10);
155  vtkGetMacro(Tolerance, int);
157 
159 
163  vtkSetClampMacro(Zoom, double, 0.1, 10.0);
164  vtkGetMacro(Zoom, double);
166 
168 
172  void Modified() override;
174 
176 
179  void EndInteraction() override;
181 
183 
187  void SetShouldConstrainSize(vtkTypeBool shouldConstrainSize);
188  vtkGetMacro(ShouldConstrainSize, vtkTypeBool);
190 
192 
198  bool SetSizeConstraintDimensionSizes(int minDimensionSize, int maxDimensionSize);
200 
202 
205  vtkGetMacro(MinDimensionSize, int);
207 
209 
212  vtkGetMacro(MaxDimensionSize, int);
214 
215 protected:
218 
219  vtkRenderer* Renderer;
220  vtkProp* OrientationMarker;
221  vtkPolyData* Outline;
222  vtkActor2D* OutlineActor;
223 
224  unsigned long StartEventObserverId;
225 
226  static void ProcessEvents(
227  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
228 
229  // ProcessEvents() dispatches to these methods.
230  virtual void OnLeftButtonDown();
231  virtual void OnLeftButtonUp();
232  virtual void OnMouseMove();
233 
234  // observer to update the renderer's camera
235  vtkOrientationMarkerWidgetObserver* Observer;
236 
237  vtkTypeBool Interactive;
238  int Tolerance;
239  int Moving;
240  double Zoom = 1.0;
241 
242  // viewport to position/size this widget
243  double Viewport[4];
244 
245  // used to compute relative movements
246  int StartPosition[2];
247 
248  // Manage the state of the widget
249  int State;
251  {
252  Outside = 0,
258  AdjustingP4
259  };
260 
261  // Whether the min/max size constraints should be applied.
262  vtkTypeBool ShouldConstrainSize = 0;
263  // The minimum dimension size to be allowed for width and height.
264  int MinDimensionSize = 20;
265  // The maximum dimension size to be allowed for width and height.
266  int MaxDimensionSize = 500;
267 
268  // use to determine what state the mouse is over, edge1 p1, etc.
269  // returns a state from the WidgetState enum above
270  virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
271 
272  // set the cursor to the correct shape based on State argument
273  virtual void SetCursor(int state);
274 
275  // adjust the viewport depending on state
276  void MoveWidget(int X, int Y);
277  void ResizeTopLeft(int X, int Y);
278  void ResizeTopRight(int X, int Y);
279  void ResizeBottomLeft(int X, int Y);
280  void ResizeBottomRight(int X, int Y);
281 
284 
285  // Used to reverse compute the Viewport ivar with respect to the current
286  // renderer viewport
288  // Used to compute and set the viewport on the internal renderer based on the
289  // Viewport ivar. The computed viewport will be with respect to the whole
290  // render window
292 
293  // Resize the widget if it is outside of the current size constraints,
294  // or if the widget is not square.
296 
297 private:
299  void operator=(const vtkOrientationMarkerWidget&) = delete;
300 
301  // set up the actors and observers created by this widget
302  void SetupWindowInteraction();
303  // tear down up the actors and observers created by this widget
304  void TearDownWindowInteraction();
305 };
306 
307 VTK_ABI_NAMESPACE_END
308 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:44
a simple class to control print indentation
Definition: vtkIndent.h:38
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
abstract base class for most VTK objects
Definition: vtkObject.h:61
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:89
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:55
abstract specification for renderers
Definition: vtkRenderer.h:71
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_SIZEHINT(...)