1.1 --- a/vymmodel.cpp Mon May 05 13:46:42 2008 +0000
1.2 +++ b/vymmodel.cpp Mon May 05 13:46:42 2008 +0000
1.3 @@ -4,6 +4,9 @@
1.4 #include "geometry.h" // for addBBox
1.5 #include "vymmodel.h"
1.6
1.7 +
1.8 +extern Settings settings;
1.9 +
1.10 VymModel::VymModel()
1.11 {
1.12 // cout << "Const VymModel\n";
1.13 @@ -24,6 +27,15 @@
1.14 void VymModel::init ()
1.15 {
1.16 addMapCenter();
1.17 +
1.18 + // animations
1.19 + animationUse=settings.readBoolEntry("/animation/use",false);
1.20 + animationTicks=settings.readNumEntry("/animation/ticks",10);
1.21 + animationInterval=settings.readNumEntry("/animation/interval",50);
1.22 + animObjList.clear();
1.23 + animationTimer=new QTimer (this);
1.24 + connect(animationTimer, SIGNAL(timeout()), this, SLOT(animate()));
1.25 +
1.26 }
1.27
1.28 void VymModel::setMapEditor(MapEditor *me)
1.29 @@ -251,9 +263,6 @@
1.30 // Move all branches and MapCenters away from lmo
1.31 // to avoid collisions
1.32
1.33 - //
1.34 -
1.35 -
1.36 QPolygonF pA;
1.37 QPolygonF pB;
1.38
1.39 @@ -275,6 +284,44 @@
1.40 }
1.41 }
1.42
1.43 +void VymModel::animate()
1.44 +{
1.45 + animationTimer->stop();
1.46 + BranchObj *bo;
1.47 + int i=0;
1.48 + while (i<animObjList.size() )
1.49 + {
1.50 + bo=(BranchObj*)animObjList.at(i);
1.51 + if (!bo->animate())
1.52 + {
1.53 + if (i>=0) animObjList.removeAt(i);
1.54 + }
1.55 + bo->reposition();
1.56 + i++;
1.57 + }
1.58 + mapEditor->updateSelection();
1.59 + mapScene->update();
1.60 + animationTimer->start();
1.61 +}
1.62 +
1.63 +
1.64 +void VymModel::startAnimation(const QPointF &start, const QPointF &dest)
1.65 +{
1.66 + BranchObj *bo=getSelectedBranch();
1.67 + if (bo && bo->getDepth()>0)
1.68 + {
1.69 + AnimPoint ap;
1.70 + ap.setStart (start);
1.71 + ap.setDest (dest);
1.72 + ap.setTicks (animationTicks);
1.73 + ap.setAnimated (true);
1.74 + bo->setAnimation (ap);
1.75 + animObjList.append( bo );
1.76 + animationTimer->setSingleShot (true);
1.77 + animationTimer->start(animationInterval);
1.78 + }
1.79 +}
1.80 +
1.81
1.82 //////////////////////////////////////////////
1.83 // Selection related