KiCad PCB EDA Suite
dialog_exchange_modules.cpp File Reference
#include <fctsys.h>
#include <class_drawpanel.h>
#include <class_draw_panel_gal.h>
#include <confirm.h>
#include <kicad_string.h>
#include <wxPcbStruct.h>
#include <macros.h>
#include <board_commit.h>
#include <class_board.h>
#include <class_module.h>
#include <project.h>
#include <pcbnew.h>
#include <dialog_exchange_modules.h>
#include <wildcards_and_files_ext.h>
#include <kiway.h>

Go to the source code of this file.

Functions

static bool RecreateCmpFile (BOARD *aBrd, const wxString &aFullCmpFileName)
 

Function Documentation

bool RecreateCmpFile ( BOARD aBrd,
const wxString &  aFullCmpFileName 
)
static

Definition at line 444 of file dialog_exchange_modules.cpp.

References DateAndTime(), LIB_ID::Format(), MODULE::GetFPID(), MODULE::GetPath(), MODULE::GetReference(), EDA_ITEM::GetTimeStamp(), MODULE::GetValue(), BOARD::m_Modules, MODULE::Next(), and TO_UTF8.

Referenced by DIALOG_EXCHANGE_MODULE::RebuildCmpList(), and PCB_EDIT_FRAME::RecreateCmpFileFromBoard().

445 {
446  FILE* cmpFile;
447 
448  cmpFile = wxFopen( aFullCmpFileName, wxT( "wt" ) );
449 
450  if( cmpFile == NULL )
451  return false;
452 
453  fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) );
454 
455  MODULE* module = aBrd->m_Modules;
456  for( ; module != NULL; module = module->Next() )
457  {
458  fprintf( cmpFile, "\nBeginCmp\n" );
459  fprintf( cmpFile, "TimeStamp = %8.8lX\n", (unsigned long)module->GetTimeStamp() );
460  fprintf( cmpFile, "Path = %s\n", TO_UTF8( module->GetPath() ) );
461  fprintf( cmpFile, "Reference = %s;\n",
462  !module->GetReference().IsEmpty() ?
463  TO_UTF8( module->GetReference() ) : "[NoRef]" );
464  fprintf( cmpFile, "ValeurCmp = %s;\n",
465  !module->GetValue().IsEmpty() ?
466  TO_UTF8( module->GetValue() ) : "[NoVal]" );
467  fprintf( cmpFile, "IdModule = %s;\n", module->GetFPID().Format().c_str() );
468  fprintf( cmpFile, "EndCmp\n" );
469  }
470 
471  fprintf( cmpFile, "\nEndListe\n" );
472  fclose( cmpFile );
473 
474  return true;
475 }
MODULE * Next() const
Definition: class_module.h:99
const wxString & GetValue() const
Function GetValue.
Definition: class_module.h:439
const LIB_ID & GetFPID() const
Definition: class_module.h:151
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
time_t GetTimeStamp() const
Definition: base_struct.h:204
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:411
DLIST< MODULE > m_Modules
Definition: class_board.h:243
UTF8 Format() const
Function Format.
Definition: lib_id.cpp:263
const wxString & GetPath() const
Definition: class_module.h:160
wxString DateAndTime()
Function DateAndTime.
Definition: string.cpp:229