diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp index 8abaeefa8f..29ac743fa4 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp @@ -18,7 +18,6 @@ #include "RicCreateEnsembleWellLogFeature.h" -#include "RiaColorTables.h" #include "RiaGuiApplication.h" #include "RiaImportEclipseCaseTools.h" #include "RiaLogging.h" @@ -32,13 +31,13 @@ #include "RicImportGeneralDataFeature.h" #include "RicRecursiveFileSearchDialog.h" #include "RifReaderSettings.h" +#include "WellLogCommands/RicNewEnsembleWellLogPlotFeature.h" #include "WellPathCommands/RicImportWellPaths.h" #include "RigLasFileExporter.h" #include "RimDialogData.h" #include "RimEclipseCase.h" -#include "RimEnsembleWellLogCurveSet.h" #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimWellLogExtractionCurve.h" @@ -60,6 +59,7 @@ #include #include #include +#include #include @@ -83,8 +83,9 @@ void RicCreateEnsembleWellLogFeature::openDialogAndExecuteCommand() defaultDir, pathFilter, fileNameFilter, - { RicRecursiveFileSearchDialog::FileType::GRDECL, - RicRecursiveFileSearchDialog::FileType::EGRID } ); + { RicRecursiveFileSearchDialog::FileType::EGRID, + RicRecursiveFileSearchDialog::FileType::GRDECL }, + true ); if ( !result.ok || result.files.isEmpty() ) { return; @@ -238,16 +239,10 @@ void RicCreateEnsembleWellLogFeature::executeCommand( const RicCreateEnsembleWel for ( const auto& property : properties ) { // Create well log track - cvf::Color3f color = RiaColorTables::normalPaletteColors().cycledColor3f( trackNum ); QString title = QString( "Track %1" ).arg( trackNum ); RimWellLogTrack* wellLogTrack = RimcWellLogPlot_newWellLogTrack::createWellLogTrack( wellLogPlot, eclipseCase, wellPath, title ); - auto* ensembleWellLogCurveSet = new RimEnsembleWellLogCurveSet(); - ensembleWellLogCurveSet->setEnsembleWellLogs( ensembleWellLog ); - ensembleWellLogCurveSet->setColor( color ); - ensembleWellLogCurveSet->setWellLogChannelName( property.first ); - wellLogTrack->setEnsembleWellLogCurveSet( ensembleWellLogCurveSet ); - ensembleWellLogCurveSet->loadDataAndUpdate( true ); + RicNewEnsembleWellLogPlotFeature::addEnsembleCurveSetToTrack( wellLogTrack, ensembleWellLog, property.first, trackNum ); trackNum++; } @@ -302,4 +297,5 @@ void RicCreateEnsembleWellLogFeature::onActionTriggered( bool isChecked ) void RicCreateEnsembleWellLogFeature::setupActionLook( QAction* actionToSetup ) { actionToSetup->setText( "Create Ensemble Well Log..." ); + actionToSetup->setIcon( QIcon( ":/WellLogFile.svg" ) ); } diff --git a/ApplicationLibCode/Commands/WellLogCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/WellLogCommands/CMakeLists_files.cmake index 278dc9b3d8..2c889181c1 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/WellLogCommands/CMakeLists_files.cmake @@ -27,6 +27,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicNewWellBoreStabilityPlotFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewWellMeasurementCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewEnsembleWellLogCurveSetFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicNewEnsembleWellLogPlotFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewRftWellLogPlotFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewRftSegmentWellLogPlotFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewMultiPhaseRftSegmentPlotFeature.cpp diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewEnsembleWellLogPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewEnsembleWellLogPlotFeature.cpp new file mode 100644 index 0000000000..7d82fcd7ee --- /dev/null +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewEnsembleWellLogPlotFeature.cpp @@ -0,0 +1,131 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2026- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewEnsembleWellLogPlotFeature.h" + +#include "RicNewWellLogPlotFeatureImpl.h" + +#include "RiaColorTables.h" +#include "RiaResultNames.h" + +#include "RimEnsembleWellLogCurveSet.h" +#include "RimEnsembleWellLogs.h" +#include "RimWellLogChannel.h" +#include "RimWellLogLasFile.h" +#include "RimWellLogPlot.h" +#include "RimWellLogPlotNameConfig.h" +#include "RimWellLogTrack.h" + +#include "RiuPlotMainWindowTools.h" + +#include "cafSelectionManager.h" + +#include + +#include + +CAF_CMD_SOURCE_INIT( RicNewEnsembleWellLogPlotFeature, "RicNewEnsembleWellLogPlotFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleWellLogCurveSet* RicNewEnsembleWellLogPlotFeature::addEnsembleCurveSetToTrack( RimWellLogTrack* track, + RimEnsembleWellLogs* ensembleWellLogs, + const QString& channelName, + int colorIndex ) +{ + auto* curveSet = new RimEnsembleWellLogCurveSet(); + curveSet->setEnsembleWellLogs( ensembleWellLogs ); + curveSet->setColor( RiaColorTables::normalPaletteColors().cycledColor3f( colorIndex ) ); + if ( !channelName.isEmpty() ) curveSet->setWellLogChannelName( channelName ); + track->setEnsembleWellLogCurveSet( curveSet ); + if ( !channelName.isEmpty() ) curveSet->loadDataAndUpdate( true ); + + return curveSet; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewEnsembleWellLogPlotFeature::isCommandEnabled() const +{ + return caf::SelectionManager::instance()->selectedItemOfType() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewEnsembleWellLogPlotFeature::onActionTriggered( bool isChecked ) +{ + auto* ensembleWellLogs = caf::SelectionManager::instance()->selectedItemOfType(); + if ( !ensembleWellLogs ) return; + + // Collect available channels (alphabetically, as in the channel list), excluding depth channels + const QStringList depthChannels = { "DEPT", "DEPTH", "MD", "MDEPTH", "TVDMSL", "TVDRKB", RiaResultNames::indexKResultName().toUpper() }; + std::set channelNames; + for ( auto* wellLogFile : ensembleWellLogs->wellLogFiles() ) + { + for ( auto* channel : wellLogFile->wellLogChannels() ) + { + if ( !depthChannels.contains( channel->name().toUpper() ) ) channelNames.insert( channel->name() ); + } + } + + RimDepthTrackPlot* plot = nullptr; + RimEnsembleWellLogCurveSet* firstCurveSet = nullptr; + int trackIndex = 0; + for ( const QString& channelName : channelNames ) + { + RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( true, channelName, plot ); + plot = plotTrack->firstAncestorOrThisOfType(); + if ( trackIndex == 0 ) + { + // The automatic plot name is built from well/case data and is empty without a well path + plot->nameConfig()->setCustomName( ensembleWellLogs->name() ); + plot->setNamingMethod( RiaDefines::ObjectNamingMethod::CUSTOM ); + } + + auto* curveSet = addEnsembleCurveSetToTrack( plotTrack, ensembleWellLogs, channelName, trackIndex ); + if ( !firstCurveSet ) firstCurveSet = curveSet; + trackIndex++; + } + + if ( !plot ) + { + // No channels found: create an empty track with a curve set the user can configure + RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack(); + plot = plotTrack->firstAncestorOrThisOfType(); + + firstCurveSet = addEnsembleCurveSetToTrack( plotTrack, ensembleWellLogs, QString(), 0 ); + } + + plot->updateConnectedEditors(); + if ( auto* wellLogPlot = dynamic_cast( plot ) ) wellLogPlot->zoomAll(); + + RiuPlotMainWindowTools::onObjectAppended( firstCurveSet ); + RiuPlotMainWindowTools::refreshToolbars(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewEnsembleWellLogPlotFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "New Well Log Plot" ); + actionToSetup->setIcon( QIcon( ":/WellLogPlot16x16.png" ) ); +} diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewEnsembleWellLogPlotFeature.h b/ApplicationLibCode/Commands/WellLogCommands/RicNewEnsembleWellLogPlotFeature.h new file mode 100644 index 0000000000..1b0c7e11dd --- /dev/null +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewEnsembleWellLogPlotFeature.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2026- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimEnsembleWellLogCurveSet; +class RimEnsembleWellLogs; +class RimWellLogTrack; + +//================================================================================================== +/// +//================================================================================================== +class RicNewEnsembleWellLogPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + // Add a curve set for the given channel to the track. The color is picked from the default palette by colorIndex. + // The curve set is left unconfigured and not loaded if channelName is empty. + static RimEnsembleWellLogCurveSet* + addEnsembleCurveSetToTrack( RimWellLogTrack* track, RimEnsembleWellLogs* ensembleWellLogs, const QString& channelName, int colorIndex ); + +protected: + bool isCommandEnabled() const override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +};