VTK
vtkLineRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLineRepresentation.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 =========================================================================*/
41 #ifndef vtkLineRepresentation_h
42 #define vtkLineRepresentation_h
43 
44 #include "vtkInteractionWidgetsModule.h" // For export macro
46 
47 class vtkActor;
48 class vtkConeSource;
49 class vtkPolyDataMapper;
50 class vtkLineSource;
51 class vtkProperty;
52 class vtkPolyData;
55 class vtkBox;
56 class vtkFollower;
57 class vtkVectorText;
58 class vtkPolyDataMapper;
59 class vtkCellPicker;
60 
61 class VTKINTERACTIONWIDGETS_EXPORT vtkLineRepresentation : public vtkWidgetRepresentation
62 {
63 public:
68 
70 
74  void PrintSelf(ostream& os, vtkIndent indent);
76 
78 
83  void GetPoint1WorldPosition(double pos[3]);
85  void GetPoint1DisplayPosition(double pos[3]);
87  void SetPoint1WorldPosition(double pos[3]);
88  void SetPoint1DisplayPosition(double pos[3]);
89  void GetPoint2DisplayPosition(double pos[3]);
91  void GetPoint2WorldPosition(double pos[3]);
93  void SetPoint2WorldPosition(double pos[3]);
94  void SetPoint2DisplayPosition(double pos[3]);
96 
98 
111 
113 
116  vtkGetObjectMacro(Point1Representation,vtkPointHandleRepresentation3D);
117  vtkGetObjectMacro(Point2Representation,vtkPointHandleRepresentation3D);
118  vtkGetObjectMacro(LineHandleRepresentation,vtkPointHandleRepresentation3D);
120 
122 
126  vtkGetObjectMacro(EndPointProperty,vtkProperty);
127  vtkGetObjectMacro(SelectedEndPointProperty,vtkProperty);
129 
131 
135  vtkGetObjectMacro(EndPoint2Property,vtkProperty);
136  vtkGetObjectMacro(SelectedEndPoint2Property,vtkProperty);
138 
140 
144  vtkGetObjectMacro(LineProperty,vtkProperty);
145  vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
147 
149 
154  vtkSetClampMacro(Tolerance,int,1,100);
155  vtkGetMacro(Tolerance,int);
157 
159 
164  void SetResolution(int res);
167 
177 
179 
182  virtual void PlaceWidget(double bounds[6]);
183  virtual void BuildRepresentation();
184  virtual int ComputeInteractionState(int X, int Y, int modify=0);
185  virtual void StartWidgetInteraction(double e[2]);
186  virtual void WidgetInteraction(double e[2]);
187  virtual double *GetBounds();
189 
191 
194  virtual void GetActors(vtkPropCollection *pc);
200 
201  // Manage the state of the widget
202  enum {Outside=0,OnP1,OnP2,TranslatingP1,TranslatingP2,OnLine,Scaling};
203 
205 
214  vtkSetClampMacro(InteractionState,int,Outside,Scaling);
216 
218 
222  virtual void SetRepresentationState(int);
223  vtkGetMacro(RepresentationState, int);
225 
227 
231  void SetDirectionalLine(bool val);
232  vtkGetMacro(DirectionalLine, bool);
233  vtkBooleanMacro(DirectionalLine, bool);
235 
241 
245  virtual void SetRenderer(vtkRenderer *ren);
246 
248 
251  vtkSetMacro( DistanceAnnotationVisibility, int );
252  vtkGetMacro( DistanceAnnotationVisibility, int );
253  vtkBooleanMacro( DistanceAnnotationVisibility, int );
255 
257 
262  vtkSetStringMacro(DistanceAnnotationFormat);
263  vtkGetStringMacro(DistanceAnnotationFormat);
265 
267 
270  void SetDistanceAnnotationScale(double x, double y, double z)
271  {
272  double scale[3];
273  scale[0] = x;
274  scale[1] = y;
275  scale[2] = z;
276  this->SetDistanceAnnotationScale(scale);
277  }
278  virtual void SetDistanceAnnotationScale( double scale[3] );
279  virtual double * GetDistanceAnnotationScale();
281 
285  double GetDistance();
286 
287 
292  void SetLineColor(double r, double g, double b);
293 
298 
300 
303  vtkGetObjectMacro(TextActor, vtkFollower);
305 
306  enum { RestrictNone = 0, RestrictToX, RestrictToY, RestrictToZ };
307 
312  vtkSetClampMacro(RestrictFlag, int, RestrictNone, RestrictToZ);
313 
314 protected:
317 
318  // The handle and the rep used to close the handles
323 
324  // Manage how the representation appears
327 
328  // the line
332 
333  // glyphs representing hot spots (e.g., handles)
337 
338  // Properties used to control the appearance of selected objects and
339  // the manipulator in general.
347 
348  // Selection tolerance for the handles and the line
350 
351  // Helper members
353  void ClampPosition(double x[3]);
354  void HighlightPoint(int ptId, int highlight);
355  void HighlightLine(int highlight);
356  int InBounds(double x[3]);
357  void SizeHandles();
358 
359  // Ivars used during widget interaction to hold initial positions
360  double StartP1[3];
361  double StartP2[3];
362  double StartLineHandle[3];
363  double Length;
364  double LastEventPosition[3];
365 
366  // Support GetBounds() method
368 
369  // Need to keep track if we have successfully initialized the display position.
370  // The widget tends to do stuff in world coordinates, put if the renderer has
371  // not been assigned, then certain operations do not properly update the display
372  // position.
374 
375  // Format for the label
378 
382  double Distance;
384 
386 
388 
389 private:
390  vtkLineRepresentation(const vtkLineRepresentation&) VTK_DELETE_FUNCTION;
391  void operator=(const vtkLineRepresentation&) VTK_DELETE_FUNCTION;
392 };
393 
394 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:43
vtkLineRepresentation::HandleRepresentation
vtkPointHandleRepresentation3D * HandleRepresentation
Definition: vtkLineRepresentation.h:319
vtkLineRepresentation::Point2Representation
vtkPointHandleRepresentation3D * Point2Representation
Definition: vtkLineRepresentation.h:321
vtkWidgetRepresentation.h
vtkLineRepresentation::SetPoint2DisplayPosition
void SetPoint2DisplayPosition(double pos[3])
vtkLineRepresentation::HandleMapper
vtkPolyDataMapper ** HandleMapper
Definition: vtkLineRepresentation.h:335
vtkLineRepresentation::GetResolution
int GetResolution()
vtkLineRepresentation::EndPoint2Property
vtkProperty * EndPoint2Property
Definition: vtkLineRepresentation.h:342
vtkFollower
a subclass of actor that always faces the camera
Definition: vtkFollower.h:47
vtkLineRepresentation::GetDistanceAnnotationScale
virtual double * GetDistanceAnnotationScale()
vtkLineRepresentation::~vtkLineRepresentation
~vtkLineRepresentation()
vtkLineRepresentation::DirectionalLine
bool DirectionalLine
Definition: vtkLineRepresentation.h:326
vtkLineRepresentation::HasTranslucentPolygonalGeometry
virtual int HasTranslucentPolygonalGeometry()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
vtkLineRepresentation::SetHandleRepresentation
void SetHandleRepresentation(vtkPointHandleRepresentation3D *handle)
This method is used to specify the type of handle representation to use for the three internal vtkHan...
vtkLineRepresentation::SetDistanceAnnotationScale
void SetDistanceAnnotationScale(double x, double y, double z)
Scale text (font size along each dimension).
Definition: vtkLineRepresentation.h:270
vtkLineRepresentation::ClampToBounds
int ClampToBounds
Definition: vtkLineRepresentation.h:352
vtkLineRepresentation::TextActor
vtkFollower * TextActor
Definition: vtkLineRepresentation.h:379
vtkX3D::scale
@ scale
Definition: vtkX3D.h:229
vtkLineRepresentation::LineHandleRepresentation
vtkPointHandleRepresentation3D * LineHandleRepresentation
Definition: vtkLineRepresentation.h:322
vtkLineRepresentation::HighlightLine
void HighlightLine(int highlight)
vtkLineRepresentation::GetMTime
virtual vtkMTimeType GetMTime()
Overload the superclasses' GetMTime() because internal classes are used to keep the state of the repr...
vtkLineRepresentation::BoundingBox
vtkBox * BoundingBox
Definition: vtkLineRepresentation.h:367
vtkLineRepresentation::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
vtkPointHandleRepresentation3D
represent the position of a point in 3D space
Definition: vtkPointHandleRepresentation3D.h:44
vtkLineRepresentation::SizeHandles
void SizeHandles()
vtkLineRepresentation::BuildRepresentation
virtual void BuildRepresentation()
vtkLineRepresentation::LineActor
vtkActor * LineActor
Definition: vtkLineRepresentation.h:329
vtkLineRepresentation::RenderTranslucentPolygonalGeometry
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *)
vtkLineRepresentation::vtkLineRepresentation
vtkLineRepresentation()
vtkLineRepresentation::PlaceWidget
virtual void PlaceWidget(double bounds[6])
These are methods that satisfy vtkWidgetRepresentation's API.
vtkConeSource
generate polygonal cone
Definition: vtkConeSource.h:45
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:55
vtkLineRepresentation::SetResolution
void SetResolution(int res)
Set/Get the resolution (number of subdivisions) of the line.
vtkLineRepresentation::SetRepresentationState
virtual void SetRepresentationState(int)
Sets the visual appearance of the representation based on the state it is in.
vtkLineRepresentation::InstantiateHandleRepresentation
void InstantiateHandleRepresentation()
vtkLineRepresentation::CreateDefaultProperties
void CreateDefaultProperties()
vtkLineRepresentation::AnnotationTextScaleInitialized
bool AnnotationTextScaleInitialized
Definition: vtkLineRepresentation.h:383
vtkLineRepresentation::GetDistanceAnnotationProperty
virtual vtkProperty * GetDistanceAnnotationProperty()
Get the distance annotation property.
vtkLineRepresentation::SetRenderer
virtual void SetRenderer(vtkRenderer *ren)
Overridden to set the rendererer on the internal representations.
vtkLineRepresentation::GetActors
virtual void GetActors(vtkPropCollection *pc)
Methods supporting the rendering process.
vtkLineRepresentation::GetPoint1WorldPosition
double * GetPoint1WorldPosition()
vtkLineRepresentation::GetBounds
virtual double * GetBounds()
Methods to make this class behave as a vtkProp.
vtkLineRepresentation::GetPoint1DisplayPosition
double * GetPoint1DisplayPosition()
vtkVectorText
create polygonal text
Definition: vtkVectorText.h:48
vtkLineRepresentation::SetLineColor
void SetLineColor(double r, double g, double b)
Convenience method to set the line color.
vtkLineRepresentation::TextInput
vtkVectorText * TextInput
Definition: vtkLineRepresentation.h:381
vtkLineRepresentation::DistanceAnnotationVisibility
int DistanceAnnotationVisibility
Definition: vtkLineRepresentation.h:376
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
vtkLineRepresentation::GetPoint2DisplayPosition
double * GetPoint2DisplayPosition()
vtkLineRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkMTimeType
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
vtkLineRepresentation::RenderOpaqueGeometry
virtual int RenderOpaqueGeometry(vtkViewport *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
vtkLineRepresentation::SelectedLineProperty
vtkProperty * SelectedLineProperty
Definition: vtkLineRepresentation.h:345
vtkLineRepresentation::DistanceAnnotationFormat
char * DistanceAnnotationFormat
Definition: vtkLineRepresentation.h:377
vtkLineRepresentation::WidgetInteraction
virtual void WidgetInteraction(double e[2])
vtkLineRepresentation::GetPoint2WorldPosition
double * GetPoint2WorldPosition()
vtkLineRepresentation::GetDistance
double GetDistance()
Get the distance between the points.
vtkLineRepresentation::Length
double Length
Definition: vtkLineRepresentation.h:363
vtkLineRepresentation::RestrictFlag
int RestrictFlag
Definition: vtkLineRepresentation.h:387
vtkLineRepresentation::Tolerance
int Tolerance
Definition: vtkLineRepresentation.h:349
vtkLineRepresentation::GetPoint2DisplayPosition
void GetPoint2DisplayPosition(double pos[3])
vtkLineRepresentation::LineProperty
vtkProperty * LineProperty
Definition: vtkLineRepresentation.h:344
vtkLineRepresentation::LinePicker
vtkCellPicker * LinePicker
Definition: vtkLineRepresentation.h:385
vtkLineRepresentation::EndPointProperty
vtkProperty * EndPointProperty
Definition: vtkLineRepresentation.h:340
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkLineRepresentation::GetPolyData
void GetPolyData(vtkPolyData *pd)
Retrieve the polydata (including points) that defines the line.
vtkLineRepresentation::Point1Representation
vtkPointHandleRepresentation3D * Point1Representation
Definition: vtkLineRepresentation.h:320
vtkLineRepresentation::GetPoint2WorldPosition
void GetPoint2WorldPosition(double pos[3])
vtkGetStringMacro
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:43
vtkLineRepresentation::HighlightPoint
void HighlightPoint(int ptId, int highlight)
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:48
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkLineRepresentation::Handle
vtkActor ** Handle
Definition: vtkLineRepresentation.h:334
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkLineRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double e[2])
vtkLineRepresentation::TextMapper
vtkPolyDataMapper * TextMapper
Definition: vtkLineRepresentation.h:380
vtkBox
implicit function for a bounding box
Definition: vtkBox.h:42
vtkLineRepresentation::SetPoint1WorldPosition
void SetPoint1WorldPosition(double pos[3])
vtkLineRepresentation::RepresentationState
int RepresentationState
Definition: vtkLineRepresentation.h:325
vtkLineRepresentation::New
static vtkLineRepresentation * New()
Instantiate the class.
vtkLineRepresentation::ClampPosition
void ClampPosition(double x[3])
vtkLineRepresentation::SetDirectionalLine
void SetDirectionalLine(bool val)
Sets the representation to be a directional line with point 1 represented as a cone.
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:64
vtkLineRepresentation::SetDistanceAnnotationScale
virtual void SetDistanceAnnotationScale(double scale[3])
vtkLineRepresentation::HandleGeometry
vtkPolyDataAlgorithm ** HandleGeometry
Definition: vtkLineRepresentation.h:336
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
vtkLineRepresentation::Distance
double Distance
Definition: vtkLineRepresentation.h:382
vtkLineRepresentation::LineSource
vtkLineSource * LineSource
Definition: vtkLineRepresentation.h:331
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:65
vtkLineRepresentation::GetPoint1WorldPosition
void GetPoint1WorldPosition(double pos[3])
Methods to Set/Get the coordinates of the two points defining this representation.
vtkLineRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkLineRepresentation::SetPoint1DisplayPosition
void SetPoint1DisplayPosition(double pos[3])
vtkLineRepresentation::TranslatingP2
@ TranslatingP2
Definition: vtkLineRepresentation.h:202
vtkLineRepresentation::InBounds
int InBounds(double x[3])
vtkPropCollection
a list of Props
Definition: vtkPropCollection.h:39
vtkLineRepresentation::SelectedEndPoint2Property
vtkProperty * SelectedEndPoint2Property
Definition: vtkLineRepresentation.h:343
vtkLineRepresentation::SetPoint2WorldPosition
void SetPoint2WorldPosition(double pos[3])
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:70
vtkLineRepresentation::SelectedEndPointProperty
vtkProperty * SelectedEndPointProperty
Definition: vtkLineRepresentation.h:341
vtkLineRepresentation
a class defining the representation for a vtkLineWidget2
Definition: vtkLineRepresentation.h:62
vtkLineRepresentation::GetPoint1DisplayPosition
void GetPoint1DisplayPosition(double pos[3])
vtkLineRepresentation::InitializedDisplayPosition
int InitializedDisplayPosition
Definition: vtkLineRepresentation.h:373
vtkLineRepresentation::LineMapper
vtkPolyDataMapper * LineMapper
Definition: vtkLineRepresentation.h:330
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:45