mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#9202 Well Log Plot: add option for having the legend inside the plot
This commit is contained in:
committed by
Magne Sjaastad
parent
df16e1fe5c
commit
318f187635
@@ -945,7 +945,7 @@ void RimDepthTrackPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi
|
||||
uiOrderingForAutoName( uiConfigName, *titleGroup );
|
||||
|
||||
caf::PdmUiGroup* plotLayoutGroup = uiOrdering.addNewGroup( "Plot Layout" );
|
||||
RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, *plotLayoutGroup );
|
||||
RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, *plotLayoutGroup, true );
|
||||
plotLayoutGroup->add( &m_subTitleFontSize );
|
||||
plotLayoutGroup->add( &m_axisTitleFontSize );
|
||||
plotLayoutGroup->add( &m_axisValueFontSize );
|
||||
|
||||
@@ -33,6 +33,19 @@
|
||||
|
||||
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotWindow, "RimPlotWindow" ); // Do not use. Abstract class
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template <>
|
||||
void caf::AppEnum<RimPlotWindow::LegendPosition>::setUp()
|
||||
{
|
||||
addItem( RimPlotWindow::LegendPosition::ABOVE, "ABOVE", "Above" );
|
||||
addItem( RimPlotWindow::LegendPosition::INSIDE, "INSIDE", "Inside" );
|
||||
setDefault( RimPlotWindow::LegendPosition::ABOVE );
|
||||
}
|
||||
}; // namespace caf
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -59,6 +72,7 @@ RimPlotWindow::RimPlotWindow()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_titleFontSize, "TitleFontSize", "Title Font Size" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_legendFontSize, "LegendDeltaFontSize", "Legend Font Size" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_legendPosition, "LegendPosition", "Legend Position" );
|
||||
|
||||
m_titleFontSize = caf::FontTools::RelativeSize::XXLarge;
|
||||
m_legendFontSize = caf::FontTools::RelativeSize::Large;
|
||||
@@ -89,6 +103,7 @@ RimPlotWindow& RimPlotWindow::operator=( RimPlotWindow&& rhs )
|
||||
m_plotLegendsHorizontal = rhs.m_plotLegendsHorizontal();
|
||||
m_titleFontSize = rhs.m_titleFontSize();
|
||||
m_legendFontSize = rhs.m_legendFontSize();
|
||||
m_legendPosition = rhs.m_legendPosition();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -180,6 +195,22 @@ void RimPlotWindow::setLegendFontSize( caf::FontTools::RelativeSize fontSize )
|
||||
m_legendFontSize = fontSize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotWindow::LegendPosition RimPlotWindow::legendPosition() const
|
||||
{
|
||||
return m_legendPosition();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotWindow::setLegendPosition( RimPlotWindow::LegendPosition legendPosition )
|
||||
{
|
||||
m_legendPosition = legendPosition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -250,11 +281,8 @@ void RimPlotWindow::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
updateWindowVisibility();
|
||||
}
|
||||
|
||||
if ( changedField == &m_showPlotLegends || changedField == &m_plotLegendsHorizontal )
|
||||
{
|
||||
updateLayout();
|
||||
}
|
||||
else if ( changedField == &m_legendFontSize || changedField == &m_titleFontSize )
|
||||
if ( changedField == &m_showPlotLegends || changedField == &m_plotLegendsHorizontal ||
|
||||
changedField == &m_legendFontSize || changedField == &m_titleFontSize || changedField == &m_legendPosition )
|
||||
{
|
||||
updateLayout();
|
||||
}
|
||||
@@ -284,10 +312,14 @@ QList<caf::PdmOptionItemInfo> RimPlotWindow::calculateValueOptions( const caf::P
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotWindow::uiOrderingForPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
void RimPlotWindow::uiOrderingForPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering, bool showLegendPosition )
|
||||
{
|
||||
uiOrdering.add( &m_showPlotLegends );
|
||||
uiOrdering.add( &m_plotLegendsHorizontal );
|
||||
if ( showLegendPosition )
|
||||
{
|
||||
uiOrdering.add( &m_legendPosition );
|
||||
}
|
||||
uiOrdering.add( &m_titleFontSize );
|
||||
uiOrdering.add( &m_legendFontSize );
|
||||
}
|
||||
|
||||
@@ -44,6 +44,12 @@ class RimPlotWindow : public RimViewWindow
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum class LegendPosition
|
||||
{
|
||||
ABOVE,
|
||||
INSIDE,
|
||||
};
|
||||
|
||||
RimPlotWindow();
|
||||
~RimPlotWindow() override;
|
||||
|
||||
@@ -54,11 +60,13 @@ public:
|
||||
bool plotTitleVisible() const;
|
||||
void setPlotTitleVisible( bool showPlotTitle );
|
||||
|
||||
virtual QString description() const = 0;
|
||||
bool legendsVisible() const;
|
||||
void setLegendsVisible( bool doShow );
|
||||
bool legendsHorizontal() const;
|
||||
void setLegendsHorizontal( bool horizontal );
|
||||
virtual QString description() const = 0;
|
||||
bool legendsVisible() const;
|
||||
void setLegendsVisible( bool doShow );
|
||||
bool legendsHorizontal() const;
|
||||
void setLegendsHorizontal( bool horizontal );
|
||||
void setLegendPosition( RimPlotWindow::LegendPosition legendPosition );
|
||||
RimPlotWindow::LegendPosition legendPosition() const;
|
||||
|
||||
void updateFonts() override;
|
||||
|
||||
@@ -84,7 +92,7 @@ protected:
|
||||
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
|
||||
void uiOrderingForPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
|
||||
void uiOrderingForPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering, bool showLegendPosition = false );
|
||||
|
||||
void updateWindowVisibility();
|
||||
|
||||
@@ -100,10 +108,11 @@ private:
|
||||
void assignIdIfNecessary() final;
|
||||
|
||||
protected:
|
||||
caf::PdmField<int> m_id;
|
||||
caf::PdmField<bool> m_showPlotTitle;
|
||||
caf::PdmField<bool> m_showPlotLegends;
|
||||
caf::PdmField<bool> m_plotLegendsHorizontal;
|
||||
caf::PdmField<int> m_id;
|
||||
caf::PdmField<bool> m_showPlotTitle;
|
||||
caf::PdmField<bool> m_showPlotLegends;
|
||||
caf::PdmField<bool> m_plotLegendsHorizontal;
|
||||
caf::PdmField<caf::AppEnum<LegendPosition>> m_legendPosition;
|
||||
|
||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_titleFontSize;
|
||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_legendFontSize;
|
||||
|
||||
Reference in New Issue
Block a user