00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00023
00024 #ifndef _vtkQtChartAxis_h
00025 #define _vtkQtChartAxis_h
00026
00027 #include "vtkQtChartExport.h"
00028 #include <QObject>
00029 #include <QGraphicsItem>
00030
00031 #include "vtkQtChartGraphicsItemTypes.h"
00032
00033 class vtkQtChartAxisInternal;
00034 class vtkQtChartAxisModel;
00035 class vtkQtChartAxisOptions;
00036 class vtkQtChartContentsArea;
00037 class vtkQtChartContentsSpace;
00038 class QGraphicsLineItem;
00039 class QVariant;
00040
00041
00045 class VTKQTCHART_EXPORT vtkQtChartAxis : public QObject, public QGraphicsItem
00046 {
00047 Q_OBJECT
00048
00049 public:
00050 enum AxisLocation
00051 {
00052 Left = 0,
00053 Bottom,
00054 Right,
00055 Top
00056 };
00057
00058 enum AxisDomain
00059 {
00060 UnsupportedDomain = -1,
00061 Number = 0,
00062 Date,
00063 Time,
00064 String
00065 };
00066
00067 enum {Type = vtkQtChart_AxisType};
00068
00069 public:
00074 vtkQtChartAxis(AxisLocation location, QGraphicsItem *parent=0);
00075 virtual ~vtkQtChartAxis();
00076
00077 virtual int type() const {return vtkQtChartAxis::Type;}
00078
00080
00081
00082
00083
00084
00085 AxisLocation getLocation() const {return this->Location;}
00086
00091 vtkQtChartAxisModel *getModel() const {return this->Model;}
00092
00096 void setModel(vtkQtChartAxisModel *model);
00097
00107 void setNeigbors(const vtkQtChartAxis *atMin, const vtkQtChartAxis *atMax);
00108
00112 void setParallelAxis(const vtkQtChartAxis *across);
00113
00117 void setContentsSpace(const vtkQtChartContentsSpace *contents);
00118
00128 void setDataAvailable(bool available);
00129
00135 bool isBestFitGenerated() const;
00136
00141 void setBestFitGenerated(bool on);
00142
00147 void getBestFitRange(QVariant &min, QVariant &max) const;
00148
00153 void setBestFitRange(const QVariant &min, const QVariant &max);
00154
00164 bool isRangePaddingUsed() const;
00165
00169 void setRangePaddingUsed(bool padRange);
00170
00181 bool isExpansionToZeroUsed() const;
00182
00186 void setExpansionToZeroUsed(bool expand);
00187
00199 bool isExtraSpaceUsed() const;
00200
00206 void setExtraSpaceUsed(bool addSpace);
00207
00212 bool isSpaceTooSmall() const;
00213
00217 void setSpaceTooSmall(bool tooSmall);
00219
00221
00222
00223
00224
00225
00226 vtkQtChartAxisOptions *getOptions() const {return this->Options;}
00227
00235 void setOptions(const vtkQtChartAxisOptions &options);
00237
00239
00240
00241
00242
00243
00244
00245
00246 void layoutAxis(const QRectF &area);
00247
00254 void adjustAxisLayout();
00255
00266 float getPreferredSpace() const;
00267
00272 float getFontHeight() const;
00273
00281 float getMaxLabelWidth() const;
00282
00287 float getTickLength() const;
00288
00293 float getSmallTickLength() const;
00294
00299 float getTickLabelSpacing() const;
00300
00305 bool isLogScaleAvailable() const;
00306
00312 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
00313 QWidget *widget=0);
00315
00317
00318 virtual QRectF boundingRect() const;
00319
00328 QRectF getBounds() const;
00329
00335 bool isLabelTickVisible(int index) const;
00336
00342 float getLabelLocation(int index) const;
00343
00348 AxisDomain getAxisDomain() const;
00349
00355 bool isValueInDomain(const QVariant &value) const;
00356
00365 float getPixel(const QVariant &value) const;
00366
00376 float getZeroPixel() const;
00378
00386 static bool isLogScaleValid(const QVariant &min, const QVariant &max);
00387
00388 signals:
00390 void layoutNeeded();
00391
00399 void pixelScaleChanged();
00400
00401 public slots:
00403 void reset();
00404
00408 void setOffset(float offset);
00409
00410 private slots:
00412 void handleFontChange();
00413
00415 void handlePresentationChange();
00416
00418 void handleColorChange();
00419
00421 void handleAxisScaleChange();
00422
00426 void insertLabel(int index);
00427
00431 void startLabelRemoval(int index);
00432
00436 void finishLabelRemoval(int index);
00437
00438 private:
00449 float getLabelWidthGuess(const QVariant &minimum,
00450 const QVariant &maximum) const;
00451
00455 void generateLabels(const QRectF &contents);
00456
00460 void generateLogLabels(const QRectF &contents);
00461
00462 public:
00463 static const double MinLogValue;
00464
00465 private:
00466 vtkQtChartAxisInternal *Internal;
00467 vtkQtChartAxisOptions *Options;
00468 vtkQtChartAxisModel *Model;
00469 const vtkQtChartAxis *AtMin;
00470 const vtkQtChartAxis *AtMax;
00471 const vtkQtChartAxis *Across;
00472 const vtkQtChartContentsSpace *Zoom;
00473 AxisLocation Location;
00474 };
00475
00476 #endif