r18134 by jghali - #11414: wrong unit conversion for gradient vector

scribus-commit scribus-commit at lists.scribus.net
Fri Feb 8 22:24:15 UTC 2013


Author: jghali
Date: Fri Feb  8 22:24:14 2013
New Revision: 18134

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18134
Log:
#11414: wrong unit conversion for gradient vector

Modified:
    trunk/Scribus/scribus/ui/cpalette.cpp
    trunk/Scribus/scribus/ui/cpalette.h
    trunk/Scribus/scribus/ui/gradientvectordialog.cpp
    trunk/Scribus/scribus/ui/gradientvectordialog.h
    trunk/Scribus/scribus/ui/propertiespalette.cpp
    trunk/Scribus/scribus/ui/propertiespalette_group.cpp

Modified: trunk/Scribus/scribus/ui/cpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18134&path=/trunk/Scribus/scribus/ui/cpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/cpalette.cpp Fri Feb  8 22:24:14 2013
@@ -290,9 +290,9 @@
 	if(CGradDia && gradEditButton->isChecked())
 	{
 		if(tabFillStroke->currentIndex() == 0)
-			CGradDia->setValues(currentItem->gradientStartX(), currentItem->gradientStartY(), currentItem->gradientEndX(), currentItem->gradientEndY(), currentItem->GrFocalX, currentItem->GrFocalY, currentItem->GrScale, currentItem->GrSkew, 0, 0);
+			setGradientVectorValues();
 		else
-			CGradDia->setValues(currentItem->GrStrokeStartX, currentItem->GrStrokeStartY, currentItem->GrStrokeEndX, currentItem->GrStrokeEndY, currentItem->GrStrokeFocalX, currentItem->GrStrokeFocalY, currentItem->GrStrokeScale, currentItem->GrStrokeSkew, 0, 0);
+			setGradientVectorStrokeValues();
 	}
 	editMeshColors->setEnabled(!CGradDia->isVisible());
 	gradEditButton->setEnabled(true);
@@ -1435,34 +1435,7 @@
 {
 	if (gradEditButton->isChecked())
 	{
-		CGradDia->unitChange(currentDoc->unitIndex());
-		CGradDia->setValues(currentItem->gradientStartX(), currentItem->gradientStartY(), currentItem->gradientEndX(), currentItem->gradientEndY(), currentItem->GrFocalX, currentItem->GrFocalY, currentItem->GrScale, currentItem->GrSkew, 0, 0);
-		if (currentItem->gradientType() == 6)
-			CGradDia->selectLinear();
-		else if (currentItem->gradientType() == 7)
-			CGradDia->selectRadial();
-		else if (currentItem->gradientType() == 9)
-		{
-			CGradDia->setValues(currentItem->GrControl1.x(), currentItem->GrControl1.y(), currentItem->GrControl2.x(), currentItem->GrControl2.y(), currentItem->GrControl3.x(), currentItem->GrControl3.y(), currentItem->GrControl4.x(), currentItem->GrControl4.y(), 0, 0);
-			CGradDia->selectFourColor();
-		}
-		else if (currentItem->gradientType() == 10)
-		{
-			CGradDia->setValues(currentItem->GrControl1.x(), currentItem->GrControl1.y(), currentItem->GrControl2.x(), currentItem->GrControl2.y(), currentItem->GrControl3.x(), currentItem->GrControl3.y(), currentItem->GrControl4.x(), currentItem->GrControl4.y(), currentItem->GrControl5.x(), currentItem->GrControl5.y());
-			CGradDia->selectDiamond();
-		}
-		else if (currentItem->gradientType() == 11)
-		{
-			CGradDia->selectMesh();
-			editMeshColors->setEnabled(false);
-		}
-		else if (currentItem->gradientType() == 12)
-		{
-			CGradDia->selectPatchMesh();
-			editMeshColors->setEnabled(false);
-		}
-		else if (currentItem->gradientType() == 13)
-			CGradDia->selectConical();
+		setGradientVectorValues();
 		CGradDia->show();
 	}
 	else
@@ -1487,20 +1460,63 @@
 {
 	if (gradEditButtonStroke->isChecked())
 	{
+		setGradientVectorStrokeValues();
+		CGradDia->show();
+	}
+	else
+	{
+		CGradDia->hide();
+	}
+	editStrokeGradient = 1;
+	emit editGradient(editStrokeGradient);
+}
+
+void Cpalette::setGradientVectorValues()
+{
+	if (gradEditButton->isChecked())
+	{
+		CGradDia->unitChange(currentDoc->unitIndex());
+		CGradDia->setValues(currentItem->gradientStartX(), currentItem->gradientStartY(), currentItem->gradientEndX(), currentItem->gradientEndY(), currentItem->GrFocalX, currentItem->GrFocalY, currentItem->GrScale, currentItem->GrSkew, 0, 0);
+		if (currentItem->gradientType() == 6)
+			CGradDia->selectLinear();
+		else if (currentItem->gradientType() == 7)
+			CGradDia->selectRadial();
+		else if (currentItem->gradientType() == 9)
+		{
+			CGradDia->setValues(currentItem->GrControl1.x(), currentItem->GrControl1.y(), currentItem->GrControl2.x(), currentItem->GrControl2.y(), currentItem->GrControl3.x(), currentItem->GrControl3.y(), currentItem->GrControl4.x(), currentItem->GrControl4.y(), 0, 0);
+			CGradDia->selectFourColor();
+		}
+		else if (currentItem->gradientType() == 10)
+		{
+			CGradDia->setValues(currentItem->GrControl1.x(), currentItem->GrControl1.y(), currentItem->GrControl2.x(), currentItem->GrControl2.y(), currentItem->GrControl3.x(), currentItem->GrControl3.y(), currentItem->GrControl4.x(), currentItem->GrControl4.y(), currentItem->GrControl5.x(), currentItem->GrControl5.y());
+			CGradDia->selectDiamond();
+		}
+		else if (currentItem->gradientType() == 11)
+		{
+			CGradDia->selectMesh();
+			editMeshColors->setEnabled(false);
+		}
+		else if (currentItem->gradientType() == 12)
+		{
+			CGradDia->selectPatchMesh();
+			editMeshColors->setEnabled(false);
+		}
+		else if (currentItem->gradientType() == 13)
+			CGradDia->selectConical();
+	}
+}
+
+void Cpalette::setGradientVectorStrokeValues()
+{
+	if (gradEditButtonStroke->isChecked())
+	{
 		CGradDia->unitChange(currentDoc->unitIndex());
 		CGradDia->setValues(currentItem->GrStrokeStartX, currentItem->GrStrokeStartY, currentItem->GrStrokeEndX, currentItem->GrStrokeEndY, currentItem->GrStrokeFocalX, currentItem->GrStrokeFocalY, currentItem->GrStrokeScale, currentItem->GrStrokeSkew, 0, 0);
 		if (currentItem->strokeGradientType() == 6)
 			CGradDia->selectLinear();
 		else
 			CGradDia->selectRadial();
-		CGradDia->show();
-	}
-	else
-	{
-		CGradDia->hide();
-	}
-	editStrokeGradient = 1;
-	emit editGradient(editStrokeGradient);
+	}
 }
 
 void Cpalette::setActiveGradDia(bool active)

Modified: trunk/Scribus/scribus/ui/cpalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18134&path=/trunk/Scribus/scribus/ui/cpalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.h (original)
+++ trunk/Scribus/scribus/ui/cpalette.h Fri Feb  8 22:24:14 2013
@@ -181,6 +181,9 @@
 	void   setCurrentItem(PageItem* item);
 	void   updateFromItem();
 
+	void   setGradientVectorValues();
+	void   setGradientVectorStrokeValues();
+
 	int    m_blockUpdates;
 	void   blockUpdates(bool block) { if (block) ++m_blockUpdates; else --m_blockUpdates; }
 	bool   updatesBlocked() { return (m_blockUpdates > 0); }

Modified: trunk/Scribus/scribus/ui/gradientvectordialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18134&path=/trunk/Scribus/scribus/ui/gradientvectordialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/gradientvectordialog.cpp (original)
+++ trunk/Scribus/scribus/ui/gradientvectordialog.cpp Fri Feb  8 22:24:14 2013
@@ -22,10 +22,13 @@
  ***************************************************************************/
 
 #include "gradientvectordialog.h"
+#include "units.h"
 #include "util_icon.h"
 
 GradientVectorDialog::GradientVectorDialog(QWidget* parent) : ScrPaletteBase( parent, "GradientVectorPalette", false, 0 )
 {
+	m_unitRatio = 1.0;
+
 	setupUi(this);
 	gSk->setNewUnit(6);
 	gSk->setValues(-89, 89, 2, 0);
@@ -272,37 +275,39 @@
 	disconnect(gC4YD,  SIGNAL(valueChanged(double)), this, SLOT(changeSpecialD()));
 	disconnect(gC5XD,  SIGNAL(valueChanged(double)), this, SLOT(changeSpecialD()));
 	disconnect(gC5YD,  SIGNAL(valueChanged(double)), this, SLOT(changeSpecialD()));
-	gX1->setValue(x1);
-	gX2->setValue(x2);
-	gY1->setValue(y1);
-	gY2->setValue(y2);
-	gFX->setValue(fx);
-	gFY->setValue(fy);
+
+	gX1->setValue(x1 * m_unitRatio);
+	gX2->setValue(x2 * m_unitRatio);
+	gY1->setValue(y1 * m_unitRatio);
+	gY2->setValue(y2 * m_unitRatio);
+	gFX->setValue(fx * m_unitRatio);
+	gFY->setValue(fy * m_unitRatio);
 	gSk->setValue(sk);
 	gSc->setValue(sg * 100.0);
-	gX1_2->setValue(x1);
-	gX2_2->setValue(x2);
-	gY1_2->setValue(y1);
-	gY2_2->setValue(y2);
+	gX1_2->setValue(x1 * m_unitRatio);
+	gX2_2->setValue(x2 * m_unitRatio);
+	gY1_2->setValue(y1 * m_unitRatio);
+	gY2_2->setValue(y2 * m_unitRatio);
 	gSk_2->setValue(sk);
-	gC1X->setValue(x1);
-	gC1Y->setValue(y1);
-	gC2X->setValue(x2);
-	gC2Y->setValue(y2);
-	gC3X->setValue(fx);
-	gC3Y->setValue(fy);
-	gC4X->setValue(sg);
-	gC4Y->setValue(sk);
-	gC1XD->setValue(x1);
-	gC1YD->setValue(y1);
-	gC2XD->setValue(x2);
-	gC2YD->setValue(y2);
-	gC3XD->setValue(fx);
-	gC3YD->setValue(fy);
-	gC4XD->setValue(sg);
-	gC4YD->setValue(sk);
-	gC5XD->setValue(cx);
-	gC5YD->setValue(cy);
+	gC1X->setValue(x1 * m_unitRatio);
+	gC1Y->setValue(y1 * m_unitRatio);
+	gC2X->setValue(x2 * m_unitRatio);
+	gC2Y->setValue(y2 * m_unitRatio);
+	gC3X->setValue(fx * m_unitRatio);
+	gC3Y->setValue(fy * m_unitRatio);
+	gC4X->setValue(sg * m_unitRatio);
+	gC4Y->setValue(sk * m_unitRatio);
+	gC1XD->setValue(x1 * m_unitRatio);
+	gC1YD->setValue(y1 * m_unitRatio);
+	gC2XD->setValue(x2 * m_unitRatio);
+	gC2YD->setValue(y2 * m_unitRatio);
+	gC3XD->setValue(fx * m_unitRatio);
+	gC3YD->setValue(fy * m_unitRatio);
+	gC4XD->setValue(sg * m_unitRatio);
+	gC4YD->setValue(sk * m_unitRatio);
+	gC5XD->setValue(cx * m_unitRatio);
+	gC5YD->setValue(cy * m_unitRatio);
+
 	connect(gX1,   SIGNAL(valueChanged(double)), this, SLOT(changeSpecialL()));
 	connect(gX2,   SIGNAL(valueChanged(double)), this, SLOT(changeSpecialL()));
 	connect(gY1,   SIGNAL(valueChanged(double)), this, SLOT(changeSpecialL()));
@@ -358,6 +363,8 @@
 
 void GradientVectorDialog::unitChange(int unitIndex)
 {
+	m_unitRatio = unitGetRatioFromIndex(unitIndex);
+
 	disconnect(gX1,   SIGNAL(valueChanged(double)), this, SLOT(changeSpecialL()));
 	disconnect(gX2,   SIGNAL(valueChanged(double)), this, SLOT(changeSpecialL()));
 	disconnect(gY1,   SIGNAL(valueChanged(double)), this, SLOT(changeSpecialL()));

Modified: trunk/Scribus/scribus/ui/gradientvectordialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18134&path=/trunk/Scribus/scribus/ui/gradientvectordialog.h
==============================================================================
--- trunk/Scribus/scribus/ui/gradientvectordialog.h (original)
+++ trunk/Scribus/scribus/ui/gradientvectordialog.h Fri Feb  8 22:24:14 2013
@@ -70,6 +70,9 @@
 	void changeSpecialD();
 	void unitChange(int unitIndex);
 
+protected:
+	double m_unitRatio;
+
 signals:
 	void NewSpecial(double, double, double, double, double, double, double, double, double, double);
 	void editGradient(int);

Modified: trunk/Scribus/scribus/ui/propertiespalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18134&path=/trunk/Scribus/scribus/ui/propertiespalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette.cpp Fri Feb  8 22:24:14 2013
@@ -917,18 +917,17 @@
 
 	groupPal->updateColorSpecialGradient();
 
-	double dur=m_doc->unitRatio();
 	PageItem *currItem=m_doc->m_Selection->itemAt(0);
 	if (currItem)
 	{
 		if (m_ScMW->view->editStrokeGradient == 0)
-			Cpal->setSpecialGradient(currItem->GrStartX * dur, currItem->GrStartY * dur, currItem->GrEndX * dur, currItem->GrEndY * dur, currItem->GrFocalX * dur, currItem->GrFocalY * dur, currItem->GrScale, currItem->GrSkew, 0, 0);
+			Cpal->setSpecialGradient(currItem->GrStartX, currItem->GrStartY, currItem->GrEndX, currItem->GrEndY, currItem->GrFocalX, currItem->GrFocalY, currItem->GrScale, currItem->GrSkew, 0, 0);
 		else if (m_ScMW->view->editStrokeGradient == 1)
-			Cpal->setSpecialGradient(currItem->GrStrokeStartX * dur, currItem->GrStrokeStartY * dur, currItem->GrStrokeEndX * dur, currItem->GrStrokeEndY * dur, currItem->GrStrokeFocalX * dur, currItem->GrStrokeFocalY * dur, currItem->GrStrokeScale, currItem->GrStrokeSkew, 0, 0);
+			Cpal->setSpecialGradient(currItem->GrStrokeStartX, currItem->GrStrokeStartY, currItem->GrStrokeEndX, currItem->GrStrokeEndY, currItem->GrStrokeFocalX, currItem->GrStrokeFocalY, currItem->GrStrokeScale, currItem->GrStrokeSkew, 0, 0);
 		else if (m_ScMW->view->editStrokeGradient == 3)
-			Cpal->setSpecialGradient(currItem->GrControl1.x() * dur, currItem->GrControl1.y() * dur, currItem->GrControl2.x() * dur, currItem->GrControl2.y() * dur, currItem->GrControl3.x() * dur, currItem->GrControl3.y() * dur, currItem->GrControl4.x() * dur, currItem->GrControl4.y() * dur, 0, 0);
+			Cpal->setSpecialGradient(currItem->GrControl1.x(), currItem->GrControl1.y(), currItem->GrControl2.x(), currItem->GrControl2.y(), currItem->GrControl3.x(), currItem->GrControl3.y(), currItem->GrControl4.x(), currItem->GrControl4.y(), 0, 0);
 		else if (m_ScMW->view->editStrokeGradient == 4)
-			Cpal->setSpecialGradient(currItem->GrControl1.x() * dur, currItem->GrControl1.y() * dur, currItem->GrControl2.x() * dur, currItem->GrControl2.y() * dur, currItem->GrControl3.x() * dur, currItem->GrControl3.y() * dur, currItem->GrControl4.x() * dur, currItem->GrControl4.y() * dur, currItem->GrControl5.x(), currItem->GrControl5.y());
+			Cpal->setSpecialGradient(currItem->GrControl1.x(), currItem->GrControl1.y(), currItem->GrControl2.x(), currItem->GrControl2.y(), currItem->GrControl3.x(), currItem->GrControl3.y(), currItem->GrControl4.x(), currItem->GrControl4.y(), currItem->GrControl5.x(), currItem->GrControl5.y());
 		else if ((m_ScMW->view->editStrokeGradient == 5) || (m_ScMW->view->editStrokeGradient == 6))
 			Cpal->setMeshPoint();
 		else if (m_ScMW->view->editStrokeGradient == 8)
@@ -936,7 +935,7 @@
 		else if (m_ScMW->view->editStrokeGradient == 9)
 			Cpal->setMeshPatch();
 		else if (!currItem->isGroup())
-			Tpal->setSpecialGradient(currItem->GrMaskStartX * dur, currItem->GrMaskStartY * dur, currItem->GrMaskEndX * dur, currItem->GrMaskEndY * dur, currItem->GrMaskFocalX * dur, currItem->GrMaskFocalY * dur, currItem->GrMaskScale, currItem->GrMaskSkew);
+			Tpal->setSpecialGradient(currItem->GrMaskStartX, currItem->GrMaskStartY, currItem->GrMaskEndX, currItem->GrMaskEndY, currItem->GrMaskFocalX, currItem->GrMaskFocalY, currItem->GrMaskScale, currItem->GrMaskSkew);
 	}
 }
 

Modified: trunk/Scribus/scribus/ui/propertiespalette_group.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18134&path=/trunk/Scribus/scribus/ui/propertiespalette_group.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_group.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_group.cpp Fri Feb  8 22:24:14 2013
@@ -379,7 +379,6 @@
 		return;
 	if(m_doc->m_Selection->isEmpty())
 		return;
-	double ratio = m_doc->unitRatio();
 	PageItem *currItem = m_doc->m_Selection->itemAt(0);
 	if (currItem)
 	{
@@ -395,7 +394,7 @@
 			break;
 		default:
 			if (currItem->isGroup())
-				transPalWidget->setSpecialGradient(currItem->GrMaskStartX * ratio, currItem->GrMaskStartY * ratio, currItem->GrMaskEndX * ratio, currItem->GrMaskEndY * ratio, currItem->GrMaskFocalX * ratio, currItem->GrMaskFocalY * ratio, currItem->GrMaskScale, currItem->GrMaskSkew);
+				transPalWidget->setSpecialGradient(currItem->GrMaskStartX, currItem->GrMaskStartY, currItem->GrMaskEndX, currItem->GrMaskEndY, currItem->GrMaskFocalX, currItem->GrMaskFocalY, currItem->GrMaskScale, currItem->GrMaskSkew);
 		}
 	}
 }




More information about the scribus-commit mailing list