提交 43ed278b 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

a lot of improvement has been taken place

上级 709ac991
......@@ -93,6 +93,8 @@ osm_frame_widget::osm_frame_widget(QWidget *parent) :
QTVOSM_DEBUG("The osm_frame_widget class constructed.");
EnumPlugins();
UpdateLayerTable();
//Dock is closable
ui->dockWidget_side->installEventFilter(this);
m_mutex_proteced.unlock();
}
void osm_frame_widget::UpdateLayerTable()
......@@ -117,9 +119,9 @@ tilesviewer * osm_frame_widget::viewer()
bool osm_frame_widget::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::Close && !( obj==ui->tab_map))
if (event->type() == QEvent::Close)
{
if (m_PropPageslayer.contains(obj))
if (obj == ui->tab_map)
{
QWidget * wig = qobject_cast<QWidget *>(obj);
if (wig)
......@@ -129,15 +131,19 @@ bool osm_frame_widget::eventFilter(QObject *obj, QEvent *event)
wig->setWindowFlags(flg);
ui->tabWidget_main->addTab(
wig,
m_PropPageslayer[obj]->get_name()
);
"Map"
);
return true;
}
}
else if (obj == ui->dockWidget_side)
{
ui->dockWidget_side->hide();
QMargins m = this->layout()->contentsMargins();
this->layout()->setContentsMargins(m.left(),m.top(),12,m.bottom());
return true;
}
}
else if (obj==ui->tab_map)//Map
{
if (event->type() == QEvent::Close)
else if (m_PropPageslayer.contains(obj))
{
QWidget * wig = qobject_cast<QWidget *>(obj);
if (wig)
......@@ -147,11 +153,16 @@ bool osm_frame_widget::eventFilter(QObject *obj, QEvent *event)
wig->setWindowFlags(flg);
ui->tabWidget_main->addTab(
wig,
"Map"
m_PropPageslayer[obj]->get_name()
);
return true;
}
return true;
}
else
{
}
}
// standard event processing
return QObject::eventFilter(obj, event);
......@@ -179,7 +190,21 @@ osm_frame_widget::~osm_frame_widget()
{
delete ui;
}
void osm_frame_widget::mousePressEvent(QMouseEvent * e)
{
if (e->pos().x() >= this->rect().right()-12)
{
if (ui->dockWidget_side->isVisible()==false)
{
ui->dockWidget_side->show();
QMargins m = this->layout()->contentsMargins();
this->layout()->setContentsMargins(m.left(),m.top(),m.left(),m.bottom());
}
}
QWidget::mousePressEvent(e);
}
void osm_frame_widget::EnumPlugins()
{
QTVOSM_DEBUG("The osm_frame_widget is enuming plugins.");
......
......@@ -42,6 +42,8 @@ protected:
void UpdateLayerTable();
bool AppendLayer(QString SLName,layer_interface * interface);
void EnumPlugins();
void mousePressEvent(QMouseEvent *);
protected slots:
void delacmd_refresh_layer_view();
void on_tabWidget_main_tabCloseRequested(int index);
......
......@@ -102,6 +102,9 @@
<height>240</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::WheelFocus</enum>
</property>
</widget>
</item>
</layout>
......@@ -136,7 +139,7 @@
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
<set>QDockWidget::AllDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Tools</string>
......
......@@ -27,11 +27,11 @@ namespace QTVOSM
int nCenX = nCenter_X/256;
int nCenY = nCenter_Y/256;
//current left top tile idx
int nCurrLeftX = floor((nCenter_X-m_pViewer->width()/2)/256.0);
int nCurrTopY = floor((nCenter_Y-m_pViewer->height()/2)/256.0);
int nCurrLeftX = floor((nCenter_X-m_pViewer->windowWidth()/2)/256.0);
int nCurrTopY = floor((nCenter_Y-m_pViewer->windowHeight()/2)/256.0);
//current right btm
int nCurrRightX = ceil((nCenter_X+m_pViewer->width()/2)/256.0);
int nCurrBottomY = ceil((nCenter_Y+m_pViewer->height()/2)/256.0);
int nCurrRightX = ceil((nCenter_X+m_pViewer->windowWidth()/2)/256.0);
int nCurrBottomY = ceil((nCenter_Y+m_pViewer->windowHeight()/2)/256.0);
//draw images
......@@ -58,8 +58,8 @@ namespace QTVOSM
int zero_offX = int(nCenter_X+0.5) % 256;
int zero_offY = int(nCenter_Y+0.5) % 256;
//bitblt cood
int tar_x = m_pViewer->width()/2-zero_offX+nTileOffX;
int tar_y = m_pViewer->height()/2-zero_offY+nTileOffY;
int tar_x = m_pViewer->windowWidth()/2-zero_offX+nTileOffX;
int tar_y = m_pViewer->windowHeight()/2-zero_offY+nTileOffY;
//bitblt
pImage->drawImage(tar_x,tar_y,image_source);
}
......@@ -83,8 +83,8 @@ namespace QTVOSM
bool res = false;
if (event->button()==Qt::LeftButton)
{
int nOffsetX = event->pos().x()-m_pViewer->width()/2;
int nOffsetY = event->pos().y()-m_pViewer->height()/2;
int nOffsetX = event->pos().x()-m_pViewer->windowWidth()/2;
int nOffsetY = event->pos().y()-m_pViewer->windowHeight()/2;
m_pViewer->DragView(-nOffsetX,-nOffsetY);
res = true;
}
......@@ -95,7 +95,7 @@ namespace QTVOSM
layer_interface * layer_browser::load_initial_plugin(QString /*strSLibPath*/,viewer_interface * viewer)
{
m_pViewer =dynamic_cast<tilesviewer *>(viewer);
m_pViewer =dynamic_cast<viewer_interface *>(viewer);
if (m_pViewer==0)
return 0;
return this;
......
......@@ -33,7 +33,7 @@ namespace QTVOSM{
QString get_name() {return m_name;}
void set_name(QString vb) { m_name = vb; }
protected:
tilesviewer * m_pViewer;
viewer_interface * m_pViewer;
QString m_name;
private:
//get single tile from web service
......
......@@ -53,6 +53,7 @@ namespace QTVOSM{
m_nCacheExpireDays = nCacheExpireDays;
QSettings settings(QCoreApplication::applicationFilePath()+".ini",QSettings::IniFormat);
settings.setValue(QString("settings/CacheExpireDays_%1").arg(get_name()), m_nCacheExpireDays);
emit cacheExpireChanged(m_nCacheExpireDays);
}
/*!
......@@ -77,11 +78,11 @@ namespace QTVOSM{
int nCenX = nCenter_X/256;
int nCenY = nCenter_Y/256;
//!2.2 calculate current left top tile idx
int nCurrLeftX = floor((nCenter_X-m_pViewer->width()/2)/256.0);
int nCurrTopY = floor((nCenter_Y-m_pViewer->height()/2)/256.0);
int nCurrLeftX = floor((nCenter_X-m_pViewer->windowWidth()/2)/256.0);
int nCurrTopY = floor((nCenter_Y-m_pViewer->windowHeight()/2)/256.0);
//!2.3 calculate current right bottom idx
int nCurrRightX = ceil((nCenter_X+m_pViewer->width()/2)/256.0);
int nCurrBottomY = ceil((nCenter_Y+m_pViewer->height()/2)/256.0);
int nCurrRightX = ceil((nCenter_X+m_pViewer->windowWidth()/2)/256.0);
int nCurrBottomY = ceil((nCenter_Y+m_pViewer->windowHeight()/2)/256.0);
//!2.4 a repeat from tileindx left to right.
for (int col = nCurrLeftX;col<=nCurrRightX;col++)
......@@ -107,8 +108,8 @@ namespace QTVOSM{
int zero_offX = int(nCenter_X+0.5) % 256;
int zero_offY = int(nCenter_Y+0.5) % 256;
//bitblt cood
int tar_x = m_pViewer->width()/2-zero_offX+nTileOffX;
int tar_y = m_pViewer->height()/2-zero_offY+nTileOffY;
int tar_x = m_pViewer->windowWidth()/2-zero_offX+nTileOffX;
int tar_y = m_pViewer->windowHeight()/2-zero_offY+nTileOffY;
//bitblt
pPainter->drawImage(tar_x,tar_y,image_source);
}
......@@ -137,8 +138,8 @@ namespace QTVOSM{
}
else if (event->button()==Qt::RightButton)
{
int nOffsetX = event->pos().x()-m_pViewer->width()/2;
int nOffsetY = event->pos().y()-m_pViewer->height()/2;
int nOffsetX = event->pos().x()-m_pViewer->windowWidth()/2;
int nOffsetY = event->pos().y()-m_pViewer->windowHeight()/2;
m_pViewer->DragView(-nOffsetX,-nOffsetY);
res = true;
}
......@@ -196,10 +197,10 @@ namespace QTVOSM{
layer_interface * layer_tiles::load_initial_plugin(QString /*strSLibPath*/,viewer_interface * viewer)
{
m_pViewer = dynamic_cast<tilesviewer *>(viewer);
m_pViewer = dynamic_cast<viewer_interface *>(viewer);
if (!m_pViewer)
return 0;
connect(m_downloader,SIGNAL(evt_all_taskFinished()),m_pViewer,SLOT(UpdateWindow()));
connect(m_downloader,SIGNAL(evt_all_taskFinished()),this,SLOT(updateViewer()));
//Get Cache Address
QSettings settings(QCoreApplication::applicationFilePath()+".ini",QSettings::IniFormat);
m_strServerURL = settings.value(QString("settings/ServerURL_%1").arg(m_name),"http://c.tile.openstreetmap.org/%1/%2/%3.png").toString();
......@@ -207,6 +208,12 @@ namespace QTVOSM{
m_nCacheExpireDays = settings.value(QString("settings/CacheExpireDays_%1").arg(m_name), 30).toInt();
return this;
}
void layer_tiles::updateViewer()
{
if (!m_pViewer)
return ;
m_pViewer->UpdateWindow();
}
QWidget * layer_tiles::load_prop_window()
{
......@@ -273,7 +280,7 @@ namespace QTVOSM{
void layer_tiles::UpdateLayer()
{
m_pViewer->update();
m_pViewer->UpdateWindow();
}
......@@ -290,7 +297,7 @@ namespace QTVOSM{
{
this->m_bconnected = bconnected;
if (!m_pViewer) return;
m_pViewer->update();
m_pViewer->UpdateWindow();
emit connected(m_bconnected);
//! 1. source=MAIN_MAP, destin = ALL, msg = CONNECTION
if (this->is_active())
......
......@@ -54,7 +54,7 @@ namespace QTVOSM{
bool is_exclusive(){return true;}
void set_active(bool at) { m_bActive = at;}
protected:
tilesviewer * m_pViewer;
viewer_interface * m_pViewer;
layer_tiles_page * m_propPage;
bool m_bActive;
bool m_bVisible;
......@@ -76,6 +76,8 @@ namespace QTVOSM{
bool getTileImage(int nLevel,int nX,int nY,QImage & image);
//! regisit images to web service
bool RegImages(int nX, int nY,int nLevel);
protected slots:
void updateViewer();
public slots:
void setServerUrl(QString url);
void setLocalCache(QString cache);
......@@ -84,6 +86,7 @@ namespace QTVOSM{
void connected(bool);
void svrurlChanged(QString);
void cacheChanged(QString);
void cacheExpireChanged(int);
};
}
#endif // LAYER_TILES_H
......@@ -18,7 +18,7 @@ namespace QTVOSM{
QString strServerURL = settings.value(QString("settings/ServerURL_%1").arg(layer->get_name()),"http://c.tile.openstreetmap.org/%1/%2/%3.png").toString();
QString strLocalCache = settings.value(QString("settings/LocalCache_%1").arg(layer->get_name()), QCoreApplication::applicationDirPath() +"/OSMCache").toString();
int nCacheExpireDays = settings.value(QString("settings/CacheExpireDays_%1").arg(layer->get_name()), 30).toInt();
ui->lineEdit->setText(strLocalCache);
ui->lineEdit_cacheFolder->setText(strLocalCache);
ui->lineEdit_addressUrl->setText(strServerURL);
ui->spinBox_cacheExpireDays->setValue(nCacheExpireDays);
this->setWindowTitle(layer->get_name());
......@@ -28,6 +28,8 @@ namespace QTVOSM{
connect (layer, &layer_tiles::connected ,this->ui->checkBox_connect, &QCheckBox::setChecked);
connect (layer, &layer_tiles::svrurlChanged ,this->ui->lineEdit_addressUrl, &QLineEdit::setText);
connect (layer, &layer_tiles::cacheChanged ,this->ui->lineEdit_cacheFolder, &QLineEdit::setText);
connect (layer, &layer_tiles::cacheExpireChanged ,this->ui->spinBox_cacheExpireDays, &QSpinBox::setValue);
ui->checkBox_connect->setChecked(layer->isConnected());
}
void layer_tiles_page::reTransUI()
......@@ -45,12 +47,12 @@ namespace QTVOSM{
QString strLocalCache = settings.value(QString("settings/LocalCache_%1").arg(m_pLayer->get_name()), QCoreApplication::applicationDirPath() +"/OSMCache").toString();
QString strFolder = QFileDialog::getExistingDirectory(this,tr("Select the local cache"),strLocalCache,QFileDialog::ShowDirsOnly);
if (strFolder.length())
ui->lineEdit->setText(strFolder);
ui->lineEdit_cacheFolder->setText(strFolder);
}
void layer_tiles_page::on_pushButton_apply_clicked()
{
m_pLayer->setLocalCache(ui->lineEdit->text());
m_pLayer->setLocalCache(ui->lineEdit_cacheFolder->text());
m_pLayer->setServerUrl(ui->lineEdit_addressUrl->text());
m_pLayer->setCacheExpireDays(ui->spinBox_cacheExpireDays->value());
m_pLayer->UpdateLayer();
......
......@@ -96,7 +96,7 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
<widget class="QLineEdit" name="lineEdit_cacheFolder"/>
</item>
<item>
<widget class="QToolButton" name="toolButton_browser">
......
......@@ -101,11 +101,6 @@ namespace QTVOSM{
void moveLayerTop(layer_interface *);
void moveLayerBottom(layer_interface *);
void updateLayerGridView();
public slots:
//set current level
void setLevel(int n);
//set current br level to n-4
void setBrLevel(int n);
//force update
void UpdateWindow();
//set center LLA
......@@ -113,8 +108,15 @@ namespace QTVOSM{
//set center LLA, not emit centerChanged
void setBrCenterLLA(double lat, double lon);
virtual QRect windowRect(){return this->rect();}
virtual int windowWidth() {return width();}
virtual int windowHeight() {return height();}
bool saveToImage(const QString & strFm);
public slots:
//set current level
void setLevel(int n);
//set current br level to n-4
void setBrLevel(int n);
protected slots:
void _do_next_evts();
signals:
......
......@@ -23,6 +23,8 @@ namespace QTVOSM{
bool needDo = false;
bool allFinished = false;
bool succeeded = false;
bool redirect = false;
tag_download_tasks redirect_tk;
m_mutex_protect.lock();
QString errMsg;
QString sourceUrl;
......@@ -31,19 +33,42 @@ namespace QTVOSM{
const tag_download_tasks & tk = m_map_pendingTasks[rply];
if (rply->error()==QNetworkReply::NoError)
{
QString strDir = tk.str_destinDir;
QString strFile = tk.str_destinFile;
//mkdir
QDir dir(strDir);
dir.mkpath(strDir);
//saveFile
QFile file(strDir+"/"+strFile);
if (file.open(QIODevice::WriteOnly)==true)
if (rply->bytesAvailable())
{
file.write(rply->readAll());
file.close();
succeeded = true;
sourceUrl = m_map_pendingTasks[rply].str_url;
QString strDir = tk.str_destinDir;
QString strFile = tk.str_destinFile;
//mkdir
QDir dir(strDir);
dir.mkpath(strDir);
//saveFile
QFile file(strDir+"/"+strFile);
if (file.open(QIODevice::WriteOnly)==true)
{
file.write(rply->readAll());
file.close();
succeeded = true;
sourceUrl = m_map_pendingTasks[rply].str_url;
}
}
else
{
QVariant vaurl = rply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (vaurl.type()==QVariant::Url)
{
QUrl urlRd = vaurl.toUrl();
if (urlRd.isRelative())
urlRd = rply->request().url().resolved(urlRd);
redirect_tk = tk;
redirect_tk.str_url = urlRd.toString();
errMsg = tr("task redirected: %1").arg(redirect_tk.str_url);
redirect = true;
succeeded = true;
}
else
{
errMsg = tr("reply is empty: %1").arg(tk.str_url);
}
}
}
else
......@@ -62,14 +87,10 @@ namespace QTVOSM{
if (m_listTask.empty()==true && m_map_pendingTasks.empty()==true)
allFinished = true;
m_mutex_protect.unlock();
if (needDo)
emit evt_doNextJob();
if (allFinished == true && succeeded)
emit evt_all_taskFinished();
if (succeeded)
{
QString strMsg = tr("task succeeded: %1").arg(sourceUrl);
QString strMsg = tr("task succeeded: %1;%2").arg(sourceUrl).arg(errMsg);
emit evt_message(strMsg);
}
else
......@@ -77,6 +98,15 @@ namespace QTVOSM{
QString strMsg = tr("task failed: %1,msg %2").arg(sourceUrl).arg(errMsg);
emit evt_message(strMsg);
}
if (redirect)
{
addDownloadUrl(redirect_tk.str_url,redirect_tk.str_destinDir,redirect_tk.str_destinFile,true);
}
if (needDo)
emit evt_doNextJob();
if (allFinished == true && succeeded)
emit evt_all_taskFinished();
}
......
......@@ -90,6 +90,8 @@ namespace QTVOSM{
virtual void updateLayerGridView()= 0;
//! get the windows device size in pixels
virtual QRect windowRect() = 0;
virtual int windowWidth() = 0;
virtual int windowHeight() = 0;
//! force update
virtual void UpdateWindow() = 0;
//! drag image for special pixes
......
......@@ -41,6 +41,7 @@ class qtvplugin_geomarker : public QWidget,public layer_interface
Q_OBJECT
Q_PLUGIN_METADATA(IID OSMLayerInterface_iid )
Q_INTERFACES(QTVOSM::layer_interface)
typedef QMap<QString, QVariant> (tpfunc_call)(const QMap<QString, QVariant> &);
private:
struct tag_xml_mark{
QString name;
......@@ -123,17 +124,15 @@ private:
//other function calls
private:
void initialBindPluginFuntions();
QMap<QString,
std::function <
QMap<QString, QVariant> (const QMap<QString, QVariant> &)
>
> m_map_pluginFunctions;
QMap<QString,std::function <tpfunc_call> > m_map_pluginFunctions;
QMap<QString, QVariant> func_exists (const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_delete_marks (const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_delete_props (const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_mark_names (const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_mark (const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_props (const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_save_xml (const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_load_xml (const QMap<QString, QVariant> &);
//overloaded virtual funtions
protected:
......
......@@ -57,6 +57,8 @@ void qtvplugin_geomarker::initialBindPluginFuntions()
m_map_pluginFunctions["mark_names"] = std::bind(&qtvplugin_geomarker::func_mark_names, this,std::placeholders::_1);
m_map_pluginFunctions["mark"] = std::bind(&qtvplugin_geomarker::func_mark, this,std::placeholders::_1);
m_map_pluginFunctions["props"] = std::bind(&qtvplugin_geomarker::func_props, this,std::placeholders::_1);
m_map_pluginFunctions["load_xml"] = std::bind(&qtvplugin_geomarker::func_load_xml, this,std::placeholders::_1);
m_map_pluginFunctions["save_xml"] = std::bind(&qtvplugin_geomarker::func_save_xml, this,std::placeholders::_1);
}
/**
......@@ -864,3 +866,59 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_props (const QMap<QString,
//! return value is the user-defined key-pairs.
return std::move(res);
}
/**
* @brief func_save_xml is a internal function for plugin call_func "save_xml"
*
* the paraments used by paras is listed below.
* function=props;
* @param paras The key-value style paraments.
* @return QMap<QString, QVariant> if error happens, a property called "error" will store the most possible reason.
*/
QMap<QString, QVariant> qtvplugin_geomarker::func_save_xml (const QMap<QString, QVariant> & paras)
{
//!xml: user should specify xml filename or the function calll will fail;
QMap<QString, QVariant> res;
if (paras.contains("xml")==false)
{
res["error"] = tr("xml must exist in paraments.");
return std::move(res);
}
QString name = paras["xml"].toString();
if (name.size()==0)
{
res["error"] = tr("xml could not be empty.");
return std::move(res);
}
bool ok = this->xml_save(name);
res ["return"] = ok;
return res;
}
/**
* @brief func_save_xml is a internal function for plugin call_func "save_xml"
*
* the paraments used by paras is listed below.
* function=props;
* @param paras The key-value style paraments.
* @return QMap<QString, QVariant> if error happens, a property called "error" will store the most possible reason.
*/
QMap<QString, QVariant> qtvplugin_geomarker::func_load_xml (const QMap<QString, QVariant> & paras)
{
//!xml: user should specify xml filename or the function calll will fail;
QMap<QString, QVariant> res;
if (paras.contains("xml")==false)
{
res["error"] = tr("xml must exist in paraments.");
return std::move(res);
}
QString name = paras["xml"].toString();
if (name.size()==0)
{
res["error"] = tr("xml could not be empty.");
return std::move(res);
}
bool ok = this->xml_load(name);
res ["return"] = ok;
return res;
}
Qt Openstreepmap viewer
Qt Mercator Map Viewer (OpenStreetMap based)
---------------------------
We are very glad to publish qplanetosm viewer V1.0.0, a plug-in based cross platform opensource map viewer.
This project was orginally designed for Parkinglots status visualization only. A few month ago, develop team find that plugin system in qt is strong enough , can do many other things than parkinglots project. Main features :
This Project contains a cross-platform qt-based openstreetmap(OSM) viewer.
* Project qtviewer_planetosm is the main project, provides a plugin system for layer extension.
* Project qtviewer_planetosm is also a win32 active-X warpper , C#, VB, MFC and Web Apps in win32 will take advantage of this feature.
* Project qtviewer_planetosm is the main project, provides a plugin system for layer extension. Layers will be able to call coordinates convertion functions using specail interface provided by main framework; Layers can communicate with main-framework and other plugins using event system and function call system. Both event system and function call system is based on key-value style parament delivering (QMap<QString, QVariant>).
* Project axqtviewer_planetosm stays at a same phycial path with qtviewer_planetosm, it is a win32 active-X warpper if qtviewer_planetosm. C#, VB, MFC and Old Web Apps in win32 will take advantage of this feature. It also provides a key-value event / function call system , using QString. It is mostly like a bridge across internal QMap<QString, QVariant> calls and external QString calls.
2 sample plugin examples, demonstrating how plugin works.
* Project qtvplugin_grid demonstrating low-level painting and event handling using QPainter and Coordinates convertions.
* Project qtvplugin_geomarker demonstrating heigh-level painting and event handling using QGraphicsScene system. It may be very interesting to see how to deal with map zooming in QGraphicsScene , keeping point marks same pixel size in different level.
1 ActiveX container, demonstrating how to draw animation marks on OSM Map.
* testcontainer is a active-qt based container. in this container, features will be tested such like event system, plugin method system.
There are also several limitations for this project.
* The OSM tiles is just a BACKGROUND image, vector data is not supported. For another word, it is impossible to query road names, place names during navigating.
* Projection system is limited to mercator projection, others is not supported.
* In Linux system, active-X control is disabled, we will introduce D-bus or TCP server in future instead.
......@@ -132,7 +132,7 @@ void testcontainer::on_pushButton_test_navigate_clicked()
QMessageBox::information(this,"osm_get_center_latlon",QString("lat = %1, lon=%2").arg(lat).arg(lon) );
//Set a new center position
lat = 31; lon = 121;
lat = rand()%1700/10.0-85; lon = rand()%3600/10.0-180;
ui->axWidget_map1->dynamicCall("osm_set_center_pos(double,double)",lat,lon);
//Get map center position
......@@ -262,12 +262,15 @@ void testcontainer::on_pushButton_test_mark_clicked()
QMessageBox::information(this,"geomarker1::delete_marks",res);
res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","geomarker1",
"function=update_point;name=ID1;type=1;"
"lat=31.3737;lon=121.3783474;"
QString("function=update_point;name=ID1;type=1;"
"lat=%1;lon=%2;"
"style_pen=2;color_pen=0,0,255,128;width_pen=3;"
"style_brush=1;color_brush=0,255,0,128;"
"color_label=0,0,255,96;weight_label=99;size_label=12;"
"width=16;height=20;").toString();
"width=16;height=20;")
.arg(rand()%1700/10.0-85)
.arg(rand()%3600/10.0-180)
).toString();
if (res.contains("error"))
QMessageBox::information(this,"geomarker1::update_point",res);
......@@ -308,11 +311,16 @@ void testcontainer::on_pushButton_test_line_clicked()
QMessageBox::information(this,"geomarker1::delete_marks",res);
res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","geomarker1",
"function=update_line;name=ID3;type=3;"
"lat0=31.3737;lon0=121.3783474;"
"lat1=40.3737;lon1=111.34347;"
QString("function=update_line;name=ID3;type=3;"
"lat0=%1;lon0=%2;"
"lat1=%3;lon1=%4;"
"style_pen=4;color_pen=255,0,0,96;"
"width_pen=2;").toString();
"width_pen=2;")
.arg(rand()%1700/10.0-85)
.arg(rand()%3600/10.0-180)
.arg(rand()%1700/10.0-85)
.arg(rand()%3600/10.0-180)
).toString();
if (res.contains("error"))
QMessageBox::information(this,"geomarker1::update_line",res);
......@@ -354,7 +362,7 @@ void testcontainer::timerEvent(QTimerEvent * e)
{
if (e->timerId()==m_nAnTimer)
{
static double tposlat = 31, tposlon=121;
static double tposlat = rand()%1700/10.0-85 , tposlon= rand()%3600/10.0-180;
tposlat += sin(tposlon * 3.14/180.0)/5+0.1;
tposlon -= cos(tposlat * 3.14/180.0)/5+0.1;
if (tposlat > 85 ) tposlat = -85;
......@@ -408,3 +416,13 @@ void testcontainer::on_pushButton_test_cache_clicked()
res = ui->axWidget_map1->dynamicCall("osm_set_cache_expire_days(QString,int)","OSM",res.toInt()+1).toString();
QMessageBox::information(this,"geomarker1::osm_get_cache_expire_days",res);
}
void testcontainer::on_pushButton_test_xml_clicked()
{
QString res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","geomarker1",
"function=load_xml;xml=.//test.xml;").toString();
QMessageBox::information(this,"geomarker1::load_xml",res);
res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","geomarker1",
"function=save_xml;xml=.//test.xml;").toString();
QMessageBox::information(this,"geomarker1::save_xml",res);
}
......@@ -37,6 +37,7 @@ protected slots:
void on_pushButton_test_line_clicked();
void on_pushButton_test_polygon_clicked();
void on_pushButton_test_request_clicked();
void on_pushButton_test_xml_clicked();
};
#endif // TESTCONTAINER_H
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>892</width>
<width>973</width>
<height>600</height>
</rect>
</property>
......@@ -163,6 +163,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_test_xml">
<property name="text">
<string>xml</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册