diff --git a/common/api/api_enums.cpp b/common/api/api_enums.cpp index b9b21b5eec..0f02aa70fb 100644 --- a/common/api/api_enums.cpp +++ b/common/api/api_enums.cpp @@ -76,7 +76,6 @@ KICAD_T FromProtoEnum( types::KiCadObjectType aValue ) case types::KiCadObjectType::KOT_SCH_PIN: return SCH_PIN_T; case types::KiCadObjectType::KOT_LIB_SYMBOL: return LIB_SYMBOL_T; // case types::KiCadObjectType::KOT_LIB_SHAPE: return LIB_SHAPE_T; - // case types::KiCadObjectType::KOT_LIB_TEXT: return LIB_TEXT_T; // case types::KiCadObjectType::KOT_LIB_TEXTBOX: return LIB_TEXTBOX_T; // case types::KiCadObjectType::KOT_LIB_PIN: return LIB_PIN_T; case types::KiCadObjectType::KOT_WSG_LINE: return WSG_LINE_T; @@ -139,7 +138,6 @@ types::KiCadObjectType ToProtoEnum( KICAD_T aValue ) case SCH_PIN_T: return types::KiCadObjectType::KOT_SCH_PIN; case LIB_SYMBOL_T: return types::KiCadObjectType::KOT_LIB_SYMBOL; // case LIB_SHAPE_T: return types::KiCadObjectType::KOT_LIB_SHAPE; - // case LIB_TEXT_T: return types::KiCadObjectType::KOT_LIB_TEXT; // case LIB_TEXTBOX_T: return types::KiCadObjectType::KOT_LIB_TEXTBOX; // case LIB_PIN_T: return types::KiCadObjectType::KOT_LIB_PIN; case WSG_LINE_T: return types::KiCadObjectType::KOT_WSG_LINE; diff --git a/common/eda_item.cpp b/common/eda_item.cpp index 97051aeb54..1e1f0d9742 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -397,7 +397,6 @@ static struct EDA_ITEM_DESC .Map( LIB_SYMBOL_T, _HKI( "Symbol" ) ) .Map( LIB_SHAPE_T, _HKI( "Graphic" ) ) - .Map( LIB_TEXT_T, _HKI( "Text" ) ) .Map( LIB_TEXTBOX_T, _HKI( "Text Box" ) ) .Map( LIB_PIN_T, _HKI( "Pin" ) ) diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index d94e38d9fc..962153bed6 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -127,8 +127,6 @@ set( EESCHEMA_DLGS dialogs/dialog_lib_shape_properties_base.cpp dialogs/dialog_lib_symbol_properties.cpp dialogs/dialog_lib_symbol_properties_base.cpp - dialogs/dialog_lib_text_properties.cpp - dialogs/dialog_lib_text_properties_base.cpp dialogs/dialog_lib_textbox_properties.cpp dialogs/dialog_lib_textbox_properties_base.cpp dialogs/dialog_line_properties.cpp @@ -364,7 +362,6 @@ set( EESCHEMA_SRCS lib_pin.cpp lib_shape.cpp lib_symbol.cpp - lib_text.cpp lib_textbox.cpp libarch.cpp menubar.cpp diff --git a/eeschema/api/api_sch_utils.cpp b/eeschema/api/api_sch_utils.cpp index 138f8220be..6995cf6682 100644 --- a/eeschema/api/api_sch_utils.cpp +++ b/eeschema/api/api_sch_utils.cpp @@ -21,9 +21,7 @@ #include #include #include -#include #include - #include #include #include @@ -31,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -95,7 +92,6 @@ std::unique_ptr CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer case LIB_SYMBOL_T: return nullptr; // TODO: ctor currently requires non-null name case LIB_SHAPE_T: return std::make_unique( parentLibSymbol ); - case LIB_TEXT_T: return std::make_unique( parentLibSymbol ); case LIB_TEXTBOX_T: return std::make_unique( parentLibSymbol ); case LIB_PIN_T: return std::make_unique( parentLibSymbol ); diff --git a/eeschema/dialogs/dialog_lib_text_properties.cpp b/eeschema/dialogs/dialog_lib_text_properties.cpp deleted file mode 100644 index a4ce73c567..0000000000 --- a/eeschema/dialogs/dialog_lib_text_properties.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2001 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2023 KiCad Developers, see change_log.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 - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "confirm.h" - -DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, - LIB_TEXT* aText ) : - DIALOG_LIB_TEXT_PROPERTIES_BASE( aParent ), - m_parent( aParent ), - m_graphicText( aText ), - m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ) -{ - COLOR_SETTINGS* colorSettings = m_parent->GetColorSettings(); - COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); - - m_scintillaTricks = new SCINTILLA_TRICKS( m_StyledTextCtrl, wxT( "{}" ), false, - // onAcceptFn - [this]( wxKeyEvent& aEvent ) - { - wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); - } ); - - SetInitialFocus( m_StyledTextCtrl ); - - m_separator1->SetIsSeparator(); - - m_horizontal->SetIsRadioButton(); - m_horizontal->SetBitmap( KiBitmapBundle( BITMAPS::text_horizontal ) ); - m_vertical->SetIsRadioButton(); - m_vertical->SetBitmap( KiBitmapBundle( BITMAPS::text_vertical ) ); - - m_separator2->SetIsSeparator(); - - m_bold->SetIsCheckButton(); - m_bold->SetBitmap( KiBitmapBundle( BITMAPS::text_bold ) ); - m_italic->SetIsCheckButton(); - m_italic->SetBitmap( KiBitmapBundle( BITMAPS::text_italic ) ); - - m_separator3->SetIsSeparator(); - - m_hAlignLeft->SetIsRadioButton(); - m_hAlignLeft->SetBitmap( KiBitmapBundle( BITMAPS::text_align_left ) ); - m_hAlignCenter->SetIsRadioButton(); - m_hAlignCenter->SetBitmap( KiBitmapBundle( BITMAPS::text_align_center ) ); - m_hAlignRight->SetIsRadioButton(); - m_hAlignRight->SetBitmap( KiBitmapBundle( BITMAPS::text_align_right ) ); - - m_separator4->SetIsSeparator(); - - m_vAlignTop->SetIsRadioButton(); - m_vAlignTop->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_top ) ); - m_vAlignCenter->SetIsRadioButton(); - m_vAlignCenter->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_center ) ); - m_vAlignBottom->SetIsRadioButton(); - m_vAlignBottom->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_bottom ) ); - - m_separator5->SetIsSeparator(); - - m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); - m_textColorSwatch->SetSwatchBackground( schematicBackground ); - - m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onOrientButton, this ); - m_vertical->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onOrientButton, this ); - - m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton, this ); - m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton, this ); - m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton, this ); - - m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton, this ); - m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton, this ); - m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton, this ); - - SetupStandardButtons(); - - if( !aParent->IsSymbolEditable() || aParent->IsSymbolAlias() ) - { - m_sdbSizerButtonsCancel->SetDefault(); - m_sdbSizerButtonsOK->SetLabel( _( "Read Only" ) ); - m_sdbSizerButtonsOK->Enable( false ); - } - - // Now all widgets have the size fixed, call FinishDialogSettings - finishDialogSettings(); -} - - -DIALOG_LIB_TEXT_PROPERTIES::~DIALOG_LIB_TEXT_PROPERTIES() -{ - delete m_scintillaTricks; -}; - - -bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow() -{ - wxCHECK( m_commonToAllUnits, false ); - - if( m_graphicText ) - { - const SYMBOL* symbol = m_graphicText->GetParentSymbol(); - - wxCHECK( symbol, false ); - - m_textSize.SetValue( m_graphicText->GetTextWidth() ); - m_StyledTextCtrl->SetValue( m_graphicText->GetText() ); - m_StyledTextCtrl->EmptyUndoBuffer(); - - m_fontCtrl->SetFontSelection( m_graphicText->GetFont() ); - m_textColorSwatch->SetSwatchColor( m_graphicText->GetTextColor(), false ); - - m_italic->Check( m_graphicText->IsItalic() ); - m_bold->Check( m_graphicText->IsBold() ); - - m_privateCheckbox->SetValue( m_graphicText->IsPrivate() ); - m_commonToAllUnits->SetValue( symbol->GetUnitCount() > 1 && m_graphicText->GetUnit() == 0 ); - m_commonToAllUnits->Enable( symbol->GetUnitCount() > 1 ); - m_commonToAllBodyStyles->SetValue( m_graphicText->GetBodyStyle() == 0 ); - - if( m_graphicText->GetTextAngle().IsHorizontal() ) - m_horizontal->Check(); - else - m_vertical->Check(); - - switch ( m_graphicText->GetHorizJustify() ) - { - case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break; - case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break; - case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break; - case GR_TEXT_H_ALIGN_INDETERMINATE: break; - } - - switch ( m_graphicText->GetVertJustify() ) - { - case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break; - case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break; - case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break; - case GR_TEXT_V_ALIGN_INDETERMINATE: break; - } - } - else - { - SYMBOL_EDITOR_SETTINGS* cfg = m_parent->GetSettings(); - auto* tools = m_parent->GetToolManager()->GetTool(); - SYMBOL* symbol = m_parent->GetCurSymbol(); - - wxCHECK( cfg && symbol && tools, false ); - - m_textSize.SetValue( schIUScale.MilsToIU( cfg->m_Defaults.text_size ) ); - - m_commonToAllUnits->SetValue( symbol->GetUnitCount() > 1 && !tools->GetDrawSpecificUnit() ); - m_commonToAllUnits->Enable( symbol->GetUnitCount() > 1 ); - m_commonToAllBodyStyles->SetValue( !tools->GetDrawSpecificBodyStyle() ); - - if( tools->GetLastTextAngle().IsHorizontal() ) - m_horizontal->Check(); - else - m_vertical->Check(); - } - - return true; -} - - -void DIALOG_LIB_TEXT_PROPERTIES::onOrientButton( wxCommandEvent& aEvent ) -{ - for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } ) - { - if( btn->IsChecked() && btn != aEvent.GetEventObject() ) - btn->Check( false ); - } -} - - -void DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent ) -{ - for( BITMAP_BUTTON* btn : { m_hAlignLeft, m_hAlignCenter, m_hAlignRight } ) - { - if( btn->IsChecked() && btn != aEvent.GetEventObject() ) - btn->Check( false ); - } -} - - -void DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent ) -{ - for( BITMAP_BUTTON* btn : { m_vAlignTop, m_vAlignCenter, m_vAlignBottom } ) - { - if( btn->IsChecked() && btn != aEvent.GetEventObject() ) - btn->Check( false ); - } -} - - -bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow() -{ - if( m_graphicText ) - { - if( m_StyledTextCtrl->GetValue().IsEmpty() ) - { - // Other text items do not have defined extents, and so will disappear if empty - DisplayError( this, _( "Text can not be empty." ) ); - return false; - } - else - { - m_graphicText->SetText( m_StyledTextCtrl->GetValue() ); - } - - if( m_fontCtrl->HaveFontSelection() ) - { - m_graphicText->SetFont( m_fontCtrl->GetFontSelection( m_bold->IsChecked(), - m_italic->IsChecked() ) ); - } - - if( m_textSize.GetValue() != m_graphicText->GetTextWidth() ) - m_graphicText->SetTextSize( VECTOR2I( m_textSize.GetValue(), m_textSize.GetValue() ) ); - - if( m_horizontal->IsChecked() ) - m_graphicText->SetTextAngle( ANGLE_HORIZONTAL ); - else - m_graphicText->SetTextAngle( ANGLE_VERTICAL ); - - m_graphicText->SetPrivate( m_privateCheckbox->GetValue() ); - - if( !m_commonToAllUnits->GetValue() ) - m_graphicText->SetUnit( m_parent->GetUnit() ); - else - m_graphicText->SetUnit( 0 ); - - if( !m_commonToAllBodyStyles->GetValue() ) - m_graphicText->SetBodyStyle( m_parent->GetBodyStyle() ); - else - m_graphicText->SetBodyStyle( 0 ); - - // Must come after SetTextSize() - m_graphicText->SetBold( m_bold->IsChecked() ); - m_graphicText->SetItalic( m_italic->IsChecked() ); - m_graphicText->SetTextColor( m_textColorSwatch->GetSwatchColor() ); - - if( m_hAlignLeft->IsChecked() ) - m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - else if( m_hAlignCenter->IsChecked() ) - m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); - else - m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - - if( m_vAlignTop->IsChecked() ) - m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - else if( m_vAlignCenter->IsChecked() ) - m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); - else - m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - - // Record settings used for next time: - auto* tools = m_parent->GetToolManager()->GetTool(); - tools->SetLastTextAngle( m_graphicText->GetTextAngle() ); - tools->SetDrawSpecificBodyStyle( !m_commonToAllBodyStyles->GetValue() ); - tools->SetDrawSpecificUnit( !m_commonToAllUnits->GetValue() ); - } - - m_parent->SetMsgPanel( m_graphicText ); - - return true; -} - - -void DIALOG_LIB_TEXT_PROPERTIES::onMultiLineTCLostFocus( wxFocusEvent& event ) -{ - if( m_scintillaTricks ) - m_scintillaTricks->CancelAutocomplete(); - - event.Skip(); -} diff --git a/eeschema/dialogs/dialog_lib_text_properties.h b/eeschema/dialogs/dialog_lib_text_properties.h deleted file mode 100644 index 9966a798f8..0000000000 --- a/eeschema/dialogs/dialog_lib_text_properties.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2001 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2022 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 - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - - -#ifndef DIALOG_LIB_TEXT_PROPERTIES_H -#define DIALOG_LIB_TEXT_PROPERTIES_H - -#include -#include - -class SYMBOL_EDIT_FRAME; -class SCINTILLA_TRICKS; -class LIB_TEXT; - - -class DIALOG_LIB_TEXT_PROPERTIES : public DIALOG_LIB_TEXT_PROPERTIES_BASE -{ -public: - DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, LIB_TEXT* aText ); - ~DIALOG_LIB_TEXT_PROPERTIES() override; - -private: - void onOrientButton( wxCommandEvent &aEvent ); - void onHAlignButton( wxCommandEvent &aEvent ); - void onVAlignButton( wxCommandEvent &aEvent ); - void onMultiLineTCLostFocus( wxFocusEvent& event ) override; - - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; - - SYMBOL_EDIT_FRAME* m_parent; - LIB_TEXT* m_graphicText; - - UNIT_BINDER m_textSize; - SCINTILLA_TRICKS* m_scintillaTricks; -}; - - -#endif // DIALOG_LIB_TEXT_PROPERTIES_H diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.cpp b/eeschema/dialogs/dialog_lib_text_properties_base.cpp deleted file mode 100644 index c8bc0788cf..0000000000 --- a/eeschema/dialogs/dialog_lib_text_properties_base.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "widgets/bitmap_button.h" -#include "widgets/color_swatch.h" -#include "widgets/font_choice.h" - -#include "dialog_lib_text_properties_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_LIB_TEXT_PROPERTIES_BASE::DIALOG_LIB_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* bMainSizer; - bMainSizer = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bPropertiesSizer; - bPropertiesSizer = new wxBoxSizer( wxVERTICAL ); - - wxGridBagSizer* gbSizer1; - gbSizer1 = new wxGridBagSizer( 3, 0 ); - gbSizer1->SetFlexibleDirection( wxBOTH ); - gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - gbSizer1->SetEmptyCellSize( wxSize( -1,10 ) ); - - m_textLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textLabel->Wrap( -1 ); - gbSizer1->Add( m_textLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxLEFT, 5 ); - - m_StyledTextCtrl = new wxStyledTextCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN, wxEmptyString ); - m_StyledTextCtrl->SetUseTabs( true ); - m_StyledTextCtrl->SetTabWidth( 4 ); - m_StyledTextCtrl->SetIndent( 4 ); - m_StyledTextCtrl->SetTabIndents( false ); - m_StyledTextCtrl->SetBackSpaceUnIndents( false ); - m_StyledTextCtrl->SetViewEOL( false ); - m_StyledTextCtrl->SetViewWhiteSpace( false ); - m_StyledTextCtrl->SetMarginWidth( 2, 0 ); - m_StyledTextCtrl->SetIndentationGuides( false ); - m_StyledTextCtrl->SetReadOnly( false ); - m_StyledTextCtrl->SetMarginWidth( 1, 0 ); - m_StyledTextCtrl->SetMarginWidth( 0, 0 ); - m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS ); - m_StyledTextCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("BLACK") ) ); - m_StyledTextCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("WHITE") ) ); - m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS ); - m_StyledTextCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("BLACK") ) ); - m_StyledTextCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("WHITE") ) ); - m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY ); - m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUS ); - m_StyledTextCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("BLACK") ) ); - m_StyledTextCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("WHITE") ) ); - m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUS ); - m_StyledTextCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("BLACK") ) ); - m_StyledTextCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("WHITE") ) ); - m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY ); - m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY ); - m_StyledTextCtrl->SetSelBackground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); - m_StyledTextCtrl->SetSelForeground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) ); - gbSizer1->Add( m_StyledTextCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 4 ), wxEXPAND, 5 ); - - 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|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 ); - gbSizer1->Add( m_fontCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); - - wxBoxSizer* formattingSizer; - formattingSizer = new wxBoxSizer( wxHORIZONTAL ); - - m_separator1 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_separator1->Enable( false ); - - formattingSizer->Add( m_separator1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - m_horizontal = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_horizontal->SetToolTip( _("Horizontal text") ); - - formattingSizer->Add( m_horizontal, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_vertical = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_vertical->SetToolTip( _("Vertical text") ); - - formattingSizer->Add( m_vertical, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_separator2 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_separator2->Enable( false ); - - formattingSizer->Add( m_separator2, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_bold = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_bold->SetToolTip( _("Bold") ); - - formattingSizer->Add( m_bold, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_italic = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_italic->SetToolTip( _("Italic") ); - - formattingSizer->Add( m_italic, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_separator3 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_separator3->Enable( false ); - - formattingSizer->Add( m_separator3, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_hAlignLeft = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_hAlignLeft->SetToolTip( _("Align left") ); - - formattingSizer->Add( m_hAlignLeft, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_hAlignCenter = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_hAlignCenter->SetToolTip( _("Align horizontal center") ); - - formattingSizer->Add( m_hAlignCenter, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_hAlignRight = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_hAlignRight->SetToolTip( _("Align right") ); - - formattingSizer->Add( m_hAlignRight, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_separator4 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_separator4->Enable( false ); - - formattingSizer->Add( m_separator4, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_vAlignTop = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_vAlignTop->SetToolTip( _("Align top") ); - - formattingSizer->Add( m_vAlignTop, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_vAlignCenter = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_vAlignCenter->SetToolTip( _("Align vertical center") ); - - formattingSizer->Add( m_vAlignCenter, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_vAlignBottom = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_vAlignBottom->SetToolTip( _("Align bottom") ); - - formattingSizer->Add( m_vAlignBottom, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_separator5 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); - m_separator5->Enable( false ); - - formattingSizer->Add( m_separator5, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - gbSizer1->Add( formattingSizer, wxGBPosition( 2, 3 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); - - m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textSizeLabel->Wrap( -1 ); - gbSizer1->Add( m_textSizeLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - wxBoxSizer* bSizer71; - bSizer71 = new wxBoxSizer( wxHORIZONTAL ); - - m_textSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer71->Add( m_textSizeCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textSizeUnits->Wrap( -1 ); - bSizer71->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 3 ); - - m_textColorLabel = new wxStaticText( this, wxID_ANY, _("Color:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textColorLabel->Wrap( -1 ); - bSizer71->Add( m_textColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 15 ); - - - bSizer71->Add( 5, 0, 0, 0, 5 ); - - m_panelBorderColor1 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer221; - bSizer221 = new wxBoxSizer( wxVERTICAL ); - - m_textColorSwatch = new COLOR_SWATCH( m_panelBorderColor1, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer221->Add( m_textColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - - m_panelBorderColor1->SetSizer( bSizer221 ); - m_panelBorderColor1->Layout(); - bSizer221->Fit( m_panelBorderColor1 ); - bSizer71->Add( m_panelBorderColor1, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - gbSizer1->Add( bSizer71, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); - - m_privateCheckbox = new wxCheckBox( this, wxID_ANY, _("Private to Symbol Editor"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_privateCheckbox, wxGBPosition( 5, 0 ), wxGBSpan( 1, 2 ), wxLEFT, 5 ); - - m_commonToAllUnits = new wxCheckBox( this, wxID_ANY, _("Common to all units"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_commonToAllUnits, wxGBPosition( 5, 3 ), wxGBSpan( 1, 1 ), wxLEFT, 100 ); - - m_commonToAllBodyStyles = new wxCheckBox( this, wxID_ANY, _("Common to all body styles"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_commonToAllBodyStyles, wxGBPosition( 6, 3 ), wxGBSpan( 1, 1 ), wxLEFT, 100 ); - - - bPropertiesSizer->Add( gbSizer1, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - wxFlexGridSizer* fgSizer3; - fgSizer3 = new wxFlexGridSizer( 5, 4, 3, 3 ); - fgSizer3->SetFlexibleDirection( wxBOTH ); - fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - - fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); - - - bPropertiesSizer->Add( fgSizer3, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - wxBoxSizer* bBottomtBoxSizer; - bBottomtBoxSizer = new wxBoxSizer( wxVERTICAL ); - - - bPropertiesSizer->Add( bBottomtBoxSizer, 0, wxEXPAND|wxTOP|wxLEFT, 5 ); - - - bMainSizer->Add( bPropertiesSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_sdbSizerButtons = new wxStdDialogButtonSizer(); - m_sdbSizerButtonsOK = new wxButton( this, wxID_OK ); - m_sdbSizerButtons->AddButton( m_sdbSizerButtonsOK ); - m_sdbSizerButtonsCancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizerButtons->AddButton( m_sdbSizerButtonsCancel ); - m_sdbSizerButtons->Realize(); - - bMainSizer->Add( m_sdbSizerButtons, 0, wxEXPAND|wxALL, 5 ); - - - this->SetSizer( bMainSizer ); - this->Layout(); - bMainSizer->Fit( this ); - - // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnCloseDialog ) ); - m_StyledTextCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); - m_StyledTextCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); -} - -DIALOG_LIB_TEXT_PROPERTIES_BASE::~DIALOG_LIB_TEXT_PROPERTIES_BASE() -{ - // Disconnect Events - this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnCloseDialog ) ); - m_StyledTextCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); - m_StyledTextCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); - -} diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.fbp b/eeschema/dialogs/dialog_lib_text_properties_base.fbp deleted file mode 100644 index 9e626cca42..0000000000 --- a/eeschema/dialogs/dialog_lib_text_properties_base.fbp +++ /dev/null @@ -1,2198 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_lib_text_properties_base - 1000 - none - - - 1 - DIALOG_LIB_TEXT_PROPERTIES_BASE - - . - - 1 - 1 - 1 - 1 - UI - 0 - 1 - 0 - - 0 - wxAUI_MGR_DEFAULT - - - - 1 - 0 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_LIB_TEXT_PROPERTIES_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Text Item Properties - - 0 - - - - OnCloseDialog - - - bMainSizer - wxVERTICAL - none - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 1 - - - bPropertiesSizer - wxVERTICAL - none - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 1 - - -1,10 - wxBOTH - - - 0 - - gbSizer1 - wxFLEX_GROWMODE_SPECIFIED - none - 3 - - 5 - 1 - 0 - wxRIGHT|wxLEFT - 0 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Text: - 0 - - 0 - - - 0 - - 1 - m_textLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - 4 - 1 - wxEXPAND - 0 - 1 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - 0 - - 0 - 0 - wxID_ANY - 0 - 0 - - 0 - - - 0 - - 1 - m_StyledTextCtrl - 1 - - - protected - 1 - - 0 - Resizable - 1 - - ; ; forward_declare - 0 - 4 - 0 - - 1 - 0 - 0 - - - wxBORDER_SUNKEN - onMultiLineTCLostFocus - OnSetFocusText - - - - 5 - 1 - 0 - wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 2 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Font: - 0 - - 0 - - - 0 - - 1 - m_fontLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - 2 - 1 - wxEXPAND - 2 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Default Font" "KiCad Font" - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_fontCtrl - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - FONT_CHOICE; widgets/font_choice.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - 2 - 3 - wxEXPAND - 2 - 1 - - - formattingSizer - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 0 - - 1 - - - 0 - 0 - wxID_ANY - - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_separator1 - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Horizontal text - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_horizontal - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Horizontal text - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Vertical text - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_vertical - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Vertical text - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 0 - - 1 - - - 0 - 0 - wxID_ANY - - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_separator2 - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Bold - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_bold - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Bold - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Italic - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_italic - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Italic - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 0 - - 1 - - - 0 - 0 - wxID_ANY - - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_separator3 - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align left - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_hAlignLeft - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align left - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align center - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_hAlignCenter - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align horizontal center - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align right - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_hAlignRight - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align right - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 0 - - 1 - - - 0 - 0 - wxID_ANY - - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_separator4 - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align top - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_vAlignTop - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align top - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align vertical center - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_vAlignCenter - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align vertical center - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 1 - - 1 - - - 0 - 0 - wxID_ANY - Align bottom - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_vAlignBottom - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - Align bottom - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 0 - - 1 - - - 0 - 0 - wxID_ANY - - - 0 - - 0 - -1,-1 - - 0 - - 1 - m_separator5 - 1 - - - protected - 1 - - - - Resizable - 1 - 21,21 - wxBORDER_NONE - BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 3 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Text size: - 0 - - 0 - - - 0 - - 1 - m_textSizeLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - 1 - 1 - wxEXPAND - 3 - 1 - - - bSizer71 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - -1,-1 - 0 - -1,-1 - 1 - m_textSizeCtrl - 1 - - - protected - 1 - - Resizable - 1 - -1,-1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - -1,-1 - 1 - m_textSizeUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 15 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Color: - 0 - - 0 - - - 0 - - 1 - m_textColorLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; Not forward_declare - 0 - - - - - -1 - - - - 5 - - 0 - - 0 - protected - 5 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelBorderColor1 - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - - - - wxBORDER_SIMPLE|wxTAB_TRAVERSAL - - - bSizer221 - wxVERTICAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - COLOR_SWATCH - 1 - - - 1 - - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_textColorSwatch - 1 - - - protected - 1 - - Resizable - - 1 - - COLOR_SWATCH; widgets/color_swatch.h; forward_declare - 0 - - - - - - - - - - - - - 5 - 2 - 0 - wxLEFT - 5 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Private to Symbol Editor - - 0 - - - 0 - - 1 - m_privateCheckbox - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 100 - 1 - 3 - wxLEFT - 5 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Common to all units - - 0 - - - 0 - - 1 - m_commonToAllUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 100 - 1 - 3 - wxLEFT - 6 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Common to all body styles - - 0 - - - 0 - - 1 - m_commonToAllBodyStyles - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 4 - wxBOTH - - - 3 - -1,-1 - fgSizer3 - wxFLEX_GROWMODE_SPECIFIED - none - 5 - 3 - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - - - 5 - wxEXPAND|wxTOP|wxLEFT - 0 - - - bBottomtBoxSizer - wxVERTICAL - none - - - - - - 5 - wxEXPAND|wxALL - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizerButtons - protected - - - - - - diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.h b/eeschema/dialogs/dialog_lib_text_properties_base.h deleted file mode 100644 index 094e9fa891..0000000000 --- a/eeschema/dialogs/dialog_lib_text_properties_base.h +++ /dev/null @@ -1,93 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include -#include -class BITMAP_BUTTON; -class COLOR_SWATCH; -class FONT_CHOICE; - -#include "dialog_shim.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_LIB_TEXT_PROPERTIES_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_LIB_TEXT_PROPERTIES_BASE : public DIALOG_SHIM -{ - private: - - protected: - wxStaticText* m_textLabel; - wxStyledTextCtrl* m_StyledTextCtrl; - wxStaticText* m_fontLabel; - FONT_CHOICE* m_fontCtrl; - BITMAP_BUTTON* m_separator1; - BITMAP_BUTTON* m_horizontal; - BITMAP_BUTTON* m_vertical; - BITMAP_BUTTON* m_separator2; - BITMAP_BUTTON* m_bold; - BITMAP_BUTTON* m_italic; - BITMAP_BUTTON* m_separator3; - BITMAP_BUTTON* m_hAlignLeft; - BITMAP_BUTTON* m_hAlignCenter; - BITMAP_BUTTON* m_hAlignRight; - BITMAP_BUTTON* m_separator4; - BITMAP_BUTTON* m_vAlignTop; - BITMAP_BUTTON* m_vAlignCenter; - BITMAP_BUTTON* m_vAlignBottom; - BITMAP_BUTTON* m_separator5; - wxStaticText* m_textSizeLabel; - wxTextCtrl* m_textSizeCtrl; - wxStaticText* m_textSizeUnits; - wxStaticText* m_textColorLabel; - wxPanel* m_panelBorderColor1; - COLOR_SWATCH* m_textColorSwatch; - wxCheckBox* m_privateCheckbox; - wxCheckBox* m_commonToAllUnits; - wxCheckBox* m_commonToAllBodyStyles; - wxStdDialogButtonSizer* m_sdbSizerButtons; - wxButton* m_sdbSizerButtonsOK; - wxButton* m_sdbSizerButtonsCancel; - - // Virtual event handlers, override them in your derived class - virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); } - virtual void onMultiLineTCLostFocus( wxFocusEvent& event ) { event.Skip(); } - virtual void OnSetFocusText( wxFocusEvent& event ) { event.Skip(); } - - - public: - - DIALOG_LIB_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Item Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - - ~DIALOG_LIB_TEXT_PROPERTIES_BASE(); - -}; - diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index 00cf3b2f2b..a850f28740 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -24,6 +24,7 @@ */ #include +#include #include #include #include @@ -39,7 +40,7 @@ #include -DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_ITEM* aTextItem ) : +DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_ITEM* aTextItem ) : DIALOG_TEXT_PROPERTIES_BASE( aParent ), m_frame( aParent ), m_currentItem( aTextItem ), @@ -49,6 +50,8 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_ITE m_scintillaTricks( nullptr ), m_helpWindow( nullptr ) { + m_isSymbolEditor = dynamic_cast( aParent ) != nullptr; + COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings(); COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); @@ -152,23 +155,38 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_ITE m_separator5->SetIsSeparator(); - SCH_SHEET_LIST sheetList = m_frame->Schematic().GetSheets(); - sheetList.SortByPageNumbers( false ); + m_fgSymbolEditor->Show( m_isSymbolEditor ); - for( const SCH_SHEET_PATH& sheet : sheetList ) + if( SCH_EDIT_FRAME* schematicEditor = dynamic_cast( m_frame ) ) { - wxString sheetPageNum = sheet.GetPageNumber(); - wxString sheetName = sheet.size() == 1 ? _( "" ) : sheet.Last()->GetName(); + SCH_SHEET_LIST sheetList = schematicEditor->Schematic().GetSheets(); + sheetList.SortByPageNumbers( false ); - m_hyperlinkCombo->Append( wxT( "#" ) + sheetPageNum, - wxString::Format( _( "Page %s (%s)" ), sheetPageNum, sheetName ) ); - m_pageNumbers.push_back( sheetPageNum ); + for( const SCH_SHEET_PATH& sheet : sheetList ) + { + wxString sheetPageNum = sheet.GetPageNumber(); + wxString sheetName = sheet.size() == 1 ? _( "" ) + : sheet.Last()->GetName(); + + m_hyperlinkCombo->Append( wxT( "#" ) + sheetPageNum, + wxString::Format( _( "Page %s (%s)" ), + sheetPageNum, + sheetName ) ); + m_pageNumbers.push_back( sheetPageNum ); + } + + m_hyperlinkCombo->Append( wxT( "---" ) ); + m_hyperlinkCombo->Append( wxT( "file://" ), wxT( "file://..." ) ); + m_hyperlinkCombo->Append( wxT( "http://" ), wxT( "http://..." ) ); + m_hyperlinkCombo->Append( wxT( "https://" ), wxT( "https://..." ) ); + } + else + { + m_excludeFromSim->Hide(); + m_syntaxHelp->Hide(); + m_hyperlinkCb->Hide(); + m_hyperlinkCombo->Hide(); } - - m_hyperlinkCombo->Append( wxT( "---" ) ); - m_hyperlinkCombo->Append( wxT( "file://" ), wxT( "file://..." ) ); - m_hyperlinkCombo->Append( wxT( "http://" ), wxT( "http://..." ) ); - m_hyperlinkCombo->Append( wxT( "https://" ), wxT( "https://..." ) ); SetupStandardButtons(); Layout(); @@ -199,22 +217,28 @@ DIALOG_TEXT_PROPERTIES::~DIALOG_TEXT_PROPERTIES() void DIALOG_TEXT_PROPERTIES::getContextualTextVars( const wxString& aCrossRef, wxArrayString* aTokens ) { + SCHEMATIC* schematic = m_currentItem->Schematic(); + if( !aCrossRef.IsEmpty() ) { - SCH_SHEET_LIST sheets = m_frame->Schematic().GetSheets(); - SCH_REFERENCE_LIST refs; - SCH_SYMBOL* refSymbol = nullptr; + SCH_SYMBOL* refSymbol = nullptr; - sheets.GetSymbols( refs ); - - for( int jj = 0; jj < (int) refs.GetCount(); jj++ ) + if( schematic ) { - SCH_REFERENCE& ref = refs[jj]; + SCH_SHEET_LIST sheets = m_currentItem->Schematic()->GetSheets(); + SCH_REFERENCE_LIST refs; - if( ref.GetSymbol()->GetRef( &ref.GetSheetPath(), true ) == aCrossRef ) + sheets.GetSymbols( refs ); + + for( int jj = 0; jj < (int) refs.GetCount(); jj++ ) { - refSymbol = ref.GetSymbol(); - break; + SCH_REFERENCE& ref = refs[jj]; + + if( ref.GetSymbol()->GetRef( &ref.GetSheetPath(), true ) == aCrossRef ) + { + refSymbol = ref.GetSymbol(); + break; + } } } @@ -223,8 +247,6 @@ void DIALOG_TEXT_PROPERTIES::getContextualTextVars( const wxString& aCrossRef, } else { - SCHEMATIC* schematic = m_currentItem->Schematic(); - if( schematic && schematic->CurrentSheet().Last() ) { schematic->CurrentSheet().Last()->GetContextualTextVars( aTokens ); @@ -243,16 +265,20 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() if( !wxDialog::TransferDataToWindow() ) return false; - SCHEMATIC& schematic = m_frame->Schematic(); - m_hyperlinkCb->SetValue( m_currentText->HasHyperlink() ); m_hyperlinkCombo->SetValue( m_currentText->GetHyperlink() ); + wxString text = m_currentText->GetText(); + // show text variable cross-references in a human-readable format - m_textCtrl->SetValue( schematic.ConvertKIIDsToRefs( m_currentText->GetText() ) ); + if( SCHEMATIC* schematic = m_currentItem->Schematic() ) + text = schematic->ConvertKIIDsToRefs( text ); + + m_textCtrl->SetValue( text ); m_textCtrl->EmptyUndoBuffer(); - m_excludeFromSim->SetValue( m_currentItem->GetExcludedFromSim() ); + if( !m_isSymbolEditor ) + m_excludeFromSim->SetValue( m_currentItem->GetExcludedFromSim() ); m_fontCtrl->SetFontSelection( m_currentText->GetFont() ); m_textSize.SetValue( m_currentText->GetTextWidth() ); @@ -315,6 +341,17 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() m_fillColorSwatch->Enable( textBox->IsFilled() ); } + if( m_isSymbolEditor ) + { + SYMBOL* symbol = m_currentItem->GetParentSymbol(); + + m_privateCheckbox->SetValue( m_currentItem->IsPrivate() ); + m_commonToAllUnits->SetValue( symbol->IsMulti() && m_currentItem->GetUnit() == 0 ); + m_commonToAllUnits->Enable( symbol->IsMulti() ); + m_commonToAllBodyStyles->SetValue( symbol->HasAlternateBodyStyle() && m_currentItem->GetBodyStyle() == 0 ); + m_commonToAllBodyStyles->Enable( symbol->HasAlternateBodyStyle() ); + } + return true; } @@ -416,7 +453,6 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() return false; SCH_COMMIT commit( m_frame ); - wxString text; /* save old text in undo list if not already in edit */ if( m_currentItem->GetEditFlags() == 0 ) @@ -424,8 +460,11 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() m_frame->GetCanvas()->Refresh(); + wxString text = m_textCtrl->GetValue(); + // convert any text variable cross-references to their UUIDs - text = m_frame->Schematic().ConvertRefsToKIIDs( m_textCtrl->GetValue() ); + if( SCHEMATIC* schematic = m_currentItem->Schematic() ) + text = schematic->ConvertRefsToKIIDs( m_textCtrl->GetValue() ); #ifdef __WXMAC__ // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting @@ -454,7 +493,24 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() m_currentItem->SetExcludedFromSim( m_excludeFromSim->GetValue() ); - if( !m_currentText->ValidateHyperlink( m_hyperlinkCombo->GetValue() ) ) + if( m_isSymbolEditor ) + { + SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast( m_frame ); + + m_currentItem->SetPrivate( m_privateCheckbox->GetValue() ); + + if( !m_commonToAllUnits->GetValue() ) + m_currentItem->SetUnit( symbolEditor->GetUnit() ); + else + m_currentItem->SetUnit( 0 ); + + if( !m_commonToAllBodyStyles->GetValue() ) + m_currentItem->SetBodyStyle( symbolEditor->GetBodyStyle() ); + else + m_currentItem->SetBodyStyle( 0 ); + } + + if( !EDA_TEXT::ValidateHyperlink( m_hyperlinkCombo->GetValue() ) ) { DisplayError( this, _( "Invalid hyperlink destination. Please enter either a valid URL " "(e.g. file:// or http(s)://) or \"#\" to create " @@ -467,7 +523,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() } if( m_currentText->GetTextWidth() != m_textSize.GetValue() ) - m_currentText->SetTextSize( VECTOR2I( m_textSize.GetValue(), m_textSize.GetValue() ) ); + m_currentText->SetTextSize( VECTOR2I( m_textSize.GetIntValue(), m_textSize.GetIntValue() ) ); if( m_fontCtrl->HaveFontSelection() ) { diff --git a/eeschema/dialogs/dialog_text_properties.h b/eeschema/dialogs/dialog_text_properties.h index 4de839c5af..fe2050d1d1 100644 --- a/eeschema/dialogs/dialog_text_properties.h +++ b/eeschema/dialogs/dialog_text_properties.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2024 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 @@ -38,8 +38,8 @@ class HTML_MESSAGE_BOX; class DIALOG_TEXT_PROPERTIES : public DIALOG_TEXT_PROPERTIES_BASE { public: - DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* parent, SCH_ITEM* aTextItem ); - ~DIALOG_TEXT_PROPERTIES(); + DIALOG_TEXT_PROPERTIES( SCH_BASE_FRAME* parent, SCH_ITEM* aTextItem ); + ~DIALOG_TEXT_PROPERTIES() override; private: void getContextualTextVars( const wxString& aCrossRef, wxArrayString* aTokens ); @@ -59,7 +59,8 @@ private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - SCH_EDIT_FRAME* m_frame; + SCH_BASE_FRAME* m_frame; + bool m_isSymbolEditor; SCH_ITEM* m_currentItem; EDA_TEXT* m_currentText; UNIT_BINDER m_textSize; diff --git a/eeschema/dialogs/dialog_text_properties_base.cpp b/eeschema/dialogs/dialog_text_properties_base.cpp index fcd4fc3670..606d23b171 100644 --- a/eeschema/dialogs/dialog_text_properties_base.cpp +++ b/eeschema/dialogs/dialog_text_properties_base.cpp @@ -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,12 ) ); + m_textEntrySizer->SetEmptyCellSize( wxSize( 0,6 ) ); m_textLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); m_textLabel->Wrap( -1 ); @@ -84,7 +84,7 @@ 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, 10 ); + m_textEntrySizer->Add( m_excludeFromSim, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxTOP|wxBOTTOM, 10 ); m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 ); m_fontLabel->Wrap( -1 ); @@ -309,6 +309,34 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi bMainSizer->Add( m_textEntrySizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); + m_fgSymbolEditor = new wxFlexGridSizer( 0, 3, 0, 0 ); + m_fgSymbolEditor->AddGrowableCol( 0 ); + m_fgSymbolEditor->AddGrowableCol( 2 ); + m_fgSymbolEditor->SetFlexibleDirection( wxBOTH ); + m_fgSymbolEditor->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_privateCheckbox = new wxCheckBox( this, wxID_ANY, _("Private to Symbol Editor"), wxDefaultPosition, wxDefaultSize, 0 ); + m_privateCheckbox->SetValue(true); + m_fgSymbolEditor->Add( m_privateCheckbox, 0, wxRIGHT, 5 ); + + + m_fgSymbolEditor->Add( 60, 0, 1, wxEXPAND, 5 ); + + m_commonToAllUnits = new wxCheckBox( this, wxID_ANY, _("Common to all units"), wxDefaultPosition, wxDefaultSize, 0 ); + m_fgSymbolEditor->Add( m_commonToAllUnits, 0, wxRIGHT|wxLEFT, 5 ); + + + m_fgSymbolEditor->Add( 0, 0, 1, wxEXPAND, 5 ); + + + m_fgSymbolEditor->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_commonToAllBodyStyles = new wxCheckBox( this, wxID_ANY, _("Common to all body styles"), wxDefaultPosition, wxDefaultSize, 0 ); + m_fgSymbolEditor->Add( m_commonToAllBodyStyles, 0, wxALL, 5 ); + + + bMainSizer->Add( m_fgSymbolEditor, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); + m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( this, wxID_OK ); m_sdbSizer1->AddButton( m_sdbSizer1OK ); diff --git a/eeschema/dialogs/dialog_text_properties_base.fbp b/eeschema/dialogs/dialog_text_properties_base.fbp index a015f8a7d3..f9422cd8f1 100644 --- a/eeschema/dialogs/dialog_text_properties_base.fbp +++ b/eeschema/dialogs/dialog_text_properties_base.fbp @@ -128,7 +128,7 @@ wxEXPAND|wxTOP|wxRIGHT|wxLEFT 1 - 0,12 + 0,6 wxBOTH 3 @@ -358,7 +358,7 @@ 10 2 0 - wxTOP + wxTOP|wxBOTTOM 1 1 @@ -3117,6 +3117,249 @@ + + 10 + wxEXPAND|wxRIGHT|wxLEFT + 0 + + 3 + wxBOTH + 0,2 + + 0 + + m_fgSymbolEditor + wxFLEX_GROWMODE_SPECIFIED + protected + 0 + 0 + + 5 + wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Private to Symbol Editor + + 0 + + + 0 + + 1 + m_privateCheckbox + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 60 + + + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Common to all units + + 0 + + + 0 + + 1 + m_commonToAllUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Common to all body styles + + 0 + + + 0 + + 1 + m_commonToAllBodyStyles + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 wxALL|wxEXPAND diff --git a/eeschema/dialogs/dialog_text_properties_base.h b/eeschema/dialogs/dialog_text_properties_base.h index b3d0fc482d..c1823bab68 100644 --- a/eeschema/dialogs/dialog_text_properties_base.h +++ b/eeschema/dialogs/dialog_text_properties_base.h @@ -94,6 +94,10 @@ class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM COLOR_SWATCH* m_fillColorSwatch; wxCheckBox* m_hyperlinkCb; WX_COMBOBOX* m_hyperlinkCombo; + wxFlexGridSizer* m_fgSymbolEditor; + wxCheckBox* m_privateCheckbox; + wxCheckBox* m_commonToAllUnits; + wxCheckBox* m_commonToAllBodyStyles; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Cancel; diff --git a/eeschema/import_gfx/graphics_importer_lib_symbol.cpp b/eeschema/import_gfx/graphics_importer_lib_symbol.cpp index 06142f3625..f45817d1b1 100644 --- a/eeschema/import_gfx/graphics_importer_lib_symbol.cpp +++ b/eeschema/import_gfx/graphics_importer_lib_symbol.cpp @@ -27,9 +27,8 @@ #include #include -#include +#include #include -#include GRAPHICS_IMPORTER_LIB_SYMBOL::GRAPHICS_IMPORTER_LIB_SYMBOL( LIB_SYMBOL* aSymbol, int aUnit ) : @@ -186,17 +185,16 @@ void GRAPHICS_IMPORTER_LIB_SYMBOL::AddText( const VECTOR2D& aOrigin, const wxStr double aOrientation, GR_TEXT_H_ALIGN_T aHJustify, GR_TEXT_V_ALIGN_T aVJustify, const COLOR4D& aColor ) { - std::unique_ptr textItem = std::make_unique( m_symbol ); + auto textItem = std::make_unique( MapCoordinate( aOrigin ), aText, LAYER_DEVICE ); + textItem->SetParent( m_symbol ); textItem->SetUnit( m_unit ); textItem->SetTextColor( aColor ); textItem->SetTextThickness( MapLineWidth( aThickness ) ); - textItem->SetTextPos( MapCoordinate( aOrigin ) ); textItem->SetTextAngle( EDA_ANGLE( aOrientation, DEGREES_T ) ); textItem->SetTextWidth( aWidth * ImportScalingFactor().x ); textItem->SetTextHeight( aHeight * ImportScalingFactor().y ); textItem->SetVertJustify( aVJustify ); textItem->SetHorizJustify( aHJustify ); - textItem->SetText( aText ); addItem( std::move( textItem ) ); } diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index dbcc305acd..80b6dc05b3 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -971,6 +971,8 @@ void LIB_SYMBOL::AddDrawItem( SCH_ITEM* aItem, bool aSort ) { wxCHECK( aItem, /* void */ ); + aItem->SetParent( this ); + m_drawings.push_back( aItem ); if( aSort ) diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index 8962ef44a1..00cab138eb 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -45,7 +45,7 @@ class TEST_LIB_SYMBOL_FIXTURE; typedef std::shared_ptr LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL typedef std::weak_ptr LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL -typedef MULTIVECTOR LIB_ITEMS_CONTAINER; +typedef MULTIVECTOR LIB_ITEMS_CONTAINER; typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS; diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp deleted file mode 100644 index 14b9cacd6a..0000000000 --- a/eeschema/lib_text.cpp +++ /dev/null @@ -1,533 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2004-2024 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 - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // For some default values -#include - -LIB_TEXT::LIB_TEXT( SCH_ITEM* aParent ) : - SCH_ITEM( aParent, LIB_TEXT_T ), - EDA_TEXT( schIUScale, wxEmptyString ) -{ - SetTextSize( VECTOR2I( schIUScale.MilsToIU( DEFAULT_TEXT_SIZE ), - schIUScale.MilsToIU( DEFAULT_TEXT_SIZE ) ) ); -} - - -void LIB_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const -{ - aCount = 2; - aLayers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : LAYER_DEVICE; - aLayers[1] = LAYER_SELECTION_SHADOWS; -} - - -bool LIB_TEXT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const -{ - EDA_TEXT tmp_text( *this ); - tmp_text.SetTextPos( DefaultTransform.TransformCoordinate( GetTextPos() ) ); - - /* The text orientation may need to be flipped if the - * transformation matrix causes xy axes to be flipped. - * this simple algo works only for schematic matrix (rot 90 or/and mirror) - */ - bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL ); - - tmp_text.SetTextAngle( t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL ); - return tmp_text.TextHitTest( aPosition, aAccuracy ); -} - - -EDA_ITEM* LIB_TEXT::Clone() const -{ - return new LIB_TEXT( *this ); -} - - -int LIB_TEXT::compare( const SCH_ITEM& aOther, int aCompareFlags ) const -{ - wxASSERT( aOther.Type() == LIB_TEXT_T ); - - int retv = SCH_ITEM::compare( aOther, aCompareFlags ); - - if( retv ) - return retv; - - const LIB_TEXT* tmp = ( LIB_TEXT* ) &aOther; - - int result = GetText().CmpNoCase( tmp->GetText() ); - - if( result != 0 ) - return result; - - if( GetTextPos().x != tmp->GetTextPos().x ) - return GetTextPos().x - tmp->GetTextPos().x; - - if( GetTextPos().y != tmp->GetTextPos().y ) - return GetTextPos().y - tmp->GetTextPos().y; - - if( GetTextWidth() != tmp->GetTextWidth() ) - return GetTextWidth() - tmp->GetTextWidth(); - - if( GetTextHeight() != tmp->GetTextHeight() ) - return GetTextHeight() - tmp->GetTextHeight(); - - return 0; -} - - -void LIB_TEXT::Move( const VECTOR2I& aOffset ) -{ - EDA_TEXT::Offset( aOffset ); -} - - -void LIB_TEXT::NormalizeJustification( bool inverse ) -{ - if( GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER && GetVertJustify() == GR_TEXT_V_ALIGN_CENTER ) - return; - - VECTOR2I delta( 0, 0 ); - BOX2I bbox = GetTextBox(); - - if( GetTextAngle().IsHorizontal() ) - { - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - delta.x = bbox.GetWidth() / 2; - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - delta.x = - bbox.GetWidth() / 2; - - if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) - delta.y = - bbox.GetHeight() / 2; - else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) - delta.y = bbox.GetHeight() / 2; - } - else - { - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - delta.y = bbox.GetWidth() / 2; - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - delta.y = - bbox.GetWidth() / 2; - - if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) - delta.x = + bbox.GetHeight() / 2; - else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) - delta.x = - bbox.GetHeight() / 2; - } - - if( inverse ) - SetTextPos( GetTextPos() - delta ); - else - SetTextPos( GetTextPos() + delta ); -} - - -void LIB_TEXT::MirrorHorizontally( int aCenter ) -{ - NormalizeJustification( false ); - int x = GetTextPos().x; - - x -= aCenter; - x *= -1; - x += aCenter; - - if( GetTextAngle().IsHorizontal() ) - { - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - } - else - { - if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) - SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) - SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - } - - SetTextX( x ); - NormalizeJustification( true ); -} - - -void LIB_TEXT::MirrorVertically( int aCenter ) -{ - NormalizeJustification( false ); - int y = GetTextPos().y; - - y -= aCenter; - y *= -1; - y += aCenter; - - if( GetTextAngle().IsHorizontal() ) - { - if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) - SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) - SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - } - else - { - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - } - - SetTextY( y ); - NormalizeJustification( true ); -} - - -void LIB_TEXT::Rotate( const VECTOR2I& center, bool aRotateCCW ) -{ - NormalizeJustification( false ); - EDA_ANGLE rot_angle = aRotateCCW ? -ANGLE_90 : ANGLE_90; - - VECTOR2I pt = GetTextPos(); - RotatePoint( pt, center, rot_angle ); - SetTextPos( pt ); - - if( GetTextAngle().IsHorizontal() ) - { - SetTextAngle( ANGLE_VERTICAL ); - } - else - { - // 180° rotation is a mirror - - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - - if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) - SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) - SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - - SetTextAngle( ANGLE_0 ); - } - - NormalizeJustification( true ); -} - - -void LIB_TEXT::Plot( PLOTTER* plotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, - int aUnit, int aBodyStyle, const VECTOR2I& offset, bool aDimmed ) -{ - wxASSERT( plotter != nullptr ); - - if( IsPrivate() ) - return; - - if( aBackground ) - return; - - SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( plotter ); - - BOX2I bBox = GetBoundingBox(); - // convert coordinates from draw Y axis to symbol_editor Y axis - bBox.RevertYAxis(); - - /* - * Calculate the text justification, according to the symbol orientation/mirror. This is - * a bit complicated due to cumulative calculations: - * - numerous cases (mirrored or not, rotation) - * - the plotter's Text() function will also recalculate H and V justifications according - * to the text orientation - * - when a symbol is mirrored the text is not, and justifications become a nightmare - * - * So the easier way is to use no justifications (centered text) and use GetBoundingBox to - * know the text coordinate considered as centered. - */ - VECTOR2I txtpos = bBox.Centre(); - TEXT_ATTRIBUTES attrs = GetAttributes(); - attrs.m_Halign = GR_TEXT_H_ALIGN_CENTER; - attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER; - - // The text orientation may need to be flipped if the transformation matrix causes xy - // axes to be flipped. - int t1 = ( renderSettings->m_Transform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL ); - VECTOR2I pos = renderSettings->TransformCoordinate( txtpos ) + offset; - COLOR4D color = GetTextColor(); - COLOR4D bg = renderSettings->GetBackgroundColor(); - - if( !plotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) - color = renderSettings->GetLayerColor( LAYER_DEVICE ); - - if( !IsVisible() ) - bg = renderSettings->GetLayerColor( LAYER_HIDDEN ); - else if( bg == COLOR4D::UNSPECIFIED || !plotter->GetColorMode() ) - bg = COLOR4D::WHITE; - - if( aDimmed ) - { - color.Desaturate( ); - color = color.Mix( bg, 0.5f ); - } - - int penWidth = std::max( GetEffectiveTextPenWidth(), renderSettings->GetMinPenWidth() ); - - KIFONT::FONT* font = GetFont(); - - if( !font ) - font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() ); - - attrs.m_StrokeWidth = penWidth; - attrs.m_Angle = t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL; - - plotter->PlotText( pos, color, GetText(), attrs, font, GetFontMetrics() ); -} - - -int LIB_TEXT::GetPenWidth() const -{ - return GetEffectiveTextPenWidth(); -} - - -KIFONT::FONT* LIB_TEXT::getDrawFont() const -{ - KIFONT::FONT* font = EDA_TEXT::GetFont(); - - if( !font ) - font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() ); - - return font; -} - - -void LIB_TEXT::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, - const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) -{ - wxDC* DC = aSettings->GetPrintDC(); - COLOR4D color = GetTextColor(); - bool blackAndWhiteMode = GetGRForceBlackPenState(); - int penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetDefaultPenWidth() ); - - if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED ) - color = aSettings->GetLayerColor( LAYER_DEVICE ); - - COLOR4D bg = aSettings->GetBackgroundColor(); - - if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() ) - bg = COLOR4D::WHITE; - - if( !IsVisible() ) - bg = aSettings->GetLayerColor( LAYER_HIDDEN ); - - if( aDimmed ) - { - color.Desaturate( ); - color = color.Mix( bg, 0.5f ); - } - - // Calculate the text orientation, according to the symbol orientation/mirror (needed when - // draw text in schematic) - EDA_ANGLE orient = GetTextAngle(); - - if( aSettings->m_Transform.y1 ) // Rotate symbol 90 degrees. - { - if( orient == ANGLE_HORIZONTAL ) - orient = ANGLE_VERTICAL; - else - orient = ANGLE_HORIZONTAL; - } - - KIFONT::FONT* font = GetFont(); - - if( !font ) - font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() ); - - /* - * Calculate the text justification, according to the symbol orientation/mirror. - * This is a bit complicated due to cumulative calculations: - * - numerous cases (mirrored or not, rotation) - * - the GRText function will also recalculate H and V justifications according to the text - * orientation. - * - When a symbol is mirrored, the text is not mirrored and justifications are complicated - * to calculate so the more easily way is to use no justifications (centered text) and - * use GetBoundingBox to know the text coordinate considered as centered - */ - BOX2I bBox = GetBoundingBox(); - - // convert coordinates from draw Y axis to symbol_editor Y axis: - bBox.RevertYAxis(); - VECTOR2I txtpos = bBox.Centre(); - - // Calculate pos according to mirror/rotation. - txtpos = aSettings->m_Transform.TransformCoordinate( txtpos ) + aOffset; - - GRPrintText( DC, txtpos, color, GetShownText( true ), orient, GetTextSize(), - GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), - font, GetFontMetrics() ); -} - - -void LIB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) -{ - wxString msg; - - getSymbolEditorMsgPanelInfo( aFrame, aList ); - - // Don't use GetShownText() here; we want to show the user the variable references - aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) ); - - aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) ); - - aList.emplace_back( _( "Style" ), GetTextStyleName() ); - - aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) ); - - switch ( GetHorizJustify() ) - { - case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break; - case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break; - case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break; - case GR_TEXT_H_ALIGN_INDETERMINATE: msg = INDETERMINATE_STATE; break; - } - - aList.emplace_back( _( "H Justification" ), msg ); - - switch ( GetVertJustify() ) - { - case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break; - case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break; - case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break; - case GR_TEXT_V_ALIGN_INDETERMINATE: msg = INDETERMINATE_STATE; break; - } - - aList.emplace_back( _( "V Justification" ), msg ); -} - - -const BOX2I LIB_TEXT::GetBoundingBox() const -{ - /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when - * calling GetTextBox() that works using top to bottom Y axis orientation. - */ - BOX2I bbox = GetTextBox( -1, true ); - bbox.RevertYAxis(); - - // We are using now a bottom to top Y axis. - VECTOR2I orig = bbox.GetOrigin(); - VECTOR2I end = bbox.GetEnd(); - - RotatePoint( orig, GetTextPos(), -GetTextAngle() ); - RotatePoint( end, GetTextPos(), -GetTextAngle() ); - - bbox.SetOrigin( orig ); - bbox.SetEnd( end ); - - // We are using now a top to bottom Y axis: - bbox.RevertYAxis(); - - return bbox; -} - - -wxString LIB_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const -{ - return wxString::Format( _( "Graphic Text '%s'" ), KIUI::EllipsizeMenuText( GetText() ) ); -} - - -BITMAPS LIB_TEXT::GetMenuImage() const -{ - return BITMAPS::text; -} - - -void LIB_TEXT::BeginEdit( const VECTOR2I& aPosition ) -{ - SetTextPos( aPosition ); -} - - -void LIB_TEXT::CalcEdit( const VECTOR2I& aPosition ) -{ - SetTextPos( aPosition ); -} - - -bool LIB_TEXT::operator==( const SCH_ITEM& aOther ) const -{ - if( Type() != aOther.Type() ) - return false; - - const LIB_TEXT& other = static_cast( aOther ); - - return SCH_ITEM::operator==( aOther ) && EDA_TEXT::operator==( other ); -} - - -double LIB_TEXT::Similarity( const SCH_ITEM& aOther ) const -{ - if( m_Uuid == aOther.m_Uuid ) - return 1.0; - - if( aOther.Type() != Type() ) - return 0.0; - - const LIB_TEXT& other = static_cast( aOther ); - - double similarity = SimilarityBase( other ); - similarity *= EDA_TEXT::Similarity( other ); - - return similarity; -} - -static struct LIB_TEXT_DESC -{ - LIB_TEXT_DESC() - { - PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); - REGISTER_TYPE( LIB_TEXT ); - propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.InheritsAfter( TYPE_HASH( LIB_TEXT ), TYPE_HASH( SCH_ITEM ) ); - propMgr.InheritsAfter( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ) ); - - propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Mirrored" ) ); - propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) ); - propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) ); - propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) ); - - // Orientation is exposed differently in schematic; mask the base for now - propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) ); - } -} _LIB_TEXT_DESC; diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h deleted file mode 100644 index e1dd6c8875..0000000000 --- a/eeschema/lib_text.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2024 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 - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef LIB_TEXT_H -#define LIB_TEXT_H - -#include -#include - - -/** - * Define a symbol library graphical text item. - * - * This is only a graphical text item. Field text like the reference designator, - * symbol value, etc. are not LIB_TEXT items. See the #SCH_FIELD class for the - * field item definition. - */ -class LIB_TEXT : public SCH_ITEM, public EDA_TEXT -{ -public: - LIB_TEXT( SCH_ITEM* aParent ); - - // Do not create a copy constructor. The one generated by the compiler is adequate. - - ~LIB_TEXT() { } - - wxString GetClass() const override - { - return wxT( "LIB_TEXT" ); - } - - static inline bool ClassOf( const EDA_ITEM* aItem ) - { - return aItem && aItem->Type() == LIB_TEXT_T; - } - - wxString GetFriendlyName() const override - { - return _( "Text" ); - } - - void ViewGetLayers( int aLayers[], int& aCount ) const override; - - bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; - - bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override - { - if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) ) - return false; - - BOX2I rect = aRect; - - rect.Inflate( aAccuracy ); - - BOX2I textBox = GetTextBox(); - textBox.RevertYAxis(); - - if( aContained ) - return rect.Contains( textBox ); - - return rect.Intersects( textBox, GetTextAngle() ); - } - - int GetPenWidth() const override; - - KIFONT::FONT* getDrawFont() const override; - - const BOX2I GetBoundingBox() const override; - - void BeginEdit( const VECTOR2I& aStartPoint ) override; - void CalcEdit( const VECTOR2I& aPosition ) override; - - void Move( const VECTOR2I& aOffset ) override; - - VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); } - void SetPosition( const VECTOR2I& aPos ) override { EDA_TEXT::SetTextPos( aPos ); } - - void MirrorHorizontally( int aCenter ) override; - void MirrorVertically( int aCenter ) override; - void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override; - - void NormalizeJustification( bool inverse ); - - void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, - const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override; - - void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, - int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override; - - wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override; - void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - - BITMAPS GetMenuImage() const override; - - EDA_ITEM* Clone() const override; - - double Similarity( const SCH_ITEM& aOther ) const override; - - bool operator==( const SCH_ITEM& aOther ) const override; - -private: - /** - * @copydoc SCH_ITEM::compare() - * - * The text specific sort order is as follows: - * - Text string, case insensitive compare. - * - Text horizontal (X) position. - * - Text vertical (Y) position. - * - Text width. - * - Text height. - */ - int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override; -}; - - -#endif // LIB_TEXT_H diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp index 14e2f7a565..bf3a36b00b 100644 --- a/eeschema/sch_io/altium/sch_io_altium.cpp +++ b/eeschema/sch_io/altium/sch_io_altium.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -1521,7 +1520,7 @@ void SCH_IO_ALTIUM::ParseLabel( const std::map& aProperties, schsym = m_symbols.at( libSymbolIt->first ); } - LIB_TEXT* textItem = new LIB_TEXT( symbol ); + SCH_TEXT* textItem = new SCH_TEXT( { 0, 0 }, elem.text, LAYER_DEVICE ); symbol->AddDrawItem( textItem, false ); /// Handle labels that are in a library symbol, not on schematic @@ -1531,10 +1530,9 @@ void SCH_IO_ALTIUM::ParseLabel( const std::map& aProperties, textItem->SetPosition( GetRelativePosition( elem.location + m_sheetOffset, schsym ) ); textItem->SetUnit( std::max( 0, elem.ownerpartid ) ); - textItem->SetText( elem.text ); SetTextPositioning( textItem, elem.justification, elem.orientation ); - size_t fontId = static_cast( elem.fontId ); + size_t fontId = elem.fontId; if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() ) { diff --git a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp index 12414a1f6f..206c1816d0 100644 --- a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -1696,9 +1695,9 @@ const LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef( const SYMDEF_ID& aSymd for( std::pair textPair : csSym.Texts ) { TEXT csText = textPair.second; + VECTOR2I pos = getKiCadLibraryPoint( csText.Position, csSym.Origin ); + auto libtext = std::make_unique( pos, csText.Text, LAYER_DEVICE ); - std::unique_ptr libtext = std::make_unique( kiSym.get() ); - libtext->SetText( csText.Text ); libtext->SetUnit( gateNumber ); libtext->SetPosition( getKiCadLibraryPoint( csText.Position, csSym.Origin ) ); libtext->SetMultilineAllowed( true ); // temporarily so that we calculate bbox correctly @@ -1720,7 +1719,7 @@ const LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef( const SYMDEF_ID& aSymd RotatePoint( linePos, libtext->GetTextPos(), -libtext->GetTextAngle() ); - LIB_TEXT* textLine = static_cast( libtext->Duplicate() ); + SCH_TEXT* textLine = static_cast( libtext->Duplicate() ); textLine->SetText( strings[ii] ); textLine->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); textLine->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); @@ -3064,12 +3063,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT EDA_ITEM* textEdaItem = dynamic_cast( aKiCadTextItem ); wxCHECK( textEdaItem, /* void */ ); // ensure this is a EDA_ITEM - switch( textEdaItem->Type() ) - { - // Some KiCad schematic text items only permit a limited amount of angles - // and text justifications - case LIB_TEXT_T: - case SCH_FIELD_T: + if( textEdaItem->Type() == SCH_FIELD_T || aInvertY ) { // Spin style not used. All text justifications are permitted. However, only orientations // of 0 deg or 90 deg are supported @@ -3101,10 +3095,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT aKiCadTextItem->SetTextAngle( angle ); setAlignment( aKiCadTextItem, textAlignment ); - return; } - - case SCH_TEXT_T: + else if( textEdaItem->Type() == SCH_TEXT_T ) { // Note spin style in a SCH_TEXT results in a vertical alignment GR_TEXT_V_ALIGN_BOTTOM // so need to adjust the location of the text element based on Cadstar's original text @@ -3122,6 +3114,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT 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; + default: wxFAIL_MSG( "Unexpected Spin Style" ); break; } aKiCadTextItem->SetTextPos( pos ); @@ -3147,23 +3140,22 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT aKiCadTextItem->SetTextAngle( ANGLE_VERTICAL ); aKiCadTextItem->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; + + default: + wxFAIL_MSG( "Unexpected Spin Style" ); + break; } aKiCadTextItem->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - break; } - - // We don't want to change position of net labels as that would break connectivity - case SCH_LABEL_T: - case SCH_GLOBAL_LABEL_T: - case SCH_HIER_LABEL_T: - case SCH_SHEET_PIN_T: - static_cast( aKiCadTextItem )->SetSpinStyle( spin ); - return; - - default: + else if( SCH_LABEL_BASE* label = dynamic_cast( aKiCadTextItem ) ) + { + // We don't want to change position of net labels as that would break connectivity + label->SetSpinStyle( spin ); + } + else + { wxFAIL_MSG( "Unexpected item type" ); - return; } } @@ -3246,9 +3238,9 @@ LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart( const LIB_SYMBOL* aSym break; } - case KICAD_T::LIB_TEXT_T: + case KICAD_T::SCH_TEXT_T: { - LIB_TEXT& txt = static_cast( item ); + SCH_TEXT& txt = static_cast( item ); txt.SetPosition( scalePt( txt.GetPosition() ) ); txt.SetTextSize( scaleSize( txt.GetTextSize() ) ); diff --git a/eeschema/sch_io/eagle/sch_io_eagle.cpp b/eeschema/sch_io/eagle/sch_io_eagle.cpp index 7e68d514a9..a97d74717b 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.cpp +++ b/eeschema/sch_io/eagle/sch_io_eagle.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -2224,8 +2223,7 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr libtext( loadSymbolText( aSymbol, currentNode, - aGateNumber ) ); + std::unique_ptr libtext( loadSymbolText( currentNode, aGateNumber ) ); if( libtext->GetText() == wxT( "${REFERENCE}" ) ) { @@ -2515,15 +2513,10 @@ LIB_PIN* SCH_IO_EAGLE::loadPin( std::unique_ptr& aSymbol, wxXmlNode* } -LIB_TEXT* SCH_IO_EAGLE::loadSymbolText( std::unique_ptr& aSymbol, - wxXmlNode* aLibText, int aGateNumber ) +SCH_TEXT* SCH_IO_EAGLE::loadSymbolText( wxXmlNode* aLibText, int aGateNumber ) { - std::unique_ptr libtext = std::make_unique( aSymbol.get() ); - ETEXT etext( aLibText ); - - libtext->SetUnit( aGateNumber ); - libtext->SetPosition( VECTOR2I( etext.x.ToSchUnits(), etext.y.ToSchUnits() ) ); - + ETEXT etext( aLibText ); + VECTOR2I pos( etext.x.ToSchUnits(), etext.y.ToSchUnits() ); const wxString& eagleText = aLibText->GetNodeContent(); wxString adjustedText; wxStringTokenizer tokenizer( eagleText, "\r\n" ); @@ -2539,7 +2532,12 @@ LIB_TEXT* SCH_IO_EAGLE::loadSymbolText( std::unique_ptr& aSymbol, adjustedText += tmp; } - libtext->SetText( adjustedText.IsEmpty() ? wxString( wxT( "~" ) ) : adjustedText ); + if( adjustedText.IsEmpty() ) + adjustedText = wxT( "~" ); + + auto libtext = std::make_unique( pos, adjustedText, LAYER_DEVICE ); + + libtext->SetUnit( aGateNumber ); loadTextAttributes( libtext.get(), etext ); return libtext.release(); @@ -2599,9 +2597,8 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorSetPosition( VECTOR2I( legendPosX, KiROUND( legendPosY ) ) ); - legendText->SetText( wxString( legendChar ) ); + SCH_TEXT* legendText = new SCH_TEXT( VECTOR2I( legendPosX, KiROUND( legendPosY ) ), + wxString( legendChar ), LAYER_DEVICE ); legendText->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 90 ), schIUScale.MilsToIU( 100 ) ) ); aItems.push_back( legendText ); @@ -2640,9 +2637,8 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorSetPosition( VECTOR2I( legendPosX, KiROUND( legendPosY ) ) ); - legendText->SetText( wxString( legendChar ) ); + SCH_TEXT* legendText = new SCH_TEXT( VECTOR2I( legendPosX, KiROUND( legendPosY ) ), + wxString( legendChar ), LAYER_DEVICE ); legendText->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 90 ), schIUScale.MilsToIU( 100 ) ) ); aItems.push_back( legendText ); @@ -2681,9 +2677,8 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorSetPosition( VECTOR2I( KiROUND( legendPosX ), legendPosY ) ); - legendText->SetText( wxString( legendChar ) ); + SCH_TEXT* legendText = new SCH_TEXT( VECTOR2I( KiROUND( legendPosX ), legendPosY ), + wxString( legendChar ), LAYER_DEVICE ); legendText->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 90 ), schIUScale.MilsToIU( 100 ) ) ); aItems.push_back( legendText ); @@ -2722,9 +2717,8 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vectorSetPosition( VECTOR2I( KiROUND( legendPosX ), legendPosY ) ); - legendText->SetText( wxString( legendChar ) ); + SCH_TEXT* legendText = new SCH_TEXT( VECTOR2I( KiROUND( legendPosX ), legendPosY ), + wxString( legendChar ), LAYER_DEVICE ); legendText->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 90 ), schIUScale.MilsToIU( 100 ) ) ); aItems.push_back( legendText ); @@ -2781,7 +2775,7 @@ void SCH_IO_EAGLE::loadTextAttributes( EDA_TEXT* aText, const ETEXT& aAttribs ) } -void SCH_IO_EAGLE::loadFieldAttributes( SCH_FIELD* aField, const LIB_TEXT* aText ) const +void SCH_IO_EAGLE::loadFieldAttributes( SCH_FIELD* aField, const SCH_TEXT* aText ) const { aField->SetTextPos( aText->GetPosition() ); aField->SetTextSize( aText->GetTextSize() ); diff --git a/eeschema/sch_io/eagle/sch_io_eagle.h b/eeschema/sch_io/eagle/sch_io_eagle.h index 4bb8a914a7..3f6d090fa2 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.h +++ b/eeschema/sch_io/eagle/sch_io_eagle.h @@ -166,12 +166,11 @@ private: int aGateNumber ); LIB_PIN* loadPin( std::unique_ptr& aSymbol, wxXmlNode*, EPIN* epin, int aGateNumber ); - LIB_TEXT* loadSymbolText( std::unique_ptr& aSymbol, wxXmlNode* aLibText, - int aGateNumber ); + SCH_TEXT* loadSymbolText( wxXmlNode* aLibText, int aGateNumber ); void loadSymbolFrame( wxXmlNode* aFrameNode, std::vector& aLines ); void loadTextAttributes( EDA_TEXT* aText, const ETEXT& aAttribs ) const; - void loadFieldAttributes( SCH_FIELD* aField, const LIB_TEXT* aText ) const; + void loadFieldAttributes( SCH_FIELD* aField, const SCH_TEXT* aText ) const; ///< Move net labels that are detached from any wire to the nearest wire void adjustNetLabels(); diff --git a/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp b/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp index c7a20dc1ec..19ff2bfa59 100644 --- a/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp +++ b/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -899,20 +898,21 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol if( textType == wxS( "P" ) ) { textItem = &aSymbol->GetReferenceField(); + textItem->SetTextPos( RelPosSym( pos ) ); + textItem->SetText( textStr ); } else if( textType == wxS( "N" ) ) { textItem = &aSymbol->GetValueField(); + textItem->SetTextPos( RelPosSym( pos ) ); + textItem->SetText( textStr ); } else { - textItem = new LIB_TEXT( aSymbol ); + textItem = new SCH_TEXT( RelPosSym( pos ), textStr, LAYER_DEVICE ); added = true; } - textItem->SetTextPos( RelPosSym( pos ) ); - textItem->SetText( textStr ); - textItem->SetTextAngleDegrees( ( 360 - angle ) % 360 ); textItem->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); diff --git a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp index 6c51f870cf..78f1ec7a96 100644 --- a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp +++ b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -513,14 +512,11 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector text = std::make_unique( ksymbol ); - - text->SetPosition( ScalePosSym( pos ) ); - text->SetText( UnescapeHTML( textStr ) ); + auto text = std::make_unique( ScalePosSym( pos ), UnescapeHTML( textStr ), + LAYER_DEVICE ); text->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); text->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - text->SetTextAngleDegrees( angle ); text->SetUnit( currentUnit ); diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp index 450fdea389..4d58d8e14f 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include @@ -720,8 +720,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDrawEntries( std::unique_ptr break; case 'T': // Text - aSymbol->AddDrawItem( loadText( aSymbol, aReader, aMajorVersion, aMinorVersion ), - false ); + aSymbol->AddDrawItem( loadText( aReader, aMajorVersion, aMinorVersion ), false ); break; case 'S': // Square @@ -949,35 +948,23 @@ LIB_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadCircle( std::unique_ptr& aSymbol, - LINE_READER& aReader, - int aMajorVersion, - int aMinorVersion ) +SCH_TEXT* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText( LINE_READER& aReader, + int aMajorVersion, int aMinorVersion ) { const char* line = aReader.Line(); wxCHECK_MSG( strCompare( "T", line, &line ), nullptr, "Invalid LIB_TEXT definition" ); - LIB_TEXT* text = new LIB_TEXT( aSymbol.get() ); - double angleInTenths = parseInt( aReader, line, &line ); - - text->SetTextAngle( EDA_ANGLE( angleInTenths, TENTHS_OF_A_DEGREE_T ) ); - + double angleInTenths; VECTOR2I center; + VECTOR2I size; + wxString str; + + angleInTenths = parseInt( aReader, line, &line ); center.x = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); center.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); - text->SetPosition( center ); - - VECTOR2I size; - size.x = size.y = schIUScale.MilsToIU( parseInt( aReader, line, &line ) ); - text->SetTextSize( size ); - text->SetVisible( !parseInt( aReader, line, &line ) ); - text->SetUnit( parseInt( aReader, line, &line ) ); - text->SetBodyStyle( parseInt( aReader, line, &line ) ); - - wxString str; // If quoted string loading fails, load as not quoted string. if( *line == '"' ) @@ -1000,7 +987,12 @@ LIB_TEXT* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText( std::unique_ptr& str.Replace( "''", "\"" ); } - text->SetText( str ); + SCH_TEXT* text = new SCH_TEXT( center, str, LAYER_DEVICE ); + text->SetTextAngle( EDA_ANGLE( angleInTenths, TENTHS_OF_A_DEGREE_T ) ); + text->SetTextSize( size ); + text->SetVisible( !parseInt( aReader, line, &line ) ); + text->SetUnit( parseInt( aReader, line, &line ) ); + text->SetBodyStyle( parseInt( aReader, line, &line ) ); // Here things are murky and not well defined. At some point it appears the format // was changed to add text properties. However rather than add the token to the end of @@ -1579,23 +1571,23 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMA { switch( item.Type() ) { - default: - case LIB_PIN_T: savePin( (LIB_PIN* ) &item, aFormatter ); break; - case LIB_TEXT_T: saveText( ( LIB_TEXT* ) &item, aFormatter ); break; + case LIB_PIN_T: savePin( static_cast( &item ), aFormatter ); break; + case SCH_TEXT_T: saveText( static_cast( &item ), aFormatter ); break; case LIB_SHAPE_T: { LIB_SHAPE& shape = static_cast( item ); switch( shape.GetShape() ) { - case SHAPE_T::ARC: saveArc( &shape, aFormatter ); break; - case SHAPE_T::BEZIER: saveBezier( &shape, aFormatter ); break; - case SHAPE_T::CIRCLE: saveCircle( &shape, aFormatter ); break; - case SHAPE_T::POLY: savePolyLine( &shape, aFormatter ); break; - case SHAPE_T::RECTANGLE: saveRectangle( &shape, aFormatter ); break; + case SHAPE_T::ARC: saveArc( &shape, aFormatter ); break; + case SHAPE_T::BEZIER: saveBezier( &shape, aFormatter ); break; + case SHAPE_T::CIRCLE: saveCircle( &shape, aFormatter ); break; + case SHAPE_T::POLY: savePolyLine( &shape, aFormatter ); break; + case SHAPE_T::RECTANGLE: saveRectangle( &shape, aFormatter ); break; default: break; } } + default: break; } } @@ -1821,9 +1813,9 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveRectangle( LIB_SHAPE* aRectangle, } -void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveText( const LIB_TEXT* aText, OUTPUTFORMATTER& aFormatter ) +void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveText( const SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter ) { - wxCHECK_RET( aText && aText->Type() == LIB_TEXT_T, "Invalid LIB_TEXT object." ); + wxCHECK_RET( aText && aText->Type() == SCH_TEXT_T, "Invalid SCH_TEXT object." ); wxString text = aText->GetText(); diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.h b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.h index 2faf8903da..63dc1e28ae 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.h +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.h @@ -75,8 +75,7 @@ private: void loadDocs(); static LIB_SHAPE* loadArc( std::unique_ptr& aSymbol, LINE_READER& aReader ); static LIB_SHAPE* loadCircle( std::unique_ptr& aSymbol, LINE_READER& aReader ); - static LIB_TEXT* loadText( std::unique_ptr& aSymbol, LINE_READER& aReader, - int aMajorVersion, int aMinorVersion ); + static SCH_TEXT* loadText( LINE_READER& aReader, int aMajorVersion, int aMinorVersion ); static LIB_SHAPE* loadRect( std::unique_ptr& aSymbol, LINE_READER& aReader ); static LIB_PIN* loadPin( std::unique_ptr& aSymbol, LINE_READER& aReader ); static LIB_SHAPE* loadPolyLine( std::unique_ptr& aSymbol, LINE_READER& aReader ); @@ -92,7 +91,7 @@ private: static void savePin( const LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter ); static void savePolyLine( LIB_SHAPE* aPolyLine, OUTPUTFORMATTER& aFormatter ); static void saveRectangle( LIB_SHAPE* aRectangle, OUTPUTFORMATTER& aFormatter ); - static void saveText( const LIB_TEXT* aText, OUTPUTFORMATTER& aFormatter ); + static void saveText( const SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter ); int m_versionMajor; int m_versionMinor; diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp index 4aea4c5b06..7d55518161 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp @@ -49,13 +49,8 @@ #include #include #include -#include #include -#include -#include -#include // for MAX_UNIT_COUNT_PER_PACKAGE definition #include -#include #include #include #include diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp index 7124cfa3c4..7c4b45c780 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -375,8 +374,8 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFO savePin( static_cast( aItem ), aFormatter, aNestLevel ); break; - case LIB_TEXT_T: - saveText( static_cast( aItem ), aFormatter, aNestLevel ); + case SCH_TEXT_T: + saveText( static_cast( aItem ), aFormatter, aNestLevel ); break; case LIB_TEXTBOX_T: @@ -471,10 +470,10 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFor } -void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveText( LIB_TEXT* aText, OUTPUTFORMATTER& aFormatter, +void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveText( SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter, int aNestLevel ) { - wxCHECK_RET( aText && aText->Type() == LIB_TEXT_T, "Invalid LIB_TEXT object." ); + wxCHECK_RET( aText && aText->Type() == SCH_TEXT_T, "Invalid SCH_TEXT object." ); aFormatter.Print( aNestLevel, "(text%s %s (at %s %s %g)\n", aText->IsPrivate() ? " private" : "", diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h index 3e72ab83fc..087ec5eb35 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h @@ -26,7 +26,7 @@ class FILE_LINE_READER; class LIB_PIN; -class LIB_TEXT; +class SCH_TEXT; class LIB_TEXTBOX; class LINE_READER; class SCH_IO_KICAD_SEXPR; @@ -66,7 +66,7 @@ private: int aNestLevel ); static void saveField( SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter, int aNestLevel ); static void savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); - static void saveText( LIB_TEXT* aText, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); + static void saveText( SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); static void saveTextBox( LIB_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp index e36613249b..6c19e283e7 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include // KiROUND, Clamp #include @@ -577,7 +576,7 @@ SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem() break; case T_text: - return parseText(); + return parseSymbolText(); break; case T_text_box: @@ -1756,14 +1755,15 @@ LIB_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseRectangle() } -LIB_TEXT* SCH_IO_KICAD_SEXPR_PARSER::parseText() +SCH_TEXT* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolText() { wxCHECK_MSG( CurTok() == T_text, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a text token." ) ); T token; - std::unique_ptr text = std::make_unique( nullptr ); + std::unique_ptr text = std::make_unique(); + text->SetLayer( LAYER_DEVICE ); text->SetUnit( m_unit ); text->SetBodyStyle( m_bodyStyle ); token = NextTok(); @@ -1799,7 +1799,7 @@ LIB_TEXT* SCH_IO_KICAD_SEXPR_PARSER::parseText() break; case T_effects: - parseEDA_TEXT( static_cast( text.get() ), true ); + parseEDA_TEXT( text.get(), true ); break; default: diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h index 0568a6799e..22032a0670 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h @@ -39,7 +39,7 @@ class LIB_SHAPE; class LIB_PIN; -class LIB_TEXT; +class LIB_TEXTBOX; class PAGE_INFO; class SCH_BITMAP; class SCH_BUS_WIRE_ENTRY; @@ -201,7 +201,7 @@ private: LIB_PIN* parsePin(); LIB_SHAPE* parsePolyLine(); LIB_SHAPE* parseRectangle(); - LIB_TEXT* parseText(); + SCH_TEXT* parseSymbolText(); LIB_TEXTBOX* parseTextBox(); void parsePAGE_INFO( PAGE_INFO& aPageInfo ); diff --git a/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp b/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp index b841615e8b..2b1f2d3f13 100644 --- a/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp +++ b/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp @@ -788,7 +788,7 @@ SCH_TEXT* SCH_IO_LTSPICE_PARSER::CreateSCH_TEXT( VECTOR2I aOffset, const wxStrin LTSPICE_SCHEMATIC::JUSTIFICATION aJustification ) { VECTOR2I pos = ToKicadCoords( aOffset ) + m_originOffset; - SCH_TEXT* textItem = new SCH_TEXT( pos, aText, SCH_TEXT_T ); + SCH_TEXT* textItem = new SCH_TEXT( pos, aText ); textItem->SetTextSize( ToKicadFontSize( aFontSize ) ); textItem->SetVisible( true ); diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index d8f51d3b2b..16445f49e4 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -178,8 +178,8 @@ SPIN_STYLE SPIN_STYLE::MirrorX() { 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; + case SPIN_STYLE::LEFT: break; + case SPIN_STYLE::RIGHT: break; } return SPIN_STYLE( newSpin ); @@ -194,8 +194,8 @@ SPIN_STYLE SPIN_STYLE::MirrorY() { 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; + case SPIN_STYLE::UP: break; + case SPIN_STYLE::BOTTOM: break; } return SPIN_STYLE( newSpin ); @@ -203,7 +203,7 @@ SPIN_STYLE SPIN_STYLE::MirrorY() SCH_LABEL_BASE::SCH_LABEL_BASE( const VECTOR2I& aPos, const wxString& aText, KICAD_T aType ) : - SCH_TEXT( aPos, aText, aType ), + SCH_TEXT( aPos, aText, LAYER_NOTES, aType ), m_shape( L_UNSPECIFIED ), m_connectionType( CONNECTION_TYPE::NONE ), m_isDangling( true ), diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 1647192d6a..43efd886e5 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -124,10 +123,9 @@ static LIB_SYMBOL* dummy() square->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) ); square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) ); - LIB_TEXT* text = new LIB_TEXT( symbol ); + SCH_TEXT* text = new SCH_TEXT( { 0, 0 }, wxT( "??" ), LAYER_DEVICE ); text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) ); - text->SetText( wxString( wxT( "??" ) ) ); symbol->AddDrawItem( square ); symbol->AddDrawItem( text ); @@ -192,9 +190,6 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed ) drawBoundingBox = false; draw( static_cast( aItem ), aLayer, aDimmed ); break; - case LIB_TEXT_T: - draw( static_cast( aItem ), aLayer, aDimmed ); - break; case LIB_TEXTBOX_T: draw( static_cast( aItem ), aLayer, aDimmed ); break; @@ -211,7 +206,7 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed ) draw( static_cast( aItem ), aLayer ); break; case SCH_TEXT_T: - draw( static_cast( aItem ), aLayer ); + draw( static_cast( aItem ), aLayer, aDimmed ); break; case SCH_TEXTBOX_T: draw( static_cast( aItem ), aLayer ); @@ -516,10 +511,6 @@ float SCH_PAINTER::getTextThickness( const EDA_ITEM* aItem ) const pen = static_cast( aItem )->GetEffectiveTextPenWidth( pen ); break; - case LIB_TEXT_T: - pen = std::max( pen, static_cast( aItem )->GetEffectiveTextPenWidth() ); - break; - case LIB_TEXTBOX_T: pen = std::max( pen, static_cast( aItem )->GetEffectiveTextPenWidth() ); break; @@ -988,112 +979,6 @@ void SCH_PAINTER::draw( const LIB_SHAPE* aShape, int aLayer, bool aDimmed ) } -void SCH_PAINTER::draw( const LIB_TEXT* aText, int aLayer, bool aDimmed ) -{ - if( !isUnitAndConversionShown( aText ) ) - return; - - if( aText->IsPrivate() && !m_schSettings.m_IsSymbolEditor ) - return; - - bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; - - if( drawingShadows && !( aText->IsBrightened() || aText->IsSelected() ) ) - return; - - COLOR4D color = getRenderColor( aText, aLayer, drawingShadows, aDimmed ); - - if( !aText->IsVisible() ) - { - if( !m_schematic || eeconfig()->m_Appearance.show_hidden_fields ) - color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows, aDimmed ); - else - return; - } - - BOX2I bBox = aText->GetBoundingBox(); - - m_gal->SetFillColor( color ); - m_gal->SetStrokeColor( color ); - - if( drawingShadows && getFont( aText )->IsOutline() ) - { - bBox.Inflate( KiROUND( getTextThickness( aText ) * 2 ) ); - - m_gal->SetIsStroke( false ); - m_gal->SetIsFill( true ); - m_gal->DrawRectangle( bBox.GetPosition(), bBox.GetEnd() ); - } - else - { - wxString shownText( aText->GetShownText( true ) ); - VECTOR2D pos = bBox.Centre(); - TEXT_ATTRIBUTES attrs = aText->GetAttributes(); - - attrs.m_StrokeWidth = KiROUND( getTextThickness( aText ) ); - - // Due to the fact a shadow text can be drawn left or right aligned, - // it needs an offset = shadowWidth/2 to be drawn at the same place as normal text - // texts drawn as GR_TEXT_H_ALIGN_CENTER do not need a specific offset. - // this offset is shadowWidth/2 but for some reason we need to slightly modify this offset - // for a better look (better alignment of shadow shape), for KiCad font only - double shadowOffset = 0.0; - - if( drawingShadows ) - { - double shadowWidth = getShadowWidth( !aText->IsSelected() ); - attrs.m_StrokeWidth += getShadowWidth( !aText->IsSelected() ); - - const double adjust = 1.2f; // Value chosen after tests - shadowOffset = shadowWidth/2.0f * adjust; - } - - if( attrs.m_Angle == ANGLE_VERTICAL ) - { - switch( attrs.m_Halign ) - { - case GR_TEXT_H_ALIGN_LEFT: - pos.y = bBox.GetBottom() + shadowOffset; - break; - case GR_TEXT_H_ALIGN_CENTER: - pos.y = ( bBox.GetTop() + bBox.GetBottom() ) / 2.0; - break; - case GR_TEXT_H_ALIGN_RIGHT: - pos.y = bBox.GetTop() - shadowOffset; - break; - case GR_TEXT_H_ALIGN_INDETERMINATE: - wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) ); - break; - } - } - else - { - switch( attrs.m_Halign ) - { - case GR_TEXT_H_ALIGN_LEFT: - pos.x = bBox.GetLeft() - shadowOffset; - break; - case GR_TEXT_H_ALIGN_CENTER: - pos.x = ( bBox.GetLeft() + bBox.GetRight() ) / 2.0; - break; - case GR_TEXT_H_ALIGN_RIGHT: - pos.x = bBox.GetRight() + shadowOffset; - break; - case GR_TEXT_H_ALIGN_INDETERMINATE: - wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) ); - break; - } - } - - // Because the text vertical position is the bounding box center, the text is drawn as - // vertically centered. - attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER; - - strokeText( shownText, pos, attrs, aText->GetFontMetrics() ); - } -} - - void SCH_PAINTER::draw( const LIB_TEXTBOX* aTextBox, int aLayer, bool aDimmed ) { if( !isUnitAndConversionShown( aTextBox ) ) @@ -2049,8 +1934,14 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) } -void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer ) +void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer, bool aDimmed ) { + if( !isUnitAndConversionShown( aText ) ) + return; + + if( aText->IsPrivate() && !m_schSettings.m_IsSymbolEditor ) + return; + bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; if( m_schSettings.IsPrinting() && drawingShadows ) @@ -2069,7 +1960,7 @@ void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer ) default: aLayer = LAYER_NOTES; break; } - COLOR4D color = getRenderColor( aText, aLayer, drawingShadows ); + COLOR4D color = getRenderColor( aText, aLayer, drawingShadows, aDimmed ); if( m_schematic ) { @@ -2101,7 +1992,80 @@ void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer ) attrs.m_Angle = aText->GetDrawRotation(); attrs.m_StrokeWidth = KiROUND( getTextThickness( aText ) ); - if( drawingShadows && !font->IsOutline() ) + if( drawingShadows && font->IsOutline() ) + { + BOX2I bBox = aText->GetBoundingBox(); + bBox.Inflate( KiROUND( getTextThickness( aText ) * 2 ) ); + bBox.RevertYAxis(); + + m_gal->SetIsStroke( false ); + m_gal->SetIsFill( true ); + m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) ); + } + else if( aText->GetLayer() == LAYER_DEVICE ) + { + BOX2I bBox = aText->GetBoundingBox(); + VECTOR2D pos = bBox.Centre(); + + // Due to the fact a shadow text can be drawn left or right aligned, it needs to be + // offset by shadowWidth/2 to be drawn at the same place as normal text. + // For some reason we need to slightly modify this offset for a better look (better + // alignment of shadow shape), for KiCad font only. + double shadowOffset = 0.0; + + if( drawingShadows ) + { + double shadowWidth = getShadowWidth( !aText->IsSelected() ); + attrs.m_StrokeWidth += getShadowWidth( !aText->IsSelected() ); + + const double adjust = 1.2f; // Value chosen after tests + shadowOffset = shadowWidth/2.0f * adjust; + } + + if( attrs.m_Angle == ANGLE_VERTICAL ) + { + switch( attrs.m_Halign ) + { + case GR_TEXT_H_ALIGN_LEFT: + pos.y = bBox.GetBottom() + shadowOffset; + break; + case GR_TEXT_H_ALIGN_CENTER: + pos.y = ( bBox.GetTop() + bBox.GetBottom() ) / 2.0; + break; + case GR_TEXT_H_ALIGN_RIGHT: + pos.y = bBox.GetTop() - shadowOffset; + break; + case GR_TEXT_H_ALIGN_INDETERMINATE: + wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) ); + break; + } + } + else + { + switch( attrs.m_Halign ) + { + case GR_TEXT_H_ALIGN_LEFT: + pos.x = bBox.GetLeft() - shadowOffset; + break; + case GR_TEXT_H_ALIGN_CENTER: + pos.x = ( bBox.GetLeft() + bBox.GetRight() ) / 2.0; + break; + case GR_TEXT_H_ALIGN_RIGHT: + pos.x = bBox.GetRight() + shadowOffset; + break; + case GR_TEXT_H_ALIGN_INDETERMINATE: + wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) ); + break; + } + } + + // Because the text vertical position is the bounding box center, the text is drawn as + // vertically centered. + attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER; + + strokeText( shownText, pos, attrs, aText->GetFontMetrics() ); + } + else if( drawingShadows ) { m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); @@ -2123,17 +2087,6 @@ void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer ) text_offset.y += fudge; strokeText( shownText, aText->GetDrawPos() + text_offset, attrs, aText->GetFontMetrics() ); - - } - else if( drawingShadows ) - { - BOX2I bBox = aText->GetBoundingBox(); - bBox.Inflate( KiROUND( getTextThickness( aText ) * 2 ) ); - bBox.RevertYAxis(); - - m_gal->SetIsStroke( false ); - m_gal->SetIsFill( true ); - m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) ); } else { @@ -2554,9 +2507,9 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer ) tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED, tempItem.Move( mapCoords( aSymbol->GetPosition() ) ); - if( tempItem.Type() == LIB_TEXT_T ) + if( tempItem.Type() == SCH_TEXT_T ) { - LIB_TEXT* textItem = static_cast( &tempItem ); + SCH_TEXT* textItem = static_cast( &tempItem ); if( textItem->HasTextVars() ) textItem->SetText( expandLibItemTextVars( textItem->GetText(), aSymbol ) ); @@ -2850,7 +2803,7 @@ void SCH_PAINTER::draw( const SCH_GLOBALLABEL* aLabel, int aLayer ) m_gal->DrawPolyline( pts2 ); } - draw( static_cast( aLabel ), aLayer ); + draw( static_cast( aLabel ), aLayer, false ); } @@ -2889,7 +2842,7 @@ void SCH_PAINTER::draw( const SCH_LABEL* aLabel, int aLayer ) return; } - draw( static_cast( aLabel ), aLayer ); + draw( static_cast( aLabel ), aLayer, false ); } @@ -2954,7 +2907,7 @@ void SCH_PAINTER::draw( const SCH_HIERLABEL* aLabel, int aLayer ) m_gal->SetStrokeColor( color ); m_gal->DrawPolyline( pts2 ); - draw( static_cast( aLabel ), aLayer ); + draw( static_cast( aLabel ), aLayer, false ); } @@ -3050,7 +3003,7 @@ void SCH_PAINTER::draw( const SCH_SHEET* aSheet, int aLayer ) if( aLayer == LAYER_SHEET_BACKGROUND ) { - // Do not fill the shape in B&W print mode, to avoid to visible items + // Do not fill the shape in B&W print mode, to avoid to visible items // inside the shape if( !m_schSettings.PrintBlackAndWhiteReq() ) { diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 84f631d063..7852ba5388 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -94,7 +94,7 @@ private: void draw( const SCH_FIELD* aField, int aLayer, bool aDimmed ); void draw( const SCH_SHAPE* aShape, int aLayer ); void draw( const SCH_TEXTBOX* aTextBox, int aLayer ); - void draw( const SCH_TEXT* aText, int aLayer ); + void draw( const SCH_TEXT* aText, int aLayer, bool aDimmed ); void draw( const SCH_TABLE* aTable, int aLayer ); void draw( const SCH_LABEL* aText, int aLayer ); void draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer ); diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 8a45f5d10f..c0580cff15 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -86,10 +85,9 @@ static LIB_SYMBOL* dummy() square->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) ); square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) ); - LIB_TEXT* text = new LIB_TEXT( symbol ); + SCH_TEXT* text = new SCH_TEXT( { 0, 0 }, wxT( "??"), LAYER_DEVICE ); text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) ); - text->SetText( wxString( wxT( "??" ) ) ); symbol->AddDrawItem( square ); symbol->AddDrawItem( text ); diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 3e14f3b72b..418bf7c684 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -46,13 +46,14 @@ #include -SCH_TEXT::SCH_TEXT( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) : +SCH_TEXT::SCH_TEXT( const VECTOR2I& aPos, const wxString& aText, SCH_LAYER_ID aLayer, + KICAD_T aType ) : SCH_ITEM( nullptr, aType ), - EDA_TEXT( schIUScale, text ) + EDA_TEXT( schIUScale, aText ) { - m_layer = LAYER_NOTES; + m_layer = aLayer; - SetTextPos( pos ); + SetTextPos( aPos ); SetMultilineAllowed( true ); m_excludedFromSim = false; @@ -74,33 +75,168 @@ VECTOR2I SCH_TEXT::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) co } +void SCH_TEXT::NormalizeJustification( bool inverse ) +{ + if( GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER && GetVertJustify() == GR_TEXT_V_ALIGN_CENTER ) + return; + + VECTOR2I delta( 0, 0 ); + BOX2I bbox = GetTextBox(); + + if( GetTextAngle().IsHorizontal() ) + { + if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) + delta.x = bbox.GetWidth() / 2; + else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + delta.x = - bbox.GetWidth() / 2; + + if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) + delta.y = - bbox.GetHeight() / 2; + else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) + delta.y = bbox.GetHeight() / 2; + } + else + { + if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) + delta.y = bbox.GetWidth() / 2; + else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + delta.y = - bbox.GetWidth() / 2; + + if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) + delta.x = + bbox.GetHeight() / 2; + else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) + delta.x = - bbox.GetHeight() / 2; + } + + if( inverse ) + SetTextPos( GetTextPos() - delta ); + else + SetTextPos( GetTextPos() + delta ); +} + + void SCH_TEXT::MirrorHorizontally( int aCenter ) { - if( GetTextAngle() == ANGLE_HORIZONTAL ) - FlipHJustify(); + if( m_layer == LAYER_DEVICE ) + { + NormalizeJustification( false ); + int x = GetTextPos().x; - SetTextX( MIRRORVAL( GetTextPos().x, aCenter ) ); + x -= aCenter; + x *= -1; + x += aCenter; + + if( GetTextAngle().IsHorizontal() ) + { + if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) + SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + } + else + { + if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) + SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) + SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + } + + SetTextX( x ); + NormalizeJustification( true ); + } + else + { + if( GetTextAngle() == ANGLE_HORIZONTAL ) + FlipHJustify(); + + SetTextX( MIRRORVAL( GetTextPos().x, aCenter ) ); + } } void SCH_TEXT::MirrorVertically( int aCenter ) { - if( GetTextAngle() == ANGLE_VERTICAL ) - FlipHJustify(); + if( m_layer == LAYER_DEVICE ) + { + NormalizeJustification( false ); + int y = GetTextPos().y; - SetTextY( MIRRORVAL( GetTextPos().y, aCenter ) ); + y -= aCenter; + y *= -1; + y += aCenter; + + if( GetTextAngle().IsHorizontal() ) + { + if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) + SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) + SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + } + else + { + if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) + SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + } + + SetTextY( y ); + NormalizeJustification( true ); + } + else + { + if( GetTextAngle() == ANGLE_VERTICAL ) + FlipHJustify(); + + SetTextY( MIRRORVAL( GetTextPos().y, aCenter ) ); + } } void SCH_TEXT::Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) { - VECTOR2I pt = GetTextPos(); - RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 ); - VECTOR2I offset = pt - GetTextPos(); + if( m_layer == LAYER_DEVICE ) + { + NormalizeJustification( false ); + EDA_ANGLE rot_angle = aRotateCCW ? -ANGLE_90 : ANGLE_90; - Rotate90( false ); + VECTOR2I pt = GetTextPos(); + RotatePoint( pt, aCenter, rot_angle ); + SetTextPos( pt ); - SetTextPos( GetTextPos() + offset ); + if( GetTextAngle().IsHorizontal() ) + { + SetTextAngle( ANGLE_VERTICAL ); + } + else + { + // 180° rotation is a mirror + + if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) + SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + + if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) + SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); + else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) + SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + + SetTextAngle( ANGLE_0 ); + } + + NormalizeJustification( true ); + } + else + { + VECTOR2I pt = GetTextPos(); + RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 ); + VECTOR2I offset = pt - GetTextPos(); + + Rotate90( false ); + + SetTextPos( GetTextPos() + offset ); + } } @@ -197,53 +333,133 @@ KIFONT::FONT* SCH_TEXT::getDrawFont() const void SCH_TEXT::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) { - COLOR4D color = GetTextColor(); - bool blackAndWhiteMode = GetGRForceBlackPenState(); - VECTOR2I text_offset = aOffset + GetSchematicTextOffset( aSettings ); + COLOR4D color = GetTextColor(); + COLOR4D bg = aSettings->GetBackgroundColor(); + bool blackAndWhiteMode = GetGRForceBlackPenState(); if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED ) color = aSettings->GetLayerColor( m_layer ); + if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() ) + bg = COLOR4D::WHITE; + + if( !IsVisible() ) + bg = aSettings->GetLayerColor( LAYER_HIDDEN ); + + if( aDimmed ) + { + color.Desaturate( ); + color = color.Mix( bg, 0.5f ); + } + KIFONT::FONT* font = GetFont(); if( !font ) font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() ); - // Adjust text drawn in an outline font to more closely mimic the positioning of - // SCH_FIELD text. - if( font->IsOutline() ) + if( m_layer == LAYER_DEVICE ) { - BOX2I firstLineBBox = GetTextBox( 0 ); - int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y; - int adjust = KiROUND( sizeDiff * 0.4 ); - VECTOR2I adjust_offset( 0, - adjust ); + wxDC* DC = aSettings->GetPrintDC(); + int penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetDefaultPenWidth() ); - RotatePoint( adjust_offset, GetDrawRotation() ); - text_offset += adjust_offset; + // Calculate the text orientation, according to the symbol orientation/mirror (needed when + // draw text in schematic) + EDA_ANGLE orient = GetTextAngle(); + + if( aSettings->m_Transform.y1 ) // Rotate symbol 90 degrees. + { + if( orient == ANGLE_HORIZONTAL ) + orient = ANGLE_VERTICAL; + else + orient = ANGLE_HORIZONTAL; + } + + /* + * Calculate the text justification, according to the symbol orientation/mirror. + * This is a bit complicated due to cumulative calculations: + * - numerous cases (mirrored or not, rotation) + * - the GRText function will also recalculate H and V justifications according to the text + * orientation. + * - When a symbol is mirrored, the text is not mirrored and justifications are complicated + * to calculate so the more easily way is to use no justifications (centered text) and + * use GetBoundingBox to know the text coordinate considered as centered + */ + BOX2I bBox = GetBoundingBox(); + + // convert coordinates from draw Y axis to symbol_editor Y axis: + bBox.RevertYAxis(); + VECTOR2I txtpos = bBox.Centre(); + + // Calculate pos according to mirror/rotation. + txtpos = aSettings->m_Transform.TransformCoordinate( txtpos ) + aOffset; + + GRPrintText( DC, txtpos, color, GetShownText( true ), orient, GetTextSize(), + GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), + IsBold(), font, GetFontMetrics() ); } + else + { + VECTOR2I text_offset = aOffset + GetSchematicTextOffset( aSettings ); - EDA_TEXT::Print( aSettings, text_offset, color ); + // Adjust text drawn in an outline font to more closely mimic the positioning of + // SCH_FIELD text. + if( font->IsOutline() ) + { + BOX2I firstLineBBox = GetTextBox( 0 ); + int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y; + int adjust = KiROUND( sizeDiff * 0.4 ); + VECTOR2I adjust_offset( 0, - adjust ); + + RotatePoint( adjust_offset, GetDrawRotation() ); + text_offset += adjust_offset; + } + + EDA_TEXT::Print( aSettings, text_offset, color ); + } } const BOX2I SCH_TEXT::GetBoundingBox() const { - BOX2I bbox = GetTextBox(); - - if( !GetTextAngle().IsZero() ) // Rotate bbox. + if( m_layer == LAYER_DEVICE ) // TODO: remove upside-down coordinate system in symbol editor { - VECTOR2I pos = bbox.GetOrigin(); + BOX2I bbox = GetTextBox( -1, true ); + bbox.RevertYAxis(); + + // We are using now a bottom to top Y axis. + VECTOR2I orig = bbox.GetOrigin(); VECTOR2I end = bbox.GetEnd(); - RotatePoint( pos, GetTextPos(), GetTextAngle() ); - RotatePoint( end, GetTextPos(), GetTextAngle() ); + RotatePoint( orig, GetTextPos(), -GetTextAngle() ); + RotatePoint( end, GetTextPos(), -GetTextAngle() ); - bbox.SetOrigin( pos ); + bbox.SetOrigin( orig ); bbox.SetEnd( end ); - } - bbox.Normalize(); - return bbox; + // We are using now a top to bottom Y axis: + bbox.RevertYAxis(); + + return bbox; + } + else + { + BOX2I bbox = GetTextBox(); + + if( !GetTextAngle().IsZero() ) // Rotate bbox. + { + VECTOR2I pos = bbox.GetOrigin(); + VECTOR2I end = bbox.GetEnd(); + + RotatePoint( pos, GetTextPos(), GetTextAngle() ); + RotatePoint( end, GetTextPos(), GetTextAngle() ); + + bbox.SetOrigin( pos ); + bbox.SetEnd( end ); + } + + bbox.Normalize(); + return bbox; + } } @@ -309,28 +525,76 @@ BITMAPS SCH_TEXT::GetMenuImage() const bool SCH_TEXT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const { - BOX2I bBox = GetBoundingBox(); - bBox.Inflate( aAccuracy ); - return bBox.Contains( aPosition ); + if( m_layer == LAYER_DEVICE ) // TODO: remove upside-down coordinate system in symbol editor + { + EDA_TEXT tmp_text( *this ); + tmp_text.SetTextPos( DefaultTransform.TransformCoordinate( GetTextPos() ) ); + + /* The text orientation may need to be flipped if the + * transformation matrix causes xy axes to be flipped. + * this simple algo works only for schematic matrix (rot 90 or/and mirror) + */ + bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL ); + + tmp_text.SetTextAngle( t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL ); + return tmp_text.TextHitTest( aPosition, aAccuracy ); + } + else + { + BOX2I bBox = GetBoundingBox(); + bBox.Inflate( aAccuracy ); + return bBox.Contains( aPosition ); + } } bool SCH_TEXT::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const { - BOX2I bBox = GetBoundingBox(); - bBox.Inflate( aAccuracy ); + if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) ) + return false; - if( aContained ) - return aRect.Contains( bBox ); + BOX2I rect = aRect; - return aRect.Intersects( bBox ); + rect.Inflate( aAccuracy ); + + if( m_layer == LAYER_DEVICE ) // TODO: remove upside-down coordinate system in symbol editor + { + BOX2I bBox = GetTextBox(); + bBox.RevertYAxis(); + + if( aContained ) + return rect.Contains( bBox ); + + return rect.Intersects( bBox, GetTextAngle() ); + } + else + { + BOX2I bBox = GetBoundingBox(); + + if( aContained ) + return aRect.Contains( bBox ); + + return aRect.Intersects( bBox ); + } +} + + +void SCH_TEXT::BeginEdit( const VECTOR2I& aPosition ) +{ + SetTextPos( aPosition ); +} + + +void SCH_TEXT::CalcEdit( const VECTOR2I& aPosition ) +{ + SetTextPos( aPosition ); } void SCH_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const { aCount = 2; - aLayers[0] = m_layer; + aLayers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : m_layer; aLayers[1] = LAYER_SELECTION_SHADOWS; } @@ -338,61 +602,114 @@ void SCH_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) { - if( aBackground ) + if( aBackground || IsPrivate() ) return; - SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet(); - RENDER_SETTINGS* settings = aPlotter->RenderSettings(); - SCH_CONNECTION* connection = Connection(); - int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer; - COLOR4D color = GetTextColor(); - int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() ); - VECTOR2I text_offset = GetSchematicTextOffset( aPlotter->RenderSettings() ); + SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); + COLOR4D color = GetTextColor(); + COLOR4D bg = renderSettings->GetBackgroundColor(); if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) - color = settings->GetLayerColor( layer ); + { + SCH_CONNECTION* connection = Connection(); - penWidth = std::max( penWidth, settings->GetMinPenWidth() ); + if( connection && connection->IsBus() ) + color = renderSettings->GetLayerColor( LAYER_BUS ); + else + color = renderSettings->GetLayerColor( m_layer ); + } + + if( !IsVisible() ) + bg = renderSettings->GetLayerColor( LAYER_HIDDEN ); + else if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() ) + bg = COLOR4D::WHITE; + + if( aDimmed ) + { + color.Desaturate( ); + color = color.Mix( bg, 0.5f ); + } + + int penWidth = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() ); + penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() ); aPlotter->SetCurrentLineWidth( penWidth ); KIFONT::FONT* font = GetFont(); if( !font ) - font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() ); - - // Adjust text drawn in an outline font to more closely mimic the positioning of - // SCH_FIELD text. - if( font->IsOutline() ) - { - BOX2I firstLineBBox = GetTextBox( 0 ); - int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y; - int adjust = KiROUND( sizeDiff * 0.4 ); - VECTOR2I adjust_offset( 0, - adjust ); - - RotatePoint( adjust_offset, GetDrawRotation() ); - text_offset += adjust_offset; - } - - std::vector positions; - wxArrayString strings_list; - wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' ); - positions.reserve( strings_list.Count() ); - - GetLinePositions( positions, (int) strings_list.Count() ); + font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() ); TEXT_ATTRIBUTES attrs = GetAttributes(); attrs.m_StrokeWidth = penWidth; - attrs.m_Multiline = false; - for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) + if( m_layer == LAYER_DEVICE ) { - VECTOR2I textpos = positions[ii] + text_offset; - wxString& txt = strings_list.Item( ii ); - aPlotter->PlotText( textpos, color, txt, attrs, font, GetFontMetrics() ); - } + BOX2I bBox = GetBoundingBox(); + // convert coordinates from draw Y axis to symbol_editor Y axis + bBox.RevertYAxis(); - if( HasHyperlink() ) - aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() ); + /* + * Calculate the text justification, according to the symbol orientation/mirror. This is + * a bit complicated due to cumulative calculations: + * - numerous cases (mirrored or not, rotation) + * - the plotter's Text() function will also recalculate H and V justifications according + * to the text orientation + * - when a symbol is mirrored the text is not, and justifications become a nightmare + * + * So the easier way is to use no justifications (centered text) and use GetBoundingBox to + * know the text coordinate considered as centered. + */ + VECTOR2I txtpos = bBox.Centre(); + attrs.m_Halign = GR_TEXT_H_ALIGN_CENTER; + attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER; + + // The text orientation may need to be flipped if the transformation matrix causes xy + // axes to be flipped. + if( ( renderSettings->m_Transform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL ) ) + attrs.m_Angle = ANGLE_HORIZONTAL; + else + attrs.m_Angle = ANGLE_VERTICAL; + + aPlotter->PlotText( renderSettings->TransformCoordinate( txtpos ) + aOffset, color, + GetText(), attrs, font, GetFontMetrics() ); + } + else + { + SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet(); + VECTOR2I text_offset = GetSchematicTextOffset( aPlotter->RenderSettings() ); + + // Adjust text drawn in an outline font to more closely mimic the positioning of + // SCH_FIELD text. + if( font->IsOutline() ) + { + BOX2I firstLineBBox = GetTextBox( 0 ); + int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y; + int adjust = KiROUND( sizeDiff * 0.4 ); + VECTOR2I adjust_offset( 0, - adjust ); + + RotatePoint( adjust_offset, GetDrawRotation() ); + text_offset += adjust_offset; + } + + std::vector positions; + wxArrayString strings_list; + wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' ); + positions.reserve( strings_list.Count() ); + + GetLinePositions( positions, (int) strings_list.Count() ); + + attrs.m_Multiline = false; + + for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) + { + VECTOR2I textpos = positions[ii] + text_offset; + wxString& txt = strings_list.Item( ii ); + aPlotter->PlotText( textpos, color, txt, attrs, font, GetFontMetrics() ); + } + + if( HasHyperlink() ) + aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() ); + } } @@ -401,7 +718,7 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector( &aOther ); - double retval = 1.0; + double retval = SimilarityBase( aOther ); if( GetLayer() != other->GetLayer() ) retval *= 0.9; @@ -463,6 +800,38 @@ double SCH_TEXT::Similarity( const SCH_ITEM& aOther ) const } +int SCH_TEXT::compare( const SCH_ITEM& aOther, int aCompareFlags ) const +{ + wxASSERT( aOther.Type() == SCH_TEXT_T ); + + int retv = SCH_ITEM::compare( aOther, aCompareFlags ); + + if( retv ) + return retv; + + const SCH_TEXT& tmp = static_cast( aOther ); + + int result = GetText().CmpNoCase( tmp.GetText() ); + + if( result != 0 ) + return result; + + if( GetTextPos().x != tmp.GetTextPos().x ) + return GetTextPos().x - tmp.GetTextPos().x; + + if( GetTextPos().y != tmp.GetTextPos().y ) + return GetTextPos().y - tmp.GetTextPos().y; + + if( GetTextWidth() != tmp.GetTextWidth() ) + return GetTextWidth() - tmp.GetTextWidth(); + + if( GetTextHeight() != tmp.GetTextHeight() ) + return GetTextHeight() - tmp.GetTextHeight(); + + return 0; +} + + #if defined(DEBUG) void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index 29a34fe8ed..ec0f9261e6 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 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,6 @@ #include #include -#include #include // for CONNECTION_TYPE #include @@ -39,22 +38,27 @@ class SCH_TEXT : public SCH_ITEM, public EDA_TEXT { public: SCH_TEXT( const VECTOR2I& aPos = { 0, 0 }, const wxString& aText = wxEmptyString, - KICAD_T aType = SCH_TEXT_T ); + SCH_LAYER_ID aLayer = LAYER_NOTES, KICAD_T aType = SCH_TEXT_T ); SCH_TEXT( const SCH_TEXT& aText ); - ~SCH_TEXT() { } + ~SCH_TEXT() override { } - static inline bool ClassOf( const EDA_ITEM* aItem ) + static bool ClassOf( const EDA_ITEM* aItem ) { return aItem && SCH_TEXT_T == aItem->Type(); } - virtual wxString GetClass() const override + wxString GetClass() const override { return wxT( "SCH_TEXT" ); } + wxString GetFriendlyName() const override + { + return _( "Text" ); + } + virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText, int aDepth = 0 ) const; @@ -104,6 +108,8 @@ public: EDA_TEXT::Offset( aMoveVector ); } + void NormalizeJustification( bool inverse ); + void MirrorHorizontally( int aCenter ) override; void MirrorVertically( int aCenter ) override; void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override; @@ -111,6 +117,9 @@ public: virtual void Rotate90( bool aClockwise ); virtual void MirrorSpinStyle( bool aLeftRight ); + void BeginEdit( const VECTOR2I& aStartPoint ) override; + void CalcEdit( const VECTOR2I& aPosition ) override; + bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override { return SCH_ITEM::Matches( GetText(), aSearchData ); @@ -121,7 +130,7 @@ public: return EDA_TEXT::Replace( aSearchData ); } - virtual bool IsReplaceable() const override { return true; } + bool IsReplaceable() const override { return true; } void ViewGetLayers( int aLayers[], int& aCount ) const override; @@ -148,9 +157,9 @@ public: void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - virtual double Similarity( const SCH_ITEM& aItem ) const override; + double Similarity( const SCH_ITEM& aItem ) const override; - virtual bool operator==( const SCH_ITEM& aItem ) const override; + bool operator==( const SCH_ITEM& aItem ) const override; #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override; @@ -163,6 +172,18 @@ protected: const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); } + /** + * @copydoc SCH_ITEM::compare() + * + * The text specific sort order is as follows: + * - Text string, case insensitive compare. + * - Text horizontal (X) position. + * - Text vertical (Y) position. + * - Text width. + * - Text height. + */ + int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override; + protected: bool m_excludedFromSim; }; diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index d4100a2c7e..c6681198a9 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index 28972a4b1b..02111f7e3c 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -36,7 +36,6 @@ class SCH_EDIT_FRAME; class SYMBOL_LIB_TABLE; class LIB_SYMBOL; -class DIALOG_LIB_TEXT_PROPERTIES; class SYMBOL_TREE_PANE; class LIB_TREE_NODE; class LIB_ID; diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 37437682d4..1b9b0cf7a2 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -354,7 +354,7 @@ TOOL_ACTION EE_ACTIONS::placeSymbolText( TOOL_ACTION_ARGS() .Tooltip( _( "Add a text item" ) ) .Icon( BITMAPS::text ) .Flags( AF_ACTIVATE ) - .Parameter( LIB_TEXT_T ) ); + .Parameter( SCH_TEXT_T ) ); TOOL_ACTION EE_ACTIONS::drawSymbolTextBox( TOOL_ACTION_ARGS() .Name( "eeschema.SymbolDrawing.drawSymbolTextBox" ) diff --git a/eeschema/tools/ee_grid_helper.cpp b/eeschema/tools/ee_grid_helper.cpp index 7fede8ae41..57213d9cd2 100644 --- a/eeschema/tools/ee_grid_helper.cpp +++ b/eeschema/tools/ee_grid_helper.cpp @@ -377,7 +377,6 @@ GRID_HELPER_GRIDS EE_GRID_HELPER::GetItemGrid( const EDA_ITEM* aItem ) const return GRID_CONNECTABLE; case SCH_FIELD_T: - case LIB_TEXT_T: case SCH_TEXT_T: return GRID_TEXT; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 23ddb29262..136fc9d417 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -571,7 +571,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) else { m_selection = RequestSelection( { LIB_SHAPE_T, - LIB_TEXT_T, + SCH_TEXT_T, LIB_TEXTBOX_T, LIB_PIN_T, SCH_FIELD_T } ); @@ -1647,7 +1647,6 @@ bool EE_SELECTION_TOOL::itemPassesFilter( EDA_ITEM* aItem ) case SCH_TABLE_T: case SCH_TABLECELL_T: case SCH_FIELD_T: - case LIB_TEXT_T: case LIB_TEXTBOX_T: if( !m_filter.text ) return false; @@ -2480,11 +2479,11 @@ bool EE_SELECTION_TOOL::Selectable( const EDA_ITEM* aItem, const VECTOR2I* aPos, case LIB_SYMBOL_T: // In symbol_editor we do not want to select the symbol itself. return false; - case SCH_FIELD_T: // SCH_FIELD object can always be edited. + case SCH_FIELD_T: // SCH_FIELD objects are not unit/body-style-specific. break; case LIB_SHAPE_T: - case LIB_TEXT_T: + case SCH_TEXT_T: case LIB_PIN_T: if( symEditFrame ) { diff --git a/eeschema/tools/symbol_editor_drawing_tools.cpp b/eeschema/tools/symbol_editor_drawing_tools.cpp index 9ac286a570..64502a09f4 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.cpp +++ b/eeschema/tools/symbol_editor_drawing_tools.cpp @@ -30,15 +30,13 @@ #include #include #include -#include -#include +#include #include #include #include #include #include #include -#include #include #include #include "dialog_lib_textbox_properties.h" @@ -217,9 +215,12 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) g_lastPinWeakPtr = item; break; } - case LIB_TEXT_T: + case SCH_TEXT_T: { - LIB_TEXT* text = new LIB_TEXT( symbol ); + SCH_TEXT* text = new SCH_TEXT( VECTOR2I( cursorPos.x, -cursorPos.y ), + wxEmptyString, LAYER_DEVICE ); + + text->SetParent( symbol ); if( m_drawSpecificUnit ) text->SetUnit( m_frame->GetUnit() ); @@ -227,12 +228,11 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) if( m_drawSpecificBodyStyle ) text->SetBodyStyle( m_frame->GetBodyStyle() ); - text->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) ); text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ), schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) ); text->SetTextAngle( m_lastTextAngle ); - DIALOG_LIB_TEXT_PROPERTIES dlg( m_frame, text ); + DIALOG_TEXT_PROPERTIES dlg( m_frame, text ); if( dlg.ShowModal() != wxID_OK || NoPrintableChars( text->GetText() ) ) delete text; @@ -283,13 +283,13 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) switch( item->Type() ) { case LIB_PIN_T: - pinTool->PlacePin( (LIB_PIN*) item ); + pinTool->PlacePin( static_cast( item ) ); item->ClearEditFlags(); commit.Push( _( "Add Pin" ) ); break; - case LIB_TEXT_T: - symbol->AddDrawItem( (LIB_TEXT*) item ); + case SCH_TEXT_T: + symbol->AddDrawItem( static_cast( item ) ); item->ClearEditFlags(); commit.Push( _( "Add Text" ) ); break; diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index 750a41ad50..0842c2dcb8 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -32,14 +32,13 @@ #include #include #include -#include +#include #include #include #include #include #include #include -#include #include #include "symbol_editor_edit_tool.h" #include // for wxTextEntryDialog @@ -274,7 +273,7 @@ static std::vector nonFields = { LIB_SYMBOL_T, LIB_SHAPE_T, - LIB_TEXT_T, + SCH_TEXT_T, LIB_TEXTBOX_T, LIB_PIN_T }; @@ -462,7 +461,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) editShapeProperties( static_cast( item ) ); break; - case LIB_TEXT_T: + case SCH_TEXT_T: editTextProperties( item ); break; @@ -510,10 +509,10 @@ void SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties( LIB_SHAPE* aShape ) void SYMBOL_EDITOR_EDIT_TOOL::editTextProperties( SCH_ITEM* aItem ) { - if ( aItem->Type() != LIB_TEXT_T ) + if ( aItem->Type() != SCH_TEXT_T ) return; - DIALOG_LIB_TEXT_PROPERTIES dlg( m_frame, static_cast( aItem ) ); + DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast( aItem ) ); if( dlg.ShowModal() != wxID_OK ) return; @@ -811,8 +810,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent ) { // If it's not a symbol then paste as text newPart = new LIB_SYMBOL( "dummy_part" ); - LIB_TEXT* newText = new LIB_TEXT( newPart ); - newText->SetText( clipboardData ); + SCH_TEXT* newText = new SCH_TEXT( { 0, 0 }, clipboardData, LAYER_DEVICE ); newPart->AddDrawItem( newText ); } diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index 8da702dff0..d1f3037584 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -201,7 +201,6 @@ enum KICAD_T */ LIB_SYMBOL_T, LIB_SHAPE_T, - LIB_TEXT_T, LIB_TEXTBOX_T, LIB_PIN_T, @@ -413,7 +412,6 @@ constexpr bool IsEeschemaType( const KICAD_T aType ) case LIB_SYMBOL_T: case LIB_SHAPE_T: - case LIB_TEXT_T: case LIB_TEXTBOX_T: case LIB_PIN_T: return true; diff --git a/qa/tests/eeschema/test_ee_item.cpp b/qa/tests/eeschema/test_ee_item.cpp index 44ac2c9e34..94b39400fa 100644 --- a/qa/tests/eeschema/test_ee_item.cpp +++ b/qa/tests/eeschema/test_ee_item.cpp @@ -45,7 +45,6 @@ #include #include -#include #include #include @@ -117,7 +116,6 @@ public: case SCH_SHEET_T: return new SCH_SHEET(); case LIB_SHAPE_T: return new LIB_SHAPE( &m_symbol, SHAPE_T::ARC ); - case LIB_TEXT_T: return new LIB_TEXT( &m_symbol ); case LIB_TEXTBOX_T: return new LIB_TEXTBOX( &m_symbol, 0, FILL_T::NO_FILL, "test" ); case LIB_PIN_T: return new LIB_PIN( &m_symbol );