Commit 0132ceb3 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: remove support of .mdc files (now useless) (already done in cvpcb).

parent 8d0605c3
......@@ -75,6 +75,7 @@ add_library(common ${COMMON_SRCS})
set(PCB_COMMON_SRCS
pcbcommon.cpp
footprint_info.cpp
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp
../pcbnew/class_board_connected_item.cpp
......
......@@ -6,7 +6,7 @@
#endif
#ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION "(2011-02-20 BZR 2825)"
#define KICAD_BUILD_VERSION "(2011-02-22 BZR 2835)"
#endif
//#define VERSION_STABILITY "stable"
......
/**
* @file listlib.cpp
* @file footprint_info.cpp
*/
......@@ -13,9 +13,8 @@
#include "kicad_string.h"
#include "macros.h"
#include "appl_wxstruct.h"
#include "cvpcb.h"
#include "cvpcb_mainframe.h"
#include "pcbstruct.h"
#include "pcbcommon.h"
#include "richio.h"
#include "filter_reader.h"
#include "footprint_info.h"
......
......@@ -34,7 +34,6 @@ set(CVPCB_SRCS
genequiv.cpp
init.cpp
listboxes.cpp
listlib.cpp
loadcmp.cpp
menubar.cpp
readschematicnetlist.cpp
......
......@@ -19,12 +19,11 @@
/**
* Analyze the libraries to find the module.
* If this module is found, copy it into memory, and
* string end of the list of modules.
* Read libraries to find a module.
* If this module is found, copy it into memory
*
* @param CmpName - Module name
* @return - Module if found otherwise NULL.
* @return - a pointer to the loaded module or NULL.
*/
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& CmpName )
{
......
......@@ -5,6 +5,9 @@
#ifndef _FOOTPRINT_INFO_H_
#define _FOOTPRINT_INFO_H_
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/foreach.hpp>
#include "kicad_string.h"
/*
......
......@@ -12,9 +12,7 @@
// Definitions relatives aux libraries
#define ENTETE_LIBRAIRIE "PCBNEW-LibModule-V1"
#define ENTETE_LIBDOC "PCBNEW-LibDoc----V1"
#define L_ENTETE_LIB 18
#define EXT_DOC wxT( "mdc" )
class NETINFO_ITEM;
class MARKER_PCB;
......
......@@ -202,14 +202,12 @@ public:
* abort an existing footprint is found
* @param aDisplayDialog = true to display a dialog to enter or confirm the
* footprint name
* @param aCreateDocFile = true to creates the associated doc file
* @return : 1 if OK,0 if abort
* @return : true if OK, false if abort
*/
int Save_Module_In_Library( const wxString& aLibName,
bool Save_Module_In_Library( const wxString& aLibName,
MODULE* aModule,
bool aOverwrite,
bool aDisplayDialog,
bool aCreateDocFile );
bool aDisplayDialog );
void Archive_Modules( const wxString& LibName,
bool NewModulesOnly );
......
......@@ -17,7 +17,7 @@
; General Product Description Definitions
!define PRODUCT_NAME "KiCad"
!define PRODUCT_VERSION "2011.02.20"
!define PRODUCT_VERSION "2011.02.22"
!define PRODUCT_WEB_SITE "http://iut-tice.ujf-grenoble.fr/kicad/"
!define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/"
!define COMPANY_NAME ""
......
......@@ -35,9 +35,6 @@ static const wxString ModExportFileWildcard(
_( "Kicad foot print export files (*.emp)|*.emp" ) );
static bool CreateDocLibrary( const wxString& LibName );
/*
* Function Import_Module
* Read a file containing only one footprint.
......@@ -389,8 +386,6 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname
msg.Printf( _( "Component %s deleted in library %s" ), GetChars( CmpName ),
GetChars( oldFileName.GetFullPath() ) );
SetStatusText( msg );
CreateDocLibrary( oldFileName.GetFullPath() );
}
......@@ -473,15 +468,13 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
{
if( Save_Module_In_Library( fileName, Module,
NewModulesOnly ? false : true,
false, false ) == 0 )
false ) == 0 )
break;
DisplayActivity( (int) ( ii * Pas ), wxEmptyString );
/* Check for request to stop backup (ESCAPE key actuated) */
if( DrawPanel->m_AbortRequest )
break;
}
CreateDocLibrary( fileName );
}
......@@ -494,14 +487,12 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
* an existing footprint is found
* @param aDisplayDialog = true to display a dialog to enter or confirm the
* footprint name
* @param aCreateDocFile = true to creates the associated doc file
* @return : 1 if OK, 0 if abort
* @return : true if OK, false if abort
*/
int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
bool WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
MODULE* aModule,
bool aOverwrite,
bool aDisplayDialog,
bool aCreateDocFile )
bool aDisplayDialog )
{
wxFileName oldFileName;
wxFileName newFileName;
......@@ -519,7 +510,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
{
msg.Printf( _( "Library %s not found" ), GetChars( aLibName ) );
DisplayError( this, msg );
return 0;
return false;
}
/* Ask for the footprint name in lib */
......@@ -542,7 +533,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
{
msg.Printf( _( "Unable to open %s" ), GetChars( aLibName ) );
DisplayError( this, msg );
return 0;
return false;
}
/* Read library file : library header */
......@@ -553,7 +544,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
msg.Printf( _( "File %s is not a eeschema library" ),
GetChars( aLibName ) );
DisplayError( this, msg );
return 0;
return false;
}
/* Read footprints in lib: - search for an existing footprint */
......@@ -603,7 +594,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
if( ( lib_module = wxFopen( aLibName, wxT( "rt" ) ) ) == NULL )
{
DisplayError( this, wxT( "Librairi.cpp: Error oldlib not found" ) );
return 0;
return false;
}
newFileName = aLibName;
......@@ -614,7 +605,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
fclose( lib_module );
msg = _( "Unable to create " ) + newFileName.GetFullPath();
DisplayError( this, msg );
return 0;
return false;
}
wxBeginBusyCursor();
......@@ -702,13 +693,9 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
if( !wxRenameFile( newFileName.GetFullPath(), aLibName ) )
{
DisplayError( this, wxT( "Librairi.cpp: rename NewLib err" ) );
return 0;
return false;
}
/* creates the new .dcm doc file corresponding to the new library */
if( aCreateDocFile )
CreateDocLibrary( aLibName );
if( aDisplayDialog )
{
msg = _( "Component " ); msg += Name_Cmp;
......@@ -717,7 +704,7 @@ int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
SetStatusText( msg );
}
return 1;
return true;
}
......@@ -840,107 +827,3 @@ int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName )
return 1;
}
/* Synch. Dcm combines a library Libname
* (Full file name)
*/
static bool CreateDocLibrary( const wxString& LibName )
{
char Line[1024];
char cbuf[256];
wxString Name, Doc, KeyWord;
wxFileName fn;
FILE* LibMod, * LibDoc;
fn = LibName;
fn.SetExt( EXT_DOC );
LibMod = wxFopen( LibName, wxT( "rt" ) );
if( LibMod == NULL )
return false;
/* Read library header. */
GetLine( LibMod, Line, NULL, sizeof(Line) - 1 );
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{
fclose( LibMod );
return false;
}
LibDoc = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( LibDoc == NULL )
{
fclose( LibMod );
return false;
}
fprintf( LibDoc, ENTETE_LIBDOC );
fprintf( LibDoc, " %s\n", DateAndTime( cbuf ) );
/* Read library. */
Name = Doc = KeyWord = wxEmptyString;
while( GetLine( LibMod, Line, NULL, sizeof(Line) - 1 ) )
{
if( Line[0] != '$' )
continue;
if( strnicmp( Line, "$MODULE", 6 ) == 0 )
{
while( GetLine( LibMod, Line, NULL, sizeof(Line) - 1 ) )
{
if( Line[0] == '$' )
{
if( Line[1] == 'E' )
break;
if( Line[1] == 'P' ) /* Pad Descr */
{
while( GetLine( LibMod, Line, NULL, sizeof(Line) - 1 ) )
{
if( (Line[0] == '$') && (Line[1] == 'E') )
break;
}
}
}
if( Line[0] == 'L' ) /* LibName */
Name = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
if( Line[0] == 'K' ) /* KeyWords */
KeyWord = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
if( Line[0] == 'C' ) /* Doc */
Doc = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
}
/* Generate the module the documentation. */
if( ( Name != wxEmptyString )
&& ( ( Doc != wxEmptyString ) || ( KeyWord != wxEmptyString ) ) )
{
fprintf( LibDoc, "#\n$MODULE %s\n", CONV_TO_UTF8( Name ) );
fprintf( LibDoc, "Li %s\n", CONV_TO_UTF8( Name ) );
if( Doc != wxEmptyString )
fprintf( LibDoc, "Cd %s\n", CONV_TO_UTF8( Doc ) );
if( KeyWord != wxEmptyString )
fprintf( LibDoc, "Kw %s\n", CONV_TO_UTF8( KeyWord ) );
fprintf( LibDoc, "$EndMODULE\n" );
}
Name = Doc = KeyWord = wxEmptyString;
} /* End read 1 module */
if( strnicmp( Line, "$INDEX", 6 ) == 0 )
{
while( GetLine( LibMod, Line, NULL, sizeof(Line) - 1 ) )
{
if( strnicmp( Line, "$EndINDEX", 9 ) == 0 )
break;
}
/* End read INDEX */
}
}
fclose( LibMod );
fprintf( LibDoc, "#\n$EndLIBDOC\n" );
fclose( LibDoc );
return true;
}
......@@ -19,30 +19,12 @@
#include "dialog_helpers.h"
#include "richio.h"
#include "filter_reader.h"
class FOOTPRINT_ITEM
{
public:
FOOTPRINT_ITEM* Next;
wxString m_Name, m_Doc, m_KeyWord;
public:
FOOTPRINT_ITEM()
{
Next = NULL;
}
~FOOTPRINT_ITEM()
{
}
};
#include "footprint_info.h"
static void DisplayCmpDoc( wxString& Name );
static void ReadDocLib( const wxString& ModLibName );
static FOOTPRINT_ITEM* MList;
static FOOTPRINT_LIST MList;
/**
* Function Load_Module_From_BOARD
......@@ -371,144 +353,42 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow
const wxString& aMask,
const wxString& aKeyWord )
{
unsigned ii;
char* Line;
wxFileName fn;
static wxString OldName; /* Save the name of the last module loaded. */
wxString CmpName;
wxString libFullName;
FILE* file;
wxString msg;
wxArrayString itemslist;
wxBeginBusyCursor();
wxArrayString libnames_list;
/* Find modules in libraries. */
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ )
{
/* Calculate the full file name of the library. */
if( aLibraryFullFilename.IsEmpty() )
{
fn = wxFileName( wxEmptyString, g_LibName_List[ii],
ModuleFileExtension );
}
libnames_list = g_LibName_List;
else
fn = aLibraryFullFilename;
libFullName = wxGetApp().FindLibraryPath( fn );
if( libFullName.IsEmpty() )
{
msg.Printf( _( "PCB footprint library file <%s> not found in search paths." ),
GetChars( fn.GetFullName() ) );
wxMessageBox( msg, _( "Library Load Error" ),
wxOK | wxICON_ERROR, this );
continue;
}
ReadDocLib( libFullName );
if( !aKeyWord.IsEmpty() ) /* Don't read the library if selection
* by keywords, already read. */
{
if( !aLibraryFullFilename.IsEmpty() )
break;
continue;
}
libnames_list.Add( aLibraryFullFilename );
file = wxFopen( libFullName, wxT( "rt" ) );
if( file == NULL )
{
if( !aLibraryFullFilename.IsEmpty() )
break;
continue;
}
FILE_LINE_READER fileReader( file, libFullName );
FILTER_READER reader( fileReader );
// Statusbar library loaded message
msg = _( "Library " ) + fn.GetFullPath() + _( " loaded" );
SetStatusText( msg );
/* Read header. */
reader.ReadLine();
Line = reader.Line();
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{
msg.Printf( _( "<%s> is not a valid Kicad PCB footprint library file." ),
GetChars( libFullName ) );
wxMessageBox( msg, _( "Library Load Error" ), wxOK | wxICON_ERROR, this );
continue;
}
/* Read library. */
while( reader.ReadLine() )
{
Line = reader.Line();
if( Line[0] != '$' )
continue;
if( strnicmp( Line, "$MODULE", 6 ) == 0 )
break;
if( strnicmp( Line, "$INDEX", 6 ) == 0 )
{
while( reader.ReadLine() )
{
Line = reader.Line();
if( strnicmp( Line, "$EndINDEX", 9 ) == 0 )
break;
strupper( Line );
msg = CONV_FROM_UTF8( StrPurge( Line ) );
if( aMask.IsEmpty() )
itemslist.Add( msg );
else if( WildCompareString( aMask, msg, false ) )
itemslist.Add( msg );
}
} /* End read INDEX */
}
/* End read library. */
file = NULL;
if( !aLibraryFullFilename.IsEmpty() )
break;
}
/* Find modules in libraries. */
MList.ReadFootprintFiles( libnames_list );
wxArrayString footprint_names_list;
/* Create list of modules if search by keyword. */
if( !aKeyWord.IsEmpty() )
{
FOOTPRINT_ITEM* ItemMod = MList;
while( ItemMod != NULL )
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
{
if( KeyWordOk( aKeyWord, ItemMod->m_KeyWord ) )
itemslist.Add( ItemMod->m_Name );
ItemMod = ItemMod->Next;
if( KeyWordOk( aKeyWord, MList.GetItem(ii).m_KeyWord ) )
footprint_names_list.Add( MList.GetItem(ii).m_Module );
}
}
else
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
footprint_names_list.Add( MList.GetItem(ii).m_Module );
wxEndBusyCursor();
msg.Printf( _( "Modules [%d items]" ), itemslist.GetCount() );
WinEDAListBox dlg( aWindow, msg, itemslist, OldName,
msg.Printf( _( "Modules [%d items]" ), footprint_names_list.GetCount() );
WinEDAListBox dlg( aWindow, msg, footprint_names_list, OldName,
DisplayCmpDoc, GetComponentDialogPosition() );
dlg.SortList();
if( dlg.ShowModal() == wxID_OK )
CmpName = dlg.GetTextSelection();
else
CmpName.Empty();
while( MList != NULL )
{
FOOTPRINT_ITEM* NewMod = MList->Next;
delete MList;
MList = NewMod;
}
if( CmpName != wxEmptyString )
OldName = CmpName;
......@@ -521,93 +401,17 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow
*/
static void DisplayCmpDoc( wxString& Name )
{
FOOTPRINT_ITEM* Mod = MList;
FOOTPRINT_INFO* module_info = MList.GetModuleInfo( Name );
if( !Mod )
if( !module_info )
{
Name.Empty();
return;
}
while( Mod )
{
if( !Mod->m_Name.IsEmpty() && ( Mod->m_Name.CmpNoCase( Name ) == 0 ) )
break;
Mod = Mod->Next;
}
if( Mod )
{
Name = !Mod->m_Doc.IsEmpty() ? Mod->m_Doc : wxT( "No Doc" );
Name = module_info->m_Doc.IsEmpty() ? wxT( "No Doc" ) : module_info->m_Doc;
Name += wxT( "\nKeyW: " );
Name += !Mod->m_KeyWord.IsEmpty() ? Mod->m_KeyWord : wxT( "No Keyword" );
}
else
Name = wxEmptyString;
}
/* Read the doc file and combine with a library ModLibName.
* Load in memory the list of docs string pointed to by mlist
* ModLibName = full file name of the library modules
*/
static void ReadDocLib( const wxString& ModLibName )
{
FOOTPRINT_ITEM* NewMod;
char* Line;
FILE* LibDoc;
wxFileName fn = ModLibName;
fn.SetExt( EXT_DOC );
if( ( LibDoc = wxFopen( fn.GetFullPath(), wxT( "rt" ) ) ) == NULL )
return;
FILE_LINE_READER fileReader( LibDoc, fn.GetFullPath() );
FILTER_READER reader( fileReader );
reader.ReadLine();
Line = reader.Line();
if( strnicmp( Line, ENTETE_LIBDOC, L_ENTETE_LIB ) != 0 )
return;
while( reader.ReadLine() )
{
Line = reader.Line();
if( Line[0] != '$' )
continue;
if( Line[1] == 'E' )
break; ;
if( Line[1] == 'M' ) /* Debut decription 1 module */
{
NewMod = new FOOTPRINT_ITEM();
NewMod->Next = MList;
MList = NewMod;
while( reader.ReadLine() )
{
Line = reader.Line();
if( Line[0] == '$' ) /* $EndMODULE */
break;
switch( Line[0] )
{
case 'L': /* LibName */
NewMod->m_Name = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
break;
case 'K': /* KeyWords */
NewMod->m_KeyWord = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
break;
case 'C': /* Doc */
NewMod->m_Doc = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
break;
}
}
} /* End read 1 module. */
}
Name += module_info->m_KeyWord.IsEmpty() ? wxT( "No Keyword" ) : module_info->m_KeyWord;
}
......
......@@ -264,8 +264,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
wxFileName fn;
fn = wxFileName( wxEmptyString, m_CurrentLib, ModuleFileExtension );
wxString full_filename = wxGetApp().FindLibraryPath( fn );
Save_Module_In_Library( full_filename, GetBoard()->m_Modules,
true, true, true );
Save_Module_In_Library( full_filename, GetBoard()->m_Modules, true, true );
GetScreen()->ClrModify();
break;
}
......
release version:
2011 feb 20
2011 feb 22
files (.zip,.tgz):
kicad-2011-02-20
kicad-2011-02-22
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