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=========================================================================*/
57#ifndef vtkLineRepresentation_h
58#define vtkLineRepresentation_h
59
60#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_0_0
61#include "vtkInteractionWidgetsModule.h" // For export macro
63
64class vtkActor;
65class vtkConeSource;
67class vtkLineSource;
68class vtkProperty;
69class vtkPolyData;
72class vtkBox;
73class vtkFollower;
74class vtkVectorText;
76class vtkCellPicker;
77
78class VTKINTERACTIONWIDGETS_EXPORT vtkLineRepresentation : public vtkWidgetRepresentation
79{
80public:
85
87
91 void PrintSelf(ostream& os, vtkIndent indent) override;
93
95
100 void GetPoint1WorldPosition(double pos[3]);
102 void GetPoint1DisplayPosition(double pos[3]);
103 double* GetPoint1DisplayPosition() VTK_SIZEHINT(3);
104 void SetPoint1WorldPosition(double pos[3]);
105 void SetPoint1DisplayPosition(double pos[3]);
106 void GetPoint2DisplayPosition(double pos[3]);
107 double* GetPoint2DisplayPosition() VTK_SIZEHINT(3);
108 void GetPoint2WorldPosition(double pos[3]);
109 double* GetPoint2WorldPosition() VTK_SIZEHINT(3);
110 void SetPoint2WorldPosition(double pos[3]);
111 void SetPoint2DisplayPosition(double pos[3]);
113
115
125 void SetHandleRepresentation(vtkPointHandleRepresentation3D* handle);
126 void InstantiateHandleRepresentation();
128
130
133 vtkGetObjectMacro(Point1Representation, vtkPointHandleRepresentation3D);
134 vtkGetObjectMacro(Point2Representation, vtkPointHandleRepresentation3D);
135 vtkGetObjectMacro(LineHandleRepresentation, vtkPointHandleRepresentation3D);
137
139
143 vtkGetObjectMacro(EndPointProperty, vtkProperty);
144 vtkGetObjectMacro(SelectedEndPointProperty, vtkProperty);
146
148
152 vtkGetObjectMacro(EndPoint2Property, vtkProperty);
153 vtkGetObjectMacro(SelectedEndPoint2Property, vtkProperty);
155
157
161 vtkGetObjectMacro(LineProperty, vtkProperty);
162 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
164
166
171 vtkSetClampMacro(Tolerance, int, 1, 100);
172 vtkGetMacro(Tolerance, int);
174
176
181 void SetResolution(int res);
182 int GetResolution();
184
193 void GetPolyData(vtkPolyData* pd);
194
196
199 void PlaceWidget(double bounds[6]) override;
200 void BuildRepresentation() override;
201 int ComputeInteractionState(int X, int Y, int modify = 0) override;
202 void StartWidgetInteraction(double e[2]) override;
203 void WidgetInteraction(double e[2]) override;
204 double* GetBounds() VTK_SIZEHINT(6) override;
206
208
211 void GetActors(vtkPropCollection* pc) override;
212 void ReleaseGraphicsResources(vtkWindow*) override;
213 int RenderOpaqueGeometry(vtkViewport*) override;
214 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
215 vtkTypeBool HasTranslucentPolygonalGeometry() override;
217
218 // Manage the state of the widget
219 enum
220 {
221 Outside = 0,
227 Scaling
228 };
229
231
240 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
242
244
248 virtual void SetRepresentationState(int);
249 vtkGetMacro(RepresentationState, int);
251
253
257 void SetDirectionalLine(bool val);
258 vtkGetMacro(DirectionalLine, bool);
259 vtkBooleanMacro(DirectionalLine, bool);
261
267
271 void SetRenderer(vtkRenderer* ren) override;
272
274
277 vtkSetMacro(DistanceAnnotationVisibility, vtkTypeBool);
278 vtkGetMacro(DistanceAnnotationVisibility, vtkTypeBool);
279 vtkBooleanMacro(DistanceAnnotationVisibility, vtkTypeBool);
281
283
288 vtkSetStringMacro(DistanceAnnotationFormat);
289 vtkGetStringMacro(DistanceAnnotationFormat);
291
293
296 void SetDistanceAnnotationScale(double x, double y, double z)
297 {
298 double scale[3];
299 scale[0] = x;
300 scale[1] = y;
301 scale[2] = z;
302 this->SetDistanceAnnotationScale(scale);
303 }
304 virtual void SetDistanceAnnotationScale(double scale[3]);
307
311 double GetDistance();
312
317 void SetLineColor(double r, double g, double b);
318
322 virtual vtkProperty* GetDistanceAnnotationProperty();
323
325
328 vtkGetObjectMacro(TextActor, vtkFollower);
330
331 enum
332 {
333 RestrictNone = 0,
336 RestrictToZ
337 };
338
343 VTK_DEPRECATED_IN_9_0_0("Removed in 9.0")
344 void SetRestrictFlag(int restrict_flag);
345
346protected:
349
350 // The handle and the rep used to close the handles
351 vtkPointHandleRepresentation3D* HandleRepresentation;
352 vtkPointHandleRepresentation3D* Point1Representation;
353 vtkPointHandleRepresentation3D* Point2Representation;
354 vtkPointHandleRepresentation3D* LineHandleRepresentation;
355
356 // Manage how the representation appears
357 int RepresentationState;
358 bool DirectionalLine;
359
360 // the line
361 vtkActor* LineActor;
362 vtkPolyDataMapper* LineMapper;
363 vtkLineSource* LineSource;
364
365 // glyphs representing hot spots (e.g., handles)
366 vtkActor** Handle;
367 vtkPolyDataMapper** HandleMapper;
368 vtkPolyDataAlgorithm** HandleGeometry;
369
370 // Properties used to control the appearance of selected objects and
371 // the manipulator in general.
372 vtkProperty* EndPointProperty;
373 vtkProperty* SelectedEndPointProperty;
374 vtkProperty* EndPoint2Property;
375 vtkProperty* SelectedEndPoint2Property;
376 vtkProperty* LineProperty;
377 vtkProperty* SelectedLineProperty;
378 void CreateDefaultProperties();
379
380 // Selection tolerance for the handles and the line
381 int Tolerance;
382
383 // Helper members
384 int ClampToBounds;
385 void ClampPosition(double x[3]);
386 void HighlightPoint(int ptId, int highlight);
387 void HighlightLine(int highlight);
388 int InBounds(double x[3]);
389 void SizeHandles();
390
391 // Ivars used during widget interaction to hold initial positions
392 double StartP1[3];
393 double StartP2[3];
394 double StartLineHandle[3];
395 double Length;
396 double LastEventPosition[3];
397
398 // Support GetBounds() method
399 vtkBox* BoundingBox;
400
401 // Need to keep track if we have successfully initialized the display position.
402 // The widget tends to do stuff in world coordinates, put if the renderer has
403 // not been assigned, then certain operations do not properly update the display
404 // position.
405 int InitializedDisplayPosition;
406
407 // Format for the label
408 vtkTypeBool DistanceAnnotationVisibility;
409 char* DistanceAnnotationFormat;
410
411 vtkFollower* TextActor;
412 vtkPolyDataMapper* TextMapper;
413 vtkVectorText* TextInput;
414 double Distance;
415 bool AnnotationTextScaleInitialized;
416
417 vtkCellPicker* LinePicker;
418
419private:
421 void operator=(const vtkLineRepresentation&) = delete;
422};
423
424#endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
implicit function for a bounding box
Definition: vtkBox.h:138
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:96
generate polygonal cone
a subclass of actor that always faces the camera
Definition: vtkFollower.h:120
a simple class to control print indentation
Definition: vtkIndent.h:113
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
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:195
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:171
abstract specification for renderers
Definition: vtkRenderer.h:173
create polygonal text
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:36
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(...)