VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkAxis.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 __vtkAxis_h 00026 #define __vtkAxis_h 00027 00028 #include "vtkContextItem.h" 00029 #include "vtkSmartPointer.h" // For vtkSmartPointer 00030 00031 class vtkContext2D; 00032 class vtkPen; 00033 class vtkFloatArray; 00034 class vtkDoubleArray; 00035 class vtkStringArray; 00036 class vtkTextProperty; 00037 00038 class VTK_CHARTS_EXPORT vtkAxis : public vtkContextItem 00039 { 00040 public: 00041 vtkTypeMacro(vtkAxis, vtkContextItem); 00042 virtual void PrintSelf(ostream &os, vtkIndent indent); 00043 00044 //BTX 00046 00048 enum { 00049 LEFT = 0, 00050 BOTTOM, 00051 RIGHT, 00052 TOP, 00053 PARALLEL 00054 }; 00056 //ETX 00057 00059 static vtkAxis *New(); 00060 00062 00063 vtkSetMacro(Position, int); 00064 vtkGetMacro(Position, int); 00066 00068 00069 vtkSetVector2Macro(Point1, float); 00071 00073 00074 vtkGetVector2Macro(Point1, float); 00076 00078 00079 vtkSetVector2Macro(Point2, float); 00081 00083 00084 vtkGetVector2Macro(Point2, float); 00086 00088 00089 vtkSetMacro(NumberOfTicks, int); 00091 00093 00094 vtkGetMacro(NumberOfTicks, int); 00096 00098 00100 vtkGetObjectMacro(LabelProperties, vtkTextProperty); 00102 00104 virtual void SetMinimum(double minimum); 00105 00107 00108 vtkGetMacro(Minimum, double); 00110 00112 virtual void SetMaximum(double maximum); 00113 00115 00116 vtkGetMacro(Maximum, double); 00118 00120 virtual void SetRange(double minimum, double maximum); 00121 00123 00124 vtkSetStringMacro(Title); 00125 vtkGetStringMacro(Title); 00127 00129 00130 vtkGetObjectMacro(TitleProperties, vtkTextProperty); 00132 00134 00135 vtkSetMacro(LogScale, bool); 00136 vtkGetMacro(LogScale, bool); 00138 00140 00141 vtkSetMacro(GridVisible, bool); 00142 vtkGetMacro(GridVisible, bool); 00144 00146 00147 vtkSetMacro(LabelsVisible, bool); 00148 vtkGetMacro(LabelsVisible, bool); 00150 00152 00153 virtual void SetPrecision(int precision); 00154 vtkGetMacro(Precision, int); 00156 00158 00160 virtual void SetNotation(int notation); 00161 vtkGetMacro(Notation, int); 00163 00165 00167 vtkSetMacro(Behavior, int); 00168 vtkGetMacro(Behavior, int); 00170 00172 00174 vtkGetObjectMacro(Pen, vtkPen); 00176 00178 00180 vtkGetObjectMacro(GridPen, vtkPen); 00182 00185 virtual void Update(); 00186 00188 virtual bool Paint(vtkContext2D *painter); 00189 00194 virtual void AutoScale(); 00195 00198 virtual void RecalculateTickSpacing(); 00199 00202 virtual vtkDoubleArray* GetTickPositions(); 00203 00205 virtual void SetTickPositions(vtkDoubleArray*); 00206 00209 virtual vtkFloatArray* GetTickScenePositions(); 00210 00212 virtual vtkStringArray* GetTickLabels(); 00213 00215 virtual void SetTickLabels(vtkStringArray*); 00216 00217 //BTX 00218 protected: 00219 vtkAxis(); 00220 ~vtkAxis(); 00221 00223 void GenerateTickLabels(double min, double max); 00224 00227 double CalculateNiceMinMax(double &min, double &max); 00228 00232 double NiceNumber(double number, bool roundUp); 00233 00234 int Position; // The position of the axis (LEFT, BOTTOM, RIGHT, TOP) 00235 float Point1[2]; // The position of point 1 (usually the origin) 00236 float Point2[2]; // The position of point 2 (usually the terminus) 00237 double TickInterval; // Interval between tick marks in plot space 00238 int NumberOfTicks; // The number of tick marks to draw 00239 vtkTextProperty* LabelProperties; // Text properties for the labels. 00240 double Minimum; // Minimum value of the axis 00241 double Maximum; // Maximum values of the axis 00242 char* Title; // The text label drawn on the axis 00243 vtkTextProperty* TitleProperties; // Text properties for the axis title 00244 bool LogScale; // Should the axis use a log scale 00245 bool GridVisible; // Whether the grid for the axis should be drawn 00246 bool LabelsVisible; // Should the axis labels be visible 00247 int Precision; // Numerical precision to use, defaults to 2. 00248 int Notation; // The notation to use (standard, scientific, mixed) 00249 int Behavior; // The behaviour of the axis (auto, fixed, custom). 00250 00252 vtkPen* Pen; 00253 00256 vtkPen* GridPen; 00257 00259 vtkSmartPointer<vtkDoubleArray> TickPositions; 00260 00262 vtkSmartPointer<vtkFloatArray> TickScenePositions; 00263 00265 vtkSmartPointer<vtkStringArray> TickLabels; 00266 00269 bool UsingNiceMinMax; 00270 00272 bool TickMarksDirty; 00273 00275 vtkTimeStamp BuildTime; 00276 00277 private: 00278 vtkAxis(const vtkAxis &); // Not implemented. 00279 void operator=(const vtkAxis &); // Not implemented. 00280 //ETX 00281 }; 00282 00283 #endif //__vtkAxis_h