VTK  9.1.20211115
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
a actor that draws 2D data
Definition: vtkActor2D.h:149
represent a vtkBorderWidget
virtual void GetSize(double size[2])
Subclasses should implement these methods.
static vtkBorderRepresentation * New()
Instantiate this class.
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
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:290
a simple class to control print indentation
Definition: vtkIndent.h:113
represent and manipulate 3D points
Definition: vtkPoints.h:143
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:194
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
Definition: vtkTransform.h:164
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
@ 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