mapcenterobj.cpp
author insilmaril
Tue, 26 May 2009 11:24:51 +0000
changeset 774 2f002657dada
parent 773 340bc29da9a0
permissions -rw-r--r--
added missing new files
     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() 
    23 {
    24 //    cout << "Destr MapCenterObj\n";
    25 	clear();
    26 }	
    27 
    28 void MapCenterObj::clear() 
    29 {
    30 	BranchObj::clear();
    31 }
    32 
    33 void MapCenterObj::init () 
    34 {
    35 	BranchObj::init();
    36     orientation=LinkableMapObj::UndefinedOrientation;
    37 
    38 	// TODO this should be done in TextObj later...
    39 	//QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
    40 	//heading->setFont(font);
    41 	//FIXME-2 no treeitem yet:  setDefAttr(MovedBranch); and already in BI::createMapObj ?!?
    42 
    43 	frame->setFrameType (FrameObj::Rectangle);
    44 }
    45 
    46 
    47 void MapCenterObj::updateLink()
    48 {
    49 	// set childPos to middle of MapCenterObj
    50 	childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
    51 	childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
    52 	parPos=childPos;		
    53 	for (int i=0; i<treeItem->branchCount(); ++i)
    54 		treeItem->getBranchObjNum(i)->updateLink();
    55 }
    56 
    57 void MapCenterObj::updateRelPositions()
    58 {
    59 	if (repositionRequest) unsetAllRepositionRequests();
    60 
    61 	// update relative Positions of branches and floats
    62 	for (int i=0; i<treeItem->branchCount(); ++i)
    63 	{
    64 		treeItem->getBranchObjNum(i)->setRelPos();
    65 		treeItem->getBranchObjNum(i)->setOrientation();
    66 	}
    67 	
    68 	for (int i=0; i<floatimage.size(); ++i)
    69 		floatimage.at(i)->setRelPos();
    70 
    71 	if (repositionRequest) reposition();
    72 }
    73