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=========================================================================*/
184#ifndef vtkOrientationMarkerWidget_h
185#define vtkOrientationMarkerWidget_h
186
187#include "vtkInteractionWidgetsModule.h" // For export macro
189
190class vtkActor2D;
191class vtkPolyData;
192class vtkProp;
193class vtkOrientationMarkerWidgetObserver;
194class vtkRenderer;
195
196class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver
197{
198public:
201 void PrintSelf(ostream& os, vtkIndent indent) override;
202
204
207 virtual void SetOrientationMarker(vtkProp* prop);
208 vtkGetObjectMacro(OrientationMarker, vtkProp);
210
214 void SetEnabled(int) override;
215
220 void ExecuteCameraUpdateEvent(vtkObject* o, unsigned long event, void* calldata);
221
223
228 vtkGetMacro(Interactive, vtkTypeBool);
229 vtkBooleanMacro(Interactive, vtkTypeBool);
231
233
238 void SetOutlineColor(double r, double g, double b);
241
243
255 vtkSetVector4Macro(Viewport, double);
256 vtkGetVector4Macro(Viewport, double);
258
260
265 vtkSetClampMacro(Tolerance, int, 1, 10);
266 vtkGetMacro(Tolerance, int);
268
270
274 vtkSetClampMacro(Zoom, double, 0.1, 10.0);
275 vtkGetMacro(Zoom, double);
277
279
283 void Modified() override;
285
287
290 void EndInteraction() override;
292
294
298 void SetShouldConstrainSize(const vtkTypeBool shouldConstrainSize);
299 vtkGetMacro(ShouldConstrainSize, vtkTypeBool);
301
303
309 bool SetSizeConstraintDimensionSizes(const int minDimensionSize, const int maxDimensionSize);
311
313
316 vtkGetMacro(MinDimensionSize, int);
318
320
323 vtkGetMacro(MaxDimensionSize, int);
325
326protected:
329
330 vtkRenderer* Renderer;
331 vtkProp* OrientationMarker;
332 vtkPolyData* Outline;
333 vtkActor2D* OutlineActor;
334
335 unsigned long StartEventObserverId;
336
337 static void ProcessEvents(
338 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
339
340 // ProcessEvents() dispatches to these methods.
341 virtual void OnLeftButtonDown();
342 virtual void OnLeftButtonUp();
343 virtual void OnMouseMove();
344
345 // observer to update the renderer's camera
346 vtkOrientationMarkerWidgetObserver* Observer;
347
348 vtkTypeBool Interactive;
349 int Tolerance;
350 int Moving;
351 double Zoom = 1.0;
352
353 // viewport to position/size this widget
354 double Viewport[4];
355
356 // used to compute relative movements
357 int StartPosition[2];
358
359 // Manage the state of the widget
360 int State;
362 {
363 Outside = 0,
369 AdjustingP4
370 };
371
372 // Whether the min/max size constraints should be applied.
373 vtkTypeBool ShouldConstrainSize = 0;
374 // The minimum dimension size to be allowed for width and height.
375 int MinDimensionSize = 20;
376 // The maximum dimension size to be allowed for width and height.
377 int MaxDimensionSize = 500;
378
379 // use to determine what state the mouse is over, edge1 p1, etc.
380 // returns a state from the WidgetState enum above
381 virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
382
383 // set the cursor to the correct shape based on State argument
384 virtual void SetCursor(int state);
385
386 // adjust the viewport depending on state
387 void MoveWidget(int X, int Y);
388 void ResizeTopLeft(int X, int Y);
389 void ResizeTopRight(int X, int Y);
390 void ResizeBottomLeft(int X, int Y);
391 void ResizeBottomRight(int X, int Y);
392
395
396 // Used to reverse compute the Viewport ivar with respect to the current
397 // renderer viewport
399 // Used to compute and set the viewport on the internal renderer based on the
400 // Viewport ivar. The computed viewport will be with respect to the whole
401 // render window
403
404 // Resize the widget if it is outside of the current size constraints,
405 // or if the widget is not square.
407
408private:
410 void operator=(const vtkOrientationMarkerWidget&) = delete;
411
412 // set up the actors and observers created by this widget
413 void SetupWindowInteraction();
414 // tear down up the actors and observers created by this widget
415 void TearDownWindowInteraction();
416};
417
418#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:82
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:76
abstract specification for renderers
Definition: vtkRenderer.h:182
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)