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

Gerbview: added: image polarity, axis select, layer rotation. Code cleanup.

parent 9ec8d536
Loading
Loading
Loading
Loading
+9 −17
Original line number Diff line number Diff line

Here is the proposed copyright message to be added to all source files
at their top.  There is one line that represents the main copyright holder
and that would be Jean-Pierre Charras for existing modules.  
at their top.  There is one line that represents the main copyright holder.

But in the future, the respective author of any newly coded module would be
listed as the main copyright holder. Additional workers who might earn a
partial copyright holder status of the respective module are simply left in the
change_log.txt file, see the 2nd Copyright line below.

Jean-Pierre, let me know if this is satisfactory and I will run a script I have to 
pre-pend it to all the sources.   

Thanks, Dick Hollenbeck dick@softplc.com.



/*
 * This program source code file is part of KICAD, a free EDA CAD application.
 *
 * Copyright (C) 1992-2009 Jean-Pierre Charras, jean-pierre.charras@inpg.fr
 * Copyright (C) 1992-2009 Kicad Developers, see AUTHORS.txt for contributors.
 * Copyright (C) 1992-2010 <Creator>
 * Copyright (C) 1992-2010 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
+58 −39
Original line number Diff line number Diff line
@@ -61,7 +61,29 @@ extern int scale( double aCoord, bool isMetric ); // defined it rs274d.cpp
 */


GERBER::GERBER( WinEDA_GerberFrame* aParent, int aLayer )
GERBER_LAYER::GERBER_LAYER()
{
    ResetDefaultValues();
}


GERBER_LAYER::~GERBER_LAYER()
{
}


void GERBER_LAYER::ResetDefaultValues()
{
    m_LayerName     = wxT( "no name" );             // Layer name from the LN command
    m_LayerNegative = false;                        // true = Negative Layer
    m_StepForRepeat.x     = m_StepForRepeat.y = 0;  // X and Y offsets for Step and Repeat command
    m_XRepeatCount        = 1;                      // The repeat count on X axis
    m_YRepeatCount        = 1;                      // The repeat count on Y axis
    m_StepForRepeatMetric = false;                  // false = Inches, true = metric
}


GERBER_IMAGE::GERBER_IMAGE( WinEDA_GerberFrame* aParent, int aLayer )
{
    m_Parent = aParent;
    m_GraphicLayer = aLayer;  // Graphic layer Number
@@ -77,7 +99,7 @@ GERBER::GERBER( WinEDA_GerberFrame* aParent, int aLayer )
}


GERBER::~GERBER()
GERBER_IMAGE::~GERBER_IMAGE()
{
    for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
    {
@@ -90,7 +112,7 @@ GERBER::~GERBER()
}


D_CODE* GERBER::GetDCODE( int aDCODE, bool create )
D_CODE* GERBER_IMAGE::GetDCODE( int aDCODE, bool create )
{
    unsigned ndx = aDCODE - FIRST_DCODE;

@@ -109,7 +131,7 @@ D_CODE* GERBER::GetDCODE( int aDCODE, bool create )
}


APERTURE_MACRO* GERBER::FindApertureMacro( const APERTURE_MACRO& aLookup )
APERTURE_MACRO* GERBER_IMAGE::FindApertureMacro( const APERTURE_MACRO& aLookup )
{
    APERTURE_MACRO_SET::iterator iter = m_aperture_macros.find( aLookup );

@@ -123,48 +145,41 @@ APERTURE_MACRO* GERBER::FindApertureMacro( const APERTURE_MACRO& aLookup )
}


void GERBER::ResetDefaultValues()
void GERBER_IMAGE::ResetDefaultValues()
{
    m_GBRLayerParams.ResetDefaultValues();
    m_FileName.Empty();
    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_ImageName     = wxT( "no name" );             // Image name from the IN command
    m_ImageNegative = false;                        // true = Negative image
    m_GerbMetric    = false;                        // false = Inches (default), true = metric
    m_Relative = false;                             // false = absolute Coord,
                                                    // true = relative Coord
    m_NoTrailingZeros = false;                      // true: trailing zeros deleted
    m_ImageOffset.x   = m_ImageOffset.y = 0;        // Coord Offset, from IO command
    m_ImageRotation = 0;                            // Allowed 0, 900, 1800, 2700 (in 0.1 degree
    m_LocalRotation = 0;                            // Layer totation from RO command (in 0.1 degree)
    m_Offset.x = 0;
    m_Offset.y = 0;                                 // Coord Offset, from OF command
    m_Scale.x  = m_Scale.y = 1.0;                   // scale (A and B) this layer
    m_MirrorA  = false;                             // true: miror / axe A (default = X)
    m_MirrorB  = false;                             // true: miror / axe B (default = Y)
    m_SwapAxis = false;                             // false if A = X, B = Y; true if A =Y, B = Y
    m_ImageOffset.x = m_ImageOffset.y = 0;          // Coord Offset, from IO command
    m_Offset.x  = m_Offset.y = 0;                   // Coord Offset, from OF command
    m_Rotation  = 0;                                // Allowed 0, 90, 180, 270
    m_StepForRepeat.x = m_StepForRepeat.y = 0;      // X and Y offsets for Step and Repeat command
    m_XRepeatCount = 1;                             // The repeat count on X axis
    m_YRepeatCount = 1;                             // The repeat count on Y axis
    m_StepForRepeatMetric = false;                  // false = Inches, true = metric
    m_Has_DCode = false;                            // true = DCodes in file
                                                    // false = no DCode->
                                                    // search for separate DCode file
    m_FmtScale.x = m_FmtScale.y = 4;                // Initialize default format to 3.4 => 4
    m_FmtLen.x   = m_FmtLen.y = 3 + 4;              // Initialize default format len = 3+4

    m_LayerScale.x = m_LayerScale.y = 1.0;          // scale (A and B) this layer
    m_Iterpolation = GERB_INTERPOL_LINEAR_1X;       // Linear, 90 arc, Circ.
    m_360Arc_enbl  = false;                         // 360 deg circular
                                                    // interpolation disable
    m_Current_Tool = 0;                             // Current Tool (Dcode)
                                                    // number selected
    m_CommandState = 0;                             // gives tate of the
                                                    // stacking order analysis
    m_Current_Tool = 0;                             // Current Dcode selected
    m_CommandState = 0;                             // State of the current command
    m_CurrentPos.x = m_CurrentPos.y = 0;            // current specified coord
                                                    // for plot
    m_PreviousPos.x = m_PreviousPos.y = 0;          // old current specified
                                                    // coord for plot
    m_PreviousPos.x = m_PreviousPos.y = 0;          // last specified coord
    m_IJPos.x = m_IJPos.y = 0;                      // current centre coord for
                                                    // plot arcs & circles
    m_Current_File    = NULL;                       // File to read
    m_Current_File    = NULL;                       // Gerger file to read
    m_FilesPtr        = 0;
    m_PolygonFillMode = false;
    m_PolygonFillModeState = 0;
@@ -172,7 +187,7 @@ void GERBER::ResetDefaultValues()
}


int GERBER::ReturnUsedDcodeNumber()
int GERBER_IMAGE::ReturnUsedDcodeNumber()
{
    int count = 0;

@@ -187,7 +202,7 @@ int GERBER::ReturnUsedDcodeNumber()
}


void GERBER::InitToolTable()
void GERBER_IMAGE::InitToolTable()
{
    for( int count = 0; count < TOOLS_MAX_COUNT; count++ )
    {
@@ -207,7 +222,7 @@ void GERBER::InitToolTable()
 * for instance when reading a Gerber file
 * @param aMessage = the straing to add in list
 */
void GERBER::ReportMessage( const wxString aMessage )
void GERBER_IMAGE::ReportMessage( const wxString aMessage )
{
    m_Parent->ReportMessage( aMessage );
}
@@ -217,11 +232,12 @@ void GERBER::ReportMessage( const wxString aMessage )
 * Clear the message list
 * Call it before reading a Gerber file
 */
void GERBER::ClearMessageList()
void GERBER_IMAGE::ClearMessageList()
{
    m_Parent->ClearMessageList();
}


/** Function StepAndRepeatItem
 * Gerber format has a command Step an Repeat
 * This function must be called when reading a gerber file and
@@ -229,15 +245,16 @@ void GERBER::ClearMessageList()
 * (i.e when m_XRepeatCount or m_YRepeatCount are > 1)
 * @param aItem = the item to repeat
 */
void GERBER::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
void GERBER_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
{
    if( m_XRepeatCount < 2 && m_YRepeatCount < 2 )
    if( GetLayerParams().m_XRepeatCount < 2 &&
        GetLayerParams().m_YRepeatCount < 2 )
        return; // Nothing to repeat
    // Duplicate item:
    wxString msg;
    for( int ii = 0; ii < m_XRepeatCount; ii++ )
    for( int ii = 0; ii < GetLayerParams().m_XRepeatCount; ii++ )
    {
        for( int jj = 0; jj < m_YRepeatCount; jj++ )
        for( int jj = 0; jj < GetLayerParams().m_YRepeatCount; jj++ )
        {
            // the first gerber item already exists (this is the template)
            // create duplicate only if ii or jj > 0
@@ -245,8 +262,10 @@ wxString msg;
                continue;
            GERBER_DRAW_ITEM* dupItem = new GERBER_DRAW_ITEM( aItem );
            wxPoint           move_vector;
            move_vector.x = scale( ii * m_StepForRepeat.x, m_StepForRepeatMetric );
            move_vector.y = scale( jj * m_StepForRepeat.y, m_StepForRepeatMetric );
            move_vector.x = scale( ii * GetLayerParams().m_StepForRepeat.x,
                                   GetLayerParams().m_StepForRepeatMetric );
            move_vector.y = scale( jj * GetLayerParams().m_StepForRepeat.y,
                                   GetLayerParams().m_StepForRepeatMetric );
            dupItem->MoveXY( move_vector );
            m_Parent->GetBoard()->m_Drawings.Append( dupItem );
        }
+108 −58
Original line number Diff line number Diff line
@@ -20,49 +20,90 @@ class WinEDA_GerberFrame;
class BOARD;
class D_CODE;

/* gerber files have different parameters to define units and how items must be plotted.
 *  some are for the entire file, and other can change along a file.
 *  In Gerber world:
 *  an image is the entire gerber file and its "global" parameters
 *  a layer (that is very different from a board layer) is just a sub set of a file that
 *  have specific parameters
 *  if a Image parameter is set more than once, only the last value is used
 *  Some parameters can change along a file and are not layer specific: they are stored
 *  in GERBER_ITEM items, when instancied.
 *
 *  In Gerbview, to handle these parameters, there are 2 classes:
 *  GERBER_IMAGE : the main class containing most of parameters and data to plot a graphic layer
 *  Some of them can change along the file
 *  There is one GERBER_IMAGE per file and one graphic layer per file or GERBER_IMAGE
 *  Gerbview does not read and merge 2 gerber file in one graphic layer:
 *  I believe this is not possible due to the constraints in Image parameters.
 *  GERBER_LAYER : containing the subset of parameters that is layer speficic
 *  A GERBER_IMAGE must include one GERBER_LAYER to define all parameters to plot a file.
 *  But a GERBER_IMAGE can use more than one GERBER_LAYER.
 */

class GERBER_IMAGE;

class GERBER_LAYER
{
    friend class GERBER_IMAGE;
public:

    // These parameters are layer specfic:
    wxString    m_LayerName;            // Layer name, from LN <name>* command
    bool        m_LayerNegative;        // true = Negative Layer: command LP
    wxRealPoint m_StepForRepeat;        // X and Y offsets for Step and Repeat command
    int         m_XRepeatCount;         // The repeat count on X axis
    int         m_YRepeatCount;         // The repeat count on Y axis
    bool        m_StepForRepeatMetric;  // false = Inches, true = metric
                                        // needed here because repeated
                                        // gerber items can have coordinates
                                        // in different units than step parameters
                                        // and the actual coordinates calculation must handle this

public:
    GERBER_LAYER();
    ~GERBER_LAYER();
private:
    void ResetDefaultValues();
};

/**
 * Class GERBER
 * holds the data for one gerber file or layer
 * Class GERBER_IMAGE
 * holds the Image data and parameters for one gerber file
 * and layer parameters (TODO: move them in GERBER_LAYER class
 */
class GERBER
class GERBER_IMAGE
{
    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
    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

    BOARD*             m_Pcb;

    GERBER_LAYER       m_GBRLayerParams; // hold params for the current gerber layer

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_GraphicLayer;                          // Graphic layer Number
    bool               m_LayerNegative;                                 // true = Negative Layer
    bool               m_ImageNegative;                         // true = Negative image
    bool               m_GerbMetric;                            // false = Inches, true = metric
    bool               m_Relative;                              // false = absolute Coord, true = relative Coord
    bool               m_NoTrailingZeros;                       // true: remove tailing zeros.
    bool               m_SwapAxis;                                      // false (default) if A = X and B = Y
                                                                        // true if A = Y, B = X
    bool               m_MirrorA;                                       // true: miror / axe A (X)
    bool               m_MirrorB;                                       // true: miror / axe B (Y)
    wxPoint            m_ImageOffset;                           // Coord Offset, from IO command
    wxPoint            m_Offset;                                        // Coord Offset, from OF command
    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;                                      // Image rotation (0, 90, 180, 270
    int                m_ImageRotation;                         // Image rotation (0, 90, 180, 270
                                                                // Note these values are stored in 0.1 degrees
    wxRealPoint        m_StepForRepeat;                                 // X and Y offsets for Step and Repeat command
    int                m_XRepeatCount;                                  // The repeat count on X axis
    int                m_YRepeatCount;                                  // The repeat count on Y axis
    bool               m_StepForRepeatMetric;                           // false = Inches, true = metric
                                                                        // needed here because repeated
                                                                        // gerber items can have coordinates
                                                                        // in different units than step parameters
                                                                        // and the actual coordinates calculation must handle this

    int                m_LocalRotation;                         // Local rotation, added to m_ImageRotation
                                                                //  Note this value is stored in 0.1 degrees
    wxPoint            m_Offset;                                // Coord Offset, from OF command
    wxRealPoint        m_Scale;                                 // scale (X and Y) of layer.
    bool               m_SwapAxis;                              // false (default) if A = X and B = Y
                                                                // true if A = Y, B = X
    bool               m_MirrorA;                               // true: miror / axe A (X)
    bool               m_MirrorB;                               // true: miror / axe B (Y)
    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.
@@ -85,12 +126,21 @@ public:
    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();
    GERBER_IMAGE( WinEDA_GerberFrame* aParent, int layer );
    ~GERBER_IMAGE();
    void Clear_GERBER_IMAGE();
    int  ReturnUsedDcodeNumber();
    void ResetDefaultValues();

    /** function GetLayerParams
     * @return the current layers params
     */
    GERBER_LAYER& GetLayerParams()
    {
        return m_GBRLayerParams;
    }


    /** function ReportMessage
     * Add a message (a string) in message list
     * for instance when reading a Gerber file
+5 −4
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include "macros.h"
#include "trigo.h"
#include "gerbview.h"
#include "class_GERBER.h"



@@ -95,7 +96,7 @@ bool AM_PRIMITIVE::mapExposure( GERBER_DRAW_ITEM* aParent )
            break;

        case 2:     // reverse exposure
            exposure = !aParent->m_LayerNegative;
            exposure = !aParent->GetLayerPolarity();
        }
        break;

@@ -107,7 +108,7 @@ bool AM_PRIMITIVE::mapExposure( GERBER_DRAW_ITEM* aParent )
        break;
    }

    return exposure ^ aParent->m_ImageNegative;
    return exposure ^ aParent->m_imageParams->m_ImageNegative;
}


@@ -574,12 +575,12 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent,
        aBuffer.push_back( pos );

        // Copy the 4 shape, rotated by 90, 180 and 270 deg
        for( int jj = 900; jj <= 2700; jj += 900 )
        for( int jj = 1; jj <= 3; jj ++ )
        {
            for( int ii = 0; ii < 4; ii++ )
            {
                pos = aBuffer[ii];
                RotatePoint( &pos, jj );
                RotatePoint( &pos, jj*900 );
                aBuffer.push_back( pos );
            }
        }
+49 −33
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@


/**********************************************************/
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER* aGerberparams ) :
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER_IMAGE* aGerberparams ) :
    BOARD_ITEM( aParent, TYPE_GERBER_DRAW_ITEM )
/**********************************************************/
{
@@ -52,12 +52,12 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER* aGerberparams )
    m_Flashed       = false;
    m_DCode         = 0;
    m_UnitsMetric   = false;
    m_ImageNegative = false;
    m_LayerNegative = false;
    m_swapAxis      = false;
    m_mirrorA       = false;
    m_mirrorB       = false;
    m_drawScale.x   = m_drawScale.y = 1.0;
    m_layerRotation = 0;
    if( m_imageParams )
        SetLayerParameters();
}
@@ -83,7 +83,6 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
    m_DCode         = aSource.m_DCode;
    m_PolyCorners   = aSource.m_PolyCorners;
    m_UnitsMetric   = aSource.m_UnitsMetric;
    m_ImageNegative = aSource.m_ImageNegative;
    m_LayerNegative = aSource.m_LayerNegative;
    m_swapAxis      = aSource.m_swapAxis;
    m_mirrorA       = aSource.m_mirrorA;
@@ -91,6 +90,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
    m_layerOffset   = aSource.m_layerOffset;
    m_drawScale.x   = aSource.m_drawScale.x;
    m_drawScale.y   = aSource.m_drawScale.y;
    m_layerRotation = aSource.m_layerRotation;
}


@@ -127,16 +127,19 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition )
    abPos  += m_layerOffset + m_imageParams->m_ImageOffset;
    abPos.x = wxRound( abPos.x * m_drawScale.x );
    abPos.y = wxRound( abPos.y * m_drawScale.y );
    if( m_imageParams->m_Rotation )
        RotatePoint( &abPos, -m_imageParams->m_Rotation );
    int rotation = m_layerRotation + m_imageParams->m_ImageRotation;
    if( rotation )
        RotatePoint( &abPos, -rotation );
    if( m_mirrorA )
        NEGATE( abPos.x );

    // abPos.y must be negated, because draw axis is top to bottom
    if( !m_mirrorB )
        NEGATE( abPos.y );
    return abPos;
}


/**
 * Function GetXYPosition
 * returns the image position of aPosition for this object.
@@ -154,8 +157,9 @@ wxPoint GERBER_DRAW_ITEM::GetXYPosition(const wxPoint& aABPosition )
        NEGATE( xyPos.x );
    if( !m_mirrorB )
        NEGATE( xyPos.y );
    if( m_imageParams->m_Rotation )
        RotatePoint( &xyPos, m_imageParams->m_Rotation );
    int rotation = m_layerRotation + m_imageParams->m_ImageRotation;
    if( rotation )
        RotatePoint( &xyPos, rotation );
    xyPos.x = wxRound( xyPos.x / m_drawScale.x );
    xyPos.y = wxRound( xyPos.y / m_drawScale.y );
    xyPos  -= m_layerOffset + m_imageParams->m_ImageOffset;
@@ -164,6 +168,7 @@ wxPoint GERBER_DRAW_ITEM::GetXYPosition(const wxPoint& aABPosition )
    return xyPos;
}


/** function SetLayerParameters
 * Initialize draw parameters from Image and Layer parameters
 * found in the gerber file:
@@ -178,8 +183,10 @@ void GERBER_DRAW_ITEM::SetLayerParameters()
    // true if A =Y, B = Y
    m_mirrorA     = m_imageParams->m_MirrorA;      // true: mirror / axe A
    m_mirrorB     = m_imageParams->m_MirrorB;      // true: mirror / axe B
    m_drawScale   = m_imageParams->m_LayerScale;            // A and B scaling factor
    m_drawScale   = m_imageParams->m_Scale;         // A and B scaling factor
    m_layerOffset = m_imageParams->m_Offset;        // Offset from OF command
    // Rotation from RO command:
    m_layerRotation = m_imageParams->m_LocalRotation;
}


@@ -229,7 +236,7 @@ D_CODE* GERBER_DRAW_ITEM::GetDcodeDescr()
{
    if( (m_DCode < FIRST_DCODE) || (m_DCode > LAST_DCODE) )
        return NULL;
    GERBER* gerber = g_GERBER_List[m_Layer];
    GERBER_IMAGE* gerber = g_GERBER_List[m_Layer];
    if( gerber == NULL )
        return NULL;

@@ -246,8 +253,8 @@ EDA_Rect GERBER_DRAW_ITEM::GetBoundingBox()

    bbox.Inflate( m_Size.x / 2, m_Size.y / 2 );

    bbox.SetOrigin(GetXYPosition( bbox.GetOrigin() ) );
    bbox.SetEnd(GetXYPosition( bbox.GetEnd() ) );
    bbox.SetOrigin( GetABPosition( bbox.GetOrigin() ) );
    bbox.SetEnd( GetABPosition( bbox.GetEnd() ) );
    return bbox;
}

@@ -260,6 +267,7 @@ EDA_Rect GERBER_DRAW_ITEM::GetBoundingBox()
void GERBER_DRAW_ITEM::MoveAB( const wxPoint& aMoveVector )
{
    wxPoint xymove = GetXYPosition( aMoveVector );

    m_Start     += xymove;
    m_End       += xymove;
    m_ArcCentre += xymove;
@@ -267,6 +275,7 @@ void GERBER_DRAW_ITEM::MoveAB( const wxPoint& aMoveVector )
        m_PolyCorners[ii] += xymove;
}


/**
 * Function MoveXY
 * move this object.
@@ -281,6 +290,7 @@ void GERBER_DRAW_ITEM::MoveXY( const wxPoint& aMoveVector )
        m_PolyCorners[ii] += aMoveVector;
}


/** function Save.
 * currently: no nothing, but must be defined to meet requirements
 * of the basic class
@@ -325,8 +335,14 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,

    alt_color = g_DrawBgColor;

    if( m_Flags & DRAW_ERASED )   // draw in background color ("negative" color)
    /* isDark is true if flash is positive and should use a drawing
     *   color other than the background color, else use the background color
     *   when drawing so that an erasure happens.
     */
    bool isDark = !(m_LayerNegative ^ m_imageParams->m_ImageNegative);
    if( !isDark )
    {
        // draw in background color ("negative" color)
        EXCHG( color, alt_color );
    }

@@ -338,7 +354,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
    {
    case GBR_POLYGON:
        isFilled = (g_DisplayPolygonsModeSketch == false);
        if( m_Flags & DRAW_ERASED )
        if( !isDark )
            isFilled = true;
        DrawGbrPoly( &aPanel->m_ClipBox, aDC, color, aOffset, isFilled );
        break;
@@ -469,17 +485,15 @@ void GERBER_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame )

    // This next info can be see as debug info, so it can be disabled
#if 1
    // Display offset
    wxPoint tmp = m_layerOffset + m_imageParams->m_ImageOffset;
    msg.Printf( wxT("X=%f Y=%f"), (double)tmp.x/10000, (double)tmp.y/10000);
    frame->AppendMsgPanel( _( "Offset" ), msg, DARKRED );

    // Display rotation
    msg.Printf( wxT("%d"), m_imageParams->m_Rotation/10);
    frame->AppendMsgPanel( _( "Image rotation" ), msg, DARKRED );
    msg.Printf( wxT( "%.1f" ), (double)(m_imageParams->m_ImageRotation+m_layerRotation) / 10 );
    frame->AppendMsgPanel( _( "Rotation" ), msg, DARKRED );

    // Display mirroring
    msg.Printf( wxT("X%d Y%d"), m_mirrorA, m_mirrorB);
    msg.Printf( wxT( "A:%s B:%s" ),
                m_mirrorA ? _("Yes") : _("No"),
                m_mirrorB ? _("Yes") : _("No"));
    frame->AppendMsgPanel( _( "Mirror" ), msg, DARKRED );

    // Display AB axis swap
@@ -497,6 +511,7 @@ void GERBER_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame )
 */
bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos )
{
    // calculate aRefPos in XY gerber axis:
    wxPoint ref_pos = GetXYPosition( aRefPos );

    // TODO: a better analyse of the shape (perhaps create a D_CODE::HitTest for flashed items)
@@ -533,6 +548,7 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos )
bool GERBER_DRAW_ITEM::HitTest( EDA_Rect& refArea )
{
    wxPoint pos = GetABPosition( m_Start );

    if( refArea.Inside( pos ) )
        return true;
    pos = GetABPosition( m_End );
Loading