fix(nmNum): 修复未计算分析重开成果后显示空结果页

- 根据成果快照控制参数结果和后处理页签的创建与显隐
- 隐藏框架恢复的空数值页签,并同步清理旧结果内容
- 在初始化、分析切换和成果清空时同步页签状态
- 保留已有成果及过期成果的查看能力
feature/fix-result-persistence-20261118
lh 1 week ago
parent 56847a17c5
commit 20fb023c43

@ -19,13 +19,23 @@ public:
* @brief 安装或同步三维结果页与只读结果参数页。
* @param pFitting 结果页所属的流动段分析窗口,非所有权指针。
* @param pManager 与 pFitting 绑定的 DataManager,非所有权指针。
* @return 两个页面均成功安装或同步时返回 true。
* @note 不要求 Manager 已有快照;无快照时仍安装稳定空页面。
* @return 有快照时两个页面均安装成功,或无快照时已有页面同步完成,返回 true。
* @note 仅持有结果快照时创建缺失页面;无快照时清理已有控件并隐藏框架恢复的数值页签。
* 过期快照仍可查看,不能以是否匹配当前输入作为页面创建条件。
*/
static bool installOrSynchronize(
iSubWndFitting* pFitting,
nmDataAnalyzeManager* pManager);
/**
* @brief 按所属分析的成果状态同步现有数值结果页签,不创建窗口或切换当前页。
* @note 框架可能先恢复包含 NmRst/Nm3D 的解释结果容器;无快照时必须显式隐藏。
* 有快照时仅显示已安装对应业务控件的页签,兼容结果容器分开显示的布局。
*/
static void synchronizeVisibility(
iSubWndFitting* pFitting,
nmDataAnalyzeManager* pManager);
private:
/** @brief 纯静态职责类,禁止构造实例。 */
nmPebiResultPageInstaller();

@ -1,16 +1,54 @@
#include "nmPebiResultPageInstaller.h"
#include "iSubWndFitting.h"
#include "iWxResult.h"
#include "nmDataAnalyzeManager.h"
#include "nmWxParaPropertyPebi.h"
#include "nmWxPebiResultViewWidget.h"
#include <QLayout>
#include <QLayoutItem>
#include <QList>
#include <QString>
#include <QVBoxLayout>
#include <QWidget>
void nmPebiResultPageInstaller::synchronizeVisibility(
iSubWndFitting* pFitting,
nmDataAnalyzeManager* pManager)
{
if(pFitting == nullptr || pManager == nullptr ||
pManager->getGridType() != NM_Grid_PEBI ||
nmDataAnalyzeManager::findManagerByFitting(pFitting) != pManager) {
return;
}
const bool bHasSnapshot = pManager->hasPebiResultSnapshot();
// 直接查找所属分析的现有结果容器,不通过取页接口触发页签显示或激活。
const QList<iWxResult*> listResultWindows = pFitting->findChildren<iWxResult*>();
foreach(iWxResult* pResultWindow, listResultWindows) {
nmWxPebiResultViewWidget* pResultView =
pResultWindow->findChild<nmWxPebiResultViewWidget*>();
nmWxParaPropertyPebi* pResultParameters =
pResultWindow->findChild<nmWxParaPropertyPebi*>();
if(!bHasSnapshot) {
// 重新加载无成果的数据时清理旧内容;只处理结果容器内的只读参数,
// 不触碰左侧用于编辑当前模型的参数面板。
if(pResultView != nullptr) {
pResultView->setDataManager(pManager);
}
if(pResultParameters != nullptr) {
pResultParameters->setDataManager(pManager);
pResultParameters->rebuildResultParas();
}
}
pResultWindow->setTabItemVisibleEx(
iWxResult::TSI_NmRst, bHasSnapshot && pResultParameters != nullptr, false);
pResultWindow->setTabItemVisibleEx(
iWxResult::TSI_Nm3D, bHasSnapshot && pResultView != nullptr, false);
}
}
bool nmPebiResultPageInstaller::installOrSynchronize(
iSubWndFitting* pFitting,
nmDataAnalyzeManager* pManager)
@ -22,6 +60,14 @@ bool nmPebiResultPageInstaller::installOrSynchronize(
return false;
}
// 保存分析输入不代表已经求解。框架反序列化会恢复结果容器及页签,
// 无快照时不仅要阻止创建,还必须隐藏已经恢复的两个空数值页签。
// 这里按快照是否存在判断;输入修改后保留的历史快照仍允许恢复查看。
if(!pManager->hasPebiResultSnapshot()) {
synchronizeVisibility(pFitting, pManager);
return true;
}
QString sErrorMessage;
QWidget* p3DPage = pFitting->getFitSubRstWxOf(
FSRT_Nm3D, true, &sErrorMessage);
@ -82,11 +128,13 @@ bool nmPebiResultPageInstaller::installOrSynchronize(
pResultParameters->setDataManager(pManager);
pResultParameters->rebuildResultParas();
pResultLayout->addWidget(pResultParameters);
synchronizeVisibility(pFitting, pManager);
return true;
}
// 参数页未监听快照状态信号,每次生产入口同步均需显式重建。
pResultParameters->setDataManager(pManager);
pResultParameters->rebuildResultParas();
synchronizeVisibility(pFitting, pManager);
return true;
}

@ -462,6 +462,7 @@ void nmSubWndMain::onPebiResultSnapshotChanged()
pDataManager->getPebiResultSnapshot();
if(pSnapshot.isNull()) {
m_sObservedPebiResultSnapshotId.clear();
nmPebiResultPageInstaller::synchronizeVisibility(pSubWndFitting, pDataManager);
return;
}

@ -600,6 +600,9 @@ void nmSubWndUtils::setupNumericalDockWidgets(nmDataAnalyzeManager* pDataManager
pWxDockNm1->setWidget(pAnalWx);
pWxDockNm2->setWidget(pParaWx);
// 新建和恢复分析共用装配入口,空数值成果不能显示框架默认的数值页签。
nmPebiResultPageInstaller::synchronizeVisibility(pSubWndFitting, pDataManager);
}
bool nmSubWndUtils::fillNmDockWxs(iSubWnd* pSubWnd)
@ -1223,7 +1226,8 @@ bool nmSubWndUtils::loadRsts(iSubWnd* pSubWnd, \
pSubWndF, pWxDockNm1, pWxDockNm2);
}
// 即使两个 Dock 已存在,也必须刷新三维结果和只读结果参数页。
// Dock 是否存在与是否计算过无关。统一入口按加载后的快照决定是否
// 创建结果页;仅保存了分析输入时隐藏框架恢复的数值页签并清理旧内容。
if(!nmPebiResultPageInstaller::installOrSynchronize(
pSubWndF, pDataManager)) {
return false;
@ -1365,6 +1369,8 @@ void nmSubWndUtils::slotHandleTabChange(int index)
}
if(pDataManger != nullptr) {
// 框架切换分析可能恢复结果容器的默认页签,显隐必须跟随本分析。
nmPebiResultPageInstaller::synchronizeVisibility(pSubWndF, pDataManger);
// 切换分析后必须同步活动数值面板。即使DataManager已经是当前对象,
// 结果井下拉框也可能仍指向后创建的另一个分析面板。
iDockBaseWx* pWxDockNm1 = pSubWndF->getNmDockWx(0);
@ -1570,6 +1576,8 @@ void nmSubWndUtils::slotHandleMdiSubWindowActivated(QMdiSubWindow* pSubWindow)
if(pCurFitting != nullptr) {
foreach(iSubWnd* pSub, vecSubWnds) {
if(pSub == pCurFitting) {
nmPebiResultPageInstaller::synchronizeVisibility(
pCurFitting, nmDataAnalyzeManager::findManagerByFitting(pCurFitting));
return;
}
}
@ -1584,6 +1592,9 @@ void nmSubWndUtils::slotHandleMdiSubWindowActivated(QMdiSubWindow* pSubWindow)
// 下拉框填充函数会读取getCurrentInstance(),顺序不能颠倒。
nmDataAnalyzeManager::setCurrentFitting(pSubWndF);
nmPebiResultPageInstaller::synchronizeVisibility(
pSubWndF, nmDataAnalyzeManager::findManagerByFitting(pSubWndF));
iDockBaseWx* pWxDockNm1 = pSubWndF->getNmDockWx(0);
if(pWxDockNm1 == nullptr) {
return;

Loading…
Cancel
Save