Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+225
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
**
|
||||
** @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
|
||||
|
||||
// Own
|
||||
#include <Map/situation_map_types.h>
|
||||
#include "abstract_event_dispatcher.h"
|
||||
|
||||
|
||||
//Esri
|
||||
#include <arcgis/TaskWatcher.h>
|
||||
|
||||
|
||||
// Qt
|
||||
#include <QtCore/QList>
|
||||
|
||||
|
||||
// #define SITUATIONMAP_OWN_WHEEL_HANDLING
|
||||
|
||||
|
||||
|
||||
// Forward:
|
||||
namespace Esri {
|
||||
namespace ArcGISRuntime {
|
||||
class Map;
|
||||
class IdentifyGraphicsOverlayResult;
|
||||
} }
|
||||
|
||||
namespace SituationMap {
|
||||
class MapImpl;
|
||||
}
|
||||
|
||||
|
||||
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 enter | | To show/hide some widgets |
|
||||
| Mouse leave | | To show/hide some widgets |
|
||||
| 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, SituationMap::MapImpl *sitMap );
|
||||
|
||||
virtual ~EventMouseNavigator() = default;
|
||||
/** @} */
|
||||
|
||||
inline static void setPickTolerance( int value = 5 ) { _pickTolerance = value; }
|
||||
|
||||
inline static int pickTolerance() { return _pickTolerance; }
|
||||
|
||||
inline static void setZoomFactorBase(qreal value = 1.002) { if ((value > 1) && (value <= 1.1))_zoomFactorBase = value; }
|
||||
|
||||
inline static qreal zoomFactorBase() { return _zoomFactorBase; }
|
||||
|
||||
signals:
|
||||
/**
|
||||
Will be emitted if the mouse enters the widget.
|
||||
*/
|
||||
void enterEvent();
|
||||
|
||||
/**
|
||||
Will be emitted if the mouse leaves the widget.
|
||||
*/
|
||||
void leaveEvent();
|
||||
|
||||
|
||||
/**
|
||||
Will be emitted if the user clicks to map objects with the left mouse button.
|
||||
*/
|
||||
void selectionRequest( const QList< SituationMap::UniqueMapId > & idList, const QPointF &viewPortPos );
|
||||
|
||||
/**
|
||||
Will be emitted if the user clicks to the map with the rigth mouse button.
|
||||
*/
|
||||
void contextMenuRequest( const QList< SituationMap::UniqueMapId > & idList, const QPointF &viewPortPos );
|
||||
|
||||
/**
|
||||
Signal will be emitted if a mouse move is done.
|
||||
*/
|
||||
void mouseMovedEvent( int x, int y );
|
||||
|
||||
#ifdef SITUATIONMAP_OWN_WHEEL_HANDLING
|
||||
/**
|
||||
Signal will be emitted if the mouse wheel has been rotated
|
||||
*/
|
||||
void mouseWheelEvent(qreal factor, const QPointF &cursorPositionMap);
|
||||
#endif
|
||||
|
||||
protected slots:
|
||||
|
||||
void onGetPickingResult(const QUuid &taskId, const QList<Esri::ArcGISRuntime::IdentifyGraphicsOverlayResult *> &identifyResults );
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
QList<UniqueMapId> mapToUniqueMapId( const QList<Esri::ArcGISRuntime::IdentifyGraphicsOverlayResult*> & identifyResults);
|
||||
|
||||
bool eventFilter(QObject*, QEvent*) override;
|
||||
|
||||
|
||||
enum class RequestType
|
||||
{
|
||||
None,
|
||||
Selection,
|
||||
Picking
|
||||
}; // RequestType
|
||||
|
||||
|
||||
enum SelectionMode
|
||||
{
|
||||
NoSelection = 0x00,
|
||||
SingleSelection = 0x01,
|
||||
MultiSelection = 0x02,
|
||||
FrameSelection = 0x04
|
||||
}; // SelectionMode
|
||||
|
||||
Q_DECLARE_FLAGS(SelectionModes,SelectionMode)
|
||||
|
||||
SituationMap::MapImpl *_sitMap;
|
||||
|
||||
QPoint _mouseMoveRefPos;
|
||||
QCursor _restoreMouseCursor;
|
||||
bool _cursorChanged;
|
||||
|
||||
static int _pickTolerance;
|
||||
|
||||
QPointF _viewPortPos;
|
||||
SelectionModes _selectionMode;
|
||||
RequestType _pendingRequest;
|
||||
bool _mousePanningActive;
|
||||
bool _mousePanningActiveForCenterMapMidButton;
|
||||
|
||||
#ifdef SITUATIONMAP_OWN_WHEEL_HANDLING
|
||||
Esri::ArcGISRuntime::TaskWatcher _mouseZoomTaskWatcher;
|
||||
#endif
|
||||
|
||||
Qt::MouseButton _pressedMouseButton;
|
||||
|
||||
static qreal _zoomFactorBase; // Base value to calculate zoom factor values from QWheelEvent
|
||||
|
||||
Esri::ArcGISRuntime::TaskWatcher _pickingTask;
|
||||
|
||||
/**
|
||||
test for already running picking task.
|
||||
*/
|
||||
bool checkRunningPickingTask();
|
||||
|
||||
/**
|
||||
Find out which map objects are at given mouse position and emits the signal selectionRequest
|
||||
*/
|
||||
void selectionRequested(const QPointF & );
|
||||
|
||||
/**
|
||||
Find out which map objects are at given mouse position and emits the signal contextMenuRequest
|
||||
*/
|
||||
void pickRequested( const QPointF & );
|
||||
|
||||
/**
|
||||
Helper function to get all map objects at a given position of all GraphicsOverlays
|
||||
@param pos position in window coordinates
|
||||
*/
|
||||
void requestPicking(const QPointF &pos);
|
||||
|
||||
}; /* EventMouseNavigator */
|
||||
|
||||
|
||||
} } /* namespace SituationMap::RB */
|
||||
Reference in new issue
Block a user