mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
#12457 Move management of time axis annotations
Use RimTimeAxisAnnotationUpdater for management of annotation objects.
This commit is contained in:
1 parent
975bd32bac
commit
ad83985e62
14 files changed
+284
-166
No files matched your search
@@ -15,6 +15,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPolylineTarget.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisAnnotation.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimTimeAxisAnnotation.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimTimeAxisAnnotationUpdater.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEquilibriumAxisAnnotation.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.h
|
||||
)
|
||||
@@ -36,6 +37,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPolylineTarget.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisAnnotation.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimTimeAxisAnnotation.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimTimeAxisAnnotationUpdater.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEquilibriumAxisAnnotation.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.cpp
|
||||
)
|
||||
|
||||
@@ -33,6 +33,21 @@
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimTimeAxisAnnotation, "RimTimeAxisAnnotation" );
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
QString defaultDateTimeFormatString()
|
||||
{
|
||||
auto dateFormatString = RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(),
|
||||
RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY );
|
||||
|
||||
auto timeFormatString = RiaQDateTimeTools::timeFormatString( RiaPreferences::current()->timeFormat(),
|
||||
RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE );
|
||||
|
||||
return QString( "%1 %2" ).arg( dateFormatString ).arg( timeFormatString );
|
||||
}
|
||||
} // namespace internal
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -44,6 +59,31 @@ RimTimeAxisAnnotation::RimTimeAxisAnnotation()
|
||||
m_value.uiCapability()->setUiHidden( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimTimeAxisAnnotation* RimTimeAxisAnnotation::createTimeAnnotation( time_t time, const cvf::Color3f& color, const QString& dateTimeFormatString )
|
||||
{
|
||||
RimTimeAxisAnnotation* annotation = new RimTimeAxisAnnotation();
|
||||
annotation->setTime( time, dateTimeFormatString );
|
||||
annotation->setColor( color );
|
||||
return annotation;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimTimeAxisAnnotation* RimTimeAxisAnnotation::createTimeRangeAnnotation( time_t startTime,
|
||||
time_t endTime,
|
||||
const cvf::Color3f& color,
|
||||
const QString& dateTimeFormatString )
|
||||
{
|
||||
RimTimeAxisAnnotation* annotation = new RimTimeAxisAnnotation();
|
||||
annotation->setTimeRange( startTime, endTime, dateTimeFormatString );
|
||||
annotation->setColor( color );
|
||||
return annotation;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -51,18 +91,7 @@ void RimTimeAxisAnnotation::setTime( time_t time, const QString& dateTimeFormatS
|
||||
{
|
||||
m_value = RiaTimeTTools::toDouble( time );
|
||||
|
||||
QString formatString = dateTimeFormatString;
|
||||
|
||||
if ( formatString.isEmpty() )
|
||||
{
|
||||
QString dateFormatString = RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(),
|
||||
RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY );
|
||||
|
||||
QString timeFormatString = RiaQDateTimeTools::timeFormatString( RiaPreferences::current()->timeFormat(),
|
||||
RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE );
|
||||
|
||||
QString dateTimeFormatString = QString( "%1 %2" ).arg( dateFormatString ).arg( timeFormatString );
|
||||
}
|
||||
QString formatString = dateTimeFormatString.isEmpty() ? internal::defaultDateTimeFormatString() : dateTimeFormatString;
|
||||
|
||||
m_name = RiaQDateTimeTools::toStringUsingApplicationLocale( RiaQDateTimeTools::fromTime_t( time ), formatString );
|
||||
|
||||
@@ -72,22 +101,16 @@ void RimTimeAxisAnnotation::setTime( time_t time, const QString& dateTimeFormatS
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTimeAxisAnnotation::setTimeRange( time_t startTime, time_t endTime )
|
||||
void RimTimeAxisAnnotation::setTimeRange( time_t startTime, time_t endTime, const QString& dateTimeFormatString )
|
||||
{
|
||||
m_rangeStart = RiaTimeTTools::toDouble( startTime );
|
||||
m_rangeEnd = RiaTimeTTools::toDouble( endTime );
|
||||
|
||||
QString dateFormatString = RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(),
|
||||
RiaDefines::DateFormatComponents::DATE_FORMAT_YEAR_MONTH_DAY );
|
||||
|
||||
QString timeFormatString = RiaQDateTimeTools::timeFormatString( RiaPreferences::current()->timeFormat(),
|
||||
RiaDefines::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE );
|
||||
|
||||
QString dateTimeFormatString = QString( "%1 %2" ).arg( dateFormatString ).arg( timeFormatString );
|
||||
QString formatString = dateTimeFormatString.isEmpty() ? internal::defaultDateTimeFormatString() : dateTimeFormatString;
|
||||
|
||||
m_name = QString( "%0 - %1" )
|
||||
.arg( RiaQDateTimeTools::toStringUsingApplicationLocale( RiaQDateTimeTools::fromTime_t( startTime ), dateTimeFormatString ) )
|
||||
.arg( RiaQDateTimeTools::toStringUsingApplicationLocale( RiaQDateTimeTools::fromTime_t( endTime ), dateTimeFormatString ) );
|
||||
.arg( RiaQDateTimeTools::toStringUsingApplicationLocale( RiaQDateTimeTools::fromTime_t( startTime ), formatString ) )
|
||||
.arg( RiaQDateTimeTools::toStringUsingApplicationLocale( RiaQDateTimeTools::fromTime_t( endTime ), formatString ) );
|
||||
|
||||
setAnnotationType( AnnotationType::RANGE );
|
||||
}
|
||||
|
||||
@@ -38,12 +38,20 @@ class RimTimeAxisAnnotation : public RimPlotAxisAnnotation
|
||||
public:
|
||||
RimTimeAxisAnnotation();
|
||||
|
||||
void setTime( time_t time, const QString& dateTimeFormatString );
|
||||
void setTimeRange( time_t startTime, time_t endTime );
|
||||
static RimTimeAxisAnnotation*
|
||||
createTimeAnnotation( time_t time, const cvf::Color3f& color, const QString& dateTimeFormatString = QString() );
|
||||
|
||||
static RimTimeAxisAnnotation* createTimeRangeAnnotation( time_t startTime,
|
||||
time_t endTime,
|
||||
const cvf::Color3f& color,
|
||||
const QString& dateTimeFormatString = QString() );
|
||||
|
||||
private:
|
||||
void setTime( time_t time, const QString& dateTimeFormatString = QString() );
|
||||
void setTimeRange( time_t startTime, time_t endTime, const QString& dateTimeFormatString = QString() );
|
||||
|
||||
void setDefaultColor();
|
||||
|
||||
protected:
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void initAfterRead() override;
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2025 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 "RimTimeAxisAnnotationUpdater.h"
|
||||
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimSummaryDeclineCurve.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryRegressionAnalysisCurve.h"
|
||||
#include "RimSummaryTimeAxisProperties.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimTimeAxisAnnotation*> RimTimeAxisAnnotationUpdater::createTimeAnnotations( const RimSummaryPlot* summaryPlot )
|
||||
{
|
||||
if ( !summaryPlot ) return {};
|
||||
|
||||
std::vector<RimTimeAxisAnnotation*> timeAnnotations;
|
||||
|
||||
for ( auto curve : summaryPlot->allCurves() )
|
||||
{
|
||||
if ( auto declineCurve = dynamic_cast<RimSummaryDeclineCurve*>( curve ) )
|
||||
{
|
||||
auto annotations = declineCurve->createTimeAnnotations();
|
||||
timeAnnotations.insert( timeAnnotations.end(), annotations.begin(), annotations.end() );
|
||||
}
|
||||
else if ( auto regressionCurve = dynamic_cast<RimSummaryRegressionAnalysisCurve*>( curve ) )
|
||||
{
|
||||
auto annotations = regressionCurve->createTimeAnnotations();
|
||||
timeAnnotations.insert( timeAnnotations.end(), annotations.begin(), annotations.end() );
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto curveSet : summaryPlot->curveSets() )
|
||||
{
|
||||
auto annotations = curveSet->createTimeAnnotations();
|
||||
timeAnnotations.insert( timeAnnotations.end(), annotations.begin(), annotations.end() );
|
||||
}
|
||||
|
||||
return timeAnnotations;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTimeAxisAnnotationUpdater::updateTimeAnnotationObjects( RimSummaryPlot* summaryPlot )
|
||||
{
|
||||
if ( !summaryPlot ) return;
|
||||
|
||||
if ( auto axisProps = summaryPlot->timeAxisProperties() )
|
||||
{
|
||||
axisProps->removeAllAnnotations();
|
||||
|
||||
for ( auto annotation : createTimeAnnotations( summaryPlot ) )
|
||||
{
|
||||
axisProps->appendAnnotation( annotation );
|
||||
}
|
||||
summaryPlot->updateAxes();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2025 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimEnsembleCurveSet;
|
||||
class RimSummaryDeclineCurve;
|
||||
class RimSummaryPlot;
|
||||
class RimTimeAxisAnnotation;
|
||||
|
||||
namespace RimTimeAxisAnnotationUpdater
|
||||
{
|
||||
void updateTimeAnnotationObjects( RimSummaryPlot* summaryPlot );
|
||||
std::vector<RimTimeAxisAnnotation*> createTimeAnnotations( const RimSummaryPlot* summaryPlot );
|
||||
}; // namespace RimTimeAxisAnnotationUpdater
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "RimSummaryEnsemble.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimTimeAxisAnnotation.h"
|
||||
#include "RimTimeStepFilter.h"
|
||||
|
||||
#include "RiuAbstractLegendFrame.h"
|
||||
@@ -522,6 +523,57 @@ std::pair<time_t, time_t> RimEnsembleCurveSet::selectedTimeStepRange() const
|
||||
return { selectedMin, selectedMax };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimTimeAxisAnnotation*> RimEnsembleCurveSet::createTimeAnnotations() const
|
||||
{
|
||||
if ( !m_showCurves() ) return {};
|
||||
|
||||
bool showTimeRange = false;
|
||||
bool showSelectedTimeSteps = false;
|
||||
|
||||
if ( ( m_colorMode() == ColorMode::BY_OBJECTIVE_FUNCTION &&
|
||||
m_objectiveFunction()->functionType() == RimObjectiveFunction::FunctionType::F1 ) ||
|
||||
( m_colorMode() == ColorMode::BY_CUSTOM_OBJECTIVE_FUNCTION && m_customObjectiveFunction() &&
|
||||
m_customObjectiveFunction()->weightContainsFunctionType( RimObjectiveFunction::FunctionType::F1 ) ) )
|
||||
{
|
||||
showTimeRange = true;
|
||||
}
|
||||
|
||||
if ( ( m_colorMode() == ColorMode::BY_OBJECTIVE_FUNCTION &&
|
||||
m_objectiveFunction()->functionType() == RimObjectiveFunction::FunctionType::F2 ) ||
|
||||
( m_colorMode() == ColorMode::BY_CUSTOM_OBJECTIVE_FUNCTION && m_customObjectiveFunction() &&
|
||||
m_customObjectiveFunction()->weightContainsFunctionType( RimObjectiveFunction::FunctionType::F2 ) ) )
|
||||
{
|
||||
showSelectedTimeSteps = true;
|
||||
}
|
||||
|
||||
for ( auto filter : m_curveFilters->filters() )
|
||||
{
|
||||
if ( filter->isActive() && filter->filterMode() == RimEnsembleCurveFilter::FilterMode::SUMMARY_VALUE ) showTimeRange = true;
|
||||
}
|
||||
|
||||
std::vector<RimTimeAxisAnnotation*> timeAnnotations;
|
||||
if ( showTimeRange )
|
||||
{
|
||||
auto [minTimeStep, maxTimeStep] = selectedTimeStepRange();
|
||||
|
||||
timeAnnotations.push_back( RimTimeAxisAnnotation::createTimeRangeAnnotation( minTimeStep, maxTimeStep, m_colorForRealizations ) );
|
||||
}
|
||||
|
||||
if ( showSelectedTimeSteps )
|
||||
{
|
||||
for ( QDateTime timeStep : m_selectedTimeSteps() )
|
||||
{
|
||||
timeAnnotations.push_back(
|
||||
RimTimeAxisAnnotation::createTimeAnnotation( RiaTimeTTools::fromQDateTime( timeStep ), m_colorForRealizations ) );
|
||||
}
|
||||
}
|
||||
|
||||
return timeAnnotations;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -2067,48 +2119,10 @@ void RimEnsembleCurveSet::updateCurveColors()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::updateTimeAnnotations()
|
||||
{
|
||||
auto plot = firstAncestorOrThisOfTypeAsserted<RimSummaryPlot>();
|
||||
plot->removeAllTimeAnnotations();
|
||||
|
||||
bool showTimeRange = false;
|
||||
bool showSelectedTimeSteps = false;
|
||||
|
||||
if ( ( m_colorMode() == ColorMode::BY_OBJECTIVE_FUNCTION &&
|
||||
m_objectiveFunction()->functionType() == RimObjectiveFunction::FunctionType::F1 ) ||
|
||||
( m_colorMode() == ColorMode::BY_CUSTOM_OBJECTIVE_FUNCTION && m_customObjectiveFunction() &&
|
||||
m_customObjectiveFunction()->weightContainsFunctionType( RimObjectiveFunction::FunctionType::F1 ) ) )
|
||||
if ( auto plot = firstAncestorOrThisOfType<RimSummaryPlot>() )
|
||||
{
|
||||
showTimeRange = true;
|
||||
plot->updateAndRedrawTimeAnnotations();
|
||||
}
|
||||
|
||||
if ( ( m_colorMode() == ColorMode::BY_OBJECTIVE_FUNCTION &&
|
||||
m_objectiveFunction()->functionType() == RimObjectiveFunction::FunctionType::F2 ) ||
|
||||
( m_colorMode() == ColorMode::BY_CUSTOM_OBJECTIVE_FUNCTION && m_customObjectiveFunction() &&
|
||||
m_customObjectiveFunction()->weightContainsFunctionType( RimObjectiveFunction::FunctionType::F2 ) ) )
|
||||
{
|
||||
showSelectedTimeSteps = true;
|
||||
}
|
||||
|
||||
for ( auto filter : m_curveFilters->filters() )
|
||||
{
|
||||
if ( filter->isActive() && filter->filterMode() == RimEnsembleCurveFilter::FilterMode::SUMMARY_VALUE ) showTimeRange = true;
|
||||
}
|
||||
|
||||
if ( showTimeRange )
|
||||
{
|
||||
auto [minTimeStep, maxTimeStep] = selectedTimeStepRange();
|
||||
plot->addTimeRangeAnnotation( minTimeStep, maxTimeStep );
|
||||
}
|
||||
|
||||
if ( showSelectedTimeSteps )
|
||||
{
|
||||
for ( QDateTime timeStep : m_selectedTimeSteps() )
|
||||
{
|
||||
plot->addTimeAnnotation( RiaTimeTTools::fromQDateTime( timeStep ) );
|
||||
}
|
||||
}
|
||||
|
||||
plot->updateAxes();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -65,6 +65,7 @@ class RiuPlotWidget;
|
||||
class RiuPlotCurve;
|
||||
class RimPlotAxisPropertiesInterface;
|
||||
class RimSummaryAddressSelector;
|
||||
class RimTimeAxisAnnotation;
|
||||
|
||||
class QwtPlot;
|
||||
class QwtPlotCurve;
|
||||
@@ -197,6 +198,8 @@ public:
|
||||
RiaDefines::HorizontalAxisType xAxisType() const;
|
||||
void findOrAssignBottomAxisX( RiuPlotAxis plotAxis );
|
||||
|
||||
std::vector<RimTimeAxisAnnotation*> createTimeAnnotations() const;
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
|
||||
|
||||
@@ -70,15 +70,6 @@ RimSummaryDeclineCurve::RimSummaryDeclineCurve()
|
||||
CAF_PDM_InitField( &m_showTimeSelectionInPlot, "ShowTimeSelectionInPlot", true, "Show In Plot" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryDeclineCurve::~RimSummaryDeclineCurve()
|
||||
{
|
||||
auto plot = firstAncestorOrThisOfType<RimSummaryPlot>();
|
||||
if ( plot && m_timeRangeAnnotation ) plot->removeTimeAnnotation( m_timeRangeAnnotation );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -99,6 +90,24 @@ std::vector<double> RimSummaryDeclineCurve::valuesX() const
|
||||
return createDeclineCurveValues( RimSummaryCurve::valuesX(), RimSummaryCurve::timeStepsX(), minTimeStep, maxTimeStep, curveType() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimTimeAxisAnnotation*> RimSummaryDeclineCurve::createTimeAnnotations() const
|
||||
{
|
||||
if ( m_showTimeSelectionInPlot && isChecked() )
|
||||
{
|
||||
auto [minTimeStep, maxTimeStep] = selectedTimeStepRange();
|
||||
|
||||
auto annotation = RimTimeAxisAnnotation::createTimeRangeAnnotation( minTimeStep, maxTimeStep, color() );
|
||||
annotation->setName( "" );
|
||||
|
||||
return { annotation };
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -445,16 +454,9 @@ QString RimSummaryDeclineCurve::curveExportDescription( const RifEclipseSummaryA
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryDeclineCurve::updateTimeAnnotations()
|
||||
{
|
||||
auto plot = firstAncestorOrThisOfTypeAsserted<RimSummaryPlot>();
|
||||
if ( m_timeRangeAnnotation ) plot->removeTimeAnnotation( m_timeRangeAnnotation );
|
||||
|
||||
if ( m_showTimeSelectionInPlot && isChecked() )
|
||||
if ( auto plot = firstAncestorOrThisOfType<RimSummaryPlot>() )
|
||||
{
|
||||
auto [minTimeStep, maxTimeStep] = selectedTimeStepRange();
|
||||
|
||||
m_timeRangeAnnotation = plot->addTimeRangeAnnotation( minTimeStep, maxTimeStep );
|
||||
m_timeRangeAnnotation->setColor( color() );
|
||||
m_timeRangeAnnotation->setName( "" );
|
||||
plot->updateAndRedrawTimeAnnotations();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ public:
|
||||
};
|
||||
|
||||
RimSummaryDeclineCurve();
|
||||
~RimSummaryDeclineCurve() override;
|
||||
|
||||
void setDeclineCurveType( DeclineCurveType declineCurveType );
|
||||
|
||||
@@ -56,6 +55,8 @@ public:
|
||||
// X Axis functions
|
||||
std::vector<double> valuesX() const override;
|
||||
|
||||
std::vector<RimTimeAxisAnnotation*> createTimeAnnotations() const;
|
||||
|
||||
protected:
|
||||
void updateTimeAnnotations() override;
|
||||
|
||||
@@ -107,6 +108,4 @@ private:
|
||||
caf::PdmField<int> m_maxTimeSliderPosition;
|
||||
|
||||
caf::PdmField<bool> m_showTimeSelectionInPlot;
|
||||
|
||||
caf::PdmPointer<RimTimeAxisAnnotation> m_timeRangeAnnotation;
|
||||
};
|
||||
@@ -1487,7 +1487,13 @@ void RimSummaryMultiPlot::updateReadOutSettings()
|
||||
{
|
||||
for ( auto plot : summaryPlots() )
|
||||
{
|
||||
if ( !m_readOutSettings->enableVerticalLine() ) plot->removeAllTimeAnnotations();
|
||||
if ( !m_readOutSettings->enableVerticalLine() )
|
||||
{
|
||||
if ( auto axisProps = plot->timeAxisProperties() )
|
||||
{
|
||||
axisProps->removeAllAnnotations();
|
||||
}
|
||||
}
|
||||
|
||||
if ( !m_readOutSettings->enableHorizontalLine() )
|
||||
{
|
||||
@@ -1499,7 +1505,7 @@ void RimSummaryMultiPlot::updateReadOutSettings()
|
||||
|
||||
plot->enableCurvePointTracking( m_readOutSettings->enableCurvePointTracking() );
|
||||
|
||||
plot->updateAxes();
|
||||
plot->updateAndRedrawTimeAnnotations();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1769,15 +1775,11 @@ void RimSummaryMultiPlot::updateReadOutLines( double qwtTimeValue, double yValue
|
||||
{
|
||||
plot->timeAxisProperties()->removeAllAnnotations();
|
||||
|
||||
auto anno = new RimTimeAxisAnnotation;
|
||||
|
||||
anno->setTime( timeTValue, dateFormatString );
|
||||
|
||||
auto lineAppearance = m_readOutSettings->lineAppearance();
|
||||
auto anno = RimTimeAxisAnnotation::createTimeAnnotation( timeTValue, lineAppearance->color() );
|
||||
|
||||
Qt::PenStyle style = lineAppearance->isDashed() ? Qt::PenStyle::DashLine : Qt::PenStyle::SolidLine;
|
||||
anno->setPenStyle( style );
|
||||
anno->setColor( lineAppearance->color() );
|
||||
anno->setAlignment( m_readOutSettings->verticalLineLabelAlignment() );
|
||||
|
||||
plot->timeAxisProperties()->appendAnnotation( anno );
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "SummaryPlotCommands/RicSummaryPlotEditorUi.h"
|
||||
|
||||
#include "Annotations/RimTimeAxisAnnotationUpdater.h"
|
||||
#include "RimAsciiDataCurve.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
@@ -1348,54 +1349,11 @@ void RimSummaryPlot::updateCaseNameHasChanged()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimTimeAxisAnnotation* RimSummaryPlot::addTimeAnnotation( time_t time )
|
||||
void RimSummaryPlot::updateAndRedrawTimeAnnotations()
|
||||
{
|
||||
RimSummaryTimeAxisProperties* axisProps = timeAxisProperties();
|
||||
CAF_ASSERT( axisProps );
|
||||
RimTimeAxisAnnotationUpdater::updateTimeAnnotationObjects( this );
|
||||
|
||||
auto* annotation = new RimTimeAxisAnnotation;
|
||||
const QString formatString;
|
||||
annotation->setTime( time, formatString );
|
||||
annotation->setDefaultColor();
|
||||
|
||||
axisProps->appendAnnotation( annotation );
|
||||
return annotation;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimTimeAxisAnnotation* RimSummaryPlot::addTimeRangeAnnotation( time_t startTime, time_t endTime )
|
||||
{
|
||||
RimSummaryTimeAxisProperties* axisProps = timeAxisProperties();
|
||||
CAF_ASSERT( axisProps );
|
||||
|
||||
auto* annotation = new RimTimeAxisAnnotation;
|
||||
annotation->setTimeRange( startTime, endTime );
|
||||
annotation->setDefaultColor();
|
||||
|
||||
axisProps->appendAnnotation( annotation );
|
||||
return annotation;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::removeAllTimeAnnotations()
|
||||
{
|
||||
RimSummaryTimeAxisProperties* axisProps = timeAxisProperties();
|
||||
if ( axisProps ) axisProps->removeAllAnnotations();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::removeTimeAnnotation( RimTimeAxisAnnotation* annotation )
|
||||
{
|
||||
RimSummaryTimeAxisProperties* axisProps = timeAxisProperties();
|
||||
CAF_ASSERT( axisProps );
|
||||
|
||||
axisProps->removeAnnotation( annotation );
|
||||
updateAxes();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -2980,6 +2938,7 @@ void RimSummaryPlot::onCurveCollectionChanged( const SignalEmitter* emitter )
|
||||
{
|
||||
curvesChanged.send();
|
||||
|
||||
updateAndRedrawTimeAnnotations();
|
||||
updateStackedCurveData();
|
||||
scheduleReplotIfVisible();
|
||||
|
||||
|
||||
@@ -124,11 +124,8 @@ public:
|
||||
void reattachAllCurves() override;
|
||||
void updateCaseNameHasChanged();
|
||||
|
||||
RimTimeAxisAnnotation* addTimeAnnotation( time_t time );
|
||||
RimTimeAxisAnnotation* addTimeRangeAnnotation( time_t startTime, time_t endTime );
|
||||
void removeTimeAnnotation( RimTimeAxisAnnotation* annotation );
|
||||
void removeAllTimeAnnotations();
|
||||
void updateAnnotationsInPlotWidget();
|
||||
void updateAndRedrawTimeAnnotations();
|
||||
void updateAnnotationsInPlotWidget();
|
||||
|
||||
void updateAxes() override;
|
||||
|
||||
|
||||
@@ -132,15 +132,6 @@ RimSummaryRegressionAnalysisCurve::RimSummaryRegressionAnalysisCurve()
|
||||
m_valueRangeY.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryRegressionAnalysisCurve::~RimSummaryRegressionAnalysisCurve()
|
||||
{
|
||||
auto plot = firstAncestorOrThisOfType<RimSummaryPlot>();
|
||||
if ( plot && m_timeRangeAnnotation ) plot->removeTimeAnnotation( m_timeRangeAnnotation );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -852,6 +843,21 @@ bool RimSummaryRegressionAnalysisCurve::isRegressionCurve() const
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimTimeAxisAnnotation*> RimSummaryRegressionAnalysisCurve::createTimeAnnotations() const
|
||||
{
|
||||
if ( m_showTimeSelectionInPlot && isChecked() )
|
||||
{
|
||||
auto [minTimeStep, maxTimeStep] = selectedTimeStepRange();
|
||||
|
||||
return { RimTimeAxisAnnotation::createTimeRangeAnnotation( minTimeStep, maxTimeStep, color() ) };
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -925,14 +931,9 @@ std::pair<std::vector<time_t>, std::vector<double>> RimSummaryRegressionAnalysis
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryRegressionAnalysisCurve::updateTimeAnnotations()
|
||||
{
|
||||
auto plot = firstAncestorOrThisOfTypeAsserted<RimSummaryPlot>();
|
||||
if ( m_timeRangeAnnotation ) plot->removeTimeAnnotation( m_timeRangeAnnotation );
|
||||
|
||||
if ( m_showTimeSelectionInPlot && isChecked() )
|
||||
if ( auto plot = firstAncestorOrThisOfType<RimSummaryPlot>() )
|
||||
{
|
||||
auto [minTimeStep, maxTimeStep] = selectedTimeStepRange();
|
||||
m_timeRangeAnnotation = plot->addTimeRangeAnnotation( minTimeStep, maxTimeStep );
|
||||
m_timeRangeAnnotation->setColor( color() );
|
||||
plot->updateAndRedrawTimeAnnotations();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,6 @@ public:
|
||||
};
|
||||
|
||||
RimSummaryRegressionAnalysisCurve();
|
||||
~RimSummaryRegressionAnalysisCurve() override;
|
||||
|
||||
void setEnsembleCurveSet( RimEnsembleCurveSet* ensembleCurveSet );
|
||||
|
||||
@@ -93,6 +92,8 @@ public:
|
||||
|
||||
bool isRegressionCurve() const override;
|
||||
|
||||
std::vector<RimTimeAxisAnnotation*> createTimeAnnotations() const;
|
||||
|
||||
protected:
|
||||
void updateTimeAnnotations() override;
|
||||
|
||||
@@ -158,11 +159,10 @@ private:
|
||||
caf::PdmField<caf::AppEnum<RangeType>> m_yRangeSelection;
|
||||
caf::PdmField<std::pair<double, double>> m_valueRangeY;
|
||||
|
||||
caf::PdmPointer<RimTimeAxisAnnotation> m_timeRangeAnnotation;
|
||||
std::vector<double> m_valuesX;
|
||||
std::vector<time_t> m_timeStepsX;
|
||||
std::vector<double> m_valuesY;
|
||||
std::vector<time_t> m_timeStepsY;
|
||||
std::vector<double> m_valuesX;
|
||||
std::vector<time_t> m_timeStepsX;
|
||||
std::vector<double> m_valuesY;
|
||||
std::vector<time_t> m_timeStepsY;
|
||||
|
||||
// Source curve data
|
||||
std::vector<double> m_sourceValuesX;
|
||||
|
||||
Reference in new issue
Block a user