2008-05-07 15:08:16 +00:00
|
|
|
/****************************************************************
|
2009-12-02 21:44:03 +00:00
|
|
|
* EESchema: backanno.cpp
|
|
|
|
* (functions for backannotating Footprint info
|
|
|
|
****************************************************************/
|
2008-05-07 15:08:16 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "kicad_string.h"
|
|
|
|
#include "gestfich.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
|
|
|
#include "build_version.h"
|
2008-05-07 15:08:16 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "general.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_sheet_path.h"
|
|
|
|
#include "sch_component.h"
|
2010-01-05 08:48:49 +00:00
|
|
|
|
2008-05-07 15:08:16 +00:00
|
|
|
|
2011-03-28 18:23:01 +00:00
|
|
|
const wxString BackAnnotateFileWildcard( wxT( "EESchema Back Annotation File (*.stf)|*.stf" ) );
|
2008-05-08 20:34:39 +00:00
|
|
|
|
2008-05-15 15:59:11 +00:00
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFilename, bool aSetFieldAttributeToVisible )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2008-05-16 09:21:01 +00:00
|
|
|
int LineNum = 0;
|
|
|
|
char* cp, Ref[256], FootPrint[256], Line[1024];
|
2011-03-28 18:23:01 +00:00
|
|
|
SCH_SHEET_LIST SheetList;
|
2008-05-07 23:41:05 +00:00
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
while( GetLine( aFilename, Line, &LineNum, sizeof(Line) ) )
|
2008-05-07 23:41:05 +00:00
|
|
|
{
|
|
|
|
if( sscanf( Line, "comp = \"%s module = \"%s", Ref, FootPrint ) == 2 )
|
|
|
|
{
|
|
|
|
for( cp = Ref; *cp; cp++ )
|
|
|
|
if( *cp == '"' )
|
|
|
|
*cp = 0;
|
|
|
|
|
|
|
|
for( cp = FootPrint; *cp; cp++ )
|
|
|
|
if( *cp == '"' )
|
|
|
|
*cp = 0;
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
wxString reference = FROM_UTF8( Ref );
|
|
|
|
wxString Footprint = FROM_UTF8( FootPrint );
|
2011-03-28 18:23:01 +00:00
|
|
|
SheetList.SetComponentFootprint( reference, Footprint, aSetFieldAttributeToVisible );
|
2008-05-07 23:41:05 +00:00
|
|
|
}
|
2008-05-07 15:08:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-05-07 23:41:05 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
bool SCH_EDIT_FRAME::ReadInputStuffFile()
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2011-03-28 18:23:01 +00:00
|
|
|
wxString title, filename;
|
|
|
|
FILE* file;
|
2008-05-07 23:41:05 +00:00
|
|
|
wxString msg;
|
2011-03-28 18:23:01 +00:00
|
|
|
bool visible = false;
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Load Back Annotate File" ), wxEmptyString, wxEmptyString,
|
|
|
|
BackAnnotateFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2008-05-16 09:21:01 +00:00
|
|
|
return false;
|
|
|
|
|
2011-03-28 18:23:01 +00:00
|
|
|
filename = dlg.GetPath();
|
|
|
|
title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
|
|
|
|
title += wxT( " " ) + filename;
|
|
|
|
SetTitle( title );
|
|
|
|
|
|
|
|
int response = wxMessageBox( _( "Do you want to make all the foot print fields visible?" ),
|
|
|
|
_( "Field Display Option" ),
|
|
|
|
wxYES_NO | wxICON_QUESTION | wxCANCEL, this );
|
|
|
|
|
|
|
|
if( response == wxCANCEL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( response == wxYES )
|
|
|
|
visible = true;
|
|
|
|
|
|
|
|
file = wxFopen( filename, wxT( "rt" ) );
|
|
|
|
|
|
|
|
if( file == NULL )
|
2008-05-07 23:41:05 +00:00
|
|
|
{
|
2011-03-28 18:23:01 +00:00
|
|
|
msg.Printf( _( "Failed to open back annotate file <%s>" ), filename.GetData() );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
return false;
|
2008-05-07 15:08:16 +00:00
|
|
|
}
|
2008-05-07 23:41:05 +00:00
|
|
|
|
2011-03-28 18:23:01 +00:00
|
|
|
ProcessStuffFile( file, visible );
|
2008-05-07 15:08:16 +00:00
|
|
|
|
2011-03-28 18:23:01 +00:00
|
|
|
return true;
|
2008-05-07 15:08:16 +00:00
|
|
|
}
|