VTK  9.3.0
vtkBorderRepresentation.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
39#ifndef vtkBorderRepresentation_h
40#define vtkBorderRepresentation_h
41
42#include "vtkCoordinate.h" //Because of the viewport coordinate macro
43#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
44#include "vtkInteractionWidgetsModule.h" // For export macro
45#include "vtkLegacy.h" // for VTK_LEGACY_REMOVE
47
48#include "vtkNew.h" // for ivars
49
50VTK_ABI_NAMESPACE_BEGIN
51class vtkPoints;
52class vtkPolyData;
53class vtkTransform;
56class vtkActor2D;
57class vtkProperty2D;
58class vtkCellArray;
59
60class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
61{
62public:
67
69
73 void PrintSelf(ostream& os, vtkIndent indent) override;
75
77
86 vtkViewportCoordinateMacro(Position);
87 vtkViewportCoordinateMacro(Position2);
89
90 enum
91 {
92 BORDER_OFF = 0,
94 BORDER_ACTIVE
95 };
96
98
109 virtual void SetShowBorder(int border);
112 virtual int GetShowBorder();
113 void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
114 void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
115 void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
117
119
124 vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
125 vtkGetMacro(ShowVerticalBorder, int);
127
129
134 vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
135 vtkGetMacro(ShowHorizontalBorder, int);
137
139
142 vtkGetObjectMacro(BorderProperty, vtkProperty2D);
144
146
151 virtual void SetShowPolygon(int border);
152 virtual int GetShowPolygon();
153 void SetShowPolygonToOff() { this->SetShowPolygon(BORDER_OFF); }
154 void SetShowPolygonToOn() { this->SetShowPolygon(BORDER_ON); }
155 void SetShowPolygonToActive() { this->SetShowPolygon(BORDER_ACTIVE); }
157
159
164 vtkSetClampMacro(ShowPolygonBackground, int, BORDER_OFF, BORDER_ACTIVE);
165 vtkGetMacro(ShowPolygonBackground, int);
167
169
179 vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
180 vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
181 vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
183
185
194 vtkSetMacro(ProportionalResize, vtkTypeBool);
195 vtkGetMacro(ProportionalResize, vtkTypeBool);
196 vtkBooleanMacro(ProportionalResize, vtkTypeBool);
198
200
207 vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
208 vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
210
212
219 vtkSetVector2Macro(MinimumSize, int);
220 vtkGetVector2Macro(MinimumSize, int);
221 vtkSetVector2Macro(MaximumSize, int);
222 vtkGetVector2Macro(MaximumSize, int);
224
226
233 vtkSetClampMacro(Tolerance, int, 1, 10);
234 vtkGetMacro(Tolerance, int);
236
238
242 vtkGetVectorMacro(SelectionPoint, double, 2);
244
246
251 vtkSetMacro(Moving, vtkTypeBool);
252 vtkGetMacro(Moving, vtkTypeBool);
253 vtkBooleanMacro(Moving, vtkTypeBool);
255
256 enum
257 {
258 AnyLocation = 0,
264 UpperCenter
265 };
266
268
279 virtual void SetWindowLocation(int enumLocation);
280 vtkGetMacro(WindowLocation, int);
282
289 virtual void UpdateWindowLocation();
290
295 {
296 Outside = 0,
305 AdjustingE3
306 };
307#if !defined(VTK_LEGACY_REMOVE)
308 VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
310#endif
311
312 vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
313
319
321
325 void BuildRepresentation() override;
326 void StartWidgetInteraction(double eventPos[2]) override;
327 void WidgetInteraction(double eventPos[2]) override;
328 virtual void GetSize(double size[2])
329 {
330 size[0] = 1.0;
331 size[1] = 1.0;
332 }
333 int ComputeInteractionState(int X, int Y, int modify = 0) override;
335
337
348
350 "SetBWActorDisplayOverlay is deprecated. Use "
351 "SetBWActorDisplayOverlayEdges or SetBWActorDisplayOverlayPolygon instead.")
352 void SetBWActorDisplayOverlay(bool);
353
354 void SetBWActorDisplayOverlayEdges(bool);
355 void SetBWActorDisplayOverlayPolygon(bool);
356
358
362 vtkSetVector3Macro(BorderColor, double);
363 vtkGetVector3Macro(BorderColor, double);
365
367
371 vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
372 vtkGetMacro(BorderThickness, float);
374
376
384 vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
385 vtkGetMacro(CornerRadiusStrength, double);
387
389
394 vtkSetClampMacro(CornerResolution, int, 0, 1000);
395 vtkGetMacro(CornerResolution, int);
397
399
403 vtkSetVector3Macro(PolygonColor, double);
404 vtkGetVector3Macro(PolygonColor, double);
406
408
412 vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
413 vtkGetMacro(PolygonOpacity, double);
415
417
420 void SetPolygonRGBA(double rgba[4]);
421 void SetPolygonRGBA(double r, double g, double b, double a);
422
426 void GetPolygonRGBA(double rgba[4]);
427 void GetPolygonRGBA(double& r, double& g, double& b, double& a);
429
430protected:
433
434 // Ivars
435 int ShowVerticalBorder = BORDER_ON;
436 int ShowHorizontalBorder = BORDER_ON;
437 int ShowPolygonBackground = BORDER_ON;
438 vtkNew<vtkProperty2D> BorderProperty;
439 vtkNew<vtkProperty2D> PolygonProperty;
440 vtkTypeBool EnforceNormalizedViewportBounds = 0;
441 vtkTypeBool ProportionalResize = 0;
442 int Tolerance = 3;
443 vtkTypeBool Moving = 0;
444 double SelectionPoint[2] = { 0.0, 0.0 };
445
446 // Layout (position of lower left and upper right corners of border)
449
450 // Window location by enumeration
451 int WindowLocation = AnyLocation;
452
453 // Sometimes subclasses must negotiate with their superclasses
454 // to achieve the correct layout.
456 virtual void NegotiateLayout();
457
458 // Update the border visibility based on InteractionState.
459 // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
460 // ComputeInteractionState()
461 virtual void UpdateShowBorder();
462
463 // Keep track of start position when moving border
464 double StartPosition[2];
465
466 // Border representation. Subclasses may use the BWTransform class
467 // to transform their geometry into the region surrounded by the border.
478
479 // Constraints on size
480 double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
481 int MinimumSize[2] = { 1, 1 };
482 int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
483
484 // Properties of the border
485 double BorderColor[3] = { 1.0, 1.0, 1.0 };
486 float BorderThickness = 1.0;
487 double CornerRadiusStrength = 0.0;
488 int CornerResolution = 20;
489
490 // Properties of the inner polygon (ie. the background)
491 double PolygonColor[3] = { 1.0, 1.0, 1.0 };
492 double PolygonOpacity = 0.0;
493
498
506 void ComputeOneRoundCorner(vtkCellArray* polys, vtkPoints* points, double radius, vtkIdType xPt,
507 vtkIdType yPt, double startAngle);
508
509private:
511 void operator=(const vtkBorderRepresentation&) = delete;
512};
513
514VTK_ABI_NAMESPACE_END
515#endif
a actor that draws 2D data
Definition vtkActor2D.h:44
represent a vtkBorderWidget
virtual void GetSize(double size[2])
Subclasses should implement these methods.
void ComputeOneRoundCorner(vtkCellArray *polys, vtkPoints *points, double radius, vtkIdType xPt, vtkIdType yPt, double startAngle)
Create a quarter circle centered in point[idCenterX].x, point[idCenterY].y), of radius 'radius' with ...
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
virtual int GetShowBorderMinValue()
Specify when and if the border should appear.
vtkNew< vtkPolyDataMapper2D > BWMapperEdges
void SetShowPolygonToOn()
Specify when and if the border's polygon background should appear.
vtkNew< vtkActor2D > BWActorPolygon
void SetShowBorderToActive()
Specify when and if the border should appear.
void WidgetInteraction(double eventPos[2]) override
Subclasses should implement these methods.
void GetActors2D(vtkPropCollection *) override
These methods are necessary to make this representation behave as a vtkProp.
void SetShowPolygonToOff()
Specify when and if the border's polygon background should appear.
virtual void SetWindowLocation(int enumLocation)
Set the representation position, by enumeration ( AnyLocation = 0, LowerLeftCorner,...
static vtkBorderRepresentation * New()
Instantiate this class.
vtkNew< vtkCoordinate > PositionCoordinate
void ComputeRoundCorners()
Create all 4 round corners with the specified radius and resolution.
vtkNew< vtkCoordinate > Position2Coordinate
virtual void NegotiateLayout()
vtkTypeBool HasTranslucentPolygonalGeometry() override
These methods are necessary to make this representation behave as a vtkProp.
int ComputeInteractionState(int X, int Y, int modify=0) override
Subclasses should implement these methods.
void SetShowBorderToOn()
Specify when and if the border should appear.
InteractionStateType
Define the various states that the representation can be in.
virtual void SetShowBorder(int border)
Specify when and if the border should appear.
void StartWidgetInteraction(double eventPos[2]) override
Subclasses should implement these methods.
vtkNew< vtkTransform > BWTransform
int RenderOpaqueGeometry(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
virtual int GetShowPolygon()
Specify when and if the border's polygon background should appear.
virtual int GetShowBorderMaxValue()
Specify when and if the border should appear.
void PrintSelf(ostream &os, vtkIndent indent) override
Define standard methods.
virtual void UpdateWindowLocation()
Update window location if a window location is set.
void SetShowPolygonToActive()
Specify when and if the border's polygon background should appear.
vtkNew< vtkPolyDataMapper2D > BWMapperPolygon
int RenderOverlay(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
void BuildRepresentation() override
Subclasses should implement these methods.
virtual void SetShowPolygon(int border)
Specify when and if the border's polygon background should appear.
virtual int GetShowBorder()
Specify when and if the border should appear.
vtkNew< vtkPolyData > PolyDataEdges
vtkNew< vtkActor2D > BWActorEdges
vtkNew< vtkTransformPolyDataFilter > BWTransformFilter
vtkNew< vtkPolyData > BWPolyData
void SetShowBorderToOff()
Specify when and if the border should appear.
vtkNew< vtkPolyData > PolyDataPolygon
void ReleaseGraphicsResources(vtkWindow *) override
These methods are necessary to make this representation behave as a vtkProp.
vtkMTimeType GetMTime() override
Return the MTime of this object.
virtual void UpdateShowBorder()
object to represent cell connectivity
a simple class to control print indentation
Definition vtkIndent.h:38
Allocate and hold a VTK object.
Definition vtkNew.h:60
represent and manipulate 3D points
Definition vtkPoints.h:38
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:89
an ordered list of Props
represent surface properties of a 2D image
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
abstract specification for Viewports
Definition vtkViewport.h:54
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:34
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_2_0(reason)
int vtkIdType
Definition vtkType.h:315
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270
#define VTK_INT_MAX
Definition vtkType.h:144
#define VTK_FLOAT_MAX
Definition vtkType.h:152