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

start to test ocx featues in windows

上级 e3a2be45
......@@ -72,11 +72,6 @@ osm_frame_widget::osm_frame_widget(QWidget *parent) :
map_evt["source"] = "MAIN_MAP";
map_evt["destin"] = "ALL";
map_evt["name"] = "WINDOW_CREATE";
double tlat, tlon;
ui->widget_mainMap->centerLLA(&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["nLevel"] = ui->widget_mainMap->level();
ui->widget_mainMap->post_event(map_evt);
}
......@@ -92,10 +87,6 @@ osm_frame_widget::osm_frame_widget(QWidget *parent) :
map_evt["source"] = "MAIN_MAP";
map_evt["destin"] = "ALL";
map_evt["name"] = "MAP_INITED";
double tlat, tlon;
ui->widget_mainMap->centerLLA(&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["nLevel"] = ui->widget_mainMap->level();
ui->widget_mainMap->post_event(map_evt);
}
......
......@@ -293,14 +293,9 @@ namespace QTVOSM{
if (this->is_active())
{
QMap<QString, QVariant> map_evt;
map_evt["source"] = "MAIN_MAP";
map_evt["source"] = get_name();
map_evt["destin"] = "ALL";
map_evt["name"] = "CONNECTION";
double tlat, tlon;
m_pViewer->centerLLA(&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["nLevel"] = m_pViewer->level();
map_evt["status"] =m_bconnected?"CONNECTED":"CLOSED";
m_pViewer->post_event(map_evt);
}
......
......@@ -128,13 +128,7 @@ namespace QTVOSM{
map_evt["source"] = "MAIN_MAP";
map_evt["destin"] = "ALL";
map_evt["name"] = "LAYER_MOVED_UP";
double tlat, tlon;
centerLLA(&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["nLevel"] = m_nLevel;
map_evt["layerName"] = ly->get_name();
post_event(map_evt);
}
}
......@@ -155,13 +149,7 @@ namespace QTVOSM{
map_evt["source"] = "MAIN_MAP";
map_evt["destin"] = "ALL";
map_evt["name"] = "LAYER_MOVED_DOWN";
double tlat, tlon;
centerLLA(&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["nLevel"] = m_nLevel;
map_evt["layerName"] = ly->get_name();
post_event(map_evt);
}
}
......@@ -182,11 +170,6 @@ namespace QTVOSM{
map_evt["source"] = "MAIN_MAP";
map_evt["destin"] = "ALL";
map_evt["name"] = "LAYER_MOVED_TOP";
double tlat, tlon;
centerLLA(&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["nLevel"] = m_nLevel;
map_evt["layerName"] = ly->get_name();
post_event(map_evt);
......@@ -208,13 +191,7 @@ namespace QTVOSM{
map_evt["source"] = "MAIN_MAP";
map_evt["destin"] = "ALL";
map_evt["name"] = "LAYER_MOVED_BOTTOM";
double tlat, tlon;
centerLLA(&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["nLevel"] = m_nLevel;
map_evt["layerName"] = ly->get_name();
post_event(map_evt);
}
}
......@@ -274,10 +251,6 @@ namespace QTVOSM{
map_evt["source"] = "MAIN_MAP";
map_evt["destin"] = "ALL";
map_evt["name"] = "LEVEL_CHANGED";
double tlat, tlon;
centerLLA(&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["nLevel"] = n;
post_event(map_evt);
}
......@@ -333,8 +306,8 @@ namespace QTVOSM{
map_evt["name"] = "MOUSE_BUTTON_DOWN";
double tlat, tlon;
CV_DP2LLA(event->pos().x(),event->pos().y(),&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["lat"] = tlat;
map_evt["lon"] = tlon;
map_evt["nLevel"] = m_nLevel;
post_event(map_evt);
......@@ -398,11 +371,6 @@ namespace QTVOSM{
map_evt["source"] = "MAIN_MAP";
map_evt["destin"] = "OUTER";
map_evt["name"] = "MAP_RESIZED";
double tlat, tlon;
centerLLA(&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["nLevel"] = m_nLevel;
map_evt["width"] = event->size().width();
map_evt["height"] = event->size().height();
post_event(map_evt);
......@@ -439,8 +407,8 @@ namespace QTVOSM{
map_evt["name"] = "MOUSE_BUTTON_UP";
double tlat, tlon;
CV_DP2LLA(event->pos().x(),event->pos().y(),&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["lat"] = tlat;
map_evt["lon"] = tlon;
map_evt["nLevel"] = m_nLevel;
post_event(map_evt);
}
......@@ -477,8 +445,8 @@ namespace QTVOSM{
map_evt["name"] = "MOUSE_BUTTON_BLCLK";
double tlat, tlon;
CV_DP2LLA(event->pos().x(),event->pos().y(),&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["lat"] = tlat;
map_evt["lon"] = tlon;
map_evt["nLevel"] = m_nLevel;
post_event(map_evt);
}
......@@ -507,8 +475,8 @@ namespace QTVOSM{
map_evt["name"] = "MOUSE_MOVE";
double tlat, tlon;
CV_DP2LLA(event->pos().x(),event->pos().y(),&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["lat"] = tlat;
map_evt["lon"] = tlon;
map_evt["nLevel"] = m_nLevel;
map_evt["mask"] = (quint32)event->buttons();
post_event(map_evt);
......@@ -535,8 +503,8 @@ namespace QTVOSM{
map_evt["name"] = "MOUSE_WHELL";
double tlat, tlon;
CV_DP2LLA(event->pos().x(),event->pos().y(),&tlat,&tlon);
map_evt["main_lat"] = tlat;
map_evt["main_lon"] = tlon;
map_evt["lat"] = tlat;
map_evt["lon"] = tlon;
map_evt["nLevel"] = m_nLevel;
map_evt["pDeltaX"] = event->pixelDelta().x();
map_evt["pDeltaY"] = event->pixelDelta().y();
......@@ -583,8 +551,8 @@ namespace QTVOSM{
map_evt["source"] = "MAIN_MAP";
map_evt["destin"] = "OUTER";
map_evt["name"] = "CENTER_CHANGED";
map_evt["main_lat"] = lat;
map_evt["main_lon"] = lon;
map_evt["lat"] = lat;
map_evt["lon"] = lon;
map_evt["nLevel"] = m_nLevel;
post_event(map_evt);
}
......@@ -627,8 +595,8 @@ namespace QTVOSM{
map_evt["destin"] = "OUTER";
map_evt["name"] = "CENTER_CHANGED";
centerLLA(&lat,&lon);
map_evt["main_lat"] = lat;
map_evt["main_lon"] = lon;
map_evt["lat"] = lat;
map_evt["lon"] = lon;
map_evt["nLevel"] = m_nLevel;
post_event(map_evt);
}
......
......@@ -59,10 +59,10 @@ qtaxviewer_planetosm::~qtaxviewer_planetosm()
\fn qtaxviewer_planetosm::setTileAddress
\param addr QString type address.
*/
void qtaxviewer_planetosm::setTileAddress (QString addr)
void qtaxviewer_planetosm::osm_set_remote_address (QString layerName, QString addr)
{
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer("OSM");
layer_interface * la = pv->layer(layerName);
if (la)
{
layer_tiles * lt = dynamic_cast<layer_tiles *>(la);
......@@ -71,11 +71,11 @@ void qtaxviewer_planetosm::setTileAddress (QString addr)
}
}
QString qtaxviewer_planetosm::tileAddress() const
QString qtaxviewer_planetosm::osm_get_remote_address(QString layerName) const
{
QString res = "http://c.tile.openstreetmap.org/%1/%2/%3.png";
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer("OSM");
layer_interface * la = pv->layer(layerName);
if (la)
{
layer_tiles * lt = dynamic_cast<layer_tiles *>(la);
......@@ -92,15 +92,15 @@ QString qtaxviewer_planetosm::tileAddress() const
\fn qtaxviewer_planetosm::ConnectToServer
*/
void qtaxviewer_planetosm::ConnectToServer (void)
void qtaxviewer_planetosm::osm_set_auto_download (QString LayerName, int v)
{
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer("OSM");
layer_interface * la = pv->layer(LayerName);
if (la)
{
layer_tiles * lt = dynamic_cast<layer_tiles *>(la);
if (lt)
lt->connectToTilesServer(true);
lt->connectToTilesServer(v==0?false:true);
}
}
......@@ -112,10 +112,10 @@ void qtaxviewer_planetosm::ConnectToServer (void)
\fn qtaxviewer_planetosm::IsConnected
\return int -1 means connected, 0 mean not.
*/
int qtaxviewer_planetosm::IsConnected(void)
int qtaxviewer_planetosm::osm_get_auto_download(QString LayerName)
{
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer("OSM");
layer_interface * la = pv->layer(LayerName);
if (la)
{
layer_tiles * lt = dynamic_cast<layer_tiles *>(la);
......@@ -125,13 +125,13 @@ int qtaxviewer_planetosm::IsConnected(void)
return 0;
}
int qtaxviewer_planetosm::GetLevel(void)
int qtaxviewer_planetosm::osm_get_level(void)
{
tilesviewer * pv = this->ui->widget_mainMap ;
return pv->level();
}
int qtaxviewer_planetosm::SetLevel(int lv)
int qtaxviewer_planetosm::osm_set_level(int lv)
{
tilesviewer * pv = this->ui->widget_mainMap ;
int res = pv->level();
......@@ -139,7 +139,7 @@ int qtaxviewer_planetosm::SetLevel(int lv)
return res;
}
double qtaxviewer_planetosm::GetCenterLatitude()
double qtaxviewer_planetosm::osm_get_center_lat()
{
tilesviewer * pv = this->ui->widget_mainMap ;
double lat,lon;
......@@ -147,7 +147,7 @@ double qtaxviewer_planetosm::GetCenterLatitude()
return lat;
}
double qtaxviewer_planetosm::GetCenterLongitude()
double qtaxviewer_planetosm::osm_get_center_lon()
{
tilesviewer * pv = this->ui->widget_mainMap ;
double lat,lon;
......@@ -155,7 +155,7 @@ double qtaxviewer_planetosm::GetCenterLongitude()
return lon;
}
int qtaxviewer_planetosm::SetCenterPos(double lat,double lon)
int qtaxviewer_planetosm::osm_set_center_pos(double lat,double lon)
{
tilesviewer * pv = this->ui->widget_mainMap ;
pv->setCenterLLA(lat,lon);
......@@ -170,68 +170,13 @@ int qtaxviewer_planetosm::SetCenterPos(double lat,double lon)
\param fm filename in QString. ext name can specify the format.
\return int 1 means OK, 0 means failed.
*/
int qtaxviewer_planetosm::SaveCurrentViewToFile(QString fm)
int qtaxviewer_planetosm::osm_save_view(QString fm)
{
tilesviewer * pv = this->ui->widget_mainMap ;
bool ok = pv->saveToImage(fm);
return ok==true?1:0;
}
/*!
\brief FrozenMap mean that
UI inputs, include MOUOSE, KEY, will take no effect for dragging
\fn qtaxviewer_planetosm::FrozenMap
\param status set status. >0 means frozen it, <0 means re-enable it, 0 means just get status
\return int the current status.
*/
int qtaxviewer_planetosm::FrozenMap(int status)
{
int ret = 0;
if (status==0)
{
QVector <layer_interface *> layers = ui->widget_mainMap->layers();
for (int i=0;i<layers.size()&& ret == 0;++i)
{
//It's exclusive, there should be at most only one layer_tiles active
if (layers[i]->is_exclusive()==true && layers[i]->is_active()==true)
ret = -1;
}
if (ret==0)
ret = 1;
}
else if (status > 0)
{
QVector <layer_interface *> layers = ui->widget_mainMap->layers();
for (int i=0;i<layers.size();++i)
{
//Turn all exclusive layers off( de-actived)
if (layers[i]->is_exclusive()==true && layers[i]->is_active()==true)
{
ret = 1;
layers[i]->set_active(false);
}
}
this->UpdateLayerTable();
}
else
{
QVector <layer_interface *> layers = ui->widget_mainMap->layers();
for (int i=0;i<layers.size() && ret == 0;++i)
{
//Turn first exclusive layers on( actived)
if (layers[i]->is_exclusive()==true && layers[i]->is_active()==true)
{
ret = -1;
layers[i]->set_active(true);
ui->widget_mainMap->adjust_layers(layers[i]);
}
}
this->UpdateLayerTable();
}
return ret;
}
/*!
\brief this protected function is designed to filter events, and fire OCX events when needed.
......@@ -270,25 +215,17 @@ void qtaxviewer_planetosm::_next_pending_evts()
e = & *m_list_events.constBegin();
m_mutex_evts.unlock();
//!3,Extract dsource,destin, lat, lon from map
QString str_source = e->value("source").toString();
QString str_name = e->value("name").toString();
double d_lat = e->value("main_lat").toDouble();
double d_lon = e->value("main_lon").toDouble();
QString str_additional_prop;
//!4, for other key-value paras, just put it into str_additional_prop
QString str_props;
//!3,Extract props.just put it into str_prop, split by ;
for(QMap<QString, QVariant>::const_iterator p = e->begin();p!=e->end();++p)
{
if (p.key()!="source" && p.key()!="name" && p.key()!="main_lat" && p.key()!="main_lon")
{
str_additional_prop += p.key();
str_additional_prop +="=";
str_additional_prop +=p.value().toString();
str_additional_prop +=";";
}
str_props += p.key();
str_props +=":";
str_props +=p.value().toString();
str_props +=";";
}
//!5,Fire the OCX Event
emit evt_Message(str_source,str_name,d_lat,d_lon,str_additional_prop);
emit evt_Message(str_props);
//pop from queue
m_mutex_evts.lock();
......@@ -302,6 +239,149 @@ void qtaxviewer_planetosm::_next_pending_evts()
emit _evt_next_pending_evts();
}
int qtaxviewer_planetosm::osm_layer_get_count()
{
return ui->widget_mainMap->layerNames().size();
}
QString qtaxviewer_planetosm::osm_layer_get_name(int n)
{
QVector<QString> names = ui->widget_mainMap->layerNames();
if (n>=0 && n<names.size())
return names[n];
return "";
}
int qtaxviewer_planetosm::osm_layer_set_visiable(QString layerName, int v)
{
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer(layerName);
if (la)
{
la->set_visible(v==0?false:true);
pv->updateLayerGridView();
return la->is_visible()==false?0:-1;
}
return 0;
}
int qtaxviewer_planetosm::osm_layer_get_visiable(QString layerName)
{
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer(layerName);
if (la)
return la->is_visible()==false?0:-1;
return 0;
}
int qtaxviewer_planetosm::osm_layer_set_active(QString layerName, int v)
{
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer(layerName);
if (la)
{
la->set_active(v==0?false:true);
if (v!=0)
pv->adjust_layers(la);
pv->updateLayerGridView();
return la->is_active()==false?0:-1;
}
return 0;
}
int qtaxviewer_planetosm::osm_layer_get_active(QString layerName)
{
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer(layerName);
if (la)
return la->is_active()==false?0:-1;
return 0;
}
int qtaxviewer_planetosm::osm_layer_move_up(QString layerName)
{
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer(layerName);
if (la)
{
pv->moveLayerUp(la);
pv->updateLayerGridView();
return -1;
}
return 0;
}
int qtaxviewer_planetosm::osm_layer_move_down(QString layerName)
{
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer(layerName);
if (la)
{
pv->moveLayerDown(la);
pv->updateLayerGridView();
return -1;
}
return 0;
}
int qtaxviewer_planetosm::osm_layer_move_top(QString layerName)
{
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer(layerName);
if (la)
{
pv->moveLayerTop(la);
pv->updateLayerGridView();
return -1;
}
return 0;
}
int qtaxviewer_planetosm::osm_layer_move_bottom(QString layerName)
{
tilesviewer * pv = this->ui->widget_mainMap ;
layer_interface * la = pv->layer(layerName);
if (la)
{
pv->moveLayerBottom(la);
pv->updateLayerGridView();
return -1;
}
return 0;
}
//function Calls
QString qtaxviewer_planetosm::osm_layer_call_function(QString layerName, QString args)
{
QString strRes;
tilesviewer * pv = ui->widget_mainMap ;
layer_interface * la = pv->layer(layerName);
if (la)
{
QMap<QString, QVariant> p_in,p_out;
QStringList lst = args.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();
p_in[name] = value;
}
}
p_out = la->call_func(p_in);
for(QMap<QString, QVariant>::iterator p = p_out.begin();p!=p_out.end();++p)
{
strRes += p.key();
strRes += ":";
strRes += p.value().toString();
strRes += ";";
}
}
return strRes;
}
QAXFACTORY_DEFAULT(qtaxviewer_planetosm,
"{8FDF97AD-FEFA-44C9-973B-1B66D4C529DF}",
"{4272B226-BAF3-4B7D-87F5-FBFB9D472666}",
......
......@@ -17,7 +17,6 @@
class qtaxviewer_planetosm :public osm_frame_widget, public QAxBindable
{
Q_OBJECT
Q_PROPERTY(QString tileAddress READ tileAddress WRITE setTileAddress)
protected:
QTranslator qtTranslator;
QTranslator appTranslator;
......@@ -30,34 +29,41 @@ protected:
public:
explicit qtaxviewer_planetosm(QWidget *parent = 0);
~qtaxviewer_planetosm();
//! return the tileAddress which OSM plugin take use of
QString tileAddress(void) const;
//! slots below is designed for activeX interfaces
public slots:
void setTileAddress (QString);
void ConnectToServer (void);
int IsConnected(void);
QString osm_get_remote_address(QString layerName) const;
void osm_set_remote_address (QString layerName, QString addr);
void osm_set_auto_download (QString layerName, int flag);
int osm_get_auto_download(QString layerName);
//Navigate
int GetLevel(void);
int SetLevel(int);
double GetCenterLatitude();
double GetCenterLongitude();
int SetCenterPos(double lat,double lon);
int osm_get_level(void);
int osm_set_level(int);
double osm_get_center_lat();
double osm_get_center_lon();
int osm_set_center_pos(double lat,double lon);
//! \brief PrintScreen
int SaveCurrentViewToFile(QString);
//! \brief acitve/ deactive Map drag
int FrozenMap(int status);
//! new interfaces
public slots:
int osm_save_view(QString);
//layer methods
int osm_layer_get_count();
QString osm_layer_get_name(int n);
int osm_layer_set_visiable(QString layerName, int v);
int osm_layer_get_visiable(QString layerName);
int osm_layer_set_active(QString layerName, int v);
int osm_layer_get_active(QString layerName);
int osm_layer_move_up(QString layerName);
int osm_layer_move_down(QString layerName);
int osm_layer_move_top(QString layerName);
int osm_layer_move_bottom(QString layerName);
//function Calls
QString osm_layer_call_function(QString layerName, QString args);
protected slots:
//! internal evts
void _next_pending_evts();
signals:
void _evt_next_pending_evts();
//! Classical MFC-Styly messages
void evt_Message(QString ,QString ,double,double,QString);
//! messages
void evt_Message(QString);
};
#endif // QTAXVIEWER_PLANETOSM_H
......@@ -2,6 +2,7 @@
#include "ui_testcontainer.h"
#include <QAxBase>
#include <QDebug>
#include <QMessageBox>
testcontainer::testcontainer(QWidget *parent) :
QDialog(parent),
ui(new Ui::testcontainer)
......@@ -11,26 +12,15 @@ testcontainer::testcontainer(QWidget *parent) :
flg |= Qt::WindowMinMaxButtonsHint;
this->setWindowFlags(flg);
m_pModel = new QStandardItemModel (0,6,this);
m_pModel = new QStandardItemModel (0,2,this);
m_pModel->setHeaderData(0,Qt::Horizontal,tr("ctrl"));
m_pModel->setHeaderData(1,Qt::Horizontal,tr("source"));
m_pModel->setHeaderData(2,Qt::Horizontal,tr("msg"));
m_pModel->setHeaderData(3,Qt::Horizontal,tr("lat"));
m_pModel->setHeaderData(4,Qt::Horizontal,tr("lon"));
m_pModel->setHeaderData(5,Qt::Horizontal,tr("props"));
m_pModel->setHeaderData(1,Qt::Horizontal,tr("msg"));
ui->tableView_msg->setModel(m_pModel);
ui->axWidget_map1->setControl("{8FDF97AD-FEFA-44C9-973B-1B66D4C529DF}");
ui->axWidget_map1->dynamicCall("setTileAddress(QString)","http://c.tile.openstreetmap.org/%1/%2/%3.png");
ui->axWidget_map1->dynamicCall("ConnectToServer()");
ui->axWidget_map2->setControl("{8FDF97AD-FEFA-44C9-973B-1B66D4C529DF}");
ui->axWidget_map2->dynamicCall("setTileAddress(QString)","http://c.tile.openstreetmap.org/%1/%2/%3.png");
ui->axWidget_map2->dynamicCall("ConnectToServer()");
connect (ui->axWidget_map1,SIGNAL(evt_Message(QString ,QString ,double,double,QString)),this,SLOT(slot_message(QString ,QString ,double,double,QString)));
connect (ui->axWidget_map2,SIGNAL(evt_Message(QString ,QString ,double,double,QString)),this,SLOT(slot_message(QString ,QString ,double,double,QString)));
connect (ui->axWidget_map1,SIGNAL(evt_Message(QString)),this,SLOT(slot_message(QString)));
connect (ui->axWidget_map2,SIGNAL(evt_Message(QString)),this,SLOT(slot_message(QString)));
}
testcontainer::~testcontainer()
......@@ -41,21 +31,112 @@ void testcontainer::closeEvent(QCloseEvent *)
{
QCoreApplication::quit();
}
void testcontainer::slot_message(QString src ,QString msg ,double lat,double lon,QString ext)
void testcontainer::slot_message(QString message)
{
QAxBase * base = qobject_cast<QAxBase *>(sender());
QList<QStandardItem *> list_newrow;
list_newrow << new QStandardItem(QString("%1").arg((quint64)base));
list_newrow << new QStandardItem(QString("%1").arg(src));
list_newrow << new QStandardItem(QString("%1").arg(msg));
list_newrow << new QStandardItem(QString("%1").arg(lat));
list_newrow << new QStandardItem(QString("%1").arg(lon));
list_newrow << new QStandardItem(QString("%1").arg(ext));
//if (base)
// qDebug()<<(quint64)base<<src <<" send "<<msg<< " lat="<<lat<<", lon="<<lon<<" extmsg="<<ext;
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
QVariant vt_addr = ui->axWidget_map1->dynamicCall("osm_get_remote_address(QString)","OSM");
QString str_addr = vt_addr.toString();
QMessageBox::information(this,"get osm address from LAYER \"OSM\"",str_addr);
//set address to another value
ui->axWidget_map1->dynamicCall("osm_set_remote_address(QString,QString)","OSM", "http://localhost/osmtile.cgi?level=%1&x=%2&y=%3");
//get again
QVariant vt_addr2 = ui->axWidget_map1->dynamicCall("osm_get_remote_address(QString)","OSM");
QString str_addr2 = vt_addr2.toString();
QMessageBox::information(this,"get osm address from LAYER \"OSM\"",str_addr2);
//set address to another value
ui->axWidget_map1->dynamicCall("osm_set_remote_address(QString,QString)","OSM", str_addr);
//get again
QVariant vt_addr3 = ui->axWidget_map1->dynamicCall("osm_get_remote_address(QString)","OSM");
QString str_addr3 = vt_addr3.toString();
QMessageBox::information(this,"get osm address from LAYER \"OSM\"",str_addr3);
}
void testcontainer::on_pushButton_test_autodl_clicked()
{
//get raw address
QVariant vt_addr = ui->axWidget_map1->dynamicCall("osm_get_auto_download(QString)","OSM");
int n_status = vt_addr.toInt();
QMessageBox::information(this,"get auto download from LAYER \"OSM\"",QString("status = %1").arg(n_status) );
ui->axWidget_map1->dynamicCall("osm_set_auto_download(QString, int)","OSM" , n_status==0?-1:0);
vt_addr = ui->axWidget_map1->dynamicCall("osm_get_auto_download(QString)","OSM");
n_status = vt_addr.toInt();
QMessageBox::information(this,"get auto download from LAYER \"OSM\"",QString("status = %1").arg(n_status) );
}
void testcontainer::on_pushButton_test_navigate_clicked()
{
QVariant vt_addr = ui->axWidget_map1->dynamicCall("osm_get_level()");
int n_level = vt_addr.toInt();
QMessageBox::information(this,"get_level",QString("level = %1").arg(n_level) );
ui->axWidget_map1->dynamicCall("osm_set_level(int)",n_level<5?++n_level:--n_level);
vt_addr = ui->axWidget_map1->dynamicCall("osm_get_level()");
n_level = vt_addr.toInt();
QMessageBox::information(this,"get_level",QString("level = %1").arg(n_level) );
double lat = ui->axWidget_map1->dynamicCall("osm_get_center_lat()").toDouble();
double lon = ui->axWidget_map1->dynamicCall("osm_get_center_lon()").toDouble();
QMessageBox::information(this,"osm_get_center_latlon",QString("lat = %1, lon=%2").arg(lat).arg(lon) );
lat = 31; lon = 121;
ui->axWidget_map1->dynamicCall("osm_set_center_pos(double,double)",lat,lon);
lat = ui->axWidget_map1->dynamicCall("osm_get_center_lat()").toDouble();
lon = ui->axWidget_map1->dynamicCall("osm_get_center_lon()").toDouble();
QMessageBox::information(this,"osm_get_center_latlon",QString("lat = %1, lon=%2").arg(lat).arg(lon) );
}
void testcontainer::on_pushButton_test_layers_clicked()
{
QVariant vt_num = ui->axWidget_map1->dynamicCall("osm_layer_get_count()");
int n_num = vt_num.toInt();
QString strLayerNames;
for (int i=0;i<n_num;++i)
{
QVariant vt_name = ui->axWidget_map1->dynamicCall("osm_layer_get_name(int)",i);
QString strname = vt_name.toString();
strLayerNames += strname + ";";
}
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()
{
ui->axWidget_map1->dynamicCall("osm_layer_move_up(QString)","grid1");
on_pushButton_test_layers_clicked();
ui->axWidget_map1->dynamicCall("osm_layer_move_bottom(QString)","grid1");
on_pushButton_test_layers_clicked();
ui->axWidget_map1->dynamicCall("osm_layer_move_top(QString)","grid1");
on_pushButton_test_layers_clicked();
ui->axWidget_map1->dynamicCall("osm_layer_move_down(QString)","grid1");
on_pushButton_test_layers_clicked();
int bv = ui->axWidget_map1->dynamicCall("osm_layer_get_visiable(QString)","grid1").toInt();
QMessageBox::information(this,"visibility",QString("osm_layer_get_visiable(\"grid1\") returns %1").arg(bv));
bv = ui->axWidget_map1->dynamicCall("osm_layer_set_visiable(QString, int)","grid1", bv==0?-1:0).toInt();
QMessageBox::information(this,"visibility",QString("osm_layer_set_visiable(\"grid1\") returns %1").arg(bv));
bv = ui->axWidget_map1->dynamicCall("osm_layer_set_visiable(QString, int)","grid1", bv==0?-1:0).toInt();
QMessageBox::information(this,"visibility",QString("osm_layer_set_visiable(\"grid1\") returns %1").arg(bv));
int av = ui->axWidget_map1->dynamicCall("osm_layer_get_active(QString)","OSM").toInt();
QMessageBox::information(this,"active",QString("osm_layer_get_active(\"OSM\") returns %1").arg(av));
av = ui->axWidget_map1->dynamicCall("osm_layer_set_active(QString,int)","OSM",av==0?-1:0).toInt();
QMessageBox::information(this,"active",QString("osm_layer_set_active(\"OSM\") returns %1").arg(av));
av = ui->axWidget_map1->dynamicCall("osm_layer_set_active(QString,int)","OSM",av==0?-1:0).toInt();
QMessageBox::information(this,"active",QString("osm_layer_set_active(\"OSM\") returns %1").arg(av));
}
......@@ -20,7 +20,12 @@ protected:
private:
Ui::testcontainer *ui;
protected slots:
void slot_message(QString ,QString ,double,double,QString);
void slot_message(QString);
void on_pushButton_test_adds_clicked();
void on_pushButton_test_autodl_clicked();
void on_pushButton_test_navigate_clicked();
void on_pushButton_test_layers_clicked();
void on_pushButton_test_layer_move_clicked();
};
#endif // TESTCONTAINER_H
......@@ -72,11 +72,56 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_lla">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_test_adds">
<property name="text">
<string>test_addr</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_test_autodl">
<property name="text">
<string>test_auto_download</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_test_navigate">
<property name="text">
<string>test_navigate</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_test_layers">
<property name="text">
<string>test_layers</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_test_layer_move">
<property name="text">
<string>test_layer_move</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册