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 
23 #ifndef vtkChartXYZ_h
24 #define vtkChartXYZ_h
25 
26 #include "vtkChartsCoreModule.h" // For export macro
27 #include "vtkContextItem.h"
28 #include "vtkColor.h" // For vtkColor4ub
29 #include "vtkRect.h" // For vtkRectf ivars
30 #include "vtkNew.h" // For 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 
81 
85  virtual void SetAxis(int axisIndex, vtkAxis* axis);
86 
87 
89 
92  void SetAxisColor(const vtkColor4ub& color);
93  vtkColor4ub GetAxisColor();
95 
100  void SetAutoRotate(bool b);
101 
106  void SetDecorateAxes(bool b);
107 
112  void SetFitToScene(bool b);
113 
117  void Update() override;
118 
122  bool Paint(vtkContext2D *painter) override;
123 
127  virtual vtkIdType AddPlot(vtkPlot3D* plot);
128 
132  void ClearPlots();
133 
138  void RecalculateBounds();
139 
145  void RecalculateTransform();
146 
150  bool Hit(const vtkContextMouseEvent &mouse) override;
151 
155  bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override;
156 
160  bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override;
161 
165  bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta) override;
166 
172  bool KeyPressEvent(const vtkContextKeyEvent &key) override;
173 
174 protected:
175  vtkChartXYZ();
176  ~vtkChartXYZ() override;
177 
183  virtual void CalculateTransforms();
184 
191  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y, vtkAxis *z,
192  vtkTransform *transform);
193 
197  bool Rotate(const vtkContextMouseEvent &mouse);
198 
202  bool Pan(const vtkContextMouseEvent &mouse);
203 
207  bool Zoom(const vtkContextMouseEvent &mouse);
208 
212  bool Spin(const vtkContextMouseEvent &mouse);
213 
217  void LookDownX();
218 
222  void LookDownY();
223 
227  void LookDownZ();
228 
232  void LookUpX();
233 
237  void LookUpY();
238 
242  void LookUpZ();
243 
247  bool CheckForSceneResize();
248 
252  void RescaleAxes();
253 
257  void ScaleUpAxes();
258 
262  void ScaleDownAxes();
263 
267  void ZoomAxes(int delta);
268 
273  void InitializeAxesBoundaryPoints();
274 
284  void InitializeFutureBox();
285 
289  void ComputeDataBounds();
290 
294  void DrawAxes(vtkContext3D *context);
295 
300  void DetermineWhichAxesToLabel();
301 
305  void DrawTickMarks(vtkContext2D *painter);
306 
310  void DrawAxesLabels(vtkContext2D *painter);
311 
317  void GetOffsetForAxisLabel(int axis, float *bounds, float *offset);
318 
324  double CalculateNiceMinMax(double &min, double &max, int axis);
325 
329  void GetClippingPlaneEquation(int i, double *planeEquation);
330 
335 
339  std::vector< vtkSmartPointer<vtkAxis> > Axes;
340 
346 
351  bool IsX;
352 
357  double Angle;
358 
364 
370 
375 
382 
387 
392 
398 
404 
410 
417 
422 
427 
432 
437 
441  std::vector<vtkPlot3D *> Plots;
442 
447 
452 
457 
462 
467  float AxesBoundaryPoints[14][3];
468 
473  float TickLabelOffset[3][2];
474 
479 
484 
486 
489  int XAxisToLabel[3];
490  int YAxisToLabel[3];
491  int ZAxisToLabel[3];
493 
497  int DirectionToData[3];
498 
502  double DataBounds[4];
503 
504 private:
505  vtkChartXYZ(const vtkChartXYZ &) = delete;
506  void operator=(const vtkChartXYZ &) = delete;
507 };
508 
509 #endif
int SceneHeight
The height of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:478
std::vector< vtkSmartPointer< vtkAxis > > Axes
The 3 axes of this chart.
Definition: vtkChartXYZ.h:339
bool AutoRotate
This boolean indicates whether or not we're using this chart to rotate on a timer.
Definition: vtkChartXYZ.h:345
data structure to represent key events.
int SceneWidth
The weight of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:483
vtkNew< vtkTransform > PlotTransform
This transform translates and scales the plots' data points so that they appear within the axes of th...
Definition: vtkChartXYZ.h:381
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:403
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:391
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
int vtkIdType
Definition: vtkType.h:347
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:351
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
vtkRectf Geometry
The size and position of this chart.
Definition: vtkChartXYZ.h:334
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:68
data structure to represent mouse events.
double Angle
When we're in AutoRotate mode, this value tells the chart how much it should be rotated.
Definition: vtkChartXYZ.h:357
a simple class to control print indentation
Definition: vtkIndent.h:33
std::string YAxisLabel
The label for the Y Axis.
Definition: vtkChartXYZ.h:451
std::string ZAxisLabel
The label for the Z Axis.
Definition: vtkChartXYZ.h:456
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:36
vtkNew< vtkTransform > Translation
This transform keeps track of how the data points have been panned within the chart.
Definition: vtkChartXYZ.h:397
vtkSmartPointer< vtkAnnotationLink > Link
This link is used to share selected points with other classes.
Definition: vtkChartXYZ.h:436
virtual bool KeyPressEvent(const vtkContextKeyEvent &key)
Key press event.
dynamic, self-adjusting array of unsigned char
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:62
vtkNew< vtkPen > AxisPen
This is the pen that is used to draw the axes.
Definition: vtkChartXYZ.h:431
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:374
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
bool FitToScene
This boolean indicates whether or not we should automatically resize the chart so that it snugly fill...
Definition: vtkChartXYZ.h:369
std::string XAxisLabel
The label for the X Axis.
Definition: vtkChartXYZ.h:446
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:461
vtkNew< vtkTransform > BoxScale
This transform keeps track of how the axes have been scaled (zoomed in or zoomed out).
Definition: vtkChartXYZ.h:409
std::vector< vtkPlot3D * > Plots
The plots that are drawn within this chart.
Definition: vtkChartXYZ.h:441
Factory class for drawing 3D XYZ charts.
Definition: vtkChartXYZ.h:45
vtkNew< vtkTransform > FutureBox
This transform is initialized as a copy of Box.
Definition: vtkChartXYZ.h:416
bool DrawAxesDecoration
This boolean indicates whether or not we should draw tick marks and axes labels.
Definition: vtkChartXYZ.h:363
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:421
vtkNew< vtkTransform > Box
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:386
vtkNew< vtkPen > Pen
This is the pen that is used to draw data from the plots.
Definition: vtkChartXYZ.h:426
Class for drawing 3D primitives to a graphical context.
Definition: vtkContext3D.h:40