@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef AXISANIMATION |
|
21 | #ifndef AXISANIMATION_H | |
22 |
#define AXISANIMATION |
|
22 | #define AXISANIMATION_H | |
23 |
|
23 | |||
24 | #include "axis_p.h" |
|
24 | #include "axis_p.h" | |
25 | #include "chartanimation_p.h" |
|
25 | #include "chartanimation_p.h" |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef BARANIMATION_P_H |
|
21 | #ifndef BARANIMATION_P_H | |
22 |
#define BARANIMATION_P_H |
|
22 | #define BARANIMATION_P_H | |
23 |
|
23 | |||
24 | #include "chartanimation_p.h" |
|
24 | #include "chartanimation_p.h" | |
25 | #include "barchartitem_p.h" |
|
25 | #include "barchartitem_p.h" |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef CHARTANIMATION_H |
|
21 | #ifndef CHARTANIMATION_H | |
22 |
#define CHARTANIMATION_H |
|
22 | #define CHARTANIMATION_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include <QVariantAnimation> |
|
25 | #include <QVariantAnimation> |
@@ -18,8 +18,9 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef CHARTANIMATOR_P_H |
|
21 | #ifndef CHARTANIMATOR_P_H | |
22 |
#define CHARTANIMATOR_P_H |
|
22 | #define CHARTANIMATOR_P_H | |
|
23 | ||||
23 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
24 | #include "chartanimation_p.h" |
|
25 | #include "chartanimation_p.h" | |
25 | #include "piechartitem_p.h" |
|
26 | #include "piechartitem_p.h" |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef PIEANIMATION_P_H |
|
21 | #ifndef PIEANIMATION_P_H | |
22 |
#define PIEANIMATION_P_H |
|
22 | #define PIEANIMATION_P_H | |
23 |
|
23 | |||
24 | #include "chartanimation_p.h" |
|
24 | #include "chartanimation_p.h" | |
25 | #include "piechartitem_p.h" |
|
25 | #include "piechartitem_p.h" |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef PIESLICEANIMATION_P_H |
|
21 | #ifndef PIESLICEANIMATION_P_H | |
22 |
#define PIESLICEANIMATION_P_H |
|
22 | #define PIESLICEANIMATION_P_H | |
23 |
|
23 | |||
24 | #include "piechartitem_p.h" |
|
24 | #include "piechartitem_p.h" | |
25 | #include <QVariantAnimation> |
|
25 | #include <QVariantAnimation> |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef SPLINEANIMATION_P_H |
|
21 | #ifndef SPLINEANIMATION_P_H | |
22 |
#define SPLINEANIMATION_P_H |
|
22 | #define SPLINEANIMATION_P_H | |
23 | #include "chartanimation_p.h" |
|
23 | #include "chartanimation_p.h" | |
24 | #include <QPointF> |
|
24 | #include <QPointF> | |
25 |
|
25 |
@@ -18,8 +18,9 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef XY |
|
21 | #ifndef XYANIMATION_P_H | |
22 |
#define XY |
|
22 | #define XYANIMATION_P_H | |
|
23 | ||||
23 | #include "chartanimation_p.h" |
|
24 | #include "chartanimation_p.h" | |
24 | #include <QPointF> |
|
25 | #include <QPointF> | |
25 |
|
26 |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef QAREASERIES_H |
|
21 | #ifndef QAREASERIES_H | |
22 |
#define QAREASERIES_H |
|
22 | #define QAREASERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qseries.h> |
|
25 | #include <qseries.h> |
@@ -27,8 +27,8 | |||||
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
#ifndef QAREASERIES_P_H |
|
30 | #ifndef QAREASERIES_P_H | |
31 |
#define QAREASERIES_P_H |
|
31 | #define QAREASERIES_P_H | |
32 |
|
32 | |||
33 | #include "qseries_p.h" |
|
33 | #include "qseries_p.h" | |
34 |
|
34 |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef AXIS |
|
21 | #ifndef AXIS_H | |
22 |
#define AXIS |
|
22 | #define AXIS_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "chart_p.h" |
|
25 | #include "chart_p.h" |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef QCHARTAXIS_H |
|
21 | #ifndef QCHARTAXIS_H | |
22 |
#define QCHARTAXIS_H |
|
22 | #define QCHARTAXIS_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qchartaxiscategories.h> |
|
25 | #include <qchartaxiscategories.h> |
@@ -27,8 +27,8 | |||||
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
#ifndef QCHARTAXIS_P_H |
|
30 | #ifndef QCHARTAXIS_P_H | |
31 |
#define QCHARTAXIS_P_H |
|
31 | #define QCHARTAXIS_P_H | |
32 |
|
32 | |||
33 | #include "qchartaxis.h" |
|
33 | #include "qchartaxis.h" | |
34 |
|
34 |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef QCHARTAXISCATEGORIES_H |
|
21 | #ifndef QCHARTAXISCATEGORIES_H | |
22 |
#define QCHARTAXISCATEGORIES_H |
|
22 | #define QCHARTAXISCATEGORIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qbarseries.h> |
|
25 | #include <qbarseries.h> |
@@ -27,8 +27,8 | |||||
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
#ifndef QCHARTAXISCATEGORIES_P_H |
|
30 | #ifndef QCHARTAXISCATEGORIES_P_H | |
31 |
#define QCHARTAXISCATEGORIES_P_H |
|
31 | #define QCHARTAXISCATEGORIES_P_H | |
32 |
|
32 | |||
33 | #include "qchartaxiscategories.h" |
|
33 | #include "qchartaxiscategories.h" | |
34 |
|
34 |
@@ -18,11 +18,11 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
|
21 | #include "barchartmodel_p.h" | |||
|
22 | #include "qbarset.h" | |||
21 | #include <limits.h> |
|
23 | #include <limits.h> | |
22 | #include <QVector> |
|
24 | #include <QVector> | |
23 | #include <QDebug> |
|
25 | #include <QDebug> | |
24 | #include "barchartmodel_p.h" |
|
|||
25 | #include "qbarset.h" |
|
|||
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
@@ -195,4 +195,4 QString BarChartModel::categoryName(int category) | |||||
195 |
|
195 | |||
196 | #include "moc_barchartmodel_p.cpp" |
|
196 | #include "moc_barchartmodel_p.cpp" | |
197 |
|
197 | |||
198 |
QTCOMMERCIALCHART_END_NAMESPACE |
|
198 | QTCOMMERCIALCHART_END_NAMESPACE No newline at end of file |
@@ -27,8 +27,8 | |||||
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
#ifndef QPERCENTBARSERIES_P_H |
|
30 | #ifndef QPERCENTBARSERIES_P_H | |
31 |
#define QPERCENTBARSERIES_P_H |
|
31 | #define QPERCENTBARSERIES_P_H | |
32 |
|
32 | |||
33 | #include "qbarseries_p.h" |
|
33 | #include "qbarseries_p.h" | |
34 | #include "domain_p.h" |
|
34 | #include "domain_p.h" |
@@ -27,8 +27,8 | |||||
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
#ifndef QSTACKEDBARSERIES_P_H |
|
30 | #ifndef QSTACKEDBARSERIES_P_H | |
31 |
#define QSTACKEDBARSERIES_P_H |
|
31 | #define QSTACKEDBARSERIES_P_H | |
32 |
|
32 | |||
33 | #include "qbarseries_p.h" |
|
33 | #include "qbarseries_p.h" | |
34 | #include "domain_p.h" |
|
34 | #include "domain_p.h" |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef CHART_H |
|
21 | #ifndef CHART_H | |
22 |
#define CHART_H |
|
22 | #define CHART_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include <QRect> |
|
25 | #include <QRect> |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef CHARTBACKGROUND_H |
|
21 | #ifndef CHARTBACKGROUND_H | |
22 |
#define CHARTBACKGROUND_H |
|
22 | #define CHARTBACKGROUND_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include <QGraphicsRectItem> |
|
25 | #include <QGraphicsRectItem> |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef CHARTCONFIG_H |
|
21 | #ifndef CHARTCONFIG_H | |
22 |
#define CHARTCONFIG_H |
|
22 | #define CHARTCONFIG_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #ifdef Q_CC_MSVC |
|
25 | #ifdef Q_CC_MSVC |
@@ -27,8 +27,8 | |||||
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 "qseries.h" |
|
33 | #include "qseries.h" | |
34 | #include "domain_p.h" |
|
34 | #include "domain_p.h" |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef CHARTITEM_H |
|
21 | #ifndef CHARTITEM_H | |
22 |
#define CHARTITEM_H |
|
22 | #define CHARTITEM_H | |
23 |
|
23 | |||
24 | #include "chart_p.h" |
|
24 | #include "chart_p.h" | |
25 | #include "chartpresenter_p.h" |
|
25 | #include "chartpresenter_p.h" |
@@ -1,27 +1,26 | |||||
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 | #include "chartpresenter_p.h" | ||
21 | #include "qchart.h" |
|
21 | #include "qchart.h" | |
22 | #include "qchart_p.h" |
|
22 | #include "qchart_p.h" | |
23 | #include "qchartaxis.h" |
|
23 | #include "qchartaxis.h" | |
24 | #include "chartpresenter_p.h" |
|
|||
25 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
26 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
27 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
@@ -33,26 +32,26 | |||||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
33 | |||
35 | ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), |
|
34 | ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), | |
36 |
|
|
35 | m_chart(chart), | |
37 |
|
|
36 | m_animator(0), | |
38 |
|
|
37 | m_dataset(dataset), | |
39 |
|
|
38 | m_chartTheme(0), | |
40 |
|
|
39 | m_chartRect(QRectF(QPoint(0,0),m_chart->size())), | |
41 |
|
|
40 | m_options(QChart::NoAnimation), | |
42 |
|
|
41 | m_minLeftMargin(0), | |
43 |
|
|
42 | m_minBottomMargin(0), | |
44 |
|
|
43 | m_backgroundItem(0), | |
45 |
|
|
44 | m_titleItem(0), | |
46 |
|
|
45 | m_marginBig(60), | |
47 |
|
|
46 | m_marginSmall(20), | |
48 |
|
|
47 | m_marginTiny(10), | |
49 |
|
|
48 | m_chartMargins(QRect(m_marginBig,m_marginBig,0,0)) | |
50 | { |
|
49 | { | |
51 | } |
|
50 | } | |
52 |
|
51 | |||
53 | ChartPresenter::~ChartPresenter() |
|
52 | ChartPresenter::~ChartPresenter() | |
54 | { |
|
53 | { | |
55 |
|
|
54 | delete m_chartTheme; | |
56 | } |
|
55 | } | |
57 |
|
56 | |||
58 | void ChartPresenter::setGeometry(const QRectF& rect) |
|
57 | void ChartPresenter::setGeometry(const QRectF& rect) | |
@@ -65,23 +64,23 void ChartPresenter::setGeometry(const QRectF& rect) | |||||
65 | void ChartPresenter::setMinimumMarginWidth(Axis* axis, qreal width) |
|
64 | void ChartPresenter::setMinimumMarginWidth(Axis* axis, qreal width) | |
66 | { |
|
65 | { | |
67 | switch(axis->axisType()){ |
|
66 | switch(axis->axisType()){ | |
68 |
|
|
67 | case Axis::X_AXIS: | |
69 |
|
|
68 | { | |
70 |
|
|
69 | if(width>m_chartRect.width()+ m_chartMargins.left()) { | |
71 |
|
|
70 | m_minLeftMargin= width - m_chartRect.width(); | |
72 |
|
|
71 | updateLayout(); | |
73 | } |
|
|||
74 | break; |
|
|||
75 | } |
|
72 | } | |
76 | case Axis::Y_AXIS: |
|
73 | break; | |
77 | { |
|
74 | } | |
|
75 | case Axis::Y_AXIS: | |||
|
76 | { | |||
78 |
|
77 | |||
79 |
|
|
78 | if(m_minLeftMargin!=width){ | |
80 |
|
|
79 | m_minLeftMargin= width; | |
81 |
|
|
80 | updateLayout(); | |
82 | } |
|
|||
83 | break; |
|
|||
84 | } |
|
81 | } | |
|
82 | break; | |||
|
83 | } | |||
85 |
|
84 | |||
86 | } |
|
85 | } | |
87 | } |
|
86 | } | |
@@ -89,23 +88,23 void ChartPresenter::setMinimumMarginWidth(Axis* axis, qreal width) | |||||
89 | void ChartPresenter::setMinimumMarginHeight(Axis* axis, qreal height) |
|
88 | void ChartPresenter::setMinimumMarginHeight(Axis* axis, qreal height) | |
90 | { |
|
89 | { | |
91 | switch(axis->axisType()){ |
|
90 | switch(axis->axisType()){ | |
92 |
|
|
91 | case Axis::X_AXIS: | |
93 |
|
|
92 | { | |
94 |
|
|
93 | if(m_minBottomMargin!=height) { | |
95 |
|
|
94 | m_minBottomMargin= height; | |
96 |
|
|
95 | updateLayout(); | |
97 | } |
|
|||
98 | break; |
|
|||
99 | } |
|
96 | } | |
100 | case Axis::Y_AXIS: |
|
97 | break; | |
101 | { |
|
98 | } | |
|
99 | case Axis::Y_AXIS: | |||
|
100 | { | |||
102 |
|
101 | |||
103 |
|
|
102 | if(height>m_chartMargins.bottom()+m_chartRect.height()){ | |
104 |
|
|
103 | m_minBottomMargin= height - m_chartRect.height(); | |
105 |
|
|
104 | updateLayout(); | |
106 | } |
|
|||
107 | break; |
|
|||
108 | } |
|
105 | } | |
|
106 | break; | |||
|
107 | } | |||
109 |
|
108 | |||
110 | } |
|
109 | } | |
111 | } |
|
110 | } | |
@@ -149,14 +148,14 void ChartPresenter::handleAxisRemoved(QChartAxis* axis) | |||||
149 |
|
148 | |||
150 | void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) |
|
149 | void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) | |
151 | { |
|
150 | { | |
152 |
|
|
151 | Chart *item = series->d_ptr->createGraphics(this); | |
153 |
|
|
152 | Q_ASSERT(item); | |
154 |
|
|
153 | QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF))); | |
155 |
|
|
154 | QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),item,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); | |
156 |
|
|
155 | //initialize | |
157 |
|
|
156 | item->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY()); | |
158 |
|
|
157 | if(m_chartRect.isValid()) item->handleGeometryChanged(m_chartRect); | |
159 |
|
|
158 | m_chartItems.insert(series,item); | |
160 | } |
|
159 | } | |
161 |
|
160 | |||
162 | void ChartPresenter::handleSeriesRemoved(QSeries* series) |
|
161 | void ChartPresenter::handleSeriesRemoved(QSeries* series) | |
@@ -166,19 +165,19 void ChartPresenter::handleSeriesRemoved(QSeries* series) | |||||
166 | if(m_animator) { |
|
165 | if(m_animator) { | |
167 | //small hack to handle area animations |
|
166 | //small hack to handle area animations | |
168 | if(series->type()==QSeries::SeriesTypeArea){ |
|
167 | if(series->type()==QSeries::SeriesTypeArea){ | |
169 |
|
|
168 | QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series); | |
170 |
|
|
169 | AreaChartItem* area = static_cast<AreaChartItem*>(item); | |
171 |
|
|
170 | m_animator->removeAnimation(area->upperLineItem()); | |
172 |
|
|
171 | if(areaSeries->lowerSeries()) m_animator->removeAnimation(area->lowerLineItem()); | |
173 | }else |
|
172 | }else | |
174 | m_animator->removeAnimation(item); |
|
173 | m_animator->removeAnimation(item); | |
175 | } |
|
174 | } | |
176 | delete item; |
|
175 | delete item; | |
177 | } |
|
176 | } | |
178 |
|
177 | |||
179 | void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force) |
|
178 | void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force) | |
180 | { |
|
179 | { | |
181 |
|
|
180 | if(m_chartTheme && m_chartTheme->id() == theme) return; | |
182 | delete m_chartTheme; |
|
181 | delete m_chartTheme; | |
183 | m_chartTheme = ChartTheme::createTheme(theme); |
|
182 | m_chartTheme = ChartTheme::createTheme(theme); | |
184 | m_chartTheme->setForced(force); |
|
183 | m_chartTheme->setForced(force); | |
@@ -208,75 +207,75 void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options) | |||||
208 |
|
207 | |||
209 | void ChartPresenter::resetAllElements() |
|
208 | void ChartPresenter::resetAllElements() | |
210 | { |
|
209 | { | |
211 |
|
|
210 | QList<QChartAxis*> axisList = m_axisItems.uniqueKeys(); | |
212 |
|
|
211 | QList<QSeries*> seriesList = m_chartItems.uniqueKeys(); | |
213 |
|
212 | |||
214 |
|
|
213 | foreach(QChartAxis* axis, axisList) { | |
215 |
|
|
214 | handleAxisRemoved(axis); | |
216 |
|
|
215 | handleAxisAdded(axis,m_dataset->domain(axis)); | |
217 |
|
|
216 | } | |
218 |
|
|
217 | foreach(QSeries* series, seriesList) { | |
219 |
|
|
218 | handleSeriesRemoved(series); | |
220 |
|
|
219 | handleSeriesAdded(series,m_dataset->domain(series)); | |
221 |
|
|
220 | } | |
222 | } |
|
221 | } | |
223 |
|
222 | |||
224 | void ChartPresenter::zoomIn() |
|
223 | void ChartPresenter::zoomIn() | |
225 | { |
|
224 | { | |
226 |
|
|
225 | QRectF rect = chartGeometry(); | |
227 |
|
|
226 | rect.setWidth(rect.width()/2); | |
228 |
|
|
227 | rect.setHeight(rect.height()/2); | |
229 |
|
|
228 | rect.moveCenter(chartGeometry().center()); | |
230 |
|
|
229 | zoomIn(rect); | |
231 | } |
|
230 | } | |
232 |
|
231 | |||
233 | void ChartPresenter::zoomIn(const QRectF& rect) |
|
232 | void ChartPresenter::zoomIn(const QRectF& rect) | |
234 | { |
|
233 | { | |
235 |
|
|
234 | QRectF r = rect.normalized(); | |
236 | r.translate(-m_chartMargins.topLeft()); |
|
235 | r.translate(-m_chartMargins.topLeft()); | |
237 |
|
|
236 | if(m_animator) { | |
238 |
|
237 | |||
239 |
|
|
238 | QPointF point(r.center().x()/chartGeometry().width(),r.center().y()/chartGeometry().height()); | |
240 |
|
|
239 | m_animator->setState(ChartAnimator::ZoomInState,point); | |
241 | } |
|
240 | } | |
242 |
|
|
241 | m_dataset->zoomInDomain(r,chartGeometry().size()); | |
243 |
|
|
242 | if(m_animator) { | |
244 |
|
|
243 | m_animator->setState(ChartAnimator::ShowState); | |
245 | } |
|
244 | } | |
246 | } |
|
245 | } | |
247 |
|
246 | |||
248 | void ChartPresenter::zoomOut() |
|
247 | void ChartPresenter::zoomOut() | |
249 | { |
|
248 | { | |
250 |
|
|
249 | if(m_animator) | |
251 | { |
|
250 | { | |
252 |
|
|
251 | m_animator->setState(ChartAnimator::ZoomOutState); | |
253 | } |
|
252 | } | |
254 |
|
253 | |||
255 |
|
|
254 | QSizeF size = chartGeometry().size(); | |
256 |
|
|
255 | QRectF rect = chartGeometry(); | |
257 | rect.translate(-m_chartMargins.topLeft()); |
|
256 | rect.translate(-m_chartMargins.topLeft()); | |
258 | m_dataset->zoomOutDomain(rect.adjusted(size.width()/4,size.height()/4,-size.width()/4,-size.height()/4),size); |
|
257 | m_dataset->zoomOutDomain(rect.adjusted(size.width()/4,size.height()/4,-size.width()/4,-size.height()/4),size); | |
259 | //m_dataset->zoomOutDomain(m_zoomStack[m_zoomIndex-1],geometry().size()); |
|
258 | //m_dataset->zoomOutDomain(m_zoomStack[m_zoomIndex-1],geometry().size()); | |
260 |
|
259 | |||
261 |
|
|
260 | if(m_animator){ | |
262 |
|
|
261 | m_animator->setState(ChartAnimator::ShowState); | |
263 | } |
|
262 | } | |
264 | } |
|
263 | } | |
265 |
|
264 | |||
266 | void ChartPresenter::scroll(int dx,int dy) |
|
265 | void ChartPresenter::scroll(int dx,int dy) | |
267 | { |
|
266 | { | |
268 |
|
|
267 | if(m_animator){ | |
269 |
|
|
268 | if(dx<0) m_animator->setState(ChartAnimator::ScrollLeftState,QPointF()); | |
270 |
|
|
269 | if(dx>0) m_animator->setState(ChartAnimator::ScrollRightState,QPointF()); | |
271 |
|
|
270 | if(dy<0) m_animator->setState(ChartAnimator::ScrollUpState,QPointF()); | |
272 |
|
|
271 | if(dy>0) m_animator->setState(ChartAnimator::ScrollDownState,QPointF()); | |
273 | } |
|
272 | } | |
274 |
|
273 | |||
275 |
|
|
274 | m_dataset->scrollDomain(dx,dy,chartGeometry().size()); | |
276 |
|
275 | |||
277 | if(m_animator){ |
|
276 | if(m_animator){ | |
278 |
|
|
277 | m_animator->setState(ChartAnimator::ShowState); | |
279 | } |
|
278 | } | |
280 | } |
|
279 | } | |
281 |
|
280 | |||
282 | QChart::AnimationOptions ChartPresenter::animationOptions() const |
|
281 | QChart::AnimationOptions ChartPresenter::animationOptions() const | |
@@ -311,41 +310,41 void ChartPresenter::updateLayout() | |||||
311 | // Reserve some space for legend |
|
310 | // Reserve some space for legend | |
312 | switch (legend->alignment()) { |
|
311 | switch (legend->alignment()) { | |
313 |
|
312 | |||
314 |
|
|
313 | case QLegend::AlignmentTop: { | |
315 |
|
|
314 | int ledgendSize = legend->minHeight(); | |
316 |
|
|
315 | int topPadding = 2*m_marginTiny + titleSize.height() + ledgendSize + m_marginTiny; | |
317 |
|
|
316 | m_chartMargins = QRect(QPoint(m_chartMargins.left(),topPadding),QPoint(m_chartMargins.right(),m_chartMargins.bottom())); | |
318 |
|
|
317 | m_legendMargins = QRect(QPoint(m_chartMargins.left(),topPadding - (ledgendSize + m_marginTiny)),QPoint(m_chartMargins.right(),m_rect.height()-topPadding + m_marginTiny)); | |
319 |
|
|
318 | titlePadding = m_marginTiny + m_marginTiny; | |
320 |
|
|
319 | break; | |
321 |
|
|
320 | } | |
322 |
|
|
321 | case QLegend::AlignmentBottom: { | |
323 |
|
|
322 | int ledgendSize = legend->minHeight(); | |
324 |
|
|
323 | int bottomPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minBottomMargin; | |
325 |
|
|
324 | m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(m_chartMargins.right(),bottomPadding)); | |
326 |
|
|
325 | m_legendMargins = QRect(QPoint(m_chartMargins.left(),m_rect.height()-bottomPadding + m_marginTiny + m_minBottomMargin),QPoint(m_chartMargins.right(),m_marginTiny + m_marginSmall)); | |
327 |
|
|
326 | titlePadding = m_chartMargins.top()/2; | |
328 |
|
|
327 | break; | |
329 |
|
|
328 | } | |
330 |
|
|
329 | case QLegend::AlignmentLeft: { | |
331 |
|
|
330 | int ledgendSize = legend->minWidth(); | |
332 |
|
|
331 | int leftPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minLeftMargin; | |
333 |
|
|
332 | m_chartMargins = QRect(QPoint(leftPadding,m_chartMargins.top()),QPoint(m_chartMargins.right(),m_chartMargins.bottom())); | |
334 |
|
|
333 | m_legendMargins = QRect(QPoint(m_marginTiny + m_marginSmall,m_chartMargins.top()),QPoint(m_rect.width()-leftPadding + m_marginTiny + m_minLeftMargin,m_chartMargins.bottom())); | |
335 |
|
|
334 | titlePadding = m_chartMargins.top()/2; | |
336 |
|
|
335 | break; | |
337 |
|
|
336 | } | |
338 |
|
|
337 | case QLegend::AlignmentRight: { | |
339 |
|
|
338 | int ledgendSize = legend->minWidth(); | |
340 |
|
|
339 | int rightPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny; | |
341 |
|
|
340 | m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(rightPadding,m_chartMargins.bottom())); | |
342 |
|
|
341 | m_legendMargins = QRect(QPoint(m_rect.width()- rightPadding+ m_marginTiny ,m_chartMargins.top()),QPoint(m_marginTiny + m_marginSmall,m_chartMargins.bottom())); | |
343 |
|
|
342 | titlePadding = m_chartMargins.top()/2; | |
344 |
|
|
343 | break; | |
345 |
|
|
344 | } | |
346 |
|
|
345 | default: { | |
347 |
|
|
346 | break; | |
348 |
|
|
347 | } | |
349 | } |
|
348 | } | |
350 | } |
|
349 | } | |
351 |
|
350 | |||
@@ -372,10 +371,10 void ChartPresenter::updateLayout() | |||||
372 |
|
371 | |||
373 | legend->setGeometry(m_rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom())); |
|
372 | legend->setGeometry(m_rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom())); | |
374 |
|
373 | |||
375 | if(m_chartRect!=chartRect){ |
|
374 | if(m_chartRect!=chartRect){ | |
376 | m_chartRect=chartRect; |
|
375 | m_chartRect=chartRect; | |
377 | emit geometryChanged(m_chartRect); |
|
376 | emit geometryChanged(m_chartRect); | |
378 | } |
|
377 | } | |
379 |
|
378 | |||
380 |
|
379 | |||
381 | } |
|
380 | } |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef CHARTPRESENTER_H |
|
21 | #ifndef CHARTPRESENTER_H | |
22 |
#define CHARTPRESENTER_H |
|
22 | #define CHARTPRESENTER_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "chartbackground_p.h" //TODO fix me |
|
25 | #include "chartbackground_p.h" //TODO fix me |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef DOMAIN_H |
|
21 | #ifndef DOMAIN_H | |
22 |
#define DOMAIN_H |
|
22 | #define DOMAIN_H | |
23 | #include "qchartglobal.h" |
|
23 | #include "qchartglobal.h" | |
24 | #include <QRectF> |
|
24 | #include <QRectF> | |
25 | #include <QSizeF> |
|
25 | #include <QSizeF> |
@@ -28,8 +28,8 | |||||
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
|
30 | |||
31 |
#ifndef LEGENDSCROLLER_P_H |
|
31 | #ifndef LEGENDSCROLLER_P_H | |
32 |
#define LEGENDSCROLLER_P_H |
|
32 | #define LEGENDSCROLLER_P_H | |
33 |
|
33 | |||
34 | #include "qlegend.h" |
|
34 | #include "qlegend.h" | |
35 | #include "scroller_p.h" |
|
35 | #include "scroller_p.h" |
@@ -27,8 +27,8 | |||||
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
#ifndef QLEGEND_P_H |
|
30 | #ifndef QLEGEND_P_H | |
31 |
#define QLEGEND_P_H |
|
31 | #define QLEGEND_P_H | |
32 |
|
32 | |||
33 | #include "qlegend.h" |
|
33 | #include "qlegend.h" | |
34 |
|
34 |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef QLINESERIES_H |
|
21 | #ifndef QLINESERIES_H | |
22 |
#define QLINESERIES_H |
|
22 | #define QLINESERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qxyseries.h> |
|
25 | #include <qxyseries.h> | |
@@ -33,12 +33,12 class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries | |||||
33 | { |
|
33 | { | |
34 | public: |
|
34 | public: | |
35 | explicit QLineSeries(QObject *parent=0); |
|
35 | explicit QLineSeries(QObject *parent=0); | |
36 |
|
|
36 | ~QLineSeries(); | |
37 |
|
37 | |||
38 |
|
|
38 | QSeries::QSeriesType type() const; | |
39 |
|
39 | |||
40 | protected: |
|
40 | protected: | |
41 |
|
|
41 | QLineSeries(QLineSeriesPrivate &d,QObject *parent = 0); | |
42 |
|
42 | |||
43 | private: |
|
43 | private: | |
44 | Q_DECLARE_PRIVATE(QLineSeries); |
|
44 | Q_DECLARE_PRIVATE(QLineSeries); |
@@ -27,8 +27,8 | |||||
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
#ifndef QLINESERIES_P_H |
|
30 | #ifndef QLINESERIES_P_H | |
31 |
#define QLINESERIES_P_H |
|
31 | #define QLINESERIES_P_H | |
32 |
|
32 | |||
33 | #include "qxyseries_p.h" |
|
33 | #include "qxyseries_p.h" | |
34 |
|
34 |
@@ -1,219 +1,218 | |||||
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 "qchartview.h" |
|
21 | #include "qchartview.h" | |
22 | #include "qchart_p.h" |
|
22 | #include "qchartview_p.h" | |
23 |
#include "qchart |
|
23 | #include "qchart_p.h" | |
24 | #include <QGraphicsScene> |
|
24 | #include <QGraphicsScene> | |
25 | #include <QRubberBand> |
|
25 | #include <QRubberBand> | |
26 |
|
26 | |||
27 |
|
27 | /*! | ||
28 | /*! |
|
28 | \enum QChartView::RubberBand | |
29 | \enum QChartView::RubberBand |
|
29 | ||
30 |
|
30 | This enum describes the different types of rubber bands that can be used for zoom rect selection | ||
31 | This enum describes the different types of rubber bands that can be used for zoom rect selection |
|
31 | ||
32 |
|
32 | \value NoRubberBand | ||
33 |
\value |
|
33 | \value VerticalRubberBand | |
34 |
\value |
|
34 | \value HorizonalRubberBand | |
35 |
\value |
|
35 | \value RectangleRubberBand | |
36 | \value RectangleRubberBand |
|
36 | */ | |
37 | */ |
|
37 | ||
38 |
|
38 | /*! | ||
39 | /*! |
|
39 | \class QChartView | |
40 | \class QChartView |
|
40 | \brief Standalone charting widget. | |
41 | \brief Standalone charting widget. |
|
41 | ||
42 |
|
42 | QChartView is a standalone widget that can display charts. It does not require separate | ||
43 | QChartView is a standalone widget that can display charts. It does not require separate |
|
43 | QGraphicsScene to work. It manages the graphical representation of different types of | |
44 | QGraphicsScene to work. It manages the graphical representation of different types of |
|
44 | QChartSeries and other chart related objects like QChartAxis and QChartLegend. If you want to | |
45 | QChartSeries and other chart related objects like QChartAxis and QChartLegend. If you want to |
|
45 | display a chart in your existing QGraphicsScene, you can use the QChart class instead. | |
46 | display a chart in your existing QGraphicsScene, you can use the QChart class instead. |
|
46 | ||
47 |
|
47 | \sa QChart | ||
48 | \sa QChart |
|
48 | */ | |
49 | */ |
|
49 | ||
50 |
|
50 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||
51 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
51 | ||
52 |
|
52 | /*! | ||
53 | /*! |
|
53 | Constructs a chartView object which is a child of a\a parent. | |
54 | Constructs a chartView object which is a child of a\a parent. |
|
54 | */ | |
55 | */ |
|
55 | QChartView::QChartView(QChart *chart,QWidget *parent) : | |
56 | QChartView::QChartView(QChart *chart,QWidget *parent) : |
|
56 | QGraphicsView(parent), | |
57 | QGraphicsView(parent), |
|
57 | d_ptr(new QChartViewPrivate()) | |
58 | d_ptr(new QChartViewPrivate()) |
|
58 | { | |
59 | { |
|
59 | Q_ASSERT(chart); | |
60 | Q_ASSERT(chart); |
|
60 | d_ptr->m_scene = new QGraphicsScene(this); | |
61 | d_ptr->m_scene = new QGraphicsScene(this); |
|
61 | d_ptr->m_chart = chart; | |
62 | d_ptr->m_chart = chart; |
|
62 | setFrameShape(QFrame::NoFrame); | |
63 | setFrameShape(QFrame::NoFrame); |
|
63 | setBackgroundRole(QPalette::Window); | |
64 | setBackgroundRole(QPalette::Window); |
|
64 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
65 |
set |
|
65 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
66 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
66 | setScene(d_ptr->m_scene); | |
67 |
|
|
67 | d_ptr->m_scene->addItem(chart); | |
68 | d_ptr->m_scene->addItem(chart); |
|
68 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
69 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
69 | } | |
70 | } |
|
70 | ||
71 |
|
71 | |||
72 |
|
72 | /*! | ||
73 | /*! |
|
73 | Destroys the object and it's children, like QChartSeries and QChartAxis object added to it. | |
74 | Destroys the object and it's children, like QChartSeries and QChartAxis object added to it. |
|
74 | */ | |
75 | */ |
|
75 | QChartView::~QChartView() | |
76 | QChartView::~QChartView() |
|
76 | { | |
77 | { |
|
77 | } | |
78 | } |
|
78 | ||
79 |
|
79 | /*! | ||
80 | /*! |
|
80 | Returns the pointer to the associated chart | |
81 | Returns the pointer to the associated chart |
|
81 | */ | |
82 | */ |
|
82 | QChart* QChartView::chart() const | |
83 | QChart* QChartView::chart() const |
|
83 | { | |
84 | { |
|
84 | return d_ptr->m_chart; | |
85 | return d_ptr->m_chart; |
|
85 | } | |
86 | } |
|
86 | ||
87 |
|
87 | /*! | ||
88 | /*! |
|
88 | Sets the RubberBandPlicy to \a rubberBand. Selected policy determines the way zooming is performed. | |
89 | Sets the RubberBandPlicy to \a rubberBand. Selected policy determines the way zooming is performed. |
|
89 | */ | |
90 | */ |
|
90 | void QChartView::setRubberBand(const RubberBands& rubberBand) | |
91 | void QChartView::setRubberBand(const RubberBands& rubberBand) |
|
91 | { | |
92 | { |
|
92 | d_ptr->m_rubberBandFlags=rubberBand; | |
93 | d_ptr->m_rubberBandFlags=rubberBand; |
|
93 | ||
94 |
|
94 | if (!d_ptr->m_rubberBandFlags) { | ||
95 |
|
|
95 | delete d_ptr->m_rubberBand; | |
96 |
|
|
96 | d_ptr->m_rubberBand=0; | |
97 | d_ptr->m_rubberBand=0; |
|
97 | return; | |
98 | return; |
|
98 | } | |
99 | } |
|
99 | ||
100 |
|
100 | if (!d_ptr->m_rubberBand) { | ||
101 | if (!d_ptr->m_rubberBand) { |
|
101 | d_ptr->m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this); | |
102 | d_ptr->m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this); |
|
102 | d_ptr->m_rubberBand->setEnabled(true); | |
103 | d_ptr->m_rubberBand->setEnabled(true); |
|
103 | } | |
104 | } |
|
104 | } | |
105 | } |
|
105 | ||
106 |
|
106 | /*! | ||
107 | /*! |
|
107 | Returns the RubberBandPolicy that is currently being used by the widget. | |
108 | Returns the RubberBandPolicy that is currently being used by the widget. |
|
108 | */ | |
109 | */ |
|
109 | QChartView::RubberBands QChartView::rubberBand() const | |
110 | QChartView::RubberBands QChartView::rubberBand() const |
|
110 | { | |
111 | { |
|
111 | return d_ptr->m_rubberBandFlags; | |
112 | return d_ptr->m_rubberBandFlags; |
|
112 | } | |
113 | } |
|
113 | ||
114 |
|
114 | /*! | ||
115 | /*! |
|
115 | If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area. | |
116 | If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area. |
|
116 | If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation. | |
117 | If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation. |
|
117 | */ | |
118 | */ |
|
118 | void QChartView::mousePressEvent(QMouseEvent *event) | |
119 | void QChartView::mousePressEvent(QMouseEvent *event) |
|
119 | { | |
120 | { |
|
120 | if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) { | |
121 | if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) { |
|
121 | ||
122 |
|
122 | int padding = d_ptr->m_chart->margins().top(); | ||
123 | int padding = d_ptr->m_chart->margins().top(); |
|
123 | QRect rect(padding, padding, width() - 2 * padding, height() - 2 * padding); | |
124 | QRect rect(padding, padding, width() - 2 * padding, height() - 2 * padding); |
|
124 | ||
125 |
|
125 | if (rect.contains(event->pos())) { | ||
126 | if (rect.contains(event->pos())) { |
|
126 | d_ptr->m_rubberBandOrigin = event->pos(); | |
127 | d_ptr->m_rubberBandOrigin = event->pos(); |
|
127 | d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize())); | |
128 | d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize())); |
|
128 | d_ptr->m_rubberBand->show(); | |
129 | d_ptr->m_rubberBand->show(); |
|
129 | event->accept(); | |
130 | event->accept(); |
|
130 | } | |
131 |
|
|
131 | } | |
132 | } |
|
132 | else { | |
133 | else { |
|
133 | QGraphicsView::mousePressEvent(event); | |
134 | QGraphicsView::mousePressEvent(event); |
|
134 | } | |
135 | } |
|
135 | } | |
136 | } |
|
136 | ||
137 |
|
137 | /*! | ||
138 | /*! |
|
138 | If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry. | |
139 | If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry. |
|
139 | In other case the defualt QGraphicsView::mouseMoveEvent implementation is called. | |
140 | In other case the defualt QGraphicsView::mouseMoveEvent implementation is called. |
|
140 | */ | |
141 | */ |
|
141 | void QChartView::mouseMoveEvent(QMouseEvent *event) | |
142 | void QChartView::mouseMoveEvent(QMouseEvent *event) |
|
142 | { | |
143 | { |
|
143 | if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) { | |
144 | if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) { |
|
144 | QRectF margins = d_ptr->m_chart->margins(); | |
145 |
QRectF |
|
145 | QRectF geometry = d_ptr->m_chart->geometry(); | |
146 | QRectF geometry = d_ptr->m_chart->geometry(); |
|
146 | QRectF rect =geometry.adjusted(margins.left(),margins.top(),-margins.right(),-margins.bottom()); | |
147 | QRectF rect =geometry.adjusted(margins.left(),margins.top(),-margins.right(),-margins.bottom()); |
|
147 | int width = event->pos().x() - d_ptr->m_rubberBandOrigin.x(); | |
148 |
int |
|
148 | int height = event->pos().y() - d_ptr->m_rubberBandOrigin.y(); | |
149 | int height = event->pos().y() - d_ptr->m_rubberBandOrigin.y(); |
|
149 | if (!d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) { | |
150 | if (!d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) { |
|
150 | d_ptr->m_rubberBandOrigin.setY(rect.top()); | |
151 | d_ptr->m_rubberBandOrigin.setY(rect.top()); |
|
151 | height = rect.height(); | |
152 | height = rect.height(); |
|
152 | } | |
153 | } |
|
153 | if (!d_ptr->m_rubberBandFlags.testFlag(HorizonalRubberBand)) { | |
154 | if (!d_ptr->m_rubberBandFlags.testFlag(HorizonalRubberBand)) { |
|
154 | d_ptr->m_rubberBandOrigin.setX(rect.left()); | |
155 | d_ptr->m_rubberBandOrigin.setX(rect.left()); |
|
155 | width= rect.width(); | |
156 | width= rect.width(); |
|
156 | } | |
157 | } |
|
157 | d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin.x(),d_ptr->m_rubberBandOrigin.y(), width,height).normalized()); | |
158 | d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin.x(),d_ptr->m_rubberBandOrigin.y(), width,height).normalized()); |
|
158 | } | |
159 | } |
|
159 | else { | |
160 | else { |
|
160 | QGraphicsView::mouseMoveEvent(event); | |
161 | QGraphicsView::mouseMoveEvent(event); |
|
161 | } | |
162 | } |
|
162 | } | |
163 | } |
|
163 | ||
164 |
|
164 | /*! | ||
165 | /*! |
|
165 | If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand | |
166 | If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand |
|
166 | If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled. | |
167 | If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled. |
|
167 | */ | |
168 | */ |
|
168 | void QChartView::mouseReleaseEvent(QMouseEvent *event) | |
169 | void QChartView::mouseReleaseEvent(QMouseEvent *event) |
|
169 | { | |
170 | { |
|
170 | if(d_ptr->m_rubberBand) { | |
171 | if(d_ptr->m_rubberBand) { |
|
171 | if (event->button() == Qt::LeftButton && d_ptr->m_rubberBand->isVisible()) { | |
172 | if (event->button() == Qt::LeftButton && d_ptr->m_rubberBand->isVisible()) { |
|
172 | d_ptr->m_rubberBand->hide(); | |
173 |
d_ptr->m_rubberBand-> |
|
173 | QRect rect = d_ptr->m_rubberBand->geometry(); | |
174 |
|
|
174 | d_ptr->m_chart->zoomIn(rect); | |
175 | d_ptr->m_chart->zoomIn(rect); |
|
175 | event->accept(); | |
176 | event->accept(); |
|
176 | } | |
177 | } |
|
177 | ||
178 |
|
178 | if(event->button()==Qt::RightButton){ | ||
179 | if(event->button()==Qt::RightButton){ |
|
179 | d_ptr->m_chart->zoomOut(); | |
180 | d_ptr->m_chart->zoomOut(); |
|
180 | event->accept(); | |
181 | event->accept(); |
|
181 | } | |
182 |
|
|
182 | } | |
183 | } |
|
183 | else { | |
184 | else { |
|
184 | QGraphicsView::mouseReleaseEvent(event); | |
185 | QGraphicsView::mouseReleaseEvent(event); |
|
185 | } | |
186 | } |
|
186 | } | |
187 | } |
|
187 | ||
188 |
|
188 | /*! | ||
189 | /*! |
|
189 | Resizes and updates the chart area using the \a event data | |
190 | Resizes and updates the chart area using the \a event data |
|
190 | */ | |
191 | */ |
|
191 | void QChartView::resizeEvent(QResizeEvent *event) | |
192 | void QChartView::resizeEvent(QResizeEvent *event) |
|
192 | { | |
193 | { |
|
193 | QGraphicsView::resizeEvent(event); | |
194 | QGraphicsView::resizeEvent(event); |
|
194 | d_ptr->m_chart->resize(size()); | |
195 |
d_ptr->m_chart-> |
|
195 | setMinimumSize(d_ptr->m_chart->minimumSize().toSize()); | |
196 |
set |
|
196 | setSceneRect(d_ptr->m_chart->geometry()); | |
197 | setSceneRect(d_ptr->m_chart->geometry()); |
|
197 | } | |
198 | } |
|
198 | ||
199 |
|
199 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
200 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
200 | ||
201 |
|
201 | QChartViewPrivate::QChartViewPrivate(): | ||
202 | QChartViewPrivate::QChartViewPrivate(): |
|
202 | m_scene(0), | |
203 |
m_ |
|
203 | m_chart(0), | |
204 |
m_ |
|
204 | m_presenter(0), | |
205 | m_presenter(0), |
|
205 | m_rubberBand(0), | |
206 | m_rubberBand(0), |
|
206 | m_rubberBandFlags(QChartView::NoRubberBand) | |
207 | m_rubberBandFlags(QChartView::NoRubberBand) |
|
207 | { | |
208 | { |
|
208 | ||
209 |
|
209 | } | ||
210 | } |
|
210 | ||
211 |
|
211 | QChartViewPrivate::~QChartViewPrivate() | ||
212 | QChartViewPrivate::~QChartViewPrivate() |
|
212 | { | |
213 | { |
|
213 | ||
214 |
|
214 | } | ||
215 | } |
|
215 | ||
216 |
|
216 | #include "moc_qchartview.cpp" | ||
217 | #include "moc_qchartview.cpp" |
|
217 | ||
218 |
|
218 | QTCOMMERCIALCHART_END_NAMESPACE | ||
219 | QTCOMMERCIALCHART_END_NAMESPACE |
|
@@ -33,6 +33,7 | |||||
33 | #include "qchartview.h" |
|
33 | #include "qchartview.h" | |
34 |
|
34 | |||
35 | class QGraphicsScene; |
|
35 | class QGraphicsScene; | |
|
36 | class ChartPresenter; | |||
36 |
|
37 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
39 |
@@ -27,8 +27,8 | |||||
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
#ifndef QSERIES_P_H |
|
30 | #ifndef QSERIES_P_H | |
31 |
#define QSERIES_P_H |
|
31 | #define QSERIES_P_H | |
32 |
|
32 | |||
33 | #include "qseries.h" |
|
33 | #include "qseries.h" | |
34 |
|
34 |
@@ -27,8 +27,8 | |||||
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
#ifndef QSCATTERSERIES_P_H |
|
30 | #ifndef QSCATTERSERIES_P_H | |
31 |
#define QSCATTERSERIES_P_H |
|
31 | #define QSCATTERSERIES_P_H | |
32 |
|
32 | |||
33 | #include "qxyseries_p.h" |
|
33 | #include "qxyseries_p.h" | |
34 |
|
34 |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef SCATTER |
|
21 | #ifndef SCATTERCHARTITEM_H | |
22 |
#define SCATTER |
|
22 | #define SCATTERCHARTITEM_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "xychartitem_p.h" |
|
25 | #include "xychartitem_p.h" |
@@ -27,8 +27,8 | |||||
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
#ifndef SCROLLER_P_H |
|
30 | #ifndef SCROLLER_P_H | |
31 |
#define SCROLLER_P_H |
|
31 | #define SCROLLER_P_H | |
32 |
|
32 | |||
33 | #include "qchartglobal.h" |
|
33 | #include "qchartglobal.h" | |
34 | #include <QBasicTimer> |
|
34 | #include <QBasicTimer> |
@@ -27,8 +27,8 | |||||
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 |
#ifndef QSPLINESERIES_P_H |
|
30 | #ifndef QSPLINESERIES_P_H | |
31 |
#define QSPLINESERIES_P_H |
|
31 | #define QSPLINESERIES_P_H | |
32 |
|
32 | |||
33 | #include "qlineseries_p.h" |
|
33 | #include "qlineseries_p.h" | |
34 |
|
34 |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef CHARTTHEMEBLUE |
|
21 | #ifndef CHARTTHEMEBLUEICY_P_H | |
22 |
#define CHARTTHEMEBLUE |
|
22 | #define CHARTTHEMEBLUEICY_P_H | |
23 |
|
23 | |||
24 | #include "charttheme_p.h" |
|
24 | #include "charttheme_p.h" | |
25 |
|
25 |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef CHARTTHEME |
|
21 | #ifndef CHARTTHEMELIGHT_P_H | |
22 |
#define CHARTTHEME |
|
22 | #define CHARTTHEMELIGHT_P_H | |
23 |
|
23 | |||
24 | #include "charttheme_p.h" |
|
24 | #include "charttheme_p.h" | |
25 |
|
25 |
@@ -18,8 +18,8 | |||||
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 |
#ifndef QXYSERIES_H |
|
21 | #ifndef QXYSERIES_H | |
22 |
#define QXYSERIES_H |
|
22 | #define QXYSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qseries.h> |
|
25 | #include <qseries.h> |
General Comments 0
You need to be logged in to leave comments.
Login now