Commit 30c7821b authored by jean-pierre charras's avatar jean-pierre charras

Grebview: add info in layer manager for Excellon drill filles, similar to X2...

Grebview: add info in layer manager for Excellon drill filles, similar to X2 file function info in X2 gerber files.
parent 49fa6f92
...@@ -548,6 +548,9 @@ int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& aFilename, ...@@ -548,6 +548,9 @@ int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& aFilename,
{ {
wxFile cfgfile( aFilename ); wxFile cfgfile( aFilename );
if( !cfgfile.IsOpened() ) // There is a problem to open file
return 0;
// get length // get length
cfgfile.SeekEnd(); cfgfile.SeekEnd();
wxFileOffset size = cfgfile.Tell(); wxFileOffset size = cfgfile.Tell();
......
...@@ -455,7 +455,7 @@ const wxString GERBER_IMAGE_LIST::GetDisplayName( int aIdx ) ...@@ -455,7 +455,7 @@ const wxString GERBER_IMAGE_LIST::GetDisplayName( int aIdx )
if( aIdx >= 0 && aIdx < (int)m_GERBER_List.size() ) if( aIdx >= 0 && aIdx < (int)m_GERBER_List.size() )
gerber = m_GERBER_List[aIdx]; gerber = m_GERBER_List[aIdx];
if( gerber && gerber->m_InUse) if( IsUsed(aIdx ) )
{ {
if( gerber->m_FileFunction ) if( gerber->m_FileFunction )
name.Printf( _( "Layer %d (%s, %s)" ), aIdx + 1, name.Printf( _( "Layer %d (%s, %s)" ), aIdx + 1,
......
...@@ -95,7 +95,7 @@ void X2_ATTRIBUTE::DbgListPrms() ...@@ -95,7 +95,7 @@ void X2_ATTRIBUTE::DbgListPrms()
* buff = the buffer containing current Gerber data (GERBER_BUFZ size) * buff = the buffer containing current Gerber data (GERBER_BUFZ size)
* text = a pointer to the first char to read in Gerber data * text = a pointer to the first char to read in Gerber data
*/ */
bool X2_ATTRIBUTE::ParseAttribCmd( FILE* aFile, char *aBuffer, int aBuffSize, char*& aText ) bool X2_ATTRIBUTE::ParseAttribCmd( FILE* aFile, char *aBuffer, int aBuffSize, char* &aText )
{ {
bool ok = true; bool ok = true;
wxString data; wxString data;
......
...@@ -97,7 +97,7 @@ public: ...@@ -97,7 +97,7 @@ public:
* or the end of line if the line does not contain '%' or aBuffer == NULL (X1 mode) * or the end of line if the line does not contain '%' or aBuffer == NULL (X1 mode)
* @return true if no error. * @return true if no error.
*/ */
bool ParseAttribCmd( FILE* aFile, char *aBuffer, int aBuffSize, char*& aText ); bool ParseAttribCmd( FILE* aFile, char *aBuffer, int aBuffSize, char* &aText );
/** /**
* Debug function: pring using wxLogMessage le list of parameters * Debug function: pring using wxLogMessage le list of parameters
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004-2010 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr * Copyright (C) 2004-2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors.
* *
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2011 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> * Copyright (C) 1992-2014 Jean-Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#include <class_GERBER.h> #include <class_GERBER.h>
#include <class_excellon.h> #include <class_excellon.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <class_X2_gerber_attributes.h>
#include <cmath> #include <cmath>
...@@ -105,6 +106,12 @@ void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem, ...@@ -105,6 +106,12 @@ void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
wxSize aPenSize, wxSize aPenSize,
bool aLayerNegative ); bool aLayerNegative );
// Getber X2 files have a file attribute which specify the type of image
// (copper, solder paste ... and sides tpo, bottom or inner copper layers)
// Excellon drill files do not have attributes, so, just to identify the image
// In gerbview, we add this attribute, like a Gerber drill file
static const char file_attribute[] = ".FileFunction,Other,Drill*";
static EXCELLON_CMD excellonHeaderCmdList[] = static EXCELLON_CMD excellonHeaderCmdList[] =
{ {
{ "M0", DRILL_M_END, -1 }, // End of Program - No Rewind { "M0", DRILL_M_END, -1 }, // End of Program - No Rewind
...@@ -168,16 +175,16 @@ static EXCELLON_CMD excellon_G_CmdList[] = ...@@ -168,16 +175,16 @@ static EXCELLON_CMD excellon_G_CmdList[] =
bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName )
{ {
wxString msg; wxString msg;
int layer = getActiveLayer(); // current layer used in GerbView int layerId = getActiveLayer(); // current layer used in GerbView
EXCELLON_IMAGE* drill_Layer = (EXCELLON_IMAGE*) g_GERBER_List.GetGbrImage( layer ); EXCELLON_IMAGE* drill_Layer = (EXCELLON_IMAGE*) g_GERBER_List.GetGbrImage( layerId );
if( drill_Layer == NULL ) if( drill_Layer == NULL )
{ {
drill_Layer = new EXCELLON_IMAGE( this, layer ); drill_Layer = new EXCELLON_IMAGE( this, layerId );
layer = g_GERBER_List.AddGbrImage( drill_Layer, layer ); layerId = g_GERBER_List.AddGbrImage( drill_Layer, layerId );
} }
if( layer < 0 ) if( layerId < 0 )
{ {
DisplayError( this, _( "No room to load file" ) ); DisplayError( this, _( "No room to load file" ) );
return false; return false;
...@@ -220,7 +227,7 @@ bool EXCELLON_IMAGE::Read_EXCELLON_File( FILE * aFile, ...@@ -220,7 +227,7 @@ bool EXCELLON_IMAGE::Read_EXCELLON_File( FILE * aFile,
m_FileName = aFullFileName; m_FileName = aFullFileName;
m_Current_File = aFile; m_Current_File = aFile;
SetLocaleTo_C_standard(); LOCALE_IO toggleIo;
// FILE_LINE_READER will close the file. // FILE_LINE_READER will close the file.
if( m_Current_File == NULL ) if( m_Current_File == NULL )
...@@ -289,7 +296,16 @@ bool EXCELLON_IMAGE::Read_EXCELLON_File( FILE * aFile, ...@@ -289,7 +296,16 @@ bool EXCELLON_IMAGE::Read_EXCELLON_File( FILE * aFile,
} // End switch } // End switch
} }
} }
SetLocaleTo_Default();
// Add our file attribute, to identify the drill file
X2_ATTRIBUTE dummy;
char* text = (char*)file_attribute;
dummy.ParseAttribCmd( m_Current_File, NULL, 0, text );
delete m_FileFunction;
m_FileFunction = new X2_ATTRIBUTE_FILEFUNCTION( dummy );
m_InUse = true;
return true; return true;
} }
......
...@@ -77,7 +77,7 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName, ...@@ -77,7 +77,7 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName,
if( path != wxEmptyString ) if( path != wxEmptyString )
wxSetWorkingDirectory( path ); wxSetWorkingDirectory( path );
SetLocaleTo_C_standard(); LOCALE_IO toggleIo;
while( true ) while( true )
{ {
...@@ -171,8 +171,8 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName, ...@@ -171,8 +171,8 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName,
} }
} }
} }
fclose( gerber->m_Current_File ); fclose( gerber->m_Current_File );
SetLocaleTo_Default();
gerber->m_InUse = true; gerber->m_InUse = true;
......
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