Netclass directive and label conversion improvements.

1) Copy label fields when converting.
2) Don't assume netclass directive should be net name -- this is very
unlikely.
3) Don't show font controls in Netclass Directive Properties dialog --
there's no basic text associated witha  Directive Label.
This commit is contained in:
Jeff Young 2022-09-22 01:05:51 +01:00
parent c44e54756a
commit fc10db25ba
8 changed files with 80 additions and 90 deletions

View File

@ -28,13 +28,10 @@
#include <widgets/color_swatch.h> #include <widgets/color_swatch.h>
#include <settings/color_settings.h> #include <settings/color_settings.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <base_units.h>
#include <sch_validators.h> #include <sch_validators.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <general.h>
#include <gr_text.h> #include <gr_text.h>
#include <confirm.h> #include <confirm.h>
#include <sch_reference_list.h>
#include <schematic.h> #include <schematic.h>
#include <dialogs/html_message_box.h> #include <dialogs/html_message_box.h>
#include <dialog_label_properties.h> #include <dialog_label_properties.h>
@ -170,10 +167,21 @@ DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_L
m_triState->Hide(); m_triState->Hide();
m_passive->Hide(); m_passive->Hide();
m_fontLabel->SetLabel( _( "Orientation:" ) );
m_fontCtrl->Hide();
m_separator1->Hide();
m_bold->Hide();
m_italic->Hide();
m_separator2->Hide();
m_spin0->SetBitmap( KiBitmap( BITMAPS::pinorient_down ) ); m_spin0->SetBitmap( KiBitmap( BITMAPS::pinorient_down ) );
m_spin1->SetBitmap( KiBitmap( BITMAPS::pinorient_up ) ); m_spin1->SetBitmap( KiBitmap( BITMAPS::pinorient_up ) );
m_spin2->SetBitmap( KiBitmap( BITMAPS::pinorient_right ) ); m_spin2->SetBitmap( KiBitmap( BITMAPS::pinorient_right ) );
m_spin3->SetBitmap( KiBitmap( BITMAPS::pinorient_left ) ); m_spin3->SetBitmap( KiBitmap( BITMAPS::pinorient_left ) );
m_separator3->Hide();
m_formattingGB->Detach( m_fontCtrl );
m_formattingGB->Detach( m_iconBar );
m_formattingGB->Add( m_iconBar, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxRIGHT, 5 );
} }
else else
{ {
@ -211,7 +219,7 @@ DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_L
DIALOG_LABEL_PROPERTIES::~DIALOG_LABEL_PROPERTIES() DIALOG_LABEL_PROPERTIES::~DIALOG_LABEL_PROPERTIES()
{ {
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ); EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
wxASSERT( cfg ); wxASSERT( cfg );
if( cfg ) if( cfg )
@ -350,8 +358,7 @@ void DIALOG_LABEL_PROPERTIES::OnValueCharHook( wxKeyEvent& aEvent )
{ {
m_textSizeCtrl->SetFocusFromKbd(); m_textSizeCtrl->SetFocusFromKbd();
} }
else else if( !m_fields->empty() )
if( !m_fields->empty() )
{ {
m_grid->SetFocusFromKbd(); m_grid->SetFocusFromKbd();
m_grid->MakeCellVisible( 0, 0 ); m_grid->MakeCellVisible( 0, 0 );
@ -371,19 +378,10 @@ void DIALOG_LABEL_PROPERTIES::OnValueCharHook( wxKeyEvent& aEvent )
static bool positioningChanged( const SCH_FIELD& a, const SCH_FIELD& b ) static bool positioningChanged( const SCH_FIELD& a, const SCH_FIELD& b )
{ {
if( a.GetPosition() != b.GetPosition() ) return a.GetPosition() != b.GetPosition()
return true; || a.GetHorizJustify() != b.GetHorizJustify()
|| a.GetVertJustify() != b.GetVertJustify()
if( a.GetHorizJustify() != b.GetHorizJustify() ) || a.GetTextAngle() != b.GetTextAngle();
return true;
if( a.GetVertJustify() != b.GetVertJustify() )
return true;
if( a.GetTextAngle() != b.GetTextAngle() )
return true;
return false;
} }

View File

@ -79,5 +79,4 @@ private:
}; };
#endif // DIALOG_LABEL_PROPERTIES_H #endif // DIALOG_LABEL_PROPERTIES_H

View File

@ -181,70 +181,68 @@ DIALOG_LABEL_PROPERTIES_BASE::DIALOG_LABEL_PROPERTIES_BASE( wxWindow* parent, wx
wxStaticBoxSizer* formatting; wxStaticBoxSizer* formatting;
formatting = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Formatting") ), wxVERTICAL ); formatting = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Formatting") ), wxVERTICAL );
wxGridBagSizer* gbSizer1; m_formattingGB = new wxGridBagSizer( 3, 0 );
gbSizer1 = new wxGridBagSizer( 3, 0 ); m_formattingGB->SetFlexibleDirection( wxBOTH );
gbSizer1->SetFlexibleDirection( wxBOTH ); m_formattingGB->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_fontLabel = new wxStaticText( formatting->GetStaticBox(), wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 ); m_fontLabel = new wxStaticText( formatting->GetStaticBox(), wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 );
m_fontLabel->Wrap( -1 ); m_fontLabel->Wrap( -1 );
gbSizer1->Add( m_fontLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); m_formattingGB->Add( m_fontLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") }; wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") };
int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString ); int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString );
m_fontCtrl = new FONT_CHOICE( formatting->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fontCtrlNChoices, m_fontCtrlChoices, 0 ); m_fontCtrl = new FONT_CHOICE( formatting->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fontCtrlNChoices, m_fontCtrlChoices, 0 );
m_fontCtrl->SetSelection( 0 ); m_fontCtrl->SetSelection( 0 );
gbSizer1->Add( m_fontCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_formattingGB->Add( m_fontCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
wxBoxSizer* formattingSizer; m_iconBar = new wxBoxSizer( wxHORIZONTAL );
formattingSizer = new wxBoxSizer( wxHORIZONTAL );
m_separator1 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); m_separator1 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE );
m_separator1->Enable( false ); m_separator1->Enable( false );
formattingSizer->Add( m_separator1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); m_iconBar->Add( m_separator1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_bold = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); m_bold = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE );
m_bold->SetToolTip( _("Bold") ); m_bold->SetToolTip( _("Bold") );
formattingSizer->Add( m_bold, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_iconBar->Add( m_bold, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_italic = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); m_italic = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE );
m_italic->SetToolTip( _("Italic") ); m_italic->SetToolTip( _("Italic") );
formattingSizer->Add( m_italic, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_iconBar->Add( m_italic, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_separator2 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); m_separator2 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE );
m_separator2->Enable( false ); m_separator2->Enable( false );
formattingSizer->Add( m_separator2, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_iconBar->Add( m_separator2, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_spin0 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); m_spin0 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE );
formattingSizer->Add( m_spin0, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_iconBar->Add( m_spin0, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_spin1 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); m_spin1 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE );
formattingSizer->Add( m_spin1, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_iconBar->Add( m_spin1, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_spin2 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); m_spin2 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE );
formattingSizer->Add( m_spin2, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_iconBar->Add( m_spin2, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_spin3 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); m_spin3 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE );
formattingSizer->Add( m_spin3, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_iconBar->Add( m_spin3, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_autoRotate = new wxCheckBox( formatting->GetStaticBox(), wxID_ANY, _("Auto"), wxDefaultPosition, wxDefaultSize, 0 ); m_autoRotate = new wxCheckBox( formatting->GetStaticBox(), wxID_ANY, _("Auto"), wxDefaultPosition, wxDefaultSize, 0 );
formattingSizer->Add( m_autoRotate, 0, wxALL, 5 ); m_iconBar->Add( m_autoRotate, 0, wxALL, 5 );
m_separator3 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); m_separator3 = new BITMAP_BUTTON( formatting->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE );
m_separator3->Enable( false ); m_separator3->Enable( false );
formattingSizer->Add( m_separator3, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_iconBar->Add( m_separator3, 0, wxALIGN_CENTER_VERTICAL, 5 );
gbSizer1->Add( formattingSizer, wxGBPosition( 0, 3 ), wxGBSpan( 1, 1 ), wxEXPAND|wxRIGHT|wxLEFT, 5 ); m_formattingGB->Add( m_iconBar, wxGBPosition( 0, 3 ), wxGBSpan( 1, 1 ), wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_textSizeLabel = new wxStaticText( formatting->GetStaticBox(), wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeLabel = new wxStaticText( formatting->GetStaticBox(), wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_textSizeLabel->Wrap( -1 ); m_textSizeLabel->Wrap( -1 );
gbSizer1->Add( m_textSizeLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_formattingGB->Add( m_textSizeLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
wxBoxSizer* bSizer71; wxBoxSizer* bSizer71;
bSizer71 = new wxBoxSizer( wxHORIZONTAL ); bSizer71 = new wxBoxSizer( wxHORIZONTAL );
@ -277,10 +275,10 @@ DIALOG_LABEL_PROPERTIES_BASE::DIALOG_LABEL_PROPERTIES_BASE( wxWindow* parent, wx
bSizer71->Add( m_panelBorderColor1, 0, wxALIGN_CENTER_VERTICAL, 5 ); bSizer71->Add( m_panelBorderColor1, 0, wxALIGN_CENTER_VERTICAL, 5 );
gbSizer1->Add( bSizer71, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); m_formattingGB->Add( bSizer71, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 );
formatting->Add( gbSizer1, 1, wxEXPAND, 5 ); formatting->Add( m_formattingGB, 1, wxEXPAND, 5 );
optionsSizer->Add( formatting, 1, wxEXPAND|wxTOP, 5 ); optionsSizer->Add( formatting, 1, wxEXPAND|wxTOP, 5 );

View File

@ -1451,9 +1451,9 @@
<property name="growablerows"></property> <property name="growablerows"></property>
<property name="hgap">0</property> <property name="hgap">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">gbSizer1</property> <property name="name">m_formattingGB</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property> <property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property> <property name="permission">protected</property>
<property name="vgap">3</property> <property name="vgap">3</property>
<object class="gbsizeritem" expanded="1"> <object class="gbsizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
@ -1595,9 +1595,9 @@
<property name="rowspan">1</property> <property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="0"> <object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">formattingSizer</property> <property name="name">m_iconBar</property>
<property name="orient">wxHORIZONTAL</property> <property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property> <property name="permission">protected</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property> <property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>

View File

@ -76,8 +76,10 @@ class DIALOG_LABEL_PROPERTIES_BASE : public DIALOG_SHIM
wxRadioButton* m_circle; wxRadioButton* m_circle;
wxRadioButton* m_diamond; wxRadioButton* m_diamond;
wxRadioButton* m_rectangle; wxRadioButton* m_rectangle;
wxGridBagSizer* m_formattingGB;
wxStaticText* m_fontLabel; wxStaticText* m_fontLabel;
FONT_CHOICE* m_fontCtrl; FONT_CHOICE* m_fontCtrl;
wxBoxSizer* m_iconBar;
BITMAP_BUTTON* m_separator1; BITMAP_BUTTON* m_separator1;
BITMAP_BUTTON* m_bold; BITMAP_BUTTON* m_bold;
BITMAP_BUTTON* m_italic; BITMAP_BUTTON* m_italic;

View File

@ -28,7 +28,7 @@
#include <ee_actions.h> #include <ee_actions.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <project.h> #include <project.h>
#include <id.h> #include <pgm_base.h>
#include <eeschema_id.h> #include <eeschema_id.h>
#include <confirm.h> #include <confirm.h>
#include <view/view_controls.h> #include <view/view_controls.h>
@ -54,8 +54,6 @@
#include <string_utils.h> #include <string_utils.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <wx/filedlg.h> #include <wx/filedlg.h>
#include <sch_shape.h>
#include "pgm_base.h"
SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() : SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() :
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ), EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ),
@ -65,7 +63,6 @@ SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() :
m_lastTextOrientation( TEXT_SPIN_STYLE::RIGHT ), m_lastTextOrientation( TEXT_SPIN_STYLE::RIGHT ),
m_lastTextBold( false ), m_lastTextBold( false ),
m_lastTextItalic( false ), m_lastTextItalic( false ),
m_lastNetClassDirectiveItalic( true ),
m_lastTextAngle( ANGLE_0 ), m_lastTextAngle( ANGLE_0 ),
m_lastTextJust( GR_TEXT_H_ALIGN_LEFT ), m_lastTextJust( GR_TEXT_H_ALIGN_LEFT ),
m_lastFillStyle( FILL_T::NO_FILL ), m_lastFillStyle( FILL_T::NO_FILL ),
@ -988,12 +985,12 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
} }
textItem->SetParent( schematic ); textItem->SetParent( schematic );
textItem->SetBold( m_lastTextBold );
if( aType == LAYER_NETCLASS_REFS ) if( aType != LAYER_NETCLASS_REFS )
textItem->SetItalic( m_lastNetClassDirectiveItalic ); {
else textItem->SetBold( m_lastTextBold );
textItem->SetItalic( m_lastTextItalic ); textItem->SetItalic( m_lastTextItalic );
}
textItem->SetTextSpinStyle( m_lastTextOrientation ); textItem->SetTextSpinStyle( m_lastTextOrientation );
textItem->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) ); textItem->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
@ -1030,12 +1027,11 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
return nullptr; return nullptr;
} }
m_lastTextBold = textItem->IsBold(); if( aType != LAYER_NETCLASS_REFS )
{
if( aType == LAYER_NETCLASS_REFS ) m_lastTextBold = textItem->IsBold();
m_lastNetClassDirectiveItalic = textItem->IsItalic();
else
m_lastTextItalic = textItem->IsItalic(); m_lastTextItalic = textItem->IsItalic();
}
m_lastTextOrientation = textItem->GetTextSpinStyle(); m_lastTextOrientation = textItem->GetTextSpinStyle();

View File

@ -82,7 +82,6 @@ private:
TEXT_SPIN_STYLE m_lastTextOrientation; TEXT_SPIN_STYLE m_lastTextOrientation;
bool m_lastTextBold; bool m_lastTextBold;
bool m_lastTextItalic; bool m_lastTextItalic;
bool m_lastNetClassDirectiveItalic;
EDA_ANGLE m_lastTextAngle; EDA_ANGLE m_lastTextAngle;
GR_TEXT_H_ALIGN_T m_lastTextJust; GR_TEXT_H_ALIGN_T m_lastTextJust;
FILL_T m_lastFillStyle; FILL_T m_lastFillStyle;

View File

@ -29,7 +29,6 @@
#include <tools/sch_line_wire_bus_tool.h> #include <tools/sch_line_wire_bus_tool.h>
#include <tools/sch_move_tool.h> #include <tools/sch_move_tool.h>
#include <tools/sch_drawing_tools.h> #include <tools/sch_drawing_tools.h>
#include <widgets/infobar.h>
#include <ee_actions.h> #include <ee_actions.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <confirm.h> #include <confirm.h>
@ -51,7 +50,6 @@
#include <schematic.h> #include <schematic.h>
#include <drawing_sheet/ds_proxy_view_item.h> #include <drawing_sheet/ds_proxy_view_item.h>
#include <eeschema_id.h> #include <eeschema_id.h>
#include <wx/gdicmn.h>
#include <dialogs/dialog_change_symbols.h> #include <dialogs/dialog_change_symbols.h>
#include <dialogs/dialog_image_properties.h> #include <dialogs/dialog_image_properties.h>
#include <dialogs/dialog_line_properties.h> #include <dialogs/dialog_line_properties.h>
@ -63,7 +61,6 @@
#include <dialogs/dialog_shape_properties.h> #include <dialogs/dialog_shape_properties.h>
#include <dialogs/dialog_label_properties.h> #include <dialogs/dialog_label_properties.h>
#include <dialogs/dialog_text_properties.h> #include <dialogs/dialog_text_properties.h>
#include <math/util.h> // for KiROUND
#include <pgm_base.h> #include <pgm_base.h>
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <symbol_editor_settings.h> #include <symbol_editor_settings.h>
@ -158,21 +155,10 @@ bool SCH_EDIT_TOOL::Init()
auto sheetHasUndefinedPins = auto sheetHasUndefinedPins =
[]( const SELECTION& aSel ) []( const SELECTION& aSel )
{ {
if( aSel.Size() != 1 ) if( aSel.Size() == 1 && aSel.Front()->Type() == SCH_SHEET_T )
return false; return static_cast<SCH_SHEET*>( aSel.Front() )->HasUndefinedPins();
if( !aSel.HasType( SCH_SHEET_T ) ) return false;
return false;
SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aSel.Front() );
wxCHECK( item, false );
SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( item );
wxCHECK( sheet, false );
return sheet->HasUndefinedPins();
}; };
auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } ); auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } );
@ -1908,12 +1894,8 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
{ {
SCH_DIRECTIVE_LABEL* dirlabel = static_cast<SCH_DIRECTIVE_LABEL*>( item ); SCH_DIRECTIVE_LABEL* dirlabel = static_cast<SCH_DIRECTIVE_LABEL*>( item );
// a SCH_DIRECTIVE_LABEL has no text, but it usually has at least one field // a SCH_DIRECTIVE_LABEL has no text
// containing the net class name txt = _( "<empty>" );
if( dirlabel->GetFields().empty() )
txt = _( "<empty>" );
else
txt = dirlabel->GetFields()[0].GetText();
orientation = dirlabel->GetTextSpinStyle(); orientation = dirlabel->GetTextSpinStyle();
href = dirlabel->GetHyperlink(); href = dirlabel->GetHyperlink();
@ -1997,7 +1979,12 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
local_txt.Replace( " ", "_" ); local_txt.Replace( " ", "_" );
// label strings are "escaped" i.e. a '/' is replaced by "{slash}" // label strings are "escaped" i.e. a '/' is replaced by "{slash}"
return EscapeString( local_txt, CTX_NETNAME ); local_txt = EscapeString( local_txt, CTX_NETNAME );
if( local_txt.IsEmpty() )
return _( "<empty>" );
else
return local_txt;
}; };
switch( convertTo ) switch( convertTo )
@ -2039,12 +2026,17 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
{ {
SCH_LABEL_BASE* new_label = new SCH_DIRECTIVE_LABEL( position ); SCH_LABEL_BASE* new_label = new SCH_DIRECTIVE_LABEL( position );
// a SCH_DIRECTIVE_LABEL usually has at least one field containing the net class // A SCH_DIRECTIVE_LABEL usually has at least one field containing the net class
// name // name. If we're copying from a text object assume the text is the netclass
SCH_FIELD netclass( position, 0, new_label, wxT( "Netclass" ) ); // name. Otherwise, we'll just copy the fields which will either have a netclass
netclass.SetText( txt ); // or not.
netclass.SetVisible( true ); if( !dynamic_cast<SCH_LABEL_BASE*>( item ) )
new_label->GetFields().push_back( netclass ); {
SCH_FIELD netclass( position, 0, new_label, wxT( "Netclass" ) );
netclass.SetText( txt );
netclass.SetVisible( true );
new_label->GetFields().push_back( netclass );
}
new_label->SetShape( LABEL_FLAG_SHAPE::F_ROUND ); new_label->SetShape( LABEL_FLAG_SHAPE::F_ROUND );
new_label->SetTextSpinStyle( orientation ); new_label->SetTextSpinStyle( orientation );
@ -2135,6 +2127,12 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
newtext->AutoplaceFields( m_frame->GetScreen(), false ); newtext->AutoplaceFields( m_frame->GetScreen(), false );
SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item );
SCH_LABEL_BASE* new_label = dynamic_cast<SCH_LABEL_BASE*>( newtext );
if( label && new_label )
new_label->SetFields( label->GetFields() );
if( selected ) if( selected )
m_toolMgr->RunAction( EE_ACTIONS::removeItemFromSel, true, item ); m_toolMgr->RunAction( EE_ACTIONS::removeItemFromSel, true, item );