VTK  9.2.6
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=========================================================================*/
50#ifndef vtkLineRepresentation_h
51#define vtkLineRepresentation_h
52
53#include "vtkInteractionWidgetsModule.h" // For export macro
55
56class vtkActor;
57class vtkConeSource;
59class vtkLineSource;
60class vtkProperty;
61class vtkPolyData;
64class vtkBox;
65class vtkFollower;
66class vtkVectorText;
68class vtkCellPicker;
69
70class VTKINTERACTIONWIDGETS_EXPORT vtkLineRepresentation : public vtkWidgetRepresentation
71{
72public:
77
79
83 void PrintSelf(ostream& os, vtkIndent indent) override;
85
87
92 void GetPoint1WorldPosition(double pos[3]);
94 void GetPoint1DisplayPosition(double pos[3]);
95 double* GetPoint1DisplayPosition() VTK_SIZEHINT(3);
96 void SetPoint1WorldPosition(double pos[3]);
97 void SetPoint1DisplayPosition(double pos[3]);
98 void GetPoint2DisplayPosition(double pos[3]);
99 double* GetPoint2DisplayPosition() VTK_SIZEHINT(3);
100 void GetPoint2WorldPosition(double pos[3]);
101 double* GetPoint2WorldPosition() VTK_SIZEHINT(3);
102 void SetPoint2WorldPosition(double pos[3]);
103 void SetPoint2DisplayPosition(double pos[3]);
105
107
117 void SetHandleRepresentation(vtkPointHandleRepresentation3D* handle);
118 void InstantiateHandleRepresentation();
120
122
125 vtkGetObjectMacro(Point1Representation, vtkPointHandleRepresentation3D);
126 vtkGetObjectMacro(Point2Representation, vtkPointHandleRepresentation3D);
127 vtkGetObjectMacro(LineHandleRepresentation, vtkPointHandleRepresentation3D);
129
131
135 vtkGetObjectMacro(EndPointProperty, vtkProperty);
136 vtkGetObjectMacro(SelectedEndPointProperty, vtkProperty);
138
140
144 vtkGetObjectMacro(EndPoint2Property, vtkProperty);
145 vtkGetObjectMacro(SelectedEndPoint2Property, vtkProperty);
147
149
153 vtkGetObjectMacro(LineProperty, vtkProperty);
154 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
156
158
163 vtkSetClampMacro(Tolerance, int, 1, 100);
164 vtkGetMacro(Tolerance, int);
166
168
173 void SetResolution(int res);
174 int GetResolution();
176
185 void GetPolyData(vtkPolyData* pd);
186
188
191 void PlaceWidget(double bounds[6]) override;
192 void BuildRepresentation() override;
193 int ComputeInteractionState(int X, int Y, int modify = 0) override;
194 void StartWidgetInteraction(double e[2]) override;
195 void WidgetInteraction(double e[2]) override;
196 double* GetBounds() VTK_SIZEHINT(6) override;
198
200
203 void GetActors(vtkPropCollection* pc) override;
204 void ReleaseGraphicsResources(vtkWindow*) override;
205 int RenderOpaqueGeometry(vtkViewport*) override;
206 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
207 vtkTypeBool HasTranslucentPolygonalGeometry() override;
209
210 // Manage the state of the widget
211 enum
212 {
213 Outside = 0,
219 Scaling
220 };
221
223
232 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
234
236
240 virtual void SetRepresentationState(int);
241 vtkGetMacro(RepresentationState, int);
243
245
249 void SetDirectionalLine(bool val);
250 vtkGetMacro(DirectionalLine, bool);
251 vtkBooleanMacro(DirectionalLine, bool);
253
259
263 void SetRenderer(vtkRenderer* ren) override;
264
266
269 vtkSetMacro(DistanceAnnotationVisibility, vtkTypeBool);
270 vtkGetMacro(DistanceAnnotationVisibility, vtkTypeBool);
271 vtkBooleanMacro(DistanceAnnotationVisibility, vtkTypeBool);
273
275
280 vtkSetStringMacro(DistanceAnnotationFormat);
281 vtkGetStringMacro(DistanceAnnotationFormat);
283
285
288 void SetDistanceAnnotationScale(double x, double y, double z)
289 {
290 double scale[3];
291 scale[0] = x;
292 scale[1] = y;
293 scale[2] = z;
294 this->SetDistanceAnnotationScale(scale);
295 }
296 virtual void SetDistanceAnnotationScale(double scale[3]);
299
303 double GetDistance();
304
309 void SetLineColor(double r, double g, double b);
310
314 virtual vtkProperty* GetDistanceAnnotationProperty();
315
317
320 vtkGetObjectMacro(TextActor, vtkFollower);
322
323 enum
324 {
325 RestrictNone = 0,
328 RestrictToZ
329 };
330
331protected:
334
335 // The handle and the rep used to close the handles
340
341 // Manage how the representation appears
344
345 // the line
349
350 // glyphs representing hot spots (e.g., handles)
354
355 // Properties used to control the appearance of selected objects and
356 // the manipulator in general.
364
365 // Selection tolerance for the handles and the line
367
368 // Helper members
370 void ClampPosition(double x[3]);
371 void HighlightPoint(int ptId, int highlight);
372 void HighlightLine(int highlight);
373 int InBounds(double x[3]);
375
376 // Ivars used during widget interaction to hold initial positions
377 double StartP1[3];
378 double StartP2[3];
379 double StartLineHandle[3];
380 double Length;
381 double LastEventPosition[3];
382
383 // Support GetBounds() method
385
386 // Need to keep track if we have successfully initialized the display position.
387 // The widget tends to do stuff in world coordinates, put if the renderer has
388 // not been assigned, then certain operations do not properly update the display
389 // position.
391
392 // Format for the label
395
399 double Distance;
401
403
404private:
406 void operator=(const vtkLineRepresentation&) = delete;
407};
408
409#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:61
implicit function for a bounding box
Definition vtkBox.h:51
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
a subclass of actor that always faces the camera
Definition vtkFollower.h:53
a simple class to control print indentation
Definition vtkIndent.h:49
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.
vtkPolyDataMapper * TextMapper
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 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.
vtkPolyDataMapper * LineMapper
vtkPointHandleRepresentation3D * LineHandleRepresentation
double * GetPoint1WorldPosition()
Methods to Set/Get the coordinates of the two points defining this representation.
void SetRenderer(vtkRenderer *ren) override
Overridden to set the rendererer on the internal representations.
vtkPolyDataAlgorithm ** HandleGeometry
virtual double * GetDistanceAnnotationScale()
Scale text (font size along each dimension).
void HighlightLine(int highlight)
void HighlightPoint(int ptId, int highlight)
vtkPointHandleRepresentation3D * Point2Representation
vtkPointHandleRepresentation3D * HandleRepresentation
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
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
an ordered list of Props
represent surface properties of a geometric object
Definition vtkProperty.h:77
abstract specification for renderers
Definition vtkRenderer.h:82
create polygonal text
abstract specification for Viewports
Definition vtkViewport.h:65
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:69
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287
#define VTK_SIZEHINT(...)