mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 07:30:20 -05:00
Migrate all assert macros in ApplicationLibCode to CAF_ASSERT and remove every use of cvfAssert.h. CVF_ASSERT is replaced one to one. CVF_TIGHT_ASSERT is also replaced by CAF_ASSERT, which is semantically exact: CVF_ENABLE_TIGHT_ASSERTS is 1 only under _DEBUG, and that is what CAF_ASSERT now does. The two CVF_FAIL_MSG sites become CAF_ASSERT( false && "message" ), preserving the message with the idiom already used elsewhere in the code base. Counts before and after: CVF_ASSERT 1044 to 0, CVF_TIGHT_ASSERT 66 to 0, CVF_FAIL_MSG 2 to 0, cvfAssert.h references 154 to 0. Include handling: files that included cvfAssert.h directly now include cafAssert.h instead, includes left dead by the migration are removed, and files that were relying on cvfAssert.h transitively get an explicit cafAssert.h. Files that reach cafAssert.h through another caf header are left unchanged; a missing include here is a compile error, not a silently disabled assert. ResultStatisticsCache links only LibCore and therefore had no path to cafAssert.h. Add the cafPdmCore directory as a private include path rather than linking the library, since cafAssert.h is header only. Note that this stops these asserts from firing in Release and RelWithDebInfo, where CVF_ASSERT was previously active.
288 lines
9.7 KiB
C++
288 lines
9.7 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 "RiaGuiApplication.h"
|
|
|
|
#include "Formations/RimFormationNames.h"
|
|
#include "RimCase.h"
|
|
#include "RimColorLegend.h"
|
|
#include "RimColorLegendCollection.h"
|
|
#include "RimEclipseCase.h"
|
|
#include "RimMainPlotCollection.h"
|
|
#include "RimProject.h"
|
|
#include "RimRftPlotCollection.h"
|
|
#include "RimStimPlanModelPlot.h"
|
|
#include "RimStimPlanModelPlotCollection.h"
|
|
#include "RimWellBoreStabilityPlot.h"
|
|
#include "RimWellLogCurveCommonDataSource.h"
|
|
#include "RimWellLogPlot.h"
|
|
#include "RimWellLogPlotCollection.h"
|
|
#include "RimWellLogPlotNameConfig.h"
|
|
#include "RimWellLogTrack.h"
|
|
#include "RimWellPath.h"
|
|
|
|
#include "cafAssert.h"
|
|
|
|
#include <QString>
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellBoreStabilityPlot* RicNewWellLogPlotFeatureImpl::createWellBoreStabilityPlot( bool showAfterCreation /*= true*/,
|
|
const QString& plotDescription /*= QString("")*/,
|
|
const RimWbsParameters* params /*= nullptr*/ )
|
|
{
|
|
RimWellLogPlotCollection* wellLogPlotColl = wellLogPlotCollection();
|
|
CAF_ASSERT( wellLogPlotColl );
|
|
|
|
// Make sure the summary plot window is created
|
|
RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
|
|
|
|
RimWellBoreStabilityPlot* plot = new RimWellBoreStabilityPlot();
|
|
if ( params )
|
|
{
|
|
plot->copyWbsParameters( params );
|
|
}
|
|
|
|
plot->dockAsPlotWindow();
|
|
|
|
wellLogPlotColl->addWellLogPlot( plot );
|
|
|
|
if ( !plotDescription.isEmpty() )
|
|
{
|
|
plot->nameConfig()->setCustomName( plotDescription );
|
|
}
|
|
else
|
|
{
|
|
plot->nameConfig()->setCustomName( QString( "Well Bore Stability Plot %1" ).arg( wellLogPlotCollection()->wellLogPlots().size() ) );
|
|
}
|
|
|
|
wellLogPlotColl->updateConnectedEditors();
|
|
|
|
if ( showAfterCreation )
|
|
{
|
|
RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow();
|
|
}
|
|
|
|
return plot;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createRftSegmentPlot()
|
|
{
|
|
auto plot = createWellLogPlot();
|
|
|
|
plot->setDepthOrientation( RiaDefines::Orientation::HORIZONTAL );
|
|
plot->setNamingMethod( RiaDefines::ObjectNamingMethod::TEMPLATE );
|
|
QString templateText = RiaDefines::namingVariableCase() + ", " + RiaDefines::namingVariableWell() + " - Branch " +
|
|
RiaDefines::namingVariableWellBranch() + ", " + RiaDefines::namingVariableTime();
|
|
plot->setNameTemplateText( templateText );
|
|
plot->setPlotTitleVisible( true );
|
|
plot->setLegendItemsClickable( false );
|
|
plot->enableDepthMarkerLine( true );
|
|
plot->setLegendPosition( RimPlotWindow::LegendPosition::INSIDE_UPPER_RIGHT );
|
|
plot->setLegendFontSize( caf::FontTools::RelativeSize::Small );
|
|
plot->setLegendsHorizontal( false );
|
|
plot->setAutoZoomMaximumDepthFactor( 0.1 );
|
|
|
|
return plot;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellLogTrack* RicNewWellLogPlotFeatureImpl::createWellLogTrackWithAutoUpdate()
|
|
{
|
|
auto track = new RimWellLogTrack();
|
|
track->setAutoCheckStateBasedOnCurveData( true );
|
|
|
|
return track;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createWellLogPlot( bool showAfterCreation, const QString& plotDescription )
|
|
{
|
|
RimWellLogPlotCollection* wellLogPlotColl = wellLogPlotCollection();
|
|
CAF_ASSERT( wellLogPlotColl );
|
|
|
|
// Make sure the summary plot window is created
|
|
RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
|
|
|
|
RimWellLogPlot* plot = new RimWellLogPlot();
|
|
plot->dockAsPlotWindow();
|
|
|
|
wellLogPlotColl->addWellLogPlot( plot );
|
|
|
|
if ( !plotDescription.isEmpty() )
|
|
{
|
|
plot->nameConfig()->setCustomName( plotDescription );
|
|
}
|
|
else
|
|
{
|
|
plot->nameConfig()->setCustomName( QString( "Well Log Plot %1" ).arg( wellLogPlotCollection()->wellLogPlots().size() ) );
|
|
}
|
|
|
|
wellLogPlotColl->updateConnectedEditors();
|
|
|
|
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()->allGridCases();
|
|
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 ( auto* formationNames = caseToApply->activeFormationNames() )
|
|
{
|
|
if ( auto* legend = RimProject::current()->colorLegendCollection->findByName( formationNames->shortName() ) )
|
|
{
|
|
plotTrack->setColorShadingLegend( legend );
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( wellPathToApply )
|
|
{
|
|
plotTrack->setFormationWellPath( wellPathToApply );
|
|
}
|
|
|
|
if ( !simWellToApply.isEmpty() )
|
|
{
|
|
plotTrack->setFormationSimWellName( simWellToApply );
|
|
}
|
|
|
|
if ( wellPathToApply )
|
|
{
|
|
plotTrack->setFormationTrajectoryType( RiaDefines::WellLogTrackTrajectoryType::WELL_PATH );
|
|
}
|
|
else if ( !simWellToApply.isEmpty() )
|
|
{
|
|
plotTrack->setFormationTrajectoryType( RiaDefines::WellLogTrackTrajectoryType::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 )
|
|
{
|
|
CAF_ASSERT( plot );
|
|
plot->loadDataAndUpdate();
|
|
plot->zoomAll();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellLogPlotCollection* RicNewWellLogPlotFeatureImpl::wellLogPlotCollection()
|
|
{
|
|
return RimMainPlotCollection::current()->wellLogPlotCollection();
|
|
}
|