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 "vtkInteractionWidgetsModule.h" // For export macro
68 #include "vtk3DWidget.h"
69 #include "vtkCursor3D.h" // Needed for faster access to the Cursor3D
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
95  {this->Superclass::PlaceWidget();}
96  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
97  double zmin, double zmax) override
98  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
100 
105  void GetPolyData(vtkPolyData *pd);
106 
112  void SetPosition(double x, double y, double z)
113  {this->Cursor3D->SetFocalPoint(x,y,z);}
114  void SetPosition(double x[3])
115  {this->SetPosition(x[0],x[1],x[2]);}
117  {return this->Cursor3D->GetFocalPoint();}
118  void GetPosition(double xyz[3])
119  {this->Cursor3D->GetFocalPoint(xyz);}
120 
124  void SetOutline(int o)
125  {this->Cursor3D->SetOutline(o);}
127  {return this->Cursor3D->GetOutline();}
128  void OutlineOn()
129  {this->Cursor3D->OutlineOn();}
130  void OutlineOff()
131  {this->Cursor3D->OutlineOff();}
132 
136  void SetXShadows(int o)
137  {this->Cursor3D->SetXShadows(o);}
139  {return this->Cursor3D->GetXShadows();}
140  void XShadowsOn()
141  {this->Cursor3D->XShadowsOn();}
142  void XShadowsOff()
143  {this->Cursor3D->XShadowsOff();}
144 
148  void SetYShadows(int o)
149  {this->Cursor3D->SetYShadows(o);}
151  {return this->Cursor3D->GetYShadows();}
152  void YShadowsOn()
153  {this->Cursor3D->YShadowsOn();}
154  void YShadowsOff()
155  {this->Cursor3D->YShadowsOff();}
156 
160  void SetZShadows(int o)
161  {this->Cursor3D->SetZShadows(o);}
163  {return this->Cursor3D->GetZShadows();}
164  void ZShadowsOn()
165  {this->Cursor3D->ZShadowsOn();}
166  void ZShadowsOff()
167  {this->Cursor3D->ZShadowsOff();}
168 
175  { this->Cursor3D->SetTranslationMode(mode); this->Cursor3D->Update(); }
177  { return this->Cursor3D->GetTranslationMode(); }
179  { this->SetTranslationMode(1); }
181  { this->SetTranslationMode(0); }
182 
184 
187  void AllOn()
188  {
189  this->OutlineOn();
190  this->XShadowsOn();
191  this->YShadowsOn();
192  this->ZShadowsOn();
193  }
194  void AllOff()
195  {
196  this->OutlineOff();
197  this->XShadowsOff();
198  this->YShadowsOff();
199  this->ZShadowsOff();
200  }
202 
204 
209  vtkGetObjectMacro(Property,vtkProperty);
210  vtkGetObjectMacro(SelectedProperty,vtkProperty);
212 
214 
220  vtkSetClampMacro(HotSpotSize,double,0.0,1.0);
221  vtkGetMacro(HotSpotSize,double);
223 
224 protected:
225  vtkPointWidget();
226  ~vtkPointWidget() override;
227 
228  // Manage the state of the widget
229  friend class vtkLineWidget;
230 
231  int State;
233  {
234  Start=0,
239  };
240 
241  // Handles the events
242  static void ProcessEvents(vtkObject* object,
243  unsigned long event,
244  void* clientdata,
245  void* calldata);
246 
247  // ProcessEvents() dispatches to these methods.
248  virtual void OnMouseMove();
249  virtual void OnLeftButtonDown();
250  virtual void OnLeftButtonUp();
251  virtual void OnMiddleButtonDown();
252  virtual void OnMiddleButtonUp();
253  virtual void OnRightButtonDown();
254  virtual void OnRightButtonUp();
255 
256  // the cursor3D
260  void Highlight(int highlight);
261 
262  // Do the picking
264 
265  // Register internal Pickers within PickingManager
266  void RegisterPickers() override;
267 
268  // Methods to manipulate the cursor
270  void Translate(double *p1, double *p2);
271  void Scale(double *p1, double *p2, int X, int Y);
272  void MoveFocus(double *p1, double *p2);
274 
275  // Properties used to control the appearance of selected objects and
276  // the manipulator in general.
280 
281  // The size of the hot spot.
282  double HotSpotSize;
283  int DetermineConstraintAxis(int constraint, double *x);
286 
287 private:
288  vtkPointWidget(const vtkPointWidget&) = delete;
289  void operator=(const vtkPointWidget&) = delete;
290 };
291 
292 #endif
void OnRightButtonDown()
vtkProperty * SelectedProperty
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
void TranslationModeOff()
abstract base class for most VTK objects
Definition: vtkObject.h:53
void OnLeftButtonDown()
represent surface properties of a geometric object
Definition: vtkProperty.h:60
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:33
void AllOn()
Convenience methods to turn outline and shadows on and off.
3D widget for manipulating a line
Definition: vtkLineWidget.h:87
#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:63
void TranslationModeOn()
void SetPosition(double x[3])
generate a 3D cursor representation
Definition: vtkCursor3D.h:36
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:67
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)