VTK  9.6.1
vtkLineRepresentation.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
28
29#ifndef vtkLineRepresentation_h
30#define vtkLineRepresentation_h
31
32#include "vtkInteractionWidgetsModule.h" // For export macro
34#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
35
36VTK_ABI_NAMESPACE_BEGIN
37class vtkActor;
38class vtkConeSource;
40class vtkLineSource;
41class vtkProperty;
42class vtkPolyData;
45class vtkBox;
46class vtkFollower;
47class vtkVectorText;
49class vtkCellPicker;
50
51class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkLineRepresentation
53{
54public:
59
61
65 void PrintSelf(ostream& os, vtkIndent indent) override;
67
69
74 void GetPoint1WorldPosition(double pos[3]) VTK_FUTURE_CONST;
77 void GetPoint1DisplayPosition(double pos[3]) VTK_FUTURE_CONST;
80 void SetPoint1WorldPosition(double pos[3]);
82 void SetPoint1DisplayPosition(double pos[3]);
84 void GetPoint2DisplayPosition(double pos[3]) VTK_FUTURE_CONST;
87 void GetPoint2WorldPosition(double pos[3]) VTK_FUTURE_CONST;
89 void SetPoint2WorldPosition(double pos[3]);
91 void SetPoint2DisplayPosition(double pos[3]);
93
95
108
110
117
119
123 vtkGetObjectMacro(EndPointProperty, vtkProperty);
128
130
134 vtkGetObjectMacro(EndPoint2Property, vtkProperty);
139
141
145 vtkGetObjectMacro(LineProperty, vtkProperty);
150
152
157 vtkSetClampMacro(Tolerance, int, 1, 100);
158 vtkGetMacro(Tolerance, int);
160
162
167 void SetResolution(int res);
170
180
182
185 void PlaceWidget(double bounds[6]) override;
186 void BuildRepresentation() override;
187 int ComputeInteractionState(int X, int Y, int modify = 0) override;
188 void StartWidgetInteraction(double e[2]) override;
189 void WidgetInteraction(double e[2]) override;
190 double* GetBounds() VTK_SIZEHINT(6) override;
192
194
197 void GetActors(vtkPropCollection* pc) override;
203
204 // Manage the state of the widget
205 enum
206 {
214 };
215
217
226 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
228
230
234 virtual void SetRepresentationState(int);
235 vtkGetMacro(RepresentationState, int);
237
239
243 void SetDirectionalLine(bool val);
244 vtkGetMacro(DirectionalLine, bool);
245 vtkBooleanMacro(DirectionalLine, bool);
247
253
257 void SetRenderer(vtkRenderer* ren) override;
258
260
267
269
274 vtkSetStringMacro(DistanceAnnotationFormat);
275 vtkGetStringMacro(DistanceAnnotationFormat);
277
279
282 void SetDistanceAnnotationScale(double x, double y, double z)
283 {
284 double scale[3];
285 scale[0] = x;
286 scale[1] = y;
287 scale[2] = z;
288 this->SetDistanceAnnotationScale(scale);
289 }
290 virtual void SetDistanceAnnotationScale(double scale[3]);
293
297 double GetDistance();
298
303 void SetLineColor(double r, double g, double b);
304
306
309 void SetInteractionColor(double, double, double);
310 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
311 void SetForegroundColor(double, double, double);
312 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
314
319
321
324 vtkGetObjectMacro(TextActor, vtkFollower);
326
327 enum
328 {
333 };
334
335protected:
338
339 // The handle and the rep used to close the handles
344
345 // Manage how the representation appears
348
349 // the line
353
354 // glyphs representing hot spots (e.g., handles)
358
359 // Properties used to control the appearance of selected objects and
360 // the manipulator in general.
368
369 // Selection tolerance for the handles and the line
371
372 // Helper members
374 void ClampPosition(double x[3]);
375
377
380 void HighlightPoint(int ptId, int highlight);
381 void HighlightLine(int highlight);
383
384 int InBounds(double x[3]);
386
387 // Ivars used during widget interaction to hold initial positions
388 double StartP1[3];
389 double StartP2[3];
391 double Length;
393
394 // Support GetBounds() method
396
397 // Need to keep track if we have successfully initialized the display position.
398 // The widget tends to do stuff in world coordinates, put if the renderer has
399 // not been assigned, then certain operations do not properly update the display
400 // position.
402
403 // Format for the label
406
410 double Distance;
412
414
415private:
416 void UpdatePointAndLineProperties();
417
419 void operator=(const vtkLineRepresentation&) = delete;
420};
421
422VTK_ABI_NAMESPACE_END
423#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:42
implicit function for a bounding box
Definition vtkBox.h:31
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
a subclass of actor that always faces the camera
Definition vtkFollower.h:34
a simple class to control print indentation
Definition vtkIndent.h:29
void SetDirectionalLine(bool val)
Sets the representation to be a directional line with point 1 represented as a cone.
void InstantiateHandleRepresentation()
This method is used to specify the type of handle representation to use for the three internal vtkHan...
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting the rendering process.
void SetInteractionColor(double c[3])
Set the widget color, and the color of interactive handles.
vtkPolyDataMapper * TextMapper
void SetEndPoint2Property(vtkProperty *property)
Set/Get the end-point (sphere) properties.
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting the rendering process.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
static vtkLineRepresentation * New()
Instantiate the class.
virtual void SetDistanceAnnotationScale(double scale[3])
Scale text (font size along each dimension).
void PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetForegroundColor(double c[3])
Set the widget color, and the color of interactive handles.
void SetDistanceAnnotationScale(double x, double y, double z)
Scale text (font size along each dimension).
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.
void SetPoint1DisplayPosition(double pos[3])
Methods to Set/Get the coordinates of the two points defining this representation.
void SetResolution(int res)
Set/Get the resolution (number of subdivisions) of the line.
vtkPolyDataMapper * LineMapper
vtkPointHandleRepresentation3D * LineHandleRepresentation
void SetSelectedEndPoint2Property(vtkProperty *property)
Set/Get the end-point (sphere) properties.
void SetPoint1WorldPosition(double pos[3])
Methods to Set/Get the coordinates of the two points defining this representation.
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting the rendering process.
void GetPoint1WorldPosition(double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining this representation.
double * GetPoint1WorldPosition()
Methods to Set/Get the coordinates of the two points defining this representation.
void SetSelectedEndPointProperty(vtkProperty *property)
Set/Get the end-point (sphere) properties.
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetRenderer(vtkRenderer *ren) override
Overridden to set the rendererer on the internal representations.
void GetPoint1DisplayPosition(double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining this representation.
void SetSelectedLineProperty(vtkProperty *property)
Set/Get the line properties.
void GetActors(vtkPropCollection *pc) override
Methods supporting the rendering process.
void SetHandleRepresentation(vtkPointHandleRepresentation3D *handle)
This method is used to specify the type of handle representation to use for the three internal vtkHan...
void SetLineColor(double r, double g, double b)
Convenience method to set the line color.
vtkPolyDataAlgorithm ** HandleGeometry
void SetForegroundColor(double, double, double)
Set the widget color, and the color of interactive handles.
virtual double * GetDistanceAnnotationScale()
Scale text (font size along each dimension).
virtual vtkProperty * GetDistanceAnnotationProperty()
Get the distance annotation property.
void GetPoint2DisplayPosition(double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining this representation.
void HighlightLine(int highlight)
These methods are just changing the properties of actors and representations.
void HighlightPoint(int ptId, int highlight)
These methods are just changing the properties of actors and representations.
void GetPolyData(vtkPolyData *pd)
Retrieve the polydata (including points) that defines the line.
double GetDistance()
Get the distance between the points.
vtkPointHandleRepresentation3D * Point2Representation
void SetEndPointProperty(vtkProperty *property)
Set/Get the end-point (sphere) properties.
vtkPointHandleRepresentation3D * HandleRepresentation
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetInteractionColor(double, double, double)
Set the widget color, and the color of interactive handles.
void GetPoint2WorldPosition(double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining this representation.
vtkPolyDataMapper ** HandleMapper
int GetResolution()
Set/Get the resolution (number of subdivisions) of the line.
void SetPoint2DisplayPosition(double pos[3])
Methods to Set/Get the coordinates of the two points defining this representation.
void SetPoint2WorldPosition(double pos[3])
Methods to Set/Get the coordinates of the two points defining this representation.
vtkProperty * SelectedEndPoint2Property
~vtkLineRepresentation() override
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting the rendering process.
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkMTimeType GetMTime() override
Overload the superclasses' GetMTime() because internal classes are used to keep the state of the repr...
void SetLineProperty(vtkProperty *property)
Set/Get the line properties.
int InBounds(double x[3])
create a line defined by two end points
represent the position of a point in 3D space
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
an ordered list of Props
represent surface properties of a geometric object
Definition vtkProperty.h:60
abstract specification for renderers
Definition vtkRenderer.h:64
create polygonal text
abstract specification for Viewports
Definition vtkViewport.h:47
window superclass for vtkRenderWindow
Definition vtkWindow.h:29
int vtkTypeBool
Definition vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:323
#define VTK_SIZEHINT(...)
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)
#define vtkPolyDataAlgorithm