Pcbnew: legacy canvas: make trace len display working while creating the trace.
Previously, the full trace length was always displayed as 0 during track creation in the info canvas.
This commit is contained in:
parent
5de246c5be
commit
cee313da8c
|
@ -74,7 +74,7 @@ void PCB_EDIT_FRAME::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
|
|||
return;
|
||||
|
||||
m_canvas->CrossHairOff( DC ); // Erase cursor shape
|
||||
Track = GetBoard()->MarkTrace( track, &nb_segm, NULL, NULL, true );
|
||||
Track = GetBoard()->MarkTrace( GetBoard()->m_Track, track, &nb_segm, NULL, NULL, true );
|
||||
DrawTraces( m_canvas, DC, Track, nb_segm, GR_OR | GR_HIGHLIGHT );
|
||||
|
||||
for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- )
|
||||
|
|
|
@ -388,32 +388,32 @@ TRACKS BOARD::TracksInNetBetweenPoints( const wxPoint& aStartPos, const wxPoint&
|
|||
}
|
||||
|
||||
|
||||
void BOARD::chainMarkedSegments( wxPoint aPosition, const LSET& aLayerSet, TRACKS* aList )
|
||||
void BOARD::chainMarkedSegments( TRACK* aTrackList, wxPoint aPosition,
|
||||
const LSET& aLayerSet, TRACKS* aList )
|
||||
{
|
||||
LSET layer_set = aLayerSet;
|
||||
|
||||
if( !m_Track ) // no tracks at all in board
|
||||
if( !aTrackList ) // no tracks at all in board
|
||||
return;
|
||||
|
||||
D_PAD* pad = NULL;
|
||||
double distanceToPadCenter;
|
||||
double distanceToPadCenter = std::numeric_limits<double>::max();
|
||||
|
||||
/* Set the BUSY flag of all connected segments, first search starting at
|
||||
* aPosition. The search ends when a pad is found (end of a track), a
|
||||
* segment end has more than one other segment end connected, or when no
|
||||
* connected item found.
|
||||
*
|
||||
* Vias are a special case because they must look for segments connected
|
||||
* Vias are a special case because they can connect segments
|
||||
* on other layers and they change the layer mask. They can be a track
|
||||
* end or not. They will be analyzer later and vias on terminal points
|
||||
* end or not. They will be analyzed later, and vias on terminal points
|
||||
* of the track will be considered as part of this track if they do not
|
||||
* connect segments of a other track together and will be considered as
|
||||
* connect segments on a other track together and will be considered as
|
||||
* part of a other track when removing the via, the segments of that other
|
||||
* track are disconnected.
|
||||
*/
|
||||
for( ; ; )
|
||||
{
|
||||
|
||||
if( !pad )
|
||||
pad = GetPad( aPosition, layer_set );
|
||||
|
||||
|
@ -427,7 +427,7 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, const LSET& aLayerSet, TRACK
|
|||
* is found we do not know at this time the number of connected items
|
||||
* and we do not know if this via is on the track or finish the track
|
||||
*/
|
||||
TRACK* via = m_Track->GetVia( NULL, aPosition, layer_set );
|
||||
TRACK* via = aTrackList->GetVia( NULL, aPosition, layer_set );
|
||||
|
||||
if( via )
|
||||
{
|
||||
|
@ -443,7 +443,7 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, const LSET& aLayerSet, TRACK
|
|||
* if > 1 segment:
|
||||
* then end of "track" (because more than 2 segments are connected at aPosition)
|
||||
*/
|
||||
TRACK* segment = m_Track;
|
||||
TRACK* segment = aTrackList;
|
||||
|
||||
while( ( segment = ::GetTrack( segment, NULL, aPosition, layer_set ) ) != NULL )
|
||||
{
|
||||
|
@ -1812,7 +1812,7 @@ TRACK* BOARD::GetVisibleTrack( TRACK* aStartingTrace, const wxPoint& aPosition,
|
|||
}
|
||||
|
||||
|
||||
TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
||||
TRACK* BOARD::MarkTrace( TRACK* aTrackList, TRACK* aTrace, int* aCount,
|
||||
double* aTraceLength, double* aPadToDieLength,
|
||||
bool aReorder )
|
||||
{
|
||||
|
@ -1829,7 +1829,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
|||
|
||||
// Ensure the flag BUSY of all tracks of the board is cleared
|
||||
// because we use it to mark segments of the track
|
||||
for( TRACK* track = m_Track; track; track = track->Next() )
|
||||
for( TRACK* track = aTrackList; track; track = track->Next() )
|
||||
track->SetState( BUSY, false );
|
||||
|
||||
// Set flags of the initial track segment
|
||||
|
@ -1847,7 +1847,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
|||
*/
|
||||
if( aTrace->Type() == PCB_VIA_T )
|
||||
{
|
||||
TRACK* segm1 = ::GetTrack( m_Track, NULL, aTrace->GetStart(), layer_set );
|
||||
TRACK* segm1 = ::GetTrack( aTrackList, NULL, aTrace->GetStart(), layer_set );
|
||||
TRACK* segm2 = NULL;
|
||||
TRACK* segm3 = NULL;
|
||||
|
||||
|
@ -1875,13 +1875,13 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
|||
if( segm1 ) // search for other segments connected to the initial segment start point
|
||||
{
|
||||
layer_set = segm1->GetLayerSet();
|
||||
chainMarkedSegments( aTrace->GetStart(), layer_set, &trackList );
|
||||
chainMarkedSegments( aTrackList, aTrace->GetStart(), layer_set, &trackList );
|
||||
}
|
||||
|
||||
if( segm2 ) // search for other segments connected to the initial segment end point
|
||||
{
|
||||
layer_set = segm2->GetLayerSet();
|
||||
chainMarkedSegments( aTrace->GetStart(), layer_set, &trackList );
|
||||
chainMarkedSegments( aTrackList, aTrace->GetStart(), layer_set, &trackList );
|
||||
}
|
||||
}
|
||||
else // mark the chain using both ends of the initial segment
|
||||
|
@ -1889,8 +1889,8 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
|||
TRACKS from_start;
|
||||
TRACKS from_end;
|
||||
|
||||
chainMarkedSegments( aTrace->GetStart(), layer_set, &from_start );
|
||||
chainMarkedSegments( aTrace->GetEnd(), layer_set, &from_end );
|
||||
chainMarkedSegments( aTrackList, aTrace->GetStart(), layer_set, &from_start );
|
||||
chainMarkedSegments( aTrackList, aTrace->GetEnd(), layer_set, &from_end );
|
||||
|
||||
// combine into one trackList:
|
||||
trackList.insert( trackList.end(), from_start.begin(), from_start.end() );
|
||||
|
@ -1916,7 +1916,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
|||
|
||||
layer_set = via->GetLayerSet();
|
||||
|
||||
TRACK* track = ::GetTrack( m_Track, NULL, via->GetStart(), layer_set );
|
||||
TRACK* track = ::GetTrack( aTrackList, NULL, via->GetStart(), layer_set );
|
||||
|
||||
// GetTrace does not consider tracks flagged BUSY.
|
||||
// So if no connected track found, this via is on the current track
|
||||
|
@ -1959,7 +1959,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
|
|||
int busy_count = 0;
|
||||
TRACK* firstTrack;
|
||||
|
||||
for( firstTrack = m_Track; firstTrack; firstTrack = firstTrack->Next() )
|
||||
for( firstTrack = aTrackList; firstTrack; firstTrack = firstTrack->Next() )
|
||||
{
|
||||
// Search for the first flagged BUSY segments
|
||||
if( firstTrack->GetState( BUSY ) )
|
||||
|
|
|
@ -203,11 +203,13 @@ private:
|
|||
* is used by MarkTrace() to set the BUSY flag of connected segments of the trace
|
||||
* segment located at \a aPosition on aLayerMask.
|
||||
* Vias are put in list but their flags BUSY is not set
|
||||
* @param aTrackList is the beginning of the track list (usually the board track list).
|
||||
* @param aPosition A wxPoint object containing the position of the starting search.
|
||||
* @param aLayerSet The allowed layers for segments to search.
|
||||
* @param aList The track list to fill with points of flagged segments.
|
||||
*/
|
||||
void chainMarkedSegments( wxPoint aPosition, const LSET& aLayerSet, TRACKS* aList );
|
||||
void chainMarkedSegments( TRACK* aTrackList, wxPoint aPosition,
|
||||
const LSET& aLayerSet, TRACKS* aList );
|
||||
|
||||
// The default copy constructor & operator= are inadequate,
|
||||
// either write one or do not use it at all
|
||||
|
@ -1247,6 +1249,8 @@ public:
|
|||
* are rearranged into a contiguous chain within the given list.
|
||||
* </p>
|
||||
*
|
||||
* @param aTrackList The list of available track segments.
|
||||
* usually tracks on board, but can be a list of segments currently created.
|
||||
* @param aTrace The segment within a list of trace segments to test.
|
||||
* @param aCount A pointer to an integer where to return the number of
|
||||
* marked segments (can be NULL).
|
||||
|
@ -1262,7 +1266,7 @@ public:
|
|||
* track length in this case, flags are reset
|
||||
* @return TRACK* - The first in the chain of interesting segments.
|
||||
*/
|
||||
TRACK* MarkTrace( TRACK* aTrace, int* aCount, double* aTraceLength,
|
||||
TRACK* MarkTrace( TRACK* aTrackList, TRACK* aTrace, int* aCount, double* aTraceLength,
|
||||
double* aInPackageLength, bool aReorder );
|
||||
|
||||
/**
|
||||
|
|
|
@ -1082,7 +1082,15 @@ void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
|
|||
{
|
||||
double trackLen = 0;
|
||||
double lenPadToDie = 0;
|
||||
board->MarkTrace( this, NULL, &trackLen, &lenPadToDie, false );
|
||||
|
||||
// Find the beginning of the track buffer containing this, because it is not
|
||||
// always the track list on board, but can be a "private" list
|
||||
TRACK* track_buffer_start = this;
|
||||
|
||||
while( track_buffer_start->Back() )
|
||||
track_buffer_start = track_buffer_start->Back();
|
||||
|
||||
board->MarkTrace( track_buffer_start, this, NULL, &trackLen, &lenPadToDie, false );
|
||||
msg = ::LengthDoubleToString( trackLen );
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKCYAN ) );
|
||||
|
||||
|
|
|
@ -208,7 +208,8 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
|
|||
if( pt_segm == NULL )
|
||||
return;
|
||||
|
||||
TRACK* trackList = GetBoard()->MarkTrace( pt_segm, &segments_to_delete_count,
|
||||
TRACK* trackList = GetBoard()->MarkTrace( GetBoard()->m_Track, pt_segm,
|
||||
&segments_to_delete_count,
|
||||
NULL, NULL, true );
|
||||
|
||||
if( segments_to_delete_count == 0 )
|
||||
|
|
|
@ -211,7 +211,8 @@ void PCB_EDIT_FRAME::Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment )
|
|||
if( aTrackSegment == NULL )
|
||||
return;
|
||||
|
||||
pt_track = GetBoard()->MarkTrace( aTrackSegment, &nb_segm, NULL, NULL, true );
|
||||
pt_track = GetBoard()->MarkTrace( GetBoard()->m_Track, aTrackSegment, &nb_segm,
|
||||
NULL, NULL, true );
|
||||
|
||||
PICKED_ITEMS_LIST itemsListPicker;
|
||||
bool change = false;
|
||||
|
|
|
@ -287,7 +287,8 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
|
|||
// Mark the full trace containing track_segment, and recalculate the
|
||||
// beginning of the trace, and the number of segments, as the new trace
|
||||
// can contain also already existing track segments
|
||||
aNewTrack = GetBoard()->MarkTrace( track_segment, &aNewTrackSegmentsCount,
|
||||
aNewTrack = GetBoard()->MarkTrace( GetBoard()->m_Track, track_segment,
|
||||
&aNewTrackSegmentsCount,
|
||||
nullptr, nullptr, true );
|
||||
wxASSERT( aNewTrack );
|
||||
|
||||
|
@ -421,7 +422,8 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
|
|||
if( pt_del )
|
||||
pt_del->SetState( IS_LINKED, false );
|
||||
|
||||
pt_del = GetBoard()->MarkTrace( pt_del, &nb_segm, NULL, NULL, true );
|
||||
pt_del = GetBoard()->MarkTrace( GetBoard()->m_Track, pt_del, &nb_segm,
|
||||
NULL, NULL, true );
|
||||
|
||||
/* Test if the marked track is redundant, i.e. if one of marked segments
|
||||
* is connected to the starting point of the new track.
|
||||
|
|
|
@ -780,44 +780,19 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
|
|||
if( isegm->GetLength() == 0 && g_CurrentTrackSegment->Back() )
|
||||
isegm = g_CurrentTrackSegment->Back();
|
||||
|
||||
// display interesting segment info only:
|
||||
// display track info:
|
||||
frame->SetMsgPanel( isegm );
|
||||
|
||||
// Display current track length (on board) and the the actual track len
|
||||
// if there is an extra len due to the len die on the starting pad (if any)
|
||||
double trackLen = 0.0;
|
||||
double lenPadToDie = 0.0;
|
||||
wxString msg;
|
||||
|
||||
// If the starting point is on a pad, add current track length+ length die
|
||||
if( g_FirstTrackSegment->GetState( BEGIN_ONPAD ) )
|
||||
{
|
||||
D_PAD* pad = (D_PAD*) g_FirstTrackSegment->start;
|
||||
lenPadToDie = (double) pad->GetPadToDieLength();
|
||||
}
|
||||
|
||||
// calculate track len on board:
|
||||
for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
|
||||
trackLen += track->GetLength();
|
||||
|
||||
msg = frame->LengthDoubleToString( trackLen );
|
||||
frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN );
|
||||
|
||||
if( lenPadToDie != 0 ) // display the track len on board and the actual track len
|
||||
{
|
||||
frame->AppendMsgPanel( _( "Full Len" ), msg, DARKCYAN );
|
||||
msg = frame->LengthDoubleToString( trackLen+lenPadToDie );
|
||||
frame->AppendMsgPanel( _( "Pad to die" ), msg, DARKCYAN );
|
||||
}
|
||||
|
||||
// Add current segments count (number of segments in this new track):
|
||||
msg.Printf( wxT( "%d" ), g_CurrentTrackList.GetCount() );
|
||||
// Display current segments count (number of segments in this new track):
|
||||
msg.Printf( "%d", g_CurrentTrackList.GetCount() );
|
||||
frame->AppendMsgPanel( _( "Segs Count" ), msg, DARKCYAN );
|
||||
|
||||
displ_opts->m_ShowTrackClearanceMode = showTrackClearanceMode;
|
||||
displ_opts->m_DisplayPcbTrackFill = tmp;
|
||||
|
||||
frame->BuildAirWiresTargetsList( NULL, g_CurrentTrackSegment->GetEnd(), g_CurrentTrackSegment->GetNetCode() );
|
||||
frame->BuildAirWiresTargetsList( NULL, g_CurrentTrackSegment->GetEnd(),
|
||||
g_CurrentTrackSegment->GetNetCode() );
|
||||
frame->TraceAirWiresToTargets( aDC );
|
||||
}
|
||||
|
||||
|
|
|
@ -948,7 +948,7 @@ int SELECTION_TOOL::selectCopper( const TOOL_EVENT& aEvent )
|
|||
void SELECTION_TOOL::selectAllItemsConnectedToTrack( TRACK& aSourceTrack )
|
||||
{
|
||||
int segmentCount;
|
||||
TRACK* trackList = board()->MarkTrace( &aSourceTrack, &segmentCount,
|
||||
TRACK* trackList = board()->MarkTrace( board()->m_Track, &aSourceTrack, &segmentCount,
|
||||
nullptr, nullptr, true );
|
||||
|
||||
for( int i = 0; i < segmentCount; ++i )
|
||||
|
|
Loading…
Reference in New Issue