Commit 77b572f7 authored by Robin Eschbach's avatar Robin Eschbach
Browse files

[ADD #139] automatic sorting to point connector

parent bfea5ce5
......@@ -47,9 +47,41 @@ WFiberHandler::WFiberHandler( WMPointConnector* pointConnector )
m_fiberCount = 1;
}
void WFiberHandler::sortVertices()
{
if( m_fibers->empty() )
{
return;
}
for( auto fiber = m_fibers->begin(); fiber != m_fibers->end(); fiber++ )
{
if( fiber->empty() )
{
continue;
}
std::sort( fiber->begin(), fiber->end(), []( osg::Vec3 a, osg::Vec3 b )
{
if( a.z() != b.z() )
{
return a.z() < b.z();
}
if(a.x() != b.x() )
{
return a.x() < b.x();
}
return a.y() < b.y();
} );
}
}
void WFiberHandler::addVertexToFiber( osg::Vec3 vertex, size_t fiberIdx, bool silent )
{
m_fibers->at( fiberIdx ).push_back( vertex );
sortVertices();
if( !silent )
{
......
......@@ -165,6 +165,11 @@ public:
*/
void selectLastPoint();
/**
* Sorts the vertices by their z value.
*/
void sortVertices();
/**
* Checks if a fiber is hidden.
* \param idx The index of the fiber to check.
......
......@@ -206,6 +206,8 @@ void WMPointConnector::handleInput()
m_fiberHandler->setFiberCount( fibers->size() );
m_fiberHandler->selectorUpdate( fibers->size() - 1 );
m_fiberHandler->sortVertices();
updatePoints();
updateOutput();
}
......@@ -271,10 +273,12 @@ void WMPointConnector::handleClick( osg::Vec3 cameraPosition, osg::Vec3 directio
{
if( m_fiberHandler->getSelectedFiber() == fiberIdx )
{
return;
m_connectorData->selectPoint( hitIdx );
}
else {
m_fiberHandler->selectFiber( fiberIdx );
m_fiberHandler->selectorUpdate( fiberIdx );
}
m_fiberHandler->selectFiber( fiberIdx );
m_fiberHandler->selectorUpdate( fiberIdx );
}
else
{
......
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