From 04ea20dd442f051cfd8ec6e87365ea2999a9f4fe Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 14 Apr 2020 11:08:42 +0200 Subject: [PATCH] Eeschema, SCH_PAINTER: fix max text thickness issue, to have small texts readable. --- common/dialogs/dialog_text_entry_base.fbp | 326 +++++++++++----------- common/eda_text.cpp | 2 +- eeschema/sch_painter.cpp | 45 ++- eeschema/sch_painter.h | 9 + include/painter.h | 2 +- 5 files changed, 214 insertions(+), 170 deletions(-) diff --git a/common/dialogs/dialog_text_entry_base.fbp b/common/dialogs/dialog_text_entry_base.fbp index 5793ac3e5e..9a9d1d4fc5 100644 --- a/common/dialogs/dialog_text_entry_base.fbp +++ b/common/dialogs/dialog_text_entry_base.fbp @@ -1,8 +1,8 @@ - + - + C++ 1 source_name @@ -16,9 +16,9 @@ none 1 dialog_text_entry_base - + . - + 1 1 1 @@ -29,67 +29,67 @@ 0 wxAUI_MGR_DEFAULT - + wxBOTH - + 1 1 impl_virtual - - - + + + 0 wxID_ANY - - + + WX_TEXT_ENTRY_DIALOG_BASE - + -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + bSizerMain wxVERTICAL none @@ -98,7 +98,7 @@ wxALL|wxEXPAND 1 - + bSizerContent wxVERTICAL none @@ -111,78 +111,78 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY MyLabel - + 0 - - + + 0 - + 1 m_label 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -194,86 +194,86 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - - + + + 0 300,-1 1 m_textCtrl 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -291,17 +291,17 @@ 1 0 0 - + m_sdbSizer1 protected - - - - - - - - + + + + + + + + diff --git a/common/eda_text.cpp b/common/eda_text.cpp index fe42b39862..4d90b74c91 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -149,7 +149,7 @@ int EDA_TEXT::GetEffectiveTextPenWidth( RENDER_SETTINGS* aSettings ) const width = GetPenSizeForBold( GetTextWidth() ); if( width <= 0 && aSettings ) - width = aSettings->GetDefaultPenWidth(); + width = aSettings->GetDefaultTextThickness(); // Clip pen size for small texts: width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() ); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 68c76c9bb5..ebc222440d 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -78,7 +78,9 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() : m_DefaultLineWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ), m_DefaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ), m_DefaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS ) -{ } +{ + m_defaultPenWidth = m_DefaultLineWidth; +} void SCH_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings ) @@ -340,6 +342,39 @@ float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows } +float SCH_PAINTER::getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadows ) +{ + float width = (float) aItem->GetEffectiveTextPenWidth( &m_schSettings ); + + if( aItem->IsSelected() && aDrawingShadows ) + width += getShadowWidth(); + + return width; +} + + +float SCH_PAINTER::getTextThickness( const LIB_FIELD* aItem, bool aDrawingShadows ) +{ + float width = (float) aItem->GetEffectiveTextPenWidth( &m_schSettings ); + + if( aItem->IsSelected() && aDrawingShadows ) + width += getShadowWidth(); + + return width; +} + + +float SCH_PAINTER::getTextThickness( const LIB_TEXT* aItem, bool aDrawingShadows ) +{ + float width = (float) aItem->GetEffectiveTextPenWidth( &m_schSettings ); + + if( aItem->IsSelected() && aDrawingShadows ) + width += getShadowWidth(); + + return width; +} + + void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition, double aAngle ) { m_gal->StrokeText( aText, aPosition, aAngle, GetTextMarkupFlags() ); @@ -572,7 +607,7 @@ void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer ) return; } - m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) ); + m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) ); m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetStrokeColor( color ); @@ -641,7 +676,7 @@ void SCH_PAINTER::draw( LIB_TEXT *aText, int aLayer ) m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); - m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) ); + m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) ); m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetStrokeColor( color ); @@ -1243,7 +1278,7 @@ void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer ) m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); - m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) ); + m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) ); m_gal->SetStrokeColor( color ); m_gal->SetTextAttributes( aText ); @@ -1441,7 +1476,6 @@ void SCH_PAINTER::draw( SCH_FIELD *aField, int aLayer ) m_gal->SetStrokeColor( color ); m_gal->SetIsStroke( true ); - m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) ); if( drawingShadows && eeconfig()->m_Selection.text_as_box ) { @@ -1462,6 +1496,7 @@ void SCH_PAINTER::draw( SCH_FIELD *aField, int aLayer ) m_gal->SetFontBold( aField->IsBold() ); m_gal->SetFontItalic( aField->IsItalic() ); m_gal->SetTextMirrored( aField->IsMirrored() ); + m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) ); strokeText( aField->GetShownText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI / 2 : 0 ); } diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index f2ddd966ee..9409d62d59 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -99,6 +99,12 @@ public: const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_SCHEMATIC_CURSOR ]; } + int GetDefaultTextThickness() const override + { + return m_DefaultLineWidth; + } + + int m_ShowUnit; // Show all units if 0 int m_ShowConvert; // Show all conversions if 0 @@ -173,6 +179,9 @@ private: float getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows ); float getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ); float getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows ); + float getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadows ); + float getTextThickness( const LIB_FIELD* aItem, bool aDrawingShadows ); + float getTextThickness( const LIB_TEXT* aItem, bool aDrawingShadows ); bool setDeviceColors( const LIB_ITEM* aItem, int aLayer ); void fillIfSelection( int aLayer ); diff --git a/include/painter.h b/include/painter.h index 4248e617b8..c0c0da7fdc 100644 --- a/include/painter.h +++ b/include/painter.h @@ -159,7 +159,7 @@ public: float GetWorksheetLineWidth() const { return m_worksheetLineWidth; } - int GetDefaultPenWidth() const { return m_defaultPenWidth; } + virtual int GetDefaultTextThickness() const { return m_defaultPenWidth; } int GetTextMarkupFlags() const { return m_textMarkupFlags; } bool GetShowPageLimits() const { return m_showPageLimits; }