From de419075326d74e8352c2fbc51ba10b9ce3c1e8d Mon Sep 17 00:00:00 2001 From: Richard Harrison Date: Thu, 10 Mar 2022 15:06:28 +0100 Subject: [PATCH] Use helper method for OSGText alignment mapAlignment --- src/Cockpit/NavDisplay.cxx | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/src/Cockpit/NavDisplay.cxx b/src/Cockpit/NavDisplay.cxx index a2ed96883..2c81b024e 100644 --- a/src/Cockpit/NavDisplay.cxx +++ b/src/Cockpit/NavDisplay.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -90,37 +91,6 @@ static osg::Vec4 readColor(SGPropertyNode* colorNode, const osg::Vec4& c) return result; } -static osgText::Text::AlignmentType readAlignment(const std::string& t) -{ - if (t == "left-top") { - return osgText::Text::LEFT_TOP; - } else if (t == "left-center") { - return osgText::Text::LEFT_CENTER; - } else if (t == "left-bottom") { - return osgText::Text::LEFT_BOTTOM; - } else if (t == "center-top") { - return osgText::Text::CENTER_TOP; - } else if (t == "center-center") { - return osgText::Text::CENTER_CENTER; - } else if (t == "center-bottom") { - return osgText::Text::CENTER_BOTTOM; - } else if (t == "right-top") { - return osgText::Text::RIGHT_TOP; - } else if (t == "right-center") { - return osgText::Text::RIGHT_CENTER; - } else if (t == "right-bottom") { - return osgText::Text::RIGHT_BOTTOM; - } else if (t == "left-baseline") { - return osgText::Text::LEFT_BASE_LINE; - } else if (t == "center-baseline") { - return osgText::Text::CENTER_BASE_LINE; - } else if (t == "right-baseline") { - return osgText::Text::RIGHT_BASE_LINE; - } - - return osgText::Text::BASE_LINE; -} - static string formatPropertyValue(SGPropertyNode* nd, const string& format) { assert(nd); @@ -306,7 +276,7 @@ public: hasText = false; if (node->hasChild("text")) { hasText = true; - alignment = readAlignment(node->getStringValue("text-align")); + alignment = simgear::osgutils::mapAlignment(node->getStringValue("text-align")); textTemplate = node->getStringValue("text"); textOffset.x() = node->getFloatValue("text-offset-x", 0); textOffset.y() = node->getFloatValue("text-offset-y", 0);