Eeschema: netlist generation: fix bad choice for the "best net name" when selecting a net name between labels connected to the same net.
Code cleanup and remove unused file.
This commit is contained in:
parent
5927f026b3
commit
f2e5da63e3
|
@ -9,7 +9,27 @@
|
|||
#include <common.h>
|
||||
#include <math_for_graphics.h>
|
||||
|
||||
// Returns true if the point P is on the segment S.
|
||||
// faster than TestSegmentHit() because P should be exactly on S
|
||||
// therefore works fine only for H, V and 45 deg segm (suitable for wires in eeschema)
|
||||
bool IsPointOnSegment( const wxPoint& aSegStart, const wxPoint& aSegEnd,
|
||||
const wxPoint& aTestPoint )
|
||||
{
|
||||
wxPoint vectSeg = aSegEnd - aSegStart; // Vector from S1 to S2
|
||||
wxPoint vectPoint = aTestPoint - aSegStart; // Vector from S1 to P
|
||||
|
||||
// Use long long here to avoid overflow in calculations
|
||||
if( (long long) vectSeg.x * vectPoint.y - (long long) vectSeg.y * vectPoint.x )
|
||||
return false; /* Cross product non-zero, vectors not parallel */
|
||||
|
||||
if( ( (long long) vectSeg.x * vectPoint.x + (long long) vectSeg.y * vectPoint.y ) <
|
||||
( (long long) vectPoint.x * vectPoint.x + (long long) vectPoint.y * vectPoint.y ) )
|
||||
return false; /* Point not on segment */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true if the segment 1 intersectd the segment 2.
|
||||
bool SegmentIntersectsSegment( const wxPoint &a_p1_l1, const wxPoint &a_p2_l1,
|
||||
const wxPoint &a_p1_l2, const wxPoint &a_p2_l2 )
|
||||
{
|
||||
|
|
|
@ -71,7 +71,6 @@ set(EESCHEMA_SRCS
|
|||
component_references_lister.cpp
|
||||
controle.cpp
|
||||
cross-probing.cpp
|
||||
dangling_ends.cpp
|
||||
database.cpp
|
||||
${EESCHEMA_DLGS}
|
||||
edit_component_in_schematic.cpp
|
||||
|
|
|
@ -182,7 +182,7 @@ NETLIST_OBJECT::NETLIST_OBJECT()
|
|||
m_Member = 0; /* for labels type NET_BUSLABELMEMBER ( bus member created
|
||||
* from the BUS label ) member number
|
||||
*/
|
||||
m_FlagOfConnection = UNCONNECTED;
|
||||
m_ConnectionType = UNCONNECTED;
|
||||
m_PinNum = 0; /* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
|
||||
m_netNameCandidate = NULL; /* a pointer to a NETLIST_OBJECT type label connected to this
|
||||
* object used to give a name to the net
|
||||
|
|
|
@ -104,7 +104,7 @@ public:
|
|||
int m_Member; /* for labels type NET_BUSLABELMEMBER ( bus member
|
||||
* created from the BUS label ) member number.
|
||||
*/
|
||||
NET_CONNECTION_T m_FlagOfConnection;
|
||||
NET_CONNECTION_T m_ConnectionType; // Used to store the connection type
|
||||
SCH_SHEET_PATH m_SheetListInclude; // sheet path which contains the hierarchical label
|
||||
long m_PinNum; // pin number ( 1 long = 4 bytes -> 4 ascii codes)
|
||||
wxString m_Label; // Label text (for labels) or Pin name (for pins)
|
||||
|
@ -137,6 +137,23 @@ public:
|
|||
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_T aFlg = UNCONNECTED )
|
||||
{
|
||||
m_ConnectionType = aFlg;
|
||||
}
|
||||
|
||||
NET_CONNECTION_T GetConnectionType()
|
||||
{
|
||||
return m_ConnectionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set m_netNameCandidate to a connected item which will
|
||||
* be used to calcule the net name of the item
|
||||
|
@ -223,6 +240,10 @@ class NETLIST_OBJECT_LIST: public std::vector <NETLIST_OBJECT*>
|
|||
{
|
||||
bool m_isOwner; // = true if the objects in list are owned my me, and therefore
|
||||
// the memory should be freed by the destructor and the list cleared
|
||||
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.
|
||||
|
@ -250,16 +271,64 @@ public:
|
|||
/*
|
||||
* Acces to an item in list
|
||||
*/
|
||||
NETLIST_OBJECT* GetItem( unsigned aIdx )
|
||||
NETLIST_OBJECT* GetItem( unsigned aIdx ) const
|
||||
{
|
||||
return *( this->begin() + aIdx );
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete all objects in list and clear list
|
||||
* (free memory used to store info about NETLIST_OBJECT items)
|
||||
* Acces to an item type
|
||||
*/
|
||||
void ClearList();
|
||||
NETLIST_ITEM_T 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_T 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_T aFlg = UNCONNECTED )
|
||||
{
|
||||
GetItem( aIdx )->SetConnectionType( aFlg );
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete all objects in list and clear list
|
||||
* (delete NETLIST_OBJECT items)
|
||||
*/
|
||||
void FreeList();
|
||||
|
||||
/*
|
||||
* Clear list but do not delete NETLIST_OBJECT items
|
||||
* (they can be deleted only if the instance is owner of the items
|
||||
*/
|
||||
void Clear() { this->clear(); }
|
||||
|
||||
/**
|
||||
* Reset the connection type of all items to UNCONNECTED type
|
||||
*/
|
||||
void ResetConnectionsType( )
|
||||
{
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
GetItem( ii )->SetConnectionType( UNCONNECTED );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sorts the list of connected items by net code
|
||||
|
@ -273,46 +342,6 @@ public:
|
|||
*/
|
||||
void SortListbySheet();
|
||||
|
||||
/*
|
||||
* 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 betweena 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 );
|
||||
|
||||
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();
|
||||
|
||||
#if defined(DEBUG)
|
||||
void DumpNetTable()
|
||||
|
@ -352,11 +381,48 @@ private:
|
|||
{
|
||||
return Objet1->m_SheetList.Cmp( Objet2->m_SheetList ) < 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 betweena 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 );
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
|
||||
extern NETLIST_OBJECT_LIST g_NetObjectslist;
|
||||
|
||||
/**
|
||||
* Function IsBusLabel
|
||||
* test if \a aLabel has a bus notation.
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/**
|
||||
* @file dangling_ends.cpp
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <sch_item_struct.h>
|
||||
#include <wxEeschemaStruct.h>
|
||||
|
||||
#include <general.h>
|
||||
#include <protos.h>
|
||||
#include <class_libentry.h>
|
||||
#include <lib_pin.h>
|
||||
#include <sch_component.h>
|
||||
|
||||
|
||||
/* Returns true if the point P is on the segment S. */
|
||||
bool SegmentIntersect( wxPoint aSegStart, wxPoint aSegEnd, wxPoint aTestPoint )
|
||||
{
|
||||
wxPoint vectSeg = aSegEnd - aSegStart; // Vector from S1 to S2
|
||||
wxPoint vectPoint = aTestPoint - aSegStart; // Vector from S1 to P
|
||||
|
||||
// Use long long here to avoid overflow in calculations
|
||||
if( (long long) vectSeg.x * vectPoint.y - (long long) vectSeg.y * vectPoint.x )
|
||||
return false; /* Cross product non-zero, vectors not parallel */
|
||||
|
||||
if( ( (long long) vectSeg.x * vectPoint.x + (long long) vectSeg.y * vectPoint.y ) <
|
||||
( (long long) vectPoint.x * vectPoint.x + (long long) vectPoint.y * vectPoint.y ) )
|
||||
return false; /* Point not on segment */
|
||||
|
||||
return true;
|
||||
}
|
|
@ -464,20 +464,20 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
|||
*/
|
||||
TestDuplicateSheetNames( true );
|
||||
|
||||
m_parent->BuildNetListBase();
|
||||
NETLIST_OBJECT_LIST* objectsConnectedList = m_parent->BuildNetListBase();
|
||||
|
||||
/* Reset the flag m_FlagOfConnection, that will be used next, in calculations */
|
||||
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
||||
g_NetObjectslist[ii]->m_FlagOfConnection = UNCONNECTED;
|
||||
// Reset the connection type indicator
|
||||
objectsConnectedList->ResetConnectionsType();
|
||||
|
||||
unsigned lastNet;
|
||||
unsigned nextNet = lastNet = 0;
|
||||
int NetNbItems = 0;
|
||||
int MinConn = NOC;
|
||||
|
||||
for( unsigned net = 0; net < g_NetObjectslist.size(); net++ )
|
||||
for( unsigned net = 0; net < objectsConnectedList->size(); net++ )
|
||||
{
|
||||
if( g_NetObjectslist[lastNet]->GetNet() != g_NetObjectslist[net]->GetNet() )
|
||||
if( objectsConnectedList->GetItemNet( lastNet ) !=
|
||||
objectsConnectedList->GetItemNet( net ) )
|
||||
{
|
||||
// New net found:
|
||||
MinConn = NOC;
|
||||
|
@ -485,7 +485,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
|||
nextNet = net;
|
||||
}
|
||||
|
||||
switch( g_NetObjectslist[net]->m_Type )
|
||||
switch( objectsConnectedList->GetItemType( net ) )
|
||||
{
|
||||
// These items do not create erc problems
|
||||
case NET_ITEM_UNSPECIFIED:
|
||||
|
@ -507,7 +507,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
|||
// ERC problems when pin sheets do not match hierarchical labels.
|
||||
// Each pin sheet must match a hierarchical label
|
||||
// Each hierarchical label must match a pin sheet
|
||||
TestLabel( net, nextNet );
|
||||
TestLabel( objectsConnectedList, net, nextNet );
|
||||
break;
|
||||
|
||||
case NET_NOCONNECT:
|
||||
|
@ -516,14 +516,14 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
|||
MinConn = NET_NC;
|
||||
|
||||
if( NetNbItems != 0 )
|
||||
Diagnose( g_NetObjectslist[net], NULL, MinConn, UNC );
|
||||
Diagnose( objectsConnectedList->GetItem( net ), NULL, MinConn, UNC );
|
||||
|
||||
break;
|
||||
|
||||
case NET_PIN:
|
||||
|
||||
// Look for ERC problems between pins:
|
||||
TestOthersItems( net, nextNet, &NetNbItems, &MinConn );
|
||||
TestOthersItems( objectsConnectedList, net, nextNet, &NetNbItems, &MinConn );
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -727,8 +727,9 @@ Do you want to annotate schematic?" ) ) )
|
|||
SCH_SCREENS screens;
|
||||
screens.SchematicCleanUp();
|
||||
|
||||
BuildNetListBase();
|
||||
bool success = WriteNetListFile( aFormat, aFullFileName, aNetlistOptions );
|
||||
NETLIST_OBJECT_LIST * connectedItemsList = BuildNetListBase();
|
||||
bool success = WriteNetListFile( connectedItemsList, aFormat,
|
||||
aFullFileName, aNetlistOptions );
|
||||
|
||||
return success;
|
||||
}
|
||||
|
|
104
eeschema/erc.cpp
104
eeschema/erc.cpp
|
@ -349,40 +349,40 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
|
|||
}
|
||||
|
||||
|
||||
void TestOthersItems( unsigned NetItemRef, unsigned netstart,
|
||||
int* NetNbItems, int* MinConnexion )
|
||||
void TestOthersItems( NETLIST_OBJECT_LIST* aList,
|
||||
unsigned aNetItemRef, unsigned aNetStart,
|
||||
int* aNetNbItems, int* aMinConnexion )
|
||||
{
|
||||
unsigned NetItemTst;
|
||||
|
||||
int ref_elect_type, jj, erc = OK, local_minconn;
|
||||
unsigned netItemTst = aNetStart;
|
||||
int jj;
|
||||
int erc = OK;
|
||||
|
||||
/* Analysis of the table of connections. */
|
||||
ref_elect_type = g_NetObjectslist[NetItemRef]->m_ElectricalType;
|
||||
|
||||
NetItemTst = netstart;
|
||||
local_minconn = NOC;
|
||||
int ref_elect_type = aList->GetItem( aNetItemRef )->m_ElectricalType;
|
||||
int local_minconn = NOC;
|
||||
|
||||
if( ref_elect_type == PIN_NC )
|
||||
local_minconn = NPI;
|
||||
|
||||
/* Test pins connected to NetItemRef */
|
||||
for( ; ; NetItemTst++ )
|
||||
for( ; ; netItemTst++ )
|
||||
{
|
||||
if( NetItemRef == NetItemTst )
|
||||
if( aNetItemRef == netItemTst )
|
||||
continue;
|
||||
|
||||
// We examine only a given net. We stop the search if the net changes
|
||||
if( ( NetItemTst >= g_NetObjectslist.size() ) // End of list
|
||||
|| ( g_NetObjectslist[NetItemRef]->GetNet() !=
|
||||
g_NetObjectslist[NetItemTst]->GetNet() ) ) // End of net
|
||||
if( ( netItemTst >= aList->size() ) // End of list
|
||||
|| ( aList->GetItemNet( aNetItemRef ) !=
|
||||
aList->GetItemNet( netItemTst ) ) ) // End of net
|
||||
{
|
||||
/* End net code found: minimum connection test. */
|
||||
if( (*MinConnexion < NET_NC ) && (local_minconn < NET_NC ) )
|
||||
if( ( *aMinConnexion < NET_NC ) && ( local_minconn < NET_NC ) )
|
||||
{
|
||||
/* Not connected or not driven pin. */
|
||||
bool seterr = true;
|
||||
|
||||
if( local_minconn == NOC && g_NetObjectslist[NetItemRef]->m_Type == NET_PIN )
|
||||
if( local_minconn == NOC &&
|
||||
aList->GetItemType( aNetItemRef ) == NET_PIN )
|
||||
{
|
||||
/* This pin is not connected: for multiple part per
|
||||
* package, and duplicated pin,
|
||||
|
@ -392,49 +392,49 @@ void TestOthersItems( unsigned NetItemRef, unsigned netstart,
|
|||
* TODO test also if instances connected are connected to
|
||||
* the same net
|
||||
*/
|
||||
for( unsigned duplicate = 0; duplicate < g_NetObjectslist.size(); duplicate++ )
|
||||
for( unsigned duplicate = 0; duplicate < aList->size(); duplicate++ )
|
||||
{
|
||||
if( g_NetObjectslist[duplicate]->m_Type != NET_PIN )
|
||||
if( aList->GetItemType( duplicate ) != NET_PIN )
|
||||
continue;
|
||||
|
||||
if( duplicate == NetItemRef )
|
||||
if( duplicate == aNetItemRef )
|
||||
continue;
|
||||
|
||||
if( g_NetObjectslist[NetItemRef]->m_PinNum !=
|
||||
g_NetObjectslist[duplicate]->m_PinNum )
|
||||
if( aList->GetItem( aNetItemRef )->m_PinNum !=
|
||||
aList->GetItem( duplicate )->m_PinNum )
|
||||
continue;
|
||||
|
||||
if( ( (SCH_COMPONENT*) g_NetObjectslist[NetItemRef]->
|
||||
m_Link )->GetRef( &g_NetObjectslist[NetItemRef]-> m_SheetList ) !=
|
||||
( (SCH_COMPONENT*) g_NetObjectslist[duplicate]->m_Link )
|
||||
->GetRef( &g_NetObjectslist[duplicate]->m_SheetList ) )
|
||||
if( ( (SCH_COMPONENT*) aList->GetItem( aNetItemRef )->
|
||||
m_Link )->GetRef( &aList->GetItem( aNetItemRef )-> m_SheetList ) !=
|
||||
( (SCH_COMPONENT*) aList->GetItem( duplicate )->m_Link )
|
||||
->GetRef( &aList->GetItem( duplicate )->m_SheetList ) )
|
||||
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 an other
|
||||
// item)
|
||||
if( (duplicate > 0)
|
||||
&& ( g_NetObjectslist[duplicate]->GetNet() ==
|
||||
g_NetObjectslist[duplicate - 1]->GetNet() ) )
|
||||
&& ( aList->GetItemNet( duplicate ) ==
|
||||
aList->GetItemNet( duplicate - 1 ) ) )
|
||||
seterr = false;
|
||||
|
||||
if( (duplicate < g_NetObjectslist.size() - 1)
|
||||
&& ( g_NetObjectslist[duplicate]->GetNet() ==
|
||||
g_NetObjectslist[duplicate + 1]->GetNet() ) )
|
||||
if( (duplicate < aList->size() - 1)
|
||||
&& ( aList->GetItemNet( duplicate ) ==
|
||||
aList->GetItemNet( duplicate + 1 ) ) )
|
||||
seterr = false;
|
||||
}
|
||||
}
|
||||
|
||||
if( seterr )
|
||||
Diagnose( g_NetObjectslist[NetItemRef], NULL, local_minconn, WAR );
|
||||
Diagnose( aList->GetItem( aNetItemRef ), NULL, local_minconn, WAR );
|
||||
|
||||
*MinConnexion = DRV; // inhibiting other messages of this
|
||||
*aMinConnexion = DRV; // inhibiting other messages of this
|
||||
// type for the net.
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
switch( g_NetObjectslist[NetItemTst]->m_Type )
|
||||
switch( aList->GetItemType( netItemTst ) )
|
||||
{
|
||||
case NET_ITEM_UNSPECIFIED:
|
||||
case NET_SEGMENT:
|
||||
|
@ -456,13 +456,13 @@ void TestOthersItems( unsigned NetItemRef, unsigned netstart,
|
|||
break;
|
||||
|
||||
case NET_PIN:
|
||||
jj = g_NetObjectslist[NetItemTst]->m_ElectricalType;
|
||||
jj = aList->GetItem( netItemTst )->m_ElectricalType;
|
||||
local_minconn = std::max( MinimalReq[ref_elect_type][jj], local_minconn );
|
||||
|
||||
if( NetItemTst <= NetItemRef )
|
||||
if( netItemTst <= aNetItemRef )
|
||||
break;
|
||||
|
||||
*NetNbItems += 1;
|
||||
*aNetNbItems += 1;
|
||||
|
||||
if( erc == OK )
|
||||
{
|
||||
|
@ -470,14 +470,12 @@ void TestOthersItems( unsigned NetItemRef, unsigned netstart,
|
|||
|
||||
if( erc != OK )
|
||||
{
|
||||
if( g_NetObjectslist[NetItemTst]->m_FlagOfConnection == 0 )
|
||||
if( aList->GetConnectionType( netItemTst ) == UNCONNECTED )
|
||||
{
|
||||
Diagnose( g_NetObjectslist[NetItemRef],
|
||||
g_NetObjectslist[NetItemTst],
|
||||
0,
|
||||
erc );
|
||||
g_NetObjectslist[NetItemTst]->m_FlagOfConnection =
|
||||
NOCONNECT_SYMBOL_PRESENT;
|
||||
Diagnose( aList->GetItem( aNetItemRef ),
|
||||
aList->GetItem( netItemTst ),
|
||||
0, erc );
|
||||
aList->SetConnectionType( netItemTst, NOCONNECT_SYMBOL_PRESENT );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -538,38 +536,36 @@ bool WriteDiagnosticERC( const wxString& aFullFileName )
|
|||
}
|
||||
|
||||
|
||||
void TestLabel( unsigned NetItemRef, unsigned StartNet )
|
||||
void TestLabel( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned aStartNet )
|
||||
{
|
||||
unsigned NetItemTst;
|
||||
unsigned netItemTst = aStartNet;
|
||||
int erc = 1;
|
||||
|
||||
NetItemTst = StartNet;
|
||||
|
||||
/* Review the list of labels connected to NetItemRef. */
|
||||
for( ; ; NetItemTst++ )
|
||||
for( ; ; netItemTst++ )
|
||||
{
|
||||
if( NetItemTst == NetItemRef )
|
||||
if( netItemTst == aNetItemRef )
|
||||
continue;
|
||||
|
||||
/* Is always in the same net? */
|
||||
if( ( NetItemTst == g_NetObjectslist.size() )
|
||||
|| ( g_NetObjectslist[NetItemRef]->GetNet() != g_NetObjectslist[NetItemTst]->GetNet() ) )
|
||||
if( ( netItemTst == aList->size() )
|
||||
|| ( aList->GetItemNet( aNetItemRef ) != aList->GetItemNet( netItemTst ) ) )
|
||||
{
|
||||
/* End Netcode found. */
|
||||
if( erc )
|
||||
{
|
||||
/* Glabel or SheetLabel orphaned. */
|
||||
Diagnose( g_NetObjectslist[NetItemRef], NULL, -1, WAR );
|
||||
Diagnose( aList->GetItem( aNetItemRef ), NULL, -1, WAR );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( g_NetObjectslist[NetItemRef]->IsLabelConnected( g_NetObjectslist[NetItemTst] ) )
|
||||
if( aList->GetItem( aNetItemRef )->IsLabelConnected( aList->GetItem( netItemTst ) ) )
|
||||
erc = 0;
|
||||
|
||||
//same thing, different order.
|
||||
if( g_NetObjectslist[NetItemTst]->IsLabelConnected( g_NetObjectslist[NetItemRef] ) )
|
||||
if( aList->GetItem( netItemTst )->IsLabelConnected( aList->GetItem( aNetItemRef ) ) )
|
||||
erc = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
class EDA_DRAW_PANEL;
|
||||
class NETLIST_OBJECT;
|
||||
class NETLIST_OBJECT_LIST;
|
||||
|
||||
/* For ERC markers: error types (used in diags, and to set the color):
|
||||
*/
|
||||
|
@ -83,15 +84,16 @@ extern void Diagnose( NETLIST_OBJECT* NetItemRef, NETLIST_OBJECT* NetItemTst,
|
|||
* Perform ERC testing for electrical conflicts between \a NetItemRef and other items
|
||||
* on the same net.
|
||||
*/
|
||||
extern void TestOthersItems( unsigned NetItemRef, unsigned NetStart,
|
||||
int* NetNbItems, int* MinConnexion );
|
||||
extern void TestOthersItems( NETLIST_OBJECT_LIST* aList,
|
||||
unsigned aNetItemRef, unsigned aNetStart,
|
||||
int* aNetNbItems, int* aMinConnexion );
|
||||
|
||||
/**
|
||||
* Function TestLabel
|
||||
* performs an ERC on a sheet labels to verify that it is connected to a corresponding
|
||||
* sub sheet global label.
|
||||
*/
|
||||
extern void TestLabel( unsigned NetItemRef, unsigned StartNet );
|
||||
extern void TestLabel( NETLIST_OBJECT_LIST* aList, unsigned aNetItemRef, unsigned aStartNet );
|
||||
|
||||
/**
|
||||
* Function TestDuplicateSheetNames( )
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2012 jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 1992-2013 jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 1992-2013 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -44,15 +44,12 @@
|
|||
#include <sch_sheet.h>
|
||||
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
#include <xnode.h> // also nests: <wx/xml/xml.h>
|
||||
|
||||
#include <build_version.h>
|
||||
#include <set>
|
||||
|
||||
#define INTERMEDIATE_NETLIST_EXT wxT("xml")
|
||||
|
||||
#include <set>
|
||||
|
||||
/**
|
||||
* Class UNIQUE_STRINGS
|
||||
* tracks unique wxStrings and is useful in telling if a string
|
||||
|
@ -95,6 +92,8 @@ bool UNIQUE_STRINGS::Lookup( const wxString& aString )
|
|||
*/
|
||||
class NETLIST_EXPORT_TOOL
|
||||
{
|
||||
NETLIST_OBJECT_LIST * m_masterList; /// The main connected items flat list
|
||||
|
||||
/// Used to temporary store and filter the list of pins of a schematic component
|
||||
/// when generating schematic component data in netlist (comp section)
|
||||
NETLIST_OBJECT_LIST m_SortedComponentPinList;
|
||||
|
@ -187,7 +186,7 @@ class NETLIST_EXPORT_TOOL
|
|||
* - 6 CA
|
||||
* </p>
|
||||
*/
|
||||
bool writeListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList );
|
||||
bool writeListOfNetsCADSTAR( FILE* f );
|
||||
|
||||
/**
|
||||
* Function makeGenericRoot
|
||||
|
@ -230,6 +229,10 @@ class NETLIST_EXPORT_TOOL
|
|||
XNODE* makeGenericLibraries();
|
||||
|
||||
public:
|
||||
NETLIST_EXPORT_TOOL( NETLIST_OBJECT_LIST * aMasterList )
|
||||
{
|
||||
m_masterList = aMasterList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function WriteKiCadNetList
|
||||
|
@ -354,6 +357,8 @@ wxString NETLIST_EXPORT_TOOL::MakeCommandLine( const wxString& aFormatString,
|
|||
|
||||
/* Function WriteNetListFile
|
||||
* creates the netlist file. Netlist info must be existing
|
||||
* (call BuildNetListBase() to create this info )
|
||||
* param aConnectedItemsList = the initialized list of connected items
|
||||
* param aFormat = netlist format (NET_TYPE_PCBNEW ...)
|
||||
* param aFullFileName = full netlist file name
|
||||
* param aNetlistOptions = netlist options using OR'ed bits.
|
||||
|
@ -361,12 +366,13 @@ wxString NETLIST_EXPORT_TOOL::MakeCommandLine( const wxString& aFormatString,
|
|||
* if NET_USE_X_PREFIX is set : change "U" and "IC" refernce prefix to "X"
|
||||
* return true if success.
|
||||
*/
|
||||
bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileName,
|
||||
bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList,
|
||||
int aFormat, const wxString& aFullFileName,
|
||||
unsigned aNetlistOptions )
|
||||
{
|
||||
bool ret = true;
|
||||
FILE* f = NULL;
|
||||
NETLIST_EXPORT_TOOL helper;
|
||||
NETLIST_EXPORT_TOOL helper( aConnectedItemsList );
|
||||
|
||||
bool open_file = aFormat < NET_TYPE_CUSTOM1;
|
||||
if( (aFormat == NET_TYPE_PCBNEW) && (aNetlistOptions & NET_PCBNEW_USE_NEW_FORMAT ) )
|
||||
|
@ -439,8 +445,6 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
|
|||
D(printf("commandLine:'%s'\n", TO_UTF8( commandLine ) );)
|
||||
|
||||
ProcessExecute( commandLine, wxEXEC_SYNC );
|
||||
|
||||
// ::wxRemoveFile( tmpFile.GetFullPath() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -473,7 +477,7 @@ void NETLIST_EXPORT_TOOL::sprintPinNetName( wxString& aResult,
|
|||
// caller's loop.
|
||||
aResult.Empty();
|
||||
|
||||
if( netcode != 0 && aPin->m_FlagOfConnection == PAD_CONNECT )
|
||||
if( netcode != 0 && aPin->GetConnectionType() == PAD_CONNECT )
|
||||
{
|
||||
aResult = aPin->GetNetName();
|
||||
|
||||
|
@ -852,9 +856,9 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericListOfNets()
|
|||
|
||||
m_LibParts.clear(); // must call this function before using m_LibParts.
|
||||
|
||||
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
||||
for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
|
||||
{
|
||||
NETLIST_OBJECT* nitem = g_NetObjectslist[ii];
|
||||
NETLIST_OBJECT* nitem = m_masterList->GetItem( ii );
|
||||
SCH_COMPONENT* comp;
|
||||
|
||||
// New net found, write net id;
|
||||
|
@ -1035,8 +1039,8 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericComponents()
|
|||
bool NETLIST_EXPORT_TOOL::WriteKiCadNetList( const wxString& aOutFileName )
|
||||
{
|
||||
// Prepare list of nets generation
|
||||
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
||||
g_NetObjectslist[ii]->m_Flag = 0;
|
||||
for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
|
||||
m_masterList->GetItem( ii )->m_Flag = 0;
|
||||
|
||||
std::auto_ptr<XNODE> xroot( makeGenericRoot() );
|
||||
|
||||
|
@ -1058,8 +1062,8 @@ bool NETLIST_EXPORT_TOOL::WriteKiCadNetList( const wxString& aOutFileName )
|
|||
bool NETLIST_EXPORT_TOOL::WriteGENERICNetList( const wxString& aOutFileName )
|
||||
{
|
||||
// Prepare list of nets generation
|
||||
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
||||
g_NetObjectslist[ii]->m_Flag = 0;
|
||||
for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
|
||||
m_masterList->GetItem( ii )->m_Flag = 0;
|
||||
|
||||
// output the XML format netlist.
|
||||
wxXmlDocument xdoc;
|
||||
|
@ -1091,8 +1095,8 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPspice( FILE* f, bool aUsePrefix )
|
|||
NETLIST_HEAD_STRING, TO_UTF8( DateAndTime() ) );
|
||||
|
||||
// Prepare list of nets generation (not used here, but...
|
||||
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
||||
g_NetObjectslist[ii]->m_Flag = 0;
|
||||
for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
|
||||
m_masterList->GetItem( ii )->m_Flag = 0;
|
||||
|
||||
ret |= fprintf( f, "* To exclude a component from the Spice Netlist add [Spice_Netlist_Enabled] user FIELD set to: N\n" );
|
||||
ret |= fprintf( f, "* To reorder the component spice node sequence add [Spice_Node_Sequence] user FIELD and define sequence: 2,1,0\n" );
|
||||
|
@ -1370,8 +1374,8 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPCBNEW( FILE* f, bool with_pcbnew )
|
|||
NETLIST_HEAD_STRING, TO_UTF8( DateAndTime() ) );
|
||||
|
||||
// Prepare list of nets generation
|
||||
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
||||
g_NetObjectslist[ii]->m_Flag = 0;
|
||||
for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
|
||||
m_masterList->GetItem( ii )->m_Flag = 0;
|
||||
|
||||
// Create netlist module section
|
||||
m_ReferencesAlreadyFound.Clear();
|
||||
|
@ -1487,7 +1491,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPCBNEW( FILE* f, bool with_pcbnew )
|
|||
{
|
||||
ret |= fprintf( f, "{ Pin List by Nets\n" );
|
||||
|
||||
if( !writeGENERICListOfNets( f, g_NetObjectslist ) )
|
||||
if( !writeGENERICListOfNets( f, *m_masterList ) )
|
||||
ret = -1;
|
||||
|
||||
ret |= fprintf( f, "}\n" );
|
||||
|
@ -1502,9 +1506,9 @@ bool NETLIST_EXPORT_TOOL::addPinToComponentPinList( SCH_COMPONENT* aComponent,
|
|||
SCH_SHEET_PATH* aSheetPath, LIB_PIN* aPin )
|
||||
{
|
||||
// Search the PIN description for Pin in g_NetObjectslist
|
||||
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
||||
for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
|
||||
{
|
||||
NETLIST_OBJECT* pin = g_NetObjectslist[ii];
|
||||
NETLIST_OBJECT* pin = m_masterList->GetItem( ii );
|
||||
|
||||
if( pin->m_Type != NET_PIN )
|
||||
continue;
|
||||
|
@ -1567,7 +1571,7 @@ void NETLIST_EXPORT_TOOL::eraseDuplicatePins( )
|
|||
if( m_SortedComponentPinList[idxref]->m_PinNum != m_SortedComponentPinList[jj]->m_PinNum )
|
||||
break;
|
||||
|
||||
if( m_SortedComponentPinList[idxref]->m_FlagOfConnection == PAD_CONNECT )
|
||||
if( m_SortedComponentPinList[idxref]->GetConnectionType() == PAD_CONNECT )
|
||||
{
|
||||
m_SortedComponentPinList[jj]->m_Flag = 1;
|
||||
m_SortedComponentPinList[jj] = NULL;
|
||||
|
@ -1575,7 +1579,7 @@ void NETLIST_EXPORT_TOOL::eraseDuplicatePins( )
|
|||
else /* the reference pin is not connected: remove this pin if the
|
||||
* other pin is connected */
|
||||
{
|
||||
if( m_SortedComponentPinList[jj]->m_FlagOfConnection == PAD_CONNECT )
|
||||
if( m_SortedComponentPinList[jj]->GetConnectionType() == PAD_CONNECT )
|
||||
{
|
||||
m_SortedComponentPinList[idxref]->m_Flag = 1;
|
||||
m_SortedComponentPinList[idxref] = NULL;
|
||||
|
@ -1729,8 +1733,8 @@ bool NETLIST_EXPORT_TOOL::WriteNetListCADSTAR( FILE* f )
|
|||
ret |= fprintf( f, "\n" );
|
||||
|
||||
// Prepare list of nets generation
|
||||
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
||||
g_NetObjectslist[ii]->m_Flag = 0;
|
||||
for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
|
||||
m_masterList->GetItem( ii )->m_Flag = 0;
|
||||
|
||||
// Create netlist module section
|
||||
m_ReferencesAlreadyFound.Clear();
|
||||
|
@ -1772,7 +1776,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListCADSTAR( FILE* f )
|
|||
|
||||
m_SortedComponentPinList.clear();
|
||||
|
||||
if( ! writeListOfNetsCADSTAR( f, g_NetObjectslist ) )
|
||||
if( ! writeListOfNetsCADSTAR( f ) )
|
||||
ret = -1; // set error
|
||||
|
||||
ret |= fprintf( f, "\n%sEND\n", TO_UTF8( StartLine ) );
|
||||
|
@ -1781,7 +1785,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListCADSTAR( FILE* f )
|
|||
}
|
||||
|
||||
|
||||
bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList )
|
||||
bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f )
|
||||
{
|
||||
int ret = 0;
|
||||
wxString InitNetDesc = StartLine + wxT( "ADD_TER" );
|
||||
|
@ -1793,9 +1797,9 @@ bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST&
|
|||
SCH_COMPONENT* Cmp;
|
||||
wxString netName;
|
||||
|
||||
for( ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
||||
for( ii = 0; ii < m_masterList->size(); ii++ )
|
||||
{
|
||||
NETLIST_OBJECT* nitem = aObjectsList[ii];
|
||||
NETLIST_OBJECT* nitem = m_masterList->GetItem( ii );
|
||||
|
||||
// Get the NetName of the current net :
|
||||
if( ( NetCode = nitem->GetNet() ) != lastNetCode )
|
||||
|
|
|
@ -49,17 +49,16 @@
|
|||
#define IS_BUS true
|
||||
|
||||
// Buffer to build the list of items used in netlist and erc calculations
|
||||
NETLIST_OBJECT_LIST g_NetObjectslist( true );
|
||||
NETLIST_OBJECT_LIST s_NetObjectslist( true );
|
||||
|
||||
//#define NETLIST_DEBUG
|
||||
|
||||
// Local variables
|
||||
static int LastNetCode, LastBusNetCode;
|
||||
|
||||
NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST()
|
||||
{
|
||||
if( m_isOwner )
|
||||
ClearList();
|
||||
FreeList();
|
||||
else
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,7 +66,7 @@ NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST()
|
|||
* Delete all objects in list and clear list
|
||||
* (free memory used to store info about NETLIST_OBJECT items)
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::ClearList()
|
||||
void NETLIST_OBJECT_LIST::FreeList()
|
||||
{
|
||||
std::vector<NETLIST_OBJECT*>::iterator iter;
|
||||
|
||||
|
@ -93,9 +92,9 @@ void NETLIST_OBJECT_LIST::SortListbySheet()
|
|||
|
||||
/*
|
||||
* Build net list connection table.
|
||||
* Updates g_NetObjectslist
|
||||
* Initializes s_NetObjectslist
|
||||
*/
|
||||
void SCH_EDIT_FRAME::BuildNetListBase()
|
||||
NETLIST_OBJECT_LIST * SCH_EDIT_FRAME::BuildNetListBase()
|
||||
{
|
||||
wxBusyCursor Busy;
|
||||
|
||||
|
@ -103,20 +102,22 @@ void SCH_EDIT_FRAME::BuildNetListBase()
|
|||
SCH_SHEET_LIST aSheets;
|
||||
|
||||
// Build netlist info
|
||||
bool success = g_NetObjectslist.BuildNetListInfo( aSheets );
|
||||
bool success = s_NetObjectslist.BuildNetListInfo( aSheets );
|
||||
|
||||
if( !success )
|
||||
{
|
||||
SetStatusText( _("No Objects" ) );
|
||||
return;
|
||||
return &s_NetObjectslist;
|
||||
}
|
||||
|
||||
/* The new %zu specification is needed to properly format a size_t
|
||||
* value (returned by size(), here) */
|
||||
wxString msg;
|
||||
|
||||
msg.Printf( _( "Net count = %zu" ), g_NetObjectslist.size() );
|
||||
msg.Printf( _( "Net count = %zu" ), s_NetObjectslist.size() );
|
||||
SetStatusText( msg );
|
||||
|
||||
return &s_NetObjectslist;
|
||||
}
|
||||
|
||||
/* the master function of NETLIST_OBJECT_LIST class.
|
||||
|
@ -125,8 +126,8 @@ void SCH_EDIT_FRAME::BuildNetListBase()
|
|||
*/
|
||||
bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
||||
{
|
||||
g_NetObjectslist.SetOwner( true );
|
||||
g_NetObjectslist.ClearList();
|
||||
s_NetObjectslist.SetOwner( true );
|
||||
s_NetObjectslist.FreeList();
|
||||
|
||||
SCH_SHEET_PATH* sheet;
|
||||
|
||||
|
@ -147,7 +148,7 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
SortListbySheet();
|
||||
|
||||
sheet = &(GetItem( 0 )->m_SheetList);
|
||||
LastNetCode = LastBusNetCode = 1;
|
||||
m_lastNetCode = m_lastBusNetCode = 1;
|
||||
|
||||
for( unsigned ii = 0, istart = 0; ii < size(); ii++ )
|
||||
{
|
||||
|
@ -176,31 +177,31 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
// Test connections point to point type without bus.
|
||||
if( net_item->GetNet() == 0 )
|
||||
{
|
||||
net_item->SetNet( LastNetCode );
|
||||
LastNetCode++;
|
||||
net_item->SetNet( m_lastNetCode );
|
||||
m_lastNetCode++;
|
||||
}
|
||||
|
||||
PointToPointConnect( net_item, IS_WIRE, istart );
|
||||
pointToPointConnect( net_item, IS_WIRE, istart );
|
||||
break;
|
||||
|
||||
case NET_JUNCTION:
|
||||
// Control of the junction outside BUS.
|
||||
if( net_item->GetNet() == 0 )
|
||||
{
|
||||
net_item->SetNet( LastNetCode );
|
||||
LastNetCode++;
|
||||
net_item->SetNet( m_lastNetCode );
|
||||
m_lastNetCode++;
|
||||
}
|
||||
|
||||
SegmentToPointConnect( net_item, IS_WIRE, istart );
|
||||
segmentToPointConnect( net_item, IS_WIRE, istart );
|
||||
|
||||
/* Control of the junction, on BUS. */
|
||||
if( net_item->m_BusNetCode == 0 )
|
||||
{
|
||||
net_item->m_BusNetCode = LastBusNetCode;
|
||||
LastBusNetCode++;
|
||||
net_item->m_BusNetCode = m_lastBusNetCode;
|
||||
m_lastBusNetCode++;
|
||||
}
|
||||
|
||||
SegmentToPointConnect( net_item, IS_BUS, istart );
|
||||
segmentToPointConnect( net_item, IS_BUS, istart );
|
||||
break;
|
||||
|
||||
case NET_LABEL:
|
||||
|
@ -209,11 +210,11 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
// Test connections type junction without bus.
|
||||
if( net_item->GetNet() == 0 )
|
||||
{
|
||||
net_item->SetNet( LastNetCode );
|
||||
LastNetCode++;
|
||||
net_item->SetNet( m_lastNetCode );
|
||||
m_lastNetCode++;
|
||||
}
|
||||
|
||||
SegmentToPointConnect( net_item, IS_WIRE, istart );
|
||||
segmentToPointConnect( net_item, IS_WIRE, istart );
|
||||
break;
|
||||
|
||||
case NET_SHEETBUSLABELMEMBER:
|
||||
|
@ -224,11 +225,11 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
/* Control type connections point to point mode bus */
|
||||
if( net_item->m_BusNetCode == 0 )
|
||||
{
|
||||
net_item->m_BusNetCode = LastBusNetCode;
|
||||
LastBusNetCode++;
|
||||
net_item->m_BusNetCode = m_lastBusNetCode;
|
||||
m_lastBusNetCode++;
|
||||
}
|
||||
|
||||
PointToPointConnect( net_item, IS_BUS, istart );
|
||||
pointToPointConnect( net_item, IS_BUS, istart );
|
||||
break;
|
||||
|
||||
case NET_BUSLABELMEMBER:
|
||||
|
@ -237,11 +238,11 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
/* Control connections similar has on BUS */
|
||||
if( net_item->GetNet() == 0 )
|
||||
{
|
||||
net_item->m_BusNetCode = LastBusNetCode;
|
||||
LastBusNetCode++;
|
||||
net_item->m_BusNetCode = m_lastBusNetCode;
|
||||
m_lastBusNetCode++;
|
||||
}
|
||||
|
||||
SegmentToPointConnect( net_item, IS_BUS, istart );
|
||||
segmentToPointConnect( net_item, IS_BUS, istart );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +253,7 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
#endif
|
||||
|
||||
/* Updating the Bus Labels Netcode connected by Bus */
|
||||
ConnectBusLabels();
|
||||
connectBusLabels();
|
||||
|
||||
/* Group objects by label. */
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
|
@ -291,11 +292,11 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
#endif
|
||||
|
||||
// Connection between hierarchy sheets
|
||||
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
if( GetItem( ii )->m_Type == NET_SHEETLABEL
|
||||
|| GetItem( ii )->m_Type == NET_SHEETBUSLABELMEMBER )
|
||||
SheetLabelConnect( GetItem( ii ) );
|
||||
sheetLabelConnect( GetItem( ii ) );
|
||||
}
|
||||
|
||||
// Sort objects by NetCode
|
||||
|
@ -308,24 +309,24 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
|
||||
/* Compress numbers of Netcode having consecutive values. */
|
||||
int NetCode = 0;
|
||||
LastNetCode = 0;
|
||||
m_lastNetCode = 0;
|
||||
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
if( GetItem( ii )->GetNet() != LastNetCode )
|
||||
if( GetItem( ii )->GetNet() != m_lastNetCode )
|
||||
{
|
||||
NetCode++;
|
||||
LastNetCode = GetItem( ii )->GetNet();
|
||||
m_lastNetCode = GetItem( ii )->GetNet();
|
||||
}
|
||||
|
||||
GetItem( ii )->SetNet( NetCode );
|
||||
}
|
||||
|
||||
// Set the minimal connection info:
|
||||
SetUnconnectedFlag();
|
||||
setUnconnectedFlag();
|
||||
|
||||
// find the best label object to give the best net name to each net
|
||||
FindBestNetNameForEachNet();
|
||||
findBestNetNameForEachNet();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -348,9 +349,9 @@ static int getPriority( const NETLIST_OBJECT* Objet )
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* function evalLabelsPriority used by FindBestNetNameForEachNet()
|
||||
/* function evalLabelsPriority used by findBestNetNameForEachNet()
|
||||
* evalLabelsPriority calculates the priority of alabel1 and aLabel2
|
||||
* return true if alabel1 has a smaller priority than aLabel2
|
||||
* return true if alabel1 has a highter priority than aLabel2
|
||||
*/
|
||||
static bool evalLabelsPriority( const NETLIST_OBJECT* aLabel1,
|
||||
const NETLIST_OBJECT* aLabel2 )
|
||||
|
@ -359,7 +360,7 @@ static bool evalLabelsPriority( const NETLIST_OBJECT* aLabel1,
|
|||
int priority2 = getPriority( aLabel2 );
|
||||
|
||||
if( priority1 != priority2 )
|
||||
return priority1 < priority2;
|
||||
return priority1 > priority2;
|
||||
|
||||
// Objects have here the same priority, therefore they have the same type.
|
||||
|
||||
|
@ -383,15 +384,15 @@ static bool evalLabelsPriority( const NETLIST_OBJECT* aLabel1,
|
|||
// 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 ) ;
|
||||
return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
|
||||
|
||||
return aLabel1->m_SheetList.PathHumanReadable().Cmp(
|
||||
aLabel2->m_SheetList.PathHumanReadable() );
|
||||
aLabel2->m_SheetList.PathHumanReadable() ) < 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function FindBestNetNameForEachNet
|
||||
* 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.
|
||||
|
@ -401,7 +402,7 @@ static bool evalLabelsPriority( const NETLIST_OBJECT* aLabel1,
|
|||
* the label is in the first sheet in a hierarchy (the root sheet has the most priority)
|
||||
* alphabetic order.
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::FindBestNetNameForEachNet()
|
||||
void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
|
||||
{
|
||||
int netcode = 0; // current netcode for tested items
|
||||
unsigned idxstart = 0; // index of the first item of this net
|
||||
|
@ -448,6 +449,8 @@ void NETLIST_OBJECT_LIST::FindBestNetNameForEachNet()
|
|||
else
|
||||
{
|
||||
if( evalLabelsPriority( item, candidate ) )
|
||||
// item has a highter priority than candidate
|
||||
// so update the best candidate
|
||||
candidate = item;
|
||||
}
|
||||
break;
|
||||
|
@ -512,7 +515,7 @@ void NETLIST_OBJECT_LIST::FindBestNetNameForEachNet()
|
|||
* Propagate net codes from a parent sheet to an include sheet,
|
||||
* from a pin sheet connection
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::SheetLabelConnect( NETLIST_OBJECT* SheetLabel )
|
||||
void NETLIST_OBJECT_LIST::sheetLabelConnect( NETLIST_OBJECT* SheetLabel )
|
||||
{
|
||||
if( SheetLabel->GetNet() == 0 )
|
||||
return;
|
||||
|
@ -547,9 +550,9 @@ void NETLIST_OBJECT_LIST::SheetLabelConnect( NETLIST_OBJECT* SheetLabel )
|
|||
* Propagate net codes between the corresponding labels (ie when
|
||||
* the <member_number> is the same) when they are connected
|
||||
* uqsually by their BusNetCode
|
||||
* Uses and updates the variable LastNetCode
|
||||
* Uses and updates the variable m_lastNetCode
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::ConnectBusLabels()
|
||||
void NETLIST_OBJECT_LIST::connectBusLabels()
|
||||
{
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
|
@ -561,8 +564,8 @@ void NETLIST_OBJECT_LIST::ConnectBusLabels()
|
|||
{
|
||||
if( Label->GetNet() == 0 )
|
||||
{
|
||||
Label->SetNet( LastNetCode );
|
||||
LastNetCode++;
|
||||
Label->SetNet( m_lastNetCode );
|
||||
m_lastNetCode++;
|
||||
}
|
||||
|
||||
for( unsigned jj = ii + 1; jj < size(); jj++ )
|
||||
|
@ -642,7 +645,7 @@ void NETLIST_OBJECT_LIST::propageNetCode( int aOldNetCode, int aNewNetCode, bool
|
|||
* Leaf schema
|
||||
* (There can be no physical connection between elements of different sheets)
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::PointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus,
|
||||
void NETLIST_OBJECT_LIST::pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus,
|
||||
int start )
|
||||
{
|
||||
int netCode;
|
||||
|
@ -745,7 +748,7 @@ void NETLIST_OBJECT_LIST::PointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus
|
|||
* The list of objects is expected sorted by sheets.
|
||||
* Search is done from index aIdxStart to the last element of list
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::SegmentToPointConnect( NETLIST_OBJECT* aJonction,
|
||||
void NETLIST_OBJECT_LIST::segmentToPointConnect( NETLIST_OBJECT* aJonction,
|
||||
bool aIsBus, int aIdxStart )
|
||||
{
|
||||
for( unsigned i = aIdxStart; i < size(); i++ )
|
||||
|
@ -767,7 +770,7 @@ void NETLIST_OBJECT_LIST::SegmentToPointConnect( NETLIST_OBJECT* aJonction,
|
|||
continue;
|
||||
}
|
||||
|
||||
if( SegmentIntersect( segment->m_Start, segment->m_End, aJonction->m_Start ) )
|
||||
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 )
|
||||
|
@ -837,13 +840,13 @@ void NETLIST_OBJECT_LIST::labelConnect( NETLIST_OBJECT* aLabelRef )
|
|||
}
|
||||
|
||||
|
||||
/* Set the m_FlagOfConnection member of items in list
|
||||
/* Set the m_ConnectionType 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 NETLIST_OBJECT_LIST::SetUnconnectedFlag()
|
||||
void NETLIST_OBJECT_LIST::setUnconnectedFlag()
|
||||
{
|
||||
NETLIST_OBJECT* NetItemRef;
|
||||
unsigned NetStart, NetEnd;
|
||||
|
@ -863,13 +866,13 @@ void NETLIST_OBJECT_LIST::SetUnconnectedFlag()
|
|||
if( ( idxtoTest >= size() )
|
||||
|| ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
|
||||
{
|
||||
/* Net analysis to update m_FlagOfConnection */
|
||||
/* Net analysis to update m_ConnectionType */
|
||||
NetEnd = idxtoTest;
|
||||
|
||||
/* set m_FlagOfConnection member to StateFlag for all items of
|
||||
/* set m_ConnectionType member to StateFlag for all items of
|
||||
* this net: */
|
||||
for( unsigned kk = NetStart; kk < NetEnd; kk++ )
|
||||
GetItem( kk )->m_FlagOfConnection = StateFlag;
|
||||
GetItem( kk )->m_ConnectionType = StateFlag;
|
||||
|
||||
if( idxtoTest >= size() )
|
||||
return;
|
||||
|
|
|
@ -21,12 +21,6 @@ class SCH_ITEM;
|
|||
//void DisplayCmpDoc( wxString& Name );
|
||||
wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufName );
|
||||
|
||||
|
||||
/*********************/
|
||||
/* DANGLING_ENDS.CPP */
|
||||
/*********************/
|
||||
bool SegmentIntersect( wxPoint aSegStart, wxPoint aSegEnd, wxPoint aTestPoint );
|
||||
|
||||
// operations_on_item_lists.cpp
|
||||
void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList );
|
||||
|
||||
|
|
|
@ -535,7 +535,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
|
|||
wxT( "Dangling end type list overflow. Bad programmer!" ) );
|
||||
|
||||
DANGLING_END_ITEM & nextItem = aItemList[ii];
|
||||
m_isDangling = !SegmentIntersect( item.GetPosition(), nextItem.GetPosition(), m_Pos );
|
||||
m_isDangling = !IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_Pos );
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -31,6 +31,19 @@
|
|||
#include <math.h>
|
||||
#include <wx/gdicmn.h> // For wxPoint
|
||||
|
||||
/**
|
||||
* Function IsPointOnSegment
|
||||
* @param aSegStart The first point of the segment S.
|
||||
* @param aSegEnd The second point of the segment S.
|
||||
* @param aTestPoint The point P to test.
|
||||
* @return true if the point P is on the segment S.
|
||||
* faster than TestSegmentHit() because P should be exactly on S
|
||||
* therefore works fine only for H, V and 45 deg segm.
|
||||
* suitable for busses and wires in eeschema, otherwise use TestSegmentHit()
|
||||
*/
|
||||
bool IsPointOnSegment( const wxPoint& aSegStart, const wxPoint& aSegEnd,
|
||||
const wxPoint& aTestPoint );
|
||||
|
||||
/**
|
||||
* Function SegmentIntersectsSegment
|
||||
*
|
||||
|
@ -105,8 +118,8 @@ inline double EuclideanNorm( const wxSize &vector )
|
|||
//! @param linePointA Point on line
|
||||
//! @param linePointB Point on line
|
||||
//! @param referencePoint Reference point
|
||||
inline double DistanceLinePoint( const wxPoint &linePointA,
|
||||
const wxPoint &linePointB,
|
||||
inline double DistanceLinePoint( const wxPoint &linePointA,
|
||||
const wxPoint &linePointB,
|
||||
const wxPoint &referencePoint )
|
||||
{
|
||||
// Some of the multiple double casts are redundant. However in the previous
|
||||
|
@ -114,9 +127,9 @@ inline double DistanceLinePoint( const wxPoint &linePointA,
|
|||
// the division (EuclideanNorm gives a double so from int it would
|
||||
// be promoted); that means that the whole expression were
|
||||
// vulnerable to overflow during int multiplications
|
||||
return fabs( ( double(linePointB.x - linePointA.x) *
|
||||
return fabs( ( double(linePointB.x - linePointA.x) *
|
||||
double(linePointA.y - referencePoint.y) -
|
||||
double(linePointA.x - referencePoint.x ) *
|
||||
double(linePointA.x - referencePoint.x ) *
|
||||
double(linePointB.y - linePointA.y) )
|
||||
/ EuclideanNorm( linePointB - linePointA ) );
|
||||
}
|
||||
|
@ -126,7 +139,7 @@ inline double DistanceLinePoint( const wxPoint &linePointA,
|
|||
//! @param pointB Second point
|
||||
//! @param threshold The maximum distance
|
||||
//! @return True or false
|
||||
inline bool HitTestPoints( const wxPoint &pointA, const wxPoint &pointB,
|
||||
inline bool HitTestPoints( const wxPoint &pointA, const wxPoint &pointB,
|
||||
double threshold )
|
||||
{
|
||||
wxPoint vectorAB = pointB - pointA;
|
||||
|
@ -157,7 +170,7 @@ inline double CrossProduct( const wxPoint &vectorA, const wxPoint &vectorB )
|
|||
* @param aEnd is the second end-point of the line segment
|
||||
* @param aDist = maximum distance for hit
|
||||
*/
|
||||
bool TestSegmentHit( const wxPoint &aRefPoint, wxPoint aStart,
|
||||
bool TestSegmentHit( const wxPoint &aRefPoint, wxPoint aStart,
|
||||
wxPoint aEnd, int aDist );
|
||||
|
||||
/**
|
||||
|
@ -191,10 +204,10 @@ template <class T> inline void NORMALIZE_ANGLE_360( T &Angle )
|
|||
while( Angle < -3600 )
|
||||
Angle += 3600;
|
||||
while( Angle > 3600 )
|
||||
Angle -= 3600;
|
||||
Angle -= 3600;
|
||||
}
|
||||
|
||||
/// Normalize angle to be in the 0.0 .. 360.0 range:
|
||||
/// Normalize angle to be in the 0.0 .. 360.0 range:
|
||||
template <class T> inline void NORMALIZE_ANGLE_POS( T &Angle )
|
||||
{
|
||||
while( Angle < 0 )
|
||||
|
|
|
@ -446,8 +446,14 @@ public:
|
|||
*/
|
||||
void SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT* LibItem );
|
||||
|
||||
/* netlist generation */
|
||||
void BuildNetListBase();
|
||||
/**
|
||||
* BuildNetListBase
|
||||
* netlist generation:
|
||||
* Creates a flat list which stores all connected objects, and mainly
|
||||
* pins and labels.
|
||||
* @return a pointer to the list
|
||||
*/
|
||||
NETLIST_OBJECT_LIST * BuildNetListBase();
|
||||
|
||||
/**
|
||||
* Function CreateNetlist
|
||||
|
@ -474,6 +480,8 @@ public:
|
|||
/**
|
||||
* Function WriteNetListFile
|
||||
* Create the netlist file. Netlist info must be existing
|
||||
* (BuildNetListBase() creates this info)
|
||||
* @param aConnectedItemsList = the initialized list of connected items
|
||||
* @param aFormat = netlist format (NET_TYPE_PCBNEW ...)
|
||||
* @param aFullFileName = full netlist file name
|
||||
* @param aNetlistOptions = netlist options using OR'ed bits.
|
||||
|
@ -485,7 +493,8 @@ public:
|
|||
* </p>
|
||||
* @return true if success.
|
||||
*/
|
||||
bool WriteNetListFile( int aFormat,
|
||||
bool WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList,
|
||||
int aFormat,
|
||||
const wxString& aFullFileName,
|
||||
unsigned aNetlistOptions );
|
||||
|
||||
|
|
Loading…
Reference in New Issue