2023-07-07 10:58:33 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2023- Equinor 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 "RimcIdenticalGridCaseGroup.h"
|
|
|
|
|
|
|
|
|
|
#include "RimEclipseStatisticsCase.h"
|
|
|
|
|
#include "RimIdenticalGridCaseGroup.h"
|
2026-09-16 17:20:17 +02:00
|
|
|
#include "RimProject.h"
|
2023-07-07 10:58:33 +02:00
|
|
|
|
|
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
|
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimIdenticalGridCaseGroup, RimcIdenticalGridCaseGroup_createStatisticsCase, "create_statistics_case" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimcIdenticalGridCaseGroup_createStatisticsCase::RimcIdenticalGridCaseGroup_createStatisticsCase( caf::PdmObjectHandle* self )
|
2025-06-16 11:05:00 +02:00
|
|
|
: caf::PdmObjectCreationMethod( self )
|
|
|
|
|
|
2023-07-07 10:58:33 +02:00
|
|
|
{
|
2026-09-16 17:20:17 +02:00
|
|
|
CAF_PDM_InitObject( "Create Statistics Case", "", "", "Create a new statistics case in the grid case group" );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_populateResultSelection,
|
|
|
|
|
"PopulateResultSelection",
|
|
|
|
|
false,
|
|
|
|
|
"Populate Result Selection",
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
"Select all available source properties for statistics. When false, no properties are selected "
|
|
|
|
|
"and set_source_properties() must be called before compute_statistics()." );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimcIdenticalGridCaseGroup_createStatisticsCase::setPopulateResultSelection( bool populate )
|
|
|
|
|
{
|
|
|
|
|
m_populateResultSelection = populate;
|
2023-07-07 10:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-05-07 11:34:59 +02:00
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimcIdenticalGridCaseGroup_createStatisticsCase::execute()
|
2023-07-07 10:58:33 +02:00
|
|
|
{
|
|
|
|
|
auto gridCaseGroup = self<RimIdenticalGridCaseGroup>();
|
2026-09-16 17:20:17 +02:00
|
|
|
if ( !gridCaseGroup ) return std::unexpected( "No grid case group is available." );
|
|
|
|
|
|
|
|
|
|
RimEclipseStatisticsCase* statCase = m_populateResultSelection() ? gridCaseGroup->createAndAppendStatisticsCase()
|
|
|
|
|
: gridCaseGroup->createAndAppendEmptyStatisticsCase();
|
|
|
|
|
if ( !statCase ) return std::unexpected( "Could not create statistics case." );
|
2023-07-07 10:58:33 +02:00
|
|
|
|
2026-09-16 17:20:17 +02:00
|
|
|
RimProject::current()->assignCaseIdToCase( statCase );
|
2023-07-07 10:58:33 +02:00
|
|
|
gridCaseGroup->updateConnectedEditors();
|
|
|
|
|
|
|
|
|
|
return statCase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-06-16 11:05:00 +02:00
|
|
|
QString RimcIdenticalGridCaseGroup_createStatisticsCase::classKeywordReturnedType() const
|
2023-07-07 10:58:33 +02:00
|
|
|
{
|
2025-06-16 11:05:00 +02:00
|
|
|
return RimEclipseStatisticsCase::classKeywordStatic();
|
2023-07-07 10:58:33 +02:00
|
|
|
}
|