fix(nmNum): 调整边界默认名称并完善中文显示

- 新建边界默认不设置名称,保留用户自定义名称
- 参数树按边界类型显示中文,并补充顶点翻译
- 边界替换按对象索引删除,兼容空名称
- 使用 UTF-8 保存边界名称,避免中文乱码
- 清理无用翻译并更新 qm 资源
feature/fix-result-persistence-20261118
lh 1 week ago
parent 20fb023c43
commit b91b328dcd

Binary file not shown.

@ -2528,10 +2528,6 @@ No valid error was returned; keep the last accepted result and reduce the step.<
<source>Polygon</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PolygonOutline</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fracture</source>
<translation type="unfinished"></translation>
@ -2548,18 +2544,10 @@ No valid error was returned; keep the last accepted result and reduce the step.<
<source>Rectangle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RectangleOutline</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Circle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CircleOutline</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Limit</source>
<translation type="unfinished"></translation>
@ -6718,6 +6706,10 @@ Supported types: Vertical, Vertical Fractured, and Horizontal Multi-Fractured We
</context>
<context>
<name>nmWxParaPropertyPebi</name>
<message>
<source>Vertex %1</source>
<translation>顶点 %1</translation>
</message>
<message>
<source>RectangleOutline</source>
<translation>矩形边界</translation>

@ -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<rapidjson::SizeType>(nameUtf8.size()), allocator).Move(), allocator);
// 序列化点
rapidjson::Value pointsArray(rapidjson::kArrayType); // 创建一个 RapidJSON 数组类型的值

@ -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);

@ -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<QPointF>& 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<QPointF>& 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) {

@ -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);
}
}

Loading…
Cancel
Save