VTK  9.0.1
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 
23 #ifndef vtkChartXYZ_h
24 #define vtkChartXYZ_h
25 
26 #include "vtkChartsCoreModule.h" // For export macro
27 #include "vtkColor.h" // For vtkColor4ub
28 #include "vtkContextItem.h"
29 #include "vtkNew.h" // For ivars
30 #include "vtkRect.h" // For vtkRectf ivars
31 #include "vtkSmartPointer.h" // For ivars
32 #include <vector> // For ivars
33 
34 class vtkAnnotationLink;
35 class vtkAxis;
36 class vtkContext3D;
38 class vtkPen;
39 class vtkPlaneCollection;
40 class vtkPlot3D;
41 class vtkTable;
42 class vtkTransform;
44 
45 class VTKCHARTSCORE_EXPORT vtkChartXYZ : public vtkContextItem
46 {
47 public:
48  vtkTypeMacro(vtkChartXYZ, vtkContextItem);
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
51  static vtkChartXYZ* New();
52 
59  void SetGeometry(const vtkRectf& bounds);
60 
64  void SetAngle(double angle);
65 
69  void SetAroundX(bool isX);
70 
74  virtual void SetAnnotationLink(vtkAnnotationLink* link);
75 
79  vtkAxis* GetAxis(int axis);
80 
84  virtual void SetAxis(int axisIndex, vtkAxis* axis);
85 
87 
90  void SetAxisColor(const vtkColor4ub& color);
91  vtkColor4ub GetAxisColor();
93 
98  void SetAutoRotate(bool b);
99 
104  void SetDecorateAxes(bool b);
105 
110  void SetFitToScene(bool b);
111 
115  void Update() override;
116 
120  bool Paint(vtkContext2D* painter) override;
121 
125  virtual vtkIdType AddPlot(vtkPlot3D* plot);
126 
130  void ClearPlots();
131 
136  void RecalculateBounds();
137 
143  void RecalculateTransform();
144 
148  bool Hit(const vtkContextMouseEvent& mouse) override;
149 
153  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
154 
158  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
159 
163  bool MouseWheelEvent(const vtkContextMouseEvent& mouse, int delta) override;
164 
170  bool KeyPressEvent(const vtkContextKeyEvent& key) override;
171 
172 protected:
173  vtkChartXYZ();
174  ~vtkChartXYZ() override;
175 
181  virtual void CalculateTransforms();
182 
189  bool CalculatePlotTransform(vtkAxis* x, vtkAxis* y, vtkAxis* z, vtkTransform* transform);
190 
194  bool Rotate(const vtkContextMouseEvent& mouse);
195 
199  bool Pan(const vtkContextMouseEvent& mouse);
200 
204  bool Zoom(const vtkContextMouseEvent& mouse);
205 
209  bool Spin(const vtkContextMouseEvent& mouse);
210 
214  void LookDownX();
215 
219  void LookDownY();
220 
224  void LookDownZ();
225 
229  void LookUpX();
230 
234  void LookUpY();
235 
239  void LookUpZ();
240 
244  bool CheckForSceneResize();
245 
249  void RescaleAxes();
250 
254  void ScaleUpAxes();
255 
259  void ScaleDownAxes();
260 
264  void ZoomAxes(int delta);
265 
270  void InitializeAxesBoundaryPoints();
271 
281  void InitializeFutureBox();
282 
286  void ComputeDataBounds();
287 
291  void DrawAxes(vtkContext3D* context);
292 
297  void DetermineWhichAxesToLabel();
298 
302  void DrawTickMarks(vtkContext2D* painter);
303 
307  void DrawAxesLabels(vtkContext2D* painter);
308 
314  void GetOffsetForAxisLabel(int axis, float* bounds, float* offset);
315 
321  double CalculateNiceMinMax(double& min, double& max, int axis);
322 
326  void GetClippingPlaneEquation(int i, double* planeEquation);
327 
332 
336  std::vector<vtkSmartPointer<vtkAxis> > Axes;
337 
343 
348  bool IsX;
349 
354  double Angle;
355 
361 
367 
372 
379 
384 
389 
395 
401 
407 
414 
419 
424 
429 
434 
438  std::vector<vtkPlot3D*> Plots;
439 
444 
449 
454 
459 
464  float AxesBoundaryPoints[14][3];
465 
470  float TickLabelOffset[3][2];
471 
476 
481 
483 
486  int XAxisToLabel[3];
487  int YAxisToLabel[3];
488  int ZAxisToLabel[3];
490 
494  int DirectionToData[3];
495 
499  double DataBounds[4];
500 
501 private:
502  vtkChartXYZ(const vtkChartXYZ&) = delete;
503  void operator=(const vtkChartXYZ&) = delete;
504 };
505 
506 #endif
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:400
vtkChartXYZ::Box
vtkNew< vtkTransform > Box
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:383
vtkChartXYZ::Pen
vtkNew< vtkPen > Pen
This is the pen that is used to draw data from the plots.
Definition: vtkChartXYZ.h:423
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:34
vtkChartXYZ::BoxScale
vtkNew< vtkTransform > BoxScale
This transform keeps track of how the axes have been scaled (zoomed in or zoomed out).
Definition: vtkChartXYZ.h:406
vtkContextKeyEvent
data structure to represent key events.
Definition: vtkContextKeyEvent.h:34
vtkChartXYZ::Rotation
vtkNew< vtkTransform > Rotation
This transform keeps track of how the chart has been rotated.
Definition: vtkChartXYZ.h:388
vtkIdType
int vtkIdType
Definition: vtkType.h:338
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:378
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:62
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkX3D::key
@ key
Definition: vtkX3D.h:263
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:348
vtkAbstractContextItem::KeyPressEvent
virtual bool KeyPressEvent(const vtkContextKeyEvent &key)
Key press event.
vtkChartXYZ
Factory class for drawing 3D XYZ charts.
Definition: vtkChartXYZ.h:45
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:35
vtkSmartPointer< vtkAnnotationLink >
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
vtkContextItem.h
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
vtkX3D::color
@ color
Definition: vtkX3D.h:227
vtkChartXYZ::YAxisLabel
std::string YAxisLabel
The label for the Y Axis.
Definition: vtkChartXYZ.h:448
vtkChartXYZ::Link
vtkSmartPointer< vtkAnnotationLink > Link
This link is used to share selected points with other classes.
Definition: vtkChartXYZ.h:433
vtkX3D::offset
@ offset
Definition: vtkX3D.h:444
vtkChartXYZ::ZAxisLabel
std::string ZAxisLabel
The label for the Z Axis.
Definition: vtkChartXYZ.h:453
vtkColor.h
vtkRect.h
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkAbstractContextItem::Hit
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
vtkSmartPointer.h
vtkChartXYZ::Axes
std::vector< vtkSmartPointer< vtkAxis > > Axes
The 3 axes of this chart.
Definition: vtkChartXYZ.h:336
vtkNew< vtkTransform >
vtkContextItem::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkChartXYZ::Geometry
vtkRectf Geometry
The size and position of this chart.
Definition: vtkChartXYZ.h:331
vtkChartXYZ::Angle
double Angle
When we're in AutoRotate mode, this value tells the chart how much it should be rotated.
Definition: vtkChartXYZ.h:354
vtkAbstractContextItem::MouseMoveEvent
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
vtkChartXYZ::Plots
std::vector< vtkPlot3D * > Plots
The plots that are drawn within this chart.
Definition: vtkChartXYZ.h:438
vtkChartXYZ::ContextTransform
vtkNew< vtkTransform > ContextTransform
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:371
vtkChartXYZ::Translation
vtkNew< vtkTransform > Translation
This transform keeps track of how the data points have been panned within the chart.
Definition: vtkChartXYZ.h:394
vtkChartXYZ::FitToScene
bool FitToScene
This boolean indicates whether or not we should automatically resize the chart so that it snugly fill...
Definition: vtkChartXYZ.h:366
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:31
vtkPlot3D
Abstract class for 3D plots.
Definition: vtkPlot3D.h:44
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:458
vtkNew.h
vtkChartXYZ::FutureBox
vtkNew< vtkTransform > FutureBox
This transform is initialized as a copy of Box.
Definition: vtkChartXYZ.h:413
vtkAbstractContextItem::Paint
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
vtkChartXYZ::AxisPen
vtkNew< vtkPen > AxisPen
This is the pen that is used to draw the axes.
Definition: vtkChartXYZ.h:428
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:68
vtkColor4ub
Definition: vtkColor.h:264
vtkChartXYZ::FutureBoxScale
vtkNew< vtkTransform > FutureBoxScale
This transform keeps track of the Scale of the FutureBox transform.
Definition: vtkChartXYZ.h:418
vtkContext3D
Class for drawing 3D primitives to a graphical context.
Definition: vtkContext3D.h:40
vtkChartXYZ::SceneHeight
int SceneHeight
The height of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:475
vtkAbstractContextItem::MouseButtonPressEvent
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...
vtkPen
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:36
vtkPlaneCollection
maintain a list of planes
Definition: vtkPlaneCollection.h:33
vtkChartXYZ::DrawAxesDecoration
bool DrawAxesDecoration
This boolean indicates whether or not we should draw tick marks and axes labels.
Definition: vtkChartXYZ.h:360
vtkRectf
Definition: vtkRect.h:326
vtkAbstractContextItem::MouseWheelEvent
virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta)
Mouse wheel event, positive delta indicates forward movement of the wheel.
vtkAbstractContextItem::Update
virtual void Update()
Perform any updates to the item that may be necessary before rendering.
vtkChartXYZ::XAxisLabel
std::string XAxisLabel
The label for the X Axis.
Definition: vtkChartXYZ.h:443
vtkChartXYZ::AutoRotate
bool AutoRotate
This boolean indicates whether or not we're using this chart to rotate on a timer.
Definition: vtkChartXYZ.h:342
vtkChartXYZ::SceneWidth
int SceneWidth
The weight of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:480