mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3997 Use AppEnum for font size in preferences as well so it is more easily shared.
This commit is contained in:
@@ -1857,36 +1857,7 @@ void RiaApplication::applyPreferences()
|
||||
mainPlotWindow()->projectTreeView()->enableAppendOfClassNameToUiItemText(m_preferences->appendClassNameToUiText());
|
||||
}
|
||||
|
||||
RiaFontCache::FontSize fontSizeType = RiaFontCache::FONT_SIZE_16;
|
||||
if (m_preferences->fontSizeInScene() == "8")
|
||||
{
|
||||
fontSizeType = RiaFontCache::FONT_SIZE_8;
|
||||
}
|
||||
else if (m_preferences->fontSizeInScene() == "10")
|
||||
{
|
||||
fontSizeType = RiaFontCache::FONT_SIZE_10;
|
||||
}
|
||||
else if (m_preferences->fontSizeInScene() == "12")
|
||||
{
|
||||
fontSizeType = RiaFontCache::FONT_SIZE_12;
|
||||
}
|
||||
else if (m_preferences->fontSizeInScene() == "14")
|
||||
{
|
||||
fontSizeType = RiaFontCache::FONT_SIZE_14;
|
||||
}
|
||||
else if (m_preferences->fontSizeInScene() == "16")
|
||||
{
|
||||
fontSizeType = RiaFontCache::FONT_SIZE_16;
|
||||
}
|
||||
else if (m_preferences->fontSizeInScene() == "24")
|
||||
{
|
||||
fontSizeType = RiaFontCache::FONT_SIZE_24;
|
||||
}
|
||||
else if (m_preferences->fontSizeInScene() == "32")
|
||||
{
|
||||
fontSizeType = RiaFontCache::FONT_SIZE_32;
|
||||
}
|
||||
|
||||
RiaFontCache::FontSize fontSizeType = m_preferences->fontSizeInScene();
|
||||
m_customFont = RiaFontCache::getFont(fontSizeType);
|
||||
|
||||
if (this->project())
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "cvfObject.h"
|
||||
#include "cvfFont.h"
|
||||
|
||||
#include "RiaFontCache.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
@@ -90,6 +92,8 @@ public:
|
||||
PLA_CALCULATE_STATISTICS = 1
|
||||
};
|
||||
|
||||
typedef RiaFontCache::FontSize FontSize;
|
||||
|
||||
public:
|
||||
RiaApplication(int& argc, char** argv);
|
||||
~RiaApplication() override;
|
||||
|
||||
@@ -18,6 +18,52 @@
|
||||
|
||||
#include "RiaFontCache.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafFixedAtlasFont.h"
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::FixedAtlasFont::FontSize mapToAtlasFontSize(RiaFontCache::FontSize fontSize)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -35,21 +81,3 @@ cvf::ref<caf::FixedAtlasFont> RiaFontCache::getFont(FontSize size)
|
||||
}
|
||||
return ms_fonts[size];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::FixedAtlasFont::FontSize RiaFontCache::mapToAtlasFontSize(FontSize fontSize)
|
||||
{
|
||||
switch (fontSize)
|
||||
{
|
||||
case FONT_SIZE_8: return caf::FixedAtlasFont::POINT_SIZE_8;
|
||||
case FONT_SIZE_10: return caf::FixedAtlasFont::POINT_SIZE_10;
|
||||
case FONT_SIZE_12: return caf::FixedAtlasFont::POINT_SIZE_12;
|
||||
case FONT_SIZE_14: return caf::FixedAtlasFont::POINT_SIZE_14;
|
||||
case FONT_SIZE_16: return caf::FixedAtlasFont::POINT_SIZE_16;
|
||||
case FONT_SIZE_24: return caf::FixedAtlasFont::POINT_SIZE_24;
|
||||
case FONT_SIZE_32: return caf::FixedAtlasFont::POINT_SIZE_32;
|
||||
default: return caf::FixedAtlasFont::POINT_SIZE_16;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cvfBase.h>
|
||||
#include <cafFixedAtlasFont.h>
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class FixedAtlasFont;
|
||||
template<typename T> class AppEnum;
|
||||
}
|
||||
|
||||
class RimSummaryCaseCollection;
|
||||
|
||||
//==================================================================================================
|
||||
@@ -42,10 +48,10 @@ public:
|
||||
FONT_SIZE_32
|
||||
};
|
||||
|
||||
typedef caf::AppEnum<FontSize> FontSizeType;
|
||||
|
||||
static cvf::ref<caf::FixedAtlasFont> getFont(FontSize size);
|
||||
|
||||
private:
|
||||
static caf::FixedAtlasFont::FontSize mapToAtlasFontSize(FontSize fontSize);
|
||||
|
||||
static std::map<FontSize, cvf::ref<caf::FixedAtlasFont>> ms_fonts;
|
||||
};
|
||||
|
||||
@@ -72,7 +72,7 @@ RiaPreferences::RiaPreferences(void)
|
||||
CAF_PDM_InitField(&defaultViewerBackgroundColor, "defaultViewerBackgroundColor", cvf::Color3f(0.69f, 0.77f, 0.87f), "Viewer Background", "", "The viewer background color for new views", "");
|
||||
|
||||
CAF_PDM_InitField(&defaultScaleFactorZ, "defaultScaleFactorZ", 5, "Default Z Scale Factor", "", "", "");
|
||||
CAF_PDM_InitField(&fontSizeInScene, "fontSizeInScene", QString("8"), "Font Size", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&fontSizeInScene, "fontSizeInScene", "Font Size", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&showLasCurveWithoutTvdWarning, "showLasCurveWithoutTvdWarning", true, "Show LAS Curve Without TVD Warning", "", "", "");
|
||||
showLasCurveWithoutTvdWarning.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
@@ -249,23 +249,7 @@ QList<caf::PdmOptionItemInfo> RiaPreferences::calculateValueOptions(const caf::P
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
*useOptionsOnly = true;
|
||||
|
||||
if (&fontSizeInScene == fieldNeedingOptions)
|
||||
{
|
||||
QStringList fontSizes;
|
||||
fontSizes << "8";
|
||||
fontSizes << "10";
|
||||
fontSizes << "12";
|
||||
fontSizes << "14";
|
||||
fontSizes << "16";
|
||||
fontSizes << "24";
|
||||
fontSizes << "32";
|
||||
|
||||
for (int oIdx = 0; oIdx < fontSizes.size(); ++oIdx)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(fontSizes[oIdx], fontSizes[oIdx]));
|
||||
}
|
||||
}
|
||||
else if (fieldNeedingOptions == &gridImportMode)
|
||||
if (fieldNeedingOptions == &gridImportMode)
|
||||
{
|
||||
// Manual option handling in order to one only a subset of the enum values
|
||||
SummaryRestartFilesImportModeType skip(RiaPreferences::NOT_IMPORT);
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RiaFontCache.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
@@ -39,6 +41,7 @@ class RiaPreferences : public caf::PdmObject
|
||||
public:
|
||||
enum SummaryRestartFilesImportMode { IMPORT, NOT_IMPORT, SEPARATE_CASES };
|
||||
typedef caf::AppEnum<SummaryRestartFilesImportMode> SummaryRestartFilesImportModeType;
|
||||
typedef RiaFontCache::FontSizeType FontSizeType;
|
||||
|
||||
RiaPreferences(void);
|
||||
~RiaPreferences(void) override;
|
||||
@@ -72,7 +75,7 @@ public: // Pdm Fields
|
||||
caf::PdmField<cvf::Color3f> defaultViewerBackgroundColor;
|
||||
caf::PdmField<cvf::Color3f> defaultWellLabelColor;
|
||||
caf::PdmField<bool> showLasCurveWithoutTvdWarning;
|
||||
caf::PdmField<QString> fontSizeInScene;
|
||||
caf::PdmField<FontSizeType> fontSizeInScene;
|
||||
caf::PdmField<bool> showLegendBackground;
|
||||
|
||||
caf::PdmField<bool> useShaders;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "RimContourMapProjection.h"
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cafFixedAtlasFont.h"
|
||||
|
||||
#include "cvfCamera.h"
|
||||
#include "cvfDrawableText.h"
|
||||
|
||||
@@ -39,6 +39,10 @@
|
||||
#include "RivReachCircleAnnotationPartMgr.h"
|
||||
#include "RivTextAnnotationPartMgr.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cafFixedAtlasFont.h"
|
||||
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfDrawableText.h"
|
||||
@@ -48,9 +52,6 @@
|
||||
#include "cvfRenderStatePoint.h"
|
||||
#include "cvfqtUtils.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafEffectGenerator.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafFixedAtlasFont.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfDrawableText.h"
|
||||
|
||||
@@ -27,24 +27,6 @@
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimAnnotationTextAppearance, "RimAnnotationTextAppearance");
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template<>
|
||||
void RimAnnotationTextAppearance::FontSize::setUp()
|
||||
{
|
||||
addItem(RiaFontCache::FONT_SIZE_8, "FONT_SIZE_8", "8");
|
||||
addItem(RiaFontCache::FONT_SIZE_10, "FONT_SIZE_10", "10");
|
||||
addItem(RiaFontCache::FONT_SIZE_12, "FONT_SIZE_12", "12");
|
||||
addItem(RiaFontCache::FONT_SIZE_14, "FONT_SIZE_14", "14");
|
||||
addItem(RiaFontCache::FONT_SIZE_16, "FONT_SIZE_16", "16");
|
||||
addItem(RiaFontCache::FONT_SIZE_24, "FONT_SIZE_24", "24");
|
||||
addItem(RiaFontCache::FONT_SIZE_32, "FONT_SIZE_32", "32");
|
||||
|
||||
setDefault(RiaFontCache::FONT_SIZE_8);
|
||||
}
|
||||
} // namespace caf
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -55,7 +37,9 @@ RimAnnotationTextAppearance::RimAnnotationTextAppearance()
|
||||
auto prefs = RiaApplication::instance()->preferences();
|
||||
auto defaultBackgroundColor = prefs->defaultViewerBackgroundColor();
|
||||
|
||||
CAF_PDM_InitField(&m_fontSize, "FontSize", FontSize(), "Font Size", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_fontSize, "FontSize", "Font Size", "", "", "");
|
||||
m_fontSize = prefs->fontSizeInScene();
|
||||
|
||||
CAF_PDM_InitField(&m_fontColor, "FontColor", cvf::Color3f(cvf::Color3f::BLACK), "Font Color", "", "", "");
|
||||
CAF_PDM_InitField(&m_backgroundColor, "BackgroundColor", defaultBackgroundColor , "Background Color", "", "", "");
|
||||
CAF_PDM_InitField(&m_anchorLineColor, "AnchorLineColor", cvf::Color3f(cvf::Color3f::BLACK), "Anchor Line Color", "", "", "");
|
||||
|
||||
Reference in New Issue
Block a user