Skip to content

Commit

Permalink
Add project menu
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Nov 22, 2016
1 parent 13e79f8 commit 33e5449
Show file tree
Hide file tree
Showing 28 changed files with 1,395 additions and 918 deletions.
130 changes: 84 additions & 46 deletions Data/Map.earth
Original file line number Diff line number Diff line change
@@ -1,47 +1,85 @@
<map name="google" type="geocentric" version="2">
<options type="geocentric">
<cache path="cache_dir" type="filesystem" />
<terrain color="#ffffff00"
min_lod="0"
max_lod="18"
first_lod="0"
blending="true"
/>
</options>

<image name="google map and image" driver="xyz" min_level="0" max_level="18" visible="true">
<url>http://www.google.cn/maps/vt?lyrs=y&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<profile>spherical-mercator</profile>
<cache_policy usage="read_write" />
</image>

<image name="google image" driver="xyz" min_level="0" max_level="18" visible="false">
<url>http://www.google.cn/maps/vt?lyrs=s&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<profile>spherical-mercator</profile>
<cache_policy usage="read_write" />
</image>

<image name="google map" driver="xyz" min_level="0" max_level="18" visible="false">
<url>http://www.google.cn/maps/vt?lyrs=r&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<profile>spherical-mercator</profile>
<cache_policy usage="read_write" />
</image>

<image name="baidu" driver="xyz" visible="false">
<url>http://online[0-9].map.bdimg.com/onlinelabel/?qt=tile&amp;x={x}&amp;y={y}&amp;z={z}</url>
<profile>spherical-mercator</profile>
<cache_policy usage="read_write" />
</image>

<image name="amap" driver="xyz" visible="false">
<url>http://wprd0[1-4].is.autonavi.com/appmaptile?lang=zh_cn&amp;size=1&amp;style=7&amp;x={x}&amp;y={y}&amp;z={z}&amp;scl=1&amp;ltype=4</url>
<profile>spherical-mercator</profile>
<cache_policy usage="read_write" />
</image>

<image name="amap-1" driver="xyz" visible="false" profile="global-mercator">
<url>"http://webst0[1234].is.autonavi.com/appmaptile?style=6&amp;x={x}&amp;y={y}&amp;z={z}"</url>
<cache_policy usage="read_write" />
</image>

<?xml version="1.0" ?>
<map>
<version>2</version>
<options>
<name>project</name>
<cache>
<path>cache_dir</path>
<type>filesystem</type>
</cache>
<type>geocentric</type>
<terrain>
<blending>true</blending>
<color>#ffffff00</color>
<first_lod>0</first_lod>
<max_lod>18</max_lod>
<min_lod>0</min_lod>
</terrain>
</options>
<image>
<max_level>18</max_level>
<min_level>0</min_level>
<visible>true</visible>
<url>http://www.google.cn/maps/vt?lyrs=y&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>spherical-mercator</profile>
<name>google map and image</name>
<driver>xyz</driver>
</image>
<image>
<max_level>18</max_level>
<min_level>0</min_level>
<visible>false</visible>
<url>http://www.google.cn/maps/vt?lyrs=s&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>spherical-mercator</profile>
<name>google image</name>
<driver>xyz</driver>
</image>
<image>
<max_level>18</max_level>
<min_level>0</min_level>
<visible>false</visible>
<url>http://www.google.cn/maps/vt?lyrs=r&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>spherical-mercator</profile>
<name>google map</name>
<driver>xyz</driver>
</image>
<image>
<visible>false</visible>
<url>http://online[0-9].map.bdimg.com/onlinelabel/?qt=tile&amp;x={x}&amp;y={y}&amp;z={z}</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>spherical-mercator</profile>
<name>baidu</name>
<driver>xyz</driver>
</image>
<image>
<visible>false</visible>
<url>http://wprd0[1-4].is.autonavi.com/appmaptile?lang=zh_cn&amp;size=1&amp;style=7&amp;x={x}&amp;y={y}&amp;z={z}&amp;scl=1&amp;ltype=4</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>spherical-mercator</profile>
<name>amap</name>
<driver>xyz</driver>
</image>
<image>
<visible>false</visible>
<url>../../build-RabbitGIS-Desktop_Qt_5_7_0_MSVC2015_32bit-Debug/Debug/Data/&quot;http:/webst0[1234].is.autonavi.com/appmaptile?style=6&amp;x={x}&amp;y={y}&amp;z={z}&quot;</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>global-mercator</profile>
<name>amap-1</name>
<driver>xyz</driver>
</image>
</map>
130 changes: 84 additions & 46 deletions Data/Map_zh_CN.earth
Original file line number Diff line number Diff line change
@@ -1,47 +1,85 @@
<map name="google" type="geocentric" version="2">
<options type="geocentric">
<cache path="cache_dir" type="filesystem" />
<terrain color="#ffffff00"
min_lod="0"
max_lod="18"
first_lod="0"
blending="true"
/>
</options>

<image name="google影像交通地图" driver="xyz" min_level="0" max_level="18" visible="true">
<url>http://www.google.cn/maps/vt?lyrs=y&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<profile>spherical-mercator</profile>
<cache_policy usage="read_write" />
</image>

<image name="google影像" driver="xyz" min_level="0" max_level="18" visible="false">
<url>http://www.google.cn/maps/vt?lyrs=s&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<profile>spherical-mercator</profile>
<cache_policy usage="read_write" />
</image>

<image name="google交通地图" driver="xyz" min_level="0" max_level="18" visible="false">
<url>http://www.google.cn/maps/vt?lyrs=r&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<profile>spherical-mercator</profile>
<cache_policy usage="read_write" />
</image>

<image name="百度地图" driver="xyz" visible="false">
<url>http://online[0-9].map.bdimg.com/onlinelabel/?qt=tile&amp;x={x}&amp;y={y}&amp;z={z}</url>
<profile>spherical-mercator</profile>
<cache_policy usage="read_write" />
</image>

<image name="高德地图" driver="xyz" visible="false">
<url>http://wprd0[1-4].is.autonavi.com/appmaptile?lang=zh_cn&amp;size=1&amp;style=7&amp;x={x}&amp;y={y}&amp;z={z}&amp;scl=1&amp;ltype=4</url>
<profile>spherical-mercator</profile>
<cache_policy usage="read_write" />
</image>

<image name="高德地图-1" driver="xyz" visible="false" profile="global-mercator">
<url>"http://webst0[1234].is.autonavi.com/appmaptile?style=6&amp;x={x}&amp;y={y}&amp;z={z}"</url>
<cache_policy usage="read_write" />
</image>

<?xml version="1.0" ?>
<map>
<version>2</version>
<options>
<name>project</name>
<cache>
<path>cache_dir</path>
<type>filesystem</type>
</cache>
<type>geocentric</type>
<terrain>
<blending>true</blending>
<color>#ffffff00</color>
<first_lod>0</first_lod>
<max_lod>18</max_lod>
<min_lod>0</min_lod>
</terrain>
</options>
<image>
<max_level>18</max_level>
<min_level>0</min_level>
<visible>true</visible>
<url>http://www.google.cn/maps/vt?lyrs=y&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>spherical-mercator</profile>
<name>google影像交通地图</name>
<driver>xyz</driver>
</image>
<image>
<max_level>18</max_level>
<min_level>0</min_level>
<visible>false</visible>
<url>http://www.google.cn/maps/vt?lyrs=s&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>spherical-mercator</profile>
<name>google影像</name>
<driver>xyz</driver>
</image>
<image>
<max_level>18</max_level>
<min_level>0</min_level>
<visible>false</visible>
<url>http://www.google.cn/maps/vt?lyrs=r&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>spherical-mercator</profile>
<name>google交通地图</name>
<driver>xyz</driver>
</image>
<image>
<visible>false</visible>
<url>http://online[0-9].map.bdimg.com/onlinelabel/?qt=tile&amp;x={x}&amp;y={y}&amp;z={z}</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>spherical-mercator</profile>
<name>百度地图</name>
<driver>xyz</driver>
</image>
<image>
<visible>false</visible>
<url>http://wprd0[1-4].is.autonavi.com/appmaptile?lang=zh_cn&amp;size=1&amp;style=7&amp;x={x}&amp;y={y}&amp;z={z}&amp;scl=1&amp;ltype=4</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>spherical-mercator</profile>
<name>高德地图</name>
<driver>xyz</driver>
</image>
<image>
<visible>false</visible>
<url>Debug/Data/&quot;http:/webst0[1234].is.autonavi.com/appmaptile?style=6&amp;x={x}&amp;y={y}&amp;z={z}&quot;</url>
<cache_policy>
<usage>read_write</usage>
</cache_policy>
<profile>global-mercator</profile>
<name>高德地图-1</name>
<driver>xyz</driver>
</image>
</map>
56 changes: 40 additions & 16 deletions Mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "Mainwindow.h"
#include "ui_Mainwindow.h"
#include <vector>
#include <QFileDialog>
#include <QDebug>
Expand All @@ -18,6 +18,7 @@
#include <osgEarthUtil/EarthManipulator>
#include <osgEarthAnnotation/PlaceNode>
#include <osgEarthUtil/LatLongFormatter>
#include <osgDB/WriteFile>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
Expand All @@ -43,17 +44,17 @@ MainWindow::MainWindow(QWidget *parent) :
this->setCentralWidget(&m_MapViewer);
m_MapViewer.setCursor(Qt::OpenHandCursor);

nRet = LoadMap(CGlobalDir::Instance()->GetDirData()
nRet = LoadProject(CGlobalDir::Instance()->GetDirData()
+ QDir::separator()
+ "Map_"
+ (CGlobal::Instance()->GetLanguage() == "Default"
? QLocale::system().name()
: CGlobal::Instance()->GetLanguage())
+ ".earth");
if(nRet)
nRet = LoadMap(CGlobalDir::Instance()->GetApplicationEarthFile());
nRet = LoadProject(CGlobalDir::Instance()->GetApplicationEarthFile());
if(nRet)
statusBar()->showMessage(tr("Open Map fail"));
statusBar()->showMessage(tr("Open project fail"));

bool check = connect(ui->menuMap_A, SIGNAL(aboutToShow()),
SLOT(slotMenuMapShow()));
Expand All @@ -80,10 +81,10 @@ MainWindow::~MainWindow()
delete ui;
}

int MainWindow::LoadMap(QString szFile)
int MainWindow::LoadProject(QString szFile)
{
int nRet = 0;
this->statusBar()->showMessage(tr("Loading map ...... "));
this->statusBar()->showMessage(tr("Loading project ...... "));
m_MapViewer.setCursor(Qt::BusyCursor);
do {
osg::Node* mapNode = osgDB::readNodeFile(
Expand All @@ -92,7 +93,7 @@ int MainWindow::LoadMap(QString szFile)
{
LOG_MODEL_ERROR("MainWindow", "Open node file fail: %s",
szFile.toStdString().c_str());
this->statusBar()->showMessage(tr("Load map fail:%1").arg(szFile));
this->statusBar()->showMessage(tr("Load project fail:%1").arg(szFile));
nRet = -1;
break;
}
Expand Down Expand Up @@ -158,18 +159,37 @@ int MainWindow::LoadMap(QString szFile)
return nRet;
}

void MainWindow::on_actionOpen_O_triggered()
void MainWindow::on_actionOpen_Project_triggered()
{
this->statusBar()->showMessage(tr("Open map file ......"));
QString szFile = QFileDialog::getOpenFileName(this, tr("Open map file"),
QString(), tr("Map file(*.earth);; All(*.*)"));
this->statusBar()->showMessage(tr("Open project file ......"));
QString szFile = QFileDialog::getOpenFileName(this, tr("Open project file"),
QString(), tr("Project file(*.earth);; All(*.*)"));
if(!szFile.isEmpty())
LoadMap(szFile);
LoadProject(szFile);

this->statusBar()->showMessage(tr("Ready"));
return;
}

void MainWindow::on_actionSava_project_S_triggered()
{
this->statusBar()->showMessage(tr("Save project to file ......"));
QString szFile = QFileDialog::getSaveFileName(this, tr("Open project file"),
QString(), tr("Project file(*.earth);; All(*.*)"));
if(!szFile.isEmpty())
{
if(!osgDB::writeNodeFile(*m_Root, szFile.toStdString()))
{
LOG_MODEL_ERROR("MainWindow", "writeNodeFile fail:%s",
szFile.toStdString().c_str());
}
}

this->statusBar()->showMessage(tr("Ready"));
return;

}

void MainWindow::on_actionOpen_track_T_triggered()
{
this->statusBar()->showMessage(tr("Open track file ......"));
Expand Down Expand Up @@ -455,8 +475,11 @@ void MainWindow::on_actionMeasure_the_distance_M_triggered()
{
m_MapViewer.setCursor(Qt::OpenHandCursor);
m_pMeasureTool->close();
delete m_pMeasureTool;
m_pMeasureTool = NULL;
if(m_pMeasureTool)
{
delete m_pMeasureTool;
m_pMeasureTool = NULL;
}
}
}

Expand Down Expand Up @@ -595,7 +618,8 @@ int MainWindow::InitToolbar()
ui->mainToolBar->setVisible(CGlobal::Instance()->GetToolbarVisable());
ui->actionToolBar->setChecked(CGlobal::Instance()->GetToolbarVisable());

ui->mainToolBar->addAction(ui->actionOpen_O);
ui->mainToolBar->addAction(ui->actionOpen_Project);
ui->mainToolBar->addAction(ui->actionSava_project_S);
ui->mainToolBar->addAction(ui->actionOpen_track_T);
ui->mainToolBar->addSeparator();
ui->mainToolBar->addAction(ui->actionMeasure_the_distance_M);
Expand Down
Loading

0 comments on commit 33e5449

Please sign in to comment.