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 00028 #ifndef __vtkAxis_h 00029 #define __vtkAxis_h 00030 00031 #include "vtkContextItem.h" 00032 #include "vtkSmartPointer.h" // For vtkSmartPointer 00033 #include "vtkVector.h" // For position variables 00034 #include "vtkRect.h" // For bounding rect 00035 #include "vtkStdString.h" // For vtkStdString ivars 00036 00037 class vtkContext2D; 00038 class vtkPen; 00039 class vtkFloatArray; 00040 class vtkDoubleArray; 00041 class vtkStringArray; 00042 class vtkTextProperty; 00043 00044 class VTK_CHARTS_EXPORT vtkAxis : public vtkContextItem 00045 { 00046 public: 00047 vtkTypeMacro(vtkAxis, vtkContextItem); 00048 virtual void PrintSelf(ostream &os, vtkIndent indent); 00049 00051 00053 enum { 00054 LEFT = 0, 00055 BOTTOM, 00056 RIGHT, 00057 TOP, 00058 PARALLEL 00059 }; 00061 00063 static vtkAxis *New(); 00064 00066 00068 virtual void SetPosition(int position); 00069 vtkGetMacro(Position, int); 00071 00073 00074 void SetPoint1(const vtkVector2f& pos); 00075 void SetPoint1(float x, float y); 00077 00079 00080 vtkGetVector2Macro(Point1, float); 00081 vtkVector2f GetPosition1(); 00083 00085 00086 void SetPoint2(const vtkVector2f& pos); 00087 void SetPoint2(float x, float y); 00089 00091 00092 vtkGetVector2Macro(Point2, float); 00093 vtkVector2f GetPosition2(); 00095 00097 00099 vtkSetMacro(NumberOfTicks, int); 00101 00103 00104 vtkGetMacro(NumberOfTicks, int); 00106 00108 00110 vtkGetObjectMacro(LabelProperties, vtkTextProperty); 00112 00114 virtual void SetMinimum(double minimum); 00115 00117 00118 vtkGetMacro(Minimum, double); 00120 00122 virtual void SetMaximum(double maximum); 00123 00125 00126 vtkGetMacro(Maximum, double); 00128 00130 virtual void SetRange(double minimum, double maximum); 00131 00134 virtual void SetMinimumLimit(double lowest); 00135 00137 00139 vtkGetMacro(MinimumLimit, double); 00141 00144 virtual void SetMaximumLimit(double highest); 00145 00147 00149 vtkGetMacro(MaximumLimit, double); 00151 00153 00154 virtual void SetTitle(const vtkStdString &title); 00155 virtual vtkStdString GetTitle(); 00157 00159 00160 vtkGetObjectMacro(TitleProperties, vtkTextProperty); 00162 00164 00165 vtkSetMacro(LogScale, bool); 00166 vtkGetMacro(LogScale, bool); 00168 00170 00171 vtkSetMacro(GridVisible, bool); 00172 vtkGetMacro(GridVisible, bool); 00174 00176 00177 vtkSetMacro(LabelsVisible, bool); 00178 vtkGetMacro(LabelsVisible, bool); 00180 00182 00183 virtual void SetPrecision(int precision); 00184 vtkGetMacro(Precision, int); 00186 00188 00189 enum { 00190 STANDARD = 0, 00191 SCIENTIFIC, 00192 MIXED 00193 }; 00195 00197 00199 virtual void SetNotation(int notation); 00200 vtkGetMacro(Notation, int); 00202 00204 00205 enum { 00206 AUTO = 0, 00207 FIXED, 00208 CUSTOM 00209 }; 00211 00213 00215 vtkSetMacro(Behavior, int); 00216 vtkGetMacro(Behavior, int); 00218 00220 00222 vtkGetObjectMacro(Pen, vtkPen); 00224 00226 00228 vtkGetObjectMacro(GridPen, vtkPen); 00230 00233 virtual void Update(); 00234 00236 virtual bool Paint(vtkContext2D *painter); 00237 00242 virtual void AutoScale(); 00243 00246 virtual void RecalculateTickSpacing(); 00247 00250 virtual vtkDoubleArray* GetTickPositions(); 00251 00253 virtual void SetTickPositions(vtkDoubleArray* positions); 00254 00257 virtual vtkFloatArray* GetTickScenePositions(); 00258 00260 virtual vtkStringArray* GetTickLabels(); 00261 00263 virtual void SetTickLabels(vtkStringArray* labels); 00264 00270 vtkRectf GetBoundingRect(vtkContext2D* painter); 00271 00272 //BTX 00273 protected: 00274 vtkAxis(); 00275 ~vtkAxis(); 00276 00278 void GenerateTickLabels(double min, double max); 00279 00282 void GenerateTickLabels(); 00283 00286 double CalculateNiceMinMax(double &min, double &max); 00287 00291 double NiceNumber(double number, bool roundUp); 00292 00294 00300 double LogScaleTickMark(double number, 00301 bool roundUp, 00302 bool &niceValue, 00303 int &order); 00305 00307 00314 void GenerateLogScaleTickMarks(int order, 00315 double min = 1.0, 00316 double max = 9.0, 00317 bool detailLabels = true); 00319 00320 int Position; // The position of the axis (LEFT, BOTTOM, RIGHT, TOP) 00321 float *Point1; // The position of point 1 (usually the origin) 00322 float *Point2; // The position of point 2 (usually the terminus) 00323 vtkVector2f Position1, Position2; 00324 double TickInterval; // Interval between tick marks in plot space 00325 int NumberOfTicks; // The number of tick marks to draw 00326 vtkTextProperty* LabelProperties; // Text properties for the labels. 00327 double Minimum; // Minimum value of the axis 00328 double Maximum; // Maximum values of the axis 00329 double MinimumLimit; // Lowest possible value for Minimum 00330 double MaximumLimit; // Highest possible value for Maximum 00331 vtkStdString Title; // The text label drawn on the axis 00332 vtkTextProperty* TitleProperties; // Text properties for the axis title 00333 bool LogScale; // Should the axis use a log scale 00334 bool GridVisible; // Whether the grid for the axis should be drawn 00335 bool LabelsVisible; // Should the axis labels be visible 00336 int Precision; // Numerical precision to use, defaults to 2. 00337 int Notation; // The notation to use (standard, scientific, mixed) 00338 int Behavior; // The behaviour of the axis (auto, fixed, custom). 00339 float MaxLabel[2]; // The widest/tallest axis label. 00340 00342 vtkPen* Pen; 00343 00346 vtkPen* GridPen; 00347 00349 vtkSmartPointer<vtkDoubleArray> TickPositions; 00350 00352 vtkSmartPointer<vtkFloatArray> TickScenePositions; 00353 00355 vtkSmartPointer<vtkStringArray> TickLabels; 00356 00359 bool UsingNiceMinMax; 00360 00362 bool TickMarksDirty; 00363 00365 bool Resized; 00366 00368 bool LogScaleReasonable; 00369 00371 vtkTimeStamp BuildTime; 00372 00373 private: 00374 vtkAxis(const vtkAxis &); // Not implemented. 00375 void operator=(const vtkAxis &); // Not implemented. 00376 //ETX 00377 }; 00378 00379 #endif //__vtkAxis_h