@@ -1,46 +1,45 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef CHARTVIEW_H |
|
21 | #ifndef CHARTVIEW_H | |
22 | #define CHARTVIEW_H |
|
22 | #define CHARTVIEW_H | |
23 |
|
23 | |||
24 | #include <QChartView> |
|
24 | #include <QChartView> | |
25 | #include <QRubberBand> |
|
25 | #include <QRubberBand> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
28 | |||
29 | class ChartView : public QChartView |
|
29 | class ChartView : public QChartView | |
30 | { |
|
30 | { | |
31 | public: |
|
31 | public: | |
32 | ChartView(QChart *chart, QWidget *parent = 0); |
|
32 | ChartView(QChart *chart, QWidget *parent = 0); | |
33 | protected: |
|
33 | protected: | |
34 | void mousePressEvent(QMouseEvent *event); |
|
34 | void mousePressEvent(QMouseEvent *event); | |
35 | void mouseMoveEvent(QMouseEvent *event); |
|
35 | void mouseMoveEvent(QMouseEvent *event); | |
36 | void mouseReleaseEvent(QMouseEvent *event); |
|
36 | void mouseReleaseEvent(QMouseEvent *event); | |
37 | void keyPressEvent(QKeyEvent *event); |
|
37 | void keyPressEvent(QKeyEvent *event); | |
38 |
|
38 | |||
39 | private: |
|
39 | private: | |
40 | bool m_isScrolling; |
|
40 | bool m_isScrolling; | |
41 | bool m_isRubberBandShown; |
|
|||
42 | QRubberBand m_rubberBand; |
|
41 | QRubberBand m_rubberBand; | |
43 | QPoint m_origin; |
|
42 | QPoint m_origin; | |
44 | }; |
|
43 | }; | |
45 |
|
44 | |||
46 | #endif |
|
45 | #endif |
@@ -1,100 +1,98 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef CHARTDATASET_P_H |
|
30 | #ifndef CHARTDATASET_P_H | |
31 | #define CHARTDATASET_P_H |
|
31 | #define CHARTDATASET_P_H | |
32 |
|
32 | |||
33 | #include "qabstractseries.h" |
|
33 | #include "qabstractseries.h" | |
34 | #include "domain_p.h" |
|
34 | #include "domain_p.h" | |
35 | #include "qabstractaxis_p.h" |
|
35 | #include "qabstractaxis_p.h" | |
36 | #include <QVector> |
|
36 | #include <QVector> | |
37 |
|
37 | |||
38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
39 |
|
39 | |||
40 | class QAbstractAxis; |
|
40 | class QAbstractAxis; | |
41 |
|
41 | |||
42 | class QTCOMMERCIALCHART_AUTOTEST_EXPORT ChartDataSet : public QObject |
|
42 | class QTCOMMERCIALCHART_AUTOTEST_EXPORT ChartDataSet : public QObject | |
43 | { |
|
43 | { | |
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 | public: |
|
45 | public: | |
46 | ChartDataSet(QChart* parent=0); |
|
46 | ChartDataSet(QChart* parent=0); | |
47 | virtual ~ChartDataSet(); |
|
47 | virtual ~ChartDataSet(); | |
48 |
|
48 | |||
49 | void addSeries(QAbstractSeries* series); |
|
49 | void addSeries(QAbstractSeries* series); | |
50 | void removeSeries(QAbstractSeries* series); |
|
50 | void removeSeries(QAbstractSeries* series); | |
51 | void removeAllSeries(); |
|
51 | void removeAllSeries(); | |
52 | void updateSeries(QAbstractSeries* series); |
|
52 | void updateSeries(QAbstractSeries* series); | |
53 |
|
53 | |||
54 | void zoomInDomain(const QRectF& rect, const QSizeF& size); |
|
54 | void zoomInDomain(const QRectF& rect, const QSizeF& size); | |
55 | void zoomOutDomain(const QRectF& rect, const QSizeF& size); |
|
55 | void zoomOutDomain(const QRectF& rect, const QSizeF& size); | |
56 | void scrollDomain(qreal dx,qreal dy,const QSizeF& size); |
|
56 | void scrollDomain(qreal dx,qreal dy,const QSizeF& size); | |
57 |
|
57 | |||
58 | int seriesCount(QAbstractSeries::SeriesType type); |
|
58 | int seriesCount(QAbstractSeries::SeriesType type); | |
59 | int seriesIndex(QAbstractSeries *series); |
|
59 | int seriesIndex(QAbstractSeries *series); | |
60 |
|
60 | |||
61 | QAbstractAxis* axisX(QAbstractSeries *series) const; |
|
61 | QAbstractAxis* axisX(QAbstractSeries *series) const; | |
62 | QAbstractAxis* axisY(QAbstractSeries *series) const; |
|
62 | QAbstractAxis* axisY(QAbstractSeries *series) const; | |
63 |
|
63 | |||
64 | void setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Orientation orientation); |
|
64 | void setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Orientation orientation); | |
65 |
|
65 | |||
66 | QList<QAbstractSeries*> series() const; |
|
66 | QList<QAbstractSeries*> series() const; | |
67 | Domain* domain(QAbstractSeries *series) const; |
|
67 | Domain* domain(QAbstractSeries *series) const; | |
68 |
|
68 | |||
69 | void removeAxis(QAbstractAxis* axis); |
|
69 | void removeAxis(QAbstractAxis* axis); | |
70 | void createDefaultAxes(); |
|
70 | void createDefaultAxes(); | |
71 |
|
71 | |||
72 | Q_SIGNALS: |
|
72 | Q_SIGNALS: | |
73 | void seriesAdded(QAbstractSeries* series, Domain* domain); |
|
73 | void seriesAdded(QAbstractSeries* series, Domain* domain); | |
74 | void seriesRemoved(QAbstractSeries* series); |
|
74 | void seriesRemoved(QAbstractSeries* series); | |
75 | void seriesUpdated(QAbstractSeries* series); |
|
75 | void seriesUpdated(QAbstractSeries* series); | |
76 | void axisAdded(QAbstractAxis* axis,Domain* domain); |
|
76 | void axisAdded(QAbstractAxis* axis,Domain* domain); | |
77 | void axisRemoved(QAbstractAxis* axis); |
|
77 | void axisRemoved(QAbstractAxis* axis); | |
78 |
|
78 | |||
79 | private: |
|
79 | private: | |
80 | void calculateDomain(QAbstractSeries* series,Domain* domain); |
|
80 | void calculateDomain(QAbstractSeries* series,Domain* domain); | |
81 | void createAxes(QAbstractAxis::AxisTypes type,Qt::Orientation orientation); |
|
81 | void createAxes(QAbstractAxis::AxisTypes type,Qt::Orientation orientation); | |
82 | QAbstractAxis* createAxis(QAbstractAxis::AxisType type,Qt::Orientation orientation); |
|
82 | QAbstractAxis* createAxis(QAbstractAxis::AxisType type,Qt::Orientation orientation); | |
83 | void initializeAxis(QAbstractAxis* axis,QAbstractSeries* series); |
|
83 | void initializeAxis(QAbstractAxis* axis,QAbstractSeries* series); | |
84 | void removeAxes(QAbstractSeries* series); |
|
84 | void removeAxes(QAbstractSeries* series); | |
85 | void blockAxisSignals(bool enabled); |
|
85 | void blockAxisSignals(bool enabled); | |
86 | void createSeriesIndex(QAbstractSeries* series); |
|
86 | void createSeriesIndex(QAbstractSeries* series); | |
87 | void removeSeriesIndex(QAbstractSeries* series); |
|
87 | void removeSeriesIndex(QAbstractSeries* series); | |
88 |
|
88 | |||
89 | private: |
|
89 | private: | |
90 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisXMap; |
|
90 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisXMap; | |
91 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisYMap; |
|
91 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisYMap; | |
92 | QMap<QAbstractSeries*, Domain*> m_seriesDomainMap; |
|
92 | QMap<QAbstractSeries*, Domain*> m_seriesDomainMap; | |
93 | QMap<int, QAbstractSeries*> m_indexSeriesMap; |
|
93 | QMap<int, QAbstractSeries*> m_indexSeriesMap; | |
94 | int m_domainIndex; |
|
|||
95 |
|
||||
96 | }; |
|
94 | }; | |
97 |
|
95 | |||
98 | QTCOMMERCIALCHART_END_NAMESPACE |
|
96 | QTCOMMERCIALCHART_END_NAMESPACE | |
99 |
|
97 | |||
100 | #endif /* CHARTENGINE_P_H_ */ |
|
98 | #endif /* CHARTENGINE_P_H_ */ |
@@ -1,393 +1,393 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "charttheme_p.h" |
|
21 | #include "charttheme_p.h" | |
22 | #include "qchart.h" |
|
22 | #include "qchart.h" | |
23 | #include "qchart_p.h" |
|
23 | #include "qchart_p.h" | |
24 | #include "qchartview.h" |
|
24 | #include "qchartview.h" | |
25 | #include "qlegend.h" |
|
25 | #include "qlegend.h" | |
26 | #include "qabstractaxis.h" |
|
26 | #include "qabstractaxis.h" | |
27 | #include <QTime> |
|
27 | #include <QTime> | |
28 |
|
28 | |||
29 | //series |
|
29 | //series | |
30 | #include "qbarset.h" |
|
30 | #include "qbarset.h" | |
31 | #include "qabstractbarseries.h" |
|
31 | #include "qabstractbarseries.h" | |
32 | #include "qstackedbarseries.h" |
|
32 | #include "qstackedbarseries.h" | |
33 | #include "qpercentbarseries.h" |
|
33 | #include "qpercentbarseries.h" | |
34 | #include "qlineseries.h" |
|
34 | #include "qlineseries.h" | |
35 | #include "qareaseries.h" |
|
35 | #include "qareaseries.h" | |
36 | #include "qscatterseries.h" |
|
36 | #include "qscatterseries.h" | |
37 | #include "qpieseries.h" |
|
37 | #include "qpieseries.h" | |
38 | #include "qpieslice.h" |
|
38 | #include "qpieslice.h" | |
39 | #include "qpieslice_p.h" |
|
39 | #include "qpieslice_p.h" | |
40 | #include "qsplineseries.h" |
|
40 | #include "qsplineseries.h" | |
41 |
|
41 | |||
42 | //items |
|
42 | //items | |
43 | #include "chartaxis_p.h" |
|
43 | #include "chartaxis_p.h" | |
44 | #include "abstractbarchartitem_p.h" |
|
44 | #include "abstractbarchartitem_p.h" | |
45 | #include "stackedbarchartitem_p.h" |
|
45 | #include "stackedbarchartitem_p.h" | |
46 | #include "percentbarchartitem_p.h" |
|
46 | #include "percentbarchartitem_p.h" | |
47 | #include "linechartitem_p.h" |
|
47 | #include "linechartitem_p.h" | |
48 | #include "areachartitem_p.h" |
|
48 | #include "areachartitem_p.h" | |
49 | #include "scatterchartitem_p.h" |
|
49 | #include "scatterchartitem_p.h" | |
50 | #include "piechartitem_p.h" |
|
50 | #include "piechartitem_p.h" | |
51 | #include "splinechartitem_p.h" |
|
51 | #include "splinechartitem_p.h" | |
52 |
|
52 | |||
53 | //themes |
|
53 | //themes | |
54 | #include "chartthemesystem_p.h" |
|
54 | #include "chartthemesystem_p.h" | |
55 | #include "chartthemelight_p.h" |
|
55 | #include "chartthemelight_p.h" | |
56 | #include "chartthemebluecerulean_p.h" |
|
56 | #include "chartthemebluecerulean_p.h" | |
57 | #include "chartthemedark_p.h" |
|
57 | #include "chartthemedark_p.h" | |
58 | #include "chartthemebrownsand_p.h" |
|
58 | #include "chartthemebrownsand_p.h" | |
59 | #include "chartthemebluencs_p.h" |
|
59 | #include "chartthemebluencs_p.h" | |
60 | #include "chartthemehighcontrast_p.h" |
|
60 | #include "chartthemehighcontrast_p.h" | |
61 | #include "chartthemeblueicy_p.h" |
|
61 | #include "chartthemeblueicy_p.h" | |
62 |
|
62 | |||
63 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
63 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
64 |
|
64 | |||
65 | ChartTheme::ChartTheme(QChart::ChartTheme id) : |
|
65 | ChartTheme::ChartTheme(QChart::ChartTheme id) : | |
|
66 | m_id(id), | |||
66 | m_masterFont(QFont("arial", 14)), |
|
67 | m_masterFont(QFont("arial", 14)), | |
67 | m_labelFont(QFont("arial", 10)), |
|
68 | m_labelFont(QFont("arial", 10)), | |
68 | m_labelBrush(QColor(QRgb(0x000000))), |
|
69 | m_labelBrush(QColor(QRgb(0x000000))), | |
69 | m_axisLinePen(QPen(QRgb(0x000000))), |
|
70 | m_axisLinePen(QPen(QRgb(0x000000))), | |
70 | m_backgroundShadesPen(Qt::NoPen), |
|
71 | m_backgroundShadesPen(Qt::NoPen), | |
71 | m_backgroundShadesBrush(Qt::NoBrush), |
|
72 | m_backgroundShadesBrush(Qt::NoBrush), | |
72 | m_backgroundShades(BackgroundShadesNone), |
|
73 | m_backgroundShades(BackgroundShadesNone), | |
73 | m_backgroundDropShadowEnabled(false), |
|
74 | m_backgroundDropShadowEnabled(false), | |
74 | m_gridLinePen(QPen(QRgb(0x000000))), |
|
75 | m_gridLinePen(QPen(QRgb(0x000000))), | |
75 | m_force(false) |
|
76 | m_force(false) | |
76 | { |
|
77 | { | |
77 | m_id = id; |
|
|||
78 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); |
|
78 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 |
|
81 | |||
82 | ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme) |
|
82 | ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme) | |
83 | { |
|
83 | { | |
84 | switch(theme) { |
|
84 | switch(theme) { | |
85 | case QChart::ChartThemeLight: |
|
85 | case QChart::ChartThemeLight: | |
86 | return new ChartThemeLight(); |
|
86 | return new ChartThemeLight(); | |
87 | case QChart::ChartThemeBlueCerulean: |
|
87 | case QChart::ChartThemeBlueCerulean: | |
88 | return new ChartThemeBlueCerulean(); |
|
88 | return new ChartThemeBlueCerulean(); | |
89 | case QChart::ChartThemeDark: |
|
89 | case QChart::ChartThemeDark: | |
90 | return new ChartThemeDark(); |
|
90 | return new ChartThemeDark(); | |
91 | case QChart::ChartThemeBrownSand: |
|
91 | case QChart::ChartThemeBrownSand: | |
92 | return new ChartThemeBrownSand(); |
|
92 | return new ChartThemeBrownSand(); | |
93 | case QChart::ChartThemeBlueNcs: |
|
93 | case QChart::ChartThemeBlueNcs: | |
94 | return new ChartThemeBlueNcs(); |
|
94 | return new ChartThemeBlueNcs(); | |
95 | case QChart::ChartThemeHighContrast: |
|
95 | case QChart::ChartThemeHighContrast: | |
96 | return new ChartThemeHighContrast(); |
|
96 | return new ChartThemeHighContrast(); | |
97 | case QChart::ChartThemeBlueIcy: |
|
97 | case QChart::ChartThemeBlueIcy: | |
98 | return new ChartThemeBlueIcy(); |
|
98 | return new ChartThemeBlueIcy(); | |
99 | default: |
|
99 | default: | |
100 | return new ChartThemeSystem(); |
|
100 | return new ChartThemeSystem(); | |
101 | } |
|
101 | } | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | void ChartTheme::decorate(QChart *chart) |
|
104 | void ChartTheme::decorate(QChart *chart) | |
105 | { |
|
105 | { | |
106 | QBrush brush; |
|
106 | QBrush brush; | |
107 |
|
107 | |||
108 | if(m_force || brush == chart->backgroundBrush()) |
|
108 | if(m_force || brush == chart->backgroundBrush()) | |
109 | chart->setBackgroundBrush(m_chartBackgroundGradient); |
|
109 | chart->setBackgroundBrush(m_chartBackgroundGradient); | |
110 | chart->setTitleFont(m_masterFont); |
|
110 | chart->setTitleFont(m_masterFont); | |
111 | chart->setTitleBrush(m_labelBrush); |
|
111 | chart->setTitleBrush(m_labelBrush); | |
112 | chart->setDropShadowEnabled(m_backgroundDropShadowEnabled); |
|
112 | chart->setDropShadowEnabled(m_backgroundDropShadowEnabled); | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | void ChartTheme::decorate(QLegend *legend) |
|
115 | void ChartTheme::decorate(QLegend *legend) | |
116 | { |
|
116 | { | |
117 | QPen pen; |
|
117 | QPen pen; | |
118 | QBrush brush; |
|
118 | QBrush brush; | |
119 | QFont font; |
|
119 | QFont font; | |
120 |
|
120 | |||
121 | if (m_force || pen == legend->pen()) |
|
121 | if (m_force || pen == legend->pen()) | |
122 | legend->setPen(m_axisLinePen); |
|
122 | legend->setPen(m_axisLinePen); | |
123 |
|
123 | |||
124 | if (m_force || brush == legend->brush()) |
|
124 | if (m_force || brush == legend->brush()) | |
125 | legend->setBrush(m_chartBackgroundGradient); |
|
125 | legend->setBrush(m_chartBackgroundGradient); | |
126 |
|
126 | |||
127 | if (m_force || font == legend->font()) |
|
127 | if (m_force || font == legend->font()) | |
128 | legend->setFont(m_labelFont); |
|
128 | legend->setFont(m_labelFont); | |
129 |
|
129 | |||
130 | if (m_force || brush == legend->labelBrush()) |
|
130 | if (m_force || brush == legend->labelBrush()) | |
131 | legend->setLabelBrush(m_labelBrush); |
|
131 | legend->setLabelBrush(m_labelBrush); | |
132 | } |
|
132 | } | |
133 |
|
133 | |||
134 | void ChartTheme::decorate(QAreaSeries *series, int index) |
|
134 | void ChartTheme::decorate(QAreaSeries *series, int index) | |
135 | { |
|
135 | { | |
136 | QPen pen; |
|
136 | QPen pen; | |
137 | QBrush brush; |
|
137 | QBrush brush; | |
138 |
|
138 | |||
139 | if (m_force || pen == series->pen()){ |
|
139 | if (m_force || pen == series->pen()){ | |
140 | pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0)); |
|
140 | pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0)); | |
141 | pen.setWidthF(2); |
|
141 | pen.setWidthF(2); | |
142 | series->setPen(pen); |
|
142 | series->setPen(pen); | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | if (m_force || brush == series->brush()) { |
|
145 | if (m_force || brush == series->brush()) { | |
146 | QBrush brush(m_seriesColors.at(index % m_seriesColors.size())); |
|
146 | QBrush brush(m_seriesColors.at(index % m_seriesColors.size())); | |
147 | series->setBrush(brush); |
|
147 | series->setBrush(brush); | |
148 | } |
|
148 | } | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 |
|
151 | |||
152 | void ChartTheme::decorate(QLineSeries *series,int index) |
|
152 | void ChartTheme::decorate(QLineSeries *series,int index) | |
153 | { |
|
153 | { | |
154 | QPen pen; |
|
154 | QPen pen; | |
155 | if(m_force || pen == series->pen()){ |
|
155 | if(m_force || pen == series->pen()){ | |
156 | pen.setColor(m_seriesColors.at(index%m_seriesColors.size())); |
|
156 | pen.setColor(m_seriesColors.at(index%m_seriesColors.size())); | |
157 | pen.setWidthF(2); |
|
157 | pen.setWidthF(2); | |
158 | series->setPen(pen); |
|
158 | series->setPen(pen); | |
159 | } |
|
159 | } | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 | void ChartTheme::decorate(QAbstractBarSeries *series, int index) |
|
162 | void ChartTheme::decorate(QAbstractBarSeries *series, int index) | |
163 | { |
|
163 | { | |
164 | QBrush brush; |
|
164 | QBrush brush; | |
165 | QPen pen; |
|
165 | QPen pen; | |
166 | QList<QBarSet *> sets = series->barSets(); |
|
166 | QList<QBarSet *> sets = series->barSets(); | |
167 |
|
167 | |||
168 | qreal takeAtPos = 0.5; |
|
168 | qreal takeAtPos = 0.5; | |
169 | qreal step = 0.2; |
|
169 | qreal step = 0.2; | |
170 | if (sets.count() > 1 ) { |
|
170 | if (sets.count() > 1 ) { | |
171 | step = 1.0 / (qreal) sets.count(); |
|
171 | step = 1.0 / (qreal) sets.count(); | |
172 | if (sets.count() % m_seriesGradients.count()) |
|
172 | if (sets.count() % m_seriesGradients.count()) | |
173 | step *= m_seriesGradients.count(); |
|
173 | step *= m_seriesGradients.count(); | |
174 | else |
|
174 | else | |
175 | step *= (m_seriesGradients.count() - 1); |
|
175 | step *= (m_seriesGradients.count() - 1); | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | for (int i(0); i < sets.count(); i++) { |
|
178 | for (int i(0); i < sets.count(); i++) { | |
179 | int colorIndex = (index + i) % m_seriesGradients.count(); |
|
179 | int colorIndex = (index + i) % m_seriesGradients.count(); | |
180 | if (i > 0 && i % m_seriesGradients.count() == 0) { |
|
180 | if (i > 0 && i % m_seriesGradients.count() == 0) { | |
181 | // There is no dedicated base color for each sets, generate more colors |
|
181 | // There is no dedicated base color for each sets, generate more colors | |
182 | takeAtPos += step; |
|
182 | takeAtPos += step; | |
183 | if (takeAtPos == 1.0) |
|
183 | if (takeAtPos == 1.0) | |
184 | takeAtPos += step; |
|
184 | takeAtPos += step; | |
185 | takeAtPos -= (int) takeAtPos; |
|
185 | takeAtPos -= (int) takeAtPos; | |
186 | } |
|
186 | } | |
187 | if (m_force || brush == sets.at(i)->brush()) |
|
187 | if (m_force || brush == sets.at(i)->brush()) | |
188 | sets.at(i)->setBrush(colorAt(m_seriesGradients.at(colorIndex), takeAtPos)); |
|
188 | sets.at(i)->setBrush(colorAt(m_seriesGradients.at(colorIndex), takeAtPos)); | |
189 |
|
189 | |||
190 | // Pick label color from the opposite end of the gradient. |
|
190 | // Pick label color from the opposite end of the gradient. | |
191 | // 0.3 as a boundary seems to work well. |
|
191 | // 0.3 as a boundary seems to work well. | |
192 | if (m_force || brush == sets.at(i)->labelBrush()) { |
|
192 | if (m_force || brush == sets.at(i)->labelBrush()) { | |
193 | if (takeAtPos < 0.3) |
|
193 | if (takeAtPos < 0.3) | |
194 | sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1)); |
|
194 | sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1)); | |
195 | else |
|
195 | else | |
196 | sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0)); |
|
196 | sets.at(i)->setLabelBrush(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0)); | |
197 | } |
|
197 | } | |
198 |
|
198 | |||
199 | if (m_force || pen == sets.at(i)->pen()) { |
|
199 | if (m_force || pen == sets.at(i)->pen()) { | |
200 | QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0); |
|
200 | QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0); | |
201 | sets.at(i)->setPen(c); |
|
201 | sets.at(i)->setPen(c); | |
202 | } |
|
202 | } | |
203 | } |
|
203 | } | |
204 | } |
|
204 | } | |
205 |
|
205 | |||
206 | void ChartTheme::decorate(QScatterSeries *series, int index) |
|
206 | void ChartTheme::decorate(QScatterSeries *series, int index) | |
207 | { |
|
207 | { | |
208 | QPen pen; |
|
208 | QPen pen; | |
209 | QBrush brush; |
|
209 | QBrush brush; | |
210 |
|
210 | |||
211 | if (m_force || pen == series->pen()) { |
|
211 | if (m_force || pen == series->pen()) { | |
212 | pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0)); |
|
212 | pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0)); | |
213 | pen.setWidthF(2); |
|
213 | pen.setWidthF(2); | |
214 | series->setPen(pen); |
|
214 | series->setPen(pen); | |
215 | } |
|
215 | } | |
216 |
|
216 | |||
217 | if (m_force || brush == series->brush()) { |
|
217 | if (m_force || brush == series->brush()) { | |
218 | QBrush brush(m_seriesColors.at(index % m_seriesColors.size())); |
|
218 | QBrush brush(m_seriesColors.at(index % m_seriesColors.size())); | |
219 | series->setBrush(brush); |
|
219 | series->setBrush(brush); | |
220 | } |
|
220 | } | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
223 | void ChartTheme::decorate(QPieSeries *series, int index) |
|
223 | void ChartTheme::decorate(QPieSeries *series, int index) | |
224 | { |
|
224 | { | |
225 |
|
225 | |||
226 | for (int i(0); i < series->slices().count(); i++) { |
|
226 | for (int i(0); i < series->slices().count(); i++) { | |
227 |
|
227 | |||
228 | QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0); |
|
228 | QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0); | |
229 |
|
229 | |||
230 | // Get color for a slice from a gradient linearly, beginning from the start of the gradient |
|
230 | // Get color for a slice from a gradient linearly, beginning from the start of the gradient | |
231 | qreal pos = (qreal) (i + 1) / (qreal) series->count(); |
|
231 | qreal pos = (qreal) (i + 1) / (qreal) series->count(); | |
232 | QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos); |
|
232 | QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos); | |
233 |
|
233 | |||
234 | QPieSlice *s = series->slices().at(i); |
|
234 | QPieSlice *s = series->slices().at(i); | |
235 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); |
|
235 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); | |
236 |
|
236 | |||
237 | if (m_force || d->m_data.m_slicePen.isThemed()) |
|
237 | if (m_force || d->m_data.m_slicePen.isThemed()) | |
238 | d->setPen(penColor, true); |
|
238 | d->setPen(penColor, true); | |
239 |
|
239 | |||
240 | if (m_force || d->m_data.m_sliceBrush.isThemed()) |
|
240 | if (m_force || d->m_data.m_sliceBrush.isThemed()) | |
241 | d->setBrush(brushColor, true); |
|
241 | d->setBrush(brushColor, true); | |
242 |
|
242 | |||
243 | if (m_force || d->m_data.m_labelBrush.isThemed()) |
|
243 | if (m_force || d->m_data.m_labelBrush.isThemed()) | |
244 | d->setLabelBrush(m_labelBrush.color(), true); |
|
244 | d->setLabelBrush(m_labelBrush.color(), true); | |
245 |
|
245 | |||
246 | if (m_force || d->m_data.m_labelFont.isThemed()) |
|
246 | if (m_force || d->m_data.m_labelFont.isThemed()) | |
247 | d->setLabelFont(m_labelFont, true); |
|
247 | d->setLabelFont(m_labelFont, true); | |
248 | } |
|
248 | } | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | void ChartTheme::decorate(QSplineSeries *series, int index) |
|
251 | void ChartTheme::decorate(QSplineSeries *series, int index) | |
252 | { |
|
252 | { | |
253 | QPen pen; |
|
253 | QPen pen; | |
254 | if(m_force || pen == series->pen()){ |
|
254 | if(m_force || pen == series->pen()){ | |
255 | pen.setColor(m_seriesColors.at(index%m_seriesColors.size())); |
|
255 | pen.setColor(m_seriesColors.at(index%m_seriesColors.size())); | |
256 | pen.setWidthF(2); |
|
256 | pen.setWidthF(2); | |
257 | series->setPen(pen); |
|
257 | series->setPen(pen); | |
258 | } |
|
258 | } | |
259 | } |
|
259 | } | |
260 |
|
260 | |||
261 | void ChartTheme::decorate(QAbstractAxis *axis) |
|
261 | void ChartTheme::decorate(QAbstractAxis *axis) | |
262 | { |
|
262 | { | |
263 | QPen pen; |
|
263 | QPen pen; | |
264 | QBrush brush; |
|
264 | QBrush brush; | |
265 | QFont font; |
|
265 | QFont font; | |
266 |
|
266 | |||
267 | bool axisX = axis->orientation()== Qt::Horizontal; |
|
267 | bool axisX = axis->orientation()== Qt::Horizontal; | |
268 |
|
268 | |||
269 | if (axis->isLineVisible()) { |
|
269 | if (axis->isLineVisible()) { | |
270 |
|
270 | |||
271 | if(m_force || brush == axis->labelsBrush()){ |
|
271 | if(m_force || brush == axis->labelsBrush()){ | |
272 | axis->setLabelsBrush(m_labelBrush); |
|
272 | axis->setLabelsBrush(m_labelBrush); | |
273 | } |
|
273 | } | |
274 | if(m_force || pen == axis->labelsPen()){ |
|
274 | if(m_force || pen == axis->labelsPen()){ | |
275 | axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons |
|
275 | axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons | |
276 | } |
|
276 | } | |
277 |
|
277 | |||
278 |
|
278 | |||
279 | if (m_force || axis->shadesVisible()) { |
|
279 | if (m_force || axis->shadesVisible()) { | |
280 |
|
280 | |||
281 | if(m_force || brush == axis->shadesBrush()){ |
|
281 | if(m_force || brush == axis->shadesBrush()){ | |
282 | axis->setShadesBrush(m_backgroundShadesBrush); |
|
282 | axis->setShadesBrush(m_backgroundShadesBrush); | |
283 | } |
|
283 | } | |
284 |
|
284 | |||
285 | if(m_force || pen == axis->shadesPen()){ |
|
285 | if(m_force || pen == axis->shadesPen()){ | |
286 | axis->setShadesPen(m_backgroundShadesPen); |
|
286 | axis->setShadesPen(m_backgroundShadesPen); | |
287 | } |
|
287 | } | |
288 |
|
288 | |||
289 | if( m_force && (m_backgroundShades == BackgroundShadesBoth |
|
289 | if( m_force && (m_backgroundShades == BackgroundShadesBoth | |
290 | || (m_backgroundShades == BackgroundShadesVertical && axisX) |
|
290 | || (m_backgroundShades == BackgroundShadesVertical && axisX) | |
291 | || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))){ |
|
291 | || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))){ | |
292 | axis->setShadesVisible(true); |
|
292 | axis->setShadesVisible(true); | |
293 |
|
293 | |||
294 | } |
|
294 | } | |
295 | } |
|
295 | } | |
296 |
|
296 | |||
297 | if(m_force || pen == axis->linePen()){ |
|
297 | if(m_force || pen == axis->linePen()){ | |
298 | axis->setLinePen(m_axisLinePen); |
|
298 | axis->setLinePen(m_axisLinePen); | |
299 | } |
|
299 | } | |
300 |
|
300 | |||
301 | if(m_force || pen == axis->gridLinePen()){ |
|
301 | if(m_force || pen == axis->gridLinePen()){ | |
302 | axis->setGridLinePen(m_gridLinePen); |
|
302 | axis->setGridLinePen(m_gridLinePen); | |
303 | } |
|
303 | } | |
304 |
|
304 | |||
305 | if(m_force || font == axis->labelsFont()){ |
|
305 | if(m_force || font == axis->labelsFont()){ | |
306 | axis->setLabelsFont(m_labelFont); |
|
306 | axis->setLabelsFont(m_labelFont); | |
307 | } |
|
307 | } | |
308 | } |
|
308 | } | |
309 | } |
|
309 | } | |
310 |
|
310 | |||
311 | void ChartTheme::generateSeriesGradients() |
|
311 | void ChartTheme::generateSeriesGradients() | |
312 | { |
|
312 | { | |
313 | // Generate gradients in HSV color space |
|
313 | // Generate gradients in HSV color space | |
314 | foreach (const QColor& color, m_seriesColors) { |
|
314 | foreach (const QColor& color, m_seriesColors) { | |
315 | QLinearGradient g; |
|
315 | QLinearGradient g; | |
316 | qreal h = color.hsvHueF(); |
|
316 | qreal h = color.hsvHueF(); | |
317 | qreal s = color.hsvSaturationF(); |
|
317 | qreal s = color.hsvSaturationF(); | |
318 |
|
318 | |||
319 | // TODO: tune the algorithm to give nice results with most base colors defined in |
|
319 | // TODO: tune the algorithm to give nice results with most base colors defined in | |
320 | // most themes. The rest of the gradients we can define manually in theme specific |
|
320 | // most themes. The rest of the gradients we can define manually in theme specific | |
321 | // implementation. |
|
321 | // implementation. | |
322 | QColor start = color; |
|
322 | QColor start = color; | |
323 | start.setHsvF(h, 0.0, 1.0); |
|
323 | start.setHsvF(h, 0.0, 1.0); | |
324 | g.setColorAt(0.0, start); |
|
324 | g.setColorAt(0.0, start); | |
325 |
|
325 | |||
326 | g.setColorAt(0.5, color); |
|
326 | g.setColorAt(0.5, color); | |
327 |
|
327 | |||
328 | QColor end = color; |
|
328 | QColor end = color; | |
329 | end.setHsvF(h, s, 0.25); |
|
329 | end.setHsvF(h, s, 0.25); | |
330 | g.setColorAt(1.0, end); |
|
330 | g.setColorAt(1.0, end); | |
331 |
|
331 | |||
332 | m_seriesGradients << g; |
|
332 | m_seriesGradients << g; | |
333 | } |
|
333 | } | |
334 | } |
|
334 | } | |
335 |
|
335 | |||
336 |
|
336 | |||
337 | QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos) |
|
337 | QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos) | |
338 | { |
|
338 | { | |
339 | Q_ASSERT(pos >= 0.0 && pos <= 1.0); |
|
339 | Q_ASSERT(pos >= 0.0 && pos <= 1.0); | |
340 | qreal r = start.redF() + ((end.redF() - start.redF()) * pos); |
|
340 | qreal r = start.redF() + ((end.redF() - start.redF()) * pos); | |
341 | qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos); |
|
341 | qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos); | |
342 | qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos); |
|
342 | qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos); | |
343 | QColor c; |
|
343 | QColor c; | |
344 | c.setRgbF(r, g, b); |
|
344 | c.setRgbF(r, g, b); | |
345 | return c; |
|
345 | return c; | |
346 | } |
|
346 | } | |
347 |
|
347 | |||
348 | QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos) |
|
348 | QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos) | |
349 | { |
|
349 | { | |
350 | Q_ASSERT(pos >= 0 && pos <= 1.0); |
|
350 | Q_ASSERT(pos >= 0 && pos <= 1.0); | |
351 |
|
351 | |||
352 | QGradientStops stops = gradient.stops(); |
|
352 | QGradientStops stops = gradient.stops(); | |
353 | int count = stops.count(); |
|
353 | int count = stops.count(); | |
354 |
|
354 | |||
355 | // find previous stop relative to position |
|
355 | // find previous stop relative to position | |
356 | QGradientStop prev = stops.first(); |
|
356 | QGradientStop prev = stops.first(); | |
357 | for (int i = 0; i < count; i++) { |
|
357 | for (int i = 0; i < count; i++) { | |
358 | QGradientStop stop = stops.at(i); |
|
358 | QGradientStop stop = stops.at(i); | |
359 | if (pos > stop.first) |
|
359 | if (pos > stop.first) | |
360 | prev = stop; |
|
360 | prev = stop; | |
361 |
|
361 | |||
362 | // given position is actually a stop position? |
|
362 | // given position is actually a stop position? | |
363 | if (pos == stop.first) { |
|
363 | if (pos == stop.first) { | |
364 | //qDebug() << "stop color" << pos; |
|
364 | //qDebug() << "stop color" << pos; | |
365 | return stop.second; |
|
365 | return stop.second; | |
366 | } |
|
366 | } | |
367 | } |
|
367 | } | |
368 |
|
368 | |||
369 | // find next stop relative to position |
|
369 | // find next stop relative to position | |
370 | QGradientStop next = stops.last(); |
|
370 | QGradientStop next = stops.last(); | |
371 | for (int i = count - 1; i >= 0; i--) { |
|
371 | for (int i = count - 1; i >= 0; i--) { | |
372 | QGradientStop stop = stops.at(i); |
|
372 | QGradientStop stop = stops.at(i); | |
373 | if (pos < stop.first) |
|
373 | if (pos < stop.first) | |
374 | next = stop; |
|
374 | next = stop; | |
375 | } |
|
375 | } | |
376 |
|
376 | |||
377 | //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first; |
|
377 | //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first; | |
378 |
|
378 | |||
379 | qreal range = next.first - prev.first; |
|
379 | qreal range = next.first - prev.first; | |
380 | qreal posDelta = pos - prev.first; |
|
380 | qreal posDelta = pos - prev.first; | |
381 | qreal relativePos = posDelta / range; |
|
381 | qreal relativePos = posDelta / range; | |
382 |
|
382 | |||
383 | //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos; |
|
383 | //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos; | |
384 |
|
384 | |||
385 | return colorAt(prev.second, next.second, relativePos); |
|
385 | return colorAt(prev.second, next.second, relativePos); | |
386 | } |
|
386 | } | |
387 |
|
387 | |||
388 | void ChartTheme::setForced(bool enabled) |
|
388 | void ChartTheme::setForced(bool enabled) | |
389 | { |
|
389 | { | |
390 | m_force = enabled; |
|
390 | m_force = enabled; | |
391 | } |
|
391 | } | |
392 |
|
392 | |||
393 | QTCOMMERCIALCHART_END_NAMESPACE |
|
393 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,70 +1,67 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef LEGENDLAYOUT_H_ |
|
21 | #ifndef LEGENDLAYOUT_H_ | |
22 | #define LEGENDLAYOUT_H_ |
|
22 | #define LEGENDLAYOUT_H_ | |
23 | #include <QGraphicsLayout> |
|
23 | #include <QGraphicsLayout> | |
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | class QLegend; |
|
28 | class QLegend; | |
29 |
|
29 | |||
30 | class LegendLayout : public QGraphicsLayout |
|
30 | class LegendLayout : public QGraphicsLayout | |
31 | { |
|
31 | { | |
32 | public: |
|
32 | public: | |
33 |
|
33 | |||
34 | LegendLayout(QLegend* legend); |
|
34 | LegendLayout(QLegend* legend); | |
35 | virtual ~LegendLayout(); |
|
35 | virtual ~LegendLayout(); | |
36 |
|
36 | |||
37 | void setGeometry(const QRectF& rect); |
|
37 | void setGeometry(const QRectF& rect); | |
38 |
|
38 | |||
39 | void setOffset(qreal x, qreal y); |
|
39 | void setOffset(qreal x, qreal y); | |
40 | QPointF offset() const; |
|
40 | QPointF offset() const; | |
41 |
|
41 | |||
42 | protected: |
|
42 | protected: | |
43 | QSizeF sizeHint ( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; |
|
43 | QSizeF sizeHint ( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; | |
44 | int count() const { return 0; } |
|
44 | int count() const { return 0; } | |
45 | QGraphicsLayoutItem* itemAt(int) const { return 0; }; |
|
45 | QGraphicsLayoutItem* itemAt(int) const { return 0; }; | |
46 | void removeAt(int){}; |
|
46 | void removeAt(int){}; | |
47 |
|
47 | |||
48 | private: |
|
48 | private: | |
49 | void setAttachedGeometry(const QRectF& rect); |
|
49 | void setAttachedGeometry(const QRectF& rect); | |
50 | void setDettachedGeometry(const QRectF& rect); |
|
50 | void setDettachedGeometry(const QRectF& rect); | |
51 |
|
51 | |||
52 | private: |
|
52 | private: | |
53 | QLegend* m_legend; |
|
53 | QLegend* m_legend; | |
54 | int m_marginBig; |
|
|||
55 | int m_marginSmall; |
|
|||
56 | int m_marginTiny; |
|
|||
57 | qreal m_offsetX; |
|
54 | qreal m_offsetX; | |
58 | qreal m_offsetY; |
|
55 | qreal m_offsetY; | |
59 | qreal m_minOffsetX; |
|
56 | qreal m_minOffsetX; | |
60 | qreal m_minOffsetY; |
|
57 | qreal m_minOffsetY; | |
61 | qreal m_maxOffsetX; |
|
58 | qreal m_maxOffsetX; | |
62 | qreal m_maxOffsetY; |
|
59 | qreal m_maxOffsetY; | |
63 | qreal m_width; |
|
60 | qreal m_width; | |
64 | qreal m_height; |
|
61 | qreal m_height; | |
65 |
|
62 | |||
66 | }; |
|
63 | }; | |
67 |
|
64 | |||
68 | QTCOMMERCIALCHART_END_NAMESPACE |
|
65 | QTCOMMERCIALCHART_END_NAMESPACE | |
69 |
|
66 | |||
70 | #endif |
|
67 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now