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=========================================================================*/
48#ifndef vtkBorderRepresentation_h
49#define vtkBorderRepresentation_h
50
51#include "vtkCoordinate.h" //Because of the viewport coordinate macro
52#include "vtkInteractionWidgetsModule.h" // For export macro
54
55#include "vtkNew.h" // for ivars
56
57class vtkPoints;
58class vtkPolyData;
59class vtkTransform;
62class vtkActor2D;
63class vtkProperty2D;
64class vtkCellArray;
65
66class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
67{
68public:
73
75
79 void PrintSelf(ostream& os, vtkIndent indent) override;
81
83
92 vtkViewportCoordinateMacro(Position);
93 vtkViewportCoordinateMacro(Position2);
95
96 enum
97 {
98 BORDER_OFF = 0,
100 BORDER_ACTIVE
101 };
102
104
115 virtual void SetShowBorder(int border);
118 virtual int GetShowBorder();
119 void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
120 void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
121 void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
123
125
129 vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
130 vtkGetMacro(ShowVerticalBorder, int);
132
134
138 vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
139 vtkGetMacro(ShowHorizontalBorder, int);
141
143
146 vtkGetObjectMacro(BorderProperty, vtkProperty2D);
148
150
160 vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
161 vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
162 vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
164
166
175 vtkSetMacro(ProportionalResize, vtkTypeBool);
176 vtkGetMacro(ProportionalResize, vtkTypeBool);
177 vtkBooleanMacro(ProportionalResize, vtkTypeBool);
179
181
188 vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
189 vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
191
193
200 vtkSetVector2Macro(MinimumSize, int);
201 vtkGetVector2Macro(MinimumSize, int);
202 vtkSetVector2Macro(MaximumSize, int);
203 vtkGetVector2Macro(MaximumSize, int);
205
207
214 vtkSetClampMacro(Tolerance, int, 1, 10);
215 vtkGetMacro(Tolerance, int);
217
219
223 vtkGetVectorMacro(SelectionPoint, double, 2);
225
227
232 vtkSetMacro(Moving, vtkTypeBool);
233 vtkGetMacro(Moving, vtkTypeBool);
234 vtkBooleanMacro(Moving, vtkTypeBool);
236
241 {
242 Outside = 0,
251 AdjustingE3
252 };
253 vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
254
260
262
266 void BuildRepresentation() override;
267 void StartWidgetInteraction(double eventPos[2]) override;
268 void WidgetInteraction(double eventPos[2]) override;
269 virtual void GetSize(double size[2])
270 {
271 size[0] = 1.0;
272 size[1] = 1.0;
273 }
274 int ComputeInteractionState(int X, int Y, int modify = 0) override;
276
278
289
291
293
297 vtkSetVector3Macro(BorderColor, double);
298 vtkGetVector3Macro(BorderColor, double);
300
302
306 vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
307 vtkGetMacro(BorderThickness, float);
309
311
319 vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
320 vtkGetMacro(CornerRadiusStrength, double);
322
324
329 vtkSetClampMacro(CornerResolution, int, 0, 1000);
330 vtkGetMacro(CornerResolution, int);
332
334
338 vtkSetVector3Macro(PolygonColor, double);
339 vtkGetVector3Macro(PolygonColor, double);
341
343
347 vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
348 vtkGetMacro(PolygonOpacity, double);
350
352
355 void SetPolygonRGBA(double rgba[4]);
356 void SetPolygonRGBA(double r, double g, double b, double a);
357
361 void GetPolygonRGBA(double rgba[4]);
362 void GetPolygonRGBA(double& r, double& g, double& b, double& a);
364
365protected:
368
369 // Ivars
370 int ShowVerticalBorder = BORDER_ON;
371 int ShowHorizontalBorder = BORDER_ON;
374 vtkTypeBool EnforceNormalizedViewportBounds = 0;
375 vtkTypeBool ProportionalResize = 0;
376 int Tolerance = 3;
377 vtkTypeBool Moving = 0;
378 double SelectionPoint[2] = { 0.0, 0.0 };
379
380 // Layout (position of lower left and upper right corners of border)
383
384 // Sometimes subclasses must negotiate with their superclasses
385 // to achieve the correct layout.
387 virtual void NegotiateLayout();
388
389 // Update the border visibility based on InteractionState.
390 // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
391 // ComputeInteractionState()
392 virtual void UpdateShowBorder();
393
394 // Keep track of start position when moving border
395 double StartPosition[2];
396
397 // Border representation. Subclasses may use the BWTransform class
398 // to transform their geometry into the region surrounded by the border.
409
410 // Constraints on size
411 double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
412 int MinimumSize[2] = { 1, 1 };
413 int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
414
415 // Properties of the border
416 double BorderColor[3] = { 1.0, 1.0, 1.0 };
417 float BorderThickness = 1.0;
418 double CornerRadiusStrength = 0.0;
419 int CornerResolution = 20;
420
421 // Properties of the inner polygon (ie. the background)
422 double PolygonColor[3] = { 1.0, 1.0, 1.0 };
423 double PolygonOpacity = 0.0;
424
429
438 vtkIdType xPt, vtkIdType yPt, const double startAngle);
439
440private:
442 void operator=(const vtkBorderRepresentation&) = delete;
443};
444
445#endif
a actor that draws 2D data
Definition: vtkActor2D.h:49
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:190
a simple class to control print indentation
Definition: vtkIndent.h:43
represent and manipulate 3D points
Definition: vtkPoints.h:43
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:95
an ordered list of Props
represent surface properties of a 2D image
Definition: vtkProperty2D.h:47
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:64
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:45
@ points
Definition: vtkX3D.h:452
@ startAngle
Definition: vtkX3D.h:492
@ radius
Definition: vtkX3D.h:258
@ size
Definition: vtkX3D.h:259
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