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 
95  void SetAxisColor(const vtkColor4ub& color);
96  vtkColor4ub GetAxisColor();
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 
141  void RecalculateBounds();
142 
148  void RecalculateTransform();
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:
178  vtkChartXYZ();
179  ~vtkChartXYZ() override;
180 
186  virtual void CalculateTransforms();
187 
194  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y, vtkAxis *z,
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 
250  bool CheckForSceneResize();
251 
255  void RescaleAxes();
256 
260  void ScaleUpAxes();
261 
265  void ScaleDownAxes();
266 
270  void ZoomAxes(int delta);
271 
276  void InitializeAxesBoundaryPoints();
277 
287  void InitializeFutureBox();
288 
292  void ComputeDataBounds();
293 
297  void DrawAxes(vtkContext3D *context);
298 
303  void DetermineWhichAxesToLabel();
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
int SceneHeight
The height of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:481
std::vector< vtkSmartPointer< vtkAxis > > Axes
The 3 axes of this chart.
Definition: vtkChartXYZ.h:342
bool AutoRotate
This boolean indicates whether or not we&#39;re using this chart to rotate on a timer.
Definition: vtkChartXYZ.h:348
data structure to represent key events.
int SceneWidth
The weight of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:486
vtkNew< vtkTransform > PlotTransform
This transform translates and scales the plots&#39; data points so that they appear within the axes of th...
Definition: vtkChartXYZ.h:384
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:406
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:394
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
int vtkIdType
Definition: vtkType.h:347
bool IsX
When we&#39;re in AutoRotate mode, this boolean tells us if we should rotate about the X axis or the Y ax...
Definition: vtkChartXYZ.h:354
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:58
vtkRectf Geometry
The size and position of this chart.
Definition: vtkChartXYZ.h:337
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.
double Angle
When we&#39;re in AutoRotate mode, this value tells the chart how much it should be rotated.
Definition: vtkChartXYZ.h:360
a simple class to control print indentation
Definition: vtkIndent.h:39
std::string YAxisLabel
The label for the Y Axis.
Definition: vtkChartXYZ.h:454
std::string ZAxisLabel
The label for the Z Axis.
Definition: vtkChartXYZ.h:459
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:400
vtkSmartPointer< vtkAnnotationLink > Link
This link is used to share selected points with other classes.
Definition: vtkChartXYZ.h:439
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:68
vtkNew< vtkPen > AxisPen
This is the pen that is used to draw the axes.
Definition: vtkChartXYZ.h:434
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:377
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:372
std::string XAxisLabel
The label for the X Axis.
Definition: vtkChartXYZ.h:449
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:464
vtkNew< vtkTransform > BoxScale
This transform keeps track of how the axes have been scaled (zoomed in or zoomed out).
Definition: vtkChartXYZ.h:412
std::vector< vtkPlot3D * > Plots
The plots that are drawn within this chart.
Definition: vtkChartXYZ.h:444
Factory class for drawing 3D XYZ charts.
Definition: vtkChartXYZ.h:48
vtkNew< vtkTransform > FutureBox
This transform is initialized as a copy of Box.
Definition: vtkChartXYZ.h:419
bool DrawAxesDecoration
This boolean indicates whether or not we should draw tick marks and axes labels.
Definition: vtkChartXYZ.h:366
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:424
vtkNew< vtkTransform > Box
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:389
vtkNew< vtkPen > Pen
This is the pen that is used to draw data from the plots.
Definition: vtkChartXYZ.h:429
Class for drawing 3D primitives to a graphical context.
Definition: vtkContext3D.h:40