VTK  9.3.20240423
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
89#ifndef vtkBorderRepresentation_h
90#define vtkBorderRepresentation_h
91
92#include "vtkCoordinate.h" //Because of the viewport coordinate macro
93#include "vtkInteractionWidgetsModule.h" // For export macro
95#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
96
97#include "vtkNew.h" // for ivars
98
99VTK_ABI_NAMESPACE_BEGIN
100class vtkPoints;
101class vtkPolyData;
102class vtkTransform;
105class vtkActor2D;
106class vtkProperty2D;
107class vtkCellArray;
108
109class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkBorderRepresentation
111{
112public:
117
119
123 void PrintSelf(ostream& os, vtkIndent indent) override;
125
127
136 vtkViewportCoordinateMacro(Position);
137 vtkViewportCoordinateMacro(Position2);
139
140 enum
141 {
142 BORDER_OFF = 0,
144 BORDER_ACTIVE
145 };
146
148
159 virtual void SetShowBorder(int border);
162 virtual int GetShowBorder();
163 void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
164 void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
165 void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
167
169
174 vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
175 vtkGetMacro(ShowVerticalBorder, int);
177
179
184 vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
185 vtkGetMacro(ShowHorizontalBorder, int);
187
189
192 vtkGetObjectMacro(BorderProperty, vtkProperty2D);
194
196
201 virtual void SetShowPolygon(int border);
202 virtual int GetShowPolygon();
203 void SetShowPolygonToOff() { this->SetShowPolygon(BORDER_OFF); }
204 void SetShowPolygonToOn() { this->SetShowPolygon(BORDER_ON); }
205 void SetShowPolygonToActive() { this->SetShowPolygon(BORDER_ACTIVE); }
207
209
214 vtkSetClampMacro(ShowPolygonBackground, int, BORDER_OFF, BORDER_ACTIVE);
215 vtkGetMacro(ShowPolygonBackground, int);
217
219
227 vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
228 vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
229 vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
231
233
242 vtkSetMacro(ProportionalResize, vtkTypeBool);
243 vtkGetMacro(ProportionalResize, vtkTypeBool);
244 vtkBooleanMacro(ProportionalResize, vtkTypeBool);
246
248
255 vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
256 vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
258
260
267 vtkSetVector2Macro(MinimumSize, int);
268 vtkGetVector2Macro(MinimumSize, int);
269 vtkSetVector2Macro(MaximumSize, int);
270 vtkGetVector2Macro(MaximumSize, int);
272
274
281 vtkSetClampMacro(Tolerance, int, 1, 10);
282 vtkGetMacro(Tolerance, int);
284
286
290 vtkGetVectorMacro(SelectionPoint, double, 2);
292
294
299 vtkSetMacro(Moving, vtkTypeBool);
300 vtkGetMacro(Moving, vtkTypeBool);
301 vtkBooleanMacro(Moving, vtkTypeBool);
303
304 enum
305 {
306 AnyLocation = 0,
312 UpperCenter
313 };
314
316
327 virtual void SetWindowLocation(int enumLocation);
328 vtkGetMacro(WindowLocation, int);
330
337 virtual void UpdateWindowLocation();
338
343 {
344 Outside = 0,
353 AdjustingE3
354 };
355
356 vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
357
363
365
369 void BuildRepresentation() override;
370 void StartWidgetInteraction(double eventPos[2]) override;
371 void WidgetInteraction(double eventPos[2]) override;
372 virtual void GetSize(double size[2])
373 {
374 size[0] = 1.0;
375 size[1] = 1.0;
376 }
377 int ComputeInteractionState(int X, int Y, int modify = 0) override;
379
381
392
395
397
401 vtkSetVector3Macro(BorderColor, double);
402 vtkGetVector3Macro(BorderColor, double);
404
406
410 vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
411 vtkGetMacro(BorderThickness, float);
413
415
423 vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
424 vtkGetMacro(CornerRadiusStrength, double);
426
428
433 vtkSetClampMacro(CornerResolution, int, 0, 1000);
434 vtkGetMacro(CornerResolution, int);
436
438
442 vtkSetVector3Macro(PolygonColor, double);
443 vtkGetVector3Macro(PolygonColor, double);
445
447
451 vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
452 vtkGetMacro(PolygonOpacity, double);
454
456
459 void SetPolygonRGBA(double rgba[4]);
460 void SetPolygonRGBA(double r, double g, double b, double a);
461
465 void GetPolygonRGBA(double rgba[4]);
466 void GetPolygonRGBA(double& r, double& g, double& b, double& a);
468
469protected:
472
473 // Ivars
474 int ShowVerticalBorder = BORDER_ON;
475 int ShowHorizontalBorder = BORDER_ON;
476 int ShowPolygonBackground = BORDER_ON;
479 vtkTypeBool EnforceNormalizedViewportBounds = 0;
480 vtkTypeBool ProportionalResize = 0;
481 int Tolerance = 3;
482 vtkTypeBool Moving = 0;
483 double SelectionPoint[2] = { 0.0, 0.0 };
484
485 // Layout (position of lower left and upper right corners of border)
488
489 // Window location by enumeration
490 int WindowLocation = AnyLocation;
491
492 // Sometimes subclasses must negotiate with their superclasses
493 // to achieve the correct layout.
495 virtual void NegotiateLayout();
496
497 // Update the border visibility based on InteractionState.
498 // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
499 // ComputeInteractionState()
500 virtual void UpdateShowBorder();
501
502 // Keep track of start position when moving border
503 double StartPosition[2];
504
505 // Border representation. Subclasses may use the BWTransform class
506 // to transform their geometry into the region surrounded by the border.
517
518 // Constraints on size
519 double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
520 int MinimumSize[2] = { 1, 1 };
521 int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
522
523 // Properties of the border
524 double BorderColor[3] = { 1.0, 1.0, 1.0 };
525 float BorderThickness = 1.0;
526 double CornerRadiusStrength = 0.0;
527 int CornerResolution = 20;
528
529 // Properties of the inner polygon (ie. the background)
530 double PolygonColor[3] = { 1.0, 1.0, 1.0 };
531 double PolygonOpacity = 0.0;
532
537
545 void ComputeOneRoundCorner(vtkCellArray* polys, vtkPoints* points, double radius, vtkIdType xPt,
546 vtkIdType yPt, double startAngle);
547
548private:
550 void operator=(const vtkBorderRepresentation&) = delete;
551};
552
553VTK_ABI_NAMESPACE_END
554#endif
a actor that draws 2D data
Definition vtkActor2D.h:145
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 ...
void SetPolygonRGBA(double r, double g, double b, double a)
Convenience method to set the background color and the opacity at once.
void GetPolygonRGBA(double rgba[4])
Convenience method to get the background color and the opacity at once.
vtkNew< vtkProperty2D > BorderProperty
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.
void GetPolygonRGBA(double &r, double &g, double &b, double &a)
Convenience method to set the background color and the opacity at once.
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,...
void SetBWActorDisplayOverlayPolygon(bool)
~vtkBorderRepresentation() override
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< vtkProperty2D > PolygonProperty
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.
void SetBWActorDisplayOverlayEdges(bool)
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
void SetPolygonRGBA(double rgba[4])
Convenience method to set the background color and the opacity at once.
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:108
Allocate and hold a VTK object.
Definition vtkNew.h:160
represent and manipulate 3D points
Definition vtkPoints.h:139
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
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:65
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
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
#define VTK_MARSHALAUTO