diff --git a/Bin/Config/Lang/cn/nmNum_cn.qm b/Bin/Config/Lang/cn/nmNum_cn.qm
index 53099f7b..2cf0aa96 100644
Binary files a/Bin/Config/Lang/cn/nmNum_cn.qm and b/Bin/Config/Lang/cn/nmNum_cn.qm differ
diff --git a/Bin/Config/Lang/cn/nmNum_cn.ts b/Bin/Config/Lang/cn/nmNum_cn.ts
index 3551f2d0..bc62f5cc 100644
--- a/Bin/Config/Lang/cn/nmNum_cn.ts
+++ b/Bin/Config/Lang/cn/nmNum_cn.ts
@@ -2528,10 +2528,6 @@ No valid error was returned; keep the last accepted result and reduce the step.<
Polygon
-
- PolygonOutline
-
-
Fracture
@@ -2548,18 +2544,10 @@ No valid error was returned; keep the last accepted result and reduce the step.<
Rectangle
-
- RectangleOutline
-
-
Circle
-
- CircleOutline
-
-
Limit
@@ -6718,6 +6706,10 @@ Supported types: Vertical, Vertical Fractured, and Horizontal Multi-Fractured We
nmWxParaPropertyPebi
+
+ Vertex %1
+ 顶点 %1
+
RectangleOutline
矩形边界
diff --git a/Src/nmNum/nmData/nmDataOutline.cpp b/Src/nmNum/nmData/nmDataOutline.cpp
index b7e686af..1e130b94 100644
--- a/Src/nmNum/nmData/nmDataOutline.cpp
+++ b/Src/nmNum/nmData/nmDataOutline.cpp
@@ -59,9 +59,10 @@ rapidjson::Value nmDataOutline::ToJsonValue(rapidjson::Document::AllocatorType&
// 创建一个 RapidJSON 对象类型的值
rapidjson::Value outlineObject(rapidjson::kObjectType);
- // 序列化名称
- // 将 QString 转换为 UTF-8 编码的 C 字符串,并添加到 JSON 中
- outlineObject.AddMember("OutlineName", rapidjson::Value(m_sName.toStdString().c_str(), allocator).Move(), allocator);
+ // 与 FromJsonValue 的 UTF-8 读取一致,保留用户手动填写的中文名称。
+ const QByteArray nameUtf8 = m_sName.toUtf8();
+ outlineObject.AddMember("OutlineName", rapidjson::Value(nameUtf8.constData(),
+ static_cast(nameUtf8.size()), allocator).Move(), allocator);
// 序列化点
rapidjson::Value pointsArray(rapidjson::kArrayType); // 创建一个 RapidJSON 数组类型的值
diff --git a/Src/nmNum/nmPlot/nmGuiPlot.cpp b/Src/nmNum/nmPlot/nmGuiPlot.cpp
index 578e32f8..54daf83a 100644
--- a/Src/nmNum/nmPlot/nmGuiPlot.cpp
+++ b/Src/nmNum/nmPlot/nmGuiPlot.cpp
@@ -786,15 +786,17 @@ nmObjBase* nmGuiPlot::_createOneObj(NM_Obj_Type o, QString& sName)
{
Q_ASSERT(NULL != m_pPlot);
- // 确保名称不重复
- QStringList listOlds;
-
- for(int i = 0; i < m_pPlot->getObjCount(); i++) {
- listOlds << m_pPlot->getObjByIndex(i)->getName();
+ const bool bOutline = o == NMOT_RectOutline ||
+ o == NMOT_PolygonOutline || o == NMOT_RoundOutline;
+ // 单一边界允许没有名称;恢复用户自定义名称时也不自动追加编号。
+ if(!bOutline) {
+ QStringList listOlds;
+ for(int i = 0; i < m_pPlot->getObjCount(); i++) {
+ listOlds << m_pPlot->getObjByIndex(i)->getName();
+ }
+ sName = ZxBaseUtil::getNextOneName(listOlds, sName);
}
- sName = ZxBaseUtil::getNextOneName(listOlds, sName);
-
// 创建,此处代码为了简洁,作了非规范性书写
nmObjBase* pObj = NULL;
@@ -836,6 +838,11 @@ nmObjBase* nmGuiPlot::_createOneObj(NM_Obj_Type o, QString& sName)
}
Q_ASSERT(NULL != pObj);
+ if(bOutline) {
+ // 几何基类构造时会加载样式模板;以本次传入名称覆盖模板中的旧名称。
+ // 新建边界传入空名,加载成果则传入已保存的用户名称。
+ pObj->setName(sName);
+ }
bindObjSignals(pObj);
m_pPlot->addOneObj(pObj);
diff --git a/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp b/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp
index 7186c748..2d41782c 100644
--- a/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp
+++ b/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp
@@ -110,7 +110,7 @@ bool nmGuiPlotCmdHelper::runAction(QString sAction) {
? QLatin1String("nObjRoundOutline") : QLatin1String("nObjPolygonOutline"));
int objCount = pPlot->getObjCount();
- for(int i = 0; i < objCount; i++) {
+ for(int i = objCount - 1; i >= 0; --i) {
ZxObjBase* obj = pPlot->getObjByIndex(i);
if (obj == NULL)
@@ -124,40 +124,16 @@ bool nmGuiPlotCmdHelper::runAction(QString sAction) {
continue;
}
- // 检查是否为矩形轮廓
- if (_isSame("nObjRectOutline", nmObj->getTagName())) {
+ // 边界可无名称,按命中的对象索引删除,避免名称为空或重名时误删。
+ if (_isSame("nObjRectOutline", nmObj->getTagName()) ||
+ _isSame("nObjPolygonOutline", nmObj->getTagName()) ||
+ _isSame("nObjRoundOutline", nmObj->getTagName())) {
nmPlotDialogContextProvider* pDialogProvider = nmPlotDialogContext::provider();
if (pDialogProvider != nullptr && pDialogProvider->confirmSwitchOutline(
pNmPlot, nmObj->getTagName(), sTargetOutlineTag)) {
- // 删除图元
- pPlot->removeObjByName(nmObj->getName());
- nmObj->removeData();
- } else {
- return false;
- }
- }
-
- // 检查是否为多边形轮廓
- if (_isSame("nObjPolygonOutline", nmObj->getTagName())) {
- nmPlotDialogContextProvider* pDialogProvider = nmPlotDialogContext::provider();
- if (pDialogProvider != nullptr && pDialogProvider->confirmSwitchOutline(
- pNmPlot, nmObj->getTagName(), sTargetOutlineTag)) {
- // 删除图元
- pPlot->removeObjByName(nmObj->getName());
- nmObj->removeData();
- } else {
- return false;
- }
- }
-
- // 检查是否为圆形轮廓
- if (_isSame("nObjRoundOutline", nmObj->getTagName())) {
- nmPlotDialogContextProvider* pDialogProvider = nmPlotDialogContext::provider();
- if (pDialogProvider != nullptr && pDialogProvider->confirmSwitchOutline(
- pNmPlot, nmObj->getTagName(), sTargetOutlineTag)) {
- // 删除图元
- pPlot->removeObjByName(nmObj->getName());
+ // 先解除数据绑定,图元移除后不再访问其指针。
nmObj->removeData();
+ pPlot->removeObjByIndex(i);
} else {
return false;
}
@@ -370,7 +346,7 @@ void nmGuiPlotCmdHelper::slotObjPtsFinished(QVector& vec) {
} else if (pTool->getNOT() == NMOT_Polygon) {
sName = tr("Polygon");
} else if (pTool->getNOT() == NMOT_PolygonOutline) {
- sName = tr("PolygonOutline");
+ sName.clear(); // 边界默认不命名,用户可在图元属性中自行填写。
} else if (pTool->getNOT() == NMOT_Line_Fracture) {
sName = tr("Fracture");
} else if (pTool->getNOT() == NMOT_Line_Fault) {
@@ -382,11 +358,11 @@ void nmGuiPlotCmdHelper::slotObjPtsFinished(QVector& vec) {
} else if (pTool->getNOT() == NMOT_Rect) {
sName = tr("Rectangle");
} else if (pTool->getNOT() == NMOT_RectOutline) {
- sName = tr("RectangleOutline");
+ sName.clear();
} else if (pTool->getNOT() == NMOT_Round) {
sName = tr("Circle");
} else if (pTool->getNOT() == NMOT_RoundOutline) {
- sName = tr("CircleOutline");
+ sName.clear();
} else if (pTool->getNOT() == NMOT_Region) {
sName = tr("Limit");
} else if (pTool->getNOT() == NMOT_Delete) {
diff --git a/Src/nmNum/nmSubWxs/nmWxParaPropertyPebi.cpp b/Src/nmNum/nmSubWxs/nmWxParaPropertyPebi.cpp
index a14ece49..778c36c9 100644
--- a/Src/nmNum/nmSubWxs/nmWxParaPropertyPebi.cpp
+++ b/Src/nmNum/nmSubWxs/nmWxParaPropertyPebi.cpp
@@ -498,9 +498,11 @@ void nmWxParaPropertyPebi::rebuildAllParas()
if (pOutline != nullptr)
{
QString sOutlineName = pOutline->getName();
+ // 空名称及旧版本自动生成的英文名称按类型显示;不回写图元名称,
+ // 用户填写的自定义名称仍原样展示,避免打开参数树就给地图补上标签。
if (pOutline->getOutlineType() == NM_Rect_Outline_Type)
{
- if (sOutlineName.isEmpty())
+ if (sOutlineName.isEmpty() || sOutlineName == QLatin1String("RectangleOutline"))
{
sOutlineName = tr("RectangleOutline");
}
@@ -510,7 +512,7 @@ void nmWxParaPropertyPebi::rebuildAllParas()
}
else if (pOutline->getOutlineType() == NM_Round_Outline_Type)
{
- if (sOutlineName.isEmpty())
+ if (sOutlineName.isEmpty() || sOutlineName == QLatin1String("CircleOutline"))
{
sOutlineName = tr("CircleOutline");
}
@@ -520,7 +522,7 @@ void nmWxParaPropertyPebi::rebuildAllParas()
}
else if (pOutline->getOutlineType() == NM_Polygon_Outline_Type)
{
- if (sOutlineName.isEmpty())
+ if (sOutlineName.isEmpty() || sOutlineName == QLatin1String("PolygonOutline"))
{
sOutlineName = tr("PolygonOutline");
}
@@ -529,7 +531,7 @@ void nmWxParaPropertyPebi::rebuildAllParas()
for (int i = 0; i < pOutline->getOutlinePointCount(); ++i)
{
const QString sPointCode = QString("BVERT%1").arg(i + 1, 4, 10, QChar('0'));
- mapObjectNames[sPointCode] = QString("%1 %2").arg(tr("Point")).arg(i + 1);
+ mapObjectNames[sPointCode] = tr("Vertex %1").arg(i + 1);
listParas << polygonPointParasOf(sPointCode);
}
}