mapcenterobj.cpp
author insilmaril
Wed, 13 May 2009 08:26:27 +0000
changeset 767 6d2b32f305f9
parent 766 7a71a914afdb
child 773 340bc29da9a0
permissions -rw-r--r--
Started to use QtKinetic for Animation
     1 #include <QDateTime>
     2 
     3 #include "floatimageobj.h"
     4 #include "geometry.h"
     5 #include "mapcenterobj.h"
     6 
     7 /////////////////////////////////////////////////////////////////
     8 // MapCenterObj
     9 /////////////////////////////////////////////////////////////////
    10 MapCenterObj::MapCenterObj() : BranchObj ()
    11 {
    12 //    cout << "Const MapCenterObj\n";
    13     init();
    14 }
    15 
    16 MapCenterObj::MapCenterObj(QGraphicsScene* s) : BranchObj (s)
    17 {
    18 //    cout << "Const MapCenterObj   canvas="<<s<<"\n";
    19     init();
    20 }
    21 
    22 MapCenterObj::MapCenterObj(QGraphicsScene* s,VymModel *m) : BranchObj (s)
    23 {
    24 //    cout << "Const MapCenterObj   canvas="<<s<<"\n";
    25 	model=m;
    26     init();
    27 }
    28 
    29 MapCenterObj::~MapCenterObj() 
    30 {
    31 //    cout << "Destr MapCenterObj\n";
    32 	clear();
    33 }	
    34 
    35 void MapCenterObj::clear() 
    36 {
    37 	BranchObj::clear();
    38 }
    39 
    40 void MapCenterObj::init () 
    41 {
    42 	BranchObj::init();
    43     orientation=LinkableMapObj::UndefinedOrientation;
    44 
    45 	// TODO this should be done in TextObj later...
    46 	//QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
    47 	//heading->setFont(font);
    48 	//FIXME-2 no treeitem yet:  setDefAttr(MovedBranch);
    49 
    50 	frame->setFrameType (FrameObj::Rectangle);
    51 }
    52 
    53 void MapCenterObj::move (double x, double y)
    54 {
    55 	BranchObj::move(x,y);
    56 }
    57 
    58 void MapCenterObj::move (QPointF absPos)
    59 {
    60 	BranchObj::move(absPos);
    61 }
    62 
    63 void MapCenterObj::moveBy (double x, double y)
    64 {
    65 	BranchObj::moveBy(x,y);
    66 }
    67 
    68 void MapCenterObj::moveAll (double x, double y)
    69 {
    70 	// Get rel. position
    71 	double dx=x-absPos.x();
    72 	double dy=y-absPos.y();
    73 
    74 	// Move myself and branches
    75 	moveAllBy (dx,dy);
    76 }
    77 
    78 void MapCenterObj::moveAllBy (double dx, double dy)
    79 {
    80 	// Move myself and children
    81 	BranchObj::moveBy(dx,dy);
    82 }
    83 
    84 void MapCenterObj::updateLink()
    85 {
    86 	// set childPos to middle of MapCenterObj
    87 	childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
    88 	childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
    89 	parPos=childPos;		
    90 	for (int i=0; i<treeItem->branchCount(); ++i)
    91 		treeItem->getBranchObjNum(i)->updateLink();
    92 }
    93 
    94 void MapCenterObj::updateRelPositions()
    95 {
    96 	if (repositionRequest) unsetAllRepositionRequests();
    97 
    98 	// update relative Positions of branches and floats
    99 	for (int i=0; i<treeItem->branchCount(); ++i)
   100 	{
   101 		treeItem->getBranchObjNum(i)->setRelPos();
   102 		treeItem->getBranchObjNum(i)->setOrientation();
   103 	}
   104 	
   105 	for (int i=0; i<floatimage.size(); ++i)
   106 		floatimage.at(i)->setRelPos();
   107 
   108 	if (repositionRequest) reposition();
   109 }
   110