Files
qt5-legatus-legacy/Lts/Viewer/SituationMap/Tests/EsriMapTouchTest/event_mouse_navigator.h
T
2026-08-13 18:33:10 +02:00

155 lines
6.0 KiB
Objective-C
Executable File

/**
**
** @RDE_HEADER@
** Event Dispatcher for Qt5 to handle mouse events navigate on map
** $Id$
** $HeadURL$
** $Author$
**
** -----------------------------------------------------------------------------------------------
**
** Hardware-Environment: Intel-PC
** Software-Environment: Windows 7, Qt 5.4. ArcGIS 10.2.5
**
** Language ........: C++ 11
**
** -----------------------------------------------------------------------------------------------
**
** Author ...........: Jörg Turla, SPD G, Tel. 3132
**
** -----------------------------------------------------------------------------------------------
**
** Notes .........:
**
** 24.04.2015, JT : first edition
**
** -----------------------------------------------------------------------------------------------
*/
#pragma once
#include <QtCore/QList>
#include "abstract_event_dispatcher.h"
namespace EsriRuntimeQt
{
class Map;
} /* namespace EsriRuntimeQt */
namespace SituationMap { namespace RB
{
/**
@class EventMouseNavigator event_mouse_navigator.h
@brief Event filter that handles mouse events for general map operation like selecting object, zooming and paning the map window
Implements class \c AbstractEventDispatcher to manage event handling for general map operation like selecting object, zooming and
panning the map window. Monitoring the mouse position can be realized by connecting the \c mouseMovedEvent signal. If the user has
clicked to map objects the signal \c selectionRequest is emitted.
Following events are handled:
| Input-Event | Interface Function | Description |
| :--------------------------------------------- | : ----------------- | : --------------------------------------------------------------------------- |
| Mouse move without any modifier | | Move Cursor. |
| Mouse move with pressed left button | | Panning of map if more then 3 pixels moved. |
| Mouse move with pressed middle button | | Panning of map. |
| Mouse wheel | | Redirect to \c Esri map for zooming. |
| Left mouse button release | | Emits signal \c selectionRequest with list of map objects at cursor position. |
@see AbstractEventDispatcher, EventDelegater, EventDispatcher
*/
class EventMouseNavigator : public AbstractEventDispatcher
{
Q_OBJECT
public:
/**
@name Construction & Destruction
@{
*/
EventMouseNavigator(const EventMouseNavigator &) = delete;
EventMouseNavigator & operator = (const EventMouseNavigator &) = delete;
EventMouseNavigator( QWidget * getEventsFrom, EsriRuntimeQt::Map * esriMap );
virtual ~EventMouseNavigator() {}
/** @} */
inline static void setPickTolerance( int value = 20 ) { _pickTolerance = value; }
signals:
/**
Will be emitted if the user clicks to map objects with the left mouse button.
*/
void selectionRequest( const QList< uint > & idList, QPoint viewPortPos );
/**
Will be emitted if the user clicks to the map with the rigth mouse button.
*/
void contextMenuRequest( const QList< uint > & idList, QPoint viewPortPos );
/**
Signal will be emitted if a mouse move is done.
*/
void mouseMovedEvent( int x, int y );
protected:
virtual bool eventFilter(QObject*, QEvent*);
enum SelectionMode
{
NoSelection = 0x00,
SingleSelection = 0x01,
MultiSelection = 0x02,
FrameSelection = 0x04
}; // SelectionMode
Q_DECLARE_FLAGS(SelectionModes,SelectionMode)
EsriRuntimeQt::Map * _esriMap;
QPoint _mouseMoveRefPos;
QCursor _restoreMouseCursor;
static int _pickTolerance;
SelectionModes _selectionMode;
QList<uint> _selectedIdList; // List of selected object-ids. Is completly handled in selectionRequested()
unsigned int _idConnectionCount; // counter to avoid multiple signals selectionRequest, see implementation of selectionRequested()
bool _mousePanningActive; // is panning with mouse active
/**
Find out which map objects are at given mouse position and emits the signal selectionRequest
*/
void selectionRequested( const QPoint & );
/**
Find out which map objects are at given mouse position and emits the signal contextMenuRequest
*/
void pickRequested( const QPoint & );
/**
Helper function to get all map objets at a given position
@param pos position in window coordinates
@param pickIdList List to store uid's of picked map objects. Don't use a local variable here because the picking is a asynchrone function
@param append If true the uid's are appended at end of list. Otherwise the list will be cleared first.
@param pickSignal Function pointer to signal to be emitted at end.
*/
void pickObjects( const QPoint & pos
, QList<uint> & pickIdList
, bool append
, void (EventMouseNavigator::*pickSignal)(const QList< uint>&,QPoint) );
}; /* EventMouseNavigator */
} } /* namespace SituationMap::RB */