# HG changeset patch # User insilmaril # Date 1209995202 0 # Node ID d0086df58648106f405c68a9db582f3437b7bb26 # Parent 1973a58f390086a037d8e12f750d2d6adf18c8aa Some code cleanup and experimental stuff to support animations later diff -r 1973a58f3900 -r d0086df58648 animpoint.cpp --- a/animpoint.cpp Thu Apr 10 19:56:11 2008 +0000 +++ b/animpoint.cpp Mon May 05 13:46:42 2008 +0000 @@ -1,5 +1,7 @@ #include "animpoint.h" +#include + AnimPoint::AnimPoint() { init(); @@ -27,6 +29,8 @@ { if (rx() != other.rx() ) return false; if (ry() != other.ry() ) return false; + if (startPos != other.startPos) return false; + if (destPos != other.destPos) return false; if (animated != other.animated ) return false; return true; @@ -35,24 +39,62 @@ void AnimPoint::init () { animated=false; + n=0; + startPos=QPointF(0,0); + destPos=QPointF(0,0); + vector=QPointF(0,0); + animTicks=10; } void AnimPoint::copy (AnimPoint other) { setX (other.x() ); setY (other.x() ); + startPos=other.startPos; + destPos=other.destPos; + vector=other.vector; animated=other.animated; + n=other.n; + animTicks=other.animTicks; +} + +void AnimPoint::setStart(const QPointF &p) +{ + startPos=p; + initVector(); +} + +QPointF AnimPoint::getStart() +{ + return startPos; } void AnimPoint::setDest(const QPointF &p) { destPos=p; + initVector(); +} + +QPointF AnimPoint::getDest() +{ + return destPos; +} + +void AnimPoint::setTicks (const uint &t) +{ + animTicks=t; +} + +uint AnimPoint::getTicks() +{ + return animTicks; } void AnimPoint::setAnimated(bool b) { animated=b; + if (b) n=0; } bool AnimPoint::isAnimated() @@ -60,11 +102,30 @@ return animated; } -void AnimPoint::animate() +bool AnimPoint::animate() { - setX (x()+1); - setY (y()+1); + if (!animated) return animated; + n++; + if (n>animTicks) + { + vector=QPointF(0,0); + animated=false; + return animated; + } + + setX (startPos.x() + vector.x()*sqrt(n/animTicks) ); + setY (startPos.y() + vector.y()*sqrt(n/animTicks) ); + /* + setX (startPos.x() + vector.x()*(n/animTicks) ); + setY (startPos.y() + vector.y()*(n/animTicks) ); + */ + return animated; } +void AnimPoint::initVector() +{ + vector.setX (destPos.x()-startPos.x() ); + vector.setY (destPos.y()-startPos.y() ); +} diff -r 1973a58f3900 -r d0086df58648 animpoint.h --- a/animpoint.h Thu Apr 10 19:56:11 2008 +0000 +++ b/animpoint.h Mon May 05 13:46:42 2008 +0000 @@ -13,15 +13,24 @@ bool operator== ( AnimPoint ); void init(); void copy(AnimPoint other); + void setStart (const QPointF &); + QPointF getStart(); void setDest (const QPointF &); + QPointF getDest(); + void setTicks (const uint &t); + uint getTicks(); void setAnimated(bool); bool isAnimated (); - void animate(); + bool animate(); private: - QPointF currentPos; + void initVector(); + + QPointF startPos; QPointF destPos; + QPointF vector; qreal n; + qreal animTicks; bool animated; }; diff -r 1973a58f3900 -r d0086df58648 branchobj.cpp --- a/branchobj.cpp Thu Apr 10 19:56:11 2008 +0000 +++ b/branchobj.cpp Mon May 05 13:46:42 2008 +0000 @@ -1307,12 +1307,14 @@ qreal th = bboxTotal.height(); // TODO testing /* - cout << "BO::alignRelTo "<