Commit aa9e61ed authored by charras's avatar charras

Code cleanup about netlist, ERC and markers in eeschema ( work in progress )

parent a97a2b4b
......@@ -8,7 +8,7 @@
#include "appl_wxstruct.h"
#define BUILD_VERSION "(20090708-unstable)"
#define BUILD_VERSION "(20090712-unstable)"
#ifdef HAVE_SVN_VERSION
......
......@@ -23,6 +23,7 @@ set(EESCHEMA_SRCS
class_libentry_fields.cpp
class_library.cpp
class_marker_sch.cpp
class_netlist_object.cpp
class_pin.cpp
class_sch_cmp_field.cpp
class_schematic_items.cpp
......
......@@ -675,10 +675,6 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
bBox.Merge( DrawEntry->GetBoundingBox() );
}
wxRect r = bBox;
wxLogDebug( wxT( "New boundary box = (%d, %d, %d, %d)" ), r.GetLeft(),
r.GetRight(), r.GetBottom(), r.GetTop() );
return bBox;
}
......
/*************************************************************************************/
/* Class NETLIST_OBJECT to handle 1 item connected (in netlist and erc calculations) */
/*************************************************************************************/
#include "fctsys.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "class_netlist_object.h"
#if defined(DEBUG)
#include <iostream>
const char* ShowType( NetObjetType aType )
{
const char* ret;
switch( aType )
{
case NET_SEGMENT:
ret = "segment"; break;
case NET_BUS:
ret = "bus"; break;
case NET_JONCTION:
ret = "junction"; break;
case NET_LABEL:
ret = "label"; break;
case NET_HIERLABEL:
ret = "hierlabel"; break;
case NET_GLOBLABEL:
ret = "glabel"; break;
case NET_BUSLABELMEMBER:
ret = "buslblmember"; break;
case NET_HIERBUSLABELMEMBER:
ret = "hierbuslblmember"; break;
case NET_GLOBBUSLABELMEMBER:
ret = "gbuslblmember"; break;
case NET_SHEETBUSLABELMEMBER:
ret = "sbuslblmember"; break;
case NET_SHEETLABEL:
ret = "sheetlabel"; break;
case NET_PINLABEL:
ret = "pinlabel"; break;
case NET_PIN:
ret = "pin"; break;
case NET_NOCONNECT:
ret = "noconnect"; break;
default:
ret = "??"; break;
}
return ret;
}
void NETLIST_OBJECT::Show( std::ostream& out, int ndx )
{
wxString path = m_SheetList.PathHumanReadable();
out << "<netItem ndx=\"" << ndx << '"' <<
" type=\"" << ShowType( m_Type ) << '"' <<
" netCode=\"" << GetNet() << '"' <<
" sheet=\"" << CONV_TO_UTF8( path ) << '"' <<
">\n";
out << " <start " << m_Start << "/> <end " << m_End << "/>\n";
if( m_Label )
out << " <label>" << m_Label->mb_str() << "</label>\n";
if( m_Comp )
m_Comp->Show( 1, out );
else
out << " m_Comp==NULL\n";
out << "</netItem>\n";
}
#endif
NETLIST_OBJECT::NETLIST_OBJECT()
{
m_Type = NET_ITEM_UNSPECIFIED; /* Type of this item (see NetObjetType enum) */
m_Comp = NULL; /* Pointer on the library item that created this net object (the parent)*/
m_Link = NULL; /* For Hierarchical_PIN_Sheet_Struct:
* Pointer to the hierarchy sheet that contains this Hierarchical_PIN_Sheet_Struct
* For Pins: pointer to the component that contains this pin
*/
m_Flag = 0; /* flag used in calculations */
m_ElectricalType = 0; /* Has meaning only for Pins and hierachical pins: electrical type */
m_NetCode = 0; /* net code for all items except BUS labels because a BUS label has
* as many net codes as bus members
*/
m_BusNetCode = 0; /* Used for BUS connections */
m_Member = 0; /* for labels type NET_BUSLABELMEMBER ( bus member created from the BUS label )
* member number
*/
m_FlagOfConnection = UNCONNECTED;
m_PinNum = 0; /* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
m_Label = 0; /* For all labels:pointer on the text label */
}
// Copy constructor
NETLIST_OBJECT::NETLIST_OBJECT( NETLIST_OBJECT& aSource )
{
}
NETLIST_OBJECT::~NETLIST_OBJECT()
{
/* NETLIST_OBJECT is owner of m_Label only if its type is
* NET_HIERBUSLABELMEMBER, NET_GLOBBUSLABELMEMBER, NET_SHEETBUSLABELMEMBER or NET_BUSLABELMEMBER
* So we must delete m_Label only for these cases
* ( see the note in ConvertBustToMembers)
*/
switch( m_Type )
{
default:
break;
case NET_HIERBUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
case NET_SHEETBUSLABELMEMBER:
case NET_BUSLABELMEMBER:
SAFE_DELETE( m_Label );
break;
}
}
/*************************************************************************************/
/* Class NETLIST_OBJECT to handle 1 item connected (in netlist and erc calculations) */
/*************************************************************************************/
#ifndef _CLASS_NETLIST_OBJECT_H_
#define _CLASS_NETLIST_OBJECT_H_
/* Type of Net objects (wires, labels, pins...) */
enum NetObjetType {
NET_ITEM_UNSPECIFIED, // only for not yet initialized instances
NET_SEGMENT, // connection by wire
NET_BUS, // connection by bus
NET_JONCTION, // connection by junction: can connect to or more crossing wires
NET_LABEL, // this is a local label
NET_GLOBLABEL, // this is a global label that connect all others global label in whole hierrachy
NET_HIERLABEL, // element to indicate connection to a higher-level sheet
NET_SHEETLABEL, // element to indicate connection to a lower-level sheet.
NET_BUSLABELMEMBER, /* created when a bus label is found:
* the bus label (like DATA[0..7] is converted to n single labels like DATA0, DATA1 ...
*/
NET_GLOBBUSLABELMEMBER, // see NET_BUSLABELMEMBER, used when a global bus label is found
NET_HIERBUSLABELMEMBER, // see NET_BUSLABELMEMBER, used when a hierarchical bus label is found
NET_SHEETBUSLABELMEMBER, // see NET_BUSLABELMEMBER, used when a pin sheet label using bus notation is found
NET_PINLABEL, /* created when a pin is POWER (IN or OUT) with invisible attribute is found:
* these pins are equivalent to a global label and are automatically connected
*/
NET_PIN, // this is an usual pin
NET_NOCONNECT // this is a no connect symbol
};
/* Values for .m_FlagOfConnection member */
enum ConnectType {
UNCONNECTED = 0, /* Pin or Label not connected (error) */
NOCONNECT_SYMBOL_PRESENT, /* Pin not connected but have a NoConnect symbol on it (no error) */
PAD_CONNECT /* Normal connection (no error) */
};
class NETLIST_OBJECT
{
public:
NetObjetType m_Type; /* Type of this item (see NetObjetType enum) */
EDA_BaseStruct* m_Comp; /* Pointer on the library item that created this net object (the parent)*/
SCH_ITEM* m_Link; /* For Hierarchical_PIN_Sheet_Struct:
* Pointer to the hierarchy sheet that contains this Hierarchical_PIN_Sheet_Struct
* For Pins: pointer to the component that contains this pin
*/
int m_Flag; /* flag used in calculations */
DrawSheetPath m_SheetList;
int m_ElectricalType; /* Has meaning only for Pins and hierachical pins: electrical type */
private:
int m_NetCode; /* net code for all items except BUS labels because a BUS label has
* as many net codes as bus members
*/
public:
int m_BusNetCode; /* Used for BUS connections */
int m_Member; /* for labels type NET_BUSLABELMEMBER ( bus member created from the BUS label )
* member number
*/
ConnectType m_FlagOfConnection;
DrawSheetPath m_SheetListInclude; /* sheet that the hierarchal label connects to.*/
long m_PinNum; /* pin number ( 1 long = 4 bytes -> 4 ascii codes) */
const wxString* m_Label; /* For all labels:pointer on the text label */
wxPoint m_Start; // Position of object or for segments: starting point
wxPoint m_End; // For segments (wire and busses): ending point
#if defined(DEBUG)
void Show( std::ostream& out, int ndx );
#endif
NETLIST_OBJECT();
NETLIST_OBJECT( NETLIST_OBJECT& aSource ); // Copy constructor
~NETLIST_OBJECT();
void SetNet( int aNetCode ) { m_NetCode = aNetCode; }
int GetNet() const { return m_NetCode; }
};
#endif // _CLASS_NETLIST_OBJECT_H_
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -11,6 +11,8 @@
#define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins
#include "class_netlist_object.h"
/* Id to select netlist type */
enum TypeNetForm {
NET_TYPE_UNINIT = 0,
......@@ -30,69 +32,6 @@ enum TypeNetForm {
/* Max pin number per component and footprint */
#define MAXPIN 5000
enum NetObjetType {
/* Type des objets de Net */
NET_SEGMENT,
NET_BUS,
NET_JONCTION,
NET_LABEL,
NET_GLOBLABEL,
NET_HIERLABEL, //on a screen to indicate connection to a higher-level sheet
NET_SHEETLABEL, //on a drawscreen element to indicate connection to a lower-level sheet.
NET_BUSLABELMEMBER,
NET_GLOBBUSLABELMEMBER,
NET_HIERBUSLABELMEMBER,
NET_SHEETBUSLABELMEMBER,
NET_PINLABEL,
NET_PIN,
NET_NOCONNECT
};
enum ConnectType {
/* Valeur du Flag de connection */
UNCONNECTED = 0, /* Pin ou Label non connecte */
NOCONNECT, /* Pin volontairement non connectee (Symb. NoConnect utilise) */
PAD_CONNECT /* connexion normale */
};
/* Structure decrivant 1 element de connexion (pour netlist ) */
class ObjetNetListStruct
{
public:
NetObjetType m_Type; // Type of this item (see NetObjetType enum)
EDA_BaseStruct* m_Comp; /* Pointer on the schematic item that created this net object (the parent)*/
void* m_Link; /* For Hierarchical_PIN_Sheet_Struct:
* Pointer to the hierarchy sheet that contains this Hierarchical_PIN_Sheet_Struct
* For Pins: pointer to the component that contains this pin
*/
int m_Flag; /* flag used in calculations */
DrawSheetPath m_SheetList;
int m_ElectricalType; /* Has meaning only for Pins and hierachical pins: electrical type */
private:
int m_NetCode; /* net code for all items except BUS labels because a BUS label has
* as many net codes as bus members
*/
public:
int m_BusNetCode; /* Used for BUS connections */
int m_Member; /* for labels type NET_BUSLABELMEMBER ( bus member created from the BUS label )
* member number
*/
ConnectType m_FlagOfConnection;
DrawSheetPath m_SheetListInclude; /* sheet that the hierarchal label connects to.*/
long m_PinNum; /* numero de pin( 4 octets -> 4 codes ascii) */
const wxString* m_Label; /* For all labels:pointer on the text label */
wxPoint m_Start, m_End;
#if defined(DEBUG)
void Show( std::ostream& out, int ndx );
#endif
void SetNet( int aNetCode ) { m_NetCode = aNetCode; }
int GetNet() const { return m_NetCode; }
};
/* object used in annotation to handle a list of components in schematic
......@@ -150,15 +89,17 @@ public:
/* Global Variables */
extern int g_NbrObjNet;
extern ObjetNetListStruct* g_TabObjNet;
// Buffer to build the list of items used in netlist and erc calculations
typedef std::vector <NETLIST_OBJECT*> NETLIST_OBJECT_LIST;
extern NETLIST_OBJECT_LIST g_NetObjectslist;
/* Prototypes: */
void WriteNetList( WinEDA_SchematicFrame* frame,
const wxString& FileNameNL,
bool use_netnames );
void FreeTabNetList( ObjetNetListStruct* TabNetItems, int NbrNetItems );
void FreeNetObjectsList( std::vector <NETLIST_OBJECT*>& aNetObjectslist );
/** Function ReturnUserNetlistTypeName
* to retrieve user netlist type names
......
......@@ -28,8 +28,6 @@
#define CUSTOM_NETLIST_TITLE wxT( "CustomNetlistTitle" )
#define CUSTOM_NETLIST_COMMAND wxT( "CustomNetlistCommand" )
/* Loacl variable */
/****************************************************/
wxString ReturnUserNetlistTypeName( bool first_item )
/****************************************************/
......@@ -531,7 +529,6 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
break;
}
FreeTabNetList( g_TabObjNet, g_NbrObjNet );
m_Parent->m_NetlistFormat = netformat_tmp;
WriteCurrentNetlistSetup();
......
......@@ -166,7 +166,7 @@ public:
SCH_COMPONENT* LibItem );
/* netlist generation */
void* BuildNetListBase();
void BuildNetListBase();
/**
* Function DeleteAnnotation
......
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