|
|
|
|
@ -1,4 +1,13 @@
|
|
|
|
|
#include "nmWxPebiResultViewWidget.h"
|
|
|
|
|
#include "nmVolumeImportTask.h"
|
|
|
|
|
#include "nmVolumeSceneController.h"
|
|
|
|
|
#include "nmVTKViewState.h"
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
#include <QPixmap>
|
|
|
|
|
#include <QPolygon>
|
|
|
|
|
#include <QPen>
|
|
|
|
|
|
|
|
|
|
#include "iUnitGroup.h"
|
|
|
|
|
#include "iUnitHelper.h"
|
|
|
|
|
@ -803,6 +812,30 @@ bool nmWxPebiResultFilterSettingsDlg::convertUnitValue(
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @brief 外部三维模式的窗口私有状态,所有成员仅由 GUI 线程管理。 */
|
|
|
|
|
class nmWxPebiVolumeState
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/** @brief 初始化为空模式;控制器在通用渲染容器创建后绑定。 */
|
|
|
|
|
nmWxPebiVolumeState()
|
|
|
|
|
: m_pController(nullptr), m_pTask(nullptr), m_pProgress(nullptr),
|
|
|
|
|
m_pImportAction(nullptr), m_pReturnAction(nullptr), m_pButton(nullptr),
|
|
|
|
|
m_bImported(false), m_bPendingSync(false), m_bRegionVisible(false),
|
|
|
|
|
m_bRegionDialogVisible(false) {}
|
|
|
|
|
nmVolumeSceneController* m_pController; ///< 窗口独占,必须在渲染容器之前析构。
|
|
|
|
|
nmVolumeImportTask* m_pTask; ///< 当前唯一导入线程,结束后才允许读取结果。
|
|
|
|
|
QProgressDialog* m_pProgress; ///< 临时进度框,窗口对象树拥有。
|
|
|
|
|
QAction* m_pImportAction; ///< 按钮菜单和右键菜单共享的导入动作。
|
|
|
|
|
QAction* m_pReturnAction; ///< 仅外部模型模式启用的返回动作。
|
|
|
|
|
QToolButton* m_pButton; ///< 唯一新增的常驻切片工具按钮。
|
|
|
|
|
nmVTKViewState m_oSavedView; ///< 第一次进入外部模式前捕获的计算结果视图。
|
|
|
|
|
nmVTKViewCommandController::ViewCommands m_eSavedCommands; ///< 原结果提供的视图命令能力。
|
|
|
|
|
bool m_bImported; ///< 当前画面是否为外部三维模型。
|
|
|
|
|
bool m_bPendingSync; ///< 外部模式期间发生 Manager 变化,返回时重新读取。
|
|
|
|
|
bool m_bRegionVisible; ///< 原区域轮廓的实际可见状态。
|
|
|
|
|
bool m_bRegionDialogVisible; ///< 原区域统计面板是否可见。
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
nmWxPebiResultViewWidget::nmWxPebiResultViewWidget(
|
|
|
|
|
nmDataAnalyzeManager* pDataManager,
|
|
|
|
|
QWidget* pParent)
|
|
|
|
|
@ -818,6 +851,7 @@ nmWxPebiResultViewWidget::nmWxPebiResultViewWidget(
|
|
|
|
|
m_pFilterAction(nullptr),
|
|
|
|
|
m_pRegionPressureAction(nullptr),
|
|
|
|
|
m_pRegionState(new nmWxPebiResultRegionState),
|
|
|
|
|
m_pVolumeState(new nmWxPebiVolumeState),
|
|
|
|
|
m_bObservedSnapshotCurrent(false),
|
|
|
|
|
m_bObservedStateValid(false),
|
|
|
|
|
m_bSynchronizing(false),
|
|
|
|
|
@ -829,6 +863,16 @@ nmWxPebiResultViewWidget::nmWxPebiResultViewWidget(
|
|
|
|
|
|
|
|
|
|
nmWxPebiResultViewWidget::~nmWxPebiResultViewWidget()
|
|
|
|
|
{
|
|
|
|
|
// 先取消并断开队列回调,等待线程退出后才能释放窗口和相关 DLL 对象。
|
|
|
|
|
if(m_pVolumeState->m_pTask != nullptr) {
|
|
|
|
|
disconnect(m_pVolumeState->m_pTask, nullptr, this, nullptr);
|
|
|
|
|
m_pVolumeState->m_pTask->requestCancel();
|
|
|
|
|
m_pVolumeState->m_pTask->wait();
|
|
|
|
|
delete m_pVolumeState->m_pTask;
|
|
|
|
|
}
|
|
|
|
|
delete m_pVolumeState->m_pController;
|
|
|
|
|
delete m_pVolumeState;
|
|
|
|
|
m_pVolumeState = nullptr;
|
|
|
|
|
disconnectDataManager();
|
|
|
|
|
destroyRegionPressureState();
|
|
|
|
|
if(m_pControlBar != nullptr) {
|
|
|
|
|
@ -862,8 +906,21 @@ void nmWxPebiResultViewWidget::setDataManager(
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_pVolumeState->m_pTask != nullptr) m_pVolumeState->m_pTask->requestCancel();
|
|
|
|
|
disconnectDataManager();
|
|
|
|
|
clearSceneAndControls(tr("No result data."));
|
|
|
|
|
if(isImportedVolumeMode()) {
|
|
|
|
|
// 分析上下文换绑时丢弃旧计算结果,但保留用户正在检查的外部模型。
|
|
|
|
|
clearRegionPressureSelection(false);
|
|
|
|
|
m_pSceneController->clear();
|
|
|
|
|
m_pDisplayedSnapshot.clear();
|
|
|
|
|
m_sDisplayedSnapshotId.clear();
|
|
|
|
|
m_pVolumeState->m_oSavedView = nmVTKViewState();
|
|
|
|
|
m_pVolumeState->m_bRegionVisible = false;
|
|
|
|
|
m_pVolumeState->m_bRegionDialogVisible = false;
|
|
|
|
|
m_pVolumeState->m_bPendingSync = true;
|
|
|
|
|
} else {
|
|
|
|
|
clearSceneAndControls(tr("No result data."));
|
|
|
|
|
}
|
|
|
|
|
m_pDataManager = pDataManager;
|
|
|
|
|
if(!m_pDataManager.isNull()) {
|
|
|
|
|
connect(m_pDataManager.data(), SIGNAL(sigPebiResultStateChanged()),
|
|
|
|
|
@ -913,6 +970,10 @@ void nmWxPebiResultViewWidget::onDataManagerDestroyed(QObject* pObject)
|
|
|
|
|
Q_UNUSED(pObject);
|
|
|
|
|
// destroyed() 到达时 QPointer 可能已经清空,槽内绝不再读取 Manager。
|
|
|
|
|
m_pDataManager = nullptr;
|
|
|
|
|
if(isImportedVolumeMode()) {
|
|
|
|
|
m_pVolumeState->m_bPendingSync = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(m_bSynchronizing) {
|
|
|
|
|
// 极端嵌套事件下不得在快照提交栈内递归清场,退出当前事务后再读空状态。
|
|
|
|
|
m_bSyncPending = true;
|
|
|
|
|
@ -930,6 +991,9 @@ void nmWxPebiResultViewWidget::appendContextMenuActions(QMenu* pMenu)
|
|
|
|
|
if(pMenu == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
pMenu->addAction(m_pVolumeState->m_pImportAction);
|
|
|
|
|
pMenu->addAction(m_pVolumeState->m_pReturnAction);
|
|
|
|
|
pMenu->addSeparator();
|
|
|
|
|
pMenu->addAction(m_pFilterAction);
|
|
|
|
|
pMenu->addAction(m_pRegionPressureAction);
|
|
|
|
|
pMenu->addSeparator();
|
|
|
|
|
@ -968,6 +1032,7 @@ void nmWxPebiResultViewWidget::onViewportSizeChanged(
|
|
|
|
|
int nWidth,
|
|
|
|
|
int nHeight)
|
|
|
|
|
{
|
|
|
|
|
if(m_pVolumeState->m_pController != nullptr) m_pVolumeState->m_pController->setViewportSize(nWidth, nHeight);
|
|
|
|
|
if(m_pSceneController != nullptr) {
|
|
|
|
|
// SceneController 缓存尺寸,即使当前尚未创建结果色标也不会丢失。
|
|
|
|
|
m_pSceneController->setViewportSize(nWidth, nHeight);
|
|
|
|
|
@ -976,6 +1041,7 @@ void nmWxPebiResultViewWidget::onViewportSizeChanged(
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onShowFilterSettings()
|
|
|
|
|
{
|
|
|
|
|
if(isImportedVolumeMode()) return;
|
|
|
|
|
nmPebiResultPlaybackController* pPlaybackController =
|
|
|
|
|
m_pControlBar == nullptr ? nullptr :
|
|
|
|
|
m_pControlBar->getPlaybackController();
|
|
|
|
|
@ -998,6 +1064,7 @@ void nmWxPebiResultViewWidget::onShowFilterSettings()
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onRegionPressureStatisticsTriggered()
|
|
|
|
|
{
|
|
|
|
|
if(isImportedVolumeMode()) return;
|
|
|
|
|
if(m_pRegionState == nullptr || m_pControlBar == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -1223,6 +1290,7 @@ void nmWxPebiResultViewWidget::processPendingRegionInteractionEvent()
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onResultDisplayStateChanged()
|
|
|
|
|
{
|
|
|
|
|
if(isImportedVolumeMode()) return;
|
|
|
|
|
if(m_pRegionState != nullptr && m_pSceneController != nullptr &&
|
|
|
|
|
m_pRegionState->m_eState ==
|
|
|
|
|
nmWxPebiResultRegionState::State_Completed) {
|
|
|
|
|
@ -1251,6 +1319,7 @@ void nmWxPebiResultViewWidget::onCloseRegionPressureStatistics()
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onExportAnimationRequested()
|
|
|
|
|
{
|
|
|
|
|
if(isImportedVolumeMode()) return;
|
|
|
|
|
nmPebiResultPlaybackController* pPlaybackController =
|
|
|
|
|
m_pControlBar == nullptr ? nullptr :
|
|
|
|
|
m_pControlBar->getPlaybackController();
|
|
|
|
|
@ -1426,6 +1495,10 @@ void nmWxPebiResultViewWidget::onExportAnimationRequested()
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onScalarBarToggled(bool bVisible)
|
|
|
|
|
{
|
|
|
|
|
if(isImportedVolumeMode()) {
|
|
|
|
|
m_pVolumeState->m_pController->setScalarBarVisible(bVisible);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(m_pControlBar != nullptr &&
|
|
|
|
|
m_pControlBar->isExternalInteractionLocked()) {
|
|
|
|
|
synchronizeBusinessActions();
|
|
|
|
|
@ -1438,6 +1511,10 @@ void nmWxPebiResultViewWidget::onScalarBarToggled(bool bVisible)
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onScaleGridToggled(bool bVisible)
|
|
|
|
|
{
|
|
|
|
|
if(isImportedVolumeMode()) {
|
|
|
|
|
m_pVolumeState->m_pController->setScaleGridVisible(bVisible);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(m_pControlBar != nullptr &&
|
|
|
|
|
m_pControlBar->isExternalInteractionLocked()) {
|
|
|
|
|
synchronizeBusinessActions();
|
|
|
|
|
@ -1450,6 +1527,7 @@ void nmWxPebiResultViewWidget::onScaleGridToggled(bool bVisible)
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onWellNamesToggled(bool bVisible)
|
|
|
|
|
{
|
|
|
|
|
if(isImportedVolumeMode()) return;
|
|
|
|
|
if(m_pControlBar != nullptr &&
|
|
|
|
|
m_pControlBar->isExternalInteractionLocked()) {
|
|
|
|
|
synchronizeBusinessActions();
|
|
|
|
|
@ -1489,6 +1567,7 @@ void nmWxPebiResultViewWidget::createUi()
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_Print |
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_PrintPreview);
|
|
|
|
|
m_pSceneController = new nmPebiResultSceneController(m_pRenderContainer);
|
|
|
|
|
m_pVolumeState->m_pController = new nmVolumeSceneController(m_pRenderContainer);
|
|
|
|
|
connect(m_pRenderContainer, SIGNAL(viewportSizeChanged(int,int)),
|
|
|
|
|
this, SLOT(onViewportSizeChanged(int,int)));
|
|
|
|
|
const QSize oInitialViewportSize =
|
|
|
|
|
@ -1567,6 +1646,39 @@ void nmWxPebiResultViewWidget::createUi()
|
|
|
|
|
if(pCopyAction != nullptr) m_pToolBar->addAction(pCopyAction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 只增加一个常驻按钮。小图标直接绘制,避免部署时丢失额外资源文件。
|
|
|
|
|
QPixmap oSliceIcon(32, 32);
|
|
|
|
|
oSliceIcon.fill(Qt::transparent);
|
|
|
|
|
{
|
|
|
|
|
QPainter oPainter(&oSliceIcon);
|
|
|
|
|
oPainter.setRenderHint(QPainter::Antialiasing);
|
|
|
|
|
oPainter.setPen(QPen(QColor(65, 85, 105), 1.5));
|
|
|
|
|
oPainter.drawRect(7, 5, 18, 22);
|
|
|
|
|
oPainter.setBrush(QColor(60, 155, 215, 160));
|
|
|
|
|
QPolygon oPlane;
|
|
|
|
|
oPlane << QPoint(3, 20) << QPoint(20, 11) << QPoint(29, 14) << QPoint(12, 24);
|
|
|
|
|
oPainter.drawPolygon(oPlane);
|
|
|
|
|
}
|
|
|
|
|
m_pVolumeState->m_pButton = new QToolButton(m_pToolBar);
|
|
|
|
|
m_pVolumeState->m_pButton->setObjectName(QLatin1String("volumeSliceButton"));
|
|
|
|
|
m_pVolumeState->m_pButton->setIcon(QIcon(oSliceIcon));
|
|
|
|
|
m_pVolumeState->m_pButton->setIconSize(m_pToolBar->iconSize());
|
|
|
|
|
m_pVolumeState->m_pButton->setText(tr("Slice"));
|
|
|
|
|
m_pVolumeState->m_pButton->setToolTip(tr("Slice"));
|
|
|
|
|
m_pVolumeState->m_pButton->setAutoRaise(true);
|
|
|
|
|
m_pVolumeState->m_pButton->setPopupMode(QToolButton::InstantPopup);
|
|
|
|
|
QMenu* pSliceMenu = new QMenu(m_pVolumeState->m_pButton);
|
|
|
|
|
m_pVolumeState->m_pImportAction = new QAction(tr("Import 3D Model..."), this);
|
|
|
|
|
m_pVolumeState->m_pImportAction->setObjectName(QLatin1String("importVolumeAction"));
|
|
|
|
|
m_pVolumeState->m_pReturnAction = new QAction(tr("Return to Calculation Result"), this);
|
|
|
|
|
m_pVolumeState->m_pReturnAction->setObjectName(QLatin1String("returnCalculationAction"));
|
|
|
|
|
pSliceMenu->addAction(m_pVolumeState->m_pImportAction);
|
|
|
|
|
pSliceMenu->addAction(m_pVolumeState->m_pReturnAction);
|
|
|
|
|
m_pVolumeState->m_pButton->setMenu(pSliceMenu);
|
|
|
|
|
m_pToolBar->addWidget(m_pVolumeState->m_pButton);
|
|
|
|
|
connect(m_pVolumeState->m_pImportAction, SIGNAL(triggered()), this, SLOT(onImportVolumeRequested()));
|
|
|
|
|
connect(m_pVolumeState->m_pReturnAction, SIGNAL(triggered()), this, SLOT(onReturnToCalculationResult()));
|
|
|
|
|
|
|
|
|
|
connect(m_pScalarBarAction, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(onScalarBarToggled(bool)));
|
|
|
|
|
connect(m_pScaleGridAction, SIGNAL(toggled(bool)),
|
|
|
|
|
@ -1612,6 +1724,11 @@ void nmWxPebiResultViewWidget::createUi()
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::synchronizeOnce()
|
|
|
|
|
{
|
|
|
|
|
if(isImportedVolumeMode()) {
|
|
|
|
|
// 正式结果变化不能抢占正在查看的外部模型;返回时读取 Manager 最新快照。
|
|
|
|
|
m_pVolumeState->m_bPendingSync = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(m_pDataManager.isNull()) {
|
|
|
|
|
if(m_bObservedStateValid && m_pObservedSnapshot.isNull()) {
|
|
|
|
|
return;
|
|
|
|
|
@ -2210,6 +2327,8 @@ void nmWxPebiResultViewWidget::rememberObservedState(
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::synchronizeBusinessActions()
|
|
|
|
|
{
|
|
|
|
|
synchronizeVolumeActions();
|
|
|
|
|
if(isImportedVolumeMode()) return;
|
|
|
|
|
if(m_pSceneController == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -2274,6 +2393,12 @@ void nmWxPebiResultViewWidget::synchronizeBusinessActions()
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::refreshStatusBar()
|
|
|
|
|
{
|
|
|
|
|
if(isImportedVolumeMode()) {
|
|
|
|
|
m_pStatusLabel->setStyleSheet("QLabel { color: #a32626; background: #fdecec; }");
|
|
|
|
|
m_pStatusLabel->setText(m_sOperationError);
|
|
|
|
|
m_pStatusLabel->setVisible(!m_sOperationError.isEmpty());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(m_pStatusLabel == nullptr || m_pSceneController == nullptr ||
|
|
|
|
|
!m_pSceneController->hasSnapshot()) {
|
|
|
|
|
if(m_pStatusLabel != nullptr) {
|
|
|
|
|
@ -2310,3 +2435,187 @@ void nmWxPebiResultViewWidget::disconnectDataManager()
|
|
|
|
|
}
|
|
|
|
|
m_pDataManager = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultViewWidget::isImportedVolumeMode() const
|
|
|
|
|
{
|
|
|
|
|
return m_pVolumeState != nullptr && m_pVolumeState->m_bImported;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultViewWidget::canImportVolume() const
|
|
|
|
|
{
|
|
|
|
|
if(m_pVolumeState == nullptr || m_pVolumeState->m_pTask != nullptr ||
|
|
|
|
|
m_pControlBar == nullptr || m_pControlBar->isExportInProgress() ||
|
|
|
|
|
isRegionPressureDrawing()) return false;
|
|
|
|
|
nmPebiResultPlaybackController* pPlayback = m_pControlBar->getPlaybackController();
|
|
|
|
|
return (pPlayback == nullptr || !pPlayback->isPlaying()) &&
|
|
|
|
|
(isImportedVolumeMode() || !m_pControlBar->isExternalInteractionLocked());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::synchronizeVolumeActions()
|
|
|
|
|
{
|
|
|
|
|
if(m_pVolumeState == nullptr || m_pVolumeState->m_pImportAction == nullptr) return;
|
|
|
|
|
m_pVolumeState->m_pImportAction->setEnabled(canImportVolume());
|
|
|
|
|
m_pVolumeState->m_pImportAction->setText(isImportedVolumeMode()
|
|
|
|
|
? tr("Replace 3D Model...") : tr("Import 3D Model..."));
|
|
|
|
|
m_pVolumeState->m_pReturnAction->setEnabled(isImportedVolumeMode() && m_pVolumeState->m_pTask == nullptr);
|
|
|
|
|
if(!isImportedVolumeMode()) return;
|
|
|
|
|
nmVolumeSceneController* pVolume = m_pVolumeState->m_pController;
|
|
|
|
|
setActionCheckedWithoutSignal(m_pScalarBarAction, pVolume->isScalarBarVisible());
|
|
|
|
|
setActionCheckedWithoutSignal(m_pScaleGridAction, pVolume->isScaleGridVisible());
|
|
|
|
|
m_pScalarBarAction->setEnabled(pVolume->hasScalarProperty());
|
|
|
|
|
m_pScaleGridAction->setEnabled(pVolume->hasData());
|
|
|
|
|
m_pWellNamesAction->setEnabled(false);
|
|
|
|
|
m_pFilterAction->setEnabled(false);
|
|
|
|
|
m_pRegionPressureAction->setEnabled(false);
|
|
|
|
|
m_pControlBar->getExportAnimationAction()->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onImportVolumeRequested()
|
|
|
|
|
{
|
|
|
|
|
if(!canImportVolume()) return;
|
|
|
|
|
const QString sFilePath = QFileDialog::getOpenFileName(this, tr("Import 3D Model"),
|
|
|
|
|
QString(), tr("VTK Volume Mesh (*.vtk *.vtu)"));
|
|
|
|
|
if(!sFilePath.isEmpty()) importVolumeFile(sFilePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultViewWidget::importVolumeFile(const QString& sFilePath)
|
|
|
|
|
{
|
|
|
|
|
if(!isResultViewGuiThread() || sFilePath.isEmpty() || !canImportVolume()) return false;
|
|
|
|
|
m_pVolumeState->m_pTask = new nmVolumeImportTask(sFilePath, this);
|
|
|
|
|
m_pVolumeState->m_pProgress = new QProgressDialog(tr("Loading 3D model..."), tr("Cancel"), 0, 100, this);
|
|
|
|
|
m_pVolumeState->m_pProgress->setObjectName(QLatin1String("volumeImportProgress"));
|
|
|
|
|
m_pVolumeState->m_pProgress->setWindowModality(Qt::WindowModal);
|
|
|
|
|
m_pVolumeState->m_pProgress->setMinimumDuration(0);
|
|
|
|
|
m_pVolumeState->m_pProgress->setAutoClose(false);
|
|
|
|
|
m_pVolumeState->m_pProgress->setAutoReset(false);
|
|
|
|
|
connect(m_pVolumeState->m_pProgress, SIGNAL(canceled()), this, SLOT(onCancelVolumeImport()));
|
|
|
|
|
connect(m_pVolumeState->m_pTask, SIGNAL(progressChanged(int)),
|
|
|
|
|
m_pVolumeState->m_pProgress, SLOT(setValue(int)), Qt::QueuedConnection);
|
|
|
|
|
connect(m_pVolumeState->m_pTask, SIGNAL(finished()),
|
|
|
|
|
this, SLOT(onVolumeImportFinished()), Qt::QueuedConnection);
|
|
|
|
|
m_pVolumeState->m_pProgress->show();
|
|
|
|
|
synchronizeBusinessActions();
|
|
|
|
|
m_pVolumeState->m_pTask->start();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onCancelVolumeImport()
|
|
|
|
|
{
|
|
|
|
|
if(m_pVolumeState->m_pTask != nullptr) m_pVolumeState->m_pTask->requestCancel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onVolumeImportFinished()
|
|
|
|
|
{
|
|
|
|
|
nmVolumeImportTask* pTask = m_pVolumeState->m_pTask;
|
|
|
|
|
if(pTask == nullptr || sender() != pTask) return;
|
|
|
|
|
// finished 发出后仍等待线程完全退出,确保结果和字符串已不再被工作线程改写。
|
|
|
|
|
pTask->wait();
|
|
|
|
|
const bool bCanceled = pTask->isCanceled();
|
|
|
|
|
const QSharedPointer<const nmVolumeData> pData = pTask->getResult();
|
|
|
|
|
QString sError = pTask->getError();
|
|
|
|
|
disconnect(pTask, nullptr, nullptr, nullptr);
|
|
|
|
|
delete pTask;
|
|
|
|
|
m_pVolumeState->m_pTask = nullptr;
|
|
|
|
|
// 模态进度更新可能嵌套处理 Qt 事件;延迟删除,避免在 setValue 栈内析构。
|
|
|
|
|
m_pVolumeState->m_pProgress->hide();
|
|
|
|
|
m_pVolumeState->m_pProgress->deleteLater();
|
|
|
|
|
m_pVolumeState->m_pProgress = nullptr;
|
|
|
|
|
if(bCanceled) {
|
|
|
|
|
synchronizeBusinessActions();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
nmVTKViewState oPreviousView;
|
|
|
|
|
m_pRenderContainer->captureViewState(oPreviousView);
|
|
|
|
|
if(pData.isNull() || !m_pVolumeState->m_pController->setData(pData, &sError)) {
|
|
|
|
|
m_sOperationError = sError.isEmpty() ? tr("Unable to display the 3D model.") : sError;
|
|
|
|
|
synchronizeBusinessActions();
|
|
|
|
|
// 空结果页也应显示导入错误,而不是把错误藏在不可见的旧结果状态中。
|
|
|
|
|
m_pStatusLabel->setStyleSheet("QLabel { color: #a32626; background: #fdecec; }");
|
|
|
|
|
m_pStatusLabel->setText(m_sOperationError);
|
|
|
|
|
m_pStatusLabel->show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(!isImportedVolumeMode()) {
|
|
|
|
|
m_pVolumeState->m_oSavedView = oPreviousView;
|
|
|
|
|
m_pVolumeState->m_eSavedCommands = m_pRenderContainer->getViewCommandController()->getCapabilities();
|
|
|
|
|
m_pControlBar->stopPlayback();
|
|
|
|
|
stopRegionPressureDrawing();
|
|
|
|
|
// 区域图层由 Scene 所有;先核实对象身份,避免访问已被外部清理的观察指针。
|
|
|
|
|
nmVTKScene* pScene = m_pRenderContainer->getScene();
|
|
|
|
|
const bool bHasRegionLayer = pScene != nullptr && m_pRegionState->m_pLayer != nullptr &&
|
|
|
|
|
pScene->getLayer(QString::fromLatin1(PEBI_REGION_PRESSURE_LAYER_ID)) == m_pRegionState->m_pLayer;
|
|
|
|
|
m_pVolumeState->m_bRegionVisible = bHasRegionLayer && m_pRegionState->m_pLayer->isVisible();
|
|
|
|
|
m_pVolumeState->m_bRegionDialogVisible = m_pRegionState->m_pDialog != nullptr && m_pRegionState->m_pDialog->isVisible();
|
|
|
|
|
if(bHasRegionLayer) m_pRegionState->m_pLayer->setVisible(false);
|
|
|
|
|
if(m_pRegionState->m_pDialog != nullptr) m_pRegionState->m_pDialog->hide();
|
|
|
|
|
m_pSceneController->setSuspended(true);
|
|
|
|
|
}
|
|
|
|
|
m_pRenderContainer->setViewCommandCapabilities(m_pVolumeState->m_eSavedCommands |
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_Right |
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_Isometric);
|
|
|
|
|
m_pVolumeState->m_bImported = true;
|
|
|
|
|
m_pControlBar->setExternalInteractionLocked(true);
|
|
|
|
|
m_pControlBar->hide();
|
|
|
|
|
m_pRenderContainer->restoreDefaultInteraction();
|
|
|
|
|
m_pVolumeState->m_pController->activate(true);
|
|
|
|
|
m_sOperationError.clear();
|
|
|
|
|
synchronizeBusinessActions();
|
|
|
|
|
refreshStatusBar();
|
|
|
|
|
m_pRenderContainer->showReadyState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onReturnToCalculationResult()
|
|
|
|
|
{
|
|
|
|
|
if(!isImportedVolumeMode() || m_pVolumeState->m_pTask != nullptr) return;
|
|
|
|
|
const QSharedPointer<const nmPebiResultSnapshot> pLatest = m_pDataManager.isNull()
|
|
|
|
|
? QSharedPointer<const nmPebiResultSnapshot>() : m_pDataManager->getPebiResultSnapshot();
|
|
|
|
|
const bool bSameSnapshot = !pLatest.isNull() && pLatest == m_pDisplayedSnapshot &&
|
|
|
|
|
pLatest->getSnapshotId() == m_sDisplayedSnapshotId && m_pSceneController->hasSnapshot();
|
|
|
|
|
if(!pLatest.isNull() && !bSameSnapshot) {
|
|
|
|
|
QString sError;
|
|
|
|
|
// PEBI 仍处于挂起状态,候选绑定既不显示图层,也不移动当前三维相机。
|
|
|
|
|
if(!m_pSceneController->setSnapshot(pLatest, &sError)) {
|
|
|
|
|
m_sOperationError = tr("Unable to return to the latest calculation result: %1").arg(sError);
|
|
|
|
|
refreshStatusBar();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_pVolumeState->m_pController->hide();
|
|
|
|
|
m_pRenderContainer->setRotationCenterPickTarget(nullptr);
|
|
|
|
|
m_pVolumeState->m_bImported = false;
|
|
|
|
|
m_pRenderContainer->setViewCommandCapabilities(m_pVolumeState->m_eSavedCommands);
|
|
|
|
|
if(pLatest.isNull()) {
|
|
|
|
|
m_pSceneController->setSuspended(false);
|
|
|
|
|
m_pVolumeState->m_pController->clear();
|
|
|
|
|
clearSceneAndControls(tr("No result data."));
|
|
|
|
|
} else {
|
|
|
|
|
if(!bSameSnapshot) clearRegionPressureSelection(false);
|
|
|
|
|
m_pSceneController->setSuspended(false);
|
|
|
|
|
if(bSameSnapshot) {
|
|
|
|
|
m_pRenderContainer->restoreViewState(m_pVolumeState->m_oSavedView);
|
|
|
|
|
nmVTKScene* pScene = m_pRenderContainer->getScene();
|
|
|
|
|
if(pScene != nullptr && m_pRegionState->m_pLayer != nullptr &&
|
|
|
|
|
pScene->getLayer(QString::fromLatin1(PEBI_REGION_PRESSURE_LAYER_ID)) == m_pRegionState->m_pLayer) {
|
|
|
|
|
m_pRegionState->m_pLayer->setVisible(m_pVolumeState->m_bRegionVisible);
|
|
|
|
|
}
|
|
|
|
|
if(m_pVolumeState->m_bRegionDialogVisible && m_pRegionState->m_pDialog != nullptr) m_pRegionState->m_pDialog->show();
|
|
|
|
|
} else {
|
|
|
|
|
m_pRenderContainer->fitTopViewWithoutRender();
|
|
|
|
|
m_pRenderContainer->resetRotationCenterWithoutRender();
|
|
|
|
|
}
|
|
|
|
|
m_pVolumeState->m_pController->clear();
|
|
|
|
|
m_pDisplayedSnapshot = pLatest;
|
|
|
|
|
m_sDisplayedSnapshotId = pLatest->getSnapshotId();
|
|
|
|
|
rememberObservedState(pLatest, m_sDisplayedSnapshotId, m_pDataManager->isPebiResultSnapshotCurrent());
|
|
|
|
|
m_sBindingError.clear();
|
|
|
|
|
m_sOperationError.clear();
|
|
|
|
|
m_pRenderContainer->showReadyState();
|
|
|
|
|
}
|
|
|
|
|
m_pVolumeState->m_bPendingSync = false;
|
|
|
|
|
m_pVolumeState->m_oSavedView = nmVTKViewState();
|
|
|
|
|
m_pControlBar->setExternalInteractionLocked(false);
|
|
|
|
|
m_pControlBar->show();
|
|
|
|
|
m_pControlBar->synchronizeFromScene();
|
|
|
|
|
synchronizeBusinessActions();
|
|
|
|
|
refreshStatusBar();
|
|
|
|
|
}
|
|
|
|
|
|