@@ -49,12 +49,12 Q_SIGNALS: | |||||
49 |
|
49 | |||
50 | public: |
|
50 | public: | |
51 | virtual ChartAxis* createGraphics(ChartPresenter* presenter) = 0; |
|
51 | virtual ChartAxis* createGraphics(ChartPresenter* presenter) = 0; | |
52 |
virtual void |
|
52 | virtual void emitRange() = 0; | |
53 |
|
53 | |||
54 | protected: |
|
54 | protected: | |
55 | virtual void setMin(const QVariant &min) = 0; |
|
55 | virtual void setMin(const QVariant &min) = 0; | |
56 | virtual void setMax(const QVariant &max) = 0; |
|
56 | virtual void setMax(const QVariant &max) = 0; | |
57 |
virtual void setRange(const QVariant &min, const QVariant &max |
|
57 | virtual void setRange(const QVariant &min, const QVariant &max) = 0; | |
58 | virtual int ticksCount() const = 0; |
|
58 | virtual int ticksCount() const = 0; | |
59 |
|
59 | |||
60 | public: |
|
60 | public: |
@@ -23,6 +23,7 | |||||
23 | #include "chartcategoriesaxisx_p.h" |
|
23 | #include "chartcategoriesaxisx_p.h" | |
24 | #include "chartcategoriesaxisy_p.h" |
|
24 | #include "chartcategoriesaxisy_p.h" | |
25 | #include <qmath.h> |
|
25 | #include <qmath.h> | |
|
26 | #include <QDebug> | |||
26 |
|
27 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
29 | |||
@@ -47,11 +48,12 void QCategoriesAxis::append(const QStringList &categories) | |||||
47 | { |
|
48 | { | |
48 | Q_D(QCategoriesAxis); |
|
49 | Q_D(QCategoriesAxis); | |
49 | if (d->m_categories.isEmpty()) { |
|
50 | if (d->m_categories.isEmpty()) { | |
50 | d->m_minCategory = categories.first(); |
|
51 | d->m_categories.append(categories); | |
51 | d->m_maxCategory = categories.last(); |
|
52 | setRange(categories.first(),categories.last()); | |
|
53 | }else{ | |||
|
54 | d->m_categories.append(categories); | |||
52 | } |
|
55 | } | |
53 |
|
56 | |||
54 | d->m_categories.append(categories); |
|
|||
55 | emit categoriesChanged(); |
|
57 | emit categoriesChanged(); | |
56 | } |
|
58 | } | |
57 |
|
59 | |||
@@ -60,14 +62,14 void QCategoriesAxis::append(const QStringList &categories) | |||||
60 | */ |
|
62 | */ | |
61 | void QCategoriesAxis::append(const QString &category) |
|
63 | void QCategoriesAxis::append(const QString &category) | |
62 | { |
|
64 | { | |
63 |
|
|
65 | Q_D(QCategoriesAxis); | |
64 |
|
|
66 | if (d->m_categories.isEmpty()) { | |
65 | d->m_minCategory = category; |
|
67 | d->m_categories.append(category); | |
66 | d->m_maxCategory = category; |
|
68 | setRange(category,category); | |
67 | } |
|
69 | }else{ | |
68 |
|
70 | d->m_categories.append(category); | ||
69 | d->m_categories.append(category); |
|
71 | } | |
70 |
|
|
72 | emit categoriesChanged(); | |
71 | } |
|
73 | } | |
72 |
|
74 | |||
73 | /*! |
|
75 | /*! | |
@@ -78,8 +80,7 void QCategoriesAxis::remove(const QString &category) | |||||
78 | Q_D(QCategoriesAxis); |
|
80 | Q_D(QCategoriesAxis); | |
79 | if (d->m_categories.contains(category)) { |
|
81 | if (d->m_categories.contains(category)) { | |
80 | d->m_categories.removeAt(d->m_categories.indexOf(category)); |
|
82 | d->m_categories.removeAt(d->m_categories.indexOf(category)); | |
81 | d->m_minCategory = d->m_categories.first(); |
|
83 | setRange(d->m_categories.first(),d->m_categories.last()); | |
82 | d->m_maxCategory = d->m_categories.last(); |
|
|||
83 | emit categoriesChanged(); |
|
84 | emit categoriesChanged(); | |
84 | } |
|
85 | } | |
85 | } |
|
86 | } | |
@@ -91,10 +92,11 void QCategoriesAxis::insert(int index, const QString &category) | |||||
91 | { |
|
92 | { | |
92 | Q_D(QCategoriesAxis); |
|
93 | Q_D(QCategoriesAxis); | |
93 | if (d->m_categories.isEmpty()) { |
|
94 | if (d->m_categories.isEmpty()) { | |
94 |
|
|
95 | d->m_categories.insert(index,category); | |
95 | d->m_maxCategory = category; |
|
96 | setRange(category,category); | |
|
97 | }else{ | |||
|
98 | ||||
96 | } |
|
99 | } | |
97 | d->m_categories.insert(index,category); |
|
|||
98 | emit categoriesChanged(); |
|
100 | emit categoriesChanged(); | |
99 | } |
|
101 | } | |
100 |
|
102 | |||
@@ -105,18 +107,18 void QCategoriesAxis::clear() | |||||
105 | { |
|
107 | { | |
106 | Q_D(QCategoriesAxis); |
|
108 | Q_D(QCategoriesAxis); | |
107 | d->m_categories.clear(); |
|
109 | d->m_categories.clear(); | |
108 | d->m_minCategory.clear(); |
|
110 | setRange(QString::null,QString::null); | |
109 | d->m_maxCategory.clear(); |
|
|||
110 | emit categoriesChanged(); |
|
111 | emit categoriesChanged(); | |
111 | } |
|
112 | } | |
112 |
|
113 | |||
113 | void QCategoriesAxis::setCategories(const QStringList &categories) |
|
114 | void QCategoriesAxis::setCategories(const QStringList &categories) | |
114 | { |
|
115 | { | |
115 | Q_D(QCategoriesAxis); |
|
116 | Q_D(QCategoriesAxis); | |
|
117 | if(d->m_categories!=categories){ | |||
116 | d->m_categories = categories; |
|
118 | d->m_categories = categories; | |
117 | d->m_minCategory = categories.first(); |
|
119 | setRange(categories.first(),categories.last()); | |
118 | d->m_maxCategory = categories.last(); |
|
|||
119 | emit categoriesChanged(); |
|
120 | emit categoriesChanged(); | |
|
121 | } | |||
120 | } |
|
122 | } | |
121 |
|
123 | |||
122 | QStringList QCategoriesAxis::categories() |
|
124 | QStringList QCategoriesAxis::categories() | |
@@ -200,24 +202,21 void QCategoriesAxis::setRange(const QString& minCategory, const QString& maxCat | |||||
200 | return; |
|
202 | return; | |
201 | } |
|
203 | } | |
202 |
|
204 | |||
203 | d->m_minCategory = minCategory; |
|
|||
204 | d->m_maxCategory = maxCategory; |
|
|||
205 |
|
||||
206 | bool changed = false; |
|
205 | bool changed = false; | |
207 | if (!qFuzzyIsNull(d->m_min - (minIndex))) { |
|
206 | if (!qFuzzyIsNull(d->m_min - (minIndex))) { | |
|
207 | d->m_minCategory = minCategory; | |||
208 | d->m_min = minIndex; |
|
208 | d->m_min = minIndex; | |
209 | changed = true; |
|
209 | changed = true; | |
210 | } |
|
210 | } | |
211 |
|
211 | |||
212 | if (!qFuzzyIsNull(d->m_max - (maxIndex))) { |
|
212 | if (!qFuzzyIsNull(d->m_max - (maxIndex))) { | |
213 | d->m_max = maxIndex; |
|
213 | d->m_max = maxIndex; | |
|
214 | d->m_maxCategory = maxCategory; | |||
214 | changed = true; |
|
215 | changed = true; | |
215 | } |
|
216 | } | |
216 |
|
217 | |||
217 | if ((changed)) { |
|
218 | if ((changed)) { | |
218 | if(!signalsBlocked()){ |
|
219 | d->emitRange(); | |
219 | emit d->changed(d->m_min -0.5, d->m_max +0.5, qCeil(d->m_max + 0.5) -qCeil(d->m_min - 0.5) +1, false); |
|
|||
220 | } |
|
|||
221 | emit categoriesChanged(); |
|
220 | emit categoriesChanged(); | |
222 | } |
|
221 | } | |
223 | } |
|
222 | } | |
@@ -253,9 +252,8 void QCategoriesAxisPrivate::setMax(const QVariant &max) | |||||
253 | setRange(m_minCategory,max); |
|
252 | setRange(m_minCategory,max); | |
254 | } |
|
253 | } | |
255 |
|
254 | |||
256 |
void QCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &max |
|
255 | void QCategoriesAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |
257 | { |
|
256 | { | |
258 | Q_UNUSED(force); // TODO: use this? |
|
|||
259 | Q_Q(QCategoriesAxis); |
|
257 | Q_Q(QCategoriesAxis); | |
260 | QString value1 = min.toString(); |
|
258 | QString value1 = min.toString(); | |
261 | QString value2 = max.toString(); |
|
259 | QString value2 = max.toString(); | |
@@ -284,9 +282,12 ChartAxis* QCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) | |||||
284 | } |
|
282 | } | |
285 | } |
|
283 | } | |
286 |
|
284 | |||
287 |
void QCategoriesAxisPrivate:: |
|
285 | void QCategoriesAxisPrivate::emitRange() | |
288 | { |
|
286 | { | |
289 | setRange(m_min,m_max,true); |
|
287 | Q_Q( QCategoriesAxis); | |
|
288 | if(!q->signalsBlocked()) { | |||
|
289 | emit changed(m_min -0.5, m_max +0.5, qCeil(m_max + 0.5) -qCeil(m_min - 0.5) +1, false); | |||
|
290 | } | |||
290 | } |
|
291 | } | |
291 |
|
292 | |||
292 |
|
293 |
@@ -31,6 +31,8 class QTCOMMERCIALCHART_EXPORT QCategoriesAxis : public QAbstractAxis | |||||
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) |
|
33 | Q_PROPERTY(QStringList categories READ categories WRITE setCategories NOTIFY categoriesChanged) | |
|
34 | Q_PROPERTY(QString min READ min WRITE setMin NOTIFY minChanged) | |||
|
35 | Q_PROPERTY(QString max READ max WRITE setMax NOTIFY maxChanged) | |||
34 |
|
36 | |||
35 | public: |
|
37 | public: | |
36 | explicit QCategoriesAxis(QObject *parent = 0); |
|
38 | explicit QCategoriesAxis(QObject *parent = 0); | |
@@ -60,6 +62,9 public: | |||||
60 |
|
62 | |||
61 | Q_SIGNALS: |
|
63 | Q_SIGNALS: | |
62 | void categoriesChanged(); |
|
64 | void categoriesChanged(); | |
|
65 | void minChanged(const QString &min); | |||
|
66 | void maxChanged(const QString &max); | |||
|
67 | void rangeChanged(const QString &min, const QString &max); | |||
63 |
|
68 | |||
64 | private: |
|
69 | private: | |
65 | Q_DECLARE_PRIVATE(QCategoriesAxis) |
|
70 | Q_DECLARE_PRIVATE(QCategoriesAxis) |
@@ -45,13 +45,13 public: | |||||
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
47 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
48 |
void |
|
48 | void emitRange(); | |
49 |
|
49 | |||
50 | private: |
|
50 | private: | |
51 | //range handling |
|
51 | //range handling | |
52 | void setMin(const QVariant &min); |
|
52 | void setMin(const QVariant &min); | |
53 | void setMax(const QVariant &max); |
|
53 | void setMax(const QVariant &max); | |
54 |
void setRange(const QVariant &min, const QVariant &max |
|
54 | void setRange(const QVariant &min, const QVariant &max); | |
55 | int ticksCount() const; |
|
55 | int ticksCount() const; | |
56 |
|
56 | |||
57 | Q_SIGNALS: |
|
57 | Q_SIGNALS: |
@@ -165,10 +165,8 void QValuesAxis::setRange(qreal min, qreal max) | |||||
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | if (changed) { |
|
167 | if (changed) { | |
|
168 | d->emitRange(); | |||
168 | emit rangeChanged(d->m_min,d->m_max); |
|
169 | emit rangeChanged(d->m_min,d->m_max); | |
169 | if(!signalsBlocked()){ |
|
|||
170 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); |
|
|||
171 | } |
|
|||
172 | } |
|
170 | } | |
173 | } |
|
171 | } | |
174 |
|
172 | |||
@@ -252,9 +250,8 void QValuesAxisPrivate::setMax(const QVariant &max) | |||||
252 | if(ok) q->setMax(value); |
|
250 | if(ok) q->setMax(value); | |
253 | } |
|
251 | } | |
254 |
|
252 | |||
255 |
void QValuesAxisPrivate::setRange(const QVariant &min, const QVariant &max |
|
253 | void QValuesAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |
256 | { |
|
254 | { | |
257 | Q_UNUSED(force); // TODO: use this |
|
|||
258 | Q_Q(QValuesAxis); |
|
255 | Q_Q(QValuesAxis); | |
259 | bool ok1; |
|
256 | bool ok1; | |
260 | bool ok2; |
|
257 | bool ok2; | |
@@ -279,9 +276,12 ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter) | |||||
279 |
|
276 | |||
280 | } |
|
277 | } | |
281 |
|
278 | |||
282 |
void QValuesAxisPrivate:: |
|
279 | void QValuesAxisPrivate::emitRange() | |
283 | { |
|
280 | { | |
284 | setRange(m_min,m_max,true); |
|
281 | Q_Q(QValuesAxis); | |
|
282 | if(!q->signalsBlocked()) { | |||
|
283 | emit changed(m_min, m_max, m_ticksCount, m_niceNumbers); | |||
|
284 | } | |||
285 | } |
|
285 | } | |
286 |
|
286 | |||
287 | #include "moc_qvaluesaxis.cpp" |
|
287 | #include "moc_qvaluesaxis.cpp" |
@@ -50,12 +50,12 public Q_SLOTS: | |||||
50 |
|
50 | |||
51 | public: |
|
51 | public: | |
52 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
52 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
53 |
void |
|
53 | void emitRange(); | |
54 |
|
54 | |||
55 | protected: |
|
55 | protected: | |
56 | void setMin(const QVariant &min); |
|
56 | void setMin(const QVariant &min); | |
57 | void setMax(const QVariant &max); |
|
57 | void setMax(const QVariant &max); | |
58 |
void setRange(const QVariant &min, const QVariant &max |
|
58 | void setRange(const QVariant &min, const QVariant &max); | |
59 | int ticksCount() const; |
|
59 | int ticksCount() const; | |
60 |
|
60 | |||
61 | private: |
|
61 | private: |
@@ -373,9 +373,7 void ChartDataSet::setAxisX(QAbstractSeries *series, QAbstractAxis *axis) | |||||
373 | } |
|
373 | } | |
374 |
|
374 | |||
375 | m_seriesAxisXMap.insert(series,axis); |
|
375 | m_seriesAxisXMap.insert(series,axis); | |
376 |
|
376 | axis->d_ptr->emitRange(); | ||
377 | // Force range update |
|
|||
378 | axis->d_ptr->updateRange(); |
|
|||
379 | } |
|
377 | } | |
380 |
|
378 | |||
381 | void ChartDataSet::setAxisY(QAbstractSeries *series, QAbstractAxis *axis) |
|
379 | void ChartDataSet::setAxisY(QAbstractSeries *series, QAbstractAxis *axis) | |
@@ -414,6 +412,7 void ChartDataSet::setAxisY(QAbstractSeries *series, QAbstractAxis *axis) | |||||
414 | } |
|
412 | } | |
415 |
|
413 | |||
416 | m_seriesAxisYMap.insert(series,axis); |
|
414 | m_seriesAxisYMap.insert(series,axis); | |
|
415 | axis->d_ptr->emitRange(); | |||
417 | } |
|
416 | } | |
418 |
|
417 | |||
419 | Domain* ChartDataSet::domain(QAbstractSeries *series) const |
|
418 | Domain* ChartDataSet::domain(QAbstractSeries *series) const |
General Comments 0
You need to be logged in to leave comments.
Login now