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 =========================================================================*/
70 #ifndef vtkPointWidget_h
71 #define vtkPointWidget_h
72 
73 #include "vtkInteractionWidgetsModule.h" // For export macro
74 #include "vtk3DWidget.h"
75 #include "vtkCursor3D.h" // Needed for faster access to the Cursor3D
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);
93 
95 
98  virtual void SetEnabled(int);
99  virtual void PlaceWidget(double bounds[6]);
100  void PlaceWidget()
101  {this->Superclass::PlaceWidget();}
102  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
103  double zmin, double zmax)
104  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
106 
111  void GetPolyData(vtkPolyData *pd);
112 
118  void SetPosition(double x, double y, double z)
119  {this->Cursor3D->SetFocalPoint(x,y,z);}
120  void SetPosition(double x[3])
121  {this->SetPosition(x[0],x[1],x[2]);}
122  double* GetPosition()
123  {return this->Cursor3D->GetFocalPoint();}
124  void GetPosition(double xyz[3])
125  {this->Cursor3D->GetFocalPoint(xyz);}
126 
130  void SetOutline(int o)
131  {this->Cursor3D->SetOutline(o);}
133  {return this->Cursor3D->GetOutline();}
134  void OutlineOn()
135  {this->Cursor3D->OutlineOn();}
136  void OutlineOff()
137  {this->Cursor3D->OutlineOff();}
138 
142  void SetXShadows(int o)
143  {this->Cursor3D->SetXShadows(o);}
145  {return this->Cursor3D->GetXShadows();}
146  void XShadowsOn()
147  {this->Cursor3D->XShadowsOn();}
148  void XShadowsOff()
149  {this->Cursor3D->XShadowsOff();}
150 
154  void SetYShadows(int o)
155  {this->Cursor3D->SetYShadows(o);}
157  {return this->Cursor3D->GetYShadows();}
158  void YShadowsOn()
159  {this->Cursor3D->YShadowsOn();}
160  void YShadowsOff()
161  {this->Cursor3D->YShadowsOff();}
162 
166  void SetZShadows(int o)
167  {this->Cursor3D->SetZShadows(o);}
169  {return this->Cursor3D->GetZShadows();}
170  void ZShadowsOn()
171  {this->Cursor3D->ZShadowsOn();}
172  void ZShadowsOff()
173  {this->Cursor3D->ZShadowsOff();}
174 
181  { this->Cursor3D->SetTranslationMode(mode); this->Cursor3D->Update(); }
183  { return this->Cursor3D->GetTranslationMode(); }
185  { this->SetTranslationMode(1); }
187  { this->SetTranslationMode(0); }
188 
190 
193  void AllOn()
194  {
195  this->OutlineOn();
196  this->XShadowsOn();
197  this->YShadowsOn();
198  this->ZShadowsOn();
199  }
200  void AllOff()
201  {
202  this->OutlineOff();
203  this->XShadowsOff();
204  this->YShadowsOff();
205  this->ZShadowsOff();
206  }
208 
210 
215  vtkGetObjectMacro(Property,vtkProperty);
216  vtkGetObjectMacro(SelectedProperty,vtkProperty);
218 
220 
226  vtkSetClampMacro(HotSpotSize,double,0.0,1.0);
227  vtkGetMacro(HotSpotSize,double);
229 
230 protected:
231  vtkPointWidget();
232  ~vtkPointWidget();
233 
234  // Manage the state of the widget
235  friend class vtkLineWidget;
236 
237  int State;
239  {
240  Start=0,
245  };
246 
247  // Handles the events
248  static void ProcessEvents(vtkObject* object,
249  unsigned long event,
250  void* clientdata,
251  void* calldata);
252 
253  // ProcessEvents() dispatches to these methods.
254  virtual void OnMouseMove();
255  virtual void OnLeftButtonDown();
256  virtual void OnLeftButtonUp();
257  virtual void OnMiddleButtonDown();
258  virtual void OnMiddleButtonUp();
259  virtual void OnRightButtonDown();
260  virtual void OnRightButtonUp();
261 
262  // the cursor3D
266  void Highlight(int highlight);
267 
268  // Do the picking
270 
271  // Register internal Pickers within PickingManager
272  virtual void RegisterPickers();
273 
274  // Methods to manipulate the cursor
276  void Translate(double *p1, double *p2);
277  void Scale(double *p1, double *p2, int X, int Y);
278  void MoveFocus(double *p1, double *p2);
280 
281  // Properties used to control the appearance of selected objects and
282  // the manipulator in general.
286 
287  // The size of the hot spot.
288  double HotSpotSize;
289  int DetermineConstraintAxis(int constraint, double *x);
292 
293 private:
294  vtkPointWidget(const vtkPointWidget&) VTK_DELETE_FUNCTION;
295  void operator=(const vtkPointWidget&) VTK_DELETE_FUNCTION;
296 };
297 
298 #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:59
void OnLeftButtonDown()
represent surface properties of a geometric object
Definition: vtkProperty.h:64
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:85
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)
Methods that satisfy the superclass' API.
vtkCursor3D * Cursor3D
void CreateDefaultProperties()
vtkProperty * Property
void PlaceWidget()
Methods that satisfy the superclass' API.
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
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:69
void TranslationModeOn()
void SetPosition(double x[3])
generate a 3D cursor representation
Definition: vtkCursor3D.h:39
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()
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
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)