From 9769d391e108ceaf82d2adba1b54572058346084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 12 Dec 2017 13:22:16 +0100 Subject: [PATCH] #2199, #2245 Summary plots. Add paste commands for cross plot. Add duplicate summary plots and curves --- .../Application/Tools/RiaSummaryTools.cpp | 8 ++ .../Application/Tools/RiaSummaryTools.h | 1 + .../CMakeLists_files.cmake | 12 ++ ...cDuplicateSummaryCrossPlotCurveFeature.cpp | 63 +++++++++ ...RicDuplicateSummaryCrossPlotCurveFeature.h | 40 ++++++ .../RicDuplicateSummaryCrossPlotFeature.cpp | 75 +++++++++++ .../RicDuplicateSummaryCrossPlotFeature.h | 39 ++++++ .../RicDuplicateSummaryCurveFeature.cpp | 80 ++++++++++++ .../RicDuplicateSummaryCurveFeature.h | 38 ++++++ .../RicDuplicateSummaryPlotFeature.cpp | 75 +++++++++++ .../RicDuplicateSummaryPlotFeature.h | 39 ++++++ .../RicNewSummaryCrossPlotFeature.cpp | 5 +- .../RicPasteSummaryCrossPlotCurveFeature.cpp | 91 +++++++++++++ .../RicPasteSummaryCrossPlotCurveFeature.h | 43 +++++++ .../RicPasteSummaryCrossPlotFeature.cpp | 120 ++++++++++++++++++ .../RicPasteSummaryCrossPlotFeature.h | 46 +++++++ .../RicPasteSummaryCurveFeature.cpp | 84 +++++++----- .../RicPasteSummaryCurveFeature.h | 6 +- .../RicPasteSummaryPlotFeature.cpp | 55 ++++---- .../RicPasteSummaryPlotFeature.h | 3 + .../RimContextCommandBuilder.cpp | 9 ++ .../Summary/RimSummaryCrossPlotCollection.cpp | 10 +- .../Summary/RimSummaryCrossPlotCollection.h | 3 +- 23 files changed, 880 insertions(+), 65 deletions(-) create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp create mode 100644 ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h diff --git a/ApplicationCode/Application/Tools/RiaSummaryTools.cpp b/ApplicationCode/Application/Tools/RiaSummaryTools.cpp index ff9b0c4671..5d6af6a70f 100644 --- a/ApplicationCode/Application/Tools/RiaSummaryTools.cpp +++ b/ApplicationCode/Application/Tools/RiaSummaryTools.cpp @@ -130,3 +130,11 @@ RimSummaryCrossPlotCollection* RiaSummaryTools::parentCrossPlotCollection(caf::P return crossPlotColl; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaSummaryTools::isSummaryCrossPlot(const RimSummaryPlot* plot) +{ + return dynamic_cast(plot); +} diff --git a/ApplicationCode/Application/Tools/RiaSummaryTools.h b/ApplicationCode/Application/Tools/RiaSummaryTools.h index 8390cfe86d..92271a4bbc 100644 --- a/ApplicationCode/Application/Tools/RiaSummaryTools.h +++ b/ApplicationCode/Application/Tools/RiaSummaryTools.h @@ -44,4 +44,5 @@ public: static RimSummaryCrossPlot* parentCrossPlot(caf::PdmObject* object); static RimSummaryCrossPlotCollection* parentCrossPlotCollection(caf::PdmObject* object); + static bool isSummaryCrossPlot(const RimSummaryPlot* plot); }; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake index 41c571f364..841ee8017a 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake @@ -9,12 +9,18 @@ set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryPlotFeature.h +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCurveFeature.h +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotFeature.h +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotCurveFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.h ${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h ${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.h +${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteSummaryCurveFeature.h +${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotCurveFeature.h ${CEE_CURRENT_LIST_DIR}RicPasteSummaryCaseFeature.h ${CEE_CURRENT_LIST_DIR}RicAsciiExportSummaryPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicNewGridTimeHistoryCurveFeature.h @@ -38,12 +44,18 @@ set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.cpp +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryPlotFeature.cpp +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCurveFeature.cpp +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotFeature.cpp +${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotCurveFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.cpp ${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp ${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.cpp +${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteSummaryCurveFeature.cpp +${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotCurveFeature.cpp ${CEE_CURRENT_LIST_DIR}RicPasteSummaryCaseFeature.cpp ${CEE_CURRENT_LIST_DIR}RicAsciiExportSummaryPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicNewGridTimeHistoryCurveFeature.cpp diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp new file mode 100644 index 0000000000..f8496965b4 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicDuplicateSummaryCrossPlotCurveFeature.h" + +#include "RiaApplication.h" + +#include "RicPasteSummaryCurveFeature.h" + +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RiaSummaryTools.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryCrossPlot.h" +#include "RimSummaryCrossPlotCollection.h" + +#include "RiuMainPlotWindow.h" + +#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" + +#include "cafSelectionManagerTools.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicDuplicateSummaryCrossPlotCurveFeature, "RicDuplicateSummaryCrossPlotCurveFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDuplicateSummaryCrossPlotCurveFeature::isCommandEnabled() +{ + RimSummaryCrossPlot* selectedPlot = caf::firstAncestorOfTypeFromSelectedObject(); + return (selectedPlot); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryCrossPlotCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Duplicate Summary Cross Plot Curve"); + actionToSetup->setIcon(QIcon(":/SummaryCurve16x16.png")); +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h new file mode 100644 index 0000000000..58438cad7b --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicDuplicateSummaryCurveFeature.h" + +#include "cafCmdFeature.h" + +#include + +class RimSummaryCrossPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicDuplicateSummaryCrossPlotCurveFeature : public RicDuplicateSummaryCurveFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void setupActionLook( QAction* actionToSetup ); +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp new file mode 100644 index 0000000000..994f6176c3 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicDuplicateSummaryCrossPlotFeature.h" + +#include "RiaSummaryTools.h" + +#include "RicPasteSummaryCrossPlotFeature.h" + +#include "RimSummaryCrossPlot.h" +#include "RimSummaryCrossPlotCollection.h" + +#include "cvfAssert.h" +#include "cafSelectionManagerTools.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicDuplicateSummaryCrossPlotFeature, "RicDuplicateSummaryCrossPlotFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDuplicateSummaryCrossPlotFeature::isCommandEnabled() +{ + RimSummaryCrossPlotCollection* sumPlotColl = nullptr; + + caf::PdmObject* selObj = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (selObj) + { + sumPlotColl = RiaSummaryTools::parentCrossPlotCollection(selObj); + } + + if (sumPlotColl) return true; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryCrossPlotFeature::onActionTriggered(bool isChecked) +{ + std::vector selectedObjects = caf::selectedObjectsByType(); + + if (selectedObjects.size() == 1) + { + RicPasteSummaryCrossPlotFeature::copyPlotAndAddToCollection(selectedObjects[0]); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Duplicate Summary Cross Plot"); + actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); +} + diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h new file mode 100644 index 0000000000..a247fa562f --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimSummaryPlotCollection; +class RimSummaryCase; +class RimSummaryPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicDuplicateSummaryCrossPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook(QAction* actionToSetup); +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp new file mode 100644 index 0000000000..ad1e0b2cb3 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp @@ -0,0 +1,80 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicDuplicateSummaryCurveFeature.h" + +#include "RiaApplication.h" + +#include "RicPasteSummaryCurveFeature.h" + +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RiaSummaryTools.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" +#include "RimSummaryPlotCollection.h" + +#include "RiuMainPlotWindow.h" + +#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" + +#include "cafSelectionManagerTools.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicDuplicateSummaryCurveFeature, "RicDuplicateSummaryCurveFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDuplicateSummaryCurveFeature::isCommandEnabled() +{ + RimSummaryPlot* selectedPlot = caf::firstAncestorOfTypeFromSelectedObject(); + return (selectedPlot && !RiaSummaryTools::isSummaryCrossPlot(selectedPlot)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryCurveFeature::onActionTriggered(bool isChecked) +{ + RimProject* project = RiaApplication::instance()->project(); + CVF_ASSERT(project); + + RimSummaryCurve* curve = caf::firstAncestorOfTypeFromSelectedObject(); + if (curve) + { + RimSummaryCurve* newCurve = RicPasteSummaryCurveFeature::copyCurveAndAddToPlot(curve); + + RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Duplicate Summary Curve"); + actionToSetup->setIcon(QIcon(":/SummaryCurve16x16.png")); +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h new file mode 100644 index 0000000000..03c9862bc0 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimSummaryPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicDuplicateSummaryCurveFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp new file mode 100644 index 0000000000..0efdc162e0 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicDuplicateSummaryPlotFeature.h" + +#include "RiaSummaryTools.h" + +#include "RicPasteSummaryPlotFeature.h" + +#include "RimSummaryPlot.h" +#include "RimSummaryPlotCollection.h" + +#include "cvfAssert.h" +#include "cafSelectionManagerTools.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicDuplicateSummaryPlotFeature, "RicDuplicateSummaryPlotFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDuplicateSummaryPlotFeature::isCommandEnabled() +{ + RimSummaryPlotCollection* sumPlotColl = nullptr; + + caf::PdmObject* selObj = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (selObj) + { + sumPlotColl = RiaSummaryTools::parentSummaryPlotCollection(selObj); + } + + if (sumPlotColl) return true; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryPlotFeature::onActionTriggered(bool isChecked) +{ + std::vector selectedObjects = caf::selectedObjectsByType(); + + if (selectedObjects.size() == 1) + { + RicPasteSummaryPlotFeature::copyPlotAndAddToCollection(selectedObjects[0]); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDuplicateSummaryPlotFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Duplicate Summary Plot"); + actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); +} + diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h new file mode 100644 index 0000000000..aa1e0bba11 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimSummaryPlotCollection; +class RimSummaryCase; +class RimSummaryPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicDuplicateSummaryPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook(QAction* actionToSetup); +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp index 9e6ad6d126..b4ed164d33 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp @@ -57,8 +57,9 @@ void RicNewSummaryCrossPlotFeature::onActionTriggered(bool isChecked) CVF_ASSERT(project); RimSummaryCrossPlotCollection* summaryCrossPlotColl = project->mainPlotCollection()->summaryCrossPlotCollection(); - RimSummaryPlot* summaryPlot = summaryCrossPlotColl->addSummaryPlot(); - + RimSummaryPlot* summaryPlot = summaryCrossPlotColl->createSummaryPlot(); + + summaryCrossPlotColl->addSummaryPlot(summaryPlot); if (summaryPlot) { summaryCrossPlotColl->updateConnectedEditors(); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp new file mode 100644 index 0000000000..e7e557a7ea --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.cpp @@ -0,0 +1,91 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteSummaryCrossPlotCurveFeature.h" + +#include "RiaSummaryTools.h" + +#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" + +#include "RimSummaryCurve.h" +#include "RimSummaryCurveFilter.h" +#include "RimSummaryCrossPlot.h" + +#include "cafPdmDefaultObjectFactory.h" +#include "cafPdmDocument.h" +#include "cafPdmObjectGroup.h" +#include "cafSelectionManagerTools.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicPasteSummaryCrossPlotCurveFeature, "RicPasteSummaryCrossPlotCurveFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteSummaryCrossPlotCurveFeature::isCommandEnabled() +{ + caf::PdmObject* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + if(!RiaSummaryTools::parentCrossPlot(destinationObject)) + { + return false; + } + + if (summaryCurvesOnClipboard().size() == 0) + { + return false; + } + + for (caf::PdmPointer curve : summaryCurvesOnClipboard()) + { + // Check that owner plot is correct type + RimSummaryCrossPlot* ownerPlot = nullptr; + curve->firstAncestorOrThisOfType(ownerPlot); + + if (!ownerPlot) return false; + } + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +//void RicPasteSummaryCrossPlotCurveFeature::onActionTriggered(bool isChecked) +//{ +// std::vector > sourceObjects = RicPasteSummaryCurveFeature::summaryCurves(); +// +// for (size_t i = 0; i < sourceObjects.size(); i++) +// { +// copyCurveAndAddToPlot(sourceObjects[i]); +// } +//} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryCrossPlotCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste Summary Cross Plot Curve"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h new file mode 100644 index 0000000000..278ff6521e --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotCurveFeature.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicPasteSummaryCurveFeature.h" + +#include "cafCmdFeature.h" +#include "cafPdmPointer.h" + +#include + +class RimSummaryCurve; +class RimSummaryCurveFilter; + +//================================================================================================== +/// +//================================================================================================== +class RicPasteSummaryCrossPlotCurveFeature : public RicPasteSummaryCurveFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + //virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook(QAction* actionToSetup) override; +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp new file mode 100644 index 0000000000..ebb2cbad57 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.cpp @@ -0,0 +1,120 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteSummaryCrossPlotFeature.h" + +#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" + +#include "RimSummaryCrossPlot.h" +#include "RimSummaryCrossPlotCollection.h" + +#include "cafPdmDefaultObjectFactory.h" +#include "cafPdmDocument.h" +#include "cafPdmObjectGroup.h" +#include "cafPdmObjectGroup.h" +#include "cafSelectionManagerTools.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicPasteSummaryCrossPlotFeature, "RicPasteSummaryCrossPlotFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryCrossPlotFeature::copyPlotAndAddToCollection(RimSummaryCrossPlot *sourcePlot) +{ + RimSummaryCrossPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject(); + + if (plotColl) + { + RimSummaryCrossPlot* newSummaryPlot = dynamic_cast(sourcePlot->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(newSummaryPlot); + + plotColl->addSummaryPlot(newSummaryPlot); + + // Resolve references after object has been inserted into the data model + newSummaryPlot->resolveReferencesRecursively(); + newSummaryPlot->initAfterReadRecursively(); + + QString nameOfCopy = QString("Copy of ") + newSummaryPlot->description(); + newSummaryPlot->setDescription(nameOfCopy); + + plotColl->updateConnectedEditors(); + + newSummaryPlot->loadDataAndUpdate(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteSummaryCrossPlotFeature::isCommandEnabled() +{ + caf::PdmObjectHandle* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + RimSummaryCrossPlotCollection* plotColl = nullptr; + destinationObject->firstAncestorOrThisOfType(plotColl); + if (!plotColl) + { + return false; + } + + return RicPasteSummaryCrossPlotFeature::summaryPlots().size() > 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryCrossPlotFeature::onActionTriggered(bool isChecked) +{ + std::vector > sourceObjects = RicPasteSummaryCrossPlotFeature::summaryPlots(); + + for (size_t i = 0; i < sourceObjects.size(); i++) + { + copyPlotAndAddToCollection(sourceObjects[i]); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste Summary Cross Plot"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector > RicPasteSummaryCrossPlotFeature::summaryPlots() +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector > typedObjects; + objectGroup.objectsByType(&typedObjects); + + return typedObjects; +} + diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h new file mode 100644 index 0000000000..78a751a623 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCrossPlotFeature.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" +#include "cafPdmPointer.h" + +#include + +class RimSummaryCrossPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicPasteSummaryCrossPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static void copyPlotAndAddToCollection(RimSummaryCrossPlot *sourcePlot); + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + static std::vector > summaryPlots(); +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp index 9ca814082f..cfb0f828bc 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.cpp @@ -18,16 +18,19 @@ #include "RicPasteSummaryCurveFeature.h" +#include "RiaSummaryTools.h" + #include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" +#include "RimSummaryCrossPlot.h" #include "cafPdmDefaultObjectFactory.h" #include "cafPdmDocument.h" #include "cafPdmObjectGroup.h" -#include "cafSelectionManager.h" +#include "cafSelectionManagerTools.h" #include "cvfAssert.h" @@ -36,21 +39,62 @@ CAF_CMD_SOURCE_INIT(RicPasteSummaryCurveFeature, "RicPasteSummaryCurveFeature"); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve* RicPasteSummaryCurveFeature::copyCurveAndAddToPlot(RimSummaryCurve *sourceCurve) +{ + RimSummaryPlot* summaryPlot = caf::firstAncestorOfTypeFromSelectedObject(); + + RimSummaryCurve* newCurve = dynamic_cast(sourceCurve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(newCurve); + + summaryPlot->addCurveAndUpdate(newCurve); + + // Resolve references after object has been inserted into the project data model + newCurve->resolveReferencesRecursively(); + + // If source curve is part of a curve filter, resolve of references to the summary case does not + // work when pasting the new curve into a plot. Must set summary case manually. + newCurve->setSummaryCaseY(sourceCurve->summaryCaseY()); + + newCurve->initAfterReadRecursively(); + + newCurve->loadDataAndUpdate(true); + newCurve->updateConnectedEditors(); + + summaryPlot->updateConnectedEditors(); + + return newCurve; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RicPasteSummaryCurveFeature::isCommandEnabled() { - caf::PdmObjectHandle* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + caf::PdmObject* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); RimSummaryPlot* summaryPlot = nullptr; destinationObject->firstAncestorOrThisOfType(summaryPlot); - if (!summaryPlot) + if(!RiaSummaryTools::parentSummaryPlot(destinationObject)) { return false; } - return RicPasteSummaryCurveFeature::summaryCurves().size() > 0; + if (summaryCurvesOnClipboard().size() == 0) + { + return false; + } + + for (caf::PdmPointer curve : summaryCurvesOnClipboard()) + { + // Check that owner plot is correct type + RimSummaryPlot* ownerPlot = RiaSummaryTools::parentSummaryPlot(curve); + + if (!ownerPlot) return false; + } + return true; } //-------------------------------------------------------------------------------------------------- @@ -58,37 +102,11 @@ bool RicPasteSummaryCurveFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicPasteSummaryCurveFeature::onActionTriggered(bool isChecked) { - caf::PdmObjectHandle* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); - - RimSummaryPlot* summaryPlot = nullptr; - destinationObject->firstAncestorOrThisOfType(summaryPlot); - if (!summaryPlot) - { - return; - } - - std::vector > sourceObjects = RicPasteSummaryCurveFeature::summaryCurves(); + std::vector > sourceObjects = RicPasteSummaryCurveFeature::summaryCurvesOnClipboard(); for (size_t i = 0; i < sourceObjects.size(); i++) { - RimSummaryCurve* newObject = dynamic_cast(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); - CVF_ASSERT(newObject); - - summaryPlot->addCurveAndUpdate(newObject); - - // Resolve references after object has been inserted into the project data model - newObject->resolveReferencesRecursively(); - - // If source curve is part of a curve filter, resolve of references to the summary case does not - // work when pasting the new curve into a plot. Must set summary case manually. - newObject->setSummaryCaseY(sourceObjects[i]->summaryCaseY()); - - newObject->initAfterReadRecursively(); - - newObject->loadDataAndUpdate(true); - newObject->updateConnectedEditors(); - - summaryPlot->updateConnectedEditors(); + copyCurveAndAddToPlot(sourceObjects[i]); } } @@ -105,7 +123,7 @@ void RicPasteSummaryCurveFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector > RicPasteSummaryCurveFeature::summaryCurves() +std::vector > RicPasteSummaryCurveFeature::summaryCurvesOnClipboard() { caf::PdmObjectGroup objectGroup; RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h index d0f85d3a3f..e73c87e907 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryCurveFeature.h @@ -33,12 +33,14 @@ class RicPasteSummaryCurveFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + static RimSummaryCurve* copyCurveAndAddToPlot(RimSummaryCurve *sourceCurve); + protected: // Overrides virtual bool isCommandEnabled() override; virtual void onActionTriggered( bool isChecked ) override; virtual void setupActionLook(QAction* actionToSetup) override; -private: - static std::vector > summaryCurves(); + static std::vector > summaryCurvesOnClipboard(); }; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp index 62a519e28f..1e5023fa52 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.cpp @@ -27,7 +27,7 @@ #include "cafPdmDocument.h" #include "cafPdmObjectGroup.h" #include "cafPdmObjectGroup.h" -#include "cafSelectionManager.h" +#include "cafSelectionManagerTools.h" #include "cvfAssert.h" @@ -36,6 +36,34 @@ CAF_CMD_SOURCE_INIT(RicPasteSummaryPlotFeature, "RicPasteSummaryPlotFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteSummaryPlotFeature::copyPlotAndAddToCollection(RimSummaryPlot *sourcePlot) +{ + RimSummaryPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject(); + + if (plotColl) + { + RimSummaryPlot* newSummaryPlot = dynamic_cast(sourcePlot->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(newSummaryPlot); + + plotColl->summaryPlots.push_back(newSummaryPlot); + + // Resolve references after object has been inserted into the data model + newSummaryPlot->resolveReferencesRecursively(); + newSummaryPlot->initAfterReadRecursively(); + + QString nameOfCopy = QString("Copy of ") + newSummaryPlot->description(); + newSummaryPlot->setDescription(nameOfCopy); + + plotColl->updateConnectedEditors(); + + newSummaryPlot->loadDataAndUpdate(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -58,34 +86,11 @@ bool RicPasteSummaryPlotFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicPasteSummaryPlotFeature::onActionTriggered(bool isChecked) { - caf::PdmObjectHandle* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); - - RimSummaryPlotCollection* plotColl = nullptr; - destinationObject->firstAncestorOrThisOfType(plotColl); - if (!plotColl) - { - return; - } - std::vector > sourceObjects = RicPasteSummaryPlotFeature::summaryPlots(); for (size_t i = 0; i < sourceObjects.size(); i++) { - RimSummaryPlot* newSummaryPlot = dynamic_cast(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); - CVF_ASSERT(newSummaryPlot); - - plotColl->summaryPlots.push_back(newSummaryPlot); - - // Resolve references after object has been inserted into the data model - newSummaryPlot->resolveReferencesRecursively(); - newSummaryPlot->initAfterReadRecursively(); - - QString nameOfCopy = QString("Copy of ") + newSummaryPlot->description(); - newSummaryPlot->setDescription(nameOfCopy); - - plotColl->updateConnectedEditors(); - - newSummaryPlot->loadDataAndUpdate(); + copyPlotAndAddToCollection(sourceObjects[i]); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h index f80e50ea4d..fabd9844f0 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteSummaryPlotFeature.h @@ -32,6 +32,9 @@ class RicPasteSummaryPlotFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + static void copyPlotAndAddToCollection(RimSummaryPlot *sourcePlot); + protected: // Overrides virtual bool isCommandEnabled() override; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 3552051ff4..a457e05e2b 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -330,6 +330,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteSummaryCrossPlotFeature"; + menuBuilder << "Separator"; menuBuilder << "RicNewSummaryCrossPlotFeature"; } else if (dynamic_cast(uiItem)) @@ -358,12 +360,15 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) // This is also the definition for RimSummaryCrossPlot { menuBuilder << "RicPasteSummaryCurveFeature"; + menuBuilder << "RicPasteSummaryCrossPlotCurveFeature"; menuBuilder << "RicPasteSummaryPlotFeature"; menuBuilder << "RicPasteAsciiDataToSummaryPlotFeature"; menuBuilder << "Separator"; menuBuilder << "RicEditSummaryPlotFeature"; menuBuilder << "RicNewSummaryPlotFeature"; + menuBuilder << "RicDuplicateSummaryPlotFeature"; menuBuilder << "RicNewSummaryCurveFeature"; + menuBuilder << "RicDuplicateSummaryCrossPlotFeature"; menuBuilder << "RicNewSummaryCrossPlotCurveFeature"; menuBuilder << "Separator"; menuBuilder << "RicShowSummaryCurveCalculatorFeature"; @@ -377,9 +382,12 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { menuBuilder << "RicPasteSummaryCurveFeature"; + menuBuilder << "RicPasteSummaryCrossPlotCurveFeature"; menuBuilder << "Separator"; menuBuilder << "RicNewSummaryCurveFeature"; + menuBuilder << "RicDuplicateSummaryCurveFeature"; menuBuilder << "RicNewSummaryCrossPlotCurveFeature"; + menuBuilder << "RicDuplicateSummaryCrossPlotCurveFeature"; menuBuilder << "Separator"; menuBuilder << "RicCopyReferencesToClipboardFeature"; menuBuilder << "Separator"; @@ -388,6 +396,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { menuBuilder << "RicPasteSummaryCurveFeature"; + menuBuilder << "RicPasteSummaryCrossPlotCurveFeature"; menuBuilder << "Separator"; menuBuilder << "RicEditSummaryPlotFeature"; menuBuilder << "RicNewSummaryCurveFeature"; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp index 0f7bc2e8a9..88d3116d25 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp @@ -86,13 +86,19 @@ void RimSummaryCrossPlotCollection::summaryPlotItemInfos(QListsetDescription(QString("Summary Cross Plot %1").arg(m_summaryCrossPlots.size())); return plot; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCrossPlotCollection::addSummaryPlot(RimSummaryPlot *plot) +{ + m_summaryCrossPlots().push_back(plot); +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.h index dbff3ec2cd..472802f90d 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.h @@ -37,7 +37,8 @@ public: void deleteAllChildObjects(); std::vector summaryPlots() const; - RimSummaryPlot* addSummaryPlot(); + RimSummaryPlot* createSummaryPlot(); + void addSummaryPlot(RimSummaryPlot *plot); void updateSummaryNameHasChanged(); void summaryPlotItemInfos(QList* optionInfos) const;