From 1d01f827ae05bd0c6e2d8c353e748b0ebba8fd48 Mon Sep 17 00:00:00 2001 From: hm Date: Sat, 28 May 2022 20:25:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BC=93=E5=AD=98=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Setting/Index0/Global/GlobalSetting.cpp | 119 +++++++-- App/Setting/Index0/Global/GlobalSetting.h | 15 ++ App/Setting/Index0/Global/GlobalSetting.ui | 262 ++++++++++---------- App/mainwindow.cpp | 17 ++ opmap/mapwidget/mapripper.cpp | 56 +++-- opmap/mapwidget/mapripper.h | 5 +- opmap/mapwidget/opmapwidget.cpp | 37 ++- opmap/mapwidget/opmapwidget.h | 11 +- 8 files changed, 358 insertions(+), 164 deletions(-) diff --git a/App/Setting/Index0/Global/GlobalSetting.cpp b/App/Setting/Index0/Global/GlobalSetting.cpp index 2bf4a88..edfd02f 100644 --- a/App/Setting/Index0/Global/GlobalSetting.cpp +++ b/App/Setting/Index0/Global/GlobalSetting.cpp @@ -19,22 +19,25 @@ GlobalSetting::GlobalSetting(QWidget *parent) : { ui->comboBox_map_level->addItem(tr("level %1").arg(i),i); } + ui->comboBox_map_level->setCurrentIndex(17); //地图缓存相关UI - ui->label_mapcache_info->hide(); - ui->label_maplat->hide(); - ui->label_maplevel->hide(); - ui->label_maplng->hide(); - ui->label_leftmap->hide(); - ui->label_rightmap->hide(); - ui->doubleSpinBox_left_lat->hide(); - ui->doubleSpinBox_left_lng->hide(); - ui->doubleSpinBox_right_lat->hide(); - ui->doubleSpinBox_right_lng->hide(); - ui->pushButton_map_cache->hide(); - ui->comboBox_map_level->hide(); +// ui->label_mapcache_info->hide(); +// ui->label_maplat->hide(); +// ui->label_maplevel->hide(); +// ui->label_maplng->hide(); +// ui->label_leftmap->hide(); +// ui->label_rightmap->hide(); + +// ui->doubleSpinBox_left_lat->hide(); +// ui->doubleSpinBox_left_lng->hide(); +// ui->doubleSpinBox_right_lat->hide(); +// ui->doubleSpinBox_right_lng->hide(); + +// ui->pushButton_map_cache->hide(); +// ui->comboBox_map_level->hide(); @@ -470,9 +473,6 @@ void GlobalSetting::MapTypes(QStringList list) { //QStringList map; - - - Selector *selector = new Selector(this); selector->setGeometry(0,0,this->width(),this->height()); @@ -488,3 +488,92 @@ void GlobalSetting::on_pushButton_MapProvider_clicked() { emit getMapTypes(); } + +void GlobalSetting::on_pushButton_map_cache_clicked() +{ + if(isMapCaching == false) + { + //检测左上和右下的坐标 + qreal lat_l = ui->doubleSpinBox_left_lat->value(); + qreal lng_l = ui->doubleSpinBox_left_lng->value(); + + qreal lat_r = ui->doubleSpinBox_right_lat->value(); + qreal lng_r = ui->doubleSpinBox_right_lng->value(); + + qint8 zoom = ui->comboBox_map_level->currentData().toInt(); + + + if((lat_l == lat_r) &&(lng_l == lng_r))//如果值一样,说明就是一个点,不开启缓存 + { + return; + } + + + //修改当前的名字 + ui->pushButton_map_cache->setText(tr("stop cache")); + + //状态改为正在换成 + isMapCaching = true; + + //显示隐藏的进度条 + + ui->progressBar_mapcache->show(); + + ui->doubleSpinBox_left_lat->setEnabled(false); + ui->doubleSpinBox_left_lng->setEnabled(false); + ui->doubleSpinBox_right_lat->setEnabled(false); + ui->doubleSpinBox_right_lng->setEnabled(false); + ui->comboBox_map_level->setEditable(false); + + //发送缓存指令 + + emit mapCache(isMapCaching,lat_l,lng_l,lat_r,lng_r,zoom); + } + else + { + setripfinished(); + } +} + +void GlobalSetting::setripfinished() +{ + //修改名字 + ui->pushButton_map_cache->setText(tr("start cache")); + + //修改状态 + isMapCaching = false; + + + ui->progressBar_mapcache->hide(); + + ui->doubleSpinBox_left_lat->setEnabled(true); + ui->doubleSpinBox_left_lng->setEnabled(true); + ui->doubleSpinBox_right_lat->setEnabled(true); + ui->doubleSpinBox_right_lng->setEnabled(true); + ui->comboBox_map_level->setEditable(true); + + //发送停止指令 + emit mapCache(isMapCaching,0,0,0,0,0); + + //emit mapCacheCancel(); +} + + + + +void GlobalSetting::SetPercentage(const int &perc) +{ + ui->progressBar_mapcache->setValue(perc); +} +void GlobalSetting::SetProvider(const QString &prov, const int &zoom) +{ + //ui->mainlabel->setText(QString(tr("Currently ripping from:%1 at Zoom level %2")).arg(prov).arg(zoom)); +} +void GlobalSetting::SetNumberOfTiles(const int &total, const int &actual) +{ + //ui->statuslabel->setText(QString(tr("Downloading tile %1 of %2")).arg(actual).arg(total)); +} + + + + diff --git a/App/Setting/Index0/Global/GlobalSetting.h b/App/Setting/Index0/Global/GlobalSetting.h index d80cbe3..e95c74c 100644 --- a/App/Setting/Index0/Global/GlobalSetting.h +++ b/App/Setting/Index0/Global/GlobalSetting.h @@ -28,6 +28,14 @@ public slots: void ServoParameter(QString type,QVariant data); + + + void SetPercentage(int const & perc); + void SetProvider(QString const & prov, int const & zoom); + void SetNumberOfTiles(int const & total, int const & actual); + + void setripfinished(); + private slots: void setMapProvider(QVariant key); @@ -47,6 +55,8 @@ private slots: void on_pushButton_MapProvider_clicked(); + void on_pushButton_map_cache_clicked(); + signals: void showMessage(const QString &message,int TimeOut = 0); @@ -64,12 +74,17 @@ signals: void setMapTypes(QVariant value); void getMapTypes(void); + + void mapCache(bool start,qreal lat_l,qreal lng_l,qreal lat_r,qreal lng_r,qint8 zoom); + void mapCacheCancel(); + private: Ui::GlobalSetting *ui; QMap bingmap; + bool isMapCaching = false; }; diff --git a/App/Setting/Index0/Global/GlobalSetting.ui b/App/Setting/Index0/Global/GlobalSetting.ui index cd33183..b960e23 100644 --- a/App/Setting/Index0/Global/GlobalSetting.ui +++ b/App/Setting/Index0/Global/GlobalSetting.ui @@ -7,7 +7,7 @@ 0 0 467 - 562 + 588 @@ -384,136 +384,6 @@ - - - - 地图设置 - - - - - - 8 - - - -90.000000000000000 - - - 90.000000000000000 - - - - - - - 右下坐标 - - - - - - - 8 - - - -90.000000000000000 - - - 90.000000000000000 - - - - - - - 8 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - 地图等级 - - - - - - - - - - 左上坐标 - - - - - - - 选择地图 - - - - - - - 纬度 - - - - - - - 开始缓存 - - - - - - - 0 - - - %v - - - - - - - 经度 - - - - - - - 8 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - 地图缓存信息 - - - - - - @@ -557,6 +427,136 @@ + + + + 地图设置 + + + + + + 左上坐标 + + + + + + + 8 + + + -90.000000000000000 + + + 90.000000000000000 + + + + + + + 地图等级 + + + + + + + 地图缓存信息 + + + + + + + 经度 + + + + + + + 0 + + + %v + + + + + + + 纬度 + + + + + + + 选择地图 + + + + + + + 8 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + start cache + + + + + + + 8 + + + -90.000000000000000 + + + 90.000000000000000 + + + + + + + + + + 右下坐标 + + + + + + + 8 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + diff --git a/App/mainwindow.cpp b/App/mainwindow.cpp index f88b5ec..e2c250d 100644 --- a/App/mainwindow.cpp +++ b/App/mainwindow.cpp @@ -310,6 +310,23 @@ MainWindow::MainWindow(QWidget *parent) this,&MainWindow::setServoOffset); + connect(setting->index0->globalsetting,SIGNAL(mapCache(bool,qreal,qreal,qreal,qreal,qint8)), + map,SLOT(userRipMap(bool,qreal,qreal,qreal,qreal,qint8))); + + + connect(map,SIGNAL(ripfinished()), + setting->index0->globalsetting,SLOT(setripfinished())); + + + connect(map,SIGNAL(percentageChanged(int)), + setting->index0->globalsetting,SLOT(SetPercentage(int))); + + connect(map,SIGNAL(numberOfTilesChanged(int,int)), + setting->index0->globalsetting,SLOT(SetNumberOfTiles(int,int))); + + connect(map,SIGNAL(providerChanged(QString,int)), + setting->index0->globalsetting,SLOT(SetProvider(QString,int))); + //command ----- dlink diff --git a/opmap/mapwidget/mapripper.cpp b/opmap/mapwidget/mapripper.cpp index 3a570de..f1f8830 100644 --- a/opmap/mapwidget/mapripper.cpp +++ b/opmap/mapwidget/mapripper.cpp @@ -26,22 +26,22 @@ */ #include "mapripper.h" namespace mapcontrol { -MapRipper::MapRipper(internals::Core *core, const internals::RectLatLng & rect) : sleep(100), cancel(false), progressForm(0), core(core), yesToAll(false) +MapRipper::MapRipper(internals::Core *core, const internals::RectLatLng & rect,int const & maxz) : sleep(100), cancel(false), core(core), yesToAll(true) { if (!rect.IsEmpty()) { type = core->GetMapType(); - progressForm = new MapRipForm; - connect(progressForm, SIGNAL(cancelRequest()), this, SLOT(stopFetching())); + //progressForm = new MapRipForm; + //connect(progressForm, SIGNAL(cancelRequest()), this, SLOT(stopFetching())); area = rect; zoom = core->Zoom(); - maxzoom = core->MaxZoom(); + setMaxZoom(maxz); points = core->Projection()->GetAreaTileList(area, zoom, 0); this->start(); cancel = false; - progressForm->show(); - connect(this, SIGNAL(percentageChanged(int)), progressForm, SLOT(SetPercentage(int))); - connect(this, SIGNAL(numberOfTilesChanged(int, int)), progressForm, SLOT(SetNumberOfTiles(int, int))); - connect(this, SIGNAL(providerChanged(QString, int)), progressForm, SLOT(SetProvider(QString, int))); + //progressForm->show(); + //connect(this, SIGNAL(percentageChanged(int)), progressForm, SLOT(SetPercentage(int))); + //connect(this, SIGNAL(numberOfTilesChanged(int, int)), progressForm, SLOT(SetNumberOfTiles(int, int))); + //connect(this, SIGNAL(providerChanged(QString, int)), progressForm, SLOT(SetProvider(QString, int))); connect(this, SIGNAL(finished()), this, SLOT(finish())); emit numberOfTilesChanged(0, 0); } else @@ -53,9 +53,10 @@ MapRipper::MapRipper(internals::Core *core, const internals::RectLatLng & rect) } void MapRipper::finish() { + if (zoom < maxzoom && !cancel) { ++zoom; - int ret; + int ret = QMessageBox::Yes; if (!yesToAll) { QMessageBox msgBox; msgBox.setText(QString(tr("Continue Ripping at zoom level %1?")).arg(zoom)); @@ -66,24 +67,34 @@ void MapRipper::finish() } else { ret = QMessageBox::Yes; } + if (ret == QMessageBox::Yes) { points.clear(); points = core->Projection()->GetAreaTileList(area, zoom, 0); + //qDebug() << zoom << maxzoom << ret; + 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; + //progressForm->close(); + //delete progressForm; + + emit ripfinished(); this->deleteLater(); } } else { - yesToAll = false; - progressForm->close(); - delete progressForm; + //yesToAll = false; + //progressForm->close(); + //delete progressForm; + + emit ripfinished(); this->deleteLater(); } } @@ -105,11 +116,13 @@ void MapRipper::run() core::Point p = points[i]; { - // qDebug()<<"offline fetching:"<GetImageFrom(type, p, zoom); + //qDebug() << img; + if (img.length() != 0) { goodtile = true; img = NULL; @@ -138,4 +151,17 @@ void MapRipper::stopFetching() cancel = true; } + +void MapRipper::setMaxZoom(int const & zoom) +{ + if(zoom <= core->MaxZoom()) + { + maxzoom = zoom; + } + else + { + maxzoom = core->MaxZoom(); + } +} + } diff --git a/opmap/mapwidget/mapripper.h b/opmap/mapwidget/mapripper.h index 72de890..6dfa438 100644 --- a/opmap/mapwidget/mapripper.h +++ b/opmap/mapwidget/mapripper.h @@ -43,7 +43,7 @@ class MapRipper : public QThread { Q_OBJECT public: - MapRipper(internals::Core *, internals::RectLatLng const &); + MapRipper(internals::Core *, internals::RectLatLng const &,int const & maxz); void run(); private: QList points; @@ -63,10 +63,13 @@ signals: void numberOfTilesChanged(int const & total, int const & actual); void providerChanged(QString const & prov, int const & zoom); + void ripfinished(); public slots: void stopFetching(); void finish(); + void setMaxZoom(int const & zoom); + }; } #endif // MAPRIPPER_H diff --git a/opmap/mapwidget/opmapwidget.cpp b/opmap/mapwidget/opmapwidget.cpp index 502fe4e..30198d0 100644 --- a/opmap/mapwidget/opmapwidget.cpp +++ b/opmap/mapwidget/opmapwidget.cpp @@ -1650,9 +1650,44 @@ void OPMapWidget::SetRotate(qreal const & value) compass->setRotation(value); } } + +void OPMapWidget::userRipMap(bool start, qreal lat_l, qreal lng_l, qreal lat_r, qreal lng_r, qint8 zoom) +{ + internals::RectLatLng rect(lat_l,lng_l,lat_r - lat_l,lng_r - lng_l); + + if(start == true) + { + + + MapRipper * mapRipper = new MapRipper(core, rect,zoom); + + connect(mapRipper,SIGNAL(percentageChanged(int)), + this,SIGNAL(percentageChanged(int))); + + connect(mapRipper,SIGNAL(numberOfTilesChanged(int,int)), + this,SIGNAL(numberOfTilesChanged(int,int))); + + connect(mapRipper,SIGNAL(providerChanged(QString,int)), + this,SIGNAL(providerChanged(QString,int))); + + connect(this, SIGNAL(cancelRequest()), + mapRipper, SLOT(stopFetching())); + + connect(mapRipper,SIGNAL(ripfinished()), + this,SIGNAL(ripfinished())); + + } + else + { + emit cancelRequest(); + } +} + + + void OPMapWidget::RipMap() { - new MapRipper(core, map->SelectedArea()); + new MapRipper(core, map->SelectedArea(),core->MaxZoom()); } void OPMapWidget::setSelectedWP(QListlist) diff --git a/opmap/mapwidget/opmapwidget.h b/opmap/mapwidget/opmapwidget.h index 23f9ddb..246082e 100644 --- a/opmap/mapwidget/opmapwidget.h +++ b/opmap/mapwidget/opmapwidget.h @@ -503,7 +503,7 @@ private: QTimer *NoOperationTimer = nullptr; - + //MapRipper * mapRipper = nullptr; internals::PointLatLng point_begin; @@ -536,6 +536,12 @@ protected: // private slots: signals: + void cancelRequest(); + void percentageChanged(int const & perc); + void numberOfTilesChanged(int const & total, int const & actual); + void providerChanged(QString const & prov, int const & zoom); + void ripfinished(); + void settableClicked(void); void showMessage(const QString &message,int TimeOut = 0); @@ -762,6 +768,9 @@ public slots: void getCurrentPoint(int group); + + void userRipMap(bool start,qreal lat_l,qreal lng_l,qreal lat_r,qreal lng_r,qint8 zoom); + }; } #endif // OPMAPWIDGET_H