50 if( gerber !=
nullptr )
56 std::unique_ptr<GERBER_FILE_IMAGE> gerber_uptr = std::make_unique<GERBER_FILE_IMAGE>( layer );
60 bool success = gerber_uptr->LoadGerberFile( GERBER_FullFileName );
65 msg.Printf(
_(
"File '%s' not found" ), GERBER_FullFileName );
70 gerber = gerber_uptr.release();
71 wxASSERT( gerber !=
nullptr );
90 msg =
_(
"Warning: this file has no D-Code definition\n"
91 "Therefore the size of some items is undefined");
93 msg =
_(
"Warning: this file has some missing D-Code definitions\n"
94 "Therefore the size of some items is undefined");
142 char* letter =
nullptr;
143 bool foundADD =
false;
144 bool foundD0 =
false;
145 bool foundD2 =
false;
146 bool foundM0 =
false;
147 bool foundM2 =
false;
148 bool foundStar =
false;
166 for(
size_t i = 0; i < strlen( line ); i++ )
168 if( !isascii( line[i] ) )
172 if( strstr( line,
"%ADD" ) )
175 if( strstr( line,
"D00" ) || strstr( line,
"D0" ) )
178 if( strstr( line,
"D02" ) || strstr( line,
"D2" ) )
181 if( strstr( line,
"M00" ) || strstr( line,
"M0" ) )
184 if( strstr( line,
"M02" ) || strstr( line,
"M2" ) )
187 if( strstr( line,
"*" ) )
191 if( ( letter = strstr( line,
"X" ) ) != nullptr )
193 if( isdigit( letter[1] ) )
197 if( ( letter = strstr( line,
"Y" ) ) != nullptr )
199 if( isdigit( letter[1] ) )
210 if( ( foundD0 || foundD2 || foundM0 || foundM2 ) && foundADD && foundStar
211 && ( foundX || foundY ) )
217 else if( ( foundD0 || foundD2 || foundM0 || foundM2 ) && !foundADD && foundStar
218 && ( foundX || foundY ) )
326 msg.Printf( wxT(
"Unexpected char 0x%2.2X" ), *
text );
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
A LINE_READER that reads from an open file.
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
int AddGbrImage(GERBER_FILE_IMAGE *aGbrImage, int aIdx)
Add a GERBER_FILE_IMAGE* at index aIdx or at the first free location if aIdx < 0.
Hold the image data and parameters for one gerber file and layer parameters.
bool Execute_G_Command(char *&text, int G_command)
bool LoadGerberFile(const wxString &aFullFileName)
Read and load a gerber file.
int m_Last_Pen_Command
Current or last pen state (0..9, set by Dn option with n < 10.
VECTOR2I ReadIJCoord(char *&Text)
Return the current coordinate type pointed to by InnJnn Text (InnnnJmmmm)
static char m_LineBuffer[GERBER_BUFZ+1]
virtual void ResetDefaultValues()
Set all parameters to a default value, before reading a file.
const wxArrayString & GetMessages() const
void ClearMessageList()
Clear the message list.
wxString m_FileName
Full File Name for this layer.
bool m_InUse
true if this image is currently in use (a file is loaded in it) false if it must be not drawn
bool m_ImageNegative
true = Negative image
void AddMessageToList(const wxString &aMessage)
Add a message to the message list.
int m_LineNum
Line number of the gerber file while reading.
VECTOR2I m_IJPos
IJ coord (for arcs & circles )
bool Execute_DCODE_Command(char *&text, int D_command)
static bool TestFileIsRS274(const wxString &aFullFileName)
Performs a heuristics-based check of whether the file is an RS274 gerber file.
bool ReadRS274XCommand(char *aBuff, unsigned int aBuffSize, char *&aText)
Read a single RS274X command terminated with a %.
bool m_Has_DCode
< True if has DCodes in file or false if no DCodes found. Perhaps deprecated RS274D file.
VECTOR2I ReadXYCoord(char *&aText, bool aExcellonMode=false)
Return the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm).
int m_CommandState
state of gerber analysis command
VECTOR2I m_CurrentPos
current specified coord for plot
GERBER_DRAW_ITEMS & GetItems()
int CodeNumber(char *&aText)
Reads the next number and returns the value.
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
int GetActiveLayer() const
Return the active layer.
bool Read_GERBER_File(const wxString &GERBER_FullFileName)
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
void Erase_Current_DrawLayer(bool query)
void ListSet(const wxString &aList)
Add a list of items.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
An abstract base class for deriving all objects that can be added to a VIEW.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
char * Line() const
Return a pointer to the last line that was read in.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
This file contains miscellaneous commonly used macros and functions.
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.