Permalink
Browse files

Moved the expansion of the key codes into ApplicationUsage so that he…

…lp is only generated for non zero keycodes.
  • Loading branch information...
1 parent 1e11952 commit 529a4dfce5c373d7fe9ab7ba9782825b7a53ede4 @osg-training-guest osg-training-guest committed Dec 5, 2012
@@ -77,6 +77,8 @@ class OSG_EXPORT ApplicationUsage : public osg::Referenced
const UsageMap& getEnvironmentalVariablesDefaults() const { return _environmentalVariablesDefaults; }
+ void addKeyboardMouseBinding(const std::string& prefix, int key, const std::string& explanation);
+ void addKeyboardMouseBinding(int key, const std::string& explanation);
void addKeyboardMouseBinding(const std::string& option,const std::string& explanation);
void setKeyboardMouseBindings(const UsageMap& usageMap) { _keyboardMouse=usageMap; }
@@ -18,6 +18,8 @@
#include <osg/Math>
#include <osg/ref_ptr>
+#include <sstream>
+
using namespace osg;
ApplicationUsage::ApplicationUsage(const std::string& commandLineUsage):
@@ -42,7 +44,7 @@ void ApplicationUsage::addUsageExplanation(Type type,const std::string& option,c
addEnvironmentalVariable(option,explanation);
break;
case(KEYBOARD_MOUSE_BINDING):
- addKeyboardMouseBinding(option,explanation);
+ //addKeyboardMouseBinding(option,explanation);
break;
default:
break;
@@ -61,6 +63,32 @@ void ApplicationUsage::addEnvironmentalVariable(const std::string& option,const
_environmentalVariablesDefaults[option]=defaultValue;
}
+void ApplicationUsage::addKeyboardMouseBinding(const std::string& prefix, int key, const std::string& explanation)
+{
+ if (key!=0)
+ {
+ std::ostringstream ostr;
+ ostr<<prefix;
+
+ if (key==' ')
+ {
+ ostr<<"Space";
+ }
+ else if (key!=0)
+ {
+ ostr<<char(key);
+ }
+
+ _keyboardMouse[ostr.str()]=explanation;
+ }
+}
+
+
+void ApplicationUsage::addKeyboardMouseBinding(int key,const std::string& explanation)
+{
+ addKeyboardMouseBinding("",key,explanation);
+}
+
void ApplicationUsage::addKeyboardMouseBinding(const std::string& option,const std::string& explanation)
{
_keyboardMouse[option]=explanation;
@@ -206,5 +206,5 @@ void HelpHandler::setUpScene(osgViewer::ViewerBase* viewer)
void HelpHandler::getUsage(osg::ApplicationUsage& usage) const
{
- usage.addKeyboardMouseBinding("h","Onscreen help.");
+ if (_keyEventTogglesOnScreenHelp) usage.addKeyboardMouseBinding(_keyEventTogglesOnScreenHelp,"Onscreen help.");
}
@@ -11,8 +11,6 @@
* OpenSceneGraph Public License for more details.
*/
-#include <sstream>
-
#include <osgDB/WriteFile>
#include <osgViewer/Viewer>
@@ -851,17 +849,8 @@ void ScreenCaptureHandler::stopCapture()
/** Get the keyboard and mouse usage of this manipulator.*/
void ScreenCaptureHandler::getUsage(osg::ApplicationUsage& usage) const
{
- {
- std::ostringstream ostr;
- ostr<<char(_keyEventTakeScreenShot);
- usage.addKeyboardMouseBinding(ostr.str(),"Take screenshot.");
- }
-
- {
- std::ostringstream ostr;
- ostr<<char(_keyEventToggleContinuousCapture);
- usage.addKeyboardMouseBinding(ostr.str(),"Toggle continuous screen capture.");
- }
+ usage.addKeyboardMouseBinding(_keyEventTakeScreenShot,"Take screenshot.");
+ usage.addKeyboardMouseBinding(_keyEventToggleContinuousCapture,"Toggle continuous screen capture.");
}
}
@@ -1707,8 +1707,8 @@ void StatsHandler::createCameraTimeStats(osg::Vec3& pos, bool acquireGPUStats, o
void StatsHandler::getUsage(osg::ApplicationUsage& usage) const
{
- usage.addKeyboardMouseBinding("s","On screen stats.");
- usage.addKeyboardMouseBinding("S","Output stats to console.");
+ usage.addKeyboardMouseBinding(_keyEventTogglesOnScreenStats,"On screen stats.");
+ usage.addKeyboardMouseBinding(_keyEventPrintsOutStats,"Output stats to console.");
}
}
@@ -68,9 +68,9 @@ WindowSizeHandler::WindowSizeHandler() :
void WindowSizeHandler::getUsage(osg::ApplicationUsage &usage) const
{
- usage.addKeyboardMouseBinding(reinterpret_cast<const char*>(&_keyEventToggleFullscreen), "Toggle full screen.");
- usage.addKeyboardMouseBinding(reinterpret_cast<const char*>(&_keyEventWindowedResolutionUp), "Increase the screen resolution (in windowed mode).");
- usage.addKeyboardMouseBinding(reinterpret_cast<const char*>(&_keyEventWindowedResolutionDown), "Decrease the screen resolution (in windowed mode).");
+ usage.addKeyboardMouseBinding(_keyEventToggleFullscreen, "Toggle full screen.");
+ usage.addKeyboardMouseBinding(_keyEventWindowedResolutionUp, "Increase the screen resolution (in windowed mode).");
+ usage.addKeyboardMouseBinding(_keyEventWindowedResolutionDown, "Decrease the screen resolution (in windowed mode).");
}
bool WindowSizeHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
@@ -308,8 +308,8 @@ ThreadingHandler::ThreadingHandler() :
void ThreadingHandler::getUsage(osg::ApplicationUsage &usage) const
{
- usage.addKeyboardMouseBinding(reinterpret_cast<const char*>(&_keyEventChangeThreadingModel), "Toggle threading model.");
- usage.addKeyboardMouseBinding(reinterpret_cast<const char*>(&_keyEventChangeEndBarrierPosition), "Toggle the placement of the end of frame barrier.");
+ usage.addKeyboardMouseBinding(_keyEventChangeThreadingModel, "Toggle threading model.");
+ usage.addKeyboardMouseBinding(_keyEventChangeEndBarrierPosition, "Toggle the placement of the end of frame barrier.");
}
bool ThreadingHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
@@ -420,8 +420,8 @@ RecordCameraPathHandler::RecordCameraPathHandler(const std::string& filename, fl
void RecordCameraPathHandler::getUsage(osg::ApplicationUsage &usage) const
{
- usage.addKeyboardMouseBinding(reinterpret_cast<const char*>(&_keyEventToggleRecord), "Toggle camera path recording.");
- usage.addKeyboardMouseBinding(reinterpret_cast<const char*>(&_keyEventTogglePlayback), "Toggle camera path playback.");
+ usage.addKeyboardMouseBinding(_keyEventToggleRecord, "Toggle camera path recording.");
+ usage.addKeyboardMouseBinding(_keyEventTogglePlayback, "Toggle camera path playback.");
}
bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
@@ -631,17 +631,8 @@ bool LODScaleHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionA
void LODScaleHandler::getUsage(osg::ApplicationUsage& usage) const
{
- {
- std::ostringstream ostr;
- ostr<<char(_keyEventIncreaseLODScale);
- usage.addKeyboardMouseBinding(ostr.str(),"Increase LODScale.");
- }
-
- {
- std::ostringstream ostr;
- ostr<<char(_keyEventDecreaseLODScale);
- usage.addKeyboardMouseBinding(ostr.str(),"Decrease LODScale.");
- }
+ usage.addKeyboardMouseBinding(_keyEventIncreaseLODScale,"Increase LODScale.");
+ usage.addKeyboardMouseBinding(_keyEventDecreaseLODScale,"Decrease LODScale.");
}
ToggleSyncToVBlankHandler::ToggleSyncToVBlankHandler():
@@ -696,11 +687,7 @@ bool ToggleSyncToVBlankHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::
void ToggleSyncToVBlankHandler::getUsage(osg::ApplicationUsage& usage) const
{
- {
- std::ostringstream ostr;
- ostr<<char(_keyEventToggleSyncToVBlank);
- usage.addKeyboardMouseBinding(ostr.str(),"Toggle SyncToVBlank.");
- }
+ usage.addKeyboardMouseBinding(_keyEventToggleSyncToVBlank,"Toggle SyncToVBlank.");
}

0 comments on commit 529a4df

Please sign in to comment.