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=========================================================================*/
47#ifndef vtkLineRepresentation_h
48#define vtkLineRepresentation_h
49
50#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_0_0
51#include "vtkInteractionWidgetsModule.h" // For export macro
53
54class vtkActor;
55class vtkConeSource;
57class vtkLineSource;
58class vtkProperty;
59class vtkPolyData;
62class vtkBox;
63class vtkFollower;
64class vtkVectorText;
66class vtkCellPicker;
67
68class VTKINTERACTIONWIDGETS_EXPORT vtkLineRepresentation : public vtkWidgetRepresentation
69{
70public:
75
77
81 void PrintSelf(ostream& os, vtkIndent indent) override;
83
85
90 void GetPoint1WorldPosition(double pos[3]);
92 void GetPoint1DisplayPosition(double pos[3]);
93 double* GetPoint1DisplayPosition() VTK_SIZEHINT(3);
94 void SetPoint1WorldPosition(double pos[3]);
95 void SetPoint1DisplayPosition(double pos[3]);
96 void GetPoint2DisplayPosition(double pos[3]);
97 double* GetPoint2DisplayPosition() VTK_SIZEHINT(3);
98 void GetPoint2WorldPosition(double pos[3]);
99 double* GetPoint2WorldPosition() VTK_SIZEHINT(3);
100 void SetPoint2WorldPosition(double pos[3]);
101 void SetPoint2DisplayPosition(double pos[3]);
103
105
115 void SetHandleRepresentation(vtkPointHandleRepresentation3D* handle);
116 void InstantiateHandleRepresentation();
118
120
123 vtkGetObjectMacro(Point1Representation, vtkPointHandleRepresentation3D);
124 vtkGetObjectMacro(Point2Representation, vtkPointHandleRepresentation3D);
125 vtkGetObjectMacro(LineHandleRepresentation, vtkPointHandleRepresentation3D);
127
129
133 vtkGetObjectMacro(EndPointProperty, vtkProperty);
134 vtkGetObjectMacro(SelectedEndPointProperty, vtkProperty);
136
138
142 vtkGetObjectMacro(EndPoint2Property, vtkProperty);
143 vtkGetObjectMacro(SelectedEndPoint2Property, vtkProperty);
145
147
151 vtkGetObjectMacro(LineProperty, vtkProperty);
152 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
154
156
161 vtkSetClampMacro(Tolerance, int, 1, 100);
162 vtkGetMacro(Tolerance, int);
164
166
171 void SetResolution(int res);
172 int GetResolution();
174
183 void GetPolyData(vtkPolyData* pd);
184
186
189 void PlaceWidget(double bounds[6]) override;
190 void BuildRepresentation() override;
191 int ComputeInteractionState(int X, int Y, int modify = 0) override;
192 void StartWidgetInteraction(double e[2]) override;
193 void WidgetInteraction(double e[2]) override;
194 double* GetBounds() VTK_SIZEHINT(6) override;
196
198
201 void GetActors(vtkPropCollection* pc) override;
202 void ReleaseGraphicsResources(vtkWindow*) override;
203 int RenderOpaqueGeometry(vtkViewport*) override;
204 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
205 vtkTypeBool HasTranslucentPolygonalGeometry() override;
207
208 // Manage the state of the widget
209 enum
210 {
211 Outside = 0,
217 Scaling
218 };
219
221
230 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
232
234
238 virtual void SetRepresentationState(int);
239 vtkGetMacro(RepresentationState, int);
241
243
247 void SetDirectionalLine(bool val);
248 vtkGetMacro(DirectionalLine, bool);
249 vtkBooleanMacro(DirectionalLine, bool);
251
257
261 void SetRenderer(vtkRenderer* ren) override;
262
264
267 vtkSetMacro(DistanceAnnotationVisibility, vtkTypeBool);
268 vtkGetMacro(DistanceAnnotationVisibility, vtkTypeBool);
269 vtkBooleanMacro(DistanceAnnotationVisibility, vtkTypeBool);
271
273
278 vtkSetStringMacro(DistanceAnnotationFormat);
279 vtkGetStringMacro(DistanceAnnotationFormat);
281
283
286 void SetDistanceAnnotationScale(double x, double y, double z)
287 {
288 double scale[3];
289 scale[0] = x;
290 scale[1] = y;
291 scale[2] = z;
292 this->SetDistanceAnnotationScale(scale);
293 }
294 virtual void SetDistanceAnnotationScale(double scale[3]);
297
301 double GetDistance();
302
307 void SetLineColor(double r, double g, double b);
308
312 virtual vtkProperty* GetDistanceAnnotationProperty();
313
315
318 vtkGetObjectMacro(TextActor, vtkFollower);
320
321 enum
322 {
323 RestrictNone = 0,
326 RestrictToZ
327 };
328
333 VTK_DEPRECATED_IN_9_0_0("Removed in 9.0")
334 void SetRestrictFlag(int restrict_flag);
335
336protected:
339
340 // The handle and the rep used to close the handles
341 vtkPointHandleRepresentation3D* HandleRepresentation;
342 vtkPointHandleRepresentation3D* Point1Representation;
343 vtkPointHandleRepresentation3D* Point2Representation;
344 vtkPointHandleRepresentation3D* LineHandleRepresentation;
345
346 // Manage how the representation appears
347 int RepresentationState;
348 bool DirectionalLine;
349
350 // the line
351 vtkActor* LineActor;
352 vtkPolyDataMapper* LineMapper;
353 vtkLineSource* LineSource;
354
355 // glyphs representing hot spots (e.g., handles)
356 vtkActor** Handle;
357 vtkPolyDataMapper** HandleMapper;
358 vtkPolyDataAlgorithm** HandleGeometry;
359
360 // Properties used to control the appearance of selected objects and
361 // the manipulator in general.
362 vtkProperty* EndPointProperty;
363 vtkProperty* SelectedEndPointProperty;
364 vtkProperty* EndPoint2Property;
365 vtkProperty* SelectedEndPoint2Property;
366 vtkProperty* LineProperty;
367 vtkProperty* SelectedLineProperty;
368 void CreateDefaultProperties();
369
370 // Selection tolerance for the handles and the line
371 int Tolerance;
372
373 // Helper members
374 int ClampToBounds;
375 void ClampPosition(double x[3]);
376 void HighlightPoint(int ptId, int highlight);
377 void HighlightLine(int highlight);
378 int InBounds(double x[3]);
379 void SizeHandles();
380
381 // Ivars used during widget interaction to hold initial positions
382 double StartP1[3];
383 double StartP2[3];
384 double StartLineHandle[3];
385 double Length;
386 double LastEventPosition[3];
387
388 // Support GetBounds() method
389 vtkBox* BoundingBox;
390
391 // Need to keep track if we have successfully initialized the display position.
392 // The widget tends to do stuff in world coordinates, put if the renderer has
393 // not been assigned, then certain operations do not properly update the display
394 // position.
395 int InitializedDisplayPosition;
396
397 // Format for the label
398 vtkTypeBool DistanceAnnotationVisibility;
399 char* DistanceAnnotationFormat;
400
401 vtkFollower* TextActor;
402 vtkPolyDataMapper* TextMapper;
403 vtkVectorText* TextInput;
404 double Distance;
405 bool AnnotationTextScaleInitialized;
406
407 vtkCellPicker* LinePicker;
408
409private:
411 void operator=(const vtkLineRepresentation&) = delete;
412};
413
414#endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:55
implicit function for a bounding box
Definition: vtkBox.h:48
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:76
generate polygonal cone
Definition: vtkConeSource.h:48
a subclass of actor that always faces the camera
Definition: vtkFollower.h:50
a simple class to control print indentation
Definition: vtkIndent.h:43
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:70
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:95
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:71
abstract specification for renderers
Definition: vtkRenderer.h:73
create polygonal text
Definition: vtkVectorText.h:51
abstract specification for Viewports
Definition: vtkViewport.h:56
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:45
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(...)