mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
First round of caf::FontTools
This commit is contained in:
@@ -727,66 +727,6 @@ void RimSummaryPlot::applyDefaultCurveAppearances()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryPlot::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const
|
||||
{
|
||||
if ( fontSettingType == RiaDefines::FontSettingType::PLOT_FONT && m_plotWidget )
|
||||
{
|
||||
for ( auto plotAxis : allPlotAxes() )
|
||||
{
|
||||
if ( plotAxis->titleFontSize() != defaultFontSize || plotAxis->valuesFontSize() != defaultFontSize )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_legendFontSize() != defaultFontSize )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryPlot::applyFontSize( RiaDefines::FontSettingType fontSettingType,
|
||||
int oldFontSize,
|
||||
int fontSize,
|
||||
bool forceChange /*= false*/ )
|
||||
{
|
||||
bool anyChange = false;
|
||||
|
||||
if ( fontSettingType == RiaDefines::FontSettingType::PLOT_FONT && m_plotWidget )
|
||||
{
|
||||
for ( auto plotAxis : allPlotAxes() )
|
||||
{
|
||||
if ( forceChange || plotAxis->titleFontSize() == oldFontSize )
|
||||
{
|
||||
plotAxis->setTitleFontSize( fontSize );
|
||||
anyChange = true;
|
||||
}
|
||||
if ( forceChange || plotAxis->valuesFontSize() == oldFontSize )
|
||||
{
|
||||
plotAxis->setValuesFontSize( fontSize );
|
||||
anyChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( forceChange || m_legendFontSize() == oldFontSize )
|
||||
{
|
||||
m_legendFontSize = fontSize;
|
||||
anyChange = true;
|
||||
}
|
||||
|
||||
if ( anyChange ) loadDataAndUpdate();
|
||||
}
|
||||
return anyChange;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1110,8 +1050,9 @@ void RimSummaryPlot::updateTimeAxis()
|
||||
}
|
||||
|
||||
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom,
|
||||
m_timeAxisProperties->titleFontSize(),
|
||||
m_timeAxisProperties->valuesFontSize(),
|
||||
caf::FontTools::pointSizeToPixelSize( m_timeAxisProperties->titleFontSize() ),
|
||||
caf::FontTools::pointSizeToPixelSize(
|
||||
m_timeAxisProperties->valuesFontSize() ),
|
||||
true,
|
||||
alignment );
|
||||
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, m_timeAxisProperties->title() );
|
||||
@@ -1477,7 +1418,7 @@ void RimSummaryPlot::onLoadDataAndUpdate()
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
m_plotWidget->setLegendVisible( m_showPlotLegends && isMdiWindow() );
|
||||
m_plotWidget->setLegendFontSize( m_legendFontSize() );
|
||||
m_plotWidget->setLegendFontSize( legendFontSize() );
|
||||
m_plotWidget->updateLegend();
|
||||
}
|
||||
this->updateAxes();
|
||||
@@ -1664,11 +1605,7 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
|
||||
if ( isMdiWindow() )
|
||||
{
|
||||
mainOptions->add( &m_showPlotLegends );
|
||||
if ( m_showPlotLegends() )
|
||||
{
|
||||
mainOptions->add( &m_legendFontSize );
|
||||
}
|
||||
uiOrderingForPlotLayout( uiConfigName, *mainOptions );
|
||||
}
|
||||
|
||||
mainOptions->add( &m_normalizeCurveYValues );
|
||||
@@ -1826,6 +1763,8 @@ void RimSummaryPlot::updateNameHelperWithCurveData( RimSummaryPlotNameHelper* na
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::doUpdateLayout()
|
||||
{
|
||||
updateFonts();
|
||||
|
||||
this->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
|
||||
@@ -147,12 +147,6 @@ public:
|
||||
size_t singleColorCurveCount() const;
|
||||
void applyDefaultCurveAppearances();
|
||||
|
||||
bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const override;
|
||||
bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
|
||||
int oldFontSize,
|
||||
int fontSize,
|
||||
bool forceChange = false ) override;
|
||||
|
||||
void setNormalizationEnabled( bool enable );
|
||||
bool isNormalizationEnabled();
|
||||
|
||||
|
||||
@@ -127,8 +127,8 @@ void RimSummaryPlotAxisFormatter::applyAxisPropertiesToPlot( RiuQwtPlotWidget* q
|
||||
}
|
||||
qwtPlot->setAxisTitleText( m_axisProperties->qwtPlotAxisType(), axisTitle );
|
||||
qwtPlot->setAxisFontsAndAlignment( m_axisProperties->qwtPlotAxisType(),
|
||||
m_axisProperties->titleFontSize(),
|
||||
m_axisProperties->valuesFontSize(),
|
||||
caf::FontTools::pointSizeToPixelSize( m_axisProperties->titleFontSize() ),
|
||||
caf::FontTools::pointSizeToPixelSize( m_axisProperties->valuesFontSize() ),
|
||||
true,
|
||||
titleAlignment );
|
||||
qwtPlot->setAxisTitleEnabled( m_axisProperties->qwtPlotAxisType(), true );
|
||||
|
||||
@@ -98,10 +98,8 @@ RimSummaryTimeAxisProperties::RimSummaryTimeAxisProperties()
|
||||
m_visibleTimeSinceStartRangeMin.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_titlePositionEnum, "TitlePosition", "Title Position", "", "", "" );
|
||||
CAF_PDM_InitField( &m_titleFontSize, "FontSize", 10, "Font Size", "", "", "" );
|
||||
m_titleFontSize = RiaApplication::instance()->preferences()->defaultPlotFontSize();
|
||||
CAF_PDM_InitField( &m_valuesFontSize, "ValuesFontSize", 10, "Font Size", "", "", "" );
|
||||
m_valuesFontSize = RiaApplication::instance()->preferences()->defaultPlotFontSize();
|
||||
CAF_PDM_InitFieldNoDefault( &m_titleFontSize, "FontSize", "Font Size", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_valuesFontSize, "ValuesFontSize", "Font Size", "", "", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_automaticDateComponents, "AutoDate", true, "Automatic Date/Time Labels", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_dateComponents, "DateComponents", "Set Date Label", "", "", "" );
|
||||
@@ -137,15 +135,7 @@ RimPlotAxisPropertiesInterface::AxisTitlePositionType RimSummaryTimeAxisProperti
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimSummaryTimeAxisProperties::titleFontSize() const
|
||||
{
|
||||
return m_titleFontSize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryTimeAxisProperties::setTitleFontSize( int fontSize )
|
||||
{
|
||||
m_titleFontSize = fontSize;
|
||||
return caf::FontTools::absolutePointSize( plotFontSize(), m_titleFontSize() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -153,15 +143,15 @@ void RimSummaryTimeAxisProperties::setTitleFontSize( int fontSize )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimSummaryTimeAxisProperties::valuesFontSize() const
|
||||
{
|
||||
return m_valuesFontSize;
|
||||
return caf::FontTools::absolutePointSize( plotFontSize(), m_valuesFontSize() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryTimeAxisProperties::setValuesFontSize( int fontSize )
|
||||
caf::FontTools::FontSize RimSummaryTimeAxisProperties::plotFontSize() const
|
||||
{
|
||||
m_valuesFontSize = fontSize;
|
||||
return RiaPreferences::current()->defaultPlotFontSize();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -359,27 +349,8 @@ QList<caf::PdmOptionItemInfo>
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
*useOptionsOnly = true;
|
||||
|
||||
if ( &m_titleFontSize == fieldNeedingOptions || &m_valuesFontSize == fieldNeedingOptions )
|
||||
{
|
||||
std::vector<int> fontSizes;
|
||||
fontSizes.push_back( 8 );
|
||||
fontSizes.push_back( 9 );
|
||||
fontSizes.push_back( 10 );
|
||||
fontSizes.push_back( 11 );
|
||||
fontSizes.push_back( 12 );
|
||||
fontSizes.push_back( 14 );
|
||||
fontSizes.push_back( 16 );
|
||||
fontSizes.push_back( 18 );
|
||||
fontSizes.push_back( 24 );
|
||||
|
||||
for ( int value : fontSizes )
|
||||
{
|
||||
QString text = QString( "%1" ).arg( value );
|
||||
options.push_back( caf::PdmOptionItemInfo( text, value ) );
|
||||
}
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_dateFormat )
|
||||
|
||||
if ( fieldNeedingOptions == &m_dateFormat )
|
||||
{
|
||||
for ( auto dateFormat : RiaQDateTimeTools::supportedDateFormats() )
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "RimPlotAxisPropertiesInterface.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafFontTools.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
@@ -65,9 +66,7 @@ public:
|
||||
|
||||
AxisTitlePositionType titlePosition() const override;
|
||||
int titleFontSize() const override;
|
||||
void setTitleFontSize( int fontSize ) override;
|
||||
int valuesFontSize() const override;
|
||||
void setValuesFontSize( int fontSize ) override;
|
||||
TimeModeType timeMode() const;
|
||||
void setTimeMode( TimeModeType val );
|
||||
double fromTimeTToDisplayUnitScale();
|
||||
@@ -113,10 +112,11 @@ protected:
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
double fromDateToDisplayTime( const QDateTime& displayTime );
|
||||
QDateTime fromDisplayTimeToDate( double displayTime );
|
||||
void updateTimeVisibleRange();
|
||||
void updateDateVisibleRange();
|
||||
double fromDateToDisplayTime( const QDateTime& displayTime );
|
||||
QDateTime fromDisplayTimeToDate( double displayTime );
|
||||
void updateTimeVisibleRange();
|
||||
void updateDateVisibleRange();
|
||||
caf::FontTools::FontSize plotFontSize() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<caf::AppEnum<TimeModeType>> m_timeMode;
|
||||
@@ -132,9 +132,10 @@ private:
|
||||
caf::PdmField<double> m_visibleTimeSinceStartRangeMax;
|
||||
caf::PdmField<bool> m_isAutoZoom;
|
||||
|
||||
caf::PdmField<int> m_titleFontSize;
|
||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_titleFontSize;
|
||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_valuesFontSize;
|
||||
|
||||
caf::PdmField<caf::AppEnum<AxisTitlePositionType>> m_titlePositionEnum;
|
||||
caf::PdmField<int> m_valuesFontSize;
|
||||
caf::PdmField<bool> m_automaticDateComponents;
|
||||
caf::PdmField<DateFormatEnum> m_dateComponents;
|
||||
caf::PdmField<TimeFormatEnum> m_timeComponents;
|
||||
|
||||
Reference in New Issue
Block a user