23#include <wx/filedlg.h>
25#include <wx/hyperlink.h>
35using namespace std::placeholders;
108using namespace KIGFX;
112 const std::vector<PENDING_STACK_EXPANSION>& aPending )
114 if( aPreRoute.count( aVia->
m_Uuid ) )
120 if( !exp.m_Pos || *exp.m_Pos != aVia->
GetPosition() )
129 return &exp.m_Preset;
142 if( aCurrent == aStart )
146 if( aCurrent == aEnd )
158class UI_UPDATE_INTERVAL_GUARD
161 UI_UPDATE_INTERVAL_GUARD(
long aNewInterval ) :
162 m_saved( wxUpdateUIEvent::GetUpdateInterval() )
164 wxUpdateUIEvent::SetUpdateInterval( aNewInterval );
167 ~UI_UPDATE_INTERVAL_GUARD()
169 wxUpdateUIEvent::SetUpdateInterval( m_saved );
204 .Name(
"pcbnew.InteractiveRouter.PlaceVia" )
206 .DefaultHotkey(
'V' )
207 .LegacyHotkeyName(
"Add Through Via" )
208 .FriendlyName(
_(
"Place Through Via" ) )
209 .Tooltip(
_(
"Adds a through-hole via at the end of currently routed track." ) )
215 .Name(
"pcbnew.InteractiveRouter.PlaceBlindVia" )
218 .LegacyHotkeyName(
"Add Blind/Buried Via" )
219 .FriendlyName(
_(
"Place Blind/Buried Via" ) )
220 .Tooltip(
_(
"Adds a blind or buried via at the end of currently routed track.") )
226 .Name(
"pcbnew.InteractiveRouter.PlaceMicroVia" )
228 .DefaultHotkey(
MD_CTRL +
'V' )
229 .LegacyHotkeyName(
"Add MicroVia" )
230 .FriendlyName(
_(
"Place Microvia" ) )
231 .Tooltip(
_(
"Adds a microvia at the end of currently routed track." ) )
238 .Name(
"pcbnew.InteractiveRouter.PlaceViaStack" )
241 .FriendlyName(
_(
"Place Microvia Stack at Track End" ) )
242 .Tooltip(
_(
"Drops the active microvia stack preset at the end of the currently routed track "
243 "and continues on the target layer." ) )
248 .Name(
"pcbnew.InteractiveRouter.SelLayerAndPlaceVia" )
250 .DefaultHotkey(
'<' )
251 .LegacyHotkeyName(
"Select Layer and Add Through Via" )
252 .FriendlyName(
_(
"Select Layer and Place Through Via..." ) )
253 .Tooltip(
_(
"Select a layer, then add a through-hole via at the end of currently routed track." ) )
259 .Name(
"pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia" )
261 .DefaultHotkey(
MD_ALT +
'<' )
262 .LegacyHotkeyName(
"Select Layer and Add Blind/Buried Via" )
263 .FriendlyName(
_(
"Select Layer and Place Blind/Buried Via..." ) )
264 .Tooltip(
_(
"Select a layer, then add a blind or buried via at the end of currently routed track." ) )
270 .Name(
"pcbnew.InteractiveRouter.SelLayerAndPlaceMicroVia" )
272 .FriendlyName(
_(
"Select Layer and Place Micro Via..." ) )
273 .Tooltip(
_(
"Select a layer, then add a micro via at the end of currently routed track." ) )
279 .Name(
"pcbnew.InteractiveRouter.CustomTrackViaSize" )
281 .DefaultHotkey(
'Q' )
282 .LegacyHotkeyName(
"Custom Track/Via Size" )
283 .FriendlyName(
_(
"Custom Track/Via Size..." ) )
284 .Tooltip(
_(
"Shows a dialog for changing the track width and via size." ) )
288 .Name(
"pcbnew.InteractiveRouter.SpreadTracksSetDistance" )
290 .DefaultHotkey(
'E' )
291 .LegacyHotkeyName(
"Set Spreading Distance" )
292 .FriendlyName(
_(
"Set Spreading Distance..." ) )
293 .Tooltip(
_(
"Sets the distance between the tracks for the Spread Tracks tool." ) )
297 .Name(
"pcbnew.InteractiveRouter.IncreaseSpreadingDistance" )
299 .DefaultHotkey(
']' )
300 .LegacyHotkeyName(
"Increase Spreading Distance" )
301 .FriendlyName(
_(
"Increase Spreading Distance..." ) )
302 .Tooltip(
_(
"Increases the distance between the tracks for the Spread Tracks tool by one grid unit." ) )
306 .Name(
"pcbnew.InteractiveRouter.DecreaseSpreadingDistance" )
308 .DefaultHotkey(
'[' )
309 .LegacyHotkeyName(
"Decrease Spreading Distance" )
310 .FriendlyName(
_(
"Decrease Spreading Distance..." ) )
311 .Tooltip(
_(
"Decreases the distance between the tracks for the Spread Tracks tool by one grid unit." ) )
316 .Name(
"pcbnew.InteractiveRouter.SwitchPosture" )
318 .DefaultHotkey(
'/' )
319 .LegacyHotkeyName(
"Switch Track Posture" )
320 .FriendlyName(
_(
"Switch Track Posture" ) )
321 .Tooltip(
_(
"Switches posture of the currently routed track." ) )
326 .Name(
"pcbnew.InteractiveRouter.SwitchRoundingToNext" )
328 .DefaultHotkey(
MD_CTRL +
'/' )
329 .FriendlyName(
_(
"Track Corner Mode Switch" ) )
330 .Tooltip(
_(
"Switches between sharp/rounded and 45°/90° corners when routing tracks." ) )
335 .Name(
"pcbnew.InteractiveRouter.SwitchRounding45" )
337 .DefaultHotkey(
MD_CTRL +
'W' )
338 .FriendlyName(
_(
"Track Corner Mode 45" ) )
339 .Tooltip(
_(
"Switch to 45° corner when routing tracks." ) ) );
342 .Name(
"pcbnew.InteractiveRouter.SwitchRounding90" )
345 .FriendlyName(
_(
"Track Corner Mode 90" ) )
346 .Tooltip(
_(
"Switch to 90° corner when routing tracks." ) ) );
349 .Name(
"pcbnew.InteractiveRouter.SwitchRoundingArc45" )
352 .FriendlyName(
_(
"Track Corner Mode Arc 45" ) )
353 .Tooltip(
_(
"Switch to arc 45° corner when routing tracks." ) ) );
356 .Name(
"pcbnew.InteractiveRouter.SwitchRoundingArc90" )
358 .DefaultHotkey(
MD_ALT +
'W' )
359 .FriendlyName(
_(
"Track Corner Mode Arc 90" ) )
360 .Tooltip(
_(
"Switch to arc 90° corner when routing tracks." ) ) );
363#define _(s) wxGetTranslation((s))
386 SetTitle(
_(
"Select Track/Via Width" ) );
404 _(
"Route using the width of the starting track." ), wxITEM_CHECK );
409 _(
"Use track and via sizes from the net class" ), wxITEM_CHECK );
414 _(
"Specify custom track and via sizes" ), wxITEM_CHECK );
425 msg =
_(
"Track netclass width" );
427 msg.Printf(
_(
"Track %s" ),
m_frame.MessageTextFromValue( width ) );
430 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
441 msg =
_(
"Via netclass values" );
444 if(
via.m_Drill > 0 )
446 msg.Printf(
_(
"Via %s, hole %s" ),
447 m_frame.MessageTextFromValue(
via.m_Diameter ),
448 m_frame.MessageTextFromValue(
via.m_Drill ) );
452 msg.Printf(
_(
"Via %s" ),
453 m_frame.MessageTextFromValue(
via.m_Diameter ) );
458 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
466 int id = aEvent.GetId();
518 SetTitle(
_(
"Select Differential Pair Dimensions" ) );
534 _(
"Use differential pair dimensions from the net class" ), wxITEM_CHECK );
539 _(
"Specify custom differential pair dimensions" ), wxITEM_CHECK );
552 if( diffPair.
m_Gap <= 0 )
556 msg.Printf(
_(
"Width %s" ),
561 msg.Printf(
_(
"Width %s, via gap %s" ),
570 msg.Printf(
_(
"Width %s, gap %s" ),
576 msg.Printf(
_(
"Width %s, gap %s, via gap %s" ),
584 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
592 int id = aEvent.GetId();
636 auto& menu =
m_menu->GetMenu();
637 menu.SetUntranslatedTitle(
_HKI(
"Interactive Router" ) );
657 auto notRoutingCond =
660 return !
m_router->RoutingInProgress();
663 auto spreadingTracksCond =
669 auto inRouteSelected =
678 std::vector<PNS::NET_HANDLE> currentNets =
m_router->GetCurrentNets();
680 if( currentNets.empty() || currentNets[0] ==
nullptr )
687 RN_NET* ratsnest =
board->GetConnectivity()->GetRatsnestForNet( currentNet );
689 return ratsnest && !ratsnest->
GetEdges().empty();
694 menu.AddSeparator( 1 );
697 menu.AddSeparator( haveHighlight, 2 );
725 submenuCornerMode->
SetTitle(
_(
"Track Corner Mode" ) );
735 menu.AddMenu( submenuCornerMode );
738 auto cornerMode45Cond =
744 auto cornerMode90Cond =
750 auto cornerModeArc45Cond =
756 auto cornerModeArc90Cond =
762#define CHECK( x ) ACTION_CONDITIONS().Check( x )
806 static size_t lastLoggerSize = 0;
807 static wxString mruPath;
812 if( !logger || logger->GetEvents().size() == 0
813 || logger->GetEvents().size() == lastLoggerSize )
818 if( !testCaseDir.IsEmpty() )
825 wxFileName
path = wxFileName::DirName( testCaseDir );
829 if(
path.DirExists() )
831 doExit = !
IsOK(
frame(), wxString::Format(
_(
"Test case in directory %s already exists. Overwrite?"),
path.GetFullPath() ) );
835 path.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
838 path.SetName( wxT(
"pns") );
839 logPath =
path.GetFullPath();
848 lastLoggerSize = logger->GetEvents().size();
854 if ( mruPath.IsEmpty() )
859 wxFileDialog dlg(
frame(),
_(
"Save router log" ), mruPath,
"pns.log",
861 wxFD_OVERWRITE_PROMPT | wxFD_SAVE );
865 if( dlg.ShowModal() != wxID_OK )
867 lastLoggerSize = logger->GetEvents().size();
871 logPath = dlg.GetPath();
875 wxFileName fname_log( logPath );
876 mruPath = fname_log.GetPath();
877 fname_log.SetExt(
"log" );
878 wxLogTrace( wxT(
"PNS" ), wxT(
"save log to: %s" ), fname_log.GetFullPath() );
880 wxFileName fname_dump( fname_log );
881 fname_dump.SetExt(
"dump" );
883 wxFileName fname_settings( fname_log );
884 fname_settings.SetExt(
"settings" );
886 FILE* settings_f = wxFopen( fname_settings.GetAbsolutePath(),
"wb" );
890 DisplayError(
frame(), wxString::Format(
_(
"Unable to write '%s'." ), fname_settings.GetAbsolutePath() ) );
894 std::string settingsStr =
m_router->Settings().FormatAsString();
895 fprintf( settings_f,
"%s\n", settingsStr.c_str() );
896 fclose( settings_f );
903 pcb_io.
SaveBoard( fname_dump.GetAbsolutePath(), *
m_iface->GetBoard(),
nullptr );
912 wxString srcRules = editFrame->GetBoard()->GetDesignRulesPath();
914 if( !srcRules.IsEmpty() && wxFileName::FileExists( srcRules ) )
916 wxFileName fname_rules( fname_dump );
918 wxCopyFile( srcRules, fname_rules.GetAbsolutePath() );
923 std::vector<PNS::ITEM*> removed;
927 for(
auto item : removed )
932 wxASSERT_MSG( item->Parent() !=
nullptr,
"removed an item with no parent uuid?" );
944 logData.
m_Events = logger->GetEvents();
946 FILE* log_f = wxFopen( fname_log.GetAbsolutePath(),
"wb" );
952 fname_log.GetAbsolutePath() ) );
956 fprintf( log_f,
"%s\n", logString.c_str().AsChar() );
992 bool asChanged =
false;
1047 int startLayer =
m_iface->GetPNSLayerFromBoardLayer( tl );
1053 return m_iface->GetBoardLayerFromPNSLayer( ls.
Start() );
1062 int activeLayer =
m_iface->GetPNSLayerFromBoardLayer(
frame()->GetActiveLayer() );
1063 int currentLayer =
m_router->GetCurrentLayer();
1065 if( currentLayer != activeLayer )
1066 m_router->SwitchLayer( activeLayer );
1068 std::optional<int> newLayer =
m_router->Sizes().PairedLayer( currentLayer );
1071 newLayer =
m_router->Sizes().GetLayerTop();
1073 m_router->SwitchLayer( *newLayer );
1084 std::vector<PNS::NET_HANDLE> nets =
m_router->GetCurrentNets();
1088 std::shared_ptr<DRC_ENGINE>& drcEngine = bds.
m_DRCEngine;
1094 dummyTrack.
SetLayer( targetLayer );
1116 if( !constraint.
IsNull() )
1144 dummyTrackB.
SetLayer( targetLayer );
1151 if( !constraint.
IsNull() )
1169 if( !constraint.
IsNull() )
1203 wxASSERT_MSG(
false, wxT(
"Unhandled via type" ) );
1250 if( presets.empty() )
1252 frame()->GetInfoBar()->ShowMessageFor(
_(
"No microvia stack presets defined. Add one in Board Setup, "
1253 "Microvia Stacks." ),
1254 3000, wxICON_INFORMATION );
1258 int idx = std::clamp( bds.
GetViaStackIndex(), 0, (
int) presets.size() - 1 );
1270 frame()->GetInfoBar()->ShowMessageFor(
_(
"The microvia stack preset layers are not present on this board." ),
1271 3000, wxICON_ERROR );
1279 frame()->GetInfoBar()->ShowMessageFor( wxString::Format(
_(
"The microvia stack runs between %s and %s. "
1280 "Route on one of those layers to place it." ),
1283 3000, wxICON_ERROR );
1298 if( traces.
Size() > 0 )
1302 if( line->PointCount() > 0 )
1303 head = line->CLine().CLastPoint();
1309 frame()->GetInfoBar()->ShowMessageFor(
_(
"Could not end the track here for a microvia stack." ), 3000,
1327 if( !
m_router->GetCurrentNets().empty() )
1330 net = ni->GetNetCode();
1379 m_iface->GetPNSLayerFromBoardLayer( targetLayer ) );
1386 if(
m_router->RoutingInProgress() )
1404 if( traces.
Size() == 0 )
1411 if( line->EndsWithVia() )
1455 size_t target_idx = 0;
1457 for(
size_t i = 0; i < layers.size(); i++ )
1459 if( layers[i] == currentLayer )
1466 target_idx = ( idx + 1 ) % layers.size();
1469 for(
size_t i = 0; i < layers.size() - 1; i++ )
1473 targetLayer = layers[target_idx];
1478 if( target_idx >= layers.size() )
1493 size_t target_idx = 0;
1495 for(
size_t i = 0; i < layers.size(); i++ )
1497 if( layers[i] == currentLayer )
1504 target_idx = ( idx > 0 ) ? ( idx - 1 ) : ( layers.size() - 1 );
1506 for(
size_t i = 0; i < layers.size() - 1; i++ )
1510 targetLayer = layers[target_idx];
1514 if( target_idx > 0 )
1517 target_idx = layers.size() - 1;
1539 if( !enabledLayers.test( targetLayer ) )
1545 if( targetLayer == currentLayer )
1565 bool selectLayer =
false;
1570 const int actViaFlags = aEvent.
Parameter<
int>();
1585 endPoint =
frame()->GetCanvas()->ClientToScreen( endPoint );
1591 not_allowed_ly.
set( currentLayer );
1593 targetLayer =
frame()->SelectOneLayer(
static_cast<PCB_LAYER_ID>( currentLayer ),
1594 not_allowed_ly, endPoint );
1605 if( currentLayer == targetLayer )
1616 && ( ( targetLayer ==
B_Cu && currentLayer ==
F_Cu )
1617 || ( targetLayer ==
F_Cu && currentLayer ==
B_Cu ) ) )
1632 if( !
m_router->GetNearestRatnestAnchor( otherEnd, otherEndLayers, otherEndItem ) )
1635 currentLayer = pairTop;
1636 targetLayer = pairBottom;
1643 const std::optional<int> pairedLayerPns =
m_router->Sizes().PairedLayer(
m_router->GetCurrentLayer() );
1651 const bool otherEndIsThrough =
1652 otherEndLayers == allCopperLayers
1653 || ( otherEndItem && otherEndItem->
HasHole()
1654 && otherEndItem->
Hole()->
Layers() == allCopperLayers );
1656 if( otherEndIsThrough )
1660 if( currentLayer == pairBottom )
1661 targetLayer = pairTop;
1662 else if( currentLayer == pairTop )
1663 targetLayer = pairBottom;
1665 targetLayer = pairTop;
1667 else if( currentLayer == otherEndLayerPcbId && pairedLayerPns.has_value() )
1671 targetLayer =
m_iface->GetBoardLayerFromPNSLayer( *pairedLayerPns );
1675 targetLayer =
m_iface->GetBoardLayerFromPNSLayer( otherEndLayers.
Start() );
1681 if( currentLayer == pairTop || currentLayer == pairBottom )
1685 currentLayer = pairTop;
1686 targetLayer = pairBottom;
1692 targetLayer = pairTop;
1696 if( currentLayer == targetLayer )
1699 infobar->
ShowMessageFor(
_(
"Via needs 2 different layers." ), 5000, wxICON_ERROR,
1700 WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION );
1715 if( !
m_router->GetCurrentNets().empty() )
1722 if( !constraint.
IsNull() )
1727 if( !constraint.
IsNull() )
1738 m_iface->GetPNSLayerFromBoardLayer( targetLayer ) );
1745 if(
m_router->RoutingInProgress() )
1771 int pnsLayer =
m_iface->GetPNSLayerFromBoardLayer( pcbLayer );
1782 if( !
getView()->IsLayerVisible( pcbLayer ) )
1790 m_iface->SetStartLayerFromPCBNew( pcbLayer );
1792 frame()->GetBoard()->GetDesignSettings().m_TempOverrideTrackWidth =
false;
1795 m_iface->GetPNSLayerFromBoardLayer(
frame()->GetScreen()->m_Route_Layer_BOTTOM ) );
1825 m_router->ClearViewDecorations();
1836 frame()->UndoRedoBlock(
true );
1872 frame()->UndoRedoBlock(
false );
1894 auto syncRouterAndFrameLayer =
1897 int pnsLayer =
m_router->GetCurrentLayer();
1903 if( !
getView()->IsLayerVisible( pcbLayer ) )
1918 if( startWithVia && !startReachesViaTarget )
1925 UI_UPDATE_INTERVAL_GUARD uiGuard( 200 );
1931 m_toolMgr->GetView()->SyncLayerVisibilityCache();
1936 if( !
m_router->RoutingInProgress() )
1938 if( evt->IsCancelInteractive() )
1955 if( std::optional<VECTOR2I> last =
m_router->UndoLastSegment() )
1958 evt->SetMousePosition( last.value() );
1969 bool* autoRouted = evt->Parameter<
bool*>();
1976 if( autoRouted !=
nullptr )
1985 if( autoRouted !=
nullptr )
1987 *autoRouted =
false;
1997 bool needsAppend =
m_router->Placer()->HasPlacedAnything();
2001 syncRouterAndFrameLayer();
2013 frame()->ShowInfoBarError(
m_router->FailureReason(),
true );
2022 bool needLayerSwitch =
m_router->IsPlacingVia();
2023 bool forceCommit =
false;
2033 if( needLayerSwitch )
2043 syncRouterAndFrameLayer();
2084 bool forceFinish =
true;
2085 bool forceCommit =
false;
2091 || evt->IsActivate()
2097 if( evt->IsActivate() && !evt->IsMoveTool() )
2104 else if( evt->IsUndoRedo() )
2122 evt->SetPassEvent();
2143 if( settingsDlg.
ShowModal() == wxID_OK )
2175 settings.SetMode( mode );
2203 return m_router->Settings().Mode();
2209 return m_router->RoutingInProgress();
2243 if(
m_router->RoutingInProgress() )
2267 controls->ForceCursorPosition(
false );
2272 std::vector<BOARD_CONNECTED_ITEM*> itemList;
2279 itemList.push_back(
pad );
2287 std::shared_ptr<CONNECTIVITY_DATA> connectivity =
frame->GetBoard()->GetConnectivity();
2290 bool groupStart =
true;
2298 RN_NET* net = connectivity->GetRatsnestForNet( item->GetNetCode() );
2303 std::vector<std::shared_ptr<const CN_ANCHOR>> anchors;
2307 std::shared_ptr<const CN_ANCHOR> target = edge.GetTargetNode();
2308 std::shared_ptr<const CN_ANCHOR>
source = edge.GetSourceNode();
2310 if( !
source ||
source->Dirty() || !target || target->Dirty() )
2313 if(
source->Parent() == item )
2314 anchors.push_back(
source );
2315 else if( target->Parent() == item )
2316 anchors.push_back( target );
2320 for( std::shared_ptr<const CN_ANCHOR>
anchor : anchors )
2329 if(
frame->GetActiveLayer() != originalLayer )
2330 frame->SetActiveLayer( originalLayer );
2337 bool autoRouted =
false;
2382 std::vector<BOARD_CONNECTED_ITEM*> trackItems;
2390 if( trackItems.empty() )
2400 int dpSkipped = std::erase_if( trackItems,
2408 frame->ShowInfoBarMsg(
_(
"Differential pair members cannot be optimized." ) );
2410 bool groupStart =
true;
2428 branch->
Remove( originalLine );
2430 PNS::LINE optimizedLine( originalLine );
2439 if(
m_router->Settings().GetRestrictAngles() )
2461 branch->
Add( optimizedLine );
2473 int value =
m_router->Settings().GetSpreadTracksDistance();
2474 wxIntegerValidator<int>
validator( &value );
2479 if( modalResult == wxID_OK )
2481 int newSpreadDist = wxAtoi( dlg.
GetValue() );
2482 m_router->Settings().SetSpreadTracksDistance( newSpreadDist );
2494 int dist =
m_router->Settings().GetSpreadTracksDistance();
2496 int remainder = dist %
grid.x;
2499 dist += (
grid.x - remainder ) +
grid.x;
2501 dist -= remainder +
grid.x;
2506 m_router->Settings().SetSpreadTracksDistance( dist );
2528 controls->ForceCursorPosition(
false );
2537 bool pickingStartPoint =
true;
2543 m_toolMgr->GetView()->SyncLayerVisibilityCache();
2554 trackItems.
Add( ritem );
2558 if( trackItems.
Empty() )
2560 frame->ShowInfoBarError(
_(
"Please select a group of tracks you want to spread." ) );
2563 frame->ShowInfoBarMsg(
_(
"Pick a track you want to spread other tracks around." ) );
2568 if( evt->IsCancelInteractive() )
2573 else if( evt->IsActivate() )
2575 if( evt->IsMoveTool() || evt->IsEditorTool() )
2578 frame->PushTool( originalEvent );
2591 else if( evt->IsMotion() )
2593 if( pickingStartPoint )
2603 else if( evt->IsClick(
BUT_LEFT ) )
2605 if( !pickingStartPoint )
2607 m_router->FixRoute( evt->Position(),
nullptr,
true,
true );
2612 pickingStartPoint =
false;
2614 frame->GetInfoBar()->Dismiss();
2640 evt->SetPassEvent();
2656 frame->GetInfoBar()->Dismiss();
2667 if(
m_router->RoutingInProgress() )
2672 controls->ForceCursorPosition(
false );
2690 if(
m_router->RoutingInProgress() )
2713 controls->ForceCursorPosition(
false );
2729 m_toolMgr->GetView()->SyncLayerVisibilityCache();
2731 if( !evt->IsDrag() )
2734 if( evt->IsCancelInteractive() )
2738 else if( evt->IsActivate() )
2740 if( evt->IsMoveTool() || evt->IsEditorTool() )
2743 frame->PushTool( originalEvent );
2774 evt->SetPassEvent(
false );
2783 if( evt->HasPosition() )
2797 else if( evt->IsKeyPressed() )
2802 evt->SetPassEvent();
2810 evt->SetPassEvent();
2836 KIDIALOG dlg(
frame(),
_(
"The selected item is locked." ),
_(
"Confirmation" ),
2837 wxOK | wxCANCEL | wxICON_WARNING );
2838 dlg.SetOKLabel(
_(
"Drag Anyway" ) );
2849 if( !
m_router->FailureReason().IsEmpty() )
2850 frame()->ShowInfoBarError(
m_router->FailureReason(),
true );
2860 frame()->UndoRedoBlock(
true );
2862 UI_UPDATE_INTERVAL_GUARD uiGuard( 200 );
2868 m_toolMgr->GetView()->SyncLayerVisibilityCache();
2881 if( dragger->GetForceMarkObstaclesMode( &dragStatus ) )
2888 hint.Printf(
_(
"(%s to commit anyway.)" ),
2892 statusItem->
SetMessage(
_(
"Track violates DRC." ) );
2902 bool forceFinish =
false;
2903 bool forceCommit = evt->Modifier(
MD_CTRL );
2913 || evt->IsActivate() )
2918 if( evt->IsActivate() && !evt->IsMoveTool() )
2923 else if( evt->IsUndoRedo() )
2951 evt->SetPassEvent();
2956 evt->SetPassEvent();
2965 if(
m_router->RoutingInProgress() )
2971 frame()->UndoRedoBlock(
false );
2998 if( vias + traces == 0 )
3012 for(
int i = 0; !reference && i < aCollector.
GetCount(); i++ )
3013 reference =
dynamic_cast<PCB_TRACK*
>( aCollector[i] );
3027 refPoint = reference->
GetEnd();
3031 for(
int i = 0; i < aCollector.
GetCount(); i++ )
3035 if( neighbor && neighbor != reference )
3040 if( neighbor->
GetStart() != refPoint && neighbor->
GetEnd() != refPoint )
3047 aCollector.
Append( reference );
3063 bool allFootprints =
true;
3064 bool allTracks =
true;
3068 switch( item->Type() )
3077 allFootprints =
false;
3113 default:
return false;
3121 std::copy( aOriginalSelection.
Items().begin(), aOriginalSelection.
Items().end(), std::back_inserter( selItems ) );
3137 std::deque<EDA_ITEM*> selectedItems =
selection.GetItems();
3147 std::set<FOOTPRINT*> footprints;
3148 std::set<PAD*> freePads;
3149 bool blockDrag =
false;
3152 footprints.insert(
static_cast<FOOTPRINT*
>( item ) );
3156 for(
int idx = 0; idx <
selection.Size(); ++idx )
3158 if( !
selection.GetItem( idx )->IsBOARD_ITEM() )
3164 footprints.insert(
static_cast<FOOTPRINT*
>( selItem ) );
3174 frame()->ShowInfoBarMsg(
_(
"The selection contains items that cannot be dragged." ) );
3191 bool wasLocked =
false;
3208 bool showCourtyardConflicts =
frame()->GetPcbNewSettings()->m_ShowCourtyardCollisions;
3210 std::shared_ptr<DRC_ENGINE> drcEngine =
m_toolMgr->GetTool<
DRC_TOOL>()->GetDRCEngine();
3214 std::vector<BOARD_ITEM*> dynamicItems;
3215 std::unique_ptr<CONNECTIVITY_DATA> dynamicData =
nullptr;
3217 std::vector<PNS::ITEM*> leaderSegments;
3218 bool singleFootprintDrag =
false;
3226 for(
auto it = footprints.begin(); it != footprints.end(); )
3228 bool hasSolid =
false;
3230 for(
PAD*
pad : ( *it )->Pads() )
3231 hasSolid |= !
m_router->GetWorld()->FindItemsByParent(
pad ).empty();
3233 it = hasSolid ? std::next( it ) : footprints.erase( it );
3237 m_toolMgr->GetView()->SyncLayerVisibilityCache();
3239 if( !footprints.empty() )
3242 if( footprints.size() == 1 && !blockDrag )
3243 singleFootprintDrag =
true;
3245 if( showCourtyardConflicts )
3254 itemsToDrag.
Add( solid );
3258 if( connectivityData->GetRatsnestForPad(
pad ).size() > 0 )
3259 dynamicItems.push_back(
pad );
3266 itemsToDrag.
Add( solid );
3272 || shape->GetLayer() ==
Margin
3276 itemsToDrag.
Add( solid );
3280 if( showCourtyardConflicts )
3284 dynamicData = std::make_unique<CONNECTIVITY_DATA>(
board()->GetConnectivity(), dynamicItems,
true );
3285 connectivityData->BlockRatsnestItems( dynamicItems );
3288 if( footprints.empty() || blockDrag )
3290 for(
EDA_ITEM* selItem : selectedItems )
3292 if( !selItem->IsBOARD_ITEM() )
3305 itemsToDrag.
Add( pnsItem );
3309 PAD*
pad =
static_cast<PAD*
>( boardItem );
3312 if( footprints.count(
pad->GetParentFootprint() ) )
3315 freePads.insert(
pad );
3319 itemsToDrag.
Add( solid );
3331 if( itemsToDrag.
Count() >= 1 )
3337 int layer =
m_iface->GetPNSLayerFromBoardLayer( activeLayer );
3339 SEG::ecoord closestDistSq = std::numeric_limits<SEG::ecoord>::max();
3343 const SHAPE* shape = pitem->Shape( layer );
3350 if( distSq < closestDistSq )
3352 closestDistSq = distSq;
3353 closestItem = pitem;
3363 if( closestItem->
Net() )
3368 if( !footprints.empty() && singleFootprintDrag )
3379 tweakedMousePos =
footprint->GetPosition();
3394 int dragMode = aEvent.
Parameter<
int> ();
3396 if( !footprints.empty() || !freePads.empty() || blockDrag )
3397 dragMode &=
~PNS::DM_FREE_ANGLE;
3402 m_iface->SetIndependentPads( freePads );
3404 bool dragStarted =
m_router->StartDragging( p, itemsToDrag, dragMode );
3408 m_iface->SetIndependentPads( {} );
3411 frame()->ShowInfoBarMsg(
_(
"Nothing in the selection can be dragged." ) );
3416 if( !footprints.empty() )
3417 connectivityData->ClearLocalRatsnest();
3431 frame()->UndoRedoBlock(
true );
3435 size_t held = blockDragger->AnchoredLines().size();
3439 frame()->ShowInfoBarWarning(
3440 wxString::Format( wxPLURAL(
"%zu selected arc cannot move because both ends are fixed.",
3441 "%zu selected arcs cannot move because both ends are fixed.", held ),
3465 UI_UPDATE_INTERVAL_GUARD uiGuard( 200 );
3467 bool hasMouseMoved =
false;
3468 bool hasMultidragCancelled =
false;
3474 m_toolMgr->GetView()->SyncLayerVisibilityCache();
3478 if( evt->IsCancelInteractive()
3480 || evt->IsActivate() )
3485 hasMultidragCancelled =
true;
3489 else if( evt->IsMotion()
3493 hasMouseMoved =
true;
3499 if( !footprints.empty() )
3508 previewItem =
static_cast<BOARD_ITEM*
>( drawing->Clone() );
3509 previewItem->
Move( offset );
3518 &&
pad->GetDrillSize().x == 0 )
3521 previewItem->
Move( offset );
3534 previewItem->
Move( offset );
3539 previewItem->
Move( offset );
3543 if( showCourtyardConflicts )
3547 if( showCourtyardConflicts )
3549 courtyardClearanceDRC.
Run();
3557 dynamicData->Move( offset - lastOffset );
3558 lastOffset = offset;
3559 connectivityData->ComputeLocalRatsnest( dynamicItems, dynamicData.get(), offset );
3562 for(
PAD*
pad : freePads )
3569 if( dragger->GetForceMarkObstaclesMode( &dragStatus ) )
3577 statusItem->
SetMessage(
_(
"Track violates DRC." ) );
3585 else if( hasMouseMoved && ( evt->IsMouseUp(
BUT_LEFT )
3589 bool forceFinish =
false;
3590 bool forceCommit = evt->Modifier(
MD_CTRL );
3594 leaderSegments =
m_router->GetLastCommittedLeaderSegments();
3598 else if( evt->IsUndoRedo() )
3626 evt->SetPassEvent();
3631 evt->SetPassEvent();
3637 if( !footprints.empty() )
3654 connectivityData->ClearLocalRatsnest();
3657 for(
PAD*
pad : freePads )
3660 m_iface->SetIndependentPads( {} );
3665 if(
m_router->RoutingInProgress() )
3669 if( itemsToDrag.
Size() && hasMultidragCancelled )
3673 else if( leaderSegments.size() )
3675 std::vector<EDA_ITEM*> newItems;
3678 newItems.push_back( lseg->Parent() );
3686 frame()->UndoRedoBlock(
false );
3710 m_toolMgr->GetView()->SyncLayerVisibilityCache();
3738 KIDIALOG dlg(
frame(),
_(
"The selected item is locked." ),
_(
"Confirmation" ),
3739 wxOK | wxCANCEL | wxICON_WARNING );
3740 dlg.SetOKLabel(
_(
"Break Track" ) );
3749 frame()->UndoRedoBlock(
true );
3752 if(
m_router->RoutingInProgress() )
3755 frame()->UndoRedoBlock(
false );
3783 if( !
m_router->GetCurrentNets().empty() )
3802 std::vector<MSG_PANEL_ITEM> items;
3809 std::vector<PNS::NET_HANDLE> nets =
m_router->GetCurrentNets();
3810 wxString description;
3816 wxASSERT( nets.size() >= 2 );
3823 description = wxString::Format(
_(
"Routing Diff Pair: %s" ),
3830 if( *netclassA == *netclassB )
3836 secondary = wxString::Format(
_(
"Resolved Netclass: %s" ),
3839 else if( !nets.empty() && nets[0] )
3843 description = wxString::Format(
_(
"Routing Track: %s" ),
3846 secondary = wxString::Format(
3847 _(
"Resolved Netclass: %s" ),
3852 description =
_(
"Routing Track" );
3853 secondary =
_(
"(no net)" );
3856 items.emplace_back( description, secondary );
3858 wxString cornerMode;
3860 if(
m_router->Settings().GetFreeAngleMode() )
3862 cornerMode =
_(
"Free-angle" );
3866 switch(
m_router->Settings().GetCornerMode() )
3876 items.emplace_back(
_(
"Corner Style" ), cornerMode );
3878 switch(
m_router->Settings().Mode() )
3886 items.emplace_back(
_(
"Mode" ), mode );
3888#define FORMAT_VALUE( x ) frame()->MessageTextFromValue( x )
3892 items.emplace_back( wxString::Format(
_(
"Track Width: %s" ),
3894 wxString::Format(
_(
"(from %s)" ),
3897 items.emplace_back( wxString::Format(
_(
"Min Clearance: %s" ),
3899 wxString::Format(
_(
"(from %s)" ),
3902 items.emplace_back( wxString::Format(
_(
"Diff Pair Gap: %s" ),
3904 wxString::Format(
_(
"(from %s)" ),
3908 wxASSERT( traces.
Count() == 2 );
3911 traces[1],
m_router->GetCurrentLayer(), &constraint ) )
3913 items.emplace_back( wxString::Format(
_(
"DP Max Uncoupled-length: %s" ),
3915 wxString::Format(
_(
"(from %s)" ),
3921 items.emplace_back( wxString::Format(
_(
"Track Width: %s" ),
3923 wxString::Format(
_(
"(from %s)" ),
3926 items.emplace_back( wxString::Format(
_(
"Min Clearance: %s" ),
3928 wxString::Format(
_(
"(from %s)" ),
3934 frame()->SetMsgPanel( items );
std::function< void(const VECTOR2I &, GENERAL_COLLECTOR &, PCB_SELECTION_TOOL *)> CLIENT_SELECTION_FILTER
@ switch_corner_rounding_shape
constexpr BOX2I BOX2ISafe(const BOX2D &aInput)
static TOOL_ACTION cancelInteractive
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
static TOOL_ACTION pasteSpecial
static TOOL_ACTION cursorDblClick
static TOOL_ACTION doDelete
static TOOL_ACTION cursorClick
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION refreshPreview
static TOOL_ACTION finishInteractive
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SetLayerVisible(int aLayer, bool isVisible)
Manually update visibility for a given layer.
BASE_SET & set(size_t pos)
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
virtual void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
NETINFO_ITEM * GetNet() const
Return NETINFO_ITEM object for a given item.
Container for design settings for a BOARD object.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
void SetCustomDiffPairWidth(int aWidth)
Sets custom track width for differential pairs (i.e.
int GetCurrentViaSize() const
void SetViaSizeIndex(int aIndex)
Set the current via size list index to aIndex.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
bool m_UseConnectedTrackWidth
int GetTrackWidthIndex() const
int GetViaSizeIndex() const
int GetDiffPairIndex() const
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
void SetDiffPairIndex(int aIndex)
bool m_TempOverrideTrackWidth
void SetCustomDiffPairGap(int aGap)
Sets custom gap for differential pairs (i.e.
bool UseNetClassVia() const
Return true if netclass values should be used to obtain appropriate via size.
int GetViaStackIndex() const
bool UseNetClassTrack() const
Return true if netclass values should be used to obtain appropriate track width.
bool UseNetClassDiffPair() const
Return true if netclass values should be used to obtain appropriate diff pair dimensions.
void SetTrackWidthIndex(int aIndex)
Set the current track width list index to aIndex.
int GetCopperLayerCount() const
void UseCustomDiffPairDimensions(bool aEnabled)
Enables/disables custom differential pair dimensions.
std::vector< int > m_TrackWidthList
int GetCurrentViaDrill() const
std::vector< VIA_STACK_PRESET > m_ViaStackPresets
std::vector< VIA_DIMENSION > m_ViasDimensionsList
void SetCustomDiffPairViaGap(int aGap)
Sets custom via gap for differential pairs (i.e.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SetLocked(bool aLocked) override
bool IsLocked() const override
virtual void Move(const VECTOR2I &aMoveVector)
Move this object.
Information pertinent to a Pcbnew printed circuit board.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
BOARD_DESIGN_SETTINGS & GetDesignSettings()
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.
void Empty()
Clear the list.
int GetCount() const
Return the number of objects in the list.
int CountType(KICAD_T aType)
Count the number of items matching aType.
void Append(EDA_ITEM *item)
Add an item to the end of the list.
PNS::LOGGER::TEST_CASE_TYPE getTestCaseType() const
const wxString & getTestCaseName() const
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
@ ROUNDED_90
H/V with filleted corners.
@ MITERED_90
H/V only (90-degree corners)
@ ROUNDED_45
H/V/45 with filleted corners.
@ MITERED_45
H/V/45 with mitered corners (default)
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
std::vector< FOOTPRINT * > m_FpInMove
void ClearConflicts(KIGFX::VIEW *aView)
void UpdateConflicts(KIGFX::VIEW *aView, bool aHighlightMoved)
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, INFOBAR_MESSAGE_TYPE aType=INFOBAR_MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
Used when the right click button is pressed, or when the select tool is in effect.
static const std::vector< KICAD_T > DraggableItems
A scan list for items that can be dragged.
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox.
Abstract interface for drawing on a 2D-surface.
BOX2D GetVisibleWorldExtents() const
bool GetGridSnapping() const
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void ShowPreview(bool aShow=true)
virtual int GetTopLayer() const
GAL * GetGAL() const
Return the GAL this view is using to draw graphical primitives.
void Hide(VIEW_ITEM *aItem, bool aHide=true, bool aHideOverlay=false)
Temporarily hide the item in the view (e.g.
void AddToPreview(VIEW_ITEM *aItem, bool aTakeOwnership=true)
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
A collection of nets and the parameters used to route or test these nets.
bool HasuViaDrill() const
const wxString GetHumanReadableName() const
Gets the consolidated name of this netclass (which may be an aggregate).
bool HasuViaDiameter() const
int GetuViaDiameter() const
Handle the data for a net.
const wxString & GetNetname() const
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
static TOOL_ACTION_GROUP layerDirectSwitchActions()
static TOOL_ACTION layerToggle
static TOOL_ACTION drag45Degree
static TOOL_ACTION layerInner12
static TOOL_ACTION routerUndoLastSegment
static TOOL_ACTION layerInner8
static TOOL_ACTION layerInner3
static TOOL_ACTION layerPrev
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
static TOOL_ACTION layerInner2
static TOOL_ACTION routerAttemptFinish
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
static TOOL_ACTION trackViaSizeChanged
static TOOL_ACTION layerChanged
static TOOL_ACTION layerInner25
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
static TOOL_ACTION routerRouteSelectedFromEnd
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
static TOOL_ACTION routerWalkaroundMode
static TOOL_ACTION routerShoveMode
static TOOL_ACTION layerInner24
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION layerInner29
static TOOL_ACTION routerSpreadTracks
static TOOL_ACTION routerOptimizeSelected
static TOOL_ACTION routerAutorouteSelected
static TOOL_ACTION layerInner11
static TOOL_ACTION routerDiffPairDialog
static TOOL_ACTION routerContinueFromEnd
static TOOL_ACTION layerInner16
static TOOL_ACTION layerInner26
static TOOL_ACTION layerInner18
static TOOL_ACTION layerInner14
static TOOL_ACTION selectLayerPair
static TOOL_ACTION layerInner6
static TOOL_ACTION dragFreeAngle
static TOOL_ACTION clearHighlight
static TOOL_ACTION layerInner22
static TOOL_ACTION layerInner5
static TOOL_ACTION layerInner20
static TOOL_ACTION layerInner7
static TOOL_ACTION layerInner27
static TOOL_ACTION cancelCurrentItem
static TOOL_ACTION layerInner1
static TOOL_ACTION layerInner10
static TOOL_ACTION layerInner15
static TOOL_ACTION layerInner17
static TOOL_ACTION layerBottom
static TOOL_ACTION layerInner19
static TOOL_ACTION layerInner9
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
static TOOL_ACTION layerInner30
static TOOL_ACTION layerTop
static TOOL_ACTION cycleRouterMode
static TOOL_ACTION layerInner4
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
static TOOL_ACTION layerInner13
static TOOL_ACTION layerInner21
static TOOL_ACTION layerNext
static TOOL_ACTION routerRouteSelected
static TOOL_ACTION placeViaStack
static TOOL_ACTION layerInner23
static TOOL_ACTION layerInner28
Common, abstract interface for edit frames.
APPEARANCE_CONTROLS * GetAppearancePanel()
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual PCB_LAYER_ID GetActiveLayer() const
The main frame for Pcbnew.
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS.
A PCB_IO derivation for saving and loading Pcbnew s-expression formatted files.
void SaveBoard(const wxString &aFileName, BOARD &aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
PCB_LAYER_ID m_Route_Layer_TOP
PCB_LAYER_ID m_Route_Layer_BOTTOM
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
EDA_ITEM_FLAGS IsPointOnEnds(const VECTOR2I &point, int min_dist=0) const
Return STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if point if near (dist = m...
static int ExpandMultiHopMicrovias(BOARD *aBoard, BOARD_COMMIT *aCommit, const std::function< const VIA_STACK_PRESET *(PCB_VIA *)> &aMatcher=nullptr)
Replace loose microvias spanning more than one hop with stacks of single hop microvias.
static std::set< KIID > CollectExpandableMicrovias(BOARD *aBoard)
Ids of the vias ExpandMultiHopMicrovias would consider right now.
static const wxString GENERATOR_TYPE
PCB_LAYER_ID BottomLayer() const
VECTOR2I GetPosition() const override
void SetPosition(const VECTOR2I &aPoint) override
void SetSizeFromRules(int aDiameter, int aDrill)
Give the via a uniform padstack sized from its diameter and hole rules.
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
For a via m_layer contains the top layer, the other layer is in m_bottomLayer/.
int GetWidth() const override
void SetViaType(VIATYPE aViaType)
PCB_LAYER_ID TopLayer() const
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
int Count(int aKindMask=-1) const
void Add(const LINE &aLine)
std::vector< ITEM * > & Items()
Base class for PNS router board items.
const PNS_LAYER_RANGE & Layers() const
virtual NET_HANDLE Net() const
bool OfKind(int aKindMask) const
virtual HOLE * Hole() const
virtual bool HasHole() const
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
bool CompareGeometry(const LINE &aOther)
Return true if the line is geometrically identical as line aOther.
virtual void ClearLinks()
Erase the linking information. Used to detach the line from the owning node.
static wxString FormatLogFileAsJSON(const LOG_DATA &aLogData)
Keep the router "world" - i.e.
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Check if the item collides with anything else in the world, and if found, returns the obstacle.
RULE_RESOLVER * GetRuleResolver() const
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
const LINE AssembleLine(LINKED_ITEM *aSeg, int *aOriginSegmentIndex=nullptr, bool aStopAtLockedJoints=false, bool aFollowLockedSegments=false, bool aAllowSegmentSizeMismatch=true)
Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
void Remove(ARC *aArc)
Remove an item from this branch.
static bool Optimize(LINE *aLine, int aEffortLevel, NODE *aWorld, const VECTOR2I &aV=VECTOR2I(0, 0))
A quick shortcut to optimize a line without creating and setting up an optimizer.
@ SMART_PADS
Reroute pad exits.
@ FANOUT_CLEANUP
Simplify pad-pad and pad-via connections if possible.
@ MERGE_SEGMENTS
Reduce corner cost iteratively.
@ MERGE_COLINEAR
Merge co-linear segments.
@ MERGE_OBTUSE
Reduce corner cost by merging obtuse segments.
@ REQUIRE_OBTUSE_ANGLES
Try to prevent 90-degree or acute corners in a drag.
Contain all persistent settings of the router, such as the mode, optimization effort,...
void SetMode(PNS_MODE aMode)
Set the routing mode.
PNS_MODE Mode() const
Return the routing mode.
virtual bool QueryConstraint(CONSTRAINT_TYPE aType, const ITEM *aItemA, const ITEM *aItemB, int aLayer, CONSTRAINT *aConstraint)=0
virtual NET_HANDLE DpCoupledNet(NET_HANDLE aNet)=0
void SetViaType(VIATYPE aViaType)
void SetTrackWidth(int aWidth)
int DiffPairWidth() const
void SetDiffPairWidth(int aWidth)
void SetDiffPairWidthSource(const wxString &aSource)
void SetDiffPairGapSource(const wxString &aSource)
void SetDiffPairGap(int aGap)
void SetViaDrill(int aDrill)
wxString GetClearanceSource() const
wxString GetDiffPairGapSource() const
wxString GetDiffPairWidthSource() const
void AddLayerPair(int aL1, int aL2)
void SetClearance(int aClearance)
bool TrackWidthIsExplicit() const
void SetViaDiameter(int aDiameter)
void SetClearanceSource(const wxString &aSource)
wxString GetWidthSource() const
void SetWidthSource(const wxString &aSource)
int DiffPairViaGap() const
Represent a contiguous set of PCB layers.
bool Overlaps(const PNS_LAYER_RANGE &aOther) const
bool SaveAs(const wxString &aDirectory, const wxString &aFile)
bool SaveAs(const wxString &aDirectory, const wxString &aFile)
Container for project specific data.
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
virtual PROJECT_FILE & GetProjectFile() const
Describe ratsnest for a single net.
const std::vector< CN_EDGE > & GetEdges() const
void SetMessage(const wxString &aStatus)
void SetHint(const wxString &aHint)
void SetPosition(const VECTOR2I &aPos) override
VECTOR2I::extended_type ecoord
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
std::deque< EDA_ITEM * > & Items()
std::vector< EDA_ITEM * > GetItemsSortedBySelectionOrder() const
An abstract shape on 2D plane.
virtual SEG::ecoord SquaredDistance(const VECTOR2I &aP, bool aOutlineOnly=false) const
A modified version of the wxInfoBar class that allows us to:
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
A KICAD version of wxTextEntryDialog which supports the various improvements/work-arounds from DIALOG...
wxString GetValue() const
void SetTextValidator(const wxValidator &validator)
Handle a list of polygons defining a copper zone.
@ BLOCK
Cannot be represented at all, export to this target is not possible.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
@ VIA_DIAMETER_CONSTRAINT
@ DIFF_PAIR_GAP_CONSTRAINT
#define ROUTER_TRANSIENT
transient items that should NOT be cached
#define ENDPOINT
ends. (Used to support dragging.)
std::uint32_t EDA_ITEM_FLAGS
#define STARTPOINT
When a line is selected, these flags indicate which.
a few functions useful in geometry calculations.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=1u)
Clamp a vector to values that can be negated, respecting numeric limits of coordinates data type with...
wxString m_RouterTestCaseDirectory
Router test case directory.
static const std::string DesignRulesFileExtension
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
std::optional< wxString > fileHashMMH3(const wxString &aFilePath)
Calculates an MMH3 hash of a given file.
The Cairo implementation of the graphics abstraction layer.
Push and Shove diff pair dimensions (gap) settings dialog.
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
@ RM_Walkaround
Only walk around.
@ PNS_MODE_ROUTE_DIFF_PAIR
@ ID_POPUP_PCB_SELECT_WIDTH1
@ ID_POPUP_PCB_SELECT_DIFFPAIR16
@ ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES
@ ID_POPUP_PCB_SELECT_WIDTH16
@ ID_POPUP_PCB_SELECT_AUTO_WIDTH
@ ID_POPUP_PCB_SELECT_CUSTOM_WIDTH
@ ID_POPUP_PCB_SELECT_DIFFPAIR1
@ ID_POPUP_PCB_SELECT_USE_NETCLASS_DIFFPAIR
@ ID_POPUP_PCB_SELECT_VIASIZE1
@ ID_POPUP_PCB_SELECT_CUSTOM_DIFFPAIR
@ ID_POPUP_PCB_SELECT_VIASIZE16
Class that computes missing connections on a PCB.
std::vector< EDA_ITEM * > EDA_ITEMS
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
Container to handle a stock of specific differential pairs each with unique track width,...
An abstract function object, returning a design rule (clearance, diff pair gap, etc) required between...
std::optional< wxString > m_BoardHash
std::optional< TEST_CASE_TYPE > m_TestCaseType
std::vector< ITEM * > m_AddedItems
std::vector< EVENT_ENTRY > m_Events
std::set< KIID > m_RemovedItems
std::vector< ITEM * > m_Heads
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
A named microvia stack definition, chosen while routing instead of entering the values each time.
PCB_LAYER_ID m_StartLayer
JSON_SCHEMA_VALIDATOR validator(schema)
HYPERLINK_DV_RENDERER::RUN RUN
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
wxPoint ToWxPoint(const VECTOR2I &aSize)
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Definition of file extensions used in Kicad.