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
30#ifndef vtkBorderRepresentation_h
31#define vtkBorderRepresentation_h
32
33#include "vtkCoordinate.h" //Because of the viewport coordinate macro
34#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
35#include "vtkInteractionWidgetsModule.h" // For export macro
36#include "vtkLegacy.h" // for VTK_LEGACY_REMOVE
38
39#include "vtkNew.h" // for ivars
40
41VTK_ABI_NAMESPACE_BEGIN
42class vtkPoints;
43class vtkPolyData;
44class vtkTransform;
47class vtkActor2D;
48class vtkProperty2D;
49class vtkCellArray;
50
51class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
52{
53public:
58
60
64 void PrintSelf(ostream& os, vtkIndent indent) override;
66
68
77 vtkViewportCoordinateMacro(Position);
78 vtkViewportCoordinateMacro(Position2);
80
81 enum
82 {
83 BORDER_OFF = 0,
85 BORDER_ACTIVE
86 };
87
89
100 virtual void SetShowBorder(int border);
103 virtual int GetShowBorder();
104 void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
105 void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
106 void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
108
110
115 vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
116 vtkGetMacro(ShowVerticalBorder, int);
118
120
125 vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
126 vtkGetMacro(ShowHorizontalBorder, int);
128
130
133 vtkGetObjectMacro(BorderProperty, vtkProperty2D);
135
137
142 virtual void SetShowPolygon(int border);
143 virtual int GetShowPolygon();
144 void SetShowPolygonToOff() { this->SetShowPolygon(BORDER_OFF); }
145 void SetShowPolygonToOn() { this->SetShowPolygon(BORDER_ON); }
146 void SetShowPolygonToActive() { this->SetShowPolygon(BORDER_ACTIVE); }
148
150
155 vtkSetClampMacro(ShowPolygonBackground, int, BORDER_OFF, BORDER_ACTIVE);
156 vtkGetMacro(ShowPolygonBackground, int);
158
160
170 vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
171 vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
172 vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
174
176
185 vtkSetMacro(ProportionalResize, vtkTypeBool);
186 vtkGetMacro(ProportionalResize, vtkTypeBool);
187 vtkBooleanMacro(ProportionalResize, vtkTypeBool);
189
191
198 vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
199 vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
201
203
210 vtkSetVector2Macro(MinimumSize, int);
211 vtkGetVector2Macro(MinimumSize, int);
212 vtkSetVector2Macro(MaximumSize, int);
213 vtkGetVector2Macro(MaximumSize, int);
215
217
224 vtkSetClampMacro(Tolerance, int, 1, 10);
225 vtkGetMacro(Tolerance, int);
227
229
233 vtkGetVectorMacro(SelectionPoint, double, 2);
235
237
242 vtkSetMacro(Moving, vtkTypeBool);
243 vtkGetMacro(Moving, vtkTypeBool);
244 vtkBooleanMacro(Moving, vtkTypeBool);
246
247 enum
248 {
249 AnyLocation = 0,
255 UpperCenter
256 };
257
259
270 virtual void SetWindowLocation(int enumLocation);
271 vtkGetMacro(WindowLocation, int);
273
280 virtual void UpdateWindowLocation();
281
286 {
287 Outside = 0,
296 AdjustingE3
297 };
298#if !defined(VTK_LEGACY_REMOVE)
299 VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
301#endif
302
303 vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
304
310
312
316 void BuildRepresentation() override;
317 void StartWidgetInteraction(double eventPos[2]) override;
318 void WidgetInteraction(double eventPos[2]) override;
319 virtual void GetSize(double size[2])
320 {
321 size[0] = 1.0;
322 size[1] = 1.0;
323 }
324 int ComputeInteractionState(int X, int Y, int modify = 0) override;
326
328
339
341 "SetBWActorDisplayOverlay is deprecated. Use "
342 "SetBWActorDisplayOverlayEdges or SetBWActorDisplayOverlayPolygon instead.")
343 void SetBWActorDisplayOverlay(bool);
344
345 void SetBWActorDisplayOverlayEdges(bool);
346 void SetBWActorDisplayOverlayPolygon(bool);
347
349
353 vtkSetVector3Macro(BorderColor, double);
354 vtkGetVector3Macro(BorderColor, double);
356
358
362 vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
363 vtkGetMacro(BorderThickness, float);
365
367
375 vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
376 vtkGetMacro(CornerRadiusStrength, double);
378
380
385 vtkSetClampMacro(CornerResolution, int, 0, 1000);
386 vtkGetMacro(CornerResolution, int);
388
390
394 vtkSetVector3Macro(PolygonColor, double);
395 vtkGetVector3Macro(PolygonColor, double);
397
399
403 vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
404 vtkGetMacro(PolygonOpacity, double);
406
408
411 void SetPolygonRGBA(double rgba[4]);
412 void SetPolygonRGBA(double r, double g, double b, double a);
413
417 void GetPolygonRGBA(double rgba[4]);
418 void GetPolygonRGBA(double& r, double& g, double& b, double& a);
420
421protected:
424
425 // Ivars
426 int ShowVerticalBorder = BORDER_ON;
427 int ShowHorizontalBorder = BORDER_ON;
428 int ShowPolygonBackground = BORDER_ON;
429 vtkNew<vtkProperty2D> BorderProperty;
430 vtkNew<vtkProperty2D> PolygonProperty;
431 vtkTypeBool EnforceNormalizedViewportBounds = 0;
432 vtkTypeBool ProportionalResize = 0;
433 int Tolerance = 3;
434 vtkTypeBool Moving = 0;
435 double SelectionPoint[2] = { 0.0, 0.0 };
436
437 // Layout (position of lower left and upper right corners of border)
440
441 // Window location by enumeration
442 int WindowLocation = AnyLocation;
443
444 // Sometimes subclasses must negotiate with their superclasses
445 // to achieve the correct layout.
447 virtual void NegotiateLayout();
448
449 // Update the border visibility based on InteractionState.
450 // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
451 // ComputeInteractionState()
452 virtual void UpdateShowBorder();
453
454 // Keep track of start position when moving border
455 double StartPosition[2];
456
457 // Border representation. Subclasses may use the BWTransform class
458 // to transform their geometry into the region surrounded by the border.
469
470 // Constraints on size
471 double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
472 int MinimumSize[2] = { 1, 1 };
473 int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
474
475 // Properties of the border
476 double BorderColor[3] = { 1.0, 1.0, 1.0 };
477 float BorderThickness = 1.0;
478 double CornerRadiusStrength = 0.0;
479 int CornerResolution = 20;
480
481 // Properties of the inner polygon (ie. the background)
482 double PolygonColor[3] = { 1.0, 1.0, 1.0 };
483 double PolygonOpacity = 0.0;
484
489
497 void ComputeOneRoundCorner(vtkCellArray* polys, vtkPoints* points, double radius, vtkIdType xPt,
498 vtkIdType yPt, double startAngle);
499
500private:
502 void operator=(const vtkBorderRepresentation&) = delete;
503};
504
505VTK_ABI_NAMESPACE_END
506#endif
a actor that draws 2D data
Definition vtkActor2D.h:35
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:29
Allocate and hold a VTK object.
Definition vtkNew.h:51
represent and manipulate 3D points
Definition vtkPoints.h:29
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:80
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:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:25
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