r23038 by jghali - Add const qualifier to a few FPointArray methods + some refactoring
scribus-commit
scribus-commit at lists.scribus.net
Fri Jun 21 11:44:19 UTC 2019
Author: jghali
Date: Fri Jun 21 11:44:19 2019
New Revision: 23038
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23038
Log:
Add const qualifier to a few FPointArray methods + some refactoring
Modified:
trunk/Scribus/scribus/canvasmode_drawbezier.cpp
trunk/Scribus/scribus/fpointarray.cpp
trunk/Scribus/scribus/fpointarray.h
trunk/Scribus/scribus/plugins/import/ai/importai.cpp
trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
trunk/Scribus/scribus/scribusview.cpp
trunk/Scribus/scribus/ui/arrowchooser.cpp
trunk/Scribus/scribus/ui/extimageprops.cpp
trunk/Scribus/scribus/util_math.cpp
trunk/Scribus/scribus/util_math.h
Modified: trunk/Scribus/scribus/canvasmode_drawbezier.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23038&path=/trunk/Scribus/scribus/canvasmode_drawbezier.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawbezier.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_drawbezier.cpp Fri Jun 21 11:44:19 2019
@@ -93,7 +93,7 @@
}
else
{
- m_doc->sizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem, false, false);
+ m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false);
// currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2.0, 1)));
m_doc->adjustItemSize(currItem);
currItem->ContourLine = currItem->PoLine.copy();
@@ -168,7 +168,7 @@
if (!currItem)
return;
- m_doc->sizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem, false, false);
+ m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false);
currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2.0, 1.0)));
m_doc->adjustItemSize(currItem);
currItem->ContourLine = currItem->PoLine.copy();
@@ -369,7 +369,7 @@
currItem->PoLine.translate(0, -npf2.y());
m_doc->moveItem(0, npf2.y(), currItem);
}
- m_doc->sizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem, false, false, false);
+ m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false, false);
currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2, 1.0)));
m_canvas->newRedrawPolygon();
// undoManager->setUndoEnabled(false);
@@ -426,7 +426,7 @@
}
else
{
- m_doc->sizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem, false, false, false);
+ m_doc->sizeItem(currItem->PoLine.widthHeight().x(), currItem->PoLine.widthHeight().y(), currItem, false, false, false);
m_doc->adjustItemSize(currItem);
currItem->Sizing = ssiz;
currItem->ContourLine = currItem->PoLine.copy();
Modified: trunk/Scribus/scribus/fpointarray.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23038&path=/trunk/Scribus/scribus/fpointarray.cpp
==============================================================================
--- trunk/Scribus/scribus/fpointarray.cpp (original)
+++ trunk/Scribus/scribus/fpointarray.cpp Fri Jun 21 11:44:19 2019
@@ -201,14 +201,14 @@
}
}
-QRectF FPointArray::boundingRect()
+QRectF FPointArray::boundingRect() const
{
FPoint min = getMinClipF(this);
FPoint max = getMaxClipF(this);
return QRectF(QPointF(min.x(), min.y()), QPointF(max.x(), max.y()));
}
-FPoint FPointArray::WidthHeight() const
+FPoint FPointArray::widthHeight() const
{
if ( QVector<FPoint>::count() == 0 )
return FPoint( 0.0, 0.0 ); // null rectangle
@@ -537,7 +537,7 @@
return tmp;
}
-QPainterPath FPointArray::toQPainterPath(bool closed)
+QPainterPath FPointArray::toQPainterPath(bool closed) const
{
QPainterPath m_path = QPainterPath();
bool nPath = true;
Modified: trunk/Scribus/scribus/fpointarray.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23038&path=/trunk/Scribus/scribus/fpointarray.h
==============================================================================
--- trunk/Scribus/scribus/fpointarray.h (original)
+++ trunk/Scribus/scribus/fpointarray.h Fri Jun 21 11:44:19 2019
@@ -45,6 +45,8 @@
FPointArray() : m_svgState(nullptr) {};
FPointArray(int size) : QVector<FPoint>(size), m_svgState(nullptr) {};
FPointArray(const FPointArray &a) : QVector<FPoint>(a), m_svgState(nullptr) {};
+ ~FPointArray();
+
int size() const { return QVector<FPoint>::count(); }
bool resize(int newCount);
void reverse();
@@ -54,13 +56,13 @@
bool putPoints(int index, int nPoints, double firstx, double firsty, ... );
bool putPoints(int index, int nPoints, const FPointArray & from, int fromIndex = 0 );
void point(int i, double *x, double *y) const;
- const FPoint& point(int i) const{ return QVector<FPoint>::at(i); }
+ const FPoint& point(int i) const { return QVector<FPoint>::at(i); }
QPoint pointQ(int i) const;
QPointF pointQF(int i) const;
void translate( double dx, double dy );
void scale( double sx, double sy );
- QRectF boundingRect();
- FPoint WidthHeight() const;
+ QRectF boundingRect() const;
+ FPoint widthHeight() const;
void map(const QTransform& m);
FPointArray &operator=( const FPointArray &a );
FPointArray copy() const;
@@ -77,19 +79,18 @@
double lenPathDist(int seg, double t1, double t2) const;
void pointTangentNormalAt( int seg, double t, FPoint* p, FPoint* tn, FPoint* n ) const;
void pointDerivativesAt( int seg, double t, FPoint* p, FPoint* d1, FPoint* d2 ) const;
- ~FPointArray();
void svgInit();
void svgMoveTo(double x, double y);
void svgLineTo(double x, double y);
- //void svgCurveTo(double x1, double y1, double x2, double y2);
void svgCurveToCubic(double x1, double y1, double x2, double y2, double x3, double y3);
void svgArcTo(double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag, double x1, double y1);
void svgClosePath();
void calculateArc(bool relative, double &curx, double &cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag);
bool parseSVG(const QString& svgPath);
QString svgPath(bool closed = false) const;
- QPainterPath toQPainterPath(bool closed);
+ QPainterPath toQPainterPath(bool closed) const;
void fromQPainterPath(QPainterPath &path, bool close = false);
+
private:
SVGState * m_svgState;
};
Modified: trunk/Scribus/scribus/plugins/import/ai/importai.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23038&path=/trunk/Scribus/scribus/plugins/import/ai/importai.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/ai/importai.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/ai/importai.cpp Fri Jun 21 11:44:19 2019
@@ -1412,7 +1412,7 @@
dataString = "";
if (fObjectMode)
{
- FPoint wh = currentSpecialPath.WidthHeight();
+ FPoint wh = currentSpecialPath.widthHeight();
if ((currentSpecialPath.size() > 3) && (wh.x() != 0.0) && (wh.y() != 0.0))
{
z = m_Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, baseX, baseY, 10, 10, 0, CommonStrings::None, CommonStrings::None);
@@ -1590,7 +1590,7 @@
/* Start Object creation commands */
else if ((command == "b") || (command == "B") || (command == "f") || (command == "F") || (command == "s") || (command == "S"))
{
- FPoint wh = Coords.WidthHeight();
+ FPoint wh = Coords.widthHeight();
if ((Coords.size() > 3) && (wh.x() != 0.0) && (wh.y() != 0.0))
{
if ((!WasU) || ((WasU) && (FirstU)))
Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23038&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp Fri Jun 21 11:44:19 2019
@@ -1593,7 +1593,7 @@
out.parseSVG(output);
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
out.map(m_ctm);
- FPoint wh = out.WidthHeight();
+ FPoint wh = out.widthHeight();
if ((out.size() > 3) && ((wh.x() != 0.0) || (wh.y() != 0.0)))
{
CurrColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &CurrStrokeShade);
@@ -1671,7 +1671,7 @@
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
out.map(m_ctm);
Coords = output;
- FPoint wh = out.WidthHeight();
+ FPoint wh = out.widthHeight();
if ((out.size() > 3) && ((wh.x() != 0.0) || (wh.y() != 0.0)))
{
CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &CurrFillShade);
@@ -1716,7 +1716,7 @@
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
out.map(m_ctm);
Coords = output;
- FPoint wh = out.WidthHeight();
+ FPoint wh = out.widthHeight();
if ((out.size() > 3) && ((wh.x() != 0.0) || (wh.y() != 0.0)))
{
CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &CurrFillShade);
@@ -3410,7 +3410,7 @@
double yCoor = m_doc->currentPage()->yOffset();
FPointArray textPath;
textPath.fromQPainterPath(qPath);
- FPoint wh = textPath.WidthHeight();
+ FPoint wh = textPath.widthHeight();
if ((textPath.size() > 3) && ((wh.x() != 0.0) || (wh.y() != 0.0)))
{
CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &CurrFillShade);
@@ -3927,7 +3927,7 @@
bool ret = false;
if (m_currentClipPath.count() != 0)
{
- FPoint wh = m_currentClipPath.WidthHeight();
+ FPoint wh = m_currentClipPath.widthHeight();
if ((wh.x() > 0) && (wh.y() > 0))
ret = true;
}
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23038&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp Fri Jun 21 11:44:19 2019
@@ -206,8 +206,8 @@
it->PoLine.translate(0, -np2.y());
ScCore->primaryMainWindow()->view->MoveItem(0, np2.y(), it);
}
- ScCore->primaryMainWindow()->view->SizeItem(it->PoLine.WidthHeight().x(),
- it->PoLine.WidthHeight().y(), i, false, false, false);
+ ScCore->primaryMainWindow()->view->SizeItem(it->PoLine.widthHeight().x(),
+ it->PoLine.widthHeight().y(), i, false, false, false);
ScCore->primaryMainWindow()->view->AdjustItemSize(it);*/
if (strlen(Name) > 0)
{
@@ -284,7 +284,7 @@
it->PoLine.translate(0, -np2.y());
ScCore->primaryMainWindow()->doc->moveItem(0, np2.y(), it);
}
- ScCore->primaryMainWindow()->doc->sizeItem(it->PoLine.WidthHeight().x(), it->PoLine.WidthHeight().y(), it, false, false, false);
+ ScCore->primaryMainWindow()->doc->sizeItem(it->PoLine.widthHeight().x(), it->PoLine.widthHeight().y(), it, false, false, false);
ScCore->primaryMainWindow()->doc->adjustItemSize(it);
if (strlen(Name) > 0)
{
@@ -366,7 +366,7 @@
it->PoLine.translate(0, -np2.y());
ScCore->primaryMainWindow()->doc->moveItem(0, np2.y(), it);
}
- ScCore->primaryMainWindow()->doc->sizeItem(it->PoLine.WidthHeight().x(), it->PoLine.WidthHeight().y(), it, false, false, false);
+ ScCore->primaryMainWindow()->doc->sizeItem(it->PoLine.widthHeight().x(), it->PoLine.widthHeight().y(), it, false, false, false);
ScCore->primaryMainWindow()->doc->adjustItemSize(it);
if (strlen(Name) > 0)
{
@@ -457,7 +457,7 @@
it->PoLine.translate(0, -np2.y());
ScCore->primaryMainWindow()->doc->moveItem(0, np2.y(), it);
}
- ScCore->primaryMainWindow()->doc->sizeItem(it->PoLine.WidthHeight().x(), it->PoLine.WidthHeight().y(), it, false, false, false);
+ ScCore->primaryMainWindow()->doc->sizeItem(it->PoLine.widthHeight().x(), it->PoLine.widthHeight().y(), it, false, false, false);
ScCore->primaryMainWindow()->doc->adjustItemSize(it);
if (strlen(Name) > 0)
{
Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23038&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Fri Jun 21 11:44:19 2019
@@ -1463,7 +1463,7 @@
{
FPoint tp2(getMinClipF(&currItem->ContourLine));
FPoint tp(getMaxClipF(&currItem->ContourLine));
- FPoint tpS = currItem->ContourLine.WidthHeight();
+ FPoint tpS = currItem->ContourLine.widthHeight();
currItem->ContourLine.translate(-qRound((tp.x() + tp2.x()) / 2.0), -qRound((tp.y() + tp2.y()) / 2.0));
switch (mode)
{
Modified: trunk/Scribus/scribus/ui/arrowchooser.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23038&path=/trunk/Scribus/scribus/ui/arrowchooser.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/arrowchooser.cpp (original)
+++ trunk/Scribus/scribus/ui/arrowchooser.cpp Fri Jun 21 11:44:19 2019
@@ -47,7 +47,7 @@
Path = arrowStyles->at(a).points.copy();
FPoint min = getMinClipF(&Path);
Path.translate(-min.x(), -min.y());
- FPoint max = Path.WidthHeight();
+ FPoint max = Path.widthHeight();
QTransform mm;
QTransform mm2;
if (arrowDirection)
Modified: trunk/Scribus/scribus/ui/extimageprops.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23038&path=/trunk/Scribus/scribus/ui/extimageprops.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/extimageprops.cpp (original)
+++ trunk/Scribus/scribus/ui/extimageprops.cpp Fri Jun 21 11:44:19 2019
@@ -256,7 +256,7 @@
Path = info->PDSpathData[it.key()].copy();
FPoint min = getMinClipF(&Path);
Path.translate(-min.x(), -min.y());
- FPoint max = Path.WidthHeight();
+ FPoint max = Path.widthHeight();
QTransform mm;
mm.scale(34.0 / qMax(max.x(), max.y()), 34.0 / qMax(max.x(), max.y()));
Path.map(mm);
Modified: trunk/Scribus/scribus/util_math.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23038&path=/trunk/Scribus/scribus/util_math.cpp
==============================================================================
--- trunk/Scribus/scribus/util_math.cpp (original)
+++ trunk/Scribus/scribus/util_math.cpp Fri Jun 21 11:44:19 2019
@@ -424,16 +424,16 @@
return outa;
}
-FPoint getMaxClipF(FPointArray* Clip)
+FPoint getMaxClipF(const FPointArray* clip)
{
FPoint np, rp;
double mx = 0;
double my = 0;
- int clipSize=Clip->size();
+ int clipSize = clip->size();
for (int i = 0; i < clipSize; ++i)
{
- np = Clip->point(i);
- if (Clip->isMarker(i))
+ np = clip->point(i);
+ if (clip->isMarker(i))
continue;
if (np.x() > mx)
mx = np.x();
@@ -444,16 +444,16 @@
return rp;
}
-FPoint getMinClipF(FPointArray* Clip)
+FPoint getMinClipF(const FPointArray* clip)
{
FPoint np, rp;
- double mx = std::numeric_limits<double>::max();
- double my = std::numeric_limits<double>::max();
- int clipSize=Clip->size();
+ double mx = std::numeric_limits<double>::max();
+ double my = std::numeric_limits<double>::max();
+ int clipSize = clip->size();
for (int i = 0; i < clipSize; ++i)
{
- np = Clip->point(i);
- if (Clip->isMarker(i))
+ np = clip->point(i);
+ if (clip->isMarker(i))
continue;
if (np.x() < mx)
mx = np.x();
Modified: trunk/Scribus/scribus/util_math.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23038&path=/trunk/Scribus/scribus/util_math.h
==============================================================================
--- trunk/Scribus/scribus/util_math.h (original)
+++ trunk/Scribus/scribus/util_math.h Fri Jun 21 11:44:19 2019
@@ -30,8 +30,8 @@
*/
bool SCRIBUS_API compareDouble(double a, double b);
uint SCRIBUS_API getDouble(const QByteArray& in, bool raw);
-FPoint SCRIBUS_API getMaxClipF(FPointArray* Clip);
-FPoint SCRIBUS_API getMinClipF(FPointArray* Clip);
+FPoint SCRIBUS_API getMaxClipF(const FPointArray* clip);
+FPoint SCRIBUS_API getMinClipF(const FPointArray* clip);
FPoint SCRIBUS_API projectPointOnLine(FPoint p, QPointF lineStart, QPointF lineEnd);
bool SCRIBUS_API regionContainsRect(const QRegion& shape, QRect rect);
QPolygon SCRIBUS_API FlattenPath(const FPointArray& ina, QList<uint> &Segs);
More information about the scribus-commit
mailing list