r15666 by jghali - update rotation value in PP correctly when using rotation mode
scribus-commit
scribus-commit at lists.scribus.net
Thu Oct 28 01:02:00 CEST 2010
Author: jghali
Date: Wed Oct 27 23:02:00 2010
New Revision: 15666
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15666
Log:
update rotation value in PP correctly when using rotation mode
Modified:
branches/ScribusOIF/scribus/canvasmode_rotate.cpp
branches/ScribusOIF/scribus/scribusdoc.cpp
branches/ScribusOIF/scribus/scribusdoc.h
Modified: branches/ScribusOIF/scribus/canvasmode_rotate.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15666&path=/branches/ScribusOIF/scribus/canvasmode_rotate.cpp
==============================================================================
--- branches/ScribusOIF/scribus/canvasmode_rotate.cpp (original)
+++ branches/ScribusOIF/scribus/canvasmode_rotate.cpp Wed Oct 27 23:02:00 2010
@@ -316,24 +316,20 @@
{
m_view->startGroupTransaction(Um::Rotate, "", Um::IRotate);
}
- double newW = xy2Deg(mousePointDoc.x()-m_view->RCenter.x(), mousePointDoc.y()-m_view->RCenter.y()); //xy2Deg(m->x()/sc - m_view->RCenter.x(), m->y()/sc - m_view->RCenter.y());
+ double angle = 0;
+ double newW = xy2Deg(mousePointDoc.x()-m_view->RCenter.x(), mousePointDoc.y()-m_view->RCenter.y()); //xy2Deg(m->x()/sc - m_view->RCenter.x(), m->y()/sc - m_view->RCenter.y());
if (m->modifiers() & Qt::ControlModifier)
{
newW=constrainAngle(newW, m_doc->opToolPrefs().constrain);
m_view->oldW=constrainAngle(m_view->oldW, m_doc->opToolPrefs().constrain);
//RotateGroup uses MoveBy so its pretty hard to constrain the result
- if (m_doc->m_Selection->isMultipleSelection())
- m_doc->rotateGroup(newW-m_view->oldW, m_view->RCenter);
- else
- m_doc->RotateItem(newW, currItem->ItemNr);
+ angle = m_doc->m_Selection->isMultipleSelection() ? (newW-m_view->oldW) : newW;
}
else
{
- if (m_doc->m_Selection->isMultipleSelection())
- m_doc->rotateGroup(newW - m_view->oldW, m_view->RCenter);
- else
- m_doc->RotateItem(currItem->rotation() - (m_view->oldW - newW), currItem->ItemNr);
- }
+ angle = m_doc->m_Selection->isMultipleSelection() ? (newW - m_view->oldW) : (currItem->rotation() - (m_view->oldW - newW));
+ }
+ m_doc->itemSelection_Rotate(angle);
m_view->oldW = newW;
m_canvas->setRenderModeUseBuffer(false);
if (!m_doc->m_Selection->isMultipleSelection())
Modified: branches/ScribusOIF/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15666&path=/branches/ScribusOIF/scribus/scribusdoc.cpp
==============================================================================
--- branches/ScribusOIF/scribus/scribusdoc.cpp (original)
+++ branches/ScribusOIF/scribus/scribusdoc.cpp Wed Oct 27 23:02:00 2010
@@ -8285,6 +8285,23 @@
emit firstSelectedItemType(m_Selection->itemAt(0)->itemType());
}
+void ScribusDoc::itemSelection_Rotate(double angle, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
+ assert(itemSelection!=0);
+
+ if (itemSelection->count() == 0) return;
+
+ if (itemSelection->count() > 1)
+ {
+ rotateGroup(angle, itemSelection);
+ }
+ else if (itemSelection->count() == 1)
+ {
+ RotateItem(angle, itemSelection->itemAt(0));
+ }
+ changed();
+}
void ScribusDoc::itemSelection_ChangePreviewResolution(int id)
{
@@ -11335,13 +11352,36 @@
regionsChanged()->update(OldRect.adjusted(-10, -10, 20, 20));
}
-
-void ScribusDoc::rotateGroup(double angle, FPoint RCenter)
+void ScribusDoc::rotateGroup(double angle, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
+ Q_ASSERT(itemSelection!=0);
+
+ double gx, gy, gh, gw;
+ FPoint rotationPoint(0, 0);
+ itemSelection->getGroupRect(&gx, &gy, &gw, &gh);
+ if (this->rotMode == 0)
+ rotationPoint = FPoint(gx, gy);
+ if (this->rotMode == 1)
+ rotationPoint = FPoint(gx, gy);
+ if (this->rotMode == 2)
+ rotationPoint = FPoint(gx + gw / 2.0, gy + gh / 2.0);
+ if (this->rotMode == 3)
+ rotationPoint = FPoint(gx, gy+gh);
+ if (this->rotMode == 4)
+ rotationPoint = FPoint(gx+gw, gy+gh);
+ rotateGroup(angle, rotationPoint, itemSelection);
+}
+
+void ScribusDoc::rotateGroup(double angle, FPoint RCenter, Selection* customSelection)
{
double gxS, gyS, ghS, gwS;
double sc = 1; // FIXME:av Scale;
PageItem* currItem;
- m_Selection->getGroupRect(&gxS, &gyS, &gwS, &ghS);
+ Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
+ Q_ASSERT(itemSelection!=0);
+
+ itemSelection->getGroupRect(&gxS, &gyS, &gwS, &ghS);
QTransform ma;
ma.translate(RCenter.x(), RCenter.y());
ma.scale(1, 1);
@@ -11350,18 +11390,18 @@
// gyS -= minCanvasCoordinate.y();
QRect oldR = QRect(static_cast<int>(gxS*sc-5), static_cast<int>(gyS*sc-5), static_cast<int>(gwS*sc+10), static_cast<int>(ghS*sc+10));
FPoint n;
- for (int a = 0; a < m_Selection->count(); ++a)
- {
- currItem = m_Selection->itemAt(a);
+ for (int a = 0; a < itemSelection->count(); ++a)
+ {
+ currItem = itemSelection->itemAt(a);
n = FPoint(currItem->xPos() - RCenter.x(), currItem->yPos() - RCenter.y());
currItem->setXYPos(ma.m11() * n.x() + ma.m21() * n.y() + ma.dx(), ma.m22() * n.y() + ma.m12() * n.x() + ma.dy());
currItem->rotateBy(angle);
setRedrawBounding(currItem);
}
- currItem = m_Selection->itemAt(0);
+ currItem = itemSelection->itemAt(0);
GroupOnPage(currItem);
- m_Selection->setGroupRect();
- m_Selection->getGroupRect(&gxS, &gyS, &gwS, &ghS);
+ itemSelection->setGroupRect();
+ itemSelection->getGroupRect(&gxS, &gyS, &gwS, &ghS);
// gxS -= minCanvasCoordinate.x();
// gyS -= minCanvasCoordinate.y();
regionsChanged()->update(QRectF(gxS-5, gyS-5, gwS+10, ghS+10).unite(oldR));
Modified: branches/ScribusOIF/scribus/scribusdoc.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15666&path=/branches/ScribusOIF/scribus/scribusdoc.h
==============================================================================
--- branches/ScribusOIF/scribus/scribusdoc.h (original)
+++ branches/ScribusOIF/scribus/scribusdoc.h Wed Oct 27 23:02:00 2010
@@ -1002,7 +1002,8 @@
bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
void AdjustItemSize(PageItem *currItem);
void moveGroup(double x, double y, bool fromMP = false, Selection* customSelection = 0);
- void rotateGroup(double angle, FPoint RCenter);
+ void rotateGroup(double angle, Selection* customSelection = 0);
+ void rotateGroup(double angle, FPoint RCenter, Selection* customSelection = 0);
void scaleGroup(double scx, double scy, bool scaleText=true, Selection* customSelection = 0);
//! \brief Get a list of frames of certain type
QMap<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType);
@@ -1245,6 +1246,7 @@
void itemSelection_ApplyImageEffects(ScImageEffectList& newEffectList, Selection* customSelection=0);
void itemSelection_FlipH();
void itemSelection_FlipV();
+ void itemSelection_Rotate(double angle, Selection* customSelection = 0);
void itemSelection_DoHyphenate();
void itemSelection_DoDeHyphenate();
void itemSelection_SendToLayer(int layerID);
More information about the scribus-commit
mailing list