floatobj.cpp
author insilmaril
Wed, 06 May 2009 09:50:08 +0000
branchrelease-1-12-maintained
changeset 67 6c6aa8d5e9b6
parent 0 7a96bd401351
child 2 608f976aa7bb
child 160 72cc3873306a
permissions -rw-r--r--
Fixed wrong linenumber in error message of XML parser
     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 }
    46 
    47 void FloatObj::copy (FloatObj* other)
    48 {
    49 	LinkableMapObj::copy (other);
    50 	relPos=other->relPos;
    51 	useOrientation=other->useOrientation;
    52 	setVisibility (other->visible);
    53 }
    54 
    55 void FloatObj::setRelPos()
    56 {
    57 	if (useOrientation)
    58 	{
    59 		if (parObj->getOrientation()==OrientLeftOfCenter)
    60 			relPos.setX ( parObj->x() +parObj->width() - bbox.width() -absPos.x());
    61 		else	
    62 			relPos.setX (absPos.x() - parObj->x() );
    63 	}
    64 	else
    65 		relPos.setX (absPos.x() - parObj->x() );
    66 	relPos.setY (absPos.y() - parObj->y() );
    67 }
    68 
    69 void FloatObj::setRelPos(const QPoint &p)
    70 {
    71 	relPos=p;
    72 }
    73 
    74 void FloatObj::setZ(const int &i)
    75 {
    76 	zPlane=i;
    77 }
    78 
    79 int FloatObj::z()
    80 {
    81 	return zPlane;
    82 }
    83 
    84 
    85 void FloatObj::setUseOrientation (const bool &b)
    86 {	
    87 	if (useOrientation!=b)
    88 	{
    89 		useOrientation=b;
    90 		requestReposition();
    91 	}	
    92 }
    93 
    94 void FloatObj::setFloatExport(const bool& b)
    95 {
    96 	floatExport=b;
    97 }
    98 
    99 bool FloatObj::getFloatExport()
   100 {
   101 	return floatExport;
   102 }
   103 
   104 void FloatObj::move (double x, double y)
   105 {
   106 	MapObj::move(x,y);
   107 	selbox->move(x,y);
   108 }
   109 
   110 void FloatObj::move (QPoint p)
   111 {
   112 	move (p.x(), p.y());
   113 }
   114 
   115 void FloatObj::reposition()
   116 {
   117 	if (useOrientation)
   118 	{
   119 		if (parObj->getOrientation()==OrientLeftOfCenter)
   120 			move (parObj->x() - relPos.x() + parObj->width() - bbox.width(), parObj->y()+relPos.y());
   121 		else	
   122 			move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
   123 	}		
   124 	else
   125 		move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
   126 	updateLink();	
   127 }
   128 
   129 QRect FloatObj::getTotalBBox()
   130 {
   131 	return bbox;
   132 }
   133 
   134 QRect FloatObj::getBBoxSizeWithChilds()
   135 {
   136 	return bboxTotal;
   137 }
   138 
   139 void FloatObj::select()
   140 {
   141     LinkableMapObj::select();
   142 	// Temporary draw the link while FO is selected
   143 	if (style==StyleUndef) 
   144 	{
   145 		setLinkStyle(getDefLinkStyle());
   146 		setLinkColor(parObj->getLinkColor());
   147 	}	
   148 
   149 	// Update FloatExport switch in context menu
   150 	if (floatExport)
   151 		actionEditToggleFloatExport->setEnabled (true);
   152 	else	
   153 		actionEditToggleFloatExport->setEnabled (true);
   154 
   155 
   156 }
   157 
   158 void FloatObj::unselect()
   159 {
   160 	LinkableMapObj::unselect();
   161 	setLinkStyle (StyleUndef);
   162 }
   163