mapobj.cpp
branchqt4-port
changeset 17 557239819c45
parent 0 7a96bd401351
     1.1 --- a/mapobj.cpp	Sun Jan 30 12:58:47 2005 +0000
     1.2 +++ b/mapobj.cpp	Wed Aug 30 12:16:25 2006 +0000
     1.3 @@ -1,17 +1,17 @@
     1.4  #include "mapobj.h"
     1.5 +#include "misc.h"
     1.6  
     1.7  /////////////////////////////////////////////////////////////////
     1.8  // MapObj
     1.9  /////////////////////////////////////////////////////////////////
    1.10  MapObj::MapObj ()
    1.11  {
    1.12 -	// TODO not used any longer...
    1.13 -	cout << "Const MapObj (): Please set canvas somehow!!!\n";
    1.14 -    // canvas=actMapEditor->getCanvas();
    1.15 +	//qWarning ( "Const MapObj (): Please set canvas somehow!!!");
    1.16 +	canvas=NULL;
    1.17      init ();
    1.18  }
    1.19  
    1.20 -MapObj::MapObj (QCanvas* c)
    1.21 +MapObj::MapObj (Q3Canvas* c)
    1.22  {
    1.23  //  cout << "Const MapObj\n";
    1.24      canvas=c;
    1.25 @@ -45,7 +45,7 @@
    1.26  	bbox.setSize (QSize(other->bbox.width(), other->bbox.height() ) );
    1.27  }
    1.28  
    1.29 -QCanvas* MapObj::getCanvas()
    1.30 +Q3Canvas* MapObj::getCanvas()
    1.31  {
    1.32  	return canvas;
    1.33  }
    1.34 @@ -70,6 +70,16 @@
    1.35      return bbox.height();
    1.36  }
    1.37  
    1.38 +QPoint MapObj::getAbsPos() 
    1.39 +{
    1.40 +    return absPos;
    1.41 +}
    1.42 +
    1.43 +QString MapObj::getPos()
    1.44 +{
    1.45 +	return qpointToString(absPos);
    1.46 +}
    1.47 +
    1.48  void MapObj::move (double x, double y) 
    1.49  {
    1.50      int xi=static_cast <int> (x);
    1.51 @@ -77,18 +87,23 @@
    1.52      absPos.setX( xi);
    1.53      absPos.setY( yi);
    1.54      bbox.moveTopLeft(QPoint(xi,yi));
    1.55 +    clickBox.moveTopLeft(QPoint(xi,yi));
    1.56  }
    1.57  
    1.58  void MapObj::moveBy (double x, double y) 
    1.59  {
    1.60 -    move (x+absPos.x(),y+absPos.y() );
    1.61 +	int ix=(int)x;
    1.62 +	int iy=(int)y;
    1.63 +    MapObj::move (x+absPos.x(),y+absPos.y() );
    1.64 +	bbox.moveBy (ix,iy);
    1.65 +	clickBox.moveBy (ix,iy);
    1.66  }
    1.67  
    1.68 -bool MapObj::inBBox(QPoint p)
    1.69 +bool MapObj::inBox(const QPoint &p)
    1.70  {
    1.71 -    if (p.x() >= bbox.left() && p.x() <= bbox.right()  
    1.72 -	&& p.y() <= bbox.bottom() && p.y() >= bbox.top() )
    1.73 -	return true;
    1.74 +    if (p.x() >= clickBox.left() && p.x() <= clickBox.right()  
    1.75 +	&& p.y() <= clickBox.bottom() && p.y() >= clickBox.top() )
    1.76 +		return true;
    1.77      return false;	
    1.78  }
    1.79  
    1.80 @@ -98,7 +113,9 @@
    1.81  }
    1.82  
    1.83  QRect MapObj::addBBox(QRect r1, QRect r2)
    1.84 -{
    1.85 +{	
    1.86 +	// Find smallest QRect containing given rectangles
    1.87 +
    1.88  	QRect n;
    1.89  	// Set left border
    1.90  	if (r1.left() <= r2.left() )
    1.91 @@ -141,3 +158,4 @@
    1.92  {
    1.93      visible=v;
    1.94  }
    1.95 +