Add reload and delete of pressure/depth data

This commit is contained in:
Magne Sjaastad 2023-03-13 14:47:44 +01:00
parent ab44f9fa17
commit eb5a0cf936
10 changed files with 159 additions and 10 deletions

View File

@ -80,6 +80,11 @@ void RicOpenInTextEditorFeature::onActionTriggered( bool isChecked )
{
filePath = templateFileItem->absoluteFilePath();
}
if ( auto pressureDepthData = dynamic_cast<RimPressureDepthData*>( uiItems.front() ) )
{
filePath = pressureDepthData->filePath();
}
}
if ( !filePath.isEmpty() )

View File

@ -85,6 +85,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicDeleteUncheckedSubItemsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicRenameSummaryCaseFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicImportPressureDepthDataFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicReloadPressureDepthDataFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -173,6 +174,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicDeleteUncheckedSubItemsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicRenameSummaryCaseFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicImportPressureDepthDataFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicReloadPressureDepthDataFeature.cpp
)
if(RESINSIGHT_USE_QT_CHARTS)

View File

@ -51,19 +51,24 @@ CAF_CMD_SOURCE_INIT( RicImportPressureDepthDataFeature, "RicImportPressureDepthD
void RicImportPressureDepthDataFeature::selectPressureDepthDataPathInDialog()
{
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory( "SUMMARY_CASE_DIR" );
QString filePath = RiuFileDialogTools::getOpenFileName( nullptr, "Import Pressure/Depth Data", defaultDir );
RimProject* proj = app->project();
RimObservedDataCollection* observedDataCollection = proj->activeOilField() ? proj->activeOilField()->observedDataCollection() : nullptr;
if ( !observedDataCollection ) return;
const RimPressureDepthData* importedData = observedDataCollection->createAndAddPressureDepthDataFromPath( filePath );
QString defaultDir = app->lastUsedDialogDirectory( "SUMMARY_CASE_DIR" );
QString filterText = QString( "Text Files (*.txt);;All Files (*.*)" );
if ( importedData != nullptr )
RimPressureDepthData* firstImportedObject = nullptr;
QStringList filePaths = RiuFileDialogTools::getOpenFileNames( nullptr, "Import Pressure/Depth Data", defaultDir, filterText );
for ( const QString& filePath : filePaths )
{
RimPressureDepthData* importedData = observedDataCollection->createAndAddPressureDepthDataFromPath( filePath );
if ( !firstImportedObject && importedData ) firstImportedObject = importedData;
}
if ( firstImportedObject != nullptr )
{
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::selectAsCurrentItem( importedData );
RiuPlotMainWindowTools::selectAsCurrentItem( firstImportedObject );
}
}

View File

@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- 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 "RicReloadPressureDepthDataFeature.h"
#include "RimPressureDepthData.h"
#include "RimViewWindow.h"
#include "cafPdmObject.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicReloadPressureDepthDataFeature, "RicReloadPressureDepthDataFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicReloadPressureDepthDataFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicReloadPressureDepthDataFeature::onActionTriggered( bool isChecked )
{
std::vector<RimPressureDepthData*> pressureDepthDataObjects;
caf::SelectionManager::instance()->objectsByType( &pressureDepthDataObjects );
for ( RimPressureDepthData* pressureDepthData : pressureDepthDataObjects )
{
pressureDepthData->createRftReaderInterface();
std::vector<caf::PdmObjectHandle*> referringObjects;
pressureDepthData->objectsWithReferringPtrFields( referringObjects );
for ( auto refObj : referringObjects )
{
if ( refObj )
{
RimViewWindow* viewWindow = nullptr;
refObj->firstAncestorOrThisOfType( viewWindow );
if ( viewWindow )
{
viewWindow->loadDataAndUpdate();
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicReloadPressureDepthDataFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Reload" );
actionToSetup->setIcon( QIcon( ":/Refresh.svg" ) );
}

View File

@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- 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 RicReloadPressureDepthDataFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -105,6 +105,7 @@
#include "RimPlotDataFilterCollection.h"
#include "RimPlotDataFilterItem.h"
#include "RimPltPlotCollection.h"
#include "RimPressureDepthData.h"
#include "RimPressureTable.h"
#include "RimProject.h"
#include "RimRftCase.h"
@ -133,6 +134,7 @@
#include "RimSummaryMultiPlot.h"
#include "RimSummaryMultiPlotCollection.h"
#include "RimSummaryPlot.h"
#include "RimSummaryTimeAxisProperties.h"
#include "RimSurface.h"
#include "RimSurfaceCollection.h"
#include "RimValveTemplate.h"
@ -185,7 +187,6 @@
#include <QString>
#include <QStringList>
#include "RimSummaryTimeAxisProperties.h"
#include <vector>
//--------------------------------------------------------------------------------------------------
@ -1082,6 +1083,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder.addSeparator();
menuBuilder << "RicNewRftWellLogPlotFeature";
}
else if ( dynamic_cast<RimPressureDepthData*>( firstUiItem ) )
{
menuBuilder << "RicOpenInTextEditorFeature";
menuBuilder << "RicReloadPressureDepthDataFeature";
}
if ( dynamic_cast<Rim3dView*>( firstUiItem ) )
{

View File

@ -26,6 +26,7 @@
#include "RifKeywordVectorParser.h"
#include "RimCsvUserData.h"
#include "RimMainPlotCollection.h"
#include "RimObservedEclipseUserData.h"
#include "RimObservedFmuRftData.h"
#include "RimObservedSummaryData.h"
@ -112,6 +113,14 @@ std::vector<RimPressureDepthData*> RimObservedDataCollection::allPressureDepthDa
return m_observedPressureDepthArray.children();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimObservedDataCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects )
{
RimMainPlotCollection::current()->loadDataAndUpdateAllPlots();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -49,6 +49,7 @@ public:
private:
bool fileExists( const QString& fileName, QString* errorText = nullptr );
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
private:
caf::PdmChildArrayField<RimObservedSummaryData*> m_observedDataArray;

View File

@ -38,6 +38,16 @@ RimPressureDepthData::RimPressureDepthData()
m_wells.xmlCapability()->disableIO();
m_wells.uiCapability()->setUiReadOnly( true );
m_wells.registerGetMethod( this, &RimPressureDepthData::wellNames );
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimPressureDepthData::filePath() const
{
return m_filePath().path();
}
//--------------------------------------------------------------------------------------------------
@ -53,7 +63,7 @@ void RimPressureDepthData::setFilePath( const QString& path )
//--------------------------------------------------------------------------------------------------
void RimPressureDepthData::createRftReaderInterface()
{
m_fmuRftReader = new RifReaderPressureDepthData( m_filePath );
m_fmuRftReader = new RifReaderPressureDepthData( m_filePath().path() );
m_fmuRftReader->load();
}

View File

@ -24,6 +24,7 @@
#include "RifReaderPressureDepthData.h"
#include "cafFilePath.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
@ -35,6 +36,7 @@ class RimPressureDepthData : public RimNamedObject
public:
RimPressureDepthData();
QString filePath() const;
void setFilePath( const QString& path );
void createRftReaderInterface();
RifReaderRftInterface* rftReader();
@ -45,6 +47,6 @@ public:
private:
cvf::ref<RifReaderPressureDepthData> m_fmuRftReader;
caf::PdmField<QString> m_filePath;
caf::PdmField<caf::FilePath> m_filePath;
caf::PdmProxyValueField<std::vector<QString>> m_wells;
};