OpenWalnut  1.5.0dev
WMouseLocationHandler.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2017 OpenWalnut Community, Hochschule Worms
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <string>
26 
27 #include "WMouseLocationHandler.h"
28 #include "../common/WAssert.h"
29 
30 
32  : m_mouseLocation( WMouseLocationInfo() ),
33  m_viewerName( "" )
34 {
35 }
36 
38  : m_mouseLocation( WMouseLocationInfo() ),
39  m_viewerName( viewerName )
40 {
41 }
42 
44 {
45 }
46 
48 {
49  return &m_locationSignal;
50 }
51 
52 bool WMouseLocationHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& /* aa */ )
53 {
54  float x = ea.getX();
55  float y = ea.getY();
56 
57  WMouseLocationInfo locationInfo;
58 
59  locationInfo = WMouseLocationInfo( m_viewerName, std::make_pair( x, y ) );
60  m_mouseLocation = locationInfo;
62  return false;
63 }
64 
66 {
67  return m_mouseLocation;
68 }
This class holds the information about the mouse pointer location in a certain viewe.
WMouseLocationHandler()
Constructor that initalizes members with sensible defaults.
boost::signals2::signal< void(WMouseLocationInfo) > m_locationSignal
One can register to this signal to receive location events.
WMouseLocationInfo m_mouseLocation
Representation of mouse location.
std::string m_viewerName
which viewer sends the signal
WMouseLocationInfo getLocationInfo()
Gives information about the mouse location.
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
Deals with the events found by the osg.
boost::signals2::signal< void(WMouseLocationInfo) > * getLocationSignal()
virtual ~WMouseLocationHandler()
Virtual destructor needed because of virtual function.