VTK  9.3.20240424
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
172#ifndef vtkOrientationMarkerWidget_h
173#define vtkOrientationMarkerWidget_h
174
175#include "vtkInteractionWidgetsModule.h" // For export macro
177
178VTK_ABI_NAMESPACE_BEGIN
179class vtkActor2D;
180class vtkPolyData;
181class vtkProp;
182class vtkOrientationMarkerWidgetObserver;
183class vtkRenderer;
184
185class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver
186{
187public:
190 void PrintSelf(ostream& os, vtkIndent indent) override;
191
193
196 virtual void SetOrientationMarker(vtkProp* prop);
197 vtkGetObjectMacro(OrientationMarker, vtkProp);
199
203 void SetEnabled(int) override;
204
209 void ExecuteCameraUpdateEvent(vtkObject* o, unsigned long event, void* calldata);
210
212
217 vtkGetMacro(Interactive, vtkTypeBool);
218 vtkBooleanMacro(Interactive, vtkTypeBool);
220
222
227 void SetOutlineColor(double r, double g, double b);
230
232
244 vtkSetVector4Macro(Viewport, double);
245 vtkGetVector4Macro(Viewport, double);
247
249
254 vtkSetClampMacro(Tolerance, int, 1, 10);
255 vtkGetMacro(Tolerance, int);
257
259
263 vtkSetClampMacro(Zoom, double, 0.1, 10.0);
264 vtkGetMacro(Zoom, double);
266
268
272 void Modified() override;
274
276
279 void EndInteraction() override;
281
283
287 void SetShouldConstrainSize(vtkTypeBool shouldConstrainSize);
288 vtkGetMacro(ShouldConstrainSize, vtkTypeBool);
290
292
298 bool SetSizeConstraintDimensionSizes(int minDimensionSize, int maxDimensionSize);
300
302
305 vtkGetMacro(MinDimensionSize, int);
307
309
312 vtkGetMacro(MaxDimensionSize, int);
314
315protected:
318
319 vtkRenderer* Renderer;
320 vtkProp* OrientationMarker;
321 vtkPolyData* Outline;
322 vtkActor2D* OutlineActor;
323
324 unsigned long StartEventObserverId;
325
326 static void ProcessEvents(
327 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
328
329 // ProcessEvents() dispatches to these methods.
330 virtual void OnLeftButtonDown();
331 virtual void OnLeftButtonUp();
332 virtual void OnMouseMove();
333
334 // observer to update the renderer's camera
335 vtkOrientationMarkerWidgetObserver* Observer;
336
337 vtkTypeBool Interactive;
338 int Tolerance;
339 int Moving;
340 double Zoom = 1.0;
341
342 // viewport to position/size this widget
343 double Viewport[4];
344
345 // used to compute relative movements
346 int StartPosition[2];
347
348 // Manage the state of the widget
349 int State;
351 {
352 Outside = 0,
358 AdjustingP4
359 };
360
361 // Whether the min/max size constraints should be applied.
362 vtkTypeBool ShouldConstrainSize = 0;
363 // The minimum dimension size to be allowed for width and height.
364 int MinDimensionSize = 20;
365 // The maximum dimension size to be allowed for width and height.
366 int MaxDimensionSize = 500;
367
368 // use to determine what state the mouse is over, edge1 p1, etc.
369 // returns a state from the WidgetState enum above
370 virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
371
372 // set the cursor to the correct shape based on State argument
373 virtual void SetCursor(int state);
374
375 // adjust the viewport depending on state
376 void MoveWidget(int X, int Y);
377 void ResizeTopLeft(int X, int Y);
378 void ResizeTopRight(int X, int Y);
379 void ResizeBottomLeft(int X, int Y);
380 void ResizeBottomRight(int X, int Y);
381
384
385 // Used to reverse compute the Viewport ivar with respect to the current
386 // renderer viewport
388 // Used to compute and set the viewport on the internal renderer based on the
389 // Viewport ivar. The computed viewport will be with respect to the whole
390 // render window
392
393 // Resize the widget if it is outside of the current size constraints,
394 // or if the widget is not square.
396
397private:
399 void operator=(const vtkOrientationMarkerWidget&) = delete;
400
401 // set up the actors and observers created by this widget
402 void SetupWindowInteraction();
403 // tear down up the actors and observers created by this widget
404 void TearDownWindowInteraction();
405};
406
407VTK_ABI_NAMESPACE_END
408#endif
a actor that draws 2D data
Definition vtkActor2D.h:145
a simple class to control print indentation
Definition vtkIndent.h:108
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
abstract base class for most VTK objects
Definition vtkObject.h:162
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
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
abstract specification for renderers
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)