VTK
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 =========================================================================*/
64 #ifndef vtkPointWidget_h
65 #define vtkPointWidget_h
66 
67 #include "vtk3DWidget.h"
68 #include "vtkCursor3D.h" // Needed for faster access to the Cursor3D
69 #include "vtkInteractionWidgetsModule.h" // For export macro
70 
71 class vtkActor;
72 class vtkPolyDataMapper;
73 class vtkCellPicker;
74 class vtkPolyData;
75 class vtkProperty;
76 
77 class VTKINTERACTIONWIDGETS_EXPORT vtkPointWidget : public vtk3DWidget
78 {
79 public:
83  static vtkPointWidget* New();
84 
85  vtkTypeMacro(vtkPointWidget, vtk3DWidget);
86  void PrintSelf(ostream& os, vtkIndent indent) override;
87 
89 
92  void SetEnabled(int) override;
93  void PlaceWidget(double bounds[6]) override;
94  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
96  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
97  {
98  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
99  }
101 
106  void GetPolyData(vtkPolyData* pd);
107 
113  void SetPosition(double x, double y, double z) { this->Cursor3D->SetFocalPoint(x, y, z); }
114  void SetPosition(double x[3]) { this->SetPosition(x[0], x[1], x[2]); }
115  double* GetPosition() VTK_SIZEHINT(3) { return this->Cursor3D->GetFocalPoint(); }
116  void GetPosition(double xyz[3]) { this->Cursor3D->GetFocalPoint(xyz); }
117 
121  void SetOutline(int o) { this->Cursor3D->SetOutline(o); }
122  int GetOutline() { return this->Cursor3D->GetOutline(); }
123  void OutlineOn() { this->Cursor3D->OutlineOn(); }
124  void OutlineOff() { this->Cursor3D->OutlineOff(); }
125 
129  void SetXShadows(int o) { this->Cursor3D->SetXShadows(o); }
130  int GetXShadows() { return this->Cursor3D->GetXShadows(); }
131  void XShadowsOn() { this->Cursor3D->XShadowsOn(); }
132  void XShadowsOff() { this->Cursor3D->XShadowsOff(); }
133 
137  void SetYShadows(int o) { this->Cursor3D->SetYShadows(o); }
138  int GetYShadows() { return this->Cursor3D->GetYShadows(); }
139  void YShadowsOn() { this->Cursor3D->YShadowsOn(); }
140  void YShadowsOff() { this->Cursor3D->YShadowsOff(); }
141 
145  void SetZShadows(int o) { this->Cursor3D->SetZShadows(o); }
146  int GetZShadows() { return this->Cursor3D->GetZShadows(); }
147  void ZShadowsOn() { this->Cursor3D->ZShadowsOn(); }
148  void ZShadowsOff() { this->Cursor3D->ZShadowsOff(); }
149 
156  {
157  this->Cursor3D->SetTranslationMode(mode);
158  this->Cursor3D->Update();
159  }
160  int GetTranslationMode() { return this->Cursor3D->GetTranslationMode(); }
161  void TranslationModeOn() { this->SetTranslationMode(1); }
162  void TranslationModeOff() { this->SetTranslationMode(0); }
163 
165 
168  void AllOn()
169  {
170  this->OutlineOn();
171  this->XShadowsOn();
172  this->YShadowsOn();
173  this->ZShadowsOn();
174  }
175  void AllOff()
176  {
177  this->OutlineOff();
178  this->XShadowsOff();
179  this->YShadowsOff();
180  this->ZShadowsOff();
181  }
183 
185 
190  vtkGetObjectMacro(Property, vtkProperty);
191  vtkGetObjectMacro(SelectedProperty, vtkProperty);
193 
195 
201  vtkSetClampMacro(HotSpotSize, double, 0.0, 1.0);
202  vtkGetMacro(HotSpotSize, double);
204 
205 protected:
206  vtkPointWidget();
207  ~vtkPointWidget() override;
208 
209  // Manage the state of the widget
210  friend class vtkLineWidget;
211 
212  int State;
214  {
215  Start = 0,
220  };
221 
222  // Handles the events
223  static void ProcessEvents(
224  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
225 
226  // ProcessEvents() dispatches to these methods.
227  virtual void OnMouseMove();
228  virtual void OnLeftButtonDown();
229  virtual void OnLeftButtonUp();
230  virtual void OnMiddleButtonDown();
231  virtual void OnMiddleButtonUp();
232  virtual void OnRightButtonDown();
233  virtual void OnRightButtonUp();
234 
235  // the cursor3D
239  void Highlight(int highlight);
240 
241  // Do the picking
243 
244  // Register internal Pickers within PickingManager
245  void RegisterPickers() override;
246 
247  // Methods to manipulate the cursor
249  void Translate(double* p1, double* p2);
250  void Scale(double* p1, double* p2, int X, int Y);
251  void MoveFocus(double* p1, double* p2);
253 
254  // Properties used to control the appearance of selected objects and
255  // the manipulator in general.
259 
260  // The size of the hot spot.
261  double HotSpotSize;
262  int DetermineConstraintAxis(int constraint, double* x);
265 
266 private:
267  vtkPointWidget(const vtkPointWidget&) = delete;
268  void operator=(const vtkPointWidget&) = delete;
269 };
270 
271 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkPointWidget::GetZShadows
int GetZShadows()
Definition: vtkPointWidget.h:146
vtkCursor3D.h
vtkPointWidget::SetPosition
void SetPosition(double x[3])
Definition: vtkPointWidget.h:114
vtkPointWidget::TranslationMode
int TranslationMode
Definition: vtkPointWidget.h:252
vtkPointWidget::GetOutline
int GetOutline()
Definition: vtkPointWidget.h:122
vtkPointWidget::GetYShadows
int GetYShadows()
Definition: vtkPointWidget.h:138
vtkLineWidget::CreateDefaultProperties
void CreateDefaultProperties()
vtkPointWidget::YShadowsOn
void YShadowsOn()
Definition: vtkPointWidget.h:139
vtkCursor3D
generate a 3D cursor representation
Definition: vtkCursor3D.h:36
vtkLineWidget::OnRightButtonDown
void OnRightButtonDown()
vtkPointWidget::WaitingForMotion
int WaitingForMotion
Definition: vtkPointWidget.h:263
vtkPointWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Definition: vtkPointWidget.h:95
vtkLineWidget::OnMiddleButtonDown
void OnMiddleButtonDown()
vtkPointWidget::GetPosition
void GetPosition(double xyz[3])
Definition: vtkPointWidget.h:116
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkLineWidget::Start
Definition: vtkLineWidget.h:199
vtkPointWidget::Property
vtkProperty * Property
Definition: vtkPointWidget.h:256
vtkPointWidget::SelectedProperty
vtkProperty * SelectedProperty
Definition: vtkPointWidget.h:257
vtkPointWidget::WidgetState
WidgetState
Definition: vtkPointWidget.h:213
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkPointWidget::OutlineOn
void OutlineOn()
Definition: vtkPointWidget.h:123
vtkLineWidget::OnLeftButtonUp
void OnLeftButtonUp()
vtkPointWidget
position a point in 3D space
Definition: vtkPointWidget.h:77
vtk3DWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPointWidget::ZShadowsOff
void ZShadowsOff()
Definition: vtkPointWidget.h:148
vtkPointWidget::HotSpotSize
double HotSpotSize
Definition: vtkPointWidget.h:261
vtkPointWidget::YShadowsOff
void YShadowsOff()
Definition: vtkPointWidget.h:140
vtkPointWidget::WaitCount
int WaitCount
Definition: vtkPointWidget.h:264
vtkPointWidget::Translating
Definition: vtkPointWidget.h:218
vtkPointWidget::AllOff
void AllOff()
Definition: vtkPointWidget.h:175
vtkPointWidget::State
int State
Definition: vtkPointWidget.h:212
vtkPointWidget::SetPosition
void SetPosition(double x, double y, double z)
Set/Get the position of the point.
Definition: vtkPointWidget.h:113
vtkLineWidget::OnRightButtonUp
void OnRightButtonUp()
vtkLineWidget::OnMouseMove
virtual void OnMouseMove()
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkLineWidget
3D widget for manipulating a line
Definition: vtkLineWidget.h:87
vtkPointWidget::GetTranslationMode
int GetTranslationMode()
Definition: vtkPointWidget.h:160
vtkLineWidget::Scale
void Scale(double *p1, double *p2, int X, int Y)
vtkPointWidget::Cursor3D
vtkCursor3D * Cursor3D
Definition: vtkPointWidget.h:238
vtkInteractorObserver::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkPointWidget::TranslationModeOn
void TranslationModeOn()
Definition: vtkPointWidget.h:161
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkPointWidget::GetPosition
double * GetPosition()
Definition: vtkPointWidget.h:115
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:73
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkPointWidget::ConstraintAxis
int ConstraintAxis
Definition: vtkPointWidget.h:248
vtkPointWidget::SetXShadows
void SetXShadows(int o)
Turn on/off the wireframe x-shadows.
Definition: vtkPointWidget.h:129
vtkPointWidget::XShadowsOn
void XShadowsOn()
Definition: vtkPointWidget.h:131
vtkLineWidget::Outside
Definition: vtkLineWidget.h:203
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
vtkLineWidget::OnLeftButtonDown
void OnLeftButtonDown()
vtkPointWidget::SetOutline
void SetOutline(int o)
Turn on/off the wireframe bounding box.
Definition: vtkPointWidget.h:121
vtkInteractorObserver::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkPointWidget::SetTranslationMode
void SetTranslationMode(int mode)
If translation mode is on, as the widget is moved the bounding box, shadows, and cursor are all trans...
Definition: vtkPointWidget.h:155
vtkLineWidget::OnMiddleButtonUp
void OnMiddleButtonUp()
vtkPointWidget::PlaceWidget
void PlaceWidget() override
Definition: vtkPointWidget.h:94
vtkPointWidget::XShadowsOff
void XShadowsOff()
Definition: vtkPointWidget.h:132
vtkPointWidget::SetYShadows
void SetYShadows(int o)
Turn on/off the wireframe y-shadows.
Definition: vtkPointWidget.h:137
vtkPointWidget::CursorPicker
vtkCellPicker * CursorPicker
Definition: vtkPointWidget.h:242
vtkPointWidget::Mapper
vtkPolyDataMapper * Mapper
Definition: vtkPointWidget.h:237
vtkPointWidget::Scaling
Definition: vtkPointWidget.h:217
vtkPointWidget::Actor
vtkActor * Actor
Definition: vtkPointWidget.h:236
vtk3DWidget::PlaceWidget
virtual void PlaceWidget()
vtkPointWidget::SetZShadows
void SetZShadows(int o)
Turn on/off the wireframe z-shadows.
Definition: vtkPointWidget.h:145
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkX3D::mode
Definition: vtkX3D.h:253
vtkPointWidget::ZShadowsOn
void ZShadowsOn()
Definition: vtkPointWidget.h:147
vtk3DWidget.h
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkPointWidget::AllOn
void AllOn()
Convenience methods to turn outline and shadows on and off.
Definition: vtkPointWidget.h:168
vtkPointWidget::Moving
Definition: vtkPointWidget.h:216
vtkPointWidget::GetXShadows
int GetXShadows()
Definition: vtkPointWidget.h:130
vtkPointWidget::TranslationModeOff
void TranslationModeOff()
Definition: vtkPointWidget.h:162
vtkPointWidget::OutlineOff
void OutlineOff()
Definition: vtkPointWidget.h:124