VTK  9.7.1
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
30 #ifndef vtkBorderRepresentation_h
31 #define vtkBorderRepresentation_h
32 
33 #include "vtkCoordinate.h" //Because of the viewport coordinate macro
34 #include "vtkInteractionWidgetsModule.h" // For export macro
36 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
37 
38 #include "vtkNew.h" // for ivars
39 
40 VTK_ABI_NAMESPACE_BEGIN
41 class vtkPoints;
42 class vtkPolyData;
43 class vtkTransform;
44 class vtkTransformFilter;
46 class vtkActor2D;
47 class vtkProperty2D;
48 class vtkCellArray;
49 
50 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkBorderRepresentation
52 {
53 public:
57  static vtkBorderRepresentation* New();
58 
60 
64  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
68 
77  vtkViewportCoordinateMacro(Position);
78  vtkViewportCoordinateMacro(Position2);
80 
81  enum
82  {
83  BORDER_OFF = 0,
85  BORDER_ACTIVE
86  };
87 
89 
100  virtual void SetShowBorder(int border);
101  virtual int GetShowBorderMinValue();
102  virtual int GetShowBorderMaxValue();
103  virtual int GetShowBorder();
104  void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
105  void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
106  void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
108 
110 
115  vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
116  vtkGetMacro(ShowVerticalBorder, int);
118 
120 
125  vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
126  vtkGetMacro(ShowHorizontalBorder, int);
128 
130 
133  vtkGetObjectMacro(BorderProperty, vtkProperty2D);
135 
137 
142  virtual void SetShowPolygon(int border);
143  virtual int GetShowPolygon();
144  void SetShowPolygonToOff() { this->SetShowPolygon(BORDER_OFF); }
145  void SetShowPolygonToOn() { this->SetShowPolygon(BORDER_ON); }
146  void SetShowPolygonToActive() { this->SetShowPolygon(BORDER_ACTIVE); }
148 
150 
155  vtkSetClampMacro(ShowPolygonBackground, int, BORDER_OFF, BORDER_ACTIVE);
156  vtkGetMacro(ShowPolygonBackground, int);
158 
160 
168  vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
169  vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
170  vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
172 
174 
183  vtkSetMacro(ProportionalResize, vtkTypeBool);
184  vtkGetMacro(ProportionalResize, vtkTypeBool);
185  vtkBooleanMacro(ProportionalResize, vtkTypeBool);
187 
189 
196  vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
197  vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
199 
201 
208  vtkSetVector2Macro(MinimumSize, int);
209  vtkGetVector2Macro(MinimumSize, int);
210  vtkSetVector2Macro(MaximumSize, int);
211  vtkGetVector2Macro(MaximumSize, int);
213 
215 
222  vtkSetClampMacro(Tolerance, int, 1, 10);
223  vtkGetMacro(Tolerance, int);
225 
227 
231  vtkGetVectorMacro(SelectionPoint, double, 2);
233 
235 
240  vtkSetMacro(Moving, vtkTypeBool);
241  vtkGetMacro(Moving, vtkTypeBool);
242  vtkBooleanMacro(Moving, vtkTypeBool);
244 
245  enum
246  {
247  AnyLocation = 0,
253  UpperCenter
254  };
255 
257 
268  virtual void SetWindowLocation(int enumLocation);
269  vtkGetMacro(WindowLocation, int);
271 
278  virtual void UpdateWindowLocation();
279 
284  {
285  Outside = 0,
294  AdjustingE3
295  };
296 
297  vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
298 
303  vtkMTimeType GetMTime() override;
304 
306 
310  void BuildRepresentation() override;
311  void StartWidgetInteraction(double eventPos[2]) override;
312  void WidgetInteraction(double eventPos[2]) override;
313  virtual void GetSize(double size[2])
314  {
315  size[0] = 1.0;
316  size[1] = 1.0;
317  }
318  int ComputeInteractionState(int X, int Y, int modify = 0) override;
320 
322 
326  void GetActors2D(vtkPropCollection*) override;
327  void ReleaseGraphicsResources(vtkWindow*) override;
328  int RenderOverlay(vtkViewport*) override;
329  int RenderOpaqueGeometry(vtkViewport*) override;
333 
334  void SetBWActorDisplayOverlayEdges(bool);
335  void SetBWActorDisplayOverlayPolygon(bool);
336 
338 
342  vtkSetVector3Macro(BorderColor, double);
343  vtkGetVector3Macro(BorderColor, double);
345 
347 
351  vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
352  vtkGetMacro(BorderThickness, float);
354 
356 
364  vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
365  vtkGetMacro(CornerRadiusStrength, double);
367 
369 
374  vtkSetClampMacro(CornerResolution, int, 0, 1000);
375  vtkGetMacro(CornerResolution, int);
377 
379 
383  vtkSetVector3Macro(PolygonColor, double);
384  vtkGetVector3Macro(PolygonColor, double);
386 
388 
392  vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
393  vtkGetMacro(PolygonOpacity, double);
395 
397 
400  void SetPolygonRGBA(double rgba[4]);
401  void SetPolygonRGBA(double r, double g, double b, double a);
402 
406  void GetPolygonRGBA(double rgba[4]);
407  void GetPolygonRGBA(double& r, double& g, double& b, double& a);
409 
410 protected:
412  ~vtkBorderRepresentation() override;
413 
414  // Ivars
415  int ShowVerticalBorder = BORDER_ON;
416  int ShowHorizontalBorder = BORDER_ON;
417  int ShowPolygonBackground = BORDER_ON;
420  vtkTypeBool EnforceNormalizedViewportBounds = 0;
421  vtkTypeBool ProportionalResize = 0;
422  int Tolerance = 3;
423  vtkTypeBool Moving = 0;
424  double SelectionPoint[2] = { 0.0, 0.0 };
425 
426  // Layout (position of lower left and upper right corners of border)
429 
430  // Window location by enumeration
431  int WindowLocation = AnyLocation;
432 
433  // Sometimes subclasses must negotiate with their superclasses
434  // to achieve the correct layout.
436  virtual void NegotiateLayout();
437 
438  // Update the border visibility based on InteractionState.
439  // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
440  // ComputeInteractionState()
441  virtual void UpdateShowBorder();
442 
443  // Keep track of start position when moving border
444  double StartPosition[2];
445 
446  // Border representation. Subclasses may use the BWTransform class
447  // to transform their geometry into the region surrounded by the border.
458 
459  // Constraints on size
460  double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
461  int MinimumSize[2] = { 1, 1 };
462  int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
463 
464  // Properties of the border
465  double BorderColor[3] = { 1.0, 1.0, 1.0 };
466  float BorderThickness = 1.0;
467  double CornerRadiusStrength = 0.0;
468  int CornerResolution = 20;
469 
470  // Properties of the inner polygon (ie. the background)
471  double PolygonColor[3] = { 1.0, 1.0, 1.0 };
472  double PolygonOpacity = 0.0;
473 
477  void ComputeRoundCorners();
478 
486  void ComputeOneRoundCorner(vtkCellArray* polys, vtkPoints* points, double radius, vtkIdType xPt,
487  vtkIdType yPt, double startAngle);
488 
489 private:
491  void operator=(const vtkBorderRepresentation&) = delete;
492 };
493 
494 VTK_ABI_NAMESPACE_END
495 #endif
vtkNew< vtkPolyData > BWPolyData
vtkNew< vtkTransformFilter > BWTransformFilter
vtkNew< vtkCoordinate > Position2Coordinate
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
void SetShowPolygonToOn()
Specify when and if the border's polygon background should appear.
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkNew< vtkCoordinate > PositionCoordinate
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
abstract specification for Viewports
Definition: vtkViewport.h:46
void GetActors2D(vtkPropCollection *) override
virtual void StartWidgetInteraction(double eventPos[2])
#define VTK_INT_MAX
Definition: vtkType.h:192
a actor that draws 2D data
Definition: vtkActor2D.h:35
void SetShowBorderToOff()
Specify when and if the border should appear.
vtkNew< vtkPolyDataMapper2D > BWMapperEdges
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
int RenderOpaqueGeometry(vtkViewport *viewport) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
vtkNew< vtkPolyDataMapper2D > BWMapperPolygon
an ordered list of Props
vtkNew< vtkActor2D > BWActorPolygon
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
virtual void GetSize(double size[2])
Subclasses should implement these methods.
vtkNew< vtkPolyData > PolyDataEdges
vtkNew< vtkProperty2D > PolygonProperty
#define VTK_FLOAT_MAX
Definition: vtkType.h:200
void SetShowPolygonToOff()
Specify when and if the border's polygon background should appear.
void SetShowBorderToOn()
Specify when and if the border should appear.
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetShowBorderToActive()
Specify when and if the border should appear.
int RenderOverlay(vtkViewport *viewport) override
InteractionStateType
Define the various states that the representation can be in.
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
virtual vtkMTimeType GetMTime()
Return this object's modified time.
virtual void WidgetInteraction(double newEventPos[2])
represent a vtkBorderWidget
void SetShowPolygonToActive()
Specify when and if the border's polygon background should appear.
vtkNew< vtkActor2D > BWActorEdges
object to represent cell connectivity
Definition: vtkCellArray.h:177
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
transform points and associated normals and vectors
represent surface properties of a 2D image
Definition: vtkProperty2D.h:30
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkNew< vtkTransform > BWTransform
vtkNew< vtkProperty2D > BorderProperty
draw vtkPolyData onto the image plane
represent and manipulate 3D points
Definition: vtkPoints.h:30
vtkNew< vtkPolyData > PolyDataPolygon