提交 7587475b 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

1. Introduce testcontainer in linux

2. Support both string and qmap calls in widget
上级 1dfceda3
...@@ -4,11 +4,13 @@ SUBDIRS += \ ...@@ -4,11 +4,13 @@ SUBDIRS += \
qtwidget_planetosm \ qtwidget_planetosm \
qtvplugin_grid \ qtvplugin_grid \
qtvplugin_geomarker \ qtvplugin_geomarker \
qtwidget_planetosm_designer qtwidget_planetosm_designer \
test_container
qtwidget_planetosm.file = qtviewer_planetosm/qtwidget_planetosm.pro qtwidget_planetosm.file = qtviewer_planetosm/qtwidget_planetosm.pro
win32:{ win32:{
SUBDIRS +=\ SUBDIRS +=\
qtaxviewer_planetosm\ qtaxviewer_planetosm
test_container
qtaxviewer_planetosm.file = qtviewer_planetosm/qtaxviewer_planetosm.pro qtaxviewer_planetosm.file = qtviewer_planetosm/qtaxviewer_planetosm.pro
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
QT += core gui network QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
linux:QMAKE_CXXFLAGS += -std=c++11 linux:QMAKE_CXXFLAGS += -std=c++11 -fPIC
win32-g++:QMAKE_CXXFLAGS += -std=c++11 win32-g++:QMAKE_CXXFLAGS += -std=c++11
TARGET = ../../bin/qtviewer_planetosm TARGET = ../../bin/qtviewer_planetosm
TEMPLATE = app TEMPLATE = app
......
...@@ -381,7 +381,35 @@ int qtwidget_planetosm::osm_layer_move_bottom(QString layerName) ...@@ -381,7 +381,35 @@ int qtwidget_planetosm::osm_layer_move_bottom(QString layerName)
} }
return 0; return 0;
} }
QString qtwidget_planetosm::map_to_string(const QMap<QString, QVariant> & m)
{
QString s;
for(QMap<QString, QVariant>::const_iterator p = m.begin();p!=m.end();++p)
{
s += p.key();
s += "=";
s += p.value().toString();
s += ";";
}
return std::move(s);
}
QMap<QString, QVariant> qtwidget_planetosm::string_to_map(const QString & s)
{
QMap<QString, QVariant> res;
QStringList lst = s.split(";");
foreach (QString s, lst)
{
int t = s.indexOf("=");
if (t>0 && t< s.size())
{
QString name = s.left(t).trimmed();
QString value = s.mid(t+1).trimmed();
res[name] = value;
}
}
return std::move(res);
}
/** /**
* @brief osm_layer_call_function call layers' call_func method from * @brief osm_layer_call_function call layers' call_func method from
* outside the ocx ctrl. Please MAKE SURE that this function is called from UI thread, * outside the ocx ctrl. Please MAKE SURE that this function is called from UI thread,
...@@ -407,5 +435,33 @@ QMap<QString, QVariant> qtwidget_planetosm::osm_layer_call_function(QString laye ...@@ -407,5 +435,33 @@ QMap<QString, QVariant> qtwidget_planetosm::osm_layer_call_function(QString laye
return p_out; return p_out;
} }
/**
* @brief osm_layer_call_function call layers' call_func method from
* outside the ocx ctrl. Please MAKE SURE that this function is called from UI thread,
* which means the same thread that OCX ctrl stays. Calling "call_func" from another thread is
* NOT SUPPORTED, and will cause strange problems.
*
* @param layerName the layer name to whom this function call will be sent
* @param args args stored in key, value strings,
* key, value is connected with "=", and each pairs splitted by ";"
* eg, function=get_polygon;x=38.43834784;y=16.3834754;
* @return QString the result string is also formatted with key-vaslue para strings.
*/
QString qtwidget_planetosm::osm_layer_call_function(QString layerName, QString args)
{
QString strRes;
osm_frame_widget * mp = qobject_cast<osm_frame_widget *>(m_map_widget);
tilesviewer * pv = mp->viewer();
layer_interface * la = pv->layer(layerName);
if (la)
{
QMap<QString, QVariant> p_in,p_out;
p_in = string_to_map(args);
p_out = la->call_func(p_in);
strRes = map_to_string(p_out);
}
else
strRes = QString("error=Layer name \"%1\" does not exist.;").arg(layerName);
return strRes;
}
...@@ -33,6 +33,8 @@ public: ...@@ -33,6 +33,8 @@ public:
//! slots below is designed for widget interfaces //! slots below is designed for widget interfaces
public: public:
QTVOSM::viewer_interface * viewer(); QTVOSM::viewer_interface * viewer();
QString map_to_string(const QMap<QString, QVariant> & m);
QMap<QString, QVariant> string_to_map(const QString & s);
QString osm_get_remote_address(QString layerName) const; QString osm_get_remote_address(QString layerName) const;
void osm_set_remote_address (QString layerName, QString addr); void osm_set_remote_address (QString layerName, QString addr);
QString osm_get_local_cache(QString layerName) const; QString osm_get_local_cache(QString layerName) const;
...@@ -62,6 +64,7 @@ public: ...@@ -62,6 +64,7 @@ public:
int osm_layer_move_bottom(QString layerName); int osm_layer_move_bottom(QString layerName);
//function Calls //function Calls
QMap<QString, QVariant> osm_layer_call_function(QString layerName, QMap<QString, QVariant> args); QMap<QString, QVariant> osm_layer_call_function(QString layerName, QMap<QString, QVariant> args);
QString osm_layer_call_function(QString layerName, QString args);
signals: signals:
void map_event(QMap<QString, QVariant> p); void map_event(QMap<QString, QVariant> p);
}; };
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
QT += core gui network designer QT += core gui network designer
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
linux:QMAKE_CXXFLAGS += -std=c++11 linux:QMAKE_CXXFLAGS += -std=c++11 -fPIC
win32-g++:QMAKE_CXXFLAGS += -std=c++11 win32-g++:QMAKE_CXXFLAGS += -std=c++11
TARGET = ../../bin/qtwidget_planetosm TARGET = ../../bin/qtwidget_planetosm
TEMPLATE = lib TEMPLATE = lib
CONFIG += dll
DEFINES += PLANETOSM_EXPORT_DLL DEFINES += PLANETOSM_EXPORT_DLL
......
...@@ -36,6 +36,11 @@ qtvplugin_grid::qtvplugin_grid(QWidget *parent) : ...@@ -36,6 +36,11 @@ qtvplugin_grid::qtvplugin_grid(QWidget *parent) :
bFinished = true; bFinished = true;
m_bActive = false; m_bActive = false;
m_nMarks = 0; m_nMarks = 0;
m_pModelCombo = new QStandardItemModel(this);
m_pModelCombo->appendRow(new QStandardItem(tr("POINT")));
m_pModelCombo->appendRow(new QStandardItem(tr("LINE")));
m_pModelCombo->appendRow(new QStandardItem(tr("POLYGON")));
ui->combox_type->setModel(m_pModelCombo);
} }
qtvplugin_grid::~qtvplugin_grid() qtvplugin_grid::~qtvplugin_grid()
...@@ -717,8 +722,11 @@ void qtvplugin_grid::on_pushButton_add_mark_clicked() ...@@ -717,8 +722,11 @@ void qtvplugin_grid::on_pushButton_add_mark_clicked()
QString strMarkerName = QString("geomarker%1").arg(m_nInstance); QString strMarkerName = QString("geomarker%1").arg(m_nInstance);
layer_interface * pif = m_pVi->layer(strMarkerName); layer_interface * pif = m_pVi->layer(strMarkerName);
save_ini(); save_ini();
int tp = ui->combox_type->currentIndex();
QString strAll = ui->plainTextEdit_markcmd->toPlainText(); QString strAll = ui->plainTextEdit_markcmd->toPlainText();
QStringList strLines = strAll.split("\n",QString::SkipEmptyParts); QStringList strLines = strAll.split("\n",QString::SkipEmptyParts);
int c = 0;
QMap<QString, QVariant> map_multi;
foreach (QString str, strLines) foreach (QString str, strLines)
{ {
QString strRegWest = QString("([%1])+").arg(ui->lineEdit_west_spliter->text()); QString strRegWest = QString("([%1])+").arg(ui->lineEdit_west_spliter->text());
...@@ -767,7 +775,7 @@ void qtvplugin_grid::on_pushButton_add_mark_clicked() ...@@ -767,7 +775,7 @@ void qtvplugin_grid::on_pushButton_add_mark_clicked()
lon *= lonNG; lon *= lonNG;
if (pif) if (tp==0)
{ {
QMap<QString, QVariant> inPara, outPara; QMap<QString, QVariant> inPara, outPara;
inPara["function"] = "update_point"; inPara["function"] = "update_point";
...@@ -787,8 +795,25 @@ void qtvplugin_grid::on_pushButton_add_mark_clicked() ...@@ -787,8 +795,25 @@ void qtvplugin_grid::on_pushButton_add_mark_clicked()
++m_nMarks; ++m_nMarks;
outPara = pif->call_func(inPara); outPara = pif->call_func(inPara);
} }
} else
{
map_multi[QString("lat%1").arg(c)] = lat;
map_multi[QString("lon%1").arg(c)] = lon;
++c;
}
}
if (tp)
{
QMap<QString, QVariant> outPara;
map_multi["function"] = "update_polygon";
map_multi["name"] = QString("%1_%2").arg(get_name()).arg(m_nMarks);
map_multi["color_pen"] = "0,0,255,128";
map_multi["color_brush"] = "0,0,0,64";
map_multi["type"] = (tp==1)?6:4;
outPara = pif->call_func(map_multi);
++m_nMarks;
}
} }
void qtvplugin_grid::on_pushButton_clear_clicked() void qtvplugin_grid::on_pushButton_clear_clicked()
...@@ -840,6 +865,7 @@ void qtvplugin_grid::load_ini() ...@@ -840,6 +865,7 @@ void qtvplugin_grid::load_ini()
ui->lineEdit_south_spliter->setText(settings.value("settings/lineEdit_south_spliter","S").toString()); ui->lineEdit_south_spliter->setText(settings.value("settings/lineEdit_south_spliter","S").toString());
ui->lineEdit_west_spliter->setText(settings.value("settings/lineEdit_west_spliter","W").toString()); ui->lineEdit_west_spliter->setText(settings.value("settings/lineEdit_west_spliter","W").toString());
ui->plainTextEdit_markcmd->setPlainText(settings.value("settings/plainTextEdit_markcmd","").toString()); ui->plainTextEdit_markcmd->setPlainText(settings.value("settings/plainTextEdit_markcmd","").toString());
ui->combox_type->setCurrentIndex(settings.value("settings/combox_type",0).toInt());
} }
void qtvplugin_grid::save_ini() void qtvplugin_grid::save_ini()
...@@ -848,4 +874,5 @@ void qtvplugin_grid::save_ini() ...@@ -848,4 +874,5 @@ void qtvplugin_grid::save_ini()
settings.setValue("settings/lineEdit_south_spliter",ui->lineEdit_south_spliter->text()); settings.setValue("settings/lineEdit_south_spliter",ui->lineEdit_south_spliter->text());
settings.setValue("settings/lineEdit_west_spliter",ui->lineEdit_west_spliter->text()); settings.setValue("settings/lineEdit_west_spliter",ui->lineEdit_west_spliter->text());
settings.setValue("settings/plainTextEdit_markcmd",ui->plainTextEdit_markcmd->toPlainText()); settings.setValue("settings/plainTextEdit_markcmd",ui->plainTextEdit_markcmd->toPlainText());
settings.setValue("settings/combox_type",ui->combox_type->currentIndex());
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <QWidget> #include <QWidget>
#include <QTranslator> #include <QTranslator>
#include <QVector> #include <QVector>
#include <QStandardItemModel>
#include "../qtviewer_planetosm/osmtiles/layer_interface.h" #include "../qtviewer_planetosm/osmtiles/layer_interface.h"
#include "../qtviewer_planetosm/osmtiles/viewer_interface.h" #include "../qtviewer_planetosm/osmtiles/viewer_interface.h"
namespace Ui { namespace Ui {
...@@ -54,7 +55,7 @@ private: ...@@ -54,7 +55,7 @@ private:
bool bFinished; bool bFinished;
//simple mark //simple mark
int m_nMarks; int m_nMarks;
QStandardItemModel * m_pModelCombo;
//measure method //measure method
void CalArea(); void CalArea();
double GetArea(double * PointX,double * PointY,int Count); double GetArea(double * PointX,double * PointY,int Count);
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>392</width> <width>410</width>
<height>384</height> <height>418</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -101,6 +101,9 @@ ...@@ -101,6 +101,9 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QComboBox" name="combox_type"/>
</item>
<item> <item>
<widget class="QPushButton" name="pushButton_add_mark"> <widget class="QPushButton" name="pushButton_add_mark">
<property name="text"> <property name="text">
......
...@@ -10,7 +10,9 @@ win32-g++:QMAKE_CXXFLAGS += -std=c++11 ...@@ -10,7 +10,9 @@ win32-g++:QMAKE_CXXFLAGS += -std=c++11
TARGET = ../../bin/qtwidget_planetosm_designer TARGET = ../../bin/qtwidget_planetosm_designer
TEMPLATE = lib TEMPLATE = lib
LIBS += -L$$OUT_PWD/../bin win32:LIBS += -L$$OUT_PWD/../bin
linux:LIBS += -L$$OUT_PWD/../../bin
LIBS += -lqtwidget_planetosm LIBS += -lqtwidget_planetosm
DEFINES += QTWIDGET_PLANETOSM_DESIGNER_LIBRARY DEFINES += QTWIDGET_PLANETOSM_DESIGNER_LIBRARY
......
...@@ -4,20 +4,28 @@ ...@@ -4,20 +4,28 @@
# #
#------------------------------------------------- #-------------------------------------------------
QT += core gui axcontainer QT += core gui
win32: QT+= axcontainer
linux: QMAKE_CXXFLAGS += -std=c++11
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ../../bin/test_container TARGET = ../../bin/test_container
TEMPLATE = app TEMPLATE = app
LIBS += -L$$OUT_PWD/../bin win32:LIBS += -L$$OUT_PWD/../bin
linux:LIBS += -L$$OUT_PWD/../../bin
LIBS += -lqtwidget_planetosm LIBS += -lqtwidget_planetosm
INCLUDEPATH += $$PWD/../qtviewer_planetosm INCLUDEPATH += $$PWD/../qtviewer_planetosm
SOURCES += main.cpp\ SOURCES += main.cpp
testcontainer.cpp
HEADERS += testcontainer.h HEADERS += testcontainer.h
FORMS += testcontainer.ui win32{
FORMS += testcontainer.ui
SOURCES += testcontainer.cpp
}
linux{
FORMS += testcontainer_linux.ui
SOURCES += testcontainer_linux.cpp
}
...@@ -26,8 +26,8 @@ private: ...@@ -26,8 +26,8 @@ private:
QString m_str_gridLayerName; QString m_str_gridLayerName;
QString m_str_markerLayerName; QString m_str_markerLayerName;
void confirmLayerNames(); void confirmLayerNames();
void show_message(QString);
protected slots: protected slots:
void slot_message(QString);
void on_pushButton_test_adds_clicked(); void on_pushButton_test_adds_clicked();
void on_pushButton_test_cache_clicked(); void on_pushButton_test_cache_clicked();
void on_pushButton_test_autodl_clicked(); void on_pushButton_test_autodl_clicked();
......
#include "testcontainer.h"
#include "ui_testcontainer_linux.h"
#include <QDebug>
#include <QMessageBox>
testcontainer::testcontainer(QWidget *parent) :
QDialog(parent),
ui(new Ui::testcontainer)
{
ui->setupUi(this);
QFont ft;
ft.setPixelSize(9);
ui->tableView_msg->setFont(ft);
ui->tableView_msg->verticalHeader()->setDefaultSectionSize(16);
Qt::WindowFlags flg = this->windowFlags();
flg |= Qt::WindowMinMaxButtonsHint;
this->setWindowFlags(flg);
m_pModel = new QStandardItemModel (0,2,this);
m_pModel->setHeaderData(0,Qt::Horizontal,tr("ctrl"));
m_pModel->setHeaderData(1,Qt::Horizontal,tr("msg"));
ui->tableView_msg->setModel(m_pModel);
m_nAnTimer = startTimer(150);
confirmLayerNames();
}
void testcontainer::confirmLayerNames()
{
//Get Total layers
int n_num = ui->osmmap->osm_layer_get_count();
//Get Layer names
for (int i=0;i<n_num;++i)
{
QString strname = ui->osmmap->osm_layer_get_name(i);
if (strname.indexOf("grid")>=0)
m_str_gridLayerName = strname;
else if (strname.indexOf("geomarker")>=0)
m_str_markerLayerName = strname;
}
}
testcontainer::~testcontainer()
{
delete ui;
}
void testcontainer::closeEvent(QCloseEvent *)
{
QCoreApplication::quit();
}
void testcontainer::show_message(QString message)
{
QList<QStandardItem *> list_newrow;
list_newrow << new QStandardItem(QString("map"));
list_newrow << new QStandardItem(QString("%1").arg(message));
m_pModel->appendRow(list_newrow);
while (m_pModel->rowCount()>1024)
m_pModel->removeRow(0);
ui->tableView_msg->scrollToBottom();
}
void testcontainer::on_pushButton_test_adds_clicked()
{
//get raw address
QString str_addr = ui->osmmap->osm_get_remote_address("OSM");
QMessageBox::information(this,"get osm address from LAYER \"OSM\"",str_addr);
//set address to another value
ui->osmmap->osm_set_remote_address("OSM","http://localhost/osmtile.cgi?level=%1&x=%2&y=%3");
//get again
QString str_addr2 = ui->osmmap->osm_get_remote_address("OSM");
QMessageBox::information(this,"get osm address from LAYER \"OSM\"",str_addr2);
//set address to another value
ui->osmmap->osm_set_remote_address("OSM", str_addr);
//get again
QString str_addr3 = ui->osmmap->osm_get_remote_address("OSM");
QMessageBox::information(this,"get osm address from LAYER \"OSM\"",str_addr3);
}
void testcontainer::on_pushButton_test_autodl_clicked()
{
//get auto download flag
int n_status = ui->osmmap->osm_get_auto_download("OSM");
QMessageBox::information(this,"get auto download from LAYER \"OSM\"",QString("status = %1").arg(n_status) );
//set flag to opposite option
ui->osmmap->osm_set_auto_download(
"OSM" ,
n_status==0?-1:0);
//get again
n_status = ui->osmmap->osm_get_auto_download("OSM");
QMessageBox::information(this,"get auto download from LAYER \"OSM\"",QString("status = %1").arg(n_status) );
}
void testcontainer::on_pushButton_test_navigate_clicked()
{
//Get curent Level
int n_level = ui->osmmap->osm_get_level();
QMessageBox::information(this,"get_level",QString("level = %1").arg(n_level) );
//Set level to a new value
ui->osmmap->osm_set_level(n_level<5?++n_level:--n_level);
//Let's see level again
n_level = ui->osmmap->osm_get_level();
QMessageBox::information(this,"get_level",QString("level = %1").arg(n_level) );
//Get map center position
double lat = ui->osmmap->osm_get_center_lat();
double lon = ui->osmmap->osm_get_center_lon();
QMessageBox::information(this,"osm_get_center_latlon",QString("lat = %1, lon=%2").arg(lat).arg(lon) );
//Set a new center position
lat = rand()%1700/10.0-85; lon = rand()%3600/10.0-180;
ui->osmmap->osm_set_center_pos(lat,lon);
//Get map center position
lat = ui->osmmap->osm_get_center_lat();
lon = ui->osmmap->osm_get_center_lon();
QMessageBox::information(this,"osm_get_center_latlon",QString("lat = %1, lon=%2").arg(lat).arg(lon) );
}
void testcontainer::on_pushButton_test_layers_clicked()
{
//Get Total layers
int n_num = ui->osmmap->osm_layer_get_count();
//Get Layer names
QString strLayerNames;
for (int i=0;i<n_num;++i)
{
QString strname = ui->osmmap->osm_layer_get_name(i);
strLayerNames += strname + ";\n";
}
QMessageBox::information(this,"layer count",QString("osm_layer_get_count() returns %1\n%2").arg(n_num).arg(strLayerNames) );
}
void testcontainer::on_pushButton_test_layer_move_clicked()
{
//Move layers up and down
ui->osmmap->osm_layer_move_up(m_str_gridLayerName);
on_pushButton_test_layers_clicked();
ui->osmmap->osm_layer_move_bottom(m_str_gridLayerName);
on_pushButton_test_layers_clicked();
ui->osmmap->osm_layer_move_top(m_str_gridLayerName);
on_pushButton_test_layers_clicked();
ui->osmmap->osm_layer_move_down(m_str_gridLayerName);
on_pushButton_test_layers_clicked();
//Set layer's visiblity
int bv = ui->osmmap->osm_layer_get_visiable(m_str_gridLayerName);
QMessageBox::information(this,"visibility",QString("osm_layer_get_visiable(\"grid\") returns %1").arg(bv));
bv = ui->osmmap->osm_layer_set_visiable(m_str_gridLayerName, bv==0?-1:0);
QMessageBox::information(this,"visibility",QString("osm_layer_set_visiable(\"grid\") returns %1").arg(bv));
bv = ui->osmmap->osm_layer_set_visiable(m_str_gridLayerName, bv==0?-1:0);
QMessageBox::information(this,"visibility",QString("osm_layer_set_visiable(\"grid\") returns %1").arg(bv));
//Set layer's activity
int av = ui->osmmap->osm_layer_get_active("OSM");
QMessageBox::information(this,"active",QString("osm_layer_get_active(\"OSM\") returns %1").arg(av));
av = ui->osmmap->osm_layer_set_active("OSM",av==0?-1:0);
QMessageBox::information(this,"active",QString("osm_layer_set_active(\"OSM\") returns %1").arg(av));
av = ui->osmmap->osm_layer_set_active("OSM",av==0?-1:0);
QMessageBox::information(this,"active",QString("osm_layer_set_active(\"OSM\") returns %1").arg(av));
}
QString testcontainer::map_to_string(const QMap<QString, QVariant> & m)
{
QString s;
for(QMap<QString, QVariant>::const_iterator p = m.begin();p!=m.end();++p)
{
s += p.key();
s += "=";
s += p.value().toString();
s += ";";
}
return std::move(s);
}
QMap<QString, QVariant> testcontainer::string_to_map(const QString & s)
{
QMap<QString, QVariant> res;
QStringList lst = s.split(";");
foreach (QString s, lst)
{
int t = s.indexOf("=");
if (t>0 && t< s.size())
{
QString name = s.left(t).trimmed();
QString value = s.mid(t+1).trimmed();
res[name] = value;
}
}
return std::move(res);
}
void testcontainer::on_pushButton_test_grid_enable_clicked()
{
//Get the grid plugin's ruler status
QString res = ui->osmmap->
osm_layer_call_function(
m_str_gridLayerName,
"function=get_ruler_status;");
QMessageBox::information(this,"grid::get_ruler_status",res);
//Check result
QMap<QString, QVariant> mres = string_to_map(res);
if (mres["status"].toInt())
{
res = ui->osmmap->
osm_layer_call_function(
m_str_gridLayerName,
"function=set_ruler_status;status=0;");
QMessageBox::information(this,"grid::set_ruler_status to false, you can call get_polygon to get polygon strings..",res);
}
else
{
res = ui->osmmap->osm_layer_call_function(
m_str_gridLayerName,
"function=set_ruler_status;status=-1;");
QMessageBox::information(this,"grid::set_ruler_status to true, you can draw polygons on map using mouse lbutton for begin and rbutton for end.",res);
}
}
void testcontainer::on_pushButton_test_grid_getPolygon_clicked()
{
//Get current ploygon lla.
QString res = ui->osmmap->
osm_layer_call_function(
m_str_gridLayerName,
"function=get_polygon;");
res.replace(";",";\n");
res.replace("=","=\t");
QMessageBox::information(this,"grid::get_polygon",res);
}
void testcontainer::on_pushButton_test_mark_clicked()
{
QString res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=delete_marks;name0=ID3;name1=ID4;");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::delete_marks",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
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;")
.arg(rand()%1700/10.0-85)
.arg(rand()%3600/10.0-180)
);
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_point",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=update_props;name=ID1;"
"LABEL=Shanghai;EXPRESS=Shunfeng;Pero=IMMEDIATE;"
"CheckTime=2014-12-31 23:11:27;"
"From=Shanghai;To=Beijing");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_props",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=update_point;name=ID2;type=2;"
"lat=40.3737;lon=111.34347;"
"style_pen=3;color_pen=0,255,0,128;"
"width_pen=2;style_brush=3;color_brush=255,128,0,128;"
"width=12;height=12;");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_point",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=update_props;name=ID2;"
"LABEL=Neimeng;EXPRESS=YunDa;Pero=NORMAL;"
"CheckTime=2014-12-30 07:18:32;"
"From=Huhehaote;To=YinChuan");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_props",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=update_icon;name=ID7;"
"lat=1.233;lon=2.28373;"
"scale=2;rotate=0;smooth=1;"
"color_label=255,0,0,128;weight_label=99;size_label=9;"
"icon=default;");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_icon",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=update_props;name=ID7;"
"LABEL=COSCO;EXPRESS=TianTian;Pero=IMMD;"
"CheckTime=2012-12-30 07:18:32;"
"From=PEKING;To=LONDON;CAR=Apple Watch;");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_props",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=show_props;ID7=1;ID1=0");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_props",res);
}
void testcontainer::on_pushButton_test_line_clicked()
{
QString res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=delete_marks;name0=ID1;name1=ID2;name2=ID4;");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::delete_marks",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
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;")
.arg(rand()%1700/10.0-85)
.arg(rand()%3600/10.0-180)
.arg(rand()%1700/10.0-85)
.arg(rand()%3600/10.0-180)
);
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_line",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=update_props;name=ID3;"
"LABEL=HighWay;");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_point",res);
}
void testcontainer::on_pushButton_test_polygon_clicked()
{
QString res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=delete_marks;name0=ID1;name1=ID2;name2=ID3;");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::delete_marks",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=update_polygon;name=ID4;type=4;"
"lat0=12.2;lon0=67.3;"
"lat1=14.3;lon1=62.8;"
"lat2=22.7;lon2=66.5;"
"lat3=11.5;lon3=72.2;"
"lat4=10.8;lon4=69.4;"
"style_pen=2;color_pen=0,0,255,128;"
"width_pen=3;style_brush=1;color_brush=0,255,0,128;");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_polygon",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=update_props;name=ID4;"
"LABEL=Region;");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_point",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=update_polygon;name=ID40;type=6;"
"lat0=42.2;lon0=-67.3;"
"lat1=34.3;lon1=-62.8;"
"lat2=22.7;lon2=-66.5;"
"lat3=11.5;lon3=-72.2;"
"lat4=0.8;lon4=-69.4;"
"style_pen=2;color_pen=0,0,255,128;"
"width_pen=3;style_brush=1;color_brush=0,255,0,128;");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_polygon",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=update_props;name=ID40;"
"LABEL=Multiline;");
if (res.contains("error"))
QMessageBox::information(this,"geomarker::update_point",res);
}
void testcontainer::timerEvent(QTimerEvent * e)
{
if (e->timerId()==m_nAnTimer)
{
QString res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=exists;name=ID7;");
QMap<QString, QVariant> mres = string_to_map(res);
if (mres["return"].toInt())
{
//Get info of this mark
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=mark;name=ID7");
QMap<QString, QVariant> mparas = string_to_map(res);
double lat = mparas["lat"].toDouble() + 0.173245467333;
double lon = mparas["lon"].toDouble() + 0.245546767673;
qreal rot = mparas["rotate"].toReal()+1.38745738457;
if (rot>360) rot = 0;
if (lat >=85) lat = -85;
if (lon >=180) lon = -180;
ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
QString("function=update_icon;name=ID7;lat=%1;lon=%2;rotate=%4;")
.arg(lat)
.arg(lon).arg(rot)
);
}
}
}
void testcontainer::on_pushButton_test_request_clicked()
{
QString res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=mark_names;");
show_message("geomarker::mark_names:"+res);
QMap<QString,QVariant> mp = string_to_map(res);
QString str_prop_vis = "function=props_vis;" ;
int c = 0;
foreach (QString key, mp.keys())
{
str_prop_vis += QString("name%1=%2;").arg(c++).arg(mp[key].toString());
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=mark;name="+mp[key].toString());
show_message("geomarker::mark:"+res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=props;name="+mp[key].toString());
show_message("geomarker::props:"+res);
}
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName, str_prop_vis);
show_message("geomarker::props_vis:"+res);
}
void testcontainer::on_pushButton_test_cache_clicked()
{
//Get the address of local cache
QString res = ui->osmmap->osm_get_local_cache("OSM");
QMessageBox::information(this,"geomarker::osm_get_local_cache",res);
//set it to /
ui->osmmap->osm_set_local_cache("OSM","/OSMCache");
//Get expire Days
res = ui->osmmap->osm_get_cache_expire_days("OSM");
QMessageBox::information(this,"geomarker::osm_get_cache_expire_days",res);
res = ui->osmmap->osm_set_cache_expire_days("OSM",res.toInt()+1);
QMessageBox::information(this,"geomarker::osm_get_cache_expire_days",res);
}
void testcontainer::on_pushButton_test_xml_clicked()
{
QString res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=load_xml;xml=.//test.xml;");
QMessageBox::information(this,"geomarker::load_xml",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=save_xml;xml=.//test.xml;");
QMessageBox::information(this,"geomarker::save_xml",res);
}
void testcontainer::on_pushButton_test_resource_clicked()
{
QString res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=add_resource;name=lena;filename=./lena.png;centerx=32;centery=32;");
QMessageBox::information(this,"geomarker::add_resource",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=load_resources;xml=.//resource.xml;");
QMessageBox::information(this,"geomarker::load_resources",res);
res = ui->osmmap->osm_layer_call_function(m_str_markerLayerName,
"function=save_resources;xml=.//resource.xml;");
QMessageBox::information(this,"geomarker::save_resources",res);
}
void testcontainer::on_osmmap_map_event(QMap<QString, QVariant> p)
{
QList<QStandardItem *> list_newrow;
list_newrow << new QStandardItem(QString("%1").arg((quint64)ui->osmmap));
QString message = this->map_to_string(p);
if (message.contains("MOUSE_MOVE"))
{
ui->label_mouseMove->setText(message);
}
else
{
list_newrow << new QStandardItem(QString("%1").arg(message));
m_pModel->appendRow(list_newrow);
while (m_pModel->rowCount()>1024)
m_pModel->removeRow(0);
ui->tableView_msg->scrollToBottom();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>testcontainer</class>
<widget class="QDialog" name="testcontainer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1054</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>testcontainer</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Layer control</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="pushButton_test_navigate">
<property name="text">
<string>navigate</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButton_test_cache">
<property name="text">
<string>cache Folder</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QPushButton" name="pushButton_test_xml">
<property name="text">
<string>marks save/load</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QPushButton" name="pushButton_test_mark">
<property name="text">
<string>add marks</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Plugin test:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>background osm conn</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_test_autodl">
<property name="text">
<string>connect</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QPushButton" name="pushButton_test_grid_getPolygon">
<property name="text">
<string>get polygon</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QPushButton" name="pushButton_test_resource">
<property name="text">
<string>res save/load</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QPushButton" name="pushButton_test_grid_enable">
<property name="text">
<string>measure on/off</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_test_adds">
<property name="text">
<string>address</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QPushButton" name="pushButton_test_layers">
<property name="text">
<string>enum layers</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>geo marker</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QPushButton" name="pushButton_test_layer_move">
<property name="text">
<string>order a layer</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Grid measure</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Plugin test:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Navigate</string>
</property>
</widget>
</item>
<item row="16" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="13" column="0">
<widget class="QPushButton" name="pushButton_test_polygon">
<property name="text">
<string>add a polygon</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QPushButton" name="pushButton_test_request">
<property name="text">
<string>get info</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QPushButton" name="pushButton_test_line">
<property name="text">
<string>add a line</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="WidgetMap">
<attribute name="title">
<string>WidgetMap</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="qtwidget_planetosm" name="osmmap" native="true"/>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QTableView" name="tableView_msg">
<property name="minimumSize">
<size>
<width>0</width>
<height>128</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>128</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_mouseMove">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>qtwidget_planetosm</class>
<extends>QWidget</extends>
<header>qtwidget_planetosm.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册