Add a user-defined ratio for text offset from wire/bus.
Fixes https://gitlab.com/kicad/code/kicad/issues/2392
This commit is contained in:
parent
026d5c699f
commit
40b2eabfc1
|
@ -68,6 +68,8 @@ bool PANEL_SETUP_FORMATTING::TransferDataToWindow()
|
|||
m_wireWidth.SetValue( GetDefaultWireThickness() );
|
||||
m_junctionSize.SetValue( SCH_JUNCTION::g_SymbolSize );
|
||||
|
||||
m_textOffsetRatioCtrl->SetValue( wxString::Format( "%f", GetTextOffsetRatio() * 100.0 ) );
|
||||
|
||||
int superSubFlags = ENABLE_SUBSCRIPT_MARKUP | ENABLE_SUPERSCRIPT_MARKUP;
|
||||
m_checkSuperSub->SetValue( GetTextMarkupFlags() & superSubFlags );
|
||||
|
||||
|
@ -104,6 +106,11 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow()
|
|||
SetDefaultWireThickness( m_wireWidth.GetValue() );
|
||||
SCH_JUNCTION::g_SymbolSize = m_junctionSize.GetValue();
|
||||
|
||||
double dtmp = 0.0;
|
||||
wxString msg = m_textOffsetRatioCtrl->GetValue();
|
||||
msg.ToDouble( &dtmp );
|
||||
SetTextOffsetRatio( dtmp / 100.0 );
|
||||
|
||||
int superSubFlags = ENABLE_SUBSCRIPT_MARKUP | ENABLE_SUPERSCRIPT_MARKUP;
|
||||
|
||||
if( m_checkSuperSub->GetValue() )
|
||||
|
|
|
@ -59,6 +59,19 @@ PANEL_SETUP_FORMATTING_BASE::PANEL_SETUP_FORMATTING_BASE( wxWindow* parent, wxWi
|
|||
m_textSizeUnits->Wrap( -1 );
|
||||
fgSizer2->Add( m_textSizeUnits, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_textOffsetRatioLabel = new wxStaticText( sbSizer4->GetStaticBox(), wxID_ANY, _("Text offset ratio:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_textOffsetRatioLabel->Wrap( -1 );
|
||||
m_textOffsetRatioLabel->SetToolTip( _("Percentage of the text size to offset text above or below wire or bus") );
|
||||
|
||||
fgSizer2->Add( m_textOffsetRatioLabel, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_textOffsetRatioCtrl = new wxTextCtrl( sbSizer4->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer2->Add( m_textOffsetRatioCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
|
||||
|
||||
m_offsetRatioUnits = new wxStaticText( sbSizer4->GetStaticBox(), wxID_ANY, _("%"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_offsetRatioUnits->Wrap( -1 );
|
||||
fgSizer2->Add( m_offsetRatioUnits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
|
||||
|
||||
|
||||
sbSizer4->Add( fgSizer2, 1, wxEXPAND|wxBOTTOM, 5 );
|
||||
|
||||
|
@ -78,7 +91,7 @@ PANEL_SETUP_FORMATTING_BASE::PANEL_SETUP_FORMATTING_BASE( wxWindow* parent, wxWi
|
|||
sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Connections") ), wxVERTICAL );
|
||||
|
||||
wxFlexGridSizer* fgSizer32;
|
||||
fgSizer32 = new wxFlexGridSizer( 0, 3, 3, 0 );
|
||||
fgSizer32 = new wxFlexGridSizer( 0, 3, 5, 0 );
|
||||
fgSizer32->AddGrowableCol( 1 );
|
||||
fgSizer32->SetFlexibleDirection( wxBOTH );
|
||||
fgSizer32->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
|
|
@ -427,6 +427,192 @@
|
|||
<property name="wrap">-1</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|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">Text offset ratio:</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_textOffsetRatioLabel</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 offset text above or below wire or bus</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|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT</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_textOffsetRatioCtrl</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|wxBOTTOM|wxRIGHT</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_offsetRatioUnits</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 class="sizeritem" expanded="1">
|
||||
|
@ -583,7 +769,7 @@
|
|||
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
|
||||
<property name="permission">none</property>
|
||||
<property name="rows">0</property>
|
||||
<property name="vgap">3</property>
|
||||
<property name="vgap">5</property>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
|
||||
|
|
|
@ -38,6 +38,9 @@ class PANEL_SETUP_FORMATTING_BASE : public wxPanel
|
|||
wxStaticText* m_textSizeLabel;
|
||||
wxTextCtrl* m_textSizeCtrl;
|
||||
wxStaticText* m_textSizeUnits;
|
||||
wxStaticText* m_textOffsetRatioLabel;
|
||||
wxTextCtrl* m_textOffsetRatioCtrl;
|
||||
wxStaticText* m_offsetRatioUnits;
|
||||
wxCheckBox* m_checkSuperSub;
|
||||
wxStaticText* m_superSubHint;
|
||||
wxStaticText* m_busWidthLabel;
|
||||
|
|
|
@ -58,6 +58,7 @@ static int s_defaultBusThickness = Mils2iu( DEFAULTBUSTHICKNESS );
|
|||
static int s_defaultWireThickness = Mils2iu( DEFAULTDRAWLINETHICKNESS );
|
||||
static int s_defaultTextSize = Mils2iu( DEFAULT_SIZE_TEXT );
|
||||
static int s_drawDefaultLineThickness = -1;
|
||||
static double s_textOffsetRatio = 0.08;
|
||||
static bool s_selectTextAsBox = false;
|
||||
static bool s_selectDrawChildren = true;
|
||||
static bool s_selectFillShapes = false;
|
||||
|
@ -274,6 +275,18 @@ void SetDefaultLineThickness( int aThickness )
|
|||
}
|
||||
|
||||
|
||||
double GetTextOffsetRatio()
|
||||
{
|
||||
return s_textOffsetRatio;
|
||||
}
|
||||
|
||||
|
||||
void SetTextOffsetRatio( double aOffsetRatio )
|
||||
{
|
||||
s_textOffsetRatio = aOffsetRatio;
|
||||
}
|
||||
|
||||
|
||||
bool GetSelectionTextAsBox()
|
||||
{
|
||||
return s_selectTextAsBox;
|
||||
|
@ -365,6 +378,10 @@ void SCH_EDIT_FRAME::AddFormattingParameters( std::vector<PARAM_CFG*>& params )
|
|||
&s_defaultTextSize,
|
||||
Mils2iu( DEFAULT_SIZE_TEXT ),
|
||||
5, 1000, nullptr, 1 / IU_PER_MILS ) );
|
||||
params.push_back( new PARAM_CFG_DOUBLE( wxT( "TextOffsetRatio" ),
|
||||
&s_textOffsetRatio,
|
||||
(double) TXT_MARGIN / DEFAULT_SIZE_TEXT,
|
||||
-200.0, 200.0 ) );
|
||||
params.push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "LineThickness" ),
|
||||
&s_drawDefaultLineThickness,
|
||||
Mils2iu( appSettings->m_Drawing.default_line_thickness ),
|
||||
|
|
|
@ -48,6 +48,7 @@ class ERC_SETTINGS;
|
|||
#define DEFAULT_REPEAT_LABEL_INC 1 ///< the default value (overwritten by the eeschema config)
|
||||
#define DEFAULT_REPEAT_OFFSET_PIN 100 ///< the default value (overwritten by the eeschema config)
|
||||
///< when repeating a pin
|
||||
#define TXT_MARGIN 4
|
||||
|
||||
///< The thickness to draw busses that do not have a specific width
|
||||
///< (can be changed in preference menu)
|
||||
|
@ -113,6 +114,12 @@ void SetDefaultLineThickness( int aThickness );
|
|||
int GetDefaultTextSize();
|
||||
void SetDefaultTextSize( int aSize );
|
||||
|
||||
/**
|
||||
* Amount to offset text above/below wires & busses. Expressed as a ratio of the text size.
|
||||
*/
|
||||
double GetTextOffsetRatio();
|
||||
void SetTextOffsetRatio( double aOffsetRatio );
|
||||
|
||||
/**
|
||||
* Default line thickness used to draw/plot busses.
|
||||
*/
|
||||
|
|
|
@ -51,12 +51,6 @@
|
|||
|
||||
extern void IncrementLabelMember( wxString& name, int aIncrement );
|
||||
|
||||
// Only for tests: set DRAW_BBOX to 1 to draw the bounding box of labels
|
||||
#define DRAW_BBOX 0
|
||||
|
||||
// Margin in internal units (mils) between labels and wires
|
||||
#define TXT_MARGIN 4
|
||||
|
||||
/* Coding polygons for global symbol graphic shapes.
|
||||
* the first parml is the number of corners
|
||||
* others are the corners coordinates in reduced units
|
||||
|
@ -140,7 +134,8 @@ wxPoint SCH_TEXT::GetSchematicTextOffset() const
|
|||
wxPoint text_offset;
|
||||
|
||||
// add an offset to x (or y) position to aid readability of text on a wire or line
|
||||
int thick_offset = Mils2iu( TXT_MARGIN ) + ( GetPenSize() + GetDefaultLineThickness() ) / 2;
|
||||
int thick_offset = KiROUND( GetTextOffsetRatio() * GetTextSize().y );
|
||||
thick_offset += ( GetPenSize() + GetDefaultLineThickness() ) / 2;
|
||||
|
||||
switch( GetLabelSpinStyle() )
|
||||
{
|
||||
|
@ -771,7 +766,8 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() const
|
|||
|
||||
case PINSHEETLABEL_SHAPE::PS_OUTPUT:
|
||||
case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED:
|
||||
offset += TXT_MARGIN;
|
||||
offset += KiROUND( GetTextOffsetRatio() * GetTextSize().y );
|
||||
;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1184,23 +1180,24 @@ const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const
|
|||
wxPoint SCH_HIERLABEL::GetSchematicTextOffset() const
|
||||
{
|
||||
wxPoint text_offset;
|
||||
int width = std::max( GetThickness(), GetDefaultLineThickness() );
|
||||
int ii = GetTextWidth() + TXT_MARGIN + width;
|
||||
int thickness = std::max( GetThickness(), GetDefaultLineThickness() );
|
||||
int offset = KiROUND( GetTextOffsetRatio() * GetTextSize().y );
|
||||
int total_offset = GetTextWidth() + offset + thickness;
|
||||
|
||||
switch( GetLabelSpinStyle() )
|
||||
{
|
||||
default:
|
||||
case LABEL_SPIN_STYLE::LEFT:
|
||||
text_offset.x = -ii;
|
||||
text_offset.x = -total_offset;
|
||||
break; // Orientation horiz normale
|
||||
case LABEL_SPIN_STYLE::UP:
|
||||
text_offset.y = -ii;
|
||||
text_offset.y = -total_offset;
|
||||
break; // Orientation vert UP
|
||||
case LABEL_SPIN_STYLE::RIGHT:
|
||||
text_offset.x = ii;
|
||||
text_offset.x = total_offset;
|
||||
break; // Orientation horiz inverse
|
||||
case LABEL_SPIN_STYLE::BOTTOM:
|
||||
text_offset.y = ii;
|
||||
text_offset.y = total_offset;
|
||||
break; // Orientation vert BOTTOM
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue