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=========================================================================*/
42#ifndef vtkBorderRepresentation_h
43#define vtkBorderRepresentation_h
44
45#include "vtkCoordinate.h" //Because of the viewport coordinate macro
46#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
47#include "vtkInteractionWidgetsModule.h" // For export macro
49
50#include "vtkNew.h" // for ivars
51
52class vtkPoints;
53class vtkPolyData;
54class vtkTransform;
57class vtkActor2D;
58class vtkProperty2D;
59class vtkCellArray;
60
61class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
62{
63public:
68
70
74 void PrintSelf(ostream& os, vtkIndent indent) override;
76
78
87 vtkViewportCoordinateMacro(Position);
88 vtkViewportCoordinateMacro(Position2);
90
91 enum
92 {
93 BORDER_OFF = 0,
95 BORDER_ACTIVE
96 };
97
99
110 virtual void SetShowBorder(int border);
113 virtual int GetShowBorder();
114 void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
115 void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
116 void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
118
120
125 vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
126 vtkGetMacro(ShowVerticalBorder, int);
128
130
135 vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
136 vtkGetMacro(ShowHorizontalBorder, int);
138
140
143 vtkGetObjectMacro(BorderProperty, vtkProperty2D);
145
147
152 virtual void SetShowPolygon(int border);
153 virtual int GetShowPolygon();
154 void SetShowPolygonToOff() { this->SetShowPolygon(BORDER_OFF); }
155 void SetShowPolygonToOn() { this->SetShowPolygon(BORDER_ON); }
156 void SetShowPolygonToActive() { this->SetShowPolygon(BORDER_ACTIVE); }
158
160
165 vtkSetClampMacro(ShowPolygonBackground, int, BORDER_OFF, BORDER_ACTIVE);
166 vtkGetMacro(ShowPolygonBackground, int);
168
170
180 vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
181 vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
182 vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
184
186
195 vtkSetMacro(ProportionalResize, vtkTypeBool);
196 vtkGetMacro(ProportionalResize, vtkTypeBool);
197 vtkBooleanMacro(ProportionalResize, vtkTypeBool);
199
201
208 vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
209 vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
211
213
220 vtkSetVector2Macro(MinimumSize, int);
221 vtkGetVector2Macro(MinimumSize, int);
222 vtkSetVector2Macro(MaximumSize, int);
223 vtkGetVector2Macro(MaximumSize, int);
225
227
234 vtkSetClampMacro(Tolerance, int, 1, 10);
235 vtkGetMacro(Tolerance, int);
237
239
243 vtkGetVectorMacro(SelectionPoint, double, 2);
245
247
252 vtkSetMacro(Moving, vtkTypeBool);
253 vtkGetMacro(Moving, vtkTypeBool);
254 vtkBooleanMacro(Moving, vtkTypeBool);
256
257 enum
258 {
259 AnyLocation = 0,
265 UpperCenter
266 };
267
269
280 virtual void SetWindowLocation(int enumLocation);
281 vtkGetMacro(WindowLocation, int);
283
288 {
289 Outside = 0,
298 AdjustingE3
299 };
300#if !defined(VTK_LEGACY_REMOVE)
301 VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
303#endif
304
305 vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
306
312
314
318 void BuildRepresentation() override;
319 void StartWidgetInteraction(double eventPos[2]) override;
320 void WidgetInteraction(double eventPos[2]) override;
321 virtual void GetSize(double size[2])
322 {
323 size[0] = 1.0;
324 size[1] = 1.0;
325 }
326 int ComputeInteractionState(int X, int Y, int modify = 0) override;
328
330
341
343 "SetBWActorDisplayOverlay is deprecated. Use "
344 "SetBWActorDisplayOverlayEdges or SetBWActorDisplayOverlayPolygon instead.")
345 void SetBWActorDisplayOverlay(bool);
346
347 void SetBWActorDisplayOverlayEdges(bool);
348 void SetBWActorDisplayOverlayPolygon(bool);
349
351
355 vtkSetVector3Macro(BorderColor, double);
356 vtkGetVector3Macro(BorderColor, double);
358
360
364 vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
365 vtkGetMacro(BorderThickness, float);
367
369
377 vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
378 vtkGetMacro(CornerRadiusStrength, double);
380
382
387 vtkSetClampMacro(CornerResolution, int, 0, 1000);
388 vtkGetMacro(CornerResolution, int);
390
392
396 vtkSetVector3Macro(PolygonColor, double);
397 vtkGetVector3Macro(PolygonColor, double);
399
401
405 vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
406 vtkGetMacro(PolygonOpacity, double);
408
410
413 void SetPolygonRGBA(double rgba[4]);
414 void SetPolygonRGBA(double r, double g, double b, double a);
415
419 void GetPolygonRGBA(double rgba[4]);
420 void GetPolygonRGBA(double& r, double& g, double& b, double& a);
422
423protected:
426
427 // Ivars
428 int ShowVerticalBorder = BORDER_ON;
429 int ShowHorizontalBorder = BORDER_ON;
430 int ShowPolygonBackground = BORDER_ON;
431 vtkNew<vtkProperty2D> BorderProperty;
432 vtkNew<vtkProperty2D> PolygonProperty;
433 vtkTypeBool EnforceNormalizedViewportBounds = 0;
434 vtkTypeBool ProportionalResize = 0;
435 int Tolerance = 3;
436 vtkTypeBool Moving = 0;
437 double SelectionPoint[2] = { 0.0, 0.0 };
438
439 // Layout (position of lower left and upper right corners of border)
442
443 // Window location by enumeration
444 int WindowLocation = AnyLocation;
445 virtual void UpdateWindowLocation();
446
447 // Sometimes subclasses must negotiate with their superclasses
448 // to achieve the correct layout.
450 virtual void NegotiateLayout();
451
452 // Update the border visibility based on InteractionState.
453 // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
454 // ComputeInteractionState()
455 virtual void UpdateShowBorder();
456
457 // Keep track of start position when moving border
458 double StartPosition[2];
459
460 // Border representation. Subclasses may use the BWTransform class
461 // to transform their geometry into the region surrounded by the border.
472
473 // Constraints on size
474 double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
475 int MinimumSize[2] = { 1, 1 };
476 int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
477
478 // Properties of the border
479 double BorderColor[3] = { 1.0, 1.0, 1.0 };
480 float BorderThickness = 1.0;
481 double CornerRadiusStrength = 0.0;
482 int CornerResolution = 20;
483
484 // Properties of the inner polygon (ie. the background)
485 double PolygonColor[3] = { 1.0, 1.0, 1.0 };
486 double PolygonOpacity = 0.0;
487
492
500 void ComputeOneRoundCorner(vtkCellArray* polys, vtkPoints* points, const double radius,
501 vtkIdType xPt, vtkIdType yPt, const double startAngle);
502
503private:
505 void operator=(const vtkBorderRepresentation&) = delete;
506};
507
508#endif
a actor that draws 2D data
Definition vtkActor2D.h:46
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:40
Allocate and hold a VTK object.
Definition vtkNew.h:62
represent and manipulate 3D points
Definition vtkPoints.h:40
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:91
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:56
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:39
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