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

1. change "region" to "polygon". region is not a same type of concept as "point" and "line"

2. set 3 method, perpare for call_func.
Signed-off-by: 丁劲犇's avatargoldenhawking <goldenhawking@163.com>
上级 b6ec4a2d
......@@ -95,7 +95,7 @@ namespace QTVOSM
virtual void set_visible(bool /*vb*/) {}
public:
//user-def direct function calls
virtual QMap<QString, QVariant> call_func(const QMap<QString, QVariant> /*paras*/){return std::move( QMap<QString, QVariant>());}
virtual QMap<QString, QVariant> call_func(const QMap<QString, QVariant> & /*paras*/){return std::move( QMap<QString, QVariant>());}
};
......
......@@ -387,7 +387,7 @@ QMap<QString, QVariant> qtaxviewer_planetosm::string_to_map(const QString & s)
* @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_region;x=38.43834784;y=16.3834754;
* eg, function=get_polygon;x=38.43834784;y=16.3834754;
* @return QString the result string is also formatted with key-vaslue para strings.
*/
QString qtaxviewer_planetosm::osm_layer_call_function(QString layerName, QString args)
......
......@@ -145,7 +145,7 @@
<translation>可见</translation>
</message>
<message>
<location filename="osm_frame_widget.cpp" line="390"/>
<location filename="osm_frame_widget.cpp" line="381"/>
<source>save to image</source>
<translation>保存到图像</translation>
</message>
......
......@@ -10,7 +10,7 @@ namespace QTVP_GEOMARKER{
QString name,
QTVOSM::viewer_interface * pVi,const QPolygonF & lla_polygon)
:QGraphicsPolygonItem(0)
,geoItemBase(name,QTVP_GEOMARKER::ITEAMTYPE_REGION,pVi)
,geoItemBase(name,QTVP_GEOMARKER::ITEAMTYPE_POLYGON,pVi)
{
assert(vi()!=0);
m_llap = lla_polygon;
......
......@@ -17,7 +17,7 @@ namespace QTVP_GEOMARKER{
ITEAMTYPE_ELLIPSE_POINT = 1,
ITEAMTYPE_RECT_POINT = 2,
ITEAMTYPE_LINE = 3,
ITEAMTYPE_REGION = 4
ITEAMTYPE_POLYGON = 4
};
inline const QString & item_name_by_enum(geo_item_type tp)
{
......@@ -26,7 +26,7 @@ namespace QTVP_GEOMARKER{
"ELLIPSE_POINT",
"RECT_POINT",
"LINE",
"REGION"
"POLYGON"
};
return names[(int)tp];
}
......
......@@ -449,7 +449,7 @@ QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_line(const QString &
}
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_region (const QString & name,const QPolygonF latlons, QPen pen, QBrush brush)
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_polygon (const QString & name,const QPolygonF latlons, QPen pen, QBrush brush)
{
QTVP_GEOMARKER::geoItemBase * res = 0;
//Get raw Item by name
......
......@@ -16,14 +16,14 @@ namespace Ui {
using namespace QTVOSM;
/*!
\brief qtvplugin_geomarker introduces QGraphicesView system, established a common approach for geo marking.
GEO marker is a vector symbol displays on the background OSM raster map. there are 3 different mark types supported by this plugin.
1. Point Marks. Include ellipse and rect style mark. these type of mark stand for a single point on earth, with a specified lat, lon .the with and height
for rect / ellipse circumrect can be specified by user at runtime, in PIXEL. with and height will stay still during map zoom.
GEO marker is a vector symbol that will be displayed on the background OSM raster map. there are 3 different mark types supported by this plugin.
1. Point Marks. Include ellipse and rect style mark. these type of mark stand for a single point on earth, with a specified lat, lon .the width and height
for rect / ellipse circumrect can be specified by user at runtime, in PIXEL. width and height will stay still during map zoom.
2. Line Mark. Line mark is a beeline on map. ATTENTION, in Mercator Projection system, the geo shortest path between 2 points on earth is NOT a beeline, that means
beeline on a map is just for display performance and accessibility. the real path is a curve , which has 2 point of intersections exactly at start position and end position.
3. Polygon (Region) Mark. Polygon mark is a region on map. borders of a region is painted with lines, for a same reason above, the geo shortest path between 2 points on earth is NOT a beeline either.
3. Polygon (Polygon) Mark. Polygon mark is a polygon on map. borders of a polygon is painted with lines, for a same reason above, the geo shortest path between 2 points on earth is NOT a beeline either.
Marks above shares a same style system provided by Qt painter system. pen, brush , font can be setted for each mark.
......@@ -105,10 +105,13 @@ private:
//Geo mark updating functions
private:
template <class T>
QTVP_GEOMARKER::geoItemBase * update_point (const QString & name,double lat, double lon, int width, int height, QPen pen, QBrush brush);
QTVP_GEOMARKER::geoItemBase * update_line (const QString & name,double lat1, double lon1,double lat2, double lon2, QPen pen);
QTVP_GEOMARKER::geoItemBase * update_region (const QString & name,const QPolygonF latlons, QPen pen, QBrush brush);
bool update_mark(tag_xml_mark & mark);
QTVP_GEOMARKER::geoItemBase * update_point (const QString & name,double lat, double lon, int width, int height, QPen pen, QBrush brush);
QTVP_GEOMARKER::geoItemBase * update_point (const QMap<QString, QVariant> &);
QTVP_GEOMARKER::geoItemBase * update_line (const QString & name,double lat1, double lon1,double lat2, double lon2, QPen pen);
QTVP_GEOMARKER::geoItemBase * update_line (const QMap<QString, QVariant> &);
QTVP_GEOMARKER::geoItemBase * update_polygon (const QString & name,const QPolygonF latlons, QPen pen, QBrush brush);
QTVP_GEOMARKER::geoItemBase * update_polygon (const QMap<QString, QVariant> &);
bool update_mark (tag_xml_mark & mark);
//overloaded virtual funtions
protected:
......@@ -127,7 +130,7 @@ protected:
bool cb_event(const QMap<QString, QVariant>);
void timerEvent(QTimerEvent * e);
QMap<QString, QVariant> call_func(const QMap<QString, QVariant> /*paras*/);
QMap<QString, QVariant> call_func(const QMap<QString, QVariant> & /*paras*/);
//ui slots
protected slots:
......@@ -144,7 +147,7 @@ protected slots:
void on_pushButton_del_clicked();
void on_pushButton_pickToLine1_clicked();
void on_pushButton_pickToLine2_clicked();
void on_pushButton_getRegion_clicked();
void on_pushButton_getPolygon_clicked();
void on_pushButton_save_clicked();
void on_pushButton_load_clicked();
};
......
......@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Grid</string>
<string>geoMarker</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<property name="spacing">
......@@ -349,7 +349,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="page_region">
<widget class="QWidget" name="page_polygon">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_13">
......@@ -381,9 +381,9 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_getRegion">
<widget class="QPushButton" name="pushButton_getPolygon">
<property name="text">
<string>Call Region Get</string>
<string>Call Polygon Get</string>
</property>
</widget>
</item>
......
......@@ -17,7 +17,7 @@
* @param paras the key-value style paraments.
* @return QMap<QString, QVariant> the key-value style return values.
*/
QMap<QString, QVariant> qtvplugin_geomarker::call_func(const QMap<QString, QVariant> paras)
QMap<QString, QVariant> qtvplugin_geomarker::call_func(const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
if (paras.contains("function"))
......@@ -25,13 +25,17 @@ QMap<QString, QVariant> qtvplugin_geomarker::call_func(const QMap<QString, QVar
QString funct = paras["function"].toString();
if (funct=="update_point")
{
update_point(paras);
}
else if (funct=="update_line")
{
update_line(paras);
}
else if (funct=="update_polygon")
{
update_polygon(paras);
}
else if (funct=="update_prop")
{
}
......@@ -136,7 +140,7 @@ bool qtvplugin_geomarker::saveToXml(QString xml)
}
}
break;
case QTVP_GEOMARKER::ITEAMTYPE_REGION:
case QTVP_GEOMARKER::ITEAMTYPE_POLYGON:
{
QTVP_GEOMARKER::geoGraphicsPolygonItem * pU = dynamic_cast<QTVP_GEOMARKER::geoGraphicsPolygonItem *>(item);
if (pU)
......@@ -439,9 +443,9 @@ bool qtvplugin_geomarker::update_mark(tag_xml_mark & mark)
double lon2 = mark.geoPoints.last().x();
newitem = update_line(name,lat1,lon1,lat2,lon2,pen);
}
else if (mark.type==QTVP_GEOMARKER::ITEAMTYPE_REGION)
else if (mark.type==QTVP_GEOMARKER::ITEAMTYPE_POLYGON)
{
newitem = update_region(name,mark.geoPoints,pen,brush);
newitem = update_polygon(name,mark.geoPoints,pen,brush);
}
else
return false;
......@@ -467,3 +471,16 @@ bool qtvplugin_geomarker::update_mark(tag_xml_mark & mark)
return true;
}
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_point (const QMap<QString, QVariant> & paras)
{
return 0;
}
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_line (const QMap<QString, QVariant> & paras)
{
return 0;
}
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_polygon (const QMap<QString, QVariant> & paras)
{
return 0;
}
......@@ -336,7 +336,7 @@ void qtvplugin_geomarker::on_pushButton_update_clicked()
latlons.push_back(ll);
}
if (latlons.size())
newitem = update_region(name,latlons,pen,brush);
newitem = update_polygon(name,latlons,pen,brush);
}
else
......@@ -433,7 +433,7 @@ void qtvplugin_geomarker::on_tableView_marks_doubleClicked(const QModelIndex & i
}
}
void qtvplugin_geomarker::on_pushButton_getRegion_clicked()
void qtvplugin_geomarker::on_pushButton_getPolygon_clicked()
{
if (!m_pVi) return;
QString strGridName = QString("grid%1").arg(m_nInstance);
......@@ -441,7 +441,7 @@ void qtvplugin_geomarker::on_pushButton_getRegion_clicked()
if (pif)
{
QMap<QString, QVariant> inPara, outPara;
inPara["function"] = "get_region";
inPara["function"] = "get_polygon";
outPara = pif->call_func(inPara);
QString strPlainText = "";
if (outPara.contains("size"))
......@@ -513,7 +513,7 @@ void qtvplugin_geomarker::refreshItemUI(QString markname)
ui->radioButton_tool_line->setChecked(true);
}
break;
case QTVP_GEOMARKER::ITEAMTYPE_REGION:
case QTVP_GEOMARKER::ITEAMTYPE_POLYGON:
{
QTVP_GEOMARKER::geoGraphicsPolygonItem * pitem = dynamic_cast<QTVP_GEOMARKER::geoGraphicsPolygonItem *>(item);
if (!pitem)
......
......@@ -3,13 +3,9 @@
<TS version="2.1" language="zh_CN">
<context>
<name>qtvplugin_geomarker</name>
<message>
<source>Grid</source>
<translation></translation>
</message>
<message>
<source>Marks</source>
<translation>标记</translation>
<translation>标记</translation>
</message>
<message>
<source>points</source>
......@@ -45,15 +41,15 @@
</message>
<message>
<source>width</source>
<translation>宽度</translation>
<translation>像素宽</translation>
</message>
<message>
<source>height</source>
<translation>高度</translation>
<translation>像素高</translation>
</message>
<message>
<source>Edge color</source>
<translation>描边色彩</translation>
<translation type="vanished">描边色彩</translation>
</message>
<message>
<source>...</source>
......@@ -91,26 +87,18 @@
<source>Lon2</source>
<translation></translation>
</message>
<message>
<source>pad</source>
<translation></translation>
</message>
<message>
<source>color</source>
<translation>色彩</translation>
<translation type="vanished">色彩</translation>
</message>
<message>
<source>corner Points</source>
<translation>顶点</translation>
</message>
<message>
<source>Call Region Get</source>
<source>Call Polygon Get</source>
<translation>获取当前区域</translation>
</message>
<message>
<source>Save Data</source>
<translation></translation>
</message>
<message>
<source>Properties</source>
<translation>属性</translation>
......@@ -143,5 +131,105 @@
<source>Select Color</source>
<translation>选择色彩</translation>
</message>
<message>
<source>Save</source>
<translation>保存XML</translation>
</message>
<message>
<source>Load</source>
<translation>加载XML</translation>
</message>
<message>
<source>Pen width</source>
<translation>笔像素宽</translation>
</message>
<message>
<source>Pen Style</source>
<translation>笔风格</translation>
</message>
<message>
<source>Pen Color</source>
<translation>笔色彩</translation>
</message>
<message>
<source>Text Color</source>
<translation>文本色彩</translation>
</message>
<message>
<source>weight</source>
<translation>文本粗细</translation>
</message>
<message>
<source>Fill Style</source>
<translation>填充风格</translation>
</message>
<message>
<source>Font Size</source>
<translation>字号</translation>
</message>
<message>
<source>Version must &gt;=1.0.</source>
<translation>本XML版本号必须&gt;=1.0.</translation>
</message>
<message>
<source>This XML is not a geomarker format file.</source>
<translation>这不是一个正确的 geomarker 格式文件</translation>
</message>
<message>
<source>Empty XML.</source>
<translation>XML 没有有效信息</translation>
</message>
<message>
<source>mark name is null or type error .</source>
<translation>类型错误或者标记名称 name 字段为空</translation>
</message>
<message>
<source>coords is 0 .</source>
<translation>坐标为0.</translation>
</message>
<message>
<source>missing geo coords .</source>
<translation>地理坐标不足</translation>
</message>
<message>
<source>save to xml</source>
<translation>导出到XML</translation>
</message>
<message>
<source>succeed</source>
<translation>成功</translation>
</message>
<message>
<source>Successfully saved XML file</source>
<translation>保存XML成功</translation>
</message>
<message>
<source>failed</source>
<translation>失败</translation>
</message>
<message>
<source>Save XML file</source>
<translation>保存XML文件</translation>
</message>
<message>
<source> Failed</source>
<translation>失败</translation>
</message>
<message>
<source>load from xml</source>
<translation>从XML加载</translation>
</message>
<message>
<source>Successfully load XML file</source>
<translation>成功从XML文件加载数据</translation>
</message>
<message>
<source>Load XML file</source>
<translation>加载XML数据</translation>
</message>
<message>
<source>geoMarker</source>
<translation>标记工具插件</translation>
</message>
</context>
</TS>
......@@ -642,7 +642,7 @@ double qtvplugin_grid::CalDistance(double dLatStart,double dLatEnd,double dLonSt
/**
* function calls avaliable:
* 1.function=get_region, no other para needed. returns current selected region's cornor points, in lat, lon; size=N;lat0=XX;lon0=XX;
* 1.function=get_polygon, no other para needed. returns current selected polygon's cornor points, in lat, lon; size=N;lat0=XX;lon0=XX;
* lat1=XX;lon1=XX;lat2=XX;lon2=XX;...;latN-1=XX;lonN-1=XX.
* 2.function=get_ruler_status, no other para needed.returns whether ruler tool is active now, status=0 means not active, status=-1 means active.
* 3.function=set_ruler_status, with para status, will set ruler status to given value.
......@@ -651,13 +651,13 @@ double qtvplugin_grid::CalDistance(double dLatStart,double dLatEnd,double dLonSt
* @param paras the key-value style paraments.
* @return QMap<QString, QVariant> the key-value style return paraments.
*/
QMap<QString, QVariant> qtvplugin_grid::call_func(const QMap<QString, QVariant> paras)
QMap<QString, QVariant> qtvplugin_grid::call_func(const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
if (paras.contains("function"))
{
QString funct = paras["function"].toString();
if (funct=="get_region")
if (funct=="get_polygon")
{
int Count = m_list_points.size();
res["size"] = Count;
......
......@@ -11,7 +11,7 @@ namespace Ui {
}
using namespace QTVOSM;
/*! qtvplugin_grid support distance and area measuring. function calls avaliable:
1.function=get_region, no other para needed. returns current selected region's cornor points, in lat, lon; size=N;lat0=XX;lon0=XX;
1.function=get_polygon, no other para needed. returns current selected polygon's cornor points, in lat, lon; size=N;lat0=XX;lon0=XX;
lat1=XX;lon1=XX;lat2=XX;lon2=XX;...;latN-1=XX;lonN-1=XX.
2.function=get_ruler_status, no other para needed.returns whether ruler tool is active now, status=0 means not active, status=-1 means active.
3.function=set_ruler_status, with para status, will set ruler status to given value.
......@@ -33,7 +33,7 @@ public:
QString get_name();
void set_name(QString vb);
QWidget * get_propWindow() {return this;}
QMap<QString, QVariant> call_func(const QMap<QString, QVariant> /*paras*/);
QMap<QString, QVariant> call_func(const QMap<QString, QVariant> & /*paras*/);
private:
int m_nInstance;
//International Translator
......
......@@ -185,18 +185,18 @@ void testcontainer::on_pushButton_test_grid_enable_clicked()
if (mres["status"].toInt())
{
res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","grid1","function=set_ruler_status;status=0;").toString();
QMessageBox::information(this,"grid1::set_ruler_status to false, you can call get_region to get region strings..",res);
QMessageBox::information(this,"grid1::set_ruler_status to false, you can call get_polygon to get polygon strings..",res);
}
else
{
res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","grid1","function=set_ruler_status;status=-1;").toString();
QMessageBox::information(this,"grid1::set_ruler_status to true, you can draw regions on map using mouse lbutton for begin and rbutton for end.",res);
QMessageBox::information(this,"grid1::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_getRegion_clicked()
void testcontainer::on_pushButton_test_grid_getPolygon_clicked()
{
QString res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","grid1","function=get_region;").toString();
QMessageBox::information(this,"grid1::get_region",res);
QString res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)","grid1","function=get_polygon;").toString();
QMessageBox::information(this,"grid1::get_polygon",res);
}
......@@ -29,7 +29,7 @@ protected slots:
void on_pushButton_test_layers_clicked();
void on_pushButton_test_layer_move_clicked();
void on_pushButton_test_grid_enable_clicked();
void on_pushButton_test_grid_getRegion_clicked();
void on_pushButton_test_grid_getPolygon_clicked();
};
#endif // TESTCONTAINER_H
......@@ -122,9 +122,9 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_test_grid_getRegion">
<widget class="QPushButton" name="pushButton_test_grid_getPolygon">
<property name="text">
<string>grid_region</string>
<string>grid_polygon</string>
</property>
</widget>
</item>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册