VTK  9.0.3
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 =========================================================================*/
69 #ifndef vtkOrientationMarkerWidget_h
70 #define vtkOrientationMarkerWidget_h
71 
72 #include "vtkInteractionWidgetsModule.h" // For export macro
73 #include "vtkInteractorObserver.h"
74 
75 class vtkActor2D;
76 class vtkPolyData;
77 class vtkProp;
78 class vtkOrientationMarkerWidgetObserver;
79 class vtkRenderer;
80 
81 class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver
82 {
83 public:
86  void PrintSelf(ostream& os, vtkIndent indent) override;
87 
89 
92  virtual void SetOrientationMarker(vtkProp* prop);
93  vtkGetObjectMacro(OrientationMarker, vtkProp);
95 
99  void SetEnabled(int) override;
100 
105  void ExecuteCameraUpdateEvent(vtkObject* o, unsigned long event, void* calldata);
106 
108 
113  vtkGetMacro(Interactive, vtkTypeBool);
114  vtkBooleanMacro(Interactive, vtkTypeBool);
116 
118 
123  void SetOutlineColor(double r, double g, double b);
126 
128 
140  vtkSetVector4Macro(Viewport, double);
141  vtkGetVector4Macro(Viewport, double);
143 
145 
150  vtkSetClampMacro(Tolerance, int, 1, 10);
151  vtkGetMacro(Tolerance, int);
153 
155 
159  void Modified() override;
161 
162 protected:
165 
166  vtkRenderer* Renderer;
167  vtkProp* OrientationMarker;
168  vtkPolyData* Outline;
169  vtkActor2D* OutlineActor;
170 
171  unsigned long StartEventObserverId;
172 
173  static void ProcessEvents(
174  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
175 
176  // ProcessEvents() dispatches to these methods.
177  virtual void OnLeftButtonDown();
178  virtual void OnLeftButtonUp();
179  virtual void OnMouseMove();
180 
181  // observer to update the renderer's camera
182  vtkOrientationMarkerWidgetObserver* Observer;
183 
184  vtkTypeBool Interactive;
185  int Tolerance;
186  int Moving;
187 
188  // viewport to position/size this widget
189  double Viewport[4];
190 
191  // used to compute relative movements
192  int StartPosition[2];
193 
194  // Manage the state of the widget
195  int State;
197  {
198  Outside = 0,
204  AdjustingP4
205  };
206 
207  // use to determine what state the mouse is over, edge1 p1, etc.
208  // returns a state from the WidgetState enum above
209  virtual int ComputeStateBasedOnPosition(int X, int Y, int* pos1, int* pos2);
210 
211  // set the cursor to the correct shape based on State argument
212  virtual void SetCursor(int state);
213 
214  // adjust the viewport depending on state
215  void MoveWidget(int X, int Y);
216  void ResizeTopLeft(int X, int Y);
217  void ResizeTopRight(int X, int Y);
218  void ResizeBottomLeft(int X, int Y);
219  void ResizeBottomRight(int X, int Y);
220 
223 
224  // Used to reverse compute the Viewport ivar with respect to the current
225  // renderer viewport
227  // Used to compute and set the viewport on the internal renderer based on the
228  // Viewport ivar. The computed viewport will be with respect to the whole
229  // render window
231 
232 private:
234  void operator=(const vtkOrientationMarkerWidget&) = delete;
235 
236  // set up the actors and observers created by this widget
237  void SetupWindowInteraction();
238  // tear down up the actors and observers created by this widget
239  void TearDownWindowInteraction();
240 };
241 
242 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:40
a simple class to control print indentation
Definition: vtkIndent.h:34
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
abstract base class for most VTK objects
Definition: vtkObject.h:54
2D widget for manipulating a marker prop
void SetInteractive(vtkTypeBool state)
Set/get whether to allow this widget to be interactively moved/scaled.
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 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()
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:85
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
abstract specification for renderers
Definition: vtkRenderer.h:59
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)