2019-07-19 06:54:15 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- 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 "RicfCreateStatisticsCase.h"
|
|
|
|
|
|
|
|
#include "RimCaseCollection.h"
|
|
|
|
#include "RimEclipseStatisticsCase.h"
|
|
|
|
#include "RimEclipseStatisticsCaseCollection.h"
|
|
|
|
#include "RimIdenticalGridCaseGroup.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
|
|
|
|
#include "Riu3DMainWindowTools.h"
|
|
|
|
|
2020-08-21 04:13:07 -05:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2019-07-19 06:54:15 -05:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfCreateStatisticsCaseResult, "createStatisticsCaseResult" );
|
2019-07-19 06:54:15 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RicfCreateStatisticsCaseResult::RicfCreateStatisticsCaseResult( int caseId /*= -1*/ )
|
2019-07-19 06:54:15 -05:00
|
|
|
{
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitObject( "statistics_case_result" );
|
|
|
|
CAF_PDM_InitField( &this->caseId, "caseId", caseId, "" );
|
2019-07-19 06:54:15 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfCreateStatisticsCase, "createStatisticsCase" );
|
2019-07-19 06:54:15 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicfCreateStatisticsCase::RicfCreateStatisticsCase()
|
|
|
|
{
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitScriptableField( &m_caseGroupId, "caseGroupId", -1, "Case Group Id" );
|
2019-07-19 06:54:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 08:11:22 -05:00
|
|
|
caf::PdmScriptResponse RicfCreateStatisticsCase::execute()
|
2019-07-19 06:54:15 -05:00
|
|
|
{
|
2020-05-12 02:50:38 -05:00
|
|
|
RimProject* project = RimProject::current();
|
2019-07-19 06:54:15 -05:00
|
|
|
|
|
|
|
std::vector<RimIdenticalGridCaseGroup*> gridCaseGroups;
|
2019-09-06 03:40:57 -05:00
|
|
|
project->descendantsIncludingThisOfType( gridCaseGroups );
|
|
|
|
for ( auto gridCaseGroup : gridCaseGroups )
|
2019-07-19 06:54:15 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( gridCaseGroup->groupId() == m_caseGroupId() )
|
2019-07-19 06:54:15 -05:00
|
|
|
{
|
|
|
|
RimEclipseStatisticsCase* createdObject = gridCaseGroup->createAndAppendStatisticsCase();
|
2019-09-06 03:40:57 -05:00
|
|
|
project->assignCaseIdToCase( createdObject );
|
2019-07-19 06:54:15 -05:00
|
|
|
gridCaseGroup->updateConnectedEditors();
|
2020-03-10 08:11:22 -05:00
|
|
|
caf::PdmScriptResponse response;
|
2019-09-06 03:40:57 -05:00
|
|
|
response.setResult( new RicfCreateStatisticsCaseResult( createdObject->caseId() ) );
|
2019-07-19 06:54:15 -05:00
|
|
|
return response;
|
|
|
|
}
|
|
|
|
}
|
2020-03-10 08:11:22 -05:00
|
|
|
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, "Could not find grid case group" );
|
2019-07-19 06:54:15 -05:00
|
|
|
}
|