VTK  9.1.0
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 "vtkInteractionWidgetsModule.h" // For export macro
45
46#include "vtkNew.h" // for ivars
47
48class vtkPoints;
49class vtkPolyData;
50class vtkTransform;
53class vtkActor2D;
54class vtkProperty2D;
55class vtkCellArray;
56
57class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
58{
59public:
64
66
70 void PrintSelf(ostream& os, vtkIndent indent) override;
72
74
83 vtkViewportCoordinateMacro(Position);
84 vtkViewportCoordinateMacro(Position2);
86
87 enum
88 {
89 BORDER_OFF = 0,
91 BORDER_ACTIVE
92 };
93
95
106 virtual void SetShowBorder(int border);
109 virtual int GetShowBorder();
110 void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
111 void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
112 void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
114
116
120 vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
121 vtkGetMacro(ShowVerticalBorder, int);
123
125
129 vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
130 vtkGetMacro(ShowHorizontalBorder, int);
132
134
137 vtkGetObjectMacro(BorderProperty, vtkProperty2D);
139
141
151 vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
152 vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
153 vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
155
157
166 vtkSetMacro(ProportionalResize, vtkTypeBool);
167 vtkGetMacro(ProportionalResize, vtkTypeBool);
168 vtkBooleanMacro(ProportionalResize, vtkTypeBool);
170
172
179 vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
180 vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
182
184
191 vtkSetVector2Macro(MinimumSize, int);
192 vtkGetVector2Macro(MinimumSize, int);
193 vtkSetVector2Macro(MaximumSize, int);
194 vtkGetVector2Macro(MaximumSize, int);
196
198
205 vtkSetClampMacro(Tolerance, int, 1, 10);
206 vtkGetMacro(Tolerance, int);
208
210
214 vtkGetVectorMacro(SelectionPoint, double, 2);
216
218
223 vtkSetMacro(Moving, vtkTypeBool);
224 vtkGetMacro(Moving, vtkTypeBool);
225 vtkBooleanMacro(Moving, vtkTypeBool);
227
232 {
233 Outside = 0,
242 AdjustingE3
243 };
244 vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
245
251
253
257 void BuildRepresentation() override;
258 void StartWidgetInteraction(double eventPos[2]) override;
259 void WidgetInteraction(double eventPos[2]) override;
260 virtual void GetSize(double size[2])
261 {
262 size[0] = 1.0;
263 size[1] = 1.0;
264 }
265 int ComputeInteractionState(int X, int Y, int modify = 0) override;
267
269
280
282
284
288 vtkSetVector3Macro(BorderColor, double);
289 vtkGetVector3Macro(BorderColor, double);
291
293
297 vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
298 vtkGetMacro(BorderThickness, float);
300
302
310 vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
311 vtkGetMacro(CornerRadiusStrength, double);
313
315
320 vtkSetClampMacro(CornerResolution, int, 0, 1000);
321 vtkGetMacro(CornerResolution, int);
323
325
329 vtkSetVector3Macro(PolygonColor, double);
330 vtkGetVector3Macro(PolygonColor, double);
332
334
338 vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
339 vtkGetMacro(PolygonOpacity, double);
341
343
346 void SetPolygonRGBA(double rgba[4]);
347 void SetPolygonRGBA(double r, double g, double b, double a);
348
352 void GetPolygonRGBA(double rgba[4]);
353 void GetPolygonRGBA(double& r, double& g, double& b, double& a);
355
356protected:
359
360 // Ivars
361 int ShowVerticalBorder = BORDER_ON;
362 int ShowHorizontalBorder = BORDER_ON;
365 vtkTypeBool EnforceNormalizedViewportBounds = 0;
366 vtkTypeBool ProportionalResize = 0;
367 int Tolerance = 3;
368 vtkTypeBool Moving = 0;
369 double SelectionPoint[2] = { 0.0, 0.0 };
370
371 // Layout (position of lower left and upper right corners of border)
374
375 // Sometimes subclasses must negotiate with their superclasses
376 // to achieve the correct layout.
378 virtual void NegotiateLayout();
379
380 // Update the border visibility based on InteractionState.
381 // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
382 // ComputeInteractionState()
383 virtual void UpdateShowBorder();
384
385 // Keep track of start position when moving border
386 double StartPosition[2];
387
388 // Border representation. Subclasses may use the BWTransform class
389 // to transform their geometry into the region surrounded by the border.
400
401 // Constraints on size
402 double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
403 int MinimumSize[2] = { 1, 1 };
404 int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
405
406 // Properties of the border
407 double BorderColor[3] = { 1.0, 1.0, 1.0 };
408 float BorderThickness = 1.0;
409 double CornerRadiusStrength = 0.0;
410 int CornerResolution = 20;
411
412 // Properties of the inner polygon (ie. the background)
413 double PolygonColor[3] = { 1.0, 1.0, 1.0 };
414 double PolygonOpacity = 0.0;
415
420
428 void ComputeOneRoundCorner(vtkCellArray* polys, vtkPoints* points, const double radius,
429 vtkIdType xPt, vtkIdType yPt, const double startAngle);
430
431private:
433 void operator=(const vtkBorderRepresentation&) = delete;
434};
435
436#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.
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 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.
_InteractionState
Define the various states that the representation can be in.
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 SetBWActorDisplayOverlay(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.
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 GetShowBorderMaxValue()
Specify when and if the border should appear.
void PrintSelf(ostream &os, vtkIndent indent) override
Define standard methods.
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 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
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
Definition: vtkCellArray.h:181
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:86
an ordered list of Props
represent surface properties of a 2D image
Definition: vtkProperty2D.h:38
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
abstract specification for Viewports
Definition: vtkViewport.h:47
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
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