diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp index 7e45c65123..ae107614f3 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp @@ -68,7 +68,9 @@ void RicEditSummaryPlotFeature::closeDialogAndResetTargetPlot() //-------------------------------------------------------------------------------------------------- bool RicEditSummaryPlotFeature::isCommandEnabled() { - return true; + if (selectedSummaryPlot()) return true; + + return false; } //-------------------------------------------------------------------------------------------------- @@ -92,11 +94,9 @@ void RicEditSummaryPlotFeature::onActionTriggered(bool isChecked) } // Set target plot - std::vector plots; - caf::SelectionManager::instance()->objectsByType(&plots); - if (plots.size() == 1) + if (selectedSummaryPlot()) { - curveCreator->updateFromSummaryPlot(plots.front()); + curveCreator->updateFromSummaryPlot(selectedSummaryPlot()); } } @@ -108,3 +108,19 @@ void RicEditSummaryPlotFeature::setupActionLook(QAction* actionToSetup) actionToSetup->setText("Edit Summary Plot"); actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlot* RicEditSummaryPlotFeature::selectedSummaryPlot() const +{ + RimSummaryPlot* sumPlot = nullptr; + + caf::PdmObject* selObj = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (selObj) + { + selObj->firstAncestorOrThisOfType(sumPlot); + } + + return sumPlot; +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.h index 9e4a911cb4..9f6259bf7b 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.h @@ -22,6 +22,7 @@ #include class RicSummaryCurveCreatorFactoryImpl; +class RimSummaryPlot; namespace caf { class PdmUiPropertyViewDialog; @@ -44,6 +45,9 @@ protected: virtual void onActionTriggered( bool isChecked ); virtual void setupActionLook(QAction* actionToSetup); +private: + RimSummaryPlot* selectedSummaryPlot() const; + private: RicSummaryCurveCreatorFactoryImpl* m_curveCreatorFactory; }; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp index 2fb6a8386d..905e63a32b 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp @@ -103,9 +103,13 @@ void RicNewSummaryCurveFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- RimSummaryPlot* RicNewSummaryCurveFeature::selectedSummaryPlot() const { + RimSummaryPlot* sumPlot = nullptr; + caf::PdmObject* selObj = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); - RimSummaryPlot * sumPlot; - selObj->firstAncestorOrThisOfType(sumPlot); + if (selObj) + { + selObj->firstAncestorOrThisOfType(sumPlot); + } return sumPlot; }