Commit ffbce6de authored by jean-pierre charras's avatar jean-pierre charras

Gerbview: Added: read Excellon files created by Pcbnew. The full Excellon...

Gerbview:   Added: read Excellon files created by Pcbnew. The full Excellon command set is not supported, but drill files created by Pcbnew are supported.
parent 0d740e45
...@@ -4,6 +4,12 @@ KiCad ChangeLog 2010 ...@@ -4,6 +4,12 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2011-Mar-16, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
Gerbview:
Added: read Excellon files created by Pcbnew.
The full Excellon command set is not supported, but drill files created by Pcbnew are supported.
2011-Feb-05, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> 2011-Feb-05, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
CvPcb: CvPcb:
......
...@@ -34,6 +34,7 @@ set(GERBVIEW_SRCS ...@@ -34,6 +34,7 @@ set(GERBVIEW_SRCS
dummy_functions.cpp dummy_functions.cpp
draw_gerber_screen.cpp draw_gerber_screen.cpp
events_called_functions.cpp events_called_functions.cpp
excellon_read_drill_file.cpp
export_to_pcbnew.cpp export_to_pcbnew.cpp
files.cpp files.cpp
gerbview.cpp gerbview.cpp
......
...@@ -142,7 +142,16 @@ public: ...@@ -142,7 +142,16 @@ public:
~GERBER_IMAGE(); ~GERBER_IMAGE();
void Clear_GERBER_IMAGE(); void Clear_GERBER_IMAGE();
int ReturnUsedDcodeNumber(); int ReturnUsedDcodeNumber();
void ResetDefaultValues(); virtual void ResetDefaultValues();
/**
* Function GetParent
* @return the GERBVIEW_FRAME parent of this GERBER_IMAGE
*/
GERBVIEW_FRAME* GetParent()
{
return m_Parent;
}
/** /**
* Function GetLayerParams * Function GetLayerParams
......
This diff is collapsed.
This diff is collapsed.
...@@ -73,7 +73,8 @@ clear an existing layer to load any new layers." ), NB_LAYERS ); ...@@ -73,7 +73,8 @@ clear an existing layer to load any new layers." ), NB_LAYERS );
break; break;
case ID_GERBVIEW_LOAD_DRILL_FILE: case ID_GERBVIEW_LOAD_DRILL_FILE:
DisplayError( this, _( "Not yet available..." ) ); LoadExcellonFiles( wxEmptyString );
DrawPanel->Refresh();
break; break;
case ID_GERBVIEW_LOAD_DCODE_FILE: case ID_GERBVIEW_LOAD_DCODE_FILE:
...@@ -195,6 +196,88 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) ...@@ -195,6 +196,88 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
return true; return true;
} }
bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName )
{
wxString filetypes;
wxArrayString filenamesList;
wxFileName filename = aFullFileName;
wxString currentPath;
if( !filename.IsOk() )
{
filetypes = _( "Drill files (.drl)" );
filetypes << wxT("|");
filetypes += wxT(";*.drl;*.DRL" );
filetypes << wxT("|");
/* All filetypes */
filetypes += AllFilesWildcard;
/* Use the current working directory if the file name path does not exist. */
if( filename.DirExists() )
currentPath = filename.GetPath();
else
currentPath = wxGetCwd();
wxFileDialog dlg( this,
_( "Open Drill File" ),
currentPath,
filename.GetFullName(),
filetypes,
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_CHANGE_DIR );
if( dlg.ShowModal() == wxID_CANCEL )
return false;
dlg.GetPaths( filenamesList );
currentPath = wxGetCwd();
}
else
{
wxFileName filename = aFullFileName;
filenamesList.Add( aFullFileName );
currentPath = filename.GetPath();
}
// Read gerber files: each file is loaded on a new gerbview layer
int layer = getActiveLayer();
for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ )
{
wxFileName filename = filenamesList[ii];
if( !filename.IsAbsolute() )
filename.SetPath( currentPath );
GetScreen()->SetFileName( filename.GetFullPath() );
setActiveLayer( layer, false );
if( Read_EXCELLON_File( filename.GetFullPath() ) )
{
layer = getNextAvailableLayer( layer );
if( layer == NO_AVAILABLE_LAYERS )
{
wxString msg = wxT( "No more empty layers are available. The remaining gerber " );
msg += wxT( "files will not be loaded." );
wxMessageBox( msg );
break;
}
setActiveLayer( layer, false );
}
}
Zoom_Automatique( false );
g_SaveTime = time( NULL );
// Synchronize layers tools with actual active layer:
setActiveLayer( getActiveLayer() );
syncLayerBox();
return true;
}
/* /*
* Read a DCode file (not used with RX274X files , just with RS274D old files). * Read a DCode file (not used with RX274X files , just with RS274D old files).
......
...@@ -407,6 +407,17 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title, ...@@ -407,6 +407,17 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
bool Read_GERBER_File( const wxString& GERBER_FullFileName, bool Read_GERBER_File( const wxString& GERBER_FullFileName,
const wxString& D_Code_FullFileName ); const wxString& D_Code_FullFileName );
/**
* function LoadDrllFiles
* Load a drill (EXCELLON) file or many files.
* @param aFileName - void string or file name with full path to open or empty string to
* open a new file. In this case one one file is loaded
* if void string: user will be prompted for filename(s)
* @return true if file was opened successfully.
*/
bool LoadExcellonFiles( const wxString& aFileName );
bool Read_EXCELLON_File( const wxString& aFullFileName );
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
/** /**
......
...@@ -39,10 +39,9 @@ void GERBVIEW_FRAME::ReCreateMenuBar( void ) ...@@ -39,10 +39,9 @@ void GERBVIEW_FRAME::ReCreateMenuBar( void )
filesMenu->Append( ID_GERBVIEW_LOAD_DCODE_FILE, _( "Load DCodes" ), filesMenu->Append( ID_GERBVIEW_LOAD_DCODE_FILE, _( "Load DCodes" ),
_( "Load D-Codes File" ), FALSE ); _( "Load D-Codes File" ), FALSE );
#if 0 // TODO
filesMenu->Append( ID_GERBVIEW_LOAD_DRILL_FILE, _( "Load EXCELLON Drill File" ), filesMenu->Append( ID_GERBVIEW_LOAD_DRILL_FILE, _( "Load EXCELLON Drill File" ),
_( "Load excellon drill file" ), FALSE ); _( "Load excellon drill file" ), FALSE );
#endif
filesMenu->Append( ID_NEW_BOARD, _( "&Clear All" ), filesMenu->Append( ID_NEW_BOARD, _( "&Clear All" ),
_( "Clear all layers. All data will be deleted" ), FALSE ); _( "Clear all layers. All data will be deleted" ), FALSE );
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
* @param aSize The diameter of the round flash * @param aSize The diameter of the round flash
* @param aLayerNegative = true if the current layer is negative * @param aLayerNegative = true if the current layer is negative
*/ */
static void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem, void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
APERTURE_T aAperture, APERTURE_T aAperture,
int Dcode_index, int Dcode_index,
int aLayer, int aLayer,
...@@ -138,7 +138,7 @@ static void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem, ...@@ -138,7 +138,7 @@ static void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
* @param aPenSize The size of the flash. Note rectangular shapes are legal. * @param aPenSize The size of the flash. Note rectangular shapes are legal.
* @param aLayerNegative = true if the current layer is negative * @param aLayerNegative = true if the current layer is negative
*/ */
static void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem, void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
int Dcode_index, int Dcode_index,
int aLayer, int aLayer,
const wxPoint& aStart, const wxPoint& aStart,
...@@ -725,10 +725,6 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) ...@@ -725,10 +725,6 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
case 2: // code D2: exposure OFF (i.e. "move to") case 2: // code D2: exposure OFF (i.e. "move to")
m_Exposure = false; m_Exposure = false;
// D( printf( "Move to %d,%d to %d,%d\n",
// m_PreviousPos.x, m_PreviousPos.y,
// m_CurrentPos.x, m_CurrentPos.y ); )
m_PreviousPos = m_CurrentPos; m_PreviousPos = m_CurrentPos;
break; break;
...@@ -743,9 +739,6 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) ...@@ -743,9 +739,6 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
gbritem = new GERBER_DRAW_ITEM( pcb, this ); gbritem = new GERBER_DRAW_ITEM( pcb, this );
pcb->m_Drawings.Append( gbritem ); pcb->m_Drawings.Append( gbritem );
// D( printf( "Add flashed dcode %d layer %d at %d %d\n", dcode, activeLayer,
// m_CurrentPos.x, m_CurrentPos.y ); )
fillFlashedGBRITEM( gbritem, aperture, fillFlashedGBRITEM( gbritem, aperture,
dcode, activeLayer, m_CurrentPos, dcode, activeLayer, m_CurrentPos,
size, GetLayerParams().m_LayerNegative ); size, GetLayerParams().m_LayerNegative );
......
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