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