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=========================================================================*/
178#ifndef vtkOrientationMarkerWidget_h
179#define vtkOrientationMarkerWidget_h
180
181#include "vtkInteractionWidgetsModule.h" // For export macro
183
184class vtkActor2D;
185class vtkPolyData;
186class vtkProp;
187class vtkOrientationMarkerWidgetObserver;
188class vtkRenderer;
189
190class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver
191{
192public:
195 void PrintSelf(ostream& os, vtkIndent indent) override;
196
198
201 virtual void SetOrientationMarker(vtkProp* prop);
202 vtkGetObjectMacro(OrientationMarker, vtkProp);
204
208 void SetEnabled(int) override;
209
214 void ExecuteCameraUpdateEvent(vtkObject* o, unsigned long event, void* calldata);
215
217
222 vtkGetMacro(Interactive, vtkTypeBool);
223 vtkBooleanMacro(Interactive, vtkTypeBool);
225
227
232 void SetOutlineColor(double r, double g, double b);
235
237
249 vtkSetVector4Macro(Viewport, double);
250 vtkGetVector4Macro(Viewport, double);
252
254
259 vtkSetClampMacro(Tolerance, int, 1, 10);
260 vtkGetMacro(Tolerance, int);
262
264
268 vtkSetClampMacro(Zoom, double, 0.1, 10.0);
269 vtkGetMacro(Zoom, double);
271
273
277 void Modified() override;
279
281
284 void EndInteraction() override;
286
288
292 void SetShouldConstrainSize(const vtkTypeBool shouldConstrainSize);
293 vtkGetMacro(ShouldConstrainSize, vtkTypeBool);
295
297
303 bool SetSizeConstraintDimensionSizes(const int minDimensionSize, const int maxDimensionSize);
305
307
310 vtkGetMacro(MinDimensionSize, int);
312
314
317 vtkGetMacro(MaxDimensionSize, int);
319
320protected:
323
324 vtkRenderer* Renderer;
325 vtkProp* OrientationMarker;
326 vtkPolyData* Outline;
327 vtkActor2D* OutlineActor;
328
329 unsigned long StartEventObserverId;
330
331 static void ProcessEvents(
332 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
333
334 // ProcessEvents() dispatches to these methods.
335 virtual void OnLeftButtonDown();
336 virtual void OnLeftButtonUp();
337 virtual void OnMouseMove();
338
339 // observer to update the renderer's camera
340 vtkOrientationMarkerWidgetObserver* Observer;
341
342 vtkTypeBool Interactive;
343 int Tolerance;
344 int Moving;
345 double Zoom = 1.0;
346
347 // viewport to position/size this widget
348 double Viewport[4];
349
350 // used to compute relative movements
351 int StartPosition[2];
352
353 // Manage the state of the widget
354 int State;
356 {
357 Outside = 0,
363 AdjustingP4
364 };
365
366 // Whether the min/max size constraints should be applied.
367 vtkTypeBool ShouldConstrainSize = 0;
368 // The minimum dimension size to be allowed for width and height.
369 int MinDimensionSize = 20;
370 // The maximum dimension size to be allowed for width and height.
371 int MaxDimensionSize = 500;
372
373 // use to determine what state the mouse is over, edge1 p1, etc.
374 // returns a state from the WidgetState enum above
375 virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
376
377 // set the cursor to the correct shape based on State argument
378 virtual void SetCursor(int state);
379
380 // adjust the viewport depending on state
381 void MoveWidget(int X, int Y);
382 void ResizeTopLeft(int X, int Y);
383 void ResizeTopRight(int X, int Y);
384 void ResizeBottomLeft(int X, int Y);
385 void ResizeBottomRight(int X, int Y);
386
389
390 // Used to reverse compute the Viewport ivar with respect to the current
391 // renderer viewport
393 // Used to compute and set the viewport on the internal renderer based on the
394 // Viewport ivar. The computed viewport will be with respect to the whole
395 // render window
397
398 // Resize the widget if it is outside of the current size constraints,
399 // or if the widget is not square.
401
402private:
404 void operator=(const vtkOrientationMarkerWidget&) = delete;
405
406 // set up the actors and observers created by this widget
407 void SetupWindowInteraction();
408 // tear down up the actors and observers created by this widget
409 void TearDownWindowInteraction();
410};
411
412#endif
a actor that draws 2D data
Definition: vtkActor2D.h:149
a simple class to control print indentation
Definition: vtkIndent.h:113
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
abstract base class for most VTK objects
Definition: vtkObject.h:73
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:195
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:67
abstract specification for renderers
Definition: vtkRenderer.h:173
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)