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

OP-37 GCS/MapPlugin changed graphic implementation. Map is now a QGraphicsItem, Widget is a QGraphicsView.

Rotation of map working, rotation keeps map centered. 

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@728 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-06-08 17:59:29 +00:00 committed by zedamota
parent 6268ba26a1
commit a32bced9fc
10 changed files with 597 additions and 50 deletions

View File

@ -57,6 +57,7 @@
namespace mapcontrol
{
class OPMapControl;
class MapGraphicItem;
}
namespace internals {
@ -64,6 +65,7 @@ class Core:public QObject,public QRunnable
{
Q_OBJECT
friend class mapcontrol::OPMapControl;
friend class mapcontrol::MapGraphicItem;
public:
Core();
void run();

View File

@ -0,0 +1,362 @@
#include "mapgraphicitem.h"
namespace mapcontrol
{
MapGraphicItem::MapGraphicItem(Core *core):core(core),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false)
{
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;
DragButton = Qt::RightButton;
isMouseOverMarker=false;
maprect=QRectF(0,0,1022,680);
core->SetCurrentRegion(Rectangle(0, 0, maprect.width(), maprect.height()));
core->SetMapType(MapType::GoogleHybrid);
this->SetZoom(2);
connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
core->StartSystem();
//resize();
}
void MapGraphicItem::resize(const QRectF &rect)
{
if(rotation!=0)
{
maprect=boundingBox(scene()->sceneRect(),rotation);
this->setTransform(QTransform().translate(-(maprect.width()-scene()->width())/2,-(maprect.height()-scene()->height())/2));
this->setTransformOriginPoint(maprect.center().x(),maprect.center().y());
this->setRotation(rotation);
}
else
maprect=rect;
core->OnMapSizeChanged(maprect.width(),maprect.height());
core->SetCurrentRegion(Rectangle(0, 0, maprect.width(), maprect.height()));
if(isVisible())
{
core->GoToCurrentPosition();
}
}
QRectF MapGraphicItem::boundingRect() const
{
const int Margin = 1;
return maprect.adjusted(-Margin, -Margin, +Margin, +Margin);
}
void MapGraphicItem::Core_OnNeedInvalidation()
{
this->update();
}
void MapGraphicItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if(MapRenderTransform!=1)
{
QTransform transform;
transform.scale(MapRenderTransform,MapRenderTransform);
painter->setWorldTransform(transform);
{
DrawMap2D(painter);
}
painter->resetTransform();
}
else
{
DrawMap2D(painter);
}
painter->drawRect(maprect);
}
void MapGraphicItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if(core->IsDragging())
{
core->mouseCurrent.SetX(event->pos().x());
core->mouseCurrent.SetY(event->pos().y());
{
core->Drag(core->mouseCurrent);
}
}
}
void MapGraphicItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if(!IsMouseOverMarker())
{
if(event->button() == DragButton && CanDragMap())
{
core->mouseDown.SetX(event->pos().x());
core->mouseDown.SetY(event->pos().y());
this->setCursor(Qt::SizeAllCursor);
core->BeginDrag(core->mouseDown);
this->update();
}
else if(!isSelected)
{
isSelected = true;
SetSelectedArea (RectLatLng::Empty);
selectionEnd = PointLatLng::Empty;
selectionStart = FromLocalToLatLng(event->pos().x(), event->pos().y());
}
}
}
void MapGraphicItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if(isSelected)
{
isSelected = false;
}
if(core->IsDragging())
{
core->EndDrag();
this->setCursor(Qt::ArrowCursor);
if(!BoundsOfMap.IsEmpty() && !BoundsOfMap.Contains(core->CurrentPosition()))
{
if(!core->LastLocationInBounds.IsEmpty())
{
core->SetCurrentPosition(core->LastLocationInBounds);
}
}
}
else
{
if(!selectionEnd.IsEmpty() && !selectionStart.IsEmpty())
{
if(!selectedArea.IsEmpty() && event->modifiers() == Qt::ShiftModifier)
{
// SetZoomToFitRect(SelectedArea());TODO
}
}
}
}
void MapGraphicItem::wheelEvent(QGraphicsSceneWheelEvent *event)
{
if(!IsMouseOverMarker() && !IsDragging())
{
if(core->GetmouseLastZoom().X() != event->pos().x() && core->mouseLastZoom.Y() != event->pos().y())
{
if(GetMouseWheelZoomType() == MouseWheelZoomType::MousePositionAndCenter)
{
core->SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
}
else if(GetMouseWheelZoomType() == MouseWheelZoomType::ViewCenter)
{
core->SetCurrentPosition(FromLocalToLatLng((int) maprect.width()/2, (int) maprect.height()/2));
}
else if(GetMouseWheelZoomType() == MouseWheelZoomType::MousePositionWithoutCenter)
{
core->SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
}
core->mouseLastZoom.SetX((event->pos().x()));
core->mouseLastZoom.SetY((event->pos().y()));
}
// set mouse position to map center
if(GetMouseWheelZoomType() != MouseWheelZoomType::MousePositionWithoutCenter)
{
{
// System.Drawing.Point p = PointToScreen(new System.Drawing.Point(Width/2, Height/2));
// Stuff.SetCursorPos((int) p.X, (int) p.Y);
}
}
core->MouseWheelZooming = true;
if(event->delta() > 0)
{
SetZoom(Zoom()+1);
}
else if(event->delta() < 0)
{
SetZoom(Zoom()-1);
}
core->MouseWheelZooming = false;
}
}
void MapGraphicItem::DrawMap2D(QPainter *painter)
{
// qDebug()<<core->Matrix.count();
// 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++)
{
core->SettilePoint (core->GetcenterTileXYLocation());
core->SettilePoint(Point(core->GettilePoint().X()+ i,core->GettilePoint().Y()+j));
{
Tile* t = core->Matrix.TileAt(core->GettilePoint());
//qDebug()<<"OPMapControl::DrawMap2D tile:"<<t->GetPos().ToString()<<" as "<<t->Overlays.count()<<" overlays";
//Tile t = core->Matrix[tileToDraw];
if(t!=0)
{
//qDebug()<< "opmapcontrol:draw2d TileHasValue:"<<t->GetPos().ToString();
core->tileRect.SetX(core->GettilePoint().X()*core->tileRect.Width());
core->tileRect.SetY(core->GettilePoint().Y()*core->tileRect.Height());
core->tileRect.Offset(core->GetrenderOffset());
if(core->GetCurrentRegion().IntersectsWith(core->tileRect))
{
bool found = false;
// render tile
//lock(t.Overlays)
{
foreach(QByteArray img,t->Overlays)
{
if(img.count()!=0)
{
if(!found)
found = true;
{
painter->drawPixmap(core->tileRect.X(),core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height(),PureImageProxy::FromStream(img));
}
}
}
}
if(showTileGridLines)
{
painter->setPen(EmptyTileBorders);
painter->drawRect(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height());
{
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();
}
}
// add text if tile is missing
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->setPen(EmptyTileBorders);
painter->drawRect(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height());
// raise error
}
}
}
}
}
}
}
PointLatLng MapGraphicItem::FromLocalToLatLng(int x, int y)
{
if(MapRenderTransform!=-1)
{
x = (int) (x * MapRenderTransform);
y = (int) (y * MapRenderTransform);
}
return core->FromLocalToLatLng(x, y);
}
double MapGraphicItem::Zoom()
{
return zoomReal;
}
void MapGraphicItem::SetZoom(double const& value)
{
if(zoomReal != value)
{
if(value > MaxZoom())
{
zoomReal = MaxZoom();
}
else
if(value < MinZoom())
{
zoomReal = MinZoom();
}
else
{
zoomReal = value;
}
float remainder = (float)std::fmod((float) value, (float) 1);
if(remainder != 0)
{
float scaleValue = remainder + 1;
{
MapRenderTransform = scaleValue;
}
SetZoomStep((qint32)(value - remainder));
this->update();
}
else
{
MapRenderTransform = 1;
SetZoomStep ((qint32)(value));
zoomReal = ZoomStep();
this->update();
}
}
}
int MapGraphicItem::ZoomStep()const
{
return core->Zoom();
}
void MapGraphicItem::SetZoomStep(int const& value)
{
if(value > MaxZoom())
{
core->SetZoom(MaxZoom());
}
else if(value < MinZoom())
{
core->SetZoom(MinZoom());
}
else
{
core->SetZoom(value);
}
}
void MapGraphicItem::Offset(int const& x, int const& y)
{
core->DragOffset(Point(x, y));
}
void MapGraphicItem::mapRotate(qreal angle)
{
rotation=angle;
resize(scene()->sceneRect());
}
QRectF MapGraphicItem::boundingBox(const QRectF &rect, const qreal &angle)
{
QRectF ret(rect);
float c=cos(angle*2*M_PI/360);
float s=sin(angle*2*M_PI/360);
ret.setHeight(rect.height()*fabs(c)+rect.width()*fabs(s));
ret.setWidth(rect.width()*fabs(c)+rect.height()*fabs(s));
return ret;
}
}

View File

@ -0,0 +1,83 @@
#ifndef MAPGRAPHICITEM_H
#define MAPGRAPHICITEM_H
#include <QGraphicsItem>
#include "../internals/core.h"
#include <QtGui>
#include <QTransform>
#include <QWidget>
#include <QBrush>
#include <QFont>
#include <QObject>
namespace mapcontrol
{
class OPMapWidget;
class MapGraphicItem:public QObject,public QGraphicsItem
{
friend class mapcontrol::OPMapWidget;
Q_OBJECT
public:
MapGraphicItem(Core *core);
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
protected:
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
void wheelEvent ( QGraphicsSceneWheelEvent * event );
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
bool IsMouseOverMarker()const{return isMouseOverMarker;}
bool IsDragging()const{return core->IsDragging();}
int ZoomStep()const;
void SetZoomStep(int const& value);
private:
Core *core;
bool showTileGridLines;
qreal MapRenderTransform;
void DrawMap2D(QPainter *painter);
QFont MissingDataFont;
int maxZoom;
int minZoom;
RectLatLng selectedArea;
PointLatLng selectionStart;
PointLatLng selectionEnd;
double zoomReal;
QRectF maprect;
bool isSelected;
bool isMouseOverMarker;
void SetIsMouseOverMarker(bool const& value){isMouseOverMarker = value;}
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;
int MaxZoom()const{return maxZoom;}
int MinZoom()const{return minZoom;}
MouseWheelZoomType::Types GetMouseWheelZoomType(){return core->GetMouseWheelZoomType();}
QString GetMouseWheelZoomTypeStr(){return MouseWheelZoomType::TypesStrList().at((int)core->GetMouseWheelZoomType());}
bool MapScaleInfoEnabled;
Qt::MouseButton DragButton;
void SetSelectedArea(RectLatLng const& value){selectedArea = value;this->update();}
RectLatLng BoundsOfMap;
void Offset(int const& x, int const& y);
bool CanDragMap()const{return core->CanDragMap;}
void SetCanDragMap(bool const& value){core->CanDragMap = value;}
double Zoom();
void SetZoom(double const& value);
void mapRotate ( qreal angle );
private slots:
void Core_OnNeedInvalidation();
public slots:
void resize ( QRectF const &rect );
};
}
#endif // MAPGRAPHICITEM_H

View File

@ -1,6 +1,10 @@
include (../common.pri)
SOURCES += opmapcontrol.cpp
SOURCES += opmapcontrol.cpp \
mapgraphicitem.cpp \
opmapwidget.cpp
LIBS += -L../build \
-lcore \
-linternals
HEADERS += opmapcontrol.h
HEADERS += opmapcontrol.h \
mapgraphicitem.h \
opmapwidget.h

View File

@ -1,4 +1,5 @@
#include "opmapcontrol.h"
#include <QImage>
namespace mapcontrol
{
OPMapControl::OPMapControl(QWidget *parent):QWidget(parent),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false)
@ -14,7 +15,7 @@ OPMapControl::OPMapControl(QWidget *parent):QWidget(parent),MapRenderTransform(1
DragButton = Qt::RightButton;
isMouseOverMarker=false;
core.SetCurrentRegion(Rectangle(-50, -50, this->width()+100, this->height()+100));
core.SetMapType(MapType::OpenStreetMap);
core.SetMapType(MapType::GoogleHybrid);
core.SetZoom(3);
connect(&core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
@ -94,7 +95,7 @@ void OPMapControl::DrawMap2D(QPainter &painter)
if(!found)
found = true;
{
painter.drawPixmap(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height(),PureImageProxy::FromStream(img));
painter.drawImage(QRectF(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height()),QImage::fromData(img));
}
}
@ -140,7 +141,7 @@ void OPMapControl::mousePressEvent ( QMouseEvent* evnt )
{
if(!IsMouseOverMarker())
{
if(evnt->button() == DragButton && CanDragMap())
if(evnt->button() == DragButton && core.CanDragMap)
{
core.mouseDown.SetX(evnt->x());
core.mouseDown.SetY(evnt->y());
@ -186,11 +187,11 @@ void OPMapControl::mouseReleaseEvent ( QMouseEvent* evnt )
core.EndDrag();
this->setCursor(Qt::ArrowCursor);
if(!BoundsOfMap.IsEmpty() && !BoundsOfMap.Contains(CurrentPosition()))
if(!BoundsOfMap.IsEmpty() && !BoundsOfMap.Contains(core.CurrentPosition()))
{
if(!core.LastLocationInBounds.IsEmpty())
{
SetCurrentPosition(core.LastLocationInBounds);
core.SetCurrentPosition(core.LastLocationInBounds);
}
}
}
@ -198,7 +199,7 @@ void OPMapControl::mouseReleaseEvent ( QMouseEvent* evnt )
{
if(!selectionEnd.IsEmpty() && !selectionStart.IsEmpty())
{
if(!SelectedArea().IsEmpty() && evnt->modifiers() == Qt::ShiftModifier)
if(!selectedArea.IsEmpty() && evnt->modifiers() == Qt::ShiftModifier)
{
// SetZoomToFitRect(SelectedArea());TODO
}

View File

@ -18,43 +18,18 @@ class internals::Core;
class OPMapControl:public QWidget
{
Q_OBJECT
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(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom)
// 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(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
// Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom)
public:
OPMapControl(QWidget *parent=0);
QBrush EmptytileBrush;
QString EmptyTileText;
QPen EmptyTileBorders;
QPen ScalePen;
QPen SelectionPen;
bool ShowTileGridLines()const {return showTileGridLines;}
void SetShowTileGridLines(bool const& value){showTileGridLines=value;this->repaint();}
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());}
bool MapScaleInfoEnabled;
Qt::MouseButton DragButton;
RectLatLng SelectedArea()const{return selectedArea;}
void SetSelectedArea(RectLatLng const& value){selectedArea = value;this->repaint();}
RectLatLng BoundsOfMap;
void Offset(int const& x, int const& y);
bool CanDragMap()const{return core.CanDragMap;}
void SetCanDragMap(bool const& value){core.CanDragMap = value;}
PointLatLng CurrentPosition()const{return core.CurrentPosition();}
void SetCurrentPosition(PointLatLng const& value){core.SetCurrentPosition(value);}
double Zoom();
void SetZoom(double const& value);
protected:
void paintEvent ( QPaintEvent* evnt );
void mousePressEvent ( QMouseEvent* evnt );
@ -69,6 +44,33 @@ protected:
int ZoomStep()const;
void SetZoomStep(int const& value);
private:
QBrush EmptytileBrush;
QString EmptyTileText;
QPen EmptyTileBorders;
QPen ScalePen;
QPen SelectionPen;
// bool ShowTileGridLines()const {return showTileGridLines;}
// void SetShowTileGridLines(bool const& value){showTileGridLines=value;this->repaint();}
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());}
bool MapScaleInfoEnabled;
Qt::MouseButton DragButton;
// RectLatLng SelectedArea()const{return selectedArea;}
void SetSelectedArea(RectLatLng const& value){selectedArea = value;this->update();}
RectLatLng BoundsOfMap;
void Offset(int const& x, int const& y);
bool CanDragMap()const{return core.CanDragMap;}
void SetCanDragMap(bool const& value){core.CanDragMap = value;}
// PointLatLng CurrentPosition()const{return core.CurrentPosition();}
// void SetCurrentPosition(PointLatLng const& value){core.SetCurrentPosition(value);}
double Zoom();
void SetZoom(double const& value);
bool showTileGridLines;
Core core;
qreal MapRenderTransform;

View File

@ -0,0 +1,28 @@
#include "opmapwidget.h"
#include <QtGui>
namespace mapcontrol
{
OPMapWidget::OPMapWidget(QWidget *parent):QGraphicsView(parent)
{
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)));
}
void OPMapWidget::resizeEvent(QResizeEvent *event)
{
if (scene())
scene()->setSceneRect(
QRect(QPoint(0, 0), event->size()));
QGraphicsView::resizeEvent(event);
}
}

View File

@ -0,0 +1,51 @@
#ifndef OPMAPWIDGET_H
#define OPMAPWIDGET_H
#include "../mapwidget/mapgraphicitem.h"
#include <QObject>
namespace mapcontrol
{
class OPMapWidget:public QGraphicsView
{
Q_OBJECT
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(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom)
Q_PROPERTY(qreal Rotate READ Rotate WRITE SetRotate)
public:
OPMapWidget(QWidget *parent=0);
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;}
MouseWheelZoomType::Types GetMouseWheelZoomType(){return map->core->GetMouseWheelZoomType();}
void SetMouseWheelZoomType(MouseWheelZoomType::Types const& value){map->core->SetMouseWheelZoomType(value);}
void SetMouseWheelZoomTypeByStr(const QString &value){map->core->SetMouseWheelZoomType(MouseWheelZoomType::TypeByStr(value));}
QString GetMouseWheelZoomTypeStr(){return map->GetMouseWheelZoomTypeStr();}
RectLatLng SelectedArea()const{return map->selectedArea;}
void SetSelectedArea(RectLatLng const& value){ map->selectedArea = value;this->update();}
bool CanDragMap()const{return map->CanDragMap();}
void SetCanDragMap(bool const& value){map->SetCanDragMap(value);}
PointLatLng CurrentPosition()const{return map->core->CurrentPosition();}
void SetCurrentPosition(PointLatLng const& value){map->core->SetCurrentPosition(value);}
double Zoom(){map->Zoom();}
void SetZoom(double const& value){map->SetZoom(value);}
qreal Rotate(){return map->rotation;}
void SetRotate(qreal const& value){return map->mapRotate(value);}
private:
internals::Core *core;
MapGraphicItem *map;
QGraphicsScene mscene;
protected:
void resizeEvent(QResizeEvent *event);
// private slots:
};
}
#endif // OPMAPWIDGET_H

View File

@ -2,19 +2,32 @@
#include <QApplication>
//#include "map.h"
#include "../mapwidget/opmapcontrol.h"
//#include "../mapwidget/opmapcontrol.h"
//#include "../mapwidget/mapgraphicitem.h"
#include "../mapwidget/opmapwidget.h"
#include <QGLWidget>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// map * mw = new map();
// mw->resize(400,590);
// mw->setWindowTitle("Map");
// mw->adjustSize();
// mw->show();1022 680
mapcontrol::OPMapControl map;
map.setGeometry(20,20,1022,680);
map.show();
// mapcontrol::OPMapControl map;
// map.setGeometry(20,20,1022,680);
// map.show();
// QGraphicsScene scene;
// internals::Core *c=new internals::Core;
// mapcontrol::MapGraphicItem *mapi=new mapcontrol::MapGraphicItem(c);
// scene.addItem(mapi);
// QGraphicsView view(&scene);
// view.setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
// view.setRenderHints(QPainter::Antialiasing
// | QPainter::TextAntialiasing);
//
// mapi->rotate(10);
// view.show();
mapcontrol::OPMapWidget *map=new mapcontrol::OPMapWidget();
map->show();
return app.exec();
}

View File

@ -3,6 +3,7 @@ PROJECT = gettilestest
TEMPLATE = app
QT += network
QT += sql
QT += opengl
CONFIG += console
CONFIG -= app_bundle
DEPENDPATH += .