diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-04-07 23:42:04 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-04-07 23:42:04 +0000 |
| commit | 945ce419c806c73d70203dec33ececafbe108a92 (patch) | |
| tree | cfcdb59bf47e9db7f9e01f7eebb59924bdeaea94 /src/svg | |
| parent | Merge from trunk (again) (diff) | |
| parent | Extensions. SVG+media fix (see Bug #400356). (diff) | |
| download | inkscape-945ce419c806c73d70203dec33ececafbe108a92.tar.gz inkscape-945ce419c806c73d70203dec33ececafbe108a92.zip | |
Merge from trunk
(bzr r9508.1.73)
Diffstat (limited to 'src/svg')
| -rw-r--r-- | src/svg/svg-affine-test.h | 80 | ||||
| -rw-r--r-- | src/svg/svg-affine.cpp | 16 | ||||
| -rw-r--r-- | src/svg/svg-path.cpp | 6 | ||||
| -rw-r--r-- | src/svg/svg.h | 6 |
4 files changed, 54 insertions, 54 deletions
diff --git a/src/svg/svg-affine-test.h b/src/svg/svg-affine-test.h index be5a941bb..11b9012a8 100644 --- a/src/svg/svg-affine-test.h +++ b/src/svg/svg-affine-test.h @@ -2,7 +2,7 @@ #include "svg/svg.h" #include "streq.h" -#include <2geom/matrix.h> +#include <2geom/affine.h> #include <algorithm> #include <glib.h> #include <iostream> @@ -14,10 +14,10 @@ class SvgAffineTest : public CxxTest::TestSuite private: struct test_t { char const * str; - Geom::Matrix matrix; + Geom::Affine matrix; }; struct approx_equal_pred { - bool operator()(Geom::Matrix const &ref, Geom::Matrix const &cm) const + bool operator()(Geom::Affine const &ref, Geom::Affine const &cm) const { double maxabsdiff = 0; for(size_t i=0; i<6; i++) { @@ -59,7 +59,7 @@ public: "skewY(0)"}; size_t n = G_N_ELEMENTS(strs); for(size_t i=0; i<n; i++) { - Geom::Matrix cm; + Geom::Affine cm; TSM_ASSERT(strs[i] , sp_svg_transform_read(strs[i], &cm)); TSM_ASSERT_EQUALS(strs[i] , Geom::identity() , cm); } @@ -73,7 +73,7 @@ public: void testReadMatrix() { for(size_t i=0; i<G_N_ELEMENTS(read_matrix_tests); i++) { - Geom::Matrix cm; + Geom::Affine cm; TSM_ASSERT(read_matrix_tests[i].str , sp_svg_transform_read(read_matrix_tests[i].str, &cm)); TSM_ASSERT_RELATION(read_matrix_tests[i].str , approx_equal_pred , read_matrix_tests[i].matrix , cm); } @@ -82,7 +82,7 @@ public: void testReadTranslate() { for(size_t i=0; i<G_N_ELEMENTS(read_translate_tests); i++) { - Geom::Matrix cm; + Geom::Affine cm; TSM_ASSERT(read_translate_tests[i].str , sp_svg_transform_read(read_translate_tests[i].str, &cm)); TSM_ASSERT_RELATION(read_translate_tests[i].str , approx_equal_pred , read_translate_tests[i].matrix , cm); } @@ -91,7 +91,7 @@ public: void testReadScale() { for(size_t i=0; i<G_N_ELEMENTS(read_scale_tests); i++) { - Geom::Matrix cm; + Geom::Affine cm; TSM_ASSERT(read_scale_tests[i].str , sp_svg_transform_read(read_scale_tests[i].str, &cm)); TSM_ASSERT_RELATION(read_scale_tests[i].str , approx_equal_pred , read_scale_tests[i].matrix , cm); } @@ -100,7 +100,7 @@ public: void testReadRotate() { for(size_t i=0; i<G_N_ELEMENTS(read_rotate_tests); i++) { - Geom::Matrix cm; + Geom::Affine cm; TSM_ASSERT(read_rotate_tests[i].str , sp_svg_transform_read(read_rotate_tests[i].str, &cm)); TSM_ASSERT_RELATION(read_rotate_tests[i].str , approx_equal_pred , read_rotate_tests[i].matrix , cm); } @@ -109,7 +109,7 @@ public: void testReadSkew() { for(size_t i=0; i<G_N_ELEMENTS(read_skew_tests); i++) { - Geom::Matrix cm; + Geom::Affine cm; TSM_ASSERT(read_skew_tests[i].str , sp_svg_transform_read(read_skew_tests[i].str, &cm)); TSM_ASSERT_RELATION(read_skew_tests[i].str , approx_equal_pred , read_skew_tests[i].matrix , cm); } @@ -166,8 +166,8 @@ public: // there should be 1 or more comma-wsp sequences between transforms... This doesn't make sense and it seems // likely that instead of a + they meant a ? (zero or one comma-wsp sequences). char const * str = "skewY(17)skewX(9)translate(7,13)scale(2)rotate(13)translate(3,5)"; - Geom::Matrix ref(2.0199976232558053, 1.0674773585906016, -0.14125199392774669, 1.9055550612095459, 14.412730624347654, 28.499820929377454); // Precomputed using Mathematica - Geom::Matrix cm; + Geom::Affine ref(2.0199976232558053, 1.0674773585906016, -0.14125199392774669, 1.9055550612095459, 14.412730624347654, 28.499820929377454); // Precomputed using Mathematica + Geom::Affine cm; TS_ASSERT(sp_svg_transform_read(str, &cm)); TS_ASSERT_RELATION(approx_equal_pred , ref , cm); } @@ -175,7 +175,7 @@ public: void testReadFailures() { for(size_t i=0; i<G_N_ELEMENTS(read_fail_tests); i++) { - Geom::Matrix cm; + Geom::Affine cm; TSM_ASSERT(read_fail_tests[i] , !sp_svg_transform_read(read_fail_tests[i], &cm)); } } @@ -184,26 +184,26 @@ public: static double const DEGREE = M_PI/180.; SvgAffineTest::test_t const SvgAffineTest::read_matrix_tests[3] = { - {"matrix(0,0,0,0,0,0)",Geom::Matrix(0,0,0,0,0,0)}, - {" matrix(1,2,3,4,5,6)",Geom::Matrix(1,2,3,4,5,6)}, - {"matrix (1 2 -3,-4,5e6,-6e-7)",Geom::Matrix(1,2,-3,-4,5e6,-6e-7)}}; + {"matrix(0,0,0,0,0,0)",Geom::Affine(0,0,0,0,0,0)}, + {" matrix(1,2,3,4,5,6)",Geom::Affine(1,2,3,4,5,6)}, + {"matrix (1 2 -3,-4,5e6,-6e-7)",Geom::Affine(1,2,-3,-4,5e6,-6e-7)}}; SvgAffineTest::test_t const SvgAffineTest::read_translate_tests[3] = { - {"translate(1)",Geom::Matrix(1,0,0,1,1,0)}, - {"translate(1,1)",Geom::Matrix(1,0,0,1,1,1)}, - {"translate(-1e3 .123e2)",Geom::Matrix(1,0,0,1,-1e3,.123e2)}}; + {"translate(1)",Geom::Affine(1,0,0,1,1,0)}, + {"translate(1,1)",Geom::Affine(1,0,0,1,1,1)}, + {"translate(-1e3 .123e2)",Geom::Affine(1,0,0,1,-1e3,.123e2)}}; SvgAffineTest::test_t const SvgAffineTest::read_scale_tests[3] = { - {"scale(2)",Geom::Matrix(2,0,0,2,0,0)}, - {"scale(2,3)",Geom::Matrix(2,0,0,3,0,0)}, - {"scale(0.1e-2 -.475e0)",Geom::Matrix(0.1e-2,0,0,-.475e0,0,0)}}; + {"scale(2)",Geom::Affine(2,0,0,2,0,0)}, + {"scale(2,3)",Geom::Affine(2,0,0,3,0,0)}, + {"scale(0.1e-2 -.475e0)",Geom::Affine(0.1e-2,0,0,-.475e0,0,0)}}; SvgAffineTest::test_t const SvgAffineTest::read_rotate_tests[4] = { - {"rotate(13 )",Geom::Matrix(cos(13.*DEGREE),sin(13.*DEGREE),-sin(13.*DEGREE),cos(13.*DEGREE),0,0)}, - {"rotate(-13)",Geom::Matrix(cos(-13.*DEGREE),sin(-13.*DEGREE),-sin(-13.*DEGREE),cos(-13.*DEGREE),0,0)}, - {"rotate(373)",Geom::Matrix(cos(13.*DEGREE),sin(13.*DEGREE),-sin(13.*DEGREE),cos(13.*DEGREE),0,0)}, - {"rotate(13,7,11)",Geom::Matrix(cos(13.*DEGREE),sin(13.*DEGREE),-sin(13.*DEGREE),cos(13.*DEGREE),(1-cos(13.*DEGREE))*7+sin(13.*DEGREE)*11,(1-cos(13.*DEGREE))*11-sin(13.*DEGREE)*7)}}; + {"rotate(13 )",Geom::Affine(cos(13.*DEGREE),sin(13.*DEGREE),-sin(13.*DEGREE),cos(13.*DEGREE),0,0)}, + {"rotate(-13)",Geom::Affine(cos(-13.*DEGREE),sin(-13.*DEGREE),-sin(-13.*DEGREE),cos(-13.*DEGREE),0,0)}, + {"rotate(373)",Geom::Affine(cos(13.*DEGREE),sin(13.*DEGREE),-sin(13.*DEGREE),cos(13.*DEGREE),0,0)}, + {"rotate(13,7,11)",Geom::Affine(cos(13.*DEGREE),sin(13.*DEGREE),-sin(13.*DEGREE),cos(13.*DEGREE),(1-cos(13.*DEGREE))*7+sin(13.*DEGREE)*11,(1-cos(13.*DEGREE))*11-sin(13.*DEGREE)*7)}}; SvgAffineTest::test_t const SvgAffineTest::read_skew_tests[3] = { - {"skewX( 30)",Geom::Matrix(1,0,tan(30.*DEGREE),1,0,0)}, - {"skewX(-30)",Geom::Matrix(1,0,tan(-30.*DEGREE),1,0,0)}, - {"skewY(390)",Geom::Matrix(1,tan(30.*DEGREE),0,1,0,0)}}; + {"skewX( 30)",Geom::Affine(1,0,tan(30.*DEGREE),1,0,0)}, + {"skewX(-30)",Geom::Affine(1,0,tan(-30.*DEGREE),1,0,0)}, + {"skewY(390)",Geom::Affine(1,tan(30.*DEGREE),0,1,0,0)}}; char const * const SvgAffineTest::read_fail_tests[25] = { "matrix((1,2,3,4,5,6)", "matrix((1,2,3,4,5,6))", @@ -232,22 +232,22 @@ char const * const SvgAffineTest::read_fail_tests[25] = { "skewY(1,2)"}; SvgAffineTest::test_t const SvgAffineTest::write_matrix_tests[2] = { - {"matrix(1,2,3,4,5,6)",Geom::Matrix(1,2,3,4,5,6)}, - {"matrix(-1,2123,3,0.4,1e-8,1e20)",Geom::Matrix(-1,2.123e3,3+1e-14,0.4,1e-8,1e20)}}; + {"matrix(1,2,3,4,5,6)",Geom::Affine(1,2,3,4,5,6)}, + {"matrix(-1,2123,3,0.4,1e-8,1e20)",Geom::Affine(-1,2.123e3,3+1e-14,0.4,1e-8,1e20)}}; SvgAffineTest::test_t const SvgAffineTest::write_translate_tests[3] = { - {"translate(1,1)",Geom::Matrix(1,0,0,1,1,1)}, - {"translate(1)",Geom::Matrix(1,0,0,1,1,0)}, - {"translate(-1345,0.123)",Geom::Matrix(1,0,0,1,-1.345e3,.123)}}; + {"translate(1,1)",Geom::Affine(1,0,0,1,1,1)}, + {"translate(1)",Geom::Affine(1,0,0,1,1,0)}, + {"translate(-1345,0.123)",Geom::Affine(1,0,0,1,-1.345e3,.123)}}; SvgAffineTest::test_t const SvgAffineTest::write_scale_tests[2] = { - {"scale(0)",Geom::Matrix(0,0,0,0,0,0)}, - {"scale(2,3)",Geom::Matrix(2,0,0,3,0,0)}}; + {"scale(0)",Geom::Affine(0,0,0,0,0,0)}, + {"scale(2,3)",Geom::Affine(2,0,0,3,0,0)}}; SvgAffineTest::test_t const SvgAffineTest::write_rotate_tests[2] = { - {"rotate(13)",Geom::Matrix(cos(13.*DEGREE),sin(13.*DEGREE),-sin(13.*DEGREE),cos(13.*DEGREE),0,0)}, - {"rotate(-13,7,11)",Geom::Matrix(cos(-13.*DEGREE),sin(-13.*DEGREE),-sin(-13.*DEGREE),cos(-13.*DEGREE),(1-cos(-13.*DEGREE))*7+sin(-13.*DEGREE)*11,(1-cos(-13.*DEGREE))*11-sin(-13.*DEGREE)*7)}}; + {"rotate(13)",Geom::Affine(cos(13.*DEGREE),sin(13.*DEGREE),-sin(13.*DEGREE),cos(13.*DEGREE),0,0)}, + {"rotate(-13,7,11)",Geom::Affine(cos(-13.*DEGREE),sin(-13.*DEGREE),-sin(-13.*DEGREE),cos(-13.*DEGREE),(1-cos(-13.*DEGREE))*7+sin(-13.*DEGREE)*11,(1-cos(-13.*DEGREE))*11-sin(-13.*DEGREE)*7)}}; SvgAffineTest::test_t const SvgAffineTest::write_skew_tests[3] = { - {"skewX(30)",Geom::Matrix(1,0,tan(30.*DEGREE),1,0,0)}, - {"skewX(-30)",Geom::Matrix(1,0,tan(-30.*DEGREE),1,0,0)}, - {"skewY(390)",Geom::Matrix(1,tan(30.*DEGREE),0,1,0,0)}}; + {"skewX(30)",Geom::Affine(1,0,tan(30.*DEGREE),1,0,0)}, + {"skewX(-30)",Geom::Affine(1,0,tan(-30.*DEGREE),1,0,0)}, + {"skewY(390)",Geom::Affine(1,tan(30.*DEGREE),0,1,0,0)}}; /* Local Variables: diff --git a/src/svg/svg-affine.cpp b/src/svg/svg-affine.cpp index b61d09a79..a986e5986 100644 --- a/src/svg/svg-affine.cpp +++ b/src/svg/svg-affine.cpp @@ -30,7 +30,7 @@ #endif bool -sp_svg_transform_read(gchar const *str, Geom::Matrix *transform) +sp_svg_transform_read(gchar const *str, Geom::Affine *transform) { int idx; char keyword[32]; @@ -40,7 +40,7 @@ sp_svg_transform_read(gchar const *str, Geom::Matrix *transform) if (str == NULL) return false; - Geom::Matrix a(Geom::identity()); + Geom::Affine a(Geom::identity()); idx = 0; while (str[idx]) { @@ -100,7 +100,7 @@ sp_svg_transform_read(gchar const *str, Geom::Matrix *transform) /* ok, have parsed keyword and args, now modify the transform */ if (!strcmp (keyword, "matrix")) { if (n_args != 6) return false; - a = (*((Geom::Matrix *) &(args)[0])) * a; + a = (*((Geom::Affine *) &(args)[0])) * a; } else if (!strcmp (keyword, "translate")) { if (n_args == 1) { args[1] = 0; @@ -124,19 +124,19 @@ sp_svg_transform_read(gchar const *str, Geom::Matrix *transform) a = ( Geom::Translate(-args[1], -args[2]) * rot * Geom::Translate(args[1], args[2]) - * Geom::Matrix(a) ); + * Geom::Affine(a) ); } else { a = rot * a; } } else if (!strcmp (keyword, "skewX")) { if (n_args != 1) return false; - a = ( Geom::Matrix(1, 0, + a = ( Geom::Affine(1, 0, tan(args[0] * M_PI / 180.0), 1, 0, 0) * a ); } else if (!strcmp (keyword, "skewY")) { if (n_args != 1) return false; - a = ( Geom::Matrix(1, tan(args[0] * M_PI / 180.0), + a = ( Geom::Affine(1, tan(args[0] * M_PI / 180.0), 0, 1, 0, 0) * a ); @@ -154,7 +154,7 @@ sp_svg_transform_read(gchar const *str, Geom::Matrix *transform) #define EQ(a,b) (fabs ((a) - (b)) < 1e-9) gchar * -sp_svg_transform_write(Geom::Matrix const &transform) +sp_svg_transform_write(Geom::Affine const &transform) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -243,7 +243,7 @@ sp_svg_transform_write(Geom::Matrix const &transform) gchar * -sp_svg_transform_write(Geom::Matrix const *transform) +sp_svg_transform_write(Geom::Affine const *transform) { return sp_svg_transform_write(*transform); } diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 22af18acb..8781d75e6 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -93,9 +93,9 @@ static void sp_svg_write_curve(Inkscape::SVG::PathString & str, Geom::Curve cons (*cubic_bezier)[3][0], (*cubic_bezier)[3][1] ); } else if(Geom::SVGEllipticalArc const *svg_elliptical_arc = dynamic_cast<Geom::SVGEllipticalArc const *>(c)) { - str.arcTo( svg_elliptical_arc->ray(0), svg_elliptical_arc->ray(1), - Geom::rad_to_deg(svg_elliptical_arc->rotation_angle()), - svg_elliptical_arc->large_arc_flag(), svg_elliptical_arc->sweep_flag(), + str.arcTo( svg_elliptical_arc->ray(Geom::X), svg_elliptical_arc->ray(Geom::Y), + Geom::rad_to_deg(svg_elliptical_arc->rotationAngle()), + svg_elliptical_arc->largeArc(), svg_elliptical_arc->sweep(), svg_elliptical_arc->finalPoint() ); } else if(Geom::HLineSegment const *hline_segment = dynamic_cast<Geom::HLineSegment const *>(c)) { diff --git a/src/svg/svg.h b/src/svg/svg.h index 237a5d348..d5335e1b4 100644 --- a/src/svg/svg.h +++ b/src/svg/svg.h @@ -54,10 +54,10 @@ unsigned int sp_svg_length_read_ldd( const gchar *str, SVGLength::Unit *unit, do std::string sp_svg_length_write_with_units(SVGLength const &length); -bool sp_svg_transform_read(gchar const *str, Geom::Matrix *transform); +bool sp_svg_transform_read(gchar const *str, Geom::Affine *transform); -gchar *sp_svg_transform_write(Geom::Matrix const &transform); -gchar *sp_svg_transform_write(Geom::Matrix const *transform); +gchar *sp_svg_transform_write(Geom::Affine const &transform); +gchar *sp_svg_transform_write(Geom::Affine const *transform); double sp_svg_read_percentage( const char * str, double def ); |
