chartpresenter_p.h
193 lines
| 5.5 KiB
| text/x-c
|
CLexer
|
r794 | /**************************************************************************** | ||
** | ||||
|
r2688 | ** Copyright (C) 2014 Digia Plc | ||
|
r794 | ** All rights reserved. | ||
|
r2740 | ** For any questions to Digia, please use contact form at http://qt.io | ||
|
r794 | ** | ||
|
r2740 | ** This file is part of the Qt Charts module. | ||
|
r794 | ** | ||
|
r2740 | ** Licensees holding valid commercial license for Qt may use this file in | ||
** accordance with the Qt License Agreement provided with the Software | ||||
** or, alternatively, in accordance with the terms contained in a written | ||||
** agreement between you and Digia. | ||||
|
r794 | ** | ||
** If you have questions regarding the use of this file, please use | ||||
|
r2740 | ** contact form at http://qt.io | ||
|
r794 | ** | ||
****************************************************************************/ | ||||
|
r1366 | // W A R N I N G | ||
// ------------- | ||||
// | ||||
|
r2574 | // This file is not part of the Qt Enterprise Chart API. It exists purely as an | ||
|
r1366 | // implementation detail. This header file may change from version to | ||
// version without notice, or even be removed. | ||||
// | ||||
// We mean it. | ||||
|
r969 | #ifndef CHARTPRESENTER_H | ||
#define CHARTPRESENTER_H | ||||
|
r131 | |||
|
r2714 | #include <QtCharts/QChartGlobal> | ||
#include <QtCharts/QChart> //because of QChart::ChartThemeId | ||||
#include <QtCore/QRectF> | ||||
#include <QtCore/QMargins> | ||||
#include <QtCore/QLocale> | ||||
|
r131 | |||
|
r2712 | QT_CHARTS_BEGIN_NAMESPACE | ||
|
r131 | |||
|
r2273 | class ChartItem; | ||
class AxisItem; | ||||
|
r988 | class QAbstractSeries; | ||
|
r131 | class ChartDataSet; | ||
|
r2275 | class AbstractDomain; | ||
|
r2483 | class ChartAxisElement; | ||
|
r530 | class ChartAnimator; | ||
|
r1006 | class ChartBackground; | ||
|
r1965 | class ChartTitle; | ||
|
r1241 | class ChartAnimation; | ||
|
r2483 | class AbstractChartLayout; | ||
|
r131 | |||
class ChartPresenter: public QObject | ||||
{ | ||||
Q_OBJECT | ||||
public: | ||||
|
r375 | enum ZValues { | ||
BackgroundZValue = -1, | ||||
|
r2498 | PlotAreaZValue, | ||
ShadesZValue, | ||||
|
r375 | GridZValue, | ||
|
r1790 | AxisZValue, | ||
|
r1260 | SeriesZValue, | ||
LineChartZValue = SeriesZValue, | ||||
|
r1747 | SplineChartZValue = SeriesZValue, | ||
|
r1260 | BarSeriesZValue = SeriesZValue, | ||
ScatterSeriesZValue = SeriesZValue, | ||||
PieSeriesZValue = SeriesZValue, | ||||
|
r2548 | BoxPlotSeriesZValue = SeriesZValue, | ||
|
r1747 | LegendZValue, | ||
TopMostZValue | ||||
|
r375 | }; | ||
|
r1260 | |||
enum State { | ||||
ShowState, | ||||
|
r1241 | ScrollUpState, | ||
ScrollDownState, | ||||
ScrollLeftState, | ||||
ScrollRightState, | ||||
ZoomInState, | ||||
ZoomOutState | ||||
}; | ||||
|
r262 | |||
|
r2483 | ChartPresenter(QChart *chart, QChart::ChartType type); | ||
|
r131 | virtual ~ChartPresenter(); | ||
|
r139 | |||
|
r2273 | |||
void setGeometry(QRectF rect); | ||||
QRectF geometry() const; | ||||
QGraphicsItem *rootItem(){ return m_chart; } | ||||
|
r2131 | ChartBackground *backgroundElement(); | ||
|
r2498 | QAbstractGraphicsShapeItem *plotAreaElement(); | ||
|
r2131 | ChartTitle *titleElement(); | ||
|
r2483 | QList<ChartAxisElement *> axisItems() const; | ||
|
r2273 | QList<ChartItem *> chartItems() const; | ||
|
r2131 | QLegend *legend(); | ||
|
r1534 | |||
|
r2131 | void setBackgroundBrush(const QBrush &brush); | ||
|
r1534 | QBrush backgroundBrush() const; | ||
|
r2131 | void setBackgroundPen(const QPen &pen); | ||
|
r1534 | QPen backgroundPen() const; | ||
|
r2549 | void setBackgroundRoundness(qreal diameter); | ||
qreal backgroundRoundness() const; | ||||
|
r2498 | void setPlotAreaBackgroundBrush(const QBrush &brush); | ||
QBrush plotAreaBackgroundBrush() const; | ||||
void setPlotAreaBackgroundPen(const QPen &pen); | ||||
QPen plotAreaBackgroundPen() const; | ||||
|
r2131 | void setTitle(const QString &title); | ||
|
r1534 | QString title() const; | ||
|
r2131 | void setTitleFont(const QFont &font); | ||
|
r1534 | QFont titleFont() const; | ||
void setTitleBrush(const QBrush &brush); | ||||
QBrush titleBrush() const; | ||||
void setBackgroundVisible(bool visible); | ||||
bool isBackgroundVisible() const; | ||||
|
r2498 | void setPlotAreaBackgroundVisible(bool visible); | ||
bool isPlotAreaBackgroundVisible() const; | ||||
|
r1534 | void setBackgroundDropShadowEnabled(bool enabled); | ||
bool isBackgroundDropShadowEnabled() const; | ||||
|
r2707 | void setLocalizeNumbers(bool localize); | ||
|
r2708 | inline bool localizeNumbers() const { return m_localizeNumbers; } | ||
void setLocale(const QLocale &locale); | ||||
inline const QLocale &locale() const { return m_locale; } | ||||
|
r2707 | |||
|
r1534 | void setVisible(bool visible); | ||
|
r131 | |||
|
r298 | void setAnimationOptions(QChart::AnimationOptions options); | ||
QChart::AnimationOptions animationOptions() const; | ||||
|
r2131 | void startAnimation(ChartAnimation *animation); | ||
|
r2273 | |||
void setState(State state,QPointF point); | ||||
|
r1241 | State state() const { return m_state; } | ||
QPointF statePoint() const { return m_statePoint; } | ||||
|
r2483 | AbstractChartLayout *layout(); | ||
QChart::ChartType chartType() const { return m_chart->chartType(); } | ||||
|
r2498 | QChart *chart() { return m_chart; } | ||
|
r1534 | |||
|
r2539 | static QRectF textBoundingRect(const QFont &font, const QString &text, qreal angle = 0.0); | ||
|
r2604 | static QString truncatedText(const QFont &font, const QString &text, qreal angle, | ||
qreal maxWidth, qreal maxHeight, QRectF &boundingRect); | ||||
|
r2592 | inline static qreal textMargin() { return qreal(0.5); } | ||
|
r2707 | |||
QString numberToString(double value, char f = 'g', int prec = 6); | ||||
|
r2709 | QString numberToString(int value); | ||
|
r2707 | |||
|
r1534 | private: | ||
void createBackgroundItem(); | ||||
|
r2498 | void createPlotAreaBackgroundItem(); | ||
|
r1534 | void createTitleItem(); | ||
|
r131 | |||
|
r775 | public Q_SLOTS: | ||
|
r2273 | void handleSeriesAdded(QAbstractSeries *series); | ||
|
r2131 | void handleSeriesRemoved(QAbstractSeries *series); | ||
|
r2273 | void handleAxisAdded(QAbstractAxis *axis); | ||
|
r2131 | void handleAxisRemoved(QAbstractAxis *axis); | ||
|
r439 | |||
|
r2716 | signals: | ||
void plotAreaChanged(const QRectF &plotArea); | ||||
|
r131 | private: | ||
|
r2131 | QChart *m_chart; | ||
|
r2273 | QList<ChartItem *> m_chartItems; | ||
|
r2483 | QList<ChartAxisElement *> m_axisItems; | ||
|
r2273 | QList<QAbstractSeries *> m_series; | ||
QList<QAbstractAxis *> m_axes; | ||||
|
r298 | QChart::AnimationOptions m_options; | ||
|
r1241 | State m_state; | ||
QPointF m_statePoint; | ||||
|
r2483 | AbstractChartLayout *m_layout; | ||
|
r2131 | ChartBackground *m_background; | ||
|
r2498 | QAbstractGraphicsShapeItem *m_plotAreaBackground; | ||
|
r2131 | ChartTitle *m_title; | ||
|
r2273 | QRectF m_rect; | ||
|
r2707 | bool m_localizeNumbers; | ||
QLocale m_locale; | ||||
|
r131 | }; | ||
|
r2712 | QT_CHARTS_END_NAMESPACE | ||
|
r131 | |||
|
r1935 | #endif /* CHARTPRESENTER_H */ | ||