mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
OP-37 GCS/MapPlugin Created new configuration class.
Created lots of signals. Changed settings to not show tile lines by default. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@806 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
791997dbad
commit
3b0000a074
@ -29,11 +29,15 @@
|
||||
#define ACCESSMODE_H
|
||||
|
||||
#include "debugheader.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QMetaObject>
|
||||
#include <QMetaEnum>
|
||||
#include <QStringList>
|
||||
namespace core {
|
||||
struct AccessMode
|
||||
class AccessMode:public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Types)
|
||||
public:
|
||||
enum Types
|
||||
{
|
||||
@ -52,6 +56,31 @@ namespace core {
|
||||
/// </summary>
|
||||
CacheOnly,
|
||||
};
|
||||
static QString StrByType(Types const& value)
|
||||
{
|
||||
QMetaObject metaObject = AccessMode().staticMetaObject;
|
||||
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||
QString s=metaEnum.valueToKey(value);
|
||||
return s;
|
||||
}
|
||||
static Types TypeByStr(QString const& value)
|
||||
{
|
||||
QMetaObject metaObject = AccessMode().staticMetaObject;
|
||||
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||
Types s=(Types)metaEnum.keyToValue(value.toLatin1());
|
||||
return s;
|
||||
}
|
||||
static QStringList TypesList()
|
||||
{
|
||||
QStringList ret;
|
||||
QMetaObject metaObject = AccessMode().staticMetaObject;
|
||||
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||
for(int x=0;x<metaEnum.keyCount();++x)
|
||||
{
|
||||
ret.append(metaEnum.key(x));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <QObject>
|
||||
#include <QMetaObject>
|
||||
#include <QMetaEnum>
|
||||
#include <QStringList>
|
||||
namespace core {
|
||||
class GeoCoderStatusCode:public QObject
|
||||
{
|
||||
@ -114,6 +115,17 @@ namespace core {
|
||||
Types s=(Types)metaEnum.keyToValue(value.toLatin1());
|
||||
return s;
|
||||
}
|
||||
static QStringList TypesList()
|
||||
{
|
||||
QStringList ret;
|
||||
QMetaObject metaObject = GeoCoderStatusCode().staticMetaObject;
|
||||
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||
for(int x=0;x<metaEnum.keyCount();++x)
|
||||
{
|
||||
ret.append(metaEnum.key(x));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ namespace core {
|
||||
<<"zh-TW";
|
||||
|
||||
}
|
||||
QString LanguageType::toString(Types type)
|
||||
QString LanguageType::toShortString(Types type)
|
||||
{
|
||||
return list[type];
|
||||
}
|
||||
|
@ -29,16 +29,18 @@
|
||||
#define LANGUAGETYPE_H
|
||||
|
||||
#include <QString>
|
||||
#include <QMetaObject>
|
||||
#include <QMetaEnum>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
|
||||
namespace core {
|
||||
class LanguageType
|
||||
class LanguageType:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Types)
|
||||
public:
|
||||
|
||||
enum Types
|
||||
enum Types
|
||||
{
|
||||
Arabic,
|
||||
Bulgarian,
|
||||
@ -95,14 +97,38 @@ namespace core {
|
||||
ChineseSimplified,
|
||||
ChineseTraditional,
|
||||
};
|
||||
|
||||
|
||||
QString toString(Types type);
|
||||
|
||||
static QString StrByType(Types const& value)
|
||||
{
|
||||
QMetaObject metaObject = LanguageType().staticMetaObject;
|
||||
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||
QString s=metaEnum.valueToKey(value);
|
||||
return s;
|
||||
}
|
||||
static Types TypeByStr(QString const& value)
|
||||
{
|
||||
QMetaObject metaObject = LanguageType().staticMetaObject;
|
||||
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||
Types s=(Types)metaEnum.keyToValue(value.toLatin1());
|
||||
return s;
|
||||
}
|
||||
static QStringList TypesList()
|
||||
{
|
||||
QStringList ret;
|
||||
QMetaObject metaObject = LanguageType().staticMetaObject;
|
||||
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||
for(int x=0;x<metaEnum.keyCount();++x)
|
||||
{
|
||||
ret.append(metaEnum.key(x));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
QString toShortString(Types type);
|
||||
LanguageType();
|
||||
~LanguageType();
|
||||
private:
|
||||
QStringList list;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif // LANGUAGETYPE_H
|
||||
|
@ -41,7 +41,7 @@ namespace core {
|
||||
{
|
||||
accessmode=AccessMode::ServerAndCache;
|
||||
Language=LanguageType::PortuguesePortugal;
|
||||
LanguageStr=LanguageType().toString(Language);
|
||||
LanguageStr=LanguageType().toShortString(Language);
|
||||
// Cache::Instance()->ImageCache=PureImageCache();
|
||||
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ namespace core {
|
||||
QByteArray GetImageFrom(const MapType::Types &type,const core::Point &pos,const int &zoom);
|
||||
bool UseMemoryCache();//TODO
|
||||
void setUseMemoryCache(const bool& value){useMemoryCache=value;}
|
||||
void setLanguage(const LanguageType::Types& language);//TODO
|
||||
LanguageType::Types GetLanguage();//TODO
|
||||
void setLanguage(const LanguageType::Types& language){Language=language;}//TODO
|
||||
LanguageType::Types GetLanguage(){return Language;}//TODO
|
||||
AccessMode::Types GetAccessMode()const{return accessmode;};
|
||||
void setAccessMode(const AccessMode::Types& mode){accessmode=mode;};
|
||||
int MaxZoom;
|
||||
|
@ -29,6 +29,5 @@
|
||||
|
||||
|
||||
namespace internals {
|
||||
QStringList MouseWheelZoomType::strList=QStringList()<<"MousePositionAndCenter"<<"MousePositionWithoutCenter"<<"ViewCenter";
|
||||
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ namespace internals {
|
||||
qDebug()<<"core:run"<<" ID="<<debug;
|
||||
#endif //DEBUG_CORE
|
||||
bool last = false;
|
||||
int stillToGo;
|
||||
|
||||
LoadTask task;
|
||||
|
||||
@ -64,7 +65,8 @@ namespace internals {
|
||||
{
|
||||
task = tileLoadQueue.dequeue();
|
||||
{
|
||||
last = tileLoadQueue.count() == 0;
|
||||
stillToGo=tileLoadQueue.count();
|
||||
last = (stillToGo == 0);
|
||||
#ifdef DEBUG_CORE
|
||||
qDebug()<<"TileLoadQueue: " << tileLoadQueue.count()<<" Point:"<<task.Pos.ToString()<<" ID="<<debug;;
|
||||
#endif //DEBUG_CORE
|
||||
@ -151,6 +153,7 @@ namespace internals {
|
||||
{
|
||||
Matrix.SetTileAt(task.Pos,t);
|
||||
emit OnNeedInvalidation();
|
||||
emit OnTilesStillToLoad(stillToGo);
|
||||
#ifdef DEBUG_CORE
|
||||
qDebug()<<"Core::run add tile "<<t->GetPos().ToString()<<" to matrix index "<<task.Pos.ToString()<<" ID="<<debug;
|
||||
qDebug()<<"Core::run matrix index "<<task.Pos.ToString()<<" as tile with "<<Matrix.TileAt(task.Pos)->Overlays.count()<<" ID="<<debug;
|
||||
|
@ -138,10 +138,8 @@ public:
|
||||
bool IsDragging()const{return isDragging;}
|
||||
|
||||
int Zoom()const{return zoom;}
|
||||
|
||||
void SetZoom(int const& value);
|
||||
|
||||
|
||||
void UpdateBounds();
|
||||
|
||||
MapType::Types GetMapType(){return mapType;}
|
||||
@ -161,7 +159,6 @@ public:
|
||||
|
||||
PointLatLng FromLocalToLatLng(int const& x, int const& y);
|
||||
|
||||
|
||||
Point FromLatLngToLocal(PointLatLng const& latlng);
|
||||
|
||||
int GetMaxZoomToFitRect(RectLatLng const& rect);
|
||||
@ -194,6 +191,7 @@ public:
|
||||
signals:
|
||||
void OnCurrentPositionChanged(PointLatLng point);
|
||||
void OnTileLoadComplete();
|
||||
void OnTilesStillToLoad(int number);
|
||||
void OnTileLoadStart();
|
||||
void OnMapDrag();
|
||||
void OnMapZoomChanged();
|
||||
@ -224,13 +222,10 @@ private:
|
||||
Size minOfTiles;
|
||||
Size maxOfTiles;
|
||||
|
||||
|
||||
|
||||
core::Point tilePoint;
|
||||
|
||||
Rectangle CurrentRegion;
|
||||
|
||||
|
||||
QQueue<LoadTask> tileLoadQueue;
|
||||
|
||||
int zoom;
|
||||
|
@ -30,12 +30,14 @@
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QMetaType>
|
||||
|
||||
#include <QMetaObject>
|
||||
#include <QMetaEnum>
|
||||
namespace internals {
|
||||
struct MouseWheelZoomType:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
class MouseWheelZoomType:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Types)
|
||||
public:
|
||||
enum Types
|
||||
{
|
||||
/// <summary>
|
||||
@ -54,11 +56,32 @@ public:
|
||||
/// </summary>
|
||||
ViewCenter,
|
||||
};
|
||||
Q_ENUMS(Types)
|
||||
static QStringList TypesStrList(){return strList;}
|
||||
static Types TypeByStr(QString const& value){return (Types)MouseWheelZoomType::strList.indexOf(value);}
|
||||
private:
|
||||
static QStringList strList;
|
||||
static QString StrByType(Types const& value)
|
||||
{
|
||||
QMetaObject metaObject = MouseWheelZoomType().staticMetaObject;
|
||||
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||
QString s=metaEnum.valueToKey(value);
|
||||
return s;
|
||||
}
|
||||
static Types TypeByStr(QString const& value)
|
||||
{
|
||||
QMetaObject metaObject = MouseWheelZoomType().staticMetaObject;
|
||||
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||
Types s=(Types)metaEnum.keyToValue(value.toLatin1());
|
||||
return s;
|
||||
}
|
||||
static QStringList TypesList()
|
||||
{
|
||||
QStringList ret;
|
||||
QMetaObject metaObject = MouseWheelZoomType().staticMetaObject;
|
||||
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
|
||||
for(int x=0;x<metaEnum.keyCount();++x)
|
||||
{
|
||||
ret.append(metaEnum.key(x));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
27
ground/src/libs/opmapcontrol/src/mapwidget/configuration.cpp
Normal file
27
ground/src/libs/opmapcontrol/src/mapwidget/configuration.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "configuration.h"
|
||||
|
||||
Configuration::Configuration()
|
||||
{
|
||||
EmptytileBrush = Qt::cyan;
|
||||
MissingDataFont =QFont ("Times",10,QFont::Bold);
|
||||
EmptyTileText = "We are sorry, but we don't\nhave imagery at this zoom\nlevel for this region.";
|
||||
EmptyTileBorders = QPen(Qt::white);
|
||||
ScalePen = QPen(Qt::blue);
|
||||
SelectionPen = QPen(Qt::blue);
|
||||
}
|
||||
void Configuration::SetAccessMode(core::AccessMode::Types const& type)
|
||||
{
|
||||
core::OPMaps::Instance()->setAccessMode(type);
|
||||
}
|
||||
core::AccessMode::Types Configuration::AccessMode()
|
||||
{
|
||||
return core::OPMaps::Instance()->GetAccessMode();
|
||||
}
|
||||
void Configuration::SetLanguage(core::LanguageType::Types const& type)
|
||||
{
|
||||
core::OPMaps::Instance()->setLanguage(type);
|
||||
}
|
||||
core::LanguageType::Types Configuration::Language()
|
||||
{
|
||||
return core::OPMaps::Instance()->GetLanguage();
|
||||
}
|
31
ground/src/libs/opmapcontrol/src/mapwidget/configuration.h
Normal file
31
ground/src/libs/opmapcontrol/src/mapwidget/configuration.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef CONFIGURATION_H
|
||||
#define CONFIGURATION_H
|
||||
|
||||
#include <QBrush>
|
||||
#include <QPen>
|
||||
#include <QString>
|
||||
#include <QFont>
|
||||
#include "../core/opmaps.h"
|
||||
#include "../core/accessmode.h"
|
||||
class Configuration
|
||||
{
|
||||
public:
|
||||
Configuration();
|
||||
QBrush EmptytileBrush;
|
||||
QString EmptyTileText;
|
||||
QPen EmptyTileBorders;
|
||||
QPen ScalePen;
|
||||
QPen SelectionPen;
|
||||
QFont MissingDataFont;
|
||||
|
||||
void SetAccessMode(core::AccessMode::Types const& type);
|
||||
core::AccessMode::Types AccessMode();
|
||||
|
||||
void SetLanguage(core::LanguageType::Types const& type);
|
||||
core::LanguageType::Types Language();
|
||||
|
||||
void SetUseMemoryCache(bool const& value){core::OPMaps::Instance()->setUseMemoryCache(value);}
|
||||
bool UseMemoryCache(){return core::OPMaps::Instance()->UseMemoryCache();}
|
||||
};
|
||||
|
||||
#endif // CONFIGURATION_H
|
@ -1,16 +1,10 @@
|
||||
#include "mapgraphicitem.h"
|
||||
namespace mapcontrol
|
||||
{
|
||||
MapGraphicItem::MapGraphicItem(internals::Core *core):core(core),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false),rotation(0)
|
||||
MapGraphicItem::MapGraphicItem(internals::Core *core, Configuration *configuration):core(core),config(configuration),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false),rotation(0)
|
||||
{
|
||||
EmptytileBrush = Qt::cyan;
|
||||
MissingDataFont =QFont ("Times",10,QFont::Bold);
|
||||
EmptyTileText = "We are sorry, but we don't\nhave imagery at this zoom\nlevel for this region.";
|
||||
EmptyTileBorders = QPen(Qt::white);
|
||||
ScalePen = QPen(Qt::blue);
|
||||
SelectionPen = QPen(Qt::blue);
|
||||
MapScaleInfoEnabled = true;
|
||||
showTileGridLines=true;
|
||||
|
||||
showTileGridLines=false;
|
||||
DragButton = Qt::RightButton;
|
||||
isMouseOverMarker=false;
|
||||
maprect=QRectF(0,0,1022,680);
|
||||
@ -237,10 +231,10 @@ namespace mapcontrol
|
||||
|
||||
if(showTileGridLines)
|
||||
{
|
||||
painter->setPen(EmptyTileBorders);
|
||||
painter->setPen(config->EmptyTileBorders);
|
||||
painter->drawRect(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height());
|
||||
{
|
||||
painter->setFont(MissingDataFont);
|
||||
painter->setFont(config->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();
|
||||
@ -251,13 +245,13 @@ namespace mapcontrol
|
||||
if(!found)
|
||||
{
|
||||
|
||||
painter->fillRect(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),EmptytileBrush);
|
||||
painter->setFont(MissingDataFont);
|
||||
painter->drawText(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),EmptyTileText);
|
||||
painter->fillRect(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),config->EmptytileBrush);
|
||||
painter->setFont(config->MissingDataFont);
|
||||
painter->drawText(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),config->EmptyTileText);
|
||||
|
||||
|
||||
|
||||
painter->setPen(EmptyTileBorders);
|
||||
painter->setPen(config->EmptyTileBorders);
|
||||
painter->drawRect(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height());
|
||||
|
||||
// raise error
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include "../internals/core.h"
|
||||
#include "configuration.h"
|
||||
#include <QtGui>
|
||||
#include <QTransform>
|
||||
#include <QWidget>
|
||||
@ -17,7 +18,7 @@ class MapGraphicItem:public QObject,public QGraphicsItem
|
||||
friend class mapcontrol::OPMapWidget;
|
||||
Q_OBJECT
|
||||
public:
|
||||
MapGraphicItem(internals::Core *core);
|
||||
MapGraphicItem(internals::Core *core,Configuration *configuration);
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
@ -37,10 +38,13 @@ protected:
|
||||
|
||||
private:
|
||||
internals::Core *core;
|
||||
Configuration *config;
|
||||
bool showTileGridLines;
|
||||
qreal MapRenderTransform;
|
||||
void DrawMap2D(QPainter *painter);
|
||||
QFont MissingDataFont;
|
||||
///
|
||||
// QFont MissingDataFont;
|
||||
///
|
||||
int maxZoom;
|
||||
int minZoom;
|
||||
internals::RectLatLng selectedArea;
|
||||
@ -54,17 +58,18 @@ private:
|
||||
internals::PointLatLng FromLocalToLatLng(int x, int y);
|
||||
qreal rotation;
|
||||
QRectF boundingBox(QRectF const& rect, qreal const& angle);
|
||||
|
||||
QBrush EmptytileBrush;
|
||||
QString EmptyTileText;
|
||||
QPen EmptyTileBorders;
|
||||
QPen ScalePen;
|
||||
QPen SelectionPen;
|
||||
///
|
||||
// QBrush EmptytileBrush;
|
||||
// QString EmptyTileText;
|
||||
// QPen EmptyTileBorders;
|
||||
// QPen ScalePen;
|
||||
// QPen SelectionPen;
|
||||
///
|
||||
int MaxZoom()const{return maxZoom;}
|
||||
int MinZoom()const{return minZoom;}
|
||||
internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return core->GetMouseWheelZoomType();}
|
||||
QString GetMouseWheelZoomTypeStr(){return internals::MouseWheelZoomType::TypesStrList().at((int)core->GetMouseWheelZoomType());}
|
||||
bool MapScaleInfoEnabled;
|
||||
// QString GetMouseWheelZoomTypeStr(){return internals::MouseWheelZoomType::TypesStrList().at((int)core->GetMouseWheelZoomType());}
|
||||
// bool MapScaleInfoEnabled;
|
||||
Qt::MouseButton DragButton;
|
||||
void SetSelectedArea(internals::RectLatLng const& value){selectedArea = value;this->update();}
|
||||
internals::RectLatLng BoundsOfMap;
|
||||
|
@ -1,16 +1,19 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = opmapwidget
|
||||
DEFINES += OPMAPWIDGET_LIBRARY
|
||||
|
||||
include(../../../../openpilotgcslibrary.pri)
|
||||
|
||||
#DESTDIR = ../build
|
||||
SOURCES += mapgraphicitem.cpp \
|
||||
opmapwidget.cpp
|
||||
|
||||
LIBS += -L../build -lcore -linternals -lcore
|
||||
opmapwidget.cpp \
|
||||
configuration.cpp
|
||||
LIBS += -L../build \
|
||||
-lcore \
|
||||
-linternals \
|
||||
-lcore
|
||||
HEADERS += mapgraphicitem.h \
|
||||
opmapwidget.h
|
||||
|
||||
opmapwidget.h \
|
||||
configuration.h
|
||||
QT += opengl
|
||||
QT += network
|
||||
QT += sql
|
||||
|
@ -3,28 +3,45 @@
|
||||
#include <QMetaObject>
|
||||
namespace mapcontrol
|
||||
{
|
||||
OPMapWidget::OPMapWidget(QWidget *parent):QGraphicsView(parent),useOpenGL(false)
|
||||
// OPMapWidget::OPMapWidget(QWidget *parent):QGraphicsView(parent),useOpenGL(false)
|
||||
// {
|
||||
// setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
//
|
||||
// core=new internals::Core;
|
||||
// map=new MapGraphicItem(core);
|
||||
// //text.setZValue(20);
|
||||
// //QGraphicsTextItem *t=new QGraphicsTextItem(map);
|
||||
// // t->setPos(10,10);
|
||||
// mscene.addItem(map);
|
||||
// map->setZValue(-1);
|
||||
// //t->setZValue(10);
|
||||
// this->setScene(&mscene);
|
||||
// this->adjustSize();
|
||||
// // t->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||
// connect(&mscene,SIGNAL(sceneRectChanged(QRectF)),map,SLOT(resize(QRectF)));
|
||||
// connect(map,SIGNAL(zoomChanged(double)),this,SIGNAL(zoomChanged(double)));
|
||||
// }
|
||||
OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config):QGraphicsView(parent),configuration(config)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
|
||||
core=new internals::Core;
|
||||
map=new MapGraphicItem(core);
|
||||
//text.setZValue(20);
|
||||
//QGraphicsTextItem *t=new QGraphicsTextItem(map);
|
||||
// t->setPos(10,10);
|
||||
map=new MapGraphicItem(core,config);
|
||||
mscene.addItem(map);
|
||||
map->setZValue(-1);
|
||||
//t->setZValue(10);
|
||||
this->setScene(&mscene);
|
||||
this->adjustSize();
|
||||
// t->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||
connect(&mscene,SIGNAL(sceneRectChanged(QRectF)),map,SLOT(resize(QRectF)));
|
||||
connect(map,SIGNAL(zoomChanged(double)),this,SIGNAL(zoomChanged(double)));
|
||||
QMetaObject metaObject = this->staticMetaObject;
|
||||
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("internals::MouseWheelZoomType::Types"));
|
||||
QString s=metaEnum.valueToKey(1);
|
||||
QString ss=s;
|
||||
connect(map->core,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)),this,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)));
|
||||
connect(map->core,SIGNAL(OnEmptyTileError(int,core::Point)),this,SIGNAL(OnEmptyTileError(int,core::Point)));
|
||||
connect(map->core,SIGNAL(OnMapDrag()),this,SIGNAL(OnMapDrag()));
|
||||
connect(map->core,SIGNAL(OnMapTypeChanged(MapType::Types)),this,SIGNAL(OnMapTypeChanged(MapType::Types)));
|
||||
connect(map->core,SIGNAL(OnMapZoomChanged()),this,SIGNAL(OnMapZoomChanged()));
|
||||
connect(map->core,SIGNAL(OnTileLoadComplete()),this,SIGNAL(OnTileLoadComplete()));
|
||||
connect(map->core,SIGNAL(OnTileLoadStart()),this,SIGNAL(OnTileLoadStart()));
|
||||
connect(map->core,SIGNAL(OnTilesStillToLoad(int)),this,SIGNAL(OnTilesStillToLoad(int)));
|
||||
}
|
||||
|
||||
void OPMapWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
if (scene())
|
||||
@ -45,6 +62,7 @@ namespace mapcontrol
|
||||
{
|
||||
delete map;
|
||||
delete core;
|
||||
delete configuration;
|
||||
}
|
||||
void OPMapWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
|
@ -4,7 +4,8 @@
|
||||
#include "../mapwidget/mapgraphicitem.h"
|
||||
#include "../core/geodecoderstatus.h"
|
||||
#include "../core/maptype.h"
|
||||
|
||||
#include "../core/languagetype.h"
|
||||
#include "configuration.h"
|
||||
#include <QObject>
|
||||
#include <QtOpenGL/QGLWidget>
|
||||
namespace mapcontrol
|
||||
@ -15,8 +16,23 @@ namespace mapcontrol
|
||||
static MapType::Types MapTypeFromString(QString const& value){return MapType::TypeByStr(value);}
|
||||
static QString StrFromMapType(MapType::Types const& value){return MapType::StrByType(value);}
|
||||
static QStringList MapTypes(){return MapType::TypesList();}
|
||||
|
||||
static GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const& value){return GeoCoderStatusCode::TypeByStr(value);}
|
||||
static QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const& value){return GeoCoderStatusCode::StrByType(value);}
|
||||
static QStringList GeoCoderTypes(){return GeoCoderStatusCode::TypesList();}
|
||||
|
||||
|
||||
static internals::MouseWheelZoomType::Types MouseWheelZoomTypeFromString(QString const& value){return internals::MouseWheelZoomType::TypeByStr(value);}
|
||||
static QString StrFromMouseWheelZoomType(internals::MouseWheelZoomType::Types const& value){return internals::MouseWheelZoomType::StrByType(value);}
|
||||
static QStringList MouseWheelZoomTypes(){return internals::MouseWheelZoomType::TypesList();}
|
||||
|
||||
static core::LanguageType::Types LanguageTypeFromString(QString const& value){return core::LanguageType::TypeByStr(value);}
|
||||
static QString StrFromLanguageType(core::LanguageType::Types const& value){return core::LanguageType::StrByType(value);}
|
||||
static QStringList LanguageTypes(){return core::LanguageType::TypesList();}
|
||||
|
||||
static core::AccessMode::Types AccessModeFromString(QString const& value){return core::AccessMode::TypeByStr(value);}
|
||||
static QString StrFromAccessMode(core::AccessMode::Types const& value){return core::AccessMode::StrByType(value);}
|
||||
static QStringList AccessModeTypes(){return core::AccessMode::TypesList();}
|
||||
};
|
||||
|
||||
class OPMapWidget:public QGraphicsView
|
||||
@ -25,47 +41,62 @@ namespace mapcontrol
|
||||
|
||||
Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
|
||||
Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
|
||||
Q_PROPERTY(internals::MouseWheelZoomType::Types MouseWheelZoom READ GetMouseWheelZoomType WRITE SetMouseWheelZoomType)
|
||||
Q_PROPERTY(QString MouseWheelZoomStr READ GetMouseWheelZoomTypeStr WRITE SetMouseWheelZoomTypeByStr)
|
||||
// Q_PROPERTY(internals::MouseWheelZoomType::Types MouseWheelZoom READ GetMouseWheelZoomType WRITE SetMouseWheelZoomType)
|
||||
// Q_PROPERTY(QString MouseWheelZoomStr READ GetMouseWheelZoomTypeStr WRITE SetMouseWheelZoomTypeByStr)
|
||||
Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
|
||||
Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom)
|
||||
Q_PROPERTY(qreal Rotate READ Rotate WRITE SetRotate)
|
||||
Q_ENUMS(internals::MouseWheelZoomType::Types)
|
||||
Q_ENUMS(internals::GeoCoderStatusCode::Types)
|
||||
|
||||
public:
|
||||
// GeoCoderStatusCode x;
|
||||
// MapType y;
|
||||
QSize sizeHint() const;
|
||||
OPMapWidget(QWidget *parent=0);
|
||||
OPMapWidget(QWidget *parent=0,Configuration *config=new Configuration);
|
||||
~OPMapWidget();
|
||||
|
||||
bool ShowTileGridLines()const {return map->showTileGridLines;}
|
||||
void SetShowTileGridLines(bool const& value){map->showTileGridLines=value;map->update();}
|
||||
|
||||
int MaxZoom()const{return map->maxZoom;}
|
||||
void SetMaxZoom(int const& value){map->maxZoom = value;}
|
||||
|
||||
int MinZoom()const{return map->minZoom;}
|
||||
void SetMinZoom(int const& value){map->minZoom = value;}
|
||||
|
||||
internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return map->core->GetMouseWheelZoomType();}
|
||||
void SetMouseWheelZoomType(internals::MouseWheelZoomType::Types const& value){map->core->SetMouseWheelZoomType(value);}
|
||||
void SetMouseWheelZoomTypeByStr(const QString &value){map->core->SetMouseWheelZoomType(internals::MouseWheelZoomType::TypeByStr(value));}
|
||||
QString GetMouseWheelZoomTypeStr(){return map->GetMouseWheelZoomTypeStr();}
|
||||
// void SetMouseWheelZoomTypeByStr(const QString &value){map->core->SetMouseWheelZoomType(internals::MouseWheelZoomType::TypeByStr(value));}
|
||||
// QString GetMouseWheelZoomTypeStr(){return map->GetMouseWheelZoomTypeStr();}
|
||||
|
||||
internals::RectLatLng SelectedArea()const{return map->selectedArea;}
|
||||
void SetSelectedArea(internals::RectLatLng const& value){ map->selectedArea = value;this->update();}
|
||||
|
||||
bool CanDragMap()const{return map->CanDragMap();}
|
||||
void SetCanDragMap(bool const& value){map->SetCanDragMap(value);}
|
||||
|
||||
internals::PointLatLng CurrentPosition()const{return map->core->CurrentPosition();}
|
||||
void SetCurrentPosition(internals::PointLatLng const& value){map->core->SetCurrentPosition(value);}
|
||||
|
||||
double Zoom(){return map->Zoom();}
|
||||
void SetZoom(double const& value){map->SetZoom(value);}
|
||||
|
||||
qreal Rotate(){return map->rotation;}
|
||||
void SetRotate(qreal const& value){map->mapRotate(value);}
|
||||
void ReloadMap(){map->ReloadMap(); map->resize();;}
|
||||
|
||||
void ReloadMap(){map->ReloadMap(); map->resize();}
|
||||
|
||||
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return map->SetCurrentPositionByKeywords(keys);}
|
||||
|
||||
bool UseOpenGL(){return useOpenGL;}
|
||||
void SetUseOpenGL(bool const& value);
|
||||
|
||||
MapType::Types GetMapType(){return map->core->GetMapType();}
|
||||
void SetMapType(MapType::Types const& value){map->core->SetMapType(value);}
|
||||
|
||||
bool isStarted(){return map->core->isStarted();}
|
||||
void X(){map->core->GoToCurrentPosition();}
|
||||
|
||||
Configuration* configuration;
|
||||
|
||||
private:
|
||||
internals::Core *core;
|
||||
MapGraphicItem *map;
|
||||
@ -73,6 +104,9 @@ namespace mapcontrol
|
||||
bool useOpenGL;
|
||||
GeoCoderStatusCode x;
|
||||
MapType y;
|
||||
core::AccessMode xx;
|
||||
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void showEvent ( QShowEvent * event );
|
||||
@ -80,7 +114,15 @@ namespace mapcontrol
|
||||
// private slots:
|
||||
signals:
|
||||
void zoomChanged(double zoom);
|
||||
|
||||
signals:
|
||||
void OnCurrentPositionChanged(internals::PointLatLng point);
|
||||
void OnTileLoadComplete();
|
||||
void OnTileLoadStart();
|
||||
void OnMapDrag();
|
||||
void OnMapZoomChanged();
|
||||
void OnMapTypeChanged(MapType::Types type);
|
||||
void OnEmptyTileError(int zoom, core::Point pos);
|
||||
void OnTilesStillToLoad(int number);
|
||||
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user