VTK
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 "vtkContextItem.h"
31 #include "vtkColor.h" // For vtkColor4ub
32 #include "vtkRect.h" // For vtkRectf ivars
33 #include "vtkNew.h" // For ivars
34 #include "vtkSmartPointer.h" // For ivars
35 #include <vector> // For ivars
36 
37 class vtkAnnotationLink;
38 class vtkAxis;
39 class vtkContext3D;
41 class vtkPen;
42 class vtkPlaneCollection;
43 class vtkPlot3D;
44 class vtkTable;
45 class vtkTransform;
47 
48 class VTKCHARTSCORE_EXPORT vtkChartXYZ : public vtkContextItem
49 {
50 public:
51  vtkTypeMacro(vtkChartXYZ, vtkContextItem);
52  void PrintSelf(ostream &os, vtkIndent indent) override;
53 
54  static vtkChartXYZ * New();
55 
62  void SetGeometry(const vtkRectf &bounds);
63 
67  void SetAngle(double angle);
68 
72  void SetAroundX(bool isX);
73 
77  virtual void SetAnnotationLink(vtkAnnotationLink *link);
78 
82  vtkAxis * GetAxis(int axis);
83 
84 
88  virtual void SetAxis(int axisIndex, vtkAxis* axis);
89 
90 
92 
98 
103  void SetAutoRotate(bool b);
104 
109  void SetDecorateAxes(bool b);
110 
115  void SetFitToScene(bool b);
116 
120  void Update() override;
121 
125  bool Paint(vtkContext2D *painter) override;
126 
130  virtual vtkIdType AddPlot(vtkPlot3D* plot);
131 
135  void ClearPlots();
136 
142 
149 
153  bool Hit(const vtkContextMouseEvent &mouse) override;
154 
158  bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override;
159 
163  bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override;
164 
168  bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta) override;
169 
175  bool KeyPressEvent(const vtkContextKeyEvent &key) override;
176 
177 protected:
179  ~vtkChartXYZ() override;
180 
186  virtual void CalculateTransforms();
187 
195  vtkTransform *transform);
196 
200  bool Rotate(const vtkContextMouseEvent &mouse);
201 
205  bool Pan(const vtkContextMouseEvent &mouse);
206 
210  bool Zoom(const vtkContextMouseEvent &mouse);
211 
215  bool Spin(const vtkContextMouseEvent &mouse);
216 
220  void LookDownX();
221 
225  void LookDownY();
226 
230  void LookDownZ();
231 
235  void LookUpX();
236 
240  void LookUpY();
241 
245  void LookUpZ();
246 
251 
255  void RescaleAxes();
256 
260  void ScaleUpAxes();
261 
266 
270  void ZoomAxes(int delta);
271 
277 
288 
293 
297  void DrawAxes(vtkContext3D *context);
298 
304 
308  void DrawTickMarks(vtkContext2D *painter);
309 
313  void DrawAxesLabels(vtkContext2D *painter);
314 
320  void GetOffsetForAxisLabel(int axis, float *bounds, float *offset);
321 
327  double CalculateNiceMinMax(double &min, double &max, int axis);
328 
332  void GetClippingPlaneEquation(int i, double *planeEquation);
333 
338 
342  std::vector< vtkSmartPointer<vtkAxis> > Axes;
343 
349 
354  bool IsX;
355 
360  double Angle;
361 
367 
373 
378 
385 
390 
395 
401 
407 
413 
420 
425 
430 
435 
440 
444  std::vector<vtkPlot3D *> Plots;
445 
450 
455 
460 
465 
470  float AxesBoundaryPoints[14][3];
471 
476  float TickLabelOffset[3][2];
477 
482 
487 
489 
492  int XAxisToLabel[3];
493  int YAxisToLabel[3];
494  int ZAxisToLabel[3];
496 
500  int DirectionToData[3];
501 
505  double DataBounds[4];
506 
507 private:
508  vtkChartXYZ(const vtkChartXYZ &) = delete;
509  void operator=(const vtkChartXYZ &) = delete;
510 };
511 
512 #endif
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:406
vtkChartXYZ::ScaleUpAxes
void ScaleUpAxes()
Scale up the axes when the scene gets larger.
vtkChartXYZ::Box
vtkNew< vtkTransform > Box
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:389
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:429
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:41
vtkChartXYZ::BoxScale
vtkNew< vtkTransform > BoxScale
This transform keeps track of how the axes have been scaled (zoomed in or zoomed out).
Definition: vtkChartXYZ.h:412
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:394
vtkChartXYZ::InitializeAxesBoundaryPoints
void InitializeAxesBoundaryPoints()
Initialize a list of "test points".
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkChartXYZ::ZoomAxes
void ZoomAxes(int delta)
Change the scaling of the axes by a specified amount.
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:384
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:69
vtkX3D::key
@ key
Definition: vtkX3D.h:257
vtkChartXYZ::Axes
std::vector< vtkSmartPointer< vtkAxis > > Axes
The 3 axes of this chart.
Definition: vtkChartXYZ.h:342
vtkChartXYZ::IsX
bool IsX
When we're in AutoRotate mode, this boolean tells us if we should rotate about the X axis or the Y ax...
Definition: vtkChartXYZ.h:354
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:49
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:42
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::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:59
vtkChartXYZ::GetAxis
vtkAxis * GetAxis(int axis)
Get the x (0), y (1) or z (2) axis.
vtkChartXYZ::GetAxisColor
vtkColor4ub GetAxisColor()
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:61
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::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::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:221
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:454
vtkChartXYZ::Link
vtkSmartPointer< vtkAnnotationLink > Link
This link is used to share selected points with other classes.
Definition: vtkChartXYZ.h:439
vtkX3D::offset
@ offset
Definition: vtkX3D.h:438
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:459
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:40
vtkChartXYZ::New
static vtkChartXYZ * New()
vtkSmartPointer.h
vtkNew< vtkTransform >
vtkChartXYZ::Geometry
vtkRectf Geometry
The size and position of this chart.
Definition: vtkChartXYZ.h:337
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::Angle
double Angle
When we're in AutoRotate mode, this value tells the chart how much it should be rotated.
Definition: vtkChartXYZ.h:360
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:377
vtkChartXYZ::Translation
vtkNew< vtkTransform > Translation
This transform keeps track of how the data points have been panned within the chart.
Definition: vtkChartXYZ.h:400
vtkChartXYZ::FitToScene
bool FitToScene
This boolean indicates whether or not we should automatically resize the chart so that it snugly fill...
Definition: vtkChartXYZ.h:372
vtkChartXYZ::ClearPlots
void ClearPlots()
Remove all the plots from this chart.
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:35
vtkPlot3D
Abstract class for 3D plots.
Definition: vtkPlot3D.h:45
vtkChartXYZ::LookUpX
void LookUpX()
Adjust the rotation of the chart so that we are looking up the X axis.
vtkX3D::string
@ string
Definition: vtkX3D.h:490
vtkChartXYZ::BoundingCube
vtkNew< vtkPlaneCollection > BoundingCube
The six planes that define the bounding cube of our 3D axes.
Definition: vtkChartXYZ.h:464
vtkChartXYZ::Plots
std::vector< vtkPlot3D * > Plots
The plots that are drawn within this chart.
Definition: vtkChartXYZ.h:444
vtkNew.h
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:419
vtkChartXYZ::AxisPen
vtkNew< vtkPen > AxisPen
This is the pen that is used to draw the axes.
Definition: vtkChartXYZ.h:434
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:72
vtkChartXYZ::DrawTickMarks
void DrawTickMarks(vtkContext2D *painter)
Draw tick marks and tick mark labels along the axes.
vtkColor4ub
Definition: vtkColor.h:241
vtkChartXYZ::FutureBoxScale
vtkNew< vtkTransform > FutureBoxScale
This transform keeps track of the Scale of the FutureBox transform.
Definition: vtkChartXYZ.h:424
vtkContext3D
Class for drawing 3D primitives to a graphical context.
Definition: vtkContext3D.h:41
vtkChartXYZ::SetAngle
void SetAngle(double angle)
Set the rotation angle for the chart (AutoRotate mode only).
vtkChartXYZ::SceneHeight
int SceneHeight
The height of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:481
vtkPen
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:40
vtkPlaneCollection
maintain a list of planes
Definition: vtkPlaneCollection.h:37
vtkChartXYZ::DrawAxesDecoration
bool DrawAxesDecoration
This boolean indicates whether or not we should draw tick marks and axes labels.
Definition: vtkChartXYZ.h:366
vtkChartXYZ::LookDownX
void LookDownX()
Adjust the rotation of the chart so that we are looking down the X axis.
vtkRectf
Definition: vtkRect.h:333
vtkChartXYZ::SetAxis
virtual void SetAxis(int axisIndex, vtkAxis *axis)
Set the x (0), y (1) or z (2) axis.
vtkChartXYZ::SetAutoRotate
void SetAutoRotate(bool b)
Set whether or not we're using this chart to rotate on a timer.
vtkChartXYZ::CalculateNiceMinMax
double CalculateNiceMinMax(double &min, double &max, int axis)
Calculate the next "nicest" numbers above and below the current minimum.
vtkChartXYZ::XAxisLabel
std::string XAxisLabel
The label for the X Axis.
Definition: vtkChartXYZ.h:449
vtkChartXYZ::AutoRotate
bool AutoRotate
This boolean indicates whether or not we're using this chart to rotate on a timer.
Definition: vtkChartXYZ.h:348
vtkChartXYZ::SceneWidth
int SceneWidth
The weight of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:486