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 =========================================================================*/
88 #ifndef vtkBorderRepresentation_h
89 #define vtkBorderRepresentation_h
90 
91 #include "vtkCoordinate.h" //Because of the viewport coordinate macro
92 #include "vtkInteractionWidgetsModule.h" // For export macro
94 
95 #include "vtkNew.h" // for ivars
96 
97 class vtkPoints;
98 class vtkPolyData;
99 class vtkTransform;
101 class vtkPolyDataMapper2D;
102 class vtkActor2D;
103 class vtkProperty2D;
104 class vtkCellArray;
105 
106 class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
107 {
108 public:
113 
115 
119  void PrintSelf(ostream& os, vtkIndent indent) override;
121 
123 
132  vtkViewportCoordinateMacro(Position);
133  vtkViewportCoordinateMacro(Position2);
135 
136  enum
137  {
138  BORDER_OFF = 0,
140  BORDER_ACTIVE
141  };
142 
144 
155  virtual void SetShowBorder(int border);
156  virtual int GetShowBorderMinValue();
157  virtual int GetShowBorderMaxValue();
158  virtual int GetShowBorder();
159  void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
160  void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
161  void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
163 
165 
169  vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
170  vtkGetMacro(ShowVerticalBorder, int);
172 
174 
178  vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
179  vtkGetMacro(ShowHorizontalBorder, int);
181 
183 
186  vtkGetObjectMacro(BorderProperty, vtkProperty2D);
188 
190 
200  vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
201  vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
202  vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
204 
206 
215  vtkSetMacro(ProportionalResize, vtkTypeBool);
216  vtkGetMacro(ProportionalResize, vtkTypeBool);
217  vtkBooleanMacro(ProportionalResize, vtkTypeBool);
219 
221 
228  vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
229  vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
231 
233 
240  vtkSetVector2Macro(MinimumSize, int);
241  vtkGetVector2Macro(MinimumSize, int);
242  vtkSetVector2Macro(MaximumSize, int);
243  vtkGetVector2Macro(MaximumSize, int);
245 
247 
254  vtkSetClampMacro(Tolerance, int, 1, 10);
255  vtkGetMacro(Tolerance, int);
257 
259 
263  vtkGetVectorMacro(SelectionPoint, double, 2);
265 
267 
272  vtkSetMacro(Moving, vtkTypeBool);
273  vtkGetMacro(Moving, vtkTypeBool);
274  vtkBooleanMacro(Moving, vtkTypeBool);
276 
281  {
282  Outside = 0,
291  AdjustingE3
292  };
293  vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
294 
299  vtkMTimeType GetMTime() override;
300 
302 
306  void BuildRepresentation() override;
307  void StartWidgetInteraction(double eventPos[2]) override;
308  void WidgetInteraction(double eventPos[2]) override;
309  virtual void GetSize(double size[2])
310  {
311  size[0] = 1.0;
312  size[1] = 1.0;
313  }
314  int ComputeInteractionState(int X, int Y, int modify = 0) override;
316 
318 
324  int RenderOverlay(vtkViewport*) override;
329 
331 
333 
337  vtkSetVector3Macro(BorderColor, double);
338  vtkGetVector3Macro(BorderColor, double);
340 
342 
346  vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
347  vtkGetMacro(BorderThickness, float);
349 
351 
359  vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
360  vtkGetMacro(CornerRadiusStrength, double);
362 
364 
369  vtkSetClampMacro(CornerResolution, int, 0, 1000);
370  vtkGetMacro(CornerResolution, int);
372 
374 
378  vtkSetVector3Macro(PolygonColor, double);
379  vtkGetVector3Macro(PolygonColor, double);
381 
383 
387  vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
388  vtkGetMacro(PolygonOpacity, double);
390 
392 
395  void SetPolygonRGBA(double rgba[4]);
396  void SetPolygonRGBA(double r, double g, double b, double a);
397 
401  void GetPolygonRGBA(double rgba[4]);
402  void GetPolygonRGBA(double& r, double& g, double& b, double& a);
404 
405 protected:
408 
409  // Ivars
410  int ShowVerticalBorder = BORDER_ON;
411  int ShowHorizontalBorder = BORDER_ON;
414  vtkTypeBool EnforceNormalizedViewportBounds = 0;
415  vtkTypeBool ProportionalResize = 0;
416  int Tolerance = 3;
417  vtkTypeBool Moving = 0;
418  double SelectionPoint[2] = { 0.0, 0.0 };
419 
420  // Layout (position of lower left and upper right corners of border)
423 
424  // Sometimes subclasses must negotiate with their superclasses
425  // to achieve the correct layout.
427  virtual void NegotiateLayout();
428 
429  // Update the border visibility based on InteractionState.
430  // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
431  // ComputeInteractionState()
432  virtual void UpdateShowBorder();
433 
434  // Keep track of start position when moving border
435  double StartPosition[2];
436 
437  // Border representation. Subclasses may use the BWTransform class
438  // to transform their geometry into the region surrounded by the border.
449 
450  // Constraints on size
451  double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
452  int MinimumSize[2] = { 1, 1 };
453  int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
454 
455  // Properties of the border
456  double BorderColor[3] = { 1.0, 1.0, 1.0 };
457  float BorderThickness = 1.0;
458  double CornerRadiusStrength = 0.0;
459  int CornerResolution = 20;
460 
461  // Properties of the inner polygon (ie. the background)
462  double PolygonColor[3] = { 1.0, 1.0, 1.0 };
463  double PolygonOpacity = 0.0;
464 
469 
478  vtkIdType xPt, vtkIdType yPt, const double startAngle);
479 
480 private:
482  void operator=(const vtkBorderRepresentation&) = delete;
483 };
484 
485 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkWidgetRepresentation.h
vtkBorderRepresentation::Inside
@ Inside
Definition: vtkBorderRepresentation.h:283
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:155
vtkBorderRepresentation::BWTransform
vtkNew< vtkTransform > BWTransform
Definition: vtkBorderRepresentation.h:443
vtkPolyDataMapper2D
draw vtkPolyData onto the image plane
Definition: vtkPolyDataMapper2D.h:154
vtkBorderRepresentation::PositionCoordinate
vtkNew< vtkCoordinate > PositionCoordinate
Definition: vtkBorderRepresentation.h:421
vtkBorderRepresentation::AdjustingP3
@ AdjustingP3
Definition: vtkBorderRepresentation.h:287
vtkBorderRepresentation::Position2Coordinate
vtkNew< vtkCoordinate > Position2Coordinate
Definition: vtkBorderRepresentation.h:422
vtkBorderRepresentation
represent a vtkBorderWidget
Definition: vtkBorderRepresentation.h:107
vtkBorderRepresentation::PolyDataPolygon
vtkNew< vtkPolyData > PolyDataPolygon
Definition: vtkBorderRepresentation.h:442
vtkBorderRepresentation::SetShowBorder
virtual void SetShowBorder(int border)
Specify when and if the border should appear.
vtkBorderRepresentation::UpdateShowBorder
virtual void UpdateShowBorder()
vtkBorderRepresentation::WidgetInteraction
void WidgetInteraction(double eventPos[2]) override
Subclasses should implement these methods.
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkBorderRepresentation::BWPolyData
vtkNew< vtkPolyData > BWPolyData
Definition: vtkBorderRepresentation.h:440
vtkBorderRepresentation::RenderOpaqueGeometry
int RenderOpaqueGeometry(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
vtkBorderRepresentation::New
static vtkBorderRepresentation * New()
Instantiate this class.
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:60
vtkBorderRepresentation::BWMapperPolygon
vtkNew< vtkPolyDataMapper2D > BWMapperPolygon
Definition: vtkBorderRepresentation.h:446
vtkBorderRepresentation::SetPolygonRGBA
void SetPolygonRGBA(double rgba[4])
Convenience method to set the background color and the opacity at once.
vtkBorderRepresentation::BORDER_ON
@ BORDER_ON
Definition: vtkBorderRepresentation.h:139
vtkBorderRepresentation::PolyDataEdges
vtkNew< vtkPolyData > PolyDataEdges
Definition: vtkBorderRepresentation.h:441
vtkBorderRepresentation::AdjustingP2
@ AdjustingP2
Definition: vtkBorderRepresentation.h:286
vtkBorderRepresentation::AdjustingP1
@ AdjustingP1
Definition: vtkBorderRepresentation.h:285
vtkBorderRepresentation::SetShowBorderToOff
void SetShowBorderToOff()
Specify when and if the border should appear.
Definition: vtkBorderRepresentation.h:159
vtkBorderRepresentation::GetShowBorderMaxValue
virtual int GetShowBorderMaxValue()
Specify when and if the border should appear.
vtkBorderRepresentation::BWMapperEdges
vtkNew< vtkPolyDataMapper2D > BWMapperEdges
Definition: vtkBorderRepresentation.h:445
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
vtkBorderRepresentation::SetBWActorDisplayOverlay
void SetBWActorDisplayOverlay(bool)
vtkBorderRepresentation::BuildRepresentation
void BuildRepresentation() override
Subclasses should implement these methods.
vtkBorderRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Define standard methods.
vtkBorderRepresentation::SetShowBorderToActive
void SetShowBorderToActive()
Specify when and if the border should appear.
Definition: vtkBorderRepresentation.h:161
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
vtkBorderRepresentation::ComputeInteractionState
int ComputeInteractionState(int X, int Y, int modify=0) override
Subclasses should implement these methods.
vtkBorderRepresentation::vtkBorderRepresentation
vtkBorderRepresentation()
vtkBorderRepresentation::GetActors2D
void GetActors2D(vtkPropCollection *) override
These methods are necessary to make this representation behave as a vtkProp.
vtkX3D::points
@ points
Definition: vtkX3D.h:452
vtkBorderRepresentation::SetShowBorderToOn
void SetShowBorderToOn()
Specify when and if the border should appear.
Definition: vtkBorderRepresentation.h:160
vtkBorderRepresentation::ComputeRoundCorners
void ComputeRoundCorners()
Create all 4 round corners with the specified radius and resolution.
vtkBorderRepresentation::BWTransformFilter
vtkNew< vtkTransformPolyDataFilter > BWTransformFilter
Definition: vtkBorderRepresentation.h:444
vtkBorderRepresentation::NegotiateLayout
virtual void NegotiateLayout()
vtkBorderRepresentation::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
These methods are necessary to make this representation behave as a vtkProp.
vtkBorderRepresentation::PolygonProperty
vtkNew< vtkProperty2D > PolygonProperty
Definition: vtkBorderRepresentation.h:413
vtkBorderRepresentation::SetPolygonRGBA
void SetPolygonRGBA(double r, double g, double b, double a)
Convenience method to set the background color and the opacity at once.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:290
vtkBorderRepresentation::BWActorPolygon
vtkNew< vtkActor2D > BWActorPolygon
Definition: vtkBorderRepresentation.h:448
vtkBorderRepresentation::GetSize
virtual void GetSize(double size[2])
Subclasses should implement these methods.
Definition: vtkBorderRepresentation.h:309
vtkBorderRepresentation::GetShowBorderMinValue
virtual int GetShowBorderMinValue()
Specify when and if the border should appear.
vtkBorderRepresentation::GetPolygonRGBA
void GetPolygonRGBA(double &r, double &g, double &b, double &a)
Convenience method to set the background color and the opacity at once.
vtkBorderRepresentation::AdjustingE1
@ AdjustingE1
Definition: vtkBorderRepresentation.h:289
vtkBorderRepresentation::GetShowBorder
virtual int GetShowBorder()
Specify when and if the border should appear.
vtkBorderRepresentation::RenderTranslucentPolygonalGeometry
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
vtkBorderRepresentation::GetPolygonRGBA
void GetPolygonRGBA(double rgba[4])
Convenience method to get the background color and the opacity at once.
vtkBorderRepresentation::ComputeOneRoundCorner
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 ...
vtkX3D::size
@ size
Definition: vtkX3D.h:259
vtkNew< vtkProperty2D >
VTK_FLOAT_MAX
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
vtkX3D::startAngle
@ startAngle
Definition: vtkX3D.h:492
vtkTransformPolyDataFilter
transform points and associated normals and vectors for polygonal dataset
Definition: vtkTransformPolyDataFilter.h:155
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkBorderRepresentation::AdjustingE2
@ AdjustingE2
Definition: vtkBorderRepresentation.h:290
vtkCoordinate.h
vtkBorderRepresentation::BWActorEdges
vtkNew< vtkActor2D > BWActorEdges
Definition: vtkBorderRepresentation.h:447
vtkProperty2D
represent surface properties of a 2D image
Definition: vtkProperty2D.h:147
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:149
vtkParticleTracerBaseNamespace::Position
struct Position_t Position
Definition: vtkParticleTracerBase.h:63
vtkBorderRepresentation::_InteractionState
_InteractionState
Define the various states that the representation can be in.
Definition: vtkBorderRepresentation.h:281
vtkNew.h
vtkBorderRepresentation::BWPoints
vtkNew< vtkPoints > BWPoints
Definition: vtkBorderRepresentation.h:439
vtkBorderRepresentation::AdjustingE0
@ AdjustingE0
Definition: vtkBorderRepresentation.h:288
vtkBorderRepresentation::GetMTime
vtkMTimeType GetMTime() override
Return the MTime of this object.
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
vtkBorderRepresentation::StartWidgetInteraction
void StartWidgetInteraction(double eventPos[2]) override
Subclasses should implement these methods.
vtkBorderRepresentation::Negotiated
int Negotiated
Definition: vtkBorderRepresentation.h:426
vtkBorderRepresentation::BorderProperty
vtkNew< vtkProperty2D > BorderProperty
Definition: vtkBorderRepresentation.h:412
vtkBorderRepresentation::RenderOverlay
int RenderOverlay(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
vtkBorderRepresentation::~vtkBorderRepresentation
~vtkBorderRepresentation() override
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:85
vtkX3D::radius
@ radius
Definition: vtkX3D.h:258
vtkBorderRepresentation::AdjustingP0
@ AdjustingP0
Definition: vtkBorderRepresentation.h:284
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkBorderRepresentation::HasTranslucentPolygonalGeometry
vtkTypeBool HasTranslucentPolygonalGeometry() override
These methods are necessary to make this representation behave as a vtkProp.
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287