branchobj.cpp
author insilmaril
Sat, 08 Aug 2009 21:58:26 +0000
changeset 787 c6bb4fdcc55f
parent 786 6269016c9905
child 788 78ba80b54bc4
permissions -rw-r--r--
Fixed selections with cursor in MapEditor
insilmaril@0
     1
#include "branchobj.h"
insilmaril@616
     2
insilmaril@749
     3
#include "branchitem.h"
insilmaril@643
     4
#include "geometry.h"
insilmaril@0
     5
#include "mapeditor.h"
insilmaril@0
     6
#include "mainwindow.h"
insilmaril@616
     7
#include "misc.h"
insilmaril@616
     8
insilmaril@767
     9
extern FlagRow *standardFlagsMaster;
insilmaril@767
    10
extern FlagRow *systemFlagsMaster;
insilmaril@0
    11
insilmaril@0
    12
/////////////////////////////////////////////////////////////////
insilmaril@0
    13
// BranchObj
insilmaril@0
    14
/////////////////////////////////////////////////////////////////
insilmaril@0
    15
insilmaril@746
    16
BranchObj::BranchObj () :OrnamentedObj()	// FIXME-3 needed at all?
insilmaril@0
    17
{
insilmaril@0
    18
//    cout << "Const BranchObj ()\n";
insilmaril@0
    19
    setParObj (this);	
insilmaril@0
    20
    init();
insilmaril@0
    21
}
insilmaril@0
    22
insilmaril@755
    23
BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s)// FIXME-3 needed at all?
insilmaril@0
    24
{
insilmaril@755
    25
//    cout << "Const BranchObj (s)  \n";
insilmaril@83
    26
	parObj=NULL;
insilmaril@408
    27
    scene=s;
insilmaril@755
    28
	init();
insilmaril@0
    29
}
insilmaril@0
    30
insilmaril@755
    31
BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s)// FIXME-3 needed at all?
insilmaril@0
    32
{
insilmaril@408
    33
//    cout << "Const BranchObj (s,p)\n";
insilmaril@408
    34
    scene=s;
insilmaril@0
    35
    setParObj (p);	
insilmaril@773
    36
	if (treeItem->depth()==1)	// FIXME-3 needed to recursively calc depth?
insilmaril@0
    37
		// Calc angle to mapCenter if I am a mainbranch
insilmaril@0
    38
		// needed for reordering the mainbranches clockwise 
insilmaril@0
    39
		// around mapcenter 
insilmaril@408
    40
		angle=getAngle (QPointF (x() - parObj->getChildPos().x() , 
insilmaril@408
    41
								(y() - parObj->getChildPos().y() ) ) );
insilmaril@0
    42
    init();
insilmaril@0
    43
}
insilmaril@0
    44
insilmaril@0
    45
BranchObj::~BranchObj ()
insilmaril@0
    46
{
insilmaril@757
    47
//	cout << "Destr BranchObj of "<<this<<" ("<<treeItem->getHeading().toStdString()<<")"<<endl;
insilmaril@757
    48
insilmaril@722
    49
	// If I'm animated, I need to un-animate myself first
insilmaril@722
    50
	if (anim.isAnimated() )
insilmaril@722
    51
	{
insilmaril@722
    52
		anim.setAnimated (false);
insilmaril@773
    53
		VymModel *model=treeItem->getModel();
insilmaril@722
    54
		model->stopAnimation (this);
insilmaril@722
    55
	}
insilmaril@722
    56
insilmaril@0
    57
	// Check, if this branch was the last child to be deleted
insilmaril@749
    58
	// If so, unset the scrolled flags in parent // FIXME-2 better do this in model?
insilmaril@0
    59
insilmaril@749
    60
	/*
insilmaril@425
    61
	BranchObj *po=(BranchObj*)parObj;
insilmaril@83
    62
	BranchObj *bo;
insilmaril@0
    63
	if (po)
insilmaril@0
    64
	{
insilmaril@425
    65
		bo=((BranchObj*)parObj)->getLastBranch();
insilmaril@425
    66
		if (bo) po->unScroll();
insilmaril@0
    67
	}
insilmaril@749
    68
	*/
insilmaril@83
    69
	clear();
insilmaril@0
    70
}
insilmaril@0
    71
insilmaril@0
    72
bool BranchObj::operator< ( const BranchObj & other )
insilmaril@0
    73
{
insilmaril@0
    74
    return  angle < other.angle;
insilmaril@0
    75
}
insilmaril@0
    76
insilmaril@0
    77
bool BranchObj::operator== ( const BranchObj & other )
insilmaril@0
    78
{
insilmaril@0
    79
    return angle == other.angle;
insilmaril@0
    80
}
insilmaril@0
    81
insilmaril@0
    82
void BranchObj::init () 
insilmaril@0
    83
{
insilmaril@83
    84
	if (parObj)
insilmaril@83
    85
	{
insilmaril@83
    86
		absPos=getRandPos();
insilmaril@83
    87
		absPos+=parObj->getChildPos();
insilmaril@83
    88
	}
insilmaril@0
    89
}
insilmaril@0
    90
insilmaril@0
    91
void BranchObj::copy (BranchObj* other)
insilmaril@0
    92
{
insilmaril@0
    93
    OrnamentedObj::copy(other);
insilmaril@0
    94
insilmaril@0
    95
	setVisibility (other->visible);
insilmaril@0
    96
insilmaril@0
    97
	angle=other->angle;
insilmaril@0
    98
insilmaril@0
    99
    positionBBox();
insilmaril@0
   100
}
insilmaril@0
   101
insilmaril@0
   102
void BranchObj::clear() 
insilmaril@0
   103
{
insilmaril@755
   104
	//setVisibility (true); //FIXME-4 needed?
insilmaril@425
   105
insilmaril@95
   106
	while (!xlink.isEmpty())
insilmaril@406
   107
		delete xlink.takeFirst();
insilmaril@0
   108
}
insilmaril@0
   109
insilmaril@411
   110
bool isAbove (BranchObj* a, BranchObj *b)
insilmaril@411
   111
{
insilmaril@411
   112
	if (a->angle < b->angle)
insilmaril@411
   113
		return true;
insilmaril@411
   114
	else	
insilmaril@411
   115
		return false;
insilmaril@411
   116
}
insilmaril@411
   117
insilmaril@408
   118
void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off)
insilmaril@0
   119
{
insilmaril@0
   120
	// Temporary link to lmo
insilmaril@0
   121
	// m is position of mouse pointer 
insilmaril@0
   122
	// offset 0: default 1: below lmo   -1 above lmo  (if possible)
insilmaril@0
   123
insilmaril@775
   124
	BranchItem *pi=(BranchItem*)(lmo->getTreeItem()->parent());
insilmaril@775
   125
	int pi_depth=pi->depth();
insilmaril@0
   126
	BranchObj* o=(BranchObj*)(lmo);
insilmaril@0
   127
	if (!parObjTmpBuf) 
insilmaril@0
   128
		parObjTmpBuf=parObj;
insilmaril@0
   129
insilmaril@786
   130
	// ignore mapcenter and mainbranch	//FIXME-3 MCO meanwhile also could be relinked
insilmaril@775
   131
	if (pi_depth<2) off=0;
insilmaril@0
   132
	if (off==0)
insilmaril@0
   133
		link2ParPos=false;
insilmaril@0
   134
	else
insilmaril@0
   135
		link2ParPos=true;
insilmaril@93
   136
	parObj=o;
insilmaril@0
   137
insilmaril@779
   138
	// setLinkStyle calls updateLinkGeometry, only set it once
insilmaril@786
   139
	//LinkableMapObj::Style ls=getDefLinkStyle (lmo->getTreeItem() );
insilmaril@786
   140
	//if (style!=ls ) setLinkStyle (ls);
insilmaril@786
   141
	setLinkStyle (lmo->getDefLinkStyle (lmo->getTreeItem()));
insilmaril@0
   142
insilmaril@0
   143
	// Move temporary to new position at destination
insilmaril@0
   144
	// Usually the positioning would be done by reposition(),
insilmaril@0
   145
	// but then also the destination branch would "Jump" around...
insilmaril@0
   146
	// Better just do it approximately
insilmaril@786
   147
	if (parObj->getTreeItem()->depth()==0)	
insilmaril@786
   148
	{	// new parent is a mapcenter
insilmaril@0
   149
insilmaril@408
   150
		QPointF p= normalise ( QPointF (m.x() - o->getChildPos().x(),
insilmaril@0
   151
									  m.y() - o->getChildPos().y() ));
insilmaril@0
   152
		if (p.x()<0) p.setX( p.x()-bbox.width() );
insilmaril@0
   153
		move2RelPos (p);
insilmaril@0
   154
	} else
insilmaril@0
   155
	{	
insilmaril@408
   156
		qreal y;
insilmaril@0
   157
		if (off==0)
insilmaril@0
   158
		{
insilmaril@0
   159
			// new parent is just a branch, link to it
insilmaril@721
   160
			QRectF t=o->getBBoxSizeWithChildren();
insilmaril@750
   161
			if (o->getTreeItem()->getLastBranch())
insilmaril@0
   162
				y=t.y() + t.height() ;
insilmaril@0
   163
			else
insilmaril@0
   164
				y=t.y();
insilmaril@0
   165
insilmaril@0
   166
		} else
insilmaril@0
   167
		{
insilmaril@0
   168
			if (off<0)
insilmaril@0
   169
				// we want to link above lmo
insilmaril@0
   170
				y=o->y() - height() + 5;
insilmaril@0
   171
			else	
insilmaril@0
   172
				// we want to link below lmo
insilmaril@0
   173
				// Bottom of sel should be 5 pixels above
insilmaril@0
   174
				// the bottom of the branch _below_ the target:
insilmaril@0
   175
				// Don't try to find that branch, guess 12 pixels
insilmaril@0
   176
				y=o->getChildPos().y()  -height() + 12; 
insilmaril@0
   177
		}	
insilmaril@462
   178
		if (o->getOrientation()==LinkableMapObj::LeftOfCenter)
insilmaril@0
   179
			move ( o->getChildPos().x() - linkwidth, y );
insilmaril@0
   180
		else	
insilmaril@0
   181
			move (o->getChildPos().x() + linkwidth, y );
insilmaril@0
   182
	}	
insilmaril@0
   183
insilmaril@779
   184
	// updateLinkGeometry is called implicitly in move
insilmaril@417
   185
	requestReposition();	
insilmaril@0
   186
}
insilmaril@0
   187
insilmaril@0
   188
void BranchObj::unsetParObjTmp()
insilmaril@0
   189
{
insilmaril@0
   190
	if (parObjTmpBuf) 
insilmaril@0
   191
	{
insilmaril@0
   192
		link2ParPos=false;
insilmaril@0
   193
		parObj=parObjTmpBuf;
insilmaril@0
   194
		parObjTmpBuf=NULL;
insilmaril@786
   195
		setLinkStyle (getDefLinkStyle(treeItem->parent() ) );
insilmaril@779
   196
		updateLinkGeometry();
insilmaril@0
   197
	}		
insilmaril@0
   198
}
insilmaril@0
   199
insilmaril@0
   200
void BranchObj::setVisibility(bool v, int toDepth)
insilmaril@0
   201
{
insilmaril@749
   202
	BranchItem *bi=(BranchItem*)treeItem;
insilmaril@755
   203
    if (bi->depth() <= toDepth)
insilmaril@0
   204
    {
insilmaril@0
   205
		frame->setVisibility(v);
insilmaril@0
   206
		heading->setVisibility(v);
insilmaril@0
   207
		systemFlags->setVisibility(v);
insilmaril@0
   208
		standardFlags->setVisibility(v);
insilmaril@0
   209
		LinkableMapObj::setVisibility (v);
insilmaril@730
   210
		int i;
insilmaril@785
   211
		for (i=0; i<treeItem->imageCount(); ++i)
insilmaril@785
   212
			treeItem->getImageObjNum(i)->setVisibility (v);
insilmaril@730
   213
		for (i=0; i<xlink.size(); ++i)	
insilmaril@730
   214
			xlink.at(i)->setVisibility ();	
insilmaril@730
   215
insilmaril@721
   216
		// Only change children, if I am not scrolled
insilmaril@749
   217
		if (! bi->isScrolled() && (bi->depth() < toDepth))
insilmaril@0
   218
		{
insilmaril@785
   219
			// Now go recursivly through all children //FIXME-3 are there multiple calls for lower level items???
insilmaril@750
   220
			for (i=0; i<treeItem->branchCount(); ++i)
insilmaril@753
   221
				treeItem->getBranchObjNum(i)->setVisibility (v,toDepth);	
insilmaril@0
   222
		}
insilmaril@0
   223
    } // depth <= toDepth	
insilmaril@0
   224
	requestReposition();
insilmaril@0
   225
}	
insilmaril@0
   226
insilmaril@0
   227
void BranchObj::setVisibility(bool v)
insilmaril@0
   228
{
insilmaril@0
   229
    setVisibility (v,MAX_DEPTH);
insilmaril@0
   230
}
insilmaril@0
   231
insilmaril@0
   232
insilmaril@0
   233
void BranchObj::setLinkColor ()
insilmaril@0
   234
{
insilmaril@0
   235
	// Overloaded from LinkableMapObj
insilmaril@0
   236
	// BranchObj can use color of heading
insilmaril@0
   237
insilmaril@773
   238
	VymModel *model=treeItem->getModel();
insilmaril@721
   239
	if (model)
insilmaril@611
   240
	{
insilmaril@721
   241
		if (model->getMapLinkColorHint()==HeadingColor)
insilmaril@164
   242
			LinkableMapObj::setLinkColor (heading->getColor() );
insilmaril@164
   243
		else	
insilmaril@164
   244
			LinkableMapObj::setLinkColor ();
insilmaril@611
   245
	}		
insilmaril@0
   246
}
insilmaril@0
   247
insilmaril@753
   248
void BranchObj::updateContentSize()
insilmaril@753
   249
{
insilmaril@753
   250
	calcBBoxSize();
insilmaril@753
   251
	positionBBox();
insilmaril@753
   252
	requestReposition();
insilmaril@100
   253
}
insilmaril@0
   254
insilmaril@333
   255
void BranchObj::positionContents()
insilmaril@333
   256
{
insilmaril@785
   257
	for (int i=0; i<treeItem->imageCount(); ++i)
insilmaril@785
   258
		treeItem->getImageObjNum(i)->reposition();
insilmaril@333
   259
	OrnamentedObj::positionContents();
insilmaril@333
   260
}
insilmaril@0
   261
insilmaril@0
   262
void BranchObj::move (double x, double y)
insilmaril@0
   263
{
insilmaril@0
   264
	OrnamentedObj::move (x,y);
insilmaril@776
   265
	FloatImageObj *fio;
insilmaril@776
   266
    for (int i=0; i<treeItem->imageCount(); ++i )
insilmaril@776
   267
	{
insilmaril@776
   268
		fio=treeItem->getImageObjNum(i);
insilmaril@776
   269
		if (fio) fio->reposition();
insilmaril@776
   270
	}
insilmaril@0
   271
    positionBBox();
insilmaril@0
   272
}
insilmaril@0
   273
insilmaril@408
   274
void BranchObj::move (QPointF p)
insilmaril@0
   275
{
insilmaril@0
   276
	move (p.x(), p.y());
insilmaril@0
   277
}
insilmaril@0
   278
insilmaril@0
   279
void BranchObj::moveBy (double x, double y)
insilmaril@0
   280
{
insilmaril@0
   281
	OrnamentedObj::moveBy (x,y);
insilmaril@750
   282
	for (int i=0; i<treeItem->branchCount(); ++i)
insilmaril@753
   283
		treeItem->getBranchObjNum(i)->moveBy (x,y);
insilmaril@333
   284
    positionBBox();
insilmaril@0
   285
}
insilmaril@83
   286
	
insilmaril@408
   287
void BranchObj::moveBy (QPointF p)
insilmaril@0
   288
{
insilmaril@0
   289
	moveBy (p.x(), p.y());
insilmaril@0
   290
}
insilmaril@0
   291
insilmaril@0
   292
insilmaril@0
   293
void BranchObj::positionBBox()
insilmaril@0
   294
{
insilmaril@408
   295
	QPointF ap=getAbsPos();
insilmaril@223
   296
	bbox.moveTopLeft (ap);
insilmaril@169
   297
	positionContents();
insilmaril@0
   298
insilmaril@0
   299
	// set the frame
insilmaril@408
   300
	frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
insilmaril@83
   301
insilmaril@83
   302
	// Update links to other branches
insilmaril@406
   303
	for (int i=0; i<xlink.size(); ++i)
insilmaril@406
   304
		xlink.at(i)->updateXLink();
insilmaril@0
   305
}
insilmaril@0
   306
insilmaril@0
   307
void BranchObj::calcBBoxSize()
insilmaril@0
   308
{
insilmaril@408
   309
    QSizeF heading_r=heading->getSize();
insilmaril@408
   310
    qreal heading_w=(qreal) heading_r.width() ;
insilmaril@408
   311
    qreal heading_h=(qreal) heading_r.height() ;
insilmaril@767
   312
    QSizeF sysflags_r=systemFlags->getSize();
insilmaril@767
   313
	qreal sysflags_h=sysflags_r.height();
insilmaril@767
   314
	qreal sysflags_w=sysflags_r.width();
insilmaril@767
   315
    QSizeF stanflags_r=standardFlags->getSize();
insilmaril@767
   316
	qreal stanflags_h=stanflags_r.height();
insilmaril@767
   317
	qreal stanflags_w=stanflags_r.width();
insilmaril@408
   318
    qreal w;
insilmaril@408
   319
    qreal h;
insilmaril@0
   320
insilmaril@0
   321
	// set width to sum of all widths
insilmaril@0
   322
	w=heading_w + sysflags_w + stanflags_w;
insilmaril@0
   323
	// set height to maximum needed height
insilmaril@0
   324
	h=max (sysflags_h,stanflags_h);
insilmaril@0
   325
	h=max (h,heading_h);
insilmaril@0
   326
insilmaril@223
   327
	// Save the dimension of flags and heading
insilmaril@408
   328
	ornamentsBBox.setSize ( QSizeF(w,h));
insilmaril@223
   329
insilmaril@223
   330
	// clickBox includes Flags and Heading
insilmaril@223
   331
    clickBox.setSize (ornamentsBBox.size() );
insilmaril@169
   332
insilmaril@169
   333
	// Floatimages 
insilmaril@408
   334
	QPointF rp;
insilmaril@169
   335
insilmaril@169
   336
	topPad=botPad=leftPad=rightPad=0;
insilmaril@785
   337
	bool incV=((BranchItem*)treeItem)->getIncludeImagesVer();
insilmaril@785
   338
	bool incH=((BranchItem*)treeItem)->getIncludeImagesHor();
insilmaril@785
   339
	if (incH || incV)
insilmaril@169
   340
	{
insilmaril@785
   341
		FloatImageObj *fio;
insilmaril@785
   342
		for (int i=0; i<treeItem->imageCount(); ++i )	
insilmaril@169
   343
		{
insilmaril@785
   344
			fio=treeItem->getImageObjNum(i);
insilmaril@785
   345
			rp=fio->getRelPos();
insilmaril@785
   346
			if (incV)
insilmaril@169
   347
			{
insilmaril@785
   348
				if (rp.y() < 0) 
insilmaril@785
   349
					topPad=max (topPad,-rp.y()-h);
insilmaril@785
   350
				if (rp.y()+fio->height() > 0)
insilmaril@785
   351
					botPad=max (botPad,rp.y()+fio->height());
insilmaril@785
   352
			}		
insilmaril@785
   353
			if (incH)
insilmaril@785
   354
			{
insilmaril@785
   355
				if (orientation==LinkableMapObj::RightOfCenter)
insilmaril@169
   356
				{
insilmaril@785
   357
					if (-rp.x()-w > 0) 
insilmaril@785
   358
						leftPad=max (leftPad,-rp.x()-w);
insilmaril@785
   359
					if (rp.x()+fio->width() > 0)
insilmaril@785
   360
						rightPad=max (rightPad,rp.x()+fio->width());
insilmaril@785
   361
				} else
insilmaril@213
   362
				{
insilmaril@785
   363
					if (rp.x()< 0) 
insilmaril@785
   364
						leftPad=max (leftPad,-rp.x());
insilmaril@785
   365
					if (rp.x()+fio->width() > w)
insilmaril@785
   366
						rightPad=max (rightPad,rp.x()+fio->width()-w);
insilmaril@785
   367
				}
insilmaril@785
   368
			}		
insilmaril@169
   369
		}	
insilmaril@169
   370
		h+=topPad+botPad;
insilmaril@213
   371
		w+=leftPad+rightPad;
insilmaril@169
   372
	}
insilmaril@169
   373
insilmaril@169
   374
	// Frame thickness
insilmaril@462
   375
    w+=frame->getPadding();
insilmaril@462
   376
    h+=frame->getPadding();
insilmaril@169
   377
	
insilmaril@169
   378
	// Finally set size
insilmaril@408
   379
    bbox.setSize (QSizeF (w,h));
insilmaril@0
   380
}
insilmaril@0
   381
insilmaril@223
   382
void BranchObj::setDockPos()
insilmaril@223
   383
{
insilmaril@775
   384
	if (treeItem->getType()==TreeItem::MapCenter)
insilmaril@775
   385
	{
insilmaril@775
   386
		// set childPos to middle of MapCenterObj
insilmaril@775
   387
		childPos.setX( clickBox.topLeft().x() + clickBox.width()/2 );
insilmaril@775
   388
		childPos.setY( clickBox.topLeft().y() + clickBox.height()/2 );
insilmaril@775
   389
		parPos=childPos;		
insilmaril@775
   390
		for (int i=0; i<treeItem->branchCount(); ++i)
insilmaril@779
   391
			treeItem->getBranchObjNum(i)->updateLinkGeometry();
insilmaril@775
   392
insilmaril@775
   393
	} else
insilmaril@775
   394
	{
insilmaril@775
   395
		// Sets childpos and parpos depending on orientation
insilmaril@775
   396
		if (getOrientation()==LinkableMapObj::LeftOfCenter )
insilmaril@775
   397
		{
insilmaril@775
   398
			childPos=QPointF (
insilmaril@775
   399
				ornamentsBBox.bottomLeft().x(), 
insilmaril@775
   400
				bottomlineY);
insilmaril@775
   401
			parPos=QPointF (
insilmaril@775
   402
				ornamentsBBox.bottomRight().x(),
insilmaril@775
   403
				bottomlineY);
insilmaril@775
   404
		} else
insilmaril@775
   405
		{
insilmaril@775
   406
			childPos=QPointF (
insilmaril@775
   407
				ornamentsBBox.bottomRight().x(), 
insilmaril@775
   408
				bottomlineY);
insilmaril@775
   409
			parPos=QPointF (
insilmaril@775
   410
				ornamentsBBox.bottomLeft().x(),
insilmaril@775
   411
				bottomlineY);
insilmaril@775
   412
		}
insilmaril@775
   413
	}
insilmaril@223
   414
}
insilmaril@382
   415
insilmaril@767
   416
void BranchObj::updateData()
insilmaril@0
   417
{
insilmaril@767
   418
	bool changed=false;
insilmaril@753
   419
	if (!treeItem)
insilmaril@254
   420
	{
insilmaril@753
   421
		qWarning ("BranchObj::udpateHeading treeItem==NULL");
insilmaril@753
   422
		return;
insilmaril@753
   423
	}
insilmaril@767
   424
	QString s=treeItem->getHeading();
insilmaril@767
   425
	if (s!=heading->text())
insilmaril@767
   426
	{
insilmaril@767
   427
		heading->setText (s);
insilmaril@767
   428
		changed=true;
insilmaril@767
   429
	}
insilmaril@767
   430
	QStringList TIactiveFlags=treeItem->activeStandardFlagNames();
insilmaril@767
   431
insilmaril@767
   432
	// Add missing standard flags active in TreeItem
insilmaril@767
   433
	for (int i=0;i<=TIactiveFlags.size()-1;i++)
insilmaril@767
   434
	{	
insilmaril@767
   435
		if (!standardFlags->isActive (TIactiveFlags.at(i) ))
insilmaril@767
   436
		{
insilmaril@767
   437
			Flag *f=standardFlagsMaster->getFlag(TIactiveFlags.at(i));
insilmaril@767
   438
			if (f) standardFlags->activate (f);
insilmaril@767
   439
			changed=true;
insilmaril@767
   440
		}
insilmaril@767
   441
	}
insilmaril@767
   442
	// Remove standard flags no longer active in TreeItem
insilmaril@767
   443
	QStringList BOactiveFlags=standardFlags->activeFlagNames();
insilmaril@767
   444
	for (int i=0;i<BOactiveFlags.size();++i)
insilmaril@767
   445
		if (!TIactiveFlags.contains (BOactiveFlags.at(i)))
insilmaril@767
   446
		{
insilmaril@767
   447
			standardFlags->deactivate (BOactiveFlags.at(i));
insilmaril@767
   448
			changed=true;
insilmaril@767
   449
		}	
insilmaril@767
   450
insilmaril@767
   451
	// Add missing system flags active in TreeItem
insilmaril@767
   452
	TIactiveFlags=treeItem->activeSystemFlagNames();
insilmaril@767
   453
	for (int i=0;i<TIactiveFlags.size();++i)
insilmaril@767
   454
	{	
insilmaril@767
   455
		if (!systemFlags->isActive (TIactiveFlags.at(i) ))
insilmaril@767
   456
		{
insilmaril@767
   457
			Flag *f=systemFlagsMaster->getFlag(TIactiveFlags.at(i));
insilmaril@767
   458
			if (f) systemFlags->activate (f);
insilmaril@767
   459
			changed=true;
insilmaril@767
   460
		}
insilmaril@767
   461
	}
insilmaril@767
   462
	// Remove system flags no longer active in TreeItem
insilmaril@767
   463
	BOactiveFlags=systemFlags->activeFlagNames();
insilmaril@767
   464
	for (int i=0;i<BOactiveFlags.size();++i)
insilmaril@767
   465
	{
insilmaril@767
   466
		if (!TIactiveFlags.contains (BOactiveFlags.at(i)))
insilmaril@767
   467
		{
insilmaril@767
   468
			systemFlags->deactivate (BOactiveFlags.at(i));
insilmaril@767
   469
			changed=true;
insilmaril@767
   470
		}	
insilmaril@767
   471
	}
insilmaril@785
   472
	updateContentSize();
insilmaril@254
   473
}
insilmaril@254
   474
insilmaril@0
   475
insilmaril@95
   476
void BranchObj::addXLink (XLinkObj *xlo)
insilmaril@83
   477
{
insilmaril@95
   478
	xlink.append (xlo);
insilmaril@83
   479
	
insilmaril@83
   480
}
insilmaril@83
   481
insilmaril@95
   482
void BranchObj::removeXLinkRef (XLinkObj *xlo)
insilmaril@83
   483
{
insilmaril@406
   484
	xlink.removeAt (xlink.indexOf(xlo));
insilmaril@83
   485
}
insilmaril@83
   486
insilmaril@95
   487
void BranchObj::deleteXLink(XLinkObj *xlo)
insilmaril@83
   488
{
insilmaril@95
   489
	xlo->deactivate();
insilmaril@95
   490
	if (!xlo->isUsed()) delete (xlo);
insilmaril@83
   491
}
insilmaril@83
   492
insilmaril@95
   493
void BranchObj::deleteXLinkAt (int i)
insilmaril@94
   494
{
insilmaril@95
   495
	XLinkObj *xlo=xlink.at(i);
insilmaril@95
   496
	xlo->deactivate();
insilmaril@95
   497
	if (!xlo->isUsed()) delete(xlo);
insilmaril@94
   498
}
insilmaril@94
   499
insilmaril@97
   500
XLinkObj* BranchObj::XLinkAt (int i)
insilmaril@97
   501
{
insilmaril@97
   502
	return xlink.at(i);
insilmaril@97
   503
}
insilmaril@97
   504
insilmaril@95
   505
BranchObj* BranchObj::XLinkTargetAt (int i)
insilmaril@89
   506
{
insilmaril@406
   507
	if (i>=0 && i<xlink.size())
insilmaril@406
   508
	{
insilmaril@406
   509
		if (xlink.at(i))
insilmaril@406
   510
			return xlink.at(i)->otherBranch (this);
insilmaril@406
   511
	}
insilmaril@406
   512
	return NULL;
insilmaril@89
   513
}
insilmaril@89
   514
insilmaril@785
   515
 
insilmaril@785
   516
// FIXME-3 FloatImageObj* BranchObj::addFloatImage ()
insilmaril@785
   517
/*
insilmaril@0
   518
{
insilmaril@408
   519
	FloatImageObj *newfi=new FloatImageObj (scene,this);
insilmaril@0
   520
	floatimage.append (newfi);
insilmaril@749
   521
	if ( ((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem) )
insilmaril@0
   522
		newfi->setVisibility (false);
insilmaril@0
   523
	else	
insilmaril@0
   524
		newfi->setVisibility(visible);
insilmaril@785
   525
	//calcBBoxSize();
insilmaril@785
   526
	//positionBBox();
insilmaril@0
   527
	requestReposition();
insilmaril@0
   528
	return newfi;
insilmaril@0
   529
}
insilmaril@785
   530
*/
insilmaril@0
   531
insilmaril@785
   532
//FIXME-3 FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio)
insilmaril@785
   533
/*
insilmaril@0
   534
{
insilmaril@408
   535
	FloatImageObj *newfi=new FloatImageObj (scene,this);
insilmaril@0
   536
	floatimage.append (newfi);
insilmaril@0
   537
	newfi->copy (fio);
insilmaril@749
   538
	if (((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem) )
insilmaril@0
   539
		newfi->setVisibility (false);
insilmaril@0
   540
	else	
insilmaril@0
   541
		newfi->setVisibility(visible);
insilmaril@785
   542
	//calcBBoxSize();
insilmaril@785
   543
	//positionBBox();
insilmaril@0
   544
	requestReposition();
insilmaril@0
   545
	return newfi;
insilmaril@0
   546
}
insilmaril@785
   547
*/
insilmaril@0
   548
insilmaril@785
   549
/* FIXME-3 FloatImageObj* BranchObj::getFirstFloatImage ()
insilmaril@0
   550
{
insilmaril@0
   551
    return floatimage.first();
insilmaril@0
   552
}
insilmaril@0
   553
insilmaril@0
   554
FloatImageObj* BranchObj::getLastFloatImage ()
insilmaril@0
   555
{
insilmaril@0
   556
    return floatimage.last();
insilmaril@0
   557
}
insilmaril@0
   558
insilmaril@785
   559
FIXME -3 FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
insilmaril@0
   560
{
insilmaril@0
   561
    return floatimage.at(i);
insilmaril@0
   562
}
insilmaril@0
   563
insilmaril@0
   564
void BranchObj::removeFloatImage (FloatImageObj *fio)
insilmaril@0
   565
{
insilmaril@404
   566
	int i=floatimage.indexOf (fio);
insilmaril@411
   567
	if (i>-1) delete (floatimage.takeAt (i));
insilmaril@169
   568
	calcBBoxSize();
insilmaril@169
   569
	positionBBox();
insilmaril@0
   570
	requestReposition();
insilmaril@0
   571
}
insilmaril@785
   572
*/
insilmaril@0
   573
insilmaril@0
   574
void BranchObj::savePosInAngle ()
insilmaril@0
   575
{
insilmaril@0
   576
	// Save position in angle
insilmaril@750
   577
	for (int i=0; i<treeItem->branchCount(); ++i)
insilmaril@753
   578
		treeItem->getBranchObjNum(i)->angle=i;
insilmaril@0
   579
}
insilmaril@0
   580
insilmaril@146
   581
void BranchObj::setDefAttr (BranchModification mod)
insilmaril@146
   582
{
insilmaril@146
   583
	int fontsize;
insilmaril@755
   584
	switch (treeItem->depth())
insilmaril@146
   585
	{
insilmaril@146
   586
		case 0: fontsize=16; break;
insilmaril@146
   587
		case 1: fontsize=12; break;
insilmaril@146
   588
		default: fontsize=10; break;
insilmaril@146
   589
	}	
insilmaril@786
   590
	setLinkStyle(getDefLinkStyle(treeItem->parent() ));
insilmaril@146
   591
	setLinkColor ();
insilmaril@146
   592
	QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
insilmaril@146
   593
	font.setPointSize(fontsize);
insilmaril@146
   594
	heading->setFont(font );
insilmaril@146
   595
insilmaril@146
   596
	if (mod==NewBranch)
insilmaril@760
   597
		setColor (treeItem->getHeadingColor() );
insilmaril@146
   598
	calcBBoxSize();
insilmaril@146
   599
}
insilmaril@146
   600
insilmaril@760
   601
void BranchObj::sortChildren() //FIXME-2  
insilmaril@604
   602
{
insilmaril@749
   603
/*
insilmaril@749
   604
	int childCount=branch.count(); 
insilmaril@604
   605
	int curChildIndex;
insilmaril@604
   606
	bool madeChanges=false;
insilmaril@604
   607
	do
insilmaril@604
   608
	{
insilmaril@604
   609
		madeChanges=false;
insilmaril@604
   610
		for(curChildIndex=1;curChildIndex<childCount;curChildIndex++){
insilmaril@753
   611
			BranchObj* curChild=(BranchObj*)treeItem->getBranchObjNum(curChildIndex);
insilmaril@753
   612
			BranchObj* prevChild=(BranchObj*)treeItem->getBranchObjNum(curChildIndex-1);
insilmaril@604
   613
			if(prevChild->heading->text().compare(curChild->heading->text())>0)
insilmaril@604
   614
			{
insilmaril@604
   615
				this->moveBranchUp(curChild);
insilmaril@604
   616
				madeChanges=true;
insilmaril@604
   617
			}
insilmaril@604
   618
		}
insilmaril@604
   619
	}while(madeChanges);
insilmaril@749
   620
*/
insilmaril@604
   621
}
insilmaril@604
   622
insilmaril@721
   623
void BranchObj::alignRelativeTo (QPointF ref,bool alignSelf)
insilmaril@0
   624
{
insilmaril@408
   625
	qreal th = bboxTotal.height();	
insilmaril@773
   626
	int depth=treeItem->depth();	// FIXME-3 needed to recursively calc depth?
insilmaril@223
   627
// TODO testing
insilmaril@223
   628
/*
insilmaril@755
   629
insilmaril@755
   630
	QString h=QString (depth,' ');
insilmaril@753
   631
	h+=treeItem->getHeading();
insilmaril@753
   632
	h+=QString (15,' ');
insilmaril@753
   633
	h.truncate (15);
insilmaril@688
   634
	QPointF pp; if (parObj) pp=parObj->getChildPos();
insilmaril@753
   635
	cout << "BO::alignRelTo ";
insilmaril@753
   636
	cout<<h.toStdString();
insilmaril@755
   637
	cout << "    d="<<depth<<
insilmaril@755
   638
//cout<<  "  ref="<<ref<<
insilmaril@753
   639
      	"  bbox.tL="<<bboxTotal.topLeft()<<
insilmaril@223
   640
		"  absPos="<<absPos<<
insilmaril@721
   641
//		"  relPos="<<relPos<<
insilmaril@721
   642
//		"  parPos="<<pp<<
insilmaril@753
   643
		"  w="<<bbox.width()<<
insilmaril@753
   644
		"  h="<<bbox.height()<<
insilmaril@753
   645
//		"  orient="<<orientation<<
insilmaril@753
   646
//		"  alignSelf="<<alignSelf<<
insilmaril@753
   647
//		"  scrolled="<<((BranchItem*)treeItem)->isScrolled()<<
insilmaril@254
   648
//		"  pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
insilmaril@382
   649
//		"  hidden="<<hidden<<
insilmaril@753
   650
		"  th="<<th<<
insilmaril@382
   651
		endl;
insilmaril@394
   652
*/
insilmaril@0
   653
insilmaril@382
   654
	setOrientation();
insilmaril@779
   655
	//updateLinkGeometry();
insilmaril@382
   656
insilmaril@755
   657
	if (depth==1 && parObj)
insilmaril@364
   658
	{
insilmaril@753
   659
		// Position relatively, if needed
insilmaril@753
   660
		//if (useRelPos) move2RelPos (relPos.x(), relPos.y());
insilmaril@382
   661
insilmaril@753
   662
		// Calc angle to mapCenter if I am a mainbranch
insilmaril@753
   663
		// needed for reordering the mainbranches clockwise 
insilmaril@753
   664
		// around mapcenter 
insilmaril@753
   665
		angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ), 
insilmaril@753
   666
								(int)(y() - parObj->getChildPos().y() ) ) );
insilmaril@753
   667
	}							
insilmaril@753
   668
	if (depth>1)
insilmaril@0
   669
    {
insilmaril@0
   670
		// Align myself depending on orientation and parent, but
insilmaril@382
   671
		// only if I am not a mainbranch or mapcenter itself
insilmaril@688
   672
insilmaril@688
   673
		if (anim.isAnimated())
insilmaril@0
   674
		{
insilmaril@688
   675
			move2RelPos(anim);
insilmaril@688
   676
		} else
insilmaril@688
   677
		{
insilmaril@688
   678
			LinkableMapObj::Orientation o;
insilmaril@688
   679
			o=parObj->getOrientation();
insilmaril@721
   680
			if (alignSelf)
insilmaril@721
   681
				switch (orientation) 
insilmaril@721
   682
				{
insilmaril@721
   683
					case LinkableMapObj::LeftOfCenter:
insilmaril@721
   684
						move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
insilmaril@721
   685
						//move (ref.x() , ref.y() + (th-bbox.height())/2 );
insilmaril@721
   686
					break;
insilmaril@721
   687
					case LinkableMapObj::RightOfCenter:	
insilmaril@721
   688
						move (ref.x() , ref.y() + (th-bbox.height())/2  );
insilmaril@721
   689
					break;
insilmaril@721
   690
					default:
insilmaril@721
   691
						qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
insilmaril@721
   692
					break;
insilmaril@753
   693
			}
insilmaril@688
   694
		}
insilmaril@0
   695
    }		
insilmaril@0
   696
insilmaril@749
   697
	if ( ((BranchItem*)treeItem)->isScrolled() ) return;
insilmaril@0
   698
insilmaril@721
   699
    // Set reference point for alignment of children
insilmaril@408
   700
    QPointF ref2;
insilmaril@462
   701
    if (orientation==LinkableMapObj::LeftOfCenter)
insilmaril@223
   702
		ref2.setX(bbox.topLeft().x() - linkwidth);
insilmaril@0
   703
    else	
insilmaril@223
   704
		ref2.setX(bbox.topRight().x() + linkwidth);
insilmaril@0
   705
insilmaril@0
   706
	if (depth==1)
insilmaril@0
   707
		ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
insilmaril@0
   708
	else	
insilmaril@0
   709
		ref2.setY(ref.y() );	
insilmaril@0
   710
insilmaril@721
   711
    // Align the children depending on reference point 
insilmaril@750
   712
	for (int i=0; i<treeItem->branchCount(); ++i)
insilmaril@0
   713
    {	
insilmaril@753
   714
		if (!treeItem->getBranchNum(i)->isHidden())
insilmaril@254
   715
		{
insilmaril@753
   716
			treeItem->getBranchObjNum(i)->alignRelativeTo (ref2,true);
insilmaril@721
   717
insilmaril@721
   718
			// append next branch below current one
insilmaril@753
   719
			ref2.setY(ref2.y() + treeItem->getBranchObjNum(i)->getBBoxSizeWithChildren().height() );
insilmaril@254
   720
		}
insilmaril@0
   721
    }
insilmaril@0
   722
}
insilmaril@0
   723
insilmaril@0
   724
insilmaril@0
   725
void BranchObj::reposition()
insilmaril@0
   726
{	
insilmaril@164
   727
/* TODO testing only
insilmaril@753
   728
	if (!treeItem->getHeading().isEmpty())
insilmaril@753
   729
		cout << "BO::reposition  "<<qPrintable(treeItem->getHeading())<<endl;
insilmaril@0
   730
	else	
insilmaril@0
   731
		cout << "BO::reposition  ???"<<endl;
insilmaril@753
   732
//	cout << "  orient="<<orientation<<endl;
insilmaril@0
   733
*/		
insilmaril@382
   734
insilmaril@755
   735
	if (treeItem->depth()==0)
insilmaril@0
   736
	{
insilmaril@0
   737
		// only calculate the sizes once. If the deepest LMO 
insilmaril@0
   738
		// changes its height,
insilmaril@0
   739
		// all upper LMOs have to change, too.
insilmaril@721
   740
		calcBBoxSizeWithChildren();
insilmaril@779
   741
		updateLinkGeometry();	// This update is needed if the scene is resized 
insilmaril@333
   742
						// due to excessive moving of a FIO
insilmaril@333
   743
insilmaril@408
   744
	    alignRelativeTo ( QPointF (absPos.x(),
insilmaril@0
   745
			absPos.y()-(bboxTotal.height()-bbox.height())/2) );
insilmaril@753
   746
		//FIXME-2 qSort (branch.begin(),branch.end(), isAbove);
insilmaril@333
   747
		positionBBox();	// Reposition bbox and contents
insilmaril@0
   748
	} else
insilmaril@0
   749
	{
insilmaril@0
   750
		// This is only important for moving branches:
insilmaril@0
   751
		// For editing a branch it isn't called...
insilmaril@408
   752
	    alignRelativeTo ( QPointF (absPos.x(),
insilmaril@0
   753
							absPos.y()-(bboxTotal.height()-bbox.height())/2) );
insilmaril@0
   754
	}
insilmaril@0
   755
}
insilmaril@0
   756
insilmaril@382
   757
void BranchObj::unsetAllRepositionRequests()
insilmaril@382
   758
{
insilmaril@382
   759
	repositionRequest=false;
insilmaril@750
   760
	for (int i=0; i<treeItem->branchCount(); ++i)
insilmaril@753
   761
		treeItem->getBranchObjNum(i)->unsetAllRepositionRequests();
insilmaril@382
   762
}
insilmaril@382
   763
insilmaril@0
   764
insilmaril@661
   765
QPolygonF BranchObj::shape()
insilmaril@661
   766
{
insilmaril@661
   767
	QPolygonF p;
insilmaril@661
   768
insilmaril@661
   769
	QRectF r=getTotalBBox();
insilmaril@661
   770
	if (orientation==LinkableMapObj::LeftOfCenter)
insilmaril@661
   771
		p   <<r.bottomLeft()
insilmaril@661
   772
			<<r.topLeft()
insilmaril@661
   773
			<<QPointF (bbox.topLeft().x(), r.topLeft().y() )
insilmaril@661
   774
			<<bbox.topRight()
insilmaril@661
   775
			<<bbox.bottomRight()
insilmaril@661
   776
			<<QPointF (bbox.bottomLeft().x(), r.bottomLeft().y() ) ;
insilmaril@661
   777
	else		
insilmaril@661
   778
		p   <<r.bottomRight()
insilmaril@661
   779
			<<r.topRight()
insilmaril@661
   780
			<<QPointF (bbox.topRight().x(), r.topRight().y() )
insilmaril@661
   781
			<<bbox.topLeft()
insilmaril@661
   782
			<<bbox.bottomLeft()
insilmaril@661
   783
			<<QPointF (bbox.bottomRight().x(), r.bottomRight().y() ) ;
insilmaril@661
   784
	return p;
insilmaril@661
   785
}
insilmaril@661
   786
insilmaril@408
   787
QRectF BranchObj::getTotalBBox()
insilmaril@0
   788
{
insilmaril@408
   789
	QRectF r=bbox;
insilmaril@0
   790
insilmaril@749
   791
	if ( ((BranchItem*)treeItem)->isScrolled() ) return r;
insilmaril@0
   792
insilmaril@750
   793
	for (int i=0; i<treeItem->branchCount(); ++i)
insilmaril@753
   794
		if (!treeItem->getBranchNum(i)->isHidden())
insilmaril@753
   795
			r=addBBox(treeItem->getBranchObjNum(i)->getTotalBBox(),r);
insilmaril@0
   796
insilmaril@755
   797
/* FIXME-3 lots of occurences of treeItem->getBranchObjNum(i) in branchobj.cpp
insilmaril@755
   798
            better check if they are not NULL and maybe simplify...
insilmaril@755
   799
			(have been NULL at least in calcBBoxSizeWithChilds...)
insilmaril@755
   800
*/			
insilmaril@755
   801
insilmaril@785
   802
	for (int i=0; i<treeItem->imageCount(); ++i)
insilmaril@785
   803
		if (!treeItem->isHidden())
insilmaril@785
   804
			r=addBBox(treeItem->getImageObjNum(i)->getTotalBBox(),r);
insilmaril@0
   805
	return r;
insilmaril@0
   806
}
insilmaril@0
   807
insilmaril@721
   808
QRectF BranchObj::getBBoxSizeWithChildren()
insilmaril@0
   809
{
insilmaril@0
   810
	return bboxTotal;
insilmaril@0
   811
}
insilmaril@0
   812
insilmaril@721
   813
void BranchObj::calcBBoxSizeWithChildren()
insilmaril@169
   814
{	
insilmaril@169
   815
	// This is initially called only from reposition and
insilmaril@0
   816
	// and only for mapcenter. So it won't be
insilmaril@0
   817
	// called more than once for a single user 
insilmaril@0
   818
	// action
insilmaril@0
   819
	
insilmaril@169
   820
insilmaril@721
   821
	// Calculate size of LMO including all children (to align them later)
insilmaril@0
   822
	bboxTotal.setX(bbox.x() );
insilmaril@0
   823
	bboxTotal.setY(bbox.y() );
insilmaril@0
   824
insilmaril@721
   825
	// if branch is scrolled, ignore children, but still consider floatimages
insilmaril@753
   826
	BranchItem *bi=(BranchItem*)treeItem;
insilmaril@753
   827
	if ( bi->isScrolled() ) 
insilmaril@0
   828
	{
insilmaril@0
   829
		bboxTotal.setWidth (bbox.width());
insilmaril@0
   830
		bboxTotal.setHeight(bbox.height());
insilmaril@0
   831
		return;
insilmaril@0
   832
	}
insilmaril@0
   833
	
insilmaril@753
   834
	if (bi->isHidden())
insilmaril@254
   835
	{
insilmaril@254
   836
		bboxTotal.setWidth (0);
insilmaril@254
   837
		bboxTotal.setHeight(0);
insilmaril@254
   838
		if (parObj)
insilmaril@254
   839
		{
insilmaril@254
   840
			bboxTotal.setX (parObj->x());
insilmaril@254
   841
			bboxTotal.setY (parObj->y());
insilmaril@254
   842
		} else
insilmaril@254
   843
		{
insilmaril@254
   844
			bboxTotal.setX (bbox.x());
insilmaril@254
   845
			bboxTotal.setY (bbox.y());
insilmaril@254
   846
		}
insilmaril@254
   847
		return;
insilmaril@254
   848
	}
insilmaril@254
   849
	
insilmaril@408
   850
	QRectF r(0,0,0,0);
insilmaril@408
   851
	QRectF br;
insilmaril@0
   852
	// Now calculate recursivly
insilmaril@0
   853
	// sum of heights 
insilmaril@0
   854
	// maximum of widths 
insilmaril@0
   855
	// minimum of y
insilmaril@755
   856
	for (int i=0; i<treeItem->branchCount(); i++)
insilmaril@0
   857
	{
insilmaril@753
   858
		if (!bi->getBranchNum(i)->isHidden())
insilmaril@254
   859
		{
insilmaril@753
   860
			bi->getBranchObjNum(i)->calcBBoxSizeWithChildren();
insilmaril@753
   861
			br=bi->getBranchObjNum(i)->getBBoxSizeWithChildren();
insilmaril@254
   862
			r.setWidth( max (br.width(), r.width() ));
insilmaril@254
   863
			r.setHeight(br.height() + r.height() );
insilmaril@254
   864
			if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
insilmaril@254
   865
		}
insilmaril@0
   866
	}
insilmaril@0
   867
	// Add myself and also
insilmaril@0
   868
	// add width of link to sum if necessary
insilmaril@753
   869
	if (bi->branchCount()<1)
insilmaril@0
   870
		bboxTotal.setWidth (bbox.width() + r.width() );
insilmaril@0
   871
	else	
insilmaril@0
   872
		bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
insilmaril@169
   873
	
insilmaril@169
   874
	bboxTotal.setHeight(max (r.height(),  bbox.height()));
insilmaril@0
   875
}
insilmaril@0
   876
insilmaril@0
   877
QString BranchObj::getSelectString()
insilmaril@0
   878
{
insilmaril@773
   879
	VymModel *model=treeItem->getModel();
insilmaril@773
   880
	if (model)
insilmaril@773
   881
		return model->getSelectString (this);
insilmaril@773
   882
	else
insilmaril@773
   883
		return QString();
insilmaril@0
   884
}
insilmaril@0
   885
insilmaril@688
   886
void BranchObj::setAnimation(const AnimPoint &ap)
insilmaril@462
   887
{
insilmaril@688
   888
	anim=ap;
insilmaril@462
   889
}
insilmaril@462
   890
insilmaril@688
   891
bool BranchObj::animate()
insilmaril@688
   892
{
insilmaril@688
   893
	anim.animate ();
insilmaril@721
   894
	if ( anim.isAnimated() )
insilmaril@721
   895
	{
insilmaril@721
   896
		setRelPos (anim);
insilmaril@721
   897
		return true;
insilmaril@721
   898
	}
insilmaril@723
   899
	parObj->reposition();	// we might have been relinked meanwhile
insilmaril@721
   900
	return false;
insilmaril@688
   901
}
insilmaril@688
   902