Permalink
Browse files

Added support for 0x and numeric defintion of keys to be used with <c…

…lick_to_event> functionality.
  • Loading branch information...
1 parent 181b810 commit 079de03c0ef65f382d10238f2886254d6f13eedb @osg-training-guest osg-training-guest committed Nov 30, 2012
Showing with 20 additions and 0 deletions.
  1. +1 −0 applications/present3D/present3D.cpp
  2. +19 −0 src/osgPlugins/p3d/ReaderWriterP3D.cpp
@@ -136,6 +136,7 @@ class ForwardToDeviceEventHandler : public osgGA::GUIEventHandler {
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *)
{
+ OSG_INFO<<"ForwardToDeviceEventHandler::setEvent("<<ea.getKey()<<")"<<std::endl;
_device->sendEvent(ea);
return false;
}
@@ -1371,13 +1371,32 @@ bool ReaderWriterP3DXML::getKeyPositionInner(osgDB::XmlNode*cur, osgPresentation
std::string key = cur->getTrimmedContents();
unsigned int keyValue = 0;
+ if (key.empty())
+ {
+ OSG_NOTICE<<"Warning: empty <key></key> is invalid, ignoring tag."<<std::endl;
+ return false;
+ }
+
StringKeyMap::const_iterator itr=_stringKeyMap.find(key);
if (itr != _stringKeyMap.end())
{
keyValue = itr->second;
}
+ if (key.find("0x",0,2)!=std::string::npos)
+ {
+ std::istringstream iss(key);
+ iss>>std::hex>>keyValue;
+ OSG_INFO<<"ReaderWriterP3DXML::getKeyPositionInner() hex result = "<<keyValue<<std::endl;
+ }
+ else if (key.size()>1 && (key[0]>='0' && key[0]<='9'))
+ {
+ std::istringstream iss(key);
+ iss>>keyValue;
+ OSG_INFO<<"ReaderWriterP3DXML::getKeyPositionInner() numeric result = "<<keyValue<<std::endl;
+ }
else if (key.length()==1)
{
+ OSG_INFO<<"ReaderWriterP3DXML::getKeyPositionInner() alphanumeric result = "<<keyValue<<std::endl;
keyValue = key[0];
}
else

0 comments on commit 079de03

Please sign in to comment.