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) override;
55 
57 
64  void SetWorldPosition(double p[3]) override;
65  void SetDisplayPosition(double p[3]) 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(vtkTypeBool mode);
129  vtkGetMacro(TranslationMode,vtkTypeBool);
130  vtkBooleanMacro(TranslationMode,vtkTypeBool);
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) override;
178 
180 
183  double *GetBounds() VTK_SIZEHINT(6) override;
184  void BuildRepresentation() override;
185  void StartWidgetInteraction(double eventPos[2]) override;
186  void WidgetInteraction(double eventPos[2]) override;
187  int ComputeInteractionState(int X, int Y, int modify=0) override;
188  void PlaceWidget(double bounds[6]) override;
189  void StartComplexInteraction(
191  vtkAbstractWidget *widget,
192  unsigned long event, void *calldata) override;
193  void ComplexInteraction(
195  vtkAbstractWidget *widget,
196  unsigned long event, void *calldata) override;
197  int ComputeComplexInteractionState(
199  vtkAbstractWidget *widget,
200  unsigned long event, void *calldata, int modify = 0) override;
202 
204 
207  void ShallowCopy(vtkProp *prop) override;
208  void DeepCopy(vtkProp *prop) override;
209  void GetActors(vtkPropCollection *) override;
210  void ReleaseGraphicsResources(vtkWindow *) override;
211  int RenderOpaqueGeometry(vtkViewport *viewport) override;
212  int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override;
213  int HasTranslucentPolygonalGeometry() override;
215 
216  void Highlight(int highlight) override;
217 
219 
230  vtkSetMacro( SmoothMotion, vtkTypeBool );
231  vtkGetMacro( SmoothMotion, vtkTypeBool );
232  vtkBooleanMacro( SmoothMotion, vtkTypeBool );
234 
235  /*
236  * Register internal Pickers within PickingManager
237  */
238  void RegisterPickers() override;
239 
240 protected:
242  ~vtkPointHandleRepresentation3D() override;
243 
244  // the cursor3D
245  vtkActor *Actor;
247  vtkCursor3D *Cursor3D;
248 
249 
250  // Do the picking
251  vtkCellPicker *CursorPicker;
252  double LastPickPosition[3];
253  double LastEventPosition[3];
254 
255  // Methods to manipulate the cursor
256  int ConstraintAxis;
257  void Translate(double *p1, double *p2);
258  void Scale(double *p1, double *p2, double eventPos[2]);
259  void MoveFocus(double *p1, double *p2);
260  void SizeBounds();
261 
262  // Given a motion vector defined by p1 --> p2 (p1 and p2 are in
263  // world coordinates), the new display position of the handle center is
264  // populated into requestedDisplayPos. This is again only a request for the
265  // new display position. It is up to the point placer to deduce the
266  // appropriate world co-ordinates that this display position will map into.
267  // The placer may even disallow such a movement.
268  // If "SmoothMotion" is OFF, the returned requestedDisplayPos is the same
269  // as the event position, ie the location of the mouse cursor. If its OFF,
270  // incremental offsets as described above are used to compute it.
271  void MoveFocusRequest( double *p1, double *p2,
272  double eventPos[2], double requestedDisplayPos[3] );
273 
274  // Properties used to control the appearance of selected objects and
275  // the manipulator in general.
276  vtkProperty *Property;
277  vtkProperty *SelectedProperty;
278  void CreateDefaultProperties();
279 
280  // The size of the hot spot.
281  double HotSpotSize;
282  int DetermineConstraintAxis(int constraint, double *x, double *startPoint);
283  int WaitingForMotion;
284  int WaitCount;
285 
286  // Current handle sized (may reflect scaling)
287  double CurrentHandleSize;
288 
289  // Control how translation works
290  vtkTypeBool TranslationMode;
291 
292  vtkTypeBool SmoothMotion;
293 
294 private:
296  void operator=(const vtkPointHandleRepresentation3D&) = delete;
297 };
298 
299 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkCursor3D.h
vtkPointHandleRepresentation3D::XShadowsOff
void XShadowsOff()
Definition: vtkPointHandleRepresentation3D.h:89
vtkPointHandleRepresentation3D::SetXShadows
void SetXShadows(int o)
Turn on/off the wireframe x-shadows.
Definition: vtkPointHandleRepresentation3D.h:83
vtkCursor3D
generate a 3D cursor representation
Definition: vtkCursor3D.h:36
vtkPointHandleRepresentation3D::SetYShadows
void SetYShadows(int o)
Turn on/off the wireframe y-shadows.
Definition: vtkPointHandleRepresentation3D.h:95
vtkPointHandleRepresentation3D
represent the position of a point in 3D space
Definition: vtkPointHandleRepresentation3D.h:40
vtkPointHandleRepresentation3D::GetYShadows
int GetYShadows()
Definition: vtkPointHandleRepresentation3D.h:97
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkPointHandleRepresentation3D::YShadowsOn
void YShadowsOn()
Definition: vtkPointHandleRepresentation3D.h:99
vtkPointHandleRepresentation3D::GetZShadows
int GetZShadows()
Definition: vtkPointHandleRepresentation3D.h:109
vtkHandleRepresentation::SetWorldPosition
virtual void SetWorldPosition(double pos[3])
vtkHandleRepresentation
abstract class for representing widget handles
Definition: vtkHandleRepresentation.h:55
vtkHandleRepresentation.h
vtkPointHandleRepresentation3D::AllOn
void AllOn()
Convenience methods to turn outline and shadows on and off.
Definition: vtkPointHandleRepresentation3D.h:137
vtkPointHandleRepresentation3D::SetOutline
void SetOutline(int o)
Turn on/off the wireframe bounding box.
Definition: vtkPointHandleRepresentation3D.h:71
vtkWidgetRepresentation::SetHandleSize
virtual void SetHandleSize(double)
Set/Get the factor that controls the size of the handles that appear as part of the widget (if any).
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkHandleRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAbstractWidget
define the API for widget / widget representation
Definition: vtkAbstractWidget.h:63
vtkPointHandleRepresentation3D::GetXShadows
int GetXShadows()
Definition: vtkPointHandleRepresentation3D.h:85
vtkWidgetRepresentation::GetBounds
double * GetBounds() override
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:215
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkPointHandleRepresentation3D::AllOff
void AllOff()
Definition: vtkPointHandleRepresentation3D.h:144
vtkPointHandleRepresentation3D::OutlineOff
void OutlineOff()
Definition: vtkPointHandleRepresentation3D.h:77
vtkX3D::size
Definition: vtkX3D.h:253
vtkPointHandleRepresentation3D::SetZShadows
void SetZShadows(int o)
Turn on/off the wireframe z-shadows.
Definition: vtkPointHandleRepresentation3D.h:107
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:72
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkPointHandleRepresentation3D::ZShadowsOff
void ZShadowsOff()
Definition: vtkPointHandleRepresentation3D.h:113
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
vtkHandleRepresentation::SetDisplayPosition
virtual void SetDisplayPosition(double pos[3])
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
vtkPointHandleRepresentation3D::YShadowsOff
void YShadowsOff()
Definition: vtkPointHandleRepresentation3D.h:101
vtkPointHandleRepresentation3D::XShadowsOn
void XShadowsOn()
Definition: vtkPointHandleRepresentation3D.h:87
vtkPointHandleRepresentation3D::ZShadowsOn
void ZShadowsOn()
Definition: vtkPointHandleRepresentation3D.h:111
vtkX3D::mode
Definition: vtkX3D.h:247
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:60
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:35
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkPointHandleRepresentation3D::GetOutline
int GetOutline()
Definition: vtkPointHandleRepresentation3D.h:73
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPointHandleRepresentation3D::OutlineOn
void OutlineOn()
Definition: vtkPointHandleRepresentation3D.h:75