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) 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]) 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) override;
200  void BuildRepresentation() override;
201  void StartWidgetInteraction(double eventPos[2]) override;
202  void WidgetInteraction(double eventPos[2]) override;
203  int ComputeInteractionState(int X, int Y, int modify) override;
205 
210  void SetDisplayPosition(double pos[3]) override;
211 
213 
216  void GetActors(vtkPropCollection *) override;
217  void ReleaseGraphicsResources(vtkWindow *) override;
218  int RenderOverlay(vtkViewport *viewport) override;
219  int RenderOpaqueGeometry(vtkViewport *viewport) override;
220  int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override;
221  int HasTranslucentPolygonalGeometry() override;
222  void ShallowCopy(vtkProp* prop) override;
224 
225  enum {XAxis=0,YAxis,ZAxis,Oblique};
226 
227  void Highlight(int highlight) override;
228 
229 protected:
232 
233  // Render the cursor
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.
256  void CreateDefaultProperties();
257 
258  // Controlling vars
263 
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=nullptr);
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&) = delete;
288 };
289 
290 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkWidgetRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double eventPos[2])
Definition: vtkWidgetRepresentation.h:136
vtkWidgetRepresentation::GetActors
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes.
Definition: vtkWidgetRepresentation.h:217
vtkConstrainedPointHandleRepresentation::ZAxis
Definition: vtkConstrainedPointHandleRepresentation.h:225
vtkConstrainedPointHandleRepresentation
point representation constrained to a 2D plane
Definition: vtkConstrainedPointHandleRepresentation.h:55
vtkPlane
perform various plane computations
Definition: vtkPlane.h:31
vtkConstrainedPointHandleRepresentation::SelectedProperty
vtkProperty * SelectedProperty
Definition: vtkConstrainedPointHandleRepresentation.h:254
vtkConstrainedPointHandleRepresentation::SetProjectionNormalToXAxis
void SetProjectionNormalToXAxis()
Definition: vtkConstrainedPointHandleRepresentation.h:103
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkConstrainedPointHandleRepresentation::Actor
vtkActor * Actor
Definition: vtkConstrainedPointHandleRepresentation.h:234
vtkConstrainedPointHandleRepresentation::ProjectionPosition
double ProjectionPosition
Definition: vtkConstrainedPointHandleRepresentation.h:260
vtkHandleRepresentation
abstract class for representing widget handles
Definition: vtkHandleRepresentation.h:55
vtkConstrainedPointHandleRepresentation::Mapper
vtkPolyDataMapper * Mapper
Definition: vtkConstrainedPointHandleRepresentation.h:235
vtkConstrainedPointHandleRepresentation::CursorShape
vtkPolyData * CursorShape
Definition: vtkConstrainedPointHandleRepresentation.h:237
vtkConstrainedPointHandleRepresentation::ActiveCursorShape
vtkPolyData * ActiveCursorShape
Definition: vtkConstrainedPointHandleRepresentation.h:238
vtkWidgetRepresentation::BuildRepresentation
virtual void BuildRepresentation()=0
vtkHandleRepresentation.h
vtkPlanes
implicit function for convex set of planes
Definition: vtkPlanes.h:49
vtkConstrainedPointHandleRepresentation::ProjectToPlane
int ProjectToPlane
Definition: vtkConstrainedPointHandleRepresentation.h:261
vtkConstrainedPointHandleRepresentation::Property
vtkProperty * Property
Definition: vtkConstrainedPointHandleRepresentation.h:253
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.
vtkWidgetRepresentation::RenderTranslucentPolygonalGeometry
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:223
vtkWidgetRepresentation::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkWidgetRepresentation.h:220
vtkX3D::position
Definition: vtkX3D.h:261
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:137
vtkWidgetRepresentation::HasTranslucentPolygonalGeometry
int HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkWidgetRepresentation.h:225
vtkConstrainedPointHandleRepresentation::SetProjectionNormalToOblique
void SetProjectionNormalToOblique()
Definition: vtkConstrainedPointHandleRepresentation.h:109
vtkConstrainedPointHandleRepresentation::ObliquePlane
vtkPlane * ObliquePlane
Definition: vtkConstrainedPointHandleRepresentation.h:262
vtkConstrainedPointHandleRepresentation::ActiveProperty
vtkProperty * ActiveProperty
Definition: vtkConstrainedPointHandleRepresentation.h:255
vtkConstrainedPointHandleRepresentation::SetProjectionNormalToZAxis
void SetProjectionNormalToZAxis()
Definition: vtkConstrainedPointHandleRepresentation.h:107
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
vtkHandleRepresentation::CheckConstraint
virtual int CheckConstraint(vtkRenderer *renderer, double pos[2])
Method has to be overridden in the subclasses which has constraints on placing the handle (Ex.
vtkConstrainedPointHandleRepresentation::BoundingPlanes
vtkPlaneCollection * BoundingPlanes
Definition: vtkConstrainedPointHandleRepresentation.h:264
vtkConstrainedPointHandleRepresentation::FocalData
vtkPolyData * FocalData
Definition: vtkConstrainedPointHandleRepresentation.h:239
vtkConstrainedPointHandleRepresentation::SetProjectionNormalToYAxis
void SetProjectionNormalToYAxis()
Definition: vtkConstrainedPointHandleRepresentation.h:105
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkGlyph3D
copy oriented and scaled glyph geometry to every input point
Definition: vtkGlyph3D.h:105
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
vtkConstrainedPointHandleRepresentation::Glypher
vtkGlyph3D * Glypher
Definition: vtkConstrainedPointHandleRepresentation.h:236
vtkWidgetRepresentation::RenderOverlay
int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:221
vtkConstrainedPointHandleRepresentation::Oblique
Definition: vtkConstrainedPointHandleRepresentation.h:225
vtkWidgetRepresentation::RenderOpaqueGeometry
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:222
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:57
vtkHandleRepresentation::SetDisplayPosition
virtual void SetDisplayPosition(double pos[3])
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
vtkConstrainedPointHandleRepresentation::XAxis
Definition: vtkConstrainedPointHandleRepresentation.h:225
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkConstrainedPointHandleRepresentation::YAxis
Definition: vtkConstrainedPointHandleRepresentation.h:225
vtkHandleRepresentation::SetRenderer
void SetRenderer(vtkRenderer *ren) override
Subclasses of vtkWidgetRepresentation must implement these methods.
vtkHandleRepresentation::ShallowCopy
void ShallowCopy(vtkProp *prop) override
Methods to make this class properly act like a vtkWidgetRepresentation.
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:60
vtkPlaneCollection
maintain a list of planes
Definition: vtkPlaneCollection.h:33
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:35
vtkConstrainedPointHandleRepresentation::ProjectionNormal
int ProjectionNormal
Definition: vtkConstrainedPointHandleRepresentation.h:259
vtkConstrainedPointHandleRepresentation::FocalPoint
vtkPoints * FocalPoint
Definition: vtkConstrainedPointHandleRepresentation.h:240
vtkWidgetRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkWidgetRepresentation::Highlight
virtual void Highlight(int vtkNotUsed(highlightOn))
Definition: vtkWidgetRepresentation.h:142