174 graphic->hide(); |
174 graphic->hide(); |
175 } else { |
175 } else { |
176 graphic->setScene(Q_NULLPTR); |
176 graphic->setScene(Q_NULLPTR); |
177 m_scene.reset(new QGraphicsScene(this)); |
177 m_scene.reset(new QGraphicsScene(this)); |
178 |
178 |
|
179 quint32 maxValue = 0; |
|
180 int maxSize = 0; |
|
181 for(QMap<quint32, QVector<quint32> >::const_iterator i = healthPoints.constBegin(); i != healthPoints.constEnd(); ++i) |
|
182 { |
|
183 maxSize = qMax(maxSize, i.value().size()); |
|
184 |
|
185 foreach (quint32 v, i.value()) |
|
186 maxValue = qMax(maxValue, v); |
|
187 } |
|
188 |
|
189 if(maxSize < 2) |
|
190 return; |
|
191 |
179 QMap<quint32, QVector<quint32> >::const_iterator i = healthPoints.constBegin(); |
192 QMap<quint32, QVector<quint32> >::const_iterator i = healthPoints.constBegin(); |
180 while (i != healthPoints.constEnd()) |
193 while (i != healthPoints.constEnd()) |
181 { |
194 { |
182 quint32 c = i.key(); |
195 quint32 c = i.key(); |
183 //QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); |
196 //QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); |
184 QVector<quint32> hps = i.value(); |
197 const QVector<quint32>& hps = i.value(); |
185 |
198 |
186 QPainterPath path; |
199 QPainterPath path; |
187 if (hps.size()) |
200 if (hps.size()) |
188 path.moveTo(0, hps[0]); |
201 path.moveTo(0, hps[0]); |
189 |
202 |
190 for(int t = 1; t < hps.size(); ++t) |
203 for(int t = 1; t < hps.size(); ++t) |
191 path.lineTo(t, hps[t]); |
204 path.lineTo(t * maxValue / (maxSize - 1), hps[t]); |
192 |
205 |
193 QPen pen(c); |
206 QPen pen(c); |
194 pen.setWidth(2); |
207 pen.setWidth(2); |
195 pen.setCosmetic(true); |
208 pen.setCosmetic(true); |
196 |
209 |