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 00062 enum { 00063 TICK_SIMPLE = 0, 00064 TICK_WILKINSON_EXTENDED 00065 }; 00066 00068 static vtkAxis *New(); 00069 00071 00073 virtual void SetPosition(int position); 00074 vtkGetMacro(Position, int); 00076 00078 00079 void SetPoint1(const vtkVector2f& pos); 00080 void SetPoint1(float x, float y); 00082 00084 00085 vtkGetVector2Macro(Point1, float); 00086 vtkVector2f GetPosition1(); 00088 00090 00091 void SetPoint2(const vtkVector2f& pos); 00092 void SetPoint2(float x, float y); 00094 00096 00097 vtkGetVector2Macro(Point2, float); 00098 vtkVector2f GetPosition2(); 00100 00102 00104 vtkSetMacro(NumberOfTicks, int); 00106 00108 00109 vtkGetMacro(NumberOfTicks, int); 00111 00113 00115 vtkGetObjectMacro(LabelProperties, vtkTextProperty); 00117 00119 virtual void SetMinimum(double minimum); 00120 00122 00123 vtkGetMacro(Minimum, double); 00125 00127 virtual void SetMaximum(double maximum); 00128 00130 00131 vtkGetMacro(Maximum, double); 00133 00135 00136 virtual void SetRange(double minimum, double maximum); 00137 virtual void SetRange(double range[2]); 00139 00141 virtual void GetRange(double *range); 00142 00145 virtual void SetMinimumLimit(double lowest); 00146 00148 00150 vtkGetMacro(MinimumLimit, double); 00152 00155 virtual void SetMaximumLimit(double highest); 00156 00158 00160 vtkGetMacro(MaximumLimit, double); 00162 00164 00165 vtkGetVector2Macro(Margins, int); 00167 00169 00170 vtkSetVector2Macro(Margins, int); 00172 00174 00175 virtual void SetTitle(const vtkStdString &title); 00176 virtual vtkStdString GetTitle(); 00178 00180 00181 vtkGetObjectMacro(TitleProperties, vtkTextProperty); 00183 00185 00186 vtkSetMacro(LogScale, bool); 00187 vtkGetMacro(LogScale, bool); 00189 00191 00192 vtkSetMacro(GridVisible, bool); 00193 vtkGetMacro(GridVisible, bool); 00195 00197 00198 vtkSetMacro(LabelsVisible, bool); 00199 vtkGetMacro(LabelsVisible, bool); 00201 00203 00204 virtual void SetPrecision(int precision); 00205 vtkGetMacro(Precision, int); 00207 00209 00210 enum { 00211 STANDARD_NOTATION = 0, 00212 SCIENTIFIC_NOTATION, 00213 FIXED_NOTATION, 00215 00216 // deprecated, use the *_NOTATION versions above 00217 STANDARD = STANDARD_NOTATION, 00218 SCIENTIFIC = SCIENTIFIC_NOTATION, 00219 MIXED = FIXED_NOTATION 00220 }; 00221 00223 00225 virtual void SetNotation(int notation); 00226 vtkGetMacro(Notation, int); 00228 00230 00231 enum { 00232 AUTO = 0, 00233 FIXED, 00234 CUSTOM 00235 }; 00237 00239 00241 vtkSetMacro(Behavior, int); 00242 vtkGetMacro(Behavior, int); 00244 00246 00248 vtkGetObjectMacro(Pen, vtkPen); 00250 00252 00254 vtkGetObjectMacro(GridPen, vtkPen); 00256 00258 00264 vtkSetMacro(TickLabelAlgorithm, int) 00265 vtkGetMacro(TickLabelAlgorithm, int) 00267 00270 virtual void Update(); 00271 00273 virtual bool Paint(vtkContext2D *painter); 00274 00279 virtual void AutoScale(); 00280 00283 virtual void RecalculateTickSpacing(); 00284 00287 virtual vtkDoubleArray* GetTickPositions(); 00288 00290 virtual void SetTickPositions(vtkDoubleArray* positions); 00291 00294 virtual vtkFloatArray* GetTickScenePositions(); 00295 00297 virtual vtkStringArray* GetTickLabels(); 00298 00300 virtual void SetTickLabels(vtkStringArray* labels); 00301 00307 vtkRectf GetBoundingRect(vtkContext2D* painter); 00308 00309 //BTX 00310 protected: 00311 vtkAxis(); 00312 ~vtkAxis(); 00313 00315 void GenerateTickLabels(double min, double max); 00316 00319 void GenerateTickLabels(); 00320 00321 void GenerateLabelFormat(int notation, double n); 00322 00325 double CalculateNiceMinMax(double &min, double &max); 00326 00330 double NiceNumber(double number, bool roundUp); 00331 00333 00339 double LogScaleTickMark(double number, 00340 bool roundUp, 00341 bool &niceValue, 00342 int &order); 00344 00346 00353 void GenerateLogScaleTickMarks(int order, 00354 double min = 1.0, 00355 double max = 9.0, 00356 bool detailLabels = true); 00358 00359 int Position; // The position of the axis (LEFT, BOTTOM, RIGHT, TOP) 00360 float *Point1; // The position of point 1 (usually the origin) 00361 float *Point2; // The position of point 2 (usually the terminus) 00362 vtkVector2f Position1, Position2; 00363 double TickInterval; // Interval between tick marks in plot space 00364 int NumberOfTicks; // The number of tick marks to draw 00365 vtkTextProperty* LabelProperties; // Text properties for the labels. 00366 double Minimum; // Minimum value of the axis 00367 double Maximum; // Maximum values of the axis 00368 double MinimumLimit; // Lowest possible value for Minimum 00369 double MaximumLimit; // Highest possible value for Maximum 00370 int Margins[2]; // Horizontal/vertical margins for the axis 00371 vtkStdString Title; // The text label drawn on the axis 00372 vtkTextProperty* TitleProperties; // Text properties for the axis title 00373 bool LogScale; // Should the axis use a log scale 00374 bool GridVisible; // Whether the grid for the axis should be drawn 00375 bool LabelsVisible; // Should the axis labels be visible 00376 int Precision; // Numerical precision to use, defaults to 2. 00377 int Notation; // The notation to use (standard, scientific, mixed) 00378 int Behavior; // The behaviour of the axis (auto, fixed, custom). 00379 float MaxLabel[2]; // The widest/tallest axis label. 00380 bool TitleAppended; // Track if the title is updated when the label formats 00381 // are changed in the Extended Axis Labeling algorithm 00382 00384 vtkPen* Pen; 00385 00388 vtkPen* GridPen; 00389 00391 vtkSmartPointer<vtkDoubleArray> TickPositions; 00392 00394 vtkSmartPointer<vtkFloatArray> TickScenePositions; 00395 00397 vtkSmartPointer<vtkStringArray> TickLabels; 00398 00401 bool UsingNiceMinMax; 00402 00404 bool TickMarksDirty; 00405 00407 bool Resized; 00408 00410 bool LogScaleReasonable; 00411 00413 int TickLabelAlgorithm; 00414 00416 vtkTimeStamp BuildTime; 00417 00418 private: 00419 vtkAxis(const vtkAxis &); // Not implemented. 00420 void operator=(const vtkAxis &); // Not implemented. 00421 //ETX 00422 }; 00423 00424 #endif //__vtkAxis_h