mapobj.cpp
author insilmaril
Fri, 11 Jul 2008 12:36:39 +0000
changeset 715 c7f2d53c98d1
parent 692 c5e3cb54b9db
child 754 db0ec4bcf416
permissions -rw-r--r--
Fix for umlauts in paths
     1 #include "mapobj.h"
     2 #include "misc.h"
     3 
     4 /////////////////////////////////////////////////////////////////
     5 // MapObj
     6 /////////////////////////////////////////////////////////////////
     7 MapObj::MapObj ()
     8 {
     9 	//qWarning ( "Const MapObj (): Please set scene somehow!!!");
    10 	scene=NULL;
    11     init ();
    12 }
    13 
    14 MapObj::MapObj (QGraphicsScene *s)
    15 {
    16 //  cout << "Const MapObj\n";
    17     scene=s;
    18     init ();
    19 }
    20 
    21 
    22 MapObj::MapObj (MapObj* mo)
    23 {
    24 //    cout << "CopyConst MapObj\n";
    25     copy (mo);
    26 }
    27 
    28 MapObj::~MapObj ()
    29 {
    30 //    cout << "Destr MapObj\n";
    31 }
    32 
    33 void MapObj::init ()
    34 {
    35     absPos=QPointF(0,0);
    36     visible=true;
    37 }
    38 
    39 void MapObj::copy(MapObj* other)
    40 {
    41 //    scene=other->scene;	// already set in constr. of child, use that one...
    42     absPos=other->absPos;
    43 	bbox.setX (other->bbox.x() );
    44 	bbox.setY (other->bbox.y() );
    45 	bbox.setSize (QSizeF(other->bbox.width(), other->bbox.height() ) );
    46 }
    47 
    48 QGraphicsScene* MapObj::getScene()
    49 {
    50 	return scene;
    51 }
    52 
    53 qreal MapObj::x() 
    54 {
    55     return absPos.x();
    56 }
    57 
    58 qreal MapObj::y() 
    59 {
    60     return absPos.y();
    61 }
    62 
    63 qreal MapObj::width() 
    64 {
    65     return bbox.width();
    66 }
    67 
    68 qreal MapObj::height() 
    69 {
    70     return bbox.height();
    71 }
    72 
    73 QPointF MapObj::getAbsPos() 
    74 {
    75     return absPos;
    76 }
    77 
    78 QString MapObj::getPos()
    79 {
    80 	return qpointfToString(absPos);
    81 }
    82 
    83 void MapObj::move (double x, double y) 
    84 {
    85     absPos.setX( x);
    86     absPos.setY( y);
    87     bbox.moveTo(QPointF(x,y));
    88     clickBox.moveTo(QPointF(x,y));
    89 }
    90 
    91 void MapObj::move (QPointF p)
    92 {
    93 	absPos=p;
    94 	bbox.moveTo (p);
    95 	clickBox.moveTo (p);
    96 }
    97 
    98 void MapObj::moveBy (double x, double y) 
    99 {
   100     MapObj::move (x+absPos.x(),y+absPos.y() );
   101 	bbox.moveTo (bbox.x()+x,bbox.y()+y);
   102 	clickBox.moveTo (clickBox.x()+x,clickBox.y()+y);
   103 }
   104 
   105 QRectF MapObj::getBBox()
   106 {
   107     return bbox;
   108 }
   109 
   110 QRectF MapObj::getClickBox()
   111 {
   112     return clickBox;
   113 }
   114 
   115 
   116 QSizeF MapObj::getSize()
   117 {
   118     return bbox.size();
   119 }
   120 
   121 
   122 bool MapObj::isVisibleObj()
   123 {
   124     return visible;
   125 }
   126 
   127 void MapObj::setVisibility(bool v)
   128 {
   129     visible=v;
   130 }
   131