Remove the last bits of the old netlist system
This commit is contained in:
parent
cf17a675b4
commit
38a4e4ad5a
|
@ -188,8 +188,6 @@ set( EESCHEMA_SRCS
|
|||
libarch.cpp
|
||||
menubar.cpp
|
||||
netlist_generator.cpp
|
||||
netlist_object_list.cpp
|
||||
netlist_object.cpp
|
||||
pin_number.cpp
|
||||
pin_type.cpp
|
||||
plot_schematic_DXF.cpp
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include <reporter.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <sch_view.h>
|
||||
#include <netlist_object.h>
|
||||
#include <sch_marker.h>
|
||||
#include <sch_component.h>
|
||||
#include <connection_graph.h>
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include <bitmaps.h>
|
||||
#include <reporter.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <netlist_object.h>
|
||||
#include <schematic.h>
|
||||
#include <connection_graph.h>
|
||||
#include <tools/ee_actions.h>
|
||||
|
|
182
eeschema/erc.cpp
182
eeschema/erc.cpp
|
@ -33,7 +33,6 @@
|
|||
#include <fctsys.h>
|
||||
#include <kicad_string.h>
|
||||
#include <lib_pin.h>
|
||||
#include <netlist_object.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sch_marker.h>
|
||||
#include <sch_reference_list.h>
|
||||
|
@ -359,186 +358,6 @@ int ERC_TESTER::TestMultiunitFootprints()
|
|||
}
|
||||
|
||||
|
||||
void ERC_TESTER::diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, int aMinConn,
|
||||
PIN_ERROR aDiag )
|
||||
{
|
||||
if( aDiag == PIN_ERROR::OK || aMinConn < 1 || aNetItemRef->m_Type != NETLIST_ITEM::PIN )
|
||||
return;
|
||||
|
||||
ERC_SETTINGS& settings = m_schematic->ErcSettings();
|
||||
|
||||
SCH_PIN* pin = static_cast<SCH_PIN*>( aNetItemRef->m_Comp );
|
||||
|
||||
if( aNetItemTst == NULL)
|
||||
{
|
||||
if( aMinConn == NOD ) /* Nothing driving the net. */
|
||||
{
|
||||
if( settings.GetSeverity( ERCE_PIN_NOT_DRIVEN ) != RPT_SEVERITY_IGNORE )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_PIN_NOT_DRIVEN );
|
||||
ercItem->SetItems( pin );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, aNetItemRef->m_Start );
|
||||
aNetItemRef->m_SheetPath.LastScreen()->Append( marker );
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( aNetItemTst && aNetItemTst->m_Type == NETLIST_ITEM::PIN ) /* Error between 2 pins */
|
||||
{
|
||||
if( settings.GetSeverity( ERCE_PIN_TO_PIN_WARNING ) != RPT_SEVERITY_IGNORE )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create(
|
||||
aDiag == PIN_ERROR::PP_ERROR ? ERCE_PIN_TO_PIN_ERROR : ERCE_PIN_TO_PIN_WARNING );
|
||||
ercItem->SetItems( pin, static_cast<SCH_PIN*>( aNetItemTst->m_Comp ) );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, aNetItemRef->m_Start );
|
||||
aNetItemRef->m_SheetPath.LastScreen()->Append( marker );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ERC_TESTER::TestOthersItems( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef,
|
||||
unsigned aNetStart, int* aMinConnexion )
|
||||
{
|
||||
ERC_SETTINGS& settings = m_schematic->ErcSettings();
|
||||
|
||||
unsigned netItemTst = aNetStart;
|
||||
ELECTRICAL_PINTYPE jj;
|
||||
PIN_ERROR erc = PIN_ERROR::OK;
|
||||
|
||||
/* Analysis of the table of connections. */
|
||||
ELECTRICAL_PINTYPE ref_elect_type = aList->GetItem( aNetItemRef )->m_ElectricalPinType;
|
||||
int local_minconn = NOC;
|
||||
|
||||
if( ref_elect_type == ELECTRICAL_PINTYPE::PT_NC )
|
||||
local_minconn = NPI;
|
||||
|
||||
/* Test pins connected to NetItemRef */
|
||||
for( ; ; netItemTst++ )
|
||||
{
|
||||
if( aNetItemRef == netItemTst )
|
||||
continue;
|
||||
|
||||
// We examine only a given net. We stop the search if the net changes
|
||||
if( ( netItemTst >= aList->size() ) // End of list
|
||||
|| ( aList->GetItemNet( aNetItemRef ) !=
|
||||
aList->GetItemNet( netItemTst ) ) ) // End of net
|
||||
{
|
||||
/* End net code found: minimum connection test. */
|
||||
if( ( *aMinConnexion < NET_NC ) && ( local_minconn < NET_NC ) )
|
||||
{
|
||||
/* Not connected or not driven pin. */
|
||||
bool seterr = true;
|
||||
|
||||
if( local_minconn == NOC && aList->GetItemType( aNetItemRef ) == NETLIST_ITEM::PIN )
|
||||
{
|
||||
/* This pin is not connected: for multiple part per
|
||||
* package, and duplicated pin,
|
||||
* search for another instance of this pin
|
||||
* this will be flagged only if all instances of this pin
|
||||
* are not connected
|
||||
* TODO test also if instances connected are connected to
|
||||
* the same net
|
||||
*/
|
||||
for( unsigned duplicate = 0; duplicate < aList->size(); duplicate++ )
|
||||
{
|
||||
if( aList->GetItemType( duplicate ) != NETLIST_ITEM::PIN )
|
||||
continue;
|
||||
|
||||
if( duplicate == aNetItemRef )
|
||||
continue;
|
||||
|
||||
if( aList->GetItem( aNetItemRef )->m_PinNum !=
|
||||
aList->GetItem( duplicate )->m_PinNum )
|
||||
continue;
|
||||
|
||||
if( ( (SCH_COMPONENT*) aList->GetItem( aNetItemRef )->
|
||||
m_Link )->GetRef( &aList->GetItem( aNetItemRef )-> m_SheetPath ) !=
|
||||
( (SCH_COMPONENT*) aList->GetItem( duplicate )->m_Link )
|
||||
->GetRef( &aList->GetItem( duplicate )->m_SheetPath ) )
|
||||
continue;
|
||||
|
||||
// Same component and same pin. Do dot create error for this pin
|
||||
// if the other pin is connected (i.e. if duplicate net has another
|
||||
// item)
|
||||
if( (duplicate > 0)
|
||||
&& ( aList->GetItemNet( duplicate ) ==
|
||||
aList->GetItemNet( duplicate - 1 ) ) )
|
||||
seterr = false;
|
||||
|
||||
if( (duplicate < aList->size() - 1)
|
||||
&& ( aList->GetItemNet( duplicate ) ==
|
||||
aList->GetItemNet( duplicate + 1 ) ) )
|
||||
seterr = false;
|
||||
}
|
||||
}
|
||||
|
||||
if( seterr )
|
||||
{
|
||||
diagnose( aList->GetItem( aNetItemRef ), nullptr, local_minconn,
|
||||
PIN_ERROR::WARNING );
|
||||
}
|
||||
|
||||
*aMinConnexion = DRV; // inhibiting other messages of this
|
||||
// type for the net.
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
switch( aList->GetItemType( netItemTst ) )
|
||||
{
|
||||
case NETLIST_ITEM::ITEM_UNSPECIFIED:
|
||||
case NETLIST_ITEM::SEGMENT:
|
||||
case NETLIST_ITEM::BUS:
|
||||
case NETLIST_ITEM::JUNCTION:
|
||||
case NETLIST_ITEM::LABEL:
|
||||
case NETLIST_ITEM::HIERLABEL:
|
||||
case NETLIST_ITEM::BUSLABELMEMBER:
|
||||
case NETLIST_ITEM::HIERBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::SHEETBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::SHEETLABEL:
|
||||
case NETLIST_ITEM::GLOBLABEL:
|
||||
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::PINLABEL:
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::NOCONNECT:
|
||||
local_minconn = std::max( NET_NC, local_minconn );
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::PIN:
|
||||
jj = aList->GetItem( netItemTst )->m_ElectricalPinType;
|
||||
local_minconn = std::max( settings.GetPinMinDrive( ref_elect_type, jj ),
|
||||
local_minconn );
|
||||
|
||||
if( netItemTst <= aNetItemRef )
|
||||
break;
|
||||
|
||||
if( erc == PIN_ERROR::OK )
|
||||
{
|
||||
erc = settings.GetPinMapValue( ref_elect_type, jj );
|
||||
|
||||
if( erc != PIN_ERROR::OK )
|
||||
{
|
||||
if( aList->GetConnectionType( netItemTst ) == NET_CONNECTION::UNCONNECTED )
|
||||
{
|
||||
aList->SetConnectionType( netItemTst,
|
||||
NET_CONNECTION::NOCONNECT_SYMBOL_PRESENT );
|
||||
}
|
||||
|
||||
diagnose( aList->GetItem( aNetItemRef ), aList->GetItem( netItemTst ), 1, erc );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ERC_TESTER::TestNoConnectPins()
|
||||
{
|
||||
int err_count = 0;
|
||||
|
@ -723,7 +542,6 @@ int ERC_TESTER::TestSimilarLabels()
|
|||
|
||||
for( const std::pair<NET_NAME_CODE, std::vector<CONNECTION_SUBGRAPH*>> net : nets )
|
||||
{
|
||||
const wxString& netName = net.first.first;
|
||||
std::vector<SCH_PIN*> pins;
|
||||
|
||||
for( CONNECTION_SUBGRAPH* subgraph : net.second )
|
||||
|
|
|
@ -125,13 +125,6 @@ public:
|
|||
int TestSimilarLabels();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef
|
||||
* or between aNetItemRef and aNetItemTst.
|
||||
* if MinConn < 0: this is an error on labels
|
||||
*/
|
||||
void diagnose( NETLIST_OBJECT* NetItemRef, NETLIST_OBJECT* NetItemTst, int MinConnexion,
|
||||
PIN_ERROR Diag );
|
||||
|
||||
SCHEMATIC* m_schematic;
|
||||
};
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include <kicad_string.h>
|
||||
|
||||
#include <class_libentry.h>
|
||||
#include <netlist_object.h>
|
||||
#include <lib_pin.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_text.h>
|
||||
|
|
|
@ -211,33 +211,3 @@ void SCH_EDIT_FRAME::sendNetlistToCvpcb()
|
|||
Kiway().ExpressMail( FRAME_CVPCB, MAIL_EESCHEMA_NETLIST, packet, this );
|
||||
}
|
||||
|
||||
|
||||
NETLIST_OBJECT_LIST* SCH_EDIT_FRAME::BuildNetListBase( bool updateStatusText )
|
||||
{
|
||||
// Ensure netlist is up to date
|
||||
RecalculateConnections( NO_CLEANUP );
|
||||
|
||||
// I own this list until I return it to the new owner.
|
||||
std::unique_ptr<NETLIST_OBJECT_LIST> ret( new NETLIST_OBJECT_LIST() );
|
||||
|
||||
// Creates the flattened sheet list:
|
||||
SCH_SHEET_LIST aSheets = Schematic().GetSheets();
|
||||
|
||||
// Build netlist info
|
||||
bool success = ret->BuildNetListInfo( aSheets );
|
||||
|
||||
if( !success )
|
||||
{
|
||||
if( updateStatusText )
|
||||
SetStatusText( _( "No Objects" ) );
|
||||
return ret.release();
|
||||
}
|
||||
|
||||
wxString msg = wxString::Format( _( "Net count = %d" ), int( ret->size() ) );
|
||||
|
||||
if( updateStatusText )
|
||||
SetStatusText( msg );
|
||||
|
||||
return ret.release();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,464 +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) 2013 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2016 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file netlist_object.cpp
|
||||
* @brief Class NETLIST_OBJECT to handle 1 item connected (in netlist and erc calculations)
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <macros.h>
|
||||
#include <list>
|
||||
|
||||
#include <sch_component.h>
|
||||
#include <sch_connection.h>
|
||||
#include <netlist_object.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <schematic.h>
|
||||
#include <project/net_settings.h>
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
||||
#include <iostream>
|
||||
|
||||
const char* ShowType( NETLIST_ITEM aType )
|
||||
{
|
||||
const char* ret;
|
||||
|
||||
switch( aType )
|
||||
{
|
||||
case NETLIST_ITEM::SEGMENT:
|
||||
ret = "segment"; break;
|
||||
|
||||
case NETLIST_ITEM::BUS:
|
||||
ret = "bus"; break;
|
||||
|
||||
case NETLIST_ITEM::JUNCTION:
|
||||
ret = "junction"; break;
|
||||
|
||||
case NETLIST_ITEM::LABEL:
|
||||
ret = "label"; break;
|
||||
|
||||
case NETLIST_ITEM::HIERLABEL:
|
||||
ret = "hierlabel"; break;
|
||||
|
||||
case NETLIST_ITEM::GLOBLABEL:
|
||||
ret = "glabel"; break;
|
||||
|
||||
case NETLIST_ITEM::BUSLABELMEMBER:
|
||||
ret = "buslblmember"; break;
|
||||
|
||||
case NETLIST_ITEM::HIERBUSLABELMEMBER:
|
||||
ret = "hierbuslblmember"; break;
|
||||
|
||||
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
||||
ret = "gbuslblmember"; break;
|
||||
|
||||
case NETLIST_ITEM::SHEETBUSLABELMEMBER:
|
||||
ret = "sbuslblmember"; break;
|
||||
|
||||
case NETLIST_ITEM::SHEETLABEL:
|
||||
ret = "sheetlabel"; break;
|
||||
|
||||
case NETLIST_ITEM::PINLABEL:
|
||||
ret = "pinlabel"; break;
|
||||
|
||||
case NETLIST_ITEM::PIN:
|
||||
ret = "pin"; break;
|
||||
|
||||
case NETLIST_ITEM::NOCONNECT:
|
||||
ret = "noconnect"; break;
|
||||
|
||||
default:
|
||||
ret = "??"; break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT::Show( std::ostream& out, int ndx ) const
|
||||
{
|
||||
wxString path = m_SheetPath.PathHumanReadable();
|
||||
|
||||
out << "<netItem ndx=\"" << ndx << '"' <<
|
||||
" type=\"" << ShowType( m_Type ) << '"' <<
|
||||
" netCode=\"" << GetNet() << '"' <<
|
||||
" sheet=\"" << TO_UTF8( path ) << '"' <<
|
||||
">\n";
|
||||
|
||||
out << " <start " << m_Start << "/> <end " << m_End << "/>\n";
|
||||
|
||||
if( !m_Label.IsEmpty() )
|
||||
out << " <label>" << m_Label.mb_str() << "</label>\n";
|
||||
|
||||
out << " <sheetpath>" << m_SheetPath.PathHumanReadable().mb_str() << "</sheetpath>\n";
|
||||
|
||||
switch( m_Type )
|
||||
{
|
||||
case NETLIST_ITEM::PIN:
|
||||
/* GetRef() needs to be const
|
||||
out << " <refOfComp>" << GetComponentParent()->GetRef(&m_SheetPath).mb_str()
|
||||
<< "</refOfComp>\n";
|
||||
*/
|
||||
|
||||
if( m_Comp )
|
||||
m_Comp->Show( 1, out );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
// not all the m_Comp classes have working Show functions.
|
||||
;
|
||||
}
|
||||
|
||||
/* was segfault-ing
|
||||
if( m_Comp )
|
||||
m_Comp->Show( 1, out ); // labels may not have good Show() funcs?
|
||||
else
|
||||
out << " m_Comp==NULL\n";
|
||||
*/
|
||||
|
||||
out << "</netItem>\n";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
NETLIST_OBJECT::NETLIST_OBJECT()
|
||||
{
|
||||
m_Type = NETLIST_ITEM::ITEM_UNSPECIFIED; /* Type of this item (see NETLIST_ITEM_T enum) */
|
||||
m_Comp = NULL; /* Pointer on the library item that created this net object
|
||||
* (the parent)*/
|
||||
m_Link = NULL; /* For SCH_SHEET_PIN:
|
||||
* Pointer to the hierarchy sheet that contains this
|
||||
* SCH_SHEET_PIN For Pins: pointer to the component that
|
||||
* contains this pin
|
||||
*/
|
||||
m_Flag = 0; /* flag used in calculations */
|
||||
m_netCode = 0; /* net code for all items except BUS labels because a BUS
|
||||
* label has as many net codes as bus members
|
||||
*/
|
||||
m_BusNetCode = 0; /* Used for BUS connections */
|
||||
m_Member = 0; /* for labels type NETLIST_ITEM::BUSLABELMEMBER ( bus member created
|
||||
* from the BUS label ) member number
|
||||
*/
|
||||
m_ConnectionType = NET_CONNECTION::UNCONNECTED;
|
||||
m_ElectricalPinType =
|
||||
ELECTRICAL_PINTYPE::PT_INPUT; /* Has meaning only for Pins: electrical type of the pin
|
||||
* used to detect conflicts between pins in ERC
|
||||
*/
|
||||
m_netNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
|
||||
* object used to give a name to the net
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
// Copy constructor
|
||||
NETLIST_OBJECT::NETLIST_OBJECT( NETLIST_OBJECT& aSource )
|
||||
{
|
||||
*this = aSource;
|
||||
}
|
||||
|
||||
|
||||
NETLIST_OBJECT::~NETLIST_OBJECT()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// return true if the object is a label of any type
|
||||
bool NETLIST_OBJECT::IsLabelType() const
|
||||
{
|
||||
return m_Type == NETLIST_ITEM::LABEL || m_Type == NETLIST_ITEM::GLOBLABEL
|
||||
|| m_Type == NETLIST_ITEM::HIERLABEL || m_Type == NETLIST_ITEM::BUSLABELMEMBER
|
||||
|| m_Type == NETLIST_ITEM::GLOBBUSLABELMEMBER
|
||||
|| m_Type == NETLIST_ITEM::HIERBUSLABELMEMBER || m_Type == NETLIST_ITEM::PINLABEL;
|
||||
}
|
||||
|
||||
bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT* aNetItem )
|
||||
{
|
||||
if( aNetItem == this ) // Don't compare the same net list object.
|
||||
return false;
|
||||
|
||||
NETLIST_ITEM at = m_Type;
|
||||
NETLIST_ITEM bt = aNetItem->m_Type;
|
||||
|
||||
if( ( at == NETLIST_ITEM::HIERLABEL || at == NETLIST_ITEM::HIERBUSLABELMEMBER )
|
||||
&& ( bt == NETLIST_ITEM::SHEETLABEL || bt == NETLIST_ITEM::SHEETBUSLABELMEMBER ) )
|
||||
{
|
||||
if( m_SheetPath == aNetItem->m_SheetPathInclude )
|
||||
{
|
||||
return true; //connected!
|
||||
}
|
||||
}
|
||||
else if( ( at == NETLIST_ITEM::GLOBLABEL ) && ( bt == NETLIST_ITEM::GLOBLABEL ) )
|
||||
{
|
||||
if( m_Label == aNetItem->m_Label )
|
||||
return true; //connected!
|
||||
}
|
||||
|
||||
return false; //these two are unconnected
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT::ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItems )
|
||||
{
|
||||
SCH_CONNECTION conn;
|
||||
wxCHECK_RET( conn.IsBusLabel( m_Label ),
|
||||
wxT( "<" ) + m_Label + wxT( "> is not a valid bus label." ) );
|
||||
|
||||
if( m_Type == NETLIST_ITEM::HIERLABEL )
|
||||
m_Type = NETLIST_ITEM::HIERBUSLABELMEMBER;
|
||||
else if( m_Type == NETLIST_ITEM::GLOBLABEL )
|
||||
m_Type = NETLIST_ITEM::GLOBBUSLABELMEMBER;
|
||||
else if( m_Type == NETLIST_ITEM::SHEETLABEL )
|
||||
m_Type = NETLIST_ITEM::SHEETBUSLABELMEMBER;
|
||||
else if( m_Type == NETLIST_ITEM::LABEL )
|
||||
m_Type = NETLIST_ITEM::BUSLABELMEMBER;
|
||||
else
|
||||
wxCHECK_RET( false, wxT( "Net list object type is not valid." ) );
|
||||
|
||||
// NOTE: all netlist objects generated from a single bus definition need to have different
|
||||
// member codes set. For bus vectors, the member code matches the vector index, but for
|
||||
// bus groups (including with nested vectors) the code is something arbitrary.
|
||||
long member_offset = 0;
|
||||
|
||||
auto alias = static_cast<SCH_ITEM*>( m_Comp )->Schematic()->GetBusAlias( m_Label );
|
||||
wxString group_name;
|
||||
bool self_set = false;
|
||||
std::vector<wxString> bus_contents_vec;
|
||||
|
||||
if( alias || NET_SETTINGS::ParseBusGroup( m_Label, &group_name, &bus_contents_vec ) )
|
||||
{
|
||||
if( alias )
|
||||
{
|
||||
for( const wxString& member : alias->Members() )
|
||||
bus_contents_vec.emplace_back( member );
|
||||
}
|
||||
|
||||
// For named bus groups, like "USB{DP DM}"
|
||||
wxString group_prefix = ( group_name != "" ) ? ( group_name + "." ) : "";
|
||||
|
||||
std::list<wxString> bus_contents( bus_contents_vec.begin(), bus_contents_vec.end() );
|
||||
|
||||
for( const auto& bus_member : bus_contents )
|
||||
{
|
||||
wxString prefix;
|
||||
std::vector<wxString> members;
|
||||
|
||||
// Nested bus vector inside a bus group
|
||||
if( NET_SETTINGS::ParseBusVector( bus_member, &prefix, &members ) )
|
||||
{
|
||||
long begin, end;
|
||||
|
||||
prefix = group_prefix + prefix;
|
||||
begin = conn.VectorStart();
|
||||
end = conn.VectorEnd();
|
||||
|
||||
if( !self_set )
|
||||
{
|
||||
m_Label = members[0];
|
||||
m_Member = ( begin++ ) + ( member_offset++ );
|
||||
|
||||
self_set = true;
|
||||
begin++;
|
||||
}
|
||||
|
||||
fillBusVector( aNetListItems, prefix, begin, end, member_offset );
|
||||
member_offset += std::abs( end - begin );
|
||||
}
|
||||
else if( auto nested_alias = static_cast<SCH_ITEM*>( m_Comp )->Schematic()->GetBusAlias(
|
||||
bus_member ) )
|
||||
{
|
||||
// Nested alias inside a group
|
||||
for( const auto& alias_member : nested_alias->Members() )
|
||||
{
|
||||
bus_contents.push_back( alias_member );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !self_set )
|
||||
{
|
||||
m_Label = group_prefix + bus_member;
|
||||
m_Member = member_offset++;
|
||||
self_set = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto item = new NETLIST_OBJECT( *this );
|
||||
item->m_Label = group_prefix + bus_member;
|
||||
item->m_Member = member_offset++;
|
||||
aNetListItems.push_back( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( NET_SETTINGS::ParseBusVector( m_Label, &group_name, &bus_contents_vec ) )
|
||||
{
|
||||
long begin = conn.VectorStart();
|
||||
long end = conn.VectorEnd();
|
||||
|
||||
m_Label = bus_contents_vec[0];
|
||||
m_Member = begin;
|
||||
|
||||
fillBusVector( aNetListItems, group_name, begin + 1, end, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void NETLIST_OBJECT::fillBusVector( NETLIST_OBJECT_LIST& aNetListItems,
|
||||
wxString aName, long aBegin, long aEnd, long aOffset )
|
||||
{
|
||||
for( long member = aBegin; member <= aEnd; member++ )
|
||||
{
|
||||
auto item = new NETLIST_OBJECT( *this );
|
||||
|
||||
item->m_Label = aName;
|
||||
item->m_Label << member;
|
||||
item->m_Member = member;
|
||||
|
||||
aNetListItems.push_back( item );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool NETLIST_OBJECT::IsLabelGlobal() const
|
||||
{
|
||||
// return true if the object is a global label
|
||||
// * a actual global label
|
||||
// * a pin label coming from a invisible power pin
|
||||
return ( m_Type == NETLIST_ITEM::PINLABEL ) || ( m_Type == NETLIST_ITEM::GLOBLABEL )
|
||||
|| ( m_Type == NETLIST_ITEM::GLOBBUSLABELMEMBER );
|
||||
}
|
||||
|
||||
|
||||
bool NETLIST_OBJECT::IsLabelBusMemberType() const
|
||||
{
|
||||
// return true if the object is a bus label member build from a
|
||||
// schematic bus label (like label[xx..yy)
|
||||
// They are labels with very specific properties, especially for connection
|
||||
// between them: 2 bus label members can be connected only
|
||||
// if they have the same member value.
|
||||
return ( m_Type == NETLIST_ITEM::SHEETBUSLABELMEMBER )
|
||||
|| ( m_Type == NETLIST_ITEM::BUSLABELMEMBER )
|
||||
|| ( m_Type == NETLIST_ITEM::HIERBUSLABELMEMBER )
|
||||
|| ( m_Type == NETLIST_ITEM::GLOBBUSLABELMEMBER );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* return the net name of the item
|
||||
*/
|
||||
wxString NETLIST_OBJECT::GetNetName() const
|
||||
{
|
||||
if( m_netNameCandidate == NULL )
|
||||
return wxEmptyString;
|
||||
|
||||
wxString netName;
|
||||
|
||||
if( m_netNameCandidate->m_Type == NETLIST_ITEM::PIN )
|
||||
return GetShortNetName();
|
||||
|
||||
if( !m_netNameCandidate->IsLabelGlobal() )
|
||||
{
|
||||
// usual net name, prefix it by the sheet path
|
||||
netName = m_netNameCandidate->m_SheetPath.PathHumanReadable();
|
||||
}
|
||||
|
||||
netName += m_netNameCandidate->m_Label;
|
||||
|
||||
return netName;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the short net name of the item i.e. the net name
|
||||
* from the "best" label without any prefix.
|
||||
* 2 different nets can have the same short name
|
||||
*/
|
||||
wxString NETLIST_OBJECT::GetShortNetName() const
|
||||
{
|
||||
if( m_netNameCandidate == NULL )
|
||||
return wxEmptyString;
|
||||
|
||||
wxString netName;
|
||||
|
||||
if( m_netNameCandidate->m_Type == NETLIST_ITEM::PIN )
|
||||
{
|
||||
SCH_COMPONENT* link = m_netNameCandidate->GetComponentParent();
|
||||
if( link ) // Should be always true
|
||||
{
|
||||
netName = wxT("Net-(");
|
||||
netName << link->GetRef( &m_netNameCandidate->m_SheetPath );
|
||||
netName << wxT("-Pad") << m_netNameCandidate->m_PinNum << wxT(")");
|
||||
}
|
||||
}
|
||||
else
|
||||
netName = m_netNameCandidate->m_Label;
|
||||
|
||||
return netName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set m_netNameCandidate to a connected item which will
|
||||
* be used to calcule the net name of the item
|
||||
* Obviously the candidate can be only a label
|
||||
* If there is no label on the net, a pad name will be
|
||||
* used to build a net name (something like Cmp<REF>_Pad<PAD_NAME>
|
||||
* @param aCandidate = the connected item candidate
|
||||
*/
|
||||
void NETLIST_OBJECT::SetNetNameCandidate( NETLIST_OBJECT* aCandidate )
|
||||
{
|
||||
switch( aCandidate->m_Type )
|
||||
{
|
||||
case NETLIST_ITEM::HIERLABEL:
|
||||
case NETLIST_ITEM::LABEL:
|
||||
case NETLIST_ITEM::PINLABEL:
|
||||
case NETLIST_ITEM::GLOBLABEL:
|
||||
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::SHEETBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::PIN:
|
||||
m_netNameCandidate = aCandidate;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const wxString NETLIST_OBJECT::GetPinNameText() const
|
||||
{
|
||||
wxString name;
|
||||
// returns the pin name, for NETLIST_ITEM::PIN (usual pin) item.
|
||||
if( m_Type == NETLIST_ITEM::PIN )
|
||||
{
|
||||
name = static_cast<LIB_PIN*>( m_Comp )->GetName();
|
||||
|
||||
if( name == "~" ) //empty name
|
||||
name = wxEmptyString;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
|
@ -1,494 +0,0 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2013 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file netlist_object.h
|
||||
* @brief Definition of the NETLIST_OBJECT class.
|
||||
*/
|
||||
|
||||
#ifndef NETLIST_OBJECT_H
|
||||
#define NETLIST_OBJECT_H
|
||||
|
||||
|
||||
#include <sch_sheet_path.h>
|
||||
#include <lib_pin.h>
|
||||
#include <sch_item.h>
|
||||
|
||||
class NETLIST_OBJECT_LIST;
|
||||
class SCH_COMPONENT;
|
||||
|
||||
|
||||
/* Type of Net objects (wires, labels, pins...) */
|
||||
enum class NETLIST_ITEM
|
||||
{
|
||||
ITEM_UNSPECIFIED, // only for not yet initialized instances
|
||||
SEGMENT, // connection by wire
|
||||
BUS, // connection by bus
|
||||
JUNCTION, // connection by junction: can connect to
|
||||
// or more crossing wires
|
||||
LABEL, // this is a local label
|
||||
GLOBLABEL, // this is a global label that connect all
|
||||
// others global label in whole hierarchy
|
||||
HIERLABEL, // element to indicate connection to a
|
||||
// higher-level sheet
|
||||
SHEETLABEL, // element to indicate connection to a
|
||||
// lower-level sheet.
|
||||
BUSLABELMEMBER, /* created when a bus label is found:
|
||||
* the bus label (like DATA[0..7] is
|
||||
* converted to n single labels like
|
||||
* DATA0, DATA1 ...
|
||||
* These objects are living only in the current
|
||||
* NETLIST_OBJECT_LIST, not in shematic.
|
||||
*/
|
||||
GLOBBUSLABELMEMBER, // see NET_BUSLABELMEMBER, used when a
|
||||
// global bus label is found
|
||||
HIERBUSLABELMEMBER, // see NET_BUSLABELMEMBER, used when a
|
||||
// hierarchical bus label is found
|
||||
SHEETBUSLABELMEMBER, // see NET_BUSLABELMEMBER, used when a
|
||||
// pin sheet label using bus notation
|
||||
// is found
|
||||
PINLABEL, /* created when a pin is POWER (IN or
|
||||
* OUT) with invisible attribute is found:
|
||||
* these pins are equivalent to a global
|
||||
* label and are automatically connected
|
||||
*/
|
||||
PIN, // this is an usual pin
|
||||
NOCONNECT // this is a no connect symbol
|
||||
};
|
||||
|
||||
|
||||
/* Values for .m_FlagOfConnection member */
|
||||
enum class NET_CONNECTION
|
||||
{
|
||||
UNCONNECTED = 0, /* Pin or Label not connected (error) */
|
||||
NOCONNECT_SYMBOL_PRESENT, /* Pin not connected but have a NoConnect
|
||||
* symbol on it (no error) */
|
||||
PAD_CONNECT /* Normal connection (no error) */
|
||||
};
|
||||
|
||||
|
||||
class NETLIST_OBJECT
|
||||
{
|
||||
public:
|
||||
NETLIST_ITEM m_Type; /* Type of item (see NETLIST_ITEM_T enum) */
|
||||
EDA_ITEM* m_Comp; /* Pointer to the item that
|
||||
* created this net object (the parent)
|
||||
*/
|
||||
SCH_ITEM* m_Link; /* For SCH_SHEET_PIN:
|
||||
* Pointer to the hierarchy sheet that
|
||||
* contains this SCH_SHEET_PIN
|
||||
* For Pins: pointer to the schematic component
|
||||
* that contains this pin
|
||||
*/
|
||||
int m_Flag; /* flag used in calculations */
|
||||
SCH_SHEET_PATH m_SheetPath; // the sheet path which contains this item
|
||||
SCH_SHEET_PATH m_SheetPathInclude; // sheet path which contains the hierarchical label
|
||||
ELECTRICAL_PINTYPE m_ElectricalPinType; // Has meaning only for Pins: electrical type of the pin
|
||||
int m_BusNetCode; /* Used for BUS connections */
|
||||
int m_Member; /* for labels type NET_BUSLABELMEMBER ( bus member
|
||||
* created from the BUS label ) member number.
|
||||
*/
|
||||
NET_CONNECTION m_ConnectionType; // Used to store the connection type
|
||||
wxString m_PinNum; // pin number
|
||||
wxString m_Label; // Label text (for labels) or Pin name (for pins)
|
||||
wxPoint m_Start; // Position of object or for segments: starting point
|
||||
wxPoint m_End; // For segments (wire and buses): ending point
|
||||
|
||||
private:
|
||||
int m_netCode; /* net code for all items except BUS
|
||||
* labels because a BUS label has
|
||||
* as many net codes as bus members
|
||||
*/
|
||||
NETLIST_OBJECT* m_netNameCandidate; /* a pointer to a label connected to the net,
|
||||
* that can be used to give a name to the net
|
||||
* or a pin if there is no label in net
|
||||
* When no label, the pin is used to build
|
||||
* default net name.
|
||||
*/
|
||||
|
||||
public:
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( std::ostream& out, int ndx ) const;
|
||||
#endif
|
||||
|
||||
NETLIST_OBJECT();
|
||||
NETLIST_OBJECT( NETLIST_OBJECT& aSource ); // Copy constructor
|
||||
|
||||
~NETLIST_OBJECT();
|
||||
|
||||
// Accessors:
|
||||
void SetNet( int aNetCode ) { m_netCode = aNetCode; }
|
||||
int GetNet() const { return m_netCode; }
|
||||
|
||||
/**
|
||||
* Set the item connection type:
|
||||
* UNCONNECTED Pin or Label not connected (error)
|
||||
* NOCONNECT_SYMBOL_PRESENT Pin not connected but have a NoConnect
|
||||
* symbol on it (no error)
|
||||
* PAD_CONNECT Normal connection (no error)
|
||||
*/
|
||||
void SetConnectionType( NET_CONNECTION aFlg = NET_CONNECTION::UNCONNECTED )
|
||||
{
|
||||
m_ConnectionType = aFlg;
|
||||
}
|
||||
|
||||
NET_CONNECTION GetConnectionType() const
|
||||
{
|
||||
return m_ConnectionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set m_netNameCandidate to a connected item which will
|
||||
* be used to calcule the net name of the item
|
||||
* Obviously the candidate can be only a label
|
||||
* when there is no label on the net a pad which will
|
||||
* used to build a net name (something like Cmp<REF>_Pad<PAD_NAME>
|
||||
* @param aCandidate = the connected item candidate
|
||||
*/
|
||||
void SetNetNameCandidate( NETLIST_OBJECT* aCandidate );
|
||||
|
||||
/**
|
||||
* @return true if an item has already a net name candidate
|
||||
* and false if not ( m_netNameCandidate == NULL )
|
||||
*/
|
||||
bool HasNetNameCandidate() { return m_netNameCandidate != NULL; }
|
||||
|
||||
/**
|
||||
* returns a pin number in wxString form. Pin numbers are not always
|
||||
* numbers. \"A23\" would be a valid pin number.
|
||||
*/
|
||||
const wxString& GetPinNumText() const
|
||||
{
|
||||
return m_PinNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the pin name, for NET_PIN (usual pin) item.
|
||||
*/
|
||||
const wxString GetPinNameText() const;
|
||||
|
||||
/** For Pins (NET_PINS):
|
||||
* @return the schematic component which contains this pin
|
||||
* (Note: this is the schematic component, not the library component
|
||||
* for others items: return NULL
|
||||
*/
|
||||
SCH_COMPONENT* GetComponentParent() const
|
||||
{
|
||||
if( m_Link && m_Link->Type() == SCH_COMPONENT_T )
|
||||
return (SCH_COMPONENT*) m_Link;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function IsLabelConnected
|
||||
* tests if the net list object is a hierarchical label or sheet label and is
|
||||
* connected to an associated hierarchical label or sheet label of \a aNetItem.
|
||||
*
|
||||
* @param aNetItem A pointer to a NETLIST_OBJECT to test against.
|
||||
* @return A bool value of true if there is a connection with \a aNetItem or false
|
||||
* if no connection to \a aNetItem.
|
||||
*/
|
||||
bool IsLabelConnected( NETLIST_OBJECT* aNetItem );
|
||||
|
||||
/**
|
||||
* Function IsLabelGlobal
|
||||
* @return true if the object is a global label
|
||||
* (i.e. an real global label or a pin label coming
|
||||
* from a power pin invisible
|
||||
*/
|
||||
bool IsLabelGlobal() const;
|
||||
|
||||
/**
|
||||
* Function IsLabelBusMemberType
|
||||
* @return true if the object is a bus label member build from a
|
||||
* schematic bus label (like label[xx..yy], xx and yy are the first and last
|
||||
* bus member id)
|
||||
* bus label members have specific properties:
|
||||
* they do not live in schematic
|
||||
* they have specific properties in connections:
|
||||
* 2 bus label members can be connected connected only if they have the same member value.
|
||||
*/
|
||||
bool IsLabelBusMemberType() const;
|
||||
|
||||
/**
|
||||
* Function IsLabelType
|
||||
* @return true if the object is a label of any type
|
||||
*/
|
||||
bool IsLabelType() const;
|
||||
|
||||
/**
|
||||
* Function GetNetName
|
||||
* @return the full net name of the item, i.e. the net name from the "best" label,
|
||||
* prefixed by the sheet path
|
||||
*/
|
||||
wxString GetNetName() const;
|
||||
|
||||
/**
|
||||
* Function GetShortNetName
|
||||
* @return the short net name of the item i.e. the net name from the "best" label
|
||||
* without any prefix. 2 different nets can have the same short name
|
||||
*/
|
||||
wxString GetShortNetName() const;
|
||||
|
||||
/**
|
||||
* Function ConvertBusToNetListItems
|
||||
* breaks the text of a bus label type net list object into as many members as
|
||||
* it contains and creates a #NETLIST_OBJECT for each label and adds it to \a
|
||||
* aNetListItems.
|
||||
*
|
||||
* @param aNetListItems A reference to vector of #NETLIST_OBJECT pointers to add
|
||||
* the bus label NETLIST_OBJECTs.
|
||||
*/
|
||||
void ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItems );
|
||||
|
||||
private:
|
||||
/**
|
||||
* Given a bus vector, append the appropriate members into the list
|
||||
* If given something like "DATA", 7, 0, will append "DATA7", "DATA6", etc.
|
||||
*
|
||||
* @param aNetListItems is the list to append to
|
||||
* @param aName is the prefix for the vector, like "DATA"
|
||||
* @param aBegin is the first entry in the vector
|
||||
* @param aEnd is the last entry in the vector
|
||||
* @param aOffset is an offset to add to the member code for each member
|
||||
*/
|
||||
void fillBusVector( NETLIST_OBJECT_LIST& aNetListItems, wxString aName,
|
||||
long aBegin, long aEnd, long aOffset );
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Type NETLIST_OBJECTS
|
||||
* is a container referring to (not owning) NETLIST_OBJECTs, which are connected items
|
||||
* in a full schematic hierarchy. It is useful when referring to NETLIST_OBJECTs
|
||||
* actually owned by some other container.
|
||||
*/
|
||||
typedef std::vector<NETLIST_OBJECT*> NETLIST_OBJECTS;
|
||||
|
||||
|
||||
/**
|
||||
* NETLIST_OBJECT_LIST
|
||||
* is a container holding and _owning_ NETLIST_OBJECTs, which are connected items
|
||||
* in a full schematic hierarchy. It is helpful for netlist and ERC calculations.
|
||||
*/
|
||||
class NETLIST_OBJECT_LIST : public NETLIST_OBJECTS
|
||||
{
|
||||
int m_lastNetCode; // Used in intermediate calculation: last net code created
|
||||
int m_lastBusNetCode; // Used in intermediate calculation:
|
||||
// last net code created for bus members
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* NETLIST_OBJECT_LIST handle a list of connected items.
|
||||
* these NETLIST_OBJECT items are freeed by the destructor
|
||||
*/
|
||||
NETLIST_OBJECT_LIST()
|
||||
{
|
||||
// Do not leave some members uninitialized:
|
||||
m_lastNetCode = 0;
|
||||
m_lastBusNetCode = 0;
|
||||
}
|
||||
|
||||
~NETLIST_OBJECT_LIST();
|
||||
|
||||
/**
|
||||
* Function BuildNetListInfo
|
||||
* the master function of tgis class.
|
||||
* Build the list of connected objects (pins, labels ...) and
|
||||
* all info to generate netlists or run ERC diags
|
||||
* @param aSheets = the flattened sheet list
|
||||
* @return true if OK, false is not item found
|
||||
*/
|
||||
bool BuildNetListInfo( SCH_SHEET_LIST& aSheets );
|
||||
|
||||
/**
|
||||
* Acces to an item in list
|
||||
*/
|
||||
NETLIST_OBJECT* GetItem( unsigned aIdx ) const
|
||||
{
|
||||
return *( this->begin() + aIdx );
|
||||
}
|
||||
|
||||
/**
|
||||
* Acces to an item type
|
||||
*/
|
||||
NETLIST_ITEM GetItemType( unsigned aIdx ) const
|
||||
{
|
||||
return GetItem( aIdx )->m_Type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acces to an item net code
|
||||
*/
|
||||
int GetItemNet( unsigned aIdx ) const
|
||||
{
|
||||
return GetItem( aIdx )->GetNet();
|
||||
}
|
||||
|
||||
NET_CONNECTION GetConnectionType( unsigned aIdx )
|
||||
{
|
||||
return GetItem( aIdx )->GetConnectionType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the item connection type:
|
||||
* UNCONNECTED Pin or Label not connected (error)
|
||||
* NOCONNECT_SYMBOL_PRESENT Pin not connected but have a NoConnect
|
||||
* symbol on it (no error)
|
||||
* PAD_CONNECT Normal connection (no error)
|
||||
*/
|
||||
void SetConnectionType( unsigned aIdx, NET_CONNECTION aFlg = NET_CONNECTION::UNCONNECTED )
|
||||
{
|
||||
GetItem( aIdx )->SetConnectionType( aFlg );
|
||||
}
|
||||
|
||||
/** Delete all objects in list and clear list */
|
||||
void Clear();
|
||||
|
||||
/**
|
||||
* Reset the connection type of all items to UNCONNECTED type
|
||||
*/
|
||||
void ResetConnectionsType()
|
||||
{
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
GetItem( ii )->SetConnectionType( NET_CONNECTION::UNCONNECTED );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sorts the list of connected items by net code
|
||||
*/
|
||||
void SortListbyNetcode();
|
||||
|
||||
/*
|
||||
* Sorts the list of connected items by sheet.
|
||||
* This sorting is used when searching "physical" connection between items
|
||||
* because obviously only items inside the same sheet can be connected
|
||||
*/
|
||||
void SortListbySheet();
|
||||
|
||||
#if defined(DEBUG)
|
||||
void DumpNetTable()
|
||||
{
|
||||
for( unsigned idx = 0; idx < size(); ++idx )
|
||||
{
|
||||
GetItem( idx )->Show( std::cout, idx );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
/*
|
||||
* Propagate aNewNetCode to items having an internal netcode aOldNetCode
|
||||
* used to interconnect group of items already physically connected,
|
||||
* when a new connection is found between aOldNetCode and aNewNetCode
|
||||
*/
|
||||
void propagateNetCode( int aOldNetCode, int aNewNetCode, bool aIsBus );
|
||||
|
||||
/*
|
||||
* This function merges the net codes of groups of objects already connected
|
||||
* to labels (wires, bus, pins ... ) when 2 labels are equivalents
|
||||
* (i.e. group objects connected by labels)
|
||||
*/
|
||||
void labelConnect( NETLIST_OBJECT* aLabelRef );
|
||||
|
||||
/* Comparison function to sort by increasing Netcode the list of connected items
|
||||
*/
|
||||
static bool sortItemsbyNetcode( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 )
|
||||
{
|
||||
return Objet1->GetNet() < Objet2->GetNet();
|
||||
}
|
||||
|
||||
/* Comparison routine to sort items by Sheet path
|
||||
*/
|
||||
static bool sortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 )
|
||||
{
|
||||
return Objet1->m_SheetPath.Cmp( Objet2->m_SheetPath ) < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Propagate net codes from a parent sheet to an include sheet,
|
||||
* from a pin sheet connection
|
||||
*/
|
||||
void sheetLabelConnect( NETLIST_OBJECT* aSheetLabel );
|
||||
|
||||
void pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus, int start );
|
||||
|
||||
/**
|
||||
* Search connections between a junction and segments
|
||||
* Propagate the junction net code to objects connected by this junction.
|
||||
* The junction must have a valid net code
|
||||
* The list of objects is expected sorted by sheets.
|
||||
* Search is done from index aIdxStart to the last element of list
|
||||
*/
|
||||
void segmentToPointConnect( NETLIST_OBJECT* aJonction, bool aIsBus, int aIdxStart );
|
||||
|
||||
|
||||
/**
|
||||
* Function connectBusLabels
|
||||
* Propagate the net code (and create it, if not yet existing) between
|
||||
* all bus label member objects connected by they name.
|
||||
* Search is done in the entire list
|
||||
*/
|
||||
void connectBusLabels();
|
||||
|
||||
/**
|
||||
* Set the m_FlagOfConnection member of items in list
|
||||
* depending on the connection type:
|
||||
* UNCONNECTED, PAD_CONNECT or NOCONNECT_SYMBOL_PRESENT
|
||||
* The list is expected sorted by order of net code,
|
||||
* i.e. items having the same net code are grouped
|
||||
*/
|
||||
void setUnconnectedFlag();
|
||||
|
||||
/**
|
||||
* Function findBestNetNameForEachNet
|
||||
* fill the .m_NetNameCandidate member of each item of aNetItemBuffer
|
||||
* with a reference to the "best" NETLIST_OBJECT usable to give a name to the net
|
||||
* If no suitable object found, .m_NetNameCandidate is filled with 0.
|
||||
* The "best" NETLIST_OBJECT is a NETLIST_OBJECT that have the type label
|
||||
* and by priority order:
|
||||
* the label is global or local
|
||||
* the label is in the first sheet in a hierarchy (the root sheet has the most priority)
|
||||
* alphabetic order.
|
||||
*/
|
||||
void findBestNetNameForEachNet();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function IsBusLabel
|
||||
* test if \a aLabel has a bus notation.
|
||||
*
|
||||
* @param aLabel A wxString object containing the label to test.
|
||||
* @return true if text is a bus notation format otherwise false is returned.
|
||||
*/
|
||||
extern bool IsBusLabel( const wxString& aLabel );
|
||||
|
||||
#endif // NETLIST_OBJECT_H
|
|
@ -1,871 +0,0 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2018 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 <netlist_object.h>
|
||||
#include <class_library.h>
|
||||
#include <macros.h>
|
||||
#include <sch_junction.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_line.h>
|
||||
#include <sch_text.h>
|
||||
#include <sch_screen.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <algorithm>
|
||||
|
||||
#define IS_WIRE false
|
||||
#define IS_BUS true
|
||||
|
||||
//#define NETLIST_DEBUG
|
||||
|
||||
NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::Clear()
|
||||
{
|
||||
NETLIST_OBJECTS::iterator iter;
|
||||
|
||||
for( iter = begin(); iter != end(); iter++ )
|
||||
{
|
||||
NETLIST_OBJECT* item = *iter;
|
||||
delete item;
|
||||
}
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::SortListbyNetcode()
|
||||
{
|
||||
sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsbyNetcode );
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::SortListbySheet()
|
||||
{
|
||||
sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsBySheet );
|
||||
}
|
||||
|
||||
|
||||
bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
||||
{
|
||||
SCH_SHEET_PATH* sheet;
|
||||
|
||||
// Fill list with connected items from the flattened sheet list
|
||||
for( unsigned i = 0; i < aSheets.size(); i++ )
|
||||
{
|
||||
sheet = &aSheets[i];
|
||||
|
||||
for( auto item : sheet->LastScreen()->Items() )
|
||||
item->GetNetListItem( *this, sheet );
|
||||
}
|
||||
|
||||
if( size() == 0 )
|
||||
return false;
|
||||
|
||||
// Sort objects by Sheet
|
||||
SortListbySheet();
|
||||
|
||||
sheet = &(GetItem( 0 )->m_SheetPath);
|
||||
m_lastNetCode = m_lastBusNetCode = 1;
|
||||
|
||||
for( unsigned ii = 0, istart = 0; ii < size(); ii++ )
|
||||
{
|
||||
NETLIST_OBJECT* net_item = GetItem( ii );
|
||||
|
||||
if( net_item->m_SheetPath != *sheet ) // Sheet change
|
||||
{
|
||||
sheet = &(net_item->m_SheetPath);
|
||||
istart = ii;
|
||||
}
|
||||
|
||||
switch( net_item->m_Type )
|
||||
{
|
||||
case NETLIST_ITEM::ITEM_UNSPECIFIED:
|
||||
wxMessageBox( wxT( "BuildNetListInfo() error" ) );
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::PIN:
|
||||
case NETLIST_ITEM::PINLABEL:
|
||||
case NETLIST_ITEM::SHEETLABEL:
|
||||
case NETLIST_ITEM::NOCONNECT:
|
||||
if( net_item->GetNet() != 0 )
|
||||
break;
|
||||
|
||||
// Intentionally fall through if there is no net assigned
|
||||
KI_FALLTHROUGH;
|
||||
|
||||
case NETLIST_ITEM::SEGMENT:
|
||||
// Test connections point to point type without bus.
|
||||
if( net_item->GetNet() == 0 )
|
||||
{
|
||||
net_item->SetNet( m_lastNetCode );
|
||||
m_lastNetCode++;
|
||||
}
|
||||
|
||||
pointToPointConnect( net_item, IS_WIRE, istart );
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::JUNCTION:
|
||||
// Control of the junction outside BUS.
|
||||
if( net_item->GetNet() == 0 )
|
||||
{
|
||||
net_item->SetNet( m_lastNetCode );
|
||||
m_lastNetCode++;
|
||||
}
|
||||
|
||||
segmentToPointConnect( net_item, IS_WIRE, istart );
|
||||
|
||||
// Control of the junction, on BUS.
|
||||
if( net_item->m_BusNetCode == 0 )
|
||||
{
|
||||
net_item->m_BusNetCode = m_lastBusNetCode;
|
||||
m_lastBusNetCode++;
|
||||
}
|
||||
|
||||
segmentToPointConnect( net_item, IS_BUS, istart );
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::LABEL:
|
||||
case NETLIST_ITEM::HIERLABEL:
|
||||
case NETLIST_ITEM::GLOBLABEL:
|
||||
// Test connections type junction without bus.
|
||||
if( net_item->GetNet() == 0 )
|
||||
{
|
||||
net_item->SetNet( m_lastNetCode );
|
||||
m_lastNetCode++;
|
||||
}
|
||||
|
||||
segmentToPointConnect( net_item, IS_WIRE, istart );
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::SHEETBUSLABELMEMBER:
|
||||
if( net_item->m_BusNetCode != 0 )
|
||||
break;
|
||||
|
||||
// Intentionally fall through if there is no bus assigned
|
||||
KI_FALLTHROUGH;
|
||||
|
||||
case NETLIST_ITEM::BUS:
|
||||
// Control type connections point to point mode bus
|
||||
if( net_item->m_BusNetCode == 0 )
|
||||
{
|
||||
net_item->m_BusNetCode = m_lastBusNetCode;
|
||||
m_lastBusNetCode++;
|
||||
}
|
||||
|
||||
pointToPointConnect( net_item, IS_BUS, istart );
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::BUSLABELMEMBER:
|
||||
case NETLIST_ITEM::HIERBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
||||
// Control connections similar has on BUS
|
||||
if( net_item->GetNet() == 0 )
|
||||
{
|
||||
net_item->m_BusNetCode = m_lastBusNetCode;
|
||||
m_lastBusNetCode++;
|
||||
}
|
||||
|
||||
segmentToPointConnect( net_item, IS_BUS, istart );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(NETLIST_DEBUG) && defined(DEBUG)
|
||||
std::cout << "\n\nafter sheet local\n\n";
|
||||
DumpNetTable();
|
||||
#endif
|
||||
|
||||
// Updating the Bus Labels Netcode connected by Bus
|
||||
connectBusLabels();
|
||||
|
||||
// Group objects by label.
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
switch( GetItem( ii )->m_Type )
|
||||
{
|
||||
case NETLIST_ITEM::PIN:
|
||||
case NETLIST_ITEM::SHEETLABEL:
|
||||
case NETLIST_ITEM::SEGMENT:
|
||||
case NETLIST_ITEM::JUNCTION:
|
||||
case NETLIST_ITEM::BUS:
|
||||
case NETLIST_ITEM::NOCONNECT:
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::LABEL:
|
||||
case NETLIST_ITEM::GLOBLABEL:
|
||||
case NETLIST_ITEM::PINLABEL:
|
||||
case NETLIST_ITEM::BUSLABELMEMBER:
|
||||
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
||||
labelConnect( GetItem( ii ) );
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::SHEETBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::HIERLABEL:
|
||||
case NETLIST_ITEM::HIERBUSLABELMEMBER:
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::ITEM_UNSPECIFIED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(NETLIST_DEBUG) && defined(DEBUG)
|
||||
std::cout << "\n\nafter sheet global\n\n";
|
||||
DumpNetTable();
|
||||
#endif
|
||||
|
||||
// Connection between hierarchy sheets
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
if( GetItem( ii )->m_Type == NETLIST_ITEM::SHEETLABEL
|
||||
|| GetItem( ii )->m_Type == NETLIST_ITEM::SHEETBUSLABELMEMBER )
|
||||
sheetLabelConnect( GetItem( ii ) );
|
||||
}
|
||||
|
||||
// Sort objects by NetCode
|
||||
SortListbyNetcode();
|
||||
|
||||
#if defined(NETLIST_DEBUG) && defined(DEBUG)
|
||||
std::cout << "\n\nafter qsort()\n";
|
||||
DumpNetTable();
|
||||
#endif
|
||||
|
||||
// Compress numbers of Netcode having consecutive values.
|
||||
int NetCode = 0;
|
||||
m_lastNetCode = 0;
|
||||
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
if( GetItem( ii )->GetNet() != m_lastNetCode )
|
||||
{
|
||||
NetCode++;
|
||||
m_lastNetCode = GetItem( ii )->GetNet();
|
||||
}
|
||||
|
||||
GetItem( ii )->SetNet( NetCode );
|
||||
}
|
||||
|
||||
// Set the minimal connection info:
|
||||
setUnconnectedFlag();
|
||||
|
||||
// find the best label object to give the best net name to each net
|
||||
findBestNetNameForEachNet();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Helper function to give a priority to sort labels:
|
||||
// NETLIST_ITEM::PINLABEL, NETLIST_ITEM::GLOBBUSLABELMEMBER and NETLIST_ITEM::GLOBLABEL are global labels
|
||||
// and the priority is high
|
||||
static int getPriority( const NETLIST_OBJECT* Objet )
|
||||
{
|
||||
switch( Objet->m_Type )
|
||||
{
|
||||
case NETLIST_ITEM::PIN:
|
||||
return 1;
|
||||
case NETLIST_ITEM::LABEL:
|
||||
return 2;
|
||||
case NETLIST_ITEM::HIERLABEL:
|
||||
return 3;
|
||||
case NETLIST_ITEM::PINLABEL:
|
||||
return 4;
|
||||
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
||||
return 5;
|
||||
case NETLIST_ITEM::GLOBLABEL:
|
||||
return 6;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* function evalLabelsPriority used by findBestNetNameForEachNet()
|
||||
* evalLabelsPriority calculates the priority of alabel1 and aLabel2
|
||||
* return true if alabel1 has a higher priority than aLabel2
|
||||
*/
|
||||
static bool evalLabelsPriority( const NETLIST_OBJECT* aLabel1, const NETLIST_OBJECT* aLabel2 )
|
||||
{
|
||||
// Global labels have the highest prioriy.
|
||||
// For local labels: names are prefixed by their sheetpath
|
||||
// use name defined in the more top level hierarchical sheet
|
||||
// Note: the final net name uses human sheetpath name, not timestamp sheetpath name
|
||||
// They are equivalent, but not for human readers.
|
||||
if( ! aLabel1->IsLabelGlobal() && ! aLabel2->IsLabelGlobal() )
|
||||
{
|
||||
if( aLabel1->m_SheetPath.size() != aLabel2->m_SheetPath.size() )
|
||||
return aLabel1->m_SheetPath.size() < aLabel2->m_SheetPath.size();
|
||||
}
|
||||
|
||||
int priority1 = getPriority( aLabel1 );
|
||||
int priority2 = getPriority( aLabel2 );
|
||||
|
||||
if( priority1 != priority2 )
|
||||
return priority1 > priority2;
|
||||
|
||||
// Objects have here the same priority, therefore they have the same type.
|
||||
// for global labels, we select the best candidate by alphabetic order
|
||||
// because they have no sheetpath as prefix name
|
||||
// for other labels, we select them before by sheet deep order
|
||||
// because the actual name is /sheetpath/label
|
||||
// and for a given path length, by alphabetic order
|
||||
if( aLabel1->IsLabelGlobal() )
|
||||
return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
|
||||
|
||||
// Sheet paths have here the same length: use alphabetic label name order
|
||||
// For labels on sheets having an equivalent deep in hierarchy, use
|
||||
// alphabetic label name order:
|
||||
if( aLabel1->m_Label.Cmp( aLabel2->m_Label ) != 0 )
|
||||
return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
|
||||
|
||||
// For identical labels having the same priority: choose the
|
||||
// alphabetic label full name order
|
||||
return aLabel1->m_SheetPath.PathHumanReadable().Cmp(
|
||||
aLabel2->m_SheetPath.PathHumanReadable() ) < 0;
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
|
||||
{
|
||||
// Important note: NETLIST_ITEM::SHEETLABEL items of sheet items should *NOT* be considered,
|
||||
// because they live in a sheet but their names are actually used in the subsheet.
|
||||
// Moreover, in the parent sheet, the name of NETLIST_ITEM::SHEETLABEL can be not unique,
|
||||
// ( for instance when 2 different sheets share the same schematic in complex hierarchies
|
||||
// and 2 identical NETLIST_ITEM::SHEETLABEL labels can be connected to 2 different nets
|
||||
|
||||
int netcode = 0; // current netcode for tested items
|
||||
unsigned idxstart = 0; // index of the first item of this net
|
||||
NETLIST_OBJECT* item;
|
||||
NETLIST_OBJECT* candidate;
|
||||
|
||||
// Pass 1: find the best name for labelled nets:
|
||||
candidate = NULL;
|
||||
for( unsigned ii = 0; ii <= size(); ii++ )
|
||||
{
|
||||
if( ii == size() ) // last item already tested
|
||||
item = NULL;
|
||||
else
|
||||
item = GetItem( ii );
|
||||
|
||||
if( !item || netcode != item->GetNet() ) // End of net found
|
||||
{
|
||||
if( candidate ) // One or more labels exists, find the best
|
||||
{
|
||||
for (unsigned jj = idxstart; jj < ii; jj++ )
|
||||
GetItem( jj )->SetNetNameCandidate( candidate );
|
||||
}
|
||||
|
||||
if( item == NULL ) // End of list
|
||||
break;
|
||||
|
||||
// Prepare next net analysis:
|
||||
netcode = item->GetNet();
|
||||
candidate = NULL;
|
||||
idxstart = ii;
|
||||
}
|
||||
|
||||
switch( item->m_Type )
|
||||
{
|
||||
case NETLIST_ITEM::HIERLABEL:
|
||||
case NETLIST_ITEM::LABEL:
|
||||
case NETLIST_ITEM::PINLABEL:
|
||||
case NETLIST_ITEM::GLOBLABEL:
|
||||
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
||||
// A candidate is found: select the better between the previous and this one
|
||||
if( candidate == NULL )
|
||||
candidate = item;
|
||||
else
|
||||
{
|
||||
if( evalLabelsPriority( item, candidate ) )
|
||||
// item has a higher priority than candidate so update the best candidate
|
||||
candidate = item;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Pass 2: find the best name for not labelled nets:
|
||||
// The "default" net name is Net-<<Ref cmp>_Pad<num pad>>
|
||||
// (see NETLIST_OBJECT::GetShortNetName())
|
||||
// therefore the "best" is the short net name alphabetically classed first
|
||||
// (to avoid net names changes when the net is not modified,
|
||||
// even if components are moved or deleted and undelete or replaced, as long
|
||||
// the reference is kept)
|
||||
|
||||
// Build a list of items with no net names
|
||||
NETLIST_OBJECTS list; // no ownership of elements being pointed at
|
||||
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
item = GetItem( ii );
|
||||
|
||||
if( !item->HasNetNameCandidate() )
|
||||
list.push_back( item );
|
||||
}
|
||||
|
||||
if( list.size() == 0 )
|
||||
return;
|
||||
|
||||
idxstart = 0;
|
||||
candidate = NULL;
|
||||
netcode = list[0]->GetNet();
|
||||
|
||||
for( unsigned ii = 0; ii <= list.size(); ii++ )
|
||||
{
|
||||
if( ii < list.size() )
|
||||
item = list[ii];
|
||||
else
|
||||
item = NULL;
|
||||
|
||||
if( !item || netcode != item->GetNet() ) // End of net found
|
||||
{
|
||||
if( candidate )
|
||||
{
|
||||
for (unsigned jj = idxstart; jj < ii; jj++ )
|
||||
{
|
||||
NETLIST_OBJECT* obj = list[jj];
|
||||
obj->SetNetNameCandidate( candidate );
|
||||
}
|
||||
}
|
||||
|
||||
if( !item )
|
||||
break;
|
||||
|
||||
netcode = item->GetNet();
|
||||
candidate = NULL;
|
||||
idxstart = ii;
|
||||
}
|
||||
|
||||
// Examine all pins of the net to find the best candidate,
|
||||
// i.e. the first net name candidate, by alphabetic order
|
||||
// the net names are built by GetShortNetName
|
||||
// (Net-<{reference}-Pad{pad number}> like Net-<U3-Pad5>
|
||||
// Not named nets do not have usually a lot of members.
|
||||
// Many have only 2 members(a pad and a non connection symbol)
|
||||
if( item->m_Type == NETLIST_ITEM::PIN )
|
||||
{
|
||||
// A candidate is found, however components which are not in
|
||||
// netlist are not candidate because some have their reference
|
||||
// changed each time the netlist is built (power components)
|
||||
// and anyway obviously they are not a good candidate
|
||||
SCH_COMPONENT* link = item->GetComponentParent();
|
||||
|
||||
if( link && link->IsInNetlist() )
|
||||
{
|
||||
// select the better between the previous and this one
|
||||
item->SetNetNameCandidate( item ); // Needed to calculate GetShortNetName
|
||||
|
||||
if( candidate == NULL )
|
||||
candidate = item;
|
||||
else
|
||||
{
|
||||
if( item->GetShortNetName().Cmp( candidate->GetShortNetName() ) < 0 )
|
||||
candidate = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::sheetLabelConnect( NETLIST_OBJECT* SheetLabel )
|
||||
{
|
||||
if( SheetLabel->GetNet() == 0 )
|
||||
return;
|
||||
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
NETLIST_OBJECT* ObjetNet = GetItem( ii );
|
||||
|
||||
if( ObjetNet->m_SheetPath != SheetLabel->m_SheetPathInclude )
|
||||
continue; //use SheetInclude, not the sheet!!
|
||||
|
||||
if( ( ObjetNet->m_Type != NETLIST_ITEM::HIERLABEL )
|
||||
&& ( ObjetNet->m_Type != NETLIST_ITEM::HIERBUSLABELMEMBER ) )
|
||||
continue;
|
||||
|
||||
if( ObjetNet->GetNet() == SheetLabel->GetNet() )
|
||||
continue; //already connected.
|
||||
|
||||
if( ObjetNet->m_Label != SheetLabel->m_Label )
|
||||
continue; //different names.
|
||||
|
||||
// Propagate Netcode having all the objects of the same Netcode.
|
||||
if( ObjetNet->GetNet() )
|
||||
propagateNetCode( ObjetNet->GetNet(), SheetLabel->GetNet(), IS_WIRE );
|
||||
else
|
||||
ObjetNet->SetNet( SheetLabel->GetNet() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::connectBusLabels()
|
||||
{
|
||||
// Propagate the net code between all bus label member objects connected by they name.
|
||||
// If the net code is not yet existing, a new one is created
|
||||
// Search is done in the entire list
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
NETLIST_OBJECT* Label = GetItem( ii );
|
||||
|
||||
if( Label->IsLabelBusMemberType() )
|
||||
{
|
||||
if( Label->GetNet() == 0 )
|
||||
{
|
||||
// Not yet existiing net code: create a new one.
|
||||
Label->SetNet( m_lastNetCode );
|
||||
m_lastNetCode++;
|
||||
}
|
||||
|
||||
for( unsigned jj = ii + 1; jj < size(); jj++ )
|
||||
{
|
||||
NETLIST_OBJECT* LabelInTst = GetItem( jj );
|
||||
|
||||
if( LabelInTst->IsLabelBusMemberType() )
|
||||
{
|
||||
if( LabelInTst->m_BusNetCode != Label->m_BusNetCode )
|
||||
continue;
|
||||
|
||||
if( LabelInTst->m_Member != Label->m_Member )
|
||||
continue;
|
||||
|
||||
if( LabelInTst->GetNet() == 0 )
|
||||
// Append this object to the current net
|
||||
LabelInTst->SetNet( Label->GetNet() );
|
||||
else
|
||||
// Merge the 2 net codes, they are connected.
|
||||
propagateNetCode( LabelInTst->GetNet(), Label->GetNet(), IS_WIRE );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::propagateNetCode( int aOldNetCode, int aNewNetCode, bool aIsBus )
|
||||
{
|
||||
if( aOldNetCode == aNewNetCode )
|
||||
return;
|
||||
|
||||
if( aIsBus == false ) // Propagate NetCode
|
||||
{
|
||||
for( unsigned jj = 0; jj < size(); jj++ )
|
||||
{
|
||||
NETLIST_OBJECT* object = GetItem( jj );
|
||||
|
||||
if( object->GetNet() == aOldNetCode )
|
||||
object->SetNet( aNewNetCode );
|
||||
}
|
||||
}
|
||||
else // Propagate BusNetCode
|
||||
{
|
||||
for( unsigned jj = 0; jj < size(); jj++ )
|
||||
{
|
||||
NETLIST_OBJECT* object = GetItem( jj );
|
||||
|
||||
if( object->m_BusNetCode == aOldNetCode )
|
||||
object->m_BusNetCode = aNewNetCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus, int start )
|
||||
{
|
||||
int netCode;
|
||||
|
||||
if( aIsBus == false ) // Objects other than BUS and BUSLABELS
|
||||
{
|
||||
netCode = aRef->GetNet();
|
||||
|
||||
for( unsigned i = start; i < size(); i++ )
|
||||
{
|
||||
NETLIST_OBJECT* item = GetItem( i );
|
||||
|
||||
if( item->m_SheetPath != aRef->m_SheetPath ) //used to be > (why?)
|
||||
continue;
|
||||
|
||||
switch( item->m_Type )
|
||||
{
|
||||
case NETLIST_ITEM::SEGMENT:
|
||||
case NETLIST_ITEM::PIN:
|
||||
case NETLIST_ITEM::LABEL:
|
||||
case NETLIST_ITEM::HIERLABEL:
|
||||
case NETLIST_ITEM::GLOBLABEL:
|
||||
case NETLIST_ITEM::SHEETLABEL:
|
||||
case NETLIST_ITEM::PINLABEL:
|
||||
case NETLIST_ITEM::JUNCTION:
|
||||
case NETLIST_ITEM::NOCONNECT:
|
||||
if( aRef->m_Start == item->m_Start
|
||||
|| aRef->m_Start == item->m_End
|
||||
|| aRef->m_End == item->m_Start
|
||||
|| aRef->m_End == item->m_End )
|
||||
{
|
||||
if( item->GetNet() == 0 )
|
||||
item->SetNet( netCode );
|
||||
else
|
||||
propagateNetCode( item->GetNet(), netCode, IS_WIRE );
|
||||
}
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::BUS:
|
||||
case NETLIST_ITEM::BUSLABELMEMBER:
|
||||
case NETLIST_ITEM::SHEETBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::HIERBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::ITEM_UNSPECIFIED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Object type BUS, BUSLABELS, and junctions.
|
||||
{
|
||||
netCode = aRef->m_BusNetCode;
|
||||
|
||||
for( unsigned i = start; i < size(); i++ )
|
||||
{
|
||||
NETLIST_OBJECT* item = GetItem( i );
|
||||
|
||||
if( item->m_SheetPath != aRef->m_SheetPath )
|
||||
continue;
|
||||
|
||||
switch( item->m_Type )
|
||||
{
|
||||
case NETLIST_ITEM::ITEM_UNSPECIFIED:
|
||||
case NETLIST_ITEM::SEGMENT:
|
||||
case NETLIST_ITEM::PIN:
|
||||
case NETLIST_ITEM::LABEL:
|
||||
case NETLIST_ITEM::HIERLABEL:
|
||||
case NETLIST_ITEM::GLOBLABEL:
|
||||
case NETLIST_ITEM::SHEETLABEL:
|
||||
case NETLIST_ITEM::PINLABEL:
|
||||
case NETLIST_ITEM::NOCONNECT:
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::BUS:
|
||||
case NETLIST_ITEM::BUSLABELMEMBER:
|
||||
case NETLIST_ITEM::SHEETBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::HIERBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::JUNCTION:
|
||||
if( aRef->m_Start == item->m_Start
|
||||
|| aRef->m_Start == item->m_End
|
||||
|| aRef->m_End == item->m_Start
|
||||
|| aRef->m_End == item->m_End )
|
||||
{
|
||||
if( item->m_BusNetCode == 0 )
|
||||
item->m_BusNetCode = netCode;
|
||||
else
|
||||
propagateNetCode( item->m_BusNetCode, netCode, IS_BUS );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::segmentToPointConnect( NETLIST_OBJECT* aJonction,
|
||||
bool aIsBus, int aIdxStart )
|
||||
{
|
||||
for( unsigned i = aIdxStart; i < size(); i++ )
|
||||
{
|
||||
NETLIST_OBJECT* segment = GetItem( i );
|
||||
|
||||
// if different sheets, obviously no physical connection between elements.
|
||||
if( segment->m_SheetPath != aJonction->m_SheetPath )
|
||||
continue;
|
||||
|
||||
if( aIsBus == IS_WIRE )
|
||||
{
|
||||
if( segment->m_Type != NETLIST_ITEM::SEGMENT )
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( segment->m_Type != NETLIST_ITEM::BUS )
|
||||
continue;
|
||||
}
|
||||
|
||||
if( IsPointOnSegment( segment->m_Start, segment->m_End, aJonction->m_Start ) )
|
||||
{
|
||||
// Propagation Netcode has all the objects of the same Netcode.
|
||||
if( aIsBus == IS_WIRE )
|
||||
{
|
||||
if( segment->GetNet() )
|
||||
propagateNetCode( segment->GetNet(), aJonction->GetNet(), aIsBus );
|
||||
else
|
||||
segment->SetNet( aJonction->GetNet() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( segment->m_BusNetCode )
|
||||
propagateNetCode( segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
|
||||
else
|
||||
segment->m_BusNetCode = aJonction->m_BusNetCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::labelConnect( NETLIST_OBJECT* aLabelRef )
|
||||
{
|
||||
if( aLabelRef->GetNet() == 0 )
|
||||
return;
|
||||
|
||||
for( unsigned i = 0; i < size(); i++ )
|
||||
{
|
||||
NETLIST_OBJECT* item = GetItem( i );
|
||||
|
||||
if( item->GetNet() == aLabelRef->GetNet() )
|
||||
continue;
|
||||
|
||||
if( item->m_SheetPath != aLabelRef->m_SheetPath )
|
||||
{
|
||||
if( item->m_Type != NETLIST_ITEM::PINLABEL && item->m_Type != NETLIST_ITEM::GLOBLABEL
|
||||
&& item->m_Type != NETLIST_ITEM::GLOBBUSLABELMEMBER )
|
||||
continue;
|
||||
|
||||
if( ( item->m_Type == NETLIST_ITEM::GLOBLABEL
|
||||
|| item->m_Type == NETLIST_ITEM::GLOBBUSLABELMEMBER )
|
||||
&& item->m_Type != aLabelRef->m_Type )
|
||||
//global labels only connect other global labels.
|
||||
continue;
|
||||
}
|
||||
|
||||
// NETLIST_ITEM::HIERLABEL are used to connect sheets.
|
||||
// NETLIST_ITEM::LABEL are local to a sheet
|
||||
// NETLIST_ITEM::GLOBLABEL are global.
|
||||
// NETLIST_ITEM::PINLABEL is a kind of global label (generated by a power pin invisible)
|
||||
if( item->IsLabelType() )
|
||||
{
|
||||
if( item->m_Label != aLabelRef->m_Label )
|
||||
continue;
|
||||
|
||||
if( item->GetNet() )
|
||||
propagateNetCode( item->GetNet(), aLabelRef->GetNet(), IS_WIRE );
|
||||
else
|
||||
item->SetNet( aLabelRef->GetNet() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::setUnconnectedFlag()
|
||||
{
|
||||
NETLIST_OBJECT* NetItemRef;
|
||||
unsigned NetStart, NetEnd;
|
||||
NET_CONNECTION StateFlag;
|
||||
|
||||
NetStart = NetEnd = 0;
|
||||
StateFlag = NET_CONNECTION::UNCONNECTED;
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
NetItemRef = GetItem( ii );
|
||||
if( NetItemRef->m_Type == NETLIST_ITEM::NOCONNECT
|
||||
&& StateFlag != NET_CONNECTION::PAD_CONNECT )
|
||||
StateFlag = NET_CONNECTION::NOCONNECT_SYMBOL_PRESENT;
|
||||
|
||||
// Analysis of current net.
|
||||
unsigned idxtoTest = ii + 1;
|
||||
|
||||
if( ( idxtoTest >= size() )
|
||||
|| ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
|
||||
{
|
||||
// Net analysis to update m_ConnectionType
|
||||
NetEnd = idxtoTest;
|
||||
|
||||
/* set m_ConnectionType member to StateFlag for all items of
|
||||
* this net: */
|
||||
for( unsigned kk = NetStart; kk < NetEnd; kk++ )
|
||||
GetItem( kk )->m_ConnectionType = StateFlag;
|
||||
|
||||
if( idxtoTest >= size() )
|
||||
return;
|
||||
|
||||
// Start Analysis next Net
|
||||
StateFlag = NET_CONNECTION::UNCONNECTED;
|
||||
NetStart = idxtoTest;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* test the current item: if this is a pin and if the reference item
|
||||
* is also a pin, then 2 pins are connected, so set StateFlag to
|
||||
* PAD_CONNECT (can be already done) Of course, if the current
|
||||
* item is a no connect symbol, set StateFlag to
|
||||
* NOCONNECT_SYMBOL_PRESENT to inhibit error diags. However if
|
||||
* StateFlag is already set to PAD_CONNECT this state is kept (the
|
||||
* no connect symbol was surely an error and an ERC will report this)
|
||||
*/
|
||||
for( ; ; idxtoTest++ )
|
||||
{
|
||||
if( ( idxtoTest >= size() )
|
||||
|| ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
|
||||
break;
|
||||
|
||||
switch( GetItem( idxtoTest )->m_Type )
|
||||
{
|
||||
case NETLIST_ITEM::ITEM_UNSPECIFIED:
|
||||
wxMessageBox( wxT( "BuildNetListBase() error" ) );
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::SEGMENT:
|
||||
case NETLIST_ITEM::LABEL:
|
||||
case NETLIST_ITEM::HIERLABEL:
|
||||
case NETLIST_ITEM::GLOBLABEL:
|
||||
case NETLIST_ITEM::SHEETLABEL:
|
||||
case NETLIST_ITEM::PINLABEL:
|
||||
case NETLIST_ITEM::BUS:
|
||||
case NETLIST_ITEM::BUSLABELMEMBER:
|
||||
case NETLIST_ITEM::SHEETBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::HIERBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
||||
case NETLIST_ITEM::JUNCTION:
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::PIN:
|
||||
if( NetItemRef->m_Type == NETLIST_ITEM::PIN )
|
||||
StateFlag = NET_CONNECTION::PAD_CONNECT;
|
||||
|
||||
break;
|
||||
|
||||
case NETLIST_ITEM::NOCONNECT:
|
||||
if( StateFlag != NET_CONNECTION::PAD_CONNECT )
|
||||
StateFlag = NET_CONNECTION::NOCONNECT_SYMBOL_PRESENT;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,7 +32,6 @@
|
|||
#include <sch_component.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <schematic.h>
|
||||
#include <netlist_object.h>
|
||||
#include <trace_helpers.h>
|
||||
|
||||
|
||||
|
@ -1540,55 +1539,6 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR aInspector, void* aTestData,
|
|||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
||||
SCH_SHEET_PATH* aSheetPath )
|
||||
{
|
||||
if( !m_part || !m_onBoard )
|
||||
return;
|
||||
|
||||
for( LIB_PIN* pin = m_part->GetNextPin(); pin; pin = m_part->GetNextPin( pin ) )
|
||||
{
|
||||
wxASSERT( pin->Type() == LIB_PIN_T );
|
||||
|
||||
if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath ) ) )
|
||||
continue;
|
||||
|
||||
if( pin->GetConvert() && ( pin->GetConvert() != GetConvert() ) )
|
||||
continue;
|
||||
|
||||
wxPoint pos = GetTransform().TransformCoordinate( pin->GetPosition() ) + m_Pos;
|
||||
|
||||
NETLIST_OBJECT* item = new NETLIST_OBJECT();
|
||||
item->m_SheetPathInclude = *aSheetPath;
|
||||
item->m_Comp = m_pins[ m_pinMap.at( pin ) ].get();
|
||||
item->m_SheetPath = *aSheetPath;
|
||||
item->m_Type = NETLIST_ITEM::PIN;
|
||||
item->m_Link = (SCH_ITEM*) this;
|
||||
item->m_ElectricalPinType = pin->GetType();
|
||||
item->m_PinNum = pin->GetNumber();
|
||||
item->m_Label = pin->GetName();
|
||||
item->m_Start = item->m_End = pos;
|
||||
|
||||
aNetListItems.push_back( item );
|
||||
|
||||
if( pin->IsPowerConnection() )
|
||||
{
|
||||
// There is an associated PIN_LABEL.
|
||||
item = new NETLIST_OBJECT();
|
||||
item->m_SheetPathInclude = *aSheetPath;
|
||||
item->m_Comp = m_pins[ m_pinMap.at( pin ) ].get();
|
||||
item->m_SheetPath = *aSheetPath;
|
||||
item->m_Type = NETLIST_ITEM::PINLABEL;
|
||||
item->m_Label = pin->GetName();
|
||||
item->m_Start = pos;
|
||||
item->m_End = item->m_Start;
|
||||
|
||||
aNetListItems.push_back( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SCH_COMPONENT::operator <( const SCH_ITEM& aItem ) const
|
||||
{
|
||||
if( Type() != aItem.Type() )
|
||||
|
|
|
@ -623,8 +623,6 @@ public:
|
|||
|
||||
BITMAP_DEF GetMenuImage() const override;
|
||||
|
||||
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
|
||||
|
||||
bool operator <( const SCH_ITEM& aItem ) const override;
|
||||
|
||||
bool operator==( const SCH_COMPONENT& aComponent) const;
|
||||
|
|
|
@ -357,15 +357,6 @@ public:
|
|||
m_highlightedConn = aConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a flat list which stores all connected objects.
|
||||
* TODO(JE) Remove this once ERC is moved off of it
|
||||
*
|
||||
* @param updateStatusText decides if window StatusText should be modified.
|
||||
* @return NETLIST_OBJECT_LIST* - caller owns the object.
|
||||
*/
|
||||
NETLIST_OBJECT_LIST* BuildNetListBase( bool updateStatusText = true );
|
||||
|
||||
/**
|
||||
* Checks if we are ready to write a netlist file for the current schematic
|
||||
*
|
||||
|
|
|
@ -482,18 +482,6 @@ public:
|
|||
*/
|
||||
virtual void Plot( PLOTTER* aPlotter );
|
||||
|
||||
/**
|
||||
* Create a new #NETLIST_OBJECT for the schematic object and adds it to \a aNetListItems.
|
||||
*
|
||||
* <p>
|
||||
* Not all schematic objects have net list items associated with them. This
|
||||
* method only needs to be overridden for those schematic objects that have
|
||||
* net list objects associated with them.
|
||||
* </p>
|
||||
*/
|
||||
virtual void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
||||
SCH_SHEET_PATH* aSheetPath ) { }
|
||||
|
||||
/**
|
||||
* Set the schematic item position to \a aPosition.
|
||||
*
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
|
||||
#include <sch_painter.h>
|
||||
#include <sch_junction.h>
|
||||
#include <netlist_object.h>
|
||||
#include <sch_connection.h>
|
||||
#include <schematic.h>
|
||||
#include <settings/color_settings.h>
|
||||
|
@ -146,21 +145,6 @@ void SCH_JUNCTION::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
|
|||
}
|
||||
|
||||
|
||||
void SCH_JUNCTION::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
||||
SCH_SHEET_PATH* aSheetPath )
|
||||
{
|
||||
NETLIST_OBJECT* item = new NETLIST_OBJECT();
|
||||
|
||||
item->m_SheetPath = *aSheetPath;
|
||||
item->m_SheetPathInclude = *aSheetPath;
|
||||
item->m_Comp = (SCH_ITEM*) this;
|
||||
item->m_Type = NETLIST_ITEM::JUNCTION;
|
||||
item->m_Start = item->m_End = m_pos;
|
||||
|
||||
aNetListItems.push_back( item );
|
||||
}
|
||||
|
||||
|
||||
#if defined(DEBUG)
|
||||
void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) const
|
||||
{
|
||||
|
|
|
@ -92,8 +92,6 @@ public:
|
|||
|
||||
BITMAP_DEF GetMenuImage() const override;
|
||||
|
||||
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
|
||||
|
||||
wxPoint GetPosition() const override { return m_pos; }
|
||||
void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <sch_line.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <settings/color_settings.h>
|
||||
#include <netlist_object.h>
|
||||
#include <schematic.h>
|
||||
#include <project/project_file.h>
|
||||
#include <project/net_settings.h>
|
||||
|
@ -656,33 +655,6 @@ BITMAP_DEF SCH_LINE::GetMenuImage() const
|
|||
}
|
||||
|
||||
|
||||
void SCH_LINE::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
||||
SCH_SHEET_PATH* aSheetPath )
|
||||
{
|
||||
// Net list item not required for graphic lines.
|
||||
if( IsGraphicLine() )
|
||||
return;
|
||||
|
||||
NETLIST_OBJECT* item = new NETLIST_OBJECT();
|
||||
item->m_SheetPath = *aSheetPath;
|
||||
item->m_SheetPathInclude = *aSheetPath;
|
||||
item->m_Comp = (SCH_ITEM*) this;
|
||||
item->m_Start = m_start;
|
||||
item->m_End = m_end;
|
||||
|
||||
if( GetLayer() == LAYER_BUS )
|
||||
{
|
||||
item->m_Type = NETLIST_ITEM::BUS;
|
||||
}
|
||||
else /* WIRE */
|
||||
{
|
||||
item->m_Type = NETLIST_ITEM::SEGMENT;
|
||||
}
|
||||
|
||||
aNetListItems.push_back( item );
|
||||
}
|
||||
|
||||
|
||||
bool SCH_LINE::operator <( const SCH_ITEM& aItem ) const
|
||||
{
|
||||
if( Type() != aItem.Type() )
|
||||
|
|
|
@ -207,8 +207,6 @@ public:
|
|||
|
||||
BITMAP_DEF GetMenuImage() const override;
|
||||
|
||||
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
|
||||
|
||||
bool operator <( const SCH_ITEM& aItem ) const override;
|
||||
|
||||
wxPoint GetPosition() const override { return m_start; }
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include <bitmaps.h>
|
||||
#include <schematic.h>
|
||||
#include <sch_no_connect.h>
|
||||
#include <netlist_object.h>
|
||||
#include <settings/color_settings.h>
|
||||
#include <default_values.h> // For some default values
|
||||
|
||||
|
@ -142,21 +141,6 @@ void SCH_NO_CONNECT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) cons
|
|||
}
|
||||
|
||||
|
||||
void SCH_NO_CONNECT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
||||
SCH_SHEET_PATH* aSheetPath )
|
||||
{
|
||||
NETLIST_OBJECT* item = new NETLIST_OBJECT();
|
||||
|
||||
item->m_SheetPath = *aSheetPath;
|
||||
item->m_SheetPathInclude = *aSheetPath;
|
||||
item->m_Comp = this;
|
||||
item->m_Type = NETLIST_ITEM::NOCONNECT;
|
||||
item->m_Start = item->m_End = m_pos;
|
||||
|
||||
aNetListItems.push_back( item );
|
||||
}
|
||||
|
||||
|
||||
bool SCH_NO_CONNECT::doIsConnected( const wxPoint& aPosition ) const
|
||||
{
|
||||
return m_pos == aPosition;
|
||||
|
|
|
@ -103,8 +103,6 @@ public:
|
|||
|
||||
BITMAP_DEF GetMenuImage() const override;
|
||||
|
||||
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
|
||||
|
||||
wxPoint GetPosition() const override { return m_pos; }
|
||||
void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#include <class_libentry.h>
|
||||
#include <connection_graph.h>
|
||||
#include <lib_pin.h>
|
||||
#include <netlist_object.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_junction.h>
|
||||
#include <sch_line.h>
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include <sch_painter.h>
|
||||
#include <schematic.h>
|
||||
#include <settings/color_settings.h>
|
||||
#include <netlist_object.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <pgm_base.h>
|
||||
|
||||
|
@ -936,29 +935,6 @@ bool SCH_SHEET::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
|
|||
}
|
||||
|
||||
|
||||
void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath )
|
||||
{
|
||||
SCH_SHEET_PATH sheetPath = *aSheetPath;
|
||||
sheetPath.push_back( this );
|
||||
|
||||
for( SCH_SHEET_PIN* sheetPin : m_pins )
|
||||
{
|
||||
NETLIST_OBJECT* item = new NETLIST_OBJECT();
|
||||
item->m_SheetPathInclude = sheetPath;
|
||||
item->m_SheetPath = *aSheetPath;
|
||||
item->m_Comp = sheetPin;
|
||||
item->m_Link = this;
|
||||
item->m_Type = NETLIST_ITEM::SHEETLABEL;
|
||||
item->m_Label = sheetPin->GetText();
|
||||
item->m_Start = item->m_End = sheetPin->GetPosition();
|
||||
aNetListItems.push_back( item );
|
||||
|
||||
if( SCH_CONNECTION::IsBusLabel( sheetPin->GetShownText() ) )
|
||||
item->ConvertBusToNetListItems( aNetListItems );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHEET::Plot( PLOTTER* aPlotter )
|
||||
{
|
||||
wxString Text;
|
||||
|
|
|
@ -558,9 +558,6 @@ public:
|
|||
|
||||
BITMAP_DEF GetMenuImage() const override;
|
||||
|
||||
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
||||
SCH_SHEET_PATH* aSheetPath ) override;
|
||||
|
||||
SCH_SHEET& operator=( const SCH_ITEM& aSheet );
|
||||
|
||||
bool operator <( const SCH_ITEM& aItem ) const override;
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include <bitmaps.h>
|
||||
#include <sch_text.h>
|
||||
#include <schematic.h>
|
||||
#include <netlist_object.h>
|
||||
#include <settings/color_settings.h>
|
||||
#include <sch_painter.h>
|
||||
#include <default_values.h>
|
||||
|
@ -556,34 +555,6 @@ BITMAP_DEF SCH_TEXT::GetMenuImage() const
|
|||
}
|
||||
|
||||
|
||||
void SCH_TEXT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
||||
SCH_SHEET_PATH* aSheetPath )
|
||||
{
|
||||
if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL )
|
||||
return;
|
||||
|
||||
NETLIST_OBJECT* item = new NETLIST_OBJECT();
|
||||
item->m_SheetPath = *aSheetPath;
|
||||
item->m_SheetPathInclude = *aSheetPath;
|
||||
item->m_Comp = (SCH_ITEM*) this;
|
||||
item->m_Type = NETLIST_ITEM::LABEL;
|
||||
|
||||
if( GetLayer() == LAYER_GLOBLABEL )
|
||||
item->m_Type = NETLIST_ITEM::GLOBLABEL;
|
||||
else if( GetLayer() == LAYER_HIERLABEL )
|
||||
item->m_Type = NETLIST_ITEM::HIERLABEL;
|
||||
|
||||
item->m_Label = GetText();
|
||||
item->m_Start = item->m_End = GetTextPos();
|
||||
|
||||
aNetListItems.push_back( item );
|
||||
|
||||
// If a bus connects to label
|
||||
if( SCH_CONNECTION::IsBusLabel( GetText() ) )
|
||||
item->ConvertBusToNetListItems( aNetListItems );
|
||||
}
|
||||
|
||||
|
||||
bool SCH_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
{
|
||||
EDA_RECT bBox = GetBoundingBox();
|
||||
|
|
|
@ -308,8 +308,6 @@ public:
|
|||
|
||||
BITMAP_DEF GetMenuImage() const override;
|
||||
|
||||
void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
|
||||
|
||||
wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); }
|
||||
void SetPosition( const wxPoint& aPosition ) override { EDA_TEXT::SetTextPos( aPosition ); }
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <netlist_exporters/netlist_exporter_pspice.h>
|
||||
#include <project/project_file.h>
|
||||
#include <project/net_settings.h>
|
||||
#include <netlist_object.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sch_sexpr_plugin.h>
|
||||
#include <sch_line.h>
|
||||
|
|
Loading…
Reference in New Issue