VTK
vtkConstrainedPointHandleRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkConstrainedPointHandleRepresentation.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 =========================================================================*/
37 #ifndef vtkConstrainedPointHandleRepresentation_h
38 #define vtkConstrainedPointHandleRepresentation_h
39 
40 #include "vtkInteractionWidgetsModule.h" // For export macro
42 
43 class vtkProperty;
44 class vtkActor;
45 class vtkPolyDataMapper;
46 class vtkPolyData;
47 class vtkGlyph3D;
48 class vtkPoints;
49 class vtkPolyData;
50 class vtkPlane;
51 class vtkPlaneCollection;
52 class vtkPlanes;
53 class vtkRenderer;
54 
55 class VTKINTERACTIONWIDGETS_EXPORT vtkConstrainedPointHandleRepresentation : public vtkHandleRepresentation
56 {
57 public:
62 
64 
68  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
70 
72 
77  void SetCursorShape(vtkPolyData *cursorShape);
78  vtkPolyData *GetCursorShape();
80 
82 
87  void SetActiveCursorShape(vtkPolyData *activeShape);
88  vtkPolyData *GetActiveCursorShape();
90 
92 
97  vtkSetClampMacro(ProjectionNormal,int,
100  vtkGetMacro(ProjectionNormal,int);
102 
104  { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::XAxis); }
106  { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::YAxis); }
108  { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::ZAxis); }
110  { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::Oblique); }
111 
113 
117  void SetObliquePlane(vtkPlane *);
118  vtkGetObjectMacro(ObliquePlane, vtkPlane);
120 
122 
129  void SetProjectionPosition(double position);
130  vtkGetMacro(ProjectionPosition, double);
132 
134 
142  void AddBoundingPlane(vtkPlane *plane);
143  void RemoveBoundingPlane(vtkPlane *plane);
144  void RemoveAllBoundingPlanes();
145  virtual void SetBoundingPlanes(vtkPlaneCollection*);
146  vtkGetObjectMacro(BoundingPlanes,vtkPlaneCollection);
147  void SetBoundingPlanes(vtkPlanes *planes);
149 
155  int CheckConstraint(vtkRenderer *renderer, double pos[2]) VTK_OVERRIDE;
156 
158 
163  void SetPosition(double x, double y, double z);
164  void SetPosition(double xyz[3]);
165  double* GetPosition();
166  void GetPosition(double xyz[3]);
168 
170 
174  vtkGetObjectMacro(Property,vtkProperty);
176 
178 
182  vtkGetObjectMacro(SelectedProperty,vtkProperty);
184 
186 
190  vtkGetObjectMacro(ActiveProperty,vtkProperty);
192 
194 
199  void SetRenderer(vtkRenderer *ren) VTK_OVERRIDE;
200  void BuildRepresentation() VTK_OVERRIDE;
201  void StartWidgetInteraction(double eventPos[2]) VTK_OVERRIDE;
202  void WidgetInteraction(double eventPos[2]) VTK_OVERRIDE;
203  int ComputeInteractionState(int X, int Y, int modify) VTK_OVERRIDE;
205 
210  void SetDisplayPosition(double pos[3]) VTK_OVERRIDE;
211 
213 
216  void GetActors(vtkPropCollection *) VTK_OVERRIDE;
217  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
218  int RenderOverlay(vtkViewport *viewport) VTK_OVERRIDE;
219  int RenderOpaqueGeometry(vtkViewport *viewport) VTK_OVERRIDE;
220  int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) VTK_OVERRIDE;
221  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
222  void ShallowCopy(vtkProp* prop) VTK_OVERRIDE;
224 
225  enum {XAxis=0,YAxis,ZAxis,Oblique};
226 
227  void Highlight(int highlight) VTK_OVERRIDE;
228 
229 protected:
232 
233  // Render the cursor
234  vtkActor *Actor;
236  vtkGlyph3D *Glypher;
237  vtkPolyData *CursorShape;
238  vtkPolyData *ActiveCursorShape;
239  vtkPolyData *FocalData;
240  vtkPoints *FocalPoint;
241 
242  // Support picking
243  double LastPickPosition[3];
244  double LastEventPosition[2];
245 
246  // Methods to manipulate the cursor
247  void Translate(double eventPos[2]);
248  void Scale(double eventPos[2]);
249 
250 
251  // Properties used to control the appearance of selected objects and
252  // the manipulator in general.
253  vtkProperty *Property;
254  vtkProperty *SelectedProperty;
255  vtkProperty *ActiveProperty;
256  void CreateDefaultProperties();
257 
258  // Controlling vars
259  int ProjectionNormal;
260  double ProjectionPosition;
261  int ProjectToPlane;
262  vtkPlane *ObliquePlane;
263 
264  vtkPlaneCollection *BoundingPlanes;
265 
266  // Internal method for computing 3D location from 2D screen position
267  int GetIntersectionPosition( double eventPos[2],
268  double worldPos[3],
269  double tolerance = 0.0,
270  vtkRenderer *renderer=0);
271 
272  // Internal method for getting the project normal as a vector
273  void GetProjectionNormal( double normal[3] );
274 
275  // Internal method for getting the origin of the
276  // constraining plane as a 3-tuple
277  void GetProjectionOrigin( double origin[3] );
278 
279 
280 
281  // Distance between where the mouse event happens and where the
282  // widget is focused - maintain this distance during interaction.
283  double InteractionOffset[2];
284 
285 private:
287  void operator=(const vtkConstrainedPointHandleRepresentation&) VTK_DELETE_FUNCTION;
288 };
289 
290 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
abstract class for representing widget handles
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:58
maintain a list of planes
implicit function for convex set of planes
Definition: vtkPlanes.h:48
abstract specification for renderers
Definition: vtkRenderer.h:57
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
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.
an ordered list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
virtual int CheckConstraint(vtkRenderer *renderer, double pos[2])
Method has to be overridden in the subclasses which has constraints on placing the handle (Ex...
a simple class to control print indentation
Definition: vtkIndent.h:33
copy oriented and scaled glyph geometry to every input point
Definition: vtkGlyph3D.h:105
perform various plane computations
Definition: vtkPlane.h:31
map vtkPolyData to graphics primitives
virtual void Highlight(int vtkNotUsed(highlightOn))
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void SetRenderer(vtkRenderer *ren) override
Methods to make this class properly act like a vtkWidgetRepresentation.
point representation constrained to a 2D plane
represent and manipulate 3D points
Definition: vtkPoints.h:33