axisitem_p.h
93 lines
| 2.3 KiB
| text/x-c
|
CLexer
|
r67 | #ifndef AXISITEM_H_ | ||
#define AXISITEM_H_ | ||||
|
r140 | #include "domain_p.h" | ||
|
r104 | #include "chartitem_p.h" | ||
|
r67 | #include <QGraphicsItem> | ||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
|
r140 | class QChartAxis; | ||
class AxisItem : public QObject, public ChartItem | ||||
|
r67 | { | ||
|
r140 | Q_OBJECT | ||
|
r67 | public: | ||
enum AxisType{X_AXIS,Y_AXIS}; | ||||
|
r439 | AxisItem(QChartAxis* axis,AxisType type = X_AXIS,QGraphicsItem* parent = 0); | ||
|
r67 | ~AxisItem(); | ||
//from QGraphicsItem | ||||
QRectF boundingRect() const; | ||||
|
r176 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | ||
|
r67 | |||
|
r176 | AxisType axisType() const {return m_type;}; | ||
|
r140 | |||
|
r184 | void setAxisOpacity(qreal opacity); | ||
qreal axisOpacity() const; | ||||
|
r176 | void setGridOpacity(qreal opacity); | ||
qreal gridOpacity() const; | ||||
|
r140 | |||
|
r176 | void setLabelsOpacity(qreal opacity); | ||
qreal labelsOpacity() const; | ||||
|
r140 | |||
|
r176 | void setShadesOpacity(qreal opacity); | ||
qreal shadesOpacity() const; | ||||
|
r67 | |||
|
r176 | void setLabelsAngle(int angle); | ||
int labelsAngle()const { return m_labelsAngle; } | ||||
void setShadesBrush(const QBrush& brush); | ||||
void setShadesPen(const QPen& pen); | ||||
|
r140 | |||
|
r184 | void setAxisPen(const QPen& pen); | ||
|
r176 | void setGridPen(const QPen& pen); | ||
void setLabelsPen(const QPen& pen); | ||||
void setLabelsBrush(const QBrush& brush); | ||||
void setLabelsFont(const QFont& font); | ||||
|
r513 | inline QRectF geometry() const { return m_rect; } | ||
inline qreal zoomFactor() const { return m_zoomFactor;} | ||||
|
r504 | |||
|
r176 | public slots: | ||
|
r502 | void handleAxisUpdated(); | ||
void handleAxisCategoriesUpdated(); | ||||
void handleRangeChanged(qreal min , qreal max); | ||||
void handleTicksCountChanged(int count); | ||||
void handleGeometryChanged(const QRectF& size); | ||||
|
r439 | |||
|
r291 | public: | ||
|
r502 | virtual void updateLayout(QVector<qreal>& layout); | ||
void setLayout(QVector<qreal>& layout); | ||||
|
r452 | QVector<qreal> layout() { return m_layoutVector;}; | ||
|
r393 | |||
|
r85 | private: | ||
|
r452 | inline bool isEmpty(); | ||
|
r223 | void createItems(int count); | ||
|
r502 | void deleteItems(int count); | ||
QVector<qreal> calculateLayout() const; | ||||
QStringList createLabels(int ticks, qreal min, qreal max) const; | ||||
|
r497 | |||
|
r67 | private: | ||
|
r439 | QChartAxis* m_chartAxis; | ||
|
r140 | AxisType m_type; | ||
QRectF m_rect; | ||||
|
r176 | int m_labelsAngle; | ||
QGraphicsItemGroup m_grid; | ||||
QGraphicsItemGroup m_shades; | ||||
QGraphicsItemGroup m_labels; | ||||
|
r272 | QGraphicsItemGroup m_axis; | ||
|
r291 | QVector<qreal> m_layoutVector; | ||
|
r452 | qreal m_min; | ||
qreal m_max; | ||||
|
r502 | int m_ticksCount; | ||
|
r513 | qreal m_zoomFactor; | ||
|
r140 | |||
|
r67 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif /* AXISITEM_H_ */ | ||||