VTK  9.7.1
vtkGridAxesPlaneActor2D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
3 // SPDX-License-Identifier: BSD-3-Clause
13 #ifndef vtkGridAxesPlaneActor2D_h
14 #define vtkGridAxesPlaneActor2D_h
15 
16 #include "vtkProp3D.h"
17 #include "vtkRenderingGridAxesModule.h" //needed for exports
18 
19 #include "vtkGridAxesHelper.h" // For face enumeration
20 #include "vtkNew.h" // For member variables
21 #include "vtkSmartPointer.h" // For member variables
22 #include <deque> // For keeping track of tick marks
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class vtkActor;
26 class vtkCellArray;
27 class vtkDoubleArray;
28 class vtkPoints;
29 class vtkPolyData;
30 class vtkPolyDataMapper;
31 class vtkProperty;
32 
33 class VTKRENDERINGGRIDAXES_EXPORT vtkGridAxesPlaneActor2D : public vtkProp3D
34 {
35 public:
36  static vtkGridAxesPlaneActor2D* New();
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
41 
49  vtkSetVector6Macro(GridBounds, double);
50  vtkGetVector6Macro(GridBounds, double);
52 
54 
62  vtkSetClampMacro(Face, int, vtkGridAxesHelper::MIN_YZ, vtkGridAxesHelper::MAX_XY);
63  vtkGetMacro(Face, int);
65 
74  void GetActors(vtkPropCollection*) override;
75 
80  void UpdateGeometry(vtkViewport* vp);
81 
83 
86  vtkSetMacro(GenerateGrid, bool);
87  vtkGetMacro(GenerateGrid, bool);
88  vtkBooleanMacro(GenerateGrid, bool);
90 
92 
96  vtkSetMacro(GenerateEdges, bool);
97  vtkGetMacro(GenerateEdges, bool);
98  vtkBooleanMacro(GenerateEdges, bool);
100 
102 
106  vtkSetMacro(GenerateTicks, bool);
107  vtkGetMacro(GenerateTicks, bool);
108  vtkBooleanMacro(GenerateTicks, bool);
110 
111  enum : unsigned char
112  {
113  TICK_DIRECTION_INWARDS = 0x1,
114  TICK_DIRECTION_OUTWARDS = 0x2,
115  TICK_DIRECTION_BOTH = TICK_DIRECTION_INWARDS | TICK_DIRECTION_OUTWARDS,
116  };
117 
119 
124  vtkSetClampMacro(TickDirection, unsigned int, static_cast<unsigned int>(TICK_DIRECTION_INWARDS),
125  static_cast<unsigned int>(TICK_DIRECTION_BOTH));
126  vtkGetMacro(TickDirection, unsigned int);
128 
130 
140  void SetTickPositions(int axis, vtkDoubleArray* data);
141  const std::deque<double>& GetTickPositions(int axis)
142  {
143  return (axis >= 0 && axis < 3) ? this->TickPositions[axis] : this->EmptyVector;
144  }
146 
148 
153  void SetProperty(vtkProperty*);
154  vtkProperty* GetProperty();
156 
157  //--------------------------------------------------------------------------
158  // Methods for vtkProp3D API.
159  //--------------------------------------------------------------------------
160 
162 
165  double* GetBounds() override
166  {
167  this->GetGridBounds(this->Bounds);
168  return this->Bounds;
169  }
171 
173 
176  int RenderOpaqueGeometry(vtkViewport*) override;
177  int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
178  int RenderOverlay(vtkViewport* viewport) override;
181 
187  void ReleaseGraphicsResources(vtkWindow*) override;
188 
189 protected:
190  vtkGridAxesPlaneActor2D(vtkGridAxesHelper* helper = nullptr);
191  ~vtkGridAxesPlaneActor2D() override;
192 
194 
201  friend class vtkGridAxesActor2D;
203 
205 
208  void Update(vtkViewport* viewport);
209  bool UpdateEdges(vtkViewport* viewport);
210  bool UpdateGrid(vtkViewport* viewport);
211  bool UpdateTicks(vtkViewport* viewport);
213 
214 private:
216  void operator=(const vtkGridAxesPlaneActor2D&) = delete;
217  std::deque<double> EmptyVector;
218 
219  typedef std::pair<vtkVector3d, vtkVector3d> LineSegmentType;
220  std::deque<LineSegmentType> LineSegments;
221 
222  double GridBounds[6];
223  int Face = vtkGridAxesHelper::MIN_YZ;
224 
225  bool GenerateGrid = true;
226  bool GenerateEdges = true;
227  bool GenerateTicks = true;
228  unsigned int TickDirection = TICK_DIRECTION_BOTH;
229  std::deque<double> TickPositions[3];
230 
231  vtkNew<vtkPolyData> PolyData;
232  vtkNew<vtkPoints> PolyDataPoints;
233  vtkNew<vtkCellArray> PolyDataLines;
235  vtkNew<vtkActor> Actor;
236 
238  bool HelperManagedExternally;
239 };
240 
241 VTK_ABI_NAMESPACE_END
242 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:59
virtual int RenderOpaqueGeometry(vtkViewport *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkProp.h:236
virtual vtkTypeBool HasTranslucentPolygonalGeometry()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkProp.h:300
virtual int RenderOverlay(vtkViewport *)
Definition: vtkProp.h:239
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:39
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
dynamic, self-adjusting array of double
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:64
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkProp.h:321
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
renders a 2D grid for vtkGridAxesActor2D.
a simple class to control print indentation
Definition: vtkIndent.h:28
void UpdateGrid(int iteration)
double Bounds[6]
Definition: vtkProp3D.h:400
bool Update(vtkViewport *viewport)
map vtkPolyData to graphics primitives
object to represent cell connectivity
Definition: vtkCellArray.h:177
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *)
Definition: vtkProp.h:237
const std::deque< double > & GetTickPositions(int axis)
Set the tick positions for each of the coordinate axis.
is a helper object used by vtkGridAxesActor2D, vtkGridAxesActor3D, and vtkGridAxesPlane2DActor.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
double * GetBounds() override
Returns the prop bounds.
virtual void GetActors(vtkPropCollection *)
For some exporters and other other operations we must be able to collect all the actors or volumes...
Definition: vtkProp.h:60
represent and manipulate 3D points
Definition: vtkPoints.h:30
actor for an axes plane in a 3D view.