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 along
20 * with this program. If not, see <http://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/socket.h>
33#include <wx/wupdlock.h>
34
35#include <advanced_config.h>
37#include <kiface_base.h>
38#include <kiway.h>
41#include <pgm_base.h>
42#include <pcb_edit_frame.h>
46#include <bitmaps.h>
47#include <confirm.h>
48#include <footprint.h>
49#include <footprint_utils.h>
50#include <lset.h>
51#include <trace_helpers.h>
52#include <pcbnew_id.h>
53#include <pcbnew_settings.h>
56#include <dialog_find.h>
60#include <dialog_board_setup.h>
64#include <pad.h>
65#include <pcb_target.h>
66#include <pcb_point.h>
67#include <pcb_track.h>
68#include <layer_pairs.h>
71#include <functional>
72#include <pcb_barcode.h>
73#include <pcb_painter.h>
78#include <local_history.h>
79#include <tool/tool_manager.h>
81#include <tool/action_toolbar.h>
82#include <tool/common_control.h>
83#include <tool/common_tools.h>
84#include <tool/embed_tool.h>
86#include <tool/selection.h>
87#include <tool/zoom_tool.h>
88#include <tools/array_tool.h>
93#include <tools/edit_tool.h>
97#include <tools/drc_tool.h>
100#include <tools/convert_tool.h>
101#include <tools/drawing_tool.h>
102#include <tools/pcb_control.h>
110#include <tools/pad_tool.h>
112#include <properties/property.h>
117#include <router/router_tool.h>
120#include <dialog_drc.h> // for DIALOG_DRC_WINDOW_NAME definition
125#include <widgets/wx_infobar.h>
129#include <widgets/wx_aui_utils.h>
130#include <kiplatform/app.h>
131#include <kiplatform/ui.h>
132#include <core/profile.h>
133#include <math/box2_minmax.h>
137#include <toolbars_pcb_editor.h>
139
140#ifdef KICAD_IPC_API
141#include <api/api_server.h>
142#include <api/api_handler_pcb.h>
144#include <api/api_utils.h>
145#endif
146
147#include <richio.h>
148
149using namespace std::placeholders;
150
151
152#define INSPECT_DRC_ERROR_DIALOG_NAME wxT( "InspectDrcErrorDialog" )
153#define INSPECT_CLEARANCE_DIALOG_NAME wxT( "InspectClearanceDialog" )
154#define INSPECT_CONSTRAINTS_DIALOG_NAME wxT( "InspectConstraintsDialog" )
155#define FOOTPRINT_DIFF_DIALOG_NAME wxT( "FootprintDiffDialog" )
156
157
158BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
161
164
165 EVT_SIZE( PCB_EDIT_FRAME::OnSize )
166
167 // Menu Files:
170
171 EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
172 EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
173
174 // Horizontal toolbar
178
179 // Tracks and vias sizes general options
181 PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
182
183 // User interface update event handlers.
184 EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
185 EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::OnUpdateSelectViaSize )
187 PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
189 PCB_EDIT_FRAME::OnUpdateSelectViaSize )
190 // Drop files event
191 EVT_DROP_FILES( PCB_EDIT_FRAME::OnDropFiles )
192END_EVENT_TABLE()
193
194
195PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
196 PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_EDITOR, _( "PCB Editor" ), wxDefaultPosition, wxDefaultSize,
198 m_exportNetlistAction( nullptr ),
199 m_findDialog( nullptr ),
200 m_findByPropertiesDialog( nullptr ),
201 m_inspectDrcErrorDlg( nullptr ),
202 m_inspectClearanceDlg( nullptr ),
203 m_inspectConstraintsDlg( nullptr ),
204 m_footprintDiffDlg( nullptr ),
205 m_boardSetupDlg( nullptr ),
206 m_designBlocksPane( nullptr ),
207 m_importProperties( nullptr ),
208 m_eventCounterTimer( nullptr )
209{
210 m_maximizeByDefault = true;
211 m_showBorderAndTitleBlock = true; // true to display sheet references
212 m_SelTrackWidthBox = nullptr;
213 m_SelViaSizeBox = nullptr;
214 m_CurrentVariantCtrl = nullptr;
215 m_ShowLayerManagerTools = true;
216 m_supportsAutoSave = true;
217 m_ProbingSchToPcb = false;
218 m_ShowSearch = false;
219 m_ShowNetInspector = false;
220 // Ensure timer has an owner before binding so it generates events.
221 m_crossProbeFlashTimer.SetOwner( this );
222 Bind( wxEVT_TIMER, &PCB_EDIT_FRAME::OnCrossProbeFlashTimer, this, m_crossProbeFlashTimer.GetId() );
223
224 // We don't know what state board was in when it was last saved, so we have to
225 // assume dirty
226 m_ZoneFillsDirty = true;
227
228 m_aboutTitle = _HKI( "KiCad PCB Editor" );
229
230 // Must be created before the menus are created.
231 if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist )
232 {
233 m_exportNetlistAction = new TOOL_ACTION( "pcbnew.EditorControl.exportNetlist",
234 AS_GLOBAL, 0, "", _( "Netlist..." ),
235 _( "Export netlist used to update schematics" ) );
236 }
237
238 // Create GAL canvas
239 auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
240 GetGalDisplayOptions(),
242
243 SetCanvas( canvas );
244 SetBoard( new BOARD() );
245
246 wxIcon icon;
247 wxIconBundle icon_bundle;
248
249 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 48 ) );
250 icon_bundle.AddIcon( icon );
251 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 128 ) );
252 icon_bundle.AddIcon( icon );
253 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 256 ) );
254 icon_bundle.AddIcon( icon );
255 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_32 ) );
256 icon_bundle.AddIcon( icon );
257 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_16 ) );
258 icon_bundle.AddIcon( icon );
259
260 SetIcons( icon_bundle );
261
262 // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
263 // initialize parameters in m_LayersManager
264 LoadSettings( config() );
265
266 SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ) ) );
267
268 // PCB drawings start in the upper left corner.
269 GetScreen()->m_Center = false;
270
271 setupTools();
272 setupUIConditions();
273
274 m_toolbarSettings = GetToolbarSettings<PCB_EDIT_TOOLBAR_SETTINGS>( "pcbnew-toolbars" );
275 configureToolbars();
276 RecreateToolbars();
277 PrepareLayerIndicator( true );
278
279 ReCreateMenuBar();
280
281#ifdef KICAD_IPC_API
283 &PCB_EDIT_FRAME::onPluginAvailabilityChanged, this );
284#endif
285
286 // Fetch a COPY of the config as a lot of these initializations are going to overwrite our
287 // data.
288 PCBNEW_SETTINGS::AUI_PANELS aui_cfg = GetPcbNewSettings()->m_AuiPanels;
289
290 m_propertiesPanel = new PCB_PROPERTIES_PANEL( this, this );
291 m_propertiesPanel->SetSplitterProportion( aui_cfg.properties_splitter );
292
293 m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
294
295 m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
296 m_searchPane = new PCB_SEARCH_PANE( this );
297 m_netInspectorPanel = new PCB_NET_INSPECTOR_PANEL( this, this );
298 m_designBlocksPane = new PCB_DESIGN_BLOCK_PANE( this, nullptr, m_designBlockHistoryList );
299
300 m_auimgr.SetManagedWindow( this );
301
302 CreateInfoBar();
303
304 unsigned int auiFlags = wxAUI_MGR_DEFAULT;
305#if !defined( _WIN32 )
306 // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
307 // of graphical glitches.
308 auiFlags |= wxAUI_MGR_LIVE_RESIZE;
309#endif
310 m_auimgr.SetFlags( auiFlags );
311
312 // Rows; layers 4 - 6
313 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( wxS( "TopMainToolbar" ) )
314 .Top().Layer( 6 ) );
315 m_auimgr.AddPane( m_tbTopAux, EDA_PANE().HToolbar().Name( wxS( "TopAuxToolbar" ) )
316 .Top().Layer( 5 ) );
317 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
318 .Bottom().Layer( 6 ) );
319
320 // Columns; layers 1 - 3
321 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( wxS( "LeftToolbar" ) )
322 .Left().Layer( 3 ) );
323
324 m_auimgr.AddPane( m_tbRight, EDA_PANE().VToolbar().Name( wxS( "RightToolbar" ) )
325 .Right().Layer( 3 ) );
326
327 m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( wxS( "LayersManager" ) )
328 .Right().Layer( 4 )
329 .Caption( _( "Appearance" ) ).PaneBorder( false )
330 // Don't use -1 for don't-change-height on a growable panel; it has side-effects.
331 .MinSize( m_appearancePanel->GetMinSize().x, FromDIP( 60 ) )
332#ifdef __WXMAC__
333 // Best size for this pane is calculated larger than necessary on wxMac
334 .BestSize( m_appearancePanel->GetMinSize().x, -1 )
335#else
336 .BestSize( m_appearancePanel->GetBestSize().x, -1 )
337#endif
338 .FloatingSize( m_appearancePanel->GetBestSize() )
339 .CloseButton( false ) );
340
341 m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Name( wxS( "SelectionFilter" ) )
342 .Right().Layer( 4 ).Position( 2 )
343 .Caption( _( "Selection Filter" ) ).PaneBorder( false )
344 // Fixed-size pane; -1 for MinSize height is required
345 .MinSize( m_selectionFilterPanel->GetMinSize().x, -1 )
346 .BestSize( m_selectionFilterPanel->GetBestSize().x, -1 )
347 .FloatingSize( m_selectionFilterPanel->GetBestSize() )
348 .CloseButton( false ) );
349
350 m_auimgr.AddPane( m_designBlocksPane, EDA_PANE().Name( DesignBlocksPaneName() )
351 .Right().Layer( 5 )
352 .Caption( _( "Design Blocks" ) )
353 .CaptionVisible( true )
354 .PaneBorder( true )
355 .TopDockable( false )
356 .BottomDockable( false )
357 .CloseButton( true )
358 .MinSize( FromDIP( wxSize( 240, 60 ) ) )
359 .BestSize( FromDIP( wxSize( 300, 200 ) ) )
360 .FloatingSize( FromDIP( wxSize( 800, 600 ) ) )
361 .FloatingPosition( FromDIP( wxPoint( 50, 200 ) ) )
362 .Show( true ) );
363
364 m_auimgr.AddPane( m_propertiesPanel, EDA_PANE().Name( PropertiesPaneName() )
365 .Left().Layer( 5 )
366 .Caption( _( "Properties" ) ).PaneBorder( false )
367 .MinSize( FromDIP( wxSize( 240, 60 ) ) )
368 .BestSize( FromDIP( wxSize( 300, 200 ) ) )
369 .FloatingSize( wxSize( 300, 200 ) )
370 .CloseButton( true ) );
371
372 // Center
373 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
374 .Center() );
375
376 m_auimgr.AddPane( m_netInspectorPanel, EDA_PANE().Name( NetInspectorPanelName() )
377 .Bottom()
378 .Caption( _( "Net Inspector" ) )
379 .PaneBorder( false )
380 .MinSize( FromDIP( wxSize( 240, 60 ) ) )
381 .BestSize( FromDIP( wxSize( 300, 200 ) ) )
382 .FloatingSize( wxSize( 300, 200 ) )
383 .CloseButton( true ) );
384
385 m_auimgr.AddPane( m_searchPane, EDA_PANE().Name( SearchPaneName() )
386 .Bottom()
387 .Caption( _( "Search" ) ).PaneBorder( false )
388 .MinSize( FromDIP( wxSize ( 180, 60 ) ) )
389 .BestSize( FromDIP( wxSize ( 180, 100 ) ) )
390 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
391 .DestroyOnClose( false )
392 .CloseButton( true ) );
393
394 RestoreAuiLayout();
395
396 m_auimgr.GetPane( "LayersManager" ).Show( m_ShowLayerManagerTools );
397 m_auimgr.GetPane( "SelectionFilter" ).Show( m_ShowLayerManagerTools );
398 m_auimgr.GetPane( PropertiesPaneName() ).Show( GetPcbNewSettings()->m_AuiPanels.show_properties );
399 m_auimgr.GetPane( NetInspectorPanelName() ).Show( m_ShowNetInspector );
400 m_auimgr.GetPane( SearchPaneName() ).Show( m_ShowSearch );
401 m_auimgr.GetPane( DesignBlocksPaneName() ).Show( GetPcbNewSettings()->m_AuiPanels.design_blocks_show );
402
403 // The selection filter doesn't need to grow in the vertical direction when docked
404 m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
405 FinishAUIInitialization();
406
407 if( aui_cfg.right_panel_width > 0 )
408 {
409 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( wxS( "LayersManager" ) );
410 SetAuiPaneSize( m_auimgr, layersManager, aui_cfg.right_panel_width, -1 );
411
412 wxAuiPaneInfo& designBlocksPane = m_auimgr.GetPane( DesignBlocksPaneName() );
413 SetAuiPaneSize( m_auimgr, designBlocksPane, aui_cfg.design_blocks_panel_docked_width, -1 );
414 }
415
416 if( aui_cfg.properties_panel_width > 0 && m_propertiesPanel )
417 {
418 wxAuiPaneInfo& propertiesPanel = m_auimgr.GetPane( PropertiesPaneName() );
419 SetAuiPaneSize( m_auimgr, propertiesPanel, aui_cfg.properties_panel_width, -1 );
420 }
421
422 if( aui_cfg.search_panel_height > 0
423 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_TOP
424 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
425 {
426 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
427 searchPane.Direction( aui_cfg.search_panel_dock_direction );
428 SetAuiPaneSize( m_auimgr, searchPane, -1, aui_cfg.search_panel_height );
429 }
430 else if( aui_cfg.search_panel_width > 0
431 && ( aui_cfg.search_panel_dock_direction == wxAUI_DOCK_LEFT
432 || aui_cfg.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
433 {
434 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
435 searchPane.Direction( aui_cfg.search_panel_dock_direction );
436 SetAuiPaneSize( m_auimgr, searchPane, aui_cfg.search_panel_width, -1 );
437 }
438
439 m_appearancePanel->SetTabIndex( aui_cfg.appearance_panel_tab );
440
441 {
442 m_layerPairSettings = std::make_unique<LAYER_PAIR_SETTINGS>();
443
444 m_layerPairSettings->Bind( PCB_LAYER_PAIR_PRESETS_CHANGED, [&]( wxCommandEvent& aEvt )
445 {
446 // Update the project file list
447 std::span<const LAYER_PAIR_INFO> newPairInfos = m_layerPairSettings->GetLayerPairs();
449 std::vector<LAYER_PAIR_INFO>{ newPairInfos.begin(), newPairInfos.end() };
450 });
451
452 m_layerPairSettings->Bind( PCB_CURRENT_LAYER_PAIR_CHANGED, [&]( wxCommandEvent& aEvt )
453 {
454 const LAYER_PAIR& layerPair = m_layerPairSettings->GetCurrentLayerPair();
455 PCB_SCREEN& screen = *GetScreen();
456
457 screen.m_Route_Layer_TOP = layerPair.GetLayerA();
458 screen.m_Route_Layer_BOTTOM = layerPair.GetLayerB();
459
460 // Update the toolbar icon
461 PrepareLayerIndicator();
462 });
463 }
464
465 GetToolManager()->PostAction( ACTIONS::zoomFitScreen );
466
467 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
468 // to calculate the wrong zoom size. See PCB_EDIT_FRAME::onSize().
469 Bind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
470
471 Bind( wxEVT_IDLE,
472 [this]( wxIdleEvent& aEvent )
473 {
474 BOX2D viewport = GetCanvas()->GetView()->GetViewport();
475
476 if( viewport != m_lastNetnamesViewport )
477 {
478 redrawNetnames();
479 m_lastNetnamesViewport = viewport;
480 }
481
482 // Do not forget to pass the Idle event to other clients:
483 aEvent.Skip();
484 } );
485
486 resolveCanvasType();
487
488 setupUnits( config() );
489
490 // Ensure the DRC engine is initialized so that constraints can be resolved even before a
491 // board is loaded or saved
492 try
493 {
494 m_toolManager->GetTool<DRC_TOOL>()->GetDRCEngine()->InitEngine( wxFileName() );
495 }
496 catch( PARSE_ERROR& )
497 {
498 }
499
500 // Sync action plugins in case they changed since the last time the frame opened
501 GetToolManager()->RunAction( ACTIONS::pluginsReload );
502
503#ifdef KICAD_IPC_API
504 m_apiHandler = std::make_unique<API_HANDLER_PCB>( this );
505 Pgm().GetApiServer().RegisterHandler( m_apiHandler.get() );
506
507 if( Kiface().IsSingle() )
508 {
509 m_apiHandlerCommon = std::make_unique<API_HANDLER_COMMON>();
510 Pgm().GetApiServer().RegisterHandler( m_apiHandlerCommon.get() );
511 }
512#endif
513
514 GetCanvas()->SwitchBackend( m_canvasType );
515 ActivateGalCanvas();
516
517 // Default shutdown reason until a file is loaded
518 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New PCB file is unsaved" ) );
519
520 // disable Export STEP item if kicad2step does not exist
521 wxString strK2S = Pgm().GetExecutablePath();
522
523#ifdef __WXMAC__
524 if( strK2S.Find( wxT( "pcbnew.app" ) ) != wxNOT_FOUND )
525 {
526 // On macOS, we have standalone applications inside the main bundle, so we handle that here:
527 strK2S += wxT( "../../" );
528 }
529
530 strK2S += wxT( "Contents/MacOS/" );
531#endif
532
533 wxFileName appK2S( strK2S, wxT( "kicad2step" ) );
534
535#ifdef _WIN32
536 appK2S.SetExt( wxT( "exe" ) );
537#endif
538
539 // Ensure the window is on top
540 Raise();
541
542// if( !appK2S.FileExists() )
543 // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
544
545 // AUI doesn't refresh properly on wxMac after changes in eb7dc6dd, so force it to
546#ifdef __WXMAC__
547 if( Kiface().IsSingle() )
548 {
549 CallAfter( [this]()
550 {
551 m_appearancePanel->OnBoardChanged();
552 } );
553 }
554#endif
555
556 // Register a call to update the toolbar sizes. It can't be done immediately because
557 // it seems to require some sizes calculated that aren't yet (at least on GTK).
558 CallAfter( [this]()
559 {
560 // Ensure the controls on the toolbars all are correctly sized
561 UpdateToolbarControlSizes();
562
563 // Update the angle snap mode toolbar button to reflect the current preference
564 GetToolManager()->RunAction( PCB_ACTIONS::angleSnapModeChanged );
565 } );
566
567 if( ADVANCED_CFG::GetCfg().m_ShowEventCounters )
568 {
569 m_eventCounterTimer = new wxTimer( this );
570
571 Bind( wxEVT_TIMER,
572 [&]( wxTimerEvent& aEvent )
573 {
574 GetCanvas()->m_PaintEventCounter->Show();
575 GetCanvas()->m_PaintEventCounter->Reset();
576
578 static_cast<KIGFX::WX_VIEW_CONTROLS*>( GetCanvas()->GetViewControls() );
581
582 },
583 m_eventCounterTimer->GetId() );
584
585 m_eventCounterTimer->Start( 1000 );
586 }
587
590 m_acceptedExts.emplace( wxS( "dxf" ), &PCB_ACTIONS::ddImportGraphics );
592 DragAcceptFiles( true );
593
594 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &PCB_EDIT_FRAME::onCloseModelessBookReporterDialogs, this );
595}
596
597
598void PCB_EDIT_FRAME::StartCrossProbeFlash( const std::vector<BOARD_ITEM*>& aItems )
599{
600 if( !GetPcbNewSettings()->m_CrossProbing.flash_selection )
601 {
602 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash(PCB): aborted (setting disabled) items=%zu",
603 aItems.size() );
604 return;
605 }
606
607 if( aItems.empty() )
608 {
609 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash(PCB): aborted (no items)" );
610 return;
611 }
612
613 // Don't start flashing if any of the items are being moved. The flash timer toggles
614 // selection hide/show which corrupts the VIEW overlay state during an active move.
615 for( const BOARD_ITEM* item : aItems )
616 {
617 if( item->IsMoving() )
618 {
619 wxLogTrace( traceCrossProbeFlash,
620 "StartCrossProbeFlash(PCB): aborted (items are moving)" );
621 return;
622 }
623 }
624
626 {
627 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash(PCB): restarting existing flash (phase=%d)",
630 }
631
632 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash(PCB): starting with %zu items", aItems.size() );
633
634 // Store uuids
636 for( BOARD_ITEM* it : aItems )
637 m_crossProbeFlashItems.push_back( it->m_Uuid );
638
641
642 if( !m_crossProbeFlashTimer.GetOwner() )
643 m_crossProbeFlashTimer.SetOwner( this );
644
645 bool started = m_crossProbeFlashTimer.Start( 500, wxTIMER_CONTINUOUS ); // 0.5s intervals -> 3s total for 6 phases
646 wxLogTrace( traceCrossProbeFlash, "StartCrossProbeFlash(PCB): timer start=%d id=%d",
647 (int) started, m_crossProbeFlashTimer.GetId() );
648}
649
650
651void PCB_EDIT_FRAME::OnCrossProbeFlashTimer( wxTimerEvent& aEvent )
652{
653 wxLogTrace( traceCrossProbeFlash, "Timer(PCB) fired: phase=%d running=%d items=%zu",
655
657 {
658 wxLogTrace( traceCrossProbeFlash, "Timer(PCB) fired but not flashing (ignored)" );
659 return;
660 }
661
663
664 if( !selTool )
665 return;
666
667 // Don't manipulate the selection while items are being moved. The move tool holds a
668 // live reference to the selection and toggling hide/show on selected items corrupts
669 // the VIEW overlay state, causing crashes.
670 for( const KIID& id : m_crossProbeFlashItems )
671 {
672 if( EDA_ITEM* item = GetBoard()->ResolveItem( id, true ) )
673 {
674 if( item->IsMoving() )
675 {
676 wxLogTrace( traceCrossProbeFlash,
677 "Timer(PCB) phase=%d: items are moving, stopping flash",
679 m_crossProbeFlashing = false;
681 return;
682 }
683 }
684 }
685
686 // Prevent recursion / IPC during flashing
687 bool prevGuard = m_ProbingSchToPcb;
688 m_ProbingSchToPcb = true;
689
690 if( m_crossProbeFlashPhase % 2 == 0 )
691 {
692 // Hide selection
693 selTool->ClearSelection( true );
694 wxLogTrace( traceCrossProbeFlash, "Phase %d (PCB): cleared selection", m_crossProbeFlashPhase );
695 }
696 else
697 {
698 // Restore selection
699 for( const KIID& id : m_crossProbeFlashItems )
700 {
701 if( EDA_ITEM* item = GetBoard()->ResolveItem( id, true ) )
702 selTool->AddItemToSel( item, true );
703 }
704
705 wxLogTrace( traceCrossProbeFlash, "Phase %d (PCB): restored %zu items",
707 }
708
709 // Force a redraw even if the canvas / frame does not currently have focus (mouse elsewhere)
710 if( GetCanvas() )
711 {
713 wxLogTrace( traceCrossProbeFlash, "Phase %d (PCB): forced canvas refresh",
715 }
716
717 m_ProbingSchToPcb = prevGuard;
718
720
721 if( m_crossProbeFlashPhase > 6 )
722 {
723 // Ensure final state (selected)
724 for( const KIID& id : m_crossProbeFlashItems )
725 {
726 if( EDA_ITEM* item = GetBoard()->ResolveItem( id, true ) )
727 selTool->AddItemToSel( item, true );
728 }
729
730 m_crossProbeFlashing = false;
732
733 wxLogTrace( traceCrossProbeFlash, "Flashing complete (PCB). Final selection size=%zu",
734 m_crossProbeFlashItems.size() );
735 }
736}
737
738
740{
741 if( ADVANCED_CFG::GetCfg().m_ShowEventCounters )
742 {
743 // Stop the timer during destruction early to avoid potential event race conditions (that
744 // do happen on windows)
745 m_eventCounterTimer->Stop();
746 delete m_eventCounterTimer;
747 }
748
749 // Close modeless dialogs
750 wxWindow* drcDlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
751
752 if( drcDlg )
753 drcDlg->Close( true );
754
755 wxWindow* ruleEditorDlg = wxWindow::FindWindowByName( DIALOG_DRC_RULE_EDITOR_WINDOW_NAME );
756
757 if( ruleEditorDlg )
758 ruleEditorDlg->Close( true );
759
760 // Shutdown all running tools
761 if( m_toolManager )
762 m_toolManager->ShutdownAllTools();
763
764 if( GetBoard() )
766
767 // We passed ownership of these to wxAuiManager.
768 // delete m_selectionFilterPanel;
769 // delete m_appearancePanel;
770 // delete m_propertiesPanel;
771 // delete m_netInspectorPanel;
772
774}
775
776
777void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard, bool aBuildConnectivity,
778 PROGRESS_REPORTER* aReporter )
779{
780 if( m_pcb )
781 m_pcb->ClearProject();
782
783 PCB_BASE_EDIT_FRAME::SetBoard( aBoard, aReporter );
784
785 aBoard->SetProject( &Prj() );
786
787 if( aBuildConnectivity )
788 aBoard->BuildConnectivity();
789
790 // reload the drawing-sheet
791 SetPageSettings( aBoard->GetPageSettings() );
792
794}
795
796
801
802
803std::unique_ptr<GRID_HELPER> PCB_EDIT_FRAME::MakeGridHelper()
804{
805 return std::make_unique<PCB_GRID_HELPER>( m_toolManager, GetMagneticItemsSettings() );
806}
807
808
810{
811 /*
812 * While new items being scrolled into the view will get painted, they will only get
813 * annotated with netname instances currently within the view. Subsequent panning will not
814 * draw newly-visible netname instances because the item has already been drawn.
815 *
816 * This routine, fired on idle if the viewport has changed, looks for visible items that
817 * might have multiple netname instances and redraws them. (It does not need to handle pads
818 * and vias because they only ever have a single netname instance drawn on them.)
819 */
820 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
821
822 if( !cfg || cfg->m_Display.m_NetNames < 2 )
823 return;
824
825 KIGFX::VIEW* view = GetCanvas()->GetView();
826 BOX2D viewport = view->GetViewport();
827
828 // Inflate to catch most of the track width
829 BOX2I_MINMAX clipbox( BOX2ISafe( viewport.Inflate( pcbIUScale.mmToIU( 2.0 ) ) ) );
830
831 for( PCB_TRACK* track : GetBoard()->Tracks() )
832 {
833 // Don't need to update vias
834 if( track->Type() == PCB_VIA_T )
835 continue;
836
837 // Don't update invisible tracks
838 if( !clipbox.Intersects( BOX2I_MINMAX( track->GetStart(), track->GetEnd() ) ) )
839 continue;
840
841 if( track->ViewGetLOD( GetNetnameLayer( track->GetLayer() ), view ) < view->GetScale() )
842 view->Update( track, KIGFX::REPAINT );
843 }
844}
845
846
847void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
848{
849 PCB_BASE_FRAME::SetPageSettings( aPageSettings );
850
851 // Prepare drawing-sheet template
853 &m_pcb->GetPageSettings(),
854 m_pcb->GetProject(),
855 &m_pcb->GetTitleBlock(),
856 &m_pcb->GetProperties() );
857
858 drawingSheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
859 drawingSheet->SetSheetPath( std::string( GetFullScreenDesc().mb_str() ) );
860
861 // A board is not like a schematic having a main page and sub sheets.
862 // So for the drawing sheet, use only the first page option to display items
863 drawingSheet->SetIsFirstPage( true );
864
865 BASE_SCREEN* screen = GetScreen();
866
867 if( screen != nullptr )
868 {
869 drawingSheet->SetPageNumber(TO_UTF8( screen->GetPageNumber() ) );
870 drawingSheet->SetSheetCount( screen->GetPageCount() );
871 }
872
873 if( BOARD* board = GetBoard() )
874 {
875 drawingSheet->SetFileName( TO_UTF8( board->GetFileName() ) );
876 wxString currentVariant = board->GetCurrentVariant();
877 wxString variantDesc = board->GetVariantDescription( currentVariant );
878 drawingSheet->SetVariantName( TO_UTF8( currentVariant ) );
879 drawingSheet->SetVariantDesc( TO_UTF8( variantDesc ) );
880 }
881
882 // PCB_DRAW_PANEL_GAL takes ownership of the drawing-sheet
883 GetCanvas()->SetDrawingSheet( drawingSheet );
884}
885
886
888{
889 return GetScreen() && GetScreen()->IsContentModified();
890}
891
892
894{
895 return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
896}
897
898
900{
901 // Create the manager and dispatcher & route draw panel events to the dispatcher
903 m_toolManager->SetEnvironment( m_pcb, GetCanvas()->GetView(),
904 GetCanvas()->GetViewControls(), config(), this );
905 m_actions = new PCB_ACTIONS();
907
908 // Register tools
909 m_toolManager->RegisterTool( new COMMON_CONTROL );
910 m_toolManager->RegisterTool( new COMMON_TOOLS );
911 m_toolManager->RegisterTool( new PCB_SELECTION_TOOL );
912 m_toolManager->RegisterTool( new ZOOM_TOOL );
913 m_toolManager->RegisterTool( new PCB_PICKER_TOOL );
914 m_toolManager->RegisterTool( new ROUTER_TOOL );
915 m_toolManager->RegisterTool( new EDIT_TOOL );
916 m_toolManager->RegisterTool( new PCB_EDIT_TABLE_TOOL );
917 m_toolManager->RegisterTool( new GLOBAL_EDIT_TOOL );
918 m_toolManager->RegisterTool( new PAD_TOOL );
919 m_toolManager->RegisterTool( new DRAWING_TOOL );
920 m_toolManager->RegisterTool( new PCB_POINT_EDITOR );
921 m_toolManager->RegisterTool( new PCB_CONTROL );
922 m_toolManager->RegisterTool( new PCB_DESIGN_BLOCK_CONTROL );
923 m_toolManager->RegisterTool( new BOARD_EDITOR_CONTROL );
924 m_toolManager->RegisterTool( new BOARD_INSPECTION_TOOL );
925 m_toolManager->RegisterTool( new BOARD_REANNOTATE_TOOL );
926 m_toolManager->RegisterTool( new ALIGN_DISTRIBUTE_TOOL );
927 m_toolManager->RegisterTool( new MICROWAVE_TOOL );
928 m_toolManager->RegisterTool( new POSITION_RELATIVE_TOOL );
929 m_toolManager->RegisterTool( new ARRAY_TOOL );
930 m_toolManager->RegisterTool( new ZONE_FILLER_TOOL );
931 m_toolManager->RegisterTool( new AUTOPLACE_TOOL );
932 m_toolManager->RegisterTool( new DRC_TOOL );
933 m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS );
934 m_toolManager->RegisterTool( new CONVERT_TOOL );
935 m_toolManager->RegisterTool( new PCB_GROUP_TOOL );
936 m_toolManager->RegisterTool( new GENERATOR_TOOL );
937 m_toolManager->RegisterTool( new PROPERTIES_TOOL );
938 m_toolManager->RegisterTool( new MULTICHANNEL_TOOL );
939 m_toolManager->RegisterTool( new EMBED_TOOL );
940 m_toolManager->RegisterTool( new DRC_RULE_EDITOR_TOOL );
941 m_toolManager->InitTools();
942
943 for( TOOL_BASE* tool : m_toolManager->Tools() )
944 {
945 if( PCB_TOOL_BASE* pcbTool = dynamic_cast<PCB_TOOL_BASE*>( tool ) )
946 pcbTool->SetIsBoardEditor( true );
947 }
948
949 // Run the selection tool, it is supposed to be always active
950 m_toolManager->InvokeTool( "common.InteractiveSelection" );
951}
952
953
955{
957
958 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
959 PCB_EDITOR_CONDITIONS cond( this );
960
961 auto undoCond =
962 [ this ] (const SELECTION& aSel )
963 {
964 DRAWING_TOOL* drawingTool = m_toolManager->GetTool<DRAWING_TOOL>();
965
966 if( drawingTool && drawingTool->GetDrawingMode() != DRAWING_TOOL::MODE::NONE )
967 return true;
968
969 ROUTER_TOOL* routerTool = m_toolManager->GetTool<ROUTER_TOOL>();
970
971 if( routerTool && routerTool->RoutingInProgress() )
972 return true;
973
974 return GetUndoCommandCount() > 0;
975 };
976
977 auto groupWithDesignBlockLink =
978 [] ( const SELECTION& aSel )
979 {
980 if( aSel.Size() != 1 )
981 return false;
982
983 if( aSel[0]->Type() != PCB_GROUP_T )
984 return false;
985
986 PCB_GROUP* group = static_cast<PCB_GROUP*>( aSel.GetItem( 0 ) );
987
988 return group->HasDesignBlockLink();
989 };
990
991 wxASSERT( mgr );
992
993#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
994#define CHECK( x ) ACTION_CONDITIONS().Check( x )
995// clang-format off
996
998 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
1000
1004
1005 mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
1006 mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
1013
1014 static const std::vector<KICAD_T> groupTypes = { PCB_GROUP_T, PCB_GENERATOR_T };
1015
1020
1021 mgr->SetConditions( PCB_ACTIONS::placeLinkedDesignBlock, ENABLE( groupWithDesignBlockLink) );
1022 mgr->SetConditions( PCB_ACTIONS::saveToLinkedDesignBlock, ENABLE( groupWithDesignBlockLink) );
1023
1029
1030 auto enableZoneControlCondition =
1031 [this] ( const SELECTION& )
1032 {
1035 };
1036
1038 ENABLE( enableZoneControlCondition )
1041 ENABLE( enableZoneControlCondition )
1044 ENABLE( enableZoneControlCondition )
1047 ENABLE( enableZoneControlCondition )
1049
1051
1052 auto hasElements =
1053 [ this ] ( const SELECTION& aSel )
1054 {
1055 return GetBoard() &&
1056 ( !GetBoard()->IsEmpty() || !SELECTION_CONDITIONS::Idle( aSel ) );
1057 };
1058
1059 auto boardFlippedCond =
1060 [this]( const SELECTION& )
1061 {
1063 };
1064
1065 auto layerManagerCond =
1066 [this] ( const SELECTION& )
1067 {
1068 return LayerManagerShown();
1069 };
1070
1071 auto propertiesCond =
1072 [this] ( const SELECTION& )
1073 {
1074 return PropertiesShown();
1075 };
1076
1077 auto netInspectorCond =
1078 [this] ( const SELECTION& )
1079 {
1080 return NetInspectorShown();
1081 };
1082
1083 auto searchPaneCond =
1084 [this] ( const SELECTION& )
1085 {
1086 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
1087 };
1088
1089 auto designBlockCond =
1090 [ this ] (const SELECTION& aSel )
1091 {
1092 return m_auimgr.GetPane( DesignBlocksPaneName() ).IsShown();
1093 };
1094
1095 auto highContrastCond =
1096 [this] ( const SELECTION& )
1097 {
1099 };
1100
1101 auto globalRatsnestCond =
1102 [this] (const SELECTION& )
1103 {
1105 return cfg && cfg->m_Display.m_ShowGlobalRatsnest;
1106 };
1107
1108 auto curvedRatsnestCond =
1109 [this] (const SELECTION& )
1110 {
1112 return cfg && cfg->m_Display.m_DisplayRatsnestLinesCurved;
1113 };
1114
1115 auto netHighlightCond =
1116 [this]( const SELECTION& )
1117 {
1118 if( auto* canvas = GetCanvas() )
1119 {
1120 if( auto* view = canvas->GetView() )
1121 {
1122 if( auto* painter = view->GetPainter() )
1123 {
1124 if( auto* settings = painter->GetSettings() )
1125 return !settings->GetHighlightNetCodes().empty();
1126 }
1127 }
1128 }
1129
1130 return false;
1131 };
1132
1133 auto enableNetHighlightCond =
1134 [this]( const SELECTION& )
1135 {
1137 return tool && tool->IsNetHighlightSet();
1138 };
1139
1140 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
1141 mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
1142 mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
1143 mgr->SetConditions( PCB_ACTIONS::showRatsnest, CHECK( globalRatsnestCond ) );
1144 mgr->SetConditions( PCB_ACTIONS::ratsnestLineMode, CHECK( curvedRatsnestCond ) );
1145 mgr->SetConditions( PCB_ACTIONS::toggleNetHighlight, CHECK( netHighlightCond )
1146 .Enable( enableNetHighlightCond ) );
1147 mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
1148 mgr->SetConditions( PCB_ACTIONS::showNetInspector, CHECK( netInspectorCond ) );
1149 mgr->SetConditions( PCB_ACTIONS::showSearch, CHECK( searchPaneCond ) );
1150 mgr->SetConditions( PCB_ACTIONS::showDesignBlockPanel, CHECK( designBlockCond ) );
1151
1154
1155 const auto isArcKeepCenterMode =
1156 [this]( const SELECTION& )
1157 {
1160 };
1161
1162 const auto isArcKeepEndpointMode =
1163 [this]( const SELECTION& )
1164 {
1167 };
1168
1169 const auto isArcKeepRadiusMode =
1170 [this]( const SELECTION& )
1171 {
1174 };
1175
1176 mgr->SetConditions( ACTIONS::pointEditorArcKeepCenter, CHECK( isArcKeepCenterMode ) );
1177 mgr->SetConditions( ACTIONS::pointEditorArcKeepEndpoint, CHECK( isArcKeepEndpointMode ) );
1178 mgr->SetConditions( ACTIONS::pointEditorArcKeepRadius, CHECK( isArcKeepRadiusMode ) );
1179
1180 auto isHighlightMode =
1181 [this]( const SELECTION& )
1182 {
1183 ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
1184 return tool && tool->GetRouterMode() == PNS::RM_MarkObstacles;
1185 };
1186
1187 auto isShoveMode =
1188 [this]( const SELECTION& )
1189 {
1190 ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
1191 return tool && tool->GetRouterMode() == PNS::RM_Shove;
1192 };
1193
1194 auto isWalkaroundMode =
1195 [this]( const SELECTION& )
1196 {
1197 ROUTER_TOOL* tool = m_toolManager->GetTool<ROUTER_TOOL>();
1198 return tool && tool->GetRouterMode() == PNS::RM_Walkaround;
1199 };
1200
1201 mgr->SetConditions( PCB_ACTIONS::routerHighlightMode, CHECK( isHighlightMode ) );
1202 mgr->SetConditions( PCB_ACTIONS::routerShoveMode, CHECK( isShoveMode ) );
1203 mgr->SetConditions( PCB_ACTIONS::routerWalkaroundMode, CHECK( isWalkaroundMode ) );
1204
1205 auto isAutoTrackWidth =
1206 [this]( const SELECTION& )
1207 {
1209 };
1210
1211 mgr->SetConditions( PCB_ACTIONS::autoTrackWidth, CHECK( isAutoTrackWidth ) );
1212
1213 auto haveNetCond =
1214 [] ( const SELECTION& aSel )
1215 {
1216 for( EDA_ITEM* item : aSel )
1217 {
1218 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
1219 {
1220 if( bci->GetNetCode() > 0 )
1221 return true;
1222 }
1223 }
1224
1225 return false;
1226 };
1227
1228 mgr->SetConditions( PCB_ACTIONS::showNetInRatsnest, ENABLE( haveNetCond ) );
1229 mgr->SetConditions( PCB_ACTIONS::hideNetInRatsnest, ENABLE( haveNetCond ) );
1232
1233 static const std::vector<KICAD_T> trackTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T };
1234 static const std::vector<KICAD_T> padOwnerTypes = { PCB_FOOTPRINT_T, PCB_PAD_T };
1235 static const std::vector<KICAD_T> footprintTypes = { PCB_FOOTPRINT_T };
1236 static const std::vector<KICAD_T> crossProbeTypes = { PCB_PAD_T, PCB_FOOTPRINT_T, PCB_GROUP_T };
1237 static const std::vector<KICAD_T> zoneTypes = { PCB_ZONE_T };
1238
1244
1245
1247 && SELECTION_CONDITIONS::OnlyTypes( zoneTypes );
1248
1250 && SELECTION_CONDITIONS::OnlyTypes( zoneTypes );
1251
1252 mgr->SetConditions( PCB_ACTIONS::zoneDuplicate, ENABLE( singleZoneCond ) );
1253 mgr->SetConditions( PCB_ACTIONS::drawZoneCutout, ENABLE( singleZoneCond ) );
1254 mgr->SetConditions( PCB_ACTIONS::drawSimilarZone, ENABLE( singleZoneCond ) );
1255 mgr->SetConditions( PCB_ACTIONS::zoneMerge, ENABLE( zoneMergeCond ) );
1256
1259
1260#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
1261
1262 // These tools can be used at any time to inspect the board
1267
1268 auto isDRCIdle =
1269 [this] ( const SELECTION& )
1270 {
1271 DRC_TOOL* tool = m_toolManager->GetTool<DRC_TOOL>();
1272 return !( tool && tool->IsDRCRunning() );
1273 };
1274
1275#define CURRENT_EDIT_TOOL( action ) \
1276 mgr->SetConditions( action, ACTION_CONDITIONS().Check( cond.CurrentTool( action ) ) \
1277 .Enable( isDRCIdle ) )
1278
1279 // These tools edit the board, so they must be disabled during some operations
1311
1317
1318#undef CURRENT_TOOL
1319#undef CURRENT_EDIT_TOOL
1320#undef ENABLE
1321#undef CHECK
1322// clang-format on
1323}
1324
1325
1326void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
1327{
1328 if( event.GetId() == wxID_EXIT )
1329 Kiway().OnKiCadExit();
1330
1331 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1332 Close( false );
1333}
1334
1335
1336void PCB_EDIT_FRAME::ResolveDRCExclusions( bool aCreateMarkers )
1337{
1338 BOARD_COMMIT commit( this );
1339
1340 for( PCB_MARKER* marker : GetBoard()->ResolveDRCExclusions( aCreateMarkers ) )
1341 {
1342 if( marker->GetMarkerType() == MARKER_BASE::MARKER_DRAWING_SHEET )
1343 marker->GetRCItem()->SetItems( GetCanvas()->GetDrawingSheet() );
1344
1345 commit.Add( marker );
1346 }
1347
1348 commit.Push( wxEmptyString, SKIP_UNDO | SKIP_SET_DIRTY );
1349
1350 for( PCB_MARKER* marker : GetBoard()->Markers() )
1351 {
1352 if( marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
1353 GetCanvas()->GetView()->Update( marker );
1354 }
1355
1357}
1358
1359
1360bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
1361{
1362 // Shutdown blocks must be determined and vetoed as early as possible
1363 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
1364 && IsContentModified() )
1365 {
1366 return false;
1367 }
1368
1369 ZONE_FILLER_TOOL* zoneFillerTool = m_toolManager->GetTool<ZONE_FILLER_TOOL>();
1370
1371 if( zoneFillerTool->IsBusy() )
1372 {
1373 wxBell();
1374
1375 if( wxWindow* reporter = dynamic_cast<wxWindow*>( zoneFillerTool->GetProgressReporter() ) )
1376 reporter->ShowWithEffect( wxSHOW_EFFECT_EXPAND );
1377
1378 return false;
1379 }
1380
1381 // Don't allow closing while the modal footprint chooser is open
1382 auto* chooser = (FOOTPRINT_CHOOSER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_CHOOSER, false );
1383
1384 if( chooser && chooser->IsModal() ) // Can close footprint chooser?
1385 return false;
1386
1387 if( Kiface().IsSingle() )
1388 {
1389 auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
1390
1391 if( fpEditor && !fpEditor->Close() ) // Can close footprint editor?
1392 return false;
1393
1394 auto* fpViewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER, false );
1395
1396 if( fpViewer && !fpViewer->Close() ) // Can close footprint viewer?
1397 return false;
1398 }
1399 else
1400 {
1401 auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
1402
1403 if( fpEditor && fpEditor->IsCurrentFPFromBoard() )
1404 {
1405 if( !fpEditor->CanCloseFPFromBoard( true ) )
1406 return false;
1407 }
1408 }
1409
1410 if( IsContentModified() )
1411 {
1412 wxFileName fileName = GetBoard()->GetFileName();
1413 wxString msg = _( "Save changes to '%s' before closing?" );
1414
1415 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
1416 [&]() -> bool
1417 {
1418 return SaveBoard();
1419 } ) )
1420 {
1421 return false;
1422 }
1423
1424 // If user discarded changes, create a duplicate commit of last saved PCB state and
1425 // advance Last_Save_pcb tag for explicit history event.
1426 if( GetLastUnsavedChangesResponse() == wxID_NO )
1427 {
1428 wxString projPath = Prj().GetProjectPath();
1429
1430 if( !projPath.IsEmpty() && Kiway().LocalHistory().HistoryExists( projPath ) )
1431 {
1432 Kiway().LocalHistory().CommitDuplicateOfLastSave( projPath, wxS("pcb"),
1433 wxS("Discard unsaved pcb changes") );
1434 }
1435 }
1436 }
1437
1438 return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
1439}
1440
1441
1443{
1444 // Unregister the autosave saver before any cleanup that might invalidate the board
1445 if( GetBoard() )
1447
1448 // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
1449 // when closing this frame if a footprint was selected, and the footprint editor called
1450 // to edit this footprint, and when closing pcbnew if this footprint is still selected
1451 // See https://bugs.launchpad.net/kicad/+bug/1655858
1452 // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
1453 // avoid the crash (JPC)
1454 GetCanvas()->SetEvtHandlerEnabled( false );
1455
1457
1458#ifdef KICAD_IPC_API
1459 Pgm().GetApiServer().DeregisterHandler( m_apiHandler.get() );
1460 wxTheApp->Unbind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED,
1461 &PCB_EDIT_FRAME::onPluginAvailabilityChanged, this );
1462#endif
1463
1464 // Clean up mode-less dialogs.
1465 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &PCB_EDIT_FRAME::onCloseModelessBookReporterDialogs,
1466 this );
1467
1468 wxWindow* drcDlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
1469
1470 if( drcDlg )
1471 drcDlg->Close( true );
1472
1473 wxWindow* ruleEditorDlg = wxWindow::FindWindowByName( DIALOG_DRC_RULE_EDITOR_WINDOW_NAME );
1474
1475 if( ruleEditorDlg )
1476 ruleEditorDlg->Close( true );
1477
1478
1479 if( m_findDialog )
1480 {
1481 m_findDialog->Destroy();
1482 m_findDialog = nullptr;
1483 }
1484
1486 {
1487 m_findByPropertiesDialog->Destroy();
1488 m_findByPropertiesDialog = nullptr;
1489 }
1490
1492 {
1493 m_inspectDrcErrorDlg->Destroy();
1494 m_inspectDrcErrorDlg = nullptr;
1495 }
1496
1498 {
1499 m_inspectClearanceDlg->Destroy();
1500 m_inspectClearanceDlg = nullptr;
1501 }
1502
1504 {
1505 m_inspectConstraintsDlg->Destroy();
1506 m_inspectConstraintsDlg = nullptr;
1507 }
1508
1509 if( m_footprintDiffDlg )
1510 {
1511 m_footprintDiffDlg->Destroy();
1512 m_footprintDiffDlg = nullptr;
1513 }
1514
1515 // Delete the auto save file if it exists.
1516 wxFileName fn = GetBoard()->GetFileName();
1517
1518 // Make sure local settings are persisted
1519 if( Prj().GetLocalSettings().ShouldAutoSave() )
1520 {
1521 m_netInspectorPanel->SaveSettings();
1523 }
1524 else
1525 {
1526 wxLogTrace( traceAutoSave, wxT( "Skipping auto-save of migrated local settings" ) );
1527 }
1528
1529 // Do not show the layer manager during closing to avoid flicker
1530 // on some platforms (Windows) that generate useless redraw of items in
1531 // the Layer Manager
1533 {
1534 m_auimgr.GetPane( wxS( "LayersManager" ) ).Show( false );
1535 m_auimgr.GetPane( wxS( "TabbedPanel" ) ).Show( false );
1536 }
1537
1538 // Unlink the old project if needed
1540
1541 // Delete board structs and undo/redo lists, to avoid crash on exit
1542 // when deleting some structs (mainly in undo/redo lists) too late
1543 Clear_Pcb( false, true );
1544
1545 // do not show the window because ScreenPcb will be deleted and we do not
1546 // want any paint event
1547 Show( false );
1548
1550}
1551
1552
1559
1560
1561void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage, wxWindow* aParent )
1562{
1563 static std::mutex dialogMutex; // Local static mutex
1564
1565 std::unique_lock<std::mutex> dialogLock( dialogMutex, std::try_to_lock );
1566
1567 // One dialog at a time.
1568 if( !dialogLock.owns_lock() )
1569 {
1570 if( m_boardSetupDlg && m_boardSetupDlg->IsShown() )
1571 {
1572 m_boardSetupDlg->Raise(); // Brings the existing dialog to the front
1573 }
1574
1575 return;
1576 }
1577
1578 // Make sure everything's up-to-date
1580
1581 DIALOG_BOARD_SETUP dlg( this, aParent );
1582
1583 if( !aInitialPage.IsEmpty() )
1584 dlg.SetInitialPage( aInitialPage, wxEmptyString );
1585
1586 // Assign dlg to the m_boardSetupDlg pointer to track its status.
1587 m_boardSetupDlg = &dlg;
1588
1589 // QuasiModal required for Scintilla auto-complete
1590 if( dlg.ShowQuasiModal() == wxID_OK )
1591 {
1592 // Note: We must synchronise time domain properties before nets and classes, otherwise the updates
1593 // called by the board listener events are using stale data
1596
1597 if( !GetBoard()->SynchronizeComponentClasses( std::unordered_set<wxString>() ) )
1598 {
1599 m_infoBar->RemoveAllButtons();
1600 m_infoBar->AddCloseButton();
1601 m_infoBar->ShowMessage( _( "Could not load component class assignment rules" ),
1602 wxICON_WARNING, WX_INFOBAR::MESSAGE_TYPE::GENERIC );
1603 }
1604
1605 // We don't know if anything was modified, so err on the side of requiring a save
1606 OnModify();
1607
1609
1612
1613 PCBNEW_SETTINGS* settings = GetPcbNewSettings();
1614 static LSET maskAndPasteLayers = LSET( { F_Mask, F_Paste, B_Mask, B_Paste } );
1615
1617 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1618 {
1619 int flags = 0;
1620
1621 if( !aItem->IsBOARD_ITEM() )
1622 return flags;
1623
1624 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aItem );
1625
1626 if( item->Type() == PCB_VIA_T || item->Type() == PCB_PAD_T )
1627 {
1628 // Note: KIGFX::REPAINT isn't enough for things that go from invisible
1629 // to visible as they won't be found in the view layer's itemset for
1630 // re-painting.
1631 if( ( GetBoard()->GetVisibleLayers() & maskAndPasteLayers ).any() )
1632 flags |= KIGFX::ALL;
1633 }
1634
1635 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T || item->Type() == PCB_VIA_T )
1636 {
1638 flags |= KIGFX::REPAINT;
1639 }
1640
1641 if( item->Type() == PCB_PAD_T )
1642 {
1643 if( settings->m_Display.m_PadClearance )
1644 flags |= KIGFX::REPAINT;
1645 }
1646
1647 if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem ) )
1648 {
1649 if( text->HasTextVars() )
1650 {
1651 text->ClearRenderCache();
1652 text->ClearBoundingBoxCache();
1654 }
1655 }
1656
1657 return flags;
1658 } );
1659
1660 GetCanvas()->Refresh();
1661
1665
1666 //this event causes the routing tool to reload its design rules information
1668 toolEvent.SetHasPosition( false );
1669 m_toolManager->ProcessEvent( toolEvent );
1670 }
1671
1672 GetCanvas()->SetFocus();
1673
1674 // Reset m_boardSetupDlg after the dialog is closed
1675 m_boardSetupDlg = nullptr;
1676}
1677
1678
1680{
1681 m_searchPane->FocusSearch();
1682}
1683
1684
1686{
1688
1689 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
1690 wxASSERT( cfg );
1691
1692 if( cfg )
1693 {
1697 }
1698}
1699
1700
1702{
1704
1705 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
1706 wxASSERT( cfg );
1707
1708 if( cfg )
1709 {
1710 wxAuiPaneInfo& apperancePane = m_auimgr.GetPane( AppearancePanelName() );
1711 cfg->m_AuiPanels.show_layer_manager = apperancePane.IsShown();
1712
1713 if( m_propertiesPanel )
1714 {
1715 cfg->m_AuiPanels.show_properties = m_propertiesPanel->IsShownOnScreen();
1717 cfg->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion();
1718 }
1719
1720 // ensure m_ShowSearch is up to date (the pane can be closed)
1721 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
1722 m_ShowSearch = searchPaneInfo.IsShown();
1724 cfg->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
1725 cfg->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
1726 cfg->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
1727
1729 {
1730 wxAuiPaneInfo& netInspectorhPaneInfo = m_auimgr.GetPane( NetInspectorPanelName() );
1731 m_ShowNetInspector = netInspectorhPaneInfo.IsShown();
1733 }
1734
1735 if( m_appearancePanel )
1736 {
1739 cfg->m_AuiPanels.appearance_expand_layer_display = m_appearancePanel->IsLayerOptionsExpanded();
1740 cfg->m_AuiPanels.appearance_expand_net_display = m_appearancePanel->IsNetOptionsExpanded();
1741 }
1742
1743 wxAuiPaneInfo& designBlocksPane = m_auimgr.GetPane( DesignBlocksPaneName() );
1744 cfg->m_AuiPanels.design_blocks_show = designBlocksPane.IsShown();
1745
1746 if( designBlocksPane.IsDocked() )
1748 else
1749 {
1750 cfg->m_AuiPanels.design_blocks_panel_float_height = designBlocksPane.floating_size.y;
1751 cfg->m_AuiPanels.design_blocks_panel_float_width = designBlocksPane.floating_size.x;
1752 }
1753
1754 m_designBlocksPane->SaveSettings();
1755 }
1756}
1757
1758
1760{
1761 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( config() );
1762
1763 return cfg ? cfg->m_RotationAngle : ANGLE_90;
1764}
1765
1766
1771
1772
1774{
1775
1776 GetColorSettings()->SetColor( LAYER_GRID, aColor );
1777 GetCanvas()->GetGAL()->SetGridColor( aColor );
1778}
1779
1780
1781void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer, bool aForceRedraw )
1782{
1783 const PCB_LAYER_ID oldLayer = GetActiveLayer();
1784
1785 if( oldLayer == aLayer && !aForceRedraw )
1786 return;
1787
1789
1790 m_appearancePanel->OnLayerChanged();
1791
1792 m_toolManager->PostAction( PCB_ACTIONS::layerChanged ); // notify other tools
1793 GetCanvas()->SetFocus(); // allow capture of hotkeys
1794 GetCanvas()->SetHighContrastLayer( aLayer );
1795
1796 /*
1797 * Only show pad, via and track clearances when a copper layer is active
1798 * and then only show the clearance layer for that copper layer. For
1799 * front/back non-copper layers, show the clearance layer for the outer
1800 * layer on that side.
1801 *
1802 * For pads/vias, this is to avoid clutter when there are pad/via layers
1803 * that vary in flash (i.e. clearance from the hole or pad edge), padstack
1804 * shape on each layer or clearances on each layer.
1805 *
1806 * For tracks, this follows the same logic as pads/vias, but in theory could
1807 * have their own set of independent clearance layers to allow track clearance
1808 * to be shown for more layers.
1809 */
1810 const auto getClearanceLayerForActive = []( PCB_LAYER_ID aActiveLayer ) -> std::optional<int>
1811 {
1812 if( IsCopperLayer( aActiveLayer ) )
1813 return CLEARANCE_LAYER_FOR( aActiveLayer );
1814
1815 return std::nullopt;
1816 };
1817
1818 if( std::optional<int> oldClearanceLayer = getClearanceLayerForActive( oldLayer ) )
1819 GetCanvas()->GetView()->SetLayerVisible( *oldClearanceLayer, false );
1820
1821 if( std::optional<int> newClearanceLayer = getClearanceLayerForActive( aLayer ) )
1822 GetCanvas()->GetView()->SetLayerVisible( *newClearanceLayer, true );
1823
1825 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1826 {
1827 if( !aItem->IsBOARD_ITEM() )
1828 return 0;
1829
1830 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aItem );
1831
1832 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible
1833 // as they won't be found in the view layer's itemset for re-painting.
1834 if( GetDisplayOptions().m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN )
1835 {
1836 if( item->IsOnLayer( oldLayer ) || item->IsOnLayer( aLayer ) )
1837 return KIGFX::ALL;
1838 }
1839
1840 if( item->Type() == PCB_VIA_T )
1841 {
1842 PCB_VIA* via = static_cast<PCB_VIA*>( item );
1843
1844 // Vias on a restricted layer set must be redrawn when the active layer
1845 // is changed
1846 if( via->GetViaType() == VIATYPE::BLIND
1847 || via->GetViaType() == VIATYPE::BURIED
1848 || via->GetViaType() == VIATYPE::MICROVIA )
1849 {
1850 return KIGFX::REPAINT;
1851 }
1852
1853 if( via->GetRemoveUnconnected() )
1854 return KIGFX::ALL;
1855 }
1856 else if( item->Type() == PCB_PAD_T )
1857 {
1858 PAD* pad = static_cast<PAD*>( item );
1859
1860 if( pad->GetRemoveUnconnected() )
1861 return KIGFX::ALL;
1862 }
1863
1864 return 0;
1865 } );
1866
1867 GetCanvas()->Refresh();
1868}
1869
1870
1872{
1873 wxFileName fn( GetBoard()->GetFileName() );
1874 Kiway().LocalHistory().Init( fn.GetPath() );
1876
1877 layerEnum.Choices().Clear();
1878 layerEnum.Undefined( UNDEFINED_LAYER );
1879
1880 for( PCB_LAYER_ID layer : LSET::AllLayersMask() )
1881 {
1882 // Canonical name
1883 layerEnum.Map( layer, LSET::Name( layer ) );
1884
1885 // User name
1886 layerEnum.Map( layer, GetBoard()->GetLayerName( layer ) );
1887 }
1888
1889 DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
1890
1891 try
1892 {
1894 }
1895 catch( PARSE_ERROR& )
1896 {
1897 // Not sure this is the best place to tell the user their rules are buggy, so
1898 // we'll stay quiet for now. Feel free to revisit this decision....
1899 }
1900
1902
1903 UpdateTitle();
1904
1905 // Display a warning that the file is read only
1906 if( fn.FileExists() && !fn.IsFileWritable() )
1907 {
1908 m_infoBar->RemoveAllButtons();
1909 m_infoBar->AddCloseButton();
1910 m_infoBar->ShowMessage( _( "Board file is read only." ),
1911 wxICON_WARNING, WX_INFOBAR::MESSAGE_TYPE::OUTDATED_SAVE );
1912 }
1913
1915
1916 // Sync layer and item visibility
1918
1919 SetElementVisibility( LAYER_RATSNEST, GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
1920
1921 m_appearancePanel->OnBoardChanged();
1922
1923 // Apply saved display state to the appearance panel after it has been set up
1924 PROJECT_LOCAL_SETTINGS& localSettings = Prj().GetLocalSettings();
1925
1926 m_appearancePanel->ApplyLayerPreset( localSettings.m_ActiveLayerPreset );
1927
1928 if( GetBoard()->GetDesignSettings().IsLayerEnabled( localSettings.m_ActiveLayer ) )
1929 SetActiveLayer( localSettings.m_ActiveLayer, true );
1930 else
1931 SetActiveLayer( GetActiveLayer(), true ); // Make sure to repaint even if not switching
1932
1933 PROJECT_FILE& projectFile = Prj().GetProjectFile();
1934
1935 m_layerPairSettings->SetLayerPairs( projectFile.m_LayerPairInfos );
1936 m_layerPairSettings->SetCurrentLayerPair( LAYER_PAIR{ F_Cu, B_Cu } );
1937
1938 // Updates any auto dimensions and the auxiliary toolbar tracks/via sizes
1940
1941 // Sync the net inspector now we have connectivity calculated
1943 m_netInspectorPanel->OnBoardChanged();
1944
1945 // Display the loaded board:
1946 Zoom_Automatique( false );
1947
1948 // Invalidate painting as loading the DRC engine will cause clearances to become valid
1950
1951 Refresh();
1952
1953 SetMsgPanel( GetBoard() );
1954 SetStatusText( wxEmptyString );
1955
1956 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "PCB file changes are unsaved" ) );
1957}
1958
1959
1961{
1962 m_appearancePanel->UpdateDisplayOptions();
1963}
1964
1965
1967{
1968 return GetBoard()->IsElementVisible( aElement );
1969}
1970
1971
1973{
1974 // Force the RATSNEST visible
1975 if( aElement == LAYER_RATSNEST )
1976 GetCanvas()->GetView()->SetLayerVisible( aElement, true );
1977 else
1978 GetCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
1979
1980 GetBoard()->SetElementVisibility( aElement, aNewState );
1981}
1982
1983
1985{
1986 // call my base class
1988
1989 m_auimgr.GetPane( m_appearancePanel ).Caption( _( "Appearance" ) );
1990 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
1991 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
1992 m_auimgr.GetPane( m_netInspectorPanel ).Caption( _( "Net Inspector" ) );
1993 m_auimgr.Update();
1994
1995 UpdateTitle();
1996}
1997
1998
2000{
2002
2003 if( project.m_PcbLastPath[ aType ].IsEmpty() )
2004 return wxEmptyString;
2005
2006 wxFileName absoluteFileName = project.m_PcbLastPath[ aType ];
2007 wxFileName pcbFileName = GetBoard()->GetFileName();
2008
2009 absoluteFileName.MakeAbsolute( pcbFileName.GetPath() );
2010 return absoluteFileName.GetFullPath();
2011}
2012
2013
2014void PCB_EDIT_FRAME::SetLastPath( LAST_PATH_TYPE aType, const wxString& aLastPath )
2015{
2017
2018 wxFileName relativeFileName = aLastPath;
2019 wxFileName pcbFileName = GetBoard()->GetFileName();
2020
2021 relativeFileName.MakeRelativeTo( pcbFileName.GetPath() );
2022
2023 if( relativeFileName.GetFullPath() != project.m_PcbLastPath[ aType ] )
2024 {
2025 project.m_PcbLastPath[ aType ] = relativeFileName.GetFullPath();
2026 OnModify();
2027 }
2028}
2029
2030
2032{
2034 Kiway().LocalHistory().NoteFileChange( GetBoard()->GetFileName() );
2035 m_ZoneFillsDirty = true;
2036
2037 if( m_isClosing )
2038 return;
2039
2040 Update3DView( true, GetPcbNewSettings()->m_Display.m_Live3DRefresh );
2041
2042 if( !GetTitle().StartsWith( wxT( "*" ) ) )
2043 UpdateTitle();
2044
2045}
2046
2047
2049{
2050 Update3DView( true, true );
2051
2052 std::shared_ptr<CONNECTIVITY_DATA> connectivity = GetBoard()->GetConnectivity();
2053 connectivity->RecalculateRatsnest( nullptr );
2055
2056 std::vector<MSG_PANEL_ITEM> msg_list;
2057 GetBoard()->GetMsgPanelInfo( this, msg_list );
2058 SetMsgPanel( msg_list );
2059}
2060
2061
2063{
2064 wxFileName fn = GetBoard()->GetFileName();
2065 bool readOnly = false;
2066 bool unsaved = false;
2067
2068 if( fn.IsOk() && fn.FileExists() )
2069 readOnly = !fn.IsFileWritable();
2070 else
2071 unsaved = true;
2072
2073 wxString title;
2074
2075 if( IsContentModified() )
2076 title = wxT( "*" );
2077
2078 title += fn.GetName();
2079
2080 if( readOnly )
2081 title += wxS( " " ) + _( "[Read Only]" );
2082
2083 if( unsaved )
2084 title += wxS( " " ) + _( "[Unsaved]" );
2085
2086 title += wxT( " \u2014 " ) + _( "PCB Editor" );
2087
2088 SetTitle( title );
2089}
2090
2091
2093{
2094 // Update the layer manager and other widgets from the board setup
2095 // (layer and items visibility, colors ...)
2096
2097 // Rebuild list of nets (full ratsnest rebuild)
2099
2100 // Update info shown by the horizontal toolbars
2102
2103 LSET activeLayers = GetBoard()->GetEnabledLayers();
2104
2105 if( !activeLayers.test( GetActiveLayer() ) )
2106 SetActiveLayer( activeLayers.Seq().front() );
2107
2108 m_SelLayerBox->SetLayerSelection( GetActiveLayer() );
2109
2111
2112 layerEnum.Choices().Clear();
2113 layerEnum.Undefined( UNDEFINED_LAYER );
2114
2115 for( PCB_LAYER_ID layer : LSET::AllLayersMask() )
2116 {
2117 // Canonical name
2118 layerEnum.Map( layer, LSET::Name( layer ) );
2119
2120 // User name
2121 layerEnum.Map( layer, GetBoard()->GetLayerName( layer ) );
2122 }
2123
2125
2126 // Sync visibility with canvas
2127 for( PCB_LAYER_ID layer : LSET::AllLayersMask() )
2128 GetCanvas()->GetView()->SetLayerVisible( layer, GetBoard()->IsLayerVisible( layer ) );
2129
2130 // Stackup and/or color theme may have changed
2131 m_appearancePanel->OnBoardChanged();
2132 m_netInspectorPanel->OnParentSetupChanged();
2133}
2134
2135
2137{
2138 // switches currently used canvas (Cairo / OpenGL).
2139 PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
2140}
2141
2142
2144{
2145 if( !m_findDialog )
2146 {
2147 m_findDialog = new DIALOG_FIND( this );
2148 m_findDialog->SetCallback( std::bind( &PCB_SELECTION_TOOL::FindItem,
2149 m_toolManager->GetTool<PCB_SELECTION_TOOL>(), _1 ) );
2150 }
2151
2152 wxString findString;
2153
2154 PCB_SELECTION& selection = m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
2155
2156 if( selection.Size() == 1 )
2157 {
2158 EDA_ITEM* front = selection.Front();
2159
2160 switch( front->Type() )
2161 {
2162 case PCB_FOOTPRINT_T:
2163 findString = UnescapeString( static_cast<FOOTPRINT*>( front )->GetValue() );
2164 break;
2165
2166 case PCB_FIELD_T:
2167 case PCB_TEXT_T:
2168 findString = UnescapeString( static_cast<PCB_TEXT*>( front )->GetText() );
2169
2170 if( findString.Contains( wxT( "\n" ) ) )
2171 findString = findString.Before( '\n' );
2172
2173 break;
2174
2175 default:
2176 break;
2177 }
2178 }
2179
2180 m_findDialog->Preload( findString );
2181
2182 m_findDialog->Show( true );
2183}
2184
2185
2194
2195
2201
2202
2208
2209
2210void PCB_EDIT_FRAME::FindNext( bool reverse )
2211{
2212 if( !m_findDialog )
2214
2215 m_findDialog->FindNext( reverse );
2216}
2217
2218
2220{
2221 if( Kiface().IsSingle() )
2222 return 0;
2223
2224 // Update PCB requires a netlist. Therefore the schematic editor must be running
2225 // If this is not the case, open the schematic editor
2226 KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
2227
2228 // If Kiway() cannot create the eeschema frame, it shows a error message, and
2229 // frame is null
2230 if( !frame )
2231 return -1;
2232
2233 if( !frame->IsShownOnScreen() )
2234 {
2235 wxEventBlocker blocker( this );
2236 wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
2238
2239 // Maybe the file hasn't been converted to the new s-expression file format so
2240 // see if the legacy schematic file is still in play.
2241 if( !fn.FileExists() )
2242 {
2244
2245 if( !fn.FileExists() )
2246 {
2247 DisplayErrorMessage( this, _( "The schematic for this board cannot be found." ) );
2248 return -2;
2249 }
2250 }
2251
2252 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
2253
2254 // we show the schematic editor frame, because do not show is seen as
2255 // a not yet opened schematic by Kicad manager, which is not the case
2256 frame->Show( true );
2257
2258 // bring ourselves back to the front
2259 Raise();
2260 }
2261
2262 return 1; //Success!
2263}
2264
2265
2267 const wxString& aAnnotateMessage )
2268{
2269 int standalone = TestStandalone();
2270
2271 if( standalone == 0 )
2272 {
2273 DisplayErrorMessage( this, _( "Cannot update the PCB because PCB editor is opened in "
2274 "stand-alone mode. In order to create or update PCBs from "
2275 "schematics, you must launch the KiCad project manager and "
2276 "create a project." ) );
2277 return false; // Not in standalone mode
2278 }
2279
2280 if( standalone < 0 ) // Problem with Eeschema or the schematic
2281 return false;
2282
2283 Raise(); // Show
2284
2285 std::string payload( aAnnotateMessage );
2286
2287 Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
2288
2289 if( payload == aAnnotateMessage )
2290 {
2291 Raise();
2292 DisplayErrorMessage( this, aAnnotateMessage );
2293 return false;
2294 }
2295
2296 try
2297 {
2298 auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
2299 KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
2300 netlistReader.LoadNetlist();
2301 }
2302 catch( const IO_ERROR& e )
2303 {
2304 Raise();
2305
2306 // Do not translate extra_info strings. These are for developers
2307 wxString extra_info = e.Problem() + wxT( " : " ) + e.What() + wxT( " at " ) + e.Where();
2308
2309 DisplayErrorMessage( this, _( "Received an error while reading netlist. Please "
2310 "report this issue to the KiCad team using the menu "
2311 "Help->Report Bug."), extra_info );
2312 return false;
2313 }
2314
2315 return true;
2316}
2317
2318
2320{
2321 if( aFootprint == nullptr )
2322 return;
2323
2325
2326 /*
2327 * Make sure dlg is destroyed before GetCanvas->Refresh is called
2328 * later or the refresh will try to modify its properties since
2329 * they share a GL context.
2330 */
2331 {
2332 DIALOG_FOOTPRINT_PROPERTIES dlg( this, aFootprint );
2333
2334 dlg.ShowQuasiModal();
2335 retvalue = dlg.GetReturnValue();
2336 }
2337
2338 /*
2339 * retvalue =
2340 * FP_PROPS_UPDATE_FP to show Update Footprints dialog
2341 * FP_PROPS_CHANGE_FP to show Change Footprints dialog
2342 * FP_PROPS_OK for normal edit
2343 * FP_PROPS_CANCEL if aborted
2344 * FP_PROPS_EDIT_BOARD_FP to load board footprint into Footprint Editor
2345 * FP_PROPS_EDIT_LIBRARY_FP to load library footprint into Footprint Editor
2346 */
2347
2349 {
2350 // If something edited, push a refresh request
2351 GetCanvas()->Refresh();
2352 }
2354 {
2355 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ) )
2356 {
2357 FOOTPRINT_EDIT_FRAME* fp_editor = static_cast<FOOTPRINT_EDIT_FRAME*>( frame );
2358
2359 fp_editor->LoadFootprintFromBoard( aFootprint );
2360 fp_editor->Show( true );
2361 fp_editor->Raise(); // Iconize( false );
2362 }
2363 }
2365 {
2366 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ) )
2367 {
2368 FOOTPRINT_EDIT_FRAME* fp_editor = static_cast<FOOTPRINT_EDIT_FRAME*>( frame );
2369
2370 fp_editor->LoadFootprintFromLibrary( aFootprint->GetFPID() );
2371 fp_editor->Show( true );
2372 fp_editor->Raise(); // Iconize( false );
2373 }
2374 }
2376 {
2377 ShowExchangeFootprintsDialog( aFootprint, true, true );
2378 }
2380 {
2381 ShowExchangeFootprintsDialog( aFootprint, false, true );
2382 }
2383}
2384
2385
2387 bool aSelectedMode )
2388{
2389 DIALOG_EXCHANGE_FOOTPRINTS dialog( this, aFootprint, aUpdateMode, aSelectedMode );
2390
2391 return dialog.ShowQuasiModal();
2392}
2393
2394
2408static void processTextItem( const PCB_TEXT& aSrc, PCB_TEXT& aDest, const VECTOR2I& aPosShift,
2409 const EDA_ANGLE& aAngleShift, bool aResetText, bool aResetTextLayers,
2410 bool aResetTextEffects, bool aResetTextPositions, bool* aUpdated )
2411{
2412 if( aResetText )
2413 *aUpdated |= aSrc.GetText() != aDest.GetText();
2414 else
2415 aDest.SetText( aSrc.GetText() );
2416
2417 if( aResetTextLayers )
2418 {
2419 *aUpdated |= aSrc.GetLayer() != aDest.GetLayer();
2420 *aUpdated |= aSrc.IsVisible() != aDest.IsVisible();
2421 }
2422 else
2423 {
2424 aDest.SetLayer( aSrc.GetLayer() );
2425 aDest.SetVisible( aSrc.IsVisible() );
2426 }
2427
2428 VECTOR2I origPos = aDest.GetFPRelativePosition();
2429
2430 if( aResetTextEffects )
2431 {
2432 *aUpdated |= aSrc.GetHorizJustify() != aDest.GetHorizJustify();
2433 *aUpdated |= aSrc.GetVertJustify() != aDest.GetVertJustify();
2434 *aUpdated |= aSrc.GetTextSize() != aDest.GetTextSize();
2435 *aUpdated |= aSrc.GetTextThickness() != aDest.GetTextThickness();
2436 }
2437 else
2438 {
2439 EDA_ANGLE origAngle = aDest.GetTextAngle();
2440 aDest.SetAttributes( aSrc );
2441 aDest.SetTextAngle( origAngle ); // apply rotation as part of position shift
2442 }
2443
2444 if( aResetTextPositions )
2445 {
2446 *aUpdated |= aSrc.GetFPRelativePosition() != origPos;
2447 *aUpdated |= aSrc.GetTextAngle() != aDest.GetTextAngle();
2448
2449 aDest.SetFPRelativePosition( origPos );
2450 }
2451 else
2452 {
2453 VECTOR2I rotatedShift = GetRotated( aSrc.GetFPRelativePosition() - aPosShift, -aAngleShift );
2454
2455 aDest.SetFPRelativePosition( rotatedShift );
2456 aDest.SetTextAngle( aSrc.GetTextAngle() );
2457 }
2458
2459 aDest.SetLocked( aSrc.IsLocked() );
2460 aDest.SetUuid( aSrc.m_Uuid );
2461}
2462
2463
2464template<typename T>
2465static std::vector<std::pair<T*, T*>> matchItemsBySimilarity( const std::vector<T*>& aExisting,
2466 const std::vector<T*>& aNew )
2467{
2468 struct MATCH_CANDIDATE
2469 {
2470 T* existing;
2471 T* updated;
2472 double score;
2473 };
2474
2475 std::vector<MATCH_CANDIDATE> candidates;
2476
2477 for( T* existing : aExisting )
2478 {
2479 for( T* updated : aNew )
2480 {
2481 if( existing->Type() != updated->Type() )
2482 continue;
2483
2484 double similarity = existing->Similarity( *updated );
2485
2486 if constexpr( std::is_same_v<T, PAD> )
2487 {
2488 if( existing->GetNumber() == updated->GetNumber() )
2489 similarity += 2.0;
2490 }
2491
2492 if( similarity <= 0.0 )
2493 continue;
2494
2495 candidates.push_back( { existing, updated, similarity } );
2496 }
2497 }
2498
2499 std::sort( candidates.begin(), candidates.end(),
2500 []( const MATCH_CANDIDATE& a, const MATCH_CANDIDATE& b )
2501 {
2502 if( a.score != b.score )
2503 return a.score > b.score;
2504
2505 if( a.existing != b.existing )
2506 return a.existing < b.existing;
2507
2508 return a.updated < b.updated;
2509 } );
2510
2511 std::vector<std::pair<T*, T*>> matches;
2512 matches.reserve( candidates.size() );
2513
2514 std::unordered_set<T*> matchedExisting;
2515 std::unordered_set<T*> matchedNew;
2516
2517 for( const MATCH_CANDIDATE& candidate : candidates )
2518 {
2519 if( matchedExisting.find( candidate.existing ) != matchedExisting.end() )
2520 continue;
2521
2522 if( matchedNew.find( candidate.updated ) != matchedNew.end() )
2523 continue;
2524
2525 matchedExisting.insert( candidate.existing );
2526 matchedNew.insert( candidate.updated );
2527 matches.emplace_back( candidate.existing, candidate.updated );
2528 }
2529
2530 return matches;
2531}
2532
2533
2535 BOARD_COMMIT& aCommit,
2536 bool matchPadPositions,
2537 bool deleteExtraTexts,
2538 bool resetTextLayers,
2539 bool resetTextEffects,
2540 bool resetTextPositions,
2541 bool resetTextContent,
2542 bool resetFabricationAttrs,
2543 bool resetClearanceOverrides,
2544 bool reset3DModels,
2545 bool* aUpdated )
2546{
2547 EDA_GROUP* parentGroup = aExisting->GetParentGroup();
2548 bool dummyBool = false;
2549
2550 if( !aUpdated )
2551 aUpdated = &dummyBool;
2552
2553 if( parentGroup )
2554 {
2555 aCommit.Modify( parentGroup->AsEdaItem(), nullptr, RECURSE_MODE::NO_RECURSE );
2556 parentGroup->RemoveItem( aExisting );
2557 parentGroup->AddItem( aNew );
2558 }
2559
2560 aNew->SetParent( GetBoard() );
2561
2562 // This is the position and angle shift to apply to the new footprint if the footprint
2563 // has a change anchor point or rotation compared to the existing footprint.
2564 VECTOR2I posShift( 0, 0 );
2565 EDA_ANGLE angleShift = ANGLE_0;
2566
2567 VECTOR2I position = aExisting->GetPosition();
2568 EDA_ANGLE orientation = aExisting->GetOrientation();
2569
2570 if( matchPadPositions )
2571 {
2572 if( ComputeFootprintShift( *aExisting, *aNew, posShift, angleShift ) )
2573 {
2574 position += posShift;
2575 orientation += angleShift;
2576 }
2577 }
2578
2579 PlaceFootprint( aNew, false, position );
2580
2581 if( aNew->GetLayer() != aExisting->GetLayer() )
2582 aNew->Flip( aNew->GetPosition(), GetPcbNewSettings()->m_FlipDirection );
2583
2584 if( aNew->GetOrientation() != orientation )
2585 aNew->SetOrientation( orientation );
2586
2587 aNew->SetLocked( aExisting->IsLocked() );
2588
2589 aNew->SetUuid( aExisting->m_Uuid );
2590 aNew->Reference().SetUuid( aExisting->Reference().m_Uuid );
2591 aNew->Value().SetUuid( aExisting->Value().m_Uuid );
2592
2593 std::vector<PAD*> oldPads;
2594 oldPads.reserve( aExisting->Pads().size() );
2595
2596 for( PAD* pad : aExisting->Pads() )
2597 oldPads.push_back( pad );
2598
2599 std::vector<PAD*> newPads;
2600 newPads.reserve( aNew->Pads().size() );
2601
2602 for( PAD* pad : aNew->Pads() )
2603 newPads.push_back( pad );
2604
2605 auto padMatches = matchItemsBySimilarity<PAD>( oldPads, newPads );
2606 std::unordered_set<PAD*> matchedNewPads;
2607
2608 for( const auto& match : padMatches )
2609 {
2610 PAD* oldPad = match.first;
2611 PAD* newPad = match.second;
2612
2613 matchedNewPads.insert( newPad );
2614 newPad->SetUuid( oldPad->m_Uuid );
2616 newPad->SetPinFunction( oldPad->GetPinFunction() );
2617 newPad->SetPinType( oldPad->GetPinType() );
2618
2619 if( newPad->IsOnCopperLayer() )
2620 newPad->SetNetCode( oldPad->GetNetCode() );
2621 else
2623 }
2624
2625 for( PAD* newPad : aNew->Pads() )
2626 {
2627 if( matchedNewPads.find( newPad ) != matchedNewPads.end() )
2628 continue;
2629
2630 newPad->ResetUuid();
2631 newPad->SetNetCode( NETINFO_LIST::UNCONNECTED );
2632 }
2633
2634 std::vector<BOARD_ITEM*> oldDrawings;
2635 oldDrawings.reserve( aExisting->GraphicalItems().size() );
2636
2637 for( BOARD_ITEM* item : aExisting->GraphicalItems() )
2638 oldDrawings.push_back( item );
2639
2640 std::vector<BOARD_ITEM*> newDrawings;
2641 newDrawings.reserve( aNew->GraphicalItems().size() );
2642
2643 for( BOARD_ITEM* item : aNew->GraphicalItems() )
2644 newDrawings.push_back( item );
2645
2646 auto drawingMatches = matchItemsBySimilarity<BOARD_ITEM>( oldDrawings, newDrawings );
2647 std::unordered_map<BOARD_ITEM*, BOARD_ITEM*> oldToNewDrawings;
2648 std::unordered_set<BOARD_ITEM*> matchedNewDrawings;
2649
2650 for( const auto& match : drawingMatches )
2651 {
2652 BOARD_ITEM* oldItem = match.first;
2653 BOARD_ITEM* newItem = match.second;
2654
2655 oldToNewDrawings[ oldItem ] = newItem;
2656 matchedNewDrawings.insert( newItem );
2657 newItem->SetUuid( oldItem->m_Uuid );
2658 }
2659
2660 for( BOARD_ITEM* newItem : newDrawings )
2661 {
2662 if( matchedNewDrawings.find( newItem ) == matchedNewDrawings.end() )
2663 newItem->ResetUuid();
2664 }
2665
2666 std::vector<ZONE*> oldZones;
2667 oldZones.reserve( aExisting->Zones().size() );
2668
2669 for( ZONE* zone : aExisting->Zones() )
2670 oldZones.push_back( zone );
2671
2672 std::vector<ZONE*> newZones;
2673 newZones.reserve( aNew->Zones().size() );
2674
2675 for( ZONE* zone : aNew->Zones() )
2676 newZones.push_back( zone );
2677
2678 auto zoneMatches = matchItemsBySimilarity<ZONE>( oldZones, newZones );
2679 std::unordered_set<ZONE*> matchedNewZones;
2680
2681 for( const auto& match : zoneMatches )
2682 {
2683 ZONE* oldZone = match.first;
2684 ZONE* newZone = match.second;
2685
2686 matchedNewZones.insert( newZone );
2687 newZone->SetUuid( oldZone->m_Uuid );
2688 }
2689
2690 for( ZONE* newZone : newZones )
2691 {
2692 if( matchedNewZones.find( newZone ) == matchedNewZones.end() )
2693 newZone->ResetUuid();
2694 }
2695
2696 std::vector<PCB_POINT*> oldPoints;
2697 oldPoints.reserve( aExisting->Points().size() );
2698
2699 for( PCB_POINT* point : aExisting->Points() )
2700 oldPoints.push_back( point );
2701
2702 std::vector<PCB_POINT*> newPoints;
2703 newPoints.reserve( aNew->Points().size() );
2704
2705 for( PCB_POINT* point : aNew->Points() )
2706 newPoints.push_back( point );
2707
2708 auto pointMatches = matchItemsBySimilarity<PCB_POINT>( oldPoints, newPoints );
2709 std::unordered_set<PCB_POINT*> matchedNewPoints;
2710
2711 for( const auto& match : pointMatches )
2712 {
2713 PCB_POINT* oldPoint = match.first;
2714 PCB_POINT* newPoint = match.second;
2715
2716 matchedNewPoints.insert( newPoint );
2717 newPoint->SetUuid( oldPoint->m_Uuid );
2718 }
2719
2720 for( PCB_POINT* newPoint : newPoints )
2721 {
2722 if( matchedNewPoints.find( newPoint ) == matchedNewPoints.end() )
2723 newPoint->ResetUuid();
2724 }
2725
2726 std::vector<PCB_GROUP*> oldGroups;
2727 oldGroups.reserve( aExisting->Groups().size() );
2728
2729 for( PCB_GROUP* group : aExisting->Groups() )
2730 oldGroups.push_back( group );
2731
2732 std::vector<PCB_GROUP*> newGroups;
2733 newGroups.reserve( aNew->Groups().size() );
2734
2735 for( PCB_GROUP* group : aNew->Groups() )
2736 newGroups.push_back( group );
2737
2738 auto groupMatches = matchItemsBySimilarity<PCB_GROUP>( oldGroups, newGroups );
2739 std::unordered_set<PCB_GROUP*> matchedNewGroups;
2740
2741 for( const auto& match : groupMatches )
2742 {
2743 PCB_GROUP* oldGroup = match.first;
2744 PCB_GROUP* newGroup = match.second;
2745
2746 matchedNewGroups.insert( newGroup );
2747 newGroup->SetUuid( oldGroup->m_Uuid );
2748 }
2749
2750 for( PCB_GROUP* newGroup : newGroups )
2751 {
2752 if( matchedNewGroups.find( newGroup ) == matchedNewGroups.end() )
2753 newGroup->ResetUuid();
2754 }
2755
2756 std::vector<PCB_FIELD*> oldFieldsVec;
2757 std::vector<PCB_FIELD*> newFieldsVec;
2758
2759 oldFieldsVec.reserve( aExisting->GetFields().size() );
2760
2761 for( PCB_FIELD* field : aExisting->GetFields() )
2762 {
2763 wxCHECK2( field, continue );
2764
2765 if( field->IsReference() || field->IsValue() )
2766 continue;
2767
2768 oldFieldsVec.push_back( field );
2769 }
2770
2771 newFieldsVec.reserve( aNew->GetFields().size() );
2772
2773 for( PCB_FIELD* field : aNew->GetFields() )
2774 {
2775 wxCHECK2( field, continue );
2776
2777 if( field->IsReference() || field->IsValue() )
2778 continue;
2779
2780 newFieldsVec.push_back( field );
2781 }
2782
2783 auto fieldMatches = matchItemsBySimilarity<PCB_FIELD>( oldFieldsVec, newFieldsVec );
2784 std::unordered_map<PCB_FIELD*, PCB_FIELD*> oldToNewFields;
2785 std::unordered_set<PCB_FIELD*> matchedNewFields;
2786
2787 for( const auto& match : fieldMatches )
2788 {
2789 PCB_FIELD* oldField = match.first;
2790 PCB_FIELD* newField = match.second;
2791
2792 oldToNewFields[ oldField ] = newField;
2793 matchedNewFields.insert( newField );
2794 newField->SetUuid( oldField->m_Uuid );
2795 }
2796
2797 for( PCB_FIELD* newField : newFieldsVec )
2798 {
2799 if( matchedNewFields.find( newField ) == matchedNewFields.end() )
2800 newField->ResetUuid();
2801 }
2802
2803 std::unordered_map<PCB_TEXT*, PCB_TEXT*> oldToNewTexts;
2804
2805 for( const auto& match : drawingMatches )
2806 {
2807 PCB_TEXT* oldText = dynamic_cast<PCB_TEXT*>( match.first );
2808 PCB_TEXT* newText = dynamic_cast<PCB_TEXT*>( match.second );
2809
2810 if( oldText && newText )
2811 oldToNewTexts[ oldText ] = newText;
2812 }
2813
2814 std::set<PCB_TEXT*> handledTextItems;
2815
2816 for( BOARD_ITEM* oldItem : aExisting->GraphicalItems() )
2817 {
2818 PCB_TEXT* oldTextItem = dynamic_cast<PCB_TEXT*>( oldItem );
2819
2820 if( oldTextItem )
2821 {
2822 // Dimensions have PCB_TEXT base but are not treated like texts in the updater
2823 if( dynamic_cast<PCB_DIMENSION_BASE*>( oldTextItem ) )
2824 continue;
2825
2826 PCB_TEXT* newTextItem = nullptr;
2827
2828 auto textMatchIt = oldToNewTexts.find( oldTextItem );
2829
2830 if( textMatchIt != oldToNewTexts.end() )
2831 newTextItem = textMatchIt->second;
2832
2833 if( newTextItem )
2834 {
2835 handledTextItems.insert( newTextItem );
2836 processTextItem( *oldTextItem, *newTextItem, posShift, angleShift, resetTextContent, resetTextLayers,
2837 resetTextEffects, resetTextPositions, aUpdated );
2838 }
2839 else if( deleteExtraTexts )
2840 {
2841 *aUpdated = true;
2842 }
2843 else
2844 {
2845 newTextItem = static_cast<PCB_TEXT*>( oldTextItem->Clone() );
2846 handledTextItems.insert( newTextItem );
2847 aNew->Add( newTextItem );
2848 }
2849 }
2850 }
2851
2852 // Check for any newly-added text items and set the update flag as appropriate
2853 for( BOARD_ITEM* newItem : aNew->GraphicalItems() )
2854 {
2855 PCB_TEXT* newTextItem = dynamic_cast<PCB_TEXT*>( newItem );
2856
2857 if( newTextItem )
2858 {
2859 // Dimensions have PCB_TEXT base but are not treated like texts in the updater
2860 if( dynamic_cast<PCB_DIMENSION_BASE*>( newTextItem ) )
2861 continue;
2862
2863 if( !handledTextItems.contains( newTextItem ) )
2864 {
2865 *aUpdated = true;
2866 break;
2867 }
2868 }
2869 }
2870
2871 // Copy reference. The initial text is always used, never resetted
2872 processTextItem( aExisting->Reference(), aNew->Reference(), posShift, angleShift, false, resetTextLayers,
2873 resetTextEffects, resetTextPositions, aUpdated );
2874
2875 // Copy value
2876 processTextItem( aExisting->Value(), aNew->Value(), posShift, angleShift,
2877 // reset value text only when it is a proxy for the footprint ID
2878 // (cf replacing value "MountingHole-2.5mm" with "MountingHole-4.0mm")
2879 aExisting->GetValue() == aExisting->GetFPID().GetLibItemName().wx_str(),
2880 resetTextLayers, resetTextEffects, resetTextPositions, aUpdated );
2881
2882 std::set<PCB_FIELD*> handledFields;
2883
2884 // Copy fields in accordance with the reset* flags
2885 for( PCB_FIELD* oldField : aExisting->GetFields() )
2886 {
2887 wxCHECK2( oldField, continue );
2888
2889 // Reference and value are already handled
2890 if( oldField->IsReference() || oldField->IsValue() )
2891 continue;
2892
2893 PCB_FIELD* newField = nullptr;
2894
2895 auto fieldMatchIt = oldToNewFields.find( oldField );
2896
2897 if( fieldMatchIt != oldToNewFields.end() )
2898 newField = fieldMatchIt->second;
2899
2900 if( newField )
2901 {
2902 handledFields.insert( newField );
2903 processTextItem( *oldField, *newField, posShift, angleShift, resetTextContent, resetTextLayers,
2904 resetTextEffects, resetTextPositions, aUpdated );
2905 }
2906 else if( deleteExtraTexts )
2907 {
2908 *aUpdated = true;
2909 }
2910 else
2911 {
2912 newField = new PCB_FIELD( *oldField );
2913 handledFields.insert( newField );
2914 aNew->Add( newField );
2915 }
2916 }
2917
2918 // Check for any newly-added fields and set the update flag as appropriate
2919 for( PCB_FIELD* newField : aNew->GetFields() )
2920 {
2921 wxCHECK2( newField, continue );
2922
2923 // Reference and value are already handled
2924 if( newField->IsReference() || newField->IsValue() )
2925 continue;
2926
2927 if( !handledFields.contains( newField ) )
2928 {
2929 *aUpdated = true;
2930 break;
2931 }
2932 }
2933
2934 if( resetFabricationAttrs )
2935 {
2936 // We've replaced the existing footprint with the library one, so the fabrication attrs
2937 // are already reset. Just set the aUpdated flag if appropriate.
2938 if( aNew->GetAttributes() != aExisting->GetAttributes() )
2939 *aUpdated = true;
2940 }
2941 else
2942 {
2943 aNew->SetAttributes( aExisting->GetAttributes() );
2944 }
2945
2946 if( resetClearanceOverrides )
2947 {
2948 if( aExisting->AllowSolderMaskBridges() != aNew->AllowSolderMaskBridges() )
2949 *aUpdated = true;
2950
2951 if( ( aExisting->GetLocalClearance() != aNew->GetLocalClearance() )
2952 || ( aExisting->GetLocalSolderMaskMargin() != aNew->GetLocalSolderMaskMargin() )
2953 || ( aExisting->GetLocalSolderPasteMargin() != aNew->GetLocalSolderPasteMargin() )
2955 || ( aExisting->GetLocalZoneConnection() != aNew->GetLocalZoneConnection() ) )
2956 {
2957 *aUpdated = true;
2958 }
2959 }
2960 else
2961 {
2962 aNew->SetLocalClearance( aExisting->GetLocalClearance() );
2966 aNew->SetLocalZoneConnection( aExisting->GetLocalZoneConnection() );
2968 }
2969
2970 if( reset3DModels )
2971 {
2972 // We've replaced the existing footprint with the library one, so the 3D models are
2973 // already reset. Just set the aUpdated flag if appropriate.
2974 if( aNew->Models().size() != aExisting->Models().size() )
2975 {
2976 *aUpdated = true;
2977 }
2978 else
2979 {
2980 for( size_t ii = 0; ii < aNew->Models().size(); ++ii )
2981 {
2982 if( aNew->Models()[ii] != aExisting->Models()[ii] )
2983 {
2984 *aUpdated = true;
2985 break;
2986 }
2987 }
2988 }
2989 }
2990 else
2991 {
2992 // Preserve model references and all embedded model data.
2993 aNew->Models() = aExisting->Models();
2994
2995 for( const auto& [name, file] : aExisting->GetEmbeddedFiles()->EmbeddedFileMap() )
2996 {
2998 continue;
2999
3000 aNew->GetEmbeddedFiles()->RemoveFile( name, true );
3002 }
3003 }
3004
3005 // Updating other parameters
3006 aNew->SetPath( aExisting->GetPath() );
3007 aNew->SetSheetfile( aExisting->GetSheetfile() );
3008 aNew->SetSheetname( aExisting->GetSheetname() );
3009 aNew->SetFilters( aExisting->GetFilters() );
3010 aNew->SetStaticComponentClass( aExisting->GetComponentClass() );
3011
3012 if( *aUpdated == false )
3013 {
3014 // Check pad shapes, graphics, zones, etc. for changes
3016 *aUpdated = true;
3017 }
3018
3019 aCommit.Remove( aExisting );
3020 aCommit.Add( aNew );
3021
3022 aNew->ClearFlags();
3023}
3024
3025
3027{
3029 m_appearancePanel->CommonSettingsChanged( aFlags );
3030
3032
3034
3035 SetElementVisibility( LAYER_RATSNEST, GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
3036
3038
3039 // Netclass definitions could have changed, either by us or by Eeschema, so we need to
3040 // recompile the implicit rules
3041 DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
3042 WX_INFOBAR* infobar = GetInfoBar();
3043
3044 try
3045 {
3047
3048 if( infobar->GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::DRC_RULES_ERROR )
3049 infobar->Dismiss();
3050 }
3051 catch( PARSE_ERROR& )
3052 {
3053 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Edit design rules" ),
3054 wxEmptyString );
3055
3056 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
3057 [&]( wxHyperlinkEvent& aEvent )
3058 {
3059 ShowBoardSetupDialog( _( "Custom Rules" ) );
3060 } ) );
3061
3062 infobar->RemoveAllButtons();
3063 infobar->AddButton( button );
3064 infobar->AddCloseButton();
3065 infobar->ShowMessage( _( "Could not compile custom design rules." ), wxICON_ERROR,
3066 WX_INFOBAR::MESSAGE_TYPE::DRC_RULES_ERROR );
3067 }
3068
3071
3072 Layout();
3073 SendSizeEvent();
3074}
3075
3076
3081
3082
3084{
3085 // Register autosave history saver for the board.
3086 // Saver serializes the in-memory BOARD into HISTORY_FILE_DATA. Prettify and
3087 // file I/O happen on a background thread to avoid blocking the UI.
3088 if( GetBoard() )
3089 {
3091 [this]( const wxString& aProjectPath, std::vector<HISTORY_FILE_DATA>& aFileData )
3092 {
3093 GetBoard()->SaveToHistory( aProjectPath, aFileData );
3094 } );
3095 }
3096}
3097
3098
3100{
3101 TOOL_BASE* currentTool = GetToolManager()->GetCurrentTool();
3102
3103 // When a single item that can be point-edited is selected, the point editor
3104 // tool will be active instead of the selection tool. It blocks undo/redo
3105 // while the user is actually dragging points around, though, so we can use
3106 // this as an initial check to prevent API actions when points are being edited.
3107 if( UndoRedoBlocked() )
3108 return false;
3109
3110 // Don't allow any API use while the user is using a tool that could
3111 // modify the model in the middle of the message stream
3112 if( currentTool != GetToolManager()->GetTool<PCB_SELECTION_TOOL>() &&
3113 currentTool != GetToolManager()->GetTool<PCB_POINT_EDITOR>() )
3114 {
3115 return false;
3116 }
3117
3118 ZONE_FILLER_TOOL* zoneFillerTool = m_toolManager->GetTool<ZONE_FILLER_TOOL>();
3119
3120 if( zoneFillerTool->IsBusy() )
3121 return false;
3122
3123 ROUTER_TOOL* routerTool = m_toolManager->GetTool<ROUTER_TOOL>();
3124
3125 if( routerTool && routerTool->RoutingInProgress() )
3126 return false;
3127
3129}
3130
3131
3137
3138
3139bool PCB_EDIT_FRAME::GetPluginActionButtonVisible( const wxString& aPluginPath, bool aPluginDefault )
3140{
3141 if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
3142 {
3143 for( const auto& [identifier, visible] : cfg->m_Plugins.actions )
3144 {
3145 if( identifier == aPluginPath )
3146 return visible;
3147 }
3148 }
3149
3150 // Plugin is not in settings, return default.
3151 return aPluginDefault;
3152}
3153
3154
3156{
3157 return GetBoard()->GetFileName();
3158}
3159
3160
3162{
3163 return m_auimgr.GetPane( wxS( "LayersManager" ) ).IsShown();
3164}
3165
3166
3168{
3169 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
3170}
3171
3172
3174{
3175 return m_auimgr.GetPane( NetInspectorPanelName() ).IsShown();
3176}
3177
3178
3179void PCB_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
3180{
3181 if( IsShownOnScreen() )
3182 {
3183 // We only need this until the frame is done resizing and the final client size is
3184 // established.
3185 Unbind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
3187 }
3188
3189 // Skip() is called in the base class.
3190 EDA_DRAW_FRAME::OnSize( aEvent );
3191}
3192
3193
3204
3205
3216
3217
3228
3229
3231{
3232 if( !m_footprintDiffDlg )
3233 {
3235 _( "Compare Footprint with Library" ) );
3236
3237 m_footprintDiffDlg->m_sdbSizerApply->SetLabel( _( "Update Footprint from Library..." ) );
3238 m_footprintDiffDlg->m_sdbSizerApply->PostSizeEventToParent();
3239 m_footprintDiffDlg->m_sdbSizerApply->Show();
3240 }
3241
3242 return m_footprintDiffDlg;
3243}
3244
3245
3247{
3248 if( m_inspectDrcErrorDlg && aEvent.GetString() == INSPECT_DRC_ERROR_DIALOG_NAME )
3249 {
3250 m_inspectDrcErrorDlg->Destroy();
3251 m_inspectDrcErrorDlg = nullptr;
3252 }
3253 else if( m_inspectClearanceDlg && aEvent.GetString() == INSPECT_CLEARANCE_DIALOG_NAME )
3254 {
3255 m_inspectClearanceDlg->Destroy();
3256 m_inspectClearanceDlg = nullptr;
3257 }
3258 else if( m_inspectConstraintsDlg && aEvent.GetString() == INSPECT_CONSTRAINTS_DIALOG_NAME )
3259 {
3260 m_inspectConstraintsDlg->Destroy();
3261 m_inspectConstraintsDlg = nullptr;
3262 }
3263 else if( m_footprintDiffDlg && aEvent.GetString() == FOOTPRINT_DIFF_DIALOG_NAME )
3264 {
3265 if( aEvent.GetId() == wxID_APPLY )
3266 {
3267 KIID fpUUID = m_footprintDiffDlg->GetUserItemID();
3268
3269 CallAfter(
3270 [this, fpUUID]()
3271 {
3272 BOARD_ITEM* item = m_pcb->ResolveItem( fpUUID );
3273
3274 if( FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( item ) )
3275 {
3276 m_toolManager->RunAction<EDA_ITEM*>( ACTIONS::selectItem, footprint );
3277
3278 DIALOG_EXCHANGE_FOOTPRINTS dialog( this, footprint, true, true );
3279 dialog.ShowQuasiModal();
3280 }
3281 } );
3282 }
3283
3284 m_footprintDiffDlg->Destroy();
3285 m_footprintDiffDlg = nullptr;
3286 }
3287}
3288
3289
3290#ifdef KICAD_IPC_API
3291void PCB_EDIT_FRAME::onPluginAvailabilityChanged( wxCommandEvent& aEvt )
3292{
3293 wxLogTrace( traceApi, "PCB frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
3295 aEvt.Skip();
3296}
3297#endif
3298
3299
3301{
3302 PCB_LAYER_ID curLayer = GetActiveLayer();
3303 const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
3304
3305 // Check if the specified layer matches the present layer
3306 if( layer == curLayer )
3307 return;
3308
3309 // Copper layers cannot be selected unconditionally; how many of those layers are currently
3310 // enabled needs to be checked.
3311 if( IsCopperLayer( layer ) )
3312 {
3313 if( layer > GetBoard()->GetCopperLayerStackMaxId() )
3314 return;
3315 }
3316
3317 // Is yet more checking required? E.g. when the layer to be selected is a non-copper layer,
3318 // or when switching between a copper layer and a non-copper layer, or vice-versa?
3319
3320 SetActiveLayer( layer );
3321
3323 GetCanvas()->Refresh();
3324}
3325
3326
3328{
3329 switch( aItem->Type() )
3330 {
3333 break;
3334
3335 case PCB_BARCODE_T:
3336 ShowBarcodePropertiesDialog( static_cast<PCB_BARCODE*>( aItem ) );
3337 break;
3338
3339 case PCB_FIELD_T:
3340 case PCB_TEXT_T:
3341 ShowTextPropertiesDialog( static_cast<PCB_TEXT*>( aItem ) );
3342 break;
3343
3344 case PCB_TEXTBOX_T:
3345 ShowTextBoxPropertiesDialog( static_cast<PCB_TEXTBOX*>( aItem ) );
3346 break;
3347
3348 case PCB_TABLE_T:
3349 {
3350 DIALOG_TABLE_PROPERTIES dlg( this, static_cast<PCB_TABLE*>( aItem ) );
3351
3352 //QuasiModal required for Scintilla auto-complete
3353 dlg.ShowQuasiModal();
3354 break;
3355 }
3356
3357 case PCB_PAD_T:
3358 ShowPadPropertiesDialog( static_cast<PAD*>( aItem ) );
3359 break;
3360
3361 case PCB_FOOTPRINT_T:
3362 ShowFootprintPropertiesDialog( static_cast<FOOTPRINT*>( aItem ) );
3363 break;
3364
3365 case PCB_TARGET_T:
3366 ShowTargetOptionsDialog( static_cast<PCB_TARGET*>( aItem ) );
3367 break;
3368
3369 case PCB_DIM_ALIGNED_T:
3370 case PCB_DIM_CENTER_T:
3371 case PCB_DIM_RADIAL_T:
3373 case PCB_DIM_LEADER_T:
3374 {
3375 DIALOG_DIMENSION_PROPERTIES dlg( this, static_cast<PCB_DIMENSION_BASE*>( aItem ) );
3376
3377 dlg.ShowModal();
3378 break;
3379 }
3380
3381 case PCB_SHAPE_T:
3382 ShowGraphicItemPropertiesDialog( static_cast<PCB_SHAPE*>( aItem ) );
3383 break;
3384
3385 case PCB_ZONE_T:
3386 Edit_Zone_Params( static_cast<ZONE*>( aItem ) );
3387 break;
3388
3389 case PCB_GROUP_T:
3391 static_cast<EDA_GROUP*>( static_cast<PCB_GROUP*>( aItem ) ) );
3392 break;
3393
3394 case PCB_GENERATOR_T:
3395 static_cast<PCB_GENERATOR*>( aItem )->ShowPropertiesDialog( this );
3396 break;
3397
3398 case PCB_MARKER_T:
3399 m_toolManager->GetTool<DRC_TOOL>()->CrossProbe( static_cast<PCB_MARKER*>( aItem ) );
3400 break;
3401
3402 case PCB_POINT_T:
3403 break;
3404
3405 default:
3406 break;
3407 }
3408}
3409
3410
3412{
3413 // For now we just delegate to the base implementation which commits any pending
3414 // local history snapshots. If PCB-specific preconditions are later needed (e.g.
3415 // flushing zone fills or router state) they can be added here before calling the
3416 // base class method.
3418}
const char * name
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:112
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:104
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
@ HIDDEN
Inactive layers are hidden.
constexpr BOX2I BOX2ISafe(const BOX2D &aInput)
Definition box2.h:929
BOX2< VECTOR2D > BOX2D
Definition box2.h:923
static TOOL_ACTION toggleGrid
Definition actions.h:198
static TOOL_ACTION paste
Definition actions.h:80
static TOOL_ACTION unselectAll
Definition actions.h:83
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition actions.h:227
static TOOL_ACTION togglePolarCoords
Definition actions.h:209
static TOOL_ACTION copy
Definition actions.h:78
static TOOL_ACTION pluginsReload
Definition actions.h:294
static TOOL_ACTION selectSetLasso
Definition actions.h:221
static TOOL_ACTION selectSetRect
Set lasso selection mode.
Definition actions.h:220
static TOOL_ACTION group
Definition actions.h:239
static TOOL_ACTION pasteSpecial
Definition actions.h:81
static TOOL_ACTION groupProperties
Definition actions.h:247
static TOOL_ACTION pointEditorArcKeepCenter
Definition actions.h:273
static TOOL_ACTION ungroup
Definition actions.h:240
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:157
static TOOL_ACTION pointEditorArcKeepRadius
Definition actions.h:275
static TOOL_ACTION showSearch
Definition actions.h:116
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION duplicate
Definition actions.h:84
static TOOL_ACTION highContrastMode
Definition actions.h:155
static TOOL_ACTION embeddedFiles
Definition actions.h:297
static TOOL_ACTION measureTool
Definition actions.h:252
static TOOL_ACTION doDelete
Definition actions.h:85
static TOOL_ACTION selectionTool
Definition actions.h:251
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION zoomFitScreen
Definition actions.h:142
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:146
static TOOL_ACTION showProperties
Definition actions.h:266
static TOOL_ACTION cut
Definition actions.h:77
static TOOL_ACTION gridSetOrigin
Definition actions.h:195
static TOOL_ACTION toggleGridOverrides
Definition actions.h:199
static TOOL_ACTION selectAll
Definition actions.h:82
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition actions.h:274
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:48
Tool responsible for automagic placement of components.
Handles how to draw a screen (a board, a schematic ...)
Definition base_screen.h:41
int GetPageCount() const
Definition base_screen.h:72
bool IsContentModified() const
Definition base_screen.h:60
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,...
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
void SetLocalRatsnestVisible(bool aVisible)
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:84
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:268
void SetLocked(bool aLocked) override
Definition board_item.h:359
void SetUuid(const KIID &aUuid)
bool IsLocked() const override
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition board_item.h:350
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:316
VECTOR2I GetFPRelativePosition() const
@ INSTANCE_TO_INSTANCE
Definition board_item.h:478
void SetFPRelativePosition(const VECTOR2I &aPos)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:323
void BuildListOfNets()
Definition board.h:967
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition board.cpp:1042
void RemoveAllListeners()
Remove all listeners.
Definition board.cpp:3447
const PAGE_INFO & GetPageSettings() const
Definition board.h:807
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
Definition board.cpp:1036
void InitializeClearanceCache()
Initialize the clearance cache for all board items.
Definition board.cpp:1110
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:3899
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:195
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition board.cpp:2887
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition board.cpp:205
const wxString & GetFileName() const
Definition board.h:360
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition board.cpp:1048
void ClearProject()
Definition board.cpp:246
bool IsEmpty() const
Definition board.cpp:606
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:2392
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition board.cpp:976
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition board.cpp:307
void SynchronizeTuningProfileProperties()
Ensure that all time domain properties providers are in sync with current settings.
Definition board.cpp:2881
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:571
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:558
void SetColor(int aLayer, const COLOR4D &aColor)
COLOR4D GetColor(int aLayer) const
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition commit.h:90
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:106
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Definition commit.h:78
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
enum FP_PROPS_RETVALUE GetReturnValue()
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:87
bool IsDRCRunning() const
Check to see if the DRC engine is running the tests.
Definition drc_tool.h:74
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 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 ReCreateAuxiliaryToolbar()
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 set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:46
void RemoveItem(EDA_ITEM *aItem)
Remove item from group.
Definition eda_group.cpp:40
void AddItem(EDA_ITEM *aItem)
Add item to group.
Definition eda_group.cpp:27
virtual EDA_ITEM * AsEdaItem()=0
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:100
const KIID m_Uuid
Definition eda_item.h:528
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:118
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition eda_item.h:151
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:93
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:91
const EDA_ANGLE & GetTextAngle() const
Definition eda_text.h:158
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:109
virtual bool IsVisible() const
Definition eda_text.h:198
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
Definition eda_text.cpp:417
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition eda_text.h:211
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:370
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition eda_text.h:214
virtual void SetText(const wxString &aText)
Definition eda_text.cpp:254
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:283
int GetTextThickness() const
Definition eda_text.h:139
VECTOR2I GetTextSize() const
Definition eda_text.h:272
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:56
void RemoveFile(const wxString &name, bool aErase=true)
Remove a file from the collection and frees the memory.
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
const std::map< wxString, EMBEDDED_FILE * > & EmbeddedFileMap() const
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:770
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.
bool AllowSolderMaskBridges() const
Definition footprint.h:443
ZONE_CONNECTION GetLocalZoneConnection() const
Definition footprint.h:419
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition footprint.h:574
EDA_ANGLE GetOrientation() const
Definition footprint.h:350
ZONES & Zones()
Definition footprint.h:332
PCB_POINTS & Points()
Definition footprint.h:338
void SetOrientation(const EDA_ANGLE &aNewAngle)
void SetAllowSolderMaskBridges(bool aAllow)
Definition footprint.h:444
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition footprint.h:416
wxString GetSheetname() const
Definition footprint.h:397
void SetPath(const KIID_PATH &aPath)
Definition footprint.h:395
void SetFilters(const wxString &aFilters)
Definition footprint.h:404
void SetStaticComponentClass(const COMPONENT_CLASS *aClass) const
Sets the component class object pointer for this footprint.
bool FootprintNeedsUpdate(const FOOTPRINT *aLibFP, int aCompareFlags=0, REPORTER *aReporter=nullptr)
Return true if a board footprint differs from the library version.
void SetAttributes(int aAttributes)
Definition footprint.h:438
void SetSheetfile(const wxString &aSheetfile)
Definition footprint.h:401
std::optional< int > GetLocalSolderPasteMargin() const
Definition footprint.h:412
PCB_FIELD & Value()
read/write accessors:
Definition footprint.h:807
std::optional< int > GetLocalClearance() const
Definition footprint.h:406
std::deque< PAD * > & Pads()
Definition footprint.h:326
int GetAttributes() const
Definition footprint.h:437
const COMPONENT_CLASS * GetComponentClass() const
Returns the component class for this footprint.
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition footprint.h:418
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition footprint.h:359
wxString GetSheetfile() const
Definition footprint.h:400
const LIB_ID & GetFPID() const
Definition footprint.h:371
bool IsLocked() const override
Definition footprint.h:564
PCB_FIELD & Reference()
Definition footprint.h:808
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition footprint.h:415
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
GROUPS & Groups()
Definition footprint.h:335
wxString GetFilters() const
Definition footprint.h:403
void SetSheetname(const wxString &aSheetname)
Definition footprint.h:398
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly) const
Populate a std::vector with PCB_TEXTs.
std::vector< FP_3DMODEL > & Models()
Definition footprint.h:343
const wxString & GetValue() const
Definition footprint.h:793
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition footprint.h:410
void SetLocalClearance(std::optional< int > aClearance)
Definition footprint.h:407
const KIID_PATH & GetPath() const
Definition footprint.h:394
std::optional< int > GetLocalSolderMaskMargin() const
Definition footprint.h:409
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition footprint.h:413
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition footprint.h:1223
VECTOR2I GetPosition() const override
Definition footprint.h:347
DRAWINGS & GraphicalItems()
Definition footprint.h:329
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
bool Contains(GAL_LAYER_ID aPos)
Definition layer_ids.h:439
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?
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:95
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
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:91
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:86
bool IsBOARD_ITEM() const
Definition view_item.h:102
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:67
double GetScale() const
Definition view.h:285
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition view.cpp:598
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:1809
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition view.h:409
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition view.cpp:1666
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition view.h:656
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:1682
An implementation of class VIEW_CONTROLS for wxWidgets library.
std::unique_ptr< PROF_COUNTER > m_MotionEventCounter
Definition kiid.h:48
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:315
void OnKiCadExit()
Definition kiway.cpp:798
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:402
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:500
LOCAL_HISTORY & LocalHistory()
Return the LOCAL_HISTORY associated with this KIWAY.
Definition kiway.h:426
virtual void CommonSettingsChanged(int aFlags=0)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition kiway.cpp:594
PCB_LAYER_ID GetLayerA() const
PCB_LAYER_ID GetLayerB() const
const UTF8 & GetLibItemName() const
Definition lib_id.h:102
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.
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:313
static const LSET & AllLayersMask()
Definition lset.cpp:641
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition lset.cpp:188
@ MARKER_DRAWING_SHEET
Definition marker_base.h:56
Tool responsible for adding microwave features to PCBs.
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition netinfo.h:228
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition pad.h:55
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition pad.h:153
const wxString & GetPinType() const
Definition pad.h:154
const wxString & GetPinFunction() const
Definition pad.h:148
bool IsOnCopperLayer() const override
Definition pad.cpp:1573
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition pad.h:147
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:79
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:51
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 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 ddAppendBoard
Drag and drop.
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 zoneDisplayTriangulated
static TOOL_ACTION placeDesignBlock
static TOOL_ACTION selectUnconnected
Select unconnected footprints from ratsnest of selection.
Definition pcb_actions.h:88
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:97
static TOOL_ACTION microwaveCreateStub
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
Definition pcb_actions.h:82
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 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 deselectNet
Remove all connections belonging to a single net from the active selection.
Definition pcb_actions.h:85
static TOOL_ACTION drawLine
static TOOL_ACTION placeLinkedDesignBlock
static TOOL_ACTION localRatsnestTool
static TOOL_ACTION drawAlignedDimension
static TOOL_ACTION drawZone
static TOOL_ACTION selectOnSchematic
Select symbols/pins on schematic corresponding to selected footprints/pads.
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.
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
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.
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true, std::optional< VECTOR2I > aPosition=std::nullopt)
Place aFootprint at the current cursor position (or provided one) and updates footprint coordinates w...
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:47
Handle design block actions in the PCB editor.
Abstract dimension API.
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.
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
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:99
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
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:72
wxTimer m_crossProbeFlashTimer
Timer to toggle selection visibility for flash.
void StartCrossProbeFlash(const std::vector< BOARD_ITEM * > &aItems)
void OnCrossProbeFlashTimer(wxTimerEvent &aEvent)
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.
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
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 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 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:42
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 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()
void ExchangeFootprint(FOOTPRINT *aExisting, FOOTPRINT *aNew, BOARD_COMMIT &aCommit, bool matchPadPositions, bool deleteExtraTexts=true, bool resetTextLayers=true, bool resetTextEffects=true, bool resetTextPositions=true, bool resetTextContent=true, bool resetFabricationAttrs=true, bool resetClearanceOverrides=true, bool reset3DModels=true, bool *aUpdated=nullptr)
Replace aExisting footprint by aNew footprint using the Existing footprint settings (position,...
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()
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:53
PCB net inspection panel.
Generic tool for picking an item.
Tool that displays edit points allowing to modify items by dragging the points.
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
Definition pcb_point.h:43
PCB_LAYER_ID m_Route_Layer_TOP
Definition pcb_screen.h:43
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition pcb_screen.h:44
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.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pcb_text.cpp:519
Tool useful for viewing footprints.
virtual const wxString & GetExecutablePath() const
Definition pgm_base.cpp:867
The interactive edit tool.
void Show(std::ostream &aStream=std::cerr)
Definition profile.h:277
void Reset()
Definition profile.h:267
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:187
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition project.h:210
void IncrementNetclassesTicker()
Definition project.h:118
virtual PROJECT_FILE & GetProjectFile() const
Definition project.h:204
void IncrementTextVarsTicker()
Definition project.h:115
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:177
int Size() const
Returns the number of selected parts.
Definition selection.h:121
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition richio.h:226
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:66
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:80
Generic, UI-independent tool event.
Definition tool_event.h:171
void SetHasPosition(bool aHasPosition)
Definition tool_event.h:261
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).
wxString wx_str() const
Definition utf8.cpp:45
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()
Handle a list of polygons defining a copper zone.
Definition zone.h:74
A type-safe container of any type.
Definition ki_any.h:93
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:131
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:202
int GetLastUnsavedChangesResponse()
Return the result code from the last call to HandleUnsavedChanges(): wxID_YES, wxID_NO or wxID_CANCEL...
Definition confirm.cpp:144
This file is part of the common library.
#define CHECK(x)
#define ENABLE(x)
#define DIALOG_DRC_WINDOW_NAME
Definition dialog_drc.h:41
#define DIALOG_DRC_RULE_EDITOR_WINDOW_NAME
#define _(s)
Declaration of the eda_3d_viewer class.
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:411
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:413
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define PCB_EDIT_FRAME_NAME
@ NO_RECURSE
Definition eda_item.h:54
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)
bool ComputeFootprintShift(const FOOTPRINT &aExisting, const FOOTPRINT &aNew, VECTOR2I &aShift, EDA_ANGLE &aAngleShift)
Compute position and angle shift between two footprints.
Collection of reusable/testable functions for footprint manipulation.
@ FRAME_PCB_EDITOR
Definition frame_type.h:42
@ FRAME_FOOTPRINT_VIEWER
Definition frame_type.h:45
@ FRAME_SCH
Definition frame_type.h:34
@ FRAME_FOOTPRINT_CHOOSER
Definition frame_type.h:44
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:43
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:27
@ ID_ON_GRID_SELECT
Definition id.h:116
@ ID_FILE_LIST_CLEAR
Definition id.h:62
@ ID_EDA_SOCKET_EVENT
Definition id.h:136
@ ID_EDA_SOCKET_EVENT_SERV
Definition id.h:135
@ ID_ON_ZOOM_SELECT
Definition id.h:115
@ ID_FILEMAX
Definition id.h:60
@ ID_FILE1
Definition id.h:59
PROJECT & Prj()
Definition kicad.cpp:644
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
Definition layer_ids.h:856
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:679
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition layer_ids.h:228
@ LAYER_GRID
Definition layer_ids.h:254
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored).
Definition layer_ids.h:295
@ LAYER_RATSNEST
Definition layer_ids.h:253
#define CLEARANCE_LAYER_FOR(boardLayer)
Definition layer_ids.h:373
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ F_Paste
Definition layer_ids.h:104
@ B_Mask
Definition layer_ids.h:98
@ B_Cu
Definition layer_ids.h:65
@ F_Mask
Definition layer_ids.h:97
@ B_Paste
Definition layer_ids.h:105
@ UNDEFINED_LAYER
Definition layer_ids.h:61
@ F_Cu
Definition layer_ids.h:64
@ MAIL_SCH_GET_NETLIST
Definition mail_type.h:49
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:58
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:55
@ ALL
All except INITIAL_ADD.
Definition view_item.h:59
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition definitions.h:38
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:44
BARCODE class definition.
static std::vector< std::pair< T *, T * > > matchItemsBySimilarity(const std::vector< T * > &aExisting, const std::vector< T * > &aNew)
static void processTextItem(const PCB_TEXT &aSrc, PCB_TEXT &aDest, const VECTOR2I &aPosShift, const EDA_ANGLE &aAngleShift, bool aResetText, bool aResetTextLayers, bool aResetTextEffects, bool aResetTextPositions, bool *aUpdated)
copy text settings from aSrc to aDest
#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:42
#define SKIP_UNDO
Definition sch_commit.h:40
#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:37
bool Intersects(const BOX2I_MINMAX &aOther) const
Definition box2_minmax.h:73
A filename or source description, a problem input line, a line number, a byte offset,...
TRACK_CLEARANCE_MODE m_TrackClearance
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition tool_action.h:49
@ AS_ACTIVE
All active tools.
Definition tool_action.h:48
@ TA_MODEL_CHANGE
Model has changed (partial update).
Definition tool_event.h:121
@ TC_COMMAND
Definition tool_event.h:57
#define TEXTVARS_CHANGED
wxLogTrace helper definitions.
VECTOR2I GetRotated(const VECTOR2I &aVector, const EDA_ANGLE &aAngle)
Return a new VECTOR2I that is the result of rotating aVector by aAngle.
Definition trigo.h:77
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:85
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:103
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:100
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:88
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:94
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:101
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:108
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:90
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:105
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:89
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:86
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:87
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition typeinfo.h:96
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:98
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:104
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:83
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:99
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:84
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:95
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:91
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
Definition typeinfo.h:110
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:93
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:102
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687
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.