2009-02-04 15:25:03 +00:00
|
|
|
|
/*******************************************************************/
|
|
|
|
|
/* CVPCB: Routines de base : */
|
|
|
|
|
/* lecture Netliste et creation des fenetres composants et modules */
|
|
|
|
|
/*******************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "confirm.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
#include "gr_basic.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "gestfich.h"
|
|
|
|
|
#include "id.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "cvpcb.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
#include "protos.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "cvstruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* routines locales : */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
2009-02-04 15:25:03 +00:00
|
|
|
|
void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*********************************************************/
|
2009-02-04 15:25:03 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*
|
2009-02-04 15:25:03 +00:00
|
|
|
|
* - Affecte un module au composant selectionne
|
|
|
|
|
* - Selectionne le composant suivant
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2009-02-04 15:25:03 +00:00
|
|
|
|
STORECMP* Composant;
|
|
|
|
|
int ii, NumCmp, IsNew = 1;
|
|
|
|
|
wxString Line;
|
|
|
|
|
|
|
|
|
|
if( g_BaseListeCmp == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
NumCmp = m_ListCmp->GetSelection();
|
|
|
|
|
if( NumCmp < 0 )
|
|
|
|
|
{
|
|
|
|
|
NumCmp = 0;
|
|
|
|
|
m_ListCmp->SetSelection( NumCmp, TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Composant = g_BaseListeCmp;
|
|
|
|
|
for( ii = 0; Composant != NULL; Composant = Composant->Pnext, ii++ )
|
|
|
|
|
{
|
|
|
|
|
if( NumCmp == ii )
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( Composant == NULL )
|
|
|
|
|
return;
|
|
|
|
|
if( !Composant->m_Module.IsEmpty() )
|
|
|
|
|
IsNew = 0;
|
|
|
|
|
|
|
|
|
|
Composant->m_Module = package;
|
|
|
|
|
|
|
|
|
|
Line.Printf( CMP_FORMAT, ii + 1,
|
|
|
|
|
Composant->m_Reference.GetData(), Composant->m_Valeur.GetData(),
|
|
|
|
|
Composant->m_Module.GetData() );
|
|
|
|
|
modified = 1;
|
|
|
|
|
if( IsNew )
|
|
|
|
|
composants_non_affectes -= 1;
|
|
|
|
|
|
|
|
|
|
m_ListCmp->SetString( NumCmp, Line );
|
|
|
|
|
m_ListCmp->SetSelection( NumCmp, FALSE );
|
|
|
|
|
|
|
|
|
|
// We activate next component:
|
|
|
|
|
if( NumCmp < (m_ListCmp->GetCount() - 1) )
|
|
|
|
|
NumCmp++;
|
|
|
|
|
m_ListCmp->SetSelection( NumCmp, TRUE );
|
|
|
|
|
|
|
|
|
|
Line.Printf( _( "Components: %d (free: %d)" ),
|
|
|
|
|
nbcomp, composants_non_affectes );
|
|
|
|
|
SetStatusText( Line, 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/********************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
|
void WinEDA_CvpcbFrame::ReadNetListe()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*******************************************/
|
2009-02-04 15:25:03 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Lecture de la netliste selon format, ainsi que du fichier des composants
|
2009-02-04 15:25:03 +00:00
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2009-02-04 15:25:03 +00:00
|
|
|
|
STORECMP* Composant;
|
|
|
|
|
wxString msg;
|
|
|
|
|
int ii;
|
|
|
|
|
int error_level;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
error_level = ReadSchematicNetlist();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
if( error_level < 0 )
|
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
/* lecture des correspondances */
|
|
|
|
|
loadcmp();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
if( m_ListCmp == NULL )
|
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
if( !NetInNameBuffer.IsEmpty() )
|
|
|
|
|
wxSetWorkingDirectory( wxPathOnly( NetInNameBuffer ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
Read_Config( NetInNameBuffer ); // relecture de la config (elle peut etre modifi<66>e)
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
listlib();
|
|
|
|
|
BuildFootprintListBox();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
m_ListCmp->Clear();
|
|
|
|
|
Composant = g_BaseListeCmp;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
composants_non_affectes = 0;
|
|
|
|
|
for( ii = 1; Composant != NULL; Composant = Composant->Pnext, ii++ )
|
|
|
|
|
{
|
|
|
|
|
msg.Printf( CMP_FORMAT, ii,
|
|
|
|
|
Composant->m_Reference.GetData(),
|
|
|
|
|
Composant->m_Valeur.GetData(),
|
|
|
|
|
Composant->m_Module.GetData() );
|
|
|
|
|
m_ListCmp->AppendLine( msg );
|
|
|
|
|
if( Composant->m_Module.IsEmpty() )
|
|
|
|
|
composants_non_affectes += 1;
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
if( g_BaseListeCmp )
|
|
|
|
|
m_ListCmp->SetSelection( 0, TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-21 15:12:26 +00:00
|
|
|
|
msg.Printf( _( "Components: %d (free: %d)" ), nbcomp,
|
2009-02-04 15:25:03 +00:00
|
|
|
|
composants_non_affectes );
|
|
|
|
|
SetStatusText( msg, 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
/* Mise a jour du titre de la fenetre principale */
|
|
|
|
|
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
|
|
|
|
|
msg.Printf( wxT( "%s [%s]" ), Title.GetData(), FFileName.GetData() );
|
|
|
|
|
SetTitle( msg );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************/
|
2009-02-04 15:25:03 +00:00
|
|
|
|
int WinEDA_CvpcbFrame::SaveNetList( const wxString& FullFilename )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*****************************************************************/
|
2009-02-04 15:25:03 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Sauvegarde des fichiers netliste et cmp
|
2009-02-04 15:25:03 +00:00
|
|
|
|
* Le nom complet du fichier Netliste doit etre dans FFileName.
|
|
|
|
|
* Le nom du fichier cmp en est deduit
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2009-02-04 15:25:03 +00:00
|
|
|
|
wxString NetlistFullFileName = FullFilename;
|
|
|
|
|
|
|
|
|
|
if( NetlistFullFileName.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
wxString Mask = wxT( "*" ) + NetExtBuffer;
|
|
|
|
|
if( !NetNameBuffer.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
NetlistFullFileName = NetNameBuffer;
|
|
|
|
|
ChangeFileNameExt( NetlistFullFileName, NetExtBuffer );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetlistFullFileName =
|
|
|
|
|
EDA_FileSelector( _( "Save NetList and Components List files" ),
|
|
|
|
|
NetDirBuffer, /* Chemin par defaut */
|
|
|
|
|
NetlistFullFileName, /* nom fichier par defaut */
|
|
|
|
|
NetExtBuffer, /* extension par defaut */
|
|
|
|
|
Mask, /* Masque d'affichage */
|
|
|
|
|
this,
|
|
|
|
|
wxFD_SAVE,
|
|
|
|
|
TRUE
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if( NetlistFullFileName.IsEmpty() )
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
FFileName = NetlistFullFileName;
|
|
|
|
|
NetNameBuffer = NetlistFullFileName;
|
|
|
|
|
if( SaveComponentList( NetlistFullFileName ) == 0 )
|
|
|
|
|
{
|
|
|
|
|
DisplayError( this, _( "Unable to create component file (.cmp)" ) );
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dest = wxFopen( NetlistFullFileName, wxT( "wt" ) );
|
|
|
|
|
if( dest == 0 )
|
|
|
|
|
{
|
|
|
|
|
DisplayError( this, _( "Unable to create netlist file" ) );
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GenNetlistPcbnew();
|
|
|
|
|
|
|
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
2009-02-04 15:25:03 +00:00
|
|
|
|
bool WinEDA_CvpcbFrame::ReadInputNetList( const wxString& FullFileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**********************************************************************/
|
2009-02-04 15:25:03 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Routine de selection du nom de la netliste d'entree, et de lecure de
|
2009-02-04 15:25:03 +00:00
|
|
|
|
* celle-ci
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2009-02-04 15:25:03 +00:00
|
|
|
|
wxString Mask, Line;
|
|
|
|
|
|
|
|
|
|
if( FullFileName.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
if( !NetInExtBuffer.IsEmpty() )
|
|
|
|
|
Mask = wxT( "*" ) + NetInExtBuffer;
|
|
|
|
|
else
|
|
|
|
|
Mask = wxT( "*.net" );
|
2009-02-22 10:38:40 +00:00
|
|
|
|
Line = EDA_FileSelector( _( "Open NetList File:" ),
|
2009-02-04 15:25:03 +00:00
|
|
|
|
NetDirBuffer, /* Chemin par defaut */
|
|
|
|
|
NetInNameBuffer, /* nom fichier par defaut */
|
|
|
|
|
NetInExtBuffer, /* extension par defaut */
|
|
|
|
|
Mask, /* Masque d'affichage */
|
|
|
|
|
this,
|
|
|
|
|
0,
|
|
|
|
|
FALSE
|
|
|
|
|
);
|
|
|
|
|
if( Line.IsEmpty() )
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Line = FullFileName;
|
|
|
|
|
|
|
|
|
|
NetInNameBuffer = Line;
|
|
|
|
|
NetNameBuffer = Line;
|
|
|
|
|
FFileName = NetInNameBuffer;
|
|
|
|
|
|
|
|
|
|
/* Mise a jour du titre de la fenetre principale */
|
|
|
|
|
Line = g_Main_Title + wxT( " " ) + GetBuildVersion();
|
|
|
|
|
Line += wxT( " " ) + NetInNameBuffer;
|
|
|
|
|
SetTitle( Line );
|
|
|
|
|
|
|
|
|
|
ReadNetListe();
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|