VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkChartXYZ.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 00025 #ifndef __vtkChartXYZ_h 00026 #define __vtkChartXYZ_h 00027 00028 #include "vtkChartsCoreModule.h" // For export macro 00029 #include "vtkContextItem.h" 00030 #include "vtkColor.h" // For vtkColor4ub 00031 #include "vtkRect.h" // For vtkRectf ivars 00032 #include "vtkNew.h" // For ivars 00033 #include "vtkSmartPointer.h" // For ivars 00034 #include <vector> // For ivars 00035 00036 class vtkAnnotationLink; 00037 class vtkAxis; 00038 class vtkContext3D; 00039 class vtkContextMouseEvent; 00040 class vtkPen; 00041 class vtkPlaneCollection; 00042 class vtkPlot3D; 00043 class vtkTable; 00044 class vtkTransform; 00045 class vtkUnsignedCharArray; 00046 00047 class VTKCHARTSCORE_EXPORT vtkChartXYZ : public vtkContextItem 00048 { 00049 public: 00050 vtkTypeMacro(vtkChartXYZ, vtkContextItem); 00051 virtual void PrintSelf(ostream &os, vtkIndent indent); 00052 00053 static vtkChartXYZ * New(); 00054 00059 void SetGeometry(const vtkRectf &bounds); 00060 00062 void SetAngle(double angle); 00063 00065 void SetAroundX(bool isX); 00066 00068 virtual void SetAnnotationLink(vtkAnnotationLink *link); 00069 00071 vtkAxis * GetAxis(int axis); 00072 00074 00075 void SetAxisColor(const vtkColor4ub& color); 00076 vtkColor4ub GetAxisColor(); 00078 00081 void SetAutoRotate(bool b); 00082 00085 void SetDecorateAxes(bool b); 00086 00089 void SetFitToScene(bool b); 00090 00093 virtual void Update(); 00094 00097 virtual bool Paint(vtkContext2D *painter); 00098 00100 virtual vtkIdType AddPlot(vtkPlot3D* plot); 00101 00103 void ClearPlots(); 00104 00107 void RecalculateBounds(); 00108 00112 void RecalculateTransform(); 00113 00114 //BTX 00116 virtual bool Hit(const vtkContextMouseEvent &mouse); 00117 00119 virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse); 00120 00123 virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse); 00124 00126 virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta); 00127 00129 00132 virtual bool KeyPressEvent(const vtkContextKeyEvent &key); 00133 //ETX 00135 00136 protected: 00137 vtkChartXYZ(); 00138 ~vtkChartXYZ(); 00139 00143 virtual void CalculateTransforms(); 00144 00146 00150 bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y, vtkAxis *z, 00151 vtkTransform *transform); 00153 00155 bool Rotate(const vtkContextMouseEvent &mouse); 00156 00158 bool Pan(const vtkContextMouseEvent &mouse); 00159 00161 bool Zoom(const vtkContextMouseEvent &mouse); 00162 00164 bool Spin(const vtkContextMouseEvent &mouse); 00165 00168 void LookDownX(); 00169 00172 void LookDownY(); 00173 00176 void LookDownZ(); 00177 00180 void LookUpX(); 00181 00184 void LookUpY(); 00185 00188 void LookUpZ(); 00189 00191 bool CheckForSceneResize(); 00192 00194 void RescaleAxes(); 00195 00197 void ScaleUpAxes(); 00198 00200 void ScaleDownAxes(); 00201 00203 void ZoomAxes(int delta); 00204 00208 void InitializeAxesBoundaryPoints(); 00209 00217 void InitializeFutureBox(); 00218 00220 void ComputeDataBounds(); 00221 00223 void DrawAxes(vtkContext3D *context); 00224 00227 void DetermineWhichAxesToLabel(); 00228 00230 void DrawTickMarks(vtkContext2D *painter); 00231 00233 void DrawAxesLabels(vtkContext2D *painter); 00234 00238 void GetOffsetForAxisLabel(int axis, float *bounds, float *offset); 00239 00243 double CalculateNiceMinMax(double &min, double &max, int axis); 00244 00246 void GetClippingPlaneEquation(int i, double *planeEquation); 00247 00249 vtkRectf Geometry; 00250 00252 std::vector< vtkSmartPointer<vtkAxis> > Axes; 00253 00256 bool AutoRotate; 00257 00260 bool IsX; 00261 00264 double Angle; 00265 00268 bool DrawAxesDecoration; 00269 00272 bool FitToScene; 00273 00276 vtkNew<vtkTransform> ContextTransform; 00277 00281 vtkNew<vtkTransform> PlotTransform; 00282 00285 vtkNew<vtkTransform> Box; 00286 00288 vtkNew<vtkTransform> Rotation; 00289 00292 vtkNew<vtkTransform> Translation; 00293 00296 vtkNew<vtkTransform> Scale; 00297 00300 vtkNew<vtkTransform> BoxScale; 00301 00305 vtkNew<vtkTransform> FutureBox; 00306 00308 vtkNew<vtkTransform> FutureBoxScale; 00309 00311 vtkNew<vtkPen> Pen; 00312 00314 vtkNew<vtkPen> AxisPen; 00315 00317 vtkSmartPointer<vtkAnnotationLink> Link; 00318 00320 std::vector<vtkPlot3D *> Plots; 00321 00323 std::string XAxisLabel; 00324 00326 std::string YAxisLabel; 00327 00329 std::string ZAxisLabel; 00330 00332 vtkNew<vtkPlaneCollection> BoundingCube; 00333 00336 float AxesBoundaryPoints[14][3]; 00337 00340 float TickLabelOffset[3][2]; 00341 00343 int SceneHeight; 00344 00346 int SceneWidth; 00347 00349 00350 int XAxisToLabel[3]; 00351 int YAxisToLabel[3]; 00352 int ZAxisToLabel[3]; 00354 00356 int DirectionToData[3]; 00357 00359 double DataBounds[4]; 00360 00361 private: 00362 vtkChartXYZ(const vtkChartXYZ &); // Not implemented. 00363 void operator=(const vtkChartXYZ &); // Not implemented. 00364 }; 00365 00366 #endif