Commit 3e0c707e authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[REFAC] made "unpick" string a static const member to remove duplication

DRY!
parent de5c7146
......@@ -28,6 +28,8 @@
#include "WPickHandler.h"
const std::string WPickHandler::unpickString = "unpick";
WPickHandler::WPickHandler()
: m_hitResult( WPickInfo() ),
m_startPick( WPickInfo() ),
......@@ -182,7 +184,7 @@ void WPickHandler::unpick( )
m_inPickMode = false;
if( m_hitResult != WPickInfo() )
{
m_hitResult = WPickInfo( "unpick", m_viewerName, WPosition(), std::make_pair( 0, 0 ), WPickInfo::NONE );
m_hitResult = WPickInfo( WPickHandler::unpickString, m_viewerName, WPosition(), std::make_pair( 0, 0 ), WPickInfo::NONE );
m_startPick = WPickInfo();
m_scrollWheel = 0;
}
......@@ -290,7 +292,7 @@ void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea
}
// if we have a previous pick we search for it in the list
if( m_startPick.getName() != "" && m_startPick.getName() != "unpick" )
if( m_startPick.getName() != "" && m_startPick.getName() != WPickHandler::unpickString )
{
while( ( hitr != intersections.end() ) && !startPickIsStillInList )
{
......@@ -321,7 +323,7 @@ void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea
}
// Set the new pickInfo if the previously picked is still in list or we have a pick in conjunction with previously no pick
if( startPickIsStillInList || ( intersetionsExist && ( m_startPick.getName() == "unpick" || m_startPick.getName() == "" ) ) )
if( startPickIsStillInList || ( intersetionsExist && ( m_startPick.getName() == WPickHandler::unpickString || m_startPick.getName() == "" ) ) )
{
// if nothing was picked before, or the previously picked was found: set new pickInfo
WPosition pickPos;
......@@ -338,7 +340,7 @@ void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea
}
// Use the old PickInfo with updated pixel info if we have previously picked something but the old is not in list anymore
if( !startPickIsStillInList && m_startPick.getName() != "" && m_startPick.getName() != "unpick" )
if( !startPickIsStillInList && m_startPick.getName() != "" && m_startPick.getName() != WPickHandler::unpickString )
{
pickInfo = WPickInfo( m_startPick.getName(), m_viewerName, m_startPick.getPickPosition(), std::make_pair( x, y ),
m_startPick.getModifierKey(), m_mouseButton, m_startPick.getPickNormal(), m_scrollWheel );
......
......@@ -72,7 +72,7 @@ public:
virtual void pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea );
/**
* Send a pick signal with the string "unpick"
* Send a pick signal with the unpickString
*/
virtual void unpick();
......@@ -94,6 +94,8 @@ public:
*/
void setPaintMode( int mode );
static const std::string unpickString; //!< The string indicating picking has stopped.
protected:
/**
* Virtual destructor needed because of virtual function.
......
......@@ -222,7 +222,7 @@ void WROIBox::updateGFX()
m_isPicked = true;
m_oldScrollWheel = m_pickInfo.getScrollWheel();
}
if( m_isPicked && m_pickInfo.getName() == "unpick" )
if( m_isPicked && m_pickInfo.getName() == WPickHandler::unpickString )
{
// Perform all actions necessary for finishing a pick
if( m_not->get() )
......
......@@ -187,7 +187,7 @@ void WROISphere::updateGFX()
m_dirty->set( true );
m_isPicked = true;
}
if( m_isPicked && m_pickInfo.getName() == "unpick" )
if( m_isPicked && m_pickInfo.getName() == WPickHandler::unpickString )
{
// Perform all actions necessary for finishing a pick
m_pickNormal = WVector3d();
......
......@@ -380,7 +380,7 @@ void WMPaintTexture::queuePaint( WPickInfo pickInfo )
return;
}
if( !m_painting->get() || ( pickInfo.getMouseButton() != WPickInfo::MOUSE_LEFT ) || ( pickInfo.getName() == "unpick" ) )
if( !m_painting->get() || ( pickInfo.getMouseButton() != WPickInfo::MOUSE_LEFT ) || ( pickInfo.getName() == WPickHandler::unpickString ) )
{
return;
}
......
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