Push TEXT_SPIN_STYLE from SCH_TEXT out to SCH_LABEL_BASE.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15444
This commit is contained in:
Jeff Young 2023-09-07 17:09:53 +01:00
parent 3723e9efc1
commit 0310973e3f
36 changed files with 784 additions and 737 deletions

View File

@ -270,10 +270,13 @@ void EDA_TEXT::SetKeepUpright( bool aKeepUpright )
}
void EDA_TEXT::SetAttributes( const EDA_TEXT& aSrc )
void EDA_TEXT::SetAttributes( const EDA_TEXT& aSrc, bool aSetPosition )
{
m_attributes = aSrc.m_attributes;
m_pos = aSrc.m_pos;
if( aSetPosition )
m_pos = aSrc.m_pos;
ClearRenderCache();
m_bounding_box_cache_valid = false;
}

View File

@ -314,10 +314,10 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( SCH_COMMIT* aCommit,
}
}
if( SCH_TEXT* sch_text = dynamic_cast<SCH_TEXT*>( aItem ) )
if( SCH_LABEL_BASE* sch_label = dynamic_cast<SCH_LABEL_BASE*>( aItem ) )
{
if( m_orientation->GetStringSelection() != INDETERMINATE_ACTION )
sch_text->SetTextSpinStyle( (TEXT_SPIN_STYLE::SPIN) m_orientation->GetSelection() );
sch_label->SetSpinStyle( (SPIN_STYLE::SPIN) m_orientation->GetSelection() );
}
if( SCH_FIELD* sch_field = dynamic_cast<SCH_FIELD*>( aItem ) )

View File

@ -214,6 +214,24 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_
m_bold = new wxCheckBox( m_specifiedValues, wxID_ANY, _("Bold"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
fgSizer1->Add( m_bold, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_italic = new wxCheckBox( m_specifiedValues, wxID_ANY, _("Italic"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
fgSizer1->Add( m_italic, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
fgSizer1->Add( 0, 5, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
@ -227,14 +245,15 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_
m_orientation->SetSelection( 4 );
fgSizer1->Add( m_orientation, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM, 4 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticText16 = new wxStaticText( m_specifiedValues, wxID_ANY, _("(labels only)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText16->Wrap( -1 );
fgSizer1->Add( m_staticText16, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer1->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 25 );
m_italic = new wxCheckBox( m_specifiedValues, wxID_ANY, _("Italic"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
fgSizer1->Add( m_italic, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );

View File

@ -2389,6 +2389,120 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" 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="checked">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">Italic</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_italic</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">wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER</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="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">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">5</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
@ -2526,29 +2640,9 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">25</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="flag">wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="spacer" expanded="0">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -2562,7 +2656,6 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
@ -2577,7 +2670,8 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Italic</property>
<property name="label">(labels only)</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -2585,7 +2679,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_italic</property>
<property name="name">m_staticText16</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -2595,17 +2689,34 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER</property>
<property name="subclass">; forward_declare</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="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="0">
<property name="border">25</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="spacer" expanded="0">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">

View File

@ -74,9 +74,10 @@ class DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE : public DIALOG_SHIM
wxTextCtrl* m_textSizeCtrl;
wxStaticText* m_textSizeUnits;
wxCheckBox* m_bold;
wxCheckBox* m_italic;
wxStaticText* orientationLabel;
wxChoice* m_orientation;
wxCheckBox* m_italic;
wxStaticText* m_staticText16;
wxStaticText* hAlignLabel;
wxChoice* m_hAlign;
wxStaticText* m_staticText14;

View File

@ -348,12 +348,12 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataToWindow()
m_italic->Check( m_currentLabel->IsItalic() );
m_textColorSwatch->SetSwatchColor( m_currentLabel->GetTextColor(), false );
switch( m_currentLabel->GetTextSpinStyle() )
switch( m_currentLabel->GetSpinStyle() )
{
case TEXT_SPIN_STYLE::RIGHT: m_spin0->Check( true ); break;
case TEXT_SPIN_STYLE::LEFT: m_spin1->Check( true ); break;
case TEXT_SPIN_STYLE::UP: m_spin2->Check( true ); break;
case TEXT_SPIN_STYLE::BOTTOM: m_spin3->Check( true ); break;
case SPIN_STYLE::RIGHT: m_spin0->Check( true ); break;
case SPIN_STYLE::LEFT: m_spin1->Check( true ); break;
case SPIN_STYLE::UP: m_spin2->Check( true ); break;
case SPIN_STYLE::BOTTOM: m_spin3->Check( true ); break;
}
if( m_currentLabel->AutoRotateOnPlacementSupported() )
@ -553,12 +553,12 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow()
m_currentLabel->SetTextColor( m_textColorSwatch->GetSwatchColor() );
TEXT_SPIN_STYLE selectedSpinStyle= TEXT_SPIN_STYLE::LEFT;
SPIN_STYLE selectedSpinStyle= SPIN_STYLE::LEFT;
if( m_spin0->IsChecked() ) selectedSpinStyle = TEXT_SPIN_STYLE::RIGHT;
else if( m_spin1->IsChecked() ) selectedSpinStyle = TEXT_SPIN_STYLE::LEFT;
else if( m_spin2->IsChecked() ) selectedSpinStyle = TEXT_SPIN_STYLE::UP;
else if( m_spin3->IsChecked() ) selectedSpinStyle = TEXT_SPIN_STYLE::BOTTOM;
if( m_spin0->IsChecked() ) selectedSpinStyle = SPIN_STYLE::RIGHT;
else if( m_spin1->IsChecked() ) selectedSpinStyle = SPIN_STYLE::LEFT;
else if( m_spin2->IsChecked() ) selectedSpinStyle = SPIN_STYLE::UP;
else if( m_spin3->IsChecked() ) selectedSpinStyle = SPIN_STYLE::BOTTOM;
if( m_currentLabel->AutoRotateOnPlacementSupported() )
{
@ -572,9 +572,9 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow()
}
if( !m_currentLabel->AutoRotateOnPlacement()
&& m_currentLabel->GetTextSpinStyle() != selectedSpinStyle )
&& m_currentLabel->GetSpinStyle() != selectedSpinStyle )
{
m_currentLabel->SetTextSpinStyle( selectedSpinStyle );
m_currentLabel->SetSpinStyle( selectedSpinStyle );
}
if( doAutoplace )

View File

@ -67,7 +67,7 @@ DIALOG_LIB_TEXT_PROPERTIES_BASE::DIALOG_LIB_TEXT_PROPERTIES_BASE( wxWindow* pare
m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 );
m_fontLabel->Wrap( -1 );
gbSizer1->Add( m_fontLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxLEFT, 5 );
gbSizer1->Add( m_fontLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") };
int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString );

View File

@ -226,7 +226,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxRIGHT|wxLEFT</property>
<property name="flag">wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="row">2</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">

View File

@ -72,14 +72,12 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_ITE
}
else
{
m_hAlignCenter->Show( false );
m_separator3->Show( false );
m_vAlignTop->Show( false );
m_vAlignCenter->Show( false );
m_vAlignBottom->Show( false );
wxSizer* parentSizer = m_vAlignTop->GetContainingSizer();
parentSizer->Detach( m_hAlignCenter );
parentSizer->Detach( m_separator3 );
parentSizer->Detach( m_vAlignTop );
parentSizer->Detach( m_vAlignCenter );
@ -271,17 +269,22 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
m_bold->Check( m_currentText->IsBold() );
m_italic->Check( m_currentText->IsItalic() );
switch( m_currentText->GetHorizJustify() )
{
case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check(); break;
case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check(); break;
case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check(); break;
}
if( m_currentText->GetTextAngle() == ANGLE_VERTICAL )
m_vertical->Check();
else
m_horizontal->Check();
if( m_currentItem->Type() == SCH_TEXTBOX_T )
{
SCH_TEXTBOX* textBox = static_cast<SCH_TEXTBOX*>( m_currentItem );
switch( m_currentText->GetHorizJustify() )
{
case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check(); break;
case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check(); break;
case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check(); break;
}
switch( m_currentText->GetVertJustify() )
{
case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check(); break;
@ -289,11 +292,6 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check(); break;
}
if( m_currentText->GetTextAngle() == ANGLE_VERTICAL )
m_vertical->Check();
else
m_horizontal->Check();
m_borderCheckbox->SetValue( textBox->GetWidth() >= 0 );
if( textBox->GetWidth() >= 0 )
@ -322,28 +320,6 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
m_fillColorLabel->Enable( textBox->IsFilled() );
m_fillColorSwatch->Enable( textBox->IsFilled() );
}
else
{
switch( static_cast<SCH_TEXT*>( m_currentItem )->GetTextSpinStyle() )
{
case TEXT_SPIN_STYLE::RIGHT:
m_hAlignLeft->Check( true ); // Spin style to right means text aligned left
m_horizontal->Check( true );
break;
case TEXT_SPIN_STYLE::LEFT:
m_hAlignRight->Check( true ); // Spin style to left means text aligned right
m_horizontal->Check( true );
break;
case TEXT_SPIN_STYLE::UP:
m_hAlignLeft->Check( true ); // Spin style up means text aligned to bottom
m_vertical->Check( true );
break;
case TEXT_SPIN_STYLE::BOTTOM: // Spin style down means text aligned to top
m_hAlignRight->Check( true );
m_vertical->Check( true );
break;
}
}
return true;
}
@ -522,36 +498,22 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
m_currentText->SetItalic( m_italic->IsChecked() );
m_currentText->SetTextColor( m_textColorSwatch->GetSwatchColor() );
if( m_currentItem->Type() == SCH_TEXT_T )
{
SCH_TEXT* textItem = static_cast<SCH_TEXT*>( m_currentItem );
if( m_hAlignRight->IsChecked() )
{
if( m_vertical->IsChecked() )
textItem->SetTextSpinStyle( TEXT_SPIN_STYLE::BOTTOM );
else
textItem->SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT );
}
else
{
if( m_vertical->IsChecked() )
textItem->SetTextSpinStyle( TEXT_SPIN_STYLE::UP );
else
textItem->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
}
}
if( m_hAlignRight->IsChecked() )
m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else if( m_hAlignCenter->IsChecked() )
m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
else
m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
if( m_vertical->IsChecked() )
m_currentText->SetTextAngle( ANGLE_VERTICAL );
else
m_currentText->SetTextAngle( ANGLE_HORIZONTAL );
if( m_currentItem->Type() == SCH_TEXTBOX_T )
{
SCH_TEXTBOX* textBox = static_cast<SCH_TEXTBOX*>( m_currentItem );
if( m_hAlignRight->IsChecked() )
m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else if( m_hAlignCenter->IsChecked() )
m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
else
m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
if( m_vAlignBottom->IsChecked() )
m_currentText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
else if( m_vAlignCenter->IsChecked() )
@ -559,11 +521,6 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
else
m_currentText->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
if( m_vertical->IsChecked() )
m_currentText->SetTextAngle( ANGLE_VERTICAL );
else
m_currentText->SetTextAngle( ANGLE_HORIZONTAL );
STROKE_PARAMS stroke = textBox->GetStroke();
if( m_borderCheckbox->GetValue() )

View File

@ -32,7 +32,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
m_textEntrySizer = new wxGridBagSizer( 2, 3 );
m_textEntrySizer->SetFlexibleDirection( wxBOTH );
m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_textEntrySizer->SetEmptyCellSize( wxSize( 0,10 ) );
m_textEntrySizer->SetEmptyCellSize( wxSize( 0,12 ) );
m_textLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 );
m_textLabel->Wrap( -1 );
@ -84,17 +84,17 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
m_textEntrySizer->Add( bSizer41, wxGBPosition( 1, 5 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALIGN_RIGHT|wxLEFT, 5 );
m_excludeFromSim = new wxCheckBox( this, wxID_ANY, _("Exclude from simulation"), wxDefaultPosition, wxDefaultSize, 0 );
m_textEntrySizer->Add( m_excludeFromSim, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxTOP|wxBOTTOM, 10 );
m_textEntrySizer->Add( m_excludeFromSim, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxTOP, 10 );
m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 );
m_fontLabel->Wrap( -1 );
m_textEntrySizer->Add( m_fontLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
m_textEntrySizer->Add( m_fontLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") };
int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString );
m_fontCtrl = new FONT_CHOICE( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fontCtrlNChoices, m_fontCtrlChoices, 0 );
m_fontCtrl->SetSelection( 0 );
m_textEntrySizer->Add( m_fontCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP, 5 );
m_textEntrySizer->Add( m_fontCtrl, wxGBPosition( 3, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
wxBoxSizer* bSizeCtrlSizer;
bSizeCtrlSizer = new wxBoxSizer( wxHORIZONTAL );
@ -175,11 +175,11 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
bSizeCtrlSizer->Add( m_separator5, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( bSizeCtrlSizer, wxGBPosition( 2, 3 ), wxGBSpan( 1, 2 ), wxEXPAND|wxTOP, 5 );
m_textEntrySizer->Add( bSizeCtrlSizer, wxGBPosition( 3, 3 ), wxGBSpan( 1, 2 ), wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_textSizeLabel->Wrap( -1 );
m_textEntrySizer->Add( m_textSizeLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( m_textSizeLabel, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* bSizer71;
bSizer71 = new wxBoxSizer( wxHORIZONTAL );
@ -212,14 +212,14 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
bSizer71->Add( m_panelBorderColor1, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( bSizer71, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 );
m_textEntrySizer->Add( bSizer71, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 );
m_borderCheckbox = new wxCheckBox( this, wxID_ANY, _("Border"), wxDefaultPosition, wxDefaultSize, 0 );
m_textEntrySizer->Add( m_borderCheckbox, wxGBPosition( 5, 0 ), wxGBSpan( 1, 2 ), wxBOTTOM, 2 );
m_textEntrySizer->Add( m_borderCheckbox, wxGBPosition( 6, 0 ), wxGBSpan( 1, 2 ), wxBOTTOM, 2 );
m_borderWidthLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderWidthLabel->Wrap( -1 );
m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 7, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
@ -252,19 +252,19 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
bSizer7->Add( m_panelBorderColor, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( bSizer7, wxGBPosition( 6, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 );
m_textEntrySizer->Add( bSizer7, wxGBPosition( 7, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 );
m_borderStyleLabel = new wxStaticText( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderStyleLabel->Wrap( -1 );
m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 7, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 8, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_borderStyleCombo = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) );
m_textEntrySizer->Add( m_borderStyleCombo, wxGBPosition( 7, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 );
m_textEntrySizer->Add( m_borderStyleCombo, wxGBPosition( 8, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 );
m_filledCtrl = new wxCheckBox( this, wxID_ANY, _("Background fill"), wxDefaultPosition, wxDefaultSize, 0 );
m_textEntrySizer->Add( m_filledCtrl, wxGBPosition( 5, 4 ), wxGBSpan( 1, 2 ), wxRIGHT, 80 );
m_textEntrySizer->Add( m_filledCtrl, wxGBPosition( 6, 4 ), wxGBSpan( 1, 2 ), wxRIGHT, 80 );
wxBoxSizer* bSizer8;
bSizer8 = new wxBoxSizer( wxHORIZONTAL );
@ -287,13 +287,13 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
bSizer8->Add( m_panelFillColor, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( bSizer8, wxGBPosition( 6, 4 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 );
m_textEntrySizer->Add( bSizer8, wxGBPosition( 7, 4 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 );
m_hyperlinkCb = new wxCheckBox( this, wxID_ANY, _("Link:"), wxDefaultPosition, wxDefaultSize, 0 );
m_hyperlinkCb->SetValue(true);
m_hyperlinkCb->SetToolTip( _("Make this text item a clickable hyperlink") );
m_textEntrySizer->Add( m_hyperlinkCb, wxGBPosition( 9, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
m_textEntrySizer->Add( m_hyperlinkCb, wxGBPosition( 10, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
wxBoxSizer* bSizer11;
bSizer11 = new wxBoxSizer( wxHORIZONTAL );
@ -302,7 +302,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
bSizer11->Add( m_hyperlinkCombo, 1, wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( bSizer11, wxGBPosition( 9, 1 ), wxGBSpan( 1, 6 ), wxEXPAND|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( bSizer11, wxGBPosition( 10, 1 ), wxGBSpan( 1, 6 ), wxEXPAND|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->AddGrowableCol( 3 );

View File

@ -126,7 +126,7 @@
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxGridBagSizer" expanded="1">
<property name="empty_cell_size">0,10</property>
<property name="empty_cell_size">0,12</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">3</property>
<property name="growablerows"></property>
@ -353,7 +353,7 @@
<property name="border">10</property>
<property name="colspan">2</property>
<property name="column">0</property>
<property name="flag">wxTOP|wxBOTTOM</property>
<property name="flag">wxTOP</property>
<property name="row">1</property>
<property name="rowspan">1</property>
<object class="wxCheckBox" expanded="1">
@ -420,8 +420,8 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP</property>
<property name="row">2</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">3</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -484,8 +484,8 @@
<property name="border">5</property>
<property name="colspan">2</property>
<property name="column">1</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP</property>
<property name="row">2</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxEXPAND</property>
<property name="row">3</property>
<property name="rowspan">1</property>
<object class="wxChoice" expanded="1">
<property name="BottomDockable">1</property>
@ -551,8 +551,8 @@
<property name="border">5</property>
<property name="colspan">2</property>
<property name="column">3</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="row">2</property>
<property name="flag">wxEXPAND|wxALIGN_CENTER_VERTICAL</property>
<property name="row">3</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
@ -1661,7 +1661,7 @@
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">3</property>
<property name="row">4</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -1725,7 +1725,7 @@
<property name="colspan">1</property>
<property name="column">1</property>
<property name="flag">wxEXPAND</property>
<property name="row">3</property>
<property name="row">4</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
@ -2060,7 +2060,7 @@
<property name="colspan">2</property>
<property name="column">0</property>
<property name="flag">wxBOTTOM</property>
<property name="row">5</property>
<property name="row">6</property>
<property name="rowspan">1</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
@ -2128,7 +2128,7 @@
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">6</property>
<property name="row">7</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -2192,7 +2192,7 @@
<property name="colspan">2</property>
<property name="column">1</property>
<property name="flag">wxEXPAND</property>
<property name="row">6</property>
<property name="row">7</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
@ -2527,7 +2527,7 @@
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">7</property>
<property name="row">8</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -2591,7 +2591,7 @@
<property name="colspan">2</property>
<property name="column">1</property>
<property name="flag">wxEXPAND</property>
<property name="row">7</property>
<property name="row">8</property>
<property name="rowspan">1</property>
<object class="wxBitmapComboBox" expanded="1">
<property name="BottomDockable">1</property>
@ -2659,7 +2659,7 @@
<property name="colspan">2</property>
<property name="column">4</property>
<property name="flag">wxRIGHT</property>
<property name="row">5</property>
<property name="row">6</property>
<property name="rowspan">1</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
@ -2727,7 +2727,7 @@
<property name="colspan">2</property>
<property name="column">4</property>
<property name="flag">wxEXPAND</property>
<property name="row">6</property>
<property name="row">7</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
@ -2927,7 +2927,7 @@
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM</property>
<property name="row">9</property>
<property name="row">10</property>
<property name="rowspan">1</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
@ -2995,7 +2995,7 @@
<property name="colspan">6</property>
<property name="column">1</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxALIGN_CENTER_VERTICAL</property>
<property name="row">9</property>
<property name="row">10</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>

View File

@ -321,26 +321,25 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
addItem( e2 );
SCH_TEXT* t1 = new SCH_TEXT( MILS_POINT( 2850, 2250 ), wxT( "PLAIN TEXT" ) );
t1->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::LEFT );
addItem( t1 );
SCH_LABEL* t2 = new SCH_LABEL( MILS_POINT( 1975, 1500 ), wxT( "LABEL_{0}" ) );
t2->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::RIGHT );
t2->SetSpinStyle( SPIN_STYLE::SPIN::RIGHT );
t2->SetIsDangling( false );
addItem( t2 );
SCH_LABEL* t3 = new SCH_LABEL( MILS_POINT( 1975, 2600 ), wxT( "LABEL_{1}" ) );
t3->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::RIGHT );
t3->SetSpinStyle( SPIN_STYLE::SPIN::RIGHT );
t3->SetIsDangling( false );
addItem( t3 );
SCH_GLOBALLABEL* t4 = new SCH_GLOBALLABEL( MILS_POINT( 1750, 1400 ), wxT( "GLOBAL[0..3]" ) );
t4->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::LEFT );
t4->SetSpinStyle( SPIN_STYLE::SPIN::LEFT );
t4->SetIsDangling( false );
addItem( t4 );
SCH_HIERLABEL* t5 = new SCH_HIERLABEL( MILS_POINT( 3250, 1600 ), wxT( "HIER_LABEL" ) );
t5->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::RIGHT );
t5->SetSpinStyle( SPIN_STYLE::SPIN::RIGHT );
t5->SetIsDangling( false );
addItem( t5 );

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 1992-2013 jp.charras at wanadoo.fr
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -28,7 +28,7 @@
#include <lib_pin.h>
#include <sch_symbol.h>
#include <sch_text.h>
#include <sch_label.h>
#include <sch_sheet.h>
#include <schematic.h>

View File

@ -1561,13 +1561,13 @@ void SCH_EDIT_FRAME::AutoRotateItem( SCH_SCREEN* aScreen, SCH_ITEM* aItem )
if( label->AutoRotateOnPlacement() )
{
TEXT_SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(),
label->GetTextSpinStyle(),
&GetCurrentSheet() );
SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(),
label->GetSpinStyle(),
&GetCurrentSheet() );
if( spin != label->GetTextSpinStyle() )
if( spin != label->GetSpinStyle() )
{
label->SetTextSpinStyle( spin );
label->SetSpinStyle( spin );
for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
{

View File

@ -153,6 +153,54 @@ wxString getElectricalTypeLabel( LABEL_FLAG_SHAPE aType )
}
SPIN_STYLE SPIN_STYLE::RotateCCW()
{
SPIN newSpin = m_spin;
switch( m_spin )
{
case SPIN_STYLE::LEFT: newSpin = SPIN_STYLE::BOTTOM; break;
case SPIN_STYLE::BOTTOM: newSpin = SPIN_STYLE::RIGHT; break;
case SPIN_STYLE::RIGHT: newSpin = SPIN_STYLE::UP; break;
case SPIN_STYLE::UP: newSpin = SPIN_STYLE::LEFT; break;
}
return SPIN_STYLE( newSpin );
}
SPIN_STYLE SPIN_STYLE::MirrorX()
{
SPIN newSpin = m_spin;
switch( m_spin )
{
case SPIN_STYLE::UP: newSpin = SPIN_STYLE::BOTTOM; break;
case SPIN_STYLE::BOTTOM: newSpin = SPIN_STYLE::UP; break;
case SPIN_STYLE::LEFT: break;
case SPIN_STYLE::RIGHT: break;
}
return SPIN_STYLE( newSpin );
}
SPIN_STYLE SPIN_STYLE::MirrorY()
{
SPIN newSpin = m_spin;
switch( m_spin )
{
case SPIN_STYLE::LEFT: newSpin = SPIN_STYLE::RIGHT; break;
case SPIN_STYLE::RIGHT: newSpin = SPIN_STYLE::LEFT; break;
case SPIN_STYLE::UP: break;
case SPIN_STYLE::BOTTOM: break;
}
return SPIN_STYLE( newSpin );
}
SCH_LABEL_BASE::SCH_LABEL_BASE( const VECTOR2I& aPos, const wxString& aText, KICAD_T aType ) :
SCH_TEXT( aPos, aText, aType ),
m_shape( L_UNSPECIFIED ),
@ -286,6 +334,60 @@ COLOR4D SCH_LABEL_BASE::GetLabelColor() const
}
void SCH_LABEL_BASE::SetSpinStyle( SPIN_STYLE aSpinStyle )
{
// Assume "Right" and Left" mean which side of the anchor the text will be on
// Thus we want to left justify text up against the anchor if we are on the right
switch( aSpinStyle )
{
default:
wxFAIL_MSG( "Bad spin style" );
KI_FALLTHROUGH;
case SPIN_STYLE::RIGHT: // Horiz Normal Orientation
SetTextAngle( ANGLE_HORIZONTAL );
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case SPIN_STYLE::UP: // Vert Orientation UP
SetTextAngle( ANGLE_VERTICAL );
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case SPIN_STYLE::LEFT: // Horiz Orientation - Right justified
SetTextAngle( ANGLE_HORIZONTAL );
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
SetTextAngle( ANGLE_VERTICAL );
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
}
SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
}
SPIN_STYLE SCH_LABEL_BASE::GetSpinStyle() const
{
if( GetTextAngle() == ANGLE_VERTICAL )
{
if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
return SPIN_STYLE::BOTTOM;
else
return SPIN_STYLE::UP;
}
else
{
if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
return SPIN_STYLE::LEFT;
else
return SPIN_STYLE::RIGHT;
}
}
VECTOR2I SCH_LABEL_BASE::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const
{
VECTOR2I text_offset;
@ -293,13 +395,13 @@ VECTOR2I SCH_LABEL_BASE::GetSchematicTextOffset( const RENDER_SETTINGS* aSetting
// add an offset to x (or y) position to aid readability of text on a wire or line
int dist = GetTextOffset( aSettings ) + GetPenWidth();
switch( GetTextSpinStyle() )
switch( GetSpinStyle() )
{
case TEXT_SPIN_STYLE::UP:
case TEXT_SPIN_STYLE::BOTTOM: text_offset.x = -dist; break; // Vert Orientation
case SPIN_STYLE::UP:
case SPIN_STYLE::BOTTOM: text_offset.x = -dist; break; // Vert Orientation
default:
case TEXT_SPIN_STYLE::LEFT:
case TEXT_SPIN_STYLE::RIGHT: text_offset.y = -dist; break; // Horiz Orientation
case SPIN_STYLE::LEFT:
case SPIN_STYLE::RIGHT: text_offset.y = -dist; break; // Horiz Orientation
}
return text_offset;
@ -490,10 +592,10 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
{
VECTOR2I offset( 0, 0 );
switch( GetTextSpinStyle() )
switch( GetSpinStyle() )
{
default:
case TEXT_SPIN_STYLE::LEFT:
case SPIN_STYLE::LEFT:
field.SetTextAngle( ANGLE_HORIZONTAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
@ -504,7 +606,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
break;
case TEXT_SPIN_STYLE::UP:
case SPIN_STYLE::UP:
field.SetTextAngle( ANGLE_VERTICAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
@ -515,7 +617,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
break;
case TEXT_SPIN_STYLE::RIGHT:
case SPIN_STYLE::RIGHT:
field.SetTextAngle( ANGLE_HORIZONTAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
@ -526,7 +628,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
break;
case TEXT_SPIN_STYLE::BOTTOM:
case SPIN_STYLE::BOTTOM:
field.SetTextAngle( ANGLE_VERTICAL );
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
@ -1046,13 +1148,13 @@ void SCH_LABEL_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
switch( GetTextSpinStyle() )
switch( GetSpinStyle() )
{
case TEXT_SPIN_STYLE::LEFT: msg = _( "Align right" ); break;
case TEXT_SPIN_STYLE::UP: msg = _( "Align bottom" ); break;
case TEXT_SPIN_STYLE::RIGHT: msg = _( "Align left" ); break;
case TEXT_SPIN_STYLE::BOTTOM: msg = _( "Align top" ); break;
default: msg = wxT( "???" ); break;
case SPIN_STYLE::LEFT: msg = _( "Align right" ); break;
case SPIN_STYLE::UP: msg = _( "Align bottom" ); break;
case SPIN_STYLE::RIGHT: msg = _( "Align left" ); break;
case SPIN_STYLE::BOTTOM: msg = _( "Align top" ); break;
default: msg = wxT( "???" ); break;
}
aList.emplace_back( _( "Justification" ), msg );
@ -1312,7 +1414,7 @@ void SCH_DIRECTIVE_LABEL::MirrorHorizontally( int aCenter )
// vertical shape (like a text reduced to only "I" letter).
// So the mirroring is not exactly similar to a SCH_TEXT item
// Text is NOT really mirrored; it is moved to a suitable horizontal position
SetTextSpinStyle( GetTextSpinStyle().MirrorX() );
SetSpinStyle( GetSpinStyle().MirrorX() );
SetTextX( MIRRORVAL( GetTextPos().x, aCenter ) );
@ -1348,7 +1450,7 @@ void SCH_DIRECTIVE_LABEL::MirrorVertically( int aCenter )
// vertical shape (like a text reduced to only "I" letter).
// So the mirroring is not exactly similar to a SCH_TEXT item
// Text is NOT really mirrored; it is moved to a suitable vertical position
SetTextSpinStyle( GetTextSpinStyle().MirrorY() );
SetSpinStyle( GetSpinStyle().MirrorY() );
SetTextY( MIRRORVAL( GetTextPos().y, aCenter ) );
@ -1418,13 +1520,13 @@ void SCH_DIRECTIVE_LABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSett
// Rotate outlines and move corners to real position
for( VECTOR2I& aPoint : aPoints )
{
switch( GetTextSpinStyle() )
switch( GetSpinStyle() )
{
default:
case TEXT_SPIN_STYLE::LEFT: break;
case TEXT_SPIN_STYLE::UP: RotatePoint( aPoint, -ANGLE_90 ); break;
case TEXT_SPIN_STYLE::RIGHT: RotatePoint( aPoint, ANGLE_180 ); break;
case TEXT_SPIN_STYLE::BOTTOM: RotatePoint( aPoint, ANGLE_90 ); break;
case SPIN_STYLE::LEFT: break;
case SPIN_STYLE::UP: RotatePoint( aPoint, -ANGLE_90 ); break;
case SPIN_STYLE::RIGHT: RotatePoint( aPoint, ANGLE_180 ); break;
case SPIN_STYLE::BOTTOM: RotatePoint( aPoint, ANGLE_90 ); break;
}
aPoint += aPos;
@ -1448,25 +1550,25 @@ void SCH_DIRECTIVE_LABEL::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
for( SCH_FIELD& field : m_fields )
{
switch( GetTextSpinStyle() )
switch( GetSpinStyle() )
{
default:
case TEXT_SPIN_STYLE::LEFT:
case SPIN_STYLE::LEFT:
field.SetTextAngle( ANGLE_HORIZONTAL );
offset = { symbolWidth + margin, origin };
break;
case TEXT_SPIN_STYLE::UP:
case SPIN_STYLE::UP:
field.SetTextAngle( ANGLE_VERTICAL );
offset = { -origin, -( symbolWidth + margin ) };
break;
case TEXT_SPIN_STYLE::RIGHT:
case SPIN_STYLE::RIGHT:
field.SetTextAngle( ANGLE_HORIZONTAL );
offset = { symbolWidth + margin, -origin };
break;
case TEXT_SPIN_STYLE::BOTTOM:
case SPIN_STYLE::BOTTOM:
field.SetTextAngle( ANGLE_VERTICAL );
offset = { origin, -( symbolWidth + margin ) };
break;
@ -1541,20 +1643,20 @@ VECTOR2I SCH_GLOBALLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSettin
break;
}
switch( GetTextSpinStyle() )
switch( GetSpinStyle() )
{
default:
case TEXT_SPIN_STYLE::LEFT: return VECTOR2I( -horiz, vert );
case TEXT_SPIN_STYLE::UP: return VECTOR2I( vert, -horiz );
case TEXT_SPIN_STYLE::RIGHT: return VECTOR2I( horiz, vert );
case TEXT_SPIN_STYLE::BOTTOM: return VECTOR2I( vert, horiz );
case SPIN_STYLE::LEFT: return VECTOR2I( -horiz, vert );
case SPIN_STYLE::UP: return VECTOR2I( vert, -horiz );
case SPIN_STYLE::RIGHT: return VECTOR2I( horiz, vert );
case SPIN_STYLE::BOTTOM: return VECTOR2I( vert, horiz );
}
}
void SCH_GLOBALLABEL::SetTextSpinStyle( TEXT_SPIN_STYLE aSpinStyle )
void SCH_GLOBALLABEL::SetSpinStyle( SPIN_STYLE aSpinStyle )
{
SCH_TEXT::SetTextSpinStyle( aSpinStyle );
SCH_LABEL_BASE::SetSpinStyle( aSpinStyle );
SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
}
@ -1675,13 +1777,13 @@ void SCH_GLOBALLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings
{
aPoint.x += x_offset;
switch( GetTextSpinStyle() )
switch( GetSpinStyle() )
{
default:
case TEXT_SPIN_STYLE::LEFT: break;
case TEXT_SPIN_STYLE::UP: RotatePoint( aPoint, -ANGLE_90 ); break;
case TEXT_SPIN_STYLE::RIGHT: RotatePoint( aPoint, ANGLE_180 ); break;
case TEXT_SPIN_STYLE::BOTTOM: RotatePoint( aPoint, ANGLE_90 ); break;
case SPIN_STYLE::LEFT: break;
case SPIN_STYLE::UP: RotatePoint( aPoint, -ANGLE_90 ); break;
case SPIN_STYLE::RIGHT: RotatePoint( aPoint, ANGLE_180 ); break;
case SPIN_STYLE::BOTTOM: RotatePoint( aPoint, ANGLE_90 ); break;
}
aPoint += aPos;
@ -1712,9 +1814,9 @@ SCH_HIERLABEL::SCH_HIERLABEL( const VECTOR2I& pos, const wxString& text, KICAD_T
}
void SCH_HIERLABEL::SetTextSpinStyle( TEXT_SPIN_STYLE aSpinStyle )
void SCH_HIERLABEL::SetSpinStyle( SPIN_STYLE aSpinStyle )
{
SCH_TEXT::SetTextSpinStyle( aSpinStyle );
SCH_LABEL_BASE::SetSpinStyle( aSpinStyle );
SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
}
@ -1730,7 +1832,7 @@ void SCH_HIERLABEL::CreateGraphicShape( const RENDER_SETTINGS* aSettings,
std::vector<VECTOR2I>& aPoints, const VECTOR2I& aPos,
LABEL_FLAG_SHAPE aShape ) const
{
int* Template = TemplateShape[static_cast<int>( aShape )][static_cast<int>( m_spin_style )];
int* Template = TemplateShape[static_cast<int>( aShape )][static_cast<int>( GetSpinStyle() )];
int halfSize = GetTextHeight() / 2;
int imax = *Template;
Template++;
@ -1766,31 +1868,31 @@ const BOX2I SCH_HIERLABEL::GetBodyBoundingBox() const
int dx, dy;
switch( GetTextSpinStyle() )
switch( GetSpinStyle() )
{
default:
case TEXT_SPIN_STYLE::LEFT:
case SPIN_STYLE::LEFT:
dx = -length;
dy = height;
x += schIUScale.MilsToIU( DANGLING_SYMBOL_SIZE );
y -= height / 2;
break;
case TEXT_SPIN_STYLE::UP:
case SPIN_STYLE::UP:
dx = height;
dy = -length;
x -= height / 2;
y += schIUScale.MilsToIU( DANGLING_SYMBOL_SIZE );
break;
case TEXT_SPIN_STYLE::RIGHT:
case SPIN_STYLE::RIGHT:
dx = length;
dy = height;
x -= schIUScale.MilsToIU( DANGLING_SYMBOL_SIZE );
y -= height / 2;
break;
case TEXT_SPIN_STYLE::BOTTOM:
case SPIN_STYLE::BOTTOM:
dx = height;
dy = length;
x -= height / 2;
@ -1811,13 +1913,13 @@ VECTOR2I SCH_HIERLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings
dist += GetTextWidth();
switch( GetTextSpinStyle() )
switch( GetSpinStyle() )
{
default:
case TEXT_SPIN_STYLE::LEFT: text_offset.x = -dist; break; // Orientation horiz normale
case TEXT_SPIN_STYLE::UP: text_offset.y = -dist; break; // Orientation vert UP
case TEXT_SPIN_STYLE::RIGHT: text_offset.x = dist; break; // Orientation horiz inverse
case TEXT_SPIN_STYLE::BOTTOM: text_offset.y = dist; break; // Orientation vert BOTTOM
case SPIN_STYLE::LEFT: text_offset.x = -dist; break; // Orientation horiz normale
case SPIN_STYLE::UP: text_offset.y = -dist; break; // Orientation vert UP
case SPIN_STYLE::RIGHT: text_offset.x = dist; break; // Orientation horiz inverse
case SPIN_STYLE::BOTTOM: text_offset.y = dist; break; // Orientation vert BOTTOM
}
return text_offset;

View File

@ -31,6 +31,78 @@
#include <sch_connection.h> // for CONNECTION_TYPE
/*
* Spin style for labels of all kinds on schematics
* Basically a higher level abstraction of rotation and justification of text
*/
class SPIN_STYLE
{
public:
enum SPIN : int
{
LEFT = 0,
UP = 1,
RIGHT = 2,
BOTTOM = 3
};
SPIN_STYLE() = default;
constexpr SPIN_STYLE( SPIN aSpin ) : m_spin( aSpin )
{
}
constexpr bool operator==( SPIN a ) const
{
return m_spin == a;
}
constexpr bool operator!=( SPIN a ) const
{
return m_spin != a;
}
operator int() const
{
return static_cast<int>( m_spin );
}
SPIN_STYLE RotateCCW();
/**
* Mirror the label spin style across the X axis or simply swaps up and bottom.
*/
SPIN_STYLE MirrorX();
/**
* Mirror the label spin style across the Y axis or simply swaps left and right.
*/
SPIN_STYLE MirrorY();
private:
SPIN m_spin;
};
/*
* Label and flag shapes used with text objects.
*/
enum LABEL_FLAG_SHAPE
{
L_INPUT,
L_OUTPUT,
L_BIDI,
L_TRISTATE,
L_UNSPECIFIED,
F_FIRST,
F_DOT = F_FIRST,
F_ROUND,
F_DIAMOND,
F_RECTANGLE
};
class SCH_LABEL_BASE : public SCH_TEXT
{
public:
@ -72,11 +144,14 @@ public:
}
}
LABEL_FLAG_SHAPE GetShape() const override { return m_shape; }
void SetShape( LABEL_FLAG_SHAPE aShape ) override { m_shape = aShape; }
LABEL_FLAG_SHAPE GetShape() const { return m_shape; }
void SetShape( LABEL_FLAG_SHAPE aShape ) { m_shape = aShape; }
COLOR4D GetLabelColor() const;
virtual void SetSpinStyle( SPIN_STYLE aSpinStyle );
SPIN_STYLE GetSpinStyle() const;
void SetLastResolvedState( const SCH_ITEM* aItem ) override
{
const SCH_LABEL_BASE* aLabel = dynamic_cast<const SCH_LABEL_BASE*>( aItem );
@ -382,7 +457,7 @@ public:
int GetMandatoryFieldCount() override { return 1; }
void SetTextSpinStyle( TEXT_SPIN_STYLE aSpinStyle ) override;
void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
@ -434,7 +509,7 @@ public:
return wxT( "SCH_HIERLABEL" );
}
void SetTextSpinStyle( TEXT_SPIN_STYLE aSpinStyle ) override;
void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;

View File

@ -2403,22 +2403,22 @@ void SCH_ALTIUM_PLUGIN::ParseHarnessEntry( const std::map<wxString, wxString>& a
default:
case ASCH_SHEET_ENTRY_SIDE::LEFT:
sheetPin->SetPosition( { pos.x, pos.y + elem.DistanceFromTop } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT );
sheetPin->SetSpinStyle( SPIN_STYLE::LEFT );
sheetPin->SetSide( SHEET_SIDE::LEFT );
break;
case ASCH_SHEET_ENTRY_SIDE::RIGHT:
sheetPin->SetPosition( { pos.x + size.x, pos.y + elem.DistanceFromTop } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
sheetPin->SetSpinStyle( SPIN_STYLE::RIGHT );
sheetPin->SetSide( SHEET_SIDE::RIGHT );
break;
case ASCH_SHEET_ENTRY_SIDE::TOP:
sheetPin->SetPosition( { pos.x + elem.DistanceFromTop, pos.y } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::UP );
sheetPin->SetSpinStyle( SPIN_STYLE::UP );
sheetPin->SetSide( SHEET_SIDE::TOP );
break;
case ASCH_SHEET_ENTRY_SIDE::BOTTOM:
sheetPin->SetPosition( { pos.x + elem.DistanceFromTop, pos.y + size.y } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::BOTTOM );
sheetPin->SetSpinStyle( SPIN_STYLE::BOTTOM );
sheetPin->SetSide( SHEET_SIDE::BOTTOM );
break;
}
@ -2600,7 +2600,7 @@ void SCH_ALTIUM_PLUGIN::ParseSheetEntry( const std::map<wxString, wxString>& aPr
sheetPin->SetText( elem.name );
sheetPin->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
//sheetPin->SetTextSpinStyle( getSpinStyle( term.OrientAngle, false ) );
//sheetPin->SetSpinStyle( getSpinStyle( term.OrientAngle, false ) );
//sheetPin->SetPosition( getKiCadPoint( term.Position ) );
VECTOR2I pos = sheetIt->second->GetPosition();
@ -2611,25 +2611,25 @@ void SCH_ALTIUM_PLUGIN::ParseSheetEntry( const std::map<wxString, wxString>& aPr
default:
case ASCH_SHEET_ENTRY_SIDE::LEFT:
sheetPin->SetPosition( { pos.x, pos.y + elem.distanceFromTop } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT );
sheetPin->SetSpinStyle( SPIN_STYLE::LEFT );
sheetPin->SetSide( SHEET_SIDE::LEFT );
break;
case ASCH_SHEET_ENTRY_SIDE::RIGHT:
sheetPin->SetPosition( { pos.x + size.x, pos.y + elem.distanceFromTop } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
sheetPin->SetSpinStyle( SPIN_STYLE::RIGHT );
sheetPin->SetSide( SHEET_SIDE::RIGHT );
break;
case ASCH_SHEET_ENTRY_SIDE::TOP:
sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::UP );
sheetPin->SetSpinStyle( SPIN_STYLE::UP );
sheetPin->SetSide( SHEET_SIDE::TOP );
break;
case ASCH_SHEET_ENTRY_SIDE::BOTTOM:
sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y + size.y } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::BOTTOM );
sheetPin->SetSpinStyle( SPIN_STYLE::BOTTOM );
sheetPin->SetSide( SHEET_SIDE::BOTTOM );
break;
}
@ -3117,9 +3117,9 @@ void SCH_ALTIUM_PLUGIN::ParsePort( const ASCH_PORT& aElem )
case ASCH_PORT_STYLE::RIGHT:
case ASCH_PORT_STYLE::LEFT_RIGHT:
if( ( startIsWireTerminal || startIsBusTerminal ) )
label->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
label->SetSpinStyle( SPIN_STYLE::RIGHT );
else
label->SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT );
label->SetSpinStyle( SPIN_STYLE::LEFT );
break;
case ASCH_PORT_STYLE::NONE_VERTICAL:
@ -3127,9 +3127,9 @@ void SCH_ALTIUM_PLUGIN::ParsePort( const ASCH_PORT& aElem )
case ASCH_PORT_STYLE::BOTTOM:
case ASCH_PORT_STYLE::TOP_BOTTOM:
if( ( startIsWireTerminal || startIsBusTerminal ) )
label->SetTextSpinStyle( TEXT_SPIN_STYLE::UP );
label->SetSpinStyle( SPIN_STYLE::UP );
else
label->SetTextSpinStyle( TEXT_SPIN_STYLE::BOTTOM );
label->SetSpinStyle( SPIN_STYLE::BOTTOM );
break;
}

View File

@ -619,7 +619,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadHierarchicalSheetPins()
sheetPin->SetText( name );
sheetPin->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
sheetPin->SetTextSpinStyle( getSpinStyle( term.OrientAngle, false ) );
sheetPin->SetSpinStyle( getSpinStyle( term.OrientAngle, false ) );
sheetPin->SetPosition( getKiCadPoint( term.Position ) );
if( sheetPin->Type() == SCH_SHEET_PIN_T )
@ -946,7 +946,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
linkOrigin.Justification );
}
netLabel->SetTextSpinStyle( getSpinStyle( sym.OrientAngle, sym.Mirror ) );
netLabel->SetSpinStyle( getSpinStyle( sym.OrientAngle, sym.Mirror ) );
if( libSymDef.Alternate.Lower().Contains( "in" ) )
netLabel->SetShape( LABEL_FLAG_SHAPE::L_INPUT );
@ -1349,15 +1349,15 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets()
auto fixNetLabelsAndSheetPins =
[&]( const EDA_ANGLE& aWireAngle, NETELEMENT_ID& aNetEleID )
{
TEXT_SPIN_STYLE spin = getSpinStyle( aWireAngle );
SPIN_STYLE spin = getSpinStyle( aWireAngle );
if( netlabels.find( aNetEleID ) != netlabels.end() )
netlabels.at( aNetEleID )->SetTextSpinStyle( spin.MirrorY() );
netlabels.at( aNetEleID )->SetSpinStyle( spin.MirrorY() );
SCH_HIERLABEL* sheetPin = getHierarchicalLabel( aNetEleID );
if( sheetPin )
sheetPin->SetTextSpinStyle( spin.MirrorX() );
sheetPin->SetSpinStyle( spin.MirrorX() );
};
// Now we can load the wires and fix the label orientations
@ -1419,9 +1419,10 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets()
label->SetPosition( getKiCadPoint( junc.Location ) );
label->SetVisible( true );
EDA_ANGLE labelAngle = getAngle( junc.NetLabel.OrientAngle );
TEXT_SPIN_STYLE spin = getSpinStyle( labelAngle );
label->SetTextSpinStyle( spin );
EDA_ANGLE labelAngle = getAngle( junc.NetLabel.OrientAngle );
SPIN_STYLE spin = getSpinStyle( labelAngle );
label->SetSpinStyle( spin );
m_sheetMap.at( junc.LayerID )->GetScreen()->Append( label );
}
@ -2876,11 +2877,11 @@ int CADSTAR_SCH_ARCHIVE_LOADER::getKiCadUnitNumberFromGate( const GATE_ID& aCads
}
TEXT_SPIN_STYLE CADSTAR_SCH_ARCHIVE_LOADER::getSpinStyle( const long long& aCadstarOrientation,
bool aMirror )
SPIN_STYLE CADSTAR_SCH_ARCHIVE_LOADER::getSpinStyle( const long long& aCadstarOrientation,
bool aMirror )
{
EDA_ANGLE orientation = getAngle( aCadstarOrientation );
TEXT_SPIN_STYLE spinStyle = getSpinStyle( orientation );
EDA_ANGLE orientation = getAngle( aCadstarOrientation );
SPIN_STYLE spinStyle = getSpinStyle( orientation );
if( aMirror )
{
@ -2892,21 +2893,21 @@ TEXT_SPIN_STYLE CADSTAR_SCH_ARCHIVE_LOADER::getSpinStyle( const long long& aCads
}
TEXT_SPIN_STYLE CADSTAR_SCH_ARCHIVE_LOADER::getSpinStyle( const EDA_ANGLE& aOrientation )
SPIN_STYLE CADSTAR_SCH_ARCHIVE_LOADER::getSpinStyle( const EDA_ANGLE& aOrientation )
{
TEXT_SPIN_STYLE spinStyle = TEXT_SPIN_STYLE::LEFT;
SPIN_STYLE spinStyle = SPIN_STYLE::LEFT;
EDA_ANGLE oDeg = aOrientation;
oDeg.Normalize180();
if( oDeg >= -ANGLE_45 && oDeg <= ANGLE_45 )
spinStyle = TEXT_SPIN_STYLE::RIGHT; // 0deg
spinStyle = SPIN_STYLE::RIGHT; // 0deg
else if( oDeg >= ANGLE_45 && oDeg <= ANGLE_135 )
spinStyle = TEXT_SPIN_STYLE::UP; // 90deg
spinStyle = SPIN_STYLE::UP; // 90deg
else if( oDeg >= ANGLE_135 || oDeg <= -ANGLE_135 )
spinStyle = TEXT_SPIN_STYLE::LEFT; // 180deg
spinStyle = SPIN_STYLE::LEFT; // 180deg
else
spinStyle = TEXT_SPIN_STYLE::BOTTOM; // 270deg
spinStyle = SPIN_STYLE::BOTTOM; // 270deg
return spinStyle;
}
@ -3066,8 +3067,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT
}
};
TEXT_SPIN_STYLE spin = getSpinStyle( aCadstarOrientAngle, aMirrored );
EDA_ITEM* textEdaItem = dynamic_cast<EDA_ITEM*>( aKiCadTextItem );
SPIN_STYLE spin = getSpinStyle( aCadstarOrientAngle, aMirrored );
EDA_ITEM* textEdaItem = dynamic_cast<EDA_ITEM*>( aKiCadTextItem );
wxCHECK( textEdaItem, /* void */ ); // ensure this is a EDA_ITEM
switch( textEdaItem->Type() )
@ -3124,10 +3125,10 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT
// And correct the error introduced by the text offsetting in KiCad
switch( spin )
{
case TEXT_SPIN_STYLE::BOTTOM: pos = { bb.GetRight() - off, bb.GetTop() }; break;
case TEXT_SPIN_STYLE::UP: pos = { bb.GetRight() - off, bb.GetBottom() }; break;
case TEXT_SPIN_STYLE::LEFT: pos = { bb.GetRight() , bb.GetBottom() + off }; break;
case TEXT_SPIN_STYLE::RIGHT: pos = { bb.GetLeft() , bb.GetBottom() + off }; break;
case SPIN_STYLE::BOTTOM: pos = { bb.GetRight() - off, bb.GetTop() }; break;
case SPIN_STYLE::UP: pos = { bb.GetRight() - off, bb.GetBottom() }; break;
case SPIN_STYLE::LEFT: pos = { bb.GetRight() , bb.GetBottom() + off }; break;
case SPIN_STYLE::RIGHT: pos = { bb.GetLeft() , bb.GetBottom() + off }; break;
}
aKiCadTextItem->SetTextPos( pos );
@ -3139,7 +3140,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT
case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_SHEET_PIN_T:
static_cast<SCH_TEXT*>( aKiCadTextItem )->SetTextSpinStyle( spin );
static_cast<SCH_LABEL_BASE*>( aKiCadTextItem )->SetSpinStyle( spin );
return;
default:

View File

@ -41,7 +41,7 @@
struct CADSTAR_PART_ENTRY;
class BUS_ALIAS;
class EDA_TEXT;
class TEXT_SPIN_STYLE;
class SPIN_STYLE;
class LIB_FIELD;
class LIB_SYMBOL;
class REPORTER;
@ -261,8 +261,8 @@ private:
ELECTRICAL_PINTYPE getKiCadPinType( const CADSTAR_PIN_TYPE& aPinType );
int getKiCadUnitNumberFromGate( const GATE_ID& aCadstarGateID );
TEXT_SPIN_STYLE getSpinStyle( const long long& aCadstarOrientation, bool aMirror );
TEXT_SPIN_STYLE getSpinStyle( const EDA_ANGLE& aOrientation );
SPIN_STYLE getSpinStyle( const long long& aCadstarOrientation, bool aMirror );
SPIN_STYLE getSpinStyle( const EDA_ANGLE& aOrientation );
ALIGNMENT mirrorX( const ALIGNMENT& aCadstarAlignment );
ALIGNMENT rotate180( const ALIGNMENT& aCadstarAlignment );

View File

@ -1326,7 +1326,7 @@ void SCH_EAGLE_PLUGIN::loadSegments( wxXmlNode* aSegmentsNode, const wxString& n
// feature of Eagle schematics.
if( !labelled && firstWireFound )
{
std::unique_ptr<SCH_TEXT> label;
std::unique_ptr<SCH_LABEL_BASE> label;
// Add a global label if the net appears on more than one Eagle sheet
if( m_netCounts[netName.ToStdString()] > 1 )
@ -1342,9 +1342,9 @@ void SCH_EAGLE_PLUGIN::loadSegments( wxXmlNode* aSegmentsNode, const wxString& n
schIUScale.MilsToIU( 40 ) ) );
if( firstWire.B.x > firstWire.A.x )
label->SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT );
label->SetSpinStyle( SPIN_STYLE::LEFT );
else
label->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
label->SetSpinStyle( SPIN_STYLE::RIGHT );
screen->Append( label.release() );
}
@ -1500,8 +1500,8 @@ SCH_TEXT* SCH_EAGLE_PLUGIN::loadLabel( wxXmlNode* aLabelNode, const wxString& aN
// Determine if the label is local or global depending on
// the number of sheets the net appears in
bool global = m_netCounts[aNetName] > 1;
std::unique_ptr<SCH_TEXT> label;
bool global = m_netCounts[aNetName] > 1;
std::unique_ptr<SCH_LABEL_BASE> label;
VECTOR2I textSize = VECTOR2I( KiROUND( elabel.size.ToSchUnits() * 0.7 ),
KiROUND( elabel.size.ToSchUnits() * 0.7 ) );
@ -1514,7 +1514,7 @@ SCH_TEXT* SCH_EAGLE_PLUGIN::loadLabel( wxXmlNode* aLabelNode, const wxString& aN
label->SetPosition( elabelpos );
label->SetText( escapeName( elabel.netname ) );
label->SetTextSize( textSize );
label->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
label->SetSpinStyle( SPIN_STYLE::RIGHT );
if( elabel.rot )
{
@ -3391,10 +3391,10 @@ void SCH_EAGLE_PLUGIN::addImplicitConnections( SCH_SYMBOL* aSymbol, SCH_SCREEN*
switch( pin->GetOrientation() )
{
case PIN_ORIENTATION::PIN_LEFT: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT ); break;
case PIN_ORIENTATION::PIN_RIGHT: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT ); break;
case PIN_ORIENTATION::PIN_UP: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::UP ); break;
case PIN_ORIENTATION::PIN_DOWN: netLabel->SetTextSpinStyle( TEXT_SPIN_STYLE::BOTTOM ); break;
case PIN_ORIENTATION::PIN_LEFT: netLabel->SetSpinStyle( SPIN_STYLE::RIGHT ); break;
case PIN_ORIENTATION::PIN_RIGHT: netLabel->SetSpinStyle( SPIN_STYLE::LEFT ); break;
case PIN_ORIENTATION::PIN_UP: netLabel->SetSpinStyle( SPIN_STYLE::UP ); break;
case PIN_ORIENTATION::PIN_DOWN: netLabel->SetSpinStyle( SPIN_STYLE::BOTTOM ); break;
}
aScreen->Append( netLabel );

View File

@ -3831,17 +3831,18 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
case T_at:
text->SetPosition( parseXY() );
text->SetTextAngle( EDA_ANGLE( parseDouble( "text angle" ), DEGREES_T ) );
switch( static_cast<int>( parseDouble( "text angle" ) ) )
if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( text.get() ) )
{
case 0: text->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT ); break;
case 90: text->SetTextSpinStyle( TEXT_SPIN_STYLE::UP ); break;
case 180: text->SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT ); break;
case 270: text->SetTextSpinStyle( TEXT_SPIN_STYLE::BOTTOM ); break;
default:
wxFAIL;
text->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
break;
switch( static_cast<int>( label->GetTextAngle().AsDegrees() ) )
{
case 0: label->SetSpinStyle( SPIN_STYLE::RIGHT ); break;
case 90: label->SetSpinStyle( SPIN_STYLE::UP ); break;
case 180: label->SetSpinStyle( SPIN_STYLE::LEFT ); break;
case 270: label->SetSpinStyle( SPIN_STYLE::BOTTOM ); break;
default: wxFAIL; label->SetSpinStyle( SPIN_STYLE::RIGHT ); break;
}
}
NeedRIGHT();
@ -3895,26 +3896,6 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
case T_effects:
parseEDA_TEXT( static_cast<EDA_TEXT*>( text.get() ), true );
// Spin style is defined differently for graphical text (#SCH_TEXT) objects.
if( text->Type() == SCH_TEXT_T )
{
if( text->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT
&& text->GetTextAngle().IsVertical() )
{
// The vertically aligned text angle is always 90 (labels use 270 for the
// down direction) combined with the text justification flags.
text->SetTextSpinStyle( TEXT_SPIN_STYLE::BOTTOM );
}
else if( text->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT
&& text->GetTextAngle().IsHorizontal() )
{
// The horizontally aligned text angle is always 0 (labels use 180 for the
// left direction) combined with the text justification flags.
text->SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT );
}
}
break;
case T_iref: // legacy format; current is a T_property (aka SCH_FIELD)

View File

@ -1283,22 +1283,22 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel )
if( label )
{
if( aText->Type() == SCH_GLOBAL_LABEL_T
|| aText->Type() == SCH_HIER_LABEL_T
|| aText->Type() == SCH_DIRECTIVE_LABEL_T )
if( label->Type() == SCH_GLOBAL_LABEL_T
|| label->Type() == SCH_HIER_LABEL_T
|| label->Type() == SCH_DIRECTIVE_LABEL_T )
{
m_out->Print( 0, " (shape %s)", getSheetPinShapeToken( label->GetShape() ) );
}
// The angle of the text is always 0 or 90 degrees for readibility reasons,
// but the item itself can have more rotation (-90 and 180 deg)
switch( aText->GetTextSpinStyle() )
switch( label->GetSpinStyle() )
{
default:
case TEXT_SPIN_STYLE::LEFT: angle += ANGLE_180; break;
case TEXT_SPIN_STYLE::UP: break;
case TEXT_SPIN_STYLE::RIGHT: break;
case TEXT_SPIN_STYLE::BOTTOM: angle += ANGLE_180; break;
case SPIN_STYLE::LEFT: angle += ANGLE_180; break;
case SPIN_STYLE::UP: break;
case SPIN_STYLE::RIGHT: break;
case SPIN_STYLE::BOTTOM: angle += ANGLE_180; break;
}
}

View File

@ -990,42 +990,46 @@ SCH_TEXT* SCH_LEGACY_PLUGIN::loadText( LINE_READER& aReader )
}
int spinStyle = parseInt( aReader, line, &line );
// Sadly we store the orientation of hierarchical and global labels using a different
// int encoding than that for local labels:
// Global Local
// Left justified 0 2
// Up 1 3
// Right justified 2 0
// Down 3 1
// So we must flip it as the enum is setup with the "global" numbering
if( text->Type() != SCH_GLOBAL_LABEL_T && text->Type() != SCH_HIER_LABEL_T )
{
if( spinStyle == 0 )
spinStyle = 2;
else if( spinStyle == 2 )
spinStyle = 0;
}
text->SetTextSpinStyle( static_cast<TEXT_SPIN_STYLE::SPIN>( spinStyle ) );
int size = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
text->SetTextSize( VECTOR2I( size, size ) );
// Parse the global and hierarchical label type.
if( text->Type() == SCH_HIER_LABEL_T || text->Type() == SCH_GLOBAL_LABEL_T )
if( textType == SCH_LABEL_T || textType == SCH_HIER_LABEL_T || textType == SCH_GLOBAL_LABEL_T )
{
auto resultIt = std::find_if( sheetLabelNames.begin(), sheetLabelNames.end(),
[ &line ]( const auto& it )
{
return strCompare( it.second, line, &line );
} );
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( text.get() );
if( resultIt != sheetLabelNames.end() )
text->SetShape( resultIt->first );
else
SCH_PARSE_ERROR( "invalid label type", aReader, line );
// Sadly we store the orientation of hierarchical and global labels using a different
// int encoding than that for local labels:
// Global Local
// Left justified 0 2
// Up 1 3
// Right justified 2 0
// Down 3 1
// So we must flip it as the enum is setup with the "global" numbering
if( textType == SCH_LABEL_T )
{
if( spinStyle == 0 )
spinStyle = 2;
else if( spinStyle == 2 )
spinStyle = 0;
}
label->SetSpinStyle( static_cast<SPIN_STYLE::SPIN>( spinStyle ) );
// Parse the global and hierarchical label type.
if( textType == SCH_HIER_LABEL_T || textType == SCH_GLOBAL_LABEL_T )
{
auto resultIt = std::find_if( sheetLabelNames.begin(), sheetLabelNames.end(),
[ &line ]( const auto& it )
{
return strCompare( it.second, line, &line );
} );
if( resultIt != sheetLabelNames.end() )
label->SetShape( resultIt->first );
else
SCH_PARSE_ERROR( "invalid label type", aReader, line );
}
}
int penWidth = 0;
@ -1991,13 +1995,18 @@ void SCH_LEGACY_PLUGIN::saveText( SCH_TEXT* aText )
textType = "Label";
}
// Local labels must have their spin style inverted for left and right
int spinStyle = static_cast<int>( aText->GetTextSpinStyle() );
int spinStyle = 0;
if( spinStyle == 0 )
spinStyle = 2;
else if( spinStyle == 2 )
spinStyle = 0;
// Local labels must have their spin style inverted for left and right
if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( aText ) )
{
spinStyle = static_cast<int>( label->GetSpinStyle() );
if( spinStyle == 0 )
spinStyle = 2;
else if( spinStyle == 2 )
spinStyle = 0;
}
m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %d\n%s\n", textType,
schIUScale.IUToMils( aText->GetPosition().x ),
@ -2010,13 +2019,14 @@ void SCH_LEGACY_PLUGIN::saveText( SCH_TEXT* aText )
{
textType = ( layer == LAYER_GLOBLABEL ) ? "GLabel" : "HLabel";
auto shapeLabelIt = sheetLabelNames.find( aText->GetShape() );
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aText );
auto shapeLabelIt = sheetLabelNames.find( label->GetShape() );
wxCHECK_RET( shapeLabelIt != sheetLabelNames.end(), "Shape not found in names list" );
m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %s %d\n%s\n", textType,
schIUScale.IUToMils( aText->GetPosition().x ),
schIUScale.IUToMils( aText->GetPosition().y ),
static_cast<int>( aText->GetTextSpinStyle() ),
static_cast<int>( label->GetSpinStyle() ),
schIUScale.IUToMils( aText->GetTextWidth() ),
shapeLabelIt->second,
italics,

View File

@ -904,13 +904,13 @@ SCH_LABEL_BASE* LTSPICE_SCH_PARSER::CreateSCH_LABEL( KICAD_T aType, const VECTOR
label->SetText( aValue );
label->SetTextSize( ToKicadFontSize( aFontSize ) );
label->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
label->SetSpinStyle( SPIN_STYLE::RIGHT );
}
else if( aType == SCH_DIRECTIVE_LABEL_T )
{
label = new SCH_DIRECTIVE_LABEL();
label->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
label->SetSpinStyle( SPIN_STYLE::RIGHT );
SCH_FIELD field( { 0, 0 }, -1, label, wxS( "DATAFLAG" ) );
field.SetText( aValue );

View File

@ -502,9 +502,9 @@ bool SCH_SCREEN::IsExplicitJunctionNeeded( const VECTOR2I& aPosition ) const
return isJunction && !hasBusEntry && !hasExplicitJunction;
}
TEXT_SPIN_STYLE SCH_SCREEN::GetLabelOrientationForPoint( const VECTOR2I& aPosition,
TEXT_SPIN_STYLE aDefaultOrientation,
const SCH_SHEET_PATH* aSheet ) const
SPIN_STYLE SCH_SCREEN::GetLabelOrientationForPoint( const VECTOR2I& aPosition,
SPIN_STYLE aDefaultOrientation,
const SCH_SHEET_PATH* aSheet ) const
{
auto ret = aDefaultOrientation;
for( SCH_ITEM* item : Items().Overlapping( aPosition ) )
@ -527,18 +527,18 @@ TEXT_SPIN_STYLE SCH_SCREEN::GetLabelOrientationForPoint( const VECTOR2I& a
// bus is vertical -> label shall be horizontal and
// shall be placed to the side where the bus entry is
if( aPosition.x < bus->GetPosition().x )
ret = TEXT_SPIN_STYLE::LEFT;
ret = SPIN_STYLE::LEFT;
else if( aPosition.x > bus->GetPosition().x )
ret = TEXT_SPIN_STYLE::RIGHT;
ret = SPIN_STYLE::RIGHT;
}
else if( bus->Angle().AsDegrees() == 0.0 )
{
// bus is horizontal -> label shall be vertical and
// shall be placed to the side where the bus entry is
if( aPosition.y < bus->GetPosition().y )
ret = TEXT_SPIN_STYLE::UP;
ret = SPIN_STYLE::UP;
else if( aPosition.y > bus->GetPosition().y )
ret = TEXT_SPIN_STYLE::BOTTOM;
ret = SPIN_STYLE::BOTTOM;
}
}
}
@ -553,28 +553,16 @@ TEXT_SPIN_STYLE SCH_SCREEN::GetLabelOrientationForPoint( const VECTOR2I& a
if( -45 < angle && angle <= 45 )
{
if( line->GetStartPoint().x <= line->GetEndPoint().x )
{
ret = line->GetEndPoint() == aPosition ? TEXT_SPIN_STYLE::RIGHT
: TEXT_SPIN_STYLE::LEFT;
}
ret = line->GetEndPoint() == aPosition ? SPIN_STYLE::RIGHT : SPIN_STYLE::LEFT;
else
{
ret = line->GetEndPoint() == aPosition ? TEXT_SPIN_STYLE::LEFT
: TEXT_SPIN_STYLE::RIGHT;
}
ret = line->GetEndPoint() == aPosition ? SPIN_STYLE::LEFT : SPIN_STYLE::RIGHT;
}
else
{
if( line->GetStartPoint().y <= line->GetEndPoint().y )
{
ret = line->GetEndPoint() == aPosition ? TEXT_SPIN_STYLE::BOTTOM
: TEXT_SPIN_STYLE::UP;
}
ret = line->GetEndPoint() == aPosition ? SPIN_STYLE::BOTTOM : SPIN_STYLE::UP;
else
{
ret = line->GetEndPoint() == aPosition ? TEXT_SPIN_STYLE::UP
: TEXT_SPIN_STYLE::BOTTOM;
}
ret = line->GetEndPoint() == aPosition ? SPIN_STYLE::UP : SPIN_STYLE::BOTTOM;
}
}
break;
@ -588,103 +576,95 @@ TEXT_SPIN_STYLE SCH_SCREEN::GetLabelOrientationForPoint( const VECTOR2I& a
if( pin->GetPosition() == aPosition )
{
if( pin->GetOrientation() == PIN_ORIENTATION::PIN_RIGHT )
{
ret = TEXT_SPIN_STYLE::LEFT;
}
ret = SPIN_STYLE::LEFT;
else if( pin->GetOrientation() == PIN_ORIENTATION::PIN_LEFT )
{
ret = TEXT_SPIN_STYLE::RIGHT;
}
ret = SPIN_STYLE::RIGHT;
else if( pin->GetOrientation() == PIN_ORIENTATION::PIN_UP )
{
ret = TEXT_SPIN_STYLE::BOTTOM;
}
ret = SPIN_STYLE::BOTTOM;
else if( pin->GetOrientation() == PIN_ORIENTATION::PIN_DOWN )
{
ret = TEXT_SPIN_STYLE::UP;
}
ret = SPIN_STYLE::UP;
switch( static_cast<SYMBOL_ORIENTATION_T>(
symbol->GetOrientation() & ( ~( SYM_MIRROR_X | SYM_MIRROR_Y ) ) ) )
{
case SYM_ROTATE_CLOCKWISE:
case SYM_ORIENT_90:
if( ret == TEXT_SPIN_STYLE::UP )
ret = TEXT_SPIN_STYLE::LEFT;
else if( ret == TEXT_SPIN_STYLE::BOTTOM )
ret = TEXT_SPIN_STYLE::RIGHT;
else if( ret == TEXT_SPIN_STYLE::LEFT )
ret = TEXT_SPIN_STYLE::BOTTOM;
else if( ret == TEXT_SPIN_STYLE::RIGHT )
ret = TEXT_SPIN_STYLE::UP;
if( ret == SPIN_STYLE::UP )
ret = SPIN_STYLE::LEFT;
else if( ret == SPIN_STYLE::BOTTOM )
ret = SPIN_STYLE::RIGHT;
else if( ret == SPIN_STYLE::LEFT )
ret = SPIN_STYLE::BOTTOM;
else if( ret == SPIN_STYLE::RIGHT )
ret = SPIN_STYLE::UP;
if( symbol->GetOrientation() & SYM_MIRROR_X )
{
if( ret == TEXT_SPIN_STYLE::UP )
ret = TEXT_SPIN_STYLE::BOTTOM;
else if( ret == TEXT_SPIN_STYLE::BOTTOM )
ret = TEXT_SPIN_STYLE::UP;
if( ret == SPIN_STYLE::UP )
ret = SPIN_STYLE::BOTTOM;
else if( ret == SPIN_STYLE::BOTTOM )
ret = SPIN_STYLE::UP;
}
if( symbol->GetOrientation() & SYM_MIRROR_Y )
{
if( ret == TEXT_SPIN_STYLE::LEFT )
ret = TEXT_SPIN_STYLE::RIGHT;
else if( ret == TEXT_SPIN_STYLE::RIGHT )
ret = TEXT_SPIN_STYLE::LEFT;
if( ret == SPIN_STYLE::LEFT )
ret = SPIN_STYLE::RIGHT;
else if( ret == SPIN_STYLE::RIGHT )
ret = SPIN_STYLE::LEFT;
}
break;
case SYM_ROTATE_COUNTERCLOCKWISE:
case SYM_ORIENT_270:
if( ret == TEXT_SPIN_STYLE::UP )
ret = TEXT_SPIN_STYLE::RIGHT;
else if( ret == TEXT_SPIN_STYLE::BOTTOM )
ret = TEXT_SPIN_STYLE::LEFT;
else if( ret == TEXT_SPIN_STYLE::LEFT )
ret = TEXT_SPIN_STYLE::UP;
else if( ret == TEXT_SPIN_STYLE::RIGHT )
ret = TEXT_SPIN_STYLE::BOTTOM;
if( ret == SPIN_STYLE::UP )
ret = SPIN_STYLE::RIGHT;
else if( ret == SPIN_STYLE::BOTTOM )
ret = SPIN_STYLE::LEFT;
else if( ret == SPIN_STYLE::LEFT )
ret = SPIN_STYLE::UP;
else if( ret == SPIN_STYLE::RIGHT )
ret = SPIN_STYLE::BOTTOM;
if( symbol->GetOrientation() & SYM_MIRROR_X )
{
if( ret == TEXT_SPIN_STYLE::UP )
ret = TEXT_SPIN_STYLE::BOTTOM;
else if( ret == TEXT_SPIN_STYLE::BOTTOM )
ret = TEXT_SPIN_STYLE::UP;
if( ret == SPIN_STYLE::UP )
ret = SPIN_STYLE::BOTTOM;
else if( ret == SPIN_STYLE::BOTTOM )
ret = SPIN_STYLE::UP;
}
if( symbol->GetOrientation() & SYM_MIRROR_Y )
{
if( ret == TEXT_SPIN_STYLE::LEFT )
ret = TEXT_SPIN_STYLE::RIGHT;
else if( ret == TEXT_SPIN_STYLE::RIGHT )
ret = TEXT_SPIN_STYLE::LEFT;
if( ret == SPIN_STYLE::LEFT )
ret = SPIN_STYLE::RIGHT;
else if( ret == SPIN_STYLE::RIGHT )
ret = SPIN_STYLE::LEFT;
}
break;
case SYM_ORIENT_180:
if( ret == TEXT_SPIN_STYLE::UP )
ret = TEXT_SPIN_STYLE::BOTTOM;
else if( ret == TEXT_SPIN_STYLE::BOTTOM )
ret = TEXT_SPIN_STYLE::UP;
else if( ret == TEXT_SPIN_STYLE::LEFT )
ret = TEXT_SPIN_STYLE::RIGHT;
else if( ret == TEXT_SPIN_STYLE::RIGHT )
ret = TEXT_SPIN_STYLE::LEFT;
if( ret == SPIN_STYLE::UP )
ret = SPIN_STYLE::BOTTOM;
else if( ret == SPIN_STYLE::BOTTOM )
ret = SPIN_STYLE::UP;
else if( ret == SPIN_STYLE::LEFT )
ret = SPIN_STYLE::RIGHT;
else if( ret == SPIN_STYLE::RIGHT )
ret = SPIN_STYLE::LEFT;
if( symbol->GetOrientation() & SYM_MIRROR_X )
{
if( ret == TEXT_SPIN_STYLE::UP )
ret = TEXT_SPIN_STYLE::BOTTOM;
else if( ret == TEXT_SPIN_STYLE::BOTTOM )
ret = TEXT_SPIN_STYLE::UP;
if( ret == SPIN_STYLE::UP )
ret = SPIN_STYLE::BOTTOM;
else if( ret == SPIN_STYLE::BOTTOM )
ret = SPIN_STYLE::UP;
}
if( symbol->GetOrientation() & SYM_MIRROR_Y )
{
if( ret == TEXT_SPIN_STYLE::LEFT )
ret = TEXT_SPIN_STYLE::RIGHT;
else if( ret == TEXT_SPIN_STYLE::RIGHT )
ret = TEXT_SPIN_STYLE::LEFT;
if( ret == SPIN_STYLE::LEFT )
ret = SPIN_STYLE::RIGHT;
else if( ret == SPIN_STYLE::RIGHT )
ret = SPIN_STYLE::LEFT;
}
break;
case SYM_ORIENT_0:
@ -692,18 +672,18 @@ TEXT_SPIN_STYLE SCH_SCREEN::GetLabelOrientationForPoint( const VECTOR2I& a
default:
if( symbol->GetOrientation() & SYM_MIRROR_X )
{
if( ret == TEXT_SPIN_STYLE::UP )
ret = TEXT_SPIN_STYLE::BOTTOM;
else if( ret == TEXT_SPIN_STYLE::BOTTOM )
ret = TEXT_SPIN_STYLE::UP;
if( ret == SPIN_STYLE::UP )
ret = SPIN_STYLE::BOTTOM;
else if( ret == SPIN_STYLE::BOTTOM )
ret = SPIN_STYLE::UP;
}
if( symbol->GetOrientation() & SYM_MIRROR_Y )
{
if( ret == TEXT_SPIN_STYLE::LEFT )
ret = TEXT_SPIN_STYLE::RIGHT;
else if( ret == TEXT_SPIN_STYLE::RIGHT )
ret = TEXT_SPIN_STYLE::LEFT;
if( ret == SPIN_STYLE::LEFT )
ret = SPIN_STYLE::RIGHT;
else if( ret == SPIN_STYLE::RIGHT )
ret = SPIN_STYLE::LEFT;
}
break;
}

View File

@ -49,7 +49,7 @@
#include <sch_reference_list.h>
#include <sch_rtree.h>
#include <sch_sheet.h>
#include <sch_text.h>
#include <sch_label.h>
#include <sch_sheet_path.h>
class BUS_ALIAS;
@ -340,9 +340,9 @@ public:
*/
bool IsExplicitJunctionNeeded( const VECTOR2I& aPosition ) const;
TEXT_SPIN_STYLE GetLabelOrientationForPoint( const VECTOR2I& aPosition,
TEXT_SPIN_STYLE aDefaultOrientation,
const SCH_SHEET_PATH* aSheet ) const;
SPIN_STYLE GetLabelOrientationForPoint( const VECTOR2I& aPosition,
SPIN_STYLE aDefaultOrientation,
const SCH_SHEET_PATH* aSheet ) const;
/**
* Indicates that a juction dot may be placed at the given location. See IsJunctionNeeded
* for more info.

View File

@ -121,25 +121,25 @@ void SCH_SHEET_PIN::SetSide( SHEET_SIDE aEdge )
case SHEET_SIDE::LEFT:
m_edge = aEdge;
SetTextX( Sheet->m_pos.x );
SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT ); // Orientation horiz inverse
SetSpinStyle( SPIN_STYLE::RIGHT ); // Orientation horiz inverse
break;
case SHEET_SIDE::RIGHT:
m_edge = aEdge;
SetTextX( Sheet->m_pos.x + Sheet->m_size.x );
SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT ); // Orientation horiz normal
SetSpinStyle( SPIN_STYLE::LEFT ); // Orientation horiz normal
break;
case SHEET_SIDE::TOP:
m_edge = aEdge;
SetTextY( Sheet->m_pos.y );
SetTextSpinStyle( TEXT_SPIN_STYLE::BOTTOM ); // Orientation vert BOTTOM
SetSpinStyle( SPIN_STYLE::BOTTOM ); // Orientation vert BOTTOM
break;
case SHEET_SIDE::BOTTOM:
m_edge = aEdge;
SetTextY( Sheet->m_pos.y + Sheet->m_size.y );
SetTextSpinStyle( TEXT_SPIN_STYLE::UP ); // Orientation vert UP
SetSpinStyle( SPIN_STYLE::UP ); // Orientation vert UP
break;
default:

View File

@ -48,70 +48,6 @@
using KIGFX::SCH_RENDER_SETTINGS;
TEXT_SPIN_STYLE TEXT_SPIN_STYLE::RotateCW()
{
SPIN newSpin = m_spin;
switch( m_spin )
{
case TEXT_SPIN_STYLE::LEFT: newSpin = TEXT_SPIN_STYLE::UP; break;
case TEXT_SPIN_STYLE::UP: newSpin = TEXT_SPIN_STYLE::RIGHT; break;
case TEXT_SPIN_STYLE::RIGHT: newSpin = TEXT_SPIN_STYLE::BOTTOM; break;
case TEXT_SPIN_STYLE::BOTTOM: newSpin = TEXT_SPIN_STYLE::LEFT; break;
}
return TEXT_SPIN_STYLE( newSpin );
}
TEXT_SPIN_STYLE TEXT_SPIN_STYLE::RotateCCW()
{
SPIN newSpin = m_spin;
switch( m_spin )
{
case TEXT_SPIN_STYLE::LEFT: newSpin = TEXT_SPIN_STYLE::BOTTOM; break;
case TEXT_SPIN_STYLE::BOTTOM: newSpin = TEXT_SPIN_STYLE::RIGHT; break;
case TEXT_SPIN_STYLE::RIGHT: newSpin = TEXT_SPIN_STYLE::UP; break;
case TEXT_SPIN_STYLE::UP: newSpin = TEXT_SPIN_STYLE::LEFT; break;
}
return TEXT_SPIN_STYLE( newSpin );
}
TEXT_SPIN_STYLE TEXT_SPIN_STYLE::MirrorX()
{
SPIN newSpin = m_spin;
switch( m_spin )
{
case TEXT_SPIN_STYLE::UP: newSpin = TEXT_SPIN_STYLE::BOTTOM; break;
case TEXT_SPIN_STYLE::BOTTOM: newSpin = TEXT_SPIN_STYLE::UP; break;
case TEXT_SPIN_STYLE::LEFT: break;
case TEXT_SPIN_STYLE::RIGHT: break;
}
return TEXT_SPIN_STYLE( newSpin );
}
TEXT_SPIN_STYLE TEXT_SPIN_STYLE::MirrorY()
{
SPIN newSpin = m_spin;
switch( m_spin )
{
case TEXT_SPIN_STYLE::LEFT: newSpin = TEXT_SPIN_STYLE::RIGHT; break;
case TEXT_SPIN_STYLE::RIGHT: newSpin = TEXT_SPIN_STYLE::LEFT; break;
case TEXT_SPIN_STYLE::UP: break;
case TEXT_SPIN_STYLE::BOTTOM: break;
}
return TEXT_SPIN_STYLE( newSpin );
}
SCH_TEXT::SCH_TEXT( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) :
SCH_ITEM( nullptr, aType ),
EDA_TEXT( schIUScale, text )
@ -119,7 +55,6 @@ SCH_TEXT::SCH_TEXT( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) :
m_layer = LAYER_NOTES;
SetTextPos( pos );
SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT );
SetMultilineAllowed( true );
m_excludedFromSim = false;
@ -128,8 +63,7 @@ SCH_TEXT::SCH_TEXT( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) :
SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) :
SCH_ITEM( aText ),
EDA_TEXT( aText ),
m_spin_style( aText.m_spin_style )
EDA_TEXT( aText )
{
m_excludedFromSim = aText.m_excludedFromSim;
}
@ -142,21 +76,36 @@ VECTOR2I SCH_TEXT::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) co
}
void SCH_TEXT::FlipHJustify()
{
if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
}
void SCH_TEXT::MirrorHorizontally( int aCenter )
{
// Text is NOT really mirrored; it is moved to a suitable horizontal position
SetTextSpinStyle( GetTextSpinStyle().MirrorY() );
if( GetTextAngle() == ANGLE_HORIZONTAL )
{
FlipHJustify();
SetTextX( MIRRORVAL( GetTextPos().x, aCenter ) );
if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT || GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
SetTextX( MIRRORVAL( GetTextPos().x, aCenter ) );
}
}
void SCH_TEXT::MirrorVertically( int aCenter )
{
// Text is NOT really mirrored; it is moved to a suitable vertical position
SetTextSpinStyle( GetTextSpinStyle().MirrorX() );
if( GetTextAngle() == ANGLE_VERTICAL )
{
FlipHJustify();
SetTextY( MIRRORVAL( GetTextPos().y, aCenter ) );
if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT || GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
SetTextY( MIRRORVAL( GetTextPos().y, aCenter ) );
}
}
@ -174,57 +123,23 @@ void SCH_TEXT::Rotate( const VECTOR2I& aCenter )
void SCH_TEXT::Rotate90( bool aClockwise )
{
if( aClockwise )
SetTextSpinStyle( GetTextSpinStyle().RotateCW() );
else
SetTextSpinStyle( GetTextSpinStyle().RotateCCW() );
if( ( GetTextAngle() == ANGLE_HORIZONTAL && aClockwise )
|| ( GetTextAngle() == ANGLE_HORIZONTAL && !aClockwise ) )
{
FlipHJustify();
}
SetTextAngle( GetTextAngle() == ANGLE_VERTICAL ? ANGLE_HORIZONTAL : ANGLE_VERTICAL );
}
void SCH_TEXT::MirrorSpinStyle( bool aLeftRight )
{
if( aLeftRight )
SetTextSpinStyle( GetTextSpinStyle().MirrorY() );
else
SetTextSpinStyle( GetTextSpinStyle().MirrorX() );
}
void SCH_TEXT::SetTextSpinStyle( TEXT_SPIN_STYLE aSpinStyle )
{
m_spin_style = aSpinStyle;
// Assume "Right" and Left" mean which side of the anchor the text will be on
// Thus we want to left justify text up against the anchor if we are on the right
switch( aSpinStyle )
if( ( GetTextAngle() == ANGLE_HORIZONTAL && aLeftRight )
|| ( GetTextAngle() == ANGLE_VERTICAL && !aLeftRight ) )
{
default:
wxFAIL_MSG( "Bad spin style" );
m_spin_style = TEXT_SPIN_STYLE::RIGHT; // Handle the error spin style by resetting
KI_FALLTHROUGH;
case TEXT_SPIN_STYLE::RIGHT: // Horiz Normal Orientation
SetTextAngle( ANGLE_HORIZONTAL );
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case TEXT_SPIN_STYLE::UP: // Vert Orientation UP
SetTextAngle( ANGLE_VERTICAL );
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
break;
case TEXT_SPIN_STYLE::LEFT: // Horiz Orientation - Right justified
SetTextAngle( ANGLE_HORIZONTAL );
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
case TEXT_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
SetTextAngle( ANGLE_VERTICAL );
SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
break;
FlipHJustify();
}
SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
}
@ -235,7 +150,6 @@ void SCH_TEXT::SwapData( SCH_ITEM* aItem )
SCH_TEXT* item = static_cast<SCH_TEXT*>( aItem );
std::swap( m_layer, item->m_layer );
std::swap( m_spin_style, item->m_spin_style );
SwapText( *item );
SwapAttributes( *item );
@ -514,13 +428,11 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
switch( GetTextSpinStyle() )
switch( GetHorizJustify() )
{
case TEXT_SPIN_STYLE::LEFT: msg = _( "Align right" ); break;
case TEXT_SPIN_STYLE::UP: msg = _( "Align bottom" ); break;
case TEXT_SPIN_STYLE::RIGHT: msg = _( "Align left" ); break;
case TEXT_SPIN_STYLE::BOTTOM: msg = _( "Align top" ); break;
default: msg = wxT( "???" ); break;
case GR_TEXT_H_ALIGN_LEFT: msg = _( "Align left" ); break;
case GR_TEXT_H_ALIGN_CENTER: msg = _( "Align center" ); break;
case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Align right" ); break;
}
aList.emplace_back( _( "Justification" ), msg );

View File

@ -34,80 +34,6 @@
class HTML_MESSAGE_BOX;
/*
* Spin style for text items of all kinds on schematics
* Basically a higher level abstraction of rotation and justification of text
*/
class TEXT_SPIN_STYLE
{
public:
enum SPIN : int
{
LEFT = 0,
UP = 1,
RIGHT = 2,
BOTTOM = 3
};
TEXT_SPIN_STYLE() = default;
constexpr TEXT_SPIN_STYLE( SPIN aSpin ) : m_spin( aSpin )
{
}
constexpr bool operator==( SPIN a ) const
{
return m_spin == a;
}
constexpr bool operator!=( SPIN a ) const
{
return m_spin != a;
}
operator int() const
{
return static_cast<int>( m_spin );
}
TEXT_SPIN_STYLE RotateCW();
TEXT_SPIN_STYLE RotateCCW();
/**
* Mirror the label spin style across the X axis or simply swaps up and bottom.
*/
TEXT_SPIN_STYLE MirrorX();
/**
* Mirror the label spin style across the Y axis or simply swaps left and right.
*/
TEXT_SPIN_STYLE MirrorY();
private:
SPIN m_spin;
};
/*
* Label and flag shapes used with text objects.
*/
enum LABEL_FLAG_SHAPE
{
L_INPUT,
L_OUTPUT,
L_BIDI,
L_TRISTATE,
L_UNSPECIFIED,
F_FIRST,
F_DOT = F_FIRST,
F_ROUND,
F_DIAMOND,
F_RECTANGLE
};
class SCH_TEXT : public SCH_ITEM, public EDA_TEXT
{
public:
@ -146,19 +72,6 @@ public:
void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; }
bool GetExcludedFromSim() const override { return m_excludedFromSim; }
/**
* Set a spin or rotation angle, along with specific horizontal and vertical justification
* styles with each angle.
*
* @param aSpinStyle Spin style as per #TEXT_SPIN_STYLE storage class, may be the enum
* values or int value
*/
virtual void SetTextSpinStyle( TEXT_SPIN_STYLE aSpinStyle );
TEXT_SPIN_STYLE GetTextSpinStyle() const { return m_spin_style; }
virtual LABEL_FLAG_SHAPE GetShape() const { return L_UNSPECIFIED; }
virtual void SetShape( LABEL_FLAG_SHAPE aShape ) { }
/**
* This offset depends on the orientation, the type of text, and the area required to
* draw the associated graphic symbol or to put the text above a wire.
@ -184,6 +97,7 @@ public:
EDA_TEXT::Offset( aMoveVector );
}
void FlipHJustify();
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter ) override;
@ -236,18 +150,6 @@ protected:
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
protected:
/**
* The orientation of text and any associated drawing elements of derived objects.
* - 0 is the horizontal and left justified.
* - 1 is vertical and top justified.
* - 2 is horizontal and right justified. It is the equivalent of the mirrored 0 orientation.
* - 3 is vertical and bottom justified. It is the equivalent of the mirrored 1 orientation.
*
* This is a duplication of m_Orient, m_HJustified, and m_VJustified in #EDA_TEXT but is
* easier to handle than 3 parameters when editing and reading and saving files.
*/
TEXT_SPIN_STYLE m_spin_style;
bool m_excludedFromSim;
};

View File

@ -586,17 +586,17 @@ void BACK_ANNOTATE::applyChangelist()
}
static TEXT_SPIN_STYLE orientLabel( SCH_PIN* aPin )
static SPIN_STYLE orientLabel( SCH_PIN* aPin )
{
TEXT_SPIN_STYLE spin = TEXT_SPIN_STYLE::RIGHT;
SPIN_STYLE spin = SPIN_STYLE::RIGHT;
// Initial orientation from the pin
switch( aPin->GetLibPin()->GetOrientation() )
{
case PIN_ORIENTATION::PIN_UP: spin = TEXT_SPIN_STYLE::BOTTOM; break;
case PIN_ORIENTATION::PIN_DOWN: spin = TEXT_SPIN_STYLE::UP; break;
case PIN_ORIENTATION::PIN_LEFT: spin = TEXT_SPIN_STYLE::RIGHT; break;
case PIN_ORIENTATION::PIN_RIGHT: spin = TEXT_SPIN_STYLE::LEFT; break;
case PIN_ORIENTATION::PIN_UP: spin = SPIN_STYLE::BOTTOM; break;
case PIN_ORIENTATION::PIN_DOWN: spin = SPIN_STYLE::UP; break;
case PIN_ORIENTATION::PIN_LEFT: spin = SPIN_STYLE::RIGHT; break;
case PIN_ORIENTATION::PIN_RIGHT: spin = SPIN_STYLE::LEFT; break;
}
// Reorient based on the actual symbol orientation now
@ -717,8 +717,8 @@ void BACK_ANNOTATE::processNetNameChange( SCH_COMMIT* aCommit, const wxString& a
case SCH_PIN_T:
{
SCH_PIN* schPin = static_cast<SCH_PIN*>( driver );
TEXT_SPIN_STYLE spin = orientLabel( schPin );
SCH_PIN* schPin = static_cast<SCH_PIN*>( driver );
SPIN_STYLE spin = orientLabel( schPin );
if( schPin->IsGlobalPower() )
{
@ -742,7 +742,7 @@ void BACK_ANNOTATE::processNetNameChange( SCH_COMMIT* aCommit, const wxString& a
SCH_LABEL* label = new SCH_LABEL( driver->GetPosition(), aNewName );
label->SetParent( &m_frame->Schematic() );
label->SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
label->SetTextSpinStyle( spin );
label->SetSpinStyle( spin );
label->SetFlags( IS_NEW );
SCH_SCREEN* screen = aConnection->Sheet().LastScreen();

View File

@ -30,7 +30,6 @@
#include <tools/ee_grid_helper.h>
#include <ee_actions.h>
#include <sch_edit_frame.h>
#include <project.h>
#include <pgm_base.h>
#include <eeschema_id.h>
#include <confirm.h>
@ -54,7 +53,6 @@
#include <dialogs/dialog_text_properties.h>
#include <dialogs/dialog_wire_bus_properties.h>
#include <dialogs/dialog_junction_props.h>
#include <dialogs/dialog_sheet_pin_properties.h>
#include <string_utils.h>
#include <wildcards_and_files_ext.h>
#include <wx/filedlg.h>
@ -64,7 +62,7 @@ SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() :
m_lastSheetPinType( LABEL_FLAG_SHAPE::L_INPUT ),
m_lastGlobalLabelShape( LABEL_FLAG_SHAPE::L_INPUT ),
m_lastNetClassFlagShape( LABEL_FLAG_SHAPE::F_ROUND ),
m_lastTextOrientation( TEXT_SPIN_STYLE::RIGHT ),
m_lastTextOrientation( SPIN_STYLE::RIGHT ),
m_lastTextBold( false ),
m_lastTextItalic( false ),
m_lastTextAngle( ANGLE_0 ),
@ -1044,7 +1042,9 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
textItem->SetItalic( m_lastTextItalic );
}
textItem->SetTextSpinStyle( m_lastTextOrientation );
if( labelItem )
labelItem->SetSpinStyle( m_lastTextOrientation );
textItem->SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
textItem->SetFlags( IS_NEW | IS_MOVING );
@ -1090,7 +1090,8 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
m_lastTextItalic = textItem->IsItalic();
}
m_lastTextOrientation = textItem->GetTextSpinStyle();
if( labelItem )
m_lastTextOrientation = labelItem->GetSpinStyle();
if( aType == LAYER_GLOBLABEL || aType == LAYER_HIERLABEL )
{

View File

@ -77,7 +77,7 @@ private:
LABEL_FLAG_SHAPE m_lastSheetPinType;
LABEL_FLAG_SHAPE m_lastGlobalLabelShape;
LABEL_FLAG_SHAPE m_lastNetClassFlagShape;
TEXT_SPIN_STYLE m_lastTextOrientation;
SPIN_STYLE m_lastTextOrientation;
bool m_lastTextBold;
bool m_lastTextItalic;
EDA_ANGLE m_lastTextAngle;

View File

@ -2108,12 +2108,13 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
if( item && item->Type() != convertTo )
{
EDA_TEXT* sourceText = dynamic_cast<EDA_TEXT*>( item );
bool selected = item->IsSelected();
SCH_ITEM* newtext = nullptr;
VECTOR2I position = item->GetPosition();
wxString txt;
wxString href;
TEXT_SPIN_STYLE orientation = TEXT_SPIN_STYLE::SPIN::RIGHT;
SPIN_STYLE spinStyle = SPIN_STYLE::SPIN::RIGHT;
LABEL_FLAG_SHAPE shape = LABEL_FLAG_SHAPE::L_UNSPECIFIED;
switch( item->Type() )
@ -2122,10 +2123,10 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T:
{
SCH_TEXT* label = static_cast<SCH_LABEL_BASE*>( item );
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( item );
txt = UnescapeString( label->GetText() );
orientation = label->GetTextSpinStyle();
spinStyle = label->GetSpinStyle();
shape = label->GetShape();
href = label->GetHyperlink();
break;
@ -2138,7 +2139,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
// a SCH_DIRECTIVE_LABEL has no text
txt = _( "<empty>" );
orientation = dirlabel->GetTextSpinStyle();
spinStyle = dirlabel->GetSpinStyle();
href = dirlabel->GetHyperlink();
break;
}
@ -2148,7 +2149,6 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
SCH_TEXT* text = static_cast<SCH_TEXT*>( item );
txt = text->GetText();
orientation = text->GetTextSpinStyle();
href = text->GetHyperlink();
break;
}
@ -2167,7 +2167,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( item );
wxCHECK( text, 0 );
int textSize = text->GetTextSize().y;
bbox.Inflate( item->Schematic()->Settings().m_LabelSizeRatio * textSize );
bbox.Inflate( KiROUND( item->Schematic()->Settings().m_LabelSizeRatio * textSize ) );
}
txt = textbox->GetText();
@ -2176,12 +2176,12 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
{
if( textbox->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
{
orientation = TEXT_SPIN_STYLE::SPIN::BOTTOM;
spinStyle = SPIN_STYLE::SPIN::BOTTOM;
position = VECTOR2I( bbox.Centre().x, bbox.GetOrigin().y );
}
else
{
orientation = TEXT_SPIN_STYLE::SPIN::UP;
spinStyle = SPIN_STYLE::SPIN::UP;
position = VECTOR2I( bbox.Centre().x, bbox.GetEnd().y );
}
}
@ -2189,12 +2189,12 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
{
if( textbox->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
{
orientation = TEXT_SPIN_STYLE::SPIN::LEFT;
spinStyle = SPIN_STYLE::SPIN::LEFT;
position = VECTOR2I( bbox.GetEnd().x, bbox.Centre().y );
}
else
{
orientation = TEXT_SPIN_STYLE::SPIN::RIGHT;
spinStyle = SPIN_STYLE::SPIN::RIGHT;
position = VECTOR2I( bbox.GetOrigin().x, bbox.Centre().y );
}
}
@ -2237,7 +2237,8 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
SCH_LABEL_BASE* new_label = new SCH_LABEL( position, getValidNetname( txt ) );
new_label->SetShape( shape );
new_label->SetTextSpinStyle( orientation );
new_label->SetAttributes( *sourceText, false );
new_label->SetSpinStyle( spinStyle );
new_label->SetHyperlink( href );
newtext = new_label;
break;
@ -2248,7 +2249,8 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
SCH_LABEL_BASE* new_label = new SCH_GLOBALLABEL( position, getValidNetname( txt ) );
new_label->SetShape( shape );
new_label->SetTextSpinStyle( orientation );
new_label->SetAttributes( *sourceText, false );
new_label->SetSpinStyle( spinStyle );
new_label->SetHyperlink( href );
newtext = new_label;
break;
@ -2259,7 +2261,8 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
SCH_LABEL_BASE* new_label = new SCH_HIERLABEL( position, getValidNetname( txt ) );
new_label->SetShape( shape );
new_label->SetTextSpinStyle( orientation );
new_label->SetAttributes( *sourceText, false );
new_label->SetSpinStyle( spinStyle );
new_label->SetHyperlink( href );
newtext = new_label;
break;
@ -2282,7 +2285,8 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
}
new_label->SetShape( LABEL_FLAG_SHAPE::F_ROUND );
new_label->SetTextSpinStyle( orientation );
new_label->SetAttributes( *sourceText, false );
new_label->SetSpinStyle( spinStyle );
new_label->SetHyperlink( href );
newtext = new_label;
break;
@ -2292,7 +2296,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
{
SCH_TEXT* new_text = new SCH_TEXT( position, txt );
new_text->SetTextSpinStyle( orientation );
new_text->SetAttributes( *sourceText, false );
new_text->SetHyperlink( href );
newtext = new_text;
break;
@ -2306,44 +2310,34 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item ) )
bbox.Inflate( -label->GetLabelBoxExpansion() );
EDA_TEXT* textItem = dynamic_cast<EDA_TEXT*>( item );
wxCHECK(textItem, 0 );
// Careful: GetTextMargin() is dependent on font size...
new_textbox->SetTextSize( textItem->GetTextSize() );
new_textbox->SetAttributes( *sourceText, false );
int margin = new_textbox->GetTextMargin();
bbox.Inflate( margin );
VECTOR2I topLeft = bbox.GetPosition();
VECTOR2I botRight = bbox.GetEnd();
// Add 1/20 of the margin at the end to reduce line-breaking changes.
int slop = margin / 20;
switch( orientation )
if( sourceText->GetTextAngle() == ANGLE_VERTICAL )
{
case TEXT_SPIN_STYLE::SPIN::RIGHT:
new_textbox->SetPosition( bbox.GetPosition() );
new_textbox->SetEnd( bbox.GetEnd() + VECTOR2I( slop, 0 ) );
break;
case TEXT_SPIN_STYLE::SPIN::LEFT:
new_textbox->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
new_textbox->SetPosition( bbox.GetPosition() - VECTOR2I( slop, 0 ) );
new_textbox->SetEnd( bbox.GetEnd() );
break;
case TEXT_SPIN_STYLE::SPIN::UP:
new_textbox->SetTextAngle( ANGLE_VERTICAL );
new_textbox->SetPosition( bbox.GetPosition() - VECTOR2I( 0, slop ) );
new_textbox->SetEnd( bbox.GetEnd() );
break;
case TEXT_SPIN_STYLE::SPIN::BOTTOM:
new_textbox->SetTextAngle( ANGLE_VERTICAL );
new_textbox->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
new_textbox->SetPosition( bbox.GetPosition() );
new_textbox->SetEnd( bbox.GetEnd() + VECTOR2I( 0, slop ) );
break;
if( sourceText->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
botRight.y += slop;
else
topLeft.y -= slop;
}
else
{
if( sourceText->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
topLeft.x -= slop;
else
botRight.x += slop;
}
new_textbox->SetPosition( topLeft );
new_textbox->SetEnd( botRight );
new_textbox->SetHyperlink( href );
newtext = new_textbox;

View File

@ -1521,7 +1521,6 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
{
// If it wasn't content, then paste as text object.
SCH_TEXT* text_item = new SCH_TEXT( VECTOR2I( 0, 0 ), content );
text_item->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT ); // Left alignment
tempScreen->Append( text_item );
}

View File

@ -390,7 +390,7 @@ SCH_LINE* SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus( const wxString& aNet, const VECTO
m_busUnfold.label = new SCH_LABEL( m_busUnfold.entry->GetEnd(), aNet );
m_busUnfold.label->SetTextSize( VECTOR2I( cfg.m_DefaultTextSize, cfg.m_DefaultTextSize ) );
m_busUnfold.label->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
m_busUnfold.label->SetSpinStyle( SPIN_STYLE::RIGHT );
m_busUnfold.label->SetParent( m_frame->GetScreen() );
m_busUnfold.label->SetFlags( IS_NEW | IS_MOVING );

View File

@ -168,7 +168,7 @@ public:
/**
* Set the text attributes from another instance.
*/
void SetAttributes( const EDA_TEXT& aSrc );
void SetAttributes( const EDA_TEXT& aSrc, bool aSetPosition = true );
/**
* Swap the text attributes of the two involved instances.