VTK  9.2.6
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 =========================================================================*/
42 #ifndef vtkBorderRepresentation_h
43 #define vtkBorderRepresentation_h
44 
45 #include "vtkCoordinate.h" //Because of the viewport coordinate macro
46 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
47 #include "vtkInteractionWidgetsModule.h" // For export macro
49 
50 #include "vtkNew.h" // for ivars
51 
52 class vtkPoints;
53 class vtkPolyData;
54 class vtkTransform;
57 class vtkActor2D;
58 class vtkProperty2D;
59 class vtkCellArray;
60 
61 class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
62 {
63 public:
67  static vtkBorderRepresentation* New();
68 
70 
74  void PrintSelf(ostream& os, vtkIndent indent) override;
76 
78 
87  vtkViewportCoordinateMacro(Position);
88  vtkViewportCoordinateMacro(Position2);
90 
91  enum
92  {
93  BORDER_OFF = 0,
95  BORDER_ACTIVE
96  };
97 
99 
110  virtual void SetShowBorder(int border);
111  virtual int GetShowBorderMinValue();
112  virtual int GetShowBorderMaxValue();
113  virtual int GetShowBorder();
114  void SetShowBorderToOff() { this->SetShowBorder(BORDER_OFF); }
115  void SetShowBorderToOn() { this->SetShowBorder(BORDER_ON); }
116  void SetShowBorderToActive() { this->SetShowBorder(BORDER_ACTIVE); }
118 
120 
125  vtkSetClampMacro(ShowVerticalBorder, int, BORDER_OFF, BORDER_ACTIVE);
126  vtkGetMacro(ShowVerticalBorder, int);
128 
130 
135  vtkSetClampMacro(ShowHorizontalBorder, int, BORDER_OFF, BORDER_ACTIVE);
136  vtkGetMacro(ShowHorizontalBorder, int);
138 
140 
143  vtkGetObjectMacro(BorderProperty, vtkProperty2D);
145 
147 
152  virtual void SetShowPolygon(int border);
153  virtual int GetShowPolygon();
154  void SetShowPolygonToOff() { this->SetShowPolygon(BORDER_OFF); }
155  void SetShowPolygonToOn() { this->SetShowPolygon(BORDER_ON); }
156  void SetShowPolygonToActive() { this->SetShowPolygon(BORDER_ACTIVE); }
158 
160 
165  vtkSetClampMacro(ShowPolygonBackground, int, BORDER_OFF, BORDER_ACTIVE);
166  vtkGetMacro(ShowPolygonBackground, int);
168 
170 
180  vtkSetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
181  vtkGetMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
182  vtkBooleanMacro(EnforceNormalizedViewportBounds, vtkTypeBool);
184 
186 
195  vtkSetMacro(ProportionalResize, vtkTypeBool);
196  vtkGetMacro(ProportionalResize, vtkTypeBool);
197  vtkBooleanMacro(ProportionalResize, vtkTypeBool);
199 
201 
208  vtkSetVector2Macro(MinimumNormalizedViewportSize, double);
209  vtkGetVector2Macro(MinimumNormalizedViewportSize, double);
211 
213 
220  vtkSetVector2Macro(MinimumSize, int);
221  vtkGetVector2Macro(MinimumSize, int);
222  vtkSetVector2Macro(MaximumSize, int);
223  vtkGetVector2Macro(MaximumSize, int);
225 
227 
234  vtkSetClampMacro(Tolerance, int, 1, 10);
235  vtkGetMacro(Tolerance, int);
237 
239 
243  vtkGetVectorMacro(SelectionPoint, double, 2);
245 
247 
252  vtkSetMacro(Moving, vtkTypeBool);
253  vtkGetMacro(Moving, vtkTypeBool);
254  vtkBooleanMacro(Moving, vtkTypeBool);
256 
257  enum
258  {
259  AnyLocation = 0,
265  UpperCenter
266  };
267 
269 
280  virtual void SetWindowLocation(int enumLocation);
281  vtkGetMacro(WindowLocation, int);
283 
288  {
289  Outside = 0,
298  AdjustingE3
299  };
300 #if !defined(VTK_LEGACY_REMOVE)
301  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
303 #endif
304 
305  vtkSetClampMacro(InteractionState, int, 0, AdjustingE3);
306 
311  vtkMTimeType GetMTime() override;
312 
314 
318  void BuildRepresentation() override;
319  void StartWidgetInteraction(double eventPos[2]) override;
320  void WidgetInteraction(double eventPos[2]) override;
321  virtual void GetSize(double size[2])
322  {
323  size[0] = 1.0;
324  size[1] = 1.0;
325  }
326  int ComputeInteractionState(int X, int Y, int modify = 0) override;
328 
330 
334  void GetActors2D(vtkPropCollection*) override;
335  void ReleaseGraphicsResources(vtkWindow*) override;
336  int RenderOverlay(vtkViewport*) override;
337  int RenderOpaqueGeometry(vtkViewport*) override;
341 
343  "SetBWActorDisplayOverlay is deprecated. Use "
344  "SetBWActorDisplayOverlayEdges or SetBWActorDisplayOverlayPolygon instead.")
345  void SetBWActorDisplayOverlay(bool);
346 
347  void SetBWActorDisplayOverlayEdges(bool);
348  void SetBWActorDisplayOverlayPolygon(bool);
349 
351 
355  vtkSetVector3Macro(BorderColor, double);
356  vtkGetVector3Macro(BorderColor, double);
358 
360 
364  vtkSetClampMacro(BorderThickness, float, 0, VTK_FLOAT_MAX);
365  vtkGetMacro(BorderThickness, float);
367 
369 
377  vtkSetClampMacro(CornerRadiusStrength, double, 0.0, 1.0);
378  vtkGetMacro(CornerRadiusStrength, double);
380 
382 
387  vtkSetClampMacro(CornerResolution, int, 0, 1000);
388  vtkGetMacro(CornerResolution, int);
390 
392 
396  vtkSetVector3Macro(PolygonColor, double);
397  vtkGetVector3Macro(PolygonColor, double);
399 
401 
405  vtkSetClampMacro(PolygonOpacity, double, 0.0, 1.0);
406  vtkGetMacro(PolygonOpacity, double);
408 
410 
413  void SetPolygonRGBA(double rgba[4]);
414  void SetPolygonRGBA(double r, double g, double b, double a);
415 
419  void GetPolygonRGBA(double rgba[4]);
420  void GetPolygonRGBA(double& r, double& g, double& b, double& a);
422 
423 protected:
425  ~vtkBorderRepresentation() override;
426 
427  // Ivars
428  int ShowVerticalBorder = BORDER_ON;
429  int ShowHorizontalBorder = BORDER_ON;
430  int ShowPolygonBackground = BORDER_ON;
431  vtkNew<vtkProperty2D> BorderProperty;
432  vtkNew<vtkProperty2D> PolygonProperty;
433  vtkTypeBool EnforceNormalizedViewportBounds = 0;
434  vtkTypeBool ProportionalResize = 0;
435  int Tolerance = 3;
436  vtkTypeBool Moving = 0;
437  double SelectionPoint[2] = { 0.0, 0.0 };
438 
439  // Layout (position of lower left and upper right corners of border)
442 
443  // Window location by enumeration
444  int WindowLocation = AnyLocation;
445  virtual void UpdateWindowLocation();
446 
447  // Sometimes subclasses must negotiate with their superclasses
448  // to achieve the correct layout.
450  virtual void NegotiateLayout();
451 
452  // Update the border visibility based on InteractionState.
453  // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
454  // ComputeInteractionState()
455  virtual void UpdateShowBorder();
456 
457  // Keep track of start position when moving border
458  double StartPosition[2];
459 
460  // Border representation. Subclasses may use the BWTransform class
461  // to transform their geometry into the region surrounded by the border.
472 
473  // Constraints on size
474  double MinimumNormalizedViewportSize[2] = { 0.0, 0.0 };
475  int MinimumSize[2] = { 1, 1 };
476  int MaximumSize[2] = { VTK_INT_MAX, VTK_INT_MAX };
477 
478  // Properties of the border
479  double BorderColor[3] = { 1.0, 1.0, 1.0 };
480  float BorderThickness = 1.0;
481  double CornerRadiusStrength = 0.0;
482  int CornerResolution = 20;
483 
484  // Properties of the inner polygon (ie. the background)
485  double PolygonColor[3] = { 1.0, 1.0, 1.0 };
486  double PolygonOpacity = 0.0;
487 
491  void ComputeRoundCorners();
492 
500  void ComputeOneRoundCorner(vtkCellArray* polys, vtkPoints* points, const double radius,
501  vtkIdType xPt, vtkIdType yPt, const double startAngle);
502 
503 private:
505  void operator=(const vtkBorderRepresentation&) = delete;
506 };
507 
508 #endif
vtkNew< vtkPolyData > BWPolyData
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:287
abstract specification for Viewports
Definition: vtkViewport.h:55
void GetActors2D(vtkPropCollection *) override
virtual void StartWidgetInteraction(double eventPos[2])
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_INT_MAX
Definition: vtkType.h:155
a actor that draws 2D data
Definition: vtkActor2D.h:45
void SetShowBorderToOff()
Specify when and if the border should appear.
vtkNew< vtkPolyDataMapper2D > BWMapperEdges
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
int vtkIdType
Definition: vtkType.h:332
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
vtkNew< vtkPolyDataMapper2D > BWMapperPolygon
an ordered list of Props
vtkNew< vtkActor2D > BWActorPolygon
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
virtual void GetSize(double size[2])
Subclasses should implement these methods.
vtkNew< vtkTransformPolyDataFilter > BWTransformFilter
vtkNew< vtkPolyData > PolyDataEdges
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
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:39
void SetShowBorderToActive()
Specify when and if the border should appear.
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])
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
represent a vtkBorderWidget
void SetShowPolygonToActive()
Specify when and if the border's polygon background should appear.
vtkNew< vtkActor2D > BWActorEdges
int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) override
object to represent cell connectivity
Definition: vtkCellArray.h:186
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Allocate and hold a VTK object.
Definition: vtkMeta.h:30
represent surface properties of a 2D image
Definition: vtkProperty2D.h:40
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkNew< vtkTransform > BWTransform
draw vtkPolyData onto the image plane
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkNew< vtkPolyData > PolyDataPolygon