From 215e22481af5b19331882af27a3243eca7c2cf38 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 14 Jan 2014 16:28:07 -0200 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/profile/divecartesianaxis.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'qt-ui/profile/divecartesianaxis.cpp') diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp index dc99d1f88..358b85ef4 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/qt-ui/profile/divecartesianaxis.cpp @@ -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) -- cgit v1.2.3-70-g09d2