VTK  9.7.1
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
63 #ifndef vtkOrientationMarkerWidget_h
64 #define vtkOrientationMarkerWidget_h
65 
66 #include "vtkInteractionWidgetsModule.h" // For export macro
67 #include "vtkInteractorObserver.h"
68 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
69 
70 VTK_ABI_NAMESPACE_BEGIN
71 class vtkActor2D;
72 class vtkPolyData;
73 class vtkProp;
74 class vtkOrientationMarkerWidgetObserver;
75 class vtkRenderer;
76 
77 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkOrientationMarkerWidget
78  : public vtkInteractorObserver
79 {
80 public:
83  void PrintSelf(ostream& os, vtkIndent indent) override;
84 
89  void SetRenderer(vtkRenderer* renderer);
90  vtkRenderer* GetRenderer();
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);
128  double* GetOutlineColor() VTK_SIZEHINT(3);
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:
217  ~vtkOrientationMarkerWidget() override;
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  bool OrientationMarkerBound = false;
269  bool RendererBound = false;
270  bool EventsBound = false;
271 
272  // use to determine what state the mouse is over, edge1 p1, etc.
273  // returns a state from the WidgetState enum above
274  virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
275 
276  // set the cursor to the correct shape based on State argument
277  virtual void SetCursor(int state);
278 
279  // adjust the viewport depending on state
280  void MoveWidget(int X, int Y);
281  void ResizeTopLeft(int X, int Y);
282  void ResizeTopRight(int X, int Y);
283  void ResizeBottomLeft(int X, int Y);
284  void ResizeBottomRight(int X, int Y);
285 
286  void SquareRenderer();
287  void UpdateOutline();
288 
289  // Used to reverse compute the Viewport ivar with respect to the current
290  // renderer viewport
291  void UpdateViewport();
292  // Used to compute and set the viewport on the internal renderer based on the
293  // Viewport ivar. The computed viewport will be with respect to the whole
294  // render window
295  void UpdateInternalViewport();
296 
297  // Resize the widget if it is outside of the current size constraints,
298  // or if the widget is not square.
299  void ResizeToFitSizeConstraints();
300 
301  void BindOrientationMarker();
302  void UnBindOrientationMarker();
303  void BindRenderer();
304  void UnBindRenderer();
305  void BindEvents();
306  void UnBindEvents();
307 
308 private:
310  void operator=(const vtkOrientationMarkerWidget&) = delete;
311 };
312 
313 VTK_ABI_NAMESPACE_END
314 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
abstract base class for most VTK objects
Definition: vtkObject.h:52
a actor that draws 2D data
Definition: vtkActor2D.h:35
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
2D widget for manipulating a marker prop
abstract specification for renderers
Definition: vtkRenderer.h:63
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor ...
int vtkTypeBool
Definition: vtkABI.h:64
a simple class to control print indentation
Definition: vtkIndent.h:28
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...