qtvplugin_geomarker_uimethods.cpp 38.3 KB
Newer Older
1 2 3 4 5
#include "qtvplugin_geomarker.h"
#include "ui_qtvplugin_geomarker.h"
#include <QSettings>
#include <QColorDialog>
#include <QSet>
6 7 8
#include <QMap>
#include <QRegExp>
#include <QDebug>
9 10
#include <QFileDialog>
#include <QMessageBox>
11 12
#include "geographicsellipseitem.h"
#include "geographicsrectitem.h"
13 14
#include "geographicslineitem.h"
#include "geographicspolygonitem.h"
15
#include "geographicsmultilineitem.h"
16
#include "dialogselecticon.h"
17 18 19 20 21 22 23

void		qtvplugin_geomarker::timerEvent(QTimerEvent * e)
{
	if (e->timerId()==m_nTimerID_refreshUI && m_bNeedRefresh)
	{
		killTimer(m_nTimerID_refreshUI);
		m_nTimerID_refreshUI = -1;
24 25 26
		if (m_items_to_insert.empty()==true)
		{
			m_items_to_insert = m_pScene->geo_item_names();
27
			m_pGeoItemModel->removeRows(0,m_pGeoItemModel->rowCount());
28
		}
29
		//refersh
30 31 32
		int ct = 0;
		//we do not use geoItemsBase pointer, because a geoItemsBase pointer may be invalid when delayed ipdate approach is taking place.
		while (++ct < 2048 && m_items_to_insert.empty()==false)
33
		{
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
			QString keyname = m_items_to_insert.first();
			m_items_to_insert.pop_front();
			QTVP_GEOMARKER::geoItemBase * item = m_pScene->geoitem_by_name(keyname);
			if (!item)
				continue;
			int c = m_pGeoItemModel->rowCount();
			m_pGeoItemModel->appendRow(new QStandardItem(item->item_name()));
			m_pGeoItemModel->setData(
						m_pGeoItemModel->index(c,1),
						QTVP_GEOMARKER::item_name_by_enum(item->item_type())
						);
			m_pGeoItemModel->setData(
						m_pGeoItemModel->index(c,2),
						item->prop_counts()
						);
49 50

		}
51 52 53
		if (m_items_to_insert.empty()==true)
			m_bNeedRefresh = false;
		m_nTimerID_refreshUI = startTimer(217);
54
	}
丁劲犇's avatar
丁劲犇 已提交
55 56 57 58 59 60
	else if (m_nTimerID_refreshMap==e->timerId() && m_bNeedUpdateView==true)
	{
		m_bNeedUpdateView = false;
		killTimer(m_nTimerID_refreshMap);
		m_nTimerID_refreshMap = -1;
		m_pVi->UpdateWindow();
61
		m_nTimerID_refreshMap = startTimer(97);
丁劲犇's avatar
丁劲犇 已提交
62
	}
63
	else if (m_nTimerID_levelQueue == e->timerId())
丁劲犇's avatar
丁劲犇 已提交
64
	{
65
		killTimer(m_nTimerID_levelQueue);
66
		++m_nDivideTimer;
67
		if (true==m_pScene->deal_level_queue())
68 69
			m_pVi->UpdateWindow();
		else if (m_nDivideTimer % 20 == 0)
丁劲犇's avatar
丁劲犇 已提交
70 71
		{
			if (m_pScene->progress_queue()<0.999)
72
				m_pVi->UpdateWindow();
丁劲犇's avatar
丁劲犇 已提交
73
		}
74
		m_nTimerID_levelQueue = startTimer(119);
丁劲犇's avatar
丁劲犇 已提交
75
	}
76 77 78 79 80
}




81
void qtvplugin_geomarker::on_radioButton_QTV_tool_point_toggled(bool b)
82 83 84 85
{
	if (b) ui->stackedWidget_marks->setCurrentIndex(0);
}

86
void qtvplugin_geomarker::on_radioButton_QTV_tool_line_toggled(bool b )
87 88 89 90
{
	if (b) ui->stackedWidget_marks->setCurrentIndex(1);
}

91
void qtvplugin_geomarker::on_radioButton_QTV_tool_polygon_toggled(bool b)
92 93 94
{
	if (b) ui->stackedWidget_marks->setCurrentIndex(2);
}
95
void qtvplugin_geomarker::on_radioButton_QTV_tool_icons_toggled(bool b )
96 97 98
{
	if (b) ui->stackedWidget_marks->setCurrentIndex(3);
}
99

100
void qtvplugin_geomarker::on_toolButton_QTV_selColorPen_clicked()
101
{
102
	QString str = ui->lineEdit_QTV_PenColor->text();
103 104 105

	QColor col = QColorDialog::getColor(string2color(str),this,tr("Select Color"),QColorDialog::ShowAlphaChannel|QColorDialog::DontUseNativeDialog);
	if (col.isValid())
106
		ui->lineEdit_QTV_PenColor->setText(color2string(col));
107
}
108
void qtvplugin_geomarker::on_toolButton_QTV_selColorFill_clicked()
109
{
110
	QString str = ui->lineEdit_QTV_FillColor->text();
111 112 113

	QColor col = QColorDialog::getColor(string2color(str),this,tr("Select Color"),QColorDialog::ShowAlphaChannel|QColorDialog::DontUseNativeDialog);
	if (col.isValid())
114
		ui->lineEdit_QTV_FillColor->setText(color2string(col));
115
}
116
void qtvplugin_geomarker::on_toolButton_QTV_selColorText_clicked()
117
{
118
	QString str = ui->lineEdit_QTV_TextColor->text();
119

120 121
	QColor col = QColorDialog::getColor(string2color(str),this,tr("Select Color"),QColorDialog::ShowAlphaChannel|QColorDialog::DontUseNativeDialog);
	if (col.isValid())
122
		ui->lineEdit_QTV_TextColor->setText(color2string(col));
123
}
124
void qtvplugin_geomarker::on_pushButton_QTV_pickToLine1_clicked()
125
{
126 127
	ui->lineEdit_QTV_lineLat1->setText(ui->lineEdit_QTV_point_lat->text());
	ui->lineEdit_QTV_lineLon1->setText(ui->lineEdit_QTV_point_lon->text());
128 129
}

130
void qtvplugin_geomarker::on_pushButton_QTV_pickToLine2_clicked()
131
{
132 133
	ui->lineEdit_QTV_lineLat2->setText(ui->lineEdit_QTV_point_lat->text());
	ui->lineEdit_QTV_lineLon2->setText(ui->lineEdit_QTV_point_lon->text());
134 135 136
}


137
void qtvplugin_geomarker::ini_save()
138
{
139
	QSettings settings(ini_file(),QSettings::IniFormat);
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
	int radioButton_QTV_tool_point = 0;
	if (ui->radioButton_QTV_tool_line->isChecked()==true) radioButton_QTV_tool_point = 1;
	else if (ui->radioButton_QTV_tool_polygon->isChecked()==true) radioButton_QTV_tool_point = 2;
	else if (ui->radioButton_QTV_tool_icons->isChecked()==true) radioButton_QTV_tool_point = 3;
	else radioButton_QTV_tool_point = 0;
	settings.setValue("ui/radioButton_QTV_tool_point",radioButton_QTV_tool_point);

	settings.setValue("ui/lineEdit_QTV_currentID",ui->lineEdit_QTV_currentID->text());

	settings.setValue("ui/lineEdit_QTV_point_lat",ui->lineEdit_QTV_point_lat->text());
	settings.setValue("ui/lineEdit_QTV_point_lon",ui->lineEdit_QTV_point_lon->text());
	settings.setValue("ui/spinBox_QTV_point_width",ui->spinBox_QTV_point_width->value());
	settings.setValue("ui/spinBox_QTV_point_height",ui->spinBox_QTV_point_height->value());


	int radioButton_QTV_PointRect = 0;
	if (ui->radioButton_QTV_PointRound->isChecked()==true) radioButton_QTV_PointRect = 1;
	else radioButton_QTV_PointRect = 0;
	settings.setValue("ui/radioButton_QTV_PointRect",radioButton_QTV_PointRect);

	settings.setValue("ui/lineEdit_QTV_PenColor",ui->lineEdit_QTV_PenColor->text());
	settings.setValue("ui/lineEdit_QTV_FillColor",ui->lineEdit_QTV_FillColor->text());
	settings.setValue("ui/lineEdit_QTV_TextColor",ui->lineEdit_QTV_TextColor->text());
	settings.setValue("ui/lineEdit_QTV_prop_name",ui->lineEdit_QTV_prop_name->text());
	settings.setValue("ui/lineEdit_QTV_prop_string",ui->lineEdit_QTV_prop_string->text());
	settings.setValue("ui/lineEdit_QTV_lineLat1",ui->lineEdit_QTV_lineLat1->text());
	settings.setValue("ui/lineEdit_QTV_lineLat2",ui->lineEdit_QTV_lineLat2->text());
	settings.setValue("ui/lineEdit_QTV_lineLon1",ui->lineEdit_QTV_lineLon1->text());
	settings.setValue("ui/lineEdit_QTV_lineLon2",ui->lineEdit_QTV_lineLon2->text());
	settings.setValue("ui/spinBox_QTV_penWidth",ui->spinBox_QTV_penWidth->value());
	settings.setValue("ui/comboBox_QTV_linePad",ui->comboBox_QTV_linePad->currentIndex());
	settings.setValue("ui/comboBox_QTV_fillPad",ui->comboBox_QTV_fillPad->currentIndex());
	settings.setValue("ui/plainTextEdit_QTV_corners",ui->plainTextEdit_QTV_corners->toPlainText());

	settings.setValue("ui/spinBox_QTV_textWeight",ui->spinBox_QTV_textWeight->value());
	settings.setValue("ui/spinBox_QTV_fontSize",ui->spinBox_QTV_fontSize->value());
	settings.setValue("ui/lineEdit_QTV_icon_lat",ui->lineEdit_QTV_icon_lat->text());
	settings.setValue("ui/lineEdit_QTV_icon_lon",ui->lineEdit_QTV_icon_lon->text());
	settings.setValue("ui/lineEdit_QTV_icon_rotate",ui->lineEdit_QTV_icon_rotate->text());
	settings.setValue("ui/lineEdit_QTV_icon_scale",ui->lineEdit_QTV_icon_scale->text());
	settings.setValue("ui/checkBox_QTV_multiline",ui->checkBox_QTV_multiline->isChecked()?-1:0);
181
	settings.setValue("ui/checkBox_QTV_acceptHoverEvent",ui->checkBox_QTV_acceptHoverEvent->isChecked()?-1:0);
182 183
}

184
void qtvplugin_geomarker::ini_load()
185
{
186
	QSettings settings(ini_file(),QSettings::IniFormat);
187 188
	int radioButton_QTV_tool_point =  settings.value("ui/radioButton_QTV_tool_point",0).toInt();
	switch (radioButton_QTV_tool_point)
189 190
	{
	case 0:
191
		ui->radioButton_QTV_tool_point->setChecked(true);
192 193
		break;
	case 1:
194
		ui->radioButton_QTV_tool_line->setChecked(true);
195 196
		break;
	case 2:
197
		ui->radioButton_QTV_tool_polygon->setChecked(true);
198
		break;
199
	case 3:
200
		ui->radioButton_QTV_tool_icons->setChecked(true);
201
		break;
202
	default:
203
		ui->radioButton_QTV_tool_point->setChecked(true);
204 205
		break;
	}
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
	QString lineEdit_QTV_currentID = settings.value("ui/lineEdit_QTV_currentID","PT0").toString();
	ui->lineEdit_QTV_currentID->setText(lineEdit_QTV_currentID);

	QString lineEdit_QTV_point_lat = settings.value("ui/lineEdit_QTV_point_lat","0").toString();
	ui->lineEdit_QTV_point_lat->setText(lineEdit_QTV_point_lat);
	QString lineEdit_QTV_point_lon = settings.value("ui/lineEdit_QTV_point_lon","0").toString();
	ui->lineEdit_QTV_point_lon->setText(lineEdit_QTV_point_lon);
	int spinBox_QTV_point_width = settings.value("ui/spinBox_QTV_point_width",8).toInt();
	ui->spinBox_QTV_point_width->setValue(spinBox_QTV_point_width);
	int spinBox_QTV_point_height = settings.value("ui/spinBox_QTV_point_height",8).toInt();
	ui->spinBox_QTV_point_height->setValue(spinBox_QTV_point_height);
	QString lineEdit_QTV_PenColor = settings.value("ui/lineEdit_QTV_PenColor",color2string(QColor(0,0,0,128))).toString();
	ui->lineEdit_QTV_PenColor->setText(lineEdit_QTV_PenColor);
	QString lineEdit_QTV_FillColor = settings.value("ui/lineEdit_QTV_FillColor",color2string(QColor(255,255,255,128))).toString();
	ui->lineEdit_QTV_FillColor->setText(lineEdit_QTV_FillColor);
	QString lineEdit_QTV_TextColor = settings.value("ui/lineEdit_QTV_TextColor",color2string(QColor(0,0,0))).toString();
	ui->lineEdit_QTV_TextColor->setText(lineEdit_QTV_TextColor);
	int radioButton_QTV_PointRect =  settings.value("ui/radioButton_QTV_PointRect",0).toInt();
	switch (radioButton_QTV_PointRect)
225 226
	{
	case 0:
227
		ui->radioButton_QTV_PointRect->setChecked(true);
228 229
		break;
	case 1:
230
		ui->radioButton_QTV_PointRound->setChecked(true);
231 232
		break;
	default:
233
		ui->radioButton_QTV_PointRect->setChecked(true);
234 235 236
		break;
	}

237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
	QString lineEdit_QTV_prop_name = settings.value("ui/lineEdit_QTV_prop_name","LABEL").toString();
	ui->lineEdit_QTV_prop_name->setText(lineEdit_QTV_prop_name);
	QString lineEdit_QTV_prop_string = settings.value("ui/lineEdit_QTV_prop_string","please input label here").toString();
	ui->lineEdit_QTV_prop_string->setText(lineEdit_QTV_prop_string);
	QString lineEdit_QTV_lineLat1 = settings.value("ui/lineEdit_QTV_lineLat1","0").toString();
	ui->lineEdit_QTV_lineLat1->setText(lineEdit_QTV_lineLat1);
	QString lineEdit_QTV_lineLat2 = settings.value("ui/lineEdit_QTV_lineLat2","0").toString();
	ui->lineEdit_QTV_lineLat2->setText(lineEdit_QTV_lineLat2);
	QString lineEdit_QTV_lineLon1 = settings.value("ui/lineEdit_QTV_lineLon1","0").toString();
	ui->lineEdit_QTV_lineLon1->setText(lineEdit_QTV_lineLon1);
	QString lineEdit_QTV_lineLon2 = settings.value("ui/lineEdit_QTV_lineLon2","0").toString();
	ui->lineEdit_QTV_lineLon2->setText(lineEdit_QTV_lineLon2);
	int spinBox_QTV_penWidth = settings.value("ui/spinBox_QTV_penWidth",3).toInt();
	ui->spinBox_QTV_penWidth->setValue(spinBox_QTV_penWidth);
	int comboBox_QTV_linePad = settings.value("ui/comboBox_QTV_linePad",1).toInt();
	ui->comboBox_QTV_linePad->setCurrentIndex(comboBox_QTV_linePad);
	int comboBox_QTV_fillPad = settings.value("ui/comboBox_QTV_fillPad",1).toInt();
	ui->comboBox_QTV_fillPad->setCurrentIndex(comboBox_QTV_fillPad);

	QString plainTextEdit_QTV_corners = settings.value("ui/plainTextEdit_QTV_corners","0").toString();
	ui->plainTextEdit_QTV_corners->setPlainText(plainTextEdit_QTV_corners);

	int spinBox_QTV_fontSize = settings.value("ui/spinBox_QTV_fontSize",9).toInt();
	ui->spinBox_QTV_fontSize->setValue(spinBox_QTV_fontSize);

	int spinBox_QTV_textWeight = settings.value("ui/spinBox_QTV_textWeight",16).toInt();
	ui->spinBox_QTV_textWeight->setValue(spinBox_QTV_textWeight);

	QString lineEdit_QTV_icon_lat = settings.value("ui/lineEdit_QTV_icon_lat","0").toString();
	ui->lineEdit_QTV_icon_lat->setText(lineEdit_QTV_icon_lat);
	QString lineEdit_QTV_icon_lon = settings.value("ui/lineEdit_QTV_icon_lon","0").toString();
	ui->lineEdit_QTV_icon_lon->setText(lineEdit_QTV_icon_lon);
	QString lineEdit_QTV_icon_scale = settings.value("ui/lineEdit_QTV_icon_scale","1.0").toString();
	ui->lineEdit_QTV_icon_scale->setText(lineEdit_QTV_icon_scale);
	QString lineEdit_QTV_icon_rotate = settings.value("ui/lineEdit_QTV_icon_rotate","1.0").toString();
	ui->lineEdit_QTV_icon_rotate->setText(lineEdit_QTV_icon_rotate);

	int checkBox_QTV_multiline = settings.value("ui/checkBox_QTV_multiline",0).toInt();
	ui->checkBox_QTV_multiline->setChecked(checkBox_QTV_multiline?true:false);
276

277 278
	int checkBox_QTV_acceptHoverEvent = settings.value("ui/checkBox_QTV_acceptHoverEvent",0).toInt();
	ui->checkBox_QTV_acceptHoverEvent->setChecked(checkBox_QTV_acceptHoverEvent?true:false);
279
}
280 281 282 283 284


void qtvplugin_geomarker::style_save()
{
	QSettings settings(ini_file(),QSettings::IniFormat);
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
	settings.setValue("default_style/spinBox_QTV_point_width",ui->spinBox_QTV_point_width->value());
	settings.setValue("default_style/spinBox_QTV_point_height",ui->spinBox_QTV_point_height->value());
	int radioButton_QTV_PointRect = 0;
	if (ui->radioButton_QTV_PointRound->isChecked()==true) radioButton_QTV_PointRect = 1;
	else radioButton_QTV_PointRect = 0;
	settings.setValue("default_style/radioButton_QTV_PointRect",radioButton_QTV_PointRect);

	settings.setValue("default_style/lineEdit_QTV_PenColor",ui->lineEdit_QTV_PenColor->text());
	settings.setValue("default_style/lineEdit_QTV_FillColor",ui->lineEdit_QTV_FillColor->text());
	settings.setValue("default_style/lineEdit_QTV_TextColor",ui->lineEdit_QTV_TextColor->text());
	settings.setValue("default_style/spinBox_QTV_penWidth",ui->spinBox_QTV_penWidth->value());
	settings.setValue("default_style/comboBox_QTV_linePad",ui->comboBox_QTV_linePad->currentIndex());
	settings.setValue("default_style/comboBox_QTV_fillPad",ui->comboBox_QTV_fillPad->currentIndex());

	settings.setValue("default_style/spinBox_QTV_textWeight",ui->spinBox_QTV_textWeight->value());
	settings.setValue("default_style/spinBox_QTV_fontSize",ui->spinBox_QTV_fontSize->value());
	settings.setValue("default_style/lineEdit_QTV_icon_rotate",ui->lineEdit_QTV_icon_rotate->text());
	settings.setValue("default_style/lineEdit_QTV_icon_scale",ui->lineEdit_QTV_icon_scale->text());
	settings.setValue("default_style/checkBox_QTV_multiline",ui->checkBox_QTV_multiline->isChecked()?-1:0);
	settings.setValue("default_style/checkBox_QTV_icon_smooth",ui->checkBox_QTV_icon_smooth->isChecked()?-1:0);
	settings.setValue("default_style/comboBox_QTV_icons",ui->comboBox_QTV_icons->currentText());
306 307

	//update current style
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
	m_default_style.n_point_width = ui->spinBox_QTV_point_width->value();
	m_default_style.n_point_height = ui->spinBox_QTV_point_height->value();
	m_default_style.n_point_rect = radioButton_QTV_PointRect;
	m_default_style.pen.setColor(string2color(ui->lineEdit_QTV_PenColor->text()));
	m_default_style.pen.setWidth(ui->spinBox_QTV_penWidth->value());
	m_default_style.pen.setStyle(static_cast<Qt::PenStyle>(ui->comboBox_QTV_linePad->currentIndex()));
	m_default_style.brush.setColor(string2color(ui->lineEdit_QTV_FillColor->text()));
	m_default_style.brush.setStyle(static_cast<Qt::BrushStyle>(ui->comboBox_QTV_fillPad->currentIndex()));
	m_default_style.text_color = string2color(ui->lineEdit_QTV_TextColor->text());
	m_default_style.font.setWeight(ui->spinBox_QTV_textWeight->value());
	m_default_style.font.setPointSize(ui->spinBox_QTV_fontSize->value());
	m_default_style.scale = ui->lineEdit_QTV_icon_scale->text().toFloat();
	m_default_style.rotate = ui->lineEdit_QTV_icon_rotate->text().toFloat();
	m_default_style.multiline = ui->checkBox_QTV_multiline->isChecked()?-1:0;
	m_default_style.smooth = ui->checkBox_QTV_icon_smooth->isChecked()?-1:0;
	m_default_style.icon_name = ui->comboBox_QTV_icons->currentText();
324 325 326 327 328 329
}

void qtvplugin_geomarker::style_load()
{
	QSettings settings(ini_file(),QSettings::IniFormat);

330 331
	int spinBox_QTV_point_width = settings.value("default_style/spinBox_QTV_point_width",8).toInt();
	ui->spinBox_QTV_point_width->setValue(spinBox_QTV_point_width);
332

333 334
	int spinBox_QTV_point_height = settings.value("default_style/spinBox_QTV_point_height",8).toInt();
	ui->spinBox_QTV_point_height->setValue(spinBox_QTV_point_height);
335

336 337
	QString lineEdit_QTV_PenColor = settings.value("default_style/lineEdit_QTV_PenColor",color2string(QColor(0,0,0,128))).toString();
	ui->lineEdit_QTV_PenColor->setText(lineEdit_QTV_PenColor);
338

339 340
	QString lineEdit_QTV_FillColor = settings.value("default_style/lineEdit_QTV_FillColor",color2string(QColor(255,255,255,128))).toString();
	ui->lineEdit_QTV_FillColor->setText(lineEdit_QTV_FillColor);
341

342 343
	QString lineEdit_QTV_TextColor = settings.value("default_style/lineEdit_QTV_TextColor",color2string(QColor(0,0,0))).toString();
	ui->lineEdit_QTV_TextColor->setText(lineEdit_QTV_TextColor);
344

345 346
	int radioButton_QTV_PointRect =  settings.value("default_style/radioButton_QTV_PointRect",0).toInt();
	switch (radioButton_QTV_PointRect)
347 348
	{
	case 0:
349
		ui->radioButton_QTV_PointRect->setChecked(true);
350 351
		break;
	case 1:
352
		ui->radioButton_QTV_PointRound->setChecked(true);
353 354
		break;
	default:
355
		ui->radioButton_QTV_PointRect->setChecked(true);
356 357 358
		break;
	}

359 360
	int spinBox_QTV_penWidth = settings.value("default_style/spinBox_QTV_penWidth",3).toInt();
	ui->spinBox_QTV_penWidth->setValue(spinBox_QTV_penWidth);
361

362 363
	int comboBox_QTV_linePad = settings.value("default_style/comboBox_QTV_linePad",1).toInt();
	ui->comboBox_QTV_linePad->setCurrentIndex(comboBox_QTV_linePad);
364

365 366
	int comboBox_QTV_fillPad = settings.value("default_style/comboBox_QTV_fillPad",1).toInt();
	ui->comboBox_QTV_fillPad->setCurrentIndex(comboBox_QTV_fillPad);
367 368


369 370
	int spinBox_QTV_fontSize = settings.value("default_style/spinBox_QTV_fontSize",9).toInt();
	ui->spinBox_QTV_fontSize->setValue(spinBox_QTV_fontSize);
371

372 373
	int spinBox_QTV_textWeight = settings.value("default_style/spinBox_QTV_textWeight",16).toInt();
	ui->spinBox_QTV_textWeight->setValue(spinBox_QTV_textWeight);
374

375 376
	QString lineEdit_QTV_icon_scale = settings.value("default_style/lineEdit_QTV_icon_scale","1.0").toString();
	ui->lineEdit_QTV_icon_scale->setText(lineEdit_QTV_icon_scale);
377

378 379
	QString lineEdit_QTV_icon_rotate = settings.value("default_style/lineEdit_QTV_icon_rotate","1.0").toString();
	ui->lineEdit_QTV_icon_rotate->setText(lineEdit_QTV_icon_rotate);
380

381 382
	int checkBox_QTV_multiline = settings.value("default_style/checkBox_QTV_multiline",0).toInt();
	ui->checkBox_QTV_multiline->setChecked(checkBox_QTV_multiline?true:false);
383

384 385
	int checkBox_QTV_icon_smooth = settings.value("default_style/checkBox_QTV_icon_smooth",0).toInt();
	ui->checkBox_QTV_icon_smooth->setChecked(checkBox_QTV_icon_smooth?true:false);
386

387 388 389
	QString comboBox_QTV_icons = settings.value("default_style/comboBox_QTV_icons","default").toString();
	if (m_map_icons.contains(comboBox_QTV_icons))
		ui->comboBox_QTV_icons->setCurrentText(comboBox_QTV_icons);
390
	//update current style
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
	m_default_style.n_point_width = ui->spinBox_QTV_point_width->value();
	m_default_style.n_point_height = ui->spinBox_QTV_point_height->value();
	m_default_style.n_point_rect = radioButton_QTV_PointRect;
	m_default_style.pen.setColor(string2color(ui->lineEdit_QTV_PenColor->text()));
	m_default_style.pen.setWidth(ui->spinBox_QTV_penWidth->value());
	m_default_style.pen.setStyle(static_cast<Qt::PenStyle>(ui->comboBox_QTV_linePad->currentIndex()));
	m_default_style.brush.setColor(string2color(ui->lineEdit_QTV_FillColor->text()));
	m_default_style.brush.setStyle(static_cast<Qt::BrushStyle>(ui->comboBox_QTV_fillPad->currentIndex()));
	m_default_style.text_color = string2color(ui->lineEdit_QTV_TextColor->text());
	m_default_style.font.setWeight(ui->spinBox_QTV_textWeight->value());
	m_default_style.font.setPointSize(ui->spinBox_QTV_fontSize->value());
	m_default_style.scale = ui->lineEdit_QTV_icon_scale->text().toFloat();
	m_default_style.rotate = ui->lineEdit_QTV_icon_rotate->text().toFloat();
	m_default_style.multiline = ui->checkBox_QTV_multiline->isChecked()?-1:0;
	m_default_style.smooth = ui->checkBox_QTV_icon_smooth->isChecked()?-1:0;
	m_default_style.icon_name = ui->comboBox_QTV_icons->currentText();
}

void qtvplugin_geomarker::on_pushButton_QTV_update_clicked()
410 411 412
{
	if (m_pVi==0 || !m_pScene)
		return;
413
	QString name = ui->lineEdit_QTV_currentID->text();
414
	ini_save();
丁劲犇's avatar
丁劲犇 已提交
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443

	//Get pen and brush settings
	Qt::PenStyle pst [] ={
		Qt::NoPen	,
		Qt::SolidLine	,
		Qt::DashLine	,
		Qt::DotLine	,
		Qt::DashDotLine	,
		Qt::DashDotDotLine	,
		Qt::CustomDashLine
	};
	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
	};

444
	int ptdd = ui->comboBox_QTV_linePad->currentIndex();
丁劲犇's avatar
丁劲犇 已提交
445 446
	if (ptdd < 0 || ptdd >=7)
		ptdd = 1;
447 448
	QColor penColor = string2color( ui->lineEdit_QTV_PenColor->text());
	int penWidth = ui->spinBox_QTV_penWidth->value();
丁劲犇's avatar
丁劲犇 已提交
449 450 451 452 453
	QPen pen;//(QBrush(color),width,pst[ptdd]);
	pen.setColor(penColor);
	pen.setWidth(penWidth);
	pen.setStyle(pst[ptdd]);

454
	int btdd = ui->comboBox_QTV_fillPad->currentIndex();
丁劲犇's avatar
丁劲犇 已提交
455 456 457
	if (btdd < 0 || btdd >=15)
		btdd = 1;

458
	QColor brushColor = string2color( ui->lineEdit_QTV_FillColor->text());
丁劲犇's avatar
丁劲犇 已提交
459 460 461 462
	QBrush brush;
	brush.setColor(brushColor);
	brush.setStyle(bst[btdd]);

463 464
	QTVP_GEOMARKER::geoItemBase * newitem = 0;

465
	if (ui->radioButton_QTV_tool_point->isChecked())
466
	{
467 468 469 470 471
		double lat = ui->lineEdit_QTV_point_lat->text().toDouble();
		double lon = ui->lineEdit_QTV_point_lon->text().toDouble();
		int tp = ui->radioButton_QTV_PointRect->isChecked()?0:1;
		int width = ui->spinBox_QTV_point_width->value();
		int height = ui->spinBox_QTV_point_height->value();
472
		if (tp==0)
473
			newitem = update_point<QTVP_GEOMARKER::geoGraphicsRectItem>(name,lat,lon,width,height,pen,brush);
474
		else
475
			newitem = update_point<QTVP_GEOMARKER::geoGraphicsEllipseItem>(name,lat,lon,width,height,pen,brush);
476
	}
477
	else if (ui->radioButton_QTV_tool_line->isChecked())
478
	{
479 480 481 482
		double lat1 = ui->lineEdit_QTV_lineLat1->text().toDouble();
		double lat2 = ui->lineEdit_QTV_lineLat2->text().toDouble();
		double lon1 = ui->lineEdit_QTV_lineLon1->text().toDouble();
		double lon2 = ui->lineEdit_QTV_lineLon2->text().toDouble();
483
		newitem = update_line(name,lat1,lon1,lat2,lon2,pen);
484
	}
485
	else if (ui->radioButton_QTV_tool_polygon->isChecked())
486
	{
487
		QPolygonF latlons;
488
		QString strPlainTexts = ui->plainTextEdit_QTV_corners->toPlainText();
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
		strPlainTexts.remove(' ');
		strPlainTexts.remove('\n');
		strPlainTexts.remove('\r');
		strPlainTexts.remove('\015');
		strPlainTexts.remove('\012');
		QStringList lst = strPlainTexts.split(QRegExp("[,;]"),QString::SkipEmptyParts);
		int c = 0;
		QPointF ll;
		foreach (QString s,lst)
		{
			if (c%2==0)
				ll.setY(s.toDouble());
			else
				ll.setX(s.toDouble());
			if ((++c) % 2==0)
				latlons.push_back(ll);
		}
		if (latlons.size())
507
			newitem = update_polygon(name,latlons,pen,brush,ui->checkBox_QTV_multiline->isChecked()?true:false);
508 509

	}
510
	else if (ui->radioButton_QTV_tool_icons->isChecked())
丁劲犇's avatar
丁劲犇 已提交
511
	{
512 513 514 515 516 517
		double lat = ui->lineEdit_QTV_icon_lat->text().toDouble();
		double lon = ui->lineEdit_QTV_icon_lon->text().toDouble();
		qreal scale = ui->lineEdit_QTV_icon_scale->text().toFloat();
		qreal rotate = ui->lineEdit_QTV_icon_rotate->text().toFloat();
		QString iconname = ui->comboBox_QTV_icons->currentText();
		int smooth = ui->checkBox_QTV_icon_smooth->isChecked()?1:0;
518
		newitem = update_icon(name,lat,lon,scale,rotate,smooth,iconname);
丁劲犇's avatar
丁劲犇 已提交
519
	}
520 521
	else
		return;
522 523
	if (newitem)
	{
524 525 526
		int fontSz = ui->spinBox_QTV_fontSize->value();
		int fontWeight = ui->spinBox_QTV_textWeight->value();
		QColor textColor = string2color( ui->lineEdit_QTV_TextColor->text());
527 528 529 530 531
		QFont f = newitem->labelFont();
		f.setPointSize(fontSz);
		f.setWeight(fontWeight);
		newitem->setLabelFont(f);
		newitem->setLabelColor(textColor);
532
		newitem->setWantMouseHoverEvent(ui->checkBox_QTV_acceptHoverEvent->isChecked());
533
	}
丁劲犇's avatar
丁劲犇 已提交
534
	scheduleRefreshMarks();
535
	m_pVi->UpdateWindow();
536 537
}

538
void qtvplugin_geomarker::on_pushButton_QTV_del_clicked()
539 540
{
	QSet<int> rows;
541
	QModelIndexList lst =  ui->tableView_QTV_marks->selectionModel()->selectedIndexes();
542 543 544 545 546 547 548 549 550
	foreach (QModelIndex idd, lst)
		rows.insert(idd.row());
	foreach (int row, rows)
	{
		QString namep = m_pGeoItemModel->data(m_pGeoItemModel->index(row,0)).toString();
		QTVP_GEOMARKER::geoItemBase * b = m_pScene->geoitem_by_name(namep);
		if (b)
			m_pScene->removeItem(b,0);
	}
丁劲犇's avatar
丁劲犇 已提交
551
	scheduleRefreshMarks();
552 553 554

}

555
void qtvplugin_geomarker::on_pushButton_QTV_prop_update_clicked()
556
{
557
	ini_save();
558
	QString name = ui->lineEdit_QTV_currentID->text();
559 560 561 562
	//Fill in the pages
	QTVP_GEOMARKER::geoItemBase * item = m_pScene->geoitem_by_name(name);
	if (item)
	{
563
		item->set_prop_data(ui->lineEdit_QTV_prop_name->text(),ui->lineEdit_QTV_prop_string->text());
564
		this->refreshProps(item);
丁劲犇's avatar
丁劲犇 已提交
565
		this->scheduleRefreshMarks();
566
		//Update Font
567 568 569
		int fontSz = ui->spinBox_QTV_fontSize->value();
		int fontWeight = ui->spinBox_QTV_textWeight->value();
		QColor textColor = string2color( ui->lineEdit_QTV_TextColor->text());
570 571 572 573 574 575 576
		QFont f = item->labelFont();
		f.setPointSize(fontSz);
		f.setWeight(fontWeight);
		item->setLabelFont(f);
		item->setLabelColor(textColor);

		m_pVi->UpdateWindow();
577 578
	}
}
579
void qtvplugin_geomarker::on_pushButton_QTV_prop_delete_clicked()
580
{
581
	QString name = ui->lineEdit_QTV_currentID->text();
582 583 584 585 586
	//Fill in the pages
	QTVP_GEOMARKER::geoItemBase * item = m_pScene->geoitem_by_name(name);
	if (item)
	{
		QSet<int> rows;
587
		QModelIndexList lst =  ui->tableView_QTV_props->selectionModel()->selectedIndexes();
588 589 590 591 592 593 594 595 596 597 598 599
		foreach (QModelIndex idd, lst)
			rows.insert(idd.row());
		foreach (int row, rows)
		{
			QString namep = m_pGeoPropModel->data(m_pGeoPropModel->index(row,0)).toString();
			item->del_prop(namep);
		}
	}
	this->refreshProps(item);
}


600
void qtvplugin_geomarker::on_tableView_QTV_marks_doubleClicked(const QModelIndex & index)
601 602 603 604 605 606 607 608 609 610 611 612
{
	int row = index.row();
	if (row >=0 && row < m_pGeoItemModel->rowCount() )
	{
		QString name = m_pGeoItemModel->data(
					m_pGeoItemModel->index(row,0)
					).toString();

		refreshItemUI(name);
	}
}

613
void qtvplugin_geomarker::on_pushButton_QTV_getPolygon_clicked()
614 615
{
	if (!m_pVi)	return;
616
	QString strGridName = "grid";/*QString("grid%1").arg(m_nInstance);*/
617 618 619 620
	layer_interface * pif =  m_pVi->layer(strGridName);
	if (pif)
	{
		QMap<QString, QVariant> inPara, outPara;
621
		inPara["function"] = "get_polygon";
622 623 624 625 626 627 628 629 630
		outPara = pif->call_func(inPara);
		QString strPlainText = "";
		if (outPara.contains("size"))
		{
			int nsz = outPara["size"].toInt();
			for (int i=0;i<nsz;++i)
			{
				QString latkey = QString("lat%1").arg(i);
				QString lonkey = QString("lon%1").arg(i);
631
				strPlainText += QString("%1,%2;\n").arg(outPara[latkey].toDouble(),0,'f',7).arg(outPara[lonkey].toDouble(),0,'f',7);
632 633
			}
		}
634
		ui->plainTextEdit_QTV_corners->setPlainText(strPlainText);
635 636
	}
}
637 638 639 640 641 642 643
void qtvplugin_geomarker::refreshItemUI(QString markname)
{
	QString name = markname;
	//Fill in the pages
	QTVP_GEOMARKER::geoItemBase * item = m_pScene->geoitem_by_name(name);
	if (item)
	{
644
		ui->lineEdit_QTV_currentID->setText(item->item_name());
丁劲犇's avatar
丁劲犇 已提交
645 646 647
		//Update Pen and brush
		QPen pen;
		QBrush brush;
648 649 650 651 652 653 654
		switch (item->item_type())
		{
		case QTVP_GEOMARKER::ITEAMTYPE_RECT_POINT:
		{
			QTVP_GEOMARKER::geoGraphicsRectItem * pitem = dynamic_cast<QTVP_GEOMARKER::geoGraphicsRectItem *>(item);
			if (!pitem)
				break;
丁劲犇's avatar
丁劲犇 已提交
655 656
			pen = pitem->pen();
			brush = pitem->brush();
657 658 659 660 661 662
			ui->lineEdit_QTV_point_lat->setText(QString("%1").arg(pitem->lat(),0,'f',7));
			ui->lineEdit_QTV_point_lon->setText(QString("%1").arg(pitem->lon(),0,'f',7));
			ui->radioButton_QTV_PointRect->setChecked(true);
			ui->spinBox_QTV_point_width->setValue(pitem->width());
			ui->spinBox_QTV_point_height->setValue(pitem->height());
			ui->radioButton_QTV_tool_point->setChecked(true);
663 664 665 666 667 668 669
		}
			break;
		case QTVP_GEOMARKER::ITEAMTYPE_ELLIPSE_POINT:
		{
			QTVP_GEOMARKER::geoGraphicsEllipseItem * pitem = dynamic_cast<QTVP_GEOMARKER::geoGraphicsEllipseItem *>(item);
			if (!pitem)
				break;
丁劲犇's avatar
丁劲犇 已提交
670 671
			pen = pitem->pen();
			brush = pitem->brush();
672 673 674 675 676 677
			ui->lineEdit_QTV_point_lat->setText(QString("%1").arg(pitem->lat(),0,'f',7));
			ui->lineEdit_QTV_point_lon->setText(QString("%1").arg(pitem->lon(),0,'f',7));
			ui->radioButton_QTV_PointRound->setChecked(true);
			ui->spinBox_QTV_point_width->setValue(pitem->width());
			ui->spinBox_QTV_point_height->setValue(pitem->height());
			ui->radioButton_QTV_tool_point->setChecked(true);
678 679 680
		}
			break;
		case QTVP_GEOMARKER::ITEAMTYPE_LINE:
681 682 683 684
		{
			QTVP_GEOMARKER::geoGraphicsLineItem * pitem = dynamic_cast<QTVP_GEOMARKER::geoGraphicsLineItem *>(item);
			if (!pitem)
				break;
丁劲犇's avatar
丁劲犇 已提交
685
			pen = pitem->pen();
686 687 688 689 690
			ui->lineEdit_QTV_lineLat1->setText(QString("%1").arg(pitem->lat1(),0,'f',7));
			ui->lineEdit_QTV_lineLat2->setText(QString("%1").arg(pitem->lat2(),0,'f',7));
			ui->lineEdit_QTV_lineLon1->setText(QString("%1").arg(pitem->lon1(),0,'f',7));
			ui->lineEdit_QTV_lineLon2->setText(QString("%1").arg(pitem->lon2(),0,'f',7));
			ui->radioButton_QTV_tool_line->setChecked(true);
691
		}
692
			break;
693
		case QTVP_GEOMARKER::ITEAMTYPE_POLYGON:
694 695 696 697
		{
			QTVP_GEOMARKER::geoGraphicsPolygonItem * pitem = dynamic_cast<QTVP_GEOMARKER::geoGraphicsPolygonItem *>(item);
			if (!pitem)
				break;
丁劲犇's avatar
丁劲犇 已提交
698 699
			pen = pitem->pen();
			brush = pitem->brush();
700 701 702
			QPolygonF pol = pitem->llas();
			QString strPlainText;
			foreach (QPointF p, pol)
703
				strPlainText += QString("%1,%2;\n").arg(p.y(),0,'f',7).arg(p.x(),0,'f',7);
704 705 706
			ui->plainTextEdit_QTV_corners->setPlainText(strPlainText);
			ui->radioButton_QTV_tool_polygon->setChecked(true);
			ui->checkBox_QTV_multiline->setChecked(false);
707
		}
708
			break;
709 710 711 712 713
		case QTVP_GEOMARKER::ITEAMTYPE_PIXMAP:
		{
			QTVP_GEOMARKER::geoGraphicsPixmapItem * pitem = dynamic_cast<QTVP_GEOMARKER::geoGraphicsPixmapItem *>(item);
			if (!pitem)
				break;
714 715 716 717 718
			ui->lineEdit_QTV_icon_lat->setText(QString("%1").arg(pitem->lat(),0,'f',7));
			ui->lineEdit_QTV_icon_lon->setText(QString("%1").arg(pitem->lon(),0,'f',7));
			ui->radioButton_QTV_tool_icons->setChecked(true);
			ui->lineEdit_QTV_icon_rotate->setText(QString("%1").arg(pitem->rotation()));
			ui->lineEdit_QTV_icon_scale->setText(QString("%1").arg(pitem->scale()));
719
			QString nameicon = pitem->icon()->name;
720
			ui->comboBox_QTV_icons->setCurrentText(nameicon);
721 722
		}
			break;
723 724 725 726 727 728 729 730 731 732 733
		case QTVP_GEOMARKER::ITEAMTYPE_MULTILINE:
		{
			QTVP_GEOMARKER::geoGraphicsMultilineItem * pitem = dynamic_cast<QTVP_GEOMARKER::geoGraphicsMultilineItem *>(item);
			if (!pitem)
				break;
			pen = pitem->pen();
			brush = pitem->brush();
			QPolygonF pol = pitem->llas();
			QString strPlainText;
			foreach (QPointF p, pol)
				strPlainText += QString("%1,%2;\n").arg(p.y(),0,'f',7).arg(p.x(),0,'f',7);
734 735 736
			ui->plainTextEdit_QTV_corners->setPlainText(strPlainText);
			ui->radioButton_QTV_tool_polygon->setChecked(true);
			ui->checkBox_QTV_multiline->setChecked(true);
737 738 739
		}
			break;

740 741 742 743
		default:
			break;

		}//end switch
丁劲犇's avatar
丁劲犇 已提交
744 745

		QColor colorPen = pen.color();
746
		ui->lineEdit_QTV_PenColor->setText(color2string(colorPen));
丁劲犇's avatar
丁劲犇 已提交
747
		QColor colorFill = brush.color();
748
		ui->lineEdit_QTV_FillColor->setText(color2string(colorFill));
丁劲犇's avatar
丁劲犇 已提交
749
		int penwidth = pen.width();
750
		ui->spinBox_QTV_penWidth->setValue(penwidth);
丁劲犇's avatar
丁劲犇 已提交
751 752
		Qt::PenStyle st = pen.style();
		int nst = int(st);
753 754
		if (nst >=0 && nst < ui->comboBox_QTV_linePad->count())
			ui->comboBox_QTV_linePad->setCurrentIndex((int)st);
丁劲犇's avatar
丁劲犇 已提交
755 756
		Qt::BrushStyle bs = brush.style();
		int nbs = int(bs);
757 758
		if (nbs >=0 && nbs < ui->comboBox_QTV_fillPad->count())
			ui->comboBox_QTV_fillPad->setCurrentIndex((int)nbs);
759 760

		QColor colorText = item->labelColor();
761
		ui->lineEdit_QTV_TextColor->setText(color2string(colorText));
762 763

		int fsize = item->labelFont().pointSize();
764
		ui->spinBox_QTV_fontSize->setValue(fsize);
765 766

		int weight = item->labelFont().weight();
767
		ui->spinBox_QTV_textWeight->setValue(weight);
768

769 770 771
		bool bwant_hover = item->wantMouseHoverEvent();
		ui->checkBox_QTV_acceptHoverEvent->setChecked(bwant_hover);

772 773 774 775
		refreshProps(item);
	}//end if item

}
丁劲犇's avatar
丁劲犇 已提交
776 777 778 779 780 781 782 783 784 785 786
void qtvplugin_geomarker::refreshIconModel()
{
	m_pIconsModel->clear();
	foreach (QString key, m_map_icons.keys())
	{
		QStandardItem * item =  new QStandardItem(key);
		QIcon icon(m_map_icons[key].icon);
		item->setIcon(icon);
		m_pIconsModel->appendRow(item);
	}
}
787 788 789

void qtvplugin_geomarker::refreshProps(QTVP_GEOMARKER::geoItemBase * itm)
{
790 791
	if (itm==0)
		return;
792 793 794 795 796 797 798 799 800 801 802 803 804 805
	m_pGeoPropModel->removeRows(0,m_pGeoPropModel->rowCount());
	int ct = itm->prop_counts();
	QStringList lstNames = itm->prop_names();
	QVariantList lstValues = itm->prop_values();
	for (int i=0;i<ct;++i)
	{
		m_pGeoPropModel->appendRow(new QStandardItem(lstNames.first()));
		m_pGeoPropModel->setData(
					m_pGeoPropModel->index(i,1),
					lstValues.first());
		lstNames.pop_front();
		lstValues.pop_front();
	}
}
806
void qtvplugin_geomarker::on_pushButton_QTV_save_clicked()
807
{
808
	QSettings settings(ini_file(),QSettings::IniFormat);
809 810
	QString strLastSaveImgDir = settings.value("history/last_save_xml_dir","./").toString();
	QString newfm = QFileDialog::getSaveFileName(this,tr("save to xml"),strLastSaveImgDir,
811
                                 "xml (*.xml);;cmd (*.cmd);;All files(*.*)"
812 813 814
								 );
	if (newfm.size()>2)
	{
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834
        if (newfm.right(3).toUpper()=="XML")
        {
            if (true==xml_save(newfm))
            {
                settings.setValue("history/last_save_xml_dir",newfm);
                //QMessageBox::information(this,tr("succeed"),tr("Successfully saved XML file") + newfm);
            }
            else
                QMessageBox::warning(this,tr("failed"),tr("Save XML file") + newfm + tr(" Failed"));
        }
        else
        {
			if (true==cmd_save(newfm))
			{
				settings.setValue("history/last_save_xml_dir",newfm);
				//QMessageBox::information(this,tr("succeed"),tr("Successfully saved XML file") + newfm);
			}
			else
				QMessageBox::warning(this,tr("failed"),tr("Save CMD file") + newfm + tr(" Failed"));
        }
835 836
	}
}
837

838
void qtvplugin_geomarker::on_pushButton_QTV_load_clicked()
839
{
840
	QSettings settings(ini_file(),QSettings::IniFormat);
841 842
	QString strLastSaveImgDir = settings.value("history/last_open_xml_dir","./").toString();
	QString newfm = QFileDialog::getOpenFileName(this,tr("load from xml"),strLastSaveImgDir,
843
                                 "xml (*.xml);;cmd (*.cmd);;All files(*.*)"
844 845 846
								 );
	if (newfm.size()>2)
	{
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866
        if (newfm.right(3).toUpper()=="XML")
        {
            if (true==xml_load(newfm))
            {
                settings.setValue("history/last_open_xml_dir",newfm);
                //QMessageBox::information(this,tr("succeed"),tr("Successfully load XML file") + newfm);
            }
            else
                QMessageBox::warning(this,tr("failed"),tr("Load XML file") + newfm + tr(" Failed"));
        }
        else
        {
			if (true==cmd_load(newfm))
			{
				settings.setValue("history/last_open_xml_dir",newfm);
				//QMessageBox::information(this,tr("succeed"),tr("Successfully load XML file") + newfm);
			}
			else
				QMessageBox::warning(this,tr("failed"),tr("Load CMD file") + newfm + tr(" Failed"));
        }
867
	}
丁劲犇's avatar
丁劲犇 已提交
868
	scheduleRefreshMarks();
869 870
	m_pVi->UpdateWindow();
}
871
void qtvplugin_geomarker::on_pushButton_QTV_import_icon_clicked()
丁劲犇's avatar
丁劲犇 已提交
872
{
873
	DialogSelectIcon dlg (ini_file()) ;
874
	if (dlg.exec()==QDialog::Accepted)
丁劲犇's avatar
丁劲犇 已提交
875
	{
876
		m_map_icons[dlg.m_icon.name] = dlg.m_icon;
丁劲犇's avatar
丁劲犇 已提交
877
	}
878
	refreshIconModel();
丁劲犇's avatar
丁劲犇 已提交
879
}
880
void qtvplugin_geomarker::on_pushButton_QTV_load_icons_clicked()
丁劲犇's avatar
丁劲犇 已提交
881 882
{
	QSettings settings(ini_file(),QSettings::IniFormat);
883
	QString strLastSaveImgDir = settings.value("history/last_save_icon_xml_dir","./").toString();
丁劲犇's avatar
丁劲犇 已提交
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899
	QString newfm = QFileDialog::getOpenFileName(this,tr("load from xml"),strLastSaveImgDir,
								 "xml (*.xml);;All files(*.*)"
								 );
	if (newfm.size()>2)
	{
		if (true==xml_icon_load(newfm))
		{
			settings.setValue("history/last_load_icon_xml_dir",newfm);
			//QMessageBox::information(this,tr("succeed"),tr("Successfully load XML file") + newfm);
		}
		else
			QMessageBox::warning(this,tr("failed"),tr("Load XML file") + newfm + tr(" Failed"));
	}
	this->refreshIconModel();
}

900
void qtvplugin_geomarker::on_pushButton_QTV_save_icons_clicked()
丁劲犇's avatar
丁劲犇 已提交
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917
{
	QSettings settings(ini_file(),QSettings::IniFormat);
	QString strLastSaveImgDir = settings.value("history/last_save_icon_xml_dir","./").toString();
	QString newfm = QFileDialog::getSaveFileName(this,tr("save to xml"),strLastSaveImgDir,
								 "xml (*.xml);;All files(*.*)"
								 );
	if (newfm.size()>2)
	{
		if (true==xml_icon_save(newfm))
		{
			settings.setValue("history/last_save_icon_xml_dir",newfm);
			//QMessageBox::information(this,tr("succeed"),tr("Successfully saved XML file") + newfm);
		}
		else
			QMessageBox::warning(this,tr("failed"),tr("Save XML file") + newfm + tr(" Failed"));
	}
}
918
void qtvplugin_geomarker::on_pushButton_QTV_collaps_all_clicked()
919
{
丁劲犇's avatar
丁劲犇 已提交
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934
	QList< QTVP_GEOMARKER::geoItemBase *  > lst = m_pScene->geo_items();

	bool needupdate = false;
	foreach (QTVP_GEOMARKER::geoItemBase * base,lst)
	{
		bool bOldVis = base->props_visible();
		if (bOldVis)
			needupdate = true;
		base->show_props(false);
	}
	if (needupdate)
	{
		//scheduleRefreshMarks();
		scheduleUpdateMap();
	}
935
}
936
void qtvplugin_geomarker::on_pushButton_QTV_refresh_list_clicked()
丁劲犇's avatar
丁劲犇 已提交
937 938 939
{
	this->scheduleRefreshMarks();
}
940
void qtvplugin_geomarker::on_radioButton_QTV_display_clicked()
丁劲犇's avatar
丁劲犇 已提交
941 942 943 944 945 946 947 948 949 950 951 952
{
	if (!m_pVi)	return ;
	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();
953
	ui->toolBox_QTV_marks->setCurrentIndex(0);
丁劲犇's avatar
丁劲犇 已提交
954 955 956

}

957
void qtvplugin_geomarker::on_radioButton_QTV_rect_selection_clicked()
丁劲犇's avatar
丁劲犇 已提交
958 959 960 961 962 963 964
{
	if (!m_pVi)	return ;
	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();
965
	ui->toolBox_QTV_marks->setCurrentIndex(1);
丁劲犇's avatar
丁劲犇 已提交
966
}
967
void qtvplugin_geomarker::on_pushButton_QTV_sel_clear_clicked()
丁劲犇's avatar
丁劲犇 已提交
968 969 970 971
{
	clearSelection();
}

972
void qtvplugin_geomarker::on_pushButton_QTV_sel_delselected_clicked()
丁劲犇's avatar
丁劲犇 已提交
973 974 975 976 977 978 979 980 981 982
{
	foreach (QString namep,m_set_itemNameSelected)
	{
		QTVP_GEOMARKER::geoItemBase * b = m_pScene->geoitem_by_name(namep);
		if (b)
			m_pScene->removeItem(b,0);
	}
	clearSelection();
	scheduleRefreshMarks();
}
983
void qtvplugin_geomarker::on_pushButton_QTV_style_default_save_clicked()
984 985 986 987
{
	style_save();
}

988
void qtvplugin_geomarker::on_pushButton_QTV_style_default_load_clicked()
989 990 991
{
	style_load();
}