VTK  9.0.1
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:
65 
67 
71  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
75 
80  void GetPoint1WorldPosition(double pos[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  vtkTypeBool HasTranslucentPolygonalGeometry() override;
197 
198  // Manage the state of the widget
199  enum
200  {
201  Outside = 0,
207  Scaling
208  };
209 
211 
220  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
222 
224 
228  virtual void SetRepresentationState(int);
229  vtkGetMacro(RepresentationState, int);
231 
233 
237  void SetDirectionalLine(bool val);
238  vtkGetMacro(DirectionalLine, bool);
239  vtkBooleanMacro(DirectionalLine, bool);
241 
246  vtkMTimeType GetMTime() override;
247 
251  void SetRenderer(vtkRenderer* ren) override;
252 
254 
257  vtkSetMacro(DistanceAnnotationVisibility, vtkTypeBool);
258  vtkGetMacro(DistanceAnnotationVisibility, vtkTypeBool);
259  vtkBooleanMacro(DistanceAnnotationVisibility, vtkTypeBool);
261 
263 
268  vtkSetStringMacro(DistanceAnnotationFormat);
269  vtkGetStringMacro(DistanceAnnotationFormat);
271 
273 
276  void SetDistanceAnnotationScale(double x, double y, double z)
277  {
278  double scale[3];
279  scale[0] = x;
280  scale[1] = y;
281  scale[2] = z;
282  this->SetDistanceAnnotationScale(scale);
283  }
284  virtual void SetDistanceAnnotationScale(double scale[3]);
287 
291  double GetDistance();
292 
297  void SetLineColor(double r, double g, double b);
298 
302  virtual vtkProperty* GetDistanceAnnotationProperty();
303 
305 
308  vtkGetObjectMacro(TextActor, vtkFollower);
310 
311  enum
312  {
313  RestrictNone = 0,
316  RestrictToZ
317  };
318 
323  VTK_LEGACY(void SetRestrictFlag(int restrict_flag));
324 
325 protected:
328 
329  // The handle and the rep used to close the handles
334 
335  // Manage how the representation appears
338 
339  // the line
343 
344  // glyphs representing hot spots (e.g., handles)
348 
349  // Properties used to control the appearance of selected objects and
350  // the manipulator in general.
358 
359  // Selection tolerance for the handles and the line
361 
362  // Helper members
364  void ClampPosition(double x[3]);
365  void HighlightPoint(int ptId, int highlight);
366  void HighlightLine(int highlight);
367  int InBounds(double x[3]);
368  void SizeHandles();
369 
370  // Ivars used during widget interaction to hold initial positions
371  double StartP1[3];
372  double StartP2[3];
373  double StartLineHandle[3];
374  double Length;
375  double LastEventPosition[3];
376 
377  // Support GetBounds() method
379 
380  // Need to keep track if we have successfully initialized the display position.
381  // The widget tends to do stuff in world coordinates, put if the renderer has
382  // not been assigned, then certain operations do not properly update the display
383  // position.
385 
386  // Format for the label
389 
393  double Distance;
395 
397 
398 private:
400  void operator=(const vtkLineRepresentation&) = delete;
401 };
402 
403 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
implicit function for a bounding box
Definition: vtkBox.h:39
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:67
generate polygonal cone
Definition: vtkConeSource.h:39
a subclass of actor that always faces the camera
Definition: vtkFollower.h:41
a simple class to control print indentation
Definition: vtkIndent.h:34
a class defining the representation for a vtkLineWidget2
void SetDirectionalLine(bool val)
Sets the representation to be a directional line with point 1 represented as a cone.
vtkTypeBool DistanceAnnotationVisibility
double * GetPoint1WorldPosition()
vtkPolyDataMapper * TextMapper
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkLineRepresentation * New()
Instantiate the class.
virtual void SetDistanceAnnotationScale(double scale[3])
void SetDistanceAnnotationScale(double x, double y, double z)
Scale text (font size along each dimension).
vtkProperty * SelectedEndPointProperty
vtkPointHandleRepresentation3D * Point1Representation
void ClampPosition(double x[3])
virtual void SetRepresentationState(int)
Sets the visual appearance of the representation based on the state it is in.
vtkPolyDataMapper * LineMapper
vtkPointHandleRepresentation3D * LineHandleRepresentation
void SetRenderer(vtkRenderer *ren) override
Overridden to set the rendererer on the internal representations.
vtkPolyDataAlgorithm ** HandleGeometry
void HighlightLine(int highlight)
void HighlightPoint(int ptId, int highlight)
vtkPointHandleRepresentation3D * Point2Representation
virtual double * GetDistanceAnnotationScale()
vtkPointHandleRepresentation3D * HandleRepresentation
void SetRestrictFlag(int restrict_flag)
Set if translations should be restricted to one of the axes (disabled if RestrictNone is specified).
vtkPolyDataMapper ** HandleMapper
vtkProperty * SelectedEndPoint2Property
~vtkLineRepresentation() override
void GetPoint1WorldPosition(double pos[3])
Methods to Set/Get the coordinates of the two points defining this representation.
vtkMTimeType GetMTime() override
Overload the superclasses' GetMTime() because internal classes are used to keep the state of the repr...
int InBounds(double x[3])
create a line defined by two end points
Definition: vtkLineSource.h:61
represent the position of a point in 3D space
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:62
abstract specification for renderers
Definition: vtkRenderer.h:59
create polygonal text
Definition: vtkVectorText.h:42
abstract specification for Viewports
Definition: vtkViewport.h:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
@ scale
Definition: vtkX3D.h:235
int vtkTypeBool
Definition: vtkABI.h:69
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
#define VTK_SIZEHINT(...)