2023-05-12 16:02:56 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// 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 "RicCreateRegressionAnalysisCurveFeature.h"
|
|
|
|
|
|
2023-10-17 11:35:36 +02:00
|
|
|
#include "RiaColorTables.h"
|
2023-09-30 11:07:23 +02:00
|
|
|
#include "RiaColorTools.h"
|
2023-05-12 16:02:56 +02:00
|
|
|
#include "RiaSummaryTools.h"
|
|
|
|
|
|
2023-09-30 11:07:23 +02:00
|
|
|
#include "RimEnsembleCurveSet.h"
|
2023-05-12 16:02:56 +02:00
|
|
|
#include "RimSummaryCurve.h"
|
|
|
|
|
#include "RimSummaryMultiPlot.h"
|
|
|
|
|
#include "RimSummaryPlot.h"
|
|
|
|
|
#include "RimSummaryRegressionAnalysisCurve.h"
|
2023-09-30 11:07:23 +02:00
|
|
|
|
2023-05-12 16:02:56 +02:00
|
|
|
#include "RiuPlotMainWindowTools.h"
|
|
|
|
|
|
|
|
|
|
#include "cafSelectionManagerTools.h"
|
|
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT( RicCreateRegressionAnalysisCurveFeature, "RicCreateRegressionAnalysisCurveFeature" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-06-26 14:28:46 +02:00
|
|
|
bool RicCreateRegressionAnalysisCurveFeature::isCommandEnabled() const
|
2023-05-12 16:02:56 +02:00
|
|
|
{
|
2023-09-30 11:07:23 +02:00
|
|
|
return caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot>();
|
2023-05-12 16:02:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RicCreateRegressionAnalysisCurveFeature::onActionTriggered( bool isChecked )
|
|
|
|
|
{
|
2023-09-30 11:07:23 +02:00
|
|
|
RimSummaryRegressionAnalysisCurve* newCurve = nullptr;
|
|
|
|
|
|
|
|
|
|
if ( auto summaryCurve = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryCurve>() )
|
|
|
|
|
{
|
|
|
|
|
newCurve = createRegressionAnalysisCurveAndAddToPlot( summaryCurve );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( auto curveSet = caf::firstAncestorOfTypeFromSelectedObject<RimEnsembleCurveSet>() )
|
2023-05-12 16:02:56 +02:00
|
|
|
{
|
2023-09-30 11:07:23 +02:00
|
|
|
newCurve = createRegressionAnalysisCurveAndAddToPlot( curveSet );
|
|
|
|
|
}
|
2023-05-12 16:02:56 +02:00
|
|
|
|
2023-09-30 11:07:23 +02:00
|
|
|
if ( newCurve )
|
|
|
|
|
{
|
2023-05-12 16:02:56 +02:00
|
|
|
RiuPlotMainWindowTools::showPlotMainWindow();
|
|
|
|
|
RiuPlotMainWindowTools::selectAsCurrentItem( newCurve );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RicCreateRegressionAnalysisCurveFeature::setupActionLook( QAction* actionToSetup )
|
|
|
|
|
{
|
|
|
|
|
actionToSetup->setText( "Create Regression Analysis Curve" );
|
2023-06-10 16:30:34 +02:00
|
|
|
actionToSetup->setIcon( QIcon( ":/regression-curve.svg" ) );
|
2023-05-12 16:02:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimSummaryRegressionAnalysisCurve*
|
|
|
|
|
RicCreateRegressionAnalysisCurveFeature::createRegressionAnalysisCurveAndAddToPlot( RimSummaryCurve* sourceCurve )
|
|
|
|
|
{
|
2023-10-17 11:35:36 +02:00
|
|
|
auto* summaryPlot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot>();
|
2023-05-12 16:02:56 +02:00
|
|
|
|
2023-09-30 11:07:23 +02:00
|
|
|
auto newCurve = new RimSummaryRegressionAnalysisCurve();
|
2023-09-20 09:48:03 +02:00
|
|
|
RiaSummaryTools::copyCurveDataSources( *newCurve, *sourceCurve );
|
2023-05-12 16:02:56 +02:00
|
|
|
|
2023-10-17 11:35:36 +02:00
|
|
|
auto candidates = RiaColorTables::summaryCurveDefaultPaletteColors();
|
|
|
|
|
auto contrastColor = RiaColorTools::selectContrastColorFromCandiates( sourceCurve->color(), candidates.color3fArray() );
|
|
|
|
|
|
|
|
|
|
newCurve->setColor( contrastColor );
|
2023-05-16 11:37:02 +02:00
|
|
|
newCurve->setSymbol( RiuPlotCurveSymbol::PointSymbolEnum::SYMBOL_RECT );
|
|
|
|
|
newCurve->setSymbolSkipDistance( 50 );
|
2023-05-12 16:02:56 +02:00
|
|
|
|
|
|
|
|
summaryPlot->addCurveAndUpdate( newCurve );
|
|
|
|
|
|
2023-09-20 09:48:03 +02:00
|
|
|
RiaSummaryTools::copyCurveAxisData( *newCurve, *sourceCurve );
|
|
|
|
|
|
2023-09-30 11:07:23 +02:00
|
|
|
newCurve->loadDataAndUpdate( true );
|
|
|
|
|
newCurve->updateConnectedEditors();
|
|
|
|
|
|
2023-10-17 11:35:36 +02:00
|
|
|
auto* summaryMultiPlot = summaryPlot->firstAncestorOrThisOfType<RimSummaryMultiPlot>();
|
2023-09-30 11:07:23 +02:00
|
|
|
if ( summaryMultiPlot )
|
|
|
|
|
{
|
|
|
|
|
summaryMultiPlot->updatePlotTitles();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
summaryPlot->updatePlotTitle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
summaryPlot->updateAllRequiredEditors();
|
|
|
|
|
|
|
|
|
|
return newCurve;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimSummaryRegressionAnalysisCurve*
|
|
|
|
|
RicCreateRegressionAnalysisCurveFeature::createRegressionAnalysisCurveAndAddToPlot( RimEnsembleCurveSet* sourceCurveSet )
|
|
|
|
|
{
|
2023-10-17 11:35:36 +02:00
|
|
|
auto* summaryPlot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot>();
|
2023-09-30 11:07:23 +02:00
|
|
|
|
|
|
|
|
auto newCurve = new RimSummaryRegressionAnalysisCurve();
|
|
|
|
|
|
|
|
|
|
newCurve->setEnsembleCurveSet( sourceCurveSet );
|
|
|
|
|
|
|
|
|
|
auto color = RiaColorTools::fromQColorTo3f( sourceCurveSet->mainEnsembleColor() );
|
2023-10-17 11:35:36 +02:00
|
|
|
|
|
|
|
|
auto candidates = RiaColorTables::summaryCurveDefaultPaletteColors();
|
|
|
|
|
auto contrastColor = RiaColorTools::selectContrastColorFromCandiates( color, candidates.color3fArray() );
|
|
|
|
|
|
|
|
|
|
newCurve->setColor( contrastColor );
|
2023-09-30 11:07:23 +02:00
|
|
|
newCurve->setSymbol( RiuPlotCurveSymbol::PointSymbolEnum::SYMBOL_RECT );
|
|
|
|
|
newCurve->setSymbolSkipDistance( 50 );
|
|
|
|
|
|
|
|
|
|
summaryPlot->addCurveAndUpdate( newCurve );
|
|
|
|
|
|
|
|
|
|
newCurve->setAxisTypeX( sourceCurveSet->xAxisType() );
|
|
|
|
|
newCurve->setTopOrBottomAxisX( sourceCurveSet->axisX() );
|
|
|
|
|
newCurve->setLeftOrRightAxisY( sourceCurveSet->axisY() );
|
|
|
|
|
|
2023-05-12 16:02:56 +02:00
|
|
|
newCurve->loadDataAndUpdate( true );
|
|
|
|
|
newCurve->updateConnectedEditors();
|
|
|
|
|
|
2023-10-17 11:35:36 +02:00
|
|
|
auto* summaryMultiPlot = summaryPlot->firstAncestorOrThisOfType<RimSummaryMultiPlot>();
|
2023-05-12 16:02:56 +02:00
|
|
|
if ( summaryMultiPlot )
|
|
|
|
|
{
|
|
|
|
|
summaryMultiPlot->updatePlotTitles();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
summaryPlot->updatePlotTitle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
summaryPlot->updateAllRequiredEditors();
|
|
|
|
|
|
|
|
|
|
return newCurve;
|
|
|
|
|
}
|