ResInsight/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp
Kristian Bendiksen 20ca3354b9
Stimplan preprocessor refact (#5895)
* #5633 Add Fracture Model data object.
* #5633 Add visualization for Fracture Model.
* Use thickness direction well path.
* #5834 WIP Fracture Model: Extract facies names along thickness direction vector
* Update to class enums.
* Remove RimFractureModel dip, tilt and azimuth (no longer used).
* #5824: Fix fracture model direction relative to formation dip
* Workaround problem in generated python code which breaks tests on linux. See #5862.
* Update name of thickness direction well path.
* #5834 Add import command for facies roff file.
* #5834 Show color legend data in facies track.
Also make it possible to change the data source for the curve data in plot.
* Fracture Model: replace "Thickness Type" with "Extraction Type".
* Use shorter curve legends in fracture model plot.
* Use class enum for RimFractureModel::ExtractionType.
* Use RimProject::current() instead of RiaApplication::instance()->project().
* Simplify RimFractureModel by not implementing Rim3dPropertiesInterface.
* Use scoped enums in RiaPlotAnnotationTool.
* Remove unused RimFractureModelPlot fields.
* Hide fracture model plots field, and add accessor methods.
2020-05-14 06:39:55 +02:00

250 lines
8.1 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RicNewWellLogPlotFeatureImpl.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimFractureModelPlot.h"
#include "RimFractureModelPlotCollection.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimWellBoreStabilityPlot.h"
#include "RimWellLogCurveCommonDataSource.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotCollection.h"
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "RiaGuiApplication.h"
#include "cvfAssert.h"
#include <QString>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellBoreStabilityPlot*
RicNewWellLogPlotFeatureImpl::createWellBoreStabilityPlot( bool showAfterCreation /*= true*/,
const QString& plotDescription /*= QString("")*/,
const RimWbsParameters* params /*= nullptr*/ )
{
RimWellLogPlotCollection* wellLogPlotColl = wellLogPlotCollection();
CVF_ASSERT( wellLogPlotColl );
// Make sure the summary plot window is created
RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
RimWellBoreStabilityPlot* plot = new RimWellBoreStabilityPlot();
if ( params )
{
plot->copyWbsParameters( params );
}
plot->setAsPlotMdiWindow();
wellLogPlotColl->wellLogPlots().push_back( plot );
if ( !plotDescription.isEmpty() )
{
plot->nameConfig()->setCustomName( plotDescription );
}
else
{
plot->nameConfig()->setCustomName(
QString( "Well Bore Stability Plot %1" ).arg( wellLogPlotCollection()->wellLogPlots.size() ) );
}
if ( showAfterCreation )
{
RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow();
}
return plot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createWellLogPlot( bool showAfterCreation, const QString& plotDescription )
{
RimWellLogPlotCollection* wellLogPlotColl = wellLogPlotCollection();
CVF_ASSERT( wellLogPlotColl );
// Make sure the summary plot window is created
RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
RimWellLogPlot* plot = new RimWellLogPlot();
plot->setAsPlotMdiWindow();
wellLogPlotColl->wellLogPlots().push_back( plot );
if ( !plotDescription.isEmpty() )
{
plot->nameConfig()->setCustomName( plotDescription );
}
else
{
plot->nameConfig()->setCustomName(
QString( "Well Log Plot %1" ).arg( wellLogPlotCollection()->wellLogPlots.size() ) );
}
if ( showAfterCreation )
{
RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow();
}
return plot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogTrack* RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( bool updateAfter,
const QString& trackDescription,
RimDepthTrackPlot* existingPlot )
{
RimDepthTrackPlot* plot = existingPlot;
if ( plot == nullptr )
{
plot = createWellLogPlot();
}
RimCase* caseToApply = nullptr;
RimWellPath* wellPathToApply = nullptr;
QString simWellToApply;
RimWellLogCurveCommonDataSource* commonDataSource = plot->commonDataSource();
caseToApply = commonDataSource->caseToApply();
wellPathToApply = commonDataSource->wellPathToApply();
simWellToApply = commonDataSource->simWellNameToApply();
caf::Tristate branchDetectionToApply = commonDataSource->branchDetectionToApply();
int branchIndexToApply = commonDataSource->branchIndexToApply();
if ( !caseToApply )
{
std::vector<RimCase*> allCases;
RimProject::current()->allCases( allCases );
if ( !allCases.empty() )
{
caseToApply = allCases.front();
}
}
if ( !wellPathToApply && caseToApply )
{
auto allWellPaths = RimProject::current()->allWellPaths();
if ( !allWellPaths.empty() )
{
wellPathToApply = allWellPaths.front();
}
}
if ( simWellToApply.isEmpty() && caseToApply )
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( caseToApply );
if ( eclipseCase )
{
auto allSimWells = eclipseCase->sortedSimWellNames();
if ( !allSimWells.empty() )
{
simWellToApply = *allSimWells.begin();
}
}
}
RimWellLogTrack* plotTrack = new RimWellLogTrack();
plot->addPlot( plotTrack );
if ( !trackDescription.isEmpty() )
{
plotTrack->setDescription( trackDescription );
}
else
{
plotTrack->setDescription( QString( "Track %1" ).arg( plot->plotCount() ) );
}
if ( caseToApply )
{
plotTrack->setFormationCase( caseToApply );
}
if ( wellPathToApply )
{
plotTrack->setFormationWellPath( wellPathToApply );
}
if ( !simWellToApply.isEmpty() )
{
plotTrack->setFormationSimWellName( simWellToApply );
}
if ( wellPathToApply )
{
plotTrack->setFormationTrajectoryType( RimWellLogTrack::WELL_PATH );
}
else if ( !simWellToApply.isEmpty() )
{
plotTrack->setFormationTrajectoryType( RimWellLogTrack::SIMULATION_WELL );
}
if ( !branchDetectionToApply.isPartiallyTrue() )
{
plotTrack->setFormationBranchDetection( branchDetectionToApply.isTrue() );
}
if ( branchIndexToApply >= 0 )
{
plotTrack->setFormationBranchIndex( branchIndexToApply );
}
if ( updateAfter )
{
updateAfterCreation( plot );
}
return plotTrack;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewWellLogPlotFeatureImpl::updateAfterCreation( RimDepthTrackPlot* plot )
{
CVF_ASSERT( plot );
plot->loadDataAndUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlotCollection* RicNewWellLogPlotFeatureImpl::wellLogPlotCollection()
{
RimProject* project = RimProject::current();
CVF_ASSERT( project );
RimMainPlotCollection* mainPlotColl = project->mainPlotCollection();
CVF_ASSERT( mainPlotColl );
RimWellLogPlotCollection* wellLogPlotColl = mainPlotColl->wellLogPlotCollection();
CVF_ASSERT( wellLogPlotColl );
return mainPlotColl->wellLogPlotCollection();
}