@@ -1,55 +1,48 | |||||
1 | #include "baranimation_p.h" |
|
1 | #include "baranimation_p.h" | |
2 | #include "barchartitem_p.h" |
|
2 | #include "barchartitem_p.h" | |
3 | #include <QParallelAnimationGroup> |
|
3 | #include <QParallelAnimationGroup> | |
4 | #include <QTimer> |
|
4 | #include <QTimer> | |
5 |
|
5 | |||
6 | Q_DECLARE_METATYPE(QVector<QRectF>) |
|
6 | Q_DECLARE_METATYPE(QVector<QRectF>) | |
7 | //Q_DECLARE_METATYPE(BarLayout) // TODO? |
|
7 | //Q_DECLARE_METATYPE(BarLayout) // TODO? | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
11 | |||
12 | BarAnimation::BarAnimation(BarChartItem *item) |
|
12 | BarAnimation::BarAnimation(BarChartItem *item) | |
13 | :ChartAnimation(item), |
|
13 | :ChartAnimation(item), | |
14 | m_item(item) |
|
14 | m_item(item) | |
15 | { |
|
15 | { | |
16 | } |
|
16 | } | |
17 |
|
17 | |||
18 | BarAnimation::~BarAnimation() |
|
18 | BarAnimation::~BarAnimation() | |
19 | { |
|
19 | { | |
20 | } |
|
20 | } | |
21 |
|
21 | |||
22 | void BarAnimation::updateValues(const QVector<QRectF>& layout) |
|
|||
23 | { |
|
|||
24 | // TODO?: |
|
|||
25 | // qDebug() << "BarAnimation::updateValues" << layout.count(); |
|
|||
26 | } |
|
|||
27 |
|
||||
28 |
|
||||
29 | QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const |
|
22 | QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const | |
30 | { |
|
23 | { | |
31 | QVector<QRectF> startVector = qVariantValue<QVector<QRectF> > (from); |
|
24 | QVector<QRectF> startVector = qVariantValue<QVector<QRectF> > (from); | |
32 | QVector<QRectF> endVector = qVariantValue<QVector<QRectF> > (to); |
|
25 | QVector<QRectF> endVector = qVariantValue<QVector<QRectF> > (to); | |
33 | QVector<QRectF> result; |
|
26 | QVector<QRectF> result; | |
34 |
|
27 | |||
35 | Q_ASSERT(startVector.count() == endVector.count()) ; |
|
28 | Q_ASSERT(startVector.count() == endVector.count()) ; | |
36 |
|
29 | |||
37 | for(int i =0 ;i< startVector.count();i++){ |
|
30 | for(int i =0 ;i< startVector.count();i++){ | |
38 | //QRectF value = startVector[i] + ((endVector[i] - startVector[i]) * progress); |
|
31 | //QRectF value = startVector[i] + ((endVector[i] - startVector[i]) * progress); | |
39 | QPointF topLeft = startVector[i].topLeft() + ((endVector[i].topLeft() - startVector[i].topLeft()) * progress); |
|
32 | QPointF topLeft = startVector[i].topLeft() + ((endVector[i].topLeft() - startVector[i].topLeft()) * progress); | |
40 | QSizeF size = startVector[i].size() + ((endVector[i].size() - startVector[i].size()) * progress); |
|
33 | QSizeF size = startVector[i].size() + ((endVector[i].size() - startVector[i].size()) * progress); | |
41 | QRectF value(topLeft,size); |
|
34 | QRectF value(topLeft,size); | |
42 | result << value; |
|
35 | result << value; | |
43 | } |
|
36 | } | |
44 | return qVariantFromValue(result); |
|
37 | return qVariantFromValue(result); | |
45 | } |
|
38 | } | |
46 |
|
39 | |||
47 | void BarAnimation::updateCurrentValue(const QVariant &value) |
|
40 | void BarAnimation::updateCurrentValue(const QVariant &value) | |
48 | { |
|
41 | { | |
49 | QVector<QRectF> layout = qVariantValue<QVector<QRectF> >(value); |
|
42 | QVector<QRectF> layout = qVariantValue<QVector<QRectF> >(value); | |
50 | m_item->setLayout(layout); |
|
43 | m_item->setLayout(layout); | |
51 | } |
|
44 | } | |
52 |
|
45 | |||
53 | #include "moc_baranimation_p.cpp" |
|
46 | #include "moc_baranimation_p.cpp" | |
54 |
|
47 | |||
55 | QTCOMMERCIALCHART_END_NAMESPACE |
|
48 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,36 +1,34 | |||||
1 | #ifndef BARANIMATION_P_H_ |
|
1 | #ifndef BARANIMATION_P_H_ | |
2 | #define BARANIMATION_P_H_ |
|
2 | #define BARANIMATION_P_H_ | |
3 |
|
3 | |||
4 | #include "chartanimation_p.h" |
|
4 | #include "chartanimation_p.h" | |
5 | #include "barchartitem_p.h" |
|
5 | #include "barchartitem_p.h" | |
6 |
|
6 | |||
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
8 |
|
8 | |||
9 | class BarChartItem; |
|
9 | class BarChartItem; | |
10 | class QBarSet; |
|
10 | class QBarSet; | |
11 | class BarSetAnimation; |
|
11 | class BarSetAnimation; | |
12 |
|
12 | |||
13 | class BarAnimation : public ChartAnimation |
|
13 | class BarAnimation : public ChartAnimation | |
14 | { |
|
14 | { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 |
|
16 | |||
17 | public: |
|
17 | public: | |
18 | BarAnimation(BarChartItem *item); |
|
18 | BarAnimation(BarChartItem *item); | |
19 | ~BarAnimation(); |
|
19 | ~BarAnimation(); | |
20 |
|
20 | |||
21 | void updateValues(const QVector<QRectF>& layout); |
|
|||
22 |
|
||||
23 | public: // from QVariantAnimation |
|
21 | public: // from QVariantAnimation | |
24 | virtual QVariant interpolated (const QVariant & from, const QVariant & to, qreal progress ) const; |
|
22 | virtual QVariant interpolated (const QVariant & from, const QVariant & to, qreal progress ) const; | |
25 | virtual void updateCurrentValue (const QVariant & value ); |
|
23 | virtual void updateCurrentValue (const QVariant & value ); | |
26 |
|
24 | |||
27 | public Q_SLOTS: |
|
25 | public Q_SLOTS: | |
28 |
|
26 | |||
29 | private: |
|
27 | private: | |
30 | BarChartItem *m_item; |
|
28 | BarChartItem *m_item; | |
31 | QHash<QBarSet*, BarSetAnimation*> m_animations; |
|
29 | QHash<QBarSet*, BarSetAnimation*> m_animations; | |
32 | }; |
|
30 | }; | |
33 |
|
31 | |||
34 | QTCOMMERCIALCHART_END_NAMESPACE |
|
32 | QTCOMMERCIALCHART_END_NAMESPACE | |
35 |
|
33 | |||
36 | #endif |
|
34 | #endif |
@@ -1,357 +1,354 | |||||
1 | #include "barchartitem_p.h" |
|
1 | #include "barchartitem_p.h" | |
2 | #include "bar_p.h" |
|
2 | #include "bar_p.h" | |
3 | #include "barvalue_p.h" |
|
3 | #include "barvalue_p.h" | |
4 | #include "qbarset.h" |
|
4 | #include "qbarset.h" | |
5 | #include "qbarseries.h" |
|
5 | #include "qbarseries.h" | |
6 | #include "qchart.h" |
|
6 | #include "qchart.h" | |
7 | #include "qchartaxis.h" |
|
7 | #include "qchartaxis.h" | |
8 | #include "qchartaxiscategories.h" |
|
8 | #include "qchartaxiscategories.h" | |
9 | #include "chartpresenter_p.h" |
|
9 | #include "chartpresenter_p.h" | |
10 | #include "chartanimator_p.h" |
|
10 | #include "chartanimator_p.h" | |
11 | #include "chartdataset_p.h" |
|
11 | #include "chartdataset_p.h" | |
12 | #include <QDebug> |
|
12 | #include <QDebug> | |
13 | #include <QToolTip> |
|
13 | #include <QToolTip> | |
14 |
|
14 | |||
15 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
15 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
16 |
|
16 | |||
17 | BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : |
|
17 | BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : | |
18 | ChartItem(presenter), |
|
18 | ChartItem(presenter), | |
19 | mLayoutSet(false), |
|
19 | mLayoutSet(false), | |
20 | mSeries(series) |
|
20 | mSeries(series) | |
21 | { |
|
21 | { | |
22 | connect(series,SIGNAL(showToolTip(QPoint,QString)),this,SLOT(showToolTip(QPoint,QString))); |
|
22 | connect(series,SIGNAL(showToolTip(QPoint,QString)),this,SLOT(showToolTip(QPoint,QString))); | |
23 | connect(series, SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); |
|
23 | connect(series, SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); | |
24 | //TODO: connect(series,SIGNAL("position or size has changed"), this, SLOT(handleLayoutChanged())); |
|
24 | //TODO: connect(series,SIGNAL("position or size has changed"), this, SLOT(handleLayoutChanged())); | |
25 | connect(series, SIGNAL(restructuredBar(int)), this, SLOT(handleModelChanged(int))); |
|
25 | connect(series, SIGNAL(restructuredBar(int)), this, SLOT(handleModelChanged(int))); | |
26 | setZValue(ChartPresenter::BarSeriesZValue); |
|
26 | setZValue(ChartPresenter::BarSeriesZValue); | |
27 | initAxisLabels(); |
|
27 | initAxisLabels(); | |
28 | dataChanged(); |
|
28 | dataChanged(); | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | BarChartItem::~BarChartItem() |
|
31 | BarChartItem::~BarChartItem() | |
32 | { |
|
32 | { | |
33 | disconnect(this,SLOT(showToolTip(QPoint,QString))); |
|
33 | disconnect(this,SLOT(showToolTip(QPoint,QString))); | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
36 | void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
37 | { |
|
37 | { | |
38 | if (!mLayoutSet) { |
|
38 | if (!mLayoutSet) { | |
39 | qDebug() << "BarChartItem::paint called without layout set. Aborting."; |
|
39 | qDebug() << "BarChartItem::paint called without layout set. Aborting."; | |
40 | return; |
|
40 | return; | |
41 | } |
|
41 | } | |
42 | foreach(QGraphicsItem* i, childItems()) { |
|
42 | foreach(QGraphicsItem* i, childItems()) { | |
43 | i->paint(painter,option,widget); |
|
43 | i->paint(painter,option,widget); | |
44 | } |
|
44 | } | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | QRectF BarChartItem::boundingRect() const |
|
47 | QRectF BarChartItem::boundingRect() const | |
48 | { |
|
48 | { | |
49 | return m_rect; |
|
49 | return m_rect; | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | void BarChartItem::dataChanged() |
|
52 | void BarChartItem::dataChanged() | |
53 | { |
|
53 | { | |
54 | // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them? |
|
54 | // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them? | |
55 | // Delete old bars |
|
55 | // Delete old bars | |
56 | foreach (QGraphicsItem* item, childItems()) { |
|
56 | foreach (QGraphicsItem* item, childItems()) { | |
57 | delete item; |
|
57 | delete item; | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | mBars.clear(); |
|
60 | mBars.clear(); | |
61 | mFloatingValues.clear(); |
|
61 | mFloatingValues.clear(); | |
62 | mLayout.clear(); |
|
62 | mLayout.clear(); | |
63 |
|
63 | |||
64 | // Create new graphic items for bars |
|
64 | // Create new graphic items for bars | |
65 | for (int c=0; c<mSeries->categoryCount(); c++) { |
|
65 | for (int c=0; c<mSeries->categoryCount(); c++) { | |
66 | QString category = mSeries->categoryName(c); |
|
66 | QString category = mSeries->categoryName(c); | |
67 | for (int s=0; s<mSeries->barsetCount(); s++) { |
|
67 | for (int s=0; s<mSeries->barsetCount(); s++) { | |
68 | QBarSet *set = mSeries->barsetAt(s); |
|
68 | QBarSet *set = mSeries->barsetAt(s); | |
69 | Bar *bar = new Bar(category,this); |
|
69 | Bar *bar = new Bar(category,this); | |
70 | childItems().append(bar); |
|
70 | childItems().append(bar); | |
71 | mBars.append(bar); |
|
71 | mBars.append(bar); | |
72 | connect(bar,SIGNAL(clicked(QString)),set,SIGNAL(clicked(QString))); |
|
72 | connect(bar,SIGNAL(clicked(QString)),set,SIGNAL(clicked(QString))); | |
73 | connect(bar,SIGNAL(rightClicked(QString)),set,SIGNAL(rightClicked(QString))); |
|
73 | connect(bar,SIGNAL(rightClicked(QString)),set,SIGNAL(rightClicked(QString))); | |
74 | connect(bar,SIGNAL(hoverEntered(QPoint)),set,SLOT(barHoverEnterEvent(QPoint))); |
|
74 | connect(bar,SIGNAL(hoverEntered(QPoint)),set,SLOT(barHoverEnterEvent(QPoint))); | |
75 | connect(bar,SIGNAL(hoverLeaved()),set,SLOT(barHoverLeaveEvent())); |
|
75 | connect(bar,SIGNAL(hoverLeaved()),set,SLOT(barHoverLeaveEvent())); | |
76 | mLayout.append(QRectF(0,0,0,0)); |
|
76 | mLayout.append(QRectF(0,0,0,0)); | |
77 | } |
|
77 | } | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | // Create floating values |
|
80 | // Create floating values | |
81 | for (int category=0; category<mSeries->categoryCount(); category++) { |
|
81 | for (int category=0; category<mSeries->categoryCount(); category++) { | |
82 | for (int s=0; s<mSeries->barsetCount(); s++) { |
|
82 | for (int s=0; s<mSeries->barsetCount(); s++) { | |
83 | QBarSet *set = mSeries->barsetAt(s); |
|
83 | QBarSet *set = mSeries->barsetAt(s); | |
84 | BarValue *value = new BarValue(*set, this); |
|
84 | BarValue *value = new BarValue(*set, this); | |
85 | childItems().append(value); |
|
85 | childItems().append(value); | |
86 | mFloatingValues.append(value); |
|
86 | mFloatingValues.append(value); | |
87 | connect(set,SIGNAL(toggleFloatingValues()),value,SLOT(toggleVisible())); |
|
87 | connect(set,SIGNAL(toggleFloatingValues()),value,SLOT(toggleVisible())); | |
88 | } |
|
88 | } | |
89 | } |
|
89 | } | |
90 | } |
|
90 | } | |
91 | /* |
|
91 | /* | |
92 | void BarChartItem::layoutChanged() |
|
92 | void BarChartItem::layoutChanged() | |
93 | { |
|
93 | { | |
94 | qDebug() << "Deprecated BarChartItem::layoutChanged called. aborting"; |
|
94 | qDebug() << "Deprecated BarChartItem::layoutChanged called. aborting"; | |
95 | return; |
|
95 | return; | |
96 | // Scale bars to new layout |
|
96 | // Scale bars to new layout | |
97 | // Layout for bars: |
|
97 | // Layout for bars: | |
98 | if (mSeries->barsetCount() <= 0) { |
|
98 | if (mSeries->barsetCount() <= 0) { | |
99 | qDebug() << "No sets in model!"; |
|
99 | qDebug() << "No sets in model!"; | |
100 | return; |
|
100 | return; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | if (childItems().count() == 0) { |
|
103 | if (childItems().count() == 0) { | |
104 | qDebug() << "WARNING: BarChartitem::layoutChanged called before graphics items are created!"; |
|
104 | qDebug() << "WARNING: BarChartitem::layoutChanged called before graphics items are created!"; | |
105 | return; |
|
105 | return; | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 |
|
108 | |||
109 | // Use temporary qreals for accurancy (we might get some compiler warnings... :) |
|
109 | // Use temporary qreals for accurancy (we might get some compiler warnings... :) | |
110 | qreal categoryCount = mSeries->categoryCount(); |
|
110 | qreal categoryCount = mSeries->categoryCount(); | |
111 | qreal setCount = mSeries->barsetCount(); |
|
111 | qreal setCount = mSeries->barsetCount(); | |
112 | qreal max = mSeries->max(); |
|
112 | qreal max = mSeries->max(); | |
113 |
|
113 | |||
114 | // Domain: |
|
114 | // Domain: | |
115 | if (mDomainMaxY > max) { |
|
115 | if (mDomainMaxY > max) { | |
116 | max = mDomainMaxY; |
|
116 | max = mDomainMaxY; | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | qreal width = geometry().width(); |
|
119 | qreal width = geometry().width(); | |
120 | qreal height = geometry().height(); |
|
120 | qreal height = geometry().height(); | |
121 | qreal scale = (height/max); |
|
121 | qreal scale = (height/max); | |
122 | qreal categoryWidth = width/categoryCount; |
|
122 | qreal categoryWidth = width/categoryCount; | |
123 | qreal barWidth = categoryWidth / (setCount+1); |
|
123 | qreal barWidth = categoryWidth / (setCount+1); | |
124 |
|
124 | |||
125 | BarLayout layout; |
|
125 | BarLayout layout; | |
126 |
|
126 | |||
127 | int itemIndex(0); |
|
127 | int itemIndex(0); | |
128 | for (int category=0; category < categoryCount; category++) { |
|
128 | for (int category=0; category < categoryCount; category++) { | |
129 | qreal xPos = categoryWidth * category + barWidth/2; |
|
129 | qreal xPos = categoryWidth * category + barWidth/2; | |
130 | qreal yPos = height; |
|
130 | qreal yPos = height; | |
131 | for (int set = 0; set < setCount; set++) { |
|
131 | for (int set = 0; set < setCount; set++) { | |
132 | qreal barHeight = mSeries->valueAt(set,category) * scale; |
|
132 | qreal barHeight = mSeries->valueAt(set,category) * scale; | |
133 | Bar* bar = mBars.at(itemIndex); |
|
133 | Bar* bar = mBars.at(itemIndex); | |
134 |
|
134 | |||
135 | QRectF rect(xPos,yPos-barHeight,mBarWidth,barHeight); |
|
135 | QRectF rect(xPos,yPos-barHeight,mBarWidth,barHeight); | |
136 | layout.insert(bar,rect); |
|
136 | layout.insert(bar,rect); | |
137 | // TODO: width settable per bar? |
|
137 | // TODO: width settable per bar? | |
138 | bar->setRect(xPos, yPos-barHeight,barWidth, barHeight); |
|
138 | bar->setRect(xPos, yPos-barHeight,barWidth, barHeight); | |
139 | bar->setPen(mSeries->barsetAt(set)->pen()); |
|
139 | bar->setPen(mSeries->barsetAt(set)->pen()); | |
140 | bar->setBrush(mSeries->barsetAt(set)->brush()); |
|
140 | bar->setBrush(mSeries->barsetAt(set)->brush()); | |
141 |
|
141 | |||
142 | // bar->resize(mBarWidth, barHeight); |
|
142 | // bar->resize(mBarWidth, barHeight); | |
143 | // layout.insert(bar,QSizeF(mBarWidth,barHeight)); |
|
143 | // layout.insert(bar,QSizeF(mBarWidth,barHeight)); | |
144 | bar->setPen(mSeries->barsetAt(set)->pen()); |
|
144 | bar->setPen(mSeries->barsetAt(set)->pen()); | |
145 | bar->setBrush(mSeries->barsetAt(set)->brush()); |
|
145 | bar->setBrush(mSeries->barsetAt(set)->brush()); | |
146 | // bar->setPos(xPos, yPos-barHeight); |
|
146 | // bar->setPos(xPos, yPos-barHeight); | |
147 | itemIndex++; |
|
147 | itemIndex++; | |
148 | xPos += barWidth; |
|
148 | xPos += barWidth; | |
149 | } |
|
149 | } | |
150 | } |
|
150 | } | |
151 |
|
151 | |||
152 | // Position floating values |
|
152 | // Position floating values | |
153 | itemIndex = 0; |
|
153 | itemIndex = 0; | |
154 | for (int category=0; category < mSeries->categoryCount(); category++) { |
|
154 | for (int category=0; category < mSeries->categoryCount(); category++) { | |
155 | qreal xPos = categoryWidth * category + categoryWidth/2 + barWidth; |
|
155 | qreal xPos = categoryWidth * category + categoryWidth/2 + barWidth; | |
156 | qreal yPos = height; |
|
156 | qreal yPos = height; | |
157 | for (int set=0; set < mSeries->barsetCount(); set++) { |
|
157 | for (int set=0; set < mSeries->barsetCount(); set++) { | |
158 | qreal barHeight = mSeries->valueAt(set,category) * scale; |
|
158 | qreal barHeight = mSeries->valueAt(set,category) * scale; | |
159 | BarValue* value = mFloatingValues.at(itemIndex); |
|
159 | BarValue* value = mFloatingValues.at(itemIndex); | |
160 |
|
160 | |||
161 | QBarSet* barSet = mSeries->barsetAt(set); |
|
161 | QBarSet* barSet = mSeries->barsetAt(set); | |
162 | value->resize(100,50); // TODO: proper layout for this. |
|
162 | value->resize(100,50); // TODO: proper layout for this. | |
163 | value->setPos(xPos, yPos-barHeight/2); |
|
163 | value->setPos(xPos, yPos-barHeight/2); | |
164 | value->setPen(barSet->floatingValuePen()); |
|
164 | value->setPen(barSet->floatingValuePen()); | |
165 |
|
165 | |||
166 | if (mSeries->valueAt(set,category) != 0) { |
|
166 | if (mSeries->valueAt(set,category) != 0) { | |
167 | value->setValueString(QString::number(mSeries->valueAt(set,category))); |
|
167 | value->setValueString(QString::number(mSeries->valueAt(set,category))); | |
168 | } else { |
|
168 | } else { | |
169 | value->setValueString(QString("")); |
|
169 | value->setValueString(QString("")); | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | itemIndex++; |
|
172 | itemIndex++; | |
173 | xPos += barWidth; |
|
173 | xPos += barWidth; | |
174 | } |
|
174 | } | |
175 | } |
|
175 | } | |
176 | // update(); |
|
176 | // update(); | |
177 | } |
|
177 | } | |
178 | */ |
|
178 | */ | |
179 | QVector<QRectF> BarChartItem::calculateLayout() |
|
179 | QVector<QRectF> BarChartItem::calculateLayout() | |
180 | { |
|
180 | { | |
181 | // layoutChanged(); |
|
181 | // layoutChanged(); | |
182 | /* |
|
182 | /* | |
183 | BarLayout layout; |
|
183 | BarLayout layout; | |
184 | foreach(Bar* bar, mBars) { |
|
184 | foreach(Bar* bar, mBars) { | |
185 | layout.insert(bar,bar->boundingRect()); |
|
185 | layout.insert(bar,bar->boundingRect()); | |
186 | } |
|
186 | } | |
187 | */ |
|
187 | */ | |
188 | QVector<QRectF> layout; |
|
188 | QVector<QRectF> layout; | |
189 |
|
189 | |||
190 | // Use temporary qreals for accurancy (we might get some compiler warnings... :) |
|
190 | // Use temporary qreals for accurancy (we might get some compiler warnings... :) | |
191 |
|
|
191 | qreal categoryCount = mSeries->categoryCount(); | |
192 |
|
|
192 | qreal setCount = mSeries->barsetCount(); | |
193 |
|
193 | |||
194 | // qreal tW = mWidth; |
|
|||
195 | // qreal tH = mHeight; |
|
|||
196 | qreal width = geometry().width(); |
|
194 | qreal width = geometry().width(); | |
197 | qreal height = geometry().height(); |
|
195 | qreal height = geometry().height(); | |
198 |
|
196 | |||
199 |
qreal |
|
197 | qreal max = mSeries->max(); | |
200 |
|
198 | |||
201 | // Domain: |
|
199 | // Domain: | |
202 |
if (mDomainMaxY > |
|
200 | if (mDomainMaxY > max) { | |
203 |
|
|
201 | max = mDomainMaxY; | |
204 | } |
|
202 | } | |
205 |
|
203 | |||
206 |
qreal scale = (height/ |
|
204 | qreal scale = (height/max); | |
207 |
qreal |
|
205 | qreal categoryWidth = width/categoryCount; | |
208 | qreal categoryWidth = width/tC; |
|
|||
209 | qreal barWidth = categoryWidth / (setCount+1); |
|
206 | qreal barWidth = categoryWidth / (setCount+1); | |
210 |
|
207 | |||
211 | int itemIndex(0); |
|
208 | int itemIndex(0); | |
212 | for (int category=0; category < categoryCount; category++) { |
|
209 | for (int category=0; category < categoryCount; category++) { | |
213 |
qreal xPos = categoryWidth * category + |
|
210 | qreal xPos = categoryWidth * category + barWidth/2; | |
214 | qreal yPos = height; |
|
211 | qreal yPos = height; | |
215 | for (int set = 0; set < setCount; set++) { |
|
212 | for (int set = 0; set < setCount; set++) { | |
216 | qreal barHeight = mSeries->valueAt(set,category) * scale; |
|
213 | qreal barHeight = mSeries->valueAt(set,category) * scale; | |
217 | Bar* bar = mBars.at(itemIndex); |
|
214 | Bar* bar = mBars.at(itemIndex); | |
218 |
|
215 | |||
219 | QRectF rect(xPos,yPos-barHeight,barWidth,barHeight); |
|
216 | QRectF rect(xPos,yPos-barHeight,barWidth,barHeight); | |
220 | //layout.insert(bar,rect); |
|
217 | //layout.insert(bar,rect); | |
221 | layout.append(rect); |
|
218 | layout.append(rect); | |
222 | // TODO: width settable per bar? |
|
219 | // TODO: width settable per bar? | |
223 | // bar->resize(mBarWidth, barHeight); |
|
220 | // bar->resize(mBarWidth, barHeight); | |
224 | // layout.insert(bar,QSizeF(mBarWidth,barHeight)); |
|
221 | // layout.insert(bar,QSizeF(mBarWidth,barHeight)); | |
225 | bar->setPen(mSeries->barsetAt(set)->pen()); |
|
222 | bar->setPen(mSeries->barsetAt(set)->pen()); | |
226 | bar->setBrush(mSeries->barsetAt(set)->brush()); |
|
223 | bar->setBrush(mSeries->barsetAt(set)->brush()); | |
227 | // bar->setPos(xPos, yPos-barHeight); |
|
224 | // bar->setPos(xPos, yPos-barHeight); | |
228 | itemIndex++; |
|
225 | itemIndex++; | |
229 | xPos += barWidth; |
|
226 | xPos += barWidth; | |
230 | } |
|
227 | } | |
231 | } |
|
228 | } | |
232 |
|
229 | |||
233 | // Position floating values |
|
230 | // Position floating values | |
234 | itemIndex = 0; |
|
231 | itemIndex = 0; | |
235 | for (int category=0; category < mSeries->categoryCount(); category++) { |
|
232 | for (int category=0; category < mSeries->categoryCount(); category++) { | |
236 |
qreal xPos = categoryWidth * category |
|
233 | qreal xPos = categoryWidth * category + barWidth; | |
237 | qreal yPos = height; |
|
234 | qreal yPos = height; | |
238 | for (int set=0; set < mSeries->barsetCount(); set++) { |
|
235 | for (int set=0; set < mSeries->barsetCount(); set++) { | |
239 | qreal barHeight = mSeries->valueAt(set,category) * scale; |
|
236 | qreal barHeight = mSeries->valueAt(set,category) * scale; | |
240 | BarValue* value = mFloatingValues.at(itemIndex); |
|
237 | BarValue* value = mFloatingValues.at(itemIndex); | |
241 |
|
238 | |||
242 | QBarSet* barSet = mSeries->barsetAt(set); |
|
239 | QBarSet* barSet = mSeries->barsetAt(set); | |
243 | value->resize(100,50); // TODO: proper layout for this. |
|
240 | value->resize(100,50); // TODO: proper layout for this. | |
244 | value->setPos(xPos, yPos-barHeight/2); |
|
241 | value->setPos(xPos, yPos-barHeight/2); | |
245 | value->setPen(barSet->floatingValuePen()); |
|
242 | value->setPen(barSet->floatingValuePen()); | |
246 |
|
243 | |||
247 | if (mSeries->valueAt(set,category) != 0) { |
|
244 | if (mSeries->valueAt(set,category) != 0) { | |
248 | value->setValueString(QString::number(mSeries->valueAt(set,category))); |
|
245 | value->setValueString(QString::number(mSeries->valueAt(set,category))); | |
249 | } else { |
|
246 | } else { | |
250 | value->setValueString(QString("")); |
|
247 | value->setValueString(QString("")); | |
251 | } |
|
248 | } | |
252 |
|
249 | |||
253 | itemIndex++; |
|
250 | itemIndex++; | |
254 | xPos += barWidth; |
|
251 | xPos += barWidth; | |
255 | } |
|
252 | } | |
256 | } |
|
253 | } | |
257 |
|
254 | |||
258 | return layout; |
|
255 | return layout; | |
259 | } |
|
256 | } | |
260 |
|
257 | |||
261 | void BarChartItem::applyLayout(const QVector<QRectF> &layout) |
|
258 | void BarChartItem::applyLayout(const QVector<QRectF> &layout) | |
262 | { |
|
259 | { | |
263 | if (animator()) |
|
260 | if (animator()) | |
264 | animator()->updateLayout(this, mLayout, layout); |
|
261 | animator()->updateLayout(this, mLayout, layout); | |
265 | else |
|
262 | else | |
266 | setLayout(layout); |
|
263 | setLayout(layout); | |
267 | } |
|
264 | } | |
268 |
|
265 | |||
269 | void BarChartItem::setLayout(const QVector<QRectF> &layout) |
|
266 | void BarChartItem::setLayout(const QVector<QRectF> &layout) | |
270 | { |
|
267 | { | |
271 | mLayout = layout; |
|
268 | mLayout = layout; | |
272 |
|
269 | |||
273 | for (int i=0; i<mBars.count(); i++) { |
|
270 | for (int i=0; i<mBars.count(); i++) { | |
274 | //mBars.at(i)->setSize(layout.at(i).size()); |
|
271 | //mBars.at(i)->setSize(layout.at(i).size()); | |
275 | //mBars.at(i)->setPos(layout.at(i).topLeft()); |
|
272 | //mBars.at(i)->setPos(layout.at(i).topLeft()); | |
276 | mBars.at(i)->setRect(layout.at(i)); |
|
273 | mBars.at(i)->setRect(layout.at(i)); | |
277 | } |
|
274 | } | |
278 |
|
275 | |||
279 | update(); |
|
276 | update(); | |
280 | } |
|
277 | } | |
281 |
|
278 | |||
282 | void BarChartItem::initAxisLabels() |
|
279 | void BarChartItem::initAxisLabels() | |
283 | { |
|
280 | { | |
284 | int count = mSeries->categoryCount(); |
|
281 | int count = mSeries->categoryCount(); | |
285 | if (0 == count) { |
|
282 | if (0 == count) { | |
286 | return; |
|
283 | return; | |
287 | } |
|
284 | } | |
288 |
|
285 | |||
289 | Domain* domain = presenter()->dataSet()->domain(mSeries); |
|
286 | Domain* domain = presenter()->dataSet()->domain(mSeries); | |
290 |
|
287 | |||
291 | qreal min = 0; |
|
288 | qreal min = 0; | |
292 | qreal max = count+1; |
|
289 | qreal max = count+1; | |
293 |
|
290 | |||
294 | domain->setRangeX(min,max,count+1); |
|
291 | domain->setRangeX(min,max,count+1); | |
295 | } |
|
292 | } | |
296 |
|
293 | |||
297 | //handlers |
|
294 | //handlers | |
298 |
|
295 | |||
299 | void BarChartItem::handleModelChanged(int index) |
|
296 | void BarChartItem::handleModelChanged(int index) | |
300 | { |
|
297 | { | |
301 | Q_UNUSED(index) |
|
298 | Q_UNUSED(index) | |
302 | dataChanged(); |
|
299 | dataChanged(); | |
303 | } |
|
300 | } | |
304 |
|
301 | |||
305 | void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) |
|
302 | void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) | |
306 | { |
|
303 | { | |
307 | mDomainMinX = minX; |
|
304 | mDomainMinX = minX; | |
308 | mDomainMaxX = maxX; |
|
305 | mDomainMaxX = maxX; | |
309 | mDomainMinY = minY; |
|
306 | mDomainMinY = minY; | |
310 | mDomainMaxY = maxY; |
|
307 | mDomainMaxY = maxY; | |
311 | handleLayoutChanged(); |
|
308 | handleLayoutChanged(); | |
312 |
|
309 | |||
313 | /* |
|
310 | /* | |
314 | int count = mSeries->categoryCount(); |
|
311 | int count = mSeries->categoryCount(); | |
315 | if (0 == count) { |
|
312 | if (0 == count) { | |
316 | return; |
|
313 | return; | |
317 | } |
|
314 | } | |
318 |
|
315 | |||
319 | // Position labels to domain |
|
316 | // Position labels to domain | |
320 | qreal min = domain.minX(); |
|
317 | qreal min = domain.minX(); | |
321 | qreal max = domain.maxX(); |
|
318 | qreal max = domain.maxX(); | |
322 | qreal step = (max-min)/count; |
|
319 | qreal step = (max-min)/count; | |
323 | QChartAxisCategories& categories = mChart->axisX()->categories(); |
|
320 | QChartAxisCategories& categories = mChart->axisX()->categories(); | |
324 | categories.clear(); |
|
321 | categories.clear(); | |
325 | for (int i=0; i<count; i++) { |
|
322 | for (int i=0; i<count; i++) { | |
326 | categories.insert(min,mSeries->categoryName(i)); |
|
323 | categories.insert(min,mSeries->categoryName(i)); | |
327 | min += step; |
|
324 | min += step; | |
328 | } |
|
325 | } | |
329 | */ |
|
326 | */ | |
330 | } |
|
327 | } | |
331 |
|
328 | |||
332 | void BarChartItem::handleGeometryChanged(const QRectF& rect) |
|
329 | void BarChartItem::handleGeometryChanged(const QRectF& rect) | |
333 | { |
|
330 | { | |
334 | m_rect=rect; |
|
331 | m_rect=rect; | |
335 | handleLayoutChanged(); |
|
332 | handleLayoutChanged(); | |
336 | mLayoutSet = true; |
|
333 | mLayoutSet = true; | |
337 | setPos(rect.topLeft()); |
|
334 | setPos(rect.topLeft()); | |
338 | } |
|
335 | } | |
339 |
|
336 | |||
340 | void BarChartItem::handleLayoutChanged() |
|
337 | void BarChartItem::handleLayoutChanged() | |
341 | { |
|
338 | { | |
342 | qDebug() << "BarChartItem::handleLayoutChanged"; |
|
339 | qDebug() << "BarChartItem::handleLayoutChanged"; | |
343 | QVector<QRectF> layout = calculateLayout(); |
|
340 | QVector<QRectF> layout = calculateLayout(); | |
344 | applyLayout(layout); |
|
341 | applyLayout(layout); | |
345 | update(); |
|
342 | update(); | |
346 | } |
|
343 | } | |
347 |
|
344 | |||
348 |
|
345 | |||
349 | void BarChartItem::showToolTip(QPoint pos, QString tip) |
|
346 | void BarChartItem::showToolTip(QPoint pos, QString tip) | |
350 | { |
|
347 | { | |
351 | // TODO: cool tooltip instead of default |
|
348 | // TODO: cool tooltip instead of default | |
352 | QToolTip::showText(pos,tip); |
|
349 | QToolTip::showText(pos,tip); | |
353 | } |
|
350 | } | |
354 |
|
351 | |||
355 | #include "moc_barchartitem_p.cpp" |
|
352 | #include "moc_barchartitem_p.cpp" | |
356 |
|
353 | |||
357 | QTCOMMERCIALCHART_END_NAMESPACE |
|
354 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,73 +1,73 | |||||
1 | #ifndef DOMAIN_H_ |
|
1 | #ifndef DOMAIN_H_ | |
2 | #define DOMAIN_H_ |
|
2 | #define DOMAIN_H_ | |
3 | #include "qchartglobal.h" |
|
3 | #include "qchartglobal.h" | |
4 | #include "qchartaxis.h" |
|
4 | #include "qchartaxis.h" | |
5 | #include <QRectF> |
|
5 | #include <QRectF> | |
6 | #include <QSizeF> |
|
6 | #include <QSizeF> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class Domain: public QObject { |
|
10 | class Domain: public QObject { | |
11 | Q_OBJECT |
|
11 | Q_OBJECT | |
12 | public: |
|
12 | public: | |
13 | explicit Domain(QObject* object=0); |
|
13 | explicit Domain(QObject* object=0); | |
14 | virtual ~Domain(); |
|
14 | virtual ~Domain(); | |
15 |
|
15 | |||
16 | void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY); |
|
16 | void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY); | |
17 | void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY, int tickXCount, int tickYCount); |
|
17 | void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY, int tickXCount, int tickYCount); | |
18 | void setRangeX(qreal min, qreal max); |
|
18 | void setRangeX(qreal min, qreal max); | |
19 | void setRangeX(qreal min, qreal max, int tickCount); |
|
19 | void setRangeX(qreal min, qreal max, int tickCount); | |
20 | void setRangeY(qreal min, qreal max); |
|
20 | void setRangeY(qreal min, qreal max); | |
21 | void setRangeY(qreal min, qreal max, int tickCount); |
|
21 | void setRangeY(qreal min, qreal max, int tickCount); | |
22 | void setMinX(qreal min); |
|
22 | void setMinX(qreal min); | |
23 | void setMaxX(qreal max); |
|
23 | void setMaxX(qreal max); | |
24 | void setMinY(qreal min); |
|
24 | void setMinY(qreal min); | |
25 | void setMaxY(qreal max); |
|
25 | void setMaxY(qreal max); | |
26 |
|
26 | |||
27 | qreal minX() const {return m_minX;}; |
|
27 | qreal minX() const {return m_minX;}; | |
28 | qreal maxX() const {return m_maxX;}; |
|
28 | qreal maxX() const {return m_maxX;}; | |
29 | qreal minY() const {return m_minY;}; |
|
29 | qreal minY() const {return m_minY;}; | |
30 | qreal maxY() const {return m_maxY;}; |
|
30 | qreal maxY() const {return m_maxY;}; | |
31 |
|
31 | |||
32 | qreal spanX() const; |
|
32 | qreal spanX() const; | |
33 | qreal spanY() const; |
|
33 | qreal spanY() const; | |
34 | bool isEmpty() const; |
|
34 | bool isEmpty() const; | |
35 |
|
35 | |||
36 | int tickXCount() const {return m_tickXCount;} |
|
36 | int tickXCount() const {return m_tickXCount;} | |
37 | int tickYCount() const {return m_tickYCount;} |
|
37 | int tickYCount() const {return m_tickYCount;} | |
38 |
|
38 | |||
39 | friend bool operator== (const Domain &domain1, const Domain &domain2); |
|
39 | friend bool operator== (const Domain &domain1, const Domain &domain2); | |
40 | friend bool operator!= (const Domain &domain1, const Domain &domain2); |
|
40 | friend bool operator!= (const Domain &domain1, const Domain &domain2); | |
41 | friend QDebug operator<<(QDebug dbg, const Domain &domain); |
|
41 | friend QDebug operator<<(QDebug dbg, const Domain &domain); | |
42 |
|
42 | |||
43 | void zoomIn(const QRectF& rect, const QSizeF& size); |
|
43 | void zoomIn(const QRectF& rect, const QSizeF& size); | |
44 | void zoomOut(const QRectF& rect, const QSizeF& size); |
|
44 | void zoomOut(const QRectF& rect, const QSizeF& size); | |
45 | void move(int dx,int dy,const QSizeF& size); |
|
45 | void move(int dx,int dy,const QSizeF& size); | |
46 |
|
46 | |||
47 | signals: |
|
47 | signals: | |
48 | void domainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY); |
|
48 | void domainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY); | |
49 | void rangeXChanged(qreal min, qreal max, int tickXCount); |
|
49 | void rangeXChanged(qreal min, qreal max, int tickXCount); | |
50 | void rangeYChanged(qreal min, qreal max, int tickYCount); |
|
50 | void rangeYChanged(qreal min, qreal max, int tickYCount); | |
51 |
|
51 | |||
52 | public slots: |
|
52 | public slots: | |
53 | void handleAxisXChanged(qreal min,qreal max,int tickXCount,QChartAxis::LabelsSelection mode); |
|
53 | void handleAxisXChanged(qreal min,qreal max,int tickXCount = 5,QChartAxis::LabelsSelection mode = QChartAxis::NativeLabelsSelection); | |
54 | void handleAxisYChanged(qreal min,qreal max,int tickYCount,QChartAxis::LabelsSelection mode); |
|
54 | void handleAxisYChanged(qreal min,qreal max,int tickYCount = 5,QChartAxis::LabelsSelection mode = QChartAxis::NativeLabelsSelection); | |
55 |
|
55 | |||
56 | private: |
|
56 | private: | |
57 | void niceNumbers(qreal &min, qreal &max, int &ticksCount); |
|
57 | void niceNumbers(qreal &min, qreal &max, int &ticksCount); | |
58 | void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount); |
|
58 | void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount); | |
59 | qreal niceNumber(qreal x,bool celing); |
|
59 | qreal niceNumber(qreal x,bool celing); | |
60 |
|
60 | |||
61 | private: |
|
61 | private: | |
62 | qreal m_minX; |
|
62 | qreal m_minX; | |
63 | qreal m_maxX; |
|
63 | qreal m_maxX; | |
64 | qreal m_minY; |
|
64 | qreal m_minY; | |
65 | qreal m_maxY; |
|
65 | qreal m_maxY; | |
66 | int m_tickXCount; |
|
66 | int m_tickXCount; | |
67 | int m_tickYCount; |
|
67 | int m_tickYCount; | |
68 | QChartAxis::LabelsSelection m_selection; |
|
68 | QChartAxis::LabelsSelection m_selection; | |
69 | }; |
|
69 | }; | |
70 |
|
70 | |||
71 | QTCOMMERCIALCHART_END_NAMESPACE |
|
71 | QTCOMMERCIALCHART_END_NAMESPACE | |
72 |
|
72 | |||
73 | #endif |
|
73 | #endif |
@@ -1,578 +1,579 | |||||
1 | #include <QtTest/QtTest> |
|
1 | #include <QtTest/QtTest> | |
2 | #include <private/domain_p.h> |
|
2 | #include <private/domain_p.h> | |
|
3 | #include <qchartaxis.h> | |||
3 |
|
4 | |||
4 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
5 | QTCOMMERCIALCHART_USE_NAMESPACE | |
5 |
|
6 | |||
6 | Q_DECLARE_METATYPE(Domain*) |
|
7 | Q_DECLARE_METATYPE(Domain*) | |
7 | Q_DECLARE_METATYPE(QSizeF) |
|
8 | Q_DECLARE_METATYPE(QSizeF) | |
8 |
|
9 | |||
9 | class tst_Domain : public QObject |
|
10 | class tst_Domain : public QObject | |
10 | { |
|
11 | { | |
11 | Q_OBJECT |
|
12 | Q_OBJECT | |
12 |
|
13 | |||
13 | public slots: |
|
14 | public slots: | |
14 | void initTestCase(); |
|
15 | void initTestCase(); | |
15 | void cleanupTestCase(); |
|
16 | void cleanupTestCase(); | |
16 | void init(); |
|
17 | void init(); | |
17 | void cleanup(); |
|
18 | void cleanup(); | |
18 |
|
19 | |||
19 | private slots: |
|
20 | private slots: | |
20 | void domain(); |
|
21 | void domain(); | |
21 | void handleAxisRangeXChanged_data(); |
|
22 | void handleAxisRangeXChanged_data(); | |
22 | void handleAxisRangeXChanged(); |
|
23 | void handleAxisRangeXChanged(); | |
23 | void handleAxisRangeYChanged_data(); |
|
24 | void handleAxisRangeYChanged_data(); | |
24 | void handleAxisRangeYChanged(); |
|
25 | void handleAxisRangeYChanged(); | |
25 | void isEmpty_data(); |
|
26 | void isEmpty_data(); | |
26 | void isEmpty(); |
|
27 | void isEmpty(); | |
27 | void maxX_data(); |
|
28 | void maxX_data(); | |
28 | void maxX(); |
|
29 | void maxX(); | |
29 | void maxY_data(); |
|
30 | void maxY_data(); | |
30 | void maxY(); |
|
31 | void maxY(); | |
31 | void minX_data(); |
|
32 | void minX_data(); | |
32 | void minX(); |
|
33 | void minX(); | |
33 | void minY_data(); |
|
34 | void minY_data(); | |
34 | void minY(); |
|
35 | void minY(); | |
35 | void operatorEquals_data(); |
|
36 | void operatorEquals_data(); | |
36 | void operatorEquals(); |
|
37 | void operatorEquals(); | |
37 | void setRange_data(); |
|
38 | void setRange_data(); | |
38 | void setRange(); |
|
39 | void setRange(); | |
39 | void setRangeX_data(); |
|
40 | void setRangeX_data(); | |
40 | void setRangeX(); |
|
41 | void setRangeX(); | |
41 | void setRangeY_data(); |
|
42 | void setRangeY_data(); | |
42 | void setRangeY(); |
|
43 | void setRangeY(); | |
43 | void spanX_data(); |
|
44 | void spanX_data(); | |
44 | void spanX(); |
|
45 | void spanX(); | |
45 | void spanY_data(); |
|
46 | void spanY_data(); | |
46 | void spanY(); |
|
47 | void spanY(); | |
47 | void zoom_data(); |
|
48 | void zoom_data(); | |
48 | void zoom(); |
|
49 | void zoom(); | |
49 | }; |
|
50 | }; | |
50 |
|
51 | |||
51 | void tst_Domain::initTestCase() |
|
52 | void tst_Domain::initTestCase() | |
52 | { |
|
53 | { | |
53 | } |
|
54 | } | |
54 |
|
55 | |||
55 | void tst_Domain::cleanupTestCase() |
|
56 | void tst_Domain::cleanupTestCase() | |
56 | { |
|
57 | { | |
57 | } |
|
58 | } | |
58 |
|
59 | |||
59 | void tst_Domain::init() |
|
60 | void tst_Domain::init() | |
60 | { |
|
61 | { | |
61 | } |
|
62 | } | |
62 |
|
63 | |||
63 | void tst_Domain::cleanup() |
|
64 | void tst_Domain::cleanup() | |
64 | { |
|
65 | { | |
65 | } |
|
66 | } | |
66 |
|
67 | |||
67 | void tst_Domain::domain() |
|
68 | void tst_Domain::domain() | |
68 | { |
|
69 | { | |
69 | Domain domain; |
|
70 | Domain domain; | |
70 |
|
71 | |||
71 | QCOMPARE(domain.isEmpty(), true); |
|
72 | QCOMPARE(domain.isEmpty(), true); | |
72 | QCOMPARE(domain.maxX(), 0.0); |
|
73 | QCOMPARE(domain.maxX(), 0.0); | |
73 | QCOMPARE(domain.maxY(), 0.0); |
|
74 | QCOMPARE(domain.maxY(), 0.0); | |
74 | QCOMPARE(domain.minX(), 0.0); |
|
75 | QCOMPARE(domain.minX(), 0.0); | |
75 | QCOMPARE(domain.minY(), 0.0); |
|
76 | QCOMPARE(domain.minY(), 0.0); | |
76 | } |
|
77 | } | |
77 |
|
78 | |||
78 | void tst_Domain::handleAxisRangeXChanged_data() |
|
79 | void tst_Domain::handleAxisRangeXChanged_data() | |
79 | { |
|
80 | { | |
80 | QTest::addColumn<qreal>("min"); |
|
81 | QTest::addColumn<qreal>("min"); | |
81 | QTest::addColumn<qreal>("max"); |
|
82 | QTest::addColumn<qreal>("max"); | |
82 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
83 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
83 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
84 | QTest::newRow("0 1") << 0.0 << 1.0; | |
84 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
85 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
85 | } |
|
86 | } | |
86 |
|
87 | |||
87 | void tst_Domain::handleAxisRangeXChanged() |
|
88 | void tst_Domain::handleAxisRangeXChanged() | |
88 | { |
|
89 | { | |
89 | QFETCH(qreal, min); |
|
90 | QFETCH(qreal, min); | |
90 | QFETCH(qreal, max); |
|
91 | QFETCH(qreal, max); | |
91 |
|
92 | |||
92 | Domain domain; |
|
93 | Domain domain; | |
93 |
|
94 | |||
94 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
95 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
95 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
96 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
96 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
97 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
97 |
|
98 | |||
98 |
domain.handleAxis |
|
99 | domain.handleAxisXChanged(min, max); | |
99 |
|
100 | |||
100 | QList<QVariant> arg0 = spy0.first(); |
|
101 | QList<QVariant> arg0 = spy0.first(); | |
101 | QVERIFY(arg0.at(0).toReal() == min); |
|
102 | QVERIFY(arg0.at(0).toReal() == min); | |
102 | QVERIFY(arg0.at(1).toReal() == max); |
|
103 | QVERIFY(arg0.at(1).toReal() == max); | |
103 |
|
104 | |||
104 | QList<QVariant> arg1 = spy1.first(); |
|
105 | QList<QVariant> arg1 = spy1.first(); | |
105 | QVERIFY(arg1.at(0).toReal() == min); |
|
106 | QVERIFY(arg1.at(0).toReal() == min); | |
106 | QVERIFY(arg1.at(1).toReal() == max); |
|
107 | QVERIFY(arg1.at(1).toReal() == max); | |
107 |
|
108 | |||
108 | QCOMPARE(spy0.count(), 1); |
|
109 | QCOMPARE(spy0.count(), 1); | |
109 | QCOMPARE(spy1.count(), 1); |
|
110 | QCOMPARE(spy1.count(), 1); | |
110 | QCOMPARE(spy2.count(), 0); |
|
111 | QCOMPARE(spy2.count(), 0); | |
111 |
|
112 | |||
112 | } |
|
113 | } | |
113 |
|
114 | |||
114 | void tst_Domain::handleAxisRangeYChanged_data() |
|
115 | void tst_Domain::handleAxisRangeYChanged_data() | |
115 | { |
|
116 | { | |
116 | QTest::addColumn<qreal>("min"); |
|
117 | QTest::addColumn<qreal>("min"); | |
117 | QTest::addColumn<qreal>("max"); |
|
118 | QTest::addColumn<qreal>("max"); | |
118 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
119 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
119 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
120 | QTest::newRow("0 1") << 0.0 << 1.0; | |
120 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
121 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
121 | } |
|
122 | } | |
122 |
|
123 | |||
123 |
|
124 | |||
124 | void tst_Domain::handleAxisRangeYChanged() |
|
125 | void tst_Domain::handleAxisRangeYChanged() | |
125 | { |
|
126 | { | |
126 | QFETCH(qreal, min); |
|
127 | QFETCH(qreal, min); | |
127 | QFETCH(qreal, max); |
|
128 | QFETCH(qreal, max); | |
128 |
|
129 | |||
129 | Domain domain; |
|
130 | Domain domain; | |
130 |
|
131 | |||
131 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
132 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
132 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
133 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
133 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
134 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
134 |
|
135 | |||
135 |
domain.handleAxis |
|
136 | domain.handleAxisYChanged(min, max,5); | |
136 |
|
137 | |||
137 | QList<QVariant> arg0 = spy0.first(); |
|
138 | QList<QVariant> arg0 = spy0.first(); | |
138 | QVERIFY(arg0.at(2).toReal() == min); |
|
139 | QVERIFY(arg0.at(2).toReal() == min); | |
139 | QVERIFY(arg0.at(3).toReal() == max); |
|
140 | QVERIFY(arg0.at(3).toReal() == max); | |
140 |
|
141 | |||
141 | QList<QVariant> arg1 = spy2.first(); |
|
142 | QList<QVariant> arg1 = spy2.first(); | |
142 | QVERIFY(arg1.at(0).toReal() == min); |
|
143 | QVERIFY(arg1.at(0).toReal() == min); | |
143 | QVERIFY(arg1.at(1).toReal() == max); |
|
144 | QVERIFY(arg1.at(1).toReal() == max); | |
144 |
|
145 | |||
145 | QCOMPARE(spy0.count(), 1); |
|
146 | QCOMPARE(spy0.count(), 1); | |
146 | QCOMPARE(spy1.count(), 0); |
|
147 | QCOMPARE(spy1.count(), 0); | |
147 | QCOMPARE(spy2.count(), 1); |
|
148 | QCOMPARE(spy2.count(), 1); | |
148 | } |
|
149 | } | |
149 |
|
150 | |||
150 | void tst_Domain::isEmpty_data() |
|
151 | void tst_Domain::isEmpty_data() | |
151 | { |
|
152 | { | |
152 | QTest::addColumn<qreal>("minX"); |
|
153 | QTest::addColumn<qreal>("minX"); | |
153 | QTest::addColumn<qreal>("maxX"); |
|
154 | QTest::addColumn<qreal>("maxX"); | |
154 | QTest::addColumn<qreal>("minY"); |
|
155 | QTest::addColumn<qreal>("minY"); | |
155 | QTest::addColumn<qreal>("maxY"); |
|
156 | QTest::addColumn<qreal>("maxY"); | |
156 | QTest::addColumn<bool>("isEmpty"); |
|
157 | QTest::addColumn<bool>("isEmpty"); | |
157 | QTest::newRow("0 0 0 0") << 0.0 << 0.0 << 0.0 << 0.0 << true; |
|
158 | QTest::newRow("0 0 0 0") << 0.0 << 0.0 << 0.0 << 0.0 << true; | |
158 | QTest::newRow("0 1 0 0") << 0.0 << 1.0 << 0.0 << 0.0 << true; |
|
159 | QTest::newRow("0 1 0 0") << 0.0 << 1.0 << 0.0 << 0.0 << true; | |
159 | QTest::newRow("0 0 0 1") << 0.0 << 1.0 << 0.0 << 0.0 << true; |
|
160 | QTest::newRow("0 0 0 1") << 0.0 << 1.0 << 0.0 << 0.0 << true; | |
160 | QTest::newRow("0 1 0 1") << 0.0 << 1.0 << 0.0 << 1.0 << false; |
|
161 | QTest::newRow("0 1 0 1") << 0.0 << 1.0 << 0.0 << 1.0 << false; | |
161 | } |
|
162 | } | |
162 |
|
163 | |||
163 | void tst_Domain::isEmpty() |
|
164 | void tst_Domain::isEmpty() | |
164 | { |
|
165 | { | |
165 | QFETCH(qreal, minX); |
|
166 | QFETCH(qreal, minX); | |
166 | QFETCH(qreal, maxX); |
|
167 | QFETCH(qreal, maxX); | |
167 | QFETCH(qreal, minY); |
|
168 | QFETCH(qreal, minY); | |
168 | QFETCH(qreal, maxY); |
|
169 | QFETCH(qreal, maxY); | |
169 | QFETCH(bool, isEmpty); |
|
170 | QFETCH(bool, isEmpty); | |
170 |
|
171 | |||
171 | Domain domain; |
|
172 | Domain domain; | |
172 | domain.setRange(minX,maxX,minY,maxY); |
|
173 | domain.setRange(minX,maxX,minY,maxY); | |
173 | QCOMPARE(domain.isEmpty(), isEmpty); |
|
174 | QCOMPARE(domain.isEmpty(), isEmpty); | |
174 | } |
|
175 | } | |
175 |
|
176 | |||
176 | void tst_Domain::maxX_data() |
|
177 | void tst_Domain::maxX_data() | |
177 | { |
|
178 | { | |
178 | QTest::addColumn<qreal>("maxX1"); |
|
179 | QTest::addColumn<qreal>("maxX1"); | |
179 | QTest::addColumn<qreal>("maxX2"); |
|
180 | QTest::addColumn<qreal>("maxX2"); | |
180 | QTest::addColumn<int>("count"); |
|
181 | QTest::addColumn<int>("count"); | |
181 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
182 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
182 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
183 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
183 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
184 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
184 | } |
|
185 | } | |
185 |
|
186 | |||
186 | void tst_Domain::maxX() |
|
187 | void tst_Domain::maxX() | |
187 | { |
|
188 | { | |
188 | QFETCH(qreal, maxX1); |
|
189 | QFETCH(qreal, maxX1); | |
189 | QFETCH(qreal, maxX2); |
|
190 | QFETCH(qreal, maxX2); | |
190 | QFETCH(int, count); |
|
191 | QFETCH(int, count); | |
191 |
|
192 | |||
192 | Domain domain; |
|
193 | Domain domain; | |
193 |
|
194 | |||
194 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
195 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
195 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
196 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
196 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
197 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
197 |
|
198 | |||
198 | domain.setMaxX(maxX1); |
|
199 | domain.setMaxX(maxX1); | |
199 | QCOMPARE(domain.maxX(), maxX1); |
|
200 | QCOMPARE(domain.maxX(), maxX1); | |
200 | domain.setMaxX(maxX2); |
|
201 | domain.setMaxX(maxX2); | |
201 | QCOMPARE(domain.maxX(), maxX2); |
|
202 | QCOMPARE(domain.maxX(), maxX2); | |
202 |
|
203 | |||
203 |
|
204 | |||
204 | QCOMPARE(spy0.count(), count); |
|
205 | QCOMPARE(spy0.count(), count); | |
205 | QCOMPARE(spy1.count(), count); |
|
206 | QCOMPARE(spy1.count(), count); | |
206 | QCOMPARE(spy2.count(), 0); |
|
207 | QCOMPARE(spy2.count(), 0); | |
207 |
|
208 | |||
208 | } |
|
209 | } | |
209 |
|
210 | |||
210 | void tst_Domain::maxY_data() |
|
211 | void tst_Domain::maxY_data() | |
211 | { |
|
212 | { | |
212 | QTest::addColumn<qreal>("maxY1"); |
|
213 | QTest::addColumn<qreal>("maxY1"); | |
213 | QTest::addColumn<qreal>("maxY2"); |
|
214 | QTest::addColumn<qreal>("maxY2"); | |
214 | QTest::addColumn<int>("count"); |
|
215 | QTest::addColumn<int>("count"); | |
215 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
216 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
216 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
217 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
217 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
218 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
218 | } |
|
219 | } | |
219 |
|
220 | |||
220 |
|
221 | |||
221 | void tst_Domain::maxY() |
|
222 | void tst_Domain::maxY() | |
222 | { |
|
223 | { | |
223 | QFETCH(qreal, maxY1); |
|
224 | QFETCH(qreal, maxY1); | |
224 | QFETCH(qreal, maxY2); |
|
225 | QFETCH(qreal, maxY2); | |
225 | QFETCH(int, count); |
|
226 | QFETCH(int, count); | |
226 |
|
227 | |||
227 | Domain domain; |
|
228 | Domain domain; | |
228 |
|
229 | |||
229 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
230 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
230 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
231 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
231 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
232 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
232 |
|
233 | |||
233 | domain.setMaxY(maxY1); |
|
234 | domain.setMaxY(maxY1); | |
234 | QCOMPARE(domain.maxY(), maxY1); |
|
235 | QCOMPARE(domain.maxY(), maxY1); | |
235 | domain.setMaxY(maxY2); |
|
236 | domain.setMaxY(maxY2); | |
236 | QCOMPARE(domain.maxY(), maxY2); |
|
237 | QCOMPARE(domain.maxY(), maxY2); | |
237 |
|
238 | |||
238 | QCOMPARE(spy0.count(), count); |
|
239 | QCOMPARE(spy0.count(), count); | |
239 | QCOMPARE(spy1.count(), 0); |
|
240 | QCOMPARE(spy1.count(), 0); | |
240 | QCOMPARE(spy2.count(), count); |
|
241 | QCOMPARE(spy2.count(), count); | |
241 | } |
|
242 | } | |
242 |
|
243 | |||
243 | void tst_Domain::minX_data() |
|
244 | void tst_Domain::minX_data() | |
244 | { |
|
245 | { | |
245 | QTest::addColumn<qreal>("minX1"); |
|
246 | QTest::addColumn<qreal>("minX1"); | |
246 | QTest::addColumn<qreal>("minX2"); |
|
247 | QTest::addColumn<qreal>("minX2"); | |
247 | QTest::addColumn<int>("count"); |
|
248 | QTest::addColumn<int>("count"); | |
248 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
249 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
249 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
250 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
250 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
251 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
251 | } |
|
252 | } | |
252 |
|
253 | |||
253 |
|
254 | |||
254 | void tst_Domain::minX() |
|
255 | void tst_Domain::minX() | |
255 | { |
|
256 | { | |
256 | QFETCH(qreal, minX1); |
|
257 | QFETCH(qreal, minX1); | |
257 | QFETCH(qreal, minX2); |
|
258 | QFETCH(qreal, minX2); | |
258 | QFETCH(int, count); |
|
259 | QFETCH(int, count); | |
259 |
|
260 | |||
260 | Domain domain; |
|
261 | Domain domain; | |
261 |
|
262 | |||
262 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
263 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
263 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
264 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
264 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
265 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
265 |
|
266 | |||
266 | domain.setMinX(minX1); |
|
267 | domain.setMinX(minX1); | |
267 | QCOMPARE(domain.minX(), minX1); |
|
268 | QCOMPARE(domain.minX(), minX1); | |
268 | domain.setMinX(minX2); |
|
269 | domain.setMinX(minX2); | |
269 | QCOMPARE(domain.minX(), minX2); |
|
270 | QCOMPARE(domain.minX(), minX2); | |
270 |
|
271 | |||
271 | QCOMPARE(spy0.count(), count); |
|
272 | QCOMPARE(spy0.count(), count); | |
272 | QCOMPARE(spy1.count(), count); |
|
273 | QCOMPARE(spy1.count(), count); | |
273 | QCOMPARE(spy2.count(), 0); |
|
274 | QCOMPARE(spy2.count(), 0); | |
274 | } |
|
275 | } | |
275 |
|
276 | |||
276 | void tst_Domain::minY_data() |
|
277 | void tst_Domain::minY_data() | |
277 | { |
|
278 | { | |
278 | QTest::addColumn<qreal>("minY1"); |
|
279 | QTest::addColumn<qreal>("minY1"); | |
279 | QTest::addColumn<qreal>("minY2"); |
|
280 | QTest::addColumn<qreal>("minY2"); | |
280 | QTest::addColumn<int>("count"); |
|
281 | QTest::addColumn<int>("count"); | |
281 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
282 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
282 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
283 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
283 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
284 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
284 | } |
|
285 | } | |
285 |
|
286 | |||
286 | void tst_Domain::minY() |
|
287 | void tst_Domain::minY() | |
287 | { |
|
288 | { | |
288 | QFETCH(qreal, minY1); |
|
289 | QFETCH(qreal, minY1); | |
289 | QFETCH(qreal, minY2); |
|
290 | QFETCH(qreal, minY2); | |
290 | QFETCH(int, count); |
|
291 | QFETCH(int, count); | |
291 |
|
292 | |||
292 | Domain domain; |
|
293 | Domain domain; | |
293 |
|
294 | |||
294 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
295 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
295 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
296 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
296 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
297 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
297 |
|
298 | |||
298 | domain.setMinY(minY1); |
|
299 | domain.setMinY(minY1); | |
299 | QCOMPARE(domain.minY(), minY1); |
|
300 | QCOMPARE(domain.minY(), minY1); | |
300 | domain.setMinY(minY2); |
|
301 | domain.setMinY(minY2); | |
301 | QCOMPARE(domain.minY(), minY2); |
|
302 | QCOMPARE(domain.minY(), minY2); | |
302 |
|
303 | |||
303 | QCOMPARE(spy0.count(), count); |
|
304 | QCOMPARE(spy0.count(), count); | |
304 | QCOMPARE(spy1.count(), 0); |
|
305 | QCOMPARE(spy1.count(), 0); | |
305 | QCOMPARE(spy2.count(), count); |
|
306 | QCOMPARE(spy2.count(), count); | |
306 | } |
|
307 | } | |
307 |
|
308 | |||
308 | void tst_Domain::operatorEquals_data() |
|
309 | void tst_Domain::operatorEquals_data() | |
309 | { |
|
310 | { | |
310 |
|
311 | |||
311 | QTest::addColumn<Domain*>("domain1"); |
|
312 | QTest::addColumn<Domain*>("domain1"); | |
312 | QTest::addColumn<Domain*>("domain2"); |
|
313 | QTest::addColumn<Domain*>("domain2"); | |
313 | QTest::addColumn<bool>("equals"); |
|
314 | QTest::addColumn<bool>("equals"); | |
314 | QTest::addColumn<bool>("notEquals"); |
|
315 | QTest::addColumn<bool>("notEquals"); | |
315 | Domain* a; |
|
316 | Domain* a; | |
316 | Domain* b; |
|
317 | Domain* b; | |
317 | a = new Domain(); |
|
318 | a = new Domain(); | |
318 | a->setRange(0,100,0,100); |
|
319 | a->setRange(0,100,0,100); | |
319 | b = new Domain(); |
|
320 | b = new Domain(); | |
320 | b->setRange(0,100,0,100); |
|
321 | b->setRange(0,100,0,100); | |
321 | QTest::newRow("equals") << a << b << true <<false; |
|
322 | QTest::newRow("equals") << a << b << true <<false; | |
322 | a = new Domain(); |
|
323 | a = new Domain(); | |
323 | a->setRange(0,100,0,100); |
|
324 | a->setRange(0,100,0,100); | |
324 | b = new Domain(); |
|
325 | b = new Domain(); | |
325 | b->setRange(0,100,0,1); |
|
326 | b->setRange(0,100,0,1); | |
326 | QTest::newRow("equals") << a << b << false << true; |
|
327 | QTest::newRow("equals") << a << b << false << true; | |
327 | a = new Domain(); |
|
328 | a = new Domain(); | |
328 | a->setRange(0,100,0,100); |
|
329 | a->setRange(0,100,0,100); | |
329 | b = new Domain(); |
|
330 | b = new Domain(); | |
330 | b->setRange(0,1,0,100); |
|
331 | b->setRange(0,1,0,100); | |
331 | QTest::newRow("equals") << a << b << false << true; |
|
332 | QTest::newRow("equals") << a << b << false << true; | |
332 |
|
333 | |||
333 | } |
|
334 | } | |
334 |
|
335 | |||
335 | void tst_Domain::operatorEquals() |
|
336 | void tst_Domain::operatorEquals() | |
336 | { |
|
337 | { | |
337 | QFETCH(Domain*, domain1); |
|
338 | QFETCH(Domain*, domain1); | |
338 | QFETCH(Domain*, domain2); |
|
339 | QFETCH(Domain*, domain2); | |
339 | QFETCH(bool, equals); |
|
340 | QFETCH(bool, equals); | |
340 | QFETCH(bool, notEquals); |
|
341 | QFETCH(bool, notEquals); | |
341 |
|
342 | |||
342 | Domain domain; |
|
343 | Domain domain; | |
343 |
|
344 | |||
344 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
345 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
345 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
346 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
346 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
347 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
347 |
|
348 | |||
348 | QCOMPARE(*domain1==*domain2, equals); |
|
349 | QCOMPARE(*domain1==*domain2, equals); | |
349 | QCOMPARE(*domain1!=*domain2, notEquals); |
|
350 | QCOMPARE(*domain1!=*domain2, notEquals); | |
350 |
|
351 | |||
351 | QCOMPARE(spy0.count(), 0); |
|
352 | QCOMPARE(spy0.count(), 0); | |
352 | QCOMPARE(spy1.count(), 0); |
|
353 | QCOMPARE(spy1.count(), 0); | |
353 | QCOMPARE(spy2.count(), 0); |
|
354 | QCOMPARE(spy2.count(), 0); | |
354 | } |
|
355 | } | |
355 |
|
356 | |||
356 | void tst_Domain::setRange_data() |
|
357 | void tst_Domain::setRange_data() | |
357 | { |
|
358 | { | |
358 | QTest::addColumn<qreal>("minX"); |
|
359 | QTest::addColumn<qreal>("minX"); | |
359 | QTest::addColumn<qreal>("maxX"); |
|
360 | QTest::addColumn<qreal>("maxX"); | |
360 | QTest::addColumn<qreal>("minY"); |
|
361 | QTest::addColumn<qreal>("minY"); | |
361 | QTest::addColumn<qreal>("maxY"); |
|
362 | QTest::addColumn<qreal>("maxY"); | |
362 | QTest::newRow("1,2,1,2") << 1.0 << 2.0 << 1.0 << 2.0; |
|
363 | QTest::newRow("1,2,1,2") << 1.0 << 2.0 << 1.0 << 2.0; | |
363 | QTest::newRow("1,3,1,3") << 1.0 << 3.0 << 1.0 << 3.0; |
|
364 | QTest::newRow("1,3,1,3") << 1.0 << 3.0 << 1.0 << 3.0; | |
364 | QTest::newRow("-1,5,-2,-1") << -1.0 << 5.0 << -2.0 << -1.0; |
|
365 | QTest::newRow("-1,5,-2,-1") << -1.0 << 5.0 << -2.0 << -1.0; | |
365 | } |
|
366 | } | |
366 |
|
367 | |||
367 | void tst_Domain::setRange() |
|
368 | void tst_Domain::setRange() | |
368 | { |
|
369 | { | |
369 | QFETCH(qreal, minX); |
|
370 | QFETCH(qreal, minX); | |
370 | QFETCH(qreal, maxX); |
|
371 | QFETCH(qreal, maxX); | |
371 | QFETCH(qreal, minY); |
|
372 | QFETCH(qreal, minY); | |
372 | QFETCH(qreal, maxY); |
|
373 | QFETCH(qreal, maxY); | |
373 |
|
374 | |||
374 | Domain domain; |
|
375 | Domain domain; | |
375 |
|
376 | |||
376 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
377 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
377 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
378 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
378 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
379 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
379 |
|
380 | |||
380 | domain.setRange(minX, maxX, minY, maxY); |
|
381 | domain.setRange(minX, maxX, minY, maxY); | |
381 |
|
382 | |||
382 | QCOMPARE(domain.minX(), minX); |
|
383 | QCOMPARE(domain.minX(), minX); | |
383 | QCOMPARE(domain.maxX(), maxX); |
|
384 | QCOMPARE(domain.maxX(), maxX); | |
384 | QCOMPARE(domain.minY(), minY); |
|
385 | QCOMPARE(domain.minY(), minY); | |
385 | QCOMPARE(domain.maxY(), maxY); |
|
386 | QCOMPARE(domain.maxY(), maxY); | |
386 |
|
387 | |||
387 | QCOMPARE(spy0.count(), 1); |
|
388 | QCOMPARE(spy0.count(), 1); | |
388 | QCOMPARE(spy1.count(), 1); |
|
389 | QCOMPARE(spy1.count(), 1); | |
389 | QCOMPARE(spy2.count(), 1); |
|
390 | QCOMPARE(spy2.count(), 1); | |
390 |
|
391 | |||
391 |
|
392 | |||
392 | } |
|
393 | } | |
393 |
|
394 | |||
394 | void tst_Domain::setRangeX_data() |
|
395 | void tst_Domain::setRangeX_data() | |
395 | { |
|
396 | { | |
396 | QTest::addColumn<qreal>("min"); |
|
397 | QTest::addColumn<qreal>("min"); | |
397 | QTest::addColumn<qreal>("max"); |
|
398 | QTest::addColumn<qreal>("max"); | |
398 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
399 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
399 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
400 | QTest::newRow("0 1") << 0.0 << 1.0; | |
400 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
401 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
401 | } |
|
402 | } | |
402 |
|
403 | |||
403 | void tst_Domain::setRangeX() |
|
404 | void tst_Domain::setRangeX() | |
404 | { |
|
405 | { | |
405 | QFETCH(qreal, min); |
|
406 | QFETCH(qreal, min); | |
406 | QFETCH(qreal, max); |
|
407 | QFETCH(qreal, max); | |
407 |
|
408 | |||
408 | Domain domain; |
|
409 | Domain domain; | |
409 |
|
410 | |||
410 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
411 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
411 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
412 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
412 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
413 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
413 |
|
414 | |||
414 | domain.setRangeX(min, max); |
|
415 | domain.setRangeX(min, max); | |
415 |
|
416 | |||
416 | QList<QVariant> arg0 = spy0.first(); |
|
417 | QList<QVariant> arg0 = spy0.first(); | |
417 | QVERIFY(arg0.at(0).toReal() == min); |
|
418 | QVERIFY(arg0.at(0).toReal() == min); | |
418 | QVERIFY(arg0.at(1).toReal() == max); |
|
419 | QVERIFY(arg0.at(1).toReal() == max); | |
419 |
|
420 | |||
420 | QList<QVariant> arg1 = spy1.first(); |
|
421 | QList<QVariant> arg1 = spy1.first(); | |
421 | QVERIFY(arg1.at(0).toReal() == min); |
|
422 | QVERIFY(arg1.at(0).toReal() == min); | |
422 | QVERIFY(arg1.at(1).toReal() == max); |
|
423 | QVERIFY(arg1.at(1).toReal() == max); | |
423 |
|
424 | |||
424 | QCOMPARE(spy0.count(), 1); |
|
425 | QCOMPARE(spy0.count(), 1); | |
425 | QCOMPARE(spy1.count(), 1); |
|
426 | QCOMPARE(spy1.count(), 1); | |
426 | QCOMPARE(spy2.count(), 0); |
|
427 | QCOMPARE(spy2.count(), 0); | |
427 | } |
|
428 | } | |
428 |
|
429 | |||
429 | void tst_Domain::setRangeY_data() |
|
430 | void tst_Domain::setRangeY_data() | |
430 | { |
|
431 | { | |
431 | QTest::addColumn<qreal>("min"); |
|
432 | QTest::addColumn<qreal>("min"); | |
432 | QTest::addColumn<qreal>("max"); |
|
433 | QTest::addColumn<qreal>("max"); | |
433 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
434 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
434 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
435 | QTest::newRow("0 1") << 0.0 << 1.0; | |
435 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
436 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
436 | } |
|
437 | } | |
437 |
|
438 | |||
438 | void tst_Domain::setRangeY() |
|
439 | void tst_Domain::setRangeY() | |
439 | { |
|
440 | { | |
440 | QFETCH(qreal, min); |
|
441 | QFETCH(qreal, min); | |
441 | QFETCH(qreal, max); |
|
442 | QFETCH(qreal, max); | |
442 |
|
443 | |||
443 | Domain domain; |
|
444 | Domain domain; | |
444 |
|
445 | |||
445 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
446 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
446 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
447 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
447 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
448 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
448 |
|
449 | |||
449 | domain.setRangeY(min, max); |
|
450 | domain.setRangeY(min, max); | |
450 |
|
451 | |||
451 | QList<QVariant> arg0 = spy0.first(); |
|
452 | QList<QVariant> arg0 = spy0.first(); | |
452 | QVERIFY(arg0.at(2).toReal() == min); |
|
453 | QVERIFY(arg0.at(2).toReal() == min); | |
453 | QVERIFY(arg0.at(3).toReal() == max); |
|
454 | QVERIFY(arg0.at(3).toReal() == max); | |
454 |
|
455 | |||
455 | QList<QVariant> arg1 = spy2.first(); |
|
456 | QList<QVariant> arg1 = spy2.first(); | |
456 | QVERIFY(arg1.at(0).toReal() == min); |
|
457 | QVERIFY(arg1.at(0).toReal() == min); | |
457 | QVERIFY(arg1.at(1).toReal() == max); |
|
458 | QVERIFY(arg1.at(1).toReal() == max); | |
458 |
|
459 | |||
459 | QCOMPARE(spy0.count(), 1); |
|
460 | QCOMPARE(spy0.count(), 1); | |
460 | QCOMPARE(spy1.count(), 0); |
|
461 | QCOMPARE(spy1.count(), 0); | |
461 | QCOMPARE(spy2.count(), 1); |
|
462 | QCOMPARE(spy2.count(), 1); | |
462 | } |
|
463 | } | |
463 |
|
464 | |||
464 | void tst_Domain::spanX_data() |
|
465 | void tst_Domain::spanX_data() | |
465 | { |
|
466 | { | |
466 | QTest::addColumn<qreal>("minX"); |
|
467 | QTest::addColumn<qreal>("minX"); | |
467 | QTest::addColumn<qreal>("maxX"); |
|
468 | QTest::addColumn<qreal>("maxX"); | |
468 | QTest::addColumn<qreal>("spanX"); |
|
469 | QTest::addColumn<qreal>("spanX"); | |
469 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; |
|
470 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; | |
470 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; |
|
471 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; | |
471 | } |
|
472 | } | |
472 |
|
473 | |||
473 | void tst_Domain::spanX() |
|
474 | void tst_Domain::spanX() | |
474 | { |
|
475 | { | |
475 | QFETCH(qreal, minX); |
|
476 | QFETCH(qreal, minX); | |
476 | QFETCH(qreal, maxX); |
|
477 | QFETCH(qreal, maxX); | |
477 | QFETCH(qreal, spanX); |
|
478 | QFETCH(qreal, spanX); | |
478 |
|
479 | |||
479 | Domain domain; |
|
480 | Domain domain; | |
480 |
|
481 | |||
481 | domain.setRangeX(minX,maxX); |
|
482 | domain.setRangeX(minX,maxX); | |
482 |
|
483 | |||
483 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
484 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
484 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
485 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
485 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
486 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
486 |
|
487 | |||
487 | QCOMPARE(domain.spanX(), spanX); |
|
488 | QCOMPARE(domain.spanX(), spanX); | |
488 |
|
489 | |||
489 | QCOMPARE(spy0.count(), 0); |
|
490 | QCOMPARE(spy0.count(), 0); | |
490 | QCOMPARE(spy1.count(), 0); |
|
491 | QCOMPARE(spy1.count(), 0); | |
491 | QCOMPARE(spy2.count(), 0); |
|
492 | QCOMPARE(spy2.count(), 0); | |
492 | } |
|
493 | } | |
493 |
|
494 | |||
494 | void tst_Domain::spanY_data() |
|
495 | void tst_Domain::spanY_data() | |
495 | { |
|
496 | { | |
496 | QTest::addColumn<qreal>("minY"); |
|
497 | QTest::addColumn<qreal>("minY"); | |
497 | QTest::addColumn<qreal>("maxY"); |
|
498 | QTest::addColumn<qreal>("maxY"); | |
498 | QTest::addColumn<qreal>("spanY"); |
|
499 | QTest::addColumn<qreal>("spanY"); | |
499 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; |
|
500 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; | |
500 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; |
|
501 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; | |
501 | } |
|
502 | } | |
502 |
|
503 | |||
503 | void tst_Domain::spanY() |
|
504 | void tst_Domain::spanY() | |
504 | { |
|
505 | { | |
505 | QFETCH(qreal, minY); |
|
506 | QFETCH(qreal, minY); | |
506 | QFETCH(qreal, maxY); |
|
507 | QFETCH(qreal, maxY); | |
507 | QFETCH(qreal, spanY); |
|
508 | QFETCH(qreal, spanY); | |
508 |
|
509 | |||
509 | Domain domain; |
|
510 | Domain domain; | |
510 |
|
511 | |||
511 | domain.setRangeY(minY,maxY); |
|
512 | domain.setRangeY(minY,maxY); | |
512 |
|
513 | |||
513 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
514 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
514 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
515 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
515 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
516 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
516 |
|
517 | |||
517 | QCOMPARE(domain.spanY(), spanY); |
|
518 | QCOMPARE(domain.spanY(), spanY); | |
518 |
|
519 | |||
519 | QCOMPARE(spy0.count(), 0); |
|
520 | QCOMPARE(spy0.count(), 0); | |
520 | QCOMPARE(spy1.count(), 0); |
|
521 | QCOMPARE(spy1.count(), 0); | |
521 | QCOMPARE(spy2.count(), 0); |
|
522 | QCOMPARE(spy2.count(), 0); | |
522 | } |
|
523 | } | |
523 |
|
524 | |||
524 |
|
525 | |||
525 | void tst_Domain::zoom_data() |
|
526 | void tst_Domain::zoom_data() | |
526 | { |
|
527 | { | |
527 | QTest::addColumn<QRectF>("rect0"); |
|
528 | QTest::addColumn<QRectF>("rect0"); | |
528 | QTest::addColumn<QSizeF>("size0"); |
|
529 | QTest::addColumn<QSizeF>("size0"); | |
529 | QTest::addColumn<QRectF>("rect1"); |
|
530 | QTest::addColumn<QRectF>("rect1"); | |
530 | QTest::addColumn<QSizeF>("size1"); |
|
531 | QTest::addColumn<QSizeF>("size1"); | |
531 | QTest::addColumn<QRectF>("rect2"); |
|
532 | QTest::addColumn<QRectF>("rect2"); | |
532 | QTest::addColumn<QSizeF>("size2"); |
|
533 | QTest::addColumn<QSizeF>("size2"); | |
533 | QTest::newRow("first") << QRectF(10,10,100,100) << QSizeF(1000,1000) << QRectF(20,20,100,100) << QSizeF(1000,1000) << QRectF(50,50,100,100) << QSizeF(1000,1000); |
|
534 | QTest::newRow("first") << QRectF(10,10,100,100) << QSizeF(1000,1000) << QRectF(20,20,100,100) << QSizeF(1000,1000) << QRectF(50,50,100,100) << QSizeF(1000,1000); | |
534 | QTest::newRow("scound") << QRectF(10,10,50,50) << QSizeF(1000,1000) << QRectF(20,20,100,100) << QSizeF(1000,1000) << QRectF(50,50,100,100) << QSizeF(1000,1000); |
|
535 | QTest::newRow("scound") << QRectF(10,10,50,50) << QSizeF(1000,1000) << QRectF(20,20,100,100) << QSizeF(1000,1000) << QRectF(50,50,100,100) << QSizeF(1000,1000); | |
535 | QTest::newRow("third") << QRectF(10,10,10,10) << QSizeF(100,100) << QRectF(20,20,20,20) << QSizeF(100,100) << QRectF(50,50,50,50) << QSizeF(100,100); |
|
536 | QTest::newRow("third") << QRectF(10,10,10,10) << QSizeF(100,100) << QRectF(20,20,20,20) << QSizeF(100,100) << QRectF(50,50,50,50) << QSizeF(100,100); | |
536 | } |
|
537 | } | |
537 |
|
538 | |||
538 | void tst_Domain::zoom() |
|
539 | void tst_Domain::zoom() | |
539 | { |
|
540 | { | |
540 | QFETCH(QRectF, rect0); |
|
541 | QFETCH(QRectF, rect0); | |
541 | QFETCH(QSizeF, size0); |
|
542 | QFETCH(QSizeF, size0); | |
542 | QFETCH(QRectF, rect1); |
|
543 | QFETCH(QRectF, rect1); | |
543 | QFETCH(QSizeF, size1); |
|
544 | QFETCH(QSizeF, size1); | |
544 | QFETCH(QRectF, rect2); |
|
545 | QFETCH(QRectF, rect2); | |
545 | QFETCH(QSizeF, size2); |
|
546 | QFETCH(QSizeF, size2); | |
546 |
|
547 | |||
547 | Domain domain; |
|
548 | Domain domain; | |
548 |
|
549 | |||
549 | domain.setRange(0,1000,0,1000); |
|
550 | domain.setRange(0,1000,0,1000); | |
550 |
|
551 | |||
551 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); |
|
552 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal, qreal, qreal, qreal))); | |
552 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); |
|
553 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal, qreal))); | |
553 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); |
|
554 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal, qreal))); | |
554 |
|
555 | |||
555 | Domain domain0; |
|
556 | Domain domain0; | |
556 | domain0.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); |
|
557 | domain0.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); | |
557 | domain.zoomIn(rect0, size0); |
|
558 | domain.zoomIn(rect0, size0); | |
558 | Domain domain1; |
|
559 | Domain domain1; | |
559 | domain1.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); |
|
560 | domain1.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); | |
560 | domain.zoomIn(rect1, size1); |
|
561 | domain.zoomIn(rect1, size1); | |
561 | Domain domain2; |
|
562 | Domain domain2; | |
562 | domain2.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); |
|
563 | domain2.setRange(domain.minX(),domain.maxX(),domain.minY(),domain.maxY()); | |
563 | domain.zoomIn(rect2, size2); |
|
564 | domain.zoomIn(rect2, size2); | |
564 | domain.zoomOut(rect2, size2); |
|
565 | domain.zoomOut(rect2, size2); | |
565 | QCOMPARE(domain == domain2,true); |
|
566 | QCOMPARE(domain == domain2,true); | |
566 | domain.zoomOut(rect1, size1); |
|
567 | domain.zoomOut(rect1, size1); | |
567 | QCOMPARE(domain == domain1,true); |
|
568 | QCOMPARE(domain == domain1,true); | |
568 | domain.zoomOut(rect0, size0); |
|
569 | domain.zoomOut(rect0, size0); | |
569 | QCOMPARE(domain == domain0,true); |
|
570 | QCOMPARE(domain == domain0,true); | |
570 | QCOMPARE(spy0.count(), 6); |
|
571 | QCOMPARE(spy0.count(), 6); | |
571 | QCOMPARE(spy1.count(), 6); |
|
572 | QCOMPARE(spy1.count(), 6); | |
572 | QCOMPARE(spy2.count(), 6); |
|
573 | QCOMPARE(spy2.count(), 6); | |
573 |
|
574 | |||
574 | } |
|
575 | } | |
575 |
|
576 | |||
576 | QTEST_MAIN(tst_Domain) |
|
577 | QTEST_MAIN(tst_Domain) | |
577 | #include "tst_domain.moc" |
|
578 | #include "tst_domain.moc" | |
578 |
|
579 |
General Comments 0
You need to be logged in to leave comments.
Login now