2019-04-09 05:43:15 -05:00
|
|
|
#include "RicfCreateSaturationPressurePlots.h"
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 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 <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicfCreateSaturationPressurePlots.h"
|
|
|
|
|
|
|
|
#include "GridCrossPlotCommands/RicCreateSaturationPressurePlotsFeature.h"
|
|
|
|
|
2019-05-06 03:36:05 -05:00
|
|
|
#include "RiaGuiApplication.h"
|
2019-04-09 05:43:15 -05:00
|
|
|
#include "RiaLogging.h"
|
|
|
|
|
|
|
|
#include "RimEclipseResultCase.h"
|
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimSaturationPressurePlotCollection.h"
|
|
|
|
|
2020-08-21 04:13:07 -05:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2020-03-10 08:11:22 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfCreateSaturationPressurePlots, "createSaturationPressurePlots" );
|
2019-04-09 05:43:15 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicfCreateSaturationPressurePlots::RicfCreateSaturationPressurePlots()
|
|
|
|
{
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitScriptableField( &m_caseIds, "caseIds", std::vector<int>(), "Case IDs" );
|
2019-04-09 05:43:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 08:11:22 -05:00
|
|
|
caf::PdmScriptResponse RicfCreateSaturationPressurePlots::execute()
|
2019-04-09 05:43:15 -05:00
|
|
|
{
|
|
|
|
std::vector<int> caseIds = m_caseIds();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( caseIds.empty() )
|
2019-04-09 05:43:15 -05:00
|
|
|
{
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject* project = RimProject::current();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( project )
|
2019-04-09 05:43:15 -05:00
|
|
|
{
|
|
|
|
auto eclipeCases = project->eclipseCases();
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto c : eclipeCases )
|
2019-04-09 05:43:15 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caseIds.push_back( c->caseId() );
|
2019-04-09 05:43:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( caseIds.empty() )
|
2019-05-23 06:59:19 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString error( "createSaturationPressurePlots: No cases found" );
|
|
|
|
RiaLogging::error( error );
|
2020-03-10 08:11:22 -05:00
|
|
|
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error );
|
2019-05-23 06:59:19 -05:00
|
|
|
}
|
|
|
|
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject* project = RimProject::current();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !project )
|
2019-04-09 05:43:15 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString error( "No project loaded" );
|
|
|
|
RiaLogging::error( error );
|
2020-03-10 08:11:22 -05:00
|
|
|
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error );
|
2019-05-23 06:59:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
auto eclipeCases = project->eclipseCases();
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto c : eclipeCases )
|
2019-05-23 06:59:19 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto eclipseResultCase = dynamic_cast<RimEclipseResultCase*>( c );
|
|
|
|
if ( !eclipseResultCase ) continue;
|
2019-04-09 05:43:15 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto caseId : caseIds )
|
2019-05-23 06:59:19 -05:00
|
|
|
{
|
2022-08-18 00:12:23 -05:00
|
|
|
if ( c->caseId() == caseId )
|
2019-04-09 05:43:15 -05:00
|
|
|
{
|
2020-02-28 04:40:23 -06:00
|
|
|
int timeStep = 0;
|
|
|
|
RicCreateSaturationPressurePlotsFeature::createPlots( eclipseResultCase, timeStep );
|
2019-04-09 05:43:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-19 07:30:25 -05:00
|
|
|
RimSaturationPressurePlotCollection* collection = RimMainPlotCollection::current()->saturationPressurePlotCollection();
|
2019-04-09 05:43:15 -05:00
|
|
|
collection->updateAllRequiredEditors();
|
2019-05-06 03:36:05 -05:00
|
|
|
RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow();
|
2019-05-23 06:59:19 -05:00
|
|
|
|
2020-03-10 08:11:22 -05:00
|
|
|
return caf::PdmScriptResponse();
|
2019-04-09 05:43:15 -05:00
|
|
|
}
|