Commit 0687921f authored by jean-pierre charras's avatar jean-pierre charras

Gerbview: display now an error report after loading a gerber file.

parent 0f64b352
......@@ -23,13 +23,13 @@ void DIALOG_LOAD_ERROR::ListClear(void)
/** Function ListSet
* Add a list of items.
* @param list = a string containing items. Items are separated by '\n'
* @param aList = a string containing items. Items are separated by '\n'
*/
void DIALOG_LOAD_ERROR::ListSet(const wxString &list)
void DIALOG_LOAD_ERROR::ListSet(const wxString &aList)
{
wxArrayString* wxStringSplit( wxString txt, wxChar splitter );
wxArrayString* strings_list = wxStringSplit( list, wxChar('\n') );
wxArrayString* strings_list = wxStringSplit( aList, wxChar('\n') );
m_htmlWindow->AppendToPage(wxT("<ul>") );
for ( unsigned ii = 0; ii < strings_list->GetCount(); ii ++ )
{
......@@ -42,6 +42,22 @@ void DIALOG_LOAD_ERROR::ListSet(const wxString &list)
delete strings_list;
}
/** Function ListSet
* Add a list of items.
* @param aList = a wxArrayString containing items
*/
void DIALOG_LOAD_ERROR::ListSet(const wxArrayString &aList)
{
m_htmlWindow->AppendToPage(wxT("<ul>") );
for ( unsigned ii = 0; ii < aList.GetCount(); ii ++ )
{
m_htmlWindow->AppendToPage(wxT("<li>") );
m_htmlWindow->AppendToPage( aList.Item(ii) );
m_htmlWindow->AppendToPage(wxT("</li>") );
}
m_htmlWindow->AppendToPage(wxT("</ul>") );
}
/** Function MessageSet
* Add a message (in bold) to message list.
* @param message = the message
......
......@@ -39,7 +39,7 @@
/* Definitions for enabling and disabling debugging features in gr_basic.cpp.
* Please remember to set these back to 0 before making SVN commits.
* Please remember to set these back to 0 before making LAUNCHPAD commits.
*/
#define DEBUG_DUMP_CLIP_ERROR_COORDS 0 // Set to 1 to dump clip algorithm errors.
#define DEBUG_DUMP_CLIP_COORDS 0 // Set to 1 to dump clipped coordinates.
......@@ -834,6 +834,8 @@ void GRMixedLine( EDA_Rect* ClipBox,
/*
* Draw a mixed line, in screen (Pixels) space.
* Currently, draw a line (not a mixed line)
* Perhaps this function is not very useful.
*/
void GRSMixedLine( EDA_Rect* ClipBox,
wxDC* DC,
......
......@@ -182,6 +182,8 @@ void GERBER::InitToolTable()
m_Aperture_List[count]->m_Num_Dcode = count + FIRST_DCODE;
m_Aperture_List[count]->Clear_D_CODE_Data();
}
m_aperture_macros.clear();
}
/** function ReportMessage
......
......@@ -17,6 +17,9 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame,
const wxString& FullFileName );
/* Load agerber file selected from history list on current layer
* Previous data is deleted
*/
void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event )
{
wxString fn;
......@@ -53,6 +56,7 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
if( origLayer < NB_LAYERS )
{
setActiveLayer(origLayer+1);
Erase_Current_Layer( false );
if( !LoadOneGerberFile( wxEmptyString ) )
setActiveLayer(origLayer);
......@@ -69,10 +73,6 @@ delete an existing layer to load any new layers." ), NB_LAYERS );
}
break;
case ID_APPEND_FILE:
LoadOneGerberFile( wxEmptyString );
break;
case ID_NEW_BOARD:
Clear_Pcb( true );
Zoom_Automatique( false );
......@@ -87,14 +87,6 @@ delete an existing layer to load any new layers." ), NB_LAYERS );
LoadDCodeFile( this, wxEmptyString );
break;
case ID_SAVE_BOARD:
SaveGerberFile( GetScreen()->m_FileName );
break;
case ID_SAVE_BOARD_AS:
SaveGerberFile( wxEmptyString );
break;
default:
DisplayError( this, wxT( "File_io Internal Error" ) );
break;
......
......@@ -32,20 +32,15 @@ BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_GerberFrame::OnZoom )
EVT_TOOL( wxID_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_SAVE_BOARD, WinEDA_GerberFrame::Files_io )
// Menu Files:
EVT_MENU( wxID_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_SAVE_BOARD, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_SAVE_BOARD_AS, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_GEN_PLOT, WinEDA_GerberFrame::ToPlotter )
EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW,
WinEDA_GerberFrame::ExportDataInPcbnewFormat )
......
......@@ -31,11 +31,7 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void )
wxMenu* filesMenu = new wxMenu;
filesMenu->Append( wxID_FILE, _( "Load Gerber File" ),
_( "Load a new Gerber file on the current layer" ),
FALSE );
filesMenu->Append( ID_APPEND_FILE, _( "Append Gerber File to Current Layer" ),
_( "Append a new Gerber file to the current layer" ),
_( "Load a new Gerber file on the current layer. Previous data will be deleted" ),
FALSE );
filesMenu->Append( ID_MENU_INC_LAYER_AND_APPEND_FILE,
......@@ -45,26 +41,18 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void )
filesMenu->Append( ID_GERBVIEW_LOAD_DCODE_FILE, _( "Load DCodes" ),
_( "Load D-Codes File" ), FALSE );
#if 0
#if 0 // TODO
filesMenu->Append( ID_GERBVIEW_LOAD_DRILL_FILE, _( "Load EXCELLON Drill File" ),
_( "Load excellon drill file" ), FALSE );
#endif
filesMenu->Append( ID_NEW_BOARD, _( "&Clear All" ),
_( "Clear all layers" ), FALSE );
_( "Clear all layers. All data will be deleted" ), FALSE );
filesMenu->AppendSeparator();
filesMenu->Append( ID_GERBVIEW_EXPORT_TO_PCBNEW, _( "&Export to Pcbnew" ),
_( "Export data in pcbnew format" ), FALSE );
#if 0
filesMenu->AppendSeparator();
filesMenu->Append( ID_SAVE_BOARD, _( "&Save Layers" ),
_( "Save current layers (GERBER format)" ), FALSE );
filesMenu->Append( ID_SAVE_BOARD_AS, _( "Save Layers As..." ),
_( "Save current layers as.." ), FALSE );
#endif
filesMenu->AppendSeparator();
......
......@@ -11,6 +11,7 @@
#include "pcbplot.h"
#include "protos.h"
#include "dialog_load_error.h"
/* Read a gerber file, RS274D or RS274X format.
*/
......@@ -27,7 +28,6 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName,
char* text;
int layer; /* current layer used in gerbview */
GERBER* gerber;
int error = 0;
layer = GetScreen()->m_Active_Layer;
......@@ -57,7 +57,6 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName,
if( path != wxEmptyString )
wxSetWorkingDirectory( path );
wxBusyCursor show_wait;
SetLocaleTo_C_standard();
while( TRUE )
......@@ -130,15 +129,11 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName,
if( gerber->m_CommandState != ENTER_RS274X_CMD )
{
gerber->m_CommandState = ENTER_RS274X_CMD;
if( !gerber->ReadRS274XCommand( this, line, text ) )
{
error++;
}
gerber->ReadRS274XCommand( this, line, text );
}
else //Error
{
error++;
ReportMessage( wxT("Expected RS274X Command") );
gerber->m_CommandState = CMD_IDLE;
text++;
}
......@@ -146,25 +141,27 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName,
default:
text++;
error++;
msg.Printf( wxT("Unexpected symbol <%c>"), *text );
ReportMessage( msg );
break;
}
}
}
fclose( gerber->m_Current_File );
if( error )
// Display errors list
if( m_Messages.size() > 0 )
{
msg.Printf( _( "%d errors while reading Gerber file [%s]" ),
error, GetChars(GERBER_FullFileName) );
DisplayError( this, msg );
DIALOG_LOAD_ERROR dlg( this );
dlg.ListSet(m_Messages);
dlg.ShowModal();
}
fclose( gerber->m_Current_File );
SetLocaleTo_Default();
/* Init DCodes list and perhaps read a DCODES file,
* if the gerber file is only a RS274D file (without any aperture
* information)
* if the gerber file is only a RS274D file
* (i.e. without any aperture information)
*/
if( !gerber->m_Has_DCode )
{
......
......@@ -975,7 +975,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, char*& text, int
break;
default:
msg.Printf( wxT( "Execute_DCODE_Command: interpol error (type %X)" ),
msg.Printf( wxT( "RS274D: DCODE Command: interpol error (type %X)" ),
m_Iterpolation );
ReportMessage( msg );
break;
......
......@@ -296,7 +296,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
case STEP_AND_REPEAT:
case ROTATE:
{
msg.Printf( _( "Command <%c%c> ignored by Gerbview" ),
msg.Printf( _( "RS274X: Command \"%c%c\" ignored by Gerbview" ),
(command >> 8) & 0xFF, command & 0xFF );
ReportMessage( msg );
}
......@@ -531,7 +531,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
APERTURE_MACRO* pam = FindApertureMacro( am_lookup );
if( !pam )
{
msg.Printf( wxT( "aperture macro %s not found\n" ),
msg.Printf( wxT( "RS274X: aperture macro %s not found\n" ),
CONV_TO_UTF8( am_lookup.name ) );
ReportMessage( msg );
ok = false;
......@@ -676,7 +676,7 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
default:
// @todo, there needs to be a way of reporting the line number
msg.Printf( wxT( "Invalid primitive id code %d\n" ), prim.primitive_id );
msg.Printf( wxT( "RS274X: Invalid primitive id code %d\n" ), prim.primitive_id );
ReportMessage( msg );
return false;
}
......@@ -702,7 +702,7 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
if( i < paramCount )
{ // maybe some day we can throw an exception and track a line number
msg.Printf( wxT( "read macro descr type %d: read %d parameters, insufficient parameters\n" ),
msg.Printf( wxT( "RS274X: read macro descr type %d: read %d parameters, insufficient parameters\n" ),
prim.primitive_id, i );
ReportMessage( msg );
}
......
......@@ -42,16 +42,15 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
// Set up toolbar
m_HToolBar->AddTool( ID_NEW_BOARD, wxEmptyString,
wxBitmap( new_xpm ),
_( "New world" ) );
_( "Erase all layers" ) );
m_HToolBar->AddTool( wxID_FILE, wxEmptyString,
wxBitmap( open_xpm ),
_( "Open existing Layer" ) );
_( "Load a new Gerber file on the current layer. Previous data will be deleted" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( wxID_UNDO, wxEmptyString,
wxBitmap( undelete_xpm ),
_( "Undelete" ) );
......@@ -59,7 +58,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( wxID_PRINT, wxEmptyString,
wxBitmap( print_button ),
_( "Print world" ) );
_( "Print layers" ) );
m_HToolBar->AddSeparator();
msg = AddHotkeyName( _( "Zoom in" ), s_Gerbview_Hokeys_Descr, HK_ZOOM_IN );
......
......@@ -18,11 +18,18 @@ protected:
public:
/** Constructor */
DIALOG_LOAD_ERROR( wxWindow* parent );
/** Function ListSet
* Add a list of items.
* @param list = a string containing items. Items are separated by '\n'
*/
void ListSet(const wxString &list);
/** Function ListSet
* Add a list of items.
* @param list = a wxArrayString containing items.
*/
void ListSet(const wxArrayString &list);
void ListClear();
/** Function MessageSet
* Add a message (in bold) to message list.
......
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