From 6b55c8c9febbf66d7ebd4224c104ed0c3eeb5698 Mon Sep 17 00:00:00 2001 From: goldenhawking Date: Fri, 22 Apr 2016 15:03:10 +0000 Subject: [PATCH] We introduce style default settings in geomarker. With the help of this feature, a function call without complete style para will use the default. --- qtvplugin_geomarker/qtvplugin_geomarker.cpp | 1 + qtvplugin_geomarker/qtvplugin_geomarker.h | 24 ++ qtvplugin_geomarker/qtvplugin_geomarker.ui | 75 +++-- .../qtvplugin_geomarker_func.cpp | 262 ++++++++++++++++-- .../qtvplugin_geomarker_uimethods.cpp | 162 ++++++++++- qtvplugin_grid/qtvplugin_grid.cpp | 29 +- test_container/testcontainer.cpp | 11 + test_container/testcontainer.h | 1 + test_container/testcontainer.ui | 7 + 9 files changed, 503 insertions(+), 69 deletions(-) diff --git a/qtvplugin_geomarker/qtvplugin_geomarker.cpp b/qtvplugin_geomarker/qtvplugin_geomarker.cpp index a83545f..1facfe4 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker.cpp +++ b/qtvplugin_geomarker/qtvplugin_geomarker.cpp @@ -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 diff --git a/qtvplugin_geomarker/qtvplugin_geomarker.h b/qtvplugin_geomarker/qtvplugin_geomarker.h index b3b312d..659f1ff 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker.h +++ b/qtvplugin_geomarker/qtvplugin_geomarker.h @@ -52,6 +52,21 @@ private: QMap styles; QMap 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 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 func_selection_clear(const QMap &); QMap func_selection_delete(const QMap &); QMap func_selected_items (const QMap &); + //style setting + QMap func_set_default_style(const QMap &); + QMap func_default_style (const QMap &); //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 diff --git a/qtvplugin_geomarker/qtvplugin_geomarker.ui b/qtvplugin_geomarker/qtvplugin_geomarker.ui index 8b9987c..f938ca8 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker.ui +++ b/qtvplugin_geomarker/qtvplugin_geomarker.ui @@ -182,8 +182,8 @@ 0 0 - 169 - 229 + 142 + 121 @@ -441,7 +441,7 @@ - + 1 @@ -602,7 +602,7 @@ - + Multiline(Not close) @@ -775,22 +775,36 @@ - + + + Qt::Horizontal + + + + 40 + 20 + + + + + + - Pen width + Save to default style - - - 1 - - - 256 + + + Load from default style + + + + @@ -801,10 +815,6 @@ - - - - @@ -826,6 +836,23 @@ + + + + Pen width + + + + + + + 1 + + + 256 + + + @@ -942,10 +969,17 @@ + + + + Update Prop + + + - Delete + Delete Prop @@ -963,13 +997,6 @@ - - - - Update - - - diff --git a/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp b/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp index 57b5c67..4509842 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp +++ b/qtvplugin_geomarker/qtvplugin_geomarker_func.cpp @@ -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 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 qtvplugin_geomarker::func_update_point (const QMapgeoitem_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 qtvplugin_geomarker::func_update_point (const QMap 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 qtvplugin_geomarker::func_update_point (const QMap(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 qtvplugin_geomarker::func_update_point (const QMapsetLabelColor(textColor); } + else + newitem->setLabelColor(m_default_style.text_color); //scheduleRefreshMarks(); scheduleUpdateMap(); } @@ -287,10 +293,10 @@ QMap qtvplugin_geomarker:: func_update_icon (const QMapgeoitem_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 qtvplugin_geomarker:: func_update_icon (const QMaplabelFont(); + 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 qtvplugin_geomarker:: func_update_icon (const QMapsetLabelColor(textColor); } + else + newitem->setLabelColor( m_default_style.text_color); //scheduleRefreshMarks(); scheduleUpdateMap(); } @@ -392,7 +400,7 @@ QMap qtvplugin_geomarker::func_update_line (const QMapgeoitem_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 qtvplugin_geomarker::func_update_line (const QMaplabelFont(); + 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 qtvplugin_geomarker::func_update_line (const QMapsetLabelColor(textColor); } + else + newitem->setLabelColor(m_default_style.text_color); //scheduleRefreshMarks(); scheduleUpdateMap(); } @@ -507,7 +517,7 @@ QMap qtvplugin_geomarker::func_update_polygon (const QMap qtvplugin_geomarker::func_update_polygon (const QMapgeoitem_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 qtvplugin_geomarker::func_update_polygon (const QMaplabelFont(); + 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 qtvplugin_geomarker::func_update_polygon (const QMapsetLabelColor(textColor); } + else + newitem->setLabelColor(m_default_style.text_color); //scheduleRefreshMarks(); scheduleUpdateMap(); } @@ -784,6 +796,8 @@ QMap qtvplugin_geomarker::func_delete_marks (const QMapremoveItem(key,0); res["ALL"] = 1; + needUpdate = true; + scheduleRefreshMarks(); } if (needUpdate) { @@ -1448,3 +1462,213 @@ QMap qtvplugin_geomarker::func_selected_items (const QMap if error happens, a property called "error" will store the most possible reason. + * the return value will be empty if no error happens.; + */ +QMap qtvplugin_geomarker::func_set_default_style(const QMap & paras) +{ + QMap 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 if error happens, a property called "error" will store the most possible reason. + * the return value is listed below: + */ +QMap qtvplugin_geomarker::func_default_style(const QMap &) +{ + QMap 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); +} + diff --git a/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp b/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp index c663b44..f3fb288 100644 --- a/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp +++ b/qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp @@ -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(ui->comboBox_linePad->currentIndex())); + m_default_style.brush.setColor(string2color(ui->lineEdit_FillColor->text())); + m_default_style.brush.setStyle(static_cast(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(ui->comboBox_linePad->currentIndex())); + m_default_style.brush.setColor(string2color(ui->lineEdit_FillColor->text())); + m_default_style.brush.setStyle(static_cast(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(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(); +} diff --git a/qtvplugin_grid/qtvplugin_grid.cpp b/qtvplugin_grid/qtvplugin_grid.cpp index b3546d9..51dda7f 100644 --- a/qtvplugin_grid/qtvplugin_grid.cpp +++ b/qtvplugin_grid/qtvplugin_grid.cpp @@ -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 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; diff --git a/test_container/testcontainer.cpp b/test_container/testcontainer.cpp index 999054a..0673e3c 100644 --- a/test_container/testcontainer.cpp +++ b/test_container/testcontainer.cpp @@ -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); + +} diff --git a/test_container/testcontainer.h b/test_container/testcontainer.h index 9683c8e..63c5b84 100644 --- a/test_container/testcontainer.h +++ b/test_container/testcontainer.h @@ -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 p); }; diff --git a/test_container/testcontainer.ui b/test_container/testcontainer.ui index 1c91dbb..7b7c8fe 100644 --- a/test_container/testcontainer.ui +++ b/test_container/testcontainer.ui @@ -211,6 +211,13 @@ + + + + default_style + + + -- GitLab