|
|
|
@ -48,8 +48,8 @@ MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) : |
|
|
|
|
ui->vlMapDialog->setSpacing(widgetMargin); |
|
|
|
|
setMinimumSize(500 * screenRatio, 600 * screenRatio); |
|
|
|
|
setMaximumSize(500 * screenRatio, 600 * screenRatio); |
|
|
|
|
setMouseTracking(true); |
|
|
|
|
|
|
|
|
|
zoomPercent = 100; |
|
|
|
|
changeMode = false; |
|
|
|
|
propUpdate = false; |
|
|
|
|
} |
|
|
|
@ -79,35 +79,12 @@ void MapLocationDialog::setCayoPerico(bool isCayoPerico) |
|
|
|
|
ui->hlMapDialog->removeItem(ui->vlPosLayout); |
|
|
|
|
ui->hlMapDialog->addLayout(ui->vlPosLayout); |
|
|
|
|
ui->labPos->setAlignment(Qt::AlignRight); |
|
|
|
|
mapImage = QImage(":/img/mapcayoperico.jpg"); |
|
|
|
|
} |
|
|
|
|
drawPointOnMap(xpos_old, ypos_old); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapLocationDialog::on_cmdChange_clicked() |
|
|
|
|
{ |
|
|
|
|
qreal screenRatio = AppEnv::screenRatio(); |
|
|
|
|
int pointMakerSize = 8 * screenRatio; |
|
|
|
|
QPixmap pointMakerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMakerSize, pointMakerSize)); |
|
|
|
|
QCursor pointMakerCursor(pointMakerPixmap); |
|
|
|
|
ui->cmdDone->setVisible(true); |
|
|
|
|
ui->cmdApply->setVisible(false); |
|
|
|
|
ui->cmdChange->setVisible(false); |
|
|
|
|
ui->cmdRevert->setVisible(false); |
|
|
|
|
|
|
|
|
|
setCursor(pointMakerCursor); |
|
|
|
|
changeMode = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapLocationDialog::on_cmdDone_clicked() |
|
|
|
|
{ |
|
|
|
|
ui->cmdDone->setVisible(false); |
|
|
|
|
ui->cmdChange->setVisible(true); |
|
|
|
|
if (xpos_new != xpos_old || ypos_new != ypos_old) { |
|
|
|
|
ui->cmdApply->setVisible(true); |
|
|
|
|
ui->cmdRevert->setVisible(true); |
|
|
|
|
else { |
|
|
|
|
mapImage = QImage(":/img/mappreview.jpg"); |
|
|
|
|
} |
|
|
|
|
setCursor(Qt::ArrowCursor); |
|
|
|
|
changeMode = false; |
|
|
|
|
drawPointOnMap(xpos_old, ypos_old); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapLocationDialog::updatePosFromEvent(double x, double y) |
|
|
|
@ -134,19 +111,20 @@ void MapLocationDialog::updatePosFromEvent(double x, double y) |
|
|
|
|
void MapLocationDialog::paintEvent(QPaintEvent *ev) |
|
|
|
|
{ |
|
|
|
|
QPainter painter(this); |
|
|
|
|
painter.setRenderHint(QPainter::SmoothPixmapTransform, true); |
|
|
|
|
|
|
|
|
|
// Screen Ratio
|
|
|
|
|
qreal screenRatio = AppEnv::screenRatio(); |
|
|
|
|
qreal screenRatioPR = AppEnv::screenRatioPR(); |
|
|
|
|
|
|
|
|
|
// Paint Map
|
|
|
|
|
QImage mapImage; |
|
|
|
|
if (p_isCayoPerico) { |
|
|
|
|
mapImage = QImage(":/img/mapcayoperico.jpg"); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
mapImage = QImage(":/img/mappreview.jpg"); |
|
|
|
|
} |
|
|
|
|
painter.setRenderHint(QPainter::SmoothPixmapTransform, true); |
|
|
|
|
painter.drawImage(QRect(QPoint(0, 0), size()), mapImage); |
|
|
|
|
const double zoomLevel = static_cast<double>(zoomPercent) / 100; |
|
|
|
|
const QSize mapImageSize = mapImage.size(); |
|
|
|
|
const QPointF mapImageMid(static_cast<double>(mapImageSize.width()) / 2, static_cast<double>(mapImageSize.height()) / 2); |
|
|
|
|
const QSizeF srcImageSize(static_cast<double>(mapImageSize.width()) / zoomLevel , static_cast<double>(mapImageSize.height()) / zoomLevel); |
|
|
|
|
const QPointF mapImageTopLeft(mapImageMid.x() - (srcImageSize.width() / 2), mapImageMid.y() - (srcImageSize.height() / 2)); |
|
|
|
|
const QPointF mapImageBottomRight(mapImageMid.x() + (srcImageSize.width() / 2), mapImageMid.y() + (srcImageSize.height() / 2)); |
|
|
|
|
painter.drawImage(QRect(QPoint(0, 0), size()), mapImage, QRectF(mapImageTopLeft, mapImageBottomRight)); |
|
|
|
|
|
|
|
|
|
// Paint Marker
|
|
|
|
|
QSize mapPixelSize = size(); |
|
|
|
@ -169,27 +147,24 @@ void MapLocationDialog::paintEvent(QPaintEvent *ev) |
|
|
|
|
xpos_mp = xpos_per * mapPixelSize.width(); // locate window width pos
|
|
|
|
|
ypos_mp = ypos_per * mapPixelSize.height(); // locate window height pos
|
|
|
|
|
} |
|
|
|
|
long xpos_pr, ypos_pr; |
|
|
|
|
QPointF pointMarkerPos(xpos_mp, ypos_mp); |
|
|
|
|
if (screenRatioPR != 1) { |
|
|
|
|
xpos_pr = xpos_mp - pointMarkerHalfSize + screenRatioPR; |
|
|
|
|
ypos_pr = ypos_mp - pointMarkerHalfSize + screenRatioPR; |
|
|
|
|
pointMarkerPos.setX(pointMarkerPos.x() - pointMarkerHalfSize + screenRatioPR); |
|
|
|
|
pointMarkerPos.setY(pointMarkerPos.y() - pointMarkerHalfSize + screenRatioPR); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
xpos_pr = xpos_mp - pointMarkerHalfSize; |
|
|
|
|
ypos_pr = ypos_mp - pointMarkerHalfSize; |
|
|
|
|
pointMarkerPos.setX(pointMarkerPos.x() - pointMarkerHalfSize); |
|
|
|
|
pointMarkerPos.setY(pointMarkerPos.y() - pointMarkerHalfSize); |
|
|
|
|
} |
|
|
|
|
QPixmap mapMarkerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMarkerSize, pointMarkerSize)); |
|
|
|
|
painter.drawPixmap(xpos_pr, ypos_pr, pointMarkerSize, pointMarkerSize, mapMarkerPixmap); |
|
|
|
|
painter.drawPixmap(pointMarkerPos, mapMarkerPixmap); |
|
|
|
|
|
|
|
|
|
QDialog::paintEvent(ev); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev) |
|
|
|
|
{ |
|
|
|
|
if (!changeMode) { |
|
|
|
|
ev->ignore(); |
|
|
|
|
} |
|
|
|
|
else if (ev->buttons() & Qt::LeftButton) { |
|
|
|
|
if (changeMode && ev->buttons() & Qt::LeftButton) { |
|
|
|
|
#if QT_VERSION >= 0x060000 |
|
|
|
|
const QPointF localPos = ev->position(); |
|
|
|
|
#elif QT_VERSION >= 0x050000 |
|
|
|
@ -208,19 +183,37 @@ void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev) |
|
|
|
|
#else |
|
|
|
|
updatePosFromEvent(localPos.x(), localPos.y()); |
|
|
|
|
#endif |
|
|
|
|
ev->accept(); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
ev->ignore(); |
|
|
|
|
else if (dragStart && ev->buttons() & Qt::LeftButton) { |
|
|
|
|
#if QT_VERSION >= 0x060000 |
|
|
|
|
const QPointF dragNewPosition = ev->position(); |
|
|
|
|
#elif QT_VERSION >= 0x050000 |
|
|
|
|
const QPointF dragNewPosition = ev->localPos(); |
|
|
|
|
#else |
|
|
|
|
const QPointF dragNewPosition = ev->posF(); |
|
|
|
|
#endif |
|
|
|
|
mapDiffPosition = dragNewPosition - dragPosition + mapDiffPosition; |
|
|
|
|
dragPosition = dragNewPosition; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev) |
|
|
|
|
void MapLocationDialog::mousePressEvent(QMouseEvent *ev) |
|
|
|
|
{ |
|
|
|
|
if (!changeMode) { |
|
|
|
|
ev->ignore(); |
|
|
|
|
if (!changeMode && ev->button() == Qt::LeftButton) { |
|
|
|
|
#if QT_VERSION >= 0x060000 |
|
|
|
|
dragPosition = ev->position(); |
|
|
|
|
#elif QT_VERSION >= 0x050000 |
|
|
|
|
dragPosition = ev->localPos(); |
|
|
|
|
#else |
|
|
|
|
dragPosition = ev->posF(); |
|
|
|
|
#endif |
|
|
|
|
dragStart = true; |
|
|
|
|
} |
|
|
|
|
else if (ev->button() == Qt::LeftButton) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev) |
|
|
|
|
{ |
|
|
|
|
if (changeMode && ev->button() == Qt::LeftButton) { |
|
|
|
|
#if QT_VERSION >= 0x060000 |
|
|
|
|
const QPointF localPos = ev->position(); |
|
|
|
|
#elif QT_VERSION >= 0x050000 |
|
|
|
@ -239,11 +232,63 @@ void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev) |
|
|
|
|
#else |
|
|
|
|
updatePosFromEvent(localPos.x(), localPos.y()); |
|
|
|
|
#endif |
|
|
|
|
ev->accept(); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
ev->ignore(); |
|
|
|
|
else if (dragStart && ev->button() == Qt::LeftButton) { |
|
|
|
|
dragStart = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapLocationDialog::wheelEvent(QWheelEvent *ev) |
|
|
|
|
{ |
|
|
|
|
const QPoint numPixels = ev->pixelDelta(); |
|
|
|
|
const QPoint numDegrees = ev->angleDelta(); |
|
|
|
|
if (!numPixels.isNull()) { |
|
|
|
|
if (numPixels.y() < 0 && zoomPercent != 100) { |
|
|
|
|
zoomPercent = zoomPercent - 10; |
|
|
|
|
repaint(); |
|
|
|
|
} |
|
|
|
|
else if (numPixels.y() > 0 && zoomPercent != 400) { |
|
|
|
|
zoomPercent = zoomPercent + 10; |
|
|
|
|
repaint(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (!numDegrees.isNull()) { |
|
|
|
|
if (numDegrees.y() < 0 && zoomPercent != 100) { |
|
|
|
|
zoomPercent = zoomPercent - 10; |
|
|
|
|
repaint(); |
|
|
|
|
} |
|
|
|
|
else if (numDegrees.y() > 0 && zoomPercent != 400) { |
|
|
|
|
zoomPercent = zoomPercent + 10; |
|
|
|
|
repaint(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapLocationDialog::on_cmdChange_clicked() |
|
|
|
|
{ |
|
|
|
|
qreal screenRatio = AppEnv::screenRatio(); |
|
|
|
|
int pointMakerSize = 8 * screenRatio; |
|
|
|
|
QPixmap pointMakerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMakerSize, pointMakerSize)); |
|
|
|
|
QCursor pointMakerCursor(pointMakerPixmap); |
|
|
|
|
ui->cmdDone->setVisible(true); |
|
|
|
|
ui->cmdApply->setVisible(false); |
|
|
|
|
ui->cmdChange->setVisible(false); |
|
|
|
|
ui->cmdRevert->setVisible(false); |
|
|
|
|
|
|
|
|
|
setCursor(pointMakerCursor); |
|
|
|
|
changeMode = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapLocationDialog::on_cmdDone_clicked() |
|
|
|
|
{ |
|
|
|
|
ui->cmdDone->setVisible(false); |
|
|
|
|
ui->cmdChange->setVisible(true); |
|
|
|
|
if (xpos_new != xpos_old || ypos_new != ypos_old) { |
|
|
|
|
ui->cmdApply->setVisible(true); |
|
|
|
|
ui->cmdRevert->setVisible(true); |
|
|
|
|
} |
|
|
|
|
setCursor(Qt::ArrowCursor); |
|
|
|
|
changeMode = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapLocationDialog::on_cmdApply_clicked() |
|
|
|
|