Refactored plot axis annotations.

Added time axis annotations.
This commit is contained in:
Ruben Thoms 2020-12-07 16:47:34 +01:00 committed by Magne Sjaastad
parent c6e10c9c5d
commit c6b3721991
23 changed files with 938 additions and 195 deletions

View File

@ -156,6 +156,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimColorLegendItem.h
${CMAKE_CURRENT_LIST_DIR}/RimAbstractPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimVfpTableExtractor.h
${CMAKE_CURRENT_LIST_DIR}/RimCaseDisplayNameTools.h
${CMAKE_CURRENT_LIST_DIR}/RimEquilibriumAxisAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimTimeAxisAnnotation.h
)
@ -314,6 +316,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimColorLegend.cpp
${CMAKE_CURRENT_LIST_DIR}/RimColorLegendItem.cpp
${CMAKE_CURRENT_LIST_DIR}/RimVfpTableExtractor.cpp
${CMAKE_CURRENT_LIST_DIR}/RimCaseDisplayNameTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RimEquilibriumAxisAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimTimeAxisAnnotation.cpp
)
if(Qt5Charts_FOUND)

View File

@ -27,8 +27,8 @@
#include "RimEclipseResultCase.h"
#include "RimEclipseResultDefinition.h"
#include "RimEquilibriumAxisAnnotation.h"
#include "RimGridCrossPlotDataSet.h"
#include "RimPlotAxisAnnotation.h"
#include "RimPlotAxisProperties.h"
#include "CellFilters/RimPlotCellPropertyFilter.h"
@ -172,18 +172,18 @@ void RimSaturationPressurePlot::assignCaseAndEquilibriumRegion( RiaDefines::Poro
yAxisProps->setInvertedAxis( true );
{
RimPlotAxisAnnotation* annotation = new RimPlotAxisAnnotation;
RimEquilibriumAxisAnnotation* annotation = new RimEquilibriumAxisAnnotation;
annotation->setEquilibriumData( eclipseResultCase,
zeroBasedEquilRegionIndex,
RimPlotAxisAnnotation::PL_EQUIL_GAS_OIL_CONTACT );
RimEquilibriumAxisAnnotation::PlotAxisAnnotationType::PL_EQUIL_GAS_OIL_CONTACT );
yAxisProps->appendAnnotation( annotation );
}
{
RimPlotAxisAnnotation* annotation = new RimPlotAxisAnnotation;
RimEquilibriumAxisAnnotation* annotation = new RimEquilibriumAxisAnnotation;
annotation->setEquilibriumData( eclipseResultCase,
zeroBasedEquilRegionIndex,
RimPlotAxisAnnotation::PL_EQUIL_WATER_OIL_CONTACT );
RimEquilibriumAxisAnnotation::PlotAxisAnnotationType::PL_EQUIL_WATER_OIL_CONTACT );
yAxisProps->appendAnnotation( annotation );
}

View File

@ -0,0 +1,215 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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 "RimEquilibriumAxisAnnotation.h"
#include "RigEclipseCaseData.h"
#include "RigEquil.h"
#include "RimEclipseCase.h"
#include "RimPlot.h"
#include "RimTools.h"
#include "RimViewWindow.h"
#include <cmath>
namespace caf
{
template <>
void RimEquilibriumAxisAnnotation::ExportKeywordEnum::setUp()
{
addItem( RimEquilibriumAxisAnnotation::PlotAxisAnnotationType::PL_USER_DEFINED, "User Defined", "User Defined" );
addItem( RimEquilibriumAxisAnnotation::PlotAxisAnnotationType::PL_EQUIL_WATER_OIL_CONTACT,
"PL_EQUIL_WATER_OIL_CONTACT",
"PL_EQUIL_WATER_OIL_CONTACT" );
addItem( RimEquilibriumAxisAnnotation::PlotAxisAnnotationType::PL_EQUIL_GAS_OIL_CONTACT,
"PL_EQUIL_GAS_OIL_CONTACT",
"PL_EQUIL_GAS_OIL_CONTACT" );
setDefault( RimEquilibriumAxisAnnotation::PlotAxisAnnotationType::PL_USER_DEFINED );
}
} // namespace caf
CAF_PDM_SOURCE_INIT( RimEquilibriumAxisAnnotation, "RimEquilibriumAxisAnnotation" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEquilibriumAxisAnnotation::RimEquilibriumAxisAnnotation()
: RimPlotAxisAnnotation()
{
CAF_PDM_InitObject( "Equilibrium Annotation", ":/LeftAxis16x16.png", "", "" );
CAF_PDM_InitFieldNoDefault( &m_annotationType, "AnnotationType", "AnnotationType", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_sourceCase, "Associated3DCase", "Eclipse Case", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_equilNum, "m_equilNum", "equil Num", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEquilibriumAxisAnnotation::setEquilibriumData( RimEclipseCase* eclipseCase,
int zeroBasedEquilRegionIndex,
RimEquilibriumAxisAnnotation::PlotAxisAnnotationType annotationType )
{
m_sourceCase = eclipseCase;
m_equilNum = zeroBasedEquilRegionIndex + 1;
m_annotationType = annotationType;
updateName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimEquilibriumAxisAnnotation::value() const
{
if ( m_annotationType() == PlotAxisAnnotationType::PL_EQUIL_WATER_OIL_CONTACT )
{
return selectedItem().waterOilContactDepth();
}
else if ( m_annotationType() == PlotAxisAnnotationType::PL_EQUIL_GAS_OIL_CONTACT )
{
return selectedItem().gasOilContactDepth();
}
return m_value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QColor RimEquilibriumAxisAnnotation::color() const
{
if ( m_annotationType() == PlotAxisAnnotationType::PL_EQUIL_WATER_OIL_CONTACT )
{
return QColor( 0, 0, 0 );
}
else if ( m_annotationType() == PlotAxisAnnotationType::PL_EQUIL_GAS_OIL_CONTACT )
{
return QColor( 220, 0, 0 );
}
return RimPlotAxisAnnotation::color();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimEquilibriumAxisAnnotation::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_sourceCase )
{
RimTools::caseOptionItems( &options );
}
else if ( fieldNeedingOptions == &m_equilNum )
{
for ( int i = 0; i < static_cast<int>( equilItems().size() ); i++ )
{
QString uiText = QString( "%1" ).arg( i + 1 );
options.push_back( caf::PdmOptionItemInfo( uiText, i ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEquilibriumAxisAnnotation::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_annotationType );
if ( m_annotationType() == PlotAxisAnnotationType::PL_USER_DEFINED )
{
uiOrdering.add( &m_name );
uiOrdering.add( &m_value );
}
else
{
uiOrdering.add( &m_sourceCase );
uiOrdering.add( &m_equilNum );
}
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEquil RimEquilibriumAxisAnnotation::selectedItem() const
{
int index = m_equilNum() - 1;
if ( index < static_cast<int>( equilItems().size() ) )
{
return equilItems()[index];
}
return RigEquil::defaultObject();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigEquil> RimEquilibriumAxisAnnotation::equilItems() const
{
if ( m_sourceCase && m_sourceCase->eclipseCaseData() )
{
m_sourceCase->ensureDeckIsParsedForEquilData();
return m_sourceCase->eclipseCaseData()->equilData();
}
return std::vector<RigEquil>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEquilibriumAxisAnnotation::updateName()
{
QString text;
if ( m_annotationType() == PlotAxisAnnotationType::PL_EQUIL_WATER_OIL_CONTACT ||
m_annotationType() == PlotAxisAnnotationType::PL_EQUIL_GAS_OIL_CONTACT )
{
double diffBetweenTwoContactDepths =
std::fabs( selectedItem().gasOilContactDepth() - selectedItem().waterOilContactDepth() );
if ( diffBetweenTwoContactDepths < 0.1 )
{
text = QString( "GWC %1" ).arg( selectedItem().gasOilContactDepth() );
}
else if ( m_annotationType() == PlotAxisAnnotationType::PL_EQUIL_WATER_OIL_CONTACT )
{
text = QString( "WOC %1" ).arg( value() );
}
else if ( m_annotationType() == PlotAxisAnnotationType::PL_EQUIL_GAS_OIL_CONTACT )
{
text = QString( "GOC %1" ).arg( value() );
}
m_name = text;
}
}

View File

@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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 "RimPlotAxisAnnotation.h"
#include "cafAppEnum.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include <QString>
class RimEclipseCase;
class RigEquil;
//==================================================================================================
///
///
//==================================================================================================
class RimEquilibriumAxisAnnotation : public RimPlotAxisAnnotation
{
CAF_PDM_HEADER_INIT;
public:
enum class PlotAxisAnnotationType
{
PL_USER_DEFINED = 0,
PL_EQUIL_WATER_OIL_CONTACT,
PL_EQUIL_GAS_OIL_CONTACT
};
typedef caf::AppEnum<PlotAxisAnnotationType> ExportKeywordEnum;
RimEquilibriumAxisAnnotation();
void setEquilibriumData( RimEclipseCase* eclipseCase,
int zeroBasedEquilRegionIndex,
PlotAxisAnnotationType annotationType );
double value() const override;
QColor color() const override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
protected:
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
private:
RigEquil selectedItem() const;
std::vector<RigEquil> equilItems() const;
void updateName();
private:
caf::PdmField<ExportKeywordEnum> m_annotationType;
caf::PdmPtrField<RimEclipseCase*> m_sourceCase;
caf::PdmField<int> m_equilNum;
};

View File

@ -28,18 +28,6 @@
#include <cmath>
namespace caf
{
template <>
void RimPlotAxisAnnotation::ExportKeywordEnum::setUp()
{
addItem( RimPlotAxisAnnotation::PL_USER_DEFINED, "User Defined", "User Defined" );
addItem( RimPlotAxisAnnotation::PL_EQUIL_WATER_OIL_CONTACT, "PL_EQUIL_WATER_OIL_CONTACT", "PL_EQUIL_WATER_OIL_CONTACT" );
addItem( RimPlotAxisAnnotation::PL_EQUIL_GAS_OIL_CONTACT, "PL_EQUIL_GAS_OIL_CONTACT", "PL_EQUIL_GAS_OIL_CONTACT" );
setDefault( RimPlotAxisAnnotation::PL_USER_DEFINED );
}
} // namespace caf
CAF_PDM_SOURCE_INIT( RimPlotAxisAnnotation, "RimPlotAxisAnnotation" );
//--------------------------------------------------------------------------------------------------
@ -47,6 +35,7 @@ CAF_PDM_SOURCE_INIT( RimPlotAxisAnnotation, "RimPlotAxisAnnotation" );
//--------------------------------------------------------------------------------------------------
RimPlotAxisAnnotation::RimPlotAxisAnnotation()
{
m_annotationType = AnnotationType::LINE;
CAF_PDM_InitObject( "Plot Axis Annotation", ":/LeftAxis16x16.png", "", "" );
CAF_PDM_InitField( &m_isActive, "Active", true, "Active", "", "", "" );
@ -55,10 +44,8 @@ RimPlotAxisAnnotation::RimPlotAxisAnnotation()
CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_value, "Value", "Value", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_annotationType, "AnnotationType", "AnnotationType", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_sourceCase, "Associated3DCase", "Eclipse Case", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_equilNum, "m_equilNum", "equil Num", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_rangeStart, "RangeStart", "Range Start", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_rangeEnd, "RangeEnd", "Range End", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
@ -80,15 +67,9 @@ void RimPlotAxisAnnotation::setValue( double value )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisAnnotation::setEquilibriumData( RimEclipseCase* eclipseCase,
int zeroBasedEquilRegionIndex,
PlotAxisAnnotationType annotationType )
RimPlotAxisAnnotation::AnnotationType RimPlotAxisAnnotation::annotationType() const
{
m_sourceCase = eclipseCase;
m_equilNum = zeroBasedEquilRegionIndex + 1;
m_annotationType = annotationType;
updateName();
return m_annotationType;
}
//--------------------------------------------------------------------------------------------------
@ -104,32 +85,30 @@ QString RimPlotAxisAnnotation::name() const
//--------------------------------------------------------------------------------------------------
double RimPlotAxisAnnotation::value() const
{
if ( m_annotationType() == PL_EQUIL_WATER_OIL_CONTACT )
{
return selectedItem().waterOilContactDepth();
}
else if ( m_annotationType() == PL_EQUIL_GAS_OIL_CONTACT )
{
return selectedItem().gasOilContactDepth();
}
return m_value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPlotAxisAnnotation::rangeStart() const
{
return m_rangeStart();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPlotAxisAnnotation::rangeEnd() const
{
return m_rangeEnd();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QColor RimPlotAxisAnnotation::color() const
{
if ( m_annotationType() == PL_EQUIL_WATER_OIL_CONTACT )
{
return QColor( 0, 0, 0 );
}
else if ( m_annotationType() == PL_EQUIL_GAS_OIL_CONTACT )
{
return QColor( 220, 0, 0 );
}
return QColor( 0, 0, 100 );
}
@ -164,47 +143,13 @@ void RimPlotAxisAnnotation::fieldChangedByUi( const caf::PdmFieldHandle* changed
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimPlotAxisAnnotation::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_sourceCase )
{
RimTools::caseOptionItems( &options );
}
else if ( fieldNeedingOptions == &m_equilNum )
{
for ( int i = 0; i < static_cast<int>( equilItems().size() ); i++ )
{
QString uiText = QString( "%1" ).arg( i + 1 );
options.push_back( caf::PdmOptionItemInfo( uiText, i ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisAnnotation::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_annotationType );
if ( m_annotationType() == PL_USER_DEFINED )
{
uiOrdering.add( &m_name );
uiOrdering.add( &m_value );
}
else
{
uiOrdering.add( &m_sourceCase );
uiOrdering.add( &m_equilNum );
}
uiOrdering.add( &m_name );
uiOrdering.add( &m_value );
uiOrdering.skipRemainingFields();
}
@ -212,58 +157,7 @@ void RimPlotAxisAnnotation::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEquil RimPlotAxisAnnotation::selectedItem() const
void RimPlotAxisAnnotation::setAnnotationType( AnnotationType annoType )
{
int index = m_equilNum() - 1;
if ( index < static_cast<int>( equilItems().size() ) )
{
return equilItems()[index];
}
return RigEquil::defaultObject();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigEquil> RimPlotAxisAnnotation::equilItems() const
{
if ( m_sourceCase && m_sourceCase->eclipseCaseData() )
{
m_sourceCase->ensureDeckIsParsedForEquilData();
return m_sourceCase->eclipseCaseData()->equilData();
}
return std::vector<RigEquil>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisAnnotation::updateName()
{
QString text;
if ( m_annotationType() == PL_EQUIL_WATER_OIL_CONTACT || m_annotationType() == PL_EQUIL_GAS_OIL_CONTACT )
{
double diffBetweenTwoContactDepths =
std::fabs( selectedItem().gasOilContactDepth() - selectedItem().waterOilContactDepth() );
if ( diffBetweenTwoContactDepths < 0.1 )
{
text = QString( "GWC %1" ).arg( selectedItem().gasOilContactDepth() );
}
else if ( m_annotationType() == PL_EQUIL_WATER_OIL_CONTACT )
{
text = QString( "WOC %1" ).arg( value() );
}
else if ( m_annotationType() == PL_EQUIL_GAS_OIL_CONTACT )
{
text = QString( "GOC %1" ).arg( value() );
}
m_name = text;
}
m_annotationType = annoType;
}

View File

@ -18,16 +18,12 @@
#pragma once
#include "cafAppEnum.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include <QString>
class RimEclipseCase;
class RigEquil;
//==================================================================================================
///
///
@ -37,50 +33,41 @@ class RimPlotAxisAnnotation : public caf::PdmObject
CAF_PDM_HEADER_INIT;
public:
enum PlotAxisAnnotationType
enum class AnnotationType
{
PL_USER_DEFINED,
PL_EQUIL_WATER_OIL_CONTACT,
PL_EQUIL_GAS_OIL_CONTACT
LINE = 0,
RANGE
};
typedef caf::AppEnum<PlotAxisAnnotationType> ExportKeywordEnum;
RimPlotAxisAnnotation();
void setName( const QString& name );
void setValue( double value );
void setEquilibriumData( RimEclipseCase* eclipseCase,
int zeroBasedEquilRegionIndex,
PlotAxisAnnotationType annotationType );
QString name() const;
double value() const;
QColor color() const;
AnnotationType annotationType() const;
virtual QString name() const;
virtual double value() const;
virtual double rangeStart() const;
virtual double rangeEnd() const;
virtual QColor color() const;
caf::PdmFieldHandle* userDescriptionField() override;
caf::PdmFieldHandle* objectToggleField() override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
protected:
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
private:
RigEquil selectedItem() const;
std::vector<RigEquil> equilItems() const;
void updateName();
private:
caf::PdmField<ExportKeywordEnum> m_annotationType;
protected:
caf::PdmField<bool> m_isActive;
caf::PdmField<QString> m_name;
caf::PdmField<double> m_value;
caf::PdmField<double> m_rangeStart;
caf::PdmField<double> m_rangeEnd;
caf::PdmPtrField<RimEclipseCase*> m_sourceCase;
caf::PdmField<int> m_equilNum;
protected:
void setAnnotationType( AnnotationType annotationType );
private:
AnnotationType m_annotationType;
};

View File

@ -345,6 +345,14 @@ void RimPlotAxisProperties::appendAnnotation( RimPlotAxisAnnotation* annotation
m_annotations.push_back( annotation );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisProperties::removeAllAnnotations()
{
m_annotations.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -67,7 +67,7 @@ public:
QwtPlot::Axis qwtPlotAxisType() const;
QString name() const;
RiaDefines::PlotAxis plotAxisType() const;
RiaDefines::PlotAxis plotAxisType() const override;
bool useAutoTitle() const;
bool showDescription() const;
bool showAcronym() const;
@ -79,6 +79,7 @@ public:
std::vector<RimPlotAxisAnnotation*> annotations() const;
void appendAnnotation( RimPlotAxisAnnotation* annotation );
void removeAllAnnotations() override;
caf::PdmField<QString> customTitle;

View File

@ -18,8 +18,12 @@
#pragma once
#include "RiaDefines.h"
#include "cafAppEnum.h"
class RimPlotAxisAnnotation;
class RimPlotAxisPropertiesInterface
{
public:
@ -37,6 +41,11 @@ public:
};
using LegendTickmarkCountEnum = caf::AppEnum<LegendTickmarkCount>;
virtual std::vector<RimPlotAxisAnnotation*> annotations() const = 0;
virtual void appendAnnotation( RimPlotAxisAnnotation* annotation ) = 0;
virtual void removeAllAnnotations() = 0;
virtual RiaDefines::PlotAxis plotAxisType() const = 0;
public:
virtual AxisTitlePositionType titlePosition() const = 0;
virtual int titleFontSize() const = 0;

View File

@ -0,0 +1,128 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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 "RimTimeAxisAnnotation.h"
#include "RiaPreferences.h"
#include "RiaQDateTimeTools.h"
#include "RiaTimeTTools.h"
#include "RigEclipseCaseData.h"
#include "RigEquil.h"
#include "RiuGuiTheme.h"
#include "RiuQwtPlotCurve.h"
#include "RimEclipseCase.h"
#include "RimPlot.h"
#include "RimTools.h"
#include "RimViewWindow.h"
#include <QDateTime>
#include <cmath>
CAF_PDM_SOURCE_INIT( RimTimeAxisAnnotation, "RimTimeAxisAnnotation" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimTimeAxisAnnotation::RimTimeAxisAnnotation()
: RimPlotAxisAnnotation()
{
CAF_PDM_InitObject( "Time Axis Annotation", ":/LeftAxis16x16.png", "", "" );
m_value.uiCapability()->setUiHidden( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTimeAxisAnnotation::setTime( time_t time )
{
m_value = RiaTimeTTools::toDouble( time );
QString dateFormatString = RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(),
RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY );
QString timeFormatString =
RiaQDateTimeTools::timeFormatString( RiaPreferences::current()->timeFormat(),
RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE );
QString dateTimeFormatString = QString( "%1 %2" ).arg( dateFormatString ).arg( timeFormatString );
m_name =
RiaQDateTimeTools::toStringUsingApplicationLocale( RiaQDateTimeTools::fromTime_t( time ), dateTimeFormatString );
this->setAnnotationType( AnnotationType::LINE );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTimeAxisAnnotation::setTimeRange( time_t startTime, time_t endTime )
{
m_rangeStart = RiaTimeTTools::toDouble( startTime );
m_rangeEnd = RiaTimeTTools::toDouble( endTime );
QString dateFormatString = RiaQDateTimeTools::dateFormatString( RiaPreferences::current()->dateFormat(),
RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY );
QString timeFormatString =
RiaQDateTimeTools::timeFormatString( RiaPreferences::current()->timeFormat(),
RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_HOUR_MINUTE );
QString dateTimeFormatString = QString( "%1 %2" ).arg( dateFormatString ).arg( timeFormatString );
m_name = QString( "%0 - %1" )
.arg( RiaQDateTimeTools::toStringUsingApplicationLocale( RiaQDateTimeTools::fromTime_t( startTime ),
dateTimeFormatString ) )
.arg( RiaQDateTimeTools::toStringUsingApplicationLocale( RiaQDateTimeTools::fromTime_t( endTime ),
dateTimeFormatString ) );
this->setAnnotationType( AnnotationType::RANGE );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QColor RimTimeAxisAnnotation::color() const
{
if ( annotationType() == AnnotationType::LINE )
{
return RiuGuiTheme::getColorByVariableName( "secondaryColor" ); // QColor(255, 0, 0);
}
else if ( annotationType() == RimPlotAxisAnnotation::AnnotationType::RANGE )
{
return RiuGuiTheme::getColorByVariableName( "primaryColor" ); // QColor( 0, 0, 255 );
}
return RiuGuiTheme::getColorByVariableName( "textColor" ); // QColor(0, 0, 100);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTimeAxisAnnotation::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_name );
uiOrdering.add( &m_value );
uiOrdering.add( &m_rangeStart );
uiOrdering.add( &m_rangeEnd );
uiOrdering.skipRemainingFields();
}

View File

@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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 "RimPlotAxisAnnotation.h"
#include "cafAppEnum.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include <QString>
//==================================================================================================
///
///
//==================================================================================================
class RimTimeAxisAnnotation : public RimPlotAxisAnnotation
{
CAF_PDM_HEADER_INIT;
public:
RimTimeAxisAnnotation();
void setTime( time_t time );
void setTimeRange( time_t startTime, time_t endTime );
QColor color() const override;
protected:
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
};

View File

@ -409,6 +409,14 @@ void RimSummaryCurve::setOverrideCurveDataY( const std::vector<time_t>& dateTime
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveDefinition RimSummaryCurve::curveDefinitionX() const
{
return RiaSummaryCurveDefinition( summaryCaseX(), summaryAddressX(), isEnsembleCurve() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -72,10 +72,11 @@ public:
void setOverrideCurveDataY( const std::vector<time_t>& xValues, const std::vector<double>& yValues );
// X Axis functions
RimSummaryCase* summaryCaseX() const;
RifEclipseSummaryAddress summaryAddressX() const;
std::string unitNameX() const;
std::vector<double> valuesX() const;
RiaSummaryCurveDefinition curveDefinitionX() const;
RimSummaryCase* summaryCaseX() const;
RifEclipseSummaryAddress summaryAddressX() const;
std::string unitNameX() const;
std::vector<double> valuesX() const;
void setSummaryCaseX( RimSummaryCase* sumCase );
void setSummaryAddressX( const RifEclipseSummaryAddress& address );

View File

@ -238,6 +238,15 @@ void RimSummaryPlot::updateAxes()
updateYAxis( RiaDefines::PlotAxis::PLOT_AXIS_LEFT );
updateYAxis( RiaDefines::PlotAxis::PLOT_AXIS_RIGHT );
if ( m_timeAxisProperties() && m_plotWidget )
{
m_plotWidget->updateAnnotationObjects( m_timeAxisProperties() );
}
if ( m_leftYAxisProperties() && m_plotWidget )
{
m_plotWidget->updateAnnotationObjects( m_leftYAxisProperties() );
}
if ( m_isCrossPlot )
{
updateBottomXAxis();
@ -247,6 +256,8 @@ void RimSummaryPlot::updateAxes()
updateTimeAxis();
}
m_plotWidget->scheduleReplot();
updateZoomInQwt();
}
@ -1162,6 +1173,45 @@ void RimSummaryPlot::updateCaseNameHasChanged()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::addTimeAnnotation( time_t time )
{
RimSummaryTimeAxisProperties* axisProps = timeAxisProperties();
{
RimTimeAxisAnnotation* annotation = new RimTimeAxisAnnotation;
annotation->setTime( time );
axisProps->appendAnnotation( annotation );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::addTimeRangeAnnotation( time_t startTime, time_t endTime )
{
RimSummaryTimeAxisProperties* axisProps = timeAxisProperties();
{
RimTimeAxisAnnotation* annotation = new RimTimeAxisAnnotation;
annotation->setTimeRange( startTime, endTime );
axisProps->appendAnnotation( annotation );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::removeAllTimeAnnotations()
{
RimSummaryTimeAxisProperties* axisProps = timeAxisProperties();
{
axisProps->removeAllAnnotations();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -107,6 +107,10 @@ public:
void reattachAllCurves() override;
void updateCaseNameHasChanged();
void addTimeAnnotation( time_t time );
void addTimeRangeAnnotation( time_t startTime, time_t endTime );
void removeAllTimeAnnotations();
void updateAxes() override;
bool isLogarithmicScaleEnabled( RiaDefines::PlotAxis plotAxis ) const;

View File

@ -115,6 +115,10 @@ RimSummaryTimeAxisProperties::RimSummaryTimeAxisProperties()
CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_annotations, "Annotations", "", "", "", "" );
m_annotations.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_visibleDateTimeRangeMax_OBSOLETE, "VisibleRangeMax", "Max", "", "", "" );
m_visibleDateTimeRangeMax_OBSOLETE.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() );
@ -130,6 +134,14 @@ RimPlotAxisPropertiesInterface::AxisTitlePositionType RimSummaryTimeAxisProperti
return m_titlePositionEnum();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaDefines::PlotAxis RimSummaryTimeAxisProperties::plotAxisType() const
{
return RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -490,6 +502,30 @@ RiaQDateTimeTools::TimeFormatComponents
return components;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPlotAxisAnnotation*> RimSummaryTimeAxisProperties::annotations() const
{
return m_annotations.childObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryTimeAxisProperties::appendAnnotation( RimPlotAxisAnnotation* annotation )
{
m_annotations.push_back( annotation );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryTimeAxisProperties::removeAllAnnotations()
{
m_annotations.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -19,7 +19,9 @@
#pragma once
#include "RiaQDateTimeTools.h"
#include "RimPlotAxisPropertiesInterface.h"
#include "RimTimeAxisAnnotation.h"
#include "cafAppEnum.h"
#include "cafFontTools.h"
@ -64,6 +66,7 @@ public:
caf::PdmField<QString> title;
caf::PdmField<bool> showTitle;
RiaDefines::PlotAxis plotAxisType() const override;
AxisTitlePositionType titlePosition() const override;
int titleFontSize() const override;
int valuesFontSize() const override;
@ -78,6 +81,10 @@ public:
timeComponents( RiaQDateTimeTools::TimeFormatComponents fallback =
RiaQDateTimeTools::TimeFormatComponents::TIME_FORMAT_UNSPECIFIED ) const;
std::vector<RimPlotAxisAnnotation*> annotations() const override;
void appendAnnotation( RimPlotAxisAnnotation* annotation ) override;
void removeAllAnnotations() override;
const QString& dateFormat() const;
const QString& timeFormat() const;
@ -142,6 +149,7 @@ private:
caf::PdmField<QString> m_dateFormat;
caf::PdmField<QString> m_timeFormat;
caf::PdmField<LegendTickmarkCountEnum> m_majorTickmarkCount;
caf::PdmChildArrayField<RimPlotAxisAnnotation*> m_annotations;
caf::PdmField<QDateTime> m_visibleDateTimeRangeMin_OBSOLETE;
caf::PdmField<QDateTime> m_visibleDateTimeRangeMax_OBSOLETE;

View File

@ -24,7 +24,7 @@
#include "RimGridCrossPlotDataSet.h"
#include "RimPlot.h"
#include "RimPlotAxisAnnotation.h"
#include "RimPlotAxisProperties.h"
#include "RimPlotAxisPropertiesInterface.h"
#include "RimRegularLegendConfig.h"
#include "RiuCvfOverlayItemWidget.h"
@ -123,13 +123,17 @@ RiuGridCrossQwtPlot::~RiuGridCrossQwtPlot()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::updateAnnotationObjects( RimPlotAxisProperties* axisProperties )
void RiuGridCrossQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties )
{
m_annotationTool->detachAllAnnotations();
for ( auto annotation : axisProperties->annotations() )
{
m_annotationTool->attachAnnotationLine( this, annotation->color(), annotation->name(), annotation->value() );
m_annotationTool->attachAnnotationLine( this,
annotation->color(),
annotation->name(),
annotation->value(),
RiuPlotAnnotationTool::Orientation::HORIZONTAL );
}
}

View File

@ -29,7 +29,7 @@
class RimGridCrossPlot;
class RimGridCrossPlotDataSet;
class RimPlotAxisProperties;
class RimPlotAxisPropertiesInterface;
class RimPlot;
class RiuCvfOverlayItemWidget;
class RiuDraggableOverlayFrame;
@ -56,7 +56,7 @@ public:
RiuGridCrossQwtPlot( const RiuGridCrossQwtPlot& ) = delete;
void updateAnnotationObjects( RimPlotAxisProperties* axisProperties );
void updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties );
void setLegendFontSize( int fontSize );
void setInternalQwtLegendVisible( bool visible );

View File

@ -18,6 +18,8 @@
#include "RiuPlotAnnotationTool.h"
#include "RiuGuiTheme.h"
#include "cafCategoryMapper.h"
#include "cvfMath.h"
@ -93,7 +95,7 @@ void RiuPlotAnnotationTool::attachNamedRegions( QwtPlot*
shading->attach( m_plot );
shading->setZ( -100.0 );
shading->setXAxis( QwtPlot::xTop );
m_markers.push_back( std::move( shading ) );
m_horizontalMarkers.push_back( std::move( shading ) );
}
QColor lineColor( 0, 0, 0, 0 );
@ -120,7 +122,7 @@ void RiuPlotAnnotationTool::attachNamedRegions( QwtPlot*
Qt::Alignment horizontalAlignment = trackTextAlignment( trackSpan );
RiuPlotAnnotationTool::horizontalDashedLine( line, name, yPositions[i].first, lineColor, textColor, horizontalAlignment );
line->attach( m_plot );
m_markers.push_back( std::move( line ) );
m_horizontalMarkers.push_back( std::move( line ) );
if ( ( i != names.size() - 1 ) && cvf::Math::abs( yPositions[i].second - yPositions[i + 1].first ) > delta )
{
@ -128,7 +130,7 @@ void RiuPlotAnnotationTool::attachNamedRegions( QwtPlot*
RiuPlotAnnotationTool::horizontalDashedLine( bottomLine, QString(), yPositions[i].second, lineColor, textColor );
bottomLine->attach( m_plot );
m_markers.push_back( std::move( bottomLine ) );
m_horizontalMarkers.push_back( std::move( bottomLine ) );
}
}
}
@ -140,7 +142,7 @@ void RiuPlotAnnotationTool::attachWellPicks( QwtPlot* plot,
const std::vector<QString>& names,
const std::vector<double>& yPositions )
{
detachAllAnnotations();
detachAllAnnotations( Orientation::HORIZONTAL );
if ( names.size() != yPositions.size() ) return;
m_plot = plot;
@ -150,7 +152,7 @@ void RiuPlotAnnotationTool::attachWellPicks( QwtPlot* plot,
QwtPlotMarker* line( new QwtPlotMarker() );
RiuPlotAnnotationTool::horizontalDashedLine( line, names[i], yPositions[i] );
line->attach( m_plot );
m_markers.push_back( std::move( line ) );
m_horizontalMarkers.push_back( std::move( line ) );
}
}
@ -160,14 +162,89 @@ void RiuPlotAnnotationTool::attachWellPicks( QwtPlot* plot,
void RiuPlotAnnotationTool::attachAnnotationLine( QwtPlot* plot,
const QColor& color,
const QString& annotationText,
const double yPosition )
const double position,
Orientation orientation )
{
m_plot = plot;
QwtPlotMarker* line( new QwtPlotMarker() );
RiuPlotAnnotationTool::horizontalDashedLine( line, annotationText, yPosition, color, color );
if ( orientation == Orientation::HORIZONTAL )
{
RiuPlotAnnotationTool::horizontalDashedLine( line, annotationText, position, color, color );
m_horizontalMarkers.push_back( std::move( line ) );
}
else if ( orientation == Orientation::VERTICAL )
{
RiuPlotAnnotationTool::verticalLine( line,
annotationText,
position,
color,
RiuGuiTheme::getColorByVariableName( "textColor" ) );
m_verticalMarkers.push_back( std::move( line ) );
}
line->attach( m_plot );
m_markers.push_back( std::move( line ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::attachAnnotationRange( QwtPlot* plot,
const QColor& color,
const QString& annotationText,
const double rangeStart,
const double rangeEnd,
Orientation orientation )
{
m_plot = plot;
if ( orientation == Orientation::HORIZONTAL )
{
RiuPlotAnnotationTool::horizontalRange( annotationText,
std::make_pair( rangeStart, rangeEnd ),
color,
RiuGuiTheme::getColorByVariableName( "textColor" ) );
}
else if ( orientation == Orientation::VERTICAL )
{
RiuPlotAnnotationTool::verticalRange( annotationText,
std::make_pair( rangeStart, rangeEnd ),
color,
RiuGuiTheme::getColorByVariableName( "textColor" ),
Qt::AlignHCenter );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::detachAllAnnotations( Orientation orientation )
{
if ( m_plot )
{
if ( orientation == Orientation::HORIZONTAL )
{
for ( size_t i = 0; i < m_horizontalMarkers.size(); i++ )
{
m_horizontalMarkers[i]->detach();
delete m_horizontalMarkers[i];
}
}
else if ( orientation == Orientation::VERTICAL )
{
for ( size_t i = 0; i < m_verticalMarkers.size(); i++ )
{
m_verticalMarkers[i]->detach();
delete m_verticalMarkers[i];
}
}
}
if ( orientation == Orientation::HORIZONTAL )
{
m_horizontalMarkers.clear();
}
else if ( orientation == Orientation::VERTICAL )
{
m_verticalMarkers.clear();
}
}
//--------------------------------------------------------------------------------------------------
@ -175,15 +252,8 @@ void RiuPlotAnnotationTool::attachAnnotationLine( QwtPlot* plot,
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::detachAllAnnotations()
{
if ( m_plot )
{
for ( size_t i = 0; i < m_markers.size(); i++ )
{
m_markers[i]->detach();
delete m_markers[i];
}
}
m_markers.clear();
detachAllAnnotations( Orientation::HORIZONTAL );
detachAllAnnotations( Orientation::VERTICAL );
}
//--------------------------------------------------------------------------------------------------
@ -228,3 +298,113 @@ void RiuPlotAnnotationTool::horizontalDashedLine( QwtPlotMarker* line,
line->setLabel( label );
line->setLabelAlignment( horizontalAlignment | Qt::AlignBottom );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::horizontalRange( const QString& name,
const std::pair<double, double> yRange,
const QColor& color /*= QColor( 0, 0, 100 )*/,
const QColor& textColor /*= QColor( 0, 0, 100 )*/,
Qt::Alignment horizontalAlignment /*= Qt::AlignRight */ )
{
QColor shadingColor = color;
shadingColor.setAlpha( 10 );
QwtPlotZoneItem* shading = new QwtPlotZoneItem();
shading->setOrientation( Qt::Horizontal );
shading->setInterval( yRange.first, yRange.second );
shading->setPen( shadingColor, 0.0, Qt::NoPen );
QBrush brush( shadingColor );
shading->setBrush( brush );
shading->attach( m_plot );
shading->setZ( -100.0 );
shading->setXAxis( QwtPlot::xBottom );
m_horizontalMarkers.push_back( std::move( shading ) );
QwtPlotMarker* line( new QwtPlotMarker() );
RiuPlotAnnotationTool::horizontalDashedLine( line, name, yRange.first, color, color, horizontalAlignment );
line->attach( m_plot );
m_horizontalMarkers.push_back( std::move( line ) );
QwtPlotMarker* bottomLine( new QwtPlotMarker() );
RiuPlotAnnotationTool::horizontalDashedLine( bottomLine, QString(), yRange.second, color, color );
bottomLine->attach( m_plot );
m_horizontalMarkers.push_back( std::move( bottomLine ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::verticalRange( const QString& name,
const std::pair<double, double> xRange,
const QColor& color /*= QColor( 0, 0, 100 )*/,
const QColor& textColor /*= QColor( 0, 0, 100 )*/,
Qt::Alignment horizontalAlignment /*= Qt::AlignRight */ )
{
QColor shadingColor = color;
shadingColor.setAlpha( 50 );
QwtPlotZoneItem* shading = new QwtPlotZoneItem();
shading->setOrientation( Qt::Vertical );
shading->setInterval( xRange.first, xRange.second );
shading->setPen( shadingColor, 0.0, Qt::NoPen );
QBrush brush( shadingColor );
shading->setBrush( brush );
shading->attach( m_plot );
shading->setZ( -100.0 );
shading->setXAxis( QwtPlot::xBottom );
m_verticalMarkers.push_back( std::move( shading ) );
QStringList labels = name.split( " - " );
QwtPlotMarker* line( new QwtPlotMarker() );
RiuPlotAnnotationTool::verticalLine( line,
labels[0],
xRange.first,
color,
textColor,
Qt::SolidLine,
Qt::AlignRight | horizontalAlignment );
line->attach( m_plot );
m_verticalMarkers.push_back( std::move( line ) );
QwtPlotMarker* rightLine( new QwtPlotMarker() );
RiuPlotAnnotationTool::verticalLine( rightLine,
labels.size() == 2 ? labels[1] : QString(),
xRange.second,
color,
textColor,
Qt::SolidLine,
Qt::AlignLeft | horizontalAlignment );
rightLine->attach( m_plot );
m_verticalMarkers.push_back( std::move( rightLine ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::verticalLine( QwtPlotMarker* line,
const QString& name,
double xValue,
const QColor& color /*= QColor(0, 0, 100) */,
const QColor& textColor /*= QColor(0, 0, 100) */,
Qt::PenStyle lineStyle /*= Qt::DashLine */,
Qt::Alignment horizontalAlignment /*= Qt::AlignRight | Qt::AlignBottom */ )
{
QPen curvePen;
curvePen.setStyle( lineStyle );
curvePen.setColor( color );
curvePen.setWidth( 1 );
line->setAxes( QwtPlot::xBottom, QwtPlot::yLeft );
line->setLineStyle( QwtPlotMarker::VLine );
line->setLinePen( curvePen );
line->setXValue( xValue );
QwtText label( name );
label.setColor( textColor );
line->setLabel( label );
line->setLabelAlignment( horizontalAlignment );
line->setLabelOrientation( Qt::Orientation::Vertical );
}

View File

@ -55,6 +55,11 @@ public:
CENTRE_COLUMN,
RIGHT_COLUMN
};
enum class Orientation
{
HORIZONTAL = 0,
VERTICAL
};
public:
RiuPlotAnnotationTool(){};
@ -72,9 +77,33 @@ public:
const std::vector<Qt::BrushStyle>& brushStyles = {} );
void attachWellPicks( QwtPlot* plot, const std::vector<QString>& names, const std::vector<double>& yPositions );
void attachAnnotationLine( QwtPlot* plot, const QColor& color, const QString& annotationText, const double yPosition );
void attachAnnotationLine( QwtPlot* plot,
const QColor& color,
const QString& annotationText,
const double position,
Orientation orientation );
void attachAnnotationRange( QwtPlot* plot,
const QColor& color,
const QString& annotationText,
const double rangeStart,
const double rangeEnd,
Orientation orientation );
void horizontalRange( const QString& name,
const std::pair<double, double> yRange,
const QColor& color = QColor( 0, 0, 100 ),
const QColor& textColor = QColor( 0, 0, 100 ),
Qt::Alignment horizontalAlignment = Qt::AlignRight );
void verticalRange( const QString& name,
const std::pair<double, double> xRange,
const QColor& color = QColor( 0, 0, 100 ),
const QColor& textColor = QColor( 0, 0, 100 ),
Qt::Alignment horizontalAlignment = Qt::AlignRight );
void detachAllAnnotations();
void detachAllAnnotations( Orientation orientation );
private:
static Qt::Alignment trackTextAlignment( TrackSpan trackSpan );
@ -85,7 +114,16 @@ private:
const QColor& textColor = QColor( 0, 0, 100 ),
Qt::Alignment horizontalAlignment = Qt::AlignRight );
void verticalLine( QwtPlotMarker* line,
const QString& name,
double xValue,
const QColor& color = QColor( 0, 0, 100 ),
const QColor& textColor = QColor( 0, 0, 100 ),
Qt::PenStyle lineStyle = Qt::DashLine,
Qt::Alignment horizontalAlignment = Qt::AlignRight | Qt::AlignBottom );
private:
QPointer<QwtPlot> m_plot;
std::vector<QwtPlotItem*> m_markers;
std::vector<QwtPlotItem*> m_horizontalMarkers;
std::vector<QwtPlotItem*> m_verticalMarkers;
};

View File

@ -27,6 +27,9 @@
#include "RimEnsembleStatisticsCase.h"
#include "RimMainPlotCollection.h"
#include "RimPlot.h"
#include "RimPlotAxisAnnotation.h"
#include "RimPlotAxisProperties.h"
#include "RimPlotAxisPropertiesInterface.h"
#include "RimRegularLegendConfig.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
@ -36,6 +39,7 @@
#include "RimSummaryPlotCollection.h"
#include "RiuCvfOverlayItemWidget.h"
#include "RiuPlotAnnotationTool.h"
#include "RiuQwtCurvePointTracker.h"
#include "RiuQwtPlotWheelZoomer.h"
#include "RiuRimQwtPlotCurve.h"
@ -130,6 +134,8 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*=
RiuQwtPlotTools::setDefaultAxes( this );
setInternalLegendVisible( true );
m_annotationTool = std::unique_ptr<RiuPlotAnnotationTool>( new RiuPlotAnnotationTool() );
}
//--------------------------------------------------------------------------------------------------
@ -167,6 +173,40 @@ void RiuSummaryQwtPlot::setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithm
if ( m_wheelZoomer ) m_wheelZoomer->setAxisIsLogarithmic( axis, logarithmic );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuSummaryQwtPlot::updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties )
{
RiuPlotAnnotationTool::Orientation orientation = RiuPlotAnnotationTool::Orientation::HORIZONTAL;
if ( axisProperties->plotAxisType() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM )
{
orientation = RiuPlotAnnotationTool::Orientation::VERTICAL;
}
m_annotationTool->detachAllAnnotations( orientation );
for ( auto annotation : axisProperties->annotations() )
{
if ( annotation->annotationType() == RimPlotAxisAnnotation::AnnotationType::LINE )
{
m_annotationTool->attachAnnotationLine( this,
annotation->color(),
annotation->name(),
annotation->value(),
orientation );
}
else if ( annotation->annotationType() == RimPlotAxisAnnotation::AnnotationType::RANGE )
{
m_annotationTool->attachAnnotationRange( this,
annotation->color(),
annotation->name(),
annotation->rangeStart(),
annotation->rangeEnd(),
orientation );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -31,6 +31,8 @@ class RimSummaryPlot;
class RiuCvfOverlayItemWidget;
class RiuQwtPlotZoomer;
class RiuQwtPlotWheelZoomer;
class RimPlotAxisPropertiesInterface;
class RiuPlotAnnotationTool;
//==================================================================================================
//
@ -54,6 +56,8 @@ public:
void useTimeBasedTimeAxis();
void setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithmic );
void updateAnnotationObjects( RimPlotAxisPropertiesInterface* axisProperties );
protected:
void contextMenuEvent( QContextMenuEvent* ) override;
void setDefaults();
@ -64,6 +68,8 @@ private slots:
void onZoomedSlot();
private:
std::unique_ptr<RiuPlotAnnotationTool> m_annotationTool;
QPointer<RiuQwtPlotZoomer> m_zoomerLeft;
QPointer<RiuQwtPlotZoomer> m_zoomerRight;
QPointer<RiuQwtPlotWheelZoomer> m_wheelZoomer;