VTK
vtkAxis.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAxis.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 
28 #ifndef __vtkAxis_h
29 #define __vtkAxis_h
30 
31 #include "vtkContextItem.h"
32 #include "vtkSmartPointer.h" // For vtkSmartPointer
33 #include "vtkVector.h" // For position variables
34 #include "vtkRect.h" // For bounding rect
35 #include "vtkStdString.h" // For vtkStdString ivars
36 
37 class vtkContext2D;
38 class vtkPen;
39 class vtkFloatArray;
40 class vtkDoubleArray;
41 class vtkStringArray;
42 class vtkTextProperty;
43 
45 {
46 public:
47  vtkTypeMacro(vtkAxis, vtkContextItem);
48  virtual void PrintSelf(ostream &os, vtkIndent indent);
49 
51 
53  enum {
54  LEFT = 0,
57  TOP,
58  PARALLEL
59  };
61 
63  static vtkAxis *New();
64 
66 
68  virtual void SetPosition(int position);
69  vtkGetMacro(Position, int);
71 
73 
74  void SetPoint1(const vtkVector2f& pos);
75  void SetPoint1(float x, float y);
77 
79 
80  vtkGetVector2Macro(Point1, float);
81  vtkVector2f GetPosition1();
83 
85 
86  void SetPoint2(const vtkVector2f& pos);
87  void SetPoint2(float x, float y);
89 
91 
92  vtkGetVector2Macro(Point2, float);
93  vtkVector2f GetPosition2();
95 
97 
99  vtkSetMacro(NumberOfTicks, int);
101 
103 
104  vtkGetMacro(NumberOfTicks, int);
106 
108 
110  vtkGetObjectMacro(LabelProperties, vtkTextProperty);
112 
114  virtual void SetMinimum(double minimum);
115 
117 
118  vtkGetMacro(Minimum, double);
120 
122  virtual void SetMaximum(double maximum);
123 
125 
126  vtkGetMacro(Maximum, double);
128 
130  virtual void SetRange(double minimum, double maximum);
131 
134  virtual void SetMinimumLimit(double lowest);
135 
137 
139  vtkGetMacro(MinimumLimit, double);
141 
144  virtual void SetMaximumLimit(double highest);
145 
147 
149  vtkGetMacro(MaximumLimit, double);
151 
153 
154  virtual void SetTitle(const vtkStdString &title);
155  virtual vtkStdString GetTitle();
157 
159 
160  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
162 
164 
165  vtkSetMacro(LogScale, bool);
166  vtkGetMacro(LogScale, bool);
168 
170 
171  vtkSetMacro(GridVisible, bool);
172  vtkGetMacro(GridVisible, bool);
174 
176 
177  vtkSetMacro(LabelsVisible, bool);
178  vtkGetMacro(LabelsVisible, bool);
180 
182 
183  virtual void SetPrecision(int precision);
184  vtkGetMacro(Precision, int);
186 
188 
189  enum {
190  STANDARD = 0,
192  MIXED
193  };
195 
197 
199  virtual void SetNotation(int notation);
200  vtkGetMacro(Notation, int);
202 
204 
205  enum {
206  AUTO = 0,
208  CUSTOM
209  };
211 
213 
215  vtkSetMacro(Behavior, int);
216  vtkGetMacro(Behavior, int);
218 
220 
222  vtkGetObjectMacro(Pen, vtkPen);
224 
226 
228  vtkGetObjectMacro(GridPen, vtkPen);
230 
233  virtual void Update();
234 
236  virtual bool Paint(vtkContext2D *painter);
237 
242  virtual void AutoScale();
243 
246  virtual void RecalculateTickSpacing();
247 
250  virtual vtkDoubleArray* GetTickPositions();
251 
253  virtual void SetTickPositions(vtkDoubleArray* positions);
254 
257  virtual vtkFloatArray* GetTickScenePositions();
258 
260  virtual vtkStringArray* GetTickLabels();
261 
263  virtual void SetTickLabels(vtkStringArray* labels);
264 
270  vtkRectf GetBoundingRect(vtkContext2D* painter);
271 
272 //BTX
273 protected:
274  vtkAxis();
275  ~vtkAxis();
276 
278  void GenerateTickLabels(double min, double max);
279 
282  void GenerateTickLabels();
283 
286  double CalculateNiceMinMax(double &min, double &max);
287 
291  double NiceNumber(double number, bool roundUp);
292 
294 
300  double LogScaleTickMark(double number,
301  bool roundUp,
302  bool &niceValue,
303  int &order);
305 
307 
314  void GenerateLogScaleTickMarks(int order,
315  double min = 1.0,
316  double max = 9.0,
317  bool detailLabels = true);
319 
320  int Position; // The position of the axis (LEFT, BOTTOM, RIGHT, TOP)
321  float *Point1; // The position of point 1 (usually the origin)
322  float *Point2; // The position of point 2 (usually the terminus)
323  vtkVector2f Position1, Position2;
324  double TickInterval; // Interval between tick marks in plot space
325  int NumberOfTicks; // The number of tick marks to draw
326  vtkTextProperty* LabelProperties; // Text properties for the labels.
327  double Minimum; // Minimum value of the axis
328  double Maximum; // Maximum values of the axis
329  double MinimumLimit; // Lowest possible value for Minimum
330  double MaximumLimit; // Highest possible value for Maximum
331  vtkStdString Title; // The text label drawn on the axis
332  vtkTextProperty* TitleProperties; // Text properties for the axis title
333  bool LogScale; // Should the axis use a log scale
334  bool GridVisible; // Whether the grid for the axis should be drawn
335  bool LabelsVisible; // Should the axis labels be visible
336  int Precision; // Numerical precision to use, defaults to 2.
337  int Notation; // The notation to use (standard, scientific, mixed)
338  int Behavior; // The behaviour of the axis (auto, fixed, custom).
339  float MaxLabel[2]; // The widest/tallest axis label.
340 
343 
347 
350 
353 
356 
360 
363 
365  bool Resized;
366 
369 
372 
373 private:
374  vtkAxis(const vtkAxis &); // Not implemented.
375  void operator=(const vtkAxis &); // Not implemented.
376 //ETX
377 };
378 
379 #endif //__vtkAxis_h
double MaximumLimit
Definition: vtkAxis.h:330
double TickInterval
Definition: vtkAxis.h:324
#define VTK_CHARTS_EXPORT
vtkTextProperty * LabelProperties
Definition: vtkAxis.h:326
Wrapper around vtkstd::string to keep symbols short.
Definition: vtkStdString.h:45
bool LabelsVisible
Definition: vtkAxis.h:335
float * Point1
Definition: vtkAxis.h:321
vtkPen * Pen
Definition: vtkAxis.h:342
bool LogScale
Definition: vtkAxis.h:333
base class for items that are part of a vtkContextScene.
int Notation
Definition: vtkAxis.h:337
double MinimumLimit
Definition: vtkAxis.h:329
virtual bool Paint(vtkContext2D *painter)
record modification and/or execution time
Definition: vtkTimeStamp.h:33
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:42
a vtkAbstractArray subclass for strings
vtkStdString Title
Definition: vtkAxis.h:331
bool GridVisible
Definition: vtkAxis.h:334
int Precision
Definition: vtkAxis.h:336
float * Point2
Definition: vtkAxis.h:322
dynamic, self-adjusting array of double
vtkTimeStamp BuildTime
Definition: vtkAxis.h:371
bool Resized
Definition: vtkAxis.h:365
bool LogScaleReasonable
Definition: vtkAxis.h:368
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:54
takes care of drawing 2D axes
Definition: vtkAxis.h:44
double Maximum
Definition: vtkAxis.h:328
a simple class to control print indentation
Definition: vtkIndent.h:37
vtkSmartPointer< vtkStringArray > TickLabels
Definition: vtkAxis.h:355
int Position
Definition: vtkAxis.h:320
int Behavior
Definition: vtkAxis.h:338
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:37
vtkPen * GridPen
Definition: vtkAxis.h:346
double Minimum
Definition: vtkAxis.h:327
vtkVector2f Position2
Definition: vtkAxis.h:323
vtkTextProperty * TitleProperties
Definition: vtkAxis.h:332
vtkSmartPointer< vtkDoubleArray > TickPositions
Definition: vtkAxis.h:349
bool UsingNiceMinMax
Definition: vtkAxis.h:359
virtual void PrintSelf(ostream &os, vtkIndent indent)
static vtkObject * New()
int NumberOfTicks
Definition: vtkAxis.h:325
virtual void Update()
vtkSmartPointer< vtkFloatArray > TickScenePositions
Definition: vtkAxis.h:352
bool TickMarksDirty
Definition: vtkAxis.h:362