VTK  9.3.20240418
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
77 #ifndef vtkPointWidget_h
78 #define vtkPointWidget_h
79 
80 #include "vtk3DWidget.h"
81 #include "vtkCursor3D.h" // Needed for faster access to the Cursor3D
82 #include "vtkInteractionWidgetsModule.h" // For export macro
83 
84 VTK_ABI_NAMESPACE_BEGIN
85 class vtkActor;
86 class vtkPolyDataMapper;
87 class vtkCellPicker;
88 class vtkPolyData;
89 class vtkProperty;
90 
91 class VTKINTERACTIONWIDGETS_EXPORT vtkPointWidget : public vtk3DWidget
92 {
93 public:
97  static vtkPointWidget* New();
98 
99  vtkTypeMacro(vtkPointWidget, vtk3DWidget);
100  void PrintSelf(ostream& os, vtkIndent indent) override;
101 
103 
106  void SetEnabled(int) override;
107  void PlaceWidget(double bounds[6]) override;
108  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
110  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
111  {
112  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
113  }
115 
121 
127  void SetPosition(double x, double y, double z) { this->Cursor3D->SetFocalPoint(x, y, z); }
128  void SetPosition(double x[3]) { this->SetPosition(x[0], x[1], x[2]); }
129  double* GetPosition() VTK_SIZEHINT(3) { return this->Cursor3D->GetFocalPoint(); }
130  void GetPosition(double xyz[3]) { this->Cursor3D->GetFocalPoint(xyz); }
131 
135  void SetOutline(int o) { this->Cursor3D->SetOutline(o); }
136  int GetOutline() { return this->Cursor3D->GetOutline(); }
137  void OutlineOn() { this->Cursor3D->OutlineOn(); }
138  void OutlineOff() { this->Cursor3D->OutlineOff(); }
139 
143  void SetXShadows(int o) { this->Cursor3D->SetXShadows(o); }
144  int GetXShadows() { return this->Cursor3D->GetXShadows(); }
145  void XShadowsOn() { this->Cursor3D->XShadowsOn(); }
146  void XShadowsOff() { this->Cursor3D->XShadowsOff(); }
147 
151  void SetYShadows(int o) { this->Cursor3D->SetYShadows(o); }
152  int GetYShadows() { return this->Cursor3D->GetYShadows(); }
153  void YShadowsOn() { this->Cursor3D->YShadowsOn(); }
154  void YShadowsOff() { this->Cursor3D->YShadowsOff(); }
155 
159  void SetZShadows(int o) { this->Cursor3D->SetZShadows(o); }
160  int GetZShadows() { return this->Cursor3D->GetZShadows(); }
161  void ZShadowsOn() { this->Cursor3D->ZShadowsOn(); }
162  void ZShadowsOff() { this->Cursor3D->ZShadowsOff(); }
163 
170  {
171  this->Cursor3D->SetTranslationMode(mode);
172  this->Cursor3D->Update();
173  }
174  int GetTranslationMode() { return this->Cursor3D->GetTranslationMode(); }
175  void TranslationModeOn() { this->SetTranslationMode(1); }
176  void TranslationModeOff() { this->SetTranslationMode(0); }
177 
179 
182  void AllOn()
183  {
184  this->OutlineOn();
185  this->XShadowsOn();
186  this->YShadowsOn();
187  this->ZShadowsOn();
188  }
189  void AllOff()
190  {
191  this->OutlineOff();
192  this->XShadowsOff();
193  this->YShadowsOff();
194  this->ZShadowsOff();
195  }
197 
199 
204  vtkGetObjectMacro(Property, vtkProperty);
205  vtkGetObjectMacro(SelectedProperty, vtkProperty);
207 
209 
215  vtkSetClampMacro(HotSpotSize, double, 0.0, 1.0);
216  vtkGetMacro(HotSpotSize, double);
218 
219 protected:
221  ~vtkPointWidget() override;
222 
223  // Manage the state of the widget
224  friend class vtkLineWidget;
225 
226  int State;
228  {
229  Start = 0,
233  Outside
234  };
235 
236  // Handles the events
237  static void ProcessEvents(
238  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
239 
240  // ProcessEvents() dispatches to these methods.
241  virtual void OnMouseMove();
242  virtual void OnLeftButtonDown();
243  virtual void OnLeftButtonUp();
244  virtual void OnMiddleButtonDown();
245  virtual void OnMiddleButtonUp();
246  virtual void OnRightButtonDown();
247  virtual void OnRightButtonUp();
248 
249  // the cursor3D
253  void Highlight(int highlight);
254 
255  // Do the picking
257 
258  // Register internal Pickers within PickingManager
259  void RegisterPickers() override;
260 
261  // Methods to manipulate the cursor
263  void Translate(double* p1, double* p2);
264  void Scale(double* p1, double* p2, int X, int Y);
265  void MoveFocus(double* p1, double* p2);
267 
268  // Properties used to control the appearance of selected objects and
269  // the manipulator in general.
273 
274  // The size of the hot spot.
275  double HotSpotSize;
276  int DetermineConstraintAxis(int constraint, double* x);
279 
280 private:
281  vtkPointWidget(const vtkPointWidget&) = delete;
282  void operator=(const vtkPointWidget&) = delete;
283 };
284 
285 VTK_ABI_NAMESPACE_END
286 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:60
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:151
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:91
generate a 3D cursor representation
Definition: vtkCursor3D.h:48
a simple class to control print indentation
Definition: vtkIndent.h:108
3D widget for manipulating a line
abstract base class for most VTK objects
Definition: vtkObject.h:162
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:181
represent surface properties of a geometric object
Definition: vtkProperty.h:167
@ mode
Definition: vtkX3D.h:247
#define VTK_SIZEHINT(...)