diff -r cade59622d81 -r 0c2d74acf035 vymmodel.cpp --- a/vymmodel.cpp Mon May 05 13:46:42 2008 +0000 +++ b/vymmodel.cpp Mon May 05 13:46:42 2008 +0000 @@ -4,6 +4,9 @@ #include "geometry.h" // for addBBox #include "vymmodel.h" + +extern Settings settings; + VymModel::VymModel() { // cout << "Const VymModel\n"; @@ -24,6 +27,15 @@ void VymModel::init () { addMapCenter(); + + // animations + animationUse=settings.readBoolEntry("/animation/use",false); + animationTicks=settings.readNumEntry("/animation/ticks",10); + animationInterval=settings.readNumEntry("/animation/interval",50); + animObjList.clear(); + animationTimer=new QTimer (this); + connect(animationTimer, SIGNAL(timeout()), this, SLOT(animate())); + } void VymModel::setMapEditor(MapEditor *me) @@ -251,9 +263,6 @@ // Move all branches and MapCenters away from lmo // to avoid collisions - // - - QPolygonF pA; QPolygonF pB; @@ -275,6 +284,44 @@ } } +void VymModel::animate() +{ + animationTimer->stop(); + BranchObj *bo; + int i=0; + while (ianimate()) + { + if (i>=0) animObjList.removeAt(i); + } + bo->reposition(); + i++; + } + mapEditor->updateSelection(); + mapScene->update(); + animationTimer->start(); +} + + +void VymModel::startAnimation(const QPointF &start, const QPointF &dest) +{ + BranchObj *bo=getSelectedBranch(); + if (bo && bo->getDepth()>0) + { + AnimPoint ap; + ap.setStart (start); + ap.setDest (dest); + ap.setTicks (animationTicks); + ap.setAnimated (true); + bo->setAnimation (ap); + animObjList.append( bo ); + animationTimer->setSingleShot (true); + animationTimer->start(animationInterval); + } +} + ////////////////////////////////////////////// // Selection related