r16763 by fschmid - Fixed painting of polygons with non closed subpaths.

scribus-commit scribus-commit at lists.scribus.net
Thu Aug 4 22:17:23 UTC 2011


Author: fschmid
Date: Thu Aug  4 22:17:23 2011
New Revision: 16763

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16763
Log:
Fixed painting of polygons with non closed subpaths.

Modified:
    trunk/Scribus/scribus/fpointarray.cpp
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
    trunk/Scribus/scribus/pslib.cpp
    trunk/Scribus/scribus/scpainter.cpp

Modified: trunk/Scribus/scribus/fpointarray.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16763&path=/trunk/Scribus/scribus/fpointarray.cpp
==============================================================================
--- trunk/Scribus/scribus/fpointarray.cpp (original)
+++ trunk/Scribus/scribus/fpointarray.cpp Thu Aug  4 22:17:23 2011
@@ -472,7 +472,7 @@
 QString FPointArray::svgPath(bool closed) const
 {
 	QString tmp = "";
-	FPoint np, np1, np2, np3;
+	FPoint np, np1, np2, np3, np4, firstP;
 	bool nPath = true;
 	bool first = true;
 	if (size() > 3)
@@ -481,18 +481,19 @@
 		{
 			if (point(poi).x() > 900000)
 			{
-//				tmp += "Z ";
 				nPath = true;
 				continue;
 			}
 			if (nPath)
 			{
 				np = point(poi);
-				if ((!first) && (closed))
+				if ((!first) && (closed) && (np4 == firstP))
 					tmp += "Z ";
 				tmp += "M"+QString::number(np.x())+" "+QString::number(np.y())+" ";
 				nPath = false;
 				first = false;
+				firstP = np;
+				np4 = np;
 			}
 			np = point(poi);
 			np1 = point(poi+1);
@@ -502,6 +503,7 @@
 				tmp += QString("L%1 %2 ").arg(np3.x()).arg(np3.y());
 			else
 				tmp += QString("C%1 %2 %3 %4 %5 %6 ").arg(np1.x()).arg(np1.y()).arg(np2.x()).arg(np2.y()).arg(np3.x()).arg(np3.y());
+			np4 = np3;
 		}
 		if (closed)
 			tmp += "Z";
@@ -514,7 +516,7 @@
 	QPainterPath m_path = QPainterPath();
 	bool nPath = true;
 	bool first = true;
-	FPoint np, np1, np2, np3;
+	FPoint np, np1, np2, np3, np4, firstP;
 	if (size() > 3)
 	{
 		for (uint poi = 0; poi < size()-3; poi += 4)
@@ -527,11 +529,13 @@
 			if (nPath)
 			{
 				np = point(poi);
-				if ((!first) && (closed))
+				if ((!first) && (closed) && (np4 == firstP))
 					m_path.closeSubpath();
 				m_path.moveTo(np.x(), np.y());
 				nPath = false;
 				first = false;
+				firstP = np;
+				np4 = np;
 			}
 			np = point(poi);
 			np1 = point(poi+1);
@@ -541,6 +545,7 @@
 				m_path.lineTo(np3.x(), np3.y());
 			else
 				m_path.cubicTo(np1.x(), np1.y(), np2.x(), np2.y(), np3.x(), np3.y());
+			np4 = np3;
 		}
 		if (closed)
 			m_path.closeSubpath();

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16763&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Thu Aug  4 22:17:23 2011
@@ -5760,24 +5760,28 @@
 QString PDFLibCore::SetClipPath(PageItem *ite, bool poly)
 {
 	QString tmp("");
+	FPoint np, np1, np2, np3, np4, firstP;
+	bool nPath = true;
+	bool first = true;
 	if (ite->PoLine.size() > 3)
 	{
-		bool nPath = true;
 		for (uint poi=0; poi<ite->PoLine.size()-3; poi += 4)
 		{
 			if (ite->PoLine.point(poi).x() > 900000)
 			{
-				if (poly)
-					tmp += "h\n";
 				nPath = true;
 				continue;
 			}
-			FPoint np, np1, np2, np3;
 			if (nPath)
 			{
 				np = ite->PoLine.point(poi);
+				if ((!first) && (poly) && (np4 == firstP))
+					tmp += "h\n";
 				tmp += FToStr(np.x())+" "+FToStr(-np.y())+" m\n";
 				nPath = false;
+				first = false;
+				firstP = np;
+				np4 = np;
 			}
 			np = ite->PoLine.point(poi);
 			np1 = ite->PoLine.point(poi+1);
@@ -5791,6 +5795,7 @@
 				tmp += FToStr(np2.x())+" "+FToStr(-np2.y())+" ";
 				tmp += FToStr(np3.x())+" "+FToStr(-np3.y())+" c\n";
 			}
+			np4 = np3;
 		}
 	}
 	return tmp;
@@ -5799,24 +5804,28 @@
 QString PDFLibCore::SetClipPathArray(FPointArray *ite, bool poly)
 {
 	QString tmp("");
+	FPoint np, np1, np2, np3, np4, firstP;
+	bool nPath = true;
+	bool first = true;
 	if (ite->size() > 3)
 	{
-		bool nPath = true;
 		for (uint poi=0; poi<ite->size()-3; poi += 4)
 		{
 			if (ite->point(poi).x() > 900000)
 			{
-				if (poly)
-					tmp += "h\n";
 				nPath = true;
 				continue;
 			}
-			FPoint np, np1, np2, np3;
 			if (nPath)
 			{
 				np = ite->point(poi);
+				if ((!first) && (poly) && (np4 == firstP))
+					tmp += "h\n";
 				tmp += FToStr(np.x())+" "+FToStr(-np.y())+" m\n";
 				nPath = false;
+				first = false;
+				firstP = np;
+				np4 = np;
 			}
 			np = ite->point(poi);
 			np1 = ite->point(poi+1);
@@ -5830,6 +5839,7 @@
 				tmp += FToStr(np2.x())+" "+FToStr(-np2.y())+" ";
 				tmp += FToStr(np3.x())+" "+FToStr(-np3.y())+" c\n";
 			}
+			np4 = np3;
 		}
 	}
 	return tmp;

Modified: trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16763&path=/trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp Thu Aug  4 22:17:23 2011
@@ -2176,23 +2176,28 @@
 QString SVGExPlug::SetClipPath(FPointArray *ite, bool closed)
 {
 	QString tmp = "";
-	FPoint np, np1, np2, np3;
+	FPoint np, np1, np2, np3, np4, firstP;
 	bool nPath = true;
+	bool first = true;
 	if (ite->size() > 3)
 	{
 		for (uint poi=0; poi<ite->size()-3; poi += 4)
 		{
 			if (ite->point(poi).x() > 900000)
 			{
-				tmp += "Z ";
 				nPath = true;
 				continue;
 			}
 			if (nPath)
 			{
 				np = ite->point(poi);
+				if ((!first) && (closed) && (np4 == firstP))
+					tmp += "Z ";
 				tmp += QString("M%1 %2 ").arg(np.x()).arg(np.y());
 				nPath = false;
+				first = false;
+				firstP = np;
+				np4 = np;
 			}
 			np = ite->point(poi);
 			np1 = ite->point(poi+1);
@@ -2202,6 +2207,7 @@
 				tmp += QString("L%1 %2 ").arg(np3.x()).arg(np3.y());
 			else
 				tmp += QString("C%1 %2 %3 %4 %5 %6 ").arg(np1.x()).arg(np1.y()).arg(np2.x()).arg(np2.y()).arg(np3.x()).arg(np3.y());
+			np4 = np3;
 		}
 	}
 	if (closed)

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16763&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp (original)
+++ trunk/Scribus/scribus/pslib.cpp Thu Aug  4 22:17:23 2011
@@ -4805,24 +4805,28 @@
 
 void PSLib::SetClipPath(FPointArray *c, bool poly)
 {
-	FPoint np, np1, np2, np3;
+	FPoint np, np1, np2, np3, np4, firstP;
 	bool nPath = true;
+	bool first = true;
 	if (c->size() > 3)
 	{
 		for (uint poi=0; poi<c->size()-3; poi += 4)
 		{
 			if (c->point(poi).x() > 900000)
 			{
-				if (poly)
-					PS_closepath();
 				nPath = true;
 				continue;
 			}
 			if (nPath)
 			{
 				np = c->point(poi);
+				if ((!first) && (poly) && (np4 == firstP))
+					PS_closepath();
 				PS_moveto(np.x(), -np.y());
 				nPath = false;
+				first = false;
+				firstP = np;
+				np4 = np;
 			}
 			np = c->point(poi);
 			np1 = c->point(poi+1);
@@ -4832,10 +4836,7 @@
 				PS_lineto(np3.x(), -np3.y());
 			else
 				PS_curve(np1.x(), -np1.y(), np2.x(), -np2.y(), np3.x(), -np3.y());
-/*			np = c->point(poi+1);
-			np1 = c->point(poi+3);
-			np2 = c->point(poi+2);
-			PS_curve(np.x(), -np.y(), np1.x(), -np1.y(), np2.x(), -np2.y()); */
+			np4 = np3;
 		}
 	}
 }

Modified: trunk/Scribus/scribus/scpainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16763&path=/trunk/Scribus/scribus/scpainter.cpp
==============================================================================
--- trunk/Scribus/scribus/scpainter.cpp (original)
+++ trunk/Scribus/scribus/scpainter.cpp Thu Aug  4 22:17:23 2011
@@ -1798,7 +1798,7 @@
 {
 	bool nPath = true;
 	bool first = true;
-	FPoint np, np1, np2, np3, np4;
+	FPoint np, np1, np2, np3, np4, firstP;
 	if (points->size() > 3)
 	{
 		newPath();
@@ -1812,9 +1812,10 @@
 			if (nPath)
 			{
 				np = points->point(poi);
-				if ((!first) && (closed))
+				if ((!first) && (closed) && (np4 == firstP))
 					cairo_close_path( m_cr );
     			cairo_move_to( m_cr, np.x(), np.y());
+				firstP = np;
 				nPath = false;
 				first = false;
 				np4 = np;




More information about the scribus-commit mailing list