refactor(nmNum): 优化复合区和区域标记参数布局及命名

feature/ReservoirPropertiesDlg-Refactoring-20260813
lh 5 days ago
parent 6b2009bf62
commit d847d428f5

Binary file not shown.

@ -6815,9 +6815,11 @@ Average pressure in contour: %2 MPa</source>
<message><source>Homogeneous</source><translation></translation></message> <message><source>Homogeneous</source><translation></translation></message>
<message><source>Dual porosity pseudo steady state</source><translation></translation></message> <message><source>Dual porosity pseudo steady state</source><translation></translation></message>
<message><source>Fault flow model</source><translation></translation></message> <message><source>Fault flow model</source><translation></translation></message>
<message><source>Region flow model</source><translation></translation></message> <message><source>Boundary type</source><translation></translation></message>
<message><source>Leaky</source><translation></translation></message> <message><source>Leaky</source><translation></translation></message>
<message><source>Composite limit</source><translation></translation></message> <message><source>Composite limit</source><translation></translation></message>
<message><source>Permeable boundary</source><translation></translation></message>
<message><source>Composite boundary</source><translation></translation></message>
<message><source>Fracture flow model</source><translation></translation></message> <message><source>Fracture flow model</source><translation></translation></message>
<message><source>Finite conductivity</source><translation></translation></message> <message><source>Finite conductivity</source><translation></translation></message>
<message><source>Infinite conductivity</source><translation></translation></message> <message><source>Infinite conductivity</source><translation></translation></message>
@ -6830,11 +6832,11 @@ Average pressure in contour: %2 MPa</source>
<message><source>Basic properties</source><translation></translation></message> <message><source>Basic properties</source><translation></translation></message>
<message><source>Fluid parameters</source><translation></translation></message> <message><source>Fluid parameters</source><translation></translation></message>
<message><source>Compression and saturation</source><translation></translation></message> <message><source>Compression and saturation</source><translation></translation></message>
<message><source>Dual-medium parameters</source><translation></translation></message> <message><source>Reservoir medium parameters</source><translation></translation></message>
<message><source>Geometry</source><translation></translation></message> <message><source>Geometry</source><translation></translation></message>
<message><source>Flow properties</source><translation></translation></message> <message><source>Flow properties</source><translation></translation></message>
<message><source>Conductivity properties</source><translation></translation></message> <message><source>Conductivity properties</source><translation></translation></message>
<message><source>Region properties</source><translation></translation></message> <message><source>Boundary properties</source><translation></translation></message>
</context> </context>
<context> <context>
<name>nmSubWndMain</name> <name>nmSubWndMain</name>

@ -72,6 +72,7 @@ struct NM_SUB_WXS_EXPORT nmReservoirParameterGroupInfo
int m_nRowSpan; ///< 分组纵向跨越的行数。 int m_nRowSpan; ///< 分组纵向跨越的行数。
int m_nColumnSpan; ///< 分组横跨的列数。 int m_nColumnSpan; ///< 分组横跨的列数。
bool m_bValueRightAligned; ///< 数值输入是否右对齐。 bool m_bValueRightAligned; ///< 数值输入是否右对齐。
bool m_bFieldsCentered; ///< 分组内字段是否水平居中并随宽度伸展。
QList<nmReservoirParameterFieldInfo> m_listFields; ///< 分组内按显示顺序排列的字段。 QList<nmReservoirParameterFieldInfo> m_listFields; ///< 分组内按显示顺序排列的字段。
}; };

@ -70,10 +70,14 @@ public:
* @brief * @brief
* @param pLayout * @param pLayout
* @param nRow * @param nRow
* @param nColumnOffset
* @param sError * @param sError
* @return true * @return true
*/ */
bool initialize(QGridLayout* pLayout, int nRow, QString& sError); bool initialize(QGridLayout* pLayout,
int nRow,
int nColumnOffset,
QString& sError);
/** @brief 返回编辑会话使用的稳定参数ID。 */ /** @brief 返回编辑会话使用的稳定参数ID。 */
QString parameterId() const; QString parameterId() const;
@ -131,10 +135,13 @@ private:
/** @brief 创建数值输入框及单位控件。 */ /** @brief 创建数值输入框及单位控件。 */
bool createNumericEditor(QGridLayout* pLayout, bool createNumericEditor(QGridLayout* pLayout,
int nRow, int nRow,
int nColumnOffset,
QString& sError); QString& sError);
/** @brief 创建稳定code枚举下拉框。 */ /** @brief 创建稳定code枚举下拉框。 */
void createEnumEditor(QGridLayout* pLayout, int nRow); void createEnumEditor(QGridLayout* pLayout,
int nRow,
int nColumnOffset);
/** @brief 按XML精度格式化无单位或整数参数。 */ /** @brief 按XML精度格式化无单位或整数参数。 */
QString formatBaseValue(double dValue) const; QString formatBaseValue(double dValue) const;

@ -20,9 +20,11 @@ static const char* const s_pCatalogTranslationMarkers[] =
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Homogeneous"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Homogeneous"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Dual porosity pseudo steady state"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Dual porosity pseudo steady state"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Fault flow model"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Fault flow model"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Region flow model"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Boundary type"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Leaky"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Leaky"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Composite limit"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Composite limit"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Permeable boundary"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Composite boundary"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Fracture flow model"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Fracture flow model"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Finite conductivity"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Finite conductivity"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Infinite conductivity"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Infinite conductivity"),
@ -36,11 +38,11 @@ static const char* const s_pCatalogTranslationMarkers[] =
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Vertical well"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Vertical well"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Fractured vertical well"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Fractured vertical well"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Multistage fractured horizontal well"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Multistage fractured horizontal well"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Dual-medium parameters"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Reservoir medium parameters"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Geometry"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Geometry"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Flow properties"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Flow properties"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Conductivity properties"), QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Conductivity properties"),
QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Region properties") QT_TRANSLATE_NOOP("nmWxReservoirPropertiesEditor", "Boundary properties")
}; };
/** @brief 返回当前语言下的界面文字。 */ /** @brief 返回当前语言下的界面文字。 */
@ -108,19 +110,21 @@ nmReservoirParameterFieldInfo reservoirModelField(
return oField; return oField;
} }
/** @brief 创建断层或复合区流动模型字段。 */ /** @brief 按指定显示文字创建断层或复合区流动模型字段。 */
nmReservoirParameterFieldInfo leakageModelField( nmReservoirParameterFieldInfo leakageModelField(
const QString& sParameterId, const QString& sParameterId,
const char* pLabel) const char* pLabel,
const char* pLeakyText,
const char* pCompositeText)
{ {
nmReservoirParameterFieldInfo oField; nmReservoirParameterFieldInfo oField;
oField.m_sParameterId = sParameterId; oField.m_sParameterId = sParameterId;
oField.m_sLabel = editorText(pLabel); oField.m_sLabel = editorText(pLabel);
oField.m_eEditorType = NM_RESERVOIR_EDITOR_ENUM; oField.m_eEditorType = NM_RESERVOIR_EDITOR_ENUM;
oField.m_bUnitEnabled = false; oField.m_bUnitEnabled = false;
oField.m_listOptions.append(enumOption("leaky", "Leaky")); oField.m_listOptions.append(enumOption("leaky", pLeakyText));
oField.m_listOptions.append(enumOption( oField.m_listOptions.append(enumOption(
"composite_limit", "Composite limit")); "composite_limit", pCompositeText));
return oField; return oField;
} }
@ -154,6 +158,7 @@ nmReservoirParameterGroupInfo parameterGroup(
oGroup.m_nRowSpan = 1; oGroup.m_nRowSpan = 1;
oGroup.m_nColumnSpan = nColumnSpan; oGroup.m_nColumnSpan = nColumnSpan;
oGroup.m_bValueRightAligned = false; oGroup.m_bValueRightAligned = false;
oGroup.m_bFieldsCentered = false;
return oGroup; return oGroup;
} }
@ -535,7 +540,8 @@ nmReservoirParameterCatalog::createObjectInfos(
oSnapshot.m_vecRegionMarks[nIndex].getRegionMarkName(); oSnapshot.m_vecRegionMarks[nIndex].getRegionMarkName();
nmReservoirParameterGroupInfo oDual = nmReservoirParameterGroupInfo oDual =
parameterGroup("Dual-medium parameters", 0, 0, 2); parameterGroup("Reservoir medium parameters", 0, 0, 2);
oDual.m_bFieldsCentered = true;
oDual.m_listFields oDual.m_listFields
<< reservoirModelField(prefixed( << reservoirModelField(prefixed(
oInfo.m_sObjectCode, "RM_ReservoirType")) oInfo.m_sObjectCode, "RM_ReservoirType"))
@ -584,7 +590,9 @@ nmReservoirParameterCatalog::createObjectInfos(
oFlow.m_listFields oFlow.m_listFields
<< leakageModelField(prefixed( << leakageModelField(prefixed(
oInfo.m_sObjectCode, "FT_FlowModel"), oInfo.m_sObjectCode, "FT_FlowModel"),
"Fault flow model") "Fault flow model",
"Leaky",
"Composite limit")
<< numericField(prefixed( << numericField(prefixed(
oInfo.m_sObjectCode, "FT_Leakage"), oInfo.m_sObjectCode, "FT_Leakage"),
"FT_Leakage"); "FT_Leakage");
@ -659,11 +667,14 @@ nmReservoirParameterCatalog::createObjectInfos(
oSnapshot.m_vecRegions[nIndex].getRegoinName(); oSnapshot.m_vecRegions[nIndex].getRegoinName();
nmReservoirParameterGroupInfo oRegion = nmReservoirParameterGroupInfo oRegion =
parameterGroup("Region properties", 0, 0, 2); parameterGroup("Boundary properties", 0, 0, 2);
oRegion.m_bFieldsCentered = true;
oRegion.m_listFields oRegion.m_listFields
<< leakageModelField(prefixed( << leakageModelField(prefixed(
oInfo.m_sObjectCode, "R_FlowModel"), oInfo.m_sObjectCode, "R_FlowModel"),
"Region flow model") "Boundary type",
"Permeable boundary",
"Composite boundary")
<< numericField(prefixed( << numericField(prefixed(
oInfo.m_sObjectCode, "R_Leakage"), oInfo.m_sObjectCode, "R_Leakage"),
"R_Leakage"); "R_Leakage");

@ -64,6 +64,7 @@ nmReservoirParameterField::~nmReservoirParameterField()
bool nmReservoirParameterField::initialize(QGridLayout* pLayout, bool nmReservoirParameterField::initialize(QGridLayout* pLayout,
int nRow, int nRow,
int nColumnOffset,
QString& sError) QString& sError)
{ {
if (pLayout == nullptr) if (pLayout == nullptr)
@ -75,7 +76,7 @@ bool nmReservoirParameterField::initialize(QGridLayout* pLayout,
// 第一步枚举字段不依赖XML数值定义直接创建稳定code下拉框。 // 第一步枚举字段不依赖XML数值定义直接创建稳定code下拉框。
if (isEnum()) if (isEnum())
{ {
createEnumEditor(pLayout, nRow); createEnumEditor(pLayout, nRow, nColumnOffset);
sError.clear(); sError.clear();
return true; return true;
} }
@ -91,7 +92,7 @@ bool nmReservoirParameterField::initialize(QGridLayout* pLayout,
} }
// 第三步:创建原型中的标签、输入框和单位列,不增加字段外框。 // 第三步:创建原型中的标签、输入框和单位列,不增加字段外框。
return createNumericEditor(pLayout, nRow, sError); return createNumericEditor(pLayout, nRow, nColumnOffset, sError);
} }
QString nmReservoirParameterField::parameterId() const QString nmReservoirParameterField::parameterId() const
@ -137,6 +138,7 @@ int nmReservoirParameterField::editorHeight()
bool nmReservoirParameterField::createNumericEditor( bool nmReservoirParameterField::createNumericEditor(
QGridLayout* pLayout, QGridLayout* pLayout,
int nRow, int nRow,
int nColumnOffset,
QString& sError) QString& sError)
{ {
QWidget* pParentWidget = pLayout->parentWidget(); QWidget* pParentWidget = pLayout->parentWidget();
@ -153,8 +155,8 @@ bool nmReservoirParameterField::createNumericEditor(
m_pLineEdit->setSizePolicy(QSizePolicy::Expanding, m_pLineEdit->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Fixed); QSizePolicy::Fixed);
pLayout->addWidget(m_pLabel, nRow, 0); pLayout->addWidget(m_pLabel, nRow, nColumnOffset);
pLayout->addWidget(m_pLineEdit, nRow, 1); pLayout->addWidget(m_pLineEdit, nRow, nColumnOffset + 1);
// 有单位参数直接注册到主对话框绑定器;字段只按控件指针读写, // 有单位参数直接注册到主对话框绑定器;字段只按控件指针读写,
// 因此多口井共用同一基础参数ID时也不会发生串值。 // 因此多口井共用同一基础参数ID时也不会发生串值。
@ -166,7 +168,7 @@ bool nmReservoirParameterField::createNumericEditor(
m_pUnitComboBox->setMinimumWidth(unitMinimumWidth()); m_pUnitComboBox->setMinimumWidth(unitMinimumWidth());
m_pUnitComboBox->setSizePolicy(QSizePolicy::Expanding, m_pUnitComboBox->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Fixed); QSizePolicy::Fixed);
pLayout->addWidget(m_pUnitComboBox, nRow, 2); pLayout->addWidget(m_pUnitComboBox, nRow, nColumnOffset + 2);
if (m_pUnitService == nullptr || if (m_pUnitService == nullptr ||
!m_pUnitService->bindUnitField( !m_pUnitService->bindUnitField(
m_pLineEdit, m_pLineEdit,
@ -186,7 +188,7 @@ bool nmReservoirParameterField::createNumericEditor(
m_pUnitLabel->setMinimumWidth(unitMinimumWidth()); m_pUnitLabel->setMinimumWidth(unitMinimumWidth());
m_pUnitLabel->setSizePolicy(QSizePolicy::Expanding, m_pUnitLabel->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Fixed); QSizePolicy::Fixed);
pLayout->addWidget(m_pUnitLabel, nRow, 2); pLayout->addWidget(m_pUnitLabel, nRow, nColumnOffset + 2);
} }
updateValidationAppearance(true); updateValidationAppearance(true);
@ -195,7 +197,8 @@ bool nmReservoirParameterField::createNumericEditor(
} }
void nmReservoirParameterField::createEnumEditor(QGridLayout* pLayout, void nmReservoirParameterField::createEnumEditor(QGridLayout* pLayout,
int nRow) int nRow,
int nColumnOffset)
{ {
QWidget* pParentWidget = pLayout->parentWidget(); QWidget* pParentWidget = pLayout->parentWidget();
m_pLabel = new QLabel(m_oFieldInfo.m_sLabel, pParentWidget); m_pLabel = new QLabel(m_oFieldInfo.m_sLabel, pParentWidget);
@ -224,9 +227,9 @@ void nmReservoirParameterField::createEnumEditor(QGridLayout* pLayout,
m_pUnitLabel->setSizePolicy(QSizePolicy::Expanding, m_pUnitLabel->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Fixed); QSizePolicy::Fixed);
pLayout->addWidget(m_pLabel, nRow, 0); pLayout->addWidget(m_pLabel, nRow, nColumnOffset);
pLayout->addWidget(m_pValueComboBox, nRow, 1); pLayout->addWidget(m_pValueComboBox, nRow, nColumnOffset + 1);
pLayout->addWidget(m_pUnitLabel, nRow, 2); pLayout->addWidget(m_pUnitLabel, nRow, nColumnOffset + 2);
} }
void nmReservoirParameterField::setBaseValue(const QVariant& oValue) void nmReservoirParameterField::setBaseValue(const QVariant& oValue)

@ -234,14 +234,31 @@ bool nmReservoirParameterPage::buildGroup(
pFieldLayout->setContentsMargins(8, 15, 8, 10); pFieldLayout->setContentsMargins(8, 15, 8, 10);
pFieldLayout->setHorizontalSpacing(6); pFieldLayout->setHorizontalSpacing(6);
pFieldLayout->setVerticalSpacing(6); pFieldLayout->setVerticalSpacing(6);
// 标签列由本组最长标签的自然宽度决定,数值列和单位列按比例使用剩余空间。 int nFieldColumnOffset = 0;
// 字段较少的通栏分组使用独立的左右弹性列,
// 使参数区域保持居中,输入列仍可随窗口宽度适度伸展。
if (oGroupInfo.m_bFieldsCentered)
{
nFieldColumnOffset = 1;
pFieldLayout->setColumnStretch(0, 1);
pFieldLayout->setColumnStretch(1, 0);
pFieldLayout->setColumnStretch(2, 1);
pFieldLayout->setColumnStretch(3, 0);
pFieldLayout->setColumnStretch(4, 1);
}
else
{
// 常规分组由最长标签决定标签列宽,数值列和单位列按比例伸展。
pFieldLayout->setColumnStretch(0, 0); pFieldLayout->setColumnStretch(0, 0);
pFieldLayout->setColumnStretch(1, 8); pFieldLayout->setColumnStretch(1, 8);
pFieldLayout->setColumnStretch(2, 5); pFieldLayout->setColumnStretch(2, 5);
}
pFieldLayout->setColumnMinimumWidth( pFieldLayout->setColumnMinimumWidth(
1, nmReservoirParameterField::editorMinimumWidth()); nFieldColumnOffset + 1,
nmReservoirParameterField::editorMinimumWidth());
pFieldLayout->setColumnMinimumWidth( pFieldLayout->setColumnMinimumWidth(
2, nmReservoirParameterField::unitMinimumWidth()); nFieldColumnOffset + 2,
nmReservoirParameterField::unitMinimumWidth());
// 每个字段只把三个直接控件放入此网格,不产生字段外框或子面板。 // 每个字段只把三个直接控件放入此网格,不产生字段外框或子面板。
for (int nFieldIndex = 0; for (int nFieldIndex = 0;
@ -253,7 +270,10 @@ bool nmReservoirParameterPage::buildGroup(
oGroupInfo.m_listFields[nFieldIndex], oGroupInfo.m_listFields[nFieldIndex],
m_pUnitService, m_pUnitService,
pGroupBox); pGroupBox);
if (!pField->initialize(pFieldLayout, nFieldIndex, sError)) if (!pField->initialize(pFieldLayout,
nFieldIndex,
nFieldColumnOffset,
sError))
{ {
delete pGroupContainer; delete pGroupContainer;
return false; return false;

Loading…
Cancel
Save