mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Summary Plot: make it possible to set color on line and range annotations.
This commit is contained in:
parent
3b4244bdbf
commit
1fefa6f363
@ -18,20 +18,14 @@
|
||||
|
||||
#include "RimTimeAxisAnnotation.h"
|
||||
|
||||
#include "RiaColorTools.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaQDateTimeTools.h"
|
||||
#include "RiaTimeTTools.h"
|
||||
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigEquil.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RiuGuiTheme.h"
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimPlot.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
@ -48,6 +42,8 @@ RimTimeAxisAnnotation::RimTimeAxisAnnotation()
|
||||
CAF_PDM_InitObject( "Time Axis Annotation", ":/LeftAxis16x16.png" );
|
||||
|
||||
m_value.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitField( &m_color, "Color", RiaColorTools::fromQColorTo3f( defaultColor( AnnotationType::LINE ) ), "Color" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -96,19 +92,43 @@ void RimTimeAxisAnnotation::setTimeRange( time_t startTime, time_t endTime )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QColor RimTimeAxisAnnotation::color() const
|
||||
QColor RimTimeAxisAnnotation::defaultColor( AnnotationType annotationType )
|
||||
{
|
||||
if ( annotationType() == AnnotationType::LINE )
|
||||
if ( annotationType == AnnotationType::LINE )
|
||||
{
|
||||
return RiuGuiTheme::getColorByVariableName( "secondaryColor" ); // QColor(255, 0, 0);
|
||||
}
|
||||
else if ( annotationType() == RimPlotAxisAnnotation::AnnotationType::RANGE )
|
||||
else if ( annotationType == RimPlotAxisAnnotation::AnnotationType::RANGE )
|
||||
{
|
||||
return RiuGuiTheme::getColorByVariableName( "primaryColor" ); // QColor( 0, 0, 255 );
|
||||
}
|
||||
return RiuGuiTheme::getColorByVariableName( "textColor" ); // QColor(0, 0, 100);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTimeAxisAnnotation::setDefaultColor()
|
||||
{
|
||||
m_color = RiaColorTools::fromQColorTo3f( defaultColor( annotationType() ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTimeAxisAnnotation::setColor( const cvf::Color3f& color )
|
||||
{
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QColor RimTimeAxisAnnotation::color() const
|
||||
{
|
||||
return RiaColorTools::toQColor( m_color );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -121,3 +141,14 @@ void RimTimeAxisAnnotation::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
|
||||
|
||||
uiOrdering.skipRemainingFields();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTimeAxisAnnotation::initAfterRead()
|
||||
{
|
||||
if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2023.03" ) )
|
||||
{
|
||||
setDefaultColor();
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include "cvfColor3.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
//==================================================================================================
|
||||
@ -42,6 +44,14 @@ public:
|
||||
void setTimeRange( time_t startTime, time_t endTime );
|
||||
QColor color() const override;
|
||||
|
||||
void setColor( const cvf::Color3f& color );
|
||||
void setDefaultColor();
|
||||
|
||||
protected:
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void initAfterRead() override;
|
||||
|
||||
static QColor defaultColor( AnnotationType annotationType );
|
||||
|
||||
caf::PdmField<cvf::Color3f> m_color;
|
||||
};
|
||||
|
@ -423,6 +423,7 @@ void RimSummaryDeclineCurve::updateTimeAnnotations()
|
||||
if ( m_showTimeSelectionInPlot )
|
||||
{
|
||||
m_timeRangeAnnotation = plot->addTimeRangeAnnotation( m_minTimeStep, m_maxTimeStep );
|
||||
m_timeRangeAnnotation->setColor( color() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1351,6 +1351,7 @@ RimTimeAxisAnnotation* RimSummaryPlot::addTimeAnnotation( time_t time )
|
||||
|
||||
auto* annotation = new RimTimeAxisAnnotation;
|
||||
annotation->setTime( time );
|
||||
annotation->setDefaultColor();
|
||||
|
||||
axisProps->appendAnnotation( annotation );
|
||||
return annotation;
|
||||
@ -1365,6 +1366,7 @@ RimTimeAxisAnnotation* RimSummaryPlot::addTimeRangeAnnotation( time_t startTime,
|
||||
|
||||
auto* annotation = new RimTimeAxisAnnotation;
|
||||
annotation->setTimeRange( startTime, endTime );
|
||||
annotation->setDefaultColor();
|
||||
|
||||
axisProps->appendAnnotation( annotation );
|
||||
return annotation;
|
||||
|
@ -569,6 +569,7 @@ void RimSummaryRegressionAnalysisCurve::updateTimeAnnotations()
|
||||
if ( m_showTimeSelectionInPlot )
|
||||
{
|
||||
m_timeRangeAnnotation = plot->addTimeRangeAnnotation( m_minTimeStep, m_maxTimeStep );
|
||||
m_timeRangeAnnotation->setColor( color() );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user