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 <wx_html_report_panel.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 451 of file dialog_exchange_modules.cpp.

References UTF8::c_str(), 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().

452 {
453  FILE* cmpFile;
454 
455  cmpFile = wxFopen( aFullCmpFileName, wxT( "wt" ) );
456 
457  if( cmpFile == NULL )
458  return false;
459 
460  fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) );
461 
462  MODULE* module = aBrd->m_Modules;
463  for( ; module != NULL; module = module->Next() )
464  {
465  fprintf( cmpFile, "\nBeginCmp\n" );
466  fprintf( cmpFile, "TimeStamp = %8.8lX\n", (unsigned long)module->GetTimeStamp() );
467  fprintf( cmpFile, "Path = %s\n", TO_UTF8( module->GetPath() ) );
468  fprintf( cmpFile, "Reference = %s;\n",
469  !module->GetReference().IsEmpty() ?
470  TO_UTF8( module->GetReference() ) : "[NoRef]" );
471  fprintf( cmpFile, "ValeurCmp = %s;\n",
472  !module->GetValue().IsEmpty() ?
473  TO_UTF8( module->GetValue() ) : "[NoVal]" );
474  fprintf( cmpFile, "IdModule = %s;\n", module->GetFPID().Format().c_str() );
475  fprintf( cmpFile, "EndCmp\n" );
476  }
477 
478  fprintf( cmpFile, "\nEndListe\n" );
479  fclose( cmpFile );
480 
481  return true;
482 }
MODULE * Next() const
Definition: class_module.h:120
const wxString & GetValue() const
Function GetValue.
Definition: class_module.h:467
const LIB_ID & GetFPID() const
Definition: class_module.h:184
#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
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:439
DLIST< MODULE > m_Modules
Definition: class_board.h:245
const char * c_str() const
Definition: utf8.h:107
UTF8 Format() const
Definition: lib_id.cpp:263
const wxString & GetPath() const
Definition: class_module.h:193
wxString DateAndTime()
Function DateAndTime.
Definition: string.cpp:229
timestamp_t GetTimeStamp() const
Definition: base_struct.h:231