VTK  9.2.6
vtkChartXYZ.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkChartXYZ.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 =========================================================================*/
15 
26 #ifndef vtkChartXYZ_h
27 #define vtkChartXYZ_h
28 
29 #include "vtkChartsCoreModule.h" // For export macro
30 #include "vtkColor.h" // For vtkColor4ub
31 #include "vtkContextItem.h"
32 #include "vtkNew.h" // For ivars
33 #include "vtkRect.h" // For vtkRectf ivars
34 #include "vtkSmartPointer.h" // For ivars
35 #include "vtkStdString.h" // For vtkStdString
36 #include "vtkTextProperty.h" // For axes text properties
37 #include <vector> // For ivars
38 
39 class vtkAnnotationLink;
40 class vtkAxis;
41 class vtkContext3D;
43 class vtkPen;
44 class vtkPlaneCollection;
45 class vtkPlot3D;
46 class vtkTable;
47 class vtkTransform;
49 
50 class VTKCHARTSCORE_EXPORT vtkChartXYZ : public vtkContextItem
51 {
52 public:
53  vtkTypeMacro(vtkChartXYZ, vtkContextItem);
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
56  static vtkChartXYZ* New();
57 
67  void SetGeometry(const vtkRectf& bounds);
68 
76  void SetMargins(const vtkVector4i& margins);
77 
81  vtkSetMacro(Angle, double);
82 
86  void SetAroundX(bool isX);
87 
91  virtual void SetAnnotationLink(vtkAnnotationLink* link);
92 
96  vtkAxis* GetAxis(int axis);
97 
101  virtual void SetAxis(int axisIndex, vtkAxis* axis);
102 
104 
107  void SetAxisColor(const vtkColor4ub& color);
108  vtkColor4ub GetAxisColor();
110 
130  vtkTextProperty* GetAxesTextProperty();
131 
135  vtkSetMacro(XAxisLabel, vtkStdString);
136 
140  vtkSetMacro(YAxisLabel, vtkStdString);
141 
145  vtkSetMacro(ZAxisLabel, vtkStdString);
146 
152  vtkSetMacro(EnsureOuterEdgeAxisLabelling, bool);
153 
158  vtkSetMacro(AutoRotate, bool);
159 
164  void SetDecorateAxes(bool b);
165 
170  void SetFitToScene(bool b);
171 
175  void Update() override;
176 
180  bool Paint(vtkContext2D* painter) override;
181 
185  virtual vtkIdType AddPlot(vtkPlot3D* plot);
186 
190  virtual bool RemovePlot(vtkPlot3D* plot);
191 
195  void ClearPlots();
196 
201  void RecalculateBounds();
202 
208  void RecalculateTransform();
209 
213  bool Hit(const vtkContextMouseEvent& mouse) override;
214 
218  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
219 
223  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
224 
228  bool MouseWheelEvent(const vtkContextMouseEvent& mouse, int delta) override;
229 
235  bool KeyPressEvent(const vtkContextKeyEvent& key) override;
236 
240  void SetClippingPlanesEnabled(bool);
241 
245  vtkGetMacro(ClippingPlanesEnabled, bool);
246 
250  vtkSetMacro(ScaleBoxWithPlot, bool);
251 
255  vtkGetMacro(ScaleBoxWithPlot, bool);
256 
257 protected:
258  vtkChartXYZ();
259  ~vtkChartXYZ() override;
260 
265  {
268  UP,
269  DOWN
270  };
271 
276  {
282  STANDARD
283  };
284 
289  {
297  NORTH_WEST
298  };
299 
305  virtual void CalculateTransforms();
306 
313  bool CalculatePlotTransform(vtkAxis* x, vtkAxis* y, vtkAxis* z, vtkTransform* transform);
314 
318  bool Rotate(const vtkContextMouseEvent& mouse);
319 
323  bool Rotate(const RotateDirection rotateDirection);
324 
328  bool Pan(const vtkContextMouseEvent& mouse);
329 
333  bool Zoom(const vtkContextMouseEvent& mouse);
334 
338  bool Spin(const vtkContextMouseEvent& mouse);
339 
343  void LookDownX();
344 
348  void LookDownY();
349 
353  void LookDownZ();
354 
358  void LookUpX();
359 
363  void LookUpY();
364 
368  void LookUpZ();
369 
373  bool CheckForSceneResize();
374 
378  void RescaleAxes();
379 
383  void ScaleUpAxes();
384 
388  void ScaleDownAxes();
389 
393  void ZoomAxes(int delta);
394 
399  void InitializeAxesBoundaryPoints();
400 
410  void InitializeFutureBox();
411 
415  void ComputeDataBounds();
416 
420  void DrawAxes(vtkContext3D* context);
421 
426  void DetermineWhichAxesToLabel();
427 
432  void NewDetermineWhichAxesToLabel();
433 
438  void LegacyDetermineWhichAxesToLabel();
442  void DrawTickMarks(vtkContext2D* painter);
443 
447  void DrawAxesLabels(vtkContext2D* painter);
448 
454  void GetOffsetForAxisLabel(int axis, float* bounds, float* offset);
455 
461  double CalculateNiceMinMax(double& min, double& max, int axis);
462 
466  void GetClippingPlaneEquation(int i, double* planeEquation);
467 
471  std::size_t GetMarginLeft() const;
472 
476  std::size_t GetMarginBottom() const;
477 
481  std::size_t GetPlotWidth() const;
482 
486  std::size_t GetPlotHeight() const;
487 
491  enum
492  {
494  USE_GEOMETRY
495  } SizeStrategy = USE_GEOMETRY;
496 
501  vtkVector4i Margins = vtkVector4i(40, 40, 40, 40);
502 
507  vtkRectf Geometry = vtkRectf(40, 40, 120, 120);
508 
512  std::vector<vtkSmartPointer<vtkAxis>> Axes;
513 
518  bool AutoRotate = false;
519 
524  bool IsX = false;
525 
530  double Angle = 0;
531 
536  bool DrawAxesDecoration = true;
537 
542  bool FitToScene = true;
543 
548 
555 
560 
565 
571 
577 
583 
590 
595 
600 
605 
610 
614  std::vector<vtkPlot3D*> Plots;
615 
619  std::vector<vtkIdType> FreePlaces;
620 
625 
630 
635 
640 
646  bool EnsureOuterEdgeAxisLabelling = false;
651 
656  float AxesBoundaryPoints[8][3];
657 
662  float TickLabelOffset[3][2];
663 
668 
673 
675 
678  int XAxisToLabel[3];
679  int YAxisToLabel[3];
680  int ZAxisToLabel[3];
682 
686  int DirectionToData[3];
687 
691  double DataBounds[4];
692 
696  bool ClippingPlanesEnabled = true;
697 
701  bool ScaleBoxWithPlot = true;
702 
703 private:
704  vtkChartXYZ(const vtkChartXYZ&) = delete;
705  void operator=(const vtkChartXYZ&) = delete;
706 };
707 
708 #endif
int SceneHeight
The height of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:667
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
data structure to represent key events.
int SceneWidth
The weight of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:672
AxisState
The state of an axis.
Definition: vtkChartXYZ.h:275
vtkNew< vtkTransform > PlotTransform
This transform translates and scales the plots' data points so that they appear within the axes of th...
Definition: vtkChartXYZ.h:554
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:576
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:564
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
int vtkIdType
Definition: vtkType.h:332
std::vector< vtkIdType > FreePlaces
These plots got removed (from Plots), try to reuse the free spot.
Definition: vtkChartXYZ.h:619
vtkNew< vtkTextProperty > AxesTextProperty
The text properties of the axes.
Definition: vtkChartXYZ.h:624
std::vector< vtkSmartPointer< vtkAxis > > Axes
The 3 axes of this chart.
Definition: vtkChartXYZ.h:512
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:57
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:71
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:39
std::string YAxisLabel
The label for the Y Axis.
Definition: vtkChartXYZ.h:634
std::string ZAxisLabel
The label for the Z Axis.
Definition: vtkChartXYZ.h:639
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:39
vtkNew< vtkTransform > Translation
This transform keeps track of how the data points have been panned within the chart.
Definition: vtkChartXYZ.h:570
vtkSmartPointer< vtkAnnotationLink > Link
This link is used to share selected points with other classes.
Definition: vtkChartXYZ.h:609
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:614
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:73
vtkNew< vtkPen > AxisPen
This is the pen that is used to draw the axes.
Definition: vtkChartXYZ.h:604
Direction
The direction to data from an axis.
Definition: vtkChartXYZ.h:288
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:547
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:629
Abstract class for 3D plots.
Definition: vtkPlot3D.h:44
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:650
RotateDirection
Rotation directions.
Definition: vtkChartXYZ.h:264
vtkNew< vtkTransform > BoxScale
This transform keeps track of how the axes have been scaled (zoomed in or zoomed out).
Definition: vtkChartXYZ.h:582
Factory class for drawing 3D XYZ charts.
Definition: vtkChartXYZ.h:50
vtkNew< vtkTransform > FutureBox
This transform is initialized as a copy of Box.
Definition: vtkChartXYZ.h:589
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:594
vtkNew< vtkTransform > Box
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:559
vtkNew< vtkPen > Pen
This is the pen that is used to draw data from the plots.
Definition: vtkChartXYZ.h:599
Class for drawing 3D primitives to a graphical context.
Definition: vtkContext3D.h:40