r24713 by jghali - Code cleanup

scribus-commit scribus-commit at lists.scribus.net
Sat Oct 2 20:49:05 UTC 2021


Author: jghali
Date: Sat Oct  2 20:49:05 2021
New Revision: 24713

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24713
Log:
Code cleanup

Modified:
    trunk/Scribus/scribus/scpainter.cpp
    trunk/Scribus/scribus/scpainter.h
    trunk/Scribus/scribus/scpainterex_cairo.cpp
    trunk/Scribus/scribus/scpainterex_cairo.h
    trunk/Scribus/scribus/scpainterex_ps2.cpp
    trunk/Scribus/scribus/scpainterex_ps2.h
    trunk/Scribus/scribus/scpainterexbase.h

Modified: trunk/Scribus/scribus/scpainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24713&path=/trunk/Scribus/scribus/scpainter.cpp
==============================================================================
--- trunk/Scribus/scribus/scpainter.cpp	(original)
+++ trunk/Scribus/scribus/scpainter.cpp	Sat Oct  2 20:49:05 2021
@@ -26,67 +26,17 @@
 {
 	Q_ASSERT(w >= 0);
 	Q_ASSERT(h >= 0);
-	m_maskPattern = nullptr;
-	m_pattern = nullptr;
-	m_imageMask = nullptr;
+
 	m_image = target;
 	m_layerTransparency = transparency;
 	m_blendMode = blendmode;
-	m_blendModeFill = 0;
-	m_blendModeStroke = 0;
 	m_width = w;
 	m_height= h;
-	m_fontSize = 0.0;
-	mf_underline = false;
-	mf_strikeout = false;
-	mf_shadow = false;
-	mf_outlined = false;
-	m_fill = QColor(0,0,0);
-	m_fill_trans = 1.0;
-	m_fillRule = true;
-	m_fillMode = 1;
-	m_patternScaleX = 0.0;
-	m_patternScaleX = 0.0;
-	m_patternScaleY = 0.0;
-	m_patternOffsetX = 0.0;
-	m_patternOffsetY = 0.0;
-	m_patternRotation = 0.0;
-	m_patternSkewX = 0.0;
-	m_patternSkewY = 0.0;
-	m_patternMirrorX = false;
-	m_patternMirrorY = false;
-	m_gradientScale = 0.0;
-	m_gradientSkew = 0.0;
+
 	setHatchParameters(0, 2, 0, false, QColor(), QColor(), 0.0, 0.0);
-	m_stroke = QColor(0,0,0);
-	m_stroke_trans = 1.0;
-	m_LineWidth = 1.0;
-	m_strokeMode = 0;
-	m_maskMode = 0;
-	m_mask_patternScaleX = 0.0;
-	m_mask_patternScaleY = 0.0;
-	m_mask_patternOffsetX = 0.0;
-	m_mask_patternOffsetY = 0.0;
-	m_mask_patternRotation = 0.0;
-	m_mask_patternSkewX = 0.0;
-	m_mask_patternSkewY = 0.0;
-	m_mask_patternMirrorX = false;
-	m_mask_patternMirrorY = false;
-	m_mask_gradientScale = 0.0;
-	m_mask_gradientSkew = 0.0;
-	PLineEnd = Qt::FlatCap;
-	PLineJoin = Qt::MiterJoin;
-	m_offset = 0;
-	m_zoomFactor = 1;
-	m_layeredMode = true;
-	m_imageMode = true;
-	m_svgMode = false;
-
-	fill_gradient = VGradient(VGradient::linear);
-	stroke_gradient = VGradient(VGradient::linear);
-
-	m_matrix = QTransform();
+
 	m_zoomStack.clear();
+
 	cairo_surface_t *img = cairo_image_surface_create_for_data(m_image->bits(), CAIRO_FORMAT_ARGB32, w, h, w * 4);
 	cairo_surface_set_device_scale(img, m_image->devicePixelRatio(), m_image->devicePixelRatio());
 	m_cr = cairo_create(img);
@@ -227,7 +177,7 @@
 {
 	cairo_matrix_t matrix;
 	cairo_get_matrix(m_cr, &matrix);
-	QTransform mat = QTransform(matrix.xx, matrix.yx, matrix.xy, matrix.yy, matrix.x0, matrix.y0);
+	QTransform mat(matrix.xx, matrix.yx, matrix.xy, matrix.yy, matrix.x0, matrix.y0);
 	return mat;
 }
 
@@ -835,11 +785,11 @@
 				qStopRampPoints.append(colorStops[offset]->rampPoint);
 			}
 			qStopColors.last().getRgbF(&r, &g, &b, &a);
-			QPointF centerP = QPointF(gradControlP5.x(), gradControlP5.y());
-			QLineF edge1 = QLineF(centerP, QPointF(p1x, p1y));
-			QLineF edge2 = QLineF(centerP, QPointF(p2x, p2y));
-			QLineF edge3 = QLineF(centerP, QPointF(p3x, p3y));
-			QLineF edge4 = QLineF(centerP, QPointF(p4x, p4y));
+			QPointF centerP(gradControlP5.x(), gradControlP5.y());
+			QLineF edge1(centerP, QPointF(p1x, p1y));
+			QLineF edge2(centerP, QPointF(p2x, p2y));
+			QLineF edge3(centerP, QPointF(p3x, p3y));
+			QLineF edge4(centerP, QPointF(p4x, p4y));
 			QPointF p1 = edge1.pointAt(colorStops.last()->rampPoint);
 			QPointF p2 = edge2.pointAt(colorStops.last()->rampPoint);
 			QPointF p3 = edge3.pointAt(colorStops.last()->rampPoint);
@@ -1647,7 +1597,7 @@
 	strokePath();
 }
 
-void ScPainter::drawText(QRectF area, const QString& text, bool filled, int align)
+void ScPainter::drawText(const QRectF& area, const QString& text, bool filled, int align)
 {
 	cairo_text_extents_t extents;
 	cairo_font_extents_t extentsF;
@@ -1951,7 +1901,7 @@
 	int *vmin = new int[qMax(w,h)];
 	int divsum = (div+1)>>1;
 	divsum *= divsum;
-	int *dv = new int[256*divsum];
+	int *dv = new int[256 * (size_t) divsum];
 	for (i = 0; i < 256 * divsum; ++i)
 	{
 		dv[i] = (i / divsum);
@@ -1999,7 +1949,7 @@
 			ainsum += sir[0];
 			asum += ainsum;
 			stackpointer = (stackpointer + 1) % div;
-			sir = stack[(stackpointer) % div];
+			sir = stack[stackpointer % div];
 			aoutsum += sir[0];
 			ainsum -= sir[0];
 			++yi;
@@ -2066,23 +2016,23 @@
 	if (radius < 1)
 		return;
 	cairo_surface_t *data = cairo_get_group_target(m_cr);
-	QRgb *pix = (QRgb*)cairo_image_surface_get_data(data);
+	QRgb *pix = (QRgb*) cairo_image_surface_get_data(data);
 	int w   = cairo_image_surface_get_width(data);
 	int h   = cairo_image_surface_get_height(data);
-	int wm  = w-1;
-	int hm  = h-1;
-	int wh  = w*h;
-	int div = radius+radius+1;
+	int wm  = w - 1;
+	int hm  = h - 1;
+	int wh  = w * h;
+	int div = radius + radius + 1;
 	int *r = new int[wh];
 	int *g = new int[wh];
 	int *b = new int[wh];
 	int *a = new int[wh];
 	int rsum, gsum, bsum, asum, x, y, i, yp, yi, yw;
 	QRgb p;
-	int *vmin = new int[qMax(w,h)];
+	int *vmin = new int[qMax(w, h)];
 	int divsum = (div+1)>>1;
 	divsum *= divsum;
-	int *dv = new int[256*divsum];
+	int *dv = new int[256 * (size_t) divsum];
 	for (i = 0; i < 256 * divsum; ++i)
 	{
 		dv[i] = (i / divsum);
@@ -2165,8 +2115,8 @@
 			gsum += ginsum;
 			bsum += binsum;
 			asum += ainsum;
-			stackpointer = (stackpointer+1)%div;
-			sir = stack[(stackpointer)%div];
+			stackpointer = (stackpointer + 1) % div;
+			sir = stack[stackpointer % div];
 			routsum += sir[0];
 			goutsum += sir[1];
 			boutsum += sir[2];

Modified: trunk/Scribus/scribus/scpainter.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24713&path=/trunk/Scribus/scribus/scpainter.h
==============================================================================
--- trunk/Scribus/scribus/scpainter.h	(original)
+++ trunk/Scribus/scribus/scpainter.h	Sat Oct  2 20:49:05 2021
@@ -36,6 +36,7 @@
 public:
 	ScPainter(QImage *target, int w, int h, double transparency = 1.0, int blendmode = 0);
 	virtual ~ScPainter();
+
 	enum FillMode { None, Solid, Gradient, Pattern, Hatch };
 	virtual void beginLayer(double transparency, int blendmode, FPointArray *clipArray = nullptr);
 	virtual void endLayer();
@@ -65,12 +66,12 @@
 	virtual void fillPath();
 	virtual void strokePath();
 	virtual void setFillRule(bool fillRule);
-	virtual bool fillRule() { return m_fillRule; }
+	virtual bool fillRule() const { return m_fillRule; }
 	virtual void setFillMode(int fill);
-	virtual int  fillMode() { return m_fillMode; }
-	virtual int  maskMode() { return m_maskMode; }
+	virtual int  fillMode() const  { return m_fillMode; }
+	virtual int  maskMode() const  { return m_maskMode; }
 	virtual void setStrokeMode(int stroke);
-	virtual int  strokeMode() { return m_strokeMode; }
+	virtual int  strokeMode() const  { return m_strokeMode; }
 	virtual void setGradient(VGradient::VGradientType mode, const FPoint& orig, const FPoint& vec, const FPoint& foc, double scale, double skew);
 	virtual void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
 
@@ -101,7 +102,7 @@
 	virtual void drawSharpLine(QPointF start, QPointF end);
 	virtual void drawRect(double, double, double, double);
 	virtual void drawSharpRect(double x, double y, double w, double h);
-	virtual void drawText(QRectF area, const QString& text, bool filled = true, int align = 0);
+	virtual void drawText(const QRectF& area, const QString& text, bool filled = true, int align = 0);
 	virtual void drawShadeCircle(const QRectF &re, const QColor& color, bool sunken, int lineWidth);
 	virtual void drawShadePanel(const QRectF &r, const QColor& color, bool sunken, int lineWidth);
 	virtual void drawUnderlinedRect(const QRectF &r, const QColor& color, int lineWidth);
@@ -134,17 +135,17 @@
 	virtual void setBlendModeFill(int blendMode);
 	virtual void setBlendModeStroke(int blendMode);
 
-	VGradient fill_gradient;
-	VGradient stroke_gradient;
+	VGradient fill_gradient { VGradient::linear };
+	VGradient stroke_gradient { VGradient::linear };
 	VGradient mask_gradient;
-	ScPattern *m_maskPattern;
-	ScPattern *m_pattern;
+	ScPattern *m_maskPattern { nullptr };
+	ScPattern *m_pattern { nullptr };
 
 private:
 	void fillPathHelper();
 	void strokePathHelper();
 
-	cairo_t *m_cr;
+	cairo_t* m_cr { nullptr };
 	struct layerProp
 	{
 		cairo_surface_t *data;
@@ -169,41 +170,41 @@
 		bool fillRule;
 	};
 	cairo_pattern_t *getMaskPattern();
-	cairo_surface_t *m_imageMask;
+	cairo_surface_t *m_imageMask { nullptr };
 	QImage m_imageQ;
 
 	QStack<layerProp> m_Layers;
 	QStack<double> m_zoomStack;
-	QImage *m_image;
+	QImage *m_image { nullptr };
 	double  m_layerTransparency;
 	int  m_blendMode;
-	int  m_blendModeFill;
-	int  m_blendModeStroke;
+	int  m_blendModeFill { 0 };
+	int  m_blendModeStroke { 0 };
 	unsigned int m_width;
 	unsigned int m_height;
 	QTransform m_matrix;
 	ScFace m_font;
-	double m_fontSize;
-	bool mf_underline;
-	bool mf_strikeout;
-	bool mf_shadow;
-	bool mf_outlined;
+	double m_fontSize { 0.0 };
+	bool mf_underline { false };
+	bool mf_strikeout { false };
+	bool mf_shadow { false };
+	bool mf_outlined { false };
 	/*! \brief Filling */
-	QColor m_fill;
-	double m_fill_trans;
-	bool m_fillRule;
-	int m_fillMode;				// 0 = none, 1 = solid, 2 = gradient 3 = pattern 4 = hatch
-	double m_patternScaleX;
-	double m_patternScaleY;
-	double m_patternOffsetX;
-	double m_patternOffsetY;
-	double m_patternRotation;
-	double m_patternSkewX;
-	double m_patternSkewY;
-	bool m_patternMirrorX;
-	bool m_patternMirrorY;
-	double m_gradientScale;
-	double m_gradientSkew;
+	QColor m_fill { 0, 0, 0 };
+	double m_fill_trans { 1.0 };
+	bool m_fillRule { true };
+	int m_fillMode { 1 };				// 0 = none, 1 = solid, 2 = gradient 3 = pattern 4 = hatch
+	double m_patternScaleX { 0.0 };
+	double m_patternScaleY { 0.0 };
+	double m_patternOffsetX { 0.0 };
+	double m_patternOffsetY { 0.0 };
+	double m_patternRotation { 0.0 };
+	double m_patternSkewX { 0.0 };
+	double m_patternSkewY { 0.0 };
+	bool m_patternMirrorX { false };
+	bool m_patternMirrorY { false };
+	double m_gradientScale { 0.0 };
+	double m_gradientSkew { 0.0 };
 	FPoint gradPatchP1;
 	FPoint gradPatchP2;
 	FPoint gradPatchP3;
@@ -219,44 +220,44 @@
 	QColor gradPatchColor4;
 	QList<QList<MeshPoint> > meshGradientArray;
 	QList<meshGradientPatch> meshGradientPatches;
-	double m_hatchAngle;
-	double m_hatchDistance;
-	int m_hatchType;				// 0 = single 1 = double 2 = triple
-	bool m_hatchUseBackground;
+	double m_hatchAngle { 0.0 };
+	double m_hatchDistance { 0.0 };
+	int m_hatchType { 0 };				// 0 = single 1 = double 2 = triple
+	bool m_hatchUseBackground { false };
 	QColor m_hatchBackground;
 	QColor m_hatchForeground;
-	double m_hatchWidth;
-	double m_hatchHeight;
+	double m_hatchWidth { 0.0 };
+	double m_hatchHeight { 0.0 };
 	/*! \brief Stroking */
-	QColor m_stroke;
-	double m_stroke_trans;
-	double m_LineWidth;
-	int m_strokeMode;				// 0 = none, 1 = solid, 2 = gradient 3 = pattern
-	int m_maskMode;				// 0 = none, 1 = gradient 2 = pattern
-	double m_mask_patternScaleX;
-	double m_mask_patternScaleY;
-	double m_mask_patternOffsetX;
-	double m_mask_patternOffsetY;
-	double m_mask_patternRotation;
-	double m_mask_patternSkewX;
-	double m_mask_patternSkewY;
-	bool m_mask_patternMirrorX;
-	bool m_mask_patternMirrorY;
-	double m_mask_gradientScale;
-	double m_mask_gradientSkew;
+	QColor m_stroke { 0, 0, 0 };
+	double m_stroke_trans { 1.0 };
+	double m_LineWidth { 1.0 };
+	int m_strokeMode { 0 };				// 0 = none, 1 = solid, 2 = gradient 3 = pattern
+	int m_maskMode { 0 };				// 0 = none, 1 = gradient 2 = pattern
+	double m_mask_patternScaleX { 0.0 };
+	double m_mask_patternScaleY { 0.0 };
+	double m_mask_patternOffsetX { 0.0 };
+	double m_mask_patternOffsetY { 0.0 };
+	double m_mask_patternRotation { 0.0 };
+	double m_mask_patternSkewX { 0.0 };
+	double m_mask_patternSkewY { 0.0 };
+	bool m_mask_patternMirrorX { false };
+	bool m_mask_patternMirrorY { false };
+	double m_mask_gradientScale { 0.0 };
+	double m_mask_gradientSkew { 0.0 };
 
 	/*! \brief Line End Style */
-	Qt::PenCapStyle PLineEnd;
+	Qt::PenCapStyle PLineEnd { Qt::FlatCap };
   /*! \brief Line Join Style */
-	Qt::PenJoinStyle PLineJoin;
+	Qt::PenJoinStyle PLineJoin { Qt::MiterJoin };
   /*! \brief The Dash Array */
 	QVector<double> m_array;
-	double m_offset;
+	double m_offset { 0.0 };
 	/*! \brief Zoom Factor of the Painter */
-	double m_zoomFactor;
-	bool m_imageMode;
-	bool m_layeredMode;
-	bool m_svgMode;
+	double m_zoomFactor { 1.0 };
+	bool m_imageMode { true };
+	bool m_layeredMode { true };
+	bool m_svgMode { false };
 };
 
 #endif

Modified: trunk/Scribus/scribus/scpainterex_cairo.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24713&path=/trunk/Scribus/scribus/scpainterex_cairo.cpp
==============================================================================
--- trunk/Scribus/scribus/scpainterex_cairo.cpp	(original)
+++ trunk/Scribus/scribus/scpainterex_cairo.cpp	Sat Oct  2 20:49:05 2021
@@ -11,31 +11,18 @@
 #include "util.h"
 #include "util_math.h"
 
-ScPainterEx_Cairo::ScPainterEx_Cairo(cairo_t* context, QRect& rect,  ScribusDoc* doc, bool gray) : ScPainterExBase()
+ScPainterEx_Cairo::ScPainterEx_Cairo(cairo_t* context, const QRect& rect,  ScribusDoc* doc, bool gray) : ScPainterExBase()
 {
 	m_doc    = doc;
 	m_width  = rect.width();
 	m_height = rect.height();
-	m_blendModeLayer = 0;
-	m_blendModeFill = 0;
-	m_blendModeStroke = 0;
 	m_strokeColor = ScColorShade(QColor(0,0,0), 100);
 	m_fillColor = ScColorShade(QColor(0,0,0), 100);
-	m_fillTrans = 1.0;
-	m_strokeTrans = 1.0;
-	m_fillRule  = true;
-	m_fillMode  = 1;
-	m_lineWidth = 1.0;
-	m_offset    = 0;
-	m_lineEnd   = Qt::SquareCap;
-	m_lineJoin  = Qt::RoundJoin;
-	m_fillGradient   = VGradientEx(VGradientEx::linear);
-	m_strokeGradient = VGradientEx(VGradientEx::linear);
 	// Grayscale conversion parameter
 	m_convertToGray = gray;
 	// Initialization of Windows GDI data
 	m_cr = context;
-	m_positionX = m_positionY = 0;
+
 	clear();
 }
 
@@ -44,11 +31,10 @@
 
 }
 
-QColor ScPainterEx_Cairo::transformColor(ScColorShade& colorShade, double trans)
-{
-	QColor c, color;
-	c = ScColorEngine::getShadeColor(colorShade.color, m_doc, colorShade.shade);
-	color = qRgba(qRed(c.rgb()), qGreen(c.rgb()), qBlue(c.rgb()), qAlpha(trans * 255));
+QColor ScPainterEx_Cairo::transformColor(const ScColorShade& colorShade, double trans) const
+{
+	QColor c = ScColorEngine::getShadeColor(colorShade.color, m_doc, colorShade.shade);
+	QColor color = qRgba(qRed(c.rgb()), qGreen(c.rgb()), qBlue(c.rgb()), qAlpha(trans * 255));
 	if (m_convertToGray)
 	{
 		int grayLevel;
@@ -60,7 +46,7 @@
 	return color;
 }
 
-void ScPainterEx_Cairo::transformImage(QImage& image)
+void ScPainterEx_Cairo::transformImage(QImage& image) const
 {
 	int rgb, grey;
 	int imageWidth = image.width();
@@ -101,7 +87,7 @@
 	m_graphics->FillRectangle(&brush, 0, 0, m_width, m_height);*/
 }
 
-const QTransform ScPainterEx_Cairo::worldMatrix()
+QTransform ScPainterEx_Cairo::worldMatrix() const
 {
 	cairo_matrix_t matrix;
 	cairo_get_matrix(m_cr, &matrix);
@@ -434,6 +420,14 @@
 		cairo_set_operator(m_cr, CAIRO_OPERATOR_HSL_COLOR);
 	else if (blendMode == 15)
 		cairo_set_operator(m_cr, CAIRO_OPERATOR_HSL_LUMINOSITY);
+	else if (blendMode == 16)
+		cairo_set_operator(m_cr, CAIRO_OPERATOR_ADD);
+	else if (blendMode == 17)
+		cairo_set_operator(m_cr, CAIRO_OPERATOR_DEST_IN);
+	else if (blendMode == 18)
+		cairo_set_operator(m_cr, CAIRO_OPERATOR_DEST_OUT);
+	else if (blendMode == 19)
+		cairo_set_operator(m_cr, CAIRO_OPERATOR_CLEAR);
 	else
 		cairo_set_operator(m_cr, CAIRO_OPERATOR_OVER);
 }

Modified: trunk/Scribus/scribus/scpainterex_cairo.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24713&path=/trunk/Scribus/scribus/scpainterex_cairo.h
==============================================================================
--- trunk/Scribus/scribus/scpainterex_cairo.h	(original)
+++ trunk/Scribus/scribus/scpainterex_cairo.h	Sat Oct  2 20:49:05 2021
@@ -16,86 +16,86 @@
 class ScPainterEx_Cairo : public ScPainterExBase
 {
 public:
-	ScPainterEx_Cairo(cairo_t* context, QRect& rect, ScribusDoc* doc, bool gray );
+	ScPainterEx_Cairo(cairo_t* context, const QRect& rect, ScribusDoc* doc, bool gray );
 	virtual ~ScPainterEx_Cairo();
 
-	virtual Capabilities capabilities() { return transparencies; }
-
-	virtual int supportedColorModes() { return (int) rgbMode; }
-	virtual ColorMode preferredColorMode() { return rgbMode; }
-	virtual ImageMode imageMode() { return rgbImages; }
-
-	virtual void begin();
-	virtual void end();
-	virtual void clear();
-	virtual void clear( ScColorShade & );
+	Capabilities capabilities() const override { return transparencies; }
+
+	int supportedColorModes() const override { return (int) rgbMode; }
+	ColorMode preferredColorMode() const override { return rgbMode; }
+	ImageMode imageMode() const override { return rgbImages; }
+
+	void begin() override;
+	void end() override;
+	void clear() override;
+	void clear(ScColorShade &) override;
 
 	// matrix manipulation
-	virtual void setWorldMatrix( const QTransform & );
-	virtual const QTransform worldMatrix();
-	virtual void translate( double, double );
-	virtual void translate( const QPointF& offset );
-	virtual void rotate( double );
-	virtual void scale( double, double );
+	void setWorldMatrix(const QTransform &) override;
+	QTransform worldMatrix() const override;
+	void translate( double, double ) override;
+	void translate( const QPointF& offset ) override;
+	void rotate( double ) override;
+	void scale( double, double ) override;
 
 	// drawing
-	virtual void moveTo( const double &, const double & );
-	virtual void lineTo( const double &, const double & );
-	virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
-	virtual void newPath();
+	void moveTo( const double &, const double & ) override;
+	void lineTo( const double &, const double & ) override;
+	void curveTo( FPoint p1, FPoint p2, FPoint p3 ) override;
+	void newPath() override;
 	virtual void closePath();
-	virtual void fillPath();
-	virtual void strokePath();
-	virtual void setFillRule( bool fillRule );
-	virtual bool fillRule() { return m_fillRule; }
-	virtual void setFillMode( int fill );
-	virtual int  fillMode() { return m_fillMode; }
-	virtual void setStrokeMode( int fill );
-	virtual int  strokeMode() { return m_strokeMode; }
-	virtual void setGradient( VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew);
-	virtual void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
-
-	virtual void setMaskMode( int mask );
-	virtual void setGradientMask(VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew);
-	virtual void setPatternMask(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
-
-	virtual void set4ColorGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4);
-	virtual void set4ColorColors(const ScColorShade& col1, const ScColorShade& col2, const ScColorShade& col3, const ScColorShade& col4);
-	virtual void setDiamondGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4, FPoint c5);
-	virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<QList<MeshPoint> > meshArray);
-	virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<meshGradientPatch> meshPatches);
-
-	virtual void setClipPath();
-
-	virtual void drawImage( ScImage *image, ScPainterExBase::ImageMode mode );
-	virtual void setupPolygon(const FPointArray *points, bool closed = true);
-	virtual void drawPolygon();
-	virtual void drawPolyLine();
-	virtual void drawLine(FPoint start, FPoint end);
-	virtual void drawLine(const QPointF& start, const QPointF& end);
-	virtual void drawRect(double, double, double, double);
+	void fillPath() override;
+	void strokePath() override;
+	void setFillRule( bool fillRule ) override;
+	bool fillRule() const override  { return m_fillRule; }
+	void setFillMode( int fill ) override;
+	int  fillMode() const  override  { return m_fillMode; }
+	void setStrokeMode( int fill ) override;
+	int  strokeMode()  const override { return m_strokeMode; }
+	void setGradient( VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew) override;
+	void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY) override;
+
+	void setMaskMode( int mask ) override;
+	void setGradientMask(VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew) override;
+	void setPatternMask(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY) override;
+
+	void set4ColorGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4) override;
+	void set4ColorColors(const ScColorShade& col1, const ScColorShade& col2, const ScColorShade& col3, const ScColorShade& col4) override;
+	void setDiamondGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4, FPoint c5) override;
+	void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<QList<MeshPoint> > meshArray) override;
+	void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<meshGradientPatch> meshPatches) override;
+
+	void setClipPath() override;
+
+	void drawImage( ScImage *image, ScPainterExBase::ImageMode mode ) override;
+	void setupPolygon(const FPointArray *points, bool closed = true) override;
+	void drawPolygon() override;
+	void drawPolyLine() override;
+	void drawLine(FPoint start, FPoint end) override;
+	void drawLine(const QPointF& start, const QPointF& end) override;
+	void drawRect(double, double, double, double) override;
 
 	// pen + brush
-	virtual ScColorShade pen();
-	virtual ScColorShade brush();
-	virtual void setPen( const ScColorShade & );
-	virtual void setPen( const ScColorShade &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
-	virtual void setPenOpacity( double op );
-	virtual void setLineWidth( double w);
-	virtual void setDash(const QVector<double>& array, double ofs);
-	virtual void setBrush( const ScColorShade & );
-	virtual void setBrushOpacity( double op );
-	virtual void setOpacity( double op );
-	virtual void setFont( const QFont &f );
-	virtual QFont font();
+	ScColorShade pen() override;
+	ScColorShade brush() override;
+	void setPen( const ScColorShade & ) override;
+	void setPen( const ScColorShade &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo ) override;
+	void setPenOpacity( double op ) override;
+	void setLineWidth( double w) override;
+	void setDash(const QVector<double>& array, double ofs) override;
+	void setBrush( const ScColorShade & ) override;
+	void setBrushOpacity( double op ) override;
+	void setOpacity( double op ) override;
+	void setFont( const QFont &f ) override;
+	QFont font() override;
 
 	// stack management
-	virtual void save();
-	virtual void restore();
-
-	virtual void setRasterOp( int op );
-	virtual void setBlendModeFill( int blendMode );
-	virtual void setBlendModeStroke( int blendMode );
+	void save() override;
+	void restore() override;
+
+	void setRasterOp( int op ) override;
+	void setBlendModeFill( int blendMode ) override;
+	void setBlendModeStroke( int blendMode ) override;
 
 private:
 	void fillPathHelper();
@@ -115,21 +115,21 @@
 
 	void getClipPathDimensions( QRect& r );
 
-	ScribusDoc* m_doc;
+	ScribusDoc* m_doc { nullptr };
 
 	unsigned int m_width;
 	unsigned int m_height;
 	QTransform m_matrix;
 	QFont m_font;
 /* Layer blend mode*/
-	int  m_blendModeLayer;
-	int  m_blendModeFill;
-	int  m_blendModeStroke;
+	int  m_blendModeLayer { 0 };
+	int  m_blendModeFill { 0 };
+	int  m_blendModeStroke { 0 };
 /* Filling */
 	ScColorShade m_fillColor;
-	double m_fillTrans;
-	bool   m_fillRule;
-	int    m_fillMode;			// 0 = none, 1 = solid, 2 = gradient
+	double m_fillTrans { 1.0 };
+	bool   m_fillRule { true };
+	int    m_fillMode { 1 };			// 0 = none, 1 = solid, 2 = gradient
 	int    m_gradientMode;		// 1 = linear, 2 = radial
 
 	double m_patternScaleX;
@@ -162,8 +162,8 @@
 	double m_gradientSkew;
 /* Stroking */
 	ScColorShade m_strokeColor;
-	double m_strokeTrans;
-	double m_lineWidth;
+	double m_strokeTrans { 1.0 };
+	double m_lineWidth { 1.0 };
 	int    m_strokeMode;				// 0 = none, 1 = solid, 2 = gradient 3 = pattern
 /* Masking */
 	int    m_maskMode;				// 0 = none, 1 = gradient 2 = pattern
@@ -180,28 +180,28 @@
 	double m_maskGradientSkew;
 
 /* Grayscale conversion option */
-	bool   m_convertToGray;
+	bool   m_convertToGray { false };
 
 /* Line End Style */
-	Qt::PenCapStyle m_lineEnd;
+	Qt::PenCapStyle m_lineEnd { Qt::SquareCap };
 /* Line Join Style */
-	Qt::PenJoinStyle m_lineJoin;
+	Qt::PenJoinStyle m_lineJoin { Qt::RoundJoin };
 /* The Dash Array */
 	QVector<double> m_array;
-	double m_offset;
+	double m_offset { 0.0 };
 /* Transformation Stack */
 	QStack<QTransform> m_stack;
 
 /* Cairo context */
-	cairo_t* m_cr;
+	cairo_t* m_cr { nullptr };
 
 /* Color conversion function */
-	QColor transformColor( ScColorShade& colorShade, double trans );
-	void   transformImage( QImage& image );
+	QColor transformColor( const ScColorShade& colorShade, double trans ) const;
+	void   transformImage( QImage& image ) const;
 
 	QStack<int> m_gStates;
-	double      m_positionX;
-	double      m_positionY;
+	double      m_positionX { 0.0 };
+	double      m_positionY { 0.0 };
 };
 
 #endif

Modified: trunk/Scribus/scribus/scpainterex_ps2.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24713&path=/trunk/Scribus/scribus/scpainterex_ps2.cpp
==============================================================================
--- trunk/Scribus/scribus/scpainterex_ps2.cpp	(original)
+++ trunk/Scribus/scribus/scpainterex_ps2.cpp	Sat Oct  2 20:49:05 2021
@@ -29,30 +29,24 @@
 #include "scpainterex_ps2.h"
 
 #include <cfloat>
+#include <cmath>
+#include <iostream>
+#include <memory>
 #include <QPaintDevice>
 #include <QPixmap>
 #include <QImage>
-
-#include <cmath>
-#include <iostream>
-#include <memory>
-using namespace std;
 
 #include "colormgmt/sccolormgmtengine.h"
 #include "sccolorengine.h"
 #include "scimage.h"
 #include "util.h"
 
+using namespace std;
+
 ScPs2OutputParams::ScPs2OutputParams(ScribusDoc* doc)
 {
 	document = doc;
 	colorMode = ScPainterExBase::rgbMode;
-	reloadImages = true;
-	resolution = 72;
-	useProfiles = false;
-	toGray = false;
-	mirrorH = false;
-	mirrorV = false;
 	hProfile = nullptr;
 	rgbToOutputColorTransform = nullptr;
 	rgbToOutputImageTransform = nullptr;
@@ -60,11 +54,10 @@
 	cmykToOutputImageTransform = nullptr;
 }
 
-ScPainterEx_Ps2::ScPainterEx_Ps2(QIODevice* iodev, QRect& rect, ScPs2OutputParams& options )
+ScPainterEx_Ps2::ScPainterEx_Ps2(QIODevice* iodev, const QRect& rect, const ScPs2OutputParams& options )
 {
 	m_stream.setDevice( iodev );
 	m_colorMode = options.colorMode;
-	m_encoding  = Ascii85Encoding;
 	m_options = options;
 	m_width = rect.width();
 	m_height= rect.height();
@@ -72,27 +65,10 @@
 	m_y = rect.top();
 	m_fillColor = ScColorShade( QColor(0,0,0), 100 );
 	m_strokeColor = ScColorShade( QColor(0,0,0), 100 );
-	m_fillTrans = 1.0;
-	m_strokeTrans = 1.0;
-	m_fillRule = true;
-	m_fillMode = 1;
-	m_lineWidth = 1.0;
-	m_offset = 0;
 	m_array.clear();
-	m_lineEnd = Qt::SquareCap;
-	m_lineJoin = Qt::RoundJoin;
-	m_fillGradient = VGradientEx(VGradientEx::linear);
-	m_strokeGradient = VGradientEx(VGradientEx::linear);
-	m_matrix = QTransform();
-	m_pageTrans = QTransform();
-	// Path state
-	m_pathIsClosed = true;
-	m_drawingClosedPath = false;
+
 	// TODO : set proper values
-	m_deviceDimX = 0;
-	m_deviceDimY = 0;
-	m_deviceResX = 0;
-	m_deviceResY = 0;
+
 	clear();
 }
 
@@ -100,7 +76,7 @@
 {
 }
 
-ScPainterExBase::ImageMode ScPainterEx_Ps2::imageMode()
+ScPainterExBase::ImageMode ScPainterEx_Ps2::imageMode() const
 {
 	ImageMode imageMode;
 	if (m_options.hProfile && m_options.rgbToOutputImageTransform && m_options.cmykToOutputImageTransform)
@@ -112,7 +88,7 @@
 	return imageMode;
 }
 
-void ScPainterEx_Ps2::transformImage( QImage* image, uchar* data, int scan)
+void ScPainterEx_Ps2::transformImage( QImage* image, uchar* data, int scan) const
 {
 	int rgb, grey;
 	int imageWidth = image->width();
@@ -155,7 +131,7 @@
 
 }
 
-const QTransform ScPainterEx_Ps2::worldMatrix()
+QTransform ScPainterEx_Ps2::worldMatrix() const
 {
 	return m_matrix;
 }
@@ -165,7 +141,7 @@
 	m_matrix = mat;
 }
 
-void ScPainterEx_Ps2::transformPoint( const FPoint& in, FPoint& out )
+void ScPainterEx_Ps2::transformPoint( const FPoint& in, FPoint& out ) const
 {
 	double x, y;
 	x = in.x() * m_matrix.m11() + in.y() * m_matrix.m21() + m_matrix.dx();
@@ -174,7 +150,7 @@
 	out.setY( y );
 }
 
-void ScPainterEx_Ps2::transformPoints( const FPoint* ArrayIn, FPoint* ArrayOut, uint length )
+void ScPainterEx_Ps2::transformPoints( const FPoint* ArrayIn, FPoint* ArrayOut, uint length ) const
 {
 	for (uint i = 0; i < length; i++)
 	{
@@ -451,7 +427,7 @@
 	m_clipBBox = m_pathBBox;
 }
 
-void ScPainterEx_Ps2::putColor(ScColorShade& colorShade, bool doFill)
+void ScPainterEx_Ps2::putColor(const ScColorShade& colorShade, bool doFill)
 {
 	ColorMode colorMode = m_colorMode;
 	double r = 0, g = 0, b = 0, gray = 0;
@@ -520,7 +496,7 @@
 		ScColorEngine::getShadeColorRGB(colorShade.color, m_options.document, rgb, colorShade.shade);
 		rgb.getValues(r, g, b);
 	}
-	else if ( m_colorMode == cmykMode )
+	else if (m_colorMode == cmykMode)
 	{
 		CMYKColorF cmyk;
 		colorMode = cmykMode;
@@ -698,7 +674,7 @@
 	int    height = image->height();
 	for (int y = 0; y < height; y++)
 	{
-		QRgb* imageBits = (QRgb*)(image->qImage().scanLine(y));
+		auto* imageBits = (const QRgb*)(image->qImage().scanLine(y));
 		for (int x = 0; x < width; ++x)
 		{
 			if (qAlpha(*imageBits) != 255)
@@ -722,7 +698,7 @@
 		width++;
 	for (int y = 0; y < height; ++y)
 	{
-		unsigned char* imageBits = image->scanLine(y);
+		const unsigned char* imageBits = image->scanLine(y);
 		for (int x = 0; x < width; x++)
 		{
 			length++;
@@ -748,7 +724,7 @@
 	int height = image->height();
 	for (int y = 0; y < height; ++y)
 	{
-		QRgb* imageBits = (QRgb*)(image->qImage().scanLine(y));
+		auto* imageBits = (const QRgb*)(image->qImage().scanLine(y));
 		for (int x = 0; x < width; ++x)
 		{
 			cindex = 0;
@@ -801,7 +777,7 @@
 	int  height = image->height();
 	for (int y = 0; y < height; ++y)
 	{
-		QRgb* imageBits = (QRgb*)(image->qImage().scanLine(y));
+		auto* imageBits = (const QRgb*)(image->qImage().scanLine(y));
 		for (int x = 0; x < width; ++x)
 		{
 			length++;
@@ -831,7 +807,7 @@
 	int height = image->height();
 	for (int y = 0; y < height; y++)
 	{
-		QRgb* imageBits = (QRgb*)(image->qImage().scanLine(y));
+		auto* imageBits = (const QRgb*)(image->qImage().scanLine(y));
 		for (int x = 0; x < width; x++)
 		{
 			four_tuple[0] = (uchar) qRed(*imageBits);
@@ -863,7 +839,7 @@
 	int height = image->height();
 	for (int y = 0; y < height; ++y)
 	{
-		QRgb* imageBits = (QRgb*)(image->qImage().scanLine(y));
+		auto* imageBits = (const QRgb*)(image->qImage().scanLine(y));
 		for (int x = 0; x < width; ++x)
 		{
 			length++;
@@ -962,7 +938,7 @@
 	strokePath();
 }
 
-void ScPainterEx_Ps2::drawGradient( VGradientEx& gradient )
+void ScPainterEx_Ps2::drawGradient( const VGradientEx& gradient )
 {
 //	QRect clipPathRect;
 	save();
@@ -976,7 +952,7 @@
 	restore();
 }
 
-void ScPainterEx_Ps2::drawLinearGradient( VGradientEx& gradient, const QRect& rect )
+void ScPainterEx_Ps2::drawLinearGradient(const VGradientEx& gradient, const QRect& rect )
 {
 	if (m_colorMode == cmykMode)
 		drawLinearGradient_CMYK(gradient, rect);
@@ -984,7 +960,7 @@
 		drawLinearGradient_RGB(gradient, rect);
 }
 
-void ScPainterEx_Ps2::drawLinearGradient_RGB( VGradientEx& gradient, const QRect& rect )
+void ScPainterEx_Ps2::drawLinearGradient_RGB( const VGradientEx& gradient, const QRect& rect )
 {
 	double r1, g1, b1;
 	double r2, g2, b2;
@@ -992,7 +968,6 @@
 	double ramp1, ramp2;
 	double length, scale;
 	double x1, y1, x2, y2, dx, dy;
-	int clipBoxWidth, clipBoxHeight, maxDim;
 	QList<VColorStopEx*> colorStops = gradient.colorStops();
 	VColorStopEx stop1( *colorStops[0] );
 	VColorStopEx stop2( *colorStops[0] );
@@ -1002,10 +977,11 @@
 	if (gradient.stops() < 2) 
 		return;
 
-	clipBoxWidth = rect.width();
-	clipBoxHeight = rect.height();
-	maxDim = qRound(sqrt( (double) (clipBoxWidth * clipBoxWidth + clipBoxHeight * clipBoxHeight) )) * 2;
-	if (maxDim <= 0) return;
+	qint64 clipBoxWidth = rect.width();
+	qint64 clipBoxHeight = rect.height();
+	qint64 maxDim = qRound64(sqrt( (double) (clipBoxWidth * clipBoxWidth + clipBoxHeight * clipBoxHeight) )) * 2;
+	if (maxDim <= 0)
+		return;
 
 	x1 = m_matrix.dx() + gradient.origin().x() * m_matrix.m11();
 	y1 = m_matrix.dy() + gradient.origin().y() * m_matrix.m22();
@@ -1083,7 +1059,7 @@
 	}
 }
 
-void ScPainterEx_Ps2::drawLinearGradient_CMYK(VGradientEx& gradient, const QRect& rect)
+void ScPainterEx_Ps2::drawLinearGradient_CMYK(const VGradientEx& gradient, const QRect& rect)
 {
 	double c1, m1, j1, n1;
 	double c2, m2, j2, n2;
@@ -1091,7 +1067,6 @@
 	double ramp1, ramp2;
 	double length, scale;
 	double x1, y1, x2, y2, dx, dy;
-	int clipBoxWidth, clipBoxHeight, maxDim;
 	QList<VColorStopEx*> colorStops = gradient.colorStops();
 	VColorStopEx stop1( *colorStops[0] );
 	VColorStopEx stop2( *colorStops[0] );
@@ -1101,10 +1076,11 @@
 	if ( gradient.stops() < 2 ) 
 		return;
 
-	clipBoxWidth = rect.width();
-	clipBoxHeight = rect.height();
-	maxDim = qRound(sqrt( (double) (clipBoxWidth * clipBoxWidth + clipBoxHeight * clipBoxHeight) )) * 2;
-	if ( maxDim <= 0 ) return;
+	qint64 clipBoxWidth = rect.width();
+	qint64 clipBoxHeight = rect.height();
+	qint64 maxDim = qRound64(sqrt( (double) (clipBoxWidth * clipBoxWidth + clipBoxHeight * clipBoxHeight) )) * 2;
+	if (maxDim <= 0)
+		return;
 
 	x1 = m_matrix.dx() + gradient.origin().x() * m_matrix.m11();
 	y1 = m_matrix.dy() + gradient.origin().y() * m_matrix.m22();
@@ -1115,8 +1091,8 @@
 
 	dx = ( p2.x() - p1.x() );
 	dy = ( p2.y() - p1.y() );
-	length = sqrt(( dx * dx + dy * dy ));
-	if ( length == 0.0 )
+	length = sqrt(dx * dx + dy * dy);
+	if (length == 0.0)
 		scale = 1.0;
 	else
 		scale = 1.0 / length;
@@ -1189,7 +1165,7 @@
 	}
 }
 
-void ScPainterEx_Ps2::drawCircularGradient( VGradientEx& gradient, const QRect& rect )
+void ScPainterEx_Ps2::drawCircularGradient(const VGradientEx& gradient, const QRect& rect )
 {
 	if (m_colorMode == cmykMode)
 		drawCircularGradient_CMYK(gradient, rect);
@@ -1197,21 +1173,21 @@
 		drawCircularGradient_RGB(gradient, rect);
 }
 
-void ScPainterEx_Ps2::drawCircularGradient_RGB( VGradientEx& gradient, const QRect& rect )
+void ScPainterEx_Ps2::drawCircularGradient_RGB(const VGradientEx& gradient, const QRect& rect )
 {
 	double r1, g1, b1;
 	double r2, g2, b2;
 	double ramp1, ramp2;
-	int clipBoxWidth, clipBoxHeight, maxDim;
 	QList<VColorStopEx*> colorStops = gradient.colorStops();
 	VColorStopEx stop1( *colorStops[gradient.stops() - 1] );
 	VColorStopEx stop2( *colorStops[gradient.stops() - 1] );
 	RGBColorF rgb;
 
-	clipBoxWidth = rect.width();
-	clipBoxHeight = rect.height();
-	maxDim = qRound(sqrt( (double) (clipBoxWidth * clipBoxWidth + clipBoxHeight * clipBoxHeight) )) * 2;
-	if ( maxDim <= 0 ) return;
+	qint64 clipBoxWidth = rect.width();
+	qint64 clipBoxHeight = rect.height();
+	qint64 maxDim = qRound64(sqrt( (double) (clipBoxWidth * clipBoxWidth + clipBoxHeight * clipBoxHeight) )) * 2;
+	if ( maxDim <= 0 )
+		return;
 
 	FPoint pc( gradient.origin().x(), gradient.origin().y() );
 	FPoint pcz( gradient.origin().x(), gradient.origin().y() );
@@ -1279,21 +1255,21 @@
 	}
 }
 
-void ScPainterEx_Ps2::drawCircularGradient_CMYK( VGradientEx& gradient, const QRect& rect )
+void ScPainterEx_Ps2::drawCircularGradient_CMYK(const VGradientEx& gradient, const QRect& rect )
 {
 	double c1, m1, y1, k1;
 	double c2, m2, y2, k2;
 	double ramp1, ramp2;
-	int clipBoxWidth, clipBoxHeight, maxDim;
 	QList<VColorStopEx*> colorStops = gradient.colorStops();
 	VColorStopEx stop1( *colorStops[gradient.stops() - 1] );
 	VColorStopEx stop2( *colorStops[gradient.stops() - 1] );
 	CMYKColorF cmyk;
 
-	clipBoxWidth = rect.width();
-	clipBoxHeight = rect.height();
-	maxDim = qRound(sqrt( (double) (clipBoxWidth * clipBoxWidth + clipBoxHeight * clipBoxHeight) )) * 2;
-	if (maxDim <= 0) return;
+	qint64 clipBoxWidth = rect.width();
+	qint64 clipBoxHeight = rect.height();
+	qint64 maxDim = qRound64(sqrt( (double) (clipBoxWidth * clipBoxWidth + clipBoxHeight * clipBoxHeight) )) * 2;
+	if (maxDim <= 0)
+		return;
 
 	FPoint pc( gradient.origin().x(), gradient.origin().y() );
 	FPoint pcz( gradient.origin().x(), gradient.origin().y() );
@@ -1368,11 +1344,13 @@
 	}
 }
 
-void ScPainterEx_Ps2::getPathBoundingBox(const FPointArray* points, QRect& r )
+void ScPainterEx_Ps2::getPathBoundingBox(const FPointArray* points, QRect& r) const
 {
 	FPoint point;
-	double bottom = DBL_MAX, top   = DBL_MIN;
-	double left   = DBL_MAX, right = DBL_MIN;
+	double bottom = DBL_MAX;
+	double top = DBL_MIN;
+	double left = DBL_MAX;
+	double right = DBL_MIN;
 
 	r.setCoords(0, 0, 0, 0);
 

Modified: trunk/Scribus/scribus/scpainterex_ps2.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24713&path=/trunk/Scribus/scribus/scpainterex_ps2.h
==============================================================================
--- trunk/Scribus/scribus/scpainterex_ps2.h	(original)
+++ trunk/Scribus/scribus/scpainterex_ps2.h	Sat Oct  2 20:49:05 2021
@@ -54,14 +54,14 @@
 {
 public:
 	ScPs2OutputParams(ScribusDoc* doc = nullptr);
-	ScPainterExBase::ColorMode colorMode;
-	ScribusDoc* document;
-	bool reloadImages;
-	int resolution;
-	bool useProfiles;
-	bool toGray;
-	bool mirrorH;
-	bool mirrorV;
+	ScPainterExBase::ColorMode colorMode { ScPainterExBase::rgbMode };
+	ScribusDoc* document { nullptr };
+	bool reloadImages { true };
+	int resolution { 72 };
+	bool useProfiles { false };
+	bool toGray { false };
+	bool mirrorH { false };
+	bool mirrorV { false };
 	QString outputProfile;
 	ScColorProfile   hProfile;
 	ScColorTransform rgbToOutputColorTransform;
@@ -74,92 +74,92 @@
 {
 public:
 
-	ScPainterEx_Ps2( QIODevice* iodev, QRect& rect, ScPs2OutputParams& options );
+	ScPainterEx_Ps2( QIODevice* iodev, const QRect& rect, const ScPs2OutputParams& options );
 	virtual ~ScPainterEx_Ps2();
 
-	virtual int supportedColorModes() { return (int) (rgbMode|cmykMode); }
-	virtual ColorMode preferredColorMode() { return m_colorMode; }
+	int supportedColorModes() const override { return (int) (rgbMode|cmykMode); }
+	ColorMode preferredColorMode() const override { return m_colorMode; }
 	virtual void setPreferredColorMode(ScPainterEx_Ps2::ColorMode colorMode) { m_colorMode = colorMode; }
-	virtual ImageMode imageMode();
-
-	virtual void begin();
-	virtual void end();
-	virtual void clear();
-	virtual void clear( ScColorShade & );
+	ImageMode imageMode() const override;
+
+	void begin() override;
+	void end() override;
+	void clear() override;
+	void clear( ScColorShade & ) override;
 
 	// matrix manipulation
-	virtual void setWorldMatrix( const QTransform & );
-	virtual const QTransform worldMatrix();
-	virtual void translate( double, double );
-	virtual void translate( const QPointF& offset );
-	virtual void rotate( double );
-	virtual void scale( double, double );
+	void setWorldMatrix( const QTransform & ) override;
+	QTransform worldMatrix() const override;
+	void translate( double, double ) override;
+	void translate( const QPointF& offset ) override;
+	void rotate( double ) override;
+	void scale( double, double ) override;
 
 	// drawing
-	virtual void moveTo( const double &, const double & );
-	virtual void lineTo( const double &, const double & );
-	virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
-	virtual void newPath();
+	void moveTo( const double &, const double & ) override;
+	void lineTo( const double &, const double & ) override;
+	void curveTo( FPoint p1, FPoint p2, FPoint p3 ) override;
+	void newPath() override;
 	virtual void closePath();
-	virtual void fillPath();
-	virtual void strokePath();
-	virtual void setFillRule( bool fillRule );
-	virtual bool fillRule() { return m_fillRule; }
-	virtual void setFillMode( int fill );
-	virtual int  fillMode() { return m_fillMode; }
-	virtual void setStrokeMode( int fill );
-	virtual int  strokeMode() { return m_strokeMode; }
-	virtual void setGradient( VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew);
-	virtual void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
-
-	virtual void setMaskMode( int mask ) {};
-	virtual void setGradientMask(VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew) {};
-	virtual void setPatternMask(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY) {};
-
-	virtual void set4ColorGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4) {};
-	virtual void set4ColorColors(const ScColorShade& col1, const ScColorShade& col2, const ScColorShade& col3, const ScColorShade& col4) {};
-	virtual void setDiamondGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4, FPoint c5) {};
-	virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<QList<MeshPoint> > meshArray) {};
-	virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<meshGradientPatch> meshPatches) {};
-
-	virtual void setClipPath();
-
-	virtual void drawImage( ScImage *image, ScPainterExBase::ImageMode mode );
-	virtual void drawRGBImage_ps2( ScImage *image );
-	virtual void drawCMYKImage_ps2( ScImage *image );
-
-	virtual bool hasAlphaChannel( ScImage* image );
-
-	virtual void setupPolygon(const FPointArray *points, bool closed = true);
-	virtual void drawPolygon();
-	virtual void drawPolyLine();
-	virtual void drawLine(FPoint start, FPoint end);
-	virtual void drawLine(const QPointF& start, const QPointF& end);
-	virtual void drawRect(double, double, double, double);
+	void fillPath() override;
+	void strokePath() override;
+	void setFillRule( bool fillRule ) override;
+	bool fillRule() const override { return m_fillRule; }
+	void setFillMode( int fill ) override;
+	int  fillMode() const override { return m_fillMode; }
+	void setStrokeMode( int fill ) override;
+	int  strokeMode() const override { return m_strokeMode; }
+	void setGradient( VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew) override;
+	void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY) override;
+
+	void setMaskMode( int mask ) override {};
+	void setGradientMask(VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew) override  {};
+	void setPatternMask(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY)  override {};
+
+	void set4ColorGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4)  override {};
+	void set4ColorColors(const ScColorShade& col1, const ScColorShade& col2, const ScColorShade& col3, const ScColorShade& col4)  override {};
+	void setDiamondGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4, FPoint c5)  override {};
+	void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<QList<MeshPoint> > meshArray)  override {};
+	void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<meshGradientPatch> meshPatches)  override {};
+
+	void setClipPath() override;
+
+	void drawImage( ScImage *image, ScPainterExBase::ImageMode mode ) override;
+
+	void setupPolygon(const FPointArray *points, bool closed = true) override;
+	void drawPolygon() override;
+	void drawPolyLine() override;
+	void drawLine(FPoint start, FPoint end) override;
+	void drawLine(const QPointF& start, const QPointF& end) override;
+	void drawRect(double, double, double, double) override;
 
 	// pen + brush
-	virtual ScColorShade pen();
-	virtual ScColorShade brush();
-	virtual void setPen( const ScColorShade & );
-	virtual void setPen( const ScColorShade &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
-	virtual void setPenOpacity( double op );
-	virtual void setLineWidth( double w);
-	virtual void setDash(const QVector<double>& array, double ofs);
-	virtual void setBrush( const ScColorShade & );
-	virtual void setBrushOpacity( double op );
-	virtual void setOpacity( double op );
-	virtual void setFont( const QFont &f );
-	virtual QFont font();
+	ScColorShade pen() override;
+	ScColorShade brush() override;
+	void setPen( const ScColorShade & ) override;
+	void setPen( const ScColorShade &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo ) override;
+	void setPenOpacity( double op ) override;
+	void setLineWidth( double w) override;
+	void setDash(const QVector<double>& array, double ofs) override;
+	void setBrush( const ScColorShade & ) override;
+	void setBrushOpacity( double op ) override;
+	void setOpacity( double op ) override;
+	void setFont( const QFont &f ) override;
+	QFont font() override;
 
 	// stack management
-	virtual void save();
-	virtual void restore();
-
-	virtual void setRasterOp( int op );
-	virtual void setBlendModeFill( int blendMode ) {};
-	virtual void setBlendModeStroke( int blendMode ) {};
+	void save() override;
+	void restore() override;
+
+	void setRasterOp( int op ) override;
+	void setBlendModeFill( int blendMode )  override {};
+	void setBlendModeStroke( int blendMode ) override {};
 
 protected:
+	virtual void drawRGBImage_ps2(ScImage* image);
+	virtual void drawCMYKImage_ps2(ScImage* image);
+
+	virtual bool hasAlphaChannel(ScImage* image);
 
 	virtual void writeRGBImageToStream_Ascii85 ( ScImage* image );
 	virtual void writeRGBImageToStream_AsciiHex ( ScImage* image );
@@ -169,15 +169,16 @@
 
 private:
 
-	typedef enum {
+	enum AsciiEncoding
+	{
 		Ascii85Encoding,
 		AsciiHexEncoding
-	} AsciiEncoding;
+	};
 
 	/* Output stream */
 	QTextStream   m_stream;
 	ColorMode     m_colorMode;
-	AsciiEncoding m_encoding; 
+	AsciiEncoding m_encoding { Ascii85Encoding };
 
 	/* Path bounding boxes*/
 	QRect m_pathBBox;
@@ -188,18 +189,18 @@
 
 	/* Basic drawing functions*/
 	void drawVPath( int mode );
-	void drawGradient( VGradientEx& gradient );
-	void drawLinearGradient( VGradientEx& gradient, const QRect& rect );
-	void drawLinearGradient_RGB( VGradientEx& gradient, const QRect& rect );
-	void drawLinearGradient_CMYK( VGradientEx& gradient, const QRect& rect );
-	void drawCircularGradient( VGradientEx& gradient, const QRect& rect );
-	void drawCircularGradient_RGB( VGradientEx& gradient, const QRect& rect );
-	void drawCircularGradient_CMYK( VGradientEx& gradient, const QRect& rect );
-	void getPathBoundingBox(const FPointArray* points, QRect& r );
-	void transformPoint( const FPoint& in, FPoint& out );
-	void transformPoints( const FPoint* in, FPoint* out, uint length );
-
-	void putColor( ScColorShade& colorShade, bool doFill );
+	void drawGradient(const VGradientEx& gradient );
+	void drawLinearGradient(const VGradientEx& gradient, const QRect& rect);
+	void drawLinearGradient_RGB( const VGradientEx& gradient, const QRect& rect);
+	void drawLinearGradient_CMYK( const VGradientEx& gradient, const QRect& rect);
+	void drawCircularGradient(const VGradientEx& gradient, const QRect& rect);
+	void drawCircularGradient_RGB(const VGradientEx& gradient, const QRect& rect);
+	void drawCircularGradient_CMYK(const VGradientEx& gradient, const QRect& rect);
+	void getPathBoundingBox(const FPointArray* points, QRect& r) const;
+	void transformPoint( const FPoint& in, FPoint& out) const;
+	void transformPoints( const FPoint* in, FPoint* out, uint length) const;
+
+	void putColor(const ScColorShade& colorShade, bool doFill);
 
 	unsigned int m_width;
 	unsigned int m_height;
@@ -210,47 +211,47 @@
 	QFont m_font;
 /* Filling */
 	ScColorShade m_fillColor;
-	double m_fillTrans;
-	bool   m_fillRule;
-	int    m_fillMode;			// 0 = none, 1 = solid, 2 = gradient
-
-	double m_patternScaleX;
-	double m_patternScaleY;
-	double m_patternOffsetX;
-	double m_patternOffsetY;
-	double m_patternRotation;
-	double m_patternSkewX;
-	double m_patternSkewY;
-	bool   m_patternMirrorX;
-	bool   m_patternMirrorY;
+	double m_fillTrans { 1.0 };
+	bool   m_fillRule { true };
+	int    m_fillMode { 1 };			// 0 = none, 1 = solid, 2 = gradient
+
+	double m_patternScaleX { 1.0 };
+	double m_patternScaleY { 1.0 };
+	double m_patternOffsetX { 0.0 };
+	double m_patternOffsetY { 0.0 };
+	double m_patternRotation { 0.0 };
+	double m_patternSkewX { 0.0 };
+	double m_patternSkewY { 0.0 };
+	bool   m_patternMirrorX { false };
+	bool   m_patternMirrorY { false };
 
 /* Stroking */
 	ScColorShade m_strokeColor;
-	double m_strokeTrans;
-	double m_lineWidth;
-	int    m_strokeMode;				// 0 = none, 1 = solid, 2 = gradient 3 = pattern
+	double m_strokeTrans { 1.0 };
+	double m_lineWidth { 1.0 };
+	int    m_strokeMode { 0 };				// 0 = none, 1 = solid, 2 = gradient 3 = pattern
 /* Line End Style */
-	Qt::PenCapStyle m_lineEnd;
+	Qt::PenCapStyle m_lineEnd { Qt::SquareCap };
 /* Line Join Style */
-	Qt::PenJoinStyle m_lineJoin;
+	Qt::PenJoinStyle m_lineJoin { Qt::RoundJoin };
 /* The Dash Array */
 	QVector<double> m_array;
-	double m_offset;
+	double m_offset { 0.0 };
 /* Transformation Stack */
 	QStack<QTransform> m_stack;
 
 /* Some data to describe state of drawing */	
-	bool m_pathIsClosed;
-	bool m_drawingClosedPath;
+	bool m_pathIsClosed { false };
+	bool m_drawingClosedPath { false };
 /* Drawing surface dimensions */
-	double m_deviceDimX;
-	double m_deviceDimY;
+	double m_deviceDimX { 0.0 };
+	double m_deviceDimY { 0.0 };
 /* Device resolutions */
-	double m_deviceResX;
-	double m_deviceResY;
+	double m_deviceResX { 0.0 };
+	double m_deviceResY { 0.0 };
 
 /* Color conversion function */
-	void   transformImage( QImage* image, uchar* data, int scan);
+	void   transformImage(QImage* image, uchar* data, int scan) const;
 };
 
 #endif

Modified: trunk/Scribus/scribus/scpainterexbase.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24713&path=/trunk/Scribus/scribus/scpainterexbase.h
==============================================================================
--- trunk/Scribus/scribus/scpainterexbase.h	(original)
+++ trunk/Scribus/scribus/scpainterexbase.h	Sat Oct  2 20:49:05 2021
@@ -51,19 +51,19 @@
 class SCRIBUS_API ScPainterExBase
 {
 public:
-	virtual ~ScPainterExBase() {};
+	virtual ~ScPainterExBase() = default;
 
 	enum FillMode { None, Solid, Gradient, Pattern };
 	enum ColorMode { rgbMode = 1, cmykMode = 2 };
 	enum ImageMode { cmykImages, rgbImages, rawImages };
 	enum Capabilities{ basic = 0, transparencies = 1, patterns = 2 };
 
-	virtual Capabilities capabilities() { return basic; }
+	virtual Capabilities capabilities() const { return basic; }
 	virtual bool hasCapability(Capabilities cap) { return ((m_capabilities & (int) cap) != 0); }
 
-	virtual int supportedColorModes() = 0;
-	virtual ColorMode preferredColorMode() = 0;
-	virtual ImageMode imageMode() = 0;
+	virtual int supportedColorModes() const = 0;
+	virtual ColorMode preferredColorMode() const = 0;
+	virtual ImageMode imageMode() const = 0;
 	
 	virtual void begin() = 0;
 	virtual void end() = 0;
@@ -72,7 +72,7 @@
 
 	// matrix manipulation
 	virtual void setWorldMatrix(const QTransform &) = 0;
-	virtual const QTransform worldMatrix() = 0;
+	virtual QTransform worldMatrix() const = 0;
 	virtual void translate(double, double) = 0;
 	virtual void translate(const QPointF& offset) = 0;
 	virtual void rotate(double) = 0;
@@ -86,11 +86,11 @@
 	virtual void fillPath() = 0;
 	virtual void strokePath() = 0;
 	virtual void setFillRule(bool fillRule) = 0;
-	virtual bool fillRule()  = 0;
+	virtual bool fillRule() const = 0;
 	virtual void setFillMode(int fill) = 0;
-	virtual int  fillMode() = 0;
+	virtual int  fillMode() const = 0;
 	virtual void setStrokeMode(int stroke) = 0;
-	virtual int  strokeMode() = 0;
+	virtual int  strokeMode() const = 0;
 	virtual void setGradient(VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew) = 0;
 	virtual void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY) = 0;
 
@@ -136,15 +136,15 @@
 	virtual void setBlendModeFill(int blendMode) = 0;
 	virtual void setBlendModeStroke(int blendMode) = 0;
 
-	VGradientEx  m_fillGradient;
-	VGradientEx  m_strokeGradient;
+	VGradientEx  m_fillGradient { VGradientEx::linear };
+	VGradientEx  m_strokeGradient { VGradientEx::linear };
 	VGradientEx  m_maskGradient;
 	ScPattern*   m_pattern;
 	ScPattern*   m_maskPattern;
 	QTransform   m_patternTransform;
 
 protected:
-	int m_capabilities;
+	int m_capabilities { 0 };
 	ScPainterExBase(void);
 };
 




More information about the scribus-commit mailing list