floatobj.cpp
author insilmaril
Thu, 16 Feb 2006 11:07:46 +0000
changeset 209 fdfb72def375
parent 173 309609406650
child 218 160459d924a1
permissions -rw-r--r--
copied new logo to _all_ icons
     1 #include "floatobj.h"
     2 
     3 extern QAction* actionEditToggleFloatExport;
     4 
     5 /////////////////////////////////////////////////////////////////
     6 // FloatObj
     7 /////////////////////////////////////////////////////////////////
     8 
     9 FloatObj::FloatObj ():LinkableMapObj() 
    10 {
    11 //    cout << "Const FloatObj ()\n";
    12     setParObj (this);	
    13     init();
    14     depth=-1;
    15 }
    16 
    17 FloatObj::FloatObj (QCanvas* c):LinkableMapObj(c)
    18 {
    19 //	cout << "Const FloatObj (c)  called from MapCenterObj (c)\n";
    20     setParObj (this);	
    21     init();
    22     depth=-1;
    23 }
    24 
    25 FloatObj::FloatObj (QCanvas* c, LinkableMapObj* p):LinkableMapObj (c)
    26 {
    27 //    cout << "Const FloatObj (c,p)\n";
    28     setParObj (p);	
    29     depth=p->getDepth()+1;
    30     init();
    31 }
    32 
    33 FloatObj::~FloatObj ()
    34 {
    35 //   cout << "Destr FloatObj\n";
    36 }
    37 
    38 void FloatObj::init () 
    39 {
    40     setChildObj(this);
    41 	relPos=getRandPos();
    42 	useOrientation=true;
    43 	floatExport=true;
    44 	zPlane=Z_ICON;
    45 	setLinkStyle (StyleParabel);
    46 	setHideLinkUnselected(true);
    47 }
    48 
    49 void FloatObj::copy (FloatObj* other)
    50 {
    51 	LinkableMapObj::copy (other);
    52 	relPos=other->relPos;
    53 	useOrientation=other->useOrientation;
    54 	setVisibility (other->visible);
    55 }
    56 
    57 void FloatObj::setRelPos()
    58 {
    59 	if (useOrientation)
    60 	{
    61 		if (parObj->getOrientation()==OrientLeftOfCenter)
    62 			relPos.setX ( parObj->x() +parObj->width() - bbox.width() -absPos.x());
    63 		else	
    64 			relPos.setX (absPos.x() - parObj->x() );
    65 	}
    66 	else
    67 		relPos.setX (absPos.x() - parObj->x() );
    68 	relPos.setY (absPos.y() - parObj->y() );
    69 	if (parObj)
    70 	{	
    71 		parObj->calcBBoxSize();
    72 		parObj->requestReposition();
    73 	}	
    74 }
    75 
    76 void FloatObj::setRelPos(const QPoint &p)
    77 {
    78 	relPos=p;
    79 	if (parObj)
    80 	{	parObj->calcBBoxSize();
    81 		parObj->requestReposition();
    82 	}	
    83 }
    84 
    85 QPoint FloatObj::getRelPos ()
    86 {
    87 	return relPos;
    88 }
    89 
    90 void FloatObj::setZ(const int &i)
    91 {
    92 	zPlane=i;
    93 }
    94 
    95 int FloatObj::z()
    96 {
    97 	return zPlane;
    98 }
    99 
   100 
   101 void FloatObj::setUseOrientation (const bool &b)
   102 {	
   103 	if (useOrientation!=b)
   104 	{
   105 		useOrientation=b;
   106 		requestReposition();
   107 	}	
   108 }
   109 
   110 void FloatObj::setFloatExport(const bool& b)
   111 {
   112 	floatExport=b;
   113 }
   114 
   115 bool FloatObj::getFloatExport()
   116 {
   117 	return floatExport;
   118 }
   119 
   120 void FloatObj::move (double x, double y)
   121 {
   122 	MapObj::move(x,y);
   123 	selbox->move(x,y);
   124 }
   125 
   126 void FloatObj::move (QPoint p)
   127 {
   128 	move (p.x(), p.y());
   129 }
   130 
   131 void FloatObj::reposition()
   132 {
   133 	if (useOrientation)
   134 	{
   135 		if (parObj->getOrientation()==OrientLeftOfCenter)
   136 			move (parObj->x() - relPos.x() + parObj->width() - bbox.width(), parObj->y()+relPos.y());
   137 		else	
   138 			move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
   139 	}		
   140 	else
   141 		move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
   142 	updateLink();	
   143 }
   144 
   145 QRect FloatObj::getTotalBBox()
   146 {
   147 	return bbox;
   148 }
   149 
   150 QRect FloatObj::getBBoxSizeWithChilds()
   151 {
   152 	return bboxTotal;
   153 }
   154 
   155 void FloatObj::select()
   156 {
   157     LinkableMapObj::select();
   158 	setLinkColor(parObj->getLinkColor());
   159 
   160 	// Update FloatExport switch in context menu
   161 	if (floatExport)
   162 		actionEditToggleFloatExport->setEnabled (true);
   163 	else	
   164 		actionEditToggleFloatExport->setEnabled (true);
   165 
   166 
   167 }
   168 
   169 void FloatObj::unselect()
   170 {
   171 	LinkableMapObj::unselect();
   172 }
   173