Commit f53b6d62 authored by Robin Eschbach's avatar Robin Eschbach
Browse files

[ADD #441] point deletion with multiselection

parent 779a6030
......@@ -30,7 +30,8 @@ WOnscreenSelection::WOnscreenSelection():
m_selectionHandler( new WOnscreenSelectionHandler( this ) ),
m_isSelecting( false ),
m_shader( new WGEShader( "WOnscreenSelection" ) ),
m_thickness( 25.0f )
m_thickness( 25.0f ),
m_clickType( false )
{
WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getView()->addEventHandler( m_selectionHandler.get() );
}
......@@ -146,6 +147,8 @@ void WOnscreenSelection::updateDisplay()
m_projection->getOrCreateStateSet()->setDataVariance( osg::Object::DYNAMIC );
m_projection->getOrCreateStateSet()->setMode( GL_DEPTH_TEST, osg::StateAttribute::OFF );
m_projection->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
m_projection->getOrCreateStateSet()->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
m_projection->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
osg::ref_ptr< osg::Geode > lines = new osg::Geode();
osg::ref_ptr< osg::Geometry > geometry = new osg::Geometry();
......@@ -216,6 +219,7 @@ void WOnscreenSelection::updateDisplay()
osg::Camera* camera = WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getCamera();
state->addUniform( new osg::Uniform( "u_viewport", osg::Vec2( camera->getViewport()->width(), camera->getViewport()->height() ) ) );
state->addUniform( new osg::Uniform( "u_thickness", thickness ) );
state->addUniform( new osg::Uniform( "u_clickType", m_clickType ) );
osg::ref_ptr< osg::MatrixTransform > matrix = new osg::MatrixTransform();
matrix->setMatrix( osg::Matrix::identity() );
......@@ -305,7 +309,7 @@ bool WOnscreenSelection::boxCheck( float x, float y )
bool WOnscreenSelection::brushCheck( float x, float y )
{
osg::Camera* camera = WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getCamera();
float thick2 = m_thickness * m_thickness;
float thick2 = ( m_thickness * 0.5 ) * ( m_thickness * 0.5 ); // * 0.5 because we need distance to center of the brush
float width = camera->getViewport()->width();
float height = camera->getViewport()->height();
......@@ -393,3 +397,13 @@ int WOnscreenSelection::crossingNumberProduct( float x, float y, WPosition b, WP
float delta = ( b.x() - x ) * ( c.y() - y ) - ( b.y() - y ) * ( c.x() - x );
return delta > 0 ? -1 : delta < 0 ? 1 : 0;
}
void WOnscreenSelection::setClickType(bool clickType)
{
m_clickType = clickType;
}
bool WOnscreenSelection::getClickType()
{
return m_clickType;
}
......@@ -28,11 +28,13 @@
#include <vector>
#include <boost/function.hpp>
#include <osg/Depth>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/LineWidth>
#include <osg/Projection>
#include "core/graphicsEngine/postprocessing/WGEPostprocessingNode.h"
#include "core/graphicsEngine/shaders/WGEShader.h"
#include "core/kernel/WKernel.h"
#include "WOnscreenSelectionHandler.h"
......@@ -191,6 +193,19 @@ public:
*/
int crossingNumberProduct( float x, float y, WPosition b, WPosition c );
/**
* Sets the click type.
* \param clickType true for left click, false for right click.
*/
void setClickType( bool clickType );
/**
* Gets the click type.
* \return true left click.
* \return false right click.
*/
bool getClickType();
private:
/**
* Updates the current rendered data.
......@@ -211,6 +226,8 @@ private:
float m_thickness; //!< The thickness of the brush.
bool m_clickType; //!< Whether this is a left click or not.
CallbackType m_onstart; //!< The Callback for the start function.
CallbackType m_onend; //!< The Callback for the end function.
......
......@@ -64,8 +64,9 @@ bool WOnscreenSelectionHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA:
return false;
}
if( ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON )
if( ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON || ea.getButton() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON )
{
m_manager->setClickType( ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON );
if( ea.getEventType() == osgGA::GUIEventAdapter::PUSH )
{
m_mousePressed = true;
......
......@@ -24,7 +24,16 @@
#version 120
uniform bool u_clickType;
void main()
{
gl_FragColor= vec4( 0.39, 0.58, 0.93, 1.0 );
if( u_clickType )
{
gl_FragColor = vec4( 0.39, 0.58, 0.93, 0.5 );
}
else
{
gl_FragColor = vec4( 1.00, 0.45, 0.46, 0.5 );
}
}
ADD_MODULE( filterProtonData )
ADD_MODULE( pointConnector )
ADD_MODULE( writeProtonCSV )
ADD_MODULE( lineDrawer )
\ No newline at end of file
......@@ -460,11 +460,23 @@ void WMPointConnector::selectionEnd( WOnscreenSelection::WSelectionType, float,
for( size_t idx = 0; idx < m_connectorData->getVertices()->size(); idx++ )
{
osg::Vec3 vertex = m_connectorData->getVertices()->at( idx );
if( !m_fiberHandler->getFiberOfPoint( vertex ) && m_onscreenSelection->isSelected( vertex.x(), vertex.y(), vertex.z() ) )
if( m_onscreenSelection->isSelected( vertex.x(), vertex.y(), vertex.z() ) )
{
m_connectorData->deselectPoint();
m_connectorData->selectPoint( idx );
m_fiberHandler->addVertexToFiber( vertex, m_fiberHandler->getSelectedFiber() );
if( m_onscreenSelection->getClickType() )
{
if( !m_fiberHandler->getFiberOfPoint( vertex ) )
{
m_connectorData->deselectPoint();
m_connectorData->selectPoint( idx );
m_fiberHandler->addVertexToFiber( vertex, m_fiberHandler->getSelectedFiber() );
}
}
else
{
m_connectorData->deselectPoint();
m_fiberHandler->removeVertexFromFiber( m_connectorData->getVertices()->at( idx ), m_fiberHandler->getSelectedFiber() );
m_fiberHandler->selectLastPoint();
}
}
}
......
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