diff --git a/common/api/api_enums.cpp b/common/api/api_enums.cpp
index d03e066d7d..12fe941077 100644
--- a/common/api/api_enums.cpp
+++ b/common/api/api_enums.cpp
@@ -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_PIN: return SCH_PIN_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_RECT: return WSG_RECT_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_PIN_T: return types::KiCadObjectType::KOT_SCH_PIN;
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_RECT_T: return types::KiCadObjectType::KOT_WSG_RECT;
case WSG_POLY_T: return types::KiCadObjectType::KOT_WSG_POLY;
diff --git a/common/eda_item.cpp b/common/eda_item.cpp
index 7a610a33b8..682e337882 100644
--- a/common/eda_item.cpp
+++ b/common/eda_item.cpp
@@ -396,7 +396,6 @@ static struct EDA_ITEM_DESC
.Map( SCH_SCREEN_T, _HKI( "SCH Screen" ) )
.Map( LIB_SYMBOL_T, _HKI( "Symbol" ) )
- .Map( LIB_PIN_T, _HKI( "Pin" ) )
.Map( GERBER_LAYOUT_T, _HKI( "Gerber Layout" ) )
.Map( GERBER_DRAW_ITEM_T, _HKI( "Draw Item" ) )
diff --git a/common/gr_text.cpp b/common/gr_text.cpp
index c90a5711d2..5fa8122da7 100644
--- a/common/gr_text.cpp
+++ b/common/gr_text.cpp
@@ -151,8 +151,13 @@ void GRPrintText( wxDC* aDC, const VECTOR2I& aPos, const COLOR4D& aColor, const
if( !aFont )
aFont = KIFONT::FONT::GetFont();
- if( aWidth == 0 && aBold ) // Use default values if aWidth == 0
- aWidth = GetPenSizeForBold( std::min( aSize.x, aSize.y ) );
+ if( aWidth == 0 ) // Use default values if aWidth == 0
+ {
+ if( aBold )
+ aWidth = GetPenSizeForBold( std::min( aSize.x, aSize.y ) );
+ else
+ aWidth = GetPenSizeForNormal( std::min( aSize.x, aSize.y ) );
+ }
if( aWidth < 0 )
{
diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt
index a3c994fd3f..7ace801cd1 100644
--- a/eeschema/CMakeLists.txt
+++ b/eeschema/CMakeLists.txt
@@ -353,7 +353,6 @@ set( EESCHEMA_SRCS
generate_alias_info.cpp
gfx_import_utils.cpp
picksymbol.cpp
- lib_pin.cpp
lib_symbol.cpp
libarch.cpp
menubar.cpp
diff --git a/eeschema/api/api_sch_utils.cpp b/eeschema/api/api_sch_utils.cpp
index 62cb03db60..99faa38a99 100644
--- a/eeschema/api/api_sch_utils.cpp
+++ b/eeschema/api/api_sch_utils.cpp
@@ -18,7 +18,7 @@
* with this program. If not, see .
*/
-#include
+#include
#include
#include
#include
@@ -41,10 +41,6 @@
std::unique_ptr CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer )
{
SCH_ITEM* parentSchItem = dynamic_cast( aContainer );
- LIB_SYMBOL* parentLibSymbol = nullptr;
-
- if( aContainer && aContainer->Type() == LIB_SYMBOL_T )
- parentLibSymbol = static_cast( aContainer );
switch( aType )
{
@@ -83,13 +79,13 @@ std::unique_ptr CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer
case SCH_PIN_T:
{
- // TODO: constructing currently requires LIB_PIN and SCH_SYMBOL ptr,
- // or SCH_SYMBOL and number+alt. Need to determine ideal default ctor.
+ if( aContainer && aContainer->Type() == LIB_SYMBOL_T )
+ return std::make_unique( static_cast( aContainer ) );
+
return nullptr;
}
case LIB_SYMBOL_T: return nullptr; // TODO: ctor currently requires non-null name
- case LIB_PIN_T: return std::make_unique( parentLibSymbol );
default:
return nullptr;
diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp
index 4e460639e4..78a59e2cf2 100644
--- a/eeschema/autoplace_fields.cpp
+++ b/eeschema/autoplace_fields.cpp
@@ -53,10 +53,9 @@
#include
#include
-#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp
index 16aa9ebc8b..13c292dd37 100644
--- a/eeschema/connection_graph.cpp
+++ b/eeschema/connection_graph.cpp
@@ -654,9 +654,7 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
}
else if( item->Type() == SCH_SHEET_T )
{
- SCH_SHEET* sheet = static_cast( item );
-
- for( SCH_SHEET_PIN* pin : sheet->GetPins() )
+ for( SCH_SHEET_PIN* pin : static_cast( item )->GetPins() )
{
if( pin->IsConnectivityDirty() )
{
@@ -976,7 +974,7 @@ void CONNECTION_GRAPH::removeSubgraphs( std::set& aSubgrap
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 );
else
++it;
@@ -984,7 +982,7 @@ void CONNECTION_GRAPH::removeSubgraphs( std::set& aSubgrap
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 );
else
++it;
@@ -1657,7 +1655,7 @@ void CONNECTION_GRAPH::processSubGraphs()
{
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 );
wxLogTrace( ConnTrace,
@@ -2388,7 +2386,7 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo
{
if( !candidate->m_strong_driver
|| candidate->m_hier_ports.empty()
- || visited.count( candidate ) )
+ || visited.contains( candidate ) )
{
continue;
}
@@ -2425,7 +2423,7 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo
for( CONNECTION_SUBGRAPH* candidate : it->second )
{
if( candidate->m_hier_pins.empty()
- || visited.count( candidate )
+ || visited.contains( candidate )
|| candidate->m_driver_connection->Type() != aParent->m_driver_connection->Type() )
{
continue;
@@ -3470,7 +3468,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
if( pin )
{
ercItem->SetItems( pin, aSubgraph->m_no_connect );
- pos = pin->GetTransformedPosition();
+ pos = pin->GetPosition();
}
else
{
@@ -3586,7 +3584,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
ercItem->SetItemsSheetPaths( sheet );
ercItem->SetItems( pin );
- SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetTransformedPosition() );
+ SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetPosition() );
screen->Append( marker );
ok = false;
@@ -3611,8 +3609,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
ercItem->SetItemsSheetPaths( sheet );
ercItem->SetItems( testPin );
- SCH_MARKER* marker = new SCH_MARKER( ercItem,
- testPin->GetTransformedPosition() );
+ SCH_MARKER* marker = new SCH_MARKER( ercItem, testPin->GetPosition() );
screen->Append( marker );
ok = false;
diff --git a/eeschema/dialogs/dialog_erc.h b/eeschema/dialogs/dialog_erc.h
index 3bc539bbfa..c8883dd78c 100644
--- a/eeschema/dialogs/dialog_erc.h
+++ b/eeschema/dialogs/dialog_erc.h
@@ -26,11 +26,9 @@
#define _DIALOG_ERC_H_
#include
-#include // For PINTYPE_COUNT definition
#include
#include
-#include
/**
diff --git a/eeschema/dialogs/dialog_field_properties.cpp b/eeschema/dialogs/dialog_field_properties.cpp
index 26c92bbae4..5afb397253 100644
--- a/eeschema/dialogs/dialog_field_properties.cpp
+++ b/eeschema/dialogs/dialog_field_properties.cpp
@@ -162,14 +162,10 @@ DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const
* pinNumber pinName pinNumber pinName...
* fpFilter fpFilter...
*/
- wxString netlist;
-
- std::vector pinList;
- symbol->GetPins( pinList, 0, 1 ); // All units, but a single convert
-
+ wxString netlist;
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() );
if( !pins.IsEmpty() )
diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
index 8ece0263b3..d4bc958c85 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
+++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp
@@ -23,8 +23,8 @@
#include "dialog_lib_edit_pin_table.h"
#include "grid_tricks.h"
-#include "lib_pin.h"
-#include "pin_numbers.h"
+#include
+#include
#include "pgm_base.h"
#include
#include
@@ -155,7 +155,7 @@ public:
return GetValue( m_rows[ aRow ], aCol, m_frame );
}
- static wxString GetValue( const std::vector& pins, int aCol,
+ static wxString GetValue( const std::vector& pins, int aCol,
EDA_DRAW_FRAME* aParentFrame )
{
wxString fieldValue;
@@ -163,7 +163,7 @@ public:
if( pins.empty() )
return fieldValue;
- for( LIB_PIN* pin : pins )
+ for( SCH_PIN* pin : pins )
{
wxString val;
@@ -292,7 +292,7 @@ public:
break;
}
- std::vector pins = m_rows[ aRow ];
+ std::vector pins = m_rows[ aRow ];
// If the NUMBER column is edited and the pins are grouped, renumber, and add or
// remove pins based on the comma separated list of pins.
@@ -316,8 +316,8 @@ public:
else
{
// Create new pins
- LIB_PIN* newPin = new LIB_PIN( this->m_symbol );
- LIB_PIN* last = pins.back();
+ SCH_PIN* newPin = new SCH_PIN( this->m_symbol );
+ SCH_PIN* last = pins.back();
newPin->SetNumber( pinName );
newPin->SetName( last->GetName() );
@@ -361,7 +361,7 @@ public:
return;
}
- for( LIB_PIN* pin : pins )
+ for( SCH_PIN* pin : pins )
{
switch( aCol )
{
@@ -454,7 +454,7 @@ public:
m_edited = true;
}
- static int findRow( const std::vector>& aRowSet, const wxString& aName )
+ static int findRow( const std::vector>& aRowSet, const wxString& aName )
{
for( size_t i = 0; i < aRowSet.size(); ++i )
{
@@ -465,7 +465,7 @@ public:
return -1;
}
- static bool compare( const std::vector& lhs, const std::vector& rhs,
+ static bool compare( const std::vector& lhs, const std::vector& rhs,
int sortCol, bool ascending, EDA_DRAW_FRAME* parentFrame )
{
wxString lhStr = GetValue( lhs, sortCol, parentFrame );
@@ -518,10 +518,10 @@ public:
return res;
}
- void RebuildRows( const std::vector& aPins, bool groupByName, bool groupBySelection )
+ void RebuildRows( const std::vector& aPins, bool groupByName, bool groupBySelection )
{
WX_GRID* grid = dynamic_cast( GetView() );
- std::vector clear_flags;
+ std::vector clear_flags;
clear_flags.reserve( aPins.size() );
@@ -529,7 +529,7 @@ public:
{
if( groupBySelection )
{
- for( LIB_PIN* pin : aPins )
+ for( SCH_PIN* pin : aPins )
pin->ClearTempFlags();
int firstSelectedRow;
@@ -539,7 +539,7 @@ public:
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 );
clear_flags.push_back( pin );
@@ -558,9 +558,9 @@ public:
m_rows.clear();
if( groupBySelection )
- m_rows.emplace_back( std::vector() );
+ m_rows.emplace_back( std::vector() );
- for( LIB_PIN* pin : aPins )
+ for( SCH_PIN* pin : aPins )
{
if( m_unitFilter == -1 || pin->GetUnit() == 0 || pin->GetUnit() == m_unitFilter )
{
@@ -573,7 +573,7 @@ public:
if( rowIndex < 0 )
{
- m_rows.emplace_back( std::vector() );
+ m_rows.emplace_back( std::vector() );
rowIndex = m_rows.size() - 1;
}
@@ -590,7 +590,7 @@ public:
ascending = GetView()->IsSortOrderAscending();
}
- for( std::vector& row : m_rows )
+ for( std::vector& row : m_rows )
SortPins( row );
if( !groupBySelection )
@@ -605,32 +605,32 @@ public:
GetView()->SelectRow( 0 );
}
- for( LIB_PIN* pin : clear_flags )
+ for( SCH_PIN* pin : clear_flags )
pin->ClearFlags( CANDIDATE );
}
void SortRows( int aSortCol, bool ascending )
{
std::sort( m_rows.begin(), m_rows.end(),
- [ aSortCol, ascending, this ]( const std::vector& lhs,
- const std::vector& rhs ) -> bool
+ [ aSortCol, ascending, this ]( const std::vector& lhs,
+ const std::vector& rhs ) -> bool
{
return compare( lhs, rhs, aSortCol, ascending, m_frame );
} );
}
- void SortPins( std::vector& aRow )
+ void SortPins( std::vector& aRow )
{
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;
} );
}
- void AppendRow( LIB_PIN* aPin )
+ void AppendRow( SCH_PIN* aPin )
{
- std::vector row;
+ std::vector row;
row.push_back( aPin );
m_rows.push_back( row );
@@ -641,9 +641,9 @@ public:
}
}
- std::vector RemoveRow( int aRow )
+ std::vector RemoveRow( int aRow )
{
- std::vector removedRow = m_rows[ aRow ];
+ std::vector removedRow = m_rows[ aRow ];
m_rows.erase( m_rows.begin() + aRow );
@@ -656,7 +656,7 @@ public:
return removedRow;
}
- std::vector GetRowPins( int aRow )
+ std::vector GetRowPins( int aRow )
{
return m_rows[ aRow ];
}
@@ -698,9 +698,9 @@ private:
SYMBOL_EDIT_FRAME* m_frame;
// Because the rows of the grid can either be a single pin or a group of pins, the
- // data model is a 2D vector. If we're in the single pin case, each row's LIB_PINs
+ // data model is a 2D vector. If we're in the single pin case, each row's SCH_PINs
// contains only a single pin.
- std::vector> m_rows;
+ std::vector> m_rows;
int m_unitFilter; // 0 to show pins for all units
bool m_edited;
@@ -709,7 +709,7 @@ private:
LIB_SYMBOL* m_symbol; // Parent symbol that the pins belong to.
std::unique_ptr m_eval;
- std::map< std::pair, int>, wxString > m_evalOriginal;
+ std::map< std::pair, 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
// m_pins will already be empty.
- for( LIB_PIN* pin : m_pins )
+ for( SCH_PIN* pin : m_pins )
delete pin;
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()
{
// Make a copy of the pins for editing
- std::vector pins = m_symbol->GetAllLibPins();
+ std::vector pins = m_symbol->GetAllLibPins();
- for( LIB_PIN* pin : pins )
- m_pins.push_back( new LIB_PIN( *pin ) );
+ for( SCH_PIN* pin : pins )
+ m_pins.push_back( new SCH_PIN( *pin ) );
m_dataModel->RebuildRows( m_pins, m_cbGroup->GetValue(), false );
@@ -908,16 +908,14 @@ bool DIALOG_LIB_EDIT_PIN_TABLE::TransferDataFromWindow()
return false;
// Delete the part's pins
- std::vector pins = m_symbol->GetAllLibPins();
+ std::vector pins = m_symbol->GetAllLibPins();
- for( LIB_PIN* pin : pins )
+ for( SCH_PIN* pin : pins )
m_symbol->RemoveDrawItem( pin );
// Transfer our pins to the part
- for( LIB_PIN* pin : m_pins )
- {
+ for( SCH_PIN* pin : m_pins )
m_symbol->AddDrawItem( pin );
- }
m_pins.clear();
@@ -948,12 +946,12 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow( wxCommandEvent& event )
if( !m_grid->CommitPendingChanges() )
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.
if( m_pins.size() > 0 )
{
- LIB_PIN* last = m_pins.back();
+ SCH_PIN* last = m_pins.back();
newPin->SetOrientation( last->GetOrientation() );
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 );
updateSummary();
@@ -1018,16 +1016,16 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow( wxCommandEvent& event )
m_grid->SetGridCursor( nextSelRow, m_grid->GetGridCursorCol() );
m_grid->SelectRow( nextSelRow );
- std::vector removedRow = m_dataModel->RemoveRow( curRow );
+ std::vector 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 ) );
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 ) );
updateSummary();
@@ -1042,15 +1040,15 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnCellEdited( 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() )
{
- const std::vector& pins = m_dataModel->GetRowPins( event.GetRow() );
+ const std::vector& pins = m_dataModel->GetRowPins( event.GetRow() );
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() )
{
@@ -1256,7 +1254,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::updateSummary()
{
PIN_NUMBERS pinNumbers;
- for( LIB_PIN* pin : m_pins )
+ for( SCH_PIN* pin : m_pins )
{
if( pin->GetNumber().Length() )
pinNumbers.insert( pin->GetNumber() );
diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.h b/eeschema/dialogs/dialog_lib_edit_pin_table.h
index 2069a658ab..937c25e09e 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin_table.h
+++ b/eeschema/dialogs/dialog_lib_edit_pin_table.h
@@ -23,8 +23,7 @@
#include "dialog_lib_edit_pin_table_base.h"
-#include
-#include
+#include
enum COL_ORDER
{
@@ -73,8 +72,8 @@ public:
void OnUpdateUI( wxUpdateUIEvent& event ) override;
void OnCancel( wxCommandEvent& event ) override;
void OnClose( wxCloseEvent& event ) override;
- void AddPin( LIB_PIN* pin );
- void RemovePin( LIB_PIN* pin );
+ void AddPin( SCH_PIN* pin );
+ void RemovePin( SCH_PIN* pin );
bool IsDisplayGrouped();
protected:
@@ -87,7 +86,7 @@ protected:
int m_originalColWidths[ COL_COUNT ];
std::bitset<64> m_columnsShown;
LIB_SYMBOL* m_symbol;
- std::vector m_pins; // a copy of the pins owned by me
+ std::vector m_pins; // a copy of the pins owned by me
bool m_modified; ///< true when there are unsaved changes
wxSize m_size;
diff --git a/eeschema/dialogs/dialog_pin_properties.cpp b/eeschema/dialogs/dialog_pin_properties.cpp
index 728bc61961..55bdc688b9 100644
--- a/eeschema/dialogs/dialog_pin_properties.cpp
+++ b/eeschema/dialogs/dialog_pin_properties.cpp
@@ -25,7 +25,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -36,7 +36,7 @@
#include
#include
-class ALT_PIN_DATA_MODEL : public wxGridTableBase, public std::vector
+class ALT_PIN_DATA_MODEL : public wxGridTableBase, public std::vector
{
public:
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 );
@@ -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 ),
m_frame( parent ),
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:
m_dummyParent = new LIB_SYMBOL( *static_cast( m_pin->GetParentSymbol() ) );
- m_dummyPin = new LIB_PIN( *m_pin );
+ m_dummyPin = new SCH_PIN( *m_pin );
m_dummyPin->SetParent( m_dummyParent );
m_dummyParent->SetShowPinNames( true );
m_dummyParent->SetShowPinNumbers( true );
@@ -306,7 +306,7 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow()
m_checkApplyToAllParts->SetToolTip( commonUnitsToolTip );
- for( const std::pair& alt : m_pin->GetAlternates() )
+ for( const std::pair& alt : m_pin->GetAlternates() )
m_alternatesDataModel->AppendRow( alt.second );
return true;
@@ -364,10 +364,10 @@ bool DIALOG_PIN_PROPERTIES::TransferDataFromWindow()
m_pin->SetUnit( m_checkApplyToAllParts->GetValue() ? 0 : m_frame->GetUnit() );
m_pin->SetVisible( m_checkShow->GetValue() );
- std::map& alternates = m_pin->GetAlternates();
+ std::map& alternates = m_pin->GetAlternates();
alternates.clear();
- for( const LIB_PIN::ALT& alt : *m_alternatesDataModel )
+ for( const SCH_PIN::ALT& alt : *m_alternatesDataModel )
alternates[ alt.m_Name ] = alt;
return true;
@@ -450,7 +450,7 @@ void DIALOG_PIN_PROPERTIES::OnAddAlternate( wxCommandEvent& event )
if( !m_alternatesGrid->CommitPendingChanges() )
return;
- LIB_PIN::ALT newAlt;
+ SCH_PIN::ALT newAlt;
newAlt.m_Name = wxEmptyString;
newAlt.m_Type = m_pin->GetType();
newAlt.m_Shape = m_pin->GetShape();
diff --git a/eeschema/dialogs/dialog_pin_properties.h b/eeschema/dialogs/dialog_pin_properties.h
index 14cf7dc88b..6f79bba94a 100644
--- a/eeschema/dialogs/dialog_pin_properties.h
+++ b/eeschema/dialogs/dialog_pin_properties.h
@@ -33,7 +33,7 @@
#include
#include
-#include
+#include
#include
@@ -53,7 +53,7 @@ class ALT_PIN_DATA_MODEL;
class DIALOG_PIN_PROPERTIES : public DIALOG_PIN_PROPERTIES_BASE
{
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;
bool TransferDataToWindow() override;
@@ -73,10 +73,10 @@ protected:
private:
SYMBOL_EDIT_FRAME* m_frame;
- LIB_PIN* m_pin;
+ SCH_PIN* m_pin;
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_posY;
diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp
index 38866c7726..2584b4a53c 100644
--- a/eeschema/dialogs/dialog_sim_model.cpp
+++ b/eeschema/dialogs/dialog_sim_model.cpp
@@ -79,7 +79,7 @@ DIALOG_SIM_MODEL::DIALOG_SIM_MODEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame
{
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
if( !pin->GetParentSymbol()->HasAlternateBodyStyle() || pin->GetBodyStyle() < 2 )
@@ -87,7 +87,7 @@ DIALOG_SIM_MODEL::DIALOG_SIM_MODEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame
}
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.
return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0;
@@ -1064,7 +1064,7 @@ int DIALOG_SIM_MODEL::findSymbolPinRow( const wxString& aSymbolPinNumber ) co
{
for( int row = 0; row < static_cast( m_sortedPartPins.size() ); ++row )
{
- LIB_PIN* pin = m_sortedPartPins[row];
+ SCH_PIN* pin = m_sortedPartPins[row];
if( pin->GetNumber() == aSymbolPinNumber )
return row;
@@ -1107,7 +1107,7 @@ const SIM_LIBRARY* DIALOG_SIM_MODEL::library() const
template
wxString DIALOG_SIM_MODEL::getSymbolPinString( int symbolPinIndex ) const
{
- LIB_PIN* pin = m_sortedPartPins.at( symbolPinIndex );
+ SCH_PIN* pin = m_sortedPartPins.at( symbolPinIndex );
wxString pinNumber;
wxString pinName;
diff --git a/eeschema/dialogs/dialog_sim_model.h b/eeschema/dialogs/dialog_sim_model.h
index 62184a37d9..daae964f62 100644
--- a/eeschema/dialogs/dialog_sim_model.h
+++ b/eeschema/dialogs/dialog_sim_model.h
@@ -130,7 +130,7 @@ private:
wxString m_prevLibrary;
const SIM_MODEL* m_prevModel;
- std::vector m_sortedPartPins; //< Pins of the current part.
+ std::vector m_sortedPartPins; //< Pins of the current part.
std::map m_curModelTypeOfDeviceType;
SIM_MODEL::TYPE m_curModelType;
diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp
index 6a279efa81..a735de0600 100644
--- a/eeschema/dialogs/dialog_symbol_properties.cpp
+++ b/eeschema/dialogs/dialog_symbol_properties.cpp
@@ -100,7 +100,7 @@ public:
for( const SCH_PIN& pin : *this )
{
- LIB_PIN* lib_pin = pin.GetLibPin();
+ SCH_PIN* lib_pin = pin.GetLibPin();
wxGridCellAttr* attr = nullptr;
if( lib_pin->GetAlternates().empty() )
@@ -114,7 +114,7 @@ public:
wxArrayString choices;
choices.push_back( lib_pin->GetName() );
- for( const std::pair& alt : lib_pin->GetAlternates() )
+ for( const std::pair& alt : lib_pin->GetAlternates() )
choices.push_back( alt.first );
attr = new wxGridCellAttr();
diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp
index 9cbd75949f..63c1aa058e 100644
--- a/eeschema/dialogs/panel_eeschema_color_settings.cpp
+++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp
@@ -389,7 +389,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
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->SetLength( schIUScale.MilsToIU( 100 ) );
@@ -403,7 +403,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
endPointsByType.emplace_back( PIN_END, pin, mapLibItemPosition( pin->GetPosition() ) );
symbol->AddDrawItem( pin );
- pin = new LIB_PIN( symbol );
+ pin = new SCH_PIN( symbol );
pin->SetPosition( MILS_POINT( p.x - 300, p.y - 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() ) );
symbol->AddDrawItem( pin );
- pin = new LIB_PIN( symbol );
+ pin = new SCH_PIN( symbol );
pin->SetPosition( MILS_POINT( p.x + 300, p.y ) );
pin->SetLength( schIUScale.MilsToIU( 100 ) );
diff --git a/eeschema/dialogs/panel_setup_pinmap.h b/eeschema/dialogs/panel_setup_pinmap.h
index debe3fb48c..8d22e43ab5 100644
--- a/eeschema/dialogs/panel_setup_pinmap.h
+++ b/eeschema/dialogs/panel_setup_pinmap.h
@@ -25,7 +25,7 @@
#ifndef _PANEL_SETUP_PINMAP_H_
#define _PANEL_SETUP_PINMAP_H_
-#include // For PINTYPE_COUNT definition
+#include // For PINTYPE_COUNT definition
#include
#include "panel_setup_pinmap_base.h"
diff --git a/eeschema/ee_collectors.cpp b/eeschema/ee_collectors.cpp
index 1b4f57735a..a4194c7129 100644
--- a/eeschema/ee_collectors.cpp
+++ b/eeschema/ee_collectors.cpp
@@ -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
// 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 )
return INSPECT_RESULT::CONTINUE;
diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp
index 9f015cc7df..c8243321e9 100644
--- a/eeschema/erc.cpp
+++ b/eeschema/erc.cpp
@@ -34,7 +34,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -493,8 +493,7 @@ int ERC_TESTER::TestMissingUnits()
for( int missing_unit : missing_units )
{
- std::vector pins;
- int bodyStyle = 0;
+ int bodyStyle = 0;
for( size_t ii = 0; ii < refList.GetCount(); ++ii )
{
@@ -505,9 +504,7 @@ int ERC_TESTER::TestMissingUnits()
}
}
- libSymbol->GetPins( pins, missing_unit, bodyStyle );
-
- for( LIB_PIN* pin : pins )
+ for( SCH_PIN* pin : libSymbol->GetPins( missing_unit, bodyStyle ) )
{
switch( pin->GetType() )
{
@@ -728,7 +725,7 @@ int ERC_TESTER::TestPinToPin()
ERC_SCH_PIN_CONTEXT& refPin = *refIt;
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
// 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();
if( ispowerNet )
- hasDriver |= ( DrivingPowerPinTypes.count( testType ) != 0 );
+ hasDriver |= DrivingPowerPinTypes.contains( testType );
else
- hasDriver |= ( DrivingPinTypes.count( testType ) != 0 );
+ hasDriver |= DrivingPinTypes.contains( testType );
PIN_ERROR erc = settings.GetPinMapValue( refType, testType );
@@ -782,8 +779,7 @@ int ERC_TESTER::TestPinToPin()
ElectricalPinTypeGetText( refType ),
ElectricalPinTypeGetText( testType ) ) );
- SCH_MARKER* marker = new SCH_MARKER( ercItem,
- refPin.Pin()->GetTransformedPosition() );
+ SCH_MARKER* marker = new SCH_MARKER( ercItem, refPin.Pin()->GetPosition() );
pinToScreenMap[refPin.Pin()]->Append( marker );
errors++;
}
@@ -802,8 +798,7 @@ int ERC_TESTER::TestPinToPin()
ercItem->SetSheetSpecificPath( needsDriver.Sheet() );
ercItem->SetItemsSheetPaths( needsDriver.Sheet() );
- SCH_MARKER* marker = new SCH_MARKER( ercItem,
- needsDriver.Pin()->GetTransformedPosition() );
+ SCH_MARKER* marker = new SCH_MARKER( ercItem, needsDriver.Pin()->GetPosition() );
pinToScreenMap[needsDriver.Pin()]->Append( marker );
errors++;
}
@@ -860,8 +855,7 @@ int ERC_TESTER::TestMultUnitPinConflicts()
ercItem->SetSheetSpecificPath( sheet );
ercItem->SetItemsSheetPaths( sheet, sheet );
- SCH_MARKER* marker = new SCH_MARKER( ercItem,
- pin->GetTransformedPosition() );
+ SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetPosition() );
sheet.LastScreen()->Append( marker );
errors += 1;
}
@@ -1159,7 +1153,7 @@ int ERC_TESTER::TestOffGridEndpoints()
for( SCH_PIN* pin : symbol->GetPins( nullptr ) )
{
- VECTOR2I pinPos = pin->GetTransformedPosition();
+ VECTOR2I pinPos = pin->GetPosition();
if( ( pinPos.x % gridSize ) != 0 || ( pinPos.y % gridSize ) != 0 )
{
diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp
index 48dbf4c099..77d8273d20 100644
--- a/eeschema/fields_grid_table.cpp
+++ b/eeschema/fields_grid_table.cpp
@@ -99,15 +99,10 @@ static wxString netList( LIB_SYMBOL* aSymbol )
* pinNumber pinName pinNumber pinName...
* fpFilter fpFilter...
*/
- wxString netlist;
-
- std::vector pinList;
-
- aSymbol->GetPins( pinList, 0, 1 ); // All units, but a single convert
-
+ wxString netlist;
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() );
if( !pins.IsEmpty() )
diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
deleted file mode 100644
index eb0d2b4754..0000000000
--- a/eeschema/lib_pin.cpp
+++ /dev/null
@@ -1,1707 +0,0 @@
-/*
- * This program source code file is part of KiCad, a free EDA CAD application.
- *
- * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
- * Copyright (C) 2015 Wayne Stambaugh
- * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you may find one here:
- * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
- * or you may search the http://www.gnu.org website for the version 2 license,
- * or you may write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "sch_painter.h"
-#include "plotters/plotter.h"
-
-
-// small margin in internal units between the pin text and the pin line
-#define PIN_TEXT_MARGIN 4
-
-const wxString LIB_PIN::GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType )
-{
- // These strings are the canonical name of the electrictal type
- // Not translated, no space in name, only ASCII chars.
- // to use when the string name must be known and well defined
- // must have same order than enum ELECTRICAL_PINTYPE (see lib_pin.h)
- static const wxChar* msgPinElectricType[] =
- {
- wxT( "input" ),
- wxT( "output" ),
- wxT( "bidirectional" ),
- wxT( "tri_state" ),
- wxT( "passive" ),
- wxT( "free" ),
- wxT( "unspecified" ),
- wxT( "power_in" ),
- wxT( "power_out" ),
- wxT( "open_collector" ),
- wxT( "open_emitter" ),
- wxT( "no_connect" )
- };
-
- return msgPinElectricType[static_cast( aType )];
-}
-
-
-/// Utility for getting the size of the 'internal' pin decorators (as a radius)
-// i.e. the clock symbols (falling clock is actually external but is of
-// the same kind)
-
-static int internalPinDecoSize( const RENDER_SETTINGS* aSettings, const LIB_PIN &aPin )
-{
- const SCH_RENDER_SETTINGS* settings = static_cast( aSettings );
-
- if( settings && settings->m_PinSymbolSize )
- return settings->m_PinSymbolSize;
-
- return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
-}
-
-/// 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
-static int externalPinDecoSize( const RENDER_SETTINGS* aSettings, const LIB_PIN &aPin )
-{
- const SCH_RENDER_SETTINGS* settings = static_cast( aSettings );
-
- if( settings && settings->m_PinSymbolSize )
- return settings->m_PinSymbolSize;
-
- return aPin.GetNumberTextSize() / 2;
-}
-
-
-LIB_PIN::LIB_PIN( SCH_ITEM* aParent ) :
- SCH_ITEM( aParent, LIB_PIN_T, 0, 0 ),
- m_orientation( PIN_ORIENTATION::PIN_RIGHT ),
- m_shape( GRAPHIC_PINSHAPE::LINE ),
- m_type( ELECTRICAL_PINTYPE::PT_UNSPECIFIED ),
- m_attributes( 0 )
-{
- // Use the application settings for pin sizes if exists.
- // pgm can be nullptr when running a shared lib from a script, not from a kicad appl
- PGM_BASE* pgm = PgmOrNull();
-
- if( pgm )
- {
- auto* settings = pgm->GetSettingsManager().GetAppSettings();
- m_length = schIUScale.MilsToIU( settings->m_Defaults.pin_length );
- m_numTextSize = schIUScale.MilsToIU( settings->m_Defaults.pin_num_size );
- m_nameTextSize = schIUScale.MilsToIU( settings->m_Defaults.pin_name_size );
- }
- else // Use hardcoded eeschema defaults: symbol_editor settings are not existing.
- {
- m_length = schIUScale.MilsToIU( DEFAULT_PIN_LENGTH );
- m_numTextSize = schIUScale.MilsToIU( DEFAULT_PINNUM_SIZE );
- m_nameTextSize = schIUScale.MilsToIU( DEFAULT_PINNAME_SIZE );
- }
-}
-
-
-LIB_PIN::LIB_PIN( SCH_ITEM* aParent, const wxString& aName, const wxString& aNumber,
- PIN_ORIENTATION aOrientation, ELECTRICAL_PINTYPE aPinType, int aLength,
- int aNameTextSize, int aNumTextSize, int aBodyStyle, const VECTOR2I& aPos,
- int aUnit ) :
- SCH_ITEM( aParent, LIB_PIN_T, aUnit, aBodyStyle ),
- m_position( aPos ),
- m_length( aLength ),
- m_orientation( aOrientation ),
- m_shape( GRAPHIC_PINSHAPE::LINE ),
- m_type( aPinType ),
- m_attributes( 0 ),
- m_numTextSize( aNumTextSize ),
- m_nameTextSize( aNameTextSize )
-{
- SetName( aName );
- SetNumber( aNumber );
-}
-
-
-bool LIB_PIN::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
-{
- BOX2I rect = GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE );
-
- return rect.Inflate( aAccuracy ).Contains( aPosition );
-}
-
-
-bool LIB_PIN::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
-{
- if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) )
- return false;
-
- BOX2I sel = aRect;
-
- if ( aAccuracy )
- sel.Inflate( aAccuracy );
-
- if( aContained )
- return sel.Contains( GetBoundingBox( false, false, false ) );
-
- return sel.Intersects( GetBoundingBox( false, true, m_flags & SHOW_ELEC_TYPE ) );
-}
-
-
-int LIB_PIN::GetPenWidth() const
-{
- return 0;
-}
-
-
-wxString LIB_PIN::GetShownName() const
-{
- if( m_name == wxS( "~" ) )
- return wxEmptyString;
- else
- return m_name;
-}
-
-
-VECTOR2I LIB_PIN::GetPinRoot() const
-{
- switch( m_orientation )
- {
- default:
- case PIN_ORIENTATION::PIN_RIGHT: return VECTOR2I( m_position.x + m_length, -( m_position.y ) );
- case PIN_ORIENTATION::PIN_LEFT: return VECTOR2I( m_position.x - m_length, -( m_position.y ) );
- case PIN_ORIENTATION::PIN_UP: return VECTOR2I( m_position.x, -( m_position.y + m_length ) );
- case PIN_ORIENTATION::PIN_DOWN: return VECTOR2I( m_position.x, -( m_position.y - m_length ) );
- }
-}
-
-
-void LIB_PIN::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
- const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
-{
- LIB_SYMBOL* part = dynamic_cast( GetParentSymbol() );
-
- wxCHECK( part && aSettings, /* void */ );
-
- /* Calculate pin orient taking in account the symbol orientation. */
- PIN_ORIENTATION orient = PinDrawOrient( aSettings->m_Transform );
-
- /* Calculate the pin position */
- VECTOR2I pos1 = aSettings->TransformCoordinate( m_position ) + aOffset;
-
- if( IsVisible() || aSettings->m_ShowHiddenFields )
- {
- printPinSymbol( aSettings, pos1, orient, aDimmed );
-
- printPinTexts( aSettings, pos1, orient, part->GetPinNameOffset(),
- aSettings->m_ShowPinNumbers || part->GetShowPinNumbers(),
- aSettings->m_ShowPinNames || part->GetShowPinNames(),
- aDimmed );
-
- if( aSettings->m_ShowPinElectricalTypes )
- printPinElectricalTypeName( aSettings, pos1, orient, aDimmed );
-
- if( aSettings->m_ShowConnectionPoints
- && m_type != ELECTRICAL_PINTYPE::PT_NC
- && m_type != ELECTRICAL_PINTYPE::PT_NIC )
- {
- wxDC* DC = aSettings->GetPrintDC();
- COLOR4D color = aSettings->GetLayerColor( IsVisible() ? LAYER_PIN : LAYER_HIDDEN );
-
- COLOR4D bg = aSettings->GetBackgroundColor();
-
- if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
- bg = COLOR4D::WHITE;
-
- if( aDimmed )
- {
- color.Desaturate( );
- color = color.Mix( bg, 0.5f );
- }
-
- GRCircle( DC, pos1, TARGET_PIN_RADIUS, 0, color );
- }
- }
-}
-
-
-void LIB_PIN::printPinSymbol( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aPos,
- PIN_ORIENTATION aOrient, bool aDimmed )
-{
- wxDC* DC = aSettings->GetPrintDC();
- int MapX1, MapY1, x1, y1;
- int width = GetEffectivePenWidth( aSettings );
- int posX = aPos.x, posY = aPos.y, len = m_length;
- COLOR4D color = aSettings->GetLayerColor( IsVisible() ? LAYER_PIN : LAYER_HIDDEN );
- COLOR4D bg = aSettings->GetBackgroundColor();
-
- if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
- bg = COLOR4D::WHITE;
-
- if( !IsVisible() )
- bg = aSettings->GetLayerColor( LAYER_HIDDEN );
-
- if( aDimmed )
- {
- color.Desaturate( );
- color = color.Mix( bg, 0.5f );
- }
-
- MapX1 = MapY1 = 0;
- x1 = posX;
- y1 = posY;
-
- switch( aOrient )
- {
- case PIN_ORIENTATION::PIN_UP: y1 = posY - len; MapY1 = 1; break;
- case PIN_ORIENTATION::PIN_DOWN: y1 = posY + len; MapY1 = -1; break;
- case PIN_ORIENTATION::PIN_LEFT: x1 = posX - len; MapX1 = 1; break;
- case PIN_ORIENTATION::PIN_RIGHT: x1 = posX + len; MapX1 = -1; break;
- }
-
- if( m_shape == GRAPHIC_PINSHAPE::INVERTED || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK )
- {
- const int radius = externalPinDecoSize( aSettings, *this );
- GRCircle( DC, VECTOR2I( MapX1 * radius + x1, MapY1 * radius + y1 ), radius, width, color );
-
- GRMoveTo( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 );
- GRLineTo( DC, posX, posY, width, color );
- }
- else
- {
- GRMoveTo( x1, y1 );
- GRLineTo( DC, posX, posY, width, color );
- }
-
- // Draw the clock shape (>)inside the symbol
- if( m_shape == GRAPHIC_PINSHAPE::CLOCK
- || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK
- || m_shape == GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK
- || m_shape == GRAPHIC_PINSHAPE::CLOCK_LOW )
- {
- const int clock_size = internalPinDecoSize( aSettings, *this );
- if( MapY1 == 0 ) /* MapX1 = +- 1 */
- {
- GRMoveTo( x1, y1 + clock_size );
- GRLineTo( DC, x1 - MapX1 * clock_size * 2, y1, width, color );
- GRLineTo( DC, x1, y1 - clock_size, width, color );
- }
- else /* MapX1 = 0 */
- {
- GRMoveTo( x1 + clock_size, y1 );
- GRLineTo( DC, x1, y1 - MapY1 * clock_size * 2, width, color );
- GRLineTo( DC, x1 - clock_size, y1, width, color );
- }
- }
-
- // Draw the active low (or H to L active transition)
- if( m_shape == GRAPHIC_PINSHAPE::INPUT_LOW
- || m_shape == GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK
- || m_shape == GRAPHIC_PINSHAPE::CLOCK_LOW )
- {
- const int deco_size = externalPinDecoSize( aSettings, *this );
- if( MapY1 == 0 ) /* MapX1 = +- 1 */
- {
- GRMoveTo( x1 + MapX1 * deco_size * 2, y1 );
- GRLineTo( DC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width, color );
- GRLineTo( DC, x1, y1, width, color );
- }
- else /* MapX1 = 0 */
- {
- GRMoveTo( x1, y1 + MapY1 * deco_size * 2 );
- GRLineTo( DC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width, color );
- GRLineTo( DC, x1, y1, width, color );
- }
- }
-
- if( m_shape == GRAPHIC_PINSHAPE::OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
- {
- const int deco_size = externalPinDecoSize( aSettings, *this );
- if( MapY1 == 0 ) /* MapX1 = +- 1 */
- {
- GRMoveTo( x1, y1 - deco_size * 2 );
- GRLineTo( DC, x1 + MapX1 * deco_size * 2, y1, width, color );
- }
- else /* MapX1 = 0 */
- {
- GRMoveTo( x1 - deco_size * 2, y1 );
- GRLineTo( DC, x1, y1 + MapY1 * deco_size * 2, width, color );
- }
- }
- else if( m_shape == GRAPHIC_PINSHAPE::NONLOGIC ) /* NonLogic pin symbol */
- {
- const int deco_size = externalPinDecoSize( aSettings, *this );
- GRMoveTo( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size );
- GRLineTo( DC, x1 + (MapX1 + MapY1) * deco_size, y1 + ( MapY1 - MapX1 ) * deco_size, width,
- color );
- GRMoveTo( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size );
- GRLineTo( DC, x1 + (MapX1 - MapY1) * deco_size, y1 + ( MapY1 + MapX1 ) * deco_size, width,
- color );
- }
-
- if( m_type == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
- {
- const int deco_size = TARGET_PIN_RADIUS;
- GRLine( DC, posX - deco_size, posY - deco_size, posX + deco_size, posY + deco_size, width,
- color );
- GRLine( DC, posX + deco_size, posY - deco_size, posX - deco_size, posY + deco_size, width,
- color );
- }
-}
-
-
-void LIB_PIN::printPinTexts( const RENDER_SETTINGS* aSettings, VECTOR2I& aPinPos,
- PIN_ORIENTATION aPinOrient, int aTextInside, bool aDrawPinNum,
- bool aDrawPinName, bool aDimmed )
-{
- if( !aDrawPinName && !aDrawPinNum )
- return;
-
- KIFONT::FONT* font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), false, false );
- wxString name = GetShownName();
- wxString number = GetShownNumber();
- VECTOR2I nameSize( m_nameTextSize, m_nameTextSize );
- VECTOR2I numSize( m_numTextSize, m_numTextSize );
- int nameWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_nameTextSize, true ),
- aSettings->GetDefaultPenWidth() );
- int numWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_numTextSize, true ),
- aSettings->GetDefaultPenWidth() );
- int name_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + nameWidth;
- int num_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + numWidth;
-
- /* Get the num and name colors */
- COLOR4D nameColor = aSettings->GetLayerColor( IsVisible() ? LAYER_PINNAM : LAYER_HIDDEN );
- COLOR4D numColor = aSettings->GetLayerColor( IsVisible() ? LAYER_PINNUM : LAYER_HIDDEN );
- COLOR4D bg = aSettings->GetBackgroundColor();
-
- if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
- bg = COLOR4D::WHITE;
-
- if( !IsVisible() )
- bg = aSettings->GetLayerColor( LAYER_HIDDEN );
-
- if( aDimmed )
- {
- nameColor.Desaturate();
- numColor.Desaturate();
- nameColor = nameColor.Mix( bg, 0.5f );
- numColor = numColor.Mix( bg, 0.5f );
- }
-
- int x1 = aPinPos.x;
- int y1 = aPinPos.y;
-
- switch( aPinOrient )
- {
- case PIN_ORIENTATION::PIN_UP: y1 -= m_length; break;
- case PIN_ORIENTATION::PIN_DOWN: y1 += m_length; break;
- case PIN_ORIENTATION::PIN_LEFT: x1 -= m_length; break;
- case PIN_ORIENTATION::PIN_RIGHT: x1 += m_length; break;
- }
-
- if( name.IsEmpty() || m_nameTextSize == 0 )
- aDrawPinName = false;
-
- if( number.IsEmpty() || m_numTextSize == 0 )
- aDrawPinNum = false;
-
- auto printName =
- [&]( int x, int y, const EDA_ANGLE& angle, enum GR_TEXT_H_ALIGN_T hAlign,
- enum GR_TEXT_V_ALIGN_T vAlign )
- {
- GRPrintText( aSettings->GetPrintDC(), VECTOR2I( x, y ), nameColor, name, angle,
- nameSize, hAlign, vAlign, nameWidth, false, false, font, GetFontMetrics() );
- };
-
- auto printNum =
- [&]( int x, int y, const EDA_ANGLE& angle, enum GR_TEXT_H_ALIGN_T hAlign,
- enum GR_TEXT_V_ALIGN_T vAlign )
- {
- GRPrintText( aSettings->GetPrintDC(), VECTOR2I( x, y ), numColor, number, angle,
- numSize, hAlign, vAlign, numWidth, false, false, font, GetFontMetrics() );
- };
-
- if( aTextInside ) // Draw the text inside, but the pin numbers outside.
- {
- if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
- || ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
- {
- // It is an horizontal line
- if( aDrawPinName )
- {
- if( aPinOrient == PIN_ORIENTATION::PIN_RIGHT )
- {
- printName( x1 + aTextInside, y1, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER );
- }
- else // Orient == PIN_LEFT
- {
- printName( x1 - aTextInside, y1, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER );
- }
- }
-
- if( aDrawPinNum )
- {
- printNum( ( x1 + aPinPos.x ) / 2, y1 - num_offset, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- }
- else /* Its a vertical line. */
- {
- // Text is drawn from bottom to top (i.e. to negative value for Y axis)
- if( aPinOrient == PIN_ORIENTATION::PIN_DOWN )
- {
- if( aDrawPinName )
- {
- printName( x1, y1 + aTextInside, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER );
- }
-
- if( aDrawPinNum )
- {
- printNum( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- }
- else /* PIN_UP */
- {
- if( aDrawPinName )
- {
- printName( x1, y1 - aTextInside, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER );
- }
-
- if( aDrawPinNum )
- {
- printNum( x1 - num_offset, ( y1 + aPinPos.y) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- }
- }
- }
- else /**** Draw num & text pin outside ****/
- {
- if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
- || ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
- {
- /* Its an horizontal line. */
- if( aDrawPinName && aDrawPinNum )
- {
- printName( ( x1 + aPinPos.x ) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
-
- printNum( ( x1 + aPinPos.x ) / 2, y1 + num_offset, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP );
- }
- else if( aDrawPinName )
- {
- printName( ( x1 + aPinPos.x ) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- else if( aDrawPinNum )
- {
- printNum( ( x1 + aPinPos.x ) / 2, y1 - num_offset, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- }
- else /* Its a vertical line. */
- {
- if( aDrawPinName && aDrawPinNum )
- {
- printName( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
-
- printNum( x1 + num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP );
- }
- else if( aDrawPinName )
- {
- printName( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- else if( aDrawPinNum )
- {
- printNum( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- }
- }
-}
-
-
-void LIB_PIN::printPinElectricalTypeName( const RENDER_SETTINGS* aSettings, VECTOR2I& aPosition,
- PIN_ORIENTATION aOrientation, bool aDimmed )
-{
- wxDC* DC = aSettings->GetPrintDC();
- wxString typeName = GetElectricalTypeName();
-
- // Use a reasonable (small) size to draw the text
- int textSize = ( m_nameTextSize * 3 ) / 4;
-
- #define ETXT_MAX_SIZE schIUScale.mmToIU( 0.7 )
-
- if( textSize > ETXT_MAX_SIZE )
- textSize = ETXT_MAX_SIZE;
-
- // Use a reasonable pen size to draw the text
- int pensize = textSize/6;
-
- // Get a suitable color
- COLOR4D color = aSettings->GetLayerColor( IsVisible() ? LAYER_PRIVATE_NOTES : LAYER_HIDDEN );
- COLOR4D bg = aSettings->GetBackgroundColor();
-
- if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
- bg = COLOR4D::WHITE;
-
- if( !IsVisible() )
- bg = aSettings->GetLayerColor( LAYER_HIDDEN );
-
- if( aDimmed )
- {
- color.Desaturate( );
- color = color.Mix( bg, 0.5f );
- }
-
- VECTOR2I txtpos = aPosition;
- int offset = schIUScale.mmToIU( 0.4 );
- GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_LEFT;
- EDA_ANGLE orient = ANGLE_HORIZONTAL;
- KIFONT::FONT* font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), false, false );
-
- switch( aOrientation )
- {
- case PIN_ORIENTATION::PIN_UP:
- txtpos.y += offset;
- orient = ANGLE_VERTICAL;
- hjustify = GR_TEXT_H_ALIGN_RIGHT;
- break;
-
- case PIN_ORIENTATION::PIN_DOWN:
- txtpos.y -= offset;
- orient = ANGLE_VERTICAL;
- break;
-
- case PIN_ORIENTATION::PIN_LEFT:
- txtpos.x += offset;
- break;
-
- case PIN_ORIENTATION::PIN_RIGHT:
- txtpos.x -= offset;
- hjustify = GR_TEXT_H_ALIGN_RIGHT;
- break;
- }
-
- GRPrintText( DC, txtpos, color, typeName, orient, VECTOR2I( textSize, textSize ), hjustify,
- GR_TEXT_V_ALIGN_CENTER, pensize, false, false, font, GetFontMetrics() );
-}
-
-
-void LIB_PIN::PlotPinType( PLOTTER *aPlotter, const VECTOR2I &aPosition,
- PIN_ORIENTATION aOrientation, bool aDimmed ) const
-{
- int MapX1, MapY1, x1, y1;
- SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
- COLOR4D color = renderSettings->GetLayerColor( LAYER_PIN );
- COLOR4D bg = renderSettings->GetBackgroundColor();
- int penWidth = GetEffectivePenWidth( renderSettings );
-
- if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
- bg = COLOR4D::WHITE;
-
- if( aDimmed )
- {
- color.Desaturate( );
- color = color.Mix( bg, 0.5f );
- }
-
- aPlotter->SetColor( color );
- aPlotter->SetCurrentLineWidth( penWidth );
-
- MapX1 = MapY1 = 0;
- x1 = aPosition.x; y1 = aPosition.y;
-
- switch( aOrientation )
- {
- case PIN_ORIENTATION::PIN_UP: y1 = aPosition.y - m_length; MapY1 = 1; break;
- case PIN_ORIENTATION::PIN_DOWN: y1 = aPosition.y + m_length; MapY1 = -1; break;
- case PIN_ORIENTATION::PIN_LEFT: x1 = aPosition.x - m_length; MapX1 = 1; break;
- case PIN_ORIENTATION::PIN_RIGHT: x1 = aPosition.x + m_length; MapX1 = -1; break;
- }
-
- if( m_shape == GRAPHIC_PINSHAPE::INVERTED || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK )
- {
- const int radius = externalPinDecoSize( aPlotter->RenderSettings(), *this );
- aPlotter->Circle( VECTOR2I( MapX1 * radius + x1, MapY1 * radius + y1 ), radius * 2,
- FILL_T::NO_FILL, penWidth );
-
- aPlotter->MoveTo( VECTOR2I( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ) );
- aPlotter->FinishTo( aPosition );
- }
- else if( m_shape == GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK )
- {
- const int deco_size = internalPinDecoSize( aPlotter->RenderSettings(), *this );
- if( MapY1 == 0 ) /* MapX1 = +- 1 */
- {
- aPlotter->MoveTo( VECTOR2I( x1, y1 + deco_size ) );
- aPlotter->LineTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 ) );
- aPlotter->FinishTo( VECTOR2I( x1, y1 - deco_size ) );
- }
- else /* MapX1 = 0 */
- {
- aPlotter->MoveTo( VECTOR2I( x1 + deco_size, y1 ) );
- aPlotter->LineTo( VECTOR2I( x1, y1 + MapY1 * deco_size * 2 ) );
- aPlotter->FinishTo( VECTOR2I( x1 - deco_size, y1 ) );
- }
-
- aPlotter->MoveTo( VECTOR2I( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 ) );
- aPlotter->FinishTo( aPosition );
- }
- else
- {
- aPlotter->MoveTo( VECTOR2I( x1, y1 ) );
- aPlotter->FinishTo( aPosition );
- }
-
- if( m_shape == GRAPHIC_PINSHAPE::CLOCK
- || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK
- || m_shape == GRAPHIC_PINSHAPE::CLOCK_LOW )
- {
- const int deco_size = internalPinDecoSize( aPlotter->RenderSettings(), *this );
- if( MapY1 == 0 ) /* MapX1 = +- 1 */
- {
- aPlotter->MoveTo( VECTOR2I( x1, y1 + deco_size ) );
- aPlotter->LineTo( VECTOR2I( x1 - MapX1 * deco_size * 2, y1 ) );
- aPlotter->FinishTo( VECTOR2I( x1, y1 - deco_size ) );
- }
- else /* MapX1 = 0 */
- {
- aPlotter->MoveTo( VECTOR2I( x1 + deco_size, y1 ) );
- aPlotter->LineTo( VECTOR2I( x1, y1 - MapY1 * deco_size * 2 ) );
- aPlotter->FinishTo( VECTOR2I( x1 - deco_size, y1 ) );
- }
- }
-
- if( m_shape == GRAPHIC_PINSHAPE::INPUT_LOW
- || m_shape == GRAPHIC_PINSHAPE::CLOCK_LOW ) /* IEEE symbol "Active Low Input" */
- {
- const int deco_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
-
- if( MapY1 == 0 ) /* MapX1 = +- 1 */
- {
- aPlotter->MoveTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 ) );
- aPlotter->LineTo( VECTOR2I( x1 + MapX1 * deco_size * 2, y1 - deco_size * 2 ) );
- aPlotter->FinishTo( VECTOR2I( x1, y1 ) );
- }
- else /* MapX1 = 0 */
- {
- aPlotter->MoveTo( VECTOR2I( x1, y1 + MapY1 * deco_size * 2 ) );
- aPlotter->LineTo( VECTOR2I( x1 - deco_size * 2, y1 + MapY1 * deco_size * 2 ) );
- aPlotter->FinishTo( VECTOR2I( x1, y1 ) );
- }
- }
-
- if( m_shape == GRAPHIC_PINSHAPE::OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
- {
- const int symbol_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
-
- if( MapY1 == 0 ) /* MapX1 = +- 1 */
- {
- aPlotter->MoveTo( VECTOR2I( x1, y1 - symbol_size * 2 ) );
- aPlotter->FinishTo( VECTOR2I( x1 + MapX1 * symbol_size * 2, y1 ) );
- }
- else /* MapX1 = 0 */
- {
- aPlotter->MoveTo( VECTOR2I( x1 - symbol_size * 2, y1 ) );
- aPlotter->FinishTo( VECTOR2I( x1, y1 + MapY1 * symbol_size * 2 ) );
- }
- }
- else if( m_shape == GRAPHIC_PINSHAPE::NONLOGIC ) /* NonLogic pin symbol */
- {
- const int deco_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
- aPlotter->MoveTo( VECTOR2I( x1 - ( MapX1 + MapY1 ) * deco_size,
- y1 - ( MapY1 - MapX1 ) * deco_size ) );
- aPlotter->FinishTo( VECTOR2I( x1 + ( MapX1 + MapY1 ) * deco_size,
- y1 + ( MapY1 - MapX1 ) * deco_size ) );
- aPlotter->MoveTo( VECTOR2I( x1 - ( MapX1 - MapY1 ) * deco_size,
- y1 - ( MapY1 + MapX1 ) * deco_size ) );
- aPlotter->FinishTo( VECTOR2I( x1 + ( MapX1 - MapY1 ) * deco_size,
- y1 + ( MapY1 + MapX1 ) * deco_size ) );
- }
-
- if( m_type == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
- {
- const int deco_size = TARGET_PIN_RADIUS;
- const int ex1 = aPosition.x;
- const int ey1 = aPosition.y;
- aPlotter->MoveTo( VECTOR2I( ex1 - deco_size, ey1 - deco_size ) );
- aPlotter->FinishTo( VECTOR2I( ex1 + deco_size, ey1 + deco_size ) );
- aPlotter->MoveTo( VECTOR2I( ex1 + deco_size, ey1 - deco_size ) );
- aPlotter->FinishTo( VECTOR2I( ex1 - deco_size, ey1 + deco_size ) );
- }
-}
-
-
-void LIB_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIENTATION aPinOrient,
- int aTextInside, bool aDrawPinNum, bool aDrawPinName,
- bool aDimmed ) const
-{
- RENDER_SETTINGS* settings = aPlotter->RenderSettings();
- KIFONT::FONT* font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), false, false );
- wxString name = GetShownName();
- wxString number = GetShownNumber();
-
- if( name.IsEmpty() || m_nameTextSize == 0 )
- aDrawPinName = false;
-
- if( number.IsEmpty() || m_numTextSize == 0 )
- aDrawPinNum = false;
-
- if( !aDrawPinNum && !aDrawPinName )
- return;
-
- int namePenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_nameTextSize, true ),
- settings->GetDefaultPenWidth() );
- int numPenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_numTextSize, true ),
- settings->GetDefaultPenWidth() );
- int name_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + namePenWidth;
- int num_offset = schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + numPenWidth;
-
- /* Get the num and name colors */
- COLOR4D nameColor = settings->GetLayerColor( LAYER_PINNAM );
- COLOR4D numColor = settings->GetLayerColor( LAYER_PINNUM );
- COLOR4D bg = settings->GetBackgroundColor();
-
- if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
- bg = COLOR4D::WHITE;
-
- if( aDimmed )
- {
- nameColor.Desaturate( );
- numColor.Desaturate( );
- nameColor = nameColor.Mix( bg, 0.5f );
- numColor = numColor.Mix( bg, 0.5f );
- }
-
- int x1 = aPinPos.x;
- int y1 = aPinPos.y;
-
- switch( aPinOrient )
- {
- case PIN_ORIENTATION::PIN_UP: y1 -= m_length; break;
- case PIN_ORIENTATION::PIN_DOWN: y1 += m_length; break;
- case PIN_ORIENTATION::PIN_LEFT: x1 -= m_length; break;
- case PIN_ORIENTATION::PIN_RIGHT: x1 += m_length; break;
- }
-
- auto plotName =
- [&]( int x, int y, const EDA_ANGLE& angle, GR_TEXT_H_ALIGN_T hJustify,
- GR_TEXT_V_ALIGN_T vJustify )
- {
- TEXT_ATTRIBUTES attrs;
- attrs.m_StrokeWidth = namePenWidth;
- attrs.m_Angle = angle;
- attrs.m_Size = VECTOR2I( m_nameTextSize, m_nameTextSize );
- attrs.m_Halign = hJustify;
- attrs.m_Valign = vJustify;
- attrs.m_Multiline = false;
-
- aPlotter->PlotText( VECTOR2I( x, y ), nameColor, name, attrs, font, GetFontMetrics() );
- };
-
- auto plotNum =
- [&]( int x, int y, const EDA_ANGLE& angle, GR_TEXT_H_ALIGN_T hJustify,
- GR_TEXT_V_ALIGN_T vJustify )
- {
- TEXT_ATTRIBUTES attrs;
- attrs.m_StrokeWidth = numPenWidth;
- attrs.m_Angle = angle;
- attrs.m_Size = VECTOR2I( m_numTextSize, m_numTextSize );
- attrs.m_Halign = hJustify;
- attrs.m_Valign = vJustify;
- attrs.m_Multiline = false;
-
- aPlotter->PlotText( VECTOR2I( x, y ), numColor, number, attrs, font, GetFontMetrics() );
- };
-
- /* Draw the text inside, but the pin numbers outside. */
- if( aTextInside )
- {
- if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
- || ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) ) /* Its an horizontal line. */
- {
- if( aDrawPinName )
- {
- if( aPinOrient == PIN_ORIENTATION::PIN_RIGHT )
- {
- plotName( x1 + aTextInside, y1, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER );
- }
- else // orient == PIN_LEFT
- {
- plotName( x1 - aTextInside, y1, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER );
- }
- }
-
- if( aDrawPinNum )
- {
- plotNum( ( x1 + aPinPos.x) / 2, y1 - num_offset, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- }
- else /* Its a vertical line. */
- {
- if( aPinOrient == PIN_ORIENTATION::PIN_DOWN )
- {
- if( aDrawPinName )
- {
- plotName( x1, y1 + aTextInside, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER );
- }
-
- if( aDrawPinNum )
- {
- plotNum( x1 - num_offset, ( y1 + aPinPos.y) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- }
- else /* PIN_UP */
- {
- if( aDrawPinName )
- {
- plotName( x1, y1 - aTextInside, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER );
- }
-
- if( aDrawPinNum )
- {
- plotNum( x1 - num_offset, ( y1 + aPinPos.y) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- }
- }
- }
- else /* Draw num & text pin outside */
- {
- if( ( aPinOrient == PIN_ORIENTATION::PIN_LEFT )
- || ( aPinOrient == PIN_ORIENTATION::PIN_RIGHT ) )
- {
- /* Its an horizontal line. */
- if( aDrawPinName && aDrawPinNum )
- {
- plotName( ( x1 + aPinPos.x) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
-
- plotNum( ( x1 + aPinPos.x) / 2, y1 + num_offset, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP );
- }
- else if( aDrawPinName )
- {
- plotName( ( x1 + aPinPos.x) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- else if( aDrawPinNum )
- {
- plotNum( ( x1 + aPinPos.x) / 2, y1 - name_offset, ANGLE_HORIZONTAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- }
- else
- {
- /* Its a vertical line. */
- if( aDrawPinName && aDrawPinNum )
- {
- plotName( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
-
- plotNum( x1 + num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP );
- }
- else if( aDrawPinName )
- {
- plotName( x1 - name_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- else if( aDrawPinNum )
- {
- plotNum( x1 - num_offset, ( y1 + aPinPos.y ) / 2, ANGLE_VERTICAL,
- GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM );
- }
- }
- }
-}
-
-
-PIN_ORIENTATION LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const
-{
- PIN_ORIENTATION orient;
- VECTOR2I end; // position of pin end starting at 0,0 according to its orientation, length = 1
-
- switch( m_orientation )
- {
- case PIN_ORIENTATION::PIN_UP: end.y = 1; break;
- case PIN_ORIENTATION::PIN_DOWN: end.y = -1; break;
- case PIN_ORIENTATION::PIN_LEFT: end.x = -1; break;
- case PIN_ORIENTATION::PIN_RIGHT: end.x = 1; break;
- }
-
- // = pos of end point, according to the symbol orientation.
- end = aTransform.TransformCoordinate( end );
- orient = PIN_ORIENTATION::PIN_UP;
-
- if( end.x == 0 )
- {
- if( end.y > 0 )
- orient = PIN_ORIENTATION::PIN_DOWN;
- }
- else
- {
- orient = PIN_ORIENTATION::PIN_RIGHT;
-
- if( end.x < 0 )
- orient = PIN_ORIENTATION::PIN_LEFT;
- }
-
- return orient;
-}
-
-
-EDA_ITEM* LIB_PIN::Clone() const
-{
- //return new LIB_PIN( *this );
- SCH_ITEM* newPin = new LIB_PIN( *this );
- wxASSERT( newPin->GetUnit() == m_unit && newPin->GetBodyStyle() == m_bodyStyle );
- return newPin;
-}
-
-
-int LIB_PIN::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
-{
- wxASSERT( aOther.Type() == LIB_PIN_T );
-
- int retv = SCH_ITEM::compare( aOther, aCompareFlags );
-
- if( retv )
- return retv;
-
- const LIB_PIN* tmp = (LIB_PIN*) &aOther;
-
- // When comparing units, we do not compare the part numbers. If everything else is
- // identical, then we can just renumber the parts for the inherited symbol.
- if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT ) && m_number != tmp->m_number )
- return m_number.Cmp( tmp->m_number );
-
- int result = m_name.Cmp( tmp->m_name );
-
- if( result )
- return result;
-
- if( m_position.x != tmp->m_position.x )
- return m_position.x - tmp->m_position.x;
-
- if( m_position.y != tmp->m_position.y )
- return m_position.y - tmp->m_position.y;
-
- if( m_length != tmp->m_length )
- return m_length - tmp->m_length;
-
- if( m_orientation != tmp->m_orientation )
- return static_cast( m_orientation ) - static_cast( tmp->m_orientation );
-
- if( m_shape != tmp->m_shape )
- return static_cast( m_shape ) - static_cast( tmp->m_shape );
-
- if( m_type != tmp->m_type )
- return static_cast( m_type ) - static_cast( tmp->m_type );
-
- if( m_attributes != tmp->m_attributes )
- return m_attributes - tmp->m_attributes;
-
- if( m_numTextSize != tmp->m_numTextSize )
- return m_numTextSize - tmp->m_numTextSize;
-
- if( m_nameTextSize != tmp->m_nameTextSize )
- return m_nameTextSize - tmp->m_nameTextSize;
-
- if( m_alternates.size() != tmp->m_alternates.size() )
- return m_alternates.size() - tmp->m_alternates.size();
-
- auto lhsItem = m_alternates.begin();
- auto rhsItem = tmp->m_alternates.begin();
-
- while( lhsItem != m_alternates.end() )
- {
- const ALT& lhsAlt = lhsItem->second;
- const ALT& rhsAlt = rhsItem->second;
-
- retv = lhsAlt.m_Name.Cmp( rhsAlt.m_Name );
-
- if( retv )
- return retv;
-
- if( lhsAlt.m_Type != rhsAlt.m_Type )
- return static_cast( lhsAlt.m_Type ) - static_cast( rhsAlt.m_Type );
-
- if( lhsAlt.m_Shape != rhsAlt.m_Shape )
- return static_cast( lhsAlt.m_Shape ) - static_cast( rhsAlt.m_Shape );
-
- ++lhsItem;
- ++rhsItem;
- }
-
- return 0;
-}
-
-void LIB_PIN::ChangeLength( int aLength )
-{
- int lengthChange = m_length - aLength;
- int offsetX = 0;
- int offsetY = 0;
-
- switch( m_orientation )
- {
- case PIN_ORIENTATION::PIN_RIGHT:
- offsetX = lengthChange;
- break;
- case PIN_ORIENTATION::PIN_LEFT:
- offsetX = -1 * lengthChange;
- break;
- case PIN_ORIENTATION::PIN_UP:
- offsetY = lengthChange;
- break;
- case PIN_ORIENTATION::PIN_DOWN:
- offsetY = -1 * lengthChange;
- break;
- }
-
- VECTOR2I offset = VECTOR2I( offsetX, offsetY );
- Move( offset );
-
- m_length = aLength;
-}
-
-void LIB_PIN::Move( const VECTOR2I& aOffset )
-{
- m_position += aOffset;
-}
-
-
-void LIB_PIN::MirrorHorizontally( int aCenter )
-{
- m_position.x -= aCenter;
- m_position.x *= -1;
- m_position.x += aCenter;
-
- if( m_orientation == PIN_ORIENTATION::PIN_RIGHT )
- m_orientation = PIN_ORIENTATION::PIN_LEFT;
- else if( m_orientation == PIN_ORIENTATION::PIN_LEFT )
- m_orientation = PIN_ORIENTATION::PIN_RIGHT;
-}
-
-
-void LIB_PIN::MirrorVertically( int aCenter )
-{
- m_position.y -= aCenter;
- m_position.y *= -1;
- m_position.y += aCenter;
-
- if( m_orientation == PIN_ORIENTATION::PIN_UP )
- m_orientation = PIN_ORIENTATION::PIN_DOWN;
- else if( m_orientation == PIN_ORIENTATION::PIN_DOWN )
- m_orientation = PIN_ORIENTATION::PIN_UP;
-}
-
-
-void LIB_PIN::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
-{
- EDA_ANGLE rot_angle = aRotateCCW ? -ANGLE_90 : ANGLE_90;
-
- RotatePoint( m_position, aCenter, rot_angle );
-
- if( aRotateCCW )
- {
- switch( m_orientation )
- {
- case PIN_ORIENTATION::PIN_RIGHT: m_orientation = PIN_ORIENTATION::PIN_UP; break;
- case PIN_ORIENTATION::PIN_UP: m_orientation = PIN_ORIENTATION::PIN_LEFT; break;
- case PIN_ORIENTATION::PIN_LEFT: m_orientation = PIN_ORIENTATION::PIN_DOWN; break;
- case PIN_ORIENTATION::PIN_DOWN: m_orientation = PIN_ORIENTATION::PIN_RIGHT; break;
- }
- }
- else
- {
- switch( m_orientation )
- {
- case PIN_ORIENTATION::PIN_RIGHT: m_orientation = PIN_ORIENTATION::PIN_DOWN; break;
- case PIN_ORIENTATION::PIN_UP: m_orientation = PIN_ORIENTATION::PIN_RIGHT; break;
- case PIN_ORIENTATION::PIN_LEFT: m_orientation = PIN_ORIENTATION::PIN_UP; break;
- case PIN_ORIENTATION::PIN_DOWN: m_orientation = PIN_ORIENTATION::PIN_LEFT; break;
- }
- }
-}
-
-
-void LIB_PIN::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
- int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
-{
- if( aBackground )
- return;
-
- SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
-
- if( !IsVisible() && !renderSettings->m_ShowHiddenPins )
- return;
-
- const SYMBOL* part = GetParentSymbol();
- PIN_ORIENTATION orient = PinDrawOrient( renderSettings->m_Transform );
- VECTOR2I pos = renderSettings->TransformCoordinate( m_position ) + aOffset;
-
- PlotPinType( aPlotter, pos, orient, aDimmed );
- PlotPinTexts( aPlotter, pos, orient, part->GetPinNameOffset(), part->GetShowPinNumbers(),
- part->GetShowPinNames(), aDimmed );
-}
-
-
-void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList )
-{
- getSymbolEditorMsgPanelInfo( aFrame, aList );
-
- aList.emplace_back( _( "Name" ), UnescapeString( GetShownName() ) );
- aList.emplace_back( _( "Number" ), GetShownNumber() );
- aList.emplace_back( _( "Type" ), ElectricalPinTypeGetText( m_type ) );
- aList.emplace_back( _( "Style" ), PinShapeGetText( m_shape ) );
-
- aList.emplace_back( _( "Style" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
-
- // Display pin length
- aList.emplace_back( _( "Length" ), aFrame->MessageTextFromValue( m_length, true ) );
-
- aList.emplace_back( _( "Orientation" ), PinOrientationName( m_orientation ) );
-
- VECTOR2I pinpos = GetPosition();
- pinpos.y = -pinpos.y; // Display coords are top to bottom; lib item coords are bottom to top
-
- aList.emplace_back( _( "Pos X" ), aFrame->MessageTextFromValue( pinpos.x, true ) );
- aList.emplace_back( _( "Pos Y" ), aFrame->MessageTextFromValue( pinpos.y, true ) );
-
- #if 0 // For debug purpose only
- aList.emplace_back( _( "Flags" ), wxString::Format( "%8.8X", (long)GetFlags() ) );
- #endif
-}
-
-
-const BOX2I LIB_PIN::ViewBBox() const
-{
- return GetBoundingBox( false, true, true );
-}
-
-
-void LIB_PIN::ViewGetLayers( int aLayers[], int& aCount ) const
-{
- aCount = 6;
- aLayers[0] = LAYER_DANGLING; // We don't really show dangling vs non-dangling (since there
- // are no connections in the symbol editor), but it's still
- // a good visual indication of which end of the pin is which.
- aLayers[1] = LAYER_DEVICE;
- aLayers[2] = LAYER_SELECTION_SHADOWS;
- aLayers[3] = LAYER_OP_CURRENTS;
- aLayers[4] = LAYER_PINNAM;
- aLayers[5] = LAYER_PINNUM;
-}
-
-
-void LIB_PIN::validateExtentsCache( KIFONT::FONT* aFont, int aSize, const wxString& aText,
- EXTENTS_CACHE* aCache ) const
-{
- if( aCache->m_Font == aFont
- && aCache->m_FontSize == aSize
- && aCache->m_Extents != VECTOR2I() )
- {
- return;
- }
-
- aCache->m_Font = aFont;
- aCache->m_FontSize = aSize;
-
- VECTOR2D fontSize( aSize, aSize );
- int penWidth = GetPenSizeForNormal( aSize );
-
- aCache->m_Extents = aFont->StringBoundaryLimits( aText, fontSize, penWidth, false, false,
- GetFontMetrics() );
-}
-
-
-const BOX2I LIB_PIN::GetBoundingBox( bool aIncludeLabelsOnInvisiblePins, bool aIncludeNameAndNumber,
- bool aIncludeElectricalType ) const
-{
- EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings();
- KIFONT::FONT* font = KIFONT::FONT::GetFont( cfg->m_Appearance.default_font );
-
- BOX2I bbox;
- VECTOR2I begin;
- VECTOR2I end;
- int pinNameOffset = 0;
- int nameTextLength = 0;
- int nameTextHeight = 0;
- int numberTextLength = 0;
- int numberTextHeight = 0;
- int typeTextLength = 0;
- bool includeName = aIncludeNameAndNumber && !GetShownName().IsEmpty();
- bool includeNumber = aIncludeNameAndNumber && !GetShownNumber().IsEmpty();
- bool includeType = aIncludeElectricalType;
- int minsizeV = TARGET_PIN_RADIUS;
-
- if( !aIncludeLabelsOnInvisiblePins && !IsVisible() )
- {
- includeName = false;
- includeNumber = false;
- includeType = false;
- }
-
- if( const SYMBOL* parentSymbol = GetParentSymbol() )
- {
- if( parentSymbol->GetShowPinNames() )
- pinNameOffset = parentSymbol->GetPinNameOffset();
- else
- includeName = false;
-
- if( !parentSymbol->GetShowPinNumbers() )
- includeNumber = false;
- }
-
- if( includeNumber )
- {
- validateExtentsCache( font, m_numTextSize, GetShownNumber(), &m_numExtentsCache );
- numberTextLength = m_numExtentsCache.m_Extents.x;
- numberTextHeight = m_numExtentsCache.m_Extents.y;
- }
-
- if( includeName )
- {
- validateExtentsCache( font, m_nameTextSize, GetShownName(), &m_nameExtentsCache );
- nameTextLength = m_nameExtentsCache.m_Extents.x + pinNameOffset;
- nameTextHeight = m_nameExtentsCache.m_Extents.y + schIUScale.MilsToIU( PIN_TEXT_MARGIN );
- }
-
- if( includeType )
- {
- double fontSize = std::max( m_nameTextSize * 3 / 4, schIUScale.mmToIU( 0.7 ) );
- double stroke = fontSize / 8.0;
- VECTOR2I typeTextSize = font->StringBoundaryLimits( GetElectricalTypeName(),
- VECTOR2D( fontSize, fontSize ),
- KiROUND( stroke ), false, false,
- GetFontMetrics() );
-
- typeTextLength = typeTextSize.x + schIUScale.MilsToIU( PIN_TEXT_MARGIN ) + TARGET_PIN_RADIUS;
- minsizeV = std::max( minsizeV, typeTextSize.y / 2 );
- }
-
- // First, calculate boundary box corners position
- if( m_shape == GRAPHIC_PINSHAPE::INVERTED || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK )
- minsizeV = std::max( TARGET_PIN_RADIUS, externalPinDecoSize( nullptr, *this ) );
-
- // Calculate topLeft & bottomRight corner positions for the default pin orientation (PIN_RIGHT)
- if( pinNameOffset || !includeName )
- {
- // pin name is inside the body (or invisible)
- // pin number is above the line
- begin.y = std::max( minsizeV, numberTextHeight );
- begin.x = std::min( -typeTextLength, m_length - ( numberTextLength / 2 ) );
-
- end.x = m_length + nameTextLength;
- end.y = std::min( -minsizeV, -nameTextHeight / 2 );
- }
- else
- {
- // pin name is above pin line
- // pin number is below line
- begin.y = std::max( minsizeV, nameTextHeight );
- begin.x = -typeTextLength;
- begin.x = std::min( begin.x, ( m_length - numberTextLength ) / 2 );
- begin.x = std::min( begin.x, ( m_length - nameTextLength ) / 2 );
-
- end.x = m_length;
- end.x = std::max( end.x, ( m_length + nameTextLength ) / 2 );
- end.x = std::max( end.x, ( m_length + numberTextLength ) / 2 );
- end.y = std::min( -minsizeV, -numberTextHeight );
- }
-
- // Now, calculate boundary box corners position for the actual pin orientation
- PIN_ORIENTATION orient = PinDrawOrient( DefaultTransform );
-
- /* Calculate the pin position */
- switch( orient )
- {
- case PIN_ORIENTATION::PIN_UP:
- // Pin is rotated and texts positions are mirrored
- RotatePoint( begin, VECTOR2I( 0, 0 ), -ANGLE_90 );
- RotatePoint( end, VECTOR2I( 0, 0 ), -ANGLE_90 );
- break;
-
- case PIN_ORIENTATION::PIN_DOWN:
- RotatePoint( begin, VECTOR2I( 0, 0 ), ANGLE_90 );
- RotatePoint( end, VECTOR2I( 0, 0 ), ANGLE_90 );
- begin.x = -begin.x;
- end.x = -end.x;
- break;
-
- case PIN_ORIENTATION::PIN_LEFT:
- begin.x = -begin.x;
- end.x = -end.x;
- break;
-
- case PIN_ORIENTATION::PIN_RIGHT:
- break;
- }
-
- begin += m_position;
- end += m_position;
-
- bbox.SetOrigin( begin );
- bbox.SetEnd( end );
- bbox.Normalize();
- bbox.Inflate( ( GetPenWidth() / 2 ) + 1 );
-
- // Draw Y axis is reversed in schematic:
- bbox.RevertYAxis();
-
- return bbox;
-}
-
-
-BITMAPS LIB_PIN::GetMenuImage() const
-{
- return ElectricalPinTypeGetBitmap( m_type );
-}
-
-
-wxString LIB_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, ALT* aAlt ) const
-{
- return getItemDescription( aAlt );
-}
-
-
-wxString LIB_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
-{
- return getItemDescription( nullptr );
-}
-
-
-wxString LIB_PIN::getItemDescription( ALT* aAlt ) const
-{
- // This code previously checked "m_name.IsEmpty()" to choose the correct
- // formatting path, but that check fails if the pin is called "~" which is
- // the default for an empty pin name. Instead we get the final display string
- // that will be shown and check if it's empty.
-
- wxString name = UnescapeString( aAlt ? aAlt->m_Name : GetShownName() );
- wxString electricalTypeName = ElectricalPinTypeGetText( aAlt ? aAlt->m_Type : m_type );
- wxString pinShapeName = PinShapeGetText( aAlt ? aAlt->m_Shape : m_shape );
-
- if( IsVisible() )
- {
- if ( !name.IsEmpty() )
- {
- return wxString::Format( _( "Pin %s [%s, %s, %s]" ),
- GetShownNumber(),
- name,
- electricalTypeName,
- pinShapeName );
- }
- else
- {
- return wxString::Format( _( "Pin %s [%s, %s]" ),
- GetShownNumber(),
- electricalTypeName,
- pinShapeName );
- }
- }
- else
- {
- if( !name.IsEmpty() )
- {
- return wxString::Format( _( "Hidden pin %s [%s, %s, %s]" ),
- GetShownNumber(),
- name,
- electricalTypeName,
- pinShapeName );
- }
- else
- {
- return wxString::Format( _( "Hidden pin %s [%s, %s]" ),
- GetShownNumber(),
- electricalTypeName,
- pinShapeName );
- }
- }
-}
-
-
-bool LIB_PIN::operator==( const SCH_ITEM& aOther ) const
-{
- if( aOther.Type() != LIB_PIN_T )
- return false;
-
- const LIB_PIN* other = static_cast( &aOther );
-
- if( m_name != other->m_name )
- return false;
-
- if( m_number != other->m_number )
- return false;
-
- if( m_position != other->m_position )
- return false;
-
- if( m_length != other->m_length )
- return false;
-
- if( m_orientation != other->m_orientation )
- return false;
-
- if( m_shape != other->m_shape )
- return false;
-
- if( m_type != other->m_type )
- return false;
-
- if( m_attributes != other->m_attributes )
- return false;
-
- if( m_numTextSize != other->m_numTextSize )
- return false;
-
- if( m_nameTextSize != other->m_nameTextSize )
- return false;
-
- if( m_alternates.size() != other->m_alternates.size() )
- return false;
-
- auto lhsItem = m_alternates.begin();
- auto rhsItem = other->m_alternates.begin();
-
- while( lhsItem != m_alternates.end() )
- {
- if( rhsItem == other->m_alternates.end() )
- return false;
-
- const ALT& lhsAlt = lhsItem->second;
- const ALT& rhsAlt = rhsItem->second;
-
- if( lhsAlt.m_Name != rhsAlt.m_Name )
- return false;
-
- if( lhsAlt.m_Type != rhsAlt.m_Type )
- return false;
-
- if( lhsAlt.m_Shape != rhsAlt.m_Shape )
- return false;
-
- ++lhsItem;
- ++rhsItem;
- }
-
- return rhsItem == other->m_alternates.end();
-}
-
-
-double LIB_PIN::Similarity( const SCH_ITEM& aOther ) const
-{
- if( aOther.m_Uuid == m_Uuid )
- return 1.0;
-
- if( aOther.Type() != LIB_PIN_T )
- return 0.0;
-
- const LIB_PIN* other = static_cast( &aOther );
-
- double similarity = SimilarityBase( aOther );
-
- if( m_name != other->m_name )
- similarity *= 0.9;
-
- if( m_number != other->m_number )
- similarity *= 0.9;
-
- if( m_position != other->m_position )
- similarity *= 0.9;
-
- if( m_length != other->m_length )
- similarity *= 0.9;
-
- if( m_orientation != other->m_orientation )
- similarity *= 0.9;
-
- if( m_shape != other->m_shape )
- similarity *= 0.9;
-
- if( m_type != other->m_type )
- similarity *= 0.9;
-
- if( m_attributes != other->m_attributes )
- similarity *= 0.9;
-
- if( m_numTextSize != other->m_numTextSize )
- similarity *= 0.9;
-
- if( m_nameTextSize != other->m_nameTextSize )
- similarity *= 0.9;
-
- if( m_alternates.size() != other->m_alternates.size() )
- similarity *= 0.9;
-
- return similarity;
-}
-
-
-std::ostream& LIB_PIN::operator<<( std::ostream& aStream )
-{
- aStream << "LIB_PIN:" << std::endl
- << " Name: \"" << m_name << "\"" << std::endl
- << " Number: \"" << m_number << "\"" << std::endl
- << " Position: " << m_position << std::endl
- << " Length: " << m_length << std::endl
- << " Orientation: " << PinOrientationName( m_orientation ) << std::endl
- << " Shape: " << PinShapeGetText( m_shape ) << std::endl
- << " Type: " << ElectricalPinTypeGetText( m_type ) << std::endl
- << " Name Text Size: " << m_nameTextSize << std::endl
- << " Number Text Size: " << m_numTextSize << std::endl;
-
- return aStream;
-}
-
-
-#if defined(DEBUG)
-
-void LIB_PIN::Show( int nestLevel, std::ostream& os ) const
-{
- NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
- << " num=\"" << m_number.mb_str()
- << '"' << "/>\n";
-
-// NestedSpace( nestLevel, os ) << "" << GetClass().Lower().mb_str() << ">\n";
-}
-
-#endif
-
-void LIB_PIN::CalcEdit( const VECTOR2I& aPosition )
-{
- if( IsMoving() )
- SetPosition( aPosition );
-}
-
-
-static struct LIB_PIN_DESC
-{
- LIB_PIN_DESC()
- {
- auto& pinTypeEnum = ENUM_MAP::Instance();
-
- if( pinTypeEnum.Choices().GetCount() == 0 )
- {
- pinTypeEnum.Map( ELECTRICAL_PINTYPE::PT_INPUT, _HKI( "Input" ) )
- .Map( ELECTRICAL_PINTYPE::PT_OUTPUT, _HKI( "Output" ) )
- .Map( ELECTRICAL_PINTYPE::PT_BIDI, _HKI( "Bidirectional" ) )
- .Map( ELECTRICAL_PINTYPE::PT_TRISTATE, _HKI( "Tri-state" ) )
- .Map( ELECTRICAL_PINTYPE::PT_PASSIVE, _HKI( "Passive" ) )
- .Map( ELECTRICAL_PINTYPE::PT_NIC, _HKI( "Free" ) )
- .Map( ELECTRICAL_PINTYPE::PT_UNSPECIFIED, _HKI( "Unspecified" ) )
- .Map( ELECTRICAL_PINTYPE::PT_POWER_IN, _HKI( "Power input" ) )
- .Map( ELECTRICAL_PINTYPE::PT_POWER_OUT, _HKI( "Power output" ) )
- .Map( ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR, _HKI( "Open collector" ) )
- .Map( ELECTRICAL_PINTYPE::PT_OPENEMITTER, _HKI( "Open emitter" ) )
- .Map( ELECTRICAL_PINTYPE::PT_NC, _HKI( "Unconnected" ) );
- }
-
- auto& pinShapeEnum = ENUM_MAP::Instance();
-
- if( pinShapeEnum.Choices().GetCount() == 0 )
- {
- pinShapeEnum.Map( GRAPHIC_PINSHAPE::LINE, _HKI( "Line" ) )
- .Map( GRAPHIC_PINSHAPE::INVERTED, _HKI( "Inverted" ) )
- .Map( GRAPHIC_PINSHAPE::CLOCK, _HKI( "Clock" ) )
- .Map( GRAPHIC_PINSHAPE::INVERTED_CLOCK, _HKI( "Inverted clock" ) )
- .Map( GRAPHIC_PINSHAPE::INPUT_LOW, _HKI( "Input low" ) )
- .Map( GRAPHIC_PINSHAPE::CLOCK_LOW, _HKI( "Clock low" ) )
- .Map( GRAPHIC_PINSHAPE::OUTPUT_LOW, _HKI( "Output low" ) )
- .Map( GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK, _HKI( "Falling edge clock" ) )
- .Map( GRAPHIC_PINSHAPE::NONLOGIC, _HKI( "NonLogic" ) );
- }
-
- auto& orientationEnum = ENUM_MAP::Instance();
-
- if( orientationEnum.Choices().GetCount() == 0 )
- {
- orientationEnum.Map( PIN_ORIENTATION::PIN_RIGHT, _( "Right" ) )
- .Map( PIN_ORIENTATION::PIN_LEFT, _( "Left" ) )
- .Map( PIN_ORIENTATION::PIN_UP, _( "Up" ) )
- .Map( PIN_ORIENTATION::PIN_DOWN, _( "Down" ) );
- }
-
- PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
- REGISTER_TYPE( LIB_PIN );
- propMgr.AddTypeCast( new TYPE_CAST );
- propMgr.InheritsAfter( TYPE_HASH( LIB_PIN ), TYPE_HASH( SCH_ITEM ) );
-
- propMgr.AddProperty( new PROPERTY( _HKI( "Pin Name" ),
- &LIB_PIN::SetName, &LIB_PIN::GetName ) );
-
- propMgr.AddProperty( new PROPERTY( _HKI( "Pin Number" ),
- &LIB_PIN::SetNumber, &LIB_PIN::GetNumber ) );
-
- propMgr.AddProperty( new PROPERTY_ENUM(
- _HKI( "Electrical Type" ),
- &LIB_PIN::SetType, &LIB_PIN::GetType ) );
-
- propMgr.AddProperty( new PROPERTY_ENUM(
- _HKI( "Graphic Style" ),
- &LIB_PIN::SetShape, &LIB_PIN::GetShape ) );
-
- propMgr.AddProperty( new PROPERTY( _HKI( "Position X" ),
- &LIB_PIN::SetX, &LIB_PIN::GetX, PROPERTY_DISPLAY::PT_COORD ) );
-
- propMgr.AddProperty( new PROPERTY( _HKI( "Position Y" ),
- &LIB_PIN::SetY, &LIB_PIN::GetY, PROPERTY_DISPLAY::PT_COORD ) );
-
- propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Orientation" ),
- &LIB_PIN::SetOrientation, &LIB_PIN::GetOrientation ) );
-
- propMgr.AddProperty( new PROPERTY( _HKI( "Length" ),
- &LIB_PIN::SetLength, &LIB_PIN::GetLength,
- PROPERTY_DISPLAY::PT_SIZE ) );
-
- propMgr.AddProperty( new PROPERTY( _HKI( "Name Text Size" ),
- &LIB_PIN::SetNameTextSize, &LIB_PIN::GetNameTextSize,
- PROPERTY_DISPLAY::PT_SIZE ) );
-
- propMgr.AddProperty( new PROPERTY( _HKI( "Number Text Size" ),
- &LIB_PIN::SetNumberTextSize, &LIB_PIN::GetNumberTextSize,
- PROPERTY_DISPLAY::PT_SIZE ) );
-
- propMgr.AddProperty( new PROPERTY( _HKI( "Visible" ),
- &LIB_PIN::SetVisible, &LIB_PIN::IsVisible ) );
- }
-} _LIB_PIN_DESC;
-
-
-ENUM_TO_WXANY( PIN_ORIENTATION )
-ENUM_TO_WXANY( GRAPHIC_PINSHAPE )
-ENUM_TO_WXANY( ELECTRICAL_PINTYPE )
diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h
deleted file mode 100644
index bdf9f1e0b1..0000000000
--- a/eeschema/lib_pin.h
+++ /dev/null
@@ -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
- * 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
-#include
-
-// 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& 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& 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 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
diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp
index 0219d58cfb..928de88695 100644
--- a/eeschema/lib_symbol.cpp
+++ b/eeschema/lib_symbol.cpp
@@ -27,12 +27,11 @@
#include
#include
#include
-#include
#include
#include
#include
-#include
#include
+#include
#include
#include
@@ -293,7 +292,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
aShapes.insert( &(*it) );
else if( it->Type() == SCH_FIELD_T )
aFields.insert( &(*it) );
- else if( it->Type() == LIB_PIN_T )
+ else if( it->Type() == SCH_PIN_T )
aPins.insert( &(*it) );
}
@@ -307,7 +306,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
bShapes.insert( &(*it) );
else if( it->Type() == SCH_FIELD_T )
bFields.insert( &(*it) );
- else if( it->Type() == LIB_PIN_T )
+ else if( it->Type() == SCH_PIN_T )
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 )
{
- const LIB_PIN* aPin = static_cast( aPinItem );
- const LIB_PIN* bPin = aRhs.GetPin( aPin->GetNumber(), aPin->GetUnit(),
+ const SCH_PIN* aPin = static_cast( aPinItem );
+ const SCH_PIN* bPin = aRhs.GetPin( aPin->GetNumber(), aPin->GetUnit(),
aPin->GetBodyStyle() );
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 ) )
continue;
- if( item.Type() == LIB_PIN_T )
+ if( item.Type() == SCH_PIN_T )
{
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& aList, int aUnit, int aBodyStyle ) const
+std::vector LIB_SYMBOL::GetPins( int aUnit, int aBodyStyle ) const
{
+ std::vector pins;
+
/* Notes:
* when aUnit == 0: no unit filtering
* when aBodyStyle == 0: no body style filtering
@@ -992,7 +993,7 @@ void LIB_SYMBOL::GetPins( std::vector& aList, int aUnit, int aBodyStyl
LIB_SYMBOL_SPTR parent = m_parent.lock();
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:
if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
@@ -1002,35 +1003,29 @@ void LIB_SYMBOL::GetPins( std::vector& aList, int aUnit, int aBodyStyl
if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
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( static_cast( &item ) ) );
}
+
+ return pins;
}
-std::vector LIB_SYMBOL::GetAllLibPins() const
+std::vector LIB_SYMBOL::GetAllLibPins() const
{
- std::vector pinList;
-
- GetPins( pinList, 0, 0 );
- return pinList;
+ return GetPins( 0, 0 );
}
int LIB_SYMBOL::GetPinCount()
{
- std::vector pinList;
-
- GetPins( pinList, 0 /* all units */, 1 /* single body style */ );
- return (int) pinList.size();
+ return (int) GetPins( 0 /* all units */, 1 /* single body style */ ).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 pinList;
- GetPins( pinList, aUnit, aBodyStyle );
-
- for( LIB_PIN* pin : pinList )
+ for( SCH_PIN* pin : GetPins( aUnit, aBodyStyle ) )
{
if( aNumber == pin->GetNumber() )
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 aTestType, bool aTestOrientation, bool aTestLength ) const
{
- std::vector thisPinList;
- GetPins( thisPinList, /* aUnit */ 0, /* aBodyStyle */ 0 );
+ std::vector thisPinList = GetAllLibPins();
- for( const LIB_PIN* eachThisPin : thisPinList )
+ for( const SCH_PIN* eachThisPin : thisPinList )
{
wxASSERT( eachThisPin );
- std::vector otherPinList;
- aOtherPart.GetPins( otherPinList, /* aUnit */ 0, /* aBodyStyle */ 0 );
+ std::vector otherPinList = aOtherPart.GetAllLibPins();
bool foundMatch = false;
- for( const LIB_PIN* eachOtherPin : otherPinList )
+ for( const SCH_PIN* eachOtherPin : otherPinList )
{
wxASSERT( eachOtherPin );
@@ -1152,9 +1145,9 @@ const BOX2I LIB_SYMBOL::GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aInc
if( item.Type() == SCH_FIELD_T )
continue;
- if( item.Type() == LIB_PIN_T )
+ if( item.Type() == SCH_PIN_T )
{
- const LIB_PIN& pin = static_cast( item );
+ const SCH_PIN& pin = static_cast( item );
if( pin.IsVisible() )
{
@@ -1441,9 +1434,9 @@ int LIB_SYMBOL::GetMaxPinNumber() const
LIB_SYMBOL_SPTR parent = m_parent.lock();
const LIB_ITEMS_CONTAINER& drawItems = parent ? parent->m_drawings : m_drawings;
- for( const SCH_ITEM& item : drawItems[LIB_PIN_T] )
+ for( const SCH_ITEM& item : drawItems[SCH_PIN_T] )
{
- const LIB_PIN* pin = static_cast( &item );
+ const SCH_PIN* pin = static_cast( &item );
long currentPinNumber = 0;
if( pin->GetNumber().ToLong( ¤tPinNumber ) )
@@ -1598,7 +1591,7 @@ void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePi
{
std::vector 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 )
{
@@ -1727,8 +1720,8 @@ bool LIB_SYMBOL::operator==( const LIB_SYMBOL& aOther ) const
return false;
}
- const std::vector thisPinList = GetAllLibPins();
- const std::vector otherPinList = aOther.GetAllLibPins();
+ const std::vector thisPinList = GetAllLibPins();
+ const std::vector otherPinList = aOther.GetAllLibPins();
if( thisPinList.size() != otherPinList.size() )
return false;
@@ -1777,12 +1770,12 @@ double LIB_SYMBOL::Similarity( const SCH_ITEM& aOther ) const
similarity += max_similarity;
}
- for( const LIB_PIN* pin : GetAllLibPins() )
+ for( const SCH_PIN* pin : GetAllLibPins() )
{
totalItems += 1;
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 );
max_similarity = std::max( max_similarity, temp_similarity );
diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h
index 002d55cd5c..8280d24daf 100644
--- a/eeschema/lib_symbol.h
+++ b/eeschema/lib_symbol.h
@@ -27,9 +27,9 @@
#ifndef LIB_SYMBOL_H
#define LIB_SYMBOL_H
-#include
#include
#include
+#include
#include
#include
#include
@@ -39,13 +39,12 @@ class OUTPUTFORMATTER;
class REPORTER;
class SYMBOL_LIB;
class LIB_SYMBOL;
-class LIB_PIN;
class TEST_LIB_SYMBOL_FIXTURE;
typedef std::shared_ptr LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL
typedef std::weak_ptr LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL
-typedef MULTIVECTOR LIB_ITEMS_CONTAINER;
+typedef MULTIVECTOR LIB_ITEMS_CONTAINER;
typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS;
@@ -387,18 +386,17 @@ public:
* 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.
*
- * @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 aBodyStyle - Symbol alternate body style of pins to collect. Set to 0 to get pins
* from any DeMorgan variant of symbol.
*/
- void GetPins( std::vector& aList, int aUnit = 0, int aBodyStyle = 0 ) const;
+ std::vector GetPins( int aUnit = 0, int aBodyStyle = 0 ) const;
/**
* 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.
*/
- std::vector GetAllLibPins() const;
+ std::vector GetAllLibPins() const;
/**
* @return a count of pins for all units / converts.
@@ -414,7 +412,7 @@ public:
* required.
* @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
diff --git a/eeschema/netlist_exporters/netlist_exporter_allegro.cpp b/eeschema/netlist_exporters/netlist_exporter_allegro.cpp
index cedf8d5ef2..3b2687e289 100644
--- a/eeschema/netlist_exporters/netlist_exporter_allegro.cpp
+++ b/eeschema/netlist_exporters/netlist_exporter_allegro.cpp
@@ -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 StrNumCmp( aPin1->GetShownNumber(), aPin2->GetShownNumber(), true ) < 0;
@@ -177,18 +177,10 @@ void NETLIST_EXPORTER_ALLEGRO::extractComponentsInfo()
SCH_SYMBOL* symbol = findNextSymbol( item, &sheet );
if( !symbol || symbol->GetExcludedFromBoard() )
- {
continue;
- }
- std::vector pinList;
- pinList.clear();
- symbol->GetLibPins(pinList);
-
- if( !pinList.size() )
- {
+ if( symbol->GetLibPins().empty() )
continue;
- }
m_packageProperties.insert( std::pair( sheet.PathHumanReadable(),
@@ -450,8 +442,7 @@ void NETLIST_EXPORTER_ALLEGRO::toAllegroPackages()
fprintf( d, "PACKAGE '%s'\n", TO_UTF8( formatDevice( footprintText ) ) );
fprintf( d, "CLASS IC\n" );
- std::vector pinList;
- sym->GetLibSymbolRef()->GetPins( pinList, 0, 0 );
+ std::vector pinList = sym->GetLibSymbolRef()->GetAllLibPins();
/*
* 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();
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 aPinList )
+wxString NETLIST_EXPORTER_ALLEGRO::formatFunction( wxString aName, std::vector aPinList )
{
aName.MakeUpper();
std::list pinNameList;
diff --git a/eeschema/netlist_exporters/netlist_exporter_allegro.h b/eeschema/netlist_exporters/netlist_exporter_allegro.h
index 18f3a29ec3..125822a449 100644
--- a/eeschema/netlist_exporters/netlist_exporter_allegro.h
+++ b/eeschema/netlist_exporters/netlist_exporter_allegro.h
@@ -67,13 +67,13 @@ public:
static bool CompareSymbolRef( const wxString& aRefText1, const wxString& aRefText2 );
/**
- * Compare two LIB_PIN* variables.
+ * Compare two SCH_PIN* variables.
*
* @param aPin1
* @param aPin2
* @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:
void extractComponentsInfo();
@@ -132,7 +132,7 @@ private:
* @param aPin
* @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
@@ -142,7 +142,7 @@ private:
* @param aPinList
* @return wxString
*/
- wxString formatFunction( wxString aName, std::vector aPinList );
+ wxString formatFunction( wxString aName, std::vector aPinList );
/**
* Look up a field for a component group, which may have mismatched case, or
diff --git a/eeschema/netlist_exporters/netlist_exporter_base.h b/eeschema/netlist_exporters/netlist_exporter_base.h
index 80dffea370..450e65fd6d 100644
--- a/eeschema/netlist_exporters/netlist_exporter_base.h
+++ b/eeschema/netlist_exporters/netlist_exporter_base.h
@@ -26,10 +26,8 @@
#ifndef NETLIST_EXPORTER_H
#define NETLIST_EXPORTER_H
-#include
#include
#include