r23320 by jghali - Improve drawing of item outline when moving item inside group
scribus-commit
scribus-commit at lists.scribus.net
Mon Nov 4 08:23:17 UTC 2019
Author: jghali
Date: Mon Nov 4 08:23:16 2019
New Revision: 23320
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23320
Log:
Improve drawing of item outline when moving item inside group
Modified:
trunk/Scribus/scribus/canvasmode.cpp
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem.h
Modified: trunk/Scribus/scribus/canvasmode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23320&path=/trunk/Scribus/scribus/canvasmode.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode.cpp (original)
+++ trunk/Scribus/scribus/canvasmode.cpp Mon Nov 4 08:23:16 2019
@@ -284,9 +284,9 @@
if (m_doc->m_Selection->isMultipleSelection())
{
PageItem *curItem(nullptr);
- for(int a=0; a<m_doc->m_Selection->count(); ++a)
+ for(int i = 0; i < m_doc->m_Selection->count(); ++i)
{
- curItem = m_doc->m_Selection->itemAt(a);
+ curItem = m_doc->m_Selection->itemAt(i);
if (drawHandles)
drawHandles = !curItem->locked();
@@ -296,9 +296,9 @@
{
int docSelectionCount = m_doc->m_Selection->count();
PageItem *currItem;
- for (int a=0; a<docSelectionCount; ++a)
- {
- currItem = m_doc->m_Selection->itemAt(a);
+ for (int i = 0; i < docSelectionCount; ++i)
+ {
+ currItem = m_doc->m_Selection->itemAt(i);
if (!m_doc->Items->contains(currItem))
continue;
psx->save();
@@ -476,7 +476,6 @@
p->save();
p->scale(m_canvas->scale(), m_canvas->scale());
p->translate(-m_doc->minCanvasCoordinate.x(), -m_doc->minCanvasCoordinate.y());
-
if (m_doc->m_Selection->count() == 1)
{
@@ -547,34 +546,26 @@
}
#endif // GESTURE_FRAME_PREVIEW
{
-// QRect vr(m_canvas->exposedRect());
-// QImage img(vr.width(), vr.height(), QImage::Format_ARGB32);
-// ScPainter scp(&img,vr. width(), vr.height());
-// scp.translate(-m_doc->minCanvasCoordinate.x(), -m_doc->minCanvasCoordinate.y());
-//// scp.translate(currItem->xPos(), currItem->yPos());
-//// scp.translate(deltax, deltay);
-//// scp.scale(scalex, scaley);
-//// scp.scale(m_canvas->scale(), m_canvas->scale());
-// currItem->invalid = false;
-// currItem->DrawObj(&scp, vr);
-// p->drawImage(vr, img, img.rect() );
-
+ QTransform itemTrans = currItem->getTransform(deltax, deltay);
+ double visualWidth = currItem->visualWidth();
+ double visualHeight = currItem->visualHeight();
+ double visualLineWidth = currItem->visualLineWidth();
+ double matRot = getRotationDFromMatrix(itemTrans);
+ double matScaleX, matScaleY;
+ getScaleFromMatrix(itemTrans, matScaleX, matScaleY);
+
if (currItem->isGroup())
{
p->save();
p->setBrush(m_brush["outline"]);
p->setPen(m_pen["outline"]);
- p->translate(currItem->xPos(), currItem->yPos());
- p->translate(deltax, deltay);
- if (currItem->rotation() != 0)
- {
+ p->setWorldTransform(itemTrans, true);
+ if (matRot != 0)
p->setRenderHint(QPainter::Antialiasing);
- p->rotate(currItem->rotation());
- }
p->scale(scalex, scaley);
- p->drawRect(QRectF(0.0, 0.0, currItem->visualWidth(), currItem->visualHeight()));
+ p->drawRect(QRectF(0.0, 0.0, visualWidth, visualHeight));
p->setClipping(true);
- p->setClipRect(QRectF(0.0, 0.0, currItem->visualWidth(), currItem->visualHeight()));
+ p->setClipRect(QRectF(0.0, 0.0, visualWidth, visualHeight));
PageItem_Group* gItem = currItem->asGroupFrame();
int itemCountG = gItem->groupItemList.count();
if (itemCountG < m_canvas->moveWithFullOutlinesThreshold)
@@ -601,7 +592,6 @@
p->rotate(currItem->rotation());
}
p->drawPath(currItem->PoLine.toQPainterPath(false));
- // currItem->DrawPolyL(p, currItem->Clip);
p->restore();
}
}
@@ -616,34 +606,24 @@
p->save();
p->setBrush(m_brush["outline"]);
p->setPen(m_pen["outline"]);
- p->translate(currItem->xPos(), currItem->yPos());
- p->translate(deltax, deltay);
- if (currItem->rotation() != 0)
- {
+ p->setWorldTransform(itemTrans, true);
+ if (matRot != 0)
p->setRenderHint(QPainter::Antialiasing);
- p->rotate(currItem->rotation());
- }
+ p->scale(scalex /** matScaleX*/, scaley /** matScaleY*/);
if (currItem->isLine())
- p->translate(0, -currItem->visualLineWidth() / 2.0);
+ p->drawRect(QRectF(0.0, -visualLineWidth / 2.0, currItem->visualWidth(), currItem->visualHeight()));
else
- p->translate(-currItem->visualLineWidth() / 2.0, -currItem->visualLineWidth() / 2.0);
- p->scale(scalex, scaley);
- p->drawRect(QRectF(0.0, 0.0, currItem->visualWidth(), currItem->visualHeight()));
+ p->drawRect(QRectF(-visualLineWidth / 2.0, -visualLineWidth / 2.0, currItem->visualWidth(), currItem->visualHeight()));
p->restore();
p->save();
p->setBrush(m_brush["outline"]);
p->setPen(m_pen["outline"]);
- p->translate(currItem->xPos(), currItem->yPos());
- p->translate(deltax, deltay);
- if (currItem->rotation() != 0)
- {
+ p->setWorldTransform(itemTrans, true);
+ if (matRot != 0)
p->setRenderHint(QPainter::Antialiasing);
- p->rotate(currItem->rotation());
- }
- p->scale(scalex, scaley);
+ p->scale(scalex /** matScaleX*/, scaley /** matScaleY*/);
p->drawPath(currItem->PoLine.toQPainterPath(false));
- // currItem->DrawPolyL(p, currItem->Clip);
p->restore();
}
}
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23320&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Mon Nov 4 08:23:16 2019
@@ -8769,6 +8769,71 @@
return result;
}
+QTransform PageItem::getTransform(double deltaX, double deltaY) const
+{
+ QTransform result;
+ if (isGroupChild())
+ {
+ QList<const PageItem*> itList;
+ const PageItem* ite = this;
+ while (ite->isGroupChild())
+ {
+ itList.prepend(ite);
+ ite = ite->Parent;
+ }
+ result.translate(ite->xPos(), ite->yPos());
+ result.rotate(ite->rotation());
+ /* if (ite->isGroup() || ite->isSymbol())
+ {
+ if (ite->imageFlippedH())
+ {
+ result.translate(ite->width(), 0);
+ result.scale(-1, 1);
+ }
+ if (ite->imageFlippedV())
+ {
+ result.translate(0, ite->height());
+ result.scale(1, -1);
+ }
+ }*/
+ if (ite == this)
+ return result;
+ if (ite->isGroup())
+ result.scale(ite->width() / ite->groupWidth, ite->height() / ite->groupHeight);
+ for (int i = 0; i < itList.count(); i++)
+ {
+ ite = itList.at(i);
+ result.translate(ite->gXpos, ite->gYpos);
+ if (ite == this)
+ result.translate(deltaX, deltaY);
+ result.rotate(ite->rotation());
+ /* if (ite->isGroup() || ite->isSymbol())
+ {
+ if (ite->imageFlippedH())
+ {
+ result.translate(ite->width(), 0);
+ result.scale(-1, 1);
+ }
+ if (ite->imageFlippedV())
+ {
+ result.translate(0, ite->height());
+ result.scale(1, -1);
+ }
+ }*/
+ if (ite == this)
+ return result;
+ if (ite->isGroup())
+ result.scale(ite->width() / ite->groupWidth, ite->height() / ite->groupHeight);
+ }
+ }
+ else
+ {
+ result.translate(m_xPos + deltaX, m_yPos + deltaY);
+ result.rotate(m_rotation);
+ }
+ return result;
+}
+
QRectF PageItem::getBoundingRect() const
{
double x,y,x2,y2;
Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23320&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Mon Nov 4 08:23:16 2019
@@ -398,6 +398,7 @@
QTransform getGroupTransform() const;
void getTransform(QTransform& mat) const;
QTransform getTransform() const;
+ QTransform getTransform(double deltaX, double deltaY) const;
/// invalidates current layout information
virtual void invalidateLayout() { invalid = true; }
More information about the scribus-commit
mailing list