r16115 by fschmid - Made the Lens Distortion Plugin working again.

scribus-commit scribus-commit at lists.scribus.net
Sun Dec 19 18:49:13 CET 2010


Author: fschmid
Date: Sun Dec 19 17:49:13 2010
New Revision: 16115

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16115
Log:
Made the Lens Distortion Plugin working again.
Fixes for PS and PDF export.

Modified:
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/plugins/tools/lenseffects/lensdialog.cpp
    trunk/Scribus/scribus/plugins/tools/lenseffects/lensdialog.h
    trunk/Scribus/scribus/plugins/tools/lenseffects/lenseffects.cpp
    trunk/Scribus/scribus/pslib.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16115&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sun Dec 19 17:49:13 2010
@@ -873,9 +873,15 @@
 		return;
 	invalid = true;
 	if (dX!=0.0)
+	{
 		Xpos+=dX;
+		gXpos+=dX;
+	}
 	if (dY!=0.0)
+	{
 		Ypos+=dY;
+		gYpos+=dY;
+	}
 	if (drawingOnly || m_Doc->isLoading())
 		return;
 	checkChanges();

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16115&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Sun Dec 19 17:49:13 2010
@@ -2500,7 +2500,7 @@
 							{
 								PageItem* embedded = pat.items.at(em);
 								tmpD += "q\n";
-								tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(embedded->gHeight - embedded->gYpos)+" cm\n";
+								tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(ite->height() - embedded->gYpos)+" cm\n";
 								QString output;
 								if (!PDF_ProcessItem(output, embedded, pag, pag->pageNr(), true))
 									return "";
@@ -2515,7 +2515,7 @@
 								if ((embedded->lineColor() == CommonStrings::None) || (embedded->lineWidth() == 0.0))
 									continue;
 								tmpD += "q\n";
-								tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(embedded->gHeight - embedded->gYpos)+" cm\n";
+								tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(ite->height() - embedded->gYpos)+" cm\n";
 								tmpD += PDF_ProcessTableItem(embedded, pag);
 								tmpD += "Q\n";
 							}
@@ -2546,7 +2546,7 @@
 							{
 								PageItem* embedded = ite->groupItemList.at(em);
 								tmpD += "q\n";
-								tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(embedded->gHeight - embedded->gYpos)+" cm\n";
+								tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(ite->height() - embedded->gYpos)+" cm\n";
 								QString output;
 								if (!PDF_ProcessItem(output, embedded, pag, pag->pageNr(), true))
 									return "";
@@ -2561,7 +2561,7 @@
 								if ((embedded->lineColor() == CommonStrings::None) || (embedded->lineWidth() == 0.0))
 									continue;
 								tmpD += "q\n";
-								tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(embedded->gHeight - embedded->gYpos)+" cm\n";
+								tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(ite->height() - embedded->gYpos)+" cm\n";
 								tmpD += PDF_ProcessTableItem(embedded, pag);
 								tmpD += "Q\n";
 							}
@@ -4234,7 +4234,7 @@
 				{
 					PageItem* embedded = pat.items.at(em);
 					tmpD += "q\n";
-					tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(embedded->gHeight - embedded->gYpos)+" cm\n";
+					tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(ite->height() - embedded->gYpos)+" cm\n";
 					QString output;
 					if (!PDF_ProcessItem(output, embedded, pag, PNr, true))
 						return "";
@@ -4249,7 +4249,7 @@
 					if ((embedded->lineColor() == CommonStrings::None) || (embedded->lineWidth() == 0.0))
 						continue;
 					tmpD += "q\n";
-					tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(embedded->gHeight - embedded->gYpos)+" cm\n";
+					tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(ite->height() - embedded->gYpos)+" cm\n";
 					tmpD += PDF_ProcessTableItem(embedded, pag);
 					tmpD += "Q\n";
 				}
@@ -4280,7 +4280,7 @@
 				{
 					PageItem* embedded = ite->groupItemList.at(em);
 					tmpD += "q\n";
-					tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(embedded->gHeight - embedded->gYpos)+" cm\n";
+					tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(ite->height() - embedded->gYpos)+" cm\n";
 					QString output;
 					if (!PDF_ProcessItem(output, embedded, pag, PNr, true))
 						return "";
@@ -4295,7 +4295,7 @@
 					if ((embedded->lineColor() == CommonStrings::None) || (embedded->lineWidth() == 0.0))
 						continue;
 					tmpD += "q\n";
-					tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(embedded->gHeight - embedded->gYpos)+" cm\n";
+					tmpD +=  "1 0 0 1 "+FToStr(embedded->gXpos)+" "+FToStr(ite->height() - embedded->gYpos)+" cm\n";
 					tmpD += PDF_ProcessTableItem(embedded, pag);
 					tmpD += "Q\n";
 				}

Modified: trunk/Scribus/scribus/plugins/tools/lenseffects/lensdialog.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16115&path=/trunk/Scribus/scribus/plugins/tools/lenseffects/lensdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/lenseffects/lensdialog.cpp (original)
+++ trunk/Scribus/scribus/plugins/tools/lenseffects/lensdialog.cpp Sun Dec 19 17:49:13 2010
@@ -251,19 +251,39 @@
 	setModal(true);
 	buttonZoomOut->setIcon(QIcon(loadIcon("16/zoom-out.png")));
 	buttonZoomI->setIcon(QIcon(loadIcon("16/zoom-in.png")));
-
+	addItemsToScene(doc->m_Selection, doc, 0, 0);
+	previewWidget->setRenderHint(QPainter::Antialiasing);
+	previewWidget->setScene(&scene);
+	isFirst = true;
+	addLens();
+	connect(spinXPos, SIGNAL(valueChanged(double)), this, SLOT(setNewLensX(double)));
+	connect(spinYPos, SIGNAL(valueChanged(double)), this, SLOT(setNewLensY(double)));
+	connect(spinRadius, SIGNAL(valueChanged(double)), this, SLOT(setNewLensRadius(double)));
+	connect(spinStrength, SIGNAL(valueChanged(double)), this, SLOT(setNewLensStrength(double)));
+	connect(buttonAdd, SIGNAL(clicked()), this, SLOT(addLens()));
+	connect(buttonRemove, SIGNAL(clicked()), this, SLOT(removeLens()));
+	connect(buttonMagnify, SIGNAL(toggled(bool)), this, SLOT(changeLens()));
+	connect(buttonZoomI, SIGNAL(clicked()), this, SLOT(doZoomIn()));
+	connect(buttonZoomOut, SIGNAL(clicked()), this, SLOT(doZoomOut()));
+	connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+	connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+	connect(&scene, SIGNAL(selectionChanged()), this, SLOT(selectionHasChanged()));
+}
+
+void LensDialog::addItemsToScene(Selection* itemSelection, ScribusDoc *doc, QGraphicsPathItem* parentItem, PageItem* parent)
+{
 	PageItem *currItem;
 	double gx, gy, gh, gw;
-	doc->m_Selection->setGroupRect();
-	doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
-	uint selectedItemCount = doc->m_Selection->count();
-	QStack<PageItem*> groupStack;
-	QStack<QGraphicsPathItem*> groupStack2;
-	QStack<PageItem*> groupStack3;
-	groupStack2.push(0);
+	itemSelection->setGroupRect();
+	itemSelection->getGroupRect(&gx, &gy, &gw, &gh);
+	uint selectedItemCount = itemSelection->count();
+//	QStack<PageItem*> groupStack;
+//	QStack<QGraphicsPathItem*> groupStack2;
+//	QStack<PageItem*> groupStack3;
+//	groupStack2.push(0);
 	for (uint i = 0; i < selectedItemCount; ++i)
 	{
-		currItem = doc->m_Selection->itemAt(i);
+		currItem = itemSelection->itemAt(i);
 		FPointArray path = currItem->PoLine;
 		QPainterPath pp;
 		if (currItem->itemType() == PageItem::PolyLine)
@@ -271,8 +291,8 @@
 		else
 			pp = path.toQPainterPath(true);
 		origPath.append(pp);
-		QGraphicsPathItem* pItem = new QGraphicsPathItem(pp, groupStack2.top());
-		if (groupStack2.top() == 0)
+		QGraphicsPathItem* pItem = new QGraphicsPathItem(pp, parentItem);
+		if (parentItem == 0)
 		{
 			scene.addItem(pItem);
 			pItem->setPos(currItem->xPos() - gx, currItem->yPos() - gy);
@@ -280,7 +300,6 @@
 		}
 		else
 		{
-			PageItem* parent = groupStack3.top();
 			QTransform mm;
 			mm.rotate(-parent->rotation());
 			mm.translate(-parent->xPos(), -parent->yPos());
@@ -288,7 +307,8 @@
 		}
 		pItem->setZValue(i);
 		origPathItem.append(pItem);
-		if (((currItem->fillColor() == CommonStrings::None) && (currItem->GrType == 0)) || (currItem->controlsGroup()))
+		origPageItem.append(currItem);
+		if (((currItem->fillColor() == CommonStrings::None) && (currItem->GrType == 0)) || (currItem->isGroup()))
 			pItem->setBrush(Qt::NoBrush);
 		else
 		{
@@ -359,7 +379,7 @@
 				pItem->setBrush(paint);
 			}
 		}
-		if (currItem->controlsGroup())
+		if (currItem->isGroup())
 			pItem->setPen(Qt::NoPen);
 		else if (currItem->NamedLStyle.isEmpty())
 		{
@@ -427,14 +447,20 @@
 				pItem->setPen(QPen(paint, currItem->lineWidth(), currItem->lineStyle(), currItem->lineEnd(), currItem->lineJoin()));
 			}
 		}
-		if (currItem->controlsGroup())
-		{
-			groupStack.push(currItem->groupsLastItem);
-			groupStack2.push(pItem);
-			groupStack3.push(currItem);
+		if (currItem->isGroup())
+		{
+	//		groupStack.push(currItem->groupsLastItem);
+	//		groupStack2.push(pItem);
+	//		groupStack3.push(currItem);
 			pItem->setFlags(QGraphicsItem::ItemClipsChildrenToShape);
-		}
-		if (groupStack.count() != 0)
+			Selection tmpSelection(this, false);
+			for (int a = 0; a < currItem->groupItemList.count(); a++)
+			{
+				tmpSelection.addItem(currItem->groupItemList.at(a));
+			}
+			addItemsToScene(&tmpSelection, doc, pItem, currItem);
+		}
+	/*	if (groupStack.count() != 0)
 		{
 			while (currItem == groupStack.top())
 			{
@@ -444,25 +470,9 @@
 				if (groupStack.count() == 0)
 					break;
 			}
-		}
-	}
-
-	previewWidget->setRenderHint(QPainter::Antialiasing);
-	previewWidget->setScene(&scene);
-	isFirst = true;
-	addLens();
-	connect(spinXPos, SIGNAL(valueChanged(double)), this, SLOT(setNewLensX(double)));
-	connect(spinYPos, SIGNAL(valueChanged(double)), this, SLOT(setNewLensY(double)));
-	connect(spinRadius, SIGNAL(valueChanged(double)), this, SLOT(setNewLensRadius(double)));
-	connect(spinStrength, SIGNAL(valueChanged(double)), this, SLOT(setNewLensStrength(double)));
-	connect(buttonAdd, SIGNAL(clicked()), this, SLOT(addLens()));
-	connect(buttonRemove, SIGNAL(clicked()), this, SLOT(removeLens()));
-	connect(buttonMagnify, SIGNAL(toggled(bool)), this, SLOT(changeLens()));
-	connect(buttonZoomI, SIGNAL(clicked()), this, SLOT(doZoomIn()));
-	connect(buttonZoomOut, SIGNAL(clicked()), this, SLOT(doZoomOut()));
-	connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
-	connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
-	connect(&scene, SIGNAL(selectionChanged()), this, SLOT(selectionHasChanged()));
+		} */
+	}
+
 }
 
 void LensDialog::showEvent(QShowEvent *e)

Modified: trunk/Scribus/scribus/plugins/tools/lenseffects/lensdialog.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16115&path=/trunk/Scribus/scribus/plugins/tools/lenseffects/lensdialog.h
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/lenseffects/lensdialog.h (original)
+++ trunk/Scribus/scribus/plugins/tools/lenseffects/lensdialog.h Sun Dec 19 17:49:13 2010
@@ -72,11 +72,13 @@
 public:
 	LensDialog(QWidget* parent, ScribusDoc *doc);
 	~LensDialog() {};
+	void addItemsToScene(Selection* itemSelection, ScribusDoc *doc, QGraphicsPathItem* parentItem, PageItem* parent);
 	void lensSelected(LensItem *item);
 	void setLensPositionValues(QPointF p);
 	QGraphicsScene scene;
 	QList<QPainterPath> origPath;
 	QList<QGraphicsPathItem*> origPathItem;
+	QList<PageItem*> origPageItem;
 	QList<LensItem*> lensList;
 	int currentLens;
 	bool isFirst;

Modified: trunk/Scribus/scribus/plugins/tools/lenseffects/lenseffects.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16115&path=/trunk/Scribus/scribus/plugins/tools/lenseffects/lenseffects.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/lenseffects/lenseffects.cpp (original)
+++ trunk/Scribus/scribus/plugins/tools/lenseffects/lenseffects.cpp Sun Dec 19 17:49:13 2010
@@ -116,7 +116,7 @@
 		{
 			for (int a = 0; a < dia->origPathItem.count(); a++)
 			{
-				PageItem *currItem = currDoc->m_Selection->itemAt(a);
+				PageItem *currItem = dia->origPageItem[a];
 				if (currItem->itemType() == PageItem::Line)
 					continue;
 				QPainterPath path = dia->origPathItem[a]->path();
@@ -126,7 +126,7 @@
 				currItem->Frame = false;
 				currItem->ClipEdited = true;
 				currItem->FrameType = 3;
-				currDoc->AdjustItemSize(currItem);
+				currDoc->AdjustItemSize(currItem, true);
 				currItem->OldB2 = currItem->width();
 				currItem->OldH2 = currItem->height();
 				currItem->updateClip();

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16115&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp (original)
+++ trunk/Scribus/scribus/pslib.cpp Sun Dec 19 17:49:13 2010
@@ -2615,7 +2615,7 @@
 				{
 					PageItem* embed = pat.items.at(em);
 					PS_save();
-					PS_translate(embed->gXpos, embed->gHeight - embed->gYpos);
+					PS_translate(embed->gXpos, c->height() - embed->gYpos);
 					ProcessItem(m_Doc, a, embed, PNr, sep, farb, ic, gcr, master, true);
 					PS_restore();
 				}
@@ -2643,7 +2643,7 @@
 			{
 				PageItem* embed = c->groupItemList.at(em);
 				PS_save();
-				PS_translate(embed->gXpos, embed->gHeight - embed->gYpos);
+				PS_translate(embed->gXpos, c->height() - embed->gYpos);
 				ProcessItem(m_Doc, a, embed, PNr, sep, farb, ic, gcr, master, true);
 				PS_restore();
 			}

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16115&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sun Dec 19 17:49:13 2010
@@ -11886,11 +11886,11 @@
 }
 
 
-void ScribusDoc::AdjustItemSize(PageItem *currItem)
+void ScribusDoc::AdjustItemSize(PageItem *currItem, bool includeGroup)
 {
 	bool siz = currItem->Sizing;
 	currItem->Sizing = false;
-	if (!(currItem->isGroup() || currItem->isSymbol()))
+	if ((!(currItem->isGroup() || currItem->isSymbol())) || includeGroup)
 	{
 		FPointArray Clip;
 		Clip = currItem->PoLine;

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16115&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Sun Dec 19 17:49:13 2010
@@ -1015,7 +1015,7 @@
 	bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
 	bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
 	bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
-	void AdjustItemSize(PageItem *currItem);
+	void AdjustItemSize(PageItem *currItem, bool includeGroup = false);
 	void moveGroup(double x, double y, bool fromMP = false, Selection* customSelection = 0);
 	void rotateGroup(double angle, FPoint RCenter);
 	void scaleGroup(double scx, double scy, bool scaleText=true, Selection* customSelection = 0, bool scaleLine = false);




More information about the scribus-commit mailing list