1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

GCS some improvements to the ripping function of the map library.

This commit is contained in:
jb 2012-04-30 14:57:06 +01:00 committed by James Cotton
parent 25456e3b80
commit c95eeb92bb
7 changed files with 28 additions and 15 deletions

View File

@ -216,8 +216,6 @@ namespace mapcontrol
void MapGraphicItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void MapGraphicItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
qDebug()<<event->modifiers();
if(!IsMouseOverMarker()) if(!IsMouseOverMarker())
{ {
if(event->button() == config->DragButton && CanDragMap()&& !((event->modifiers()==Qt::ShiftModifier)||(event->modifiers()==Qt::ControlModifier))) if(event->button() == config->DragButton && CanDragMap()&& !((event->modifiers()==Qt::ShiftModifier)||(event->modifiers()==Qt::ControlModifier)))
@ -431,11 +429,6 @@ namespace mapcontrol
} }
} }
} }
// painter->drawRect(core->GetrenderOffset().X()-lastimagepoint.X()-3,core->GetrenderOffset().Y()-lastimagepoint.Y()-3,lastimage.width(),lastimage.height());
// painter->setPen(Qt::red);
// painter->drawLine(-10,-10,10,10);
// painter->drawLine(10,10,-10,-10);
// painter->drawRect(boundingRect().adjusted(100,100,-100,-100));
} }

View File

@ -33,6 +33,7 @@ MapRipForm::MapRipForm(QWidget *parent) :
ui(new Ui::MapRipForm) ui(new Ui::MapRipForm)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->cancelButton,SIGNAL(clicked()),this,SIGNAL(cancelRequest()));
} }
MapRipForm::~MapRipForm() MapRipForm::~MapRipForm()

View File

@ -44,6 +44,8 @@ public slots:
void SetPercentage(int const& perc); void SetPercentage(int const& perc);
void SetProvider(QString const& prov,int const& zoom); void SetProvider(QString const& prov,int const& zoom);
void SetNumberOfTiles(int const& total,int const& actual); void SetNumberOfTiles(int const& total,int const& actual);
signals:
void cancelRequest();
private: private:
Ui::MapRipForm *ui; Ui::MapRipForm *ui;
}; };

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>392</width> <width>521</width>
<height>133</height> <height>133</height>
</rect> </rect>
</property> </property>
@ -18,7 +18,7 @@
<rect> <rect>
<x>20</x> <x>20</x>
<y>60</y> <y>60</y>
<width>371</width> <width>481</width>
<height>23</height> <height>23</height>
</rect> </rect>
</property> </property>
@ -31,7 +31,7 @@
<rect> <rect>
<x>30</x> <x>30</x>
<y>10</y> <y>10</y>
<width>321</width> <width>481</width>
<height>16</height> <height>16</height>
</rect> </rect>
</property> </property>
@ -55,7 +55,7 @@
<widget class="QPushButton" name="cancelButton"> <widget class="QPushButton" name="cancelButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>280</x> <x>220</x>
<y>100</y> <y>100</y>
<width>75</width> <width>75</width>
<height>23</height> <height>23</height>

View File

@ -34,11 +34,13 @@ MapRipper::MapRipper(internals::Core * core, const internals::RectLatLng & rect)
{ {
type=core->GetMapType(); type=core->GetMapType();
progressForm=new MapRipForm; progressForm=new MapRipForm;
connect(progressForm,SIGNAL(cancelRequest()),this,SLOT(stopFetching()));
area=rect; area=rect;
zoom=core->Zoom(); zoom=core->Zoom();
maxzoom=core->MaxZoom(); maxzoom=core->MaxZoom();
points=core->Projection()->GetAreaTileList(area,zoom,0); points=core->Projection()->GetAreaTileList(area,zoom,0);
this->start(); this->start();
cancel=false;
progressForm->show(); progressForm->show();
connect(this,SIGNAL(percentageChanged(int)),progressForm,SLOT(SetPercentage(int))); connect(this,SIGNAL(percentageChanged(int)),progressForm,SLOT(SetPercentage(int)));
connect(this,SIGNAL(numberOfTilesChanged(int,int)),progressForm,SLOT(SetNumberOfTiles(int,int))); connect(this,SIGNAL(numberOfTilesChanged(int,int)),progressForm,SLOT(SetNumberOfTiles(int,int)));
@ -51,7 +53,7 @@ MapRipper::MapRipper(internals::Core * core, const internals::RectLatLng & rect)
} }
void MapRipper::finish() void MapRipper::finish()
{ {
if(zoom<maxzoom) if(zoom<maxzoom && !cancel)
{ {
++zoom; ++zoom;
int ret; int ret;
@ -87,7 +89,12 @@ void MapRipper::finish()
} }
} }
else else
{
yesToAll=false; yesToAll=false;
progressForm->close();
delete progressForm;
this->deleteLater();
}
} }
@ -136,4 +143,10 @@ void MapRipper::finish()
QThread::msleep(sleep); QThread::msleep(sleep);
} }
} }
void MapRipper::stopFetching()
{
QMutexLocker locker(&mutex);
cancel=true;
}
} }

View File

@ -51,6 +51,7 @@ namespace mapcontrol
int maxzoom; int maxzoom;
internals::Core * core; internals::Core * core;
bool yesToAll; bool yesToAll;
QMutex mutex;
signals: signals:
void percentageChanged(int const& perc); void percentageChanged(int const& perc);
@ -59,6 +60,7 @@ namespace mapcontrol
public slots: public slots:
void stopFetching();
void finish(); void finish();
}; };
} }

View File

@ -477,12 +477,14 @@ void OPMapGadgetWidget::contextMenuEvent(QContextMenuEvent *event)
menu.addSeparator(); menu.addSeparator();
*/ */
QMenu safeArea("Safety Area definitions");
menu.addAction(showSafeAreaAct); // menu.addAction(showSafeAreaAct);
QMenu safeAreaSubMenu(tr("Safe Area Radius") + " (" + QString::number(m_map->Home->SafeArea()) + "m)", this); QMenu safeAreaSubMenu(tr("Safe Area Radius") + " (" + QString::number(m_map->Home->SafeArea()) + "m)", this);
for (int i = 0; i < safeAreaAct.count(); i++) for (int i = 0; i < safeAreaAct.count(); i++)
safeAreaSubMenu.addAction(safeAreaAct.at(i)); safeAreaSubMenu.addAction(safeAreaAct.at(i));
menu.addMenu(&safeAreaSubMenu); safeArea.addMenu(&safeAreaSubMenu);
safeArea.addAction(showSafeAreaAct);
menu.addMenu(&safeArea);
menu.addSeparator(); menu.addSeparator();