First round of caf::FontTools

This commit is contained in:
Gaute Lindkvist 2020-05-09 11:23:58 +02:00
parent 0e70cf809c
commit 2fe4372dc2
86 changed files with 1021 additions and 966 deletions

View File

@ -1456,6 +1456,19 @@ cvf::Font* RiaApplication::defaultSceneFont()
return m_defaultSceneFont.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Font* RiaApplication::sceneFont( int fontSize )
{
if (fontSize != caf::FontTools::absolutePointSize(m_preferences->defaultSceneFontSize()))
{
auto font = RiaFontCache::getFont(fontSize);
return font.p();
}
return defaultSceneFont();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -188,6 +188,7 @@ public:
static std::vector<QString> readFileListFromTextFile( QString listFileName );
cvf::Font* defaultSceneFont();
cvf::Font* sceneFont(int fontSize);
cvf::Font* defaultAnnotationFont();
cvf::Font* defaultWellLabelFont();

View File

@ -20,71 +20,70 @@
#include "RiaGuiApplication.h"
#include "cafAppEnum.h"
#include "cafFixedAtlasFont.h"
#include <QDesktopWidget>
#include <cmath>
namespace caf
{
template <>
void RiaFontCache::FontSizeType::setUp()
{
addItem( RiaFontCache::FONT_SIZE_8, "8", "8" );
addItem( RiaFontCache::FONT_SIZE_10, "10", "10" );
addItem( RiaFontCache::FONT_SIZE_12, "12", "12" );
addItem( RiaFontCache::FONT_SIZE_14, "14", "14" );
addItem( RiaFontCache::FONT_SIZE_16, "16", "16" );
addItem( RiaFontCache::FONT_SIZE_24, "24", "24" );
addItem( RiaFontCache::FONT_SIZE_32, "32", "32" );
setDefault( RiaFontCache::FONT_SIZE_8 );
}
} // namespace caf
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::FixedAtlasFont::FontSize mapToAtlasFontSize( RiaFontCache::FontSize fontSize )
caf::FixedAtlasFont::FontSize mapToAtlasFontSize( int pointSize )
{
switch ( fontSize )
{
case RiaFontCache::FONT_SIZE_8:
return caf::FixedAtlasFont::POINT_SIZE_8;
case RiaFontCache::FONT_SIZE_10:
return caf::FixedAtlasFont::POINT_SIZE_10;
case RiaFontCache::FONT_SIZE_12:
return caf::FixedAtlasFont::POINT_SIZE_12;
case RiaFontCache::FONT_SIZE_14:
return caf::FixedAtlasFont::POINT_SIZE_14;
case RiaFontCache::FONT_SIZE_16:
return caf::FixedAtlasFont::POINT_SIZE_16;
case RiaFontCache::FONT_SIZE_24:
return caf::FixedAtlasFont::POINT_SIZE_24;
case RiaFontCache::FONT_SIZE_32:
return caf::FixedAtlasFont::POINT_SIZE_32;
default:
return caf::FixedAtlasFont::POINT_SIZE_16;
}
if ( pointSize < 10 )
return caf::FixedAtlasFont::POINT_SIZE_8;
else if ( pointSize >= 10 && pointSize < 12 )
return caf::FixedAtlasFont::POINT_SIZE_10;
else if ( pointSize >= 12 && pointSize < 14 )
return caf::FixedAtlasFont::POINT_SIZE_12;
else if ( pointSize >= 14 && pointSize < 16 )
return caf::FixedAtlasFont::POINT_SIZE_14;
else if ( pointSize >= 16 && pointSize < 20 )
return caf::FixedAtlasFont::POINT_SIZE_16;
else if ( pointSize >= 20 && pointSize < 28 )
return caf::FixedAtlasFont::POINT_SIZE_24;
return caf::FixedAtlasFont::POINT_SIZE_32;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<RiaFontCache::FontSize, cvf::ref<caf::FixedAtlasFont>> RiaFontCache::ms_fonts;
std::map<caf::FixedAtlasFont::FontSize, cvf::ref<caf::FixedAtlasFont>> RiaFontCache::ms_fonts;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<caf::FixedAtlasFont> RiaFontCache::getFont( FontSize size )
cvf::ref<caf::FixedAtlasFont> RiaFontCache::getFont( FontSize pointFontSize )
{
if ( ms_fonts.count( size ) == 0 )
int pointSize = caf::FontTools::absolutePointSize( pointFontSize );
return getFont( pointSize );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<caf::FixedAtlasFont> RiaFontCache::getFont( int pointSize )
{
int currentDPI = 96;
if ( RiaGuiApplication::isRunning() )
{
auto newFont = new caf::FixedAtlasFont( mapToAtlasFontSize( size ) );
ms_fonts.insert( std::make_pair( size, newFont ) );
currentDPI = RiaGuiApplication::desktop()->logicalDpiX();
}
return ms_fonts[size];
// the Fixed Atlas Fonts appear to be assuming a DPI of 96, so we need scaling.
double scaling = currentDPI / 96.0;
int scaledSize = scaling * pointSize;
auto atlasFontSize = mapToAtlasFontSize( scaledSize );
auto existing_it = ms_fonts.find( atlasFontSize );
if ( existing_it == ms_fonts.end() )
{
auto newFont = new caf::FixedAtlasFont( atlasFontSize );
bool inserted = false;
std::tie( existing_it, inserted ) = ms_fonts.insert( std::make_pair( atlasFontSize, newFont ) );
CAF_ASSERT( inserted );
}
return existing_it->second;
}
//--------------------------------------------------------------------------------------------------
@ -96,76 +95,24 @@ RiaFontCache::FontSize RiaFontCache::legacyEnumToPointSize( int enumValue )
switch ( enumValue )
{
case 0:
return FONT_SIZE_8;
return FontSize::FONT_SIZE_8;
case 1:
return FONT_SIZE_10;
return FontSize::FONT_SIZE_10;
case 2:
return FONT_SIZE_12;
return FontSize::FONT_SIZE_12;
case 3:
return FONT_SIZE_14;
return FontSize::FONT_SIZE_14;
case 4:
return FONT_SIZE_16;
return FontSize::FONT_SIZE_16;
case 5:
return FONT_SIZE_24;
return FontSize::FONT_SIZE_24;
case 6:
return FONT_SIZE_32;
return FontSize::FONT_SIZE_32;
default:
return FONT_SIZE_8;
return FontSize::FONT_SIZE_8;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaFontCache::FontSize RiaFontCache::fontSizeEnumFromPointSize( int pointSize )
{
std::vector<FontSize> allValues =
{FONT_SIZE_8, FONT_SIZE_10, FONT_SIZE_12, FONT_SIZE_14, FONT_SIZE_16, FONT_SIZE_24, FONT_SIZE_32};
FontSize closestEnumValue = FONT_SIZE_8;
int closestDiff = std::numeric_limits<int>::max();
for ( FontSize enumValue : allValues )
{
int diff = std::abs( (int)enumValue - pointSize );
if ( diff < closestDiff )
{
closestEnumValue = enumValue;
closestDiff = diff;
}
}
return closestEnumValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaFontCache::pointSizeToPixelSize( int pointSize )
{
auto app = RiaGuiApplication::instance();
if ( app )
{
int dpi = app->desktop()->logicalDpiX();
double inches = pointSize / 72.0;
return static_cast<int>( std::ceil( inches * dpi ) );
}
return pointSize;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaFontCache::pixelSizeToPointSize( int pixelSize )
{
auto app = RiaGuiApplication::instance();
if ( app )
{
int dpi = app->desktop()->logicalDpiX();
double inches = pixelSize / dpi;
return static_cast<int>( std::ceil( inches * 72.0 ) );
}
return pixelSize;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -19,6 +19,7 @@
#pragma once
#include "cafFixedAtlasFont.h"
#include "cafFontTools.h"
#include "cvfObject.h"
@ -38,30 +39,14 @@ class RimSummaryCaseCollection;
class RiaFontCache
{
public:
enum FontSize
{
INVALID = -1,
MIN_FONT_SIZE = 8,
FONT_SIZE_8 = 8,
FONT_SIZE_10 = 10,
FONT_SIZE_12 = 12,
FONT_SIZE_14 = 14,
FONT_SIZE_16 = 16,
FONT_SIZE_24 = 24,
FONT_SIZE_32 = 32,
MAX_FONT_SIZE = FONT_SIZE_32
};
using FontSize = caf::FontTools::FontSize;
using FontSizeEnum = caf::FontTools::FontSizeEnum;
typedef caf::AppEnum<FontSize> FontSizeType;
static cvf::ref<caf::FixedAtlasFont> getFont( FontSize fontSize );
static cvf::ref<caf::FixedAtlasFont> getFont(FontSize fontSize);
static cvf::ref<caf::FixedAtlasFont> getFont( int pointSize );
static FontSize legacyEnumToPointSize( int enumValue );
static FontSize fontSizeEnumFromPointSize( int pointSize );
static int pointSizeToPixelSize( int pointSize );
static int pixelSizeToPointSize( int pixelSize );
static void clear();
static void clear();
private:
static std::map<FontSize, cvf::ref<caf::FixedAtlasFont>> ms_fonts;
static std::map<caf::FixedAtlasFont::FontSize, cvf::ref<caf::FixedAtlasFont>> ms_fonts;
};

View File

@ -1393,7 +1393,8 @@ void RiaGuiApplication::onProgramExit()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaGuiApplication::applyGuiPreferences( const RiaPreferences* oldPreferences )
void RiaGuiApplication::applyGuiPreferences( const RiaPreferences* oldPreferences,
const std::vector<caf::FontHolderInterface*>& defaultFontObjects )
{
if ( m_activeReservoirView && m_activeReservoirView->viewer() )
{
@ -1418,7 +1419,10 @@ void RiaGuiApplication::applyGuiPreferences( const RiaPreferences* oldPreference
m_preferences->appendClassNameToUiText() );
}
std::map<RiaDefines::FontSettingType, RiaFontCache::FontSize> fontSizes = m_preferences->defaultFontSizes();
for ( auto fontObject : defaultFontObjects )
{
fontObject->updateFonts();
}
if ( this->project() )
{
@ -1457,13 +1461,6 @@ void RiaGuiApplication::applyGuiPreferences( const RiaPreferences* oldPreference
existingViewsWithCustomZScale = true;
}
RimGridView* gridView = dynamic_cast<RimGridView*>( rim3dView );
if ( gridView && gridView->annotationCollection() )
{
RiaFontCache::FontSize oldFontSize = oldPreferences->defaultAnnotationFontSize();
existingObjectsWithCustomFonts =
gridView->annotationCollection()->hasTextAnnotationsWithCustomFontSize( oldFontSize );
}
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( rim3dView );
if ( eclipseView )
{
@ -1475,18 +1472,6 @@ void RiaGuiApplication::applyGuiPreferences( const RiaPreferences* oldPreference
}
}
}
for ( auto fontTypeSizePair : fontSizes )
{
RiaFontCache::FontSize oldFontSize = oldPreferences->defaultFontSizes()[fontTypeSizePair.first];
if ( oldFontSize != fontTypeSizePair.second )
{
if ( viewWindow->hasCustomFontSizes( fontTypeSizePair.first, oldFontSize ) )
{
existingObjectsWithCustomFonts = true;
}
}
}
}
if ( oldPreferences->defaultWellLabelColor() != wellPathCollection->wellPathLabelColor() )
@ -1525,16 +1510,6 @@ void RiaGuiApplication::applyGuiPreferences( const RiaPreferences* oldPreference
for ( auto viewWindow : allViewWindows )
{
for ( auto fontTypeSizePair : fontSizes )
{
RiaFontCache::FontSize oldFontSize = oldPreferences->defaultFontSizes()[fontTypeSizePair.first];
int newFontSize = fontTypeSizePair.second;
if ( oldFontSize != newFontSize )
{
viewWindow->applyFontSize( fontTypeSizePair.first, oldFontSize, newFontSize, applySettingsToAllViews );
}
}
auto rim3dView = dynamic_cast<Rim3dView*>( viewWindow );
if ( rim3dView )
{

View File

@ -66,6 +66,11 @@ class RiuPlotMainWindow;
class RiuRecentFileActionProvider;
class RiaArgumentParser;
namespace caf
{
class FontHolderInterface;
}
//==================================================================================================
//
//
@ -123,7 +128,8 @@ public:
std::vector<QAction*> recentFileActions() const;
static void clearAllSelections();
void applyGuiPreferences( const RiaPreferences* oldPreferences = nullptr );
void applyGuiPreferences( const RiaPreferences* oldPreferences = nullptr,
const std::vector<caf::FontHolderInterface*>& defaultFontObjects = {} );
void updateGrpcServer();
static int applicationResolution();

View File

@ -179,12 +179,10 @@ RiaPreferences::RiaPreferences( void )
CAF_PDM_InitField( &m_defaultScaleFactorZ, "defaultScaleFactorZ", 5, "Default Z Scale Factor", "", "", "" );
caf::AppEnum<RiaFontCache::FontSize> fontSize = RiaFontCache::FONT_SIZE_8;
caf::AppEnum<RiaFontCache::FontSize> plotFontSize = RiaFontCache::FONT_SIZE_10;
CAF_PDM_InitField( &defaultSceneFontSize, "defaultSceneFontSizePt", fontSize, "Viewer Font Size", "", "", "" );
CAF_PDM_InitField( &defaultAnnotationFontSize, "defaultAnnotationFontSizePt", fontSize, "Annotation Font Size", "", "", "" );
CAF_PDM_InitField( &defaultWellLabelFontSize, "defaultWellLabelFontSizePt", fontSize, "Well Label Font Size", "", "", "" );
CAF_PDM_InitField( &defaultPlotFontSize, "defaultPlotFontSizePt", plotFontSize, "Plot Font Size", "", "", "" );
CAF_PDM_InitFieldNoDefault( &defaultSceneFontSize, "defaultSceneFontSizePt", "Viewer Font Size", "", "", "" );
CAF_PDM_InitFieldNoDefault( &defaultAnnotationFontSize, "defaultAnnotationFontSizePt", "Annotation Font Size", "", "", "" );
CAF_PDM_InitFieldNoDefault( &defaultWellLabelFontSize, "defaultWellLabelFontSizePt", "Well Label Font Size", "", "", "" );
CAF_PDM_InitFieldNoDefault( &defaultPlotFontSize, "defaultPlotFontSizePt", "Plot Font Size", "", "", "" );
CAF_PDM_InitField( &showLasCurveWithoutTvdWarning,
"showLasCurveWithoutTvdWarning",
@ -369,31 +367,6 @@ RiaPreferences::RiaPreferences( void )
CAF_PDM_InitField( &m_pageRightMargin, "pageRightMargin", defaultMarginSize( m_pageSize() ), "Right Margin", "", "", "" );
CAF_PDM_InitField( &m_pageBottomMargin, "pageBottomMargin", defaultMarginSize( m_pageSize() ), "Bottom Margin", "", "", "" );
caf::AppEnum<RiaFontCache::FontSize> invalidFontSize = RiaFontCache::INVALID;
CAF_PDM_InitField( &m_defaultSceneFontSize_OBSOLETE, "fontSizeInScene", invalidFontSize, "Viewer Font Size", "", "", "" );
m_defaultSceneFontSize_OBSOLETE.xmlCapability()->setIOWritable( false );
CAF_PDM_InitField( &m_defaultAnnotationFontSize_OBSOLETE,
"defaultAnnotationFontSize",
invalidFontSize,
"Annotation Font Size",
"",
"",
"" );
m_defaultAnnotationFontSize_OBSOLETE.xmlCapability()->setIOWritable( false );
CAF_PDM_InitField( &m_defaultWellLabelFontSize_OBSOLETE,
"wellLabelFontSize",
invalidFontSize,
"Well Label Font Size",
"",
"",
"" );
m_defaultWellLabelFontSize_OBSOLETE.xmlCapability()->setIOWritable( false );
CAF_PDM_InitField( &m_defaultPlotFontSize_OBSOLETE, "defaultPlotFontSize", invalidFontSize, "Plot Font Size", "", "", "" );
m_defaultPlotFontSize_OBSOLETE.xmlCapability()->setIOWritable( false );
CAF_PDM_InitField( &m_openExportedPdfInViewer, "openExportedPdfInViewer", false, "Open Exported PDF in Viewer", "", "", "" );
m_openExportedPdfInViewer.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
}
@ -668,27 +641,6 @@ QList<caf::PdmOptionItemInfo> RiaPreferences::calculateValueOptions( const caf::
//--------------------------------------------------------------------------------------------------
void RiaPreferences::initAfterRead()
{
// If the stored font size is smaller than the minimum enum value, the stored font size is actually just an enum value
int defaultSceneFontEnumValue = static_cast<int>( m_defaultSceneFontSize_OBSOLETE.v() );
if ( defaultSceneFontEnumValue >= (int)RiaFontCache::MIN_FONT_SIZE )
{
defaultSceneFontSize = RiaFontCache::legacyEnumToPointSize( defaultSceneFontEnumValue );
}
int defaultWellLabelFontEnumValue = static_cast<int>( m_defaultWellLabelFontSize_OBSOLETE.v() );
if ( defaultWellLabelFontEnumValue >= (int)RiaFontCache::MIN_FONT_SIZE )
{
defaultWellLabelFontSize = RiaFontCache::legacyEnumToPointSize( defaultWellLabelFontEnumValue );
}
int defaultAnnotationFontEnumValue = static_cast<int>( m_defaultAnnotationFontSize_OBSOLETE.v() );
if ( defaultAnnotationFontEnumValue >= (int)RiaFontCache::MIN_FONT_SIZE )
{
defaultAnnotationFontSize = RiaFontCache::legacyEnumToPointSize( defaultAnnotationFontEnumValue );
}
int defaultPlotFontEnumValue = static_cast<int>( m_defaultPlotFontSize_OBSOLETE.v() );
if ( defaultPlotFontEnumValue >= (int)RiaFontCache::MIN_FONT_SIZE )
{
defaultPlotFontSize = RiaFontCache::legacyEnumToPointSize( defaultPlotFontEnumValue );
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -56,7 +56,7 @@ public:
SEPARATE_CASES
};
typedef caf::AppEnum<SummaryRestartFilesImportMode> SummaryRestartFilesImportModeType;
typedef RiaFontCache::FontSizeType FontSizeType;
typedef RiaFontCache::FontSizeEnum FontSizeEnum;
enum class SummaryHistoryCurveStyleMode
{
@ -139,10 +139,10 @@ public: // Pdm Fields
caf::PdmField<cvf::Color3f> defaultWellLabelColor;
caf::PdmField<bool> showLasCurveWithoutTvdWarning;
caf::PdmField<FontSizeType> defaultSceneFontSize;
caf::PdmField<FontSizeType> defaultWellLabelFontSize;
caf::PdmField<FontSizeType> defaultAnnotationFontSize;
caf::PdmField<FontSizeType> defaultPlotFontSize;
caf::PdmField<FontSizeEnum> defaultSceneFontSize;
caf::PdmField<FontSizeEnum> defaultWellLabelFontSize;
caf::PdmField<FontSizeEnum> defaultAnnotationFontSize;
caf::PdmField<FontSizeEnum> defaultPlotFontSize;
caf::PdmField<QString> lastUsedProjectFileName;
@ -220,9 +220,4 @@ private:
caf::PdmField<bool> m_enableFaultsByDefault;
QStringList m_tabNames;
caf::PdmField<FontSizeType> m_defaultSceneFontSize_OBSOLETE;
caf::PdmField<FontSizeType> m_defaultWellLabelFontSize_OBSOLETE;
caf::PdmField<FontSizeType> m_defaultAnnotationFontSize_OBSOLETE;
caf::PdmField<FontSizeType> m_defaultPlotFontSize_OBSOLETE;
};

View File

@ -407,7 +407,7 @@ if (MSVC)
# If possible, the following command is supposed to be the final target
# set_target_properties(ResInsight PROPERTIES COMPILE_FLAGS "/W3 /wd4190 /wd4100 /wd4127")
set_target_properties(ResInsight PROPERTIES COMPILE_FLAGS "/W3 /wd4190 /wd4100 /wd4127 /wd4245 /wd4005")
set_target_properties(ResInsight PROPERTIES COMPILE_FLAGS "/wd4190 /wd4100 /wd4127 /wd4245 /wd4005")
if (CMAKE_CXX_COMPILER_VERSION LESS_EQUAL 19.14)
# The following warning is generated over 800 times from a qwt header only using VS2015
# Disabling temporarily

View File

@ -20,6 +20,7 @@
#include "RiaGuiApplication.h"
#include "RiaPreferences.h"
#include "RimProject.h"
#include "RiuPropertyViewTabWidget.h"
@ -38,6 +39,20 @@ bool RicEditPreferencesFeature::isCommandEnabled()
return true;
}
std::vector<caf::FontHolderInterface*> findFontObjects()
{
auto project = RimProject::current();
std::vector<caf::FontHolderInterface*> allFontObjects;
project->descendantsIncludingThisOfType( allFontObjects );
std::vector<caf::FontHolderInterface*> defaultFontObjects;
for ( auto fontObject : allFontObjects )
{
defaultFontObjects.push_back( fontObject );
}
return defaultFontObjects;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -49,6 +64,8 @@ void RicEditPreferencesFeature::onActionTriggered( bool isChecked )
QStringList tabNames = app->preferences()->tabNames();
auto defaultFontObjects = findFontObjects();
std::unique_ptr<RiaPreferences> oldPreferences = clonePreferences( app->preferences() );
RiuPropertyViewTabWidget propertyDialog( nullptr, app->preferences(), "Preferences", tabNames );
@ -57,7 +74,7 @@ void RicEditPreferencesFeature::onActionTriggered( bool isChecked )
{
// Write preferences using QSettings and apply them to the application
app->applyPreferences();
app->applyGuiPreferences( oldPreferences.get() );
app->applyGuiPreferences( oldPreferences.get(), defaultFontObjects );
app->updateGrpcServer();
}
else

View File

@ -21,6 +21,8 @@
#include "ExportCommands/RicSnapshotViewToClipboardFeature.h"
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
#include "RiaPreferences.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimEclipseView.h"
@ -68,6 +70,7 @@ RicGridStatisticsDialog::RicGridStatisticsDialog( QWidget* parent )
// Set widget properties
m_textEdit->setReadOnly( true );
RiuQwtPlotTools::setCommonPlotBehaviour( m_historgramPlot );
RiuQwtPlotTools::setCommonPlotBehaviour( m_aggregatedPlot );

View File

@ -32,6 +32,7 @@ class QStringList;
class RifHdf5ReaderInterface
{
public:
virtual ~RifHdf5ReaderInterface() = 0;
virtual std::vector<QDateTime> timeSteps() const = 0;
virtual QStringList propertyNames() const = 0;
virtual bool dynamicResult( const QString& result, size_t stepIndex, std::vector<double>* values ) const = 0;

View File

@ -20,7 +20,9 @@
#include "RivGridBoxGenerator.h"
#include "RiaColorTools.h"
#include "RiaFontCache.h"
#include "RiaGuiApplication.h"
#include "RiaPreferences.h"
#include "RivPartPriority.h"
#include "RivPatchGenerator.h"
@ -49,6 +51,8 @@ RivGridBoxGenerator::RivGridBoxGenerator()
m_scaleZ = 1.0;
m_displayModelOffset = cvf::Vec3d::ZERO;
m_fontPointSize = caf::FontTools::absolutePointSize(RiaPreferences::current()->defaultSceneFontSize());
}
//--------------------------------------------------------------------------------------------------
@ -212,6 +216,18 @@ void RivGridBoxGenerator::createGridBoxParts()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::setGridLabelFontSize( int fontSize )
{
if (m_fontPointSize != fontSize)
{
m_fontPointSize = fontSize;
m_needsRegeneration = true;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -653,9 +669,12 @@ void RivGridBoxGenerator::createLegend( EdgeType edge, cvf::Collection<cvf::Part
cvf::ref<cvf::DrawableText> geo = new cvf::DrawableText;
cvf::Font* standardFont = RiaGuiApplication::instance()->defaultSceneFont();
geo->setFont( standardFont );
cvf::ref<cvf::Font> font = RiaGuiApplication::instance()->defaultSceneFont();
if (caf::FontTools::absolutePointSize(RiaPreferences::current()->defaultSceneFontSize()) != m_fontPointSize)
{
font = RiaFontCache::getFont(m_fontPointSize);
}
geo->setFont( font.p() );
geo->setTextColor( m_gridLegendColor );
geo->setCheckPosVisible( false );
geo->setDrawBackground( false );

View File

@ -19,6 +19,8 @@
#pragma once
#include "RiaFontCache.h"
#include "cvfCollection.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
@ -46,7 +48,7 @@ public:
void updateFromBackgroundColor( const cvf::Color3f& backgroundColor );
void createGridBoxParts();
void setGridLabelFontSize(int fontSize);
void updateFromCamera( const cvf::Camera* camera );
cvf::Model* model();
@ -122,6 +124,7 @@ private:
cvf::Color3f m_gridColor;
cvf::Color3f m_gridLegendColor;
int m_fontPointSize;
bool m_needsRegeneration;
};

View File

@ -179,7 +179,7 @@ void RivContourMapProjectionPartMgr::appendContourLinesToModel( const cvf::Camer
cvf::ref<cvf::DrawableText> RivContourMapProjectionPartMgr::createTextLabel( const cvf::Color3f& textColor,
const cvf::Color3f& backgroundColor )
{
auto font = RiaFontCache::getFont( RiaFontCache::FONT_SIZE_10 );
auto font = RiaFontCache::getFont( RiaFontCache::FontSize::FONT_SIZE_10 );
cvf::ref<cvf::DrawableText> labelDrawable = new cvf::DrawableText();
labelDrawable->setFont( font.p() );

View File

@ -449,7 +449,7 @@ void RimAnalysisPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
{
caf::PdmUiGroup* selVectorsGrp = uiOrdering.addNewGroup( "Selected Vectors" );
selVectorsGrp->add( &m_selectedVarsUiField );
selVectorsGrp->add( &m_selectVariablesButtonField, {false} );
selVectorsGrp->add( &m_selectVariablesButtonField, { false } );
QString vectorNames;
if ( m_analyserOfSelectedCurveDefs )
@ -471,14 +471,14 @@ void RimAnalysisPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
timeStepGrp->add( &m_addTimestepUiField );
timeStepGrp->add( &m_selectedTimeSteps );
uiOrdering.add( &m_referenceCase, {true, 3, 2} );
uiOrdering.add( &m_referenceCase, { true, 3, 2 } );
uiOrdering.add( &m_showPlotTitle );
uiOrdering.add( &m_useAutoPlotTitle, {false} );
uiOrdering.add( &m_description, {false} );
uiOrdering.add( &m_useAutoPlotTitle, { false } );
uiOrdering.add( &m_description, { false } );
m_description.uiCapability()->setUiReadOnly( m_useAutoPlotTitle() );
uiOrdering.add( &m_barOrientation, {true, 3, 2} );
uiOrdering.add( &m_barOrientation, { true, 3, 2 } );
caf::PdmUiGroup* sortGrp = uiOrdering.addNewGroup( "Sorting and Grouping" );
sortGrp->add( &m_majorGroupType );
@ -486,7 +486,7 @@ void RimAnalysisPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
sortGrp->add( &m_minorGroupType );
sortGrp->add( &m_valueSortOperation );
sortGrp->add( &m_useTopBarsFilter );
sortGrp->add( &m_maxBarCount, {false} );
sortGrp->add( &m_maxBarCount, { false } );
m_maxBarCount.uiCapability()->setUiReadOnly( !m_useTopBarsFilter() );
caf::PdmUiGroup* legendGrp = uiOrdering.addNewGroup( "Legend" );
@ -499,10 +499,10 @@ void RimAnalysisPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
caf::PdmUiGroup* barLabelGrp = uiOrdering.addNewGroup( "Bar Labels" );
barLabelGrp->add( &m_useBarText );
barLabelGrp->add( &m_useQuantityInBarText );
barLabelGrp->add( &m_useSummaryItemInBarText, {false} );
barLabelGrp->add( &m_useSummaryItemInBarText, { false } );
barLabelGrp->add( &m_useCaseInBarText );
barLabelGrp->add( &m_useEnsembleInBarText, {false} );
barLabelGrp->add( &m_useTimeStepInBarText, {true, 4, 1} );
barLabelGrp->add( &m_useEnsembleInBarText, { false } );
barLabelGrp->add( &m_useTimeStepInBarText, { true, 4, 1 } );
m_useQuantityInBarText.uiCapability()->setUiReadOnly( !m_useBarText );
m_useSummaryItemInBarText.uiCapability()->setUiReadOnly( !m_useBarText );
@ -556,16 +556,16 @@ QList<caf::PdmOptionItemInfo> RimAnalysisPlot::calculateValueOptions( const caf:
if ( fieldNeedingOptions == &m_addTimestepUiField )
{
options.push_back( {"None", QDateTime()} );
options.push_back( { "None", QDateTime() } );
std::set<time_t> timeStepUnion = allAvailableTimeSteps();
for ( time_t timeT : timeStepUnion )
{
QDateTime dateTime = RiaQDateTimeTools::fromTime_t( timeT );
QString formatString = RiaQDateTimeTools::createTimeFormatStringFromDates( {dateTime} );
QString formatString = RiaQDateTimeTools::createTimeFormatStringFromDates( { dateTime } );
options.push_back( {dateTime.toString( formatString ), dateTime} );
options.push_back( { dateTime.toString( formatString ), dateTime } );
}
}
else if ( fieldNeedingOptions == &m_valueSortOperation )
@ -588,7 +588,7 @@ QList<caf::PdmOptionItemInfo> RimAnalysisPlot::calculateValueOptions( const caf:
{
std::vector<RimSummaryCase*> allSummaryCases = RimProject::current()->allSummaryCases();
options.push_back( {"None", nullptr} );
options.push_back( { "None", nullptr } );
for ( auto sumCase : allSummaryCases )
{
@ -599,7 +599,7 @@ QList<caf::PdmOptionItemInfo> RimAnalysisPlot::calculateValueOptions( const caf:
displayName = caseColl->name() + "/" + displayName;
}
options.push_back( {displayName, sumCase} );
options.push_back( { displayName, sumCase } );
}
}
@ -696,7 +696,7 @@ void RimAnalysisPlot::onLoadDataAndUpdate()
m_plotWidget->insertLegend( nullptr );
}
m_plotWidget->setLegendFontSize( m_legendFontSize() );
m_plotWidget->setLegendFontSize( legendFontSize() );
m_plotWidget->updateLegend();
}
@ -720,43 +720,6 @@ QImage RimAnalysisPlot::snapshotWindowContent()
return image;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimAnalysisPlot::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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1071,7 +1034,7 @@ void RimAnalysisPlot::applyFilter( const RimPlotDataFilterItem* filter,
if ( filter->useAbsoluteValues() ) value = fabs( value );
bool useLargest = filter->filterOperation() == RimPlotDataFilterItem::TOP_N;
auto itIsInsertedPair = casesToKeepWithValue.insert( {sumCase, value} );
auto itIsInsertedPair = casesToKeepWithValue.insert( { sumCase, value } );
if ( !itIsInsertedPair.second ) // Already exists in map
{
double& insertedValue = itIsInsertedPair.first->second;
@ -1165,7 +1128,7 @@ void RimAnalysisPlot::applyFilter( const RimPlotDataFilterItem* filter,
if ( historyTimesteps.size() )
{
selectedTimestepIndices =
RimAnalysisPlot::findTimestepIndices( {historyTimesteps.back()}, timesteps );
RimAnalysisPlot::findTimestepIndices( { historyTimesteps.back() }, timesteps );
}
}
else if ( filter->consideredTimeStepsType() == RimPlotDataFilterItem::SELECT_TIMESTEP_RANGE )
@ -1223,7 +1186,7 @@ void RimAnalysisPlot::applyFilter( const RimPlotDataFilterItem* filter,
if ( filter->useAbsoluteValues() ) value = fabs( value );
bool useLargest = filter->filterOperation() == RimPlotDataFilterItem::TOP_N;
auto itIsInsertedPair = casesToKeepWithValue.insert( {sumCaseInEvaluation, value} );
auto itIsInsertedPair = casesToKeepWithValue.insert( { sumCaseInEvaluation, value } );
if ( !itIsInsertedPair.second ) // Already exists in map
{
double& insertedValue = itIsInsertedPair.first->second;
@ -1277,7 +1240,7 @@ void RimAnalysisPlot::applyFilter( const RimPlotDataFilterItem* filter,
if ( filter->useAbsoluteValues() ) value = fabs( value );
bool useLargest = filter->filterOperation() == RimPlotDataFilterItem::TOP_N;
auto itIsInsertedPair = sumItemsToKeepWithValue.insert( {sumItem, value} );
auto itIsInsertedPair = sumItemsToKeepWithValue.insert( { sumItem, value } );
if ( !itIsInsertedPair.second ) // Already exists in map
{
double& insertedValue = itIsInsertedPair.first->second;
@ -1305,7 +1268,7 @@ void RimAnalysisPlot::applyFilter( const RimPlotDataFilterItem* filter,
std::multimap<double, RifEclipseSummaryAddress> valueSortedSumItems;
for ( const auto& itemValPair : sumItemsToKeepWithValue )
{
valueSortedSumItems.insert( {itemValPair.second, itemValPair.first} );
valueSortedSumItems.insert( { itemValPair.second, itemValPair.first } );
}
if ( filter->filterOperation() == RimPlotDataFilterItem::TOP_N )
@ -1336,7 +1299,7 @@ void RimAnalysisPlot::applyFilter( const RimPlotDataFilterItem* filter,
std::multimap<double, RimSummaryCase*> valueSortedSumCases;
for ( const auto& caseValPair : casesToKeepWithValue )
{
valueSortedSumCases.insert( {caseValPair.second, caseValPair.first} );
valueSortedSumCases.insert( { caseValPair.second, caseValPair.first } );
}
if ( filter->filterOperation() == RimPlotDataFilterItem::TOP_N )
@ -1448,7 +1411,7 @@ void RimAnalysisPlot::addDataToChartBuilder( RiuGroupedBarChartBuilder& chartBui
double sortValue = std::numeric_limits<double>::infinity();
QDateTime dateTime = RiaQDateTimeTools::fromTime_t( timesteps[timestepIdx] );
QString formatString = RiaQDateTimeTools::createTimeFormatStringFromDates( {dateTime} );
QString formatString = RiaQDateTimeTools::createTimeFormatStringFromDates( { dateTime } );
QString timestepString = dateTime.toString( formatString );
@ -1554,7 +1517,7 @@ void RimAnalysisPlot::updatePlotTitle()
{
if ( !autoTitle.isEmpty() ) autoTitle += " @ ";
QString formatString = RiaQDateTimeTools::createTimeFormatStringFromDates( {m_selectedTimeSteps()[0]} );
QString formatString = RiaQDateTimeTools::createTimeFormatStringFromDates( { m_selectedTimeSteps()[0] } );
autoTitle += m_selectedTimeSteps()[0].toString( formatString );
}
@ -1629,7 +1592,7 @@ std::vector<RiaSummaryCurveDefinition> RimAnalysisPlot::curveDefinitionsWithEmbe
//--------------------------------------------------------------------------------------------------
std::set<RimPlotAxisPropertiesInterface*> RimAnalysisPlot::allPlotAxes() const
{
return {m_valueAxisProperties};
return { m_valueAxisProperties };
}
//--------------------------------------------------------------------------------------------------

View File

@ -115,10 +115,6 @@ private:
void onLoadDataAndUpdate() override;
void zoomAll() override {}
QImage snapshotWindowContent() override;
bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange = false ) override;
// RimPlotWindow overrides

View File

@ -18,6 +18,8 @@
#include "RimAnnotationInViewCollection.h"
#include "RiaPreferences.h"
#include "RimAnnotationCollection.h"
#include "RimAnnotationGroupCollection.h"
#include "RimAnnotationTextAppearance.h"
@ -104,6 +106,8 @@ RimAnnotationInViewCollection::RimAnnotationInViewCollection()
"",
"" );
CAF_PDM_InitFieldNoDefault(&m_annotationFontSize, "AnnotationFontSize", "Default Font Size", "", "", "");
m_globalTextAnnotations.uiCapability()->setUiHidden( true );
m_globalReachCircleAnnotations.uiCapability()->setUiHidden( true );
m_globalUserDefinedPolylineAnnotations.uiCapability()->setUiHidden( true );
@ -244,55 +248,16 @@ void RimAnnotationInViewCollection::onGlobalCollectionChanged( const RimAnnotati
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimAnnotationInViewCollection::hasTextAnnotationsWithCustomFontSize( RiaFontCache::FontSize defaultFontSize ) const
int RimAnnotationInViewCollection::fontSize() const
{
for ( auto annotation : textAnnotations() )
{
if ( annotation->appearance()->fontSize() != defaultFontSize )
{
return true;
}
}
for ( auto annotationInView : globalTextAnnotations() )
{
if ( annotationInView->sourceAnnotation()->appearance()->fontSize() != defaultFontSize )
{
return true;
}
}
return false;
return caf::FontTools::absolutePointSize(RiaPreferences::current()->defaultSceneFontSize(), m_annotationFontSize());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimAnnotationInViewCollection::applyFontSizeToAllTextAnnotations( RiaFontCache::FontSize oldFontSize,
RiaFontCache::FontSize fontSize,
bool forceChange )
void RimAnnotationInViewCollection::updateFonts()
{
bool anyChange = false;
for ( auto annotation : textAnnotations() )
{
if ( forceChange || annotation->appearance()->fontSize() == oldFontSize )
{
annotation->appearance()->setFontSize( fontSize );
annotation->updateConnectedEditors();
anyChange = true;
}
}
for ( auto annotationInView : globalTextAnnotations() )
{
if ( forceChange || annotationInView->sourceAnnotation()->appearance()->fontSize() == oldFontSize )
{
annotationInView->sourceAnnotation()->appearance()->setFontSize( fontSize );
annotationInView->updateConnectedEditors();
anyChange = true;
}
}
return anyChange;
}
//--------------------------------------------------------------------------------------------------
@ -301,6 +266,7 @@ bool RimAnnotationInViewCollection::applyFontSizeToAllTextAnnotations( RiaFontCa
void RimAnnotationInViewCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_snapAnnotations );
uiOrdering.add( &m_annotationFontSize );
if ( m_snapAnnotations() ) uiOrdering.add( &m_annotationPlaneDepth );
uiOrdering.skipRemainingFields( true );

View File

@ -41,7 +41,7 @@ class RimPolylinesFromFileAnnotationInView;
///
///
//==================================================================================================
class RimAnnotationInViewCollection : public RimAnnotationCollectionBase
class RimAnnotationInViewCollection : public RimAnnotationCollectionBase, public caf::FontHolderInterface
{
CAF_PDM_HEADER_INIT;
@ -59,14 +59,10 @@ public:
void onGlobalCollectionChanged( const RimAnnotationCollection* globalCollection );
bool hasTextAnnotationsWithCustomFontSize( RiaFontCache::FontSize defaultFontSize ) const;
bool applyFontSizeToAllTextAnnotations( RiaFontCache::FontSize oldFontSize,
RiaFontCache::FontSize fontSize,
bool forceSizeChange = false );
int fontSize() const override;
void updateFonts();
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
@ -83,6 +79,7 @@ private:
caf::PdmField<double> m_annotationPlaneDepth;
caf::PdmField<bool> m_snapAnnotations;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_annotationFontSize;
caf::PdmChildField<RimAnnotationGroupCollection*> m_globalTextAnnotations;
caf::PdmChildField<RimAnnotationGroupCollection*> m_globalReachCircleAnnotations;
caf::PdmChildField<RimAnnotationGroupCollection*> m_globalUserDefinedPolylineAnnotations;

View File

@ -48,6 +48,9 @@ RimAbstractCorrelationPlot::RimAbstractCorrelationPlot()
CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "" );
CAF_PDM_InitField( &m_useAutoPlotTitle, "AutoTitle", true, "Automatic Plot Title", "", "", "" );
CAF_PDM_InitField( &m_description, "PlotTitle", QString( "Correlation Plot" ), "Custom Plot Title", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_labelFontSize, "LabelFontSize", "Label Font Size", "", "", "" );
m_labelFontSize = caf::FontTools::RelativeSize::XSmall;
}
//--------------------------------------------------------------------------------------------------
@ -311,19 +314,6 @@ QImage RimAbstractCorrelationPlot::snapshotWindowContent()
return image;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimAbstractCorrelationPlot::applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange /*= false */ )
{
bool anyChange = false;
return anyChange;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -72,10 +72,6 @@ protected:
void deleteViewWidget() override;
void zoomAll() override {}
QImage snapshotWindowContent() override;
bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange = false ) override;
// RimPlotWindow overrides
QString description() const override;
@ -118,4 +114,6 @@ protected:
caf::PdmField<bool> m_showPlotTitle;
caf::PdmField<bool> m_useAutoPlotTitle;
caf::PdmField<QString> m_description;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_labelFontSize;
};

View File

@ -304,7 +304,7 @@ void RimCorrelationMatrixPlot::updateAxes()
m_plotWidget->setAxisScaleEngine( QwtPlot::yLeft, new RiuQwtLinearScaleEngine );
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Result Vector" );
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, 11, 7, false, Qt::AlignCenter );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, 10, 6, false, Qt::AlignCenter );
m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft, true, false );
m_plotWidget->setAxisRange( QwtPlot::yLeft, 0.0, (double)m_resultLabels.size() + 1 );
m_plotWidget->setMajorAndMinorTickIntervalsAndRange( QwtPlot::yLeft,
@ -322,7 +322,7 @@ void RimCorrelationMatrixPlot::updateAxes()
m_plotWidget->setAxisScaleEngine( QwtPlot::xBottom, new RiuQwtLinearScaleEngine );
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Ensemble Parameter" );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, 11, 6, false, Qt::AlignCenter | Qt::AlignTop );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, 10, 6, false, Qt::AlignCenter | Qt::AlignTop );
m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::xBottom, true, false );
m_plotWidget->setAxisRange( QwtPlot::xBottom, 0.0, (double)m_paramLabels.size() + 1 );
m_plotWidget->setMajorAndMinorTickIntervalsAndRange( QwtPlot::xBottom,
@ -502,7 +502,7 @@ void RimCorrelationMatrixPlot::createMatrix()
cvf::Color3f contrastColor = RiaColorTools::contrastColor( cvf::Color3f( color ) );
textLabel.setColor( RiaColorTools::toQColor( contrastColor ) );
QFont font = textLabel.font();
font.setPixelSize( RiaFontCache::pointSizeToPixelSize( 7 ) );
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( 7 ) );
textLabel.setFont( font );
QwtPlotMarker* marker = new QwtPlotMarker();
marker->setLabel( textLabel );

View File

@ -117,7 +117,7 @@ void RimCorrelationPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Summary Vector" );
curveDataGroup->add( &m_selectedVarsUiField );
curveDataGroup->add( &m_pushButtonSelectSummaryAddress, { false, 1, 0 } );
curveDataGroup->add( &m_pushButtonSelectSummaryAddress, {false, 1, 0} );
curveDataGroup->add( &m_timeStep );
caf::PdmUiGroup* plotGroup = uiOrdering.addNewGroup( "Plot Settings" );
@ -184,11 +184,11 @@ void RimCorrelationPlot::updateAxes()
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Parameter" );
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, 11, 11, false, Qt::AlignCenter );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, 10, 10, false, Qt::AlignCenter );
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Pearson Correlation Coefficient" );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, 11, 11, false, Qt::AlignCenter );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, 10, 10, false, Qt::AlignCenter );
if ( m_showAbsoluteValues )
{
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Pearson Correlation Coefficient ABS" );

View File

@ -173,12 +173,12 @@ void RimParameterResultCrossPlot::updateAxes()
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, m_selectedVarsUiField );
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
m_plotWidget->setAxisAutoScale( QwtPlot::yLeft, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, 11, 11, false, Qt::AlignCenter );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, 10, 10, false, Qt::AlignCenter );
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, m_ensembleParameter );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true );
m_plotWidget->setAxisAutoScale( QwtPlot::xBottom, true );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, 11, 11, false, Qt::AlignCenter );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, 10, 10, false, Qt::AlignCenter );
}
//--------------------------------------------------------------------------------------------------

View File

@ -18,7 +18,6 @@
#include "RimFlowCharacteristicsPlot.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RifCsvDataTableFormatter.h"
@ -244,6 +243,21 @@ void RimFlowCharacteristicsPlot::setAquiferCellThreshold( double aquiferCellThre
m_maxPvFraction = aquiferCellThreshold;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimFlowCharacteristicsPlot::fontSize() const
{
return caf::FontTools::absolutePointSize(RiaPreferences::current()->defaultPlotFontSize());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFlowCharacteristicsPlot::updateFonts()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -788,7 +802,7 @@ double interpolate( const std::vector<double>& xData, const std::vector<double>&
//--------------------------------------------------------------------------------------------------
QString RimFlowCharacteristicsPlot::curveDataAsText() const
{
QString fieldSeparator = RiaApplication::instance()->preferences()->csvTextExportFieldSeparator;
QString fieldSeparator = RiaPreferences::current()->csvTextExportFieldSeparator;
QString tableText;
QTextStream stream( &tableText );
@ -807,7 +821,7 @@ QString RimFlowCharacteristicsPlot::curveDataAsText() const
std::vector<QDateTime> timeStepDates = m_case->timeStepDates();
std::vector<double> storageCapacitySamplingValues = {0.08, 0.1, 0.2, 0.3, 0.4};
std::vector<double> storageCapacitySamplingValues = { 0.08, 0.1, 0.2, 0.3, 0.4 };
size_t sampleCount = storageCapacitySamplingValues.size();
for ( const auto& timeIndex : m_currentlyPlottedTimeSteps )

View File

@ -82,6 +82,9 @@ public:
void setMinimumCommunication( double minimumCommunication );
void setAquiferCellThreshold( double aquiferCellThreshold );
int fontSize() const override;
void updateFonts() override;
protected:
// RimViewWindow overrides

View File

@ -18,6 +18,8 @@
#include "RimTofAccumulatedPhaseFractionsPlot.h"
#include "RiaPreferences.h"
#include "RimEclipseView.h"
#include "RimSimWellInViewCollection.h"
#include "RimWellAllocationPlot.h"
@ -133,6 +135,21 @@ size_t RimTofAccumulatedPhaseFractionsPlot::timeStep()
return static_cast<size_t>( allocationPlot->timeStep() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimTofAccumulatedPhaseFractionsPlot::fontSize() const
{
return caf::FontTools::absolutePointSize(RiaPreferences::current()->defaultPlotFontSize());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTofAccumulatedPhaseFractionsPlot::updateFonts()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -73,6 +73,8 @@ public:
QString tracerName();
size_t timeStep();
int fontSize() const override;
void updateFonts() override;
protected:
// RimViewWindow overrides
void assignIdIfNecessary() final;

View File

@ -18,6 +18,8 @@
#include "RimTotalWellAllocationPlot.h"
#include "RiaPreferences.h"
#include "RimEclipseView.h"
#include "RimSimWellInViewCollection.h"
@ -86,6 +88,21 @@ void RimTotalWellAllocationPlot::deleteViewWidget()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimTotalWellAllocationPlot::fontSize() const
{
return caf::FontTools::absolutePointSize(RiaPreferences::current()->defaultPlotFontSize());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::updateFonts()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -69,6 +69,9 @@ public:
QWidget* createViewWidget( QWidget* mainWindowParent ) override;
void deleteViewWidget() override;
int fontSize() const override;
void updateFonts() override;
protected:
// RimViewWindow overrides

View File

@ -18,6 +18,8 @@
#include "RimWellAllocationPlot.h"
#include "RiaPreferences.h"
#include "RigAccWellFlowCalculator.h"
#include "RigEclipseCaseData.h"
#include "RigFlowDiagResultAddress.h"
@ -793,6 +795,21 @@ void RimWellAllocationPlot::showPlotLegend( bool doShow )
if ( m_wellAllocationPlotWidget ) m_wellAllocationPlotWidget->showLegend( doShow );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellAllocationPlot::fontSize() const
{
return caf::FontTools::absolutePointSize(RiaPreferences::current()->defaultPlotFontSize());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::updateFonts()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -89,6 +89,9 @@ public:
void showPlotLegend( bool doShow );
int fontSize() const override;
void updateFonts() override;
protected:
// Overridden PDM methods
caf::PdmFieldHandle* userDescriptionField() override { return &m_userName; }

View File

@ -593,6 +593,7 @@ void RimGridCrossPlot::updatePlot()
RiuQwtPlotTools::setCommonPlotBehaviour( m_plotWidget );
RiuQwtPlotTools::setDefaultAxes( m_plotWidget );
updateFonts();
updateAxes();
for ( auto dataSet : m_crossPlotDataSets )
@ -729,65 +730,6 @@ void RimGridCrossPlot::setYAxisInverted( bool inverted )
m_yAxisProperties->setAxisInverted( inverted );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGridCrossPlot::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const
{
if ( fontSettingType != RiaDefines::FontSettingType::PLOT_FONT ) return false;
for ( auto plotAxis : allPlotAxes() )
{
if ( plotAxis->titleFontSize() != defaultFontSize || plotAxis->valuesFontSize() != defaultFontSize )
{
return true;
}
}
if ( legendFontSize() != defaultFontSize )
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGridCrossPlot::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 || legendFontSize() == oldFontSize )
{
setLegendFontSize( fontSize );
anyChange = true;
}
if ( anyChange ) loadDataAndUpdate();
}
return anyChange;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -913,8 +855,8 @@ void RimGridCrossPlot::updateAxisInQwt( RiaDefines::PlotAxis axisType )
alignment = Qt::AlignRight;
}
m_plotWidget->setAxisFontsAndAlignment( qwtAxisId,
axisProperties->titleFontSize(),
axisProperties->valuesFontSize(),
caf::FontTools::pointSizeToPixelSize( axisProperties->titleFontSize() ),
caf::FontTools::pointSizeToPixelSize( axisProperties->valuesFontSize() ),
true,
alignment );
m_plotWidget->setAxisTitleText( qwtAxisId, axisParameterString );

View File

@ -96,12 +96,6 @@ public:
bool isYAxisLogarithmic() const;
void setYAxisInverted( bool inverted );
bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const override;
bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange = false ) override;
void updateLegend() override;
void updateZoomInQwt() override;

View File

@ -150,6 +150,8 @@ Rim3dView::Rim3dView( void )
CAF_PDM_InitFieldNoDefault( &m_comparisonView, "ComparisonView", "Comparison View", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_fontSize, "FontSize", "Font Size", "", "", "" );
m_intersectionVizModel = new cvf::ModelBasicList;
m_intersectionVizModel->setName( "CrossSectionModel" );
@ -385,6 +387,7 @@ void Rim3dView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOr
{
caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroupWithKeyword( "Viewer", "ViewGroup" );
viewGroup->add( &m_fontSize );
viewGroup->add( &m_backgroundColor );
viewGroup->add( &m_showZScaleLabel );
viewGroup->add( &m_showGridBox );
@ -876,8 +879,17 @@ void Rim3dView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const
m_viewer->update();
}
}
else if ( changedField == &m_backgroundColor )
else if ( changedField == &m_backgroundColor || changedField == &m_fontSize )
{
if ( changedField == &m_fontSize )
{
std::vector<caf::FontHolderInterface*> fontHolderChildren;
descendantsOfType( fontHolderChildren );
for ( auto fontHolder : fontHolderChildren )
{
fontHolder->updateFonts();
}
}
this->applyBackgroundColorAndFontChanges();
}
else if ( changedField == &maximumFrameRate )
@ -996,7 +1008,7 @@ void Rim3dView::addMeasurementToModel( cvf::ModelBasicList* measureModel )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
//---------------------------------------------------- ----------------------------------------------
bool Rim3dView::isMasterView() const
{
RimViewLinker* viewLinker = this->assosiatedViewLinker();
@ -1040,7 +1052,11 @@ void Rim3dView::updateGridBoxData()
}
}
viewer()->updateGridBoxData( scaleZ(), ownerCase()->displayModelOffset(), backgroundColor(), combinedDomainBBox );
viewer()->updateGridBoxData( scaleZ(),
ownerCase()->displayModelOffset(),
backgroundColor(),
combinedDomainBBox,
fontSize() );
}
}
@ -1204,11 +1220,28 @@ void Rim3dView::applyBackgroundColorAndFontChanges()
if ( viewer() != nullptr )
{
viewer()->mainCamera()->viewport()->setClearColor( cvf::Color4f( backgroundColor() ) );
viewer()->updateFonts();
viewer()->updateFonts( fontSize() );
}
updateGridBoxData();
updateAnnotationItems();
onUpdateLegends();
this->scheduleCreateDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int Rim3dView::fontSize() const
{
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultSceneFontSize(), m_fontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateFonts()
{
applyBackgroundColorAndFontChanges();
}
//--------------------------------------------------------------------------------------------------
@ -1311,30 +1344,6 @@ cvf::ref<caf::DisplayCoordTransform> Rim3dView::displayCoordTransform() const
return coordTrans;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Rim3dView::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Rim3dView::applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange /*= false*/ )
{
if ( fontSettingType == RiaDefines::FontSettingType::SCENE_FONT )
{
applyBackgroundColorAndFontChanges();
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1365,6 +1374,10 @@ QList<caf::PdmOptionItemInfo> Rim3dView::calculateValueOptions( const caf::PdmFi
}
}
}
else if ( fieldNeedingOptions == &m_fontSize )
{
options = caf::FontTools::relativeSizeValueOptions( RiaPreferences::current()->defaultSceneFontSize() );
}
return options;
}

View File

@ -126,11 +126,9 @@ public:
void setBackgroundColor( const cvf::Color3f& newBackgroundColor );
cvf::Color3f backgroundColor() const override; // Implementation of RiuViewerToViewInterface
void applyBackgroundColorAndFontChanges();
bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const override;
bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange = false ) override;
int fontSize() const;
void updateFonts() override;
void disableLighting( bool disable );
bool isLightingDisabled() const;
@ -303,6 +301,8 @@ private:
caf::PdmField<bool> m_showZScaleLabel;
caf::PdmPtrField<Rim3dView*> m_comparisonView;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_fontSize;
// 3D display model data
cvf::ref<cvf::ModelBasicList> m_highlightVizModel;
cvf::ref<RivAnnotationsPartMgr> m_annotationsPartManager;

View File

@ -20,6 +20,7 @@
#include "RimDepthTrackPlot.h"
#include "RiaGuiApplication.h"
#include "RiaPreferences.h"
#include "RigWellLogCurveData.h"
#include "RigWellPath.h"
@ -104,6 +105,10 @@ RimDepthTrackPlot::RimDepthTrackPlot()
CAF_PDM_InitScriptableFieldWithIO( &m_isAutoScaleDepthEnabled, "AutoScaleDepthEnabled", true, "Auto Scale", "", "", "" );
m_isAutoScaleDepthEnabled.uiCapability()->setUiHidden( true );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_subTitleFontSize, "SubTitleFontSize", "Track Title Font Size", "", "", "" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_axisTitleFontSize, "AxisTitleFontSize", "Axis Title Font Size", "", "", "" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_axisValueFontSize, "AxisValueFontSize", "Axis Value Font Size", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "", "", "", "" );
m_nameConfig.uiCapability()->setUiTreeHidden( true );
m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true );
@ -701,6 +706,9 @@ void RimDepthTrackPlot::doUpdateLayout()
{
if ( m_viewer )
{
m_viewer->setTitleFontSizes( titleFontSize(), subTitleFontSize() );
m_viewer->setLegendFontSize( legendFontSize() );
m_viewer->setAxisFontSizes( axisTitleFontSize(), axisValueFontSize() );
m_viewer->scheduleUpdate();
}
}
@ -796,6 +804,11 @@ void RimDepthTrackPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel
m_isAutoScaleDepthEnabled = true;
updateZoom();
}
else if ( changedField == &m_subTitleFontSize || changedField == &m_axisTitleFontSize ||
changedField == &m_axisValueFontSize )
{
updateFonts();
}
updateConnectedEditors();
}
@ -818,6 +831,9 @@ void RimDepthTrackPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi
caf::PdmUiGroup* plotLayoutGroup = uiOrdering.addNewGroup( "Plot Layout" );
RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, *plotLayoutGroup );
plotLayoutGroup->add( &m_subTitleFontSize );
plotLayoutGroup->add( &m_axisTitleFontSize );
plotLayoutGroup->add( &m_axisValueFontSize );
uiOrdering.skipRemainingFields( true );
}
@ -851,6 +867,11 @@ QList<caf::PdmOptionItemInfo> RimDepthTrackPlot::calculateValueOptions( const ca
options.push_back( caf::PdmOptionItemInfo( UnitAppEnum::uiText( depthUnit ), depthUnit ) );
}
}
else if ( fieldNeedingOptions == &m_subTitleFontSize || fieldNeedingOptions == &m_axisTitleFontSize ||
fieldNeedingOptions == &m_axisValueFontSize )
{
options = caf::FontTools::relativeSizeValueOptions( RiaPreferences::current()->defaultPlotFontSize() );
}
( *useOptionsOnly ) = true;
return options;
@ -1064,3 +1085,27 @@ void RimDepthTrackPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* chil
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
mainPlotWindow->updateWellLogPlotToolBar();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimDepthTrackPlot::subTitleFontSize() const
{
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_subTitleFontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimDepthTrackPlot::axisTitleFontSize() const
{
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_axisTitleFontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimDepthTrackPlot::axisValueFontSize() const
{
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_axisValueFontSize() );
}

View File

@ -123,6 +123,10 @@ public:
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
int subTitleFontSize() const;
int axisTitleFontSize() const;
int axisValueFontSize() const;
protected:
QImage snapshotWindowContent() override;
@ -164,6 +168,9 @@ protected:
caf::PdmField<double> m_maxVisibleDepth;
caf::PdmField<AxisGridEnum> m_depthAxisGridVisibility;
caf::PdmField<bool> m_isAutoScaleDepthEnabled;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_subTitleFontSize;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisTitleFontSize;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisValueFontSize;
caf::PdmChildField<RimWellLogPlotNameConfig*> m_nameConfig;
caf::PdmChildArrayField<RimPlot*> m_plots;

View File

@ -367,53 +367,6 @@ bool RimGridView::isGridVisualizationMode() const
return this->m_gridCollection->isActive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGridView::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const
{
bool hasCustomFonts = Rim3dView::hasCustomFontSizes( fontSettingType, defaultFontSize );
if ( fontSettingType == RiaDefines::FontSettingType::ANNOTATION_FONT )
{
auto annotations = annotationCollection();
if ( annotations )
{
RiaFontCache::FontSize defaultFontSizeEnum = RiaFontCache::fontSizeEnumFromPointSize( defaultFontSize );
hasCustomFonts = annotations->hasTextAnnotationsWithCustomFontSize( defaultFontSizeEnum ) || hasCustomFonts;
}
}
return hasCustomFonts;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGridView::applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange /*= false*/ )
{
bool anyChange = Rim3dView::applyFontSize( fontSettingType, oldFontSize, fontSize, forceChange );
if ( fontSettingType == RiaDefines::FontSettingType::ANNOTATION_FONT )
{
auto annotations = annotationCollection();
if ( annotations )
{
RiaFontCache::FontSize oldFontSizeEnum = RiaFontCache::fontSizeEnumFromPointSize( oldFontSize );
RiaFontCache::FontSize newFontSizeEnum = RiaFontCache::fontSizeEnumFromPointSize( fontSize );
bool applyFontSizes = forceChange || !annotations->hasTextAnnotationsWithCustomFontSize( oldFontSizeEnum );
if ( applyFontSizes )
{
anyChange =
annotations->applyFontSizeToAllTextAnnotations( oldFontSizeEnum, newFontSizeEnum, forceChange ) ||
anyChange;
}
}
}
return anyChange;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -68,12 +68,6 @@ public:
bool isGridVisualizationMode() const override;
bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const override;
bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange = false ) override;
void updateWellMeasurements();
void updateSurfacesInViewTreeItems();

View File

@ -18,6 +18,8 @@
#include "RimLegendConfig.h"
#include "RiaPreferences.h"
// NB! Special macro for pure virtual class
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimLegendConfig, "LegendConfig" );
@ -46,3 +48,15 @@ RimLegendConfig::RimLegendConfig()
RimLegendConfig::~RimLegendConfig()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimLegendConfig::fontSize() const
{
caf::FontHolderInterface* parentFontHolder = nullptr;
this->firstAncestorOfType(parentFontHolder);
if (parentFontHolder) return parentFontHolder->fontSize();
return caf::FontTools::absolutePointSize(RiaPreferences::current()->defaultSceneFontSize());
}

View File

@ -18,6 +18,7 @@
#pragma once
#include "cafFontTools.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
@ -30,7 +31,7 @@ class TitledOverlayFrame;
///
///
//==================================================================================================
class RimLegendConfig : public caf::PdmObject
class RimLegendConfig : public caf::PdmObject, public caf::FontHolderInterface
{
CAF_PDM_HEADER_INIT;
@ -49,4 +50,6 @@ public:
virtual const caf::TitledOverlayFrame* titledOverlayFrame() const = 0;
virtual caf::TitledOverlayFrame* titledOverlayFrame() = 0;
virtual int fontSize() const override;
};

View File

@ -18,6 +18,8 @@
#include "RimMultiPlot.h"
#include "RiaPreferences.h"
#include "RimPlot.h"
#include "RimProject.h"
#include "RimSummaryTimeAxisProperties.h"
@ -76,6 +78,8 @@ RimMultiPlot::RimMultiPlot()
CAF_PDM_InitField( &m_showIndividualPlotTitles, "ShowPlotTitles", true, "Show Sub Plot Titles", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_majorTickmarkCount, "MajorTickmarkCount", "Major Tickmark Count", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_subTitleFontSize, "SubTitleFontSize", "Sub Plot Title Font Size", "", "", "" );
m_viewer = nullptr;
setDeletable( true );
@ -115,6 +119,7 @@ RimMultiPlot& RimMultiPlot::operator=( RimMultiPlot&& rhs )
m_columnCount = rhs.m_columnCount;
m_rowsPerPage = rhs.m_rowsPerPage;
m_showIndividualPlotTitles = rhs.m_showIndividualPlotTitles;
m_subTitleFontSize = rhs.m_subTitleFontSize;
return *this;
}
@ -302,6 +307,11 @@ void RimMultiPlot::doUpdateLayout()
m_viewer->setPlotTitle( description() );
m_viewer->setTitleVisible( m_showPlotWindowTitle );
m_viewer->setSubTitlesVisible( m_showIndividualPlotTitles );
m_viewer->setTitleFontSizes( titleFontSize(), subTitleFontSize() );
m_viewer->setLegendFontSize( legendFontSize() );
m_viewer->setAxisFontSizes( axisTitleFontSize(), axisValueFontSize() );
m_viewer->scheduleUpdate();
m_viewer->adjustSize();
}
@ -465,6 +475,30 @@ bool RimMultiPlot::previewModeEnabled() const
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimMultiPlot::subTitleFontSize() const
{
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_subTitleFontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimMultiPlot::axisTitleFontSize() const
{
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_axisTitleFontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimMultiPlot::axisValueFontSize() const
{
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_axisValueFontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -528,6 +562,10 @@ void RimMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, co
updatePlotWindowTitle();
applyPlotWindowTitleToWidgets();
}
else if ( changedField == &m_subTitleFontSize )
{
updateFonts();
}
else if ( changedField == &m_columnCount || changedField == &m_rowsPerPage )
{
updateLayout();
@ -568,6 +606,7 @@ void RimMultiPlot::uiOrderingForMultiPlotLayout( QString uiConfigName, caf::PdmU
uiOrdering.add( &m_plotWindowTitle );
uiOrdering.add( &m_showIndividualPlotTitles );
RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, uiOrdering );
uiOrdering.add( &m_subTitleFontSize );
uiOrdering.add( &m_columnCount );
uiOrdering.add( &m_rowsPerPage );
uiOrdering.add( &m_majorTickmarkCount );
@ -604,6 +643,11 @@ QList<caf::PdmOptionItemInfo> RimMultiPlot::calculateValueOptions( const caf::Pd
}
}
}
else if ( fieldNeedingOptions == &m_subTitleFontSize || fieldNeedingOptions == &m_axisTitleFontSize ||
fieldNeedingOptions == &m_axisValueFontSize )
{
return caf::FontTools::relativeSizeValueOptions( RiaPreferences::current()->defaultPlotFontSize() );
}
return options;
}
@ -682,70 +726,6 @@ void RimMultiPlot::recreatePlotWidgets()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimMultiPlot::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const
{
if ( fontSettingType == RiaDefines::FontSettingType::PLOT_FONT && m_viewer )
{
if ( m_viewer->fontSize() != defaultFontSize )
{
return true;
}
if ( m_legendFontSize() != defaultFontSize )
{
return true;
}
for ( const RimPlot* plot : plots() )
{
if ( plot->hasCustomFontSizes( fontSettingType, defaultFontSize ) )
{
return true;
}
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimMultiPlot::applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange /*= false */ )
{
bool somethingChanged = false;
if ( fontSettingType == RiaDefines::FontSettingType::PLOT_FONT && m_viewer )
{
if ( oldFontSize == m_viewer->fontSize() || forceChange )
{
m_viewer->setFontSize( fontSize );
somethingChanged = true;
}
if ( oldFontSize == m_legendFontSize() || forceChange )
{
m_legendFontSize = fontSize;
somethingChanged = true;
}
for ( RimPlot* plot : plots() )
{
if ( plot->applyFontSize( fontSettingType, oldFontSize, fontSize, forceChange ) )
{
somethingChanged = true;
}
}
if ( somethingChanged )
{
m_viewer->scheduleUpdate();
}
}
return somethingChanged;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -98,6 +98,10 @@ public:
bool previewModeEnabled() const;
int subTitleFontSize() const;
int axisTitleFontSize() const;
int axisValueFontSize() const;
protected:
QImage snapshotWindowContent() override;
@ -121,12 +125,6 @@ protected:
void updateZoom();
void recreatePlotWidgets();
bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const override;
bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange = false ) override;
private:
void cleanupBeforeClose();
void doUpdateLayout() override;
@ -136,11 +134,14 @@ private:
void onPlotAdditionOrRemoval();
protected:
caf::PdmField<bool> m_showPlotWindowTitle;
caf::PdmField<QString> m_plotWindowTitle;
caf::PdmField<ColumnCountEnum> m_columnCount;
caf::PdmField<RowCountEnum> m_rowsPerPage;
caf::PdmField<bool> m_showIndividualPlotTitles;
caf::PdmField<bool> m_showPlotWindowTitle;
caf::PdmField<QString> m_plotWindowTitle;
caf::PdmField<ColumnCountEnum> m_columnCount;
caf::PdmField<RowCountEnum> m_rowsPerPage;
caf::PdmField<bool> m_showIndividualPlotTitles;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_subTitleFontSize;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisTitleFontSize;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisValueFontSize;
caf::PdmField<RimPlotAxisPropertiesInterface::LegendTickmarkCountEnum> m_majorTickmarkCount;

View File

@ -61,6 +61,18 @@ QWidget* RimPlot::createViewWidget( QWidget* parent /*= nullptr */ )
return plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::updateFonts()
{
if (viewer())
{
viewer()->setPlotTitleFontSize(titleFontSize());
viewer()->setLegendFontSize(legendFontSize());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -98,6 +98,7 @@ protected:
static void attachPlotWidgetSignals( RimPlot* plot, RiuQwtPlotWidget* plotWidget );
QWidget* createViewWidget( QWidget* parent = nullptr ) final;
void updateFonts();
private:
virtual void doRemoveFromCollection() = 0;
virtual void doRenderWindowContent( QPaintDevice* paintDevice );

View File

@ -89,10 +89,9 @@ RimPlotAxisProperties::RimPlotAxisProperties()
CAF_PDM_InitField(&m_isAxisInverted, "AxisInverted", false, "Invert Axis", "", "", "");
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, "TitleDeltaFontSize", "Font Size", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_valuesFontSize, "ValueDeltaFontSize", "Font Size", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_annotations, "Annotations", "", "", "", "");
@ -136,26 +135,7 @@ 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 == &scaleFactor )
if ( fieldNeedingOptions == &scaleFactor )
{
for ( int exp = -12; exp <= 12; exp += 3 )
{
@ -249,15 +229,7 @@ RimPlotAxisPropertiesInterface::AxisTitlePositionType RimPlotAxisProperties::tit
//--------------------------------------------------------------------------------------------------
int RimPlotAxisProperties::titleFontSize() const
{
return m_titleFontSize;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisProperties::setTitleFontSize( int fontSize )
{
m_titleFontSize = fontSize;
return caf::FontTools::absolutePointSize( plotFontSize(), m_titleFontSize() );
}
//--------------------------------------------------------------------------------------------------
@ -265,15 +237,7 @@ void RimPlotAxisProperties::setTitleFontSize( int fontSize )
//--------------------------------------------------------------------------------------------------
int RimPlotAxisProperties::valuesFontSize() const
{
return m_valuesFontSize;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotAxisProperties::setValuesFontSize( int fontSize )
{
m_valuesFontSize = fontSize;
return caf::FontTools::absolutePointSize( plotFontSize(), m_valuesFontSize() );
}
//--------------------------------------------------------------------------------------------------
@ -454,6 +418,14 @@ void RimPlotAxisProperties::updateOptionSensitivity()
customTitle.uiCapability()->setUiReadOnly( isAutoTitle );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::FontTools::FontSize RimPlotAxisProperties::plotFontSize() const
{
return RiaPreferences::current()->defaultPlotFontSize();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -23,6 +23,7 @@
#include "RimPlotAxisPropertiesInterface.h"
#include "cafAppEnum.h"
#include "cafFontTools.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
@ -56,10 +57,9 @@ public:
void enableRangeSettings( bool enable );
void setNameAndAxis( const QString& name, QwtPlot::Axis axis );
AxisTitlePositionType titlePosition() const override;
int titleFontSize() const override;
void setTitleFontSize( int fontSize ) override;
int valuesFontSize() const override;
void setValuesFontSize( int fontSize ) override;
int titleFontSize() const override;
int valuesFontSize() const override;
QwtPlot::Axis qwtPlotAxisType() const;
QString name() const;
@ -102,7 +102,8 @@ protected:
bool* useOptionsOnly ) override;
private:
void updateOptionSensitivity();
void updateOptionSensitivity();
caf::FontTools::FontSize plotFontSize() const;
private:
caf::PdmField<bool> m_isActive;
@ -120,9 +121,9 @@ private:
bool m_enableTitleTextSettings;
bool m_isRangeSettingsEnabled;
caf::PdmField<int> m_titleFontSize;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_titleFontSize;
caf::PdmField<caf::AppEnum<AxisTitlePositionType>> m_titlePositionEnum;
caf::PdmField<int> m_valuesFontSize;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_valuesFontSize;
caf::PdmChildArrayField<RimPlotAxisAnnotation*> m_annotations;
};

View File

@ -38,9 +38,7 @@ public:
using LegendTickmarkCountEnum = caf::AppEnum<LegendTickmarkCount>;
public:
virtual AxisTitlePositionType titlePosition() const = 0;
virtual int titleFontSize() const = 0;
virtual void setTitleFontSize( int fontSize ) = 0;
virtual int valuesFontSize() const = 0;
virtual void setValuesFontSize( int fontSize ) = 0;
virtual AxisTitlePositionType titlePosition() const = 0;
virtual int titleFontSize() const = 0;
virtual int valuesFontSize() const = 0;
};

View File

@ -689,11 +689,17 @@ void RimPlotCurve::updateCurveAppearance()
if ( m_pointSymbol() != RiuQwtSymbol::SYMBOL_NONE )
{
int legendFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(),
caf::FontTools::RelativeSize::Small );
RimPlotWindow* plotWindow = nullptr;
this->firstAncestorOrThisOfType( plotWindow );
if ( plotWindow )
{
legendFontSize = plotWindow->legendFontSize();
}
// QwtPlotCurve will take ownership of the symbol
symbol = new RiuQwtSymbol( m_pointSymbol(),
m_symbolLabel(),
m_symbolLabelPosition(),
RiaApplication::instance()->preferences()->defaultPlotFontSize() );
symbol = new RiuQwtSymbol( m_pointSymbol(), m_symbolLabel(), m_symbolLabelPosition(), legendFontSize );
symbol->setSize( m_symbolSize, m_symbolSize );
symbol->setColor( curveColor );

View File

@ -55,8 +55,12 @@ RimPlotWindow::RimPlotWindow()
CAF_PDM_InitField( &m_showPlotLegends, "ShowTrackLegends", true, "Show Legends", "", "", "" );
CAF_PDM_InitField( &m_plotLegendsHorizontal, "TrackLegendsHorizontal", true, "Legend Orientation", "", "", "" );
m_plotLegendsHorizontal.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
int defaultFontSize = RiaApplication::instance()->preferences()->defaultPlotFontSize();
CAF_PDM_InitField( &m_legendFontSize, "LegendFontSize", std::max( 8, defaultFontSize - 2 ), "Legend Font Size", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_titleFontSize, "TitleFontSize", "Title Font Size", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_legendFontSize, "LegendDeltaFontSize", "Legend Font Size", "", "", "" );
m_titleFontSize = caf::FontTools::RelativeSize::XLarge;
m_legendFontSize = caf::FontTools::RelativeSize::Small;
}
//--------------------------------------------------------------------------------------------------
@ -81,6 +85,7 @@ RimPlotWindow& RimPlotWindow::operator=( RimPlotWindow&& rhs )
{
m_showPlotLegends = rhs.m_showPlotLegends();
m_plotLegendsHorizontal = rhs.m_plotLegendsHorizontal();
m_titleFontSize = rhs.m_titleFontSize();
m_legendFontSize = rhs.m_legendFontSize();
return *this;
}
@ -120,17 +125,33 @@ void RimPlotWindow::setLegendsHorizontal( bool horizontal )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimPlotWindow::legendFontSize() const
void RimPlotWindow::updateFonts()
{
return m_legendFontSize;
updateLayout();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotWindow::setLegendFontSize( int fontSize )
int RimPlotWindow::fontSize() const
{
m_legendFontSize = fontSize;
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimPlotWindow::titleFontSize() const
{
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_titleFontSize() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimPlotWindow::legendFontSize() const
{
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_legendFontSize() );
}
//--------------------------------------------------------------------------------------------------
@ -207,7 +228,7 @@ void RimPlotWindow::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
{
updateLayout();
}
else if ( changedField == &m_legendFontSize )
else if ( changedField == &m_legendFontSize || changedField == &m_titleFontSize )
{
updateLayout();
}
@ -222,30 +243,16 @@ QList<caf::PdmOptionItemInfo> RimPlotWindow::calculateValueOptions( const caf::P
bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_legendFontSize )
{
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_plotLegendsHorizontal )
if ( fieldNeedingOptions == &m_plotLegendsHorizontal )
{
options.push_back( caf::PdmOptionItemInfo( "Vertical", QVariant::fromValue( false ) ) );
options.push_back( caf::PdmOptionItemInfo( "Horizontal", QVariant::fromValue( true ) ) );
}
else if ( fieldNeedingOptions == &m_titleFontSize || fieldNeedingOptions == &m_legendFontSize )
{
options = caf::FontTools::relativeSizeValueOptions( RiaPreferences::current()->defaultPlotFontSize() );
}
return options;
}
@ -256,6 +263,7 @@ void RimPlotWindow::uiOrderingForPlotLayout( QString uiConfigName, caf::PdmUiOrd
{
uiOrdering.add( &m_showPlotLegends );
uiOrdering.add( &m_plotLegendsHorizontal );
uiOrdering.add( &m_titleFontSize );
uiOrdering.add( &m_legendFontSize );
}

View File

@ -55,8 +55,12 @@ public:
void setLegendsVisible( bool doShow );
bool legendsHorizontal() const;
void setLegendsHorizontal( bool horizontal );
int legendFontSize() const;
void setLegendFontSize( int fontSize );
void updateFonts() override;
int fontSize() const override;
int titleFontSize() const;
int legendFontSize() const;
void updateLayout();
void updateParentLayout();
@ -90,5 +94,7 @@ protected:
caf::PdmField<int> m_id;
caf::PdmField<bool> m_showPlotLegends;
caf::PdmField<bool> m_plotLegendsHorizontal;
caf::PdmField<int> m_legendFontSize;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_titleFontSize;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_legendFontSize;
};

View File

@ -639,9 +639,9 @@ void RimRegularLegendConfig::recreateLegend()
// has been removed, (and thus the opengl resources has been deleted) The text in
// the legend disappeared because of this, so workaround: recreate the legend when needed:
cvf::Font* standardFont = RiaApplication::instance()->defaultSceneFont();
m_scalarMapperLegend = new caf::OverlayScalarMapperLegend( standardFont );
m_categoryLegend = new caf::CategoryLegend( standardFont, m_categoryMapper.p() );
cvf::Font* font = RiaApplication::instance()->sceneFont( this->fontSize() );
m_scalarMapperLegend = new caf::OverlayScalarMapperLegend( font );
m_categoryLegend = new caf::CategoryLegend( font, m_categoryMapper.p() );
updateLegend();
}
@ -945,6 +945,19 @@ RimColorLegend* RimRegularLegendConfig::mapToColorLegend( ColorRangesType colorT
return project->colorLegendCollection()->findByName( RimRegularLegendConfig::ColorRangeEnum::uiText( colorType ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimRegularLegendConfig::updateFonts()
{
int pointSize = this->fontSize();
auto font = RiaApplication::instance()->sceneFont( pointSize );
m_scalarMapperLegend = new caf::OverlayScalarMapperLegend( font );
m_categoryLegend = new caf::CategoryLegend( font, m_categoryMapper.p() );
updateLegend();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -147,6 +147,8 @@ public:
static cvf::Color3ubArray colorArrayFromColorType( ColorRangesType colorType );
static RimColorLegend* mapToColorLegend( ColorRangesType colorType );
void updateFonts() override;
private:
void setNamedCategories( const std::vector<QString>& categoryNames, bool inverse );
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;

View File

@ -245,8 +245,9 @@ void RimTernaryLegendConfig::recreateLegend()
// has been removed, (and thus the opengl resources has been deleted) The text in
// the legend disappeared because of this, so workaround: recreate the legend when needed:
cvf::Font* standardFont = RiaApplication::instance()->defaultSceneFont();
m_legend = new RivTernarySaturationOverlayItem( standardFont );
int fontSize = this->fontSize();
cvf::Font* font = RiaApplication::instance()->sceneFont(fontSize);
m_legend = new RivTernarySaturationOverlayItem( font );
m_legend->setLayout( cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT );
updateLegend();
@ -526,6 +527,14 @@ caf::TitledOverlayFrame* RimTernaryLegendConfig::titledOverlayFrame()
return m_legend.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTernaryLegendConfig::updateFonts()
{
recreateLegend();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -63,6 +63,7 @@ public:
const RivTernaryScalarMapper* scalarMapper() const;
const caf::TitledOverlayFrame* titledOverlayFrame() const override;
caf::TitledOverlayFrame* titledOverlayFrame() override;
void updateFonts() override;
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;

View File

@ -20,6 +20,7 @@
#include "RiaDefines.h"
#include "cafFontTools.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
@ -50,7 +51,7 @@ struct RimMdiWindowGeometry
bool isMaximized;
};
class RimViewWindow : public caf::PdmObject
class RimViewWindow : public caf::PdmObject, public caf::FontHolderInterface
{
CAF_PDM_HEADER_INIT;
@ -83,19 +84,6 @@ public:
void viewNavigationChanged();
// Font methods relates to RimPreferences settings
// When the preferences are changed, these methods are called to propagate the changes into the windows.
virtual bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const
{
return false;
}
virtual bool
applyFontSize( RiaDefines::FontSettingType fontSettingType, int oldFontSize, int fontSize, bool forceChange = false )
{
return false;
}
protected:
void removeMdiWindowFromMdiArea();

View File

@ -121,6 +121,9 @@ void RimWellBoreStabilityPlot::defineUiOrdering( QString uiConfigName, caf::PdmU
caf::PdmUiGroup* plotLayoutGroup = uiOrdering.addNewGroup( "Plot Layout" );
RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, *plotLayoutGroup );
plotLayoutGroup->add( &m_subTitleFontSize );
plotLayoutGroup->add( &m_axisTitleFontSize );
plotLayoutGroup->add( &m_axisValueFontSize );
uiOrdering.skipRemainingFields( true );
}

View File

@ -23,6 +23,7 @@
#include "RiaExtractionTools.h"
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RiaSimWellBranchTools.h"
#include "RigEclipseCaseData.h"
@ -197,6 +198,8 @@ RimWellLogTrack::RimWellLogTrack()
m_majorTickInterval.uiCapability()->setUiHidden( true );
m_minorTickInterval.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_axisFontSize, "AxisFontSize", "Axis Font Size", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_regionAnnotationType, "AnnotationType", "Region Annotations", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_regionAnnotationDisplay, "RegionDisplay", "Region Display", "", "", "" );
@ -497,6 +500,14 @@ void RimWellLogTrack::updateYZoom()
m_plotWidget->setAxisRange( QwtPlot::yLeft, m_visibleDepthRangeMin(), m_visibleDepthRangeMax() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellLogTrack::axisFontSize() const
{
return caf::FontTools::absolutePointSize(RiaPreferences::current()->defaultPlotFontSize(), m_axisFontSize());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -881,38 +892,6 @@ QString RimWellLogTrack::asciiDataForPlotExport() const
return out;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogTrack::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const
{
if ( fontSettingType == RiaDefines::FontSettingType::PLOT_FONT && m_plotWidget )
{
return defaultFontSize != m_plotWidget->axisTitleFontSize( QwtPlot::xTop );
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogTrack::applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange /*= false*/ )
{
if ( fontSettingType == RiaDefines::FontSettingType::PLOT_FONT && m_plotWidget )
{
if ( oldFontSize == m_plotWidget->axisTitleFontSize( QwtPlot::xTop ) || forceChange )
{
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xTop, fontSize, fontSize );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, fontSize, fontSize );
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -2765,6 +2744,7 @@ void RimWellLogTrack::removeRegionAnnotations()
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::doUpdateLayout()
{
updateFonts();
m_plotWidget->scheduleReplot();
}

View File

@ -202,12 +202,6 @@ public:
QString asciiDataForPlotExport() const override;
bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const override;
bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange = false ) override;
void onAxisSelected( int axis, bool toggle ) override;
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
@ -230,6 +224,8 @@ private:
void updateXZoom();
void updateYZoom();
int axisFontSize() const;
void doRemoveFromCollection() override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
@ -308,6 +304,8 @@ private:
caf::PdmField<double> m_majorTickInterval;
caf::PdmField<double> m_minorTickInterval;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisFontSize;
caf::PdmField<RegionAnnotationTypeEnum> m_regionAnnotationType;
caf::PdmField<RegionAnnotationDisplayEnum> m_regionAnnotationDisplay;
caf::PdmPtrField<RimColorLegend*> m_colorShadingLegend;

View File

@ -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();
}

View File

@ -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();

View File

@ -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 );

View File

@ -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() )
{

View File

@ -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;

View File

@ -105,7 +105,7 @@ void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRec
{
QFont font = this->font();
font.setPixelSize(
RiaFontCache::pointSizeToPixelSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() ) );
caf::FontTools::pointSizeToPixelSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() ) );
this->setFont( font );
LayoutInfo layout( QSize( targetRect.width(), targetRect.height() ) );

View File

@ -53,7 +53,7 @@ RiuTextOverlayContentFrame::RiuTextOverlayContentFrame( QWidget* parent /*= null
layout->addWidget( m_textLabel );
QFont font = m_textLabel->font();
RiaFontCache::pointSizeToPixelSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() );
caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() );
m_textLabel->setFont( font );
}

View File

@ -39,38 +39,41 @@ RiuDockedQwtPlot::RiuDockedQwtPlot( QWidget* parent /*= nullptr*/ )
//--------------------------------------------------------------------------------------------------
void RiuDockedQwtPlot::applyFontSizes( bool replot /*= false*/ )
{
std::set<QwtPlot::Axis> allAxes = {QwtPlot::xBottom, QwtPlot::yLeft, QwtPlot::xTop, QwtPlot::yRight};
std::set<QwtPlot::Axis> allAxes = { QwtPlot::xBottom, QwtPlot::yLeft, QwtPlot::xTop, QwtPlot::yRight };
int fontPointSize = RiaApplication::instance()->preferences()->defaultPlotFontSize() - 1;
caf::FontTools::FontSize fontSize = RiaPreferences::current()->defaultPlotFontSize();
int titleFontSize = caf::FontTools::absolutePointSize( fontSize, caf::FontTools::RelativeSize::Large );
int axisFontSize = caf::FontTools::absolutePointSize( fontSize, caf::FontTools::RelativeSize::Medium );
int legendFontSize = caf::FontTools::absolutePointSize( fontSize, caf::FontTools::RelativeSize::Small );
QwtText titleText = this->title();
QFont font = titleText.font();
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( titleFontSize ) );
titleText.setFont( font );
this->setTitle( titleText );
for ( QwtPlot::Axis axis : allAxes )
{
QwtText text = this->axisTitle( axis );
QFont font = text.font();
font.setPixelSize(
RiaFontCache::pointSizeToPixelSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() ) );
text.setFont( font );
QwtText text = this->axisTitle( axis );
QFont axisTitleFont = text.font();
axisTitleFont.setPixelSize( caf::FontTools::pointSizeToPixelSize( axisFontSize ) );
text.setFont( axisTitleFont );
this->setAxisTitle( axis, text );
QFont valuesFont = this->axisFont( axis );
valuesFont.setPixelSize( font.pixelSize() );
valuesFont.setPixelSize( axisTitleFont.pixelSize() );
this->setAxisFont( axis, valuesFont );
}
if ( legend() )
{
auto font = legend()->font();
font.setPointSize( fontPointSize );
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( legendFontSize ) );
legend()->setFont( font );
}
QwtText titleText = this->title();
QFont font = titleText.font();
font.setPointSize( fontPointSize + 3 );
titleText.setFont( font );
this->setTitle( titleText );
if ( replot )
{
this->replot();

View File

@ -18,7 +18,6 @@
#include "RiuFlowCharacteristicsPlot.h"
#include "RiaApplication.h"
#include "RiaColorTables.h"
#include "RiaFeatureCommandContext.h"
#include "RiaFontCache.h"
@ -81,8 +80,8 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPl
new RiuQwtPlotWheelZoomer( m_lorenzPlot );
addWindowZoom( m_lorenzPlot );
QString dateFormat = RiaApplication::instance()->preferences()->dateFormat();
QString timeFormat = RiaApplication::instance()->preferences()->timeFormat();
QString dateFormat = RiaPreferences::current()->dateFormat();
QString timeFormat = RiaPreferences::current()->timeFormat();
RiuQwtPlotTools::enableDateBasedBottomXAxis( m_lorenzPlot, dateFormat, timeFormat );
m_lorenzPlot->setTitle( "Lorenz Coefficient" );
@ -92,7 +91,8 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPl
addWindowZoom( m_sweepEffPlot );
m_sweepEffPlot->setTitle( "Sweep Efficiency" );
int legendFontSize = RiaApplication::instance()->preferences()->defaultPlotFontSize();
int legendFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(),
caf::FontTools::RelativeSize::Small );
{
QwtText axisTitle = m_sweepEffPlot->axisTitle( QwtPlot::xBottom );

View File

@ -141,7 +141,7 @@ void RiuGridCrossQwtPlot::setLegendFontSize( int fontSize )
if ( legend() )
{
QFont font = legend()->font();
font.setPixelSize( RiaFontCache::pointSizeToPixelSize( fontSize ) );
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( fontSize ) );
legend()->setFont( font );
// Set font size for all existing labels
QList<QwtLegendLabel*> labels = legend()->findChildren<QwtLegendLabel*>();

View File

@ -133,10 +133,6 @@ RiuMultiPlotBook::RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* paren
setFocusPolicy( Qt::StrongFocus );
RiaApplication* app = RiaApplication::instance();
int defaultFontSize = app->preferences()->defaultPlotFontSize();
setFontSize( defaultFontSize );
QSize pageSize = m_plotDefinition->pageLayout().fullRectPixels( RiaGuiApplication::applicationResolution() ).size();
setBookSize( pageSize.width() );
this->setObjectName( QString( "%1" ).arg( reinterpret_cast<uint64_t>( this ) ) );
@ -229,26 +225,34 @@ void RiuMultiPlotBook::setSubTitlesVisible( bool visible )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::setFontSize( int fontSize )
void RiuMultiPlotBook::setTitleFontSizes( int titleFontSize, int subTitleFontSize )
{
QFont font = this->font();
int pixelSize = RiaFontCache::pointSizeToPixelSize( fontSize );
font.setPixelSize( pixelSize );
this->setFont( font );
for ( auto page : m_pages )
{
page->setFontSize( fontSize );
page->setTitleFontSizes( titleFontSize, subTitleFontSize );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiuMultiPlotBook::fontSize() const
void RiuMultiPlotBook::setLegendFontSize( int legendFontSize )
{
return RiaFontCache::pixelSizeToPointSize( this->font().pixelSize() );
for ( auto page : m_pages )
{
page->setLegendFontSize( legendFontSize );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::setAxisFontSizes( int axisTitleFontSize, int axisValueFontSize )
{
for ( auto page : m_pages )
{
page->setAxisFontSizes( axisTitleFontSize, axisValueFontSize );
}
}
//--------------------------------------------------------------------------------------------------
@ -512,7 +516,9 @@ RiuMultiPlotPage* RiuMultiPlotBook::createPage()
// Reapply plot settings
page->setPlotTitle( m_plotTitle );
page->setFontSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() );
page->setTitleFontSizes( m_plotDefinition->titleFontSize(), m_plotDefinition->subTitleFontSize() );
page->setLegendFontSize( m_plotDefinition->legendFontSize() );
page->setAxisFontSizes( m_plotDefinition->axisTitleFontSize(), m_plotDefinition->axisValueFontSize() );
page->setTitleVisible( m_titleVisible );
page->setSubTitlesVisible( m_subTitlesVisible );
page->setPreviewModeEnabled( m_previewMode );

View File

@ -73,8 +73,9 @@ public:
void setTitleVisible( bool visible );
void setSubTitlesVisible( bool visible );
void setFontSize( int fontSize );
int fontSize() const;
void setTitleFontSizes( int titleFontSize, int subTitleFontSize );
void setLegendFontSize( int legendFontSize );
void setAxisFontSizes( int axisTitleFontSize, int axisValueFontSize );
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget );

View File

@ -68,6 +68,12 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* pare
, m_plotDefinition( plotDefinition )
, m_previewMode( false )
, m_showSubTitles( false )
, m_titleFontPixelSize( 12 )
, m_subTitleFontPixelSize( 11 )
, m_legendFontPixelSize( 8 )
, m_axisTitleFontPixelSize( 10 )
, m_axisValueFontPixelSize( 10 )
{
CAF_ASSERT( m_plotDefinition );
@ -109,10 +115,6 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* pare
setFocusPolicy( Qt::StrongFocus );
RiaApplication* app = RiaApplication::instance();
int defaultFontSize = app->preferences()->defaultPlotFontSize();
setFontSize( defaultFontSize );
this->setObjectName( QString( "%1" ).arg( reinterpret_cast<uint64_t>( this ) ) );
this->setBackgroundRole( QPalette::Window );
@ -259,32 +261,33 @@ void RiuMultiPlotPage::setTitleVisible( bool visible )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::setFontSize( int fontSize )
void RiuMultiPlotPage::setTitleFontSizes( int titleFontSize, int subTitleFontSize )
{
int pixelSize = RiaFontCache::pointSizeToPixelSize( fontSize );
{
QFont font = m_plotTitle->font();
m_titleFontPixelSize = caf::FontTools::pointSizeToPixelSize( titleFontSize );
m_subTitleFontPixelSize = caf::FontTools::pointSizeToPixelSize( subTitleFontSize );
font.setPixelSize( pixelSize + 2 );
font.setBold( true );
m_plotTitle->setFont( font );
}
for ( QLabel* subTitle : m_subTitles )
{
QFont font = subTitle->font();
font.setPixelSize( pixelSize );
font.setBold( true );
subTitle->setFont( font );
}
scheduleUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiuMultiPlotPage::fontSize() const
void RiuMultiPlotPage::setLegendFontSize( int legendFontSize )
{
return m_plotTitle->font().pointSize() - 2;
m_legendFontPixelSize = caf::FontTools::pointSizeToPixelSize( legendFontSize );
scheduleUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::setAxisFontSizes( int axisTitleFontSize, int axisValueFontSize )
{
m_axisTitleFontPixelSize = caf::FontTools::pointSizeToPixelSize( axisTitleFontSize );
m_axisValueFontPixelSize = caf::FontTools::pointSizeToPixelSize( axisValueFontSize );
scheduleUpdate();
}
//--------------------------------------------------------------------------------------------------
@ -579,6 +582,10 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
{
clearGridLayout();
auto titleFont = m_plotTitle->font();
titleFont.setPixelSize( m_titleFontPixelSize );
m_plotTitle->setFont( titleFont );
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
if ( m_plotWidgets[tIdx] )
@ -621,11 +628,17 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
m_gridLayout->addWidget( plotWidgets[visibleIndex], 3 * row + 2, column, 1 + ( rowSpan - 1 ) * 3, colSpan );
subTitles[visibleIndex]->setVisible( m_showSubTitles );
QFont subTitleFont = subTitles[visibleIndex]->font();
subTitleFont.setPixelSize( m_subTitleFontPixelSize );
subTitles[visibleIndex]->setFont( subTitleFont );
plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft,
showYAxis( row, column ),
showYAxis( row, column ) );
plotWidgets[visibleIndex]->setAxisTitleEnabled( QwtPlot::yLeft, showYAxis( row, column ) );
plotWidgets[visibleIndex]->setAxisFontsAndAlignment( QwtPlot::yLeft,
m_axisTitleFontPixelSize,
m_axisValueFontPixelSize );
plotWidgets[visibleIndex]->show();
@ -640,7 +653,7 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
}
legends[visibleIndex]->setMaxColumns( legendColumns );
QFont legendFont = legends[visibleIndex]->font();
legendFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( m_plotDefinition->legendFontSize() ) );
legendFont.setPixelSize( m_legendFontPixelSize );
legends[visibleIndex]->setFont( legendFont );
legends[visibleIndex]->show();
}

View File

@ -79,8 +79,9 @@ public:
void setPlotTitle( const QString& plotTitle );
void setTitleVisible( bool visible );
void setFontSize( int fontSize );
int fontSize() const;
void setTitleFontSizes( int titleFontSize, int subTitleFontSize );
void setLegendFontSize( int legendFontSize );
void setAxisFontSizes( int axisTitleFontSize, int axisValueFontSize );
void setSubTitlesVisible( bool visible );
bool previewModeEnabled() const;
@ -142,6 +143,12 @@ protected:
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
caf::PdmPointer<RimPlotWindow> m_plotDefinition;
int m_titleFontPixelSize;
int m_subTitleFontPixelSize;
int m_legendFontPixelSize;
int m_axisTitleFontPixelSize;
int m_axisValueFontPixelSize;
bool m_previewMode;
bool m_showSubTitles;

View File

@ -56,10 +56,11 @@ void RiuQwtPlotTools::setCommonPlotBehaviour( QwtPlot* plot )
gridPen.setColor( Qt::lightGray );
grid->setPen( gridPen );
int fontSize = RiaApplication::instance()->preferences()->defaultPlotFontSize();
// Axis number font
QFont axisFont = plot->axisFont( QwtPlot::xBottom );
axisFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( fontSize ) );
int axisFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(),
caf::FontTools::RelativeSize::Medium );
QFont axisFont = plot->axisFont( QwtPlot::xBottom );
axisFont.setPixelSize( caf::FontTools::pointSizeToPixelSize( axisFontSize ) );
plot->setAxisFont( QwtPlot::xBottom, axisFont );
plot->setAxisFont( QwtPlot::xTop, axisFont );
@ -73,7 +74,7 @@ void RiuQwtPlotTools::setCommonPlotBehaviour( QwtPlot* plot )
{
QwtText axisTitle = plot->axisTitle( axis );
QFont axisTitleFont = axisTitle.font();
axisTitleFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( fontSize ) );
axisTitleFont.setPixelSize( caf::FontTools::pointSizeToPixelSize( axisFontSize ) );
axisTitleFont.setBold( false );
axisTitle.setFont( axisTitleFont );
axisTitle.setRenderFlags( Qt::AlignRight );

View File

@ -165,21 +165,21 @@ int RiuQwtPlotWidget::axisValueFontSize( QwtPlot::Axis axis ) const
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setAxisFontsAndAlignment( QwtPlot::Axis axis,
int titleFontSize,
int valueFontSize,
int titleFontPixelSize,
int valueFontPixelSize,
bool titleBold,
int alignment )
{
// Axis number font
QFont axisFont = this->axisFont( axis );
axisFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( valueFontSize ) );
axisFont.setPixelSize( valueFontPixelSize );
axisFont.setBold( false );
this->setAxisFont( axis, axisFont );
// Axis title font
QwtText axisTitle = this->axisTitle( axis );
QFont axisTitleFont = axisTitle.font();
axisTitleFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( titleFontSize ) );
axisTitleFont.setPixelSize( titleFontPixelSize );
axisTitleFont.setBold( titleBold );
axisTitle.setFont( axisTitleFont );
axisTitle.setRenderFlags( alignment | Qt::TextWordWrap );
@ -247,7 +247,7 @@ void RiuQwtPlotWidget::setPlotTitleFontSize( int titleFontSize )
{
auto title = this->title();
QFont font = title.font();
font.setPixelSize( RiaFontCache::pointSizeToPixelSize( titleFontSize ) );
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( titleFontSize ) );
title.setFont( font );
setTitle( title );
}
@ -260,7 +260,7 @@ void RiuQwtPlotWidget::setLegendFontSize( int fontSize )
if ( legend() )
{
QFont font = legend()->font();
font.setPixelSize( RiaFontCache::pointSizeToPixelSize( fontSize ) );
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( fontSize ) );
legend()->setFont( font );
// Set font size for all existing labels
QList<QwtLegendLabel*> labels = legend()->findChildren<QwtLegendLabel*>();
@ -1074,7 +1074,7 @@ void RiuQwtPlotWidget::highlightPlotItem( const QwtPlotItem* closestItem )
symbol->setPen( blendedSymbolLineColor, symbol->pen().width(), symbol->pen().style() );
}
}
CurveColors curveColors = { curveColor, symbolColor, symbolLineColor };
CurveColors curveColors = {curveColor, symbolColor, symbolLineColor};
m_originalCurveColors.insert( std::make_pair( plotCurve, curveColors ) );
m_originalCurveColors.insert( std::make_pair( plotCurve, curveColors ) );
m_originalZValues.insert( std::make_pair( plotCurve, zValue ) );

View File

@ -72,8 +72,8 @@ public:
int axisTitleFontSize( QwtPlot::Axis axis ) const;
int axisValueFontSize( QwtPlot::Axis axis ) const;
void setAxisFontsAndAlignment( QwtPlot::Axis,
int titleFontSize,
int valueFontSize,
int titleFontPixelSize,
int valueFontPixelSize,
bool titleBold = false,
int alignment = (int)Qt::AlignRight );

View File

@ -32,7 +32,7 @@ RiuQwtSymbol::RiuQwtSymbol( PointSymbolEnum riuStyle, const QString& label, Labe
: QwtSymbol( QwtSymbol::NoSymbol )
, m_globalLabel( label )
, m_labelPosition( labelPosition )
, m_labelFontSizePx( RiaFontCache::pointSizeToPixelSize( labelFontSizePt ) )
, m_labelFontSizePx( caf::FontTools::pointSizeToPixelSize( labelFontSizePt ) )
{
QwtSymbol::Style style = QwtSymbol::NoSymbol;

View File

@ -97,7 +97,9 @@ RiuViewer::RiuViewer( const QGLFormat& format, QWidget* parent )
{
cvf::Font* standardFont = RiaGuiApplication::instance()->defaultSceneFont();
QFont font = RiaGuiApplication::instance()->font();
font.setPointSize( RiaGuiApplication::instance()->preferences()->defaultSceneFontSize() );
auto viewFontSize = RiaPreferences::current()->defaultSceneFontSize();
font.setPointSize( caf::FontTools::absolutePointSize( viewFontSize ) );
m_axisCross = new cvf::OverlayAxisCross( m_mainCamera.p(), standardFont );
m_axisCross->setAxisLabels( "X", "Y", "Z" );
@ -206,6 +208,8 @@ RiuViewer::RiuViewer( const QGLFormat& format, QWidget* parent )
m_comparisonWindowMover = new RiuComparisonViewMover( this );
this->setComparisonViewToFollowAnimation( false );
m_fontPointSize = caf::FontTools::absolutePointSize(RiaPreferences::current()->defaultSceneFontSize());
}
//--------------------------------------------------------------------------------------------------
@ -715,7 +719,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner( caf::TitledOverlayFrame* added
addedLegend->enableBackground( preferences->showLegendBackground() );
addedLegend->setBackgroundColor( backgroundColor );
addedLegend->setBackgroundFrameColor( frameColor );
addedLegend->setFont( app->defaultSceneFont() );
addedLegend->setFont( app->sceneFont(m_fontPointSize) );
overlayRendering->addOverlayItem( addedLegend );
@ -908,7 +912,7 @@ void RiuViewer::updateLegendLayout()
const int xPos = width() - (int)scaleLegendSize.x() - margin - edgeAxisBorderWidth;
const int yPos = margin + edgeAxisBorderHeight + margin + otherItemsHeight;
m_scaleLegend->setLayoutFixedPosition( {xPos, yPos} );
m_scaleLegend->setLayoutFixedPosition( { xPos, yPos } );
}
}
@ -1111,15 +1115,17 @@ void RiuViewer::leaveEvent( QEvent* )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::updateGridBoxData( double scaleZ,
const cvf::Vec3d& displayModelOffset,
const cvf::Color3f& backgroundColor,
const cvf::BoundingBox& domainCoordBoundingBox )
void RiuViewer::updateGridBoxData( double scaleZ,
const cvf::Vec3d& displayModelOffset,
const cvf::Color3f& backgroundColor,
const cvf::BoundingBox& domainCoordBoundingBox,
int fontPointSize )
{
m_gridBoxGenerator->setScaleZ( scaleZ );
m_gridBoxGenerator->setDisplayModelOffset( displayModelOffset );
m_gridBoxGenerator->updateFromBackgroundColor( backgroundColor );
m_gridBoxGenerator->setGridBoxDomainCoordBoundingBox( domainCoordBoundingBox );
m_gridBoxGenerator->setGridLabelFontSize(fontPointSize);
m_gridBoxGenerator->createGridBoxParts();
@ -1285,9 +1291,9 @@ void RiuViewer::showScaleLegend( bool show )
if ( show )
{
if ( m_scaleLegend->orientation() == caf::OverlayScaleLegend::HORIZONTAL )
m_scaleLegend->setRenderSize( {280, 45} );
m_scaleLegend->setRenderSize( { 280, 45 } );
else
m_scaleLegend->setRenderSize( {50, 280} );
m_scaleLegend->setRenderSize( { 50, 280 } );
overlayItemsRendering()->addOverlayItem( m_scaleLegend.p() );
}
@ -1316,20 +1322,28 @@ void RiuViewer::clearHoverCursor()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::updateFonts()
void RiuViewer::updateFonts(int fontPointSize)
{
cvf::Font* standardFont = RiaGuiApplication::instance()->defaultSceneFont();
overlayItemsRendering()->removeOverlayItem( m_axisCross.p() );
m_fontPointSize = fontPointSize;
m_axisCross = new cvf::OverlayAxisCross( m_mainCamera.p(), standardFont );
auto defaultFontSize = RiaApplication::instance()->preferences()->defaultSceneFontSize();
cvf::Font* axisFont = RiaGuiApplication::instance()->defaultSceneFont();
QFont font = QApplication::font();
font.setPixelSize( caf::FontTools::pointSizeToPixelSize(m_fontPointSize ));
if ( caf::FontTools::absolutePointSize(defaultFontSize) != m_fontPointSize )
{
axisFont = RiaFontCache::getFont( m_fontPointSize ).p();
}
overlayItemsRendering()->removeOverlayItem( m_axisCross.p() );
m_axisCross = new cvf::OverlayAxisCross( m_mainCamera.p(), axisFont );
m_axisCross->setAxisLabels( "X", "Y", "Z" );
m_axisCross->setLayout( cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_RIGHT );
overlayItemsRendering()->addOverlayItem( m_axisCross.p() );
m_showAxisCross = true;
QFont font = QApplication::font();
font.setPointSize( RiaApplication::instance()->preferences()->defaultSceneFontSize() );
m_zScaleLabel->setFont( font );
m_infoLabel->setFont( font );
m_shortInfoLabel->setFont( font );
@ -1337,6 +1351,8 @@ void RiuViewer::updateFonts()
m_animationProgress->setFont( font );
m_animationProgressCompView->setFont( font );
m_versionInfoLabel->setFont( font );
m_gridBoxGenerator->setGridLabelFontSize(m_fontPointSize);
}
//--------------------------------------------------------------------------------------------------

View File

@ -23,6 +23,7 @@
#include "RiuInterfaceToViewWindow.h"
#include "RiuViewerToViewInterface.h"
#include "cafFontTools.h"
#include "cafMouseState.h"
#include "cafPdmInterfacePointer.h"
#include "cafPdmObject.h"
@ -98,10 +99,11 @@ public:
void setHistogramPercentiles( double pmin, double pmax, double mean );
void showGridBox( bool enable );
void updateGridBoxData( double scaleZ,
const cvf::Vec3d& displayModelOffset,
const cvf::Color3f& backgroundColor,
const cvf::BoundingBox& domainCoordBoundingBox );
void updateGridBoxData( double scaleZ,
const cvf::Vec3d& displayModelOffset,
const cvf::Color3f& backgroundColor,
const cvf::BoundingBox& domainCoordBoundingBox,
int fontPointSize );
void showEdgeTickMarksXY( bool enable, bool showAxisLines = false );
void showEdgeTickMarksXZ( bool enable, bool showAxisLines = false );
@ -136,7 +138,7 @@ public:
static void setHoverCursor( const QCursor& cursor );
static void clearHoverCursor();
void updateFonts();
void updateFonts(int fontPointSize);
public slots:
void slotSetCurrentFrame( int frameIndex ) override;
@ -180,6 +182,7 @@ private:
bool m_showZScaleLabel;
bool m_hideZScaleCheckbox;
double m_zScale;
int m_fontPointSize;
caf::QStyledProgressBar* m_animationProgress;
caf::QStyledProgressBar* m_animationProgressCompView;

View File

@ -56,7 +56,7 @@ target_include_directories(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})
if (MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4127")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W4 /wd4127")
endif()
source_group("" FILES ${PROJECT_FILES})

View File

@ -60,7 +60,7 @@ target_link_libraries ( ${PROJECT_NAME}
)
if (MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4100 /wd4127")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W4 /wd4100 /wd4127")
endif()
source_group("" FILES ${PROJECT_FILES})

View File

@ -56,6 +56,11 @@ public:
template <typename T>
void descendantsIncludingThisOfType(std::vector<T*>& descendants) const;
/// Traverses all children recursively to find objects of the requested type. This object is NOT
/// included if it is of the requested type.
template <typename T>
void descendantsOfType(std::vector<T*>& descendants) const;
// PtrReferences
/// The PdmPtrField's containing pointers to this PdmObjecthandle
/// Use ownerObject() on the fieldHandle to get the PdmObjectHandle
@ -195,6 +200,15 @@ void PdmObjectHandle::descendantsIncludingThisOfType(std::vector<T*>& descendant
descendants.push_back(const_cast<T*>(objectOfType));
}
descendantsOfType(descendants);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
void PdmObjectHandle::descendantsOfType(std::vector<T*>& descendants) const
{
for (auto f : m_fields)
{
std::vector<PdmObjectHandle*> childObjects;

View File

@ -74,6 +74,8 @@ set( PROJECT_FILES
cafQShortenedLabel.h
cafIconProvider.cpp
cafIconProvider.h
cafFontTools.cpp
cafFontTools.h
)
add_library( ${PROJECT_NAME}

View File

@ -0,0 +1,135 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2020- Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cafFontTools.h"
#include "cafAppEnum.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmUiItem.h"
#include <QApplication>
#include <QDesktopWidget>
#include <cmath>
using namespace caf;
template <>
void FontTools::FontSizeEnum::setUp()
{
addItem(FontTools::FontSize::FONT_SIZE_8, "8", "8");
addItem(FontTools::FontSize::FONT_SIZE_10, "10", "10");
addItem(FontTools::FontSize::FONT_SIZE_12, "12", "12");
addItem(FontTools::FontSize::FONT_SIZE_14, "14", "14");
addItem(FontTools::FontSize::FONT_SIZE_16, "16", "16");
addItem(FontTools::FontSize::FONT_SIZE_24, "24", "24");
addItem(FontTools::FontSize::FONT_SIZE_32, "32", "32");
setDefault(FontTools::FontSize::FONT_SIZE_8);
}
template <>
void FontTools::RelativeSizeEnum::setUp()
{
addItem(FontTools::RelativeSize::XXSmall, "XX Small", "XX Small");
addItem(FontTools::RelativeSize::XSmall, "X Small", "X Small");
addItem(FontTools::RelativeSize::Small, "Small", "Small");
addItem(FontTools::RelativeSize::Medium, "Medium", "Medium");
addItem(FontTools::RelativeSize::Large, "Large", "Large");
addItem(FontTools::RelativeSize::XLarge, "X Large", "X Large");
addItem(FontTools::RelativeSize::XXLarge, "XX Large", "XX Large");
setDefault(FontTools::RelativeSize::Medium);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int FontTools::absolutePointSize(FontSize normalPointSize, RelativeSize relativeSize )
{
return static_cast<int>(normalPointSize) + static_cast<int>(relativeSize);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int FontTools::pointSizeToPixelSize( int pointSize )
{
auto app = dynamic_cast<const QApplication*>( QCoreApplication::instance() );
if ( app )
{
int dpi = app->desktop()->logicalDpiX();
double inches = pointSize / 72.0;
return static_cast<int>( std::ceil( inches * dpi ) );
}
return pointSize;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int FontTools::pointSizeToPixelSize(FontSize pointSize)
{
return pointSizeToPixelSize((int) pointSize);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int FontTools::pixelSizeToPointSize( int pixelSize )
{
auto app = dynamic_cast<const QApplication*>( QCoreApplication::instance() );
if ( app )
{
int dpi = app->desktop()->logicalDpiX();
double inches = pixelSize / dpi;
return static_cast<int>( std::ceil( inches * 72.0 ) );
}
return pixelSize;
}
QList<PdmOptionItemInfo> FontTools::relativeSizeValueOptions(FontSize normalPointSize)
{
QList<caf::PdmOptionItemInfo> options;
for (size_t i = 0; i < RelativeSizeEnum::size(); ++i)
{
QString uiText = RelativeSizeEnum::uiTextFromIndex(i);
RelativeSize relSize = RelativeSizeEnum::fromIndex(i);
int absolutePointSize = FontTools::absolutePointSize(normalPointSize, relSize);
uiText += QString(" (%1 pt)").arg(absolutePointSize);
options.push_back(PdmOptionItemInfo(uiText, relSize));
}
return options;
}

View File

@ -0,0 +1,102 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2020- Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include <QList>
namespace caf
{
template <typename T>
class AppEnum;
class PdmOptionItemInfo;
}
namespace caf
{
//==================================================================================================
/// Tools for managing fonts in the application
//==================================================================================================
class FontTools
{
public:
enum class FontSize
{
INVALID = -1,
MIN_FONT_SIZE = 8,
FONT_SIZE_8 = 8,
FONT_SIZE_10 = 10,
FONT_SIZE_12 = 12,
FONT_SIZE_14 = 14,
FONT_SIZE_16 = 16,
FONT_SIZE_24 = 24,
FONT_SIZE_32 = 32,
MAX_FONT_SIZE
};
typedef caf::AppEnum<FontSize> FontSizeEnum;
enum class RelativeSize
{
XXSmall = -4,
XSmall = -2,
Small = -1,
Medium = 0,
Large = +2,
XLarge = +4,
XXLarge = +8
};
typedef caf::AppEnum<RelativeSize> RelativeSizeEnum;
static int absolutePointSize( FontSize normalPointSize, RelativeSize relativeSize = RelativeSize::Medium );
static int pointSizeToPixelSize(FontSize pointSize);
static int pointSizeToPixelSize( int pointSize );
static int pixelSizeToPointSize( int pixelSize );
static QList<caf::PdmOptionItemInfo> relativeSizeValueOptions(FontSize normalPointSize);
};
//==================================================================================================
/// Interface to implement for any PdmObject that has font sizes
//==================================================================================================
class FontHolderInterface
{
public:
virtual int fontSize() const = 0;
virtual void updateFonts() = 0;
};
} // namespace caf