diff -r 7a96bd401351 -r 21379539d952 mapobj.cpp --- a/mapobj.cpp Sun Jan 30 12:58:47 2005 +0000 +++ b/mapobj.cpp Wed Jul 05 10:29:54 2006 +0000 @@ -1,17 +1,17 @@ #include "mapobj.h" +#include "misc.h" ///////////////////////////////////////////////////////////////// // MapObj ///////////////////////////////////////////////////////////////// MapObj::MapObj () { - // TODO not used any longer... - cout << "Const MapObj (): Please set canvas somehow!!!\n"; - // canvas=actMapEditor->getCanvas(); + //qWarning ( "Const MapObj (): Please set canvas somehow!!!"); + canvas=NULL; init (); } -MapObj::MapObj (QCanvas* c) +MapObj::MapObj (Q3Canvas* c) { // cout << "Const MapObj\n"; canvas=c; @@ -45,7 +45,7 @@ bbox.setSize (QSize(other->bbox.width(), other->bbox.height() ) ); } -QCanvas* MapObj::getCanvas() +Q3Canvas* MapObj::getCanvas() { return canvas; } @@ -70,6 +70,16 @@ return bbox.height(); } +QPoint MapObj::getAbsPos() +{ + return absPos; +} + +QString MapObj::getPos() +{ + return qpointToString(absPos); +} + void MapObj::move (double x, double y) { int xi=static_cast (x); @@ -77,18 +87,23 @@ absPos.setX( xi); absPos.setY( yi); bbox.moveTopLeft(QPoint(xi,yi)); + clickBox.moveTopLeft(QPoint(xi,yi)); } void MapObj::moveBy (double x, double y) { - move (x+absPos.x(),y+absPos.y() ); + int ix=(int)x; + int iy=(int)y; + MapObj::move (x+absPos.x(),y+absPos.y() ); + bbox.moveBy (ix,iy); + clickBox.moveBy (ix,iy); } -bool MapObj::inBBox(QPoint p) +bool MapObj::inBox(const QPoint &p) { - if (p.x() >= bbox.left() && p.x() <= bbox.right() - && p.y() <= bbox.bottom() && p.y() >= bbox.top() ) - return true; + if (p.x() >= clickBox.left() && p.x() <= clickBox.right() + && p.y() <= clickBox.bottom() && p.y() >= clickBox.top() ) + return true; return false; } @@ -98,7 +113,9 @@ } QRect MapObj::addBBox(QRect r1, QRect r2) -{ +{ + // Find smallest QRect containing given rectangles + QRect n; // Set left border if (r1.left() <= r2.left() ) @@ -141,3 +158,4 @@ { visible=v; } +