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
63 #ifndef vtkOrientationMarkerWidget_h
64 #define vtkOrientationMarkerWidget_h
65 
66 #include "vtkInteractionWidgetsModule.h" // For export macro
67 #include "vtkInteractorObserver.h"
68 
69 VTK_ABI_NAMESPACE_BEGIN
70 class vtkActor2D;
71 class vtkPolyData;
72 class vtkProp;
73 class vtkOrientationMarkerWidgetObserver;
74 class vtkRenderer;
75 
76 class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver
77 {
78 public:
81  void PrintSelf(ostream& os, vtkIndent indent) override;
82 
84 
87  virtual void SetOrientationMarker(vtkProp* prop);
88  vtkGetObjectMacro(OrientationMarker, vtkProp);
90 
94  void SetEnabled(int) override;
95 
100  void ExecuteCameraUpdateEvent(vtkObject* o, unsigned long event, void* calldata);
101 
103 
107  void SetInteractive(vtkTypeBool interact);
108  vtkGetMacro(Interactive, vtkTypeBool);
109  vtkBooleanMacro(Interactive, vtkTypeBool);
111 
113 
118  void SetOutlineColor(double r, double g, double b);
121 
123 
135  vtkSetVector4Macro(Viewport, double);
136  vtkGetVector4Macro(Viewport, double);
138 
140 
145  vtkSetClampMacro(Tolerance, int, 1, 10);
146  vtkGetMacro(Tolerance, int);
148 
150 
154  vtkSetClampMacro(Zoom, double, 0.1, 10.0);
155  vtkGetMacro(Zoom, double);
157 
159 
163  void Modified() override;
165 
167 
170  void EndInteraction() override;
172 
174 
178  void SetShouldConstrainSize(vtkTypeBool shouldConstrainSize);
179  vtkGetMacro(ShouldConstrainSize, vtkTypeBool);
181 
183 
189  bool SetSizeConstraintDimensionSizes(int minDimensionSize, int maxDimensionSize);
191 
193 
196  vtkGetMacro(MinDimensionSize, int);
198 
200 
203  vtkGetMacro(MaxDimensionSize, int);
205 
206 protected:
209 
210  vtkRenderer* Renderer;
211  vtkProp* OrientationMarker;
212  vtkPolyData* Outline;
213  vtkActor2D* OutlineActor;
214 
215  unsigned long StartEventObserverId;
216 
217  static void ProcessEvents(
218  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
219 
220  // ProcessEvents() dispatches to these methods.
221  virtual void OnLeftButtonDown();
222  virtual void OnLeftButtonUp();
223  virtual void OnMouseMove();
224 
225  // observer to update the renderer's camera
226  vtkOrientationMarkerWidgetObserver* Observer;
227 
228  vtkTypeBool Interactive;
229  int Tolerance;
230  int Moving;
231  double Zoom = 1.0;
232 
233  // viewport to position/size this widget
234  double Viewport[4];
235 
236  // used to compute relative movements
237  int StartPosition[2];
238 
239  // Manage the state of the widget
240  int State;
242  {
243  Outside = 0,
249  AdjustingP4
250  };
251 
252  // Whether the min/max size constraints should be applied.
253  vtkTypeBool ShouldConstrainSize = 0;
254  // The minimum dimension size to be allowed for width and height.
255  int MinDimensionSize = 20;
256  // The maximum dimension size to be allowed for width and height.
257  int MaxDimensionSize = 500;
258 
259  // use to determine what state the mouse is over, edge1 p1, etc.
260  // returns a state from the WidgetState enum above
261  virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
262 
263  // set the cursor to the correct shape based on State argument
264  virtual void SetCursor(int state);
265 
266  // adjust the viewport depending on state
267  void MoveWidget(int X, int Y);
268  void ResizeTopLeft(int X, int Y);
269  void ResizeTopRight(int X, int Y);
270  void ResizeBottomLeft(int X, int Y);
271  void ResizeBottomRight(int X, int Y);
272 
275 
276  // Used to reverse compute the Viewport ivar with respect to the current
277  // renderer viewport
279  // Used to compute and set the viewport on the internal renderer based on the
280  // Viewport ivar. The computed viewport will be with respect to the whole
281  // render window
283 
284  // Resize the widget if it is outside of the current size constraints,
285  // or if the widget is not square.
287 
288 private:
290  void operator=(const vtkOrientationMarkerWidget&) = delete;
291 
292  // set up the actors and observers created by this widget
293  void SetupWindowInteraction();
294  // tear down up the actors and observers created by this widget
295  void TearDownWindowInteraction();
296 };
297 
298 VTK_ABI_NAMESPACE_END
299 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:35
a simple class to control print indentation
Definition: vtkIndent.h:29
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
abstract base class for most VTK objects
Definition: vtkObject.h:52
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:80
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
abstract specification for renderers
Definition: vtkRenderer.h:62
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_SIZEHINT(...)