diff --git a/qtvplugin_geomarker/dialogselecticon.ui b/qtvplugin_geomarker/dialogselecticon.ui
index 5b1194dfa8547d4ebe732972ea150ea20f85e341..5ce63e2f8039f3277ae8fe11648760251101e8ea 100644
--- a/qtvplugin_geomarker/dialogselecticon.ui
+++ b/qtvplugin_geomarker/dialogselecticon.ui
@@ -11,7 +11,7 @@
- Dialog
+ import icon resource
-
diff --git a/qtvplugin_geomarker/geoitembase.cpp b/qtvplugin_geomarker/geoitembase.cpp
index 7ed760fad69b4f54bd426cf12f8e3643ff3b10ba..4a989a154fd0526674a2a2bd67d5c312bebec1d9 100644
--- a/qtvplugin_geomarker/geoitembase.cpp
+++ b/qtvplugin_geomarker/geoitembase.cpp
@@ -73,6 +73,12 @@ namespace QTVP_GEOMARKER{
m_pLabelItem = new QGraphicsTextItem(v.toString(),pc);
m_pLabelItem->setDefaultTextColor(m_LabelTextColor);
m_pLabelItem->setFont(m_LabelTextFont);
+ if (pc->scale()>0)
+ {
+ qreal sc = pc->scale();
+ m_pLabelItem->setScale(1.0/pc->scale());
+ }
+ m_pLabelItem->setRotation(-pc->rotation());
}
else if (m_bPropVisible==false)
m_pLabelItem->setPlainText(v.toString());
@@ -118,6 +124,13 @@ namespace QTVP_GEOMARKER{
m_pLabelItem = new QGraphicsTextItem(str,pc);
m_pLabelItem->setDefaultTextColor(m_LabelTextColor);
m_pLabelItem->setFont(m_LabelTextFont);
+ if (pc->scale()>0)
+ {
+ qreal sc = pc->scale();
+ m_pLabelItem->setScale(1.0/pc->scale());
+ }
+ m_pLabelItem->setRotation(-pc->rotation());
+
}
else
m_pLabelItem->setPlainText(str);
@@ -145,6 +158,13 @@ namespace QTVP_GEOMARKER{
m_pLabelItem = new QGraphicsTextItem(v.toString(),pc);
m_pLabelItem->setDefaultTextColor(m_LabelTextColor);
m_pLabelItem->setFont(m_LabelTextFont);
+ if (pc->scale()>0)
+ {
+ qreal sc = pc->scale();
+ m_pLabelItem->setScale(1.0/pc->scale());
+ }
+ m_pLabelItem->setRotation(-pc->rotation());
+
}
m_pLabelItem->setPlainText(v.toString());
m_pLabelItem->setPos(this->label_pos());
@@ -158,6 +178,18 @@ namespace QTVP_GEOMARKER{
void geoItemBase::adjustLabelPos()
{
if (m_pLabelItem)
+ {
+ QGraphicsItem * pc = dynamic_cast (this);
+ if (pc)
+ {
+ if (pc->scale()>0)
+ {
+ qreal sc = pc->scale();
+ m_pLabelItem->setScale(1.0/pc->scale());
+ }
+ m_pLabelItem->setRotation(-pc->rotation());
+ }
m_pLabelItem->setPos(this->label_pos());
+ }
}
}
diff --git a/qtvplugin_geomarker/qtvplugin_geomarker.cpp b/qtvplugin_geomarker/qtvplugin_geomarker.cpp
index 6768236d731fef376ca4059eedb52b78da55d8ed..b2434617457e49b636d2b6377925f0668dbe46c1 100644
--- a/qtvplugin_geomarker/qtvplugin_geomarker.cpp
+++ b/qtvplugin_geomarker/qtvplugin_geomarker.cpp
@@ -583,6 +583,7 @@ QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_icon(const QString & n
pitem->setTransformationMode(Qt::SmoothTransformation);
else
pitem->setTransformationMode(Qt::FastTransformation);
+ pitem->adjustLabelPos();
}
return res;
}
diff --git a/qtvplugin_geomarker/qtvplugin_geomarker.h b/qtvplugin_geomarker/qtvplugin_geomarker.h
index cdd3fe239dd3d27b4f9b9607761b41f118ae9a4f..db1b04014caa7d0f9b56a3f98617d495b6684f6c 100644
--- a/qtvplugin_geomarker/qtvplugin_geomarker.h
+++ b/qtvplugin_geomarker/qtvplugin_geomarker.h
@@ -130,8 +130,9 @@ private:
QMap func_update_point (const QMap &);
QMap func_update_line (const QMap &);
QMap func_update_polygon (const QMap &);
+ QMap func_update_icon (const QMap &);
QMap func_update_props (const QMap &);
- //other function calls
+ //other method for plugin function calls
private:
void initialBindPluginFuntions();
QMap > m_map_pluginFunctions;
@@ -143,7 +144,10 @@ private:
QMap func_props (const QMap &);
QMap func_save_xml (const QMap &);
QMap func_load_xml (const QMap &);
-
+ //icon and its manage
+ QMap func_add_reource (const QMap &);
+ QMap func_save_reources (const QMap &);
+ QMap func_load_reources (const QMap &);
//overloaded virtual funtions
protected:
layer_interface * load_initial_plugin(QString strSLibPath,viewer_interface * ptrviewer);
diff --git a/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp b/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp
index f5728b33e8a2ec0408b24d8cc281acc70f80096d..c43877bd49b95532e1e70a0d8a9173071c4d0e0b 100644
--- a/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp
+++ b/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp
@@ -15,13 +15,14 @@
* 1.update_point Insert or Update a point mark.
* 2.update_line Insert or Update a line mark.
* 3.update_polygon Insert or Update a polygon mark.
- * 4.update_props Insert or Update a mark's user-defind properties.
- * 5.exists Test whether a special mark is exist.
- * 6.delete_marks Delete marks.
- * 7.delete_props Delete user-defined properties for a mark.
- * 8.mark_names return All mark names owned by this plugin.
- * 9.mark return All styles and geo points for a special mark.
- * 10.props return All user-defined properties for a special mark.
+ * 4.update_icon Insert or Update a icon mark.
+ * 5.update_props Insert or Update a mark's user-defind properties.
+ * 6.exists Test whether a special mark is exist.
+ * 7.delete_marks Delete marks.
+ * 8.delete_props Delete user-defined properties for a mark.
+ * 9.mark_names return All mark names owned by this plugin.
+ * 10.mark return All styles and geo points for a special mark.
+ * 11.props return All user-defined properties for a special mark.
* @param paras the key-value style paraments.
* @return QMap the key-value style return values.
*/
@@ -50,6 +51,7 @@ void qtvplugin_geomarker::initialBindPluginFuntions()
m_map_pluginFunctions["update_point"] = std::bind(&qtvplugin_geomarker::func_update_point, this,std::placeholders::_1);
m_map_pluginFunctions["update_line"] = std::bind(&qtvplugin_geomarker::func_update_line, this,std::placeholders::_1);
m_map_pluginFunctions["update_polygon"] = std::bind(&qtvplugin_geomarker::func_update_polygon, this,std::placeholders::_1);
+ m_map_pluginFunctions["update_icon"] = std::bind(&qtvplugin_geomarker::func_update_icon, this,std::placeholders::_1);
m_map_pluginFunctions["update_props"] = std::bind(&qtvplugin_geomarker::func_update_props, this,std::placeholders::_1);
m_map_pluginFunctions["exists"] = std::bind(&qtvplugin_geomarker::func_exists, this,std::placeholders::_1);
m_map_pluginFunctions["delete_marks"] = std::bind(&qtvplugin_geomarker::func_delete_marks, this,std::placeholders::_1);
@@ -237,6 +239,110 @@ QMap qtvplugin_geomarker::func_update_point (const QMap if error happens, a property called "error" will store the most possible reason.
+ */
+QMap qtvplugin_geomarker:: func_update_icon (const QMap & paras)
+{
+ QMap res;
+ //!name, lat, lon has no default values. user should specify these values or the function calll will fail;
+ if (paras.contains("name")==false || paras.contains("lat")==false || paras.contains("lon")==false)
+ {
+ res["error"] = tr("name, lat, lon must exist in paraments.");
+ return std::move(res);
+
+ }
+ QString name = paras["name"].toString();
+ if (name.size()==0)
+ {
+ res["error"] = tr("name could not be empty.");
+ return std::move(res);
+ }
+ QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
+ QString icon_name = "default";
+ qreal scale = 1.0;
+ qreal rot = 0.0;
+ int smooth = 0;
+ //if the mark is already exist, we will get its orgional style as default .
+ if (base)
+ {
+ QTVP_GEOMARKER::geoGraphicsPixmapItem * it = dynamic_cast(base);
+ if (it)
+ {
+ icon_name = it->icon()->name;
+ scale = it->scale();
+ rot = it->rotation();
+ smooth = it->transformationMode()==Qt::SmoothTransformation?1:0;
+ }
+ }
+
+ //! icon is the name that this mark will use.
+ if ( paras.contains("icon"))
+ {
+ QString icn = paras["icon"].toString();
+ if (icn.length()) icon_name = icn;
+ }
+ //! scale is the zoom ratio that this icon will use, 1.0 means no zoom
+ if ( paras.contains("scale"))
+ {
+ qreal sc = paras["scale"].toReal();
+ if (sc >0 ) scale = sc;
+ }
+ //! rotate is the rotate angle that this icon will use, 0.0 means no rotate
+ if ( paras.contains("rotate"))
+ {
+ qreal rt = paras["rotate"].toReal();
+ rot = rt;
+ }
+ //!smooth is the transform mode that this icon will use. 0 mean not smooth, but faster. 1 mean smooth.
+ if ( paras.contains("smooth"))
+ {
+ int smt =paras["smooth"].toInt();
+ if (smt ==0) smooth = 0; else smooth = 1;
+ }
+ QTVP_GEOMARKER::geoItemBase * newitem = 0;
+ /*! geo coordinate in WGS84 lattitude, longitude should be saved as lat and lon.
+ */
+ double lat =paras["lat"].toDouble();
+ double lon = paras["lon"].toDouble();
+
+ newitem = update_icon(name,lat,lon,scale,rot,smooth,icon_name);
+ if (newitem)
+ {
+ QFont f = newitem->labelFont();
+ //! size_label stands for the text label font pixel size from 1 - 720, with a normal value 9.
+ if ( paras.contains("size_label"))
+ {
+ int fontSz = paras["size_label"].toInt();
+ if (fontSz==0) fontSz = 9;
+ f.setPointSize(fontSz);
+ }
+ //! weight_label is the bolder rate for text renderring, from 1 ~ 99, 99 is the heaviest.
+ if ( paras.contains("weight_label"))
+ {
+ int fontWeight = paras["weight_label"].toInt();
+ f.setWeight(fontWeight);
+ }
+ newitem->setLabelFont(f);
+ //! color_label has 4 text color band values splitted by comma, r,g,b,a
+ if ( paras.contains("color_label"))
+ {
+ QColor textColor = string2color( paras["color_label"].toString());
+ newitem->setLabelColor(textColor);
+ }
+ scheduleRefreshMarks();
+ scheduleUpdateMap();
+ }
+ else
+ res["error"] = tr("can not create graphical object, the pointer is zero.");
+ return std::move(res);
+}
+
/**
* @brief func_update_line is a internal function for plugin call_func "update_line"
*
diff --git a/test_container/testcontainer.cpp b/test_container/testcontainer.cpp
index 4af966ae16d9853620d8779c7e3c911a7eed0aab..a97c64a8b8de226b11d7b5c3a23cce3ef7188e53 100644
--- a/test_container/testcontainer.cpp
+++ b/test_container/testcontainer.cpp
@@ -281,7 +281,7 @@ void testcontainer::on_pushButton_test_mark_clicked()
"CheckTime=2014-12-31 23:11:27;"
"From=Shanghai;To=Beijing").toString();
if (res.contains("error"))
- QMessageBox::information(this,"geomarker1::update_point",res);
+ QMessageBox::information(this,"geomarker1::update_props",res);
res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","geomarker1",
@@ -300,7 +300,25 @@ void testcontainer::on_pushButton_test_mark_clicked()
"CheckTime=2014-12-30 07:18:32;"
"From=Huhehaote;To=YinChuan").toString();
if (res.contains("error"))
- QMessageBox::information(this,"geomarker1::update_point",res);
+ QMessageBox::information(this,"geomarker1::update_props",res);
+
+ res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","geomarker1",
+ "function=update_icon;name=ID7;"
+ "lat=1.233;lon=2.28373;"
+ "scale=2;rotate=0;smooth=1;"
+ "icon=default;").toString();
+
+ if (res.contains("error"))
+ QMessageBox::information(this,"geomarker1::update_icon",res);
+
+ res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","geomarker1",
+ "function=update_props;name=ID7;"
+ "LABEL=COSCO;EXPRESS=YangChunHe;Pero=IMMD;"
+ "CheckTime=2012-12-30 07:18:32;"
+ "From=PEKING;To=YIKH").toString();
+ if (res.contains("error"))
+ QMessageBox::information(this,"geomarker1::update_props",res);
+
}
void testcontainer::on_pushButton_test_line_clicked()