Commit d24caad2 authored by Dick Hollenbeck's avatar Dick Hollenbeck

++eeschema netlist.cpp and netform.cpp:

  * Found several speed optimizations in the netlist export code.
  * Fixed a bug in EXPORT_HELP::FindAllInstancesOfComponent() that I had broke.
  * Now sort the pins properly if they have pin numbers like A1 and A10,
    i.e. alphanumerics in them.
parents 7146863b df9dae6d
......@@ -4,18 +4,25 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.
2010-Jul-30 UPDATE Dick Hollenbeck <dick@softplc.com>
2010-Aug-3 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++eeschema netlist.cpp and netform.cpp:
* Found several speed optimizations in the netlist export code.
* Now sort the pins properly if they have pin numbers like A1 and A10,
i.e. alphanumerics in them.
2010-Jul-30 & 31 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++eeschema:
* Now link with XML support within wxWidgets.
* Start of export the generic netlist in XML. Still need to rework the chain
loaded netlist plugin.
* Export the generic netlist in XML. Only the libpart elements are missing now.
Still need to rework the chain loaded netlist plugin, but may do that in XSL.
* OBJ_CMP_TO_LIST class now uses a std::string to hold the 8 bit string m_Ref,
but hides this behind accessors which provide for both Unicode and 8 bit
set and get functions.
* build_BOM.cpp retains the selected filename on subsequent runs as a default.
* Code cleaning, especially in build_BOM.cpp.
* Will work tomorrow also.
2010-jul-27, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
......
......@@ -320,3 +320,113 @@ char* strupper( char* Text )
return Text;
}
int RefDesStringCompare( const wxString& strFWord, const wxString& strSWord )
{
// The different sections of the first string
wxString strFWordBeg, strFWordMid, strFWordEnd;
// The different sections of the second string
wxString strSWordBeg, strSWordMid, strSWordEnd;
int isEqual = 0; // The numerical results of a string compare
int iReturn = 0; // The variable that is being returned
long lFirstDigit = 0; /* The converted middle section of the first
*string */
long lSecondDigit = 0; /* The converted middle section of the second
*string */
// Split the two strings into separate parts
SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd );
SplitString( strSWord, &strSWordBeg, &strSWordMid, &strSWordEnd );
// Compare the Beginning section of the strings
isEqual = strFWordBeg.CmpNoCase( strSWordBeg );
if( isEqual > 0 )
iReturn = 1;
else if( isEqual < 0 )
iReturn = -1;
else
{
// If the first sections are equal compare their digits
strFWordMid.ToLong( &lFirstDigit );
strSWordMid.ToLong( &lSecondDigit );
if( lFirstDigit > lSecondDigit )
iReturn = 1;
else if( lFirstDigit < lSecondDigit )
iReturn = -1;
else
{
// If the first two sections are equal compare the endings
isEqual = strFWordEnd.CmpNoCase( strSWordEnd );
if( isEqual > 0 )
iReturn = 1;
else if( isEqual < 0 )
iReturn = -1;
else
iReturn = 0;
}
}
return iReturn;
}
int SplitString( wxString strToSplit,
wxString* strBeginning,
wxString* strDigits,
wxString* strEnd )
{
// Clear all the return strings
strBeginning->Empty();
strDigits->Empty();
strEnd->Empty();
// There no need to do anything if the string is empty
if( strToSplit.length() == 0 )
return 0;
// Starting at the end of the string look for the first digit
int ii;
for( ii = (strToSplit.length() - 1); ii >= 0; ii-- )
{
if( isdigit( strToSplit[ii] ) )
break;
}
// If there were no digits then just set the single string
if( ii < 0 )
*strBeginning = strToSplit;
else
{
// Since there is at least one digit this is the trailing string
*strEnd = strToSplit.substr( ii + 1 );
// Go to the end of the digits
int position = ii + 1;
for( ; ii >= 0; ii-- )
{
if( !isdigit( strToSplit[ii] ) )
break;
}
// If all that was left was digits, then just set the digits string
if( ii < 0 )
*strDigits = strToSplit.substr( 0, position );
/* We were only looking for the last set of digits everything else is
*part of the preamble */
else
{
*strDigits = strToSplit.substr( ii + 1, position - ii - 1 );
*strBeginning = strToSplit.substr( 0, ii + 1 );
}
}
return 0;
}
......@@ -71,12 +71,6 @@ static bool SortLabelsBySheet( const LABEL_OBJECT& obj1,
static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList );
static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList );
int RefDesStringCompare( const wxString& lhs, const wxString& rhs );
int SplitString( wxString strToSplit,
wxString* strBeginning,
wxString* strDigits,
wxString* strEnd );
// separator used in bom export to spreadsheet
static char s_ExportSeparatorSymbol;
......@@ -1049,122 +1043,3 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
}
/* This function will act just like the strcmp function but correctly sort
* the numerical order in the string
* return -1 if first string is less than the second
* return 0 if the strings are equal
* return 1 if the first string is greater than the second
*/
int RefDesStringCompare( const wxString& strFWord, const wxString& strSWord )
{
// The different sections of the first string
wxString strFWordBeg, strFWordMid, strFWordEnd;
// The different sections of the second string
wxString strSWordBeg, strSWordMid, strSWordEnd;
int isEqual = 0; // The numerical results of a string compare
int iReturn = 0; // The variable that is being returned
long lFirstDigit = 0; /* The converted middle section of the first
*string */
long lSecondDigit = 0; /* The converted middle section of the second
*string */
// Split the two string into separate parts
SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd );
SplitString( strSWord, &strSWordBeg, &strSWordMid, &strSWordEnd );
// Compare the Beginning section of the strings
isEqual = strFWordBeg.CmpNoCase( strSWordBeg );
if( isEqual > 0 )
iReturn = 1;
else if( isEqual < 0 )
iReturn = -1;
else
{
// If the first sections are equal compare there digits
strFWordMid.ToLong( &lFirstDigit );
strSWordMid.ToLong( &lSecondDigit );
if( lFirstDigit > lSecondDigit )
iReturn = 1;
else if( lFirstDigit < lSecondDigit )
iReturn = -1;
else
{
// If the first two sections are equal compare the endings
isEqual = strFWordEnd.CmpNoCase( strSWordEnd );
if( isEqual > 0 )
iReturn = 1;
else if( isEqual < 0 )
iReturn = -1;
else
iReturn = 0;
}
}
return iReturn;
}
/* This is the function that breaks a string into three parts.
* The alphabetic preamble
* The numeric part
* Any alphabetic ending
* For example C10A is split to C 10 A
*/
int SplitString( wxString strToSplit,
wxString* strBeginning,
wxString* strDigits,
wxString* strEnd )
{
// Clear all the return strings
strBeginning->Clear();
strDigits->Clear();
strEnd->Clear();
// There no need to do anything if the string is empty
if( strToSplit.length() == 0 )
return 0;
// Starting at the end of the string look for the first digit
int ii;
for( ii = (strToSplit.length() - 1); ii >= 0; ii-- )
{
if( isdigit( strToSplit[ii] ) )
break;
}
// If there were no digits then just set the single string
if( ii < 0 )
*strBeginning = strToSplit;
else
{
// Since there is at least one digit this is the trailing string
*strEnd = strToSplit.substr( ii + 1 );
// Go to the end of the digits
int position = ii + 1;
for( ; ii >= 0; ii-- )
{
if( !isdigit( strToSplit[ii] ) )
break;
}
// If all that was left was digits, then just set the digits string
if( ii < 0 )
*strDigits = strToSplit.substr( 0, position );
/* We were only looking for the last set of digits everything else is
*part of the preamble */
else
{
*strDigits = strToSplit.substr( ii + 1, position - ii - 1 );
*strBeginning = strToSplit.substr( 0, ii + 1 );
}
}
return 0;
}
......@@ -220,7 +220,7 @@ wxString SCH_SHEET_PATH::Path()
* (the "normal" path uses the time stamps which do not changes even when
* editing sheet parameters)
*/
wxString SCH_SHEET_PATH::PathHumanReadable()
wxString SCH_SHEET_PATH::PathHumanReadable() const
{
wxString s, t;
......@@ -355,6 +355,7 @@ SCH_ITEM* SCH_SHEET_PATH::MatchNextItem( wxFindReplaceData& aSearchData,
bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 )
{
m_numSheets = d1.m_numSheets;
unsigned i;
for( i = 0; i < m_numSheets; i++ )
{
......@@ -370,10 +371,11 @@ bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 )
}
bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 )
bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const
{
if( m_numSheets != d1.m_numSheets )
return false;
for( unsigned i = 0; i < m_numSheets; i++ )
{
if( m_sheets[i] != d1.m_sheets[i] )
......@@ -384,14 +386,23 @@ bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 )
}
bool SCH_SHEET_PATH::operator!=( const SCH_SHEET_PATH& d1 )
bool SCH_SHEET_PATH::operator!=( const SCH_SHEET_PATH& d1 ) const
{
if( m_numSheets != d1.m_numSheets )
return true;
for( unsigned i = 0; i < m_numSheets; i++ )
{
if( m_sheets[i] != d1.m_sheets[i] )
{
/*
printf( "micompare this:'%s' d1:'%s'\n",
CONV_TO_UTF8( PathHumanReadable() ),
CONV_TO_UTF8( d1.PathHumanReadable() ) );
*/
return true;
}
}
return false;
......
......@@ -150,7 +150,7 @@ public:
* stamps in the path. (Time stamps do not change even when editing
* sheet parameters).
*/
wxString PathHumanReadable();
wxString PathHumanReadable() const;
/** Function BuildSheetPathInfoFromSheetPathValue
* Fill this with data to access to the hierarchical sheet known by its
......@@ -207,9 +207,9 @@ public:
bool operator=( const SCH_SHEET_PATH& d1 );
bool operator==( const SCH_SHEET_PATH& d1 );
bool operator==( const SCH_SHEET_PATH& d1 ) const;
bool operator!=( const SCH_SHEET_PATH& d1 );
bool operator!=( const SCH_SHEET_PATH& d1 ) const;
};
......
......@@ -10,7 +10,6 @@
#include "class_netlist_object.h"
#if defined(DEBUG)
#include <iostream>
const char* ShowType( NetObjetType aType )
......@@ -84,10 +83,28 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx )
if( !m_Label.IsEmpty() )
out << " <label>" << m_Label.mb_str() << "</label>\n";
out << " <sheetpath>" << m_SheetList.PathHumanReadable().mb_str() << "</sheetpath>\n";
switch( m_Type )
{
case NET_PIN:
out << " <refOfComp>" << ((SCH_COMPONENT*)m_Link)->GetRef(&m_SheetList).mb_str() << "</refOfComp>\n";
if( m_Comp )
m_Comp->Show( 1, out );
break;
default:
// not all the m_Comp classes have working Show functions.
;
}
/* was segfault-ing
if( m_Comp )
m_Comp->Show( 1, out );
m_Comp->Show( 1, out ); // labels may not have good Show() funcs?
else
out << " m_Comp==NULL\n";
*/
out << "</netItem>\n";
}
......@@ -134,3 +151,4 @@ NETLIST_OBJECT::NETLIST_OBJECT( NETLIST_OBJECT& aSource )
NETLIST_OBJECT::~NETLIST_OBJECT()
{
}
......@@ -6,6 +6,9 @@
#ifndef _CLASS_NETLIST_OBJECT_H_
#define _CLASS_NETLIST_OBJECT_H_
#include "class_pin.h" // LIB_PIN::ReturnPinStringNum( m_PinNum )
/* Type of Net objects (wires, labels, pins...) */
enum NetObjetType {
NET_ITEM_UNSPECIFIED, // only for not yet initialized instances
......@@ -105,6 +108,17 @@ public:
void SetNet( int aNetCode ) { m_NetCode = aNetCode; }
int GetNet() const { return m_NetCode; }
/**
* Function GetPinNum
* returns a pin number in wxString form. Pin numbers are not always
* numbers. "A23" would be a valid pin number.
*/
wxString GetPinNumText()
{
// hide the ugliness in here, but do it inline.
return LIB_PIN::ReturnPinStringNum( m_PinNum );
}
};
#endif // _CLASS_NETLIST_OBJECT_H_
......@@ -1485,12 +1485,6 @@ wxString LIB_PIN::ReturnPinStringNum( long aPinNum )
}
wxString LIB_PIN::GetNumber( void )
{
return ReturnPinStringNum( m_PinNum );
}
/** Function LIB_PIN::SetPinNumFromString()
* fill the buffer with pin num as a wxString
* Pin num is coded as a long
......@@ -1772,3 +1766,16 @@ const char*** LIB_PIN::GetStyleSymbols()
return s_icons_Pins_Shapes;
}
#if defined(DEBUG)
void LIB_PIN::Show( int nestLevel, std::ostream& os )
{
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
<< " num=\"" << GetNumber().mb_str()
<< '"' << "/>\n";
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
}
#endif
......@@ -7,6 +7,7 @@
#ifndef CLASS_PIN_H
#define CLASS_PIN_H
#include "classes_body_items.h"
#define TARGET_PIN_DIAM 12 /* Circle diameter drawn at the active end of
* pins */
......@@ -114,6 +115,10 @@ public:
return wxT( "LIB_PIN" );
}
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); // virtual override
#endif
/**
* Write pin object to a FILE in "*.lib" format.
......@@ -159,7 +164,12 @@ public:
*/
void ReturnPinStringNum( wxString& aStringBuffer ) const;
wxString GetNumber();
wxString GetNumber()
{
return ReturnPinStringNum( m_PinNum );
}
/** Function ReturnPinStringNum (static function)
* Pin num is coded as a long or 4 ascii chars
......
......@@ -934,7 +934,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os )
<< '"' << " chipName=\""
<< CONV_TO_UTF8( m_ChipName ) << '"' << m_Pos
<< " layer=\"" << m_Layer
<< '"' << "/>\n";
<< '"' << ">\n";
// skip the reference, it's been output already.
for( int i = 1; i < GetFieldCount(); ++i )
......
......@@ -7,6 +7,8 @@
#ifndef CLASSES_BODY_ITEMS_H
#define CLASSES_BODY_ITEMS_H
#include "base_struct.h"
class LIB_COMPONENT;
class PLOTTER;
......
This diff is collapsed.
......@@ -273,7 +273,7 @@ void WinEDA_SchematicFrame::BuildNetListBase()
sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsbyNetcode );
#if defined(NETLIST_DEBUG) && defined(DEBUG)
std::cout << "after qsort()\n";
std::cout << "\n\nafter qsort()\n";
dumpNetTable();
#endif
......@@ -467,7 +467,6 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
NETLIST_OBJECT* new_item;
SCH_COMPONENT* DrawLibItem;
LIB_COMPONENT* Entry;
LIB_PIN* pin;
SCH_SHEET_PATH list;
DrawList = sheetlist->LastScreen()->EEDrawList;
......@@ -587,24 +586,20 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) DrawList;
Entry =
CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry == NULL )
break;
for( pin = Entry->GetNextPin(); pin != NULL;
pin = Entry->GetNextPin( pin ) )
for( LIB_PIN* pin = Entry->GetNextPin(); pin; pin = Entry->GetNextPin( pin ) )
{
wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
if( pin->m_Unit
&& ( pin->m_Unit !=
DrawLibItem->GetUnitSelection( sheetlist ) ) )
if( pin->m_Unit &&
( pin->m_Unit != DrawLibItem->GetUnitSelection( sheetlist ) ) )
continue;
if( pin->m_Convert
&& ( pin->m_Convert != DrawLibItem->m_Convert ) )
if( pin->m_Convert &&
( pin->m_Convert != DrawLibItem->m_Convert ) )
continue;
wxPoint pos2 =
......@@ -640,7 +635,6 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
aNetItemBuffer.push_back( new_item );
}
}
break;
case DRAW_POLYLINE_STRUCT_TYPE:
......
......@@ -382,4 +382,4 @@ void MyFree( void* pt_mem );
void* MyZMalloc( size_t nb_octets );
void* MyMalloc( size_t nb_octets );
#endif /* __INCLUDE__COMMON_H__ */
#endif // __INCLUDE__COMMON_H__
......@@ -79,5 +79,27 @@ bool WildCompareString( const wxString& pattern,
*/
char* to_point( char* Text );
/**
* Function RefDesStringCompare
* acts just like the strcmp function but treats numbers within the string text
* correctly for sorting. eg. A10 > A2
* return -1 if first string is less than the second
* return 0 if the strings are equal
* return 1 if the first string is greater than the second
*/
int RefDesStringCompare( const wxString& lhs, const wxString& rhs );
/**
* Function SplitString
* breaks a string into three parts.
* The alphabetic preamble
* The numeric part
* Any alphabetic ending
* For example C10A is split to C 10 A
*/
int SplitString( wxString strToSplit,
wxString* strBeginning,
wxString* strDigits,
wxString* strEnd );
#endif /* __INCLUDE__KICAD_STRING_H__ */
#endif // __INCLUDE__KICAD_STRING_H__
......@@ -16,20 +16,22 @@
/**
* Function GetChars
* returns a pointer to the actual character data, either 8 or
* 16 bits wide, depending on how the wxWidgets library was compiled.
* returns a wxChar* to the actual character data within a wxString, and is
* helpful for passing strings to wxString::Printf(wxT("%s"), GetChars(wxString) )
* <p>
* wxChar is defined to be <ul>
* <li> standard C style char when wxUSE_UNICODE==0 </li>
* <li> wchar_t when wxUSE_UNICODE==1 (the default). </li>
* <ul>
* i.e. it depends on how the wxWidgets library was compiled. There was a period
* during the development of wxWidgets 2.9 when GetData() was missing, so this
* function was used to provide insulation from that design change. It may
* no longer be needed, and is harmless. GetData() seems to be an acceptable
* alternative in all cases now.
*/
static inline const wxChar* GetChars( wxString s )
static inline const wxChar* GetChars( const wxString& s )
{
#if wxCHECK_VERSION( 2, 9, 0 )
/* To be Fixed:
* Currently, access to the actual character data in <wxString::Printf
* is a moving target
* So, with wxWidgets 2.9.0 this line is subject to change:
*/
// return (const wxChar*) s.wx_str();
return (const wxChar*) s.c_str();
#else
return s.GetData();
......
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