r16288 by fschmid - Reenabled horizontal and vertical flipping of regular polygon items.

scribus-commit scribus-commit at lists.scribus.net
Fri Jan 21 20:33:37 CET 2011


Author: fschmid
Date: Fri Jan 21 19:33:37 2011
New Revision: 16288

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16288
Log:
Reenabled horizontal and vertical flipping of regular polygon items.

Modified:
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/ui/propertiespalette.cpp

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16288&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Fri Jan 21 19:33:37 2011
@@ -8272,31 +8272,6 @@
 			if (currItem->itemType() != PageItem::Line)
 				MirrorPolyH(currItem);
 			currItem->moveBy(dx, 0, true);
-			currItem->setRedrawBounding();
-			currItem->GrStartX = currItem->width() - currItem->GrStartX;
-			currItem->GrEndX = currItem->width() - currItem->GrEndX;
-		}
-		trans.commit();
-	}
-	else
-	{
-		for (uint a = 0; a < docSelectionCount; ++a)
-		{
-			PageItem* currItem=m_Selection->itemAt(a);
-			if (currItem->isImageFrame() || currItem->isTextFrame() || currItem->isLatexFrame() || currItem->isOSGFrame() || currItem->isSymbol() || currItem->isGroup())
-				currItem->flipImageH();
-			if (currItem->itemType() != PageItem::Line)
-				MirrorPolyH(currItem);
-			else
-			{
-				double ix2, iy2, iw2, ih2, ix, iy, iw, ih;
-				currItem->getBoundingRect(&ix, &iy, &iw, &ih);
-				currItem->rotateBy(currItem->rotation() * -2.0);
-				currItem->setRedrawBounding();
-				currItem->getBoundingRect(&ix2, &iy2, &iw2, &ih2);
-				currItem->moveBy(ix-ix2, iy-iy2, true);
-				currItem->setRedrawBounding();
-			}
 			currItem->GrStartX = currItem->width() - currItem->GrStartX;
 			currItem->GrEndX = currItem->width() - currItem->GrEndX;
 			if (currItem->isArc())
@@ -8312,48 +8287,15 @@
 				currItem->PoLine.translate(-tp2.x(), -tp2.y());
 				AdjustItemSize(currItem);
 			}
-		}
-	}
-	regionsChanged()->update(QRectF());
-	changed();
-	emit firstSelectedItemType(m_Selection->itemAt(0)->itemType());
-}
-
-
-void ScribusDoc::itemSelection_FlipV()
-{
-	uint docSelectionCount=m_Selection->count();
-	if (docSelectionCount == 0)
-		return;
-	if (docSelectionCount > 1)
-	{
-		UndoTransaction trans(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipV, 0, Um::IFlipV));
-		double gx, gy, gh, gw, ix, iy, iw, ih;
-		m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
-		for (uint a = 0; a < docSelectionCount; ++a)
-		{
-			PageItem* currItem=m_Selection->itemAt(a);
-			currItem->getBoundingRect(&ix, &iy, &iw, &ih);
-			double dx =  ((gh / 2.0) -  ((iy - gy) + (ih - iy) / 2.0)) * 2.0;
-			if (currItem->rotation() != 0.0)
-			{
-				double ix2, iy2, iw2, ih2;
-				currItem->rotateBy(currItem->rotation() * -2.0);
-				currItem->setRedrawBounding();
-				currItem->getBoundingRect(&ix2, &iy2, &iw2, &ih2);
-				currItem->moveBy(ix-ix2, iy-iy2, true);
-				currItem->setRedrawBounding();
-			}
-			if (currItem->isImageFrame() || currItem->isTextFrame() || currItem->isLatexFrame() || currItem->isOSGFrame() || currItem->isSymbol() || currItem->isGroup())
-				currItem->flipImageV();
-			if (currItem->itemType() != PageItem::Line)
-				MirrorPolyV(currItem);
-			currItem->moveBy(0, dx, true);
+			else if (currItem->isRegularPolygon())
+			{
+				PageItem_RegularPolygon *ar = currItem->asRegularPolygon();
+				ar->polyRotation *= -1;
+				ar->polyInnerRot *= -1;
+				ar->recalcPath();
+			}
 			currItem->setRedrawBounding();
-			currItem->GrStartY = currItem->height() - currItem->GrStartY;
-			currItem->GrEndY = currItem->height() - currItem->GrEndY;
-		}
-		regionsChanged()->update(QRectF());
+		}
 		trans.commit();
 	}
 	else
@@ -8362,9 +8304,9 @@
 		{
 			PageItem* currItem=m_Selection->itemAt(a);
 			if (currItem->isImageFrame() || currItem->isTextFrame() || currItem->isLatexFrame() || currItem->isOSGFrame() || currItem->isSymbol() || currItem->isGroup())
-				currItem->flipImageV();
+				currItem->flipImageH();
 			if (currItem->itemType() != PageItem::Line)
-				MirrorPolyV(currItem);
+				MirrorPolyH(currItem);
 			else
 			{
 				double ix2, iy2, iw2, ih2, ix, iy, iw, ih;
@@ -8375,6 +8317,65 @@
 				currItem->moveBy(ix-ix2, iy-iy2, true);
 				currItem->setRedrawBounding();
 			}
+			currItem->GrStartX = currItem->width() - currItem->GrStartX;
+			currItem->GrEndX = currItem->width() - currItem->GrEndX;
+			if (currItem->isArc())
+			{
+				PageItem_Arc *ar = currItem->asArc();
+				ar->arcStartAngle = (180 - ar->arcStartAngle) - ar->arcSweepAngle;
+				if (ar->arcStartAngle < 0)
+					ar->arcStartAngle += 360;
+				else if (ar->arcStartAngle > 360)
+					ar->arcStartAngle -= 360;
+				ar->recalcPath();
+				FPoint tp2(getMinClipF(&currItem->PoLine));
+				currItem->PoLine.translate(-tp2.x(), -tp2.y());
+				AdjustItemSize(currItem);
+			}
+			else if (currItem->isRegularPolygon())
+			{
+				PageItem_RegularPolygon *ar = currItem->asRegularPolygon();
+				ar->polyRotation *= -1;
+				ar->polyInnerRot *= -1;
+				ar->recalcPath();
+			}
+		}
+	}
+	regionsChanged()->update(QRectF());
+	changed();
+	emit firstSelectedItemType(m_Selection->itemAt(0)->itemType());
+}
+
+
+void ScribusDoc::itemSelection_FlipV()
+{
+	uint docSelectionCount=m_Selection->count();
+	if (docSelectionCount == 0)
+		return;
+	if (docSelectionCount > 1)
+	{
+		UndoTransaction trans(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipV, 0, Um::IFlipV));
+		double gx, gy, gh, gw, ix, iy, iw, ih;
+		m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
+		for (uint a = 0; a < docSelectionCount; ++a)
+		{
+			PageItem* currItem=m_Selection->itemAt(a);
+			currItem->getBoundingRect(&ix, &iy, &iw, &ih);
+			double dx =  ((gh / 2.0) -  ((iy - gy) + (ih - iy) / 2.0)) * 2.0;
+			if (currItem->rotation() != 0.0)
+			{
+				double ix2, iy2, iw2, ih2;
+				currItem->rotateBy(currItem->rotation() * -2.0);
+				currItem->setRedrawBounding();
+				currItem->getBoundingRect(&ix2, &iy2, &iw2, &ih2);
+				currItem->moveBy(ix-ix2, iy-iy2, true);
+				currItem->setRedrawBounding();
+			}
+			if (currItem->isImageFrame() || currItem->isTextFrame() || currItem->isLatexFrame() || currItem->isOSGFrame() || currItem->isSymbol() || currItem->isGroup())
+				currItem->flipImageV();
+			if (currItem->itemType() != PageItem::Line)
+				MirrorPolyV(currItem);
+			currItem->moveBy(0, dx, true);
 			currItem->GrStartY = currItem->height() - currItem->GrStartY;
 			currItem->GrEndY = currItem->height() - currItem->GrEndY;
 			if (currItem->isArc())
@@ -8390,6 +8391,62 @@
 				FPoint tp2(getMinClipF(&currItem->PoLine));
 				currItem->PoLine.translate(-tp2.x(), -tp2.y());
 				AdjustItemSize(currItem);
+			}
+			else if (currItem->isRegularPolygon())
+			{
+				PageItem_RegularPolygon *ar = currItem->asRegularPolygon();
+				ar->polyRotation = 180.0 - ar->polyRotation;
+				ar->polyRotation *= -1;
+				ar->polyInnerRot *= -1;
+				ar->recalcPath();
+			}
+			currItem->setRedrawBounding();
+		}
+		regionsChanged()->update(QRectF());
+		trans.commit();
+	}
+	else
+	{
+		for (uint a = 0; a < docSelectionCount; ++a)
+		{
+			PageItem* currItem=m_Selection->itemAt(a);
+			if (currItem->isImageFrame() || currItem->isTextFrame() || currItem->isLatexFrame() || currItem->isOSGFrame() || currItem->isSymbol() || currItem->isGroup())
+				currItem->flipImageV();
+			if (currItem->itemType() != PageItem::Line)
+				MirrorPolyV(currItem);
+			else
+			{
+				double ix2, iy2, iw2, ih2, ix, iy, iw, ih;
+				currItem->getBoundingRect(&ix, &iy, &iw, &ih);
+				currItem->rotateBy(currItem->rotation() * -2.0);
+				currItem->setRedrawBounding();
+				currItem->getBoundingRect(&ix2, &iy2, &iw2, &ih2);
+				currItem->moveBy(ix-ix2, iy-iy2, true);
+				currItem->setRedrawBounding();
+			}
+			currItem->GrStartY = currItem->height() - currItem->GrStartY;
+			currItem->GrEndY = currItem->height() - currItem->GrEndY;
+			if (currItem->isArc())
+			{
+				PageItem_Arc *ar = currItem->asArc();
+				ar->arcStartAngle *= -1;
+				ar->arcStartAngle -= ar->arcSweepAngle;
+				if (ar->arcStartAngle < 0)
+					ar->arcStartAngle += 360;
+				else if (ar->arcStartAngle > 360)
+					ar->arcStartAngle -= 360;
+				ar->recalcPath();
+				FPoint tp2(getMinClipF(&currItem->PoLine));
+				currItem->PoLine.translate(-tp2.x(), -tp2.y());
+				AdjustItemSize(currItem);
+			}
+			else if (currItem->isRegularPolygon())
+			{
+				PageItem_RegularPolygon *ar = currItem->asRegularPolygon();
+				ar->polyRotation = 180.0 - ar->polyRotation;
+				ar->polyRotation *= -1;
+				ar->polyInnerRot *= -1;
+				ar->recalcPath();
 			}
 		}
 		regionsChanged()->update(QRectF());

Modified: trunk/Scribus/scribus/ui/propertiespalette.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16288&path=/trunk/Scribus/scribus/ui/propertiespalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette.cpp Fri Jan 21 19:33:37 2011
@@ -1768,8 +1768,6 @@
 		FlipH->setCheckable(false);
 		FlipV->setCheckable(false);
 	}
-	FlipH->setDisabled(i->isRegularPolygon());
-	FlipV->setDisabled(i->isRegularPolygon());
 	setFlippedH(i->imageFlippedH());
 	setFlippedV(i->imageFlippedV());
 	RoVal = i->rotation();
@@ -2144,8 +2142,8 @@
 		//CB Why cant we do this for lines?
 //		FlipH->setEnabled((nr!=-1) && (nr!=5));
 //		FlipV->setEnabled((nr!=-1) && (nr!=5));
-		FlipH->setEnabled(nr!=-1 && nr!=13);
-		FlipV->setEnabled(nr!=-1 && nr!=13);
+		FlipH->setEnabled(nr!=-1);
+		FlipV->setEnabled(nr!=-1);
 		switch (nr)
 		{
 		case -1:
@@ -2281,32 +2279,12 @@
 	//CB Having added the selection and undo transaction to mirrorpolyh/v in doc,
 	//these can be enabled all the time
 	NameEdit->setEnabled(!isMultiple);
-	uint selectedItemCount = doc->m_Selection->count();
-	bool found = false;
-	if (selectedItemCount != 0)
-	{
-		for (uint i = 0; i < selectedItemCount; ++i)
-		{
-		//	if (doc->m_Selection->itemAt(i)->isArc() || doc->m_Selection->itemAt(i)->isRegularPolygon())
-			if (doc->m_Selection->itemAt(i)->isRegularPolygon())
-				found = true;
-			break;
-		}
-	}
-	FlipH->setEnabled(!found);
-	FlipV->setEnabled(!found);
+	FlipH->setEnabled(true);
+	FlipV->setEnabled(true);
 	if (doc->m_Selection->count() > 1)
 	{
 		FlipH->setCheckable( false );
 		FlipV->setCheckable( false );
-//		PageItem *i;
-//		uint lowestItem = 999999;
-//		for (int a=0; a<doc->m_Selection->count(); ++a)
-//		{
-//			i = doc->m_Selection->itemAt(a);
-//			lowestItem = qMin(lowestItem, i->ItemNr);
-//		}
-//		i = doc->Items->at(lowestItem);
 		SetCurItem(doc->m_Selection->itemAt(0));
 	}
 }




More information about the scribus-commit mailing list