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.
This commit is contained in:
stambaughw 2009-05-06 11:55:36 +00:00
parent 7988f2ca21
commit c2b600ce39
22 changed files with 315 additions and 426 deletions

View File

@ -1,6 +1,10 @@
/////////////////////////////////////////////////////////////////////////////
// Name: 3d_viewer.h
/////////////////////////////////////////////////////////////////////////////
#ifndef __3D_VIEWER_H__
#define __3D_VIEWER_H__
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
@ -172,3 +176,5 @@ extern double g_Draw3d_dx, g_Draw3d_dy;
extern double ZBottom, ZTop;
extern double DataScale3D; // coeff de conversion unites utilsateut -> unites 3D
extern int gl_attrib[];
#endif /* __3D_VIEWER_H__ */

View File

@ -116,9 +116,9 @@ wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
wxPoint curpos = ScreenPos;
Unscale( curpos );
#ifndef WX_ZOOM
//#ifndef WX_ZOOM
curpos += m_DrawOrg;
#endif
//#endif
return curpos;
}

View File

@ -590,8 +590,15 @@ void WinEDA_DrawFrame::AdjustScrollBars()
#else
BASE_SCREEN* screen = GetBaseScreen();
wxSize drawingSize = screen->ReturnPageSize() * 2;
DrawPanel->SetScrollbars( 1, 1, drawingSize.x, drawingSize.y,
screen->m_Curseur.x, screen->m_Curseur.y, true );
wxCoord x, y;
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
}

View File

@ -199,14 +199,12 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
#ifdef WX_ZOOM
double scale = GetScreen()->GetScalingFactor();
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;
GetScrollPixelsPerUnit(& ppuX, & ppuY);
GetViewStart(& startX, & startY);
GetScrollPixelsPerUnit( & ppuX, & ppuY );
GetViewStart( &startX, &startY );
DC->SetDeviceOrigin( origin.x - startX * ppuX, origin.y - startY * ppuY );
DC->SetUserScale( scale, scale );
wxSize size = GetScreen()->ReturnPageSize() * 2 * scale;
// wxSize size = GetScreen()->ReturnPageSize() * 2 * scale;
// DC->SetLogicalOrigin( origin.x, origin.y );
#endif
SetBoundaryBox();
@ -368,12 +366,11 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void )
GetScreen()->Unscale( realpos );
#ifdef WX_ZOOM
wxCoord x, y;
wxClientDC DC( this );
PrepareGraphicContext( &DC );
x = DC.DeviceToLogicalX( realpos.x );
y = DC.DeviceToLogicalY( realpos.y );
return wxPoint( x, y );
// wxCoord x, y;
// wxClientDC DC( this );
// PrepareGraphicContext( &DC );
// realpos.x = DC.DeviceToLogicalX( realpos.x );
// realpos.y = DC.DeviceToLogicalY( realpos.y );
#else
realpos += GetScreen()->m_DrawOrg;
#endif

View File

@ -15,19 +15,21 @@
#include "protos.h"
#include "cvstruct.h"
#define QUOTE '\''
class AUTOMODULE
class FOOTPRINT_ALIAS
{
public:
int m_Type;
AUTOMODULE* Pnext;
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
@ -68,18 +70,13 @@ char * ReadQuotedText(wxString & aTarget, char * aText)
*/
void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
{
COMPONENT_LIST::iterator iCmp;
FOOTPRINT_LIST::iterator iFp;
wxFileName fn;
wxString msg, tmp;
char Line[1024];
FILE* file;
AUTOMODULE* ItemModule, * NextMod;
AUTOMODULE* BaseListeMod = NULL;
COMPONENT* Component;
FOOTPRINT* footprint;
size_t ii;
int nb_correspondances = 0;
FOOTPRINT_ALIAS_LIST aliases;
FOOTPRINT_ALIAS* alias;
wxFileName fn;
wxString msg, tmp;
char Line[1024];
FILE* file;
size_t ii;
if( m_components.empty() )
return;
@ -89,7 +86,6 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
{
fn = m_AliasLibNames[ii];
fn.SetExt( FootprintAliasFileExtension );
tmp = wxGetApp().FindLibraryPath( fn );
if( !tmp )
@ -101,6 +97,8 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
continue;
}
wxLogDebug( wxT( "Opening footprint alias file: %s." ), tmp.c_str() );
file = wxFopen( tmp, wxT( "rt" ) );
if( file == NULL )
@ -111,74 +109,72 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
}
/* lecture fichier n */
while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL )
while( GetLine( file, Line, NULL, sizeof(Line) ) != NULL )
{
char * text = Line;
text = ReadQuotedText(tmp, text);
char* text = Line;
wxString value, footprint;
if ( text == NULL || (*text == 0 ) )
text = ReadQuotedText( value, text );
if( text == NULL || ( *text == 0 ) || value.IsEmpty() )
continue;
ItemModule = new AUTOMODULE();
ItemModule->Pnext = BaseListeMod;
BaseListeMod = ItemModule;
/* stockage du composant ( 'namecmp' 'namelib')
* name et namelib */
ItemModule->m_Name = tmp;
text++;
ReadQuotedText(ItemModule->m_LibName, text);
text = ReadQuotedText( footprint, text );
nb_correspondances++;
if( footprint.IsEmpty() )
continue;
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++;
}
fclose( file );
}
/* display some info */
msg.Printf( _( "%d equivalences" ), nb_correspondances );
/* Display the number of footpint aliases. */
msg.Printf( _( "%d footprint aliases found." ), aliases.size() );
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( m_components.IndexOf( Component ), TRUE );
m_ListCmp->SetSelection( ii, true );
if( Component->m_Module.IsEmpty() )
if( !component.m_Module.IsEmpty() )
continue;
BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
{
ItemModule = BaseListeMod;
for( ; ItemModule != NULL; ItemModule = ItemModule->Pnext )
if( alias.m_Name.CmpNoCase( component.m_Value ) != 0 )
continue;
BOOST_FOREACH( FOOTPRINT& footprint, m_footprints )
{
if( ItemModule->m_Name.CmpNoCase( Component->m_Valeur ) != 0 )
continue;
for( iFp = m_footprints.begin(); iFp != m_footprints.end(); ++iFp )
if( alias.m_FootprintName.CmpNoCase( footprint.m_Module ) == 0 )
{
footprint = *iFp;
if( ItemModule->m_LibName.CmpNoCase( footprint->m_Module ) == 0 )
{
SetNewPkg( footprint->m_Module );
break;
}
SetNewPkg( footprint.m_Module );
break;
}
}
msg.Printf( _( "Component %s: Footprint %s not found in " \
"libraries" ), Component->m_Valeur.GetData(),
ItemModule->m_LibName.GetData() );
DisplayError( this, msg, 10 );
if( component.m_Module.IsEmpty() )
{
msg.Printf( _( "Component %s: footprint %s not found in " \
"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: */
for( ItemModule = BaseListeMod; ItemModule != NULL; ItemModule = NextMod )
{
NextMod = ItemModule->Pnext;
delete ItemModule;
ii += 1;
}
BaseListeMod = NULL;
}

View File

@ -10,37 +10,38 @@
#include <wx/listimpl.cpp>
WX_DEFINE_LIST( PIN_LIST );
PIN::PIN()
{
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..) */
}
int compare( const PIN** item1, const PIN** item2 )
bool operator<( const PIN& item1, const PIN& item2 )
{
return StrLenNumICmp( (*item1)->m_PinNum.GetData(),
(*item2)->m_PinNum.GetData(), 4 );
return ( StrLenNumICmp( item1.m_Number.GetData(),
item2.m_Number.GetData(), 4 ) < 0 );
}
bool operator==( const PIN& item1, const PIN& item2 )
{
return ( item1.m_Number == item2.m_Number );
}
bool same_pin_number( const PIN* item1, const PIN* item2 )
{
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 )
{
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()
{
m_Num = 0;
@ -49,26 +50,22 @@ 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(),
(*item2)->m_Reference.GetData() );
return ( StrNumICmp( item1.m_Reference.GetData(),
item2.m_Reference.GetData() ) < 0 );
}
WX_DEFINE_LIST( FOOTPRINT_LIST );
FOOTPRINT::FOOTPRINT()
{
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(),
(*item2)->m_Module.GetData() );
return ( StrNumICmp( item1.m_Module.GetData(),
item2.m_Module.GetData() ) < 0 );
}

View File

@ -10,11 +10,9 @@
#include "gestfich.h"
#include "id.h"
#include "param_config.h"
#include "3d_viewer.h"
#include "bitmaps.h"
#include "cvpcb.h"
#include "bitmaps.h"
#include "protos.h"
#include "cvstruct.h"
#include "dialog_cvpcb_config.h"
@ -157,8 +155,8 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, long style ) :
BuildCmpListBox();
BuildFootprintListBox();
/* Creation des contraintes de dimension de la fenetre d'affichage des composants
* du schema */
/* Creation des contraintes de dimension de la fenetre d'affichage des
* composants du schema */
wxLayoutConstraints* linkpos = new wxLayoutConstraints;
linkpos->top.SameAs( this, wxTop );
linkpos->bottom.SameAs( this, wxBottom );
@ -167,8 +165,8 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, long style ) :
if( m_ListCmp )
m_ListCmp->SetConstraints( linkpos );
/* Creation des contraintes de dimension de la fenetre d'affichage des modules
* de la librairie */
/* Creation des contraintes de dimension de la fenetre d'affichage des
* modules de la librairie */
linkpos = new wxLayoutConstraints;
linkpos->top.SameAs( m_ListCmp, wxTop );
linkpos->bottom.SameAs( m_ListCmp, wxBottom );
@ -197,11 +195,6 @@ WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame()
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST );
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 )
{
unsigned ii;
wxMessageDialog dialog( this,
_( "Net and component list modified.\nSave before exit ?" ),
_( "Net and component list modified.\nSave " \
"before exit ?" ),
_( "Confirmation" ),
wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT );
@ -332,8 +326,6 @@ void WinEDA_CvpcbFrame::OnChar( wxKeyEvent& event )
void WinEDA_CvpcbFrame::ToFirstNA( wxCommandEvent& event )
/*******************************************************/
{
COMPONENT_LIST::iterator i;
COMPONENT* Component;
int ii = 0;
int selection;
@ -345,11 +337,9 @@ void WinEDA_CvpcbFrame::ToFirstNA( wxCommandEvent& event )
if( 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 );
return;
@ -367,8 +357,6 @@ void WinEDA_CvpcbFrame::ToFirstNA( wxCommandEvent& event )
void WinEDA_CvpcbFrame::ToPreviousNA( wxCommandEvent& event )
/**********************************************************/
{
COMPONENT_LIST::reverse_iterator i;
COMPONENT* Component;
int ii;
int selection;
@ -381,11 +369,9 @@ void WinEDA_CvpcbFrame::ToPreviousNA( wxCommandEvent& event )
if( selection < 0 )
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 );
return;
@ -418,25 +404,24 @@ void WinEDA_CvpcbFrame::DelAssociations( wxCommandEvent& event )
/* Supprime toutes les associations deja faites
*/
{
COMPONENT_LIST::iterator i;
COMPONENT* Component;
wxString Line;
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 );
}
m_ListCmp->SetSelection( 0 );
m_undefinedComponentCnt = m_components.GetCount();
m_undefinedComponentCnt = m_components.size();
}
Line.Printf( _( "Components: %d (free: %d)" ), m_components.GetCount(),
m_components.GetCount() );
Line.Printf( _( "Components: %d (free: %d)" ), m_components.size(),
m_components.size() );
SetStatusText( Line, 1 );
}
@ -568,7 +553,6 @@ void WinEDA_CvpcbFrame::OnLeftDClick( wxListEvent& event )
void WinEDA_CvpcbFrame::OnSelectComponent( wxListEvent& event )
/*************************************************************/
{
COMPONENT* Component;
int selection;
if( !m_HToolBar->GetToolState( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) )
@ -584,15 +568,14 @@ void WinEDA_CvpcbFrame::OnSelectComponent( wxListEvent& event )
return;
}
Component = m_components[ selection ];
if( Component == NULL )
if( &m_components[ selection ] == NULL )
{
m_FootprintList->SetActiveFootprintList( TRUE, TRUE );
return;
}
m_FootprintList->SetFootprintFilteredList( Component, m_footprints );
m_FootprintList->SetFootprintFilteredList( &m_components[ selection ],
m_footprints );
}

View File

@ -7,6 +7,10 @@
#include "pcbcommon.h"
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/foreach.hpp>
// config for footprints doc file acces
#define DEFAULT_FOOTPRINTS_LIST_FILENAME wxT( "footprints_doc/footprints.pdf" )
@ -27,21 +31,23 @@ class PIN
{
public:
int m_Index; /* variable utilisee selon types de netlistes */
int m_PinType; /* code type electrique ( Entree Sortie Passive..) */
wxString m_PinNet; /* Pointeur sur le texte nom de net */
wxString m_PinNum;
wxString m_PinName;
int m_Type; /* code type electrique ( Entree Sortie Passive..) */
wxString m_Net; /* Pointeur sur le texte nom de net */
wxString m_Number;
wxString m_Name;
wxString m_Repere; /* utilise selon formats de netliste */
PIN();
};
WX_DECLARE_LIST( PIN, PIN_LIST );
typedef boost::ptr_vector< PIN > PIN_LIST;
/* 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_net( const PIN* item1, const PIN* item2 );
@ -49,25 +55,25 @@ extern bool same_pin_net( const PIN* item1, const PIN* item2 );
class COMPONENT
{
public:
int m_Num; /* Numero d'ordre */
int m_Multi; /* Nombre d' unites par boitier */
PIN_LIST m_Pins; /* pointeur sur la liste des Pins */
wxString m_Reference; /* U3, R5 ... */
wxString m_Valeur; /* 7400, 47K ... */
wxString m_TimeStamp; /* Signature temporelle ("00000000" si absente) */
wxString m_Module; /* Nom du module (Package) corresp */
wxString m_Repere; /* utilise selon formats de netliste */
wxArrayString m_FootprintFilter; /* List of allowed footprints (wildcart allowed
* if void: no filtering */
int m_Num; /* Numero d'ordre */
int m_Multi; /* Nombre d' unites par boitier */
PIN_LIST m_Pins; /* pointeur sur la liste des Pins */
wxString m_Reference; /* U3, R5 ... */
wxString m_Value; /* 7400, 47K ... */
wxString m_TimeStamp; /* Signature temporelle ("00000000" si absente) */
wxString m_Module; /* Nom du module (Package) corresp */
wxString m_Repere; /* utilise selon formats de netliste */
wxArrayString m_FootprintFilter; /* List of allowed footprints (wildcards
* allowed ). If empty: no filtering */
COMPONENT();
~COMPONENT();
};
WX_DECLARE_LIST( COMPONENT, COMPONENT_LIST );
typedef boost::ptr_vector< COMPONENT > COMPONENT_LIST;
/* 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
@ -82,10 +88,10 @@ public:
FOOTPRINT();
};
WX_DECLARE_LIST( FOOTPRINT, FOOTPRINT_LIST );
typedef boost::ptr_vector< FOOTPRINT > FOOTPRINT_LIST;
/* 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 */
extern const wxString FootprintAliasFileExtension;

View File

@ -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->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 );
@ -45,7 +45,7 @@ DIALOG_CVPCB_CONFIG_FBP::DIALOG_CVPCB_CONFIG_FBP( wxWindow* parent, wxWindowID i
sbLibsChoiceSizer->Add( bSizerLibButtons, 0, wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( sbLibsChoiceSizer, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( sbLibsChoiceSizer, 1, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbEquivChoiceSizer;
sbEquivChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Footprint alias files") ), wxHORIZONTAL );

View File

@ -78,8 +78,8 @@
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="0">
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Footprint library files</property>
<property name="minimum_size"></property>
@ -101,7 +101,7 @@
<property name="hidden">0</property>
<property name="id">wxID_ANY</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="permission">protected</property>
<property name="pos"></property>

View File

@ -10,13 +10,19 @@
#include "confirm.h"
#include "macros.h"
#include "3d_viewer.h"
#include "cvpcb.h"
#include "bitmaps.h"
#include "protos.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 */

View File

@ -17,13 +17,11 @@
void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event )
{
COMPONENT_LIST::iterator i;
FILE* FileEquiv;
COMPONENT* Cmp;
wxString Line;
wxFileName fn = m_NetlistFileName;
if( m_components.GetCount() <= 0 )
if( m_components.empty() )
return;
/* calcul du nom du fichier */
@ -46,16 +44,14 @@ void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event )
}
/* Generation de la liste */
for( i = m_components.begin(); i != m_components.end(); ++i )
BOOST_FOREACH( COMPONENT& component, m_components )
{
Cmp = *i;
/* génération du composant si son empreinte est définie */
if( Cmp->m_Module.IsEmpty() )
if( component.m_Module.empty() )
continue;
fprintf( FileEquiv, "comp = \"%s\" module = \"%s\"\n",
CONV_TO_UTF8( Cmp->m_Reference ),
CONV_TO_UTF8( Cmp->m_Module ) );
CONV_TO_UTF8( component.m_Reference ),
CONV_TO_UTF8( component.m_Module ) );
}
fclose( FileEquiv );

View File

@ -53,7 +53,7 @@ int genorcad( bool rightJustify )
fprintf( dest, " %s ", CONV_TO_UTF8( CurrentCmp->m_Reference ) );
/* 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 */
TriPinsModule( CurrentCmp );
@ -140,7 +140,7 @@ static void TriPinsModule( COMPONENT* CurrentCmp )
wxString msg;
msg.Printf( _( "%s %s pin %s : Different Nets" ),
CurrentCmp->m_Reference.GetData(),
CurrentCmp->m_Valeur.GetData(),
CurrentCmp->m_Value.GetData(),
Pin->m_PinNum.GetData() );
DisplayError( NULL, msg, 60 );
}

View File

@ -25,7 +25,6 @@
*/
void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
{
COMPONENT_LIST::iterator i;
COMPONENT* Component;
bool isUndefined = false;
int NumCmp;
@ -38,10 +37,10 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
if( 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 )
return;
@ -51,7 +50,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
Component->m_Module = package;
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() );
m_modified = true;
@ -67,7 +66,7 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
m_ListCmp->SetSelection( NumCmp, TRUE );
Line.Printf( _( "Components: %d (free: %d)" ),
m_components.GetCount(), m_undefinedComponentCnt );
m_components.size(), m_undefinedComponentCnt );
SetStatusText( Line, 1 );
}
@ -78,8 +77,6 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
*/
bool WinEDA_CvpcbFrame::ReadNetList()
{
COMPONENT_LIST::iterator i;
COMPONENT* Component;
wxString msg;
int error_level;
@ -105,24 +102,23 @@ bool WinEDA_CvpcbFrame::ReadNetList()
BuildFootprintListBox();
m_ListCmp->Clear();
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,
Component->m_Reference.GetData(),
Component->m_Valeur.GetData(),
Component->m_Module.GetData() );
component.m_Reference.GetData(),
component.m_Value.GetData(),
component.m_Module.GetData() );
m_ListCmp->AppendLine( msg );
if( Component->m_Module.IsEmpty() )
if( component.m_Module.IsEmpty() )
m_undefinedComponentCnt += 1;
}
if( !m_components.empty() )
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 );
SetStatusText( msg, 1 );

View File

@ -34,28 +34,24 @@ ListBoxBase::~ListBoxBase()
}
/************************************************/
/*
* Adjust the column width to the entire available window width
*/
void ListBoxBase::OnSize( wxSizeEvent& event )
/************************************************/
// Adjust the column width to the entire available window width
{
wxSize size = GetClientSize();
int width = 0;
// SetColumnWidth(0, wxLIST_AUTOSIZE );
// width = GetColumnWidth(0);
SetColumnWidth( 0, MAX( width, size.x ) );
event.Skip();
}
/*********************************/
/*
* Return an index for the selected item
*/
int ListBoxBase::GetSelection()
/*********************************/
// Return an index for the selected item
{
return GetFirstSelected();
}
@ -81,21 +77,19 @@ FootprintListBox::~FootprintListBox()
}
/**********************************/
/*
* Return number of items
*/
int FootprintListBox::GetCount()
/**********************************/
// Return number of items
{
return m_ActiveFootprintList->Count();
}
/*****************************************************************************/
/*
* Change an item text
*/
void FootprintListBox::SetString( unsigned linecount, const wxString& text )
/*****************************************************************************/
// Change an item text
{
if( linecount >= m_ActiveFootprintList->Count() )
linecount = m_ActiveFootprintList->Count() - 1;
@ -104,11 +98,7 @@ void FootprintListBox::SetString( unsigned linecount, const wxString& text )
}
/***************************************************/
wxString FootprintListBox::GetSelectedFootprint()
/***************************************************/
// Return an index for the selected item
{
wxString FootprintName;
int ii = GetFirstSelected();
@ -124,34 +114,27 @@ wxString FootprintListBox::GetSelectedFootprint()
}
/*********************************************************/
void FootprintListBox::AppendLine( const wxString& text )
/*********************************************************/
// Add an item at end of list
{
m_ActiveFootprintList->Add( text );
SetItemCount( m_ActiveFootprintList->Count() );
}
/*********************************************************************/
wxString FootprintListBox::OnGetItemText( long item, long column ) const
/*********************************************************************/
/* Overlaid function: MUST be provided in wxLC_VIRTUAL mode
* because real data is not handled by ListBoxBase
/*
* Overlaid function: MUST be provided in wxLC_VIRTUAL mode
* because real data is not handled by ListBoxBase
*/
wxString FootprintListBox::OnGetItemText( long item, long column ) const
{
return m_ActiveFootprintList->Item( item );
}
/*****************************************************************/
/*
* Enable or disable an item
*/
void FootprintListBox::SetSelection( unsigned index, bool State )
/*****************************************************************/
// Enable or disable an item
{
if( (int) index >= GetCount() )
index = GetCount() - 1;
@ -190,36 +173,24 @@ ListBoxCmp::~ListBoxCmp()
*/
BEGIN_EVENT_TABLE( ListBoxCmp, LIST_BOX_TYPE )
EVT_SIZE( ListBoxBase::OnSize )
EVT_SIZE( ListBoxBase::OnSize )
END_EVENT_TABLE()
/****************************/
void ListBoxCmp::Clear()
/****************************/
// Reset ALL data
void ListBoxCmp::Clear()
{
m_ComponentList.Clear();
SetItemCount( 0 );
}
/******************************/
int ListBoxCmp::GetCount()
/******************************/
// Return number of items
{
return m_ComponentList.Count();
}
/********************************************************************/
void ListBoxCmp::SetString( unsigned linecount, const wxString& text )
/********************************************************************/
// Change an item text
{
if( linecount >= m_ComponentList.Count() )
linecount = m_ComponentList.Count() - 1;
@ -228,34 +199,27 @@ void ListBoxCmp::SetString( unsigned linecount, const wxString& text )
}
/****************************************************/
void ListBoxCmp::AppendLine( const wxString& text )
/****************************************************/
// Add an item at end of list
{
m_ComponentList.Add( text );
SetItemCount( m_ComponentList.Count() );
}
/****************************************************************/
wxString ListBoxCmp::OnGetItemText( long item, long column ) const
/****************************************************************/
/* Overlaid function: MUST be provided in wxLC_VIRTUAL mode
* because real data are not handled by ListBoxBase
/*
* Overlaid function: MUST be provided in wxLC_VIRTUAL mode
* because real data are not handled by ListBoxBase
*/
wxString ListBoxCmp::OnGetItemText( long item, long column ) const
{
return m_ComponentList.Item( item );
}
/********************************************************/
/*
* Enable or disable an item
*/
void ListBoxCmp::SetSelection( unsigned index, bool State )
/*********************************************************/
// Enable or disable an item
{
if( (int) index >= GetCount() )
index = GetCount() - 1;
@ -273,15 +237,11 @@ void ListBoxCmp::SetSelection( unsigned index, bool State )
}
/********************************************/
void WinEDA_CvpcbFrame::BuildCmpListBox()
/********************************************/
/* Create or update the schematic components list.
/*
* Create or update the schematic components list.
*/
void WinEDA_CvpcbFrame::BuildCmpListBox()
{
COMPONENT_LIST::iterator i;
COMPONENT* Component;
wxString msg;
wxSize size( 10, 10 );
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
@ -301,13 +261,12 @@ void WinEDA_CvpcbFrame::BuildCmpListBox()
m_ListCmp->m_ComponentList.Clear();
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,
Component->m_Reference.GetData(),
Component->m_Valeur.GetData(),
Component->m_Module.GetData() );
component.m_Reference.GetData(),
component.m_Value.GetData(),
component.m_Module.GetData() );
m_ListCmp->m_ComponentList.Add( msg );
}
@ -316,12 +275,11 @@ void WinEDA_CvpcbFrame::BuildCmpListBox()
}
/**********************************************/
void WinEDA_CvpcbFrame::BuildFootprintListBox()
/**********************************************/
/* Create or update the footprint list.
/*
* Create or update the footprint list.
*/
void WinEDA_CvpcbFrame::BuildFootprintListBox()
{
wxString msg;
wxSize size( 10, 10 );
@ -347,21 +305,17 @@ void WinEDA_CvpcbFrame::BuildFootprintListBox()
}
/************************************************/
void FootprintListBox::SetFootprintFullList( FOOTPRINT_LIST& list )
{
FOOTPRINT_LIST::iterator i;
FOOTPRINT* footprint;
wxString msg;
int OldSelection = GetSelection();
m_FullFootprintList.Clear();
for( i = list.begin(); i != list.end(); ++i )
BOOST_FOREACH( FOOTPRINT& footprint, list )
{
footprint = *i;
msg.Printf( wxT( "%3d %s" ), m_FullFootprintList.GetCount() + 1,
footprint->m_Module.GetData() );
footprint.m_Module.GetData() );
m_FullFootprintList.Add( msg );
}
@ -374,13 +328,10 @@ void FootprintListBox::SetFootprintFullList( FOOTPRINT_LIST& list )
}
/**********************************************************************/
void FootprintListBox::SetFootprintFilteredList( COMPONENT* Component,
FOOTPRINT_LIST& list )
/*********************************************************************/
{
FOOTPRINT_LIST::iterator i;
FOOTPRINT* footprint;
wxString msg;
unsigned jj;
int OldSelection = GetSelection();
@ -388,17 +339,15 @@ void FootprintListBox::SetFootprintFilteredList( COMPONENT* Component,
m_FilteredFootprintList.Clear();
for( i = list.begin(); i != list.end(); ++i )
BOOST_FOREACH( FOOTPRINT& footprint, list )
{
footprint = *i;
/* Search for matching footprints */
for( jj = 0; jj < Component->m_FootprintFilter.GetCount(); jj++ )
{
if( !footprint->m_Module.Matches( Component->m_FootprintFilter[jj] ) )
if( !footprint.m_Module.Matches( Component->m_FootprintFilter[jj] ) )
continue;
msg.Printf( wxT( "%3d %s" ), m_FilteredFootprintList.GetCount() + 1,
footprint->m_Module.GetData() );
footprint.m_Module.GetData() );
m_FilteredFootprintList.Add( msg );
HasItem = TRUE;
}
@ -416,24 +365,23 @@ void FootprintListBox::SetFootprintFilteredList( COMPONENT* Component,
}
/**************************************************************************/
void FootprintListBox::SetActiveFootprintList( bool FullList, bool Redraw )
/**************************************************************************/
/** Set the footprint list. We can have 2 footprint list:
* The full footprint list
* The filtered footprint list (if the current selected component has a filter for footprints)
* The filtered footprint list (if the current selected component has a
* filter for footprints)
* @param FullList true = full footprint list, false = filtered footprint list
* @param Redraw = true to redraw the window
*/
void FootprintListBox::SetActiveFootprintList( bool FullList, bool Redraw )
{
bool old_selection = m_UseFootprintFullList;
#ifdef __WINDOWS__
/* Workaround for a curious bug in wxWidgets:
* if we switch from a long list of footprints to a short list (a filtered footprint list),
* and if the selected item is near the end of the long list,
* the new list is not displayed from the top of the list box
* if we switch from a long list of footprints to a short list (a
* filtered footprint list), and if the selected item is near the end
* of the long list, the new list is not displayed from the top of
* the list box
*/
if ( m_ActiveFootprintList )
{
@ -533,15 +481,10 @@ void FootprintListBox::OnLeftDClick( wxListEvent& event )
FOOTPRINT* GetModuleDescrByName( const wxString& FootprintName,
FOOTPRINT_LIST& list )
{
FOOTPRINT_LIST::iterator i;
FOOTPRINT* footprint;
for( i = list.begin() ; i != list.end(); ++i )
BOOST_FOREACH( FOOTPRINT& footprint, list )
{
footprint = *i;
if( footprint->m_Module == FootprintName )
return footprint;
if( footprint.m_Module == FootprintName )
return &footprint;
}
return NULL;

View File

@ -48,9 +48,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames,
if( !list.empty() )
{
list.DeleteContents( true );
list.Clear();
list.DeleteContents( false );
list.clear();
}
if( libNames.GetCount() == 0 )
@ -138,7 +136,7 @@ bool LoadFootprintFiles( const wxArrayString& libNames,
ReadDocLib( tmp, list );
}
list.Sort( compare );
list.sort();
return true;
}
@ -151,13 +149,11 @@ bool LoadFootprintFiles( const wxArrayString& libNames,
static void ReadDocLib( const wxString& ModLibName, FOOTPRINT_LIST& list )
{
FOOTPRINT* NewMod;
FOOTPRINT* tmp;
char Line[1024];
wxString ModuleName;
wxString msg;
FILE* LibDoc;
wxFileName fn = ModLibName;
FOOTPRINT_LIST::iterator i;
fn.SetExt( wxT( "mdc" ) );
@ -196,13 +192,11 @@ static void ReadDocLib( const wxString& ModLibName, FOOTPRINT_LIST& list )
{
case 'L': /* LibName */
ModuleName = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
for( i = list.begin(); i != list.end(); ++i )
BOOST_FOREACH( FOOTPRINT& footprint, list )
{
tmp = *i;
if( ModuleName == tmp->m_Module )
if( ModuleName == footprint.m_Module )
{
NewMod = tmp;
NewMod = &footprint;
break;
}
}

View File

@ -103,9 +103,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
/* Clear components buffer */
if( !m_components.empty() )
{
m_components.DeleteContents( true );
m_components.Clear();
m_components.DeleteContents( false );
m_components.clear();
}
source = wxFopen( m_NetlistFileName.GetFullPath(), wxT( "rt" ) );
@ -257,7 +255,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
/* Store info for this component */
Cmp = new COMPONENT();
Cmp->m_Reference = component_reference;
Cmp->m_Valeur = component_value;
Cmp->m_Value = component_value;
m_components.push_back( Cmp );
if( m_isEESchemaNetlist ) /* copy footprint name: */
@ -278,7 +276,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
fclose( source );
m_components.Sort( compare );
m_components.sort();
return 0;
}
@ -286,7 +284,6 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
{
COMPONENT_LIST::iterator i;
char Line[BUFFER_CHAR_SIZE + 1];
wxString CmpRef;
COMPONENT* Cmp = NULL;
@ -310,9 +307,9 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
CmpRef.Trim( FALSE );
/* 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 )
break;
@ -388,8 +385,8 @@ int ReadPinConnection( FILE* f, COMPONENT* Cmp )
}
Pin = new PIN();
Pin->m_PinNum = numpin;
Pin->m_PinNet = net;
Pin->m_Number = numpin;
Pin->m_Net = net;
Cmp->m_Pins.push_back( Pin );
}
}

View File

@ -31,8 +31,6 @@ const wxString titleComponentLibErr( _( "Component Library Error" ) );
*/
int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName )
{
COMPONENT_LIST::iterator i;
COMPONENT* Cmp;
FILE* dest;
wxFileName fn( NetlistFullFileName );
char Line[1024];
@ -49,14 +47,17 @@ int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName )
fprintf( dest, " Created by %s", CONV_TO_UTF8( Title ) );
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, "TimeStamp = %s;\n", CONV_TO_UTF8( Cmp->m_TimeStamp ) );
fprintf( dest, "Reference = %s;\n", CONV_TO_UTF8( Cmp->m_Reference ) );
fprintf( dest, "ValeurCmp = %s;\n", CONV_TO_UTF8( Cmp->m_Valeur ) );
fprintf( dest, "IdModule = %s;\n", CONV_TO_UTF8( Cmp->m_Module ) );
fprintf( dest, "TimeStamp = %s;\n",
CONV_TO_UTF8( component.m_TimeStamp ) );
fprintf( dest, "Reference = %s;\n",
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" );
}
@ -71,10 +72,8 @@ int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName )
*/
bool LoadComponentFile( const wxString& fileName, COMPONENT_LIST& list )
{
COMPONENT_LIST::iterator i;
wxString timestamp, valeur, ilib, namecmp, msg;
bool read_cmp_data = FALSE, eof = FALSE;
COMPONENT* Cmp;
char Line[1024], * ident, * data;
FILE* source;
wxFileName fn = fileName;
@ -176,15 +175,13 @@ bool LoadComponentFile( const wxString& fileName, COMPONENT_LIST& list )
/* Recherche du composant correspondant en netliste et
* mise a jour de ses parametres */
for( i = list.begin(); i != list.end(); ++i )
BOOST_FOREACH( COMPONENT& component, list )
{
Cmp = *i;
if( namecmp != Cmp->m_Reference )
if( namecmp != component.m_Reference )
continue;
/* composant identifie , copie du nom du module correspondant */
Cmp->m_Module = ilib;
component.m_Module = ilib;
}
}

View File

@ -7,21 +7,25 @@
#include "class_drawpanel.h"
#include "id.h"
#include "3d_viewer.h"
#include "bitmaps.h"
#include "cvpcb.h"
#include "protos.h"
#include "cvstruct.h"
/*******************************************/
void WinEDA_CvpcbFrame::CreateScreenCmp()
/*******************************************/
/* Create or Update the frame showing the current highlighted footprint
* and (if showed) the 3D display frame
/*
* 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"
/*
* Create or Update the frame showing the current highlighted footprint
* and (if showed) the 3D display frame
*/
void WinEDA_CvpcbFrame::CreateScreenCmp()
{
wxString msg, FootprintName;
bool IsNew = FALSE;
@ -77,10 +81,10 @@ void WinEDA_CvpcbFrame::CreateScreenCmp()
/*******************************************************************/
/*
* Draws the current highlighted footprint.
*/
void WinEDA_DisplayFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/*******************************************************************/
/* Draws the current highlighted footprint */
{
if( !GetBoard() )
return;
@ -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,
int aDrawMode, const wxPoint& offset )
/********************************************************************/
/* Redraw the BOARD items but not cursors, axis or grid */
{
if( m_Modules )
{
m_Modules->Draw( aPanel, DC, GR_COPY );
}
}
}

View File

@ -20,29 +20,27 @@
#define MAX_LEN_NETNAME 16
/* Routines locales */
static void ChangePinNet( COMPONENT_LIST& list, wxString& PinNet,
int* netNumber, bool rightJustify );
static void ChangePinNet( COMPONENT_LIST& list, wxString& PinNet,
int* netNumber, bool rightJustify );
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 *pin1, *pin2;
wxString msg;
if( component->m_Pins.size() <= 1 )
if( component.m_Pins.size() <= 1 )
return;
i = component->m_Pins.begin();
pin1 = *i;
i = component.m_Pins.begin();
pin1 = &(*i);
++i;
while( i != component->m_Pins.end() )
while( i != component.m_Pins.end() )
{
pin2 = *i;
pin2 = &(*i);
wxASSERT( pin2 != NULL );
@ -56,17 +54,17 @@ static void RemoveDuplicatePins( COMPONENT* component )
if( !same_pin_net( pin1, pin2 ) )
{
msg.Printf( _( "Component %s %s pin %s : Different Nets" ),
component->m_Reference.GetData(),
component->m_Valeur.GetData(),
pin1->m_PinNum.GetData() );
component.m_Reference.GetData(),
component.m_Value.GetData(),
pin1->m_Number.GetData() );
DisplayError( NULL, msg, 60 );
}
wxLogDebug( wxT( "Removing duplicate pin %s from component %s: %s" ),
pin1->m_PinNum.c_str(), component->m_Reference.c_str(),
component->m_Valeur.c_str() );
pin1->m_Number.c_str(), component.m_Reference.c_str(),
component.m_Value.c_str() );
pin1 = pin2;
i = component->m_Pins.erase( i );
i = component.m_Pins.erase( i );
delete pin2;
}
}
@ -76,11 +74,7 @@ int GenNetlistPcbnew( FILE* file, COMPONENT_LIST& list, bool isEESchemaNetlist,
bool rightJustify )
{
#define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1"
COMPONENT_LIST::iterator iCmp;
PIN_LIST::iterator iPin;
char Line[1024];
PIN* Pin;
COMPONENT* Component;
int netNumber = 1;
DateAndTime( Line );
@ -94,40 +88,36 @@ int GenNetlistPcbnew( FILE* file, COMPONENT_LIST& list, bool isEESchemaNetlist,
/* 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() )
fprintf( file, CONV_TO_UTF8( Component->m_Module ) );
if( !component.m_Module.IsEmpty() )
fprintf( file, CONV_TO_UTF8( component.m_Module ) );
else
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 */
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 );
RemoveDuplicatePins( Component );
component.m_Pins.sort();
RemoveDuplicatePins( component );
/* Placement de la liste des pins */
for( iPin = Component->m_Pins.begin(); iPin != Component->m_Pins.end();
++iPin )
BOOST_FOREACH( PIN& pin, component.m_Pins )
{
Pin = *iPin;
if( Pin->m_PinNet.Len() > MAX_LEN_NETNAME )
ChangePinNet( list, Pin->m_PinNet, &netNumber, rightJustify );
if( pin.m_Net.Len() > MAX_LEN_NETNAME )
ChangePinNet( list, pin.m_Net, &netNumber, rightJustify );
if( !Pin->m_PinNet.IsEmpty() )
if( !pin.m_Net.IsEmpty() )
fprintf( file, " ( %s %s )\n",
CONV_TO_UTF8( Pin->m_PinNum ),
CONV_TO_UTF8( Pin->m_PinNet ) );
CONV_TO_UTF8( pin.m_Number ),
CONV_TO_UTF8( pin.m_Net ) );
else
fprintf( file, " ( %s ? )\n", CONV_TO_UTF8( Pin->m_PinNum ) );
fprintf( file, " ( %s ? )\n", CONV_TO_UTF8( pin.m_Number ) );
}
fprintf( file, " )\n" );
@ -148,15 +138,12 @@ int GenNetlistPcbnew( FILE* file, COMPONENT_LIST& list, bool isEESchemaNetlist,
*/
void WriteFootprintFilterInfos( FILE* file, COMPONENT_LIST& list )
{
COMPONENT_LIST::iterator i;
COMPONENT* component;
bool WriteHeader = FALSE;
for( i = list.begin(); i != list.end(); ++i )
BOOST_FOREACH( COMPONENT& component, list )
{
component = *i;
unsigned int FilterCount;
FilterCount = component->m_FootprintFilter.GetCount();
FilterCount = component.m_FootprintFilter.GetCount();
if( FilterCount == 0 )
continue;
if( !WriteHeader )
@ -165,12 +152,12 @@ void WriteFootprintFilterInfos( FILE* file, COMPONENT_LIST& list )
WriteHeader = TRUE;
}
fprintf( file, "$component %s\n",
CONV_TO_UTF8( component->m_Reference ) );
CONV_TO_UTF8( component.m_Reference ) );
/* Write the footprint list */
for( unsigned int jj = 0; jj < FilterCount; jj++ )
{
fprintf( file, " %s\n",
CONV_TO_UTF8( component->m_FootprintFilter[jj] ) );
CONV_TO_UTF8( component.m_FootprintFilter[jj] ) );
}
fprintf( file, "$endlist\n" );
@ -190,10 +177,6 @@ static void ChangePinNet( COMPONENT_LIST& list, wxString& PinNet,
{
wxASSERT( netNumber != NULL );
COMPONENT_LIST::iterator iCmp;
PIN_LIST::iterator iPin;
PIN* Pin;
COMPONENT* Cmp;
wxString OldName;
wxString NewName;
@ -212,18 +195,14 @@ static void ChangePinNet( COMPONENT_LIST& list, wxString& PinNet,
*netNumber = *netNumber + 1;
for( iCmp = list.begin(); iCmp != list.end(); ++iCmp )
BOOST_FOREACH( COMPONENT& component, list )
{
Cmp = *iCmp;
for( iPin = Cmp->m_Pins.begin(); iPin != Cmp->m_Pins.end(); ++iPin )
BOOST_FOREACH( PIN& pin, component.m_Pins )
{
Pin = *iPin;
if( Pin->m_PinNet != OldName )
if( pin.m_Net != OldName )
continue;
Pin->m_PinNet = NewName;
pin.m_Net = NewName;
}
}
}

View File

@ -27,11 +27,6 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
bMainSizer->Add( sbSizer5, 0, wxALL, 5 );
wxBoxSizer* bLeftSizer;
bLeftSizer = new wxBoxSizer( wxHORIZONTAL );
bMainSizer->Add( bLeftSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbLibsChoiceSizer;
sbLibsChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Component library files") ), wxHORIZONTAL );

View File

@ -151,17 +151,6 @@
</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">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>