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=========================================================================*/
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
46
47#include "vtkNew.h" // for ivars
48
49class vtkPoints;
50class vtkPolyData;
51class vtkTransform;
54class vtkActor2D;
55class vtkProperty2D;
56class vtkCellArray;
57
58class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
59{
60public:
65
67
71 void PrintSelf(ostream& os, vtkIndent indent) override;
73
75
84 vtkViewportCoordinateMacro(Position);
85 vtkViewportCoordinateMacro(Position2);
87
88 enum
89 {
90 BORDER_OFF = 0,
92 BORDER_ACTIVE
93 };
94
96
107 virtual void SetShowBorder(int border);
110 virtual int GetShowBorder();
111 void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
112 void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
113 void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
115
117
122 vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
123 vtkGetMacro(ShowVerticalBorder, int);
125
127
132 vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
133 vtkGetMacro(ShowHorizontalBorder, int);
135
137
140 vtkGetObjectMacro(BorderProperty, vtkProperty2D);
142
144
149 virtual void SetShowPolygon(int border);
150 virtual int GetShowPolygon();
151 void SetShowPolygonToOff() { this->SetShowPolygon(BORDER_OFF); }
152 void SetShowPolygonToOn() { this->SetShowPolygon(BORDER_ON); }
153 void SetShowPolygonToActive() { this->SetShowPolygon(BORDER_ACTIVE); }
155
157
162 vtkSetClampMacro(ShowPolygonBackground, int, BORDER_OFF, BORDER_ACTIVE);
163 vtkGetMacro(ShowPolygonBackground, int);
165
167
177 vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
178 vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
179 vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
181
183
192 vtkSetMacro(ProportionalResize, vtkTypeBool);
193 vtkGetMacro(ProportionalResize, vtkTypeBool);
194 vtkBooleanMacro(ProportionalResize, vtkTypeBool);
196
198
205 vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
206 vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
208
210
217 vtkSetVector2Macro(MinimumSize, int);
218 vtkGetVector2Macro(MinimumSize, int);
219 vtkSetVector2Macro(MaximumSize, int);
220 vtkGetVector2Macro(MaximumSize, int);
222
224
231 vtkSetClampMacro(Tolerance, int, 1, 10);
232 vtkGetMacro(Tolerance, int);
234
236
240 vtkGetVectorMacro(SelectionPoint, double, 2);
242
244
249 vtkSetMacro(Moving, vtkTypeBool);
250 vtkGetMacro(Moving, vtkTypeBool);
251 vtkBooleanMacro(Moving, vtkTypeBool);
253
254 enum
255 {
256 AnyLocation = 0,
262 UpperCenter
263 };
264
266
277 virtual void SetWindowLocation(int enumLocation);
278 vtkGetMacro(WindowLocation, int);
280
285 {
286 Outside = 0,
295 AdjustingE3
296 };
297#if !defined(VTK_LEGACY_REMOVE)
298 VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
300#endif
301
302 vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
303
309
311
315 void BuildRepresentation() override;
316 void StartWidgetInteraction(double eventPos[2]) override;
317 void WidgetInteraction(double eventPos[2]) override;
318 virtual void GetSize(double size[2])
319 {
320 size[0] = 1.0;
321 size[1] = 1.0;
322 }
323 int ComputeInteractionState(int X, int Y, int modify = 0) override;
325
327
338
340 "SetBWActorDisplayOverlay is deprecated. Use "
341 "SetBWActorDisplayOverlayEdges or SetBWActorDisplayOverlayPolygon instead.")
342 void SetBWActorDisplayOverlay(bool);
343
344 void SetBWActorDisplayOverlayEdges(bool);
345 void SetBWActorDisplayOverlayPolygon(bool);
346
348
352 vtkSetVector3Macro(BorderColor, double);
353 vtkGetVector3Macro(BorderColor, double);
355
357
361 vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
362 vtkGetMacro(BorderThickness, float);
364
366
374 vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
375 vtkGetMacro(CornerRadiusStrength, double);
377
379
384 vtkSetClampMacro(CornerResolution, int, 0, 1000);
385 vtkGetMacro(CornerResolution, int);
387
389
393 vtkSetVector3Macro(PolygonColor, double);
394 vtkGetVector3Macro(PolygonColor, double);
396
398
402 vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
403 vtkGetMacro(PolygonOpacity, double);
405
407
410 void SetPolygonRGBA(double rgba[4]);
411 void SetPolygonRGBA(double r, double g, double b, double a);
412
416 void GetPolygonRGBA(double rgba[4]);
417 void GetPolygonRGBA(double& r, double& g, double& b, double& a);
419
420protected:
423
424 // Ivars
425 int ShowVerticalBorder = BORDER_ON;
426 int ShowHorizontalBorder = BORDER_ON;
427 int ShowPolygonBackground = BORDER_ON;
428 vtkNew<vtkProperty2D> BorderProperty;
429 vtkNew<vtkProperty2D> PolygonProperty;
430 vtkTypeBool EnforceNormalizedViewportBounds = 0;
431 vtkTypeBool ProportionalResize = 0;
432 int Tolerance = 3;
433 vtkTypeBool Moving = 0;
434 double SelectionPoint[2] = { 0.0, 0.0 };
435
436 // Layout (position of lower left and upper right corners of border)
439
440 // Window location by enumeration
441 int WindowLocation = AnyLocation;
442 virtual void UpdateWindowLocation();
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, const double radius,
498 vtkIdType xPt, vtkIdType yPt, const double startAngle);
499
500private:
502 void operator=(const vtkBorderRepresentation&) = delete;
503};
504
505#endif
a actor that draws 2D data
Definition vtkActor2D.h:40
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:34
Allocate and hold a VTK object.
Definition vtkNew.h:56
represent and manipulate 3D points
Definition vtkPoints.h:34
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:85
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:50
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