Commit 035979d3 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

More work on Gerbview: code cleaning and cosmetic enhancements.

parent 0687921f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ set(GERBVIEW_SRCS
    controle.cpp
    controle.cpp
    dcode.cpp
    dcode.cpp
    deltrack.cpp
    deltrack.cpp
    dialog_gerber_config.cpp
    dialog_print_using_printer.cpp
    dialog_print_using_printer.cpp
    dialog_print_using_printer_base.cpp
    dialog_print_using_printer_base.cpp
    dummy_functions.cpp
    dummy_functions.cpp
@@ -41,7 +42,6 @@ set(GERBVIEW_SRCS
    options.cpp
    options.cpp
    pcbplot.cpp
    pcbplot.cpp
    readgerb.cpp
    readgerb.cpp
    reglage.cpp
    rs274d.cpp
    rs274d.cpp
    rs274x.cpp
    rs274x.cpp
    select_layers_to_pcb.cpp
    select_layers_to_pcb.cpp
+0 −1
Original line number Original line Diff line number Diff line
@@ -36,7 +36,6 @@


#include "gerbview.h"
#include "gerbview.h"
#include "class_gerber_draw_item.h"
#include "class_gerber_draw_item.h"
#include "protos.h"




#define BLOCK_COLOR BROWN
#define BLOCK_COLOR BROWN
+29 −26
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@
#include "macros.h"
#include "macros.h"


#include "gerbview.h"
#include "gerbview.h"
#include "class_GERBER.h"


/* Format Gerber: NOTES:
/* Format Gerber: NOTES:
 * Tools and D_CODES
 * Tools and D_CODES
@@ -118,7 +119,8 @@ APERTURE_MACRO* GERBER::FindApertureMacro( const APERTURE_MACRO& aLookup )
void GERBER::ResetDefaultValues()
void GERBER::ResetDefaultValues()
{
{
    m_FileName.Empty();
    m_FileName.Empty();
    m_Name = wxT( "no name" );          // Layer name
    m_ImageName     = wxT( "no image name" );   // Image name from the IN command
    m_LayerName     = wxT( "no layer name" );   // Layer name from the LN command
    m_LayerNegative = FALSE;                    // TRUE = Negative Layer
    m_LayerNegative = FALSE;                    // TRUE = Negative Layer
    m_ImageNegative = FALSE;                    // TRUE = Negative image
    m_ImageNegative = FALSE;                    // TRUE = Negative image
    m_GerbMetric    = FALSE;                    // FALSE = Inches, TRUE = metric
    m_GerbMetric    = FALSE;                    // FALSE = Inches, TRUE = metric
@@ -127,9 +129,9 @@ void GERBER::ResetDefaultValues()
    m_NoTrailingZeros = FALSE;                  // True: trailing zeros deleted
    m_NoTrailingZeros = FALSE;                  // True: trailing zeros deleted
    m_MirorA    = FALSE;                        // True: miror / axe A (X)
    m_MirorA    = FALSE;                        // True: miror / axe A (X)
    m_MirorB    = FALSE;                        // True: miror / axe B (Y)
    m_MirorB    = FALSE;                        // True: miror / axe B (Y)
    m_Has_DCode = FALSE;                // TRUE = DCodes in file (FALSE = no
    m_Has_DCode = FALSE;                        // TRUE = DCodes in file
                                        // DCode->
                                                // FALSE = no DCode->
                                        // separate DCode file
                                                // search for separate DCode file


    m_FmtScale.x = m_FmtScale.y = g_Default_GERBER_Format % 10;
    m_FmtScale.x = m_FmtScale.y = g_Default_GERBER_Format % 10;
    m_FmtLen.x   = m_FmtLen.y = m_FmtScale.x + (g_Default_GERBER_Format / 10);
    m_FmtLen.x   = m_FmtLen.y = m_FmtScale.x + (g_Default_GERBER_Format / 10);
@@ -186,6 +188,7 @@ void GERBER::InitToolTable()
    m_aperture_macros.clear();
    m_aperture_macros.clear();
}
}



/** function ReportMessage
/** function ReportMessage
 * Add a message (a string) in message list
 * Add a message (a string) in message list
 * for instance when reading a Gerber file
 * for instance when reading a Gerber file
@@ -196,6 +199,7 @@ void GERBER::ReportMessage(const wxString aMessage )
    m_Parent->ReportMessage( aMessage );
    m_Parent->ReportMessage( aMessage );
}
}



/** function ClearMessageList
/** function ClearMessageList
 * Clear the message list
 * Clear the message list
 * Call it before reading a Gerber file
 * Call it before reading a Gerber file
@@ -204,4 +208,3 @@ void GERBER::ClearMessageList( )
{
{
    m_Parent->ClearMessageList();
    m_Parent->ClearMessageList();
}
}
+157 −0
Original line number Original line Diff line number Diff line
/******************/
/* class_GERBER.h */
/******************/

#ifndef _CLASS_GERBER_H_
#define _CLASS_GERBER_H_

#include <vector>
#include <set>

#include "dcode.h"
#include "class_gerber_draw_item.h"
#include "class_aperture_macro.h"

class WinEDA_GerberFrame;
class BOARD;
class D_CODE;


/**
 * Class GERBER
 * holds the data for one gerber file or layer
 */
class GERBER
{
    WinEDA_GerberFrame* m_Parent;                           // the parent WinEDA_GerberFrame (used to display messages...)
    D_CODE*             m_Aperture_List[TOOLS_MAX_COUNT];   ///< Dcode (Aperture) List for this layer
    bool               m_Exposure;                          ///< whether an aperture macro tool is flashed on or off

    BOARD*             m_Pcb;

public:
    wxString           m_FileName;              // Full File Name for this layer
    wxString           m_ImageName;             // Image name, from IN <name>* command
    wxString           m_LayerName;             // Layer name, from LN <name>* command
    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 -> separate DCode file
    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.
    int                m_Rotation;
    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 )

    FILE*              m_Current_File;          // Current file to read
    #define            INCLUDE_FILES_COUNT_MAX 10
    FILE*              m_FilesList[INCLUDE_FILES_COUNT_MAX+2];         // Included files list
    int                m_FilesPtr;              // Stack pointer for files list

    int                m_Selected_Tool;         // Pour editions: Tool (Dcode) selectionn�

    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

    APERTURE_MACRO_SET m_aperture_macros;       ///< a collection of APERTURE_MACROS, sorted by name

public:
    GERBER( WinEDA_GerberFrame* aParent, int layer );
    ~GERBER();
    void    Clear_GERBER();
    int     ReturnUsedDcodeNumber();
    void    ResetDefaultValues();

    /** 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();

    /**
     * Function InitToolTable
     */
    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 );
    bool    Execute_DCODE_Command( WinEDA_GerberFrame* frame,
                                   char*& text, int D_commande );

    /**
     * Function ReadRS274XCommand
     * reads a single RS274X command terminated with a %
     */
    bool ReadRS274XCommand( WinEDA_GerberFrame * frame,
                            char aBuff[GERBER_BUFZ], char* & text );

    /**
     * Function ExecuteRS274XCommand
     * executes 1 command
     */
    bool ExecuteRS274XCommand( int command, char aBuff[GERBER_BUFZ],
                               char* & text );


    /**
     * 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.
     * @param text A reference to a character pointer which gives the initial
     *              text to read from.
     * @param gerber_file Which file to read from for continuation.
     * @return bool - true if a macro was read in successfully, else false.
     */
    bool ReadApertureMacro( char aBuff[GERBER_BUFZ], char* & text,
                            FILE * gerber_file );


    /**
     * 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.
     * @param createIfNoExist If true, then create the D_CODE if it does not
     *                        exist.
     * @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.
     * @return APERTURE_MACRO* - the one with a matching name, or NULL if
     *                           not found.
     */
    APERTURE_MACRO* FindApertureMacro( const APERTURE_MACRO& aLookup );
};


#endif  // ifndef _CLASS_GERBER_H_
+1 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@
#include "class_board_design_settings.h"
#include "class_board_design_settings.h"
#include "colors_selection.h"
#include "colors_selection.h"
#include "class_gerber_draw_item.h"
#include "class_gerber_draw_item.h"
#include "class_GERBER.h"




/**********************************************************/
/**********************************************************/
Loading