qtvplugin_geomarker_func.cpp 56.1 KB
Newer Older
丁劲犇's avatar
丁劲犇 已提交
1 2
#include "qtvplugin_geomarker.h"
#include "ui_qtvplugin_geomarker.h"
3 4 5 6
#include "geographicsellipseitem.h"
#include "geographicslineitem.h"
#include "geographicspolygonitem.h"
#include "geographicsrectitem.h"
7
#include "geographicsmultilineitem.h"
8 9
#include <QDebug>
#include <QMap>
丁劲犇's avatar
丁劲犇 已提交
10 11 12 13 14
/**
 * geomarker supports these function calls.
 *
 *
 *	ATTENTION!THIS FUNCTION IS NOT THREAD SAFE! Calls should be made only in main thread, also called "UI Thread"
15
 * Supported fucntions:
16 17 18
 * 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.
19 20 21 22 23 24 25 26
 * 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.
27 28 29
 * 12.add_resource		add an resource (eg, icon) to current resource list. icon mark can reference icons in current resource list.
 * 13 save_resources		save current resource list to disk files.
 * 14 load_resources		load previewsly saved list file from disk to current resource list.
丁劲犇's avatar
丁劲犇 已提交
30 31 32 33
 * 15 load_xml			load xml from diskette
 * 16 sava_xml			save marks to diskette in xml format
 * 17 props_vis(ibiliuty)	collapse detail display for items.
 * 18 show_props		show_details
丁劲犇's avatar
丁劲犇 已提交
34 35 36 37
 * 19 set_mod			set current mod.0=display, 1 = rect selection
 * 20 selection_clear	clear all selected items' status.
 * 21 selection_delete	delete all selected items.
 * 22 selected_items	return all selected item names
38 39
 * 23 set_default_style	will set default style for item mark
 * 24 default_style		will return current default style
丁劲犇's avatar
丁劲犇 已提交
40 41 42
 * @param paras	the key-value style paraments.
 * @return QMap<QString, QVariant>	the key-value style return values.
 */
43
QMap<QString, QVariant> qtvplugin_geomarker::call_func(const  QMap<QString, QVariant> & paras)
丁劲犇's avatar
丁劲犇 已提交
44 45 46 47 48
{
	QMap<QString, QVariant> res;
	if (paras.contains("function"))
	{
		QString funct = paras["function"].toString();
49 50
		if (m_map_pluginFunctions.contains(funct))
			res = m_map_pluginFunctions[funct](paras);
丁劲犇's avatar
丁劲犇 已提交
51 52 53 54 55 56 57
		else
			res["error"] = QString("unknown function \"%1\".").arg(funct);
	}
	else
		res["error"] = "\"function\" keyword not specified, nothing to do.";
	return std::move(res);
}
58

59 60 61 62
/**
 * @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.
 */
63
void qtvplugin_geomarker::initialBindPluginFuntions()
64
{
65 66 67
	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);
68
	m_map_pluginFunctions["update_icon"]	= std::bind(&qtvplugin_geomarker::func_update_icon,		this,std::placeholders::_1);
69 70 71 72 73 74 75
	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);
76 77
	m_map_pluginFunctions["load_xml"]		= std::bind(&qtvplugin_geomarker::func_load_xml,		this,std::placeholders::_1);
	m_map_pluginFunctions["save_xml"]		= std::bind(&qtvplugin_geomarker::func_save_xml,		this,std::placeholders::_1);
丁劲犇's avatar
丁劲犇 已提交
78
	m_map_pluginFunctions["add_resource"]	= std::bind(&qtvplugin_geomarker::func_add_resource,	this,std::placeholders::_1);
79 80
	m_map_pluginFunctions["save_resources"]	= std::bind(&qtvplugin_geomarker::func_save_resources,	this,std::placeholders::_1);
	m_map_pluginFunctions["load_resources"]	= std::bind(&qtvplugin_geomarker::func_load_resources,	this,std::placeholders::_1);
丁劲犇's avatar
丁劲犇 已提交
81 82
	m_map_pluginFunctions["props_vis"]		= std::bind(&qtvplugin_geomarker::func_props_vis,		this,std::placeholders::_1);
	m_map_pluginFunctions["show_props"]		= std::bind(&qtvplugin_geomarker::func_show_props,		this,std::placeholders::_1);
丁劲犇's avatar
丁劲犇 已提交
83 84 85 86
	m_map_pluginFunctions["set_mod"]		= std::bind(&qtvplugin_geomarker::func_set_mod,	this,std::placeholders::_1);
	m_map_pluginFunctions["selection_clear"]= std::bind(&qtvplugin_geomarker::func_selection_clear,	this,std::placeholders::_1);
	m_map_pluginFunctions["selection_delete"]=std::bind(&qtvplugin_geomarker::func_selection_delete,this,std::placeholders::_1);
	m_map_pluginFunctions["selected_items"]	= std::bind(&qtvplugin_geomarker::func_selected_items,	this,std::placeholders::_1);
87 88
	m_map_pluginFunctions["set_default_style"]=std::bind(&qtvplugin_geomarker::func_set_default_style,this,std::placeholders::_1);
	m_map_pluginFunctions["default_style"]	= std::bind(&qtvplugin_geomarker::func_default_style,	this,std::placeholders::_1);
89
}
90

91 92 93 94 95 96 97 98
/**
 * @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.
 */
99
QMap<QString, QVariant> qtvplugin_geomarker::func_update_point		(const QMap<QString, QVariant> & paras)
100
{
101
	QMap<QString, QVariant> res;
102
	//!name, lat, lon has no default values. user should specify these values or the function calll will fail;
丁劲犇's avatar
丁劲犇 已提交
103 104 105 106 107 108
	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);

	}
丁劲犇's avatar
丁劲犇 已提交
109 110
	QString name = paras["name"].toString();
	if (name.size()==0)
111
	{
丁劲犇's avatar
丁劲犇 已提交
112
		res["error"] = tr("name could not be empty.");
113 114
		return std::move(res);
	}
丁劲犇's avatar
丁劲犇 已提交
115
	QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
116 117 118 119
	QPen pen (m_default_style.pen);
	QBrush brush (m_default_style.brush);
	qreal width = m_default_style.n_point_width;
	qreal height =  m_default_style.n_point_height;
120
	//if the mark is already exist, we will get its orgional style as default .
丁劲犇's avatar
丁劲犇 已提交
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
	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();
			}
		}
	}
146 147

	//! style_pen from 0~6, is corresponds to the pen combo-box in UI system.
丁劲犇's avatar
丁劲犇 已提交
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
	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]);
	}
165
	//! color_pen has 4 pen color band values splitted by comma, r,g,b,a
丁劲犇's avatar
丁劲犇 已提交
166 167 168 169 170 171
	if ( paras.contains("color_pen"))
	{
		QColor penColor = string2color( paras["color_pen"].toString());
		pen.setColor(penColor);

	}
172
	//! width_pen has a value >0 , stand for the point width of the pen on screen.
丁劲犇's avatar
丁劲犇 已提交
173 174 175 176 177 178 179
	if ( paras.contains("width_pen"))
	{
		int penWidth =paras["width_pen"].toInt();
		if (penWidth<0)	penWidth = 1;
		pen.setWidth(penWidth);

	}
180
	//! style_brush from 0~14, is corresponds to the brush style combo-box in UI system.
丁劲犇's avatar
丁劲犇 已提交
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
	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]);
	}
205 206

	//! color_brush has 4 brush color band values splitted by comma, r,g,b,a
丁劲犇's avatar
丁劲犇 已提交
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
	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;
224 225
	/*! geo coordinate in WGS84 lattitude, longitude should be saved as lat and lon.
	*/
丁劲犇's avatar
丁劲犇 已提交
226 227 228
	double lat =paras["lat"].toDouble();
	double lon = paras["lon"].toDouble();

229 230 231
	int tpn = m_default_style.n_point_rect == 0 ? 2:1;
	if (paras.contains("type"))
			tpn = paras["type"].toInt();
丁劲犇's avatar
丁劲犇 已提交
232
	if (tpn > 2 || tpn <1) tpn = 1;
丁劲犇's avatar
丁劲犇 已提交
233
	QTVP_GEOMARKER::geo_item_type tpe = static_cast< QTVP_GEOMARKER::geo_item_type > (tpn);
234
	//update using same function in UI
丁劲犇's avatar
丁劲犇 已提交
235 236 237 238
	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);
239 240
	if (newitem)
	{
241
		QFont f ( m_default_style.font );
242
		//! size_label stands for the text label font pixel size from 1 - 720, with a normal value 9.
243 244 245 246 247 248
		if ( paras.contains("size_label"))
		{
			int fontSz = paras["size_label"].toInt();
			if (fontSz==0)	fontSz = 9;
			f.setPointSize(fontSz);
		}
249
		//! weight_label is the bolder rate for  text renderring, from 1 ~ 99, 99 is the heaviest.
250 251 252 253 254 255
		if ( paras.contains("weight_label"))
		{
			int fontWeight = paras["weight_label"].toInt();
			f.setWeight(fontWeight);
		}
		newitem->setLabelFont(f);
256
		//! color_label has 4 text color band values splitted by comma, r,g,b,a
257 258 259 260 261
		if ( paras.contains("color_label"))
		{
			QColor textColor = string2color( paras["color_label"].toString());
			newitem->setLabelColor(textColor);
		}
262 263
		else
			newitem->setLabelColor(m_default_style.text_color);
264 265 266 267 268 269 270 271 272

		//! want_hover is the boolean para that tells the plugin this mark want mouse hover event.
		//! this is SLOW!
		if ( paras.contains("want_hover"))
		{
			bool want_hover = paras["want_hover"].toInt()==0?false:true;
			newitem->setWantMouseHoverEvent(want_hover);
		}

273
		//scheduleRefreshMarks();
274 275 276 277 278
		scheduleUpdateMap();
	}
	else
		res["error"] = tr("can not create graphical object, the pointer is zero.");
	return std::move(res);
279
}
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
/**
 * @brief func_update_icon is a internal function for plugin call_func "update_icon"
 *
 * the paraments used by paras is listed below.
 * function=update_icon;
 * @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_icon	(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.");
		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);
305 306 307 308
	QString icon_name = m_default_style.icon_name;
	qreal scale = m_default_style.scale;
	qreal rot = m_default_style.rotate;
	int smooth = m_default_style.smooth;
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
	//if the mark is already exist, we will get its orgional style as default .
	if (base)
	{
		QTVP_GEOMARKER::geoGraphicsPixmapItem * it = dynamic_cast<QTVP_GEOMARKER::geoGraphicsPixmapItem * >(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)
	{
355
		QFont f (m_default_style.font);
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
		//! 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);
		}
376 377
		else
			newitem->setLabelColor( m_default_style.text_color);
378 379 380 381 382 383 384
		//! want_hover is the boolean para that tells the plugin this mark want mouse hover event.
		//! this is SLOW!
		if ( paras.contains("want_hover"))
		{
			bool want_hover = paras["want_hover"].toInt()==0?false:true;
			newitem->setWantMouseHoverEvent(want_hover);
		}
385
		//scheduleRefreshMarks();
386 387 388 389 390 391 392
		scheduleUpdateMap();
	}
	else
		res["error"] = tr("can not create graphical object, the pointer is zero.");
	return std::move(res);
}

393 394 395 396 397 398 399 400
/**
 * @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.
 */
401
QMap<QString, QVariant>  qtvplugin_geomarker::func_update_line		(const QMap<QString, QVariant> & paras)
402
{
403
	QMap<QString, QVariant> res;
404
	//!name, lat0, lon0, lat1,lon1 has no default values. user should specify these values or the function calll will fail;
丁劲犇's avatar
丁劲犇 已提交
405 406 407 408 409 410 411
	if (paras.contains("name")==false || paras.contains("lat0")==false || paras.contains("lon0")==false
			|| paras.contains("lat1")==false || paras.contains("lon1")==false)
	{
		res["error"] = tr("name, lat0, lon0,lat1,lon1 must  exist in paraments.");
		return std::move(res);
	}

丁劲犇's avatar
丁劲犇 已提交
412 413
	QString name = paras["name"].toString();
	if (name.size()==0)
414
	{
丁劲犇's avatar
丁劲犇 已提交
415
		res["error"] = tr("name could not be empty.");
416 417
		return std::move(res);
	}
丁劲犇's avatar
丁劲犇 已提交
418
	QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
419
	QPen pen (m_default_style.pen);
420 421

	//if the mark is already exist, we will get its orgional style as default .
丁劲犇's avatar
丁劲犇 已提交
422 423 424 425 426 427 428 429 430
	if (base)
	{
		if (base->item_type()==QTVP_GEOMARKER::ITEAMTYPE_LINE)
		{
			QTVP_GEOMARKER::geoGraphicsLineItem * it = dynamic_cast<QTVP_GEOMARKER::geoGraphicsLineItem * >(base);
				pen = it->pen();
		}

	}
431 432

	//! style_pen from 0~6, is corresponds to the pen combo-box in UI system.
丁劲犇's avatar
丁劲犇 已提交
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
	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]);
	}
450
	//! color_pen has 4 pen color band values splitted by comma, r,g,b,a
丁劲犇's avatar
丁劲犇 已提交
451 452 453 454 455 456
	if ( paras.contains("color_pen"))
	{
		QColor penColor = string2color( paras["color_pen"].toString());
		pen.setColor(penColor);

	}
457
	//! width_pen has a value >0 , stand for the point width of the pen on screen.
丁劲犇's avatar
丁劲犇 已提交
458 459 460 461 462 463 464 465 466
	if ( paras.contains("width_pen"))
	{
		int penWidth =paras["width_pen"].toInt();
		if (penWidth<0)	penWidth = 1;
		pen.setWidth(penWidth);

	}

	QTVP_GEOMARKER::geoItemBase * newitem = 0;
467 468 469
	/*! geo coordinates in WGS84 lattitude, longitude should be saved like this:
	 * lat0, lon0 stand for point1, lat1,lon1 stand for point2
	*/
470 471 472 473
	double lat1 =paras["lat0"].toDouble();
	double lon1 = paras["lon0"].toDouble();
	double lat2 =paras["lat1"].toDouble();
	double lon2 = paras["lon1"].toDouble();
474
	//update using same function in UI
丁劲犇's avatar
丁劲犇 已提交
475
	newitem = update_line(name,lat1,lon1,lat2,lon2,pen);
476 477
	if (newitem)
	{
478
		QFont f (m_default_style.font);
479
		//! size_label stands for the text label font pixel size from 1 - 720, with a normal value 9.
480 481 482 483 484 485
		if ( paras.contains("size_label"))
		{
			int fontSz =paras["size_label"].toInt();
			if (fontSz==0)	fontSz = 9;
			f.setPointSize(fontSz);
		}
486
		//! weight_label is the bolder rate for  text renderring, from 1 ~ 99, 99 is the heaviest.
487 488 489 490 491 492
		if ( paras.contains("weight_label"))
		{
			int fontWeight = paras["weight_label"].toInt();
			f.setWeight(fontWeight);
		}
		newitem->setLabelFont(f);
493
		//! color_label has 4 text color band values splitted by comma, r,g,b,a
494 495 496 497 498
		if ( paras.contains("color_label"))
		{
			QColor textColor = string2color( paras["color_label"].toString());
			newitem->setLabelColor(textColor);
		}
499 500
		else
			newitem->setLabelColor(m_default_style.text_color);
501 502 503 504 505 506 507
		//! want_hover is the boolean para that tells the plugin this mark want mouse hover event.
		//! this is SLOW!
		if ( paras.contains("want_hover"))
		{
			bool want_hover = paras["want_hover"].toInt()==0?false:true;
			newitem->setWantMouseHoverEvent(want_hover);
		}
508
		//scheduleRefreshMarks();
509 510 511 512 513 514
		scheduleUpdateMap();
	}
	else
		res["error"] = tr("can not create graphical object, the pointer is zero.");
	return std::move(res);

515
}
516 517 518 519 520 521 522 523 524

/**
 * @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.
 */
525
QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon		(const QMap<QString, QVariant> & paras)
526
{
527
	QMap<QString, QVariant> res;
528
	//!name, latn, lonn, has no default values, n>=3. user should specify these values or the function calll will fail;
丁劲犇's avatar
丁劲犇 已提交
529 530 531 532 533 534 535
	if (paras.contains("name")==false)
	{
		res["error"] = tr("name must  exist in paraments.");
		return std::move(res);
	}


丁劲犇's avatar
丁劲犇 已提交
536 537
	QString name = paras["name"].toString();
	if (name.size()==0)
538
	{
丁劲犇's avatar
丁劲犇 已提交
539
		res["error"] = tr("name could not be empty.");
540 541
		return std::move(res);
	}
542

543
	int type = m_default_style.multiline==0?4:6;//polygon
544 545 546 547 548 549 550 551 552 553 554 555
	if (paras.contains("type")==true)
	{
		type = paras["type"].toInt();
	}

	if (name.size()==0)
	{
		res["error"] = tr("name could not be empty.");
		return std::move(res);
	}


丁劲犇's avatar
丁劲犇 已提交
556
	QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
557 558
	QPen pen(m_default_style.pen);
	QBrush brush(m_default_style.brush);
559 560

	//if the mark is already exist, we will get its orgional style as default .
丁劲犇's avatar
丁劲犇 已提交
561 562
	if (base)
	{
563
		if (base->item_type()==QTVP_GEOMARKER::ITEAMTYPE_POLYGON && type !=6)
丁劲犇's avatar
丁劲犇 已提交
564 565 566 567 568 569 570 571
		{
			QTVP_GEOMARKER::geoGraphicsPolygonItem * it = dynamic_cast<QTVP_GEOMARKER::geoGraphicsPolygonItem * >(base);
			if (it)
			{
				pen = it->pen();
				brush = it->brush();
			}
		}
572 573 574 575 576 577
		else if (base->item_type()==QTVP_GEOMARKER::ITEAMTYPE_MULTILINE && type !=4)
		{
			QTVP_GEOMARKER::geoGraphicsMultilineItem * it = dynamic_cast<QTVP_GEOMARKER::geoGraphicsMultilineItem * >(base);
			if (it)
				pen = it->pen();
		}
丁劲犇's avatar
丁劲犇 已提交
578 579

	}
580 581

	//! style_pen from 0~6, is corresponds to the pen combo-box in UI system.
丁劲犇's avatar
丁劲犇 已提交
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
	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]);
	}
599 600

	//! color_pen has 4 pen color band values splitted by comma, r,g,b,a
丁劲犇's avatar
丁劲犇 已提交
601 602 603 604 605 606
	if ( paras.contains("color_pen"))
	{
		QColor penColor = string2color( paras["color_pen"].toString());
		pen.setColor(penColor);

	}
607
	//! width_pen has a value >0 , stand for the point width of the pen on screen.
丁劲犇's avatar
丁劲犇 已提交
608 609 610 611 612 613 614
	if ( paras.contains("width_pen"))
	{
		int penWidth =paras["width_pen"].toInt();
		if (penWidth<0)	penWidth = 1;
		pen.setWidth(penWidth);

	}
615
	//! style_brush from 0~14, is corresponds to the brush style combo-box in UI system.
丁劲犇's avatar
丁劲犇 已提交
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639
	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]);
	}
640
	//! color_brush has 4 brush color band values splitted by comma, r,g,b,a
丁劲犇's avatar
丁劲犇 已提交
641 642 643 644 645 646 647
	if ( paras.contains("color_brush"))
	{
		QColor brushColor = string2color( paras["color_brush"].toString());
		brush.setColor(brushColor);
	}

	QTVP_GEOMARKER::geoItemBase * newitem = 0;
648 649 650
	/*! 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.
	*/
丁劲犇's avatar
丁劲犇 已提交
651 652 653 654 655 656 657 658 659
	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));
660 661 662
		++ct;
		strKeyLat = QString("lat%1").arg(ct);
		strKeyLon = QString("lon%1").arg(ct);
丁劲犇's avatar
丁劲犇 已提交
663
	}
664
	//update using same function in UI
665 666
	if (pl.size()>2 || (type!=4 && pl.size()>1))
		newitem = update_polygon(name,pl,pen,brush,type==6?true:false);
丁劲犇's avatar
丁劲犇 已提交
667 668
	else
		res["error"] = tr("polygon must contain at least 3 points,lat0,lat1,lat2 and lon0,lon1, lon2.");
669 670 671

	if (newitem)
	{
672
		QFont f (m_default_style.font);
673
		//! size_label stands for the text label font pixel size from 1 - 720, with a normal value 9.
674 675 676 677 678 679
		if ( paras.contains("size_label"))
		{
			int fontSz = paras["size_label"].toInt();
			if (fontSz==0)	fontSz = 9;
			f.setPointSize(fontSz);
		}
680
		//! weight_label is the bolder rate for  text renderring, from 1 ~ 99, 99 is the heaviest.
681 682 683 684 685 686
		if ( paras.contains("weight_label"))
		{
			int fontWeight = paras["weight_label"].toInt();
			f.setWeight(fontWeight);
		}
		newitem->setLabelFont(f);
687
		//! color_label has 4 text color band values splitted by comma, r,g,b,a
688 689 690 691 692
		if ( paras.contains("color_label"))
		{
			QColor textColor = string2color( paras["color_label"].toString());
			newitem->setLabelColor(textColor);
		}
693 694
		else
			newitem->setLabelColor(m_default_style.text_color);
695 696 697 698 699 700 701
		//! want_hover is the boolean para that tells the plugin this mark want mouse hover event.
		//! this is SLOW!
		if ( paras.contains("want_hover"))
		{
			bool want_hover = paras["want_hover"].toInt()==0?false:true;
			newitem->setWantMouseHoverEvent(want_hover);
		}
702
		//scheduleRefreshMarks();
703 704 705 706 707 708 709
		scheduleUpdateMap();
	}
	else
		res["error"] = tr("can not create graphical object, the pointer is zero.");
	return std::move(res);

}
710 711 712 713 714 715 716 717 718

/**
 * @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.
 */
719 720 721
QMap<QString, QVariant> qtvplugin_geomarker::func_update_props(const QMap<QString, QVariant> & paras)
{
	QMap<QString, QVariant> res;
722
	//!name: user should specify these values or the function calll will fail;
723 724 725 726 727 728
	QString name = paras["name"].toString();
	if (name.size()==0)
	{
		res["error"] = tr("name does not exist in paraments.");
		return std::move(res);
	}
729 730 731 732
	/** 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.
	 */
733 734 735 736 737
	QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
	if (base)
	{
		foreach (QString key , paras.keys())
		{
丁劲犇's avatar
丁劲犇 已提交
738
			if (key!="name" && key!="function")
739 740
				base->set_prop_data(key,paras[key]);
		}
741 742 743 744 745
		if (base->props_visible())
		{
			base->show_props(false);
			base->show_props(true);
		}
746
		//scheduleRefreshMarks();
747
		scheduleUpdateMap();
748 749 750 751 752 753
	}
	else
		res["error"] = tr("name does not exist in scene.");

	return std::move(res);
}
754 755 756 757 758 759 760 761 762

/**
 * @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.
 */
763 764 765
QMap<QString, QVariant>			qtvplugin_geomarker::func_exists		(const QMap<QString, QVariant>  & paras)
{
	QMap<QString, QVariant> res;
766
	//!name: user should specify these values or the function calll will fail;
767 768 769 770 771 772 773 774 775 776 777 778 779
	QString name = paras["name"].toString();
	if (name.size()==0)
	{
		res["error"] = tr("name does not exist in paraments.");
		return std::move(res);
	}
	QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
	if (base)
	{
		res["return"] = 1;
	}
	else
		res["return"] = 0;
780
	//! return 1 means the mark name is exist, 0 mean not.
781
	return std::move(res);
782
}
783 784 785 786 787 788 789 790 791

/**
 * @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.
 */
丁劲犇's avatar
丁劲犇 已提交
792 793 794
QMap<QString, QVariant>			qtvplugin_geomarker::func_delete_marks	(const QMap<QString, QVariant> & paras)
{
	QMap<QString, QVariant> res;
795 796
	//! marknames should stored in parename name0, name1, name2
	//! for example, name0=StarBar;name1=ruijing Hospital;name2=shunfun express;
丁劲犇's avatar
丁劲犇 已提交
797 798 799 800 801 802 803 804
	QSet<QString> set_names;
	int ct = 0;
	do{
		QString keystr = QString("name%1").arg(ct++);
		if (paras.contains(keystr)==false)
			break;
		set_names.insert(paras[keystr].toString());
	}while (ct<1024*1024*1024);
丁劲犇's avatar
丁劲犇 已提交
805
	bool needUpdate = false;
丁劲犇's avatar
丁劲犇 已提交
806 807 808 809 810 811 812 813 814 815 816
	if (set_names.size())
	{
		ct = 0;
		foreach (QString key,set_names)
		{
			QString keystr = QString("name%1").arg(ct++);
			QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(key);
			if (base)
			{
				m_pScene->removeItem(base,0);
				res[keystr] = 1;
丁劲犇's avatar
丁劲犇 已提交
817
				needUpdate = true;
丁劲犇's avatar
丁劲犇 已提交
818 819 820 821 822 823 824 825 826 827 828
			}
			else
				res[keystr] = 0;
		}
	}
	else
	{
		QList< QTVP_GEOMARKER::geoItemBase *  > lst = m_pScene->geo_items();
		foreach (QTVP_GEOMARKER::geoItemBase * key,lst)
			m_pScene->removeItem(key,0);
		res["ALL"] = 1;
829 830
		needUpdate = true;
		scheduleRefreshMarks();
丁劲犇's avatar
丁劲犇 已提交
831
	}
丁劲犇's avatar
丁劲犇 已提交
832 833
	if (needUpdate)
	{
834
		//scheduleRefreshMarks();
丁劲犇's avatar
丁劲犇 已提交
835 836
		scheduleUpdateMap();
	}
丁劲犇's avatar
丁劲犇 已提交
837 838 839

	return std::move(res);
}
840 841 842 843 844 845 846 847
/**
 * @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.
 */
丁劲犇's avatar
丁劲犇 已提交
848 849 850
QMap<QString, QVariant>			qtvplugin_geomarker::func_delete_props	(const QMap<QString, QVariant> & paras)
{
	QMap<QString, QVariant> res;
851
	//!name: user should specify these values or the function calll will fail;
丁劲犇's avatar
丁劲犇 已提交
852 853 854 855 856 857 858 859 860 861 862
	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);
	}
863 864 865 866 867 868
	/*!
	 * 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;
	 */
丁劲犇's avatar
丁劲犇 已提交
869
	QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
丁劲犇's avatar
丁劲犇 已提交
870
	bool needUpdate = false;
丁劲犇's avatar
丁劲犇 已提交
871 872 873 874 875 876 877 878 879
	if (base)
	{
		int ct = 0;
		do{
			QString keystr = QString("prop%1").arg(ct++);
			if (paras.contains(keystr)==false)
				break;
			QString prop_name = paras[keystr].toString();
			base->del_prop(prop_name);
丁劲犇's avatar
丁劲犇 已提交
880
			needUpdate = true;
丁劲犇's avatar
丁劲犇 已提交
881 882 883 884 885
		}while (ct<1024*1024*1024);
	}
	else
		res["error"] = tr("the mark name.") + name + tr(" does not exist in current scene.");

丁劲犇's avatar
丁劲犇 已提交
886 887
	if (needUpdate)
	{
888 889 890 891 892
		if (base->props_visible())
		{
			base->show_props(false);
			base->show_props(true);
		}
893
		//scheduleRefreshMarks();
894
		scheduleUpdateMap();
丁劲犇's avatar
丁劲犇 已提交
895
	}
丁劲犇's avatar
丁劲犇 已提交
896 897 898
	return std::move(res);
}

899 900 901 902 903 904 905 906
/**
 * @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.
 */
丁劲犇's avatar
丁劲犇 已提交
907 908 909 910 911 912 913 914 915 916
QMap<QString, QVariant>			qtvplugin_geomarker::func_mark_names		(const QMap<QString, QVariant> & /*paras*/)
{
	QMap<QString, QVariant> res;
	QList< QTVP_GEOMARKER::geoItemBase *  > lst = m_pScene->geo_items();
	int ct = 0;
	foreach (QTVP_GEOMARKER::geoItemBase * key,lst)
	{
		QString keystr = QString("name%1").arg(ct++);
		res[keystr] = key->item_name();
	}
917 918
	//! the mark names will be stored in key-value pairs, with
	//! name0=??;name1=??;name2=??...namen-1=??
丁劲犇's avatar
丁劲犇 已提交
919 920
	return std::move(res);
}
921 922 923 924 925 926 927 928
/**
 * @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.
 */
丁劲犇's avatar
丁劲犇 已提交
929 930
QMap<QString, QVariant>			qtvplugin_geomarker::func_mark			(const QMap<QString, QVariant> & paras)
{
931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027
	//!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;
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041
		case QTVP_GEOMARKER::ITEAMTYPE_PIXMAP:
		{
			QTVP_GEOMARKER::geoGraphicsPixmapItem * pU = dynamic_cast<QTVP_GEOMARKER::geoGraphicsPixmapItem *>(item);
			if (pU)
			{
				res["lat"] = QString("%1").arg(pU->lat(),0,'f',7);
				res["lon"] = QString("%1").arg(pU->lon(),0,'f',7);
				res["icon"] = pU->icon()->name;
				res["scale"] =  pU->scale();
				res["rotate"] =  pU->rotation();
				res["smooth"] = pU->transformationMode()==Qt::SmoothTransformation?1:0;
			}
		}
			break;
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063
		case QTVP_GEOMARKER::ITEAMTYPE_MULTILINE:
		{
			QTVP_GEOMARKER::geoGraphicsMultilineItem * pU = dynamic_cast<QTVP_GEOMARKER::geoGraphicsMultilineItem *>(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;
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
		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);

1077 1078 1079 1080
		bool want_hover = item->wantMouseHoverEvent();
		res["want_hover"] = QString("%1").arg(want_hover?1:0);


1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096
	}
	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;
丁劲犇's avatar
丁劲犇 已提交
1097
	QMap<QString, QVariant> res;
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123
	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.
丁劲犇's avatar
丁劲犇 已提交
1124 1125
	return std::move(res);
}
1126 1127 1128 1129
/**
 * @brief func_save_xml is a internal function for plugin call_func "save_xml"
 *
 * the paraments used by paras is listed below.
丁劲犇's avatar
丁劲犇 已提交
1130
 * function=save_xml;
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
 * @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_save_xml		(const QMap<QString, QVariant> & paras)
{
	//!xml: user should specify xml filename or the function calll will fail;
	QMap<QString, QVariant> res;
	if (paras.contains("xml")==false)
	{
		res["error"] = tr("xml must  exist in paraments.");
		return std::move(res);
	}
	QString name = paras["xml"].toString();
	if (name.size()==0)
	{
		res["error"] = tr("xml could not be empty.");
		return std::move(res);
	}

	bool ok = this->xml_save(name);
	res ["return"] = ok;
	return res;
}
/**
 * @brief func_save_xml is a internal function for plugin call_func "save_xml"
 *
 * the paraments used by paras is listed below.
丁劲犇's avatar
丁劲犇 已提交
1158
 * function=load_xml;
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178
 * @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_load_xml		(const QMap<QString, QVariant> & paras)
{
	//!xml: user should specify xml filename or the function calll will fail;
	QMap<QString, QVariant> res;
	if (paras.contains("xml")==false)
	{
		res["error"] = tr("xml must  exist in paraments.");
		return std::move(res);
	}
	QString name = paras["xml"].toString();
	if (name.size()==0)
	{
		res["error"] = tr("xml could not be empty.");
		return std::move(res);
	}

	bool ok = this->xml_load(name);
1179 1180
	if (ok)
	{
1181
		//scheduleRefreshMarks();
1182 1183
		scheduleUpdateMap();
	}
丁劲犇's avatar
丁劲犇 已提交
1184
	res ["return"] = ok;
1185 1186
	return res;
}
丁劲犇's avatar
丁劲犇 已提交
1187
/**
1188
 * @brief func_add_resource is a internal function for plugin call_func "add_resource"
丁劲犇's avatar
丁劲犇 已提交
1189 1190
 *
 * the paraments used by paras is listed below.
1191
 * function=add_resource;
丁劲犇's avatar
丁劲犇 已提交
1192 1193 1194
 * @param paras The key-value style paraments.
 * @return QMap<QString, QVariant>  if error happens, a property called "error" will store the most possible reason.
 */
1195
QMap<QString, QVariant>			qtvplugin_geomarker::func_add_resource	(const QMap<QString, QVariant> & paras)
丁劲犇's avatar
丁劲犇 已提交
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234
{
	//!xml: user should specify xml filename or the function calll will fail;
	QMap<QString, QVariant> res;
	if (paras.contains("name")==false || paras.contains("filename")==false || paras.contains("centerx")==false || paras.contains("centery")==false)
	{
		res["error"] = tr("name, filename, centerx,centery 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);
	}
	QString filename = paras["filename"].toString();
	if (filename.size()==0)
	{
		res["error"] = tr("filename could not be empty.");
		return std::move(res);
	}
	int cenx = paras["centerx"].toInt();
	int ceny = paras["centery"].toInt();
	QTVP_GEOMARKER::tag_icon icon;
	icon.centerx = cenx;
	icon.centery = ceny;
	icon.filename = filename;
	icon.name =name;
	bool ok = icon.icon.load(icon.filename);
	res ["return"] =ok ;
	if (ok)
	{
		m_map_icons[icon.name] = icon;
		refreshIconModel();
	}

	return std::move(res);

}
/**
1235
 * @brief func_save_resources is a internal function for plugin call_func "save_resources"
丁劲犇's avatar
丁劲犇 已提交
1236 1237
 *
 * the paraments used by paras is listed below.
1238
 * function=save_resources;
丁劲犇's avatar
丁劲犇 已提交
1239 1240 1241
 * @param paras The key-value style paraments.
 * @return QMap<QString, QVariant>  if error happens, a property called "error" will store the most possible reason.
 */
1242
QMap<QString, QVariant>			qtvplugin_geomarker::func_save_resources	(const QMap<QString, QVariant> & paras)
丁劲犇's avatar
丁劲犇 已提交
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262
{
	//!xml: user should specify xml filename or the function calll will fail;
	QMap<QString, QVariant> res;
	if (paras.contains("xml")==false)
	{
		res["error"] = tr("xml must  exist in paraments.");
		return std::move(res);
	}
	QString name = paras["xml"].toString();
	if (name.size()==0)
	{
		res["error"] = tr("xml could not be empty.");
		return std::move(res);
	}

	bool ok = this->xml_icon_save(name);
	res ["return"] = ok;
	return res;
}
/**
1263
 * @brief func_load_resources is a internal function for plugin call_func "load_resources"
丁劲犇's avatar
丁劲犇 已提交
1264 1265
 *
 * the paraments used by paras is listed below.
1266
 * function=save_resources;
丁劲犇's avatar
丁劲犇 已提交
1267 1268 1269
 * @param paras The key-value style paraments.
 * @return QMap<QString, QVariant>  if error happens, a property called "error" will store the most possible reason.
 */
1270
QMap<QString, QVariant>			qtvplugin_geomarker::func_load_resources	(const QMap<QString, QVariant> & paras)
丁劲犇's avatar
丁劲犇 已提交
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289
{
	//!xml: user should specify xml filename or the function call will fail;
	QMap<QString, QVariant> res;
	if (paras.contains("xml")==false)
	{
		res["error"] = tr("xml must  exist in paraments.");
		return std::move(res);
	}
	QString name = paras["xml"].toString();
	if (name.size()==0)
	{
		res["error"] = tr("xml could not be empty.");
		return std::move(res);
	}

	bool ok = this->xml_icon_load(name);
	res ["return"] = ok;
	return res;
}
丁劲犇's avatar
丁劲犇 已提交
1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392
/**
 * @brief func_props_vis is a internal function for plugin call_func "props_vis"
 *
 * the paraments used by paras is listed below.
 * function=props_vis;
 * @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_vis		(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{
		QString keystr = QString("name%1").arg(ct++);
		if (paras.contains(keystr)==false)
			break;
		set_names.insert(paras[keystr].toString());
	}while (ct<1024*1024*1024);
	if (set_names.size())
	{
		ct = 0;
		foreach (QString key,set_names)
		{
			QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(key);
			if (base)
			{
				bool vis = base->props_visible();
				if (vis)
					res[key] = 1;
				else
					res[key] = 0;
			}
			else
				res[key] = 0;
		}
	}
	else
	{
		QList< QTVP_GEOMARKER::geoItemBase *  > lst = m_pScene->geo_items();
		foreach (QTVP_GEOMARKER::geoItemBase * key,lst)
		{
			bool vis = key->props_visible();
			if (vis)
				res[key->item_name()] = 1;
			else
				res[key->item_name()] = 0;
		}
	}

	//! the return value is "name=v;" serials, v=0 means props are collapsed, otherwise means props is visible.
	return std::move(res);
}
/**
 * @brief func_show_props is a internal function for plugin call_func "show_props"
 *
 * the paraments used by paras is listed below.
 * function=show_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_show_props		(const QMap<QString, QVariant> & paras)
{
	QMap<QString, QVariant> res;
	//! mark props visibility should be stored in paire,
	//! for example, StarBar=0;ruijing Hospital=1;shunfun express=1;
	//! all other props will be hidden.
	bool needupdate = false;

	QList< QTVP_GEOMARKER::geoItemBase *  > lst = m_pScene->geo_items();
	foreach (QTVP_GEOMARKER::geoItemBase * base,lst)
	{
		QString key = base->item_name();
		if (paras.contains(key))
		{
			bool vis = paras[key].toInt()==0?false:true;
			bool bOldVis = base->props_visible();
			if (vis!=bOldVis)
			{
				needupdate = true;
				base->show_props(vis);
				bOldVis = vis;
			}
			res[key] = bOldVis?1:0;
		}
		else
		{
			bool bOldVis = base->props_visible();
			if (bOldVis)
				needupdate = true;
			base->show_props(false);
		}
	}
	if (needupdate)
	{
		//scheduleRefreshMarks();
		scheduleUpdateMap();
	}
	//! the return value is "name=v;" serials, v=0 means props are collapsed, otherwise means props is visible.
	return std::move(res);
}
丁劲犇's avatar
丁劲犇 已提交
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415
//tools methods
/**
 * @brief func_set_mod is a internal function for plugin call_func "set_mod"
 *
 * the paraments used by paras is listed below.
 * function=set_mod;
 * @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_set_mod		(const QMap<QString, QVariant> & paras)
{
	QMap<QString, QVariant> res;
	//! the current mod can be set using the UI tools "radio button".
	//!
	//! all other props will be hidden.
	if (paras.contains("mod")==false)
	{
		res["error"] = tr("mod must  exist in paraments.");
		return std::move(res);
	}
	int mod = paras["mod"].toInt();
	if (mod==0)
	{
1416 1417
		ui->radioButton_QTV_display->setChecked(true);
		ui->toolBox_QTV_marks->setCurrentIndex(0);
丁劲犇's avatar
丁劲犇 已提交
1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430
		m_sel_ptStart_World = m_sel_ptEnd_World = QPointF();
		m_currentTools = qtvplugin_geomarker::TOOLS_DISPLAY_ONLY;
		layer_interface * pOSM =  m_pVi->layer("OSM");
		if (pOSM)
		{
			pOSM->set_active(true);
			m_pVi->adjust_layers(pOSM);
		}
		m_pVi->UpdateWindow();
		m_pVi->updateLayerGridView();
	}
	else if (mod==1)
	{
1431 1432
		ui->radioButton_QTV_rect_selection->setChecked(true);
		ui->toolBox_QTV_marks->setCurrentIndex(1);
丁劲犇's avatar
丁劲犇 已提交
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459
		m_currentTools = qtvplugin_geomarker::TOOLS_RECT_SELECTION;
		m_sel_ptStart_World = m_sel_ptEnd_World = QPointF();
		m_pVi->adjust_layers(this);
		m_pVi->UpdateWindow();
		m_pVi->updateLayerGridView();
	}
	else
	{
		res["error"] = tr("mod is not valid in paraments. 0=display, 1=rect selection");
		return std::move(res);
	}

	return std::move(res);
}

//selection methods
/**
 * @brief func_set_mod is a internal function for plugin call_func "selection_clear"
 *
 * the paraments used by paras is listed below.
 * function=selection_clear;
 * @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_selection_clear(const QMap<QString, QVariant> & paras)
{
	QMap<QString, QVariant> res;
1460
	this->on_pushButton_QTV_sel_clear_clicked();
丁劲犇's avatar
丁劲犇 已提交
1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473
	return std::move(res);
}
/**
 * @brief func_set_mod is a internal function for plugin call_func "selection_delete"
 *
 * the paraments used by paras is listed below.
 * function=selection_delete;
 * @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_selection_delete(const QMap<QString, QVariant> & paras)
{
	QMap<QString, QVariant> res;
1474
	this->on_pushButton_QTV_sel_delselected_clicked();
丁劲犇's avatar
丁劲犇 已提交
1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498
	return std::move(res);
}
/**
 * @brief func_set_mod is a internal function for plugin call_func "selected_items"
 *
 * the paraments used by paras is listed below.
 * function=selected_items;
 * @param paras The key-value style paraments.
 * @return QMap<QString, QVariant>  if error happens, a property called "error" will store the most possible reason.
 * the return value is stored in pairs, name0=??;name1=??;name2=??...namen-1=??...;
 */
QMap<QString, QVariant>			qtvplugin_geomarker::func_selected_items	(const QMap<QString, QVariant> & paras)
{
	QMap<QString, QVariant> res;
	int ct = 0;
	foreach (QString namestr,m_set_itemNameSelected)
	{
		QString keystr = QString("name%1").arg(ct++);
		res[keystr] = namestr;
	}
	//! the mark names will be stored in key-value pairs, with
	//! name0=??;name1=??;name2=??...namen-1=??
	return std::move(res);
}
1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523
/**
 * @brief func_set_default_style is a internal function for plugin call_func "set_default_style"
 *
 * the paraments used by paras is listed below.
 * function=set_default_style;
 * @param paras The key-value style paraments.
 * @return QMap<QString, QVariant>  if error happens, a property called "error" will store the most possible reason.
 * the return value will be empty if no error happens.;
 */
QMap<QString, QVariant> qtvplugin_geomarker::func_set_default_style(const QMap<QString, QVariant> & paras)
{
	QMap<QString, QVariant> res;
	QString errMsg;
	//! this function call will first load default style. then, if these paras is specified below,
	//! new  default style will be defined.
	this->style_load();
	//! style_pen from 0~6, is corresponds to the pen combo-box in UI system.
	if ( paras.contains("style_pen"))
	{
		int ptdd =paras["style_pen"].toInt();
		if (ptdd < 0 || ptdd >=7)
		{
			errMsg += "style_pen exceeds valid bound.";
			ptdd = 1;
		}
1524
		ui->comboBox_QTV_linePad->setCurrentIndex(ptdd);
1525 1526 1527 1528
	}
	//! color_pen has 4 pen color band values splitted by comma, r,g,b,a
	if ( paras.contains("color_pen"))
	{
1529
		ui->lineEdit_QTV_PenColor->setText(paras["color_pen"].toString());
1530 1531 1532 1533 1534 1535 1536 1537 1538 1539
	}
	//! 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();
		if (penWidth<0)
		{
			errMsg += "width_pen must >0.";
			penWidth = 1;
		}
1540
		ui->spinBox_QTV_penWidth->setValue(penWidth);
1541 1542 1543 1544 1545 1546 1547 1548 1549 1550
	}
	//! style_brush from 0~14, is corresponds to the brush style combo-box in UI system.
	if ( paras.contains("style_brush"))
	{
		int btdd = paras["style_brush"].toInt();
		if (btdd < 0 || btdd >=15)
		{
			btdd = 1;
			errMsg += "style_brush exceeds valid bounds.";
		}
1551
		ui->comboBox_QTV_fillPad->setCurrentIndex(btdd);
1552 1553 1554 1555 1556
	}

	//! color_brush has 4 brush color band values splitted by comma, r,g,b,a
	if ( paras.contains("color_brush"))
	{
1557
		ui->lineEdit_QTV_FillColor->setText( paras["color_brush"].toString());
1558 1559 1560 1561 1562 1563 1564
	}

	//! width has is a integer, means the default width of a point mark
	if ( paras.contains("width"))
	{
		int point_width = paras["width"].toInt();
		if (point_width==0) point_width = 8;
1565
		ui->spinBox_QTV_point_width->setValue(point_width);
1566 1567 1568 1569 1570 1571
	}
	//! height has is a integer, means the default width of a point mark
	if ( paras.contains("height"))
	{
		int point_height = paras["height"].toInt();
		if (point_height==0) point_height = 8;
1572
		ui->spinBox_QTV_point_height->setValue(point_height);
1573 1574 1575 1576 1577 1578 1579 1580
	}
	//! mark default point_type select , 1 means rect, 2 means Ecilips
	if (paras.contains("point_type"))
	{
		int tpn = paras["point_type"].toInt();
		switch (tpn)
		{
		case 1:
1581
			ui->radioButton_QTV_PointRect->setChecked(true);
1582 1583
			break;
		case 2:
1584
			ui->radioButton_QTV_PointRound->setChecked(true);
1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596
			break;
		default:
			break;
		}
	}
	//! mark default polygon_type select , 4 means polygon, 6 mean multiline
	if (paras.contains("polygon_type"))
	{
		int tpn = paras["polygon_type"].toInt();
		switch (tpn)
		{
		case 4:
1597
			ui->checkBox_QTV_multiline->setChecked(false);
1598 1599
			break;
		case 6:
1600
			ui->checkBox_QTV_multiline->setChecked(true);
1601 1602 1603 1604 1605 1606 1607 1608 1609 1610
			break;
		default:
			break;
		}
	}
	//! 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;
1611
		ui->spinBox_QTV_fontSize->setValue(fontSz);
1612 1613 1614 1615 1616 1617
	}
	//! 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();
		if (fontWeight>=0 && fontWeight <100)
1618
			ui->spinBox_QTV_textWeight->setValue(fontWeight);
1619 1620 1621 1622 1623
	}

	//! color_label has 4 text color band values splitted by comma, r,g,b,a
	if ( paras.contains("color_label"))
	{
1624
		ui->lineEdit_QTV_TextColor->setText(paras["color_label"].toString());
1625 1626 1627 1628 1629 1630
	}
	//! icon is the name that this mark will use.
	if ( paras.contains("icon"))
	{
		QString icn = paras["icon"].toString();
		if (m_map_icons.contains(icn))
1631
			ui->comboBox_QTV_icons->setCurrentText(icn);
1632 1633 1634 1635 1636 1637 1638 1639
		else
			errMsg += "icon is not exist";
	}
	//! 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 )
1640
			ui->lineEdit_QTV_icon_scale->setText(QString("%1").arg(sc));
1641 1642 1643 1644 1645
	}
	//! rotate is the rotate angle that this icon will use, 0.0 means no rotate
	if ( paras.contains("rotate"))
	{
		qreal rt = paras["rotate"].toReal();
1646
		ui->lineEdit_QTV_icon_rotate->setText(QString("%1").arg(rt));
1647 1648 1649 1650 1651
	}
	//!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();
1652
		ui->checkBox_QTV_icon_smooth->setChecked(smt==0?false:true);
1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674
	}
	if (errMsg.size())
		res["warning"] = errMsg;
	//style save
	style_save();
	return std::move(res);
}
/**
 * @brief func_default_style is a internal function for plugin call_func "default_style"
 *
 * the paraments used by paras is listed below.
 * function=default_style;
 * @param paras The key-value style paraments.
 * @return QMap<QString, QVariant>  if error happens, a property called "error" will store the most possible reason.
 * the return value is listed below:
 */
QMap<QString, QVariant> qtvplugin_geomarker::func_default_style(const QMap<QString, QVariant> &)
{
	QMap<QString, QVariant> res;
	//! this function call will first load default style.
	this->style_load();
	//! style_pen from 0~6, is corresponds to the pen combo-box in UI system.
1675
	res["style_pen"] = ui->comboBox_QTV_linePad->currentIndex();
1676
	//! color_pen has 4 pen color band values splitted by comma, r,g,b,a
1677
	res["color_pen"] = ui->lineEdit_QTV_PenColor->text();
1678
	//! width_pen has a value >0 , stand for the point width of the pen on screen.
1679
	res["width_pen"] = ui->spinBox_QTV_penWidth->value();
1680
	//! style_brush from 0~14, is corresponds to the brush style combo-box in UI system.
1681
	res["style_brush"] = ui->comboBox_QTV_fillPad->currentIndex();
1682
	//! color_brush has 4 brush color band values splitted by comma, r,g,b,a
1683
	res["color_brush"] = ui->lineEdit_QTV_FillColor->text();
1684
	//! width has is a integer, means the default width of a point mark
1685
	res["width"] = ui->spinBox_QTV_point_width->value();
1686
	//! height has is a integer, means the default width of a point mark
1687
	res["height"] = ui->spinBox_QTV_point_height->value();
1688
	//! mark default point_type select , 1 means rect, 2 means Ecilips
1689
	res["point_type"] = ui->radioButton_QTV_PointRect->isChecked()?1:2;
1690
	//! mark default polygon_type select , 4 means polygon, 6 mean multiline
1691
	res["polygon_type"] = ui->checkBox_QTV_multiline->isChecked()?6:4;
1692
	//! size_label stands for the text label font pixel size from 1 - 720, with a normal value 9.
1693
	res["size_label"] = ui->spinBox_QTV_fontSize->value();
1694
	//! weight_label is the bolder rate for  text renderring, from 1 ~ 99, 99 is the heaviest.
1695
	res["weight_label"] = ui->spinBox_QTV_textWeight->value();
1696
	//! color_label has 4 text color band values splitted by comma, r,g,b,a
1697
	res["color_label"] = ui->lineEdit_QTV_TextColor->text();
1698
	//! icon is the name that this mark will use.
1699
	res["icon"] = ui->comboBox_QTV_icons->currentText();
1700
	//! scale is the zoom ratio that this icon will use, 1.0 means no zoom
1701
	res["scale"] = ui->lineEdit_QTV_icon_scale->text();
1702
	//! rotate is the rotate angle that this icon will use, 0.0 means no rotate
1703
	res["rotate"] = ui->lineEdit_QTV_icon_rotate->text();
1704
	//!smooth is the transform mode that this icon will use. 0 mean not smooth, but faster. 1 mean smooth.
1705
	res["smooth"] = ui->checkBox_QTV_icon_smooth->isChecked()?-1:0;
1706 1707 1708
	return std::move(res);
}