KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_edit_frame.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2013 Wayne Stambaugh <[email protected]>
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#include <algorithm>
24#include <type_traits>
25#include <unordered_map>
26#include <unordered_set>
27#include <vector>
28
29#include <wx/log.h>
30#include <wx/filename.h>
31#include <wx/filedlg.h>
32#include <wx/hyperlink.h>
33#include <wx/socket.h>
34#include <wx/wupdlock.h>
35
36#include <advanced_config.h>
38#include <kiface_base.h>
39#include <kiway.h>
42#include <pgm_base.h>
43#include <pcb_edit_frame.h>
46#include <api/api_handler_pcb.h>
48#include <api/api_server.h>
49#include <api/api_utils.h>
51#include <bitmaps.h>
52#include <confirm.h>
53#include <footprint.h>
54#include <footprint_utils.h>
55#include <lset.h>
56#include <trace_helpers.h>
57#include <pcbnew_id.h>
58#include <pcbnew_settings.h>
61#include <dialog_find.h>
66#include <dialog_board_setup.h>
70#include <pad.h>
71#include <pcb_target.h>
72#include <pcb_point.h>
73#include <pcb_track.h>
74#include <layer_pairs.h>
77#include <text_var_dependency.h>
78#include <view/view.h>
80#include <functional>
81#include <pcb_barcode.h>
82#include <pcb_painter.h>
87#include <local_history.h>
88#include <tool/tool_manager.h>
90#include <tool/action_toolbar.h>
91#include <tool/common_control.h>
92#include <tool/common_tools.h>
93#include <tool/embed_tool.h>
95#include <tool/selection.h>
96#include <tool/zoom_tool.h>
97#include <tools/array_tool.h>
102#include <tools/edit_tool.h>
104#include <tools/pcb_group_tool.h>
105#include <tools/generator_tool.h>
107#include <tools/drc_tool.h>
110#include <tools/convert_tool.h>
111#include <tools/drawing_tool.h>
112#include <tools/pcb_control.h>
120#include <tools/pad_tool.h>
122#include <properties/property.h>
127#include <router/router_tool.h>
130#include <dialog_drc.h> // for DIALOG_DRC_WINDOW_NAME definition
135#include <widgets/wx_infobar.h>
139#include <widgets/wx_aui_utils.h>
140#include <kiplatform/app.h>
141#include <kiplatform/ui.h>
142#include <core/profile.h>
143#include <math/box2_minmax.h>
147#include <toolbars_pcb_editor.h>
149
150#include <richio.h>
151
152using namespace std::placeholders;
153
154
155#define INSPECT_DRC_ERROR_DIALOG_NAME wxT( "InspectDrcErrorDialog" )
156#define INSPECT_CLEARANCE_DIALOG_NAME wxT( "InspectClearanceDialog" )
157#define INSPECT_CONSTRAINTS_DIALOG_NAME wxT( "InspectConstraintsDialog" )
158#define FOOTPRINT_DIFF_DIALOG_NAME wxT( "FootprintDiffDialog" )
159
160
161BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
164
167
168 EVT_SIZE( PCB_EDIT_FRAME::OnSize )
169
170 // Menu Files:
173
174 EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
175 EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
176
177 // Horizontal toolbar
181
182 // Tracks and vias sizes general options
184 PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
185
186 // User interface update event handlers.
187 EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
188 EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::OnUpdateSelectViaSize )
190 PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
192 PCB_EDIT_FRAME::OnUpdateSelectViaSize )
193 // Drop files event
194 EVT_DROP_FILES( PCB_EDIT_FRAME::OnDropFiles )
195END_EVENT_TABLE()
196
197
198PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
199 PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_EDITOR, _( "PCB Editor" ), wxDefaultPosition, wxDefaultSize,
201 m_exportNetlistAction( nullptr ),
202 m_findDialog( nullptr ),
203 m_findByPropertiesDialog( nullptr ),
204 m_inspectDrcErrorDlg( nullptr ),
205 m_inspectClearanceDlg( nullptr ),
206 m_inspectConstraintsDlg( nullptr ),
207 m_footprintDiffDlg( nullptr ),
208 m_boardSetupDlg( nullptr ),
209 m_designBlocksPane( nullptr ),
210 m_importProperties( nullptr ),
211 m_eventCounterTimer( nullptr )
212{
213 m_maximizeByDefault = true;
214 m_showBorderAndTitleBlock = true; // true to display sheet references
215 m_SelTrackWidthBox = nullptr;
216 m_SelViaSizeBox = nullptr;
217 m_CurrentVariantCtrl = nullptr;
218 m_ShowLayerManagerTools = true;
219 m_supportsAutoSave = true;
220 m_ProbingSchToPcb = false;
221 m_ShowSearch = false;
222 m_ShowNetInspector = false;
223 // Ensure timer has an owner before binding so it generates events.
224 m_crossProbeFlashTimer.SetOwner( this );
225 Bind( wxEVT_TIMER, &PCB_EDIT_FRAME::OnCrossProbeFlashTimer, this, m_crossProbeFlashTimer.GetId() );
226
227 // We don't know what state board was in when it was last saved, so we have to
228 // assume dirty
229 m_ZoneFillsDirty = true;
230
231 m_aboutTitle = _HKI( "KiCad PCB Editor" );
232
233 // Must be created before the menus are created.
234 if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist )
235 {
236 m_exportNetlistAction = new TOOL_ACTION( "pcbnew.EditorControl.exportNetlist",
237 AS_GLOBAL, 0, "", _( "Netlist..." ),
238 _( "Export netlist used to update schematics" ) );
239 }
240
241 // Create GAL canvas
242 auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
243 GetGalDisplayOptions(),
245
246 SetCanvas( canvas );
247 SetBoard( new BOARD() );
248
249 wxIcon icon;
250 wxIconBundle icon_bundle;
251
252 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 48 ) );
253 icon_bundle.AddIcon( icon );
254 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 128 ) );
255 icon_bundle.AddIcon( icon );
256 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 256 ) );
257 icon_bundle.AddIcon( icon );
258 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_32 ) );
259 icon_bundle.AddIcon( icon );
260 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_16 ) );
261 icon_bundle.AddIcon( icon );
262
263 SetIcons( icon_bundle );
264
265 // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
266 // initialize parameters in m_LayersManager
267 LoadSettings( config() );
268
269 SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ) ) );
270
271 // PCB drawings start in the upper left corner.
272 GetScreen()->m_Center = false;
273
274 setupTools();
275 setupUIConditions();
276
277 m_toolbarSettings = GetToolbarSettings<PCB_EDIT_TOOLBAR_SETTINGS>( "pcbnew-toolbars" );
278 configureToolbars();
279 RecreateToolbars();
280 PrepareLayerIndicator( true );
281
282 ReCreateMenuBar();
283
286
287 // Fetch a COPY of the config as a lot of these initializations are going to overwrite our
288 // data.
289 PCBNEW_SETTINGS::AUI_PANELS aui_cfg = GetPcbNewSettings()->m_AuiPanels;
290
291 m_propertiesPanel = new PCB_PROPERTIES_PANEL( this, this );
292 m_propertiesPanel->SetSplitterProportion( aui_cfg.properties_splitter );
293
294 m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
295
296 m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
297 m_searchPane = new PCB_SEARCH_PANE( this );
298 m_netInspectorPanel = new PCB_NET_INSPECTOR_PANEL( this, this );
299 m_designBlocksPane = new PCB_DESIGN_BLOCK_PANE( this, nullptr, m_designBlockHistoryList );
300
301 m_auimgr.SetManagedWindow( this );
302
303 CreateInfoBar();
304
305 // Secondary infobar stacked above the main one. Load-time notices (such as
306 // the WRL -> STEP migration prompt) belong here so they aren't clobbered by
307 // the main infobar's read-only warnings, DRC rule errors, etc.
308#if defined( __WXOSX_MAC__ )
309 m_loadNoticeInfoBar = new WX_INFOBAR( GetToolCanvas() );
310#else
311 m_loadNoticeInfoBar = new WX_INFOBAR( this, &m_auimgr );
312 m_auimgr.AddPane( m_loadNoticeInfoBar,
313 EDA_PANE().InfoBar().Name( wxS( "LoadNoticeInfoBar" ) ).Top().Layer( 1 )
314 .Row( 1 ) );
315#endif
316
317 unsigned int auiFlags = wxAUI_MGR_DEFAULT;
318#if !defined( _WIN32 )
319 // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
320 // of graphical glitches.
321 auiFlags |= wxAUI_MGR_LIVE_RESIZE;
322#endif
323 m_auimgr.SetFlags( auiFlags );
324
325 // Rows; layers 4 - 6
326 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( wxS( "TopMainToolbar" ) )
327 .Top().Layer( 6 ) );
328 m_auimgr.AddPane( m_tbTopAux, EDA_PANE().HToolbar().Name( wxS( "TopAuxToolbar" ) )
329 .Top().Layer( 5 ) );
330 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
331 .Bottom().Layer( 6 ) );
332
333 // Columns; layers 1 - 3
334 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( wxS( "LeftToolbar" ) )
335 .Left().Layer( 3 ) );
336
337 m_auimgr.AddPane( m_tbRight, EDA_PANE().VToolbar().Name( wxS( "RightToolbar" ) )
338 .Right().Layer( 3 ) );
339
340 m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( wxS( "LayersManager" ) )
341 .Right().Layer( 4 )
342 .Caption( _( "Appearance" ) ).PaneBorder( false )
343 // Don't use -1 for don't-change-height on a growable panel; it has side-effects.
344 .MinSize( m_appearancePanel->GetMinSize().x, FromDIP( 60 ) )
345#ifdef __WXMAC__
346 // Best size for this pane is calculated larger than necessary on wxMac
347 .BestSize( m_appearancePanel->GetMinSize().x, -1 )
348#else
349 .BestSize( m_appearancePanel->GetBestSize().x, -1 )
350#endif
351 .FloatingSize( m_appearancePanel->GetBestSize() )
352 .CloseButton( false ) );
353
354 m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Name( wxS( "SelectionFilter" ) )
355 .Right().Layer( 4 ).Position( 2 )
356 .Caption( _( "Selection Filter" ) ).PaneBorder( false )
357 // Fixed-size pane; -1 for MinSize height is required
358 .MinSize( m_selectionFilterPanel->GetMinSize().x, -1 )
359 .BestSize( m_selectionFilterPanel->GetBestSize().x, -1 )
360 .FloatingSize( m_selectionFilterPanel->GetBestSize() )
361 .CloseButton( false ) );
362
363 m_auimgr.AddPane( m_designBlocksPane, EDA_PANE().Name( DesignBlocksPaneName() )
364 .Right().Layer( 5 )
365 .Caption( _( "Design Blocks" ) )
366 .CaptionVisible( true )
367 .PaneBorder( true )
368 .TopDockable( false )
369 .BottomDockable( false )
370 .CloseButton( true )
371 .MinSize( FromDIP( wxSize( 240, 60 ) ) )
372 .BestSize( FromDIP( wxSize( 300, 200 ) ) )
373 .FloatingSize( FromDIP( wxSize( 800, 600 ) ) )
374 .FloatingPosition( FromDIP( wxPoint( 50, 200 ) ) )
375 .Show( true ) );
376
377 m_auimgr.AddPane( m_propertiesPanel, EDA_PANE().Name( PropertiesPaneName() )
378 .Left().Layer( 5 )
379 .Caption( _( "Properties" ) ).PaneBorder( false )
380 .MinSize( FromDIP( wxSize( 240, 60 ) ) )
381 .BestSize( FromDIP( wxSize( 300, 200 ) ) )
382 .FloatingSize( wxSize( 300, 200 ) )
383 .CloseButton( true ) );
384
385 // Center
386 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
387 .Center() );
388
389 m_auimgr.AddPane( m_netInspectorPanel, EDA_PANE().Name( NetInspectorPanelName() )
390 .Bottom()
391 .Caption( _( "Net Inspector" ) )
392 .PaneBorder( false )
393 .MinSize( FromDIP( wxSize( 240, 60 ) ) )
394 .BestSize( FromDIP( wxSize( 300, 200 ) ) )
395 .FloatingSize( wxSize( 300, 200 ) )
396 .CloseButton( true ) );
397
398 m_auimgr.AddPane( m_searchPane, EDA_PANE().Name( SearchPaneName() )
399 .Bottom()
400 .Caption( _( "Search" ) ).PaneBorder( false )
401 .MinSize( FromDIP( wxSize ( 180, 60 ) ) )
402 .BestSize( FromDIP( wxSize ( 180, 100 ) ) )
403 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
404 .DestroyOnClose( false )
405 .CloseButton( true ) );
406
407 RestoreAuiLayout();
408
409 m_auimgr.GetPane( "LayersManager" ).Show( m_ShowLayerManagerTools );
410 m_auimgr.GetPane( "SelectionFilter" ).Show( m_ShowLayerManagerTools );
411 m_auimgr.GetPane( PropertiesPaneName() ).Show( GetPcbNewSettings()->m_AuiPanels.show_properties );
412 m_auimgr.GetPane( NetInspectorPanelName() ).Show( m_ShowNetInspector );
413 m_auimgr.GetPane( SearchPaneName() ).Show( m_ShowSearch );
414 m_auimgr.GetPane( DesignBlocksPaneName() ).Show( GetPcbNewSettings()->m_AuiPanels.design_blocks_show );
415
416 // The selection filter doesn't need to grow in the vertical direction when docked
417 m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
418 FinishAUIInitialization();
419
420 // FinishAUIInitialization only hides the primary "InfoBar" pane; the
421 // stacked load-notice bar has to be hidden explicitly.
422#if !defined( __WXOSX_MAC__ )
423 if( wxAuiPaneInfo& pane = m_auimgr.GetPane( wxS( "LoadNoticeInfoBar" ) ); pane.IsOk() )
424 {
425 pane.Hide();
426 m_auimgr.Update();
427 }
428#endif
429
430 if( aui_cfg.right_panel_width > 0 )
431 {
432 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( wxS( "LayersManager" ) );
433 SetAuiPaneSize( m_auimgr, layersManager, aui_cfg.right_panel_width, -1 );
434
435 wxAuiPaneInfo& designBlocksPane = m_auimgr.GetPane( DesignBlocksPaneName() );
436 SetAuiPaneSize( m_auimgr, designBlocksPane, aui_cfg.design_blocks_panel_docked_width, -1 );
437 }
438
439 if( aui_cfg.properties_panel_width > 0 && m_propertiesPanel )
440 {
441 wxAuiPaneInfo& propertiesPanel = m_auimgr.GetPane( PropertiesPaneName() );
442 SetAuiPaneSize( m_auimgr, propertiesPanel, aui_cfg.properties_panel_width, -1 );
443 }
444
445 if( aui_cfg.search_panel_height > 0
446 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_TOP
447 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
448 {
449 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
450 searchPane.Direction( aui_cfg.search_panel_dock_direction );
451 SetAuiPaneSize( m_auimgr, searchPane, -1, aui_cfg.search_panel_height );
452 }
453 else if( aui_cfg.search_panel_width > 0
454 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_LEFT
455 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
456 {
457 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
458 searchPane.Direction( aui_cfg.search_panel_dock_direction );
459 SetAuiPaneSize( m_auimgr, searchPane, aui_cfg.search_panel_width, -1 );
460 }
461
462 m_appearancePanel->SetTabIndex( aui_cfg.appearance_panel_tab );
463
464 {
465 m_layerPairSettings = std::make_unique<LAYER_PAIR_SETTINGS>();
466
467 m_layerPairSettings->Bind( PCB_LAYER_PAIR_PRESETS_CHANGED, [&]( wxCommandEvent& aEvt )
468 {
469 // Update the project file list
470 std::span<const LAYER_PAIR_INFO> newPairInfos = m_layerPairSettings->GetLayerPairs();
472 std::vector<LAYER_PAIR_INFO>{ newPairInfos.begin(), newPairInfos.end() };
473 });
474
475 m_layerPairSettings->Bind( PCB_CURRENT_LAYER_PAIR_CHANGED, [&]( wxCommandEvent& aEvt )
476 {
477 const LAYER_PAIR& layerPair = m_layerPairSettings->GetCurrentLayerPair();
478 PCB_SCREEN& screen = *GetScreen();
479
480 screen.m_Route_Layer_TOP = layerPair.GetLayerA();
481 screen.m_Route_Layer_BOTTOM = layerPair.GetLayerB();
482
483 // Update the toolbar icon
484 PrepareLayerIndicator();
485 });
486 }
487
488 GetToolManager()->PostAction( ACTIONS::zoomFitScreen );
489
490 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
491 // to calculate the wrong zoom size. See PCB_EDIT_FRAME::onSize().
492 Bind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
493
494 Bind( wxEVT_IDLE,
495 [this]( wxIdleEvent& aEvent )
496 {
497 BOX2D viewport = GetCanvas()->GetView()->GetViewport();
498
499 if( viewport != m_lastNetnamesViewport )
500 {
501 redrawNetnames();
502 m_lastNetnamesViewport = viewport;
503 }
504
505 // Do not forget to pass the Idle event to other clients:
506 aEvent.Skip();
507 } );
508
509 resolveCanvasType();
510
511 setupUnits( config() );
512
513 // Ensure the DRC engine is initialized so that constraints can be resolved even before a
514 // board is loaded or saved
515 try
516 {
517 m_toolManager->GetTool<DRC_TOOL>()->GetDRCEngine()->InitEngine( wxFileName() );
518 }
519 catch( PARSE_ERROR& )
520 {
521 }
522
523 // Sync action plugins in case they changed since the last time the frame opened
524 GetToolManager()->RunAction( ACTIONS::pluginsReload );
525
526 m_apiHandler = std::make_unique<API_HANDLER_PCB>( this );
527 Pgm().GetApiServer().RegisterHandler( m_apiHandler.get() );
528
529 if( Kiface().IsSingle() )
530 {
531 m_apiHandlerCommon = std::make_unique<API_HANDLER_COMMON>();
532 Pgm().GetApiServer().RegisterHandler( m_apiHandlerCommon.get() );
533 }
534
535 GetCanvas()->SwitchBackend( m_canvasType );
536 ActivateGalCanvas();
537
538 // Default shutdown reason until a file is loaded
539 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New PCB file is unsaved" ) );
540
541 // disable Export STEP item if kicad2step does not exist
542 wxString strK2S = Pgm().GetExecutablePath();
543
544#ifdef __WXMAC__
545 if( strK2S.Find( wxT( "pcbnew.app" ) ) != wxNOT_FOUND )
546 {
547 // On macOS, we have standalone applications inside the main bundle, so we handle that here:
548 strK2S += wxT( "../../" );
549 }
550
551 strK2S += wxT( "Contents/MacOS/" );
552#endif
553
554 wxFileName appK2S( strK2S, wxT( "kicad2step" ) );
555
556#ifdef _WIN32
557 appK2S.SetExt( wxT( "exe" ) );
558#endif
559
560 // Ensure the window is on top
561 Raise();
562
563// if( !appK2S.FileExists() )
564 // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
565
566 // AUI doesn't refresh properly on wxMac after changes in eb7dc6dd, so force it to
567#ifdef __WXMAC__
568 if( Kiface().IsSingle() )
569 {
570 CallAfter( [this]()
571 {
572 m_appearancePanel->OnBoardChanged();
573 } );
574 }
575#endif
576
577 // Register a call to update the toolbar sizes. It can't be done immediately because
578 // it seems to require some sizes calculated that aren't yet (at least on GTK).
579 CallAfter( [this]()
580 {
581 // Ensure the controls on the toolbars all are correctly sized
582 UpdateToolbarControlSizes();
583
584 // Update the angle snap mode toolbar button to reflect the current preference
585 GetToolManager()->RunAction( PCB_ACTIONS::angleSnapModeChanged );
586 } );
587
588 if( ADVANCED_CFG::GetCfg().m_ShowEventCounters )
589 {
590 m_eventCounterTimer = new wxTimer( this );
591
592 Bind( wxEVT_TIMER,
593 [&]( wxTimerEvent& aEvent )
594 {
595 GetCanvas()->m_PaintEventCounter->Show();
596 GetCanvas()->m_PaintEventCounter->Reset();
597
599 static_cast<KIGFX::WX_VIEW_CONTROLS*>( GetCanvas()->GetViewControls() );
602
603 },
604 m_eventCounterTimer->GetId() );
605
606 m_eventCounterTimer->Start( 1000 );
607 }
608
611 m_acceptedExts.emplace( wxS( "dxf" ), &PCB_ACTIONS::ddImportGraphics );
613 DragAcceptFiles( true );
614
615 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &PCB_EDIT_FRAME::onCloseModelessBookReporterDialogs, this );
616}
617
618
619void PCB_EDIT_FRAME::StartCrossProbeFlash( const std::vector<BOARD_ITEM*>& aItems )
620{
621 if( !GetPcbNewSettings()->m_CrossProbing.flash_selection )
622 {
623 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash(PCB): aborted (setting disabled) items=%zu",
624 aItems.size() );
625 return;
626 }
627
628 if( aItems.empty() )
629 {
630 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash(PCB): aborted (no items)" );
631 return;
632 }
633
634 // Don't start flashing if any of the items are being moved. The flash timer toggles
635 // selection hide/show which corrupts the VIEW overlay state during an active move.
636 for( const BOARD_ITEM* item : aItems )
637 {
638 if( item->IsMoving() )
639 {
640 wxLogTrace( traceCrossProbeFlash,
641 "StartCrossProbeFlash(PCB): aborted (items are moving)" );
642 return;
643 }
644 }
645
647 {
648 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash(PCB): restarting existing flash (phase=%d)",
651 }
652
653 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash(PCB): starting with %zu items", aItems.size() );
654
655 // Store uuids
657 for( BOARD_ITEM* it : aItems )
658 m_crossProbeFlashItems.push_back( it->m_Uuid );
659
662
663 if( !m_crossProbeFlashTimer.GetOwner() )
664 m_crossProbeFlashTimer.SetOwner( this );
665
666 bool started = m_crossProbeFlashTimer.Start( 500, wxTIMER_CONTINUOUS ); // 0.5s intervals -> 3s total for 6 phases
667 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash(PCB): timer start=%d id=%d",
668 (int) started, m_crossProbeFlashTimer.GetId() );
669}
670
671
672void PCB_EDIT_FRAME::OnCrossProbeFlashTimer( wxTimerEvent& aEvent )
673{
674 wxLogTrace( traceCrossProbeFlash, "Timer(PCB) fired: phase=%d running=%d items=%zu",
676
678 {
679 wxLogTrace( traceCrossProbeFlash, "Timer(PCB) fired but not flashing (ignored)" );
680 return;
681 }
682
684
685 if( !selTool )
686 return;
687
688 // Don't manipulate the selection while items are being moved. The move tool holds a
689 // live reference to the selection and toggling hide/show on selected items corrupts
690 // the VIEW overlay state, causing crashes.
691 for( const KIID& id : m_crossProbeFlashItems )
692 {
693 if( EDA_ITEM* item = GetBoard()->ResolveItem( id, true ) )
694 {
695 if( item->IsMoving() )
696 {
697 wxLogTrace( traceCrossProbeFlash,
698 "Timer(PCB) phase=%d: items are moving, stopping flash",
700 m_crossProbeFlashing = false;
702 return;
703 }
704 }
705 }
706
707 // Prevent recursion / IPC during flashing
708 bool prevGuard = m_ProbingSchToPcb;
709 m_ProbingSchToPcb = true;
710
711 if( m_crossProbeFlashPhase % 2 == 0 )
712 {
713 // Hide selection
714 selTool->ClearSelection( true );
715 wxLogTrace( traceCrossProbeFlash, "Phase %d (PCB): cleared selection", m_crossProbeFlashPhase );
716 }
717 else
718 {
719 // Restore selection
720 for( const KIID& id : m_crossProbeFlashItems )
721 {
722 if( EDA_ITEM* item = GetBoard()->ResolveItem( id, true ) )
723 selTool->AddItemToSel( item, true );
724 }
725
726 wxLogTrace( traceCrossProbeFlash, "Phase %d (PCB): restored %zu items",
728 }
729
730 // Force a redraw even if the canvas / frame does not currently have focus (mouse elsewhere)
731 if( GetCanvas() )
732 {
734 wxLogTrace( traceCrossProbeFlash, "Phase %d (PCB): forced canvas refresh",
736 }
737
738 m_ProbingSchToPcb = prevGuard;
739
741
742 if( m_crossProbeFlashPhase > 6 )
743 {
744 // Ensure final state (selected)
745 for( const KIID& id : m_crossProbeFlashItems )
746 {
747 if( EDA_ITEM* item = GetBoard()->ResolveItem( id, true ) )
748 selTool->AddItemToSel( item, true );
749 }
750
751 m_crossProbeFlashing = false;
753
754 wxLogTrace( traceCrossProbeFlash, "Flashing complete (PCB). Final selection size=%zu",
755 m_crossProbeFlashItems.size() );
756 }
757}
758
759
761{
762 // PCB_BASE_FRAME's dtor deletes m_pcb; canvas children outlive it. Drop
763 // every cached TEXT_VAR_TRACKER* before the tracker is freed.
765
766 if( ADVANCED_CFG::GetCfg().m_ShowEventCounters )
767 {
768 // Stop the timer during destruction early to avoid potential event race conditions (that
769 // do happen on windows)
770 m_eventCounterTimer->Stop();
771 delete m_eventCounterTimer;
772 }
773
774 // Close modeless dialogs
775 wxWindow* drcDlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
776
777 if( drcDlg )
778 drcDlg->Close( true );
779
780 wxWindow* ruleEditorDlg = wxWindow::FindWindowByName( DIALOG_DRC_RULE_EDITOR_WINDOW_NAME );
781
782 if( ruleEditorDlg )
783 ruleEditorDlg->Close( true );
784
785 // Shutdown all running tools
786 if( m_toolManager )
787 m_toolManager->ShutdownAllTools();
788
789 if( GetBoard() )
791
792 // We passed ownership of these to wxAuiManager.
793 // delete m_selectionFilterPanel;
794 // delete m_appearancePanel;
795 // delete m_propertiesPanel;
796 // delete m_netInspectorPanel;
797
799}
800
801
803{
804 if( GetCanvas() )
805 {
806 if( DS_PROXY_VIEW_ITEM* sheet = GetCanvas()->GetDrawingSheet() )
807 sheet->AttachToTracker( nullptr );
808 }
809
811 {
812 m_textVarListenerTracker->RemoveInvalidateListener( m_textVarListenerHandle );
814 m_textVarListenerTracker = nullptr;
815 }
816}
817
818
819void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard, bool aBuildConnectivity, PROGRESS_REPORTER* aReporter )
820{
821 // PCB_BASE_FRAME::SetBoard() deletes m_pcb; detach tracker consumers first.
822 if( m_pcb )
823 {
825 m_pcb->ClearProject();
827 }
828
829 PCB_BASE_EDIT_FRAME::SetBoard( aBoard, aReporter );
830
831 aBoard->SetProject( &Prj() );
832
833 if( aBuildConnectivity )
834 aBoard->BuildConnectivity();
835
836 // reload the drawing-sheet
837 SetPageSettings( aBoard->GetPageSettings() );
838
840}
841
842
847
848
849std::unique_ptr<GRID_HELPER> PCB_EDIT_FRAME::MakeGridHelper()
850{
851 return std::make_unique<PCB_GRID_HELPER>( m_toolManager, GetMagneticItemsSettings() );
852}
853
854
856{
857 /*
858 * While new items being scrolled into the view will get painted, they will only get
859 * annotated with netname instances currently within the view. Subsequent panning will not
860 * draw newly-visible netname instances because the item has already been drawn.
861 *
862 * This routine, fired on idle if the viewport has changed, looks for visible items that
863 * might have multiple netname instances and redraws them. (It does not need to handle pads
864 * and vias because they only ever have a single netname instance drawn on them.)
865 */
866 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
867
868 if( !cfg || cfg->m_Display.m_NetNames < 2 )
869 return;
870
871 KIGFX::VIEW* view = GetCanvas()->GetView();
872 BOX2D viewport = view->GetViewport();
873
874 // Inflate to catch most of the track width
875 BOX2I_MINMAX clipbox( BOX2ISafe( viewport.Inflate( pcbIUScale.mmToIU( 2.0 ) ) ) );
876
877 for( PCB_TRACK* track : GetBoard()->Tracks() )
878 {
879 // Don't need to update vias
880 if( track->Type() == PCB_VIA_T )
881 continue;
882
883 // Don't update invisible tracks
884 if( !clipbox.Intersects( BOX2I_MINMAX( track->GetStart(), track->GetEnd() ) ) )
885 continue;
886
887 if( track->ViewGetLOD( GetNetnameLayer( track->GetLayer() ), view ) < view->GetScale() )
888 view->Update( track, KIGFX::REPAINT );
889 }
890}
891
892
893void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
894{
895 PCB_BASE_FRAME::SetPageSettings( aPageSettings );
896
897 // Prepare drawing-sheet template
899 &m_pcb->GetPageSettings(),
900 m_pcb->GetProject(),
901 &m_pcb->GetTitleBlock(),
902 &m_pcb->GetProperties() );
903
904 drawingSheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
905 drawingSheet->SetSheetPath( std::string( GetFullScreenDesc().mb_str() ) );
906
907 // A board is not like a schematic having a main page and sub sheets.
908 // So for the drawing sheet, use only the first page option to display items
909 drawingSheet->SetIsFirstPage( true );
910
911 BASE_SCREEN* screen = GetScreen();
912
913 if( screen != nullptr )
914 {
915 drawingSheet->SetPageNumber(TO_UTF8( screen->GetPageNumber() ) );
916 drawingSheet->SetSheetCount( screen->GetPageCount() );
917 }
918
919 if( BOARD* board = GetBoard() )
920 {
921 drawingSheet->SetFileName( TO_UTF8( board->GetFileName() ) );
922 wxString currentVariant = board->GetCurrentVariant();
923 wxString variantDesc = board->GetVariantDescription( currentVariant );
924 drawingSheet->SetVariantName( TO_UTF8( currentVariant ) );
925 drawingSheet->SetVariantDesc( TO_UTF8( variantDesc ) );
926 }
927
928 // PCB_DRAW_PANEL_GAL takes ownership of the drawing-sheet
929 GetCanvas()->SetDrawingSheet( drawingSheet );
930
931 // Reactive title-block repaint: register the proxy with the BOARD's
932 // text-var tracker so source changes fan out to a repaint. The one-time
933 // listener installation is idempotent; calling AddInvalidateListener
934 // here each time would accumulate stale listeners across SetPageSettings
935 // calls, which is why the listener check below is guarded.
936 if( BOARD* board = GetBoard() )
937 {
938 if( BOARD_TEXT_VAR_ADAPTER* adapter = board->GetTextVarAdapter() )
939 {
940 TEXT_VAR_TRACKER* tracker = &adapter->Tracker();
941
942 drawingSheet->AttachToTracker( tracker );
943
944 // Project reload / board swap can point GetBoard() at a new
945 // tracker; detach from the previous one first so we don't leak
946 // a stale lambda that still captures `this`.
947 if( m_textVarListenerTracker != tracker
949 {
950 m_textVarListenerTracker->RemoveInvalidateListener( m_textVarListenerHandle );
952 m_textVarListenerTracker = nullptr;
953 }
954
956 {
957 KIGFX::VIEW* view = GetCanvas()->GetView();
958 m_textVarListenerTracker = tracker;
960 [this, view]( EDA_ITEM* aDep, const TEXT_VAR_REF_KEY& )
961 {
962 if( !aDep )
963 return;
964
966
967 if( aDep == current )
968 {
969 view->Update( current, KIGFX::REPAINT );
970 return;
971 }
972
973 if( aDep->IsBOARD_ITEM() )
974 view->Update( aDep, KIGFX::REPAINT );
975 } );
976 }
977 }
978 }
979}
980
981
983{
984 return GetScreen() && GetScreen()->IsContentModified();
985}
986
987
989{
990 return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
991}
992
993
995{
996 // Create the manager and dispatcher & route draw panel events to the dispatcher
998 m_toolManager->SetEnvironment( m_pcb, GetCanvas()->GetView(),
999 GetCanvas()->GetViewControls(), config(), this );
1000 m_actions = new PCB_ACTIONS();
1002
1003 // Register tools
1004 m_toolManager->RegisterTool( new COMMON_CONTROL );
1005 m_toolManager->RegisterTool( new COMMON_TOOLS );
1006 m_toolManager->RegisterTool( new PCB_SELECTION_TOOL );
1007 m_toolManager->RegisterTool( new ZOOM_TOOL );
1008 m_toolManager->RegisterTool( new PCB_PICKER_TOOL );
1009 m_toolManager->RegisterTool( new ROUTER_TOOL );
1010 m_toolManager->RegisterTool( new EDIT_TOOL );
1011 m_toolManager->RegisterTool( new PCB_EDIT_TABLE_TOOL );
1012 m_toolManager->RegisterTool( new GLOBAL_EDIT_TOOL );
1013 m_toolManager->RegisterTool( new PAD_TOOL );
1014 m_toolManager->RegisterTool( new DRAWING_TOOL );
1015 m_toolManager->RegisterTool( new PCB_POINT_EDITOR );
1016 m_toolManager->RegisterTool( new PCB_CONTROL );
1017 m_toolManager->RegisterTool( new PCB_DESIGN_BLOCK_CONTROL );
1018 m_toolManager->RegisterTool( new BOARD_EDITOR_CONTROL );
1019 m_toolManager->RegisterTool( new BOARD_INSPECTION_TOOL );
1020 m_toolManager->RegisterTool( new BOARD_REANNOTATE_TOOL );
1021 m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
1022 m_toolManager->RegisterTool( new MICROWAVE_TOOL );
1023 m_toolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
1024 m_toolManager->RegisterTool( new ARRAY_TOOL );
1025 m_toolManager->RegisterTool( new ZONE_FILLER_TOOL );
1026 m_toolManager->RegisterTool( new AUTOPLACE_TOOL );
1027 m_toolManager->RegisterTool( new DRC_TOOL );
1028 m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS );
1029 m_toolManager->RegisterTool( new CONVERT_TOOL );
1030 m_toolManager->RegisterTool( new PCB_GROUP_TOOL );
1031 m_toolManager->RegisterTool( new GENERATOR_TOOL );
1032 m_toolManager->RegisterTool( new PROPERTIES_TOOL );
1033 m_toolManager->RegisterTool( new MULTICHANNEL_TOOL );
1034 m_toolManager->RegisterTool( new EMBED_TOOL );
1035 m_toolManager->RegisterTool( new DRC_RULE_EDITOR_TOOL );
1036 m_toolManager->RegisterTool( new DIFF_PHASE_SKEW_TOOL );
1037 m_toolManager->InitTools();
1038
1039 for( TOOL_BASE* tool : m_toolManager->Tools() )
1040 {
1041 if( PCB_TOOL_BASE* pcbTool = dynamic_cast<PCB_TOOL_BASE*>( tool ) )
1042 pcbTool->SetIsBoardEditor( true );
1043 }
1044
1045 // Run the selection tool, it is supposed to be always active
1046 m_toolManager->InvokeTool( "common.InteractiveSelection" );
1047}
1048
1049
1051{
1053
1054 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
1055 PCB_EDITOR_CONDITIONS cond( this );
1056
1057 auto undoCond =
1058 [ this ] (const SELECTION& aSel )
1059 {
1060 DRAWING_TOOL* drawingTool = m_toolManager->GetTool<DRAWING_TOOL>();
1061
1062 if( drawingTool && drawingTool->GetDrawingMode() != DRAWING_TOOL::MODE::NONE )
1063 return true;
1064
1065 ROUTER_TOOL* routerTool = m_toolManager->GetTool<ROUTER_TOOL>();
1066
1067 if( routerTool && routerTool->RoutingInProgress() )
1068 return true;
1069
1070 return GetUndoCommandCount() > 0;
1071 };
1072
1073 auto groupWithDesignBlockLink =
1074 [] ( const SELECTION& aSel )
1075 {
1076 if( aSel.Size() != 1 )
1077 return false;
1078
1079 if( aSel[0]->Type() != PCB_GROUP_T )
1080 return false;
1081
1082 PCB_GROUP* group = static_cast<PCB_GROUP*>( aSel.GetItem( 0 ) );
1083
1084 return group->HasDesignBlockLink();
1085 };
1086
1087 wxASSERT( mgr );
1088
1089#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1090#define CHECK( x ) ACTION_CONDITIONS().Check( x )
1091// clang-format off
1092
1094 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
1096
1100
1101 mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
1102 mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
1109
1110 // Keep immediate-mode dispatch alive while a tool is mid-edit on an empty board, where
1111 // HasItems() is still false but an item is under construction under the cursor.
1112 auto hasElements =
1113 [ this ] ( const SELECTION& aSel )
1114 {
1115 return GetBoard() &&
1116 ( !GetBoard()->IsEmpty() || !SELECTION_CONDITIONS::Idle( aSel ) );
1117 };
1118
1120 ENABLE( SELECTION_CONDITIONS::NotEmpty ).HotkeyEnable( hasElements ) );
1122 ENABLE( SELECTION_CONDITIONS::NotEmpty ).HotkeyEnable( hasElements ) );
1124 ENABLE( SELECTION_CONDITIONS::NotEmpty ).HotkeyEnable( hasElements ) );
1126 ENABLE( SELECTION_CONDITIONS::NotEmpty ).HotkeyEnable( hasElements ) );
1127
1128 static const std::vector<KICAD_T> groupTypes = { PCB_GROUP_T, PCB_GENERATOR_T };
1129
1134
1135 mgr->SetConditions( PCB_ACTIONS::placeLinkedDesignBlock, ENABLE( groupWithDesignBlockLink) );
1136 mgr->SetConditions( PCB_ACTIONS::saveToLinkedDesignBlock, ENABLE( groupWithDesignBlockLink) );
1137
1143
1144 auto enableZoneControlCondition =
1145 [this] ( const SELECTION& )
1146 {
1149 };
1150
1152 ENABLE( enableZoneControlCondition )
1155 ENABLE( enableZoneControlCondition )
1158 ENABLE( enableZoneControlCondition )
1161 ENABLE( enableZoneControlCondition )
1163
1165
1166 auto boardFlippedCond =
1167 [this]( const SELECTION& )
1168 {
1170 };
1171
1172 auto layerManagerCond =
1173 [this] ( const SELECTION& )
1174 {
1175 return LayerManagerShown();
1176 };
1177
1178 auto propertiesCond =
1179 [this] ( const SELECTION& )
1180 {
1181 return PropertiesShown();
1182 };
1183
1184 auto netInspectorCond =
1185 [this] ( const SELECTION& )
1186 {
1187 return NetInspectorShown();
1188 };
1189
1190 auto searchPaneCond =
1191 [this] ( const SELECTION& )
1192 {
1193 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
1194 };
1195
1196 auto designBlockCond =
1197 [ this ] (const SELECTION& aSel )
1198 {
1199 return m_auimgr.GetPane( DesignBlocksPaneName() ).IsShown();
1200 };
1201
1202 auto highContrastCond =
1203 [this] ( const SELECTION& )
1204 {
1206 };
1207
1208 auto globalRatsnestCond =
1209 [this] (const SELECTION& )
1210 {
1212 return cfg && cfg->m_Display.m_ShowGlobalRatsnest;
1213 };
1214
1215 auto curvedRatsnestCond =
1216 [this] (const SELECTION& )
1217 {
1219 return cfg && cfg->m_Display.m_DisplayRatsnestLinesCurved;
1220 };
1221
1222 auto netHighlightCond =
1223 [this]( const SELECTION& )
1224 {
1225 if( auto* canvas = GetCanvas() )
1226 {
1227 if( auto* view = canvas->GetView() )
1228 {
1229 if( auto* painter = view->GetPainter() )
1230 {
1231 if( auto* settings = painter->GetSettings() )
1232 return !settings->GetHighlightNetCodes().empty();
1233 }
1234 }
1235 }
1236
1237 return false;
1238 };
1239
1240 auto enableNetHighlightCond =
1241 [this]( const SELECTION& )
1242 {
1244 return tool && tool->IsNetHighlightSet();
1245 };
1246
1247 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
1248 mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
1249 mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
1250 mgr->SetConditions( PCB_ACTIONS::showRatsnest, CHECK( globalRatsnestCond ) );
1251 mgr->SetConditions( PCB_ACTIONS::ratsnestLineMode, CHECK( curvedRatsnestCond ) );
1252 mgr->SetConditions( PCB_ACTIONS::toggleNetHighlight, CHECK( netHighlightCond )
1253 .Enable( enableNetHighlightCond ) );
1254 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
1255 mgr->SetConditions( PCB_ACTIONS::showNetInspector, CHECK( netInspectorCond ) );
1256 mgr->SetConditions( PCB_ACTIONS::showSearch, CHECK( searchPaneCond ) );
1257 mgr->SetConditions( PCB_ACTIONS::showDesignBlockPanel, CHECK( designBlockCond ) );
1258
1261
1262 const auto isArcKeepCenterMode =
1263 [this]( const SELECTION& )
1264 {
1267 };
1268
1269 const auto isArcKeepEndpointMode =
1270 [this]( const SELECTION& )
1271 {
1274 };
1275
1276 const auto isArcKeepRadiusMode =
1277 [this]( const SELECTION& )
1278 {
1281 };
1282
1283 mgr->SetConditions( ACTIONS::pointEditorArcKeepCenter, CHECK( isArcKeepCenterMode ) );
1284 mgr->SetConditions( ACTIONS::pointEditorArcKeepEndpoint, CHECK( isArcKeepEndpointMode ) );
1285 mgr->SetConditions( ACTIONS::pointEditorArcKeepRadius, CHECK( isArcKeepRadiusMode ) );
1286
1287 auto isHighlightMode =
1288 [this]( const SELECTION& )
1289 {
1290 ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
1291 return tool && tool->GetRouterMode() == PNS::RM_MarkObstacles;
1292 };
1293
1294 auto isShoveMode =
1295 [this]( const SELECTION& )
1296 {
1297 ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
1298 return tool && tool->GetRouterMode() == PNS::RM_Shove;
1299 };
1300
1301 auto isWalkaroundMode =
1302 [this]( const SELECTION& )
1303 {
1304 ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
1305 return tool && tool->GetRouterMode() == PNS::RM_Walkaround;
1306 };
1307
1308 mgr->SetConditions( PCB_ACTIONS::routerHighlightMode, CHECK( isHighlightMode ) );
1309 mgr->SetConditions( PCB_ACTIONS::routerShoveMode, CHECK( isShoveMode ) );
1310 mgr->SetConditions( PCB_ACTIONS::routerWalkaroundMode, CHECK( isWalkaroundMode ) );
1311
1312 auto isAutoTrackWidth =
1313 [this]( const SELECTION& )
1314 {
1316 };
1317
1318 mgr->SetConditions( PCB_ACTIONS::autoTrackWidth, CHECK( isAutoTrackWidth ) );
1319
1320 auto haveNetCond =
1321 [] ( const SELECTION& aSel )
1322 {
1323 for( EDA_ITEM* item : aSel )
1324 {
1325 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
1326 {
1327 if( bci->GetNetCode() > 0 )
1328 return true;
1329 }
1330 }
1331
1332 return false;
1333 };
1334
1335 auto connectedOrFootprintCond =
1336 [] ( const SELECTION& aSel )
1337 {
1338 if( aSel.Empty() )
1339 return false;
1340
1341 for( EDA_ITEM* item : aSel )
1342 {
1343 if( item->Type() == PCB_FOOTPRINT_T )
1344 continue;
1345
1346 if( !dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
1347 return false;
1348 }
1349
1350 return true;
1351 };
1352
1353 mgr->SetConditions( PCB_ACTIONS::showNetInRatsnest, ENABLE( haveNetCond ) );
1354 mgr->SetConditions( PCB_ACTIONS::hideNetInRatsnest, ENABLE( haveNetCond ) );
1357
1358 static const std::vector<KICAD_T> trackTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T };
1359 static const std::vector<KICAD_T> padOwnerTypes = { PCB_FOOTPRINT_T, PCB_PAD_T };
1360 static const std::vector<KICAD_T> footprintTypes = { PCB_FOOTPRINT_T };
1361 static const std::vector<KICAD_T> crossProbeTypes = { PCB_PAD_T, PCB_FOOTPRINT_T, PCB_GROUP_T };
1362 static const std::vector<KICAD_T> zoneTypes = { PCB_ZONE_T };
1363
1367 mgr->SetConditions( PCB_ACTIONS::grabUnconnected, ENABLE( connectedOrFootprintCond ) );
1370
1371
1373 && SELECTION_CONDITIONS::OnlyTypes( zoneTypes );
1374
1376 && SELECTION_CONDITIONS::OnlyTypes( zoneTypes );
1377
1378 mgr->SetConditions( PCB_ACTIONS::zoneDuplicate, ENABLE( singleZoneCond ) );
1379 mgr->SetConditions( PCB_ACTIONS::drawZoneCutout, ENABLE( singleZoneCond ) );
1380 mgr->SetConditions( PCB_ACTIONS::drawSimilarZone, ENABLE( singleZoneCond ) );
1381 mgr->SetConditions( PCB_ACTIONS::zoneMerge, ENABLE( zoneMergeCond ) );
1382
1385
1386#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
1387
1388 // These tools can be used at any time to inspect the board
1393
1394 auto isDRCIdle =
1395 [this] ( const SELECTION& )
1396 {
1397 DRC_TOOL* tool = m_toolManager->GetTool<DRC_TOOL>();
1398 return !( tool && tool->IsDRCRunning() );
1399 };
1400
1401#define CURRENT_EDIT_TOOL( action ) \
1402 mgr->SetConditions( action, ACTION_CONDITIONS().Check( cond.CurrentTool( action ) ) \
1403 .Enable( isDRCIdle ) )
1404
1405 // These tools edit the board, so they must be disabled during some operations
1440
1446
1447#undef CURRENT_TOOL
1448#undef CURRENT_EDIT_TOOL
1449#undef ENABLE
1450#undef CHECK
1451// clang-format on
1452}
1453
1454
1455void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
1456{
1457 if( event.GetId() == wxID_EXIT )
1458 Kiway().OnKiCadExit();
1459
1460 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1461 Close( false );
1462}
1463
1464
1465void PCB_EDIT_FRAME::ResolveDRCExclusions( bool aCreateMarkers )
1466{
1467 BOARD_COMMIT commit( this );
1468
1469 for( PCB_MARKER* marker : GetBoard()->ResolveDRCExclusions( aCreateMarkers ) )
1470 {
1471 if( marker->GetMarkerType() == MARKER_BASE::MARKER_DRAWING_SHEET )
1472 marker->GetRCItem()->SetItems( GetCanvas()->GetDrawingSheet() );
1473
1474 commit.Add( marker );
1475 }
1476
1477 commit.Push( wxEmptyString, SKIP_UNDO | SKIP_SET_DIRTY );
1478
1479 for( PCB_MARKER* marker : GetBoard()->Markers() )
1480 {
1481 if( marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
1482 GetCanvas()->GetView()->Update( marker );
1483 }
1484
1486}
1487
1488
1489bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
1490{
1491 // Shutdown blocks must be determined and vetoed as early as possible
1493 && aEvent.GetId() == wxEVT_QUERY_END_SESSION
1494 && IsContentModified() )
1495 {
1496 return false;
1497 }
1498
1499 ZONE_FILLER_TOOL* zoneFillerTool = m_toolManager->GetTool<ZONE_FILLER_TOOL>();
1500
1501 if( zoneFillerTool->IsBusy() )
1502 {
1503 wxBell();
1504
1505 if( wxWindow* reporter = dynamic_cast<wxWindow*>( zoneFillerTool->GetProgressReporter() ) )
1506 reporter->ShowWithEffect( wxSHOW_EFFECT_EXPAND );
1507
1508 return false;
1509 }
1510
1511 // Don't allow closing while the modal footprint chooser is open
1512 auto* chooser = (FOOTPRINT_CHOOSER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_CHOOSER, false );
1513
1514 if( chooser && chooser->IsModal() ) // Can close footprint chooser?
1515 return false;
1516
1517 if( Kiface().IsSingle() )
1518 {
1519 auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
1520
1521 if( fpEditor && !fpEditor->Close() ) // Can close footprint editor?
1522 return false;
1523
1524 auto* fpViewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER, false );
1525
1526 if( fpViewer && !fpViewer->Close() ) // Can close footprint viewer?
1527 return false;
1528 }
1529 else
1530 {
1531 auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
1532
1533 if( fpEditor && fpEditor->IsCurrentFPFromBoard() )
1534 {
1535 if( !fpEditor->CanCloseFPFromBoard( true ) )
1536 return false;
1537 }
1538 }
1539
1540 if( IsContentModified() )
1541 {
1542 wxFileName fileName = GetBoard()->GetFileName();
1543 wxString msg = _( "Save changes to '%s' before closing?" );
1544
1545 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
1546 [&]() -> bool
1547 {
1548 return SaveBoard();
1549 } ) )
1550 {
1551 return false;
1552 }
1553
1554 // If user discarded changes, create a duplicate commit of last saved PCB state and
1555 // advance Last_Save_pcb tag for explicit history event.
1556 if( GetLastUnsavedChangesResponse() == wxID_NO )
1557 {
1558 wxString projPath = Prj().GetProjectPath();
1559
1560 if( !projPath.IsEmpty() && Kiway().LocalHistory().HistoryExists( projPath ) )
1561 {
1562 Kiway().LocalHistory().CommitDuplicateOfLastSave( projPath, wxS( "pcb" ),
1563 wxS( "Discard unsaved pcb changes" ) );
1564 }
1565 }
1566 }
1567
1568 return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
1569}
1570
1571
1573{
1574 // Unregister the autosave saver before any cleanup that might invalidate the board
1575 if( GetBoard() )
1577
1578 // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
1579 // when closing this frame if a footprint was selected, and the footprint editor called
1580 // to edit this footprint, and when closing pcbnew if this footprint is still selected
1581 // See https://bugs.launchpad.net/kicad/+bug/1655858
1582 // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
1583 // avoid the crash (JPC)
1584 GetCanvas()->SetEvtHandlerEnabled( false );
1585
1587
1590
1591 // Clean up mode-less dialogs.
1592 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &PCB_EDIT_FRAME::onCloseModelessBookReporterDialogs, this );
1593
1594 wxWindow* drcDlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
1595
1596 if( drcDlg )
1597 drcDlg->Close( true );
1598
1599 wxWindow* ruleEditorDlg = wxWindow::FindWindowByName( DIALOG_DRC_RULE_EDITOR_WINDOW_NAME );
1600
1601 if( ruleEditorDlg )
1602 ruleEditorDlg->Close( true );
1603
1604 if( m_findDialog )
1605 {
1606 m_findDialog->Destroy();
1607 m_findDialog = nullptr;
1608 }
1609
1611 {
1612 m_findByPropertiesDialog->Destroy();
1613 m_findByPropertiesDialog = nullptr;
1614 }
1615
1617 {
1618 m_inspectDrcErrorDlg->Destroy();
1619 m_inspectDrcErrorDlg = nullptr;
1620 }
1621
1623 {
1624 m_inspectClearanceDlg->Destroy();
1625 m_inspectClearanceDlg = nullptr;
1626 }
1627
1629 {
1630 m_inspectConstraintsDlg->Destroy();
1631 m_inspectConstraintsDlg = nullptr;
1632 }
1633
1634 if( m_footprintDiffDlg )
1635 {
1636 m_footprintDiffDlg->Destroy();
1637 m_footprintDiffDlg = nullptr;
1638 }
1639
1640 // Delete the auto save file if it exists. Only sweep when the board was actually
1641 // dirtied in this session; otherwise an existing autosave is a previous-session
1642 // leftover the user explicitly deferred in the recovery dialog.
1643 if( !Prj().IsNullProject() && GetBoard() && IsContentModified() )
1644 {
1645 Kiway().LocalHistory().RemoveAutosaveFiles( Prj().GetProjectPath(), { GetBoard()->GetFileName() } );
1646 }
1647
1648 // Make sure local settings are persisted
1649 if( Prj().GetLocalSettings().ShouldAutoSave() )
1650 {
1651 m_netInspectorPanel->SaveSettings();
1653 }
1654 else
1655 {
1656 wxLogTrace( traceAutoSave, wxT( "Skipping auto-save of migrated local settings" ) );
1657 }
1658
1659 // Do not show the layer manager during closing to avoid flicker
1660 // on some platforms (Windows) that generate useless redraw of items in
1661 // the Layer Manager
1663 {
1664 m_auimgr.GetPane( wxS( "LayersManager" ) ).Show( false );
1665 m_auimgr.GetPane( wxS( "TabbedPanel" ) ).Show( false );
1666 }
1667
1668 // Unlink the old project if needed
1670
1671 // Delete board structs and undo/redo lists, to avoid crash on exit
1672 // when deleting some structs (mainly in undo/redo lists) too late
1673 Clear_Pcb( false, true );
1674
1675 // do not show the window because ScreenPcb will be deleted and we do not
1676 // want any paint event
1677 Show( false );
1678
1680}
1681
1682
1689
1690
1691void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage, wxWindow* aParent )
1692{
1693 static std::mutex dialogMutex; // Local static mutex
1694
1695 std::unique_lock<std::mutex> dialogLock( dialogMutex, std::try_to_lock );
1696
1697 // One dialog at a time.
1698 if( !dialogLock.owns_lock() )
1699 {
1700 if( m_boardSetupDlg && m_boardSetupDlg->IsShown() )
1701 {
1702 m_boardSetupDlg->Raise(); // Brings the existing dialog to the front
1703 }
1704
1705 return;
1706 }
1707
1708 // Make sure everything's up-to-date
1710
1711 DIALOG_BOARD_SETUP dlg( this, aParent );
1712
1713 if( !aInitialPage.IsEmpty() )
1714 dlg.SetInitialPage( aInitialPage, wxEmptyString );
1715
1716 // Assign dlg to the m_boardSetupDlg pointer to track its status.
1717 m_boardSetupDlg = &dlg;
1718
1719 // QuasiModal required for Scintilla auto-complete
1720 if( dlg.ShowQuasiModal() == wxID_OK )
1721 {
1722 // Note: We must synchronise time domain properties before nets and classes, otherwise the updates
1723 // called by the board listener events are using stale data
1726
1727 if( !GetBoard()->SynchronizeComponentClasses( std::unordered_set<wxString>() ) )
1728 {
1729 m_infoBar->RemoveAllButtons();
1730 m_infoBar->AddCloseButton();
1731 m_infoBar->ShowMessage( _( "Could not load component class assignment rules" ),
1732 wxICON_WARNING, WX_INFOBAR::MESSAGE_TYPE::GENERIC );
1733 }
1734
1735 // We don't know if anything was modified, so err on the side of requiring a save
1736 OnModify();
1737
1739
1742
1743 // CROSS_REF keys deliberately excluded — those are driven by per-item
1744 // BOARD_COMMIT changes.
1745 if( BOARD_TEXT_VAR_ADAPTER* adapter = GetBoard()->GetTextVarAdapter() )
1746 adapter->Tracker().InvalidateProjectScoped();
1747
1748 PCBNEW_SETTINGS* settings = GetPcbNewSettings();
1749 static LSET maskAndPasteLayers = LSET( { F_Mask, F_Paste, B_Mask, B_Paste } );
1750
1752 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1753 {
1754 int flags = 0;
1755
1756 if( !aItem->IsBOARD_ITEM() )
1757 return flags;
1758
1759 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aItem );
1760
1761 if( item->Type() == PCB_VIA_T || item->Type() == PCB_PAD_T )
1762 {
1763 // Note: KIGFX::REPAINT isn't enough for things that go from invisible
1764 // to visible as they won't be found in the view layer's itemset for
1765 // re-painting.
1766 if( ( GetBoard()->GetVisibleLayers() & maskAndPasteLayers ).any() )
1767 flags |= KIGFX::ALL;
1768 }
1769
1770 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T || item->Type() == PCB_VIA_T )
1771 {
1773 flags |= KIGFX::REPAINT;
1774 }
1775
1776 if( item->Type() == PCB_PAD_T )
1777 {
1778 if( settings->m_Display.m_PadClearance )
1779 flags |= KIGFX::REPAINT;
1780 }
1781
1782 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1783 {
1784 if( text->HasTextVars() )
1785 {
1786 text->ClearRenderCache();
1787 text->ClearBoundingBoxCache();
1789 }
1790 }
1791
1792 return flags;
1793 } );
1794
1795 GetCanvas()->Refresh();
1796
1800
1801 //this event causes the routing tool to reload its design rules information
1803 toolEvent.SetHasPosition( false );
1804 m_toolManager->ProcessEvent( toolEvent );
1805 }
1806
1807 GetCanvas()->SetFocus();
1808
1809 // Reset m_boardSetupDlg after the dialog is closed
1810 m_boardSetupDlg = nullptr;
1811}
1812
1813
1815{
1816 m_searchPane->FocusSearch();
1817}
1818
1819
1821{
1823
1824 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
1825 wxASSERT( cfg );
1826
1827 if( cfg )
1828 {
1832 }
1833}
1834
1835
1837{
1839
1840 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
1841 wxASSERT( cfg );
1842
1843 if( cfg )
1844 {
1845 wxAuiPaneInfo& apperancePane = m_auimgr.GetPane( AppearancePanelName() );
1846 cfg->m_AuiPanels.show_layer_manager = apperancePane.IsShown();
1847
1848 if( m_propertiesPanel )
1849 {
1850 cfg->m_AuiPanels.show_properties = m_propertiesPanel->IsShownOnScreen();
1852 cfg->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion();
1853 }
1854
1855 // ensure m_ShowSearch is up to date (the pane can be closed)
1856 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
1857 m_ShowSearch = searchPaneInfo.IsShown();
1859 cfg->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
1860 cfg->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
1861 cfg->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
1862
1864 {
1865 wxAuiPaneInfo& netInspectorhPaneInfo = m_auimgr.GetPane( NetInspectorPanelName() );
1866 m_ShowNetInspector = netInspectorhPaneInfo.IsShown();
1868 }
1869
1870 if( m_appearancePanel )
1871 {
1874 cfg->m_AuiPanels.appearance_expand_layer_display = m_appearancePanel->IsLayerOptionsExpanded();
1875 cfg->m_AuiPanels.appearance_expand_net_display = m_appearancePanel->IsNetOptionsExpanded();
1876 }
1877
1878 wxAuiPaneInfo& designBlocksPane = m_auimgr.GetPane( DesignBlocksPaneName() );
1879 cfg->m_AuiPanels.design_blocks_show = designBlocksPane.IsShown();
1880
1881 if( designBlocksPane.IsDocked() )
1883 else
1884 {
1885 cfg->m_AuiPanels.design_blocks_panel_float_height = designBlocksPane.floating_size.y;
1886 cfg->m_AuiPanels.design_blocks_panel_float_width = designBlocksPane.floating_size.x;
1887 }
1888
1889 m_designBlocksPane->SaveSettings();
1890 }
1891}
1892
1893
1895{
1896 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( config() );
1897
1898 return cfg ? cfg->m_RotationAngle : ANGLE_90;
1899}
1900
1901
1906
1907
1909{
1910
1911 GetColorSettings()->SetColor( LAYER_GRID, aColor );
1912 GetCanvas()->GetGAL()->SetGridColor( aColor );
1913}
1914
1915
1916void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer, bool aForceRedraw )
1917{
1918 const PCB_LAYER_ID oldLayer = GetActiveLayer();
1919
1920 if( oldLayer == aLayer && !aForceRedraw )
1921 return;
1922
1924
1925 m_appearancePanel->OnLayerChanged();
1926
1927 m_toolManager->PostAction( PCB_ACTIONS::layerChanged ); // notify other tools
1928 GetCanvas()->SetFocus(); // allow capture of hotkeys
1929 GetCanvas()->SetHighContrastLayer( aLayer );
1930
1931 /*
1932 * Only show pad, via and track clearances when a copper layer is active
1933 * and then only show the clearance layer for that copper layer. For
1934 * front/back non-copper layers, show the clearance layer for the outer
1935 * layer on that side.
1936 *
1937 * For pads/vias, this is to avoid clutter when there are pad/via layers
1938 * that vary in flash (i.e. clearance from the hole or pad edge), padstack
1939 * shape on each layer or clearances on each layer.
1940 *
1941 * For tracks, this follows the same logic as pads/vias, but in theory could
1942 * have their own set of independent clearance layers to allow track clearance
1943 * to be shown for more layers.
1944 */
1945 const auto getClearanceLayerForActive = []( PCB_LAYER_ID aActiveLayer ) -> std::optional<int>
1946 {
1947 if( IsCopperLayer( aActiveLayer ) )
1948 return CLEARANCE_LAYER_FOR( aActiveLayer );
1949
1950 return std::nullopt;
1951 };
1952
1953 if( std::optional<int> oldClearanceLayer = getClearanceLayerForActive( oldLayer ) )
1954 GetCanvas()->GetView()->SetLayerVisible( *oldClearanceLayer, false );
1955
1956 if( std::optional<int> newClearanceLayer = getClearanceLayerForActive( aLayer ) )
1957 GetCanvas()->GetView()->SetLayerVisible( *newClearanceLayer, true );
1958
1960
1962 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1963 {
1964 if( !aItem->IsBOARD_ITEM() )
1965 return 0;
1966
1967 return activeLayerUpdateFlags( static_cast<const BOARD_ITEM*>( aItem ), oldLayer,
1968 aLayer, contrastMode );
1969 } );
1970
1971 GetCanvas()->Refresh();
1972}
1973
1974
1976 PCB_LAYER_ID aNewLayer, HIGH_CONTRAST_MODE aContrastMode )
1977{
1978 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as they
1979 // won't be found in the view layer's itemset for re-painting.
1980 if( aContrastMode == HIGH_CONTRAST_MODE::HIDDEN )
1981 {
1982 if( aItem->IsOnLayer( aOldLayer ) || aItem->IsOnLayer( aNewLayer ) )
1983 return KIGFX::ALL;
1984 }
1985
1986 // High contrast dims by active layer so all flagged items repaint; without it only the flashed
1987 // copper geometry depends on the active layer, so re-cache just the items whose flashing changes.
1988 const bool highContrast = aContrastMode != HIGH_CONTRAST_MODE::NORMAL;
1989
1990 if( aItem->Type() == PCB_VIA_T )
1991 {
1992 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
1993
1994 if( via->GetViaType() == VIATYPE::BLIND
1995 || via->GetViaType() == VIATYPE::BURIED
1996 || via->GetViaType() == VIATYPE::MICROVIA )
1997 {
1998 if( highContrast
1999 || via->GetLayerSet().test( aOldLayer ) != via->GetLayerSet().test( aNewLayer ) )
2000 {
2001 return KIGFX::REPAINT;
2002 }
2003 }
2004
2005 if( via->GetRemoveUnconnected()
2006 && ( highContrast || via->FlashLayer( aOldLayer ) != via->FlashLayer( aNewLayer ) ) )
2007 {
2008 return KIGFX::ALL;
2009 }
2010 }
2011 else if( aItem->Type() == PCB_PAD_T )
2012 {
2013 const PAD* pad = static_cast<const PAD*>( aItem );
2014
2015 if( pad->GetRemoveUnconnected()
2016 && ( highContrast || pad->FlashLayer( aOldLayer ) != pad->FlashLayer( aNewLayer ) ) )
2017 {
2018 return KIGFX::ALL;
2019 }
2020 }
2021
2022 return 0;
2023}
2024
2025
2027{
2028 wxFileName fn( GetBoard()->GetFileName() );
2029
2030 if( !Prj().IsNullProject() )
2031 Kiway().LocalHistory().Init( Prj().GetProjectPath() );
2032
2034
2035 layerEnum.Choices().Clear();
2036 layerEnum.Undefined( UNDEFINED_LAYER );
2037
2038 for( PCB_LAYER_ID layer : LSET::AllLayersMask() )
2039 {
2040 // Canonical name
2041 layerEnum.Map( layer, LSET::Name( layer ) );
2042
2043 // User name
2044 layerEnum.Map( layer, GetBoard()->GetLayerName( layer ) );
2045 }
2046
2047 DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
2048
2049 try
2050 {
2051 drcTool->GetDRCEngine()->InitEngine( GetBoard()->GetDesignRulesPath() );
2052 }
2053 catch( PARSE_ERROR& )
2054 {
2055 // Not sure this is the best place to tell the user their rules are buggy, so
2056 // we'll stay quiet for now. Feel free to revisit this decision....
2057 }
2058
2060
2061 // Migrate obsolete WRL 3D model references to current STEP models. Only
2062 // runs in the GUI: CLI and scripting load paths must not mutate board
2063 // state on load. The STEP exporter does its own WRL->STEP substitution at
2064 // export time via the --subst-models flag, and the 3D cache quietly falls
2065 // back to sibling STEP files for missing WRLs in headless contexts.
2066 if( Pgm().IsGUI() )
2067 {
2068 // Silently replace references whose filename uniquely identifies a
2069 // STEP sibling. Leaves ambiguous cases for the infobar below.
2071
2072 const int unresolved = DIALOG_MIGRATE_3D_MODELS::CountUnresolvedWrlReferences( this );
2073
2074 if( unresolved > 0 )
2075 {
2076 wxString msg = wxString::Format( wxPLURAL( "%d WRL 3D model could not be matched "
2077 "to an equivalent STEP model.",
2078 "%d WRL 3D models could not be matched "
2079 "to equivalent STEP models.",
2080 unresolved ),
2081 unresolved );
2082
2083 wxHyperlinkCtrl* link = new wxHyperlinkCtrl( m_loadNoticeInfoBar, wxID_ANY,
2084 _( "Show options" ), wxEmptyString );
2085
2086 link->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& )>(
2087 [this]( wxHyperlinkEvent& )
2088 {
2089 DIALOG_MIGRATE_3D_MODELS dlg( this );
2090 dlg.ShowModal();
2091
2092 // Dismiss the infobar if nothing remains to resolve;
2093 // otherwise leave it so the user can try again.
2095 m_loadNoticeInfoBar->Dismiss();
2096 } ) );
2097
2098 m_loadNoticeInfoBar->RemoveAllButtons();
2099 m_loadNoticeInfoBar->AddButton( link );
2100 m_loadNoticeInfoBar->AddCloseButton();
2101 m_loadNoticeInfoBar->ShowMessageFor( msg, 10000, wxICON_INFORMATION );
2102 }
2103 }
2104
2105 UpdateTitle();
2106
2107 // Display a warning that the file is read only
2108 if( fn.FileExists() && !fn.IsFileWritable() )
2109 {
2110 m_infoBar->RemoveAllButtons();
2111 m_infoBar->AddCloseButton();
2112 m_infoBar->ShowMessage( _( "Board file is read only." ),
2113 wxICON_WARNING, WX_INFOBAR::MESSAGE_TYPE::OUTDATED_SAVE );
2114 }
2115
2117
2118 // Sync layer and item visibility
2120
2121 SetElementVisibility( LAYER_RATSNEST, GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
2122
2123 m_appearancePanel->OnBoardChanged();
2124
2125 // Apply saved display state to the appearance panel after it has been set up
2126 PROJECT_LOCAL_SETTINGS& localSettings = Prj().GetLocalSettings();
2127
2128 m_appearancePanel->ApplyLayerPreset( localSettings.m_ActiveLayerPreset );
2129
2130 if( GetBoard()->GetDesignSettings().IsLayerEnabled( localSettings.m_ActiveLayer ) )
2131 SetActiveLayer( localSettings.m_ActiveLayer, true );
2132 else
2133 SetActiveLayer( GetActiveLayer(), true ); // Make sure to repaint even if not switching
2134
2135 PROJECT_FILE& projectFile = Prj().GetProjectFile();
2136
2137 m_layerPairSettings->SetLayerPairs( projectFile.m_LayerPairInfos );
2138 m_layerPairSettings->SetCurrentLayerPair( LAYER_PAIR{ F_Cu, B_Cu } );
2139
2140 // Updates any auto dimensions and the auxiliary toolbar tracks/via sizes
2142
2143 // Sync the net inspector now we have connectivity calculated
2145 m_netInspectorPanel->OnBoardChanged();
2146
2147 // Display the loaded board:
2148 Zoom_Automatique( false );
2149
2150 // Invalidate painting as loading the DRC engine will cause clearances to become valid
2152
2153 Refresh();
2154
2155 SetMsgPanel( GetBoard() );
2156 SetStatusText( wxEmptyString );
2157
2158 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "PCB file changes are unsaved" ) );
2159}
2160
2161
2163{
2164 m_appearancePanel->UpdateDisplayOptions();
2165}
2166
2167
2169{
2170 return GetBoard()->IsElementVisible( aElement );
2171}
2172
2173
2175{
2176 // Force the RATSNEST visible
2177 if( aElement == LAYER_RATSNEST )
2178 GetCanvas()->GetView()->SetLayerVisible( aElement, true );
2179 else
2180 GetCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
2181
2182 GetBoard()->SetElementVisibility( aElement, aNewState );
2183}
2184
2185
2187{
2188 // call my base class
2190
2191 m_auimgr.GetPane( m_appearancePanel ).Caption( _( "Appearance" ) );
2192 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
2193 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
2194 m_auimgr.GetPane( m_netInspectorPanel ).Caption( _( "Net Inspector" ) );
2195 m_auimgr.Update();
2196
2197 UpdateTitle();
2198}
2199
2200
2202{
2204
2205 if( project.m_PcbLastPath[ aType ].IsEmpty() )
2206 return wxEmptyString;
2207
2208 wxFileName absoluteFileName = project.m_PcbLastPath[ aType ];
2209 wxFileName pcbFileName = GetBoard()->GetFileName();
2210
2211 absoluteFileName.MakeAbsolute( pcbFileName.GetPath() );
2212 return absoluteFileName.GetFullPath();
2213}
2214
2215
2216void PCB_EDIT_FRAME::SetLastPath( LAST_PATH_TYPE aType, const wxString& aLastPath )
2217{
2219
2220 wxFileName relativeFileName = aLastPath;
2221 wxFileName pcbFileName = GetBoard()->GetFileName();
2222
2223 relativeFileName.MakeRelativeTo( pcbFileName.GetPath() );
2224
2225 if( relativeFileName.GetFullPath() != project.m_PcbLastPath[ aType ] )
2226 {
2227 project.m_PcbLastPath[ aType ] = relativeFileName.GetFullPath();
2228 OnModify();
2229 }
2230}
2231
2232
2234{
2236 Kiway().LocalHistory().NoteFileChange( GetBoard()->GetFileName() );
2237 m_ZoneFillsDirty = true;
2238
2239 if( m_isClosing )
2240 return;
2241
2242 Update3DView( true, GetPcbNewSettings()->m_Display.m_Live3DRefresh );
2243
2244 if( !GetTitle().StartsWith( wxT( "*" ) ) )
2245 UpdateTitle();
2246
2247}
2248
2249
2251{
2252 Update3DView( true, true );
2253
2254 std::shared_ptr<CONNECTIVITY_DATA> connectivity = GetBoard()->GetConnectivity();
2255 connectivity->RecalculateRatsnest( nullptr );
2257
2258 std::vector<MSG_PANEL_ITEM> msg_list;
2259 GetBoard()->GetMsgPanelInfo( this, msg_list );
2260 SetMsgPanel( msg_list );
2261}
2262
2263
2265{
2266 wxFileName fn = GetBoard()->GetFileName();
2267 bool readOnly = false;
2268 bool unsaved = false;
2269
2270 if( fn.IsOk() && fn.FileExists() )
2271 readOnly = !fn.IsFileWritable();
2272 else
2273 unsaved = true;
2274
2275 wxString title;
2276
2277 if( IsContentModified() )
2278 title = wxT( "*" );
2279
2280 title += fn.GetName();
2281
2282 if( readOnly )
2283 title += wxS( " " ) + _( "[Read Only]" );
2284
2285 if( unsaved )
2286 title += wxS( " " ) + _( "[Unsaved]" );
2287
2288 title += wxT( " \u2014 " ) + _( "PCB Editor" );
2289
2290 SetTitle( title );
2291}
2292
2293
2295{
2296 // Update the layer manager and other widgets from the board setup
2297 // (layer and items visibility, colors ...)
2298
2299 // Rebuild list of nets (full ratsnest rebuild)
2301
2302 // Update info shown by the horizontal toolbars
2304
2305 LSET activeLayers = GetBoard()->GetEnabledLayers();
2306
2307 if( !activeLayers.test( GetActiveLayer() ) )
2308 SetActiveLayer( activeLayers.Seq().front() );
2309
2310 // The layer selector lives on the top auxiliary toolbar. Users can remove every
2311 // entry from that toolbar via Preferences, in which case the control is destroyed
2312 // and m_SelLayerBox is null. Avoid dereferencing it here.
2313 if( m_SelLayerBox )
2314 m_SelLayerBox->SetLayerSelection( GetActiveLayer() );
2315
2317
2318 layerEnum.Choices().Clear();
2319 layerEnum.Undefined( UNDEFINED_LAYER );
2320
2321 for( PCB_LAYER_ID layer : LSET::AllLayersMask() )
2322 {
2323 // Canonical name
2324 layerEnum.Map( layer, LSET::Name( layer ) );
2325
2326 // User name
2327 layerEnum.Map( layer, GetBoard()->GetLayerName( layer ) );
2328 }
2329
2331
2332 // Sync visibility with canvas
2333 for( PCB_LAYER_ID layer : LSET::AllLayersMask() )
2334 GetCanvas()->GetView()->SetLayerVisible( layer, GetBoard()->IsLayerVisible( layer ) );
2335
2336 // Stackup and/or color theme may have changed
2337 m_appearancePanel->OnBoardChanged();
2338 m_netInspectorPanel->OnParentSetupChanged();
2339}
2340
2341
2343{
2344 // switches currently used canvas (Cairo / OpenGL).
2345 PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
2346}
2347
2348
2350{
2351 if( !m_findDialog )
2352 {
2353 m_findDialog = new DIALOG_FIND( this );
2354 m_findDialog->SetCallback( std::bind( &PCB_SELECTION_TOOL::FindItem,
2355 m_toolManager->GetTool<PCB_SELECTION_TOOL>(), _1 ) );
2356 }
2357
2358 wxString findString;
2359
2360 PCB_SELECTION& selection = m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
2361
2362 if( selection.Size() == 1 )
2363 {
2364 EDA_ITEM* front = selection.Front();
2365
2366 switch( front->Type() )
2367 {
2368 case PCB_FOOTPRINT_T:
2369 findString = UnescapeString( static_cast<FOOTPRINT*>( front )->GetValue() );
2370 break;
2371
2372 case PCB_FIELD_T:
2373 case PCB_TEXT_T:
2374 findString = UnescapeString( static_cast<PCB_TEXT*>( front )->GetText() );
2375
2376 if( findString.Contains( wxT( "\n" ) ) )
2377 findString = findString.Before( '\n' );
2378
2379 break;
2380
2381 default:
2382 break;
2383 }
2384 }
2385
2386 m_findDialog->Preload( findString );
2387
2388 m_findDialog->Show( true );
2389}
2390
2391
2400
2401
2407
2408
2414
2415
2416void PCB_EDIT_FRAME::FindNext( bool reverse )
2417{
2418 if( !m_findDialog )
2420
2421 m_findDialog->FindNext( reverse );
2422}
2423
2424
2426{
2427 if( Kiface().IsSingle() )
2428 return 0;
2429
2430 // Update PCB requires a netlist. Therefore the schematic editor must be running
2431 // If this is not the case, open the schematic editor
2432 KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
2433
2434 // If Kiway() cannot create the eeschema frame, it shows a error message, and
2435 // frame is null
2436 if( !frame )
2437 return -1;
2438
2439 if( !frame->IsShownOnScreen() )
2440 {
2441 wxEventBlocker blocker( this );
2442 wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
2444
2445 // Maybe the file hasn't been converted to the new s-expression file format so
2446 // see if the legacy schematic file is still in play.
2447 if( !fn.FileExists() )
2448 {
2450
2451 if( !fn.FileExists() )
2452 {
2453 DisplayErrorMessage( this, _( "The schematic for this board cannot be found." ) );
2454 return -2;
2455 }
2456 }
2457
2458 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
2459
2460 // we show the schematic editor frame, because do not show is seen as
2461 // a not yet opened schematic by Kicad manager, which is not the case
2462 frame->Show( true );
2463
2464 // bring ourselves back to the front
2465 Raise();
2466 }
2467
2468 return 1; //Success!
2469}
2470
2471
2473 const wxString& aAnnotateMessage )
2474{
2475 int standalone = TestStandalone();
2476
2477 if( standalone == 0 )
2478 {
2479 DisplayErrorMessage( this, _( "Cannot update the PCB because PCB editor is opened in "
2480 "stand-alone mode. In order to create or update PCBs from "
2481 "schematics, you must launch the KiCad project manager and "
2482 "create a project." ) );
2483 return false; // Not in standalone mode
2484 }
2485
2486 if( standalone < 0 ) // Problem with Eeschema or the schematic
2487 return false;
2488
2489 Raise(); // Show
2490
2491 std::string payload( aAnnotateMessage );
2492
2493 Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
2494
2495 if( payload == aAnnotateMessage )
2496 {
2497 Raise();
2498 DisplayErrorMessage( this, aAnnotateMessage );
2499 return false;
2500 }
2501
2502 try
2503 {
2504 auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
2505 KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
2506 netlistReader.LoadNetlist();
2507 }
2508 catch( const IO_ERROR& e )
2509 {
2510 Raise();
2511
2512 // Do not translate extra_info strings. These are for developers
2513 wxString extra_info = e.Problem() + wxT( " : " ) + e.What() + wxT( " at " ) + e.Where();
2514
2515 DisplayErrorMessage( this, _( "Received an error while reading netlist. Please "
2516 "report this issue to the KiCad team using the menu "
2517 "Help->Report Bug."), extra_info );
2518 return false;
2519 }
2520
2521 return true;
2522}
2523
2524
2526{
2527 if( aFootprint == nullptr )
2528 return;
2529
2531
2532 /*
2533 * Make sure dlg is destroyed before GetCanvas->Refresh is called
2534 * later or the refresh will try to modify its properties since
2535 * they share a GL context.
2536 */
2537 {
2538 DIALOG_FOOTPRINT_PROPERTIES dlg( this, aFootprint );
2539
2540 dlg.ShowQuasiModal();
2541 retvalue = dlg.GetReturnValue();
2542 }
2543
2544 /*
2545 * retvalue =
2546 * FP_PROPS_UPDATE_FP to show Update Footprints dialog
2547 * FP_PROPS_CHANGE_FP to show Change Footprints dialog
2548 * FP_PROPS_OK for normal edit
2549 * FP_PROPS_CANCEL if aborted
2550 * FP_PROPS_EDIT_BOARD_FP to load board footprint into Footprint Editor
2551 * FP_PROPS_EDIT_LIBRARY_FP to load library footprint into Footprint Editor
2552 */
2553
2555 {
2556 // If something edited, push a refresh request
2557 GetCanvas()->Refresh();
2558 }
2560 {
2561 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ) )
2562 {
2563 FOOTPRINT_EDIT_FRAME* fp_editor = static_cast<FOOTPRINT_EDIT_FRAME*>( frame );
2564
2565 fp_editor->LoadFootprintFromBoard( aFootprint );
2566 fp_editor->Show( true );
2567 fp_editor->Raise(); // Iconize( false );
2568 }
2569 }
2571 {
2572 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ) )
2573 {
2574 FOOTPRINT_EDIT_FRAME* fp_editor = static_cast<FOOTPRINT_EDIT_FRAME*>( frame );
2575
2576 fp_editor->LoadFootprintFromLibrary( aFootprint->GetFPID() );
2577 fp_editor->Show( true );
2578 fp_editor->Raise(); // Iconize( false );
2579 }
2580 }
2582 {
2583 ShowExchangeFootprintsDialog( aFootprint, true, true );
2584 }
2586 {
2587 ShowExchangeFootprintsDialog( aFootprint, false, true );
2588 }
2589}
2590
2591
2593 bool aSelectedMode )
2594{
2595 DIALOG_EXCHANGE_FOOTPRINTS dialog( this, aFootprint, aUpdateMode, aSelectedMode );
2596
2597 return dialog.ShowQuasiModal();
2598}
2599
2600
2602{
2604 m_appearancePanel->CommonSettingsChanged( aFlags );
2605
2607
2609
2610 SetElementVisibility( LAYER_RATSNEST, GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
2611
2613
2614 // Netclass definitions could have changed, either by us or by Eeschema, so we need to
2615 // recompile the implicit rules
2616 DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
2617 WX_INFOBAR* infobar = GetInfoBar();
2618
2619 try
2620 {
2621 drcTool->GetDRCEngine()->InitEngine( GetBoard()->GetDesignRulesPath() );
2622
2623 if( infobar->GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::DRC_RULES_ERROR )
2624 infobar->Dismiss();
2625 }
2626 catch( PARSE_ERROR& )
2627 {
2628 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Edit design rules" ),
2629 wxEmptyString );
2630
2631 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
2632 [&]( wxHyperlinkEvent& aEvent )
2633 {
2634 ShowBoardSetupDialog( _( "Custom Rules" ) );
2635 } ) );
2636
2637 infobar->RemoveAllButtons();
2638 infobar->AddButton( button );
2639 infobar->AddCloseButton();
2640 infobar->ShowMessage( _( "Could not compile custom design rules." ), wxICON_ERROR,
2641 WX_INFOBAR::MESSAGE_TYPE::DRC_RULES_ERROR );
2642 }
2643
2646
2647 Layout();
2648 SendSizeEvent();
2649}
2650
2651
2656
2657
2659{
2660 // Register autosave history saver for the board.
2661 // Saver serializes the in-memory BOARD into HISTORY_FILE_DATA. Prettify and
2662 // file I/O happen on a background thread to avoid blocking the UI.
2663 if( GetBoard() )
2664 {
2666 GetBoard(),
2667 [this]( const wxString& aProjectPath, std::vector<HISTORY_FILE_DATA>& aFileData )
2668 {
2669 // See SCHEMATIC::SaveToHistory: the dirty check is only valid in ZIP
2670 // mode. In INCREMENTAL mode the manual-save flow clears the dirty
2671 // flag before the saver runs, so filtering would drop the snapshot.
2672 bool filterClean = Pgm().GetCommonSettings()->m_Backup.format == BACKUP_FORMAT::ZIP;
2673
2674 if( filterClean && !IsContentModified() )
2675 return;
2676
2677 GetBoard()->SaveToHistory( aProjectPath, aFileData );
2678 } );
2679 }
2680}
2681
2682
2684{
2686
2687 if( !mgr )
2688 return false;
2689
2690 TOOL_BASE* currentTool = mgr->GetCurrentTool();
2691
2692 // When a single item that can be point-edited is selected, the point editor
2693 // tool will be active instead of the selection tool. It blocks undo/redo
2694 // while the user is actually dragging points around, though, so we can use
2695 // this as an initial check.
2696 if( UndoRedoBlocked() )
2697 return true;
2698
2699 // A tool other than passive selection or point editing is actively modifying
2700 // the model (drawing, dragging, routing, etc.).
2701 if( currentTool != mgr->GetTool<PCB_SELECTION_TOOL>()
2702 && currentTool != mgr->GetTool<PCB_POINT_EDITOR>() )
2703 {
2704 return true;
2705 }
2706
2707 if( ZONE_FILLER_TOOL* zoneFillerTool = mgr->GetTool<ZONE_FILLER_TOOL>();
2708 zoneFillerTool && zoneFillerTool->IsBusy() )
2709 {
2710 return true;
2711 }
2712
2713 if( ROUTER_TOOL* routerTool = mgr->GetTool<ROUTER_TOOL>();
2714 routerTool && routerTool->RoutingInProgress() )
2715 {
2716 return true;
2717 }
2718
2719 return false;
2720}
2721
2722
2724{
2726 return false;
2727
2729}
2730
2731
2733{
2734 // Serializing a large board on the UI thread freezes the editor; never do it while the
2735 // user is mid-operation or the deferred input gets misinterpreted (e.g. a routed track
2736 // ending where the cursor lands once the editor unfreezes).
2738}
2739
2740
2746
2747
2748bool PCB_EDIT_FRAME::GetPluginActionButtonVisible( const wxString& aPluginPath, bool aPluginDefault )
2749{
2750 if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
2751 {
2752 for( const auto& [identifier, visible] : cfg->m_Plugins.actions )
2753 {
2754 if( identifier == aPluginPath )
2755 return visible;
2756 }
2757 }
2758
2759 // Plugin is not in settings, return default.
2760 return aPluginDefault;
2761}
2762
2763
2765{
2766 return GetBoard()->GetFileName();
2767}
2768
2769
2771{
2772 return m_auimgr.GetPane( wxS( "LayersManager" ) ).IsShown();
2773}
2774
2775
2777{
2778 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
2779}
2780
2781
2783{
2784 return m_auimgr.GetPane( NetInspectorPanelName() ).IsShown();
2785}
2786
2787
2788void PCB_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2789{
2790 if( IsShownOnScreen() )
2791 {
2792 // We only need this until the frame is done resizing and the final client size is
2793 // established.
2794 Unbind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
2796 }
2797
2798 // Skip() is called in the base class.
2799 EDA_DRAW_FRAME::OnSize( aEvent );
2800}
2801
2802
2813
2814
2825
2826
2837
2838
2840{
2841 if( !m_footprintDiffDlg )
2842 {
2844 _( "Compare Footprint with Library" ) );
2845
2846 m_footprintDiffDlg->m_sdbSizerApply->SetLabel( _( "Update Footprint from Library..." ) );
2847 m_footprintDiffDlg->m_sdbSizerApply->PostSizeEventToParent();
2848 m_footprintDiffDlg->m_sdbSizerApply->Show();
2849 }
2850
2851 return m_footprintDiffDlg;
2852}
2853
2854
2856{
2857 if( m_inspectDrcErrorDlg && aEvent.GetString() == INSPECT_DRC_ERROR_DIALOG_NAME )
2858 {
2859 m_inspectDrcErrorDlg->Destroy();
2860 m_inspectDrcErrorDlg = nullptr;
2861 }
2862 else if( m_inspectClearanceDlg && aEvent.GetString() == INSPECT_CLEARANCE_DIALOG_NAME )
2863 {
2864 m_inspectClearanceDlg->Destroy();
2865 m_inspectClearanceDlg = nullptr;
2866 }
2867 else if( m_inspectConstraintsDlg && aEvent.GetString() == INSPECT_CONSTRAINTS_DIALOG_NAME )
2868 {
2869 m_inspectConstraintsDlg->Destroy();
2870 m_inspectConstraintsDlg = nullptr;
2871 }
2872 else if( m_footprintDiffDlg && aEvent.GetString() == FOOTPRINT_DIFF_DIALOG_NAME )
2873 {
2874 if( aEvent.GetId() == wxID_APPLY )
2875 {
2876 KIID fpUUID = m_footprintDiffDlg->GetUserItemID();
2877
2878 CallAfter(
2879 [this, fpUUID]()
2880 {
2881 BOARD_ITEM* item = m_pcb->ResolveItem( fpUUID );
2882
2883 if( FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( item ) )
2884 {
2885 m_toolManager->RunAction<EDA_ITEM*>( ACTIONS::selectItem, footprint );
2886
2887 DIALOG_EXCHANGE_FOOTPRINTS dialog( this, footprint, true, true );
2888 dialog.ShowQuasiModal();
2889 }
2890 } );
2891 }
2892
2893 m_footprintDiffDlg->Destroy();
2894 m_footprintDiffDlg = nullptr;
2895 }
2896}
2897
2898
2900{
2901 wxLogTrace( traceApi, "PCB frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
2903 aEvt.Skip();
2904}
2905
2906
2908{
2909 PCB_LAYER_ID curLayer = GetActiveLayer();
2910 const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
2911
2912 // Check if the specified layer matches the present layer
2913 if( layer == curLayer )
2914 return;
2915
2916 // Copper layers cannot be selected unconditionally; how many of those layers are currently
2917 // enabled needs to be checked.
2918 if( IsCopperLayer( layer ) )
2919 {
2920 if( layer > GetBoard()->GetCopperLayerStackMaxId() )
2921 return;
2922 }
2923
2924 // Is yet more checking required? E.g. when the layer to be selected is a non-copper layer,
2925 // or when switching between a copper layer and a non-copper layer, or vice-versa?
2926
2927 SetActiveLayer( layer );
2928
2930 GetCanvas()->Refresh();
2931}
2932
2933
2935{
2936 switch( aItem->Type() )
2937 {
2940 break;
2941
2942 case PCB_BARCODE_T:
2943 ShowBarcodePropertiesDialog( static_cast<PCB_BARCODE*>( aItem ) );
2944 break;
2945
2946 case PCB_FIELD_T:
2947 case PCB_TEXT_T:
2948 ShowTextPropertiesDialog( static_cast<PCB_TEXT*>( aItem ) );
2949 break;
2950
2951 case PCB_TEXTBOX_T:
2952 ShowTextBoxPropertiesDialog( static_cast<PCB_TEXTBOX*>( aItem ) );
2953 break;
2954
2955 case PCB_TABLE_T:
2956 {
2957 DIALOG_TABLE_PROPERTIES dlg( this, static_cast<PCB_TABLE*>( aItem ) );
2958
2959 //QuasiModal required for Scintilla auto-complete
2960 dlg.ShowQuasiModal();
2961 break;
2962 }
2963
2964 case PCB_PAD_T:
2965 ShowPadPropertiesDialog( static_cast<PAD*>( aItem ) );
2966 break;
2967
2968 case PCB_FOOTPRINT_T:
2969 ShowFootprintPropertiesDialog( static_cast<FOOTPRINT*>( aItem ) );
2970 break;
2971
2972 case PCB_TARGET_T:
2973 ShowTargetOptionsDialog( static_cast<PCB_TARGET*>( aItem ) );
2974 break;
2975
2976 case PCB_DIM_ALIGNED_T:
2977 case PCB_DIM_CENTER_T:
2978 case PCB_DIM_RADIAL_T:
2980 case PCB_DIM_LEADER_T:
2981 {
2982 DIALOG_DIMENSION_PROPERTIES dlg( this, static_cast<PCB_DIMENSION_BASE*>( aItem ) );
2983
2984 dlg.ShowModal();
2985 break;
2986 }
2987
2988 case PCB_SHAPE_T:
2989 ShowGraphicItemPropertiesDialog( static_cast<PCB_SHAPE*>( aItem ) );
2990 break;
2991
2992 case PCB_ZONE_T:
2993 Edit_Zone_Params( static_cast<ZONE*>( aItem ) );
2994 break;
2995
2996 case PCB_GROUP_T:
2998 static_cast<EDA_GROUP*>( static_cast<PCB_GROUP*>( aItem ) ) );
2999 break;
3000
3001 case PCB_GENERATOR_T:
3002 static_cast<PCB_GENERATOR*>( aItem )->ShowPropertiesDialog( this );
3003 break;
3004
3005 case PCB_MARKER_T:
3006 m_toolManager->GetTool<DRC_TOOL>()->CrossProbe( static_cast<PCB_MARKER*>( aItem ) );
3007 break;
3008
3009 case PCB_POINT_T:
3010 break;
3011
3012 default:
3013 break;
3014 }
3015}
3016
3017
3019{
3020 // For now we just delegate to the base implementation which commits any pending
3021 // local history snapshots. If PCB-specific preconditions are later needed (e.g.
3022 // flushing zone fills or router state) they can be added here before calling the
3023 // base class method.
3025}
const KICOMMON_API wxEventTypeTag< wxCommandEvent > EDA_EVT_PLUGIN_AVAILABILITY_CHANGED
Notifies other parts of KiCad when plugin availability changes.
@ KEEP_ENDPOINTS_OR_START_DIRECTION
Whe editing endpoints, the other end remains in place.
@ KEEP_CENTER_ENDS_ADJUST_ANGLE
When editing endpoints, only the angle is adjusted.
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
When editing endpoints, the angle and radius are adjusted.
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition bitmap.cpp:100
HIGH_CONTRAST_MODE
Determine how inactive layers should be displayed.
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
@ HIDDEN
Inactive layers are hidden.
constexpr BOX2I BOX2ISafe(const BOX2D &aInput)
Definition box2.h:925
BOX2< VECTOR2D > BOX2D
Definition box2.h:919
static TOOL_ACTION toggleGrid
Definition actions.h:194
static TOOL_ACTION paste
Definition actions.h:76
static TOOL_ACTION unselectAll
Definition actions.h:79
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition actions.h:223
static TOOL_ACTION togglePolarCoords
Definition actions.h:205
static TOOL_ACTION copy
Definition actions.h:74
static TOOL_ACTION pluginsReload
Definition actions.h:290
static TOOL_ACTION selectSetLasso
Definition actions.h:217
static TOOL_ACTION selectSetRect
Set lasso selection mode.
Definition actions.h:216
static TOOL_ACTION group
Definition actions.h:235
static TOOL_ACTION pasteSpecial
Definition actions.h:77
static TOOL_ACTION groupProperties
Definition actions.h:243
static TOOL_ACTION pointEditorArcKeepCenter
Definition actions.h:269
static TOOL_ACTION ungroup
Definition actions.h:236
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:153
static TOOL_ACTION pointEditorArcKeepRadius
Definition actions.h:271
static TOOL_ACTION showSearch
Definition actions.h:112
static TOOL_ACTION undo
Definition actions.h:71
static TOOL_ACTION duplicate
Definition actions.h:80
static TOOL_ACTION highContrastMode
Definition actions.h:151
static TOOL_ACTION embeddedFiles
Definition actions.h:293
static TOOL_ACTION measureTool
Definition actions.h:248
static TOOL_ACTION doDelete
Definition actions.h:81
static TOOL_ACTION selectionTool
Definition actions.h:247
static TOOL_ACTION save
Definition actions.h:54
static TOOL_ACTION zoomFitScreen
Definition actions.h:138
static TOOL_ACTION redo
Definition actions.h:72
static TOOL_ACTION deleteTool
Definition actions.h:82
static TOOL_ACTION zoomTool
Definition actions.h:142
static TOOL_ACTION showProperties
Definition actions.h:262
static TOOL_ACTION cut
Definition actions.h:73
static TOOL_ACTION gridSetOrigin
Definition actions.h:191
static TOOL_ACTION toggleGridOverrides
Definition actions.h:195
static TOOL_ACTION selectAll
Definition actions.h:78
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition actions.h:270
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 OnColorThemeChanged()
Respond to change in OS's DarkMode.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
The array tool.
Definition array_tool.h:44
Tool responsible for automagic placement of components.
Handles how to draw a screen (a board, a schematic ...)
Definition base_screen.h:37
int GetPageCount() const
Definition base_screen.h:68
bool IsContentModified() const
Definition base_screen.h:56
const wxString & GetPageNumber() const
virtual 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,...
Handle actions specific to the board editor in PcbNew.
Tool for pcb inspection.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:81
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition board_item.h:347
Bridges BOARD's listener stream into the generic TEXT_VAR_TRACKER.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:373
void BuildListOfNets()
Definition board.h:1057
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition board.cpp:1100
void RemoveAllListeners()
Remove all listeners.
Definition board.cpp:3615
const PAGE_INFO & GetPageSettings() const
Definition board.h:897
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
Definition board.cpp:1094
void InitializeClearanceCache()
Initialize the clearance cache for all board items.
Definition board.cpp:1168
void SaveToHistory(const wxString &aProjectPath, std::vector< HISTORY_FILE_DATA > &aFileData)
Serialize board into HISTORY_FILE_DATA for non-blocking history commit.
Definition board.cpp:4086
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition board.cpp:201
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition board.cpp:3055
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition board.cpp:211
const wxString & GetFileName() const
Definition board.h:410
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition board.cpp:1106
void ClearProject()
Definition board.cpp:252
bool IsEmpty() const
Definition board.cpp:662
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition board.cpp:2519
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition board.cpp:1034
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition board.cpp:360
void SynchronizeTuningProfileProperties()
Ensure that all time domain properties providers are in sync with current settings.
Definition board.cpp:3049
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:642
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:554
void SetColor(int aLayer, const COLOR4D &aColor)
COLOR4D GetColor(int aLayer) const
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Definition commit.h:74
Handle actions that are shared between different applications.
AUTO_BACKUP m_Backup
Handles action that are shared between different applications.
enum FP_PROPS_RETVALUE GetReturnValue()
Dialog that offers to migrate obsolete WRL 3D model references on a loaded board to current STEP mode...
static int AutoMigrateByFilename(PCB_EDIT_FRAME *aFrame)
Silently rewrite unresolvable .wrl/.wrz references to STEP files whose filename stem matches in the s...
static int CountUnresolvedWrlReferences(PCB_EDIT_FRAME *aFrame)
Count of unique unresolvable .wrl/.wrz references on the board (deduplicated by filename).
int ShowModal() override
Tool responsible for displaying an overlay of incremental phase difference between differential pair ...
Tool responsible for drawing graphical elements like lines, arcs, circles, etc.
MODE GetDrawingMode() const
Return the current drawing mode of the DRAWING_TOOL or MODE::NONE if not currently in any drawing mod...
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
std::shared_ptr< DRC_ENGINE > GetDRCEngine()
Definition drc_tool.h:83
bool IsDRCRunning() const
Check to see if the DRC engine is running the tests.
Definition drc_tool.h:70
void SetSheetPath(const std::string &aSheetPath)
Set the sheet path displayed in the title block.
void SetSheetCount(int aSheetCount)
Change the sheet-count number displayed in the title block.
void SetVariantName(const std::string &aVariant)
Set the current variant name and description to be shown on the drawing sheet.
void SetVariantDesc(const std::string &aVariantDesc)
void SetPageNumber(const std::string &aPageNumber)
Change the page number displayed in the title block.
void SetSheetName(const std::string &aSheetName)
Set the sheet name displayed in the title block.
void SetIsFirstPage(bool aIsFirstPage)
Change if this is first page.
void AttachToTracker(TEXT_VAR_TRACKER *aTracker)
Register this proxy with aTracker as a dependent on every title-block source variable its current tem...
void SetFileName(const std::string &aFileName)
Set the file name displayed in the title block.
virtual bool doAutoSave()
This should be overridden by the derived class to handle the auto save feature.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void ThemeChanged()
Process light/dark theme change.
WX_INFOBAR * m_infoBar
wxAuiManager m_auimgr
virtual bool CanAcceptApiCommands()
Check if this frame is ready to accept API commands.
virtual void RecreateToolbars()
virtual void OnSize(wxSizeEvent &aEvent)
virtual bool canCloseWindow(wxCloseEvent &aCloseEvent)
virtual int GetUndoCommandCount() const
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
WX_INFOBAR * GetInfoBar()
static std::vector< const PLUGIN_ACTION * > GetOrderedPluginActions(PLUGIN_ACTION_SCOPE aScope, APP_SETTINGS_BASE *aCfg)
Return ordered list of plugin actions for display in the toolbar.
static const wxString AppearancePanelName()
virtual wxString GetFullScreenDesc() const
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Change the current rendering backend.
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual wxString GetScreenDesc() const
static const wxString PropertiesPaneName()
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
NET_INSPECTOR_PANEL * m_netInspectorPanel
static const wxString NetInspectorPanelName()
SEARCH_PANE * m_searchPane
static const wxString DesignBlocksPaneName()
PROPERTIES_PANEL * m_propertiesPanel
virtual void UpdateProperties()
static constexpr GAL_TYPE GAL_FALLBACK
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetFocus() override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
Specialization of the wxAuiPaneInfo class for KiCad panels.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:89
SELECTION_CONDITION NoActiveTool()
Create a functor testing if there are no tools active in the frame.
SELECTION_CONDITION BoundingBoxes()
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION PolarCoordinates()
Create a functor testing if polar coordinates are current being used.
SELECTION_CONDITION GridOverrides()
Create a functor testing if the grid overrides wires is enabled in a frame.
The interactive edit tool.
Definition edit_tool.h:52
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition property.h:727
static ENUM_MAP< T > & Instance()
Definition property.h:721
ENUM_MAP & Undefined(T aValue)
Definition property.h:734
wxPGChoices & Choices()
Definition property.h:772
void LoadFootprintFromLibrary(LIB_ID aFPID)
bool LoadFootprintFromBoard(FOOTPRINT *aFootprint)
Load a footprint from the main board into the Footprint Editor.
Component library viewer main window.
const LIB_ID & GetFPID() const
Definition footprint.h:441
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
bool Contains(GAL_LAYER_ID aPos)
Definition layer_ids.h:435
Handle actions specific to filling copper zones.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
virtual const wxString Problem() const
what was the problem?
virtual const wxString Where() const
where did the Problem() occur?
void RegisterHandler(API_HANDLER *aHandler)
Adds a new request handler to the server.
void DeregisterHandler(API_HANDLER *aHandler)
Read the new s-expression based KiCad netlist format.
virtual void LoadNetlist() override
Load the contents of the netlist file into aNetlist.
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:91
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition pcb_view.cpp:87
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:82
bool IsBOARD_ITEM() const
Definition view_item.h:98
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
double GetScale() const
Definition view.h:281
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition view.cpp:597
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition view.cpp:1835
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition view.h:405
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition view.cpp:1686
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition view.h:657
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition view.cpp:1702
An implementation of class VIEW_CONTROLS for wxWidgets library.
std::unique_ptr< PROF_COUNTER > m_MotionEventCounter
Definition kiid.h:44
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
void OnSockRequestServer(wxSocketEvent &evt)
void OnSockRequest(wxSocketEvent &evt)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:311
void OnKiCadExit()
Definition kiway.cpp:796
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:398
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr, bool aFromOtherThread=false)
Send aPayload to aDestination from aSource.
Definition kiway.cpp:496
LOCAL_HISTORY & LocalHistory()
Return the LOCAL_HISTORY associated with this KIWAY.
Definition kiway.h:422
virtual void CommonSettingsChanged(int aFlags=0)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition kiway.cpp:590
PCB_LAYER_ID GetLayerA() const
PCB_LAYER_ID GetLayerB() const
bool CommitDuplicateOfLastSave(const wxString &aProjectPath, const wxString &aFileType, const wxString &aMessage)
Create a new commit duplicating the tree pointed to by Last_Save_<fileType> and move the Last_Save_<f...
void RegisterSaver(const void *aSaverObject, const std::function< void(const wxString &, std::vector< HISTORY_FILE_DATA > &)> &aSaver)
Register a saver callback invoked during autosave history commits.
bool Init(const wxString &aProjectPath)
Initialize the local history repository for the given project path.
void NoteFileChange(const wxString &aFile)
Record that a file has been modified and should be included in the next snapshot.
void UnregisterSaver(const void *aSaverObject)
Unregister a previously registered saver callback.
void RemoveAutosaveFiles(const wxString &aProjectPath) const
Remove every autosave file under the project at aProjectPath regardless of which source it shadowed.
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition lset.cpp:309
static const LSET & AllLayersMask()
Definition lset.cpp:637
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition lset.cpp:184
@ MARKER_DRAWING_SHEET
Definition marker_base.h:52
Tool responsible for adding microwave features to PCBs.
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition pad.h:61
void SetInitialPage(const wxString &aPage, const wxString &aParentPage=wxEmptyString)
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
DISPLAY_OPTIONS m_Display
EDA_ANGLE m_RotationAngle
ARC_EDIT_MODE m_ArcEditMode
AUI_PANELS m_AuiPanels
Gather all the actions that are shared by tools.
Definition pcb_actions.h:47
static TOOL_ACTION drawRuleArea
static TOOL_ACTION microwaveCreateGap
static TOOL_ACTION drawBezier
static TOOL_ACTION placeText
static TOOL_ACTION drawOrthogonalDimension
static TOOL_ACTION drawRectangle
static TOOL_ACTION padDisplayMode
static TOOL_ACTION placeReferenceImage
static TOOL_ACTION showRatsnest
static TOOL_ACTION showLayersManager
static TOOL_ACTION toggleNetHighlight
static TOOL_ACTION saveSelectionAsDesignBlock
static TOOL_ACTION drawCircle
static TOOL_ACTION mirrorH
Mirroring of selected items.
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
static TOOL_ACTION tuneDiffPair
static TOOL_ACTION saveToLinkedDesignBlock
static TOOL_ACTION layerChanged
static TOOL_ACTION grabUnconnected
Select and move nearest unconnected footprint from ratsnest of selection.
Definition pcb_actions.h:90
static TOOL_ACTION ddAppendBoard
Drag and drop.
static TOOL_ACTION drawEllipseArc
static TOOL_ACTION highlightNet
static TOOL_ACTION autoTrackWidth
static TOOL_ACTION drawTable
static TOOL_ACTION drawTextBox
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
static TOOL_ACTION routerWalkaroundMode
static TOOL_ACTION routerShoveMode
static TOOL_ACTION drawZoneCutout
static TOOL_ACTION drawPolygon
static TOOL_ACTION hideNetInRatsnest
static TOOL_ACTION zoneDisplayFilled
static TOOL_ACTION showNetInRatsnest
static TOOL_ACTION drawRadialDimension
static TOOL_ACTION tuneSingleTrack
static TOOL_ACTION viaDisplayMode
static TOOL_ACTION drawLeader
static TOOL_ACTION angleSnapModeChanged
Notification event when angle mode changes.
static TOOL_ACTION saveBoardAsDesignBlock
static TOOL_ACTION drillOrigin
static TOOL_ACTION tuneSkew
static TOOL_ACTION trackDisplayMode
static TOOL_ACTION showNetInspector
static TOOL_ACTION microwaveCreateStubArc
static TOOL_ACTION drawEllipse
static TOOL_ACTION zoneDisplayTriangulated
static TOOL_ACTION placeDesignBlock
static TOOL_ACTION selectUnconnected
Select unconnected footprints from ratsnest of selection.
Definition pcb_actions.h:87
static TOOL_ACTION zoneDisplayFractured
static TOOL_ACTION drawVia
static TOOL_ACTION drawArc
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
static TOOL_ACTION drawSimilarZone
static TOOL_ACTION showDesignBlockPanel
static TOOL_ACTION drawCenterDimension
static TOOL_ACTION selectSameSheet
Select all components on the same sheet as the selected footprint.
Definition pcb_actions.h:96
static TOOL_ACTION microwaveCreateStub
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
Definition pcb_actions.h:78
static TOOL_ACTION ddImportGraphics
static TOOL_ACTION microwaveCreateLine
static TOOL_ACTION flipBoard
static TOOL_ACTION zoneDisplayOutline
static TOOL_ACTION ratsnestLineMode
static TOOL_ACTION textOutlines
Display texts as lines.
static TOOL_ACTION highlightNetSelection
static TOOL_ACTION microwaveCreateFunctionShape
static TOOL_ACTION placePoint
static TOOL_ACTION zoneMerge
static TOOL_ACTION mirrorV
static TOOL_ACTION unlock
static TOOL_ACTION placeFootprint
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
static TOOL_ACTION createArray
Tool for creating an array of objects.
static TOOL_ACTION showDiffPhaseSkew
Display of phase skew between differential pair tracks.
static TOOL_ACTION deselectNet
Remove all connections belonging to a single net from the active selection.
Definition pcb_actions.h:81
static TOOL_ACTION drawLine
static TOOL_ACTION placeLinkedDesignBlock
static TOOL_ACTION localRatsnestTool
static TOOL_ACTION rotateCw
Rotation of selected objects.
static TOOL_ACTION rotateCcw
static TOOL_ACTION drawAlignedDimension
static TOOL_ACTION drawZone
static TOOL_ACTION selectOnSchematic
Select symbols/pins on schematic corresponding to selected footprints/pads.
Definition pcb_actions.h:99
static TOOL_ACTION lock
Common, abstract interface for edit frames.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
int ShowTextBoxPropertiesDialog(PCB_TEXTBOX *aTextBox)
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
bool UndoRedoBlocked() const
Check if the undo and redo operations are currently blocked.
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
virtual void SetBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr) override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
std::unique_ptr< LAYER_PAIR_SETTINGS > m_layerPairSettings
APPEARANCE_CONTROLS * GetAppearancePanel()
APPEARANCE_CONTROLS * m_appearancePanel
void ShowReferenceImagePropertiesDialog(BOARD_ITEM *aBitmap)
PANEL_SELECTION_FILTER * m_selectionFilterPanel
void ShowBarcodePropertiesDialog(PCB_BARCODE *aText)
void ShowGraphicItemPropertiesDialog(PCB_SHAPE *aShape)
void ActivateGalCanvas() override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void ShowPadPropertiesDialog(PAD *aPad)
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
EDA_ITEM * ResolveItem(const KIID &aId, bool aAllowNullptrReturn=false) const override
Fetch an item by KIID.
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
virtual void SetPageSettings(const PAGE_INFO &aPageSettings) override
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Return the BOARD_DESIGN_SETTINGS for the open project.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
Handle actions that are shared between different frames in PcbNew.
Definition pcb_control.h:43
Handle design block actions in the PCB editor.
bool m_FlipBoardView
true if the board is flipped to show the mirrored view
double m_ZoneOpacity
Opacity override for filled zone areas.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
void UpdateColors()
Update the color settings in the painter and GAL.
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
void SetDrawingSheet(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Sets (or updates) drawing-sheet used by the draw panel.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void SyncLayersVisibility(const BOARD *aBoard)
Update "visibility" property of each layer of a given BOARD.
virtual void SetHighContrastLayer(int aLayer) override
SetHighContrastLayer(), with some extra smarts for PCB.
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
Group generic conditions for PCB editor states.
SELECTION_CONDITION PadFillDisplay()
Create a functor that tests if the frame fills the pads.
SELECTION_CONDITION TrackFillDisplay()
Create a functor that tests if the frame fills tracks.
SELECTION_CONDITION HasItems()
Create a functor that tests if there are items in the board.
SELECTION_CONDITION GraphicsFillDisplay()
Create a functor that tests if the frame fills graphics items.
SELECTION_CONDITION ZoneDisplayMode(ZONE_DISPLAY_MODE aMode)
Create a functor that tests the current zone display mode in the frame.
SELECTION_CONDITION ViaFillDisplay()
Create a functor that tests if the frame fills vias.
SELECTION_CONDITION TextFillDisplay()
Create a functor that tests if the frame fills text items.
The main frame for Pcbnew.
void HardRedraw() override
Rebuild the GAL and redraws the screen.
void OnDisplayOptionsChanged() override
std::size_t m_textVarListenerHandle
Reactive text-var invalidation listener state.
static bool GetPluginActionButtonVisible(const wxString &aPluginPath, bool aPluginDefault)
Return true if button visibility action plugin setting was set to true or it is unset and plugin defa...
void OnEditItemRequest(BOARD_ITEM *aItem) override
Install the corresponding dialog editor for the given item.
Definition edit.cpp:95
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
bool interactiveOperationInProgress() const
Return true when an interactive tool operation (routing, dragging, point editing, zone filling,...
int m_crossProbeFlashPhase
Phase counter.
void FindNext(bool reverse=false)
Find the next item using our existing search parameters.
void ResolveDRCExclusions(bool aCreateMarkers)
If aCreateMarkers then create DRC exclusion markers from the serialized data.
void SetBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr) override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS.
void OnModify() override
Must be called after a board change to set the modified flag.
void ThemeChanged() override
Called when light/dark theme is changed.
void SwitchLayer(PCB_LAYER_ID layer) override
Change the active layer in the editor.
Definition edit.cpp:68
wxTimer m_crossProbeFlashTimer
Timer to toggle selection visibility for flash.
void StartCrossProbeFlash(const std::vector< BOARD_ITEM * > &aItems)
void OnCrossProbeFlashTimer(wxTimerEvent &aEvent)
std::unique_ptr< API_HANDLER_PCB > m_apiHandler
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void UpdateVariantSelectionCtrl()
Update the variant selection dropdown with the current board's variant names.
bool DoAutoSave()
Perform auto save when the board has been modified and not saved within the auto save interval.
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Change the visibility of an element category.
DIALOG_BOOK_REPORTER * m_inspectDrcErrorDlg
void OnClearFileHistory(wxCommandEvent &aEvent)
std::unique_ptr< GRID_HELPER > MakeGridHelper() override
virtual ~PCB_EDIT_FRAME()
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
Switch currently used canvas (Cairo / OpenGL).
void CommonSettingsChanged(int aFlags) override
Called after the preferences dialog is run.
void ShowFindByPropertiesDialog()
Show the Find by Properties dialog.
BOARD_ITEM_CONTAINER * GetModel() const override
DIALOG_BOOK_REPORTER * GetInspectDrcErrorDialog()
void ShowTargetOptionsDialog(PCB_TARGET *aTarget)
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString, wxWindow *aParent=nullptr)
DIALOG_FIND * m_findDialog
DIALOG_BOOK_REPORTER * m_inspectConstraintsDlg
void SetPageSettings(const PAGE_INFO &aPageSettings) override
bool IsElementVisible(GAL_LAYER_ID aElement) const
Test whether a given element category is visible.
bool CanAcceptApiCommands() override
Check if this frame is ready to accept API commands.
static int activeLayerUpdateFlags(const BOARD_ITEM *aItem, PCB_LAYER_ID aOldLayer, PCB_LAYER_ID aNewLayer, HIGH_CONTRAST_MODE aContrastMode)
View update flags an item needs when the active layer changes. Static for testing.
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
void SetGridColor(const COLOR4D &aColor) override
void ProjectChanged() override
Notification event that the project has changed.
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
void doCloseWindow() override
WX_INFOBAR * m_loadNoticeInfoBar
Secondary infobar that stacks above the main one; reserved for load-time notices (currently the WRL -...
void ReCreateLayerBox(bool aForceResizeToolbar=true)
Recreate the layer box by clearing the old list and building a new one from the new layer names and c...
void SaveProjectLocalSettings() override
Save changes to the project local settings.
static std::vector< const PLUGIN_ACTION * > GetOrderedPluginActions()
Return ordered list of plugins in sequence in which they should appear on toolbar or in settings.
void detachTextVarTracker()
Drop every cached reference into the current BOARD's text-var tracker.
void onPluginAvailabilityChanged(wxCommandEvent &aEvt)
void PrepareLayerIndicator(bool aForceRebuild=false)
void ShowFindDialog()
Show the Find dialog.
void onSize(wxSizeEvent &aEvent)
int ShowExchangeFootprintsDialog(FOOTPRINT *aFootprint, bool aUpdateMode, bool aSelectedMode)
int TestStandalone()
Test if standalone mode.
void ShowFootprintPropertiesDialog(FOOTPRINT *aFootprint)
void UpdateProperties() override
bool canRunAutoSave() const override
Return true when it is safe to run an autosave snapshot right now.
bool IsContentModified() const override
Get if the current board has been modified but not saved.
bool Clear_Pcb(bool doAskAboutUnsavedChanges, bool aFinal=false)
Delete all and reinitialize the current board.
Definition initpcb.cpp:38
bool m_crossProbeFlashing
Currently flashing guard.
TOOL_ACTION * m_exportNetlistAction
The export board netlist tool action object.
void OnBoardLoaded()
Update the state of the GUI after a new board is loaded or created.
void ReCreateAuxiliaryToolbar() override
void Edit_Zone_Params(ZONE *zone_container)
Edit params (layer, clearance, ...) for a zone outline.
bool FetchNetlistFromSchematic(NETLIST &aNetlist, const wxString &aAnnotateMessage)
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
DIALOG_BOOK_REPORTER * GetFootprintDiffDialog()
EDA_ANGLE GetRotationAngle() const override
Return the angle used for rotate operations.
COLOR4D GetGridColor() override
std::vector< KIID > m_crossProbeFlashItems
Items to flash (by UUID)
void UpdateTitle()
Set the main window title bar text.
DIALOG_BOOK_REPORTER * m_footprintDiffDlg
void ActivateGalCanvas() override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
void onVariantSelected(wxCommandEvent &aEvent)
Event handler for variant selection changes in the toolbar.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void OnQuit(wxCommandEvent &event)
void NotifyFindByPropertiesDialog()
Notify the Find by Properties dialog that the selection has changed.
void onCloseModelessBookReporterDialogs(wxCommandEvent &aEvent)
PCB_DESIGN_BLOCK_PANE * m_designBlocksPane
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
DIALOG_BOARD_SETUP * m_boardSetupDlg
DIALOG_BOOK_REPORTER * GetInspectClearanceDialog()
wxTimer * m_eventCounterTimer
void Tracks_and_Vias_Size_Event(wxCommandEvent &event)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
static const wxString SearchPaneName()
DIALOG_FIND_BY_PROPERTIES * m_findByPropertiesDialog
DIALOG_BOOK_REPORTER * m_inspectClearanceDlg
void OnFileHistory(wxCommandEvent &event)
DIALOG_BOOK_REPORTER * GetInspectConstraintsDialog()
class TEXT_VAR_TRACKER * m_textVarListenerTracker
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:49
PCB net inspection panel.
Generic tool for picking an item.
Tool that displays edit points allowing to modify items by dragging the points.
PCB_LAYER_ID m_Route_Layer_TOP
Definition pcb_screen.h:39
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition pcb_screen.h:40
static bool HasUnlockedItems(const SELECTION &aSelection)
Test if any selected items are unlocked.
static bool HasLockedItems(const SELECTION &aSelection)
Test if any selected items are locked.
The selection tool: currently supports:
int ClearSelection(const TOOL_EVENT &aEvent)
void FindItem(BOARD_ITEM *aItem)
Take necessary actions to mark an item as found.
Tool useful for viewing footprints.
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:553
KICAD_API_SERVER & GetApiServer()
Definition pgm_base.h:142
virtual const wxString & GetExecutablePath() const
Definition pgm_base.cpp:879
The interactive edit tool.
void Show(std::ostream &aStream=std::cerr)
Definition profile.h:284
void Reset()
Definition profile.h:274
A progress reporter interface for use in multi-threaded environments.
The backing store for a PROJECT, in JSON format.
std::vector< LAYER_PAIR_INFO > m_LayerPairInfos
List of stored 3D viewports (view matrixes)
The project local settings are things that are attached to a particular project, but also might be pa...
wxString m_ActiveLayerPreset
The name of a LAYER_PRESET that is currently activated (or blank if none)
PCB_LAYER_ID m_ActiveLayer
The current (active) board layer for editing.
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition project.cpp:183
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition project.h:206
void IncrementNetclassesTicker()
Definition project.h:114
virtual PROJECT_FILE & GetProjectFile() const
Definition project.h:200
void IncrementTextVarsTicker()
Definition project.h:111
Action handler for the Properties panel.
PNS::PNS_MODE GetRouterMode()
bool RoutingInProgress()
Returns whether routing is currently active.
static SELECTION_CONDITION HasTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if among the selected items there is at least one of a given types.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
int AddItemToSel(const TOOL_EVENT &aEvent)
EDA_ITEM * Front() const
Definition selection.h:173
int Size() const
Returns the number of selected parts.
Definition selection.h:117
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition richio.h:222
Coordinates the dependency index with change notifications.
ListenerHandle AddInvalidateListener(InvalidateCallback aCallback)
Register a listener that fires for every invalidation.
static constexpr ListenerHandle INVALID_LISTENER
TOOL_MANAGER * m_toolManager
TOOL_DISPATCHER * m_toolDispatcher
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
ACTIONS * m_actions
Represent a single user action.
Base abstract interface for all kinds of tools.
Definition tool_base.h:62
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:76
Generic, UI-independent tool event.
Definition tool_event.h:167
void SetHasPosition(bool aHasPosition)
Definition tool_event.h:257
Master controller class:
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
TOOL_BASE * GetCurrentTool() const
Return the tool that is on the top of the active tools stack (was invoked the most recently).
A modified version of the wxInfoBar class that allows us to:
Definition wx_infobar.h:77
Handle actions specific to filling copper zones.
PROGRESS_REPORTER * GetProgressReporter()
A type-safe container of any type.
Definition ki_any.h:92
@ ZIP
Zip archive snapshots; autosave uses recovery files.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition confirm.cpp:146
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
int GetLastUnsavedChangesResponse()
Return the result code from the last call to HandleUnsavedChanges(): wxID_YES, wxID_NO or wxID_CANCEL...
Definition confirm.cpp:159
This file is part of the common library.
#define CHECK(x)
#define ENABLE(x)
#define DIALOG_DRC_WINDOW_NAME
Definition dialog_drc.h:40
#define DIALOG_DRC_RULE_EDITOR_WINDOW_NAME
#define _(s)
Declaration of the eda_3d_viewer class.
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:413
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define PCB_EDIT_FRAME_NAME
static const std::vector< KICAD_T > footprintTypes
static const std::vector< KICAD_T > groupTypes
static const std::vector< KICAD_T > trackTypes
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
#define CURRENT_EDIT_TOOL(action)
Collection of reusable/testable functions for footprint manipulation.
@ FRAME_PCB_EDITOR
Definition frame_type.h:38
@ FRAME_FOOTPRINT_VIEWER
Definition frame_type.h:41
@ FRAME_SCH
Definition frame_type.h:30
@ FRAME_FOOTPRINT_CHOOSER
Definition frame_type.h:40
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:39
a few functions useful in geometry calculations.
static const std::string LegacySchematicFileExtension
static const std::string LegacyPcbFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string SVGFileExtension
static const std::string KiCadPcbFileExtension
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
const wxChar *const traceCrossProbeFlash
Flag to enable debug output for cross-probe flash operations.
const wxChar *const traceApi
Flag to enable debug output related to the IPC API and its plugin system.
Definition api_utils.cpp:29
@ ID_ON_GRID_SELECT
Definition id.h:112
@ ID_FILE_LIST_CLEAR
Definition id.h:58
@ ID_EDA_SOCKET_EVENT
Definition id.h:132
@ ID_EDA_SOCKET_EVENT_SERV
Definition id.h:131
@ ID_ON_ZOOM_SELECT
Definition id.h:111
@ ID_FILEMAX
Definition id.h:56
@ ID_FILE1
Definition id.h:55
PROJECT & Prj()
Definition kicad.cpp:728
EVT_MENU(ID_COMPARE_PROJECT_BRANCHES, KICAD_MANAGER_FRAME::OnCompareProjectBranches) KICAD_MANAGER_FRAME
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
Definition layer_ids.h:852
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:675
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition layer_ids.h:224
@ LAYER_GRID
Definition layer_ids.h:250
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored).
Definition layer_ids.h:291
@ LAYER_RATSNEST
Definition layer_ids.h:249
#define CLEARANCE_LAYER_FOR(boardLayer)
Definition layer_ids.h:369
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_Paste
Definition layer_ids.h:100
@ B_Mask
Definition layer_ids.h:94
@ B_Cu
Definition layer_ids.h:61
@ F_Mask
Definition layer_ids.h:93
@ B_Paste
Definition layer_ids.h:101
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ F_Cu
Definition layer_ids.h:60
@ MAIL_SCH_GET_NETLIST
Definition mail_type.h:46
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:54
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:51
@ ALL
All except INITIAL_ADD.
Definition view_item.h:55
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition definitions.h:34
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition unix/app.cpp:102
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition unix/app.cpp:91
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
@ RM_Walkaround
Only walk around.
@ RM_Shove
Only shove.
#define _HKI(x)
Definition page_info.cpp:40
BARCODE class definition.
#define FOOTPRINT_DIFF_DIALOG_NAME
EVT_MENU_RANGE(ID_POPUP_PCB_SELECT_WIDTH_START_RANGE, ID_POPUP_PCB_SELECT_WIDTH_END_RANGE, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event) EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_WIDTH1
ID_POPUP_PCB_SELECT_WIDTH8
#define INSPECT_CLEARANCE_DIALOG_NAME
PCB_EDIT_FRAME::OnUpdateSelectTrackWidth EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE8, PCB_EDIT_FRAME::OnUpdateSelectViaSize) PCB_EDIT_FRAME
#define INSPECT_DRC_ERROR_DIALOG_NAME
#define INSPECT_CONSTRAINTS_DIALOG_NAME
@ ID_POPUP_PCB_SELECT_WIDTH_START_RANGE
Definition pcbnew_id.h:20
@ ID_POPUP_PCB_SELECT_WIDTH1
Definition pcbnew_id.h:24
@ ID_POPUP_PCB_SELECT_VIASIZE8
Definition pcbnew_id.h:47
@ ID_AUX_TOOLBAR_PCB_VARIANT_SELECT
Definition pcbnew_id.h:19
@ ID_AUX_TOOLBAR_PCB_VIA_SIZE
Definition pcbnew_id.h:17
@ ID_POPUP_PCB_SELECT_WIDTH_END_RANGE
Definition pcbnew_id.h:77
@ ID_POPUP_PCB_SELECT_VIASIZE1
Definition pcbnew_id.h:40
@ ID_AUX_TOOLBAR_PCB_TRACK_WIDTH
Definition pcbnew_id.h:18
@ SHOW_WITH_VIA_ALWAYS
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
LAST_PATH_TYPE
For storing PcbNew MRU paths of various types.
@ RPT_SEVERITY_EXCLUSION
#define SKIP_SET_DIRTY
Definition sch_commit.h:38
#define SKIP_UNDO
Definition sch_commit.h:36
#define CURRENT_TOOL(action)
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
KIWAY Kiway(KFCTL_STANDALONE)
wxString UnescapeString(const wxString &aSource)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
A min-max version of BOX2 for fast intersection checking.
Definition box2_minmax.h:33
bool Intersects(const BOX2I_MINMAX &aOther) const
Definition box2_minmax.h:69
BACKUP_FORMAT format
Backup format (incremental git history vs zip archives)
A filename or source description, a problem input line, a line number, a byte offset,...
TRACK_CLEARANCE_MODE m_TrackClearance
Identifies a single resolvable source that a text item's ${...} reference depends on.
else
IbisParser parser & reporter
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition tool_action.h:45
@ AS_ACTIVE
All active tools.
Definition tool_action.h:44
@ TA_MODEL_CHANGE
Model has changed (partial update).
Definition tool_event.h:117
@ TC_COMMAND
Definition tool_event.h:53
#define TEXTVARS_CHANGED
wxLogTrace helper definitions.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:81
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:99
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:96
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:84
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:90
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:97
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:104
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:86
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:101
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:85
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:82
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:83
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition typeinfo.h:92
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:94
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:100
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:79
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:95
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:80
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:91
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:87
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
Definition typeinfo.h:106
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:89
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:98
Definition of file extensions used in Kicad.
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.
WX_VIEW_CONTROLS class definition.