chartpresenter_p.h
145 lines
| 4.1 KiB
| text/x-c
|
CLexer
/ src / chartpresenter_p.h
|
r794 | /**************************************************************************** | ||
** | ||||
** Copyright (C) 2012 Digia Plc | ||||
** All rights reserved. | ||||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
|
r969 | #ifndef CHARTPRESENTER_H | ||
#define CHARTPRESENTER_H | ||||
|
r131 | |||
#include "qchartglobal.h" | ||||
|
r143 | #include "qchart.h" //becouse of QChart::ChartThemeId //TODO | ||
|
r131 | #include <QRectF> | ||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
|
r677 | class Chart; | ||
|
r988 | class QAbstractSeries; | ||
|
r131 | class ChartDataSet; | ||
class Domain; | ||||
|
r1006 | class ChartAxis; | ||
|
r143 | class ChartTheme; | ||
|
r530 | class ChartAnimator; | ||
|
r1006 | class ChartBackground; | ||
|
r1241 | class ChartAnimation; | ||
|
r131 | |||
class ChartPresenter: public QObject | ||||
{ | ||||
Q_OBJECT | ||||
public: | ||||
|
r375 | enum ZValues { | ||
BackgroundZValue = -1, | ||||
ShadesZValue, | ||||
GridZValue, | ||||
|
r1260 | SeriesZValue, | ||
LineChartZValue = SeriesZValue, | ||||
BarSeriesZValue = SeriesZValue, | ||||
ScatterSeriesZValue = SeriesZValue, | ||||
PieSeriesZValue = SeriesZValue, | ||||
|
r701 | AxisZValue, | ||
|
r540 | LegendZValue | ||
|
r375 | }; | ||
|
r1260 | |||
enum State { | ||||
ShowState, | ||||
|
r1241 | ScrollUpState, | ||
ScrollDownState, | ||||
ScrollLeftState, | ||||
ScrollRightState, | ||||
ZoomInState, | ||||
ZoomOutState | ||||
}; | ||||
|
r262 | |||
|
r131 | ChartPresenter(QChart* chart,ChartDataSet *dataset); | ||
virtual ~ChartPresenter(); | ||||
|
r139 | |||
|
r742 | ChartAnimator* animator() const { return m_animator; } | ||
ChartTheme *chartTheme() const { return m_chartTheme; } | ||||
ChartDataSet *dataSet() const { return m_dataset; } | ||||
QGraphicsItem* rootItem() const { return m_chart; } | ||||
|
r131 | |||
|
r740 | void setTheme(QChart::ChartTheme theme,bool force = true); | ||
QChart::ChartTheme theme(); | ||||
|
r143 | |||
|
r298 | void setAnimationOptions(QChart::AnimationOptions options); | ||
QChart::AnimationOptions animationOptions() const; | ||||
|
r1187 | void zoomIn(qreal factor); | ||
|
r439 | void zoomIn(const QRectF& rect); | ||
|
r1187 | void zoomOut(qreal factor); | ||
|
r531 | void scroll(int dx,int dy); | ||
|
r659 | |||
|
r855 | void setGeometry(const QRectF& rect); | ||
QRectF chartGeometry() const { return m_chartRect; } | ||||
|
r1006 | void setMinimumMarginHeight(ChartAxis* axis, qreal height); | ||
void setMinimumMarginWidth(ChartAxis* axis, qreal width); | ||||
|
r855 | qreal minimumLeftMargin() const { return m_minLeftMargin; } | ||
qreal minimumBottomMargin() const { return m_minBottomMargin; } | ||||
|
r1241 | void startAnimation(ChartAnimation* animation); | ||
State state() const { return m_state; } | ||||
QPointF statePoint() const { return m_statePoint; } | ||||
|
r855 | public: //TODO: fix me | ||
|
r531 | void resetAllElements(); | ||
|
r855 | void createChartBackgroundItem(); | ||
void createChartTitleItem(); | ||||
|
r874 | QRectF margins() const { return m_chartMargins;} | ||
|
r131 | |||
|
r775 | public Q_SLOTS: | ||
|
r988 | void handleSeriesAdded(QAbstractSeries* series,Domain* domain); | ||
void handleSeriesRemoved(QAbstractSeries* series); | ||||
|
r1006 | void handleAxisAdded(QAxis* axis,Domain* domain); | ||
void handleAxisRemoved(QAxis* axis); | ||||
|
r855 | void updateLayout(); | ||
|
r439 | |||
|
r1241 | private Q_SLOTS: | ||
void handleAnimationFinished(); | ||||
|
r775 | Q_SIGNALS: | ||
|
r139 | void geometryChanged(const QRectF& rect); | ||
|
r1241 | void animationsFinished(); | ||
|
r855 | |||
|
r131 | private: | ||
QChart* m_chart; | ||||
|
r530 | ChartAnimator* m_animator; | ||
|
r131 | ChartDataSet* m_dataset; | ||
|
r143 | ChartTheme *m_chartTheme; | ||
|
r988 | QMap<QAbstractSeries *, Chart *> m_chartItems; | ||
|
r1006 | QMap<QAxis *, ChartAxis *> m_axisItems; | ||
|
r131 | QRectF m_rect; | ||
|
r855 | QRectF m_chartRect; | ||
|
r298 | QChart::AnimationOptions m_options; | ||
|
r855 | qreal m_minLeftMargin; | ||
qreal m_minBottomMargin; | ||||
|
r1241 | State m_state; | ||
QPointF m_statePoint; | ||||
QList<ChartAnimation*> m_animations; | ||||
|
r855 | public: //TODO: fixme | ||
ChartBackground* m_backgroundItem; | ||||
QGraphicsSimpleTextItem* m_titleItem; | ||||
int m_marginBig; | ||||
int m_marginSmall; | ||||
int m_marginTiny; | ||||
|
r874 | QRectF m_chartMargins; | ||
QRectF m_legendMargins; | ||||
|
r131 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif /* CHARTPRESENTER_H_ */ | ||||