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  virtual void PrintSelf(ostream &os, vtkIndent indent);
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 
85 
88  void SetAxisColor(const vtkColor4ub& color);
89  vtkColor4ub GetAxisColor();
91 
96  void SetAutoRotate(bool b);
97 
102  void SetDecorateAxes(bool b);
103 
108  void SetFitToScene(bool b);
109 
113  virtual void Update();
114 
118  virtual bool Paint(vtkContext2D *painter);
119 
123  virtual vtkIdType AddPlot(vtkPlot3D* plot);
124 
128  void ClearPlots();
129 
134  void RecalculateBounds();
135 
141  void RecalculateTransform();
142 
146  virtual bool Hit(const vtkContextMouseEvent &mouse);
147 
151  virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse);
152 
156  virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse);
157 
161  virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta);
162 
168  virtual bool KeyPressEvent(const vtkContextKeyEvent &key);
169 
170 protected:
171  vtkChartXYZ();
172  ~vtkChartXYZ();
173 
179  virtual void CalculateTransforms();
180 
187  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y, vtkAxis *z,
188  vtkTransform *transform);
189 
193  bool Rotate(const vtkContextMouseEvent &mouse);
194 
198  bool Pan(const vtkContextMouseEvent &mouse);
199 
203  bool Zoom(const vtkContextMouseEvent &mouse);
204 
208  bool Spin(const vtkContextMouseEvent &mouse);
209 
213  void LookDownX();
214 
218  void LookDownY();
219 
223  void LookDownZ();
224 
228  void LookUpX();
229 
233  void LookUpY();
234 
238  void LookUpZ();
239 
243  bool CheckForSceneResize();
244 
248  void RescaleAxes();
249 
253  void ScaleUpAxes();
254 
258  void ScaleDownAxes();
259 
263  void ZoomAxes(int delta);
264 
269  void InitializeAxesBoundaryPoints();
270 
280  void InitializeFutureBox();
281 
285  void ComputeDataBounds();
286 
290  void DrawAxes(vtkContext3D *context);
291 
296  void DetermineWhichAxesToLabel();
297 
301  void DrawTickMarks(vtkContext2D *painter);
302 
306  void DrawAxesLabels(vtkContext2D *painter);
307 
313  void GetOffsetForAxisLabel(int axis, float *bounds, float *offset);
314 
320  double CalculateNiceMinMax(double &min, double &max, int axis);
321 
325  void GetClippingPlaneEquation(int i, double *planeEquation);
326 
331 
335  std::vector< vtkSmartPointer<vtkAxis> > Axes;
336 
342 
347  bool IsX;
348 
353  double Angle;
354 
360 
366 
371 
378 
383 
388 
394 
400 
406 
413 
418 
423 
428 
433 
437  std::vector<vtkPlot3D *> Plots;
438 
443 
448 
453 
458 
463  float AxesBoundaryPoints[14][3];
464 
469  float TickLabelOffset[3][2];
470 
475 
480 
482 
485  int XAxisToLabel[3];
486  int YAxisToLabel[3];
487  int ZAxisToLabel[3];
489 
493  int DirectionToData[3];
494 
498  double DataBounds[4];
499 
500 private:
501  vtkChartXYZ(const vtkChartXYZ &) VTK_DELETE_FUNCTION;
502  void operator=(const vtkChartXYZ &) VTK_DELETE_FUNCTION;
503 };
504 
505 #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:399
vtkChartXYZ::Box
vtkNew< vtkTransform > Box
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:382
vtkChartXYZ::Pen
vtkNew< vtkPen > Pen
This is the pen that is used to draw data from the plots.
Definition: vtkChartXYZ.h:422
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:40
vtkChartXYZ::BoxScale
vtkNew< vtkTransform > BoxScale
This transform keeps track of how the axes have been scaled (zoomed in or zoomed out).
Definition: vtkChartXYZ.h:405
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:387
vtkIdType
int vtkIdType
Definition: vtkType.h:287
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:377
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:68
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkX3D::key
Definition: vtkX3D.h:257
vtkChartXYZ::Axes
std::vector< vtkSmartPointer< vtkAxis > > Axes
The 3 axes of this chart.
Definition: vtkChartXYZ.h:335
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:347
vtkAbstractContextItem::KeyPressEvent
virtual bool KeyPressEvent(const vtkContextKeyEvent &key)
Key press event.
vtkChartXYZ
Factory class for drawing 3D XYZ charts.
Definition: vtkChartXYZ.h:48
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:41
vtkSmartPointer< vtkAnnotationLink >
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:57
vtkContextItem.h
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
vtkX3D::color
Definition: vtkX3D.h:221
vtkChartXYZ::YAxisLabel
std::string YAxisLabel
The label for the Y Axis.
Definition: vtkChartXYZ.h:447
vtkChartXYZ::Link
vtkSmartPointer< vtkAnnotationLink > Link
This link is used to share selected points with other classes.
Definition: vtkChartXYZ.h:432
vtkX3D::offset
Definition: vtkX3D.h:438
vtkChartXYZ::ZAxisLabel
std::string ZAxisLabel
The label for the Z Axis.
Definition: vtkChartXYZ.h:452
vtkColor.h
vtkRect.h
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkAbstractContextItem::Hit
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
vtkSmartPointer.h
vtkNew< vtkTransform >
vtkChartXYZ::Geometry
vtkRectf Geometry
The size and position of this chart.
Definition: vtkChartXYZ.h:330
vtkChartXYZ::Angle
double Angle
When we're in AutoRotate mode, this value tells the chart how much it should be rotated.
Definition: vtkChartXYZ.h:353
vtkAbstractContextItem::MouseMoveEvent
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
vtkChartXYZ::ContextTransform
vtkNew< vtkTransform > ContextTransform
This is the transform that is applied when rendering data from the plots.
Definition: vtkChartXYZ.h:370
vtkChartXYZ::Translation
vtkNew< vtkTransform > Translation
This transform keeps track of how the data points have been panned within the chart.
Definition: vtkChartXYZ.h:393
vtkChartXYZ::FitToScene
bool FitToScene
This boolean indicates whether or not we should automatically resize the chart so that it snugly fill...
Definition: vtkChartXYZ.h:365
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:34
vtkPlot3D
Abstract class for 3D plots.
Definition: vtkPlot3D.h:44
vtkX3D::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:457
vtkChartXYZ::Plots
std::vector< vtkPlot3D * > Plots
The plots that are drawn within this chart.
Definition: vtkChartXYZ.h:437
vtkNew.h
vtkChartXYZ::FutureBox
vtkNew< vtkTransform > FutureBox
This transform is initialized as a copy of Box.
Definition: vtkChartXYZ.h:412
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:427
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:71
vtkColor4ub
Definition: vtkColor.h:240
vtkChartXYZ::FutureBoxScale
vtkNew< vtkTransform > FutureBoxScale
This transform keeps track of the Scale of the FutureBox transform.
Definition: vtkChartXYZ.h:417
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:474
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:39
vtkPlaneCollection
maintain a list of planes
Definition: vtkPlaneCollection.h:36
vtkChartXYZ::DrawAxesDecoration
bool DrawAxesDecoration
This boolean indicates whether or not we should draw tick marks and axes labels.
Definition: vtkChartXYZ.h:359
vtkContextItem::PrintSelf
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkRectf
Definition: vtkRect.h:296
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:442
vtkChartXYZ::AutoRotate
bool AutoRotate
This boolean indicates whether or not we're using this chart to rotate on a timer.
Definition: vtkChartXYZ.h:341
vtkChartXYZ::SceneWidth
int SceneWidth
The weight of the scene, as of the most recent call to Paint().
Definition: vtkChartXYZ.h:479