diff --git a/common/project/project_file.cpp b/common/project/project_file.cpp index 45ab036756..bc8caade42 100644 --- a/common/project/project_file.cpp +++ b/common/project/project_file.cpp @@ -243,7 +243,13 @@ bool PROJECT_FILE::MigrateFromLegacy( wxConfigBase* aCfg ) fromLegacy( aCfg, "JunctionSize", "schematic.drawing.default_junction_size" ); fromLegacyString( aCfg, "FieldNameTemplates", "schematic.drawing.field_names" ); - fromLegacy( aCfg, "TextOffsetRatio", "schematic.drawing.text_offset_ratio" ); + + if( !fromLegacy( aCfg, "TextOffsetRatio", "schematic.drawing.text_offset_ratio" ) ) + { + // Use the spacing of Eeschema V5 + Set( "schematic.drawing.text_offset_ratio", 0.08 ); + Set( "schematic.drawing.label_size_ratio", 0.25 ); + } // All schematic_editor keys we keep are migrated above group_blacklist.insert( wxT( "/schematic_editor" ) ); diff --git a/eeschema/default_values.h b/eeschema/default_values.h index 3b109f7490..7a5b4c905c 100644 --- a/eeschema/default_values.h +++ b/eeschema/default_values.h @@ -26,10 +26,9 @@ #define DEFAULT_VALUES_H +///< The size of the rectangle indicating an unconnected wire or label #define DANGLING_SYMBOL_SIZE 12 -#define TXT_MARGIN 15 - ///< The default pin len value when creating pins(can be changed in preference menu) #define DEFAULT_PIN_LENGTH 100 @@ -64,7 +63,10 @@ #define DEFAULT_TEXT_SIZE 50 ///< Ratio of the font height to the baseline of the text above the wire. -#define DEFAULT_TEXT_OFFSET_RATIO 0.08 +#define DEFAULT_TEXT_OFFSET_RATIO 0.15 + +///< Ratio of the font height to space around global labels +#define DEFAULT_LABEL_SIZE_RATIO 0.375 ///< The offset of the pin name string from the end of the pin in mils. #define DEFAULT_PIN_NAME_OFFSET 20 diff --git a/eeschema/dialogs/panel_setup_formatting.cpp b/eeschema/dialogs/panel_setup_formatting.cpp index 54d1b9a54a..642d081329 100644 --- a/eeschema/dialogs/panel_setup_formatting.cpp +++ b/eeschema/dialogs/panel_setup_formatting.cpp @@ -96,6 +96,9 @@ bool PANEL_SETUP_FORMATTING::TransferDataToWindow() wxString offsetRatio = wxString::Format( "%f", settings.m_TextOffsetRatio * 100.0 ); m_textOffsetRatioCtrl->SetValue( offsetRatio ); + wxString labelSizeRatio = wxString::Format( "%f", settings.m_LabelSizeRatio * 100.0 ); + m_labelSizeRatioCtrl->SetValue( labelSizeRatio ); + return true; } @@ -165,12 +168,16 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow() settings.m_IntersheetRefsSuffix = m_suffixCtrl->GetValue(); settings.m_IntersheetRefsListOwnPage = m_listOwnPage->GetValue(); - double dtmp = 0.0; - wxString msg = m_textOffsetRatioCtrl->GetValue(); - msg.ToDouble( &dtmp ); + double dtmp = DEFAULT_TEXT_OFFSET_RATIO; + m_textOffsetRatioCtrl->GetValue().ToDouble( &dtmp ); settings.m_TextOffsetRatio = dtmp / 100.0; + dtmp = DEFAULT_LABEL_SIZE_RATIO; + m_labelSizeRatioCtrl->GetValue().ToDouble( &dtmp ); + settings.m_LabelSizeRatio = dtmp / 100.0; + m_frame->GetRenderSettings()->SetDefaultPenWidth( settings.m_DefaultLineWidth ); + m_frame->GetRenderSettings()->m_LabelSizeRatio = settings.m_LabelSizeRatio; m_frame->GetRenderSettings()->m_TextOffsetRatio = settings.m_TextOffsetRatio; m_frame->GetRenderSettings()->m_PinSymbolSize = settings.m_PinSymbolSize; m_frame->GetRenderSettings()->m_JunctionSize = settings.m_JunctionSize; @@ -198,4 +205,7 @@ void PANEL_SETUP_FORMATTING::ImportSettingsFrom( SCHEMATIC_SETTINGS& aSettings ) wxString offsetRatio = wxString::Format( "%f", aSettings.m_TextOffsetRatio * 100.0 ); m_textOffsetRatioCtrl->SetValue( offsetRatio ); + + wxString labelSizeRatio = wxString::Format( "%f", aSettings.m_LabelSizeRatio * 100.0 ); + m_labelSizeRatioCtrl->SetValue( labelSizeRatio ); } diff --git a/eeschema/dialogs/panel_setup_formatting_base.cpp b/eeschema/dialogs/panel_setup_formatting_base.cpp index f7bfd8c2c9..b1d1e0bc88 100644 --- a/eeschema/dialogs/panel_setup_formatting_base.cpp +++ b/eeschema/dialogs/panel_setup_formatting_base.cpp @@ -76,6 +76,19 @@ PANEL_SETUP_FORMATTING_BASE::PANEL_SETUP_FORMATTING_BASE( wxWindow* parent, wxWi m_offsetRatioUnits->Wrap( -1 ); fgSizer2->Add( m_offsetRatioUnits, 0, wxALIGN_CENTER_VERTICAL|wxFIXED_MINSIZE, 5 ); + m_labelSizeRatioLabel = new wxStaticText( sbSizer4->GetStaticBox(), wxID_ANY, _("Global label size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_labelSizeRatioLabel->Wrap( -1 ); + m_labelSizeRatioLabel->SetToolTip( _("Percentage of the text size to use as space around a global label") ); + + fgSizer2->Add( m_labelSizeRatioLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_labelSizeRatioCtrl = new wxTextCtrl( sbSizer4->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer2->Add( m_labelSizeRatioCtrl, 0, wxEXPAND, 5 ); + + m_labelSizeRatioUnits = new wxStaticText( sbSizer4->GetStaticBox(), wxID_ANY, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); + m_labelSizeRatioUnits->Wrap( -1 ); + fgSizer2->Add( m_labelSizeRatioUnits, 0, wxALIGN_CENTER_VERTICAL|wxFIXED_MINSIZE, 5 ); + sbSizer4->Add( fgSizer2, 1, wxALL|wxEXPAND, 5 ); diff --git a/eeschema/dialogs/panel_setup_formatting_base.fbp b/eeschema/dialogs/panel_setup_formatting_base.fbp index da666319f0..9af375d92f 100644 --- a/eeschema/dialogs/panel_setup_formatting_base.fbp +++ b/eeschema/dialogs/panel_setup_formatting_base.fbp @@ -613,6 +613,192 @@ -1 + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Global label size: + 0 + + 0 + + + 0 + + 1 + m_labelSizeRatioLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Percentage of the text size to use as space around a global label + + + + -1 + + + + 5 + wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_labelSizeRatioCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxFIXED_MINSIZE + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + % + 0 + + 0 + + + 0 + + 1 + m_labelSizeRatioUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + diff --git a/eeschema/dialogs/panel_setup_formatting_base.h b/eeschema/dialogs/panel_setup_formatting_base.h index bb2cb1b999..c6c8f3d235 100644 --- a/eeschema/dialogs/panel_setup_formatting_base.h +++ b/eeschema/dialogs/panel_setup_formatting_base.h @@ -47,6 +47,9 @@ class PANEL_SETUP_FORMATTING_BASE : public wxPanel wxStaticText* m_textOffsetRatioLabel; wxTextCtrl* m_textOffsetRatioCtrl; wxStaticText* m_offsetRatioUnits; + wxStaticText* m_labelSizeRatioLabel; + wxTextCtrl* m_labelSizeRatioCtrl; + wxStaticText* m_labelSizeRatioUnits; wxStaticText* m_lineWidthLabel; wxTextCtrl* m_lineWidthCtrl; wxStaticText* m_lineWidthUnits; diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index c4e275ac3a..46d7d000b2 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -80,6 +80,7 @@ bool SCH_EDIT_FRAME::LoadProjectSettings() GetRenderSettings()->SetDefaultPenWidth( m_defaults->m_DefaultLineWidth ); GetRenderSettings()->m_DefaultWireThickness = m_defaults->m_DefaultWireThickness; GetRenderSettings()->m_DefaultBusThickness = m_defaults->m_DefaultBusThickness; + GetRenderSettings()->m_LabelSizeRatio = m_defaults->m_LabelSizeRatio; GetRenderSettings()->m_TextOffsetRatio = m_defaults->m_TextOffsetRatio; GetRenderSettings()->m_PinSymbolSize = m_defaults->m_PinSymbolSize; GetRenderSettings()->m_JunctionSize = m_defaults->m_JunctionSize; diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 4a3cf4ec64..3268d7bb77 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -79,7 +79,8 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() : m_ShowGraphicsDisabled( false ), m_ShowUmbilicals( true ), m_OverrideItemColors( false ), - m_TextOffsetRatio( 0.08 ), + m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ), + m_TextOffsetRatio( DEFAULT_TEXT_OFFSET_RATIO ), m_DefaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ), m_DefaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS ), m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ), diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 248e5383e6..5bcf980d9a 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -117,6 +117,7 @@ public: bool m_OverrideItemColors; + double m_LabelSizeRatio; // Proportion of font size to label box double m_TextOffsetRatio; // Proportion of font size to offset text above/below // wires, buses, etc. diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 41b63dfc7b..86abff0418 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -408,6 +408,23 @@ int SCH_TEXT::GetTextOffset( const RENDER_SETTINGS* aSettings ) const } +int SCH_TEXT::GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings ) const +{ + double ratio; + + if( aSettings ) + ratio = static_cast( aSettings )->m_LabelSizeRatio; + else if( Schematic() ) + ratio = Schematic()->Settings().m_LabelSizeRatio; + else + ratio = DEFAULT_LABEL_SIZE_RATIO; // For previews (such as in Preferences), etc. + + return KiROUND( ratio * GetTextSize().y ); + + return 0; +} + + int SCH_TEXT::GetPenWidth() const { return GetEffectiveTextPenWidth(); @@ -994,7 +1011,7 @@ void SCH_GLOBALLABEL::RunOnChildren( const std::function& aFu wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const { - int horiz = GetTextOffset( aSettings ); + int horiz = GetLabelBoxExpansion( aSettings ); // Center the text on the center line of "E" instead of "R" to make room for an overbar int vert = GetTextHeight() * 0.0715; @@ -1310,7 +1327,7 @@ void SCH_GLOBALLABEL::Plot( PLOTTER* aPlotter ) const void SCH_GLOBALLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings, std::vector& aPoints, const wxPoint& Pos ) const { - int margin = GetTextOffset( aRenderSettings ); + int margin = GetLabelBoxExpansion( aRenderSettings ); int halfSize = ( GetTextHeight() / 2 ) + margin; int linewidth = GetPenWidth(); int symb_len = LenSize( GetShownText(), linewidth ) + 2 * margin; diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index b94708b618..7392891ebd 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -192,6 +192,8 @@ public: int GetTextOffset( const RENDER_SETTINGS* aSettings = nullptr ) const; + int GetLabelBoxExpansion( const RENDER_SETTINGS* aSettings = nullptr ) const; + int GetPenWidth() const override; // Geometric transforms (used in block operations): diff --git a/eeschema/schematic_settings.cpp b/eeschema/schematic_settings.cpp index 25967b8791..0dc87840cb 100644 --- a/eeschema/schematic_settings.cpp +++ b/eeschema/schematic_settings.cpp @@ -33,7 +33,7 @@ #include -const int schSettingsSchemaVersion = 0; +const int schSettingsSchemaVersion = 1; SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) : @@ -42,6 +42,7 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin m_DefaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ), m_DefaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS ), m_DefaultTextSize( DEFAULT_TEXT_SIZE * IU_PER_MILS ), + m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ), m_TextOffsetRatio( DEFAULT_TEXT_OFFSET_RATIO ), m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ), m_JunctionSize( DEFAULT_JUNCTION_DIAM * IU_PER_MILS ), @@ -115,8 +116,10 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin 1 / IU_PER_MILS ) ); m_params.emplace_back( new PARAM( "drawing.text_offset_ratio", - &m_TextOffsetRatio, - (double) TXT_MARGIN / DEFAULT_SIZE_TEXT, -200.0, 200.0 ) ); + &m_TextOffsetRatio, DEFAULT_TEXT_OFFSET_RATIO, 0.0, 2.0 ) ); + + m_params.emplace_back( new PARAM( "drawing.label_size_ratio", + &m_LabelSizeRatio, DEFAULT_LABEL_SIZE_RATIO, 0.0, 2.0 ) ); m_params.emplace_back( new PARAM_SCALED( "drawing.pin_symbol_size", &m_PinSymbolSize, @@ -217,7 +220,17 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin &m_AnnotateStartNum, 0 ) ); m_NgspiceSimulatorSettings = - std::make_shared( this, "ngspice" ); + std::make_shared( this, "ngspice" ); + + registerMigration( 0, 1, [&]() -> bool + { + OPT tor = Get( "drawing.text_offset_ratio" ); + + if( tor.is_initialized() ) + Set( "drawing.label_size_ratio", tor.get() ); + + return true; + } ); } diff --git a/eeschema/schematic_settings.h b/eeschema/schematic_settings.h index 91a949e0bf..62b84a888d 100644 --- a/eeschema/schematic_settings.h +++ b/eeschema/schematic_settings.h @@ -48,6 +48,7 @@ public: int m_DefaultWireThickness; int m_DefaultBusThickness; int m_DefaultTextSize; + double m_LabelSizeRatio; double m_TextOffsetRatio; int m_PinSymbolSize; int m_JunctionSize; // Size of junction dot in mils