2020-09-22 08:53:17 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2020- 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-11-04 06:46:17 -06:00
|
|
|
#include "RimStimPlanModelTemplateCollection.h"
|
2020-09-22 08:53:17 -05:00
|
|
|
|
|
|
|
#include "RimCase.h"
|
|
|
|
#include "RimEclipseCase.h"
|
|
|
|
#include "RimEclipseView.h"
|
|
|
|
#include "RimFracture.h"
|
|
|
|
#include "RimProject.h"
|
2020-11-04 06:46:17 -06:00
|
|
|
#include "RimStimPlanModelTemplate.h"
|
2020-09-22 08:53:17 -05:00
|
|
|
|
2020-09-25 12:13:37 -05:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2020-09-22 08:53:17 -05:00
|
|
|
#include "cafPdmObject.h"
|
2020-09-25 12:13:37 -05:00
|
|
|
#include "cafPdmObjectScriptingCapability.h"
|
2020-09-22 08:53:17 -05:00
|
|
|
|
2020-11-04 06:46:17 -06:00
|
|
|
CAF_PDM_SOURCE_INIT( RimStimPlanModelTemplateCollection, "StimPlanModelTemplateCollection" );
|
2020-09-22 08:53:17 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-11-04 06:46:17 -06:00
|
|
|
RimStimPlanModelTemplateCollection::RimStimPlanModelTemplateCollection()
|
2020-09-22 08:53:17 -05:00
|
|
|
{
|
2022-01-07 01:31:52 -06:00
|
|
|
CAF_PDM_InitScriptableObject( "StimPlan Model Templates", ":/FractureTemplates16x16.png" );
|
2020-09-22 08:53:17 -05:00
|
|
|
|
2022-01-07 01:31:52 -06:00
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanModelTemplates, "StimPlanModelTemplates", "StimPlan Model Templates" );
|
2020-09-22 08:53:17 -05:00
|
|
|
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitField( &m_nextValidId, "NextValidId", 0, "" );
|
2020-09-22 08:53:17 -05:00
|
|
|
m_nextValidId.uiCapability()->setUiHidden( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-11-04 06:46:17 -06:00
|
|
|
RimStimPlanModelTemplate* RimStimPlanModelTemplateCollection::stimPlanModelTemplate( int id ) const
|
2020-09-22 08:53:17 -05:00
|
|
|
{
|
2020-11-04 06:46:17 -06:00
|
|
|
for ( const auto& templ : m_stimPlanModelTemplates )
|
2020-09-22 08:53:17 -05:00
|
|
|
{
|
|
|
|
if ( templ->id() == id ) return templ;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-11-04 06:46:17 -06:00
|
|
|
std::vector<RimStimPlanModelTemplate*> RimStimPlanModelTemplateCollection::stimPlanModelTemplates() const
|
2020-09-22 08:53:17 -05:00
|
|
|
{
|
2020-11-04 06:46:17 -06:00
|
|
|
std::vector<RimStimPlanModelTemplate*> templates;
|
|
|
|
for ( auto& templ : m_stimPlanModelTemplates )
|
2020-09-22 08:53:17 -05:00
|
|
|
{
|
|
|
|
templates.push_back( templ );
|
|
|
|
}
|
|
|
|
return templates;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-11-04 06:46:17 -06:00
|
|
|
void RimStimPlanModelTemplateCollection::addStimPlanModelTemplate( RimStimPlanModelTemplate* templ )
|
2020-09-22 08:53:17 -05:00
|
|
|
{
|
|
|
|
templ->setId( nextFractureTemplateId() );
|
2020-11-04 06:46:17 -06:00
|
|
|
m_stimPlanModelTemplates.push_back( templ );
|
2020-09-22 08:53:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-11-04 06:46:17 -06:00
|
|
|
void RimStimPlanModelTemplateCollection::loadAndUpdateData()
|
2020-09-22 08:53:17 -05:00
|
|
|
{
|
2020-11-04 06:46:17 -06:00
|
|
|
for ( RimStimPlanModelTemplate* f : m_stimPlanModelTemplates() )
|
2020-09-22 08:53:17 -05:00
|
|
|
{
|
|
|
|
f->loadDataAndUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-11-04 06:46:17 -06:00
|
|
|
void RimStimPlanModelTemplateCollection::initAfterRead()
|
2020-09-22 08:53:17 -05:00
|
|
|
{
|
|
|
|
// Assign template id if not already assigned
|
2020-11-04 06:46:17 -06:00
|
|
|
for ( auto& templ : m_stimPlanModelTemplates )
|
2020-09-22 08:53:17 -05:00
|
|
|
{
|
|
|
|
if ( templ->id() < 0 ) templ->setId( nextFractureTemplateId() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-11-04 06:46:17 -06:00
|
|
|
int RimStimPlanModelTemplateCollection::nextFractureTemplateId()
|
2020-09-22 08:53:17 -05:00
|
|
|
{
|
|
|
|
int newId = m_nextValidId;
|
|
|
|
m_nextValidId = m_nextValidId + 1;
|
|
|
|
|
|
|
|
return newId;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-11-04 06:46:17 -06:00
|
|
|
void RimStimPlanModelTemplateCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
|
2020-09-22 08:53:17 -05:00
|
|
|
std::vector<caf::PdmObjectHandle*>& referringObjects )
|
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
RimProject* proj = RimProject::current();
|
2020-09-22 08:53:17 -05:00
|
|
|
if ( proj )
|
|
|
|
{
|
|
|
|
proj->scheduleCreateDisplayModelAndRedrawAllViews();
|
|
|
|
}
|
|
|
|
|
2024-04-03 07:53:20 -05:00
|
|
|
std::vector<Rim3dView*> views = proj->allVisibleViews();
|
2020-09-22 08:53:17 -05:00
|
|
|
for ( Rim3dView* visibleView : views )
|
|
|
|
{
|
|
|
|
if ( dynamic_cast<RimEclipseView*>( visibleView ) )
|
|
|
|
{
|
|
|
|
visibleView->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|