From 92b9acd6e81109df40175d870315fee44457f98b Mon Sep 17 00:00:00 2001 From: jb Date: Fri, 27 Apr 2012 15:55:06 +0100 Subject: [PATCH] GCS - Added support for map ripping --- .../src/mapwidget/mapgraphicitem.cpp | 8 +-- .../opmapcontrol/src/mapwidget/mapripper.cpp | 63 ++++++++++++------- .../opmapcontrol/src/mapwidget/mapripper.h | 1 + .../src/plugins/opmap/opmapgadgetwidget.cpp | 13 ++++ .../src/plugins/opmap/opmapgadgetwidget.h | 2 + 5 files changed, 60 insertions(+), 27 deletions(-) diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp index 7c7984aa0..1df30d653 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp @@ -196,7 +196,7 @@ namespace mapcontrol } } - else if(isSelected && !selectionStart.IsEmpty() && (event->modifiers() == Qt::AltModifier || event->modifiers() == Qt::ShiftModifier)) + else if(isSelected && !selectionStart.IsEmpty() && (event->modifiers() == Qt::ControlModifier || event->modifiers() == Qt::ShiftModifier)) { selectionEnd = FromLocalToLatLng(event->pos().x(), event->pos().y()); { @@ -217,10 +217,10 @@ namespace mapcontrol { - + qDebug()<modifiers(); if(!IsMouseOverMarker()) { - if(event->button() == config->DragButton && CanDragMap()&& !((event->modifiers()==Qt::AltModifier)||(event->modifiers()==Qt::ShiftModifier))) + if(event->button() == config->DragButton && CanDragMap()&& !((event->modifiers()==Qt::ShiftModifier)||(event->modifiers()==Qt::ControlModifier))) { core->mouseDown.SetX(event->pos().x()); core->mouseDown.SetY(event->pos().y()); @@ -232,7 +232,7 @@ namespace mapcontrol this->update(); } - else if(!isSelected && ((event->modifiers()==Qt::AltModifier)||(event->modifiers()==Qt::ShiftModifier))) + else if(!isSelected && ((event->modifiers()==Qt::ControlModifier)||(event->modifiers()==Qt::ShiftModifier))) { isSelected = true; SetSelectedArea (internals::RectLatLng::Empty); diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.cpp index 00a2053cd..41518b81f 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.cpp @@ -28,7 +28,7 @@ namespace mapcontrol { - MapRipper::MapRipper(internals::Core * core, const internals::RectLatLng & rect):sleep(100),cancel(false),progressForm(0),core(core) +MapRipper::MapRipper(internals::Core * core, const internals::RectLatLng & rect):sleep(100),cancel(false),progressForm(0),core(core),yesToAll(false) { if(!rect.IsEmpty()) { @@ -46,32 +46,49 @@ namespace mapcontrol connect(this,SIGNAL(finished()),this,SLOT(finish())); emit numberOfTilesChanged(0,0); } + else + QMessageBox::information(new QWidget(),"No valid selection","Please select the area of the map to rip with Mouse+Control key"); } - void MapRipper::finish() +void MapRipper::finish() +{ + if(zoomProjection()->GetAreaTileList(area,zoom,0); - this->start(); - } - else - { - progressForm->close(); - delete progressForm; - this->deleteLater(); - } - } + QMessageBox msgBox; + msgBox.setText(QString("Continue Ripping at zoom level %1?").arg(zoom)); + // msgBox.setInformativeText("Do you want to save your changes?"); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::YesAll); + msgBox.setDefaultButton(QMessageBox::Yes); + ret = msgBox.exec(); + } + else + ret=QMessageBox::Yes; + if(ret==QMessageBox::Yes) + { + points.clear(); + points=core->Projection()->GetAreaTileList(area,zoom,0); + this->start(); + } + else if(ret==QMessageBox::YesAll) + { + yesToAll=true; + points.clear(); + points=core->Projection()->GetAreaTileList(area,zoom,0); + this->start(); + } + else + { + progressForm->close(); + delete progressForm; + this->deleteLater(); + } } + else + yesToAll=false; +} void MapRipper::run() diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.h index 6b2087a12..313156863 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapripper.h @@ -50,6 +50,7 @@ namespace mapcontrol MapRipForm * progressForm; int maxzoom; internals::Core * core; + bool yesToAll; signals: void percentageChanged(int const& perc); diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp index abc51de20..2bae793a5 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp @@ -428,6 +428,10 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event) menu.addAction(reloadAct); + menu.addSeparator(); + + menu.addAction(ripAct); + menu.addSeparator(); QMenu maxUpdateRateSubMenu(tr("&Max Update Rate ") + "(" + QString::number(m_maxUpdateRate) + " ms)", this); @@ -1410,6 +1414,10 @@ void OPMapGadgetWidget::createActions() reloadAct->setStatusTip(tr("Reload the map tiles")); connect(reloadAct, SIGNAL(triggered()), this, SLOT(onReloadAct_triggered())); + ripAct = new QAction(tr("&Rip map"), this); + ripAct->setStatusTip(tr("Rip the map tiles")); + connect(ripAct, SIGNAL(triggered()), this, SLOT(onRipAct_triggered())); + copyMouseLatLonToClipAct = new QAction(tr("Mouse latitude and longitude"), this); copyMouseLatLonToClipAct->setStatusTip(tr("Copy the mouse latitude and longitude to the clipboard")); connect(copyMouseLatLonToClipAct, SIGNAL(triggered()), this, SLOT(onCopyMouseLatLonToClipAct_triggered())); @@ -1682,6 +1690,11 @@ void OPMapGadgetWidget::onReloadAct_triggered() m_map->ReloadMap(); } +void OPMapGadgetWidget::onRipAct_triggered() +{ + m_map->RipMap(); +} + void OPMapGadgetWidget::onCopyMouseLatLonToClipAct_triggered() { QClipboard *clipboard = QApplication::clipboard(); diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.h b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.h index 24f638a80..8d374acdc 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.h @@ -187,6 +187,7 @@ private slots: * @brief mouse right click context menu signals */ void onReloadAct_triggered(); + void onRipAct_triggered(); void onCopyMouseLatLonToClipAct_triggered(); void onCopyMouseLatToClipAct_triggered(); void onCopyMouseLonToClipAct_triggered(); @@ -282,6 +283,7 @@ private: QAction *closeAct1; QAction *closeAct2; QAction *reloadAct; + QAction *ripAct; QAction *copyMouseLatLonToClipAct; QAction *copyMouseLatToClipAct; QAction *copyMouseLonToClipAct;