r21288 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Fri May 6 09:12:03 UTC 2016
Author: jghali
Date: Fri May 6 09:12:03 2016
New Revision: 21288
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21288
Log:
Improve #14021 fix even more
Modified:
trunk/Scribus/scribus/canvasmode.cpp
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem.h
trunk/Scribus/scribus/pageitem_line.cpp
trunk/Scribus/scribus/selection.cpp
Modified: trunk/Scribus/scribus/canvasmode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21288&path=/trunk/Scribus/scribus/canvasmode.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode.cpp (original)
+++ trunk/Scribus/scribus/canvasmode.cpp Fri May 6 09:12:03 2016
@@ -372,7 +372,7 @@
psx->setTransform(t, true);
w = currItem->visualWidth();
h = currItem->visualHeight();
- x = -currItem->visualLineWidth() / 2.0;
+ x = currItem->asLine() ? 0 : (-currItem->visualLineWidth() / 2.0);
y = -currItem->visualLineWidth() / 2.0;
psx->setBrush(Qt::NoBrush);
QRectF drRect = QRectF(x, y, w, h).normalized();
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21288&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Fri May 6 09:12:03 2016
@@ -9126,7 +9126,7 @@
return isLine() ? extraSpace : m_height + extraSpace;
}
-double PageItem::visualLineWidth()
+double PageItem::visualLineWidth() const
{
double extraSpace = 0.0;
if (NamedLStyle.isEmpty())
Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21288&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Fri May 6 09:12:03 2016
@@ -492,7 +492,7 @@
double height() const { return m_height; }
double visualWidth() const;
double visualHeight() const;
- double visualLineWidth();
+ double visualLineWidth() const;
void setWidth(const double);
void setHeight(const double);
void setWidthHeight(const double, const double, bool drawingOnly);
Modified: trunk/Scribus/scribus/pageitem_line.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21288&path=/trunk/Scribus/scribus/pageitem_line.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_line.cpp (original)
+++ trunk/Scribus/scribus/pageitem_line.cpp Fri May 6 09:12:03 2016
@@ -174,7 +174,38 @@
void PageItem_Line::getBoundingRect(double *x1, double *y1, double *x2, double *y2) const
{
- PageItem::getBoundingRect(x1, y1, x2, y2);
+ double minx = std::numeric_limits<double>::max();
+ double miny = std::numeric_limits<double>::max();
+ double maxx = -std::numeric_limits<double>::max();
+ double maxy = -std::numeric_limits<double>::max();
+ if (m_rotation != 0)
+ {
+ FPointArray pb;
+ pb.resize(0);
+ pb.addPoint(FPoint(0, -m_lineWidth / 2.0, m_xPos, m_yPos, m_rotation, 1.0, 1.0));
+ pb.addPoint(FPoint(m_width, -m_lineWidth / 2.0, m_xPos, m_yPos, m_rotation, 1.0, 1.0));
+ pb.addPoint(FPoint(m_width, +m_lineWidth / 2.0, m_xPos, m_yPos, m_rotation, 1.0, 1.0));
+ pb.addPoint(FPoint(0, +m_lineWidth / 2.0, m_xPos, m_yPos, m_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());
+ }
+ *x1 = minx;
+ *y1 = miny;
+ *x2 = maxx;
+ *y2 = maxy;
+ }
+ else
+ {
+ *x1 = m_xPos;
+ *y1 = m_yPos - qMax(1.0, m_lineWidth) / 2.0;
+ *x2 = m_xPos + m_width;
+ *y2 = m_yPos + qMax(1.0, m_lineWidth) / 2.0;
+ }
+
QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
if (m_startArrowIndex != 0)
{
@@ -230,7 +261,63 @@
void PageItem_Line::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
{
- PageItem::getVisualBoundingRect(x1, y1, x2, y2);
+ double minx = std::numeric_limits<double>::max();
+ double miny = std::numeric_limits<double>::max();
+ double maxx = -std::numeric_limits<double>::max();
+ double maxy = -std::numeric_limits<double>::max();
+ double extraSpace = 0.0;
+ if (NamedLStyle.isEmpty())
+ {
+ if ((lineColor() != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0))
+ {
+ extraSpace = m_lineWidth / 2.0;
+ }
+ if ((!patternStrokeVal.isEmpty()) && (m_Doc->docPatterns.contains(patternStrokeVal)) && (patternStrokePath))
+ {
+ ScPattern *pat = &m_Doc->docPatterns[patternStrokeVal];
+ QTransform mat;
+ mat.rotate(patternStrokeRotation);
+ mat.scale(patternStrokeScaleX / 100.0, patternStrokeScaleY / 100.0);
+ QRectF p1R = QRectF(0, 0, pat->width / 2.0, pat->height / 2.0);
+ QRectF p2R = mat.map(p1R).boundingRect();
+ extraSpace = p2R.height();
+ }
+ }
+ else
+ {
+ multiLine ml = m_Doc->MLineStyles[NamedLStyle];
+ struct SingleLine& sl = ml[ml.size()-1];
+ if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
+ extraSpace = sl.Width / 2.0;
+ }
+ if (m_rotation != 0)
+ {
+ FPointArray pb;
+ pb.resize(0);
+ pb.addPoint(FPoint(0.0, -extraSpace, xPos(), yPos(), m_rotation, 1.0, 1.0));
+ pb.addPoint(FPoint(visualWidth(), -extraSpace, xPos(), yPos(), m_rotation, 1.0, 1.0));
+ pb.addPoint(FPoint(visualWidth(), +extraSpace, xPos(), yPos(), m_rotation, 1.0, 1.0));
+ pb.addPoint(FPoint(0.0, +extraSpace, xPos(), yPos(), m_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());
+ }
+ *x1 = minx;
+ *y1 = miny;
+ *x2 = maxx;
+ *y2 = maxy;
+ }
+ else
+ {
+ *x1 = m_xPos;
+ *y1 = m_yPos - extraSpace;
+ *x2 = m_xPos + visualWidth();
+ *y2 = m_yPos + extraSpace;
+ }
+
QRectF totalRect(QPointF(*x1, *y1), QPointF(*x2, *y2));
if (m_startArrowIndex != 0)
{
Modified: trunk/Scribus/scribus/selection.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21288&path=/trunk/Scribus/scribus/selection.cpp
==============================================================================
--- trunk/Scribus/scribus/selection.cpp (original)
+++ trunk/Scribus/scribus/selection.cpp Fri May 6 09:12:03 2016
@@ -397,32 +397,18 @@
currItem = itemAt(gc);
if (currItem->rotation() != 0)
{
- FPointArray pb(4);
- pb.setPoint(0, FPoint(currItem->xPos(), currItem->yPos()));
- pb.setPoint(1, FPoint(currItem->width(), 0.0, currItem->xPos(), currItem->yPos(), currItem->rotation(), 1.0, 1.0));
- pb.setPoint(2, FPoint(currItem->width(), currItem->height(), currItem->xPos(), currItem->yPos(), currItem->rotation(), 1.0, 1.0));
- pb.setPoint(3, FPoint(0.0, currItem->height(), currItem->xPos(), currItem->yPos(), 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());
- }
+ QRectF itRect(currItem->getBoundingRect());
+ vminx = qMin(vminx, itRect.x());
+ vminy = qMin(vminy, itRect.y());
+ vmaxx = qMax(vmaxx, itRect.right());
+ vmaxy = qMax(vmaxy, itRect.bottom());
// Same for visual
-// pb.setPoint(0, FPoint(currItem->visualXPos(), currItem->visualYPos()));
-// pb.setPoint(1, FPoint(currItem->visualWidth(), 0.0, currItem->visualXPos(), currItem->visualYPos(), currItem->rotation(), 1.0, 1.0));
-// pb.setPoint(2, FPoint(currItem->visualWidth(), currItem->visualHeight(), currItem->visualXPos(), currItem->visualYPos(), currItem->rotation(), 1.0, 1.0));
-// pb.setPoint(3, FPoint(0.0, currItem->visualHeight(), currItem->visualXPos(), currItem->visualYPos(), currItem->rotation(), 1.0, 1.0));
- QRectF itRect(currItem->getVisualBoundingRect());
-// for (uint pc = 0; pc < 4; ++pc)
- {
- vminx = qMin(vminx, itRect.x());
- vminy = qMin(vminy, itRect.y());
- vmaxx = qMax(vmaxx, itRect.right());
- vmaxy = qMax(vmaxy, itRect.bottom());
- }
+ QRectF itVisualRect(currItem->getVisualBoundingRect());
+ vminx = qMin(vminx, itVisualRect.x());
+ vminy = qMin(vminy, itVisualRect.y());
+ vmaxx = qMax(vmaxx, itVisualRect.right());
+ vmaxy = qMax(vmaxy, itVisualRect.bottom());
}
else
{
More information about the scribus-commit
mailing list