mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
OP37/GCS MapLib Added offline map creator
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1199 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
03800c418a
commit
a58a6ce269
@ -34,7 +34,7 @@ using namespace projections;
|
|||||||
|
|
||||||
namespace internals {
|
namespace internals {
|
||||||
Core::Core():MouseWheelZooming(false),currentPosition(0,0),currentPositionPixel(0,0),LastLocationInBounds(-1,-1),sizeOfMapArea(0,0)
|
Core::Core():MouseWheelZooming(false),currentPosition(0,0),currentPositionPixel(0,0),LastLocationInBounds(-1,-1),sizeOfMapArea(0,0)
|
||||||
,minOfTiles(0,0),maxOfTiles(0,0),zoom(0),isDragging(false),TooltipTextPadding(10,10),loaderLimit(5),started(false)
|
,minOfTiles(0,0),maxOfTiles(0,0),zoom(0),isDragging(false),TooltipTextPadding(10,10),loaderLimit(5),maxzoom(17),started(false)
|
||||||
{
|
{
|
||||||
mousewheelzoomtype=MouseWheelZoomType::MousePositionAndCenter;
|
mousewheelzoomtype=MouseWheelZoomType::MousePositionAndCenter;
|
||||||
SetProjection(new MercatorProjection());
|
SetProjection(new MercatorProjection());
|
||||||
@ -286,6 +286,7 @@ namespace internals {
|
|||||||
if(Projection()->Type()!="PlateCarreeProjection")
|
if(Projection()->Type()!="PlateCarreeProjection")
|
||||||
{
|
{
|
||||||
SetProjection(new PlateCarreeProjection());
|
SetProjection(new PlateCarreeProjection());
|
||||||
|
maxzoom=13;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -298,6 +299,7 @@ namespace internals {
|
|||||||
if(Projection()->Type()!="LKS94Projection")
|
if(Projection()->Type()!="LKS94Projection")
|
||||||
{
|
{
|
||||||
SetProjection(new LKS94Projection());
|
SetProjection(new LKS94Projection());
|
||||||
|
maxzoom=11;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -307,6 +309,7 @@ namespace internals {
|
|||||||
if(Projection()->Type()!="PlateCarreeProjectionPergo")
|
if(Projection()->Type()!="PlateCarreeProjectionPergo")
|
||||||
{
|
{
|
||||||
SetProjection(new PlateCarreeProjectionPergo());
|
SetProjection(new PlateCarreeProjectionPergo());
|
||||||
|
maxzoom=17;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -316,6 +319,7 @@ namespace internals {
|
|||||||
if(Projection()->Type()!="MercatorProjectionYandex")
|
if(Projection()->Type()!="MercatorProjectionYandex")
|
||||||
{
|
{
|
||||||
SetProjection(new MercatorProjectionYandex());
|
SetProjection(new MercatorProjectionYandex());
|
||||||
|
maxzoom=13;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -325,6 +329,7 @@ namespace internals {
|
|||||||
if(Projection()->Type()!="MercatorProjection")
|
if(Projection()->Type()!="MercatorProjection")
|
||||||
{
|
{
|
||||||
SetProjection(new MercatorProjection());
|
SetProjection(new MercatorProjection());
|
||||||
|
maxzoom=17;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -433,7 +438,7 @@ namespace internals {
|
|||||||
{
|
{
|
||||||
int zoom = 0;
|
int zoom = 0;
|
||||||
|
|
||||||
for(int i = 1; i <= OPMaps::Instance()->MaxZoom; i++)
|
for(int i = 1; i <= MaxZoom(); i++)
|
||||||
{
|
{
|
||||||
Point p1 = Projection()->FromLatLngToPixel(rect.LocationTopLeft(), i);
|
Point p1 = Projection()->FromLatLngToPixel(rect.LocationTopLeft(), i);
|
||||||
Point p2 = Projection()->FromLatLngToPixel(rect.Bottom(), rect.Right(), i);
|
Point p2 = Projection()->FromLatLngToPixel(rect.Bottom(), rect.Right(), i);
|
||||||
|
@ -73,35 +73,36 @@ public:
|
|||||||
Core();
|
Core();
|
||||||
~Core();
|
~Core();
|
||||||
void run();
|
void run();
|
||||||
PointLatLng CurrentPosition()const{return currentPosition;};
|
PointLatLng CurrentPosition()const{return currentPosition;}
|
||||||
|
|
||||||
void SetCurrentPosition(const PointLatLng &value);
|
void SetCurrentPosition(const PointLatLng &value);
|
||||||
|
|
||||||
core::Point GetcurrentPositionGPixel(){return currentPositionPixel;};
|
core::Point GetcurrentPositionGPixel(){return currentPositionPixel;}
|
||||||
void SetcurrentPositionGPixel(const core::Point &value){currentPositionPixel=value;};
|
void SetcurrentPositionGPixel(const core::Point &value){currentPositionPixel=value;}
|
||||||
|
|
||||||
core::Point GetrenderOffset(){return renderOffset;};
|
core::Point GetrenderOffset(){return renderOffset;}
|
||||||
void SetrenderOffset(const core::Point &value){renderOffset=value;};
|
void SetrenderOffset(const core::Point &value){renderOffset=value;}
|
||||||
|
|
||||||
core::Point GetcenterTileXYLocation(){return centerTileXYLocation;};
|
core::Point GetcenterTileXYLocation(){return centerTileXYLocation;}
|
||||||
void SetcenterTileXYLocation(const core::Point &value){centerTileXYLocation=value;};
|
void SetcenterTileXYLocation(const core::Point &value){centerTileXYLocation=value;}
|
||||||
|
|
||||||
core::Point GetcenterTileXYLocationLast(){return centerTileXYLocationLast;};
|
core::Point GetcenterTileXYLocationLast(){return centerTileXYLocationLast;}
|
||||||
void SetcenterTileXYLocationLast(const core::Point &value){centerTileXYLocationLast=value;};
|
void SetcenterTileXYLocationLast(const core::Point &value){centerTileXYLocationLast=value;}
|
||||||
|
|
||||||
core::Point GetdragPoint(){return dragPoint;};
|
core::Point GetdragPoint(){return dragPoint;}
|
||||||
void SetdragPoint(const core::Point &value){dragPoint=value;};
|
void SetdragPoint(const core::Point &value){dragPoint=value;}
|
||||||
|
|
||||||
core::Point GetmouseDown(){return mouseDown;};
|
core::Point GetmouseDown(){return mouseDown;}
|
||||||
void SetmouseDown(const core::Point &value){mouseDown=value;};
|
void SetmouseDown(const core::Point &value){mouseDown=value;}
|
||||||
|
|
||||||
core::Point GetmouseCurrent(){return mouseCurrent;};
|
core::Point GetmouseCurrent(){return mouseCurrent;}
|
||||||
void SetmouseCurrent(const core::Point &value){mouseCurrent=value;};
|
void SetmouseCurrent(const core::Point &value){mouseCurrent=value;}
|
||||||
|
|
||||||
core::Point GetmouseLastZoom(){return mouseLastZoom;};
|
core::Point GetmouseLastZoom(){return mouseLastZoom;}
|
||||||
void SetmouseLastZoom(const core::Point &value){mouseLastZoom=value;};
|
void SetmouseLastZoom(const core::Point &value){mouseLastZoom=value;}
|
||||||
|
|
||||||
MouseWheelZoomType::Types GetMouseWheelZoomType(){return mousewheelzoomtype;};
|
MouseWheelZoomType::Types GetMouseWheelZoomType(){return mousewheelzoomtype;}
|
||||||
void SetMouseWheelZoomType(const MouseWheelZoomType::Types &value){mousewheelzoomtype=value;};
|
void SetMouseWheelZoomType(const MouseWheelZoomType::Types &value){mousewheelzoomtype=value;}
|
||||||
|
|
||||||
PointLatLng GetLastLocationInBounds(){return LastLocationInBounds;}
|
PointLatLng GetLastLocationInBounds(){return LastLocationInBounds;}
|
||||||
void SetLastLocationInBounds(const PointLatLng &value){LastLocationInBounds=value;}
|
void SetLastLocationInBounds(const PointLatLng &value){LastLocationInBounds=value;}
|
||||||
@ -140,6 +141,8 @@ public:
|
|||||||
int Zoom()const{return zoom;}
|
int Zoom()const{return zoom;}
|
||||||
void SetZoom(int const& value);
|
void SetZoom(int const& value);
|
||||||
|
|
||||||
|
int MaxZoom()const{return maxzoom;}
|
||||||
|
|
||||||
void UpdateBounds();
|
void UpdateBounds();
|
||||||
|
|
||||||
MapType::Types GetMapType(){return mapType;}
|
MapType::Types GetMapType(){return mapType;}
|
||||||
@ -253,6 +256,8 @@ private:
|
|||||||
QMutex MtileToload;
|
QMutex MtileToload;
|
||||||
int tilesToload;
|
int tilesToload;
|
||||||
|
|
||||||
|
int maxzoom;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool started;
|
bool started;
|
||||||
|
|
||||||
|
@ -171,32 +171,51 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if(isSelected && !selectionStart.IsEmpty() && (event->modifiers() == Qt::AltModifier || event->modifiers() == Qt::ShiftModifier))
|
||||||
|
{
|
||||||
|
selectionEnd = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
||||||
|
{
|
||||||
|
internals::PointLatLng p1 = selectionStart;
|
||||||
|
internals::PointLatLng p2 = selectionEnd;
|
||||||
|
|
||||||
|
double x1 = qMin(p1.Lng(), p2.Lng());
|
||||||
|
double y1 = qMax(p1.Lat(), p2.Lat());
|
||||||
|
double x2 = qMax(p1.Lng(), p2.Lng());
|
||||||
|
double y2 = qMin(p1.Lat(), p2.Lat());
|
||||||
|
|
||||||
|
SetSelectedArea(internals::RectLatLng(y1, x1, x2 - x1, y1 - y2));
|
||||||
|
}
|
||||||
|
}
|
||||||
QGraphicsItem::mouseMoveEvent(event);
|
QGraphicsItem::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
void MapGraphicItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void MapGraphicItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if(!IsMouseOverMarker())
|
|
||||||
{
|
|
||||||
if(event->button() == config->DragButton && CanDragMap())
|
|
||||||
|
if(!IsMouseOverMarker())
|
||||||
{
|
{
|
||||||
core->mouseDown.SetX(event->pos().x());
|
if(event->button() == config->DragButton && CanDragMap()&& !((event->modifiers()==Qt::AltModifier)||(event->modifiers()==Qt::ShiftModifier)))
|
||||||
core->mouseDown.SetY(event->pos().y());
|
{
|
||||||
|
core->mouseDown.SetX(event->pos().x());
|
||||||
|
core->mouseDown.SetY(event->pos().y());
|
||||||
|
|
||||||
|
|
||||||
this->setCursor(Qt::SizeAllCursor);
|
this->setCursor(Qt::SizeAllCursor);
|
||||||
|
|
||||||
core->BeginDrag(core->mouseDown);
|
core->BeginDrag(core->mouseDown);
|
||||||
this->update();
|
this->update();
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(!isSelected && ((event->modifiers()==Qt::AltModifier)||(event->modifiers()==Qt::ShiftModifier)))
|
||||||
|
{
|
||||||
|
isSelected = true;
|
||||||
|
SetSelectedArea (internals::RectLatLng::Empty);
|
||||||
|
selectionEnd = internals::PointLatLng::Empty;
|
||||||
|
selectionStart = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(!isSelected)
|
|
||||||
{
|
|
||||||
isSelected = true;
|
|
||||||
SetSelectedArea (internals::RectLatLng::Empty);
|
|
||||||
selectionEnd = internals::PointLatLng::Empty;
|
|
||||||
selectionStart = FromLocalToLatLng(event->pos().x(), event->pos().y());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void MapGraphicItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void MapGraphicItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
@ -224,12 +243,35 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
if(!selectedArea.IsEmpty() && event->modifiers() == Qt::ShiftModifier)
|
if(!selectedArea.IsEmpty() && event->modifiers() == Qt::ShiftModifier)
|
||||||
{
|
{
|
||||||
// SetZoomToFitRect(SelectedArea());TODO
|
SetZoomToFitRect(SelectedArea());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool MapGraphicItem::SetZoomToFitRect(internals::RectLatLng const& rect)
|
||||||
|
{
|
||||||
|
int maxZoom = core->GetMaxZoomToFitRect(rect);
|
||||||
|
if(maxZoom > 0)
|
||||||
|
{
|
||||||
|
internals::PointLatLng center=internals::PointLatLng(rect.Lat()-(rect.HeightLat()/2), rect.Lng()+(rect.WidthLng()/2));
|
||||||
|
core->SetCurrentPosition(center);
|
||||||
|
|
||||||
|
if(maxZoom > MaxZoom())
|
||||||
|
{
|
||||||
|
maxZoom = MaxZoom();
|
||||||
|
}
|
||||||
|
|
||||||
|
if((int) Zoom() != maxZoom)
|
||||||
|
{
|
||||||
|
SetZoom(maxZoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void MapGraphicItem::wheelEvent(QGraphicsSceneWheelEvent *event)
|
void MapGraphicItem::wheelEvent(QGraphicsSceneWheelEvent *event)
|
||||||
{
|
{
|
||||||
if(!IsMouseOverMarker() && !IsDragging())
|
if(!IsMouseOverMarker() && !IsDragging())
|
||||||
@ -354,6 +396,18 @@ namespace mapcontrol
|
|||||||
// raise error
|
// raise error
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if(!SelectedArea().IsEmpty())
|
||||||
|
{
|
||||||
|
core::Point p1 = FromLatLngToLocal(SelectedArea().LocationTopLeft());
|
||||||
|
core::Point p2 = FromLatLngToLocal(SelectedArea().LocationRightBottom());
|
||||||
|
int x1 = p1.X();
|
||||||
|
int y1 = p1.Y();
|
||||||
|
int x2 = p2.X();
|
||||||
|
int y2 = p2.Y();
|
||||||
|
painter->setPen(Qt::black);
|
||||||
|
painter->setBrush(QBrush(QColor(50,50,100,20)));
|
||||||
|
painter->drawRect(x1,y1,x2-x1,y2-y1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ namespace mapcontrol
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool SetZoomToFitRect(internals::RectLatLng const& rect);
|
||||||
internals::Core *core;
|
internals::Core *core;
|
||||||
Configuration *config;
|
Configuration *config;
|
||||||
bool showTileGridLines;
|
bool showTileGridLines;
|
||||||
@ -162,7 +162,7 @@ namespace mapcontrol
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
int MaxZoom()const{return maxZoom;}
|
int MaxZoom()const{return core->MaxZoom();}
|
||||||
/**
|
/**
|
||||||
* @brief Returns the minimum allowed zoom
|
* @brief Returns the minimum allowed zoom
|
||||||
*
|
*
|
||||||
@ -171,6 +171,7 @@ namespace mapcontrol
|
|||||||
int MinZoom()const{return minZoom;}
|
int MinZoom()const{return minZoom;}
|
||||||
internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return core->GetMouseWheelZoomType();}
|
internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return core->GetMouseWheelZoomType();}
|
||||||
void SetSelectedArea(internals::RectLatLng const& value){selectedArea = value;this->update();}
|
void SetSelectedArea(internals::RectLatLng const& value){selectedArea = value;this->update();}
|
||||||
|
internals::RectLatLng SelectedArea()const{return selectedArea;}
|
||||||
internals::RectLatLng BoundsOfMap;
|
internals::RectLatLng BoundsOfMap;
|
||||||
void Offset(int const& x, int const& y);
|
void Offset(int const& x, int const& y);
|
||||||
bool CanDragMap()const{return core->CanDragMap;}
|
bool CanDragMap()const{return core->CanDragMap;}
|
||||||
@ -183,7 +184,6 @@ namespace mapcontrol
|
|||||||
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return core->SetCurrentPositionByKeywords(keys);}
|
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return core->SetCurrentPositionByKeywords(keys);}
|
||||||
MapType::Types GetMapType(){return core->GetMapType();}
|
MapType::Types GetMapType(){return core->GetMapType();}
|
||||||
void SetMapType(MapType::Types const& value){core->SetMapType(value);}
|
void SetMapType(MapType::Types const& value){core->SetMapType(value);}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void Core_OnNeedInvalidation();
|
void Core_OnNeedInvalidation();
|
||||||
void ChildPosRefresh();
|
void ChildPosRefresh();
|
||||||
|
54
ground/src/libs/opmapcontrol/src/mapwidget/mapripform.cpp
Normal file
54
ground/src/libs/opmapcontrol/src/mapwidget/mapripform.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file mapripform.cpp
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mapripform.h"
|
||||||
|
#include "ui_mapripform.h"
|
||||||
|
|
||||||
|
MapRipForm::MapRipForm(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::MapRipForm)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
MapRipForm::~MapRipForm()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
void MapRipForm::SetPercentage(const int &perc)
|
||||||
|
{
|
||||||
|
ui->progressBar->setValue(perc);
|
||||||
|
}
|
||||||
|
void MapRipForm::SetProvider(const QString &prov,const int &zoom)
|
||||||
|
{
|
||||||
|
ui->mainlabel->setText(QString("Currently ripping from:%1 at Zoom level %2").arg(prov).arg(zoom));
|
||||||
|
}
|
||||||
|
void MapRipForm::SetNumberOfTiles(const int &total, const int &actual)
|
||||||
|
{
|
||||||
|
ui->statuslabel->setText(QString("Downloading tile %1 of %2").arg(actual).arg(total));
|
||||||
|
}
|
52
ground/src/libs/opmapcontrol/src/mapwidget/mapripform.h
Normal file
52
ground/src/libs/opmapcontrol/src/mapwidget/mapripform.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file mapripform.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef MAPRIPFORM_H
|
||||||
|
#define MAPRIPFORM_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class MapRipForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MapRipForm : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MapRipForm(QWidget *parent = 0);
|
||||||
|
~MapRipForm();
|
||||||
|
public slots:
|
||||||
|
void SetPercentage(int const& perc);
|
||||||
|
void SetProvider(QString const& prov,int const& zoom);
|
||||||
|
void SetNumberOfTiles(int const& total,int const& actual);
|
||||||
|
private:
|
||||||
|
Ui::MapRipForm *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MAPRIPFORM_H
|
71
ground/src/libs/opmapcontrol/src/mapwidget/mapripform.ui
Normal file
71
ground/src/libs/opmapcontrol/src/mapwidget/mapripform.ui
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MapRipForm</class>
|
||||||
|
<widget class="QWidget" name="MapRipForm">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>392</width>
|
||||||
|
<height>133</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>MapRipper</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QProgressBar" name="progressBar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>60</y>
|
||||||
|
<width>371</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="mainlabel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>30</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>321</width>
|
||||||
|
<height>16</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Currently ripping from:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="statuslabel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>30</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>341</width>
|
||||||
|
<height>16</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Downloading tile</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="cancelButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>280</x>
|
||||||
|
<y>100</y>
|
||||||
|
<width>75</width>
|
||||||
|
<height>23</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
123
ground/src/libs/opmapcontrol/src/mapwidget/mapripper.cpp
Normal file
123
ground/src/libs/opmapcontrol/src/mapwidget/mapripper.cpp
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file mapripper.cpp
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#include "mapripper.h"
|
||||||
|
namespace mapcontrol
|
||||||
|
{
|
||||||
|
|
||||||
|
MapRipper::MapRipper(internals::Core * core, const internals::RectLatLng & rect):sleep(100),cancel(false),progressForm(0),core(core)
|
||||||
|
{
|
||||||
|
if(!rect.IsEmpty())
|
||||||
|
{
|
||||||
|
type=core->GetMapType();
|
||||||
|
progressForm=new MapRipForm;
|
||||||
|
area=rect;
|
||||||
|
zoom=core->Zoom();
|
||||||
|
maxzoom=core->MaxZoom();
|
||||||
|
points=core->Projection()->GetAreaTileList(area,zoom,0);
|
||||||
|
this->start();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void MapRipper::finish()
|
||||||
|
{
|
||||||
|
if(zoom<maxzoom)
|
||||||
|
{
|
||||||
|
++zoom;
|
||||||
|
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);
|
||||||
|
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||||
|
int ret = msgBox.exec();
|
||||||
|
if(ret==QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
points.clear();
|
||||||
|
points=core->Projection()->GetAreaTileList(area,zoom,0);
|
||||||
|
this->start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
progressForm->close();
|
||||||
|
delete progressForm;
|
||||||
|
this->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MapRipper::run()
|
||||||
|
{
|
||||||
|
int countOk = 0;
|
||||||
|
bool goodtile=false;
|
||||||
|
// Stuff.Shuffle<Point>(ref list);
|
||||||
|
QVector<core::MapType::Types> types = OPMaps::Instance()->GetAllLayersOfType(type);
|
||||||
|
int all=points.count();
|
||||||
|
for(int i = 0; i < all; i++)
|
||||||
|
{
|
||||||
|
emit numberOfTilesChanged(all,i+1);
|
||||||
|
if(cancel)
|
||||||
|
break;
|
||||||
|
|
||||||
|
core::Point p = points[i];
|
||||||
|
{
|
||||||
|
//qDebug()<<"offline fetching:"<<p.ToString();
|
||||||
|
foreach(core::MapType::Types type,types)
|
||||||
|
{
|
||||||
|
emit providerChanged(core::MapType::StrByType(type),zoom);
|
||||||
|
QByteArray img = OPMaps::Instance()->GetImageFrom(type, p, zoom);
|
||||||
|
if(img.length()!=0)
|
||||||
|
{
|
||||||
|
goodtile=true;
|
||||||
|
img=NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
goodtile=false;
|
||||||
|
}
|
||||||
|
if(goodtile)
|
||||||
|
{
|
||||||
|
countOk++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
QThread::msleep(1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit percentageChanged((int) ((i+1)*100/all));//, i+1);
|
||||||
|
// worker.ReportProgress((int) ((i+1)*100/all), i+1);
|
||||||
|
|
||||||
|
QThread::msleep(sleep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
65
ground/src/libs/opmapcontrol/src/mapwidget/mapripper.h
Normal file
65
ground/src/libs/opmapcontrol/src/mapwidget/mapripper.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file mapripper.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef MAPRIPPER_H
|
||||||
|
#define MAPRIPPER_H
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
#include "../internals/core.h"
|
||||||
|
#include "mapripform.h"
|
||||||
|
#include <QObject>
|
||||||
|
#include <QMessageBox>
|
||||||
|
namespace mapcontrol
|
||||||
|
{
|
||||||
|
class MapRipper:public QThread
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MapRipper(internals::Core *,internals::RectLatLng const&);
|
||||||
|
void run();
|
||||||
|
private:
|
||||||
|
QList<core::Point> points;
|
||||||
|
int zoom;
|
||||||
|
core::MapType::Types type;
|
||||||
|
int sleep;
|
||||||
|
internals::RectLatLng area;
|
||||||
|
bool cancel;
|
||||||
|
MapRipForm * progressForm;
|
||||||
|
int maxzoom;
|
||||||
|
internals::Core * core;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void percentageChanged(int const& perc);
|
||||||
|
void numberOfTilesChanged(int const& total,int const& actual);
|
||||||
|
void providerChanged(QString const& prov,int const& zoom);
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void finish();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // MAPRIPPER_H
|
@ -10,7 +10,9 @@ SOURCES += mapgraphicitem.cpp \
|
|||||||
waypointitem.cpp \
|
waypointitem.cpp \
|
||||||
uavitem.cpp \
|
uavitem.cpp \
|
||||||
trailitem.cpp \
|
trailitem.cpp \
|
||||||
homeitem.cpp
|
homeitem.cpp \
|
||||||
|
mapripform.cpp \
|
||||||
|
mapripper.cpp
|
||||||
LIBS += -L../build \
|
LIBS += -L../build \
|
||||||
-lcore \
|
-lcore \
|
||||||
-linternals \
|
-linternals \
|
||||||
@ -23,9 +25,14 @@ HEADERS += mapgraphicitem.h \
|
|||||||
uavmapfollowtype.h \
|
uavmapfollowtype.h \
|
||||||
uavtrailtype.h \
|
uavtrailtype.h \
|
||||||
trailitem.h \
|
trailitem.h \
|
||||||
homeitem.h
|
homeitem.h \
|
||||||
|
mapripform.h \
|
||||||
|
mapripper.h
|
||||||
QT += opengl
|
QT += opengl
|
||||||
QT += network
|
QT += network
|
||||||
QT += sql
|
QT += sql
|
||||||
QT += svg
|
QT += svg
|
||||||
RESOURCES += mapresources.qrc
|
RESOURCES += mapresources.qrc
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
mapripform.ui
|
||||||
|
@ -277,4 +277,8 @@ namespace mapcontrol
|
|||||||
if(compass)
|
if(compass)
|
||||||
compass->setRotation(value);
|
compass->setRotation(value);
|
||||||
}
|
}
|
||||||
|
void OPMapWidget::RipMap()
|
||||||
|
{
|
||||||
|
new MapRipper(core,map->SelectedArea());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "QtSvg/QGraphicsSvgItem"
|
#include "QtSvg/QGraphicsSvgItem"
|
||||||
#include "uavitem.h"
|
#include "uavitem.h"
|
||||||
#include "homeitem.h"
|
#include "homeitem.h"
|
||||||
|
#include "mapripper.h"
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
class UAVItem;
|
class UAVItem;
|
||||||
@ -147,7 +148,7 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
|
// Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
|
||||||
Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
|
Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
|
||||||
Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
|
Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
|
||||||
Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom)
|
Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom)
|
||||||
@ -186,9 +187,9 @@ namespace mapcontrol
|
|||||||
* @brief Returns the maximum zoom for the map
|
* @brief Returns the maximum zoom for the map
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int MaxZoom()const{return map->maxZoom;}
|
int MaxZoom()const{return map->MaxZoom();}
|
||||||
|
|
||||||
void SetMaxZoom(int const& value){map->maxZoom = value;}
|
// void SetMaxZoom(int const& value){map->maxZoom = value;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@ -433,7 +434,11 @@ namespace mapcontrol
|
|||||||
* @param number the number of tiles still in the queue
|
* @param number the number of tiles still in the queue
|
||||||
*/
|
*/
|
||||||
void OnTilesStillToLoad(int number);
|
void OnTilesStillToLoad(int number);
|
||||||
|
public slots:
|
||||||
|
/**
|
||||||
|
* @brief Ripps the current selection to the DB
|
||||||
|
*/
|
||||||
|
void RipMap();
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user