r16161 by fschmid - Made the "Path along Path" plugin working again.

scribus-commit scribus-commit at lists.scribus.net
Sat Dec 25 11:28:53 CET 2010


Author: fschmid
Date: Sat Dec 25 10:28:53 2010
New Revision: 16161

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16161
Log:
Made the "Path along Path" plugin working again.

Modified:
    trunk/Scribus/scribus/pageitem_group.cpp
    trunk/Scribus/scribus/pageitem_group.h
    trunk/Scribus/scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.cpp
    trunk/Scribus/scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.h
    trunk/Scribus/scribus/scribusdoc.cpp

Modified: trunk/Scribus/scribus/pageitem_group.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16161&path=/trunk/Scribus/scribus/pageitem_group.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_group.cpp (original)
+++ trunk/Scribus/scribus/pageitem_group.cpp Sat Dec 25 10:28:53 2010
@@ -54,6 +54,17 @@
 //	{
 //		delete groupItemList.takeFirst();
 //	}
+}
+
+void PageItem_Group::adjustXYPosition()
+{
+	for (int em = 0; em < groupItemList.count(); ++em)
+	{
+		PageItem* embedded = groupItemList.at(em);
+		embedded->setXYPos(xPos() + embedded->gXpos, yPos() + embedded->gYpos, true);
+		if (embedded->isGroup())
+			embedded->asGroupFrame()->adjustXYPosition();
+	}
 }
 
 QList<PageItem*> PageItem_Group::getItemList()

Modified: trunk/Scribus/scribus/pageitem_group.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16161&path=/trunk/Scribus/scribus/pageitem_group.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_group.h (original)
+++ trunk/Scribus/scribus/pageitem_group.h Sat Dec 25 10:28:53 2010
@@ -48,6 +48,7 @@
 	virtual void replaceNamedResources(ResourceCollection& newNames);
 	virtual void applicableActions(QStringList& actionList);
 	virtual QString infoDescription();
+	void adjustXYPosition();
 	
 protected:
 	virtual void DrawObj_Item(ScPainter *p, QRectF e);

Modified: trunk/Scribus/scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16161&path=/trunk/Scribus/scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.cpp (original)
+++ trunk/Scribus/scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.cpp Sat Dec 25 10:28:53 2010
@@ -26,6 +26,7 @@
 
 #include "pathdialog.h"
 #include "pathalongpath.h"
+#include "pageitem_group.h"
 #include "scribuscore.h"
 #include "scribusstructs.h"
 #include "util.h"
@@ -173,10 +174,17 @@
 			mp.rotate(pathItem->rotation());
 			effectPath.map(mp);
 			PageItem* bxi = currDoc->m_Selection->itemAt(selOffs);
+			bxi->asGroupFrame()->adjustXYPosition();
 			originalPathG.append(bxi->PoLine.copy());
 			originalXPosG.append(bxi->xPos());
 			originalYPosG.append(bxi->yPos());
+			originalXPosGi.append(bxi->gXpos);
+			originalYPosGi.append(bxi->gYpos);
 			originalRotG.append(bxi->rotation());
+			originalWidth.append(bxi->width());
+			originalHeight.append(bxi->height());
+			originalWidthG.append(bxi->groupWidth);
+			originalHeightG.append(bxi->groupHeight);
 			patternItemG.append(bxi);
 			QList<PageItem*> bxiL = bxi->getItemList();
 			for (int bx = 0; bx < bxiL.count(); ++bx)
@@ -185,6 +193,12 @@
 				originalPathG.append(cIte->PoLine.copy());
 				originalXPosG.append(cIte->xPos());
 				originalYPosG.append(cIte->yPos());
+				originalWidth.append(cIte->width());
+				originalHeight.append(cIte->height());
+				originalWidthG.append(cIte->groupWidth);
+				originalHeightG.append(cIte->groupHeight);
+				originalXPosGi.append(cIte->gXpos);
+				originalYPosGi.append(cIte->gYpos);
 				originalRotG.append(cIte->rotation());
 				patternItemG.append(cIte);
 			}
@@ -252,26 +266,27 @@
 void PathAlongPathPlugin::updateEffectG(int effectType, double offset, double offsetY, double gap, int rotate)
 {
 	qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
-	if (effectType == -1)
-	{
-		for (int bx = 0; bx < patternItemG.count(); ++bx)
-		{
-			PageItem* bxi = patternItemG[bx];
-			bxi->PoLine = originalPathG[bx];
-			bxi->Frame = false;
-			bxi->ClipEdited = true;
-			bxi->FrameType = 3;
-			bxi->setXYPos(originalXPosG[bx], originalYPosG[bx]);
-			bxi->setRotation(originalRotG[bx]);
-			currDoc->AdjustItemSize(bxi, true);
-			bxi->OldB2 = bxi->width();
-			bxi->OldH2 = bxi->height();
-			bxi->updateClip();
-			bxi->ContourLine = bxi->PoLine.copy();
-		}
-		firstUpdate = true;
-	}
-	else
+	for (int bx = 0; bx < patternItemG.count(); ++bx)
+	{
+		PageItem* bxi = patternItemG[bx];
+		bxi->PoLine = originalPathG[bx];
+		bxi->Frame = false;
+		bxi->ClipEdited = true;
+		bxi->FrameType = 3;
+		bxi->setXYPos(originalXPosG[bx], originalYPosG[bx], true);
+		bxi->setRotation(originalRotG[bx]);
+		bxi->gXpos = originalXPosGi[bx];
+		bxi->gYpos = originalYPosGi[bx];
+		bxi->setWidthHeight(originalWidth[bx], originalHeight[bx], true);
+		bxi->groupWidth = originalWidthG[bx];
+		bxi->groupHeight = originalHeightG[bx];
+		bxi->OldB2 = bxi->width();
+		bxi->OldH2 = bxi->height();
+		bxi->updateClip();
+		bxi->ContourLine = bxi->PoLine.copy();
+	}
+	firstUpdate = true;
+	if (effectType != -1)
 	{
 		Geom::Piecewise<Geom::D2<Geom::SBasis> > originaldpwd2 = FPointArray2Piecewise(effectPath, false);
 		Geom::Piecewise<Geom::D2<Geom::SBasis> > patternpwd2;
@@ -287,8 +302,10 @@
 		{
 			PageItem* bxi = patternItemG[bx];
 			FPointArray pathP = originalPathG[bx].copy();
-			double deltaX = originalXPosG[bx] - originX;
-			double deltaY = originalYPosG[bx] - originY;
+			FPoint tp(getMinClipF(&pathP));
+			double deltaX, deltaY;
+			deltaX = originalXPosG[bx] - originX;
+			deltaY = originalYPosG[bx] - originY;
 			QTransform mm;
 			mm.rotate(originalRotG[bx]);
 			pathP.map(mm);
@@ -305,12 +322,7 @@
 			bxi->Frame = false;
 			bxi->ClipEdited = true;
 			bxi->FrameType = 3;
-			bxi->setXYPos(pathItem->xPos()+deltaX, pathItem->yPos()+deltaY);
-			if (!bxi->isGroup())
-			{
-				bxi->gXpos = deltaX;
-				bxi->gYpos = deltaY;
-			}
+			bxi->setXYPos(pathItem->xPos()+deltaX, pathItem->yPos()+deltaY, true);
 			double oW = bxi->width();
 			double oH = bxi->height();
 			currDoc->AdjustItemSize(bxi, true);

Modified: trunk/Scribus/scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16161&path=/trunk/Scribus/scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.h
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.h (original)
+++ trunk/Scribus/scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.h Sat Dec 25 10:28:53 2010
@@ -96,6 +96,12 @@
 		QList<double> originalRotG;
 		QList<double> originalXPosG;
 		QList<double> originalYPosG;
+		QList<double> originalXPosGi;
+		QList<double> originalYPosGi;
+		QList<double> originalWidthG;
+		QList<double> originalHeightG;
+		QList<double> originalWidth;
+		QList<double> originalHeight;
 		QList<PageItem *> patternItemG;
 	private slots:
 		void updateEffectG(int effectType, double offset, double offsetY, double gap, int rotate);

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16161&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sat Dec 25 10:28:53 2010
@@ -9117,7 +9117,6 @@
 	assert(itemSelection!=0);
 	uint selectedItemCount=itemSelection->count();
 	PageItem *currItem;
-	int ObjGroup;
 	struct AlignObjs Object;
 	AObjects.clear();
 	for (uint a = 0; a < selectedItemCount; ++a)
@@ -9125,7 +9124,7 @@
 		currItem = itemSelection->itemAt(a);
 		Object.Objects.clear();
 		currItem->getBoundingRect(&Object.x1, &Object.y1, &Object.x2, &Object.y2);
-		if (currItem->Groups.count() > 0)
+/*		if (currItem->Groups.count() > 0)
 		{
 			ObjGroup = currItem->Groups.top();
 			bool found = false;
@@ -9151,12 +9150,12 @@
 			}
 		}
 		else
-		{
+		{ */
 			Object.Group = 0;
 			Object.ObjNr = currItem->ItemNr;
 			Object.Objects.append(currItem);
 			AObjects.append(Object);
-		}
+//		}
 	}
 	for (int i = 0; i < AObjects.count(); ++i)
 	{
@@ -11934,7 +11933,6 @@
 	}
 	itemSelection->getVisualGroupRect(&x, &y, &w, &h);
 	uint lowestItem = 999999;
-//	uint highestItem = 0;
 	for (uint a=0; a<selectedItemCount; ++a)
 	{
 		currItem = itemSelection->itemAt(a);
@@ -11943,7 +11941,6 @@
 		currItem->gWidth = w;
 		currItem->gHeight = h;
 		lowestItem = qMin(lowestItem, currItem->ItemNr);
-//		highestItem = qMax(highestItem, currItem->ItemNr);
 	}
 	double minx =  std::numeric_limits<double>::max();
 	double miny =  std::numeric_limits<double>::max();
@@ -11958,43 +11955,14 @@
 		miny = qMin(miny, y1);
 		maxx = qMax(maxx, x2);
 		maxy = qMax(maxy, y2);
-/*
-		double lw = 0.0;
-		if (currItem->lineColor() != CommonStrings::None)
-			lw = currItem->lineWidth() / 2.0;
-		if (currItem->rotation() != 0)
-		{
-			FPointArray pb;
-			pb.resize(0);
-			pb.addPoint(FPoint(currItem->xPos()-lw, currItem->yPos()-lw));
-			pb.addPoint(FPoint(currItem->width()+lw*2.0, -lw, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
-			pb.addPoint(FPoint(currItem->width()+lw*2.0, currItem->height()+lw*2.0, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
-			pb.addPoint(FPoint(-lw, currItem->height()+lw*2.0, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
-			for (uint pc = 0; pc < 4; ++pc)
-			{
-				minx = qMin(minx, pb.point(pc).x());
-				miny = qMin(miny, pb.point(pc).y());
-				maxx = qMax(maxx, pb.point(pc).x());
-				maxy = qMax(maxy, pb.point(pc).y());
-			}
-		}
-		else
-		{
-			minx = qMin(minx, currItem->xPos()-lw);
-			miny = qMin(miny, currItem->yPos()-lw);
-			maxx = qMax(maxx, currItem->xPos()-lw + currItem->width()+lw*2.0);
-			maxy = qMax(maxy, currItem->yPos()-lw + currItem->height()+lw*2.0);
-		}
-*/
 		}
 	double gx = minx;
 	double gy = miny;
 	double gw = maxx - minx;
 	double gh = maxy - miny;
-//	PageItem *high = Items->at(highestItem);
 	bool wasUndo = UndoManager::undoEnabled();
 	undoManager->setUndoEnabled(false);
-	int z = itemAdd(PageItem::Group, PageItem::Rectangle, gx, gy, gw, gh, 0, docPrefsData.itemToolPrefs.shapeFillColor, docPrefsData.itemToolPrefs.shapeLineColor, true);
+	int z = itemAdd(PageItem::Group, PageItem::Rectangle, gx, gy, gw, gh, 0, CommonStrings::None, CommonStrings::None, true);
 	PageItem *groupItem = Items->takeAt(z);
 	Items->insert(lowestItem, groupItem);
 	groupItem->setItemName( tr("Group%1").arg(GroupCounter));
@@ -12003,36 +11971,24 @@
 	groupItem->groupHeight = gh;
 	groupItem->LayerID = objectsLayer;
 	undoManager->setUndoEnabled(wasUndo);
-
-//	QMap<int, uint> ObjOrder;
 	for (uint c = 0; c < selectedItemCount; ++c)
 	{
 		currItem = itemSelection->itemAt(c);
-	//	ObjOrder.insert(currItem->ItemNr, c);
 		int d = Items->indexOf(currItem);
 		groupItem->groupItemList.append(Items->takeAt(d));
 	}
-//	QList<uint> Oindex = ObjOrder.values();
-//	for (int c = static_cast<int>(Oindex.count()-1); c > -1; c--)
-//	{
-//		Items->insert(lowestItem+1, itemSelection->itemAt(Oindex[c]));
-//	}
-
 	renumberItemsInListOrder();
 	itemSelection->clear();
 	itemSelection->addItem(groupItem);
-//	itemSelection->prependItem(groupItem);
 	selectedItemCount = itemSelection->count();
-//	SimpleState *ss = new SimpleState(Um::Group, tooltip);
-//	ss->set("GROUP", "group");
-//	ss->set("itemcount", selectedItemCount);
-
-//	for (uint a=0; a<selectedItemCount; ++a)
-//	{
-//		currItem = itemSelection->itemAt(a);
-//		currItem->Groups.push(GroupCounter);
-//		ss->set(QString("item%1").arg(a), currItem->uniqueNr);
-//	}
+	SimpleState *ss = new SimpleState(Um::Group, tooltip);
+	ss->set("GROUP", "group");
+	ss->set("itemcount", selectedItemCount);
+	for (uint a=0; a<selectedItemCount; ++a)
+	{
+		currItem = itemSelection->itemAt(a);
+		ss->set(QString("item%1").arg(a), currItem->uniqueNr);
+	}
 	GroupCounter++;
 	regionsChanged()->update(QRectF(gx-5, gy-5, gw+10, gh+10));
 	emit docChanged();
@@ -12042,7 +11998,7 @@
 		m_ScMW->scrActions["itemGroup"]->setEnabled(false);
 		m_ScMW->scrActions["itemUngroup"]->setEnabled(true);
 	}
-//	undoManager->action(this, ss, Um::SelectionGroup, Um::IGroup);
+	undoManager->action(this, ss, Um::SelectionGroup, Um::IGroup);
 	return groupItem;
 }
 
@@ -12054,7 +12010,6 @@
 		uint docSelectionCount = itemSelection->count();
 		PageItem *currItem;
 		QList<PageItem*> toDelete;
-//		QMap<int, QList<PageItem*> > groupObjects; 
 		for (uint a=0; a < docSelectionCount; ++a)
 		{
 			currItem = itemSelection->itemAt(a);
@@ -12065,7 +12020,6 @@
 		// Remove group control objects
 		setLoading(true);
 		itemSelection->delaySignalsOn();
-//		QList<PageItem*>::iterator it;
 		for (int b = 0; b < toDelete.count(); b++)
 		{
 			currItem = toDelete.at(b);




More information about the scribus-commit mailing list