mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#9620 Pressure/depth data: add user interface.
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicImportPressureDepthDataFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RicImportFormationNamesFeature.h"
|
||||
|
||||
#include "RifReaderFmuRft.h"
|
||||
|
||||
#include "RimFormationNames.h"
|
||||
#include "RimObservedDataCollection.h"
|
||||
#include "RimObservedSummaryData.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimPressureDepthData.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RiuFileDialogTools.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicImportPressureDepthDataFeature, "RicImportPressureDepthDataFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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 );
|
||||
|
||||
if ( importedData != nullptr )
|
||||
{
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( importedData );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicImportPressureDepthDataFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimObservedDataCollection*> selectionObservedDataCollection;
|
||||
caf::SelectionManager::instance()->objectsByType( &selectionObservedDataCollection );
|
||||
|
||||
std::vector<RimObservedSummaryData*> selectionObservedData;
|
||||
caf::SelectionManager::instance()->objectsByType( &selectionObservedData );
|
||||
|
||||
return ( !selectionObservedDataCollection.empty() || !selectionObservedData.empty() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportPressureDepthDataFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
selectPressureDepthDataPathInDialog();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportPressureDepthDataFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setIcon( QIcon( ":/ObservedDataFile16x16.png" ) );
|
||||
actionToSetup->setText( "Import Pressure Depth Data" );
|
||||
}
|
||||
Reference in New Issue
Block a user