394
bool SEGVIA::IsOnLayer( LAYER_NUM layer_number ) const
374
bool VIA::IsOnLayer( LAYER_ID layer_number ) const
396
LAYER_NUM bottom_layer, top_layer;
376
LAYER_ID bottom_layer, top_layer;
398
378
LayerPair( &top_layer, &bottom_layer );
400
if( bottom_layer <= layer_number && layer_number <= top_layer )
380
wxASSERT( top_layer <= bottom_layer );
382
if( top_layer <= layer_number && layer_number <= bottom_layer )
407
LAYER_MSK TRACK::GetLayerMask() const
409
if( Type() == PCB_VIA_T )
411
int via_type = GetShape();
413
if( via_type == VIA_THROUGH )
414
return ALL_CU_LAYERS;
416
// VIA_BLIND_BURIED or VIA_MICRVIA:
418
LAYER_NUM bottom_layer, top_layer;
420
// LayerPair() knows how layers are stored
421
( (SEGVIA*) this )->LayerPair( &top_layer, &bottom_layer );
423
LAYER_MSK layermask = NO_LAYERS;
425
while( bottom_layer <= top_layer )
427
layermask |= ::GetLayerMask( bottom_layer );
435
return ::GetLayerMask( m_Layer );
440
void SEGVIA::SetLayerPair( LAYER_NUM top_layer, LAYER_NUM bottom_layer )
442
if( GetShape() == VIA_THROUGH )
444
top_layer = LAYER_N_FRONT;
445
bottom_layer = LAYER_N_BACK;
448
if( bottom_layer > top_layer )
449
EXCHG( bottom_layer, top_layer );
451
// XXX EVIL usage of LAYER
452
m_Layer = (top_layer & 15) + ( (bottom_layer & 15) << 4 );
456
void SEGVIA::LayerPair( LAYER_NUM* top_layer, LAYER_NUM* bottom_layer ) const
458
LAYER_NUM b_layer = LAYER_N_BACK;
459
LAYER_NUM t_layer = LAYER_N_FRONT;
461
if( GetShape() != VIA_THROUGH )
463
// XXX EVIL usage of LAYER
464
b_layer = (m_Layer >> 4) & 15;
465
t_layer = m_Layer & 15;
467
if( b_layer > t_layer )
389
LSET VIA::GetLayerSet() const
391
if( GetViaType() == VIA_THROUGH )
392
return LSET::AllCuMask();
394
// VIA_BLIND_BURIED or VIA_MICRVIA:
396
LAYER_ID bottom_layer, top_layer;
398
// LayerPair() knows how layers are stored
399
LayerPair( &top_layer, &bottom_layer );
403
wxASSERT( top_layer <= bottom_layer );
405
// LAYER_IDs are numbered from front to back, this is top to bottom.
406
for( LAYER_NUM id = top_layer; id <= bottom_layer; ++id )
415
LSET TRACK::GetLayerSet() const
417
return LSET( m_Layer );
421
void VIA::SetLayerPair( LAYER_ID aTopLayer, LAYER_ID aBottomLayer )
423
if( GetViaType() == VIA_THROUGH )
429
if( aBottomLayer < aTopLayer )
430
EXCHG( aBottomLayer, aTopLayer );
433
m_BottomLayer = aBottomLayer;
437
void VIA::LayerPair( LAYER_ID* top_layer, LAYER_ID* bottom_layer ) const
439
LAYER_ID t_layer = F_Cu;
440
LAYER_ID b_layer = B_Cu;
442
if( GetViaType() != VIA_THROUGH )
444
b_layer = m_BottomLayer;
447
if( b_layer < t_layer )
468
448
EXCHG( b_layer, t_layer );
561
void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
562
const wxPoint& aOffset )
540
void TRACK::DrawShortNetname( EDA_DRAW_PANEL* panel,
541
wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aBgColor )
566
LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
568
if( Type() == PCB_ZONE_T && DisplayOpt.DisplayZonesMode != 0 )
571
BOARD * brd = GetBoard( );
572
EDA_COLOR_T color = brd->GetLayerColor(m_Layer);
574
if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
577
#ifdef USE_WX_OVERLAY
578
// If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
579
if( (m_Flags && IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
583
if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay )
585
if( !IsOnLayer( curr_layer ) )
586
ColorTurnToDarkDarkGray( &color );
589
if( aDrawMode & GR_HIGHLIGHT )
590
ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
592
ColorApplyHighlightFlag( &color );
594
SetAlpha( &color, 150 );
596
GRSetDrawMode( aDC, aDrawMode );
599
l_trace = m_Width >> 1;
601
if( m_Shape == S_CIRCLE )
603
radius = KiROUND( GetLineLength( m_Start, m_End ) );
605
if( aDC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH )
607
GRCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
608
m_Start.y + aOffset.y, radius, color );
613
if( aDC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH ) // Line mode if too small
615
GRCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
616
m_Start.y + aOffset.y, radius, color );
618
else if( ( !DisplayOpt.DisplayPcbTrackFill) || GetState( FORCE_SKETCH ) )
620
GRCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
621
m_Start.y + aOffset.y, radius - l_trace, color );
622
GRCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
623
m_Start.y + aOffset.y, radius + l_trace, color );
627
GRCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
628
m_Start.y + aOffset.y, radius, m_Width, color );
635
if( aDC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH )
637
GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, 0, color );
641
if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
643
GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
647
GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
648
m_Start.y + aOffset.y,
649
m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
652
if( panel->GetScreen()->m_IsPrinting )
655
// Show clearance for tracks, not for zone segments
656
if( ShowClearance( this ) )
658
GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset,
659
m_Width + (GetClearance() * 2), color );
662
/* Display the short netname for tracks, not for zone segments.
663
* we must filter tracks, to avoid a lot of texts.
543
/* we must filter tracks, to avoid a lot of texts.
664
544
* - only tracks with a length > 10 * thickness are eligible
665
545
* and, of course, if we are not printing the board
667
if( Type() == PCB_ZONE_T )
670
547
if( DisplayOpt.DisplayNetNamesMode == 0 || DisplayOpt.DisplayNetNamesMode == 1 )
732
610
tsize = (tsize * 7) / 10; // small reduction to give a better look
733
611
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
734
612
DrawGraphicHaloText( clipbox, aDC, tpos,
735
color, BLACK, WHITE, net->GetShortNetname(), angle,
736
wxSize( tsize, tsize ),
737
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
613
aBgColor, BLACK, WHITE, net->GetShortNetname(), angle,
614
wxSize( tsize, tsize ),
615
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
623
void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
624
const wxPoint& aOffset )
626
BOARD * brd = GetBoard( );
627
EDA_COLOR_T color = brd->GetLayerColor(m_Layer);
629
if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
632
#ifdef USE_WX_OVERLAY
633
// If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
634
if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
638
if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay )
640
LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
642
if( !IsOnLayer( curr_layer ) )
643
ColorTurnToDarkDarkGray( &color );
646
if( aDrawMode & GR_HIGHLIGHT )
647
ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
649
ColorApplyHighlightFlag( &color );
651
SetAlpha( &color, 150 );
653
GRSetDrawMode( aDC, aDrawMode );
655
int l_trace = m_Width / 2;
657
if( aDC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH )
659
GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, 0, color );
663
if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
665
GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
669
GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
670
m_Start.y + aOffset.y,
671
m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
674
if( panel->GetScreen()->m_IsPrinting )
677
// Show clearance for tracks, not for zone segments
678
if( ShowClearance( this ) )
680
GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset,
681
m_Width + (GetClearance() * 2), color );
684
DrawShortNetname( panel, aDC, aDrawMode, color );
688
void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
689
const wxPoint& aOffset )
691
if( DisplayOpt.DisplayZonesMode != 0 )
694
BOARD * brd = GetBoard( );
695
EDA_COLOR_T color = brd->GetLayerColor(m_Layer);
697
if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
700
#ifdef USE_WX_OVERLAY
701
// If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
702
if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
706
if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay )
708
LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
710
if( !IsOnLayer( curr_layer ) )
711
ColorTurnToDarkDarkGray( &color );
714
if( aDrawMode & GR_HIGHLIGHT )
715
ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
717
ColorApplyHighlightFlag( &color );
719
SetAlpha( &color, 150 );
721
GRSetDrawMode( aDC, aDrawMode );
723
int l_trace = m_Width / 2;
725
if( aDC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH )
727
GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, 0, color );
731
if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
733
GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
737
GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
738
m_Start.y + aOffset.y,
739
m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
742
// No clearance or netnames for zones
745
746
void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
747
748
// Show the track and its netname on different layers
1139
1096
aList.push_back( MSG_PANEL_ITEM( _( "Status" ), msg, MAGENTA ) );
1141
/* Display layer or layer pair) */
1142
if( Type() == PCB_VIA_T )
1144
SEGVIA* Via = (SEGVIA*) this;
1145
LAYER_NUM top_layer, bottom_layer;
1147
Via->LayerPair( &top_layer, &bottom_layer );
1149
msg = board->GetLayerName( top_layer ) + wxT( "/" )
1150
+ board->GetLayerName( bottom_layer );
1152
msg.Printf(wxT("%d/%d"), top_layer, bottom_layer );
1157
msg = board->GetLayerName( m_Layer );
1159
msg.Printf(wxT("%d"), m_Layer );
1162
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) );
1165
msg = ::CoordinateToString( (unsigned) m_Width );
1167
if( Type() == PCB_VIA_T ) // Display Diam and Drill values
1169
// Display diameter value:
1170
aList.push_back( MSG_PANEL_ITEM( _( "Diam" ), msg, DARKCYAN ) );
1172
// Display drill value
1173
int drill_value = GetDrillValue();
1175
msg = ::CoordinateToString( drill_value );
1177
wxString title = _( "Drill" );
1178
title += wxT( " " );
1181
title += _( "(Specific)" );
1183
title += _( "(Default)" );
1185
aList.push_back( MSG_PANEL_ITEM( title, msg, RED ) );
1189
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
1192
// Display segment length
1193
if( Type() != PCB_VIA_T ) // Display Diam and Drill values
1195
msg = ::LengthDoubleToString( GetLength() );
1196
aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) );
1201
bool TRACK::HitTest( const wxPoint& aPosition )
1203
int max_dist = m_Width >> 1;
1205
if( Type() == PCB_VIA_T )
1207
// rel_pos is aPosition relative to m_Start (or the center of the via)
1208
wxPoint rel_pos = aPosition - m_Start;
1209
double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
1210
return dist <= (double) max_dist * max_dist;
1213
return TestSegmentHit( aPosition, m_Start, m_End, max_dist );
1099
void TRACK::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
1102
BOARD* board = GetBoard();
1104
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Track" ), DARKCYAN ) );
1106
GetMsgPanelInfoBase_Common( aList );
1110
msg = board->GetLayerName( m_Layer );
1112
msg.Printf(wxT("%d"), m_Layer );
1114
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) );
1117
msg = ::CoordinateToString( (unsigned) m_Width );
1119
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
1121
// Display segment length
1122
msg = ::LengthDoubleToString( GetLength() );
1123
aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) );
1126
void SEGZONE::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
1129
BOARD* board = GetBoard();
1131
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Zone " ), DARKCYAN ) );
1133
GetMsgPanelInfoBase_Common( aList );
1137
msg = board->GetLayerName( m_Layer );
1139
msg.Printf(wxT("%d"), m_Layer );
1141
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) );
1144
msg = ::CoordinateToString( (unsigned) m_Width );
1146
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
1148
// Display segment length
1149
msg = ::LengthDoubleToString( GetLength() );
1150
aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) );
1153
void VIA::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
1156
BOARD* board = GetBoard();
1158
switch( GetViaType() )
1161
case VIA_NOT_DEFINED:
1162
msg = wxT( "???" ); // Not used yet, does not exist currently
1166
msg = _( "Micro Via" ); // from external layer (TOP or BOTTOM) from
1167
// the near neighbor inner layer only
1170
case VIA_BLIND_BURIED:
1171
msg = _( "Blind/Buried Via" ); // from inner or external to inner
1172
// or external layer (no restriction)
1176
msg = _( "Through Via" ); // Usual via (from TOP to BOTTOM layer only )
1180
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );
1182
GetMsgPanelInfoBase_Common( aList );
1185
// Display layer pair
1186
LAYER_ID top_layer, bottom_layer;
1188
LayerPair( &top_layer, &bottom_layer );
1190
msg = board->GetLayerName( top_layer ) + wxT( "/" )
1191
+ board->GetLayerName( bottom_layer );
1193
msg.Printf(wxT("%d/%d"), top_layer, bottom_layer );
1195
aList.push_back( MSG_PANEL_ITEM( _( "Layers" ), msg, BROWN ) );
1198
msg = ::CoordinateToString( (unsigned) m_Width );
1200
// Display diameter value:
1201
aList.push_back( MSG_PANEL_ITEM( _( "Diam" ), msg, DARKCYAN ) );
1203
// Display drill value
1204
int drill_value = GetDrillValue();
1206
msg = ::CoordinateToString( drill_value );
1208
wxString title = _( "Drill" );
1209
title += wxT( " " );
1212
title += _( "(Specific)" );
1214
title += _( "(Default)" );
1216
aList.push_back( MSG_PANEL_ITEM( title, msg, RED ) );
1220
bool TRACK::HitTest( const wxPoint& aPosition ) const
1222
return TestSegmentHit( aPosition, m_Start, m_End, m_Width / 2 );
1225
bool VIA::HitTest( const wxPoint& aPosition ) const
1227
int max_dist = m_Width / 2;
1229
// rel_pos is aPosition relative to m_Start (or the center of the via)
1230
wxPoint rel_pos = aPosition - m_Start;
1231
double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
1232
return dist <= (double) max_dist * max_dist;
1217
1236
bool TRACK::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1238
EDA_RECT arect = aRect;
1239
arect.Inflate( aAccuracy );
1242
/* Tracks are a special case:
1243
* they are considered inside the rect if one end is inside the rect */
1244
return arect.Contains( GetStart() ) || arect.Contains( GetEnd() );
1246
return arect.Intersects( GetStart(), GetEnd() );
1249
bool VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1220
1252
EDA_RECT arect = aRect;
1221
1253
arect.Inflate( aAccuracy );
1223
if( Type() == PCB_VIA_T )
1225
box.SetOrigin( GetStart() );
1226
box.Inflate( GetWidth() >> 1 );
1255
box.SetOrigin( GetStart() );
1256
box.Inflate( GetWidth() / 2 );
1229
return arect.Contains( box );
1231
return arect.Intersects( box );
1259
return arect.Contains( box );
1236
// Tracks are a specila case:
1237
// they are considered inside the rect if one end
1238
// is inside the rect
1239
return arect.Contains( GetStart() ) || arect.Contains( GetEnd() );
1241
return arect.Intersects( GetStart(), GetEnd() );
1246
TRACK* TRACK::GetVia( const wxPoint& aPosition, LAYER_NUM aLayer)
1250
for( track = this; track; track = track->Next() )
1252
if( track->Type() != PCB_VIA_T )
1255
if( !track->HitTest( aPosition ) )
1258
if( track->GetState( BUSY | IS_DELETED ) )
1261
if( aLayer == UNDEFINED_LAYER )
1264
if( track->IsOnLayer( aLayer ) )
1272
TRACK* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, LAYER_MSK aLayerMask )
1276
for( trace = this; trace != NULL; trace = trace->Next() )
1278
if( trace->Type() == PCB_VIA_T )
1261
return arect.Intersects( box );
1265
VIA* TRACK::GetVia( const wxPoint& aPosition, LAYER_ID aLayer)
1267
for( VIA* via = GetFirstVia( this ); via; via = GetFirstVia( via->Next() ) )
1269
if( via->HitTest( aPosition ) &&
1270
!via->GetState( BUSY | IS_DELETED ) &&
1271
((aLayer == UNDEFINED_LAYER) || (via->IsOnLayer( aLayer ))) )
1279
VIA* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, LSET aLayerMask )
1281
for( VIA* via = GetFirstVia( this, aEndTrace ); via; via = GetFirstVia( via->Next() ) )
1283
if( via->HitTest( aPosition ) &&
1284
!via->GetState( BUSY | IS_DELETED ) &&
1285
( aLayerMask & via->GetLayerSet() ).any()
1280
if( aPosition == trace->m_Start )
1282
if( trace->GetState( BUSY | IS_DELETED ) == 0 )
1284
if( aLayerMask & trace->GetLayerMask() )
1290
if( trace == aEndTrace )
1298
TRACK* TRACK::GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, int aEndPoint )
1296
TRACK* TRACK::GetTrack( TRACK* aStartTrace, TRACK* aEndTrace, ENDPOINT_T aEndPoint,
1297
bool aSameNetOnly, bool aSequential )
1300
const int NEIGHTBOUR_COUNT_MAX = 50;
1299
const wxPoint& position = GetEndPoint( aEndPoint );
1300
LSET refLayers = GetLayerSet();
1302
1301
TRACK* previousSegment;
1303
1302
TRACK* nextSegment;
1309
if( aEndPoint == FLG_START )
1306
// Simple sequential search: from aStartTrace forward to aEndTrace
1307
previousSegment = NULL;
1308
nextSegment = aStartTrace;
1314
Reflayer = GetLayerMask();
1316
previousSegment = nextSegment = this;
1319
for( ii = 0; ii < NEIGHTBOUR_COUNT_MAX; ii++ )
1321
if( (nextSegment == NULL) && (previousSegment == NULL) )
1312
/* Local bidirectional search: from this backward to aStartTrace
1313
* AND forward to aEndTrace. The idea is that nearest segments
1314
* are found (on average) faster in this way. In fact same-net
1315
* segments are almost guaranteed to be found faster, in a global
1316
* search, since they are grouped together in the track list */
1317
previousSegment = this;
1321
while( nextSegment || previousSegment )
1323
// Terminate the search in the direction if the netcode mismatches
1326
if( nextSegment && (nextSegment->GetNetCode() != GetNetCode()) )
1328
if( previousSegment && (previousSegment->GetNetCode() != GetNetCode()) )
1329
previousSegment = NULL;
1324
1332
if( nextSegment )
1326
if( nextSegment->GetState( BUSY | IS_DELETED ) )
1329
if( nextSegment == this )
1332
/* max_dist is the max distance between 2 track ends which
1333
* ensure a copper continuity */
1334
max_dist = ( nextSegment->m_Width + this->m_Width ) / 2;
1336
if( IsNear( position, nextSegment->m_Start, max_dist ) )
1338
if( Reflayer & nextSegment->GetLayerMask() )
1342
if( IsNear( position, nextSegment->m_End, max_dist ) )
1344
if( Reflayer & nextSegment->GetLayerMask() )
1334
if ( (nextSegment != this) &&
1335
!nextSegment->GetState( BUSY | IS_DELETED ) &&
1336
( refLayers & nextSegment->GetLayerSet() ).any() )
1338
if( (position == nextSegment->m_Start) ||
1339
(position == nextSegment->m_End) )
1343
// Keep looking forward
1348
1344
if( nextSegment == aEndTrace )
1349
1345
nextSegment = NULL;
1351
nextSegment = nextSegment->Next();
1347
nextSegment = nextSegment->Next();
1350
// Same as above, looking back. During sequential search this branch is inactive
1354
1351
if( previousSegment )
1356
if( previousSegment->GetState( BUSY | IS_DELETED ) )
1359
if( previousSegment == this )
1362
max_dist = ( previousSegment->m_Width + m_Width ) / 2;
1364
if( IsNear( position, previousSegment->m_Start, max_dist ) )
1366
if( Reflayer & previousSegment->GetLayerMask() )
1367
return previousSegment;
1370
if( IsNear( position, previousSegment->m_End, max_dist ) )
1372
if( Reflayer & previousSegment->GetLayerMask() )
1373
return previousSegment;
1353
if( (previousSegment != this) &&
1354
!previousSegment->GetState( BUSY | IS_DELETED ) &&
1355
( refLayers & previousSegment->GetLayerSet() ).any()
1358
if( (position == previousSegment->m_Start) ||
1359
(position == previousSegment->m_End) )
1360
return previousSegment;
1376
1363
if( previousSegment == aStartTrace )
1377
1364
previousSegment = NULL;
1378
else if( previousSegment->Type() != PCB_T )
1379
previousSegment = previousSegment->Back();
1381
previousSegment = NULL;
1386
for( nextSegment = aStartTrace; nextSegment != NULL; nextSegment = nextSegment->Next() )
1388
if( nextSegment->GetState( IS_DELETED | BUSY ) )
1390
if( nextSegment == aEndTrace )
1396
if( nextSegment == this )
1398
if( nextSegment == aEndTrace )
1404
max_dist = ( nextSegment->m_Width + m_Width ) / 2;
1406
if( IsNear( position, nextSegment->m_Start, max_dist ) )
1408
if( Reflayer & nextSegment->GetLayerMask() )
1412
if( IsNear( position, nextSegment->m_End, max_dist ) )
1414
if( Reflayer & nextSegment->GetLayerMask() )
1418
if( nextSegment == aEndTrace )
1366
previousSegment = previousSegment->Back();