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

Gerbview: more about apertures macros and draw funtions.

parent 22f483e1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1163,6 +1163,9 @@ static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] )
    if( ! ClipBox )
        return true;

    if( n <= 0 )
        return false;

    int Xmin, Xmax, Ymin, Ymax;

    Xmin = Xmax = Points[0].x;
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
###
set(GERBVIEW_SRCS
    block.cpp
    class_aperture_macro.cpp 
    class_GERBER.cpp
    class_gerber_draw_item.cpp
    class_gerbview_layer_widget.cpp
+16 −13
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent ) :
    m_Shape   = GBR_SEGMENT;
    m_Flashed = false;
    m_DCode   = 0;
    m_UnitsMetric = false;
}


@@ -70,6 +71,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
    m_Flashed     = aSource.m_Flashed;
    m_DCode       = aSource.m_DCode;
    m_PolyCorners = aSource.m_PolyCorners;
    m_UnitsMetric = aSource.m_UnitsMetric;
}


@@ -176,7 +178,7 @@ bool GERBER_DRAW_ITEM::Save( FILE* aFile ) const


/*********************************************************************/
void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
                             const wxPoint& aOffset )
/*********************************************************************/
{
@@ -203,9 +205,9 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,

        color = brd->GetLayerColor( GetLayer() );

        if( draw_mode & GR_SURBRILL )
        if( aDrawMode & GR_SURBRILL )
        {
            if( draw_mode & GR_AND )
            if( aDrawMode & GR_AND )
                color &= ~HIGHT_LIGHT_FLAG;
            else
                color |= HIGHT_LIGHT_FLAG;
@@ -214,7 +216,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
            color = ColorRefs[color & MASKCOLOR].m_LightColor;
    }

    GRSetDrawMode( DC, draw_mode );
    GRSetDrawMode( aDC, aDrawMode );

    isFilled = DisplayOpt.DisplayPcbTrackFill ? true : false;

@@ -224,7 +226,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
        isFilled = (g_DisplayPolygonsModeSketch == false);
        if( m_Flags & DRAW_ERASED )
            isFilled = true;
        DrawGbrPoly( &panel->m_ClipBox, DC, color, aOffset, isFilled );
        DrawGbrPoly( &aPanel->m_ClipBox, aDC, color, aOffset, isFilled );
        break;

    case GBR_CIRCLE:
@@ -236,14 +238,14 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
        if( !isFilled )
        {
            // draw the border of the pen's path using two circles, each as narrow as possible
            GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
            GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
                      radius - halfPenWidth, 0, color );
            GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
            GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
                      radius + halfPenWidth, 0, color );
        }
        else    // Filled mode
        {
            GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
            GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
                      radius, m_Size.x, color );
        }
        break;
@@ -251,13 +253,13 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
    case GBR_ARC:
        if( !isFilled )
        {
            GRArc1( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
            GRArc1( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
                    m_End.x, m_End.y,
                    m_ArcCentre.x, m_ArcCentre.y, 0, color );
        }
        else
        {
            GRArc1( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
            GRArc1( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
                    m_End.x, m_End.y,
                    m_ArcCentre.x, m_ArcCentre.y,
                    m_Size.x, color );
@@ -268,17 +270,18 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
    case GBR_SPOT_RECT:
    case GBR_SPOT_OVAL:
    case GBR_SPOT_POLY:
    case GBR_SPOT_MACRO:
        isFilled = DisplayOpt.DisplayPadFill ? true : false;
        d_codeDescr->DrawFlashedShape( &panel->m_ClipBox, DC, color,
        d_codeDescr->DrawFlashedShape( this, &aPanel->m_ClipBox, aDC, color,
                                       m_Start, isFilled );
        break;

    case GBR_SEGMENT:
        if( !isFilled )
            GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
            GRCSegm( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
                     m_End.x, m_End.y, m_Size.x, color );
        else
            GRFillCSegm( &panel->m_ClipBox, DC, m_Start.x,
            GRFillCSegm( &aPanel->m_ClipBox, aDC, m_Start.x,
                         m_Start.y, m_End.x, m_End.y, m_Size.x, color );
        break;

+3 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
 */

#include "base_struct.h"
#include "class_board_item.h"

/* Shapes id for basic shapes ( .m_Shape member ) */
enum Gbr_Basic_Shapes {
@@ -57,6 +58,8 @@ private:


public:
    bool m_UnitsMetric;                     /* store here the gerber units (inch/mm).
                                             *  Used only to calculate aperture macros shapes sizes  */
    int     m_Shape;                        // Shape and type of this gerber item
    wxPoint m_Start;                        // Line or arc start point or position of the shape
                                            // for flashed items
+22 −13
Original line number Diff line number Diff line
@@ -96,10 +96,11 @@ const wxChar* D_CODE::ShowApertureType( APERTURE_T aType )
    return ret;
}


/** Function Read_D_Code_File
 * Can be useful only with old RS274D Gerber file format.
 * Is not needed with RS274X files format.
 * These files need an auxiliary DCode file description. Ther is no defined file format for this.
 * These files need an auxiliary DCode file description. There is no defined file format for this.
 * This function read a file format I needed a long time ago.
 * reads in a dcode file assuming ALSPCB file format with ';' indicating comments.
 * Format is like CSV but with optional ';' delineated comments:
@@ -291,15 +292,18 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems()
 * Draw the dcode shape for flashed items.
 * When an item is flashed, the DCode shape is the shape of the item
 */
void D_CODE::DrawFlashedShape( EDA_Rect* aClipBox, wxDC* aDC, int aColor,
void D_CODE::DrawFlashedShape(  GERBER_DRAW_ITEM* aParent,
                                EDA_Rect* aClipBox, wxDC* aDC, int aColor,
                                wxPoint aShapePos, bool aFilledShape )
{
    int radius;

    switch( m_Shape )
    {
    case APT_MACRO:
        GetMacro()->DrawApertureMacroShape( aParent, aClipBox, aDC, aColor, aShapePos, aFilledShape);
        break;

    case APT_MACRO: // TODO: current a round shape
    case APT_CIRCLE:
        radius = m_Size.x >> 1;
        if( !aFilledShape )
@@ -439,6 +443,7 @@ void D_CODE::ConvertShapeToPolygon()
{
    wxPoint initialpos;
    wxPoint currpos;;

    m_PolyCorners.clear();

    switch( m_Shape )
@@ -530,6 +535,7 @@ void D_CODE::ConvertShapeToPolygon()
    case APT_POLYGON:
        currpos.x  = m_Size.x >> 1;     // first point is on X axis
        initialpos = currpos;

        // rs274x said: m_EdgesCount = 3 ... 12
        if( m_EdgesCount < 3 )
            m_EdgesCount = 3;
@@ -541,6 +547,7 @@ void D_CODE::ConvertShapeToPolygon()
            RotatePoint( &currpos, ii * 3600 / m_EdgesCount );
            m_PolyCorners.push_back( currpos );
        }

        addHoleToPolygon( m_PolyCorners, m_DrillShape, m_Drill, initialpos );
        if( m_Rotation )                   // vertical oval, rotate polygon.
        {
@@ -561,6 +568,7 @@ void D_CODE::ConvertShapeToPolygon()
    }
}


// The helper function for D_CODE::ConvertShapeToPolygon().
// Add a hole to a polygon
static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
@@ -569,6 +577,7 @@ static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
                              wxPoint               aAnchorPos )
{
    wxPoint currpos;

    if( aHoleShape == APT_DEF_ROUND_HOLE )                     // build a round hole
    {
        for( int ii = 0; ii <= SEGS_CNT; ii++ )
Loading