VTK  9.3.1
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 
101  void GetPolyData(vtkPolyData* pd);
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:
201  vtkPointWidget();
202  ~vtkPointWidget() override;
203 
204  // Manage the state of the widget
205  friend class vtkLineWidget;
206 
207  int State;
209  {
210  Start = 0,
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
void OnRightButtonDown()
vtkProperty * SelectedProperty
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
void TranslationModeOff()
abstract base class for most VTK objects
Definition: vtkObject.h:51
void OnLeftButtonDown()
represent surface properties of a geometric object
Definition: vtkProperty.h:56
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:79
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:28
void AllOn()
Convenience methods to turn outline and shadows on and off.
3D widget for manipulating a line
Definition: vtkLineWidget.h:82
#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:61
void TranslationModeOn()
void SetPosition(double x[3])
generate a 3D cursor representation
Definition: vtkCursor3D.h:28
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:59
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)