4 /////////////////////////////////////////////////////////////////
6 /////////////////////////////////////////////////////////////////
9 //qWarning ( "Const MapObj (): Please set canvas somehow!!!");
14 MapObj::MapObj (QCanvas* c)
16 // cout << "Const MapObj\n";
22 MapObj::MapObj (MapObj* mo)
24 // cout << "CopyConst MapObj\n";
30 // cout << "Destr MapObj\n";
39 void MapObj::copy(MapObj* other)
41 // canvas=other->canvas; // already set in constr. of child, use that one...
43 bbox.setX (other->bbox.x() );
44 bbox.setY (other->bbox.y() );
45 bbox.setSize (QSize(other->bbox.width(), other->bbox.height() ) );
48 QCanvas* MapObj::getCanvas()
73 QString MapObj::getPos()
75 return qpointToString(absPos);
78 void MapObj::move (double x, double y)
80 int xi=static_cast <int> (x);
81 int yi=static_cast <int> (y);
84 bbox.moveTopLeft(QPoint(xi,yi));
85 clickBox.moveTopLeft(QPoint(xi,yi));
88 void MapObj::moveBy (double x, double y)
92 move (x+absPos.x(),y+absPos.y() );
94 clickBox.moveBy (ix,iy);
97 bool MapObj::inBox(const QPoint &p)
99 if (p.x() >= clickBox.left() && p.x() <= clickBox.right()
100 && p.y() <= clickBox.bottom() && p.y() >= clickBox.top() )
105 QRect MapObj::getBBox()
110 QRect MapObj::addBBox(QRect r1, QRect r2)
112 // Find smallest QRect containing given rectangles
116 if (r1.left() <= r2.left() )
117 n.setLeft(r1.left() );
119 n.setLeft(r2.left() );
122 if (r1.top() <= r2.top() )
128 if (r1.right() <= r2.right() )
129 n.setRight(r2.right() );
131 n.setRight(r1.right() );
134 if (r1.bottom() <= r2.bottom() )
135 n.setBottom(r2.bottom() );
137 n.setBottom(r1.bottom() );
141 QSize MapObj::getSize()
147 bool MapObj::isVisibleObj()
152 void MapObj::setVisibility(bool v)