VTK  9.7.1
vtkChartXYZ.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
3 
14 #ifndef vtkChartXYZ_h
15 #define vtkChartXYZ_h
16 
17 #include "vtkChartsCoreModule.h" // For export macro
18 #include "vtkColor.h" // For vtkColor4ub
19 #include "vtkContextItem.h"
20 #include "vtkNew.h" // For ivars
21 #include "vtkRect.h" // For vtkRectf ivars
22 #include "vtkSmartPointer.h" // For ivars
23 #include "vtkStdString.h" // For vtkStdString
24 #include "vtkTextProperty.h" // For axes text properties
25 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
26 #include <vector> // For ivars
27 
28 VTK_ABI_NAMESPACE_BEGIN
29 class vtkAnnotationLink;
30 class vtkAxis;
31 class vtkContext3D;
33 class vtkPen;
34 class vtkPlaneCollection;
35 class vtkPlot3D;
36 class vtkTable;
37 class vtkTransform;
39 
40 class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkChartXYZ : public vtkContextItem
41 {
42 public:
43  vtkTypeMacro(vtkChartXYZ, vtkContextItem);
44  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
46  static vtkChartXYZ* New();
47 
57  void SetGeometry(const vtkRectf& bounds);
58 
66  void SetMargins(const vtkVector4i& margins);
67 
71  vtkSetMacro(Angle, double);
72 
76  void SetAroundX(bool isX);
77 
81  virtual void SetAnnotationLink(vtkAnnotationLink* link);
82 
86  vtkAxis* GetAxis(int axis);
87 
91  virtual void SetAxis(int axisIndex, vtkAxis* axis);
92 
94 
97  void SetAxisColor(const vtkColor4ub& color);
98  vtkColor4ub GetAxisColor();
100 
120  vtkTextProperty* GetAxesTextProperty();
121 
125  vtkSetMacro(XAxisLabel, vtkStdString);
126 
130  vtkSetMacro(YAxisLabel, vtkStdString);
131 
135  vtkSetMacro(ZAxisLabel, vtkStdString);
136 
142  vtkSetMacro(EnsureOuterEdgeAxisLabelling, bool);
143 
148  vtkSetMacro(AutoRotate, bool);
149 
154  void SetDecorateAxes(bool b);
155 
160  void SetFitToScene(bool b);
161 
165  void Update() override;
166 
170  bool Paint(vtkContext2D* painter) override;
171 
175  virtual vtkIdType AddPlot(vtkPlot3D* plot);
176 
180  virtual bool RemovePlot(vtkPlot3D* plot);
181 
185  void ClearPlots();
186 
191  void RecalculateBounds();
192 
198  void RecalculateTransform();
199 
203  bool Hit(const vtkContextMouseEvent& mouse) override;
204 
208  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
209 
213  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
214 
218  bool MouseWheelEvent(const vtkContextMouseEvent& mouse, int delta) override;
219 
225  bool KeyPressEvent(const vtkContextKeyEvent& key) override;
226 
230  void SetClippingPlanesEnabled(bool);
231 
235  vtkGetMacro(ClippingPlanesEnabled, bool);
236 
240  vtkSetMacro(ScaleBoxWithPlot, bool);
241 
245  vtkGetMacro(ScaleBoxWithPlot, bool);
246 
247 protected:
248  vtkChartXYZ();
249  ~vtkChartXYZ() override;
250 
255  {
258  UP,
259  DOWN
260  };
261 
266  {
272  STANDARD
273  };
274 
279  {
287  NORTH_WEST
288  };
289 
295  virtual void CalculateTransforms();
296 
303  bool CalculatePlotTransform(vtkAxis* x, vtkAxis* y, vtkAxis* z, vtkTransform* transform);
304 
308  bool Rotate(const vtkContextMouseEvent& mouse);
309 
313  bool Rotate(RotateDirection rotateDirection);
314 
318  bool Pan(const vtkContextMouseEvent& mouse);
319 
323  bool Zoom(const vtkContextMouseEvent& mouse);
324 
328  bool Spin(const vtkContextMouseEvent& mouse);
329 
333  void LookDownX();
334 
338  void LookDownY();
339 
343  void LookDownZ();
344 
348  void LookUpX();
349 
353  void LookUpY();
354 
358  void LookUpZ();
359 
363  bool CheckForSceneResize();
364 
368  void RescaleAxes();
369 
373  void ScaleUpAxes();
374 
378  void ScaleDownAxes();
379 
383  void ZoomAxes(int delta);
384 
389  void InitializeAxesBoundaryPoints();
390 
400  void InitializeFutureBox();
401 
405  void ComputeDataBounds();
406 
410  void DrawAxes(vtkContext3D* context);
411 
416  void DetermineWhichAxesToLabel();
417 
422  void NewDetermineWhichAxesToLabel();
423 
428  void LegacyDetermineWhichAxesToLabel();
432  void DrawTickMarks(vtkContext2D* painter);
433 
437  void DrawAxesLabels(vtkContext2D* painter);
438 
444  void GetOffsetForAxisLabel(int axis, float* bounds, float* offset);
445 
451  double CalculateNiceMinMax(double& min, double& max, int axis);
452 
456  void GetClippingPlaneEquation(int i, double* planeEquation);
457 
461  std::size_t GetMarginLeft() const;
462 
466  std::size_t GetMarginBottom() const;
467 
471  std::size_t GetPlotWidth() const;
472 
476  std::size_t GetPlotHeight() const;
477 
481  enum
482  {
484  USE_GEOMETRY
485  } SizeStrategy = USE_GEOMETRY;
486 
491  vtkVector4i Margins = vtkVector4i(40, 40, 40, 40);
492 
497  vtkRectf Geometry = vtkRectf(40, 40, 120, 120);
498 
502  std::vector<vtkSmartPointer<vtkAxis>> Axes;
503 
508  bool AutoRotate = false;
509 
514  bool IsX = false;
515 
520  double Angle = 0;
521 
526  bool DrawAxesDecoration = true;
527 
532  bool FitToScene = true;
533 
538 
545 
550 
555 
561 
567 
573 
580 
585 
590 
595 
600 
604  std::vector<vtkPlot3D*> Plots;
605 
609  std::vector<vtkIdType> FreePlaces;
610 
615 
620 
625 
630 
636  bool EnsureOuterEdgeAxisLabelling = false;
641 
646  float AxesBoundaryPoints[8][3];
647 
652  float TickLabelOffset[3][2];
653 
658 
663 
665 
668  int XAxisToLabel[3];
669  int YAxisToLabel[3];
670  int ZAxisToLabel[3];
672 
676  int DirectionToData[3];
677 
681  double DataBounds[4];
682 
686  bool ClippingPlanesEnabled = true;
687 
691  bool ScaleBoxWithPlot = true;
692 
693 private:
694  vtkChartXYZ(const vtkChartXYZ&) = delete;
695  void operator=(const vtkChartXYZ&) = delete;
696 };
697 
698 VTK_ABI_NAMESPACE_END
699 #endif
int SceneHeight
The height of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:657
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:27
data structure to represent key events.
int SceneWidth
The weight of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:662
AxisState
The state of an axis.
Definition: vtkChartXYZ.h:265
vtkNew< vtkTransform > PlotTransform
This transform translates and scales the plots' data points so that they appear within the axes of th...
Definition: vtkChartXYZ.h:544
base class for items that are part of a vtkContextScene.
virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
Mouse button down event Return true if the item holds the event, false if the event can be propagated...
vtkNew< vtkTransform > Scale
This transform keeps track of how the data points have been scaled (zoomed in or zoomed out) within t...
Definition: vtkChartXYZ.h:566
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
maintain a list of planes
vtkNew< vtkTransform > Rotation
This transform keeps track of how the chart has been rotated.
Definition: vtkChartXYZ.h:554
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
int vtkIdType
Definition: vtkType.h:363
std::vector< vtkIdType > FreePlaces
These plots got removed (from Plots), try to reuse the free spot.
Definition: vtkChartXYZ.h:609
vtkNew< vtkTextProperty > AxesTextProperty
The text properties of the axes.
Definition: vtkChartXYZ.h:614
std::vector< vtkSmartPointer< vtkAxis > > Axes
The 3 axes of this chart.
Definition: vtkChartXYZ.h:502
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta)
Mouse wheel event, positive delta indicates forward movement of the wheel.
takes care of drawing 2D axes
Definition: vtkAxis.h:61
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:28
std::string YAxisLabel
The label for the Y Axis.
Definition: vtkChartXYZ.h:624
std::string ZAxisLabel
The label for the Z Axis.
Definition: vtkChartXYZ.h:629
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:29
vtkNew< vtkTransform > Translation
This transform keeps track of how the data points have been panned within the chart.
Definition: vtkChartXYZ.h:560
vtkSmartPointer< vtkAnnotationLink > Link
This link is used to share selected points with other classes.
Definition: vtkChartXYZ.h:599
represent text properties.
virtual bool KeyPressEvent(const vtkContextKeyEvent &key)
Key press event.
dynamic, self-adjusting array of unsigned char
std::vector< vtkPlot3D * > Plots
The plots that are drawn within this chart.
Definition: vtkChartXYZ.h:604
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:59
vtkNew< vtkPen > AxisPen
This is the pen that is used to draw the axes.
Definition: vtkChartXYZ.h:594
Direction
The direction to data from an axis.
Definition: vtkChartXYZ.h:278
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
vtkNew< vtkTransform > ContextTransform
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:537
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
std::string XAxisLabel
The label for the X Axis.
Definition: vtkChartXYZ.h:619
#define VTK_MARSHALAUTO
Abstract class for 3D plots.
Definition: vtkPlot3D.h:35
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkNew< vtkPlaneCollection > BoundingCube
The six planes that define the bounding cube of our 3D axes.
Definition: vtkChartXYZ.h:640
RotateDirection
Rotation directions.
Definition: vtkChartXYZ.h:254
vtkNew< vtkTransform > BoxScale
This transform keeps track of how the axes have been scaled (zoomed in or zoomed out).
Definition: vtkChartXYZ.h:572
Factory class for drawing 3D XYZ charts.
Definition: vtkChartXYZ.h:40
vtkNew< vtkTransform > FutureBox
This transform is initialized as a copy of Box.
Definition: vtkChartXYZ.h:579
virtual void Update()
Perform any updates to the item that may be necessary before rendering.
#define max(a, b)
vtkNew< vtkTransform > FutureBoxScale
This transform keeps track of the Scale of the FutureBox transform.
Definition: vtkChartXYZ.h:584
vtkNew< vtkTransform > Box
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:549
vtkNew< vtkPen > Pen
This is the pen that is used to draw data from the plots.
Definition: vtkChartXYZ.h:589
Class for drawing 3D primitives to a graphical context.
Definition: vtkContext3D.h:33