VTK
vtkPointHandleRepresentation3D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPointHandleRepresentation3D.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 =========================================================================*/
27 #ifndef vtkPointHandleRepresentation3D_h
28 #define vtkPointHandleRepresentation3D_h
29 
30 #include "vtkInteractionWidgetsModule.h" // For export macro
32 #include "vtkCursor3D.h" // Needed for delegation to cursor3D
33 
34 class vtkCursor3D;
35 class vtkProperty;
36 class vtkActor;
37 class vtkPolyDataMapper;
38 class vtkCellPicker;
39 
40 class VTKINTERACTIONWIDGETS_EXPORT vtkPointHandleRepresentation3D : public vtkHandleRepresentation
41 {
42 public:
47 
49 
53  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
55 
57 
64  void SetWorldPosition(double p[3]) VTK_OVERRIDE;
65  void SetDisplayPosition(double p[3]) VTK_OVERRIDE;
67 
71  void SetOutline(int o)
72  {this->Cursor3D->SetOutline(o);}
73  int GetOutline()
74  {return this->Cursor3D->GetOutline();}
75  void OutlineOn()
76  {this->Cursor3D->OutlineOn();}
77  void OutlineOff()
78  {this->Cursor3D->OutlineOff();}
79 
83  void SetXShadows(int o)
84  {this->Cursor3D->SetXShadows(o);}
86  {return this->Cursor3D->GetXShadows();}
87  void XShadowsOn()
88  {this->Cursor3D->XShadowsOn();}
89  void XShadowsOff()
90  {this->Cursor3D->XShadowsOff();}
91 
95  void SetYShadows(int o)
96  {this->Cursor3D->SetYShadows(o);}
98  {return this->Cursor3D->GetYShadows();}
99  void YShadowsOn()
100  {this->Cursor3D->YShadowsOn();}
101  void YShadowsOff()
102  {this->Cursor3D->YShadowsOff();}
103 
107  void SetZShadows(int o)
108  {this->Cursor3D->SetZShadows(o);}
110  {return this->Cursor3D->GetZShadows();}
111  void ZShadowsOn()
112  {this->Cursor3D->ZShadowsOn();}
113  void ZShadowsOff()
114  {this->Cursor3D->ZShadowsOff();}
115 
117 
128  void SetTranslationMode(int mode);
129  vtkGetMacro(TranslationMode,int);
130  vtkBooleanMacro(TranslationMode,int);
132 
134 
137  void AllOn()
138  {
139  this->OutlineOn();
140  this->XShadowsOn();
141  this->YShadowsOn();
142  this->ZShadowsOn();
143  }
144  void AllOff()
145  {
146  this->OutlineOff();
147  this->XShadowsOff();
148  this->YShadowsOff();
149  this->ZShadowsOff();
150  }
152 
154 
157  void SetProperty(vtkProperty*);
158  void SetSelectedProperty(vtkProperty*);
159  vtkGetObjectMacro(Property,vtkProperty);
160  vtkGetObjectMacro(SelectedProperty,vtkProperty);
162 
164 
170  vtkSetClampMacro(HotSpotSize,double,0.0,1.0);
171  vtkGetMacro(HotSpotSize,double);
173 
177  void SetHandleSize(double size) VTK_OVERRIDE;
178 
180 
183  double *GetBounds() VTK_OVERRIDE;
184  void BuildRepresentation() VTK_OVERRIDE;
185  void StartWidgetInteraction(double eventPos[2]) VTK_OVERRIDE;
186  void WidgetInteraction(double eventPos[2]) VTK_OVERRIDE;
187  int ComputeInteractionState(int X, int Y, int modify=0) VTK_OVERRIDE;
188  void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
190 
192 
195  void ShallowCopy(vtkProp *prop) VTK_OVERRIDE;
196  void DeepCopy(vtkProp *prop) VTK_OVERRIDE;
197  void GetActors(vtkPropCollection *) VTK_OVERRIDE;
198  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
199  int RenderOpaqueGeometry(vtkViewport *viewport) VTK_OVERRIDE;
200  int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) VTK_OVERRIDE;
201  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
203 
204  void Highlight(int highlight) VTK_OVERRIDE;
205 
207 
218  vtkSetMacro( SmoothMotion, int );
219  vtkGetMacro( SmoothMotion, int );
220  vtkBooleanMacro( SmoothMotion, int );
222 
223 protected:
225  ~vtkPointHandleRepresentation3D() VTK_OVERRIDE;
226 
227  // the cursor3D
231 
232 
233  // Do the picking
235  double LastPickPosition[3];
236  double LastEventPosition[2];
237 
238  // Register internal Pickers within PickingManager
239  void RegisterPickers() VTK_OVERRIDE;
240 
241  // Methods to manipulate the cursor
242  int ConstraintAxis;
243  void Translate(double *p1, double *p2);
244  void Scale(double *p1, double *p2, double eventPos[2]);
245  void MoveFocus(double *p1, double *p2);
246  void SizeBounds();
247 
248  // Given a motion vector defined by p1 --> p2 (p1 and p2 are in
249  // world coordinates), the new display position of the handle center is
250  // populated into requestedDisplayPos. This is again only a request for the
251  // new display position. It is up to the point placer to deduce the
252  // appropriate world co-ordinates that this display position will map into.
253  // The placer may even disallow such a movement.
254  // If "SmoothMotion" is OFF, the returned requestedDisplayPos is the same
255  // as the event position, ie the location of the mouse cursor. If its OFF,
256  // incremental offsets as described above are used to compute it.
257  void MoveFocusRequest( double *p1, double *p2,
258  double eventPos[2], double requestedDisplayPos[3] );
259 
260  // Properties used to control the appearance of selected objects and
261  // the manipulator in general.
262  vtkProperty *Property;
263  vtkProperty *SelectedProperty;
264  void CreateDefaultProperties();
265 
266  // The size of the hot spot.
267  double HotSpotSize;
268  int DetermineConstraintAxis(int constraint, double *x, double *startPoint);
269  int WaitingForMotion;
270  int WaitCount;
271 
272  // Current handle sized (may reflect scaling)
273  double CurrentHandleSize;
274 
275  // Control how translation works
276  int TranslationMode;
277 
278  int SmoothMotion;
279 
280 private:
282  void operator=(const vtkPointHandleRepresentation3D&) VTK_DELETE_FUNCTION;
283 };
284 
285 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
virtual void SetWorldPosition(double pos[3])
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
virtual int ComputeInteractionState(int X, int Y, int modify=0)
abstract class for representing widget handles
represent the position of a point in 3D space
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:58
virtual void StartWidgetInteraction(double eventPos[2])
void AllOn()
Convenience methods to turn outline and shadows on and off.
virtual void SetHandleSize(double)
Set/Get the factor that controls the size of the handles that appear as part of the widget (if any)...
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
void SetYShadows(int o)
Turn on/off the wireframe y-shadows.
double * GetBounds() override
Methods to make this class behave as a vtkProp.
an ordered list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
void SetZShadows(int o)
Turn on/off the wireframe z-shadows.
void SetOutline(int o)
Turn on/off the wireframe bounding box.
int HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
virtual void WidgetInteraction(double newEventPos[2])
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
virtual void DeepCopy(vtkProp *prop)
Methods to make this class properly act like a vtkWidgetRepresentation.
map vtkPolyData to graphics primitives
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
The following is a suggested API for widget representations.
void AllOff()
Convenience methods to turn outline and shadows on and off.
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
void ShallowCopy(vtkProp *prop) override
Methods to make this class properly act like a vtkWidgetRepresentation.
virtual void Highlight(int vtkNotUsed(highlightOn))
generate a 3D cursor representation
Definition: vtkCursor3D.h:36
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void SetXShadows(int o)
Turn on/off the wireframe x-shadows.
virtual void SetDisplayPosition(double pos[3])
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...