#12291 Several minor adjustments

* Use same naming for ensemble grid cases as ensemble summary cases
* Create Polygons: Ask for polygon area cutoff when polygon count is high
* Show Create Polygons from Contour Map in polygon collection menu
* Update titles in crossplots
* Clear message panel when project is closed
* Show text message for start and complete of replace ensemble
This commit is contained in:
Magne Sjaastad authored and GitHub committed 2025-03-26 21:50:39 +01:00
1 parent 516c06bfd2
commit 0635d5870a
15 files changed
+108 -35

No files matched your search

@@ -125,6 +125,7 @@ RimEclipseCaseEnsemble* RicCreateGridCaseEnsemblesFromFilesFeature::importSingle
QString caseName = gridFileName.completeBaseName();
auto* rimResultCase = new RimEclipseResultCase();
rimResultCase->setDisplayNameType( RimCaseDisplayNameTools::DisplayName::SHORT_CASE_NAME );
rimResultCase->setCaseInfo( caseName, caseFileName );
eclipseCaseEnsemble->addCase( rimResultCase );
@@ -133,6 +134,11 @@ RimEclipseCaseEnsemble* RicCreateGridCaseEnsemblesFromFilesFeature::importSingle
if ( formations != nullptr ) rimResultCase->setFormationNames( formations );
}
for ( auto gridCase : eclipseCaseEnsemble->cases() )
{
gridCase->updateAutoShortName();
}
oilfield->analysisModels()->caseEnsembles.push_back( eclipseCaseEnsemble );
oilfield->analysisModels()->updateConnectedEditors();
@@ -296,37 +296,50 @@ void RicCreateContourMapPolygonTools::createPolygonObjects( std::vector<std::vec
auto polygons = internal::findPolygons( image, contourMapProjection );
if ( polygons.empty() ) return;
std::sort( polygons.begin(), polygons.end(), []( const auto& a, const auto& b ) { return a.first > b.first; } );
int polygonCount = 0;
QStringList polygonInfo;
for ( const auto& polygon : polygons )
const size_t polygonCountThreshold = 10;
if ( polygons.size() > polygonCountThreshold )
{
polygonInfo
<< QString( "Polygon %1: Normalized area %2, %3 vertices " ).arg( polygonCount++ ).arg( polygon.first ).arg( polygon.second.size() );
if ( polygonCount > 10 )
std::sort( polygons.begin(), polygons.end(), []( const auto& a, const auto& b ) { return a.first > b.first; } );
int polygonCount = 0;
QStringList polygonInfo;
for ( const auto& polygon : polygons )
{
polygonInfo << "More polygons found, but only the first 10 are shown.";
break;
polygonInfo
<< QString( "Polygon %1: Pixel area %2, vertex count %3 " ).arg( polygonCount++ ).arg( polygon.first ).arg( polygon.second.size() );
if ( polygonCount > 10 )
{
polygonInfo << QString( "More polygons found, but only the first 10 are shown." );
break;
}
}
QString txt = polygonInfo.join( "\n" );
txt += "\n\n Create polygons with pixel area above threshold: ";
bool ok;
int areaThreshold = QInputDialog::getInt( RiuMainWindow::instance(), "Create Polygons", txt, 10, 1, 10000, 1, &ok );
if ( ok )
{
std::vector<std::vector<cvf::Vec3d>> polygonsToCreate;
for ( const auto& polygon : polygons )
{
if ( polygon.first >= areaThreshold )
{
polygonsToCreate.push_back( polygon.second );
}
}
internal::createPolygonObjects( polygonsToCreate );
}
}
QString txt = polygonInfo.join( "\n" );
txt += "\n\n Define normalized area threshold:";
bool ok;
int areaThreshold = QInputDialog::getInt( RiuMainWindow::instance(), "Create Polygons", txt, 10, 1, 10000, 1, &ok );
if ( ok )
else
{
std::vector<std::vector<cvf::Vec3d>> polygonsToCreate;
for ( const auto& polygon : polygons )
{
if ( polygon.first >= areaThreshold )
{
polygonsToCreate.push_back( polygon.second );
}
polygonsToCreate.push_back( polygon.second );
}
internal::createPolygonObjects( polygonsToCreate );
}
}
@@ -251,8 +251,8 @@ std::pair<RimEclipseContourMapView*, RimGeoMechContourMapView*> RicExportContour
if ( !existingEclipseContourMap && !existingGeoMechContourMap )
{
existingEclipseContourMap = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>();
existingGeoMechContourMap = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechContourMapView>();
existingEclipseContourMap = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimEclipseContourMapView>();
existingGeoMechContourMap = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimGeoMechContourMapView>();
}
auto pair = std::make_pair( existingEclipseContourMap, existingGeoMechContourMap );
@@ -51,6 +51,8 @@ void RicReplaceSummaryEnsembleFeature::onActionTriggered( bool isChecked )
auto summaryEnsemble = caf::SelectionManager::instance()->selectedItemOfType<RimSummaryEnsemble>();
if ( !summaryEnsemble ) return;
RiaLogging::info( QString( "Starting replace ensemble for '" ) + summaryEnsemble->name() + "'" );
QString pathCacheName = "ENSEMBLE_FILES";
auto result = RicImportSummaryCasesFeature::runRecursiveSummaryCaseFileSearchDialogWithGrouping( "Import Ensemble", pathCacheName );
QStringList fileNames = result.files;
@@ -80,6 +82,8 @@ void RicReplaceSummaryEnsembleFeature::onActionTriggered( bool isChecked )
sumCaseMainColl->updateEnsembleNames();
sumCaseMainColl->updateAllRequiredEditors();
}
RiaLogging::info( QString( "Completed replace ensemble, new name is '" ) + summaryEnsemble->name() + "'" );
}
//--------------------------------------------------------------------------------------------------
@@ -401,8 +401,7 @@ void RimCorrelationMatrixPlot::updateAxes()
m_plotWidget->qwtPlot()->setAxisScaleDraw( QwtAxis::YLeft, new TextScaleDraw( m_resultLabels ) );
m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::YLeft, new RiuQwtLinearScaleEngine );
m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), "Result Vector" );
m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true );
m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), false );
m_plotWidget->setAxisFontsAndAlignment( RiuPlotAxis::defaultLeft(), axisTitleFontSize(), axisValueFontSize(), false, Qt::AlignCenter );
m_plotWidget->setAxisLabelsAndTicksEnabled( RiuPlotAxis::defaultLeft(), true, false );
m_plotWidget->setAxisRange( RiuPlotAxis::defaultLeft(), 0.0, (double)m_resultLabels.size() + 1 );
@@ -418,8 +417,7 @@ void RimCorrelationMatrixPlot::updateAxes()
scaleDraw->setLabelRotation( 30.0 );
m_plotWidget->qwtPlot()->setAxisScaleDraw( QwtAxis::XBottom, scaleDraw );
m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::XBottom, new RiuQwtLinearScaleEngine );
m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), "Ensemble Parameter" );
m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true );
m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), false );
m_plotWidget->setAxisFontsAndAlignment( RiuPlotAxis::defaultBottom(),
axisTitleFontSize(),
axisValueFontSize(),
@@ -658,7 +656,7 @@ void RimCorrelationMatrixPlot::updatePlotTitle()
{
if ( m_useAutoPlotTitle )
{
m_description = QString( "Parameters vs Result Vectors at %2" ).arg( timeStepString() );
m_description = QString( "Result Vectors vs Parameters at %2" ).arg( timeStepString() );
}
if ( m_plotWidget )
@@ -619,7 +619,7 @@ void RimParameterResultCrossPlot::updatePlotTitle()
QString vectorName = completeAddressText();
m_description =
QString( "%1 x %2, %3 at %4" ).arg( m_ensembleParameter ).arg( vectorName ).arg( ensemble->name() ).arg( timeStepString() );
QString( "%1 x %2, %3 at %4" ).arg( vectorName ).arg( m_ensembleParameter ).arg( ensemble->name() ).arg( timeStepString() );
}
m_plotWidget->setPlotTitle( m_description );
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
@@ -18,6 +18,7 @@
#include "RimPolygonInViewCollection.h"
#include "ContourMap/RimEclipseContourMapView.h"
#include "Rim3dView.h"
#include "RimPolygon.h"
#include "RimPolygonCollection.h"
@@ -25,6 +26,8 @@
#include "RimPolygonInView.h"
#include "RimTools.h"
#include "cafCmdFeatureMenuBuilder.h"
CAF_PDM_SOURCE_INIT( RimPolygonInViewCollection, "RimPolygonInViewCollection" );
//--------------------------------------------------------------------------------------------------
@@ -128,6 +131,10 @@ void RimPolygonInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch
//--------------------------------------------------------------------------------------------------
void RimPolygonInViewCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
if ( firstAncestorOfType<RimEclipseContourMapView>() )
{
menuBuilder << "RicCreateContourMapPolygonFeature";
}
RimPolygonCollection::appendPolygonMenuItems( menuBuilder );
}
@@ -19,6 +19,8 @@
#include "RimCase.h"
#include "RiaEnsembleNameTools.h"
#include "RicfCommandObject.h"
#include "Formations/RimFormationNames.h"
@@ -29,6 +31,7 @@
#include "Rim2dIntersectionView.h"
#include "Rim2dIntersectionViewCollection.h"
#include "RimCaseCollection.h"
#include "RimExtrudedCurveIntersection.h"
#include "RimGridView.h"
@@ -325,7 +328,27 @@ void RimCase::updateAutoShortName()
}
else if ( m_displayNameOption == RimCaseDisplayNameTools::DisplayName::SHORT_CASE_NAME )
{
m_caseUserDescription = RimCase::uniqueShortNameCase( this, RimCaseDisplayNameTools::CASE_SHORT_NAME_LENGTH );
if ( auto caseCollection = firstAncestorOrThisOfType<RimCaseCollection>() )
{
QStringList filePaths;
auto cases = caseCollection->cases();
if ( !cases.empty() )
{
for ( int i = 0; i < std::min( 4, static_cast<int>( cases.size() ) ); ++i )
{
auto caseInEnsemble = cases[i];
filePaths.push_back( caseInEnsemble->gridFileName() );
}
}
filePaths.push_back( gridFileName() );
m_caseUserDescription = RiaEnsembleNameTools::uniqueShortName( gridFileName(), filePaths, caseName() );
}
else
{
m_caseUserDescription = RimCase::uniqueShortNameCase( this, RimCaseDisplayNameTools::CASE_SHORT_NAME_LENGTH );
}
}
updateTreeItemName();
}
@@ -35,6 +35,21 @@ RimCaseCollection::RimCaseCollection()
CAF_PDM_InitFieldNoDefault( &reservoirs, "Reservoirs", "Reservoirs ChildArrayField" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimCase*> RimCaseCollection::cases() const
{
std::vector<RimCase*> caseVector;
for ( auto rimCase : reservoirs )
{
caseVector.push_back( rimCase );
}
return caseVector;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -24,6 +24,7 @@
class RimEclipseCase;
class RimIdenticalGridCaseGroup;
class RimCase;
//==================================================================================================
//
@@ -36,6 +37,9 @@ class RimCaseCollection : public caf::PdmObject
public:
RimCaseCollection();
std::vector<RimCase*> cases() const;
caf::PdmChildArrayField<RimEclipseCase*> reservoirs;
RimIdenticalGridCaseGroup* parentCaseGroup();
@@ -45,7 +45,7 @@ RimEclipseCaseEnsemble::RimEclipseCaseEnsemble()
CAF_PDM_InitFieldNoDefault( &m_caseCollection, "CaseCollection", "Ensemble Cases" );
m_caseCollection = new RimCaseCollection;
m_caseCollection->uiCapability()->setUiName( "Cases" );
m_caseCollection->uiCapability()->setUiName( "Realizations" );
m_caseCollection->uiCapability()->setUiIconFromResourceString( ":/Cases16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_viewCollection, "ViewCollection", "Views" );
@@ -326,6 +326,8 @@ void RiuMainWindow::cleanupGuiCaseClose()
}
RicShowSummaryCurveCalculatorFeature::hideCurveCalculatorDialog();
if ( m_messagePanel ) m_messagePanel->slotClearMessages();
}
//--------------------------------------------------------------------------------------------------
@@ -130,8 +130,6 @@ void RiuMessagePanel::slotShowContextMenu( const QPoint& pos )
void RiuMessagePanel::slotClearMessages()
{
m_textEdit->clear();
RiaLogging::info( "Message window cleared." );
}
//==================================================================================================
@@ -40,9 +40,10 @@ public:
void addMessage( RILogLevel messageLevel, const QString& msg );
QSize sizeHint() const override;
void slotClearMessages();
private slots:
void slotShowContextMenu( const QPoint& pos );
void slotClearMessages();
private:
QPointer<QPlainTextEdit> m_textEdit;
@@ -259,6 +259,8 @@ void RiuPlotMainWindow::cleanupGuiBeforeProjectClose()
m_multiPlotLayoutToolBarEditor->clear();
setWindowTitle( "Plots - ResInsight" );
if ( m_messagePanel ) m_messagePanel->slotClearMessages();
}
//--------------------------------------------------------------------------------------------------