From 40ded29902182436c0afb002d2bf9c7ac469f43c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 30 Sep 2007 15:06:59 +0000 Subject: [PATCH] From Dan Minor, "osgText::Text does not currently have a getAxisAlignment method. The attached code adds this, along with a member variable to keep track of the setting. It is based on the latest subversion version, and was tested by creating a new text object with the same axis alignment as an existing one (e.g. new_text->setAxisAlignment(old_text->getAxisAlignment()); )." From Robert Osfield, " I originally didn't add a getAxisAlignment() as all setAxisAlignment does is set the Rotation member variable, and potentially one could apply user defined Rotation setting after the setAxisAlignment() which would bring it out of sync with the setAxisAlignment. Rather than reject your submission on the ground of potentially getting out of sync and therefore misleading users I've added a USED_DEFINED_ROTATION to AxisAlignment enum, and set this in the serRotation and then override this setting of _axisAlignment in the setAxisAlingment method. I've also removed the lazy updating optimization you've added to the top of setAxisAlignment to avoid potential problems as well." --- include/osgText/Text | 5 ++++- src/osgText/Text.cpp | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/osgText/Text b/include/osgText/Text index 5f31c2db2..fce2f00c0 100644 --- a/include/osgText/Text +++ b/include/osgText/Text @@ -181,10 +181,12 @@ public: REVERSED_XZ_PLANE, YZ_PLANE, REVERSED_YZ_PLANE, - SCREEN + SCREEN, + USER_DEFINED_ROTATION }; void setAxisAlignment(AxisAlignment axis); + AxisAlignment getAxisAlignment() const { return _axisAlignment; } void setRotation(const osg::Quat& quat); const osg::Quat& getRotation() const { return _rotation; } @@ -533,6 +535,7 @@ protected: String _text; osg::Vec3 _position; AlignmentType _alignment; + AxisAlignment _axisAlignment; osg::Quat _rotation; bool _autoRotateToScreen; Layout _layout; diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index 1800883f8..84e210ac5 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -41,6 +41,7 @@ Text::Text(): _maximumHeight(0.0f), _lineSpacing(0.0f), _alignment(BASE_LINE), + _axisAlignment(XY_PLANE), _autoRotateToScreen(false), _layout(LEFT_TO_RIGHT), _color(1.0f,1.0f,1.0f,1.0f), @@ -77,6 +78,7 @@ Text::Text(const Text& text,const osg::CopyOp& copyop): _text(text._text), _position(text._position), _alignment(text._alignment), + _axisAlignment(text._axisAlignment), _rotation(text._rotation), _autoRotateToScreen(text._autoRotateToScreen), _layout(text._layout), @@ -199,6 +201,8 @@ void Text::setAlignment(AlignmentType alignment) void Text::setAxisAlignment(AxisAlignment axis) { + _axisAlignment = axis; + switch(axis) { case XZ_PLANE: