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

Gerbview: added support forSF (scale factor), IO (Image Offset), OF (Offset)...

Gerbview: added support forSF (scale factor), IO (Image Offset), OF (Offset) and MI (Mirror) commands.
parents 55eefbbe 2a216a51
Loading
Loading
Loading
Loading
+29 −20
Original line number Diff line number Diff line
@@ -82,8 +82,8 @@ static void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle
                          int EndAngle, int r, int width, int Color, int BgColor );
static void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
                      int width, int aPenSize, int Color );
static void GRSFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
                          int width, int Color );
static void GRSLineArray( EDA_Rect* ClipBox, wxDC* DC, wxPoint points[],
                          int lines, int width, int Color );
/**/

extern BASE_SCREEN* ActiveScreen;
@@ -990,6 +990,13 @@ void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
              GRMapY( y2 ), ZoomValue( width ), 0, Color );
}

void GRCSegm( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
              int aWidth, int aColor )
{
    GRSCSegm( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ),
              GRMapX( aEnd.x ), GRMapY( aEnd.y ),
              ZoomValue( aWidth ), 0, aColor );
}

/*
 * Draw segment (full) with rounded ends in object space (real coords.).
@@ -997,24 +1004,17 @@ void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
void GRFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
                  int width, int Color )
{
    GRSFillCSegm( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
                  GRMapY( y2 ), ZoomValue( width ), Color );
    WinClipAndDrawLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
                  GRMapY( y2 ), Color, ZoomValue( width ) );
}


/*
 * Draw segment with rounded ends in screen space.
 */
void GRSFillCSegm( EDA_Rect* ClipBox,
                   wxDC*     DC,
                   int       x1,
                   int       y1,
                   int       x2,
                   int       y2,
                   int       width,
                   int       Color )
void GRFilledSegment( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
                      int aWidth, int aColor )
{
    WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, Color, width );
    WinClipAndDrawLine( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ),
                  GRMapX( aEnd.x ), GRMapY( aEnd.y ),
                  aColor, ZoomValue( aWidth ) );
}


@@ -1498,6 +1498,15 @@ void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
             Color );
}

void GRArc1( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
             wxPoint aCenter, int aWidth, int aColor )
{
    GRSArc1( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ),
             GRMapX( aEnd.x ), GRMapY( aEnd.y ),
             GRMapX( aCenter.x ), GRMapY( aCenter.y ), ZoomValue( aWidth ),
             aColor );
}


/*
 * Draw an arc, width = width, in screen space.
+3 −20
Original line number Diff line number Diff line
@@ -45,9 +45,6 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
                                     wxDC*             DC,
                                     bool              erase );

static bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem );


/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
 *  the key (ALT, SHIFT ALT ..)
 */
@@ -292,7 +289,7 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC )
    {
        nextitem = item->Next();
        GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
        if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) )
        if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) )
            gerb_item->DeleteStructure();
    }

@@ -324,7 +321,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC )
    for( ; item; item = item->Next() )
    {
        GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
        if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) )
        if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) )
            gerb_item->Move( delta );
    }

@@ -355,7 +352,7 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
    for( ; item; item = item->Next() )
    {
        GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
        if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) )
        if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) )
        {
            /* this item must be duplicated */
            BOARD_ITEM* new_item = gerb_item->Copy();
@@ -367,17 +364,3 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
    DrawPanel->Refresh();
}

/* Test if the structure PtStruct is inside the block
 * Returns true or false
 */
bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem )
{
    if( aBlocklocate.Inside( aItem->m_Start ) )
        return true;

    if( aBlocklocate.Inside( aItem->m_End ) )
        return true;

    return false;
}
+8 −6
Original line number Diff line number Diff line
@@ -123,21 +123,23 @@ void GERBER::ResetDefaultValues()
    m_LayerName     = wxT( "no layer name" );       // Layer name from the LN command
    m_LayerNegative = false;                        // true = Negative Layer
    m_ImageNegative = false;                        // true = Negative image
    m_GerbMetric    = false;                        // false = Inches, true = metric
    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_MirorA    = false;                            // true: miror / axe A (default = X)
    m_MirorB    = false;                            // true: miror / axe B (default = Y)
    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_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_Rotation     = 0;                             // Allowed 0, 90, 180, 270
    m_Iterpolation = GERB_INTERPOL_LINEAR_1X;       // Linear, 90 arc, Circ.
    m_360Arc_enbl  = false;                         // 360 deg circular
                                                    // interpolation disable
+10 −7
Original line number Diff line number Diff line
@@ -38,15 +38,17 @@ public:
    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_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
    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;
    int                m_Rotation;                                      // Image rotation (0, 90, 180, 270
                                                                        // Note these values are stored in 0.1 degrees
    int                m_Iterpolation;                                  // Linear, 90 arc, Circ.
    bool               m_ImageNegative;                                 // true = Negative image
    int                m_Current_Tool;                                  // Current Tool (Dcode) number selected
@@ -62,7 +64,8 @@ public:
    int                m_FilesPtr;                                      // Stack pointer for files list

    int                m_Selected_Tool;                                 // For hightlight: current selected Dcode

    bool               m_Has_DCode;                                     // true = DCodes in file
                                                                        // (false = no DCode -> separate DCode file
    bool               m_360Arc_enbl;                                   // Enbl 360 deg circular interpolation
    bool               m_PolygonFillMode;                               // Enable polygon mode (read coord as a polygon descr)
    int                m_PolygonFillModeState;                          // In polygon mode: 0 = first segm, 1 = next segm
+34 −25
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
         * type is not stored in parameters list, so the first parameter is exposure
         */
        curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), gerberMetric );
        curPos = aParent->GetABPosition( curPos );
        int radius = scale( params[1].GetValue( tool ), gerberMetric ) / 2;
        if( !aFilledShape )
            GRCircle( aClipBox, aDC, curPos, radius, 0, aColor );
@@ -170,12 +171,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
        if( rotation )
        {
            for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
                RotatePoint( &polybuffer[ii], rotation );
                RotatePoint( &polybuffer[ii], -rotation );
        }

        // Move to current position:
        for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
        {
            polybuffer[ii] += curPos;
            polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
        }

        GRClosedPoly( aClipBox, aDC,
                      polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
@@ -196,12 +200,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
        if( rotation )
        {
            for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
                RotatePoint( &polybuffer[ii], rotation );
                RotatePoint( &polybuffer[ii], -rotation );
        }

        // Move to current position:
        for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
        {
            polybuffer[ii] += curPos;
            polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
        }

        GRClosedPoly( aClipBox, aDC,
                      polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
@@ -222,12 +229,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
        if( rotation )
        {
            for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
                RotatePoint( &polybuffer[ii], rotation );
                RotatePoint( &polybuffer[ii], -rotation );
        }

        // Move to current position:
        for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
        {
            polybuffer[ii] += curPos;
            polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
        }

        GRClosedPoly( aClipBox, aDC,
                      polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
@@ -255,11 +265,14 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
            subshape_poly = polybuffer;
            int sub_rotation = rotation + 900 * ii;
            for( unsigned jj = 0; jj < subshape_poly.size(); jj++ )
                RotatePoint( &subshape_poly[jj], sub_rotation );
                RotatePoint( &subshape_poly[jj], -sub_rotation );

            // Move to current position:
            for( unsigned jj = 0; jj < subshape_poly.size(); jj++ )
            {
                subshape_poly[jj] += curPos;
                subshape_poly[jj] = aParent->GetABPosition( subshape_poly[jj] );
            }

            GRClosedPoly( aClipBox, aDC,
                          subshape_poly.size(), &subshape_poly[0], true, aAltColor,
@@ -283,6 +296,8 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
        int gap = scale( params[4].GetValue( tool ), gerberMetric );
        int numCircles = wxRound( params[5].GetValue( tool ) );

        // Draw circles:
        wxPoint center = aParent->GetABPosition( curPos );
        // adjust outerDiam by this on each nested circle
        int diamAdjust = (gap + penThickness); //*2;     //Should we use * 2 ?
        for( int i = 0; i < numCircles; ++i, outerDiam -= diamAdjust )
@@ -292,12 +307,12 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
            if( !aFilledShape )
            {
                // draw the border of the pen's path using two circles, each as narrow as possible
                GRCircle( aClipBox, aDC, curPos, outerDiam / 2, 0, aColor );
                GRCircle( aClipBox, aDC, curPos, outerDiam / 2 - penThickness, 0, aColor );
                GRCircle( aClipBox, aDC, center, outerDiam / 2, 0, aColor );
                GRCircle( aClipBox, aDC, center, outerDiam / 2 - penThickness, 0, aColor );
            }
            else    // Filled mode
            {
                GRCircle( aClipBox, aDC, curPos,
                GRCircle( aClipBox, aDC, center,
                          (outerDiam - penThickness) / 2, penThickness, aColor );
            }
        }
@@ -305,17 +320,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
        // Draw the cross:
        ConvertShapeToPolygon( aParent, polybuffer, gerberMetric );

        // shape rotation:
        rotation = wxRound( params[8].GetValue( tool ) * 10.0 );
        if( rotation )
        {
        for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
                RotatePoint( &polybuffer[ii], rotation );
        }

        {
            // shape rotation:
            RotatePoint( &polybuffer[ii], -rotation );
            // Move to current position:
        for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
            polybuffer[ii] += curPos;
            polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
        }

        GRClosedPoly( aClipBox, aDC,
                      polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
@@ -344,13 +357,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
        // shape rotation:
        for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
        {
            NEGATE(polybuffer[ii].y);
            RotatePoint( &polybuffer[ii], rotation );
            RotatePoint( &polybuffer[ii], -rotation );
       }

        // Move to current position:
        for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
        {
            polybuffer[ii] += curPos;
            polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
        }

        GRClosedPoly( aClipBox, aDC,
                      polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
@@ -372,9 +387,9 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
        rotation  = wxRound( params[5].GetValue( tool ) * 10.0 );
        for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
        {
            NEGATE(polybuffer[ii].y);
            RotatePoint( &polybuffer[ii], rotation );
            RotatePoint( &polybuffer[ii], -rotation );
            polybuffer[ii] += curPos;
            polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
        }
        GRClosedPoly( aClipBox, aDC,
                      polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
@@ -441,7 +456,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent,
        {
            RotatePoint( &aBuffer[ii], -angle );
            aBuffer[ii] += start;
            NEGATE( aBuffer[ii].y );
        }
    }
    break;
@@ -471,7 +485,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent,
                                       tool ), aUnitsMetric );

        // Build poly:
        NEGATE( lowerLeft.y );
        aBuffer.push_back( lowerLeft );
        lowerLeft.y += size.y;          // Upper left
        aBuffer.push_back( lowerLeft );
@@ -479,10 +492,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent,
        aBuffer.push_back( lowerLeft );
        lowerLeft.y -= size.y;          // lower right
        aBuffer.push_back( lowerLeft );

        // Negate y coordinates:
        for( unsigned ii = 0; ii < aBuffer.size(); ii++ )
            NEGATE( aBuffer[ii].y );
    }
    break;

Loading