Commit c2b600ce authored by stambaughw's avatar stambaughw

Replace wxList with boost::ptr_vector and fix automatic association bug in CVPCB.

* ALL: More changes for wxDC based zooming.
* 3D_VIEWER: Wrap 3d_viewer.h to prevent redefinitions.
* CVPcb: Replace wxList with boost::ptr_vector and take advantage of boost::foreach.
* CVPcb: Fix automatic association bug.
* CVPcb: Rename some variables for clarity and some minor code clean ups.
* CVPcb: Fix GTK sizing issue in library and path dialog.
* EESchema: Remove left over sizer from last commit from library and path dialog.
parent 7988f2ca
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: 3d_viewer.h // Name: 3d_viewer.h
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __3D_VIEWER_H__
#define __3D_VIEWER_H__
#if !wxUSE_GLCANVAS #if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h. #error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif #endif
...@@ -172,3 +176,5 @@ extern double g_Draw3d_dx, g_Draw3d_dy; ...@@ -172,3 +176,5 @@ extern double g_Draw3d_dx, g_Draw3d_dy;
extern double ZBottom, ZTop; extern double ZBottom, ZTop;
extern double DataScale3D; // coeff de conversion unites utilsateut -> unites 3D extern double DataScale3D; // coeff de conversion unites utilsateut -> unites 3D
extern int gl_attrib[]; extern int gl_attrib[];
#endif /* __3D_VIEWER_H__ */
...@@ -116,9 +116,9 @@ wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos ) ...@@ -116,9 +116,9 @@ wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
wxPoint curpos = ScreenPos; wxPoint curpos = ScreenPos;
Unscale( curpos ); Unscale( curpos );
#ifndef WX_ZOOM //#ifndef WX_ZOOM
curpos += m_DrawOrg; curpos += m_DrawOrg;
#endif //#endif
return curpos; return curpos;
} }
......
...@@ -590,8 +590,15 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -590,8 +590,15 @@ void WinEDA_DrawFrame::AdjustScrollBars()
#else #else
BASE_SCREEN* screen = GetBaseScreen(); BASE_SCREEN* screen = GetBaseScreen();
wxSize drawingSize = screen->ReturnPageSize() * 2; wxSize drawingSize = screen->ReturnPageSize() * 2;
DrawPanel->SetScrollbars( 1, 1, drawingSize.x, drawingSize.y, wxCoord x, y;
screen->m_Curseur.x, screen->m_Curseur.y, true ); wxClientDC DC( this );
DrawPanel->PrepareGraphicContext( &DC );
x = DC.LogicalToDeviceXRel( drawingSize.GetWidth() );
y = DC.LogicalToDeviceYRel( drawingSize.GetHeight() );
DrawPanel->SetScrollbars( 1, 1, x, y,
DC.LogicalToDeviceX( screen->m_Curseur.x ),
DC.LogicalToDeviceY( screen->m_Curseur.y ),
true );
#endif #endif
} }
......
...@@ -199,14 +199,12 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC ) ...@@ -199,14 +199,12 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
#ifdef WX_ZOOM #ifdef WX_ZOOM
double scale = GetScreen()->GetScalingFactor(); double scale = GetScreen()->GetScalingFactor();
wxPoint origin = GetScreen()->m_DrawOrg; wxPoint origin = GetScreen()->m_DrawOrg;
wxLogDebug( wxT( "DC user scale factor: %0.3f, X origin: %d, Y " \
"origin: %d" ), scale, origin.x, origin.y );
int ppuX, ppuY, startX, startY; int ppuX, ppuY, startX, startY;
GetScrollPixelsPerUnit(& ppuX, & ppuY); GetScrollPixelsPerUnit( & ppuX, & ppuY );
GetViewStart(& startX, & startY); GetViewStart( &startX, &startY );
DC->SetDeviceOrigin( origin.x - startX * ppuX, origin.y - startY * ppuY ); DC->SetDeviceOrigin( origin.x - startX * ppuX, origin.y - startY * ppuY );
DC->SetUserScale( scale, scale ); DC->SetUserScale( scale, scale );
wxSize size = GetScreen()->ReturnPageSize() * 2 * scale; // wxSize size = GetScreen()->ReturnPageSize() * 2 * scale;
// DC->SetLogicalOrigin( origin.x, origin.y ); // DC->SetLogicalOrigin( origin.x, origin.y );
#endif #endif
SetBoundaryBox(); SetBoundaryBox();
...@@ -368,12 +366,11 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void ) ...@@ -368,12 +366,11 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void )
GetScreen()->Unscale( realpos ); GetScreen()->Unscale( realpos );
#ifdef WX_ZOOM #ifdef WX_ZOOM
wxCoord x, y; // wxCoord x, y;
wxClientDC DC( this ); // wxClientDC DC( this );
PrepareGraphicContext( &DC ); // PrepareGraphicContext( &DC );
x = DC.DeviceToLogicalX( realpos.x ); // realpos.x = DC.DeviceToLogicalX( realpos.x );
y = DC.DeviceToLogicalY( realpos.y ); // realpos.y = DC.DeviceToLogicalY( realpos.y );
return wxPoint( x, y );
#else #else
realpos += GetScreen()->m_DrawOrg; realpos += GetScreen()->m_DrawOrg;
#endif #endif
......
...@@ -15,19 +15,21 @@ ...@@ -15,19 +15,21 @@
#include "protos.h" #include "protos.h"
#include "cvstruct.h" #include "cvstruct.h"
#define QUOTE '\'' #define QUOTE '\''
class AUTOMODULE class FOOTPRINT_ALIAS
{ {
public: public:
int m_Type; int m_Type;
AUTOMODULE* Pnext;
wxString m_Name; wxString m_Name;
wxString m_LibName; wxString m_FootprintName;
AUTOMODULE() { m_Type = 0; Pnext = NULL; } FOOTPRINT_ALIAS() { m_Type = 0; }
}; };
typedef boost::ptr_vector< FOOTPRINT_ALIAS > FOOTPRINT_ALIAS_LIST;
/* /*
* read the string between quotes and put it in aTarget * read the string between quotes and put it in aTarget
...@@ -68,18 +70,13 @@ char * ReadQuotedText(wxString & aTarget, char * aText) ...@@ -68,18 +70,13 @@ char * ReadQuotedText(wxString & aTarget, char * aText)
*/ */
void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event ) void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
{ {
COMPONENT_LIST::iterator iCmp; FOOTPRINT_ALIAS_LIST aliases;
FOOTPRINT_LIST::iterator iFp; FOOTPRINT_ALIAS* alias;
wxFileName fn; wxFileName fn;
wxString msg, tmp; wxString msg, tmp;
char Line[1024]; char Line[1024];
FILE* file; FILE* file;
AUTOMODULE* ItemModule, * NextMod; size_t ii;
AUTOMODULE* BaseListeMod = NULL;
COMPONENT* Component;
FOOTPRINT* footprint;
size_t ii;
int nb_correspondances = 0;
if( m_components.empty() ) if( m_components.empty() )
return; return;
...@@ -89,7 +86,6 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event ) ...@@ -89,7 +86,6 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
{ {
fn = m_AliasLibNames[ii]; fn = m_AliasLibNames[ii];
fn.SetExt( FootprintAliasFileExtension ); fn.SetExt( FootprintAliasFileExtension );
tmp = wxGetApp().FindLibraryPath( fn ); tmp = wxGetApp().FindLibraryPath( fn );
if( !tmp ) if( !tmp )
...@@ -101,6 +97,8 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event ) ...@@ -101,6 +97,8 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
continue; continue;
} }
wxLogDebug( wxT( "Opening footprint alias file: %s." ), tmp.c_str() );
file = wxFopen( tmp, wxT( "rt" ) ); file = wxFopen( tmp, wxT( "rt" ) );
if( file == NULL ) if( file == NULL )
...@@ -111,74 +109,72 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event ) ...@@ -111,74 +109,72 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
} }
/* lecture fichier n */ /* lecture fichier n */
while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL ) while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL )
{ {
char * text = Line; char* text = Line;
text = ReadQuotedText(tmp, text); wxString value, footprint;
text = ReadQuotedText( value, text );
if ( text == NULL || (*text == 0 ) ) if( text == NULL || ( *text == 0 ) || value.IsEmpty() )
continue; continue;
ItemModule = new AUTOMODULE(); text++;
ItemModule->Pnext = BaseListeMod; text = ReadQuotedText( footprint, text );
BaseListeMod = ItemModule;
/* stockage du composant ( 'namecmp' 'namelib') if( footprint.IsEmpty() )
* name et namelib */ continue;
ItemModule->m_Name = tmp;
alias = new FOOTPRINT_ALIAS();
alias->m_Name = value;
alias->m_FootprintName = footprint;
wxLogDebug( wxT( "Adding alias %s for footprint %s" ),
value.c_str(), footprint.c_str() );
aliases.push_back( alias );
text++; text++;
ReadQuotedText(ItemModule->m_LibName, text);
nb_correspondances++;
} }
fclose( file ); fclose( file );
} }
/* display some info */ /* Display the number of footpint aliases. */
msg.Printf( _( "%d equivalences" ), nb_correspondances ); msg.Printf( _( "%d footprint aliases found." ), aliases.size() );
SetStatusText( msg, 0 ); SetStatusText( msg, 0 );
wxMessageBox(msg);
for( iCmp = m_components.begin(); iCmp != m_components.end(); ++iCmp ) ii = 0;
BOOST_FOREACH( COMPONENT& component, m_components )
{ {
Component = *iCmp; m_ListCmp->SetSelection( ii, true );
m_ListCmp->SetSelection( m_components.IndexOf( Component ), TRUE );
if( !component.m_Module.IsEmpty() )
continue;
if( Component->m_Module.IsEmpty() ) BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
{ {
ItemModule = BaseListeMod; if( alias.m_Name.CmpNoCase( component.m_Value ) != 0 )
for( ; ItemModule != NULL; ItemModule = ItemModule->Pnext ) continue;
{
if( ItemModule->m_Name.CmpNoCase( Component->m_Valeur ) != 0 )
continue;
for( iFp = m_footprints.begin(); iFp != m_footprints.end(); ++iFp ) BOOST_FOREACH( FOOTPRINT& footprint, m_footprints )
{
if( alias.m_FootprintName.CmpNoCase( footprint.m_Module ) == 0 )
{ {
footprint = *iFp; SetNewPkg( footprint.m_Module );
break;
if( ItemModule->m_LibName.CmpNoCase( footprint->m_Module ) == 0 )
{
SetNewPkg( footprint->m_Module );
break;
}
} }
}
msg.Printf( _( "Component %s: Footprint %s not found in " \ if( component.m_Module.IsEmpty() )
"libraries" ), Component->m_Valeur.GetData(), {
ItemModule->m_LibName.GetData() ); msg.Printf( _( "Component %s: footprint %s not found in " \
DisplayError( this, msg, 10 ); "any of the project footprint libraries." ),
component.m_Reference.c_str(),
alias.m_FootprintName.c_str() );
wxMessageBox( msg, _( "CVPcb Error" ), wxOK | wxICON_ERROR,
this );
} }
} }
}
/* free memory: */ ii += 1;
for( ItemModule = BaseListeMod; ItemModule != NULL; ItemModule = NextMod )
{
NextMod = ItemModule->Pnext;
delete ItemModule;
} }
BaseListeMod = NULL;
} }
...@@ -10,37 +10,38 @@ ...@@ -10,37 +10,38 @@
#include <wx/listimpl.cpp> #include <wx/listimpl.cpp>
WX_DEFINE_LIST( PIN_LIST );
PIN::PIN() PIN::PIN()
{ {
m_Index = 0; /* variable utilisee selon types de netlistes */ m_Index = 0; /* variable utilisee selon types de netlistes */
m_PinType = 0; /* code type electrique ( Entree Sortie Passive..) */ m_Type = 0; /* code type electrique ( Entree Sortie Passive..) */
}
bool operator<( const PIN& item1, const PIN& item2 )
{
return ( StrLenNumICmp( item1.m_Number.GetData(),
item2.m_Number.GetData(), 4 ) < 0 );
} }
int compare( const PIN** item1, const PIN** item2 ) bool operator==( const PIN& item1, const PIN& item2 )
{ {
return StrLenNumICmp( (*item1)->m_PinNum.GetData(), return ( item1.m_Number == item2.m_Number );
(*item2)->m_PinNum.GetData(), 4 );
} }
bool same_pin_number( const PIN* item1, const PIN* item2 ) bool same_pin_number( const PIN* item1, const PIN* item2 )
{ {
wxASSERT( item1 != NULL && item2 != NULL ); wxASSERT( item1 != NULL && item2 != NULL );
return ( item1->m_PinNum == item2->m_PinNum ); return ( item1->m_Number == item2->m_Number );
} }
bool same_pin_net( const PIN* item1, const PIN* item2 ) bool same_pin_net( const PIN* item1, const PIN* item2 )
{ {
wxASSERT( item1 != NULL && item2 != NULL ); wxASSERT( item1 != NULL && item2 != NULL );
return ( item1->m_PinNet == item2->m_PinNet ); return ( item1->m_Net == item2->m_Net );
} }
WX_DEFINE_LIST( COMPONENT_LIST );
COMPONENT::COMPONENT() COMPONENT::COMPONENT()
{ {
m_Num = 0; m_Num = 0;
...@@ -49,26 +50,22 @@ COMPONENT::COMPONENT() ...@@ -49,26 +50,22 @@ COMPONENT::COMPONENT()
COMPONENT::~COMPONENT() COMPONENT::~COMPONENT()
{ {
m_Pins.DeleteContents( true );
m_Pins.Clear();
} }
int compare( const COMPONENT** item1, const COMPONENT** item2 ) bool operator<( const COMPONENT& item1, const COMPONENT& item2 )
{ {
return StrNumICmp( (*item1)->m_Reference.GetData(), return ( StrNumICmp( item1.m_Reference.GetData(),
(*item2)->m_Reference.GetData() ); item2.m_Reference.GetData() ) < 0 );
} }
WX_DEFINE_LIST( FOOTPRINT_LIST );
FOOTPRINT::FOOTPRINT() FOOTPRINT::FOOTPRINT()
{ {
m_Num = 0; m_Num = 0;
} }
int compare( const FOOTPRINT** item1, const FOOTPRINT** item2 ) bool operator<( const FOOTPRINT& item1, const FOOTPRINT& item2 )
{ {
return StrNumICmp( (*item1)->m_Module.GetData(), return ( StrNumICmp( item1.m_Module.GetData(),
(*item2)->m_Module.GetData() ); item2.m_Module.GetData() ) < 0 );
} }
...@@ -10,11 +10,9 @@ ...@@ -10,11 +10,9 @@
#include "gestfich.h" #include "gestfich.h"
#include "id.h" #include "id.h"
#include "param_config.h" #include "param_config.h"
#include "bitmaps.h"
#include "3d_viewer.h"
#include "cvpcb.h" #include "cvpcb.h"
#include "bitmaps.h"
#include "protos.h" #include "protos.h"
#include "cvstruct.h" #include "cvstruct.h"
#include "dialog_cvpcb_config.h" #include "dialog_cvpcb_config.h"
...@@ -157,8 +155,8 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, long style ) : ...@@ -157,8 +155,8 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, long style ) :
BuildCmpListBox(); BuildCmpListBox();
BuildFootprintListBox(); BuildFootprintListBox();
/* Creation des contraintes de dimension de la fenetre d'affichage des composants /* Creation des contraintes de dimension de la fenetre d'affichage des
* du schema */ * composants du schema */
wxLayoutConstraints* linkpos = new wxLayoutConstraints; wxLayoutConstraints* linkpos = new wxLayoutConstraints;
linkpos->top.SameAs( this, wxTop ); linkpos->top.SameAs( this, wxTop );
linkpos->bottom.SameAs( this, wxBottom ); linkpos->bottom.SameAs( this, wxBottom );
...@@ -167,8 +165,8 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, long style ) : ...@@ -167,8 +165,8 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, long style ) :
if( m_ListCmp ) if( m_ListCmp )
m_ListCmp->SetConstraints( linkpos ); m_ListCmp->SetConstraints( linkpos );
/* Creation des contraintes de dimension de la fenetre d'affichage des modules /* Creation des contraintes de dimension de la fenetre d'affichage des
* de la librairie */ * modules de la librairie */
linkpos = new wxLayoutConstraints; linkpos = new wxLayoutConstraints;
linkpos->top.SameAs( m_ListCmp, wxTop ); linkpos->top.SameAs( m_ListCmp, wxTop );
linkpos->bottom.SameAs( m_ListCmp, wxBottom ); linkpos->bottom.SameAs( m_ListCmp, wxBottom );
...@@ -197,11 +195,6 @@ WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame() ...@@ -197,11 +195,6 @@ WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame()
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ); ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST );
config->Write( wxT( FILTERFOOTPRINTKEY ), state ); config->Write( wxT( FILTERFOOTPRINTKEY ), state );
} }
m_footprints.DeleteContents( true );
m_footprints.Clear();
m_components.DeleteContents( true );
m_components.Clear();
} }
...@@ -268,7 +261,8 @@ void WinEDA_CvpcbFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -268,7 +261,8 @@ void WinEDA_CvpcbFrame::OnCloseWindow( wxCloseEvent& Event )
{ {
unsigned ii; unsigned ii;
wxMessageDialog dialog( this, wxMessageDialog dialog( this,
_( "Net and component list modified.\nSave before exit ?" ), _( "Net and component list modified.\nSave " \
"before exit ?" ),
_( "Confirmation" ), _( "Confirmation" ),
wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT ); wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT );
...@@ -332,8 +326,6 @@ void WinEDA_CvpcbFrame::OnChar( wxKeyEvent& event ) ...@@ -332,8 +326,6 @@ void WinEDA_CvpcbFrame::OnChar( wxKeyEvent& event )
void WinEDA_CvpcbFrame::ToFirstNA( wxCommandEvent& event ) void WinEDA_CvpcbFrame::ToFirstNA( wxCommandEvent& event )
/*******************************************************/ /*******************************************************/
{ {
COMPONENT_LIST::iterator i;
COMPONENT* Component;
int ii = 0; int ii = 0;
int selection; int selection;
...@@ -345,11 +337,9 @@ void WinEDA_CvpcbFrame::ToFirstNA( wxCommandEvent& event ) ...@@ -345,11 +337,9 @@ void WinEDA_CvpcbFrame::ToFirstNA( wxCommandEvent& event )
if( selection < 0 ) if( selection < 0 )
selection = 0; selection = 0;
for( i = m_components.begin(); i != m_components.end(); ++i ) BOOST_FOREACH( COMPONENT& component, m_components )
{ {
Component = *i; if( component.m_Module.IsEmpty() && ii > selection )
if( Component->m_Module.IsEmpty() && ii > selection )
{ {
m_ListCmp->SetSelection( ii ); m_ListCmp->SetSelection( ii );
return; return;
...@@ -367,8 +357,6 @@ void WinEDA_CvpcbFrame::ToFirstNA( wxCommandEvent& event ) ...@@ -367,8 +357,6 @@ void WinEDA_CvpcbFrame::ToFirstNA( wxCommandEvent& event )
void WinEDA_CvpcbFrame::ToPreviousNA( wxCommandEvent& event ) void WinEDA_CvpcbFrame::ToPreviousNA( wxCommandEvent& event )
/**********************************************************/ /**********************************************************/
{ {
COMPONENT_LIST::reverse_iterator i;
COMPONENT* Component;
int ii; int ii;
int selection; int selection;
...@@ -381,11 +369,9 @@ void WinEDA_CvpcbFrame::ToPreviousNA( wxCommandEvent& event ) ...@@ -381,11 +369,9 @@ void WinEDA_CvpcbFrame::ToPreviousNA( wxCommandEvent& event )
if( selection < 0 ) if( selection < 0 )
selection = m_ListCmp->GetCount() - 1; selection = m_ListCmp->GetCount() - 1;
for( i = m_components.rbegin(); i != m_components.rend(); ++i ) BOOST_REVERSE_FOREACH( COMPONENT& component, m_components )
{ {
Component = *i; if( component.m_Module.IsEmpty() && ii < selection )
if( Component->m_Module.IsEmpty() && ii < selection )
{ {
m_ListCmp->SetSelection( ii ); m_ListCmp->SetSelection( ii );
return; return;
...@@ -418,25 +404,24 @@ void WinEDA_CvpcbFrame::DelAssociations( wxCommandEvent& event ) ...@@ -418,25 +404,24 @@ void WinEDA_CvpcbFrame::DelAssociations( wxCommandEvent& event )
/* Supprime toutes les associations deja faites /* Supprime toutes les associations deja faites
*/ */
{ {
COMPONENT_LIST::iterator i;
COMPONENT* Component;
wxString Line; wxString Line;
if( IsOK( this, _( "Delete selections" ) ) ) if( IsOK( this, _( "Delete selections" ) ) )
{ {
for( i = m_components.begin(); i != m_components.end(); ++i ) m_ListCmp->SetSelection( 0 );
BOOST_FOREACH( COMPONENT& component, m_components )
{ {
Component = *i; component.m_Module.Empty();
Component->m_Module.Empty();
SetNewPkg( wxEmptyString ); SetNewPkg( wxEmptyString );
} }
m_ListCmp->SetSelection( 0 ); m_ListCmp->SetSelection( 0 );
m_undefinedComponentCnt = m_components.GetCount(); m_undefinedComponentCnt = m_components.size();
} }
Line.Printf( _( "Components: %d (free: %d)" ), m_components.GetCount(), Line.Printf( _( "Components: %d (free: %d)" ), m_components.size(),
m_components.GetCount() ); m_components.size() );
SetStatusText( Line, 1 ); SetStatusText( Line, 1 );
} }
...@@ -568,7 +553,6 @@ void WinEDA_CvpcbFrame::OnLeftDClick( wxListEvent& event ) ...@@ -568,7 +553,6 @@ void WinEDA_CvpcbFrame::OnLeftDClick( wxListEvent& event )
void WinEDA_CvpcbFrame::OnSelectComponent( wxListEvent& event ) void WinEDA_CvpcbFrame::OnSelectComponent( wxListEvent& event )
/*************************************************************/ /*************************************************************/
{ {
COMPONENT* Component;
int selection; int selection;
if( !m_HToolBar->GetToolState( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) ) if( !m_HToolBar->GetToolState( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) )
...@@ -584,15 +568,14 @@ void WinEDA_CvpcbFrame::OnSelectComponent( wxListEvent& event ) ...@@ -584,15 +568,14 @@ void WinEDA_CvpcbFrame::OnSelectComponent( wxListEvent& event )
return; return;
} }
Component = m_components[ selection ]; if( &m_components[ selection ] == NULL )
if( Component == NULL )
{ {
m_FootprintList->SetActiveFootprintList( TRUE, TRUE ); m_FootprintList->SetActiveFootprintList( TRUE, TRUE );
return; return;
} }
m_FootprintList->SetFootprintFilteredList( Component, m_footprints ); m_FootprintList->SetFootprintFilteredList( &m_components[ selection ],
m_footprints );
} }
......
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
#include "pcbcommon.h" #include "pcbcommon.h"
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/foreach.hpp>
// config for footprints doc file acces // config for footprints doc file acces
#define DEFAULT_FOOTPRINTS_LIST_FILENAME wxT( "footprints_doc/footprints.pdf" ) #define DEFAULT_FOOTPRINTS_LIST_FILENAME wxT( "footprints_doc/footprints.pdf" )
...@@ -27,21 +31,23 @@ class PIN ...@@ -27,21 +31,23 @@ class PIN
{ {
public: public:
int m_Index; /* variable utilisee selon types de netlistes */ int m_Index; /* variable utilisee selon types de netlistes */
int m_PinType; /* code type electrique ( Entree Sortie Passive..) */ int m_Type; /* code type electrique ( Entree Sortie Passive..) */
wxString m_PinNet; /* Pointeur sur le texte nom de net */ wxString m_Net; /* Pointeur sur le texte nom de net */
wxString m_PinNum; wxString m_Number;
wxString m_PinName; wxString m_Name;
wxString m_Repere; /* utilise selon formats de netliste */ wxString m_Repere; /* utilise selon formats de netliste */
PIN(); PIN();
}; };
WX_DECLARE_LIST( PIN, PIN_LIST ); typedef boost::ptr_vector< PIN > PIN_LIST;
/* PIN object list sort function. */ /* PIN object list sort function. */
extern int compare( const PIN** item1, const PIN** item2 ); extern bool operator<( const PIN& item1, const PIN& item2 );
/* PIN uniqueness test function. */
extern bool operator==( const PIN& item1, const PIN& item2 );
/* PIN object comparison functions. */
extern bool same_pin_number( const PIN* item1, const PIN* item2 ); extern bool same_pin_number( const PIN* item1, const PIN* item2 );
extern bool same_pin_net( const PIN* item1, const PIN* item2 ); extern bool same_pin_net( const PIN* item1, const PIN* item2 );
...@@ -49,25 +55,25 @@ extern bool same_pin_net( const PIN* item1, const PIN* item2 ); ...@@ -49,25 +55,25 @@ extern bool same_pin_net( const PIN* item1, const PIN* item2 );
class COMPONENT class COMPONENT
{ {
public: public:
int m_Num; /* Numero d'ordre */ int m_Num; /* Numero d'ordre */
int m_Multi; /* Nombre d' unites par boitier */ int m_Multi; /* Nombre d' unites par boitier */
PIN_LIST m_Pins; /* pointeur sur la liste des Pins */ PIN_LIST m_Pins; /* pointeur sur la liste des Pins */
wxString m_Reference; /* U3, R5 ... */ wxString m_Reference; /* U3, R5 ... */
wxString m_Valeur; /* 7400, 47K ... */ wxString m_Value; /* 7400, 47K ... */
wxString m_TimeStamp; /* Signature temporelle ("00000000" si absente) */ wxString m_TimeStamp; /* Signature temporelle ("00000000" si absente) */
wxString m_Module; /* Nom du module (Package) corresp */ wxString m_Module; /* Nom du module (Package) corresp */
wxString m_Repere; /* utilise selon formats de netliste */ wxString m_Repere; /* utilise selon formats de netliste */
wxArrayString m_FootprintFilter; /* List of allowed footprints (wildcart allowed wxArrayString m_FootprintFilter; /* List of allowed footprints (wildcards
* if void: no filtering */ * allowed ). If empty: no filtering */
COMPONENT(); COMPONENT();
~COMPONENT(); ~COMPONENT();
}; };
WX_DECLARE_LIST( COMPONENT, COMPONENT_LIST ); typedef boost::ptr_vector< COMPONENT > COMPONENT_LIST;
/* COMPONENT object list sort function. */ /* COMPONENT object list sort function. */
extern int compare( const COMPONENT** item1, const COMPONENT** item2 ); extern bool operator<( const COMPONENT& item1, const COMPONENT& item2 );
class FOOTPRINT class FOOTPRINT
...@@ -82,10 +88,10 @@ public: ...@@ -82,10 +88,10 @@ public:
FOOTPRINT(); FOOTPRINT();
}; };
WX_DECLARE_LIST( FOOTPRINT, FOOTPRINT_LIST ); typedef boost::ptr_vector< FOOTPRINT > FOOTPRINT_LIST;
/* FOOTPRINT object list sort function. */ /* FOOTPRINT object list sort function. */
extern int compare( const FOOTPRINT** item1, const FOOTPRINT** item2 ); extern bool operator<( const FOOTPRINT& item1, const FOOTPRINT& item2 );
/* Gestion des noms des librairies */ /* Gestion des noms des librairies */
extern const wxString FootprintAliasFileExtension; extern const wxString FootprintAliasFileExtension;
......
...@@ -21,7 +21,7 @@ DIALOG_CVPCB_CONFIG_FBP::DIALOG_CVPCB_CONFIG_FBP( wxWindow* parent, wxWindowID i ...@@ -21,7 +21,7 @@ DIALOG_CVPCB_CONFIG_FBP::DIALOG_CVPCB_CONFIG_FBP( wxWindow* parent, wxWindowID i
m_ListLibr = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE ); m_ListLibr = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
m_ListLibr->SetToolTip( _("List of active library files.\nOnly library files in this list are loaded by Pcbnew.\nThe order of this list is important:\nPcbnew searchs for a given footprint using this list order priority.") ); m_ListLibr->SetToolTip( _("List of active library files.\nOnly library files in this list are loaded by Pcbnew.\nThe order of this list is important:\nPcbnew searchs for a given footprint using this list order priority.") );
m_ListLibr->SetMinSize( wxSize( 450,-1 ) ); m_ListLibr->SetMinSize( wxSize( 450,90 ) );
sbLibsChoiceSizer->Add( m_ListLibr, 1, wxALL|wxEXPAND, 5 ); sbLibsChoiceSizer->Add( m_ListLibr, 1, wxALL|wxEXPAND, 5 );
...@@ -45,7 +45,7 @@ DIALOG_CVPCB_CONFIG_FBP::DIALOG_CVPCB_CONFIG_FBP( wxWindow* parent, wxWindowID i ...@@ -45,7 +45,7 @@ DIALOG_CVPCB_CONFIG_FBP::DIALOG_CVPCB_CONFIG_FBP( wxWindow* parent, wxWindowID i
sbLibsChoiceSizer->Add( bSizerLibButtons, 0, wxALIGN_CENTER_VERTICAL, 5 ); sbLibsChoiceSizer->Add( bSizerLibButtons, 0, wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( sbLibsChoiceSizer, 0, wxALL|wxEXPAND, 5 ); bMainSizer->Add( sbLibsChoiceSizer, 1, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbEquivChoiceSizer; wxStaticBoxSizer* sbEquivChoiceSizer;
sbEquivChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Footprint alias files") ), wxHORIZONTAL ); sbEquivChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Footprint alias files") ), wxHORIZONTAL );
......
...@@ -78,8 +78,8 @@ ...@@ -78,8 +78,8 @@
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="0"> <object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Footprint library files</property> <property name="label">Footprint library files</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="maximum_size">-1,-1</property> <property name="maximum_size">-1,-1</property>
<property name="minimum_size">450,-1</property> <property name="minimum_size">450,90</property>
<property name="name">m_ListLibr</property> <property name="name">m_ListLibr</property>
<property name="permission">protected</property> <property name="permission">protected</property>
<property name="pos"></property> <property name="pos"></property>
......
...@@ -10,13 +10,19 @@ ...@@ -10,13 +10,19 @@
#include "confirm.h" #include "confirm.h"
#include "macros.h" #include "macros.h"
#include "3d_viewer.h"
#include "cvpcb.h" #include "cvpcb.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "protos.h" #include "protos.h"
#include "cvstruct.h" #include "cvstruct.h"
/*
* NOTE: There is something in 3d_viewer.h that causes a compiler error in
* <boost/foreach.hpp> in Linux so move it after cvpcb.h where it is
* included to prevent the error from occuring.
*/
#include "3d_viewer.h"
/*****************************************************************/ /*****************************************************************/
/* Construction de la table des evenements pour WinEDA_DrawFrame */ /* Construction de la table des evenements pour WinEDA_DrawFrame */
......
...@@ -17,13 +17,11 @@ ...@@ -17,13 +17,11 @@
void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event ) void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event )
{ {
COMPONENT_LIST::iterator i;
FILE* FileEquiv; FILE* FileEquiv;
COMPONENT* Cmp;
wxString Line; wxString Line;
wxFileName fn = m_NetlistFileName; wxFileName fn = m_NetlistFileName;
if( m_components.GetCount() <= 0 ) if( m_components.empty() )
return; return;
/* calcul du nom du fichier */ /* calcul du nom du fichier */
...@@ -46,16 +44,14 @@ void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event ) ...@@ -46,16 +44,14 @@ void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event )
} }
/* Generation de la liste */ /* Generation de la liste */
for( i = m_components.begin(); i != m_components.end(); ++i ) BOOST_FOREACH( COMPONENT& component, m_components )
{ {
Cmp = *i;
/* gnration du composant si son empreinte est dfinie */ /* gnration du composant si son empreinte est dfinie */
if( Cmp->m_Module.IsEmpty() ) if( component.m_Module.empty() )
continue; continue;
fprintf( FileEquiv, "comp = \"%s\" module = \"%s\"\n", fprintf( FileEquiv, "comp = \"%s\" module = \"%s\"\n",
CONV_TO_UTF8( Cmp->m_Reference ), CONV_TO_UTF8( component.m_Reference ),
CONV_TO_UTF8( Cmp->m_Module ) ); CONV_TO_UTF8( component.m_Module ) );
} }
fclose( FileEquiv ); fclose( FileEquiv );
......
...@@ -53,7 +53,7 @@ int genorcad( bool rightJustify ) ...@@ -53,7 +53,7 @@ int genorcad( bool rightJustify )
fprintf( dest, " %s ", CONV_TO_UTF8( CurrentCmp->m_Reference ) ); fprintf( dest, " %s ", CONV_TO_UTF8( CurrentCmp->m_Reference ) );
/* placement de la valeur */ /* placement de la valeur */
fprintf( dest, "%s\n", CONV_TO_UTF8( CurrentCmp->m_Valeur ) ); fprintf( dest, "%s\n", CONV_TO_UTF8( CurrentCmp->m_Value ) );
/* Tri des pins */ /* Tri des pins */
TriPinsModule( CurrentCmp ); TriPinsModule( CurrentCmp );
...@@ -140,7 +140,7 @@ static void TriPinsModule( COMPONENT* CurrentCmp ) ...@@ -140,7 +140,7 @@ static void TriPinsModule( COMPONENT* CurrentCmp )
wxString msg; wxString msg;
msg.Printf( _( "%s %s pin %s : Different Nets" ), msg.Printf( _( "%s %s pin %s : Different Nets" ),
CurrentCmp->m_Reference.GetData(), CurrentCmp->m_Reference.GetData(),
CurrentCmp->m_Valeur.GetData(), CurrentCmp->m_Value.GetData(),
Pin->m_PinNum.GetData() ); Pin->m_PinNum.GetData() );
DisplayError( NULL, msg, 60 ); DisplayError( NULL, msg, 60 );
} }
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
*/ */
void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
{ {
COMPONENT_LIST::iterator i;
COMPONENT* Component; COMPONENT* Component;
bool isUndefined = false; bool isUndefined = false;
int NumCmp; int NumCmp;
...@@ -38,10 +37,10 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) ...@@ -38,10 +37,10 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
if( NumCmp < 0 ) if( NumCmp < 0 )
{ {
NumCmp = 0; NumCmp = 0;
m_ListCmp->SetSelection( NumCmp, TRUE ); m_ListCmp->SetSelection( NumCmp, true );
} }
Component = m_components[ NumCmp ]; Component = &m_components[ NumCmp ];
if( Component == NULL ) if( Component == NULL )
return; return;
...@@ -51,7 +50,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) ...@@ -51,7 +50,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
Component->m_Module = package; Component->m_Module = package;
Line.Printf( CMP_FORMAT, NumCmp + 1, Line.Printf( CMP_FORMAT, NumCmp + 1,
Component->m_Reference.GetData(), Component->m_Valeur.GetData(), Component->m_Reference.GetData(), Component->m_Value.GetData(),
Component->m_Module.GetData() ); Component->m_Module.GetData() );
m_modified = true; m_modified = true;
...@@ -67,7 +66,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) ...@@ -67,7 +66,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
m_ListCmp->SetSelection( NumCmp, TRUE ); m_ListCmp->SetSelection( NumCmp, TRUE );
Line.Printf( _( "Components: %d (free: %d)" ), Line.Printf( _( "Components: %d (free: %d)" ),
m_components.GetCount(), m_undefinedComponentCnt ); m_components.size(), m_undefinedComponentCnt );
SetStatusText( Line, 1 ); SetStatusText( Line, 1 );
} }
...@@ -78,8 +77,6 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) ...@@ -78,8 +77,6 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
*/ */
bool WinEDA_CvpcbFrame::ReadNetList() bool WinEDA_CvpcbFrame::ReadNetList()
{ {
COMPONENT_LIST::iterator i;
COMPONENT* Component;
wxString msg; wxString msg;
int error_level; int error_level;
...@@ -105,24 +102,23 @@ bool WinEDA_CvpcbFrame::ReadNetList() ...@@ -105,24 +102,23 @@ bool WinEDA_CvpcbFrame::ReadNetList()
BuildFootprintListBox(); BuildFootprintListBox();
m_ListCmp->Clear(); m_ListCmp->Clear();
m_undefinedComponentCnt = 0; m_undefinedComponentCnt = 0;
for( i = m_components.begin(); i != m_components.end(); ++i )
BOOST_FOREACH( COMPONENT& component, m_components )
{ {
Component = *i;
msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1, msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
Component->m_Reference.GetData(), component.m_Reference.GetData(),
Component->m_Valeur.GetData(), component.m_Value.GetData(),
Component->m_Module.GetData() ); component.m_Module.GetData() );
m_ListCmp->AppendLine( msg ); m_ListCmp->AppendLine( msg );
if( Component->m_Module.IsEmpty() ) if( component.m_Module.IsEmpty() )
m_undefinedComponentCnt += 1; m_undefinedComponentCnt += 1;
} }
if( !m_components.empty() ) if( !m_components.empty() )
m_ListCmp->SetSelection( 0, TRUE ); m_ListCmp->SetSelection( 0, TRUE );
msg.Printf( _( "Components: %d (free: %d)" ), m_components.GetCount(), msg.Printf( _( "Components: %d (free: %d)" ), m_components.size(),
m_undefinedComponentCnt ); m_undefinedComponentCnt );
SetStatusText( msg, 1 ); SetStatusText( msg, 1 );
......
This diff is collapsed.
...@@ -48,9 +48,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames, ...@@ -48,9 +48,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames,
if( !list.empty() ) if( !list.empty() )
{ {
list.DeleteContents( true ); list.clear();
list.Clear();
list.DeleteContents( false );
} }
if( libNames.GetCount() == 0 ) if( libNames.GetCount() == 0 )
...@@ -138,7 +136,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames, ...@@ -138,7 +136,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames,
ReadDocLib( tmp, list ); ReadDocLib( tmp, list );
} }
list.Sort( compare ); list.sort();
return true; return true;
} }
...@@ -151,13 +149,11 @@ bool LoadFootprintFiles( const wxArrayString& libNames, ...@@ -151,13 +149,11 @@ bool LoadFootprintFiles( const wxArrayString& libNames,
static void ReadDocLib( const wxString& ModLibName, FOOTPRINT_LIST& list ) static void ReadDocLib( const wxString& ModLibName, FOOTPRINT_LIST& list )
{ {
FOOTPRINT* NewMod; FOOTPRINT* NewMod;
FOOTPRINT* tmp;
char Line[1024]; char Line[1024];
wxString ModuleName; wxString ModuleName;
wxString msg; wxString msg;
FILE* LibDoc; FILE* LibDoc;
wxFileName fn = ModLibName; wxFileName fn = ModLibName;
FOOTPRINT_LIST::iterator i;
fn.SetExt( wxT( "mdc" ) ); fn.SetExt( wxT( "mdc" ) );
...@@ -196,13 +192,11 @@ static void ReadDocLib( const wxString& ModLibName, FOOTPRINT_LIST& list ) ...@@ -196,13 +192,11 @@ static void ReadDocLib( const wxString& ModLibName, FOOTPRINT_LIST& list )
{ {
case 'L': /* LibName */ case 'L': /* LibName */
ModuleName = CONV_FROM_UTF8( StrPurge( Line + 3 ) ); ModuleName = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
for( i = list.begin(); i != list.end(); ++i ) BOOST_FOREACH( FOOTPRINT& footprint, list )
{ {
tmp = *i; if( ModuleName == footprint.m_Module )
if( ModuleName == tmp->m_Module )
{ {
NewMod = tmp; NewMod = &footprint;
break; break;
} }
} }
......
...@@ -103,9 +103,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -103,9 +103,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
/* Clear components buffer */ /* Clear components buffer */
if( !m_components.empty() ) if( !m_components.empty() )
{ {
m_components.DeleteContents( true ); m_components.clear();
m_components.Clear();
m_components.DeleteContents( false );
} }
source = wxFopen( m_NetlistFileName.GetFullPath(), wxT( "rt" ) ); source = wxFopen( m_NetlistFileName.GetFullPath(), wxT( "rt" ) );
...@@ -257,7 +255,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -257,7 +255,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
/* Store info for this component */ /* Store info for this component */
Cmp = new COMPONENT(); Cmp = new COMPONENT();
Cmp->m_Reference = component_reference; Cmp->m_Reference = component_reference;
Cmp->m_Valeur = component_value; 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: */
...@@ -278,7 +276,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -278,7 +276,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
fclose( source ); fclose( source );
m_components.Sort( compare ); m_components.sort();
return 0; return 0;
} }
...@@ -286,7 +284,6 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -286,7 +284,6 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
{ {
COMPONENT_LIST::iterator i;
char Line[BUFFER_CHAR_SIZE + 1]; char Line[BUFFER_CHAR_SIZE + 1];
wxString CmpRef; wxString CmpRef;
COMPONENT* Cmp = NULL; COMPONENT* Cmp = NULL;
...@@ -310,9 +307,9 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) ...@@ -310,9 +307,9 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
CmpRef.Trim( FALSE ); CmpRef.Trim( FALSE );
/* Search the new component in list */ /* Search the new component in list */
for( i = m_components.begin(); i != m_components.end(); ++i ) BOOST_FOREACH( COMPONENT& component, m_components )
{ {
Cmp = *i; Cmp = &component;
if( Cmp->m_Reference == CmpRef ) if( Cmp->m_Reference == CmpRef )
break; break;
...@@ -388,8 +385,8 @@ int ReadPinConnection( FILE* f, COMPONENT* Cmp ) ...@@ -388,8 +385,8 @@ int ReadPinConnection( FILE* f, COMPONENT* Cmp )
} }
Pin = new PIN(); Pin = new PIN();
Pin->m_PinNum = numpin; Pin->m_Number = numpin;
Pin->m_PinNet = net; Pin->m_Net = net;
Cmp->m_Pins.push_back( Pin ); Cmp->m_Pins.push_back( Pin );
} }
} }
......
...@@ -31,8 +31,6 @@ const wxString titleComponentLibErr( _( "Component Library Error" ) ); ...@@ -31,8 +31,6 @@ const wxString titleComponentLibErr( _( "Component Library Error" ) );
*/ */
int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName ) int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName )
{ {
COMPONENT_LIST::iterator i;
COMPONENT* Cmp;
FILE* dest; FILE* dest;
wxFileName fn( NetlistFullFileName ); wxFileName fn( NetlistFullFileName );
char Line[1024]; char Line[1024];
...@@ -49,14 +47,17 @@ int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName ) ...@@ -49,14 +47,17 @@ int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName )
fprintf( dest, " Created by %s", CONV_TO_UTF8( Title ) ); fprintf( dest, " Created by %s", CONV_TO_UTF8( Title ) );
fprintf( dest, " date = %s\n", DateAndTime( Line ) ); fprintf( dest, " date = %s\n", DateAndTime( Line ) );
for( i = m_components.begin(); i != m_components.end(); ++i ) BOOST_FOREACH( COMPONENT& component, m_components )
{ {
Cmp = *i;
fprintf( dest, "\nBeginCmp\n" ); fprintf( dest, "\nBeginCmp\n" );
fprintf( dest, "TimeStamp = %s;\n", CONV_TO_UTF8( Cmp->m_TimeStamp ) ); fprintf( dest, "TimeStamp = %s;\n",
fprintf( dest, "Reference = %s;\n", CONV_TO_UTF8( Cmp->m_Reference ) ); CONV_TO_UTF8( component.m_TimeStamp ) );
fprintf( dest, "ValeurCmp = %s;\n", CONV_TO_UTF8( Cmp->m_Valeur ) ); fprintf( dest, "Reference = %s;\n",
fprintf( dest, "IdModule = %s;\n", CONV_TO_UTF8( Cmp->m_Module ) ); CONV_TO_UTF8( component.m_Reference ) );
fprintf( dest, "ValeurCmp = %s;\n",
CONV_TO_UTF8( component.m_Value ) );
fprintf( dest, "IdModule = %s;\n",
CONV_TO_UTF8( component.m_Module ) );
fprintf( dest, "EndCmp\n" ); fprintf( dest, "EndCmp\n" );
} }
...@@ -71,10 +72,8 @@ int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName ) ...@@ -71,10 +72,8 @@ int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName )
*/ */
bool LoadComponentFile( const wxString& fileName, COMPONENT_LIST& list ) bool LoadComponentFile( const wxString& fileName, COMPONENT_LIST& list )
{ {
COMPONENT_LIST::iterator i;
wxString timestamp, valeur, ilib, namecmp, msg; wxString timestamp, valeur, ilib, namecmp, msg;
bool read_cmp_data = FALSE, eof = FALSE; bool read_cmp_data = FALSE, eof = FALSE;
COMPONENT* Cmp;
char Line[1024], * ident, * data; char Line[1024], * ident, * data;
FILE* source; FILE* source;
wxFileName fn = fileName; wxFileName fn = fileName;
...@@ -176,15 +175,13 @@ bool LoadComponentFile( const wxString& fileName, COMPONENT_LIST& list ) ...@@ -176,15 +175,13 @@ bool LoadComponentFile( const wxString& fileName, COMPONENT_LIST& list )
/* Recherche du composant correspondant en netliste et /* Recherche du composant correspondant en netliste et
* mise a jour de ses parametres */ * mise a jour de ses parametres */
for( i = list.begin(); i != list.end(); ++i ) BOOST_FOREACH( COMPONENT& component, list )
{ {
Cmp = *i; if( namecmp != component.m_Reference )
if( namecmp != Cmp->m_Reference )
continue; continue;
/* composant identifie , copie du nom du module correspondant */ /* composant identifie , copie du nom du module correspondant */
Cmp->m_Module = ilib; component.m_Module = ilib;
} }
} }
......
...@@ -7,21 +7,25 @@ ...@@ -7,21 +7,25 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "id.h" #include "id.h"
#include "3d_viewer.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "cvpcb.h" #include "cvpcb.h"
#include "protos.h" #include "protos.h"
#include "cvstruct.h" #include "cvstruct.h"
/*
* NOTE: There is something in 3d_viewer.h that causes a compiler error in
* <boost/foreach.hpp> in Linux so move it after cvpcb.h where it is
* included to prevent the error from occuring.
*/
#include "3d_viewer.h"
/*******************************************/
void WinEDA_CvpcbFrame::CreateScreenCmp()
/*******************************************/
/* Create or Update the frame showing the current highlighted footprint /*
* and (if showed) the 3D display frame * Create or Update the frame showing the current highlighted footprint
* and (if showed) the 3D display frame
*/ */
void WinEDA_CvpcbFrame::CreateScreenCmp()
{ {
wxString msg, FootprintName; wxString msg, FootprintName;
bool IsNew = FALSE; bool IsNew = FALSE;
...@@ -77,10 +81,10 @@ void WinEDA_CvpcbFrame::CreateScreenCmp() ...@@ -77,10 +81,10 @@ void WinEDA_CvpcbFrame::CreateScreenCmp()
/*******************************************************************/ /*
* Draws the current highlighted footprint.
*/
void WinEDA_DisplayFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) void WinEDA_DisplayFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/*******************************************************************/
/* Draws the current highlighted footprint */
{ {
if( !GetBoard() ) if( !GetBoard() )
return; return;
...@@ -101,14 +105,15 @@ void WinEDA_DisplayFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -101,14 +105,15 @@ void WinEDA_DisplayFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
} }
/********************************************************************/
/*
* Redraw the BOARD items but not cursors, axis or grid.
*/
void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC, void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC,
int aDrawMode, const wxPoint& offset ) int aDrawMode, const wxPoint& offset )
/********************************************************************/
/* Redraw the BOARD items but not cursors, axis or grid */
{ {
if( m_Modules ) if( m_Modules )
{ {
m_Modules->Draw( aPanel, DC, GR_COPY ); m_Modules->Draw( aPanel, DC, GR_COPY );
} }
} }
...@@ -20,29 +20,27 @@ ...@@ -20,29 +20,27 @@
#define MAX_LEN_NETNAME 16 #define MAX_LEN_NETNAME 16
/* Routines locales */ /* Routines locales */
static void ChangePinNet( COMPONENT_LIST& list, wxString& PinNet, static void ChangePinNet( COMPONENT_LIST& list, wxString& PinNet,
int* netNumber, bool rightJustify ); int* netNumber, bool rightJustify );
static void WriteFootprintFilterInfos( FILE* dest, COMPONENT_LIST& list ); static void WriteFootprintFilterInfos( FILE* dest, COMPONENT_LIST& list );
static void RemoveDuplicatePins( COMPONENT* component ) static void RemoveDuplicatePins( COMPONENT& component )
{ {
wxASSERT( component != NULL );
PIN_LIST::iterator i; PIN_LIST::iterator i;
PIN *pin1, *pin2; PIN *pin1, *pin2;
wxString msg; wxString msg;
if( component->m_Pins.size() <= 1 ) if( component.m_Pins.size() <= 1 )
return; return;
i = component->m_Pins.begin(); i = component.m_Pins.begin();
pin1 = *i; pin1 = &(*i);
++i; ++i;
while( i != component->m_Pins.end() ) while( i != component.m_Pins.end() )
{ {
pin2 = *i; pin2 = &(*i);
wxASSERT( pin2 != NULL ); wxASSERT( pin2 != NULL );
...@@ -56,17 +54,17 @@ static void RemoveDuplicatePins( COMPONENT* component ) ...@@ -56,17 +54,17 @@ static void RemoveDuplicatePins( COMPONENT* component )
if( !same_pin_net( pin1, pin2 ) ) if( !same_pin_net( pin1, pin2 ) )
{ {
msg.Printf( _( "Component %s %s pin %s : Different Nets" ), msg.Printf( _( "Component %s %s pin %s : Different Nets" ),
component->m_Reference.GetData(), component.m_Reference.GetData(),
component->m_Valeur.GetData(), component.m_Value.GetData(),
pin1->m_PinNum.GetData() ); pin1->m_Number.GetData() );
DisplayError( NULL, msg, 60 ); DisplayError( NULL, msg, 60 );
} }
wxLogDebug( wxT( "Removing duplicate pin %s from component %s: %s" ), wxLogDebug( wxT( "Removing duplicate pin %s from component %s: %s" ),
pin1->m_PinNum.c_str(), component->m_Reference.c_str(), pin1->m_Number.c_str(), component.m_Reference.c_str(),
component->m_Valeur.c_str() ); component.m_Value.c_str() );
pin1 = pin2; pin1 = pin2;
i = component->m_Pins.erase( i ); i = component.m_Pins.erase( i );
delete pin2; delete pin2;
} }
} }
...@@ -76,11 +74,7 @@ int GenNetlistPcbnew( FILE* file, COMPONENT_LIST& list, bool isEESchemaNetlist, ...@@ -76,11 +74,7 @@ int GenNetlistPcbnew( FILE* file, COMPONENT_LIST& list, bool isEESchemaNetlist,
bool rightJustify ) bool rightJustify )
{ {
#define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1" #define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1"
COMPONENT_LIST::iterator iCmp;
PIN_LIST::iterator iPin;
char Line[1024]; char Line[1024];
PIN* Pin;
COMPONENT* Component;
int netNumber = 1; int netNumber = 1;
DateAndTime( Line ); DateAndTime( Line );
...@@ -94,40 +88,36 @@ int GenNetlistPcbnew( FILE* file, COMPONENT_LIST& list, bool isEESchemaNetlist, ...@@ -94,40 +88,36 @@ int GenNetlistPcbnew( FILE* file, COMPONENT_LIST& list, bool isEESchemaNetlist,
/* Lecture de la liste */ /* Lecture de la liste */
/***********************/ /***********************/
for( iCmp = list.begin(); iCmp != list.end(); ++iCmp ) BOOST_FOREACH( COMPONENT& component, list )
{ {
Component = *iCmp; fprintf( file, " ( %s ", CONV_TO_UTF8( component.m_TimeStamp ) );
fprintf( file, " ( %s ", CONV_TO_UTF8( Component->m_TimeStamp ) );
if( !Component->m_Module.IsEmpty() ) if( !component.m_Module.IsEmpty() )
fprintf( file, CONV_TO_UTF8( Component->m_Module ) ); fprintf( file, CONV_TO_UTF8( component.m_Module ) );
else else
fprintf( file, "$noname$" ); fprintf( file, "$noname$" );
fprintf( file, " %s ", CONV_TO_UTF8( Component->m_Reference ) ); fprintf( file, " %s ", CONV_TO_UTF8( component.m_Reference ) );
/* placement de la valeur */ /* placement de la valeur */
fprintf( file, "%s\n", CONV_TO_UTF8( Component->m_Valeur ) ); fprintf( file, "%s\n", CONV_TO_UTF8( component.m_Value ) );
Component->m_Pins.Sort( compare ); component.m_Pins.sort();
RemoveDuplicatePins( Component ); RemoveDuplicatePins( component );
/* Placement de la liste des pins */ /* Placement de la liste des pins */
for( iPin = Component->m_Pins.begin(); iPin != Component->m_Pins.end(); BOOST_FOREACH( PIN& pin, component.m_Pins )
++iPin )
{ {
Pin = *iPin; if( pin.m_Net.Len() > MAX_LEN_NETNAME )
if( Pin->m_PinNet.Len() > MAX_LEN_NETNAME ) ChangePinNet( list, pin.m_Net, &netNumber, rightJustify );
ChangePinNet( list, Pin->m_PinNet, &netNumber, rightJustify );
if( !Pin->m_PinNet.IsEmpty() ) if( !pin.m_Net.IsEmpty() )
fprintf( file, " ( %s %s )\n", fprintf( file, " ( %s %s )\n",
CONV_TO_UTF8( Pin->m_PinNum ), CONV_TO_UTF8( pin.m_Number ),
CONV_TO_UTF8( Pin->m_PinNet ) ); CONV_TO_UTF8( pin.m_Net ) );
else else
fprintf( file, " ( %s ? )\n", CONV_TO_UTF8( Pin->m_PinNum ) ); fprintf( file, " ( %s ? )\n", CONV_TO_UTF8( pin.m_Number ) );
} }
fprintf( file, " )\n" ); fprintf( file, " )\n" );
...@@ -148,15 +138,12 @@ int GenNetlistPcbnew( FILE* file, COMPONENT_LIST& list, bool isEESchemaNetlist, ...@@ -148,15 +138,12 @@ int GenNetlistPcbnew( FILE* file, COMPONENT_LIST& list, bool isEESchemaNetlist,
*/ */
void WriteFootprintFilterInfos( FILE* file, COMPONENT_LIST& list ) void WriteFootprintFilterInfos( FILE* file, COMPONENT_LIST& list )
{ {
COMPONENT_LIST::iterator i;
COMPONENT* component;
bool WriteHeader = FALSE; bool WriteHeader = FALSE;
for( i = list.begin(); i != list.end(); ++i ) BOOST_FOREACH( COMPONENT& component, list )
{ {
component = *i;
unsigned int FilterCount; unsigned int FilterCount;
FilterCount = component->m_FootprintFilter.GetCount(); FilterCount = component.m_FootprintFilter.GetCount();
if( FilterCount == 0 ) if( FilterCount == 0 )
continue; continue;
if( !WriteHeader ) if( !WriteHeader )
...@@ -165,12 +152,12 @@ void WriteFootprintFilterInfos( FILE* file, COMPONENT_LIST& list ) ...@@ -165,12 +152,12 @@ void WriteFootprintFilterInfos( FILE* file, COMPONENT_LIST& list )
WriteHeader = TRUE; WriteHeader = TRUE;
} }
fprintf( file, "$component %s\n", fprintf( file, "$component %s\n",
CONV_TO_UTF8( component->m_Reference ) ); CONV_TO_UTF8( component.m_Reference ) );
/* Write the footprint list */ /* Write the footprint list */
for( unsigned int jj = 0; jj < FilterCount; jj++ ) for( unsigned int jj = 0; jj < FilterCount; jj++ )
{ {
fprintf( file, " %s\n", fprintf( file, " %s\n",
CONV_TO_UTF8( component->m_FootprintFilter[jj] ) ); CONV_TO_UTF8( component.m_FootprintFilter[jj] ) );
} }
fprintf( file, "$endlist\n" ); fprintf( file, "$endlist\n" );
...@@ -190,10 +177,6 @@ static void ChangePinNet( COMPONENT_LIST& list, wxString& PinNet, ...@@ -190,10 +177,6 @@ static void ChangePinNet( COMPONENT_LIST& list, wxString& PinNet,
{ {
wxASSERT( netNumber != NULL ); wxASSERT( netNumber != NULL );
COMPONENT_LIST::iterator iCmp;
PIN_LIST::iterator iPin;
PIN* Pin;
COMPONENT* Cmp;
wxString OldName; wxString OldName;
wxString NewName; wxString NewName;
...@@ -212,18 +195,14 @@ static void ChangePinNet( COMPONENT_LIST& list, wxString& PinNet, ...@@ -212,18 +195,14 @@ static void ChangePinNet( COMPONENT_LIST& list, wxString& PinNet,
*netNumber = *netNumber + 1; *netNumber = *netNumber + 1;
for( iCmp = list.begin(); iCmp != list.end(); ++iCmp ) BOOST_FOREACH( COMPONENT& component, list )
{ {
Cmp = *iCmp; BOOST_FOREACH( PIN& pin, component.m_Pins )
for( iPin = Cmp->m_Pins.begin(); iPin != Cmp->m_Pins.end(); ++iPin )
{ {
Pin = *iPin; if( pin.m_Net != OldName )
if( Pin->m_PinNet != OldName )
continue; continue;
Pin->m_PinNet = NewName; pin.m_Net = NewName;
} }
} }
} }
...@@ -27,11 +27,6 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind ...@@ -27,11 +27,6 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
bMainSizer->Add( sbSizer5, 0, wxALL, 5 ); bMainSizer->Add( sbSizer5, 0, wxALL, 5 );
wxBoxSizer* bLeftSizer;
bLeftSizer = new wxBoxSizer( wxHORIZONTAL );
bMainSizer->Add( bLeftSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbLibsChoiceSizer; wxStaticBoxSizer* sbLibsChoiceSizer;
sbLibsChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Component library files") ), wxHORIZONTAL ); sbLibsChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Component library files") ), wxHORIZONTAL );
......
...@@ -151,17 +151,6 @@ ...@@ -151,17 +151,6 @@
</object> </object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bLeftSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
</object>
</object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxALL|wxEXPAND</property>
......
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