Commit 3a9f3f89 authored by Felix Morgner's avatar Felix Morgner

merge with upstream

parents 6c2c6477 4a9681d5
......@@ -168,7 +168,8 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent,
EDA_DRAW_FRAME::~EDA_DRAW_FRAME()
{
SAFE_DELETE( m_currentScreen );
delete m_currentScreen;
m_currentScreen = NULL;
m_auimgr.UnInit();
}
......
......@@ -165,7 +165,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
bool found = false;
m_ListCmp->SetSelection( ii++, true );
if( !component->GetFootprintLibName().IsEmpty() )
if( !component->GetFootprintName().IsEmpty() )
continue;
BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
......
......@@ -344,7 +344,7 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
for( unsigned jj = 0; jj < m_netlist.GetCount(); jj++ )
{
if( m_netlist.GetComponent( jj )->GetFootprintLibName().IsEmpty() && ii > selection )
if( m_netlist.GetComponent( jj )->GetFootprintName().IsEmpty() && ii > selection )
{
m_ListCmp->SetSelection( ii );
SendMessageToEESCHEMA();
......@@ -374,7 +374,7 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
for( unsigned kk = m_netlist.GetCount() - 1; kk >= 0; kk-- )
{
if( m_netlist.GetComponent( kk )->GetFootprintLibName().IsEmpty() && ii < selection )
if( m_netlist.GetComponent( kk )->GetFootprintName().IsEmpty() && ii < selection )
{
m_ListCmp->SetSelection( ii );
SendMessageToEESCHEMA();
......@@ -414,7 +414,7 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
m_netlist.GetComponent( i )->SetFootprintLibName( wxEmptyString );
m_netlist.GetComponent( i )->SetFootprintName( wxEmptyString );
SetNewPkg( wxEmptyString );
}
......@@ -568,7 +568,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
if( FindFocus() == m_ListCmp )
{
wxString module = m_netlist.GetComponent( selection )->GetFootprintLibName();
wxString module = m_netlist.GetComponent( selection )->GetFootprintName();
bool found = false;
for( int ii = 0; ii < m_FootprintList->GetCount(); ii++ )
......@@ -788,8 +788,8 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
// not the actual name of the footprint.
for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
{
if( m_netlist.GetComponent( ii )->GetFootprintLibName() == wxT( "$noname" ) )
m_netlist.GetComponent( ii )->SetFootprintLibName( wxEmptyString );
if( m_netlist.GetComponent( ii )->GetFootprintName() == wxT( "$noname" ) )
m_netlist.GetComponent( ii )->SetFootprintName( wxEmptyString );
}
// Sort components by reference:
......@@ -840,7 +840,7 @@ bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
retval |= fprintf( outputFile, "Reference = %s;\n", TO_UTF8( component->GetReference() ) );
retval |= fprintf( outputFile, "ValeurCmp = %s;\n", TO_UTF8( component->GetValue() ) );
retval |= fprintf( outputFile, "IdModule = %s;\n",
TO_UTF8( component->GetFootprintLibName() ) );
TO_UTF8( component->GetFootprintName() ) );
retval |= fprintf( outputFile, "EndCmp\n" );
}
......
......@@ -117,7 +117,7 @@ void CVPCB_MAINFRAME::BuildCmpListBox()
msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
GetChars( component->GetReference() ),
GetChars( component->GetValue() ),
GetChars( component->GetFootprintLibName() ) );
GetChars( component->GetFootprintName() ) );
m_ListCmp->m_ComponentList.Add( msg );
}
......
......@@ -71,16 +71,16 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
// Check to see if the component has already a footprint set.
hasFootprint = !(component->GetFootprintLibName().IsEmpty());
hasFootprint = !(component->GetFootprintName().IsEmpty());
component->SetFootprintLibName( aFootprintName );
component->SetFootprintName( aFootprintName );
// create the new component description
description.Printf( CMP_FORMAT, componentIndex + 1,
GetChars( component->GetReference() ),
GetChars( component->GetValue() ),
GetChars( component->GetFootprintLibName() ) );
GetChars( component->GetFootprintName() ) );
// If the component hasn't had a footprint associated with it
// it now has, so we decrement the count of components without
......@@ -135,10 +135,10 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
GetChars( component->GetReference() ),
GetChars( component->GetValue() ),
GetChars( component->GetFootprintLibName() ) );
GetChars( component->GetFootprintName() ) );
m_ListCmp->AppendLine( msg );
if( component->GetFootprintLibName().IsEmpty() )
if( component->GetFootprintName().IsEmpty() )
m_undefinedComponentCnt += 1;
}
......
......@@ -868,7 +868,7 @@ bool LIB_COMPONENT::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorM
{
aErrorMsg.Printf( wxT( "error <%s> in DRAW command %c" ),
GetChars( aErrorMsg ), line[0] );
SAFE_DELETE( newEntry );
delete newEntry;
// Flush till end of draw section
do
......@@ -913,7 +913,7 @@ bool LIB_COMPONENT::LoadField( LINE_READER& aLineReader, wxString& aErrorMsg )
if( !field->Load( aLineReader, aErrorMsg ) )
{
SAFE_DELETE( field );
delete field;
return false;
}
......@@ -931,7 +931,7 @@ bool LIB_COMPONENT::LoadField( LINE_READER& aLineReader, wxString& aErrorMsg )
if( field->GetId() == VALUE )
m_name = field->GetText();
SAFE_DELETE( field );
delete field;
}
else
{
......
......@@ -247,7 +247,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
wxStaticText* text = new wxStaticText( m_matrixPanel, -1, wxT( "W" ), pos );
int text_height = text->GetRect().GetHeight();
bitmap_size.y = std::max( bitmap_size.y, text_height );
SAFE_DELETE( text );
delete text;
// compute the Y pos interval:
pos.y = text_height;
......
......@@ -110,7 +110,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
if( textItem->GetText().IsEmpty() )
{
SAFE_DELETE( textItem );
delete textItem;
return NULL;
}
......
......@@ -293,7 +293,8 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew )
// Clear the screen before open a new file
if( g_RootSheet )
{
SAFE_DELETE( g_RootSheet );
delete g_RootSheet;
g_RootSheet = NULL;
}
CreateScreens();
......
......@@ -143,7 +143,8 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
// Delete previous library component, if any
if( m_component )
{
SAFE_DELETE( m_component );
delete m_component;
m_component = NULL;
m_aliasName.Empty();
}
......@@ -212,7 +213,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib
if( m_component )
{
SAFE_DELETE( m_component );
delete m_component;
m_aliasName.Empty();
}
......@@ -574,7 +575,8 @@ All changes will be lost. Discard changes?" ) ) )
}
else
{
SAFE_DELETE( m_component );
delete m_component;
m_component = NULL;
m_aliasName.Empty();
}
......@@ -660,7 +662,7 @@ lost!\n\nClear the current component from the screen?" ) ) )
if( m_component )
{
SAFE_DELETE( m_component );
delete m_component;
m_aliasName.Empty();
}
......
......@@ -232,7 +232,7 @@ again." );
if( !itemLoaded )
{
SAFE_DELETE( item );
delete item;
}
else
{
......
......@@ -274,10 +274,14 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle,
SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
{
SetScreen( NULL );
SAFE_DELETE( m_CurrentSheet ); // a SCH_SHEET_PATH, on the heap.
SAFE_DELETE( m_undoItem );
SAFE_DELETE( g_RootSheet );
SAFE_DELETE( m_findReplaceData );
delete m_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
delete m_undoItem;
delete g_RootSheet;
delete m_findReplaceData;
m_CurrentSheet = NULL;
m_undoItem = NULL;
g_RootSheet = NULL;
m_findReplaceData = NULL;
CMP_LIBRARY::RemoveAllLibraries();
}
......
......@@ -292,7 +292,7 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
if( item->IsNew() )
{
SAFE_DELETE( item );
delete item;
}
else if( item->IsMoving() || item->IsResized() )
{
......
......@@ -116,8 +116,6 @@ enum pseudokeys {
#define TEXT_ORIENT_HORIZ 0
#define TEXT_ORIENT_VERT 900
#define ON 1
#define OFF 0
//-----<KiROUND KIT>------------------------------------------------------------
......
......@@ -13,6 +13,8 @@
* converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
* wxstring is a wxString, not a wxT() or _(). The scope of the return value
* is very limited and volatile, but can be used with printf() style functions well.
* NOTE: Trying to convert it to a function is tricky because of the
* type of the parameter!
*/
#define TO_UTF8( wxstring ) ( (const char*) (wxstring).utf8_str() )
......@@ -20,7 +22,6 @@
* function FROM_UTF8
* converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
*/
//#define FROM_UTF8( cstring ) wxString::FromUTF8( cstring )
static inline wxString FROM_UTF8( const char* cstring )
{
wxString line = wxString::FromUTF8( cstring );
......@@ -56,82 +57,67 @@ static inline const wxChar* GetChars( const wxString& s )
#endif
}
#define NEGATE( x ) (x = -x)
// This really need a function? anyway is used *a lot* of times
template<class T> inline void NEGATE( T& x ) { x = -x; }
/// # of elements in an array
#define DIM( x ) unsigned( sizeof(x) / sizeof( (x)[0] ) ) // not size_t
inline double DEG2RAD( double deg ) { return deg * M_PI / 180.0; }
inline double RAD2DEG( double rad ) { return rad * 180.0 / M_PI; }
#define DEG2RAD( Deg ) ( (Deg) * M_PI / 180.0 )
#define RAD2DEG( Rad ) ( (Rad) * 180.0 / M_PI )
// Normalize angle to be in the -360.0 .. 360.0:
#define NORMALIZE_ANGLE_360( Angle ) { \
while( Angle < -3600 ) \
Angle += 3600; \
while( Angle > 3600 ) \
Angle -= 3600; }
/* Normalize angle to be in the 0.0 .. 360.0 range: */
#define NORMALIZE_ANGLE_POS( Angle ) { \
while( Angle < 0 ) \
Angle += 3600; \
while( Angle >= 3600 ) \
Angle -= 3600; }
#define NEGATE_AND_NORMALIZE_ANGLE_POS( Angle ) { \
Angle = -Angle; \
while( Angle < 0 ) \
Angle += 3600; \
while( Angle >= 3600 ) \
Angle -= 3600; }
/* Normalize angle to be in the -90.0 .. 90.0 range */
#define NORMALIZE_ANGLE_90( Angle ) { \
while( Angle < -900 ) \
Angle += 1800; \
while( Angle > 900 ) \
Angle -= 1800; }
/* Normalize angle to be in the -180.0 .. 180.0 range */
#define NORMALIZE_ANGLE_180( Angle ) { \
while( Angle <= -1800 ) \
Angle += 3600; \
while( Angle > 1800 ) \
Angle -= 3600; }
/*****************************/
/* macro to exchange 2 items */
/*****************************/
/*
* The EXCHG macro uses BOOST_TYPEOF for compilers that do not have native
* typeof support (MSVC). Please do not attempt to qualify these macros
* within #ifdef compiler definitions pragmas. BOOST_TYPEOF is smart enough
* to check for native typeof support and use it instead of it's own
* implementation. These macros effectively compile to nothing on platforms
* with native typeof support.
*/
/// Normalize angle to be in the -360.0 .. 360.0:
template<class T> inline void NORMALIZE_ANGLE_360( T& Angle )
{
while( Angle < -3600 )
Angle += 3600;
while( Angle > 3600 )
Angle -= 3600;
}
/// Normalize angle to be in the 0.0 .. 360.0 range:
template<class T> inline void NORMALIZE_ANGLE_POS( T& Angle )
{
while( Angle < 0 )
Angle += 3600;
while( Angle >= 3600 )
Angle -= 3600;
}
template<class T> inline void NEGATE_AND_NORMALIZE_ANGLE_POS( T& Angle )
{
Angle = -Angle;
while( Angle < 0 )
Angle += 3600;
while( Angle >= 3600 )
Angle -= 3600;
}
/// Normalize angle to be in the -90.0 .. 90.0 range
template<class T> inline void NORMALIZE_ANGLE_90( T& Angle )
{
while( Angle < -900 )
Angle += 1800;
while( Angle > 900 )
Angle -= 1800;
}
#include <boost/typeof/typeof.hpp>
// we have to register the types used with the typeof keyword with boost
BOOST_TYPEOF_REGISTER_TYPE( wxPoint )
BOOST_TYPEOF_REGISTER_TYPE( wxSize )
BOOST_TYPEOF_REGISTER_TYPE( wxString )
class DrawSheetLabelStruct;
BOOST_TYPEOF_REGISTER_TYPE( DrawSheetLabelStruct* )
class EDA_ITEM;
BOOST_TYPEOF_REGISTER_TYPE( EDA_ITEM* )
class D_PAD;
BOOST_TYPEOF_REGISTER_TYPE( D_PAD* )
BOOST_TYPEOF_REGISTER_TYPE( const D_PAD* )
class BOARD_ITEM;
BOOST_TYPEOF_REGISTER_TYPE( BOARD_ITEM* )
#define EXCHG( a, b ) { BOOST_TYPEOF( a ) __temp__ = (a); \
(a) = (b); \
(b) = __temp__; }
/// Normalize angle to be in the -180.0 .. 180.0 range
template<class T> inline void NORMALIZE_ANGLE_180( T& Angle )
{
while( Angle <= -1800 )
Angle += 3600;
while( Angle > 1800 )
Angle -= 3600;
}
/// Exchange two values; std::swap works only with arguments of the
// same type; here the compiler will figure out what to do (I hope)
template<class T, class T2> inline void EXCHG( T& a, T2& b )
{
T temp = a;
a = b;
b = temp;
}
#endif /* ifdef MACRO_H */
......@@ -51,11 +51,6 @@
#include <wx/overlay.h>
#endif
// C++ guarantees that operator delete checks its argument for null-ness
#ifndef SAFE_DELETE
#define SAFE_DELETE( p ) delete (p); (p) = NULL;
#endif
// Option for dialog boxes
#define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT | MAYBE_RESIZE_BORDER
......
......@@ -2373,7 +2373,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
msg.Printf( _( "Checking netlist component footprint \"%s:%s:%s\".\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ),
GetChars( component->GetFootprintLibName() ) );
GetChars( component->GetFootprintName() ) );
aReporter->Report( msg );
}
......@@ -2390,13 +2390,13 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
msg.Printf( _( "Adding new component \"%s:%s\" footprint \"%s\".\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ),
GetChars( component->GetFootprintLibName() ) );
GetChars( component->GetFootprintName() ) );
else
msg.Printf( _( "Cannot add new component \"%s:%s\" due to missing "
"footprint \"%s\".\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ),
GetChars( component->GetFootprintLibName() ) );
GetChars( component->GetFootprintName() ) );
aReporter->Report( msg );
}
......@@ -2414,8 +2414,8 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
else // An existing footprint.
{
// Test for footprint change.
if( !component->GetFootprintLibName().IsEmpty() &&
footprint->GetLibRef() != component->GetFootprintLibName() )
if( !component->GetFootprintName().IsEmpty() &&
footprint->GetLibRef() != component->GetFootprintName() )
{
if( aNetlist.GetReplaceFootprints() )
{
......@@ -2427,13 +2427,13 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
GetChars( footprint->GetReference() ),
GetChars( footprint->GetPath() ),
GetChars( footprint->GetLibRef() ),
GetChars( component->GetFootprintLibName() ) );
GetChars( component->GetFootprintName() ) );
else
msg.Printf( _( "Cannot replace component \"%s:%s\" due to missing "
"footprint \"%s\".\n" ),
GetChars( footprint->GetReference() ),
GetChars( footprint->GetPath() ),
GetChars( component->GetFootprintLibName() ) );
GetChars( component->GetFootprintName() ) );
aReporter->Report( msg );
}
......
......@@ -162,8 +162,6 @@ wxString SEGZONE::GetSelectMenuText() const
NETINFO_ITEM* net;
BOARD* board = GetBoard();
text << _( "Zone" ) << wxT( " " ) << wxString::Format( wxT( "(%08lX)" ), m_TimeStamp );
if( board )
{
net = board->FindNet( GetNet() );
......
......@@ -117,9 +117,9 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
m_ValueCtrl->SetValue( m_valueCopy->GetText() );
m_FootprintNameCtrl->SetValue( m_currentModule->GetLibRef() );
m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non smd components" ) );
m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non SMD components" ) );
m_AttributsCtrl->SetItemToolTip( 1,
_( "Use this attribute for smd components.\nOnly components with this option are put in the footprint position list file" ) );
_( "Use this attribute for SMD components.\nOnly components with this option are put in the footprint position list file" ) );
m_AttributsCtrl->SetItemToolTip( 2,
_( "Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) );
......
......@@ -440,9 +440,10 @@ void DIALOG_GENDRILL::GenDrillAndMapFiles(bool aGenDrill, bool aGenMap)
if( choice >= m_Choice_Drill_Map->GetCount() )
choice = 1;
fn.SetExt( wxEmptyString ); // Will be modified by GenDrillMap
fn.SetExt( wxEmptyString ); // Will be added by GenDrillMap
wxString fullfilename = fn.GetFullPath() + wxT( "-drl_map" );
GenDrillMap( fn.GetFullPath(), excellonWriter, filefmt[choice] );
GenDrillMap( fullfilename, excellonWriter, filefmt[choice] );
}
}
......@@ -530,7 +531,7 @@ void DIALOG_GENDRILL::OnGenReportFile( wxCommandEvent& event )
// Generate the drill map of the board
void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName,
void DIALOG_GENDRILL::GenDrillMap( const wxString aFullFileNameWithoutExt,
EXCELLON_WRITER& aExcellonWriter,
PlotFormat format )
{
......@@ -574,11 +575,9 @@ void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName,
return;
}
/* Init file name */
wxFileName fn = aFileName;
fn.SetName( fn.GetName() + wxT( "-drl_map" ) );
fn.SetExt( ext );
wxString fullFilename = fn.GetFullPath();
// Add file name extension
wxString fullFilename = aFullFileNameWithoutExt;
fullFilename << wxT(".") << ext;
bool success = aExcellonWriter.GenDrillMapFile( fullFilename,
m_parent->GetPageSettings(),
......
......@@ -98,6 +98,7 @@ DIALOG_NETLIST::DIALOG_NETLIST( PCB_EDIT_FRAME* aParent, wxDC * aDC,
GetSizer()->SetSizeHints( this );
}
void DIALOG_NETLIST::OnOpenNetlistClick( wxCommandEvent& event )
{
wxString lastPath = wxFileName::GetCwd();
......
......@@ -228,11 +228,12 @@ public: EXCELLON_WRITER( BOARD* aPcb, wxPoint aOffset )
/**
* Function GenDrillMapFile
* Plot a map of drill marks for holes.
* @param aFullFileName : the name of this file (to plot it)
* @param aFullFileNameWithoutExt : the full filename of the file to create,
* without extension (will be added accordint ti the format)
* @param aSheet : the paper sheet touse for plot
* @param aFormat : one of the supported plot formats (see enum PlotFormat )
*/
bool GenDrillMapFile( const wxString& aFullFileName,
bool GenDrillMapFile( const wxString& aFullFileNameWithoutExt,
const PAGE_INFO& aSheet,
PlotFormat aFormat );
private:
......
......@@ -283,12 +283,12 @@ void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR )
*/
wxString ref;
wxString value;
wxString componentName;
wxString libPartName;
wxString libName;
wxString footprintName;
wxString library;
wxString name;
wxString pathtimestamp, timestamp;
// The token comp was read, so the next data is (ref P1)
// The token comp was read, so the next data is (ref P1)
while( (token = NextTok()) != T_RIGHT )
{
if( token == T_LEFT )
......@@ -310,7 +310,7 @@ void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR )
case T_footprint:
NeedSYMBOLorNUMBER();
componentName = FROM_UTF8( CurText() );
footprintName = FROM_UTF8( CurText() );
NeedRIGHT();
break;
......@@ -324,13 +324,13 @@ void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR )
if( token == T_lib )
{
NeedSYMBOLorNUMBER();
libName = FROM_UTF8( CurText() );
library = FROM_UTF8( CurText() );
NeedRIGHT();
}
else if( token == T_part )
{
NeedSYMBOLorNUMBER();
libPartName = FROM_UTF8( CurText() );
name = FROM_UTF8( CurText() );
NeedRIGHT();
}
else
......@@ -362,8 +362,9 @@ void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR )
}
pathtimestamp += timestamp;
COMPONENT* component = new COMPONENT( componentName, ref, value, pathtimestamp );
component->SetLibrarySource( libName, libPartName );
COMPONENT* component = new COMPONENT( footprintName, ref, value, pathtimestamp );
component->SetName( name );
component->SetLibrary( library );
m_netlist->AddComponent( component );
}
......
......@@ -102,9 +102,10 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText ) throw( PARSE_ERRO
char* text;
wxString msg;
wxString timeStamp; // the full time stamp read from netlist
wxString name; // the component name read from netlist
wxString footprintName; // the footprint name read from netlist
wxString value; // the component value read from netlist
wxString reference; // the component schematic reference designator read from netlist
wxString name; // the name of component that was placed in the schematic
char line[1024];
strcpy( line, aText );
......@@ -126,12 +127,16 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText ) throw( PARSE_ERRO
// Read footprint name (second word)
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL )
{
msg = _( "Cannot parse name in component section of netlist." );
msg = _( "Cannot parse footprint name in component section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), aText, m_lineReader->LineNumber(),
m_lineReader->Length() );
}
name = FROM_UTF8( text );
footprintName = FROM_UTF8( text );
// The footprint name will have to be looked up in the *.cmp file.
if( footprintName == wxT( "$noname" ) )
footprintName = wxEmptyString;
// Read schematic reference designator (third word)
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL )
......@@ -153,7 +158,18 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText ) throw( PARSE_ERRO
value = FROM_UTF8( text );
COMPONENT* component = new COMPONENT( name, reference, value, timeStamp );
// Read component name (fifth word) {Lib=C}
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL )
{
msg = _( "Cannot parse name comment in component section of netlist." );
THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), aText, m_lineReader->LineNumber(),
m_lineReader->Length() );
}
name = FROM_UTF8( text ).AfterFirst( wxChar( '=' ) ).BeforeLast( wxChar( '}' ) );
COMPONENT* component = new COMPONENT( footprintName, reference, value, timeStamp );
component->SetName( name );
m_netlist->AddComponent( component );
return component;
}
......
......@@ -73,7 +73,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
}
catch( IO_ERROR& ioe )
{
msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
msg.Printf( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
return;
}
......@@ -160,15 +160,17 @@ MODULE* PCB_EDIT_FRAME::ListAndSelectModuleName()
void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
throw( IO_ERROR, PARSE_ERROR )
{
bool loadFootprint;
wxString msg;
wxString lastFootprintLibName;
COMPONENT* component;
MODULE* module;
MODULE* fpOnBoard;
if( aNetlist.IsEmpty() )
return;
aNetlist.SortByFootprintLibName();
aNetlist.SortByFootprintName();
wxString libPath;
wxFileName fn;
......@@ -179,8 +181,17 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
{
component = aNetlist.GetComponent( ii );
// @todo Check if component is already on BOARD and only load footprint if it's needed.
if( ii == 0 || component->GetFootprintLibName() != lastFootprintLibName )
// Check if component footprint is already on BOARD and only load the footprint from
// the library if it's needed.
if( aNetlist.IsFindByTimeStamp() )
fpOnBoard = m_Pcb->FindModule( aNetlist.GetComponent( ii )->GetTimeStamp(), true );
else
fpOnBoard = m_Pcb->FindModule( aNetlist.GetComponent( ii )->GetReference() );
loadFootprint = (fpOnBoard != NULL) &&
(fpOnBoard->GetPath() != component->GetFootprintName());
if( loadFootprint && (component->GetFootprintName() != lastFootprintLibName) )
{
module = NULL;
......@@ -194,11 +205,11 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
if( !libPath )
continue;
module = pi->FootprintLoad( libPath, component->GetFootprintLibName() );
module = pi->FootprintLoad( libPath, component->GetFootprintName() );
if( module )
{
lastFootprintLibName = component->GetFootprintLibName();
lastFootprintLibName = component->GetFootprintName();
break;
}
}
......@@ -211,7 +222,7 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
msg.Printf( _( "*** Warning: component `%s` footprint <%s> was not found in "
"any libraries. ***\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFootprintLibName() ) );
GetChars( component->GetFootprintName() ) );
aReporter->Report( msg );
}
......
......@@ -72,7 +72,7 @@ void COMPONENT::SetModule( MODULE* aModule )
aModule->SetReference( m_reference );
aModule->SetValue( m_value );
aModule->SetLibRef( m_footprintLibName );
aModule->SetLibRef( m_footprintName );
aModule->SetPath( m_timeStamp );
}
......@@ -98,9 +98,11 @@ void COMPONENT::Show( int aNestLevel, REPORTER& aReporter )
NestedSpace( aNestLevel, aReporter );
aReporter.Report( wxT( "<component>\n" ) );
NestedSpace( aNestLevel+1, aReporter );
aReporter.Report( wxString::Format( wxT( "<ref=%s value=%s name=%s fpid=%s timestamp=%s>\n" ),
aReporter.Report( wxString::Format( wxT( "<ref=%s value=%s name=%s library=%s footprint=%s "
"footprint-lib=%s timestamp=%s>\n" ),
GetChars( m_reference ), GetChars( m_value ),
GetChars( m_name ), GetChars( m_footprintLibName ),
GetChars( m_name ), GetChars( m_library ),
GetChars( m_footprintName ), GetChars( m_footprintLib ),
GetChars( m_timeStamp ) ) );
if( !m_footprintFilters.IsEmpty() )
......@@ -177,36 +179,19 @@ COMPONENT* NETLIST::GetComponentByTimeStamp( const wxString& aTimeStamp )
}
COMPONENT* NETLIST::GetComponentByLibName( const wxString& aLibName )
{
COMPONENT* component = NULL;
for( unsigned i = 0; i < m_components.size(); i++ )
{
if( m_components[i].GetLibName() == aLibName )
{
component = &m_components[i];
break;
}
}
return component;
}
/**
* Function SortByLibName
* Function ByFootprintName
* is a helper function used to sort the component list used by loadNewModules.
*/
static bool SortByLibName( const COMPONENT& ref, const COMPONENT& cmp )
static bool ByFootprintName( const COMPONENT& ref, const COMPONENT& cmp )
{
return ref.GetFootprintLibName().CmpNoCase( cmp.GetFootprintLibName() ) > 0;
return ref.GetFootprintName().CmpNoCase( cmp.GetFootprintName() ) > 0;
}
void NETLIST::SortByFootprintLibName()
void NETLIST::SortByFootprintName()
{
m_components.sort( SortByLibName );
m_components.sort( ByFootprintName );
}
......@@ -226,6 +211,42 @@ void NETLIST::SortByReference()
}
bool NETLIST::AnyFootprintsLinked() const
{
for( unsigned i = 0; i < m_components.size(); i++ )
{
if( !m_components[i].GetFootprintName().IsEmpty() )
return true;
}
return false;
}
bool NETLIST::AllFootprintsLinked() const
{
for( unsigned i = 0; i < m_components.size(); i++ )
{
if( m_components[i].GetFootprintName().IsEmpty() )
return false;
}
return true;
}
bool NETLIST::AnyFootprintsChanged() const
{
for( unsigned i = 0; i < m_components.size(); i++ )
{
if( m_components[i].FootprintChanged() )
return true;
}
return false;
}
#if defined( DEBUG )
void NETLIST::Show( int aNestLevel, REPORTER& aReporter )
{
......@@ -413,6 +434,6 @@ void CMP_READER::Load( NETLIST* aNetlist ) throw( IO_ERROR, PARSE_ERROR )
m_lineReader->LineNumber(), m_lineReader->Length() );
}
component->SetFootprintLibName( footprint );
component->SetFootprintName( footprint );
}
}
......@@ -30,7 +30,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <algorithm>
#include <boost/ptr_container/ptr_vector.hpp>
#include <fctsys.h>
......@@ -106,31 +105,46 @@ class COMPONENT
// ZZZ This timestamp is string, not time_t
wxString m_timeStamp; ///< The component full time stamp found in netlist.
wxString m_name; ///< The name of the component found in the netlist.
/// The name of the footprint in the library assigned to the component.
wxString m_footprintLibName;
/// The name of the component in #m_library used when it was placed on the schematic..
wxString m_name;
/// The lib part name used to look up the component library part information. This only has
/// meaning in the new s-expression netlist file format.
wxString m_libraryName;
wxString m_libraryPartName;
/**
* The name of the component library where #m_name was found. This will be set to
* wxEmptyString for legacy netlist files.
*/
wxString m_library;
/// The name of the footprint in the footprint library assigned to the component.
wxString m_footprintName;
/**
* The name of the footprint library that #m_footprintName is located. This will be
* set to wxEmptyString for legacy netlist formats indicating that all libraries need
* to be searched.
*/
wxString m_footprintLib;
/// The footprint loaded from the library for this component.
/// The #MODULE loaded for #m_footprintName found in #m_footprintLib.
std::auto_ptr< MODULE > m_footprint;
/// Set to true if #m_footprintName or #m_footprintLib was changed when the footprint
/// link file was read.
bool m_footprintChanged;
static COMPONENT_NET m_emptyNet;
public:
COMPONENT( const wxString& aName,
COMPONENT( const wxString& aFootprintName,
const wxString& aReference,
const wxString& aValue,
const wxString& aTimeStamp )
{
m_name = aName;
m_footprintName = aFootprintName;
m_reference = aReference;
m_value = aValue;
m_timeStamp = aTimeStamp;
m_footprintChanged = false;
}
virtual ~COMPONENT() { };
......@@ -148,27 +162,34 @@ public:
void SortPins() { sort( m_nets.begin(), m_nets.end() ); }
void SetName( const wxString& aName ) { m_name = aName;}
const wxString& GetName() const { return m_name; }
void SetLibrary( const wxString& aLibrary ) { m_library = aLibrary; }
const wxString& GetLibrary() const { return m_library; }
const wxString& GetReference() const { return m_reference; }
const wxString& GetValue() const { return m_value; }
void SetFootprintLibName( const wxString& aFootprintLibName )
void SetFootprintName( const wxString& aFootprintName )
{
m_footprintLibName = aFootprintLibName;
m_footprintChanged = !m_footprintName.IsEmpty() && (m_footprintName != aFootprintName);
m_footprintName = aFootprintName;
}
const wxString& GetFootprintLibName() const { return m_footprintLibName; }
const wxString& GetTimeStamp() const { return m_timeStamp; }
const wxString& GetLibName() const { return m_name; }
const wxString& GetFootprintName() const { return m_footprintName; }
void SetLibrarySource( const wxString& aLibName, const wxString& aCompName )
void SetFootprintLib( const wxString& aFootprintLib )
{
m_libraryName = aLibName;
m_libraryPartName = aCompName;
m_footprintChanged = !m_footprintLib.IsEmpty() && (m_footprintLib != aFootprintLib);
m_footprintLib = aFootprintLib;
}
const wxString& GetFootprintLib() const { return m_footprintLib; }
const wxString& GetTimeStamp() const { return m_timeStamp; }
void SetFootprintFilters( const wxArrayString& aFilterList )
{
m_footprintFilters = aFilterList;
......@@ -183,11 +204,13 @@ public:
void SetModule( MODULE* aModule );
bool IsLibSource( const wxString& aLibName, const wxString& aCompName ) const
bool IsLibSource( const wxString& aLibrary, const wxString& aName ) const
{
return aLibName == m_libraryName && aCompName == m_libraryPartName;
return aLibrary == m_library && aName == m_name;
}
bool FootprintChanged() const { return m_footprintChanged; }
#if defined(DEBUG)
/**
* Function Show
......@@ -293,16 +316,7 @@ public:
*/
COMPONENT* GetComponentByTimeStamp( const wxString& aTimeStamp );
/*
* Function GetComponentByLibName
* returns a #COMPONENT by \a aLibName.
*
* @param aLibName is the component library name of the #COMPONENT.
* @return a pointer to the #COMPONENT that matches \a aLibName if found. Otherwise NULL.
*/
COMPONENT* GetComponentByLibName( const wxString& aLibName );
void SortByFootprintLibName();
void SortByFootprintName();
void SortByReference();
......@@ -328,6 +342,31 @@ public:
bool GetReplaceFootprints() const { return m_replaceFootprints; }
/**
* Function AnyFootprintsLinked
* @return true if any component with a footprint link is found.
*/
bool AnyFootprintsLinked() const;
/**
* Function AllFootprintsLinked
* @return true if all components have a footprint link.
*/
bool AllFootprintsLinked() const;
/**
* Function NoFootprintsLinked
* @return true if none of the components have a footprint link.
*/
bool NoFootprintsLinked() const { return !AnyFootprintsLinked(); }
/**
* Function AnyFootprintsChanged
* @return true if any components footprints were changed when the footprint link file
* (*.cmp) was loaded.
*/
bool AnyFootprintsChanged() const;
#if defined(DEBUG)
/**
* Function Show
......
......@@ -320,7 +320,7 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
else // VIA_MICROVIA or VIA_BLIND_BURIED
{
LAYER_NUM topLayerNdx = UNDEFINED_LAYER;
LAYER_NUM botLayerNdx = 7000;
LAYER_NUM botLayerNdx = 7000; // Ask Dick if this number loses its magic
int viaDiam = -1;
for( int i=0; i<shapeCount; ++i )
......
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