Commit 4806fa95 authored by Robin Eschbach's avatar Robin Eschbach
Browse files

[ADD #529] add keystrokes

parent 94a74a84
......@@ -28,8 +28,14 @@
static const unsigned int CTRL_DOWN = 65507;
static const unsigned int CTRL_UP = 16777249;
static const unsigned int KEY_Z = 90;
static const unsigned int SHIFT_DOWN = 65505;
static const unsigned int SHIFT_UP = 16777248;
static const unsigned int KEY_X = 88;
static const unsigned int KEY_Y = 89;
static const unsigned int KEY_Z = 90;
static const double SCALING_FACTOR = 2.0;
WKeyboardHandler::WKeyboardHandler( WMPointConnector* connector ):
m_connector( connector )
......@@ -44,6 +50,10 @@ bool WKeyboardHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActio
{
m_isCtrl = true;
}
else if( ea.getKey() == SHIFT_DOWN )
{
m_isShift = true;
}
else if( ea.getKey() == KEY_Z && m_isCtrl )
{
m_connector->getFiberHandler()->getActionHandler()->undo();
......@@ -54,6 +64,21 @@ bool WKeyboardHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActio
m_connector->getFiberHandler()->getActionHandler()->redo();
return true;
}
else if( ea.getKey() == KEY_X )
{
WPosition pos = m_connector->getScaling()->get();
m_connector->getScaling()->set( WPosition( pos.x() * ( m_isShift ? 1.0 / SCALING_FACTOR : SCALING_FACTOR ), pos.y(), pos.z() ) );
}
else if( ea.getKey() == KEY_Y )
{
WPosition pos = m_connector->getScaling()->get();
m_connector->getScaling()->set( WPosition( pos.x(), pos.y() * ( m_isShift ? 1.0 / SCALING_FACTOR : SCALING_FACTOR ), pos.z() ) );
}
else if( ea.getKey() == KEY_Z )
{
WPosition pos = m_connector->getScaling()->get();
m_connector->getScaling()->set( WPosition( pos.y(), pos.x(), pos.z() * ( m_isShift ? 1.0 / SCALING_FACTOR : SCALING_FACTOR ) ) );
}
}
if( ea.getEventType() == osgGA::GUIEventAdapter::KEYUP )
......@@ -62,6 +87,10 @@ bool WKeyboardHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActio
{
m_isCtrl = false;
}
else if( ea.getKey() == SHIFT_UP )
{
m_isShift = false;
}
}
return false;
......
......@@ -71,6 +71,11 @@ private:
* Whether ctrl is pressed or not.
*/
bool m_isCtrl = false;
/**
* Whether shift is pressed or not.
*/
bool m_isShift = false;
};
#endif // WKEYBOARDHANDLER_H
......@@ -632,3 +632,8 @@ std::shared_ptr< WOnscreenSelection > WMPointConnector::getOnscreenSelection()
{
return m_onscreenSelection;
}
WPropPosition WMPointConnector::getScaling()
{
return m_scaling;
}
......@@ -153,6 +153,12 @@ public:
*/
std::shared_ptr< WOnscreenSelection > getOnscreenSelection();
/**
*
* \return WPropPosition The scaling of this module.
*/
WPropPosition getScaling();
protected:
/**
* Entry point after loading the module. Runs in separate thread.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment