Commit f2e5da63 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: netlist generation: fix bad choice for the "best net name" when...

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