RIP LIB_PIN.

This commit is contained in:
Jeff Young 2024-04-20 10:44:34 +01:00
parent 6d11c85cad
commit 95136494b3
87 changed files with 2724 additions and 2970 deletions

View File

@ -75,7 +75,6 @@ KICAD_T FromProtoEnum( types::KiCadObjectType aValue )
case types::KiCadObjectType::KOT_SCH_SHEET: return SCH_SHEET_T; case types::KiCadObjectType::KOT_SCH_SHEET: return SCH_SHEET_T;
case types::KiCadObjectType::KOT_SCH_PIN: return SCH_PIN_T; case types::KiCadObjectType::KOT_SCH_PIN: return SCH_PIN_T;
case types::KiCadObjectType::KOT_LIB_SYMBOL: return LIB_SYMBOL_T; case types::KiCadObjectType::KOT_LIB_SYMBOL: return LIB_SYMBOL_T;
// case types::KiCadObjectType::KOT_LIB_PIN: return LIB_PIN_T;
case types::KiCadObjectType::KOT_WSG_LINE: return WSG_LINE_T; case types::KiCadObjectType::KOT_WSG_LINE: return WSG_LINE_T;
case types::KiCadObjectType::KOT_WSG_RECT: return WSG_RECT_T; case types::KiCadObjectType::KOT_WSG_RECT: return WSG_RECT_T;
case types::KiCadObjectType::KOT_WSG_POLY: return WSG_POLY_T; case types::KiCadObjectType::KOT_WSG_POLY: return WSG_POLY_T;
@ -135,7 +134,6 @@ types::KiCadObjectType ToProtoEnum( KICAD_T aValue )
case SCH_SHEET_T: return types::KiCadObjectType::KOT_SCH_SHEET; case SCH_SHEET_T: return types::KiCadObjectType::KOT_SCH_SHEET;
case SCH_PIN_T: return types::KiCadObjectType::KOT_SCH_PIN; case SCH_PIN_T: return types::KiCadObjectType::KOT_SCH_PIN;
case LIB_SYMBOL_T: return types::KiCadObjectType::KOT_LIB_SYMBOL; case LIB_SYMBOL_T: return types::KiCadObjectType::KOT_LIB_SYMBOL;
// case LIB_PIN_T: return types::KiCadObjectType::KOT_LIB_PIN;
case WSG_LINE_T: return types::KiCadObjectType::KOT_WSG_LINE; case WSG_LINE_T: return types::KiCadObjectType::KOT_WSG_LINE;
case WSG_RECT_T: return types::KiCadObjectType::KOT_WSG_RECT; case WSG_RECT_T: return types::KiCadObjectType::KOT_WSG_RECT;
case WSG_POLY_T: return types::KiCadObjectType::KOT_WSG_POLY; case WSG_POLY_T: return types::KiCadObjectType::KOT_WSG_POLY;

View File

@ -396,7 +396,6 @@ static struct EDA_ITEM_DESC
.Map( SCH_SCREEN_T, _HKI( "SCH Screen" ) ) .Map( SCH_SCREEN_T, _HKI( "SCH Screen" ) )
.Map( LIB_SYMBOL_T, _HKI( "Symbol" ) ) .Map( LIB_SYMBOL_T, _HKI( "Symbol" ) )
.Map( LIB_PIN_T, _HKI( "Pin" ) )
.Map( GERBER_LAYOUT_T, _HKI( "Gerber Layout" ) ) .Map( GERBER_LAYOUT_T, _HKI( "Gerber Layout" ) )
.Map( GERBER_DRAW_ITEM_T, _HKI( "Draw Item" ) ) .Map( GERBER_DRAW_ITEM_T, _HKI( "Draw Item" ) )

View File

@ -151,8 +151,13 @@ void GRPrintText( wxDC* aDC, const VECTOR2I& aPos, const COLOR4D& aColor, const
if( !aFont ) if( !aFont )
aFont = KIFONT::FONT::GetFont(); aFont = KIFONT::FONT::GetFont();
if( aWidth == 0 && aBold ) // Use default values if aWidth == 0 if( aWidth == 0 ) // Use default values if aWidth == 0
aWidth = GetPenSizeForBold( std::min( aSize.x, aSize.y ) ); {
if( aBold )
aWidth = GetPenSizeForBold( std::min( aSize.x, aSize.y ) );
else
aWidth = GetPenSizeForNormal( std::min( aSize.x, aSize.y ) );
}
if( aWidth < 0 ) if( aWidth < 0 )
{ {

View File

@ -353,7 +353,6 @@ set( EESCHEMA_SRCS
generate_alias_info.cpp generate_alias_info.cpp
gfx_import_utils.cpp gfx_import_utils.cpp
picksymbol.cpp picksymbol.cpp
lib_pin.cpp
lib_symbol.cpp lib_symbol.cpp
libarch.cpp libarch.cpp
menubar.cpp menubar.cpp

View File

@ -18,7 +18,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <lib_pin.h> #include <sch_pin.h>
#include <lib_symbol.h> #include <lib_symbol.h>
#include <sch_bitmap.h> #include <sch_bitmap.h>
#include <sch_bus_entry.h> #include <sch_bus_entry.h>
@ -41,10 +41,6 @@
std::unique_ptr<EDA_ITEM> CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer ) std::unique_ptr<EDA_ITEM> CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer )
{ {
SCH_ITEM* parentSchItem = dynamic_cast<SCH_ITEM*>( aContainer ); SCH_ITEM* parentSchItem = dynamic_cast<SCH_ITEM*>( aContainer );
LIB_SYMBOL* parentLibSymbol = nullptr;
if( aContainer && aContainer->Type() == LIB_SYMBOL_T )
parentLibSymbol = static_cast<LIB_SYMBOL*>( aContainer );
switch( aType ) switch( aType )
{ {
@ -83,13 +79,13 @@ std::unique_ptr<EDA_ITEM> CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer
case SCH_PIN_T: case SCH_PIN_T:
{ {
// TODO: constructing currently requires LIB_PIN and SCH_SYMBOL ptr, if( aContainer && aContainer->Type() == LIB_SYMBOL_T )
// or SCH_SYMBOL and number+alt. Need to determine ideal default ctor. return std::make_unique<SCH_PIN>( static_cast<LIB_SYMBOL*>( aContainer ) );
return nullptr; return nullptr;
} }
case LIB_SYMBOL_T: return nullptr; // TODO: ctor currently requires non-null name case LIB_SYMBOL_T: return nullptr; // TODO: ctor currently requires non-null name
case LIB_PIN_T: return std::make_unique<LIB_PIN>( parentLibSymbol );
default: default:
return nullptr; return nullptr;

View File

@ -53,10 +53,9 @@
#include <boost/range/adaptor/reversed.hpp> #include <boost/range/adaptor/reversed.hpp>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <hotkeys_basic.h>
#include <sch_symbol.h> #include <sch_symbol.h>
#include <sch_line.h> #include <sch_line.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <kiface_base.h> #include <kiface_base.h>
#include <algorithm> #include <algorithm>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>

View File

@ -654,9 +654,7 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
} }
else if( item->Type() == SCH_SHEET_T ) else if( item->Type() == SCH_SHEET_T )
{ {
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item ); for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
{ {
if( pin->IsConnectivityDirty() ) if( pin->IsConnectivityDirty() )
{ {
@ -976,7 +974,7 @@ void CONNECTION_GRAPH::removeSubgraphs( std::set<CONNECTION_SUBGRAPH*>& aSubgrap
for( auto it = m_net_name_to_code_map.begin(); it != m_net_name_to_code_map.end(); ) for( auto it = m_net_name_to_code_map.begin(); it != m_net_name_to_code_map.end(); )
{ {
if( codes_to_remove.find( it->second ) != codes_to_remove.end() ) if( codes_to_remove.contains( it->second ) )
it = m_net_name_to_code_map.erase( it ); it = m_net_name_to_code_map.erase( it );
else else
++it; ++it;
@ -984,7 +982,7 @@ void CONNECTION_GRAPH::removeSubgraphs( std::set<CONNECTION_SUBGRAPH*>& aSubgrap
for( auto it = m_bus_name_to_code_map.begin(); it != m_bus_name_to_code_map.end(); ) for( auto it = m_bus_name_to_code_map.begin(); it != m_bus_name_to_code_map.end(); )
{ {
if( codes_to_remove.find( it->second ) != codes_to_remove.end() ) if( codes_to_remove.contains( it->second ) )
it = m_bus_name_to_code_map.erase( it ); it = m_bus_name_to_code_map.erase( it );
else else
++it; ++it;
@ -1657,7 +1655,7 @@ void CONNECTION_GRAPH::processSubGraphs()
{ {
wxString new_name = create_new_name( connection ); wxString new_name = create_new_name( connection );
while( m_net_name_to_subgraphs_map.count( new_name ) ) while( m_net_name_to_subgraphs_map.contains( new_name ) )
new_name = create_new_name( connection ); new_name = create_new_name( connection );
wxLogTrace( ConnTrace, wxLogTrace( ConnTrace,
@ -2388,7 +2386,7 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo
{ {
if( !candidate->m_strong_driver if( !candidate->m_strong_driver
|| candidate->m_hier_ports.empty() || candidate->m_hier_ports.empty()
|| visited.count( candidate ) ) || visited.contains( candidate ) )
{ {
continue; continue;
} }
@ -2425,7 +2423,7 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo
for( CONNECTION_SUBGRAPH* candidate : it->second ) for( CONNECTION_SUBGRAPH* candidate : it->second )
{ {
if( candidate->m_hier_pins.empty() if( candidate->m_hier_pins.empty()
|| visited.count( candidate ) || visited.contains( candidate )
|| candidate->m_driver_connection->Type() != aParent->m_driver_connection->Type() ) || candidate->m_driver_connection->Type() != aParent->m_driver_connection->Type() )
{ {
continue; continue;
@ -3470,7 +3468,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
if( pin ) if( pin )
{ {
ercItem->SetItems( pin, aSubgraph->m_no_connect ); ercItem->SetItems( pin, aSubgraph->m_no_connect );
pos = pin->GetTransformedPosition(); pos = pin->GetPosition();
} }
else else
{ {
@ -3586,7 +3584,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
ercItem->SetItemsSheetPaths( sheet ); ercItem->SetItemsSheetPaths( sheet );
ercItem->SetItems( pin ); ercItem->SetItems( pin );
SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetTransformedPosition() ); SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetPosition() );
screen->Append( marker ); screen->Append( marker );
ok = false; ok = false;
@ -3611,8 +3609,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
ercItem->SetItemsSheetPaths( sheet ); ercItem->SetItemsSheetPaths( sheet );
ercItem->SetItems( testPin ); ercItem->SetItems( testPin );
SCH_MARKER* marker = new SCH_MARKER( ercItem, SCH_MARKER* marker = new SCH_MARKER( ercItem, testPin->GetPosition() );
testPin->GetTransformedPosition() );
screen->Append( marker ); screen->Append( marker );
ok = false; ok = false;

View File

@ -26,11 +26,9 @@
#define _DIALOG_ERC_H_ #define _DIALOG_ERC_H_
#include <wx/htmllbox.h> #include <wx/htmllbox.h>
#include <lib_pin.h> // For PINTYPE_COUNT definition
#include <dialog_erc_base.h> #include <dialog_erc_base.h>
#include <widgets/progress_reporter_base.h> #include <widgets/progress_reporter_base.h>
#include <erc_settings.h>
/** /**

View File

@ -162,14 +162,10 @@ DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const
* pinNumber pinName <tab> pinNumber pinName... * pinNumber pinName <tab> pinNumber pinName...
* fpFilter fpFilter... * fpFilter fpFilter...
*/ */
wxString netlist; wxString netlist;
std::vector<LIB_PIN*> pinList;
symbol->GetPins( pinList, 0, 1 ); // All units, but a single convert
wxArrayString pins; wxArrayString pins;
for( LIB_PIN* pin : pinList ) for( SCH_PIN* pin : symbol->GetPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() ); pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
if( !pins.IsEmpty() ) if( !pins.IsEmpty() )

View File

@ -23,8 +23,8 @@
#include "dialog_lib_edit_pin_table.h" #include "dialog_lib_edit_pin_table.h"
#include "grid_tricks.h" #include "grid_tricks.h"
#include "lib_pin.h" #include <sch_pin.h>
#include "pin_numbers.h" #include <pin_numbers.h>
#include "pgm_base.h" #include "pgm_base.h"
#include <base_units.h> #include <base_units.h>
#include <bitmaps.h> #include <bitmaps.h>
@ -155,7 +155,7 @@ public:
return GetValue( m_rows[ aRow ], aCol, m_frame ); return GetValue( m_rows[ aRow ], aCol, m_frame );
} }
static wxString GetValue( const std::vector<LIB_PIN*>& pins, int aCol, static wxString GetValue( const std::vector<SCH_PIN*>& pins, int aCol,
EDA_DRAW_FRAME* aParentFrame ) EDA_DRAW_FRAME* aParentFrame )
{ {
wxString fieldValue; wxString fieldValue;
@ -163,7 +163,7 @@ public:
if( pins.empty() ) if( pins.empty() )
return fieldValue; return fieldValue;
for( LIB_PIN* pin : pins ) for( SCH_PIN* pin : pins )
{ {
wxString val; wxString val;
@ -292,7 +292,7 @@ public:
break; break;
} }
std::vector<LIB_PIN*> pins = m_rows[ aRow ]; std::vector<SCH_PIN*> pins = m_rows[ aRow ];
// If the NUMBER column is edited and the pins are grouped, renumber, and add or // 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. // remove pins based on the comma separated list of pins.
@ -316,8 +316,8 @@ public:
else else
{ {
// Create new pins // Create new pins
LIB_PIN* newPin = new LIB_PIN( this->m_symbol ); SCH_PIN* newPin = new SCH_PIN( this->m_symbol );
LIB_PIN* last = pins.back(); SCH_PIN* last = pins.back();
newPin->SetNumber( pinName ); newPin->SetNumber( pinName );
newPin->SetName( last->GetName() ); newPin->SetName( last->GetName() );
@ -361,7 +361,7 @@ public:
return; return;
} }
for( LIB_PIN* pin : pins ) for( SCH_PIN* pin : pins )
{ {
switch( aCol ) switch( aCol )
{ {
@ -454,7 +454,7 @@ public:
m_edited = true; m_edited = true;
} }
static int findRow( const std::vector<std::vector<LIB_PIN*>>& aRowSet, const wxString& aName ) static int findRow( const std::vector<std::vector<SCH_PIN*>>& aRowSet, const wxString& aName )
{ {
for( size_t i = 0; i < aRowSet.size(); ++i ) for( size_t i = 0; i < aRowSet.size(); ++i )
{ {
@ -465,7 +465,7 @@ public:
return -1; return -1;
} }
static bool compare( const std::vector<LIB_PIN*>& lhs, const std::vector<LIB_PIN*>& rhs, static bool compare( const std::vector<SCH_PIN*>& lhs, const std::vector<SCH_PIN*>& rhs,
int sortCol, bool ascending, EDA_DRAW_FRAME* parentFrame ) int sortCol, bool ascending, EDA_DRAW_FRAME* parentFrame )
{ {
wxString lhStr = GetValue( lhs, sortCol, parentFrame ); wxString lhStr = GetValue( lhs, sortCol, parentFrame );
@ -518,10 +518,10 @@ public:
return res; return res;
} }
void RebuildRows( const std::vector<LIB_PIN*>& aPins, bool groupByName, bool groupBySelection ) void RebuildRows( const std::vector<SCH_PIN*>& aPins, bool groupByName, bool groupBySelection )
{ {
WX_GRID* grid = dynamic_cast<WX_GRID*>( GetView() ); WX_GRID* grid = dynamic_cast<WX_GRID*>( GetView() );
std::vector<LIB_PIN*> clear_flags; std::vector<SCH_PIN*> clear_flags;
clear_flags.reserve( aPins.size() ); clear_flags.reserve( aPins.size() );
@ -529,7 +529,7 @@ public:
{ {
if( groupBySelection ) if( groupBySelection )
{ {
for( LIB_PIN* pin : aPins ) for( SCH_PIN* pin : aPins )
pin->ClearTempFlags(); pin->ClearTempFlags();
int firstSelectedRow; int firstSelectedRow;
@ -539,7 +539,7 @@ public:
for( int ii = 0; ii < selectedRowCount; ++ii ) for( int ii = 0; ii < selectedRowCount; ++ii )
{ {
for( LIB_PIN* pin : m_rows[ firstSelectedRow + ii ] ) for( SCH_PIN* pin : m_rows[ firstSelectedRow + ii ] )
{ {
pin->SetFlags( CANDIDATE ); pin->SetFlags( CANDIDATE );
clear_flags.push_back( pin ); clear_flags.push_back( pin );
@ -558,9 +558,9 @@ public:
m_rows.clear(); m_rows.clear();
if( groupBySelection ) if( groupBySelection )
m_rows.emplace_back( std::vector<LIB_PIN*>() ); m_rows.emplace_back( std::vector<SCH_PIN*>() );
for( LIB_PIN* pin : aPins ) for( SCH_PIN* pin : aPins )
{ {
if( m_unitFilter == -1 || pin->GetUnit() == 0 || pin->GetUnit() == m_unitFilter ) if( m_unitFilter == -1 || pin->GetUnit() == 0 || pin->GetUnit() == m_unitFilter )
{ {
@ -573,7 +573,7 @@ public:
if( rowIndex < 0 ) if( rowIndex < 0 )
{ {
m_rows.emplace_back( std::vector<LIB_PIN*>() ); m_rows.emplace_back( std::vector<SCH_PIN*>() );
rowIndex = m_rows.size() - 1; rowIndex = m_rows.size() - 1;
} }
@ -590,7 +590,7 @@ public:
ascending = GetView()->IsSortOrderAscending(); ascending = GetView()->IsSortOrderAscending();
} }
for( std::vector<LIB_PIN*>& row : m_rows ) for( std::vector<SCH_PIN*>& row : m_rows )
SortPins( row ); SortPins( row );
if( !groupBySelection ) if( !groupBySelection )
@ -605,32 +605,32 @@ public:
GetView()->SelectRow( 0 ); GetView()->SelectRow( 0 );
} }
for( LIB_PIN* pin : clear_flags ) for( SCH_PIN* pin : clear_flags )
pin->ClearFlags( CANDIDATE ); pin->ClearFlags( CANDIDATE );
} }
void SortRows( int aSortCol, bool ascending ) void SortRows( int aSortCol, bool ascending )
{ {
std::sort( m_rows.begin(), m_rows.end(), std::sort( m_rows.begin(), m_rows.end(),
[ aSortCol, ascending, this ]( const std::vector<LIB_PIN*>& lhs, [ aSortCol, ascending, this ]( const std::vector<SCH_PIN*>& lhs,
const std::vector<LIB_PIN*>& rhs ) -> bool const std::vector<SCH_PIN*>& rhs ) -> bool
{ {
return compare( lhs, rhs, aSortCol, ascending, m_frame ); return compare( lhs, rhs, aSortCol, ascending, m_frame );
} ); } );
} }
void SortPins( std::vector<LIB_PIN*>& aRow ) void SortPins( std::vector<SCH_PIN*>& aRow )
{ {
std::sort( aRow.begin(), aRow.end(), std::sort( aRow.begin(), aRow.end(),
[]( LIB_PIN* lhs, LIB_PIN* rhs ) -> bool []( SCH_PIN* lhs, SCH_PIN* rhs ) -> bool
{ {
return PIN_NUMBERS::Compare( lhs->GetNumber(), rhs->GetNumber() ) < 0; return PIN_NUMBERS::Compare( lhs->GetNumber(), rhs->GetNumber() ) < 0;
} ); } );
} }
void AppendRow( LIB_PIN* aPin ) void AppendRow( SCH_PIN* aPin )
{ {
std::vector<LIB_PIN*> row; std::vector<SCH_PIN*> row;
row.push_back( aPin ); row.push_back( aPin );
m_rows.push_back( row ); m_rows.push_back( row );
@ -641,9 +641,9 @@ public:
} }
} }
std::vector<LIB_PIN*> RemoveRow( int aRow ) std::vector<SCH_PIN*> RemoveRow( int aRow )
{ {
std::vector<LIB_PIN*> removedRow = m_rows[ aRow ]; std::vector<SCH_PIN*> removedRow = m_rows[ aRow ];
m_rows.erase( m_rows.begin() + aRow ); m_rows.erase( m_rows.begin() + aRow );
@ -656,7 +656,7 @@ public:
return removedRow; return removedRow;
} }
std::vector<LIB_PIN*> GetRowPins( int aRow ) std::vector<SCH_PIN*> GetRowPins( int aRow )
{ {
return m_rows[ aRow ]; return m_rows[ aRow ];
} }
@ -698,9 +698,9 @@ 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 // 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 SCH_PINs
// contains only a single pin. // contains only a single pin.
std::vector<std::vector<LIB_PIN*>> m_rows; std::vector<std::vector<SCH_PIN*>> m_rows;
int m_unitFilter; // 0 to show pins for all units int m_unitFilter; // 0 to show pins for all units
bool m_edited; bool m_edited;
@ -709,7 +709,7 @@ private:
LIB_SYMBOL* m_symbol; // Parent symbol that the pins belong to. LIB_SYMBOL* m_symbol; // Parent symbol that the pins belong to.
std::unique_ptr<NUMERIC_EVALUATOR> m_eval; std::unique_ptr<NUMERIC_EVALUATOR> m_eval;
std::map< std::pair<std::vector<LIB_PIN*>, int>, wxString > m_evalOriginal; std::map< std::pair<std::vector<SCH_PIN*>, int>, wxString > m_evalOriginal;
}; };
@ -866,7 +866,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE()
// This is our copy of the pins. If they were transferred to the part on an OK, then // This is our copy of the pins. If they were transferred to the part on an OK, then
// m_pins will already be empty. // m_pins will already be empty.
for( LIB_PIN* pin : m_pins ) for( SCH_PIN* pin : m_pins )
delete pin; delete pin;
WINDOW_THAWER thawer( m_editFrame ); WINDOW_THAWER thawer( m_editFrame );
@ -879,10 +879,10 @@ DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE()
bool DIALOG_LIB_EDIT_PIN_TABLE::TransferDataToWindow() bool DIALOG_LIB_EDIT_PIN_TABLE::TransferDataToWindow()
{ {
// Make a copy of the pins for editing // Make a copy of the pins for editing
std::vector<LIB_PIN*> pins = m_symbol->GetAllLibPins(); std::vector<SCH_PIN*> pins = m_symbol->GetAllLibPins();
for( LIB_PIN* pin : pins ) for( SCH_PIN* pin : pins )
m_pins.push_back( new LIB_PIN( *pin ) ); m_pins.push_back( new SCH_PIN( *pin ) );
m_dataModel->RebuildRows( m_pins, m_cbGroup->GetValue(), false ); m_dataModel->RebuildRows( m_pins, m_cbGroup->GetValue(), false );
@ -908,16 +908,14 @@ bool DIALOG_LIB_EDIT_PIN_TABLE::TransferDataFromWindow()
return false; return false;
// Delete the part's pins // Delete the part's pins
std::vector<LIB_PIN*> pins = m_symbol->GetAllLibPins(); std::vector<SCH_PIN*> pins = m_symbol->GetAllLibPins();
for( LIB_PIN* pin : pins ) for( SCH_PIN* pin : pins )
m_symbol->RemoveDrawItem( pin ); m_symbol->RemoveDrawItem( pin );
// Transfer our pins to the part // Transfer our pins to the part
for( LIB_PIN* pin : m_pins ) for( SCH_PIN* pin : m_pins )
{
m_symbol->AddDrawItem( pin ); m_symbol->AddDrawItem( pin );
}
m_pins.clear(); m_pins.clear();
@ -948,12 +946,12 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow( wxCommandEvent& event )
if( !m_grid->CommitPendingChanges() ) if( !m_grid->CommitPendingChanges() )
return; return;
LIB_PIN* newPin = new LIB_PIN( this->m_symbol ); SCH_PIN* newPin = new SCH_PIN( this->m_symbol );
// Copy the settings of the last pin onto the new pin. // Copy the settings of the last pin onto the new pin.
if( m_pins.size() > 0 ) if( m_pins.size() > 0 )
{ {
LIB_PIN* last = m_pins.back(); SCH_PIN* last = m_pins.back();
newPin->SetOrientation( last->GetOrientation() ); newPin->SetOrientation( last->GetOrientation() );
newPin->SetType( last->GetType() ); newPin->SetType( last->GetType() );
@ -991,7 +989,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow( wxCommandEvent& event )
} }
void DIALOG_LIB_EDIT_PIN_TABLE::AddPin( LIB_PIN* pin ) void DIALOG_LIB_EDIT_PIN_TABLE::AddPin( SCH_PIN* pin )
{ {
m_pins.push_back( pin ); m_pins.push_back( pin );
updateSummary(); updateSummary();
@ -1018,16 +1016,16 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow( wxCommandEvent& event )
m_grid->SetGridCursor( nextSelRow, m_grid->GetGridCursorCol() ); m_grid->SetGridCursor( nextSelRow, m_grid->GetGridCursorCol() );
m_grid->SelectRow( nextSelRow ); m_grid->SelectRow( nextSelRow );
std::vector<LIB_PIN*> removedRow = m_dataModel->RemoveRow( curRow ); std::vector<SCH_PIN*> removedRow = m_dataModel->RemoveRow( curRow );
for( LIB_PIN* pin : removedRow ) for( SCH_PIN* pin : removedRow )
m_pins.erase( std::find( m_pins.begin(), m_pins.end(), pin ) ); m_pins.erase( std::find( m_pins.begin(), m_pins.end(), pin ) );
updateSummary(); updateSummary();
} }
void DIALOG_LIB_EDIT_PIN_TABLE::RemovePin( LIB_PIN* pin ) void DIALOG_LIB_EDIT_PIN_TABLE::RemovePin( SCH_PIN* pin )
{ {
m_pins.erase( std::find( m_pins.begin(), m_pins.end(), pin ) ); m_pins.erase( std::find( m_pins.begin(), m_pins.end(), pin ) );
updateSummary(); updateSummary();
@ -1042,15 +1040,15 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnCellEdited( wxGridEvent& event )
void DIALOG_LIB_EDIT_PIN_TABLE::OnCellSelected( wxGridEvent& event ) void DIALOG_LIB_EDIT_PIN_TABLE::OnCellSelected( wxGridEvent& event )
{ {
LIB_PIN* pin = nullptr; SCH_PIN* pin = nullptr;
if( event.GetRow() >= 0 && event.GetRow() < m_dataModel->GetNumberRows() ) if( event.GetRow() >= 0 && event.GetRow() < m_dataModel->GetNumberRows() )
{ {
const std::vector<LIB_PIN*>& pins = m_dataModel->GetRowPins( event.GetRow() ); const std::vector<SCH_PIN*>& pins = m_dataModel->GetRowPins( event.GetRow() );
if( pins.size() == 1 && m_editFrame->GetCurSymbol() ) if( pins.size() == 1 && m_editFrame->GetCurSymbol() )
{ {
for( LIB_PIN* candidate : m_editFrame->GetCurSymbol()->GetAllLibPins() ) for( SCH_PIN* candidate : m_editFrame->GetCurSymbol()->GetAllLibPins() )
{ {
if( candidate->GetNumber() == pins.at( 0 )->GetNumber() ) if( candidate->GetNumber() == pins.at( 0 )->GetNumber() )
{ {
@ -1256,7 +1254,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::updateSummary()
{ {
PIN_NUMBERS pinNumbers; PIN_NUMBERS pinNumbers;
for( LIB_PIN* pin : m_pins ) for( SCH_PIN* pin : m_pins )
{ {
if( pin->GetNumber().Length() ) if( pin->GetNumber().Length() )
pinNumbers.insert( pin->GetNumber() ); pinNumbers.insert( pin->GetNumber() );

View File

@ -23,8 +23,7 @@
#include "dialog_lib_edit_pin_table_base.h" #include "dialog_lib_edit_pin_table_base.h"
#include <lib_pin.h> #include <sch_pin.h>
#include <symbol_library.h>
enum COL_ORDER enum COL_ORDER
{ {
@ -73,8 +72,8 @@ public:
void OnUpdateUI( wxUpdateUIEvent& event ) override; void OnUpdateUI( wxUpdateUIEvent& event ) override;
void OnCancel( wxCommandEvent& event ) override; void OnCancel( wxCommandEvent& event ) override;
void OnClose( wxCloseEvent& event ) override; void OnClose( wxCloseEvent& event ) override;
void AddPin( LIB_PIN* pin ); void AddPin( SCH_PIN* pin );
void RemovePin( LIB_PIN* pin ); void RemovePin( SCH_PIN* pin );
bool IsDisplayGrouped(); bool IsDisplayGrouped();
protected: protected:
@ -87,7 +86,7 @@ protected:
int m_originalColWidths[ COL_COUNT ]; int m_originalColWidths[ COL_COUNT ];
std::bitset<64> m_columnsShown; std::bitset<64> m_columnsShown;
LIB_SYMBOL* m_symbol; LIB_SYMBOL* m_symbol;
std::vector<LIB_PIN*> m_pins; // a copy of the pins owned by me std::vector<SCH_PIN*> m_pins; // a copy of the pins owned by me
bool m_modified; ///< true when there are unsaved changes bool m_modified; ///< true when there are unsaved changes
wxSize m_size; wxSize m_size;

View File

@ -25,7 +25,7 @@
#include <bitmaps.h> #include <bitmaps.h>
#include <sch_painter.h> #include <sch_painter.h>
#include <symbol_edit_frame.h> #include <symbol_edit_frame.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <dialog_pin_properties.h> #include <dialog_pin_properties.h>
#include <confirm.h> #include <confirm.h>
#include <kiplatform/ui.h> #include <kiplatform/ui.h>
@ -36,7 +36,7 @@
#include <widgets/std_bitmap_button.h> #include <widgets/std_bitmap_button.h>
#include <wx/hyperlink.h> #include <wx/hyperlink.h>
class ALT_PIN_DATA_MODEL : public wxGridTableBase, public std::vector<LIB_PIN::ALT> class ALT_PIN_DATA_MODEL : public wxGridTableBase, public std::vector<SCH_PIN::ALT>
{ {
public: public:
ALT_PIN_DATA_MODEL( EDA_UNITS aUserUnits ) ALT_PIN_DATA_MODEL( EDA_UNITS aUserUnits )
@ -99,7 +99,7 @@ public:
} }
} }
void AppendRow( const LIB_PIN::ALT& aAlt ) void AppendRow( const SCH_PIN::ALT& aAlt )
{ {
push_back( aAlt ); push_back( aAlt );
@ -123,7 +123,7 @@ public:
}; };
DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_PIN* aPin ) : DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, SCH_PIN* aPin ) :
DIALOG_PIN_PROPERTIES_BASE( parent ), DIALOG_PIN_PROPERTIES_BASE( parent ),
m_frame( parent ), m_frame( parent ),
m_pin( aPin ), m_pin( aPin ),
@ -138,7 +138,7 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_PIN
{ {
// Creates a dummy pin to show on a panel, inside this dialog: // Creates a dummy pin to show on a panel, inside this dialog:
m_dummyParent = new LIB_SYMBOL( *static_cast<LIB_SYMBOL*>( m_pin->GetParentSymbol() ) ); m_dummyParent = new LIB_SYMBOL( *static_cast<LIB_SYMBOL*>( m_pin->GetParentSymbol() ) );
m_dummyPin = new LIB_PIN( *m_pin ); m_dummyPin = new SCH_PIN( *m_pin );
m_dummyPin->SetParent( m_dummyParent ); m_dummyPin->SetParent( m_dummyParent );
m_dummyParent->SetShowPinNames( true ); m_dummyParent->SetShowPinNames( true );
m_dummyParent->SetShowPinNumbers( true ); m_dummyParent->SetShowPinNumbers( true );
@ -306,7 +306,7 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow()
m_checkApplyToAllParts->SetToolTip( commonUnitsToolTip ); m_checkApplyToAllParts->SetToolTip( commonUnitsToolTip );
for( const std::pair<const wxString, LIB_PIN::ALT>& alt : m_pin->GetAlternates() ) for( const std::pair<const wxString, SCH_PIN::ALT>& alt : m_pin->GetAlternates() )
m_alternatesDataModel->AppendRow( alt.second ); m_alternatesDataModel->AppendRow( alt.second );
return true; return true;
@ -364,10 +364,10 @@ bool DIALOG_PIN_PROPERTIES::TransferDataFromWindow()
m_pin->SetUnit( m_checkApplyToAllParts->GetValue() ? 0 : m_frame->GetUnit() ); m_pin->SetUnit( m_checkApplyToAllParts->GetValue() ? 0 : m_frame->GetUnit() );
m_pin->SetVisible( m_checkShow->GetValue() ); m_pin->SetVisible( m_checkShow->GetValue() );
std::map<wxString, LIB_PIN::ALT>& alternates = m_pin->GetAlternates(); std::map<wxString, SCH_PIN::ALT>& alternates = m_pin->GetAlternates();
alternates.clear(); alternates.clear();
for( const LIB_PIN::ALT& alt : *m_alternatesDataModel ) for( const SCH_PIN::ALT& alt : *m_alternatesDataModel )
alternates[ alt.m_Name ] = alt; alternates[ alt.m_Name ] = alt;
return true; return true;
@ -450,7 +450,7 @@ void DIALOG_PIN_PROPERTIES::OnAddAlternate( wxCommandEvent& event )
if( !m_alternatesGrid->CommitPendingChanges() ) if( !m_alternatesGrid->CommitPendingChanges() )
return; return;
LIB_PIN::ALT newAlt; SCH_PIN::ALT newAlt;
newAlt.m_Name = wxEmptyString; newAlt.m_Name = wxEmptyString;
newAlt.m_Type = m_pin->GetType(); newAlt.m_Type = m_pin->GetType();
newAlt.m_Shape = m_pin->GetShape(); newAlt.m_Shape = m_pin->GetShape();

View File

@ -33,7 +33,7 @@
#include <dialog_pin_properties_base.h> #include <dialog_pin_properties_base.h>
#include <widgets/unit_binder.h> #include <widgets/unit_binder.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <symbol_edit_frame.h> #include <symbol_edit_frame.h>
@ -53,7 +53,7 @@ class ALT_PIN_DATA_MODEL;
class DIALOG_PIN_PROPERTIES : public DIALOG_PIN_PROPERTIES_BASE class DIALOG_PIN_PROPERTIES : public DIALOG_PIN_PROPERTIES_BASE
{ {
public: public:
DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_PIN* aPin ); DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, SCH_PIN* aPin );
~DIALOG_PIN_PROPERTIES() override; ~DIALOG_PIN_PROPERTIES() override;
bool TransferDataToWindow() override; bool TransferDataToWindow() override;
@ -73,10 +73,10 @@ protected:
private: private:
SYMBOL_EDIT_FRAME* m_frame; SYMBOL_EDIT_FRAME* m_frame;
LIB_PIN* m_pin; SCH_PIN* m_pin;
LIB_SYMBOL* m_dummyParent; LIB_SYMBOL* m_dummyParent;
LIB_PIN* m_dummyPin; // a working copy used to show changes SCH_PIN* m_dummyPin; // a working copy used to show changes
UNIT_BINDER m_posX; UNIT_BINDER m_posX;
UNIT_BINDER m_posY; UNIT_BINDER m_posY;

View File

@ -79,7 +79,7 @@ DIALOG_SIM_MODEL<T>::DIALOG_SIM_MODEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame
{ {
m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) ); m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
for( LIB_PIN* pin : aSymbol.GetAllLibPins() ) for( SCH_PIN* pin : aSymbol.GetAllLibPins() )
{ {
// De Morgan conversions are equivalences, not additional items to simulate // De Morgan conversions are equivalences, not additional items to simulate
if( !pin->GetParentSymbol()->HasAlternateBodyStyle() || pin->GetBodyStyle() < 2 ) if( !pin->GetParentSymbol()->HasAlternateBodyStyle() || pin->GetBodyStyle() < 2 )
@ -87,7 +87,7 @@ DIALOG_SIM_MODEL<T>::DIALOG_SIM_MODEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame
} }
std::sort( m_sortedPartPins.begin(), m_sortedPartPins.end(), std::sort( m_sortedPartPins.begin(), m_sortedPartPins.end(),
[]( const LIB_PIN* lhs, const LIB_PIN* rhs ) []( const SCH_PIN* lhs, const SCH_PIN* rhs )
{ {
// We sort by StrNumCmp because SIM_MODEL_BASE sorts with it too. // We sort by StrNumCmp because SIM_MODEL_BASE sorts with it too.
return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0; return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0;
@ -1064,7 +1064,7 @@ int DIALOG_SIM_MODEL<T>::findSymbolPinRow( const wxString& aSymbolPinNumber ) co
{ {
for( int row = 0; row < static_cast<int>( m_sortedPartPins.size() ); ++row ) for( int row = 0; row < static_cast<int>( m_sortedPartPins.size() ); ++row )
{ {
LIB_PIN* pin = m_sortedPartPins[row]; SCH_PIN* pin = m_sortedPartPins[row];
if( pin->GetNumber() == aSymbolPinNumber ) if( pin->GetNumber() == aSymbolPinNumber )
return row; return row;
@ -1107,7 +1107,7 @@ const SIM_LIBRARY* DIALOG_SIM_MODEL<T>::library() const
template <typename T> template <typename T>
wxString DIALOG_SIM_MODEL<T>::getSymbolPinString( int symbolPinIndex ) const wxString DIALOG_SIM_MODEL<T>::getSymbolPinString( int symbolPinIndex ) const
{ {
LIB_PIN* pin = m_sortedPartPins.at( symbolPinIndex ); SCH_PIN* pin = m_sortedPartPins.at( symbolPinIndex );
wxString pinNumber; wxString pinNumber;
wxString pinName; wxString pinName;

View File

@ -130,7 +130,7 @@ private:
wxString m_prevLibrary; wxString m_prevLibrary;
const SIM_MODEL* m_prevModel; const SIM_MODEL* m_prevModel;
std::vector<LIB_PIN*> m_sortedPartPins; //< Pins of the current part. std::vector<SCH_PIN*> m_sortedPartPins; //< Pins of the current part.
std::map<SIM_MODEL::DEVICE_T, SIM_MODEL::TYPE> m_curModelTypeOfDeviceType; std::map<SIM_MODEL::DEVICE_T, SIM_MODEL::TYPE> m_curModelTypeOfDeviceType;
SIM_MODEL::TYPE m_curModelType; SIM_MODEL::TYPE m_curModelType;

View File

@ -100,7 +100,7 @@ public:
for( const SCH_PIN& pin : *this ) for( const SCH_PIN& pin : *this )
{ {
LIB_PIN* lib_pin = pin.GetLibPin(); SCH_PIN* lib_pin = pin.GetLibPin();
wxGridCellAttr* attr = nullptr; wxGridCellAttr* attr = nullptr;
if( lib_pin->GetAlternates().empty() ) if( lib_pin->GetAlternates().empty() )
@ -114,7 +114,7 @@ public:
wxArrayString choices; wxArrayString choices;
choices.push_back( lib_pin->GetName() ); choices.push_back( lib_pin->GetName() );
for( const std::pair<const wxString, LIB_PIN::ALT>& alt : lib_pin->GetAlternates() ) for( const std::pair<const wxString, SCH_PIN::ALT>& alt : lib_pin->GetAlternates() )
choices.push_back( alt.first ); choices.push_back( alt.first );
attr = new wxGridCellAttr(); attr = new wxGridCellAttr();

View File

@ -389,7 +389,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
addItem( comp_body ); addItem( comp_body );
LIB_PIN* pin = new LIB_PIN( symbol ); SCH_PIN* pin = new SCH_PIN( symbol );
pin->SetPosition( MILS_POINT( p.x - 300, p.y + 100 ) ); pin->SetPosition( MILS_POINT( p.x - 300, p.y + 100 ) );
pin->SetLength( schIUScale.MilsToIU( 100 ) ); pin->SetLength( schIUScale.MilsToIU( 100 ) );
@ -403,7 +403,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
endPointsByType.emplace_back( PIN_END, pin, mapLibItemPosition( pin->GetPosition() ) ); endPointsByType.emplace_back( PIN_END, pin, mapLibItemPosition( pin->GetPosition() ) );
symbol->AddDrawItem( pin ); symbol->AddDrawItem( pin );
pin = new LIB_PIN( symbol ); pin = new SCH_PIN( symbol );
pin->SetPosition( MILS_POINT( p.x - 300, p.y - 100 ) ); pin->SetPosition( MILS_POINT( p.x - 300, p.y - 100 ) );
pin->SetLength( schIUScale.MilsToIU( 100 ) ); pin->SetLength( schIUScale.MilsToIU( 100 ) );
@ -417,7 +417,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
endPointsByType.emplace_back( PIN_END, pin, mapLibItemPosition( pin->GetPosition() ) ); endPointsByType.emplace_back( PIN_END, pin, mapLibItemPosition( pin->GetPosition() ) );
symbol->AddDrawItem( pin ); symbol->AddDrawItem( pin );
pin = new LIB_PIN( symbol ); pin = new SCH_PIN( symbol );
pin->SetPosition( MILS_POINT( p.x + 300, p.y ) ); pin->SetPosition( MILS_POINT( p.x + 300, p.y ) );
pin->SetLength( schIUScale.MilsToIU( 100 ) ); pin->SetLength( schIUScale.MilsToIU( 100 ) );

View File

@ -25,7 +25,7 @@
#ifndef _PANEL_SETUP_PINMAP_H_ #ifndef _PANEL_SETUP_PINMAP_H_
#define _PANEL_SETUP_PINMAP_H_ #define _PANEL_SETUP_PINMAP_H_
#include <lib_pin.h> // For PINTYPE_COUNT definition #include <sch_pin.h> // For PINTYPE_COUNT definition
#include <erc_settings.h> #include <erc_settings.h>
#include "panel_setup_pinmap_base.h" #include "panel_setup_pinmap_base.h"

View File

@ -96,7 +96,7 @@ INSPECT_RESULT EE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
// Special selection rules apply to pins of different units when edited in synchronized // 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. // pins mode. Leave it to EE_SELECTION_TOOL::Selectable() to decide what to do with them.
if( schItem && schItem->Type() != LIB_PIN_T ) if( schItem && schItem->Type() != SCH_PIN_T )
{ {
if( m_Unit && schItem->GetUnit() && schItem->GetUnit() != m_Unit ) if( m_Unit && schItem->GetUnit() && schItem->GetUnit() != m_Unit )
return INSPECT_RESULT::CONTINUE; return INSPECT_RESULT::CONTINUE;

View File

@ -34,7 +34,7 @@
#include <erc_sch_pin_context.h> #include <erc_sch_pin_context.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <string_utils.h> #include <string_utils.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <project_sch.h> #include <project_sch.h>
#include <project/project_file.h> #include <project/project_file.h>
#include <project/net_settings.h> #include <project/net_settings.h>
@ -493,8 +493,7 @@ int ERC_TESTER::TestMissingUnits()
for( int missing_unit : missing_units ) for( int missing_unit : missing_units )
{ {
std::vector<LIB_PIN*> pins; int bodyStyle = 0;
int bodyStyle = 0;
for( size_t ii = 0; ii < refList.GetCount(); ++ii ) for( size_t ii = 0; ii < refList.GetCount(); ++ii )
{ {
@ -505,9 +504,7 @@ int ERC_TESTER::TestMissingUnits()
} }
} }
libSymbol->GetPins( pins, missing_unit, bodyStyle ); for( SCH_PIN* pin : libSymbol->GetPins( missing_unit, bodyStyle ) )
for( LIB_PIN* pin : pins )
{ {
switch( pin->GetType() ) switch( pin->GetType() )
{ {
@ -728,7 +725,7 @@ int ERC_TESTER::TestPinToPin()
ERC_SCH_PIN_CONTEXT& refPin = *refIt; ERC_SCH_PIN_CONTEXT& refPin = *refIt;
ELECTRICAL_PINTYPE refType = refPin.Pin()->GetType(); ELECTRICAL_PINTYPE refType = refPin.Pin()->GetType();
if( DrivenPinTypes.count( refType ) ) if( DrivenPinTypes.contains( refType ) )
{ {
// needsDriver will be the pin shown in the error report eventually, so try to // needsDriver will be the pin shown in the error report eventually, so try to
// upgrade to a "better" pin if possible: something visible and only a power symbol // upgrade to a "better" pin if possible: something visible and only a power symbol
@ -762,9 +759,9 @@ int ERC_TESTER::TestPinToPin()
ELECTRICAL_PINTYPE testType = testPin.Pin()->GetType(); ELECTRICAL_PINTYPE testType = testPin.Pin()->GetType();
if( ispowerNet ) if( ispowerNet )
hasDriver |= ( DrivingPowerPinTypes.count( testType ) != 0 ); hasDriver |= DrivingPowerPinTypes.contains( testType );
else else
hasDriver |= ( DrivingPinTypes.count( testType ) != 0 ); hasDriver |= DrivingPinTypes.contains( testType );
PIN_ERROR erc = settings.GetPinMapValue( refType, testType ); PIN_ERROR erc = settings.GetPinMapValue( refType, testType );
@ -782,8 +779,7 @@ int ERC_TESTER::TestPinToPin()
ElectricalPinTypeGetText( refType ), ElectricalPinTypeGetText( refType ),
ElectricalPinTypeGetText( testType ) ) ); ElectricalPinTypeGetText( testType ) ) );
SCH_MARKER* marker = new SCH_MARKER( ercItem, SCH_MARKER* marker = new SCH_MARKER( ercItem, refPin.Pin()->GetPosition() );
refPin.Pin()->GetTransformedPosition() );
pinToScreenMap[refPin.Pin()]->Append( marker ); pinToScreenMap[refPin.Pin()]->Append( marker );
errors++; errors++;
} }
@ -802,8 +798,7 @@ int ERC_TESTER::TestPinToPin()
ercItem->SetSheetSpecificPath( needsDriver.Sheet() ); ercItem->SetSheetSpecificPath( needsDriver.Sheet() );
ercItem->SetItemsSheetPaths( needsDriver.Sheet() ); ercItem->SetItemsSheetPaths( needsDriver.Sheet() );
SCH_MARKER* marker = new SCH_MARKER( ercItem, SCH_MARKER* marker = new SCH_MARKER( ercItem, needsDriver.Pin()->GetPosition() );
needsDriver.Pin()->GetTransformedPosition() );
pinToScreenMap[needsDriver.Pin()]->Append( marker ); pinToScreenMap[needsDriver.Pin()]->Append( marker );
errors++; errors++;
} }
@ -860,8 +855,7 @@ int ERC_TESTER::TestMultUnitPinConflicts()
ercItem->SetSheetSpecificPath( sheet ); ercItem->SetSheetSpecificPath( sheet );
ercItem->SetItemsSheetPaths( sheet, sheet ); ercItem->SetItemsSheetPaths( sheet, sheet );
SCH_MARKER* marker = new SCH_MARKER( ercItem, SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetPosition() );
pin->GetTransformedPosition() );
sheet.LastScreen()->Append( marker ); sheet.LastScreen()->Append( marker );
errors += 1; errors += 1;
} }
@ -1159,7 +1153,7 @@ int ERC_TESTER::TestOffGridEndpoints()
for( SCH_PIN* pin : symbol->GetPins( nullptr ) ) for( SCH_PIN* pin : symbol->GetPins( nullptr ) )
{ {
VECTOR2I pinPos = pin->GetTransformedPosition(); VECTOR2I pinPos = pin->GetPosition();
if( ( pinPos.x % gridSize ) != 0 || ( pinPos.y % gridSize ) != 0 ) if( ( pinPos.x % gridSize ) != 0 || ( pinPos.y % gridSize ) != 0 )
{ {

View File

@ -99,15 +99,10 @@ static wxString netList( LIB_SYMBOL* aSymbol )
* pinNumber pinName <tab> pinNumber pinName... * pinNumber pinName <tab> pinNumber pinName...
* fpFilter fpFilter... * fpFilter fpFilter...
*/ */
wxString netlist; wxString netlist;
std::vector<LIB_PIN*> pinList;
aSymbol->GetPins( pinList, 0, 1 ); // All units, but a single convert
wxArrayString pins; wxArrayString pins;
for( LIB_PIN* pin : pinList ) for( SCH_PIN* pin : aSymbol->GetPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() ); pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
if( !pins.IsEmpty() ) if( !pins.IsEmpty() )

File diff suppressed because it is too large Load Diff

View File

@ -1,336 +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 <stambaughw@gmail.com>
* Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef CLASS_PIN_H
#define CLASS_PIN_H
#include <pin_type.h>
#include <lib_symbol.h>
// Circle diameter drawn at the active end of pins:
#define TARGET_PIN_RADIUS schIUScale.MilsToIU( 15 )
// Pin visibility flag bit:
#define PIN_INVISIBLE 1 // Set makes pin invisible
class LIB_PIN : public SCH_ITEM
{
public:
struct ALT
{
wxString m_Name;
GRAPHIC_PINSHAPE m_Shape; // Shape drawn around pin
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
{
return wxT( "LIB_PIN" );
}
static inline bool ClassOf( const EDA_ITEM* aItem )
{
return aItem && aItem->Type() == LIB_PIN_T;
}
wxString GetFriendlyName() const override
{
return _( "Pin" );
}
PIN_ORIENTATION GetOrientation() const { return m_orientation; }
void SetOrientation( PIN_ORIENTATION aOrientation ) { m_orientation = aOrientation; }
GRAPHIC_PINSHAPE GetShape() const { return m_shape; }
void SetShape( GRAPHIC_PINSHAPE aShape ) { m_shape = aShape; }
int GetLength() const { return m_length; }
void SetLength( int aLength ) { m_length = aLength; }
/**
* Change the length of a pin and adjust its position based on orientation.
*
* @param aLength New length of pin
*/
void ChangeLength( int aLength );
ELECTRICAL_PINTYPE GetType() const { return m_type; }
void SetType( ELECTRICAL_PINTYPE aType ) { m_type = aType; }
wxString const GetCanonicalElectricalTypeName() const
{
return GetCanonicalElectricalTypeName( m_type );
}
wxString const GetElectricalTypeName() const
{
return ElectricalPinTypeGetText( m_type );
}
bool IsVisible() const { return ( m_attributes & PIN_INVISIBLE ) == 0; }
void SetVisible( bool aVisible )
{
if( aVisible )
m_attributes &= ~PIN_INVISIBLE;
else
m_attributes |= PIN_INVISIBLE;
}
const wxString& GetName() const { return m_name; }
wxString GetShownName() const;
void SetName( const wxString& aName )
{
m_name = aName;
// pin name string does not support spaces
m_name.Replace( wxT( " " ), wxT( "_" ) );
m_nameExtentsCache.m_Extents = VECTOR2I();
}
const wxString& GetNumber() const { return m_number; }
wxString GetShownNumber() const { return m_number; }
void SetNumber( const wxString& aNumber )
{
m_number = aNumber;
// pin number string does not support spaces
m_number.Replace( wxT( " " ), wxT( "_" ) );
m_numExtentsCache.m_Extents = VECTOR2I();
}
int GetNameTextSize() const { return m_nameTextSize; }
void SetNameTextSize( int aSize )
{
m_nameTextSize = aSize;
m_nameExtentsCache.m_Extents = VECTOR2I();
}
int GetNumberTextSize() const { return m_numTextSize; }
void SetNumberTextSize( int aSize )
{
m_numTextSize = aSize;
m_numExtentsCache.m_Extents = VECTOR2I();
}
std::map<wxString, ALT>& GetAlternates() { return m_alternates; }
ALT GetAlt( const wxString& aAlt ) { return m_alternates[ aAlt ]; }
void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override;
/**
* Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT),
* according to its orientation and the matrix transform (rot, mirror) \a aTransform.
*
* @param aTransform Transform matrix
*/
PIN_ORIENTATION PinDrawOrient( const TRANSFORM& aTransform ) const;
// 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; }
void SetOperatingPoint( const wxString& aText ) { m_operatingPoint = aText; }
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override;
#endif
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
const BOX2I ViewBBox() const override;
void ViewGetLayers( int aLayers[], int& aCount ) const override;
/* Cannot use a default parameter here as it will not be compatible with the virtual. */
const BOX2I GetBoundingBox() const override { return GetBoundingBox( false, true, true ); }
/**
* @param aIncludeLabelsOnInvisblePins - if false, do not include labels for invisible pins
* in the calculation.
*/
const BOX2I GetBoundingBox( bool aIncludeLabelsOnInvisblePins, bool aIncludeNameAndNumber,
bool aIncludeElectricalType ) const;
/**
* Return whether this pin forms a global power connection: i.e., is part of a power symbol
* and of type POWER_IN, or is a legacy invisible global power pin on a symbol.
*/
bool IsGlobalPower() const
{
return GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN
&& ( !IsVisible() || GetParentSymbol()->IsPower() );
}
int GetPenWidth() const override;
void Move( const VECTOR2I& aOffset ) override;
VECTOR2I GetPosition() const override { return m_position; }
void SetPosition( const VECTOR2I& aPos ) override { m_position = aPos; }
// For properties system
int GetX() const { return m_position.x; }
void SetX( int aX ) { m_position.x = aX; }
int GetY() const { return m_position.y; }
void SetY( int aY ) { m_position.y = aY; }
VECTOR2I GetPinRoot() const;
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
/**
* Plot the pin name and number.
* @param aTextInside - draw the names & numbers inside the symbol body (ie: in the opposite
* direction of \a aPinOrient).
*/
void PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient,
int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed ) const;
void PlotPinType( PLOTTER *aPlotter, const VECTOR2I &aPosition, PIN_ORIENTATION aOrientation,
bool aDimmed ) const;
void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
BITMAPS GetMenuImage() const override;
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, ALT* aAlt ) const;
EDA_ITEM* Clone() const override;
void CalcEdit( const VECTOR2I& aPosition ) override;
/**
* Return a string giving the electrical type of a pin.
*
* Can be used when a known, not translated name is needed (for instance in net lists)
*
* @param aType is the electrical type (see enum ELECTRICAL_PINTYPE )
* @return The electrical name for a pin type (see enun MsgPinElectricType for names).
*/
static const wxString GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType );
double Similarity( const SCH_ITEM& aItem ) const override;
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; }
protected:
wxString getItemDescription( ALT* aAlt ) const;
struct EXTENTS_CACHE
{
KIFONT::FONT* m_Font = nullptr;
int m_FontSize = 0;
VECTOR2I m_Extents;
};
void validateExtentsCache( KIFONT::FONT* aFont, int aSize, const wxString& aText,
EXTENTS_CACHE* aCache ) const;
/**
* Print the pin symbol without text.
* If \a aColor != 0, draw with \a aColor, else with the normal pin color.
*/
void printPinSymbol( const SCH_RENDER_SETTINGS *aSettings, const VECTOR2I &aPos,
PIN_ORIENTATION aOrientation, bool aDimmed );
/**
* Put the pin number and pin text info, given the pin line coordinates.
* The line must be vertical or horizontal.
* If aDrawPinName == false the pin name is not printed.
* If aDrawPinNum = false the pin number is not printed.
* If aTextInside then the text is been put inside,otherwise all is drawn outside.
* Pin Name: substring between '~' is negated
*/
void printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos,
PIN_ORIENTATION aPinOrient, int aTextInside, bool aDrawPinNum,
bool aDrawPinName, bool aDimmed );
/**
* Draw the electrical type text of the pin (only for the footprint editor)
*/
void printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECTOR2I& aPosition,
PIN_ORIENTATION aOrientation, bool aDimmed );
std::ostream& operator<<( std::ostream& aStream );
private:
/**
* @copydoc SCH_ITEM::compare()
*
* The pin specific sort order is as follows:
* - Pin number.
* - Pin name, case insensitive compare.
* - Pin horizontal (X) position.
* - Pin vertical (Y) position.
*/
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
protected:
VECTOR2I m_position; // Position of the pin.
int m_length; // Length of the pin.
PIN_ORIENTATION m_orientation; // Pin orientation (Up, Down, Left, Right)
GRAPHIC_PINSHAPE m_shape; // Shape drawn around pin
ELECTRICAL_PINTYPE m_type; // Electrical type of the pin.
int m_attributes; // Set bit 0 to indicate pin is invisible.
wxString m_name;
wxString m_number;
int m_numTextSize; // Pin num and Pin name sizes
int m_nameTextSize;
std::map<wxString, ALT> m_alternates; // Map of alternate name to ALT structure
wxString m_operatingPoint; // No, LIB_PINs don't really have simulation
// operating points. But we draw SCH_PINs through
// their LIB_PIN counterparts, so here we are....
mutable EXTENTS_CACHE m_numExtentsCache;
mutable EXTENTS_CACHE m_nameExtentsCache;
};
#endif // CLASS_PIN_H

View File

@ -27,12 +27,11 @@
#include <sch_draw_panel.h> #include <sch_draw_panel.h>
#include <plotters/plotter.h> #include <plotters/plotter.h>
#include <sch_screen.h> #include <sch_screen.h>
#include <richio.h>
#include <template_fieldnames.h> #include <template_fieldnames.h>
#include <transform.h> #include <transform.h>
#include <symbol_library.h> #include <symbol_library.h>
#include <lib_pin.h>
#include <settings/color_settings.h> #include <settings/color_settings.h>
#include <sch_pin.h>
#include <sch_shape.h> #include <sch_shape.h>
#include <memory> #include <memory>
@ -293,7 +292,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
aShapes.insert( &(*it) ); aShapes.insert( &(*it) );
else if( it->Type() == SCH_FIELD_T ) else if( it->Type() == SCH_FIELD_T )
aFields.insert( &(*it) ); aFields.insert( &(*it) );
else if( it->Type() == LIB_PIN_T ) else if( it->Type() == SCH_PIN_T )
aPins.insert( &(*it) ); aPins.insert( &(*it) );
} }
@ -307,7 +306,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
bShapes.insert( &(*it) ); bShapes.insert( &(*it) );
else if( it->Type() == SCH_FIELD_T ) else if( it->Type() == SCH_FIELD_T )
bFields.insert( &(*it) ); bFields.insert( &(*it) );
else if( it->Type() == LIB_PIN_T ) else if( it->Type() == SCH_PIN_T )
bPins.insert( &(*it) ); bPins.insert( &(*it) );
} }
@ -346,8 +345,8 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
{ {
for( const SCH_ITEM* aPinItem : aPins ) for( const SCH_ITEM* aPinItem : aPins )
{ {
const LIB_PIN* aPin = static_cast<const LIB_PIN*>( aPinItem ); const SCH_PIN* aPin = static_cast<const SCH_PIN*>( aPinItem );
const LIB_PIN* bPin = aRhs.GetPin( aPin->GetNumber(), aPin->GetUnit(), const SCH_PIN* bPin = aRhs.GetPin( aPin->GetNumber(), aPin->GetUnit(),
aPin->GetBodyStyle() ); aPin->GetBodyStyle() );
if( !bPin ) if( !bPin )
@ -754,7 +753,7 @@ void LIB_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBo
if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) ) if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
continue; continue;
if( item.Type() == LIB_PIN_T ) if( item.Type() == SCH_PIN_T )
{ {
item.Print( aSettings, aUnit, aBodyStyle, aOffset, aForceNoFill, aDimmed ); item.Print( aSettings, aUnit, aBodyStyle, aOffset, aForceNoFill, aDimmed );
} }
@ -980,8 +979,10 @@ void LIB_SYMBOL::AddDrawItem( SCH_ITEM* aItem, bool aSort )
} }
void LIB_SYMBOL::GetPins( std::vector<LIB_PIN*>& aList, int aUnit, int aBodyStyle ) const std::vector<SCH_PIN*> LIB_SYMBOL::GetPins( int aUnit, int aBodyStyle ) const
{ {
std::vector<SCH_PIN*> pins;
/* Notes: /* Notes:
* when aUnit == 0: no unit filtering * when aUnit == 0: no unit filtering
* when aBodyStyle == 0: no body style filtering * when aBodyStyle == 0: no body style filtering
@ -992,7 +993,7 @@ void LIB_SYMBOL::GetPins( std::vector<LIB_PIN*>& aList, int aUnit, int aBodyStyl
LIB_SYMBOL_SPTR parent = m_parent.lock(); LIB_SYMBOL_SPTR parent = m_parent.lock();
const LIB_ITEMS_CONTAINER& drawItems = parent ? parent->m_drawings : m_drawings; const LIB_ITEMS_CONTAINER& drawItems = parent ? parent->m_drawings : m_drawings;
for( const SCH_ITEM& item : drawItems[LIB_PIN_T] ) for( const SCH_ITEM& item : drawItems[SCH_PIN_T] )
{ {
// Unit filtering: // Unit filtering:
if( aUnit && item.m_unit && ( item.m_unit != aUnit ) ) if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
@ -1002,35 +1003,29 @@ void LIB_SYMBOL::GetPins( std::vector<LIB_PIN*>& aList, int aUnit, int aBodyStyl
if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) ) if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
continue; continue;
aList.push_back( (LIB_PIN*) &item ); // TODO: get rid of const_cast. (It used to be a C-style cast so was less noticeable.)
pins.push_back( const_cast<SCH_PIN*>( static_cast<const SCH_PIN*>( &item ) ) );
} }
return pins;
} }
std::vector<LIB_PIN*> LIB_SYMBOL::GetAllLibPins() const std::vector<SCH_PIN*> LIB_SYMBOL::GetAllLibPins() const
{ {
std::vector<LIB_PIN*> pinList; return GetPins( 0, 0 );
GetPins( pinList, 0, 0 );
return pinList;
} }
int LIB_SYMBOL::GetPinCount() int LIB_SYMBOL::GetPinCount()
{ {
std::vector<LIB_PIN*> pinList; return (int) GetPins( 0 /* all units */, 1 /* single body style */ ).size();
GetPins( pinList, 0 /* all units */, 1 /* single body style */ );
return (int) pinList.size();
} }
LIB_PIN* LIB_SYMBOL::GetPin( const wxString& aNumber, int aUnit, int aBodyStyle ) const SCH_PIN* LIB_SYMBOL::GetPin( const wxString& aNumber, int aUnit, int aBodyStyle ) const
{ {
std::vector<LIB_PIN*> pinList; for( SCH_PIN* pin : GetPins( aUnit, aBodyStyle ) )
GetPins( pinList, aUnit, aBodyStyle );
for( LIB_PIN* pin : pinList )
{ {
if( aNumber == pin->GetNumber() ) if( aNumber == pin->GetNumber() )
return pin; return pin;
@ -1043,17 +1038,15 @@ 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 LIB_SYMBOL::PinsConflictWith( const LIB_SYMBOL& aOtherPart, bool aTestNums, bool aTestNames,
bool aTestType, bool aTestOrientation, bool aTestLength ) const bool aTestType, bool aTestOrientation, bool aTestLength ) const
{ {
std::vector<LIB_PIN*> thisPinList; std::vector<SCH_PIN*> thisPinList = GetAllLibPins();
GetPins( thisPinList, /* aUnit */ 0, /* aBodyStyle */ 0 );
for( const LIB_PIN* eachThisPin : thisPinList ) for( const SCH_PIN* eachThisPin : thisPinList )
{ {
wxASSERT( eachThisPin ); wxASSERT( eachThisPin );
std::vector<LIB_PIN*> otherPinList; std::vector<SCH_PIN*> otherPinList = aOtherPart.GetAllLibPins();
aOtherPart.GetPins( otherPinList, /* aUnit */ 0, /* aBodyStyle */ 0 );
bool foundMatch = false; bool foundMatch = false;
for( const LIB_PIN* eachOtherPin : otherPinList ) for( const SCH_PIN* eachOtherPin : otherPinList )
{ {
wxASSERT( eachOtherPin ); wxASSERT( eachOtherPin );
@ -1152,9 +1145,9 @@ const BOX2I LIB_SYMBOL::GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aInc
if( item.Type() == SCH_FIELD_T ) if( item.Type() == SCH_FIELD_T )
continue; continue;
if( item.Type() == LIB_PIN_T ) if( item.Type() == SCH_PIN_T )
{ {
const LIB_PIN& pin = static_cast<const LIB_PIN&>( item ); const SCH_PIN& pin = static_cast<const SCH_PIN&>( item );
if( pin.IsVisible() ) if( pin.IsVisible() )
{ {
@ -1441,9 +1434,9 @@ int LIB_SYMBOL::GetMaxPinNumber() const
LIB_SYMBOL_SPTR parent = m_parent.lock(); LIB_SYMBOL_SPTR parent = m_parent.lock();
const LIB_ITEMS_CONTAINER& drawItems = parent ? parent->m_drawings : m_drawings; const LIB_ITEMS_CONTAINER& drawItems = parent ? parent->m_drawings : m_drawings;
for( const SCH_ITEM& item : drawItems[LIB_PIN_T] ) for( const SCH_ITEM& item : drawItems[SCH_PIN_T] )
{ {
const LIB_PIN* pin = static_cast<const LIB_PIN*>( &item ); const SCH_PIN* pin = static_cast<const SCH_PIN*>( &item );
long currentPinNumber = 0; long currentPinNumber = 0;
if( pin->GetNumber().ToLong( &currentPinNumber ) ) if( pin->GetNumber().ToLong( &currentPinNumber ) )
@ -1598,7 +1591,7 @@ void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePi
{ {
std::vector<SCH_ITEM*> tmp; // Temporarily store the duplicated pins here. std::vector<SCH_ITEM*> tmp; // Temporarily store the duplicated pins here.
for( SCH_ITEM& item : m_drawings[ LIB_PIN_T ] ) for( SCH_ITEM& item : m_drawings[ SCH_PIN_T ] )
{ {
if( item.m_bodyStyle == 1 ) if( item.m_bodyStyle == 1 )
{ {
@ -1727,8 +1720,8 @@ bool LIB_SYMBOL::operator==( const LIB_SYMBOL& aOther ) const
return false; return false;
} }
const std::vector<LIB_PIN*> thisPinList = GetAllLibPins(); const std::vector<SCH_PIN*> thisPinList = GetAllLibPins();
const std::vector<LIB_PIN*> otherPinList = aOther.GetAllLibPins(); const std::vector<SCH_PIN*> otherPinList = aOther.GetAllLibPins();
if( thisPinList.size() != otherPinList.size() ) if( thisPinList.size() != otherPinList.size() )
return false; return false;
@ -1777,12 +1770,12 @@ double LIB_SYMBOL::Similarity( const SCH_ITEM& aOther ) const
similarity += max_similarity; similarity += max_similarity;
} }
for( const LIB_PIN* pin : GetAllLibPins() ) for( const SCH_PIN* pin : GetAllLibPins() )
{ {
totalItems += 1; totalItems += 1;
double max_similarity = 0.0; double max_similarity = 0.0;
for( const LIB_PIN* otherPin : other.GetAllLibPins() ) for( const SCH_PIN* otherPin : other.GetAllLibPins() )
{ {
double temp_similarity = pin->Similarity( *otherPin ); double temp_similarity = pin->Similarity( *otherPin );
max_similarity = std::max( max_similarity, temp_similarity ); max_similarity = std::max( max_similarity, temp_similarity );

View File

@ -27,9 +27,9 @@
#ifndef LIB_SYMBOL_H #ifndef LIB_SYMBOL_H
#define LIB_SYMBOL_H #define LIB_SYMBOL_H
#include <general.h>
#include <symbol.h> #include <symbol.h>
#include <sch_field.h> #include <sch_field.h>
#include <sch_pin.h>
#include <lib_tree_item.h> #include <lib_tree_item.h>
#include <vector> #include <vector>
#include <core/multivector.h> #include <core/multivector.h>
@ -39,13 +39,12 @@ class OUTPUTFORMATTER;
class REPORTER; class REPORTER;
class SYMBOL_LIB; class SYMBOL_LIB;
class LIB_SYMBOL; class LIB_SYMBOL;
class LIB_PIN;
class TEST_LIB_SYMBOL_FIXTURE; class TEST_LIB_SYMBOL_FIXTURE;
typedef std::shared_ptr<LIB_SYMBOL> LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL typedef std::shared_ptr<LIB_SYMBOL> LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL
typedef std::weak_ptr<LIB_SYMBOL> LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL typedef std::weak_ptr<LIB_SYMBOL> LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL
typedef MULTIVECTOR<SCH_ITEM, SCH_SHAPE_T, LIB_PIN_T> LIB_ITEMS_CONTAINER; typedef MULTIVECTOR<SCH_ITEM, SCH_SHAPE_T, SCH_PIN_T> LIB_ITEMS_CONTAINER;
typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS; typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS;
@ -387,18 +386,17 @@ public:
* Note pin objects are owned by the draw list of the symbol. Deleting any of the objects * Note pin objects are owned by the draw list of the symbol. Deleting any of the objects
* will leave list in a unstable state and will likely segfault when the list is destroyed. * will leave list in a unstable state and will likely segfault when the list is destroyed.
* *
* @param aList - Pin list to place pin object pointers into.
* @param aUnit - Unit number of pins to collect. Set to 0 to get pins from any symbol unit. * @param aUnit - Unit number of pins to collect. Set to 0 to get pins from any symbol unit.
* @param aBodyStyle - Symbol alternate body style of pins to collect. Set to 0 to get pins * @param aBodyStyle - Symbol alternate body style of pins to collect. Set to 0 to get pins
* from any DeMorgan variant of symbol. * from any DeMorgan variant of symbol.
*/ */
void GetPins( std::vector<LIB_PIN*>& aList, int aUnit = 0, int aBodyStyle = 0 ) const; std::vector<SCH_PIN*> GetPins( int aUnit = 0, int aBodyStyle = 0 ) const;
/** /**
* Return a list of pin pointers for all units / converts. Used primarily for SPICE where * Return a list of pin pointers for all units / converts. Used primarily for SPICE where
* we want to treat all unit as a single part. * we want to treat all unit as a single part.
*/ */
std::vector<LIB_PIN*> GetAllLibPins() const; std::vector<SCH_PIN*> GetAllLibPins() const;
/** /**
* @return a count of pins for all units / converts. * @return a count of pins for all units / converts.
@ -414,7 +412,7 @@ public:
* required. * required.
* @return The pin object if found. Otherwise NULL. * @return The pin object if found. Otherwise NULL.
*/ */
LIB_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 ) const; SCH_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 ) const;
/** /**
* Return true if this symbol's pins do not match another symbol's pins. This is used to * Return true if this symbol's pins do not match another symbol's pins. This is used to

View File

@ -124,7 +124,7 @@ bool NETLIST_EXPORTER_ALLEGRO::CompareSymbolRef( const wxString& aRefText1,
} }
bool NETLIST_EXPORTER_ALLEGRO::CompareLibPin( const LIB_PIN* aPin1, const LIB_PIN* aPin2 ) bool NETLIST_EXPORTER_ALLEGRO::CompareLibPin( const SCH_PIN* aPin1, const SCH_PIN* aPin2 )
{ {
// return "lhs < rhs" // return "lhs < rhs"
return StrNumCmp( aPin1->GetShownNumber(), aPin2->GetShownNumber(), true ) < 0; return StrNumCmp( aPin1->GetShownNumber(), aPin2->GetShownNumber(), true ) < 0;
@ -177,18 +177,10 @@ void NETLIST_EXPORTER_ALLEGRO::extractComponentsInfo()
SCH_SYMBOL* symbol = findNextSymbol( item, &sheet ); SCH_SYMBOL* symbol = findNextSymbol( item, &sheet );
if( !symbol || symbol->GetExcludedFromBoard() ) if( !symbol || symbol->GetExcludedFromBoard() )
{
continue; continue;
}
std::vector<LIB_PIN*> pinList; if( symbol->GetLibPins().empty() )
pinList.clear();
symbol->GetLibPins(pinList);
if( !pinList.size() )
{
continue; continue;
}
m_packageProperties.insert( std::pair<wxString, m_packageProperties.insert( std::pair<wxString,
wxString>( sheet.PathHumanReadable(), wxString>( sheet.PathHumanReadable(),
@ -450,8 +442,7 @@ void NETLIST_EXPORTER_ALLEGRO::toAllegroPackages()
fprintf( d, "PACKAGE '%s'\n", TO_UTF8( formatDevice( footprintText ) ) ); fprintf( d, "PACKAGE '%s'\n", TO_UTF8( formatDevice( footprintText ) ) );
fprintf( d, "CLASS IC\n" ); fprintf( d, "CLASS IC\n" );
std::vector<LIB_PIN*> pinList; std::vector<SCH_PIN*> pinList = sym->GetLibSymbolRef()->GetAllLibPins();
sym->GetLibSymbolRef()->GetPins( pinList, 0, 0 );
/* /*
* We must erase redundant Pins references in pinList * We must erase redundant Pins references in pinList
@ -584,7 +575,7 @@ wxString NETLIST_EXPORTER_ALLEGRO::formatText( wxString aString )
} }
wxString NETLIST_EXPORTER_ALLEGRO::formatPin( const LIB_PIN& aPin ) wxString NETLIST_EXPORTER_ALLEGRO::formatPin( const SCH_PIN& aPin )
{ {
wxString pinName4Telesis = aPin.GetName() + wxString( "__" ) + aPin.GetNumber(); wxString pinName4Telesis = aPin.GetName() + wxString( "__" ) + aPin.GetNumber();
std::regex reg( "[^A-Za-z0-9_+?/-]" ); std::regex reg( "[^A-Za-z0-9_+?/-]" );
@ -592,7 +583,7 @@ wxString NETLIST_EXPORTER_ALLEGRO::formatPin( const LIB_PIN& aPin )
} }
wxString NETLIST_EXPORTER_ALLEGRO::formatFunction( wxString aName, std::vector<LIB_PIN*> aPinList ) wxString NETLIST_EXPORTER_ALLEGRO::formatFunction( wxString aName, std::vector<SCH_PIN*> aPinList )
{ {
aName.MakeUpper(); aName.MakeUpper();
std::list<wxString> pinNameList; std::list<wxString> pinNameList;

View File

@ -67,13 +67,13 @@ public:
static bool CompareSymbolRef( const wxString& aRefText1, const wxString& aRefText2 ); static bool CompareSymbolRef( const wxString& aRefText1, const wxString& aRefText2 );
/** /**
* Compare two LIB_PIN* variables. * Compare two SCH_PIN* variables.
* *
* @param aPin1 * @param aPin1
* @param aPin2 * @param aPin2
* @return bool value * @return bool value
*/ */
static bool CompareLibPin( const LIB_PIN* aPin1, const LIB_PIN* aPin2 ); static bool CompareLibPin( const SCH_PIN* aPin1, const SCH_PIN* aPin2 );
private: private:
void extractComponentsInfo(); void extractComponentsInfo();
@ -132,7 +132,7 @@ private:
* @param aPin * @param aPin
* @return wxString * @return wxString
*/ */
wxString formatPin( const LIB_PIN& aPin ); wxString formatPin( const SCH_PIN& aPin );
/** /**
* Generate the definition of a function in Telesis format, which consists of * Generate the definition of a function in Telesis format, which consists of
@ -142,7 +142,7 @@ private:
* @param aPinList * @param aPinList
* @return wxString * @return wxString
*/ */
wxString formatFunction( wxString aName, std::vector<LIB_PIN*> aPinList ); wxString formatFunction( wxString aName, std::vector<SCH_PIN*> aPinList );
/** /**
* Look up a field for a component group, which may have mismatched case, or * Look up a field for a component group, which may have mismatched case, or

View File

@ -26,10 +26,8 @@
#ifndef NETLIST_EXPORTER_H #ifndef NETLIST_EXPORTER_H
#define NETLIST_EXPORTER_H #define NETLIST_EXPORTER_H
#include <lib_pin.h>
#include <sch_symbol.h> #include <sch_symbol.h>
#include <sch_label.h> #include <sch_label.h>
#include <sch_sheet.h>
#include <schematic.h> #include <schematic.h>
/** /**
@ -91,10 +89,6 @@ struct PIN_INFO
class NETLIST_EXPORTER_BASE class NETLIST_EXPORTER_BASE
{ {
public: public:
/**
* @param aMasterList we take ownership of this here.
* @param aLibTable is the symbol library table of the project.
*/
NETLIST_EXPORTER_BASE( SCHEMATIC_IFACE* aSchematic ) : NETLIST_EXPORTER_BASE( SCHEMATIC_IFACE* aSchematic ) :
m_schematic( aSchematic ) m_schematic( aSchematic )
{ {

View File

@ -41,7 +41,7 @@
#include <set> #include <set>
static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 ); static bool sortPinsByNumber( SCH_PIN* aPin1, SCH_PIN* aPin2 );
bool NETLIST_EXPORTER_XML::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions, bool NETLIST_EXPORTER_XML::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions,
REPORTER& aReporter ) REPORTER& aReporter )
@ -570,8 +570,6 @@ XNODE* NETLIST_EXPORTER_XML::makeLibraries()
XNODE* NETLIST_EXPORTER_XML::makeLibParts() XNODE* NETLIST_EXPORTER_XML::makeLibParts()
{ {
XNODE* xlibparts = node( wxT( "libparts" ) ); // auto_ptr XNODE* xlibparts = node( wxT( "libparts" ) ); // auto_ptr
std::vector<LIB_PIN*> pinList;
std::vector<SCH_FIELD*> fieldList; std::vector<SCH_FIELD*> fieldList;
m_libraries.clear(); m_libraries.clear();
@ -621,8 +619,7 @@ XNODE* NETLIST_EXPORTER_XML::makeLibParts()
} }
//----- show the pins here ------------------------------------ //----- show the pins here ------------------------------------
pinList.clear(); std::vector<SCH_PIN*> pinList = lcomp->GetPins( 0, 0 );
lcomp->GetPins( pinList, 0, 0 );
/* /*
* We must erase redundant Pins references in pinList * We must erase redundant Pins references in pinList
@ -633,6 +630,7 @@ XNODE* NETLIST_EXPORTER_XML::makeLibParts()
* found more than once. * found more than once.
*/ */
sort( pinList.begin(), pinList.end(), sortPinsByNumber ); sort( pinList.begin(), pinList.end(), sortPinsByNumber );
for( int ii = 0; ii < (int)pinList.size()-1; ii++ ) for( int ii = 0; ii < (int)pinList.size()-1; ii++ )
{ {
if( pinList[ii]->GetNumber() == pinList[ii+1]->GetNumber() ) if( pinList[ii]->GetNumber() == pinList[ii+1]->GetNumber() )
@ -647,6 +645,7 @@ XNODE* NETLIST_EXPORTER_XML::makeLibParts()
XNODE* pins; XNODE* pins;
xlibpart->AddChild( pins = node( wxT( "pins" ) ) ); xlibpart->AddChild( pins = node( wxT( "pins" ) ) );
for( unsigned i=0; i<pinList.size(); ++i ) for( unsigned i=0; i<pinList.size(); ++i )
{ {
XNODE* pin; XNODE* pin;
@ -683,7 +682,9 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
struct NET_NODE struct NET_NODE
{ {
NET_NODE( SCH_PIN* aPin, const SCH_SHEET_PATH& aSheet ) : m_Pin( aPin ), m_Sheet( aSheet ) NET_NODE( SCH_PIN* aPin, const SCH_SHEET_PATH& aSheet ) :
m_Pin( aPin ),
m_Sheet( aSheet )
{} {}
SCH_PIN* m_Pin; SCH_PIN* m_Pin;
@ -692,7 +693,10 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
struct NET_RECORD struct NET_RECORD
{ {
NET_RECORD( const wxString& aName ) : m_Name( aName ), m_HasNoConnect( false ){}; NET_RECORD( const wxString& aName ) :
m_Name( aName ),
m_HasNoConnect( false )
{};
wxString m_Name; wxString m_Name;
bool m_HasNoConnect; bool m_HasNoConnect;
@ -724,8 +728,8 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
{ {
if( item->Type() == SCH_PIN_T ) if( item->Type() == SCH_PIN_T )
{ {
SCH_PIN* pin = static_cast<SCH_PIN*>( item ); SCH_PIN* pin = static_cast<SCH_PIN*>( item );
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( pin->GetParentSymbol() ); SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( pin->GetParentSymbol() );
if( !symbol if( !symbol
|| ( ( aCtl & GNL_OPT_BOM ) && symbol->GetExcludedFromBOM() ) || ( ( aCtl & GNL_OPT_BOM ) && symbol->GetExcludedFromBOM() )
@ -755,7 +759,7 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
// Netlist ordering: Net name, then ref des, then pin name // Netlist ordering: Net name, then ref des, then pin name
std::sort( net_record->m_Nodes.begin(), net_record->m_Nodes.end(), std::sort( net_record->m_Nodes.begin(), net_record->m_Nodes.end(),
[]( const NET_NODE& a, const NET_NODE& b ) []( const NET_NODE& a, const NET_NODE& b )
{ {
wxString refA = a.m_Pin->GetParentSymbol()->GetRef( &a.m_Sheet ); wxString refA = a.m_Pin->GetParentSymbol()->GetRef( &a.m_Sheet );
wxString refB = b.m_Pin->GetParentSymbol()->GetRef( &b.m_Sheet ); wxString refB = b.m_Pin->GetParentSymbol()->GetRef( &b.m_Sheet );
@ -852,7 +856,7 @@ XNODE* NETLIST_EXPORTER_XML::node( const wxString& aName,
} }
static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 ) static bool sortPinsByNumber( SCH_PIN* aPin1, SCH_PIN* aPin2 )
{ {
// return "lhs < rhs" // return "lhs < rhs"
return StrNumCmp( aPin1->GetShownNumber(), aPin2->GetShownNumber(), true ) < 0; return StrNumCmp( aPin1->GetShownNumber(), aPin2->GetShownNumber(), true ) < 0;

View File

@ -24,7 +24,7 @@
#include <bitmaps.h> #include <bitmaps.h>
#include <cstddef> #include <cstddef>
#include <magic_enum.hpp> #include <magic_enum.hpp>
#include <lib_pin.h> #include <sch_pin.h>
#include "pgm_base.h" #include "pgm_base.h"
@ -141,8 +141,11 @@ void InitTables()
for( PIN_ORIENTATION orientation : magic_enum::enum_values<PIN_ORIENTATION>() ) for( PIN_ORIENTATION orientation : magic_enum::enum_values<PIN_ORIENTATION>() )
{ {
g_orientationIcons.push_back( PinOrientationGetBitmap( orientation ) ); if( orientation != PIN_ORIENTATION::INHERIT )
g_orientationNames.push_back( PinOrientationName( orientation ) ); {
g_orientationIcons.push_back( PinOrientationGetBitmap( orientation ) );
g_orientationNames.push_back( PinOrientationName( orientation ) );
}
} }
} }

View File

@ -47,7 +47,8 @@ enum class ELECTRICAL_PINTYPE
PT_OPENEMITTER, ///< pin type open emitter PT_OPENEMITTER, ///< pin type open emitter
PT_NC, ///< not connected (must be left open) PT_NC, ///< not connected (must be left open)
PT_LAST_OPTION = PT_NC ///< sentinel value, set to last usable enum option PT_LAST_OPTION = PT_NC, ///< sentinel value, set to last usable enum option
PT_INHERIT
}; };
#define ELECTRICAL_PINTYPES_TOTAL ( static_cast<int>( ELECTRICAL_PINTYPE::PT_LAST_OPTION ) + 1 ) #define ELECTRICAL_PINTYPES_TOTAL ( static_cast<int>( ELECTRICAL_PINTYPE::PT_LAST_OPTION ) + 1 )
@ -64,7 +65,8 @@ enum class GRAPHIC_PINSHAPE
FALLING_EDGE_CLOCK, FALLING_EDGE_CLOCK,
NONLOGIC, NONLOGIC,
LAST_OPTION = NONLOGIC ///< this is the sentinel value, must be set to last enum value LAST_OPTION = NONLOGIC, ///< this is the sentinel value, must be set to last enum value
INHERIT
}; };
#define GRAPHIC_PINSHAPES_TOTAL ( static_cast<int>( GRAPHIC_PINSHAPE::LAST_OPTION ) + 1 ) #define GRAPHIC_PINSHAPES_TOTAL ( static_cast<int>( GRAPHIC_PINSHAPE::LAST_OPTION ) + 1 )
@ -77,6 +79,9 @@ enum class PIN_ORIENTATION {
PIN_LEFT = 'L', PIN_LEFT = 'L',
PIN_UP = 'U', PIN_UP = 'U',
PIN_DOWN = 'D', PIN_DOWN = 'D',
LAST_OPTION = PIN_DOWN,
INHERIT = 'I'
}; };
@ -88,8 +93,8 @@ BITMAPS PinShapeGetBitmap( GRAPHIC_PINSHAPE shape );
wxString ElectricalPinTypeGetText( ELECTRICAL_PINTYPE ); wxString ElectricalPinTypeGetText( ELECTRICAL_PINTYPE );
BITMAPS ElectricalPinTypeGetBitmap( ELECTRICAL_PINTYPE ); BITMAPS ElectricalPinTypeGetBitmap( ELECTRICAL_PINTYPE );
wxString PinOrientationName( PIN_ORIENTATION aPinOrientation ); wxString PinOrientationName( PIN_ORIENTATION aOrientation );
BITMAPS PinOrientationGetBitmap( PIN_ORIENTATION aPinOrientation ); BITMAPS PinOrientationGetBitmap( PIN_ORIENTATION aOrientation );
PIN_ORIENTATION PinOrientationCode( size_t index ); PIN_ORIENTATION PinOrientationCode( size_t index );
int PinOrientationIndex( PIN_ORIENTATION code ); int PinOrientationIndex( PIN_ORIENTATION code );

View File

@ -321,16 +321,19 @@ bool SCH_CONNECTION::IsDriver() const
case SCH_HIER_LABEL_T: case SCH_HIER_LABEL_T:
case SCH_SHEET_PIN_T: case SCH_SHEET_PIN_T:
case SCH_SHEET_T: case SCH_SHEET_T:
case LIB_PIN_T:
return true; return true;
case SCH_PIN_T: case SCH_PIN_T:
{ {
const SCH_PIN* pin = static_cast<const SCH_PIN*>( Parent() ); const SCH_PIN* pin = static_cast<const SCH_PIN*>( Parent() );
const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( pin->GetParentSymbol() );
// Only annotated symbols should drive nets. if( const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( pin->GetParentSymbol() ) )
return pin->IsGlobalPower() || symbol->IsAnnotated( &m_sheet ); {
// Only annotated symbols should drive nets.
return pin->IsGlobalPower() || symbol->IsAnnotated( &m_sheet );
}
return true;
} }
default: default:

View File

@ -37,8 +37,7 @@
#include <project/net_settings.h> #include <project/net_settings.h>
#include <lib_id.h> #include <lib_id.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <sch_bitmap.h> #include <sch_bitmap.h>
#include <sch_bus_entry.h> #include <sch_bus_entry.h>
#include <sch_symbol.h> #include <sch_symbol.h>
@ -1202,7 +1201,7 @@ void SCH_IO_ALTIUM::ParsePin( const std::map<wxString, wxString>& aProperties,
symbol = libSymbolIt->second; symbol = libSymbolIt->second;
} }
LIB_PIN* pin = new LIB_PIN( symbol ); SCH_PIN* pin = new SCH_PIN( symbol );
// Make sure that these are visible when initializing the symbol // Make sure that these are visible when initializing the symbol
// This may be overriden by the file data but not by the pin defaults // This may be overriden by the file data but not by the pin defaults
@ -3213,7 +3212,7 @@ void SCH_IO_ALTIUM::ParsePowerPort( const std::map<wxString, wxString>& aPropert
libSymbol->SetLibId( libId ); libSymbol->SetLibId( libId );
// generate graphic // generate graphic
LIB_PIN* pin = new LIB_PIN( libSymbol ); SCH_PIN* pin = new SCH_PIN( libSymbol );
libSymbol->AddDrawItem( pin, false ); libSymbol->AddDrawItem( pin, false );
pin->SetName( elem.text ); pin->SetName( elem.text );

View File

@ -143,7 +143,7 @@ CADSTAR_SCH_ARCHIVE_LOADER::loadLibPart( const CADSTAR_PART_ENTRY& aPart )
for( auto& [storedPinNum, termID] : m_symDefTerminalsMap[symbolID] ) for( auto& [storedPinNum, termID] : m_symDefTerminalsMap[symbolID] )
{ {
wxCHECK( termID > 0 && sym.m_Pins.size() >= size_t( termID ), nullptr ); wxCHECK( termID > 0 && sym.m_Pins.size() >= size_t( termID ), nullptr );
LIB_PIN* pin = kiSymDef->GetPin( storedPinNum ); SCH_PIN* pin = kiSymDef->GetPin( storedPinNum );
size_t termIdx = size_t( termID ) - 1; size_t termIdx = size_t( termID ) - 1;
// For now leave numerical pin number. Otherwise, when loading the // For now leave numerical pin number. Otherwise, when loading the
@ -234,7 +234,7 @@ CADSTAR_SCH_ARCHIVE_LOADER::loadLibPart( const CADSTAR_PART_ENTRY& aPart )
{ {
for( const CADSTAR_PART_PIN& csPin : csPinVector ) for( const CADSTAR_PART_PIN& csPin : csPinVector )
{ {
std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( retSym.get() ); std::unique_ptr<SCH_PIN> pin = std::make_unique<SCH_PIN>( retSym.get() );
long pinNum = csPin.m_Identifier; long pinNum = csPin.m_Identifier;
pin->SetNumber( wxString::Format( "%ld", pinNum ) ); pin->SetNumber( wxString::Format( "%ld", pinNum ) );
@ -878,7 +878,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
kiPart->SetShowPinNames( false ); kiPart->SetShowPinNames( false );
kiPart->SetShowPinNumbers( false ); kiPart->SetShowPinNumbers( false );
std::vector<LIB_PIN*> pins = kiPart->GetAllLibPins(); std::vector<SCH_PIN*> pins = kiPart->GetAllLibPins();
wxCHECK( pins.size() == 1, /*void*/ ); wxCHECK( pins.size() == 1, /*void*/ );
pins.at( 0 )->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN ); pins.at( 0 )->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
@ -1652,7 +1652,7 @@ const LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef( const SYMDEF_ID& aSymd
TERMINAL term = termPair.second; TERMINAL term = termPair.second;
wxString pinNum = wxString::Format( "%ld", term.ID ); wxString pinNum = wxString::Format( "%ld", term.ID );
wxString pinName = wxEmptyString; wxString pinName = wxEmptyString;
std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( kiSym.get() ); std::unique_ptr<SCH_PIN> pin = std::make_unique<SCH_PIN>( kiSym.get() );
// Assume passive pin for now (we will set it later once we load the parts) // Assume passive pin for now (we will set it later once we load the parts)
pin->SetType( ELECTRICAL_PINTYPE::PT_PASSIVE ); pin->SetType( ELECTRICAL_PINTYPE::PT_PASSIVE );
@ -1829,7 +1829,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymbolGateAndPartFields( const SYMDEF_ID& a
for( auto&& [storedPinNum, termID] : m_symDefTerminalsMap[aSymdefID] ) for( auto&& [storedPinNum, termID] : m_symDefTerminalsMap[aSymdefID] )
{ {
PART::DEFINITION::PIN csPin = getPartDefinitionPin( aCadstarPart, aGateID, termID ); PART::DEFINITION::PIN csPin = getPartDefinitionPin( aCadstarPart, aGateID, termID );
LIB_PIN* pin = kiSymDef->GetPin( storedPinNum ); SCH_PIN* pin = kiSymDef->GetPin( storedPinNum );
wxString pinName = HandleTextOverbar( csPin.Label ); wxString pinName = HandleTextOverbar( csPin.Label );
wxString pinNum = HandleTextOverbar( csPin.Name ); wxString pinNum = HandleTextOverbar( csPin.Name );
@ -2132,7 +2132,7 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads
{ {
TERMINAL_TO_PINNUM_MAP termNumMap = m_pinNumsMap.at( partGateIndex ); TERMINAL_TO_PINNUM_MAP termNumMap = m_pinNumsMap.at( partGateIndex );
std::map<wxString, LIB_PIN*> pinNumToLibPinMap; std::map<wxString, SCH_PIN*> pinNumToLibPinMap;
for( auto& term : termNumMap ) for( auto& term : termNumMap )
{ {
@ -2147,7 +2147,7 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads
if( aOldPinNum == aNewPinNum ) if( aOldPinNum == aNewPinNum )
return; return;
LIB_PIN* libpin = pinNumToLibPinMap.at( aOldPinNum ); SCH_PIN* libpin = pinNumToLibPinMap.at( aOldPinNum );
libpin->SetNumber( HandleTextOverbar( aNewPinNum ) ); libpin->SetNumber( HandleTextOverbar( aNewPinNum ) );
}; };
@ -3228,9 +3228,9 @@ LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart( const LIB_SYMBOL* aSym
break; break;
} }
case KICAD_T::LIB_PIN_T: case KICAD_T::SCH_PIN_T:
{ {
LIB_PIN& pin = static_cast<LIB_PIN&>( item ); SCH_PIN& pin = static_cast<SCH_PIN&>( item );
pin.SetPosition( scalePt( pin.GetPosition() ) ); pin.SetPosition( scalePt( pin.GetPosition() ) );
pin.SetLength( scaleLen( pin.GetLength() ) ); pin.SetLength( scaleLen( pin.GetLength() ) );
@ -3298,10 +3298,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int
} }
} }
std::vector<LIB_PIN*> pins; for( SCH_PIN* pin : aSymbolToFix->GetPins( aGateNumber ) )
aSymbolToFix->GetPins( pins, aGateNumber );
for( auto& pin : pins )
{ {
auto setPinOrientation = auto setPinOrientation =
[&]( const EDA_ANGLE& aAngle ) [&]( const EDA_ANGLE& aAngle )

View File

@ -39,7 +39,6 @@
#include <io/eagle/eagle_parser.h> #include <io/eagle/eagle_parser.h>
#include <string_utils.h> #include <string_utils.h>
#include <lib_id.h> #include <lib_id.h>
#include <lib_pin.h>
#include <project.h> #include <project.h>
#include <project_sch.h> #include <project_sch.h>
#include <sch_bus_entry.h> #include <sch_bus_entry.h>
@ -50,6 +49,7 @@
#include <sch_io/kicad_legacy/sch_io_kicad_legacy.h> #include <sch_io/kicad_legacy/sch_io_kicad_legacy.h>
#include <sch_marker.h> #include <sch_marker.h>
#include <sch_screen.h> #include <sch_screen.h>
#include <sch_pin.h>
#include <sch_shape.h> #include <sch_shape.h>
#include <sch_sheet.h> #include <sch_sheet.h>
#include <sch_sheet_path.h> #include <sch_sheet_path.h>
@ -1967,10 +1967,7 @@ void SCH_IO_EAGLE::loadInstance( wxXmlNode* aInstanceNode )
symbol->SetLibSymbol( new LIB_SYMBOL( *libSymbol ) ); symbol->SetLibSymbol( new LIB_SYMBOL( *libSymbol ) );
std::vector<LIB_PIN*> pins; for( const SCH_PIN* pin : symbol->GetLibPins() )
symbol->GetLibPins( pins );
for( const LIB_PIN* pin : pins )
m_connPoints[symbol->GetPinPhysicalPosition( pin )].emplace( pin ); m_connPoints[symbol->GetPinPhysicalPosition( pin )].emplace( pin );
if( part->IsPower() ) if( part->IsPower() )
@ -2153,7 +2150,7 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBO
else if( nodeName == wxT( "pin" ) ) else if( nodeName == wxT( "pin" ) )
{ {
EPIN ePin = EPIN( currentNode ); EPIN ePin = EPIN( currentNode );
std::unique_ptr<LIB_PIN> pin( loadPin( aSymbol, currentNode, &ePin, aGateNumber ) ); std::unique_ptr<SCH_PIN> pin( loadPin( aSymbol, currentNode, &ePin, aGateNumber ) );
pincount++; pincount++;
pin->SetType( ELECTRICAL_PINTYPE::PT_BIDI ); pin->SetType( ELECTRICAL_PINTYPE::PT_BIDI );
@ -2192,7 +2189,7 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBO
for( unsigned i = 0; i < pads.GetCount(); i++ ) for( unsigned i = 0; i < pads.GetCount(); i++ )
{ {
LIB_PIN* apin = new LIB_PIN( *pin ); SCH_PIN* apin = new SCH_PIN( *pin );
wxString padname( pads[i] ); wxString padname( pads[i] );
apin->SetNumber( padname ); apin->SetNumber( padname );
@ -2429,10 +2426,10 @@ SCH_SHAPE* SCH_IO_EAGLE::loadSymbolPolyLine( wxXmlNode* aPolygonNode, int aGateN
} }
LIB_PIN* SCH_IO_EAGLE::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aPin, SCH_PIN* SCH_IO_EAGLE::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aPin,
EPIN* aEPin, int aGateNumber ) EPIN* aEPin, int aGateNumber )
{ {
std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( aSymbol.get() ); std::unique_ptr<SCH_PIN> pin = std::make_unique<SCH_PIN>( aSymbol.get() );
pin->SetPosition( VECTOR2I( aEPin->x.ToSchUnits(), aEPin->y.ToSchUnits() ) ); pin->SetPosition( VECTOR2I( aEPin->x.ToSchUnits(), aEPin->y.ToSchUnits() ) );
pin->SetName( aEPin->name ); pin->SetName( aEPin->name );
pin->SetUnit( aGateNumber ); pin->SetUnit( aGateNumber );
@ -3481,7 +3478,7 @@ const SEG* SCH_IO_EAGLE::SEG_DESC::LabelAttached( const SCH_TEXT* aLabel ) const
// TODO could be used to place junctions, instead of IsJunctionNeeded() // TODO could be used to place junctions, instead of IsJunctionNeeded()
// (see SCH_EDIT_FRAME::importFile()) // (see SCH_EDIT_FRAME::importFile())
bool SCH_IO_EAGLE::checkConnections( const SCH_SYMBOL* aSymbol, const LIB_PIN* aPin ) const bool SCH_IO_EAGLE::checkConnections( const SCH_SYMBOL* aSymbol, const SCH_PIN* aPin ) const
{ {
wxCHECK( aSymbol && aPin, false ); wxCHECK( aSymbol && aPin, false );
@ -3511,12 +3508,11 @@ void SCH_IO_EAGLE::addImplicitConnections( SCH_SYMBOL* aSymbol, SCH_SCREEN* aScr
int unit = aSymbol->GetUnit(); int unit = aSymbol->GetUnit();
const wxString reference = aSymbol->GetField( REFERENCE_FIELD )->GetText(); const wxString reference = aSymbol->GetField( REFERENCE_FIELD )->GetText();
std::vector<LIB_PIN*> pins; std::vector<SCH_PIN*> pins = aSymbol->GetLibSymbolRef()->GetAllLibPins();
aSymbol->GetLibSymbolRef()->GetPins( pins ); std::set<int> missingUnits;
std::set<int> missingUnits;
// Search all units for pins creating implicit connections // Search all units for pins creating implicit connections
for( const LIB_PIN* pin : pins ) for( const SCH_PIN* pin : pins )
{ {
if( pin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN ) if( pin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN )
{ {
@ -3536,12 +3532,13 @@ void SCH_IO_EAGLE::addImplicitConnections( SCH_SYMBOL* aSymbol, SCH_SCREEN* aScr
switch( pin->GetOrientation() ) switch( pin->GetOrientation() )
{ {
case PIN_ORIENTATION::PIN_LEFT: default:
netLabel->SetSpinStyle( SPIN_STYLE::RIGHT );
break;
case PIN_ORIENTATION::PIN_RIGHT: case PIN_ORIENTATION::PIN_RIGHT:
netLabel->SetSpinStyle( SPIN_STYLE::LEFT ); netLabel->SetSpinStyle( SPIN_STYLE::LEFT );
break; break;
case PIN_ORIENTATION::PIN_LEFT:
netLabel->SetSpinStyle( SPIN_STYLE::RIGHT );
break;
case PIN_ORIENTATION::PIN_UP: case PIN_ORIENTATION::PIN_UP:
netLabel->SetSpinStyle( SPIN_STYLE::UP ); netLabel->SetSpinStyle( SPIN_STYLE::UP );
break; break;

View File

@ -51,7 +51,7 @@ class SCH_FIELD;
class STRING_UTF8_MAP; class STRING_UTF8_MAP;
class LIB_SYMBOL; class LIB_SYMBOL;
class SYMBOL_LIB; class SYMBOL_LIB;
class LIB_PIN; class SCH_PIN;
class wxXmlNode; class wxXmlNode;
@ -156,7 +156,7 @@ private:
SCH_SHAPE* loadSymbolRectangle( wxXmlNode* aRectNode, int aGateNumber ); SCH_SHAPE* loadSymbolRectangle( wxXmlNode* aRectNode, int aGateNumber );
SCH_SHAPE* loadSymbolPolyLine( wxXmlNode* aPolygonNode, int aGateNumber ); SCH_SHAPE* loadSymbolPolyLine( wxXmlNode* aPolygonNode, int aGateNumber );
SCH_ITEM* loadSymbolWire( wxXmlNode* aWireNode, int aGateNumber ); SCH_ITEM* loadSymbolWire( wxXmlNode* aWireNode, int aGateNumber );
LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode*, EPIN* epin, SCH_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode*, EPIN* epin,
int aGateNumber ); int aGateNumber );
SCH_TEXT* loadSymbolText( wxXmlNode* aLibText, int aGateNumber ); SCH_TEXT* loadSymbolText( wxXmlNode* aLibText, int aGateNumber );
void loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*>& aLines ); void loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*>& aLines );
@ -181,7 +181,7 @@ private:
wxFileName getLibFileName(); wxFileName getLibFileName();
///< Checks if there are other wires or pins at the position of the tested pin ///< Checks if there are other wires or pins at the position of the tested pin
bool checkConnections( const SCH_SYMBOL* aSymbol, const LIB_PIN* aPin ) const; bool checkConnections( const SCH_SYMBOL* aSymbol, const SCH_PIN* aPin ) const;
/** /**
* Create net labels to emulate implicit connections in Eagle. * Create net labels to emulate implicit connections in Eagle.

View File

@ -845,7 +845,7 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol
} }
} }
std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( aSymbol ); std::unique_ptr<SCH_PIN> pin = std::make_unique<SCH_PIN>( aSymbol );
pin->SetName( pinName ); pin->SetName( pinName );
pin->SetNumber( pinNumber ); pin->SetNumber( pinNumber );
@ -1006,7 +1006,7 @@ std::pair<LIB_SYMBOL*, bool> SCH_EASYEDA_PARSER::MakePowerSymbol( const wxString
ksymbol->SetShowPinNames( false ); ksymbol->SetShowPinNames( false );
ksymbol->SetShowPinNumbers( false ); ksymbol->SetShowPinNumbers( false );
std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( ksymbol.get() ); std::unique_ptr<SCH_PIN> pin = std::make_unique<SCH_PIN>( ksymbol.get() );
pin->SetName( aNetname ); pin->SetName( aNetname );
pin->SetNumber( wxS( "1" ) ); pin->SetNumber( wxS( "1" ) );

View File

@ -709,7 +709,7 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector<nlohm
EASYEDAPRO::PIN_INFO pinInfo; EASYEDAPRO::PIN_INFO pinInfo;
pinInfo.pin = *epin; pinInfo.pin = *epin;
std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( ksymbol ); std::unique_ptr<SCH_PIN> pin = std::make_unique<SCH_PIN>( ksymbol );
pin->SetUnit( unitId ); pin->SetUnit( unitId );
@ -1141,7 +1141,7 @@ void SCH_EASYEDAPRO_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aR
ApplyAttrToField( fontStyles, schSym->GetField( VALUE_FIELD ), *globalNetAttr, ApplyAttrToField( fontStyles, schSym->GetField( VALUE_FIELD ), *globalNetAttr,
false, true, compAttrs, schSym.get() ); false, true, compAttrs, schSym.get() );
for( LIB_PIN* pin : schSym->GetAllLibPins() ) for( SCH_PIN* pin : schSym->GetAllLibPins() )
pin->SetName( globalNetAttr->value ); pin->SetName( globalNetAttr->value );
} }
else else

View File

@ -20,8 +20,9 @@
#include <magic_enum.hpp> #include <magic_enum.hpp>
#include <wx/log.h> #include <wx/log.h>
#include <lib_symbol.h>
#include <sch_shape.h> #include <sch_shape.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <sch_text.h> #include <sch_text.h>
#include <macros.h> #include <macros.h>
#include <richio.h> #include <richio.h>
@ -1080,12 +1081,12 @@ SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadRect( LINE_READER& aReader )
} }
LIB_PIN* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, SCH_PIN* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol,
LINE_READER& aReader ) LINE_READER& aReader )
{ {
const char* line = aReader.Line(); const char* line = aReader.Line();
wxCHECK_MSG( strCompare( "X", line, &line ), nullptr, "Invalid LIB_PIN definition" ); wxCHECK_MSG( strCompare( "X", line, &line ), nullptr, "Invalid SCH_PIN definition" );
wxString name; wxString name;
wxString number; wxString number;
@ -1233,8 +1234,7 @@ LIB_PIN* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin( std::unique_ptr<LIB_SYMBOL>& aS
aReader.LineNumber(), pos ); aReader.LineNumber(), pos );
} }
SCH_PIN* pin = new SCH_PIN( aSymbol.get(),
LIB_PIN* pin = new LIB_PIN( aSymbol.get(),
ConvertToNewOverbarNotation( name ), ConvertToNewOverbarNotation( name ),
ConvertToNewOverbarNotation( number ), ConvertToNewOverbarNotation( number ),
orientation, orientation,
@ -1263,7 +1263,7 @@ LIB_PIN* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin( std::unique_ptr<LIB_SYMBOL>& aS
int flags = 0; int flags = 0;
for( int j = tmp.size(); j > 0; ) for( int j = (int) tmp.size(); j > 0; )
{ {
switch( tmp[--j].GetValue() ) switch( tmp[--j].GetValue() )
{ {
@ -1572,8 +1572,8 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMA
{ {
switch( item.Type() ) switch( item.Type() )
{ {
case LIB_PIN_T: case SCH_PIN_T:
savePin( static_cast<LIB_PIN*>( &item ), aFormatter ); savePin( static_cast<SCH_PIN*>( &item ), aFormatter );
break; break;
case SCH_TEXT_T: case SCH_TEXT_T:
@ -1723,9 +1723,9 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveField( const SCH_FIELD* aField,
} }
void SCH_IO_KICAD_LEGACY_LIB_CACHE::savePin( const LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter ) void SCH_IO_KICAD_LEGACY_LIB_CACHE::savePin( const SCH_PIN* aPin, OUTPUTFORMATTER& aFormatter )
{ {
wxCHECK_RET( aPin && aPin->Type() == LIB_PIN_T, "Invalid LIB_PIN object." ); wxCHECK_RET( aPin && aPin->Type() == SCH_PIN_T, "Invalid SCH_PIN object." );
int Etype; int Etype;
@ -1784,7 +1784,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::savePin( const LIB_PIN* aPin, OUTPUTFORMATTE
aFormatter.Print( 0, "\n" ); aFormatter.Print( 0, "\n" );
const_cast<LIB_PIN*>( aPin )->ClearFlags( IS_CHANGED ); const_cast<SCH_PIN*>( aPin )->ClearFlags( IS_CHANGED );
} }

View File

@ -29,7 +29,8 @@
#include "sch_io/sch_io_lib_cache.h" #include "sch_io/sch_io_lib_cache.h"
class FILE_LINE_READER; class FILE_LINE_READER;
class LIB_PIN; class SCH_PIN;
class SCH_FIELD;
class SCH_SHAPE; class SCH_SHAPE;
class SCH_TEXT; class SCH_TEXT;
class LINE_READER; class LINE_READER;
@ -77,7 +78,7 @@ private:
static SCH_SHAPE* loadCircle( LINE_READER& aReader ); static SCH_SHAPE* loadCircle( LINE_READER& aReader );
static SCH_TEXT* loadText( LINE_READER& aReader, int aMajorVersion, int aMinorVersion ); static SCH_TEXT* loadText( LINE_READER& aReader, int aMajorVersion, int aMinorVersion );
static SCH_SHAPE* loadRect( LINE_READER& aReader ); static SCH_SHAPE* loadRect( LINE_READER& aReader );
static LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader ); static SCH_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
static SCH_SHAPE* loadPolyLine( LINE_READER& aReader ); static SCH_SHAPE* loadPolyLine( LINE_READER& aReader );
static SCH_SHAPE* loadBezier( LINE_READER& aReader ); static SCH_SHAPE* loadBezier( LINE_READER& aReader );
@ -88,7 +89,7 @@ private:
static void saveBezier( SCH_SHAPE* aBezier, OUTPUTFORMATTER& aFormatter ); static void saveBezier( SCH_SHAPE* aBezier, OUTPUTFORMATTER& aFormatter );
static void saveCircle( SCH_SHAPE* aCircle, OUTPUTFORMATTER& aFormatter ); static void saveCircle( SCH_SHAPE* aCircle, OUTPUTFORMATTER& aFormatter );
static void saveField( const SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter ); static void saveField( const SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter );
static void savePin( const LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter ); static void savePin( const SCH_PIN* aPin, OUTPUTFORMATTER& aFormatter );
static void savePolyLine( SCH_SHAPE* aPolyLine, OUTPUTFORMATTER& aFormatter ); static void savePolyLine( SCH_SHAPE* aPolyLine, OUTPUTFORMATTER& aFormatter );
static void saveRectangle( SCH_SHAPE* aRectangle, OUTPUTFORMATTER& aFormatter ); static void saveRectangle( SCH_SHAPE* aRectangle, OUTPUTFORMATTER& aFormatter );
static void saveText( const SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter ); static void saveText( const SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter );

View File

@ -39,6 +39,7 @@
#include <sch_edit_frame.h> // SYMBOL_ORIENTATION_T #include <sch_edit_frame.h> // SYMBOL_ORIENTATION_T
#include <sch_junction.h> #include <sch_junction.h>
#include <sch_line.h> #include <sch_line.h>
#include <sch_pin.h>
#include <sch_shape.h> #include <sch_shape.h>
#include <sch_no_connect.h> #include <sch_no_connect.h>
#include <sch_text.h> #include <sch_text.h>
@ -49,7 +50,6 @@
#include <sch_sheet_pin.h> #include <sch_sheet_pin.h>
#include <schematic.h> #include <schematic.h>
#include <sch_screen.h> #include <sch_screen.h>
#include <lib_pin.h>
#include <io/kicad/kicad_io_utils.h> #include <io/kicad/kicad_io_utils.h>
#include <schematic_lexer.h> #include <schematic_lexer.h>
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h> #include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>

View File

@ -22,7 +22,7 @@
#include <eda_shape.h> #include <eda_shape.h>
#include <kiid.h> #include <kiid.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <sch_sheet_pin.h> #include <sch_sheet_pin.h>
#include <sch_text.h> #include <sch_text.h>

View File

@ -370,8 +370,8 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFO
break; break;
} }
case LIB_PIN_T: case SCH_PIN_T:
savePin( static_cast<LIB_PIN*>( aItem ), aFormatter, aNestLevel ); savePin( static_cast<SCH_PIN*>( aItem ), aFormatter, aNestLevel );
break; break;
case SCH_TEXT_T: case SCH_TEXT_T:
@ -419,10 +419,10 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveField( SCH_FIELD* aField, OUTPUTFORMATTER
} }
void SCH_IO_KICAD_SEXPR_LIB_CACHE::savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter, void SCH_IO_KICAD_SEXPR_LIB_CACHE::savePin( SCH_PIN* aPin, OUTPUTFORMATTER& aFormatter,
int aNestLevel ) int aNestLevel )
{ {
wxCHECK_RET( aPin && aPin->Type() == LIB_PIN_T, "Invalid LIB_PIN object." ); wxCHECK_RET( aPin && aPin->Type() == SCH_PIN_T, "Invalid SCH_PIN object." );
aPin->ClearFlags( IS_CHANGED ); aPin->ClearFlags( IS_CHANGED );
@ -458,7 +458,7 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFor
aPin->GetNumberTextSize() ).c_str() ); aPin->GetNumberTextSize() ).c_str() );
for( const std::pair<const wxString, LIB_PIN::ALT>& alt : aPin->GetAlternates() ) for( const std::pair<const wxString, SCH_PIN::ALT>& alt : aPin->GetAlternates() )
{ {
aFormatter.Print( aNestLevel + 1, "(alternate %s %s %s)\n", aFormatter.Print( aNestLevel + 1, "(alternate %s %s %s)\n",
aFormatter.Quotew( alt.second.m_Name ).c_str(), aFormatter.Quotew( alt.second.m_Name ).c_str(),

View File

@ -25,7 +25,7 @@
#include "sch_io/sch_io_lib_cache.h" #include "sch_io/sch_io_lib_cache.h"
class FILE_LINE_READER; class FILE_LINE_READER;
class LIB_PIN; class SCH_PIN;
class SCH_TEXT; class SCH_TEXT;
class SCH_TEXTBOX; class SCH_TEXTBOX;
class LINE_READER; class LINE_READER;
@ -65,7 +65,7 @@ private:
static void saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFORMATTER& aFormatter, static void saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFORMATTER& aFormatter,
int aNestLevel ); int aNestLevel );
static void saveField( SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter, int aNestLevel ); static void saveField( SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter, int aNestLevel );
static void savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); static void savePin( SCH_PIN* aPin, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 );
static void saveText( SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); static void saveText( SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 );
static void saveTextBox( SCH_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter, static void saveTextBox( SCH_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter,
int aNestLevel = 0 ); int aNestLevel = 0 );

View File

@ -36,7 +36,7 @@
#include <base_units.h> #include <base_units.h>
#include <lib_id.h> #include <lib_id.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <math/util.h> // KiROUND, Clamp #include <math/util.h> // KiROUND, Clamp
#include <font/font.h> #include <font/font.h>
#include <string_utils.h> #include <string_utils.h>
@ -1415,7 +1415,7 @@ SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolCircle()
} }
LIB_PIN* SCH_IO_KICAD_SEXPR_PARSER::parsePin() SCH_PIN* SCH_IO_KICAD_SEXPR_PARSER::parsePin()
{ {
auto parseType = [&]( T token ) -> ELECTRICAL_PINTYPE auto parseType = [&]( T token ) -> ELECTRICAL_PINTYPE
{ {
@ -1470,7 +1470,7 @@ LIB_PIN* SCH_IO_KICAD_SEXPR_PARSER::parsePin()
T token; T token;
wxString tmp; wxString tmp;
wxString error; wxString error;
std::unique_ptr<LIB_PIN> pin = std::make_unique<LIB_PIN>( nullptr ); std::unique_ptr<SCH_PIN> pin = std::make_unique<SCH_PIN>( nullptr );
pin->SetUnit( m_unit ); pin->SetUnit( m_unit );
pin->SetBodyStyle( m_bodyStyle ); pin->SetBodyStyle( m_bodyStyle );
@ -1592,7 +1592,7 @@ LIB_PIN* SCH_IO_KICAD_SEXPR_PARSER::parsePin()
case T_alternate: case T_alternate:
{ {
LIB_PIN::ALT alt; SCH_PIN::ALT alt;
token = NextTok(); token = NextTok();

View File

@ -37,7 +37,7 @@
#include <default_values.h> // For some default values #include <default_values.h> // For some default values
class LIB_PIN; class SCH_PIN;
class PAGE_INFO; class PAGE_INFO;
class SCH_BITMAP; class SCH_BITMAP;
class SCH_BUS_WIRE_ENTRY; class SCH_BUS_WIRE_ENTRY;
@ -196,7 +196,7 @@ private:
SCH_SHAPE* parseSymbolArc(); SCH_SHAPE* parseSymbolArc();
SCH_SHAPE* parseSymbolBezier(); SCH_SHAPE* parseSymbolBezier();
SCH_SHAPE* parseSymbolCircle(); SCH_SHAPE* parseSymbolCircle();
LIB_PIN* parsePin(); SCH_PIN* parsePin();
SCH_SHAPE* parseSymbolPolyLine(); SCH_SHAPE* parseSymbolPolyLine();
SCH_SHAPE* parseSymbolRectangle(); SCH_SHAPE* parseSymbolRectangle();
SCH_TEXT* parseSymbolText(); SCH_TEXT* parseSymbolText();

View File

@ -308,7 +308,7 @@ void SCH_IO_LTSPICE_PARSER::CreateSymbol( LTSPICE_SCHEMATIC::LT_SYMBOL& aLtSymbo
for( int j = 0; j < (int) aLtSymbol.Pins.size(); j++ ) for( int j = 0; j < (int) aLtSymbol.Pins.size(); j++ )
{ {
LIB_PIN* pin = new LIB_PIN( aLibSymbol ); SCH_PIN* pin = new SCH_PIN( aLibSymbol );
CreatePin( aLtSymbol, j, pin ); CreatePin( aLtSymbol, j, pin );
aLibSymbol->AddDrawItem( pin ); aLibSymbol->AddDrawItem( pin );
@ -833,7 +833,7 @@ SCH_SYMBOL* SCH_IO_LTSPICE_PARSER::CreatePowerSymbol( const VECTOR2I& aOffset,
lib_symbol->AddDrawItem( shape ); lib_symbol->AddDrawItem( shape );
lib_symbol->SetPower(); lib_symbol->SetPower();
LIB_PIN* pin = new LIB_PIN( lib_symbol ); SCH_PIN* pin = new SCH_PIN( lib_symbol );
pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN ); pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
pin->SetPosition( ToInvertedKicadCoords( { 0, 0 } ) ); pin->SetPosition( ToInvertedKicadCoords( { 0, 0 } ) );
@ -1272,7 +1272,7 @@ void SCH_IO_LTSPICE_PARSER::CreateRect( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol,
void SCH_IO_LTSPICE_PARSER::CreatePin( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, void SCH_IO_LTSPICE_PARSER::CreatePin( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex,
LIB_PIN* aPin ) SCH_PIN* aPin )
{ {
LTSPICE_SCHEMATIC::LT_PIN& lt_pin = aLTSymbol.Pins[aIndex]; LTSPICE_SCHEMATIC::LT_PIN& lt_pin = aLTSymbol.Pins[aIndex];
wxString device = aLTSymbol.Name.Lower(); wxString device = aLTSymbol.Name.Lower();

View File

@ -35,7 +35,7 @@
class EDA_TEXT; class EDA_TEXT;
class LIB_PIN; class SCH_PIN;
class SCH_LABEL_BASE; class SCH_LABEL_BASE;
class SCH_SYMBOL; class SCH_SYMBOL;
class SCH_TEXT; class SCH_TEXT;
@ -252,7 +252,7 @@ public:
/** /**
* Create a pin from an asy file. * Create a pin from an asy file.
*/ */
void CreatePin( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, LIB_PIN* aPin ); void CreatePin( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbol, int aIndex, SCH_PIN* aPin );
/** /**
* Create a symbol arc. * Create a symbol arc.

View File

@ -32,7 +32,7 @@
#include <geometry/shape_segment.h> #include <geometry/shape_segment.h>
#include <geometry/shape_rect.h> #include <geometry/shape_rect.h>
#include <gr_text.h> #include <gr_text.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <math/util.h> #include <math/util.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <sch_bitmap.h> #include <sch_bitmap.h>
@ -88,7 +88,7 @@ std::vector<KICAD_T> SCH_PAINTER::g_ScaledSelectionTypes = {
SCH_SHEET_PIN_T, SCH_SHEET_PIN_T,
LIB_SYMBOL_T, SCH_SYMBOL_T, LIB_SYMBOL_T, SCH_SYMBOL_T,
SCH_SHEET_T, SCH_SHEET_T,
LIB_PIN_T, SCH_PIN_T SCH_PIN_T
}; };
@ -178,9 +178,9 @@ void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed )
case LIB_SYMBOL_T: case LIB_SYMBOL_T:
draw( static_cast<const LIB_SYMBOL*>( aItem ), aLayer ); draw( static_cast<const LIB_SYMBOL*>( aItem ), aLayer );
break; break;
case LIB_PIN_T: case SCH_PIN_T:
drawBoundingBox = false; drawBoundingBox = false;
draw( static_cast<const LIB_PIN*>( aItem ), aLayer, aDimmed ); draw( static_cast<const SCH_PIN*>( aItem ), aLayer, aDimmed );
break; break;
case SCH_SYMBOL_T: case SCH_SYMBOL_T:
draw( static_cast<const SCH_SYMBOL*>( aItem ), aLayer ); draw( static_cast<const SCH_SYMBOL*>( aItem ), aLayer );
@ -315,21 +315,13 @@ float SCH_PAINTER::getShadowWidth( bool aForHighlight ) const
} }
// A helper function to know if a EDA_ITEM is a member of a footprint COLOR4D SCH_PAINTER::getRenderColor( const SCH_ITEM* aItem, int aLayer, bool aDrawingShadows,
static bool IsItemFPMember( const EDA_ITEM* aItem )
{
return aItem->GetParent() && ( aItem->GetParent()->Type() == LIB_SYMBOL_T
|| aItem->GetParent()->Type() == SCH_SYMBOL_T );
}
COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows,
bool aDimmed ) const bool aDimmed ) const
{ {
COLOR4D color = m_schSettings.GetLayerColor( aLayer ); COLOR4D color = m_schSettings.GetLayerColor( aLayer );
// Graphic items of a SYMBOL frequently use the LAYER_DEVICE layer color // Graphic items of a SYMBOL frequently use the LAYER_DEVICE layer color
// (i.e. when no specific color is set) // (i.e. when no specific color is set)
bool isFpMember = IsItemFPMember( aItem ); bool isSymbolChild = aItem->GetParentSymbol() != nullptr;
if( aItem->Type() == SCH_LINE_T ) if( aItem->Type() == SCH_LINE_T )
{ {
@ -360,21 +352,22 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
{ {
if( !isFpMember || shape->GetFillColor() != COLOR4D::UNSPECIFIED ) if( !isSymbolChild || shape->GetFillColor() != COLOR4D::UNSPECIFIED )
color = shape->GetFillColor(); color = shape->GetFillColor();
if( isFpMember && shape->GetFillMode() == FILL_T::FILLED_SHAPE )
if( isSymbolChild && shape->GetFillMode() == FILL_T::FILLED_SHAPE )
color = shape->GetStroke().GetColor(); color = shape->GetStroke().GetColor();
} }
else else
{ {
if( !isFpMember || shape->GetStroke().GetColor() != COLOR4D::UNSPECIFIED ) if( !isSymbolChild || shape->GetStroke().GetColor() != COLOR4D::UNSPECIFIED )
color = shape->GetStroke().GetColor(); color = shape->GetStroke().GetColor();
} }
// A filled shape means filled; if they didn't specify a fill colour then use the // A filled shape means filled; if they didn't specify a fill colour then use the
// border colour. // border colour.
if( color == COLOR4D::UNSPECIFIED ) if( color == COLOR4D::UNSPECIFIED )
color = m_schSettings.GetLayerColor( isFpMember ? LAYER_DEVICE : LAYER_NOTES ); color = m_schSettings.GetLayerColor( isSymbolChild ? LAYER_DEVICE : LAYER_NOTES );
} }
else if( aItem->IsType( { SCH_LABEL_LOCATE_ANY_T } ) ) else if( aItem->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
{ {
@ -390,12 +383,12 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
color = textBox->GetFillColor(); color = textBox->GetFillColor();
else if( !isFpMember || textBox->GetTextColor() != COLOR4D::UNSPECIFIED ) else if( !isSymbolChild || textBox->GetTextColor() != COLOR4D::UNSPECIFIED )
color = textBox->GetTextColor(); color = textBox->GetTextColor();
} }
else if( const EDA_TEXT* otherTextItem = dynamic_cast<const EDA_TEXT*>( aItem ) ) else if( const EDA_TEXT* otherTextItem = dynamic_cast<const EDA_TEXT*>( aItem ) )
{ {
if( !isFpMember || otherTextItem->GetTextColor() != COLOR4D::UNSPECIFIED ) if( !isSymbolChild || otherTextItem->GetTextColor() != COLOR4D::UNSPECIFIED )
color = otherTextItem->GetTextColor(); color = otherTextItem->GetTextColor();
} }
} }
@ -424,8 +417,8 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
if( aDrawingShadows ) if( aDrawingShadows )
color = m_schSettings.GetLayerColor( LAYER_SELECTION_SHADOWS ); color = m_schSettings.GetLayerColor( LAYER_SELECTION_SHADOWS );
} }
else if( aItem->IsSelected() else if( aItem->IsSelected() && ( aLayer == LAYER_DEVICE_BACKGROUND
&& ( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND ) ) || aLayer == LAYER_SHEET_BACKGROUND ) )
{ {
// Selected items will be painted over all other items, so make backgrounds translucent so // Selected items will be painted over all other items, so make backgrounds translucent so
// that non-selected overlapping objects are visible // that non-selected overlapping objects are visible
@ -452,17 +445,11 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
} }
float SCH_PAINTER::getLineWidth( const EDA_ITEM* aItem, bool aDrawingShadows ) const float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) const
{ {
wxCHECK( aItem, static_cast<float>( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ) ) ); wxCHECK( aItem, static_cast<float>( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ) ) );
int pen = 0; int pen = aItem->GetEffectivePenWidth( &m_schSettings );
if( const SCH_ITEM* item = dynamic_cast<const SCH_ITEM*>( aItem ) )
pen = item->GetEffectivePenWidth( &m_schSettings );
else
UNIMPLEMENTED_FOR( aItem->GetClass() );
float width = pen; float width = pen;
if( aItem->IsBrightened() || aItem->IsSelected() ) if( aItem->IsBrightened() || aItem->IsSelected() )
@ -475,7 +462,7 @@ float SCH_PAINTER::getLineWidth( const EDA_ITEM* aItem, bool aDrawingShadows ) c
} }
float SCH_PAINTER::getTextThickness( const EDA_ITEM* aItem ) const float SCH_PAINTER::getTextThickness( const SCH_ITEM* aItem ) const
{ {
int pen = m_schSettings.GetDefaultPenWidth(); int pen = m_schSettings.GetDefaultPenWidth();
@ -540,20 +527,21 @@ static bool isFieldsLayer( int aLayer )
void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition, void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition,
const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics ) const TEXT_ATTRIBUTES& aAttributes,
const KIFONT::METRICS& aFontMetrics )
{ {
KIFONT::FONT* font = aAttrs.m_Font; KIFONT::FONT* font = aAttributes.m_Font;
if( !font ) if( !font )
{ {
font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttrs.m_Bold, font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttributes.m_Bold,
aAttrs.m_Italic ); aAttributes.m_Italic );
} }
m_gal->SetIsFill( font->IsOutline() ); m_gal->SetIsFill( font->IsOutline() );
m_gal->SetIsStroke( font->IsStroke() ); m_gal->SetIsStroke( font->IsStroke() );
font->Draw( m_gal, aText, aPosition, aAttrs, aFontMetrics ); font->Draw( m_gal, aText, aPosition, aAttributes, aFontMetrics );
} }
@ -620,8 +608,10 @@ void SCH_PAINTER::knockoutText( const wxString& aText, const VECTOR2D& aPosition
void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition, void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition,
const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics, const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics,
bool invertY ) bool aInvertY )
{ {
bool invertY = aInvertY;
KIFONT::FONT* font = aAttrs.m_Font; KIFONT::FONT* font = aAttrs.m_Font;
if( !font ) if( !font )
@ -812,7 +802,7 @@ bool SCH_PAINTER::setDeviceColors( const SCH_ITEM* aItem, int aLayer, bool aDimm
} }
int SCH_PAINTER::internalPinDecoSize( const LIB_PIN &aPin ) int SCH_PAINTER::internalPinDecoSize( const SCH_PIN &aPin )
{ {
if( m_schSettings.m_PinSymbolSize > 0 ) if( m_schSettings.m_PinSymbolSize > 0 )
return m_schSettings.m_PinSymbolSize; return m_schSettings.m_PinSymbolSize;
@ -823,7 +813,7 @@ int SCH_PAINTER::internalPinDecoSize( const LIB_PIN &aPin )
// Utility for getting the size of the 'external' pin decorators (as a radius) // Utility for getting the size of the 'external' pin decorators (as a radius)
// i.e. the negation circle, the polarity 'slopes' and the nonlogic marker // i.e. the negation circle, the polarity 'slopes' and the nonlogic marker
int SCH_PAINTER::externalPinDecoSize( const LIB_PIN &aPin ) int SCH_PAINTER::externalPinDecoSize( const SCH_PIN &aPin )
{ {
if( m_schSettings.m_PinSymbolSize > 0 ) if( m_schSettings.m_PinSymbolSize > 0 )
return m_schSettings.m_PinSymbolSize; return m_schSettings.m_PinSymbolSize;
@ -849,7 +839,7 @@ void SCH_PAINTER::drawPinDanglingIndicator( const VECTOR2I& aPos, const COLOR4D&
} }
void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed ) void SCH_PAINTER::draw( const SCH_PIN* aPin, int aLayer, bool aDimmed )
{ {
if( !isUnitAndConversionShown( aPin ) ) if( !isUnitAndConversionShown( aPin ) )
return; return;
@ -993,6 +983,7 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
{ {
switch( aPin->GetShape() ) switch( aPin->GetShape() )
{ {
default:
case GRAPHIC_PINSHAPE::LINE: case GRAPHIC_PINSHAPE::LINE:
m_gal->DrawLine( p0, pos ); m_gal->DrawLine( p0, pos );
break; break;
@ -1091,22 +1082,17 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
} }
} }
const SYMBOL* libEntry = aPin->GetParentSymbol(); if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children )
return;
// Draw the labels // Draw the labels
const SYMBOL* symbol = aPin->GetParentSymbol();
if( libEntry->Type() == LIB_SYMBOL_T ) float penWidth = (float) m_schSettings.GetDefaultPenWidth();
{ int textOffset = symbol->GetPinNameOffset();
if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children ) float nameStrokeWidth = getLineWidth( aPin, false );
return; float numStrokeWidth = getLineWidth( aPin, false );
} bool showPinNames = symbol->GetShowPinNames();
bool showPinNumbers = m_schSettings.m_ShowPinNumbers || symbol->GetShowPinNumbers();
float penWidth = (float) m_schSettings.GetDefaultPenWidth();
int textOffset = libEntry->GetPinNameOffset();
float nameStrokeWidth = getLineWidth( aPin, false );
float numStrokeWidth = getLineWidth( aPin, false );
bool showPinNames = libEntry->GetShowPinNames();
bool showPinNumbers = m_schSettings.m_ShowPinNumbers || libEntry->GetShowPinNumbers();
nameStrokeWidth = Clamp_Text_PenSize( nameStrokeWidth, aPin->GetNameTextSize(), true ); nameStrokeWidth = Clamp_Text_PenSize( nameStrokeWidth, aPin->GetNameTextSize(), true );
numStrokeWidth = Clamp_Text_PenSize( numStrokeWidth, aPin->GetNumberTextSize(), true ); numStrokeWidth = Clamp_Text_PenSize( numStrokeWidth, aPin->GetNumberTextSize(), true );
@ -1245,12 +1231,12 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
else if( nonCached( aPin ) && renderTextAsBitmap ) else if( nonCached( aPin ) && renderTextAsBitmap )
{ {
bitmapText( text[i], aPos, attrs ); bitmapText( text[i], aPos, attrs );
const_cast<LIB_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP ); const_cast<SCH_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
} }
else else
{ {
strokeText( text[i], aPos, attrs, aPin->GetFontMetrics() ); strokeText( text[i], aPos, attrs, aPin->GetFontMetrics() );
const_cast<LIB_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP ); const_cast<SCH_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
} }
}; };
@ -1695,14 +1681,13 @@ void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer, bool aDimmed )
switch( aText->Type() ) switch( aText->Type() )
{ {
case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break; case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break; case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break; case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
case SCH_DIRECTIVE_LABEL_T: aLayer = LAYER_NETCLASS_REFS; break; case SCH_DIRECTIVE_LABEL_T: aLayer = LAYER_NETCLASS_REFS; break;
case SCH_TEXT_T: case SCH_TEXT_T: aLayer = aText->GetParentSymbol() ? LAYER_DEVICE
aLayer = IsItemFPMember( aText ) ? LAYER_DEVICE : LAYER_NOTES; : LAYER_NOTES; break;
break; default: aLayer = LAYER_NOTES; break;
default: aLayer = LAYER_NOTES; break;
} }
COLOR4D color = getRenderColor( aText, aLayer, drawingShadows, aDimmed ); COLOR4D color = getRenderColor( aText, aLayer, drawingShadows, aDimmed );
@ -2259,13 +2244,11 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer )
: dummy(); : dummy();
bool invertY = true; bool invertY = true;
std::vector<LIB_PIN*> originalPins; std::vector<SCH_PIN*> originalPins = originalSymbol->GetPins( unit, bodyStyle );
originalSymbol->GetPins( originalPins, unit, bodyStyle );
// Copy the source so we can re-orient and translate it. // Copy the source so we can re-orient and translate it.
LIB_SYMBOL tempSymbol( *originalSymbol ); LIB_SYMBOL tempSymbol( *originalSymbol );
std::vector<LIB_PIN*> tempPins; std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( unit, bodyStyle );
tempSymbol.GetPins( tempPins, unit, bodyStyle );
tempSymbol.SetFlags( aSymbol->GetFlags() ); tempSymbol.SetFlags( aSymbol->GetFlags() );
@ -2296,7 +2279,7 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer )
for( unsigned i = 0; i < tempPins.size(); ++ i ) for( unsigned i = 0; i < tempPins.size(); ++ i )
{ {
SCH_PIN* symbolPin = aSymbol->GetPin( originalPins[ i ] ); SCH_PIN* symbolPin = aSymbol->GetPin( originalPins[ i ] );
LIB_PIN* tempPin = tempPins[ i ]; SCH_PIN* tempPin = tempPins[ i ];
tempPin->ClearFlags(); tempPin->ClearFlags();
tempPin->SetFlags( symbolPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED, tempPin->SetFlags( symbolPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
@ -2319,7 +2302,7 @@ void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer )
for( unsigned i = 0; i < tempPins.size(); ++i ) for( unsigned i = 0; i < tempPins.size(); ++i )
{ {
SCH_PIN* symbolPin = aSymbol->GetPin( originalPins[ i ] ); SCH_PIN* symbolPin = aSymbol->GetPin( originalPins[ i ] );
LIB_PIN* tempPin = tempPins[ i ]; SCH_PIN* tempPin = tempPins[ i ];
symbolPin->ClearFlags(); symbolPin->ClearFlags();
tempPin->ClearFlags( IS_DANGLING ); // Clear this temporary flag tempPin->ClearFlags( IS_DANGLING ); // Clear this temporary flag

View File

@ -33,7 +33,7 @@
#include <gal/painter.h> #include <gal/painter.h>
class LIB_PIN; class SCH_PIN;
class LIB_SYMBOL; class LIB_SYMBOL;
class SCH_SYMBOL; class SCH_SYMBOL;
class SCH_FIELD; class SCH_FIELD;
@ -80,7 +80,7 @@ public:
private: private:
void drawItemBoundingBox( const EDA_ITEM* aItem ); void drawItemBoundingBox( const EDA_ITEM* aItem );
void draw( const EDA_ITEM*, int, bool aDimmed ); void draw( const EDA_ITEM*, int, bool aDimmed );
void draw( const LIB_PIN* aPin, int aLayer, bool aDimmed ); void draw( const SCH_PIN* aPin, int aLayer, bool aDimmed );
void draw( const LIB_SYMBOL* aSymbol, int, bool aDrawFields = true, int aUnit = 0, void draw( const LIB_SYMBOL* aSymbol, int, bool aDrawFields = true, int aUnit = 0,
int aBodyStyle = 0, bool aDimmed = false ); int aBodyStyle = 0, bool aDimmed = false );
void draw( const SCH_SYMBOL* aSymbol, int aLayer ); void draw( const SCH_SYMBOL* aSymbol, int aLayer );
@ -106,8 +106,8 @@ private:
void drawDanglingIndicator( const VECTOR2I& aPos, const COLOR4D& aColor, int aWidth, void drawDanglingIndicator( const VECTOR2I& aPos, const COLOR4D& aColor, int aWidth,
bool aDangling, bool aDrawingShadows, bool aBrightened ); bool aDangling, bool aDrawingShadows, bool aBrightened );
int internalPinDecoSize( const LIB_PIN &aPin ); int internalPinDecoSize( const SCH_PIN &aPin );
int externalPinDecoSize( const LIB_PIN &aPin ); int externalPinDecoSize( const SCH_PIN &aPin );
// Indicates the item is drawn on a non-cached layer in OpenGL // Indicates the item is drawn on a non-cached layer in OpenGL
bool nonCached( const EDA_ITEM* aItem ); bool nonCached( const EDA_ITEM* aItem );
@ -115,11 +115,11 @@ private:
bool isUnitAndConversionShown( const SCH_ITEM* aItem ) const; bool isUnitAndConversionShown( const SCH_ITEM* aItem ) const;
float getShadowWidth( bool aForHighlight ) const; float getShadowWidth( bool aForHighlight ) const;
COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows, COLOR4D getRenderColor( const SCH_ITEM* aItem, int aLayer, bool aDrawingShadows,
bool aDimmed = false ) const; bool aDimmed = false ) const;
KIFONT::FONT* getFont( const EDA_TEXT* aText ) const; KIFONT::FONT* getFont( const EDA_TEXT* aText ) const;
float getLineWidth( const EDA_ITEM* aItem, bool aDrawingShadows ) const; float getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) const;
float getTextThickness( const EDA_ITEM* aItem ) const; float getTextThickness( const SCH_ITEM* aItem ) const;
int getOperatingPointTextSize() const; int getOperatingPointTextSize() const;

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,10 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 <stambaughw@gmail.com>
* Copyright (C) 2018 CERN * Copyright (C) 2018 CERN
* Copyright (C) 2019-2024 KiCad Developers, see AUTHOR.txt for contributors. * Copyright (C) 2004-2024 KiCad Developers, see AUTHOR.txt for contributors.
* @author Jon Evans <jon@craftyjon.com> * @author Jon Evans <jon@craftyjon.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -19,89 +21,352 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _SCH_PIN_CONNECTION_H #ifndef SCH_PIN_H
#define _SCH_PIN_CONNECTION_H #define SCH_PIN_H
#include <lib_pin.h> #include <pin_type.h>
#include <sch_item.h> #include <sch_item.h>
#include <sch_sheet_path.h> #include <symbol.h>
#include <mutex>
#include <map>
class LIB_SYMBOL;
class SCH_SYMBOL; class SCH_SYMBOL;
class MSG_PANEL_ITEM;
// Circle diameter drawn at the active end of pins:
#define TARGET_PIN_RADIUS schIUScale.MilsToIU( 15 )
// Pin visibility flag bit:
#define PIN_INVISIBLE 1 // Set makes pin invisible
class SCH_PIN : public SCH_ITEM class SCH_PIN : public SCH_ITEM
{ {
public: public:
SCH_PIN( LIB_PIN* aLibPin, SCH_SYMBOL* aParentSymbol ); struct ALT
{
wxString m_Name;
GRAPHIC_PINSHAPE m_Shape; // Shape drawn around pin
ELECTRICAL_PINTYPE m_Type; // Electrical type of the pin.
};
SCH_PIN( LIB_SYMBOL* aParentSymbol );
SCH_PIN( LIB_SYMBOL* aParentSymbol, 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 );
SCH_PIN( SCH_PIN* aLibPin, SCH_SYMBOL* aParentSymbol );
SCH_PIN( SCH_SYMBOL* aParentSymbol, const wxString& aNumber, const wxString& aAlt ); SCH_PIN( SCH_SYMBOL* aParentSymbol, const wxString& aNumber, const wxString& aAlt );
SCH_PIN( const SCH_PIN& aPin ); SCH_PIN( const SCH_PIN& aPin );
SCH_PIN& operator=( const SCH_PIN& aPin ); ~SCH_PIN() override { }
static inline bool ClassOf( const EDA_ITEM* aItem ) SCH_PIN& operator=( const SCH_PIN& aPin );
{
return aItem && SCH_PIN_T == aItem->Type();
}
wxString GetClass() const override wxString GetClass() const override
{ {
return wxT( "SCH_PIN" ); return wxT( "SCH_PIN" );
} }
LIB_PIN* GetLibPin() const { return m_libPin; } static bool ClassOf( const EDA_ITEM* aItem )
{
return aItem && aItem->Type() == SCH_PIN_T;
}
void ClearDefaultNetName( const SCH_SHEET_PATH* aPath ); wxString GetFriendlyName() const override
wxString GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoConnect = false ); {
return _( "Pin" );
}
SCH_PIN* GetLibPin() const { return m_libPin; }
void SetLibPin( SCH_PIN* aLibPin ) { m_libPin = aLibPin; }
PIN_ORIENTATION GetOrientation() const
{
if( m_libPin )
return m_libPin->GetOrientation();
return m_orientation;
}
void SetOrientation( PIN_ORIENTATION aOrientation ) { m_orientation = aOrientation; }
GRAPHIC_PINSHAPE GetShape() const
{
if( m_libPin )
{
if( !m_alt.IsEmpty() )
return m_libPin->GetAlt( m_alt ).m_Shape;
else
return m_libPin->GetShape();
}
return m_shape;
}
void SetShape( GRAPHIC_PINSHAPE aShape ) { m_shape = aShape; }
int GetLength() const
{
if( m_libPin )
return m_libPin->GetLength();
else
wxCHECK_MSG( m_length.has_value(), 0, wxS( "lib pin must have length defined!" ) );
return m_length.value();
}
void SetLength( int aLength ) { m_length = aLength; }
/**
* Change the length of a pin and adjust its position based on orientation.
*
* @param aLength New length of pin
*/
void ChangeLength( int aLength );
ELECTRICAL_PINTYPE GetType() const
{
if( m_libPin )
{
if( !m_alt.IsEmpty() )
return m_libPin->GetAlt( m_alt ).m_Type;
else
return m_libPin->GetType();
}
return m_type;
}
void SetType( ELECTRICAL_PINTYPE aType ) { m_type = aType; }
wxString GetCanonicalElectricalTypeName() const
{
if( m_libPin )
return m_libPin->GetCanonicalElectricalTypeName();
return GetCanonicalElectricalTypeName( m_type );
}
wxString GetElectricalTypeName() const
{
if( m_libPin )
return m_libPin->GetElectricalTypeName();
return ElectricalPinTypeGetText( m_type );
}
bool IsVisible() const
{
if( m_libPin )
return m_libPin->IsVisible();
return ( m_attributes & PIN_INVISIBLE ) == 0;
}
void SetVisible( bool aVisible )
{
if( aVisible )
m_attributes &= ~PIN_INVISIBLE;
else
m_attributes |= PIN_INVISIBLE;
}
const wxString& GetName() const
{
if( !m_alt.IsEmpty() )
return m_alt;
else if( m_libPin )
return m_libPin->GetName();
return m_name;
}
wxString GetShownName() const;
void SetName( const wxString& aName )
{
m_name = aName;
// pin name string does not support spaces
m_name.Replace( wxT( " " ), wxT( "_" ) );
m_nameExtentsCache.m_Extents = VECTOR2I();
}
const wxString& GetNumber() const { return m_number; }
wxString GetShownNumber() const;
void SetNumber( const wxString& aNumber )
{
m_number = aNumber;
// pin number string does not support spaces
m_number.Replace( wxT( " " ), wxT( "_" ) );
m_numExtentsCache.m_Extents = VECTOR2I();
}
int GetNameTextSize() const
{
if( m_libPin )
return m_libPin->GetNameTextSize();
else
wxCHECK_MSG( m_nameTextSize.has_value(), 0, wxS( "lib pin must have sizes defined!" ) );
return m_nameTextSize.value();
}
void SetNameTextSize( int aSize )
{
m_nameTextSize = aSize;
m_nameExtentsCache.m_Extents = VECTOR2I();
}
int GetNumberTextSize() const
{
if( m_libPin )
return m_libPin->GetNumberTextSize();
else
wxCHECK_MSG( m_numTextSize.has_value(), 0, wxS( "lib pin must have sizes defined!" ) );
return m_numTextSize.value();
}
void SetNumberTextSize( int aSize )
{
m_numTextSize = aSize;
m_numExtentsCache.m_Extents = VECTOR2I();
}
std::map<wxString, ALT>& GetAlternates()
{
if( m_libPin )
return m_libPin->GetAlternates();
return m_alternates;
}
ALT GetAlt( const wxString& aAlt )
{
return GetAlternates()[ aAlt ];
}
wxString GetAlt() const { return m_alt; } wxString GetAlt() const { return m_alt; }
void SetAlt( const wxString& aAlt ) { m_alt = aAlt; } void SetAlt( const wxString& aAlt ) { m_alt = aAlt; }
void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override;
/**
* Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT),
* according to its orientation and the matrix transform (rot, mirror) \a aTransform.
*
* @param aTransform Transform matrix
*/
PIN_ORIENTATION PinDrawOrient( const TRANSFORM& aTransform ) const;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override;
#endif
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
const BOX2I ViewBBox() const override; const BOX2I ViewBBox() const override;
void ViewGetLayers( int aLayers[], int& aCount ) const override; void ViewGetLayers( int aLayers[], int& aCount ) const override;
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override {}
void Move( const VECTOR2I& aMoveVector ) override {}
void MirrorHorizontally( int aCenter ) override {}
void MirrorVertically( int aCenter ) override {}
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override {}
VECTOR2I GetPosition() const override { return GetTransformedPosition(); }
const VECTOR2I GetLocalPosition() const { return m_position; }
void SetPosition( const VECTOR2I& aPosition ) override { m_position = aPosition; }
/* Cannot use a default parameter here as it will not be compatible with the virtual. */ /* Cannot use a default parameter here as it will not be compatible with the virtual. */
const BOX2I GetBoundingBox() const override { return GetBoundingBox( false, true, false ); } const BOX2I GetBoundingBox() const override
{
return GetBoundingBox( false, true, m_layer == LAYER_DEVICE );
}
/** /**
* @param aIncludeInvisibles - if false, do not include labels for invisible pins * @param aIncludeLabelsOnInvisiblePins - if false, do not include labels for invisible pins
* in the calculation. * in the calculation.
*/ */
const BOX2I GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber, const BOX2I GetBoundingBox( bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber,
bool aIncludeElectricalType ) const; bool aIncludeElectricalType ) const;
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; /**
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override; * Return whether this pin forms a global power connection: i.e., is part of a power symbol
* and of type POWER_IN, or is a legacy invisible global power pin on a symbol.
*/
bool IsGlobalPower() const
{
return GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN
&& ( !IsVisible() || GetParentSymbol()->IsPower() );
}
int GetPenWidth() const override { return 0; }
void Move( const VECTOR2I& aOffset ) override;
VECTOR2I GetPosition() const override;
VECTOR2I GetLocalPosition() const { return m_position; }
void SetPosition( const VECTOR2I& aPos ) override { m_position = aPos; }
// For properties system
int GetX() const { return m_position.x; }
void SetX( int aX ) { m_position.x = aX; }
int GetY() const { return m_position.y; }
void SetY( int aY ) { m_position.y = aY; }
VECTOR2I GetPinRoot() const;
void MirrorHorizontally( int aCenter ) override;
void MirrorVertically( int aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
/**
* Plot the pin name and number.
* @param aTextInside - draw the names & numbers inside the symbol body (ie: in the opposite
* direction of \a aPinOrient).
*/
void PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient,
int aTextInside, bool aDrawPinNum, bool aDrawPinName, bool aDimmed ) const;
void PlotPinType( PLOTTER *aPlotter, const VECTOR2I &aPosition, PIN_ORIENTATION aOrientation,
bool aDimmed ) const;
void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
BITMAPS GetMenuImage() const override;
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, ALT* aAlt ) const;
EDA_ITEM* Clone() const override; EDA_ITEM* Clone() const override;
void CalcEdit( const VECTOR2I& aPosition ) override;
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
/**
* Return a string giving the electrical type of a pin.
*
* Can be used when a known, not translated name is needed (for instance in net lists)
*
* @param aType is the electrical type (see enum ELECTRICAL_PINTYPE )
* @return The electrical name for a pin type (see enun MsgPinElectricType for names).
*/
static const wxString GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType );
bool IsConnectable() const override { return true; } bool IsConnectable() const override { return true; }
bool HasConnectivityChanges( const SCH_ITEM* aItem, bool HasConnectivityChanges( const SCH_ITEM* aItem,
const SCH_SHEET_PATH* aInstance = nullptr ) const override; const SCH_SHEET_PATH* aInstance = nullptr ) const override;
void ClearDefaultNetName( const SCH_SHEET_PATH* aPath );
wxString GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoConnect = false );
bool IsDangling() const override bool IsDangling() const override
{ {
if( GetType() == ELECTRICAL_PINTYPE::PT_NC || GetType() == ELECTRICAL_PINTYPE::PT_NIC ) if( GetType() == ELECTRICAL_PINTYPE::PT_NC || GetType() == ELECTRICAL_PINTYPE::PT_NIC )
@ -112,8 +377,6 @@ public:
void SetIsDangling( bool isDangling ) { m_isDangling = isDangling; } void SetIsDangling( bool isDangling ) { m_isDangling = isDangling; }
void SetLibPin( LIB_PIN* aLibPin ) { m_libPin = aLibPin; }
/** /**
* @param aPin Comparison Pin * @param aPin Comparison Pin
* @return True if aPin is stacked with this pin * @return True if aPin is stacked with this pin
@ -125,42 +388,6 @@ public:
return m_isDangling && GetPosition() == aPos; return m_isDangling && GetPosition() == aPos;
} }
/// @return the pin's position in global coordinates.
VECTOR2I GetTransformedPosition() const;
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
/*
* While many of these are currently simply covers for the equivalent LIB_PIN methods,
* the new Eeschema file format will soon allow us to override them at the schematic level.
*/
bool IsVisible() const;
wxString GetName() const;
wxString GetShownName() const;
wxString GetNumber() const { return m_number; }
wxString GetShownNumber() const;
void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
ELECTRICAL_PINTYPE GetType() const;
wxString GetCanonicalElectricalTypeName() const
{
return LIB_PIN::GetCanonicalElectricalTypeName( GetType() );
}
GRAPHIC_PINSHAPE GetShape() const;
PIN_ORIENTATION GetOrientation() const;
int GetLength() const;
bool IsGlobalPower() const;
bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override; bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
const wxString& GetOperatingPoint() const { return m_operatingPoint; } const wxString& GetOperatingPoint() const { return m_operatingPoint; }
@ -169,27 +396,91 @@ public:
double Similarity( const SCH_ITEM& aItem ) const override; double Similarity( const SCH_ITEM& aItem ) const override;
bool operator==( const SCH_ITEM& aItem ) const override; bool operator==( const SCH_ITEM& aItem ) const override;
bool operator==( const SCH_PIN& aItem ) const; bool operator!=( const SCH_ITEM& aItem ) const { return !operator==( aItem ); }
bool operator<( const SCH_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) < 0; }
bool operator>( const SCH_PIN& aRhs ) const { return compare( aRhs, EQUALITY ) > 0; }
bool operator!=( const SCH_PIN& aRhs ) const { return !( *this == aRhs ); } protected:
wxString getItemDescription( ALT* aAlt ) const;
#if defined(DEBUG) struct EXTENTS_CACHE
void Show( int nestLevel, std::ostream& os ) const override {} {
#endif KIFONT::FONT* m_Font = nullptr;
int m_FontSize = 0;
VECTOR2I m_Extents;
};
void validateExtentsCache( KIFONT::FONT* aFont, int aSize, const wxString& aText,
EXTENTS_CACHE* aCache ) const;
/**
* Print the pin symbol without text.
* If \a aColor != 0, draw with \a aColor, else with the normal pin color.
*/
void printPinSymbol( const SCH_RENDER_SETTINGS *aSettings, const VECTOR2I &aPos,
PIN_ORIENTATION aOrientation, bool aDimmed );
/**
* Put the pin number and pin text info, given the pin line coordinates.
* The line must be vertical or horizontal.
* If aDrawPinName == false the pin name is not printed.
* If aDrawPinNum = false the pin number is not printed.
* If aTextInside then the text is been put inside,otherwise all is drawn outside.
* Pin Name: substring between '~' is negated
*/
void printPinTexts( const RENDER_SETTINGS* aSettings, const VECTOR2I& aPinPos,
PIN_ORIENTATION aPinOrient, int aTextInside, bool aDrawPinNum,
bool aDrawPinName, bool aDimmed );
/**
* Draw the electrical type text of the pin (only for the footprint editor)
*/
void printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, const VECTOR2I& aPosition,
PIN_ORIENTATION aOrientation, bool aDimmed );
std::ostream& operator<<( std::ostream& aStream );
private: private:
LIB_PIN* m_libPin; /**
* @copydoc SCH_ITEM::compare()
*
* The pin specific sort order is as follows:
* - Pin number.
* - Pin name, case insensitive compare.
* - Pin horizontal (X) position.
* - Pin vertical (Y) position.
*/
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
wxString m_number; protected:
wxString m_alt; SCH_PIN* m_libPin; // The corresponding pin in the LIB_SYMBOL
VECTOR2I m_position; // (nullptr for a pin *in* the LIB_SYMBOL)
bool m_isDangling;
std::map<wxString, ALT> m_alternates; // Map of alternate name to ALT structure
// (only valid for pins in LIB_SYMBOLS)
VECTOR2I m_position; // Position of the pin.
std::optional<int> m_length; // Length of the pin.
PIN_ORIENTATION m_orientation; // Pin orientation (Up, Down, Left, Right)
GRAPHIC_PINSHAPE m_shape; // Shape drawn around pin
ELECTRICAL_PINTYPE m_type; // Electrical type of the pin.
int m_attributes; // Set bit 0 to indicate pin is invisible.
wxString m_name;
wxString m_number;
std::optional<int> m_numTextSize; // Pin num and Pin name sizes
std::optional<int> m_nameTextSize;
wxString m_alt; // The current alternate for an instance
wxString m_operatingPoint;
mutable EXTENTS_CACHE m_numExtentsCache;
mutable EXTENTS_CACHE m_nameExtentsCache;
bool m_isDangling;
/// The name that this pin connection will drive onto a net. /// The name that this pin connection will drive onto a net.
std::recursive_mutex m_netmap_mutex; std::recursive_mutex m_netmap_mutex;
std::map<const SCH_SHEET_PATH, std::pair<wxString, bool>> m_net_name_map; std::map<const SCH_SHEET_PATH, std::pair<wxString, bool>> m_net_name_map;
wxString m_operatingPoint;
}; };
#endif
#endif // SCH_PIN_H

View File

@ -42,7 +42,7 @@
#include <symbol_library.h> #include <symbol_library.h>
#include <connection_graph.h> #include <connection_graph.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <sch_symbol.h> #include <sch_symbol.h>
#include <sch_junction.h> #include <sch_junction.h>
#include <sch_line.h> #include <sch_line.h>
@ -1220,11 +1220,11 @@ void SCH_SCREEN::ClearDrawingState()
} }
LIB_PIN* SCH_SCREEN::GetPin( const VECTOR2I& aPosition, SCH_SYMBOL** aSymbol, SCH_PIN* SCH_SCREEN::GetPin( const VECTOR2I& aPosition, SCH_SYMBOL** aSymbol,
bool aEndPointOnly ) const bool aEndPointOnly ) const
{ {
SCH_SYMBOL* candidate = nullptr; SCH_SYMBOL* candidate = nullptr;
LIB_PIN* pin = nullptr; SCH_PIN* pin = nullptr;
for( SCH_ITEM* item : Items().Overlapping( SCH_SYMBOL_T, aPosition ) ) for( SCH_ITEM* item : Items().Overlapping( SCH_SYMBOL_T, aPosition ) )
{ {
@ -1237,10 +1237,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const VECTOR2I& aPosition, SCH_SYMBOL** aSymbol,
if( !candidate->GetLibSymbolRef() ) if( !candidate->GetLibSymbolRef() )
continue; continue;
std::vector<LIB_PIN*> pins; for( SCH_PIN* test_pin : candidate->GetLibPins() )
candidate->GetLibPins( pins );
for( LIB_PIN* test_pin : pins )
{ {
if( candidate->GetPinPhysicalPosition( test_pin ) == aPosition ) if( candidate->GetPinPhysicalPosition( test_pin ) == aPosition )
{ {
@ -1254,7 +1251,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const VECTOR2I& aPosition, SCH_SYMBOL** aSymbol,
} }
else else
{ {
pin = (LIB_PIN*) candidate->GetDrawItem( aPosition, LIB_PIN_T ); pin = static_cast<SCH_PIN*>( candidate->GetDrawItem( aPosition, SCH_PIN_T ) );
if( pin ) if( pin )
break; break;

View File

@ -55,7 +55,7 @@
class BUS_ALIAS; class BUS_ALIAS;
class EDA_ITEM; class EDA_ITEM;
class LIB_SYMBOL; class LIB_SYMBOL;
class LIB_PIN; class SCH_PIN;
class SCH_SYMBOL; class SCH_SYMBOL;
class SCH_LINE; class SCH_LINE;
class SCH_LABEL_BASE; class SCH_LABEL_BASE;
@ -368,7 +368,7 @@ public:
* point of the pin. * point of the pin.
* @return The pin item if found, otherwise NULL. * @return The pin item if found, otherwise NULL.
*/ */
LIB_PIN* GetPin( const VECTOR2I& aPosition, SCH_SYMBOL** aSymbol = nullptr, SCH_PIN* GetPin( const VECTOR2I& aPosition, SCH_SYMBOL** aSymbol = nullptr,
bool aEndPointOnly = false ) const; bool aEndPointOnly = false ) const;
/** /**

View File

@ -26,7 +26,7 @@
#include <widgets/msgpanel.h> #include <widgets/msgpanel.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <core/mirror.h> #include <core/mirror.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <sch_shape.h> #include <sch_shape.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <sch_symbol.h> #include <sch_symbol.h>
@ -312,7 +312,7 @@ void SCH_SYMBOL::UpdatePins()
std::map<wxString, wxString> altPinMap; std::map<wxString, wxString> altPinMap;
std::map<wxString, std::set<SCH_PIN*>> pinUuidMap; std::map<wxString, std::set<SCH_PIN*>> pinUuidMap;
std::set<SCH_PIN*> unassignedSchPins; std::set<SCH_PIN*> unassignedSchPins;
std::set<LIB_PIN*> unassignedLibPins; std::set<SCH_PIN*> unassignedLibPins;
for( const std::unique_ptr<SCH_PIN>& pin : m_pins ) for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
{ {
@ -331,9 +331,7 @@ void SCH_SYMBOL::UpdatePins()
if( !m_part ) if( !m_part )
return; return;
std::vector<LIB_PIN*> pins = m_part->GetAllLibPins(); for( SCH_PIN* libPin : m_part->GetAllLibPins() )
for( LIB_PIN* libPin : pins )
{ {
// NW: Don't filter by unit: this data-structure is used for all instances, // NW: Don't filter by unit: this data-structure is used for all instances,
// some of which might have different units. // some of which might have different units.
@ -367,7 +365,7 @@ void SCH_SYMBOL::UpdatePins()
} }
// Add any pins that were not found in the symbol // Add any pins that were not found in the symbol
for( LIB_PIN* libPin : unassignedLibPins ) for( SCH_PIN* libPin : unassignedLibPins )
{ {
SCH_PIN* pin = nullptr; SCH_PIN* pin = nullptr;
@ -503,18 +501,15 @@ void SCH_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBo
if( m_part ) if( m_part )
{ {
std::vector<LIB_PIN*> libPins; std::vector<SCH_PIN*> libPins = m_part->GetPins( m_unit, m_bodyStyle );
m_part->GetPins( libPins, m_unit, m_bodyStyle ); LIB_SYMBOL tempSymbol( *m_part );
std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( m_unit, m_bodyStyle );
LIB_SYMBOL tempSymbol( *m_part );
std::vector<LIB_PIN*> tempPins;
tempSymbol.GetPins( tempPins, m_unit, m_bodyStyle );
// Copy the pin info from the symbol to the temp pins // Copy the pin info from the symbol to the temp pins
for( unsigned i = 0; i < tempPins.size(); ++ i ) for( unsigned i = 0; i < tempPins.size(); ++ i )
{ {
SCH_PIN* symbolPin = GetPin( libPins[ i ] ); SCH_PIN* symbolPin = GetPin( libPins[ i ] );
LIB_PIN* tempPin = tempPins[ i ]; SCH_PIN* tempPin = tempPins[ i ];
tempPin->SetName( symbolPin->GetShownName() ); tempPin->SetName( symbolPin->GetShownName() );
tempPin->SetType( symbolPin->GetType() ); tempPin->SetType( symbolPin->GetType() );
@ -1108,25 +1103,25 @@ SCH_PIN* SCH_SYMBOL::GetPin( const wxString& aNumber ) const
} }
void SCH_SYMBOL::GetLibPins( std::vector<LIB_PIN*>& aPinsList ) const std::vector<SCH_PIN*> SCH_SYMBOL::GetLibPins() const
{ {
if( m_part ) if( m_part )
m_part->GetPins( aPinsList, m_unit, m_bodyStyle ); return m_part->GetPins( m_unit, m_bodyStyle );
return std::vector<SCH_PIN*>();
} }
std::vector<LIB_PIN*> SCH_SYMBOL::GetAllLibPins() const std::vector<SCH_PIN*> SCH_SYMBOL::GetAllLibPins() const
{ {
std::vector<LIB_PIN*> pinList;
if( m_part ) if( m_part )
m_part->GetPins( pinList, 0, 0 ); return m_part->GetAllLibPins();
return pinList; return std::vector<SCH_PIN*>();
} }
SCH_PIN* SCH_SYMBOL::GetPin( LIB_PIN* aLibPin ) const SCH_PIN* SCH_SYMBOL::GetPin( SCH_PIN* aLibPin ) const
{ {
auto it = m_pinMap.find( aLibPin ); auto it = m_pinMap.find( aLibPin );
@ -2045,7 +2040,7 @@ void SCH_SYMBOL::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{ {
for( std::unique_ptr<SCH_PIN>& pin : m_pins ) for( std::unique_ptr<SCH_PIN>& pin : m_pins )
{ {
LIB_PIN* lib_pin = pin->GetLibPin(); SCH_PIN* lib_pin = pin->GetLibPin();
if( lib_pin && lib_pin->GetUnit() && m_unit && ( m_unit != lib_pin->GetUnit() ) ) if( lib_pin && lib_pin->GetUnit() && m_unit && ( m_unit != lib_pin->GetUnit() ) )
continue; continue;
@ -2109,9 +2104,9 @@ bool SCH_SYMBOL::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListB
} }
VECTOR2I SCH_SYMBOL::GetPinPhysicalPosition( const LIB_PIN* Pin ) const VECTOR2I SCH_SYMBOL::GetPinPhysicalPosition( const SCH_PIN* Pin ) const
{ {
wxCHECK_MSG( Pin != nullptr && Pin->Type() == LIB_PIN_T, VECTOR2I( 0, 0 ), wxCHECK_MSG( Pin != nullptr && Pin->Type() == SCH_PIN_T, VECTOR2I( 0, 0 ),
wxT( "Cannot get physical position of pin." ) ); wxT( "Cannot get physical position of pin." ) );
return m_transform.TransformCoordinate( Pin->GetPosition() ) + m_pos; return m_transform.TransformCoordinate( Pin->GetPosition() ) + m_pos;
@ -2429,19 +2424,17 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS&
if( m_part ) if( m_part )
{ {
std::vector<LIB_PIN*> libPins; std::vector<SCH_PIN*> libPins = m_part->GetPins( GetUnit(), GetBodyStyle() );
m_part->GetPins( libPins, GetUnit(), GetBodyStyle() );
// Copy the source so we can re-orient and translate it. // Copy the source so we can re-orient and translate it.
LIB_SYMBOL tempSymbol( *m_part ); LIB_SYMBOL tempSymbol( *m_part );
std::vector<LIB_PIN*> tempPins; std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( GetUnit(), GetBodyStyle() );
tempSymbol.GetPins( tempPins, GetUnit(), GetBodyStyle() );
// Copy the pin info from the symbol to the temp pins // Copy the pin info from the symbol to the temp pins
for( unsigned i = 0; i < tempPins.size(); ++ i ) for( unsigned i = 0; i < tempPins.size(); ++ i )
{ {
SCH_PIN* symbolPin = GetPin( libPins[ i ] ); SCH_PIN* symbolPin = GetPin( libPins[ i ] );
LIB_PIN* tempPin = tempPins[ i ]; SCH_PIN* tempPin = tempPins[ i ];
tempPin->SetName( symbolPin->GetShownName() ); tempPin->SetName( symbolPin->GetShownName() );
tempPin->SetType( symbolPin->GetType() ); tempPin->SetType( symbolPin->GetType() );
@ -2544,21 +2537,18 @@ void SCH_SYMBOL::PlotPins( PLOTTER* aPlotter ) const
TRANSFORM savedTransform = renderSettings->m_Transform; TRANSFORM savedTransform = renderSettings->m_Transform;
renderSettings->m_Transform = GetTransform(); renderSettings->m_Transform = GetTransform();
std::vector<LIB_PIN*> libPins; std::vector<SCH_PIN*> libPins = m_part->GetPins( GetUnit(), GetBodyStyle() );
m_part->GetPins( libPins, GetUnit(), GetBodyStyle() );
// Copy the source to stay const // Copy the source to stay const
LIB_SYMBOL tempSymbol( *m_part ); LIB_SYMBOL tempSymbol( *m_part );
std::vector<LIB_PIN*> tempPins; std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( GetUnit(), GetBodyStyle() );
tempSymbol.GetPins( tempPins, GetUnit(), GetBodyStyle() ); SCH_PLOT_OPTS plotOpts;
SCH_PLOT_OPTS plotOpts;
// Copy the pin info from the symbol to the temp pins // Copy the pin info from the symbol to the temp pins
for( unsigned i = 0; i < tempPins.size(); ++ i ) for( unsigned i = 0; i < tempPins.size(); ++ i )
{ {
SCH_PIN* symbolPin = GetPin( libPins[ i ] ); SCH_PIN* symbolPin = GetPin( libPins[ i ] );
LIB_PIN* tempPin = tempPins[ i ]; SCH_PIN* tempPin = tempPins[ i ];
tempPin->SetName( symbolPin->GetShownName() ); tempPin->SetName( symbolPin->GetShownName() );
tempPin->SetType( symbolPin->GetType() ); tempPin->SetType( symbolPin->GetType() );
@ -2622,7 +2612,7 @@ bool SCH_SYMBOL::IsSymbolLikePowerGlobalLabel() const
if( !GetLibSymbolRef() || !GetLibSymbolRef()->IsPower() ) if( !GetLibSymbolRef() || !GetLibSymbolRef()->IsPower() )
return false; return false;
std::vector<LIB_PIN*> pin_list = GetAllLibPins(); std::vector<SCH_PIN*> pin_list = GetAllLibPins();
if( pin_list.size() != 1 ) if( pin_list.size() != 1 )
return false; return false;

View File

@ -46,6 +46,7 @@
#include <schematic.h> #include <schematic.h>
#include <symbol.h> #include <symbol.h>
#include <lib_symbol.h>
#include <sch_field.h> #include <sch_field.h>
#include <sch_pin.h> #include <sch_pin.h>
#include <sch_sheet_path.h> // SCH_SYMBOL_INSTANCE #include <sch_sheet_path.h> // SCH_SYMBOL_INSTANCE
@ -55,7 +56,6 @@
struct PICKED_SYMBOL; struct PICKED_SYMBOL;
class KIID_PATH; class KIID_PATH;
class SCH_SCREEN; class SCH_SCREEN;
class LIB_PIN;
class LIB_SYMBOL; class LIB_SYMBOL;
class NETLIST_OBJECT_LIST; class NETLIST_OBJECT_LIST;
class SYMBOL_LIB; class SYMBOL_LIB;
@ -596,17 +596,18 @@ public:
SCH_PIN* GetPin( const wxString& number ) const; SCH_PIN* GetPin( const wxString& number ) const;
/** /**
* Populate a vector with all the pins from the library object. * Populate a vector with all the pins from the library object that match the current unit
* and bodyStyle.
* *
* @param aPinsList is the list to populate with all of the pins. * @param aPinsList is the list to populate with all of the pins.
*/ */
void GetLibPins( std::vector<LIB_PIN*>& aPinsList ) const; std::vector<SCH_PIN*> GetLibPins() const;
/** /**
* @return a list of pin pointers for all units / converts. Used primarily for SPICE where * @return a list of pin pointers for all units / bodyStyles. Used primarily for SPICE where
* we want to treat all units together as a single SPICE element. * we want to treat all units together as a single SPICE element.
*/ */
std::vector<LIB_PIN*> GetAllLibPins() const; std::vector<SCH_PIN*> GetAllLibPins() const;
/** /**
* @return a count of pins for all units. * @return a count of pins for all units.
@ -614,9 +615,9 @@ public:
size_t GetFullPinCount() { return m_part ? m_part->GetPinCount() : 0; } size_t GetFullPinCount() { return m_part ? m_part->GetPinCount() : 0; }
/** /**
* @return the SCH_PIN associated with a particular LIB_PIN. * @return the instance SCH_PIN associated with a particular SCH_PIN from the LIB_SYMBOL.
*/ */
SCH_PIN* GetPin( LIB_PIN* aLibPin ) const; SCH_PIN* GetPin( SCH_PIN* aLibPin ) const;
/** /**
* Retrieve a list of the SCH_PINs for the given sheet path. * Retrieve a list of the SCH_PINs for the given sheet path.
@ -718,7 +719,7 @@ public:
std::vector<DANGLING_END_ITEM>& aItemListByPos, std::vector<DANGLING_END_ITEM>& aItemListByPos,
const SCH_SHEET_PATH* aPath = nullptr ) override; const SCH_SHEET_PATH* aPath = nullptr ) override;
VECTOR2I GetPinPhysicalPosition( const LIB_PIN* Pin ) const; VECTOR2I GetPinPhysicalPosition( const SCH_PIN* Pin ) const;
bool IsConnectable() const override { return true; } bool IsConnectable() const override { return true; }
@ -843,6 +844,12 @@ public:
bool IsPower() const override; bool IsPower() const override;
bool IsNormal() const override; bool IsNormal() const override;
/*
* We don't currently support changing these at the schematic level.
*/
bool GetShowPinNames() const override { return m_part && m_part->GetShowPinNames(); }
bool GetShowPinNumbers() const override { return m_part && m_part->GetShowPinNumbers(); }
double Similarity( const SCH_ITEM& aOther ) const override; double Similarity( const SCH_ITEM& aOther ) const override;
bool operator==( const SCH_ITEM& aOther ) const override; bool operator==( const SCH_ITEM& aOther ) const override;
@ -854,6 +861,7 @@ private:
void Init( const VECTOR2I& pos = VECTOR2I( 0, 0 ) ); void Init( const VECTOR2I& pos = VECTOR2I( 0, 0 ) );
private:
VECTOR2I m_pos; VECTOR2I m_pos;
LIB_ID m_lib_id; ///< Name and library the symbol was loaded from, i.e. 74xx:74LS00. LIB_ID m_lib_id; ///< Name and library the symbol was loaded from, i.e. 74xx:74LS00.
wxString m_prefix; ///< C, R, U, Q etc - the first character(s) which typically wxString m_prefix; ///< C, R, U, Q etc - the first character(s) which typically
@ -877,8 +885,8 @@ private:
///< PROJECT's libraries. ///< PROJECT's libraries.
bool m_isInNetlist; ///< True if the symbol should appear in netlist bool m_isInNetlist; ///< True if the symbol should appear in netlist
std::vector<std::unique_ptr<SCH_PIN>> m_pins; ///< a SCH_PIN for every LIB_PIN (all units) std::vector<std::unique_ptr<SCH_PIN>> m_pins; ///< a SCH_PIN for every SCH_PIN (all units)
std::unordered_map<LIB_PIN*, SCH_PIN*> m_pinMap; ///< library pin pointer : SCH_PIN's index std::unordered_map<SCH_PIN*, SCH_PIN*> m_pinMap; ///< library pin pointer : SCH_PIN's index
// Defines the hierarchical path and reference of the symbol. This allows support for multiple // Defines the hierarchical path and reference of the symbol. This allows support for multiple
// references to a single sub-sheet. // references to a single sub-sheet.

View File

@ -34,7 +34,7 @@
class SCH_SHEET; class SCH_SHEET;
class SCH_SCREEN; class SCH_SCREEN;
class LIB_SYMBOL; class LIB_SYMBOL;
class LIB_PIN; class SCH_PIN;
class SCH_BASE_FRAME; class SCH_BASE_FRAME;
class DS_PROXY_VIEW_ITEM; class DS_PROXY_VIEW_ITEM;

View File

@ -153,7 +153,7 @@ void SIM_LIB_MGR::SetLibrary( const wxString& aLibraryPath, REPORTER& aReporter
} }
SIM_MODEL& SIM_LIB_MGR::CreateModel( SIM_MODEL::TYPE aType, const std::vector<LIB_PIN*>& aPins, SIM_MODEL& SIM_LIB_MGR::CreateModel( SIM_MODEL::TYPE aType, const std::vector<SCH_PIN*>& aPins,
REPORTER& aReporter ) REPORTER& aReporter )
{ {
m_models.push_back( SIM_MODEL::Create( aType, aPins, aReporter ) ); m_models.push_back( SIM_MODEL::Create( aType, aPins, aReporter ) );
@ -162,7 +162,7 @@ SIM_MODEL& SIM_LIB_MGR::CreateModel( SIM_MODEL::TYPE aType, const std::vector<LI
SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel, SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel,
const std::vector<LIB_PIN*>& aPins, REPORTER& aReporter ) const std::vector<SCH_PIN*>& aPins, REPORTER& aReporter )
{ {
m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, aReporter ) ); m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, aReporter ) );
return *m_models.back(); return *m_models.back();
@ -170,7 +170,7 @@ SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel,
SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel, SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel,
const std::vector<LIB_PIN*>& aPins, const std::vector<SCH_PIN*>& aPins,
const std::vector<SCH_FIELD>& aFields, REPORTER& aReporter ) const std::vector<SCH_FIELD>& aFields, REPORTER& aReporter )
{ {
m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, aFields, aReporter ) ); m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, aFields, aReporter ) );
@ -232,10 +232,10 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
storeInValue = true; storeInValue = true;
} }
std::vector<LIB_PIN*> sourcePins = aSymbol.GetAllLibPins(); std::vector<SCH_PIN*> sourcePins = aSymbol.GetAllLibPins();
std::sort( sourcePins.begin(), sourcePins.end(), std::sort( sourcePins.begin(), sourcePins.end(),
[]( const LIB_PIN* lhs, const LIB_PIN* rhs ) []( const SCH_PIN* lhs, const SCH_PIN* rhs )
{ {
return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0; return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0;
} ); } );
@ -249,7 +249,7 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<SCH_FIELD>& aFields, SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<SCH_FIELD>& aFields,
const std::vector<LIB_PIN*>& aPins, bool aResolved, const std::vector<SCH_PIN*>& aPins, bool aResolved,
REPORTER& aReporter ) REPORTER& aReporter )
{ {
std::string libraryPath = SIM_MODEL::GetFieldValue( &aFields, SIM_LIBRARY::LIBRARY_FIELD ); std::string libraryPath = SIM_MODEL::GetFieldValue( &aFields, SIM_LIBRARY::LIBRARY_FIELD );
@ -270,7 +270,7 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<SCH_FIELD>& aFiel
SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const wxString& aLibraryPath, SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const wxString& aLibraryPath,
const std::string& aBaseModelName, const std::string& aBaseModelName,
const std::vector<SCH_FIELD>& aFields, const std::vector<SCH_FIELD>& aFields,
const std::vector<LIB_PIN*>& aPins, const std::vector<SCH_PIN*>& aPins,
REPORTER& aReporter ) REPORTER& aReporter )
{ {
wxString path; wxString path;

View File

@ -47,13 +47,13 @@ public:
void SetLibrary( const wxString& aLibraryPath, REPORTER& aReporter ); void SetLibrary( const wxString& aLibraryPath, REPORTER& aReporter );
SIM_MODEL& CreateModel( SIM_MODEL::TYPE aType, const std::vector<LIB_PIN*>& aPins, SIM_MODEL& CreateModel( SIM_MODEL::TYPE aType, const std::vector<SCH_PIN*>& aPins,
REPORTER& aReporter ); REPORTER& aReporter );
SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<LIB_PIN*>& aPins, SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<SCH_PIN*>& aPins,
REPORTER& aReporter ); REPORTER& aReporter );
SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<LIB_PIN*>& aPins, SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<SCH_PIN*>& aPins,
const std::vector<SCH_FIELD>& aFields, REPORTER& aReporter ); const std::vector<SCH_FIELD>& aFields, REPORTER& aReporter );
// TODO: The argument can be made const. // TODO: The argument can be made const.
@ -61,13 +61,13 @@ public:
REPORTER& aReporter ); REPORTER& aReporter );
SIM_LIBRARY::MODEL CreateModel( const std::vector<SCH_FIELD>& aFields, SIM_LIBRARY::MODEL CreateModel( const std::vector<SCH_FIELD>& aFields,
const std::vector<LIB_PIN*>& aPins, bool aResolved, const std::vector<SCH_PIN*>& aPins, bool aResolved,
REPORTER& aReporter ); REPORTER& aReporter );
SIM_LIBRARY::MODEL CreateModel( const wxString& aLibraryPath, SIM_LIBRARY::MODEL CreateModel( const wxString& aLibraryPath,
const std::string& aBaseModelName, const std::string& aBaseModelName,
const std::vector<SCH_FIELD>& aFields, const std::vector<SCH_FIELD>& aFields,
const std::vector<LIB_PIN*>& aPins, REPORTER& aReporter ); const std::vector<SCH_PIN*>& aPins, REPORTER& aReporter );
void SetModel( int aIndex, std::unique_ptr<SIM_MODEL> aModel ); void SetModel( int aIndex, std::unique_ptr<SIM_MODEL> aModel );

View File

@ -26,7 +26,7 @@
#include <ki_exception.h> #include <ki_exception.h>
#include <locale_io.h> #include <locale_io.h>
#include <pegtl/contrib/parse_tree.hpp> #include <pegtl/contrib/parse_tree.hpp>
#include <lib_pin.h> #include <sch_pin.h>
void SIM_LIBRARY_KIBIS::ReadFile( const wxString& aFilePath, REPORTER& aReporter ) void SIM_LIBRARY_KIBIS::ReadFile( const wxString& aFilePath, REPORTER& aReporter )
@ -41,11 +41,11 @@ void SIM_LIBRARY_KIBIS::ReadFile( const wxString& aFilePath, REPORTER& aReporter
return; return;
} }
LIB_PIN pinA( nullptr ); SCH_PIN pinA( nullptr );
LIB_PIN pinB( nullptr ); SCH_PIN pinB( nullptr );
pinA.SetNumber( wxT( "1" ) ); pinA.SetNumber( wxT( "1" ) );
pinB.SetNumber( wxT( "2" ) ); pinB.SetNumber( wxT( "2" ) );
std::vector<LIB_PIN*> pins = { &pinA, &pinB }; std::vector<SCH_PIN*> pins = { &pinA, &pinB };
for( KIBIS_COMPONENT& kcomp : m_kibis.m_components ) for( KIBIS_COMPONENT& kcomp : m_kibis.m_components )
{ {

View File

@ -421,7 +421,7 @@ TYPE SIM_MODEL::ReadTypeFromFields( const std::vector<SCH_FIELD>& aFields, REPOR
void SIM_MODEL::ReadDataFields( const std::vector<SCH_FIELD>* aFields, void SIM_MODEL::ReadDataFields( const std::vector<SCH_FIELD>* aFields,
const std::vector<LIB_PIN*>& aPins ) const std::vector<SCH_PIN*>& aPins )
{ {
bool diffMode = GetFieldValue( aFields, SIM_LIBRARY_KIBIS::DIFF_FIELD ) == "1"; bool diffMode = GetFieldValue( aFields, SIM_LIBRARY_KIBIS::DIFF_FIELD ) == "1";
SwitchSingleEndedDiff( diffMode ); SwitchSingleEndedDiff( diffMode );
@ -489,7 +489,7 @@ void SIM_MODEL::WriteFields( std::vector<SCH_FIELD>& aFields ) const
} }
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType, const std::vector<LIB_PIN*>& aPins, std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType, const std::vector<SCH_PIN*>& aPins,
REPORTER& aReporter ) REPORTER& aReporter )
{ {
std::unique_ptr<SIM_MODEL> model = Create( aType ); std::unique_ptr<SIM_MODEL> model = Create( aType );
@ -509,7 +509,7 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( TYPE aType, const std::vector<LIB_
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel, std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
const std::vector<LIB_PIN*>& aPins, const std::vector<SCH_PIN*>& aPins,
REPORTER& aReporter ) REPORTER& aReporter )
{ {
std::unique_ptr<SIM_MODEL> model; std::unique_ptr<SIM_MODEL> model;
@ -546,7 +546,7 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel, std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
const std::vector<LIB_PIN*>& aPins, const std::vector<SCH_PIN*>& aPins,
const std::vector<SCH_FIELD>& aFields, const std::vector<SCH_FIELD>& aFields,
REPORTER& aReporter ) REPORTER& aReporter )
{ {
@ -594,7 +594,7 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const std::vector<SCH_FIELD>& aFields, std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const std::vector<SCH_FIELD>& aFields,
const std::vector<LIB_PIN*>& aPins, const std::vector<SCH_PIN*>& aPins,
bool aResolved, REPORTER& aReporter ) bool aResolved, REPORTER& aReporter )
{ {
TYPE type = ReadTypeFromFields( aFields, aReporter ); TYPE type = ReadTypeFromFields( aFields, aReporter );
@ -980,7 +980,7 @@ SIM_MODEL::SIM_MODEL( TYPE aType, std::unique_ptr<SPICE_GENERATOR> aSpiceGenerat
} }
void SIM_MODEL::createPins( const std::vector<LIB_PIN*>& aSymbolPins ) void SIM_MODEL::createPins( const std::vector<SCH_PIN*>& aSymbolPins )
{ {
// Default pin sequence: model pins are the same as symbol pins. // Default pin sequence: model pins are the same as symbol pins.
// Excess model pins are set as Not Connected. // Excess model pins are set as Not Connected.
@ -1225,7 +1225,7 @@ bool SIM_MODEL::InferSimModel( T& aSymbol, std::vector<SCH_FIELD>* aFields, bool
wxString library = GetFieldValue( aFields, SIM_LIBRARY_FIELD, aResolve ); wxString library = GetFieldValue( aFields, SIM_LIBRARY_FIELD, aResolve );
wxString modelName = GetFieldValue( aFields, SIM_NAME_FIELD, aResolve ); wxString modelName = GetFieldValue( aFields, SIM_NAME_FIELD, aResolve );
wxString value = GetFieldValue( aFields, SIM_VALUE_FIELD, aResolve ); wxString value = GetFieldValue( aFields, SIM_VALUE_FIELD, aResolve );
std::vector<LIB_PIN*> pins = aSymbol.GetAllLibPins(); std::vector<SCH_PIN*> pins = aSymbol.GetAllLibPins();
*aDeviceType = GetFieldValue( aFields, SIM_DEVICE_FIELD, aResolve ); *aDeviceType = GetFieldValue( aFields, SIM_DEVICE_FIELD, aResolve );
*aModelType = GetFieldValue( aFields, SIM_DEVICE_SUBTYPE_FIELD, aResolve ); *aModelType = GetFieldValue( aFields, SIM_DEVICE_SUBTYPE_FIELD, aResolve );
@ -1527,7 +1527,7 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
}; };
auto generateDefaultPinMapFromSymbol = auto generateDefaultPinMapFromSymbol =
[]( const std::vector<LIB_PIN*>& sourcePins ) []( const std::vector<SCH_PIN*>& sourcePins )
{ {
wxString pinMap; wxString pinMap;
@ -1549,7 +1549,7 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
wxString prefix = aSymbol.GetPrefix(); wxString prefix = aSymbol.GetPrefix();
SCH_FIELD* valueField = aSymbol.FindField( wxT( "Value" ) ); SCH_FIELD* valueField = aSymbol.FindField( wxT( "Value" ) );
std::vector<LIB_PIN*> sourcePins = aSymbol.GetAllLibPins(); std::vector<SCH_PIN*> sourcePins = aSymbol.GetAllLibPins();
bool sourcePinsSorted = false; bool sourcePinsSorted = false;
auto lazySortSourcePins = auto lazySortSourcePins =
@ -1558,7 +1558,7 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
if( !sourcePinsSorted ) if( !sourcePinsSorted )
{ {
std::sort( sourcePins.begin(), sourcePins.end(), std::sort( sourcePins.begin(), sourcePins.end(),
[]( const LIB_PIN* lhs, const LIB_PIN* rhs ) []( const SCH_PIN* lhs, const SCH_PIN* rhs )
{ {
return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0; return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0;
} ); } );

View File

@ -30,9 +30,8 @@
#include <map> #include <map>
#include <utility> #include <utility>
#include <reporter.h>
#include <sch_field.h> #include <sch_field.h>
#include <lib_pin.h> #include <sch_pin.h>
// Must be included after sch_field.h (exactly eda_shape.h) to avoid a colliding // Must be included after sch_field.h (exactly eda_shape.h) to avoid a colliding
// declaration with a window header (under msys2) // declaration with a window header (under msys2)
@ -44,6 +43,7 @@ struct SPICE_ITEM;
class SPICE_GENERATOR; class SPICE_GENERATOR;
class SIM_MODEL_SERIALIZER; class SIM_MODEL_SERIALIZER;
class PROJECT; class PROJECT;
class REPORTER;
#define SIM_REFERENCE_FIELD wxT( "Reference" ) #define SIM_REFERENCE_FIELD wxT( "Reference" )
@ -410,20 +410,20 @@ public:
static TYPE ReadTypeFromFields( const std::vector<SCH_FIELD>& aFields, REPORTER& aReporter ); static TYPE ReadTypeFromFields( const std::vector<SCH_FIELD>& aFields, REPORTER& aReporter );
static std::unique_ptr<SIM_MODEL> Create( TYPE aType, const std::vector<LIB_PIN*>& aPins, static std::unique_ptr<SIM_MODEL> Create( TYPE aType, const std::vector<SCH_PIN*>& aPins,
REPORTER& aReporter ); REPORTER& aReporter );
static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL* aBaseModel, static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL* aBaseModel,
const std::vector<LIB_PIN*>& aPins, const std::vector<SCH_PIN*>& aPins,
REPORTER& aReporter ); REPORTER& aReporter );
static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL* aBaseModel, static std::unique_ptr<SIM_MODEL> Create( const SIM_MODEL* aBaseModel,
const std::vector<LIB_PIN*>& aPins, const std::vector<SCH_PIN*>& aPins,
const std::vector<SCH_FIELD>& aFields, const std::vector<SCH_FIELD>& aFields,
REPORTER& aReporter ); REPORTER& aReporter );
static std::unique_ptr<SIM_MODEL> Create( const std::vector<SCH_FIELD>& aFields, static std::unique_ptr<SIM_MODEL> Create( const std::vector<SCH_FIELD>& aFields,
const std::vector<LIB_PIN*>& aPins, const std::vector<SCH_PIN*>& aPins,
bool aResolved, REPORTER& aReporter ); bool aResolved, REPORTER& aReporter );
static std::string GetFieldValue( const std::vector<SCH_FIELD>* aFields, static std::string GetFieldValue( const std::vector<SCH_FIELD>* aFields,
@ -446,7 +446,7 @@ public:
SIM_MODEL& operator=(SIM_MODEL&& aOther ) = delete; SIM_MODEL& operator=(SIM_MODEL&& aOther ) = delete;
void ReadDataFields( const std::vector<SCH_FIELD>* aFields, void ReadDataFields( const std::vector<SCH_FIELD>* aFields,
const std::vector<LIB_PIN*>& aPins ); const std::vector<SCH_PIN*>& aPins );
void WriteFields( std::vector<SCH_FIELD>& aFields ) const; void WriteFields( std::vector<SCH_FIELD>& aFields ) const;
@ -529,7 +529,7 @@ protected:
SIM_MODEL( TYPE aType, std::unique_ptr<SPICE_GENERATOR> aSpiceGenerator, SIM_MODEL( TYPE aType, std::unique_ptr<SPICE_GENERATOR> aSpiceGenerator,
std::unique_ptr<SIM_MODEL_SERIALIZER> aSerializer ); std::unique_ptr<SIM_MODEL_SERIALIZER> aSerializer );
void createPins( const std::vector<LIB_PIN*>& aSymbolPins ); void createPins( const std::vector<SCH_PIN*>& aSymbolPins );
virtual int doFindParam( const std::string& aParamName ) const; virtual int doFindParam( const std::string& aParamName ) const;
virtual void doSetParamValue( int aParamIndex, const std::string& aValue ); virtual void doSetParamValue( int aParamIndex, const std::string& aValue );

View File

@ -121,13 +121,13 @@ public:
* Set or clear the pin name visibility flag. * Set or clear the pin name visibility flag.
*/ */
void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; } void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; }
bool GetShowPinNames() const { return m_showPinNames; } virtual bool GetShowPinNames() const { return m_showPinNames; }
/** /**
* Set or clear the pin number visibility flag. * Set or clear the pin number visibility flag.
*/ */
void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; } void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }
bool GetShowPinNumbers() const { return m_showPinNumbers; } virtual bool GetShowPinNumbers() const { return m_showPinNumbers; }
/** /**
* Set or clear the exclude from simulation flag. * Set or clear the exclude from simulation flag.

View File

@ -28,7 +28,7 @@
#include <macros.h> #include <macros.h>
// helper function to sort pins by pin num // helper function to sort pins by pin num
static bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst ); static bool sort_by_pin_number( const SCH_PIN* ref, const SCH_PIN* tst );
static void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages, static void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
EDA_DRAW_FRAME* aUnitsProvider ); EDA_DRAW_FRAME* aUnitsProvider );
@ -70,8 +70,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
aMessages.push_back( msg ); aMessages.push_back( msg );
} }
std::vector<LIB_PIN*> pinList; std::vector<SCH_PIN*> pinList = aSymbol->GetPins();
aSymbol->GetPins( pinList );
// Test for duplicates: // Test for duplicates:
// Sort pins by pin num, so 2 duplicate pins // Sort pins by pin num, so 2 duplicate pins
@ -88,8 +87,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
for( unsigned ii = 1; ii < pinList.size(); ii++ ) for( unsigned ii = 1; ii < pinList.size(); ii++ )
{ {
LIB_PIN* pin = pinList[ii - 1]; SCH_PIN* pin = pinList[ii - 1];
LIB_PIN* next = pinList[ii]; SCH_PIN* next = pinList[ii];
if( pin->GetNumber() != next->GetNumber() ) if( pin->GetNumber() != next->GetNumber() )
continue; continue;
@ -207,7 +206,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
aMessages.push_back( msg ); aMessages.push_back( msg );
} }
LIB_PIN* pin = pinList[0]; SCH_PIN* pin = pinList[0];
if( pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_IN if( pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_IN
&& pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_OUT ) && pin->GetType() != ELECTRICAL_PINTYPE::PT_POWER_OUT )
@ -226,7 +225,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
} }
for( LIB_PIN* pin : pinList ) for( SCH_PIN* pin : pinList )
{ {
wxString pinName = pin->GetName(); wxString pinName = pin->GetName();
@ -408,7 +407,7 @@ void CheckLibSymbolGraphics( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessag
} }
bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst ) bool sort_by_pin_number( const SCH_PIN* ref, const SCH_PIN* tst )
{ {
// Use number as primary key // Use number as primary key
int test = ref->GetNumber().Cmp( tst->GetNumber() ); int test = ref->GetNumber().Cmp( tst->GetNumber() );

View File

@ -1385,7 +1385,7 @@ void SYMBOL_EDIT_FRAME::FocusOnItem( SCH_ITEM* aItem )
if( m_symbol ) if( m_symbol )
{ {
for( LIB_PIN* pin : m_symbol->GetAllLibPins() ) for( SCH_PIN* pin : m_symbol->GetAllLibPins() )
{ {
if( pin->m_Uuid == lastBrightenedItemID ) if( pin->m_Uuid == lastBrightenedItemID )
lastItem = pin; lastItem = pin;

View File

@ -593,10 +593,11 @@ static SPIN_STYLE orientLabel( SCH_PIN* aPin )
// Initial orientation from the pin // Initial orientation from the pin
switch( aPin->GetLibPin()->GetOrientation() ) switch( aPin->GetLibPin()->GetOrientation() )
{ {
default:
case PIN_ORIENTATION::PIN_RIGHT: spin = SPIN_STYLE::LEFT; break;
case PIN_ORIENTATION::PIN_UP: spin = SPIN_STYLE::BOTTOM; break; case PIN_ORIENTATION::PIN_UP: spin = SPIN_STYLE::BOTTOM; break;
case PIN_ORIENTATION::PIN_DOWN: spin = SPIN_STYLE::UP; break; case PIN_ORIENTATION::PIN_DOWN: spin = SPIN_STYLE::UP; break;
case PIN_ORIENTATION::PIN_LEFT: spin = SPIN_STYLE::RIGHT; break; case PIN_ORIENTATION::PIN_LEFT: spin = SPIN_STYLE::RIGHT; break;
case PIN_ORIENTATION::PIN_RIGHT: spin = SPIN_STYLE::LEFT; break;
} }
// Reorient based on the actual symbol orientation now // Reorient based on the actual symbol orientation now

View File

@ -345,7 +345,7 @@ TOOL_ACTION EE_ACTIONS::placeSymbolPin( TOOL_ACTION_ARGS()
.Tooltip( _( "Add a pin" ) ) .Tooltip( _( "Add a pin" ) )
.Icon( BITMAPS::pin ) .Icon( BITMAPS::pin )
.Flags( AF_ACTIVATE ) .Flags( AF_ACTIVATE )
.Parameter( LIB_PIN_T ) ); .Parameter( SCH_PIN_T ) );
TOOL_ACTION EE_ACTIONS::placeSymbolText( TOOL_ACTION_ARGS() TOOL_ACTION EE_ACTIONS::placeSymbolText( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolDrawing.placeSymbolText" ) .Name( "eeschema.SymbolDrawing.placeSymbolText" )

View File

@ -364,7 +364,6 @@ GRID_HELPER_GRIDS EE_GRID_HELPER::GetItemGrid( const EDA_ITEM* aItem ) const
switch( aItem->Type() ) switch( aItem->Type() )
{ {
case LIB_SYMBOL_T: case LIB_SYMBOL_T:
case LIB_PIN_T:
case SCH_SYMBOL_T: case SCH_SYMBOL_T:
case SCH_PIN_T: case SCH_PIN_T:
case SCH_SHEET_PIN_T: case SCH_SHEET_PIN_T:

View File

@ -65,11 +65,11 @@ EDA_ITEM* EE_SELECTION::GetTopLeftItem( bool onlyModules ) const
for( EDA_ITEM* item : m_items ) for( EDA_ITEM* item : m_items )
{ {
SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item ); SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
LIB_PIN* lib_pin = dynamic_cast<LIB_PIN*>( item ); SCH_PIN* pin = dynamic_cast<SCH_PIN*>( item );
// Prefer connection points (which should remain on grid) // Prefer connection points (which should remain on grid)
if( ( sch_item && sch_item->IsConnectable() ) || lib_pin ) if( ( sch_item && sch_item->IsConnectable() ) || pin )
processItem( item, &topLeftConnectedItem, &topLeftConnectedPos ); processItem( item, &topLeftConnectedItem, &topLeftConnectedPos );
processItem( item, &topLeftItem, &topLeftPos ); processItem( item, &topLeftItem, &topLeftPos );

View File

@ -571,7 +571,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
m_selection = RequestSelection( { SCH_SHAPE_T, m_selection = RequestSelection( { SCH_SHAPE_T,
SCH_TEXT_T, SCH_TEXT_T,
SCH_TEXTBOX_T, SCH_TEXTBOX_T,
LIB_PIN_T, SCH_PIN_T,
SCH_FIELD_T } ); SCH_FIELD_T } );
} }
} }
@ -666,12 +666,13 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
switch( pin->GetOrientation() ) switch( pin->GetOrientation() )
{ {
case PIN_ORIENTATION::PIN_LEFT: default:
stub = VECTOR2I( 1 * wireGrid.x, 0 );
break;
case PIN_ORIENTATION::PIN_RIGHT: case PIN_ORIENTATION::PIN_RIGHT:
stub = VECTOR2I( -1 * wireGrid.x, 0 ); stub = VECTOR2I( -1 * wireGrid.x, 0 );
break; break;
case PIN_ORIENTATION::PIN_LEFT:
stub = VECTOR2I( 1 * wireGrid.x, 0 );
break;
case PIN_ORIENTATION::PIN_UP: case PIN_ORIENTATION::PIN_UP:
stub = VECTOR2I( 0, 1 * wireGrid.y ); stub = VECTOR2I( 0, 1 * wireGrid.y );
break; break;
@ -731,12 +732,13 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
switch( pin->GetOrientation() ) switch( pin->GetOrientation() )
{ {
case PIN_ORIENTATION::PIN_LEFT: default:
label->SetSpinStyle( SPIN_STYLE::SPIN::RIGHT );
break;
case PIN_ORIENTATION::PIN_RIGHT: case PIN_ORIENTATION::PIN_RIGHT:
label->SetSpinStyle( SPIN_STYLE::SPIN::LEFT ); label->SetSpinStyle( SPIN_STYLE::SPIN::LEFT );
break; break;
case PIN_ORIENTATION::PIN_LEFT:
label->SetSpinStyle( SPIN_STYLE::SPIN::RIGHT );
break;
case PIN_ORIENTATION::PIN_UP: case PIN_ORIENTATION::PIN_UP:
label->SetSpinStyle( SPIN_STYLE::SPIN::BOTTOM ); label->SetSpinStyle( SPIN_STYLE::SPIN::BOTTOM );
break; break;
@ -1085,9 +1087,9 @@ void EE_SELECTION_TOOL::narrowSelection( EE_COLLECTOR& collector, const VECTOR2I
continue; continue;
} }
} }
else if( item->Type() == LIB_PIN_T ) else if( item->Type() == SCH_PIN_T )
{ {
if( !static_cast<LIB_PIN*>( item )->IsVisible() if( !static_cast<SCH_PIN*>( item )->IsVisible()
&& !symbolEditorFrame->GetShowInvisiblePins() ) && !symbolEditorFrame->GetShowInvisiblePins() )
{ {
collector.Remove( i ); collector.Remove( i );
@ -1607,7 +1609,6 @@ bool EE_SELECTION_TOOL::itemPassesFilter( EDA_ITEM* aItem )
case SCH_PIN_T: case SCH_PIN_T:
case SCH_SHEET_PIN_T: case SCH_SHEET_PIN_T:
case LIB_PIN_T:
if( !m_filter.pins ) if( !m_filter.pins )
return false; return false;
@ -2438,6 +2439,15 @@ bool EE_SELECTION_TOOL::Selectable( const EDA_ITEM* aItem, const VECTOR2I* aPos,
{ {
const SCH_PIN* pin = static_cast<const SCH_PIN*>( aItem ); const SCH_PIN* pin = static_cast<const SCH_PIN*>( aItem );
if( symEditFrame )
{
if( pin->GetUnit() && pin->GetUnit() != symEditFrame->GetUnit() )
return false;
if( pin->GetBodyStyle() && pin->GetBodyStyle() != symEditFrame->GetBodyStyle() )
return false;
}
if( !pin->IsVisible() && !m_frame->GetShowAllPins() ) if( !pin->IsVisible() && !m_frame->GetShowAllPins() )
return false; return false;
@ -2481,7 +2491,6 @@ bool EE_SELECTION_TOOL::Selectable( const EDA_ITEM* aItem, const VECTOR2I* aPos,
case SCH_SHAPE_T: case SCH_SHAPE_T:
case SCH_TEXT_T: case SCH_TEXT_T:
case SCH_TEXTBOX_T: case SCH_TEXTBOX_T:
case LIB_PIN_T:
if( symEditFrame ) if( symEditFrame )
{ {
const SCH_ITEM* sch_item = static_cast<const SCH_ITEM*>( aItem ); const SCH_ITEM* sch_item = static_cast<const SCH_ITEM*>( aItem );

View File

@ -144,7 +144,7 @@ private:
EE_SELECTION_TOOL* selTool = getToolManager()->GetTool<EE_SELECTION_TOOL>(); EE_SELECTION_TOOL* selTool = getToolManager()->GetTool<EE_SELECTION_TOOL>();
EE_SELECTION& selection = selTool->GetSelection(); EE_SELECTION& selection = selTool->GetSelection();
SCH_PIN* pin = dynamic_cast<SCH_PIN*>( selection.Front() ); SCH_PIN* pin = dynamic_cast<SCH_PIN*>( selection.Front() );
LIB_PIN* libPin = pin ? pin->GetLibPin() : nullptr; SCH_PIN* libPin = pin ? pin->GetLibPin() : nullptr;
Clear(); Clear();
@ -2054,6 +2054,7 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
break; break;
case SCH_NO_CONNECT_T: case SCH_NO_CONNECT_T:
case SCH_PIN_T:
break; break;
default: // Unexpected item default: // Unexpected item

View File

@ -570,7 +570,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
{ {
try try
{ {
LIB_PIN* pin = static_cast<SCH_PIN*>( item )->GetLibPin(); SCH_PIN* pin = static_cast<SCH_PIN*>( item )->GetLibPin();
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() ); SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
wxString msg; wxString msg;
@ -2110,16 +2110,16 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
for( EDA_ITEM* item : selection.Items() ) for( EDA_ITEM* item : selection.Items() )
{ {
SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item ); SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
LIB_PIN* lib_pin = dynamic_cast<LIB_PIN*>( item ); SCH_PIN* pin = dynamic_cast<SCH_PIN*>( item );
if( sch_item && sch_item->IsConnectable() ) if( sch_item && sch_item->IsConnectable() )
{ {
for( const VECTOR2I& pt : sch_item->GetConnectionPoints() ) for( const VECTOR2I& pt : sch_item->GetConnectionPoints() )
processPt( pt ); processPt( pt );
} }
else if( lib_pin ) else if( pin )
{ {
processPt( lib_pin->GetPosition() ); processPt( pin->GetPosition() );
} }
} }

View File

@ -81,7 +81,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
{ {
KICAD_T type = aEvent.Parameter<KICAD_T>(); KICAD_T type = aEvent.Parameter<KICAD_T>();
auto* settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>(); auto* settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
auto* pinTool = type == LIB_PIN_T ? m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>() : nullptr; auto* pinTool = type == SCH_PIN_T ? m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>() : nullptr;
if( m_inTwoClickPlace ) if( m_inTwoClickPlace )
return 0; return 0;
@ -208,7 +208,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
switch( type ) switch( type )
{ {
case LIB_PIN_T: case SCH_PIN_T:
{ {
item = pinTool->CreatePin( VECTOR2I( cursorPos.x, -cursorPos.y ), symbol ); item = pinTool->CreatePin( VECTOR2I( cursorPos.x, -cursorPos.y ), symbol );
g_lastPinWeakPtr = item; g_lastPinWeakPtr = item;
@ -281,8 +281,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
switch( item->Type() ) switch( item->Type() )
{ {
case LIB_PIN_T: case SCH_PIN_T:
pinTool->PlacePin( static_cast<LIB_PIN*>( item ) ); pinTool->PlacePin( static_cast<SCH_PIN*>( item ) );
item->ClearEditFlags(); item->ClearEditFlags();
commit.Push( _( "Add Pin" ) ); commit.Push( _( "Add Pin" ) );
break; break;
@ -830,15 +830,13 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem( const TOOL_EVENT& aEvent )
{ {
SYMBOL_EDITOR_PIN_TOOL* pinTool = m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>(); SYMBOL_EDITOR_PIN_TOOL* pinTool = m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>();
LIB_SYMBOL* symbol = m_frame->GetCurSymbol(); LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
LIB_PIN* sourcePin = nullptr; SCH_PIN* sourcePin = nullptr;
if( !symbol ) if( !symbol )
return 0; return 0;
// See if we have a pin matching our weak ptr // See if we have a pin matching our weak ptr
std::vector<LIB_PIN*> pins = symbol->GetAllLibPins(); for( SCH_PIN* test : symbol->GetAllLibPins() )
for( LIB_PIN* test : pins )
{ {
if( (void*) test == g_lastPinWeakPtr ) if( (void*) test == g_lastPinWeakPtr )
{ {
@ -849,7 +847,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem( const TOOL_EVENT& aEvent )
if( sourcePin ) if( sourcePin )
{ {
LIB_PIN* pin = pinTool->RepeatPin( sourcePin ); SCH_PIN* pin = pinTool->RepeatPin( sourcePin );
g_lastPinWeakPtr = pin; g_lastPinWeakPtr = pin;
m_toolMgr->RunAction( EE_ACTIONS::clearSelection ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection );

View File

@ -274,7 +274,7 @@ static std::vector<KICAD_T> nonFields =
SCH_SHAPE_T, SCH_SHAPE_T,
SCH_TEXT_T, SCH_TEXT_T,
SCH_TEXTBOX_T, SCH_TEXTBOX_T,
LIB_PIN_T SCH_PIN_T
}; };
@ -298,9 +298,9 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
for( EDA_ITEM* item : items ) for( EDA_ITEM* item : items )
{ {
if( item->Type() == LIB_PIN_T ) if( item->Type() == SCH_PIN_T )
{ {
LIB_PIN* curr_pin = static_cast<LIB_PIN*>( item ); SCH_PIN* curr_pin = static_cast<SCH_PIN*>( item );
VECTOR2I pos = curr_pin->GetPosition(); VECTOR2I pos = curr_pin->GetPosition();
toDelete.insert( curr_pin ); toDelete.insert( curr_pin );
@ -313,12 +313,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
got_unit[curr_pin->GetUnit()] = true; got_unit[curr_pin->GetUnit()] = true;
int curr_bodyStyle = curr_pin->GetBodyStyle(); for( SCH_PIN* pin : symbol->GetAllLibPins() )
ELECTRICAL_PINTYPE etype = curr_pin->GetType();
wxString name = curr_pin->GetName();
std::vector<LIB_PIN*> pins = symbol->GetAllLibPins();
for( LIB_PIN* pin : pins )
{ {
if( got_unit[pin->GetUnit()] ) if( got_unit[pin->GetUnit()] )
continue; continue;
@ -326,13 +321,13 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
if( pin->GetPosition() != pos ) if( pin->GetPosition() != pos )
continue; continue;
if( pin->GetBodyStyle() != curr_bodyStyle ) if( pin->GetBodyStyle() != curr_pin->GetBodyStyle() )
continue; continue;
if( pin->GetType() != etype ) if( pin->GetType() != curr_pin->GetType() )
continue; continue;
if( pin->GetName() != name ) if( pin->GetName() != curr_pin->GetName() )
continue; continue;
toDelete.insert( pin ); toDelete.insert( pin );
@ -480,9 +475,9 @@ int SYMBOL_EDITOR_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
switch( item->Type() ) switch( item->Type() )
{ {
case LIB_PIN_T: case SCH_PIN_T:
if( SYMBOL_EDITOR_PIN_TOOL* pinTool = m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>() ) if( SYMBOL_EDITOR_PIN_TOOL* pinTool = m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>() )
pinTool->EditPinProperties( (LIB_PIN*) item ); pinTool->EditPinProperties( static_cast<SCH_PIN*>( item ) );
break; break;
@ -637,7 +632,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties()
} }
} }
void SYMBOL_EDITOR_EDIT_TOOL::handlePinDuplication( LIB_PIN* aOldPin, LIB_PIN* aNewPin, void SYMBOL_EDITOR_EDIT_TOOL::handlePinDuplication( SCH_PIN* aOldPin, SCH_PIN* aNewPin,
int& aSymbolLastPinNumber ) int& aSymbolLastPinNumber )
{ {
if( !aNewPin->GetNumber().IsEmpty() ) if( !aNewPin->GetNumber().IsEmpty() )
@ -905,9 +900,9 @@ int SYMBOL_EDITOR_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
SCH_ITEM* oldItem = static_cast<SCH_ITEM*>( selection.GetItem( ii ) ); SCH_ITEM* oldItem = static_cast<SCH_ITEM*>( selection.GetItem( ii ) );
SCH_ITEM* newItem = oldItem->Duplicate(); SCH_ITEM* newItem = oldItem->Duplicate();
if( newItem->Type() == LIB_PIN_T ) if( newItem->Type() == SCH_PIN_T )
{ {
LIB_PIN* newPin = static_cast<LIB_PIN*>( newItem ); SCH_PIN* newPin = static_cast<SCH_PIN*>( newItem );
if( !newPin->GetNumber().IsEmpty() ) if( !newPin->GetNumber().IsEmpty() )
newPin->SetNumber( wxString::Format( wxT( "%i" ), symbol->GetMaxPinNumber() + 1 ) ); newPin->SetNumber( wxString::Format( wxT( "%i" ), symbol->GetMaxPinNumber() + 1 ) );

View File

@ -70,7 +70,7 @@ private:
void editTextBoxProperties( SCH_ITEM* aItem ); void editTextBoxProperties( SCH_ITEM* aItem );
void editFieldProperties( SCH_FIELD* aField ); void editFieldProperties( SCH_FIELD* aField );
void editSymbolProperties(); void editSymbolProperties();
void handlePinDuplication(LIB_PIN* aOldPin, LIB_PIN* aNewPin, int &aSymbolLastPinNumber ); void handlePinDuplication(SCH_PIN* aOldPin, SCH_PIN* aNewPin, int &aSymbolLastPinNumber );
///< Set up handlers for various events. ///< Set up handlers for various events.
void setTransitions() override; void setTransitions() override;

View File

@ -179,23 +179,21 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM
if( m_frame->SynchronizePins() if( m_frame->SynchronizePins()
&& ( lib_item->GetEditFlags() & IS_PASTED ) == 0 ) && ( lib_item->GetEditFlags() & IS_PASTED ) == 0 )
{ {
std::set<LIB_PIN*> sync_pins; std::set<SCH_PIN*> sync_pins;
for( EDA_ITEM* sel_item : selection ) for( EDA_ITEM* sel_item : selection )
{ {
lib_item = static_cast<SCH_ITEM*>( sel_item ); lib_item = static_cast<SCH_ITEM*>( sel_item );
if( lib_item->Type() == LIB_PIN_T ) if( lib_item->Type() == SCH_PIN_T )
{ {
LIB_PIN* cur_pin = static_cast<LIB_PIN*>( lib_item ); SCH_PIN* cur_pin = static_cast<SCH_PIN*>( lib_item );
LIB_SYMBOL* symbol = m_frame->GetCurSymbol(); LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
std::vector<bool> got_unit( symbol->GetUnitCount() + 1 ); std::vector<bool> got_unit( symbol->GetUnitCount() + 1 );
got_unit[cur_pin->GetUnit()] = true; got_unit[cur_pin->GetUnit()] = true;
std::vector<LIB_PIN*> pins = symbol->GetAllLibPins(); for( SCH_PIN* pin : symbol->GetAllLibPins() )
for( LIB_PIN* pin : pins )
{ {
if( !got_unit[pin->GetUnit()] if( !got_unit[pin->GetUnit()]
&& pin->GetPosition() == cur_pin->GetPosition() && pin->GetPosition() == cur_pin->GetPosition()
@ -211,7 +209,7 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM
} }
} }
for( LIB_PIN* pin : sync_pins ) for( SCH_PIN* pin : sync_pins )
m_selectionTool->AddItemToSel( pin, true /*quiet mode*/ ); m_selectionTool->AddItemToSel( pin, true /*quiet mode*/ );
} }
@ -322,13 +320,13 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM
|| evt->IsClick( BUT_LEFT ) || evt->IsClick( BUT_LEFT )
|| evt->IsDblClick( BUT_LEFT ) ) || evt->IsDblClick( BUT_LEFT ) )
{ {
if( selection.GetSize() == 1 && selection.Front()->Type() == LIB_PIN_T ) if( selection.GetSize() == 1 && selection.Front()->Type() == SCH_PIN_T )
{ {
SYMBOL_EDITOR_PIN_TOOL* pinTool = m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>(); SYMBOL_EDITOR_PIN_TOOL* pinTool = m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>();
try try
{ {
LIB_PIN* curr_pin = (LIB_PIN*) selection.Front(); SCH_PIN* curr_pin = static_cast<SCH_PIN*>( selection.Front() );
if( pinTool->PlacePin( curr_pin ) ) if( pinTool->PlacePin( curr_pin ) )
{ {
@ -479,7 +477,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent )
if( delta != VECTOR2I( 0, 0 ) ) if( delta != VECTOR2I( 0, 0 ) )
doMoveItem( item, delta ); doMoveItem( item, delta );
if( LIB_PIN* pin = dynamic_cast<LIB_PIN*>( item ) ) if( SCH_PIN* pin = dynamic_cast<SCH_PIN*>( item ) )
{ {
int length = pin->GetLength(); int length = pin->GetLength();
int pinGrid; int pinGrid;

View File

@ -103,7 +103,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::Init()
return editor->IsSymbolEditable() && !editor->IsSymbolAlias(); return editor->IsSymbolEditable() && !editor->IsSymbolAlias();
}; };
auto singlePinCondition = EE_CONDITIONS::Count( 1 ) && EE_CONDITIONS::OnlyTypes( { LIB_PIN_T } ); auto singlePinCondition = EE_CONDITIONS::Count( 1 ) && EE_CONDITIONS::OnlyTypes( { SCH_PIN_T } );
CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu(); CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
@ -116,9 +116,9 @@ bool SYMBOL_EDITOR_PIN_TOOL::Init()
} }
bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin ) bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( SCH_PIN* aPin )
{ {
LIB_PIN original_pin( *aPin ); SCH_PIN original_pin( *aPin );
DIALOG_PIN_PROPERTIES dlg( m_frame, aPin ); DIALOG_PIN_PROPERTIES dlg( m_frame, aPin );
SCH_COMMIT commit( m_frame ); SCH_COMMIT commit( m_frame );
LIB_SYMBOL* parentSymbol = static_cast<LIB_SYMBOL*>( aPin->GetParentSymbol() ); LIB_SYMBOL* parentSymbol = static_cast<LIB_SYMBOL*>( aPin->GetParentSymbol() );
@ -131,9 +131,6 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
if( !aPin->IsNew() && m_frame->SynchronizePins() && parentSymbol ) if( !aPin->IsNew() && m_frame->SynchronizePins() && parentSymbol )
{ {
std::vector<LIB_PIN*> pinList;
parentSymbol->GetPins( pinList );
// a pin can have a unit id = 0 (common to all units) to unit count // a pin can have a unit id = 0 (common to all units) to unit count
// So we need a buffer size = GetUnitCount()+1 to store a value in a vector // So we need a buffer size = GetUnitCount()+1 to store a value in a vector
// when using the unit id of a pin as index // when using the unit id of a pin as index
@ -141,7 +138,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
got_unit[static_cast<size_t>(aPin->GetUnit())] = true; got_unit[static_cast<size_t>(aPin->GetUnit())] = true;
for( LIB_PIN* other : pinList ) for( SCH_PIN* other : parentSymbol->GetPins() )
{ {
if( other == aPin ) if( other == aPin )
continue; continue;
@ -209,14 +206,14 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
} }
bool SYMBOL_EDITOR_PIN_TOOL::PlacePin( LIB_PIN* aPin ) bool SYMBOL_EDITOR_PIN_TOOL::PlacePin( SCH_PIN* aPin )
{ {
LIB_SYMBOL* symbol = m_frame->GetCurSymbol(); LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
bool ask_for_pin = true; // Test for another pin in same position in other units bool ask_for_pin = true; // Test for another pin in same position in other units
std::vector<LIB_PIN*> pins = symbol->GetAllLibPins(); std::vector<SCH_PIN*> pins = symbol->GetAllLibPins();
for( LIB_PIN* test : pins ) for( SCH_PIN* test : pins )
{ {
if( test == aPin || aPin->GetPosition() != test->GetPosition() || test->GetEditFlags() ) if( test == aPin || aPin->GetPosition() != test->GetPosition() || test->GetEditFlags() )
continue; continue;
@ -265,7 +262,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::PlacePin( LIB_PIN* aPin )
} }
// Put linked pins in new position, and clear flags // Put linked pins in new position, and clear flags
for( LIB_PIN* pin : pins ) for( SCH_PIN* pin : pins )
{ {
if( ( pin->GetEditFlags() & IS_LINKED ) == 0 ) if( ( pin->GetEditFlags() & IS_LINKED ) == 0 )
continue; continue;
@ -284,11 +281,11 @@ bool SYMBOL_EDITOR_PIN_TOOL::PlacePin( LIB_PIN* aPin )
/* /*
* Create a new pin. * Create a new pin.
*/ */
LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::CreatePin( const VECTOR2I& aPosition, LIB_SYMBOL* aSymbol ) SCH_PIN* SYMBOL_EDITOR_PIN_TOOL::CreatePin( const VECTOR2I& aPosition, LIB_SYMBOL* aSymbol )
{ {
aSymbol->ClearTempFlags(); aSymbol->ClearTempFlags();
LIB_PIN* pin = new LIB_PIN( aSymbol ); SCH_PIN* pin = new SCH_PIN( aSymbol );
pin->SetFlags( IS_NEW ); pin->SetFlags( IS_NEW );
@ -317,10 +314,10 @@ LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::CreatePin( const VECTOR2I& aPosition, LIB_SYMBO
} }
void SYMBOL_EDITOR_PIN_TOOL::CreateImagePins( LIB_PIN* aPin ) void SYMBOL_EDITOR_PIN_TOOL::CreateImagePins( SCH_PIN* aPin )
{ {
int ii; int ii;
LIB_PIN* newPin; SCH_PIN* newPin;
// if "synchronize pins editing" option is off, do not create any similar pin for other // if "synchronize pins editing" option is off, do not create any similar pin for other
// units and/or shapes: each unit is edited regardless other units or body // units and/or shapes: each unit is edited regardless other units or body
@ -340,7 +337,7 @@ void SYMBOL_EDITOR_PIN_TOOL::CreateImagePins( LIB_PIN* aPin )
if( ii == aPin->GetUnit() ) if( ii == aPin->GetUnit() )
continue; continue;
newPin = static_cast<LIB_PIN*>( aPin->Duplicate() ); newPin = static_cast<SCH_PIN*>( aPin->Duplicate() );
// To avoid mistakes, gives this pin a new pin number because // To avoid mistakes, gives this pin a new pin number because
// it does no have the save pin number as the master pin // it does no have the save pin number as the master pin
@ -373,15 +370,14 @@ int SYMBOL_EDITOR_PIN_TOOL::PushPinProperties( const TOOL_EVENT& aEvent )
{ {
LIB_SYMBOL* symbol = m_frame->GetCurSymbol(); LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
EE_SELECTION& selection = m_selectionTool->GetSelection(); EE_SELECTION& selection = m_selectionTool->GetSelection();
LIB_PIN* sourcePin = dynamic_cast<LIB_PIN*>( selection.Front() ); SCH_PIN* sourcePin = dynamic_cast<SCH_PIN*>( selection.Front() );
if( !sourcePin ) if( !sourcePin )
return 0; return 0;
saveCopyInUndoList( symbol, UNDO_REDO::LIBEDIT ); saveCopyInUndoList( symbol, UNDO_REDO::LIBEDIT );
std::vector<LIB_PIN*> pins = symbol->GetAllLibPins();
for( LIB_PIN* pin : pins ) for( SCH_PIN* pin : symbol->GetAllLibPins() )
{ {
if( pin == sourcePin ) if( pin == sourcePin )
continue; continue;
@ -409,9 +405,9 @@ int SYMBOL_EDITOR_PIN_TOOL::PushPinProperties( const TOOL_EVENT& aEvent )
// Create a new pin based on the previous pin with an incremented pin number. // Create a new pin based on the previous pin with an incremented pin number.
LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::RepeatPin( const LIB_PIN* aSourcePin ) SCH_PIN* SYMBOL_EDITOR_PIN_TOOL::RepeatPin( const SCH_PIN* aSourcePin )
{ {
LIB_PIN* pin = (LIB_PIN*) aSourcePin->Duplicate(); SCH_PIN* pin = static_cast<SCH_PIN*>( aSourcePin->Duplicate() );
VECTOR2I step; VECTOR2I step;
pin->ClearFlags(); pin->ClearFlags();
@ -421,10 +417,11 @@ LIB_PIN* SYMBOL_EDITOR_PIN_TOOL::RepeatPin( const LIB_PIN* aSourcePin )
switch( pin->GetOrientation() ) switch( pin->GetOrientation() )
{ {
default:
case PIN_ORIENTATION::PIN_RIGHT: step.y = schIUScale.MilsToIU(-settings->m_Repeat.pin_step); break;
case PIN_ORIENTATION::PIN_UP: step.x = schIUScale.MilsToIU(settings->m_Repeat.pin_step); break; case PIN_ORIENTATION::PIN_UP: step.x = schIUScale.MilsToIU(settings->m_Repeat.pin_step); break;
case PIN_ORIENTATION::PIN_DOWN: step.x = schIUScale.MilsToIU(settings->m_Repeat.pin_step); break; case PIN_ORIENTATION::PIN_DOWN: step.x = schIUScale.MilsToIU(settings->m_Repeat.pin_step); break;
case PIN_ORIENTATION::PIN_LEFT: step.y = schIUScale.MilsToIU(-settings->m_Repeat.pin_step); break; case PIN_ORIENTATION::PIN_LEFT: step.y = schIUScale.MilsToIU(-settings->m_Repeat.pin_step); break;
case PIN_ORIENTATION::PIN_RIGHT: step.y = schIUScale.MilsToIU(-settings->m_Repeat.pin_step); break;
} }
pin->Move( step ); pin->Move( step );

View File

@ -41,13 +41,13 @@ public:
/// @copydoc TOOL_INTERACTIVE::Init() /// @copydoc TOOL_INTERACTIVE::Init()
bool Init() override; bool Init() override;
LIB_PIN* CreatePin( const VECTOR2I& aPosition, LIB_SYMBOL* aSymbol ); SCH_PIN* CreatePin( const VECTOR2I& aPosition, LIB_SYMBOL* aSymbol );
LIB_PIN* RepeatPin( const LIB_PIN* aSourcePin ); SCH_PIN* RepeatPin( const SCH_PIN* aSourcePin );
bool PlacePin( LIB_PIN* aPin ); bool PlacePin( SCH_PIN* aPin );
void CreateImagePins( LIB_PIN* aPin ); void CreateImagePins( SCH_PIN* aPin );
bool EditPinProperties( LIB_PIN* aPin ); bool EditPinProperties( SCH_PIN* aPin );
int PushPinProperties( const TOOL_EVENT& aEvent ); int PushPinProperties( const TOOL_EVENT& aEvent );
private: private:

View File

@ -604,17 +604,11 @@ void PANEL_SYMBOL_CHOOSER::populateFootprintSelector( LIB_ID const& aLibId )
if( symbol != nullptr ) if( symbol != nullptr )
{ {
std::vector<LIB_PIN*> temp_pins; int pinCount = symbol->GetPins( 0 /* all units */, 1 /* single bodyStyle */ ).size();
SCH_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD ); SCH_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD );
wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" ); wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
// All units, but only a single De Morgan variant. m_fp_sel_ctrl->FilterByPinCount( pinCount );
if( symbol->HasAlternateBodyStyle() )
symbol->GetPins( temp_pins, 0, 1 );
else
symbol->GetPins( temp_pins );
m_fp_sel_ctrl->FilterByPinCount( temp_pins.size() );
m_fp_sel_ctrl->FilterByFootprintFilters( symbol->GetFPFilters(), true ); m_fp_sel_ctrl->FilterByFootprintFilters( symbol->GetFPFilters(), true );
m_fp_sel_ctrl->SetDefaultFootprint( fp_name ); m_fp_sel_ctrl->SetDefaultFootprint( fp_name );
m_fp_sel_ctrl->UpdateList(); m_fp_sel_ctrl->UpdateList();

View File

@ -29,7 +29,7 @@
#include "pin_shape_combobox.h" #include "pin_shape_combobox.h"
#include <bitmaps.h> #include <bitmaps.h>
#include <lib_pin.h> #include <sch_pin.h>
PinShapeComboBox::PinShapeComboBox( wxWindow* parent, PinShapeComboBox::PinShapeComboBox( wxWindow* parent,
wxWindowID id, wxWindowID id,

View File

@ -29,7 +29,7 @@
#include "pin_type_combobox.h" #include "pin_type_combobox.h"
#include <bitmaps.h> #include <bitmaps.h>
#include <lib_pin.h> #include <sch_pin.h>
PinTypeComboBox::PinTypeComboBox( wxWindow* parent, PinTypeComboBox::PinTypeComboBox( wxWindow* parent,
wxWindowID id, wxWindowID id,

View File

@ -150,7 +150,7 @@ enum KICAD_T
SCH_FIELD_T, SCH_FIELD_T,
SCH_TEXT_T, SCH_TEXT_T,
SCH_TEXTBOX_T, SCH_TEXTBOX_T,
LIB_PIN_T, SCH_PIN_T,
// Schematic draw Items. The order of these items effects the sort order. // Schematic draw Items. The order of these items effects the sort order.
// It is currently ordered to mimic the old Eeschema locate behavior where // It is currently ordered to mimic the old Eeschema locate behavior where
@ -171,7 +171,6 @@ enum KICAD_T
SCH_SYMBOL_T, SCH_SYMBOL_T,
SCH_SHEET_PIN_T, SCH_SHEET_PIN_T,
SCH_SHEET_T, SCH_SHEET_T,
SCH_PIN_T,
// Be prudent with these types: // Be prudent with these types:
// they should be used only to locate a specific field type among SCH_FIELD_Ts // they should be used only to locate a specific field type among SCH_FIELD_Ts
@ -409,7 +408,6 @@ constexpr bool IsEeschemaType( const KICAD_T aType )
case SCHEMATIC_T: case SCHEMATIC_T:
case LIB_SYMBOL_T: case LIB_SYMBOL_T:
case LIB_PIN_T:
return true; return true;
default: default:

View File

@ -32,6 +32,7 @@
#include <qa_utils/wx_utils/unit_test_utils.h> #include <qa_utils/wx_utils/unit_test_utils.h>
#include <template_fieldnames.h> #include <template_fieldnames.h>
#include <sch_field.h>
namespace BOOST_TEST_PRINT_NAMESPACE_OPEN namespace BOOST_TEST_PRINT_NAMESPACE_OPEN

View File

@ -43,8 +43,7 @@
#include <sch_symbol.h> #include <sch_symbol.h>
#include <sch_sheet_pin.h> #include <sch_sheet_pin.h>
#include <sch_sheet.h> #include <sch_sheet.h>
#include <sch_pin.h>
#include <lib_pin.h>
#include <erc_settings.h> #include <erc_settings.h>
@ -53,7 +52,7 @@ class TEST_EE_ITEM_FIXTURE
public: public:
SCH_SHEET m_sheet; SCH_SHEET m_sheet;
LIB_SYMBOL m_symbol; LIB_SYMBOL m_symbol;
LIB_PIN m_pin; SCH_PIN m_pin;
std::shared_ptr<ERC_ITEM> m_ercItem; std::shared_ptr<ERC_ITEM> m_ercItem;
TEST_EE_ITEM_FIXTURE() : TEST_EE_ITEM_FIXTURE() :
@ -113,10 +112,9 @@ public:
"test aPin" ); "test aPin" );
case SCH_SHEET_T: return new SCH_SHEET(); case SCH_SHEET_T: return new SCH_SHEET();
case LIB_PIN_T: return new LIB_PIN( &m_symbol ); case SCH_PIN_T: return new SCH_PIN( &m_symbol );
case SCHEMATIC_T: case SCHEMATIC_T:
case SCH_PIN_T:
case LIB_SYMBOL_T: return nullptr; case LIB_SYMBOL_T: return nullptr;
default: default:

View File

@ -30,7 +30,8 @@
// Code under test // Code under test
#include <sch_shape.h> #include <sch_shape.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <lib_symbol.h>
#include "lib_field_test_utils.h" #include "lib_field_test_utils.h"
@ -425,9 +426,9 @@ BOOST_AUTO_TEST_CASE( Compare )
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 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()[SCH_SHAPE_T].front() ); m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_SHAPE_T].front() );
testPart.RemoveDrawItem( &testPart.GetDrawItems()[SCH_SHAPE_T].front() ); testPart.RemoveDrawItem( &testPart.GetDrawItems()[SCH_SHAPE_T].front() );
m_part_no_data.AddDrawItem( new LIB_PIN( &m_part_no_data ) ); m_part_no_data.AddDrawItem( new SCH_PIN( &m_part_no_data ) );
BOOST_CHECK( m_part_no_data.Compare( testPart, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) > 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() ); m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_PIN_T].front() );
// Footprint filter array comparison tests. // Footprint filter array comparison tests.
wxArrayString footPrintFilters; wxArrayString footPrintFilters;
@ -529,7 +530,7 @@ BOOST_AUTO_TEST_CASE( GetUnitItems )
BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 0 ); BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 0 );
// A single unique unit with 1 pin common to all units and all body styles. // A single unique unit with 1 pin common to all units and all body styles.
LIB_PIN* pin1 = new LIB_PIN( &m_part_no_data ); SCH_PIN* pin1 = new SCH_PIN( &m_part_no_data );
m_part_no_data.AddDrawItem( pin1 ); m_part_no_data.AddDrawItem( pin1 );
BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 0, 0 ).size() == 1 ); BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 0, 0 ).size() == 1 );
@ -543,7 +544,7 @@ BOOST_AUTO_TEST_CASE( GetUnitItems )
// Two unique units with pin 1 assigned to unit 1 and body style 1 and pin 2 assigned to // Two unique units with pin 1 assigned to unit 1 and body style 1 and pin 2 assigned to
// unit 2 and body style 1. // unit 2 and body style 1.
LIB_PIN* pin2 = new LIB_PIN( &m_part_no_data ); SCH_PIN* pin2 = new SCH_PIN( &m_part_no_data );
m_part_no_data.SetUnitCount( 2 ); m_part_no_data.SetUnitCount( 2 );
pin2->SetUnit( 2 ); pin2->SetUnit( 2 );
pin2->SetBodyStyle( 2 ); pin2->SetBodyStyle( 2 );
@ -571,7 +572,7 @@ BOOST_AUTO_TEST_CASE( GetUnitDrawItems )
BOOST_CHECK( m_part_no_data.GetUnitDrawItems().size() == 0 ); BOOST_CHECK( m_part_no_data.GetUnitDrawItems().size() == 0 );
// A single unique unit with 1 pin common to all units and all body styles. // A single unique unit with 1 pin common to all units and all body styles.
LIB_PIN* pin1 = new LIB_PIN( &m_part_no_data ); SCH_PIN* pin1 = new SCH_PIN( &m_part_no_data );
pin1->SetNumber( "1" ); pin1->SetNumber( "1" );
m_part_no_data.AddDrawItem( pin1 ); m_part_no_data.AddDrawItem( pin1 );
std::vector<struct LIB_SYMBOL_UNIT> units = m_part_no_data.GetUnitDrawItems(); std::vector<struct LIB_SYMBOL_UNIT> units = m_part_no_data.GetUnitDrawItems();
@ -679,7 +680,7 @@ BOOST_AUTO_TEST_CASE( CopyConstructor )
BOOST_AUTO_TEST_CASE( IsPowerTest ) BOOST_AUTO_TEST_CASE( IsPowerTest )
{ {
std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( "power" ); std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( "power" );
LIB_PIN* pin = new LIB_PIN( symbol.get() ); SCH_PIN* pin = new SCH_PIN( symbol.get() );
pin->SetNumber( "1" ); pin->SetNumber( "1" );
pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN ); pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
pin->SetVisible( false ); pin->SetVisible( false );

View File

@ -36,7 +36,7 @@ public:
{ {
m_parent_part = new LIB_SYMBOL( "parent_part", nullptr ); m_parent_part = new LIB_SYMBOL( "parent_part", nullptr );
m_lib_pin = new LIB_PIN( m_parent_part ); m_lib_pin = new SCH_PIN( m_parent_part );
m_parent_part->AddDrawItem( m_lib_pin ); m_parent_part->AddDrawItem( m_lib_pin );
// give the pin some kind of data we can use to test // give the pin some kind of data we can use to test
@ -61,7 +61,7 @@ public:
} }
LIB_SYMBOL* m_parent_part; LIB_SYMBOL* m_parent_part;
LIB_PIN* m_lib_pin; SCH_PIN* m_lib_pin;
SCH_SYMBOL* m_parent_symbol; SCH_SYMBOL* m_parent_symbol;
SCH_PIN* m_sch_pin; // owned by m_parent_symbol, not us SCH_PIN* m_sch_pin; // owned by m_parent_symbol, not us

View File

@ -23,7 +23,8 @@
#include <qa_utils/wx_utils/unit_test_utils.h> #include <qa_utils/wx_utils/unit_test_utils.h>
#include <sim/sim_model.h> #include <sim/sim_model.h>
#include <lib_pin.h> #include <sch_pin.h>
#include <lib_symbol.h>
class TEST_SIM_MODEL_INFERENCE class TEST_SIM_MODEL_INFERENCE
{ {
@ -82,8 +83,8 @@ BOOST_AUTO_TEST_CASE( InferPassiveValues )
}; };
std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( "symbol", nullptr ); std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( "symbol", nullptr );
symbol->AddDrawItem( new LIB_PIN( symbol.get() ) ); symbol->AddDrawItem( new SCH_PIN( symbol.get() ) );
symbol->AddDrawItem( new LIB_PIN( symbol.get() ) ); symbol->AddDrawItem( new SCH_PIN( symbol.get() ) );
wxString deviceType; wxString deviceType;
wxString modelType; wxString modelType;