//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see .
//
//---------------------------------------------------------------------------
#ifndef WPICKHANDLER_H
#define WPICKHANDLER_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../math/WPosition.h"
/**
* class to handle events with a pick
*/
class WPickHandler: public osgGA::GUIEventHandler
{
public:
/**
* Deals with the events found by the osg.
*/
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa );
/**
* Send a pick signal with the pick information as string
*/
virtual void pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea );
/**
* Send a pick signal with the string "unpick"
*/
virtual void unpick();
/**
* Gives information about the picked object.
*/
std::string getHitResult();
/**
* Returns the position where the first object was picked.
*/
wmath::WPosition getHitPosition();
/**
* returns the m_pickSignal to for registering to it.
*/
boost::signals2::signal1< void, std::string >* getPickSignal();
protected:
/**
* Virtual destructor needed because of virtual function.
*
* This desctructor is protected to avoid accidentally deleting
* a instance of WPickHandler.
* This follows the philosophy of OSG to avoid problems in multithreaded
* environments, since these pointers are used deep in the OSG where
* an deletion could cause a segfault.
*/
virtual ~WPickHandler();
std::string m_hitResult; //!< Textual representation of the result of a pick.
wmath::WPosition m_hitPosGlobal; //!< Global coordinates of the first hit of the pick.
private:
boost::signals2::signal1 m_pickSignal; //!< One can register to this signal to receive pick events.
};
#endif // WPICKHANDLER_H