#4256 Update fonts in Project and views when changing preferences

This commit is contained in:
Gaute Lindkvist
2019-04-10 12:49:20 +02:00
parent 0e0d78104b
commit 798e3ff19e
32 changed files with 411 additions and 129 deletions

View File

@@ -22,6 +22,7 @@
#include "RimAnnotationCollection.h"
#include "RimAnnotationGroupCollection.h"
#include "RimAnnotationTextAppearance.h"
#include "RimCase.h"
#include "RimProject.h"
#include "RimGridView.h"
@@ -234,6 +235,46 @@ size_t RimAnnotationInViewCollection::annotationsCount() const
return m_textAnnotations->m_annotations.size() + allGlobalPdmAnnotations().size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimAnnotationInViewCollection::hasTextAnnotationsWithCustomFontSize(RiaFontCache::FontSize defaultFontSize) 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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnnotationInViewCollection::applyFontSizeToAllTextAnnotations(RiaFontCache::FontSize fontSize)
{
for (auto annotation : textAnnotations())
{
annotation->appearance()->setFontSize(fontSize);
}
for (auto annotationInView : globalTextAnnotations())
{
annotationInView->sourceAnnotation()->appearance()->setFontSize(fontSize);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -18,6 +18,7 @@
#pragma once
#include "RiaFontCache.h"
#include "RimAnnotationCollectionBase.h"
#include "cafAppEnum.h"
@@ -59,6 +60,9 @@ public:
void onGlobalCollectionChanged(const RimAnnotationCollection* globalCollection);
size_t annotationsCount() const;
bool hasTextAnnotationsWithCustomFontSize(RiaFontCache::FontSize defaultFontSize) const;
void applyFontSizeToAllTextAnnotations(RiaFontCache::FontSize fontSize);
protected:
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;

View File

@@ -38,7 +38,7 @@ RimAnnotationTextAppearance::RimAnnotationTextAppearance()
auto defaultBackgroundColor = prefs->defaultViewerBackgroundColor();
CAF_PDM_InitFieldNoDefault(&m_fontSize, "FontSize", "Font Size", "", "", "");
m_fontSize = prefs->fontSizeInScene();
m_fontSize = prefs->defaultAnnotationFontSize();
CAF_PDM_InitField(&m_fontColor, "FontColor", cvf::Color3f(cvf::Color3f::BLACK), "Font Color", "", "", "");
CAF_PDM_InitField(&m_backgroundColor, "BackgroundColor", defaultBackgroundColor , "Background Color", "", "", "");