Commit c2af94ac authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

Reworked the endpoint designator constants FLG_BEGIN and FLG_END in a

ENDPOINT_T enum type
parent 802a59dc
...@@ -1300,12 +1300,14 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) ...@@ -1300,12 +1300,14 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
g_CurrentTrackList.PushBack( newTrack ); 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 ) if( g_FirstTrackSegment->start )
g_FirstTrackSegment->SetState( BEGIN_ONPAD, true ); 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 ) if( g_CurrentTrackSegment->end )
g_CurrentTrackSegment->SetState( END_ONPAD, true ); g_CurrentTrackSegment->SetState( END_ONPAD, true );
......
...@@ -1598,22 +1598,13 @@ D_PAD* BOARD::GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask ) ...@@ -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; D_PAD* pad = NULL;
wxPoint aPosition; const wxPoint &aPosition = aTrace->GetEndPoint( aEndPoint );
LAYER_MSK aLayerMask = GetLayerMask( aTrace->GetLayer() ); 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() ) for( MODULE* module = m_Modules; module; module = module->Next() )
{ {
pad = module->GetPad( aPosition, aLayerMask ); pad = module->GetPad( aPosition, aLayerMask );
...@@ -2195,7 +2186,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS ...@@ -2195,7 +2186,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS
aSegment->end = newTrack; aSegment->end = newTrack;
aSegment->SetState( END_ONPAD, false ); aSegment->SetState( END_ONPAD, false );
D_PAD * pad = GetPad( newTrack, FLG_START ); D_PAD * pad = GetPad( newTrack, ENDPOINT_START );
if ( pad ) if ( pad )
{ {
......
...@@ -1392,7 +1392,7 @@ public: ...@@ -1392,7 +1392,7 @@ public:
* @param aEndPoint The end point of \a aTrace the hit test against. * @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. * @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 * Function GetPadFast
......
...@@ -70,7 +70,7 @@ static bool ShowClearance( const TRACK* aTrack ) ...@@ -70,7 +70,7 @@ static bool ShowClearance( const TRACK* aTrack )
* return true if the dist between p1 and p2 < max_dist * return true if the dist between p1 and p2 < max_dist
* Currently in test (currently ratsnest algos work only if p1 == p2) * 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 #if 0 // Do not change it: does not work
int dist; int dist;
...@@ -1320,21 +1320,16 @@ VIA* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, LAYER_MSK aLayer ...@@ -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; const int NEIGHTBOUR_COUNT_MAX = 50;
TRACK* previousSegment; TRACK* previousSegment;
TRACK* nextSegment; TRACK* nextSegment;
int Reflayer; int Reflayer;
wxPoint position;
int ii; int ii;
int max_dist; int max_dist;
const wxPoint &position = GetEndPoint( aEndPoint );
if( aEndPoint == FLG_START )
position = m_Start;
else
position = m_End;
Reflayer = GetLayerMask(); Reflayer = GetLayerMask();
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#define CLASS_TRACK_H #define CLASS_TRACK_H
#include <pcbnew.h>
#include <class_board_item.h> #include <class_board_item.h>
#include <class_board_connected_item.h> #include <class_board_connected_item.h>
#include <PolyLine.h> #include <PolyLine.h>
...@@ -124,6 +125,16 @@ public: ...@@ -124,6 +125,16 @@ public:
void SetStart( const wxPoint& aStart ) { m_Start = aStart; } void SetStart( const wxPoint& aStart ) { m_Start = aStart; }
const wxPoint& GetStart() const { return m_Start; } 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 // Virtual function
const EDA_RECT GetBoundingBox() const; const EDA_RECT GetBoundingBox() const;
...@@ -252,7 +263,7 @@ public: ...@@ -252,7 +263,7 @@ public:
* @param aEndPoint The start or end point of the segment to test against. * @param aEndPoint The start or end point of the segment to test against.
* @return A TRACK object pointer if found otherwise NULL. * @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 * Function GetEndSegments
......
...@@ -86,7 +86,7 @@ private: ...@@ -86,7 +86,7 @@ private:
* i.e. when they are colinear, same width, and obviously same layer * i.e. when they are colinear, same width, and obviously same layer
*/ */
TRACK* mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK* mergeCollinearSegmentIfPossible( TRACK* aTrackRef,
TRACK* aCandidate, int aEndType ); TRACK* aCandidate, ENDPOINT_T aEndType );
}; };
/* Install the cleanup dialog frame to know what should be cleaned /* Install the cleanup dialog frame to know what should be cleaned
...@@ -304,7 +304,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks() ...@@ -304,7 +304,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
if( (type_end & START_ON_PAD ) == 0 ) if( (type_end & START_ON_PAD ) == 0 )
{ {
TRACK* other = track->GetTrack( m_Brd->m_Track, NULL, FLG_START ); TRACK* other = track->GetTrack( m_Brd->m_Track, NULL, ENDPOINT_START );
if( other == NULL ) // Test a connection to zones if( other == NULL ) // Test a connection to zones
{ {
...@@ -341,7 +341,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks() ...@@ -341,7 +341,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
track->SetState( BUSY, true ); track->SetState( BUSY, true );
VIA* via = (VIA*) other; VIA* via = (VIA*) other;
other = via->GetTrack( m_Brd->m_Track, NULL, FLG_START ); other = via->GetTrack( m_Brd->m_Track, NULL, ENDPOINT_START );
if( other == NULL ) if( other == NULL )
{ {
...@@ -364,7 +364,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks() ...@@ -364,7 +364,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
// test if this track end point is connected to an other track // test if this track end point is connected to an other track
if( (type_end & END_ON_PAD ) == 0 ) if( (type_end & END_ON_PAD ) == 0 )
{ {
TRACK* other = track->GetTrack( m_Brd->m_Track, NULL, FLG_END ); TRACK* other = track->GetTrack( m_Brd->m_Track, NULL, ENDPOINT_END );
if( other == NULL ) // Test a connection to zones if( other == NULL ) // Test a connection to zones
{ {
...@@ -402,7 +402,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks() ...@@ -402,7 +402,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
track->SetState( BUSY, true ); track->SetState( BUSY, true );
VIA* via = (VIA*) other; VIA* via = (VIA*) other;
other = via->GetTrack( m_Brd->m_Track, NULL, FLG_END ); other = via->GetTrack( m_Brd->m_Track, NULL, ENDPOINT_END );
if( other == NULL ) if( other == NULL )
{ {
...@@ -508,7 +508,7 @@ bool TRACKS_CLEANER::clean_segments() ...@@ -508,7 +508,7 @@ bool TRACKS_CLEANER::clean_segments()
// search for a possible point connected to the START point of the current segment // search for a possible point connected to the START point of the current segment
for( segStart = segment->Next(); ; ) for( segStart = segment->Next(); ; )
{ {
segStart = segment->GetTrack( segStart, NULL, FLG_START ); segStart = segment->GetTrack( segStart, NULL, ENDPOINT_START );
if( segStart ) if( segStart )
{ {
...@@ -522,7 +522,7 @@ bool TRACKS_CLEANER::clean_segments() ...@@ -522,7 +522,7 @@ bool TRACKS_CLEANER::clean_segments()
// We must have only one segment connected // We must have only one segment connected
segStart->SetState( BUSY, true ); segStart->SetState( BUSY, true );
other = segment->GetTrack( m_Brd->m_Track, NULL, FLG_START ); other = segment->GetTrack( m_Brd->m_Track, NULL, ENDPOINT_START );
segStart->SetState( BUSY, false ); segStart->SetState( BUSY, false );
if( other == NULL ) if( other == NULL )
...@@ -535,7 +535,7 @@ bool TRACKS_CLEANER::clean_segments() ...@@ -535,7 +535,7 @@ bool TRACKS_CLEANER::clean_segments()
if( flag ) // We have the starting point of the segment is connected to an other segment if( flag ) // We have the starting point of the segment is connected to an other segment
{ {
segDelete = mergeCollinearSegmentIfPossible( segment, segStart, FLG_START ); segDelete = mergeCollinearSegmentIfPossible( segment, segStart, ENDPOINT_START );
if( segDelete ) if( segDelete )
{ {
...@@ -548,7 +548,7 @@ bool TRACKS_CLEANER::clean_segments() ...@@ -548,7 +548,7 @@ bool TRACKS_CLEANER::clean_segments()
// search for a possible point connected to the END point of the current segment: // search for a possible point connected to the END point of the current segment:
for( segEnd = segment->Next(); ; ) for( segEnd = segment->Next(); ; )
{ {
segEnd = segment->GetTrack( segEnd, NULL, FLG_END ); segEnd = segment->GetTrack( segEnd, NULL, ENDPOINT_END );
if( segEnd ) if( segEnd )
{ {
...@@ -560,7 +560,7 @@ bool TRACKS_CLEANER::clean_segments() ...@@ -560,7 +560,7 @@ bool TRACKS_CLEANER::clean_segments()
// We must have only one segment connected // We must have only one segment connected
segEnd->SetState( BUSY, true ); segEnd->SetState( BUSY, true );
other = segment->GetTrack( m_Brd->m_Track, NULL, FLG_END ); other = segment->GetTrack( m_Brd->m_Track, NULL, ENDPOINT_END );
segEnd->SetState( BUSY, false ); segEnd->SetState( BUSY, false );
if( other == NULL ) if( other == NULL )
...@@ -576,7 +576,7 @@ bool TRACKS_CLEANER::clean_segments() ...@@ -576,7 +576,7 @@ bool TRACKS_CLEANER::clean_segments()
if( flag & 2 ) // We have the ending point of the segment is connected to an other segment if( flag & 2 ) // We have the ending point of the segment is connected to an other segment
{ {
segDelete = mergeCollinearSegmentIfPossible( segment, segEnd, FLG_END ); segDelete = mergeCollinearSegmentIfPossible( segment, segEnd, ENDPOINT_END );
if( segDelete ) if( segDelete )
{ {
...@@ -607,7 +607,7 @@ bool TRACKS_CLEANER::clean_segments() ...@@ -607,7 +607,7 @@ bool TRACKS_CLEANER::clean_segments()
* else return NULL * else return NULL
*/ */
TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK* aCandidate, TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK* aCandidate,
int aEndType ) ENDPOINT_T aEndType )
{ {
if( aTrackRef->GetWidth() != aCandidate->GetWidth() ) if( aTrackRef->GetWidth() != aCandidate->GetWidth() )
return NULL; return NULL;
...@@ -667,7 +667,7 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK* ...@@ -667,7 +667,7 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK*
* (this function) is called when there is only 2 connected segments, * (this function) is called when there is only 2 connected segments,
*and if this point is not on a pad, it can be removed and the 2 segments will be merged *and if this point is not on a pad, it can be removed and the 2 segments will be merged
*/ */
if( aEndType == FLG_START ) if( aEndType == ENDPOINT_START )
{ {
// We do not have a pad, which is a always terminal point for a track // We do not have a pad, which is a always terminal point for a track
if( aTrackRef->GetState( START_ON_PAD) ) if( aTrackRef->GetState( START_ON_PAD) )
...@@ -744,7 +744,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks() ...@@ -744,7 +744,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks()
} }
else else
{ {
other = segment->GetTrack( GetBoard()->m_Track, NULL, FLG_START ); other = segment->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_START );
if( other ) if( other )
net_code_s = other->GetNetCode(); net_code_s = other->GetNetCode();
...@@ -762,7 +762,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks() ...@@ -762,7 +762,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks()
} }
else else
{ {
other = segment->GetTrack( GetBoard()->m_Track, NULL, FLG_END ); other = segment->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_END );
if( other ) if( other )
net_code_e = other->GetNetCode(); net_code_e = other->GetNetCode();
......
...@@ -266,7 +266,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -266,7 +266,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
newTrack->SetState( BEGIN_ONPAD | END_ONPAD, false ); newTrack->SetState( BEGIN_ONPAD | END_ONPAD, false );
D_PAD* pad = GetBoard()->GetPad( previousTrack, FLG_END ); D_PAD* pad = GetBoard()->GetPad( previousTrack, ENDPOINT_END );
if( pad ) if( pad )
{ {
...@@ -1057,7 +1057,7 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList ) ...@@ -1057,7 +1057,7 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
while( track != NULL ) while( track != NULL )
{ {
TRACK* next_track = track->Next(); TRACK* next_track = track->Next();
LockPoint = pcb->GetPad( track, FLG_END ); LockPoint = pcb->GetPad( track, ENDPOINT_END );
if( LockPoint ) if( LockPoint )
{ {
......
...@@ -709,7 +709,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ...@@ -709,7 +709,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
s_StartSegmentPresent = s_EndSegmentPresent = true; s_StartSegmentPresent = s_EndSegmentPresent = true;
if( ( track->start == NULL ) || ( track->start->Type() == PCB_TRACE_T ) ) if( ( track->start == NULL ) || ( track->start->Type() == PCB_TRACE_T ) )
TrackToStartPoint = track->GetTrack( GetBoard()->m_Track, NULL, FLG_START ); TrackToStartPoint = track->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_START );
// Test if more than one segment is connected to this point // Test if more than one segment is connected to this point
if( TrackToStartPoint ) if( TrackToStartPoint )
...@@ -717,14 +717,14 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ...@@ -717,14 +717,14 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
TrackToStartPoint->SetState( BUSY, true ); TrackToStartPoint->SetState( BUSY, true );
if( ( TrackToStartPoint->Type() == PCB_VIA_T ) if( ( TrackToStartPoint->Type() == PCB_VIA_T )
|| track->GetTrack( GetBoard()->m_Track, NULL, FLG_START ) ) || track->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_START ) )
error = true; error = true;
TrackToStartPoint->SetState( BUSY, false ); TrackToStartPoint->SetState( BUSY, false );
} }
if( ( track->end == NULL ) || ( track->end->Type() == PCB_TRACE_T ) ) if( ( track->end == NULL ) || ( track->end->Type() == PCB_TRACE_T ) )
TrackToEndPoint = track->GetTrack( GetBoard()->m_Track, NULL, FLG_END ); TrackToEndPoint = track->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_END );
// Test if more than one segment is connected to this point // Test if more than one segment is connected to this point
if( TrackToEndPoint ) if( TrackToEndPoint )
...@@ -732,7 +732,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ...@@ -732,7 +732,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
TrackToEndPoint->SetState( BUSY, true ); TrackToEndPoint->SetState( BUSY, true );
if( (TrackToEndPoint->Type() == PCB_VIA_T) if( (TrackToEndPoint->Type() == PCB_VIA_T)
|| track->GetTrack( GetBoard()->m_Track, NULL, FLG_END ) ) || track->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_END ) )
error = true; error = true;
TrackToEndPoint->SetState( BUSY, false ); TrackToEndPoint->SetState( BUSY, false );
......
...@@ -25,9 +25,11 @@ ...@@ -25,9 +25,11 @@
#define MATCH_LAYER (1 << 2) ///< if module not on current layer, do not select #define MATCH_LAYER (1 << 2) ///< if module not on current layer, do not select
#define VISIBLE_ONLY (1 << 3) ///< if module not on a visible layer, do not select #define VISIBLE_ONLY (1 << 3) ///< if module not on a visible layer, do not select
/// Flag used in locate routines (from which endpoint work)
#define FLG_START 0 // Flag used in locate routines enum ENDPOINT_T {
#define FLG_END 1 // Flag used in locate routines ENDPOINT_START = 0,
ENDPOINT_END = 1
};
#define DIM_ANCRE_MODULE 3 // Anchor size (footprint center) #define DIM_ANCRE_MODULE 3 // Anchor size (footprint center)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment