fix: 修复结果视图井名无法隐藏的问题

- 由场景控制器统一控制井标注顶层图层显隐
- 确保井名与引线随按钮状态一起显示或隐藏
- 移除井标注图层内部重复的显隐状态和接口
- 保留跨快照显示偏好及候选标注事务提交机制
feature/nmNum-postprocessing-view-20260910
lh 2 weeks ago
parent 01ccc2b88c
commit d32e9602b0

@ -45,19 +45,12 @@ public:
/** @brief 返回活动快照是否已有完整井标注子树。 */ /** @brief 返回活动快照是否已有完整井标注子树。 */
bool hasActiveAnnotations() const; bool hasActiveAnnotations() const;
/** @brief 统一设置二维井名及其引线显隐。 */
void setWellNamesVisible(bool bVisible);
bool areWellNamesVisible() const;
private: private:
Q_DISABLE_COPY(nmPebiResultWellAnnotationLayer) Q_DISABLE_COPY(nmPebiResultWellAnnotationLayer)
vtkSmartPointer<vtkPropAssembly> m_pRootAssembly; ///< Scene 挂载的稳定根。 vtkSmartPointer<vtkPropAssembly> m_pRootAssembly; ///< Scene 挂载的稳定根。
vtkSmartPointer<vtkPropAssembly> m_pActiveSnapshotAssembly; ///< 当前快照子树。 vtkSmartPointer<vtkPropAssembly> m_pActiveSnapshotAssembly; ///< 当前快照子树。
vtkSmartPointer<vtkPropAssembly> m_pActiveAnnotationGroup; ///< 当前井名与引线组。
vtkSmartPointer<vtkPropAssembly> m_pCandidateSnapshotAssembly; ///< 待提交子树。 vtkSmartPointer<vtkPropAssembly> m_pCandidateSnapshotAssembly; ///< 待提交子树。
vtkSmartPointer<vtkPropAssembly> m_pCandidateAnnotationGroup; ///< 候选井名与引线组。
bool m_bWellNamesVisible; ///< 跨快照保留的文字与引线显隐偏好。
}; };
#endif // NMPEBIRESULTWELLANNOTATIONLAYER_H #endif // NMPEBIRESULTWELLANNOTATIONLAYER_H

@ -597,7 +597,6 @@ public:
new nmPebiResultWellAnnotationLayer( new nmPebiResultWellAnnotationLayer(
QString::fromLatin1(RESULT_WELLS_LAYER_ID)); QString::fromLatin1(RESULT_WELLS_LAYER_ID));
pLayer->setVisible(false); pLayer->setVisible(false);
pLayer->setWellNamesVisible(m_bWellNamesVisible);
if(!pScene->addLayer(pLayer)) { if(!pScene->addLayer(pLayer)) {
delete pLayer; delete pLayer;
rollbackCreatedLayers( rollbackCreatedLayers(
@ -721,8 +720,9 @@ public:
bHasData && m_bScaleGridVisible); bHasData && m_bScaleGridVisible);
} }
if(m_pWellLayer != nullptr) { if(m_pWellLayer != nullptr) {
m_pWellLayer->setWellNamesVisible(m_bWellNamesVisible); // 井图层只包含文字和引线,由 SceneController 统一控制顶层 Prop。
m_pWellLayer->setVisible(bHasData); m_pWellLayer->setVisible(
bHasData && m_bWellNamesVisible);
} }
if(m_pContainer != nullptr) { if(m_pContainer != nullptr) {
m_pContainer->setRotationCenterPickTarget( m_pContainer->setRotationCenterPickTarget(
@ -1355,10 +1355,9 @@ void nmPebiResultSceneController::setWellNamesVisible(bool bVisible)
return; return;
} }
m_pPrivate->m_bWellNamesVisible = bVisible; m_pPrivate->m_bWellNamesVisible = bVisible;
if(m_pPrivate->m_pWellLayer != nullptr) { const bool bHasData = hasSnapshot();
m_pPrivate->m_pWellLayer->setWellNamesVisible(bVisible); m_pPrivate->applyLayerVisibility(bHasData);
} if(bHasData) {
if(hasSnapshot()) {
m_pPrivate->m_pContainer->renderView(); m_pPrivate->m_pContainer->renderView();
} }
} }

@ -43,10 +43,7 @@ nmPebiResultWellAnnotationLayer::nmPebiResultWellAnnotationLayer(
: nmVTKRenderLayer(sLayerId), : nmVTKRenderLayer(sLayerId),
m_pRootAssembly(vtkSmartPointer<vtkPropAssembly>::New()), m_pRootAssembly(vtkSmartPointer<vtkPropAssembly>::New()),
m_pActiveSnapshotAssembly(nullptr), m_pActiveSnapshotAssembly(nullptr),
m_pActiveAnnotationGroup(nullptr), m_pCandidateSnapshotAssembly(nullptr)
m_pCandidateSnapshotAssembly(nullptr),
m_pCandidateAnnotationGroup(nullptr),
m_bWellNamesVisible(true)
{ {
Q_ASSERT(isWellAnnotationGuiThread()); Q_ASSERT(isWellAnnotationGuiThread());
// setRenderProp 只在未挂载时可调用,因此根 Assembly 在构造时一次固定。 // setRenderProp 只在未挂载时可调用,因此根 Assembly 在构造时一次固定。
@ -167,19 +164,16 @@ bool nmPebiResultWellAnnotationLayer::prepareCandidate(
} }
} }
pAnnotationGroup->SetVisibility(m_bWellNamesVisible ? 1 : 0);
pSnapshotAssembly->AddPart(pAnnotationGroup); pSnapshotAssembly->AddPart(pAnnotationGroup);
// 所有校验和 VTK 对象构造成功后才记录候选;活动子树仍未触碰。 // 所有校验和 VTK 对象构造成功后才记录候选;活动子树仍未触碰。
m_pCandidateSnapshotAssembly = pSnapshotAssembly; m_pCandidateSnapshotAssembly = pSnapshotAssembly;
m_pCandidateAnnotationGroup = pAnnotationGroup;
return true; return true;
} }
void nmPebiResultWellAnnotationLayer::discardCandidate() void nmPebiResultWellAnnotationLayer::discardCandidate()
{ {
Q_ASSERT(isWellAnnotationGuiThread()); Q_ASSERT(isWellAnnotationGuiThread());
m_pCandidateAnnotationGroup = nullptr;
m_pCandidateSnapshotAssembly = nullptr; m_pCandidateSnapshotAssembly = nullptr;
} }
@ -192,7 +186,6 @@ void nmPebiResultWellAnnotationLayer::commitCandidate()
m_pRootAssembly->RemovePart(m_pActiveSnapshotAssembly); m_pRootAssembly->RemovePart(m_pActiveSnapshotAssembly);
} }
m_pActiveSnapshotAssembly = m_pCandidateSnapshotAssembly; m_pActiveSnapshotAssembly = m_pCandidateSnapshotAssembly;
m_pActiveAnnotationGroup = m_pCandidateAnnotationGroup;
m_pRootAssembly->AddPart(m_pActiveSnapshotAssembly); m_pRootAssembly->AddPart(m_pActiveSnapshotAssembly);
discardCandidate(); discardCandidate();
} }
@ -205,7 +198,6 @@ void nmPebiResultWellAnnotationLayer::clear()
m_pActiveSnapshotAssembly != nullptr) { m_pActiveSnapshotAssembly != nullptr) {
m_pRootAssembly->RemovePart(m_pActiveSnapshotAssembly); m_pRootAssembly->RemovePart(m_pActiveSnapshotAssembly);
} }
m_pActiveAnnotationGroup = nullptr;
m_pActiveSnapshotAssembly = nullptr; m_pActiveSnapshotAssembly = nullptr;
} }
@ -213,23 +205,3 @@ bool nmPebiResultWellAnnotationLayer::hasActiveAnnotations() const
{ {
return m_pActiveSnapshotAssembly != nullptr; return m_pActiveSnapshotAssembly != nullptr;
} }
void nmPebiResultWellAnnotationLayer::setWellNamesVisible(bool bVisible)
{
Q_ASSERT(isWellAnnotationGuiThread());
if(!isWellAnnotationGuiThread()) {
return;
}
m_bWellNamesVisible = bVisible;
if(m_pActiveAnnotationGroup != nullptr) {
m_pActiveAnnotationGroup->SetVisibility(bVisible ? 1 : 0);
}
if(m_pCandidateAnnotationGroup != nullptr) {
m_pCandidateAnnotationGroup->SetVisibility(bVisible ? 1 : 0);
}
}
bool nmPebiResultWellAnnotationLayer::areWellNamesVisible() const
{
return m_bWellNamesVisible;
}

Loading…
Cancel
Save