diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCurves.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCurves.cpp index 109e5dab3c..91af1a7784 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCurves.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCurves.cpp @@ -34,6 +34,22 @@ CAF_CMD_SOURCE_INIT(RicEditSummaryCurves, "RicEditSummaryCurves"); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicEditSummaryCurves::closeDialogAndResetTargetPlot() +{ + if (m_dialogWithSplitter && m_dialogWithSplitter->isVisible()) + { + m_dialogWithSplitter->hide(); + } + + if (m_curveCreator) + { + m_curveCreator->updateFromSummaryPlot(nullptr); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -64,7 +80,7 @@ void RicEditSummaryCurves::onActionTriggered(bool isChecked) caf::SelectionManager::instance()->objectsByType(&plots); if (plots.size() == 1) { - m_curveCreator->setTargetPlot(plots.front()); + m_curveCreator->updateFromSummaryPlot(plots.front()); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCurves.h b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCurves.h index 698f7acb53..e3c5238bd3 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCurves.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCurves.h @@ -35,6 +35,9 @@ class RicEditSummaryCurves : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + void closeDialogAndResetTargetPlot(); + protected: // Overrides virtual bool isCommandEnabled(); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 5c4f99f886..589bb83c20 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -164,7 +164,6 @@ RicSummaryCurveCreator::RicSummaryCurveCreator() : m_identifierFieldsMap( CAF_PDM_InitFieldNoDefault(m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR][1]->pdmField(), "BlockLgrIjk", "Cell IJK", "", "", ""); CAF_PDM_InitFieldNoDefault(m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR][2]->pdmField(), "BlockLgrVectors", "Block Vectors", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_previewPlot, "PreviewPlot", "PreviewPlot", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_targetPlot, "TargetPlot", "Target Plot", "", "", ""); CAF_PDM_InitField(&m_useAutoAppearanceAssignment, "UseAutoAppearanceAssignment", true, "Auto", "", "", ""); @@ -196,9 +195,6 @@ RicSummaryCurveCreator::RicSummaryCurveCreator() : m_identifierFieldsMap( m_selectedSummaryCategory.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_selectedSummaryCategory.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); - m_previewPlot.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); - //m_previewPlot.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); - CAF_PDM_InitFieldNoDefault(&m_applyButtonField, "ApplySelection", "", "", "", ""); m_applyButtonField = false; m_applyButtonField.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); @@ -226,19 +222,29 @@ RicSummaryCurveCreator::~RicSummaryCurveCreator() delete identifierAndField->pdmField(); } } + + delete m_previewPlot; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::setTargetPlot(RimSummaryPlot* targetPlot) +void RicSummaryCurveCreator::updateFromSummaryPlot(RimSummaryPlot* targetPlot) { - m_targetPlot = targetPlot; - if (targetPlot != nullptr) + if (m_targetPlot != targetPlot) { - populateCurveCreator(*targetPlot); - updateConnectedEditors(); + resetAllFields(); } + + m_targetPlot = targetPlot; + + if (m_targetPlot) + { + populateCurveCreator(*m_targetPlot); + loadDataAndUpdatePlot(); + } + + updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -1032,3 +1038,23 @@ void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, curveCopy->initAfterReadRecursively(); curveCopy->loadDataAndUpdate(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreator::resetAllFields() +{ + m_selectedCases.clear(); + + m_previewPlot->deleteAllSummaryCurves(); + m_targetPlot = nullptr; + + // clear all state in fields + for (auto& identifierAndFieldList : m_identifierFieldsMap) + { + for (auto a : identifierAndFieldList.second) + { + a->pdmField()->v().clear(); + } + } +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h index a56886be33..2022931ab3 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h @@ -75,7 +75,7 @@ public: virtual ~RicSummaryCurveCreator(); RimSummaryPlot* previewPlot() { return m_previewPlot;} - void setTargetPlot(RimSummaryPlot* targetPlot); + void updateFromSummaryPlot(RimSummaryPlot* targetPlot); bool isCloseButtonPressed() const; void clearCloseButton(); @@ -113,13 +113,16 @@ private: void updateTargetPlot(); void copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot); + void resetAllFields(); + private: caf::PdmPtrArrayField m_selectedCases; caf::PdmField> m_selectedSummaryCategory; std::map> m_identifierFieldsMap; caf::PdmPtrField m_targetPlot; - caf::PdmChildField m_previewPlot; + + RimSummaryPlot* m_previewPlot; caf::PdmField m_useAutoAppearanceAssignment; caf::PdmField< AppearanceTypeAppEnum > m_caseAppearanceType; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 68f3c85b29..deb4b71a1a 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -59,6 +59,7 @@ #include "cafUtils.h" #include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" +#include "SummaryPlotCommands/RicEditSummaryCurves.h" #include "cvfTimer.h" @@ -183,6 +184,12 @@ void RiuMainWindow::cleanupGuiCaseClose() } } m_processMonitor->startMonitorWorkProcess(NULL); + + RicEditSummaryCurves* editSumCurves = dynamic_cast(caf::CmdFeatureManager::instance()->getCommandFeature("RicEditSummaryCurves")); + if (editSumCurves) + { + editSumCurves->closeDialogAndResetTargetPlot(); + } } //--------------------------------------------------------------------------------------------------