Moves the remaining ticks of the Axis to their correct position on update.

If the size of the Axis changed, this should move them smootly to their
place.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-01-14 16:24:33 -02:00 committed by Dirk Hohndel
parent ca979044d0
commit 36475c1ee5

View file

@ -58,6 +58,26 @@ void DiveCartesianAxis::updateTicks()
removedText->animatedHide();
}
}
// Move the remaining Ticks / Text to it's corerct position
// Regartind the possibly new values for the Axis
qreal begin = orientation == Qt::Horizontal ? m.x1() : m.y1();
qreal end = orientation == Qt::Horizontal ? m.x2() : m.y2();
double stepSize = orientation == Qt::Horizontal ? (m.x2() - m.x1()) : (m.y2() - m.y1());
stepSize = stepSize / steps;
for(int i = 0, count = ticks.size(); i < count; i++, currValue += interval){
qreal childPos = begin + i * stepSize;
labels[i]->setText(textForValue(currValue));
if ( orientation == Qt::Horizontal ){
ticks[i]->animateMoveTo(childPos, m.y1() + tickSize);
labels[i]->animateMoveTo(childPos, m.y1() + tickSize);
}
else{
ticks[i]->animateMoveTo(m.x1() - tickSize, childPos);
labels[i]->animateMoveTo(m.x1() - tickSize, childPos);
}
}
}
QString DiveCartesianAxis::textForValue(double value)