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 =========================================================================*/
70 #ifndef vtkPointWidget_h
71 #define vtkPointWidget_h
72 
73 #include "vtk3DWidget.h"
74 #include "vtkCursor3D.h" // Needed for faster access to the Cursor3D
75 #include "vtkInteractionWidgetsModule.h" // For export macro
76 
77 class vtkActor;
78 class vtkPolyDataMapper;
79 class vtkCellPicker;
80 class vtkPolyData;
81 class vtkProperty;
82 
83 class VTKINTERACTIONWIDGETS_EXPORT vtkPointWidget : public vtk3DWidget
84 {
85 public:
89  static vtkPointWidget* New();
90 
91  vtkTypeMacro(vtkPointWidget, vtk3DWidget);
92  void PrintSelf(ostream& os, vtkIndent indent) override;
93 
95 
98  void SetEnabled(int) override;
99  void PlaceWidget(double bounds[6]) override;
100  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
102  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
103  {
104  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
105  }
107 
112  void GetPolyData(vtkPolyData* pd);
113 
119  void SetPosition(double x, double y, double z) { this->Cursor3D->SetFocalPoint(x, y, z); }
120  void SetPosition(double x[3]) { this->SetPosition(x[0], x[1], x[2]); }
121  double* GetPosition() VTK_SIZEHINT(3) { return this->Cursor3D->GetFocalPoint(); }
122  void GetPosition(double xyz[3]) { this->Cursor3D->GetFocalPoint(xyz); }
123 
127  void SetOutline(int o) { this->Cursor3D->SetOutline(o); }
128  int GetOutline() { return this->Cursor3D->GetOutline(); }
129  void OutlineOn() { this->Cursor3D->OutlineOn(); }
130  void OutlineOff() { this->Cursor3D->OutlineOff(); }
131 
135  void SetXShadows(int o) { this->Cursor3D->SetXShadows(o); }
136  int GetXShadows() { return this->Cursor3D->GetXShadows(); }
137  void XShadowsOn() { this->Cursor3D->XShadowsOn(); }
138  void XShadowsOff() { this->Cursor3D->XShadowsOff(); }
139 
143  void SetYShadows(int o) { this->Cursor3D->SetYShadows(o); }
144  int GetYShadows() { return this->Cursor3D->GetYShadows(); }
145  void YShadowsOn() { this->Cursor3D->YShadowsOn(); }
146  void YShadowsOff() { this->Cursor3D->YShadowsOff(); }
147 
151  void SetZShadows(int o) { this->Cursor3D->SetZShadows(o); }
152  int GetZShadows() { return this->Cursor3D->GetZShadows(); }
153  void ZShadowsOn() { this->Cursor3D->ZShadowsOn(); }
154  void ZShadowsOff() { this->Cursor3D->ZShadowsOff(); }
155 
162  {
163  this->Cursor3D->SetTranslationMode(mode);
164  this->Cursor3D->Update();
165  }
166  int GetTranslationMode() { return this->Cursor3D->GetTranslationMode(); }
167  void TranslationModeOn() { this->SetTranslationMode(1); }
168  void TranslationModeOff() { this->SetTranslationMode(0); }
169 
171 
174  void AllOn()
175  {
176  this->OutlineOn();
177  this->XShadowsOn();
178  this->YShadowsOn();
179  this->ZShadowsOn();
180  }
181  void AllOff()
182  {
183  this->OutlineOff();
184  this->XShadowsOff();
185  this->YShadowsOff();
186  this->ZShadowsOff();
187  }
189 
191 
196  vtkGetObjectMacro(Property, vtkProperty);
197  vtkGetObjectMacro(SelectedProperty, vtkProperty);
199 
201 
207  vtkSetClampMacro(HotSpotSize, double, 0.0, 1.0);
208  vtkGetMacro(HotSpotSize, double);
210 
211 protected:
212  vtkPointWidget();
213  ~vtkPointWidget() override;
214 
215  // Manage the state of the widget
216  friend class vtkLineWidget;
217 
218  int State;
220  {
221  Start = 0,
226  };
227 
228  // Handles the events
229  static void ProcessEvents(
230  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
231 
232  // ProcessEvents() dispatches to these methods.
233  virtual void OnMouseMove();
234  virtual void OnLeftButtonDown();
235  virtual void OnLeftButtonUp();
236  virtual void OnMiddleButtonDown();
237  virtual void OnMiddleButtonUp();
238  virtual void OnRightButtonDown();
239  virtual void OnRightButtonUp();
240 
241  // the cursor3D
245  void Highlight(int highlight);
246 
247  // Do the picking
249 
250  // Register internal Pickers within PickingManager
251  void RegisterPickers() override;
252 
253  // Methods to manipulate the cursor
255  void Translate(double* p1, double* p2);
256  void Scale(double* p1, double* p2, int X, int Y);
257  void MoveFocus(double* p1, double* p2);
259 
260  // Properties used to control the appearance of selected objects and
261  // the manipulator in general.
265 
266  // The size of the hot spot.
267  double HotSpotSize;
268  int DetermineConstraintAxis(int constraint, double* x);
271 
272 private:
273  vtkPointWidget(const vtkPointWidget&) = delete;
274  void operator=(const vtkPointWidget&) = delete;
275 };
276 
277 #endif
void OnRightButtonDown()
vtkProperty * SelectedProperty
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
void TranslationModeOff()
abstract base class for most VTK objects
Definition: vtkObject.h:62
void OnLeftButtonDown()
represent surface properties of a geometric object
Definition: vtkProperty.h:67
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:90
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:39
void AllOn()
Convenience methods to turn outline and shadows on and off.
3D widget for manipulating a line
Definition: vtkLineWidget.h:93
#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:72
void TranslationModeOn()
void SetPosition(double x[3])
generate a 3D cursor representation
Definition: vtkCursor3D.h:39
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:70
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)