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 )
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 );
......
......@@ -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 )
{
......
......@@ -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
......
......@@ -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();
......
......@@ -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
......
......@@ -86,7 +86,7 @@ private:
* i.e. when they are colinear, same width, and obviously same layer
*/
TRACK* mergeCollinearSegmentIfPossible( TRACK* aTrackRef,
TRACK* aCandidate, int aEndType );
TRACK* aCandidate, ENDPOINT_T aEndType );
};
/* Install the cleanup dialog frame to know what should be cleaned
......@@ -304,7 +304,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
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
{
......@@ -341,7 +341,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
track->SetState( BUSY, true );
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 )
{
......@@ -364,7 +364,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
// test if this track end point is connected to an other track
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
{
......@@ -402,7 +402,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
track->SetState( BUSY, true );
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 )
{
......@@ -508,7 +508,7 @@ bool TRACKS_CLEANER::clean_segments()
// search for a possible point connected to the START point of the current segment
for( segStart = segment->Next(); ; )
{
segStart = segment->GetTrack( segStart, NULL, FLG_START );
segStart = segment->GetTrack( segStart, NULL, ENDPOINT_START );
if( segStart )
{
......@@ -522,7 +522,7 @@ bool TRACKS_CLEANER::clean_segments()
// We must have only one segment connected
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 );
if( other == NULL )
......@@ -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
{
segDelete = mergeCollinearSegmentIfPossible( segment, segStart, FLG_START );
segDelete = mergeCollinearSegmentIfPossible( segment, segStart, ENDPOINT_START );
if( segDelete )
{
......@@ -548,7 +548,7 @@ bool TRACKS_CLEANER::clean_segments()
// search for a possible point connected to the END point of the current segment:
for( segEnd = segment->Next(); ; )
{
segEnd = segment->GetTrack( segEnd, NULL, FLG_END );
segEnd = segment->GetTrack( segEnd, NULL, ENDPOINT_END );
if( segEnd )
{
......@@ -560,7 +560,7 @@ bool TRACKS_CLEANER::clean_segments()
// We must have only one segment connected
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 );
if( other == NULL )
......@@ -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
{
segDelete = mergeCollinearSegmentIfPossible( segment, segEnd, FLG_END );
segDelete = mergeCollinearSegmentIfPossible( segment, segEnd, ENDPOINT_END );
if( segDelete )
{
......@@ -607,7 +607,7 @@ bool TRACKS_CLEANER::clean_segments()
* else return NULL
*/
TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK* aCandidate,
int aEndType )
ENDPOINT_T aEndType )
{
if( aTrackRef->GetWidth() != aCandidate->GetWidth() )
return NULL;
......@@ -667,7 +667,7 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK*
* (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
*/
if( aEndType == FLG_START )
if( aEndType == ENDPOINT_START )
{
// We do not have a pad, which is a always terminal point for a track
if( aTrackRef->GetState( START_ON_PAD) )
......@@ -744,7 +744,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks()
}
else
{
other = segment->GetTrack( GetBoard()->m_Track, NULL, FLG_START );
other = segment->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_START );
if( other )
net_code_s = other->GetNetCode();
......@@ -762,7 +762,7 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks()
}
else
{
other = segment->GetTrack( GetBoard()->m_Track, NULL, FLG_END );
other = segment->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_END );
if( other )
net_code_e = other->GetNetCode();
......
......@@ -266,7 +266,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
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 )
{
......@@ -1057,7 +1057,7 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
while( track != NULL )
{
TRACK* next_track = track->Next();
LockPoint = pcb->GetPad( track, FLG_END );
LockPoint = pcb->GetPad( track, ENDPOINT_END );
if( LockPoint )
{
......
......@@ -709,7 +709,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
s_StartSegmentPresent = s_EndSegmentPresent = true;
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
if( TrackToStartPoint )
......@@ -717,14 +717,14 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
TrackToStartPoint->SetState( BUSY, true );
if( ( TrackToStartPoint->Type() == PCB_VIA_T )
|| track->GetTrack( GetBoard()->m_Track, NULL, FLG_START ) )
|| track->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_START ) )
error = true;
TrackToStartPoint->SetState( BUSY, false );
}
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
if( TrackToEndPoint )
......@@ -732,7 +732,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
TrackToEndPoint->SetState( BUSY, true );
if( (TrackToEndPoint->Type() == PCB_VIA_T)
|| track->GetTrack( GetBoard()->m_Track, NULL, FLG_END ) )
|| track->GetTrack( GetBoard()->m_Track, NULL, ENDPOINT_END ) )
error = true;
TrackToEndPoint->SetState( BUSY, false );
......
......@@ -25,9 +25,11 @@
#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 FLG_START 0 // Flag used in locate routines
#define FLG_END 1 // Flag used in locate routines
/// Flag used in locate routines (from which endpoint work)
enum ENDPOINT_T {
ENDPOINT_START = 0,
ENDPOINT_END = 1
};
#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