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

OP-37 GCS/MapPlugin Gave up from Designer integration, deleted related files.

QT Creator windows binaries are compiled with MSVC and the plugin would not be compatible when built with mingw so I opted not to go down that road.
Current test project is "finaltest".
Zoom, Pan, Rotate, OpenGL choice, geodecoding, map reloading... all working. 

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@752 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-06-12 20:27:33 +00:00 committed by zedamota
parent 511278ec5b
commit 5f78ee2f1c
22 changed files with 802 additions and 39 deletions

View File

@ -1,9 +1,10 @@
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = core
SUBDIRS += internals
SUBDIRS += mapwidget
CONFIG += ordered
SUBDIRS +=teste
SUBDIRS +=gettilestest
SUBDIRS +=widgettest
#SUBDIRS +=teste
#SUBDIRS +=gettilestest
#SUBDIRS +=widgettest
#SUBDIRS +=opmapplugin
SUBDIRS+=finaltest

View File

@ -7,7 +7,8 @@ WARNINGS += -Wall
# CONFIG += console
# CONFIG -= app_bundle
CONFIG += dll
#CONFIG += dll
CONFIG += staticlib
TEMPLATE = lib
UI_DIR = uics
MOC_DIR = mocs

View File

@ -28,10 +28,15 @@
#ifndef GEODECODERSTATUS_H
#define GEODECODERSTATUS_H
#include <QObject>
#include <QMetaObject>
#include <QMetaEnum>
namespace core {
struct GeoCoderStatusCode
class GeoCoderStatusCode:public QObject
{
Q_OBJECT
Q_ENUMS(Types)
public:
enum Types
{
/// <summary>
@ -95,7 +100,21 @@ struct GeoCoderStatusCode
G_GEO_TOO_MANY_QUERIES=620,
};
};
static QString StrByType(Types const& value)
{
QMetaObject metaObject = GeoCoderStatusCode().staticMetaObject;
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
QString s=metaEnum.valueToKey(value);
return s;
}
static Types TypeByStr(QString const& value)
{
QMetaObject metaObject = GeoCoderStatusCode().staticMetaObject;
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
Types s=(Types)metaEnum.keyToValue(value.toLatin1());
return s;
}
};
}
#endif // GEODECODERSTATUS_H

View File

@ -0,0 +1,20 @@
#-------------------------------------------------
#
# Project created by QtCreator 2010-06-11T10:37:33
#
#-------------------------------------------------
TARGET = finaltest
TEMPLATE = app
DESTDIR = ../build
QT += network
QT += sql
QT += opengl
LIBS += -L../build \
-lmapwidget
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui

View File

@ -0,0 +1,10 @@
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

View File

@ -0,0 +1,88 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
map=new mapcontrol::OPMapWidget();
QHBoxLayout *layout=new QHBoxLayout(parent);
layout->addWidget(map);
layout->addWidget(ui->widget);
ui->centralWidget->setLayout(layout);
connect(map,SIGNAL(zoomChanged(double)),this,SLOT(zoomChanged(double)));
}
MainWindow::~MainWindow()
{
delete ui;
delete map;
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void MainWindow::on_pushButtonZoomP_clicked()
{
double x,y;
x=map->Zoom();
y=ui->doubleSpinBox->value();
map->SetZoom(map->Zoom()+ui->doubleSpinBox->value());
}
void MainWindow::on_pushButtonZoomM_clicked()
{
map->SetZoom(map->Zoom()-ui->doubleSpinBox->value());
}
void MainWindow::on_checkBox_clicked(bool checked)
{
map->SetShowTileGridLines(checked);
}
void MainWindow::zoomChanged(double zoom)
{
ui->label_5->setText("CurrentZoom="+QString::number(zoom));
}
void MainWindow::on_pushButtonRL_clicked()
{
map->SetRotate(map->Rotate()-1);
}
void MainWindow::on_pushButtonRC_clicked()
{
map->SetRotate(0);
}
void MainWindow::on_pushButtonRR_clicked()
{
map->SetRotate(map->Rotate()+1);
}
void MainWindow::on_pushButton_clicked()
{
map->ReloadMap();
}
void MainWindow::on_pushButtonGO_clicked()
{
core::GeoCoderStatusCode::Types x=map->SetCurrentPositionByKeywords(ui->lineEdit->text());
ui->label->setText( map->geodecoderstatus.StrByType(x));
}
void MainWindow::on_checkBox_2_clicked(bool checked)
{
map->SetUseOpenGL(checked);
}

View File

@ -0,0 +1,36 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "../mapwidget/opmapwidget.h"
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
void changeEvent(QEvent *e);
private:
Ui::MainWindow *ui;
mapcontrol::OPMapWidget *map;
private slots:
void on_checkBox_2_clicked(bool checked);
void on_pushButtonGO_clicked();
void on_pushButton_clicked();
void on_pushButtonRR_clicked();
void on_pushButtonRC_clicked();
void on_pushButtonRL_clicked();
void on_checkBox_clicked(bool checked);
void on_pushButtonZoomM_clicked();
void on_pushButtonZoomP_clicked();
void zoomChanged(double zoom);
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,229 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>524</width>
<height>496</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>110</x>
<y>15</y>
<width>181</width>
<height>421</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>10</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>181</width>
<height>16777215</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Goto Place</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QPushButton" name="pushButtonGO">
<property name="text">
<string>GO</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>GeoCoderStatusCode</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Rotate</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButtonRL">
<property name="text">
<string>Left</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonRC">
<property name="text">
<string>Center</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonRR">
<property name="text">
<string>Right</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Zoom</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="pushButtonZoomP">
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonZoomM">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>ZoomIncrement</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox">
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>CurrentZoom=</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Misc</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>ShowGridLines</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>UseOpenGL</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>ReloadMap</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>524</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,271 @@
/********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
** Created: Sat 12. Jun 21:18:37 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QCheckBox>
#include <QtGui/QDoubleSpinBox>
#include <QtGui/QGroupBox>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QStatusBar>
#include <QtGui/QToolBar>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QWidget *centralWidget;
QWidget *widget;
QVBoxLayout *verticalLayout_4;
QVBoxLayout *verticalLayout_3;
QGroupBox *groupBox;
QVBoxLayout *verticalLayout_6;
QVBoxLayout *verticalLayout_5;
QLineEdit *lineEdit;
QPushButton *pushButtonGO;
QLabel *label;
QGroupBox *groupBox_2;
QHBoxLayout *horizontalLayout;
QPushButton *pushButtonRL;
QPushButton *pushButtonRC;
QPushButton *pushButtonRR;
QGroupBox *groupBox_3;
QVBoxLayout *verticalLayout;
QHBoxLayout *horizontalLayout_3;
QPushButton *pushButtonZoomP;
QPushButton *pushButtonZoomM;
QVBoxLayout *verticalLayout_2;
QLabel *label_4;
QDoubleSpinBox *doubleSpinBox;
QLabel *label_5;
QGroupBox *groupBox_4;
QVBoxLayout *verticalLayout_7;
QCheckBox *checkBox;
QCheckBox *checkBox_2;
QPushButton *pushButton;
QMenuBar *menuBar;
QToolBar *mainToolBar;
QStatusBar *statusBar;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(524, 496);
centralWidget = new QWidget(MainWindow);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
widget = new QWidget(centralWidget);
widget->setObjectName(QString::fromUtf8("widget"));
widget->setGeometry(QRect(110, 15, 181, 421));
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(10);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(widget->sizePolicy().hasHeightForWidth());
widget->setSizePolicy(sizePolicy);
widget->setMaximumSize(QSize(181, 16777215));
verticalLayout_4 = new QVBoxLayout(widget);
verticalLayout_4->setSpacing(0);
verticalLayout_4->setContentsMargins(0, 0, 0, 0);
verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4"));
verticalLayout_3 = new QVBoxLayout();
verticalLayout_3->setSpacing(6);
verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
groupBox = new QGroupBox(widget);
groupBox->setObjectName(QString::fromUtf8("groupBox"));
verticalLayout_6 = new QVBoxLayout(groupBox);
verticalLayout_6->setSpacing(6);
verticalLayout_6->setContentsMargins(11, 11, 11, 11);
verticalLayout_6->setObjectName(QString::fromUtf8("verticalLayout_6"));
verticalLayout_5 = new QVBoxLayout();
verticalLayout_5->setSpacing(6);
verticalLayout_5->setObjectName(QString::fromUtf8("verticalLayout_5"));
lineEdit = new QLineEdit(groupBox);
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
verticalLayout_5->addWidget(lineEdit);
pushButtonGO = new QPushButton(groupBox);
pushButtonGO->setObjectName(QString::fromUtf8("pushButtonGO"));
verticalLayout_5->addWidget(pushButtonGO);
verticalLayout_6->addLayout(verticalLayout_5);
label = new QLabel(groupBox);
label->setObjectName(QString::fromUtf8("label"));
verticalLayout_6->addWidget(label);
verticalLayout_3->addWidget(groupBox);
groupBox_2 = new QGroupBox(widget);
groupBox_2->setObjectName(QString::fromUtf8("groupBox_2"));
horizontalLayout = new QHBoxLayout(groupBox_2);
horizontalLayout->setSpacing(6);
horizontalLayout->setContentsMargins(11, 11, 11, 11);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
pushButtonRL = new QPushButton(groupBox_2);
pushButtonRL->setObjectName(QString::fromUtf8("pushButtonRL"));
horizontalLayout->addWidget(pushButtonRL);
pushButtonRC = new QPushButton(groupBox_2);
pushButtonRC->setObjectName(QString::fromUtf8("pushButtonRC"));
horizontalLayout->addWidget(pushButtonRC);
pushButtonRR = new QPushButton(groupBox_2);
pushButtonRR->setObjectName(QString::fromUtf8("pushButtonRR"));
horizontalLayout->addWidget(pushButtonRR);
verticalLayout_3->addWidget(groupBox_2);
groupBox_3 = new QGroupBox(widget);
groupBox_3->setObjectName(QString::fromUtf8("groupBox_3"));
verticalLayout = new QVBoxLayout(groupBox_3);
verticalLayout->setSpacing(6);
verticalLayout->setContentsMargins(11, 11, 11, 11);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
horizontalLayout_3 = new QHBoxLayout();
horizontalLayout_3->setSpacing(6);
horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3"));
pushButtonZoomP = new QPushButton(groupBox_3);
pushButtonZoomP->setObjectName(QString::fromUtf8("pushButtonZoomP"));
horizontalLayout_3->addWidget(pushButtonZoomP);
pushButtonZoomM = new QPushButton(groupBox_3);
pushButtonZoomM->setObjectName(QString::fromUtf8("pushButtonZoomM"));
horizontalLayout_3->addWidget(pushButtonZoomM);
verticalLayout->addLayout(horizontalLayout_3);
verticalLayout_2 = new QVBoxLayout();
verticalLayout_2->setSpacing(6);
verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
label_4 = new QLabel(groupBox_3);
label_4->setObjectName(QString::fromUtf8("label_4"));
label_4->setAlignment(Qt::AlignCenter);
verticalLayout_2->addWidget(label_4);
verticalLayout->addLayout(verticalLayout_2);
doubleSpinBox = new QDoubleSpinBox(groupBox_3);
doubleSpinBox->setObjectName(QString::fromUtf8("doubleSpinBox"));
doubleSpinBox->setSingleStep(0.1);
doubleSpinBox->setValue(1);
verticalLayout->addWidget(doubleSpinBox);
label_5 = new QLabel(groupBox_3);
label_5->setObjectName(QString::fromUtf8("label_5"));
label_5->setAlignment(Qt::AlignCenter);
verticalLayout->addWidget(label_5);
groupBox_4 = new QGroupBox(groupBox_3);
groupBox_4->setObjectName(QString::fromUtf8("groupBox_4"));
verticalLayout_7 = new QVBoxLayout(groupBox_4);
verticalLayout_7->setSpacing(6);
verticalLayout_7->setContentsMargins(11, 11, 11, 11);
verticalLayout_7->setObjectName(QString::fromUtf8("verticalLayout_7"));
checkBox = new QCheckBox(groupBox_4);
checkBox->setObjectName(QString::fromUtf8("checkBox"));
checkBox->setChecked(true);
verticalLayout_7->addWidget(checkBox);
checkBox_2 = new QCheckBox(groupBox_4);
checkBox_2->setObjectName(QString::fromUtf8("checkBox_2"));
verticalLayout_7->addWidget(checkBox_2);
pushButton = new QPushButton(groupBox_4);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
verticalLayout_7->addWidget(pushButton);
verticalLayout->addWidget(groupBox_4);
verticalLayout_3->addWidget(groupBox_3);
verticalLayout_4->addLayout(verticalLayout_3);
MainWindow->setCentralWidget(centralWidget);
menuBar = new QMenuBar(MainWindow);
menuBar->setObjectName(QString::fromUtf8("menuBar"));
menuBar->setGeometry(QRect(0, 0, 524, 21));
MainWindow->setMenuBar(menuBar);
mainToolBar = new QToolBar(MainWindow);
mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar);
statusBar = new QStatusBar(MainWindow);
statusBar->setObjectName(QString::fromUtf8("statusBar"));
MainWindow->setStatusBar(statusBar);
retranslateUi(MainWindow);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
groupBox->setTitle(QApplication::translate("MainWindow", "Goto Place", 0, QApplication::UnicodeUTF8));
pushButtonGO->setText(QApplication::translate("MainWindow", "GO", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("MainWindow", "GeoCoderStatusCode", 0, QApplication::UnicodeUTF8));
groupBox_2->setTitle(QApplication::translate("MainWindow", "Rotate", 0, QApplication::UnicodeUTF8));
pushButtonRL->setText(QApplication::translate("MainWindow", "Left", 0, QApplication::UnicodeUTF8));
pushButtonRC->setText(QApplication::translate("MainWindow", "Center", 0, QApplication::UnicodeUTF8));
pushButtonRR->setText(QApplication::translate("MainWindow", "Right", 0, QApplication::UnicodeUTF8));
groupBox_3->setTitle(QApplication::translate("MainWindow", "Zoom", 0, QApplication::UnicodeUTF8));
pushButtonZoomP->setText(QApplication::translate("MainWindow", "+", 0, QApplication::UnicodeUTF8));
pushButtonZoomM->setText(QApplication::translate("MainWindow", "-", 0, QApplication::UnicodeUTF8));
label_4->setText(QApplication::translate("MainWindow", "ZoomIncrement", 0, QApplication::UnicodeUTF8));
label_5->setText(QApplication::translate("MainWindow", "CurrentZoom=", 0, QApplication::UnicodeUTF8));
groupBox_4->setTitle(QApplication::translate("MainWindow", "Misc", 0, QApplication::UnicodeUTF8));
checkBox->setText(QApplication::translate("MainWindow", "ShowGridLines", 0, QApplication::UnicodeUTF8));
checkBox_2->setText(QApplication::translate("MainWindow", "UseOpenGL", 0, QApplication::UnicodeUTF8));
pushButton->setText(QApplication::translate("MainWindow", "ReloadMap", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_H

View File

@ -9,4 +9,4 @@ DEPENDPATH += .
INCLUDEPATH += ../core
SOURCES += main.cpp
LIBS += -L../build -lcore -linternals
LIBS += -L../build -lcore -linternals -lcore

View File

@ -46,6 +46,7 @@ int main(int argc, char *argv[])
//Geocoding Test
GeoCoderStatusCode::Types status;
qDebug()<<"Lisbon Coordinates:"<<OPMaps::Instance()->GetLatLngFromGeodecoder("lisbon",status).ToString();
qDebug()<<googleCopyright;
Core *core=new Core;
return a.exec();
}

View File

@ -380,7 +380,7 @@ namespace internals {
{
GeoCoderStatusCode::Types status = GeoCoderStatusCode::Unknow;
PointLatLng pos = OPMaps::Instance()->GetLatLngFromGeodecoder(keys, status);
if(pos.IsEmpty() && status == GeoCoderStatusCode::G_GEO_SUCCESS)
if(!pos.IsEmpty() && (status == GeoCoderStatusCode::G_GEO_SUCCESS))
{
SetCurrentPosition(pos);
}

View File

@ -52,18 +52,23 @@
#include <QThread>
#include <QDateTime>
//#include <QObject>
#include <QObject>
namespace mapcontrol
{
class OPMapControl;
class MapGraphicItem;
}
namespace internals {
class MouseWheelZoomType;
class Core:public QObject,public QRunnable
{
Q_OBJECT
Q_ENUMS(core::GeoCoderStatusCode::Types);
Q_ENUMS(MouseWheelZoomType::Types);
friend class mapcontrol::OPMapControl;
friend class mapcontrol::MapGraphicItem;
public:

View File

@ -32,8 +32,10 @@
#include <QMetaType>
namespace internals {
struct MouseWheelZoomType
struct MouseWheelZoomType:public QObject
{
Q_OBJECT
public:
enum Types
{
/// <summary>
@ -52,6 +54,7 @@ struct MouseWheelZoomType
/// </summary>
ViewCenter,
};
Q_ENUMS(Types)
static QStringList TypesStrList(){return strList;}
static Types TypeByStr(QString const& value){return (Types)MouseWheelZoomType::strList.indexOf(value);}
private:

View File

@ -1,7 +1,7 @@
#include "mapgraphicitem.h"
namespace mapcontrol
{
MapGraphicItem::MapGraphicItem(Core *core):core(core),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false)
MapGraphicItem::MapGraphicItem(Core *core):core(core),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false),rotation(0)
{
EmptytileBrush = Qt::cyan;
MissingDataFont =QFont ("Times",10,QFont::Bold);
@ -20,20 +20,24 @@ namespace mapcontrol
connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
core->StartSystem();
//resize();
}
void MapGraphicItem::start()
{
core->StartSystem();
}
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())
@ -330,15 +334,19 @@ namespace mapcontrol
if(value > MaxZoom())
{
core->SetZoom(MaxZoom());
emit zoomChanged(MaxZoom());
}
else if(value < MinZoom())
{
core->SetZoom(MinZoom());
emit zoomChanged(MinZoom());
}
else
{
core->SetZoom(value);
emit zoomChanged(value);
}
}
void MapGraphicItem::Offset(int const& x, int const& y)
@ -359,4 +367,11 @@ namespace mapcontrol
ret.setWidth(rect.width()*fabs(c)+rect.height()*fabs(s));
return ret;
}
QSize MapGraphicItem::sizeHint()const
{
core::Size size=core->projection->GetTileMatrixMaxXY(MinZoom());
core::Size tilesize=core->projection->TileSize();
QSize rsize((size.Width()+1)*tilesize.Width(),(size.Height()+1)*tilesize.Height());
return rsize;
}
}

View File

@ -22,7 +22,7 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
QSize sizeHint()const;
protected:
@ -74,10 +74,15 @@ private:
double Zoom();
void SetZoom(double const& value);
void mapRotate ( qreal angle );
void start();
void ReloadMap(){core->ReloadMap();}
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return core->SetCurrentPositionByKeywords(keys);}
private slots:
void Core_OnNeedInvalidation();
public slots:
void resize ( QRectF const &rect );
void resize ( QRectF const &rect=QRectF() );
signals:
void zoomChanged(double zoom);
};
}
#endif // MAPGRAPHICITEM_H

View File

@ -0,0 +1 @@
<RCC/>

View File

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

View File

@ -1,21 +1,29 @@
#include "opmapwidget.h"
#include <QtGui>
#include <QMetaObject>
namespace mapcontrol
{
OPMapWidget::OPMapWidget(QWidget *parent):QGraphicsView(parent)
OPMapWidget::OPMapWidget(QWidget *parent):QGraphicsView(parent),useOpenGL(false)
{
core=new internals::Core;
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
core=new Core;
map=new MapGraphicItem(core);
//text.setZValue(20);
QGraphicsTextItem *t=new QGraphicsTextItem(map);
t->setPos(10,10);
//QGraphicsTextItem *t=new QGraphicsTextItem(map);
// t->setPos(10,10);
mscene.addItem(map);
map->setZValue(-1);
t->setZValue(10);
//t->setZValue(10);
this->setScene(&mscene);
this->adjustSize();
t->setFlag(QGraphicsItem::ItemIsMovable,true);
// 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;
}
void OPMapWidget::resizeEvent(QResizeEvent *event)
{
@ -24,5 +32,33 @@ namespace mapcontrol
QRect(QPoint(0, 0), event->size()));
QGraphicsView::resizeEvent(event);
}
QSize OPMapWidget::sizeHint() const
{
return map->sizeHint();
}
void OPMapWidget::showEvent(QShowEvent *event)
{
map->start();
QGraphicsView::showEvent(event);
}
OPMapWidget::~OPMapWidget()
{
delete map;
delete core;
}
void OPMapWidget::closeEvent(QCloseEvent *event)
{
core->OnMapClose();
event->accept();
}
void OPMapWidget::SetUseOpenGL(const bool &value)
{
useOpenGL=value;
if (useOpenGL)
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
else
setupViewport(new QWidget());
update();
}
}

View File

@ -2,7 +2,9 @@
#define OPMAPWIDGET_H
#include "../mapwidget/mapgraphicitem.h"
#include "../core/geodecoderstatus.h"
#include <QObject>
#include <QGLWidget>
namespace mapcontrol
{
class OPMapWidget:public QGraphicsView
@ -16,8 +18,13 @@ namespace mapcontrol
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 geodecoderstatus;
QSize sizeHint() const;
OPMapWidget(QWidget *parent=0);
~OPMapWidget();
bool ShowTileGridLines()const {return map->showTileGridLines;}
void SetShowTileGridLines(bool const& value){map->showTileGridLines=value;map->update();}
int MaxZoom()const{return map->maxZoom;}
@ -34,17 +41,27 @@ namespace mapcontrol
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();}
double Zoom(){return map->Zoom();}
void SetZoom(double const& value){map->SetZoom(value);}
qreal Rotate(){return map->rotation;}
void SetRotate(qreal const& value){return map->mapRotate(value);}
void SetRotate(qreal const& value){map->mapRotate(value);}
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);
private:
internals::Core *core;
Core *core;
MapGraphicItem *map;
QGraphicsScene mscene;
bool useOpenGL;
protected:
void resizeEvent(QResizeEvent *event);
// private slots:
void resizeEvent(QResizeEvent *event);
void showEvent ( QShowEvent * event );
void closeEvent(QCloseEvent *event);
// private slots:
signals:
void zoomChanged(double zoom);
};
}

View File

@ -20,7 +20,7 @@ int main(int argc, char *argv[])
// mapcontrol::MapGraphicItem *mapi=new mapcontrol::MapGraphicItem(c);
// scene.addItem(mapi);
// QGraphicsView view(&scene);
// view.setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
view.setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
// view.setRenderHints(QPainter::Antialiasing
// | QPainter::TextAntialiasing);
//

View File

@ -11,5 +11,5 @@ INCLUDEPATH += ../core
SOURCES += main.cpp \
map.cpp
LIBS += -L../build \
-lmapwidget -lcore -linternals
-lmapwidget# -lcore -linternals -lcore
HEADERS += map.h