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

geoMark function is now tested.

上级 9e8c8244
......@@ -73,7 +73,9 @@ qtvplugin_geomarker::qtvplugin_geomarker(QWidget *parent) :
ui->comboBox_fillPad->setModel(m_pFillStyleModel);
m_bNeedRefresh = false;
m_bNeedUpdateView = false;
m_nTimerID_refreshUI = startTimer(2000);
m_nTimerID_refreshMap = startTimer(100);
}
qtvplugin_geomarker::~qtvplugin_geomarker()
......@@ -392,7 +394,7 @@ QString qtvplugin_geomarker::inifile()
return QCoreApplication::applicationFilePath() + QString("/geomarker%1.ini").arg(m_nInstance);
}
void qtvplugin_geomarker::refreshMarks()
void qtvplugin_geomarker::scheduleRefreshMarks()
{
if (!m_pVi || !m_pScene)
return;
......@@ -401,6 +403,15 @@ void qtvplugin_geomarker::refreshMarks()
//We will set a flag and refresh the ui in timerEvent Instead.
m_bNeedRefresh = true;
}
void qtvplugin_geomarker::scheduleUpdateMap()
{
if (!m_pVi || !m_pScene)
return;
//We do not refresh MAP immediately after each mark-insert, for these inserts is very dense ,
//BAD performence will arise if so.
//We will set a flag and refresh the ui in timerEvent Instead.
m_bNeedUpdateView = true;
}
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_line(const QString & name,double lat1, double lon1,double lat2, double lon2, QPen pen)
{
......
......@@ -75,7 +75,10 @@ private:
* This timer is just affects UI widgets, Map will be updated immediately otherwise.
*/
int m_nTimerID_refreshUI;
int m_nTimerID_refreshMap;
bool m_bNeedRefresh;
bool m_bNeedUpdateView;
QStandardItemModel * m_pLineStyleModel;
QStandardItemModel * m_pFillStyleModel;
QStandardItemModel * m_pGeoItemModel;
......@@ -97,7 +100,8 @@ private:
//UI refreshing functions
private:
void refreshMarks();
void scheduleRefreshMarks();
void scheduleUpdateMap();
void refreshItemUI(QString markname);
void refreshProps(QTVP_GEOMARKER::geoItemBase * itm);
QColor string2color(const QString & s);
......
......@@ -26,14 +26,22 @@ QMap<QString, QVariant> qtvplugin_geomarker::call_func(const QMap<QString, QVar
if (funct=="update_point")
{
update_point(paras);
scheduleRefreshMarks();
scheduleUpdateMap();
}
else if (funct=="update_line")
{
update_line(paras);
scheduleRefreshMarks();
scheduleUpdateMap();
}
else if (funct=="update_polygon")
{
update_polygon(paras);
scheduleRefreshMarks();
scheduleUpdateMap();
}
else if (funct=="update_prop")
{
......@@ -474,13 +482,278 @@ bool qtvplugin_geomarker::update_mark(tag_xml_mark & mark)
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_point (const QMap<QString, QVariant> & paras)
{
return 0;
QString name = paras["name"].toString();
if (name.size()==0)
return 0;
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
QPen pen(Qt::SolidLine);
QBrush brush(QColor(255,255,255,128));
qreal width =8;
qreal height =8;
if (base)
{
if (base->item_type()==QTVP_GEOMARKER::ITEAMTYPE_RECT_POINT)
{
QTVP_GEOMARKER::geoGraphicsRectItem * it = dynamic_cast<QTVP_GEOMARKER::geoGraphicsRectItem * >(base);
if (it)
{
pen = it->pen();
brush = it->brush();
width = it->width();
height = it->height();
}
}
else if (base->item_type()==QTVP_GEOMARKER::ITEAMTYPE_ELLIPSE_POINT)
{
QTVP_GEOMARKER::geoGraphicsEllipseItem * it = dynamic_cast<QTVP_GEOMARKER::geoGraphicsEllipseItem * >(base);
if (it)
{
pen = it->pen();
brush = it->brush();
width = it->width();
height = it->height();
}
}
}
if ( paras.contains("style_pen"))
{
//Get pen and brush settings
Qt::PenStyle pst [] ={
Qt::NoPen ,
Qt::SolidLine ,
Qt::DashLine ,
Qt::DotLine ,
Qt::DashDotLine ,
Qt::DashDotDotLine ,
Qt::CustomDashLine
};
int ptdd =paras["style_pen"].toInt();
if (ptdd < 0 || ptdd >=7)
ptdd = 1;
pen.setStyle(pst[ptdd]);
}
if ( paras.contains("color_pen"))
{
QColor penColor = string2color( paras["color_pen"].toString());
pen.setColor(penColor);
}
if ( paras.contains("width_pen"))
{
int penWidth =paras["width_pen"].toInt();
if (penWidth<0) penWidth = 1;
pen.setWidth(penWidth);
}
if ( paras.contains("style_brush"))
{
Qt::BrushStyle bst [] = {
Qt::NoBrush,
Qt::SolidPattern,
Qt::Dense1Pattern,
Qt::Dense2Pattern,
Qt::Dense3Pattern,
Qt::Dense4Pattern,
Qt::Dense5Pattern,
Qt::Dense6Pattern,
Qt::Dense7Pattern,
Qt::HorPattern,
Qt::VerPattern,
Qt::CrossPattern,
Qt::BDiagPattern,
Qt::FDiagPattern,
Qt::DiagCrossPattern
};
int btdd = paras["style_brush"].toInt();
if (btdd < 0 || btdd >=15)
btdd = 1;
brush.setStyle(bst[btdd]);
}
if ( paras.contains("color_brush"))
{
QColor brushColor = string2color( paras["color_brush"].toString());
brush.setColor(brushColor);
}
if ( paras.contains("width"))
{
width =paras["width"].toReal();
if (width ==0) width = 8;
}
if ( paras.contains("height"))
{
height =paras["height"].toReal();
if (height ==0) height = 8;
}
QTVP_GEOMARKER::geoItemBase * newitem = 0;
double lat =paras["lat"].toDouble();
double lon = paras["lon"].toDouble();
int tpn = paras["type"].toInt();
if (tpn > 1 || tpn <0) tpn = 0;
QTVP_GEOMARKER::geo_item_type tpe = static_cast< QTVP_GEOMARKER::geo_item_type > (tpn);
if (tpe==QTVP_GEOMARKER::ITEAMTYPE_RECT_POINT)
newitem = update_point<QTVP_GEOMARKER::geoGraphicsRectItem>(name,lat,lon,width,height,pen,brush);
else
newitem = update_point<QTVP_GEOMARKER::geoGraphicsEllipseItem>(name,lat,lon,width,height,pen,brush);
return newitem;
}
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_line (const QMap<QString, QVariant> & paras)
{
return 0;
QString name = paras["name"].toString();
if (name.size()==0)
return 0;
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
QPen pen(Qt::SolidLine);
if (base)
{
if (base->item_type()==QTVP_GEOMARKER::ITEAMTYPE_LINE)
{
QTVP_GEOMARKER::geoGraphicsLineItem * it = dynamic_cast<QTVP_GEOMARKER::geoGraphicsLineItem * >(base);
pen = it->pen();
}
}
if ( paras.contains("style_pen"))
{
//Get pen and brush settings
Qt::PenStyle pst [] ={
Qt::NoPen ,
Qt::SolidLine ,
Qt::DashLine ,
Qt::DotLine ,
Qt::DashDotLine ,
Qt::DashDotDotLine ,
Qt::CustomDashLine
};
int ptdd =paras["style_pen"].toInt();
if (ptdd < 0 || ptdd >=7)
ptdd = 1;
pen.setStyle(pst[ptdd]);
}
if ( paras.contains("color_pen"))
{
QColor penColor = string2color( paras["color_pen"].toString());
pen.setColor(penColor);
}
if ( paras.contains("width_pen"))
{
int penWidth =paras["width_pen"].toInt();
if (penWidth<0) penWidth = 1;
pen.setWidth(penWidth);
}
QTVP_GEOMARKER::geoItemBase * newitem = 0;
double lat1 =paras["lat1"].toDouble();
double lon1 = paras["lon1"].toDouble();
double lat2 =paras["lat2"].toDouble();
double lon2 = paras["lon2"].toDouble();
newitem = update_line(name,lat1,lon1,lat2,lon2,pen);
return newitem;
}
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_polygon (const QMap<QString, QVariant> & paras)
{
return 0;
QString name = paras["name"].toString();
if (name.size()==0)
return 0;
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
QPen pen(Qt::SolidLine);
QBrush brush(QColor(255,255,255,128));
if (base)
{
if (base->item_type()==QTVP_GEOMARKER::ITEAMTYPE_POLYGON)
{
QTVP_GEOMARKER::geoGraphicsPolygonItem * it = dynamic_cast<QTVP_GEOMARKER::geoGraphicsPolygonItem * >(base);
if (it)
{
pen = it->pen();
brush = it->brush();
}
}
}
if ( paras.contains("style_pen"))
{
//Get pen and brush settings
Qt::PenStyle pst [] ={
Qt::NoPen ,
Qt::SolidLine ,
Qt::DashLine ,
Qt::DotLine ,
Qt::DashDotLine ,
Qt::DashDotDotLine ,
Qt::CustomDashLine
};
int ptdd =paras["style_pen"].toInt();
if (ptdd < 0 || ptdd >=7)
ptdd = 1;
pen.setStyle(pst[ptdd]);
}
if ( paras.contains("color_pen"))
{
QColor penColor = string2color( paras["color_pen"].toString());
pen.setColor(penColor);
}
if ( paras.contains("width_pen"))
{
int penWidth =paras["width_pen"].toInt();
if (penWidth<0) penWidth = 1;
pen.setWidth(penWidth);
}
if ( paras.contains("style_brush"))
{
Qt::BrushStyle bst [] = {
Qt::NoBrush,
Qt::SolidPattern,
Qt::Dense1Pattern,
Qt::Dense2Pattern,
Qt::Dense3Pattern,
Qt::Dense4Pattern,
Qt::Dense5Pattern,
Qt::Dense6Pattern,
Qt::Dense7Pattern,
Qt::HorPattern,
Qt::VerPattern,
Qt::CrossPattern,
Qt::BDiagPattern,
Qt::FDiagPattern,
Qt::DiagCrossPattern
};
int btdd = paras["style_brush"].toInt();
if (btdd < 0 || btdd >=15)
btdd = 1;
brush.setStyle(bst[btdd]);
}
if ( paras.contains("color_brush"))
{
QColor brushColor = string2color( paras["color_brush"].toString());
brush.setColor(brushColor);
}
QTVP_GEOMARKER::geoItemBase * newitem = 0;
QPolygonF pl;
int ct = 0;
QString strKeyLat = QString("lat%1").arg(ct);
QString strKeyLon = QString("lon%1").arg(ct);
while (paras.contains(strKeyLat) && paras.contains(strKeyLon))
{
double lat =paras[strKeyLat].toDouble();
double lon = paras[strKeyLon].toDouble();
pl.push_back(QPointF(lon,lat));
}
if (pl.size()>2)
newitem = update_polygon(name,pl,pen,brush);
return newitem;
}
......@@ -62,6 +62,18 @@ void qtvplugin_geomarker::timerEvent(QTimerEvent * e)
m_pGeoItemModel->removeRows(c, rowCount - c);
m_nTimerID_refreshUI = startTimer(2000);
}
else if (m_nTimerID_refreshMap==e->timerId() && m_bNeedUpdateView==true)
{
m_bNeedUpdateView = false;
killTimer(m_nTimerID_refreshMap);
m_nTimerID_refreshMap = -1;
m_pVi->UpdateWindow();
m_nTimerID_refreshMap = startTimer(100);
}
else
{
}
}
......@@ -354,7 +366,7 @@ void qtvplugin_geomarker::on_pushButton_update_clicked()
}
refreshMarks();
scheduleRefreshMarks();
m_pVi->UpdateWindow();
}
......@@ -371,7 +383,7 @@ void qtvplugin_geomarker::on_pushButton_del_clicked()
if (b)
m_pScene->removeItem(b,0);
}
refreshMarks();
scheduleRefreshMarks();
}
......@@ -385,7 +397,7 @@ void qtvplugin_geomarker::on_pushButton_prop_update_clicked()
{
item->set_prop_data(ui->lineEdit_prop_name->text(),ui->lineEdit_prop_string->text());
this->refreshProps(item);
this->refreshMarks();
this->scheduleRefreshMarks();
//Update Font
int fontSz = ui->spinBox_fontSize->value();
int fontWeight = ui->spinBox_textWeight->value();
......@@ -614,6 +626,6 @@ void qtvplugin_geomarker::on_pushButton_load_clicked()
else
QMessageBox::warning(this,tr("failed"),tr("Load XML file") + newfm + tr(" Failed"));
}
refreshMarks();
scheduleRefreshMarks();
m_pVi->UpdateWindow();
}
......@@ -200,3 +200,14 @@ void testcontainer::on_pushButton_test_grid_getPolygon_clicked()
QMessageBox::information(this,"grid1::get_polygon",res);
}
void testcontainer::on_pushButton_test_mark_clicked()
{
QString 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;"
"style_pen=2;color_pen=0,0,255,128;"
"width_pen=3;style_brush=1;color_brush=0,255,0,128;"
"width=16;height=20;").toString();
QMessageBox::information(this,"grid1::get_polygon",res);
}
......@@ -30,6 +30,7 @@ protected slots:
void on_pushButton_test_layer_move_clicked();
void on_pushButton_test_grid_enable_clicked();
void on_pushButton_test_grid_getPolygon_clicked();
void on_pushButton_test_mark_clicked();
};
#endif // TESTCONTAINER_H
......@@ -128,6 +128,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_test_mark">
<property name="text">
<string>mark</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册