diff --git a/common/widgets/properties_panel.cpp b/common/widgets/properties_panel.cpp index 512d28ec29..7835a587d1 100644 --- a/common/widgets/properties_panel.cpp +++ b/common/widgets/properties_panel.cpp @@ -245,7 +245,12 @@ void PROPERTIES_PANEL::rebuildProperties( const SELECTION& aSelection ) } EDA_ITEM* firstItem = aSelection.Front(); - bool isFootprintEditor = m_frame->IsType( FRAME_FOOTPRINT_EDITOR ); + + bool isLibraryEditor = m_frame->IsType( FRAME_FOOTPRINT_EDITOR ) + || m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ); + + bool isDesignEditor = m_frame->IsType( FRAME_PCB_EDITOR ) + || m_frame->IsType( FRAME_SCH ); // Find a set of properties that is common to all selected items for( PROPERTY_BASE* property : commonProps ) @@ -253,7 +258,10 @@ void PROPERTIES_PANEL::rebuildProperties( const SELECTION& aSelection ) if( property->IsHiddenFromPropertiesManager() ) continue; - if( isFootprintEditor && property->IsHiddenFromLibraryEditors() ) + if( isLibraryEditor && property->IsHiddenFromLibraryEditors() ) + continue; + + if( isDesignEditor && property->IsHiddenFromDesignEditors() ) continue; if( propMgr.IsAvailableFor( TYPE_HASH( *firstItem ), property, firstItem ) ) diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 5e8e5d84d0..3fca1484df 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -362,8 +362,7 @@ set( EESCHEMA_SRCS gfx_import_utils.cpp picksymbol.cpp lib_field.cpp - lib_item.cpp - lib_pin.cpp + lib_pin.cpp lib_shape.cpp lib_symbol.cpp lib_text.cpp diff --git a/eeschema/api/api_handler_sch.cpp b/eeschema/api/api_handler_sch.cpp index c4a436dcaa..e9240c277b 100644 --- a/eeschema/api/api_handler_sch.cpp +++ b/eeschema/api/api_handler_sch.cpp @@ -265,10 +265,6 @@ HANDLER_RESULT API_HANDLER_SCH::handleCreateUpdateItemsIntern schItem->Serialize( newItem ); commit->Modify( schItem ); } - else if( LIB_ITEM* libItem = dynamic_cast( edaItem ) ) - { - // TODO: there is not currently a way to do this, haha - } else { wxASSERT( false ); diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index a522683927..8ece0263b3 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -155,7 +155,8 @@ public: return GetValue( m_rows[ aRow ], aCol, m_frame ); } - static wxString GetValue( const LIB_PINS& pins, int aCol, EDA_DRAW_FRAME* aParentFrame ) + static wxString GetValue( const std::vector& pins, int aCol, + EDA_DRAW_FRAME* aParentFrame ) { wxString fieldValue; @@ -228,10 +229,10 @@ public: case COL_DEMORGAN: switch( pin->GetBodyStyle() ) { - case LIB_ITEM::BODY_STYLE::BASE: + case BODY_STYLE::BASE: val = DEMORGAN_STD; break; - case LIB_ITEM::BODY_STYLE::DEMORGAN: + case BODY_STYLE::DEMORGAN: val = DEMORGAN_ALT; break; default: @@ -291,7 +292,7 @@ public: break; } - LIB_PINS pins = m_rows[ aRow ]; + std::vector pins = m_rows[ aRow ]; // If the NUMBER column is edited and the pins are grouped, renumber, and add or // remove pins based on the comma separated list of pins. @@ -453,7 +454,7 @@ public: m_edited = true; } - static int findRow( const std::vector& aRowSet, const wxString& aName ) + static int findRow( const std::vector>& aRowSet, const wxString& aName ) { for( size_t i = 0; i < aRowSet.size(); ++i ) { @@ -464,8 +465,8 @@ public: return -1; } - static bool compare( const LIB_PINS& lhs, const LIB_PINS& rhs, int sortCol, bool ascending, - EDA_DRAW_FRAME* parentFrame ) + static bool compare( const std::vector& lhs, const std::vector& rhs, + int sortCol, bool ascending, EDA_DRAW_FRAME* parentFrame ) { wxString lhStr = GetValue( lhs, sortCol, parentFrame ); wxString rhStr = GetValue( rhs, sortCol, parentFrame ); @@ -517,7 +518,7 @@ public: return res; } - void RebuildRows( const LIB_PINS& aPins, bool groupByName, bool groupBySelection ) + void RebuildRows( const std::vector& aPins, bool groupByName, bool groupBySelection ) { WX_GRID* grid = dynamic_cast( GetView() ); std::vector clear_flags; @@ -557,7 +558,7 @@ public: m_rows.clear(); if( groupBySelection ) - m_rows.emplace_back( LIB_PINS() ); + m_rows.emplace_back( std::vector() ); for( LIB_PIN* pin : aPins ) { @@ -572,7 +573,7 @@ public: if( rowIndex < 0 ) { - m_rows.emplace_back( LIB_PINS() ); + m_rows.emplace_back( std::vector() ); rowIndex = m_rows.size() - 1; } @@ -589,7 +590,7 @@ public: ascending = GetView()->IsSortOrderAscending(); } - for( LIB_PINS& row : m_rows ) + for( std::vector& row : m_rows ) SortPins( row ); if( !groupBySelection ) @@ -597,7 +598,7 @@ public: if ( GetView() ) { - wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_rows.size() ); + wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, (int) m_rows.size() ); GetView()->ProcessTableMessage( msg ); if( groupBySelection ) @@ -611,13 +612,14 @@ public: void SortRows( int aSortCol, bool ascending ) { std::sort( m_rows.begin(), m_rows.end(), - [ aSortCol, ascending, this ]( const LIB_PINS& lhs, const LIB_PINS& rhs ) -> bool + [ aSortCol, ascending, this ]( const std::vector& lhs, + const std::vector& rhs ) -> bool { return compare( lhs, rhs, aSortCol, ascending, m_frame ); } ); } - void SortPins( LIB_PINS& aRow ) + void SortPins( std::vector& aRow ) { std::sort( aRow.begin(), aRow.end(), []( LIB_PIN* lhs, LIB_PIN* rhs ) -> bool @@ -628,7 +630,7 @@ public: void AppendRow( LIB_PIN* aPin ) { - LIB_PINS row; + std::vector row; row.push_back( aPin ); m_rows.push_back( row ); @@ -639,9 +641,9 @@ public: } } - LIB_PINS RemoveRow( int aRow ) + std::vector RemoveRow( int aRow ) { - LIB_PINS removedRow = m_rows[ aRow ]; + std::vector removedRow = m_rows[ aRow ]; m_rows.erase( m_rows.begin() + aRow ); @@ -654,7 +656,7 @@ public: return removedRow; } - LIB_PINS GetRowPins( int aRow ) + std::vector GetRowPins( int aRow ) { return m_rows[ aRow ]; } @@ -693,21 +695,21 @@ private: } private: - SYMBOL_EDIT_FRAME* m_frame; + SYMBOL_EDIT_FRAME* m_frame; // Because the rows of the grid can either be a single pin or a group of pins, the - // data model is a 2D vector. If we're in the single pin case, each row's LIB_PINS + // data model is a 2D vector. If we're in the single pin case, each row's LIB_PINs // contains only a single pin. - std::vector m_rows; - int m_unitFilter; // 0 to show pins for all units + std::vector> m_rows; + int m_unitFilter; // 0 to show pins for all units - bool m_edited; + bool m_edited; - DIALOG_LIB_EDIT_PIN_TABLE* m_pinTable; - LIB_SYMBOL* m_symbol; // Parent symbol that the pins belong to. + DIALOG_LIB_EDIT_PIN_TABLE* m_pinTable; + LIB_SYMBOL* m_symbol; // Parent symbol that the pins belong to. - std::unique_ptr m_eval; - std::map< std::pair, wxString > m_evalOriginal; + std::unique_ptr m_eval; + std::map< std::pair, int>, wxString > m_evalOriginal; }; @@ -1016,7 +1018,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow( wxCommandEvent& event ) m_grid->SetGridCursor( nextSelRow, m_grid->GetGridCursorCol() ); m_grid->SelectRow( nextSelRow ); - LIB_PINS removedRow = m_dataModel->RemoveRow( curRow ); + std::vector removedRow = m_dataModel->RemoveRow( curRow ); for( LIB_PIN* pin : removedRow ) m_pins.erase( std::find( m_pins.begin(), m_pins.end(), pin ) ); @@ -1044,7 +1046,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnCellSelected( wxGridEvent& event ) if( event.GetRow() >= 0 && event.GetRow() < m_dataModel->GetNumberRows() ) { - const LIB_PINS& pins = m_dataModel->GetRowPins( event.GetRow() ); + const std::vector& pins = m_dataModel->GetRowPins( event.GetRow() ); if( pins.size() == 1 && m_editFrame->GetCurSymbol() ) { diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.h b/eeschema/dialogs/dialog_lib_edit_pin_table.h index 48d5bcb028..2069a658ab 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.h +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.h @@ -23,7 +23,7 @@ #include "dialog_lib_edit_pin_table_base.h" -#include +#include #include enum COL_ORDER @@ -87,7 +87,7 @@ protected: int m_originalColWidths[ COL_COUNT ]; std::bitset<64> m_columnsShown; LIB_SYMBOL* m_symbol; - LIB_PINS m_pins; // a copy of the pins owned by me + std::vector m_pins; // a copy of the pins owned by me bool m_modified; ///< true when there are unsaved changes wxSize m_size; diff --git a/eeschema/dialogs/dialog_lib_shape_properties.cpp b/eeschema/dialogs/dialog_lib_shape_properties.cpp index 325dd49c6c..862056d4fd 100644 --- a/eeschema/dialogs/dialog_lib_shape_properties.cpp +++ b/eeschema/dialogs/dialog_lib_shape_properties.cpp @@ -21,7 +21,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include #include #include #include diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index 8ee266b48d..28e361b0c9 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -501,7 +501,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow() if( m_part && m_part->HasAlternateBodyStyle() ) { - if( m_symbol->GetBodyStyle() > LIB_ITEM::BODY_STYLE::BASE ) + if( m_symbol->GetBodyStyle() > BODY_STYLE::BASE ) m_cbAlternateSymbol->SetValue( true ); } else @@ -696,9 +696,9 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow() // For symbols with multiple shapes (De Morgan representation) Set the selected shape: if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() ) - m_symbol->SetBodyStyle( LIB_ITEM::BODY_STYLE::DEMORGAN ); + m_symbol->SetBodyStyle( BODY_STYLE::DEMORGAN ); else - m_symbol->SetBodyStyle( LIB_ITEM::BODY_STYLE::BASE ); + m_symbol->SetBodyStyle( BODY_STYLE::BASE ); //Set the part selection in multiple part per package int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1; diff --git a/eeschema/ee_collectors.cpp b/eeschema/ee_collectors.cpp index 5d48bb15a8..1b4f57735a 100644 --- a/eeschema/ee_collectors.cpp +++ b/eeschema/ee_collectors.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -92,17 +91,17 @@ INSPECT_RESULT EE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData ) { if( m_Unit || m_BodyStyle ) { - LIB_ITEM* lib_item = dynamic_cast( aItem ); + SCH_ITEM* schItem = dynamic_cast( aItem ); // Special selection rules apply to pins of different units when edited in synchronized // pins mode. Leave it to EE_SELECTION_TOOL::Selectable() to decide what to do with them. - if( lib_item && lib_item->Type() != LIB_PIN_T ) + if( schItem && schItem->Type() != LIB_PIN_T ) { - if( m_Unit && lib_item->GetUnit() && lib_item->GetUnit() != m_Unit ) + if( m_Unit && schItem->GetUnit() && schItem->GetUnit() != m_Unit ) return INSPECT_RESULT::CONTINUE; - if( m_BodyStyle && lib_item->GetBodyStyle() && lib_item->GetBodyStyle() != m_BodyStyle ) + if( m_BodyStyle && schItem->GetBodyStyle() && schItem->GetBodyStyle() != m_BodyStyle ) return INSPECT_RESULT::CONTINUE; } } @@ -151,7 +150,7 @@ void EE_COLLECTOR::Collect( LIB_ITEMS_CONTAINER& aItems, const std::vectorm_includeHiddenPins ) { // horrible hack, TODO overhaul the Plot method to handle this - for( LIB_ITEM& item : symbolToPlot->GetDrawItems() ) + for( SCH_ITEM& item : symbolToPlot->GetDrawItems() ) { if( item.Type() != LIB_PIN_T ) continue; diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index e7f2114dc6..9f015cc7df 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -493,21 +493,21 @@ int ERC_TESTER::TestMissingUnits() for( int missing_unit : missing_units ) { - LIB_PINS pins; - int convert = 0; + std::vector pins; + int bodyStyle = 0; for( size_t ii = 0; ii < refList.GetCount(); ++ii ) { if( refList.GetItem( ii ).GetUnit() == missing_unit ) { - convert = refList.GetItem( ii ).GetSymbol()->GetBodyStyle(); + bodyStyle = refList.GetItem( ii ).GetSymbol()->GetBodyStyle(); break; } } - libSymbol->GetPins( pins, missing_unit, convert ); + libSymbol->GetPins( pins, missing_unit, bodyStyle ); - for( auto pin : pins ) + for( LIB_PIN* pin : pins ) { switch( pin->GetType() ) { @@ -1012,7 +1012,7 @@ int ERC_TESTER::TestLibSymbolIssues() } std::unique_ptr flattenedSymbol = libSymbol->Flatten(); - constexpr int flags = LIB_ITEM::COMPARE_FLAGS::EQUALITY | LIB_ITEM::COMPARE_FLAGS::ERC; + constexpr int flags = SCH_ITEM::COMPARE_FLAGS::EQUALITY | SCH_ITEM::COMPARE_FLAGS::ERC; if( settings.IsTestEnabled( ERCE_LIB_SYMBOL_MISMATCH ) && flattenedSymbol->Compare( *libSymbolInSchematic, flags ) != 0 ) diff --git a/eeschema/gfx_import_utils.cpp b/eeschema/gfx_import_utils.cpp index 1829735d4d..7d43e9e2c2 100644 --- a/eeschema/gfx_import_utils.cpp +++ b/eeschema/gfx_import_utils.cpp @@ -134,7 +134,7 @@ void ConvertImageToLibShapes( LIB_SYMBOL* aSymbol, int unit, wxImage img, VECTOR shape->SetUnit( unit ); - shape->Offset( offset ); + shape->Move( offset ); aSymbol->AddDrawItem( shape.release() ); } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 4d1a6547e3..aa5d49de33 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -39,8 +39,8 @@ #include -LIB_FIELD::LIB_FIELD( LIB_SYMBOL* aParent, int aId, const wxString& aName ) : - LIB_ITEM( LIB_FIELD_T, aParent ), +LIB_FIELD::LIB_FIELD( SCH_ITEM* aParent, int aId, const wxString& aName ) : + SCH_ITEM( aParent, LIB_FIELD_T ), EDA_TEXT( schIUScale ) { Init( aId ); @@ -49,7 +49,7 @@ LIB_FIELD::LIB_FIELD( LIB_SYMBOL* aParent, int aId, const wxString& aName ) : LIB_FIELD::LIB_FIELD( int aId ) : - LIB_ITEM( LIB_FIELD_T, nullptr ), + SCH_ITEM( nullptr, LIB_FIELD_T ), EDA_TEXT( schIUScale ) { Init( aId ); @@ -57,7 +57,7 @@ LIB_FIELD::LIB_FIELD( int aId ) : LIB_FIELD::LIB_FIELD( int aId, const wxString& aName ) : - LIB_ITEM( LIB_FIELD_T, nullptr ), + SCH_ITEM( nullptr, LIB_FIELD_T ), EDA_TEXT( schIUScale ) { Init( aId ); @@ -193,6 +193,23 @@ bool LIB_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const } +bool LIB_FIELD::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const +{ + if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) ) + return false; + + BOX2I sel = aRect; + + if ( aAccuracy ) + sel.Inflate( aAccuracy ); + + if( aContained ) + return sel.Contains( GetBoundingBox() ); + + return sel.Intersects( GetBoundingBox() ); +} + + EDA_ITEM* LIB_FIELD::Clone() const { return new LIB_FIELD( *this ); @@ -213,11 +230,11 @@ void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const } -int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const +int LIB_FIELD::compare( const SCH_ITEM& aOther, int aCompareFlags ) const { wxASSERT( aOther.Type() == LIB_FIELD_T ); - int retv = LIB_ITEM::compare( aOther, aCompareFlags ); + int retv = SCH_ITEM::compare( aOther, aCompareFlags ); if( retv ) return retv; @@ -226,7 +243,7 @@ int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const // Equality test will vary depending whether or not the field is mandatory. Otherwise, // sorting is done by ordinal. - if( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::EQUALITY ) + if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY ) { // Mandatory fields have fixed ordinals and their names can vary due to translated field // names. Optional fields have fixed names and their ordinals can vary. @@ -251,10 +268,10 @@ int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const bool ignoreFieldText = false; - if( m_id == REFERENCE_FIELD && !( aCompareFlags & COMPARE_FLAGS::EQUALITY ) ) + if( m_id == REFERENCE_FIELD && !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY ) ) ignoreFieldText = true; - if( m_id == VALUE_FIELD && ( aCompareFlags & COMPARE_FLAGS::ERC ) ) + if( m_id == VALUE_FIELD && ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) ) ignoreFieldText = true; if( !ignoreFieldText ) @@ -265,7 +282,7 @@ int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const return retv; } - if( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::EQUALITY ) + if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY ) { if( GetTextPos().x != tmp->GetTextPos().x ) return GetTextPos().x - tmp->GetTextPos().x; @@ -284,13 +301,13 @@ int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const } -void LIB_FIELD::Offset( const VECTOR2I& aOffset ) +void LIB_FIELD::Move( const VECTOR2I& aOffset ) { EDA_TEXT::Offset( aOffset ); } -void LIB_FIELD::MoveTo( const VECTOR2I& newPosition ) +void LIB_FIELD::SetPosition( const VECTOR2I& newPosition ) { EDA_TEXT::SetTextPos( newPosition ); } @@ -534,7 +551,7 @@ void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector ); + propMgr.AddTypeCast( new TYPE_CAST ); propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.InheritsAfter( TYPE_HASH( LIB_FIELD ), TYPE_HASH( LIB_ITEM ) ); + propMgr.InheritsAfter( TYPE_HASH( LIB_FIELD ), TYPE_HASH( SCH_ITEM ) ); propMgr.InheritsAfter( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Show Field Name" ), diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 4fd886ac20..9861f7e847 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -31,7 +31,7 @@ #define CLASS_LIBENTRY_FIELDS_H #include -#include +#include class SCH_IO_KICAD_LEGACY_LIB_CACHE; @@ -58,14 +58,14 @@ class SCH_IO_KICAD_LEGACY_LIB_CACHE; * * @see enum MANDATORY_FIELD_T */ -class LIB_FIELD : public LIB_ITEM, public EDA_TEXT +class LIB_FIELD : public SCH_ITEM, public EDA_TEXT { public: LIB_FIELD( int aId = 2 ); LIB_FIELD( int aId, const wxString& aName ); - LIB_FIELD( LIB_SYMBOL* aParent, int aId = 2, const wxString& aName = wxEmptyString ); + LIB_FIELD( SCH_ITEM* aParent, int aId = 2, const wxString& aName = wxEmptyString ); // Do not create a copy constructor. The one generated by the compiler is adequate. @@ -144,6 +144,7 @@ public: void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; + bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const override; LIB_FIELD& operator=( const LIB_FIELD& field ); @@ -165,9 +166,9 @@ public: void BeginEdit( const VECTOR2I& aStartPoint ) override; - void Offset( const VECTOR2I& aOffset ) override; + void Move( const VECTOR2I& aOffset ) override; - void MoveTo( const VECTOR2I& aPosition ) override; + void SetPosition( const VECTOR2I& aPosition ) override; VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); } @@ -201,14 +202,14 @@ public: bool ShowInChooser() const { return m_showInChooser; } void SetShowInChooser( bool aShow = true ) { m_showInChooser = aShow; } - double Similarity( const LIB_ITEM& aItem ) const override; + double Similarity( const SCH_ITEM& aItem ) const override; - bool operator==( const LIB_ITEM& aItem ) const override; + bool operator==( const SCH_ITEM& aItem ) const override; private: /** - * @copydoc LIB_ITEM::compare() + * @copydoc SCH_ITEM::compare() * * The field specific sort order is as follows: * @@ -219,7 +220,7 @@ private: * - Field width. * - Field height. */ - int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override; + int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override; /** * Calculate the new circle at \a aPosition when editing. diff --git a/eeschema/lib_item.cpp b/eeschema/lib_item.cpp deleted file mode 100644 index 1f78ebb717..0000000000 --- a/eeschema/lib_item.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr - * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 2004-2023 KiCad Developers, see change_log.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -const int fill_tab[3] = { 'N', 'F', 'f' }; - - -LIB_ITEM::LIB_ITEM( KICAD_T aType, LIB_SYMBOL* aSymbol, int aUnit, int aConvert ) : - EDA_ITEM( aSymbol, aType ), - m_unit( aUnit ), - m_bodyStyle( aConvert ), - m_private( false ) -{ -} - - -wxString LIB_ITEM::GetUnitDescription( int aUnit ) -{ - if( aUnit == 0 ) - return _( "All" ); - else - return LIB_SYMBOL::LetterSubReference( aUnit, 'A' ); -} - - -wxString LIB_ITEM::GetBodyStyleDescription( int aBodyStyle ) -{ - if( aBodyStyle == 0 ) - return _( "All" ); - else if( aBodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN ) - return _( "Alternate" ); - else if( aBodyStyle == LIB_ITEM::BODY_STYLE::BASE ) - return _( "Standard" ); - else - return wxT( "?" ); -} - - -void LIB_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) -{ - wxString msg; - - aList.emplace_back( _( "Type" ), GetFriendlyName() ); - - if( const SYMBOL* parent = GetParentSymbol() ) - { - if( parent->GetUnitCount() ) - aList.emplace_back( _( "Unit" ), GetUnitDescription( m_unit ) ); - - if( parent->HasAlternateBodyStyle() ) - aList.emplace_back( _( "Body Style" ), GetBodyStyleDescription( m_bodyStyle ) ); - } - - if( IsPrivate() ) - aList.emplace_back( _( "Private" ), wxEmptyString ); -} - - -int LIB_ITEM::compare( const LIB_ITEM& aOther, int aCompareFlags ) const -{ - if( Type() != aOther.Type() ) - return Type() - aOther.Type(); - - // When comparing unit LIB_ITEM objects, we ignore the unit number. - if( !( aCompareFlags & COMPARE_FLAGS::UNIT ) && m_unit != aOther.m_unit ) - return m_unit - aOther.m_unit; - - if( !( aCompareFlags & COMPARE_FLAGS::UNIT ) && m_bodyStyle != aOther.m_bodyStyle ) - return m_bodyStyle - aOther.m_bodyStyle; - - if( IsPrivate() != aOther.IsPrivate() ) - return IsPrivate() < aOther.IsPrivate(); - - return 0; -} - - -bool LIB_ITEM::cmp_items::operator()( const LIB_ITEM* aFirst, const LIB_ITEM* aSecond ) const -{ - return aFirst->compare( *aSecond, LIB_ITEM::COMPARE_FLAGS::EQUALITY ) < 0; -} - - -bool LIB_ITEM::operator==( const LIB_ITEM& aOther ) const -{ - if( Type() != aOther.Type() ) - return false; - - return compare( aOther, LIB_ITEM::COMPARE_FLAGS::EQUALITY ) == 0; -} - - -bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const -{ - if( Type() != aOther.Type() ) - return Type() < aOther.Type(); - - return ( compare( aOther ) < 0 ); -} - - -LIB_ITEM* LIB_ITEM::Duplicate() const -{ - LIB_ITEM* dupe = static_cast( Clone() ); - const_cast( dupe->m_Uuid ) = KIID(); - - return dupe; -} - - -bool LIB_ITEM::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const -{ - if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) ) - return false; - - BOX2I sel = aRect; - - if ( aAccuracy ) - sel.Inflate( aAccuracy ); - - if( aContained ) - return sel.Contains( GetBoundingBox() ); - - return sel.Intersects( GetBoundingBox() ); -} - - -const wxString& LIB_ITEM::GetDefaultFont() const -{ - EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); - - return cfg->m_Appearance.default_font; -} - - -const KIFONT::METRICS& LIB_ITEM::GetFontMetrics() const -{ - return KIFONT::METRICS::Default(); -} - - -void LIB_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const -{ - // Basic fallback - aCount = 3; - aLayers[0] = LAYER_DEVICE; - aLayers[1] = LAYER_DEVICE_BACKGROUND; - aLayers[2] = LAYER_SELECTION_SHADOWS; -} - - -static struct LIB_ITEM_DESC -{ - LIB_ITEM_DESC() - { - PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); - REGISTER_TYPE( LIB_ITEM ); - propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.InheritsAfter( TYPE_HASH( LIB_ITEM ), TYPE_HASH( EDA_ITEM ) ); - - auto multiUnit = - [=]( INSPECTABLE* aItem ) -> bool - { - if( LIB_ITEM* libItem = dynamic_cast( aItem ) ) - { - if( const SYMBOL* symbol = libItem->GetParentSymbol() ) - return symbol->IsMulti(); - } - - return false; - }; - - auto multiBodyStyle = - [=]( INSPECTABLE* aItem ) -> bool - { - if( LIB_ITEM* libItem = dynamic_cast( aItem ) ) - { - if( const SYMBOL* symbol = libItem->GetParentSymbol() ) - return symbol->HasAlternateBodyStyle(); - } - - return false; - }; - - propMgr.AddProperty( new PROPERTY( _HKI( "Unit" ), - &LIB_ITEM::SetUnit, &LIB_ITEM::GetUnit ) ) - .SetAvailableFunc( multiUnit ); - propMgr.AddProperty( new PROPERTY( _HKI( "Body Style" ), - &LIB_ITEM::SetBodyStyle, &LIB_ITEM::GetBodyStyle ) ) - .SetAvailableFunc( multiBodyStyle ); - - propMgr.AddProperty( new PROPERTY( _HKI( "Private" ), - &LIB_ITEM::SetPrivate, &LIB_ITEM::IsPrivate ) ); - } -} _LIB_ITEM_DESC; diff --git a/eeschema/lib_item.h b/eeschema/lib_item.h deleted file mode 100644 index bd95ead8dc..0000000000 --- a/eeschema/lib_item.h +++ /dev/null @@ -1,409 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr - * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * 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_ITEM_H_ -#define _LIB_ITEM_H_ - -#include -#include -#include -#include -#include - -class LINE_READER; -class OUTPUTFORMATTER; -class LIB_SYMBOL; -class PLOTTER; -class LIB_PIN; -class MSG_PANEL_ITEM; - -namespace KIFONT -{ -class FONT; -class METRICS; -} - - -using KIGFX::RENDER_SETTINGS; - -extern const int fill_tab[]; - - -#define MINIMUM_SELECTION_DISTANCE 2 // Minimum selection distance in internal units - - -/** - * Helper for defining a list of pin object pointers. The list does not - * use a Boost pointer class so the object pointers do not accidentally get - * deleted when the container is deleted. - */ -typedef std::vector< LIB_PIN* > LIB_PINS; - - -/** - * The base class for drawable items used by schematic library symbols. - */ -class LIB_ITEM : public EDA_ITEM -{ -public: - LIB_ITEM( KICAD_T aType, LIB_SYMBOL* aSymbol = nullptr, int aUnit = 0, int aConvert = 0 ); - - // Do not create a copy constructor. The one generated by the compiler is adequate. - - virtual ~LIB_ITEM() { } - - // Define the enums for basic body styles - enum BODY_STYLE : int - { - BASE = 1, - DEMORGAN = 2 - }; - - /** - * The list of flags used by the #compare function. - * - * - UNIT This flag relaxes unit, conversion and pin number constraints. It is used for - * #LIB_ITEM object unit comparisons. - * - EQUALITY This flag relaxes ordering contstraints so that fields, etc. don't have to - * appear in the same order to be considered equal. - * - ERC This flag relaxes constraints on data that is settable in the schematic editor. It - * compares only symbol-editor-only data. - */ - enum COMPARE_FLAGS : int - { - UNIT = 0x01, - EQUALITY = 0x02, - ERC = 0x04 - }; - - static inline bool ClassOf( const EDA_ITEM* aItem ) - { - if( !aItem ) - return false; - - switch ( aItem->Type() ) - { - case LIB_SHAPE_T: - case LIB_TEXT_T: - case LIB_TEXTBOX_T: - case LIB_PIN_T: - case LIB_FIELD_T: - return true; - default: - break; - } - - return false; - } - - static wxString GetUnitDescription( int aUnit ); - static wxString GetBodyStyleDescription( int aBodyStyle ); - - /** - * Create a copy of this #LIB_ITEM (with a new Uuid). - */ - LIB_ITEM* Duplicate() const; - - /** - * Begin drawing a symbol library draw item at \a aPosition. - * - * It typically would be called on a left click when a draw tool is selected in - * the symbol library editor and one of the graphics tools is selected. - * - * @param aPosition The position in drawing coordinates where the drawing was started. - * May or may not be required depending on the item being drawn. - */ - virtual void BeginEdit( const VECTOR2I& aPosition ) {} - - /** - * Continue an edit in progress at \a aPosition. - * - * This is used to perform the next action while drawing an item. This would be - * called for each additional left click when the mouse is captured while the item - * is being drawn. - * - * @param aPosition The position of the mouse left click in drawing coordinates. - * @return True if additional mouse clicks are required to complete the edit in progress. - */ - virtual bool ContinueEdit( const VECTOR2I& aPosition ) { return false; } - - /** - * End an object editing action. - * - * This is used to end or abort an edit action in progress initiated by BeginEdit(). - */ - virtual void EndEdit( bool aClosed = false ) {} - - /** - * Calculate the attributes of an item at \a aPosition when it is being edited. - * - * This method gets called by the Draw() method when the item is being edited. This - * probably should be a pure virtual method but bezier curves are not yet editable in - * the symbol library editor. Therefore, the default method does nothing. - * - * @param aPosition The current mouse position in drawing coordinates. - */ - virtual void CalcEdit( const VECTOR2I& aPosition ) {} - - virtual int GetPenWidth() const = 0; - - const wxString& GetDefaultFont() const; - - const KIFONT::METRICS& GetFontMetrics() const; - - virtual int GetEffectivePenWidth( const SCH_RENDER_SETTINGS* aSettings ) const - { - // For historical reasons, a stored value of 0 means "default width" and negative - // numbers meant "don't stroke". - - if( GetPenWidth() < 0 ) - return 0; - else if( GetPenWidth() == 0 ) - return std::max( aSettings->GetDefaultPenWidth(), aSettings->GetMinPenWidth() ); - else - return std::max( GetPenWidth(), aSettings->GetMinPenWidth() ); - } - - const SYMBOL* GetParentSymbol() const - { - wxCHECK( m_parent->Type() == LIB_SYMBOL_T, nullptr ); - return static_cast( m_parent ); - } - - SYMBOL* GetParentSymbol() - { - wxCHECK( m_parent->Type() == LIB_SYMBOL_T, nullptr ); - return static_cast( m_parent ); - } - - /** - * Return a measure of how likely the other object is to represent the same - * object. The scale runs from 0.0 (definitely different objects) to 1.0 (same) - * - * This is a pure virtual function. Derived classes must implement this. - */ - virtual double Similarity( const LIB_ITEM& aItem ) const = 0; - - /** - * Calculate the boilerplate similarity for all LIB_ITEMs without - * preventing the use above of a pure virtual function that catches at compile - * time when a new object has not been fully implemented - */ - double SimilarityBase( const LIB_ITEM& aItem ) const - { - double similarity = 1.0; - - if( m_unit != aItem.m_unit ) - similarity *= 0.9; - - if( m_bodyStyle != aItem.m_bodyStyle ) - similarity *= 0.9; - - if( m_private != aItem.m_private ) - similarity *= 0.9; - - return similarity; - } - - void ViewGetLayers( int aLayers[], int& aCount ) const override; - - bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override - { - // This is just here to prevent annoying compiler warnings about hidden overloaded - // virtual functions - return EDA_ITEM::HitTest( aPosition, aAccuracy ); - } - - bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override; - - /** - * @return the boundary box for this, in library coordinates - */ - const BOX2I GetBoundingBox() const override { return EDA_ITEM::GetBoundingBox(); } - - /** - * Display basic info (type, part and convert) about the current item in message panel. - *

- * This base function is used to display the information common to the - * all library items. Call the base class from the derived class or the - * common information will not be updated in the message panel. - *

- * @param aList is the list to populate. - */ - void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - - /** - * Test LIB_ITEM objects for equivalence. - * - * @param aOther Object to test against. - * @return True if object is identical to this object. - */ - virtual bool operator==( const LIB_ITEM& aOther ) const; - bool operator==( const LIB_ITEM* aOther ) const - { - return *this == *aOther; - } - - /** - * Test if another draw item is less than this draw object. - * - * @param aOther - Draw item to compare against. - * @return - True if object is less than this object. - */ - bool operator<( const LIB_ITEM& aOther) const; - - /** - * Set the drawing object by \a aOffset from the current position. - * - * @param aOffset Coordinates to offset the item position. - */ - virtual void Offset( const VECTOR2I& aOffset ) = 0; - - /** - * Move a draw object to \a aPosition. - * - * @param aPosition Position to move draw item to. - */ - virtual void MoveTo( const VECTOR2I& aPosition ) = 0; - - void SetPosition( const VECTOR2I& aPosition ) override { MoveTo( aPosition ); } - - /** - * Mirror the draw object along the horizontal (X) axis about \a aCenter point. - * - * @param aCenter Point to mirror around. - */ - virtual void MirrorHorizontally( int aCenter ) = 0; - - /** - * Mirror the draw object along the MirrorVertical (Y) axis about \a aCenter point. - * - * @param aCenter Point to mirror around. - */ - virtual void MirrorVertically( int aCenter ) = 0; - - /** - * Rotate the object about \a aCenter point. - * - * @param aCenter Point to rotate around. - * @param aRotateCCW True to rotate counter clockwise. False to rotate clockwise. - */ - virtual void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) = 0; - - /** - * Print an item. - * - * @param aUnit - which unit to print. - * @param aBodyStyle - which body style to print. - * @param aOffset - relative offset. - * @param aForceNoFill - disable printing of fills. - * @param aDimmed - reduce brightness of item. - */ - virtual void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, - const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) = 0; - - /** - * Plot the item to \a aPlotter. - * - * @param aBackground a poor-man's Z-order. The routine will get called twice, first with - * aBackground true and then with aBackground false. - * @param aUnit - which unit to print. - * @param aBodyStyle - which body style to print. - * @param aOffset relative offset. - * @param aDimmed reduce brightness of item. - */ - virtual void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, - int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) = 0; - - void SetUnit( int aUnit ) { m_unit = aUnit; } - int GetUnit() const { return m_unit; } - - void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; } - int GetBodyStyle() const { return m_bodyStyle; } - - void SetPrivate( bool aPrivate ) { m_private = aPrivate; } - bool IsPrivate() const { return m_private; } - - struct cmp_items - { - bool operator()( const LIB_ITEM* aFirst, const LIB_ITEM* aSecond ) const; - }; - -#if defined(DEBUG) - void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } -#endif - -protected: - SCH_RENDER_SETTINGS* getRenderSettings( PLOTTER* aPlotter ) const - { - return static_cast( aPlotter->RenderSettings() ); - } - - /** - * Provide the draw object specific comparison called by the == and < operators. - * - * The base object sort order which always proceeds the derived object sort order - * is as follows: - * - Symbol alternate part (DeMorgan) number. - * - Symbol part number. - * - KICAD_T enum value. - * - Result of derived classes comparison. - * - * @note Make sure you call down to #LIB_ITEM::compare before doing any derived object - * comparisons or you will break the sorting using the symbol library file format. - * - * @param aOther A reference to the other #LIB_ITEM to compare the arc against. - * @param aCompareFlags The flags used to perform the comparison. - * - * @return An integer value less than 0 if the object is less than \a aOther object, - * zero if the object is equal to \a aOther object, or greater than 0 if the - * object is greater than \a aOther object. - */ - virtual int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const; - -private: - friend class LIB_SYMBOL; - -protected: - /** - * Unit identification for multiple parts per package. Set to 0 if the item is common - * to all units. - */ - int m_unit; - - /** - * Shape identification for alternate body styles. Set 0 if the item is common to all - * body styles. This is typially used for representing DeMorgan variants in KiCad. - */ - int m_bodyStyle; - - /** - * Private items are shown only in the Symbol Editor. - */ - bool m_private; -}; - - -#endif // _LIB_ITEM_H_ diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 079760c964..1c2631d3f4 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 1992-2023 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 @@ -94,8 +94,8 @@ static int externalPinDecoSize( const RENDER_SETTINGS* aSettings, const LIB_PIN } -LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent ) : - LIB_ITEM( LIB_PIN_T, aParent ), +LIB_PIN::LIB_PIN( SCH_ITEM* aParent ) : + SCH_ITEM( aParent, LIB_PIN_T, 0, 0 ), m_orientation( PIN_ORIENTATION::PIN_RIGHT ), m_shape( GRAPHIC_PINSHAPE::LINE ), m_type( ELECTRICAL_PINTYPE::PT_UNSPECIFIED ), @@ -121,11 +121,11 @@ LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent ) : } -LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aNumber, +LIB_PIN::LIB_PIN( SCH_ITEM* aParent, const wxString& aName, const wxString& aNumber, PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength, int aNameTextSize, int aNumTextSize, int aBodyStyle, const VECTOR2I& aPos, int aUnit ) : - LIB_ITEM( LIB_PIN_T, aParent ), + SCH_ITEM( aParent, LIB_PIN_T, aUnit, aBodyStyle ), m_position( aPos ), m_length( aLength ), m_orientation( aOrientation ), @@ -137,8 +137,6 @@ LIB_PIN::LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aN { SetName( aName ); SetNumber( aNumber ); - SetUnit( aUnit ); - SetBodyStyle( aBodyStyle ); } @@ -988,15 +986,18 @@ PIN_ORIENTATION LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const EDA_ITEM* LIB_PIN::Clone() const { - return new LIB_PIN( *this ); + //return new LIB_PIN( *this ); + SCH_ITEM* newPin = new LIB_PIN( *this ); + wxASSERT( newPin->GetUnit() == m_unit && newPin->GetBodyStyle() == m_bodyStyle ); + return newPin; } -int LIB_PIN::compare( const LIB_ITEM& aOther, int aCompareFlags ) const +int LIB_PIN::compare( const SCH_ITEM& aOther, int aCompareFlags ) const { wxASSERT( aOther.Type() == LIB_PIN_T ); - int retv = LIB_ITEM::compare( aOther, aCompareFlags ); + int retv = SCH_ITEM::compare( aOther, aCompareFlags ); if( retv ) return retv; @@ -1005,7 +1006,7 @@ int LIB_PIN::compare( const LIB_ITEM& aOther, int aCompareFlags ) const // When comparing units, we do not compare the part numbers. If everything else is // identical, then we can just renumber the parts for the inherited symbol. - if( !( aCompareFlags & COMPARE_FLAGS::UNIT ) && m_number != tmp->m_number ) + if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT ) && m_number != tmp->m_number ) return m_number.Cmp( tmp->m_number ); int result = m_name.Cmp( tmp->m_name ); @@ -1092,23 +1093,17 @@ void LIB_PIN::ChangeLength( int aLength ) } VECTOR2I offset = VECTOR2I( offsetX, offsetY ); - Offset( offset ); + Move( offset ); m_length = aLength; } -void LIB_PIN::Offset( const VECTOR2I& aOffset ) +void LIB_PIN::Move( const VECTOR2I& aOffset ) { m_position += aOffset; } -void LIB_PIN::MoveTo( const VECTOR2I& aNewPosition ) -{ - m_position = aNewPosition; -} - - void LIB_PIN::MirrorHorizontally( int aCenter ) { m_position.x -= aCenter; @@ -1184,7 +1179,7 @@ void LIB_PIN::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aP void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { - LIB_ITEM::GetMsgPanelInfo( aFrame, aList ); + getSymbolEditorMsgPanelInfo( aFrame, aList ); aList.emplace_back( _( "Name" ), UnescapeString( GetShownName() ) ); aList.emplace_back( _( "Number" ), GetShownNumber() ); @@ -1456,7 +1451,7 @@ wxString LIB_PIN::getItemDescription( ALT* aAlt ) const } -bool LIB_PIN::operator==( const LIB_ITEM& aOther ) const +bool LIB_PIN::operator==( const SCH_ITEM& aOther ) const { if( aOther.Type() != LIB_PIN_T ) return false; @@ -1524,7 +1519,7 @@ bool LIB_PIN::operator==( const LIB_ITEM& aOther ) const } -double LIB_PIN::Similarity( const LIB_ITEM& aOther ) const +double LIB_PIN::Similarity( const SCH_ITEM& aOther ) const { if( aOther.m_Uuid == m_Uuid ) return 1.0; @@ -1606,7 +1601,7 @@ void LIB_PIN::Show( int nestLevel, std::ostream& os ) const void LIB_PIN::CalcEdit( const VECTOR2I& aPosition ) { if( IsMoving() ) - MoveTo( aPosition ); + SetPosition( aPosition ); } @@ -1659,8 +1654,8 @@ static struct LIB_PIN_DESC PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); REGISTER_TYPE( LIB_PIN ); - propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.InheritsAfter( TYPE_HASH( LIB_PIN ), TYPE_HASH( LIB_ITEM ) ); + propMgr.AddTypeCast( new TYPE_CAST ); + propMgr.InheritsAfter( TYPE_HASH( LIB_PIN ), TYPE_HASH( SCH_ITEM ) ); propMgr.AddProperty( new PROPERTY( _HKI( "Pin Name" ), &LIB_PIN::SetName, &LIB_PIN::GetName ) ); diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index b30c0224b0..e5d9f22d74 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -3,7 +3,7 @@ * * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors. + * 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 @@ -38,7 +38,7 @@ #define PIN_INVISIBLE 1 // Set makes pin invisible -class LIB_PIN : public LIB_ITEM +class LIB_PIN : public SCH_ITEM { public: struct ALT @@ -48,6 +48,14 @@ public: ELECTRICAL_PINTYPE m_Type; // Electrical type of the pin. }; + LIB_PIN( SCH_ITEM* aParent ); + + LIB_PIN( SCH_ITEM* aParent, const wxString& aName, const wxString& aNumber, + PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength, + int aNameTextSize, int aNumTextSize, int aConvert, const VECTOR2I& aPos, int aUnit ); + + // Do not create a copy constructor. The one generated by the compiler is adequate. + ~LIB_PIN() { } wxString GetClass() const override @@ -154,14 +162,6 @@ public: */ PIN_ORIENTATION PinDrawOrient( const TRANSFORM& aTransform ) const; - LIB_PIN( LIB_SYMBOL* aParent ); - - LIB_PIN( LIB_SYMBOL* aParent, const wxString& aName, const wxString& aNumber, - PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength, - int aNameTextSize, int aNumTextSize, int aConvert, const VECTOR2I& aPos, int aUnit ); - - // Do not create a copy constructor. The one generated by the compiler is adequate. - // No, LIB_PINs don't really have operating poinst. But we draw SCH_PINs through their LIB_PIN // counterparts, so here we are.... const wxString& GetOperatingPoint() const { return m_operatingPoint; } @@ -204,9 +204,7 @@ public: int GetPenWidth() const override; - void Offset( const VECTOR2I& aOffset ) override; - - void MoveTo( const VECTOR2I& aNewPosition ) override; + void Move( const VECTOR2I& aOffset ) override; VECTOR2I GetPosition() const override { return m_position; } void SetPosition( const VECTOR2I& aPos ) override { m_position = aPos; } @@ -258,10 +256,10 @@ public: */ static const wxString GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType ); - double Similarity( const LIB_ITEM& aItem ) const override; + double Similarity( const SCH_ITEM& aItem ) const override; - bool operator==( const LIB_ITEM& aItem ) const override; - bool operator!=( const LIB_ITEM& aItem ) const { return !operator==( aItem ); } + bool operator==( const SCH_ITEM& aItem ) const override; + bool operator!=( const SCH_ITEM& aItem ) const { return !operator==( aItem ); } bool operator<( const LIB_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) < 0; } bool operator>( const LIB_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) > 0; } @@ -306,7 +304,7 @@ protected: private: /** - * @copydoc LIB_ITEM::compare() + * @copydoc SCH_ITEM::compare() * * The pin specific sort order is as follows: * - Pin number. @@ -314,7 +312,7 @@ private: * - Pin horizontal (X) position. * - Pin vertical (Y) position. */ - int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override; + int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override; protected: VECTOR2I m_position; // Position of the pin. diff --git a/eeschema/lib_shape.cpp b/eeschema/lib_shape.cpp index 740cdf3a17..336a41f54d 100644 --- a/eeschema/lib_shape.cpp +++ b/eeschema/lib_shape.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors. + * 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 @@ -31,12 +31,11 @@ #include #include #include -#include "plotters/plotter.h" -LIB_SHAPE::LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape, int aLineWidth, FILL_T aFillType, +LIB_SHAPE::LIB_SHAPE( SCH_ITEM* aParent, SHAPE_T aShape, int aLineWidth, FILL_T aFillType, KICAD_T aType ) : - LIB_ITEM( aType, aParent ), + SCH_ITEM( aParent, aType ), EDA_SHAPE( aShape, aLineWidth, aFillType ) { m_editState = 0; @@ -67,9 +66,9 @@ EDA_ITEM* LIB_SHAPE::Clone() const } -int LIB_SHAPE::compare( const LIB_ITEM& aOther, int aCompareFlags ) const +int LIB_SHAPE::compare( const SCH_ITEM& aOther, int aCompareFlags ) const { - int retv = LIB_ITEM::compare( aOther, aCompareFlags ); + int retv = SCH_ITEM::compare( aOther, aCompareFlags ); if( retv ) return retv; @@ -78,18 +77,12 @@ int LIB_SHAPE::compare( const LIB_ITEM& aOther, int aCompareFlags ) const } -void LIB_SHAPE::Offset( const VECTOR2I& aOffset ) +void LIB_SHAPE::Move( const VECTOR2I& aOffset ) { move( aOffset ); } -void LIB_SHAPE::MoveTo( const VECTOR2I& aPosition ) -{ - setPosition( aPosition ); -} - - void LIB_SHAPE::Normalize() { if( GetShape() == SHAPE_T::RECTANGLE ) @@ -448,7 +441,7 @@ const BOX2I LIB_SHAPE::GetBoundingBox() const void LIB_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { - LIB_ITEM::GetMsgPanelInfo( aFrame, aList ); + getSymbolEditorMsgPanelInfo( aFrame, aList ); ShapeGetMsgPanelInfo( aFrame, aList ); } @@ -520,18 +513,18 @@ void LIB_SHAPE::AddPoint( const VECTOR2I& aPosition ) } -bool LIB_SHAPE::operator==( const LIB_ITEM& aOther ) const +bool LIB_SHAPE::operator==( const SCH_ITEM& aOther ) const { if( aOther.Type() != Type() ) return false; const LIB_SHAPE& other = static_cast( aOther ); - return LIB_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other ); + return SCH_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other ); } -double LIB_SHAPE::Similarity( const LIB_ITEM& aOther ) const +double LIB_SHAPE::Similarity( const SCH_ITEM& aOther ) const { if( m_Uuid == aOther.m_Uuid ) return 1.0; @@ -564,9 +557,9 @@ static struct LIB_SHAPE_DESC { PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); REGISTER_TYPE( LIB_SHAPE ); - propMgr.AddTypeCast( new TYPE_CAST ); + propMgr.AddTypeCast( new TYPE_CAST ); propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.InheritsAfter( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( LIB_ITEM ) ); + propMgr.InheritsAfter( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( SCH_ITEM ) ); propMgr.InheritsAfter( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( EDA_SHAPE ) ); // Only polygons have meaningful Position properties. @@ -580,9 +573,9 @@ static struct LIB_SHAPE_DESC return false; }; - propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( LIB_ITEM ), + propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( SCH_ITEM ), _HKI( "Position X" ), isPolygon ); - propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( LIB_ITEM ), + propMgr.OverrideAvailability( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( SCH_ITEM ), _HKI( "Position Y" ), isPolygon ); propMgr.Mask( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Filled" ) ); diff --git a/eeschema/lib_shape.h b/eeschema/lib_shape.h index 3eab67a135..3b6204f084 100644 --- a/eeschema/lib_shape.h +++ b/eeschema/lib_shape.h @@ -2,7 +2,7 @@ * 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-2022 KiCad Developers, see AUTHORS.txt for contributors. + * 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 @@ -25,14 +25,14 @@ #ifndef LIB_SHAPE_H #define LIB_SHAPE_H -#include +#include #include -class LIB_SHAPE : public LIB_ITEM, public EDA_SHAPE +class LIB_SHAPE : public SCH_ITEM, public EDA_SHAPE { public: - LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape = SHAPE_T::UNDEFINED, int aLineWidth = 0, + LIB_SHAPE( SCH_ITEM* aParent, SHAPE_T aShape = SHAPE_T::UNDEFINED, int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL, KICAD_T aType = LIB_SHAPE_T ); // Do not create a copy constructor. The one generated by the compiler is adequate. @@ -54,8 +54,8 @@ public: return ShowShape(); } - STROKE_PARAMS GetStroke() const { return m_stroke; } - void SetStroke( const STROKE_PARAMS& aStroke ) { m_stroke = aStroke; } + STROKE_PARAMS GetStroke() const override { return m_stroke; } + void SetStroke( const STROKE_PARAMS& aStroke ) override { m_stroke = aStroke; } bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override; @@ -83,9 +83,7 @@ public: void AddPoint( const VECTOR2I& aPosition ); - void Offset( const VECTOR2I& aOffset ) override; - - void MoveTo( const VECTOR2I& aPosition ) override; + void Move( const VECTOR2I& aOffset ) override; VECTOR2I GetPosition() const override { return getPosition(); } void SetPosition( const VECTOR2I& aPosition ) override { setPosition( aPosition ); } @@ -123,20 +121,20 @@ public: void ViewGetLayers( int aLayers[], int& aCount ) const override; - double Similarity( const LIB_ITEM& aOther ) const override; + double Similarity( const SCH_ITEM& aOther ) const override; - bool operator==( const LIB_ITEM& aOther ) const override; + bool operator==( const SCH_ITEM& aOther ) const override; private: /** - * @copydoc LIB_ITEM::compare() + * @copydoc SCH_ITEM::compare() * * The circle specific sort order is as follows: * - Circle horizontal (X) position. * - Circle vertical (Y) position. * - Circle radius. */ - int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override; + int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override; }; diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 6c3659ee30..1e987a406c 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -70,7 +70,7 @@ std::vector LIB_SYMBOL::GetSearchTerms() void LIB_SYMBOL::GetChooserFields( std::map& aColumnMap ) { - for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] ) + for( SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] ) { LIB_FIELD* field = static_cast( &item ); @@ -124,8 +124,6 @@ LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary ) : SYMBOL( aSymbol ), m_me( this, null_deleter() ) { - LIB_ITEM* newItem; - m_library = aLibrary; m_name = aSymbol.m_name; m_fpFilters = wxArrayString( aSymbol.m_fpFilters ); @@ -140,21 +138,21 @@ LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary ) : ClearSelected(); - for( const LIB_ITEM& oldItem : aSymbol.m_drawings ) + for( const SCH_ITEM& oldItem : aSymbol.m_drawings ) { if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 ) continue; try { - newItem = (LIB_ITEM*) oldItem.Clone(); + SCH_ITEM* newItem = (SCH_ITEM*) oldItem.Clone(); newItem->ClearSelected(); newItem->SetParent( this ); m_drawings.push_back( newItem ); } catch( ... ) { - wxFAIL_MSG( "Failed to clone LIB_ITEM." ); + wxFAIL_MSG( "Failed to clone SCH_ITEM." ); return; } } @@ -171,7 +169,7 @@ const LIB_SYMBOL& LIB_SYMBOL::operator=( const LIB_SYMBOL& aSymbol ) if( &aSymbol == this ) return aSymbol; - LIB_ITEM* newItem; + SCH_ITEM* newItem; m_library = aSymbol.m_library; m_name = aSymbol.m_name; @@ -194,12 +192,12 @@ const LIB_SYMBOL& LIB_SYMBOL::operator=( const LIB_SYMBOL& aSymbol ) m_drawings.clear(); - for( const LIB_ITEM& oldItem : aSymbol.m_drawings ) + for( const SCH_ITEM& oldItem : aSymbol.m_drawings ) { if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 ) continue; - newItem = (LIB_ITEM*) oldItem.Clone(); + newItem = (SCH_ITEM*) oldItem.Clone(); newItem->SetParent( this ); m_drawings.push_back( newItem ); } @@ -241,7 +239,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR if( m_me == aRhs.m_me ) return 0; - if( !aReporter && ( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::ERC ) == 0 ) + if( !aReporter && ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) == 0 ) { if( int tmp = m_name.Cmp( aRhs.m_name ) ) return tmp; @@ -279,9 +277,9 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR // Make sure shapes and pins are sorted. No need with fields as those are // matched by id/name. - std::set aShapes; - std::set aFields; - std::set aPins; + std::set aShapes; + std::set aFields; + std::set aPins; for( auto it = m_drawings.begin(); it != m_drawings.end(); ++it ) { @@ -293,9 +291,9 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR aPins.insert( &(*it) ); } - std::set bShapes; - std::set bFields; - std::set bPins; + std::set bShapes; + std::set bFields; + std::set bPins; for( auto it = aRhs.m_drawings.begin(); it != aRhs.m_drawings.end(); ++it ) { @@ -340,7 +338,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR } else { - for( const LIB_ITEM* aPinItem : aPins ) + for( const SCH_ITEM* aPinItem : aPins ) { const LIB_PIN* aPin = static_cast( aPinItem ); const LIB_PIN* bPin = aRhs.GetPin( aPin->GetNumber(), aPin->GetUnit(), @@ -365,7 +363,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR } } - for( const LIB_ITEM* aFieldItem : aFields ) + for( const SCH_ITEM* aFieldItem : aFields ) { const LIB_FIELD* aField = static_cast( aFieldItem ); const LIB_FIELD* bField = nullptr; @@ -441,7 +439,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR return retv; } - if( ( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::ERC ) == 0 ) + if( ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) == 0 ) { if( m_showPinNames != aRhs.m_showPinNames ) { @@ -606,7 +604,7 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const } // Grab all the rest of derived symbol fields. - for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] ) + for( const SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] ) { const LIB_FIELD* aliasField = dynamic_cast( &item ); @@ -737,7 +735,7 @@ wxString LIB_SYMBOL::LetterSubReference( int aUnit, int aFirstId ) void LIB_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) { - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) { // Do not print private items if( item.IsPrivate() ) @@ -795,7 +793,7 @@ void LIB_SYMBOL::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUni */ if( !GetGRForceBlackPenState() ) { - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) { // Do not print private items if( item.IsPrivate() ) @@ -840,7 +838,7 @@ void LIB_SYMBOL::Plot( PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotter->SetColor( color ); - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) { // Do not plot private items if( item.IsPrivate() ) @@ -883,7 +881,7 @@ void LIB_SYMBOL::PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT aPlotter->SetColor( color ); - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) { if( item.Type() != LIB_FIELD_T ) continue; @@ -912,9 +910,9 @@ void LIB_SYMBOL::PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT void LIB_SYMBOL::FixupDrawItems() { std::vector potential_top_items; - std::vector bottom_items; + std::vector bottom_items; - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) { if( item.Type() == LIB_SHAPE_T ) { @@ -932,14 +930,14 @@ void LIB_SYMBOL::FixupDrawItems() } std::sort( potential_top_items.begin(), potential_top_items.end(), - []( LIB_ITEM* a, LIB_ITEM* b ) + []( SCH_ITEM* a, SCH_ITEM* b ) { return a->GetBoundingBox().GetArea() > b->GetBoundingBox().GetArea(); } ); for( LIB_SHAPE* item : potential_top_items ) { - for( LIB_ITEM* bottom_item : bottom_items ) + for( SCH_ITEM* bottom_item : bottom_items ) { if( item->GetBoundingBox().Contains( bottom_item->GetBoundingBox() ) ) { @@ -951,7 +949,7 @@ void LIB_SYMBOL::FixupDrawItems() } -void LIB_SYMBOL::RemoveDrawItem( LIB_ITEM* aItem ) +void LIB_SYMBOL::RemoveDrawItem( SCH_ITEM* aItem ) { wxASSERT( aItem != nullptr ); @@ -976,7 +974,7 @@ void LIB_SYMBOL::RemoveDrawItem( LIB_ITEM* aItem ) } -void LIB_SYMBOL::AddDrawItem( LIB_ITEM* aItem, bool aSort ) +void LIB_SYMBOL::AddDrawItem( SCH_ITEM* aItem, bool aSort ) { wxCHECK( aItem, /* void */ ); @@ -987,7 +985,7 @@ void LIB_SYMBOL::AddDrawItem( LIB_ITEM* aItem, bool aSort ) } -void LIB_SYMBOL::GetPins( LIB_PINS& aList, int aUnit, int aBodyStyle ) const +void LIB_SYMBOL::GetPins( std::vector& aList, int aUnit, int aBodyStyle ) const { /* Notes: * when aUnit == 0: no unit filtering @@ -999,7 +997,7 @@ void LIB_SYMBOL::GetPins( LIB_PINS& aList, int aUnit, int aBodyStyle ) const LIB_SYMBOL_SPTR parent = m_parent.lock(); const LIB_ITEMS_CONTAINER& drawItems = parent ? parent->m_drawings : m_drawings; - for( const LIB_ITEM& item : drawItems[LIB_PIN_T] ) + for( const SCH_ITEM& item : drawItems[LIB_PIN_T] ) { // Unit filtering: if( aUnit && item.m_unit && ( item.m_unit != aUnit ) ) @@ -1034,7 +1032,7 @@ int LIB_SYMBOL::GetPinCount() LIB_PIN* LIB_SYMBOL::GetPin( const wxString& aNumber, int aUnit, int aBodyStyle ) const { - LIB_PINS pinList; + std::vector pinList; GetPins( pinList, aUnit, aBodyStyle ); @@ -1053,13 +1051,13 @@ LIB_PIN* LIB_SYMBOL::GetPin( const wxString& aNumber, int aUnit, int aBodyStyle bool LIB_SYMBOL::PinsConflictWith( const LIB_SYMBOL& aOtherPart, bool aTestNums, bool aTestNames, bool aTestType, bool aTestOrientation, bool aTestLength ) const { - LIB_PINS thisPinList; + std::vector thisPinList; GetPins( thisPinList, /* aUnit */ 0, /* aBodyStyle */ 0 ); for( const LIB_PIN* eachThisPin : thisPinList ) { wxASSERT( eachThisPin ); - LIB_PINS otherPinList; + std::vector otherPinList; aOtherPart.GetPins( otherPinList, /* aUnit */ 0, /* aBodyStyle */ 0 ); bool foundMatch = false; @@ -1122,7 +1120,7 @@ const BOX2I LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aBodyStyle, { BOX2I bBox; // Start with a fresh BOX2I so the Merge algorithm works - for( const LIB_ITEM& item : m_drawings ) + for( const SCH_ITEM& item : m_drawings ) { if( item.m_unit > 0 && m_unitCount > 1 && aUnit > 0 && aUnit != item.m_unit ) continue; @@ -1148,7 +1146,7 @@ const BOX2I LIB_SYMBOL::GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aInc { BOX2I bbox; - for( const LIB_ITEM& item : m_drawings ) + for( const SCH_ITEM& item : m_drawings ) { if( item.m_unit > 0 && aUnit > 0 && aUnit != item.m_unit ) continue; @@ -1223,7 +1221,7 @@ void LIB_SYMBOL::GetFields( std::vector& aList ) aList.push_back( GetFieldById( id ) ); // Now grab all the rest of fields. - for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] ) + for( SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] ) { LIB_FIELD* field = static_cast( &item ); @@ -1240,7 +1238,7 @@ void LIB_SYMBOL::GetFields( std::vector& aList ) aList.push_back( *GetFieldById( id ) ); // Now grab all the rest of fields. - for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] ) + for( SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] ) { LIB_FIELD* field = static_cast( &item ); @@ -1252,7 +1250,7 @@ void LIB_SYMBOL::GetFields( std::vector& aList ) LIB_FIELD* LIB_SYMBOL::GetFieldById( int aId ) const { - for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] ) + for( const SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] ) { LIB_FIELD* field = ( LIB_FIELD* ) &item; @@ -1266,7 +1264,7 @@ LIB_FIELD* LIB_SYMBOL::GetFieldById( int aId ) const LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName, bool aCaseInsensitive ) { - for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] ) + for( SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] ) { if( aCaseInsensitive ) { @@ -1287,7 +1285,7 @@ LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName, bool aCaseInsensit const LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName, bool aCaseInsensitive ) const { - for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] ) + for( const SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] ) { const LIB_FIELD& field = static_cast( item ); @@ -1373,9 +1371,9 @@ wxString LIB_SYMBOL::GetPrefix() } -void LIB_SYMBOL::RunOnLibChildren( const std::function& aFunction ) +void LIB_SYMBOL::RunOnChildren( const std::function& aFunction ) { - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) aFunction( &item ); } @@ -1385,7 +1383,7 @@ int LIB_SYMBOL::UpdateFieldOrdinals() int retv = 0; int lastOrdinal = MANDATORY_FIELDS; - for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] ) + for( SCH_ITEM& item : m_drawings[ LIB_FIELD_T ] ) { LIB_FIELD* field = static_cast( &item ); @@ -1419,24 +1417,24 @@ int LIB_SYMBOL::GetNextAvailableFieldId() const void LIB_SYMBOL::Move( const VECTOR2I& aOffset ) { - for( LIB_ITEM& item : m_drawings ) - item.Offset( aOffset ); + for( SCH_ITEM& item : m_drawings ) + item.Move( aOffset ); } bool LIB_SYMBOL::HasAlternateBodyStyle() const { - for( const LIB_ITEM& item : m_drawings ) + for( const SCH_ITEM& item : m_drawings ) { - if( item.m_bodyStyle > LIB_ITEM::BODY_STYLE::BASE ) + if( item.m_bodyStyle > BODY_STYLE::BASE ) return true; } if( LIB_SYMBOL_SPTR parent = m_parent.lock() ) { - for( const LIB_ITEM& item : parent->GetDrawItems() ) + for( const SCH_ITEM& item : parent->GetDrawItems() ) { - if( item.m_bodyStyle > LIB_ITEM::BODY_STYLE::BASE ) + if( item.m_bodyStyle > BODY_STYLE::BASE ) return true; } } @@ -1451,7 +1449,7 @@ int LIB_SYMBOL::GetMaxPinNumber() const LIB_SYMBOL_SPTR parent = m_parent.lock(); const LIB_ITEMS_CONTAINER& drawItems = parent ? parent->m_drawings : m_drawings; - for( const LIB_ITEM& item : drawItems[LIB_PIN_T] ) + for( const SCH_ITEM& item : drawItems[LIB_PIN_T] ) { const LIB_PIN* pin = static_cast( &item ); long currentPinNumber = 0; @@ -1466,22 +1464,26 @@ int LIB_SYMBOL::GetMaxPinNumber() const void LIB_SYMBOL::ClearTempFlags() { - for( LIB_ITEM& item : m_drawings ) + SCH_ITEM::ClearTempFlags(); + + for( SCH_ITEM& item : m_drawings ) item.ClearTempFlags(); } void LIB_SYMBOL::ClearEditFlags() { - for( LIB_ITEM& item : m_drawings ) + SCH_ITEM::ClearEditFlags(); + + for( SCH_ITEM& item : m_drawings ) item.ClearEditFlags(); } -LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, +SCH_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint ) { - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) { if( ( aUnit && item.m_unit && aUnit != item.m_unit ) || ( aBodyStyle && item.m_bodyStyle && aBodyStyle != item.m_bodyStyle ) @@ -1498,7 +1500,7 @@ LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, } -LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, +SCH_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint, const TRANSFORM& aTransform ) { /* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const @@ -1506,7 +1508,7 @@ LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, * because this function uses DefaultTransform as orient/mirror matrix * we temporary copy aTransform in DefaultTransform */ - LIB_ITEM* item; + SCH_ITEM* item; TRANSFORM transform = DefaultTransform; DefaultTransform = aTransform; @@ -1523,7 +1525,7 @@ INSPECT_RESULT LIB_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData, const std::vector& aScanTypes ) { // The part itself is never inspected, only its children - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) { if( item.IsType( aScanTypes ) ) { @@ -1560,22 +1562,22 @@ void LIB_SYMBOL::SetUnitCount( int aCount, bool aDuplicateDrawItems ) // Temporary storage for new items, as adding new items directly to // m_drawings may cause the buffer reallocation which invalidates the // iterators - std::vector< LIB_ITEM* > tmp; + std::vector tmp; - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) { if( item.m_unit != 1 ) continue; for( int j = prevCount + 1; j <= aCount; j++ ) { - LIB_ITEM* newItem = (LIB_ITEM*) item.Duplicate(); + SCH_ITEM* newItem = item.Duplicate(); newItem->m_unit = j; tmp.push_back( newItem ); } } - for( LIB_ITEM* item : tmp ) + for( SCH_ITEM* item : tmp ) m_drawings.push_back( item ); } @@ -1603,9 +1605,9 @@ void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePi { if( aDuplicatePins ) { - std::vector tmp; // Temporarily store the duplicated pins here. + std::vector tmp; // Temporarily store the duplicated pins here. - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) { // Only pins are duplicated. if( item.Type() != LIB_PIN_T ) @@ -1613,14 +1615,14 @@ void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePi if( item.m_bodyStyle == 1 ) { - LIB_ITEM* newItem = static_cast( item.Duplicate() ); + SCH_ITEM* newItem = item.Duplicate(); newItem->m_bodyStyle = 2; tmp.push_back( newItem ); } } // Transfer the new pins to the LIB_SYMBOL. - for( LIB_ITEM* item : tmp ) + for( SCH_ITEM* item : tmp ) m_drawings.push_back( item ); } } @@ -1642,11 +1644,11 @@ void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePi } -std::vector LIB_SYMBOL::GetUnitDrawItems( int aUnit, int aBodyStyle ) +std::vector LIB_SYMBOL::GetUnitDrawItems( int aUnit, int aBodyStyle ) { - std::vector unitItems; + std::vector unitItems; - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) { if( item.Type() == LIB_FIELD_T ) continue; @@ -1667,7 +1669,7 @@ std::vector LIB_SYMBOL::GetUnitDrawItems() { std::vector units; - for( LIB_ITEM& item : m_drawings ) + for( SCH_ITEM& item : m_drawings ) { if( item.Type() == LIB_FIELD_T ) continue; @@ -1738,8 +1740,8 @@ bool LIB_SYMBOL::operator==( const LIB_SYMBOL& aOther ) const return false; } - const LIB_PINS thisPinList = GetAllLibPins(); - const LIB_PINS otherPinList = aOther.GetAllLibPins(); + const std::vector thisPinList = GetAllLibPins(); + const std::vector otherPinList = aOther.GetAllLibPins(); if( thisPinList.size() != otherPinList.size() ) return false; @@ -1771,12 +1773,12 @@ double LIB_SYMBOL::Similarity( const SCH_ITEM& aOther ) const if( m_Uuid == aOther.m_Uuid ) return 1.0; - for( const LIB_ITEM& item : m_drawings ) + for( const SCH_ITEM& item : m_drawings ) { totalItems += 1; double max_similarity = 0.0; - for( const LIB_ITEM& otherItem : other.m_drawings ) + for( const SCH_ITEM& otherItem : other.m_drawings ) { double temp_similarity = item.Similarity( otherItem ); max_similarity = std::max( max_similarity, temp_similarity ); diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index e04f21d5d2..ba699d7d39 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -40,12 +40,13 @@ class REPORTER; class SYMBOL_LIB; class LIB_SYMBOL; class LIB_FIELD; +class LIB_PIN; class TEST_LIB_SYMBOL_FIXTURE; typedef std::shared_ptr LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL typedef std::weak_ptr LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL -typedef MULTIVECTOR LIB_ITEMS_CONTAINER; +typedef MULTIVECTOR LIB_ITEMS_CONTAINER; typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS; @@ -64,7 +65,7 @@ struct LIB_SYMBOL_UNIT { int m_unit; ///< The unit number. int m_bodyStyle; ///< The alternate body style of the unit. - std::vector m_items; ///< The items unique to this unit and alternate body style. + std::vector m_items; ///< The items unique to this unit and alternate body style. }; @@ -96,7 +97,7 @@ public: LIB_SYMBOL* dupe = new LIB_SYMBOL( *this, m_library ); const_cast( dupe->m_Uuid ) = KIID(); - for( LIB_ITEM& item : dupe->m_drawings ) + for( SCH_ITEM& item : dupe->m_drawings ) const_cast( item.m_Uuid ) = KIID(); return dupe; @@ -337,8 +338,7 @@ public: int GetUnit() const override { return 0; } int GetBodyStyle() const override { return 0; } - // JEY TODO: reconcile with RunOnChildren when LIB_ITEM collapses to SCH_ITEM - void RunOnLibChildren( const std::function& aFunction ); + void RunOnChildren( const std::function& aFunction ) override; /** * Order optional field indices. @@ -373,14 +373,14 @@ public: * @param aItem is the new draw object to add to the symbol. * @param aSort is the flag to determine if the newly added item should be sorted. */ - void AddDrawItem( LIB_ITEM* aItem, bool aSort = true ); + void AddDrawItem( SCH_ITEM* aItem, bool aSort = true ); /** * Remove draw \a aItem from list. * * @param aItem - Draw item to remove from list. */ - void RemoveDrawItem( LIB_ITEM* aItem ); + void RemoveDrawItem( SCH_ITEM* aItem ); void RemoveField( LIB_FIELD* aField ) { RemoveDrawItem( aField ); } @@ -397,7 +397,7 @@ public: * @param aBodyStyle - Symbol alternate body style of pins to collect. Set to 0 to get pins * from any DeMorgan variant of symbol. */ - void GetPins( LIB_PINS& aList, int aUnit = 0, int aBodyStyle = 0 ) const; + void GetPins( std::vector& aList, int aUnit = 0, int aBodyStyle = 0 ) const; /** * Return a list of pin pointers for all units / converts. Used primarily for SPICE where @@ -458,8 +458,8 @@ public: /** * Clears the status flag all draw objects in this symbol. */ - void ClearTempFlags(); - void ClearEditFlags(); + void ClearTempFlags() override; + void ClearEditFlags() override; /** * Locate a draw object. @@ -470,7 +470,7 @@ public: * @param aPoint - Coordinate for hit testing. * @return The draw object if found. Otherwise NULL. */ - LIB_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint ); + SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint ); /** * Locate a draw object (overlaid) @@ -482,7 +482,7 @@ public: * @param aTransform = the transform matrix * @return The draw object if found. Otherwise NULL. */ - LIB_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint, + SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint, const TRANSFORM& aTransform ); /** @@ -578,7 +578,7 @@ public: bool operator==( const LIB_SYMBOL& aSymbol ) const; bool operator!=( const LIB_SYMBOL& aSymbol ) const { - return Compare( aSymbol, LIB_ITEM::COMPARE_FLAGS::EQUALITY ) != 0; + return Compare( aSymbol, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) != 0; } const LIB_SYMBOL& operator=( const LIB_SYMBOL& aSymbol ); @@ -593,7 +593,7 @@ public: std::unique_ptr< LIB_SYMBOL > Flatten() const; /** - * Return a list of LIB_ITEM objects separated by unit and convert number. + * Return a list of SCH_ITEM objects separated by unit and convert number. * * @note This does not include LIB_FIELD objects since they are not associated with * unit and/or convert numbers. @@ -610,7 +610,7 @@ public: * * @return a list of unit items. */ - std::vector GetUnitDrawItems( int aUnit, int aBodyStyle ); + std::vector GetUnitDrawItems( int aUnit, int aBodyStyle ); /** * Return a measure of similarity between this symbol and \a aSymbol. diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 433e49bfaf..14b9cacd6a 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors. + * 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 @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -38,8 +37,8 @@ #include // For some default values #include -LIB_TEXT::LIB_TEXT( LIB_SYMBOL* aParent ) : - LIB_ITEM( LIB_TEXT_T, aParent ), +LIB_TEXT::LIB_TEXT( SCH_ITEM* aParent ) : + SCH_ITEM( aParent, LIB_TEXT_T ), EDA_TEXT( schIUScale, wxEmptyString ) { SetTextSize( VECTOR2I( schIUScale.MilsToIU( DEFAULT_TEXT_SIZE ), @@ -77,11 +76,11 @@ EDA_ITEM* LIB_TEXT::Clone() const } -int LIB_TEXT::compare( const LIB_ITEM& aOther, int aCompareFlags ) const +int LIB_TEXT::compare( const SCH_ITEM& aOther, int aCompareFlags ) const { wxASSERT( aOther.Type() == LIB_TEXT_T ); - int retv = LIB_ITEM::compare( aOther, aCompareFlags ); + int retv = SCH_ITEM::compare( aOther, aCompareFlags ); if( retv ) return retv; @@ -109,18 +108,12 @@ int LIB_TEXT::compare( const LIB_ITEM& aOther, int aCompareFlags ) const } -void LIB_TEXT::Offset( const VECTOR2I& aOffset ) +void LIB_TEXT::Move( const VECTOR2I& aOffset ) { EDA_TEXT::Offset( aOffset ); } -void LIB_TEXT::MoveTo( const VECTOR2I& newPosition ) -{ - SetTextPos( newPosition ); -} - - void LIB_TEXT::NormalizeJustification( bool inverse ) { if( GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER && GetVertJustify() == GR_TEXT_V_ALIGN_CENTER ) @@ -409,7 +402,7 @@ void LIB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector( aOther ); - return LIB_ITEM::operator==( aOther ) && EDA_TEXT::operator==( other ); + return SCH_ITEM::operator==( aOther ) && EDA_TEXT::operator==( other ); } -double LIB_TEXT::Similarity( const LIB_ITEM& aOther ) const +double LIB_TEXT::Similarity( const SCH_ITEM& aOther ) const { if( m_Uuid == aOther.m_Uuid ) return 1.0; @@ -524,9 +517,9 @@ static struct LIB_TEXT_DESC { PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); REGISTER_TYPE( LIB_TEXT ); - propMgr.AddTypeCast( new TYPE_CAST ); + propMgr.AddTypeCast( new TYPE_CAST ); propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.InheritsAfter( TYPE_HASH( LIB_TEXT ), TYPE_HASH( LIB_ITEM ) ); + 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" ) ); diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index 50d2a1d29a..6bdbbfb3a7 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -2,7 +2,7 @@ * 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-2022 KiCad Developers, see AUTHORS.txt for contributors. + * 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 @@ -26,7 +26,7 @@ #define LIB_TEXT_H #include -#include +#include /** @@ -36,10 +36,10 @@ * symbol value, etc. are not LIB_TEXT items. See the #LIB_FIELD class for the * field item definition. */ -class LIB_TEXT : public LIB_ITEM, public EDA_TEXT +class LIB_TEXT : public SCH_ITEM, public EDA_TEXT { public: - LIB_TEXT( LIB_SYMBOL* aParent ); + LIB_TEXT( SCH_ITEM* aParent ); // Do not create a copy constructor. The one generated by the compiler is adequate. @@ -91,11 +91,10 @@ public: void BeginEdit( const VECTOR2I& aStartPoint ) override; void CalcEdit( const VECTOR2I& aPosition ) override; - void Offset( const VECTOR2I& aOffset ) override; - - void MoveTo( 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; @@ -116,13 +115,13 @@ public: EDA_ITEM* Clone() const override; - double Similarity( const LIB_ITEM& aOther ) const override; + double Similarity( const SCH_ITEM& aOther ) const override; - bool operator==( const LIB_ITEM& aOther ) const override; + bool operator==( const SCH_ITEM& aOther ) const override; private: /** - * @copydoc LIB_ITEM::compare() + * @copydoc SCH_ITEM::compare() * * The text specific sort order is as follows: * - Text string, case insensitive compare. @@ -131,7 +130,7 @@ private: * - Text width. * - Text height. */ - int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override; + int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override; }; diff --git a/eeschema/lib_textbox.cpp b/eeschema/lib_textbox.cpp index 9a47dcd22b..57e1a79854 100644 --- a/eeschema/lib_textbox.cpp +++ b/eeschema/lib_textbox.cpp @@ -39,7 +39,7 @@ #include -LIB_TEXTBOX::LIB_TEXTBOX( LIB_SYMBOL* aParent, int aLineWidth, FILL_T aFillType, +LIB_TEXTBOX::LIB_TEXTBOX( SCH_ITEM* aParent, int aLineWidth, FILL_T aFillType, const wxString& text ) : LIB_SHAPE( aParent, SHAPE_T::RECTANGLE, aLineWidth, aFillType, LIB_TEXTBOX_T ), EDA_TEXT( schIUScale, text ) @@ -188,11 +188,11 @@ VECTOR2I LIB_TEXTBOX::GetDrawPos() const } -int LIB_TEXTBOX::compare( const LIB_ITEM& aOther, int aCompareFlags ) const +int LIB_TEXTBOX::compare( const SCH_ITEM& aOther, int aCompareFlags ) const { wxASSERT( aOther.Type() == LIB_TEXTBOX_T ); - int retv = LIB_ITEM::compare( aOther, aCompareFlags ); + int retv = SCH_ITEM::compare( aOther, aCompareFlags ); if( retv ) return retv; @@ -531,7 +531,7 @@ void LIB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector pinList; pinList.clear(); symbol->GetLibPins(pinList); @@ -450,7 +450,7 @@ void NETLIST_EXPORTER_ALLEGRO::toAllegroPackages() fprintf( d, "PACKAGE '%s'\n", TO_UTF8( formatDevice( footprintText ) ) ); fprintf( d, "CLASS IC\n" ); - LIB_PINS pinList; + std::vector pinList; sym->GetLibSymbolRef()->GetPins( pinList, 0, 0 ); /* @@ -592,7 +592,7 @@ wxString NETLIST_EXPORTER_ALLEGRO::formatPin( const LIB_PIN& aPin ) } -wxString NETLIST_EXPORTER_ALLEGRO::formatFunction( wxString aName, LIB_PINS aPinList ) +wxString NETLIST_EXPORTER_ALLEGRO::formatFunction( wxString aName, std::vector aPinList ) { aName.MakeUpper(); std::list pinNameList; diff --git a/eeschema/netlist_exporters/netlist_exporter_allegro.h b/eeschema/netlist_exporters/netlist_exporter_allegro.h index 96603e7a55..18f3a29ec3 100644 --- a/eeschema/netlist_exporters/netlist_exporter_allegro.h +++ b/eeschema/netlist_exporters/netlist_exporter_allegro.h @@ -142,7 +142,7 @@ private: * @param aPinList * @return wxString */ - wxString formatFunction( wxString aName, LIB_PINS aPinList ); + wxString formatFunction( wxString aName, std::vector aPinList ); /** * Look up a field for a component group, which may have mismatched case, or diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.cpp b/eeschema/netlist_exporters/netlist_exporter_xml.cpp index 166054f9a6..fe97d5f712 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -571,7 +571,7 @@ XNODE* NETLIST_EXPORTER_XML::makeLibParts() { XNODE* xlibparts = node( wxT( "libparts" ) ); // auto_ptr - LIB_PINS pinList; + std::vector pinList; std::vector fieldList; m_libraries.clear(); diff --git a/eeschema/picksymbol.cpp b/eeschema/picksymbol.cpp index c863bfac16..95d442e49a 100644 --- a/eeschema/picksymbol.cpp +++ b/eeschema/picksymbol.cpp @@ -151,8 +151,8 @@ void SCH_EDIT_FRAME::FlipBodyStyle( SCH_SYMBOL* aSymbol ) // 2 = shape 2 = second (DeMorgan conversion) alternate body style // > 2 is not currently supported // When m_bodyStyle = val max, return to the first shape - if( aSymbol->GetBodyStyle() > LIB_ITEM::BODY_STYLE::DEMORGAN ) - aSymbol->SetBodyStyle( LIB_ITEM::BODY_STYLE::BASE ); + if( aSymbol->GetBodyStyle() > BODY_STYLE::DEMORGAN ) + aSymbol->SetBodyStyle( BODY_STYLE::BASE ); // If selected make sure all the now-included pins are selected if( aSymbol->IsSelected() ) diff --git a/eeschema/sch_commit.cpp b/eeschema/sch_commit.cpp index ff98263bb9..a1a3d6151f 100644 --- a/eeschema/sch_commit.cpp +++ b/eeschema/sch_commit.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include @@ -133,8 +132,8 @@ void SCH_COMMIT::pushLibEdit( const wxString& aMessage, int aCommitFlags ) { view->Update( symbol ); - symbol->RunOnLibChildren( - [&]( LIB_ITEM* aChild ) + symbol->RunOnChildren( + [&]( SCH_ITEM* aChild ) { view->Update( aChild ); } ); @@ -424,7 +423,7 @@ EDA_ITEM* SCH_COMMIT::makeImage( EDA_ITEM* aItem ) const LIB_SYMBOL* symbol = frame->GetCurSymbol(); std::vector selected; - for( const LIB_ITEM& item : symbol->GetDrawItems() ) + for( const SCH_ITEM& item : symbol->GetDrawItems() ) { if( item.IsSelected() ) selected.push_back( item.m_Uuid ); @@ -432,7 +431,7 @@ EDA_ITEM* SCH_COMMIT::makeImage( EDA_ITEM* aItem ) const symbol = new LIB_SYMBOL( *symbol ); - for( LIB_ITEM& item : symbol->GetDrawItems() ) + for( SCH_ITEM& item : symbol->GetDrawItems() ) { if( alg::contains( selected, item.m_Uuid ) ) item.SetSelected(); diff --git a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp index 4638a3040c..29f4987d58 100644 --- a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp @@ -285,13 +285,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::copySymbolItems( std::unique_ptr& a int aDestUnit, bool aOverrideFields ) { // Ensure there are no items on the unit we want to load onto - for( LIB_ITEM* item : aDestSym->GetUnitDrawItems( aDestUnit, 0 /*aConvert*/ ) ) + for( SCH_ITEM* item : aDestSym->GetUnitDrawItems( aDestUnit, 0 /*aConvert*/ ) ) aDestSym->RemoveDrawItem( item ); // Copy all draw items - for( LIB_ITEM* newItem : aSourceSym->GetUnitDrawItems( 1, 0 /*aConvert*/ ) ) + for( SCH_ITEM* newItem : aSourceSym->GetUnitDrawItems( 1, 0 /*aConvert*/ ) ) { - LIB_ITEM* itemCopy = static_cast( newItem->Clone() ); + SCH_ITEM* itemCopy = static_cast( newItem->Clone() ); itemCopy->SetParent( aDestSym.get() ); itemCopy->SetUnit( aDestUnit ); aDestSym->AddDrawItem( itemCopy ); @@ -880,7 +880,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() kiPart->SetShowPinNames( false ); kiPart->SetShowPinNumbers( false ); - LIB_PINS pins = kiPart->GetAllLibPins(); + std::vector pins = kiPart->GetAllLibPins(); wxCHECK( pins.size() == 1, /*void*/ ); pins.at( 0 )->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN ); @@ -3232,7 +3232,7 @@ LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart( const LIB_SYMBOL* aSym LIB_ITEMS_CONTAINER& items = retval->GetDrawItems(); - for( LIB_ITEM& item : items ) + for( SCH_ITEM& item : items ) { switch( item.Type() ) { @@ -3326,7 +3326,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int } } - LIB_PINS pins; + std::vector pins; aSymbolToFix->GetPins( pins, aGateNumber ); for( auto& pin : pins ) diff --git a/eeschema/sch_io/eagle/sch_io_eagle.cpp b/eeschema/sch_io/eagle/sch_io_eagle.cpp index 3ae464a8b1..8a109d1b29 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.cpp +++ b/eeschema/sch_io/eagle/sch_io_eagle.cpp @@ -2137,7 +2137,7 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptrGetAttribute( wxT( "name" ) ); - std::vector items; + std::vector items; wxXmlNode* currentNode = aSymbolNode->GetChildren(); @@ -2256,11 +2256,11 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr frameItems; + std::vector frameItems; - loadFrame( currentNode, frameItems ); + loadSymbolFrame( currentNode, frameItems ); - for( LIB_ITEM* item : frameItems ) + for( SCH_ITEM* item : frameItems ) { item->SetParent( aSymbol.get() ); item->SetUnit( aGateNumber ); @@ -2338,7 +2338,7 @@ LIB_SHAPE* SCH_IO_EAGLE::loadSymbolRectangle( std::unique_ptr& aSymb } -LIB_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr& aSymbol, +SCH_ITEM* SCH_IO_EAGLE::loadSymbolWire( std::unique_ptr& aSymbol, wxXmlNode* aWireNode, int aGateNumber ) { EWIRE ewire = EWIRE( aWireNode ); @@ -2546,7 +2546,7 @@ LIB_TEXT* SCH_IO_EAGLE::loadSymbolText( std::unique_ptr& aSymbol, } -void SCH_IO_EAGLE::loadFrame( wxXmlNode* aFrameNode, std::vector& aItems ) +void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector& aItems ) { EFRAME eframe( aFrameNode ); diff --git a/eeschema/sch_io/eagle/sch_io_eagle.h b/eeschema/sch_io/eagle/sch_io_eagle.h index 0a42dfd91c..48320a63b5 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.h +++ b/eeschema/sch_io/eagle/sch_io_eagle.h @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -164,13 +163,13 @@ private: int aGateNumber ); LIB_SHAPE* loadSymbolPolyLine( std::unique_ptr& aSymbol, wxXmlNode* aPolygonNode, int aGateNumber ); - LIB_ITEM* loadSymbolWire( std::unique_ptr& aSymbol, wxXmlNode* aWireNode, + SCH_ITEM* loadSymbolWire( std::unique_ptr& aSymbol, wxXmlNode* aWireNode, int aGateNumber ); LIB_PIN* loadPin( std::unique_ptr& aSymbol, wxXmlNode*, EPIN* epin, int aGateNumber ); LIB_TEXT* loadSymbolText( std::unique_ptr& aSymbol, wxXmlNode* aLibText, int aGateNumber ); - void loadFrame( wxXmlNode* aFrameNode, std::vector& aLines ); + void loadSymbolFrame( wxXmlNode* aFrameNode, std::vector& aLines ); void loadTextAttributes( EDA_TEXT* aText, const ETEXT& aAttribs ) const; void loadFieldAttributes( LIB_FIELD* aField, const LIB_TEXT* aText ) const; diff --git a/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp b/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp index fd7a64f409..c7a20dc1ec 100644 --- a/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp +++ b/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp @@ -522,7 +522,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol svgImportPlugin.Import(); for( std::unique_ptr& item : libsymImporter.GetItems() ) - aSymbol->AddDrawItem( static_cast( item.release() ) ); + aSymbol->AddDrawItem( static_cast( item.release() ) ); } else { @@ -948,7 +948,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol TransformTextToBaseline( textItem, baselineAlign, true ); if( added ) - aSymbol->AddDrawItem( dynamic_cast( textItem ) ); + aSymbol->AddDrawItem( dynamic_cast( textItem ) ); } } } diff --git a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp index ebd5aee3a6..6c51f870cf 100644 --- a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp +++ b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp @@ -601,7 +601,7 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector& item : libsymImporter.GetItems() ) - ksymbol->AddDrawItem( static_cast( item.release() ) ); + ksymbol->AddDrawItem( static_cast( item.release() ) ); } else { diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp index d9ab2680a4..bf787dd630 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp @@ -56,6 +56,9 @@ ( LIB_VERSION( major, minor ) <= LIB_VERSION( 2, 4 ) ) +const int fill_tab[3] = { 'N', 'F', 'f' }; + + SCH_IO_KICAD_LEGACY_LIB_CACHE::SCH_IO_KICAD_LEGACY_LIB_CACHE( const wxString& aFullPathAndFileName ) : SCH_IO_LIB_CACHE( aFullPathAndFileName ) { @@ -1573,7 +1576,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMA aFormatter.Print( 0, "DRAW\n" ); - for( LIB_ITEM& item : aSymbol->GetDrawItems() ) + for( SCH_ITEM& item : aSymbol->GetDrawItems() ) { switch( item.Type() ) { diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp index 0eefddf981..831f75e695 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp @@ -724,7 +724,7 @@ void SCH_IO_KICAD_SEXPR::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSche m_out->Print( 0, " (unit %d)", unit ); - if( aSymbol->GetBodyStyle() == LIB_ITEM::BODY_STYLE::DEMORGAN ) + if( aSymbol->GetBodyStyle() == BODY_STYLE::DEMORGAN ) m_out->Print( 0, " (convert %d)", aSymbol->GetBodyStyle() ); m_out->Print( 0, "\n" ); diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp index c3a07ef8fb..b23b14214a 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp @@ -246,17 +246,17 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT } // Enforce item ordering auto cmp = - []( const LIB_ITEM* a, const LIB_ITEM* b ) + []( const SCH_ITEM* a, const SCH_ITEM* b ) { return *a < *b; }; - std::multiset save_map( cmp ); + std::multiset save_map( cmp ); - for( LIB_ITEM* item : unit.m_items ) + for( SCH_ITEM* item : unit.m_items ) save_map.insert( item ); - for( LIB_ITEM* item : save_map ) + for( SCH_ITEM* item : save_map ) saveSymbolDrawItem( item, aFormatter, aNestLevel + 2 ); aFormatter.Print( aNestLevel + 1, ")\n" ); @@ -327,10 +327,10 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, } -void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveSymbolDrawItem( LIB_ITEM* aItem, OUTPUTFORMATTER& aFormatter, +void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFORMATTER& aFormatter, int aNestLevel ) { - wxCHECK_RET( aItem, "Invalid LIB_ITEM pointer." ); + wxCHECK_RET( aItem, "Invalid SCH_ITEM pointer." ); switch( aItem->Type() ) { diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h index 352a686125..05983a6f31 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h @@ -26,7 +26,6 @@ class FILE_LINE_READER; class LIB_FIELD; -class LIB_ITEM; class LIB_PIN; class LIB_TEXT; class LIB_TEXTBOX; @@ -64,7 +63,7 @@ private: int m_fileFormatVersionAtLoad; - static void saveSymbolDrawItem( LIB_ITEM* aItem, OUTPUTFORMATTER& aFormatter, + static void saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFORMATTER& aFormatter, int aNestLevel ); static void saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFormatter, int aNestLevel ); static void savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp index 4c6649a406..db67a6ee60 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp @@ -290,7 +290,7 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi wxString name; wxString error; wxString unitDisplayName; - LIB_ITEM* item; + SCH_ITEM* item; std::unique_ptr symbol = std::make_unique( wxEmptyString ); symbol->SetUnitCount( 1 ); @@ -548,7 +548,7 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi } -LIB_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem() +SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::ParseDrawItem() { switch( CurTok() ) { diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h index 55edcdc5fe..5211177244 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h @@ -38,7 +38,6 @@ class LIB_SHAPE; -class LIB_ITEM; class LIB_PIN; class LIB_TEXT; class PAGE_INFO; @@ -90,7 +89,7 @@ public: LIB_SYMBOL* ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aFileVersion = SEXPR_SYMBOL_LIB_FILE_VERSION ); - LIB_ITEM* ParseDrawItem(); + SCH_ITEM* ParseDrawItem(); /** * Parse the internal #LINE_READER object into \a aSheet. diff --git a/eeschema/sch_io/sch_io_lib_cache.cpp b/eeschema/sch_io/sch_io_lib_cache.cpp index a8e6510c67..5b64241453 100644 --- a/eeschema/sch_io/sch_io_lib_cache.cpp +++ b/eeschema/sch_io/sch_io_lib_cache.cpp @@ -123,7 +123,7 @@ LIB_SYMBOL* SCH_IO_LIB_CACHE::removeSymbol( LIB_SYMBOL* aSymbol ) if( firstChild ) { - for( LIB_ITEM& drawItem : aSymbol->GetDrawItems() ) + for( SCH_ITEM& drawItem : aSymbol->GetDrawItems() ) { if( drawItem.Type() == LIB_FIELD_T ) { @@ -133,7 +133,7 @@ LIB_SYMBOL* SCH_IO_LIB_CACHE::removeSymbol( LIB_SYMBOL* aSymbol ) continue; } - LIB_ITEM* newItem = (LIB_ITEM*) drawItem.Clone(); + SCH_ITEM* newItem = (SCH_ITEM*) drawItem.Clone(); drawItem.SetParent( firstChild ); firstChild->AddDrawItem( newItem ); } diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index f75c80ef50..8143656761 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -48,11 +48,36 @@ #define BITMAP_FONT_SIZE_THRESHOLD 3 +wxString SCH_ITEM::GetUnitDescription( int aUnit ) +{ + if( aUnit == 0 ) + return _( "All" ); + else + return LIB_SYMBOL::LetterSubReference( aUnit, 'A' ); +} + + +wxString SCH_ITEM::GetBodyStyleDescription( int aBodyStyle ) +{ + if( aBodyStyle == 0 ) + return _( "All" ); + else if( aBodyStyle == BODY_STYLE::DEMORGAN ) + return _( "Alternate" ); + else if( aBodyStyle == BODY_STYLE::BASE ) + return _( "Standard" ); + else + return wxT( "?" ); +} + + /* Constructor and destructor for SCH_ITEM */ /* They are not inline because this creates problems with gcc at linking time in debug mode */ -SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) : - EDA_ITEM( aParent, aType ) +SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType, int aUnit, int aBodyStyle ) : + EDA_ITEM( aParent, aType ), + m_unit( aUnit ), + m_bodyStyle( aBodyStyle ), + m_private( false ) { m_layer = LAYER_WIRE; // It's only a default, in fact m_fieldsAutoplaced = FIELDS_AUTOPLACED_NO; @@ -64,6 +89,9 @@ SCH_ITEM::SCH_ITEM( const SCH_ITEM& aItem ) : EDA_ITEM( aItem ) { m_layer = aItem.m_layer; + m_unit = aItem.m_unit; + m_bodyStyle = aItem.m_bodyStyle; + m_private = aItem.m_private; m_fieldsAutoplaced = aItem.m_fieldsAutoplaced; m_connectivity_dirty = aItem.m_connectivity_dirty; } @@ -72,6 +100,9 @@ SCH_ITEM::SCH_ITEM( const SCH_ITEM& aItem ) : SCH_ITEM& SCH_ITEM::operator=( const SCH_ITEM& aItem ) { m_layer = aItem.m_layer; + m_unit = aItem.m_unit; + m_bodyStyle = aItem.m_bodyStyle; + m_private = aItem.m_private; m_fieldsAutoplaced = aItem.m_fieldsAutoplaced; m_connectivity_dirty = aItem.m_connectivity_dirty; @@ -123,26 +154,47 @@ SCHEMATIC* SCH_ITEM::Schematic() const const SYMBOL* SCH_ITEM::GetParentSymbol() const { - wxCHECK( m_parent->Type() == SCH_SYMBOL_T, nullptr ); + const EDA_ITEM* parent = GetParent(); - return static_cast( m_parent ); + while( parent ) + { + if( parent->Type() == SCH_SYMBOL_T ) + return static_cast( parent ); + else if( parent->Type() == LIB_SYMBOL_T ) + return static_cast( parent ); + else + parent = parent->GetParent(); + } + + return nullptr; } SYMBOL* SCH_ITEM::GetParentSymbol() { - wxCHECK( m_parent->Type() == SCH_SYMBOL_T, nullptr ); + EDA_ITEM* parent = GetParent(); - return static_cast( m_parent ); + while( parent ) + { + if( parent->Type() == SCH_SYMBOL_T ) + return static_cast( parent ); + else if( parent->Type() == LIB_SYMBOL_T ) + return static_cast( parent ); + else + parent = parent->GetParent(); + } + + return nullptr; } void SCH_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const { // Basic fallback - aCount = 2; - aLayers[0] = LAYER_DEVICE; - aLayers[1] = LAYER_SELECTION_SHADOWS; + aCount = 3; + aLayers[0] = LAYER_DEVICE; + aLayers[1] = LAYER_DEVICE_BACKGROUND; + aLayers[2] = LAYER_SELECTION_SHADOWS; } @@ -316,18 +368,54 @@ void SCH_ITEM::ClearCaches() } -bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const +bool SCH_ITEM::operator==( const SCH_ITEM& aOther ) const { - if( Type() != aItem.Type() ) - return Type() < aItem.Type(); + if( Type() != aOther.Type() ) + return false; - if( GetPosition().x != aItem.GetPosition().x ) - return GetPosition().x < aItem.GetPosition().x; + return compare( aOther, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) == 0; +} - if( GetPosition().y != aItem.GetPosition().y ) - return GetPosition().y < aItem.GetPosition().y; - return m_Uuid < aItem.m_Uuid; +bool SCH_ITEM::operator<( const SCH_ITEM& aOther ) const +{ + if( Type() != aOther.Type() ) + return Type() < aOther.Type(); + + return ( compare( aOther ) < 0 ); +} + + +bool SCH_ITEM::cmp_items::operator()( const SCH_ITEM* aFirst, const SCH_ITEM* aSecond ) const +{ + return aFirst->compare( *aSecond, COMPARE_FLAGS::EQUALITY ) < 0; +} + + +int SCH_ITEM::compare( const SCH_ITEM& aOther, int aCompareFlags ) const +{ + if( Type() != aOther.Type() ) + return Type() - aOther.Type(); + + if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT ) && m_unit != aOther.m_unit ) + return m_unit - aOther.m_unit; + + if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT ) && m_bodyStyle != aOther.m_bodyStyle ) + return m_bodyStyle - aOther.m_bodyStyle; + + if( IsPrivate() != aOther.IsPrivate() ) + return IsPrivate() < aOther.IsPrivate(); + + if( GetPosition().x != aOther.GetPosition().x ) + return GetPosition().x < aOther.GetPosition().x; + + if( GetPosition().y != aOther.GetPosition().y ) + return GetPosition().y < aOther.GetPosition().y; + + if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY ) + return 0; + + return m_Uuid < aOther.m_Uuid; } @@ -348,6 +436,20 @@ const KIFONT::METRICS& SCH_ITEM::GetFontMetrics() const } +int SCH_ITEM::GetEffectivePenWidth( const SCH_RENDER_SETTINGS* aSettings ) const +{ + // For historical reasons, a stored value of 0 means "default width" and negative + // numbers meant "don't stroke". + + if( GetPenWidth() < 0 ) + return 0; + else if( GetPenWidth() == 0 ) + return std::max( aSettings->GetDefaultPenWidth(), aSettings->GetMinPenWidth() ); + else + return std::max( GetPenWidth(), aSettings->GetMinPenWidth() ); +} + + bool SCH_ITEM::RenderAsBitmap( double aWorldScale ) const { if( IsHypertext() ) @@ -360,38 +462,78 @@ bool SCH_ITEM::RenderAsBitmap( double aWorldScale ) const } +void SCH_ITEM::getSymbolEditorMsgPanelInfo( EDA_DRAW_FRAME* aFrame, + std::vector& aList ) +{ + wxString msg; + + aList.emplace_back( _( "Type" ), GetFriendlyName() ); + + if( const SYMBOL* parent = GetParentSymbol() ) + { + if( parent->GetUnitCount() ) + aList.emplace_back( _( "Unit" ), GetUnitDescription( m_unit ) ); + + if( parent->HasAlternateBodyStyle() ) + aList.emplace_back( _( "Body Style" ), GetBodyStyleDescription( m_bodyStyle ) ); + } + + if( IsPrivate() ) + aList.emplace_back( _( "Private" ), wxEmptyString ); +} + + static struct SCH_ITEM_DESC { SCH_ITEM_DESC() { -#ifdef NOTYET - ENUM_MAP& layerEnum = ENUM_MAP::Instance(); - - if( layerEnum.Choices().GetCount() == 0 ) - { - layerEnum.Undefined( SCH_LAYER_ID_END ); - - for( SCH_LAYER_ID value : magic_enum::enum_values() ) - layerEnum.Map( value, LayerName( value ) ); - } -#endif - PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); REGISTER_TYPE( SCH_ITEM ); propMgr.InheritsAfter( TYPE_HASH( SCH_ITEM ), TYPE_HASH( EDA_ITEM ) ); -#ifdef NOTYET - // Not sure if this will ever be needed - propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Layer" ), - &SCH_ITEM::SetLayer, &SCH_ITEM::GetLayer ) ) - .SetIsHiddenFromPropertiesManager(); -#endif - #ifdef NOTYET // Not yet functional in UI propMgr.AddProperty( new PROPERTY( _HKI( "Locked" ), &SCH_ITEM::SetLocked, &SCH_ITEM::IsLocked ) ); #endif + + auto multiUnit = + [=]( INSPECTABLE* aItem ) -> bool + { + if( SCH_ITEM* schItem = dynamic_cast( aItem ) ) + { + if( const SYMBOL* symbol = schItem->GetParentSymbol() ) + return symbol->IsMulti(); + } + + return false; + }; + + auto multiBodyStyle = + [=]( INSPECTABLE* aItem ) -> bool + { + if( SCH_ITEM* schItem = dynamic_cast( aItem ) ) + { + if( const SYMBOL* symbol = schItem->GetParentSymbol() ) + return symbol->HasAlternateBodyStyle(); + } + + return false; + }; + + propMgr.AddProperty( new PROPERTY( _HKI( "Unit" ), + &SCH_ITEM::SetUnit, &SCH_ITEM::GetUnit ) ) + .SetAvailableFunc( multiUnit ) + .SetIsHiddenFromDesignEditors(); + + propMgr.AddProperty( new PROPERTY( _HKI( "Body Style" ), + &SCH_ITEM::SetBodyStyle, &SCH_ITEM::GetBodyStyle ) ) + .SetAvailableFunc( multiBodyStyle ) + .SetIsHiddenFromDesignEditors(); + + propMgr.AddProperty( new PROPERTY( _HKI( "Private" ), + &SCH_ITEM::SetPrivate, &SCH_ITEM::IsPrivate ) ) + .SetIsHiddenFromDesignEditors(); } } _SCH_ITEM_DESC; diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index ccde21c2cb..3ce08f4e31 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -52,6 +52,16 @@ class METRICS; } +enum BODY_STYLE : int +{ + BASE = 1, + DEMORGAN = 2 +}; + + +#define MINIMUM_SELECTION_DISTANCE 2 // Minimum selection distance in mils + + enum FIELDS_AUTOPLACED { FIELDS_AUTOPLACED_NO = 0, @@ -161,7 +171,7 @@ typedef std::vector SCH_ITEM_SET; class SCH_ITEM : public EDA_ITEM { public: - SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ); + SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType, int aUnit = 0, int aBodyStyle = 0 ); SCH_ITEM( const SCH_ITEM& aItem ); @@ -218,6 +228,18 @@ public: */ SCH_ITEM* Duplicate( bool doClone = false ) const; + static wxString GetUnitDescription( int aUnit ); + static wxString GetBodyStyleDescription( int aBodyStyle ); + + void SetUnit( int aUnit ) { m_unit = aUnit; } + int GetUnit() const { return m_unit; } + + void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; } + int GetBodyStyle() const { return m_bodyStyle; } + + void SetPrivate( bool aPrivate ) { m_private = aPrivate; } + bool IsPrivate() const { return m_private; } + virtual void SetExcludedFromSim( bool aExclude ) { } virtual bool GetExcludedFromSim() const { return false; } @@ -275,6 +297,8 @@ public: */ virtual int GetPenWidth() const { return 0; } + int GetEffectivePenWidth( const SCH_RENDER_SETTINGS* aSettings ) const; + const wxString& GetDefaultFont() const; const KIFONT::METRICS& GetFontMetrics() const; @@ -290,9 +314,25 @@ public: wxCHECK_MSG( false, 0.0, wxT( "Similarity not implemented in " ) + GetClass() ); } - virtual bool operator==( const SCH_ITEM& aOtherItem ) const + /** + * Calculate the boilerplate similarity for all LIB_ITEMs without + * preventing the use above of a pure virtual function that catches at compile + * time when a new object has not been fully implemented + */ + double SimilarityBase( const SCH_ITEM& aItem ) const { - wxCHECK_MSG( false, false, wxT( "operator== not implemented in " ) + GetClass() ); + double similarity = 1.0; + + if( m_unit != aItem.m_unit ) + similarity *= 0.9; + + if( m_bodyStyle != aItem.m_bodyStyle ) + similarity *= 0.9; + + if( m_private != aItem.m_private ) + similarity *= 0.9; + + return similarity; } /** @@ -327,6 +367,47 @@ public: wxCHECK_MSG( false, /*void*/, wxT( "Rotate not implemented in " ) + GetClass() ); } + /** + * Begin drawing a symbol library draw item at \a aPosition. + * + * It typically would be called on a left click when a draw tool is selected in + * the symbol library editor and one of the graphics tools is selected. + * + * @param aPosition The position in drawing coordinates where the drawing was started. + * May or may not be required depending on the item being drawn. + */ + virtual void BeginEdit( const VECTOR2I& aPosition ) {} + + /** + * Continue an edit in progress at \a aPosition. + * + * This is used to perform the next action while drawing an item. This would be + * called for each additional left click when the mouse is captured while the item + * is being drawn. + * + * @param aPosition The position of the mouse left click in drawing coordinates. + * @return True if additional mouse clicks are required to complete the edit in progress. + */ + virtual bool ContinueEdit( const VECTOR2I& aPosition ) { return false; } + + /** + * End an object editing action. + * + * This is used to end or abort an edit action in progress initiated by BeginEdit(). + */ + virtual void EndEdit( bool aClosed = false ) {} + + /** + * Calculate the attributes of an item at \a aPosition when it is being edited. + * + * This method gets called by the Draw() method when the item is being edited. This + * probably should be a pure virtual method but bezier curves are not yet editable in + * the symbol library editor. Therefore, the default method does nothing. + * + * @param aPosition The current mouse position in drawing coordinates. + */ + virtual void CalcEdit( const VECTOR2I& aPosition ) {} + /** * Add the schematic item end points to \a aItemList if the item has end points. * @@ -542,7 +623,28 @@ public: wxCHECK_MSG( false, /*void*/, wxT( "Plot not implemented in " ) + GetClass() ); } - virtual bool operator <( const SCH_ITEM& aItem ) const; + /** + * The list of flags used by the #compare function. + * + * UNIT This flag relaxes unit, body-style and pin-number constraints. It is used for + * #SCH_ITEM object unit comparisons. + * + * EQUALITY This flag relaxes ordering contstraints so that fields, etc. don't have to + * appear in the same order to be considered equal. + * + * ERC This flag relaxes constraints on data that is settable in the schematic editor. + * It compares only symbol-editor-only data. + */ + enum COMPARE_FLAGS : int + { + UNIT = 0x01, + EQUALITY = 0x02, + ERC = 0x04 + }; + + virtual bool operator==( const SCH_ITEM& aOther ) const; + + virtual bool operator<( const SCH_ITEM& aItem ) const; protected: SCH_RENDER_SETTINGS* getRenderSettings( PLOTTER* aPlotter ) const @@ -550,6 +652,35 @@ protected: return static_cast( aPlotter->RenderSettings() ); } + struct cmp_items + { + bool operator()( const SCH_ITEM* aFirst, const SCH_ITEM* aSecond ) const; + }; + + void getSymbolEditorMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ); + + /** + * Provide the draw object specific comparison called by the == and < operators. + * + * The base object sort order which always proceeds the derived object sort order + * is as follows: + * - Symbol alternate part (DeMorgan) number. + * - Symbol part number. + * - KICAD_T enum value. + * - Result of derived classes comparison. + * + * @note Make sure you call down to #SCH_ITEM::compare before doing any derived object + * comparisons or you will break the sorting using the symbol library file format. + * + * @param aOther A reference to the other #SCH_ITEM to compare the arc against. + * @param aCompareFlags The flags used to perform the comparison. + * + * @return An integer value less than 0 if the object is less than \a aOther object, + * zero if the object is equal to \a aOther object, or greater than 0 if the + * object is greater than \a aOther object. + */ + virtual int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const; + private: friend class CONNECTION_GRAPH; @@ -570,6 +701,9 @@ private: protected: SCH_LAYER_ID m_layer; + int m_unit; // set to 0 if common to all units + int m_bodyStyle; // set to 0 if common to all body styles + bool m_private; // only shown in Symbol Editor FIELDS_AUTOPLACED m_fieldsAutoplaced; // indicates status of field autoplacement VECTOR2I m_storedPos; // temp variable used in some move commands to store // an initial position of the item or mouse cursor @@ -581,6 +715,9 @@ protected: std::unordered_map m_connection_map; bool m_connectivity_dirty; + +private: + friend class LIB_SYMBOL; }; #ifndef SWIG diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index 105b3c3106..1fd2d41829 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -1416,7 +1416,7 @@ void SCH_LABEL_BASE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int wxDC* DC = aSettings->GetPrintDC(); COLOR4D color = aSettings->GetLayerColor( layer ); bool blackAndWhiteMode = GetGRForceBlackPenState(); - int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() ); + int penWidth = GetEffectivePenWidth( aSettings ); VECTOR2I text_offset = aOffset + GetSchematicTextOffset( aSettings ); if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED ) diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 567d4d9f07..1b2ab5affe 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -371,7 +371,7 @@ void SCH_LINE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBody VECTOR2I start = m_start; VECTOR2I end = m_end; LINE_STYLE lineStyle = GetEffectiveLineStyle(); - int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() ); + int penWidth = GetEffectivePenWidth( aSettings ); if( lineStyle <= LINE_STYLE::FIRST_TYPE ) { @@ -905,7 +905,7 @@ void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& a return; SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); - int penWidth = std::max( GetPenWidth(), renderSettings->GetMinPenWidth() ); + int penWidth = GetEffectivePenWidth( renderSettings ); COLOR4D color = GetLineColor(); if( color == COLOR4D::UNSPECIFIED ) @@ -924,7 +924,7 @@ void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& a // Plot attributes to a hypertext menu std::vector properties; BOX2I bbox = GetBoundingBox(); - bbox.Inflate( GetPenWidth() * 3 ); + bbox.Inflate( penWidth * 3 ); if( aPlotOpts.m_PDFPropertyPopups ) { diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index 18d2f42945..39063b596c 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -107,7 +107,7 @@ void SCH_NO_CONNECT::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int { wxDC* DC = aSettings->GetPrintDC(); int half = GetSize() / 2; - int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() ); + int penWidth = GetEffectivePenWidth( aSettings ); int pX = m_pos.x + aOffset.x; int pY = m_pos.y + aOffset.y; COLOR4D color = aSettings->GetLayerColor( LAYER_NOCONNECT ); @@ -198,7 +198,7 @@ void SCH_NO_CONNECT::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_O int delta = GetSize() / 2; int pX = m_pos.x; int pY = m_pos.y; - int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetDefaultPenWidth() ); + int penWidth = GetEffectivePenWidth( getRenderSettings( aPlotter ) ); aPlotter->SetCurrentLineWidth( penWidth ); aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_NOCONNECT ) ); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 0dc9473879..9998a97d72 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -123,7 +122,7 @@ static LIB_SYMBOL* dummy() LIB_SHAPE* square = new LIB_SHAPE( symbol, SHAPE_T::RECTANGLE ); - square->MoveTo( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) ); + 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 ); @@ -294,7 +293,7 @@ bool SCH_PAINTER::nonCached( const EDA_ITEM* aItem ) } -bool SCH_PAINTER::isUnitAndConversionShown( const LIB_ITEM* aItem ) const +bool SCH_PAINTER::isUnitAndConversionShown( const SCH_ITEM* aItem ) const { if( m_schSettings.m_ShowUnit // showing a specific unit && aItem->GetUnit() // item is unit-specific @@ -478,10 +477,8 @@ float SCH_PAINTER::getLineWidth( const EDA_ITEM* aItem, bool aDrawingShadows ) c int pen = 0; - if( dynamic_cast( aItem ) ) - pen = static_cast( aItem )->GetEffectivePenWidth( &m_schSettings ); - else if( dynamic_cast( aItem ) ) - pen = static_cast( aItem )->GetPenWidth(); + if( const SCH_ITEM* item = dynamic_cast( aItem ) ) + pen = item->GetEffectivePenWidth( &m_schSettings ); else UNIMPLEMENTED_FOR( aItem->GetClass() ); @@ -724,7 +721,7 @@ void SCH_PAINTER::draw( const LIB_SYMBOL* aSymbol, int aLayer, bool aDrawFields, // The parent must exist on the union of all its children's draw layers. But that doesn't // mean we want to draw each child on the union. auto childOnLayer = - []( const LIB_ITEM& item, int layer ) + []( const SCH_ITEM& item, int layer ) { int layers[512], layers_count; item.ViewGetLayers( layers, layers_count ); @@ -738,7 +735,7 @@ void SCH_PAINTER::draw( const LIB_SYMBOL* aSymbol, int aLayer, bool aDrawFields, return false; }; - for( const LIB_ITEM& item : drawnSymbol->GetDrawItems() ) + for( const SCH_ITEM& item : drawnSymbol->GetDrawItems() ) { if( !aDrawFields && item.Type() == LIB_FIELD_T ) continue; @@ -757,7 +754,7 @@ void SCH_PAINTER::draw( const LIB_SYMBOL* aSymbol, int aLayer, bool aDrawFields, } -bool SCH_PAINTER::setDeviceColors( const LIB_ITEM* aItem, int aLayer, bool aDimmed ) +bool SCH_PAINTER::setDeviceColors( const SCH_ITEM* aItem, int aLayer, bool aDimmed ) { COLOR4D bg = m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ); const EDA_SHAPE* shape = dynamic_cast( aItem ); @@ -2577,7 +2574,7 @@ static void orientSymbol( LIB_SYMBOL* symbol, int orientation ) } } - for( LIB_ITEM& item : symbol->GetDrawItems() ) + for( SCH_ITEM& item : symbol->GetDrawItems() ) { for( int i = 0; i < o.n_rots; i++ ) item.Rotate( VECTOR2I(0, 0 ), true ); @@ -2630,24 +2627,24 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer ) int bodyStyle = aSymbol->GetBodyStyle(); // Use dummy symbol if the actual couldn't be found (or couldn't be locked). - LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ? - aSymbol->GetLibSymbolRef().get() : dummy(); - LIB_PINS originalPins; + LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ? aSymbol->GetLibSymbolRef().get() + : dummy(); + std::vector originalPins; originalSymbol->GetPins( originalPins, unit, bodyStyle ); // Copy the source so we can re-orient and translate it. LIB_SYMBOL tempSymbol( *originalSymbol ); - LIB_PINS tempPins; + std::vector tempPins; tempSymbol.GetPins( tempPins, unit, bodyStyle ); tempSymbol.SetFlags( aSymbol->GetFlags() ); orientSymbol( &tempSymbol, aSymbol->GetOrientation() ); - for( LIB_ITEM& tempItem : tempSymbol.GetDrawItems() ) + for( SCH_ITEM& tempItem : tempSymbol.GetDrawItems() ) { tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED, - tempItem.MoveTo( tempItem.GetPosition() + (VECTOR2I) mapCoords( aSymbol->GetPosition() ) ); + tempItem.Move( (VECTOR2I) mapCoords( aSymbol->GetPosition() ) ); if( tempItem.Type() == LIB_TEXT_T ) { diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 50c75b51b2..7355c87ef2 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -35,7 +35,6 @@ class LIB_PIN; class LIB_SHAPE; -class LIB_ITEM; class LIB_SYMBOL; class LIB_FIELD; class LIB_TEXT; @@ -121,7 +120,7 @@ private: // Indicates the item is drawn on a non-cached layer in OpenGL bool nonCached( const EDA_ITEM* aItem ); - bool isUnitAndConversionShown( const LIB_ITEM* aItem ) const; + bool isUnitAndConversionShown( const SCH_ITEM* aItem ) const; float getShadowWidth( bool aForHighlight ) const; COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows, @@ -132,7 +131,7 @@ private: int getOperatingPointTextSize() const; - bool setDeviceColors( const LIB_ITEM* aItem, int aLayer, bool aDimmed ); + bool setDeviceColors( const SCH_ITEM* aItem, int aLayer, bool aDimmed ); void triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c ); void strokeText( const wxString& aText, const VECTOR2D& aPosition, diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index f357856dd3..98a16f7de0 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -235,14 +235,14 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUnitCount() ) { - msg = m_libPin ? LIB_ITEM::GetUnitDescription( m_libPin->GetUnit() ) : + msg = m_libPin ? GetUnitDescription( m_libPin->GetUnit() ) : wxString( "Undefined library pin." ); aList.emplace_back( _( "Unit" ), msg ); } if( symbol->HasAlternateBodyStyle() ) { - msg = m_libPin ? LIB_ITEM::GetBodyStyleDescription( m_libPin->GetBodyStyle() ) : + msg = m_libPin ? GetBodyStyleDescription( m_libPin->GetBodyStyle() ) : wxString( "Undefined library pin." ); aList.emplace_back( _( "Body Style" ), msg ); } diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 0000c9f96f..c3b988f030 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1155,7 +1155,7 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter, const SCH_PLOT_OPTS& aPlotOpts ) const return a->Type() > b->Type(); } ); - int defaultPenWidth = aPlotter->RenderSettings()->GetDefaultPenWidth(); + auto* renderSettings = static_cast( aPlotter->RenderSettings() ); constexpr bool background = true; // Bitmaps are drawn first to ensure they are in the background @@ -1163,21 +1163,21 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter, const SCH_PLOT_OPTS& aPlotOpts ) const // the bitmap PS command clears the screen for( SCH_ITEM* item : bitmaps ) { - aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); + aPlotter->SetCurrentLineWidth( item->GetEffectivePenWidth( renderSettings ) ); item->Plot( aPlotter, background, aPlotOpts, 0, 0, { 0, 0 }, false ); } // Plot the background items for( SCH_ITEM* item : other ) { - aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); + aPlotter->SetCurrentLineWidth( item->GetEffectivePenWidth( renderSettings ) ); item->Plot( aPlotter, background, aPlotOpts, 0, 0, { 0, 0 }, false ); } // Plot the foreground items for( SCH_ITEM* item : other ) { - aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); + aPlotter->SetCurrentLineWidth( item->GetEffectivePenWidth( renderSettings ) ); item->Plot( aPlotter, !background, aPlotOpts, 0, 0, { 0, 0 }, false ); } @@ -1185,7 +1185,7 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter, const SCH_PLOT_OPTS& aPlotOpts ) const // and symbols to ensure that they are always visible for( const SCH_SYMBOL* sym :symbols ) { - aPlotter->SetCurrentLineWidth( std::max( sym->GetPenWidth(), defaultPenWidth ) ); + aPlotter->SetCurrentLineWidth( sym->GetEffectivePenWidth( renderSettings ) ); for( SCH_FIELD field : sym->GetFields() ) { @@ -1202,7 +1202,7 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter, const SCH_PLOT_OPTS& aPlotOpts ) const for( SCH_ITEM* item : junctions ) { - aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); + aPlotter->SetCurrentLineWidth( item->GetEffectivePenWidth( renderSettings ) ); item->Plot( aPlotter, !background, aPlotOpts, 0, 0, { 0, 0 }, false ); } } diff --git a/eeschema/sch_shape.cpp b/eeschema/sch_shape.cpp index f5df99fd32..e17d3c2e5e 100644 --- a/eeschema/sch_shape.cpp +++ b/eeschema/sch_shape.cpp @@ -114,10 +114,7 @@ void SCH_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) { - int pen_size = GetPenWidth(); - - if( pen_size > 0 ) - pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetMinPenWidth() ); + int pen_size = GetEffectivePenWidth( getRenderSettings( aPlotter ) ); static std::vector cornerList; @@ -296,7 +293,7 @@ void SCH_SHAPE::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) { - int penWidth = GetPenWidth(); + int penWidth = GetEffectivePenWidth( aSettings ); wxDC* DC = aSettings->GetPrintDC(); COLOR4D color = GetStroke().GetColor(); @@ -365,10 +362,6 @@ void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod UNIMPLEMENTED_FOR( SHAPE_T_asString() ); } } - else - { - penWidth = std::max( penWidth, aSettings->GetMinPenWidth() ); - } if( penWidth > 0 ) { diff --git a/eeschema/sch_shape.h b/eeschema/sch_shape.h index 3087946599..81da7a56d7 100644 --- a/eeschema/sch_shape.h +++ b/eeschema/sch_shape.h @@ -80,11 +80,11 @@ public: VECTOR2I GetCenter() const { return getCenter(); } - void BeginEdit( const VECTOR2I& aStartPoint ) { beginEdit( aStartPoint ); } - bool ContinueEdit( const VECTOR2I& aPosition ) { return continueEdit( aPosition ); } - void CalcEdit( const VECTOR2I& aPosition ) { calcEdit( aPosition ); } - void EndEdit() { endEdit(); } - void SetEditState( int aState ) { setEditState( aState ); } + void BeginEdit( const VECTOR2I& aStartPoint ) override { beginEdit( aStartPoint ); } + bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); } + void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); } + void EndEdit( bool aClosed = false ) override { endEdit(); } + void SetEditState( int aState ) { setEditState( aState ); } void Move( const VECTOR2I& aOffset ) override; diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 68d6e3e81c..db3957d04c 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -1166,7 +1166,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& { aPlotter->SetColor( borderColor ); - int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() ); + int penWidth = GetEffectivePenWidth( getRenderSettings( aPlotter ) ); aPlotter->Rect( m_pos, m_pos + m_size, FILL_T::NO_FILL, penWidth ); } @@ -1199,7 +1199,7 @@ void SCH_SHEET::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBod { wxDC* DC = aSettings->GetPrintDC(); VECTOR2I pos = m_pos + aOffset; - int lineWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() ); + int lineWidth = GetEffectivePenWidth( aSettings ); COLOR4D border = GetBorderColor(); COLOR4D background = GetBackgroundColor(); diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 40c81aaa59..34b46f5af4 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -83,7 +83,7 @@ static LIB_SYMBOL* dummy() LIB_SHAPE* square = new LIB_SHAPE( symbol, SHAPE_T::RECTANGLE ); - square->MoveTo( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) ); + 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 ); @@ -207,7 +207,7 @@ void SCH_SYMBOL::Init( const VECTOR2I& pos ) m_layer = LAYER_DEVICE; m_pos = pos; m_unit = 1; // In multi unit chip - which unit to draw. - m_bodyStyle = LIB_ITEM::BODY_STYLE::BASE; // De Morgan Handling + m_bodyStyle = BODY_STYLE::BASE; // De Morgan Handling // The rotation/mirror transformation matrix. pos normal m_transform = TRANSFORM(); @@ -516,11 +516,11 @@ void SCH_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBo if( m_part ) { - LIB_PINS libPins; + std::vector libPins; m_part->GetPins( libPins, m_unit, m_bodyStyle ); LIB_SYMBOL tempSymbol( *m_part ); - LIB_PINS tempPins; + std::vector tempPins; tempSymbol.GetPins( tempPins, m_unit, m_bodyStyle ); // Copy the pin info from the symbol to the temp pins @@ -534,7 +534,7 @@ void SCH_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBo tempPin->SetShape( symbolPin->GetShape() ); } - for( LIB_ITEM& item : tempSymbol.GetDrawItems() ) + for( SCH_ITEM& item : tempSymbol.GetDrawItems() ) { if( EDA_TEXT* text = dynamic_cast( &item ) ) { @@ -2215,7 +2215,7 @@ std::vector SCH_SYMBOL::GetConnectionPoints() const } -LIB_ITEM* SCH_SYMBOL::GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType ) +SCH_ITEM* SCH_SYMBOL::GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType ) { if( m_part ) { @@ -2463,12 +2463,12 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& if( m_part ) { - LIB_PINS libPins; + std::vector libPins; m_part->GetPins( libPins, GetUnit(), GetBodyStyle() ); // Copy the source so we can re-orient and translate it. LIB_SYMBOL tempSymbol( *m_part ); - LIB_PINS tempPins; + std::vector tempPins; tempSymbol.GetPins( tempPins, GetUnit(), GetBodyStyle() ); // Copy the pin info from the symbol to the temp pins @@ -2485,7 +2485,7 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& tempPin->SetFlags( IS_DANGLING ); } - for( LIB_ITEM& item : tempSymbol.GetDrawItems() ) + for( SCH_ITEM& item : tempSymbol.GetDrawItems() ) { if( EDA_TEXT* text = dynamic_cast( &item ) ) { @@ -2575,12 +2575,12 @@ void SCH_SYMBOL::PlotPins( PLOTTER* aPlotter ) const { if( m_part ) { - LIB_PINS libPins; + std::vector libPins; m_part->GetPins( libPins, GetUnit(), GetBodyStyle() ); // Copy the source to stay const LIB_SYMBOL tempSymbol( *m_part ); - LIB_PINS tempPins; + std::vector tempPins; tempSymbol.GetPins( tempPins, GetUnit(), GetBodyStyle() ); SCH_PLOT_OPTS plotOpts; diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index e16dea6a9f..f63da39cfa 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -55,7 +55,6 @@ struct PICKED_SYMBOL; class KIID_PATH; class SCH_SCREEN; -class LIB_ITEM; class LIB_PIN; class LIB_SYMBOL; class NETLIST_OBJECT_LIST; @@ -762,7 +761,7 @@ public: * @param aType is the type of symbol library object to find or any if set to TYPE_NOT_INIT. * @return is the symbol library object if found otherwise NULL. */ - LIB_ITEM* GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType = TYPE_NOT_INIT ); + SCH_ITEM* GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType = TYPE_NOT_INIT ); wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override; diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index 20e552eb53..2de47c1fac 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -418,18 +418,16 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS return; } - SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet(); - RENDER_SETTINGS* settings = aPlotter->RenderSettings(); - int penWidth = GetPenWidth(); - COLOR4D color = GetStroke().GetColor(); - LINE_STYLE lineStyle = GetStroke().GetLineStyle(); + SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet(); + SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); + int penWidth = GetEffectivePenWidth( renderSettings ); + COLOR4D color = GetStroke().GetColor(); + LINE_STYLE lineStyle = GetStroke().GetLineStyle(); if( penWidth > 0 ) { - penWidth = std::max( penWidth, settings->GetMinPenWidth() ); - if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) - color = settings->GetLayerColor( m_layer ); + color = renderSettings->GetLayerColor( m_layer ); if( lineStyle == LINE_STYLE::DEFAULT ) lineStyle = LINE_STYLE::SOLID; @@ -443,15 +441,15 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS KIFONT::FONT* font = GetFont(); if( !font ) - font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() ); + font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() ); color = GetTextColor(); if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) - color = settings->GetLayerColor( m_layer ); + color = renderSettings->GetLayerColor( m_layer ); - penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() ); - penWidth = std::max( penWidth, settings->GetMinPenWidth() ); + penWidth = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() ); + penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() ); aPlotter->SetCurrentLineWidth( penWidth ); std::vector positions; diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index 3c2e559eb9..77edb2ea56 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -143,7 +143,7 @@ void SCH_VIEW::DisplaySymbol( LIB_SYMBOL* aSymbol ) return; // Draw the fields. - for( LIB_ITEM& item : aSymbol->GetDrawItems() ) + for( SCH_ITEM& item : aSymbol->GetDrawItems() ) { if( item.Type() == LIB_FIELD_T ) { @@ -168,7 +168,7 @@ void SCH_VIEW::DisplaySymbol( LIB_SYMBOL* aSymbol ) } } - for( LIB_ITEM& item : drawnSymbol->GetDrawItems() ) + for( SCH_ITEM& item : drawnSymbol->GetDrawItems() ) { // Fields already drawn above. (Besides, we don't want to show parent symbol fields as // users may be confused by shown fields that can not be edited.) diff --git a/eeschema/sim/sim_model.h b/eeschema/sim/sim_model.h index 04d75ffd3a..31b27ae406 100644 --- a/eeschema/sim/sim_model.h +++ b/eeschema/sim/sim_model.h @@ -33,6 +33,7 @@ #include #include #include +#include // Must be included after sch_field.h (exactly eda_shape.h) to avoid a colliding // declaration with a window header (under msys2) diff --git a/eeschema/symbol_checker.cpp b/eeschema/symbol_checker.cpp index 50c047332c..3a5fb00f20 100644 --- a/eeschema/symbol_checker.cpp +++ b/eeschema/symbol_checker.cpp @@ -70,7 +70,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, aMessages.push_back( msg ); } - LIB_PINS pinList; + std::vector pinList; aSymbol->GetPins( pinList ); // Test for duplicates: @@ -126,7 +126,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, pin->GetName(), aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), - LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); + SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); } else { @@ -143,7 +143,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), aSymbol->GetUnitReference( next->GetUnit() ), aSymbol->GetUnitReference( pin->GetUnit() ), - LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); + SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); } } else @@ -250,7 +250,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, pinName, aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), - LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); + SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); } else { @@ -261,7 +261,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), 'A' + pin->GetUnit() - 1, - LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); + SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); } } else @@ -308,7 +308,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, pinName, aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), - LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); + SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); } else { @@ -319,7 +319,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ), aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ), 'A' + pin->GetUnit() - 1, - LIB_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); + SCH_ITEM::GetBodyStyleDescription( pin->GetBodyStyle() ).Lower() ); } } else @@ -361,7 +361,7 @@ void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector& aMessag wxString msg; - for( const LIB_ITEM& item : aSymbol->GetDrawItems() ) + for( const SCH_ITEM& item : aSymbol->GetDrawItems() ) { if( item.Type() != LIB_SHAPE_T ) continue; diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 841a75cc17..8f42481f69 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -534,13 +534,13 @@ void SYMBOL_EDIT_FRAME::setupUIConditions() auto demorganStandardCond = [this]( const SELECTION& ) { - return m_bodyStyle == LIB_ITEM::BODY_STYLE::BASE; + return m_bodyStyle == BODY_STYLE::BASE; }; auto demorganAlternateCond = [this]( const SELECTION& ) { - return m_bodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN; + return m_bodyStyle == BODY_STYLE::DEMORGAN; }; auto multiUnitModeCond = @@ -1345,7 +1345,7 @@ void SYMBOL_EDIT_FRAME::HardRedraw() EE_SELECTION_TOOL* selectionTool = m_toolManager->GetTool(); EE_SELECTION& selection = selectionTool->GetSelection(); - for( LIB_ITEM& item : m_symbol->GetDrawItems() ) + for( SCH_ITEM& item : m_symbol->GetDrawItems() ) { if( !alg::contains( selection, &item ) ) item.ClearSelected(); @@ -1378,11 +1378,11 @@ const BOX2I SYMBOL_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) con } -void SYMBOL_EDIT_FRAME::FocusOnItem( LIB_ITEM* aItem ) +void SYMBOL_EDIT_FRAME::FocusOnItem( SCH_ITEM* aItem ) { static KIID lastBrightenedItemID( niluuid ); - LIB_ITEM* lastItem = nullptr; + SCH_ITEM* lastItem = nullptr; if( m_symbol ) { diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index 2cd66c4389..66684e7a4d 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -389,7 +388,7 @@ public: void KiwayMailIn( KIWAY_EXPRESS& mail ) override; - void FocusOnItem( LIB_ITEM* aItem ); + void FocusOnItem( SCH_ITEM* aItem ); /** * Load a symbol from the schematic to edit in place. diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index ee02193bd6..1478f4c9c3 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -1277,9 +1277,9 @@ void SYMBOL_EDIT_FRAME::UpdateSymbolMsgPanelInfo() AppendMsgPanel( _( "Unit" ), msg, 8 ); - if( m_bodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN ) + if( m_bodyStyle == BODY_STYLE::DEMORGAN ) msg = _( "Alternate" ); - else if( m_bodyStyle == LIB_ITEM::BODY_STYLE::BASE ) + else if( m_bodyStyle == BODY_STYLE::BASE ) msg = _( "Standard" ); else msg = wxT( "?" ); diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index c122d1b67f..a2c4cefdd6 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -377,13 +377,13 @@ void SYMBOL_VIEWER_FRAME::setupUIConditions() auto demorganStandardCond = []( const SELECTION& ) { - return m_bodyStyle == LIB_ITEM::BODY_STYLE::BASE; + return m_bodyStyle == BODY_STYLE::BASE; }; auto demorganAlternateCond = []( const SELECTION& ) { - return m_bodyStyle == LIB_ITEM::BODY_STYLE::DEMORGAN; + return m_bodyStyle == BODY_STYLE::DEMORGAN; }; auto haveDatasheetCond = @@ -410,7 +410,7 @@ void SYMBOL_VIEWER_FRAME::setupUIConditions() void SYMBOL_VIEWER_FRAME::SetUnitAndBodyStyle( int aUnit, int aBodyStyle ) { m_unit = aUnit > 0 ? aUnit : 1; - m_bodyStyle = aBodyStyle > 0 ? aBodyStyle : LIB_ITEM::BODY_STYLE::BASE; + m_bodyStyle = aBodyStyle > 0 ? aBodyStyle : BODY_STYLE::BASE; m_selection_changed = false; updatePreviewSymbol(); @@ -640,7 +640,7 @@ bool SYMBOL_VIEWER_FRAME::ReCreateLibList() ? m_libList->GetBaseString( 0 ) : wxString( wxT( "" ) ) ); m_currentSymbol.SetLibItemName( wxEmptyString ); m_unit = 1; - m_bodyStyle = LIB_ITEM::BODY_STYLE::BASE; + m_bodyStyle = BODY_STYLE::BASE; } bool cmp_changed = ReCreateSymbolList(); @@ -715,7 +715,7 @@ bool SYMBOL_VIEWER_FRAME::ReCreateSymbolList() if( m_symbolList->IsEmpty() ) { SetSelectedSymbol( wxEmptyString ); - m_bodyStyle = LIB_ITEM::BODY_STYLE::BASE; + m_bodyStyle = BODY_STYLE::BASE; m_unit = 1; return true; } @@ -727,7 +727,7 @@ bool SYMBOL_VIEWER_FRAME::ReCreateSymbolList() { // Select the first library entry when the previous entry name does not exist in // the current library. - m_bodyStyle = LIB_ITEM::BODY_STYLE::BASE; + m_bodyStyle = BODY_STYLE::BASE; m_unit = 1; index = -1; changed = true; @@ -827,7 +827,7 @@ void SYMBOL_VIEWER_FRAME::SetSelectedSymbol( const wxString& aSymbolName ) if( m_selection_changed ) { m_unit = 1; - m_bodyStyle = LIB_ITEM::BODY_STYLE::BASE; + m_bodyStyle = BODY_STYLE::BASE; m_selection_changed = false; } diff --git a/eeschema/tools/ee_grid_helper.h b/eeschema/tools/ee_grid_helper.h index 77f017cce8..540d587c0d 100644 --- a/eeschema/tools/ee_grid_helper.h +++ b/eeschema/tools/ee_grid_helper.h @@ -32,7 +32,6 @@ #include class SCH_ITEM; -class LIB_ITEM; class EE_GRID_HELPER : public GRID_HELPER diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index ad8c5de8cb..a195573819 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -430,12 +430,12 @@ void EE_INSPECTION_TOOL::DiffSymbol( SCH_SYMBOL* symbol ) field.GetName( false ) ) ); fields.back().CopyText( field ); fields.back().SetAttributes( field ); - fields.back().Offset( -symbol->GetPosition() ); + fields.back().Move( -symbol->GetPosition() ); } flattenedSchSymbol->SetFields( fields ); - if( flattenedSchSymbol->Compare( *flattenedLibSymbol, LIB_ITEM::COMPARE_FLAGS::ERC, + if( flattenedSchSymbol->Compare( *flattenedLibSymbol, SCH_ITEM::COMPARE_FLAGS::ERC, r ) == 0 ) { r->Report( _( "No relevant differences detected." ) ); diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 6707e98752..5d5345d701 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -1686,12 +1685,7 @@ void EE_SELECTION_TOOL::updateReferencePoint() VECTOR2I refP( 0, 0 ); if( m_selection.Size() > 0 ) - { - if( m_isSymbolEditor ) - refP = static_cast( m_selection.GetTopLeftItem() )->GetPosition(); - else - refP = static_cast( m_selection.GetTopLeftItem() )->GetPosition(); - } + refP = static_cast( m_selection.GetTopLeftItem() )->GetPosition(); m_selection.SetReferencePoint( refP ); } @@ -2405,7 +2399,7 @@ void EE_SELECTION_TOOL::RebuildSelection() { LIB_SYMBOL* start = static_cast( m_frame )->GetCurSymbol(); - for( LIB_ITEM& item : start->GetDrawItems() ) + for( SCH_ITEM& item : start->GetDrawItems() ) { if( item.IsSelected() ) select( &item ); @@ -2495,12 +2489,12 @@ bool EE_SELECTION_TOOL::Selectable( const EDA_ITEM* aItem, const VECTOR2I* aPos, case LIB_PIN_T: if( symEditFrame ) { - const LIB_ITEM* lib_item = static_cast( aItem ); + const SCH_ITEM* sch_item = static_cast( aItem ); - if( lib_item->GetUnit() && lib_item->GetUnit() != symEditFrame->GetUnit() ) + if( sch_item->GetUnit() && sch_item->GetUnit() != symEditFrame->GetUnit() ) return false; - if( lib_item->GetBodyStyle() && lib_item->GetBodyStyle() != symEditFrame->GetBodyStyle() ) + if( sch_item->GetBodyStyle() && sch_item->GetBodyStyle() != symEditFrame->GetBodyStyle() ) return false; } diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 1750bd3c5d..c7893095ab 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -1712,13 +1712,13 @@ int SCH_EDIT_TOOL::ChangeBodyStyle( const TOOL_EVENT& aEvent ) SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front(); if( aEvent.IsAction( &EE_ACTIONS::showDeMorganStandard ) - && symbol->GetBodyStyle() == LIB_ITEM::BODY_STYLE::BASE ) + && symbol->GetBodyStyle() == BODY_STYLE::BASE ) { return 0; } if( aEvent.IsAction( &EE_ACTIONS::showDeMorganAlternate ) - && symbol->GetBodyStyle() == LIB_ITEM::BODY_STYLE::DEMORGAN ) + && symbol->GetBodyStyle() == BODY_STYLE::DEMORGAN ) { return 0; } diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index b659802a20..b33aec447d 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -370,7 +370,7 @@ int SCH_EDITOR_CONTROL::ExportSymbolsToLibrary( const TOOL_EVENT& aEvent ) if( libSymbols.count( id ) ) { - wxASSERT_MSG( libSymbols[id]->Compare( *libSymbol, LIB_ITEM::COMPARE_FLAGS::ERC ) == 0, + wxASSERT_MSG( libSymbols[id]->Compare( *libSymbol, SCH_ITEM::COMPARE_FLAGS::ERC ) == 0, "Two symbols have the same LIB_ID but are different!" ); } else diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index 9492d37023..d041adafe3 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -483,8 +483,8 @@ int SYMBOL_EDITOR_CONTROL::RenameSymbol( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_CONTROL::OnDeMorgan( const TOOL_EVENT& aEvent ) { - int convert = aEvent.IsAction( &EE_ACTIONS::showDeMorganStandard ) ? - LIB_ITEM::BODY_STYLE::BASE : LIB_ITEM::BODY_STYLE::DEMORGAN; + int bodyStyle = aEvent.IsAction( &EE_ACTIONS::showDeMorganStandard ) ? BODY_STYLE::BASE + : BODY_STYLE::DEMORGAN; if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) { @@ -492,7 +492,7 @@ int SYMBOL_EDITOR_CONTROL::OnDeMorgan( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection ); SYMBOL_EDIT_FRAME* symbolEditor = static_cast( m_frame ); - symbolEditor->SetBodyStyle( convert ); + symbolEditor->SetBodyStyle( bodyStyle ); m_toolMgr->ResetTools( TOOL_BASE::MODEL_RELOAD ); symbolEditor->RebuildView(); @@ -500,7 +500,7 @@ int SYMBOL_EDITOR_CONTROL::OnDeMorgan( const TOOL_EVENT& aEvent ) else if( m_frame->IsType( FRAME_SCH_VIEWER ) ) { SYMBOL_VIEWER_FRAME* symbolViewer = static_cast( m_frame ); - symbolViewer->SetUnitAndBodyStyle( symbolViewer->GetUnit(), convert ); + symbolViewer->SetUnitAndBodyStyle( symbolViewer->GetUnit(), bodyStyle ); } return 0; diff --git a/eeschema/tools/symbol_editor_drawing_tools.cpp b/eeschema/tools/symbol_editor_drawing_tools.cpp index 720fe67189..9ac286a570 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.cpp +++ b/eeschema/tools/symbol_editor_drawing_tools.cpp @@ -70,7 +70,7 @@ bool SYMBOL_EDITOR_DRAWING_TOOLS::Init() auto isDrawingCondition = [] ( const SELECTION& aSel ) { - LIB_ITEM* item = (LIB_ITEM*) aSel.Front(); + SCH_ITEM* item = dynamic_cast( aSel.Front() ); return item && item->IsNew(); }; @@ -95,7 +95,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) EE_GRID_HELPER grid( m_toolMgr ); VECTOR2I cursorPos; bool ignorePrimePosition = false; - LIB_ITEM* item = nullptr; + SCH_ITEM* item = nullptr; bool isText = aEvent.IsAction( &EE_ACTIONS::placeSymbolText ); COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings(); @@ -685,14 +685,14 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( ACTIONS::cancelInteractive ); KIGFX::VIEW_CONTROLS* controls = getViewControls(); - std::vector newItems; // all new items, including group - std::vector selectedItems; // the group, or newItems if no group + std::vector newItems; // all new items, including group + std::vector selectedItems; // the group, or newItems if no group EE_SELECTION preview; SCH_COMMIT commit( m_toolMgr ); for( std::unique_ptr& ptr : list ) { - LIB_ITEM* item = dynamic_cast( ptr.get() ); + SCH_ITEM* item = dynamic_cast( ptr.get() ); wxCHECK2( item, continue ); newItems.push_back( item ); @@ -707,7 +707,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent ) commit.Modify( symbol, m_frame->GetScreen() ); // Place the imported drawings - for( LIB_ITEM* item : newItems ) + for( SCH_ITEM* item : newItems ) { symbol->AddDrawItem( item ); item->ClearEditFlags(); @@ -749,8 +749,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent ) VECTOR2I delta = cursorPos; VECTOR2I currentOffset; - for( LIB_ITEM* item : selectedItems ) - item->Offset( delta ); + for( SCH_ITEM* item : selectedItems ) + item->Move( delta ); currentOffset += delta; @@ -771,7 +771,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent ) { m_toolMgr->RunAction( EE_ACTIONS::clearSelection ); - for( LIB_ITEM* item : newItems ) + for( SCH_ITEM* item : newItems ) delete item; break; @@ -780,8 +780,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent ) { delta = VECTOR2I( cursorPos.x, -cursorPos.y ) - currentOffset; - for( LIB_ITEM* item : selectedItems ) - item->Offset( delta ); + for( SCH_ITEM* item : selectedItems ) + item->Move( delta ); currentOffset += delta; @@ -796,7 +796,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent ) commit.Modify( symbol, m_frame->GetScreen() ); // Place the imported drawings - for( LIB_ITEM* item : newItems ) + for( SCH_ITEM* item : newItems ) { symbol->AddDrawItem( item ); item->ClearEditFlags(); diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index a1df7b7d9e..0884f20123 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -158,7 +158,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) VECTOR2I rotPoint; bool ccw = ( aEvent.Matches( EE_ACTIONS::rotateCCW.MakeEvent() ) ); - LIB_ITEM* item = static_cast( selection.Front() ); + SCH_ITEM* item = static_cast( selection.Front() ); SCH_COMMIT localCommit( m_toolMgr ); SCH_COMMIT* commit = dynamic_cast( aEvent.Commit() ); @@ -175,7 +175,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) for( unsigned ii = 0; ii < selection.GetSize(); ii++ ) { - item = static_cast( selection.GetItem( ii ) ); + item = static_cast( selection.GetItem( ii ) ); item->Rotate( rotPoint, ccw ); m_frame->UpdateItem( item, false, true ); } @@ -207,7 +207,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) VECTOR2I mirrorPoint; bool xAxis = ( aEvent.Matches( EE_ACTIONS::mirrorV.MakeEvent() ) ); - LIB_ITEM* item = static_cast( selection.Front() ); + SCH_ITEM* item = static_cast( selection.Front() ); if( !item->IsMoving() ) saveCopyInUndoList( m_frame->GetCurSymbol(), UNDO_REDO::LIBEDIT ); @@ -248,7 +248,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) for( unsigned ii = 0; ii < selection.GetSize(); ii++ ) { - item = static_cast( selection.GetItem( ii ) ); + item = static_cast( selection.GetItem( ii ) ); if( xAxis ) item->MirrorVertically( mirrorPoint.y ); @@ -299,7 +299,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) commit.Modify( symbol, m_frame->GetScreen() ); - std::set toDelete; + std::set toDelete; for( EDA_ITEM* item : items ) { @@ -347,11 +347,11 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) } else { - toDelete.insert( (LIB_ITEM*) item ); + toDelete.insert( (SCH_ITEM*) item ); } } - for( LIB_ITEM* item : toDelete ) + for( SCH_ITEM* item : toDelete ) symbol->RemoveDrawItem( item ); commit.Push( _( "Delete" ) ); @@ -449,7 +449,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) } else if( selection.Size() == 1 ) { - LIB_ITEM* item = (LIB_ITEM*) selection.Front(); + SCH_ITEM* item = static_cast( selection.Front() ); // Save copy for undo if not in edit (edit command already handle the save copy) if( item->GetEditFlags() == 0 ) @@ -513,7 +513,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties( LIB_SHAPE* aShape ) } -void SYMBOL_EDITOR_EDIT_TOOL::editTextProperties( LIB_ITEM* aItem ) +void SYMBOL_EDITOR_EDIT_TOOL::editTextProperties( SCH_ITEM* aItem ) { if ( aItem->Type() != LIB_TEXT_T ) return; @@ -529,7 +529,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editTextProperties( LIB_ITEM* aItem ) } -void SYMBOL_EDITOR_EDIT_TOOL::editTextBoxProperties( LIB_ITEM* aItem ) +void SYMBOL_EDITOR_EDIT_TOOL::editTextBoxProperties( SCH_ITEM* aItem ) { if ( aItem->Type() != LIB_TEXTBOX_T ) return; @@ -765,7 +765,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent ) if( !symbol || !selection.GetSize() ) return 0; - for( LIB_ITEM& item : symbol->GetDrawItems() ) + for( SCH_ITEM& item : symbol->GetDrawItems() ) { if( item.Type() == LIB_FIELD_T ) continue; @@ -783,7 +783,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent ) delete partCopy; - for( LIB_ITEM& item : symbol->GetDrawItems() ) + for( SCH_ITEM& item : symbol->GetDrawItems() ) item.ClearFlags( STRUCT_DELETED ); if( m_toolMgr->SaveClipboard( formatter.GetString() ) ) @@ -826,15 +826,15 @@ int SYMBOL_EDITOR_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent ) commit.Modify( symbol ); m_selectionTool->ClearSelection(); - for( LIB_ITEM& item : symbol->GetDrawItems() ) + for( SCH_ITEM& item : symbol->GetDrawItems() ) item.ClearFlags( IS_NEW | IS_PASTED | SELECTED ); - for( LIB_ITEM& item : newPart->GetDrawItems() ) + for( SCH_ITEM& item : newPart->GetDrawItems() ) { if( item.Type() == LIB_FIELD_T ) continue; - LIB_ITEM* newItem = (LIB_ITEM*) item.Duplicate(); + SCH_ITEM* newItem = item.Duplicate(); newItem->SetParent( symbol ); newItem->SetFlags( IS_NEW | IS_PASTED | SELECTED ); @@ -880,8 +880,8 @@ int SYMBOL_EDITOR_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) for( unsigned ii = 0; ii < selection.GetSize(); ++ii ) { - LIB_ITEM* oldItem = static_cast( selection.GetItem( ii ) ); - LIB_ITEM* newItem = static_cast( oldItem->Duplicate() ); + SCH_ITEM* oldItem = static_cast( selection.GetItem( ii ) ); + SCH_ITEM* newItem = oldItem->Duplicate(); if( newItem->Type() == LIB_PIN_T ) { diff --git a/eeschema/tools/symbol_editor_edit_tool.h b/eeschema/tools/symbol_editor_edit_tool.h index 2314f4a174..547e2a9346 100644 --- a/eeschema/tools/symbol_editor_edit_tool.h +++ b/eeschema/tools/symbol_editor_edit_tool.h @@ -66,8 +66,8 @@ public: private: void editShapeProperties( LIB_SHAPE* aShape ); - void editTextProperties( LIB_ITEM* aItem ); - void editTextBoxProperties( LIB_ITEM* aItem ); + void editTextProperties( SCH_ITEM* aItem ); + void editTextBoxProperties( SCH_ITEM* aItem ); void editFieldProperties( LIB_FIELD* aField ); void editSymbolProperties(); void handlePinDuplication(LIB_PIN* aOldPin, LIB_PIN* aNewPin, int &aSymbolLastPinNumber ); diff --git a/eeschema/tools/symbol_editor_move_tool.cpp b/eeschema/tools/symbol_editor_move_tool.cpp index 1df710c126..956b8b5424 100644 --- a/eeschema/tools/symbol_editor_move_tool.cpp +++ b/eeschema/tools/symbol_editor_move_tool.cpp @@ -170,7 +170,7 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM { if( !m_moveInProgress ) // Prepare to start moving/dragging { - LIB_ITEM* lib_item = static_cast( selection.Front() ); + SCH_ITEM* lib_item = static_cast( selection.Front() ); // Pick up any synchronized pins // @@ -183,7 +183,7 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM for( EDA_ITEM* sel_item : selection ) { - lib_item = static_cast( sel_item ); + lib_item = static_cast( sel_item ); if( lib_item->Type() == LIB_PIN_T ) { @@ -387,7 +387,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent ) [&]( EDA_ITEM* item, const VECTOR2I& delta ) { commit.Modify( item, m_frame->GetScreen() ); - static_cast( item )->Offset( mapCoords( delta ) ); + static_cast( item )->Move( mapCoords( delta ) ); updateItem( item, true ); }; @@ -513,7 +513,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent ) void SYMBOL_EDITOR_MOVE_TOOL::moveItem( EDA_ITEM* aItem, const VECTOR2I& aDelta ) { - static_cast( aItem )->Offset( mapCoords( aDelta ) ); + static_cast( aItem )->Move( mapCoords( aDelta ) ); aItem->SetFlags( IS_MOVING ); } diff --git a/eeschema/tools/symbol_editor_pin_tool.cpp b/eeschema/tools/symbol_editor_pin_tool.cpp index 8c8d05f4bc..79e9bd043a 100644 --- a/eeschema/tools/symbol_editor_pin_tool.cpp +++ b/eeschema/tools/symbol_editor_pin_tool.cpp @@ -131,7 +131,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin ) if( !aPin->IsNew() && m_frame->SynchronizePins() && parentSymbol ) { - LIB_PINS pinList; + std::vector pinList; parentSymbol->GetPins( pinList ); // a pin can have a unit id = 0 (common to all units) to unit count @@ -270,7 +270,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::PlacePin( LIB_PIN* aPin ) if( ( pin->GetEditFlags() & IS_LINKED ) == 0 ) continue; - pin->MoveTo( aPin->GetPosition() ); + pin->SetPosition( aPin->GetPosition() ); pin->ClearFlags(); } @@ -296,7 +296,7 @@ LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::CreatePin( const VECTOR2I& aPosition, LIB_SYMBO if( m_frame->SynchronizePins() ) pin->SetFlags( IS_LINKED ); - pin->MoveTo( aPosition ); + pin->SetPosition( aPosition ); pin->SetLength( GetLastPinLength() ); pin->SetOrientation( g_LastPinOrient ); pin->SetType( g_LastPinType ); @@ -427,7 +427,7 @@ LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::RepeatPin( const LIB_PIN* aSourcePin ) case PIN_ORIENTATION::PIN_RIGHT: step.y = schIUScale.MilsToIU(-settings->m_Repeat.pin_step); break; } - pin->Offset( step ); + pin->Move( step ); wxString nextName = pin->GetName(); IncrementLabelMember( nextName, settings->m_Repeat.label_delta ); diff --git a/eeschema/widgets/panel_symbol_chooser.cpp b/eeschema/widgets/panel_symbol_chooser.cpp index 18e63f4725..975bc7a490 100644 --- a/eeschema/widgets/panel_symbol_chooser.cpp +++ b/eeschema/widgets/panel_symbol_chooser.cpp @@ -604,9 +604,9 @@ void PANEL_SYMBOL_CHOOSER::populateFootprintSelector( LIB_ID const& aLibId ) if( symbol != nullptr ) { - LIB_PINS temp_pins; - LIB_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD ); - wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" ); + std::vector temp_pins; + LIB_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD ); + wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" ); // All units, but only a single De Morgan variant. if( symbol->HasAlternateBodyStyle() ) diff --git a/eeschema/widgets/symbol_diff_widget.cpp b/eeschema/widgets/symbol_diff_widget.cpp index 76d6cc799e..cfe77aba98 100644 --- a/eeschema/widgets/symbol_diff_widget.cpp +++ b/eeschema/widgets/symbol_diff_widget.cpp @@ -133,7 +133,7 @@ void SYMBOL_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent ) m_previewItem->SetForcedTransparency( val ); view->Update( m_previewItem ); - for( LIB_ITEM& child : m_previewItem->GetDrawItems() ) + for( SCH_ITEM& child : m_previewItem->GetDrawItems() ) { child.SetForcedTransparency( val ); view->Update( &child ); @@ -152,7 +152,7 @@ void SYMBOL_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent ) m_libraryItem->SetForcedTransparency( val ); view->Update( m_libraryItem ); - for( LIB_ITEM& child : m_libraryItem->GetDrawItems() ) + for( SCH_ITEM& child : m_libraryItem->GetDrawItems() ) { child.SetForcedTransparency( val ); view->Update( &child ); diff --git a/include/eda_item.h b/include/eda_item.h index 38796083ce..d649e71806 100644 --- a/include/eda_item.h +++ b/include/eda_item.h @@ -137,7 +137,7 @@ public: return m_flags & mask; } - void ClearEditFlags() + virtual void ClearEditFlags() { ClearFlags( GetEditFlags() ); } @@ -149,7 +149,7 @@ public: return m_flags & mask; } - void ClearTempFlags() + virtual void ClearTempFlags() { ClearFlags( GetTempFlags() ); } @@ -450,7 +450,7 @@ public: * of nesting of this object within the overall tree. * @param os The ostream& to output to. */ - virtual void Show( int nestLevel, std::ostream& os ) const = 0; + virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); }; void ShowDummy( std::ostream& os ) const; ///< call this if you are a lazy developer diff --git a/include/properties/property.h b/include/properties/property.h index 68ac01b88c..77e45fc702 100644 --- a/include/properties/property.h +++ b/include/properties/property.h @@ -201,8 +201,9 @@ PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = PT_DEFAULT, m_display( aDisplay ), m_coordType( aCoordType ), m_hideFromPropertiesManager( false ), - m_hideFromRulesEditor( false ), m_hideFromLibraryEditors( false ), + m_hideFromDesignEditors( false ), + m_hideFromRulesEditor( false ), m_availFunc( [](INSPECTABLE*)->bool { return true; } ), m_writeableFunc( [](INSPECTABLE*)->bool { return true; } ), m_validator( NullValidator ) @@ -316,6 +317,13 @@ PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = PT_DEFAULT, return *this; } + bool IsHiddenFromDesignEditors() const { return m_hideFromDesignEditors; } + PROPERTY_BASE& SetIsHiddenFromDesignEditors( bool aIsHidden = true ) + { + m_hideFromDesignEditors = aIsHidden; + return *this; + } + wxString Group() const { return m_group; } PROPERTY_BASE& SetGroup( const wxString& aGroup ) { m_group = aGroup; return *this; } @@ -411,14 +419,12 @@ private: /// The coordinate type controls how distances are mapped to the user coordinate system ORIGIN_TRANSFORMS::COORD_TYPES_T m_coordType; - /// Some properties should not be shown in the Properties Manager GUI - bool m_hideFromPropertiesManager; - - /// Some properties should not be shown in the Custom Rules editor autocomplete - bool m_hideFromRulesEditor; - - /// This property should only be shown in the design editor, not the library editor - bool m_hideFromLibraryEditors; + bool m_hideFromPropertiesManager; // Do not show in Properties Manager + bool m_hideFromLibraryEditors; // Do not show in Properties Manager of symbol or + // footprint editors + bool m_hideFromDesignEditors; // Do not show in Properties Manager of schematic or + // board editors + bool m_hideFromRulesEditor; // Do not show in Custom Rules editor autocomplete /// Optional group identifier wxString m_group; diff --git a/qa/tests/eeschema/test_ee_item.cpp b/qa/tests/eeschema/test_ee_item.cpp index 66856ff4ee..98279ed6d5 100644 --- a/qa/tests/eeschema/test_ee_item.cpp +++ b/qa/tests/eeschema/test_ee_item.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include @@ -175,7 +174,6 @@ BOOST_AUTO_TEST_CASE( Move ) VECTOR2I originalPos = item->GetPosition(); SCH_ITEM* schItem = dynamic_cast( item.get() ); - LIB_ITEM* libItem = dynamic_cast( item.get() ); // Move to a point, then go back. // This has to be an identity transformation. @@ -188,14 +186,6 @@ BOOST_AUTO_TEST_CASE( Move ) schItem->Move( -aRef ); } - if( libItem != nullptr ) - { - libItem->MoveTo( libItem->GetPosition() + aRef ); - BOOST_CHECK_EQUAL( libItem->GetPosition(), originalPos + aRef ); - - libItem->MoveTo( libItem->GetPosition() - aRef ); - } - CompareItems( item.get(), aOriginalItem ); } ); } @@ -224,7 +214,6 @@ BOOST_AUTO_TEST_CASE( Rotate ) auto newItem = std::unique_ptr( item->Clone() ); SCH_ITEM* schItem = dynamic_cast( newItem.get() ); - LIB_ITEM* libItem = dynamic_cast( newItem.get() ); if( schItem != nullptr ) { @@ -236,14 +225,6 @@ BOOST_AUTO_TEST_CASE( Rotate ) schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false ); } - if( libItem != nullptr ) - { - libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false ); - libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false ); - libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false ); - libItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter(), false ); - } - CompareItems( newItem.get(), item.get() ); } else @@ -255,7 +236,6 @@ BOOST_AUTO_TEST_CASE( Rotate ) auto item = std::unique_ptr( aOriginalItem->Clone() ); SCH_ITEM* schItem = dynamic_cast( item.get() ); - LIB_ITEM* libItem = dynamic_cast( item.get() ); if( schItem != nullptr ) { @@ -266,14 +246,6 @@ BOOST_AUTO_TEST_CASE( Rotate ) schItem->Rotate( aRef, false ); } - if( libItem != nullptr ) - { - libItem->Rotate( aRef, false ); - libItem->Rotate( aRef, false ); - libItem->Rotate( aRef, false ); - libItem->Rotate( aRef, false ); - } - CompareItems( item.get(), aOriginalItem ); } ); } @@ -302,7 +274,6 @@ BOOST_AUTO_TEST_CASE( MirrorHorizontally ) auto item = std::unique_ptr( aOriginalItem->Clone() ); SCH_ITEM* schItem = dynamic_cast( item.get() ); - LIB_ITEM* libItem = dynamic_cast( item.get() ); // Two mirrorings are an identity // (warning: only for text items having no autoplaced fields). @@ -313,12 +284,6 @@ BOOST_AUTO_TEST_CASE( MirrorHorizontally ) schItem->MirrorHorizontally( aRef.x ); } - if( libItem != nullptr ) - { - libItem->MirrorHorizontally( aRef.x ); - libItem->MirrorHorizontally( aRef.x ); - } - CompareItems( item.get(), aOriginalItem ); } ); } @@ -346,7 +311,6 @@ BOOST_AUTO_TEST_CASE( MirrorVertically ) auto item = std::unique_ptr( aOriginalItem->Clone() ); SCH_ITEM* schItem = dynamic_cast( item.get() ); - LIB_ITEM* libItem = dynamic_cast( item.get() ); // Two mirrorings are an identity // (warning only for text items having no autoplaced fields). @@ -358,12 +322,6 @@ BOOST_AUTO_TEST_CASE( MirrorVertically ) schItem->MirrorVertically( aRef.y ); } - if( libItem != nullptr ) - { - libItem->MirrorVertically( aRef.y ); - libItem->MirrorVertically( aRef.y ); - } - CompareItems( item.get(), aOriginalItem ); } ); } diff --git a/qa/tests/eeschema/test_lib_part.cpp b/qa/tests/eeschema/test_lib_part.cpp index 8fd93bf0f4..99fb2d9d9a 100644 --- a/qa/tests/eeschema/test_lib_part.cpp +++ b/qa/tests/eeschema/test_lib_part.cpp @@ -372,7 +372,7 @@ BOOST_AUTO_TEST_CASE( Compare ) BOOST_CHECK_EQUAL( m_part_no_data.Compare( m_part_no_data ), 0 ); // Test for identical LIB_SYMBOL. - BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart ), 0 ); + BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ), 0 ); // Test name. testPart.SetName( "tart_name" ); @@ -411,22 +411,22 @@ BOOST_AUTO_TEST_CASE( Compare ) // Draw item list size comparison tests. testPart.AddDrawItem( new LIB_SHAPE( &testPart, SHAPE_T::RECTANGLE ) ); m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::RECTANGLE ) ); - BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart ), 0 ); + BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ), 0 ); m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_SHAPE_T].front() ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 ); testPart.RemoveDrawItem( &testPart.GetDrawItems()[LIB_SHAPE_T].front() ); m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::RECTANGLE ) ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_SHAPE_T].front() ); // Draw item list contents comparison tests. testPart.AddDrawItem( new LIB_SHAPE( &testPart, SHAPE_T::RECTANGLE ) ); m_part_no_data.AddDrawItem( new LIB_SHAPE( &m_part_no_data, SHAPE_T::ARC ) ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_SHAPE_T].front() ); testPart.RemoveDrawItem( &testPart.GetDrawItems()[LIB_SHAPE_T].front() ); m_part_no_data.AddDrawItem( new LIB_PIN( &m_part_no_data ) ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[LIB_PIN_T].front() ); // Footprint filter array comparison tests. @@ -434,11 +434,11 @@ BOOST_AUTO_TEST_CASE( Compare ) BOOST_CHECK( m_part_no_data.GetFPFilters() == footPrintFilters ); footPrintFilters.Add( "b" ); testPart.SetFPFilters( footPrintFilters ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 ); m_part_no_data.SetFPFilters( footPrintFilters ); footPrintFilters.Clear(); testPart.SetFPFilters( footPrintFilters ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); footPrintFilters.Clear(); m_part_no_data.SetFPFilters( footPrintFilters ); testPart.SetFPFilters( footPrintFilters ); @@ -446,70 +446,70 @@ BOOST_AUTO_TEST_CASE( Compare ) // Description string tests. m_part_no_data.SetDescription( "b" ); testPart.SetDescription( "b" ); - BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart ), 0 ); + BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ), 0 ); m_part_no_data.SetDescription( "a" ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 ); m_part_no_data.SetDescription( "c" ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); m_part_no_data.SetDescription( wxEmptyString ); testPart.SetDescription( wxEmptyString ); // Key word string tests. m_part_no_data.SetKeyWords( "b" ); testPart.SetKeyWords( "b" ); - BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart ), 0 ); + BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ), 0 ); m_part_no_data.SetKeyWords( "a" ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 ); m_part_no_data.SetKeyWords( "c" ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); m_part_no_data.SetKeyWords( wxEmptyString ); testPart.SetKeyWords( wxEmptyString ); // Pin name offset comparison tests. testPart.SetPinNameOffset( testPart.GetPinNameOffset() + 1 ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 ); testPart.SetPinNameOffset( testPart.GetPinNameOffset() - 2 ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); testPart.SetPinNameOffset( testPart.GetPinNameOffset() + 1 ); // Units locked flag comparison tests. testPart.LockUnits( true ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 ); testPart.LockUnits( false ); m_part_no_data.LockUnits( true ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); m_part_no_data.LockUnits( false ); // Include in BOM support tests. testPart.SetExcludedFromBOM( true ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); testPart.SetExcludedFromBOM( false ); m_part_no_data.SetExcludedFromBOM( true ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 ); m_part_no_data.SetExcludedFromBOM( false ); // Include on board support tests. testPart.SetExcludedFromBoard( true ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); testPart.SetExcludedFromBoard( false ); m_part_no_data.SetExcludedFromBoard( true ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 ); m_part_no_data.SetExcludedFromBoard( false ); // Show pin names flag comparison tests. m_part_no_data.SetShowPinNames( false ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 ); m_part_no_data.SetShowPinNames( true ); testPart.SetShowPinNames( false ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); testPart.SetShowPinNames( true ); // Show pin numbers flag comparison tests. m_part_no_data.SetShowPinNumbers( false ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) < 0 ); m_part_no_data.SetShowPinNumbers( true ); testPart.SetShowPinNumbers( false ); - BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); + BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 0 ); testPart.SetShowPinNumbers( true ); // Time stamp comparison tests.