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

Add all functions for the geomarker plugin.

上级 6bc305d6
......@@ -133,6 +133,7 @@ private:
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> &);
//overloaded virtual funtions
protected:
......
......@@ -12,11 +12,16 @@
*
* ATTENTION!THIS FUNCTION IS NOT THREAD SAFE! Calls should be made only in main thread, also called "UI Thread"
* Supported fucntions:
* 1.function=update_point
* 2.function=update_line
* 3.function=update_polygon
* 4.function=update_props
* 5.function=exists
* 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.
* @param paras the key-value style paraments.
* @return QMap<QString, QVariant> the key-value style return values.
*/
......@@ -36,22 +41,36 @@ QMap<QString, QVariant> qtvplugin_geomarker::call_func(const QMap<QString, QVar
return std::move(res);
}
/**
* @brief initialBindPluginFuntions using C++11/14 style of function bindings to build a
* string map. this approach is faster than if-elseif switches when there are a lot if functions to maintain.
*/
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_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);
m_map_pluginFunctions["delete_props"] = std::bind(&qtvplugin_geomarker::func_delete_props,this,std::placeholders::_1);
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["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_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);
m_map_pluginFunctions["delete_props"] = std::bind(&qtvplugin_geomarker::func_delete_props, this,std::placeholders::_1);
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);
}
/**
* @brief func_update_point is a internal function for plugin call_func "update_point"
*
* the paraments used by paras is listed below.
* function=update_point;
* @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_update_point (const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> 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.");
......@@ -69,7 +88,7 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
QBrush brush(QColor(255,255,255,128));
qreal width =8;
qreal height =8;
//if the mark is already exist, we will get its orgional style as default .
if (base)
{
if (base->item_type()==QTVP_GEOMARKER::ITEAMTYPE_RECT_POINT)
......@@ -95,6 +114,8 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
}
}
}
//! style_pen from 0~6, is corresponds to the pen combo-box in UI system.
if ( paras.contains("style_pen"))
{
//Get pen and brush settings
......@@ -112,12 +133,14 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
ptdd = 1;
pen.setStyle(pst[ptdd]);
}
//! color_pen has 4 pen color band values splitted by comma, r,g,b,a
if ( paras.contains("color_pen"))
{
QColor penColor = string2color( paras["color_pen"].toString());
pen.setColor(penColor);
}
//! width_pen has a value >0 , stand for the point width of the pen on screen.
if ( paras.contains("width_pen"))
{
int penWidth =paras["width_pen"].toInt();
......@@ -125,7 +148,7 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
pen.setWidth(penWidth);
}
//! style_brush from 0~14, is corresponds to the brush style combo-box in UI system.
if ( paras.contains("style_brush"))
{
Qt::BrushStyle bst [] = {
......@@ -150,6 +173,8 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
btdd = 1;
brush.setStyle(bst[btdd]);
}
//! color_brush has 4 brush color band values splitted by comma, r,g,b,a
if ( paras.contains("color_brush"))
{
QColor brushColor = string2color( paras["color_brush"].toString());
......@@ -167,13 +192,15 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
if (height ==0) height = 8;
}
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();
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);
//update using same function in UI
if (tpe==QTVP_GEOMARKER::ITEAMTYPE_RECT_POINT)
newitem = update_point<QTVP_GEOMARKER::geoGraphicsRectItem>(name,lat,lon,width,height,pen,brush);
else
......@@ -181,18 +208,21 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
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());
......@@ -205,9 +235,18 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
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"
*
* the paraments used by paras is listed below.
* function=update_line;
* @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_update_line (const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
//!name, lat0, lon0, lat1,lon1 has no default values. user should specify these values or the function calll will fail;
if (paras.contains("name")==false || paras.contains("lat0")==false || paras.contains("lon0")==false
|| paras.contains("lat1")==false || paras.contains("lon1")==false)
{
......@@ -223,6 +262,8 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_line (const QMap<QStr
}
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
QPen pen(Qt::SolidLine);
//if the mark is already exist, we will get its orgional style as default .
if (base)
{
if (base->item_type()==QTVP_GEOMARKER::ITEAMTYPE_LINE)
......@@ -232,6 +273,8 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_line (const QMap<QStr
}
}
//! style_pen from 0~6, is corresponds to the pen combo-box in UI system.
if ( paras.contains("style_pen"))
{
//Get pen and brush settings
......@@ -249,12 +292,14 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_line (const QMap<QStr
ptdd = 1;
pen.setStyle(pst[ptdd]);
}
//! color_pen has 4 pen color band values splitted by comma, r,g,b,a
if ( paras.contains("color_pen"))
{
QColor penColor = string2color( paras["color_pen"].toString());
pen.setColor(penColor);
}
//! width_pen has a value >0 , stand for the point width of the pen on screen.
if ( paras.contains("width_pen"))
{
int penWidth =paras["width_pen"].toInt();
......@@ -264,28 +309,33 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_line (const QMap<QStr
}
QTVP_GEOMARKER::geoItemBase * newitem = 0;
/*! geo coordinates in WGS84 lattitude, longitude should be saved like this:
* lat0, lon0 stand for point1, lat1,lon1 stand for point2
*/
double lat1 =paras["lat0"].toDouble();
double lon1 = paras["lon0"].toDouble();
double lat2 =paras["lat1"].toDouble();
double lon2 = paras["lon1"].toDouble();
//update using same function in UI
newitem = update_line(name,lat1,lon1,lat2,lon2,pen);
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());
......@@ -299,10 +349,19 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_line (const QMap<QStr
return std::move(res);
}
/**
* @brief func_update_polygon is a internal function for plugin call_func "update_polygo"
*
* the paraments used by paras is listed below.
* function=update_polygo;
* @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_update_polygon (const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
//!name, latn, lonn, has no default values, n>=3. user should specify these values or the function calll will fail;
if (paras.contains("name")==false)
{
res["error"] = tr("name must exist in paraments.");
......@@ -319,6 +378,8 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
QPen pen(Qt::SolidLine);
QBrush brush(QColor(255,255,255,128));
//if the mark is already exist, we will get its orgional style as default .
if (base)
{
if (base->item_type()==QTVP_GEOMARKER::ITEAMTYPE_POLYGON)
......@@ -332,6 +393,8 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
}
}
//! style_pen from 0~6, is corresponds to the pen combo-box in UI system.
if ( paras.contains("style_pen"))
{
//Get pen and brush settings
......@@ -349,12 +412,15 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
ptdd = 1;
pen.setStyle(pst[ptdd]);
}
//! color_pen has 4 pen color band values splitted by comma, r,g,b,a
if ( paras.contains("color_pen"))
{
QColor penColor = string2color( paras["color_pen"].toString());
pen.setColor(penColor);
}
//! width_pen has a value >0 , stand for the point width of the pen on screen.
if ( paras.contains("width_pen"))
{
int penWidth =paras["width_pen"].toInt();
......@@ -362,7 +428,7 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
pen.setWidth(penWidth);
}
//! style_brush from 0~14, is corresponds to the brush style combo-box in UI system.
if ( paras.contains("style_brush"))
{
Qt::BrushStyle bst [] = {
......@@ -387,6 +453,7 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
btdd = 1;
brush.setStyle(bst[btdd]);
}
//! color_brush has 4 brush color band values splitted by comma, r,g,b,a
if ( paras.contains("color_brush"))
{
QColor brushColor = string2color( paras["color_brush"].toString());
......@@ -394,7 +461,9 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
}
QTVP_GEOMARKER::geoItemBase * newitem = 0;
/*! geo coordinates in WGS84 lattitude, longitude should be saved like this:
* lat0, lon0 stand for point1, lat1,lon1 stand for point2,latn-1, lonn-1 stand for point n.
*/
QPolygonF pl;
int ct = 0;
QString strKeyLat = QString("lat%1").arg(ct);
......@@ -408,6 +477,7 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
strKeyLat = QString("lat%1").arg(ct);
strKeyLon = QString("lon%1").arg(ct);
}
//update using same function in UI
if (pl.size()>2)
newitem = update_polygon(name,pl,pen,brush);
else
......@@ -416,18 +486,21 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
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());
......@@ -441,16 +514,29 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
return std::move(res);
}
/**
* @brief func_update_props is a internal function for plugin call_func "update_props"
*
* the paraments used by paras is listed below.
* function=update_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_update_props(const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
//!name: user should specify these values or the function calll will fail;
QString name = paras["name"].toString();
if (name.size()==0)
{
res["error"] = tr("name does not exist in paraments.");
return std::move(res);
}
/** the user-defined properties are defined as key-value pairs.
* [prop_name]=[prop_value]
* note that plugin keyword "name" and "function" should not be used.
*/
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
if (base)
{
......@@ -467,9 +553,19 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_props(const QMap<QStrin
return std::move(res);
}
/**
* @brief func_exists is a internal function for plugin call_func "exists"
*
* the paraments used by paras is listed below.
* function=exists;
* @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_exists (const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
//!name: user should specify these values or the function calll will fail;
QString name = paras["name"].toString();
if (name.size()==0)
{
......@@ -483,12 +579,23 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_exists (const QMap<QString,
}
else
res["return"] = 0;
//! return 1 means the mark name is exist, 0 mean not.
return std::move(res);
}
/**
* @brief func_delete_marks is a internal function for plugin call_func "delete_marks"
*
* the paraments used by paras is listed below.
* function=delete_marks;
* @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_delete_marks (const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
//! marknames should stored in parename name0, name1, name2
//! for example, name0=StarBar;name1=ruijing Hospital;name2=shunfun express;
QSet<QString> set_names;
int ct = 0;
do{
......@@ -523,10 +630,18 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_delete_marks (const QMap<QSt
return std::move(res);
}
/**
* @brief func_delete_props is a internal function for plugin call_func "delete_props"
*
* the paraments used by paras is listed below.
* function=delete_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_delete_props (const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
//!name: user should specify these values or the function calll will fail;
if (paras.contains("name")==false)
{
res["error"] = tr("name must exist in paraments.");
......@@ -538,6 +653,12 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_delete_props (const QMap<QSt
res["error"] = tr("name could not be empty.");
return std::move(res);
}
/*!
* the property names to be deleted will be stored like this:
* prop0, prop1,...,propn-1
* for example:
* prop0=TIME;prop1=Profit;Prop2=Address;Prop3=tel;
*/
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
if (base)
{
......@@ -556,6 +677,14 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_delete_props (const QMap<QSt
return std::move(res);
}
/**
* @brief func_mark_names is a internal function for plugin call_func "mark_names"
*
* the paraments used by paras is listed below.
* function=func_mark_names;
* @param paras The key-value style paraments. no other paras needed except for "function"
* @return QMap<QString, QVariant> if error happens, a property called "error" will store the most possible reason.
*/
QMap<QString, QVariant> qtvplugin_geomarker::func_mark_names (const QMap<QString, QVariant> & /*paras*/)
{
QMap<QString, QVariant> res;
......@@ -566,11 +695,172 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_mark_names (const QMap<QStr
QString keystr = QString("name%1").arg(ct++);
res[keystr] = key->item_name();
}
//! the mark names will be stored in key-value pairs, with
//! name0=??;name1=??;name2=??...namen-1=??
return std::move(res);
}
/**
* @brief func_mark is a internal function for plugin call_func "mark"
*
* the paraments used by paras is listed below.
* function=mark;
* @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_mark (const QMap<QString, QVariant> & paras)
{
//!name: user should specify these values or the function calll will fail;
QMap<QString, QVariant> res;
if (paras.contains("name")==false)
{
res["error"] = tr("name 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 * item = m_pScene->geoitem_by_name(name);
if (item)
{
QTVP_GEOMARKER::geo_item_type x_tp = item->item_type();
QString x_name = item->item_name();
//! in return parament, contains same keys as "func_update_point","func_update_line",and "func_update_polygon":
res["name"] = x_name;
res["type"] = QString("%1").arg((int)x_tp);
switch (x_tp)
{
case QTVP_GEOMARKER::ITEAMTYPE_RECT_POINT:
{
QTVP_GEOMARKER::geoGraphicsRectItem * pU = dynamic_cast<QTVP_GEOMARKER::geoGraphicsRectItem *>(item);
if (pU)
{
res["lat"] = QString("%1").arg(pU->lat(),0,'f',7);
res["lon"] = QString("%1").arg(pU->lon(),0,'f',7);
res["width"] = QString("%1").arg(pU->width());
res["height"] = QString("%1").arg(pU->height());
res["color_pen"] = color2string(pU->pen().color());
res["style_pen"] = QString("%1").arg(int(pU->pen().style()));
res["width_pen"] = QString("%1").arg(int(pU->pen().width()));
res["color_brush"] = color2string(pU->brush().color());
res["style_brush"] = QString("%1").arg(int(pU->brush().style()));
}
}
break;
case QTVP_GEOMARKER::ITEAMTYPE_ELLIPSE_POINT:
{
QTVP_GEOMARKER::geoGraphicsEllipseItem * pU = dynamic_cast<QTVP_GEOMARKER::geoGraphicsEllipseItem *>(item);
if (pU)
{
res["lat"] = QString("%1").arg(pU->lat(),0,'f',7);
res["lon"] = QString("%1").arg(pU->lon(),0,'f',7);
res["width"] = QString("%1").arg(pU->width());
res["height"] = QString("%1").arg(pU->height());
res["color_pen"] = color2string(pU->pen().color());
res["style_pen"] = QString("%1").arg(int(pU->pen().style()));
res["width_pen"] = QString("%1").arg(int(pU->pen().width()));
res["color_brush"] = color2string(pU->brush().color());
res["style_brush"] = QString("%1").arg(int(pU->brush().style()));
}
}
break;
case QTVP_GEOMARKER::ITEAMTYPE_LINE:
{
QTVP_GEOMARKER::geoGraphicsLineItem * pU = dynamic_cast<QTVP_GEOMARKER::geoGraphicsLineItem *>(item);
if (pU)
{
res["lat0"] = QString("%1").arg(pU->lat1(),0,'f',7);
res["lon0"] = QString("%1").arg(pU->lon1(),0,'f',7);
res["lat1"] = QString("%1").arg(pU->lat2(),0,'f',7);
res["lon1"] = QString("%1").arg(pU->lon2(),0,'f',7);
res["color_pen"] = color2string(pU->pen().color());
res["style_pen"] = QString("%1").arg(int(pU->pen().style()));
res["width_pen"] = QString("%1").arg(int(pU->pen().width()));
}
}
break;
case QTVP_GEOMARKER::ITEAMTYPE_POLYGON:
{
QTVP_GEOMARKER::geoGraphicsPolygonItem * pU = dynamic_cast<QTVP_GEOMARKER::geoGraphicsPolygonItem *>(item);
if (pU)
{
QPolygonF pl = pU->llas();
int nPl = pl.size();
for (int in = 0;in < nPl; ++in)
{
QString keyLat = QString("lat%1").arg(in);
QString keyLon = QString("lon%1").arg(in);
res[keyLat] = QString("%1").arg(pl[in].y(),0,'f',7);
res[keyLon] = QString("%1").arg(pl[in].x(),0,'f',7);
}
res["color_pen"] = color2string(pU->pen().color());
res["style_pen"] = QString("%1").arg(int(pU->pen().style()));
res["width_pen"] = QString("%1").arg(int(pU->pen().width()));
res["color_brush"] = color2string(pU->brush().color());
res["style_brush"] = QString("%1").arg(int(pU->brush().style()));
}
}
break;
default:
break;
}
QColor colorText = item->labelColor();
res["color_label"] = color2string(colorText);
int fsize = item->labelFont().pointSize();
res["size_label"] = QString("%1").arg(fsize);
int weight = item->labelFont().weight();
res["weight_label"] = QString("%1").arg(weight);
}
else
res["error"] = tr("the mark name.") + name + tr(" does not exist in current scene.");
return std::move(res);
}
/**
* @brief func_props is a internal function for plugin call_func "props"
*
* 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_props (const QMap<QString, QVariant> & paras)
{
//!name: user should specify these values or the function calll will fail;
QMap<QString, QVariant> res;
if (paras.contains("name")==false)
{
res["error"] = tr("name 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 * item = m_pScene->geoitem_by_name(name);
if (item)
{
QString x_name = item->item_name();
res["name"] = x_name;
int props = item->prop_counts();
QStringList lstNames = item->prop_names();
QVariantList lstValues = item->prop_values();
for (int i=0;i<props;++i)
res[lstNames[i]] = lstValues[i];
}
else
res["error"] = tr("the mark name.") + name + tr(" does not exist in current scene.");
//! return value is the user-defined key-pairs.
return std::move(res);
}
......@@ -152,7 +152,7 @@ void testcontainer::on_pushButton_test_layers_clicked()
{
QVariant vt_name = ui->axWidget_map1->dynamicCall("osm_layer_get_name(int)",i);
QString strname = vt_name.toString();
strLayerNames += strname + ";";
strLayerNames += strname + ";\n";
}
QMessageBox::information(this,"layer count",QString("osm_layer_get_count() returns %1\n%2").arg(n_num).arg(strLayerNames) );
......@@ -249,6 +249,8 @@ void testcontainer::on_pushButton_test_grid_getPolygon_clicked()
"osm_layer_call_function(QString,QString)",
"grid1",
"function=get_polygon;").toString();
res.replace(";",";\n");
res.replace("=","=\t");
QMessageBox::information(this,"grid1::get_polygon",res);
}
......@@ -374,3 +376,24 @@ void testcontainer::timerEvent(QTimerEvent * e)
}
}
void testcontainer::on_pushButton_test_request_clicked()
{
QString res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","geomarker1",
"function=mark_names;").toString();
res.replace(";",";\n");
res.replace("=","\t=");
QMessageBox::information(this,"geomarker1::mark_names",res);
res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","geomarker1",
"function=mark;name=ID1").toString();
res.replace(";",";\n");
res.replace("=","\t=");
QMessageBox::information(this,"geomarker1::mark",res);
res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","geomarker1",
"function=props;name=ID1").toString();
res.replace(";",";\n");
res.replace("=","\t=");
QMessageBox::information(this,"geomarker1::props",res);
}
......@@ -35,6 +35,7 @@ protected slots:
void on_pushButton_test_mark_clicked();
void on_pushButton_test_line_clicked();
void on_pushButton_test_polygon_clicked();
void on_pushButton_test_request_clicked();
};
#endif // TESTCONTAINER_H
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<width>811</width>
<height>600</height>
</rect>
</property>
......@@ -149,6 +149,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_test_request">
<property name="text">
<string>request</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册