@@ -56,6 +56,10 void CartesianChartAxis::createItems(int count) | |||
|
56 | 56 | QGraphicsLineItem *item = new QGraphicsLineItem(this); |
|
57 | 57 | item->setPen(axis()->gridLinePen()); |
|
58 | 58 | gridGroup()->addToGroup(item); |
|
59 | QGraphicsRectItem *shades = new QGraphicsRectItem(this); | |
|
60 | shades->setPen(axis()->shadesPen()); | |
|
61 | shades->setBrush(axis()->shadesBrush()); | |
|
62 | shadeGroup()->addToGroup(shades); | |
|
59 | 63 | } |
|
60 | 64 | } |
|
61 | 65 | |
@@ -78,14 +82,13 void CartesianChartAxis::createItems(int count) | |||
|
78 | 82 | gridGroup()->addToGroup(grid); |
|
79 | 83 | labelGroup()->addToGroup(label); |
|
80 | 84 | |
|
81 |
if ((gridItems().size()) % 2 && gridItems().size() > |
|
|
82 |
QGraphicsRectItem* |
|
|
85 | if (gridItems().size() == 1 || (((gridItems().size() + 1) % 2) && gridItems().size() > 0)) { | |
|
86 | QGraphicsRectItem *shades = new QGraphicsRectItem(this); | |
|
83 | 87 | shades->setPen(axis()->shadesPen()); |
|
84 | 88 | shades->setBrush(axis()->shadesBrush()); |
|
85 | 89 | shadeGroup()->addToGroup(shades); |
|
86 | 90 | } |
|
87 | 91 | } |
|
88 | ||
|
89 | 92 | } |
|
90 | 93 | |
|
91 | 94 | void CartesianChartAxis::deleteItems(int count) |
@@ -96,7 +99,7 void CartesianChartAxis::deleteItems(int count) | |||
|
96 | 99 | QList<QGraphicsItem *> axis = arrowItems(); |
|
97 | 100 | |
|
98 | 101 | for (int i = 0; i < count; ++i) { |
|
99 |
if (lines.size() % 2 && lines.size() > |
|
|
102 | if (lines.size() == 1 || (((lines.size() + 1) % 2) && lines.size() > 0)) | |
|
100 | 103 | delete(shades.takeLast()); |
|
101 | 104 | delete(lines.takeLast()); |
|
102 | 105 | delete(labels.takeLast()); |
@@ -161,15 +161,30 void HorizontalAxis::updateGeometry() | |||
|
161 | 161 | } |
|
162 | 162 | |
|
163 | 163 | //shades |
|
164 | if ((i + 1) % 2 && i > 1) { | |
|
165 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem *>(shades.at(i / 2 - 1)); | |
|
166 | qreal leftBound = qMax(layout[i - 1], gridRect.left()); | |
|
167 | qreal rightBound = qMin(layout[i], gridRect.right()); | |
|
168 | rectItem->setRect(leftBound, gridRect.top(), rightBound - leftBound, gridRect.height()); | |
|
169 | if (rectItem->rect().width() <= 0.0) | |
|
170 | rectItem->setVisible(false); | |
|
164 | QGraphicsRectItem *shadeItem = 0; | |
|
165 | if (i == 0) | |
|
166 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at(0)); | |
|
167 | else if (i % 2) | |
|
168 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at((i / 2) + 1)); | |
|
169 | if (shadeItem) { | |
|
170 | qreal leftBound; | |
|
171 | qreal rightBound; | |
|
172 | if (i == 0) { | |
|
173 | leftBound = gridRect.left(); | |
|
174 | rightBound = layout[0]; | |
|
175 | } else { | |
|
176 | leftBound = layout[i]; | |
|
177 | if (i == layout.size() - 1) | |
|
178 | rightBound = gridRect.right(); | |
|
179 | else | |
|
180 | rightBound = qMin(layout[i + 1], gridRect.right()); | |
|
181 | } | |
|
182 | shadeItem->setRect(leftBound, gridRect.top(), rightBound - leftBound, | |
|
183 | gridRect.height()); | |
|
184 | if (shadeItem->rect().width() <= 0.0) | |
|
185 | shadeItem->setVisible(false); | |
|
171 | 186 | else |
|
172 |
|
|
|
187 | shadeItem->setVisible(true); | |
|
173 | 188 | } |
|
174 | 189 | |
|
175 | 190 | // check if the grid line and the axis tick should be shown |
@@ -165,15 +165,31 void VerticalAxis::updateGeometry() | |||
|
165 | 165 | } |
|
166 | 166 | |
|
167 | 167 | //shades |
|
168 | if ((i + 1) % 2 && i > 1) { | |
|
169 | QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem *>(shades.at(i / 2 - 1)); | |
|
170 | qreal lowerBound = qMin(layout[i - 1], gridRect.bottom()); | |
|
171 | qreal upperBound = qMax(layout[i], gridRect.top()); | |
|
172 | rectItem->setRect(gridRect.left(), upperBound, gridRect.width(), lowerBound - upperBound); | |
|
173 | if (rectItem->rect().height() <= 0.0) | |
|
174 | rectItem->setVisible(false); | |
|
168 | QGraphicsRectItem *shadeItem = 0; | |
|
169 | if (i == 0) | |
|
170 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at(0)); | |
|
171 | else if (i % 2) | |
|
172 | shadeItem = static_cast<QGraphicsRectItem *>(shades.at((i / 2) + 1)); | |
|
173 | if (shadeItem) { | |
|
174 | qreal lowerBound; | |
|
175 | qreal upperBound; | |
|
176 | if (i == 0) { | |
|
177 | lowerBound = gridRect.bottom(); | |
|
178 | upperBound = layout[0]; | |
|
179 | } else { | |
|
180 | lowerBound = layout[i]; | |
|
181 | if (i == layout.size() - 1) | |
|
182 | upperBound = gridRect.top(); | |
|
183 | else | |
|
184 | upperBound = qMax(layout[i + 1], gridRect.top()); | |
|
185 | ||
|
186 | } | |
|
187 | shadeItem->setRect(gridRect.left(), upperBound, gridRect.width(), | |
|
188 | lowerBound - upperBound); | |
|
189 | if (shadeItem->rect().height() <= 0.0) | |
|
190 | shadeItem->setVisible(false); | |
|
175 | 191 | else |
|
176 |
|
|
|
192 | shadeItem->setVisible(true); | |
|
177 | 193 | } |
|
178 | 194 | |
|
179 | 195 | // check if the grid line and the axis tick should be shown |
General Comments 0
You need to be logged in to leave comments.
Login now