Commit c2af94ac authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio
Browse files

Reworked the endpoint designator constants FLG_BEGIN and FLG_END in a

ENDPOINT_T enum type
parent 802a59dc
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1300,12 +1300,14 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
        g_CurrentTrackList.PushBack( newTrack );
    }

    g_FirstTrackSegment->start = pcbframe->GetBoard()->GetPad( g_FirstTrackSegment, FLG_START );
    g_FirstTrackSegment->start = pcbframe->GetBoard()->GetPad( g_FirstTrackSegment,
            ENDPOINT_START );

    if( g_FirstTrackSegment->start )
        g_FirstTrackSegment->SetState( BEGIN_ONPAD, true );

    g_CurrentTrackSegment->end = pcbframe->GetBoard()->GetPad( g_CurrentTrackSegment, FLG_END );
    g_CurrentTrackSegment->end = pcbframe->GetBoard()->GetPad( g_CurrentTrackSegment,
            ENDPOINT_END );

    if( g_CurrentTrackSegment->end )
        g_CurrentTrackSegment->SetState( END_ONPAD, true );
+3 −12
Original line number Diff line number Diff line
@@ -1598,22 +1598,13 @@ D_PAD* BOARD::GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask )
}


D_PAD* BOARD::GetPad( TRACK* aTrace, int aEndPoint )
D_PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint )
{
    D_PAD*  pad = NULL;
    wxPoint aPosition;
    const wxPoint &aPosition = aTrace->GetEndPoint( aEndPoint );

    LAYER_MSK aLayerMask = GetLayerMask( aTrace->GetLayer() );

    if( aEndPoint == FLG_START )
    {
        aPosition = aTrace->GetStart();
    }
    else
    {
        aPosition = aTrace->GetEnd();
    }

    for( MODULE* module = m_Modules;  module;  module = module->Next() )
    {
        pad = module->GetPad( aPosition, aLayerMask );
@@ -2195,7 +2186,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS
    aSegment->end = newTrack;
    aSegment->SetState( END_ONPAD, false );

    D_PAD * pad = GetPad( newTrack, FLG_START );
    D_PAD * pad = GetPad( newTrack, ENDPOINT_START );

    if ( pad )
    {
+1 −1
Original line number Diff line number Diff line
@@ -1392,7 +1392,7 @@ public:
     * @param aEndPoint The end point of \a aTrace the hit test against.
     * @return A pointer to a D_PAD object if found or NULL if not found.
     */
    D_PAD* GetPad( TRACK* aTrace, int aEndPoint );
    D_PAD* GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint );

    /**
     * Function GetPadFast
+3 −8
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ static bool ShowClearance( const TRACK* aTrack )
 * return true if the dist between p1 and p2 < max_dist
 * Currently in test (currently ratsnest algos work only if p1 == p2)
 */
inline bool IsNear( wxPoint& p1, wxPoint& p2, int max_dist )
inline bool IsNear( const wxPoint& p1, const wxPoint& p2, int max_dist )
{
#if 0   // Do not change it: does not work
    int dist;
@@ -1320,21 +1320,16 @@ VIA* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, LAYER_MSK aLayer
}


TRACK* TRACK::GetTrack( TRACK* aStartTrace, TRACK* aEndTrace, int aEndPoint )
TRACK* TRACK::GetTrack( TRACK* aStartTrace, TRACK* aEndTrace, ENDPOINT_T aEndPoint )
{
    const int NEIGHTBOUR_COUNT_MAX = 50;

    TRACK*  previousSegment;
    TRACK*  nextSegment;
    int     Reflayer;
    wxPoint position;
    int     ii;
    int     max_dist;

    if( aEndPoint == FLG_START )
        position = m_Start;
    else
        position = m_End;
    const wxPoint &position = GetEndPoint( aEndPoint );

    Reflayer = GetLayerMask();

+12 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#define CLASS_TRACK_H


#include <pcbnew.h>
#include <class_board_item.h>
#include <class_board_connected_item.h>
#include <PolyLine.h>
@@ -124,6 +125,16 @@ public:
    void SetStart( const wxPoint& aStart )      { m_Start = aStart; }
    const wxPoint& GetStart() const             { return m_Start; }


    /// Return the selected endpoint (start or end)
    const wxPoint& GetEndPoint( ENDPOINT_T aEndPoint ) const
    {
        if( aEndPoint == ENDPOINT_START )
            return m_Start;
        else
            return m_End;
    }

    // Virtual function
    const EDA_RECT GetBoundingBox() const;

@@ -252,7 +263,7 @@ public:
     * @param aEndPoint The start or end point of the segment to test against.
     * @return A TRACK object pointer if found otherwise NULL.
     */
    TRACK* GetTrack( TRACK* aStartTrace, TRACK* aEndTrace, int aEndPoint );
    TRACK* GetTrack( TRACK* aStartTrace, TRACK* aEndTrace, ENDPOINT_T aEndPoint );

    /**
     * Function GetEndSegments
Loading