branchobj.cpp
changeset 794 d922fb6ea482
parent 793 cac93797c580
child 795 6b0a5f4923d3
     1.1 --- a/branchobj.cpp	Wed Sep 09 12:57:06 2009 +0000
     1.2 +++ b/branchobj.cpp	Fri Sep 11 12:56:15 2009 +0000
     1.3 @@ -3,7 +3,7 @@
     1.4  #include "branchitem.h"
     1.5  #include "geometry.h"
     1.6  #include "mapeditor.h"
     1.7 -#include "mainwindow.h"
     1.8 +#include "mainwindow.h"   
     1.9  #include "misc.h"
    1.10  
    1.11  extern FlagRow *standardFlagsMaster;
    1.12 @@ -16,9 +16,13 @@
    1.13  BranchObj::BranchObj (QGraphicsScene* s,TreeItem *ti):OrnamentedObj (s)
    1.14  {
    1.15  //    cout << "Const BranchObj (s)  \n";
    1.16 -	parObj=NULL;
    1.17      scene=s;
    1.18  	treeItem=ti;
    1.19 +	BranchItem *pi=(BranchItem*)(ti->parent());
    1.20 +	if (pi && pi!=ti->getModel()->getRootItem() )
    1.21 +		parObj=pi->getLMO();
    1.22 +	else
    1.23 +		parObj=NULL;
    1.24  	init();
    1.25  }
    1.26  
    1.27 @@ -715,14 +719,28 @@
    1.28  
    1.29  ConvexPolygon BranchObj::getBoundingPolygon()
    1.30  {
    1.31 -	if (treeItem->branchCount()==0)
    1.32 +/*
    1.33 +	if (!pi)	//FIXME-3 Testing only
    1.34 +	{
    1.35 +		pi=scene->addPolygon(MapObj::getBoundingPolygon() );
    1.36 +		pi->setPen(Qt::NoPen);
    1.37 +		pi->setBrush( QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8) );
    1.38 +		pi->setZValue(Z_BBOX);
    1.39 +	}
    1.40 +	*/
    1.41 +	if (treeItem->branchCount()==0 || treeItem->depth()==0)
    1.42 +	{
    1.43 +		if (pi) pi->setPolygon (MapObj::getBoundingPolygon() );
    1.44  		return MapObj::getBoundingPolygon();
    1.45 +	}
    1.46  
    1.47 +	calcBBoxSizeWithChildren();	//FIXME-3 really needed?
    1.48  	QPolygonF p;
    1.49  	p<<bboxTotal.topLeft();
    1.50  	p<<bboxTotal.topRight();
    1.51  	p<<bboxTotal.bottomRight();
    1.52  	p<<bboxTotal.bottomLeft();
    1.53 +		if (pi) pi->setPolygon (p );
    1.54  	return p;
    1.55  }
    1.56