Split global label size expansion from TextOffset setting

Global label expansion ratio default is now 37.5%
Wire text offset default is now 15%
This commit is contained in:
david-beinder 2021-07-25 13:42:19 +02:00 committed by Jeff Young
parent bab13debcb
commit c34f45f646
13 changed files with 270 additions and 14 deletions

View File

@ -243,7 +243,13 @@ bool PROJECT_FILE::MigrateFromLegacy( wxConfigBase* aCfg )
fromLegacy<int>( aCfg, "JunctionSize", "schematic.drawing.default_junction_size" );
fromLegacyString( aCfg, "FieldNameTemplates", "schematic.drawing.field_names" );
fromLegacy<double>( aCfg, "TextOffsetRatio", "schematic.drawing.text_offset_ratio" );
if( !fromLegacy<double>( 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" ) );

View File

@ -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

View File

@ -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 );
}

View File

@ -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 );

View File

@ -613,6 +613,192 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Global label size:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_labelSizeRatioLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Percentage of the text size to use as space around a global label</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_labelSizeRatioCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxFIXED_MINSIZE</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">%</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_labelSizeRatioUnits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
</object>
</object>
</object>

View File

@ -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;

View File

@ -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;

View File

@ -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 ),

View File

@ -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.

View File

@ -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<const SCH_RENDER_SETTINGS*>( 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<void( SCH_ITEM* )>& 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<wxPoint>& 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;

View File

@ -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):

View File

@ -33,7 +33,7 @@
#include <sim/spice_settings.h>
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<double>( "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<double>( "drawing.label_size_ratio",
&m_LabelSizeRatio, DEFAULT_LABEL_SIZE_RATIO, 0.0, 2.0 ) );
m_params.emplace_back( new PARAM_SCALED<int>( "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<NGSPICE_SIMULATOR_SETTINGS>( this, "ngspice" );
std::make_shared<NGSPICE_SIMULATOR_SETTINGS>( this, "ngspice" );
registerMigration( 0, 1, [&]() -> bool
{
OPT<double> tor = Get<double>( "drawing.text_offset_ratio" );
if( tor.is_initialized() )
Set( "drawing.label_size_ratio", tor.get() );
return true;
} );
}

View File

@ -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