diff --git a/ApplicationCode/Commands/RicNewWellLogPlotFeature.cpp b/ApplicationCode/Commands/RicNewWellLogPlotFeature.cpp index e3f1cbd77f..c7863d0d55 100644 --- a/ApplicationCode/Commands/RicNewWellLogPlotFeature.cpp +++ b/ApplicationCode/Commands/RicNewWellLogPlotFeature.cpp @@ -19,9 +19,11 @@ #include "RicNewWellLogPlotFeature.h" +#include "RimProject.h" #include "RimMainPlotCollection.h" +#include "RimWellLogPlotCollection.h" -#include "cafSelectionManager.h" +#include "RiaApplication.h" #include @@ -33,7 +35,7 @@ CAF_CMD_SOURCE_INIT(RicNewWellLogPlotFeature, "RicNewWellLogPlotFeature"); //-------------------------------------------------------------------------------------------------- bool RicNewWellLogPlotFeature::isCommandEnabled() { - return selectedMainPlotCollection() != NULL; + return wellLogPlotCollection() != NULL; } //-------------------------------------------------------------------------------------------------- @@ -41,10 +43,10 @@ bool RicNewWellLogPlotFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewWellLogPlotFeature::onActionTriggered(bool isChecked) { - RimMainPlotCollection* mainPlotCollection = selectedMainPlotCollection(); - if (mainPlotCollection) + RimWellLogPlotCollection* wellLogPlotColl = wellLogPlotCollection(); + if (wellLogPlotColl) { - mainPlotCollection->addWellLogPlot(); + wellLogPlotColl->addWellLogPlot(); } } @@ -59,9 +61,10 @@ void RicNewWellLogPlotFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimMainPlotCollection* RicNewWellLogPlotFeature::selectedMainPlotCollection() +RimWellLogPlotCollection* RicNewWellLogPlotFeature::wellLogPlotCollection() { - std::vector selection; - caf::SelectionManager::instance()->objectsByType(&selection); - return selection.size() > 0 ? selection[0] : NULL; + RimProject* project = RiaApplication::instance()->project(); + RimMainPlotCollection* mainPlotCollection = project ? project->mainPlotCollection() : NULL; + + return mainPlotCollection ? mainPlotCollection->wellLogPlotCollection() : NULL; } diff --git a/ApplicationCode/Commands/RicNewWellLogPlotFeature.h b/ApplicationCode/Commands/RicNewWellLogPlotFeature.h index d9c05d1bf6..69ce8f4423 100644 --- a/ApplicationCode/Commands/RicNewWellLogPlotFeature.h +++ b/ApplicationCode/Commands/RicNewWellLogPlotFeature.h @@ -21,7 +21,7 @@ #include "cafCmdFeature.h" -class RimMainPlotCollection; +class RimWellLogPlotCollection; //================================================================================================== /// @@ -37,6 +37,5 @@ protected: virtual void setupActionLook( QAction* actionToSetup ); private: - - RimMainPlotCollection* selectedMainPlotCollection(); + RimWellLogPlotCollection* wellLogPlotCollection(); }; diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 65bbc39c38..d9f862c69b 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -62,6 +62,7 @@ ${CEE_CURRENT_LIST_DIR}RimTreeViewStateSerializer.h ${CEE_CURRENT_LIST_DIR}RimManagedViewConfig.h ${CEE_CURRENT_LIST_DIR}RimManagedViewCollection.h ${CEE_CURRENT_LIST_DIR}RimMainPlotCollection.h +${CEE_CURRENT_LIST_DIR}RimWellLogPlotCollection.h ${CEE_CURRENT_LIST_DIR}RimWellLogPlot.h ${CEE_CURRENT_LIST_DIR}RimWellLogPlotTrace.h ${CEE_CURRENT_LIST_DIR}RimWellLogPlotCurve.h @@ -125,6 +126,7 @@ ${CEE_CURRENT_LIST_DIR}RimTreeViewStateSerializer.cpp ${CEE_CURRENT_LIST_DIR}RimManagedViewConfig.cpp ${CEE_CURRENT_LIST_DIR}RimManagedViewCollection.cpp ${CEE_CURRENT_LIST_DIR}RimMainPlotCollection.cpp +${CEE_CURRENT_LIST_DIR}RimWellLogPlotCollection.cpp ${CEE_CURRENT_LIST_DIR}RimWellLogPlot.cpp ${CEE_CURRENT_LIST_DIR}RimWellLogPlotTrace.cpp ${CEE_CURRENT_LIST_DIR}RimWellLogPlotCurve.cpp diff --git a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp index 220a672c63..49e5696a05 100644 --- a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp @@ -18,7 +18,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimMainPlotCollection.h" -#include "RimWellLogPlot.h" +#include "RimWellLogPlotCollection.h" #include "RiuMainWindow.h" @@ -36,8 +36,10 @@ RimMainPlotCollection::RimMainPlotCollection() CAF_PDM_InitField(&show, "Show", true, "Show plots", "", "", ""); show.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&wellLogPlots, "WellLogPlots", "", "", "", ""); - wellLogPlots.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&wellLogPlotCollection, "WellLogPlotCollection", "", "", "", ""); + wellLogPlotCollection.uiCapability()->setUiHidden(true); + + wellLogPlotCollection = new RimWellLogPlotCollection(); } //-------------------------------------------------------------------------------------------------- @@ -45,6 +47,7 @@ RimMainPlotCollection::RimMainPlotCollection() //-------------------------------------------------------------------------------------------------- RimMainPlotCollection::~RimMainPlotCollection() { + if (wellLogPlotCollection()) delete wellLogPlotCollection(); } //-------------------------------------------------------------------------------------------------- @@ -61,15 +64,3 @@ caf::PdmFieldHandle* RimMainPlotCollection::objectToggleField() { return &show; } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimMainPlotCollection::addWellLogPlot() -{ - RimWellLogPlot* view = new RimWellLogPlot(); - wellLogPlots.push_back(view); - - RiuMainWindow::instance()->projectTreeView()->setExpanded(this, true); - updateConnectedEditors(); -} diff --git a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h index 2573623ea9..a234633355 100644 --- a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h +++ b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h @@ -21,9 +21,9 @@ #include "cafPdmObject.h" #include "cafPdmField.h" -#include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" -class RimWellLogPlot; +class RimWellLogPlotCollection; //================================================================================================== @@ -37,7 +37,7 @@ public: RimMainPlotCollection(); virtual ~RimMainPlotCollection(); - void addWellLogPlot(); + caf::PdmChildField wellLogPlotCollection; protected: @@ -49,5 +49,4 @@ private: private: caf::PdmField show; - caf::PdmChildArrayField wellLogPlots; }; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 275b5cbf69..77506895e0 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -565,7 +565,11 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu) std::vector uiItems; caf::SelectionManager::instance()->selectedItems(uiItems); - if (uiItems.size() > 1) + if (uiItems.size() == 0) + { + commandIds << "RicNewWellLogPlotFeature"; + } + else if (uiItems.size() > 1) { commandIds << "RicCopyReferencesToClipboardFeature"; } @@ -718,10 +722,6 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu) { commandIds << "RicDeleteItemFeature"; } - else if (dynamic_cast(uiItem)) - { - commandIds << "RicNewWellLogPlotFeature"; - } if (dynamic_cast(uiItem)) { diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 6b880dbb29..4960ee7b28 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -59,10 +59,11 @@ public: RimProject(void); virtual ~RimProject(void); - caf::PdmChildArrayField oilFields; - caf::PdmChildField scriptCollection; - caf::PdmChildField wellPathImport; - caf::PdmChildArrayField commandObjects; + caf::PdmChildArrayField oilFields; + caf::PdmChildField scriptCollection; + caf::PdmChildField wellPathImport; + caf::PdmChildField mainPlotCollection; + caf::PdmChildArrayField commandObjects; caf::PdmField treeViewState; caf::PdmField currentModelIndexPath; @@ -104,6 +105,4 @@ private: caf::PdmChildArrayField casesObsolete; // obsolete caf::PdmChildArrayField caseGroupsObsolete; // obsolete - - caf::PdmChildField mainPlotCollection; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp new file mode 100644 index 0000000000..de02f0f187 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "RimWellLogPlotCollection.h" +#include "RimWellLogPlot.h" + +#include "RiuMainWindow.h" + +#include "cafPdmUiTreeView.h" + +CAF_PDM_SOURCE_INIT(RimWellLogPlotCollection, "WellLogPlotCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogPlotCollection::RimWellLogPlotCollection() +{ + CAF_PDM_InitObject("Well Log Plots", "", "", ""); + + CAF_PDM_InitField(&show, "Show", true, "Show plots", "", "", ""); + show.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&wellLogPlots, "WellLogPlots", "", "", "", ""); + wellLogPlots.uiCapability()->setUiHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogPlotCollection::~RimWellLogPlotCollection() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlotCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimWellLogPlotCollection::objectToggleField() +{ + return &show; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlotCollection::addWellLogPlot() +{ + RimWellLogPlot* view = new RimWellLogPlot(); + wellLogPlots.push_back(view); + + RiuMainWindow::instance()->projectTreeView()->setExpanded(this, true); + updateConnectedEditors(); +} diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.h b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.h new file mode 100644 index 0000000000..876f131a77 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.h @@ -0,0 +1,53 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 "cafPdmObject.h" +#include "cafPdmField.h" +#include "cafPdmChildArrayField.h" + +class RimWellLogPlot; + + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLogPlotCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimWellLogPlotCollection(); + virtual ~RimWellLogPlotCollection(); + + void addWellLogPlot(); + +protected: + + // Overridden PDM methods + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + +private: + virtual caf::PdmFieldHandle* objectToggleField(); + +private: + caf::PdmField show; + caf::PdmChildArrayField wellLogPlots; +};