Commit b88505dd authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: code cleaning in ratsnest.cpp. Add comments.

parent 619a82a6
...@@ -397,17 +397,39 @@ public: ...@@ -397,17 +397,39 @@ public:
*/ */
void DrawGeneralRatsnest( wxDC* aDC, int aNetcode = 0 ); void DrawGeneralRatsnest( wxDC* aDC, int aNetcode = 0 );
void trace_ratsnest_pad( wxDC* DC ); /**
void build_ratsnest_pad( BOARD_ITEM* ref, const wxPoint& refpos, bool init ); * Function TraceAirWiresToTargets
* This functions shows airwires to nearest connecting points (pads)
* from the current new track end during track creation
* Uses data prepared by BuildAirWiresTargetsList()
* @param aDC = the current device context
*/
void TraceAirWiresToTargets( wxDC* DC );
/**
* Function BuildAirWiresTargetsList
* Build a list of candidates that can be a coonection point
* when a track is started.
* This functions prepares data to show airwires to nearest connecting points (pads)
* from the current new track to candidates during track creation
* @param aItemRef = the item connected to the starting point of the new track (track or pad)
* @param aPosition = the position of the new track end (usually the mouse cursor on grid)
* @param aInit = true to build full candidate list or false to update data
* When aInit = false, aItemRef is not used (can be NULL)
*/
void BuildAirWiresTargetsList( BOARD_CONNECTED_ITEM* aItemRef,
const wxPoint& aPosition, bool aInit );
/** /**
* Fucntion TestRatsNest * Function TestForActiveLinksInRatsnest
* computes the active rats nest * Explores the full rats nest list (which must exist) to determine
* The general rats nest list must exist. * the ACTIVE links in the full rats nest list
* Compute the ACTIVE rats nest in the general rats nest list * When tracks exist between pads, a link can connect 2 pads already connected by a track
* if aNetCode == 0, test all nets, else test only aNetCode * and the link is said inactive.
* When a link connects 2 pads not already connected by a track, the link is said active.
* @param aNetCode = net code to test. If 0, test all nets
*/ */
void TestRatsNest( wxDC* aDC, int aNetCode ); void TestForActiveLinksInRatsnest( int aNetCode );
/** /**
* Function TestConnections * Function TestConnections
......
...@@ -2133,7 +2133,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, int aActiveLayer, ...@@ -2133,7 +2133,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, int aActiveLayer,
} }
BOARD_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, int aLayerMask ) BOARD_CONNECTED_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, int aLayerMask )
{ {
for( MODULE* module = m_Modules; module; module = module->Next() ) for( MODULE* module = m_Modules; module; module = module->Next() )
{ {
......
...@@ -1251,7 +1251,7 @@ public: ...@@ -1251,7 +1251,7 @@ public:
* layer mask. * layer mask.
* @return A pointer to a BOARD_ITEM object if found otherwise NULL. * @return A pointer to a BOARD_ITEM object if found otherwise NULL.
*/ */
BOARD_ITEM* GetLockPoint( const wxPoint& aPosition, int aLayerMask ); BOARD_CONNECTED_ITEM* GetLockPoint( const wxPoint& aPosition, int aLayerMask );
/** /**
* Function CreateLockPoint * Function CreateLockPoint
......
...@@ -558,7 +558,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -558,7 +558,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
TestConnections( NULL ); TestConnections( NULL );
TestRatsNest( NULL, 0 ); // Recalculate the active ratsnest, i.e. the unconnected links TestForActiveLinksInRatsnest( 0 ); // Recalculate the active ratsnest, i.e. the unconnected links
OnModify(); OnModify();
GetBoard()->DisplayInfo( this ); GetBoard()->DisplayInfo( this );
DrawPanel->Refresh(); DrawPanel->Refresh();
......
...@@ -94,7 +94,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -94,7 +94,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
D_PAD* pt_pad = NULL; D_PAD* pt_pad = NULL;
TRACK* TrackOnStartPoint = NULL; TRACK* TrackOnStartPoint = NULL;
int layerMask = g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer]; int layerMask = g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer];
BOARD_ITEM* LockPoint; BOARD_CONNECTED_ITEM* LockPoint;
wxPoint pos = GetScreen()->GetCrossHairPosition(); wxPoint pos = GetScreen()->GetCrossHairPosition();
if( aTrack == NULL ) /* Starting a new track */ if( aTrack == NULL ) /* Starting a new track */
...@@ -148,7 +148,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -148,7 +148,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
D( g_CurrentTrackList.VerifyListIntegrity(); ); D( g_CurrentTrackList.VerifyListIntegrity(); );
build_ratsnest_pad( LockPoint, wxPoint( 0, 0 ), true ); BuildAirWiresTargetsList( LockPoint, wxPoint( 0, 0 ), true );
D( g_CurrentTrackList.VerifyListIntegrity(); ); D( g_CurrentTrackList.VerifyListIntegrity(); );
...@@ -428,7 +428,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -428,7 +428,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )
ShowNewTrackWhenMovingCursor( DrawPanel, aDC, wxDefaultPosition, true ); ShowNewTrackWhenMovingCursor( DrawPanel, aDC, wxDefaultPosition, true );
ShowNewTrackWhenMovingCursor( DrawPanel, aDC, wxDefaultPosition, false ); ShowNewTrackWhenMovingCursor( DrawPanel, aDC, wxDefaultPosition, false );
trace_ratsnest_pad( aDC ); TraceAirWiresToTargets( aDC );
/* cleanup /* cleanup
* if( g_CurrentTrackSegment->Next() != NULL ) * if( g_CurrentTrackSegment->Next() != NULL )
...@@ -447,7 +447,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -447,7 +447,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )
* This helps to reduce the computing time */ * This helps to reduce the computing time */
/* Attaching the end of the track. */ /* Attaching the end of the track. */
BOARD_ITEM* LockPoint = GetBoard()->GetLockPoint( pos, layerMask ); BOARD_CONNECTED_ITEM* LockPoint = GetBoard()->GetLockPoint( pos, layerMask );
if( LockPoint ) /* End of trace is on a pad. */ if( LockPoint ) /* End of trace is on a pad. */
{ {
...@@ -489,7 +489,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -489,7 +489,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )
GetBoard()->m_Track.Insert( track, insertBeforeMe ); GetBoard()->m_Track.Insert( track, insertBeforeMe );
} }
trace_ratsnest_pad( aDC ); TraceAirWiresToTargets( aDC );
DrawTraces( DrawPanel, aDC, firstTrack, newCount, GR_OR ); DrawTraces( DrawPanel, aDC, firstTrack, newCount, GR_OR );
...@@ -680,7 +680,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo ...@@ -680,7 +680,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
{ {
DrawTraces( aPanel, aDC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR ); DrawTraces( aPanel, aDC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR );
frame->trace_ratsnest_pad( aDC ); frame->TraceAirWiresToTargets( aDC );
if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
{ {
...@@ -807,8 +807,8 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo ...@@ -807,8 +807,8 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
DisplayOpt.ShowTrackClearanceMode = showTrackClearanceMode; DisplayOpt.ShowTrackClearanceMode = showTrackClearanceMode;
DisplayOpt.DisplayPcbTrackFill = Track_fill_copy; DisplayOpt.DisplayPcbTrackFill = Track_fill_copy;
frame->build_ratsnest_pad( NULL, g_CurrentTrackSegment->m_End, false ); frame->BuildAirWiresTargetsList( NULL, g_CurrentTrackSegment->m_End, false );
frame->trace_ratsnest_pad( aDC ); frame->TraceAirWiresToTargets( aDC );
} }
......
This diff is collapsed.
...@@ -174,7 +174,7 @@ int PCB_EDIT_FRAME::Fill_All_Zones( bool verbose ) ...@@ -174,7 +174,7 @@ int PCB_EDIT_FRAME::Fill_All_Zones( bool verbose )
TestConnections( NULL ); TestConnections( NULL );
// Recalculate the active ratsnest, i.e. the unconnected links // Recalculate the active ratsnest, i.e. the unconnected links
TestRatsNest( NULL, 0 ); TestForActiveLinksInRatsnest( 0 );
DrawPanel->Refresh( true ); DrawPanel->Refresh( true );
return errorLevel; return errorLevel;
......
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