45 lines
814 B
C++
45 lines
814 B
C++
|
#include <QtCore/QEvent>
|
|||
|
|
|||
|
#include <maptoolpan.h>
|
|||
|
#include <mapcanvas.h>
|
|||
|
#pragma execution_character_set("utf-8")
|
|||
|
|
|||
|
namespace LAMPMainWidget {
|
|||
|
|
|||
|
void
|
|||
|
MapToolPan::execute(QMouseEvent *event) {
|
|||
|
if(!(event->button() & Qt::LeftButton)){
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
auto type = event->type();
|
|||
|
if (QEvent::MouseButtonPress == type) {
|
|||
|
mDragStartPos = event->pos();
|
|||
|
}
|
|||
|
|
|||
|
if (QEvent::MouseButtonRelease == type) {
|
|||
|
mDragEndPos = event->pos();
|
|||
|
QRectF dragRect{mDragStartPos, mDragEndPos};
|
|||
|
mMapCanvas->mDragRect = dragRect;
|
|||
|
mMapCanvas->updateViewExtent();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void
|
|||
|
MapToolPan::setup() {
|
|||
|
mMapCanvas->setDragMode(MapCanvas::DragMode::ScrollHandDrag);
|
|||
|
}
|
|||
|
|
|||
|
QString
|
|||
|
MapToolPan::id() {
|
|||
|
return QString{"pan_tool"};
|
|||
|
}
|
|||
|
|
|||
|
void
|
|||
|
MapToolPan::deSetup() {
|
|||
|
mMapCanvas->setDragMode(MapCanvas::DragMode::NoDrag);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|