2009-11-09 14:00:22 +00:00
|
|
|
|
/**************/
|
|
|
|
|
/* gerbview.h */
|
|
|
|
|
/**************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
#ifndef GERBVIEW_H
|
|
|
|
|
#define GERBVIEW_H
|
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
#include <vector>
|
|
|
|
|
#include <set>
|
|
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
|
#include "dcode.h"
|
2010-10-01 19:11:30 +00:00
|
|
|
|
#include "class_gerber_draw_item.h"
|
|
|
|
|
#include "class_aperture_macro.h"
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
class WinEDA_GerberFrame;
|
|
|
|
|
class BOARD;
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
// Type of photoplotter action:
|
|
|
|
|
#define GERB_ACTIVE_DRAW 1 // Activate light (lower pen)
|
|
|
|
|
#define GERB_STOP_DRAW 2 // Extinguish light (lift pen)
|
2007-11-02 09:58:42 +00:00
|
|
|
|
#define GERB_FLASH 3 // Flash
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2007-11-02 09:58:42 +00:00
|
|
|
|
FORMAT_HPGL,
|
|
|
|
|
FORMAT_GERBER,
|
|
|
|
|
FORMAT_POST
|
|
|
|
|
} PlotFormat;
|
|
|
|
|
|
2010-01-29 20:36:12 +00:00
|
|
|
|
/**
|
|
|
|
|
* Enum ITEM_VISIBLE
|
|
|
|
|
* is a set of visible PCB elements.
|
|
|
|
|
*/
|
2010-02-03 14:05:17 +00:00
|
|
|
|
enum GERBER_VISIBLE
|
2010-01-29 20:36:12 +00:00
|
|
|
|
{
|
2010-02-03 14:05:17 +00:00
|
|
|
|
DCODES_VISIBLE = 1, // visible item id cannot be 0 because this id is used as wxWidget id
|
|
|
|
|
GERBER_GRID_VISIBLE,
|
|
|
|
|
END_GERBER_VISIBLE_LIST // sentinel
|
2010-01-29 20:36:12 +00:00
|
|
|
|
};
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
extern wxString g_PhotoFilenameExt;
|
|
|
|
|
extern wxString g_DrillFilenameExt;
|
|
|
|
|
extern wxString g_PenFilenameExt;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
extern int g_Default_GERBER_Format;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
extern int g_Plot_Spot_Mini; /* Diameter of the opening mini-track for
|
|
|
|
|
* GERBER */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
|
extern const wxString GerbviewProjectFileExt;
|
|
|
|
|
extern const wxString GerbviewProjectFileWildcard;
|
|
|
|
|
|
|
|
|
|
extern Ki_PageDescr* g_GerberPageSizeList[];
|
|
|
|
|
|
|
|
|
|
// Config keywords
|
|
|
|
|
extern const wxString GerbviewShowPageSizeOption;
|
2010-02-03 14:05:17 +00:00
|
|
|
|
extern const wxString GerbviewShowDCodes;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
// Interpolation type
|
2009-11-09 14:00:22 +00:00
|
|
|
|
enum Gerb_Interpolation
|
|
|
|
|
{
|
2007-11-02 09:58:42 +00:00
|
|
|
|
GERB_INTERPOL_LINEAR_1X = 0,
|
|
|
|
|
GERB_INTERPOL_LINEAR_10X,
|
|
|
|
|
GERB_INTERPOL_LINEAR_01X,
|
|
|
|
|
GERB_INTERPOL_LINEAR_001X,
|
|
|
|
|
GERB_INTERPOL_ARC_NEG,
|
2010-10-04 12:58:07 +00:00
|
|
|
|
GERB_INTERPOL_ARC_POS
|
2007-06-05 12:10:51 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Command Type (GCodes)
|
2009-11-09 14:00:22 +00:00
|
|
|
|
enum Gerb_GCommand
|
|
|
|
|
{
|
|
|
|
|
GC_MOVE = 0,
|
|
|
|
|
GC_LINEAR_INTERPOL_1X = 1,
|
|
|
|
|
GC_CIRCLE_NEG_INTERPOL = 2,
|
|
|
|
|
GC_CIRCLE_POS_INTERPOL = 3,
|
|
|
|
|
GC_COMMENT = 4,
|
|
|
|
|
GC_LINEAR_INTERPOL_10X = 10,
|
|
|
|
|
GC_LINEAR_INTERPOL_0P1X = 11,
|
|
|
|
|
GC_LINEAR_INTERPOL_0P01X = 12,
|
2007-11-02 09:58:42 +00:00
|
|
|
|
GC_TURN_ON_POLY_FILL = 36,
|
|
|
|
|
GC_TURN_OFF_POLY_FILL = 37,
|
2009-11-09 14:00:22 +00:00
|
|
|
|
GC_SELECT_TOOL = 54,
|
|
|
|
|
GC_PHOTO_MODE = 55, // can start a D03 flash command: redundant with D03
|
|
|
|
|
GC_SPECIFY_INCHES = 70,
|
2007-11-02 09:58:42 +00:00
|
|
|
|
GC_SPECIFY_MILLIMETERS = 71,
|
|
|
|
|
GC_TURN_OFF_360_INTERPOL = 74,
|
|
|
|
|
GC_TURN_ON_360_INTERPOL = 75,
|
|
|
|
|
GC_SPECIFY_ABSOLUES_COORD = 90,
|
|
|
|
|
GC_SPECIFY_RELATIVEES_COORD = 91
|
2007-06-05 12:10:51 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
enum Gerb_Analyse_Cmd
|
|
|
|
|
{
|
2007-11-02 09:58:42 +00:00
|
|
|
|
CMD_IDLE = 0,
|
|
|
|
|
END_BLOCK,
|
|
|
|
|
ENTER_RS274X_CMD
|
2007-06-05 12:10:51 +00:00
|
|
|
|
};
|
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
class D_CODE;
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Class GERBER
|
2008-11-07 07:55:28 +00:00
|
|
|
|
* holds the data for one gerber file or layer
|
|
|
|
|
*/
|
2008-11-08 06:44:07 +00:00
|
|
|
|
class GERBER
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2010-09-28 14:42:05 +00:00
|
|
|
|
D_CODE* m_Aperture_List[TOOLS_MAX_COUNT]; ///< Dcode (Aperture) List for this layer
|
2009-11-09 14:00:22 +00:00
|
|
|
|
bool m_Exposure; ///< whether an aperture macro tool is flashed on or off
|
2008-11-09 02:57:42 +00:00
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
|
BOARD* m_Pcb;
|
2008-11-09 02:57:42 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
public:
|
2009-11-09 14:00:22 +00:00
|
|
|
|
wxString m_FileName; // Full File Name for this layer
|
|
|
|
|
wxString m_Name; // Layer name
|
|
|
|
|
int m_Layer; // Layer Number
|
|
|
|
|
bool m_LayerNegative; // TRUE = Negative Layer
|
|
|
|
|
bool m_GerbMetric; // FALSE = Inches, TRUE = metric
|
|
|
|
|
bool m_Relative; // FALSE = absolute Coord, RUE = relative Coord
|
|
|
|
|
bool m_NoTrailingZeros; // True: remove tailing zeros.
|
|
|
|
|
bool m_MirorA; // True: miror / axe A (X)
|
|
|
|
|
bool m_MirorB; // True: miror / axe B (Y)
|
|
|
|
|
bool m_Has_DCode; // TRUE = DCodes in file (FALSE = no DCode->
|
2007-11-02 09:58:42 +00:00
|
|
|
|
// separate DCode file
|
2009-11-09 14:00:22 +00:00
|
|
|
|
wxPoint m_Offset; // Coord Offset
|
|
|
|
|
wxSize m_FmtScale; // Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4
|
|
|
|
|
wxSize m_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5
|
|
|
|
|
wxRealPoint m_LayerScale; // scale (X and Y) of layer.
|
2007-11-02 09:58:42 +00:00
|
|
|
|
int m_Rotation;
|
2009-11-09 14:00:22 +00:00
|
|
|
|
int m_Iterpolation; // Linear, 90 arc, Circ.
|
|
|
|
|
bool m_ImageNegative; // TRUE = Negative image
|
|
|
|
|
int m_Current_Tool; // Current Tool (Dcode) number selected
|
|
|
|
|
int m_Last_Pen_Command; // Current or last pen state (0..9, set by Dn option with n <10
|
|
|
|
|
int m_CommandState; // state of gerber analysis command.
|
|
|
|
|
wxPoint m_CurrentPos; // current specified coord for plot
|
|
|
|
|
wxPoint m_PreviousPos; // old current specified coord for plot
|
|
|
|
|
wxPoint m_IJPos; // IJ coord (for arcs & circles )
|
2007-11-02 09:58:42 +00:00
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
FILE* m_Current_File; // Current file to read
|
|
|
|
|
FILE* m_FilesList[12]; // Files list
|
|
|
|
|
int m_FilesPtr; // Stack pointer for files list
|
2007-11-02 09:58:42 +00:00
|
|
|
|
|
2010-10-04 12:58:07 +00:00
|
|
|
|
int m_Selected_Tool; // Pour editions: Tool (Dcode) selectionn<6E>
|
2007-11-02 09:58:42 +00:00
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
int m_Transform[2][2]; // The rotation/mirror transformation matrix.
|
|
|
|
|
bool m_360Arc_enbl; // Enbl 360 deg circular interpolation
|
|
|
|
|
bool m_PolygonFillMode; // Enbl polygon mode (read coord as a polygon descr)
|
|
|
|
|
int m_PolygonFillModeState; // In polygon mode: 0 = first segm, 1 = next segm
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
APERTURE_MACRO_SET m_aperture_macros; ///< a collection of APERTURE_MACROS, sorted by name
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
public:
|
2008-11-08 06:44:07 +00:00
|
|
|
|
GERBER( int layer );
|
|
|
|
|
~GERBER();
|
|
|
|
|
void Clear_GERBER();
|
2007-11-02 09:58:42 +00:00
|
|
|
|
int ReturnUsedDcodeNumber();
|
|
|
|
|
void ResetDefaultValues();
|
2008-11-09 02:57:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function InitToolTable
|
|
|
|
|
*/
|
2007-11-02 09:58:42 +00:00
|
|
|
|
void InitToolTable();
|
|
|
|
|
|
|
|
|
|
wxPoint ReadXYCoord( char*& Text );
|
|
|
|
|
wxPoint ReadIJCoord( char*& Text );
|
|
|
|
|
int ReturnGCodeNumber( char*& Text );
|
|
|
|
|
int ReturnDCodeNumber( char*& Text );
|
|
|
|
|
bool Execute_G_Command( char*& text, int G_commande );
|
2009-11-21 20:44:19 +00:00
|
|
|
|
bool Execute_DCODE_Command( WinEDA_GerberFrame* frame,
|
2007-11-02 09:58:42 +00:00
|
|
|
|
char*& text, int D_commande );
|
2008-11-07 07:55:28 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2008-12-29 20:05:47 +00:00
|
|
|
|
* size of single line of a text from a gerber file.
|
|
|
|
|
* warning: some files can have very long lines, so the buffer must be large.
|
2008-11-07 07:55:28 +00:00
|
|
|
|
*/
|
|
|
|
|
#define GERBER_BUFZ 4000
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function ReadRS274XCommand
|
|
|
|
|
* reads a single RS274X command terminated with a %
|
|
|
|
|
*/
|
2009-11-21 20:44:19 +00:00
|
|
|
|
bool ReadRS274XCommand( WinEDA_GerberFrame* frame,
|
2008-11-07 07:55:28 +00:00
|
|
|
|
char aBuff[GERBER_BUFZ], char*& text );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2008-11-07 07:55:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function ExecuteRS274XCommand
|
2009-11-09 14:00:22 +00:00
|
|
|
|
* executes 1 command
|
2008-11-07 07:55:28 +00:00
|
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
|
bool ExecuteRS274XCommand( int command, char aBuff[GERBER_BUFZ],
|
|
|
|
|
char*& text );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function ReadApertureMacro
|
|
|
|
|
* reads in an aperture macro and saves it in m_aperture_macros.
|
|
|
|
|
* @param aBuff a character buffer at least GERBER_BUFZ long that can be
|
|
|
|
|
* used to read successive lines from the gerber file.
|
2009-11-09 14:00:22 +00:00
|
|
|
|
* @param text A reference to a character pointer which gives the initial
|
|
|
|
|
* text to read from.
|
2008-11-08 06:44:07 +00:00
|
|
|
|
* @param gerber_file Which file to read from for continuation.
|
|
|
|
|
* @return bool - true if a macro was read in successfully, else false.
|
|
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
|
bool ReadApertureMacro( char aBuff[GERBER_BUFZ], char*& text,
|
|
|
|
|
FILE* gerber_file );
|
2008-11-09 02:57:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function GetDCODE
|
|
|
|
|
* returns a pointer to the D_CODE within this GERBER for the given
|
|
|
|
|
* \a aDCODE.
|
|
|
|
|
* @param aDCODE The numeric value of the D_CODE to look up.
|
2009-11-09 14:00:22 +00:00
|
|
|
|
* @param createIfNoExist If true, then create the D_CODE if it does not
|
|
|
|
|
* exist.
|
2008-11-09 02:57:42 +00:00
|
|
|
|
* @return D_CODE* - the one implied by the given \a aDCODE, or NULL
|
|
|
|
|
* if the requested \a aDCODE is out of range.
|
|
|
|
|
*/
|
|
|
|
|
D_CODE* GetDCODE( int aDCODE, bool createIfNoExist=true );
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function FindApertureMacro
|
|
|
|
|
* looks up a previously read in aperture macro.
|
|
|
|
|
* @param aLookup A dummy APERTURE_MACRO with [only] the name field set.
|
2009-11-09 14:00:22 +00:00
|
|
|
|
* @return APERTURE_MACRO* - the one with a matching name, or NULL if
|
|
|
|
|
* not found.
|
2008-11-09 02:57:42 +00:00
|
|
|
|
*/
|
|
|
|
|
APERTURE_MACRO* FindApertureMacro( const APERTURE_MACRO& aLookup );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
};
|
|
|
|
|
|
2008-11-07 07:55:28 +00:00
|
|
|
|
|
|
|
|
|
/**************/
|
|
|
|
|
/* rs274x.cpp */
|
|
|
|
|
/**************/
|
|
|
|
|
bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file );
|
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
extern GERBER* g_GERBER_List[32];
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
extern int g_DisplayPolygonsModeSketch;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
#include "pcbcommon.h"
|
2009-07-29 13:10:36 +00:00
|
|
|
|
#include "wxGerberFrame.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-11-02 09:58:42 +00:00
|
|
|
|
#endif // ifndef GERBVIEW_H
|