# HG changeset patch
# User insilmaril
# Date 1201879715 0
# Node ID a7db20d79c3296ba28d2f70167f0ee737cbc9faf
# Parent  01c028006e6dc38f25c313e544192072862f324c
Added brasilian translation by Amadeu JĂșnior

diff -r 01c028006e6d -r a7db20d79c32 vym.pro
--- a/vym.pro	Fri Feb 01 15:28:35 2008 +0000
+++ b/vym.pro	Fri Feb 01 15:28:35 2008 +0000
@@ -4,6 +4,14 @@
 CONFIG	+= qt warn_on release debug
 CONFIG += x86 ppc
 
+TRANSLATIONS += lang/vym_de.ts
+TRANSLATIONS += lang/vym_en.ts
+TRANSLATIONS += lang/vym_es.ts
+TRANSLATIONS += lang/vym_it.ts
+TRANSLATIONS += lang/vym_fr.ts
+TRANSLATIONS += lang/vym_zh_CN.ts
+TRANSLATIONS += lang/vym_pt_BR.ts
+
 # Manifest embedding was suggested by Qt docs somewhere...
 win32: CONFIG += embed_manifest_exe
 
@@ -142,11 +150,6 @@
 
 TARGET  = vym
 
-TRANSLATIONS += lang/vym_de.ts
-TRANSLATIONS += lang/vym_en.ts
-TRANSLATIONS += lang/vym_es.ts
-TRANSLATIONS += lang/vym_it.ts
-TRANSLATIONS += lang/vym_fr.ts
 
 isEmpty( PREFIX ) {
 	PREFIX = /usr/local
diff -r 01c028006e6d -r a7db20d79c32 vymmodel.cpp
--- a/vymmodel.cpp	Fri Feb 01 15:28:35 2008 +0000
+++ b/vymmodel.cpp	Fri Feb 01 15:28:35 2008 +0000
@@ -16,9 +16,8 @@
 
 void VymModel::clear() 
 {
-	for (int i=0; i<mapCenters.count(); i++)
-		mapCenters.at(i)->clear();
-	mapCenters.clear();	
+	while (!mapCenters.isEmpty())
+		delete mapCenters.takeFirst();
 }
 
 void VymModel::init () 
@@ -116,6 +115,7 @@
 	BranchObj *bo=bo_start;
 	if (bo)
 	{
+		// Try to find next branch in current MapCenter
 		rbo=bo->next();
 		if (rbo) return rbo;
 
@@ -216,6 +216,70 @@
 		mapCenters.at(i)->reposition();	//	for positioning heading
 }
 
+QPolygonF VymModel::shape(BranchObj *bo)
+{
+	// Creating (arbitrary) shapes
+
+	QPolygonF p;
+	QRectF rb=bo->getBBox();
+	if (bo->getDepth()==0)
+	{
+		// Just take BBox of this mapCenter
+		p<<rb.topLeft()<<rb.topRight()<<rb.bottomRight()<<rb.bottomLeft();
+		return p;
+	}
+
+	// Take union of BBox and TotalBBox 
+
+	QRectF ra=bo->getTotalBBox();
+	if (bo->getOrientation()==LinkableMapObj::LeftOfCenter)
+		p   <<ra.bottomLeft()
+			<<ra.topLeft()
+			<<QPointF (rb.topLeft().x(), ra.topLeft().y() )
+			<<rb.topRight()
+			<<rb.bottomRight()
+			<<QPointF (rb.bottomLeft().x(), ra.bottomLeft().y() ) ;
+	else		
+		p   <<ra.bottomRight()
+			<<ra.topRight()
+			<<QPointF (rb.topRight().x(), ra.topRight().y() )
+			<<rb.topLeft()
+			<<rb.bottomLeft()
+			<<QPointF (rb.bottomRight().x(), ra.bottomRight().y() ) ;
+	return p;		
+
+}
+
+void VymModel::moveAway(LinkableMapObj *lmo)
+{
+	// Autolayout:
+	//
+	// Move all branches and MapCenters away from lmo 
+	// to avoid collisions 
+
+	// 
+
+
+	QPolygonF pA;
+	QPolygonF pB;
+
+	BranchObj *boA=(BranchObj*)lmo;
+	BranchObj *boB;
+	for (int i=0; i<mapCenters.count(); i++)
+	{
+		boB=mapCenters.at(i);
+		pA=shape (boA);
+		pB=shape (boB);
+		PolygonCollisionResult r = PolygonCollision(pA, pB, QPoint(0,0));
+		cout <<"------->"
+			<<"="<<r.intersect
+			<<"  ("<<qPrintable(boA->getHeading() )<<")"
+			<<"  with ("<< qPrintable (boB->getHeading() )
+			<<")  willIntersect"
+			<<r.willIntersect 
+			<<"  minT="<<r.minTranslation<<endl<<endl;
+	}
+}
 
 
 //////////////////////////////////////////////
diff -r 01c028006e6d -r a7db20d79c32 vymmodel.h
--- a/vymmodel.h	Fri Feb 01 15:28:35 2008 +0000
+++ b/vymmodel.h	Fri Feb 01 15:28:35 2008 +0000
@@ -45,6 +45,8 @@
 	QRectF getTotalBBox();
 	void reposition();					//!< Call reposition for all MCOs
 	void setHideTmp (HideTmpMode mode);	
+	QPolygonF shape(BranchObj *bo);		//!< Returns arbitrary shape of subtree
+	void moveAway (LinkableMapObj *lmo);//!< Autolayout: Move all out of the way
 
 ////////////////////////////////////////// Selection related 
 	LinkableMapObj* getSelection();