Commit 474c0c8a authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[ADD] use normal information provided by WPickInfo.

[ADD] ROIBoxes can be resized now
parent 5adfda9b
......@@ -71,6 +71,11 @@ bool WPickHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAda
}
return false;
}
case osgGA::GUIEventAdapter::KEYUP : // Key on keyboard released.
{
m_shift = false;
return false;
}
case osgGA::GUIEventAdapter::KEYDOWN : // Key on keyboard pushed.
{
if ( ea.getKey() == 'c' )
......@@ -84,6 +89,10 @@ bool WPickHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAda
pick( view, *event );
}
}
if ( ea.getKey() == osgGA::GUIEventAdapter::KEY_Shift_L )
{
m_shift = true;
}
return false;
}
default:
......@@ -155,7 +164,17 @@ void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea
pickPos[0] = hitr->getWorldIntersectPoint()[0];
pickPos[1] = hitr->getWorldIntersectPoint()[1];
pickPos[2] = hitr->getWorldIntersectPoint()[2];
pickInfo = WPickInfo( extractSuitableName( hitr ), pickPos, std::make_pair( x, y ), WPickInfo::NONE );
wmath::WVector3D pickNormal;
pickNormal[0] = hitr->getWorldIntersectNormal()[0];
pickNormal[1] = hitr->getWorldIntersectNormal()[1];
pickNormal[2] = hitr->getWorldIntersectNormal()[2];
pickInfo = WPickInfo( extractSuitableName( hitr ), pickPos, std::make_pair( x, y ), WPickInfo::NONE, pickNormal );
}
if( m_shift )
{
pickInfo.setModifierKey( WPickInfo::SHIFT );
}
m_hitResult = pickInfo;
......
......@@ -98,6 +98,7 @@ protected:
WPickInfo m_hitResult; //!< Textual representation of the result of a pick.
WPickInfo m_startPick; //!< indicates what was first picked. Should be "" after unpick.
bool m_shift; //!< is shift pressed?
private:
boost::signals2::signal1<void, WPickInfo > m_pickSignal; //!< One can register to this signal to receive pick events.
......
......@@ -239,10 +239,32 @@ void WROIBox::updateGFX()
wmath::WVector3D moveVec = newPixelWorldPos - oldPixelWorldPos;
osg::Vec3Array* vertices = new osg::Vec3Array;
m_minPos += moveVec;
m_maxPos += moveVec;
setVertices( vertices, m_minPos, m_maxPos );
( ( osg::Geometry* ) ( m_geode->getDrawable( 0 ) ) )->setVertexArray( vertices );
// resize Box
if( m_pickInfo.getModifierKey() == WPickInfo::SHIFT && m_pickInfo.getPickNormal() != wmath::WVector3D() )
{
wmath::WVector3D normal = m_pickInfo.getPickNormal();
if( normal[0] <= 0 && normal[1] <= 0 && normal[2] <= 0 )
{
m_maxPos += normal * ( moveVec * normal );
}
if( normal[0] >= 0 && normal[1] >= 0 && normal[2] >= 0 )
{
m_minPos += normal * ( moveVec * normal );
}
setVertices( vertices, m_minPos, m_maxPos );
( ( osg::Geometry* ) ( m_geode->getDrawable( 0 ) ) )->setVertexArray( vertices );
}
// move Box
if( m_pickInfo.getModifierKey() == WPickInfo::NONE )
{
m_minPos += moveVec;
m_maxPos += moveVec;
setVertices( vertices, m_minPos, m_maxPos );
( ( osg::Geometry* ) ( m_geode->getDrawable( 0 ) ) )->setVertexArray( vertices );
}
}
else
{
......
......@@ -198,9 +198,11 @@ void WMHud::updatePickText( WPickInfo pickInfo )
lock = boost::unique_lock< boost::shared_mutex >( m_updateLock );
std::ostringstream os;
os << pickInfo.getName() << "\n"
<< pickInfo.getPickPosition() << "\n"
<< pickInfo.getPickPixelPosition().first << " " << pickInfo.getPickPixelPosition().second;
os << "Name: " << pickInfo.getName() << "\n"
<< "Position: " << pickInfo.getPickPosition() << "\n"
<< "Pixel coordinates: " << pickInfo.getPickPixelPosition().first << " " << pickInfo.getPickPixelPosition().second << "\n"
<< "Object normal: " << pickInfo.getPickNormal();
m_pickText = os.str();
lock.unlock();
......
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