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 =========================================================================*/
38 #ifndef vtkLineRepresentation_h
39 #define vtkLineRepresentation_h
40 
41 #include "vtkInteractionWidgetsModule.h" // For export macro
43 
44 class vtkActor;
45 class vtkConeSource;
46 class vtkPolyDataMapper;
47 class vtkLineSource;
48 class vtkProperty;
49 class vtkPolyData;
52 class vtkBox;
53 class vtkFollower;
54 class vtkVectorText;
55 class vtkPolyDataMapper;
56 class vtkCellPicker;
57 
58 class VTKINTERACTIONWIDGETS_EXPORT vtkLineRepresentation : public vtkWidgetRepresentation
59 {
60 public:
64  static vtkLineRepresentation *New();
65 
67 
71  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
75 
80  void GetPoint1WorldPosition(double pos[3]);
81  double* GetPoint1WorldPosition() VTK_SIZEHINT(3);
82  void GetPoint1DisplayPosition(double pos[3]);
83  double* GetPoint1DisplayPosition() VTK_SIZEHINT(3);
84  void SetPoint1WorldPosition(double pos[3]);
85  void SetPoint1DisplayPosition(double pos[3]);
86  void GetPoint2DisplayPosition(double pos[3]);
87  double* GetPoint2DisplayPosition() VTK_SIZEHINT(3);
88  void GetPoint2WorldPosition(double pos[3]);
89  double* GetPoint2WorldPosition() VTK_SIZEHINT(3);
90  void SetPoint2WorldPosition(double pos[3]);
91  void SetPoint2DisplayPosition(double pos[3]);
93 
95 
105  void SetHandleRepresentation(vtkPointHandleRepresentation3D *handle);
106  void InstantiateHandleRepresentation();
108 
110 
113  vtkGetObjectMacro(Point1Representation,vtkPointHandleRepresentation3D);
114  vtkGetObjectMacro(Point2Representation,vtkPointHandleRepresentation3D);
115  vtkGetObjectMacro(LineHandleRepresentation,vtkPointHandleRepresentation3D);
117 
119 
123  vtkGetObjectMacro(EndPointProperty,vtkProperty);
124  vtkGetObjectMacro(SelectedEndPointProperty,vtkProperty);
126 
128 
132  vtkGetObjectMacro(EndPoint2Property,vtkProperty);
133  vtkGetObjectMacro(SelectedEndPoint2Property,vtkProperty);
135 
137 
141  vtkGetObjectMacro(LineProperty,vtkProperty);
142  vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
144 
146 
151  vtkSetClampMacro(Tolerance,int,1,100);
152  vtkGetMacro(Tolerance,int);
154 
156 
161  void SetResolution(int res);
162  int GetResolution();
164 
173  void GetPolyData(vtkPolyData *pd);
174 
176 
179  void PlaceWidget(double bounds[6]) override;
180  void BuildRepresentation() override;
181  int ComputeInteractionState(int X, int Y, int modify=0) override;
182  void StartWidgetInteraction(double e[2]) override;
183  void WidgetInteraction(double e[2]) override;
184  double *GetBounds() VTK_SIZEHINT(6) override;
186 
188 
191  void GetActors(vtkPropCollection *pc) override;
192  void ReleaseGraphicsResources(vtkWindow*) override;
193  int RenderOpaqueGeometry(vtkViewport*) override;
194  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
195  int HasTranslucentPolygonalGeometry() override;
197 
198  // Manage the state of the widget
199  enum {Outside=0,OnP1,OnP2,TranslatingP1,TranslatingP2,OnLine,Scaling};
200 
202 
211  vtkSetClampMacro(InteractionState,int,Outside,Scaling);
213 
215 
219  virtual void SetRepresentationState(int);
220  vtkGetMacro(RepresentationState, int);
222 
224 
228  void SetDirectionalLine(bool val);
229  vtkGetMacro(DirectionalLine, bool);
230  vtkBooleanMacro(DirectionalLine, bool);
232 
237  vtkMTimeType GetMTime() override;
238 
242  void SetRenderer(vtkRenderer *ren) override;
243 
245 
248  vtkSetMacro( DistanceAnnotationVisibility, vtkTypeBool );
249  vtkGetMacro( DistanceAnnotationVisibility, vtkTypeBool );
250  vtkBooleanMacro( DistanceAnnotationVisibility, vtkTypeBool );
252 
254 
259  vtkSetStringMacro(DistanceAnnotationFormat);
260  vtkGetStringMacro(DistanceAnnotationFormat);
262 
264 
267  void SetDistanceAnnotationScale(double x, double y, double z)
268  {
269  double scale[3];
270  scale[0] = x;
271  scale[1] = y;
272  scale[2] = z;
273  this->SetDistanceAnnotationScale(scale);
274  }
275  virtual void SetDistanceAnnotationScale( double scale[3] );
276  virtual double * GetDistanceAnnotationScale() VTK_SIZEHINT(3);
278 
282  double GetDistance();
283 
284 
289  void SetLineColor(double r, double g, double b);
290 
294  virtual vtkProperty *GetDistanceAnnotationProperty();
295 
297 
300  vtkGetObjectMacro(TextActor, vtkFollower);
302 
303  enum { RestrictNone = 0, RestrictToX, RestrictToY, RestrictToZ };
304 
309  vtkSetClampMacro(RestrictFlag, int, RestrictNone, RestrictToZ);
310 
311 protected:
313  ~vtkLineRepresentation() override;
314 
315  // The handle and the rep used to close the handles
320 
321  // Manage how the representation appears
324 
325  // the line
329 
330  // glyphs representing hot spots (e.g., handles)
334 
335  // Properties used to control the appearance of selected objects and
336  // the manipulator in general.
343  void CreateDefaultProperties();
344 
345  // Selection tolerance for the handles and the line
347 
348  // Helper members
350  void ClampPosition(double x[3]);
351  void HighlightPoint(int ptId, int highlight);
352  void HighlightLine(int highlight);
353  int InBounds(double x[3]);
354  void SizeHandles();
355 
356  // Ivars used during widget interaction to hold initial positions
357  double StartP1[3];
358  double StartP2[3];
359  double StartLineHandle[3];
360  double Length;
361  double LastEventPosition[3];
362 
363  // Support GetBounds() method
365 
366  // Need to keep track if we have successfully initialized the display position.
367  // The widget tends to do stuff in world coordinates, put if the renderer has
368  // not been assigned, then certain operations do not properly update the display
369  // position.
371 
372  // Format for the label
375 
379  double Distance;
381 
383 
385 
386 private:
388  void operator=(const vtkLineRepresentation&) = delete;
389 };
390 
391 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkLineRepresentation::HandleRepresentation
vtkPointHandleRepresentation3D * HandleRepresentation
Definition: vtkLineRepresentation.h:316
vtkLineRepresentation::Point2Representation
vtkPointHandleRepresentation3D * Point2Representation
Definition: vtkLineRepresentation.h:318
vtkWidgetRepresentation.h
vtkLineRepresentation::HandleMapper
vtkPolyDataMapper ** HandleMapper
Definition: vtkLineRepresentation.h:332
vtkLineRepresentation::EndPoint2Property
vtkProperty * EndPoint2Property
Definition: vtkLineRepresentation.h:339
vtkFollower
a subclass of actor that always faces the camera
Definition: vtkFollower.h:40
vtkLineRepresentation::DirectionalLine
bool DirectionalLine
Definition: vtkLineRepresentation.h:323
vtkLineRepresentation::SetDistanceAnnotationScale
void SetDistanceAnnotationScale(double x, double y, double z)
Scale text (font size along each dimension).
Definition: vtkLineRepresentation.h:267
vtkLineRepresentation::ClampToBounds
int ClampToBounds
Definition: vtkLineRepresentation.h:349
vtkLineRepresentation::TextActor
vtkFollower * TextActor
Definition: vtkLineRepresentation.h:376
vtkX3D::scale
Definition: vtkX3D.h:229
vtkLineRepresentation::LineHandleRepresentation
vtkPointHandleRepresentation3D * LineHandleRepresentation
Definition: vtkLineRepresentation.h:319
vtkLineRepresentation::BoundingBox
vtkBox * BoundingBox
Definition: vtkLineRepresentation.h:364
vtkPointHandleRepresentation3D
represent the position of a point in 3D space
Definition: vtkPointHandleRepresentation3D.h:40
vtkWidgetRepresentation::SetRenderer
virtual void SetRenderer(vtkRenderer *ren)
Subclasses of vtkWidgetRepresentation must implement these methods.
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkLineRepresentation::LineActor
vtkActor * LineActor
Definition: vtkLineRepresentation.h:326
vtkLineRepresentation::TranslatingP2
Definition: vtkLineRepresentation.h:199
vtkConeSource
generate polygonal cone
Definition: vtkConeSource.h:38
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:60
vtkLineRepresentation::AnnotationTextScaleInitialized
bool AnnotationTextScaleInitialized
Definition: vtkLineRepresentation.h:380
vtkVectorText
create polygonal text
Definition: vtkVectorText.h:41
vtkLineRepresentation::TextInput
vtkVectorText * TextInput
Definition: vtkLineRepresentation.h:378
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkLineRepresentation::SelectedLineProperty
vtkProperty * SelectedLineProperty
Definition: vtkLineRepresentation.h:342
vtkLineRepresentation::DistanceAnnotationFormat
char * DistanceAnnotationFormat
Definition: vtkLineRepresentation.h:374
vtkLineRepresentation::Length
double Length
Definition: vtkLineRepresentation.h:360
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkLineRepresentation::RestrictFlag
int RestrictFlag
Definition: vtkLineRepresentation.h:384
vtkLineRepresentation::Tolerance
int Tolerance
Definition: vtkLineRepresentation.h:346
vtkObject::GetMTime
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkLineRepresentation::LineProperty
vtkProperty * LineProperty
Definition: vtkLineRepresentation.h:341
vtkLineRepresentation::LinePicker
vtkCellPicker * LinePicker
Definition: vtkLineRepresentation.h:382
vtkLineRepresentation::EndPointProperty
vtkProperty * EndPointProperty
Definition: vtkLineRepresentation.h:337
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
vtkLineRepresentation::Point1Representation
vtkPointHandleRepresentation3D * Point1Representation
Definition: vtkLineRepresentation.h:317
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:36
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkLineRepresentation::Handle
vtkActor ** Handle
Definition: vtkLineRepresentation.h:331
vtkLineRepresentation::TextMapper
vtkPolyDataMapper * TextMapper
Definition: vtkLineRepresentation.h:377
vtkBox
implicit function for a bounding box
Definition: vtkBox.h:38
vtkLineRepresentation::RepresentationState
int RepresentationState
Definition: vtkLineRepresentation.h:322
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:57
vtkLineRepresentation::HandleGeometry
vtkPolyDataAlgorithm ** HandleGeometry
Definition: vtkLineRepresentation.h:333
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkLineRepresentation::Distance
double Distance
Definition: vtkLineRepresentation.h:379
vtkLineRepresentation::LineSource
vtkLineSource * LineSource
Definition: vtkLineRepresentation.h:328
vtkLineRepresentation::DistanceAnnotationVisibility
vtkTypeBool DistanceAnnotationVisibility
Definition: vtkLineRepresentation.h:373
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:60
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:35
vtkLineRepresentation::SelectedEndPoint2Property
vtkProperty * SelectedEndPoint2Property
Definition: vtkLineRepresentation.h:340
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkLineRepresentation::SelectedEndPointProperty
vtkProperty * SelectedEndPointProperty
Definition: vtkLineRepresentation.h:338
vtkLineRepresentation
a class defining the representation for a vtkLineWidget2
Definition: vtkLineRepresentation.h:58
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
vtkWidgetRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkLineRepresentation::InitializedDisplayPosition
int InitializedDisplayPosition
Definition: vtkLineRepresentation.h:370
vtkLineRepresentation::LineMapper
vtkPolyDataMapper * LineMapper
Definition: vtkLineRepresentation.h:327
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41