21#ifndef GERBER_FILE_IMAGE_H
22#define GERBER_FILE_IMAGE_H
104#define GERBER_BUFZ 5000000
117 wxString
GetClass()
const override {
return wxT(
"GERBER_FILE_IMAGE" ); }
324 void Show(
int nestLevel, std::ostream& os )
const override { ShowDummy( os ); }
341 char*
GetNextLine(
char* aBuff,
unsigned int aBuffSize,
char* aText, FILE* aFile );
343 bool GetEndOfBlock(
char* aBuff,
unsigned int aBuffSize,
char*& aText, FILE* aGerberFile );
std::set< APERTURE_MACRO, APERTURE_MACRO_less_than > APERTURE_MACRO_SET
A sorted collection of APERTURE_MACROS whose key is the name field in the APERTURE_MACRO.
Support the "aperture macro" defined within standard RS274X.
A gerber DCODE (also called Aperture) definition.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
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.
void SetDrawOffetAndRotation(VECTOR2D aOffsetMM, EDA_ANGLE aRotation)
Set the offset and rotation to draw a file image Does not change any coordinate od draw items.
int m_Last_Pen_Command
Current or last pen state (0..9, set by Dn option with n < 10.
GERBER_DRAW_ITEM * GetLastItemInList() const
APERTURE_MACRO * FindApertureMacro(const APERTURE_MACRO &aLookup)
Look up a previously read in aperture macro.
VECTOR2I ReadIJCoord(char *&Text)
Return the current coordinate type pointed to by InnJnn Text (InnnnJmmmm)
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
file function parameters, found in a %TF command or a G04
void RemoveAttribute(X2_ATTRIBUTE &aAttribute)
Called when a TD command is found the Gerber file.
static char m_LineBuffer[GERBER_BUFZ+1]
int m_hasNegativeItems
True if the image is negative or has some negative items.
virtual void ResetDefaultValues()
Set all parameters to a default value, before reading a file.
const wxArrayString & GetMessages() const
bool m_SwapAxis
false if A = X and B = Y (default); true if A = Y, B = X
GERBER_FILE_IMAGE(int layer)
void ClearMessageList()
Clear the message list.
double m_LocalRotation
Local rotation added to m_ImageRotation.
const GERBER_DRAW_ITEMS & GetItems() const
VECTOR2I m_Offset
Coord Offset, from OF command.
EDA_ANGLE m_DisplayRotation
wxSize m_FmtScale
Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4.
virtual ~GERBER_FILE_IMAGE()
int m_ArcRadius
A value ( = radius in circular routing in Excellon files ).
wxString m_FileName
Full File Name for this layer.
void StepAndRepeatItem(const GERBER_DRAW_ITEM &aItem)
Gerber format has a command Step an Repeat.
bool m_ImageJustifyXCenter
Image Justify Center on X axis (default = false)
void FinishStepAndRepeatBlock()
Called when an SR block is closed (SR*%).
bool m_ImageJustifyYCenter
Image Justify Center on Y axis (default = false)
VECTOR2I m_DisplayOffset
Parameters used only to draw (display) items on this layer.
VECTOR2I m_PreviousPos
old current specified coord for plot
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.
LAST_EXTRA_ARC_DATA_TYPE m_LastArcDataType
Identifier for arc data type (IJ (center) or A## (radius)).
bool m_Exposure
Whether an aperture macro tool is flashed on or off.
wxArrayString m_messagesList
COLOR4D GetPositiveDrawColor() const
int m_LineNum
Line number of the gerber file while reading.
COLOR4D m_PositiveDrawColor
The color used to draw positive items.
std::map< wxString, int > m_ComponentsList
std::map< int, D_CODE * > m_ApertureList
Dcode (Aperture) List for this layer (see dcode.h)
VECTOR2I m_IJPos
IJ coord (for arcs & circles )
wxString m_ImageName
Image name, from IN <name>* command.
bool m_Relative
false = absolute Coord, true = relative Coord.
bool Execute_DCODE_Command(char *&text, int D_command)
wxString m_MD5_value
MD5 value found in a %TF.MD5 command.
char * GetNextLine(char *aBuff, unsigned int aBuffSize, char *aText, FILE *aFile)
Test for an end of line.
static bool TestFileIsRS274(const wxString &aFullFileName)
Performs a heuristics-based check of whether the file is an RS274 gerber file.
bool m_MirrorB
true: mirror / axis B (Y)
wxString m_PartString
string found in a %TF.Part command
D_CODE * GetDCODE(int aDCODE) const
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
bool ReadRS274XCommand(char *aBuff, unsigned int aBuffSize, char *&aText)
Read a single RS274X command terminated with a %.
double CalculateCopperArea()
Calculate the total copper area in the image.
int GetItemsCount() const
bool m_IsX2_file
True if a X2 gerber attribute was found in file.
int m_ImageRotation
Image rotation (0, 90, 180, 270 only) in degrees.
VECTOR2I m_ImageOffset
Coord Offset, from IO command.
int m_PolygonFillModeState
bool m_Has_DCode
True if has DCodes in file or false if no DCodes found. Perhaps deprecated RS274D file.
bool GetEndOfBlock(char *aBuff, unsigned int aBuffSize, char *&aText, FILE *aGerberFile)
bool ReadApertureMacro(char *aBuff, unsigned int aBuffSize, char *&text, FILE *gerber_file)
Read in an aperture macro and saves it in m_aperture_macros.
int m_Current_Tool
Current Tool (Dcode) number selected.
D_CODE * GetDCODEOrCreate(int aDCODE, bool aCreateIfNoExist=true)
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
void AddItemToList(GERBER_DRAW_ITEM *aItem)
Add a new GERBER_DRAW_ITEM item to the drawings list.
VECTOR2I ReadXYCoord(char *&aText, bool aExcellonMode=false)
Return the current coordinate type pointed to by XnnYnn Text (XnnnnYmmmm).
bool ExecuteRS274XCommand(int aCommand, char *aBuff, unsigned int aBuffSize, char *&aText)
Execute a RS274X command.
wxSize m_FmtLen
Nb chars per coord. ex fmt 2.3, m_FmtLen = 5.
VECTOR2D m_Scale
scale (X and Y) of layer.
std::map< wxString, int > m_NetnamesList
wxString GetClass() const override
Return the class name.
int m_GraphicLayer
Graphic layer Number.
APERTURE_MACRO_SET m_aperture_macros
a collection of APERTURE_MACROS, sorted by name
int ReadXCommandID(char *&text)
Read two bytes of data and assembles them into an int with the first byte in the sequence put into th...
GERBER_DRAW_ITEMS m_drawings
bool m_GerbMetric
false = Inches, true = metric
GBR_NETLIST_METADATA m_NetAttributeDict
int m_CommandState
state of gerber analysis command
wxString m_ArchiveFileName
Archive containing this layer, if loaded from a ZIP file.
bool m_NoTrailingZeros
true: remove tailing zeros.
int m_Iterpolation
Linear, 90 arc, Circ.
VECTOR2I m_CurrentPos
current specified coord for plot
bool m_MirrorA
true: mirror / axis A (X)
bool m_LastCoordIsIJPos
True if a IJ coord was read (for arcs & circles ).
GERBER_DRAW_ITEMS & GetItems()
VECTOR2I m_ImageJustifyOffset
Image Justify Offset on XY axis (default = 0,0)
int CodeNumber(char *&aText)
Reads the next number and returns the value.
GERBER_LAYER m_GBRLayerParams
GERBER_LAYER & GetLayerParams()
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Display information about image parameters in the status bar.
INSPECT_RESULT Visit(INSPECTOR aInspector, void *aTestData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
bool HasNegativeItems()
Return true if at least one item must be drawn in background color used to optimize screen refresh.
void ResetDefaultValues()
friend class GERBER_FILE_IMAGE
wxRealPoint m_StepForRepeat
bool m_StepForRepeatMetric
A color representation with 4 components: red, green, blue, alpha.
X2_ATTRIBUTE_FILEFUNCTION ( from TF.FileFunction in Gerber file) Example file function: TF....
The attribute value consists of a number of substrings separated by a comma.
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
std::vector< GERBER_DRAW_ITEM * > GERBER_DRAW_ITEMS
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D