r23410 by jghali - Simplify visualXPos(), visualYPos(), visualWidth() and visualHeight() implementation by reusing visualLineWidth()
scribus-commit
scribus-commit at lists.scribus.net
Tue Dec 10 05:16:58 UTC 2019
Author: jghali
Date: Tue Dec 10 05:16:58 2019
New Revision: 23410
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23410
Log:
Simplify visualXPos(), visualYPos(), visualWidth() and visualHeight() implementation by reusing visualLineWidth()
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem.h
trunk/Scribus/scribus/pageitem_line.cpp
trunk/Scribus/scribus/pageitem_line.h
trunk/Scribus/scribus/pageitem_pathtext.cpp
trunk/Scribus/scribus/pageitem_pathtext.h
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23410&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Tue Dec 10 05:16:58 2019
@@ -8954,42 +8954,7 @@
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))
- {
- if (isLine() && (PLineEnd == Qt::FlatCap))
- extraSpace = 0.0;
- else
- {
- extraSpace = m_lineWidth / 2.0;
- if ((extraSpace == 0.0) && m_Doc->view()) // Hairline case
- extraSpace = 0.5 / m_Doc->view()->scale();
- }
- }
- 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];
- const SingleLine& sl = ml.last();
- if (sl.Color != CommonStrings::None)
- {
- extraSpace = sl.Width / 2.0;
- if ((extraSpace == 0.0) && m_Doc->view()) // Hairline case
- extraSpace = 0.5 / m_Doc->view()->scale();
- }
- }
+ double extraSpace = visualLineWidth() / 2.0;
if (m_rotation != 0)
{
FPointArray pb;
@@ -9021,160 +8986,26 @@
double PageItem::visualXPos() const
{
- double extraSpace = 0.0;
- if (!isLine())
- {
- if (NamedLStyle.isEmpty())
- {
- if ((lineColor() != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0))
- {
- extraSpace = m_lineWidth / 2.0;
- if ((extraSpace == 0.0) && m_Doc->view()) // Hairline case
- extraSpace = 0.5 / m_Doc->view()->scale();
- }
- 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];
- const SingleLine& sl = ml.last();
- if (sl.Color != CommonStrings::None)
- {
- extraSpace = sl.Width / 2.0;
- if ((extraSpace == 0.0) && m_Doc->view()) // Hairline case
- extraSpace = 0.5 / m_Doc->view()->scale();
- }
- }
- }
- if (isPathText())
- return qMin(m_xPos + QRectF(Clip.boundingRect()).x(), m_xPos - extraSpace);
+ double extraSpace = visualLineWidth() / 2.0;
return m_xPos - extraSpace;
}
double PageItem::visualYPos() const
{
- double extraSpace = 0.0;
- if (NamedLStyle.isEmpty())
- {
- if ((lineColor() != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0))
- {
- extraSpace = m_lineWidth / 2.0;
- if ((extraSpace == 0.0) && m_Doc->view()) // Hairline case
- extraSpace = 0.5 / m_Doc->view()->scale();
- }
- 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];
- const SingleLine& sl = ml.last();
- if (sl.Color != CommonStrings::None)
- {
- extraSpace = sl.Width / 2.0;
- if ((extraSpace == 0.0) && m_Doc->view()) // Hairline case
- extraSpace = 0.5 / m_Doc->view()->scale();
- }
- }
- if (isPathText())
- return qMin(m_yPos + QRectF(Clip.boundingRect()).y(), m_yPos - extraSpace);
+ double extraSpace = visualLineWidth() / 2.0;
return m_yPos - extraSpace;
}
double PageItem::visualWidth() const
{
- double extraSpace = 0.0;
- if (!isLine())
- {
- if (NamedLStyle.isEmpty())
- {
- if ((lineColor() != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0))
- {
- extraSpace = m_lineWidth;
- if ((extraSpace == 0.0) && m_Doc->view()) // Hairline case
- extraSpace = 1.0 / m_Doc->view()->scale();
- }
- 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, pat->height);
- QRectF p2R = mat.map(p1R).boundingRect();
- extraSpace = p2R.height();
- }
- }
- else
- {
- multiLine ml = m_Doc->MLineStyles[NamedLStyle];
- const SingleLine& sl = ml.last();
- if (sl.Color != CommonStrings::None)
- {
- extraSpace = sl.Width;
- if ((extraSpace == 0.0) && m_Doc->view()) // Hairline case
- extraSpace = 1.0 / m_Doc->view()->scale();
- }
- }
- }
- if (isPathText())
- return qMax(QRectF(Clip.boundingRect()).width(), m_width + extraSpace);
+ double extraSpace = visualLineWidth();
return m_width + extraSpace;
}
double PageItem::visualHeight() const
{
- double extraSpace = 0.0;
- if (NamedLStyle.isEmpty())
- {
- if ((lineColor() != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0))
- {
- extraSpace = m_lineWidth;
- if ((extraSpace == 0.0) && m_Doc->view()) // Hairline case
- extraSpace = 1.0 / m_Doc->view()->scale();
- }
- 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, pat->height);
- 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)
- {
- extraSpace = sl.Width;
- if ((extraSpace == 0.0) && m_Doc->view()) // Hairline case
- extraSpace = 1.0 / m_Doc->view()->scale();
- }
- }
- if (isPathText())
- return qMax(QRectF(Clip.boundingRect()).height(), m_height + extraSpace);
- return isLine() ? extraSpace : m_height + extraSpace;
+ double extraSpace = visualLineWidth();
+ return m_height + extraSpace;
}
double PageItem::visualLineWidth() const
Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23410&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Tue Dec 10 05:16:58 2019
@@ -501,8 +501,8 @@
//Position
double xPos() const { return m_xPos; }
double yPos() const { return m_yPos; }
- double visualXPos() const;
- double visualYPos() const;
+ virtual double visualXPos() const;
+ virtual double visualYPos() const;
FPoint xyPos() const { return FPoint(m_xPos, m_yPos); }
void setXPos(double, bool drawingOnly=false);
void setYPos(double, bool drawingOnly=false);
@@ -511,8 +511,8 @@
//Size
double width() const override { return m_width; }
double height() const override { return m_height; }
- double visualWidth() const;
- double visualHeight() const;
+ virtual double visualWidth() const;
+ virtual double visualHeight() const;
double visualLineWidth() const;
void setWidth(double);
void setHeight(double);
Modified: trunk/Scribus/scribus/pageitem_line.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23410&path=/trunk/Scribus/scribus/pageitem_line.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_line.cpp (original)
+++ trunk/Scribus/scribus/pageitem_line.cpp Tue Dec 10 05:16:58 2019
@@ -478,3 +478,25 @@
return arrowRect;
}
+
+double PageItem_Line::visualXPos() const
+{
+ return m_xPos;
+}
+
+double PageItem_Line::visualYPos() const
+{
+ double extraSpace = visualLineWidth() / 2.0;
+ return m_yPos - extraSpace;
+}
+
+double PageItem_Line::visualWidth() const
+{
+ return m_width;
+}
+
+double PageItem_Line::visualHeight() const
+{
+ double extraSpace = visualLineWidth();
+ return extraSpace;
+}
Modified: trunk/Scribus/scribus/pageitem_line.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23410&path=/trunk/Scribus/scribus/pageitem_line.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_line.h (original)
+++ trunk/Scribus/scribus/pageitem_line.h Tue Dec 10 05:16:58 2019
@@ -58,6 +58,11 @@
QRectF getEndArrowBoundingRect() const override;
QRectF getEndArrowOldBoundingRect() const override;
+
+ double visualXPos() const override;
+ double visualYPos() const override;
+ double visualWidth() const override;
+ double visualHeight() const override;
protected:
void DrawObj_Item(ScPainter *p, QRectF e) override;
Modified: trunk/Scribus/scribus/pageitem_pathtext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23410&path=/trunk/Scribus/scribus/pageitem_pathtext.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_pathtext.cpp (original)
+++ trunk/Scribus/scribus/pageitem_pathtext.cpp Tue Dec 10 05:16:58 2019
@@ -421,3 +421,27 @@
totalRect = totalRect.united(QRectF(clipTrans.mapRect(Clip.boundingRect())));
totalRect.getCoords(x1, y1, x2, y2);
}
+
+double PageItem_PathText::visualXPos() const
+{
+ double extraSpace = visualLineWidth() / 2.0;
+ return qMin(m_xPos + QRectF(Clip.boundingRect()).x(), m_xPos - extraSpace);
+}
+
+double PageItem_PathText::visualYPos() const
+{
+ double extraSpace = visualLineWidth() / 2.0;
+ return qMin(m_yPos + QRectF(Clip.boundingRect()).y(), m_yPos - extraSpace);
+}
+
+double PageItem_PathText::visualWidth() const
+{
+ double extraSpace = visualLineWidth();
+ return qMax(QRectF(Clip.boundingRect()).width(), m_width + extraSpace);
+}
+
+double PageItem_PathText::visualHeight() const
+{
+ double extraSpace = visualLineWidth();
+ return qMax(QRectF(Clip.boundingRect()).height(), m_height + extraSpace);
+}
Modified: trunk/Scribus/scribus/pageitem_pathtext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23410&path=/trunk/Scribus/scribus/pageitem_pathtext.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_pathtext.h (original)
+++ trunk/Scribus/scribus/pageitem_pathtext.h Tue Dec 10 05:16:58 2019
@@ -49,6 +49,11 @@
void getVisualBoundingRect(double *x1, double *y1, double *x2, double *y2) const override;
+ double visualXPos() const override;
+ double visualYPos() const override;
+ double visualWidth() const override;
+ double visualHeight() const override;
+
protected:
void DrawObj_Item(ScPainter *p, QRectF e) override;
More information about the scribus-commit
mailing list