VTK  9.3.0
vtkPointWidget.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
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 VTK_ABI_NAMESPACE_BEGIN
75 class vtkActor;
76 class vtkPolyDataMapper;
77 class vtkCellPicker;
78 class vtkPolyData;
79 class vtkProperty;
80 
81 class VTKINTERACTIONWIDGETS_EXPORT vtkPointWidget : public vtk3DWidget
82 {
83 public:
87  static vtkPointWidget* New();
88 
89  vtkTypeMacro(vtkPointWidget, vtk3DWidget);
90  void PrintSelf(ostream& os, vtkIndent indent) override;
91 
93 
96  void SetEnabled(int) override;
97  void PlaceWidget(double bounds[6]) override;
98  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
100  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
101  {
102  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
103  }
105 
111 
117  void SetPosition(double x, double y, double z) { this->Cursor3D->SetFocalPoint(x, y, z); }
118  void SetPosition(double x[3]) { this->SetPosition(x[0], x[1], x[2]); }
119  double* GetPosition() VTK_SIZEHINT(3) { return this->Cursor3D->GetFocalPoint(); }
120  void GetPosition(double xyz[3]) { this->Cursor3D->GetFocalPoint(xyz); }
121 
125  void SetOutline(int o) { this->Cursor3D->SetOutline(o); }
126  int GetOutline() { return this->Cursor3D->GetOutline(); }
127  void OutlineOn() { this->Cursor3D->OutlineOn(); }
128  void OutlineOff() { this->Cursor3D->OutlineOff(); }
129 
133  void SetXShadows(int o) { this->Cursor3D->SetXShadows(o); }
134  int GetXShadows() { return this->Cursor3D->GetXShadows(); }
135  void XShadowsOn() { this->Cursor3D->XShadowsOn(); }
136  void XShadowsOff() { this->Cursor3D->XShadowsOff(); }
137 
141  void SetYShadows(int o) { this->Cursor3D->SetYShadows(o); }
142  int GetYShadows() { return this->Cursor3D->GetYShadows(); }
143  void YShadowsOn() { this->Cursor3D->YShadowsOn(); }
144  void YShadowsOff() { this->Cursor3D->YShadowsOff(); }
145 
149  void SetZShadows(int o) { this->Cursor3D->SetZShadows(o); }
150  int GetZShadows() { return this->Cursor3D->GetZShadows(); }
151  void ZShadowsOn() { this->Cursor3D->ZShadowsOn(); }
152  void ZShadowsOff() { this->Cursor3D->ZShadowsOff(); }
153 
160  {
161  this->Cursor3D->SetTranslationMode(mode);
162  this->Cursor3D->Update();
163  }
164  int GetTranslationMode() { return this->Cursor3D->GetTranslationMode(); }
165  void TranslationModeOn() { this->SetTranslationMode(1); }
166  void TranslationModeOff() { this->SetTranslationMode(0); }
167 
169 
172  void AllOn()
173  {
174  this->OutlineOn();
175  this->XShadowsOn();
176  this->YShadowsOn();
177  this->ZShadowsOn();
178  }
179  void AllOff()
180  {
181  this->OutlineOff();
182  this->XShadowsOff();
183  this->YShadowsOff();
184  this->ZShadowsOff();
185  }
187 
189 
194  vtkGetObjectMacro(Property, vtkProperty);
195  vtkGetObjectMacro(SelectedProperty, vtkProperty);
197 
199 
205  vtkSetClampMacro(HotSpotSize, double, 0.0, 1.0);
206  vtkGetMacro(HotSpotSize, double);
208 
209 protected:
211  ~vtkPointWidget() override;
212 
213  // Manage the state of the widget
214  friend class vtkLineWidget;
215 
216  int State;
218  {
219  Start = 0,
223  Outside
224  };
225 
226  // Handles the events
227  static void ProcessEvents(
228  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
229 
230  // ProcessEvents() dispatches to these methods.
231  virtual void OnMouseMove();
232  virtual void OnLeftButtonDown();
233  virtual void OnLeftButtonUp();
234  virtual void OnMiddleButtonDown();
235  virtual void OnMiddleButtonUp();
236  virtual void OnRightButtonDown();
237  virtual void OnRightButtonUp();
238 
239  // the cursor3D
243  void Highlight(int highlight);
244 
245  // Do the picking
247 
248  // Register internal Pickers within PickingManager
249  void RegisterPickers() override;
250 
251  // Methods to manipulate the cursor
253  void Translate(double* p1, double* p2);
254  void Scale(double* p1, double* p2, int X, int Y);
255  void MoveFocus(double* p1, double* p2);
257 
258  // Properties used to control the appearance of selected objects and
259  // the manipulator in general.
263 
264  // The size of the hot spot.
265  double HotSpotSize;
266  int DetermineConstraintAxis(int constraint, double* x);
269 
270 private:
271  vtkPointWidget(const vtkPointWidget&) = delete;
272  void operator=(const vtkPointWidget&) = delete;
273 };
274 
275 VTK_ABI_NAMESPACE_END
276 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:60
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:71
generate a 3D cursor representation
Definition: vtkCursor3D.h:38
a simple class to control print indentation
Definition: vtkIndent.h:38
3D widget for manipulating a line
Definition: vtkLineWidget.h:92
abstract base class for most VTK objects
Definition: vtkObject.h:61
position a point in 3D space
void CreateDefaultProperties()
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
virtual void OnMouseMove()
void AllOff()
Convenience methods to turn outline and shadows on and off.
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the point.
vtkPolyDataMapper * Mapper
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
void TranslationModeOn()
double * GetPosition()
void TranslationModeOff()
~vtkPointWidget() override
void Highlight(int highlight)
void SetOutline(int o)
Turn on/off the wireframe bounding box.
void SetZShadows(int o)
Turn on/off the wireframe z-shadows.
vtkCursor3D * Cursor3D
int DetermineConstraintAxis(int constraint, double *x)
virtual void OnRightButtonDown()
void SetTranslationMode(int mode)
If translation mode is on, as the widget is moved the bounding box, shadows, and cursor are all trans...
void SetXShadows(int o)
Turn on/off the wireframe x-shadows.
vtkActor * Actor
virtual void OnLeftButtonUp()
void GetPosition(double xyz[3])
void Translate(double *p1, double *p2)
static vtkPointWidget * New()
Instantiate this widget.
virtual void OnRightButtonUp()
void SetEnabled(int) override
Methods that satisfy the superclass' API.
void SetPosition(double x[3])
virtual void OnMiddleButtonUp()
int GetTranslationMode()
virtual void OnMiddleButtonDown()
void SetPosition(double x, double y, double z)
Set/Get the position of the point.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkProperty * SelectedProperty
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void PlaceWidget() override
Methods that satisfy the superclass' API.
virtual void OnLeftButtonDown()
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
vtkProperty * Property
void SetYShadows(int o)
Turn on/off the wireframe y-shadows.
vtkCellPicker * CursorPicker
void AllOn()
Convenience methods to turn outline and shadows on and off.
void Scale(double *p1, double *p2, int X, int Y)
void MoveFocus(double *p1, double *p2)
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
represent surface properties of a geometric object
Definition: vtkProperty.h:66
@ mode
Definition: vtkX3D.h:247
#define VTK_SIZEHINT(...)