Added the remaining of the ticks to their correct position.

When we prepare the axis to show something on the Profile
we need to add the remaining ticks to show on screen,
Since this method tries to animately move / remove things
before calling this.

This has no animations yet - will have in the future.

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:28:07 -02:00 committed by Dirk Hohndel
parent 36475c1ee5
commit 215e22481a

View file

@ -78,6 +78,36 @@ void DiveCartesianAxis::updateTicks()
}
}
// Add's the rest of the needed Ticks / Text.
for(int i = ticks.size(); i < steps; i++, currValue += interval){
qreal childPos = begin + i * stepSize;
DiveLineItem *item = new DiveLineItem(this);
item->setPen(pen());
ticks.push_back(item);
DiveTextItem *label = new DiveTextItem(this);
label->setText(textForValue(currValue));
label->setBrush(QBrush(textColor));
labels.push_back(label);
if(orientation == Qt::Horizontal){
item->setLine(0, 0, 0, tickSize);
item->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene
item->animateMoveTo(childPos, m.y1() + tickSize); // anim it to scene.
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
label->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene);
label->animateMoveTo(childPos, m.y1() + tickSize);
}
else{
item->setLine(0, 0, tickSize, 0);
item->setPos(m.x1() - tickSize, scene()->sceneRect().height() + 10);
item->animateMoveTo(m.x1() - tickSize, childPos);
label->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
label->setPos(m.x1() - tickSize, scene()->sceneRect().height() + 10);
label->animateMoveTo(m.x1() - tickSize, childPos);
}
}
}
QString DiveCartesianAxis::textForValue(double value)