1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-37 GCS/MapPlugin

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@679 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-05-29 19:43:16 +00:00 committed by zedamota
parent ab34bbfa7a
commit 198045b292
16 changed files with 73 additions and 39 deletions

View File

@ -24,6 +24,4 @@ public:
};
};
#endif // ACCESSMODE_H

View File

@ -1,5 +0,0 @@
#include "core.h"
Core::Core()
{
}

View File

@ -4,18 +4,21 @@ Point::Point(int dw)
{
this->x=(short)Point::LOWORD(dw);
this->y=(short)Point::HIWORD(dw);
empty=false;
}
Point::Point(Size sz)
{
this->x=sz.Width();
this->y=sz.Height();
empty=false;
}
Point::Point(int x, int y)
{
this->x=x;
this->y=y;
empty=false;
}
Point::Point():x(-1),y(-1)
Point::Point():x(0),y(0),empty(true)
{}
uint qHash(Point const& point)
{

View File

@ -2,7 +2,7 @@
#define POINT_H
#include "QString"
#include <QString>
//#include "size.h"
struct Size;
struct Point
@ -16,11 +16,11 @@ public:
Point(int x,int y);
Point(Size sz);
Point(int dw);
bool IsEmpty(){return (x==-1 && y==-1);}
bool IsEmpty(){return empty;}
int X()const{return this->x;}
int Y()const{return this->y;}
void SetX(const int &value){x=value;}
void SetY(const int &value){y=value;}
void SetX(const int &value){x=value;empty=false;}
void SetY(const int &value){y=value;empty=false;}
QString ToString()const{return "{"+QString::number(x)+","+QString::number(y)+"}";}
static Point Empty;
@ -39,6 +39,7 @@ public:
private:
int x;
int y;
bool empty;
};

View File

@ -1,5 +1,7 @@
#include "pureimagecache.h"
qlonglong PureImageCache::ConnCounter=0;
PureImageCache::PureImageCache()
{
gtilecache=QDir::currentPath()+QDir::separator()+"mapscache"+QDir::separator();
@ -19,7 +21,6 @@ QString PureImageCache::GtileCache()
bool PureImageCache::CreateEmptyDB(const QString &file)
{
qDebug()<<"Create database at:"<<file;
bool ret=true;
QFileInfo File(file);
QDir dir=File.absoluteDir();
QString path=dir.absolutePath();

View File

@ -32,7 +32,7 @@ public:
private:
QString gtilecache;
QMutex Mcounter;
static qlonglong ConnCounter;
};
static qlonglong ConnCounter=0;
#endif // PUREIMAGECACHE_H

View File

@ -7,7 +7,6 @@
struct Size
{
public:
Size();
Size(Point pt){width=pt.X(); height=pt.Y();};
Size(int Width,int Height){width=Width; height=Height;};

View File

@ -77,7 +77,7 @@ void UrlFactory::TryCorrectGoogleVersions()
reply=network.get(qheader);
QTime time;
time.start();
while( !(reply->isFinished() | time.elapsed()>(6*Timeout)) ){QCoreApplication::processEvents(QEventLoop::AllEvents);}
while( (!(reply->isFinished()) || (time.elapsed()>(6*Timeout))) ){QCoreApplication::processEvents(QEventLoop::AllEvents);}
qDebug()<<"Finished?"<<reply->error()<<" abort?"<<(time.elapsed()>Timeout*6);
if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
{
@ -546,7 +546,7 @@ PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool
qDebug()<<"GetLatLngFromGeocoderUrl:URL="<<url;
QTime time;
time.start();
while( !(reply->isFinished() | time.elapsed()>(6*Timeout)) ){QCoreApplication::processEvents(QEventLoop::AllEvents);}
while( (!(reply->isFinished()) || (time.elapsed()>(6*Timeout))) ){QCoreApplication::processEvents(QEventLoop::AllEvents);}
qDebug()<<"Finished?"<<reply->error()<<" abort?"<<(time.elapsed()>Timeout*6);
if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
{
@ -626,7 +626,7 @@ Placemark UrlFactory::GetPlacemarkFromReverseGeocoderUrl(const QString &url, con
qDebug()<<"GetLatLngFromGeocoderUrl:URL="<<url;
QTime time;
time.start();
while( !(reply->isFinished() | time.elapsed()>(6*Timeout)) ){QCoreApplication::processEvents(QEventLoop::AllEvents);}
while( (!(reply->isFinished()) || (time.elapsed()>(6*Timeout))) ){QCoreApplication::processEvents(QEventLoop::AllEvents);}
qDebug()<<"Finished?"<<reply->error()<<" abort?"<<(time.elapsed()>Timeout*6);
if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
{

View File

@ -0,0 +1,4 @@
#include "mousewheelzoomtype.h"
QStringList MouseWheelZoomType::strList=QStringList()<<"MousePositionAndCenter"<<"MousePositionWithoutCenter"<<"ViewCenter";

View File

@ -1,7 +1,7 @@
#include "core.h"
Core::Core():currentPosition(0,0),currentPositionPixel(0,0),LastLocationInBounds(-1,-1),sizeOfMapArea(0,0)
,minOfTiles(0,0),maxOfTiles(0,0),started(false),isDragging(false),TooltipTextPadding(10,10),MouseWheelZooming(false),loaderLimit(5)
,minOfTiles(0,0),maxOfTiles(0,0),isDragging(false),started(false),MouseWheelZooming(false),TooltipTextPadding(10,10),zoom(0),loaderLimit(5)
{
mousewheelzoomtype=MouseWheelZoomType::MousePositionAndCenter;
SetProjection(new MercatorProjection());

View File

@ -18,7 +18,8 @@ SOURCES += core.cpp \
rectlatlng.cpp \
sizelatlng.cpp \
pointlatlng.cpp \
loadtask.cpp
loadtask.cpp \
MouseWheelZoomType.cpp
HEADERS += ./projections/lks94projection.h \
./projections/mercatorprojection.h \
./projections/mercatorprojectionyandex.h \
@ -30,4 +31,4 @@ SOURCES += ./projections/lks94projection.cpp \
./projections/platecarreeprojection.cpp \
./projections/platecarreeprojectionpergo.cpp
LIBS += -L../build \
-lcore \
-lcore

View File

@ -1,6 +1,8 @@
#ifndef MOUSEWHEELZOOMTYPE_H
#define MOUSEWHEELZOOMTYPE_H
#include <QObject>
#include <QStringList>
#include <QMetaType>
struct MouseWheelZoomType
{
enum Types
@ -21,6 +23,11 @@ struct MouseWheelZoomType
/// </summary>
ViewCenter,
};
static QStringList TypesStrList(){return strList;}
static Types TypeByStr(QString const& value){return (Types)MouseWheelZoomType::strList.indexOf(value);}
private:
static QStringList strList;
};
Q_DECLARE_METATYPE(MouseWheelZoomType::Types)
#endif // MOUSEWHEELZOOMTYPE_H

View File

@ -1,6 +1,6 @@
#include "opmapcontrol.h"
OPMapControl::OPMapControl(QWidget *parent):QWidget(parent),MapRenderTransform(1)
OPMapControl::OPMapControl(QWidget *parent):QWidget(parent),MapRenderTransform(1), maxZoom(2),minZoom(2)
{
EmptytileBrush = Qt::blue;
MissingDataFont =QFont ("Times",10,QFont::Bold);
@ -8,13 +8,19 @@ OPMapControl::OPMapControl(QWidget *parent):QWidget(parent),MapRenderTransform(1
EmptyTileBorders = QPen(Qt::white);
ShowTileGridLines=true;
core.SetCurrentRegion(Rectangle(-50, -50, this->width()+100, this->height()+100));
core.SetMapType(MapType::GoogleMap);
resize();
core.SetMapType(MapType::GoogleSatellite);
core.SetZoom(2);
connect(&core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
core.StartSystem();
}
void OPMapControl::showEvent(QShowEvent *event)
{
QWidget::showEvent(event);
core.StartSystem();
resize();
}
void OPMapControl::Core_OnNeedInvalidation()
{
this->repaint();
@ -24,7 +30,8 @@ void OPMapControl::paintEvent(QPaintEvent* evnt)
{
QWidget::paintEvent(evnt);
QPainter painter(this);
// painter.setBrush(palette().foreground().color());
// painter.fillRect(this->rect(),painter.background());
if(MapRenderTransform!=1)
{
QTransform transform;
@ -39,12 +46,12 @@ void OPMapControl::paintEvent(QPaintEvent* evnt)
{
DrawMap2D(painter);
}
painter.drawText(10,10,"TESTE");
// painter.drawText(10,10,"TESTE");
}
void OPMapControl::DrawMap2D(QPainter &painter)
{
painter.drawText(10,10,"TESTE");
// painter.drawText(10,10,"TESTE");
for(int i = -core.GetsizeOfMapArea().Width(); i <= core.GetsizeOfMapArea().Width(); i++)
{
for(int j = -core.GetsizeOfMapArea().Height(); j <= core.GetsizeOfMapArea().Height(); j++)
@ -94,7 +101,7 @@ void OPMapControl::DrawMap2D(QPainter &painter)
painter.setFont(MissingDataFont);
painter.setPen(Qt::red);
painter.drawText(QRectF(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height()),Qt::AlignCenter,(core.GettilePoint() == core.GetcenterTileXYLocation()? "CENTER: " :"TILE: ")+core.GettilePoint().ToString());
qDebug()<<"ShowTileGridLine:"<<core.GettilePoint().ToString()<<"=="<<core.GetcenterTileXYLocation().ToString();
}
}

View File

@ -11,24 +11,40 @@ class OPMapControl:public QWidget
{
Q_OBJECT
Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
Q_PROPERTY(MouseWheelZoomType::Types MouseWheelZoom READ GetMouseWheelZoomType WRITE SetMouseWheelZoomType)
Q_PROPERTY(QString MouseWheelZoomStr READ GetMouseWheelZoomTypeStr WRITE SetMouseWheelZoomTypeByStr)
public:
OPMapControl(QWidget *parent=0);
QBrush EmptytileBrush;
QString EmptyTileText;
QPen EmptyTileBorders;
bool ShowTileGridLines;
int MaxZoom()const{return maxZoom;}
void SetMaxZoom(int const& value){maxZoom = value;}
int MinZoom()const{return minZoom;}
void SetMinZoom(int const& value){minZoom = value;}
MouseWheelZoomType::Types GetMouseWheelZoomType(){return core.GetMouseWheelZoomType();}
void SetMouseWheelZoomType(MouseWheelZoomType::Types const& value){core.SetMouseWheelZoomType(value);}
void SetMouseWheelZoomTypeByStr(const QString &value){core.SetMouseWheelZoomType(MouseWheelZoomType::TypeByStr(value));}
QString GetMouseWheelZoomTypeStr(){return MouseWheelZoomType::TypesStrList().at((int)core.GetMouseWheelZoomType());}
protected:
void paintEvent ( QPaintEvent* evnt );
void mousePressEvent ( QMouseEvent* evnt );
void mouseReleaseEvent ( QMouseEvent* evnt );
void mouseMoveEvent ( QMouseEvent* evnt );
void resizeEvent ( QResizeEvent * event );
void showEvent ( QShowEvent * event );
private:
Core core;
qreal MapRenderTransform;
void DrawMap2D(QPainter &painter);
QFont MissingDataFont;
void resize();
int maxZoom;
int minZoom;
private slots:
void Core_OnNeedInvalidation();
};

View File

@ -1,15 +1,18 @@
#include <QApplication>
#include "map.h"
//#include "map.h"
#include "../mapwidget/opmapcontrol.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
map * mw = new map();
// map * mw = new map();
// mw->resize(400,590);
mw->setWindowTitle("Map");
mw->adjustSize();
mw->show();
// mw->setWindowTitle("Map");
// mw->adjustSize();
// mw->show();1022 680
OPMapControl map;
map.setGeometry(20,20,1022,680);
map.show();
return app.exec();
}

View File

@ -1,5 +1,4 @@
#include "map.h"
map::map(QWidget* parent)
{
mc= new OPMapControl();