mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 07:03:25 -06:00
e2e239fd07
* #9923 Call loadDataAndUpdate() after visibility of curves is updated This will ensure that all zoom ranges are recalculated based on visible curves. * #9923 Put new segment plots in RFT Plot collection * #9923 Add "Create Rft Sement Plot" to RFT plot collection * #9923 Make sure the main window is displayed when required Make sure the main window is opened and views updated when a grid model is opened from a summary case. * #9923 Make sure fieldChanged is triggered when required Exclude field having the target state. If these fields are included, the one and only call to setValueWithFieldChanged() can contain a field with the target state value. When setting a value to a field with the same value, nothing happens and the UI will get an inconsistent state (some curves toggled off are still visible in a plot).
160 lines
5.5 KiB
C++
160 lines
5.5 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// 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 "RicImportGridModelFromSummaryCaseFeature.h"
|
|
|
|
#include "ApplicationCommands/RicShowMainWindowFeature.h"
|
|
|
|
#include "RiaEclipseFileNameTools.h"
|
|
#include "RiaImportEclipseCaseTools.h"
|
|
#include "RiaLogging.h"
|
|
|
|
#include "RimEclipseCase.h"
|
|
#include "RimFileSummaryCase.h"
|
|
#include "RimGridView.h"
|
|
#include "RimProject.h"
|
|
|
|
#include "Riu3DMainWindowTools.h"
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
#include <QAction>
|
|
#include <QFileInfo>
|
|
|
|
CAF_CMD_SOURCE_INIT( RicImportGridModelFromSummaryCaseFeature, "RicImportGridModelFromSummaryCaseFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicImportGridModelFromSummaryCaseFeature::openOrImportGridModelFromSummaryCase( const RimFileSummaryCase* summaryCase )
|
|
{
|
|
if ( !summaryCase ) return false;
|
|
|
|
if ( findAndActivateFirstView( summaryCase ) ) return true;
|
|
|
|
QString summaryFileName = summaryCase->summaryHeaderFilename();
|
|
RiaEclipseFileNameTools fileHelper( summaryFileName );
|
|
auto candidateGridFileName = fileHelper.findRelatedGridFile();
|
|
|
|
if ( QFileInfo::exists( candidateGridFileName ) )
|
|
{
|
|
bool createView = true;
|
|
auto id = RiaImportEclipseCaseTools::openEclipseCaseFromFile( candidateGridFileName, createView );
|
|
if ( id > -1 )
|
|
{
|
|
RiaLogging::info( QString( "Imported %1" ).arg( candidateGridFileName ) );
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
RiaLogging::info( QString( "No grid case found based on summary file %1" ).arg( summaryFileName ) );
|
|
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicImportGridModelFromSummaryCaseFeature::isCommandEnabled()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicImportGridModelFromSummaryCaseFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
RimFileSummaryCase* summaryCase = caf::SelectionManager::instance()->selectedItemOfType<RimFileSummaryCase>();
|
|
|
|
openOrImportGridModelFromSummaryCase( summaryCase );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicImportGridModelFromSummaryCaseFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setIcon( QIcon( ":/3DWindow.svg" ) );
|
|
|
|
RimFileSummaryCase* summaryCase = caf::SelectionManager::instance()->selectedItemOfType<RimFileSummaryCase>();
|
|
|
|
QString summaryCaseName;
|
|
if ( summaryCase ) summaryCaseName = summaryCase->caseName();
|
|
|
|
QString txt;
|
|
auto gridCase = gridModelFromSummaryCase( summaryCase );
|
|
if ( gridCase )
|
|
{
|
|
txt = "Open Grid Model View";
|
|
}
|
|
else
|
|
{
|
|
txt = "Import Grid Model";
|
|
}
|
|
|
|
if ( !summaryCaseName.isEmpty() )
|
|
{
|
|
txt += QString( " for '%1'" ).arg( summaryCaseName );
|
|
}
|
|
|
|
actionToSetup->setText( txt );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicImportGridModelFromSummaryCaseFeature::findAndActivateFirstView( const RimFileSummaryCase* summaryCase )
|
|
{
|
|
auto gridCase = gridModelFromSummaryCase( summaryCase );
|
|
if ( gridCase )
|
|
{
|
|
if ( !gridCase->gridViews().empty() )
|
|
{
|
|
RicShowMainWindowFeature::showMainWindow();
|
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem( gridCase->gridViews().front() );
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimEclipseCase* RicImportGridModelFromSummaryCaseFeature::gridModelFromSummaryCase( const RimFileSummaryCase* summaryCase )
|
|
{
|
|
if ( summaryCase )
|
|
{
|
|
QString summaryFileName = summaryCase->summaryHeaderFilename();
|
|
RiaEclipseFileNameTools fileHelper( summaryFileName );
|
|
auto candidateGridFileName = fileHelper.findRelatedGridFile();
|
|
|
|
RimProject* project = RimProject::current();
|
|
auto gridCase = project->eclipseCaseFromGridFileName( candidateGridFileName );
|
|
|
|
return gridCase;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|