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
/////////////////////////////////////////////////////////////////////////////
#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__ */
......@@ -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;
}
......
......@@ -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
}
......
......@@ -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
......
......@@ -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;
text = ReadQuotedText( value, text );
if ( text == NULL || (*text == 0 ) )
if( text == NULL || ( *text == 0 ) || value.IsEmpty() )
continue;
ItemModule = new AUTOMODULE();
ItemModule->Pnext = BaseListeMod;
BaseListeMod = ItemModule;
text++;
text = ReadQuotedText( footprint, text );
/* stockage du composant ( 'namecmp' 'namelib')
* name et namelib */
ItemModule->m_Name = tmp;
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++;
ReadQuotedText(ItemModule->m_LibName, text);
nb_correspondances++;
}
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() )
continue;
if( Component->m_Module.IsEmpty() )
BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
{
ItemModule = BaseListeMod;
for( ; ItemModule != NULL; ItemModule = ItemModule->Pnext )
{
if( ItemModule->m_Name.CmpNoCase( Component->m_Valeur ) != 0 )
continue;
if( alias.m_Name.CmpNoCase( component.m_Value ) != 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;
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;
}
......@@ -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..) */
}
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(),
(*item2)->m_PinNum.GetData(), 4 );
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 );
}
......@@ -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 );
}
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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>
......
......@@ -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 */
......
......@@ -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;
/* gnration du composant si son empreinte est dfinie */
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 );
......
......@@ -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 );
}
......
......@@ -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 );
......
This diff is collapsed.
......@@ -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;
}
}
......
......@@ -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 );
}
}
......
......@@ -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;
}
}
......
......@@ -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"
/*
* 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;
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 );
}
}
}
......@@ -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;
}
}
}
......@@ -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 );
......
......@@ -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>
......
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