diff -r f1006de05c54 -r 7d67be709091 mapeditor.cpp --- a/mapeditor.cpp Mon Sep 07 15:36:57 2009 +0000 +++ b/mapeditor.cpp Tue Sep 08 12:15:39 2009 +0000 @@ -7,6 +7,7 @@ #include #include "branchitem.h" +#include "geometry.h" #include "mainwindow.h" #include "misc.h" #include "warningdialog.h" @@ -545,10 +546,6 @@ } cout <<" hidemode="< mapobjects; + QList polys; + QList vectors; + QList orgpos; + BranchItem *bi; + BranchObj *bo; + TreeItem *ri=model->getRootItem(); + for (int i=0;ibranchCount();++i) + { + bi=ri->getBranchNum (i); + bo=(BranchObj*)bi->getLMO(); + if (bo) + { + mapobjects.append (bo); + polys.append(bo->getBoundingPolygon()); + polys[i].calcCentroid(); + vectors.append (QPointF(0,0)); + orgpos.append (polys[i].at(0)); + } + } + + // Iterate moving bounding polygons until we have no more collisions + int collisions=1; + while (collisions>0) + { + collisions=0; + for (int i=0; imoveBy(v.x(),v.y() ); + } + model->reposition(); } BranchItem* MapEditor::getBranchDirectAbove (BranchItem *bi) @@ -1050,8 +1114,8 @@ if ( e->modifiers()==Qt::ShiftModifier && dsti && dsti != seli->parent() ) { // Also save the move which was done so far - QString pold=qpointfToString(movingObj_orgRelPos); - QString pnow=qpointfToString(fio->getRelPos()); + QString pold=qpointFToString(movingObj_orgRelPos); + QString pnow=qpointFToString(fio->getRelPos()); model->saveState( seli, "moveRel "+pold, @@ -1205,8 +1269,8 @@ if(fio) { // Moved FloatObj. Maybe we need to reposition - QString pold=qpointfToString(movingObj_orgRelPos); - QString pnow=qpointfToString(fio->getRelPos()); + QString pold=qpointFToString(movingObj_orgRelPos); + QString pnow=qpointFToString(fio->getRelPos()); model->saveState( seli, "moveRel "+pold, @@ -1225,8 +1289,8 @@ { if (movingObj_orgPos != bi->getBranchObj()->getAbsPos()) // FIXME-3 check getBO here... { - QString pold=qpointfToString(movingObj_orgPos); - QString pnow=qpointfToString(bi->getBranchObj()->getAbsPos()); // FIXME-3 check getBO here... + QString pold=qpointFToString(movingObj_orgPos); + QString pnow=qpointFToString(bi->getBranchObj()->getAbsPos()); // FIXME-3 check getBO here... model->saveState( bi, @@ -1311,9 +1375,9 @@ QPointF rp(lmosel->getRelPos()); if (rp != movingObj_orgRelPos) { - QString ps=qpointfToString(rp); + QString ps=qpointFToString(rp); model->saveState( - model->getSelectString(lmosel), "moveRel "+qpointfToString(movingObj_orgRelPos), + model->getSelectString(lmosel), "moveRel "+qpointFToString(movingObj_orgRelPos), preSelStr, "moveRel "+ps, QString("Move %1 to relative position %2").arg(model->getObjectName(lmosel)).arg(ps)); }