VTK  9.2.20230606
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 =========================================================================*/
101 #ifndef vtkBorderRepresentation_h
102 #define vtkBorderRepresentation_h
103 
104 #include "vtkCoordinate.h" //Because of the viewport coordinate macro
105 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
106 #include "vtkInteractionWidgetsModule.h" // For export macro
107 #include "vtkLegacy.h" // for VTK_LEGACY_REMOVE
108 #include "vtkWidgetRepresentation.h"
109 
110 #include "vtkNew.h" // for ivars
111 
112 VTK_ABI_NAMESPACE_BEGIN
113 class vtkPoints;
114 class vtkPolyData;
115 class vtkTransform;
117 class vtkPolyDataMapper2D;
118 class vtkActor2D;
119 class vtkProperty2D;
120 class vtkCellArray;
121 
122 class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
123 {
124 public:
129 
131 
135  void PrintSelf(ostream& os, vtkIndent indent) override;
137 
139 
148  vtkViewportCoordinateMacro(Position);
149  vtkViewportCoordinateMacro(Position2);
151 
152  enum
153  {
154  BORDER_OFF = 0,
156  BORDER_ACTIVE
157  };
158 
160 
171  virtual void SetShowBorder(int border);
172  virtual int GetShowBorderMinValue();
173  virtual int GetShowBorderMaxValue();
174  virtual int GetShowBorder();
175  void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
176  void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
177  void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
179 
181 
186  vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
187  vtkGetMacro(ShowVerticalBorder, int);
189 
191 
196  vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
197  vtkGetMacro(ShowHorizontalBorder, int);
199 
201 
204  vtkGetObjectMacro(BorderProperty, vtkProperty2D);
206 
208 
213  virtual void SetShowPolygon(int border);
214  virtual int GetShowPolygon();
215  void SetShowPolygonToOff() { this->SetShowPolygon(BORDER_OFF); }
216  void SetShowPolygonToOn() { this->SetShowPolygon(BORDER_ON); }
217  void SetShowPolygonToActive() { this->SetShowPolygon(BORDER_ACTIVE); }
219 
221 
226  vtkSetClampMacro(ShowPolygonBackground, int, BORDER_OFF, BORDER_ACTIVE);
227  vtkGetMacro(ShowPolygonBackground, int);
229 
231 
241  vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
242  vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
243  vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
245 
247 
256  vtkSetMacro(ProportionalResize, vtkTypeBool);
257  vtkGetMacro(ProportionalResize, vtkTypeBool);
258  vtkBooleanMacro(ProportionalResize, vtkTypeBool);
260 
262 
269  vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
270  vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
272 
274 
281  vtkSetVector2Macro(MinimumSize, int);
282  vtkGetVector2Macro(MinimumSize, int);
283  vtkSetVector2Macro(MaximumSize, int);
284  vtkGetVector2Macro(MaximumSize, int);
286 
288 
295  vtkSetClampMacro(Tolerance, int, 1, 10);
296  vtkGetMacro(Tolerance, int);
298 
300 
304  vtkGetVectorMacro(SelectionPoint, double, 2);
306 
308 
313  vtkSetMacro(Moving, vtkTypeBool);
314  vtkGetMacro(Moving, vtkTypeBool);
315  vtkBooleanMacro(Moving, vtkTypeBool);
317 
318  enum
319  {
320  AnyLocation = 0,
326  UpperCenter
327  };
328 
330 
341  virtual void SetWindowLocation(int enumLocation);
342  vtkGetMacro(WindowLocation, int);
344 
351  virtual void UpdateWindowLocation();
352 
357  {
358  Outside = 0,
367  AdjustingE3
368  };
369 #if !defined(VTK_LEGACY_REMOVE)
370  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
372 #endif
373 
374  vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
375 
380  vtkMTimeType GetMTime() override;
381 
383 
387  void BuildRepresentation() override;
388  void StartWidgetInteraction(double eventPos[2]) override;
389  void WidgetInteraction(double eventPos[2]) override;
390  virtual void GetSize(double size[2])
391  {
392  size[0] = 1.0;
393  size[1] = 1.0;
394  }
395  int ComputeInteractionState(int X, int Y, int modify = 0) override;
397 
399 
405  int RenderOverlay(vtkViewport*) override;
410 
412  "SetBWActorDisplayOverlay is deprecated. Use "
413  "SetBWActorDisplayOverlayEdges or SetBWActorDisplayOverlayPolygon instead.")
414  void SetBWActorDisplayOverlay(bool);
415 
416  void SetBWActorDisplayOverlayEdges(bool);
417  void SetBWActorDisplayOverlayPolygon(bool);
418 
420 
424  vtkSetVector3Macro(BorderColor, double);
425  vtkGetVector3Macro(BorderColor, double);
427 
429 
433  vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
434  vtkGetMacro(BorderThickness, float);
436 
438 
446  vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
447  vtkGetMacro(CornerRadiusStrength, double);
449 
451 
456  vtkSetClampMacro(CornerResolution, int, 0, 1000);
457  vtkGetMacro(CornerResolution, int);
459 
461 
465  vtkSetVector3Macro(PolygonColor, double);
466  vtkGetVector3Macro(PolygonColor, double);
468 
470 
474  vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
475  vtkGetMacro(PolygonOpacity, double);
477 
479 
482  void SetPolygonRGBA(double rgba[4]);
483  void SetPolygonRGBA(double r, double g, double b, double a);
484 
488  void GetPolygonRGBA(double rgba[4]);
489  void GetPolygonRGBA(double& r, double& g, double& b, double& a);
491 
492 protected:
495 
496  // Ivars
497  int ShowVerticalBorder = BORDER_ON;
498  int ShowHorizontalBorder = BORDER_ON;
499  int ShowPolygonBackground = BORDER_ON;
500  vtkNew<vtkProperty2D> BorderProperty;
501  vtkNew<vtkProperty2D> PolygonProperty;
502  vtkTypeBool EnforceNormalizedViewportBounds = 0;
503  vtkTypeBool ProportionalResize = 0;
504  int Tolerance = 3;
505  vtkTypeBool Moving = 0;
506  double SelectionPoint[2] = { 0.0, 0.0 };
507 
508  // Layout (position of lower left and upper right corners of border)
511 
512  // Window location by enumeration
513  int WindowLocation = AnyLocation;
514 
515  // Sometimes subclasses must negotiate with their superclasses
516  // to achieve the correct layout.
518  virtual void NegotiateLayout();
519 
520  // Update the border visibility based on InteractionState.
521  // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
522  // ComputeInteractionState()
523  virtual void UpdateShowBorder();
524 
525  // Keep track of start position when moving border
526  double StartPosition[2];
527 
528  // Border representation. Subclasses may use the BWTransform class
529  // to transform their geometry into the region surrounded by the border.
540 
541  // Constraints on size
542  double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
543  int MinimumSize[2] = { 1, 1 };
544  int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
545 
546  // Properties of the border
547  double BorderColor[3] = { 1.0, 1.0, 1.0 };
548  float BorderThickness = 1.0;
549  double CornerRadiusStrength = 0.0;
550  int CornerResolution = 20;
551 
552  // Properties of the inner polygon (ie. the background)
553  double PolygonColor[3] = { 1.0, 1.0, 1.0 };
554  double PolygonOpacity = 0.0;
555 
560 
569  vtkIdType yPt, double startAngle);
570 
571 private:
573  void operator=(const vtkBorderRepresentation&) = delete;
574 };
575 
576 VTK_ABI_NAMESPACE_END
577 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:156
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 ...
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.
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,...
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< 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.
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
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:297
a simple class to control print indentation
Definition: vtkIndent.h:120
Allocate and hold a VTK object.
Definition: vtkNew.h:172
represent and manipulate 3D points
Definition: vtkPoints.h:150
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:201
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:171
abstract specification for Viewports
Definition: vtkViewport.h:57
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:40
@ points
Definition: vtkX3D.h:458
@ startAngle
Definition: vtkX3D.h:498
@ radius
Definition: vtkX3D.h:264
@ size
Definition: vtkX3D.h:265
int vtkTypeBool
Definition: vtkABI.h:71
#define VTK_DEPRECATED_IN_9_2_0(reason)
int vtkIdType
Definition: vtkType.h:327
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:282
#define VTK_INT_MAX
Definition: vtkType.h:156
#define VTK_FLOAT_MAX
Definition: vtkType.h:164