Show time annotation in all sub plots (#11906)

* Prepare for more customization of annotation objects
* Move files
* Add configuration of readout lines in sub plots. The location along the time axis is based on the current mouse cursor position. The location is distributed to all sub plots. Optional support for readout of values at the current time.
This commit is contained in:
Magne Sjaastad authored and GitHub committed 2025-02-05 17:19:01 +01:00
1 parent 28d3050433
commit 2021b286ab
29 files changed
+550 -100

No files matched your search

@@ -13,6 +13,10 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotationInView.h
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationGroupCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPolylineTarget.h
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimTimeAxisAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimEquilibriumAxisAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.h
)
set(SOURCE_GROUP_SOURCE_FILES
@@ -30,6 +34,10 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotationInView.cpp
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationGroupCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolylineTarget.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotAxisAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimTimeAxisAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimEquilibriumAxisAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
@@ -66,7 +66,7 @@ RimAnnotationLineAppearance::RimAnnotationLineAppearance()
CAF_PDM_InitObject( "AnnotationLineAppearance", ":/WellCollection.png" );
CAF_PDM_InitField( &m_lineFieldsHidden, "LineFieldsHidden", false, "Line Fields Hidden" );
CAF_PDM_InitField( &m_color, "Color", cvf::Color3f( cvf::Color3f::BLACK ), "Line Color" );
CAF_PDM_InitField( &m_color, "Color", cvf::Color3f( cvf::Color3f::DARK_GRAY ), "Line Color" );
CAF_PDM_InitField( &m_thickness, "Thickness", 2, "Line Thickness" );
// Stippling not yet supported. Needs new stuff in VizFwk
@@ -85,6 +85,20 @@ void RimAnnotationLineAppearance::setLineFieldsHidden( bool hidden )
m_lineFieldsHidden = hidden;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnnotationLineAppearance::configureForSummaryAnnotations()
{
m_style.uiCapability()->setUiHidden( false );
m_style.xmlCapability()->setIOReadable( true );
m_style.xmlCapability()->setIOWritable( true );
m_thickness.uiCapability()->setUiHidden( true );
m_style = STYLE_DASH;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -48,6 +48,7 @@ public:
RimAnnotationLineAppearance();
void setLineFieldsHidden( bool hidden );
void configureForSummaryAnnotations();
void setColor( const cvf::Color3f& newColor );
cvf::Color3f color() const;
@@ -0,0 +1,212 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 )
{
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;
}
}
@@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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
};
using ExportKeywordEnum = caf::AppEnum<PlotAxisAnnotationType>;
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 ) override;
protected:
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;
};
@@ -0,0 +1,213 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPlotAxisAnnotation.h"
#include "RigEclipseCaseData.h"
#include "RigEquil.h"
#include "RimEclipseCase.h"
#include "RimPlot.h"
#include "RimTools.h"
#include "RimViewWindow.h"
#include "RiaColorTools.h"
#include "cafPdmFieldCvfColor.h"
#include <cmath>
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" );
m_isActive.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name" );
CAF_PDM_InitFieldNoDefault( &m_value, "Value", "Value" );
CAF_PDM_InitFieldNoDefault( &m_rangeStart, "RangeStart", "Range Start" );
CAF_PDM_InitFieldNoDefault( &m_rangeEnd, "RangeEnd", "Range End" );
caf::AppEnum<Qt::PenStyle> defaultStyle = Qt::PenStyle::SolidLine;
CAF_PDM_InitField( &m_penStyle, "PenStyle", defaultStyle, "Pen Style" );
CAF_PDM_InitFieldNoDefault( &m_textAlignment, "TextAlignment", "Text Alignment" );
m_textAlignment = RiaDefines::TextAlignment::RIGHT;
CAF_PDM_InitFieldNoDefault( &m_color, "Color", "Color" );
m_color = cvf::Color3f( cvf::Color3f::BLACK );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisAnnotation::setName( const QString& name )
{
m_name = name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisAnnotation::setValue( double value )
{
m_value = value;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotAxisAnnotation::AnnotationType RimPlotAxisAnnotation::annotationType() const
{
return m_annotationType;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimPlotAxisAnnotation::name() const
{
return m_name();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPlotAxisAnnotation::value() const
{
return m_value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPlotAxisAnnotation::rangeStart() const
{
return m_rangeStart();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPlotAxisAnnotation::rangeEnd() const
{
return m_rangeEnd();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QColor RimPlotAxisAnnotation::color() const
{
return QColor( 0, 0, 100 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisAnnotation::setAlignment( RiaDefines::TextAlignment alignment )
{
m_textAlignment = alignment;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisAnnotation::setPenStyle( Qt::PenStyle penStyle )
{
m_penStyle = penStyle;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Qt::PenStyle RimPlotAxisAnnotation::penStyle() const
{
return m_penStyle();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisAnnotation::setColor( const cvf::Color3f& color )
{
m_color = color;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaDefines::TextAlignment RimPlotAxisAnnotation::textAlignment() const
{
return m_textAlignment();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimPlotAxisAnnotation::userDescriptionField()
{
return &m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimPlotAxisAnnotation::objectToggleField()
{
return &m_isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisAnnotation::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimPlot* parentPlot = firstAncestorOrThisOfType<RimPlot>();
if ( parentPlot )
{
parentPlot->updateAxes();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisAnnotation::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_name );
uiOrdering.add( &m_value );
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisAnnotation::setAnnotationType( AnnotationType annoType )
{
m_annotationType = annoType;
}
@@ -0,0 +1,87 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaPlotDefines.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "cvfColor3.h"
#include <QString>
//==================================================================================================
///
///
//==================================================================================================
class RimPlotAxisAnnotation : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
enum class AnnotationType
{
LINE = 0,
RANGE
};
RimPlotAxisAnnotation();
void setName( const QString& name );
QString name() const;
void setValue( double value );
virtual double value() const;
AnnotationType annotationType() const;
void setAnnotationType( AnnotationType annotationType );
void setPenStyle( Qt::PenStyle penStyle );
Qt::PenStyle penStyle() const;
void setColor( const cvf::Color3f& color );
virtual QColor color() const;
void setAlignment( RiaDefines::TextAlignment alignment );
RiaDefines::TextAlignment textAlignment() const;
double rangeStart() const;
double rangeEnd() const;
caf::PdmFieldHandle* userDescriptionField() override;
caf::PdmFieldHandle* objectToggleField() override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
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::PdmField<caf::AppEnum<Qt::PenStyle>> m_penStyle;
caf::PdmField<caf::AppEnum<RiaDefines::TextAlignment>> m_textAlignment;
caf::PdmField<cvf::Color3f> m_color;
AnnotationType m_annotationType;
};
@@ -0,0 +1,129 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPlotRectAnnotation.h"
#include "RimPlot.h"
#include "RimTools.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include <cmath>
CAF_PDM_SOURCE_INIT( RimPlotRectAnnotation, "RimPlotRectAnnotation" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotRectAnnotation::RimPlotRectAnnotation()
{
CAF_PDM_InitObject( "Plot Rect Annotation", ":/LeftAxis16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_minX, "MinX", "Min X" );
CAF_PDM_InitFieldNoDefault( &m_maxX, "MaxX", "Max X" );
CAF_PDM_InitFieldNoDefault( &m_minY, "MinY", "Min Y" );
CAF_PDM_InitFieldNoDefault( &m_maxY, "MaxY", "Max Y" );
CAF_PDM_InitField( &m_color, "Color", cvf::Color3f( cvf::Color3f::LIGHT_GRAY ), "Color" );
CAF_PDM_InitField( &m_transparency, "Transparency", 0.1, "Transparency" );
m_transparency.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_text, "Text", "Text" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotRectAnnotation::setRangeX( double minX, double maxX )
{
m_minX = minX;
m_maxX = maxX;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotRectAnnotation::setRangeY( double minY, double maxY )
{
m_minY = minY;
m_maxY = maxY;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<double, double> RimPlotRectAnnotation::rangeX() const
{
return { m_minX, m_maxX };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<double, double> RimPlotRectAnnotation::rangeY() const
{
return { m_minY, m_maxY };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotRectAnnotation::setColor( const cvf::Color3f& color )
{
m_color = color;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Color3f RimPlotRectAnnotation::color() const
{
return m_color;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotRectAnnotation::setTransparency( double transparency )
{
m_transparency = transparency;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPlotRectAnnotation::transparency() const
{
return m_transparency;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotRectAnnotation::setText( const QString& text )
{
m_text = text;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimPlotRectAnnotation::text() const
{
return m_text;
}
@@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimCheckableNamedObject.h"
#include "cafPdmField.h"
#include "cafPdmFieldCvfColor.h"
#include <QString>
//==================================================================================================
///
///
//==================================================================================================
class RimPlotRectAnnotation : public RimCheckableNamedObject
{
CAF_PDM_HEADER_INIT;
public:
RimPlotRectAnnotation();
void setRangeX( double minX, double maxX );
void setRangeY( double minY, double maxY );
std::pair<double, double> rangeX() const;
std::pair<double, double> rangeY() const;
void setColor( const cvf::Color3f& color );
cvf::Color3f color() const;
void setText( const QString& text );
QString text() const;
void setTransparency( double transparency );
double transparency() const;
protected:
caf::PdmField<double> m_minX;
caf::PdmField<double> m_maxX;
caf::PdmField<double> m_minY;
caf::PdmField<double> m_maxY;
caf::PdmField<cvf::Color3f> m_color;
caf::PdmField<double> m_transparency;
caf::PdmField<QString> m_text;
};
@@ -0,0 +1,141 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaColorTools.h"
#include "RiaPreferences.h"
#include "RiaQDateTimeTools.h"
#include "RiaTimeTTools.h"
#include "RimProject.h"
#include "RiuGuiTheme.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, const QString& dateTimeFormatString )
{
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 );
}
m_name = RiaQDateTimeTools::toStringUsingApplicationLocale( RiaQDateTimeTools::fromTime_t( time ), formatString );
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(),
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 );
m_name = QString( "%0 - %1" )
.arg( RiaQDateTimeTools::toStringUsingApplicationLocale( RiaQDateTimeTools::fromTime_t( startTime ), dateTimeFormatString ) )
.arg( RiaQDateTimeTools::toStringUsingApplicationLocale( RiaQDateTimeTools::fromTime_t( endTime ), dateTimeFormatString ) );
setAnnotationType( AnnotationType::RANGE );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QColor RimTimeAxisAnnotation::defaultColor( AnnotationType annotationType )
{
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::setDefaultColor()
{
setColor( RiaColorTools::fromQColorTo3f( defaultColor( annotationType() ) ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTimeAxisAnnotation::initAfterRead()
{
if ( RimProject::current()->isProjectFileVersionEqualOrOlderThan( "2023.03" ) )
{
setDefaultColor();
}
}
@@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmField.h"
#include "cafPdmObject.h"
#include "cvfColor3.h"
#include <QString>
//==================================================================================================
///
///
//==================================================================================================
class RimTimeAxisAnnotation : public RimPlotAxisAnnotation
{
CAF_PDM_HEADER_INIT;
public:
RimTimeAxisAnnotation();
void setTime( time_t time, const QString& dateTimeFormatString );
void setTimeRange( time_t startTime, time_t endTime );
void setDefaultColor();
void setDateTimeFormatString( const QString& formatString );
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void initAfterRead() override;
static QColor defaultColor( AnnotationType annotationType );
};