Commit aa51c05d authored by stambaughw's avatar stambaughw

CVPcb code refactoring, global variable elimination, and UI updates.

* Add methods to read and write project file parameters using dynamically defined list.
* Remove all global variables defined in CVPcb code.
* Dynamically define project file settings so class member variables can be used.
* Separate reading and writing application settings from project file settings.
* Make application UI objects and dialogs respect system UI font.
* Remove non-standard widget colors from CVPcb dialogs.
* Changed CVPcb object link list implementation to use wxList.
* Changed project library and path dialog to make OK button save project file instead of confusing "Save Cfg" button.
* Eliminate some duplicate file wildcard and extension definitions.
* The usual code reformatting, commenting, and spelling fixes.
parent bd3b4baa
......@@ -53,6 +53,7 @@ const wxString SchematicFileExtension( wxT( "sch" ) );
const wxString BoardFileExtension( wxT( "brd" ) );
const wxString NetlistFileExtension( wxT( "net" ) );
const wxString GerberFileExtension( wxT( "pho" ) );
const wxString PdfFileExtension( wxT( "pdf" ) );
/* Proper wxFileDialog wild card definitions. */
const wxString ProjectFileWildcard( _( "Kicad project files (*.pro)|*.pro" ) );
......@@ -60,6 +61,7 @@ const wxString BoardFileWildcard( _( "Kicad PCB files (*.brd)|*.brd") );
const wxString SchematicFileWildcard( _( "Kicad schematic files (*.sch)|*.sch" ) );
const wxString NetlistFileWildcard( _( "Kicad netlist files (*.net)|*.net" ) );
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) );
const wxString AllFilesWildcard( _( "All files (*)|*") );
......
......@@ -149,7 +149,7 @@ bool GetAssociatedDocument( wxFrame* aFrame,
if( !wxFileExists( fullfilename ) )
{
msg = _( "Doc File " );
msg << wxT("\"") << fullfilename << wxT("\"") << _( " not found" );
msg << wxT("\"") << aDocName << wxT("\"") << _( " not found" );
DisplayError( aFrame, msg );
return FALSE;
}
......
......@@ -179,6 +179,62 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName,
m_ProjectConfig = NULL;
}
void WinEDA_App::WriteProjectConfig( const wxString& fileName,
const wxString& GroupName,
const PARAM_CFG_ARRAY& params )
{
PARAM_CFG_BASE* param;
wxString msg;
size_t i;
ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG );
/* Write date ( surtout pour eviter bug de wxFileConfig
* qui se trompe de rubrique si declaration [xx] en premiere ligne
* (en fait si groupe vide) */
m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR );
msg = DateAndTime();
m_ProjectConfig->Write( wxT( "update" ), msg );
msg = GetAppName();
m_ProjectConfig->Write( wxT( "last_client" ), msg );
/* Save parameters */
m_ProjectConfig->DeleteGroup( GroupName ); // Erase all datas
m_ProjectConfig->Flush();
m_ProjectConfig->SetPath( GroupName );
m_ProjectConfig->Write( wxT( "version" ), CONFIG_VERSION );
m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR );
for( i = 0; i < params.GetCount(); i++ )
{
param = &params[i];
if( param->m_Group )
m_ProjectConfig->SetPath( param->m_Group );
else
m_ProjectConfig->SetPath( GroupName );
if( param->m_Setup )
continue;
if ( param->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( param->m_Ident )
m_ProjectConfig->DeleteGroup( param->m_Ident );
}
else
param->SaveParam( m_ProjectConfig );
}
m_ProjectConfig->SetPath( UNIX_STRING_DIR_SEP );
delete m_ProjectConfig;
m_ProjectConfig = NULL;
}
/*****************************************************************/
void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_BASE** aList )
/*****************************************************************/
......@@ -277,6 +333,60 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
}
bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName,
const PARAM_CFG_ARRAY& params,
bool Load_Only_if_New )
{
size_t i;
PARAM_CFG_BASE* param;
wxString timestamp;
ReCreatePrjConfig( local_config_filename, GroupName, false );
m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR );
timestamp = m_ProjectConfig->Read( wxT( "update" ) );
if( Load_Only_if_New && ( !timestamp.IsEmpty() )
&& (timestamp == m_CurrentOptionFileDateAndTime) )
{
return false;
}
m_CurrentOptionFileDateAndTime = timestamp;
if( !g_Prj_Default_Config_FullFilename.IsEmpty() )
m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
else
{
if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP +
g_Prj_Config_LocalFilename;
else
m_CurrentOptionFile = g_Prj_Config_LocalFilename;
}
for( i = 0; i < params.GetCount(); i++ )
{
param = &params[i];
if( param->m_Group )
m_ProjectConfig->SetPath( param->m_Group );
else
m_ProjectConfig->SetPath( GroupName );
if( param->m_Setup )
continue;
param->ReadParam( m_ProjectConfig );
}
delete m_ProjectConfig;
m_ProjectConfig = NULL;
return true;
}
/***************************************************************/
void WinEDA_App::ReadCurrentSetupValues( PARAM_CFG_BASE** aList )
/***************************************************************/
......
......@@ -26,7 +26,6 @@ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent,
m_Title = new wxStaticText( parent, -1, Title );
m_Title->SetForegroundColour( wxColour( 200, 0, 0 ) );
BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
m_FrameText = new wxTextCtrl( parent, -1, TextToEdit, wxDefaultPosition, Size );
......
......@@ -21,7 +21,6 @@ set(CVPCB_SRCS
listboxes.cpp
listlib.cpp
loadcmp.cpp
memoire.cpp
menucfg.cpp
readschematicnetlist.cpp
savecmp.cpp
......@@ -29,17 +28,6 @@ set(CVPCB_SRCS
tool_cvpcb.cpp
writenetlistpcbnew.cpp)
set(CVPCB_EXTRA_SRCS
# ../pcbnew/class_board_item.cpp
# ../pcbnew/class_drawsegment.cpp
# ../pcbnew/class_edge_mod.cpp
# ../pcbnew/class_equipot.cpp
# ../pcbnew/class_module.cpp
# ../pcbnew/class_text_mod.cpp
../pcbnew/ioascii.cpp
# ../pcbnew/tracemod.cpp
)
if(WIN32)
if(MINGW)
# CVPCB_RESOURCES variable is set by the macro.
......@@ -58,7 +46,7 @@ if(APPLE)
set(MACOSX_BUNDLE_NAME cvpcb)
endif(APPLE)
add_executable(cvpcb WIN32 MACOSX_BUNDLE ${CVPCB_SRCS} ${CVPCB_EXTRA_SRCS} ${CVPCB_RESOURCES})
add_executable(cvpcb WIN32 MACOSX_BUNDLE ${CVPCB_SRCS} ${CVPCB_RESOURCES})
target_link_libraries(cvpcb 3d-viewer common pcbcommon polygon bitmaps kbool ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES})
......
......@@ -29,40 +29,66 @@ public:
};
/* routines locales : */
static int auto_select( WinEDA_CvpcbFrame* frame,
STORECMP* Cmp,
AUTOMODULE* BaseListeMod );
static char * ReadQuotedText(wxString & aTarget, char * aText);
/*
* read the string between quotes and put it in aTarget
* put text in aTarget
* return a pointer to the last read char (the second quote if Ok)
*/
char * ReadQuotedText(wxString & aTarget, char * aText)
{
// search the first quote:
for( ; *aText != 0; aText++ )
{
if( *aText == QUOTE )
break;
}
/*************************************************************/
void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
/*************************************************************/
if ( *aText == 0 )
return NULL;
/* Called by the automatic association button
* Read *.equ files to try to find acorresponding footprint
* for each component that is not already linked to a footprint ( a "free" component )
aText++;
for(; *aText != 0; aText++ )
{
if( *aText == QUOTE )
break;
aTarget.Append(*aText);
}
return aText;
}
/*
* Called by the automatic association button
* Read *.equ files to try to find corresponding footprint
* for each component that is not already linked to a footprint ( a "free"
* component )
* format of a line:
* 'cmp_ref' 'footprint_name'
*/
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;
STORECMP* Component;
COMPONENT* Component;
FOOTPRINT* footprint;
size_t ii;
int nb_correspondances = 0;
if( nbcomp <= 0 )
if( m_components.empty() )
return;
/* recherche des equivalences a travers les fichiers possibles */
for( unsigned ii = 0; ii < g_ListName_Equ.GetCount(); ii++ )
for( ii = 0; ii < m_AliasLibNames.GetCount(); ii++ )
{
fn = g_ListName_Equ[ii];
fn.SetExt( EquivFileExtension );
fn = m_AliasLibNames[ii];
fn.SetExt( FootprintAliasFileExtension );
tmp = wxGetApp().FindLibraryPath( fn );
......@@ -110,100 +136,49 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
fclose( file );
}
/* display some info */
msg.Printf( _( "%d equivalences" ), nb_correspondances );
SetStatusText( msg, 0 );
wxMessageBox(msg);
Component = g_BaseListeCmp;
for( unsigned ii = 0; Component != NULL; Component = Component->Pnext, ii++ )
{
m_ListCmp->SetSelection( ii, TRUE );
if( Component->m_Module.IsEmpty() )
auto_select( this, Component, BaseListeMod );
}
/* free memory: */
for( ItemModule = BaseListeMod; ItemModule != NULL; ItemModule = NextMod )
{
NextMod = ItemModule->Pnext;
delete ItemModule;
}
BaseListeMod = NULL;
}
/***************************************************/
char * ReadQuotedText(wxString & aTarget, char * aText)
/***************************************************/
/** read the string between quotes and put it in aTarget
* put text in aTarget
* return a pointer to the last read char (the second quote if Ok)
*/
{
// search the first quote:
for( ; *aText != 0; aText++ )
for( iCmp = m_components.begin(); iCmp != m_components.end(); ++iCmp )
{
if( *aText == QUOTE )
break;
}
Component = *iCmp;
m_ListCmp->SetSelection( m_components.IndexOf( Component ), TRUE );
if ( *aText == 0 )
return NULL;
aText++;
for(; *aText != 0; aText++ )
if( Component->m_Module.IsEmpty() )
{
if( *aText == QUOTE )
break;
aTarget.Append(*aText);
}
return aText;
}
/****************************************************************/
int auto_select( WinEDA_CvpcbFrame* frame, STORECMP* Cmp,
AUTOMODULE* BaseListeMod )
/****************************************************************/
/* associe automatiquement composant et Module
* Retourne;
* 0 si OK
* 1 si module specifie non trouve en liste librairie
* 2 si pas de module specifie dans la liste des equivalences
*/
{
AUTOMODULE* ItemModule;
STOREMOD* Module;
wxString msg;
/* examen de la liste des correspondances */
ItemModule = BaseListeMod;
for( ; ItemModule != NULL; ItemModule = ItemModule->Pnext )
{
if( ItemModule->m_Name.CmpNoCase( Cmp->m_Valeur ) != 0 )
if( ItemModule->m_Name.CmpNoCase( Component->m_Valeur ) != 0 )
continue;
/* Correspondance trouvee, recherche nom module dans la liste des
* modules disponibles en librairie */
Module = g_BaseListePkg;
for( ; Module != NULL; Module = Module->Pnext )
for( iFp = m_footprints.begin(); iFp != m_footprints.end(); ++iFp )
{
if( ItemModule->m_LibName.CmpNoCase( Module->m_Module ) == 0 )
footprint = *iFp;
if( ItemModule->m_LibName.CmpNoCase( footprint->m_Module ) == 0 )
{
frame->SetNewPkg( Module->m_Module );
return 0;
SetNewPkg( footprint->m_Module );
break;
}
}
msg.Printf( _( "Component %s: Footprint %s not found in libraries" ),
Cmp->m_Valeur.GetData(), ItemModule->m_LibName.GetData() );
DisplayError( frame, msg, 10 );
return 2;
msg.Printf( _( "Component %s: Footprint %s not found in " \
"libraries" ), Component->m_Valeur.GetData(),
ItemModule->m_LibName.GetData() );
DisplayError( this, msg, 10 );
}
}
}
/* free memory: */
for( ItemModule = BaseListeMod; ItemModule != NULL; ItemModule = NextMod )
{
NextMod = ItemModule->Pnext;
delete ItemModule;
}
return 1;
BaseListeMod = NULL;
}
......@@ -8,74 +8,105 @@
#include "appl_wxstruct.h"
#include "common.h"
#include "gestfich.h"
#include "param_config.h"
#include "cvpcb.h"
#include "protos.h"
#include "cvstruct.h"
#include "cfg.h"
/* Routines Locales */
/**/
#define GROUP wxT("/cvpcb")
#define GROUPLIB wxT("/pcbnew/libraries")
#define GROUPEQU wxT("/cvpcb/libraries")
/**************************************************/
void Read_Config( const wxString& FileName )
/**************************************************/
/* lit la configuration
/**
* Return project file parameter list for CVPcb.
*
* Populate the project file parameter array specific to CVPcb if it hasn't
* already been populated and return a reference to the array to the caller.
* Creating the parameter list at run time has the advantage of being able
* to define local variables. The old method of statically building the array
* at compile time requiring global variable definitions.
*/
const PARAM_CFG_ARRAY& WinEDA_CvpcbFrame::GetProjectFileParameters( void )
{
if( !m_projectFileParams.IsEmpty() )
return m_projectFileParams;
m_projectFileParams.Add( new PARAM_CFG_BASE( GROUPLIB,
PARAM_COMMAND_ERASE ) );
m_projectFileParams.Add( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
&m_ModuleLibNames,
GROUPLIB ) );
m_projectFileParams.Add( new PARAM_CFG_LIBNAME_LIST( wxT( "EquName" ),
&m_AliasLibNames,
GROUPEQU ) );
m_projectFileParams.Add( new PARAM_CFG_WXSTRING( wxT( "NetIExt" ),
&m_NetlistFileExtension ) );
m_projectFileParams.Add( new PARAM_CFG_WXSTRING( wxT( "LibDir" ),
&m_UserLibraryPath,
GROUPLIB ) );
return m_projectFileParams;
}
/**
* lit la configuration
* 1 - lit cvpcb.cnf
* 2 - si non trouve lit <chemin de cvpcb.exe>/cvpcb.cnf
* 3 - si non trouve: init des variables aux valeurs par defaut
*
* Remarque:
* le chemin de l'executable cvpcb.exe doit etre dans BinDir
*
*/
void WinEDA_CvpcbFrame::LoadProjectFile( const wxString& FileName )
{
wxFileName fn = FileName;
/* Init des valeurs par defaut */
g_LibName_List.Clear();
g_ListName_Equ.Clear();
m_ModuleLibNames.Clear();
m_AliasLibNames.Clear();
if( fn.GetExt() != ProjectFileExtension )
fn.SetExt( ProjectFileExtension );
wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer );
wxGetApp().RemoveLibraryPath( m_UserLibraryPath );
wxGetApp().ReadProjectConfig( fn.GetFullPath(),
GROUP, ParamCfgList, FALSE );
wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP,
GetProjectFileParameters(), FALSE );
if( g_NetlistFileExtension.IsEmpty() )
g_NetlistFileExtension = wxT( "net" );
if( m_NetlistFileExtension.IsEmpty() )
m_NetlistFileExtension = wxT( "net" );
/* User library path takes precedent over default library search paths. */
wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 );
wxGetApp().InsertLibraryPath( m_UserLibraryPath, 1 );
}
/************************************************************/
void WinEDA_CvpcbFrame::Update_Config( wxCommandEvent& event )
/************************************************************/
/* fonction relai d'appel a Save_Config,
* la vraie fonction de sauvegarde de la config
*/
void WinEDA_CvpcbFrame::Update_Config( wxCommandEvent& event )
{
Save_Config( this, m_NetlistFileName.GetFullPath() );
SaveProjectFile( m_NetlistFileName.GetFullPath() );
}
void Save_Config( wxWindow* parent, const wxString& fileName )
void WinEDA_CvpcbFrame::SaveProjectFile( const wxString& fileName )
{
wxFileName fn = fileName;
fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( parent, _( "Save Project File" ), fn.GetPath(),
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(),
fn.GetFullName(), ProjectFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return;
/* ecriture de la configuration */
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList );
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP,
GetProjectFileParameters() );
}
/*******************************************************/
/** cfg.h : configuration: definition des structures **/
/*******************************************************/
#include "param_config.h"
#define INSETUP TRUE
#define GROUP wxT("/cvpcb")
#define GROUPCOMMON wxT("/common")
#define GROUPLIB wxT("/pcbnew/libraries")
#define GROUPEQU wxT("/cvpcb/libraries")
/* Liste des parametres */
static PARAM_CFG_BASE CommandCfg
(
GROUPLIB, /* identification de groupe */
PARAM_COMMAND_ERASE /* type */
);
static PARAM_CFG_LIBNAME_LIST LibNameBufCfg
(
wxT("LibName"), /* identification */
&g_LibName_List, /* Adresse du parametre */
GROUPLIB
);
static PARAM_CFG_LIBNAME_LIST EquivNameBufCfg
(
wxT("EquName"), /* identification */
&g_ListName_Equ, /* Adresse du parametre */
GROUPEQU
);
static PARAM_CFG_WXSTRING NetInExtBufCfg
(
wxT("NetIExt"), /* identification */
&g_NetlistFileExtension
);
static PARAM_CFG_WXSTRING NetDirBufCfg
(
wxT("NetDir"), /* identification */
&g_UserNetDirBuffer, /* Adresse du parametre */
GROUPCOMMON
);
static PARAM_CFG_WXSTRING UserLibDirBufCfg
(
wxT("LibDir"), /* identification */
&g_UserLibDirBuffer, /* Adresse du parametre */
GROUPLIB
);
static PARAM_CFG_BOOL DisplayPadFillCfg
(
INSETUP,
wxT("DiPadFi"), /* identification */
&DisplayOpt.DisplayPadFill, /* Adresse du parametre */
TRUE /* Valeur par defaut */
);
static PARAM_CFG_BOOL DisplayPadNumCfg
(
INSETUP,
wxT("DiPadNu"), /* identification */
&DisplayOpt.DisplayPadNum, /* Adresse du parametre */
TRUE /* Valeur par defaut */
);
static PARAM_CFG_BOOL DisplayPadNoConnCfg
(
INSETUP,
wxT("DiPadNC"), /* identification */
&DisplayOpt.DisplayPadNoConn, /* Adresse du parametre */
FALSE /* Valeur par defaut */
);
static PARAM_CFG_BOOL DisplayPadIsolCfg
(
INSETUP,
wxT("DiPadMg"), /* identification */
&DisplayOpt.DisplayPadIsol, /* Adresse du parametre */
FALSE /* Valeur par defaut */
);
static PARAM_CFG_INT DisplayModEdgeCfg
(
INSETUP,
wxT("DiModEd"), /* identification */
&DisplayOpt.DisplayModEdge, /* Adresse du parametre */
1, /* Valeur par defaut */
0, 1 /* Valeurs extremes */
);
static PARAM_CFG_INT DisplayModTextCfg
(
INSETUP,
wxT("DiModTx"), /* identification */
&DisplayOpt.DisplayModText, /* Adresse du parametre */
1, /* Valeur par defaut */
0, 1 /* Valeurs extremes */
);
static PARAM_CFG_BOOL DisplayPcbTrackFillCfg
(
INSETUP,
wxT("DiPcbTF"), /* identification */
&DisplayOpt.DisplayPcbTrackFill, /* Adresse du parametre */
TRUE /* Valeur par defaut */
);
static PARAM_CFG_BASE * ParamCfgList[] =
{
& CommandCfg,
& NetInExtBufCfg,
& NetDirBufCfg,
& UserLibDirBufCfg,
& LibNameBufCfg,
& EquivNameBufCfg,
& DisplayPadFillCfg,
& DisplayPadNumCfg,
& DisplayPadNoConnCfg,
& DisplayPadIsolCfg,
& DisplayModEdgeCfg,
& DisplayModTextCfg,
& DisplayPcbTrackFillCfg,
NULL
};
......@@ -2,58 +2,73 @@
/* class_cvpcb.cpp */
/*******************/
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "fctsys.h"
#include "kicad_string.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "cvpcb.h"
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <wx/listimpl.cpp>
#include "fctsys.h"
#include "common.h"
#include "cvpcb.h"
WX_DEFINE_LIST( PIN_LIST );
STORECMP::STORECMP()
PIN::PIN()
{
Pnext = Pback = NULL;
m_Type = STRUCT_COMPONENT;
m_Pins = NULL;
m_Num = 0;
m_Multi = 0;
m_Index = 0; /* variable utilisee selon types de netlistes */
m_PinType = 0; /* code type electrique ( Entree Sortie Passive..) */
}
int compare( const PIN** item1, const PIN** item2 )
{
return StrLenNumICmp( (*item1)->m_PinNum.GetData(),
(*item2)->m_PinNum.GetData(), 4 );
}
bool same_pin_number( const PIN* item1, const PIN* item2 )
{
wxASSERT( item1 != NULL && item2 != NULL );
return ( item1->m_PinNum == item2->m_PinNum );
}
STORECMP::~STORECMP()
bool same_pin_net( const PIN* item1, const PIN* item2 )
{
STOREPIN * Pin, * NextPin;
wxASSERT( item1 != NULL && item2 != NULL );
for( Pin = m_Pins; Pin != NULL; Pin = NextPin )
{
NextPin = Pin->Pnext; delete Pin;
}
return ( item1->m_PinNet == item2->m_PinNet );
}
WX_DEFINE_LIST( COMPONENT_LIST );
STOREMOD::STOREMOD()
COMPONENT::COMPONENT()
{
Pnext = Pback = NULL;
m_Type = STRUCT_MODULE;
m_Num = 0;
m_Multi = 0;
}
COMPONENT::~COMPONENT()
{
m_Pins.DeleteContents( true );
m_Pins.Clear();
}
STOREPIN::STOREPIN()
int compare( const COMPONENT** item1, const COMPONENT** item2 )
{
m_Type = STRUCT_PIN; /* Type de la structure */
Pnext = NULL; /* Chainage avant */
m_Index = 0; /* variable utilisee selon types de netlistes */
m_PinType = 0; /* code type electrique ( Entree Sortie Passive..) */
return StrNumICmp( (*item1)->m_Reference.GetData(),
(*item2)->m_Reference.GetData() );
}
WX_DEFINE_LIST( FOOTPRINT_LIST );
FOOTPRINT::FOOTPRINT()
{
m_Num = 0;
}
int compare( const FOOTPRINT** item1, const FOOTPRINT** item2 )
{
return StrNumICmp( (*item1)->m_Module.GetData(),
(*item2)->m_Module.GetData() );
}
This diff is collapsed.
......@@ -22,53 +22,20 @@
/* Constant string definitions for CvPcb */
const wxString ComponentFileExtension( wxT( "cmp" ) );
const wxString RetroFileExtension( wxT( "stf" ) );
const wxString EquivFileExtension( wxT( "equ" ) );
const wxString FootprintAliasFileExtension( wxT( "equ" ) );
// Wildcard for footprint libraries filesnames
const wxString g_FootprintLibFileWildcard( wxT( "Kicad footprint library file " \
"(*.mod)|*.mod" ) );
// Wildcard for schematic retroannotation (import footprint names in schematic):
const wxString RetroFileWildcard( _( "Kicad component list files (*.stf)|*.stf" ) );
// Wildcard for alias footprint files
const wxString EquivFileWildcard( _( "Kicad footprint alias files (*.equ)|*.equ" ) );
const wxString RetroFileWildcard( _( "Kicad component list files " \
"(*.stf)|*.stf" ) );
const wxString FootprintAliasFileWildcard( _( "Kicad footprint alias files " \
"(*.equ)|*.equ" ) );
const wxString titleLibLoadError( _( "Library Load Error" ) );
/* Global variables used in CVPcb. */
int g_FlagEESchema;
int Rjustify;
int modified;
int nbcomp;
int nblib;
int composants_non_affectes;
// Option to keep cvpcb open after saving netlist files
bool g_KeepCvpcbOpen = false;
STOREMOD* g_BaseListePkg = NULL;
STORECMP* g_BaseListeCmp = NULL;
wxString g_UserNetDirBuffer; // Netlist path (void = current working directory)
wxString g_NetlistFileExtension;
wxArrayString g_ListName_Equ; // list of .equ files to load
/* Name of the document footprint list
* usually located in share/modules/footprints_doc
* this is of the responsability to users to create this file
* if they want to have a list of footprints
*/
wxString g_DocModulesFileName = DEFAULT_FOOTPRINTS_LIST_FILENAME;
// Create a new application object
IMPLEMENT_APP( WinEDA_App )
/* fonctions locales */
/************************************/
/* Called to initialize the program */
......@@ -105,17 +72,10 @@ bool WinEDA_App::OnInit()
wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion();
frame = new WinEDA_CvpcbFrame( Title );
msg.Printf( wxT( "Modules: %d" ), nblib );
frame->SetStatusText( msg, 2 );
// Show the frame
SetTopWindow( frame );
Read_Config( fn.GetFullPath() );
long tmp;
if ( wxGetApp().m_EDA_CommonConfig->Read( CLOSE_OPTION_KEY, & tmp) )
g_KeepCvpcbOpen = tmp;
frame->LoadProjectFile( fn.GetFullPath() );
frame->Show( TRUE );
frame->BuildFootprintListBox();
......@@ -125,13 +85,13 @@ bool WinEDA_App::OnInit()
if( frame->ReadNetList() )
{
g_NetlistFileExtension = fn.GetExt();
frame->m_NetlistFileExtension = fn.GetExt();
return true;
}
}
listlib();
g_NetlistFileExtension = wxT( "net" );
LoadFootprintFiles( frame->m_ModuleLibNames, frame->m_footprints );
frame->m_NetlistFileExtension = wxT( "net" );
frame->m_NetlistFileName.Clear();
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() +
wxGetCwd() + wxFileName::GetPathSeparator() +
......
......@@ -8,12 +8,8 @@
#include "pcbcommon.h"
// config for footprints doc file acces
#define DOC_FOOTPRINTS_LIST_KEY wxT( "footprints_doc_file" )
#define DEFAULT_FOOTPRINTS_LIST_FILENAME wxT( "footprints_doc/footprints.pdf" )
// option key to close cvpcb after saving files
#define CLOSE_OPTION_KEY wxT( "KeepCvpcbOpen" )
// Define print format to display a schematic component line
#define CMP_FORMAT wxT( "%3d %8s - %16s : %-.32s" )
......@@ -27,19 +23,9 @@
#define TYPE_VIEWLOGIC_NET 4
enum TypeOfStruct {
STRUCT_NOT_INIT,
STRUCT_COMPONENT,
STRUCT_PIN,
STRUCT_MODULE,
STRUCT_PSEUDOMODULE
};
class STOREPIN
class PIN
{
public:
int m_Type; /* Type de la structure */
STOREPIN* Pnext; /* Chainage avant */
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 */
......@@ -47,18 +33,25 @@ public:
wxString m_PinName;
wxString m_Repere; /* utilise selon formats de netliste */
STOREPIN();
PIN();
};
class STORECMP
WX_DECLARE_LIST( PIN, PIN_LIST );
/* PIN object list sort function. */
extern int compare( 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 );
class COMPONENT
{
public:
int m_Type; /* Type de la structure */
STORECMP* Pnext; /* Chainage avant */
STORECMP* Pback; /* Chainage arriere */
int m_Num; /* Numero d'ordre */
int m_Multi; /* Nombre d' unites par boitier */
STOREPIN* m_Pins; /* pointeur sur la liste des Pins */
PIN_LIST m_Pins; /* pointeur sur la liste des Pins */
wxString m_Reference; /* U3, R5 ... */
wxString m_Valeur; /* 7400, 47K ... */
wxString m_TimeStamp; /* Signature temporelle ("00000000" si absente) */
......@@ -67,71 +60,43 @@ public:
wxArrayString m_FootprintFilter; /* List of allowed footprints (wildcart allowed
* if void: no filtering */
STORECMP();
~STORECMP();
COMPONENT();
~COMPONENT();
};
class STOREMOD
WX_DECLARE_LIST( COMPONENT, COMPONENT_LIST );
/* COMPONENT object list sort function. */
extern int compare( const COMPONENT** item1, const COMPONENT** item2 );
class FOOTPRINT
{
public:
int m_Type; /* Type de la structure */
STOREMOD* Pnext; /* Chainage avant */
STOREMOD* Pback; /* Chainage arriere */
wxString m_Module; /* Nom du module */
wxString m_LibName; /* Nom de la librairie contenant ce module */
int m_Num; /* Numero d'ordre pour affichage sur la liste */
wxString m_Doc; /* Doc associee */
wxString m_KeyWord; /* Mots cles associes */
STOREMOD();
FOOTPRINT();
};
WX_DECLARE_LIST( FOOTPRINT, FOOTPRINT_LIST );
/* FOOTPRINT object list sort function. */
extern int compare( const FOOTPRINT** item1, const FOOTPRINT** item2 );
/* Gestion des noms des librairies */
extern const wxString EquivFileExtension;
extern const wxString FootprintAliasFileExtension;
extern const wxString RetroFileExtension;
extern const wxString ComponentFileExtension;
extern const wxString RetroFileWildcard;
extern const wxString EquivFileWildcard;
extern const wxString FootprintAliasFileWildcard;
extern const wxString titleLibLoadError;
// Wildcard for footprint libraries filesnames
extern const wxString g_FootprintLibFileWildcard;
// Wildcard for schematic retroannotation (import footprint names in schematic):
extern const wxString g_FootprintEquFileWildcard;
/* Name of the document footprint list
* usually located in share/modules/footprints_doc
* this is of the responsability to users to create this file
* if they want to have a list of footprints
*/
extern wxString g_DocModulesFileName;
/* CvPcb global variable definition references. */
extern STOREMOD* g_BaseListePkg;
extern STORECMP* g_BaseListeCmp;
extern wxString g_NetlistFileExtension;
extern wxString g_UserNetDirBuffer;
extern wxArrayString g_ListName_Equ; // list of .equ files to load
extern int g_FlagEESchema;
extern int Rjustify; /* flag pout troncature des noms de Net:
* = 0: debut de chaine conservee (->ORCADPCB2)
* = 1: fin de chaine conservee (->VIEWLOGIC) */
extern int modified; /* Flag != 0 si modif attribution des module. */
extern int nbcomp; /* nombre de composants trouves */
extern int nblib; /* nombre d'empreintes trouvees */
extern int composants_non_affectes; /* nbre de composants non affectes */
extern bool g_KeepCvpcbOpen; // Option to keep cvpcb open after saving netlist files
void Plume( int state );
#endif /* __CVPCB_H__ */
/***********************************************************/
/* wxstruct.h: */
/* cvstruct.h : */
/* descriptions des principales classes derivees utilisees */
/***********************************************************/
......@@ -8,12 +8,13 @@
#include "wx/listctrl.h"
#include <wx/filename.h>
#include "param_config.h"
#include "cvpcb.h"
/* Forward declarations of all top-level window classes. */
class FootprintListBox;
class ListBoxCmp;
class WinEDA_DisplayFrame;
class STORECMP;
#define LIST_BOX_TYPE wxListView
......@@ -25,11 +26,26 @@ class WinEDA_CvpcbFrame : public WinEDA_BasicFrame
{
public:
bool m_KeepCvpcbOpen;
FootprintListBox* m_FootprintList;
ListBoxCmp* m_ListCmp;
WinEDA_DisplayFrame* DrawFrame;
WinEDA_Toolbar* m_HToolBar; // Toolbar horizontal haut d'ecran
wxFileName m_NetlistFileName;
wxArrayString m_ModuleLibNames;
wxArrayString m_AliasLibNames;
wxString m_UserLibraryPath;
wxString m_NetlistFileExtension;
wxString m_DocModulesFileName;
FOOTPRINT_LIST m_footprints;
COMPONENT_LIST m_components;
protected:
int m_undefinedComponentCnt;
bool m_modified;
bool m_rightJustify;
bool m_isEESchemaNetlist;
PARAM_CFG_ARRAY m_projectFileParams;
// Constructor and destructor
public:
......@@ -49,8 +65,6 @@ public:
void ReCreateHToolbar();
virtual void ReCreateMenuBar();
void SetLanguage( wxCommandEvent& event );
void AddFontSelectionMenu( wxMenu* main_menu );
void ProcessFontPreferences( wxCommandEvent& event );
void ToFirstNA( wxCommandEvent& event );
void ToPreviousNA( wxCommandEvent& event );
......@@ -58,11 +72,15 @@ public:
void SaveQuitCvpcb( wxCommandEvent& event );
void LoadNetList( wxCommandEvent& event );
void ConfigCvpcb( wxCommandEvent& event );
void OnKeepOpenOnSave( wxCommandEvent& event );
void DisplayModule( wxCommandEvent& event );
void AssocieModule( wxCommandEvent& event );
void WriteStuffList( wxCommandEvent& event );
void DisplayDocFile( wxCommandEvent& event );
void OnSelectFilteringFootprint( wxCommandEvent& event );
void OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event );
void SetNewPkg( const wxString& package );
void BuildCmpListBox();
void BuildFootprintListBox();
......@@ -75,6 +93,12 @@ public:
int ReadFootprintFilterList( FILE* f );
int ReadViewlogicWirList();
int ReadViewlogicNetList();
void LoadProjectFile( const wxString& FileName );
void SaveProjectFile( const wxString& fileName );
virtual void LoadSettings();
virtual void SaveSettings();
const PARAM_CFG_ARRAY& GetProjectFileParameters( void );
DECLARE_EVENT_TABLE()
};
......@@ -113,8 +137,8 @@ public:
bool m_UseFootprintFullList;
public:
FootprintListBox( WinEDA_CvpcbFrame * parent,
wxWindowID id, const wxPoint &loc, const wxSize &size,
FootprintListBox( WinEDA_CvpcbFrame * parent, wxWindowID id,
const wxPoint &loc, const wxSize &size,
int nbitems, wxString choice[] );
~FootprintListBox();
......@@ -122,8 +146,9 @@ public:
void SetSelection( unsigned index, bool State = TRUE );
void SetString( unsigned linecount, const wxString& text );
void AppendLine( const wxString& text );
void SetFootprintFullList();
void SetFootprintFilteredList( STORECMP* Component );
void SetFootprintFullList( FOOTPRINT_LIST& list );
void SetFootprintFilteredList( COMPONENT* Component,
FOOTPRINT_LIST& list );
void SetActiveFootprintList( bool FullList, bool Redraw = FALSE );
wxString GetSelectedFootprint();
......
......@@ -24,12 +24,14 @@ DIALOG_CVPCB_CONFIG::DIALOG_CVPCB_CONFIG( WinEDA_CvpcbFrame* parent ) :
DIALOG_CVPCB_CONFIG_FBP( parent )
{
wxString title;
wxFileName fn = parent->m_NetlistFileName;
fn.SetExt( ProjectFileExtension );
m_Parent = parent;
m_Config = wxGetApp().m_EDA_CommonConfig;
Init( );
title = _( "from " ) + wxGetApp().m_CurrentOptionFile;
title = _( "Project file: " ) + fn.GetFullPath();
SetTitle( title );
if( GetSizer() )
{
......@@ -44,35 +46,16 @@ void DIALOG_CVPCB_CONFIG::Init()
{
wxString msg;
SetFont( *g_DialogFont );
SetFocus();
m_LibListChanged = false;
m_LibPathChanged = false;
m_UserLibDirBufferImg = g_UserLibDirBuffer; // Save the original lib path
m_UserLibDirBufferImg = m_Parent->m_UserLibraryPath;
// Display current files extension (info)
msg = m_InfoCmpFileExt->GetLabel() + ComponentFileExtension;
m_InfoCmpFileExt->SetLabel( msg );
m_ListLibr->InsertItems( m_Parent->m_ModuleLibNames, 0 );
m_ListEquiv->InsertItems( m_Parent->m_AliasLibNames, 0 );
msg = m_InfoLibFileExt->GetLabel() + ModuleFileExtension;
m_InfoLibFileExt->SetLabel( msg );
msg = m_InfoNetlistFileExt->GetLabel() + g_NetlistFileExtension;
m_InfoNetlistFileExt->SetLabel( msg );
msg = m_InfoEquivFileExt->GetLabel() + EquivFileExtension;
m_InfoEquivFileExt->SetLabel( msg );
msg = m_InfoRetroannotFileExt->GetLabel() + RetroFileExtension;
m_InfoRetroannotFileExt->SetLabel( msg );
m_ListLibr->InsertItems( g_LibName_List, 0 );
m_ListEquiv->InsertItems( g_ListName_Equ, 0 );
// Display current modules doc file:
m_Config->Read( DOC_FOOTPRINTS_LIST_KEY, g_DocModulesFileName );
m_TextHelpModulesFileName->SetValue( g_DocModulesFileName );
m_TextHelpModulesFileName->SetValue( m_Parent->m_DocModulesFileName );
// Load user libs paths:
wxStringTokenizer Token( m_UserLibDirBufferImg, wxT( ";\n\r" ) );
......@@ -93,8 +76,6 @@ void DIALOG_CVPCB_CONFIG::Init()
// select the first path afer the current path project
if( libpaths.GetCount() > 1 )
m_DefaultLibraryPathslistBox->Select( 1 );
m_radioBoxCloseOpt->SetSelection ( g_KeepCvpcbOpen ? 1 : 0 );
}
......@@ -108,9 +89,10 @@ void DIALOG_CVPCB_CONFIG::OnCancelClick( wxCommandEvent& event )
for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
wxGetApp().RemoveLibraryPath( m_listUserPaths->GetString( ii ) );
wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 );
wxGetApp().InsertLibraryPath( m_Parent->m_UserLibraryPath, 1 );
}
EndModal( -1 );
EndModal( wxID_CANCEL );
}
......@@ -118,21 +100,17 @@ void DIALOG_CVPCB_CONFIG::OnCancelClick( wxCommandEvent& event )
void DIALOG_CVPCB_CONFIG::OnOkClick( wxCommandEvent& event )
/**************************************************************/
{
g_KeepCvpcbOpen = m_radioBoxCloseOpt->GetSelection( ) ? true : false;
m_Config->Write( CLOSE_OPTION_KEY, (long) g_KeepCvpcbOpen );
m_Config->Write( DOC_FOOTPRINTS_LIST_KEY,
m_TextHelpModulesFileName->GetValue() );
m_Parent->m_DocModulesFileName = m_TextHelpModulesFileName->GetValue();
// Recreate the user lib path
if( m_LibPathChanged )
{
g_UserLibDirBuffer.Empty();
m_Parent->m_UserLibraryPath.Empty();
for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ )
{
if( ii > 0 )
g_UserLibDirBuffer << wxT( ";" );
g_UserLibDirBuffer << m_listUserPaths->GetString( ii );
m_Parent->m_UserLibraryPath << wxT( ";" );
m_Parent->m_UserLibraryPath << m_listUserPaths->GetString( ii );
}
}
......@@ -141,20 +119,22 @@ void DIALOG_CVPCB_CONFIG::OnOkClick( wxCommandEvent& event )
if( m_LibListChanged || m_LibPathChanged )
{
// Recreate lib list
g_LibName_List.Clear();
m_Parent->m_ModuleLibNames.Clear();
for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
g_LibName_List.Add( m_ListLibr->GetString( ii ) );
m_Parent->m_ModuleLibNames.Add( m_ListLibr->GetString( ii ) );
// Recreate equ list
g_ListName_Equ.Clear();
m_Parent->m_AliasLibNames.Clear();
for( unsigned ii = 0; ii < m_ListEquiv->GetCount(); ii++ )
g_ListName_Equ.Add( m_ListEquiv->GetString( ii ) );
m_Parent->m_AliasLibNames.Add( m_ListEquiv->GetString( ii ) );
listlib();
LoadFootprintFiles( m_Parent->m_ModuleLibNames,
m_Parent->m_footprints );
m_Parent->BuildFootprintListBox();
}
if( event.GetId() != ID_SAVE_CFG )
EndModal( 0 );
m_Parent->SaveProjectFile( m_Parent->m_NetlistFileName.GetFullPath() );
EndModal( wxID_OK );
}
......@@ -209,12 +189,12 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
if( (event.GetId() == ID_INSERT_EQU) || (event.GetId() == ID_INSERT_LIB) )
insert = true;
wildcard = EquivFileWildcard;
wildcard = FootprintAliasFileWildcard;
wxListBox * list = m_ListEquiv;
if( (event.GetId() == ID_ADD_LIB) || (event.GetId() == ID_INSERT_LIB) )
{
list = m_ListLibr;
wildcard = g_FootprintLibFileWildcard;
wildcard = ModuleFileWildcard;
}
ii = list->GetSelection();
......@@ -246,8 +226,8 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of these default paths
*
* because it preserve use of default libraries paths, when the path
* is a sub path of these default paths
*/
if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) != wxNOT_FOUND ) // Ok, trivial case
libfilename = fn.GetName();
......@@ -283,15 +263,6 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
}
/*******************************************************************/
void DIALOG_CVPCB_CONFIG::OnSaveCfgClick( wxCommandEvent& event )
/*******************************************************************/
{
OnOkClick( event );
Save_Config( this, m_Parent->m_NetlistFileName.GetFullPath() );
}
/***********************************************************************/
void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
/***********************************************************************/
......@@ -370,16 +341,14 @@ void DIALOG_CVPCB_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
void DIALOG_CVPCB_CONFIG::OnBrowseModDocFile( wxCommandEvent& event )
/**************************************************************************/
{
wxString FullFileName, mask;
wxString FullFileName;
wxString docpath, filename;
docpath = wxGetApp().ReturnLastVisitedLibraryPath( wxT( "doc" ) );
mask = wxT( "*.pdf" );
wxFileDialog FilesDialog( this, _( "Footprint document file:" ), docpath,
wxEmptyString, mask,
wxFD_DEFAULT_STYLE );
wxEmptyString, PdfFileWildcard,
wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
if( FilesDialog.ShowModal() != wxID_OK )
return;
......@@ -390,7 +359,8 @@ void DIALOG_CVPCB_CONFIG::OnBrowseModDocFile( wxCommandEvent& event )
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of these default paths
* because it preserve use of default libraries paths, when the path is
* a sub path of these default paths
*/
wxFileName fn = FullFileName;
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
......
......@@ -26,7 +26,6 @@ private:
void OnCloseWindow( wxCloseEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnSaveCfgClick( wxCommandEvent& event );
void OnAddOrInsertLibClick( wxCommandEvent& event );
void OnRemoveLibClick( wxCommandEvent& event );
void OnBrowseModDocFile( wxCommandEvent& event );
......
This diff is collapsed.
This diff is collapsed.
......@@ -11,18 +11,16 @@
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/button.h>
#include <wx/listbox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/stattext.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/listbox.h>
#include <wx/statline.h>
#include <wx/textctrl.h>
#include <wx/statline.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
......@@ -37,8 +35,7 @@ class DIALOG_CVPCB_CONFIG_FBP : public wxDialog
protected:
enum
{
ID_SAVE_CFG = 1000,
ID_ADD_LIB,
ID_ADD_LIB = 1000,
ID_INSERT_LIB,
ID_REMOVE_LIB,
ID_ADD_EQU,
......@@ -50,50 +47,39 @@ class DIALOG_CVPCB_CONFIG_FBP : public wxDialog
ID_REMOVE_PATH,
};
wxButton* m_buttonOk;
wxButton* m_buttonCancel;
wxButton* m_buttonSave;
wxStaticText* m_InfoCmpFileExt;
wxStaticText* m_InfoLibFileExt;
wxStaticText* m_InfoNetlistFileExt;
wxStaticText* m_InfoEquivFileExt;
wxStaticText* m_InfoRetroannotFileExt;
wxRadioBox* m_radioBoxCloseOpt;
wxStaticText* m_staticTextlibList;
wxListBox* m_ListLibr;
wxButton* m_buttonAddLib;
wxButton* m_buttonInsLib;
wxButton* m_buttonRemoveLib;
wxListBox* m_ListLibr;
wxStaticText* m_staticTextEquList;
wxListBox* m_ListEquiv;
wxButton* m_buttonAddEqu;
wxButton* m_buttonInsEqu;
wxButton* m_buttonRemoveEqu;
wxListBox* m_ListEquiv;
wxStaticLine* m_staticline1;
wxTextCtrl* m_TextHelpModulesFileName;
wxButton* m_buttonModDoc;
wxListBox* m_listUserPaths;
wxButton* m_buttonAddPath;
wxButton* m_buttonInsPath;
wxButton* m_buttonRemovePath;
wxStaticText* m_staticTextcurrenpaths;
wxListBox* m_DefaultLibraryPathslistBox;
wxStaticLine* m_staticline2;
wxStdDialogButtonSizer* m_sdbSizer2;
wxButton* m_sdbSizer2OK;
wxButton* m_sdbSizer2Cancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnSaveCfgClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnAddOrInsertLibClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnRemoveLibClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnBrowseModDocFile( wxCommandEvent& event ){ event.Skip(); }
virtual void OnAddOrInsertPath( wxCommandEvent& event ){ event.Skip(); }
virtual void OnRemoveUserPath( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
public:
DIALOG_CVPCB_CONFIG_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 641,612 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_CVPCB_CONFIG_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_CVPCB_CONFIG_FBP();
};
......
......@@ -57,8 +57,6 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_FootprintDisplayOptionsFrame, wxDialog )
BEGIN_EVENT_TABLE( WinEDA_FootprintDisplayOptionsFrame, wxDialog )
////@begin WinEDA_FootprintDisplayOptionsFrame event table entries
EVT_BUTTON( ID_SAVE_CONFIG, WinEDA_FootprintDisplayOptionsFrame::OnSaveConfigClick )
EVT_BUTTON( wxID_OK, WinEDA_FootprintDisplayOptionsFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_FootprintDisplayOptionsFrame::OnCancelClick )
......@@ -98,7 +96,6 @@ bool WinEDA_FootprintDisplayOptionsFrame::Create( wxWindow* parent, wxWindowID i
ColumnBoxSizer = NULL;
m_IsShowPadFill = NULL;
m_IsShowPadNum = NULL;
BottomBoxSizer = NULL;
m_CancelButton = NULL;
////@end WinEDA_FootprintDisplayOptionsFrame member initialisation
......@@ -122,10 +119,8 @@ bool WinEDA_FootprintDisplayOptionsFrame::Create( wxWindow* parent, wxWindowID i
void WinEDA_FootprintDisplayOptionsFrame::CreateControls()
{
SetFont(*g_DialogFont);
////@begin WinEDA_FootprintDisplayOptionsFrame content construction
// Generated by DialogBlocks, 21/07/2008 15:12:47 (unregistered)
// Generated by DialogBlocks, 16/04/2009 14:23:49 (unregistered)
WinEDA_FootprintDisplayOptionsFrame* itemDialog1 = this;
......@@ -152,40 +147,34 @@ void WinEDA_FootprintDisplayOptionsFrame::CreateControls()
MainBoxSizer->Add(m_TextDisplayOption, 0, wxALIGN_TOP|wxALL, 5);
ColumnBoxSizer = new wxBoxSizer(wxVERTICAL);
MainBoxSizer->Add(ColumnBoxSizer, 1, wxALIGN_TOP|wxLEFT|wxRIGHT|wxTOP, 5);
MainBoxSizer->Add(ColumnBoxSizer, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_IsShowPadFill = new wxCheckBox( itemDialog1, PADFILL_OPT, _("&Pad Filled"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_IsShowPadFill = new wxCheckBox( itemDialog1, PADFILL_OPT, _("Fill &pad"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_IsShowPadFill->SetValue(false);
ColumnBoxSizer->Add(m_IsShowPadFill, 1, wxGROW|wxALL, 5);
m_IsShowPadNum = new wxCheckBox( itemDialog1, PADNUM_OPT, _("Display Pad &Num"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_IsShowPadNum = new wxCheckBox( itemDialog1, PADNUM_OPT, _("Show pad &number"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_IsShowPadNum->SetValue(false);
if (WinEDA_FootprintDisplayOptionsFrame::ShowToolTips())
m_IsShowPadNum->SetToolTip(_("Display pad number"));
ColumnBoxSizer->Add(m_IsShowPadNum, 1, wxGROW|wxALL, 5);
ColumnBoxSizer->Add(5, 5, 0, wxGROW|wxTOP, 5);
wxButton* itemButton10 = new wxButton( itemDialog1, ID_SAVE_CONFIG, _("Save Cfg"), wxDefaultPosition, wxDefaultSize, 0 );
ColumnBoxSizer->Add(itemButton10, 0, wxALIGN_LEFT|wxALL, 5);
wxStaticLine* itemStaticLine11 = new wxStaticLine( itemDialog1, ID_STATICLINE1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
OuterBoxSizer->Add(itemStaticLine11, 0, wxGROW|wxALL, 5);
wxStaticLine* itemStaticLine9 = new wxStaticLine( itemDialog1, ID_STATICLINE1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
OuterBoxSizer->Add(itemStaticLine9, 0, wxGROW|wxALL, 5);
BottomBoxSizer = new wxBoxSizer(wxHORIZONTAL);
OuterBoxSizer->Add(BottomBoxSizer, 0, wxALIGN_RIGHT|wxALL, 5);
wxStdDialogButtonSizer* itemStdDialogButtonSizer10 = new wxStdDialogButtonSizer;
wxButton* itemButton13 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton13->SetDefault();
itemButton13->SetForegroundColour(wxColour(255, 0, 0));
BottomBoxSizer->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
OuterBoxSizer->Add(itemStdDialogButtonSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxButton* itemButton11 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemStdDialogButtonSizer10->AddButton(itemButton11);
m_CancelButton = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
m_CancelButton->SetForegroundColour(wxColour(0, 0, 255));
BottomBoxSizer->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemStdDialogButtonSizer10->AddButton(m_CancelButton);
wxButton* itemButton15 = new wxButton( itemDialog1, wxID_APPLY, _("&Apply"), wxDefaultPosition, wxDefaultSize, 0 );
BottomBoxSizer->Add(itemButton15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton13 = new wxButton( itemDialog1, wxID_APPLY, _("&Apply"), wxDefaultPosition, wxDefaultSize, 0 );
itemStdDialogButtonSizer10->AddButton(itemButton13);
itemStdDialogButtonSizer10->Realize();
// Set validators
m_EdgesDisplayOption->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModEdge) );
......@@ -240,33 +229,14 @@ void WinEDA_FootprintDisplayOptionsFrame::UpdateObjectSettings(void)
{
// Update settings
////@begin WinEDA_FootprintDisplayOptionsFrame update settings
DisplayOpt.DisplayModEdge = m_Parent->m_DisplayModEdge =
m_EdgesDisplayOption->GetSelection();
DisplayOpt.DisplayModText = m_Parent->m_DisplayModText =
m_TextDisplayOption->GetSelection();
DisplayOpt.DisplayPadNum = m_Parent->m_DisplayPadNum =
m_IsShowPadNum->GetValue();
DisplayOpt.DisplayPadFill = m_Parent->m_DisplayPadFill =
m_IsShowPadFill->GetValue();
m_Parent->m_DisplayModEdge = m_EdgesDisplayOption->GetSelection();
m_Parent->m_DisplayModText = m_TextDisplayOption->GetSelection();
m_Parent->m_DisplayPadNum = m_IsShowPadNum->GetValue();
m_Parent->m_DisplayPadFill = m_IsShowPadFill->GetValue();
m_Parent->DrawPanel->Refresh();
////@end WinEDA_FootprintDisplayOptionsFrame update settings
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SAVE_CONFIG
*/
void WinEDA_FootprintDisplayOptionsFrame::OnSaveConfigClick( wxCommandEvent& event )
{
WinEDA_CvpcbFrame* parent = ( WinEDA_CvpcbFrame* )GetParent();
wxASSERT( parent && parent->IsKindOf( CLASSINFO( WinEDA_CvpcbFrame ) ) );
Save_Config( this, parent->m_NetlistFileName.GetFullPath() );
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
......
......@@ -45,7 +45,6 @@ class wxBoxSizer;
#define TEXT_SELECT 10002
#define PADFILL_OPT 10003
#define PADNUM_OPT 10004
#define ID_SAVE_CONFIG 10005
#define ID_STATICLINE1 10006
#define SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_TITLE _("Display Options")
......@@ -84,9 +83,6 @@ public:
////@begin WinEDA_FootprintDisplayOptionsFrame event handler declarations
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SAVE_CONFIG
void OnSaveConfigClick( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
void OnOkClick( wxCommandEvent& event );
......@@ -120,7 +116,6 @@ public:
wxBoxSizer* ColumnBoxSizer;
wxCheckBox* m_IsShowPadFill;
wxCheckBox* m_IsShowPadNum;
wxBoxSizer* BottomBoxSizer;
wxButton* m_CancelButton;
////@end WinEDA_FootprintDisplayOptionsFrame member variables
......
This diff is collapsed.
......@@ -22,7 +22,7 @@
/* Construction de la table des evenements pour WinEDA_DrawFrame */
/*****************************************************************/
BEGIN_EVENT_TABLE( WinEDA_DisplayFrame, WinEDA_DrawFrame )
BEGIN_EVENT_TABLE( WinEDA_DisplayFrame, WinEDA_BasePcbFrame )
EVT_CLOSE( WinEDA_DisplayFrame::OnCloseWindow )
EVT_SIZE( WinEDA_DrawFrame::OnSize )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_DisplayFrame::OnZoom )
......
......@@ -17,12 +17,13 @@
void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event )
{
COMPONENT_LIST::iterator i;
FILE* FileEquiv;
STORECMP* Cmp;
COMPONENT* Cmp;
wxString Line;
wxFileName fn = m_NetlistFileName;
if( nbcomp <= 0 )
if( m_components.GetCount() <= 0 )
return;
/* calcul du nom du fichier */
......@@ -45,8 +46,10 @@ void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event )
}
/* Generation de la liste */
for( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = Cmp->Pnext )
for( i = m_components.begin(); i != m_components.end(); ++i )
{
Cmp = *i;
/* gnration du composant si son empreinte est dfinie */
if( Cmp->m_Module.IsEmpty() )
continue;
......
/***************/
/* genorcad() */
/***************/
/***************/
/* genorcad() */
/***************/
/*
Complte la netliste (*.NET) en y placant les ref *.lib FORMAT ORCADPCB
La valeur (Part Value) est tronquee a 16 lettres
*/
* Complte la netliste (*.NET) en y placant les ref *.lib FORMAT ORCADPCB
* La valeur (Part Value) est tronquee a 16 lettres
*/
#include "fctsys.h"
......@@ -17,43 +17,43 @@ La valeur (Part Value) est tronquee a 16 lettres
#define MAX_LEN_NETNAME 16
/* Routines locales */
static void TriPinsModule( STORECMP * CurrentCmp );
static int PinCompare(const void *cmp1, const void *cmp2);
static void ChangePinNet( wxString & PinNet );
static void TriPinsModule( COMPONENT* CurrentCmp );
static void ChangePinNet( wxString& PinNet, bool rightJustify );
/* Variables Locales */
int NetNumCode; /* Nombre utilise pour cree des NetNames lors de
reaffectation de NetNames */
* reaffectation de NetNames */
int genorcad()
int genorcad( bool rightJustify )
{
char Line[1024];
STOREPIN * Pin;
STORECMP * CurrentCmp;
wxString Title = wxGetApp().GetAppName() + wxT(" ") + GetBuildVersion();
PIN* Pin;
COMPONENT* CurrentCmp;
wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
NetNumCode = 1; DateAndTime(Line);
fprintf(dest,"( { Netlist by %s, date = %s }\n",
CONV_TO_UTF8(Title), Line ) ;
NetNumCode = 1; DateAndTime( Line );
fprintf( dest, "( { Netlist by %s, date = %s }\n",
CONV_TO_UTF8( Title ), Line );
/***********************/
/* Lecture de la liste */
/***********************/
CurrentCmp = BaseListeCmp;
for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext)
for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext )
{
fprintf(dest," ( %s ", CONV_TO_UTF8(CurrentCmp->m_TimeStamp));
fprintf( dest, " ( %s ", CONV_TO_UTF8( CurrentCmp->m_TimeStamp ) );
if( ! CurrentCmp->m_Module.IsEmpty() )
fprintf(dest, CONV_TO_UTF8(CurrentCmp->m_Module));
if( !CurrentCmp->m_Module.IsEmpty() )
fprintf( dest, CONV_TO_UTF8( CurrentCmp->m_Module ) );
else fprintf(dest,"$noname$") ;
else
fprintf( dest, "$noname$" );
fprintf(dest," %s ",CONV_TO_UTF8(CurrentCmp->m_Reference)) ;
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_Valeur ) );
/* Tri des pins */
TriPinsModule( CurrentCmp );
......@@ -62,67 +62,74 @@ int genorcad()
Pin = CurrentCmp->m_Pins;
for( ; Pin != NULL; Pin = Pin->Pnext )
{
if( Pin->m_PinNet.Len() > MAX_LEN_NETNAME)
ChangePinNet( Pin->m_PinNet );
if( Pin->m_PinNet.Len() > MAX_LEN_NETNAME )
ChangePinNet( Pin->m_PinNet, rightJustify );
if( ! Pin->m_PinNet.IsEmpty() )
fprintf(dest," ( %s %s )\n",
CONV_TO_UTF8(Pin->m_PinNum),
CONV_TO_UTF8(Pin->m_PinNet));
if( !Pin->m_PinNet.IsEmpty() )
fprintf( dest, " ( %s %s )\n",
CONV_TO_UTF8( Pin->m_PinNum ),
CONV_TO_UTF8( Pin->m_PinNet ) );
else
fprintf(dest," ( %s ? )\n", CONV_TO_UTF8(Pin->m_PinNum));
fprintf( dest, " ( %s ? )\n", CONV_TO_UTF8( Pin->m_PinNum ) );
}
fprintf(dest," )\n");
fprintf( dest, " )\n" );
}
fprintf(dest,")\n*\n");
fclose(dest);
return(0);
}
fprintf( dest, ")\n*\n" );
fclose( dest );
return 0;
}
/***********************************************/
static void TriPinsModule( STORECMP * CurrentCmp )
static void TriPinsModule( COMPONENT* CurrentCmp )
/***********************************************/
/* Tri et controle des pins du module CurrentCmp
*/
*/
{
STOREPIN * Pin, * NextPin, ** BasePin;
int nbpins = 0, ii;
PIN* Pin, * NextPin, ** BasePin;
int nbpins = 0, ii;
Pin = CurrentCmp->m_Pins;
if( Pin == NULL ) return;
if( Pin == NULL )
return;
/* comptage des pins */
for( ; Pin != NULL ; Pin = Pin->Pnext ) nbpins++;
for( ; Pin != NULL; Pin = Pin->Pnext )
nbpins++;
/* Tri des pins: etablissement de la liste des pointeurs */
BasePin = (STOREPIN ** )MyZMalloc( nbpins * sizeof(STOREPIN*) );
BasePin = (PIN**) MyZMalloc( nbpins * sizeof(PIN*) );
Pin = CurrentCmp->m_Pins;
for( ii = 0 ; ii < nbpins ; ii++, Pin = Pin->Pnext )
for( ii = 0; ii < nbpins; ii++, Pin = Pin->Pnext )
{
BasePin[ii] = Pin;
}
/* Tri des Pins */
qsort( BasePin, nbpins, sizeof( STORECMP*), PinCompare) ;
qsort( BasePin, nbpins, sizeof( COMPONENT*), PinCompare );
/* Remise a jour des pointeurs chaines */
for( ii = 0 ; ii < nbpins-1 ; ii++ )
for( ii = 0; ii < nbpins - 1; ii++ )
{
BasePin[ii]->Pnext = BasePin[ii+1];
BasePin[ii]->Pnext = BasePin[ii + 1];
}
BasePin[ii]->Pnext = NULL;
CurrentCmp->m_Pins = BasePin[0];
MyFree(BasePin);
MyFree( BasePin );
/* Elimination des redondances */
Pin = CurrentCmp->m_Pins;
while( Pin != NULL)
while( Pin != NULL )
{
NextPin = Pin->Pnext;
if ( NextPin == NULL ) break;
if( NextPin == NULL )
break;
if( Pin->m_PinNum != NextPin->m_PinNum )
{
Pin = Pin->Pnext; continue;
......@@ -131,10 +138,11 @@ int nbpins = 0, ii;
if( Pin->m_PinNet != NextPin->m_PinNet )
{
wxString msg;
msg.Printf( _("%s %s pin %s : Different Nets"),
CurrentCmp->m_Reference.GetData(),CurrentCmp->m_Valeur.GetData(),
Pin->m_PinNum.GetData());
DisplayError(NULL, msg, 60 );
msg.Printf( _( "%s %s pin %s : Different Nets" ),
CurrentCmp->m_Reference.GetData(),
CurrentCmp->m_Valeur.GetData(),
Pin->m_PinNum.GetData() );
DisplayError( NULL, msg, 60 );
}
Pin->Pnext = NextPin->Pnext;
delete NextPin;
......@@ -142,60 +150,41 @@ int nbpins = 0, ii;
}
/*******************************************************/
static int PinCompare(const void *cmp1,const void *cmp2)
/*******************************************************/
/*
routine PinCompare() pour qsort() pour classement alphabetique
pour tri de la liste des Pins
*/
{
STOREPIN **pt1 , **pt2 ;
int ii;
pt1 = (STOREPIN**)cmp1;
pt2 = (STOREPIN**)cmp2;
ii = StrLenNumICmp( (*pt1)->m_PinNum.GetData(), (*pt2)->m_PinNum.GetData(), 4);
return(ii);
}
/*******************************************/
static void ChangePinNet( wxString & PinNet )
static void ChangePinNet( wxString& PinNet, bool rightJustify )
/*******************************************/
/* Change le NetName PinNet par un nom compose des 8 derniers codes de PinNet
suivi de _Xnnnnn ou nnnnn est un nom de 0 a 99999
*/
* suivi de _Xnnnnn ou nnnnn est un nom de 0 a 99999
*/
{
STOREPIN * Pin;
STORECMP * CurrentCmp;
int ii;
wxString OldName;
wxString NewName;
PIN* Pin;
COMPONENT* CurrentCmp;
int ii;
wxString OldName;
wxString NewName;
OldName = PinNet;
ii = PinNet.Len();
if( Rjustify ) /* On conserve les 8 dernieres lettres du nom */
if( rightJustify ) /* On conserve les 8 dernieres lettres du nom */
{
NewName= OldName.Right(8); NewName << NetNumCode;
NewName = OldName.Right( 8 ); NewName << NetNumCode;
}
else /* On conserve les 8 premieres lettres du nom */
{
NewName = OldName.Left(8); NewName << NetNumCode;
NewName = OldName.Left( 8 ); NewName << NetNumCode;
}
NetNumCode ++;
NetNumCode++;
CurrentCmp = BaseListeCmp;
for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext)
for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext )
{
Pin = CurrentCmp->m_Pins;
for( ; Pin != NULL; Pin = Pin->Pnext )
{
if( Pin->m_PinNet != OldName ) continue;
if( Pin->m_PinNet != OldName )
continue;
Pin->m_PinNet = NewName;
}
}
}
......@@ -19,20 +19,19 @@
/* routines locales : */
/**********************************************************/
void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
/*********************************************************/
/*
* - Affecte un module au composant selectionne
* - Selectionne le composant suivant
*/
void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
{
STORECMP* Composant;
int ii, NumCmp, IsNew = 1;
COMPONENT_LIST::iterator i;
COMPONENT* Component;
bool isUndefined = false;
int NumCmp;
wxString Line;
if( g_BaseListeCmp == NULL )
if( m_components.empty() )
return;
NumCmp = m_ListCmp->GetSelection();
......@@ -42,26 +41,22 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
m_ListCmp->SetSelection( NumCmp, TRUE );
}
Composant = g_BaseListeCmp;
for( ii = 0; Composant != NULL; Composant = Composant->Pnext, ii++ )
{
if( NumCmp == ii )
break;
}
Component = m_components[ NumCmp ];
if( Composant == NULL )
if( Component == NULL )
return;
if( !Composant->m_Module.IsEmpty() )
IsNew = 0;
Composant->m_Module = package;
isUndefined = Component->m_Module.IsEmpty();
Component->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;
Line.Printf( CMP_FORMAT, NumCmp + 1,
Component->m_Reference.GetData(), Component->m_Valeur.GetData(),
Component->m_Module.GetData() );
m_modified = true;
if( isUndefined )
m_undefinedComponentCnt -= 1;
m_ListCmp->SetString( NumCmp, Line );
m_ListCmp->SetSelection( NumCmp, FALSE );
......@@ -72,21 +67,20 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
m_ListCmp->SetSelection( NumCmp, TRUE );
Line.Printf( _( "Components: %d (free: %d)" ),
nbcomp, composants_non_affectes );
m_components.GetCount(), m_undefinedComponentCnt );
SetStatusText( Line, 1 );
}
/********************************************/
bool WinEDA_CvpcbFrame::ReadNetList()
/*******************************************/
/* Lecture de la netliste selon format, ainsi que du fichier des composants
/*
* Lecture de la netliste selon format, ainsi que du fichier des composants
*/
bool WinEDA_CvpcbFrame::ReadNetList()
{
STORECMP* Composant;
COMPONENT_LIST::iterator i;
COMPONENT* Component;
wxString msg;
int ii;
int error_level;
error_level = ReadSchematicNetlist();
......@@ -101,36 +95,35 @@ bool WinEDA_CvpcbFrame::ReadNetList()
}
/* lecture des correspondances */
loadcmp( m_NetlistFileName.GetFullPath() );
LoadComponentFile( m_NetlistFileName.GetFullPath(), m_components );
if( m_ListCmp == NULL )
return false;
Read_Config( m_NetlistFileName.GetFullPath() );
listlib();
LoadProjectFile( m_NetlistFileName.GetFullPath() );
LoadFootprintFiles( m_ModuleLibNames, m_footprints );
BuildFootprintListBox();
m_ListCmp->Clear();
Composant = g_BaseListeCmp;
composants_non_affectes = 0;
for( ii = 1; Composant != NULL; Composant = Composant->Pnext, ii++ )
m_undefinedComponentCnt = 0;
for( i = m_components.begin(); i != m_components.end(); ++i )
{
msg.Printf( CMP_FORMAT, ii,
Composant->m_Reference.GetData(),
Composant->m_Valeur.GetData(),
Composant->m_Module.GetData() );
Component = *i;
msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
Component->m_Reference.GetData(),
Component->m_Valeur.GetData(),
Component->m_Module.GetData() );
m_ListCmp->AppendLine( msg );
if( Composant->m_Module.IsEmpty() )
composants_non_affectes += 1;
if( Component->m_Module.IsEmpty() )
m_undefinedComponentCnt += 1;
}
if( g_BaseListeCmp )
if( !m_components.empty() )
m_ListCmp->SetSelection( 0, TRUE );
msg.Printf( _( "Components: %d (free: %d)" ), nbcomp,
composants_non_affectes );
msg.Printf( _( "Components: %d (free: %d)" ), m_components.GetCount(),
m_undefinedComponentCnt );
SetStatusText( msg, 1 );
/* Mise a jour du titre de la fenetre principale */
......@@ -140,14 +133,12 @@ bool WinEDA_CvpcbFrame::ReadNetList()
}
/*****************************************************************/
int WinEDA_CvpcbFrame::SaveNetList( const wxString& fileName )
/*****************************************************************/
/* Sauvegarde des fichiers netliste et cmp
/*
* Sauvegarde des fichiers netliste et cmp
* Le nom complet du fichier Netliste doit etre dans FFileName.
* Le nom du fichier cmp en est deduit
*/
int WinEDA_CvpcbFrame::SaveNetList( const wxString& fileName )
{
wxFileName fn;
......@@ -177,7 +168,8 @@ int WinEDA_CvpcbFrame::SaveNetList( const wxString& fileName )
return 0;
}
GenNetlistPcbnew( netlist );
GenNetlistPcbnew( netlist, m_components, m_isEESchemaNetlist,
m_rightJustify );
return 1;
}
This diff is collapsed.
......@@ -20,16 +20,11 @@
#include "protos.h"
/* routines locales : */
static void ReadDocLib( const wxString& ModLibName );
static int LibCompare( void* mod1, void* mod2 );
static STOREMOD* TriListeModules( STOREMOD* BaseListe, int nbitems );
static void ReadDocLib( const wxString& ModLibName, FOOTPRINT_LIST& list );
/*********************/
bool listlib()
/*********************/
/* Routine lisant la liste des librairies, et generant la liste chainee
/**
* Routine lisant la liste des librairies, et generant la liste chainee
* des modules disponibles
*
* Module descr format:
......@@ -40,22 +35,25 @@ bool listlib()
* $EndMODULE
*
*/
bool LoadFootprintFiles( const wxArrayString& libNames,
FOOTPRINT_LIST& list )
{
FILE* file; /* pour lecture librairie */
char buffer[1024];
wxFileName fn;
int end;
STOREMOD* ItemLib;
FOOTPRINT* ItemLib;
unsigned ii;
wxString tmp, msg;
if( g_BaseListePkg ) /* Liste Deja existante, a supprimer */
if( !list.empty() )
{
FreeMemoryModules();
g_BaseListePkg = NULL;
list.DeleteContents( true );
list.Clear();
list.DeleteContents( false );
}
if( g_LibName_List.GetCount() == 0 )
if( libNames.GetCount() == 0 )
{
wxMessageBox( _( "No PCB foot print libraries are listed in the " \
"current project file." ), _( "Project File Error" ),
......@@ -63,13 +61,11 @@ bool listlib()
return false;
}
nblib = 0;
/* Lecture des Librairies */
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ )
for( ii = 0; ii < libNames.GetCount(); ii++ )
{
/* Calcul du nom complet de la librairie */
fn = g_LibName_List[ii];
fn = libNames[ii];
fn.SetExt( ModuleFileExtension );
tmp = wxGetApp().FindLibraryPath( fn );
......@@ -122,12 +118,10 @@ bool listlib()
break;
}
ItemLib = new STOREMOD();
ItemLib->Pnext = g_BaseListePkg;
g_BaseListePkg = ItemLib;
ItemLib = new FOOTPRINT();
ItemLib->m_Module = CONV_FROM_UTF8( StrPurge( buffer ) );
ItemLib->m_LibName = tmp;
nblib++;
list.push_back( ItemLib );
}
if( !end )
......@@ -141,104 +135,29 @@ bool listlib()
}
fclose( file );
ReadDocLib( tmp );
ReadDocLib( tmp, list );
}
/* classement alphabetique: */
if( g_BaseListePkg )
g_BaseListePkg = TriListeModules( g_BaseListePkg, nblib );
list.Sort( compare );
return true;
}
/************************************************/
static int LibCompare( void* mod1, void* mod2 )
/************************************************/
/*
* routine compare() pour qsort() en classement alphabtique des modules
*/
{
int ii;
STOREMOD* pt1, * pt2;
pt1 = *( (STOREMOD**) mod1 );
pt2 = *( (STOREMOD**) mod2 );
ii = StrNumICmp( pt1->m_Module.GetData(), pt2->m_Module.GetData() );
return ii;
}
/********************************************************************/
static STOREMOD* TriListeModules( STOREMOD* BaseListe, int nbitems )
/********************************************************************/
/* Tri la liste des Modules par ordre alphabetique et met a jour
* le nouveau chainage avant/arriere
* retourne un pointeur sur le 1er element de la liste
*/
{
STOREMOD** bufferptr, * Item;
int ii, nb;
if( nbitems <= 0 )
return NULL;
if( BaseListe == NULL )
return NULL;
if( nbitems == 1 )
return BaseListe; // Tri inutile et impossible
bufferptr = (STOREMOD**) MyZMalloc( (nbitems + 3) * sizeof(STOREMOD*) );
for( ii = 1, nb = 0, Item = BaseListe;
Item != NULL;
Item = Item->Pnext, ii++ )
{
nb++;
bufferptr[ii] = Item;
}
/* ici bufferptr[0] = NULL et bufferptr[nbitem+1] = NULL et ces 2 valeurs
* representent le chainage arriere du 1er element ( = NULL),
* et le chainage avant du dernier element ( = NULL ) */
qsort( bufferptr + 1, nb, sizeof(STOREMOD*),
( int( * ) ( const void*, const void* ) )LibCompare );
/* Mise a jour du chainage */
for( ii = 1; ii <= nb; ii++ )
{
Item = bufferptr[ii];
Item->m_Num = ii;
Item->Pnext = bufferptr[ii + 1];
Item->Pback = bufferptr[ii - 1];
}
Item = bufferptr[1];
MyFree( bufferptr );
return Item;
}
/***************************************************/
static void ReadDocLib( const wxString& ModLibName )
/***************************************************/
/* Routine de lecture du fichier Doc associe a la librairie ModLibName.
* Cree en memoire la chaine liste des docs pointee par MList
* ModLibName = full file Name de la librairie Modules
*/
static void ReadDocLib( const wxString& ModLibName, FOOTPRINT_LIST& list )
{
STOREMOD* NewMod;
FOOTPRINT* NewMod;
FOOTPRINT* tmp;
char Line[1024];
wxString ModuleName;
wxString msg;
FILE* LibDoc;
wxFileName fn = ModLibName;
FOOTPRINT_LIST::iterator i;
fn.SetExt( wxT( "mdc" ) );
......@@ -277,12 +196,15 @@ static void ReadDocLib( const wxString& ModLibName )
{
case 'L': /* LibName */
ModuleName = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
NewMod = g_BaseListePkg;
while( NewMod )
for( i = list.begin(); i != list.end(); ++i )
{
tmp = *i;
if( ModuleName == tmp->m_Module )
{
if( ModuleName == NewMod->m_Module )
NewMod = tmp;
break;
NewMod = NewMod->Pnext;
}
}
break;
......@@ -293,7 +215,7 @@ static void ReadDocLib( const wxString& ModLibName )
break;
case 'C': /* Doc */
if( NewMod && (!NewMod->m_Doc ) )
if( NewMod && ( !NewMod->m_Doc ) )
NewMod->m_Doc = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
break;
}
......
......@@ -35,11 +35,12 @@ MODULE* WinEDA_DisplayFrame::Get_Module( const wxString& CmpName )
wxString tmp, msg;
wxFileName fn;
MODULE* Module = NULL;
WinEDA_CvpcbFrame* parent = ( WinEDA_CvpcbFrame* ) GetParent();
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ )
for( ii = 0; ii < parent->m_ModuleLibNames.GetCount(); ii++ )
{
/* Calcul du nom complet de la librairie */
fn = g_LibName_List[ii];
fn = parent->m_ModuleLibNames[ii];
fn.SetExt( ModuleFileExtension );
tmp = wxGetApp().FindLibraryPath( fn );
......
/**********************************************/
/* Routines de gestion de la memoire */
/**********************************************/
/* Fichier memoire.cpp */
#include "fctsys.h"
#include "wxstruct.h"
#include "common.h"
#include "cvpcb.h"
/********************************/
void FreeMemoryModules()
/********************************/
/* Routine de liberation memoire de la liste des modules
- remet a NULL g_BaseListePkg
- remet a 0 nblib;
*/
{
STOREMOD * Module, * NextMod;
if( g_BaseListePkg == NULL) return;
for ( Module = g_BaseListePkg; Module != NULL; Module = NextMod)
{
NextMod = Module->Pnext;
delete Module;
}
nblib = 0;
g_BaseListePkg = NULL;
}
/***********************************/
void FreeMemoryComponents()
/***********************************/
/* Routine de liberation memoire de la liste des composants
- remet a NULL BaseListeMod
- remet a 0 nbcomp
*/
{
STORECMP * Cmp, * NextCmp;
if( g_BaseListeCmp == NULL ) return;
for( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = NextCmp )
{
NextCmp = Cmp->Pnext;
delete Cmp;
}
nbcomp = 0;
g_BaseListeCmp = NULL;
}
......@@ -62,15 +62,18 @@ void WinEDA_CvpcbFrame::ReCreateMenuBar()
item->SetBitmap( config_xpm );
configmenu->Append( item );
// Font selection and setup
AddFontSelectionMenu( configmenu );
wxGetApp().AddMenuLanguageList( configmenu );
item = new wxMenuItem( configmenu, ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
_( "Keep Open On Save" ),
_( "Prevent CVPcb from exiting after saving " \
"netlist file" ),
wxITEM_CHECK );
configmenu->Append( item );
configmenu->AppendSeparator();
item = new wxMenuItem( configmenu, ID_CONFIG_SAVE,
_( "&Save config" ),
_( "Save configuration in current dir" ) );
_( "&Save Project File" ),
_( "Save changes to the project file" ) );
item->SetBitmap( save_setup_xpm );
configmenu->Append( item );
......
......@@ -5,32 +5,16 @@
#ifndef PROTOS_H
#define PROTOS_H
int GenNetlistPcbnew( FILE* f ) ;
bool loadcmp( const wxString& fileName ) ;
bool listlib() ;
STOREMOD * GetModuleDescrByName(const wxString & FootprintName);
/***********/
/* CFG.CPP */
/***********/
void Save_Config( wxWindow* parent, const wxString& fileName );
void Read_Config( const wxString & FullFileName ); /* lit la configuration */
/***************/
/* MEMOIRE.CPP */
/***************/
void FreeMemoryComponents();
/* Routine de liberation memoire de la liste des composants
- remet a NULL BaseListeMod
- remet a 0 NbComp */
void FreeMemoryModules();
/* Routine de liberation memoire de la liste des modules
- remet a NULL g_BaseListePkg
- rement a 0 NbLib; */
extern int GenNetlistPcbnew( FILE* f, COMPONENT_LIST& list,
bool isEESchemaNetlist = true,
bool rightJustify = false );
extern bool LoadComponentFile( const wxString& fileName,
COMPONENT_LIST& list );
extern bool LoadFootprintFiles( const wxArrayString& libNames,
FOOTPRINT_LIST& list );
FOOTPRINT* GetModuleDescrByName( const wxString& FootprintName,
FOOTPRINT_LIST& list );
#endif // PROTOS_H
......@@ -2,7 +2,7 @@
/* readschematicnetlist.cpp */
/****************************/
/* Read a nelist type Eeschema or OrcadPCB2 and buid the component list
/* Read a nelist type Eeschema or OrcadPCB2 and build the component list
* Manages the lines like :
* ( XXXXXX VALEUR|(pin1,pin2,...=newalim) ID VALEUR
*/
......@@ -23,20 +23,16 @@
/* routines locales : */
static int ReadPinConnection( FILE* f, STORECMP* CurrentCmp );
static int CmpCompare( void* cmp1, void* cmp2 ); /* routine pour qsort() de tri de liste des composants */
static STORECMP* TriListeComposants( STORECMP* BaseListe, int nbitems );
static int ReadPinConnection( FILE* f, COMPONENT* CurrentCmp );
/* Tri la liste des composants par ordre alphabetique et met a jour le nouveau chainage avant/arriere
* retourne un pointeur sur le 1er element de la liste */
/* Tri la liste des composants par ordre alphabetique et met a jour le nouveau
* chainage avant/arriere retourne un pointeur sur le 1er element de la liste */
#define BUFFER_CHAR_SIZE 1024 // Size of buffers used to store netlist datas
#define BUFFER_CHAR_SIZE 1024 // Size of buffers used to store netlist data
/************************************************/
int WinEDA_CvpcbFrame::ReadSchematicNetlist()
/************************************************/
/** Function ReadSchematicNetlist
/**
* Function ReadSchematicNetlist
* Read a Eeschema (or OrcadPCB) netlist
* like:
* # EESchema Netlist Version 1.1 created 15/5/2008-12:09:21
......@@ -87,6 +83,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
* $endfootprintlist
* }
*/
int WinEDA_CvpcbFrame::ReadSchematicNetlist()
{
char alim[1024];
int i, k, l;
......@@ -97,16 +94,19 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
wxString footprint_name; /* buffer for component footprint field */
wxString component_value; /* buffer for component values (470K, 22nF ...) */
char* ptchar;
STORECMP* Cmp;
COMPONENT* Cmp;
FILE* source;
modified = 0;
Rjustify = 0;
g_FlagEESchema = FALSE;
m_modified = false;
m_isEESchemaNetlist = false;
/* Clear components buffer */
if( g_BaseListeCmp )
FreeMemoryComponents();
if( !m_components.empty() )
{
m_components.DeleteContents( true );
m_components.Clear();
m_components.DeleteContents( false );
}
source = wxFopen( m_NetlistFileName.GetFullPath(), wxT( "rt" ) );
......@@ -129,7 +129,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
{
i = strnicmp( Line, "# EESchema", 7 ); /* net type EESchema */
if( i == 0 )
g_FlagEESchema = TRUE;
m_isEESchemaNetlist = TRUE;
}
if( i != 0 )
......@@ -143,7 +143,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
SetStatusText( _( "Netlist Format: EESchema" ), 0 );
/* Read the netlit */
/* Read the netlist */
for( ; ; )
{
/* Search the beginning of a component description */
......@@ -255,13 +255,12 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
}
/* Store info for this component */
Cmp = new STORECMP();
Cmp->Pnext = g_BaseListeCmp;
g_BaseListeCmp = Cmp;
Cmp = new COMPONENT();
Cmp->m_Reference = component_reference;
Cmp->m_Valeur = component_value;
m_components.push_back( Cmp );
if( g_FlagEESchema ) /* copy footprint name: */
if( m_isEESchemaNetlist ) /* copy footprint name: */
{
if( strnicmp( LibName, "$noname", 7 ) != 0 )
{
......@@ -275,26 +274,22 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
Cmp->m_TimeStamp = schematic_timestamp;
ReadPinConnection( source, Cmp );
nbcomp++;
}
fclose( source );
/* Alpabetic sorting : */
g_BaseListeCmp = TriListeComposants( g_BaseListeCmp, nbcomp );
m_components.Sort( compare );
return 0;
}
/********************************************************/
int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
/********************************************************/
{
COMPONENT_LIST::iterator i;
char Line[BUFFER_CHAR_SIZE + 1];
wxString CmpRef;
STORECMP* Cmp = NULL;
COMPONENT* Cmp = NULL;
for( ; ; )
{
......@@ -313,9 +308,12 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
CmpRef = CONV_FROM_UTF8( Line + 11 );
CmpRef.Trim( TRUE );
CmpRef.Trim( FALSE );
/* Search the new component in list */
for( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = Cmp->Pnext )
for( i = m_components.begin(); i != m_components.end(); ++i )
{
Cmp = *i;
if( Cmp->m_Reference == CmpRef )
break;
}
......@@ -333,16 +331,13 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
}
/***********************************/
int ReadPinConnection( FILE* f, STORECMP* Cmp )
/***********************************/
int ReadPinConnection( FILE* f, COMPONENT* Cmp )
{
int i, jj;
wxString numpin;
wxString net;
char Line[BUFFER_CHAR_SIZE + 1];
STOREPIN* Pin = NULL;
STOREPIN** LastPin = &Cmp->m_Pins;
PIN* Pin = NULL;
for( ; ; )
{
......@@ -392,69 +387,10 @@ int ReadPinConnection( FILE* f, STORECMP* Cmp )
net.Append( Line[i] );
}
Pin = new STOREPIN();
*LastPin = Pin;
LastPin = &Pin->Pnext;
Pin = new PIN();
Pin->m_PinNum = numpin;
Pin->m_PinNet = net;
Cmp->m_Pins.push_back( Pin );
}
}
}
/****************************************************************/
STORECMP* TriListeComposants( STORECMP* BaseListe, int nbitems )
/****************************************************************/
/* Sort the component list( this is a linked list)
* retourn the beginning of the list
*/
{
STORECMP** bufferptr, * Item;
int ii;
if( nbitems <= 0 )
return NULL;
bufferptr = (STORECMP**) MyZMalloc( (nbitems + 2) * sizeof(STORECMP*) );
for( ii = 1, Item = BaseListe; Item != NULL; Item = Item->Pnext, ii++ )
{
bufferptr[ii] = Item;
}
/* Here: bufferptr[0] = NULL and bufferptr[nbitem+1] = NULL.
* These 2 values are the first item back link, and the last item forward link
*/
qsort( bufferptr + 1, nbitems, sizeof(STORECMP*),
( int( * ) ( const void*, const void* ) )CmpCompare );
/* Update linked list */
for( ii = 1; ii <= nbitems; ii++ )
{
Item = bufferptr[ii];
Item->m_Num = ii;
Item->Pnext = bufferptr[ii + 1];
Item->Pback = bufferptr[ii - 1];
}
return bufferptr[1];
}
/****************************************/
int CmpCompare( void* mod1, void* mod2 )
/****************************************/
/*
* Compare function for qsort() : alphabetic sorting, with numbering order
*/
{
int ii;
STORECMP* pt1, * pt2;
pt1 = *( (STORECMP**) mod1 );
pt2 = *( (STORECMP**) mod2 );
ii = StrNumICmp( pt1->m_Reference.GetData(), pt2->m_Reference.GetData() );
return ii;
}
This diff is collapsed.
......@@ -43,7 +43,7 @@ void WinEDA_CvpcbFrame::CreateScreenCmp()
{
msg = _( "Footprint: " ) + FootprintName;
DrawFrame->SetTitle( msg );
STOREMOD* Module = GetModuleDescrByName( FootprintName );
FOOTPRINT* Module = GetModuleDescrByName( FootprintName, m_footprints );
msg = _( "Lib: " );
if( Module )
......
This diff is collapsed.
This diff is collapsed.
......@@ -171,12 +171,14 @@ extern const wxString SchematicFileExtension;
extern const wxString BoardFileExtension;
extern const wxString NetlistFileExtension;
extern const wxString GerberFileExtension;
extern const wxString PdfFileExtension;
extern const wxString ProjectFileWildcard;
extern const wxString SchematicFileWildcard;
extern const wxString BoardFileWildcard;
extern const wxString NetlistFileWildcard;
extern const wxString GerberFileWildcard;
extern const wxString PdfFileWildcard;
extern const wxString AllFilesWildcard;
......
......@@ -461,6 +461,7 @@ enum main_id {
ID_CVPCB_SHOW3D_FRAME,
ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
ID_CVPCB_UNUSED0,
ID_CVPCB_UNUSED1,
ID_CVPCB_UNUSED2,
......
This diff is collapsed.
This diff is collapsed.
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