1.1 --- a/mapobj.cpp Tue Sep 05 09:47:14 2006 +0000
1.2 +++ b/mapobj.cpp Fri Dec 08 20:18:58 2006 +0000
1.3 @@ -6,15 +6,15 @@
1.4 /////////////////////////////////////////////////////////////////
1.5 MapObj::MapObj ()
1.6 {
1.7 - //qWarning ( "Const MapObj (): Please set canvas somehow!!!");
1.8 - canvas=NULL;
1.9 + //qWarning ( "Const MapObj (): Please set scene somehow!!!");
1.10 + scene=NULL;
1.11 init ();
1.12 }
1.13
1.14 -MapObj::MapObj (Q3Canvas* c)
1.15 +MapObj::MapObj (QGraphicsScene *s)
1.16 {
1.17 // cout << "Const MapObj\n";
1.18 - canvas=c;
1.19 + scene=s;
1.20 init ();
1.21 }
1.22
1.23 @@ -32,91 +32,101 @@
1.24
1.25 void MapObj::init ()
1.26 {
1.27 - absPos=QPoint(0,0);
1.28 + absPos=QPointF(0,0);
1.29 visible=true;
1.30 }
1.31
1.32 void MapObj::copy(MapObj* other)
1.33 {
1.34 -// canvas=other->canvas; // already set in constr. of child, use that one...
1.35 +// scene=other->scene; // already set in constr. of child, use that one...
1.36 absPos=other->absPos;
1.37 bbox.setX (other->bbox.x() );
1.38 bbox.setY (other->bbox.y() );
1.39 - bbox.setSize (QSize(other->bbox.width(), other->bbox.height() ) );
1.40 + bbox.setSize (QSizeF(other->bbox.width(), other->bbox.height() ) );
1.41 }
1.42
1.43 -Q3Canvas* MapObj::getCanvas()
1.44 +QGraphicsScene* MapObj::getScene()
1.45 {
1.46 - return canvas;
1.47 + return scene;
1.48 }
1.49
1.50 -int MapObj::x()
1.51 +qreal MapObj::x()
1.52 {
1.53 return absPos.x();
1.54 }
1.55
1.56 -int MapObj::y()
1.57 +qreal MapObj::y()
1.58 {
1.59 return absPos.y();
1.60 }
1.61
1.62 -int MapObj::width()
1.63 +qreal MapObj::width()
1.64 {
1.65 return bbox.width();
1.66 }
1.67
1.68 -int MapObj::height()
1.69 +qreal MapObj::height()
1.70 {
1.71 return bbox.height();
1.72 }
1.73
1.74 -QPoint MapObj::getAbsPos()
1.75 +QPointF MapObj::getAbsPos()
1.76 {
1.77 return absPos;
1.78 }
1.79
1.80 QString MapObj::getPos()
1.81 {
1.82 - return qpointToString(absPos);
1.83 + return qpointfToString(absPos);
1.84 }
1.85
1.86 void MapObj::move (double x, double y)
1.87 {
1.88 - int xi=static_cast <int> (x);
1.89 - int yi=static_cast <int> (y);
1.90 - absPos.setX( xi);
1.91 - absPos.setY( yi);
1.92 - bbox.moveTopLeft(QPoint(xi,yi));
1.93 - clickBox.moveTopLeft(QPoint(xi,yi));
1.94 + absPos.setX( x);
1.95 + absPos.setY( y);
1.96 + bbox.moveTo(QPointF(x,y));
1.97 + clickBox.moveTo(QPointF(x,y));
1.98 +}
1.99 +
1.100 +void MapObj::move (QPointF p)
1.101 +{
1.102 + absPos=p;
1.103 + bbox.moveTo (p);
1.104 + clickBox.moveTo (p);
1.105 }
1.106
1.107 void MapObj::moveBy (double x, double y)
1.108 {
1.109 - int ix=(int)x;
1.110 - int iy=(int)y;
1.111 MapObj::move (x+absPos.x(),y+absPos.y() );
1.112 - bbox.moveBy (ix,iy);
1.113 - clickBox.moveBy (ix,iy);
1.114 + bbox.moveTo (bbox.x()+x,bbox.y()+y);
1.115 + clickBox.moveTo (clickBox.x()+x,clickBox.y()+y);
1.116 }
1.117
1.118 -bool MapObj::inBox(const QPoint &p)
1.119 +bool MapObj::inBox(const QPointF &p)
1.120 {
1.121 +/* FIXME testing QT4 only
1.122 + cout << "MO::inBox "<<p<<" "<<
1.123 + clickBox.left()<<","<<
1.124 + clickBox.right()<<","<<
1.125 + clickBox.top()<<","<<
1.126 + clickBox.bottom()<<endl;
1.127 + */
1.128 if (p.x() >= clickBox.left() && p.x() <= clickBox.right()
1.129 && p.y() <= clickBox.bottom() && p.y() >= clickBox.top() )
1.130 return true;
1.131 return false;
1.132 }
1.133
1.134 -QRect MapObj::getBBox()
1.135 +QRectF MapObj::getBBox()
1.136 {
1.137 return bbox;
1.138 }
1.139
1.140 -QRect MapObj::addBBox(QRect r1, QRect r2)
1.141 +QRectF MapObj::addBBox(QRectF r1, QRectF r2)
1.142 {
1.143 - // Find smallest QRect containing given rectangles
1.144 + // Find smallest QRectF containing given rectangles
1.145
1.146 - QRect n;
1.147 + QRectF n;
1.148 // Set left border
1.149 if (r1.left() <= r2.left() )
1.150 n.setLeft(r1.left() );
1.151 @@ -143,7 +153,7 @@
1.152 return n;
1.153 }
1.154
1.155 -QSize MapObj::getSize()
1.156 +QSizeF MapObj::getSize()
1.157 {
1.158 return bbox.size();
1.159 }