r14301 by fschmid - Some fixes for editing gradients on the canvas.

scribus-commit scribus-commit at lists.scribus.net
Tue Nov 17 19:15:25 CET 2009


Revision: 14301
Author: fschmid
Date: 2009-11-17T09:49:09.715263Z
Commit message: Some fixes for editing gradients on the canvas.

Changeset: 
M  /trunk/Scribus/scribus/canvas.cpp
M  /trunk/Scribus/scribus/canvasmode_editgradient.cpp
M  /trunk/Scribus/scribus/plugins/xarimplugin/importxar.cpp

Diffs:
Index: scribus/canvasmode_editgradient.cpp
===================================================================
--- scribus/canvasmode_editgradient.cpp	(revision 14300)
+++ scribus/canvasmode_editgradient.cpp	(revision 14301)
@@ -485,7 +485,6 @@
 	{
 		gradientStart = QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
 		gradientEnd = QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY);
-		gradientFocal = QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY);
 		double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
 		double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
 		QTransform m;
@@ -495,12 +494,30 @@
 		m.rotate(currItem->GrStrokeSkew);
 		m.translate(radEnd * currItem->GrStrokeScale, 0);
 		gradientScale = m.map(QPointF(0,0));
+		QTransform qmatrix;
+		qmatrix.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
+		qmatrix.rotate(rotEnd);
+		double mask_gradientSkew = 0.0;
+		if (currItem->GrStrokeSkew == 90)
+			mask_gradientSkew = 1;
+		else if (currItem->GrStrokeSkew == 180)
+			mask_gradientSkew = 0;
+		else if (currItem->GrStrokeSkew == 270)
+			mask_gradientSkew = -1;
+		else if (currItem->GrStrokeSkew == 390)
+			mask_gradientSkew = 0;
+		else
+			mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrStrokeSkew);
+		qmatrix.shear(mask_gradientSkew, 0);
+		qmatrix.translate(0, currItem->GrStrokeStartY * (1.0 - currItem->GrStrokeScale));
+		qmatrix.translate(-currItem->GrStrokeStartX, -currItem->GrStrokeStartY);
+		qmatrix.scale(1, currItem->GrStrokeScale);
+		gradientFocal = qmatrix.map(QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY));
 	}
 	else if (m_view->editStrokeGradient == 2)
 	{
 		gradientStart = QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY);
 		gradientEnd = QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY);
-		gradientFocal = QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY);
 		double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
 		double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
 		QTransform m;
@@ -510,12 +527,30 @@
 		m.rotate(currItem->GrMaskSkew);
 		m.translate(radEnd * currItem->GrMaskScale, 0);
 		gradientScale = m.map(QPointF(0,0));
+		QTransform qmatrix;
+		qmatrix.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
+		qmatrix.rotate(rotEnd);
+		double mask_gradientSkew = 0.0;
+		if (currItem->GrMaskSkew == 90)
+			mask_gradientSkew = 1;
+		else if (currItem->GrMaskSkew == 180)
+			mask_gradientSkew = 0;
+		else if (currItem->GrMaskSkew == 270)
+			mask_gradientSkew = -1;
+		else if (currItem->GrMaskSkew == 390)
+			mask_gradientSkew = 0;
+		else
+			mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrMaskSkew);
+		qmatrix.shear(mask_gradientSkew, 0);
+		qmatrix.translate(0, currItem->GrMaskStartY * (1.0 - currItem->GrMaskScale));
+		qmatrix.translate(-currItem->GrMaskStartX, -currItem->GrMaskStartY);
+		qmatrix.scale(1, currItem->GrMaskScale);
+		gradientFocal = qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY));
 	}
 	else
 	{
 		gradientStart = QPointF(currItem->GrStartX, currItem->GrStartY);
 		gradientEnd = QPointF(currItem->GrEndX, currItem->GrEndY);
-		gradientFocal = QPointF(currItem->GrFocalX, currItem->GrFocalY);
 		double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
 		double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
 		QTransform m;
@@ -525,6 +560,25 @@
 		m.rotate(currItem->GrSkew);
 		m.translate(radEnd * currItem->GrScale, 0);
 		gradientScale = m.map(QPointF(0,0));
+		QTransform qmatrix;
+		qmatrix.translate(currItem->GrStartX, currItem->GrStartY);
+		qmatrix.rotate(rotEnd);
+		double mask_gradientSkew = 0.0;
+		if (currItem->GrSkew == 90)
+			mask_gradientSkew = 1;
+		else if (currItem->GrSkew == 180)
+			mask_gradientSkew = 0;
+		else if (currItem->GrSkew == 270)
+			mask_gradientSkew = -1;
+		else if (currItem->GrSkew == 390)
+			mask_gradientSkew = 0;
+		else
+			mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrSkew);
+		qmatrix.shear(mask_gradientSkew, 0);
+		qmatrix.translate(0, currItem->GrStartY * (1.0 - currItem->GrScale));
+		qmatrix.translate(-currItem->GrStartX, -currItem->GrStartY);
+		qmatrix.scale(1, currItem->GrScale);
+		gradientFocal = qmatrix.map(QPointF(currItem->GrFocalX, currItem->GrFocalY));
 	}
 	gradientStart = itemMatrix.map(gradientStart);
 	gradientEnd = itemMatrix.map(gradientEnd);
Index: scribus/canvas.cpp
===================================================================
--- scribus/canvas.cpp	(revision 14300)
+++ scribus/canvas.cpp	(revision 14301)
@@ -1168,10 +1168,28 @@
 		psx->setPen(QPen(Qt::magenta, 8.0 / m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
 		psx->drawPoint(QPointF(currItem->GrStrokeStartX, currItem->GrStrokeStartY));
 		psx->drawPoint(QPointF(currItem->GrStrokeEndX, currItem->GrStrokeEndY));
-		if (currItem->GrTypeStroke == 7)
-			psx->drawPoint(QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY));
 		double radEnd = distance(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
 		double rotEnd = xy2Deg(currItem->GrStrokeEndX - currItem->GrStrokeStartX, currItem->GrStrokeEndY - currItem->GrStrokeStartY);
+		QTransform qmatrix;
+		qmatrix.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
+		qmatrix.rotate(rotEnd);
+		double mask_gradientSkew = 0.0;
+		if (currItem->GrStrokeSkew == 90)
+			mask_gradientSkew = 1;
+		else if (currItem->GrStrokeSkew == 180)
+			mask_gradientSkew = 0;
+		else if (currItem->GrStrokeSkew == 270)
+			mask_gradientSkew = -1;
+		else if (currItem->GrStrokeSkew == 390)
+			mask_gradientSkew = 0;
+		else
+			mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrStrokeSkew);
+		qmatrix.shear(mask_gradientSkew, 0);
+		qmatrix.translate(0, currItem->GrStrokeStartY * (1.0 - currItem->GrStrokeScale));
+		qmatrix.translate(-currItem->GrStrokeStartX, -currItem->GrStrokeStartY);
+		qmatrix.scale(1, currItem->GrStrokeScale);
+		if (currItem->GrTypeStroke == 7)
+			psx->drawPoint(qmatrix.map(QPointF(currItem->GrStrokeFocalX, currItem->GrStrokeFocalY)));
 		QTransform m;
 		m.translate(currItem->GrStrokeStartX, currItem->GrStrokeStartY);
 		m.rotate(rotEnd);
@@ -1190,10 +1208,28 @@
 		psx->setPen(QPen(Qt::magenta, 8.0 / m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
 		psx->drawPoint(QPointF(currItem->GrMaskStartX, currItem->GrMaskStartY));
 		psx->drawPoint(QPointF(currItem->GrMaskEndX, currItem->GrMaskEndY));
-		if (currItem->GrMask == 2)
-			psx->drawPoint(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY));
 		double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
 		double rotEnd = xy2Deg(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
+		QTransform qmatrix;
+		qmatrix.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
+		qmatrix.rotate(rotEnd);
+		double mask_gradientSkew = 0.0;
+		if (currItem->GrMaskSkew == 90)
+			mask_gradientSkew = 1;
+		else if (currItem->GrMaskSkew == 180)
+			mask_gradientSkew = 0;
+		else if (currItem->GrMaskSkew == 270)
+			mask_gradientSkew = -1;
+		else if (currItem->GrMaskSkew == 390)
+			mask_gradientSkew = 0;
+		else
+			mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrMaskSkew);
+		qmatrix.shear(mask_gradientSkew, 0);
+		qmatrix.translate(0, currItem->GrMaskStartY * (1.0 - currItem->GrMaskScale));
+		qmatrix.translate(-currItem->GrMaskStartX, -currItem->GrMaskStartY);
+		qmatrix.scale(1, currItem->GrMaskScale);
+		if (currItem->GrMask == 2)
+			psx->drawPoint(qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY)));
 		QTransform m;
 		m.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
 		m.rotate(rotEnd);
@@ -1212,10 +1248,28 @@
 		psx->setPen(QPen(Qt::magenta, 8.0 / m_viewMode.scale, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
 		psx->drawPoint(QPointF(currItem->GrStartX, currItem->GrStartY));
 		psx->drawPoint(QPointF(currItem->GrEndX, currItem->GrEndY));
-		if (currItem->GrType == 7)
-			psx->drawPoint(QPointF(currItem->GrFocalX, currItem->GrFocalY));
 		double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
 		double rotEnd = xy2Deg(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
+		QTransform qmatrix;
+		qmatrix.translate(currItem->GrStartX, currItem->GrStartY);
+		qmatrix.rotate(rotEnd);
+		double mask_gradientSkew = 0.0;
+		if (currItem->GrSkew == 90)
+			mask_gradientSkew = 1;
+		else if (currItem->GrSkew == 180)
+			mask_gradientSkew = 0;
+		else if (currItem->GrSkew == 270)
+			mask_gradientSkew = -1;
+		else if (currItem->GrSkew == 390)
+			mask_gradientSkew = 0;
+		else
+			mask_gradientSkew = tan(M_PI / 180.0 * currItem->GrSkew);
+		qmatrix.shear(mask_gradientSkew, 0);
+		qmatrix.translate(0, currItem->GrStartY * (1.0 - currItem->GrScale));
+		qmatrix.translate(-currItem->GrStartX, -currItem->GrStartY);
+		qmatrix.scale(1, currItem->GrScale);
+		if (currItem->GrType == 7)
+			psx->drawPoint(qmatrix.map(QPointF(currItem->GrFocalX, currItem->GrFocalY)));
 		QTransform m;
 		m.translate(currItem->GrStartX, currItem->GrStartY);
 		m.rotate(rotEnd);
Index: scribus/plugins/xarimplugin/importxar.cpp
===================================================================
--- scribus/plugins/xarimplugin/importxar.cpp	(revision 14300)
+++ scribus/plugins/xarimplugin/importxar.cpp	(revision 14301)
@@ -704,6 +704,7 @@
 	readCoords(ts, blx, bly);
 	readCoords(ts, brx, bry);
 	ts >> transStart >> transEnd >> transType;
+	gc->FillBlend = convertBlendMode(transType);
 	if (dataLen == 35)
 	{
 		double p, p1;
@@ -737,6 +738,7 @@
 	readCoords(ts, brx, bry);
 	readCoords(ts, tlx, tly);
 	ts >> transStart >> transEnd >> transType;
+	gc->FillBlend = convertBlendMode(transType);
 	if (dataLen == 43)
 	{
 		double p, p1;
@@ -768,6 +770,7 @@
 	readCoords(ts, tlx, tly);
 	readCoords(ts, brx, bry);
 	ts >> transStart >> transEnd >> transType;
+	gc->FillBlend = convertBlendMode(transType);
 	if (dataLen == 43)
 	{
 		double p, p1;




More information about the scribus-commit mailing list