@@ -47,7 +47,7 Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags): | |||||
47 | addSeries(m_series); |
|
47 | addSeries(m_series); | |
48 | createDefaultAxes(); |
|
48 | createDefaultAxes(); | |
49 | setAxisX(m_axis,m_series); |
|
49 | setAxisX(m_axis,m_series); | |
50 |
m_axis->setTick |
|
50 | m_axis->setTickCount(5); | |
51 | axisX()->setRange(0, 10); |
|
51 | axisX()->setRange(0, 10); | |
52 | axisY()->setRange(-5, 10); |
|
52 | axisY()->setRange(-5, 10); | |
53 |
|
53 | |||
@@ -61,8 +61,8 Chart::~Chart() | |||||
61 |
|
61 | |||
62 | void Chart::handleTimeout() |
|
62 | void Chart::handleTimeout() | |
63 | { |
|
63 | { | |
64 |
qreal x = plotArea().width()/m_axis->tick |
|
64 | qreal x = plotArea().width()/m_axis->tickCount(); | |
65 |
qreal y =(m_axis->max() - m_axis->min())/m_axis->tick |
|
65 | qreal y =(m_axis->max() - m_axis->min())/m_axis->tickCount(); | |
66 | m_x += y; |
|
66 | m_x += y; | |
67 | m_y = qrand() % 5 - 2.5; |
|
67 | m_y = qrand() % 5 - 2.5; | |
68 | m_series->append(m_x, m_y); |
|
68 | m_series->append(m_x, m_y); |
@@ -113,7 +113,7 void ChartValueAxisX::handleAxisUpdated() | |||||
113 | { |
|
113 | { | |
114 | //TODO:: fix this |
|
114 | //TODO:: fix this | |
115 | QValueAxis* axis = qobject_cast<QValueAxis*>(m_chartAxis); |
|
115 | QValueAxis* axis = qobject_cast<QValueAxis*>(m_chartAxis); | |
116 |
m_tickCount = axis->tick |
|
116 | m_tickCount = axis->tickCount(); | |
117 | ChartAxis::handleAxisUpdated(); |
|
117 | ChartAxis::handleAxisUpdated(); | |
118 | } |
|
118 | } | |
119 |
|
119 |
@@ -118,7 +118,7 void ChartValueAxisY::handleAxisUpdated() | |||||
118 | { |
|
118 | { | |
119 | //TODO:: fix this |
|
119 | //TODO:: fix this | |
120 | QValueAxis* axis = qobject_cast<QValueAxis*>(m_chartAxis); |
|
120 | QValueAxis* axis = qobject_cast<QValueAxis*>(m_chartAxis); | |
121 |
m_tickCount = axis->tick |
|
121 | m_tickCount = axis->tickCount(); | |
122 | ChartAxis::handleAxisUpdated(); |
|
122 | ChartAxis::handleAxisUpdated(); | |
123 | } |
|
123 | } | |
124 |
|
124 |
@@ -188,7 +188,7 void QValueAxis::setRange(qreal min, qreal max) | |||||
188 | if(d->m_niceNumbers) { |
|
188 | if(d->m_niceNumbers) { | |
189 | int ticks = d->m_tickCount; |
|
189 | int ticks = d->m_tickCount; | |
190 | d->looseNiceNumbers(min, max, ticks); |
|
190 | d->looseNiceNumbers(min, max, ticks); | |
191 |
if(ticks!=d->m_tickCount) setTick |
|
191 | if(ticks!=d->m_tickCount) setTickCount(ticks); | |
192 | } |
|
192 | } | |
193 |
|
193 | |||
194 | if (!qFuzzyIsNull(d->m_min - min)) { |
|
194 | if (!qFuzzyIsNull(d->m_min - min)) { | |
@@ -212,7 +212,7 void QValueAxis::setRange(qreal min, qreal max) | |||||
212 | /*! |
|
212 | /*! | |
213 | Sets \a count for ticks on the axis. |
|
213 | Sets \a count for ticks on the axis. | |
214 | */ |
|
214 | */ | |
215 |
void QValueAxis::setTick |
|
215 | void QValueAxis::setTickCount(int count) | |
216 | { |
|
216 | { | |
217 | Q_D(QValueAxis); |
|
217 | Q_D(QValueAxis); | |
218 | if (d->m_tickCount != count && count >=2) { |
|
218 | if (d->m_tickCount != count && count >=2) { | |
@@ -225,7 +225,7 void QValueAxis::setTicksCount(int count) | |||||
225 | \fn int QValueAxis::ticksCount() const |
|
225 | \fn int QValueAxis::ticksCount() const | |
226 | Return number of ticks on the axis |
|
226 | Return number of ticks on the axis | |
227 | */ |
|
227 | */ | |
228 |
int QValueAxis::tick |
|
228 | int QValueAxis::tickCount() const | |
229 | { |
|
229 | { | |
230 | Q_D(const QValueAxis); |
|
230 | Q_D(const QValueAxis); | |
231 | return d->m_tickCount; |
|
231 | return d->m_tickCount; |
@@ -30,7 +30,7 class QValueAxisPrivate; | |||||
30 | class QTCOMMERCIALCHART_EXPORT QValueAxis : public QAbstractAxis |
|
30 | class QTCOMMERCIALCHART_EXPORT QValueAxis : public QAbstractAxis | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 |
Q_PROPERTY(int tick |
|
33 | Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount) | |
34 | Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled) |
|
34 | Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled) | |
35 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) |
|
35 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) | |
36 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) |
|
36 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) | |
@@ -53,8 +53,8 public: | |||||
53 | void setRange(qreal min, qreal max); |
|
53 | void setRange(qreal min, qreal max); | |
54 |
|
54 | |||
55 | //ticks handling |
|
55 | //ticks handling | |
56 |
void setTick |
|
56 | void setTickCount(int count); | |
57 |
int tick |
|
57 | int tickCount() const; | |
58 |
|
58 | |||
59 | void setNiceNumbersEnabled(bool enable = true); |
|
59 | void setNiceNumbersEnabled(bool enable = true); | |
60 | bool niceNumbersEnabled() const; |
|
60 | bool niceNumbersEnabled() const; |
@@ -105,7 +105,7 void tst_QValueAxis::qvalueaxis() | |||||
105 | QVERIFY(qFuzzyIsNull(m_valuesaxis->max())); |
|
105 | QVERIFY(qFuzzyIsNull(m_valuesaxis->max())); | |
106 | QVERIFY(qFuzzyIsNull(m_valuesaxis->min())); |
|
106 | QVERIFY(qFuzzyIsNull(m_valuesaxis->min())); | |
107 | QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false); |
|
107 | QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false); | |
108 |
QCOMPARE(m_valuesaxis->tick |
|
108 | QCOMPARE(m_valuesaxis->tickCount(), 5); | |
109 | QCOMPARE(m_valuesaxis->type(), QAbstractAxis::AxisTypeValues); |
|
109 | QCOMPARE(m_valuesaxis->type(), QAbstractAxis::AxisTypeValues); | |
110 |
|
110 | |||
111 | m_chart->setAxisX(m_valuesaxis, m_series); |
|
111 | m_chart->setAxisX(m_valuesaxis, m_series); | |
@@ -115,7 +115,7 void tst_QValueAxis::qvalueaxis() | |||||
115 | QVERIFY(!qFuzzyIsNull(m_valuesaxis->max())); |
|
115 | QVERIFY(!qFuzzyIsNull(m_valuesaxis->max())); | |
116 | QVERIFY(!qFuzzyIsNull(m_valuesaxis->min())); |
|
116 | QVERIFY(!qFuzzyIsNull(m_valuesaxis->min())); | |
117 | QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false); |
|
117 | QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false); | |
118 |
QCOMPARE(m_valuesaxis->tick |
|
118 | QCOMPARE(m_valuesaxis->tickCount(), 5); | |
119 | } |
|
119 | } | |
120 |
|
120 | |||
121 | void tst_QValueAxis::max_raw_data() |
|
121 | void tst_QValueAxis::max_raw_data() | |
@@ -243,7 +243,7 void tst_QValueAxis::niceNumbersEnabled() | |||||
243 | QFETCH(int, expectedTicks); |
|
243 | QFETCH(int, expectedTicks); | |
244 |
|
244 | |||
245 | m_valuesaxis->setRange(min, max); |
|
245 | m_valuesaxis->setRange(min, max); | |
246 |
m_valuesaxis->setTick |
|
246 | m_valuesaxis->setTickCount(ticks); | |
247 |
|
247 | |||
248 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); |
|
248 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); | |
249 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); |
|
249 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); | |
@@ -264,7 +264,7 void tst_QValueAxis::niceNumbersEnabled() | |||||
264 |
|
264 | |||
265 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - expectedMin), "Min not equal"); |
|
265 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - expectedMin), "Min not equal"); | |
266 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - expectedMax), "Max not equal"); |
|
266 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - expectedMax), "Max not equal"); | |
267 |
QCOMPARE(m_valuesaxis->tick |
|
267 | QCOMPARE(m_valuesaxis->tickCount(), expectedTicks); | |
268 |
|
268 | |||
269 | } |
|
269 | } | |
270 |
|
270 | |||
@@ -338,8 +338,8 void tst_QValueAxis::ticksCount() | |||||
338 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); |
|
338 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); | |
339 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); |
|
339 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); | |
340 |
|
340 | |||
341 |
m_valuesaxis->setTick |
|
341 | m_valuesaxis->setTickCount(ticksCount); | |
342 |
QCOMPARE(m_valuesaxis->tick |
|
342 | QCOMPARE(m_valuesaxis->tickCount(), ticksCount); | |
343 |
|
343 | |||
344 | QCOMPARE(spy0.count(), 0); |
|
344 | QCOMPARE(spy0.count(), 0); | |
345 | QCOMPARE(spy1.count(), 0); |
|
345 | QCOMPARE(spy1.count(), 0); | |
@@ -349,7 +349,7 void tst_QValueAxis::ticksCount() | |||||
349 | m_view->show(); |
|
349 | m_view->show(); | |
350 | QTest::qWaitForWindowShown(m_view); |
|
350 | QTest::qWaitForWindowShown(m_view); | |
351 |
|
351 | |||
352 |
QCOMPARE(m_valuesaxis->tick |
|
352 | QCOMPARE(m_valuesaxis->tickCount(), ticksCount); | |
353 | } |
|
353 | } | |
354 |
|
354 | |||
355 | void tst_QValueAxis::noautoscale_data() |
|
355 | void tst_QValueAxis::noautoscale_data() |
General Comments 0
You need to be logged in to leave comments.
Login now