111 lines
1.6 KiB
C++
111 lines
1.6 KiB
C++
#include "stdafx.h"
|
|
#include "MapTool.h"
|
|
#include "ImageViewer.h"
|
|
#include <QAction>
|
|
|
|
MapTool::MapTool(QObject* parent)
|
|
: QObject(parent)
|
|
, m_cursor(Qt::ArrowCursor)
|
|
{
|
|
}
|
|
|
|
MapTool::~MapTool()
|
|
{
|
|
if (m_canvas && m_canvas->mapTool() == this)
|
|
{
|
|
m_canvas->unsetMapTool(this);
|
|
}
|
|
}
|
|
|
|
QAction* MapTool::action() const
|
|
{
|
|
return m_action;
|
|
}
|
|
|
|
void MapTool::setAction(QAction* action)
|
|
{
|
|
m_action = action;
|
|
}
|
|
|
|
void MapTool::setMapcavas(Mapcavas* canvas)
|
|
{
|
|
if (m_canvas == canvas)
|
|
return;
|
|
|
|
if (m_isActive && m_canvas)
|
|
{
|
|
//deactivate();
|
|
}
|
|
|
|
m_canvas = canvas;
|
|
}
|
|
|
|
Mapcavas* MapTool::canvas() const
|
|
{
|
|
return m_canvas;
|
|
}
|
|
|
|
void MapTool::setCursor(const QCursor& cursor)
|
|
{
|
|
m_cursor = cursor;
|
|
}
|
|
|
|
QCursor MapTool::cursor() const
|
|
{
|
|
return m_cursor;
|
|
}
|
|
|
|
void MapTool::activate()
|
|
{
|
|
if (m_canvas)
|
|
{
|
|
m_canvas->viewport()->setCursor(m_cursor);
|
|
}
|
|
if (m_action)
|
|
{
|
|
m_action->setChecked(true);
|
|
}
|
|
m_isActive = true;
|
|
emit activated();
|
|
}
|
|
|
|
void MapTool::deactivate()
|
|
{
|
|
if (m_action)
|
|
{
|
|
m_action->setChecked(false);
|
|
}
|
|
m_isActive = false;
|
|
emit deactivated();
|
|
}
|
|
|
|
bool MapTool::isActive() const
|
|
{
|
|
return m_isActive;
|
|
}
|
|
|
|
void MapTool::canvasMousePressEvent(QMouseEvent* e)
|
|
{
|
|
Q_UNUSED(e);
|
|
}
|
|
|
|
void MapTool::canvasMouseReleaseEvent(QMouseEvent* e)
|
|
{
|
|
Q_UNUSED(e);
|
|
}
|
|
|
|
void MapTool::canvasMouseMoveEvent(QMouseEvent* e)
|
|
{
|
|
Q_UNUSED(e);
|
|
}
|
|
|
|
void MapTool::canvasMouseDoubleClickEvent(QMouseEvent* e)
|
|
{
|
|
Q_UNUSED(e);
|
|
}
|
|
|
|
void MapTool::canvasWheelEvent(QWheelEvent* e)
|
|
{
|
|
Q_UNUSED(e);
|
|
}
|