diff -r e95081c21da2 -r 81ffad43d53f mapobj.cpp --- a/mapobj.cpp Tue Sep 05 09:47:14 2006 +0000 +++ b/mapobj.cpp Fri Dec 08 20:18:58 2006 +0000 @@ -6,15 +6,15 @@ ///////////////////////////////////////////////////////////////// MapObj::MapObj () { - //qWarning ( "Const MapObj (): Please set canvas somehow!!!"); - canvas=NULL; + //qWarning ( "Const MapObj (): Please set scene somehow!!!"); + scene=NULL; init (); } -MapObj::MapObj (Q3Canvas* c) +MapObj::MapObj (QGraphicsScene *s) { // cout << "Const MapObj\n"; - canvas=c; + scene=s; init (); } @@ -32,91 +32,101 @@ void MapObj::init () { - absPos=QPoint(0,0); + absPos=QPointF(0,0); visible=true; } void MapObj::copy(MapObj* other) { -// canvas=other->canvas; // already set in constr. of child, use that one... +// scene=other->scene; // already set in constr. of child, use that one... absPos=other->absPos; bbox.setX (other->bbox.x() ); bbox.setY (other->bbox.y() ); - bbox.setSize (QSize(other->bbox.width(), other->bbox.height() ) ); + bbox.setSize (QSizeF(other->bbox.width(), other->bbox.height() ) ); } -Q3Canvas* MapObj::getCanvas() +QGraphicsScene* MapObj::getScene() { - return canvas; + return scene; } -int MapObj::x() +qreal MapObj::x() { return absPos.x(); } -int MapObj::y() +qreal MapObj::y() { return absPos.y(); } -int MapObj::width() +qreal MapObj::width() { return bbox.width(); } -int MapObj::height() +qreal MapObj::height() { return bbox.height(); } -QPoint MapObj::getAbsPos() +QPointF MapObj::getAbsPos() { return absPos; } QString MapObj::getPos() { - return qpointToString(absPos); + return qpointfToString(absPos); } void MapObj::move (double x, double y) { - int xi=static_cast (x); - int yi=static_cast (y); - absPos.setX( xi); - absPos.setY( yi); - bbox.moveTopLeft(QPoint(xi,yi)); - clickBox.moveTopLeft(QPoint(xi,yi)); + absPos.setX( x); + absPos.setY( y); + bbox.moveTo(QPointF(x,y)); + clickBox.moveTo(QPointF(x,y)); +} + +void MapObj::move (QPointF p) +{ + absPos=p; + bbox.moveTo (p); + clickBox.moveTo (p); } void MapObj::moveBy (double x, double 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); + bbox.moveTo (bbox.x()+x,bbox.y()+y); + clickBox.moveTo (clickBox.x()+x,clickBox.y()+y); } -bool MapObj::inBox(const QPoint &p) +bool MapObj::inBox(const QPointF &p) { +/* FIXME testing QT4 only + cout << "MO::inBox "<= clickBox.left() && p.x() <= clickBox.right() && p.y() <= clickBox.bottom() && p.y() >= clickBox.top() ) return true; return false; } -QRect MapObj::getBBox() +QRectF MapObj::getBBox() { return bbox; } -QRect MapObj::addBBox(QRect r1, QRect r2) +QRectF MapObj::addBBox(QRectF r1, QRectF r2) { - // Find smallest QRect containing given rectangles + // Find smallest QRectF containing given rectangles - QRect n; + QRectF n; // Set left border if (r1.left() <= r2.left() ) n.setLeft(r1.left() ); @@ -143,7 +153,7 @@ return n; } -QSize MapObj::getSize() +QSizeF MapObj::getSize() { return bbox.size(); }