VTK  9.0.20201030
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 
41 #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
57 {
58 public:
63 
65 
69  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
73 
75 
80  void SetCursorShape(vtkPolyData* cursorShape);
81  vtkPolyData* GetCursorShape();
83 
85 
90  void SetActiveCursorShape(vtkPolyData* activeShape);
91  vtkPolyData* GetActiveCursorShape();
93 
95 
100  vtkSetClampMacro(ProjectionNormal, int, vtkConstrainedPointHandleRepresentation::XAxis,
102  vtkGetMacro(ProjectionNormal, int);
104 
106  {
107  this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::XAxis);
108  }
110  {
111  this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::YAxis);
112  }
114  {
115  this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::ZAxis);
116  }
118  {
119  this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::Oblique);
120  }
121 
123 
127  void SetObliquePlane(vtkPlane*);
128  vtkGetObjectMacro(ObliquePlane, vtkPlane);
130 
132 
139  void SetProjectionPosition(double position);
140  vtkGetMacro(ProjectionPosition, double);
142 
144 
152  void AddBoundingPlane(vtkPlane* plane);
153  void RemoveBoundingPlane(vtkPlane* plane);
154  void RemoveAllBoundingPlanes();
155  virtual void SetBoundingPlanes(vtkPlaneCollection*);
156  vtkGetObjectMacro(BoundingPlanes, vtkPlaneCollection);
157  void SetBoundingPlanes(vtkPlanes* planes);
159 
165  int CheckConstraint(vtkRenderer* renderer, double pos[2]) override;
166 
168 
173  void SetPosition(double x, double y, double z);
174  void SetPosition(double xyz[3]);
175  double* GetPosition();
176  void GetPosition(double xyz[3]);
178 
180 
184  vtkGetObjectMacro(Property, vtkProperty);
186 
188 
192  vtkGetObjectMacro(SelectedProperty, vtkProperty);
194 
196 
200  vtkGetObjectMacro(ActiveProperty, vtkProperty);
202 
204 
209  void SetRenderer(vtkRenderer* ren) override;
210  void BuildRepresentation() override;
211  void StartWidgetInteraction(double eventPos[2]) override;
212  void WidgetInteraction(double eventPos[2]) override;
213  int ComputeInteractionState(int X, int Y, int modify) override;
215 
220  void SetDisplayPosition(double pos[3]) override;
221 
223 
226  void GetActors(vtkPropCollection*) override;
227  void ReleaseGraphicsResources(vtkWindow*) override;
228  int RenderOverlay(vtkViewport* viewport) override;
229  int RenderOpaqueGeometry(vtkViewport* viewport) override;
230  int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
232  void ShallowCopy(vtkProp* prop) override;
234 
235  enum
236  {
237  XAxis = 0,
240  Oblique
241  };
242 
243  void Highlight(int highlight) override;
244 
245 protected:
248 
249  // Render the cursor
257 
258  // Support picking
259  double LastPickPosition[3];
260  double LastEventPosition[2];
261 
262  // Methods to manipulate the cursor
263  void Translate(const double* eventPos) override;
264  void Scale(const double* eventPos);
265 
266  // Properties used to control the appearance of selected objects and
267  // the manipulator in general.
271  void CreateDefaultProperties();
272 
273  // Controlling vars
278 
280 
281  // Internal method for computing 3D location from 2D screen position
282  int GetIntersectionPosition(const double eventPos[2], double worldPos[3], double tolerance = 0.0,
283  vtkRenderer* renderer = nullptr);
284 
285  // Internal method for getting the project normal as a vector
286  void GetProjectionNormal(double normal[3]);
287 
288  // Internal method for getting the origin of the
289  // constraining plane as a 3-tuple
290  void GetProjectionOrigin(double origin[3]);
291 
292  // Distance between where the mouse event happens and where the
293  // widget is focused - maintain this distance during interaction.
294  double InteractionOffset[2];
295 
296 private:
298  void operator=(const vtkConstrainedPointHandleRepresentation&) = delete;
299 };
300 
301 #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:135
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:210
vtkConstrainedPointHandleRepresentation
point representation constrained to a 2D plane
Definition: vtkConstrainedPointHandleRepresentation.h:55
vtkPlane
perform various plane computations
Definition: vtkPlane.h:33
vtkConstrainedPointHandleRepresentation::SelectedProperty
vtkProperty * SelectedProperty
Definition: vtkConstrainedPointHandleRepresentation.h:269
vtkConstrainedPointHandleRepresentation::SetProjectionNormalToXAxis
void SetProjectionNormalToXAxis()
Definition: vtkConstrainedPointHandleRepresentation.h:105
vtkConstrainedPointHandleRepresentation::Oblique
Definition: vtkConstrainedPointHandleRepresentation.h:240
vtkConstrainedPointHandleRepresentation::ZAxis
Definition: vtkConstrainedPointHandleRepresentation.h:239
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:250
vtkConstrainedPointHandleRepresentation::ProjectionPosition
double ProjectionPosition
Definition: vtkConstrainedPointHandleRepresentation.h:275
vtkHandleRepresentation
abstract class for representing widget handles
Definition: vtkHandleRepresentation.h:55
vtkConstrainedPointHandleRepresentation::Mapper
vtkPolyDataMapper * Mapper
Definition: vtkConstrainedPointHandleRepresentation.h:251
vtkConstrainedPointHandleRepresentation::CursorShape
vtkPolyData * CursorShape
Definition: vtkConstrainedPointHandleRepresentation.h:253
vtkConstrainedPointHandleRepresentation::ActiveCursorShape
vtkPolyData * ActiveCursorShape
Definition: vtkConstrainedPointHandleRepresentation.h:254
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:276
vtkConstrainedPointHandleRepresentation::Property
vtkProperty * Property
Definition: vtkConstrainedPointHandleRepresentation.h:268
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
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:216
vtkWidgetRepresentation::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkWidgetRepresentation.h:213
vtkX3D::position
Definition: vtkX3D.h:267
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:136
vtkConstrainedPointHandleRepresentation::SetProjectionNormalToOblique
void SetProjectionNormalToOblique()
Definition: vtkConstrainedPointHandleRepresentation.h:117
vtkConstrainedPointHandleRepresentation::ObliquePlane
vtkPlane * ObliquePlane
Definition: vtkConstrainedPointHandleRepresentation.h:277
vtkConstrainedPointHandleRepresentation::ActiveProperty
vtkProperty * ActiveProperty
Definition: vtkConstrainedPointHandleRepresentation.h:270
vtkConstrainedPointHandleRepresentation::SetProjectionNormalToZAxis
void SetProjectionNormalToZAxis()
Definition: vtkConstrainedPointHandleRepresentation.h:113
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:279
vtkConstrainedPointHandleRepresentation::FocalData
vtkPolyData * FocalData
Definition: vtkConstrainedPointHandleRepresentation.h:255
vtkConstrainedPointHandleRepresentation::XAxis
Definition: vtkConstrainedPointHandleRepresentation.h:237
vtkConstrainedPointHandleRepresentation::SetProjectionNormalToYAxis
void SetProjectionNormalToYAxis()
Definition: vtkConstrainedPointHandleRepresentation.h:109
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkGlyph3D
copy oriented and scaled glyph geometry to every input point
Definition: vtkGlyph3D.h:106
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkHandleRepresentation::Translate
virtual void Translate(const double *p1, const double *p2)
Translates world position by vector p1p2 projected on the constraint axis if any.
vtkConstrainedPointHandleRepresentation::Glypher
vtkGlyph3D * Glypher
Definition: vtkConstrainedPointHandleRepresentation.h:252
vtkWidgetRepresentation::RenderOverlay
int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:214
vtkWidgetRepresentation::RenderOpaqueGeometry
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
Definition: vtkWidgetRepresentation.h:215
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
vtkHandleRepresentation::SetDisplayPosition
virtual void SetDisplayPosition(double pos[3])
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
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:61
vtkPlaneCollection
maintain a list of planes
Definition: vtkPlaneCollection.h:33
vtkWidgetRepresentation::HasTranslucentPolygonalGeometry
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkWidgetRepresentation.h:218
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:35
vtkConstrainedPointHandleRepresentation::ProjectionNormal
int ProjectionNormal
Definition: vtkConstrainedPointHandleRepresentation.h:274
vtkConstrainedPointHandleRepresentation::FocalPoint
vtkPoints * FocalPoint
Definition: vtkConstrainedPointHandleRepresentation.h:256
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkWidgetRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkWidgetRepresentation::Highlight
virtual void Highlight(int vtkNotUsed(highlightOn))
Definition: vtkWidgetRepresentation.h:140
vtkConstrainedPointHandleRepresentation::YAxis
Definition: vtkConstrainedPointHandleRepresentation.h:238