r24751 by jghali - Code cleanup: add some const specifiers

scribus-commit scribus-commit at lists.scribus.net
Mon Oct 25 19:40:58 UTC 2021


Author: jghali
Date: Mon Oct 25 19:40:58 2021
New Revision: 24751

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24751
Log:
Code cleanup: add some const specifiers

Modified:
    trunk/Scribus/scribus/util_math.cpp
    trunk/Scribus/scribus/util_math.h

Modified: trunk/Scribus/scribus/util_math.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24751&path=/trunk/Scribus/scribus/util_math.cpp
==============================================================================
--- trunk/Scribus/scribus/util_math.cpp	(original)
+++ trunk/Scribus/scribus/util_math.cpp	Mon Oct 25 19:40:58 2021
@@ -81,17 +81,17 @@
 				hf *= di;
 				sc += innerRot;
 			}
-			mx = sin(sc / 180.0 * M_PI) * (wf) + (w/2.0);
-			my = cos(sc / 180.0 * M_PI) * (hf) + (h/2.0);
+			mx = sin(sc / 180.0 * M_PI) * wf + (w / 2.0);
+			my = cos(sc / 180.0 * M_PI) * hf + (h / 2.0);
 		}
 		else
 		{
-			mx = sin(sc / 180.0 * M_PI) * (w/2.0) + (w/2.0);
-			my = cos(sc / 180.0 * M_PI) * (h/2.0) + (h/2.0);
+			mx = sin(sc / 180.0 * M_PI) * (w / 2.0) + (w / 2.0);
+			my = cos(sc / 180.0 * M_PI) * (h / 2.0) + (h / 2.0);
 		}
 		cornerPoints.append(QPointF(mx, my));
 	}
-	// now calculate bezier control points if needed;
+	// now calculate bezier control points if needed
 	if (star)
 	{
 		pts.moveTo(cornerPoints[0]);
@@ -262,14 +262,13 @@
 	return path;
 }
 
-QList<QPainterPath> decomposePath(QPainterPath &path)
+QList<QPainterPath> decomposePath(const QPainterPath &path)
 {
 	QList<QPainterPath> ret;
 	QPainterPath part;
 	QPainterPath::Element element1;
 	QPainterPath::Element element2;
 
-	part = QPainterPath();
 	bool first = true;
 	for (int i = 0; i < path.elementCount(); ++i)
 	{
@@ -325,10 +324,10 @@
 
 	// Code adapted from Qt RectInRegion (cf. qregion.cpp) to detect
 	// if a specific rect is strictly contained in a specific region
-	const QRect *pbox, *pboxEnd;
-	bool partIn(false), partOut(false);
-
-	QRect *prect = ▭
+	bool partIn(false);
+	bool partOut(false);
+
+	const QRect *prect = ▭
 	int rx = rect.left();
 	int ry = rect.top();
 
@@ -338,8 +337,8 @@
 		return false;
 
 	/* can stop when both partOut and partIn are true, or we reach prect->y2 */
-	pbox = (rectCount == 1) ? &boundingRect : shape.cbegin();
-	pboxEnd = (rectCount == 1) ? (&boundingRect + 1) : shape.cend();
+	const QRect* pbox = (rectCount == 1) ? &boundingRect : shape.cbegin();
+	const QRect* pboxEnd = (rectCount == 1) ? (&boundingRect + 1) : shape.cend();
 	for (; pbox < pboxEnd; ++pbox)
 	{
 		if (pbox->bottom() < ry)
@@ -496,7 +495,7 @@
 	return newAngle;
 }
 
-double getRotationFromMatrix(QTransform& matrix, double def)
+double getRotationFromMatrix(const QTransform& matrix, double def)
 {
 	double value = def;
 	double norm = sqrt(fabs(matrix.determinant()));
@@ -519,14 +518,14 @@
 	return value;
 }
 
-double getRotationDFromMatrix(QTransform& matrix)
+double getRotationDFromMatrix(const QTransform& matrix)
 {
 	QLineF line(0.0, 0.0, 1.0, 0.0);
 	line = matrix.map(line);
 	return line.angle();
 }
 
-void getScaleFromMatrix(QTransform &matrix, double &scX, double &scY)
+void getScaleFromMatrix(const QTransform &matrix, double &scX, double &scY)
 {
 	QLineF lineX(0.0, 0.0, 1.0, 0.0);
 	QLineF lineY(0.0, 0.0, 0.0, 1.0);
@@ -536,7 +535,7 @@
 	scY = lineY.length();
 }
 
-void getTransformValuesFromMatrix(QTransform &matrix, double &scX, double &scY, double &rot, double &dx, double &dy)
+void getTransformValuesFromMatrix(const QTransform &matrix, double &scX, double &scY, double &rot, double &dx, double &dy)
 {
 	QLineF lineX(0.0, 0.0, 1.0, 0.0);
 	QLineF lineY(0.0, 0.0, 0.0, 1.0);

Modified: trunk/Scribus/scribus/util_math.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24751&path=/trunk/Scribus/scribus/util_math.h
==============================================================================
--- trunk/Scribus/scribus/util_math.h	(original)
+++ trunk/Scribus/scribus/util_math.h	Mon Oct 25 19:40:58 2021
@@ -35,7 +35,7 @@
 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> &segments);
-QList<QPainterPath> SCRIBUS_API decomposePath(QPainterPath &path);
+QList<QPainterPath> SCRIBUS_API decomposePath(const QPainterPath &path);
 QPainterPath  SCRIBUS_API regularPolygonPath(double w, double h, uint c, bool star, double factor, double rota, double factor2 = 0.0, double innerRot = 0.0, double factor3 = 0.0);
 QPainterPath  SCRIBUS_API spiralPath(double spiralWidth, double spiralHeight, double spiralStartAngle, double spiralEndAngle, double spiralFactor);
 inline double SCRIBUS_API xy2Deg(double x, double y);
@@ -56,14 +56,14 @@
    \param def the value that should be return if matrix is not a rotation matrix
    \retval double the rotation angle
  */
-double SCRIBUS_API getRotationFromMatrix(QTransform& matrix, double def);
+double SCRIBUS_API getRotationFromMatrix(const QTransform& matrix, double def);
 /*! \brief Get the rotation angle (in degree) from a transformation matrix
    \param matrix the transformation matrix
    \retval double the rotation angle
  */
-double SCRIBUS_API getRotationDFromMatrix(QTransform& matrix);
-void SCRIBUS_API getScaleFromMatrix(QTransform &matrix, double &scX, double &scY);
-void SCRIBUS_API getTransformValuesFromMatrix(QTransform &matrix, double &scX, double &scY, double &rot, double &dx, double &dy);
+double SCRIBUS_API getRotationDFromMatrix(const QTransform& matrix);
+void SCRIBUS_API getScaleFromMatrix(const QTransform &matrix, double &scX, double &scY);
+void SCRIBUS_API getTransformValuesFromMatrix(const QTransform &matrix, double &scX, double &scY, double &rot, double &dx, double &dy);
 
 
 // IMPLEMENTATION




More information about the scribus-commit mailing list