Merge remote-tracking branch 'origin/dev' into grid-geometry-extraction

This commit is contained in:
Jørgen Herje 2024-03-14 08:31:07 +01:00
commit 7ca4bd7ce3
205 changed files with 2463 additions and 658 deletions

View File

@ -286,6 +286,7 @@
<file>decline-curve.svg</file>
<file>regression-curve.svg</file>
<file>padlock.svg</file>
<file>warning.svg</file>
</qresource>
<qresource prefix="/Shader">
<file>fs_CellFace.glsl</file>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><title>ionicons-v5-r</title><path d="M85.57,446.25H426.43a32,32,0,0,0,28.17-47.17L284.18,82.58c-12.09-22.44-44.27-22.44-56.36,0L57.4,399.08A32,32,0,0,0,85.57,446.25Z" style="fill:none;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><path d="M250.26,195.39l5.74,122,5.73-121.95a5.74,5.74,0,0,0-5.79-6h0A5.74,5.74,0,0,0,250.26,195.39Z" style="fill:none;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><path d="M256,397.25a20,20,0,1,1,20-20A20,20,0,0,1,256,397.25Z"/></svg>

After

Width:  |  Height:  |  Size: 740 B

View File

@ -46,7 +46,7 @@ RiaGrpcConsoleApplication::RiaGrpcConsoleApplication( int& argc, char** argv )
{
m_idleTimer = new QTimer( this );
connect( m_idleTimer, SIGNAL( timeout() ), this, SLOT( doIdleProcessing() ) );
m_idleTimer->start( 0 );
m_idleTimer->start( 5 );
}
//--------------------------------------------------------------------------------------------------

View File

@ -21,12 +21,11 @@
#include "RiaDefines.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cvfFont.h"
#include "cafPdmPointer.h"
#include "cvfObject.h"
#include <QEventLoop>
#include <QMap>
#include <QMutex>
#include <QPointer>
#include <QProcess>
@ -35,7 +34,6 @@
#include <gsl/gsl>
#include <iostream>
#include <memory>
class QAction;
@ -79,7 +77,8 @@ class UiProcess;
namespace cvf
{
class ProgramOptions;
}
class Font;
} // namespace cvf
//==================================================================================================
/// Base class for all ResInsight applications. I.e. console and GUI

View File

@ -20,9 +20,11 @@
#include "RiaGuiApplication.h"
#include "cafAssert.h"
#include "cafFixedAtlasFont.h"
#include <QDesktopWidget>
#include <cmath>
//--------------------------------------------------------------------------------------------------

View File

@ -21,11 +21,6 @@
#include "RiaApplication.h"
#include "RiaDefines.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cvfObject.h"
#include <QApplication>
#include <QMutex>
#include <QPointer>

View File

@ -41,6 +41,7 @@
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiLineEditor.h"
#include <QCoreApplication>
#include <QDate>
#include <QDir>
#include <QLocale>

View File

@ -48,7 +48,7 @@ double RiaEclipseUnitTools::darcysConstant( RiaDefines::EclipseUnitSystem unitSy
//--------------------------------------------------------------------------------------------------
/// Convert Gas to oil equivalents
/// If field unit, the Gas is in Mega ft^3 while the others are in [stb] (barrel)
/// If field unit, the Gas is in Mft^3(=1000ft^3) while the others are in [stb] (barrel)
//--------------------------------------------------------------------------------------------------
double RiaEclipseUnitTools::convertSurfaceGasFlowRateToOilEquivalents( RiaDefines::EclipseUnitSystem caseUnitSystem, double eclGasFlowRate )
{
@ -56,18 +56,24 @@ double RiaEclipseUnitTools::convertSurfaceGasFlowRateToOilEquivalents( RiaDefine
/// we convert gas to stb as well. Based on
/// 1 [stb] = 0.15898729492800007 [m^3]
/// 1 [ft] = 0.3048 [m]
/// megaFt3ToStbFactor = 1.0 / (1.0e-6 * 0.15898729492800007 * ( 1.0 / 0.3048 )^3 )
/// double megaFt3ToStbFactor = 178107.60668;
///
/// NB Mft^3 = 1000 ft^3 - can wrongly be interpreted as M for Mega in metric units
double fieldGasToOilEquivalent = 1.0e6 / 5800; // Mega ft^3 to BOE
double metricGasToOilEquivalent = 1.0 / 1.0e3; // Sm^3 Gas to Sm^3 oe
if ( caseUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
{
const double fieldGasToOilEquivalent = 1000.0 / 5614.63;
double oilEquivalentGasRate = HUGE_VAL;
return fieldGasToOilEquivalent * eclGasFlowRate;
}
if ( caseUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD ) oilEquivalentGasRate = fieldGasToOilEquivalent * eclGasFlowRate;
if ( caseUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC ) oilEquivalentGasRate = metricGasToOilEquivalent * eclGasFlowRate;
if ( caseUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
{
double metricGasToOilEquivalent = 1.0 / 1000.0; // Sm^3 Gas to Sm^3 oe
return oilEquivalentGasRate;
return metricGasToOilEquivalent * eclGasFlowRate;
}
return HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------

View File

@ -20,7 +20,6 @@
#include "fast_float/include/fast_float/fast_float.h"
#include <cctype>
#include <charconv>
#include <regex>
#include <sstream>

View File

@ -47,6 +47,7 @@
#include "cafUtils.h"
#include <QAction>
#include <QApplication>
#include <QDebug>
#include <QDir>

View File

@ -31,7 +31,6 @@
#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiTreeSelectionEditor.h"
CAF_PDM_SOURCE_INIT( RicCreateDepthAdjustedLasFilesUi, "RicCreateDepthAdjustedLasFilesUi" );

View File

@ -33,7 +33,6 @@
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiGroup.h"
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include <QDir>

View File

@ -20,7 +20,6 @@
#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiOrdering.h"
#include <cmath>

View File

@ -25,7 +25,6 @@
#include "RimProject.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiOrdering.h"
CAF_PDM_SOURCE_INIT( RicExportWellPathsUi, "RicExportWellPathsUi" );

View File

@ -22,7 +22,6 @@
#include "RiaPreferences.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiOrdering.h"
#include <QDir>

View File

@ -24,7 +24,6 @@
#include "RicHoloLensServerSettings.h"
#include "cafPdmSettings.h"
#include "cafPdmUiOrdering.h"
#include "cvfAssert.h"

View File

@ -25,7 +25,6 @@
#include "RimProject.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiOrdering.h"
CAF_PDM_SOURCE_INIT( RicHoloLensExportToFolderUi, "RicHoloLensExportToFolderUi" );

View File

@ -19,8 +19,6 @@
#include "RicMeasurementPickEventHandler.h"
#include "RiaApplication.h"
#include "RiuViewer.h"
#include "RiuViewerCommands.h"
#include "Rim3dView.h"
#include "RimExtrudedCurveIntersection.h"
@ -28,13 +26,18 @@
#include "RimMeasurement.h"
#include "RimProject.h"
#include "cafDisplayCoordTransform.h"
#include "cafSelectionManager.h"
#include "RiuViewer.h"
#include "RiuViewerCommands.h"
#include "RivPartPriority.h"
#include "cafDisplayCoordTransform.h"
#include "cafSelectionManager.h"
#include "cvfPart.h"
#include <QApplication>
#include <vector>
//--------------------------------------------------------------------------------------------------

View File

@ -33,6 +33,7 @@
#include "cafPdmObjectHandle.h"
#include <QAction>
#include <QApplication>
#include <QClipboard>
#include <QString>

View File

@ -1,11 +1,21 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFileFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreatePolygonFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicImportPolygonFileFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicReloadPolygonFileFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDuplicatePolygonFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportPolygonCsvFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportPolygonPolFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSimplifyPolygonFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFileFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreatePolygonFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicImportPolygonFileFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicReloadPolygonFileFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDuplicatePolygonFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportPolygonCsvFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportPolygonPolFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSimplifyPolygonFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -16,23 +16,27 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicNewPolygonFeature.h"
#include "RicCreatePolygonFeature.h"
#include "RiaApplication.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonTools.h"
#include "Rim3dView.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RiuPlotMainWindowTools.h"
#include "Riu3DMainWindowTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewPolygonFeature, "RicNewPolygonFeature" );
CAF_CMD_SOURCE_INIT( RicCreatePolygonFeature, "RicCreatePolygonFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFeature::onActionTriggered( bool isChecked )
void RicCreatePolygonFeature::onActionTriggered( bool isChecked )
{
auto proj = RimProject::current();
auto polygonCollection = proj->activeOilField()->polygonCollection();
@ -40,15 +44,17 @@ void RicNewPolygonFeature::onActionTriggered( bool isChecked )
auto newPolygon = polygonCollection->appendUserDefinedPolygon();
polygonCollection->uiCapability()->updateAllRequiredEditors();
RiuPlotMainWindowTools::setExpanded( newPolygon );
RiuPlotMainWindowTools::selectAsCurrentItem( newPolygon );
Riu3DMainWindowTools::setExpanded( newPolygon );
auto activeView = RiaApplication::instance()->activeReservoirView();
RimPolygonTools::activate3dEditOfPolygonInView( newPolygon, activeView );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFeature::setupActionLook( QAction* actionToSetup )
void RicCreatePolygonFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Polygon" );
actionToSetup->setText( "Create Polygon" );
actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) );
}

View File

@ -23,7 +23,7 @@
//==================================================================================================
///
//==================================================================================================
class RicNewPolygonFeature : public caf::CmdFeature
class RicCreatePolygonFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

View File

@ -0,0 +1,79 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 "RicDuplicatePolygonFeature.h"
#include "RiaApplication.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonInView.h"
#include "Polygons/RimPolygonTools.h"
#include "Rim3dView.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "Riu3DMainWindowTools.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicDuplicatePolygonFeature, "RicDuplicatePolygonFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicatePolygonFeature::onActionTriggered( bool isChecked )
{
auto sourcePolygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>();
if ( !sourcePolygon )
{
auto sourcePolygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>();
if ( sourcePolygonInView )
{
sourcePolygon = sourcePolygonInView->polygon();
}
}
if ( !sourcePolygon ) return;
auto proj = RimProject::current();
auto polygonCollection = proj->activeOilField()->polygonCollection();
auto newPolygon = polygonCollection->createUserDefinedPolygon();
newPolygon->setPointsInDomainCoords( sourcePolygon->pointsInDomainCoords() );
auto sourceName = sourcePolygon->name();
newPolygon->setName( "Copy of " + sourceName );
polygonCollection->addUserDefinedPolygon( newPolygon );
polygonCollection->uiCapability()->updateAllRequiredEditors();
Riu3DMainWindowTools::setExpanded( newPolygon );
auto activeView = RiaApplication::instance()->activeReservoirView();
RimPolygonTools::selectPolygonInView( newPolygon, activeView );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicatePolygonFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Duplicate Polygon" );
actionToSetup->setIcon( QIcon( ":/caf/duplicate.svg" ) );
}

View File

@ -0,0 +1,33 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicDuplicatePolygonFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -0,0 +1,82 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 "RicExportPolygonCsvFeature.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonInView.h"
#include "Polygons/RimPolygonTools.h"
#include "RiuFileDialogTools.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QFileInfo>
CAF_CMD_SOURCE_INIT( RicExportPolygonCsvFeature, "RicExportPolygonCsvFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportPolygonCsvFeature::onActionTriggered( bool isChecked )
{
auto sourcePolygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>();
if ( !sourcePolygon )
{
auto sourcePolygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>();
if ( sourcePolygonInView )
{
sourcePolygon = sourcePolygonInView->polygon();
}
}
if ( !sourcePolygon ) return;
auto app = RiaGuiApplication::instance();
auto fallbackPath = app->lastUsedDialogDirectory( "BINARY_GRID" );
auto polygonPath = app->lastUsedDialogDirectoryWithFallback( RimPolygonTools::polygonCacheName(), fallbackPath );
auto polygonFileName = polygonPath + "/" + sourcePolygon->name() + ".csv";
auto fileName = RiuFileDialogTools::getSaveFileName( nullptr,
"Select File for Polygon Export to CSV",
polygonFileName,
"CSV Files (*.csv);;All files(*.*)" );
if ( !RimPolygonTools::exportPolygonCsv( sourcePolygon, fileName ) )
{
RiaLogging::error( "Failed to export polygon to " + fileName );
}
else
{
RiaLogging::info( "Completed polygon export to " + fileName );
app->setLastUsedDialogDirectory( RimPolygonTools::polygonCacheName(), QFileInfo( fileName ).absolutePath() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportPolygonCsvFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Export Polygon CSV" );
actionToSetup->setIcon( QIcon( ":/Save.svg" ) );
}

View File

@ -0,0 +1,33 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicExportPolygonCsvFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -0,0 +1,82 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 "RicExportPolygonPolFeature.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonInView.h"
#include "Polygons/RimPolygonTools.h"
#include "RiuFileDialogTools.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QFileInfo>
CAF_CMD_SOURCE_INIT( RicExportPolygonPolFeature, "RicExportPolygonPolFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportPolygonPolFeature::onActionTriggered( bool isChecked )
{
auto sourcePolygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>();
if ( !sourcePolygon )
{
auto sourcePolygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>();
if ( sourcePolygonInView )
{
sourcePolygon = sourcePolygonInView->polygon();
}
}
if ( !sourcePolygon ) return;
auto app = RiaGuiApplication::instance();
auto fallbackPath = app->lastUsedDialogDirectory( "BINARY_GRID" );
auto polygonPath = app->lastUsedDialogDirectoryWithFallback( RimPolygonTools::polygonCacheName(), fallbackPath );
auto polygonFileName = polygonPath + "/" + sourcePolygon->name() + ".pol";
auto fileName = RiuFileDialogTools::getSaveFileName( nullptr,
"Select File for Polygon Export to POL",
polygonFileName,
"POL Files (*.pol);;All files(*.*)" );
if ( !RimPolygonTools::exportPolygonPol( sourcePolygon, fileName ) )
{
RiaLogging::error( "Failed to export polygon to " + fileName );
}
else
{
RiaLogging::info( "Completed polygon export to " + fileName );
RiaApplication::instance()->setLastUsedDialogDirectory( RimPolygonTools::polygonCacheName(), QFileInfo( fileName ).absolutePath() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportPolygonPolFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Export Polygon POL" );
actionToSetup->setIcon( QIcon( ":/Save.svg" ) );
}

View File

@ -0,0 +1,33 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicExportPolygonPolFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -0,0 +1,87 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 "RicImportPolygonFileFeature.h"
#include "RiaApplication.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonFile.h"
#include "Polygons/RimPolygonTools.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "Riu3DMainWindowTools.h"
#include "RiuFileDialogTools.h"
#include <QAction>
#include <QFileInfo>
CAF_CMD_SOURCE_INIT( RicImportPolygonFileFeature, "RicImportPolygonFileFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicImportPolygonFileFeature::onActionTriggered( bool isChecked )
{
RiaApplication* app = RiaApplication::instance();
auto fallbackPath = app->lastUsedDialogDirectory( "BINARY_GRID" );
auto polygonPath = app->lastUsedDialogDirectoryWithFallback( RimPolygonTools::polygonCacheName(), fallbackPath );
QStringList fileNames = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(),
"Import Polygons",
polygonPath,
"Polylines (*.csv *.dat *.pol);;Text Files (*.txt);;Polylines "
"(*.dat);;Polylines (*.pol);;Polylines (*.csv);;All Files (*.*)" );
if ( fileNames.isEmpty() ) return;
// Remember the path to next time
app->setLastUsedDialogDirectory( RimPolygonTools::polygonCacheName(), QFileInfo( fileNames.last() ).absolutePath() );
auto proj = RimProject::current();
auto polygonCollection = proj->activeOilField()->polygonCollection();
RimPolygon* objectToSelect = nullptr;
for ( const auto& filename : fileNames )
{
auto newPolygonFile = new RimPolygonFile();
newPolygonFile->setFileName( filename );
newPolygonFile->loadData();
polygonCollection->addPolygonFile( newPolygonFile );
if ( !newPolygonFile->polygons().empty() ) objectToSelect = newPolygonFile->polygons().front();
}
polygonCollection->uiCapability()->updateAllRequiredEditors();
Riu3DMainWindowTools::setExpanded( objectToSelect );
Riu3DMainWindowTools::selectAsCurrentItem( objectToSelect );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicImportPolygonFileFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Import Polygon" );
actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) );
}

View File

@ -0,0 +1,33 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicImportPolygonFileFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -16,42 +16,36 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicNewPolygonFileFeature.h"
#include "RicReloadPolygonFileFeature.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonFile.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewPolygonFileFeature, "RicNewPolygonFileFeature" );
CAF_CMD_SOURCE_INIT( RicReloadPolygonFileFeature, "RicReloadPolygonFileFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFileFeature::onActionTriggered( bool isChecked )
void RicReloadPolygonFileFeature::onActionTriggered( bool isChecked )
{
auto proj = RimProject::current();
auto polygonCollection = proj->activeOilField()->polygonCollection();
auto polygonFile = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonFile>();
if ( polygonFile )
{
polygonFile->loadData();
polygonFile->objectChanged.send();
auto newPolygonFile = new RimPolygonFile();
newPolygonFile->setName( "File Polygon " + QString::number( polygonCollection->polygonFiles().size() + 1 ) );
polygonCollection->addPolygonFile( newPolygonFile );
polygonCollection->uiCapability()->updateAllRequiredEditors();
RiuPlotMainWindowTools::setExpanded( newPolygonFile );
RiuPlotMainWindowTools::selectAsCurrentItem( newPolygonFile );
polygonFile->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFileFeature::setupActionLook( QAction* actionToSetup )
void RicReloadPolygonFileFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New File Polygon" );
actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) );
actionToSetup->setText( "Reload" );
actionToSetup->setIcon( QIcon( ":/Refresh.svg" ) );
}

View File

@ -0,0 +1,33 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicReloadPolygonFileFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -0,0 +1,73 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 "RicSimplifyPolygonFeature.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonInView.h"
#include "RigCellGeometryTools.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QInputDialog>
CAF_CMD_SOURCE_INIT( RicSimplifyPolygonFeature, "RicSimplifyPolygonFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSimplifyPolygonFeature::onActionTriggered( bool isChecked )
{
auto sourcePolygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>();
if ( !sourcePolygon )
{
auto sourcePolygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>();
if ( sourcePolygonInView )
{
sourcePolygon = sourcePolygonInView->polygon();
}
}
if ( !sourcePolygon ) return;
const double defaultEpsilon = 10.0;
bool ok;
auto epsilon =
QInputDialog::getDouble( nullptr, "Simplify Polygon Threshold", "Threshold:", defaultEpsilon, 1.0, 1000.0, 1, &ok, Qt::WindowFlags(), 1 );
if ( ok )
{
auto coords = sourcePolygon->pointsInDomainCoords();
RigCellGeometryTools::simplifyPolygon( &coords, epsilon );
sourcePolygon->setPointsInDomainCoords( coords );
sourcePolygon->coordinatesChanged.send();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSimplifyPolygonFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Simplify Polygon" );
actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) );
}

View File

@ -23,7 +23,7 @@
//==================================================================================================
///
//==================================================================================================
class RicNewPolygonFileFeature : public caf::CmdFeature
class RicSimplifyPolygonFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

View File

@ -18,7 +18,7 @@
#include "RicCopyGridStatisticsToClipboardFeature.h"
#include "RiaApplication.h"
#include "RiaGuiApplication.h"
#include "RicWellLogTools.h"

View File

@ -22,7 +22,6 @@
#include "cafPdmObject.h"
#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiTreeSelectionEditor.h"
CAF_PDM_SOURCE_INIT( RicCreateEnsembleSurfaceUi, "RicCreateEnsembleSurfaceUi" );

View File

@ -34,7 +34,6 @@
#include "cafPdmObject.h"
#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiTreeSelectionEditor.h"
CAF_PDM_SOURCE_INIT( RicCreateEnsembleWellLogUi, "RicCreateEnsembleWellLogUi" );

View File

@ -18,7 +18,7 @@
#include "RicNewSeismicDifferenceFeature.h"
#include "RiaApplication.h"
#include "RiaGuiApplication.h"
#include "RimOilField.h"
#include "RimProject.h"

View File

@ -286,6 +286,7 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi
curve->setLineThickness( 2 );
curve->loadDataAndUpdate( false );
curve->setAutoNameComponents( false, true, false, false, false );
curve->updateCurveName();
i++;
}
@ -352,6 +353,7 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
{
curve->setCheckState( false );
}
curve->updateCurveName();
}
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
@ -392,11 +394,13 @@ std::pair<cvf::Color3f, RiuQwtPlotCurveDefines::LineStyleEnum>
if ( resultName == RiaResultNames::wbsFGMkMinResult() ) return { cvf::Color3f::BLUE, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT };
if ( resultName == RiaResultNames::wbsPPInitialResult() )
return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID };
if ( resultName == RiaResultNames::wbsPPExpResult() ) return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH };
if ( resultName == RiaResultNames::wbsPPMinResult() ) return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT };
return { cvf::Color3f::DEEP_PINK, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID };
if ( resultName == RiaResultNames::wbsPPExpResult() )
return { cvf::Color3f::DEEP_PINK, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH };
if ( resultName == RiaResultNames::wbsPPMinResult() )
return { cvf::Color3f::DEEP_PINK, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT };
if ( resultName == RiaResultNames::wbsPPMaxResult() )
return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT };
return { cvf::Color3f::DEEP_PINK, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT };
return { colors[i % colors.size()], RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID };
}

View File

@ -40,6 +40,8 @@
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include <QApplication>
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT( RicWellTarget3dEditor );
//--------------------------------------------------------------------------------------------------

View File

@ -31,19 +31,17 @@
#include "RimEclipseView.h"
#include "RimGeoMechView.h"
#include "RimModeledWellPath.h"
#include "RimWellPath.h"
#include "RimWellPathGeometryDef.h"
#include "RimWellPathTarget.h"
#include "RiuViewerCommands.h"
#include "RivFemPartGeometryGenerator.h"
#include "RivFemPickSourceInfo.h"
#include "RivSourceInfo.h"
#include "RivWellPathSourceInfo.h"
#include "cafDisplayCoordTransform.h"
#include "cafSelectionManager.h"
#include <QApplication>
#include <vector>

View File

@ -95,6 +95,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculation.h
${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationImporter.h
${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationExporter.h
${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -189,6 +190,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RifGridCalculationExporter.cpp
${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationImporter.cpp
${CMAKE_CURRENT_LIST_DIR}/RifSummaryCalculationExporter.cpp
${CMAKE_CURRENT_LIST_DIR}/RifPolygonReader.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -118,7 +118,7 @@ void RifCsvDataTableFormatter::tableCompleted()
//--------------------------------------------------------------------------------------------------
void RifCsvDataTableFormatter::outputBuffer()
{
if ( !m_columnHeaders.empty() )
if ( isAnyTextInHeader() )
{
for ( size_t i = 0; i < m_columnHeaders.size(); i++ )
{
@ -152,3 +152,21 @@ void RifCsvDataTableFormatter::outputBuffer()
m_columnHeaders.clear();
m_buffer.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifCsvDataTableFormatter::isAnyTextInHeader() const
{
for ( auto& header : m_columnHeaders )
{
for ( const auto& titleRow : header.titles )
{
if ( !titleRow.trimmed().isEmpty() )
{
return true;
}
}
}
return false;
}

View File

@ -42,6 +42,7 @@ public:
private:
void outputBuffer();
bool isAnyTextInHeader() const;
private:
QTextStream& m_out;

View File

@ -204,13 +204,13 @@ std::pair<bool, std::string> RifFaultReactivationModelExporter::printParts(
for ( auto [boundary, boundaryName] : boundaries )
{
// Create boundary condition sets for each side of the parts (except top).
auto boundaryNodes = grid->boundaryNodes();
auto boundaryElements = grid->boundaryElements();
const auto& boundaryNodes = grid->boundaryNodes();
const auto& boundaryElements = grid->boundaryElements();
const std::vector<unsigned int>& nodes = boundaryNodes[boundary];
const std::vector<unsigned int>& nodes = boundaryNodes.at( boundary );
RifInpExportTools::printNodeSet( stream, boundaryName, false, nodes );
const std::vector<unsigned int>& elements = boundaryElements[boundary];
const std::vector<unsigned int>& elements = boundaryElements.at( boundary );
RifInpExportTools::printElementSet( stream, boundaryName, false, elements );
}
@ -834,6 +834,10 @@ bool RifFaultReactivationModelExporter::exportModelSettings( const RimFaultReact
auto [topPosition, bottomPosition] = model->faultTopBottom();
auto faultNormal = model->modelNormal();
// make sure we export in local coordinates, if that is used
topPosition = model->transformPointIfNeeded( topPosition );
bottomPosition = model->transformPointIfNeeded( bottomPosition );
// make sure we move horizontally, and along the 2D model
faultNormal.z() = 0.0;
faultNormal.normalize();

View File

@ -61,7 +61,7 @@ bool RifInpExportTools::printNodes( std::ostream& stream, const std::vector<cvf:
for ( size_t i = 0; i < nodes.size(); i++ )
{
stream << i + 1 << ", " << std::setprecision( 10 ) << nodes[i].x() << ", " << nodes[i].y() << ", " << nodes[i].z() << std::endl;
stream << i + 1 << ", " << nodes[i].x() << ", " << std::setprecision( 15 ) << nodes[i].y() << ", " << nodes[i].z() << std::endl;
}
return stream.good();

View File

@ -65,7 +65,7 @@ bool JsonWriter::encodeFile( QString filePath, QMap<QString, QVariant> map )
{
QFile file;
file.setFileName( filePath );
if ( file.open( QIODevice::ReadWrite | QIODevice::Text ) )
if ( file.open( QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate ) )
{
QString content = Json::encode( map, true );
QTextStream out( &file );

View File

@ -0,0 +1,209 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 "RifPolygonReader.h"
#include "RiaTextStringTools.h"
#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h"
#include "RifCsvUserDataParser.h"
#include <QFileInfo>
#include <QTextStream>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<int, std::vector<cvf::Vec3d>>> RifPolygonReader::parsePolygonFile( const QString& fileName, QString* errorMessage )
{
QFileInfo fi( fileName );
QFile dataFile( fileName );
if ( !dataFile.open( QFile::ReadOnly ) )
{
if ( errorMessage ) ( *errorMessage ) += "Could not open file: " + fileName + "\n";
return {};
}
QTextStream stream( &dataFile );
auto fileContent = stream.readAll();
if ( fi.suffix().trimmed().toLower() == "csv" )
{
return parseTextCsv( fileContent, errorMessage );
}
else
{
auto polygons = parseText( fileContent, errorMessage );
std::vector<std::pair<int, std::vector<cvf::Vec3d>>> polygonsWithIds;
for ( auto& polygon : polygons )
{
polygonsWithIds.push_back( std::make_pair( -1, polygon ) );
}
return polygonsWithIds;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<cvf::Vec3d>> RifPolygonReader::parseText( const QString& content, QString* errorMessage )
{
std::vector<std::vector<cvf::Vec3d>> polylines( 1 );
QString myString = content;
QTextStream stream( &myString );
int lineNumber = 1;
while ( !stream.atEnd() )
{
QString line = stream.readLine();
QStringList commentLineSegs = line.split( "#" );
if ( commentLineSegs.empty() ) continue; // Empty line
QStringList lineSegs = RiaTextStringTools::splitSkipEmptyParts( commentLineSegs[0], QRegExp( "\\s+" ) );
if ( lineSegs.empty() ) continue; // No data
if ( lineSegs.size() != 3 )
{
if ( errorMessage ) ( *errorMessage ) += "Unexpected number of words on line: " + QString::number( lineNumber ) + "\n";
continue;
}
{
bool isNumberParsingOk = true;
bool isOk = true;
double x = lineSegs[0].toDouble( &isOk );
isNumberParsingOk &= isOk;
double y = lineSegs[1].toDouble( &isOk );
isNumberParsingOk &= isOk;
double z = lineSegs[2].toDouble( &isOk );
isNumberParsingOk &= isOk;
if ( !isNumberParsingOk )
{
if ( errorMessage ) ( *errorMessage ) += "Could not read the point at line: " + QString::number( lineNumber ) + "\n";
continue;
}
if ( x == 999.0 && y == 999.0 && z == 999.0 ) // New PolyLine
{
polylines.push_back( std::vector<cvf::Vec3d>() );
continue;
}
cvf::Vec3d point( x, y, -z );
polylines.back().push_back( point );
}
++lineNumber;
}
if ( polylines.back().empty() )
{
polylines.pop_back();
}
return polylines;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<int, std::vector<cvf::Vec3d>>> RifPolygonReader::parseTextCsv( const QString& content, QString* errorMessage )
{
RifCsvUserDataPastedTextParser parser( content, errorMessage );
AsciiDataParseOptions parseOptions;
parseOptions.cellSeparator = ",";
parseOptions.decimalSeparator = ".";
std::vector<std::pair<QString, std::vector<double>>> readValues;
if ( parser.parse( parseOptions ) )
{
for ( auto s : parser.tableData().columnInfos() )
{
if ( s.dataType != Column::NUMERIC ) continue;
QString columnName = QString::fromStdString( s.columnName() );
bool isNumber = false;
auto value = columnName.toDouble( &isNumber );
std::vector<double> values = s.values;
if ( isNumber )
{
values.insert( values.begin(), value );
}
readValues.push_back( { columnName, values } );
}
}
if ( readValues.size() == 4 )
{
// Three first columns represent XYZ, last column polygon ID
const auto firstSize = readValues[0].second.size();
if ( ( firstSize == readValues[1].second.size() ) && ( firstSize == readValues[2].second.size() ) &&
( firstSize == readValues[3].second.size() ) )
{
std::vector<std::pair<int, std::vector<cvf::Vec3d>>> polylines;
std::vector<cvf::Vec3d> polygon;
int polygonId = -1;
for ( size_t i = 0; i < firstSize; i++ )
{
int currentPolygonId = static_cast<int>( readValues[3].second[i] );
if ( polygonId != currentPolygonId )
{
if ( !polygon.empty() ) polylines.push_back( std::make_pair( polygonId, polygon ) );
polygon.clear();
polygonId = currentPolygonId;
}
cvf::Vec3d point( readValues[0].second[i], readValues[1].second[i], -readValues[2].second[i] );
polygon.push_back( point );
}
if ( !polygon.empty() ) polylines.push_back( std::make_pair( polygonId, polygon ) );
return polylines;
}
}
if ( readValues.size() == 3 )
{
std::vector<cvf::Vec3d> points;
for ( size_t i = 0; i < readValues[0].second.size(); i++ )
{
cvf::Vec3d point( readValues[0].second[i], readValues[1].second[i], -readValues[2].second[i] );
points.push_back( point );
}
int polygonId = -1;
return { std::make_pair( polygonId, points ) };
}
return {};
}

View File

@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfVector3.h"
#include <QString>
#include <vector>
//==================================================================================================
//
//
//==================================================================================================
class RifPolygonReader
{
public:
static std::vector<std::pair<int, std::vector<cvf::Vec3d>>> parsePolygonFile( const QString& fileName, QString* errorMessage );
// Defined public for testing purposes
public:
static std::vector<std::vector<cvf::Vec3d>> parseText( const QString& content, QString* errorMessage );
static std::vector<std::pair<int, std::vector<cvf::Vec3d>>> parseTextCsv( const QString& content, QString* errorMessage );
};

View File

@ -465,6 +465,8 @@ std::pair<std::vector<cvf::Vec3d>, std::vector<unsigned>> RifSurfaceImporter::re
}
}
if ( surfacePoints.empty() ) return { {}, {} };
// Determine axes vectors
std::vector<std::pair<cvf::Vec2d, unsigned>> pairs;
for ( auto itr = axesVectorCandidatesNum.begin(); itr != axesVectorCandidatesNum.end(); ++itr )

View File

@ -320,7 +320,13 @@ bool RifTextDataTableFormatter::isAllHeadersEmpty( const std::vector<RifTextData
{
for ( auto& header : headers )
{
if ( !header.titles.empty() ) return false;
for ( const auto& titleRow : header.titles )
{
if ( !titleRow.trimmed().isEmpty() )
{
return false;
}
}
}
return true;
}

View File

@ -92,7 +92,7 @@ struct RifTextDataTableColumn
, alignment( alignment )
, width( width )
{
titles.push_back( title );
titles.emplace_back( title );
}
RifTextDataTableColumn( const QString& title,
@ -104,8 +104,8 @@ struct RifTextDataTableColumn
, alignment( alignment )
, width( width )
{
titles.push_back( title );
titles.push_back( subTitle );
titles.emplace_back( title );
titles.emplace_back( subTitle );
}
RifTextDataTableColumn( const QString& title,
@ -118,9 +118,9 @@ struct RifTextDataTableColumn
, alignment( alignment )
, width( width )
{
titles.push_back( title );
titles.push_back( subTitle1 );
titles.push_back( subTitle2 );
titles.emplace_back( title );
titles.emplace_back( subTitle1 );
titles.emplace_back( subTitle2 );
}
QString title() const

View File

@ -57,7 +57,8 @@ void RivFemElmVisibilityCalculator::computeRangeVisibility( cvf::UByteArray*
const cvf::CellRangeFilter& rangeFilter,
const cvf::UByteArray* indexIncludeVisibility,
const cvf::UByteArray* indexExcludeVisibility,
bool useIndexInclude )
bool useIndexInclude,
bool useAndOperation )
{
elmVisibilities->resize( femPart->elementCount() );
@ -74,9 +75,19 @@ void RivFemElmVisibilityCalculator::computeRangeVisibility( cvf::UByteArray*
for ( int elmIdx = 0; elmIdx < femPart->elementCount(); ++elmIdx )
{
grid->ijkFromCellIndex( elmIdx, &mainGridI, &mainGridJ, &mainGridK );
( *elmVisibilities )[elmIdx] =
( ( *indexIncludeVisibility )[elmIdx] || rangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, false ) ) &&
( *indexExcludeVisibility )[elmIdx];
if ( useAndOperation )
{
( *elmVisibilities )[elmIdx] =
( ( *indexIncludeVisibility )[elmIdx] && rangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, false ) ) &&
( *indexExcludeVisibility )[elmIdx];
}
else
{
( *elmVisibilities )[elmIdx] =
( ( *indexIncludeVisibility )[elmIdx] || rangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, false ) ) &&
( *indexExcludeVisibility )[elmIdx];
}
}
}
else

View File

@ -41,7 +41,8 @@ public:
const cvf::CellRangeFilter& rangeFilter,
const cvf::UByteArray* indexIncludeVisibility,
const cvf::UByteArray* indexExcludeVisibility,
bool useIndexInclude );
bool useIndexInclude,
bool useAndOperation );
static void computePropertyVisibility( cvf::UByteArray* cellVisibility,
const RigFemPart* grid,

View File

@ -251,7 +251,8 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr( RivGeoMechPartMgrCache
cellRangeFilter,
&indexIncludeVisibility,
&indexExcludeVisibility,
m_geomechView->cellFilterCollection()->hasActiveIncludeIndexFilters() );
m_geomechView->cellFilterCollection()->hasActiveIncludeIndexFilters(),
m_geomechView->cellFilterCollection()->useAndOperation() );
}
else if ( pMgrKey.geometryType() == PROPERTY_FILTERED )
{

View File

@ -749,9 +749,11 @@ void RivReservoirViewPartMgr::computeFilterVisibility( RivCellSetEnum
parentGridVisibilities = reservoirGridPartMgr->cellVisibility( parentGridIndex );
}
bool hasAdditiveRangeFilters = cellFilterColl->hasActiveIncludeRangeFilters() ||
m_reservoirView->wellCollection()->hasVisibleWellCells();
bool hasAdditiveIndexFilters = cellFilterColl->hasActiveIncludeIndexFilters();
const bool hasAdditiveRangeFilters = cellFilterColl->hasActiveIncludeRangeFilters() ||
m_reservoirView->wellCollection()->hasVisibleWellCells();
const bool hasAdditiveIndexFilters = cellFilterColl->hasActiveIncludeIndexFilters();
const bool useAndOperation = cellFilterColl->useAndOperation();
#pragma omp parallel for
for ( int cellIndex = 0; cellIndex < static_cast<int>( grid->cellCount() ); cellIndex++ )
@ -771,7 +773,7 @@ void RivReservoirViewPartMgr::computeFilterVisibility( RivCellSetEnum
size_t mainGridJ;
size_t mainGridK;
bool isInSubGridArea = cell.subGrid() != nullptr;
const bool isInSubGridArea = cell.subGrid() != nullptr;
grid->ijkFromCellIndex( cellIndex, &mainGridI, &mainGridJ, &mainGridK );
bool nativeRangeVisibility = false;
@ -780,8 +782,16 @@ void RivReservoirViewPartMgr::computeFilterVisibility( RivCellSetEnum
{
if ( hasAdditiveIndexFilters )
{
nativeRangeVisibility = indexIncludeVisibility[cellIndex] ||
gridCellRangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, isInSubGridArea );
if ( useAndOperation )
{
nativeRangeVisibility = indexIncludeVisibility[cellIndex] &&
gridCellRangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, isInSubGridArea );
}
else
{
nativeRangeVisibility = indexIncludeVisibility[cellIndex] ||
gridCellRangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, isInSubGridArea );
}
}
else
{

View File

@ -28,7 +28,6 @@
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmPtrField.h"
#include "cafPdmUiOrdering.h"
// Include to make Pdm work for cvf::Color
#include "cafPdmChildField.h"

View File

@ -26,7 +26,6 @@
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmPtrField.h"
#include "cafPdmUiOrdering.h"
// Include to make Pdm work for cvf::Color
#include "cafPdmChildField.h"

View File

@ -23,7 +23,6 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmUiOrdering.h"
// Include to make Pdm work for cvf::Color
#include "cafPdmChildField.h"

View File

@ -26,7 +26,6 @@
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmPtrField.h"
#include "cafPdmUiOrdering.h"
// Include to make Pdm work for cvf::Color
#include "cafPdmChildField.h"

View File

@ -23,7 +23,6 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmUiOrdering.h"
// Include to make Pdm work for cvf::Color
#include "cafPdmChildField.h"

View File

@ -24,7 +24,6 @@
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmPtrField.h"
#include "cafPdmUiOrdering.h"
// Include to make Pdm work for cvf::Color
#include "cafPdmChildField.h"

View File

@ -26,7 +26,6 @@
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmPtrField.h"
#include "cafPdmUiOrdering.h"
// Include to make Pdm work for cvf::Color
#include "cafPdmChildField.h"

View File

@ -24,6 +24,7 @@
#include "RimCellIndexFilter.h"
#include "RimCellRangeFilter.h"
#include "RimPolygonFilter.h"
#include "RimProject.h"
#include "RimUserDefinedFilter.h"
#include "RimUserDefinedIndexFilter.h"
#include "RimViewController.h"
@ -32,8 +33,21 @@
#include "cafPdmFieldReorderCapability.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiLabelEditor.h"
#include "cvfStructGridGeometryGenerator.h"
namespace caf
{
template <>
void caf::AppEnum<RimCellFilterCollection::CombineFilterModeType>::setUp()
{
addItem( RimCellFilterCollection::AND, "AND", "AND" );
addItem( RimCellFilterCollection::OR, "OR", "OR" );
setDefault( RimCellFilterCollection::AND );
}
} // namespace caf
CAF_PDM_SOURCE_INIT( RimCellFilterCollection, "CellFilterCollection", "RimCellFilterCollection", "CellRangeFilterCollection" );
//--------------------------------------------------------------------------------------------------
@ -47,6 +61,12 @@ RimCellFilterCollection::RimCellFilterCollection()
CAF_PDM_InitScriptableField( &m_isActive, "Active", true, "Active" );
m_isActive.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_combineFilterMode, "CombineFilterMode", "" );
CAF_PDM_InitField( &m_combineModeLabel, "CombineModeLabel", QString( "" ), "Combine Polygon and Range Filters Using Operation" );
m_combineModeLabel.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() );
m_combineModeLabel.xmlCapability()->disableIO();
CAF_PDM_InitFieldNoDefault( &m_cellFilters, "CellFilters", "Filters" );
caf::PdmFieldReorderCapability::addToField( &m_cellFilters );
@ -87,6 +107,14 @@ void RimCellFilterCollection::setActive( bool bActive )
updateIconState();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCellFilterCollection::useAndOperation() const
{
return m_combineFilterMode() == RimCellFilterCollection::AND;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -124,6 +152,12 @@ void RimCellFilterCollection::initAfterRead()
m_cellFilters.push_back( filter );
}
// fallback to OR mode for older projects made without AND support
if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2023.12.0" ) )
{
m_combineFilterMode = RimCellFilterCollection::OR;
}
// Copy by xml serialization does not give a RimCase parent the first time initAfterRead is called here when creating a new a contour
// view from a 3d view. The second time we get called it is ok, so just skip setting up the filter connections if we have no case.
auto rimCase = firstAncestorOrThisOfType<RimCase>();
@ -161,6 +195,17 @@ caf::PdmFieldHandle* RimCellFilterCollection::objectToggleField()
return &m_isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellFilterCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_combineModeLabel );
uiOrdering.add( &m_combineFilterMode );
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -182,6 +227,18 @@ void RimCellFilterCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTr
updateIconState();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellFilterCollection::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
caf::PdmUiLabelEditorAttribute* myAttr = dynamic_cast<caf::PdmUiLabelEditorAttribute*>( attribute );
if ( myAttr )
{
myAttr->m_useSingleWidgetInsteadOfLabelAndEditorWidget = true;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -49,6 +49,12 @@ class RimCellFilterCollection : public caf::PdmObject
CAF_PDM_HEADER_INIT;
public:
enum CombineFilterModeType
{
OR,
AND
};
RimCellFilterCollection();
~RimCellFilterCollection() override;
@ -68,6 +74,8 @@ public:
bool isActive() const;
void setActive( bool bActive );
bool useAndOperation() const;
void compoundCellRangeFilter( cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex ) const;
void updateCellVisibilityByIndex( cvf::UByteArray* cellsIncluded, cvf::UByteArray* cellsExcluded, size_t gridIndex ) const;
@ -87,7 +95,10 @@ public:
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
caf::PdmFieldHandle* objectToggleField() override;
void initAfterRead() override;
@ -97,8 +108,10 @@ private:
void setAutoName( RimCellFilter* pFilter );
void addFilter( RimCellFilter* pFilter );
caf::PdmChildArrayField<RimCellFilter*> m_cellFilters;
caf::PdmField<bool> m_isActive;
caf::PdmChildArrayField<RimCellFilter*> m_cellFilters;
caf::PdmField<bool> m_isActive;
caf::PdmField<QString> m_combineModeLabel;
caf::PdmField<caf::AppEnum<CombineFilterModeType>> m_combineFilterMode;
caf::PdmChildArrayField<RimCellRangeFilter*> m_rangeFilters_OBSOLETE;
};

View File

@ -330,7 +330,7 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField
{
if ( changedField == &m_editPolygonButton )
{
RimPolygonTools::selectAndActivatePolygonInView( m_cellFilterPolygon(), this );
RimPolygonTools::activate3dEditOfPolygonInView( m_cellFilterPolygon(), this );
m_editPolygonButton = false;

View File

@ -27,7 +27,6 @@
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiTreeOrdering.h"
namespace caf

View File

@ -33,7 +33,6 @@
#include "RiuQwtPlotWidget.h"
#include "cafAssert.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiTreeOrdering.h"
#include <QDebug>

View File

@ -39,7 +39,8 @@ enum class Boundary
{
FarSide,
Bottom,
Fault
Fault,
Reservoir
};
enum class ElementSets

View File

@ -113,7 +113,7 @@ RimFaultReactivationModel::RimFaultReactivationModel()
CAF_PDM_InitField( &m_minReservoirCellWidth, "MinReservoirCellWidth", 5.0, "Reservoir Cell Width" );
CAF_PDM_InitField( &m_cellWidthGrowFactor, "CellWidthGrowFactor", 1.15, "Cell Width Grow Factor" );
CAF_PDM_InitField( &m_useLocalCoordinates, "UseLocalCoordinates", false, "Use Local Coordinates" );
CAF_PDM_InitField( &m_useLocalCoordinates, "UseLocalCoordinates", true, "Use Local Coordinates" );
// Time Step Selection
CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Available Time Steps" );

View File

@ -31,7 +31,6 @@
#include "RiuQwtPlotWidget.h"
#include "cafPdmUiObjectHandle.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeSelectionEditor.h"

View File

@ -63,6 +63,7 @@
#include "cvfVector3.h"
#include <QApplication>
#include <QFileInfo>
#include <array>

View File

@ -161,7 +161,8 @@ cvf::ref<cvf::UByteArray> RimGeoMechContourMapProjection::getCellVisibility() co
cellRangeFilter,
&indexIncludeVis,
&indexExcludeVis,
view()->cellFilterCollection()->hasActiveIncludeIndexFilters() );
view()->cellFilterCollection()->hasActiveIncludeIndexFilters(),
view()->cellFilterCollection()->useAndOperation() );
}
if ( view()->propertyFilterCollection()->isActive() )
{

View File

@ -1048,10 +1048,7 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() );
if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() );
if ( RiaApplication::enableDevelopmentFeatures() )
{
uiTreeOrdering.add( m_polygonInViewCollection );
}
uiTreeOrdering.add( m_polygonInViewCollection );
uiTreeOrdering.skipRemainingChildren( true );
}

View File

@ -457,7 +457,7 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle*
if ( changedField == &m_simulationWell || changedField == &m_isActive || changedField == &m_type )
{
recomputeSimulationWellBranchData();
rebuildGeometryAndScheduleCreateDisplayModel();
}
if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex ||
@ -522,7 +522,7 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle*
if ( changedField == &m_editPolygonButton )
{
RimPolygonTools::selectAndActivatePolygonInView( m_projectPolygon(), this );
RimPolygonTools::activate3dEditOfPolygonInView( m_projectPolygon(), this );
m_editPolygonButton = false;
@ -546,10 +546,14 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf::
else if ( type() == CrossSectionEnum::CS_SIMULATION_WELL )
{
geometryGroup->add( &m_simulationWell );
updateSimulationWellCenterline();
if ( m_simulationWell() && m_simulationWellBranchCenterlines.size() > 1 )
if ( m_simulationWell() )
{
geometryGroup->add( &m_branchIndex );
auto branchCenterLines = simulationWellBranchCenterlines();
if ( branchCenterLines.size() > 1 )
{
geometryGroup->add( &m_branchIndex );
}
}
}
else if ( type() == CrossSectionEnum::CS_POLYLINE )
@ -705,9 +709,8 @@ QList<caf::PdmOptionItemInfo> RimExtrudedCurveIntersection::calculateValueOption
}
else if ( fieldNeedingOptions == &m_branchIndex )
{
updateSimulationWellCenterline();
size_t branchCount = m_simulationWellBranchCenterlines.size();
auto branchCenterLines = simulationWellBranchCenterlines();
size_t branchCount = branchCenterLines.size();
options.push_back( caf::PdmOptionItemInfo( "All", -1 ) );
@ -812,14 +815,16 @@ std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::polyLines( cv
{
int branchIndexToUse = branchIndex();
if ( 0 <= branchIndexToUse && branchIndexToUse < static_cast<int>( m_simulationWellBranchCenterlines.size() ) )
auto branchCenterLines = simulationWellBranchCenterlines();
if ( 0 <= branchIndexToUse && branchIndexToUse < static_cast<int>( branchCenterLines.size() ) )
{
lines.push_back( m_simulationWellBranchCenterlines[branchIndexToUse] );
lines.push_back( branchCenterLines[branchIndexToUse] );
}
if ( branchIndexToUse == -1 )
{
lines = m_simulationWellBranchCenterlines;
lines = branchCenterLines;
}
}
}
@ -900,27 +905,6 @@ std::vector<cvf::Vec3d> RimExtrudedCurveIntersection::polyLinesForExtrusionDirec
return m_customExtrusionPoints;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::updateSimulationWellCenterline()
{
if ( m_isActive() && type() == CrossSectionEnum::CS_SIMULATION_WELL && m_simulationWell() )
{
if ( m_simulationWellBranchCenterlines.empty() )
{
auto simWells = m_simulationWell()->wellBranchesForVisualization();
const auto& [coords, wellCells] = RigSimulationWellCenterLineCalculator::extractBranchData( simWells );
m_simulationWellBranchCenterlines = coords;
}
}
else
{
m_simulationWellBranchCenterlines.clear();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1019,7 +1003,8 @@ int RimExtrudedCurveIntersection::branchIndex() const
return -1;
}
if ( m_branchIndex >= static_cast<int>( m_simulationWellBranchCenterlines.size() ) )
auto branchCenterLines = simulationWellBranchCenterlines();
if ( m_branchIndex >= static_cast<int>( branchCenterLines.size() ) )
{
return -1;
}
@ -1279,20 +1264,6 @@ double RimExtrudedCurveIntersection::extentLength()
return m_extentLength();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::recomputeSimulationWellBranchData()
{
if ( m_type() == CrossSectionEnum::CS_SIMULATION_WELL )
{
m_simulationWellBranchCenterlines.clear();
updateSimulationWellCenterline();
m_crossSectionPartMgr = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1426,3 +1397,16 @@ RimEclipseView* RimExtrudedCurveIntersection::eclipseView() const
{
return firstAncestorOrThisOfType<RimEclipseView>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::simulationWellBranchCenterlines() const
{
if ( !m_simulationWell() ) return {};
const auto simWells = m_simulationWell()->wellBranchesForVisualization();
const auto& [branchCenterLines, wellCells] = RigSimulationWellCenterLineCalculator::extractBranchData( simWells );
return branchCenterLines;
}

View File

@ -127,7 +127,6 @@ public:
void setLengthUp( double heightUp );
void setLengthDown( double heightDown );
double extentLength();
void recomputeSimulationWellBranchData();
bool hasDefiningPoints() const;
std::vector<RimSurfaceIntersectionCurve*> surfaceIntersectionCurves() const;
@ -152,7 +151,6 @@ private:
RimSimWellInViewCollection* simulationWellCollection() const;
void updateAzimuthLine();
void updateSimulationWellCenterline();
void addExtents( std::vector<cvf::Vec3d>& polyLine ) const;
void updateName();
static double azimuthInRadians( cvf::Vec3d vec );
@ -166,6 +164,8 @@ private:
RimEclipseView* eclipseView() const;
std::vector<std::vector<cvf::Vec3d>> simulationWellBranchCenterlines() const;
private:
caf::PdmField<QString> m_name;

View File

@ -295,17 +295,6 @@ std::vector<RimBoxIntersection*> RimIntersectionCollection::intersectionBoxes()
return m_intersectionBoxes.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionCollection::recomputeSimWellBranchData()
{
for ( const auto& intersection : intersections() )
{
intersection->recomputeSimulationWellBranchData();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -68,7 +68,6 @@ public:
void syncronize2dIntersectionViews();
void scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
void recomputeSimWellBranchData();
bool shouldApplyCellFiltersToIntersections() const;

View File

@ -18,14 +18,19 @@
#include "RimPolygon.h"
#include "RiaApplication.h"
#include "RiaColorTools.h"
#include "RigPolyLinesData.h"
#include "RiaApplication.h"
#include "Rim3dView.h"
#include "RimPolygonAppearance.h"
#include "RimPolygonTools.h"
#include "RiuGuiTheme.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiColorEditor.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTreeAttributes.h"
@ -36,6 +41,7 @@ CAF_PDM_SOURCE_INIT( RimPolygon, "RimPolygon" );
//--------------------------------------------------------------------------------------------------
RimPolygon::RimPolygon()
: objectChanged( this )
, coordinatesChanged( this )
{
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );
@ -78,8 +84,14 @@ void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrde
//--------------------------------------------------------------------------------------------------
void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicDuplicatePolygonFeature";
menuBuilder << "RicNewPolygonIntersectionFeature";
menuBuilder << "RicNewPolygonFilterFeature";
menuBuilder << "Separator";
menuBuilder << "RicExportPolygonCsvFeature";
menuBuilder << "RicExportPolygonPolFeature";
menuBuilder << "Separator";
menuBuilder << "RicSimplifyPolygonFeature";
}
//--------------------------------------------------------------------------------------------------
@ -88,8 +100,6 @@ void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) cons
void RimPolygon::setPointsInDomainCoords( const std::vector<cvf::Vec3d>& points )
{
m_pointsInDomainCoords = points;
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
@ -132,6 +142,30 @@ bool RimPolygon::isReadOnly() const
return m_isReadOnly();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::disableStorageOfPolygonPoints()
{
m_pointsInDomainCoords.xmlCapability()->setIOWritable( false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Color3f RimPolygon::color() const
{
return m_appearance->lineColor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::setColor( const cvf::Color3f& color )
{
m_appearance->setLineColor( color );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -158,13 +192,14 @@ void RimPolygon::fieldChangedByUi( const caf::PdmFieldHandle* changedField, cons
{
if ( changedField == &m_pointsInDomainCoords )
{
coordinatesChanged.send();
objectChanged.send();
}
if ( changedField == &m_editPolygonButton )
{
auto activeView = RiaApplication::instance()->activeReservoirView();
RimPolygonTools::selectAndActivatePolygonInView( this, activeView );
RimPolygonTools::activate3dEditOfPolygonInView( this, activeView );
m_editPolygonButton = false;
@ -189,18 +224,51 @@ void RimPolygon::defineEditorAttribute( const caf::PdmFieldHandle* field, QStrin
{
if ( auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) )
{
attrib->m_buttonText = "Edit in Active View";
if ( m_isReadOnly() )
{
attrib->m_buttonText = "Select in Active View";
}
else
{
attrib->m_buttonText = "Edit in Active View";
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::onColorTagClicked( const SignalEmitter* emitter, size_t index )
{
QColor sourceColor = RiaColorTools::toQColor( color() );
QColor newColor = caf::PdmUiColorEditor::getColor( sourceColor );
if ( newColor.isValid() && newColor != sourceColor )
{
setColor( RiaColorTools::fromQColorTo3f( newColor ) );
objectChanged.send();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( auto* treeItemAttribute = dynamic_cast<caf::PdmUiTreeViewItemAttribute*>( attribute ) )
{
auto tag = caf::PdmUiTreeViewItemAttribute::createTag( RiaColorTools::toQColor( color() ),
RiuGuiTheme::getColorByVariableName( "backgroundColor1" ),
"---" );
tag->clicked.connect( this, &RimPolygon::onColorTagClicked );
treeItemAttribute->tags.push_back( std::move( tag ) );
}
if ( m_isReadOnly )
{
caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( attribute, ":/padlock.svg" );
caf::PdmUiTreeViewItemAttribute::appendTagToTreeViewItemAttribute( attribute, ":/padlock.svg" );
}
}

View File

@ -24,6 +24,7 @@
#include "cafPdmChildField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cvfColor3.h"
#include "cvfVector3.h"
class RimPolygonAppearance;
@ -39,6 +40,7 @@ class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface
public:
caf::Signal<> objectChanged;
caf::Signal<> coordinatesChanged;
public:
RimPolygon();
@ -51,13 +53,19 @@ public:
void setReadOnly( bool isReadOnly );
bool isReadOnly() const;
void disableStorageOfPolygonPoints();
cvf::Color3f color() const;
void setColor( const cvf::Color3f& color );
cvf::ref<RigPolyLinesData> polyLinesData() const override;
void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void onColorTagClicked( const SignalEmitter* emitter, size_t index );
protected:
private:
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override;

View File

@ -85,8 +85,8 @@ RimPolygonAppearance::RimPolygonAppearance()
CAF_PDM_InitField( &m_lineThickness, "LineThickness", 3, "Line Thickness" );
CAF_PDM_InitField( &m_sphereRadiusFactor, "SphereRadiusFactor", 0.15, "Sphere Radius Factor" );
CAF_PDM_InitField( &m_lineColor, "LineColor", cvf::Color3f( cvf::Color3f::WHITE ), "Line Color" );
CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::WHITE ), "Sphere Color" );
CAF_PDM_InitField( &m_lineColor, "LineColor", cvf::Color3f( cvf::Color3f::ORANGE ), "Line Color" );
CAF_PDM_InitField( &m_sphereColor, "SphereColor", cvf::Color3f( cvf::Color3f::ORANGE ), "Sphere Color" );
CAF_PDM_InitField( &m_polygonPlaneDepth, "PolygonPlaneDepth", 0.0, "Polygon Plane Depth" );
CAF_PDM_InitField( &m_lockPolygonToPlane, "LockPolygon", false, "Lock Polygon to Plane" );
@ -123,6 +123,22 @@ bool RimPolygonAppearance::isClosed() const
return m_isClosed();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Color3f RimPolygonAppearance::lineColor() const
{
return m_lineColor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::setLineColor( const cvf::Color3f& color )
{
m_lineColor = color;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -37,6 +37,9 @@ public:
void setIsClosed( bool isClosed );
bool isClosed() const;
cvf::Color3f lineColor() const;
void setLineColor( const cvf::Color3f& color );
public:
RimPolygonAppearance();

View File

@ -23,6 +23,8 @@
#include "RimPolygonFile.h"
#include "RimProject.h"
#include "cafCmdFeatureMenuBuilder.h"
CAF_PDM_SOURCE_INIT( RimPolygonCollection, "RimPolygonCollection" );
//--------------------------------------------------------------------------------------------------
@ -30,7 +32,7 @@ CAF_PDM_SOURCE_INIT( RimPolygonCollection, "RimPolygonCollection" );
//--------------------------------------------------------------------------------------------------
RimPolygonCollection::RimPolygonCollection()
{
CAF_PDM_InitObject( "Polygons (Under construction)", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitObject( "Polygons", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" );
CAF_PDM_InitFieldNoDefault( &m_polygonFiles, "PolygonFiles", "Polygon Files" );
@ -50,10 +52,20 @@ void RimPolygonCollection::loadData()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygon* RimPolygonCollection::appendUserDefinedPolygon()
RimPolygon* RimPolygonCollection::createUserDefinedPolygon()
{
auto newPolygon = new RimPolygon();
newPolygon->setName( "Polygon " + QString::number( userDefinedPolygons().size() + 1 ) );
return newPolygon;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygon* RimPolygonCollection::appendUserDefinedPolygon()
{
auto newPolygon = createUserDefinedPolygon();
addUserDefinedPolygon( newPolygon );
return newPolygon;
@ -66,7 +78,7 @@ void RimPolygonCollection::addUserDefinedPolygon( RimPolygon* polygon )
{
m_polygons().push_back( polygon );
connectSignals( polygon );
connectPolygonSignals( polygon );
updateViewTreeItems();
scheduleRedrawViews();
@ -90,6 +102,8 @@ void RimPolygonCollection::addPolygonFile( RimPolygonFile* polygonFile )
{
m_polygonFiles().push_back( polygonFile );
connectPolygonFileSignals( polygonFile );
updateViewTreeItems();
scheduleRedrawViews();
}
@ -150,6 +164,15 @@ void RimPolygonCollection::childFieldChangedByUi( const caf::PdmFieldHandle* cha
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicCreatePolygonFeature";
menuBuilder << "RicImportPolygonFileFeature";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -178,19 +201,39 @@ void RimPolygonCollection::scheduleRedrawViews()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::connectSignals( RimPolygon* polygon )
void RimPolygonCollection::connectPolygonSignals( RimPolygon* polygon )
{
if ( polygon )
{
polygon->objectChanged.connect( this, &RimPolygonCollection::onObjectChanged );
polygon->objectChanged.connect( this, &RimPolygonCollection::onPolygonChanged );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::onObjectChanged( const caf::SignalEmitter* emitter )
void RimPolygonCollection::connectPolygonFileSignals( RimPolygonFile* polygonFile )
{
if ( polygonFile )
{
polygonFile->objectChanged.connect( this, &RimPolygonCollection::onPolygonFileChanged );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::onPolygonChanged( const caf::SignalEmitter* emitter )
{
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::onPolygonFileChanged( const caf::SignalEmitter* emitter )
{
updateViewTreeItems();
scheduleRedrawViews();
}
@ -201,6 +244,11 @@ void RimPolygonCollection::initAfterRead()
{
for ( auto& p : m_polygons() )
{
connectSignals( p );
connectPolygonSignals( p );
}
for ( auto& pf : m_polygonFiles() )
{
connectPolygonFileSignals( pf );
}
}

View File

@ -36,6 +36,7 @@ public:
RimPolygonCollection();
void loadData();
RimPolygon* createUserDefinedPolygon();
RimPolygon* appendUserDefinedPolygon();
void addUserDefinedPolygon( RimPolygon* polygon );
void deleteUserDefinedPolygons();
@ -46,15 +47,18 @@ public:
std::vector<RimPolygonFile*> polygonFiles() const;
std::vector<RimPolygon*> allPolygons() const;
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override;
private:
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override;
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
void updateViewTreeItems();
void scheduleRedrawViews();
void connectSignals( RimPolygon* polygon );
void onObjectChanged( const caf::SignalEmitter* emitter );
void connectPolygonSignals( RimPolygon* polygon );
void connectPolygonFileSignals( RimPolygonFile* polygonFile );
void onPolygonChanged( const caf::SignalEmitter* emitter );
void onPolygonFileChanged( const caf::SignalEmitter* emitter );
private:
caf::PdmChildArrayField<RimPolygon*> m_polygons;

View File

@ -17,14 +17,25 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimPolygonFile.h"
#include "RiaLogging.h"
#include "RifPolygonReader.h"
#include "RimPolygon.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiTreeAttributes.h"
#include <QFileInfo>
CAF_PDM_SOURCE_INIT( RimPolygonFile, "RimPolygonFileFile" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonFile::RimPolygonFile()
: objectChanged( this )
{
CAF_PDM_InitObject( "PolygonFile", ":/PolylinesFromFile16x16.png" );
@ -34,12 +45,48 @@ RimPolygonFile::RimPolygonFile()
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::setFileName( const QString& fileName )
{
m_fileName = fileName;
updateName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::loadData()
{
loadPolygonsFromFile();
auto polygonsFromFile = importDataFromFile( m_fileName().path() );
if ( m_polygons.size() == polygonsFromFile.size() )
{
for ( size_t i = 0; i < m_polygons.size(); i++ )
{
auto projectPoly = m_polygons()[i];
auto filePoly = polygonsFromFile[i];
projectPoly->setPointsInDomainCoords( filePoly->pointsInDomainCoords() );
delete filePoly;
}
}
else
{
m_polygons.deleteChildren();
m_polygons.setValue( polygonsFromFile );
}
if ( polygonsFromFile.empty() )
{
RiaLogging::warning( "No polygons found in file: " + m_fileName().path() );
}
else
{
RiaLogging::info( QString( "Imported %1 polygons from file: " ).arg( polygonsFromFile.size() ) + m_fileName().path() );
}
}
//--------------------------------------------------------------------------------------------------
@ -50,11 +97,36 @@ std::vector<RimPolygon*> RimPolygonFile::polygons() const
return m_polygons.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimPolygonFile::name() const
{
QString nameCandidate = RimNamedObject::name();
if ( !nameCandidate.isEmpty() )
{
return nameCandidate;
}
auto fileName = m_fileName().path();
if ( fileName.isEmpty() )
{
return "Polygon File";
}
QFileInfo fileInfo( fileName );
return fileInfo.fileName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( nameField() );
uiOrdering.add( &m_fileName );
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
@ -62,21 +134,71 @@ void RimPolygonFile::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
loadPolygonsFromFile();
if ( changedField == &m_fileName )
{
updateName();
m_polygons.deleteChildren();
loadData();
}
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::loadPolygonsFromFile()
std::vector<RimPolygon*> RimPolygonFile::importDataFromFile( const QString& fileName )
{
// m_polygons()->deletePolygons();
QString errorMessages;
auto filePolygons = RifPolygonReader::parsePolygonFile( fileName, &errorMessages );
auto polygon = new RimPolygon();
polygon->setName( "Polygon 1" );
m_polygons.push_back( polygon );
std::vector<RimPolygon*> polygons;
polygon = new RimPolygon();
polygon->setName( "Polygon 2" );
m_polygons.push_back( polygon );
for ( const auto& [polygonId, filePolygon] : filePolygons )
{
auto polygon = new RimPolygon();
polygon->disableStorageOfPolygonPoints();
polygon->setReadOnly( true );
int id = ( polygonId != -1 ) ? polygonId : static_cast<int>( polygons.size() + 1 );
polygon->setName( QString( "Polygon %1" ).arg( id ) );
polygon->setPointsInDomainCoords( filePolygon );
polygons.push_back( polygon );
}
if ( !errorMessages.isEmpty() )
{
RiaLogging::error( errorMessages );
}
return polygons;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::updateName()
{
QFileInfo fileInfo( m_fileName().path() );
setName( fileInfo.fileName() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicReloadPolygonFileFeature";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( m_polygons.empty() )
{
caf::PdmUiTreeViewItemAttribute::appendTagToTreeViewItemAttribute( attribute, ":/warning.svg" );
}
}

View File

@ -28,19 +28,29 @@ class RimPolygonFile : public RimNamedObject
{
CAF_PDM_HEADER_INIT;
public:
caf::Signal<> objectChanged;
public:
RimPolygonFile();
void setFileName( const QString& fileName );
void loadData();
std::vector<RimPolygon*> polygons() const;
QString name() const override;
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
private:
void loadPolygonsFromFile();
static std::vector<RimPolygon*> importDataFromFile( const QString& fileName );
void updateName();
private:
caf::PdmField<caf::FilePath> m_fileName;

View File

@ -18,6 +18,8 @@
#include "RimPolygonInView.h"
#include "RiaColorTools.h"
#include "RigPolyLinesData.h"
#include "Rim3dView.h"
@ -70,6 +72,7 @@ RimPolygonInView::RimPolygonInView()
m_targets.uiCapability()->setUiTreeChildrenHidden( true );
m_targets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
m_targets.uiCapability()->setCustomContextMenuEnabled( true );
m_targets.xmlCapability()->disableIO();
setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() );
}
@ -89,6 +92,8 @@ void RimPolygonInView::setPolygon( RimPolygon* polygon )
{
m_polygon = polygon;
connectSignals();
updateTargetsFromPolygon();
}
@ -231,6 +236,18 @@ void RimPolygonInView::updatePolygonFromTargets()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::connectSignals()
{
if ( m_polygon )
{
m_polygon->objectChanged.connect( this, &RimPolygonInView::onObjectChanged );
m_polygon->coordinatesChanged.connect( this, &RimPolygonInView::onCoordinatesChanged );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -322,9 +339,23 @@ void RimPolygonInView::defineObjectEditorAttribute( QString uiConfigName, caf::P
attrib->enablePicking = m_enablePicking;
}
if ( m_polygon() && m_polygon->isReadOnly() )
if ( m_polygon() )
{
caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( attribute, ":/padlock.svg" );
if ( auto* treeItemAttribute = dynamic_cast<caf::PdmUiTreeViewItemAttribute*>( attribute ) )
{
auto tag = caf::PdmUiTreeViewItemAttribute::createTag( RiaColorTools::toQColor( m_polygon->color() ),
RiuGuiTheme::getColorByVariableName( "backgroundColor1" ),
"---" );
tag->clicked.connect( m_polygon(), &RimPolygon::onColorTagClicked );
treeItemAttribute->tags.push_back( std::move( tag ) );
}
if ( m_polygon->isReadOnly() )
{
caf::PdmUiTreeViewItemAttribute::appendTagToTreeViewItemAttribute( attribute, ":/padlock.svg" );
}
}
}
@ -346,6 +377,33 @@ void RimPolygonInView::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder
if ( m_polygon() ) m_polygon->appendMenuItems( menuBuilder );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::onObjectChanged( const caf::SignalEmitter* emitter )
{
updateVisualization();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::onCoordinatesChanged( const caf::SignalEmitter* emitter )
{
updateTargetsFromPolygon();
updateConnectedEditors();
updateVisualization();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::initAfterRead()
{
connectSignals();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -51,6 +51,7 @@ public:
RimPolygon* polygon() const;
void setPolygon( RimPolygon* polygon );
void updateTargetsFromPolygon();
void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox );
void enablePicking( bool enable );
@ -79,12 +80,15 @@ protected:
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override;
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
void onObjectChanged( const caf::SignalEmitter* emitter );
void onCoordinatesChanged( const caf::SignalEmitter* emitter );
void initAfterRead() override;
private:
void updateNameField();
void updatePolygonFromTargets();
void updateTargetsFromPolygon();
void connectSignals();
private:
caf::PdmPtrField<RimPolygon*> m_polygon;

View File

@ -21,6 +21,7 @@
#include "Rim3dView.h"
#include "RimPolygon.h"
#include "RimPolygonCollection.h"
#include "RimPolygonFile.h"
#include "RimPolygonInView.h"
#include "RimTools.h"
@ -31,58 +32,74 @@ CAF_PDM_SOURCE_INIT( RimPolygonInViewCollection, "RimPolygonInViewCollection" );
//--------------------------------------------------------------------------------------------------
RimPolygonInViewCollection::RimPolygonInViewCollection()
{
CAF_PDM_InitObject( "Polygons (Under construction)", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitObject( "Polygons", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" );
CAF_PDM_InitFieldNoDefault( &m_polygonsInView, "Polygons", "Polygons" );
CAF_PDM_InitFieldNoDefault( &m_collectionsInView, "Collections", "Collections" );
nameField()->uiCapability()->setUiHidden( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::syncPolygonsInView()
void RimPolygonInViewCollection::updateFromPolygonCollection()
{
std::vector<RimPolygonInView*> existingPolygonsInView = m_polygons.childrenByType();
m_polygons.clearWithoutDelete();
auto polygonCollection = RimTools::polygonCollection();
if ( polygonCollection )
{
std::vector<RimPolygonInView*> newPolygonsInView;
for ( auto polygon : polygonCollection->allPolygons() )
{
auto it = std::find_if( existingPolygonsInView.begin(),
existingPolygonsInView.end(),
[polygon]( auto* polygonInView ) { return polygonInView->polygon() == polygon; } );
if ( it != existingPolygonsInView.end() )
{
newPolygonsInView.push_back( *it );
existingPolygonsInView.erase( it );
}
else
{
auto polygonInView = new RimPolygonInView();
polygonInView->setPolygon( polygon );
newPolygonsInView.push_back( polygonInView );
}
}
m_polygons.setValue( newPolygonsInView );
}
for ( auto polyInView : existingPolygonsInView )
{
delete polyInView;
}
updateAllViewItems();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygonInView*> RimPolygonInViewCollection::polygonsInView() const
std::vector<RimPolygonInView*> RimPolygonInViewCollection::visiblePolygonsInView() const
{
return m_polygons.childrenByType();
if ( !m_isChecked ) return {};
std::vector<RimPolygonInView*> polys = m_polygonsInView.childrenByType();
for ( auto coll : m_collectionsInView )
{
if ( !coll->isChecked() ) continue;
auto other = coll->visiblePolygonsInView();
polys.insert( polys.end(), other.begin(), other.end() );
}
return polys;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygonInView*> RimPolygonInViewCollection::allPolygonsInView() const
{
std::vector<RimPolygonInView*> polys = m_polygonsInView.childrenByType();
for ( auto coll : m_collectionsInView )
{
auto other = coll->visiblePolygonsInView();
polys.insert( polys.end(), other.begin(), other.end() );
}
return polys;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::setPolygonFile( RimPolygonFile* polygonFile )
{
m_polygonFile = polygonFile;
updateName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonFile* RimPolygonInViewCollection::polygonFile() const
{
return m_polygonFile;
}
//--------------------------------------------------------------------------------------------------
@ -90,11 +107,11 @@ std::vector<RimPolygonInView*> RimPolygonInViewCollection::polygonsInView() cons
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimCheckableObject::fieldChangedByUi( changedField, oldValue, newValue );
RimCheckableNamedObject::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_isChecked )
{
for ( auto poly : polygonsInView() )
for ( auto poly : visiblePolygonsInView() )
{
poly->updateConnectedEditors();
}
@ -105,3 +122,152 @@ void RimPolygonInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::updateAllViewItems()
{
// Based on the same concept as RimSurfaceInViewCollection
syncCollectionsWithView();
syncPolygonsWithView();
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::syncCollectionsWithView()
{
// Based on the same concept as RimSurfaceInViewCollection
auto colls = m_collectionsInView.childrenByType();
for ( auto coll : colls )
{
if ( !coll->polygonFile() )
{
m_collectionsInView.removeChild( coll );
delete coll;
}
}
if ( !m_polygonFile )
{
std::vector<RimPolygonInViewCollection*> orderedColls;
if ( auto polygonCollection = RimTools::polygonCollection() )
{
std::vector<RimPolygonInView*> newPolygonsInView;
for ( auto polygonFile : polygonCollection->polygonFiles() )
{
if ( polygonFile->polygons().empty() ) continue;
auto viewPolygonFile = getCollectionInViewForPolygonFile( polygonFile );
if ( viewPolygonFile == nullptr )
{
auto newColl = new RimPolygonInViewCollection();
newColl->setPolygonFile( polygonFile );
orderedColls.push_back( newColl );
}
else
{
viewPolygonFile->updateName();
orderedColls.push_back( viewPolygonFile );
}
}
}
m_collectionsInView.clearWithoutDelete();
for ( auto viewColl : orderedColls )
{
m_collectionsInView.push_back( viewColl );
viewColl->updateAllViewItems();
}
}
updateName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::syncPolygonsWithView()
{
std::vector<RimPolygonInView*> existingPolygonsInView = m_polygonsInView.childrenByType();
m_polygonsInView.clearWithoutDelete();
std::vector<RimPolygon*> polygons;
if ( m_polygonFile )
{
polygons = m_polygonFile->polygons();
}
else
{
auto polygonCollection = RimTools::polygonCollection();
polygons = polygonCollection->userDefinedPolygons();
}
std::vector<RimPolygonInView*> newPolygonsInView;
for ( auto polygon : polygons )
{
auto it = std::find_if( existingPolygonsInView.begin(),
existingPolygonsInView.end(),
[polygon]( auto* polygonInView ) { return polygonInView->polygon() == polygon; } );
if ( it != existingPolygonsInView.end() )
{
newPolygonsInView.push_back( *it );
existingPolygonsInView.erase( it );
( *it )->updateTargetsFromPolygon();
}
else
{
auto polygonInView = new RimPolygonInView();
polygonInView->setPolygon( polygon );
newPolygonsInView.push_back( polygonInView );
}
}
m_polygonsInView.setValue( newPolygonsInView );
for ( auto polyInView : existingPolygonsInView )
{
delete polyInView;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::updateName()
{
QString name = "Polygons";
if ( m_polygonFile )
{
name = m_polygonFile->name();
}
setName( name );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonInViewCollection* RimPolygonInViewCollection::getCollectionInViewForPolygonFile( const RimPolygonFile* polygonFile ) const
{
for ( auto collInView : m_collectionsInView )
{
if ( collInView->polygonFile() == polygonFile )
{
return collInView;
}
}
return nullptr;
}

View File

@ -18,29 +18,47 @@
#pragma once
#include "RimCheckableObject.h"
#include "RimCheckableNamedObject.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmPointer.h"
class RimPolygonInView;
class RimPolygonFile;
class RimPolygon;
//==================================================================================================
///
///
//==================================================================================================
class RimPolygonInViewCollection : public RimCheckableObject
class RimPolygonInViewCollection : public RimCheckableNamedObject
{
CAF_PDM_HEADER_INIT;
public:
RimPolygonInViewCollection();
void syncPolygonsInView();
void updateFromPolygonCollection();
std::vector<RimPolygonInView*> polygonsInView() const;
std::vector<RimPolygonInView*> visiblePolygonsInView() const;
std::vector<RimPolygonInView*> allPolygonsInView() const;
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void setPolygonFile( RimPolygonFile* polygonFile );
RimPolygonFile* polygonFile() const;
void updateAllViewItems();
void syncCollectionsWithView();
void syncPolygonsWithView();
void updateName();
RimPolygonInViewCollection* getCollectionInViewForPolygonFile( const RimPolygonFile* polygonFile ) const;
private:
caf::PdmChildArrayField<RimPolygonInView*> m_polygons;
caf::PdmChildArrayField<RimPolygonInView*> m_polygonsInView;
caf::PdmChildArrayField<RimPolygonInViewCollection*> m_collectionsInView;
caf::PdmPointer<RimPolygonFile> m_polygonFile;
};

View File

@ -18,6 +18,10 @@
#include "RimPolygonTools.h"
#include "RiaPreferences.h"
#include "RifCsvDataTableFormatter.h"
#include "RimGridView.h"
#include "RimOilField.h"
#include "RimPolygon.h"
@ -28,10 +32,13 @@
#include "Riu3DMainWindowTools.h"
#include <QFile>
#include <QTextStream>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonTools::selectAndActivatePolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject )
void RimPolygonTools::activate3dEditOfPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject )
{
auto polygonInView = findPolygonInView( polygon, sourceObject );
if ( polygonInView )
@ -41,6 +48,109 @@ void RimPolygonTools::selectAndActivatePolygonInView( RimPolygon* polygon, caf::
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonTools::selectPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject )
{
auto polygonInView = findPolygonInView( polygon, sourceObject );
if ( polygonInView )
{
Riu3DMainWindowTools::selectAsCurrentItem( polygonInView );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonTools::exportPolygonCsv( const RimPolygon* polygon, const QString& filePath )
{
if ( !polygon ) return false;
QFile file( filePath );
if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) )
{
return false;
}
QTextStream out( &file );
QString fieldSeparator = RiaPreferences::current()->csvTextExportFieldSeparator;
RifCsvDataTableFormatter formatter( out, fieldSeparator );
const int precision = 2;
std::vector<RifTextDataTableColumn> header;
header.emplace_back( "X", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) );
header.emplace_back( "Y", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) );
header.emplace_back( "Z", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) );
formatter.header( header );
for ( const auto& point : polygon->pointsInDomainCoords() )
{
formatter.add( point.x() );
formatter.add( point.y() );
formatter.add( -point.z() );
formatter.rowCompleted();
}
formatter.tableCompleted();
file.close();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonTools::exportPolygonPol( const RimPolygon* polygon, const QString& filePath )
{
if ( !polygon ) return false;
QFile file( filePath );
if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false;
QTextStream out( &file );
QString fieldSeparator = " ";
RifCsvDataTableFormatter formatter( out, fieldSeparator );
const int precision = 2;
std::vector<RifTextDataTableColumn> header;
header.emplace_back( " ", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) );
header.emplace_back( " ", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) );
header.emplace_back( " ", RifTextDataTableDoubleFormatting( RIF_FLOAT, precision ) );
formatter.header( header );
for ( const auto& point : polygon->pointsInDomainCoords() )
{
formatter.add( point.x() );
formatter.add( point.y() );
formatter.add( -point.z() );
formatter.rowCompleted();
}
const double endOfPolygon = 999.0;
formatter.add( endOfPolygon );
formatter.add( endOfPolygon );
formatter.add( endOfPolygon );
formatter.rowCompleted();
formatter.tableCompleted();
file.close();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimPolygonTools::polygonCacheName()
{
return "POLYGON";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -55,7 +165,7 @@ RimPolygonInView* RimPolygonTools::findPolygonInView( RimPolygon* polygon, caf::
{
auto polyCollection = gridView->polygonInViewCollection();
for ( auto polygonInView : polyCollection->polygonsInView() )
for ( auto polygonInView : polyCollection->allPolygonsInView() )
{
if ( polygonInView && polygonInView->polygon() == polygon )
{

View File

@ -21,6 +21,8 @@
class RimPolygon;
class RimPolygonInView;
class QString;
namespace caf
{
class PdmObject;
@ -29,7 +31,12 @@ class PdmObject;
class RimPolygonTools
{
public:
static void selectAndActivatePolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
static void activate3dEditOfPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
static void selectPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
static bool exportPolygonCsv( const RimPolygon* polygon, const QString& filePath );
static bool exportPolygonPol( const RimPolygon* polygon, const QString& filePath );
static QString polygonCacheName();
private:
static RimPolygonInView* findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );

View File

@ -23,6 +23,7 @@
#include "cafPdmFieldCapability.h"
#include <QApplication>
#include <QProcess>
#include <QProcessEnvironment>

View File

@ -1706,18 +1706,19 @@ void Rim3dView::appendMeasurementToModel()
{
if ( !nativeOrOverrideViewer() ) return;
cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() );
if ( frameScene )
const cvf::String name = "Measurement";
cvf::Scene* scene = nativeOrOverrideViewer()->currentScene( isUsingOverrideViewer() );
if ( scene )
{
cvf::String name = "Measurement";
this->removeModelByName( frameScene, name );
Rim3dView::removeModelByName( scene, name );
cvf::ref<cvf::ModelBasicList> model = new cvf::ModelBasicList;
model->setName( name );
addMeasurementToModel( model.p() );
frameScene->addModel( model.p() );
scene->addModel( model.p() );
}
}

View File

@ -23,7 +23,6 @@
#include "PlotTemplates/RimPlotTemplateFileItem.h"
#include "PlotTemplates/RimPlotTemplateFolderItem.h"
#include "Polygons/RimPolygonCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "Rim3dWellLogCurveCollection.h"
#include "Rim3dWellLogExtractionCurve.h"
@ -1139,11 +1138,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << "RicAddGridCalculationFeature";
}
else if ( dynamic_cast<RimPolygonCollection*>( firstUiItem ) )
{
menuBuilder << "RicNewPolygonFeature";
menuBuilder << "RicNewPolygonFileFeature";
}
if ( dynamic_cast<Rim3dView*>( firstUiItem ) )
{

View File

@ -49,7 +49,6 @@
#include "RimEclipseInputPropertyCollection.h"
#include "RimEclipseView.h"
#include "RimFlowDiagSolution.h"
#include "RimIntersectionCollection.h"
#include "RimMockModelSettings.h"
#include "RimProject.h"
#include "RimReservoirCellResultsStorage.h"
@ -62,9 +61,11 @@
#include "cafProgressInfo.h"
#include "cafUtils.h"
#include <QApplication>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <fstream>
#include <string>
@ -660,7 +661,6 @@ void RimEclipseResultCase::fieldChangedByUi( const caf::PdmFieldHandle* changedF
{
resView->scheduleSimWellGeometryRegen();
resView->scheduleCreateDisplayModelAndRedraw();
resView->intersectionCollection()->recomputeSimWellBranchData();
}
}

View File

@ -1981,16 +1981,13 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
if ( faultReactivationModelCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( faultReactivationModelCollection() );
uiTreeOrdering.add( annotationCollection() );
uiTreeOrdering.add( intersectionCollection() );
uiTreeOrdering.add( m_polygonInViewCollection );
if ( surfaceInViewCollection() ) uiTreeOrdering.add( surfaceInViewCollection() );
if ( seismicSectionCollection()->shouldBeVisibleInTree() ) uiTreeOrdering.add( seismicSectionCollection() );
if ( RiaApplication::enableDevelopmentFeatures() )
{
uiTreeOrdering.add( m_polygonInViewCollection );
}
uiTreeOrdering.add( annotationCollection() );
uiTreeOrdering.skipRemainingChildren( true );
}

View File

@ -609,10 +609,13 @@ std::vector<double> RimGridCalculation::getDataForResult( const QString&
values[i] = resultAccessor->cellScalarGlobIdx( activeReservoirCells[i] );
}
auto categoriesToExclude = { RiaDefines::ResultCatType::GENERATED };
if ( m_releaseMemoryAfterDataIsExtracted )
{
auto categoriesToExclude = { RiaDefines::ResultCatType::GENERATED };
sourceCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse );
sourceCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse );
sourceCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse );
sourceCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse );
}
return values;
}
@ -782,6 +785,9 @@ bool RimGridCalculation::calculateForCases( const std::vector<RimEclipseCase*>&
m_expression().contains( "min" ) || m_expression().contains( "max" ) ||
m_expression().contains( "count" );
// If multiple cases are present, release memory after data is extracted to avoid memory issues.
m_releaseMemoryAfterDataIsExtracted = isMultipleCasesPresent;
if ( isMultipleCasesPresent )
{
QString txt = "Starting calculation '" + description() + "' for " + QString::number( calculationCases.size() ) + " cases.";

View File

@ -155,4 +155,6 @@ private:
caf::PdmField<bool> m_editNonVisibleResultAddress;
caf::PdmField<bool> m_applyToAllCases_OBSOLETE;
bool m_releaseMemoryAfterDataIsExtracted = false;
};

View File

@ -405,16 +405,9 @@ void RimGridView::appendPolygonPartsToModel( caf::DisplayCoordTransform* scaleTr
m_polygonVizModel->removeAllParts();
std::vector<RimPolygonInView*> polygonsInView;
if ( m_polygonInViewCollection && m_polygonInViewCollection->isChecked() )
if ( m_polygonInViewCollection )
{
auto candidates = m_polygonInViewCollection->polygonsInView();
for ( auto polygonInView : candidates )
{
if ( polygonInView->isChecked() )
{
polygonsInView.push_back( polygonInView );
}
}
polygonsInView = m_polygonInViewCollection->visiblePolygonsInView();
}
if ( cellFilterCollection() && cellFilterCollection()->isActive() )
@ -534,7 +527,7 @@ void RimGridView::updateViewTreeItems( RiaDefines::ItemIn3dView itemType )
if ( bitmaskEnum.AnyOf( RiaDefines::ItemIn3dView::POLYGON ) )
{
m_polygonInViewCollection->syncPolygonsInView();
m_polygonInViewCollection->updateFromPolygonCollection();
}
updateConnectedEditors();

Some files were not shown because too many files have changed in this diff Show More