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

gr_basic: fix incorrect clipping of thick lines (due to changes in code, the...

gr_basic: fix incorrect clipping of thick lines (due to changes in code, the thickness was not taken in account to calculate the clip box size)
Pcbnew: fix a very minor bug.
parents 0cedcb87 e9c618b6
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -43,7 +43,7 @@ after calling this conversion function, the comma is changed in point.
(Happens after reading a parameter stored in a wxConfig structure, if this
(Happens after reading a parameter stored in a wxConfig structure, if this
parameter is a double)
parameter is a double)
Workaround:
Workaround:
Use a version > 2.9.2
Use a version > 2.9.1


Currently ( 2011, april 12 ) the 2.9.2 is not yet finalized
Currently ( 2011, april 12 ) the 2.9.2 is not yet finalized
(and can be found only on the wxWidgets snv server)
(and can be found only on the wxWidgets snv server)
+42 −47
Original line number Original line Diff line number Diff line
@@ -63,7 +63,6 @@ static void ClipAndDrawFilledPoly( EDA_RECT * ClipBox, wxDC * DC, wxPoint Points
 * ( GRSCircle is called by GRCircle for instance) after mapping coordinates
 * ( GRSCircle is called by GRCircle for instance) after mapping coordinates
 * from user units to screen units(pixels coordinates)
 * from user units to screen units(pixels coordinates)
 */
 */
static void GRSMoveTo( int x, int y );
static void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1,
static void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1,
                     int x2, int y2, int aWidth, int aColor,
                     int x2, int y2, int aWidth, int aColor,
                     wxPenStyle aStyle = wxPENSTYLE_SOLID );
                     wxPenStyle aStyle = wxPENSTYLE_SOLID );
@@ -326,18 +325,9 @@ static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int


    if( ClipBox )
    if( ClipBox )
    {
    {
        xcliplo = ClipBox->GetX();
        EDA_RECT clipbox(*ClipBox);
        ycliplo = ClipBox->GetY();
        clipbox.Inflate(width/2);
        xcliphi = ClipBox->GetRight();
        if( clipLine( &clipbox, x1, y1, x2, y2 ) )
        ycliphi = ClipBox->GetBottom();

        xcliplo -= width;
        ycliplo -= width;

        xcliphi += width;
        ycliphi += width;

        if( clipLine( ClipBox, x1, y1, x2, y2 ) )
            return;
            return;
    }
    }


@@ -591,15 +581,6 @@ void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
}
}




/*
 * Move to a new position, in screen (pixels) space.
 */
void GRSMoveTo( int x, int y )
{
    GRLastMoveToX = x;
    GRLastMoveToY = y;
}



/**
/**
 * Function GRLineArray
 * Function GRLineArray
@@ -634,15 +615,22 @@ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
    gc->ResetClip();
    gc->ResetClip();
    delete gc;
    delete gc;
#else
#else
    for( unsigned i = 0; i < aLines.size(); )

    if( aClipBox )
        aClipBox->Inflate(aWidth/2);
    for( unsigned i = 0; i < aLines.size(); i += 2)
    {
    {
        WinClipAndDrawLine( aClipBox, aDC, aLines[i].x, aLines[i].y,
        int x1 = aLines[i].x;
                            aLines[i + 1].x, aLines[i + 1].y, aColor, aWidth );
        int y1 = aLines[i].y;
        i++;
        int x2 = aLines[i+1].x;
        GRLastMoveToX = aLines[i].x;
        int y2 = aLines[i+1].y;
        GRLastMoveToY = aLines[i].y;
        GRLastMoveToX = x2;
        i++;
        GRLastMoveToY = y2;
        if( ( aClipBox == NULL ) || clipLine( aClipBox, x1, y1, x2, y2 ) )
            aDC->DrawLine( x1, y1, x2, y2 );
    }
    }
    if( aClipBox )
        aClipBox->Inflate(-aWidth/2);
#endif
#endif
}
}


@@ -663,18 +651,10 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,


    if( ClipBox )
    if( ClipBox )
    {
    {
        xcliplo = ClipBox->GetX();
        EDA_RECT clipbox(*ClipBox);
        ycliplo = ClipBox->GetY();
        clipbox.Inflate(width/2);
        xcliphi = ClipBox->GetRight();
        ycliphi = ClipBox->GetHeight();

        xcliplo -= width;
        ycliplo -= width;

        xcliphi += width;
        ycliphi += width;


        if( clipLine( ClipBox, x1, y1, x2, y2 ) )
        if( clipLine( &clipbox, x1, y1, x2, y2 ) )
            return;
            return;
    }
    }


@@ -935,7 +915,8 @@ static void GRSClosedPoly( EDA_RECT* ClipBox,


    if( Fill && ( aPointCount > 2 ) )
    if( Fill && ( aPointCount > 2 ) )
    {
    {
        GRSMoveTo( aPoints[aPointCount - 1].x, aPoints[aPointCount - 1].y );
        GRLastMoveToX = aPoints[aPointCount - 1].x;
        GRLastMoveToY = aPoints[aPointCount - 1].y;
        GRSetBrush( DC, BgColor, FILLED );
        GRSetBrush( DC, BgColor, FILLED );
#ifdef USE_CLIP_FILLED_POLYGONS
#ifdef USE_CLIP_FILLED_POLYGONS
        ClipAndDrawFilledPoly( ClipBox, DC, aPoints, aPointCount );
        ClipAndDrawFilledPoly( ClipBox, DC, aPoints, aPointCount );
@@ -1345,12 +1326,19 @@ void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
    points[4] = points[0];
    points[4] = points[0];
    GRSetColorPen( aDC, aColor, aWidth, aStyle );
    GRSetColorPen( aDC, aColor, aWidth, aStyle );
    GRSetBrush( aDC, BLACK );
    GRSetBrush( aDC, BLACK );
    ClipAndDrawFilledPoly(aClipBox, aDC, points, 5); // polygon approach is more accurate
    if( aClipBox )
    {
        EDA_RECT clipbox(*aClipBox);
        clipbox.Inflate(aWidth);
        ClipAndDrawFilledPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate
    }
    else
        ClipAndDrawFilledPoly(aClipBox, aDC, points, 5);
}
}




void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
void GRSFilledRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
                    int width, int Color, int BgColor )
                    int aWidth, int aColor, int aBgColor )
{
{


    wxPoint points[5];
    wxPoint points[5];
@@ -1359,9 +1347,16 @@ void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
    points[2] = wxPoint(x2, y2);
    points[2] = wxPoint(x2, y2);
    points[3] = wxPoint(x2, y1);
    points[3] = wxPoint(x2, y1);
    points[4] = points[0];
    points[4] = points[0];
    GRSetBrush( DC, BgColor, FILLED );
    GRSetBrush( aDC, aBgColor, FILLED );
    GRSetColorPen( DC, BgColor, width );
    GRSetColorPen( aDC, aBgColor, aWidth );
    ClipAndDrawFilledPoly(ClipBox, DC, points, 5); // polygon approach is more accurate
    if( aClipBox && (aWidth > 0) )
    {
        EDA_RECT clipbox(*aClipBox);
        clipbox.Inflate(aWidth);
        ClipAndDrawFilledPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate
    }
    else
        ClipAndDrawFilledPoly(aClipBox, aDC, points, 5);
}
}




+26 −2
Original line number Original line Diff line number Diff line
@@ -818,8 +818,32 @@ public:
     */
     */
    void   Edit_TrackSegm_Width( wxDC* aDC, TRACK* aTrackItem );
    void   Edit_TrackSegm_Width( wxDC* aDC, TRACK* aTrackItem );


    TRACK* Begin_Route( TRACK* track, wxDC* DC );
    /**
    void   End_Route( TRACK* track, wxDC* DC );
     * Function Begin_Route
     * Starts a new track and/or establish of a new track point.
     *
     * For a new track:
     * - Search the netname of the new track from the starting point
     * if it is on a pad or an existing track
     * - Highlight all this net
     * If a track is in progress:
     * - Call DRC
     * - If DRC is OK: finish the track segment and starts a new one.
     * @param aTrack = the current track segment, or NULL to start a new track
     * @param aDC = the current device context
     * @return a pointer to the new track segment or null if not created (DRC error)
     */
    TRACK* Begin_Route( TRACK* aTrack, wxDC* aDC );

    /**
     * Function End_Route
     * Terminates a track currently being created
     * @param aTrack = the current track segment in progress
     * @param aDC = the current device context
     * @return true if the track was created, false if not (due to a DRC error)
     */
    bool   End_Route( TRACK* aTrack, wxDC* aDC );

    void   ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC );
    void   ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC );
    void   Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On );
    void   Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On );
    void   Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On );
    void   Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On );
+18 −0
Original line number Original line Diff line number Diff line
@@ -88,6 +88,24 @@ BOARD::~BOARD()
    delete m_NetInfo;
    delete m_NetInfo;
}
}


/*
 * Function PushHightLight
 * save current hight light info for later use
 */
void BOARD::PushHightLight()
{
    m_hightLightPrevious = m_hightLight;
}

/*
 * Function PopHightLight
 * retrieve a previously saved hight light info
 */
void BOARD::PopHightLight()
{
    m_hightLight = m_hightLightPrevious;
    m_hightLightPrevious.Clear();
}


/**
/**
 * Function SetCurrentNetClass
 * Function SetCurrentNetClass
+2 −6
Original line number Original line Diff line number Diff line
@@ -321,17 +321,13 @@ public:
     * Function PushHightLight
     * Function PushHightLight
     * save current hight light info for later use
     * save current hight light info for later use
     */
     */
    void PushHightLight() { m_hightLightPrevious = m_hightLight; }
    void PushHightLight();


    /**
    /**
     * Function PopHightLight
     * Function PopHightLight
     * retrieve a previously saved hight light info
     * retrieve a previously saved hight light info
     */
     */
    void PopHightLight()
    void PopHightLight();
    {
        m_hightLight = m_hightLightPrevious;
        m_hightLightPrevious.Clear();
    }


    /**
    /**
     * Function GetCopperLayerCount
     * Function GetCopperLayerCount
Loading