floatobj.cpp
author insilmaril
Thu, 22 Sep 2005 12:56:05 +0000
changeset 165 4244bcd9e6ea
parent 160 72cc3873306a
child 173 309609406650
permissions -rw-r--r--
fixed problem where note got lost by copying a branch
     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 }
    70 
    71 void FloatObj::setRelPos(const QPoint &p)
    72 {
    73 	relPos=p;
    74 }
    75 
    76 void FloatObj::setZ(const int &i)
    77 {
    78 	zPlane=i;
    79 }
    80 
    81 int FloatObj::z()
    82 {
    83 	return zPlane;
    84 }
    85 
    86 
    87 void FloatObj::setUseOrientation (const bool &b)
    88 {	
    89 	if (useOrientation!=b)
    90 	{
    91 		useOrientation=b;
    92 		requestReposition();
    93 	}	
    94 }
    95 
    96 void FloatObj::setFloatExport(const bool& b)
    97 {
    98 	floatExport=b;
    99 }
   100 
   101 bool FloatObj::getFloatExport()
   102 {
   103 	return floatExport;
   104 }
   105 
   106 void FloatObj::move (double x, double y)
   107 {
   108 	MapObj::move(x,y);
   109 	selbox->move(x,y);
   110 }
   111 
   112 void FloatObj::move (QPoint p)
   113 {
   114 	move (p.x(), p.y());
   115 }
   116 
   117 void FloatObj::reposition()
   118 {
   119 	if (useOrientation)
   120 	{
   121 		if (parObj->getOrientation()==OrientLeftOfCenter)
   122 			move (parObj->x() - relPos.x() + parObj->width() - bbox.width(), parObj->y()+relPos.y());
   123 		else	
   124 			move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
   125 	}		
   126 	else
   127 		move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
   128 	updateLink();	
   129 }
   130 
   131 QRect FloatObj::getTotalBBox()
   132 {
   133 	return bbox;
   134 }
   135 
   136 QRect FloatObj::getBBoxSizeWithChilds()
   137 {
   138 	return bboxTotal;
   139 }
   140 
   141 void FloatObj::select()
   142 {
   143     LinkableMapObj::select();
   144 	// Temporary draw the link while FO is selected
   145 	if (style==StyleUndef) 
   146 	{
   147 		setLinkStyle(getDefLinkStyle());
   148 		setLinkColor(parObj->getLinkColor());
   149 	}	
   150 
   151 	// Update FloatExport switch in context menu
   152 	if (floatExport)
   153 		actionEditToggleFloatExport->setEnabled (true);
   154 	else	
   155 		actionEditToggleFloatExport->setEnabled (true);
   156 
   157 
   158 }
   159 
   160 void FloatObj::unselect()
   161 {
   162 	LinkableMapObj::unselect();
   163 	setLinkStyle (StyleUndef);
   164 }
   165