VTK  9.0.1
vtkPointWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPointWidget.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 =========================================================================*/
67 #ifndef vtkPointWidget_h
68 #define vtkPointWidget_h
69 
70 #include "vtk3DWidget.h"
71 #include "vtkCursor3D.h" // Needed for faster access to the Cursor3D
72 #include "vtkInteractionWidgetsModule.h" // For export macro
73 
74 class vtkActor;
75 class vtkPolyDataMapper;
76 class vtkCellPicker;
77 class vtkPolyData;
78 class vtkProperty;
79 
80 class VTKINTERACTIONWIDGETS_EXPORT vtkPointWidget : public vtk3DWidget
81 {
82 public:
86  static vtkPointWidget* New();
87 
88  vtkTypeMacro(vtkPointWidget, vtk3DWidget);
89  void PrintSelf(ostream& os, vtkIndent indent) override;
90 
92 
95  void SetEnabled(int) override;
96  void PlaceWidget(double bounds[6]) override;
97  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
99  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
100  {
101  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
102  }
104 
109  void GetPolyData(vtkPolyData* pd);
110 
116  void SetPosition(double x, double y, double z) { this->Cursor3D->SetFocalPoint(x, y, z); }
117  void SetPosition(double x[3]) { this->SetPosition(x[0], x[1], x[2]); }
118  double* GetPosition() VTK_SIZEHINT(3) { return this->Cursor3D->GetFocalPoint(); }
119  void GetPosition(double xyz[3]) { this->Cursor3D->GetFocalPoint(xyz); }
120 
124  void SetOutline(int o) { this->Cursor3D->SetOutline(o); }
125  int GetOutline() { return this->Cursor3D->GetOutline(); }
126  void OutlineOn() { this->Cursor3D->OutlineOn(); }
127  void OutlineOff() { this->Cursor3D->OutlineOff(); }
128 
132  void SetXShadows(int o) { this->Cursor3D->SetXShadows(o); }
133  int GetXShadows() { return this->Cursor3D->GetXShadows(); }
134  void XShadowsOn() { this->Cursor3D->XShadowsOn(); }
135  void XShadowsOff() { this->Cursor3D->XShadowsOff(); }
136 
140  void SetYShadows(int o) { this->Cursor3D->SetYShadows(o); }
141  int GetYShadows() { return this->Cursor3D->GetYShadows(); }
142  void YShadowsOn() { this->Cursor3D->YShadowsOn(); }
143  void YShadowsOff() { this->Cursor3D->YShadowsOff(); }
144 
148  void SetZShadows(int o) { this->Cursor3D->SetZShadows(o); }
149  int GetZShadows() { return this->Cursor3D->GetZShadows(); }
150  void ZShadowsOn() { this->Cursor3D->ZShadowsOn(); }
151  void ZShadowsOff() { this->Cursor3D->ZShadowsOff(); }
152 
159  {
160  this->Cursor3D->SetTranslationMode(mode);
161  this->Cursor3D->Update();
162  }
163  int GetTranslationMode() { return this->Cursor3D->GetTranslationMode(); }
164  void TranslationModeOn() { this->SetTranslationMode(1); }
165  void TranslationModeOff() { this->SetTranslationMode(0); }
166 
168 
171  void AllOn()
172  {
173  this->OutlineOn();
174  this->XShadowsOn();
175  this->YShadowsOn();
176  this->ZShadowsOn();
177  }
178  void AllOff()
179  {
180  this->OutlineOff();
181  this->XShadowsOff();
182  this->YShadowsOff();
183  this->ZShadowsOff();
184  }
186 
188 
193  vtkGetObjectMacro(Property, vtkProperty);
194  vtkGetObjectMacro(SelectedProperty, vtkProperty);
196 
198 
204  vtkSetClampMacro(HotSpotSize, double, 0.0, 1.0);
205  vtkGetMacro(HotSpotSize, double);
207 
208 protected:
209  vtkPointWidget();
210  ~vtkPointWidget() override;
211 
212  // Manage the state of the widget
213  friend class vtkLineWidget;
214 
215  int State;
217  {
218  Start = 0,
223  };
224 
225  // Handles the events
226  static void ProcessEvents(
227  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
228 
229  // ProcessEvents() dispatches to these methods.
230  virtual void OnMouseMove();
231  virtual void OnLeftButtonDown();
232  virtual void OnLeftButtonUp();
233  virtual void OnMiddleButtonDown();
234  virtual void OnMiddleButtonUp();
235  virtual void OnRightButtonDown();
236  virtual void OnRightButtonUp();
237 
238  // the cursor3D
242  void Highlight(int highlight);
243 
244  // Do the picking
246 
247  // Register internal Pickers within PickingManager
248  void RegisterPickers() override;
249 
250  // Methods to manipulate the cursor
252  void Translate(double* p1, double* p2);
253  void Scale(double* p1, double* p2, int X, int Y);
254  void MoveFocus(double* p1, double* p2);
256 
257  // Properties used to control the appearance of selected objects and
258  // the manipulator in general.
262 
263  // The size of the hot spot.
264  double HotSpotSize;
265  int DetermineConstraintAxis(int constraint, double* x);
268 
269 private:
270  vtkPointWidget(const vtkPointWidget&) = delete;
271  void operator=(const vtkPointWidget&) = delete;
272 };
273 
274 #endif
void OnRightButtonDown()
vtkProperty * SelectedProperty
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
void TranslationModeOff()
abstract base class for most VTK objects
Definition: vtkObject.h:56
void OnLeftButtonDown()
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkActor * Actor
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
void OnMiddleButtonUp()
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
int GetTranslationMode()
void OnMiddleButtonDown()
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetPosition(double x, double y, double z)
Set/Get the position of the point.
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
vtkCursor3D * Cursor3D
void CreateDefaultProperties()
vtkProperty * Property
void GetPosition(double xyz[3])
a simple class to control print indentation
Definition: vtkIndent.h:33
void AllOn()
Convenience methods to turn outline and shadows on and off.
3D widget for manipulating a line
Definition: vtkLineWidget.h:90
#define VTK_SIZEHINT(...)
void AllOff()
Convenience methods to turn outline and shadows on and off.
void SetYShadows(int o)
Turn on/off the wireframe y-shadows.
double * GetPosition()
void SetZShadows(int o)
Turn on/off the wireframe z-shadows.
void SetXShadows(int o)
Turn on/off the wireframe x-shadows.
map vtkPolyData to graphics primitives
position a point in 3D space
vtkPolyDataMapper * Mapper
void SetTranslationMode(int mode)
If translation mode is on, as the widget is moved the bounding box, shadows, and cursor are all trans...
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
void TranslationModeOn()
void SetPosition(double x[3])
generate a 3D cursor representation
Definition: vtkCursor3D.h:36
void PlaceWidget() override
Methods that satisfy the superclass' API.
void SetOutline(int o)
Turn on/off the wireframe bounding box.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void OnRightButtonUp()
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:70
virtual void PlaceWidget()
This method is used to initially place the widget.
void OnLeftButtonUp()
virtual void OnMouseMove()
vtkCellPicker * CursorPicker
void Scale(double *p1, double *p2, int X, int Y)