Collapse LIB_TEXT into SCH_TEXT.

This commit is contained in:
Jeff Young 2024-04-14 19:04:53 +01:00
parent 5d7e96841b
commit 3efe504dcc
48 changed files with 1075 additions and 4049 deletions

View File

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

View File

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

View File

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

View File

@ -21,9 +21,7 @@
#include <lib_pin.h>
#include <lib_shape.h>
#include <lib_symbol.h>
#include <lib_text.h>
#include <lib_textbox.h>
#include <sch_bitmap.h>
#include <sch_bus_entry.h>
#include <sch_field.h>
@ -31,7 +29,6 @@
#include <sch_label.h>
#include <sch_line.h>
#include <sch_no_connect.h>
#include <sch_pin.h>
#include <sch_shape.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
@ -95,7 +92,6 @@ std::unique_ptr<EDA_ITEM> 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<LIB_SHAPE>( parentLibSymbol );
case LIB_TEXT_T: return std::make_unique<LIB_TEXT>( parentLibSymbol );
case LIB_TEXTBOX_T: return std::make_unique<LIB_TEXTBOX>( parentLibSymbol );
case LIB_PIN_T: return std::make_unique<LIB_PIN>( parentLibSymbol );

View File

@ -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 <widgets/bitmap_button.h>
#include <widgets/font_choice.h>
#include <widgets/color_swatch.h>
#include <symbol_edit_frame.h>
#include <lib_text.h>
#include <settings/settings_manager.h>
#include <dialog_lib_text_properties.h>
#include <symbol_editor/symbol_editor_settings.h>
#include <tools/symbol_editor_drawing_tools.h>
#include <scintilla_tricks.h>
#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_EDITOR_DRAWING_TOOLS>();
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<SYMBOL_EDITOR_DRAWING_TOOLS>();
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();
}

View File

@ -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 <dialog_lib_text_properties_base.h>
#include <widgets/unit_binder.h>
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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class BITMAP_BUTTON;
class COLOR_SWATCH;
class FONT_CHOICE;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/stc/stc.h>
#include <wx/choice.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/panel.h>
#include <wx/checkbox.h>
#include <wx/gbsizer.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// 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();
};

View File

@ -24,6 +24,7 @@
*/
#include <sch_edit_frame.h>
#include <symbol_edit_frame.h>
#include <widgets/bitmap_button.h>
#include <widgets/font_choice.h>
#include <widgets/color_swatch.h>
@ -39,7 +40,7 @@
#include <gr_text.h>
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<SYMBOL_EDIT_FRAME*>( 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<SCH_EDIT_FRAME*>( m_frame ) )
{
wxString sheetPageNum = sheet.GetPageNumber();
wxString sheetName = sheet.size() == 1 ? _( "<root sheet>" ) : 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 ? _( "<root sheet>" )
: 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<SYMBOL_EDIT_FRAME*>( 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 \"#<page number>\" 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() )
{

View File

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

View File

@ -32,7 +32,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
m_textEntrySizer = new wxGridBagSizer( 2, 3 );
m_textEntrySizer->SetFlexibleDirection( wxBOTH );
m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_textEntrySizer->SetEmptyCellSize( wxSize( 0,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 );

View File

@ -128,7 +128,7 @@
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxGridBagSizer" expanded="true">
<property name="empty_cell_size">0,12</property>
<property name="empty_cell_size">0,6</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">3</property>
<property name="growablerows"></property>
@ -358,7 +358,7 @@
<property name="border">10</property>
<property name="colspan">2</property>
<property name="column">0</property>
<property name="flag">wxTOP</property>
<property name="flag">wxTOP|wxBOTTOM</property>
<property name="row">1</property>
<property name="rowspan">1</property>
<object class="wxCheckBox" expanded="true">
@ -3117,6 +3117,249 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxFlexGridSizer" expanded="true">
<property name="cols">3</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">0,2</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">m_fgSymbolEditor</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">protected</property>
<property name="rows">0</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Private to Symbol Editor</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_privateCheckbox</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="true">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">60</property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Common to all units</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_commonToAllUnits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="true">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="true">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Common to all body styles</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_commonToAllBodyStyles</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>

View File

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

View File

@ -27,9 +27,8 @@
#include <lib_symbol.h>
#include <lib_shape.h>
#include <lib_text.h>
#include <sch_text.h>
#include <memory>
#include <tuple>
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<LIB_TEXT> textItem = std::make_unique<LIB_TEXT>( m_symbol );
auto textItem = std::make_unique<SCH_TEXT>( 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 ) );
}

View File

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

View File

@ -45,7 +45,7 @@ class TEST_LIB_SYMBOL_FIXTURE;
typedef std::shared_ptr<LIB_SYMBOL> LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL
typedef std::weak_ptr<LIB_SYMBOL> LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL
typedef MULTIVECTOR<SCH_ITEM, SCH_FIELD_T, LIB_PIN_T> LIB_ITEMS_CONTAINER;
typedef MULTIVECTOR<SCH_ITEM, SCH_TEXT_T, LIB_PIN_T> LIB_ITEMS_CONTAINER;
typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS;

View File

@ -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 <common.h>
#include <font/font.h>
#include <sch_draw_panel.h>
#include <plotters/plotter.h>
#include <trigo.h>
#include <base_units.h>
#include <widgets/msgpanel.h>
#include <bitmaps.h>
#include <eda_draw_frame.h>
#include <general.h>
#include <transform.h>
#include <settings/color_settings.h>
#include <lib_text.h>
#include <default_values.h> // For some default values
#include <string_utils.h>
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<MSG_PANEL_ITEM>& 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<const LIB_TEXT&>( 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<const LIB_TEXT&>( 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<LIB_TEXT, SCH_ITEM> );
propMgr.AddTypeCast( new TYPE_CAST<LIB_TEXT, EDA_TEXT> );
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;

View File

@ -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 <eda_text.h>
#include <sch_item.h>
/**
* 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<MSG_PANEL_ITEM>& 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

View File

@ -40,7 +40,6 @@
#include <lib_shape.h>
#include <lib_id.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <lib_textbox.h>
#include <sch_bitmap.h>
@ -1521,7 +1520,7 @@ void SCH_IO_ALTIUM::ParseLabel( const std::map<wxString, wxString>& 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<wxString, wxString>& 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<int>( elem.fontId );
size_t fontId = elem.fontId;
if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() )
{

View File

@ -31,7 +31,6 @@
#include <core/kicad_algo.h>
#include <eda_text.h>
#include <lib_shape.h>
#include <lib_text.h>
#include <macros.h>
#include <progress_reporter.h>
#include <string_utils.h>
@ -1696,9 +1695,9 @@ const LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef( const SYMDEF_ID& aSymd
for( std::pair<TEXT_ID, TEXT> textPair : csSym.Texts )
{
TEXT csText = textPair.second;
VECTOR2I pos = getKiCadLibraryPoint( csText.Position, csSym.Origin );
auto libtext = std::make_unique<SCH_TEXT>( pos, csText.Text, LAYER_DEVICE );
std::unique_ptr<LIB_TEXT> libtext = std::make_unique<LIB_TEXT>( 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<LIB_TEXT*>( libtext->Duplicate() );
SCH_TEXT* textLine = static_cast<SCH_TEXT*>( 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<EDA_ITEM*>( 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<SCH_LABEL_BASE*>( aKiCadTextItem )->SetSpinStyle( spin );
return;
default:
else if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( 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<LIB_TEXT&>( item );
SCH_TEXT& txt = static_cast<SCH_TEXT&>( item );
txt.SetPosition( scalePt( txt.GetPosition() ) );
txt.SetTextSize( scaleSize( txt.GetTextSize() ) );

View File

@ -43,7 +43,6 @@
#include <lib_shape.h>
#include <lib_id.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <project.h>
#include <project_sch.h>
#include <sch_bus_entry.h>
@ -2224,8 +2223,7 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBO
}
else if( nodeName == wxT( "text" ) )
{
std::unique_ptr<LIB_TEXT> libtext( loadSymbolText( aSymbol, currentNode,
aGateNumber ) );
std::unique_ptr<SCH_TEXT> libtext( loadSymbolText( currentNode, aGateNumber ) );
if( libtext->GetText() == wxT( "${REFERENCE}" ) )
{
@ -2515,15 +2513,10 @@ LIB_PIN* SCH_IO_EAGLE::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode*
}
LIB_TEXT* SCH_IO_EAGLE::loadSymbolText( std::unique_ptr<LIB_SYMBOL>& aSymbol,
wxXmlNode* aLibText, int aGateNumber )
SCH_TEXT* SCH_IO_EAGLE::loadSymbolText( wxXmlNode* aLibText, int aGateNumber )
{
std::unique_ptr<LIB_TEXT> libtext = std::make_unique<LIB_TEXT>( 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<LIB_SYMBOL>& aSymbol,
adjustedText += tmp;
}
libtext->SetText( adjustedText.IsEmpty() ? wxString( wxT( "~" ) ) : adjustedText );
if( adjustedText.IsEmpty() )
adjustedText = wxT( "~" );
auto libtext = std::make_unique<SCH_TEXT>( 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::vector<SCH_ITEM*
for( i = 0; i < eframe.rows; i++ )
{
LIB_TEXT* legendText = new LIB_TEXT( nullptr );
legendText->SetPosition( 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::vector<SCH_ITEM*
for( i = 0; i < eframe.rows; i++ )
{
LIB_TEXT* legendText = new LIB_TEXT( nullptr );
legendText->SetPosition( 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::vector<SCH_ITEM*
for( i = 0; i < eframe.columns; i++ )
{
LIB_TEXT* legendText = new LIB_TEXT( nullptr );
legendText->SetPosition( 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::vector<SCH_ITEM*
for( i = 0; i < eframe.columns; i++ )
{
LIB_TEXT* legendText = new LIB_TEXT( nullptr );
legendText->SetPosition( 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() );

View File

@ -166,12 +166,11 @@ private:
int aGateNumber );
LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode*, EPIN* epin,
int aGateNumber );
LIB_TEXT* loadSymbolText( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aLibText,
int aGateNumber );
SCH_TEXT* loadSymbolText( wxXmlNode* aLibText, int aGateNumber );
void loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*>& 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();

View File

@ -30,7 +30,6 @@
#include <sch_sheet_pin.h>
#include <sch_line.h>
#include <lib_shape.h>
#include <lib_text.h>
#include <sch_no_connect.h>
#include <sch_label.h>
#include <sch_junction.h>
@ -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 );

View File

@ -34,7 +34,6 @@
#include <sch_line.h>
#include <sch_bitmap.h>
#include <lib_shape.h>
#include <lib_text.h>
#include <sch_no_connect.h>
#include <sch_label.h>
#include <sch_junction.h>
@ -513,14 +512,11 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector<nlohm
wxString textStr = line.at( 5 );
wxString fontStyleStr = line.at( 6 );
std::unique_ptr<LIB_TEXT> text = std::make_unique<LIB_TEXT>( ksymbol );
text->SetPosition( ScalePosSym( pos ) );
text->SetText( UnescapeHTML( textStr ) );
auto text = std::make_unique<SCH_TEXT>( 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 );

View File

@ -22,7 +22,7 @@
#include <lib_shape.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <sch_text.h>
#include <macros.h>
#include <richio.h>
#include <string_utils.h>
@ -720,8 +720,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDrawEntries( std::unique_ptr<LIB_SYMBOL>
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<LIB_SYMBOL
}
LIB_TEXT* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText( std::unique_ptr<LIB_SYMBOL>& 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<LIB_SYMBOL>&
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<LIB_PIN*>( &item ), aFormatter ); break;
case SCH_TEXT_T: saveText( static_cast<SCH_TEXT*>( &item ), aFormatter ); break;
case LIB_SHAPE_T:
{
LIB_SHAPE& shape = static_cast<LIB_SHAPE&>( 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();

View File

@ -75,8 +75,7 @@ private:
void loadDocs();
static LIB_SHAPE* loadArc( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
static LIB_SHAPE* loadCircle( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
static LIB_TEXT* loadText( std::unique_ptr<LIB_SYMBOL>& 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<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
static LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
static LIB_SHAPE* loadPolyLine( std::unique_ptr<LIB_SYMBOL>& 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;

View File

@ -49,13 +49,8 @@
#include <sch_sheet_pin.h>
#include <schematic.h>
#include <sch_screen.h>
#include <lib_shape.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <lib_textbox.h>
#include <eeschema_id.h> // for MAX_UNIT_COUNT_PER_PACKAGE definition
#include <io/kicad/kicad_io_utils.h>
#include <sch_file_versions.h>
#include <schematic_lexer.h>
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h>

View File

@ -24,7 +24,6 @@
#include <build_version.h>
#include <lib_shape.h>
#include <lib_symbol.h>
#include <lib_text.h>
#include <lib_textbox.h>
#include <locale_io.h>
#include <macros.h>
@ -375,8 +374,8 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFO
savePin( static_cast<LIB_PIN*>( aItem ), aFormatter, aNestLevel );
break;
case LIB_TEXT_T:
saveText( static_cast<LIB_TEXT*>( aItem ), aFormatter, aNestLevel );
case SCH_TEXT_T:
saveText( static_cast<SCH_TEXT*>( 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" : "",

View File

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

View File

@ -38,7 +38,6 @@
#include <lib_id.h>
#include <lib_shape.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <lib_textbox.h>
#include <math/util.h> // KiROUND, Clamp
#include <font/font.h>
@ -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<LIB_TEXT> text = std::make_unique<LIB_TEXT>( nullptr );
std::unique_ptr<SCH_TEXT> text = std::make_unique<SCH_TEXT>();
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<EDA_TEXT*>( text.get() ), true );
parseEDA_TEXT( text.get(), true );
break;
default:

View File

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

View File

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

View File

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

View File

@ -36,7 +36,6 @@
#include <gr_text.h>
#include <lib_shape.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <lib_textbox.h>
#include <math/util.h>
#include <pgm_base.h>
@ -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<const LIB_PIN*>( aItem ), aLayer, aDimmed );
break;
case LIB_TEXT_T:
draw( static_cast<const LIB_TEXT*>( aItem ), aLayer, aDimmed );
break;
case LIB_TEXTBOX_T:
draw( static_cast<const LIB_TEXTBOX*>( aItem ), aLayer, aDimmed );
break;
@ -211,7 +206,7 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed )
draw( static_cast<const SCH_SHAPE*>( aItem ), aLayer );
break;
case SCH_TEXT_T:
draw( static_cast<const SCH_TEXT*>( aItem ), aLayer );
draw( static_cast<const SCH_TEXT*>( aItem ), aLayer, aDimmed );
break;
case SCH_TEXTBOX_T:
draw( static_cast<const SCH_TEXTBOX*>( aItem ), aLayer );
@ -516,10 +511,6 @@ float SCH_PAINTER::getTextThickness( const EDA_ITEM* aItem ) const
pen = static_cast<const SCH_TEXTBOX*>( aItem )->GetEffectiveTextPenWidth( pen );
break;
case LIB_TEXT_T:
pen = std::max( pen, static_cast<const LIB_TEXT*>( aItem )->GetEffectiveTextPenWidth() );
break;
case LIB_TEXTBOX_T:
pen = std::max( pen, static_cast<const LIB_TEXTBOX*>( 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<LIB_TEXT*>( &tempItem );
SCH_TEXT* textItem = static_cast<SCH_TEXT*>( &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<const SCH_TEXT*>( aLabel ), aLayer );
draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer, false );
}
@ -2889,7 +2842,7 @@ void SCH_PAINTER::draw( const SCH_LABEL* aLabel, int aLayer )
return;
}
draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer );
draw( static_cast<const SCH_TEXT*>( 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<const SCH_TEXT*>( aLabel ), aLayer );
draw( static_cast<const SCH_TEXT*>( 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() )
{

View File

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

View File

@ -27,7 +27,6 @@
#include <bitmaps.h>
#include <core/mirror.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <lib_shape.h>
#include <pgm_base.h>
#include <sch_symbol.h>
@ -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 );

View File

@ -46,13 +46,14 @@
#include <trigo.h>
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<VECTOR2I> 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<VECTOR2I> 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<MSG_PANEL_IT
wxString msg;
// Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Graphic Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
if( m_excludedFromSim )
aList.emplace_back( _( "Exclude from" ), _( "Simulation" ) );
@ -422,7 +739,24 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
case GR_TEXT_H_ALIGN_INDETERMINATE: msg = INDETERMINATE_STATE; break;
}
aList.emplace_back( _( "Justification" ), msg );
if( m_layer == LAYER_DEVICE )
{
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 );
}
else
{
aList.emplace_back( _( "Justification" ), msg );
}
}
bool SCH_TEXT::operator==( const SCH_ITEM& aOther ) const
@ -444,12 +778,15 @@ bool SCH_TEXT::operator==( const SCH_ITEM& aOther ) const
double SCH_TEXT::Similarity( const SCH_ITEM& aOther ) const
{
if( m_Uuid == aOther.m_Uuid )
return 1.0;
if( Type() != aOther.Type() )
return 0.0;
const SCH_TEXT* other = static_cast<const SCH_TEXT*>( &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<const SCH_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;
}
#if defined(DEBUG)
void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const

View File

@ -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 <eda_text.h>
#include <sch_item.h>
#include <sch_field.h>
#include <sch_connection.h> // for CONNECTION_TYPE
#include <schematic.h>
@ -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<MSG_PANEL_ITEM>& 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;
};

View File

@ -38,7 +38,6 @@
#include <kiway_express.h>
#include <symbol_edit_frame.h>
#include <lib_symbol_library_manager.h>
#include <lib_text.h>
#include <symbol_editor_settings.h>
#include <paths.h>
#include <pgm_base.h>

View File

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

View File

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

View File

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

View File

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

View File

@ -30,15 +30,13 @@
#include <tools/symbol_editor_drawing_tools.h>
#include <tools/symbol_editor_pin_tool.h>
#include <tools/ee_grid_helper.h>
#include <lib_text.h>
#include <dialogs/dialog_lib_text_properties.h>
#include <dialogs/dialog_text_properties.h>
#include <lib_shape.h>
#include <lib_textbox.h>
#include <pgm_base.h>
#include <symbol_editor/symbol_editor_settings.h>
#include <settings/settings_manager.h>
#include <string_utils.h>
#include <geometry/geometry_utils.h>
#include <wx/msgdlg.h>
#include <import_gfx/dialog_import_gfx_sch.h>
#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<LIB_PIN*>( 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<SCH_TEXT*>( item ) );
item->ClearEditFlags();
commit.Push( _( "Add Text" ) );
break;

View File

@ -32,14 +32,13 @@
#include <symbol_edit_frame.h>
#include <sch_commit.h>
#include <dialogs/dialog_lib_shape_properties.h>
#include <dialogs/dialog_lib_text_properties.h>
#include <dialogs/dialog_text_properties.h>
#include <dialogs/dialog_lib_textbox_properties.h>
#include <dialogs/dialog_field_properties.h>
#include <dialogs/dialog_lib_symbol_properties.h>
#include <dialogs/dialog_lib_edit_pin_table.h>
#include <dialogs/dialog_update_symbol_fields.h>
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>
#include <lib_text.h>
#include <lib_textbox.h>
#include "symbol_editor_edit_tool.h"
#include <wx/textdlg.h> // for wxTextEntryDialog
@ -274,7 +273,7 @@ static std::vector<KICAD_T> 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<LIB_SHAPE*>( 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<LIB_TEXT*>( aItem ) );
DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_TEXT*>( 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 );
}

View File

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

View File

@ -45,7 +45,6 @@
#include <sch_sheet.h>
#include <lib_shape.h>
#include <lib_text.h>
#include <lib_textbox.h>
#include <lib_pin.h>
@ -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 );