2018-10-23 09:32:40 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2019-01-09 05:48:56 -06:00
|
|
|
//
|
2018-10-23 09:32:40 -05:00
|
|
|
// 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.
|
2019-01-09 05:48:56 -06:00
|
|
|
//
|
2018-10-23 09:32:40 -05:00
|
|
|
// 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.
|
2019-01-09 05:48:56 -06:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-10-23 09:32:40 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-11-09 02:04:40 -06:00
|
|
|
#include "RicNewContourMapViewFeature.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
|
2020-09-25 05:18:15 -05:00
|
|
|
#include "RigActiveCellInfo.h"
|
|
|
|
#include "RigEclipseCaseData.h"
|
2021-10-09 07:15:25 -05:00
|
|
|
#include "RigFemPartCollection.h"
|
2020-09-25 05:18:15 -05:00
|
|
|
|
2024-04-24 00:48:49 -05:00
|
|
|
#include "Polygons/RimPolygonInView.h"
|
2019-01-09 05:48:42 -06:00
|
|
|
#include "Rim3dView.h"
|
|
|
|
#include "RimCellEdgeColors.h"
|
2024-03-15 03:32:45 -05:00
|
|
|
#include "RimCellFilterCollection.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
#include "RimEclipseCase.h"
|
2018-11-08 09:18:03 -06:00
|
|
|
#include "RimEclipseCellColors.h"
|
2020-09-25 05:18:15 -05:00
|
|
|
#include "RimEclipseContourMapProjection.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimEclipseContourMapView.h"
|
|
|
|
#include "RimEclipseContourMapViewCollection.h"
|
2019-01-09 05:48:42 -06:00
|
|
|
#include "RimEclipseView.h"
|
2024-03-15 03:32:45 -05:00
|
|
|
#include "RimFaultInViewCollection.h"
|
2019-01-16 03:51:43 -06:00
|
|
|
#include "RimGeoMechCase.h"
|
|
|
|
#include "RimGeoMechCellColors.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimGeoMechContourMapView.h"
|
|
|
|
#include "RimGeoMechContourMapViewCollection.h"
|
2019-01-16 03:51:43 -06:00
|
|
|
#include "RimGeoMechView.h"
|
2024-04-25 03:00:25 -05:00
|
|
|
#include "RimOilField.h"
|
2024-04-24 00:48:49 -05:00
|
|
|
#include "RimPolygonFilter.h"
|
2024-04-25 03:00:25 -05:00
|
|
|
#include "RimProject.h"
|
2020-07-27 07:43:33 -05:00
|
|
|
#include "RimRegularLegendConfig.h"
|
2019-01-09 05:48:42 -06:00
|
|
|
#include "RimSimWellInViewCollection.h"
|
2020-08-05 07:07:14 -05:00
|
|
|
#include "RimSurfaceInViewCollection.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
|
|
|
|
#include "Riu3DMainWindowTools.h"
|
2020-09-30 01:32:20 -05:00
|
|
|
#include "RiuGuiTheme.h"
|
2018-11-08 09:18:03 -06:00
|
|
|
|
2020-09-30 01:32:20 -05:00
|
|
|
#include "RiaColorTools.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
#include "RiaLogging.h"
|
2024-07-04 05:38:41 -05:00
|
|
|
#include "RiaPreferencesGrid.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
|
2018-11-08 09:18:03 -06:00
|
|
|
#include "cafPdmDocument.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicNewContourMapViewFeature, "RicNewContourMapViewFeature" );
|
2018-10-23 09:32:40 -05:00
|
|
|
|
2020-09-25 05:53:03 -05:00
|
|
|
const size_t mediumSamplingThresholdCellCount = 500000u;
|
|
|
|
const size_t largeSamplingThresholdCellCount = 5000000u;
|
2020-09-25 05:18:15 -05:00
|
|
|
|
2018-10-23 09:32:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-09 05:48:56 -06:00
|
|
|
///
|
2018-10-23 09:32:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-06-26 07:28:46 -05:00
|
|
|
bool RicNewContourMapViewFeature::isCommandEnabled() const
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
bool selectedView = caf::SelectionManager::instance()->selectedItemOfType<RimGridView>() != nullptr;
|
|
|
|
bool selectedCase = caf::SelectionManager::instance()->selectedItemOfType<RimCase>() != nullptr;
|
2021-10-09 07:15:25 -05:00
|
|
|
|
|
|
|
RimGeoMechView* gmView = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechView>();
|
2024-01-05 03:21:06 -06:00
|
|
|
if ( gmView && gmView->femParts() )
|
2021-10-09 07:15:25 -05:00
|
|
|
{
|
|
|
|
// if we have more than one geomech part, contour maps does not work with the current implementation
|
|
|
|
if ( gmView->femParts()->partCount() > 1 ) return false;
|
|
|
|
}
|
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
bool selectedEclipseContourMapCollection = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapViewCollection>();
|
|
|
|
bool selectedGeoMechContourMapCollection = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechContourMapViewCollection>();
|
2019-01-16 03:51:43 -06:00
|
|
|
return selectedView || selectedCase || selectedEclipseContourMapCollection || selectedGeoMechContourMapCollection;
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-09 05:48:56 -06:00
|
|
|
///
|
2018-10-23 09:32:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicNewContourMapViewFeature::onActionTriggered( bool isChecked )
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
RimEclipseView* reservoirView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
|
|
|
|
RimEclipseContourMapView* existingEclipseContourMap = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>();
|
2024-03-15 03:32:45 -05:00
|
|
|
RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCase>();
|
2023-02-26 03:48:40 -06:00
|
|
|
RimEclipseContourMapView* eclipseContourMap = nullptr;
|
|
|
|
|
|
|
|
RimGeoMechView* geoMechView = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechView>();
|
|
|
|
RimGeoMechContourMapView* existingGeoMechContourMap = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechContourMapView>();
|
|
|
|
RimGeoMechCase* geoMechCase = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimGeoMechCase>();
|
|
|
|
RimGeoMechContourMapView* geoMechContourMap = nullptr;
|
2018-10-23 09:32:40 -05:00
|
|
|
|
|
|
|
// Find case to insert into
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( existingEclipseContourMap )
|
2018-11-09 04:44:03 -06:00
|
|
|
{
|
2024-03-15 03:32:45 -05:00
|
|
|
eclipseCase = existingEclipseContourMap->eclipseCase();
|
|
|
|
if ( eclipseCase )
|
|
|
|
{
|
|
|
|
eclipseContourMap = createEclipseContourMapFromExistingContourMap( eclipseCase, existingEclipseContourMap );
|
|
|
|
}
|
2018-11-09 04:44:03 -06:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( reservoirView )
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2024-03-15 03:32:45 -05:00
|
|
|
eclipseCase = reservoirView->eclipseCase();
|
|
|
|
if ( eclipseCase )
|
|
|
|
{
|
|
|
|
eclipseContourMap = createEclipseContourMapFrom3dView( eclipseCase, reservoirView );
|
|
|
|
}
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( eclipseCase )
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
eclipseContourMap = createEclipseContourMap( eclipseCase );
|
2019-01-16 03:51:43 -06:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( existingGeoMechContourMap )
|
2019-01-16 03:51:43 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
geoMechContourMap = createGeoMechContourMapFromExistingContourMap( geoMechCase, existingGeoMechContourMap );
|
2019-01-16 03:51:43 -06:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( geoMechView )
|
2019-01-16 03:51:43 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
geoMechContourMap = createGeoMechContourMapFrom3dView( geoMechCase, geoMechView );
|
2019-01-16 03:51:43 -06:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( geoMechCase )
|
2019-01-16 03:51:43 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
geoMechContourMap = createGeoMechContourMap( geoMechCase );
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( eclipseContourMap )
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
|
|
|
// Must be run before buildViewItems, as wells are created in this function
|
2019-01-16 03:51:43 -06:00
|
|
|
eclipseContourMap->loadDataAndUpdate();
|
2018-10-23 09:32:40 -05:00
|
|
|
|
2021-01-19 07:59:06 -06:00
|
|
|
// make sure no surfaces are shown in the view when the contourmap is generated
|
2023-02-26 03:48:40 -06:00
|
|
|
if ( eclipseContourMap->surfaceInViewCollection() ) eclipseContourMap->surfaceInViewCollection()->setCheckState( Qt::Unchecked );
|
2021-01-19 07:59:06 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( eclipseCase )
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
|
|
|
eclipseCase->updateConnectedEditors();
|
2021-01-26 06:08:21 -06:00
|
|
|
eclipseContourMap->cellFilterCollection()->setCase( eclipseCase );
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->setSelectedItem( eclipseContourMap );
|
2018-11-09 04:44:03 -06:00
|
|
|
|
2019-01-16 03:51:43 -06:00
|
|
|
eclipseContourMap->createDisplayModelAndRedraw();
|
|
|
|
eclipseContourMap->zoomAll();
|
2018-11-09 04:44:03 -06:00
|
|
|
|
2024-03-15 03:32:45 -05:00
|
|
|
RimProject* project = RimProject::current();
|
|
|
|
|
|
|
|
RimOilField* oilField = project->activeOilField();
|
|
|
|
|
|
|
|
oilField->eclipseContourMapCollection()->updateConnectedEditors();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
Riu3DMainWindowTools::setExpanded( eclipseContourMap );
|
2024-06-06 06:35:27 -05:00
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem( eclipseContourMap );
|
2019-01-16 03:51:43 -06:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( geoMechContourMap )
|
2019-01-16 03:51:43 -06:00
|
|
|
{
|
|
|
|
geoMechContourMap->loadDataAndUpdate();
|
2021-01-19 07:59:06 -06:00
|
|
|
// make sure no surfaces are shown in the view when the contourmap is generated
|
2023-02-26 03:48:40 -06:00
|
|
|
if ( geoMechContourMap->surfaceInViewCollection() ) geoMechContourMap->surfaceInViewCollection()->setCheckState( Qt::Unchecked );
|
2021-01-19 07:59:06 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( geoMechCase )
|
2019-01-16 03:51:43 -06:00
|
|
|
{
|
|
|
|
geoMechCase->updateConnectedEditors();
|
2021-04-05 11:18:34 -05:00
|
|
|
geoMechContourMap->cellFilterCollection()->setCase( geoMechCase );
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->setSelectedItem( geoMechContourMap );
|
2019-01-16 03:51:43 -06:00
|
|
|
geoMechContourMap->createDisplayModelAndRedraw();
|
|
|
|
geoMechContourMap->zoomAll();
|
2019-09-06 03:40:57 -05:00
|
|
|
Riu3DMainWindowTools::setExpanded( geoMechContourMap );
|
2024-06-06 06:35:27 -05:00
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem( geoMechContourMap );
|
2019-01-16 03:51:43 -06:00
|
|
|
}
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-09 05:48:56 -06:00
|
|
|
///
|
2018-10-23 09:32:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicNewContourMapViewFeature::setupActionLook( QAction* actionToSetup )
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
bool contourMapSelected = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>() != nullptr ||
|
|
|
|
caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechContourMapView>() != nullptr;
|
2019-01-16 03:51:43 -06:00
|
|
|
|
|
|
|
bool viewSelected = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>() != nullptr ||
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechView>() != nullptr;
|
2019-01-16 03:51:43 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( contourMapSelected )
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Duplicate Contour Map" );
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( viewSelected )
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "New Contour Map From 3d View" );
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "New Contour Map" );
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/2DMap16x16.png" ) );
|
2019-01-09 05:48:56 -06:00
|
|
|
}
|
2018-11-08 09:18:03 -06:00
|
|
|
|
2018-11-09 04:44:03 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:43:15 -06:00
|
|
|
RimEclipseContourMapView*
|
|
|
|
RicNewContourMapViewFeature::createEclipseContourMapFromExistingContourMap( RimEclipseCase* eclipseCase,
|
|
|
|
RimEclipseContourMapView* existingContourMap )
|
2018-11-09 04:44:03 -06:00
|
|
|
{
|
2024-06-14 10:18:28 -05:00
|
|
|
auto contourMap = existingContourMap->copyObject<RimEclipseContourMapView>();
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( contourMap );
|
|
|
|
contourMap->setEclipseCase( eclipseCase );
|
2020-09-30 01:32:20 -05:00
|
|
|
|
2020-10-02 04:12:25 -05:00
|
|
|
auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" );
|
2020-09-30 01:32:20 -05:00
|
|
|
contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background
|
2018-11-09 04:44:03 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmDocument::updateUiIconStateRecursively( contourMap );
|
2018-11-09 04:44:03 -06:00
|
|
|
|
|
|
|
size_t i = eclipseCase->contourMapCollection()->views().size();
|
2019-09-06 03:40:57 -05:00
|
|
|
contourMap->setName( QString( "Contour Map %1" ).arg( i + 1 ) );
|
2024-04-17 06:46:31 -05:00
|
|
|
eclipseCase->contourMapCollection()->addView( contourMap );
|
2018-11-09 04:44:03 -06:00
|
|
|
|
|
|
|
// Resolve references after contour map has been inserted into Rim structures
|
|
|
|
contourMap->resolveReferencesRecursively();
|
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
|
|
|
return contourMap;
|
|
|
|
}
|
|
|
|
|
2018-11-08 09:18:03 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFrom3dView( RimEclipseCase* eclipseCase,
|
2019-09-06 03:40:57 -05:00
|
|
|
const RimEclipseView* sourceView )
|
2018-11-08 09:18:03 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimEclipseContourMapView* contourMap = dynamic_cast<RimEclipseContourMapView*>(
|
|
|
|
sourceView->xmlCapability()->copyAndCastByXmlSerialization( RimEclipseContourMapView::classKeywordStatic(),
|
|
|
|
sourceView->classKeyword(),
|
|
|
|
caf::PdmDefaultObjectFactory::instance() ) );
|
|
|
|
CVF_ASSERT( contourMap );
|
2018-11-08 09:18:03 -06:00
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
const RigActiveCellInfo* activeCellInfo = eclipseCase->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
|
|
|
size_t activeCellCount = activeCellInfo->reservoirActiveCellCount();
|
2020-09-25 05:53:03 -05:00
|
|
|
if ( activeCellCount >= largeSamplingThresholdCellCount )
|
|
|
|
{
|
|
|
|
contourMap->contourMapProjection()->setSampleSpacingFactor( 1.5 );
|
|
|
|
}
|
|
|
|
else if ( activeCellCount >= mediumSamplingThresholdCellCount )
|
2020-09-25 05:18:15 -05:00
|
|
|
{
|
|
|
|
contourMap->contourMapProjection()->setSampleSpacingFactor( 1.2 );
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
contourMap->setEclipseCase( eclipseCase );
|
2020-09-30 01:32:20 -05:00
|
|
|
|
2020-10-02 04:12:25 -05:00
|
|
|
auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" );
|
2020-09-30 01:32:20 -05:00
|
|
|
contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background
|
|
|
|
|
2018-12-14 06:41:35 -06:00
|
|
|
contourMap->setDefaultCustomName();
|
2023-06-05 00:33:04 -05:00
|
|
|
contourMap->faultCollection()->setActive( false );
|
|
|
|
contourMap->wellCollection()->isActive = false;
|
2018-11-08 09:18:03 -06:00
|
|
|
|
2020-08-05 09:14:25 -05:00
|
|
|
// Set default values
|
|
|
|
RimRegularLegendConfig* legendConfig = contourMap->cellResult()->legendConfig();
|
2020-08-14 03:41:01 -05:00
|
|
|
if ( legendConfig && legendConfig->mappingMode() == RimRegularLegendConfig::MappingType::CATEGORY_INTEGER )
|
2020-08-05 09:14:25 -05:00
|
|
|
{
|
|
|
|
RicNewContourMapViewFeature::assignDefaultResultAndLegend( contourMap );
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmDocument::updateUiIconStateRecursively( contourMap );
|
2018-11-08 09:18:03 -06:00
|
|
|
|
2024-04-17 06:46:31 -05:00
|
|
|
eclipseCase->contourMapCollection()->addView( contourMap );
|
2018-11-08 09:18:03 -06:00
|
|
|
|
2024-04-04 02:16:57 -05:00
|
|
|
contourMap->synchronizeLocalAnnotationsFromGlobal();
|
2018-12-04 07:33:14 -06:00
|
|
|
|
2018-11-08 09:18:03 -06:00
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
2024-03-15 03:32:45 -05:00
|
|
|
eclipseCase->contourMapCollection()->updateConnectedEditors();
|
|
|
|
|
2024-04-24 00:48:49 -05:00
|
|
|
// Polygon cell filters are not working due to different organization of the project tree for Eclipse view and contour map view
|
|
|
|
// Manually assign pointers to polygon objects
|
|
|
|
//
|
|
|
|
// TODO: Find a more robust solution, perhaps introduce a root token making it possible to have a reference string pointing to objects
|
|
|
|
// relative root "$root$ PolygonCollection 0 Polygon 2"
|
|
|
|
// Make sure this concept works for geomech contour maps
|
|
|
|
|
|
|
|
auto sourceFilters = sourceView->cellFilterCollection()->filters();
|
|
|
|
auto destinationFilters = contourMap->cellFilterCollection()->filters();
|
|
|
|
if ( sourceFilters.size() == destinationFilters.size() )
|
|
|
|
{
|
|
|
|
for ( size_t i = 0; i < sourceFilters.size(); ++i )
|
|
|
|
{
|
|
|
|
auto sourcePolygonFilter = dynamic_cast<RimPolygonFilter*>( sourceFilters[i] );
|
|
|
|
auto destinationPolygonFilter = dynamic_cast<RimPolygonFilter*>( destinationFilters[i] );
|
|
|
|
|
|
|
|
if ( sourcePolygonFilter && sourcePolygonFilter->polygonInView() && destinationPolygonFilter )
|
|
|
|
{
|
|
|
|
destinationPolygonFilter->setPolygon( sourcePolygonFilter->polygonInView()->polygon() );
|
|
|
|
destinationPolygonFilter->configurePolygonEditor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-08 09:18:03 -06:00
|
|
|
return contourMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMap( RimEclipseCase* eclipseCase )
|
2018-11-08 09:18:03 -06:00
|
|
|
{
|
2023-11-09 01:57:19 -06:00
|
|
|
// Make sure case is open before accessing active cell info
|
|
|
|
eclipseCase->ensureReservoirCaseIsOpen();
|
|
|
|
if ( !eclipseCase->eclipseCaseData() ) return nullptr;
|
|
|
|
|
2019-01-11 06:56:35 -06:00
|
|
|
RimEclipseContourMapView* contourMap = new RimEclipseContourMapView();
|
2019-09-06 03:40:57 -05:00
|
|
|
contourMap->setEclipseCase( eclipseCase );
|
2018-11-08 09:18:03 -06:00
|
|
|
|
2020-08-05 09:14:25 -05:00
|
|
|
assignDefaultResultAndLegend( contourMap );
|
2018-11-08 09:18:03 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmDocument::updateUiIconStateRecursively( contourMap );
|
2018-11-08 09:18:03 -06:00
|
|
|
|
|
|
|
size_t i = eclipseCase->contourMapCollection()->views().size();
|
2019-09-06 03:40:57 -05:00
|
|
|
contourMap->setName( QString( "Contour Map %1" ).arg( i + 1 ) );
|
2020-09-25 05:18:15 -05:00
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
const RigActiveCellInfo* activeCellInfo = eclipseCase->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
|
|
|
size_t activeCellCount = activeCellInfo->reservoirActiveCellCount();
|
2020-09-25 05:53:03 -05:00
|
|
|
if ( activeCellCount >= largeSamplingThresholdCellCount )
|
|
|
|
{
|
|
|
|
contourMap->contourMapProjection()->setSampleSpacingFactor( 1.5 );
|
|
|
|
}
|
|
|
|
else if ( activeCellCount >= mediumSamplingThresholdCellCount )
|
2020-09-25 05:18:15 -05:00
|
|
|
{
|
|
|
|
contourMap->contourMapProjection()->setSampleSpacingFactor( 1.2 );
|
|
|
|
}
|
|
|
|
|
2023-06-05 00:33:04 -05:00
|
|
|
contourMap->faultCollection()->setActive( false );
|
|
|
|
contourMap->wellCollection()->isActive = false;
|
2020-09-25 05:39:54 -05:00
|
|
|
|
2024-04-17 06:46:31 -05:00
|
|
|
eclipseCase->contourMapCollection()->addView( contourMap );
|
2018-11-08 09:18:03 -06:00
|
|
|
|
2020-10-02 04:12:25 -05:00
|
|
|
auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" );
|
2020-09-30 01:32:20 -05:00
|
|
|
contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background
|
|
|
|
|
2018-11-14 05:53:44 -06:00
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
2018-11-08 09:18:03 -06:00
|
|
|
return contourMap;
|
|
|
|
}
|
2019-01-16 03:51:43 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:43:15 -06:00
|
|
|
RimGeoMechContourMapView*
|
|
|
|
RicNewContourMapViewFeature::createGeoMechContourMapFromExistingContourMap( RimGeoMechCase* geoMechCase,
|
|
|
|
RimGeoMechContourMapView* existingContourMap )
|
2019-01-16 03:51:43 -06:00
|
|
|
{
|
2024-06-14 10:18:28 -05:00
|
|
|
auto contourMap = existingContourMap->copyObject<RimGeoMechContourMapView>();
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( contourMap );
|
|
|
|
contourMap->setGeoMechCase( geoMechCase );
|
2020-09-30 01:32:20 -05:00
|
|
|
|
2020-10-02 04:12:25 -05:00
|
|
|
auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" );
|
2020-09-30 01:32:20 -05:00
|
|
|
contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background
|
2019-01-16 03:51:43 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmDocument::updateUiIconStateRecursively( contourMap );
|
2019-01-16 03:51:43 -06:00
|
|
|
|
|
|
|
size_t i = geoMechCase->contourMapCollection()->views().size();
|
2019-09-06 03:40:57 -05:00
|
|
|
contourMap->setName( QString( "Contour Map %1" ).arg( i + 1 ) );
|
2024-04-17 06:46:31 -05:00
|
|
|
geoMechCase->contourMapCollection()->addView( contourMap );
|
2019-01-16 03:51:43 -06:00
|
|
|
|
|
|
|
// Resolve references after contour map has been inserted into Rim structures
|
|
|
|
contourMap->resolveReferencesRecursively();
|
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
|
|
|
return contourMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
RimGeoMechContourMapView* RicNewContourMapViewFeature::createGeoMechContourMapFrom3dView( RimGeoMechCase* geoMechCase,
|
2019-09-06 03:40:57 -05:00
|
|
|
const RimGeoMechView* sourceView )
|
2019-01-16 03:51:43 -06:00
|
|
|
{
|
|
|
|
RimGeoMechContourMapView* contourMap = dynamic_cast<RimGeoMechContourMapView*>(
|
2019-09-06 03:40:57 -05:00
|
|
|
sourceView->xmlCapability()->copyAndCastByXmlSerialization( RimGeoMechContourMapView::classKeywordStatic(),
|
|
|
|
sourceView->classKeyword(),
|
|
|
|
caf::PdmDefaultObjectFactory::instance() ) );
|
|
|
|
CVF_ASSERT( contourMap );
|
2019-01-16 03:51:43 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
contourMap->setGeoMechCase( geoMechCase );
|
2020-09-30 01:32:20 -05:00
|
|
|
|
2020-10-02 04:12:25 -05:00
|
|
|
auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" );
|
2020-09-30 01:32:20 -05:00
|
|
|
contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background
|
|
|
|
|
2019-01-16 03:51:43 -06:00
|
|
|
contourMap->setDefaultCustomName();
|
2020-08-05 07:07:14 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmDocument::updateUiIconStateRecursively( contourMap );
|
2019-01-16 03:51:43 -06:00
|
|
|
|
2024-04-17 06:46:31 -05:00
|
|
|
geoMechCase->contourMapCollection()->addView( contourMap );
|
2019-01-16 03:51:43 -06:00
|
|
|
|
|
|
|
// Resolve references after contour map has been inserted into Rim structures
|
|
|
|
std::vector<caf::PdmFieldHandle*> fieldsWithFailingResolve;
|
2019-09-06 03:40:57 -05:00
|
|
|
contourMap->resolveReferencesRecursively( &fieldsWithFailingResolve );
|
2019-01-16 03:51:43 -06:00
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
|
|
|
return contourMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RimGeoMechContourMapView* RicNewContourMapViewFeature::createGeoMechContourMap( RimGeoMechCase* geoMechCase )
|
2019-01-16 03:51:43 -06:00
|
|
|
{
|
|
|
|
RimGeoMechContourMapView* contourMap = new RimGeoMechContourMapView();
|
2019-09-06 03:40:57 -05:00
|
|
|
contourMap->setGeoMechCase( geoMechCase );
|
2019-01-16 03:51:43 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmDocument::updateUiIconStateRecursively( contourMap );
|
2019-01-16 03:51:43 -06:00
|
|
|
|
|
|
|
size_t i = geoMechCase->contourMapCollection()->views().size();
|
2019-09-06 03:40:57 -05:00
|
|
|
contourMap->setName( QString( "Contour Map %1" ).arg( i + 1 ) );
|
2024-04-17 06:46:31 -05:00
|
|
|
geoMechCase->contourMapCollection()->addView( contourMap );
|
2019-01-16 03:51:43 -06:00
|
|
|
|
2020-10-02 04:12:25 -05:00
|
|
|
auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" );
|
2020-09-30 01:32:20 -05:00
|
|
|
contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background
|
|
|
|
|
2019-01-16 03:51:43 -06:00
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
|
|
|
return contourMap;
|
|
|
|
}
|
2020-08-05 09:14:25 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicNewContourMapViewFeature::assignDefaultResultAndLegend( RimEclipseContourMapView* contourMap )
|
|
|
|
{
|
|
|
|
if ( contourMap->cellResult() )
|
|
|
|
{
|
|
|
|
contourMap->cellResult()->setResultType( RiaDefines::ResultCatType::DYNAMIC_NATIVE );
|
|
|
|
|
2024-07-04 05:38:41 -05:00
|
|
|
if ( RiaPreferencesGrid::current()->loadAndShowSoil() )
|
2020-08-05 09:14:25 -05:00
|
|
|
{
|
|
|
|
contourMap->cellResult()->setResultVariable( "SOIL" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|