VTK  9.2.6
vtkBorderRepresentation.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkBorderRepresentation.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=========================================================================*/
51#ifndef vtkBorderRepresentation_h
52#define vtkBorderRepresentation_h
53
54#include "vtkCoordinate.h" //Because of the viewport coordinate macro
55#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
56#include "vtkInteractionWidgetsModule.h" // For export macro
58
59#include "vtkNew.h" // for ivars
60
61class vtkPoints;
62class vtkPolyData;
63class vtkTransform;
66class vtkActor2D;
67class vtkProperty2D;
68class vtkCellArray;
69
70class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
71{
72public:
77
79
83 void PrintSelf(ostream& os, vtkIndent indent) override;
85
87
96 vtkViewportCoordinateMacro(Position);
97 vtkViewportCoordinateMacro(Position2);
99
100 enum
101 {
102 BORDER_OFF = 0,
104 BORDER_ACTIVE
105 };
106
108
119 virtual void SetShowBorder(int border);
122 virtual int GetShowBorder();
123 void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
124 void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
125 void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
127
129
134 vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
135 vtkGetMacro(ShowVerticalBorder, int);
137
139
144 vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
145 vtkGetMacro(ShowHorizontalBorder, int);
147
149
152 vtkGetObjectMacro(BorderProperty, vtkProperty2D);
154
156
161 virtual void SetShowPolygon(int border);
162 virtual int GetShowPolygon();
163 void SetShowPolygonToOff() { this->SetShowPolygon(BORDER_OFF); }
164 void SetShowPolygonToOn() { this->SetShowPolygon(BORDER_ON); }
165 void SetShowPolygonToActive() { this->SetShowPolygon(BORDER_ACTIVE); }
167
169
174 vtkSetClampMacro(ShowPolygonBackground, int, BORDER_OFF, BORDER_ACTIVE);
175 vtkGetMacro(ShowPolygonBackground, int);
177
179
189 vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
190 vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
191 vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
193
195
204 vtkSetMacro(ProportionalResize, vtkTypeBool);
205 vtkGetMacro(ProportionalResize, vtkTypeBool);
206 vtkBooleanMacro(ProportionalResize, vtkTypeBool);
208
210
217 vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
218 vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
220
222
229 vtkSetVector2Macro(MinimumSize, int);
230 vtkGetVector2Macro(MinimumSize, int);
231 vtkSetVector2Macro(MaximumSize, int);
232 vtkGetVector2Macro(MaximumSize, int);
234
236
243 vtkSetClampMacro(Tolerance, int, 1, 10);
244 vtkGetMacro(Tolerance, int);
246
248
252 vtkGetVectorMacro(SelectionPoint, double, 2);
254
256
261 vtkSetMacro(Moving, vtkTypeBool);
262 vtkGetMacro(Moving, vtkTypeBool);
263 vtkBooleanMacro(Moving, vtkTypeBool);
265
266 enum
267 {
268 AnyLocation = 0,
274 UpperCenter
275 };
276
278
289 virtual void SetWindowLocation(int enumLocation);
290 vtkGetMacro(WindowLocation, int);
292
297 {
298 Outside = 0,
307 AdjustingE3
308 };
309#if !defined(VTK_LEGACY_REMOVE)
310 VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
312#endif
313
314 vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
315
321
323
327 void BuildRepresentation() override;
328 void StartWidgetInteraction(double eventPos[2]) override;
329 void WidgetInteraction(double eventPos[2]) override;
330 virtual void GetSize(double size[2])
331 {
332 size[0] = 1.0;
333 size[1] = 1.0;
334 }
335 int ComputeInteractionState(int X, int Y, int modify = 0) override;
337
339
350
352 "SetBWActorDisplayOverlay is deprecated. Use "
353 "SetBWActorDisplayOverlayEdges or SetBWActorDisplayOverlayPolygon instead.")
354 void SetBWActorDisplayOverlay(bool);
355
356 void SetBWActorDisplayOverlayEdges(bool);
357 void SetBWActorDisplayOverlayPolygon(bool);
358
360
364 vtkSetVector3Macro(BorderColor, double);
365 vtkGetVector3Macro(BorderColor, double);
367
369
373 vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
374 vtkGetMacro(BorderThickness, float);
376
378
386 vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
387 vtkGetMacro(CornerRadiusStrength, double);
389
391
396 vtkSetClampMacro(CornerResolution, int, 0, 1000);
397 vtkGetMacro(CornerResolution, int);
399
401
405 vtkSetVector3Macro(PolygonColor, double);
406 vtkGetVector3Macro(PolygonColor, double);
408
410
414 vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
415 vtkGetMacro(PolygonOpacity, double);
417
419
422 void SetPolygonRGBA(double rgba[4]);
423 void SetPolygonRGBA(double r, double g, double b, double a);
424
428 void GetPolygonRGBA(double rgba[4]);
429 void GetPolygonRGBA(double& r, double& g, double& b, double& a);
431
432protected:
435
436 // Ivars
437 int ShowVerticalBorder = BORDER_ON;
438 int ShowHorizontalBorder = BORDER_ON;
439 int ShowPolygonBackground = BORDER_ON;
440 vtkNew<vtkProperty2D> BorderProperty;
441 vtkNew<vtkProperty2D> PolygonProperty;
442 vtkTypeBool EnforceNormalizedViewportBounds = 0;
443 vtkTypeBool ProportionalResize = 0;
444 int Tolerance = 3;
445 vtkTypeBool Moving = 0;
446 double SelectionPoint[2] = { 0.0, 0.0 };
447
448 // Layout (position of lower left and upper right corners of border)
451
452 // Window location by enumeration
453 int WindowLocation = AnyLocation;
454 virtual void UpdateWindowLocation();
455
456 // Sometimes subclasses must negotiate with their superclasses
457 // to achieve the correct layout.
459 virtual void NegotiateLayout();
460
461 // Update the border visibility based on InteractionState.
462 // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
463 // ComputeInteractionState()
464 virtual void UpdateShowBorder();
465
466 // Keep track of start position when moving border
467 double StartPosition[2];
468
469 // Border representation. Subclasses may use the BWTransform class
470 // to transform their geometry into the region surrounded by the border.
481
482 // Constraints on size
483 double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
484 int MinimumSize[2] = { 1, 1 };
485 int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
486
487 // Properties of the border
488 double BorderColor[3] = { 1.0, 1.0, 1.0 };
489 float BorderThickness = 1.0;
490 double CornerRadiusStrength = 0.0;
491 int CornerResolution = 20;
492
493 // Properties of the inner polygon (ie. the background)
494 double PolygonColor[3] = { 1.0, 1.0, 1.0 };
495 double PolygonOpacity = 0.0;
496
501
509 void ComputeOneRoundCorner(vtkCellArray* polys, vtkPoints* points, const double radius,
510 vtkIdType xPt, vtkIdType yPt, const double startAngle);
511
512private:
514 void operator=(const vtkBorderRepresentation&) = delete;
515};
516
517#endif
a actor that draws 2D data
Definition vtkActor2D.h:55
represent a vtkBorderWidget
virtual void GetSize(double size[2])
Subclasses should implement these methods.
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()
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.
void ComputeOneRoundCorner(vtkCellArray *polys, vtkPoints *points, const double radius, vtkIdType xPt, vtkIdType yPt, const double startAngle)
Create a quarter circle centered in point[idCenterX].x, point[idCenterY].y), of radius 'radius' with ...
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:49
Allocate and hold a VTK object.
Definition vtkNew.h:71
represent and manipulate 3D points
Definition vtkPoints.h:49
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:69
#define VTK_DEPRECATED_IN_9_2_0(reason)
int vtkIdType
Definition vtkType.h:332
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287
#define VTK_INT_MAX
Definition vtkType.h:155
#define VTK_FLOAT_MAX
Definition vtkType.h:163