VTK  9.1.0
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 "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_0_0
42#include "vtkInteractionWidgetsModule.h" // For export macro
44
45class vtkActor;
46class vtkConeSource;
48class vtkLineSource;
49class vtkProperty;
50class vtkPolyData;
53class vtkBox;
54class vtkFollower;
55class vtkVectorText;
57class vtkCellPicker;
58
59class VTKINTERACTIONWIDGETS_EXPORT vtkLineRepresentation : public vtkWidgetRepresentation
60{
61public:
66
68
72 void PrintSelf(ostream& os, vtkIndent indent) override;
74
76
81 void GetPoint1WorldPosition(double pos[3]);
83 void GetPoint1DisplayPosition(double pos[3]);
84 double* GetPoint1DisplayPosition() VTK_SIZEHINT(3);
85 void SetPoint1WorldPosition(double pos[3]);
86 void SetPoint1DisplayPosition(double pos[3]);
87 void GetPoint2DisplayPosition(double pos[3]);
88 double* GetPoint2DisplayPosition() VTK_SIZEHINT(3);
89 void GetPoint2WorldPosition(double pos[3]);
90 double* GetPoint2WorldPosition() VTK_SIZEHINT(3);
91 void SetPoint2WorldPosition(double pos[3]);
92 void SetPoint2DisplayPosition(double pos[3]);
94
96
106 void SetHandleRepresentation(vtkPointHandleRepresentation3D* handle);
107 void InstantiateHandleRepresentation();
109
111
114 vtkGetObjectMacro(Point1Representation, vtkPointHandleRepresentation3D);
115 vtkGetObjectMacro(Point2Representation, vtkPointHandleRepresentation3D);
116 vtkGetObjectMacro(LineHandleRepresentation, vtkPointHandleRepresentation3D);
118
120
124 vtkGetObjectMacro(EndPointProperty, vtkProperty);
125 vtkGetObjectMacro(SelectedEndPointProperty, vtkProperty);
127
129
133 vtkGetObjectMacro(EndPoint2Property, vtkProperty);
134 vtkGetObjectMacro(SelectedEndPoint2Property, vtkProperty);
136
138
142 vtkGetObjectMacro(LineProperty, vtkProperty);
143 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
145
147
152 vtkSetClampMacro(Tolerance, int, 1, 100);
153 vtkGetMacro(Tolerance, int);
155
157
162 void SetResolution(int res);
163 int GetResolution();
165
174 void GetPolyData(vtkPolyData* pd);
175
177
180 void PlaceWidget(double bounds[6]) override;
181 void BuildRepresentation() override;
182 int ComputeInteractionState(int X, int Y, int modify = 0) override;
183 void StartWidgetInteraction(double e[2]) override;
184 void WidgetInteraction(double e[2]) override;
185 double* GetBounds() VTK_SIZEHINT(6) override;
187
189
192 void GetActors(vtkPropCollection* pc) override;
193 void ReleaseGraphicsResources(vtkWindow*) override;
194 int RenderOpaqueGeometry(vtkViewport*) override;
195 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
196 vtkTypeBool HasTranslucentPolygonalGeometry() override;
198
199 // Manage the state of the widget
200 enum
201 {
202 Outside = 0,
208 Scaling
209 };
210
212
221 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
223
225
229 virtual void SetRepresentationState(int);
230 vtkGetMacro(RepresentationState, int);
232
234
238 void SetDirectionalLine(bool val);
239 vtkGetMacro(DirectionalLine, bool);
240 vtkBooleanMacro(DirectionalLine, bool);
242
248
252 void SetRenderer(vtkRenderer* ren) override;
253
255
258 vtkSetMacro(DistanceAnnotationVisibility, vtkTypeBool);
259 vtkGetMacro(DistanceAnnotationVisibility, vtkTypeBool);
260 vtkBooleanMacro(DistanceAnnotationVisibility, vtkTypeBool);
262
264
269 vtkSetStringMacro(DistanceAnnotationFormat);
270 vtkGetStringMacro(DistanceAnnotationFormat);
272
274
277 void SetDistanceAnnotationScale(double x, double y, double z)
278 {
279 double scale[3];
280 scale[0] = x;
281 scale[1] = y;
282 scale[2] = z;
283 this->SetDistanceAnnotationScale(scale);
284 }
285 virtual void SetDistanceAnnotationScale(double scale[3]);
288
292 double GetDistance();
293
298 void SetLineColor(double r, double g, double b);
299
303 virtual vtkProperty* GetDistanceAnnotationProperty();
304
306
309 vtkGetObjectMacro(TextActor, vtkFollower);
311
312 enum
313 {
314 RestrictNone = 0,
317 RestrictToZ
318 };
319
324 VTK_DEPRECATED_IN_9_0_0("Removed in 9.0")
325 void SetRestrictFlag(int restrict_flag);
326
327protected:
330
331 // The handle and the rep used to close the handles
332 vtkPointHandleRepresentation3D* HandleRepresentation;
333 vtkPointHandleRepresentation3D* Point1Representation;
334 vtkPointHandleRepresentation3D* Point2Representation;
335 vtkPointHandleRepresentation3D* LineHandleRepresentation;
336
337 // Manage how the representation appears
338 int RepresentationState;
339 bool DirectionalLine;
340
341 // the line
342 vtkActor* LineActor;
343 vtkPolyDataMapper* LineMapper;
344 vtkLineSource* LineSource;
345
346 // glyphs representing hot spots (e.g., handles)
347 vtkActor** Handle;
348 vtkPolyDataMapper** HandleMapper;
349 vtkPolyDataAlgorithm** HandleGeometry;
350
351 // Properties used to control the appearance of selected objects and
352 // the manipulator in general.
353 vtkProperty* EndPointProperty;
354 vtkProperty* SelectedEndPointProperty;
355 vtkProperty* EndPoint2Property;
356 vtkProperty* SelectedEndPoint2Property;
357 vtkProperty* LineProperty;
358 vtkProperty* SelectedLineProperty;
359 void CreateDefaultProperties();
360
361 // Selection tolerance for the handles and the line
362 int Tolerance;
363
364 // Helper members
365 int ClampToBounds;
366 void ClampPosition(double x[3]);
367 void HighlightPoint(int ptId, int highlight);
368 void HighlightLine(int highlight);
369 int InBounds(double x[3]);
370 void SizeHandles();
371
372 // Ivars used during widget interaction to hold initial positions
373 double StartP1[3];
374 double StartP2[3];
375 double StartLineHandle[3];
376 double Length;
377 double LastEventPosition[3];
378
379 // Support GetBounds() method
380 vtkBox* BoundingBox;
381
382 // Need to keep track if we have successfully initialized the display position.
383 // The widget tends to do stuff in world coordinates, put if the renderer has
384 // not been assigned, then certain operations do not properly update the display
385 // position.
386 int InitializedDisplayPosition;
387
388 // Format for the label
389 vtkTypeBool DistanceAnnotationVisibility;
390 char* DistanceAnnotationFormat;
391
392 vtkFollower* TextActor;
393 vtkPolyDataMapper* TextMapper;
394 vtkVectorText* TextInput;
395 double Distance;
396 bool AnnotationTextScaleInitialized;
397
398 vtkCellPicker* LinePicker;
399
400private:
402 void operator=(const vtkLineRepresentation&) = delete;
403};
404
405#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.
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).
virtual void SetRepresentationState(int)
Sets the visual appearance of the representation based on the state it is in.
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.
virtual double * GetDistanceAnnotationScale()
Scale text (font size along each dimension).
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...
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:86
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:62
abstract specification for renderers
Definition: vtkRenderer.h:73
create polygonal text
Definition: vtkVectorText.h:42
abstract specification for Viewports
Definition: vtkViewport.h:47
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
void GetBounds(T a, double bds[6])
@ scale
Definition: vtkX3D.h:235
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DEPRECATED_IN_9_0_0(reason)
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)