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 =========================================================================*/
98 #ifndef vtkBorderRepresentation_h
99 #define vtkBorderRepresentation_h
100 
101 #include "vtkCoordinate.h" //Because of the viewport coordinate macro
102 #include "vtkInteractionWidgetsModule.h" // For export macro
103 #include "vtkWidgetRepresentation.h"
104 
105 #include "vtkNew.h" // for ivars
106 
107 class vtkPoints;
108 class vtkPolyData;
109 class vtkTransform;
111 class vtkPolyDataMapper2D;
112 class vtkActor2D;
113 class vtkProperty2D;
114 class vtkCellArray;
115 
116 class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
117 {
118 public:
123 
125 
129  void PrintSelf(ostream& os, vtkIndent indent) override;
131 
133 
142  vtkViewportCoordinateMacro(Position);
143  vtkViewportCoordinateMacro(Position2);
145 
146  enum
147  {
148  BORDER_OFF = 0,
150  BORDER_ACTIVE
151  };
152 
154 
165  virtual void SetShowBorder(int border);
166  virtual int GetShowBorderMinValue();
167  virtual int GetShowBorderMaxValue();
168  virtual int GetShowBorder();
169  void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
170  void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
171  void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
173 
175 
179  vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
180  vtkGetMacro(ShowVerticalBorder, int);
182 
184 
188  vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
189  vtkGetMacro(ShowHorizontalBorder, int);
191 
193 
196  vtkGetObjectMacro(BorderProperty, vtkProperty2D);
198 
200 
210  vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
211  vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
212  vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
214 
216 
225  vtkSetMacro(ProportionalResize, vtkTypeBool);
226  vtkGetMacro(ProportionalResize, vtkTypeBool);
227  vtkBooleanMacro(ProportionalResize, vtkTypeBool);
229 
231 
238  vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
239  vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
241 
243 
250  vtkSetVector2Macro(MinimumSize, int);
251  vtkGetVector2Macro(MinimumSize, int);
252  vtkSetVector2Macro(MaximumSize, int);
253  vtkGetVector2Macro(MaximumSize, int);
255 
257 
264  vtkSetClampMacro(Tolerance, int, 1, 10);
265  vtkGetMacro(Tolerance, int);
267 
269 
273  vtkGetVectorMacro(SelectionPoint, double, 2);
275 
277 
282  vtkSetMacro(Moving, vtkTypeBool);
283  vtkGetMacro(Moving, vtkTypeBool);
284  vtkBooleanMacro(Moving, vtkTypeBool);
286 
291  {
292  Outside = 0,
301  AdjustingE3
302  };
303  vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
304 
309  vtkMTimeType GetMTime() override;
310 
312 
316  void BuildRepresentation() override;
317  void StartWidgetInteraction(double eventPos[2]) override;
318  void WidgetInteraction(double eventPos[2]) override;
319  virtual void GetSize(double size[2])
320  {
321  size[0] = 1.0;
322  size[1] = 1.0;
323  }
324  int ComputeInteractionState(int X, int Y, int modify = 0) override;
326 
328 
334  int RenderOverlay(vtkViewport*) override;
339 
341 
343 
347  vtkSetVector3Macro(BorderColor, double);
348  vtkGetVector3Macro(BorderColor, double);
350 
352 
356  vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
357  vtkGetMacro(BorderThickness, float);
359 
361 
369  vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
370  vtkGetMacro(CornerRadiusStrength, double);
372 
374 
379  vtkSetClampMacro(CornerResolution, int, 0, 1000);
380  vtkGetMacro(CornerResolution, int);
382 
384 
388  vtkSetVector3Macro(PolygonColor, double);
389  vtkGetVector3Macro(PolygonColor, double);
391 
393 
397  vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
398  vtkGetMacro(PolygonOpacity, double);
400 
402 
405  void SetPolygonRGBA(double rgba[4]);
406  void SetPolygonRGBA(double r, double g, double b, double a);
407 
411  void GetPolygonRGBA(double rgba[4]);
412  void GetPolygonRGBA(double& r, double& g, double& b, double& a);
414 
415 protected:
418 
419  // Ivars
420  int ShowVerticalBorder = BORDER_ON;
421  int ShowHorizontalBorder = BORDER_ON;
424  vtkTypeBool EnforceNormalizedViewportBounds = 0;
425  vtkTypeBool ProportionalResize = 0;
426  int Tolerance = 3;
427  vtkTypeBool Moving = 0;
428  double SelectionPoint[2] = { 0.0, 0.0 };
429 
430  // Layout (position of lower left and upper right corners of border)
433 
434  // Sometimes subclasses must negotiate with their superclasses
435  // to achieve the correct layout.
437  virtual void NegotiateLayout();
438 
439  // Update the border visibility based on InteractionState.
440  // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
441  // ComputeInteractionState()
442  virtual void UpdateShowBorder();
443 
444  // Keep track of start position when moving border
445  double StartPosition[2];
446 
447  // Border representation. Subclasses may use the BWTransform class
448  // to transform their geometry into the region surrounded by the border.
459 
460  // Constraints on size
461  double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
462  int MinimumSize[2] = { 1, 1 };
463  int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
464 
465  // Properties of the border
466  double BorderColor[3] = { 1.0, 1.0, 1.0 };
467  float BorderThickness = 1.0;
468  double CornerRadiusStrength = 0.0;
469  int CornerResolution = 20;
470 
471  // Properties of the inner polygon (ie. the background)
472  double PolygonColor[3] = { 1.0, 1.0, 1.0 };
473  double PolygonOpacity = 0.0;
474 
479 
488  vtkIdType xPt, vtkIdType yPt, const double startAngle);
489 
490 private:
492  void operator=(const vtkBorderRepresentation&) = delete;
493 };
494 
495 #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:195
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:36
@ 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