r16786 by fschmid - Added "Conical" Gradients.

scribus-commit scribus-commit at lists.scribus.net
Mon Aug 15 10:22:38 UTC 2011


Author: fschmid
Date: Mon Aug 15 10:22:38 2011
New Revision: 16786

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16786
Log:
Added "Conical" Gradients.
Fixed transparency issues with "Mesh Gradients" in the PDF export.
Enabled grid and guide snapping when editing mesh gradients.

Modified:
    trunk/Scribus/scribus/canvasmode_editgradient.cpp
    trunk/Scribus/scribus/canvasmode_editmeshgradient.cpp
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/pslib.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/ui/about.cpp
    trunk/Scribus/scribus/ui/colorlistbox.cpp
    trunk/Scribus/scribus/ui/colorpalette.ui
    trunk/Scribus/scribus/ui/cpalette.cpp
    trunk/Scribus/scribus/ui/gradienteditor.cpp
    trunk/Scribus/scribus/ui/gradientvectordialog.cpp
    trunk/Scribus/scribus/ui/gradientvectordialog.h
    trunk/Scribus/scribus/ui/propertiespalette.cpp

Modified: trunk/Scribus/scribus/canvasmode_editgradient.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/canvasmode_editgradient.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editgradient.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editgradient.cpp Mon Aug 15 10:22:38 2011
@@ -183,22 +183,25 @@
 		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);
+		if (currItem->GrType != 13)
+		{
+			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)
+		if ((currItem->GrType == 7) || (currItem->GrType == 13))
 			psx->drawPoint(qmatrix.map(QPointF(currItem->GrFocalX, currItem->GrFocalY)));
 		QTransform m;
 		m.translate(currItem->GrStartX, currItem->GrStartY);
@@ -522,7 +525,7 @@
 				currItem->GrStartY -= np.y();
 				currItem->GrFocalX -= np.x();
 				currItem->GrFocalY -= np.y();
-				if (currItem->GrType == 7)
+				if ((currItem->GrType == 7) || (currItem->GrType == 13))
 				{
 					double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
 					double radFoc = distance(currItem->GrFocalX - currItem->GrStartX, currItem->GrFocalY - currItem->GrStartY);
@@ -541,18 +544,21 @@
 				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);
+				if (currItem->GrType != 13)
+				{
+					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);
@@ -561,7 +567,7 @@
 				QPointF shRe = m.map(shR - np);
 				currItem->GrFocalX = shRe.x();
 				currItem->GrFocalY = shRe.y();
-				if (currItem->GrType == 7)
+				if ((currItem->GrType == 7) || (currItem->GrType == 13))
 				{
 					double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
 					double radFoc = distance(currItem->GrFocalX - currItem->GrStartX, currItem->GrFocalY - currItem->GrStartY);
@@ -582,13 +588,17 @@
 				m.translate(currItem->GrStartX, currItem->GrStartY);
 				m.rotate(rotEnd);
 				m.rotate(-90);
-				m.rotate(currItem->GrSkew);
+				if (currItem->GrType != 13)
+					m.rotate(currItem->GrSkew);
 				m.translate(radEnd * currItem->GrScale, 0);
 				QPointF shP = m.map(QPointF(0,0));
 				QPointF shR = QPointF(shP.x() -np.x(), shP.y() - np.y());
 				double radNew = distance(shR.x() - currItem->GrStartX, shR.y() - currItem->GrStartY);
 				double rotNew = xy2Deg(shR.x() - currItem->GrStartX, shR.y() - currItem->GrStartY) + 90;
-				currItem->GrSkew = rotNew - rotEnd;
+				if (currItem->GrType != 13)
+					currItem->GrSkew = rotNew - rotEnd;
+				else
+					currItem->GrSkew = 0;
 				double newScale = radNew / radEnd;
 				if ((newScale > 0) && (newScale <= 1))
 					currItem->GrScale = newScale;
@@ -597,7 +607,7 @@
 			{
 				currItem->GrEndX -= np.x();
 				currItem->GrEndY -= np.y();
-				if (currItem->GrType == 7)
+				if ((currItem->GrType == 7) || (currItem->GrType == 13))
 				{
 					double radEnd = distance(currItem->GrEndX - currItem->GrStartX, currItem->GrEndY - currItem->GrStartY);
 					double radFoc = distance(currItem->GrFocalX - currItem->GrStartX, currItem->GrFocalY - currItem->GrStartY);
@@ -695,6 +705,8 @@
 			upRect = QRectF(QPointF(-currItem->width(), -currItem->height()), QPointF(currItem->width() * 2, currItem->height() * 2)).normalized();
 		}
 		upRect.translate(currItem->xPos(), currItem->yPos());
+		if (currItem->GrType == 13)
+			currItem->createConicalMesh();
 		m_doc->regionsChanged()->update(upRect.adjusted(-10.0, -10.0, 10.0, 10.0));
 	}
 }
@@ -808,18 +820,21 @@
 		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);
+		if (currItem->GrType != 13)
+		{
+			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);

Modified: trunk/Scribus/scribus/canvasmode_editmeshgradient.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/canvasmode_editmeshgradient.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editmeshgradient.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editmeshgradient.cpp Mon Aug 15 10:22:38 2011
@@ -421,12 +421,17 @@
 		return;
 	if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed())
 	{
-		double newX = mousePointDoc.x();
-		double newY = mousePointDoc.y();
+		FPoint npfN;
+		double nx = mousePointDoc.x();
+		double ny = mousePointDoc.y();
+		if (!m_doc->ApplyGuides(&nx, &ny))
+			npfN = m_doc->ApplyGridF(FPoint(nx, ny));
+		else
+			npfN = FPoint(nx, ny);
 		PageItem *currItem = m_doc->m_Selection->itemAt(0);
-		FPoint npf = FPoint(mousePointDoc.x(), mousePointDoc.y(), currItem->xPos(), currItem->yPos(), currItem->rotation(), 1, 1, true);
+		FPoint npf = FPoint(npfN.x(), npfN.y(), currItem->xPos(), currItem->yPos(), currItem->rotation(), 1, 1, true);
 		m_canvas->displayXYHUD(m->globalPos(), npf.x(), npf.y());
-		FPoint npx(Mxp - newX, Myp - newY, 0, 0, currItem->rotation(), 1, 1, true);
+		FPoint npx(Mxp - npfN.x(), Myp - npfN.y(), 0, 0, currItem->rotation(), 1, 1, true);
 		if (selectedMeshPoints.count() > 0)
 		{
 			if (m_view->editStrokeGradient == 5)
@@ -455,8 +460,8 @@
 			upRect.translate(currItem->xPos(), currItem->yPos());
 			m_doc->regionsChanged()->update(upRect.adjusted(-10.0 - currItem->width() / 2.0, -10.0 - currItem->height() / 2.0, 10.0 + currItem->width() / 2.0, 10.0 + currItem->height() / 2.0));
 		}
-		Mxp = newX;
-		Myp = newY;
+		Mxp = npfN.x();
+		Myp = npfN.y();
 	}
 }
 

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Mon Aug 15 10:22:38 2011
@@ -1489,6 +1489,7 @@
 									p->setDiamondGeometry(FPoint(0, 0), FPoint(width(), 0), FPoint(width(), height()), FPoint(0, height()), GrControl1, GrControl2, GrControl3, GrControl4, GrControl5);
 									break;
 								case 11:
+								case 13:
 									p->setFillMode(ScPainter::Gradient);
 									p->setMeshGradient(FPoint(0, 0), FPoint(width(), 0), FPoint(width(), height()), FPoint(0, height()), meshGradientArray);
 									break;
@@ -2979,6 +2980,187 @@
 		}
 	}
 	ContourLine = PoLine.copy();
+}
+
+void PageItem::createConicalMesh()
+{
+	VGradient gradient;
+	gradient.clearStops();
+	QList<VColorStop*> cstops = fill_gradient.colorStops();
+	double lastStop = -1.0;
+	double actualStop = 0.0;
+	bool   isFirst = true;
+	for (uint cst = 0; cst < fill_gradient.Stops(); ++cst)
+	{
+		actualStop = cstops.at(cst)->rampPoint;
+		if ((actualStop == lastStop) && (!isFirst))
+			continue;
+		if (isFirst)
+		{
+			if (actualStop != 0)
+			{
+				gradient.addStop(cstops.at(cst)->color, 0, 0, cstops.at(cst)->opacity, cstops.at(cst)->name, cstops.at(cst)->shade);
+				if (actualStop <= 0.25)
+					gradient.addStop(cstops.at(cst)->color, cstops.at(cst)->rampPoint, cstops.at(cst)->midPoint, cstops.at(cst)->opacity, cstops.at(cst)->name, cstops.at(cst)->shade);
+				else
+				{
+					double actDist = 0.25;
+					do
+					{
+						gradient.addStop(cstops.at(cst)->color, actDist, actDist, cstops.at(cst)->opacity, cstops.at(cst)->name, cstops.at(cst)->shade);
+						actDist += 0.25;
+					}
+					while (actualStop > actDist);
+					gradient.addStop(cstops.at(cst)->color, cstops.at(cst)->rampPoint, cstops.at(cst)->midPoint, cstops.at(cst)->opacity, cstops.at(cst)->name, cstops.at(cst)->shade);
+				}
+			}
+			else
+				gradient.addStop(cstops.at(cst)->color, cstops.at(cst)->rampPoint, cstops.at(cst)->midPoint, cstops.at(cst)->opacity, cstops.at(cst)->name, cstops.at(cst)->shade);
+			isFirst = false;
+			lastStop = actualStop;
+			continue;
+		}
+		isFirst = false;
+		if (actualStop - lastStop <= 0.25)
+			gradient.addStop(cstops.at(cst)->color, cstops.at(cst)->rampPoint, cstops.at(cst)->midPoint, cstops.at(cst)->opacity, cstops.at(cst)->name, cstops.at(cst)->shade);
+		else
+		{
+			double actDist = lastStop + 0.25;
+			do
+			{
+				gradient.addStop(computeInBetweenStop(cstops.at(cst-1), cstops.at(cst), actDist));
+				actDist += 0.25;
+			}
+			while (actualStop > actDist);
+			gradient.addStop(cstops.at(cst)->color, cstops.at(cst)->rampPoint, cstops.at(cst)->midPoint, cstops.at(cst)->opacity, cstops.at(cst)->name, cstops.at(cst)->shade);
+		}
+		if ((cst == fill_gradient.Stops()-1) && (actualStop < 1.0))
+		{
+			double distToGo = 1.0 - actualStop;
+			if (distToGo <= 0.25)
+				gradient.addStop(cstops.at(cst)->color, 1.0, 1.0, cstops.at(cst)->opacity, cstops.at(cst)->name, cstops.at(cst)->shade);
+			else
+			{
+				do
+				{
+					double actDist = actualStop + 0.25;
+					gradient.addStop(cstops.at(cst)->color, actDist, actDist, cstops.at(cst)->opacity, cstops.at(cst)->name, cstops.at(cst)->shade);
+					distToGo -= 0.25;
+					actDist += 0.25;
+				}
+				while (distToGo >= 0.25);
+				gradient.addStop(cstops.at(cst)->color, 1.0, 1.0, cstops.at(cst)->opacity, cstops.at(cst)->name, cstops.at(cst)->shade);
+			}
+			break;
+		}
+		lastStop = actualStop;
+	}
+	meshGradientArray.clear();
+	QList<meshPoint> mgList1;
+	QList<meshPoint> mgList2;
+	meshPoint mgP1, mgP2, mgP3, mgP4;
+	QPainterPath path;
+	FPointArray arcPath;
+	QLineF angLin = QLineF(QPointF(GrStartX, GrStartY), QPointF(GrEndX, GrEndY));
+	double startAngle = angLin.angle();
+	double radius = angLin.length();
+	double radius2 = radius * 2.0;
+	QList<VColorStop*> rstops = gradient.colorStops();
+	double stepAngle = 360 * rstops.at(1)->rampPoint;
+	path.arcMoveTo(-radius, -radius, radius2, radius2, 0);
+	path.arcTo(-radius, -radius, radius2, radius2, 0, -stepAngle);
+	QTransform mm;
+	mm.rotate(-startAngle);
+	path = mm.map(path);
+	QTransform mr;
+	mr.scale(1.0, GrScale);
+	path = mr.map(path);
+	arcPath.fromQPainterPath(path);
+	arcPath.translate(GrStartX, GrStartY);
+	mgP1.resetTo(arcPath.point(0));
+	mgP1.controlRight = arcPath.point(1);
+	mgP1.transparency = rstops.at(0)->opacity;
+	mgP1.shade = rstops.at(0)->shade;
+	mgP1.colorName = rstops.at(0)->name;
+	mgP1.color = rstops.at(0)->color;
+	mgP1.color.setAlphaF(mgP1.transparency);
+	mgList1.append(mgP1);
+
+	mgP2.resetTo(arcPath.point(2));
+	mgP2.controlLeft = arcPath.point(3);
+	mgP2.transparency = rstops.at(1)->opacity;
+	mgP2.shade = rstops.at(1)->shade;
+	mgP2.colorName = rstops.at(1)->name;
+	mgP2.color = rstops.at(1)->color;
+	mgP2.color.setAlphaF(mgP2.transparency);
+
+	mgP3.resetTo(FPoint(GrFocalX, GrFocalY));
+	mgP3.transparency = rstops.at(0)->opacity;
+	mgP3.shade = rstops.at(0)->shade;
+	mgP3.colorName = rstops.at(0)->name;
+	mgP3.color = rstops.at(0)->color;
+	mgP3.color.setAlphaF(mgP3.transparency);
+
+	mgList2.append(mgP3);
+	mgP3.transparency = rstops.at(1)->opacity;
+	mgP3.shade = rstops.at(1)->shade;
+	mgP3.colorName = rstops.at(1)->name;
+	mgP3.color = rstops.at(1)->color;
+	mgP3.color.setAlphaF(mgP3.transparency);
+	mgList2.append(mgP3);
+	startAngle -= stepAngle;
+	for (uint rst = 2; rst < gradient.Stops(); ++rst)
+	{
+		stepAngle = 360 * (rstops.at(rst)->rampPoint - rstops.at(rst-1)->rampPoint);
+		path = QPainterPath();
+		arcPath.resize(0);
+		path.arcMoveTo(-radius, -radius, radius2, radius2, 0);
+		path.arcTo(-radius, -radius, radius2, radius2, 0, -stepAngle);
+		QTransform mm;
+		mm.rotate(-startAngle);
+		QTransform mr;
+		mr.scale(1.0, GrScale);
+		path = mm.map(path);
+		path = mr.map(path);
+		arcPath.fromQPainterPath(path);
+		arcPath.translate(GrStartX, GrStartY);
+		mgP2.controlRight = arcPath.point(1);
+		mgList1.append(mgP2);
+
+		mgP2.resetTo(arcPath.point(2));
+		mgP2.controlLeft = arcPath.point(3);
+		mgP2.transparency = rstops.at(rst)->opacity;
+		mgP2.shade = rstops.at(rst)->shade;
+		mgP2.colorName = rstops.at(rst)->name;
+		mgP2.color = rstops.at(rst)->color;
+		mgP2.color.setAlphaF(mgP2.transparency);
+
+		mgP3.transparency = rstops.at(rst)->opacity;
+		mgP3.shade = rstops.at(rst)->shade;
+		mgP3.colorName = rstops.at(rst)->name;
+		mgP3.color = rstops.at(rst)->color;
+		mgP3.color.setAlphaF(mgP3.transparency);
+		mgList2.append(mgP3);
+		startAngle -= stepAngle;
+	}
+	mgList1.append(mgP2);
+	meshGradientArray.append(mgList1);
+	meshGradientArray.append(mgList2);
+}
+
+VColorStop PageItem::computeInBetweenStop(VColorStop* last, VColorStop* actual, double t)
+{
+	double dist = actual->rampPoint - last->rampPoint;
+	double perc = (t - last->rampPoint) / dist;
+	double Rn = ((actual->color.redF() - last->color.redF()) * perc) + last->color.redF();
+	double Gn = ((actual->color.greenF() - last->color.greenF()) * perc) + last->color.greenF();
+	double Bn = ((actual->color.blueF() - last->color.blueF()) * perc) + last->color.blueF();
+	QColor color;
+	color.setRgbF(Rn, Gn, Bn);
+	double opacity = ((actual->opacity - last->opacity) * perc) + last->opacity;
+	int shade = qRound(((actual->shade - last->shade) * perc) + last->shade);
+	QString name = last->name + actual->name + QString("%1").arg(perc);
+	return VColorStop(t, t, color, opacity, name, shade);
 }
 
 void PageItem::gradientVector(double& startX, double& startY, double& endX, double& endY, double &focalX, double &focalY, double &scale, double &skew) const
@@ -5020,7 +5202,8 @@
 		{
 			for (int gcol = 0; gcol < meshGradientArray[grow].count(); gcol++)
 			{
-				lists.collectColor(meshGradientArray[grow][gcol].colorName);
+				if (m_Doc->PageColors.contains(meshGradientArray[grow][gcol].colorName))
+					lists.collectColor(meshGradientArray[grow][gcol].colorName);
 			}
 		}
 	}

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Mon Aug 15 10:22:38 2011
@@ -661,6 +661,8 @@
 	void createGradientMesh(int rows, int cols);
 	void resetGradientMesh();
 	void meshToShape();
+	void createConicalMesh();
+	VColorStop computeInBetweenStop(VColorStop* last, VColorStop* actual, double t);
 	void gradientVector(double& startX, double& startY, double& endX, double& endY, double &focalX, double &focalY, double &scale, double &skew) const;
 	void setGradientVector(double startX, double startY, double endX, double endY, double focalX, double focalY, double scale, double skew);
 

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Mon Aug 15 10:22:38 2011
@@ -6512,6 +6512,7 @@
 	QStringList colorNames;
 	QList<int> colorShades;
 	QStringList spotColorSet;
+	QStringList tmpAddedColors;
 	bool spotMode = false;
 	bool transparencyFound = false;
 	StopVec.clear();
@@ -6519,12 +6520,25 @@
 	Gcolors.clear();
 	colorNames.clear();
 	colorShades.clear();
+	tmpAddedColors.clear();
 	for (int grow = 0; grow < c->meshGradientArray.count(); grow++)
 	{
 		for (int gcol = 0; gcol < c->meshGradientArray[grow].count(); gcol++)
 		{
 			meshPoint mp1 = c->meshGradientArray[grow][gcol];
 			colorNames.append(mp1.colorName);
+			if (!doc.PageColors.contains(mp1.colorName))
+			{
+				if (!tmpAddedColors.contains(mp1.colorName))
+				{
+					tmpAddedColors.append(mp1.colorName);
+					ScColor tmp;
+					tmp.setSpotColor(false);
+					tmp.setRegistrationColor(false);
+					tmp.fromQColor(mp1.color);
+					doc.PageColors.insert(mp1.colorName, tmp);
+				}
+			}
 			colorShades.append(mp1.shade);
 			TransVec.append(mp1.transparency);
 			if (mp1.transparency != 1.0)
@@ -6569,10 +6583,7 @@
 				vst << encode32dVal(mp1.gridPoint.x()) << encode32dVal(-mp1.gridPoint.y()) << encode32dVal(mp1.controlRight.x()) << encode32dVal(-mp1.controlRight.y()) << encode32dVal(mp2.controlLeft.x()) << encode32dVal(-mp2.controlLeft.y());
 				vst << encode32dVal(mp2.gridPoint.x()) << encode32dVal(-mp2.gridPoint.y()) << encode32dVal(mp2.controlBottom.x()) << encode32dVal(-mp2.controlBottom.y()) << encode32dVal(mp3.controlTop.x()) << encode32dVal(-mp3.controlTop.y());
 				vst << encode32dVal(mp3.gridPoint.x()) << encode32dVal(-mp3.gridPoint.y()) << encode32dVal(mp3.controlLeft.x()) << encode32dVal(-mp3.controlLeft.y()) << encode32dVal(mp4.controlRight.x()) << encode32dVal(-mp4.controlRight.y());
-				encodeColor(vst, colorNames[colInd4], colorShades[colInd4], spotColorSet, spotMode);
-				encodeColor(vst, colorNames[colInd1], colorShades[colInd1], spotColorSet, spotMode);
-				encodeColor(vst, colorNames[colInd2], colorShades[colInd2], spotColorSet, spotMode);
-				encodeColor(vst, colorNames[colInd3], colorShades[colInd3], spotColorSet, spotMode);
+				vst << encode16dVal(TransVec[colInd4]) << encode16dVal(TransVec[colInd1]) << encode16dVal(TransVec[colInd2]) << encode16dVal(TransVec[colInd3]);
 			}
 		}
 		PutDoc("/Decode [-40000 40000 -40000 40000 0 1]\n");
@@ -6780,6 +6791,13 @@
 	tmp += "/Pattern cs\n";
 	tmp += "/Pattern"+QString::number(patObject)+" scn\n";
 	output = tmp;
+	if (tmpAddedColors.count() != 0)
+	{
+		for (int cd = 0; cd < tmpAddedColors.count(); cd++)
+		{
+			doc.PageColors.remove(tmpAddedColors[cd]);
+		}
+	}
 	return true;
 }
 
@@ -6881,10 +6899,7 @@
 			vst << encode32dVal(mp1.gridPoint.x()) << encode32dVal(-mp1.gridPoint.y()) << encode32dVal(mp1.controlRight.x()) << encode32dVal(-mp1.controlRight.y()) << encode32dVal(mp2.controlLeft.x()) << encode32dVal(-mp2.controlLeft.y());
 			vst << encode32dVal(mp2.gridPoint.x()) << encode32dVal(-mp2.gridPoint.y()) << encode32dVal(mp2.controlBottom.x()) << encode32dVal(-mp2.controlBottom.y()) << encode32dVal(mp3.controlTop.x()) << encode32dVal(-mp3.controlTop.y());
 			vst << encode32dVal(mp3.gridPoint.x()) << encode32dVal(-mp3.gridPoint.y()) << encode32dVal(mp3.controlLeft.x()) << encode32dVal(-mp3.controlLeft.y()) << encode32dVal(mp4.controlRight.x()) << encode32dVal(-mp4.controlRight.y());
-			encodeColor(vst, colorNames[colInd4], colorShades[colInd4], spotColorSet, spotMode);
-			encodeColor(vst, colorNames[colInd1], colorShades[colInd1], spotColorSet, spotMode);
-			encodeColor(vst, colorNames[colInd2], colorShades[colInd2], spotColorSet, spotMode);
-			encodeColor(vst, colorNames[colInd3], colorShades[colInd3], spotColorSet, spotMode);
+			vst << encode16dVal(TransVec[colInd4]) << encode16dVal(TransVec[colInd1]) << encode16dVal(TransVec[colInd2]) << encode16dVal(TransVec[colInd3]);
 		}
 		PutDoc("/Decode [-40000 40000 -40000 40000 0 1]\n");
 		QString dat = "";
@@ -7863,7 +7878,7 @@
 			return PDF_TensorGradientFill(output, currItem);
 		else if (GType == 10)
 			return PDF_DiamondGradientFill(output, currItem);
-		else if (GType == 11)
+		else if ((GType == 11) || (GType == 13))
 			return PDF_MeshGradientFill(output, currItem);
 		else if (GType == 12)
 			return PDF_PatchMeshGradientFill(output, currItem);

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Mon Aug 15 10:22:38 2011
@@ -2916,6 +2916,12 @@
 		newItem->mask_gradient.addStop(ScColorEngine::getRGBColor(col1, doc), 0.0, 0.5, 1.0, doc->itemToolPrefs().shapeFillColor, 100);
 		newItem->mask_gradient.addStop(ScColorEngine::getRGBColor(col2, doc), 1.0, 0.5, 1.0, doc->itemToolPrefs().shapeLineColor, 100);
 	}
+	if (newItem->GrType == 13)
+	{
+		if (!newItem->gradient().isEmpty())
+			newItem->fill_gradient = doc->docGradients[newItem->gradient()];
+		newItem->createConicalMesh();
+	}
 
 	if (newItem->asPathText())
 	{

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp (original)
+++ trunk/Scribus/scribus/pslib.cpp Mon Aug 15 10:22:38 2011
@@ -3174,6 +3174,8 @@
 	QStringList cols;
 	QStringList colorValues;
 	QStringList spotColorSet;
+	QStringList tmpAddedColors;
+	tmpAddedColors.clear();
 	QList<int> colsSh;
 	for (int grow = 0; grow < c->meshGradientArray.count(); grow++)
 	{
@@ -3181,6 +3183,18 @@
 		{
 			meshPoint mp1 = c->meshGradientArray[grow][gcol];
 			cols.append(mp1.colorName);
+			if (!m_Doc->PageColors.contains(mp1.colorName))
+			{
+				if (!tmpAddedColors.contains(mp1.colorName))
+				{
+					tmpAddedColors.append(mp1.colorName);
+					ScColor tmp;
+					tmp.setSpotColor(false);
+					tmp.setRegistrationColor(false);
+					tmp.fromQColor(mp1.color);
+					m_Doc->PageColors.insert(mp1.colorName, tmp);
+				}
+			}
 			colsSh.append(mp1.shade);
 			if (spotMap.contains(mp1.colorName))
 			{
@@ -3304,6 +3318,13 @@
 		PutStream("eofill\n");
 	else
 		PutStream("fill\n");
+	if (tmpAddedColors.count() != 0)
+	{
+		for (int cd = 0; cd < tmpAddedColors.count(); cd++)
+		{
+			m_Doc->PageColors.remove(tmpAddedColors[cd]);
+		}
+	}
 	return;
 }
 
@@ -3858,7 +3879,7 @@
 			HandleDiamondGradient(c, gcr);
 			return;
 		}
-		else if (GType == 11)
+		else if ((GType == 11) || (GType == 13))
 		{
 			HandleMeshGradient(c, gcr);
 			return;

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Mon Aug 15 10:22:38 2011
@@ -3984,6 +3984,8 @@
 		cstops = ite->mask_gradient.colorStops();
 		for (uint cst = 0; cst < ite->mask_gradient.Stops(); ++cst)
 			ite->SetQColor(&cstops.at(cst)->color, cstops.at(cst)->name, cstops.at(cst)->shade);
+		if (ite->GrType == 13)
+			ite->createConicalMesh();
 	}
 	uint masterItemsCount=MasterItems.count();
 	for (uint c=0; c<masterItemsCount; ++c)
@@ -3998,6 +4000,8 @@
 		cstops = ite->mask_gradient.colorStops();
 		for (uint cst = 0; cst < ite->mask_gradient.Stops(); ++cst)
 			ite->SetQColor(&cstops.at(cst)->color, cstops.at(cst)->name, cstops.at(cst)->shade);
+		if (ite->GrType == 13)
+			ite->createConicalMesh();
 	}
 	uint frameItemsCount=FrameItems.count();
 	for (uint c=0; c<frameItemsCount; ++c)
@@ -4012,6 +4016,8 @@
 		cstops = ite->mask_gradient.colorStops();
 		for (uint cst = 0; cst < ite->mask_gradient.Stops(); ++cst)
 			ite->SetQColor(&cstops.at(cst)->color, cstops.at(cst)->name, cstops.at(cst)->shade);
+		if (ite->GrType == 13)
+			ite->createConicalMesh();
 	}
 	QStringList patterns = docPatterns.keys();
 	for (int c = 0; c < patterns.count(); ++c)
@@ -4031,6 +4037,8 @@
 				ite->SetQColor(&cstops.at(cst)->color, cstops.at(cst)->name, cstops.at(cst)->shade);
 			if (ite->asImageFrame())
 				loadPict(ite->Pfile, ite, true, false);
+			if (ite->GrType == 13)
+				ite->createConicalMesh();
 		}
 		PageItem *ite = pa.items.at(0);
 		docPatterns[patterns[c]].pattern = ite->DrawObj_toImage(pa.items, 1.0);
@@ -6721,6 +6729,8 @@
 			}
 			if ((typ > 0) && (typ < 8))
 				currItem->updateGradientVectors();
+			if (currItem->GrType == 13)
+				currItem->createConicalMesh();
 			currItem->update();
 		}
 		m_updateManager.setUpdatesEnabled();
@@ -9276,6 +9286,8 @@
 		PageItem *currItem;
 		currItem = itemSelection->itemAt(i);
 		currItem->fill_gradient = newGradient;
+		if (currItem->GrType == 13)
+			currItem->createConicalMesh();
 		currItem->update();
 	}
 	m_updateManager.setUpdatesEnabled();

Modified: trunk/Scribus/scribus/ui/about.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/ui/about.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/about.cpp (original)
+++ trunk/Scribus/scribus/ui/about.cpp Mon Aug 15 10:22:38 2011
@@ -112,7 +112,7 @@
 	buildID = new QLabel( tab );
 	buildID->setAlignment(Qt::AlignCenter);
 	buildID->setTextInteractionFlags(Qt::TextSelectableByMouse);
-	QString BUILD_DAY = "11";
+	QString BUILD_DAY = "15";
 	QString BUILD_MONTH = CommonStrings::august;
 	QString BUILD_YEAR = "2011";
 	QString BUILD_TIME = "";

Modified: trunk/Scribus/scribus/ui/colorlistbox.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/ui/colorlistbox.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorlistbox.cpp (original)
+++ trunk/Scribus/scribus/ui/colorlistbox.cpp Mon Aug 15 10:22:38 2011
@@ -448,7 +448,7 @@
 {
 	if (event != NULL)
 	{
-	/* commented out because of random crashes in the colorcombobox of the gradient editor */
+	/* commented out because of random crashes in the colorcombobox of the gradient editor
 	if (event->type() == QEvent::ToolTip)
 	{
 		if (cList != NULL)
@@ -480,7 +480,7 @@
 			}
 		}
 	}
-	else
+	else */
 	if (event->type() == QEvent::MouseButtonPress)
 	{
 		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);

Modified: trunk/Scribus/scribus/ui/colorpalette.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/ui/colorpalette.ui
==============================================================================
--- trunk/Scribus/scribus/ui/colorpalette.ui (original)
+++ trunk/Scribus/scribus/ui/colorpalette.ui Mon Aug 15 10:22:38 2011
@@ -116,6 +116,11 @@
                <item>
                 <property name="text">
                  <string>Radial</string>
+                </property>
+               </item>
+               <item>
+                <property name="text">
+                 <string>Conical</string>
                 </property>
                </item>
                <item>

Modified: trunk/Scribus/scribus/ui/cpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/ui/cpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/cpalette.cpp Mon Aug 15 10:22:38 2011
@@ -681,13 +681,15 @@
 	else if (gradientType->currentIndex() == 1)
 		emit NewGradient(7);
 	else if (gradientType->currentIndex() == 2)
+		emit NewGradient(13);
+	else if (gradientType->currentIndex() == 3)
 	{
 		setGradientColors();
 		emit NewGradient(9);
 	}
-	else if (gradientType->currentIndex() == 3)
+	else if (gradientType->currentIndex() == 4)
 		emit NewGradient(10);
-	else if (gradientType->currentIndex() == 4)
+	else if (gradientType->currentIndex() == 5)
 		emit NewGradient(11);
 }
 
@@ -869,17 +871,20 @@
 	}
 	if (number == 0)
 		fillModeCombo->setCurrentIndex(0);
-	else if (((number > 0) && (number < 8)) || (number == 9) || (number == 10) || (number == 11) || (number == 12))
-	{
-		if ((number == 5) || (number == 7))
+	else if (((number > 0) && (number < 8)) || (number == 9) || (number == 10) || (number == 11) || (number == 12) || (number == 13))
+	{
+		if ((number == 5) || (number == 7) || (number == 13))
 		{
 			stackedWidget_2->setCurrentIndex(0);
-			gradientType->setCurrentIndex(1);
+			if ((number == 5) || (number == 7))
+				gradientType->setCurrentIndex(1);
+			if (number == 13)
+				gradientType->setCurrentIndex(2);
 		}
 		else if (number == 9)
 		{
 			stackedWidget_2->setCurrentIndex(1);
-			gradientType->setCurrentIndex(2);
+			gradientType->setCurrentIndex(3);
 			if ((currentItem->GrColorP1 != CommonStrings::None) && (!currentItem->GrColorP1.isEmpty()))
 				setCurrentComboItem(colorPoint1, currentItem->GrColorP1);
 			else
@@ -908,7 +913,7 @@
 		else if (number == 10)
 		{
 			stackedWidget_2->setCurrentIndex(0);
-			gradientType->setCurrentIndex(3);
+			gradientType->setCurrentIndex(4);
 		}
 		else if (number == 11)
 		{
@@ -920,12 +925,12 @@
 				shadeMeshPoint->setValue(mp.shade);
 				transparencyMeshPoint->setValue(mp.transparency * 100);
 			}
-			gradientType->setCurrentIndex(4);
+			gradientType->setCurrentIndex(5);
 		}
 		else if (number == 12)
 		{
 			stackedWidget_2->setCurrentIndex(2);
-			gradientType->setCurrentIndex(5);
+			gradientType->setCurrentIndex(6);
 		}
 		else
 		{
@@ -978,6 +983,11 @@
 			emit NewGradient(7);
 		}
 		else if (gradientType->currentIndex() == 2)
+		{
+			stackedWidget_2->setCurrentIndex(0);
+			emit NewGradient(13);
+		}
+		else if (gradientType->currentIndex() == 3)
 		{
 			stackedWidget_2->setCurrentIndex(1);
 			if ((currentItem->GrColorP1 != CommonStrings::None) && (!currentItem->GrColorP1.isEmpty()))
@@ -1006,12 +1016,12 @@
 			color4Shade->setValue(currentItem->GrCol4Shade);
 			emit NewGradient(9);
 		}
-		else if (gradientType->currentIndex() == 3)
+		else if (gradientType->currentIndex() == 4)
 		{
 			stackedWidget_2->setCurrentIndex(0);
 			emit NewGradient(10);
 		}
-		else if (gradientType->currentIndex() == 4)
+		else if (gradientType->currentIndex() == 5)
 		{
 			stackedWidget_2->setCurrentIndex(2);
 			if ((currentItem->selectedMeshPointX > -1) && (currentItem->selectedMeshPointY > -1l))
@@ -1023,7 +1033,7 @@
 			}
 			emit NewGradient(11);
 		}
-		else if (gradientType->currentIndex() == 5)
+		else if (gradientType->currentIndex() == 6)
 		{
 			stackedWidget_2->setCurrentIndex(2);
 			emit NewGradient(12);
@@ -1052,6 +1062,11 @@
 		emit NewGradient(7);
 	}
 	else if (type == 2)
+	{
+		stackedWidget_2->setCurrentIndex(0);
+		emit NewGradient(13);
+	}
+	else if (type == 3)
 	{
 		stackedWidget_2->setCurrentIndex(1);
 		if ((currentItem->GrColorP1 != CommonStrings::None) && (!currentItem->GrColorP1.isEmpty()))
@@ -1080,12 +1095,12 @@
 		color4Shade->setValue(currentItem->GrCol4Shade);
 		emit NewGradient(9);
 	}
-	else if (type == 3)
+	else if (type == 4)
 	{
 		stackedWidget_2->setCurrentIndex(0);
 		emit NewGradient(10);
 	}
-	else if (type == 4)
+	else if (type == 5)
 	{
 		stackedWidget_2->setCurrentIndex(2);
 		if ((currentItem->selectedMeshPointX > -1) && (currentItem->selectedMeshPointY > -1l))
@@ -1097,7 +1112,7 @@
 		}
 		emit NewGradient(11);
 	}
-	else if (type == 5)
+	else if (type == 6)
 	{
 		stackedWidget_2->setCurrentIndex(2);
 		emit NewGradient(12);
@@ -1215,6 +1230,8 @@
 			CGradDia->selectMesh();
 			editMeshColors->setEnabled(false);
 		}
+		else if (currentItem->GrType == 13)
+			CGradDia->selectConical();
 		CGradDia->show();
 	}
 	else

Modified: trunk/Scribus/scribus/ui/gradienteditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/ui/gradienteditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/gradienteditor.cpp (original)
+++ trunk/Scribus/scribus/ui/gradienteditor.cpp Mon Aug 15 10:22:38 2011
@@ -41,6 +41,7 @@
 	connect(Preview, SIGNAL(selectedStop(VColorStop*)), this, SLOT(slotDisplayStop(VColorStop*)));
 	connect(Preview, SIGNAL(currStep(double)), this, SLOT(setPos(double)));
 	connect(Preview, SIGNAL(currStep(double)), this, SIGNAL(gradientChanged()));
+	connect(Preview, SIGNAL(gradientChanged()), this, SIGNAL(gradientChanged()));
 }
 
 void GradientEditor::setGradient(VGradient grad)

Modified: trunk/Scribus/scribus/ui/gradientvectordialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/ui/gradientvectordialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/gradientvectordialog.cpp (original)
+++ trunk/Scribus/scribus/ui/gradientvectordialog.cpp Mon Aug 15 10:22:38 2011
@@ -103,6 +103,16 @@
 void GradientVectorDialog::selectRadial()
 {
 	stackedWidget->setCurrentIndex(1);
+	label_7->show();
+	gSk_2->show();
+	resize(minimumSizeHint());
+}
+
+void GradientVectorDialog::selectConical()
+{
+	stackedWidget->setCurrentIndex(1);
+	label_7->hide();
+	gSk_2->hide();
 	resize(minimumSizeHint());
 }
 

Modified: trunk/Scribus/scribus/ui/gradientvectordialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/ui/gradientvectordialog.h
==============================================================================
--- trunk/Scribus/scribus/ui/gradientvectordialog.h (original)
+++ trunk/Scribus/scribus/ui/gradientvectordialog.h Mon Aug 15 10:22:38 2011
@@ -47,6 +47,7 @@
 	virtual void changeEvent(QEvent *e);
 	void selectLinear();
 	void selectRadial();
+	void selectConical();
 	void selectFourColor();
 	void selectDiamond();
 	void selectMesh();

Modified: trunk/Scribus/scribus/ui/propertiespalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16786&path=/trunk/Scribus/scribus/ui/propertiespalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette.cpp Mon Aug 15 10:22:38 2011
@@ -748,6 +748,8 @@
 				m_item->GrFocalX = m_item->GrStartX;
 				m_item->GrFocalY = m_item->GrStartY;
 			}
+			if (m_item->GrType == 13)
+				m_item->createConicalMesh();
 			m_item->update();
 			upRect = QRectF(QPointF(m_item->GrStartX, m_item->GrStartY), QPointF(m_item->GrEndX, m_item->GrEndY));
 			double radEnd = distance(m_item->GrEndX - m_item->GrStartX, m_item->GrEndY - m_item->GrStartY);




More information about the scribus-commit mailing list