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

This commit is contained in:
Jørgen Herje
2024-02-27 12:48:43 +01:00
186 changed files with 3704 additions and 1204 deletions

View File

@@ -87,7 +87,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r GrpcInterface/Python/requirements.txt
pip install -r GrpcInterface/Python/dev-requirements.txt
- name: Use CMake
uses: lukka/get-cmake@latest

View File

@@ -277,14 +277,15 @@
<file>SeismicDelta16x16.png</file>
<file>SeismicView16x16.png</file>
<file>SeismicView24x24.png</file>
<file>SeismicViews24x24.png</file>
<file>SeismicData24x24.png</file>
<file>SeismicSection16x16.png</file>
<file>Fullscreen.png</file>
<file>SeismicViews24x24.png</file>
<file>SeismicData24x24.png</file>
<file>SeismicSection16x16.png</file>
<file>Fullscreen.png</file>
<file>plot-template-standard.svg</file>
<file>plot-template-ensemble.svg</file>
<file>decline-curve.svg</file>
<file>regression-curve.svg</file>
<file>padlock.svg</file>
</qresource>
<qresource prefix="/Shader">
<file>fs_CellFace.glsl</file>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg fill="#000000" height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 485 485" xml:space="preserve">
<g>
<path d="M345,175v-72.5C345,45.981,299.019,0,242.5,0S140,45.981,140,102.5V175H70v310h345V175H345z M170,102.5
c0-39.977,32.523-72.5,72.5-72.5S315,62.523,315,102.5V175H170V102.5z M385,455H100V205h285V455z"/>
<path d="M227.5,338.047v53.568h30v-53.569c11.814-5.628,20-17.682,20-31.616c0-19.299-15.701-35-35-35c-19.299,0-35,15.701-35,35
C207.5,320.365,215.686,332.42,227.5,338.047z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 727 B

View File

@@ -48,7 +48,7 @@ RiaApplication* createApplication( int& argc, char* argv[] )
{
for ( int i = 1; i < argc; ++i )
{
if ( !qstrcmp( argv[i], "--console" ) || !qstrcmp( argv[i], "--unittest" ) || !qstrcmp( argv[i], "--version" ) )
if ( !qstrcmp( argv[i], "--console" ) || !qstrcmp( argv[i], "--unittest" ) )
{
#ifdef ENABLE_GRPC
return new RiaGrpcConsoleApplication( argc, argv );

View File

@@ -34,3 +34,5 @@
#define RESINSIGHT_OCTAVE_VERSION "@OCTAVE_VERSION_STRING@"
#define RESINSIGHT_PYTHON_VERSION "@Python3_VERSION@"
#define RESINSIGHT_GIT_HASH "@RESINSIGHT_GIT_HASH@"

View File

@@ -40,6 +40,8 @@
#include "RicfCommandObject.h"
#include "PlotTemplates/RimPlotTemplateFolderItem.h"
#include "Polygons/RimPolygonCollection.h"
#include "Rim2dIntersectionViewCollection.h"
#include "RimAnnotationCollection.h"
#include "RimAnnotationInViewCollection.h"
@@ -544,6 +546,8 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
{
seismicData->ensureFileReaderIsInitialized();
}
oilField->polygonCollection()->loadData();
}
{
@@ -658,7 +662,10 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
}
}
setActiveReservoirView( riv );
if ( riv->showWindow() )
{
setActiveReservoirView( riv );
}
RimGridView* rigv = dynamic_cast<RimGridView*>( riv );
if ( rigv ) rigv->cellFilterCollection()->updateIconState();

View File

@@ -131,6 +131,7 @@ RiaApplication::ApplicationStatus RiaConsoleApplication::handleArguments( gsl::n
if ( progOpt->option( "version" ) )
{
QString text = QString( STRPRODUCTVER ) + "\n";
text += "SHA " + QString( RESINSIGHT_GIT_HASH ) + "\n";
showFormattedTextInMessageBoxOrConsole( text );

View File

@@ -243,8 +243,17 @@ enum class View3dContent
ALL = 0b00011111
};
enum class ItemIn3dView
{
NONE = 0b00000000,
SURFACE = 0b00000001,
POLYGON = 0b00000010,
ALL = 0b00000011
};
}; // namespace RiaDefines
// Activate bit mask operators at global scope
ENABLE_BITMASK_OPERATORS( RiaDefines::MultiPlotPageUpdateType )
ENABLE_BITMASK_OPERATORS( RiaDefines::View3dContent )
ENABLE_BITMASK_OPERATORS( RiaDefines::ItemIn3dView )

View File

@@ -463,6 +463,16 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n
return RiaApplication::ApplicationStatus::EXIT_COMPLETED;
}
if ( progOpt->option( "version" ) )
{
QString text = QString( STRPRODUCTVER ) + "\n";
text += "SHA " + QString( RESINSIGHT_GIT_HASH ) + "\n";
showFormattedTextInMessageBoxOrConsole( text );
return RiaApplication::ApplicationStatus::EXIT_COMPLETED;
}
// Code generation
// -----------------
if ( cvf::Option o = progOpt->option( "generate" ) )

View File

@@ -59,10 +59,10 @@ RiaMemoryCleanup::RiaMemoryCleanup()
m_resultsToDelete.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_performDelete, "ClearSelectedData", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_performDelete );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_performDelete );
CAF_PDM_InitFieldNoDefault( &m_showMemoryReport, "ShowMemoryReport", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_showMemoryReport );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_showMemoryReport );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -121,8 +121,7 @@ RiaPreferencesSummary::RiaPreferencesSummary()
"" );
CAF_PDM_InitField( &m_selectDefaultTemplates, "selectDefaultTemplate", false, "", "", "Select Default Templates" );
m_selectDefaultTemplates.xmlCapability()->disableIO();
m_selectDefaultTemplates.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_selectDefaultTemplates );
CAF_PDM_InitFieldNoDefault( &m_selectedDefaultTemplates, "defaultSummaryTemplates", "Select Summary Plot Templates" );
m_selectedDefaultTemplates.uiCapability()->setUiReadOnly( true );

View File

@@ -595,5 +595,9 @@ std::vector<QString> RiaResultNames::wbsDerivedResultNames()
wbsSHMkMaxResult(),
wbsFGMkExpResult(),
wbsFGMkMinResult(),
wbsPPMinResult(),
wbsPPMaxResult(),
wbsPPExpResult(),
wbsPPInitialResult(),
};
}

View File

@@ -123,6 +123,7 @@ list(
ProjectDataModel/Intersections/CMakeLists_files.cmake
ProjectDataModel/CellFilters/CMakeLists_files.cmake
ProjectDataModel/ProcessControl/CMakeLists_files.cmake
ProjectDataModel/Polygons/CMakeLists_files.cmake
ProjectDataModel/WellLog/CMakeLists_files.cmake
ProjectDataModel/WellMeasurement/CMakeLists_files.cmake
ProjectDataModel/WellPath/CMakeLists_files.cmake

View File

@@ -41,6 +41,7 @@ set(COMMAND_REFERENCED_CMAKE_FILES
PlotTemplateCommands/CMakeLists_files.cmake
FractureCommands/CMakeLists_files.cmake
PlotBuilderCommands/CMakeLists_files.cmake
PolygonCommands/CMakeLists_files.cmake
)
# Include source file lists from *.cmake files

View File

@@ -18,6 +18,8 @@
#include "RicNewPolygonFilter3dviewFeature.h"
#include "Polygons/RimPolygonInView.h"
#include "RiaApplication.h"
#include "RimCase.h"
#include "RimCellFilterCollection.h"
@@ -46,7 +48,7 @@ void RicNewPolygonFilter3dviewFeature::onActionTriggered( bool isChecked )
// and the case to use
RimCase* sourceCase = viewOrComparisonView->ownerCase();
RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase );
RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase, nullptr );
if ( lastCreatedOrUpdated )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );

View File

@@ -18,9 +18,16 @@
#include "RicNewPolygonFilterFeature.h"
#include "RiaApplication.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonInView.h"
#include "RimCase.h"
#include "RimCellFilterCollection.h"
#include "RimGridView.h"
#include "RimPolygonFilter.h"
#include "Riu3DMainWindowTools.h"
#include "cafSelectionManagerTools.h"
@@ -35,16 +42,31 @@ CAF_CMD_SOURCE_INIT( RicNewPolygonFilterFeature, "RicNewPolygonFilterFeature" );
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked )
{
// Find the selected Cell Filter Collection
std::vector<RimCellFilterCollection*> colls = caf::selectedObjectsByTypeStrict<RimCellFilterCollection*>();
if ( colls.empty() ) return;
RimCellFilterCollection* filtColl = colls[0];
auto cellFilterCollection = caf::SelectionManager::instance()->selectedItemOfType<RimCellFilterCollection>();
// and the case to use
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<RimCase>();
if ( !cellFilterCollection )
{
RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView();
if ( activeView )
{
cellFilterCollection = activeView->cellFilterCollection();
}
}
RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase );
if ( lastCreatedOrUpdated )
if ( !cellFilterCollection ) return;
auto polygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>();
if ( !polygon )
{
if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>() )
{
polygon = polygonInView->polygon();
}
}
auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted<RimCase>();
if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
}

View File

@@ -6,6 +6,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonIntersectionFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@@ -16,6 +17,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonIntersectionFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewPolygonIntersectionFeature.h"
#include "RiaApplication.h"
#include "RimExtrudedCurveIntersection.h"
#include "RimGridView.h"
#include "RimIntersectionCollection.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonInView.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewPolygonIntersectionFeature, "RicNewPolygonIntersectionFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonIntersectionFeature::onActionTriggered( bool isChecked )
{
RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView();
if ( !activeView ) return;
auto collection = activeView->intersectionCollection();
if ( !collection ) return;
auto polygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>();
if ( !polygon )
{
if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>() )
{
polygon = polygonInView->polygon();
}
}
auto intersection = new RimExtrudedCurveIntersection();
intersection->configureForProjectPolyLine( polygon );
collection->appendIntersectionAndUpdate( intersection );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonIntersectionFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/CrossSection16x16.png" ) );
actionToSetup->setText( "Create Polygon Intersection" );
}

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- Equinor ASA
// 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
@@ -23,12 +23,11 @@
//==================================================================================================
///
//==================================================================================================
class RicAppendPointsToPolygonFilterFeature : public caf::CmdFeature
class RicNewPolygonIntersectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,19 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFileFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonFileFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
source_group(
"CommandFeature\\Polygons"
FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES}
${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake
)

View File

@@ -0,0 +1,54 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewPolygonFeature.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RiuPlotMainWindowTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewPolygonFeature, "RicNewPolygonFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFeature::onActionTriggered( bool isChecked )
{
auto proj = RimProject::current();
auto polygonCollection = proj->activeOilField()->polygonCollection();
auto newPolygon = polygonCollection->appendUserDefinedPolygon();
polygonCollection->uiCapability()->updateAllRequiredEditors();
RiuPlotMainWindowTools::setExpanded( newPolygon );
RiuPlotMainWindowTools::selectAsCurrentItem( newPolygon );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New 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 RicNewPolygonFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,57 @@
////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewPolygonFileFeature.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonFile.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RiuPlotMainWindowTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewPolygonFileFeature, "RicNewPolygonFileFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFileFeature::onActionTriggered( bool isChecked )
{
auto proj = RimProject::current();
auto polygonCollection = proj->activeOilField()->polygonCollection();
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 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFileFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New File 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 RicNewPolygonFileFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -91,7 +91,9 @@ bool RicUserDefinedCalculatorUi::parseExpression() const
notifyCalculatedNameChanged( m_currentCalculation()->id(), currentCurveName );
}
m_currentCalculation()->updateDependentObjects();
// Always rebuild the case meta data after parsing the expression. A change in name or change in result type will require rebuild of
// case metadata. The rebuild is considered lightweight and should not be a performance issue.
calculationCollection()->rebuildCaseMetaData();
}
return true;
@@ -198,8 +200,7 @@ void RicUserDefinedCalculatorUi::assignPushButtonEditor( caf::PdmFieldHandle* fi
CAF_ASSERT( fieldHandle );
CAF_ASSERT( fieldHandle->uiCapability() );
fieldHandle->uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
fieldHandle->uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( fieldHandle );
}
//--------------------------------------------------------------------------------------------------
@@ -221,17 +222,7 @@ bool RicUserDefinedCalculatorUi::calculate() const
{
if ( m_currentCalculation() )
{
QString previousCurveName = m_currentCalculation->description();
if ( !m_currentCalculation()->parseExpression() )
{
return false;
}
QString currentCurveName = m_currentCalculation->description();
if ( previousCurveName != currentCurveName )
{
notifyCalculatedNameChanged( m_currentCalculation()->id(), currentCurveName );
}
if ( !parseExpression() ) return false;
if ( !m_currentCalculation()->preCalculate() )
{

View File

@@ -47,6 +47,7 @@ bool RicSeismicSectionFromIntersectionFeature::isCommandEnabled() const
if ( intersection != nullptr )
{
return ( ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ) ||
( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON ) ||
( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_WELL_PATH ) );
}
@@ -70,7 +71,8 @@ void RicSeismicSectionFromIntersectionFeature::onActionTriggered( bool isChecked
RimSeismicSection* newSection = seisColl->addNewSection();
if ( !newSection ) return;
if ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE )
if ( ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ) ||
( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON ) )
{
newSection->setSectionType( RiaDefines::SeismicSectionType::SS_POLYLINE );
newSection->setUserDescription( intersection->name() );

View File

@@ -56,6 +56,7 @@
#include "cafProgressInfo.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include "cvfColor3.h"
#include "cvfMath.h"
#include <QAction>
@@ -63,6 +64,7 @@
#include <QString>
#include <algorithm>
#include <set>
CAF_CMD_SOURCE_INIT( RicNewWellBoreStabilityPlotFeature, "RicNewWellBoreStabilityPlotFeature" );
@@ -262,7 +264,7 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi
paramCurvesTrack->setFormationCase( geoMechCase );
paramCurvesTrack->setShowRegionLabels( true );
paramCurvesTrack->setShowWindow( false );
std::set<RigWbsParameter> parameters = RigWbsParameter::allParameters();
std::set<RigWbsParameter> parameters = parametersForTrack();
caf::ColorTable colors = RiaColorTables::contrastCategoryPaletteColors();
std::vector<RiuQwtPlotCurveDefines::LineStyleEnum> lineStyles = { RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID,
@@ -321,6 +323,15 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
std::vector<RiuQwtPlotCurveDefines::LineStyleEnum> lineStyles( resultNames.size(), RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
lineStyles.back() = RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH;
std::set<QString> defaultOffResults = {
RiaResultNames::wbsSHMkResult(),
RiaResultNames::wbsSHMkExpResult(),
RiaResultNames::wbsSHMkMinResult(),
RiaResultNames::wbsSHMkMaxResult(),
RiaResultNames::wbsFGMkExpResult(),
RiaResultNames::wbsFGMkMinResult(),
};
for ( size_t i = 0; i < resultNames.size(); ++i )
{
const QString& resultName = resultNames[i];
@@ -330,13 +341,14 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
curve->setGeoMechResultAddress( resAddr );
curve->setCurrentTimeStep( timeStep );
curve->setAutoNameComponents( false, true, false, false, false );
curve->setColor( colors[i % colors.size()] );
curve->setLineStyle( lineStyles[i] );
auto [color, lineStyle] = getColorAndLineStyle( resultName, i, colors );
curve->setColor( color );
curve->setLineStyle( lineStyle );
curve->setLineThickness( 2 );
curve->loadDataAndUpdate( false );
curve->setSmoothCurve( true );
curve->setSmoothingThreshold( 0.002 );
if ( resultNames[i] == RiaResultNames::wbsSHMkResult() )
if ( defaultOffResults.count( resultNames[i] ) )
{
curve->setCheckState( false );
}
@@ -361,6 +373,34 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
stabilityCurvesTrack->setAutoScalePropertyValuesEnabled( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<cvf::Color3f, RiuQwtPlotCurveDefines::LineStyleEnum>
RicNewWellBoreStabilityPlotFeature::getColorAndLineStyle( const QString& resultName, size_t i, const std::vector<cvf::Color3f>& colors )
{
if ( resultName == RiaResultNames::wbsSHMkResult() ) return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID };
if ( resultName == RiaResultNames::wbsSHMkExpResult() )
return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH };
if ( resultName == RiaResultNames::wbsSHMkMinResult() )
return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT };
if ( resultName == RiaResultNames::wbsSHMkMaxResult() )
return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT };
if ( resultName == RiaResultNames::wbsFGMkExpResult() )
return { cvf::Color3f::BLUE, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH };
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 };
if ( resultName == RiaResultNames::wbsPPMaxResult() )
return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT };
return { colors[i % colors.size()], RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -408,3 +448,22 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability
wellPathAnglesTrack->setAnnotationDisplay( RiaDefines::LIGHT_LINES );
wellPathAnglesTrack->setShowRegionLabels( false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RigWbsParameter> RicNewWellBoreStabilityPlotFeature::parametersForTrack()
{
return { RigWbsParameter::PP_Reservoir(),
RigWbsParameter::PP_NonReservoir(),
RigWbsParameter::poissonRatio(),
RigWbsParameter::UCS(),
RigWbsParameter::OBG(),
RigWbsParameter::OBG0(),
RigWbsParameter::SH(),
RigWbsParameter::DF(),
RigWbsParameter::K0_FG(),
RigWbsParameter::K0_SH(),
RigWbsParameter::FG_Shale(),
RigWbsParameter::waterDensity() };
}

View File

@@ -20,6 +20,14 @@
#include "cafCmdFeature.h"
#include "RigWbsParameter.h"
#include "RimPlotCurveAppearance.h"
#include "cvfColor3.h"
#include <set>
class RimGeoMechCase;
class RimGeoMechView;
class RimWbsParameters;
@@ -48,4 +56,8 @@ private:
static void createParametersTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase, int timeStep );
static void createStabilityCurvesTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase, int timeStep );
static void createAnglesTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase, int timeStep );
static std::set<RigWbsParameter> parametersForTrack();
static std::pair<cvf::Color3f, RiuQwtPlotCurveDefines::LineStyleEnum>
getColorAndLineStyle( const QString& resultName, size_t i, const std::vector<cvf::Color3f>& colors );
};

View File

@@ -30,7 +30,6 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h
${CMAKE_CURRENT_LIST_DIR}/RicAppendPointsToPolygonFilterFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.h
)
@@ -66,7 +65,6 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulatorPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolyline3dEditor.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAppendPointsToPolygonFilterFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.cpp
)

View File

@@ -62,7 +62,7 @@ void RicPolyline3dEditor::configureAndUpdateUi( const QString& uiConfigName )
}
m_targetEditors.clear();
if ( !pickerInterface ) return;
if ( !pickerInterface || !pickerInterface->pickEventHandler() ) return;
if ( pickerInterface->pickingEnabled() )
{

View File

@@ -21,10 +21,8 @@
#include "RicPointTangentManipulator.h"
#include "Rim3dView.h"
#include "RimAnnotationCollectionBase.h"
#include "RimCase.h"
#include "RimPolylinePickerInterface.h"
#include "RimPolylineTarget.h"
#include "RimUserDefinedPolylinesAnnotation.h"
#include "RiuViewer.h"
@@ -57,7 +55,7 @@ RicPolylineTarget3dEditor::~RicPolylineTarget3dEditor()
ownerRiuViewer->removeStaticModel( m_cvfModel.p() );
}
RimPolylineTarget* oldTarget = dynamic_cast<RimPolylineTarget*>( pdmObject() );
auto* oldTarget = dynamic_cast<RimPolylineTarget*>( pdmObject() );
if ( oldTarget )
{
oldTarget->targetPointUiCapability()->removeFieldEditor( this );
@@ -71,11 +69,11 @@ RicPolylineTarget3dEditor::~RicPolylineTarget3dEditor()
//--------------------------------------------------------------------------------------------------
void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
{
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( pdmObject() );
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
Rim3dView* view = mainOrComparisonView();
auto* target = dynamic_cast<RimPolylineTarget*>( pdmObject() );
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
Rim3dView* view = mainOrComparisonView();
if ( !target || !target->isEnabled() || !view )
if ( !target || !view )
{
if ( m_cvfModel.notNull() ) m_cvfModel->removeAllParts();
@@ -97,11 +95,17 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigNam
ownerRiuViewer->addStaticModelOnce( m_cvfModel.p(), isInComparisonView() );
}
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
double handleSize = 0.7 * view->characteristicCellSize();
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
double scalingFactor = 0.7;
if ( auto pickerInterface = target->firstAncestorOrThisOfType<RimPolylinePickerInterface>() )
{
scalingFactor *= pickerInterface->scalingFactorForTarget();
}
const double handleSize = scalingFactor * view->characteristicCellSize();
m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() ) );
// m_manipulator->setTangent(target->tangent());
m_manipulator->setHandleSize( handleSize );
m_cvfModel->removeAllParts();
m_manipulator->appendPartsToModel( m_cvfModel.p() );
@@ -114,7 +118,7 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigNam
//--------------------------------------------------------------------------------------------------
void RicPolylineTarget3dEditor::cleanupBeforeSettingPdmObject()
{
RimPolylineTarget* oldTarget = dynamic_cast<RimPolylineTarget*>( pdmObject() );
auto* oldTarget = dynamic_cast<RimPolylineTarget*>( pdmObject() );
if ( oldTarget )
{
oldTarget->targetPointUiCapability()->removeFieldEditor( this );
@@ -126,8 +130,8 @@ void RicPolylineTarget3dEditor::cleanupBeforeSettingPdmObject()
//--------------------------------------------------------------------------------------------------
void RicPolylineTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Vec3d& tangent )
{
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( pdmObject() );
Rim3dView* view = mainOrComparisonView();
auto* target = dynamic_cast<RimPolylineTarget*>( pdmObject() );
Rim3dView* view = mainOrComparisonView();
if ( !target || !view )
{
@@ -140,9 +144,7 @@ void RicPolylineTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf
domainOrigin.z() = -domainOrigin.z();
QVariant originVariant = caf::PdmValueFieldSpecialization<cvf::Vec3d>::convert( domainOrigin );
target->enableFullUpdate( false );
caf::PdmUiCommandSystemProxy::instance()->setUiValueToField( target->targetPointUiCapability(), originVariant );
target->enableFullUpdate( true );
}
//--------------------------------------------------------------------------------------------------
@@ -150,7 +152,7 @@ void RicPolylineTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf
//--------------------------------------------------------------------------------------------------
void RicPolylineTarget3dEditor::slotSelectedIn3D()
{
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( pdmObject() );
auto* target = dynamic_cast<RimPolylineTarget*>( pdmObject() );
if ( !target )
{
return;
@@ -164,7 +166,7 @@ void RicPolylineTarget3dEditor::slotSelectedIn3D()
//--------------------------------------------------------------------------------------------------
void RicPolylineTarget3dEditor::slotDragFinished()
{
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( pdmObject() );
auto* target = dynamic_cast<RimPolylineTarget*>( pdmObject() );
if ( target )
{
target->triggerVisualizationUpdate();

View File

@@ -25,13 +25,14 @@ class RicPointTangentManipulator;
#include "cvfObject.h"
#include "cvfVector3.h"
#include <QPointer>
namespace cvf
{
class ModelBasicList;
}
class QString;
#include <QPointer>
class RicPolylineTarget3dEditor : public Ric3dObjectEditorHandle
{

View File

@@ -1,83 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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 "RicAppendPointsToPolygonFilterFeature.h"
#include "RiaTextStringTools.h"
#include "RimPolygonFilter.h"
#include "RimPolylineTarget.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
#include <QClipboard>
CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPolygonFilterFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicAppendPointsToPolygonFilterFeature::isCommandEnabled() const
{
auto obj = caf::firstAncestorOfTypeFromSelectedObject<RimPolygonFilter>();
return obj != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendPointsToPolygonFilterFeature::onActionTriggered( bool isChecked )
{
auto polygonFilter = caf::firstAncestorOfTypeFromSelectedObject<RimPolygonFilter>();
if ( !polygonFilter ) return;
QStringList listOfThreeDoubles;
QClipboard* clipboard = QApplication::clipboard();
if ( clipboard )
{
QString content = clipboard->text();
listOfThreeDoubles = RiaTextStringTools::splitSkipEmptyParts( content, "\n" );
}
std::vector<cvf::Vec3d> points;
caf::PdmValueFieldSpecialization<std::vector<cvf::Vec3d>>::setFromVariant( listOfThreeDoubles, points );
for ( const auto& p : points )
{
auto newTarget = new RimPolylineTarget;
newTarget->setAsPointTargetXYD( p );
polygonFilter->insertTarget( nullptr, newTarget );
}
polygonFilter->updateEditorsAndVisualization();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendPointsToPolygonFilterFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Append Points from Clipboard" );
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
}

View File

@@ -18,9 +18,6 @@
#include "RicCreateWellTargetsPickEventHandler.h"
#include "RiaGuiApplication.h"
#include "RiaOffshoreSphericalCoords.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
@@ -30,6 +27,7 @@
#include "RigWellPathGeometryTools.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimEclipseView.h"
#include "RimGeoMechView.h"
#include "RimModeledWellPath.h"
@@ -47,10 +45,6 @@
#include "cafDisplayCoordTransform.h"
#include "cafSelectionManager.h"
#include "cvfStructGridGeometryGenerator.h"
#include <QDebug>
#include <vector>
//--------------------------------------------------------------------------------------------------
@@ -130,7 +124,14 @@ bool RicCreateWellTargetsPickEventHandler::handle3dPickEvent( const Ric3dPickEve
doSetAzimuthAndInclination = false;
cvf::Vec3d domainRayOrigin = rimView->displayCoordTransform()->transformToDomainCoord( firstPickItem.globalRayOrigin() );
cvf::Vec3d domainRayEnd = targetPointInDomain + ( targetPointInDomain - domainRayOrigin );
auto rayVector = ( targetPointInDomain - domainRayOrigin );
const double minimumRayLength = rimView->ownerCase()->characteristicCellSize() * 2;
if ( rayVector.length() < minimumRayLength )
{
rayVector = rayVector.getNormalized() * minimumRayLength;
}
cvf::Vec3d domainRayEnd = targetPointInDomain + rayVector;
cvf::Vec3d hexElementIntersection = findHexElementIntersection( rimView, firstPickItem, domainRayOrigin, domainRayEnd );
CVF_TIGHT_ASSERT( !hexElementIntersection.isUndefined() );
@@ -255,22 +256,27 @@ cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection( gsl
{
std::vector<HexIntersectionInfo> intersectionInfo;
RigHexIntersectionTools::lineHexCellIntersection( domainRayOrigin, domainRayEnd, cornerVertices.data(), cellIndex, &intersectionInfo );
if ( !intersectionInfo.empty() )
if ( intersectionInfo.empty() ) return cvf::Vec3d::UNDEFINED;
if ( intersectionInfo.size() == 1 )
{
// Sort intersection on distance to ray origin
CVF_ASSERT( intersectionInfo.size() > 1 );
std::sort( intersectionInfo.begin(),
intersectionInfo.end(),
[&domainRayOrigin]( const HexIntersectionInfo& lhs, const HexIntersectionInfo& rhs ) {
return ( lhs.m_intersectionPoint - domainRayOrigin ).lengthSquared() <
( rhs.m_intersectionPoint - domainRayOrigin ).lengthSquared();
} );
const double eps = 1.0e-2;
cvf::Vec3d intersectionRay = intersectionInfo.back().m_intersectionPoint - intersectionInfo.front().m_intersectionPoint;
cvf::Vec3d newPoint = intersectionInfo.front().m_intersectionPoint + intersectionRay * eps;
CVF_ASSERT( RigHexIntersectionTools::isPointInCell( newPoint, cornerVertices.data() ) );
return newPoint;
return intersectionInfo.front().m_intersectionPoint;
}
// Sort intersection on distance to ray origin
std::sort( intersectionInfo.begin(),
intersectionInfo.end(),
[&domainRayOrigin]( const HexIntersectionInfo& lhs, const HexIntersectionInfo& rhs ) {
return ( lhs.m_intersectionPoint - domainRayOrigin ).lengthSquared() <
( rhs.m_intersectionPoint - domainRayOrigin ).lengthSquared();
} );
const double eps = 1.0e-2;
cvf::Vec3d intersectionRay = intersectionInfo.back().m_intersectionPoint - intersectionInfo.front().m_intersectionPoint;
cvf::Vec3d newPoint = intersectionInfo.front().m_intersectionPoint + intersectionRay * eps;
CVF_ASSERT( RigHexIntersectionTools::isPointInCell( newPoint, cornerVertices.data() ) );
return newPoint;
}
return cvf::Vec3d::UNDEFINED;
}

View File

@@ -44,44 +44,41 @@ bool RicIntersectionPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& e
std::vector<RimExtrudedCurveIntersection*> selection;
caf::SelectionManager::instance()->objectsByType( &selection );
if ( selection.size() == 1 )
if ( selection.size() != 1 ) return false;
RimExtrudedCurveIntersection* intersection = selection[0];
RimGridView* gridView = intersection->firstAncestorOrThisOfTypeAsserted<RimGridView>();
if ( RiaApplication::instance()->activeMainOrComparisonGridView() != gridView )
{
{
RimExtrudedCurveIntersection* intersection = selection[0];
return false;
}
RimGridView* gridView = intersection->firstAncestorOrThisOfTypeAsserted<RimGridView>();
cvf::ref<caf::DisplayCoordTransform> transForm = gridView->displayCoordTransform();
if ( RiaApplication::instance()->activeMainOrComparisonGridView() != gridView )
{
return false;
}
cvf::Vec3d domainCoord = transForm->transformToDomainCoord( eventObject.m_pickItemInfos.front().globalPickedPoint() );
cvf::ref<caf::DisplayCoordTransform> transForm = gridView->displayCoordTransform();
if ( intersection->inputPolyLineFromViewerEnabled() )
{
intersection->appendPointToPolyLine( domainCoord );
cvf::Vec3d domainCoord = transForm->transformToDomainCoord( eventObject.m_pickItemInfos.front().globalPickedPoint() );
// Further Ui processing is stopped when true is returned
return true;
}
else if ( intersection->inputExtrusionPointsFromViewerEnabled() )
{
intersection->appendPointToExtrusionDirection( domainCoord );
if ( intersection->inputPolyLineFromViewerEnabled() )
{
intersection->appendPointToPolyLine( domainCoord );
// Further Ui processing is stopped when true is returned
return true;
}
else if ( intersection->inputTwoAzimuthPointsFromViewerEnabled() )
{
intersection->appendPointToAzimuthLine( domainCoord );
// Further Ui processing is stopped when true is returned
return true;
}
else if ( intersection->inputExtrusionPointsFromViewerEnabled() )
{
intersection->appendPointToExtrusionDirection( domainCoord );
// Further Ui processing is stopped when true is returned
return true;
}
else if ( intersection->inputTwoAzimuthPointsFromViewerEnabled() )
{
intersection->appendPointToAzimuthLine( domainCoord );
// Further Ui processing is stopped when true is returned
return true;
}
}
// Further Ui processing is stopped when true is returned
return true;
}
return false;

View File

@@ -21,21 +21,23 @@ CAF_CMD_SOURCE_INIT( RicNewPolylineTargetFeature, "RicNewPolylineTargetFeature"
#include "RimCase.h"
#include "RimGridView.h"
#include "RimPolylinePickerInterface.h"
#include "RimPolylineTarget.h"
#include "RimProject.h"
#include "RimUserDefinedPolylinesAnnotation.h"
#include "cafSelectionManager.h"
#include <QAction>
#include "cvfBoundingBox.h"
#include <QAction>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewPolylineTargetFeature::isCommandEnabled() const
{
{
std::vector<RimUserDefinedPolylinesAnnotation*> objects;
std::vector<RimPolylinePickerInterface*> objects;
caf::SelectionManager::instance()->objectsByType( &objects );
if ( !objects.empty() )
@@ -66,7 +68,7 @@ void RicNewPolylineTargetFeature::onActionTriggered( bool isChecked )
if ( !selectedTargets.empty() )
{
auto firstTarget = selectedTargets.front();
RimUserDefinedPolylinesAnnotation* polylineDef = firstTarget->firstAncestorOrThisOfTypeAsserted<RimUserDefinedPolylinesAnnotation>();
auto polylineDef = firstTarget->firstAncestorOrThisOfTypeAsserted<RimPolylinePickerInterface>();
auto afterBeforePair = polylineDef->findActiveTargetsAroundInsertionPoint( firstTarget );
@@ -109,49 +111,40 @@ void RicNewPolylineTargetFeature::onActionTriggered( bool isChecked )
return;
}
std::vector<RimUserDefinedPolylinesAnnotation*> polylineDefs;
std::vector<RimPolylinePickerInterface*> polylineDefs;
caf::SelectionManager::instance()->objectsByType( &polylineDefs );
if ( !polylineDefs.empty() )
{
auto* polylineDef = polylineDefs[0];
std::vector<RimPolylineTarget*> activeTargets = polylineDef->activeTargets();
cvf::Vec3d newPos = cvf::Vec3d::ZERO;
size_t targetCount = activeTargets.size();
if ( targetCount == 0 )
if ( targetCount > 1 )
{
newPos = activeTargets[targetCount - 1]->targetPointXYZ();
cvf::Vec3d nextLastToLast = newPos - activeTargets[targetCount - 2]->targetPointXYZ();
newPos += 0.5 * nextLastToLast;
}
else if ( targetCount > 0 )
{
newPos = activeTargets[targetCount - 1]->targetPointXYZ() + cvf::Vec3d( 0, 0, 200 );
}
else
{
auto defaultPos = cvf::Vec3d::ZERO;
// Set decent position
std::vector<RimGridView*> gridViews;
RimProject::current()->allVisibleGridViews( gridViews );
if ( !gridViews.empty() )
{
auto minPos = gridViews.front()->ownerCase()->allCellsBoundingBox().min();
defaultPos = minPos;
newPos = minPos;
}
polylineDef->appendTarget( defaultPos );
}
else
{
cvf::Vec3d newPos = cvf::Vec3d::ZERO;
if ( targetCount > 1 )
{
newPos = activeTargets[targetCount - 1]->targetPointXYZ();
cvf::Vec3d nextLastToLast = newPos - activeTargets[targetCount - 2]->targetPointXYZ();
newPos += 0.5 * nextLastToLast;
}
else if ( targetCount > 0 )
{
newPos = activeTargets[targetCount - 1]->targetPointXYZ() + cvf::Vec3d( 0, 0, 200 );
}
auto* newTarget = new RimPolylineTarget;
newTarget->setAsPointTargetXYD( { newPos[0], newPos[1], -newPos[2] } );
polylineDef->insertTarget( nullptr, newTarget );
}
auto* newTarget = new RimPolylineTarget;
newTarget->setAsPointTargetXYD( { newPos[0], newPos[1], -newPos[2] } );
polylineDef->insertTarget( nullptr, newTarget );
polylineDef->updateEditorsAndVisualization();
}

View File

@@ -56,7 +56,7 @@ public:
private:
int indexFromAddress( const RifEclipseSummaryAddress& resultAddress ) const;
void buildMetaData();
void buildMetaData() override;
private:
ecl_sum_type* m_ecl_sum;

View File

@@ -62,13 +62,13 @@ std::pair<bool, std::string> RifFaultReactivationModelExporter::exportToStream(
// The two parts are "mirrored", so face number 4 of the two parts should face eachother.
using FaultGridPart = RimFaultReactivation::GridPart;
std::map<std::pair<FaultGridPart, PartBorderSurface>, int> faces = { { { FaultGridPart::FW, PartBorderSurface::FaultSurface }, 4 },
{ { FaultGridPart::FW, PartBorderSurface::UpperSurface }, 4 },
{ { FaultGridPart::FW, PartBorderSurface::LowerSurface }, 4 },
std::map<std::pair<FaultGridPart, PartBorderSurface>, int> faces = { { { FaultGridPart::FW, PartBorderSurface::FaultSurface }, 5 },
{ { FaultGridPart::FW, PartBorderSurface::UpperSurface }, 5 },
{ { FaultGridPart::FW, PartBorderSurface::LowerSurface }, 5 },
{ { FaultGridPart::FW, PartBorderSurface::Seabed }, 2 },
{ { FaultGridPart::HW, PartBorderSurface::FaultSurface }, 4 },
{ { FaultGridPart::HW, PartBorderSurface::UpperSurface }, 4 },
{ { FaultGridPart::HW, PartBorderSurface::LowerSurface }, 4 },
{ { FaultGridPart::HW, PartBorderSurface::FaultSurface }, 5 },
{ { FaultGridPart::HW, PartBorderSurface::UpperSurface }, 5 },
{ { FaultGridPart::HW, PartBorderSurface::LowerSurface }, 5 },
{ { FaultGridPart::HW, PartBorderSurface::Seabed }, 2 } };
std::map<FaultGridPart, std::string> partNames = {
@@ -327,6 +327,7 @@ std::pair<bool, std::string>
double poissonNumber;
double permeability1;
double permeability2;
double expansion;
};
RifInpExportTools::printSectionComment( stream, "MATERIALS" );
@@ -334,7 +335,7 @@ std::pair<bool, std::string>
for ( auto [element, materialName] : materialNames )
{
std::array<double, 3> parameters = rimModel.materialParameters( element );
std::array<double, 4> parameters = rimModel.materialParameters( element );
// Incoming unit for Young's Modulus is GPa: convert to Pa.
double youngsModulus = RiaEclipseUnitTools::gigaPascalToPascal( parameters[0] );
@@ -345,12 +346,15 @@ std::pair<bool, std::string>
// Unit is already kg/m^3
double density = parameters[2];
double expansion = parameters[3];
materials.push_back( Material{ .name = materialName,
.density = density,
.youngsModulus = youngsModulus,
.poissonNumber = poissonNumber,
.permeability1 = 1e-09,
.permeability2 = 0.3 } );
.permeability2 = 0.3,
.expansion = expansion } );
}
for ( Material mat : materials )
@@ -378,6 +382,8 @@ std::pair<bool, std::string>
RifInpExportTools::printHeading( stream, "Permeability, specific=1." );
RifInpExportTools::printNumbers( stream, { mat.permeability1, mat.permeability2 } );
RifInpExportTools::printHeading( stream, "Expansion" );
RifInpExportTools::printNumbers( stream, { mat.expansion } );
}
if ( densityFromGrid )

View File

@@ -36,7 +36,7 @@ void RifMultipleSummaryReaders::addReader( RifSummaryReaderInterface* reader )
m_readers.push_back( reader );
rebuildMetaData();
buildMetaData();
}
//--------------------------------------------------------------------------------------------------
@@ -45,7 +45,7 @@ void RifMultipleSummaryReaders::addReader( RifSummaryReaderInterface* reader )
void RifMultipleSummaryReaders::removeReader( RifSummaryReaderInterface* reader )
{
m_readers.erase( reader );
rebuildMetaData();
buildMetaData();
}
//--------------------------------------------------------------------------------------------------
@@ -100,7 +100,7 @@ RiaDefines::EclipseUnitSystem RifMultipleSummaryReaders::unitSystem() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifMultipleSummaryReaders::rebuildMetaData()
void RifMultipleSummaryReaders::buildMetaData()
{
m_allErrorAddresses.clear();
m_allResultAddresses.clear();

View File

@@ -40,7 +40,7 @@ public:
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
RiaDefines::EclipseUnitSystem unitSystem() const override;
void rebuildMetaData();
void buildMetaData() override;
private:
cvf::Collection<RifSummaryReaderInterface> m_readers;

View File

@@ -78,7 +78,7 @@ public:
RiaDefines::EclipseUnitSystem unitSystem() const override;
private:
void buildMetaData();
void buildMetaData() override;
bool openFileReader( const QString& fileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger );
static void increaseEsmryFileCount();

View File

@@ -62,7 +62,7 @@ public:
RiaDefines::EclipseUnitSystem unitSystem() const override;
private:
void buildMetaData();
void buildMetaData() override;
bool openESmryFile( const QString& headerFileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger );
private:

View File

@@ -379,14 +379,13 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData*
if ( !RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName( fileName, &fileSet ) ) return false;
m_fileName = fileName;
m_fileName = fileName;
m_filesWithSameBaseName = fileSet;
}
ecl_grid_type* mainEclGrid = nullptr;
{
auto task = progress.task( "Open Init File and Load Main Grid", 19 );
// Keep the set of files of interest
m_filesWithSameBaseName = fileSet;
openInitFile();
@@ -608,39 +607,6 @@ const size_t* RifReaderEclipseOutput::eclipseCellIndexMapping()
return cellMappingECLRi;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::importFaults( const QStringList& fileSet, cvf::Collection<RigFault>* faults )
{
if ( !filenamesWithFaults().empty() )
{
for ( size_t i = 0; i < filenamesWithFaults().size(); i++ )
{
QString faultFilename = filenamesWithFaults()[i];
RifEclipseInputFileTools::parseAndReadFaults( faultFilename, faults );
}
}
else
{
foreach ( QString fname, fileSet )
{
if ( fname.endsWith( ".DATA" ) )
{
std::vector<QString> filenamesWithFaults;
RifEclipseInputFileTools::readFaultsInGridSection( fname, faults, &filenamesWithFaults, faultIncludeFileAbsolutePathPrefix() );
std::sort( filenamesWithFaults.begin(), filenamesWithFaults.end() );
std::vector<QString>::iterator last = std::unique( filenamesWithFaults.begin(), filenamesWithFaults.end() );
filenamesWithFaults.erase( last, filenamesWithFaults.end() );
setFilenamesWithFaults( filenamesWithFaults );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -103,8 +103,6 @@ private:
const well_segment_type* segment,
const char* wellName );
void importFaults( const QStringList& fileSet, cvf::Collection<RigFault>* faults );
void openInitFile();
void extractResultValuesBasedOnPorosityModel( RiaDefines::PorosityModelType matrixOrFracture,

View File

@@ -54,10 +54,9 @@ public:
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
RiaDefines::EclipseUnitSystem unitSystem() const override;
void buildMetaData() override;
private:
void buildMetaData();
RifSummaryReaderInterface* currentSummaryReader() const;
private:

View File

@@ -21,6 +21,7 @@
#include "RiaPreferences.h"
#include "RifEclipseInputFileTools.h"
#include "RifReaderSettings.h"
//--------------------------------------------------------------------------------------------------
@@ -144,3 +145,36 @@ void RifReaderInterface::setReaderSettings( std::shared_ptr<RifReaderSettings> r
{
m_readerSettings = readerSettings;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderInterface::importFaults( const QStringList& fileSet, cvf::Collection<RigFault>* faults )
{
if ( !filenamesWithFaults().empty() )
{
for ( size_t i = 0; i < filenamesWithFaults().size(); i++ )
{
QString faultFilename = filenamesWithFaults()[i];
RifEclipseInputFileTools::parseAndReadFaults( faultFilename, faults );
}
}
else
{
foreach ( QString fname, fileSet )
{
if ( fname.endsWith( ".DATA" ) )
{
std::vector<QString> filenamesWithFaults;
RifEclipseInputFileTools::readFaultsInGridSection( fname, faults, &filenamesWithFaults, faultIncludeFileAbsolutePathPrefix() );
std::sort( filenamesWithFaults.begin(), filenamesWithFaults.end() );
std::vector<QString>::iterator last = std::unique( filenamesWithFaults.begin(), filenamesWithFaults.end() );
filenamesWithFaults.erase( last, filenamesWithFaults.end() );
setFilenamesWithFaults( filenamesWithFaults );
}
}
}
}

View File

@@ -23,6 +23,7 @@
#include "RiaDefines.h"
#include "RiaPorosityModel.h"
#include "cvfCollection.h"
#include "cvfObject.h"
#include "cafPdmPointer.h"
@@ -36,6 +37,7 @@
class RigEclipseCaseData;
class RifReaderSettings;
class RigFault;
//==================================================================================================
//
@@ -77,6 +79,7 @@ public:
protected:
bool isTimeStepIncludedByFilter( size_t timeStepIndex ) const;
size_t timeStepIndexOnFile( size_t timeStepIndex ) const;
void importFaults( const QStringList& fileSet, cvf::Collection<RigFault>* faults );
private:
const RifReaderSettings* readerSettings() const;

View File

@@ -31,6 +31,8 @@
#include "RigSimWellData.h"
#include "RigWellResultFrame.h"
#include "cafProgressInfo.h"
#include "opm/input/eclipse/Deck/Deck.hpp"
#include "opm/input/eclipse/EclipseState/Runspec.hpp"
#include "opm/input/eclipse/Parser/Parser.hpp"
@@ -65,6 +67,8 @@ RifReaderOpmCommon::~RifReaderOpmCommon()
//--------------------------------------------------------------------------------------------------
bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* eclipseCase )
{
caf::ProgressInfo progress( 100, "Reading Grid" );
QStringList fileSet;
if ( !RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName( fileName, &fileSet ) ) return false;
@@ -79,7 +83,24 @@ bool RifReaderOpmCommon::open( const QString& fileName, RigEclipseCaseData* ecli
return false;
}
buildMetaData( eclipseCase );
{
auto task = progress.task( "Reading faults", 25 );
if ( isFaultImportEnabled() )
{
cvf::Collection<RigFault> faults;
importFaults( fileSet, &faults );
RigMainGrid* mainGrid = eclipseCase->mainGrid();
mainGrid->setFaults( faults );
}
}
{
auto task = progress.task( "Reading Results Meta data", 50 );
buildMetaData( eclipseCase );
}
return true;
}

View File

@@ -49,6 +49,13 @@ RifEclipseSummaryAddress RifSummaryReaderInterface::errorAddress( const RifEclip
return m_allErrorAddresses.find( errAddr ) != m_allErrorAddresses.end() ? errAddr : RifEclipseSummaryAddress();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifSummaryReaderInterface::buildMetaData()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -51,6 +51,8 @@ public:
virtual std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const = 0;
virtual RiaDefines::EclipseUnitSystem unitSystem() const = 0;
virtual void buildMetaData();
protected:
std::set<RifEclipseSummaryAddress> m_allResultAddresses; // Result and error addresses
std::set<RifEclipseSummaryAddress> m_allErrorAddresses; // Error addresses

View File

@@ -54,7 +54,6 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RivWellDiskPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivElementVectorResultPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.h
${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationTools.h
@@ -112,7 +111,6 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RivWellDiskPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivElementVectorResultPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivDrawableSpheres.cpp
${CMAKE_CURRENT_LIST_DIR}/RivBoxGeometryGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationTools.cpp

View File

@@ -1,60 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 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 "cafPdmPointer.h"
#include "cvfAssert.h"
#include "cvfCollection.h"
#include "cvfObject.h"
namespace cvf
{
class BoundingBox;
class Part;
class ModelBasicList;
class Transform;
class Font;
} // namespace cvf
namespace caf
{
class DisplayCoordTransform;
}
class Rim3dView;
class RivPolylinePartMgr;
class RivCellFilterPartMgr : public cvf::Object
{
public:
RivCellFilterPartMgr( Rim3dView* view );
~RivCellFilterPartMgr() override;
void appendGeometryPartsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& boundingBox );
void clearGeometryCache();
private:
void createCellFilterPartManagers();
private:
caf::PdmPointer<Rim3dView> m_rimView;
cvf::Collection<RivPolylinePartMgr> m_cellFilterPartMgrs;
};

View File

@@ -82,7 +82,7 @@ bool RivPolylinePartMgr::isPolylinesInBoundingBox( std::vector<std::vector<cvf::
void RivPolylinePartMgr::buildPolylineParts( const caf::DisplayCoordTransform* displayXf, const cvf::BoundingBox& boundingBox )
{
auto polylineDef = m_polylineInterface->polyLinesData();
if ( polylineDef.isNull() || polylineDef->polyLines().empty() )
if ( polylineDef.isNull() || polylineDef->rawPolyLines().empty() )
{
clearAllGeometry();
return;
@@ -107,6 +107,7 @@ void RivPolylinePartMgr::buildPolylineParts( const caf::DisplayCoordTransform* d
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName( "RivPolylinePartMgr" );
part->setDrawable( drawableGeo.p() );
part->updateBoundingBox();
caf::MeshEffectGenerator effgen( polylineDef->lineColor() );
effgen.setLineWidth( polylineDef->lineThickness() );
@@ -177,6 +178,7 @@ void RivPolylinePartMgr::buildPolylineParts( const caf::DisplayCoordTransform* d
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName( "RivPolylinePartMgr" );
part->setDrawable( vectorDrawable.p() );
part->updateBoundingBox();
part->setEffect( new cvf::Effect() );
part->setPriority( RivPartPriority::PartType::MeshLines );
@@ -190,7 +192,7 @@ void RivPolylinePartMgr::buildPolylineParts( const caf::DisplayCoordTransform* d
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<cvf::Vec3d>> RivPolylinePartMgr::getPolylinesPointsInDomain( RigPolyLinesData* lineDef )
{
auto polylines = lineDef->polyLines();
auto polylines = lineDef->rawPolyLines();
if ( !lineDef->lockToZPlane() ) return polylines;
const double planeZ = lineDef->lockedZValue();

View File

@@ -29,9 +29,7 @@ CAF_PDM_SOURCE_INIT( RimPolylineTarget, "PolylineTarget" );
///
//--------------------------------------------------------------------------------------------------
RimPolylineTarget::RimPolylineTarget()
: m_isFullUpdateEnabled( true )
{
CAF_PDM_InitField( &m_isEnabled, "IsEnabled", true, "" );
CAF_PDM_InitFieldNoDefault( &m_targetPointXyd, "TargetPointXyd", "Point" );
}
@@ -42,14 +40,6 @@ RimPolylineTarget::~RimPolylineTarget()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolylineTarget::isEnabled() const
{
return m_isEnabled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -84,14 +74,6 @@ caf::PdmUiFieldHandle* RimPolylineTarget::targetPointUiCapability()
return m_targetPointXyd.uiCapability();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolylineTarget::enableFullUpdate( bool enable )
{
m_isFullUpdateEnabled = enable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -38,14 +38,11 @@ public:
RimPolylineTarget();
~RimPolylineTarget() override;
bool isEnabled() const;
void setAsPointTargetXYD( const cvf::Vec3d& point );
void setAsPointXYZ( const cvf::Vec3d& point );
cvf::Vec3d targetPointXYZ() const;
caf::PdmUiFieldHandle* targetPointUiCapability();
void enableFullUpdate( bool enable );
void triggerVisualizationUpdate() const;
@@ -54,7 +51,5 @@ private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
private:
bool m_isFullUpdateEnabled;
caf::PdmField<bool> m_isEnabled;
caf::PdmField<cvf::Vec3d> m_targetPointXyd;
};

View File

@@ -158,7 +158,7 @@ bool RimPolylinesFromFileAnnotation::isEmpty()
{
if ( m_polyLinesData.isNull() ) return true;
for ( const std::vector<cvf::Vec3d>& line : m_polyLinesData->polyLines() )
for ( const std::vector<cvf::Vec3d>& line : m_polyLinesData->rawPolyLines() )
{
if ( !line.empty() ) return false;
}

View File

@@ -44,8 +44,7 @@ RimReachCircleAnnotation::RimReachCircleAnnotation()
CAF_PDM_InitField( &m_centerPointXyd, "CenterPointXyd", Vec3d::ZERO, "Center Point" );
m_centerPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_centerPointPickEnabled, "AnchorPointPick", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_centerPointPickEnabled );
m_centerPointPickEnabled.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_centerPointPickEnabled );
CAF_PDM_InitField( &m_radius, "Radius", 100.0, "Radius" );
CAF_PDM_InitField( &m_name, "Name", QString( "Circle Annotation" ), "Name" );

View File

@@ -51,14 +51,12 @@ RimTextAnnotation::RimTextAnnotation()
CAF_PDM_InitField( &m_anchorPointXyd, "AnchorPointXyd", Vec3d::ZERO, "Anchor Point" );
m_anchorPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_anchorPointPickEnabledButtonField, "AnchorPointPick", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_anchorPointPickEnabledButtonField );
m_anchorPointPickEnabledButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_anchorPointPickEnabledButtonField );
CAF_PDM_InitField( &m_labelPointXyd, "LabelPointXyd", Vec3d::ZERO, "Label Point" );
m_labelPointXyd.uiCapability()->setUiEditorTypeName( caf::PdmUiPickableLineEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_labelPointPickEnabledButtonField, "LabelPointPick", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_labelPointPickEnabledButtonField );
m_labelPointPickEnabledButtonField.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_labelPointPickEnabledButtonField );
CAF_PDM_InitField( &m_text, "Text", QString( "(New text)" ), "Text" );
m_text.uiCapability()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() );

View File

@@ -49,7 +49,7 @@ RimUserDefinedPolylinesAnnotation::RimUserDefinedPolylinesAnnotation()
CAF_PDM_InitField( &m_name, "Name", QString( "User Defined Polyline" ), "Name" );
CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_enablePicking );
m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" );
@@ -152,31 +152,6 @@ void RimUserDefinedPolylinesAnnotation::deleteTarget( RimPolylineTarget* targetT
delete targetToDelete;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<RimPolylineTarget*, RimPolylineTarget*>
RimUserDefinedPolylinesAnnotation::findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore )
{
RimPolylineTarget* before = nullptr;
RimPolylineTarget* after = nullptr;
bool foundTarget = false;
for ( const auto& wt : m_targets )
{
if ( wt == targetToInsertBefore )
{
foundTarget = true;
}
if ( wt->isEnabled() && !after && foundTarget ) after = wt;
if ( wt->isEnabled() && !foundTarget ) before = wt;
}
return { before, after };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -60,8 +60,6 @@ public:
void appendTarget( const cvf::Vec3d& defaultPos = cvf::Vec3d::ZERO );
std::pair<RimPolylineTarget*, RimPolylineTarget*> findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore );
void enablePicking( bool enable );
protected:

View File

@@ -267,6 +267,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimResultSelectionUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimEmCase.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolylinePickerInterface.cpp
)
if(RESINSIGHT_USE_QT_CHARTS)

View File

@@ -145,6 +145,12 @@ void RimCellFilterCollection::fieldChangedByUi( const caf::PdmFieldHandle* chang
uiCapability()->updateConnectedEditors();
onFilterUpdated( nullptr );
for ( const auto& filter : m_cellFilters )
{
// Update the filters to make sure the 3D polygon targets are removed if the filter collection is disabled
filter->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
@@ -255,12 +261,22 @@ bool RimCellFilterCollection::hasActiveIncludeRangeFilters() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase )
RimPolygonFilter* RimCellFilterCollection::addNewPolygonFilter( RimCase* srcCase, RimPolygon* polygon )
{
RimPolygonFilter* pFilter = new RimPolygonFilter();
pFilter->setCase( srcCase );
pFilter->setPolygon( polygon );
addFilter( pFilter );
pFilter->enablePicking( true );
pFilter->configurePolygonEditor();
if ( polygon )
{
pFilter->enableFilter( true );
}
else
{
pFilter->enablePicking( true );
}
onFilterUpdated( pFilter );
return pFilter;
}
@@ -485,3 +501,23 @@ void RimCellFilterCollection::updateCellVisibilityByIndex( cvf::UByteArray* incl
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygonInView*> RimCellFilterCollection::enabledCellFilterPolygons() const
{
std::vector<RimPolygonInView*> polyInView;
for ( const auto& filter : m_cellFilters )
{
if ( !filter->isActive() ) continue;
if ( auto polygonFilter = dynamic_cast<RimPolygonFilter*>( filter.p() ) )
{
polyInView.push_back( polygonFilter->polygonInView() );
}
}
return polyInView;
}

View File

@@ -32,6 +32,8 @@ class RimPolygonFilter;
class RimUserDefinedFilter;
class RimUserDefinedIndexFilter;
class RimCase;
class RimPolygonInView;
class RimPolygon;
namespace cvf
{
@@ -52,7 +54,7 @@ public:
caf::Signal<> filtersChanged;
RimPolygonFilter* addNewPolygonFilter( RimCase* srcCase );
RimPolygonFilter* addNewPolygonFilter( RimCase* srcCase, RimPolygon* polygon );
RimCellRangeFilter* addNewCellRangeFilter( RimCase* srcCase, int gridIndex, int sliceDirection = -1, int defaultSlice = -1 );
RimCellIndexFilter* addNewCellIndexFilter( RimCase* srcCase );
RimUserDefinedFilter* addNewUserDefinedFilter( RimCase* srcCase );
@@ -69,7 +71,8 @@ public:
void compoundCellRangeFilter( cvf::CellRangeFilter* cellRangeFilter, size_t gridIndex ) const;
void updateCellVisibilityByIndex( cvf::UByteArray* cellsIncluded, cvf::UByteArray* cellsExcluded, size_t gridIndex ) const;
std::vector<RimCellFilter*> filters() const;
std::vector<RimPolygonInView*> enabledCellFilterPolygons() const;
std::vector<RimCellFilter*> filters() const;
bool hasActiveFilters() const;
bool hasActiveIncludeIndexFilters() const;

View File

@@ -389,7 +389,7 @@ void RimEclipsePropertyFilter::defineObjectEditorAttribute( QString uiConfigName
if ( treeItemAttribute )
{
treeItemAttribute->tags.clear();
auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create();
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
tag->icon = caf::IconProvider( ":/chain.png" );
treeItemAttribute->tags.push_back( std::move( tag ) );

View File

@@ -20,39 +20,29 @@
#include "RigCellGeometryTools.h"
#include "RigEclipseCaseData.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
#include "RigGeoMechCaseData.h"
#include "RigMainGrid.h"
#include "RigPolyLinesData.h"
#include "RigReservoirGridTools.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimCellFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimGeoMechCase.h"
#include "RimPolylineTarget.h"
#include "RimTools.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonInView.h"
#include "Polygons/RimPolygonTools.h"
#include "Riu3DMainWindowTools.h"
#include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h"
#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h"
#include "RiuViewerCommands.h"
#include "RiaStdStringTools.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTableViewEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include <cafPdmUiDoubleSliderEditor.h>
#include "cvfBoundingBox.h"
#include "cvfStructGrid.h"
#include <QValidator>
#include <limits>
@@ -75,44 +65,24 @@ void caf::AppEnum<RimPolygonFilter::PolygonIncludeType>::setUp()
setDefault( RimPolygonFilter::PolygonIncludeType::CENTER );
}
template <>
void caf::AppEnum<RimPolygonFilter::GeometricalShape>::setUp()
{
addItem( RimPolygonFilter::GeometricalShape::AREA, "AREA", "Area Filter" );
addItem( RimPolygonFilter::GeometricalShape::LINE, "LINE", "Line Filter" );
setDefault( RimPolygonFilter::GeometricalShape::AREA );
}
template <>
void caf::AppEnum<RimPolygonFilter::PolygonDataSource>::setUp()
{
addItem( RimPolygonFilter::PolygonDataSource::DEFINED_IN_FILTER, "DEFINED_IN_FILTER", "Defined in Filter" );
addItem( RimPolygonFilter::PolygonDataSource::GLOBAL_POLYGON, "GLOBAL_POLYGON", "Polygon in Project" );
setDefault( RimPolygonFilter::PolygonDataSource::DEFINED_IN_FILTER );
}
} // namespace caf
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class ThicknessValidator : public QValidator
{
public:
State validate( QString& input, int& pos ) const override
{
if ( input.isEmpty() ) return State::Intermediate;
int val = RiaStdStringTools::toInt( input.toStdString() );
if ( val > 0 && val < 8 )
return State::Acceptable;
else
return State::Invalid;
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RadiusValidator : public QValidator
{
public:
State validate( QString& input, int& pos ) const override
{
if ( input.isEmpty() ) return State::Intermediate;
double val = RiaStdStringTools::toDouble( input.toStdString() );
if ( val > 0.001 && val <= 2.0 )
return State::Acceptable;
else
return State::Invalid;
}
};
CAF_PDM_SOURCE_INIT( RimPolygonFilter, "PolygonFilter", "PolyLineFilter" );
//--------------------------------------------------------------------------------------------------
@@ -128,70 +98,44 @@ RimPolygonFilter::RimPolygonFilter()
CAF_PDM_InitFieldNoDefault( &m_polyFilterMode, "PolygonFilterType", "Vertical Filter" );
CAF_PDM_InitFieldNoDefault( &m_polyIncludeType, "PolyIncludeType", "Cells to include" );
CAF_PDM_InitFieldNoDefault( &m_polygonDataSource, "PolygonDataSource", "Data Source" );
CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking );
m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_geometricalShape, "GeometricalShape", "" );
m_geometricalShape.registerGetMethod( this, &RimPolygonFilter::geometricalShape );
m_geometricalShape.registerSetMethod( this, &RimPolygonFilter::setGeometricalShape );
CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" );
m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
m_targets.uiCapability()->setUiTreeChildrenHidden( true );
m_targets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
m_targets.uiCapability()->setCustomContextMenuEnabled( true );
CAF_PDM_InitFieldNoDefault( &m_internalPolygon, "InternalPolygon", "Polygon For Filter" );
m_internalPolygon = new RimPolygon;
m_internalPolygon->setName( "Polygon For Filter" );
m_internalPolygon->uiCapability()->setUiTreeHidden( true );
CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" );
CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" );
CAF_PDM_InitField( &m_closePolygon, "ClosePolygon", true, "Closed Polygon" );
CAF_PDM_InitFieldNoDefault( &m_cellFilterPolygon, "Polygon", "Polygon" );
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_InitFieldNoDefault( &m_polygonEditor, "PolygonEditor", "Polygon Editor" );
m_polygonEditor = new RimPolygonInView;
m_polygonEditor->uiCapability()->setUiTreeHidden( true );
m_polygonEditor.xmlCapability()->disableIO();
CAF_PDM_InitField( &m_enableFiltering, "EnableFiltering", false, "Enable Filter" );
CAF_PDM_InitField( &m_enableKFilter, "EnableKFilter", false, "Enable K Range Filter" );
CAF_PDM_InitFieldNoDefault( &m_kFilterStr, "KRangeFilter", "K Range Filter", "", "Example: 2,4-6,10-20:2", "" );
CAF_PDM_InitField( &m_polygonPlaneDepth, "PolygonPlaneDepth", 0.0, "Polygon Plane Depth" );
CAF_PDM_InitField( &m_lockPolygonToPlane, "LockPolygon", false, "Lock Polygon to Plane" );
CAF_PDM_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editPolygonButton );
m_polygonPlaneDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
m_polygonPlaneDepth.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::TOP );
setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() );
uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_OBSOLETE_targets, "Targets", "Targets" );
m_OBSOLETE_targets.uiCapability()->setUiTreeChildrenHidden( true );
m_OBSOLETE_targets.uiCapability()->setUiTreeHidden( true );
m_OBSOLETE_targets.uiCapability()->setUiHidden( true );
m_OBSOLETE_targets.xmlCapability()->setIOWritable( false );
m_propagateToSubGrids = false;
updateIconState();
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonFilter::~RimPolygonFilter()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::updateVisualization()
{
updateCells();
filterChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::updateEditorsAndVisualization()
{
updateConnectedEditors();
updateVisualization();
setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() );
}
//--------------------------------------------------------------------------------------------------
@@ -210,6 +154,18 @@ void RimPolygonFilter::enableKFilter( bool bEnable )
m_enableKFilter = bEnable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::setPolygon( RimPolygon* polygon )
{
if ( polygon )
{
m_polygonDataSource = PolygonDataSource::GLOBAL_POLYGON;
m_cellFilterPolygon = polygon;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -238,32 +194,23 @@ QString RimPolygonFilter::fullName() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolylineTarget*> RimPolygonFilter::activeTargets() const
void RimPolygonFilter::initAfterRead()
{
return m_targets.childrenByType();
}
RimCellFilter::initAfterRead();
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert )
{
size_t index = m_targets.indexOf( targetToInsertBefore );
if ( index < m_targets.size() )
m_targets.insert( index, targetToInsert );
else
m_targets.push_back( targetToInsert );
// Move existing polygons to global polygon
if ( !m_OBSOLETE_targets.empty() )
{
std::vector<cvf::Vec3d> points;
for ( const auto& target : m_OBSOLETE_targets )
{
points.push_back( target->targetPointXYZ() );
}
updateCells();
}
m_internalPolygon->setPointsInDomainCoords( points );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete )
{
m_targets.removeChild( targetToDelete );
delete targetToDelete;
configurePolygonEditor();
}
//--------------------------------------------------------------------------------------------------
@@ -271,68 +218,17 @@ void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete )
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_enablePicking )
if ( auto attrib = dynamic_cast<RicPolyline3dEditorAttribute*>( attribute ) )
{
auto* pbAttribute = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( pbAttribute )
{
if ( !m_enablePicking )
{
pbAttribute->m_buttonText = "Start Picking Points";
}
else
{
pbAttribute->m_buttonText = "Stop Picking Points";
}
}
attrib->pickEventHandler = m_pickTargetsEventHandler;
attrib->enablePicking = m_polygonEditor->pickingEnabled();
}
else if ( field == &m_targets )
{
auto tvAttribute = dynamic_cast<caf::PdmUiTableViewEditorAttribute*>( attribute );
if ( tvAttribute )
{
tvAttribute->resizePolicy = caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FIT_CONTENT;
if ( m_enablePicking )
{
tvAttribute->baseColor.setRgb( 255, 220, 255 );
tvAttribute->alwaysEnforceResizePolicy = true;
}
}
}
else if ( field == &m_lineThickness )
if ( field == &m_editPolygonButton )
{
auto myAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute );
if ( myAttr )
if ( auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) )
{
myAttr->validator = new ThicknessValidator();
}
}
else if ( field == &m_lineThickness )
{
auto myAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute );
if ( myAttr )
{
myAttr->validator = new RadiusValidator();
}
}
else if ( field == &m_polygonPlaneDepth )
{
auto* attr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
if ( attr )
{
if ( m_srcCase )
{
auto bb = m_srcCase->allCellsBoundingBox();
attr->m_minimum = -bb.max().z();
attr->m_maximum = -bb.min().z();
}
else
{
attr->m_minimum = 0;
attr->m_maximum = 10000;
}
attrib->m_buttonText = "Edit";
}
}
}
@@ -340,14 +236,12 @@ void RimPolygonFilter::defineEditorAttribute( const caf::PdmFieldHandle* field,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget )
void RimPolygonFilter::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
{
caf::CmdFeatureMenuBuilder menuBuilder;
// When interactive edit of polyline coordinates in enabled in RimPolygonInView::m_enablePicking, the editors to RimPolygonFilter must
// be updated to trigger calls to RimPolylinePickerInterface
menuBuilder << "RicDeletePolylineTargetFeature";
menuBuilder << "RicAppendPointsToPolygonFilterFeature";
menuBuilder.appendToMenu( menu );
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
@@ -359,34 +253,26 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
auto group = uiOrdering.addNewGroup( "General" );
group->add( &m_filterMode );
group->add( &m_geometricalShape );
group->add( &m_enableFiltering );
group->add( &m_closePolygon );
group->add( &m_polygonDataSource );
if ( !isPolygonDefinedLocally() )
{
group->add( &m_cellFilterPolygon );
group->add( &m_editPolygonButton, { .newRow = false } );
}
auto group1 = uiOrdering.addNewGroup( "Polygon Selection" );
group1->add( &m_polyFilterMode );
if ( m_closePolygon() ) group1->add( &m_polyIncludeType );
group1->add( &m_targets );
group1->add( &m_enablePicking );
bool isPolygonClosed = m_cellFilterPolygon() ? m_cellFilterPolygon->isClosed() : false;
if ( isPolygonClosed )
{
group1->add( &m_polyIncludeType );
}
m_polyIncludeType.uiCapability()->setUiName( "Cells to " + modeString() );
auto group2 = uiOrdering.addNewGroup( "Appearance" );
group2->add( &m_showLines );
group2->add( &m_showSpheres );
if ( m_showLines )
{
group2->add( &m_lineThickness );
group2->add( &m_lineColor );
}
if ( m_showSpheres )
{
group2->add( &m_sphereRadiusFactor );
group2->add( &m_sphereColor );
}
group2->add( &m_lockPolygonToPlane );
if ( m_lockPolygonToPlane ) group2->add( &m_polygonPlaneDepth );
group2->setCollapsedByDefault();
auto group3 = uiOrdering.addNewGroup( "Advanced Filter Settings" );
group3->add( &m_enableKFilter );
group3->add( &m_kFilterStr );
@@ -402,7 +288,7 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
objField->uiCapability()->setUiReadOnly( readOnlyState );
}
if ( !m_closePolygon() )
if ( !isPolygonClosed )
{
m_polyFilterMode = RimPolygonFilter::PolygonFilterModeType::INDEX_K;
m_polyFilterMode.uiCapability()->setUiReadOnly( true );
@@ -411,6 +297,30 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
{
m_polyFilterMode.uiCapability()->setUiReadOnly( readOnlyState );
}
if ( isPolygonDefinedLocally() )
{
caf::PdmUiGroup* polyDefinitionGroup = uiOrdering.addNewGroup( "Polygon Definition" );
m_polygonEditor()->uiOrderingForLocalPolygon( uiConfigName, *polyDefinitionGroup );
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" );
appearanceGroup->setCollapsedByDefault();
m_internalPolygon->uiOrderingForLocalPolygon( uiConfigName, *appearanceGroup );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimPolygonFilter::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_cellFilterPolygon )
{
RimTools::polygonOptionItems( &options );
}
return options;
}
//--------------------------------------------------------------------------------------------------
@@ -418,20 +328,39 @@ void RimPolygonFilter::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_enablePicking )
if ( changedField == &m_editPolygonButton )
{
updateConnectedEditors();
RimPolygonTools::selectAndActivatePolygonInView( m_cellFilterPolygon(), this );
enableFilter( !m_enablePicking() );
filterChanged.send();
m_editPolygonButton = false;
return;
}
else if ( ( changedField == &m_showLines ) || ( changedField == &m_showSpheres ) || ( changedField == &m_sphereColor ) ||
( changedField == &m_sphereRadiusFactor ) || ( changedField == &m_lineThickness ) || ( changedField == &m_lineColor ) ||
( changedField == &m_lockPolygonToPlane ) || ( changedField == &m_polygonPlaneDepth ) )
if ( changedField == &m_polygonDataSource )
{
filterChanged.send();
if ( !isPolygonDefinedLocally() )
{
if ( m_cellFilterPolygon() == nullptr || m_cellFilterPolygon() == m_internalPolygon )
{
auto polygonCollection = RimTools::polygonCollection();
if ( polygonCollection && !polygonCollection->allPolygons().empty() )
{
m_cellFilterPolygon = polygonCollection->allPolygons().front();
}
}
}
configurePolygonEditor();
updateAllRequiredEditors();
}
else if ( changedField != &m_name )
if ( changedField == &m_cellFilterPolygon )
{
configurePolygonEditor();
updateAllRequiredEditors();
}
if ( changedField != &m_name )
{
updateCells();
filterChanged.send();
@@ -444,26 +373,10 @@ void RimPolygonFilter::fieldChangedByUi( const caf::PdmFieldHandle* changedField
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::enablePicking( bool enable )
{
m_enablePicking = enable;
m_polygonEditor->enablePicking( enable );
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonFilter::pickingEnabled() const
{
return m_enablePicking();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const
{
return m_pickTargetsEventHandler.get();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -583,7 +496,7 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector<cvf::Vec3d>&
const int gIdx = static_cast<int>( grid->gridIndex() );
std::list<size_t> foundCells;
const bool closedPolygon = m_closePolygon();
const bool closedPolygon = isPolygonClosed();
// find all cells in the K layer that matches the polygon
#pragma omp parallel for
@@ -591,8 +504,8 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector<cvf::Vec3d>&
{
for ( size_t j = 0; j < grid->cellCountJ(); j++ )
{
size_t cellIdx = grid->cellIndexFromIJK( i, j, K );
RigCell cell = grid->cell( cellIdx );
size_t cellIdx = grid->cellIndexFromIJK( i, j, K );
const RigCell& cell = grid->cell( cellIdx );
// valid cell?
if ( cell.isInvalid() ) continue;
@@ -634,7 +547,7 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector<cvf::Vec3d>&
// get the cell index
size_t newIdx = grid->cellIndexFromIJK( ci, cj, k );
// valid cell?
RigCell cell = grid->cell( newIdx );
const RigCell& cell = grid->cell( newIdx );
if ( cell.isInvalid() ) continue;
m_cells[gIdx].push_back( newIdx );
@@ -652,7 +565,7 @@ void RimPolygonFilter::updateCellsForEclipse( const std::vector<cvf::Vec3d>& poi
if ( m_polyFilterMode == PolygonFilterModeType::DEPTH_Z )
{
if ( !m_closePolygon() ) return;
if ( !isPolygonClosed() ) return;
for ( size_t gridIndex = 0; gridIndex < data->gridCount(); gridIndex++ )
{
@@ -720,7 +633,7 @@ void RimPolygonFilter::updateCellsDepthGeoMech( const std::vector<cvf::Vec3d>& p
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::updateCellsKIndexGeoMech( const std::vector<cvf::Vec3d>& points, const RigFemPartGrid* grid, int partId )
{
const bool closedPolygon = m_closePolygon();
const bool closedPolygon = isPolygonClosed();
// we need to find the K layer we hit with the first point
size_t nk;
@@ -839,7 +752,7 @@ void RimPolygonFilter::updateCellsForGeoMech( const std::vector<cvf::Vec3d>& poi
if ( m_polyFilterMode == PolygonFilterModeType::DEPTH_Z )
{
if ( m_closePolygon() )
if ( isPolygonClosed() )
{
updateCellsDepthGeoMech( points, grid, i );
}
@@ -865,16 +778,17 @@ void RimPolygonFilter::updateCells()
// get polyline as vector
std::vector<cvf::Vec3d> points;
for ( auto& target : m_targets )
if ( m_polygonEditor && m_polygonEditor->polygon() )
{
if ( target->isEnabled() ) points.push_back( target->targetPointXYZ() );
points = m_polygonEditor->polygon()->pointsInDomainCoords();
}
// We need at least three points to make a closed polygon, or just 2 for a polyline
if ( ( !m_closePolygon() && ( points.size() < 2 ) ) || ( m_closePolygon() && ( points.size() < 3 ) ) ) return;
if ( ( !isPolygonClosed() && ( points.size() < 2 ) ) || ( isPolygonClosed() && ( points.size() < 3 ) ) ) return;
// make sure first and last point is the same (req. by closed polygon methods used later)
if ( m_closePolygon() ) points.push_back( points.front() );
if ( isPolygonClosed() ) points.push_back( points.front() );
RimEclipseCase* eCase = eclipseCase();
RimGeoMechCase* gCase = geoMechCase();
@@ -892,30 +806,119 @@ void RimPolygonFilter::updateCells()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigPolyLinesData> RimPolygonFilter::polyLinesData() const
void RimPolygonFilter::configurePolygonEditor()
{
cvf::ref<RigPolyLinesData> pld = new RigPolyLinesData;
std::vector<cvf::Vec3d> line;
for ( const RimPolylineTarget* target : m_targets )
{
if ( target->isEnabled() ) line.push_back( target->targetPointXYZ() );
}
pld->setPolyLine( line );
RimPolygon* polygon = nullptr;
if ( isPolygonDefinedLocally() )
polygon = m_internalPolygon();
else
polygon = m_cellFilterPolygon();
pld->setLineAppearance( m_lineThickness, m_lineColor, m_closePolygon );
pld->setSphereAppearance( m_sphereRadiusFactor, m_sphereColor );
pld->setZPlaneLock( m_lockPolygonToPlane, -m_polygonPlaneDepth );
m_polygonEditor->setPolygon( polygon );
if ( isActive() )
// Must connect the signals after polygon is assigned to the polygon editor
// When assigning an object to a ptr field, all signals are disconnected
connectObjectSignals( polygon );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonInView* RimPolygonFilter::polygonInView() const
{
return m_polygonEditor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert )
{
m_polygonEditor->insertTarget( targetToInsertBefore, targetToInsert );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::deleteTarget( RimPolylineTarget* targetToDelete )
{
m_polygonEditor->deleteTarget( targetToDelete );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::updateEditorsAndVisualization()
{
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::updateVisualization()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolylineTarget*> RimPolygonFilter::activeTargets() const
{
return m_polygonEditor->activeTargets();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonFilter::pickingEnabled() const
{
return m_polygonEditor->pickingEnabled();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PickEventHandler* RimPolygonFilter::pickEventHandler() const
{
auto filterColl = firstAncestorOfType<RimCellFilterCollection>();
if ( filterColl && !filterColl->isActive() ) return nullptr;
if ( !isActive() ) return nullptr;
return m_pickTargetsEventHandler.get();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::AppEnum<RimPolygonFilter::GeometricalShape> RimPolygonFilter::geometricalShape() const
{
if ( isPolygonDefinedLocally() )
{
pld->setVisibility( m_showLines, m_showSpheres );
if ( !m_internalPolygon->isClosed() ) return GeometricalShape::LINE;
}
else
{
pld->setVisibility( false, false );
if ( m_cellFilterPolygon && !m_cellFilterPolygon->isClosed() ) return GeometricalShape::LINE;
}
return pld;
return GeometricalShape::AREA;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::setGeometricalShape( const caf::AppEnum<GeometricalShape>& shape )
{
if ( isPolygonDefinedLocally() )
{
m_internalPolygon->setIsClosed( shape == GeometricalShape::AREA );
}
else if ( m_cellFilterPolygon() )
{
m_cellFilterPolygon->setIsClosed( shape == GeometricalShape::AREA );
}
}
//--------------------------------------------------------------------------------------------------
@@ -932,6 +935,53 @@ void RimPolygonFilter::initializeCellList()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonFilter::isPolygonClosed() const
{
if ( isPolygonDefinedLocally() ) return m_internalPolygon->isClosed();
if ( m_cellFilterPolygon() ) return m_cellFilterPolygon->isClosed();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonFilter::isPolygonDefinedLocally() const
{
return m_polygonDataSource() == PolygonDataSource::DEFINED_IN_FILTER;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::connectObjectSignals( RimPolygon* polygon )
{
if ( m_cellFilterPolygon() )
{
m_cellFilterPolygon()->objectChanged.disconnect( this );
}
if ( polygon )
{
m_cellFilterPolygon = polygon;
polygon->objectChanged.connect( this, &RimPolygonFilter::onObjectChanged );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFilter::onObjectChanged( const caf::SignalEmitter* emitter )
{
updateCells();
filterChanged.send();
updateIconState();
}
//--------------------------------------------------------------------------------------------------
/// Find which K layer we hit, in any of the grids, for any of the selected points
//--------------------------------------------------------------------------------------------------

View File

@@ -21,42 +21,42 @@
#include "RimCellFilter.h"
#include "RimCellFilterIntervalTool.h"
#include "RimPolylinePickerInterface.h"
#include "RimPolylinesDataInterface.h"
#include "cafAppEnum.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmChildField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "cafPickEventHandler.h"
#include "cvfColor3.h"
#include <list>
#include <memory>
class RicPolylineTargetsPickEventHandler;
class RimPolygon;
class RimPolylineTarget;
class RimCase;
class RimEclipseCase;
class RimGeoMechCase;
class RigGridBase;
class RigMainGrid;
class RigFemPartGrid;
class RigPolylinesData;
class RimPolygonInView;
class RigEclipseCaseData;
class RicPolylineTargetsPickEventHandler;
//==================================================================================================
///
///
//==================================================================================================
class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface, public RimPolylinesDataInterface
class RimPolygonFilter : public RimCellFilter, public RimPolylinePickerInterface
{
CAF_PDM_HEADER_INIT;
public:
enum class PolygonDataSource
{
DEFINED_IN_FILTER,
GLOBAL_POLYGON
};
enum class GeometricalShape
{
AREA,
LINE
};
enum class PolygonFilterModeType
{
DEPTH_Z,
@@ -71,38 +71,32 @@ public:
};
RimPolygonFilter();
~RimPolygonFilter() override;
void enableFilter( bool bEnable );
void enableKFilter( bool bEnable );
void setPolygon( RimPolygon* polygon );
bool isFilterEnabled() const override;
void updateVisualization() override;
void updateEditorsAndVisualization() override;
void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override;
void deleteTarget( RimPolylineTarget* targetToDelete ) override;
void enablePicking( bool enable );
std::vector<RimPolylineTarget*> activeTargets() const override;
bool pickingEnabled() const override;
caf::PickEventHandler* pickEventHandler() const override;
void updateCellIndexFilter( cvf::UByteArray* includeVisibility, cvf::UByteArray* excludeVisibility, int gridIndex ) override;
void onGridChanged() override;
cvf::ref<RigPolyLinesData> polyLinesData() const override;
void configurePolygonEditor();
RimPolygonInView* polygonInView() const;
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
void initAfterRead() override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override;
QString fullName() const override;
private:
void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void updateCells();
void updateCellsForEclipse( const std::vector<cvf::Vec3d>& points, RimEclipseCase* eCase );
void updateCellsForGeoMech( const std::vector<cvf::Vec3d>& points, RimGeoMechCase* gCase );
@@ -118,26 +112,45 @@ private:
void initializeCellList();
caf::PdmField<bool> m_enablePicking;
caf::PdmChildArrayField<RimPolylineTarget*> m_targets;
caf::PdmField<caf::AppEnum<PolygonFilterModeType>> m_polyFilterMode;
caf::PdmField<caf::AppEnum<PolygonIncludeType>> m_polyIncludeType;
caf::PdmField<bool> m_enableFiltering;
caf::PdmField<bool> m_showLines;
caf::PdmField<bool> m_showSpheres;
caf::PdmField<int> m_lineThickness;
caf::PdmField<double> m_sphereRadiusFactor;
caf::PdmField<cvf::Color3f> m_lineColor;
caf::PdmField<cvf::Color3f> m_sphereColor;
caf::PdmField<double> m_polygonPlaneDepth;
caf::PdmField<bool> m_lockPolygonToPlane;
caf::PdmField<bool> m_enableKFilter;
caf::PdmField<QString> m_kFilterStr;
caf::PdmField<bool> m_closePolygon;
bool isPolygonClosed() const;
bool isPolygonDefinedLocally() const;
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;
void connectObjectSignals( RimPolygon* polygon );
void onObjectChanged( const caf::SignalEmitter* emitter );
// RimPolylinePickerInterface used to forward events to m_polygonEditor
void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override;
void deleteTarget( RimPolylineTarget* targetToDelete ) override;
void updateEditorsAndVisualization() override;
void updateVisualization() override;
std::vector<RimPolylineTarget*> activeTargets() const override;
bool pickingEnabled() const override;
caf::PickEventHandler* pickEventHandler() const override;
caf::AppEnum<GeometricalShape> geometricalShape() const;
void setGeometricalShape( const caf::AppEnum<GeometricalShape>& shape );
private:
caf::PdmField<caf::AppEnum<PolygonFilterModeType>> m_polyFilterMode;
caf::PdmField<caf::AppEnum<PolygonIncludeType>> m_polyIncludeType;
caf::PdmField<caf::AppEnum<PolygonDataSource>> m_polygonDataSource;
caf::PdmProxyValueField<caf::AppEnum<GeometricalShape>> m_geometricalShape;
caf::PdmField<bool> m_enableFiltering;
caf::PdmField<bool> m_enableKFilter;
caf::PdmField<QString> m_kFilterStr;
std::vector<std::vector<size_t>> m_cells;
RimCellFilterIntervalTool m_intervalTool;
// Local polygon and polygon editor
caf::PdmPtrField<RimPolygon*> m_cellFilterPolygon;
caf::PdmChildField<RimPolygon*> m_internalPolygon;
caf::PdmChildField<RimPolygonInView*> m_polygonEditor;
caf::PdmField<bool> m_editPolygonButton;
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;
caf::PdmChildArrayField<RimPolylineTarget*> m_OBSOLETE_targets;
};

View File

@@ -210,9 +210,7 @@ RimFractureTemplate::RimFractureTemplate()
"" );
CAF_PDM_InitField( &m_scaleApplyButton, "ScaleApplyButton", false, "Apply" );
m_scaleApplyButton.xmlCapability()->disableIO();
m_scaleApplyButton.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_scaleApplyButton.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_scaleApplyButton );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -66,8 +66,7 @@ RimAbstractCorrelationPlot::RimAbstractCorrelationPlot()
m_dataSources.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_pushButtonSelectSummaryAddress, "SelectAddress", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_pushButtonSelectSummaryAddress );
m_pushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_pushButtonSelectSummaryAddress );
m_pushButtonSelectSummaryAddress = false;
CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Available Time Steps" );

View File

@@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimFaultReactivationDataAccessorTemperature.h"
#include "RigFaultReactivationModel.h"
#include "RimFaultReactivationEnums.h"
#include "RiaDefines.h"
@@ -74,10 +75,55 @@ void RimFaultReactivationDataAccessorTemperature::updateResultAccessor()
m_resultAccessor =
RigResultAccessorFactory::createFromResultAddress( m_caseData, 0, RiaDefines::PorosityModelType::MATRIX_MODEL, m_timeStep, resVarAddress );
auto [wellPaths, extractors] =
RimFaultReactivationDataAccessorWellLogExtraction::createEclipseWellPathExtractors( *m_model, *m_caseData, m_seabedDepth );
m_wellPaths = wellPaths;
m_extractors = extractors;
if ( m_resultAccessor.notNull() )
{
auto [wellPaths, extractors] =
RimFaultReactivationDataAccessorWellLogExtraction::createEclipseWellPathExtractors( *m_model, *m_caseData, m_seabedDepth );
m_wellPaths = wellPaths;
m_extractors = extractors;
m_gradient = computeGradient();
}
}
//--------------------------------------------------------------------------------------------------
/// Find the top encounter with reservoir (of the two well paths), and create gradient from that point
//--------------------------------------------------------------------------------------------------
double RimFaultReactivationDataAccessorTemperature::computeGradient() const
{
double gradient = std::numeric_limits<double>::infinity();
double minDepth = -std::numeric_limits<double>::max();
for ( auto gridPart : m_model->allGridParts() )
{
auto extractor = m_extractors.find( gridPart )->second;
auto wellPath = m_wellPaths.find( gridPart )->second;
auto [values, intersections] =
RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor.p(), *extractor.p(), *wellPath );
int lastOverburdenIndex = RimFaultReactivationDataAccessorWellLogExtraction::findLastOverburdenIndex( values );
if ( lastOverburdenIndex != -1 )
{
double depth = intersections[lastOverburdenIndex].z();
double value = values[lastOverburdenIndex];
if ( !std::isinf( value ) )
{
double currentGradient =
RimFaultReactivationDataAccessorWellLogExtraction::computeGradient( intersections[0].z(),
m_seabedTemperature,
intersections[lastOverburdenIndex].z(),
values[lastOverburdenIndex] );
if ( !std::isinf( value ) && !std::isnan( currentGradient ) && depth > minDepth )
{
gradient = currentGradient;
minDepth = depth;
}
}
}
}
return gradient;
}
//--------------------------------------------------------------------------------------------------
@@ -100,6 +146,13 @@ double RimFaultReactivationDataAccessorTemperature::valueAtPosition( const cvf::
{
if ( ( m_mainGrid != nullptr ) && m_resultAccessor.notNull() )
{
auto cellIdx = m_mainGrid->findReservoirCellIndexFromPoint( position );
if ( cellIdx != cvf::UNDEFINED_SIZE_T )
{
double tempFromEclipse = m_resultAccessor->cellScalar( cellIdx );
if ( !std::isinf( tempFromEclipse ) ) return tempFromEclipse;
}
CAF_ASSERT( m_extractors.find( gridPart ) != m_extractors.end() );
auto extractor = m_extractors.find( gridPart )->second;
@@ -110,16 +163,7 @@ double RimFaultReactivationDataAccessorTemperature::valueAtPosition( const cvf::
RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor.p(), *extractor.p(), *wellPath );
auto [value, pos] =
RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( intersections, values, position, m_seabedTemperature );
if ( pos.isUndefined() )
{
auto cellIdx = m_mainGrid->findReservoirCellIndexFromPoint( position );
if ( cellIdx != cvf::UNDEFINED_SIZE_T )
{
double tempFromEclipse = m_resultAccessor->cellScalar( cellIdx );
if ( !std::isinf( tempFromEclipse ) ) return tempFromEclipse;
}
}
RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( intersections, position, m_seabedTemperature, m_gradient );
return value;
}

View File

@@ -51,13 +51,15 @@ public:
size_t elementIndex = std::numeric_limits<size_t>::max() ) const override;
private:
void updateResultAccessor() override;
void updateResultAccessor() override;
double computeGradient() const;
RimEclipseCase* m_eclipseCase;
RigEclipseCaseData* m_caseData;
const RigMainGrid* m_mainGrid;
double m_seabedTemperature;
double m_seabedDepth;
double m_gradient;
cvf::ref<RigResultAccessor> m_resultAccessor;

View File

@@ -96,23 +96,11 @@ std::pair<double, cvf::Vec3d> RimFaultReactivationDataAccessorWellLogExtraction:
//--------------------------------------------------------------------------------------------------
std::pair<double, cvf::Vec3d>
RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( const std::vector<cvf::Vec3d>& intersections,
std::vector<double>& values,
const cvf::Vec3d& position,
double seabedTemperature )
double seabedTemperature,
double gradient )
{
// Fill in missing values
fillInMissingValuesWithTopValue( intersections, values, seabedTemperature );
auto [value, extractionPosition] = findValueAndPosition( intersections, values, position );
double minDistance = computeMinimumDistance( position, intersections );
if ( minDistance < 1.0 )
{
return { value, extractionPosition };
}
else
{
return { value, cvf::Vec3d::UNDEFINED };
}
return { calculateTemperature( seabedTemperature, intersections[0].z(), std::abs( position.z() ), gradient ), position };
}
//--------------------------------------------------------------------------------------------------
@@ -182,16 +170,6 @@ std::pair<int, int> RimFaultReactivationDataAccessorWellLogExtraction::findInter
//--------------------------------------------------------------------------------------------------
std::pair<int, int> RimFaultReactivationDataAccessorWellLogExtraction::findOverburdenAndUnderburdenIndex( const std::vector<double>& values )
{
auto findLastOverburdenIndex = []( const std::vector<double>& values )
{
for ( size_t i = 0; i < values.size(); i++ )
{
if ( !std::isinf( values[i] ) ) return static_cast<int>( i );
}
return -1;
};
auto findFirstUnderburdenIndex = []( const std::vector<double>& values )
{
for ( size_t i = values.size() - 1; i > 0; i-- )
@@ -207,6 +185,19 @@ std::pair<int, int> RimFaultReactivationDataAccessorWellLogExtraction::findOverb
return { lastOverburdenIndex, firstUnderburdenIndex };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimFaultReactivationDataAccessorWellLogExtraction::findLastOverburdenIndex( const std::vector<double>& values )
{
for ( size_t i = 0; i < values.size(); i++ )
{
if ( !std::isinf( values[i] ) ) return static_cast<int>( i );
}
return -1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -481,3 +472,12 @@ double RimFaultReactivationDataAccessorWellLogExtraction::calculatePorePressure(
{
return RiaEclipseUnitTools::pascalToBar( gradient * 9.81 * depth * 1000.0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( double topValue, double topDepth, double depth, double gradient )
{
double tvdDiff = topDepth - depth;
return tvdDiff * gradient + topValue;
}

View File

@@ -51,9 +51,9 @@ public:
double gradient );
static std::pair<double, cvf::Vec3d> calculateTemperature( const std::vector<cvf::Vec3d>& intersections,
std::vector<double>& values,
const cvf::Vec3d& position,
double seabedTemperature );
double seabedTemperature,
double gradient );
static std::pair<std::map<RimFaultReactivation::GridPart, cvf::ref<RigWellPath>>,
std::map<RimFaultReactivation::GridPart, cvf::ref<RigEclipseWellLogExtractor>>>
createEclipseWellPathExtractors( const RigFaultReactivationModel& model, RigEclipseCaseData& eclipseCaseData, double seabedDepth );
@@ -76,6 +76,10 @@ public:
const cvf::Vec3d& point,
const std::map<RimFaultReactivation::ElementSets, std::vector<unsigned int>>& elementSets );
static int findLastOverburdenIndex( const std::vector<double>& values );
static double computeGradient( double depth1, double value1, double depth2, double value2 );
protected:
static std::pair<int, int> findOverburdenAndUnderburdenIndex( const std::vector<double>& values );
static double computeValueWithGradient( const std::vector<cvf::Vec3d>& intersections,
@@ -89,7 +93,6 @@ protected:
static std::pair<double, cvf::Vec3d>
findValueAndPosition( const std::vector<cvf::Vec3d>& intersections, const std::vector<double>& values, const cvf::Vec3d& position );
static double computeGradient( double depth1, double value1, double depth2, double value2 );
static std::vector<double> extractDepthValues( const std::vector<cvf::Vec3d>& intersections );
static void insertUnderburdenValues( const std::vector<cvf::Vec3d>& intersections,
@@ -103,4 +106,5 @@ protected:
static double computeMinimumDistance( const cvf::Vec3d& position, const std::vector<cvf::Vec3d>& positions );
static double calculatePorePressure( double depth, double gradient );
static double calculateTemperature( double topValue, double topDepth, double depth, double gradient );
};

View File

@@ -99,8 +99,6 @@ RimFaultReactivationModel::RimFaultReactivationModel()
CAF_PDM_InitField( &m_faultZoneCells, "FaultZoneCells", 0, "Fault Zone Width [cells]" );
CAF_PDM_InitField( &m_showModelPlane, "ShowModelPlane", true, "Show 2D Model" );
CAF_PDM_InitField( &m_flipNodeOrderFW, "FlipNodeOrderFW", false, "FW: Flip Node Order" );
CAF_PDM_InitField( &m_flipNodeOrderHW, "FlipNodeOrderHW", false, "HW: Flip Node Order" );
CAF_PDM_InitFieldNoDefault( &m_fault, "Fault", "Fault" );
m_fault.uiCapability()->setUiReadOnly( true );
@@ -344,7 +342,6 @@ void RimFaultReactivationModel::updateVisualization()
m_2Dmodel->setGenerator( generator );
m_2Dmodel->updateGeometry( m_startCellIndex, (cvf::StructGridInterface::FaceType)m_startCellFace() );
m_2Dmodel->postProcessElementSets( eclipseCase() );
m_2Dmodel->flipNodeOrder( m_flipNodeOrderFW, m_flipNodeOrderHW );
view->scheduleCreateDisplayModelAndRedraw();
}
@@ -475,9 +472,6 @@ void RimFaultReactivationModel::defineUiOrdering( QString uiConfigName, caf::Pdm
gridModelGrp->add( &m_modelThickness );
gridModelGrp->add( &m_flipNodeOrderFW );
gridModelGrp->add( &m_flipNodeOrderHW );
auto appModelGrp = modelGrp->addNewGroup( "Appearance" );
appModelGrp->setCollapsedByDefault();
appModelGrp->add( &m_modelPart1Color );
@@ -741,9 +735,9 @@ std::string RimFaultReactivationModel::baseFilePath() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::array<double, 3> RimFaultReactivationModel::materialParameters( ElementSets elementSet ) const
std::array<double, 4> RimFaultReactivationModel::materialParameters( ElementSets elementSet ) const
{
std::array<double, 3> retVal = { 0.0, 0.0, 0.0 };
std::array<double, 4> retVal = { 0.0, 0.0, 0.0, 0.0 };
static std::map<ElementSets, std::string> groupMap = { { ElementSets::OverBurden, "material_overburden" },
{ ElementSets::Reservoir, "material_reservoir" },
{ ElementSets::IntraReservoir, "material_intrareservoir" },
@@ -759,6 +753,7 @@ std::array<double, 3> RimFaultReactivationModel::materialParameters( ElementSets
retVal[0] = grp->parameterDoubleValue( "youngs_modulus", 0.0 );
retVal[1] = grp->parameterDoubleValue( "poissons_number", 0.0 );
retVal[2] = grp->parameterDoubleValue( "density", 0.0 );
retVal[3] = grp->parameterDoubleValue( "expansion", 0.0 );
break;
}

View File

@@ -107,7 +107,7 @@ public:
std::vector<QDateTime> selectedTimeSteps() const;
std::vector<size_t> selectedTimeStepIndexes() const;
std::array<double, 3> materialParameters( ElementSets elementSet ) const;
std::array<double, 4> materialParameters( ElementSets elementSet ) const;
QStringList commandParameters() const;
@@ -162,8 +162,6 @@ private:
caf::PdmField<cvf::Color3f> m_modelPart2Color;
caf::PdmField<bool> m_showModelPlane;
caf::PdmField<bool> m_flipNodeOrderFW;
caf::PdmField<bool> m_flipNodeOrderHW;
caf::PdmField<double> m_modelExtentFromAnchor;
caf::PdmField<double> m_modelMinZ;

View File

@@ -78,7 +78,7 @@ RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot()
m_selectedTimeSteps.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_selectedTimeStepsUi, "SelectedTimeStepsUi", "" );
CAF_PDM_InitFieldNoDefault( &m_applyTimeSteps, "ApplyTimeSteps", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyTimeSteps );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applyTimeSteps );
CAF_PDM_InitField( &m_maxPvFraction,
"CellPVThreshold",
@@ -97,7 +97,7 @@ RimFlowCharacteristicsPlot::RimFlowCharacteristicsPlot()
CAF_PDM_InitField( &m_tracerFilter, "TracerFilter", QString(), "Tracer Filter" );
CAF_PDM_InitFieldNoDefault( &m_selectedTracerNames, "SelectedTracerNames", " " );
CAF_PDM_InitFieldNoDefault( &m_showRegion, "ShowRegion", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_showRegion );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_showRegion );
CAF_PDM_InitField( &m_minCommunication, "MinCommunication", 0.0, "Min Communication" );
CAF_PDM_InitField( &m_maxTof, "MaxTof", 146000, "Max Time of Flight [days]" );

View File

@@ -116,7 +116,7 @@ RimWellAllocationOverTimePlot::RimWellAllocationOverTimePlot()
CAF_PDM_InitFieldNoDefault( &m_excludeTimeSteps, "ExcludeTimeSteps", "" );
m_excludeTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_applyTimeStepSelections, "ApplyTimeStepSelections", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyTimeStepSelections );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applyTimeStepSelections );
CAF_PDM_InitFieldNoDefault( &m_flowDiagSolution, "FlowDiagSolution", "Plot Type" );
CAF_PDM_InitFieldNoDefault( &m_flowValueType, "FlowValueType", "Value Type" );

View File

@@ -157,7 +157,7 @@ RimWellConnectivityTable::RimWellConnectivityTable()
CAF_PDM_InitFieldNoDefault( &m_excludeTimeSteps, "ExcludeTimeSteps", "" );
m_excludeTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_applyTimeStepSelections, "ApplyTimeStepSelections", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_applyTimeStepSelections );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applyTimeStepSelections );
// Producer/Injector tracer configuration
CAF_PDM_InitFieldNoDefault( &m_selectedProducerTracersUiField, "SelectedProducerTracers", "Producer Tracers" );
@@ -169,7 +169,7 @@ RimWellConnectivityTable::RimWellConnectivityTable()
CAF_PDM_InitField( &m_syncSelectedProducersFromInjectorSelection, "SyncSelectedInjProd", false, "<- Synch Communicators" );
m_syncSelectedProducersFromInjectorSelection.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_applySelectedInectorProducerTracers, "ApplySelectedInectorProducerTracers", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_applySelectedInectorProducerTracers );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_applySelectedInectorProducerTracers );
// Table settings
CAF_PDM_InitField( &m_showValueLabels, "ShowValueLabels", false, "Show Value Labels" );

View File

@@ -116,13 +116,13 @@ RimGeoMechCase::RimGeoMechCase()
m_elementPropertyFileNameIndexUiSelection.xmlCapability()->disableIO();
CAF_PDM_InitField( &m_importElementPropertyFileCommand, "importElementPropertyFileCommad", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_importElementPropertyFileCommand );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_importElementPropertyFileCommand );
CAF_PDM_InitField( &m_closeElementPropertyFileCommand, "closeElementPropertyFileCommad", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_closeElementPropertyFileCommand );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_closeElementPropertyFileCommand );
CAF_PDM_InitField( &m_reloadElementPropertyFileCommand, "reloadElementPropertyFileCommand", false, "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_reloadElementPropertyFileCommand );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_reloadElementPropertyFileCommand );
caf::AppEnum<BiotCoefficientType> defaultBiotCoefficientType = RimGeoMechCase::BiotCoefficientType::BIOT_NONE;
CAF_PDM_InitField( &m_biotCoefficientType, "BiotCoefficientType", defaultBiotCoefficientType, "Biot Coefficient" );

View File

@@ -74,7 +74,7 @@ RimGeoMechFaultReactivationResult::RimGeoMechFaultReactivationResult()
CAF_PDM_InitField( &m_distanceFromFault, "DistanceFromFault", 5.0, "Distance From Fault" );
CAF_PDM_InitFieldNoDefault( &m_createFaultReactivationPlot, "CreateReactivationPlot", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_createFaultReactivationPlot );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_createFaultReactivationPlot );
CAF_PDM_InitFieldNoDefault( &m_faultNormal, "FaultNormal", "" );
CAF_PDM_InitFieldNoDefault( &m_faultTopPosition, "FaultTopPosition", "" );

View File

@@ -19,6 +19,7 @@
#include "RimGeoMechView.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RiaRegressionTestRunner.h"
@@ -31,6 +32,7 @@
#include "RigFormationNames.h"
#include "RigGeoMechCaseData.h"
#include "Polygons/RimPolygonInViewCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimCellFilterCollection.h"
#include "RimEclipseResultDefinition.h"
@@ -153,7 +155,7 @@ void RimGeoMechView::onLoadDataAndUpdate()
onUpdateScaleTransform();
updateSurfacesInViewTreeItems();
updateViewTreeItems( RiaDefines::ItemIn3dView::ALL );
if ( m_geomechCase )
{
@@ -319,6 +321,9 @@ void RimGeoMechView::onCreateDisplayModel()
m_seismicSectionCollection->appendPartsToModel( this, m_seismicVizModel.p(), transform.p(), femBBox );
nativeOrOverrideViewer()->addStaticModelOnce( m_seismicVizModel.p(), isUsingOverrideViewer() );
// Polygons
appendPolygonPartsToModel( transform.p(), ownerCase()->allCellsBoundingBox() );
// Surfaces
m_surfaceVizModel->removeAllParts();
@@ -1043,6 +1048,11 @@ 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.skipRemainingChildren( true );
}

View File

@@ -91,7 +91,7 @@ RimBoxIntersection::RimBoxIntersection()
CAF_PDM_InitField( &m_depthSliderStepSize, "DepthSliderStepSize", 0.5, "Depth Slider Step Size" );
CAF_PDM_InitFieldNoDefault( &m_show3DManipulator, "show3DManipulator", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_show3DManipulator );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_show3DManipulator );
m_show3DManipulator = false;
setDeletable( true );

View File

@@ -21,23 +21,20 @@
#include "RiaVec3Tools.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigPolyLinesData.h"
#include "RigSimulationWellCenterLineCalculator.h"
#include "RigWellPath.h"
#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonTools.h"
#include "Rim2dIntersectionView.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimEnsembleSurface.h"
#include "RimGeoMechView.h"
#include "RimGridView.h"
#include "RimIntersectionResultDefinition.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSimWellInView.h"
#include "RimSimWellInViewCollection.h"
#include "RimSurface.h"
@@ -48,12 +45,8 @@
#include "RimTools.h"
#include "RimWellPath.h"
#include "RiuViewer.h"
#include "RivExtrudedCurveIntersectionPartMgr.h"
#include "cafCmdFeature.h"
#include "cafCmdFeatureManager.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmFieldScriptingCapabilityCvfVec3d.h"
#include "cafPdmObjectScriptingCapability.h"
@@ -61,12 +54,9 @@
#include "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiListEditor.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiSliderEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include "cvfBoundingBox.h"
#include "cvfGeometryTools.h"
#include "cvfPlane.h"
namespace caf
{
@@ -77,6 +67,7 @@ void caf::AppEnum<RimExtrudedCurveIntersection::CrossSectionEnum>::setUp()
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_SIMULATION_WELL, "CS_SIMULATION_WELL", "Simulation Well" );
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE, "CS_POLYLINE", "Polyline" );
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_AZIMUTHLINE, "CS_AZIMUTHLINE", "Azimuth and Dip" );
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON, "CS_POLYGON", "Project Polygon" );
setDefault( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE );
}
@@ -186,6 +177,17 @@ void RimExtrudedCurveIntersection::configureForPolyLine()
m_inputPolylineFromViewerEnabled = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::configureForProjectPolyLine( RimPolygon* polygon )
{
m_type = CrossSectionEnum::CS_POLYGON;
m_projectPolygon = polygon;
updateName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -207,6 +209,11 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection()
CAF_PDM_InitFieldNoDefault( &m_direction, "Direction", "Direction" );
CAF_PDM_InitScriptableFieldNoDefault( &m_wellPath, "WellPath", "Well Path " );
CAF_PDM_InitScriptableFieldNoDefault( &m_simulationWell, "SimulationWell", "Simulation Well" );
CAF_PDM_InitFieldNoDefault( &m_projectPolygon, "ProjectPolygon", "Project Polygon" );
CAF_PDM_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editPolygonButton );
CAF_PDM_InitScriptableFieldNoDefault( &m_userPolylineXyz, "Points", "Points", "", "Use Ctrl-C for copy and Ctrl-V for paste", "" );
CAF_PDM_InitFieldNoDefault( &m_userPolylineXydForUi, "PointsUi", "Points", "", "Use Ctrl-C for copy and Ctrl-V for paste", "" );
@@ -233,15 +240,15 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection()
CAF_PDM_InitField( &m_lengthDown, "lengthDown", 1000.0, "Length Down" );
CAF_PDM_InitFieldNoDefault( &m_inputPolylineFromViewerEnabled, "m_activateUiAppendPointsCommand", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputPolylineFromViewerEnabled );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_inputPolylineFromViewerEnabled );
m_inputPolylineFromViewerEnabled = false;
CAF_PDM_InitFieldNoDefault( &m_inputExtrusionPointsFromViewerEnabled, "inputExtrusionPointsFromViewerEnabled", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputExtrusionPointsFromViewerEnabled );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_inputExtrusionPointsFromViewerEnabled );
m_inputExtrusionPointsFromViewerEnabled = false;
CAF_PDM_InitFieldNoDefault( &m_inputTwoAzimuthPointsFromViewerEnabled, "inputTwoAzimuthPointsFromViewerEnabled", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputTwoAzimuthPointsFromViewerEnabled );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_inputTwoAzimuthPointsFromViewerEnabled );
m_inputTwoAzimuthPointsFromViewerEnabled = false;
CAF_PDM_InitFieldNoDefault( &m_surfaceIntersections, "SurfaceIntersections", "Surface Intersections" );
@@ -439,11 +446,11 @@ void RimExtrudedCurveIntersection::setKFilterOverride( bool collectionOverride,
void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_isActive || changedField == &m_type || changedField == &m_direction || changedField == &m_wellPath ||
changedField == &m_simulationWell || changedField == &m_branchIndex || changedField == &m_extentLength ||
changedField == &m_lengthUp || changedField == &m_lengthDown || changedField == &m_showInactiveCells ||
changedField == &m_useSeparateDataSource || changedField == &m_separateDataSource || changedField == &m_depthUpperThreshold ||
changedField == &m_depthLowerThreshold || changedField == &m_depthThresholdOverridden || changedField == &m_depthFilterType ||
changedField == &m_enableKFilter || changedField == &m_kFilterText || changedField == &m_kFilterCollectionOverride )
changedField == &m_simulationWell || changedField == &m_branchIndex || changedField == &m_extentLength || changedField == &m_lengthUp ||
changedField == &m_lengthDown || changedField == &m_showInactiveCells || changedField == &m_useSeparateDataSource ||
changedField == &m_separateDataSource || changedField == &m_depthUpperThreshold || changedField == &m_depthLowerThreshold ||
changedField == &m_depthThresholdOverridden || changedField == &m_depthFilterType || changedField == &m_enableKFilter ||
changedField == &m_kFilterText || changedField == &m_kFilterCollectionOverride || changedField == &m_projectPolygon )
{
rebuildGeometryAndScheduleCreateDisplayModel();
}
@@ -453,7 +460,8 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle*
recomputeSimulationWellBranchData();
}
if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex )
if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex ||
changedField == &m_projectPolygon || changedField == &m_type )
{
updateName();
}
@@ -511,6 +519,15 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle*
{
rebuildGeometryAndScheduleCreateDisplayModel();
}
if ( changedField == &m_editPolygonButton )
{
RimPolygonTools::selectAndActivatePolygonInView( m_projectPolygon(), this );
m_editPolygonButton = false;
return;
}
}
//--------------------------------------------------------------------------------------------------
@@ -540,6 +557,11 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf::
geometryGroup->add( &m_userPolylineXydForUi );
geometryGroup->add( &m_inputPolylineFromViewerEnabled );
}
else if ( type() == CrossSectionEnum::CS_POLYGON )
{
geometryGroup->add( &m_projectPolygon );
geometryGroup->add( &m_editPolygonButton, { .newRow = false } );
}
else if ( type() == CrossSectionEnum::CS_AZIMUTHLINE )
{
geometryGroup->add( &m_twoAzimuthPoints );
@@ -668,6 +690,19 @@ QList<caf::PdmOptionItemInfo> RimExtrudedCurveIntersection::calculateValueOption
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
}
}
else if ( fieldNeedingOptions == &m_projectPolygon )
{
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
RimTools::polygonOptionItems( &options );
if ( m_projectPolygon() == nullptr )
{
auto polygonCollection = RimTools::polygonCollection();
auto polygons = polygonCollection->allPolygons();
if ( !polygons.empty() ) m_projectPolygon = polygons.front();
}
}
else if ( fieldNeedingOptions == &m_branchIndex )
{
updateSimulationWellCenterline();
@@ -775,8 +810,6 @@ std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::polyLines( cv
{
if ( m_simulationWell() )
{
updateSimulationWellCenterline();
int branchIndexToUse = branchIndex();
if ( 0 <= branchIndexToUse && branchIndexToUse < static_cast<int>( m_simulationWellBranchCenterlines.size() ) )
@@ -794,6 +827,13 @@ std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::polyLines( cv
{
lines.push_back( m_userPolylineXyz );
}
else if ( type() == CrossSectionEnum::CS_POLYGON )
{
if ( m_projectPolygon )
{
lines = m_projectPolygon->polyLinesData()->completePolyLines();
}
}
else if ( type() == CrossSectionEnum::CS_AZIMUTHLINE )
{
lines.push_back( m_twoAzimuthPoints );
@@ -863,7 +903,7 @@ std::vector<cvf::Vec3d> RimExtrudedCurveIntersection::polyLinesForExtrusionDirec
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::updateSimulationWellCenterline() const
void RimExtrudedCurveIntersection::updateSimulationWellCenterline()
{
if ( m_isActive() && type() == CrossSectionEnum::CS_SIMULATION_WELL && m_simulationWell() )
{
@@ -954,6 +994,10 @@ void RimExtrudedCurveIntersection::updateName()
{
m_name = m_wellPath()->name();
}
else if ( m_type() == CrossSectionEnum::CS_POLYGON && m_projectPolygon() )
{
m_name = m_projectPolygon->name();
}
Rim2dIntersectionView* iView = correspondingIntersectionView();
if ( iView )
@@ -1081,6 +1125,14 @@ void RimExtrudedCurveIntersection::defineEditorAttribute( const caf::PdmFieldHan
{
setBaseColor( m_inputExtrusionPointsFromViewerEnabled, dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute ) );
}
if ( field == &m_editPolygonButton )
{
if ( auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) )
{
attrib->m_buttonText = "Edit";
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -24,9 +24,10 @@
#include "RimIntersectionEnums.h"
#include "cafPdmChildField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmProxyValueField.h"
#include <QString>
#include "cvfVector3.h"
class RimWellPath;
class RivExtrudedCurveIntersectionPartMgr;
@@ -40,6 +41,7 @@ class RimSurfaceCollection;
class RimSurfaceIntersectionCollection;
class RimSurfaceIntersectionCurve;
class RimSurfaceIntersectionBand;
class RimPolygon;
namespace caf
{
@@ -62,7 +64,8 @@ public:
CS_WELL_PATH,
CS_SIMULATION_WELL,
CS_POLYLINE,
CS_AZIMUTHLINE
CS_AZIMUTHLINE,
CS_POLYGON,
};
enum class CrossSectionDirEnum
@@ -102,6 +105,7 @@ public:
void configureForSimulationWell( RimSimWellInView* simWell );
void configureForWellPath( RimWellPath* wellPath );
void configureForPolyLine();
void configureForProjectPolyLine( RimPolygon* polygon );
void configureForAzimuthLine();
std::vector<std::vector<cvf::Vec3d>> polyLines( cvf::Vec3d* flattenedPolylineStartPoint = nullptr ) const;
@@ -134,7 +138,7 @@ public:
int branchIndex() const;
void rebuildGeometryAndScheduleCreateDisplayModel();
protected:
private:
caf::PdmFieldHandle* userDescriptionField() final;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
@@ -143,13 +147,12 @@ protected:
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
private:
static void setPushButtonText( bool buttonEnable, caf::PdmUiPushButtonEditorAttribute* attribute );
static void setBaseColor( bool enable, caf::PdmUiListEditorAttribute* attribute );
RimSimWellInViewCollection* simulationWellCollection() const;
void updateAzimuthLine();
void updateSimulationWellCenterline() const;
void updateSimulationWellCenterline();
void addExtents( std::vector<cvf::Vec3d>& polyLine ) const;
void updateName();
static double azimuthInRadians( cvf::Vec3d vec );
@@ -181,6 +184,9 @@ private:
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmPtrField<RimSimWellInView*> m_simulationWell;
caf::PdmPtrField<RimPolygon*> m_projectPolygon;
caf::PdmField<bool> m_editPolygonButton;
caf::PdmField<bool> m_inputPolylineFromViewerEnabled;
caf::PdmField<bool> m_inputExtrusionPointsFromViewerEnabled;
caf::PdmField<bool> m_inputTwoAzimuthPointsFromViewerEnabled;
@@ -202,11 +208,11 @@ private:
cvf::ref<RivExtrudedCurveIntersectionPartMgr> m_crossSectionPartMgr;
mutable std::vector<std::vector<cvf::Vec3d>> m_simulationWellBranchCenterlines;
std::vector<std::vector<cvf::Vec3d>> m_simulationWellBranchCenterlines;
caf::PdmField<bool> m_enableKFilter;
caf::PdmField<QString> m_kFilterText;
caf::PdmField<bool> m_kFilterCollectionOverride;
caf::PdmField<QString> m_kFilterCollectionText;
};
};

View File

@@ -19,7 +19,6 @@
#include "RimIntersection.h"
#include "RigEclipseCaseData.h"
#include "RigFemPartCollection.h"
#include "RigGeoMechCaseData.h"
#include "RimEclipseCase.h"
#include "RimEclipseResultDefinition.h"

View File

@@ -18,7 +18,6 @@
#pragma once
#include "cafPdmField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"

View File

@@ -0,0 +1,29 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimPolygon.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonFile.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonInView.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonInViewCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonAppearance.h
${CMAKE_CURRENT_LIST_DIR}/RimPolygonTools.h
)
set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimPolygon.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonFile.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonInView.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonInViewCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonAppearance.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolygonTools.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
source_group(
"ProjectDataModel\\Polygons"
FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES}
${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake
)

View File

@@ -0,0 +1,206 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygon.h"
#include "RigPolyLinesData.h"
#include "RiaApplication.h"
#include "Rim3dView.h"
#include "RimPolygonAppearance.h"
#include "RimPolygonTools.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTreeAttributes.h"
CAF_PDM_SOURCE_INIT( RimPolygon, "RimPolygon" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygon::RimPolygon()
: objectChanged( this )
{
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitField( &m_isReadOnly, "IsReadOnly", false, "Read Only" );
CAF_PDM_InitFieldNoDefault( &m_pointsInDomainCoords, "PointsInDomainCoords", "Points" );
CAF_PDM_InitField( &m_editPolygonButton, "EditPolygonButton", false, "Edit" );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_editPolygonButton );
CAF_PDM_InitFieldNoDefault( &m_appearance, "Appearance", "Appearance" );
m_appearance = new RimPolygonAppearance;
m_appearance.uiCapability()->setUiTreeChildrenHidden( true );
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigPolyLinesData> RimPolygon::polyLinesData() const
{
cvf::ref<RigPolyLinesData> pld = new RigPolyLinesData;
pld->setPolyLine( m_pointsInDomainCoords() );
m_appearance->applyAppearanceSettings( pld.p() );
return pld;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
m_appearance->uiOrdering( uiConfigName, uiOrdering );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicNewPolygonIntersectionFeature";
menuBuilder << "RicNewPolygonFilterFeature";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::setPointsInDomainCoords( const std::vector<cvf::Vec3d>& points )
{
m_pointsInDomainCoords = points;
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimPolygon::pointsInDomainCoords() const
{
return m_pointsInDomainCoords();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::setIsClosed( bool isClosed )
{
m_appearance->setIsClosed( isClosed );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygon::isClosed() const
{
return m_appearance->isClosed();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::setReadOnly( bool isReadOnly )
{
m_isReadOnly = isReadOnly;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygon::isReadOnly() const
{
return m_isReadOnly();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( nameField() );
uiOrdering.add( &m_isReadOnly );
uiOrdering.add( &m_editPolygonButton );
auto groupPoints = uiOrdering.addNewGroup( "Points" );
groupPoints->setCollapsedByDefault();
groupPoints->add( &m_pointsInDomainCoords );
m_pointsInDomainCoords.uiCapability()->setUiReadOnly( m_isReadOnly() );
auto group = uiOrdering.addNewGroup( "Appearance" );
m_appearance->uiOrdering( uiConfigName, *group );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_pointsInDomainCoords )
{
objectChanged.send();
}
if ( changedField == &m_editPolygonButton )
{
auto activeView = RiaApplication::instance()->activeReservoirView();
RimPolygonTools::selectAndActivatePolygonInView( this, activeView );
m_editPolygonButton = false;
return;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
{
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_editPolygonButton )
{
if ( auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) )
{
attrib->m_buttonText = "Edit in Active View";
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygon::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( m_isReadOnly )
{
caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( attribute, ":/padlock.svg" );
}
}

View File

@@ -0,0 +1,71 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimNamedObject.h"
#include "RimPolylinesDataInterface.h"
#include "cafPdmChildField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cvfVector3.h"
class RimPolygonAppearance;
namespace caf
{
class CmdFeatureMenuBuilder;
}
class RimPolygon : public RimNamedObject, public RimPolylinesDataInterface
{
CAF_PDM_HEADER_INIT;
public:
caf::Signal<> objectChanged;
public:
RimPolygon();
void setPointsInDomainCoords( const std::vector<cvf::Vec3d>& points );
std::vector<cvf::Vec3d> pointsInDomainCoords() const;
void setIsClosed( bool isClosed );
bool isClosed() const;
void setReadOnly( bool isReadOnly );
bool isReadOnly() const;
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;
protected:
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;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
private:
caf::PdmField<bool> m_isReadOnly;
caf::PdmField<bool> m_editPolygonButton;
caf::PdmField<std::vector<cvf::Vec3d>> m_pointsInDomainCoords;
caf::PdmChildField<RimPolygonAppearance*> m_appearance;
};

View File

@@ -0,0 +1,214 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonAppearance.h"
#include "RimCase.h"
#include "RimProject.h"
#include "RigPolyLinesData.h"
#include "RiaNumericalTools.h"
#include "RiaStdStringTools.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiLineEditor.h"
#include "cvfBoundingBox.h"
CAF_PDM_SOURCE_INIT( RimPolygonAppearance, "RimPolygonAppearance" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class ThicknessValidator : public QValidator
{
public:
State validate( QString& input, int& pos ) const override
{
if ( input.isEmpty() ) return State::Intermediate;
int val = RiaStdStringTools::toInt( input.toStdString() );
if ( val > 0 && val < 8 )
return State::Acceptable;
else
return State::Invalid;
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RadiusValidator : public QValidator
{
public:
State validate( QString& input, int& pos ) const override
{
if ( input.isEmpty() ) return State::Intermediate;
double val = RiaStdStringTools::toDouble( input.toStdString() );
if ( val > 0.001 && val <= 2.0 )
return State::Acceptable;
else
return State::Invalid;
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonAppearance::RimPolygonAppearance()
: objectChanged( this )
{
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitField( &m_isClosed, "IsClosed", true, "Closed Polygon" );
CAF_PDM_InitField( &m_showLines, "ShowLines", true, "Show Lines" );
CAF_PDM_InitField( &m_showSpheres, "ShowSpheres", false, "Show Spheres" );
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_polygonPlaneDepth, "PolygonPlaneDepth", 0.0, "Polygon Plane Depth" );
CAF_PDM_InitField( &m_lockPolygonToPlane, "LockPolygon", false, "Lock Polygon to Plane" );
m_polygonPlaneDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
m_polygonPlaneDepth.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::TOP );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::applyAppearanceSettings( RigPolyLinesData* polyLinesData )
{
polyLinesData->setLineAppearance( m_lineThickness, m_lineColor, m_isClosed );
polyLinesData->setSphereAppearance( m_sphereRadiusFactor, m_sphereColor );
polyLinesData->setZPlaneLock( m_lockPolygonToPlane, -m_polygonPlaneDepth );
polyLinesData->setVisibility( m_showLines, m_showSpheres );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::setIsClosed( bool isClosed )
{
m_isClosed = isClosed;
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonAppearance::isClosed() const
{
return m_isClosed();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_showLines );
if ( m_showLines )
{
uiOrdering.add( &m_lineThickness );
uiOrdering.add( &m_lineColor );
}
uiOrdering.add( &m_showSpheres );
if ( m_showSpheres )
{
uiOrdering.add( &m_sphereRadiusFactor );
uiOrdering.add( &m_sphereColor );
}
uiOrdering.add( &m_lockPolygonToPlane );
if ( m_lockPolygonToPlane )
{
uiOrdering.add( &m_polygonPlaneDepth );
}
uiOrdering.add( &m_isClosed );
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
objectChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonAppearance::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_lineThickness )
{
if ( auto myAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute ) )
{
myAttr->validator = new ThicknessValidator();
}
}
else if ( field == &m_lineThickness )
{
if ( auto myAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute ) )
{
myAttr->validator = new RadiusValidator();
}
}
else if ( field == &m_polygonPlaneDepth )
{
if ( auto attr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
{
auto allCases = RimProject::current()->allGridCases();
if ( allCases.empty() )
{
attr->m_minimum = 0;
attr->m_maximum = 10000.0;
}
else
{
double min = std::numeric_limits<double>::max();
double max = -std::numeric_limits<double>::max();
for ( auto gridCase : allCases )
{
auto bb = gridCase->allCellsBoundingBox();
min = std::min( min, bb.min().z() );
max = std::max( max, bb.max().z() );
}
auto adjustedMin = RiaNumericalTools::roundToNumSignificantDigitsFloor( -min, 2 );
auto adjustedMax = RiaNumericalTools::roundToNumSignificantDigitsCeil( -max, 2 );
attr->m_minimum = adjustedMax;
attr->m_maximum = adjustedMin;
}
}
}
}

View File

@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmFieldCvfColor.h"
#include "cvfVector3.h"
class RigPolyLinesData;
class RimPolygonAppearance : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
caf::Signal<> objectChanged;
void applyAppearanceSettings( RigPolyLinesData* polyLinesData );
void setIsClosed( bool isClosed );
bool isClosed() const;
public:
RimPolygonAppearance();
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
private:
caf::PdmField<bool> m_isClosed;
caf::PdmField<bool> m_showLines;
caf::PdmField<int> m_lineThickness;
caf::PdmField<cvf::Color3f> m_lineColor;
caf::PdmField<bool> m_showSpheres;
caf::PdmField<double> m_sphereRadiusFactor;
caf::PdmField<cvf::Color3f> m_sphereColor;
caf::PdmField<bool> m_lockPolygonToPlane;
caf::PdmField<double> m_polygonPlaneDepth;
};

View File

@@ -0,0 +1,206 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonCollection.h"
#include "Rim3dView.h"
#include "RimPolygon.h"
#include "RimPolygonFile.h"
#include "RimProject.h"
CAF_PDM_SOURCE_INIT( RimPolygonCollection, "RimPolygonCollection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonCollection::RimPolygonCollection()
{
CAF_PDM_InitObject( "Polygons (Under construction)", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" );
CAF_PDM_InitFieldNoDefault( &m_polygonFiles, "PolygonFiles", "Polygon Files" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::loadData()
{
for ( auto& p : m_polygonFiles() )
{
p->loadData();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygon* RimPolygonCollection::appendUserDefinedPolygon()
{
auto newPolygon = new RimPolygon();
newPolygon->setName( "Polygon " + QString::number( userDefinedPolygons().size() + 1 ) );
addUserDefinedPolygon( newPolygon );
return newPolygon;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::addUserDefinedPolygon( RimPolygon* polygon )
{
m_polygons().push_back( polygon );
connectSignals( polygon );
updateViewTreeItems();
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::deleteUserDefinedPolygons()
{
m_polygons().deleteChildren();
updateViewTreeItems();
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::addPolygonFile( RimPolygonFile* polygonFile )
{
m_polygonFiles().push_back( polygonFile );
updateViewTreeItems();
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygon*> RimPolygonCollection::userDefinedPolygons() const
{
return m_polygons.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygonFile*> RimPolygonCollection::polygonFiles() const
{
return m_polygonFiles.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygon*> RimPolygonCollection::allPolygons() const
{
std::vector<RimPolygon*> allPolygons;
for ( auto& p : m_polygonFiles() )
{
for ( auto& polygon : p->polygons() )
{
allPolygons.push_back( polygon );
}
}
for ( auto& polygon : m_polygons.childrenByType() )
{
allPolygons.push_back( polygon );
}
return allPolygons;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects )
{
updateViewTreeItems();
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
{
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::updateViewTreeItems()
{
RimProject* proj = RimProject::current();
// Make sure the tree items are synchronized
std::vector<Rim3dView*> views;
proj->allViews( views );
for ( auto view : views )
{
view->updateViewTreeItems( RiaDefines::ItemIn3dView::POLYGON );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::scheduleRedrawViews()
{
RimProject* proj = RimProject::current();
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::connectSignals( RimPolygon* polygon )
{
if ( polygon )
{
polygon->objectChanged.connect( this, &RimPolygonCollection::onObjectChanged );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::onObjectChanged( const caf::SignalEmitter* emitter )
{
scheduleRedrawViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonCollection::initAfterRead()
{
for ( auto& p : m_polygons() )
{
connectSignals( p );
}
}

View File

@@ -0,0 +1,65 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmChildArrayField.h"
#include "cafPdmObject.h"
class RimPolygon;
class RimPolygonFile;
//==================================================================================================
///
///
//==================================================================================================
class RimPolygonCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimPolygonCollection();
void loadData();
RimPolygon* appendUserDefinedPolygon();
void addUserDefinedPolygon( RimPolygon* polygon );
void deleteUserDefinedPolygons();
void addPolygonFile( RimPolygonFile* polygonFile );
std::vector<RimPolygon*> userDefinedPolygons() const;
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 updateViewTreeItems();
void scheduleRedrawViews();
void connectSignals( RimPolygon* polygon );
void onObjectChanged( const caf::SignalEmitter* emitter );
private:
caf::PdmChildArrayField<RimPolygon*> m_polygons;
caf::PdmChildArrayField<RimPolygonFile*> m_polygonFiles;
protected:
void initAfterRead() override;
};

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 Equinor ASA
// 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
@@ -16,73 +16,67 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivCellFilterPartMgr.h"
#include "RimPolygonFile.h"
#include "RimPolygon.h"
#include "Rim3dView.h"
#include "RimCellFilterCollection.h"
#include "RimPolygonFilter.h"
#include "RivPolylinePartMgr.h"
#include "cafPdmObject.h"
CAF_PDM_SOURCE_INIT( RimPolygonFile, "RimPolygonFileFile" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivCellFilterPartMgr::RivCellFilterPartMgr( Rim3dView* view )
: m_rimView( view )
RimPolygonFile::RimPolygonFile()
{
CAF_PDM_InitObject( "PolygonFile", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_fileName, "StimPlanFileName", "File Name" );
CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" );
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::loadData()
{
loadPolygonsFromFile();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygon*> RimPolygonFile::polygons() const
{
return m_polygons.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonFile::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivCellFilterPartMgr::~RivCellFilterPartMgr()
void RimPolygonFile::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
loadPolygonsFromFile();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCellFilterPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& boundingBox )
void RimPolygonFile::loadPolygonsFromFile()
{
createCellFilterPartManagers();
// m_polygons()->deletePolygons();
for ( auto& partMgr : m_cellFilterPartMgrs )
{
partMgr->appendDynamicGeometryPartsToModel( model, displayCoordTransform, boundingBox );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCellFilterPartMgr::createCellFilterPartManagers()
{
std::vector<RimCellFilterCollection*> colls = m_rimView->descendantsIncludingThisOfType<RimCellFilterCollection>();
if ( colls.empty() ) return;
auto coll = colls.front();
clearGeometryCache();
for ( auto filter : coll->filters() )
{
RimPolygonFilter* polyFilter = dynamic_cast<RimPolygonFilter*>( filter );
if ( polyFilter )
{
RivPolylinePartMgr* ppm = new RivPolylinePartMgr( m_rimView, polyFilter, coll );
m_cellFilterPartMgrs.push_back( ppm );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCellFilterPartMgr::clearGeometryCache()
{
m_cellFilterPartMgrs.clear();
auto polygon = new RimPolygon();
polygon->setName( "Polygon 1" );
m_polygons.push_back( polygon );
polygon = new RimPolygon();
polygon->setName( "Polygon 2" );
m_polygons.push_back( polygon );
}

View File

@@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimNamedObject.h"
#include "cafFilePath.h"
#include "cafPdmChildArrayField.h"
class RimPolygon;
class RimPolygonFile : public RimNamedObject
{
CAF_PDM_HEADER_INIT;
public:
RimPolygonFile();
void loadData();
std::vector<RimPolygon*> polygons() const;
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
private:
void loadPolygonsFromFile();
private:
caf::PdmField<caf::FilePath> m_fileName;
caf::PdmChildArrayField<RimPolygon*> m_polygons;
};

View File

@@ -0,0 +1,439 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonInView.h"
#include "RigPolyLinesData.h"
#include "Rim3dView.h"
#include "RimPolygon.h"
#include "RimPolygonInViewCollection.h"
#include "RimPolylineTarget.h"
#include "RimTools.h"
#include "WellPathCommands/PointTangentManipulator/RicPolyline3dEditor.h"
#include "WellPathCommands/RicPolylineTargetsPickEventHandler.h"
#include "Riu3DMainWindowTools.h"
#include "RiuGuiTheme.h"
#include "RivPolylinePartMgr.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafDisplayCoordTransform.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTableViewEditor.h"
#include "cafPdmUiTreeAttributes.h"
#include "cvfModelBasicList.h"
CAF_PDM_SOURCE_INIT( RimPolygonInView, "RimPolygonInView" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonInView::RimPolygonInView()
: m_pickTargetsEventHandler( new RicPolylineTargetsPickEventHandler( this ) )
{
CAF_PDM_InitObject( "Polygon", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_polygon, "Polygon", "Polygon" );
m_polygon.uiCapability()->setUiReadOnly( true );
nameField()->uiCapability()->setUiReadOnly( true );
CAF_PDM_InitField( &m_enablePicking, "EnablePicking", false, "" );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_enablePicking );
CAF_PDM_InitField( &m_selectPolygon, "SelectPolygon", false, "" );
caf::PdmUiPushButtonEditor::configureEditorLabelHidden( &m_selectPolygon );
CAF_PDM_InitField( &m_handleScalingFactor, "HandleScalingFactor", 1.0, "Handle Scaling Factor" );
CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" );
m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
m_targets.uiCapability()->setUiTreeChildrenHidden( true );
m_targets.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
m_targets.uiCapability()->setCustomContextMenuEnabled( true );
setUi3dEditorTypeName( RicPolyline3dEditor::uiEditorTypeName() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygon* RimPolygonInView::polygon() const
{
return m_polygon();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::setPolygon( RimPolygon* polygon )
{
m_polygon = polygon;
updateTargetsFromPolygon();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::appendPartsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* scaleTransform,
const cvf::BoundingBox& boundingBox )
{
auto view = firstAncestorOfType<Rim3dView>();
if ( m_polylinePartMgr.isNull() ) m_polylinePartMgr = new RivPolylinePartMgr( view, this, this );
m_polylinePartMgr->appendDynamicGeometryPartsToModel( model, scaleTransform, boundingBox );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::enablePicking( bool enable )
{
m_enablePicking = enable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert )
{
size_t index = m_targets.indexOf( targetToInsertBefore );
if ( index < m_targets.size() )
m_targets.insert( index, targetToInsert );
else
m_targets.push_back( targetToInsert );
updatePolygonFromTargets();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::deleteTarget( RimPolylineTarget* targetToDelete )
{
m_targets.removeChild( targetToDelete );
delete targetToDelete;
updatePolygonFromTargets();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::updateEditorsAndVisualization()
{
updateConnectedEditors();
updateVisualization();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::updateVisualization()
{
auto view = firstAncestorOfType<Rim3dView>();
if ( view )
{
view->scheduleCreateDisplayModelAndRedraw();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolylineTarget*> RimPolygonInView::activeTargets() const
{
return m_targets.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolygonInView::pickingEnabled() const
{
return m_enablePicking();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PickEventHandler* RimPolygonInView::pickEventHandler() const
{
auto filterColl = firstAncestorOfType<RimPolygonInViewCollection>();
if ( filterColl && !filterColl->isChecked() ) return nullptr;
if ( !isChecked() ) return nullptr;
if ( m_polygon() && polygon()->isReadOnly() ) return nullptr;
return m_pickTargetsEventHandler.get();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects )
{
if ( childArray == &m_targets )
{
updatePolygonFromTargets();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigPolyLinesData> RimPolygonInView::polyLinesData() const
{
if ( m_polygon )
{
return m_polygon->polyLinesData();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::updatePolygonFromTargets()
{
if ( m_polygon )
{
std::vector<cvf::Vec3d> points;
for ( const RimPolylineTarget* target : m_targets )
{
points.push_back( target->targetPointXYZ() );
}
m_polygon->setPointsInDomainCoords( points );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::updateTargetsFromPolygon()
{
if ( m_polygon )
{
m_targets.deleteChildren();
for ( const auto& p : m_polygon->pointsInDomainCoords() )
{
auto target = new RimPolylineTarget();
target->setAsPointXYZ( p );
m_targets.push_back( target );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
updateNameField();
bool enableEdit = true;
if ( m_polygon() && m_polygon->isReadOnly() ) enableEdit = false;
uiOrdering.add( m_polygon );
if ( enableEdit )
{
uiOrdering.add( &m_enablePicking );
uiOrdering.add( &m_targets );
uiOrdering.add( &m_handleScalingFactor );
}
if ( m_polygon() )
{
uiOrdering.add( &m_selectPolygon );
}
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_enablePicking )
{
updateConnectedEditors();
}
if ( changedField == &m_selectPolygon && m_polygon() )
{
Riu3DMainWindowTools::selectAsCurrentItem( m_polygon() );
}
updateVisualization();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimPolygonInView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_polygon )
{
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
RimTools::polygonOptionItems( &options );
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( auto attrib = dynamic_cast<RicPolyline3dEditorAttribute*>( attribute ) )
{
attrib->pickEventHandler = m_pickTargetsEventHandler;
attrib->enablePicking = m_enablePicking;
}
if ( m_polygon() && m_polygon->isReadOnly() )
{
caf::PdmUiTreeViewItemAttribute::createTagIfTreeViewItemAttribute( attribute, ":/padlock.svg" );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_enablePicking );
uiOrdering.add( &m_targets );
uiOrdering.add( &m_handleScalingFactor );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
if ( m_polygon() ) m_polygon->appendMenuItems( menuBuilder );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPolygonInView::scalingFactorForTarget() const
{
return m_handleScalingFactor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_enablePicking )
{
auto* pbAttribute = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( pbAttribute )
{
if ( !m_enablePicking )
{
pbAttribute->m_buttonText = "Start Picking Points";
}
else
{
pbAttribute->m_buttonText = "Stop Picking Points";
}
}
}
if ( field == &m_selectPolygon )
{
auto* pbAttribute = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( pbAttribute )
{
pbAttribute->m_buttonText = "Go to Polygon";
}
}
if ( field == &m_targets )
{
if ( auto tvAttribute = dynamic_cast<caf::PdmUiTableViewEditorAttribute*>( attribute ) )
{
tvAttribute->resizePolicy = caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FIT_CONTENT;
if ( m_enablePicking )
{
tvAttribute->baseColor = RiuGuiTheme::getColorByVariableName( "externalInputColor" );
}
tvAttribute->alwaysEnforceResizePolicy = true;
tvAttribute->heightHint = 1000;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget )
{
if ( m_polygon() && m_polygon->isReadOnly() ) return;
caf::CmdFeatureMenuBuilder menuBuilder;
menuBuilder << "RicNewPolylineTargetFeature";
menuBuilder << "Separator";
menuBuilder << "RicDeletePolylineTargetFeature";
menuBuilder.appendToMenu( menu );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::updateNameField()
{
QString name = "Undefined";
if ( m_polygon() )
{
name = m_polygon->name();
}
setName( name );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= "" */ )
{
updateNameField();
}

View File

@@ -0,0 +1,99 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimCheckableNamedObject.h"
#include "RimPolylinePickerInterface.h"
#include "RimPolylinesDataInterface.h"
#include "RivPolylinePartMgr.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmPtrField.h"
class RimPolygon;
class RivPolylinePartMgr;
class RicPolylineTargetsPickEventHandler;
class RimPolylineTarget;
namespace cvf
{
class ModelBasicList;
class BoundingBox;
} // namespace cvf
namespace caf
{
class DisplayCoordTransform;
} // namespace caf
class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesDataInterface, public RimPolylinePickerInterface
{
CAF_PDM_HEADER_INIT;
public:
RimPolygonInView();
RimPolygon* polygon() const;
void setPolygon( RimPolygon* polygon );
void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox );
void enablePicking( bool enable );
void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override;
void deleteTarget( RimPolylineTarget* targetToDelete ) override;
void updateEditorsAndVisualization() override;
void updateVisualization() override;
std::vector<RimPolylineTarget*> activeTargets() const override;
bool pickingEnabled() const override;
caf::PickEventHandler* pickEventHandler() const override;
double scalingFactorForTarget() const override;
cvf::ref<RigPolyLinesData> polyLinesData() const override;
void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects ) override;
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void uiOrderingForLocalPolygon( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
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;
private:
void updateNameField();
void updatePolygonFromTargets();
void updateTargetsFromPolygon();
private:
caf::PdmPtrField<RimPolygon*> m_polygon;
caf::PdmField<bool> m_selectPolygon;
caf::PdmField<bool> m_enablePicking;
caf::PdmField<double> m_handleScalingFactor;
caf::PdmChildArrayField<RimPolylineTarget*> m_targets;
cvf::ref<RivPolylinePartMgr> m_polylinePartMgr;
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;
};

View File

@@ -0,0 +1,107 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonInViewCollection.h"
#include "Rim3dView.h"
#include "RimPolygon.h"
#include "RimPolygonCollection.h"
#include "RimPolygonInView.h"
#include "RimTools.h"
CAF_PDM_SOURCE_INIT( RimPolygonInViewCollection, "RimPolygonInViewCollection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonInViewCollection::RimPolygonInViewCollection()
{
CAF_PDM_InitObject( "Polygons (Under construction)", ":/PolylinesFromFile16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_polygons, "Polygons", "Polygons" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::syncPolygonsInView()
{
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;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPolygonInView*> RimPolygonInViewCollection::polygonsInView() const
{
return m_polygons.childrenByType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimCheckableObject::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_isChecked )
{
for ( auto poly : polygonsInView() )
{
poly->updateConnectedEditors();
}
if ( auto view = firstAncestorOfType<Rim3dView>() )
{
view->scheduleCreateDisplayModelAndRedraw();
}
}
}

View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimCheckableObject.h"
#include "cafPdmChildArrayField.h"
class RimPolygonInView;
//==================================================================================================
///
///
//==================================================================================================
class RimPolygonInViewCollection : public RimCheckableObject
{
CAF_PDM_HEADER_INIT;
public:
RimPolygonInViewCollection();
void syncPolygonsInView();
std::vector<RimPolygonInView*> polygonsInView() const;
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
private:
caf::PdmChildArrayField<RimPolygonInView*> m_polygons;
};

View File

@@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolygonTools.h"
#include "RimGridView.h"
#include "RimOilField.h"
#include "RimPolygon.h"
#include "RimPolygonCollection.h"
#include "RimPolygonInView.h"
#include "RimPolygonInViewCollection.h"
#include "RimProject.h"
#include "Riu3DMainWindowTools.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolygonTools::selectAndActivatePolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject )
{
auto polygonInView = findPolygonInView( polygon, sourceObject );
if ( polygonInView )
{
polygonInView->enablePicking( true );
Riu3DMainWindowTools::selectAsCurrentItem( polygonInView );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolygonInView* RimPolygonTools::findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject )
{
if ( !polygon || !sourceObject )
{
return nullptr;
}
if ( auto gridView = sourceObject->firstAncestorOrThisOfType<RimGridView>() )
{
auto polyCollection = gridView->polygonInViewCollection();
for ( auto polygonInView : polyCollection->polygonsInView() )
{
if ( polygonInView && polygonInView->polygon() == polygon )
{
return polygonInView;
}
}
}
return nullptr;
}

View File

@@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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
class RimPolygon;
class RimPolygonInView;
namespace caf
{
class PdmObject;
}
class RimPolygonTools
{
public:
static void selectAndActivatePolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
private:
static RimPolygonInView* findPolygonInView( RimPolygon* polygon, caf::PdmObject* sourceObject );
};

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