Commit 3de3ed5c authored by Stefan Philips's avatar Stefan Philips

[FIX] cluster display works again (we don't use pickhandler anymore)

parent 33520c34
......@@ -28,6 +28,8 @@
#include <boost/regex.hpp>
#include <osgGA/GUIEventAdapter>
#include <osgGA/GUIEventHandler>
#include <osgGA/StateSetManipulator>
#include <osgGA/TrackballManipulator>
#include <osgViewer/ViewerEventHandlers>
......@@ -41,6 +43,7 @@
#include "core/graphicsEngine/WGEUtils.h"
#include "core/kernel/WKernel.h"
#include "core/kernel/WROIManager.h"
#include "core/ui/WUIViewWidget.h"
#include "WMClusterDisplay.h"
#include "WMClusterDisplay.xpm"
......@@ -48,6 +51,22 @@
// This line is needed by the module loader to actually find your module. Do not remove. Do NOT add a ";" here.
W_LOADABLE_MODULE( WMClusterDisplay )
bool WMClusterDisplay::MainViewEventHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& /* aa */ )
{
// wlog::debug( "WMClusterDisplay::MainViewEventHandler" ) << "handle";
if( ea.getEventType() == GUIEvents::PUSH && ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON )
{
return m_signalLeftButtonPush( WVector2f( ea.getX(), ea.getY() ) );
}
return false;
}
void WMClusterDisplay::MainViewEventHandler::subscribeLeftButtonPush( LeftButtonPushSignalType::slot_type slot )
{
m_signalLeftButtonPush.connect( slot );
}
WMClusterDisplay::WMClusterDisplay():
WModule(),
m_widgetDirty( false ),
......@@ -368,8 +387,10 @@ void WMClusterDisplay::properties()
void WMClusterDisplay::moduleMain()
{
boost::signals2::connection con = WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getPickHandler()->getPickSignal()->
connect( boost::bind( &WMClusterDisplay::dendrogramClick, this, _1 ) );
osg::ref_ptr< MainViewEventHandler > eh( new MainViewEventHandler );
eh->subscribeLeftButtonPush( boost::bind( &WMClusterDisplay::dendrogramClick, this, _1 ) );
WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getView()->addEventHandler( eh );
m_moduleState.setResetable( true, true );
m_moduleState.add( m_propCondition );
......@@ -506,7 +527,6 @@ void WMClusterDisplay::moduleMain()
//WKernel::getRunningKernel()->getRoiManager()->setUseExternalBitfield( m_active->get( true ) );
}
}
con.disconnect();
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
}
......@@ -966,19 +986,18 @@ void WMClusterDisplay::setColor( std::vector<size_t> clusters, WColor color )
}
}
void WMClusterDisplay::dendrogramClick( WPickInfo pickInfo )
bool WMClusterDisplay::dendrogramClick( const WVector2f& pos )
{
if( !m_propShowDendrogram->get() || !( pickInfo.getName() == "nothing" ) )
if( m_dendrogramGeode->inDendrogramArea( pos ) )
{
return;
int x = pos[0];
int y = pos[1];
m_propSelectedCluster->set( m_dendrogramGeode->getClickedCluster( x, y ) );
return true;
}
int x = pickInfo.getPickPixel().x();
int y = pickInfo.getPickPixel().y();
m_propSelectedCluster->set( m_dendrogramGeode->getClickedCluster( x, y ) );
return false;
}
void WMClusterDisplay::createFiberGeode()
{
m_fiberDrawable = osg::ref_ptr< WFiberDrawable >( new WFiberDrawable );
......
......@@ -29,14 +29,14 @@
#include <vector>
#include <osg/Geode>
#include <osgGA/GUIEventAdapter>
#include <osgGA/GUIEventHandler>
#include "core/common/WHierarchicalTreeFibers.h"
#include "core/graphicsEngine/geodes/WDendrogramGeode.h"
#include "core/graphicsEngine/WFiberDrawable.h"
#include "core/graphicsEngine/WGEManagedGroupNode.h"
#include "core/graphicsEngine/widgets/WOSGButton.h"
#include "core/graphicsEngine/WPickHandler.h"
#include "core/graphicsEngine/WPickInfo.h"
#include "core/graphicsEngine/WGECamera.h"
#include "core/kernel/WFiberSelector.h"
#include "core/kernel/WModule.h"
......@@ -108,6 +108,37 @@ protected:
private:
/**
* Small event handler class to catch left mouse buttons clicks in the main view.
*/
class MainViewEventHandler : public osgGA::GUIEventHandler
{
public:
typedef boost::signals2::signal< bool ( WVector2f ) > LeftButtonPushSignalType;
/**
* The OSG calls this function whenever a new event has occured.
*
* \param ea Event class for storing GUI events such as mouse or keyboard interation etc.
*
* \return true if the event was handled.
*/
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& /* aa */ );
/**
* Registers a function slot to LEFT BUTTON PUSH events. Whenever the event occurs, the slot is called with current parameters.
*
* \param slot Function object having the appropriate signature according to the used SignalType.
*/
void subscribeLeftButtonPush( LeftButtonPushSignalType::slot_type slot );
private:
/**
* Signal used for notification of the LEFT BUTTON PUSH event.
*/
LeftButtonPushSignalType m_signalLeftButtonPush;
};
/**
* helper function to read a text file
* \param fileName
......@@ -202,10 +233,11 @@ private:
std::string createLabel( size_t id );
/**
* listenes to the pickhandler and determines if a click into the dendrogram happened
* \param pickInfo the pickInfo object as sent out by the pickhandler
* handles clicks into the dendrogram
* \param pos the mouse position during the click
* \return true if it handled the click
*/
void dendrogramClick( WPickInfo pickInfo );
bool dendrogramClick( const WVector2f& pos );
/**
* helper function to initialize a fiber display node
......
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