VTK  9.1.0
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 
52 #ifndef vtkChartXYZ_h
53 #define vtkChartXYZ_h
54 
55 #include "vtkChartsCoreModule.h" // For export macro
56 #include "vtkColor.h" // For vtkColor4ub
57 #include "vtkContextItem.h"
58 #include "vtkNew.h" // For ivars
59 #include "vtkRect.h" // For vtkRectf ivars
60 #include "vtkSmartPointer.h" // For ivars
61 #include "vtkStdString.h" // For vtkStdString
62 #include "vtkTextProperty.h" // For axes text properties
63 #include <vector> // For ivars
64 
65 class vtkAnnotationLink;
66 class vtkAxis;
67 class vtkContext3D;
69 class vtkPen;
70 class vtkPlaneCollection;
71 class vtkPlot3D;
72 class vtkTable;
73 class vtkTransform;
75 
76 class VTKCHARTSCORE_EXPORT vtkChartXYZ : public vtkContextItem
77 {
78 public:
79  vtkTypeMacro(vtkChartXYZ, vtkContextItem);
80  void PrintSelf(ostream& os, vtkIndent indent) override;
81 
82  static vtkChartXYZ* New();
83 
93  void SetGeometry(const vtkRectf& bounds);
94 
102  void SetMargins(const vtkVector4i& margins);
103 
107  vtkSetMacro(Angle, double);
108 
112  void SetAroundX(bool isX);
113 
118 
122  vtkAxis* GetAxis(int axis);
123 
127  virtual void SetAxis(int axisIndex, vtkAxis* axis);
128 
130 
136 
157 
161  vtkSetMacro(XAxisLabel, vtkStdString);
162 
166  vtkSetMacro(YAxisLabel, vtkStdString);
167 
171  vtkSetMacro(ZAxisLabel, vtkStdString);
172 
178  vtkSetMacro(EnsureOuterEdgeAxisLabelling, bool);
179 
184  vtkSetMacro(AutoRotate, bool);
185 
190  void SetDecorateAxes(bool b);
191 
196  void SetFitToScene(bool b);
197 
201  void Update() override;
202 
206  bool Paint(vtkContext2D* painter) override;
207 
211  virtual vtkIdType AddPlot(vtkPlot3D* plot);
212 
216  virtual bool RemovePlot(vtkPlot3D* plot);
217 
221  void ClearPlots();
222 
228 
235 
239  bool Hit(const vtkContextMouseEvent& mouse) override;
240 
244  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
245 
249  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
250 
254  bool MouseWheelEvent(const vtkContextMouseEvent& mouse, int delta) override;
255 
261  bool KeyPressEvent(const vtkContextKeyEvent& key) override;
262 
267 
271  vtkGetMacro(ClippingPlanesEnabled, bool);
272 
276  vtkSetMacro(ScaleBoxWithPlot, bool);
277 
281  vtkGetMacro(ScaleBoxWithPlot, bool);
282 
283 protected:
285  ~vtkChartXYZ() override;
286 
291  {
294  UP,
295  DOWN
296  };
297 
302  {
308  STANDARD
309  };
310 
315  {
323  NORTH_WEST
324  };
325 
331  virtual void CalculateTransforms();
332 
340 
344  bool Rotate(const vtkContextMouseEvent& mouse);
345 
349  bool Rotate(const RotateDirection rotateDirection);
350 
354  bool Pan(const vtkContextMouseEvent& mouse);
355 
359  bool Zoom(const vtkContextMouseEvent& mouse);
360 
364  bool Spin(const vtkContextMouseEvent& mouse);
365 
369  void LookDownX();
370 
374  void LookDownY();
375 
379  void LookDownZ();
380 
384  void LookUpX();
385 
389  void LookUpY();
390 
394  void LookUpZ();
395 
400 
404  void RescaleAxes();
405 
409  void ScaleUpAxes();
410 
415 
419  void ZoomAxes(int delta);
420 
426 
437 
442 
446  void DrawAxes(vtkContext3D* context);
447 
453 
459 
468  void DrawTickMarks(vtkContext2D* painter);
469 
473  void DrawAxesLabels(vtkContext2D* painter);
474 
480  void GetOffsetForAxisLabel(int axis, float* bounds, float* offset);
481 
487  double CalculateNiceMinMax(double& min, double& max, int axis);
488 
492  void GetClippingPlaneEquation(int i, double* planeEquation);
493 
497  std::size_t GetMarginLeft() const;
498 
502  std::size_t GetMarginBottom() const;
503 
507  std::size_t GetPlotWidth() const;
508 
512  std::size_t GetPlotHeight() const;
513 
517  enum
518  {
520  USE_GEOMETRY
521  } SizeStrategy = USE_GEOMETRY;
522 
527  vtkVector4i Margins = vtkVector4i(40, 40, 40, 40);
528 
533  vtkRectf Geometry = vtkRectf(40, 40, 120, 120);
534 
538  std::vector<vtkSmartPointer<vtkAxis>> Axes;
539 
544  bool AutoRotate = false;
545 
550  bool IsX = false;
551 
556  double Angle = 0;
557 
562  bool DrawAxesDecoration = true;
563 
568  bool FitToScene = true;
569 
574 
581 
586 
591 
597 
603 
609 
616 
621 
626 
631 
636 
640  std::vector<vtkPlot3D*> Plots;
641 
645  std::vector<vtkIdType> FreePlaces;
646 
651 
656 
661 
666 
672  bool EnsureOuterEdgeAxisLabelling = false;
677 
682  float AxesBoundaryPoints[8][3];
683 
688  float TickLabelOffset[3][2];
689 
694 
699 
701 
704  int XAxisToLabel[3];
705  int YAxisToLabel[3];
706  int ZAxisToLabel[3];
708 
712  int DirectionToData[3];
713 
717  double DataBounds[4];
718 
722  bool ClippingPlanesEnabled = true;
723 
727  bool ScaleBoxWithPlot = true;
728 
729 private:
730  vtkChartXYZ(const vtkChartXYZ&) = delete;
731  void operator=(const vtkChartXYZ&) = delete;
732 };
733 
734 #endif
vtkChartXYZ::UP
@ UP
Definition: vtkChartXYZ.h:294
vtkChartXYZ::Spin
bool Spin(const vtkContextMouseEvent &mouse)
Spin the chart in response to a mouse movement.
vtkChartXYZ::Scale
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:602
vtkChartXYZ::ScaleUpAxes
void ScaleUpAxes()
Scale up the axes when the scene gets larger.
vtkStdString.h
vtkChartXYZ::GetPlotHeight
std::size_t GetPlotHeight() const
Gets the current height of the plot in pixels irrespective of the size-strategy used.
vtkChartXYZ::Box
vtkNew< vtkTransform > Box
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:585
vtkChartXYZ::AddPlot
virtual vtkIdType AddPlot(vtkPlot3D *plot)
Adds a plot to the chart.
vtkChartXYZ::Pen
vtkNew< vtkPen > Pen
This is the pen that is used to draw data from the plots.
Definition: vtkChartXYZ.h:625
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:54
vtkChartXYZ::BoxScale
vtkNew< vtkTransform > BoxScale
This transform keeps track of how the axes have been scaled (zoomed in or zoomed out).
Definition: vtkChartXYZ.h:608
vtkChartXYZ::CalculatePlotTransform
bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y, vtkAxis *z, vtkTransform *transform)
Given the x, y and z vtkAxis, and a transform, calculate the transform that the points in a chart wou...
vtkChartXYZ::InitializeFutureBox
void InitializeFutureBox()
Initialize the "future box" transform.
vtkContextKeyEvent
data structure to represent key events.
Definition: vtkContextKeyEvent.h:35
vtkChartXYZ::LookDownZ
void LookDownZ()
Adjust the rotation of the chart so that we are looking down the Z axis.
vtkChartXYZ::Pan
bool Pan(const vtkContextMouseEvent &mouse)
Pan the data within the chart in response to a mouse movement.
vtkChartXYZ::Rotation
vtkNew< vtkTransform > Rotation
This transform keeps track of how the chart has been rotated.
Definition: vtkChartXYZ.h:590
vtkChartXYZ::RemovePlot
virtual bool RemovePlot(vtkPlot3D *plot)
Removes a plot from the chart.
vtkChartXYZ::NORTH
@ NORTH
Definition: vtkChartXYZ.h:316
vtkChartXYZ::GetAxesTextProperty
vtkTextProperty * GetAxesTextProperty()
Get the text property for axes.
vtkChartXYZ::InitializeAxesBoundaryPoints
void InitializeAxesBoundaryPoints()
Initialize a list of "test points".
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkChartXYZ::ZoomAxes
void ZoomAxes(int delta)
Change the scaling of the axes by a specified amount.
vtkChartXYZ::FreePlaces
std::vector< vtkIdType > FreePlaces
These plots got removed (from Plots), try to reuse the free spot.
Definition: vtkChartXYZ.h:645
vtkChartXYZ::HORIZONTAL
@ HORIZONTAL
Definition: vtkChartXYZ.h:305
vtkChartXYZ::MouseButtonPressEvent
bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override
Mouse press event.
vtkChartXYZ::PlotTransform
vtkNew< vtkTransform > PlotTransform
This transform translates and scales the plots' data points so that they appear within the axes of th...
Definition: vtkChartXYZ.h:580
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:172
vtkX3D::key
@ key
Definition: vtkX3D.h:263
vtkChartXYZ::SetAroundX
void SetAroundX(bool isX)
Set whether or not we're rotating about the X axis.
vtkChartXYZ
Factory class for drawing 3D XYZ charts.
Definition: vtkChartXYZ.h:77
vtkChartXYZ::SetGeometry
void SetGeometry(const vtkRectf &bounds)
Set the geometry in pixel coordinates (origin and width/height).
vtkChartXYZ::DetermineWhichAxesToLabel
void DetermineWhichAxesToLabel()
For each of the XYZ dimensions, find the axis line that is furthest from the rendered data.
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:145
vtkChartXYZ::LookUpY
void LookUpY()
Adjust the rotation of the chart so that we are looking up the Y axis.
vtkChartXYZ::Paint
bool Paint(vtkContext2D *painter) override
Paint event for the chart, called whenever the chart needs to be drawn.
vtkSmartPointer< vtkAnnotationLink >
vtkChartXYZ::RecalculateBounds
void RecalculateBounds()
Determine the XYZ bounds of the plots within this chart.
vtkChartXYZ::DrawAxes
void DrawAxes(vtkContext3D *context)
Draw the cube axes of this chart.
vtkChartXYZ::HORIZONTAL_2
@ HORIZONTAL_2
Definition: vtkChartXYZ.h:306
vtkChartXYZ::DO_NOT_LABEL
@ DO_NOT_LABEL
Definition: vtkChartXYZ.h:307
vtkChartXYZ::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:73
vtkChartXYZ::SOUTH_WEST
@ SOUTH_WEST
Definition: vtkChartXYZ.h:321
vtkChartXYZ::GetAxis
vtkAxis * GetAxis(int axis)
Get the x (0), y (1) or z (2) axis.
vtkChartXYZ::GetAxisColor
vtkColor4ub GetAxisColor()
Set the color for the axes.
vtkChartXYZ::KeyPressEvent
bool KeyPressEvent(const vtkContextKeyEvent &key) override
Key press event.
vtkContextItem.h
vtkChartXYZ::SetAxisColor
void SetAxisColor(const vtkColor4ub &color)
Set the color for the axes.
vtkChartXYZ::ScaleDownAxes
void ScaleDownAxes()
Scale down the axes when the scene gets smaller.
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
vtkChartXYZ::GetClippingPlaneEquation
void GetClippingPlaneEquation(int i, double *planeEquation)
Get the equation for the ith face of our bounding cube.
vtkChartXYZ::CheckForSceneResize
bool CheckForSceneResize()
Check to see if the scene changed size since the last render.
vtkChartXYZ::LookDownY
void LookDownY()
Adjust the rotation of the chart so that we are looking down the Y axis.
vtkChartXYZ::Hit
bool Hit(const vtkContextMouseEvent &mouse) override
Returns true if the transform is interactive, false otherwise.
vtkChartXYZ::VERTICAL
@ VERTICAL
Definition: vtkChartXYZ.h:303
vtkTextProperty.h
vtkChartXYZ::vtkChartXYZ
vtkChartXYZ()
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
vtkChartXYZ::MouseWheelEvent
bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta) override
Mouse wheel event.
vtkChartXYZ::CalculateTransforms
virtual void CalculateTransforms()
Calculate the transformation matrices used to draw data points and axes in the scene.
vtkChartXYZ::NewDetermineWhichAxesToLabel
void NewDetermineWhichAxesToLabel()
New style axis labelling, ensuring labelling is always at the edges of the chart in the most sensible...
vtkChartXYZ::GetOffsetForAxisLabel
void GetOffsetForAxisLabel(int axis, float *bounds, float *offset)
Compute how some text should be offset from an axis.
vtkChartXYZ::Update
void Update() override
Perform any updates to the item that may be necessary before rendering.
vtkChartXYZ::Zoom
bool Zoom(const vtkContextMouseEvent &mouse)
Zoom in or out on the data in response to a mouse movement.
vtkX3D::color
@ color
Definition: vtkX3D.h:227
vtkChartXYZ::SetAnnotationLink
virtual void SetAnnotationLink(vtkAnnotationLink *link)
Set the vtkAnnotationLink for the chart.
vtkChartXYZ::Rotate
bool Rotate(const vtkContextMouseEvent &mouse)
Rotate the chart in response to a mouse movement.
vtkChartXYZ::YAxisLabel
std::string YAxisLabel
The label for the Y Axis.
Definition: vtkChartXYZ.h:660
vtkChartXYZ::RIGHT
@ RIGHT
Definition: vtkChartXYZ.h:293
vtkChartXYZ::Link
vtkSmartPointer< vtkAnnotationLink > Link
This link is used to share selected points with other classes.
Definition: vtkChartXYZ.h:635
vtkX3D::offset
@ offset
Definition: vtkX3D.h:444
vtkChartXYZ::LookUpZ
void LookUpZ()
Adjust the rotation of the chart so that we are looking up the Z axis.
vtkChartXYZ::ZAxisLabel
std::string ZAxisLabel
The label for the Z Axis.
Definition: vtkChartXYZ.h:665
vtkChartXYZ::RecalculateTransform
void RecalculateTransform()
Use this chart's Geometry to set the endpoints of its axes.
vtkColor.h
vtkChartXYZ::ComputeDataBounds
void ComputeDataBounds()
Compute a bounding box for the data that is rendered within the axes.
vtkRect.h
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkChartXYZ::AxesTextProperty
vtkNew< vtkTextProperty > AxesTextProperty
The text properties of the axes.
Definition: vtkChartXYZ.h:650
vtkChartXYZ::New
static vtkChartXYZ * New()
vtkSmartPointer.h
vtkChartXYZ::Axes
std::vector< vtkSmartPointer< vtkAxis > > Axes
The 3 axes of this chart.
Definition: vtkChartXYZ.h:538
vtkNew< vtkTransform >
vtkChartXYZ::RescaleAxes
void RescaleAxes()
Scale the axes up or down in response to a scene resize.
vtkChartXYZ::DrawAxesLabels
void DrawAxesLabels(vtkContext2D *painter)
Label the axes.
vtkChartXYZ::~vtkChartXYZ
~vtkChartXYZ() override
vtkChartXYZ::MouseMoveEvent
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
vtkChartXYZ::Direction
Direction
The direction to data from an axis.
Definition: vtkChartXYZ.h:315
vtkChartXYZ::Plots
std::vector< vtkPlot3D * > Plots
The plots that are drawn within this chart.
Definition: vtkChartXYZ.h:640
vtkChartXYZ::SetFitToScene
void SetFitToScene(bool b)
Set whether or not the chart should automatically resize itself to fill the scene.
vtkChartXYZ::ContextTransform
vtkNew< vtkTransform > ContextTransform
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:573
vtkChartXYZ::NORTH_EAST
@ NORTH_EAST
Definition: vtkChartXYZ.h:317
vtkChartXYZ::Translation
vtkNew< vtkTransform > Translation
This transform keeps track of how the data points have been panned within the chart.
Definition: vtkChartXYZ.h:596
vtkChartXYZ::ClearPlots
void ClearPlots()
Remove all the plots from this chart.
vtkChartXYZ::SOUTH
@ SOUTH
Definition: vtkChartXYZ.h:320
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:143
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:53
vtkPlot3D
Abstract class for 3D plots.
Definition: vtkPlot3D.h:45
vtkChartXYZ::GetMarginBottom
std::size_t GetMarginBottom() const
Gets the current margin top in pixels irrespective of the size-strategy used.
vtkChartXYZ::LookUpX
void LookUpX()
Adjust the rotation of the chart so that we are looking up the X axis.
vtkChartXYZ::EAST
@ EAST
Definition: vtkChartXYZ.h:318
vtkChartXYZ::USE_MARGINS_AND_SCENE_SIZE
@ USE_MARGINS_AND_SCENE_SIZE
Definition: vtkChartXYZ.h:519
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkChartXYZ::BoundingCube
vtkNew< vtkPlaneCollection > BoundingCube
The six planes that define the bounding cube of our 3D axes.
Definition: vtkChartXYZ.h:676
vtkChartXYZ::LegacyDetermineWhichAxesToLabel
void LegacyDetermineWhichAxesToLabel()
Old-style axis labelling, for compatibility; labelling may occur in less optimal places e....
vtkChartXYZ::SetMargins
void SetMargins(const vtkVector4i &margins)
Set the margins in pixels ordered top right bottom left The box will be drawn inside those margins,...
vtkNew.h
vtkChartXYZ::SOUTH_EAST
@ SOUTH_EAST
Definition: vtkChartXYZ.h:319
vtkChartXYZ::SetDecorateAxes
void SetDecorateAxes(bool b)
Set whether or not axes labels & tick marks should be drawn.
vtkChartXYZ::FutureBox
vtkNew< vtkTransform > FutureBox
This transform is initialized as a copy of Box.
Definition: vtkChartXYZ.h:615
vtkChartXYZ::Rotate
bool Rotate(const RotateDirection rotateDirection)
Rotate the chart in a specific direction.
vtkChartXYZ::VERTICAL_2
@ VERTICAL_2
Definition: vtkChartXYZ.h:304
vtkChartXYZ::AxisPen
vtkNew< vtkPen > AxisPen
This is the pen that is used to draw the axes.
Definition: vtkChartXYZ.h:630
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:178
vtkChartXYZ::DrawTickMarks
void DrawTickMarks(vtkContext2D *painter)
Draw tick marks and tick mark labels along the axes.
vtkColor4ub
Definition: vtkColor.h:374
vtkChartXYZ::WEST
@ WEST
Definition: vtkChartXYZ.h:322
vtkChartXYZ::FutureBoxScale
vtkNew< vtkTransform > FutureBoxScale
This transform keeps track of the Scale of the FutureBox transform.
Definition: vtkChartXYZ.h:620
vtkContext3D
Class for drawing 3D primitives to a graphical context.
Definition: vtkContext3D.h:60
vtkChartXYZ::RotateDirection
RotateDirection
Rotation directions.
Definition: vtkChartXYZ.h:291
vtkChartXYZ::SceneHeight
int SceneHeight
The height of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:693
vtkPen
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:136
vtkPlaneCollection
maintain a list of planes
Definition: vtkPlaneCollection.h:53
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:105
vtkChartXYZ::SetClippingPlanesEnabled
void SetClippingPlanesEnabled(bool)
Hide data outside the box.
vtkChartXYZ::AxisState
AxisState
The state of an axis.
Definition: vtkChartXYZ.h:302
vtkChartXYZ::LookDownX
void LookDownX()
Adjust the rotation of the chart so that we are looking down the X axis.
vtkRectf
Definition: vtkRect.h:336
vtkChartXYZ::SetAxis
virtual void SetAxis(int axisIndex, vtkAxis *axis)
Set the x (0), y (1) or z (2) axis.
vtkVector4i
Definition: vtkVector.h:560
vtkChartXYZ::CalculateNiceMinMax
double CalculateNiceMinMax(double &min, double &max, int axis)
Calculate the next "nicest" numbers above and below the current minimum.
vtkChartXYZ::GetMarginLeft
std::size_t GetMarginLeft() const
Gets the current margin left in pixels irrespective of the size-strategy used.
vtkChartXYZ::GetPlotWidth
std::size_t GetPlotWidth() const
Gets the current width of the plot in pixels irrespective of the size-strategy used.
vtkChartXYZ::XAxisLabel
std::string XAxisLabel
The label for the X Axis.
Definition: vtkChartXYZ.h:655
vtkChartXYZ::LEFT
@ LEFT
Definition: vtkChartXYZ.h:292
vtkChartXYZ::SceneWidth
int SceneWidth
The weight of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:698