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

We introduce style default settings in geomarker.

With the help of this feature, a function call without complete style para will use the default.
上级 2556a10f
......@@ -161,6 +161,7 @@ layer_interface * qtvplugin_geomarker::load_initial_plugin(QString strSLibPath,v
loadTranslations();
ini_load();
style_load();
initialBindPluginFuntions();
}
//3. elseif, we call the instance's load_initial_plugin method instead
......
......@@ -52,6 +52,21 @@ private:
QMap<QString, QString> styles;
QMap<QString, QString> props;
};
struct tag_style_item{
int n_point_width;
int n_point_height;
int n_point_rect;
QPen pen;
QBrush brush;
QColor text_color;
QFont font;
qreal rotate;
qreal scale;
int multiline;
int smooth;
QString icon_name;
};
//The global icon map
QMap<QString,QTVP_GEOMARKER::tag_icon> m_map_icons;
//Enum tools
......@@ -111,9 +126,13 @@ private:
//persistent functions
private:
//default style
tag_style_item m_default_style;
QString ini_file();
void ini_save();
void ini_load();
void style_save();
void style_load();
bool xml_save (QString xml);
bool xml_load (QString xml);
bool xml_readMark (QXmlStreamReader & reader, tag_xml_mark & mark,QString & errMsg);
......@@ -179,6 +198,9 @@ private:
QMap<QString, QVariant> func_selection_clear(const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_selection_delete(const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_selected_items (const QMap<QString, QVariant> &);
//style setting
QMap<QString, QVariant> func_set_default_style(const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_default_style (const QMap<QString, QVariant> &);
//overloaded virtual funtions
protected:
......@@ -231,6 +253,8 @@ protected slots:
void on_radioButton_rect_selection_clicked();
void on_pushButton_sel_clear_clicked();
void on_pushButton_sel_delselected_clicked();
void on_pushButton_style_default_save_clicked();
void on_pushButton_style_default_load_clicked();
};
template <class T>
......
......@@ -182,8 +182,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>169</width>
<height>229</height>
<width>142</width>
<height>121</height>
</rect>
</property>
<attribute name="label">
......@@ -441,7 +441,7 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_point_size_height">
<widget class="QSpinBox" name="spinBox_point_height">
<property name="minimum">
<number>1</number>
</property>
......@@ -602,7 +602,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QCheckBox" name="checkBox_close">
<widget class="QCheckBox" name="checkBox_multiline">
<property name="text">
<string>Multiline(Not close)</string>
</property>
......@@ -775,22 +775,36 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_11">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_style_default_save">
<property name="text">
<string>Pen width</string>
<string>Save to default style</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_penWidth">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>256</number>
<widget class="QPushButton" name="pushButton_style_default_load">
<property name="text">
<string>Load from default style</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="label_19">
<property name="text">
......@@ -801,10 +815,6 @@
<item>
<widget class="QComboBox" name="comboBox_linePad"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="label_12">
<property name="text">
......@@ -826,6 +836,23 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Pen width</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_penWidth">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>256</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_16">
<property name="text">
......@@ -942,10 +969,17 @@
<item>
<widget class="QLineEdit" name="lineEdit_prop_name"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_prop_update">
<property name="text">
<string>Update Prop</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_prop_delete">
<property name="text">
<string>Delete</string>
<string>Delete Prop</string>
</property>
</widget>
</item>
......@@ -963,13 +997,6 @@
<item>
<widget class="QLineEdit" name="lineEdit_prop_string"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_prop_update">
<property name="text">
<string>Update</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......
......@@ -35,6 +35,8 @@
* 20 selection_clear clear all selected items' status.
* 21 selection_delete delete all selected items.
* 22 selected_items return all selected item names
* 23 set_default_style will set default style for item mark
* 24 default_style will return current default style
* @param paras the key-value style paraments.
* @return QMap<QString, QVariant> the key-value style return values.
*/
......@@ -82,8 +84,8 @@ void qtvplugin_geomarker::initialBindPluginFuntions()
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);
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);
}
/**
......@@ -111,10 +113,10 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
return std::move(res);
}
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
QPen pen(Qt::SolidLine);
QBrush brush(QColor(255,255,255,128));
qreal width =8;
qreal height =8;
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;
//if the mark is already exist, we will get its orgional style as default .
if (base)
{
......@@ -224,7 +226,9 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
double lat =paras["lat"].toDouble();
double lon = paras["lon"].toDouble();
int tpn = paras["type"].toInt();
int tpn = m_default_style.n_point_rect == 0 ? 2:1;
if (paras.contains("type"))
tpn = paras["type"].toInt();
if (tpn > 2 || tpn <1) tpn = 1;
QTVP_GEOMARKER::geo_item_type tpe = static_cast< QTVP_GEOMARKER::geo_item_type > (tpn);
//update using same function in UI
......@@ -234,7 +238,7 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
newitem = update_point<QTVP_GEOMARKER::geoGraphicsEllipseItem>(name,lat,lon,width,height,pen,brush);
if (newitem)
{
QFont f = newitem->labelFont();
QFont f ( m_default_style.font );
//! size_label stands for the text label font pixel size from 1 - 720, with a normal value 9.
if ( paras.contains("size_label"))
{
......@@ -255,6 +259,8 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_point (const QMap<QStr
QColor textColor = string2color( paras["color_label"].toString());
newitem->setLabelColor(textColor);
}
else
newitem->setLabelColor(m_default_style.text_color);
//scheduleRefreshMarks();
scheduleUpdateMap();
}
......@@ -287,10 +293,10 @@ QMap<QString, QVariant> qtvplugin_geomarker:: func_update_icon (const QMap<QSt
return std::move(res);
}
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
QString icon_name = "default";
qreal scale = 1.0;
qreal rot = 0.0;
int smooth = 0;
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;
//if the mark is already exist, we will get its orgional style as default .
if (base)
{
......@@ -337,7 +343,7 @@ QMap<QString, QVariant> qtvplugin_geomarker:: func_update_icon (const QMap<QSt
newitem = update_icon(name,lat,lon,scale,rot,smooth,icon_name);
if (newitem)
{
QFont f = newitem->labelFont();
QFont f (m_default_style.font);
//! size_label stands for the text label font pixel size from 1 - 720, with a normal value 9.
if ( paras.contains("size_label"))
{
......@@ -358,6 +364,8 @@ QMap<QString, QVariant> qtvplugin_geomarker:: func_update_icon (const QMap<QSt
QColor textColor = string2color( paras["color_label"].toString());
newitem->setLabelColor(textColor);
}
else
newitem->setLabelColor( m_default_style.text_color);
//scheduleRefreshMarks();
scheduleUpdateMap();
}
......@@ -392,7 +400,7 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_line (const QMap<QStr
return std::move(res);
}
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
QPen pen(Qt::SolidLine);
QPen pen (m_default_style.pen);
//if the mark is already exist, we will get its orgional style as default .
if (base)
......@@ -451,7 +459,7 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_line (const QMap<QStr
newitem = update_line(name,lat1,lon1,lat2,lon2,pen);
if (newitem)
{
QFont f = newitem->labelFont();
QFont f (m_default_style.font);
//! size_label stands for the text label font pixel size from 1 - 720, with a normal value 9.
if ( paras.contains("size_label"))
{
......@@ -472,6 +480,8 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_line (const QMap<QStr
QColor textColor = string2color( paras["color_label"].toString());
newitem->setLabelColor(textColor);
}
else
newitem->setLabelColor(m_default_style.text_color);
//scheduleRefreshMarks();
scheduleUpdateMap();
}
......@@ -507,7 +517,7 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
return std::move(res);
}
int type = 4;//polygon
int type = m_default_style.multiline==0?4:6;//polygon
if (paras.contains("type")==true)
{
type = paras["type"].toInt();
......@@ -521,8 +531,8 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
QPen pen(Qt::SolidLine);
QBrush brush(QColor(255,255,255,128));
QPen pen(m_default_style.pen);
QBrush brush(m_default_style.brush);
//if the mark is already exist, we will get its orgional style as default .
if (base)
......@@ -636,7 +646,7 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
if (newitem)
{
QFont f = newitem->labelFont();
QFont f (m_default_style.font);
//! size_label stands for the text label font pixel size from 1 - 720, with a normal value 9.
if ( paras.contains("size_label"))
{
......@@ -657,6 +667,8 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_update_polygon (const QMap<QS
QColor textColor = string2color( paras["color_label"].toString());
newitem->setLabelColor(textColor);
}
else
newitem->setLabelColor(m_default_style.text_color);
//scheduleRefreshMarks();
scheduleUpdateMap();
}
......@@ -784,6 +796,8 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_delete_marks (const QMap<QSt
foreach (QTVP_GEOMARKER::geoItemBase * key,lst)
m_pScene->removeItem(key,0);
res["ALL"] = 1;
needUpdate = true;
scheduleRefreshMarks();
}
if (needUpdate)
{
......@@ -1448,3 +1462,213 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_selected_items (const QMap<Q
//! name0=??;name1=??;name2=??...namen-1=??
return std::move(res);
}
/**
* @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;
}
ui->comboBox_linePad->setCurrentIndex(ptdd);
}
//! color_pen has 4 pen color band values splitted by comma, r,g,b,a
if ( paras.contains("color_pen"))
{
ui->lineEdit_PenColor->setText(paras["color_pen"].toString());
}
//! 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;
}
ui->spinBox_penWidth->setValue(penWidth);
}
//! 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.";
}
ui->comboBox_fillPad->setCurrentIndex(btdd);
}
//! color_brush has 4 brush color band values splitted by comma, r,g,b,a
if ( paras.contains("color_brush"))
{
ui->lineEdit_FillColor->setText( paras["color_brush"].toString());
}
//! 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;
ui->spinBox_point_width->setValue(point_width);
}
//! 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;
ui->spinBox_point_height->setValue(point_height);
}
//! 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:
ui->radioButton_PointRect->setChecked(true);
break;
case 2:
ui->radioButton_PointRound->setChecked(true);
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:
ui->checkBox_multiline->setChecked(false);
break;
case 6:
ui->checkBox_multiline->setChecked(true);
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;
ui->spinBox_fontSize->setValue(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();
if (fontWeight>=0 && fontWeight <100)
ui->spinBox_textWeight->setValue(fontWeight);
}
//! color_label has 4 text color band values splitted by comma, r,g,b,a
if ( paras.contains("color_label"))
{
ui->lineEdit_TextColor->setText(paras["color_label"].toString());
}
//! icon is the name that this mark will use.
if ( paras.contains("icon"))
{
QString icn = paras["icon"].toString();
if (m_map_icons.contains(icn))
ui->comboBox_icons->setCurrentText(icn);
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 )
ui->lineEdit_icon_scale->setText(QString("%1").arg(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();
ui->lineEdit_icon_rotate->setText(QString("%1").arg(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();
ui->checkBox_icon_smooth->setChecked(smt==0?false:true);
}
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.
res["style_pen"] = ui->comboBox_linePad->currentIndex();
//! color_pen has 4 pen color band values splitted by comma, r,g,b,a
res["color_pen"] = ui->lineEdit_PenColor->text();
//! width_pen has a value >0 , stand for the point width of the pen on screen.
res["width_pen"] = ui->spinBox_penWidth->value();
//! style_brush from 0~14, is corresponds to the brush style combo-box in UI system.
res["style_brush"] = ui->comboBox_fillPad->currentIndex();
//! color_brush has 4 brush color band values splitted by comma, r,g,b,a
res["color_brush"] = ui->lineEdit_FillColor->text();
//! width has is a integer, means the default width of a point mark
res["width"] = ui->spinBox_point_width->value();
//! height has is a integer, means the default width of a point mark
res["height"] = ui->spinBox_point_height->value();
//! mark default point_type select , 1 means rect, 2 means Ecilips
res["point_type"] = ui->radioButton_PointRect->isChecked()?1:2;
//! mark default polygon_type select , 4 means polygon, 6 mean multiline
res["polygon_type"] = ui->checkBox_multiline->isChecked()?6:4;
//! size_label stands for the text label font pixel size from 1 - 720, with a normal value 9.
res["size_label"] = ui->spinBox_fontSize->value();
//! weight_label is the bolder rate for text renderring, from 1 ~ 99, 99 is the heaviest.
res["weight_label"] = ui->spinBox_textWeight->value();
//! color_label has 4 text color band values splitted by comma, r,g,b,a
res["color_label"] = ui->lineEdit_TextColor->text();
//! icon is the name that this mark will use.
res["icon"] = ui->comboBox_icons->currentText();
//! scale is the zoom ratio that this icon will use, 1.0 means no zoom
res["scale"] = ui->lineEdit_icon_scale->text();
//! rotate is the rotate angle that this icon will use, 0.0 means no rotate
res["rotate"] = ui->lineEdit_icon_rotate->text();
//!smooth is the transform mode that this icon will use. 0 mean not smooth, but faster. 1 mean smooth.
res["smooth"] = ui->checkBox_icon_smooth->isChecked()?-1:0;
return std::move(res);
}
......@@ -149,7 +149,7 @@ void qtvplugin_geomarker::ini_save()
settings.setValue("ui/lineEdit_point_lat",ui->lineEdit_point_lat->text());
settings.setValue("ui/lineEdit_point_lon",ui->lineEdit_point_lon->text());
settings.setValue("ui/spinBox_point_width",ui->spinBox_point_width->value());
settings.setValue("ui/spinBox_point_size_height",ui->spinBox_point_size_height->value());
settings.setValue("ui/spinBox_point_height",ui->spinBox_point_height->value());
int radioButton_PointRect = 0;
......@@ -177,7 +177,7 @@ void qtvplugin_geomarker::ini_save()
settings.setValue("ui/lineEdit_icon_lon",ui->lineEdit_icon_lon->text());
settings.setValue("ui/lineEdit_icon_rotate",ui->lineEdit_icon_rotate->text());
settings.setValue("ui/lineEdit_icon_scale",ui->lineEdit_icon_scale->text());
settings.setValue("ui/checkBox_close",ui->checkBox_close->isChecked()?-1:0);
settings.setValue("ui/checkBox_multiline",ui->checkBox_multiline->isChecked()?-1:0);
}
void qtvplugin_geomarker::ini_load()
......@@ -211,8 +211,8 @@ void qtvplugin_geomarker::ini_load()
ui->lineEdit_point_lon->setText(lineEdit_point_lon);
int spinBox_point_width = settings.value("ui/spinBox_point_width",8).toInt();
ui->spinBox_point_width->setValue(spinBox_point_width);
int spinBox_point_size_height = settings.value("ui/spinBox_point_size_height",8).toInt();
ui->spinBox_point_size_height->setValue(spinBox_point_size_height);
int spinBox_point_height = settings.value("ui/spinBox_point_height",8).toInt();
ui->spinBox_point_height->setValue(spinBox_point_height);
QString lineEdit_PenColor = settings.value("ui/lineEdit_PenColor",color2string(QColor(0,0,0,128))).toString();
ui->lineEdit_PenColor->setText(lineEdit_PenColor);
QString lineEdit_FillColor = settings.value("ui/lineEdit_FillColor",color2string(QColor(255,255,255,128))).toString();
......@@ -270,10 +270,139 @@ void qtvplugin_geomarker::ini_load()
QString lineEdit_icon_rotate = settings.value("ui/lineEdit_icon_rotate","1.0").toString();
ui->lineEdit_icon_rotate->setText(lineEdit_icon_rotate);
int checkBox_close = settings.value("ui/checkBox_close",0).toInt();
ui->checkBox_close->setChecked(checkBox_close?true:false);
int checkBox_multiline = settings.value("ui/checkBox_multiline",0).toInt();
ui->checkBox_multiline->setChecked(checkBox_multiline?true:false);
}
void qtvplugin_geomarker::style_save()
{
QSettings settings(ini_file(),QSettings::IniFormat);
settings.setValue("default_style/spinBox_point_width",ui->spinBox_point_width->value());
settings.setValue("default_style/spinBox_point_height",ui->spinBox_point_height->value());
int radioButton_PointRect = 0;
if (ui->radioButton_PointRound->isChecked()==true) radioButton_PointRect = 1;
else radioButton_PointRect = 0;
settings.setValue("default_style/radioButton_PointRect",radioButton_PointRect);
settings.setValue("default_style/lineEdit_PenColor",ui->lineEdit_PenColor->text());
settings.setValue("default_style/lineEdit_FillColor",ui->lineEdit_FillColor->text());
settings.setValue("default_style/lineEdit_TextColor",ui->lineEdit_TextColor->text());
settings.setValue("default_style/spinBox_penWidth",ui->spinBox_penWidth->value());
settings.setValue("default_style/comboBox_linePad",ui->comboBox_linePad->currentIndex());
settings.setValue("default_style/comboBox_fillPad",ui->comboBox_fillPad->currentIndex());
settings.setValue("default_style/spinBox_textWeight",ui->spinBox_textWeight->value());
settings.setValue("default_style/spinBox_fontSize",ui->spinBox_fontSize->value());
settings.setValue("default_style/lineEdit_icon_rotate",ui->lineEdit_icon_rotate->text());
settings.setValue("default_style/lineEdit_icon_scale",ui->lineEdit_icon_scale->text());
settings.setValue("default_style/checkBox_multiline",ui->checkBox_multiline->isChecked()?-1:0);
settings.setValue("default_style/checkBox_icon_smooth",ui->checkBox_icon_smooth->isChecked()?-1:0);
settings.setValue("default_style/comboBox_icons",ui->comboBox_icons->currentText());
//update current style
m_default_style.n_point_width = ui->spinBox_point_width->value();
m_default_style.n_point_height = ui->spinBox_point_height->value();
m_default_style.n_point_rect = radioButton_PointRect;
m_default_style.pen.setColor(string2color(ui->lineEdit_PenColor->text()));
m_default_style.pen.setWidth(ui->spinBox_penWidth->value());
m_default_style.pen.setStyle(static_cast<Qt::PenStyle>(ui->comboBox_linePad->currentIndex()));
m_default_style.brush.setColor(string2color(ui->lineEdit_FillColor->text()));
m_default_style.brush.setStyle(static_cast<Qt::BrushStyle>(ui->comboBox_fillPad->currentIndex()));
m_default_style.text_color = string2color(ui->lineEdit_TextColor->text());
m_default_style.font.setWeight(ui->spinBox_textWeight->value());
m_default_style.font.setPointSize(ui->spinBox_fontSize->value());
m_default_style.scale = ui->lineEdit_icon_scale->text().toFloat();
m_default_style.rotate = ui->lineEdit_icon_rotate->text().toFloat();
m_default_style.multiline = ui->checkBox_multiline->isChecked()?-1:0;
m_default_style.smooth = ui->checkBox_icon_smooth->isChecked()?-1:0;
m_default_style.icon_name = ui->comboBox_icons->currentText();
}
void qtvplugin_geomarker::style_load()
{
QSettings settings(ini_file(),QSettings::IniFormat);
int spinBox_point_width = settings.value("default_style/spinBox_point_width",8).toInt();
ui->spinBox_point_width->setValue(spinBox_point_width);
int spinBox_point_height = settings.value("default_style/spinBox_point_height",8).toInt();
ui->spinBox_point_height->setValue(spinBox_point_height);
QString lineEdit_PenColor = settings.value("default_style/lineEdit_PenColor",color2string(QColor(0,0,0,128))).toString();
ui->lineEdit_PenColor->setText(lineEdit_PenColor);
QString lineEdit_FillColor = settings.value("default_style/lineEdit_FillColor",color2string(QColor(255,255,255,128))).toString();
ui->lineEdit_FillColor->setText(lineEdit_FillColor);
QString lineEdit_TextColor = settings.value("default_style/lineEdit_TextColor",color2string(QColor(0,0,0))).toString();
ui->lineEdit_TextColor->setText(lineEdit_TextColor);
int radioButton_PointRect = settings.value("default_style/radioButton_PointRect",0).toInt();
switch (radioButton_PointRect)
{
case 0:
ui->radioButton_PointRect->setChecked(true);
break;
case 1:
ui->radioButton_PointRound->setChecked(true);
break;
default:
ui->radioButton_PointRect->setChecked(true);
break;
}
int spinBox_penWidth = settings.value("default_style/spinBox_penWidth",3).toInt();
ui->spinBox_penWidth->setValue(spinBox_penWidth);
int comboBox_linePad = settings.value("default_style/comboBox_linePad",1).toInt();
ui->comboBox_linePad->setCurrentIndex(comboBox_linePad);
int comboBox_fillPad = settings.value("default_style/comboBox_fillPad",1).toInt();
ui->comboBox_fillPad->setCurrentIndex(comboBox_fillPad);
int spinBox_fontSize = settings.value("default_style/spinBox_fontSize",9).toInt();
ui->spinBox_fontSize->setValue(spinBox_fontSize);
int spinBox_textWeight = settings.value("default_style/spinBox_textWeight",16).toInt();
ui->spinBox_textWeight->setValue(spinBox_textWeight);
QString lineEdit_icon_scale = settings.value("default_style/lineEdit_icon_scale","1.0").toString();
ui->lineEdit_icon_scale->setText(lineEdit_icon_scale);
QString lineEdit_icon_rotate = settings.value("default_style/lineEdit_icon_rotate","1.0").toString();
ui->lineEdit_icon_rotate->setText(lineEdit_icon_rotate);
int checkBox_multiline = settings.value("default_style/checkBox_multiline",0).toInt();
ui->checkBox_multiline->setChecked(checkBox_multiline?true:false);
int checkBox_icon_smooth = settings.value("default_style/checkBox_icon_smooth",0).toInt();
ui->checkBox_icon_smooth->setChecked(checkBox_icon_smooth?true:false);
QString comboBox_icons = settings.value("default_style/comboBox_icons","default").toString();
if (m_map_icons.contains(comboBox_icons))
ui->comboBox_icons->setCurrentText(comboBox_icons);
//update current style
m_default_style.n_point_width = ui->spinBox_point_width->value();
m_default_style.n_point_height = ui->spinBox_point_height->value();
m_default_style.n_point_rect = radioButton_PointRect;
m_default_style.pen.setColor(string2color(ui->lineEdit_PenColor->text()));
m_default_style.pen.setWidth(ui->spinBox_penWidth->value());
m_default_style.pen.setStyle(static_cast<Qt::PenStyle>(ui->comboBox_linePad->currentIndex()));
m_default_style.brush.setColor(string2color(ui->lineEdit_FillColor->text()));
m_default_style.brush.setStyle(static_cast<Qt::BrushStyle>(ui->comboBox_fillPad->currentIndex()));
m_default_style.text_color = string2color(ui->lineEdit_TextColor->text());
m_default_style.font.setWeight(ui->spinBox_textWeight->value());
m_default_style.font.setPointSize(ui->spinBox_fontSize->value());
m_default_style.scale = ui->lineEdit_icon_scale->text().toFloat();
m_default_style.rotate = ui->lineEdit_icon_rotate->text().toFloat();
m_default_style.multiline = ui->checkBox_multiline->isChecked()?-1:0;
m_default_style.smooth = ui->checkBox_icon_smooth->isChecked()?-1:0;
m_default_style.icon_name = ui->comboBox_icons->currentText();
}
void qtvplugin_geomarker::on_pushButton_update_clicked()
{
if (m_pVi==0 || !m_pScene)
......@@ -336,7 +465,7 @@ void qtvplugin_geomarker::on_pushButton_update_clicked()
double lon = ui->lineEdit_point_lon->text().toDouble();
int tp = ui->radioButton_PointRect->isChecked()?0:1;
int width = ui->spinBox_point_width->value();
int height = ui->spinBox_point_size_height->value();
int height = ui->spinBox_point_height->value();
if (tp==0)
newitem = update_point<QTVP_GEOMARKER::geoGraphicsRectItem>(name,lat,lon,width,height,pen,brush);
else
......@@ -372,7 +501,7 @@ void qtvplugin_geomarker::on_pushButton_update_clicked()
latlons.push_back(ll);
}
if (latlons.size())
newitem = update_polygon(name,latlons,pen,brush,ui->checkBox_close->isChecked()?true:false);
newitem = update_polygon(name,latlons,pen,brush,ui->checkBox_multiline->isChecked()?true:false);
}
else if (ui->radioButton_tool_icons->isChecked())
......@@ -527,7 +656,7 @@ void qtvplugin_geomarker::refreshItemUI(QString markname)
ui->lineEdit_point_lon->setText(QString("%1").arg(pitem->lon(),0,'f',7));
ui->radioButton_PointRect->setChecked(true);
ui->spinBox_point_width->setValue(pitem->width());
ui->spinBox_point_size_height->setValue(pitem->height());
ui->spinBox_point_height->setValue(pitem->height());
ui->radioButton_tool_point->setChecked(true);
}
break;
......@@ -542,7 +671,7 @@ void qtvplugin_geomarker::refreshItemUI(QString markname)
ui->lineEdit_point_lon->setText(QString("%1").arg(pitem->lon(),0,'f',7));
ui->radioButton_PointRound->setChecked(true);
ui->spinBox_point_width->setValue(pitem->width());
ui->spinBox_point_size_height->setValue(pitem->height());
ui->spinBox_point_height->setValue(pitem->height());
ui->radioButton_tool_point->setChecked(true);
}
break;
......@@ -572,7 +701,7 @@ void qtvplugin_geomarker::refreshItemUI(QString markname)
strPlainText += QString("%1,%2;\n").arg(p.y(),0,'f',7).arg(p.x(),0,'f',7);
ui->plainTextEdit_corners->setPlainText(strPlainText);
ui->radioButton_tool_polygon->setChecked(true);
ui->checkBox_close->setChecked(false);
ui->checkBox_multiline->setChecked(false);
}
break;
case QTVP_GEOMARKER::ITEAMTYPE_PIXMAP:
......@@ -602,7 +731,7 @@ void qtvplugin_geomarker::refreshItemUI(QString markname)
strPlainText += QString("%1,%2;\n").arg(p.y(),0,'f',7).arg(p.x(),0,'f',7);
ui->plainTextEdit_corners->setPlainText(strPlainText);
ui->radioButton_tool_polygon->setChecked(true);
ui->checkBox_close->setChecked(true);
ui->checkBox_multiline->setChecked(true);
}
break;
......@@ -818,3 +947,12 @@ void qtvplugin_geomarker::on_pushButton_sel_delselected_clicked()
clearSelection();
scheduleRefreshMarks();
}
void qtvplugin_geomarker::on_pushButton_style_default_save_clicked()
{
style_save();
}
void qtvplugin_geomarker::on_pushButton_style_default_load_clicked()
{
style_load();
}
......@@ -773,12 +773,13 @@ void qtvplugin_grid::on_pushButton_add_mark_clicked()
}
else
{
QMessageBox::warning(
this,
tr("Error LLA formar"),
tr("lat lon must have same element nums.")
);
break;
// QMessageBox::warning(
// this,
// tr("Error LLA formar"),
// tr("lat lon must have same element nums.")
// );
// break;
continue;
}
if (bLatFirst==false)
{
......@@ -797,16 +798,16 @@ void qtvplugin_grid::on_pushButton_add_mark_clicked()
inPara["name"] = QString("%1_%2").arg(get_name()).arg(m_nMarks);
inPara["lat"] = lat;
inPara["lon"] = lon;
inPara["color_pen"] = "0,0,255,128";
inPara["color_brush"] = "0,0,0,64";
inPara["width"] = "7";
inPara["height"] = "7";
inPara["type"] = 1;
//inPara["color_pen"] = "0,0,255,128";
//inPara["color_brush"] = "0,0,0,64";
//inPara["width"] = "7";
//inPara["height"] = "7";
//inPara["type"] = 1;
outPara = pif->call_func(inPara);
inPara.clear();
inPara["function"] = "update_props";
inPara["name"] = QString("%1_%2").arg(get_name()).arg(m_nMarks);
inPara["LABEL"] = QString("%1,%2").arg(lat).arg(lon);
inPara["POS"] = QString("%1,%2").arg(lat).arg(lon);
++m_nMarks;
outPara = pif->call_func(inPara);
}
......@@ -823,8 +824,8 @@ void qtvplugin_grid::on_pushButton_add_mark_clicked()
QMap<QString, QVariant> outPara;
map_multi["function"] = "update_polygon";
map_multi["name"] = QString("%1_%2").arg(get_name()).arg(m_nMarks);
map_multi["color_pen"] = "0,0,255,128";
map_multi["color_brush"] = "0,0,0,64";
//map_multi["color_pen"] = "0,0,255,128";
//map_multi["color_brush"] = "0,0,0,64";
map_multi["type"] = (tp==1)?6:4;
outPara = pif->call_func(map_multi);
++m_nMarks;
......
......@@ -574,3 +574,14 @@ void testcontainer::on_pushButton_test_geo_del_sel_clicked()
QMessageBox::information(this,"geomarker::selection_delete",res);
}
void testcontainer::on_pushButton_default_style_clicked()
{
QString res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)",m_str_markerLayerName,
"function=default_style;").toString();
QMessageBox::information(this,"geomarker::default_style",res);
res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)",m_str_markerLayerName,
"function=set_default_style;" + res).toString();
if (res.contains("error"))
QMessageBox::information(this,"geomarker::selection_delete",res);
}
......@@ -51,6 +51,7 @@ protected slots:
void on_pushButton_test_geo_selected_marks_clicked();
void on_pushButton_test_geo_clear_sel_clicked();
void on_pushButton_test_geo_del_sel_clicked();
void on_pushButton_default_style_clicked();
void on_osmmap_map_event(QMap<QString, QVariant> p);
};
......
......@@ -211,6 +211,13 @@
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QPushButton" name="pushButton_default_style">
<property name="text">
<string>default_style</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册