From 580891f18146a02b672624037dcbbb9b6755cd49 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Wed, 11 Jul 2012 13:21:58 +0200 Subject: [PATCH] Rename tf elements for easier handling. --- docs-mini/README.canvas | 10 ++++++---- src/Canvas/elements/element.cxx | 27 +++++++++++++-------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/docs-mini/README.canvas b/docs-mini/README.canvas index 8cc0b3004..a83865e10 100644 --- a/docs-mini/README.canvas +++ b/docs-mini/README.canvas @@ -76,14 +76,16 @@ only drawing Text is possible: Ratio between character height and width (default: 1) A 3x3 transformation matrix specified by 6 values - (child elements , ..., ) See + (child elements , ..., which equal to a, + ...,f used in the SVG standard) See http://www.w3.org/TR/SVG/coords.html#TransformMatrixDefined for details. You can also use shortcuts and use an alternative to specifying six values: - - Translation: , (ty, ty default to 0) - - Totation: - - Scale: , (sx is required, sy defaults to sx) + - Translation: , (both default to 0) + - Rotation: + - Scale: , (s[0] is required, s[1] + defaults to s[0]) Text alignment (default: "left-baseline") One of: "left-top" diff --git a/src/Canvas/elements/element.cxx b/src/Canvas/elements/element.cxx index 1695449aa..3c2cdc64b 100644 --- a/src/Canvas/elements/element.cxx +++ b/src/Canvas/elements/element.cxx @@ -56,19 +56,19 @@ namespace canvas switch( _transform_types[i] ) { case TT_MATRIX: - tf = osg::Matrix( tf_node->getDoubleValue("a", 1), - tf_node->getDoubleValue("b", 0), 0, 0, + tf = osg::Matrix( tf_node->getDoubleValue("m[0]", 1), + tf_node->getDoubleValue("m[1]", 0), 0, 0, - tf_node->getDoubleValue("c", 0), - tf_node->getDoubleValue("d", 1), 0, 0, + tf_node->getDoubleValue("m[2]", 0), + tf_node->getDoubleValue("m[3]", 1), 0, 0, 0, 0, 1, 0, - tf_node->getDoubleValue("e", 0), - tf_node->getDoubleValue("f", 0), 0, 1 ); + tf_node->getDoubleValue("m[4]", 0), + tf_node->getDoubleValue("m[5]", 0), 0, 1 ); break; case TT_TRANSLATE: - tf.makeTranslate( osg::Vec3f( tf_node->getDoubleValue("tx", 0), - tf_node->getDoubleValue("ty", 0), + tf.makeTranslate( osg::Vec3f( tf_node->getDoubleValue("t[0]", 0), + tf_node->getDoubleValue("t[1]", 0), 0 ) ); break; case TT_ROTATE: @@ -76,9 +76,9 @@ namespace canvas break; case TT_SCALE: { - float sx = tf_node->getDoubleValue("sx", 1); + float sx = tf_node->getDoubleValue("s[0]", 1); // sy defaults to sx... - tf.makeScale( sx, tf_node->getDoubleValue("sy", sx), 1 ); + tf.makeScale( sx, tf_node->getDoubleValue("s[1]", sx), 1 ); break; } default: @@ -151,14 +151,13 @@ namespace canvas TransformType& type = _transform_types[parent->getIndex()]; - if( name == "a" || name == "b" || name == "c" - || name == "d" || name == "e" || name == "f" ) + if( name == "m" ) type = TT_MATRIX; - else if( name == "tx" || name == "ty" ) + else if( name == "t" ) type = TT_TRANSLATE; else if( name == "rot" ) type = TT_ROTATE; - else if( name == "sx" || name == "sy" ) + else if( name == "s" ) type = TT_SCALE; else SG_LOG