Gerbview: when running gerbview from a command line, if a filename is given, and if it is a .drl file, it is loaded as drill file (instead of a gerber file, which generate an error message).

Code refactor: remove useless class members,  and move read gerber file and read excellon file from gerbview frame to the corresponding classes
This commit is contained in:
jean-pierre charras 2016-06-05 14:26:39 +02:00
parent 6d1e904334
commit f311230874
11 changed files with 226 additions and 224 deletions

View File

@ -97,8 +97,8 @@ private:
excellon_state m_State; // state of excellon file analysis
bool m_SlotOn; // true during an oblong drill definition
public: EXCELLON_IMAGE( GERBVIEW_FRAME* aParent, int layer ) :
GERBER_FILE_IMAGE( aParent, layer )
public: EXCELLON_IMAGE( int layer ) :
GERBER_FILE_IMAGE( layer )
{
m_State = READ_HEADER_STATE;
m_SlotOn = false;
@ -114,7 +114,14 @@ public: EXCELLON_IMAGE( GERBVIEW_FRAME* aParent, int layer ) :
}
bool Read_EXCELLON_File( FILE* aFile, const wxString& aFullFileName );
/**
* Read and load a drill (EXCELLON format) file.
* @param aFullFileName = the full filename of the Gerber file
* when the file cannot be loaded
* Warning and info messages are stored in m_Messages
* @return bool if OK, false if the gerber file was not loaded
*/
bool LoadFile( const wxString& aFullFileName );
private:
bool Execute_HEADER_Command( char*& text );

View File

@ -31,6 +31,7 @@
#include <common.h>
#include <class_drawpanel.h>
#include <macros.h>
#include <convert_to_biu.h>
#include <gerbview.h>
#include <gerbview_frame.h>
@ -88,9 +89,8 @@ void GERBER_LAYER::ResetDefaultValues()
}
GERBER_FILE_IMAGE::GERBER_FILE_IMAGE( GERBVIEW_FRAME* aParent, int aLayer )
GERBER_FILE_IMAGE::GERBER_FILE_IMAGE( int aLayer )
{
m_parent = aParent;
m_GraphicLayer = aLayer; // Graphic layer Number
m_IsVisible = true; // must be drawn
m_PositiveDrawColor = WHITE; // The color used to draw positive items for this image
@ -215,6 +215,7 @@ void GERBER_FILE_IMAGE::ResetDefaultValues()
m_FilesList[ii] = NULL;
}
/* Function HasNegativeItems
* return true if at least one item must be drawn in background color
* used to optimize screen refresh
@ -243,7 +244,7 @@ bool GERBER_FILE_IMAGE::HasNegativeItems()
return m_hasNegativeItems == 1;
}
int GERBER_FILE_IMAGE::UsedDcodeNumber()
int GERBER_FILE_IMAGE::GetDcodesCount()
{
int count = 0;
@ -273,29 +274,6 @@ void GERBER_FILE_IMAGE::InitToolTable()
}
/**
* Function ReportMessage
* Add a message (a string) in message list
* for instance when reading a Gerber file
* @param aMessage = the straing to add in list
*/
void GERBER_FILE_IMAGE::ReportMessage( const wxString aMessage )
{
m_parent->ReportMessage( aMessage );
}
/**
* Function ClearMessageList
* Clear the message list
* Call it before reading a Gerber file
*/
void GERBER_FILE_IMAGE::ClearMessageList()
{
m_parent->ClearMessageList();
}
/**
* Function StepAndRepeatItem
* Gerber format has a command Step an Repeat
@ -340,40 +318,41 @@ void GERBER_FILE_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
* These parameters are valid for the entire file, and must set only once
* (If more than once, only the last value is used)
*/
void GERBER_FILE_IMAGE::DisplayImageInfo( void )
void GERBER_FILE_IMAGE::DisplayImageInfo( GERBVIEW_FRAME* aMainFrame )
{
wxString msg;
m_parent->ClearMsgPanel();
aMainFrame->ClearMsgPanel();
// Display Image name (Image specific)
m_parent->AppendMsgPanel( _( "Image name" ), m_ImageName, CYAN );
aMainFrame->AppendMsgPanel( _( "Image name" ), m_ImageName, CYAN );
// Display graphic layer number used to draw this Image
// (not a Gerber parameter but is also image specific)
msg.Printf( wxT( "%d" ), m_GraphicLayer + 1 );
m_parent->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN );
aMainFrame->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN );
// Display Image rotation (Image specific)
msg.Printf( wxT( "%d" ), m_ImageRotation );
m_parent->AppendMsgPanel( _( "Img Rot." ), msg, CYAN );
aMainFrame->AppendMsgPanel( _( "Img Rot." ), msg, CYAN );
// Display Image polarity (Image specific)
msg = m_ImageNegative ? _("Negative") : _("Normal");
m_parent->AppendMsgPanel( _( "Polarity" ), msg, BROWN );
aMainFrame->AppendMsgPanel( _( "Polarity" ), msg, BROWN );
// Display Image justification and offset for justification (Image specific)
msg = m_ImageJustifyXCenter ? _("Center") : _("Normal");
m_parent->AppendMsgPanel( _( "X Justify" ), msg, DARKRED );
aMainFrame->AppendMsgPanel( _( "X Justify" ), msg, DARKRED );
msg = m_ImageJustifyYCenter ? _("Center") : _("Normal");
m_parent->AppendMsgPanel( _( "Y Justify" ), msg, DARKRED );
aMainFrame->AppendMsgPanel( _( "Y Justify" ), msg, DARKRED );
if( g_UserUnit == INCHES )
msg.Printf( wxT( "X=%f Y=%f" ), (double) m_ImageJustifyOffset.x/10000,
(double) m_ImageJustifyOffset.y/10000 );
msg.Printf( wxT( "X=%f Y=%f" ), Iu2Mils( m_ImageJustifyOffset.x ) / 1000.0,
Iu2Mils( m_ImageJustifyOffset.y ) / 1000.0 );
else
msg.Printf( wxT( "X=%f Y=%f" ), (double) m_ImageJustifyOffset.x*2.54/1000,
(double) m_ImageJustifyOffset.y*2.54/1000 );
m_parent->AppendMsgPanel( _( "Image Justify Offset" ), msg, DARKRED );
msg.Printf( wxT( "X=%f Y=%f" ), Iu2Millimeter( m_ImageJustifyOffset.x ),
Iu2Millimeter( m_ImageJustifyOffset.y ) );
aMainFrame->AppendMsgPanel( _( "Image Justify Offset" ), msg, DARKRED );
}

View File

@ -94,7 +94,6 @@ private:
*/
class GERBER_FILE_IMAGE
{
GERBVIEW_FRAME* m_parent; // the parent GERBVIEW_FRAME (used to display messages...)
D_CODE* m_Aperture_List[TOOLS_MAX_COUNT]; ///< Dcode (Aperture) List for this layer (max 999)
bool m_Exposure; ///< whether an aperture macro tool is flashed on or off
@ -160,6 +159,7 @@ public:
APERTURE_MACRO_SET m_aperture_macros; ///< a collection of APERTURE_MACROS, sorted by name
private:
wxArrayString m_messagesList; // A list of messages created when reading a file
int m_hasNegativeItems; // true if the image is negative or has some negative items
// Used to optimize drawing, because when there are no
// negative items screen refresh does not need
@ -169,23 +169,31 @@ private:
// 1 = have negative items found
public:
GERBER_FILE_IMAGE( GERBVIEW_FRAME* aParent, int layer );
GERBER_FILE_IMAGE( int layer );
virtual ~GERBER_FILE_IMAGE();
void Clear_GERBER_FILE_IMAGE();
int UsedDcodeNumber();
/**
* Read and load a gerber file.
* @param aFullFileName = the full filename of the Gerber file
* when the file cannot be loaded
* Warning and info messages are stored in m_messagesList
* @return bool if OK, false if the gerber file was not loaded
*/
bool LoadGerberFile( const wxString& aFullFileName );
const wxArrayString& GetMessages() const { return m_messagesList; }
/**
* @return the count of Dcode tools in used by the image
*/
int GetDcodesCount();
virtual void ResetDefaultValues();
EDA_COLOR_T GetPositiveDrawColor() const { return m_PositiveDrawColor; }
/**
* Function GetParent
* @return the GERBVIEW_FRAME parent of this GERBER_FILE_IMAGE
*/
GERBVIEW_FRAME* GetParent() const
{
return m_parent;
}
/**
* Function GetItemsList
* @return the first GERBER_DRAW_ITEM * item of the items list
@ -209,20 +217,24 @@ public:
*/
bool HasNegativeItems();
/**
* Function ReportMessage
* Add a message (a string) in message list
* for instance when reading a Gerber file
* @param aMessage = the straing to add in list
*/
void ReportMessage( const wxString aMessage );
/**
* Function ClearMessageList
* Clear the message list
* Call it before reading a Gerber file
*/
void ClearMessageList();
void ClearMessageList()
{
m_messagesList.Clear();
}
/**
* Function AddMessageToList
* Add a message to the message list
*/
void AddMessageToList( const wxString& aMessage )
{
m_messagesList.Add( aMessage );
}
/**
* Function InitToolTable
@ -315,8 +327,9 @@ public:
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* Display info about Image Parameters.
* @param aMainFrame = the GERBVIEW_FRAME to display messages
*/
void DisplayImageInfo( void );
void DisplayImageInfo( GERBVIEW_FRAME* aMainFrame );
};
#endif // ifndef CLASS_GERBER_FILE_IMAGE_H

View File

@ -157,6 +157,44 @@ static EXCELLON_CMD excellon_G_CmdList[] =
};
bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName )
{
wxString msg;
int layerId = getActiveLayer(); // current layer used in GerbView
EXCELLON_IMAGE* drill_Layer = (EXCELLON_IMAGE*) g_GERBER_List.GetGbrImage( layerId );
if( drill_Layer == NULL )
{
drill_Layer = new EXCELLON_IMAGE( layerId );
layerId = g_GERBER_List.AddGbrImage( drill_Layer, layerId );
}
if( layerId < 0 )
{
DisplayError( this, _( "No room to load file" ) );
return false;
}
// Read the Excellon drill file:
bool success = drill_Layer->LoadFile( aFullFileName );
if( !success )
{
msg.Printf( _( "File %s not found" ), GetChars( aFullFileName ) );
DisplayError( this, msg );
return false;
}
// Display errors list
if( drill_Layer->GetMessages().size() > 0 )
{
HTML_MESSAGE_BOX dlg( this, _( "Error reading EXCELLON drill file" ) );
dlg.ListSet( drill_Layer->GetMessages() );
dlg.ShowModal();
}
return success;
}
/*
* Read a EXCELLON file.
* Gerber classes are used because there is likeness between Gerber files
@ -169,63 +207,19 @@ static EXCELLON_CMD excellon_G_CmdList[] =
* integer 2.4 format in imperial units,
* integer 3.2 or 3.3 format (metric units).
*/
bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName )
bool EXCELLON_IMAGE::LoadFile( const wxString & aFullFileName )
{
wxString msg;
int layerId = getActiveLayer(); // current layer used in GerbView
EXCELLON_IMAGE* drill_Layer = (EXCELLON_IMAGE*) g_GERBER_List.GetGbrImage( layerId );
if( drill_Layer == NULL )
{
drill_Layer = new EXCELLON_IMAGE( this, layerId );
layerId = g_GERBER_List.AddGbrImage( drill_Layer, layerId );
}
if( layerId < 0 )
{
DisplayError( this, _( "No room to load file" ) );
return false;
}
ClearMessageList();
// Read the Excellon drill file:
FILE * file = wxFopen( aFullFileName, wxT( "rt" ) );
if( file == NULL )
{
msg.Printf( _( "File %s not found" ), GetChars( aFullFileName ) );
DisplayError( this, msg );
return false;
}
wxString path = wxPathOnly( aFullFileName );
if( path != wxEmptyString )
wxSetWorkingDirectory( path );
bool success = drill_Layer->Read_EXCELLON_File( file, aFullFileName );
// Display errors list
if( m_Messages.size() > 0 )
{
HTML_MESSAGE_BOX dlg( this, _( "Error reading EXCELLON drill file" ) );
dlg.ListSet( m_Messages );
dlg.ShowModal();
}
return success;
}
bool EXCELLON_IMAGE::Read_EXCELLON_File( FILE * aFile,
const wxString & aFullFileName )
{
wxASSERT( aFile );
// Set the default parmeter values:
ResetDefaultValues();
ClearMessageList();
m_Current_File = wxFopen( aFullFileName, wxT( "rt" ) );
if( m_Current_File == NULL )
return false;
m_FileName = aFullFileName;
m_Current_File = aFile;
LOCALE_IO toggleIo;
@ -284,8 +278,7 @@ bool EXCELLON_IMAGE::Read_EXCELLON_File( FILE * aFile,
{
wxString msg;
msg.Printf( wxT( "Unexpected symbol &lt;%c&gt;" ), *text );
if( GetParent() )
GetParent()->ReportMessage( msg );
AddMessageToList( msg );
}
break;
} // End switch
@ -330,7 +323,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
if( !cmd )
{
msg.Printf( wxT( "Unknown Excellon command &lt;%s&gt;" ), text );
ReportMessage( msg );
AddMessageToList( msg );
while( *text )
text++;
@ -377,7 +370,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
SelectUnits( true );
if( *text != ',' )
{
ReportMessage( _( "METRIC command has no parameter" ) );
AddMessageToList( _( "METRIC command has no parameter" ) );
break;
}
text++; // skip separator
@ -395,7 +388,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
SelectUnits( false );
if( *text != ',' )
{
ReportMessage( _( "INCH command has no parameter" ) );
AddMessageToList( _( "INCH command has no parameter" ) );
break;
}
text++; // skip separator
@ -423,7 +416,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
case DRILL_INCREMENTALHEADER:
if( *text != ',' )
{
ReportMessage( _( "ICI command has no parameter" ) );
AddMessageToList( _( "ICI command has no parameter" ) );
break;
}
text++; // skip separator
@ -433,7 +426,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
else if( strnicmp( text, "ON", 2 ) == 0 )
m_Relative = true;
else
ReportMessage( _( "ICI command has incorrect parameter" ) );
AddMessageToList( _( "ICI command has incorrect parameter" ) );
break;
case DRILL_TOOL_CHANGE_STOP:
@ -486,10 +479,10 @@ bool EXCELLON_IMAGE::readToolInformation( char*& aText )
// Read tool shape
if( ! *aText )
ReportMessage( wxString:: Format(
AddMessageToList( wxString:: Format(
_( "Tool definition shape not found" ) ) );
else if( *aText != 'C' )
ReportMessage( wxString:: Format(
AddMessageToList( wxString:: Format(
_( "Tool definition '%c' not supported" ), *aText ) );
if( *aText )
aText++;
@ -544,7 +537,7 @@ bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text )
{
wxString msg;
msg.Printf( _( "Tool %d not defined" ), m_Current_Tool );
ReportMessage( msg );
AddMessageToList( msg );
return false;
}
@ -688,7 +681,7 @@ bool EXCELLON_IMAGE::Execute_EXCELLON_G_Command( char*& text )
{
wxString msg;
msg.Printf( _( "Unknown Excellon G Code: &lt;%s&gt;" ), GetChars(FROM_UTF8(gcmd)) );
ReportMessage( msg );
AddMessageToList( msg );
while( *text )
text++;
return false;

View File

@ -215,7 +215,16 @@ bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
for( unsigned i=0; i<limit; ++i, ++layer )
{
setActiveLayer( layer );
LoadGerberFiles( aFileSet[i] );
// Try to guess the type of file by its ext
// if it is .drl (Kicad files), it is a drill file
wxFileName fn( aFileSet[i] );
wxString ext = fn.GetExt();
if( ext == "drl" )
LoadExcellonFiles( aFileSet[i] );
else
LoadGerberFiles( aFileSet[i] );
}
}
@ -424,7 +433,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
if( gerber == NULL )
continue;
if( gerber->UsedDcodeNumber() == 0 )
if( gerber->GetDcodesCount() == 0 )
continue;
if( layer == curr_layer )
@ -501,7 +510,7 @@ void GERBVIEW_FRAME::UpdateTitleAndInfo()
SetTitle( text );
gerber->DisplayImageInfo();
gerber->DisplayImageInfo( this );
// Display Image Name and Layer Name (from the current gerber data):
text.Printf( _( "Image name: '%s' Layer name: '%s'" ),

View File

@ -1,9 +1,9 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -574,7 +574,7 @@ public:
bool Read_GERBER_File( const wxString& GERBER_FullFileName );
/**
* function LoadDrllFiles
* function Read_EXCELLON_File
* 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

View File

@ -45,7 +45,7 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( getActiveLayer() );
if( gerber )
gerber->DisplayImageInfo( );
gerber->DisplayImageInfo( this );
}
}

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2007-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -38,58 +38,89 @@
*/
bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName )
{
int G_command = 0; // command number for G commands like G04
int D_commande = 0; // command number for D commands like D02
char line[GERBER_BUFZ];
wxString msg;
char* text;
int layer; // current layer used in GerbView
layer = getActiveLayer();
int layer = getActiveLayer();
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
if( gerber == NULL )
{
gerber = new GERBER_FILE_IMAGE( this, layer );
gerber = new GERBER_FILE_IMAGE( layer );
g_GERBER_List.AddGbrImage( gerber, layer );
}
ClearMessageList( );
/* Set the gerber scale: */
gerber->ResetDefaultValues();
/* Read the gerber file */
gerber->m_Current_File = wxFopen( GERBER_FullFileName, wxT( "rt" ) );
if( gerber->m_Current_File == 0 )
bool success = gerber->LoadGerberFile( GERBER_FullFileName );
if( !success )
{
msg.Printf( _( "File <%s> not found" ), GetChars( GERBER_FullFileName ) );
DisplayError( this, msg, 10 );
return false;
}
gerber->m_FileName = GERBER_FullFileName;
// Display errors list
if( gerber->GetMessages().size() > 0 )
{
HTML_MESSAGE_BOX dlg( this, _("Errors") );
dlg.ListSet(gerber->GetMessages());
dlg.ShowModal();
}
wxString path = wxPathOnly( GERBER_FullFileName );
/* if the gerber file is only a RS274D file
* (i.e. without any aperture information), wran the user:
*/
if( !gerber->m_Has_DCode )
{
msg = _("Warning: this file has no D-Code definition\n"
"It is perhaps an old RS274D file\n"
"Therefore the size of items is undefined");
wxMessageBox( msg );
}
return true;
}
bool GERBER_FILE_IMAGE::LoadGerberFile( const wxString& aFullFileName )
{
int G_command = 0; // command number for G commands like G04
int D_commande = 0; // command number for D commands like D02
char line[GERBER_BUFZ];
char* text;
ClearMessageList( );
ResetDefaultValues();
// Read the gerber file */
m_Current_File = wxFopen( aFullFileName, wxT( "rt" ) );
if( m_Current_File == 0 )
return false;
m_FileName = aFullFileName;
wxString path = wxPathOnly( aFullFileName );
// This change is needed to load included files, if exists:
if( path != wxEmptyString )
wxSetWorkingDirectory( path );
LOCALE_IO toggleIo;
wxString msg;
while( true )
{
if( fgets( line, sizeof(line), gerber->m_Current_File ) == NULL )
if( fgets( line, sizeof(line), m_Current_File ) == NULL )
{
if( gerber->m_FilesPtr == 0 )
if( m_FilesPtr == 0 )
break;
fclose( gerber->m_Current_File );
fclose( m_Current_File );
gerber->m_FilesPtr--;
gerber->m_Current_File =
gerber->m_FilesList[gerber->m_FilesPtr];
m_FilesPtr--;
m_Current_File = m_FilesList[m_FilesPtr];
continue;
}
@ -107,57 +138,57 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName )
break;
case '*': // End command
gerber->m_CommandState = END_BLOCK;
m_CommandState = END_BLOCK;
text++;
break;
case 'M': // End file
gerber->m_CommandState = CMD_IDLE;
m_CommandState = CMD_IDLE;
while( *text )
text++;
break;
case 'G': /* Line type Gxx : command */
G_command = gerber->GCodeNumber( text );
gerber->Execute_G_Command( text, G_command );
G_command = GCodeNumber( text );
Execute_G_Command( text, G_command );
break;
case 'D': /* Line type Dxx : Tool selection (xx > 0) or
* command if xx = 0..9 */
D_commande = gerber->DCodeNumber( text );
gerber->Execute_DCODE_Command( text, D_commande );
D_commande = DCodeNumber( text );
Execute_DCODE_Command( text, D_commande );
break;
case 'X':
case 'Y': /* Move or draw command */
gerber->m_CurrentPos = gerber->ReadXYCoord( text );
m_CurrentPos = ReadXYCoord( text );
if( *text == '*' ) // command like X12550Y19250*
{
gerber->Execute_DCODE_Command( text,
gerber->m_Last_Pen_Command );
Execute_DCODE_Command( text,
m_Last_Pen_Command );
}
break;
case 'I':
case 'J': /* Auxiliary Move command */
gerber->m_IJPos = gerber->ReadIJCoord( text );
m_IJPos = ReadIJCoord( text );
if( *text == '*' ) // command like X35142Y15945J504*
{
gerber->Execute_DCODE_Command( text,
gerber->m_Last_Pen_Command );
Execute_DCODE_Command( text,
m_Last_Pen_Command );
}
break;
case '%':
if( gerber->m_CommandState != ENTER_RS274X_CMD )
if( m_CommandState != ENTER_RS274X_CMD )
{
gerber->m_CommandState = ENTER_RS274X_CMD;
gerber->ReadRS274XCommand( line, text );
m_CommandState = ENTER_RS274X_CMD;
ReadRS274XCommand( line, text );
}
else //Error
{
ReportMessage( wxT("Expected RS274X Command") );
gerber->m_CommandState = CMD_IDLE;
AddMessageToList( wxT("Expected RS274X Command") );
m_CommandState = CMD_IDLE;
text++;
}
break;
@ -165,34 +196,15 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName )
default:
text++;
msg.Printf( wxT("Unexpected symbol <%c>"), *text );
ReportMessage( msg );
AddMessageToList( msg );
break;
}
}
}
fclose( gerber->m_Current_File );
fclose( m_Current_File );
gerber->m_InUse = true;
// Display errors list
if( m_Messages.size() > 0 )
{
HTML_MESSAGE_BOX dlg( this, _("Errors") );
dlg.ListSet(m_Messages);
dlg.ShowModal();
}
/* if the gerber file is only a RS274D file
* (i.e. without any aperture information), wran the user:
*/
if( !gerber->m_Has_DCode )
{
msg = _("Warning: this file has no D-Code definition\n"
"It is perhaps an old RS274D file\n"
"Therefore the size of items is undefined");
wxMessageBox( msg );
}
m_InUse = true;
return true;
}

View File

@ -559,7 +559,7 @@ bool GERBER_FILE_IMAGE::Execute_G_Command( char*& text, int G_command )
{
wxString msg;
msg.Printf( wxT( "G%0.2d command not handled" ), G_command );
ReportMessage( msg );
AddMessageToList( msg );
return false;
}
}
@ -620,10 +620,6 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
case GERB_INTERPOL_ARC_POS:
gbritem = m_Drawings.GetLast();
// D( printf( "Add arc poly %d,%d to %d,%d fill %d interpol %d 360_enb %d\n",
// m_PreviousPos.x, m_PreviousPos.y, m_CurrentPos.x,
// m_CurrentPos.y, m_PolygonFillModeState,
// m_Iterpolation, m_360Arc_enbl ); )
fillArcPOLY( gbritem, m_PreviousPos,
m_CurrentPos, m_IJPos,
( m_Iterpolation == GERB_INTERPOL_ARC_NEG ) ? false : true,
@ -633,10 +629,6 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
default:
gbritem = m_Drawings.GetLast();
// D( printf( "Add poly edge %d,%d to %d,%d fill %d\n",
// m_PreviousPos.x, m_PreviousPos.y,
// m_CurrentPos.x, m_CurrentPos.y, m_Iterpolation ); )
gbritem->m_Start = m_PreviousPos; // m_Start is used as temporary storage
if( gbritem->m_PolyCorners.size() == 0 )
gbritem->m_PolyCorners.push_back( gbritem->m_Start );
@ -686,9 +678,6 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
gbritem = new GERBER_DRAW_ITEM( this );
m_Drawings.Append( gbritem );
// D( printf( "Add line %d,%d to %d,%d\n",
// m_PreviousPos.x, m_PreviousPos.y,
// m_CurrentPos.x, m_CurrentPos.y ); )
fillLineGBRITEM( gbritem, dcode, m_PreviousPos,
m_CurrentPos, size, GetLayerParams().m_LayerNegative );
StepAndRepeatItem( *gbritem );
@ -715,7 +704,7 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
default:
msg.Printf( wxT( "RS274D: DCODE Command: interpol error (type %X)" ),
m_Iterpolation );
ReportMessage( msg );
AddMessageToList( msg );
break;
}

View File

@ -296,14 +296,14 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& te
default:
msg.Printf( wxT( "Unknown id (%c) in FS command" ),
*text );
ReportMessage( msg );
AddMessageToList( msg );
GetEndOfBlock( buff, text, m_Current_File );
ok = false;
break;
}
}
if( !x_fmt_known || !y_fmt_known )
ReportMessage( wxT( "RS274X: Format Statement (FS) without X or Y format" ) );
AddMessageToList( wxT( "RS274X: Format Statement (FS) without X or Y format" ) );
break;
@ -439,7 +439,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& te
else if( strnicmp( text, "270*", 4 ) == 0 )
m_ImageRotation = 270;
else
ReportMessage( _( "RS274X: Command \"IR\" rotation value not allowed" ) );
AddMessageToList( _( "RS274X: Command \"IR\" rotation value not allowed" ) );
break;
case STEP_AND_REPEAT: // command SR, like %SRX3Y2I5.0J2*%
@ -531,7 +531,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& te
case KNOCKOUT:
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
msg = _( "RS274X: Command KNOCKOUT ignored by GerbView" ) ;
ReportMessage( msg );
AddMessageToList( msg );
break;
case PLOTTER_FILM: // Command PF <string>
@ -542,7 +542,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& te
{
msg.Append( *text++ );
}
ReportMessage( msg );
AddMessageToList( msg );
break;
case ROTATE: // Layer rotation: command like %RO45*%
@ -593,7 +593,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& te
if( m_FilesPtr >= INCLUDE_FILES_CNT_MAX )
{
ok = false;
ReportMessage( _( "Too many include files!!" ) );
AddMessageToList( _( "Too many include files!!" ) );
break;
}
@ -607,7 +607,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& te
if( m_Current_File == 0 )
{
msg.Printf( wxT( "include file <%s> not found." ), line );
ReportMessage( msg );
AddMessageToList( msg );
ok = false;
m_Current_File = m_FilesList[m_FilesPtr];
break;
@ -800,7 +800,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& te
{
msg.Printf( wxT( "RS274X: aperture macro %s not found\n" ),
TO_UTF8( am_lookup.name ) );
ReportMessage( msg );
AddMessageToList( msg );
ok = false;
break;
}
@ -943,7 +943,7 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *buff,
{
msg.Printf( wxT( "RS274X: Aperture Macro \"%s\": ill. symbol, line: \"%s\"" ),
GetChars( am.name ), GetChars( FROM_UTF8( buff ) ) );
ReportMessage( msg );
AddMessageToList( msg );
primitive_type = AMP_COMMENT;
}
else
@ -996,7 +996,7 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *buff,
// @todo, there needs to be a way of reporting the line number
msg.Printf( wxT( "RS274X: Aperture Macro \"%s\": Invalid primitive id code %d, line: \"%s\"" ),
GetChars( am.name ), primitive_type, GetChars( FROM_UTF8( buff ) ) );
ReportMessage( msg );
AddMessageToList( msg );
return false;
}
@ -1023,7 +1023,7 @@ bool GERBER_FILE_IMAGE::ReadApertureMacro( char *buff,
// maybe some day we can throw an exception and track a line number
msg.Printf( wxT( "RS274X: read macro descr type %d: read %d parameters, insufficient parameters\n" ),
prim.primitive_id, ii );
ReportMessage( msg );
AddMessageToList( msg );
}
// there are more parameters to read if this is an AMP_OUTLINE

View File

@ -424,7 +424,7 @@ bool DIALOG_NETLIST::verifyFootprints( const wxString& aNetlistFilename,
return false;
}
std::auto_ptr< NETLIST_READER > nlr( netlistReader );
std::unique_ptr< NETLIST_READER > nlr( netlistReader );
netlistReader->LoadNetlist();
}
catch( const IO_ERROR& ioe )