VTK  9.3.20240229
vtkBorderRepresentation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
89 #ifndef vtkBorderRepresentation_h
90 #define vtkBorderRepresentation_h
91 
92 #include "vtkCoordinate.h" //Because of the viewport coordinate macro
93 #include "vtkInteractionWidgetsModule.h" // For export macro
95 
96 #include "vtkNew.h" // for ivars
97 
98 VTK_ABI_NAMESPACE_BEGIN
99 class vtkPoints;
100 class vtkPolyData;
101 class vtkTransform;
103 class vtkPolyDataMapper2D;
104 class vtkActor2D;
105 class vtkProperty2D;
106 class vtkCellArray;
107 
108 class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
109 {
110 public:
115 
117 
121  void PrintSelf(ostream& os, vtkIndent indent) override;
123 
125 
134  vtkViewportCoordinateMacro(Position);
135  vtkViewportCoordinateMacro(Position2);
137 
138  enum
139  {
140  BORDER_OFF = 0,
142  BORDER_ACTIVE
143  };
144 
146 
157  virtual void SetShowBorder(int border);
158  virtual int GetShowBorderMinValue();
159  virtual int GetShowBorderMaxValue();
160  virtual int GetShowBorder();
161  void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
162  void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
163  void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
165 
167 
172  vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
173  vtkGetMacro(ShowVerticalBorder, int);
175 
177 
182  vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
183  vtkGetMacro(ShowHorizontalBorder, int);
185 
187 
190  vtkGetObjectMacro(BorderProperty, vtkProperty2D);
192 
194 
199  virtual void SetShowPolygon(int border);
200  virtual int GetShowPolygon();
201  void SetShowPolygonToOff() { this->SetShowPolygon(BORDER_OFF); }
202  void SetShowPolygonToOn() { this->SetShowPolygon(BORDER_ON); }
203  void SetShowPolygonToActive() { this->SetShowPolygon(BORDER_ACTIVE); }
205 
207 
212  vtkSetClampMacro(ShowPolygonBackground, int, BORDER_OFF, BORDER_ACTIVE);
213  vtkGetMacro(ShowPolygonBackground, int);
215 
217 
225  vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
226  vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
227  vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
229 
231 
240  vtkSetMacro(ProportionalResize, vtkTypeBool);
241  vtkGetMacro(ProportionalResize, vtkTypeBool);
242  vtkBooleanMacro(ProportionalResize, vtkTypeBool);
244 
246 
253  vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
254  vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
256 
258 
265  vtkSetVector2Macro(MinimumSize, int);
266  vtkGetVector2Macro(MinimumSize, int);
267  vtkSetVector2Macro(MaximumSize, int);
268  vtkGetVector2Macro(MaximumSize, int);
270 
272 
279  vtkSetClampMacro(Tolerance, int, 1, 10);
280  vtkGetMacro(Tolerance, int);
282 
284 
288  vtkGetVectorMacro(SelectionPoint, double, 2);
290 
292 
297  vtkSetMacro(Moving, vtkTypeBool);
298  vtkGetMacro(Moving, vtkTypeBool);
299  vtkBooleanMacro(Moving, vtkTypeBool);
301 
302  enum
303  {
304  AnyLocation = 0,
310  UpperCenter
311  };
312 
314 
325  virtual void SetWindowLocation(int enumLocation);
326  vtkGetMacro(WindowLocation, int);
328 
335  virtual void UpdateWindowLocation();
336 
341  {
342  Outside = 0,
351  AdjustingE3
352  };
353 
354  vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
355 
360  vtkMTimeType GetMTime() override;
361 
363 
367  void BuildRepresentation() override;
368  void StartWidgetInteraction(double eventPos[2]) override;
369  void WidgetInteraction(double eventPos[2]) override;
370  virtual void GetSize(double size[2])
371  {
372  size[0] = 1.0;
373  size[1] = 1.0;
374  }
375  int ComputeInteractionState(int X, int Y, int modify = 0) override;
377 
379 
385  int RenderOverlay(vtkViewport*) override;
390 
393 
395 
399  vtkSetVector3Macro(BorderColor, double);
400  vtkGetVector3Macro(BorderColor, double);
402 
404 
408  vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
409  vtkGetMacro(BorderThickness, float);
411 
413 
421  vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
422  vtkGetMacro(CornerRadiusStrength, double);
424 
426 
431  vtkSetClampMacro(CornerResolution, int, 0, 1000);
432  vtkGetMacro(CornerResolution, int);
434 
436 
440  vtkSetVector3Macro(PolygonColor, double);
441  vtkGetVector3Macro(PolygonColor, double);
443 
445 
449  vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
450  vtkGetMacro(PolygonOpacity, double);
452 
454 
457  void SetPolygonRGBA(double rgba[4]);
458  void SetPolygonRGBA(double r, double g, double b, double a);
459 
463  void GetPolygonRGBA(double rgba[4]);
464  void GetPolygonRGBA(double& r, double& g, double& b, double& a);
466 
467 protected:
470 
471  // Ivars
472  int ShowVerticalBorder = BORDER_ON;
473  int ShowHorizontalBorder = BORDER_ON;
474  int ShowPolygonBackground = BORDER_ON;
477  vtkTypeBool EnforceNormalizedViewportBounds = 0;
478  vtkTypeBool ProportionalResize = 0;
479  int Tolerance = 3;
480  vtkTypeBool Moving = 0;
481  double SelectionPoint[2] = { 0.0, 0.0 };
482 
483  // Layout (position of lower left and upper right corners of border)
486 
487  // Window location by enumeration
488  int WindowLocation = AnyLocation;
489 
490  // Sometimes subclasses must negotiate with their superclasses
491  // to achieve the correct layout.
493  virtual void NegotiateLayout();
494 
495  // Update the border visibility based on InteractionState.
496  // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
497  // ComputeInteractionState()
498  virtual void UpdateShowBorder();
499 
500  // Keep track of start position when moving border
501  double StartPosition[2];
502 
503  // Border representation. Subclasses may use the BWTransform class
504  // to transform their geometry into the region surrounded by the border.
515 
516  // Constraints on size
517  double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
518  int MinimumSize[2] = { 1, 1 };
519  int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
520 
521  // Properties of the border
522  double BorderColor[3] = { 1.0, 1.0, 1.0 };
523  float BorderThickness = 1.0;
524  double CornerRadiusStrength = 0.0;
525  int CornerResolution = 20;
526 
527  // Properties of the inner polygon (ie. the background)
528  double PolygonColor[3] = { 1.0, 1.0, 1.0 };
529  double PolygonOpacity = 0.0;
530 
535 
544  vtkIdType yPt, double startAngle);
545 
546 private:
548  void operator=(const vtkBorderRepresentation&) = delete;
549 };
550 
551 VTK_ABI_NAMESPACE_END
552 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:144
represent a vtkBorderWidget
virtual void GetSize(double size[2])
Subclasses should implement these methods.
static vtkBorderRepresentation * New()
Instantiate this class.
void ComputeOneRoundCorner(vtkCellArray *polys, vtkPoints *points, double radius, vtkIdType xPt, vtkIdType yPt, double startAngle)
Create a quarter circle centered in point[idCenterX].x, point[idCenterY].y), of radius 'radius' with ...
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 SetShowPolygonToOn()
Specify when and if the border's polygon background should appear.
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.
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 SetShowPolygonToOff()
Specify when and if the border's polygon background should appear.
virtual void SetWindowLocation(int enumLocation)
Set the representation position, by enumeration ( AnyLocation = 0, LowerLeftCorner,...
void SetBWActorDisplayOverlayPolygon(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.
InteractionStateType
Define the various states that the representation can be in.
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 GetShowPolygon()
Specify when and if the border's polygon background should appear.
virtual int GetShowBorderMaxValue()
Specify when and if the border should appear.
void PrintSelf(ostream &os, vtkIndent indent) override
Define standard methods.
virtual void UpdateWindowLocation()
Update window location if a window location is set.
void SetShowPolygonToActive()
Specify when and if the border's polygon background should appear.
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 SetBWActorDisplayOverlayEdges(bool)
virtual void SetShowPolygon(int border)
Specify when and if the border's polygon background should appear.
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:285
a simple class to control print indentation
Definition: vtkIndent.h:108
represent and manipulate 3D points
Definition: vtkPoints.h:138
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:180
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:159
abstract specification for Viewports
Definition: vtkViewport.h:64
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:47
@ points
Definition: vtkX3D.h:446
@ startAngle
Definition: vtkX3D.h:486
@ radius
Definition: vtkX3D.h:252
@ size
Definition: vtkX3D.h:253
int vtkTypeBool
Definition: vtkABI.h:64
int vtkIdType
Definition: vtkType.h:315
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
#define VTK_INT_MAX
Definition: vtkType.h:144
#define VTK_FLOAT_MAX
Definition: vtkType.h:152