chartpresenter_p.h
220 lines
| 6.7 KiB
| text/x-c
|
CLexer
Miikka Heikkinen
|
r2854 | /**************************************************************************** | ||
Jani Honkonen
|
r794 | ** | ||
Miikka Heikkinen
|
r2854 | ** Copyright (C) 2016 The Qt Company Ltd. | ||
** Contact: https://www.qt.io/licensing/ | ||||
Jani Honkonen
|
r794 | ** | ||
Miikka Heikkinen
|
r2854 | ** This file is part of the Qt Charts module of the Qt Toolkit. | ||
Jani Honkonen
|
r794 | ** | ||
Miikka Heikkinen
|
r2854 | ** $QT_BEGIN_LICENSE:GPL$ | ||
Titta Heikkala
|
r2845 | ** Commercial License Usage | ||
** Licensees holding valid commercial Qt licenses may use this file in | ||||
** accordance with the commercial license agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and The Qt Company. For licensing terms | ||||
Miikka Heikkinen
|
r2854 | ** and conditions see https://www.qt.io/terms-conditions. For further | ||
** information use the contact form at https://www.qt.io/contact-us. | ||||
** | ||||
** GNU General Public License Usage | ||||
** Alternatively, this file may be used under the terms of the GNU | ||||
** General Public License version 3 or (at your option) any later version | ||||
** approved by the KDE Free Qt Foundation. The licenses are as published by | ||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3 | ||||
** included in the packaging of this file. Please review the following | ||||
** information to ensure the GNU General Public License requirements will | ||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html. | ||||
Jani Honkonen
|
r794 | ** | ||
Titta Heikkala
|
r2845 | ** $QT_END_LICENSE$ | ||
** | ||||
Miikka Heikkinen
|
r2854 | ****************************************************************************/ | ||
Jani Honkonen
|
r794 | |||
unknown
|
r1366 | // W A R N I N G | ||
// ------------- | ||||
// | ||||
Titta Heikkala
|
r2807 | // This file is not part of the Qt Chart API. It exists purely as an | ||
unknown
|
r1366 | // implementation detail. This header file may change from version to | ||
// version without notice, or even be removed. | ||||
// | ||||
// We mean it. | ||||
Michal Klocek
|
r969 | #ifndef CHARTPRESENTER_H | ||
#define CHARTPRESENTER_H | ||||
Michal Klocek
|
r131 | |||
Titta Heikkala
|
r2714 | #include <QtCharts/QChartGlobal> | ||
#include <QtCharts/QChart> //because of QChart::ChartThemeId | ||||
Miikka Heikkinen
|
r2820 | #include <private/glwidget_p.h> | ||
Titta Heikkala
|
r2714 | #include <QtCore/QRectF> | ||
#include <QtCore/QMargins> | ||||
#include <QtCore/QLocale> | ||||
Miikka Heikkinen
|
r2820 | #include <QtCore/QPointer> | ||
Miikka Heikkinen
|
r2826 | #include <QtCore/QEasingCurve> | ||
Michal Klocek
|
r131 | |||
Titta Heikkala
|
r2712 | QT_CHARTS_BEGIN_NAMESPACE | ||
Michal Klocek
|
r131 | |||
Michal Klocek
|
r2273 | class ChartItem; | ||
class AxisItem; | ||||
Tero Ahola
|
r988 | class QAbstractSeries; | ||
Michal Klocek
|
r131 | class ChartDataSet; | ||
Marek Rosa
|
r2275 | class AbstractDomain; | ||
Miikka Heikkinen
|
r2483 | class ChartAxisElement; | ||
Michal Klocek
|
r530 | class ChartAnimator; | ||
Michal Klocek
|
r1006 | class ChartBackground; | ||
Michal Klocek
|
r1965 | class ChartTitle; | ||
Michal Klocek
|
r1241 | class ChartAnimation; | ||
Miikka Heikkinen
|
r2483 | class AbstractChartLayout; | ||
Michal Klocek
|
r131 | |||
class ChartPresenter: public QObject | ||||
{ | ||||
Q_OBJECT | ||||
public: | ||||
Tero Ahola
|
r375 | enum ZValues { | ||
BackgroundZValue = -1, | ||||
Miikka Heikkinen
|
r2498 | PlotAreaZValue, | ||
ShadesZValue, | ||||
Tero Ahola
|
r375 | GridZValue, | ||
Tero Ahola
|
r1790 | AxisZValue, | ||
Tero Ahola
|
r1260 | SeriesZValue, | ||
LineChartZValue = SeriesZValue, | ||||
Michal Klocek
|
r1747 | SplineChartZValue = SeriesZValue, | ||
Tero Ahola
|
r1260 | BarSeriesZValue = SeriesZValue, | ||
ScatterSeriesZValue = SeriesZValue, | ||||
PieSeriesZValue = SeriesZValue, | ||||
Mika Salmela
|
r2548 | BoxPlotSeriesZValue = SeriesZValue, | ||
Michal Klocek
|
r1747 | LegendZValue, | ||
TopMostZValue | ||||
Tero Ahola
|
r375 | }; | ||
Tero Ahola
|
r1260 | |||
enum State { | ||||
ShowState, | ||||
Michal Klocek
|
r1241 | ScrollUpState, | ||
ScrollDownState, | ||||
ScrollLeftState, | ||||
ScrollRightState, | ||||
ZoomInState, | ||||
ZoomOutState | ||||
}; | ||||
Michal Klocek
|
r262 | |||
Miikka Heikkinen
|
r2483 | ChartPresenter(QChart *chart, QChart::ChartType type); | ||
Michal Klocek
|
r131 | virtual ~ChartPresenter(); | ||
Michal Klocek
|
r139 | |||
Michal Klocek
|
r2273 | |||
void setGeometry(QRectF rect); | ||||
QRectF geometry() const; | ||||
QGraphicsItem *rootItem(){ return m_chart; } | ||||
Jani Honkonen
|
r2131 | ChartBackground *backgroundElement(); | ||
Miikka Heikkinen
|
r2498 | QAbstractGraphicsShapeItem *plotAreaElement(); | ||
Jani Honkonen
|
r2131 | ChartTitle *titleElement(); | ||
Miikka Heikkinen
|
r2483 | QList<ChartAxisElement *> axisItems() const; | ||
Michal Klocek
|
r2273 | QList<ChartItem *> chartItems() const; | ||
Jani Honkonen
|
r2131 | QLegend *legend(); | ||
Michal Klocek
|
r1534 | |||
Jani Honkonen
|
r2131 | void setBackgroundBrush(const QBrush &brush); | ||
Michal Klocek
|
r1534 | QBrush backgroundBrush() const; | ||
Jani Honkonen
|
r2131 | void setBackgroundPen(const QPen &pen); | ||
Michal Klocek
|
r1534 | QPen backgroundPen() const; | ||
Miikka Heikkinen
|
r2549 | void setBackgroundRoundness(qreal diameter); | ||
qreal backgroundRoundness() const; | ||||
Miikka Heikkinen
|
r2498 | void setPlotAreaBackgroundBrush(const QBrush &brush); | ||
QBrush plotAreaBackgroundBrush() const; | ||||
void setPlotAreaBackgroundPen(const QPen &pen); | ||||
QPen plotAreaBackgroundPen() const; | ||||
Jani Honkonen
|
r2131 | void setTitle(const QString &title); | ||
Michal Klocek
|
r1534 | QString title() const; | ||
Jani Honkonen
|
r2131 | void setTitleFont(const QFont &font); | ||
Michal Klocek
|
r1534 | QFont titleFont() const; | ||
void setTitleBrush(const QBrush &brush); | ||||
QBrush titleBrush() const; | ||||
void setBackgroundVisible(bool visible); | ||||
bool isBackgroundVisible() const; | ||||
Miikka Heikkinen
|
r2498 | void setPlotAreaBackgroundVisible(bool visible); | ||
bool isPlotAreaBackgroundVisible() const; | ||||
Michal Klocek
|
r1534 | void setBackgroundDropShadowEnabled(bool enabled); | ||
bool isBackgroundDropShadowEnabled() const; | ||||
Miikka Heikkinen
|
r2707 | void setLocalizeNumbers(bool localize); | ||
Miikka Heikkinen
|
r2708 | inline bool localizeNumbers() const { return m_localizeNumbers; } | ||
void setLocale(const QLocale &locale); | ||||
inline const QLocale &locale() const { return m_locale; } | ||||
Miikka Heikkinen
|
r2707 | |||
Michal Klocek
|
r1534 | void setVisible(bool visible); | ||
Michal Klocek
|
r131 | |||
Michal Klocek
|
r298 | void setAnimationOptions(QChart::AnimationOptions options); | ||
QChart::AnimationOptions animationOptions() const; | ||||
Titta Heikkala
|
r2804 | void setAnimationDuration(int msecs); | ||
int animationDuration() const { return m_animationDuration; } | ||||
void setAnimationEasingCurve(const QEasingCurve &curve); | ||||
QEasingCurve animationEasingCurve() const { return m_animationCurve; } | ||||
Michal Klocek
|
r298 | |||
Jani Honkonen
|
r2131 | void startAnimation(ChartAnimation *animation); | ||
Michal Klocek
|
r2273 | |||
void setState(State state,QPointF point); | ||||
Michal Klocek
|
r1241 | State state() const { return m_state; } | ||
QPointF statePoint() const { return m_statePoint; } | ||||
Miikka Heikkinen
|
r2483 | AbstractChartLayout *layout(); | ||
QChart::ChartType chartType() const { return m_chart->chartType(); } | ||||
Miikka Heikkinen
|
r2498 | QChart *chart() { return m_chart; } | ||
Michal Klocek
|
r1534 | |||
Miikka Heikkinen
|
r2539 | static QRectF textBoundingRect(const QFont &font, const QString &text, qreal angle = 0.0); | ||
Titta Heikkala
|
r2604 | static QString truncatedText(const QFont &font, const QString &text, qreal angle, | ||
qreal maxWidth, qreal maxHeight, QRectF &boundingRect); | ||||
Miikka Heikkinen
|
r2592 | inline static qreal textMargin() { return qreal(0.5); } | ||
Miikka Heikkinen
|
r2707 | |||
QString numberToString(double value, char f = 'g', int prec = 6); | ||||
Miikka Heikkinen
|
r2709 | QString numberToString(int value); | ||
Miikka Heikkinen
|
r2707 | |||
Miikka Heikkinen
|
r2865 | void updateGLWidget(); | ||
Miikka Heikkinen
|
r2820 | void glSetUseWidget(bool enable) { m_glUseWidget = enable; } | ||
Michal Klocek
|
r1534 | private: | ||
void createBackgroundItem(); | ||||
Miikka Heikkinen
|
r2498 | void createPlotAreaBackgroundItem(); | ||
Michal Klocek
|
r1534 | void createTitleItem(); | ||
Michal Klocek
|
r131 | |||
sauimone
|
r775 | public Q_SLOTS: | ||
Michal Klocek
|
r2273 | void handleSeriesAdded(QAbstractSeries *series); | ||
Jani Honkonen
|
r2131 | void handleSeriesRemoved(QAbstractSeries *series); | ||
Michal Klocek
|
r2273 | void handleAxisAdded(QAbstractAxis *axis); | ||
Jani Honkonen
|
r2131 | void handleAxisRemoved(QAbstractAxis *axis); | ||
Michal Klocek
|
r439 | |||
Miikka Heikkinen
|
r2793 | Q_SIGNALS: | ||
Miikka Heikkinen
|
r2716 | void plotAreaChanged(const QRectF &plotArea); | ||
Michal Klocek
|
r131 | private: | ||
Jani Honkonen
|
r2131 | QChart *m_chart; | ||
Michal Klocek
|
r2273 | QList<ChartItem *> m_chartItems; | ||
Miikka Heikkinen
|
r2483 | QList<ChartAxisElement *> m_axisItems; | ||
Michal Klocek
|
r2273 | QList<QAbstractSeries *> m_series; | ||
QList<QAbstractAxis *> m_axes; | ||||
Michal Klocek
|
r298 | QChart::AnimationOptions m_options; | ||
Titta Heikkala
|
r2804 | int m_animationDuration; | ||
QEasingCurve m_animationCurve; | ||||
Michal Klocek
|
r1241 | State m_state; | ||
QPointF m_statePoint; | ||||
Miikka Heikkinen
|
r2483 | AbstractChartLayout *m_layout; | ||
Jani Honkonen
|
r2131 | ChartBackground *m_background; | ||
Miikka Heikkinen
|
r2498 | QAbstractGraphicsShapeItem *m_plotAreaBackground; | ||
Jani Honkonen
|
r2131 | ChartTitle *m_title; | ||
Michal Klocek
|
r2273 | QRectF m_rect; | ||
Miikka Heikkinen
|
r2707 | bool m_localizeNumbers; | ||
QLocale m_locale; | ||||
Miikka Heikkinen
|
r2820 | #ifndef QT_NO_OPENGL | ||
QPointer<GLWidget> m_glWidget; | ||||
#endif | ||||
bool m_glUseWidget; | ||||
Michal Klocek
|
r131 | }; | ||
Titta Heikkala
|
r2712 | QT_CHARTS_END_NAMESPACE | ||
Michal Klocek
|
r131 | |||
Jani Honkonen
|
r1935 | #endif /* CHARTPRESENTER_H */ | ||