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
58 #ifndef vtkPointWidget_h
59 #define vtkPointWidget_h
60 
61 #include "vtk3DWidget.h"
62 #include "vtkCursor3D.h" // Needed for faster access to the Cursor3D
63 #include "vtkInteractionWidgetsModule.h" // For export macro
64 
65 VTK_ABI_NAMESPACE_BEGIN
66 class vtkActor;
67 class vtkPolyDataMapper;
68 class vtkCellPicker;
69 class vtkPolyData;
70 class vtkProperty;
71 
72 class VTKINTERACTIONWIDGETS_EXPORT vtkPointWidget : public vtk3DWidget
73 {
74 public:
78  static vtkPointWidget* New();
79 
80  vtkTypeMacro(vtkPointWidget, vtk3DWidget);
81  void PrintSelf(ostream& os, vtkIndent indent) override;
82 
84 
87  void SetEnabled(int) override;
88  void PlaceWidget(double bounds[6]) override;
89  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
91  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
92  {
93  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
94  }
96 
102 
108  void SetPosition(double x, double y, double z) { this->Cursor3D->SetFocalPoint(x, y, z); }
109  void SetPosition(double x[3]) { this->SetPosition(x[0], x[1], x[2]); }
110  double* GetPosition() VTK_SIZEHINT(3) { return this->Cursor3D->GetFocalPoint(); }
111  void GetPosition(double xyz[3]) { this->Cursor3D->GetFocalPoint(xyz); }
112 
116  void SetOutline(int o) { this->Cursor3D->SetOutline(o); }
117  int GetOutline() { return this->Cursor3D->GetOutline(); }
118  void OutlineOn() { this->Cursor3D->OutlineOn(); }
119  void OutlineOff() { this->Cursor3D->OutlineOff(); }
120 
124  void SetXShadows(int o) { this->Cursor3D->SetXShadows(o); }
125  int GetXShadows() { return this->Cursor3D->GetXShadows(); }
126  void XShadowsOn() { this->Cursor3D->XShadowsOn(); }
127  void XShadowsOff() { this->Cursor3D->XShadowsOff(); }
128 
132  void SetYShadows(int o) { this->Cursor3D->SetYShadows(o); }
133  int GetYShadows() { return this->Cursor3D->GetYShadows(); }
134  void YShadowsOn() { this->Cursor3D->YShadowsOn(); }
135  void YShadowsOff() { this->Cursor3D->YShadowsOff(); }
136 
140  void SetZShadows(int o) { this->Cursor3D->SetZShadows(o); }
141  int GetZShadows() { return this->Cursor3D->GetZShadows(); }
142  void ZShadowsOn() { this->Cursor3D->ZShadowsOn(); }
143  void ZShadowsOff() { this->Cursor3D->ZShadowsOff(); }
144 
151  {
152  this->Cursor3D->SetTranslationMode(mode);
153  this->Cursor3D->Update();
154  }
155  int GetTranslationMode() { return this->Cursor3D->GetTranslationMode(); }
156  void TranslationModeOn() { this->SetTranslationMode(1); }
157  void TranslationModeOff() { this->SetTranslationMode(0); }
158 
160 
163  void AllOn()
164  {
165  this->OutlineOn();
166  this->XShadowsOn();
167  this->YShadowsOn();
168  this->ZShadowsOn();
169  }
170  void AllOff()
171  {
172  this->OutlineOff();
173  this->XShadowsOff();
174  this->YShadowsOff();
175  this->ZShadowsOff();
176  }
178 
180 
185  vtkGetObjectMacro(Property, vtkProperty);
186  vtkGetObjectMacro(SelectedProperty, vtkProperty);
188 
190 
196  vtkSetClampMacro(HotSpotSize, double, 0.0, 1.0);
197  vtkGetMacro(HotSpotSize, double);
199 
200 protected:
202  ~vtkPointWidget() override;
203 
204  // Manage the state of the widget
205  friend class vtkLineWidget;
206 
207  int State;
209  {
210  Start = 0,
214  Outside
215  };
216 
217  // Handles the events
218  static void ProcessEvents(
219  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
220 
221  // ProcessEvents() dispatches to these methods.
222  virtual void OnMouseMove();
223  virtual void OnLeftButtonDown();
224  virtual void OnLeftButtonUp();
225  virtual void OnMiddleButtonDown();
226  virtual void OnMiddleButtonUp();
227  virtual void OnRightButtonDown();
228  virtual void OnRightButtonUp();
229 
230  // the cursor3D
234  void Highlight(int highlight);
235 
236  // Do the picking
238 
239  // Register internal Pickers within PickingManager
240  void RegisterPickers() override;
241 
242  // Methods to manipulate the cursor
244  void Translate(double* p1, double* p2);
245  void Scale(double* p1, double* p2, int X, int Y);
246  void MoveFocus(double* p1, double* p2);
248 
249  // Properties used to control the appearance of selected objects and
250  // the manipulator in general.
254 
255  // The size of the hot spot.
256  double HotSpotSize;
257  int DetermineConstraintAxis(int constraint, double* x);
260 
261 private:
262  vtkPointWidget(const vtkPointWidget&) = delete;
263  void operator=(const vtkPointWidget&) = delete;
264 };
265 
266 VTK_ABI_NAMESPACE_END
267 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:60
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
generate a 3D cursor representation
Definition: vtkCursor3D.h:29
a simple class to control print indentation
Definition: vtkIndent.h:29
3D widget for manipulating a line
Definition: vtkLineWidget.h:83
abstract base class for most VTK objects
Definition: vtkObject.h:52
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:80
represent surface properties of a geometric object
Definition: vtkProperty.h:57
@ mode
Definition: vtkX3D.h:247
#define VTK_SIZEHINT(...)