Commit 4f8049f8 authored by jean-pierre charras's avatar jean-pierre charras

fixed 2 minor bugs

parent de509f57
...@@ -115,11 +115,7 @@ public: ...@@ -115,11 +115,7 @@ public:
int SaveNetList( const wxString& FullFileName ); int SaveNetList( const wxString& FullFileName );
int SaveComponentList( const wxString& FullFileName ); int SaveComponentList( const wxString& FullFileName );
bool ReadNetList(); bool ReadNetList();
int rdpcad();
int ReadSchematicNetlist(); int ReadSchematicNetlist();
int ReadFootprintFilterList( FILE* f );
int ReadViewlogicWirList();
int ReadViewlogicNetList();
void LoadProjectFile( const wxString& FileName ); void LoadProjectFile( const wxString& FileName );
void SaveProjectFile( const wxString& fileName ); void SaveProjectFile( const wxString& fileName );
virtual void LoadSettings(); virtual void LoadSettings();
......
...@@ -18,11 +18,14 @@ ...@@ -18,11 +18,14 @@
#include "protos.h" #include "protos.h"
#include "cvstruct.h" #include "cvstruct.h"
#include "richio.h"
#define SEPARATEUR '|' /* Separator character in NetList */ #define SEPARATEUR '|' /* Separator character in NetList */
static int ReadPinConnection( FILE* f, COMPONENT* CurrentCmp ); static int ReadPinConnection( FILE_LINE_READER& aNetlistReader, COMPONENT* CurrentCmp );
static int ReadFootprintFilterList( FILE_LINE_READER& aNetlistReader, COMPONENT_LIST& aComponentsList );
/* Sort the list alphabetically by component and and returns /* Sort the list alphabetically by component and and returns
...@@ -86,17 +89,12 @@ static int ReadPinConnection( FILE* f, COMPONENT* CurrentCmp ); ...@@ -86,17 +89,12 @@ static int ReadPinConnection( FILE* f, COMPONENT* CurrentCmp );
int WinEDA_CvpcbFrame::ReadSchematicNetlist() int WinEDA_CvpcbFrame::ReadSchematicNetlist()
{ {
char alim[1024]; char alim[1024];
int i, k, l; int idx, jj, k, l;
char* LibName; char* LibName;
char Line[BUFFER_CHAR_SIZE + 1]; char cbuffer[BUFFER_CHAR_SIZE]; /* temporary storage */
wxString component_reference; /* buffer for component reference (U1, R4...) */ char* ptchar;
wxString schematic_timestamp; /* buffer for component time stamp */
wxString footprint_name; /* buffer for component footprint field */
wxString component_value; /* buffer for component values (470K, 22nF ...) */
char* ptchar;
COMPONENT* Cmp; COMPONENT* Cmp;
FILE* source; FILE* source;
char* result;
m_modified = false; m_modified = false;
m_isEESchemaNetlist = false; m_isEESchemaNetlist = false;
...@@ -111,27 +109,31 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -111,27 +109,31 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
if( source == 0 ) if( source == 0 )
{ {
DisplayError( this, _( "File <" ) + m_NetlistFileName.GetFullPath() + DisplayError( this, _( "File <" ) + m_NetlistFileName.GetFullPath() +
_( "> not found" ) ); _( "> not found" ) );
return -1; return -1;
} }
FILE_LINE_READER netlistReader( source, BUFFER_CHAR_SIZE );
char* Line = netlistReader;
/* Read the file header (must be "( { OrCAD PCB" or "({ OrCAD PCB" ) /* Read the file header (must be "( { OrCAD PCB" or "({ OrCAD PCB" )
* or "# EESchema Netlist" * or "# EESchema Netlist"
*/ */
result = fgets( Line, BUFFER_CHAR_SIZE, source ); netlistReader.ReadLine( );
/* test for netlist type PCB2 */ /* test for netlist type PCB2 */
i = strnicmp( Line, "( {", 3 ); idx = strnicmp( Line, "( {", 3 );
if( i != 0 ) if( idx != 0 )
i = strnicmp( Line, "({", 2 ); idx = strnicmp( Line, "({", 2 );
if( i != 0 ) if( idx != 0 )
{ {
i = strnicmp( Line, "# EESchema", 7 ); /* net type EESchema */ idx = strnicmp( Line, "# EESchema", 7 ); /* net type EESchema */
if( i == 0 ) if( idx == 0 )
m_isEESchemaNetlist = TRUE; m_isEESchemaNetlist = true;
} }
if( i != 0 ) if( idx != 0 )
{ {
wxString msg, Lineconv = CONV_FROM_UTF8( Line ); wxString msg, Lineconv = CONV_FROM_UTF8( Line );
msg.Printf( _( "Unknown file format <%s>" ), Lineconv.GetData() ); msg.Printf( _( "Unknown file format <%s>" ), Lineconv.GetData() );
...@@ -148,56 +150,54 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -148,56 +150,54 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
{ {
/* Search the beginning of a component description */ /* Search the beginning of a component description */
if( fgets( Line, BUFFER_CHAR_SIZE, source ) == 0 ) if( netlistReader.ReadLine( ) == 0 )
break; break;
/* Remove blanks */ /* Remove blanks */
i = 0; while( Line[i] == ' ' ) idx = 0;
i++; while( Line[idx] == ' ' )
idx++;
/* remove empty lines : */ /* remove empty lines : */
if( Line[i] < ' ' ) if( Line[idx] < ' ' )
continue; continue;
if( strnicmp( &Line[i], "{ Allowed footprints", 20 ) == 0 ) if( strnicmp( &Line[idx], "{ Allowed footprints", 20 ) == 0 )
{ {
ReadFootprintFilterList( source ); ReadFootprintFilterList( netlistReader, m_components );
continue; continue;
} }
if( strnicmp( &Line[i], "( ", 2 ) != 0 ) if( strnicmp( &Line[idx], "( ", 2 ) != 0 )
continue; continue;
/*******************************/ /*******************************/
/* Component description found */ /* Component description found */
/*******************************/ /*******************************/
while( Line[i] != ' ' ) Cmp = new COMPONENT(); // Creates the new component storage
i++;
while( Line[i] == ' ' ) while( Line[idx] != ' ' )
i++; idx++;
/* i points the beginning of the schematic time stamp */ while( Line[idx] == ' ' )
idx++;
schematic_timestamp.Empty(); /* idx points the beginning of the schematic time stamp */
while( Line[i] != ' ' ) jj = 0;
schematic_timestamp.Append( Line[i++] ); while( Line[idx] != ' ' && Line[idx] )
cbuffer[jj++] = Line[idx++];
cbuffer[jj] = 0;
Cmp->m_TimeStamp = CONV_FROM_UTF8(cbuffer);
/* search val/ref.lib */ /* search val/ref.lib */
while( Line[i] == ' ' ) while( Line[idx] == ' ' )
i++; idx++;
/* i points the component value */ /* idx points the component value */
LibName = Line + i; LibName = Line + idx;
component_reference.Empty();
footprint_name.Empty();
component_value.Empty();
memset( alim, 0, sizeof(alim) );
/* Read value */ /* Read value */
ptchar = strstr( &Line[idx], " " ); // Search end of value field (space)
ptchar = strstr( &Line[i], " " ); // Search end of value field (space)
if( ptchar == 0 ) if( ptchar == 0 )
{ {
wxString msg; wxString msg;
...@@ -208,62 +208,57 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -208,62 +208,57 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
else else
k = ptchar - Line; k = ptchar - Line;
for( ; i < k; i++ ) for( jj = 0; idx < k; idx++ )
{ {
if( Line[i] == SEPARATEUR ) if( Line[idx] == SEPARATEUR )
break; break;
footprint_name.Append( Line[i] ); cbuffer[jj++] = Line[idx];
} }
cbuffer[jj] = 0;
Cmp->m_Module = CONV_FROM_UTF8(cbuffer);
if( (Line[++i] == '(') && (Line[k - 1] == ')' ) ) if( (Line[++idx] == '(') && (Line[k - 1] == ')' ) )
{ {
i++; l = 0; while( k - 1 > i ) idx++; l = 0;
alim[l++] = Line[i++]; while( k - 1 > idx )
alim[l++] = Line[idx++];
} }
else else
i = k; idx = k;
/* Search component reference */ /* Search component reference */
while( Line[i] != ' ' ) while( Line[idx] != ' ' && Line[idx] )
i++; idx++;
/* goto end of value field */ /* goto end of value field */
while( Line[i] == ' ' ) while( Line[idx] == ' ' && Line[idx] )
i++; idx++;
/* goto beginning of reference */ /* goto beginning of reference */
for( ; ; i++ ) for( jj = 0; ; idx++ )
{ {
#if defined(KICAD_GOST) if( Line[idx] == ' ' || Line[idx] == 0)
if( Line[i] == ' ' )
#else
if( Line[i] <= ' ' )
#endif
break; break;
component_reference.Append( Line[i] ); cbuffer[jj++] = Line[idx];
} }
cbuffer[jj] = 0;
Cmp->m_Reference = CONV_FROM_UTF8(cbuffer);
/* Search component value */ /* Search component value */
while( Line[i] == ' ' ) while( Line[idx] == ' ' && Line[idx] )
i++; idx++;
/** goto beginning of value */ /** goto beginning of value */
for( ; ; i++ ) for( jj = 0 ; ; idx++ )
{ {
#if defined(KICAD_GOST) if( (Line[idx] == ' ') || (Line[idx] == '\n') || (Line[idx] == '\r') || Line[idx] == 0)
if( (Line[i] == ' ') || (Line[i] == '\n') || (Line[i] == '\r') )
#else
if( Line[i] <= ' ' )
#endif
break; break;
component_value.Append( Line[i] ); cbuffer[jj++] = Line[idx];
} }
cbuffer[jj] = 0;
Cmp->m_Value = CONV_FROM_UTF8(cbuffer);
/* Store info for this component */
Cmp = new COMPONENT();
Cmp->m_Reference = component_reference;
Cmp->m_Value = component_value;
m_components.push_back( Cmp ); m_components.push_back( Cmp );
if( m_isEESchemaNetlist ) /* copy footprint name: */ if( m_isEESchemaNetlist ) /* copy footprint name: */
...@@ -277,9 +272,8 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -277,9 +272,8 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
} }
} }
} }
Cmp->m_TimeStamp = schematic_timestamp;
ReadPinConnection( source, Cmp ); ReadPinConnection( netlistReader, Cmp );
} }
fclose( source ); fclose( source );
...@@ -290,15 +284,15 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -290,15 +284,15 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
} }
int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) int ReadFootprintFilterList( FILE_LINE_READER& aNetlistReader, COMPONENT_LIST& aComponentsList )
{ {
char Line[BUFFER_CHAR_SIZE + 1]; char* Line = aNetlistReader;
wxString CmpRef; wxString CmpRef;
COMPONENT* Cmp = NULL; COMPONENT* Cmp = NULL;
for( ; ; ) for( ; ; )
{ {
if( fgets( Line, BUFFER_CHAR_SIZE, f ) == 0 ) if( aNetlistReader.ReadLine( ) == 0 )
break; break;
if( strnicmp( Line, "$endlist", 8 ) == 0 ) if( strnicmp( Line, "$endlist", 8 ) == 0 )
{ {
...@@ -311,14 +305,13 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) ...@@ -311,14 +305,13 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
if( strnicmp( Line, "$component", 10 ) == 0 ) // New component ref found if( strnicmp( Line, "$component", 10 ) == 0 ) // New component ref found
{ {
CmpRef = CONV_FROM_UTF8( Line + 11 ); CmpRef = CONV_FROM_UTF8( Line + 11 );
CmpRef.Trim( TRUE ); CmpRef.Trim( true );
CmpRef.Trim( FALSE ); CmpRef.Trim( false );
/* Search the new component in list */ /* Search the new component in list */
BOOST_FOREACH( COMPONENT& component, m_components ) BOOST_FOREACH( COMPONENT & component, aComponentsList )
{ {
Cmp = &component; Cmp = &component;
if( Cmp->m_Reference == CmpRef ) if( Cmp->m_Reference == CmpRef )
break; break;
} }
...@@ -326,8 +319,8 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) ...@@ -326,8 +319,8 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
else if( Cmp ) else if( Cmp )
{ {
wxString fp = CONV_FROM_UTF8( Line + 1 ); wxString fp = CONV_FROM_UTF8( Line + 1 );
fp.Trim( FALSE ); fp.Trim( false );
fp.Trim( TRUE ); fp.Trim( true );
Cmp->m_FootprintFilter.Add( fp ); Cmp->m_FootprintFilter.Add( fp );
} }
} }
...@@ -336,20 +329,18 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) ...@@ -336,20 +329,18 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
} }
int ReadPinConnection( FILE* f, COMPONENT* Cmp ) int ReadPinConnection( FILE_LINE_READER& aNetlistReader, COMPONENT* Cmp )
{ {
int i, jj; int i, jj;
wxString numpin; char* Line = aNetlistReader;
wxString net; char cbuffer[BUFFER_CHAR_SIZE];
char Line[BUFFER_CHAR_SIZE + 1];
PIN* Pin = NULL;
for( ; ; ) for( ; ; )
{ {
/* Find beginning of description. */ /* Find beginning of description. */
for( ; ; ) for( ; ; )
{ {
if( fgets( Line, BUFFER_CHAR_SIZE, f ) == 0 ) if( aNetlistReader.ReadLine( ) == 0 )
return -1; return -1;
/* Remove blanks from the beginning of the line. */ /* Remove blanks from the beginning of the line. */
...@@ -370,31 +361,31 @@ int ReadPinConnection( FILE* f, COMPONENT* Cmp ) ...@@ -370,31 +361,31 @@ int ReadPinConnection( FILE* f, COMPONENT* Cmp )
if( Line[i] == ')' ) if( Line[i] == ')' )
return 0; return 0;
net.Empty(); PIN * Pin = new PIN();
numpin.Empty();
/* Read pin name, 4 letters */ /* Read pin name, usually 4 letters */
for( jj = 0; jj < 4; jj++, i++ ) for( jj = 0; ; i++ )
{ {
if( Line[i] == ' ' ) if( Line[i] == ' ' || Line[i] == 0 )
break; break;
numpin.Append( Line[i] ); cbuffer[jj++] = Line[i];
} }
cbuffer[jj] = 0;
Pin->m_Number = CONV_FROM_UTF8(cbuffer);
/* Read netname */ /* Read netname */
while( Line[i] == ' ' ) while( Line[i] == ' ' )
i++; i++;
for( ; ; i++ ) for( jj = 0; ; i++ )
{ {
if( Line[i] <= ' ' ) if( Line[i] == ' ' || Line[i] == '\n' || Line[i] == '\r' || Line[i] == 0 )
break; break;
net.Append( Line[i] ); cbuffer[jj++] = Line[i];
} }
cbuffer[jj] = 0;
Pin->m_Net = CONV_FROM_UTF8(cbuffer);
Pin = new PIN();
Pin->m_Number = numpin;
Pin->m_Net = net;
Cmp->m_Pins.push_back( Pin ); Cmp->m_Pins.push_back( Pin );
} }
} }
......
...@@ -159,20 +159,9 @@ void WinEDA_PcbFrame::PrepareLayerIndicator() ...@@ -159,20 +159,9 @@ void WinEDA_PcbFrame::PrepareLayerIndicator()
if( m_HToolBar ) if( m_HToolBar )
{ {
#if wxCHECK_VERSION( 2, 8, 3 ) & !defined(__WXX11__) m_HToolBar->SetToolBitmap( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR,
m_HToolBar->SetToolNormalBitmap( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR,
*LayerPairBitmap ); *LayerPairBitmap );
#else m_HToolBar->Realize();
int pos = m_HToolBar->GetToolPos( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR );
if( pos != wxNOT_FOUND )
{
m_HToolBar->DeleteTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR );
m_HToolBar->InsertTool( pos, ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR,
*LayerPairBitmap, wxNullBitmap, false,
NULL, SEL_LAYER_HELP );
m_HToolBar->Realize();
}
#endif
} }
} }
......
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