#4016 Observed Data : Add feature to reload summary Observed Data

This commit is contained in:
Magne Sjaastad
2019-04-05 10:46:44 +02:00
parent 26f89f6e35
commit 7d242bffb5
2 changed files with 34 additions and 32 deletions

View File

@@ -1,17 +1,17 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2017- Statoil ASA // Copyright (C) 2017- Statoil ASA
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@@ -23,6 +23,8 @@
#include "RiaSummaryTools.h" #include "RiaSummaryTools.h"
#include "RimMainPlotCollection.h" #include "RimMainPlotCollection.h"
#include "RimObservedData.h"
#include "RimObservedDataCollection.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimSummaryCase.h" #include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseCollection.h"
@@ -38,30 +40,17 @@
CAF_CMD_SOURCE_INIT(RicReloadSummaryCaseFeature, "RicReloadSummaryCaseFeature"); CAF_CMD_SOURCE_INIT(RicReloadSummaryCaseFeature, "RicReloadSummaryCaseFeature");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicReloadSummaryCaseFeature::isCommandEnabled() bool RicReloadSummaryCaseFeature::isCommandEnabled()
{ {
std::vector<RimSummaryCase*> caseSelection = selectedSummaryCases(); std::vector<RimSummaryCase*> caseSelection = selectedSummaryCases();
if (caseSelection.size() == 0) return !caseSelection.empty();
{
return false;
}
for (RimSummaryCase* summaryCase : caseSelection)
{
if (summaryCase->isObservedData())
{
return false;
}
}
return true;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicReloadSummaryCaseFeature::onActionTriggered(bool isChecked) void RicReloadSummaryCaseFeature::onActionTriggered(bool isChecked)
{ {
@@ -82,7 +71,7 @@ void RicReloadSummaryCaseFeature::onActionTriggered(bool isChecked)
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicReloadSummaryCaseFeature::setupActionLook(QAction* actionToSetup) void RicReloadSummaryCaseFeature::setupActionLook(QAction* actionToSetup)
{ {
@@ -91,7 +80,7 @@ void RicReloadSummaryCaseFeature::setupActionLook(QAction* actionToSetup)
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RimSummaryCase*> RicReloadSummaryCaseFeature::selectedSummaryCases() std::vector<RimSummaryCase*> RicReloadSummaryCaseFeature::selectedSummaryCases()
{ {
@@ -106,13 +95,26 @@ std::vector<RimSummaryCase*> RicReloadSummaryCaseFeature::selectedSummaryCases()
std::vector<RimSummaryCase*> caseSelection; std::vector<RimSummaryCase*> caseSelection;
caf::SelectionManager::instance()->objectsByType(&caseSelection); caf::SelectionManager::instance()->objectsByType(&caseSelection);
std::vector<RimSummaryCaseCollection*> collectionSelection;
caf::SelectionManager::instance()->objectsByType(&collectionSelection);
for (auto collection : collectionSelection)
{ {
std::vector<RimSummaryCase*> summaryCaseCollection = collection->allSummaryCases(); std::vector<RimSummaryCaseCollection*> collectionSelection;
caseSelection.insert(caseSelection.end(), summaryCaseCollection.begin(), summaryCaseCollection.end()); caf::SelectionManager::instance()->objectsByType(&collectionSelection);
for (auto collection : collectionSelection)
{
std::vector<RimSummaryCase*> summaryCaseCollection = collection->allSummaryCases();
caseSelection.insert(caseSelection.end(), summaryCaseCollection.begin(), summaryCaseCollection.end());
}
}
{
std::vector<RimObservedDataCollection*> collectionSelection;
caf::SelectionManager::instance()->objectsByType(&collectionSelection);
for (auto collection : collectionSelection)
{
std::vector<RimObservedData*> observedCases = collection->allObservedData();
caseSelection.insert(caseSelection.end(), observedCases.begin(), observedCases.end());
}
} }
return caseSelection; return caseSelection;

View File

@@ -1,17 +1,17 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2017- Statoil ASA // Copyright (C) 2017- Statoil ASA
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////