From 4f1b7ec0d0ba21d3c81ce63e3a49f48736a67feb Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 23 Mar 2012 22:07:34 +0100 Subject: final cleanup of spiro? (bzr r11124) --- src/live_effects/spiro-converters.cpp | 123 ++++++++++++++++++++++++++++++++++ src/live_effects/spiro-converters.h | 10 ++- 2 files changed, 127 insertions(+), 6 deletions(-) create mode 100644 src/live_effects/spiro-converters.cpp (limited to 'src') diff --git a/src/live_effects/spiro-converters.cpp b/src/live_effects/spiro-converters.cpp new file mode 100644 index 000000000..3c7bdf99e --- /dev/null +++ b/src/live_effects/spiro-converters.cpp @@ -0,0 +1,123 @@ +/* Authors: + * Johan Engelen + * + * Copyright (C) 2010-2012 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "spiro-converters.h" +#include <2geom/path.h> +#include "display/curve.h" +#include + +#define SPIRO_SHOW_INFINITE_COORDINATE_CALLS +#ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS +# define SPIRO_G_MESSAGE(x) g_message(x) +#else +# define SPIRO_G_MESSAGE(x) +#endif + +namespace Spiro { + +void +ConverterSPCurve::moveto(double x, double y, bool is_open) +{ + if ( IS_FINITE(x) && IS_FINITE(y) ) { + _curve.moveto(x, y); + if (!is_open) { + _curve.closepath(); + } + } else { + SPIRO_G_MESSAGE("Spiro: moveto not finite"); + } +} + +void +ConverterSPCurve::lineto(double x, double y) +{ + if ( IS_FINITE(x) && IS_FINITE(y) ) { + _curve.lineto(x, y); + } else { + SPIRO_G_MESSAGE("Spiro: lineto not finite"); + } +} + +void +ConverterSPCurve::quadto(double xm, double ym, double x3, double y3) +{ + if ( IS_FINITE(xm) && IS_FINITE(ym) && IS_FINITE(x3) && IS_FINITE(y3) ) { + _curve.quadto(xm, ym, x3, y3); + } else { + SPIRO_G_MESSAGE("Spiro: quadto not finite"); + } +} + +void +ConverterSPCurve::curveto(double x1, double y1, double x2, double y2, double x3, double y3) +{ + if ( IS_FINITE(x1) && IS_FINITE(y1) && IS_FINITE(x2) && IS_FINITE(y2) ) { + _curve.curveto(x1, y1, x2, y2, x3, y3); + } else { + SPIRO_G_MESSAGE("Spiro: curveto not finite"); + } +} + + + + +void +ConverterPath::moveto(double x, double y, bool is_open) +{ + if ( IS_FINITE(x) && IS_FINITE(y) ) { + _path.start(Geom::Point(x, y)); + _path.close(!is_open); + } else { + SPIRO_G_MESSAGE("spiro moveto not finite"); + } +} + +void +ConverterPath::lineto(double x, double y) +{ + if ( IS_FINITE(x) && IS_FINITE(y) ) { + _path.appendNew( Geom::Point(x, y) ); + } else { + SPIRO_G_MESSAGE("spiro lineto not finite"); + } +} + +void +ConverterPath::quadto(double xm, double ym, double x3, double y3) +{ + if ( IS_FINITE(xm) && IS_FINITE(ym) && IS_FINITE(x3) && IS_FINITE(y3) ) { + _path.appendNew(Geom::Point(xm, ym), Geom::Point(x3, y3)); + } else { + SPIRO_G_MESSAGE("spiro quadto not finite"); + } +} + +void +ConverterPath::curveto(double x1, double y1, double x2, double y2, double x3, double y3) +{ + if ( IS_FINITE(x1) && IS_FINITE(y1) && IS_FINITE(x2) && IS_FINITE(y2) ) { + _path.appendNew(Geom::Point(x1, y1), Geom::Point(x2, y2), Geom::Point(x3, y3)); + } else { + SPIRO_G_MESSAGE("spiro curveto not finite"); + } +} + +} // namespace Spiro + + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/spiro-converters.h b/src/live_effects/spiro-converters.h index dbc10efda..83f6ebbc3 100644 --- a/src/live_effects/spiro-converters.h +++ b/src/live_effects/spiro-converters.h @@ -24,7 +24,7 @@ public: class ConverterSPCurve : public ConverterBase { public: ConverterSPCurve(SPCurve &curve) - : _curve(curve), _is_open(false) + : _curve(curve) {} ; virtual void moveto(double x, double y, bool is_open); @@ -32,10 +32,9 @@ public: virtual void quadto(double x1, double y1, double x2, double y2); virtual void curveto(double x1, double y1, double x2, double y2, double x3, double y3); +private: SPCurve &_curve; - bool _is_open; -private: ConverterSPCurve(const ConverterSPCurve&); ConverterSPCurve& operator=(const ConverterSPCurve&); }; @@ -47,7 +46,7 @@ private: class ConverterPath : public ConverterBase { public: ConverterPath(Geom::Path &path) - : _path(path), _is_open(false) + : _path(path) {} ; virtual void moveto(double x, double y, bool is_open); @@ -55,10 +54,9 @@ public: virtual void quadto(double x1, double y1, double x2, double y2); virtual void curveto(double x1, double y1, double x2, double y2, double x3, double y3); +private: Geom::Path &_path; - bool _is_open; -private: ConverterPath(const ConverterPath&); ConverterPath& operator=(const ConverterPath&); }; -- cgit v1.2.3