mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
First round of caf::FontTools
This commit is contained in:
@@ -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 );
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user