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 (C) 2013-2023 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 <advanced_config.h>
24#include <kiface_base.h>
25#include <kiway.h>
26#include <pgm_base.h>
27#include <pcb_edit_frame.h>
30#include <fp_lib_table.h>
31#include <bitmaps.h>
32#include <confirm.h>
33#include <trace_helpers.h>
34#include <pcbnew_id.h>
35#include <pcbnew_settings.h>
38#include <dialog_plot.h>
39#include <dialog_find.h>
42#include <dialog_board_setup.h>
43#include <invoke_pcb_dialog.h>
45#include <board.h>
47#include <footprint.h>
51#include <pcb_draw_panel_gal.h>
52#include <functional>
53#include <pcb_painter.h>
56#include <python_scripting.h>
59#include <tool/tool_manager.h>
61#include <tool/action_toolbar.h>
62#include <tool/common_control.h>
63#include <tool/common_tools.h>
65#include <tool/selection.h>
66#include <tool/zoom_tool.h>
70#include <tools/edit_tool.h>
72#include <tools/group_tool.h>
74#include <tools/drc_tool.h>
76#include <tools/convert_tool.h>
77#include <tools/drawing_tool.h>
78#include <tools/pcb_control.h>
85#include <tools/pad_tool.h>
89#include <tools/pcb_actions.h>
90#include <router/router_tool.h>
93#include <gestfich.h>
94#include <executable_names.h>
96#include <wx/socket.h>
97#include <wx/wupdlock.h>
98#include <dialog_drc.h> // for DIALOG_DRC_WINDOW_NAME definition
102#include <widgets/wx_infobar.h>
106#include <widgets/wx_aui_utils.h>
107#include <kiplatform/app.h>
108#include <core/profile.h>
112
113#ifdef KICAD_IPC_API
114#include <api/api_server.h>
115#include <api/api_handler_pcb.h>
116#endif
117
118#include <action_plugin.h>
120#include "../scripting/python_scripting.h"
121
122#include <wx/filedlg.h>
123
124using namespace std::placeholders;
125
126
127#define INSPECT_DRC_ERROR_DIALOG_NAME wxT( "InspectDrcErrorDialog" )
128#define INSPECT_CLEARANCE_DIALOG_NAME wxT( "InspectClearanceDialog" )
129#define INSPECT_CONSTRAINTS_DIALOG_NAME wxT( "InspectConstraintsDialog" )
130#define FOOTPRINT_DIFF_DIALOG_NAME wxT( "FootprintDiffDialog" )
131
132
133BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
136
137
140
141 EVT_SIZE( PCB_EDIT_FRAME::OnSize )
142
144
145 // Menu Files:
147
151
157
160
161 EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
162 EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
163
164 // menu Postprocess
166
167 // Horizontal toolbar
173
174 // Tracks and vias sizes general options
176 PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
177
178 // User interface update event handlers.
184 PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
186 PCB_EDIT_FRAME::OnUpdateSelectViaSize )
187 // Drop files event
188 EVT_DROP_FILES( PCB_EDIT_FRAME::OnDropFiles )
189END_EVENT_TABLE()
190
191
192PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
193 PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_EDITOR, _( "PCB Editor" ),
194 wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
196 m_exportNetlistAction( nullptr ),
197 m_findDialog( nullptr ),
198 m_inspectDrcErrorDlg( nullptr ),
199 m_inspectClearanceDlg( nullptr ),
200 m_inspectConstraintsDlg( nullptr ),
201 m_footprintDiffDlg( nullptr ),
202 m_importProperties( nullptr )
203{
204 m_maximizeByDefault = true;
205 m_showBorderAndTitleBlock = true; // true to display sheet references
206 m_SelTrackWidthBox = nullptr;
207 m_SelViaSizeBox = nullptr;
208 m_SelLayerBox = nullptr;
209 m_show_layer_manager_tools = true;
210 m_supportsAutoSave = true;
211 m_probingSchToPcb = false;
212 m_show_search = false;
213 m_show_net_inspector = false;
214
215 // We don't know what state board was in when it was last saved, so we have to
216 // assume dirty
217 m_ZoneFillsDirty = true;
218
219 m_aboutTitle = _HKI( "KiCad PCB Editor" );
220
221 // Must be created before the menus are created.
222 if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist )
223 {
224 m_exportNetlistAction = new TOOL_ACTION( "pcbnew.EditorControl.exportNetlist",
225 AS_GLOBAL, 0, "", _( "Netlist..." ),
226 _( "Export netlist used to update schematics" ) );
227 }
228
229 // Create GAL canvas
230 auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
231 GetGalDisplayOptions(),
233
234 SetCanvas( canvas );
235 SetBoard( new BOARD() );
236
237 wxIcon icon;
238 wxIconBundle icon_bundle;
239
240 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 48 ) );
241 icon_bundle.AddIcon( icon );
242 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 128 ) );
243 icon_bundle.AddIcon( icon );
244 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 256 ) );
245 icon_bundle.AddIcon( icon );
246 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_32 ) );
247 icon_bundle.AddIcon( icon );
248 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_16 ) );
249 icon_bundle.AddIcon( icon );
250
251 SetIcons( icon_bundle );
252
253 // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
254 // initialize parameters in m_LayersManager
255 LoadSettings( config() );
256
257 SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ) ) );
258
259 // PCB drawings start in the upper left corner.
260 GetScreen()->m_Center = false;
261
262 setupTools();
263 setupUIConditions();
264
265 ReCreateMenuBar();
266 ReCreateHToolbar();
267 ReCreateAuxiliaryToolbar();
268 ReCreateVToolbar();
269 ReCreateOptToolbar();
270
271#ifdef KICAD_IPC_API
273 &PCB_EDIT_FRAME::onPluginAvailabilityChanged, this );
274#endif
275
276 m_propertiesPanel = new PCB_PROPERTIES_PANEL( this, this );
277
278 float proportion = GetPcbNewSettings()->m_AuiPanels.properties_splitter;
279 m_propertiesPanel->SetSplitterProportion( proportion );
280
281 m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
282
283 m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
284 m_searchPane = new PCB_SEARCH_PANE( this );
285 m_netInspectorPanel = new PCB_NET_INSPECTOR_PANEL( this, this );
286
287 m_auimgr.SetManagedWindow( this );
288
289 CreateInfoBar();
290
291 unsigned int auiFlags = wxAUI_MGR_DEFAULT;
292#if !defined( _WIN32 )
293 // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
294 // of graphical glitches.
295 auiFlags |= wxAUI_MGR_LIVE_RESIZE;
296#endif
297 m_auimgr.SetFlags( auiFlags );
298
299 // Rows; layers 4 - 6
300 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( wxS( "MainToolbar" ) )
301 .Top().Layer( 6 ) );
302 m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( wxS( "AuxToolbar" ) )
303 .Top().Layer( 5 ) );
304 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
305 .Bottom().Layer( 6 ) );
306
307 // Columns; layers 1 - 3
308 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( wxS( "OptToolbar" ) )
309 .Left().Layer( 3 ) );
310
311 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( wxS( "ToolsToolbar" ) )
312 .Right().Layer( 3 ) );
313
314 m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( wxS( "LayersManager" ) )
315 .Right().Layer( 4 )
316 .Caption( _( "Appearance" ) ).PaneBorder( false )
317 .MinSize( FromDIP( 180 ), -1 ).BestSize( FromDIP( 180 ), -1 ) );
318
319 m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Name( wxS( "SelectionFilter" ) )
320 .Right().Layer( 4 ).Position( 2 )
321 .Caption( _( "Selection Filter" ) ).PaneBorder( false )
322 .MinSize( FromDIP( 180 ), -1 ).BestSize( FromDIP( 180 ), -1 ) );
323
324 m_auimgr.AddPane( m_propertiesPanel, EDA_PANE().Name( PropertiesPaneName() )
325 .Left().Layer( 5 )
326 .Caption( _( "Properties" ) ).PaneBorder( false )
327 .MinSize( FromDIP( wxSize( 240, 60 ) ) ).BestSize( FromDIP( wxSize( 300, 200 ) ) ) );
328
329 // Center
330 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
331 .Center() );
332
333 m_auimgr.AddPane( m_netInspectorPanel, EDA_PANE()
334 .Name( NetInspectorPanelName() )
335 .Bottom()
336 .Caption( _( "Net Inspector" ) )
337 .PaneBorder( false )
338 .MinSize( FromDIP( wxSize( 240, 60 ) ) )
339 .BestSize( FromDIP( wxSize( 300, 200 ) ) ) );
340
341 m_auimgr.AddPane( m_searchPane, EDA_PANE().Name( SearchPaneName() )
342 .Bottom()
343 .Caption( _( "Search" ) ).PaneBorder( false )
344 .MinSize( FromDIP( wxSize ( 180, 60 ) ) ).BestSize( FromDIP( wxSize ( 180, 100 ) ) )
345 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
346 .DestroyOnClose( false ) );
347
348
349 m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
350 m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
351 m_auimgr.GetPane( PropertiesPaneName() ).Show( GetPcbNewSettings()->m_AuiPanels.show_properties );
352 m_auimgr.GetPane( NetInspectorPanelName() ).Show( m_show_net_inspector );
353 m_auimgr.GetPane( SearchPaneName() ).Show( m_show_search );
354
355 // The selection filter doesn't need to grow in the vertical direction when docked
356 m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
357
358 FinishAUIInitialization();
359
360 if( PCBNEW_SETTINGS* settings = dynamic_cast<PCBNEW_SETTINGS*>( config() ) )
361 {
362 if( settings->m_AuiPanels.right_panel_width > 0 )
363 {
364 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( wxS( "LayersManager" ) );
365 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
366 }
367
368 if( settings->m_AuiPanels.properties_panel_width > 0 && m_propertiesPanel )
369 {
370 wxAuiPaneInfo& propertiesPanel = m_auimgr.GetPane( PropertiesPaneName() );
371 SetAuiPaneSize( m_auimgr, propertiesPanel,
372 settings->m_AuiPanels.properties_panel_width, -1 );
373 }
374
375 if( settings->m_AuiPanels.search_panel_height > 0
376 && ( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
377 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
378 {
379 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
380 searchPane.Direction( settings->m_AuiPanels.search_panel_dock_direction );
381 SetAuiPaneSize( m_auimgr, searchPane, -1, settings->m_AuiPanels.search_panel_height );
382 }
383 else if( settings->m_AuiPanels.search_panel_width > 0
384 && ( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
385 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
386 {
387 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
388 searchPane.Direction( settings->m_AuiPanels.search_panel_dock_direction );
389 SetAuiPaneSize( m_auimgr, searchPane, settings->m_AuiPanels.search_panel_width, -1 );
390 }
391
392 m_appearancePanel->SetTabIndex( settings->m_AuiPanels.appearance_panel_tab );
393 }
394
395 GetToolManager()->PostAction( ACTIONS::zoomFitScreen );
396
397 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
398 // to calculate the wrong zoom size. See PCB_EDIT_FRAME::onSize().
399 Bind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
400
401 // Redraw netnames (so that they fall within the current viewport) after the viewport
402 // has stopped changing. Redrawing them without the timer moves them smoothly with scrolling,
403 // making it look like the tracks are being dragged -- which we don't want.
404 m_redrawNetnamesTimer.SetOwner( this );
405 Connect( wxEVT_TIMER, wxTimerEventHandler( PCB_EDIT_FRAME::redrawNetnames ), nullptr, this );
406
407 Bind( wxEVT_IDLE,
408 [this]( wxIdleEvent& aEvent )
409 {
410 if( GetCanvas()->GetView()->GetViewport() != m_lastViewport )
411 {
412 m_lastViewport = GetCanvas()->GetView()->GetViewport();
413 m_redrawNetnamesTimer.StartOnce( 500 );
414 }
415
416 // Do not forget to pass the Idle event to other clients:
417 aEvent.Skip();
418 } );
419
420 resolveCanvasType();
421
422 setupUnits( config() );
423
424 // Ensure the DRC engine is initialized so that constraints can be resolved even before a
425 // board is loaded or saved
426 try
427 {
428 m_toolManager->GetTool<DRC_TOOL>()->GetDRCEngine()->InitEngine( wxFileName() );
429 }
430 catch( PARSE_ERROR& )
431 {
432 }
433
434 // Ensure the Python interpreter is up to date with its environment variables
435 PythonSyncEnvironmentVariables();
436 PythonSyncProjectName();
437
438 // Sync action plugins in case they changed since the last time the frame opened
439 GetToolManager()->RunAction( ACTIONS::pluginsReload );
440
441#ifdef KICAD_IPC_API
442 m_apiHandler = std::make_unique<API_HANDLER_PCB>( this );
443 Pgm().GetApiServer().RegisterHandler( m_apiHandler.get() );
444#endif
445
446 GetCanvas()->SwitchBackend( m_canvasType );
447 ActivateGalCanvas();
448
449 // Default shutdown reason until a file is loaded
450 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New PCB file is unsaved" ) );
451
452 // disable Export STEP item if kicad2step does not exist
453 wxString strK2S = Pgm().GetExecutablePath();
454
455#ifdef __WXMAC__
456 if( strK2S.Find( wxT( "pcbnew.app" ) ) != wxNOT_FOUND )
457 {
458 // On macOS, we have standalone applications inside the main bundle, so we handle that here:
459 strK2S += wxT( "../../" );
460 }
461
462 strK2S += wxT( "Contents/MacOS/" );
463#endif
464
465 wxFileName appK2S( strK2S, wxT( "kicad2step" ) );
466
467#ifdef _WIN32
468 appK2S.SetExt( wxT( "exe" ) );
469#endif
470
471 // Ensure the window is on top
472 Raise();
473
474// if( !appK2S.FileExists() )
475 // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
476
477 // AUI doesn't refresh properly on wxMac after changes in eb7dc6dd, so force it to
478#ifdef __WXMAC__
479 if( Kiface().IsSingle() )
480 {
481 CallAfter( [this]()
482 {
483 m_appearancePanel->OnBoardChanged();
484 } );
485 }
486#endif
487
488 // Register a call to update the toolbar sizes. It can't be done immediately because
489 // it seems to require some sizes calculated that aren't yet (at least on GTK).
490 CallAfter( [this]()
491 {
492 // Ensure the controls on the toolbars all are correctly sized
493 UpdateToolbarControlSizes();
494 } );
495
497 {
498 m_eventCounterTimer = new wxTimer( this );
499
500 Bind( wxEVT_TIMER,
501 [&]( wxTimerEvent& aEvent )
502 {
503 GetCanvas()->m_PaintEventCounter->Show();
504 GetCanvas()->m_PaintEventCounter->Reset();
505
507 static_cast<KIGFX::WX_VIEW_CONTROLS*>( GetCanvas()->GetViewControls() );
508 vc->m_MotionEventCounter->Show();
509 vc->m_MotionEventCounter->Reset();
510
511 },
512 m_eventCounterTimer->GetId() );
513
514 m_eventCounterTimer->Start( 1000 );
515 }
516
517 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &PCB_EDIT_FRAME::onCloseModelessBookReporterDialogs,
518 this );
521 DragAcceptFiles( true );
522}
523
524
526{
528
529 if( ADVANCED_CFG::GetCfg().m_ShowEventCounters )
530 {
531 // Stop the timer during destruction early to avoid potential event race conditions (that
532 // do happen on windows)
533 m_eventCounterTimer->Stop();
534 delete m_eventCounterTimer;
535 }
536
537#ifdef KICAD_IPC_API
538 Pgm().GetApiServer().DeregisterHandler( m_apiHandler.get() );
539 wxTheApp->Unbind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED,
540 &PCB_EDIT_FRAME::onPluginAvailabilityChanged, this );
541#endif
542
543 // Close modeless dialogs
544 wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
545
546 if( open_dlg )
547 open_dlg->Close( true );
548
549 // Shutdown all running tools
550 if( m_toolManager )
552
553 if( GetBoard() )
555
557 delete m_appearancePanel;
559 delete m_propertiesPanel;
560 delete m_netInspectorPanel;
561}
562
563
564void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard, bool aBuildConnectivity,
565 PROGRESS_REPORTER* aReporter )
566{
567 if( m_pcb )
569
570 PCB_BASE_EDIT_FRAME::SetBoard( aBoard, aReporter );
571
572 aBoard->SetProject( &Prj() );
573
574 if( aBuildConnectivity )
575 aBoard->BuildConnectivity();
576
577 // reload the drawing-sheet
578 SetPageSettings( aBoard->GetPageSettings() );
579}
580
581
583{
584 return m_pcb;
585}
586
587
588void PCB_EDIT_FRAME::redrawNetnames( wxTimerEvent& aEvent )
589{
590 bool needs_refresh = false;
591
592 // Don't stomp on the auto-save timer event.
593 if( aEvent.GetId() == ID_AUTO_SAVE_TIMER )
594 {
595 aEvent.Skip();
596 return;
597 }
598
599 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
600
601 if( !cfg || cfg->m_Display.m_NetNames < 2 )
602 return;
603
604 KIGFX::VIEW* view = GetCanvas()->GetView();
605 double scale = view->GetScale();
606
607 for( PCB_TRACK* track : GetBoard()->Tracks() )
608 {
609 double lod = track->ViewGetLOD( GetNetnameLayer( track->GetLayer() ), view );
610
611 if( lod < scale )
612 continue;
613
614 if( lod != track->GetCachedLOD() || scale != track->GetCachedScale() )
615 {
616 view->Update( track, KIGFX::REPAINT );
617 needs_refresh = true;
618 track->SetCachedLOD( lod );
619 track->SetCachedScale( scale );
620 }
621 }
622
623 if( needs_refresh )
624 GetCanvas()->Refresh();
625}
626
627
628void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
629{
630 PCB_BASE_FRAME::SetPageSettings( aPageSettings );
631
632 // Prepare drawing-sheet template
635 m_pcb->GetProject(),
637 &m_pcb->GetProperties() );
638
639 drawingSheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
640 drawingSheet->SetSheetPath( std::string( GetFullScreenDesc().mb_str() ) );
641
642 // A board is not like a schematic having a main page and sub sheets.
643 // So for the drawing sheet, use only the first page option to display items
644 drawingSheet->SetIsFirstPage( true );
645
646 BASE_SCREEN* screen = GetScreen();
647
648 if( screen != nullptr )
649 {
650 drawingSheet->SetPageNumber(TO_UTF8( screen->GetPageNumber() ) );
651 drawingSheet->SetSheetCount( screen->GetPageCount() );
652 }
653
654 if( BOARD* board = GetBoard() )
655 drawingSheet->SetFileName( TO_UTF8( board->GetFileName() ) );
656
657 // PCB_DRAW_PANEL_GAL takes ownership of the drawing-sheet
658 GetCanvas()->SetDrawingSheet( drawingSheet );
659}
660
661
663{
664 return GetScreen() && GetScreen()->IsContentModified();
665}
666
667
669{
670 return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
671}
672
673
675{
676 // Create the manager and dispatcher & route draw panel events to the dispatcher
679 GetCanvas()->GetViewControls(), config(), this );
680 m_actions = new PCB_ACTIONS();
682
683 // Register tools
713
714 for( TOOL_BASE* tool : m_toolManager->Tools() )
715 {
716 if( PCB_TOOL_BASE* pcbTool = dynamic_cast<PCB_TOOL_BASE*>( tool ) )
717 pcbTool->SetIsBoardEditor( true );
718 }
719
720 // Run the selection tool, it is supposed to be always active
721 m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
722}
723
724
726{
728
730 PCB_EDITOR_CONDITIONS cond( this );
731
732 auto undoCond =
733 [ this ] (const SELECTION& aSel )
734 {
736
737 if( drawingTool && drawingTool->GetDrawingMode() != DRAWING_TOOL::MODE::NONE )
738 return true;
739
741
742 if( routerTool && routerTool->RoutingInProgress() )
743 return true;
744
745 return GetUndoCommandCount() > 0;
746 };
747
748 wxASSERT( mgr );
749
750#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
751#define CHECK( x ) ACTION_CONDITIONS().Check( x )
752
754 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
756
761 mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
762 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
763 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
764
765 mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
766 mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
775
778 { PCB_GROUP_T, PCB_GENERATOR_T } ) ) );
781
787
788 if( SCRIPTING::IsWxAvailable() )
790
791 auto enableZoneControlCondition =
792 [this] ( const SELECTION& )
793 {
796 };
797
799 ENABLE( enableZoneControlCondition )
800 .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FILLED ) ) );
802 ENABLE( enableZoneControlCondition )
803 .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE ) ) );
805 ENABLE( enableZoneControlCondition )
806 .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS ) ) );
808 ENABLE( enableZoneControlCondition )
809 .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) ) );
810
812
813 auto constrainedDrawingModeCond =
814 [this]( const SELECTION& )
815 {
817 };
818
819 auto boardFlippedCond =
820 [this]( const SELECTION& )
821 {
822 return GetCanvas() && GetCanvas()->GetView()->IsMirroredX();
823 };
824
825 auto layerManagerCond =
826 [this] ( const SELECTION& )
827 {
828 return LayerManagerShown();
829 };
830
831 auto propertiesCond =
832 [this] ( const SELECTION& )
833 {
834 return PropertiesShown();
835 };
836
837 auto netInspectorCond =
838 [this] ( const SELECTION& )
839 {
840 return NetInspectorShown();
841 };
842
843 auto searchPaneCond =
844 [this] ( const SELECTION& )
845 {
846 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
847 };
848
849 auto highContrastCond =
850 [this] ( const SELECTION& )
851 {
852 return GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
853 };
854
855 auto globalRatsnestCond =
856 [this] (const SELECTION& )
857 {
859 };
860
861 auto curvedRatsnestCond =
862 [this] (const SELECTION& )
863 {
865 };
866
867 auto netHighlightCond =
868 [this]( const SELECTION& )
869 {
871 return !settings->GetHighlightNetCodes().empty();
872 };
873
874 auto enableNetHighlightCond =
875 [this]( const SELECTION& )
876 {
878 return tool && tool->IsNetHighlightSet();
879 };
880
881 mgr->SetConditions( PCB_ACTIONS::toggleHV45Mode, CHECK( constrainedDrawingModeCond ) );
882 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
883 mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
884 mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
885 mgr->SetConditions( PCB_ACTIONS::showRatsnest, CHECK( globalRatsnestCond ) );
886 mgr->SetConditions( PCB_ACTIONS::ratsnestLineMode, CHECK( curvedRatsnestCond ) );
887 mgr->SetConditions( PCB_ACTIONS::toggleNetHighlight, CHECK( netHighlightCond )
888 .Enable( enableNetHighlightCond ) );
889 mgr->SetConditions( PCB_ACTIONS::showProperties, CHECK( propertiesCond ) );
890 mgr->SetConditions( PCB_ACTIONS::showNetInspector, CHECK( netInspectorCond ) );
891 mgr->SetConditions( PCB_ACTIONS::showSearch, CHECK( searchPaneCond ) );
892
893 auto isArcKeepCenterMode =
894 [this]( const SELECTION& )
895 {
896 return GetPcbNewSettings()->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS;
897 };
898
899 auto isArcKeepEndpointMode =
900 [this]( const SELECTION& )
901 {
902 return GetPcbNewSettings()->m_ArcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION;
903 };
904
905 mgr->SetConditions( PCB_ACTIONS::pointEditorArcKeepCenter, CHECK( isArcKeepCenterMode ) );
906 mgr->SetConditions( PCB_ACTIONS::pointEditorArcKeepEndpoint, CHECK( isArcKeepEndpointMode ) );
907
908 auto isHighlightMode =
909 [this]( const SELECTION& )
910 {
912 return tool && tool->GetRouterMode() == PNS::RM_MarkObstacles;
913 };
914
915 auto isShoveMode =
916 [this]( const SELECTION& )
917 {
919 return tool && tool->GetRouterMode() == PNS::RM_Shove;
920 };
921
922 auto isWalkaroundMode =
923 [this]( const SELECTION& )
924 {
926 return tool && tool->GetRouterMode() == PNS::RM_Walkaround;
927 };
928
929 mgr->SetConditions( PCB_ACTIONS::routerHighlightMode, CHECK( isHighlightMode ) );
930 mgr->SetConditions( PCB_ACTIONS::routerShoveMode, CHECK( isShoveMode ) );
931 mgr->SetConditions( PCB_ACTIONS::routerWalkaroundMode, CHECK( isWalkaroundMode ) );
932
933 auto haveNetCond =
934 [] ( const SELECTION& aSel )
935 {
936 for( EDA_ITEM* item : aSel )
937 {
938 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
939 {
940 if( bci->GetNetCode() > 0 )
941 return true;
942 }
943 }
944
945 return false;
946 };
947
952
963
964
967
970
971 mgr->SetConditions( PCB_ACTIONS::zoneDuplicate, ENABLE( singleZoneCond ) );
972 mgr->SetConditions( PCB_ACTIONS::drawZoneCutout, ENABLE( singleZoneCond ) );
973 mgr->SetConditions( PCB_ACTIONS::drawSimilarZone, ENABLE( singleZoneCond ) );
974 mgr->SetConditions( PCB_ACTIONS::zoneMerge, ENABLE( zoneMergeCond ) );
975
977
978#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
979
980 // These tools can be used at any time to inspect the board
985
986
987 auto isDRCIdle =
988 [this] ( const SELECTION& )
989 {
991 return !( tool && tool->IsDRCRunning() );
992 };
993
994#define CURRENT_EDIT_TOOL( action ) \
995 mgr->SetConditions( action, ACTION_CONDITIONS().Check( cond.CurrentTool( action ) ) \
996 .Enable( isDRCIdle ) )
997
998 // These tools edit the board, so they must be disabled during some operations
1025
1031
1032#undef CURRENT_TOOL
1033#undef CURRENT_EDIT_TOOL
1034#undef ENABLE
1035#undef CHECK
1036}
1037
1038
1039void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
1040{
1041 if( event.GetId() == wxID_EXIT )
1042 Kiway().OnKiCadExit();
1043
1044 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1045 Close( false );
1046}
1047
1048
1049void PCB_EDIT_FRAME::ResolveDRCExclusions( bool aCreateMarkers )
1050{
1051 BOARD_COMMIT commit( this );
1052
1053 for( PCB_MARKER* marker : GetBoard()->ResolveDRCExclusions( aCreateMarkers ) )
1054 {
1055 if( marker->GetMarkerType() == MARKER_BASE::MARKER_DRAWING_SHEET )
1056 marker->GetRCItem()->SetItems( GetCanvas()->GetDrawingSheet() );
1057
1058 commit.Add( marker );
1059 }
1060
1061 commit.Push( wxEmptyString, SKIP_UNDO | SKIP_SET_DIRTY );
1062
1063 for( PCB_MARKER* marker : GetBoard()->Markers() )
1064 {
1065 if( marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
1066 GetCanvas()->GetView()->Update( marker );
1067 }
1068
1070}
1071
1072
1073bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
1074{
1075 // Shutdown blocks must be determined and vetoed as early as possible
1076 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
1077 && IsContentModified() )
1078 {
1079 return false;
1080 }
1081
1083
1084 if( zoneFillerTool->IsBusy() )
1085 {
1086 wxBell();
1087
1088 if( wxWindow* reporter = dynamic_cast<wxWindow*>( zoneFillerTool->GetProgressReporter() ) )
1089 reporter->ShowWithEffect( wxSHOW_EFFECT_EXPAND );
1090
1091 return false;
1092 }
1093
1094 if( Kiface().IsSingle() )
1095 {
1096 auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
1097
1098 if( fpEditor && !fpEditor->Close() ) // Can close footprint editor?
1099 return false;
1100
1101 auto* fpViewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER, false );
1102
1103 if( fpViewer && !fpViewer->Close() ) // Can close footprint viewer?
1104 return false;
1105
1106 // FOOTPRINT_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
1107 // sorry.
1108 auto* chooser = (FOOTPRINT_CHOOSER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_CHOOSER, false );
1109
1110 if( chooser && !chooser->Close() ) // Can close footprint chooser?
1111 return false;
1112 }
1113 else
1114 {
1115 auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
1116
1117 if( fpEditor && fpEditor->IsCurrentFPFromBoard() )
1118 {
1119 if( !fpEditor->CanCloseFPFromBoard( true ) )
1120 return false;
1121 }
1122 }
1123
1124 if( IsContentModified() )
1125 {
1126 wxFileName fileName = GetBoard()->GetFileName();
1127 wxString msg = _( "Save changes to '%s' before closing?" );
1128
1129 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
1130 [&]() -> bool
1131 {
1132 return Files_io_from_id( ID_SAVE_BOARD );
1133 } ) )
1134 {
1135 return false;
1136 }
1137 }
1138
1139 return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
1140}
1141
1142
1144{
1145 // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
1146 // when closing this frame if a footprint was selected, and the footprint editor called
1147 // to edit this footprint, and when closing pcbnew if this footprint is still selected
1148 // See https://bugs.launchpad.net/kicad/+bug/1655858
1149 // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
1150 // avoid the crash (JPC)
1151 GetCanvas()->SetEvtHandlerEnabled( false );
1152
1154
1155 // Clean up mode-less dialogs.
1156 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &PCB_EDIT_FRAME::onCloseModelessBookReporterDialogs,
1157 this );
1158
1159 wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
1160
1161 if( open_dlg )
1162 open_dlg->Close( true );
1163
1164 if( m_findDialog )
1165 {
1166 m_findDialog->Destroy();
1167 m_findDialog = nullptr;
1168 }
1169
1171 {
1172 m_inspectDrcErrorDlg->Destroy();
1173 m_inspectDrcErrorDlg = nullptr;
1174 }
1175
1177 {
1178 m_inspectClearanceDlg->Destroy();
1179 m_inspectClearanceDlg = nullptr;
1180 }
1181
1183 {
1184 m_inspectConstraintsDlg->Destroy();
1185 m_inspectConstraintsDlg = nullptr;
1186 }
1187
1188 if( m_footprintDiffDlg )
1189 {
1190 m_footprintDiffDlg->Destroy();
1191 m_footprintDiffDlg = nullptr;
1192 }
1193
1194 // Delete the auto save file if it exists.
1195 wxFileName fn = GetBoard()->GetFileName();
1196
1197 // Auto save file name is the normal file name prefixed with 'FILEEXT::AutoSaveFilePrefix'.
1198 fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() );
1199
1200 // When the auto save feature does not have write access to the board file path, it falls
1201 // back to a platform specific user temporary file path.
1202 if( !fn.IsOk() || !fn.IsDirWritable() )
1203 fn.SetPath( wxFileName::GetTempDir() );
1204
1205 wxLogTrace( traceAutoSave, wxT( "Deleting auto save file <" ) + fn.GetFullPath() + wxT( ">" ) );
1206
1207 // Remove the auto save file on a normal close of Pcbnew.
1208 if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
1209 {
1210 wxLogTrace( traceAutoSave, wxT( "The auto save file could not be removed!" ) );
1211 }
1212
1213 // Make sure local settings are persisted
1215
1216 // Do not show the layer manager during closing to avoid flicker
1217 // on some platforms (Windows) that generate useless redraw of items in
1218 // the Layer Manager
1220 {
1221 m_auimgr.GetPane( wxS( "LayersManager" ) ).Show( false );
1222 m_auimgr.GetPane( wxS( "TabbedPanel" ) ).Show( false );
1223 }
1224
1225 // Unlink the old project if needed
1227
1228 // Delete board structs and undo/redo lists, to avoid crash on exit
1229 // when deleting some structs (mainly in undo/redo lists) too late
1230 Clear_Pcb( false, true );
1231
1232 // do not show the window because ScreenPcb will be deleted and we do not
1233 // want any paint event
1234 Show( false );
1235
1237}
1238
1239
1241{
1244 GetCanvas()->Refresh();
1245}
1246
1247
1248void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage )
1249{
1250 std::unique_lock<std::mutex> dialogLock( DIALOG_BOARD_SETUP::g_Mutex, std::try_to_lock );
1251
1252 // One DIALOG_BOARD_SETUP dialog at a time.
1253 if( !dialogLock.owns_lock() )
1254 return;
1255
1256 // Make sure everything's up-to-date
1258
1259 DIALOG_BOARD_SETUP dlg( this );
1260
1261 if( !aInitialPage.IsEmpty() )
1262 dlg.SetInitialPage( aInitialPage, wxEmptyString );
1263
1264 // QuasiModal required for Scintilla auto-complete
1265 if( dlg.ShowQuasiModal() == wxID_OK )
1266 {
1268 // We don't know if anything was modified, so err on the side of requiring a save
1269 OnModify();
1270
1271 Kiway().CommonSettingsChanged( false, true );
1272
1275
1276 PCBNEW_SETTINGS* settings = GetPcbNewSettings();
1277 static LSET maskAndPasteLayers = LSET( 4, F_Mask, F_Paste, B_Mask, B_Paste );
1278
1280 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1281 {
1282 BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aItem );
1283 int flags = 0;
1284
1285 if( !item )
1286 return flags;
1287
1288 if( item->Type() == PCB_VIA_T || item->Type() == PCB_PAD_T )
1289 {
1290 // Note: KIGFX::REPAINT isn't enough for things that go from invisible
1291 // to visible as they won't be found in the view layer's itemset for
1292 // re-painting.
1293 if( ( GetBoard()->GetVisibleLayers() & maskAndPasteLayers ).any() )
1294 flags |= KIGFX::ALL;
1295 }
1296
1297 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T || item->Type() == PCB_VIA_T )
1298 {
1300 flags |= KIGFX::REPAINT;
1301 }
1302
1303 if( item->Type() == PCB_PAD_T )
1304 {
1305 if( settings->m_Display.m_PadClearance )
1306 flags |= KIGFX::REPAINT;
1307 }
1308
1309 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
1310
1311 if( text && text->HasTextVars() )
1312 {
1313 text->ClearRenderCache();
1314 text->ClearBoundingBoxCache();
1316 }
1317
1318 return flags;
1319 } );
1320
1321 GetCanvas()->Refresh();
1322
1326
1327 //this event causes the routing tool to reload its design rules information
1329 toolEvent.SetHasPosition( false );
1330 m_toolManager->ProcessEvent( toolEvent );
1331 }
1332
1333 GetCanvas()->SetFocus();
1334}
1335
1336
1338{
1340
1341 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
1342 wxASSERT( cfg );
1343
1344 if( cfg )
1345 {
1349 }
1350}
1351
1352
1354{
1356
1357 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
1358 wxASSERT( cfg );
1359
1360 if( cfg )
1361 {
1363
1364 if( m_propertiesPanel )
1365 {
1366 cfg->m_AuiPanels.show_properties = m_propertiesPanel->IsShownOnScreen();
1369 }
1370
1371 // ensure m_show_search is up to date (the pane can be closed)
1372 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
1373 m_show_search = searchPaneInfo.IsShown();
1375 cfg->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
1376 cfg->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
1377 cfg->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
1378
1380 {
1381 wxAuiPaneInfo& netInspectorhPaneInfo = m_auimgr.GetPane( NetInspectorPanelName() );
1382 m_show_net_inspector = netInspectorhPaneInfo.IsShown();
1384 }
1385
1386 if( m_appearancePanel )
1387 {
1392 }
1393 }
1394}
1395
1396
1398{
1399 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( config() );
1400
1401 return cfg ? cfg->m_RotationAngle : ANGLE_90;
1402}
1403
1404
1406{
1408}
1409
1410
1412{
1413
1414 GetColorSettings()->SetColor( LAYER_GRID, aColor );
1415 GetCanvas()->GetGAL()->SetGridColor( aColor );
1416}
1417
1418
1420{
1421 PCB_LAYER_ID oldLayer = GetActiveLayer();
1422
1423 if( oldLayer == aLayer )
1424 return;
1425
1427
1429
1430 m_toolManager->PostAction( PCB_ACTIONS::layerChanged ); // notify other tools
1431 GetCanvas()->SetFocus(); // allow capture of hotkeys
1432 GetCanvas()->SetHighContrastLayer( aLayer );
1433
1435 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1436 {
1437 BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aItem );
1438
1439 if( !item )
1440 return 0;
1441
1442 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible
1443 // as they won't be found in the view layer's itemset for re-painting.
1444 if( GetDisplayOptions().m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN )
1445 {
1446 if( item->IsOnLayer( oldLayer ) || item->IsOnLayer( aLayer ) )
1447 return KIGFX::ALL;
1448 }
1449
1450 if( item->Type() == PCB_VIA_T )
1451 {
1452 PCB_VIA* via = static_cast<PCB_VIA*>( item );
1453
1454 // Vias on a restricted layer set must be redrawn when the active layer
1455 // is changed
1456 if( via->GetViaType() == VIATYPE::BLIND_BURIED
1457 || via->GetViaType() == VIATYPE::MICROVIA )
1458 {
1459 return KIGFX::REPAINT;
1460 }
1461
1462 if( via->GetRemoveUnconnected() )
1463 return KIGFX::ALL;
1464
1465 // Clearances could be layer-dependent so redraw them when the active layer
1466 // is changed
1468 return KIGFX::REPAINT;
1469 }
1470 else if( item->Type() == PCB_PAD_T )
1471 {
1472 PAD* pad = static_cast<PAD*>( item );
1473
1474 if( pad->GetRemoveUnconnected() )
1475 return KIGFX::ALL;
1476
1477 // Clearances could be layer-dependent so redraw them when the active layer
1478 // is changed
1480 {
1481 // Round-corner rects are expensive to draw, but are mostly found on
1482 // SMD pads which only need redrawing on an active-to-not-active
1483 // switch.
1484 if( pad->GetAttribute() == PAD_ATTRIB::SMD )
1485 {
1486 if( ( oldLayer == F_Cu || aLayer == F_Cu ) && pad->IsOnLayer( F_Cu ) )
1487 return KIGFX::REPAINT;
1488
1489 if( ( oldLayer == B_Cu || aLayer == B_Cu ) && pad->IsOnLayer( B_Cu ) )
1490 return KIGFX::REPAINT;
1491 }
1492 else if( pad->IsOnLayer( oldLayer ) || pad->IsOnLayer( aLayer ) )
1493 {
1494 return KIGFX::REPAINT;
1495 }
1496 }
1497 }
1498 else if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
1499 {
1500 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
1501
1502 // Clearances could be layer-dependent so redraw them when the active layer
1503 // is changed
1505 {
1506 // Tracks aren't particularly expensive to draw, but it's an easy check.
1507 if( track->IsOnLayer( oldLayer ) || track->IsOnLayer( aLayer ) )
1508 return KIGFX::REPAINT;
1509 }
1510 }
1511
1512 return 0;
1513 } );
1514
1515 GetCanvas()->Refresh();
1516}
1517
1518
1520{
1522
1523 layerEnum.Choices().Clear();
1524 layerEnum.Undefined( UNDEFINED_LAYER );
1525
1526 for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
1527 {
1528 // Canonical name
1529 layerEnum.Map( *seq, LSET::Name( *seq ) );
1530
1531 // User name
1532 layerEnum.Map( *seq, GetBoard()->GetLayerName( *seq ) );
1533 }
1534
1535 DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
1536
1537 try
1538 {
1539 drcTool->GetDRCEngine()->InitEngine( GetDesignRulesPath() );
1540 }
1541 catch( PARSE_ERROR& )
1542 {
1543 // Not sure this is the best place to tell the user their rules are buggy, so
1544 // we'll stay quiet for now. Feel free to revisit this decision....
1545 }
1546
1547 UpdateTitle();
1548
1549 wxFileName fn = GetBoard()->GetFileName();
1550
1551 // Display a warning that the file is read only
1552 if( fn.FileExists() && !fn.IsFileWritable() )
1553 {
1556 m_infoBar->ShowMessage( _( "Board file is read only." ),
1558 }
1559
1561
1562 // Sync layer and item visibility
1564
1565 SetElementVisibility( LAYER_RATSNEST, GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
1566
1568
1569 // Apply saved display state to the appearance panel after it has been set up
1570 PROJECT_LOCAL_SETTINGS& localSettings = Prj().GetLocalSettings();
1571
1573
1574 if( GetBoard()->GetDesignSettings().IsLayerEnabled( localSettings.m_ActiveLayer ) )
1575 SetActiveLayer( localSettings.m_ActiveLayer );
1576
1577 // Updates any auto dimensions and the auxiliary toolbar tracks/via sizes
1579
1580 // Sync the net inspector now we have connectivity calculated
1583
1584 // Display the loaded board:
1585 Zoom_Automatique( false );
1586
1587 // Invalidate painting as loading the DRC engine will cause clearances to become valid
1589
1590 Refresh();
1591
1592 SetMsgPanel( GetBoard() );
1593 SetStatusText( wxEmptyString );
1594
1595 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "PCB file changes are unsaved" ) );
1596}
1597
1598
1600{
1602}
1603
1604
1606{
1607 return GetBoard()->IsElementVisible( aElement );
1608}
1609
1610
1612{
1613 // Force the RATSNEST visible
1614 if( aElement == LAYER_RATSNEST )
1615 GetCanvas()->GetView()->SetLayerVisible( aElement, true );
1616 else
1617 GetCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
1618
1619 GetBoard()->SetElementVisibility( aElement, aNewState );
1620}
1621
1622
1624{
1625 // call my base class
1627
1628 m_auimgr.GetPane( m_appearancePanel ).Caption( _( "Appearance" ) );
1629 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
1630 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
1631 m_auimgr.GetPane( m_netInspectorPanel ).Caption( _( "Net Inspector" ) );
1632 m_auimgr.Update();
1633
1634 UpdateTitle();
1635}
1636
1637
1639{
1641
1642 if( project.m_PcbLastPath[ aType ].IsEmpty() )
1643 return wxEmptyString;
1644
1645 wxFileName absoluteFileName = project.m_PcbLastPath[ aType ];
1646 wxFileName pcbFileName = GetBoard()->GetFileName();
1647
1648 absoluteFileName.MakeAbsolute( pcbFileName.GetPath() );
1649 return absoluteFileName.GetFullPath();
1650}
1651
1652
1653void PCB_EDIT_FRAME::SetLastPath( LAST_PATH_TYPE aType, const wxString& aLastPath )
1654{
1656
1657 wxFileName relativeFileName = aLastPath;
1658 wxFileName pcbFileName = GetBoard()->GetFileName();
1659
1660 relativeFileName.MakeRelativeTo( pcbFileName.GetPath() );
1661
1662 if( relativeFileName.GetFullPath() != project.m_PcbLastPath[ aType ] )
1663 {
1664 project.m_PcbLastPath[ aType ] = relativeFileName.GetFullPath();
1665 OnModify();
1666 }
1667}
1668
1669
1671{
1673
1674 Update3DView( true, GetPcbNewSettings()->m_Display.m_Live3DRefresh );
1675
1676 if( !GetTitle().StartsWith( wxT( "*" ) ) )
1677 UpdateTitle();
1678
1679 m_ZoneFillsDirty = true;
1680}
1681
1682
1684{
1685 Update3DView( true, true );
1686}
1687
1688
1689void PCB_EDIT_FRAME::ExportSVG( wxCommandEvent& event )
1690{
1691 InvokeExportSVG( this, GetBoard() );
1692}
1693
1694
1696{
1697 wxFileName fn = GetBoard()->GetFileName();
1698 bool readOnly = false;
1699 bool unsaved = false;
1700
1701 if( fn.IsOk() && fn.FileExists() )
1702 readOnly = !fn.IsFileWritable();
1703 else
1704 unsaved = true;
1705
1706 wxString title;
1707
1708 if( IsContentModified() )
1709 title = wxT( "*" );
1710
1711 title += fn.GetName();
1712
1713 if( readOnly )
1714 title += wxS( " " ) + _( "[Read Only]" );
1715
1716 if( unsaved )
1717 title += wxS( " " ) + _( "[Unsaved]" );
1718
1719 title += wxT( " \u2014 " ) + _( "PCB Editor" );
1720
1721 SetTitle( title );
1722}
1723
1724
1726{
1727 // Update the layer manager and other widgets from the board setup
1728 // (layer and items visibility, colors ...)
1729
1730 // Rebuild list of nets (full ratsnest rebuild)
1732
1733 // Update info shown by the horizontal toolbars
1735
1736 LSET activeLayers = GetBoard()->GetEnabledLayers();
1737
1738 if( !activeLayers.test( GetActiveLayer() ) )
1739 SetActiveLayer( activeLayers.Seq().front() );
1740
1742
1744
1745 layerEnum.Choices().Clear();
1746 layerEnum.Undefined( UNDEFINED_LAYER );
1747
1748 for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
1749 {
1750 // Canonical name
1751 layerEnum.Map( *seq, LSET::Name( *seq ) );
1752
1753 // User name
1754 layerEnum.Map( *seq, GetBoard()->GetLayerName( *seq ) );
1755 }
1756
1757 // Sync visibility with canvas
1758 for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
1759 GetCanvas()->GetView()->SetLayerVisible( layer, GetBoard()->IsLayerVisible( layer ) );
1760
1761 // Stackup and/or color theme may have changed
1764}
1765
1766
1768{
1769 // switches currently used canvas (Cairo / OpenGL).
1770 PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
1771}
1772
1773
1775{
1776 if( !m_findDialog )
1777 {
1778 m_findDialog = new DIALOG_FIND( this );
1781 }
1782
1783 wxString findString;
1784
1785 PCB_SELECTION& selection = m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1786
1787 if( selection.Size() == 1 )
1788 {
1789 EDA_ITEM* front = selection.Front();
1790
1791 switch( front->Type() )
1792 {
1793 case PCB_FOOTPRINT_T:
1794 findString = UnescapeString( static_cast<FOOTPRINT*>( front )->GetValue() );
1795 break;
1796
1797 case PCB_FIELD_T:
1798 case PCB_TEXT_T:
1799 findString = UnescapeString( static_cast<PCB_TEXT*>( front )->GetText() );
1800
1801 if( findString.Contains( wxT( "\n" ) ) )
1802 findString = findString.Before( '\n' );
1803
1804 break;
1805
1806 default:
1807 break;
1808 }
1809 }
1810
1811 m_findDialog->Preload( findString );
1812
1813 m_findDialog->Show( true );
1814}
1815
1816
1817void PCB_EDIT_FRAME::FindNext( bool reverse )
1818{
1819 if( !m_findDialog )
1821
1822 m_findDialog->FindNext( reverse );
1823}
1824
1825
1827{
1828 PCB_PLOT_PARAMS plotSettings = GetPlotSettings();
1829
1830 switch( aID )
1831 {
1832 case ID_GEN_PLOT_GERBER:
1833 plotSettings.SetFormat( PLOT_FORMAT::GERBER );
1834 break;
1835 case ID_GEN_PLOT_DXF:
1836 plotSettings.SetFormat( PLOT_FORMAT::DXF );
1837 break;
1838 case ID_GEN_PLOT_HPGL:
1839 plotSettings.SetFormat( PLOT_FORMAT::HPGL );
1840 break;
1841 case ID_GEN_PLOT_PDF:
1842 plotSettings.SetFormat( PLOT_FORMAT::PDF );
1843 break;
1844 case ID_GEN_PLOT_PS:
1845 plotSettings.SetFormat( PLOT_FORMAT::POST );
1846 break;
1847 case ID_GEN_PLOT:
1848 /* keep the previous setup */
1849 break;
1850 default:
1851 wxFAIL_MSG( wxT( "ToPlotter(): unexpected plot type" ) ); break;
1852 break;
1853 }
1854
1855 SetPlotSettings( plotSettings );
1856
1857 DIALOG_PLOT dlg( this );
1858 dlg.ShowQuasiModal( );
1859}
1860
1861
1863{
1864 if( Kiface().IsSingle() )
1865 return 0;
1866
1867 // Update PCB requires a netlist. Therefore the schematic editor must be running
1868 // If this is not the case, open the schematic editor
1869 KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
1870
1871 // If Kiway() cannot create the eeschema frame, it shows a error message, and
1872 // frame is null
1873 if( !frame )
1874 return -1;
1875
1876 if( !frame->IsShownOnScreen() )
1877 {
1878 wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
1880
1881 // Maybe the file hasn't been converted to the new s-expression file format so
1882 // see if the legacy schematic file is still in play.
1883 if( !fn.FileExists() )
1884 {
1886
1887 if( !fn.FileExists() )
1888 {
1889 DisplayError( this, _( "The schematic for this board cannot be found." ) );
1890 return -2;
1891 }
1892 }
1893
1894 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1895
1896 // we show the schematic editor frame, because do not show is seen as
1897 // a not yet opened schematic by Kicad manager, which is not the case
1898 frame->Show( true );
1899
1900 // bring ourselves back to the front
1901 Raise();
1902 }
1903
1904 return 1; //Success!
1905}
1906
1907
1909 const wxString& aAnnotateMessage )
1910{
1911 int standalone = TestStandalone();
1912
1913 if( standalone == 0 )
1914 {
1915 DisplayErrorMessage( this, _( "Cannot update the PCB because PCB editor is opened in "
1916 "stand-alone mode. In order to create or update PCBs from "
1917 "schematics, you must launch the KiCad project manager and "
1918 "create a project." ) );
1919 return false; // Not in standalone mode
1920 }
1921
1922 if( standalone < 0 ) // Problem with Eeschema or the schematic
1923 return false;
1924
1925 Raise(); // Show
1926
1927 std::string payload( aAnnotateMessage );
1928
1929 Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
1930
1931 if( payload == aAnnotateMessage )
1932 {
1933 Raise();
1934 DisplayErrorMessage( this, aAnnotateMessage );
1935 return false;
1936 }
1937
1938 try
1939 {
1940 auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
1941 KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
1942 netlistReader.LoadNetlist();
1943 }
1944 catch( const IO_ERROR& e )
1945 {
1946 Raise();
1947
1948 // Do not translate extra_info strings. These are for developers
1949 wxString extra_info = e.Problem() + wxT( " : " ) + e.What() + wxT( " at " ) + e.Where();
1950
1951 DisplayErrorMessage( this, _( "Received an error while reading netlist. Please "
1952 "report this issue to the KiCad team using the menu "
1953 "Help->Report Bug."), extra_info );
1954 return false;
1955 }
1956
1957 return true;
1958}
1959
1960
1962{
1963 wxString msg;
1964 wxFileName schematic( Prj().GetProjectPath(), Prj().GetProjectName(),
1966
1967 if( !schematic.FileExists() )
1968 {
1969 wxFileName legacySchematic( Prj().GetProjectPath(), Prj().GetProjectName(),
1971
1972 if( legacySchematic.FileExists() )
1973 {
1974 schematic = legacySchematic;
1975 }
1976 else
1977 {
1978 msg.Printf( _( "Schematic file '%s' not found." ), schematic.GetFullPath() );
1979 DisplayErrorMessage( this, msg );
1980 return;
1981 }
1982 }
1983
1984 if( Kiface().IsSingle() )
1985 {
1986 ExecuteFile( EESCHEMA_EXE, schematic.GetFullPath() );
1987 }
1988 else
1989 {
1990 KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, false );
1991
1992 // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
1993 // Kiway.Player( FRAME_SCH, true )
1994 // therefore, the schematic editor is sometimes running, but the schematic project
1995 // is not loaded, if the library editor was called, and the dialog field editor was used.
1996 // On Linux, it happens the first time the schematic editor is launched, if
1997 // library editor was running, and the dialog field editor was open
1998 // On Windows, it happens always after the library editor was called,
1999 // and the dialog field editor was used
2000 if( !frame )
2001 {
2002 try
2003 {
2004 frame = Kiway().Player( FRAME_SCH, true );
2005 }
2006 catch( const IO_ERROR& err )
2007 {
2008 DisplayErrorMessage( this, _( "Eeschema failed to load." ) + wxS( "\n" ) + err.What() );
2009 return;
2010 }
2011 }
2012
2013 // If Kiway() cannot create the eeschema frame, it shows a error message, and
2014 // frame is null
2015 if( !frame )
2016 return;
2017
2018 if( !frame->IsShownOnScreen() ) // the frame exists, (created by the dialog field editor)
2019 // but no project loaded.
2020 {
2021 frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFullPath() ) );
2022 frame->Show( true );
2023 }
2024
2025 // On Windows, Raise() does not bring the window on screen, when iconized or not shown
2026 // On Linux, Raise() brings the window on screen, but this code works fine
2027 if( frame->IsIconized() )
2028 {
2029 frame->Iconize( false );
2030
2031 // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
2032 // to show the frame at its normal size: Maximize should be called.
2033 frame->Maximize( false );
2034 }
2035
2036 frame->Raise();
2037 }
2038}
2039
2040
2042{
2043 const ENV_VAR_MAP& vars = Pgm().GetLocalEnvVariables();
2044
2045 // Set the environment variables for python scripts
2046 // note: the string will be encoded UTF8 for python env
2047 for( const std::pair<const wxString, ENV_VAR_ITEM>& var : vars )
2048 UpdatePythonEnvVar( var.first, var.second.GetValue() );
2049
2050 // Because the env vars can be modified by the python scripts (rewritten in UTF8),
2051 // regenerate them (in Unicode) for our normal environment
2052 for( const std::pair<const wxString, ENV_VAR_ITEM>& var : vars )
2053 wxSetEnv( var.first, var.second.GetValue() );
2054}
2055
2056
2058{
2059 wxString evValue;
2060 wxGetEnv( PROJECT_VAR_NAME, &evValue );
2061 UpdatePythonEnvVar( wxString( PROJECT_VAR_NAME ).ToStdString(), evValue );
2062
2063 // Because PROJECT_VAR_NAME can be modified by the python scripts (rewritten in UTF8),
2064 // regenerate it (in Unicode) for our normal environment
2065 wxSetEnv( PROJECT_VAR_NAME, evValue );
2066}
2067
2068
2070{
2071 if( aFootprint == nullptr )
2072 return;
2073
2075
2076 /*
2077 * Make sure dlg is destroyed before GetCanvas->Refresh is called
2078 * later or the refresh will try to modify its properties since
2079 * they share a GL context.
2080 */
2081 {
2082 DIALOG_FOOTPRINT_PROPERTIES dlg( this, aFootprint );
2083
2084 dlg.ShowModal();
2085 retvalue = dlg.GetReturnValue();
2086 }
2087
2088 /*
2089 * retvalue =
2090 * FP_PROPS_UPDATE_FP to show Update Footprints dialog
2091 * FP_PROPS_CHANGE_FP to show Change Footprints dialog
2092 * FP_PROPS_OK for normal edit
2093 * FP_PROPS_CANCEL if aborted
2094 * FP_PROPS_EDIT_BOARD_FP to load board footprint into Footprint Editor
2095 * FP_PROPS_EDIT_LIBRARY_FP to load library footprint into Footprint Editor
2096 */
2097
2099 {
2100 // If something edited, push a refresh request
2101 GetCanvas()->Refresh();
2102 }
2104 {
2105 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ) )
2106 {
2107 FOOTPRINT_EDIT_FRAME* fp_editor = static_cast<FOOTPRINT_EDIT_FRAME*>( frame );
2108
2109 fp_editor->LoadFootprintFromBoard( aFootprint );
2110 fp_editor->Show( true );
2111 fp_editor->Raise(); // Iconize( false );
2112 }
2113 }
2115 {
2116 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ) )
2117 {
2118 FOOTPRINT_EDIT_FRAME* fp_editor = static_cast<FOOTPRINT_EDIT_FRAME*>( frame );
2119
2120 fp_editor->LoadFootprintFromLibrary( aFootprint->GetFPID() );
2121 fp_editor->Show( true );
2122 fp_editor->Raise(); // Iconize( false );
2123 }
2124 }
2126 {
2127 ShowExchangeFootprintsDialog( aFootprint, true, true );
2128 }
2130 {
2131 ShowExchangeFootprintsDialog( aFootprint, false, true );
2132 }
2133}
2134
2135
2137 bool aSelectedMode )
2138{
2139 DIALOG_EXCHANGE_FOOTPRINTS dialog( this, aFootprint, aUpdateMode, aSelectedMode );
2140
2141 return dialog.ShowQuasiModal();
2142}
2143
2144
2156static void processTextItem( const PCB_TEXT& aSrc, PCB_TEXT& aDest,
2157 bool aResetText, bool aResetTextLayers, bool aResetTextEffects,
2158 bool* aUpdated )
2159{
2160 if( aResetText )
2161 *aUpdated |= aSrc.GetText() != aDest.GetText();
2162 else
2163 aDest.SetText( aSrc.GetText() );
2164
2165 if( aResetTextLayers )
2166 {
2167 *aUpdated |= aSrc.GetLayer() != aDest.GetLayer();
2168 *aUpdated |= aSrc.IsVisible() != aDest.IsVisible();
2169 }
2170 else
2171 {
2172 aDest.SetLayer( aSrc.GetLayer() );
2173 aDest.SetVisible( aSrc.IsVisible() );
2174 }
2175
2176 if( aResetTextEffects )
2177 {
2178 *aUpdated |= aSrc.GetHorizJustify() != aDest.GetHorizJustify();
2179 *aUpdated |= aSrc.GetVertJustify() != aDest.GetVertJustify();
2180 *aUpdated |= aSrc.GetTextSize() != aDest.GetTextSize();
2181 *aUpdated |= aSrc.GetTextThickness() != aDest.GetTextThickness();
2182 *aUpdated |= aSrc.GetTextAngle() != aDest.GetTextAngle();
2183 *aUpdated |= aSrc.GetFPRelativePosition() != aDest.GetFPRelativePosition();
2184 }
2185 else
2186 {
2187 // Careful: the visible bit and position are also set by SetAttributes()
2188 bool visible = aDest.IsVisible();
2189 aDest.SetAttributes( aSrc );
2190 aDest.SetVisible( visible );
2192 }
2193
2194 aDest.SetLocked( aSrc.IsLocked() );
2195}
2196
2197
2198static PCB_TEXT* getMatchingTextItem( PCB_TEXT* aRefItem, FOOTPRINT* aFootprint )
2199{
2200 std::vector<PCB_TEXT*> candidates;
2201
2202 for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
2203 {
2204 PCB_TEXT* candidate = dynamic_cast<PCB_TEXT*>( item );
2205
2206 if( candidate && candidate->GetText() == aRefItem->GetText() )
2207 candidates.push_back( candidate );
2208 }
2209
2210 if( candidates.size() == 0 )
2211 return nullptr;
2212
2213 if( candidates.size() == 1 )
2214 return candidates[0];
2215
2216 // Try refining the match by layer
2217 std::vector<PCB_TEXT*> candidatesOnSameLayer;
2218
2219 for( PCB_TEXT* candidate : candidates )
2220 {
2221 if( candidate->GetLayer() == aRefItem->GetLayer() )
2222 candidatesOnSameLayer.push_back( candidate );
2223 }
2224
2225 if( candidatesOnSameLayer.size() == 1 )
2226 return candidatesOnSameLayer[0];
2227
2228 // Last ditch effort: refine by position
2229 std::vector<PCB_TEXT*> candidatesAtSamePos;
2230
2231 for( PCB_TEXT* candidate : candidatesOnSameLayer.size() ? candidatesOnSameLayer : candidates )
2232 {
2233 if( candidate->GetFPRelativePosition() == aRefItem->GetFPRelativePosition() )
2234 candidatesAtSamePos.push_back( candidate );
2235 }
2236
2237 if( candidatesAtSamePos.size() > 0 )
2238 return candidatesAtSamePos[0];
2239 else if( candidatesOnSameLayer.size() > 0 )
2240 return candidatesOnSameLayer[0];
2241 else
2242 return candidates[0];
2243}
2244
2245
2247 BOARD_COMMIT& aCommit, bool deleteExtraTexts,
2248 bool resetTextLayers, bool resetTextEffects,
2249 bool resetTextContent, bool resetFabricationAttrs,
2250 bool reset3DModels, bool* aUpdated )
2251{
2252 PCB_GROUP* parentGroup = aExisting->GetParentGroup();
2253 bool dummyBool = false;
2254
2255 if( !aUpdated )
2256 aUpdated = &dummyBool;
2257
2258 if( parentGroup )
2259 {
2260 parentGroup->RemoveItem( aExisting );
2261 parentGroup->AddItem( aNew );
2262 }
2263
2264 aNew->SetParent( GetBoard() );
2265
2266 PlaceFootprint( aNew, false );
2267
2268 // PlaceFootprint will move the footprint to the cursor position, which we don't want. Copy
2269 // the original position across.
2270 aNew->SetPosition( aExisting->GetPosition() );
2271
2272 if( aNew->GetLayer() != aExisting->GetLayer() )
2273 aNew->Flip( aNew->GetPosition(), GetPcbNewSettings()->m_FlipLeftRight );
2274
2275 if( aNew->GetOrientation() != aExisting->GetOrientation() )
2276 aNew->SetOrientation( aExisting->GetOrientation() );
2277
2278 aNew->SetLocked( aExisting->IsLocked() );
2279
2280 // Now transfer the net info from "old" pads to the new footprint
2281 for( PAD* pad : aNew->Pads() )
2282 {
2283 PAD* pad_model = nullptr;
2284
2285 // Pads with no copper are never connected to a net
2286 if( !pad->IsOnCopperLayer() )
2287 {
2288 pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
2289 continue;
2290 }
2291
2292 // Pads with no numbers are never connected to a net
2293 if( pad->GetNumber().IsEmpty() )
2294 {
2295 pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
2296 continue;
2297 }
2298
2299 // Search for a similar pad on a copper layer, to reuse net info
2300 PAD* last_pad = nullptr;
2301
2302 while( true )
2303 {
2304 pad_model = aExisting->FindPadByNumber( pad->GetNumber(), last_pad );
2305
2306 if( !pad_model )
2307 break;
2308
2309 if( pad_model->IsOnCopperLayer() ) // a candidate is found
2310 break;
2311
2312 last_pad = pad_model;
2313 }
2314
2315 if( pad_model )
2316 {
2317 pad->SetLocalRatsnestVisible( pad_model->GetLocalRatsnestVisible() );
2318 pad->SetPinFunction( pad_model->GetPinFunction() );
2319 pad->SetPinType( pad_model->GetPinType() );
2320 }
2321
2322 pad->SetNetCode( pad_model ? pad_model->GetNetCode() : NETINFO_LIST::UNCONNECTED );
2323 }
2324
2325 for( BOARD_ITEM* item : aExisting->GraphicalItems() )
2326 {
2327 PCB_TEXT* srcItem = dynamic_cast<PCB_TEXT*>( item );
2328
2329 if( srcItem )
2330 {
2331 // Dimensions have PCB_TEXT base but are not treated like texts in the updater
2332 if( dynamic_cast<PCB_DIMENSION_BASE*>( srcItem ) )
2333 continue;
2334
2335 PCB_TEXT* destItem = getMatchingTextItem( srcItem, aNew );
2336
2337 if( destItem )
2338 {
2339 processTextItem( *srcItem, *destItem, resetTextContent, resetTextLayers,
2340 resetTextEffects, aUpdated );
2341 }
2342 else if( !deleteExtraTexts )
2343 {
2344 aNew->Add( static_cast<BOARD_ITEM*>( srcItem->Clone() ) );
2345 }
2346 }
2347 }
2348
2349 // Copy reference. The initial text is always used, never resetted
2350 processTextItem( aExisting->Reference(), aNew->Reference(),
2351 false,
2352 resetTextLayers, resetTextEffects, aUpdated );
2353
2354 // Copy value
2355 processTextItem( aExisting->Value(), aNew->Value(),
2356 // reset value text only when it is a proxy for the footprint ID
2357 // (cf replacing value "MountingHole-2.5mm" with "MountingHole-4.0mm")
2358 aExisting->GetValue() == aExisting->GetFPID().GetLibItemName().wx_str(),
2359 resetTextLayers, resetTextEffects, aUpdated );
2360
2361 // Copy fields in accordance with the reset* flags
2362 for( PCB_FIELD* field : aExisting->GetFields() )
2363 {
2364 // Reference and value are already handled
2365 if( field->IsReference() || field->IsValue() )
2366 continue;
2367
2368 PCB_FIELD* newField = aNew->GetFieldByName( field->GetName() );
2369
2370 if( !newField )
2371 {
2372 newField = new PCB_FIELD( *field );
2373 aNew->Add( newField );
2374 processTextItem( *field, *newField, true, true, true, aUpdated );
2375 }
2376 else
2377 {
2378 processTextItem( *field, *newField, resetTextContent, resetTextLayers, resetTextEffects,
2379 aUpdated );
2380 }
2381
2382 }
2383
2384 if( resetFabricationAttrs )
2385 {
2386 // We've replaced the existing footprint with the library one, so the fabrication attrs
2387 // are already reset.
2388 //
2389 // We only have to do anything if resetFabricationAttrs is *not* set....
2390 }
2391 else
2392 {
2393 // Careful; allow-soldermask-bridges is in the m_attributes field but is not presented
2394 // as a fabrication attribute in the GUI....
2395 int libraryFlagsToKeep = aNew->GetAttributes() & FP_ALLOW_SOLDERMASK_BRIDGES;
2396 int existingFlagsToKeep = aExisting->GetAttributes() & ~FP_ALLOW_SOLDERMASK_BRIDGES;
2397 aNew->SetAttributes( existingFlagsToKeep | libraryFlagsToKeep );
2398 }
2399
2400 if( reset3DModels )
2401 {
2402 // We've replaced the existing footprint with the library one, so the 3D models are
2403 // already reset.
2404 //
2405 // We only have to do anything if reset3DModels is *not* set....
2406 }
2407 else
2408 {
2409 aNew->Models() = aExisting->Models(); // Linked list of 3D models.
2410 }
2411
2412 // Updating other parameters
2413 const_cast<KIID&>( aNew->m_Uuid ) = aExisting->m_Uuid;
2414 aNew->SetPath( aExisting->GetPath() );
2415 aNew->SetSheetfile( aExisting->GetSheetfile() );
2416 aNew->SetSheetname( aExisting->GetSheetname() );
2417 aNew->SetFilters( aExisting->GetFilters() );
2418
2419 aCommit.Remove( aExisting );
2420 aCommit.Add( aNew );
2421
2422 aNew->ClearFlags();
2423}
2424
2425
2426void PCB_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
2427{
2428 PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
2429
2431
2432 SetElementVisibility( LAYER_RATSNEST, GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
2433
2435
2436 // Netclass definitions could have changed, either by us or by Eeschema, so we need to
2437 // recompile the implicit rules
2438 DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
2439 WX_INFOBAR* infobar = GetInfoBar();
2440
2441 try
2442 {
2443 drcTool->GetDRCEngine()->InitEngine( GetDesignRulesPath() );
2444
2445 if( infobar->GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::DRC_RULES_ERROR )
2446 infobar->Dismiss();
2447 }
2448 catch( PARSE_ERROR& )
2449 {
2450 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Edit design rules" ),
2451 wxEmptyString );
2452
2453 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
2454 [&]( wxHyperlinkEvent& aEvent )
2455 {
2456 ShowBoardSetupDialog( _( "Custom Rules" ) );
2457 } ) );
2458
2459 infobar->RemoveAllButtons();
2460 infobar->AddButton( button );
2461 infobar->AddCloseButton();
2462 infobar->ShowMessage( _( "Could not compile custom design rules." ), wxICON_ERROR,
2464 }
2465
2468
2469 // Update the environment variables in the Python interpreter
2470 if( aEnvVarsChanged )
2472
2473 Layout();
2474 SendSizeEvent();
2475}
2476
2477
2479{
2481}
2482
2483
2485{
2487}
2488
2489
2491{
2492 // For now, be conservative: Don't allow any API use while the user is changing things
2493 if( GetToolManager()->GetCurrentTool() != GetToolManager()->GetTool<PCB_SELECTION_TOOL>() )
2494 return false;
2495
2497
2498 if( zoneFillerTool->IsBusy() )
2499 return false;
2500
2501 ROUTER_TOOL* routerTool = m_toolManager->GetTool<ROUTER_TOOL>();
2502
2503 if( routerTool->RoutingInProgress() )
2504 return false;
2505
2507}
2508
2509
2510bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath );
2511
2512
2513void PCB_EDIT_FRAME::OnExportHyperlynx( wxCommandEvent& event )
2514{
2515 wxString wildcard = wxT( "*.hyp" );
2516 wxFileName fn = GetBoard()->GetFileName();
2517
2518 fn.SetExt( wxT("hyp") );
2519
2520 wxFileDialog dlg( this, _( "Export Hyperlynx Layout" ), fn.GetPath(), fn.GetFullName(),
2521 wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
2522
2523 if( dlg.ShowModal() != wxID_OK )
2524 return;
2525
2526 fn = dlg.GetPath();
2527
2528 // always enforce filename extension, user may not have entered it.
2529 fn.SetExt( wxT( "hyp" ) );
2530
2532}
2533
2534
2536{
2537 return GetBoard()->GetFileName();
2538}
2539
2540
2542{
2543 return m_auimgr.GetPane( wxS( "LayersManager" ) ).IsShown();
2544}
2545
2546
2548{
2549 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
2550}
2551
2552
2554{
2555 return m_auimgr.GetPane( NetInspectorPanelName() ).IsShown();
2556}
2557
2558
2559void PCB_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2560{
2561 if( IsShownOnScreen() )
2562 {
2563 // We only need this until the frame is done resizing and the final client size is
2564 // established.
2565 Unbind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
2567 }
2568
2569 // Skip() is called in the base class.
2570 EDA_DRAW_FRAME::OnSize( aEvent );
2571}
2572
2573
2575{
2578 _( "Violation Report" ) );
2579
2580 return m_inspectDrcErrorDlg;
2581}
2582
2583
2585{
2588 _( "Clearance Report" ) );
2589
2590 return m_inspectClearanceDlg;
2591}
2592
2593
2595{
2598 _( "Constraints Report" ) );
2599
2601}
2602
2603
2605{
2606 if( !m_footprintDiffDlg )
2608 _( "Compare Footprint with Library" ) );
2609
2610 return m_footprintDiffDlg;
2611}
2612
2613
2615{
2616 if( m_inspectDrcErrorDlg && aEvent.GetString() == INSPECT_DRC_ERROR_DIALOG_NAME )
2617 {
2618 m_inspectDrcErrorDlg->Destroy();
2619 m_inspectDrcErrorDlg = nullptr;
2620 }
2621 else if( m_inspectClearanceDlg && aEvent.GetString() == INSPECT_CLEARANCE_DIALOG_NAME )
2622 {
2623 m_inspectClearanceDlg->Destroy();
2624 m_inspectClearanceDlg = nullptr;
2625 }
2626 else if( m_inspectConstraintsDlg && aEvent.GetString() == INSPECT_CONSTRAINTS_DIALOG_NAME )
2627 {
2628 m_inspectConstraintsDlg->Destroy();
2629 m_inspectConstraintsDlg = nullptr;
2630 }
2631 else if( m_footprintDiffDlg && aEvent.GetString() == INSPECT_CONSTRAINTS_DIALOG_NAME )
2632 {
2633 m_footprintDiffDlg->Destroy();
2634 m_footprintDiffDlg = nullptr;
2635 }
2636}
2637
2638#ifdef KICAD_IPC_API
2639void PCB_EDIT_FRAME::onPluginAvailabilityChanged( wxCommandEvent& aEvt )
2640{
2641 wxLogTrace( traceApi, "PCB frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
2643 aEvt.Skip();
2644}
2645#endif
Class PCBNEW_ACTION_PLUGINS.
const KICOMMON_API wxEventTypeTag< wxCommandEvent > EDA_EVT_PLUGIN_AVAILABILITY_CHANGED
Notifies other parts of KiCad when plugin availability changes.
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
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
@ icon_pcbnew_32
@ icon_pcbnew_16
static TOOL_ACTION toggleGrid
Definition: actions.h:172
static TOOL_ACTION paste
Definition: actions.h:70
static TOOL_ACTION millimetersUnits
Definition: actions.h:180
static TOOL_ACTION unselectAll
Definition: actions.h:73
static TOOL_ACTION togglePolarCoords
Definition: actions.h:183
static TOOL_ACTION copy
Definition: actions.h:69
static TOOL_ACTION pluginsReload
Cursor control event types.
Definition: actions.h:224
static TOOL_ACTION pasteSpecial
Definition: actions.h:71
static TOOL_ACTION milsUnits
Definition: actions.h:179
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:135
static TOOL_ACTION showSearch
Definition: actions.h:98
static TOOL_ACTION undo
Definition: actions.h:66
static TOOL_ACTION duplicate
Definition: actions.h:74
static TOOL_ACTION inchesUnits
Definition: actions.h:178
static TOOL_ACTION highContrastMode
Definition: actions.h:133
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:132
static TOOL_ACTION measureTool
Definition: actions.h:188
static TOOL_ACTION doDelete
Definition: actions.h:75
static TOOL_ACTION selectionTool
Definition: actions.h:187
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:124
static TOOL_ACTION redo
Definition: actions.h:67
static TOOL_ACTION deleteTool
Definition: actions.h:76
static TOOL_ACTION zoomTool
Definition: actions.h:127
static TOOL_ACTION showProperties
Definition: actions.h:201
static TOOL_ACTION cut
Definition: actions.h:68
static TOOL_ACTION gridSetOrigin
Definition: actions.h:169
static TOOL_ACTION toggleGridOverrides
Definition: actions.h:173
static TOOL_ACTION selectAll
Definition: actions.h:72
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 ApplyLayerPreset(const wxString &aPresetName)
int GetTabIndex() const
Set the current notebook tab.
void UpdateDisplayOptions()
Return a list of the layer presets created by the user.
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.
Definition: app_settings.h:92
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
Definition: base_screen.cpp:71
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
bool GetLocalRatsnestVisible() const
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:77
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:226
virtual void SetLocked(bool aLocked)
Definition: board_item.h:300
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:91
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:291
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:260
VECTOR2I GetFPRelativePosition() const
Definition: board_item.cpp:262
void SetFPRelativePosition(const VECTOR2I &aPos)
Definition: board_item.cpp:276
virtual bool IsLocked() const
Definition: board_item.cpp:74
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:677
void BuildListOfNets()
Definition: board.h:816
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:743
void RemoveAllListeners()
Remove all listeners.
Definition: board.cpp:2511
const PAGE_INFO & GetPageSettings() const
Definition: board.h:671
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
Definition: board.cpp:737
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:176
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1936
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:677
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:354
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition: board.cpp:186
const wxString & GetFileName() const
Definition: board.h:319
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:749
void ClearProject()
Definition: board.cpp:225
PROJECT * GetProject() const
Definition: board.h:476
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition: board.cpp:286
void SetColor(int aLayer, const COLOR4D &aColor)
COLOR4D GetColor(int aLayer) const
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been removed.
Definition: commit.h:92
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
Definition: commit.h:80
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
Definition: common_tools.h:38
static std::mutex g_Mutex
void SetCallback(std::function< void(BOARD_ITEM *)> aCallback)
Function to be called on each found event.
Definition: dialog_find.h:63
bool Show(bool show=true) override
The Show method is overridden to make the search combobox focused by default.
void Preload(const wxString &aFindString)
Definition: dialog_find.cpp:98
void FindNext(bool reverse)
Finds the next item.
Definition: dialog_find.h:71
enum FP_PROPS_RETVALUE GetReturnValue()
A dialog to set the plot options and create plot files in various formats.
Definition: dialog_plot.h:40
int ShowQuasiModal()
Tool responsible for drawing graphical elements like lines, arcs, circles, etc.
Definition: drawing_tool.h:55
MODE GetDrawingMode() const
Return the current drawing mode of the DRAWING_TOOL or MODE::NONE if not currently in any drawing mod...
std::shared_ptr< DRC_ENGINE > GetDRCEngine()
Definition: drc_tool.h:78
bool IsDRCRunning() const
Check to see if the DRC engine is running the tests.
Definition: drc_tool.h:71
void SetSheetPath(const std::string &aSheetPath)
Set the sheet path displayed in the title block.
void SetSheetCount(int aSheetCount)
Changes the sheet-count number displayed in the title block.
void SetPageNumber(const std::string &aPageNumber)
Changes 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.
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()
Checks if this frame is ready to accept API commands.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
virtual void OnSize(wxSizeEvent &aEvent)
virtual bool canCloseWindow(wxCloseEvent &aCloseEvent)
virtual int GetUndoCommandCount() const
WX_INFOBAR * GetInfoBar()
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)
Changes the current rendering backend.
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual wxString GetScreenDesc() const
static const wxString PropertiesPaneName()
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
NET_INSPECTOR_PANEL * m_netInspectorPanel
static const wxString NetInspectorPanelName()
SEARCH_PANE * m_searchPane
PROPERTIES_PANEL * m_propertiesPanel
static constexpr GAL_TYPE GAL_FALLBACK
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetFocus() override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
const KIID m_Uuid
Definition: eda_item.h:485
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:128
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:103
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:83
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:134
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
virtual bool IsVisible() const
Definition: eda_text.h:151
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
Definition: eda_text.cpp:290
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:164
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:243
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:167
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:181
int GetTextThickness() const
Definition: eda_text.h:126
VECTOR2I GetTextSize() const
Definition: eda_text.h:222
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 ScriptingConsoleVisible()
Create a functor testing if the python scripting console window is visible.
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
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.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
The interactive edit tool.
Definition: edit_tool.h:56
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:669
static ENUM_MAP< T > & Instance()
Definition: property.h:663
ENUM_MAP & Undefined(T aValue)
Definition: property.h:676
wxPGChoices & Choices()
Definition: property.h:712
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.
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:2315
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: footprint.h:406
EDA_ANGLE GetOrientation() const
Definition: footprint.h:212
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2387
PCB_FIELD * GetFieldByName(const wxString &aFieldName)
Return a field in this symbol.
Definition: footprint.cpp:538
wxString GetSheetname() const
Definition: footprint.h:251
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:249
void SetFilters(const wxString &aFilters)
Definition: footprint.h:258
void SetAttributes(int aAttributes)
Definition: footprint.h:276
void SetSheetfile(const wxString &aSheetfile)
Definition: footprint.h:255
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:623
int GetAttributes() const
Definition: footprint.h:275
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: footprint.h:221
wxString GetSheetfile() const
Definition: footprint.h:254
PADS & Pads()
Definition: footprint.h:191
const LIB_ID & GetFPID() const
Definition: footprint.h:233
bool IsLocked() const override
Definition: footprint.h:396
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with PCB_TEXTs.
Definition: footprint.cpp:565
PCB_FIELD & Reference()
Definition: footprint.h:624
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:968
wxString GetFilters() const
Definition: footprint.h:257
void SetSheetname(const wxString &aSheetname)
Definition: footprint.h:252
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:205
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:2256
const wxString & GetValue() const
Definition: footprint.h:609
const KIID_PATH & GetPath() const
Definition: footprint.h:248
VECTOR2I GetPosition() const override
Definition: footprint.h:209
DRAWINGS & GraphicalItems()
Definition: footprint.h:194
PAD * FindPadByNumber(const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
Return a PAD with a matching number.
Definition: footprint.cpp:1781
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
bool Contains(GAL_LAYER_ID aPos)
Definition: layer_ids.h:341
Handle actions specific to filling copper zones.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp:46
virtual const wxString Where() const
where did the Problem() occur?
Definition: exceptions.cpp:40
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:104
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
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:75
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
double GetScale() const
Definition: view.h:271
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:1631
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:395
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:245
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1513
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:215
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:619
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:1523
An implementation of class VIEW_CONTROLS for wxWidgets library.
std::unique_ptr< PROF_COUNTER > m_MotionEventCounter
Definition: kiid.h:49
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
Definition: kiway_player.h:113
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:99
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:69
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
void OnKiCadExit()
Definition: kiway.cpp:717
virtual void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition: kiway.cpp:617
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:406
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:527
int SetLayerSelection(int layer)
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:521
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:575
static LSET AllLayersMask()
Definition: lset.cpp:898
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:418
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:89
@ 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:375
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:223
virtual void OnBoardChanged()
Notification from file loader when board changed and connectivity rebuilt.
virtual void OnParentSetupChanged()
Rebuild inspector data if project settings updated.
Tool relating to pads and pad settings.
Definition: pad_tool.h:37
Definition: pad.h:53
const wxString & GetPinType() const
Definition: pad.h:145
const wxString & GetPinFunction() const
Definition: pad.h:139
bool IsOnCopperLayer() const override
Definition: pad.cpp:938
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:59
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:50
static TOOL_ACTION toggleHV45Mode
Definition: pcb_actions.h:517
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:218
static TOOL_ACTION microwaveCreateGap
Definition: pcb_actions.h:506
static TOOL_ACTION placeText
Definition: pcb_actions.h:203
static TOOL_ACTION pointEditorArcKeepCenter
Definition: pcb_actions.h:293
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:214
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:199
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:330
static TOOL_ACTION placeReferenceImage
Definition: pcb_actions.h:202
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:325
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:442
static TOOL_ACTION toggleNetHighlight
Definition: pcb_actions.h:553
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:200
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:249
static TOOL_ACTION tuneDiffPair
Definition: pcb_actions.h:252
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:381
static TOOL_ACTION ddAppendBoard
Drag and drop.
Definition: pcb_actions.h:582
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:551
static TOOL_ACTION drawTable
Definition: pcb_actions.h:205
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:204
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:268
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:270
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:269
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:219
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:198
static TOOL_ACTION hideNetInRatsnest
Definition: pcb_actions.h:558
static TOOL_ACTION group
Definition: pcb_actions.h:525
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:332
static TOOL_ACTION showNetInRatsnest
Definition: pcb_actions.h:559
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:213
static TOOL_ACTION tuneSingleTrack
Definition: pcb_actions.h:251
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:331
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:215
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:535
static TOOL_ACTION tuneSkew
Definition: pcb_actions.h:253
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:329
static TOOL_ACTION showNetInspector
Definition: pcb_actions.h:443
static TOOL_ACTION microwaveCreateStubArc
Definition: pcb_actions.h:510
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:335
static TOOL_ACTION ungroup
Definition: pcb_actions.h:526
static TOOL_ACTION selectUnconnected
Select unconnected footprints from ratsnest of selection.
Definition: pcb_actions.h:102
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:334
static TOOL_ACTION drawVia
Definition: pcb_actions.h:217
static TOOL_ACTION drawArc
Definition: pcb_actions.h:201
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:404
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:489
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:220
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition: pcb_actions.h:294
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:212
static TOOL_ACTION selectSameSheet
Select all components on the same sheet as the selected footprint.
Definition: pcb_actions.h:111
static TOOL_ACTION microwaveCreateStub
Definition: pcb_actions.h:508
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
Definition: pcb_actions.h:96
static TOOL_ACTION microwaveCreateLine
Definition: pcb_actions.h:514
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:383
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:333
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:326
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:492
static TOOL_ACTION highlightNetSelection
Definition: pcb_actions.h:554
static TOOL_ACTION microwaveCreateFunctionShape
Definition: pcb_actions.h:512
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:401
static TOOL_ACTION unlock
Definition: pcb_actions.h:522
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:223
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:246
static TOOL_ACTION deselectNet
Remove all connections belonging to a single net from the active selection.
Definition: pcb_actions.h:99
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:444
static TOOL_ACTION drawLine
Definition: pcb_actions.h:197
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:560
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:211
static TOOL_ACTION drawZone
Definition: pcb_actions.h:216
static TOOL_ACTION selectOnSchematic
Select symbols/pins on schematic corresponding to selected footprints/pads.
Definition: pcb_actions.h:114
static TOOL_ACTION lock
Definition: pcb_actions.h:521
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.
void doCloseWindow() override
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
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.
APPEARANCE_CONTROLS * GetAppearancePanel()
APPEARANCE_CONTROLS * m_appearancePanel
PANEL_SELECTION_FILTER * m_selectionFilterPanel
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.
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
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 PCB_LAYER_ID GetActiveLayer() const
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
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
Returns the BOARD_DESIGN_SETTINGS for the open project.
virtual void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings)
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
Places aFootprint at the current cursor position and updates footprint coordinates with the new posit...
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
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
Abstract dimension API.
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.
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 Get45degMode()
Create a functor that tests whether only 45 degree lines should be allowed.
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
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
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 setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void ReCreateHToolbar() override
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Change the visibility of an element category.
DIALOG_BOOK_REPORTER * m_inspectDrcErrorDlg
void OnClearFileHistory(wxCommandEvent &aEvent)
virtual ~PCB_EDIT_FRAME()
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
Switch currently used canvas (Cairo / OpenGL).
BOARD_ITEM_CONTAINER * GetModel() const override
DIALOG_BOOK_REPORTER * GetInspectDrcErrorDialog()
void OnExportSTEP(wxCommandEvent &event)
Export the current BOARD to a STEP assembly.
void ExchangeFootprint(FOOTPRINT *aExisting, FOOTPRINT *aNew, BOARD_COMMIT &aCommit, bool deleteExtraTexts=true, bool resetTextLayers=true, bool resetTextEffects=true, bool resetFabricationAttrs=true, bool resetTextContent=true, bool reset3DModels=true, bool *aUpdated=nullptr)
Replace aExisting footprint by aNew footprint using the Existing footprint settings (position,...
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
Checks 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 onBoardLoaded()
Update the state of the GUI after a new board is loaded or created.
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 OnExportIDF3(wxCommandEvent &event)
Export the current BOARD to a IDFv3 board and lib files.
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.
void PythonSyncProjectName()
Synchronize the project name from KiCad's environment into the Python interpreter.
bool m_show_layer_manager_tools
void OnExportVRML(wxCommandEvent &event)
Export the current BOARD to a VRML file.
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 OnExportHyperlynx(wxCommandEvent &event)
Export the current BOARD to a Hyperlynx HYP file.
bool IsContentModified() const override
Get if the current board has been modified but not saved.
void PythonSyncEnvironmentVariables()
Synchronize the environment variables from KiCad's environment into the Python interpreter.
bool Clear_Pcb(bool doAskAboutUnsavedChanges, bool aFinal=false)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:40
TOOL_ACTION * m_exportNetlistAction
The export board netlist tool action object.
void ReCreateAuxiliaryToolbar() override
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.
void ExportSVG(wxCommandEvent &event)
Show the Export to SVG file dialog.
void RecreateCmpFileFromBoard(wxCommandEvent &aEvent)
Recreates a .cmp file from the current loaded board.
DIALOG_BOOK_REPORTER * GetFootprintDiffDialog()
EDA_ANGLE GetRotationAngle() const override
Return the angle used for rotate operations.
COLOR4D GetGridColor() override
void Files_io(wxCommandEvent &event)
Call Files_io_from_id with the wxCommandEvent id.
void UpdateTitle()
Set the main window title bar text.
DIALOG_BOOK_REPORTER * m_footprintDiffDlg
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
void ExportToGenCAD(wxCommandEvent &event)
Create a file in GenCAD 1.4 format from the current board.
void ActivateGalCanvas() override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
void Process_Special_Functions(wxCommandEvent &event)
Definition: edit.cpp:53
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void OnQuit(wxCommandEvent &event)
void onCloseModelessBookReporterDialogs(wxCommandEvent &aEvent)
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
DIALOG_BOOK_REPORTER * GetInspectClearanceDialog()
wxTimer * m_eventCounterTimer
void Tracks_and_Vias_Size_Event(wxCommandEvent &event)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void redrawNetnames(wxTimerEvent &aEvent)
static const wxString SearchPaneName()
DIALOG_BOOK_REPORTER * m_inspectClearanceDlg
void OnFileHistory(wxCommandEvent &event)
void ToPlotter(int aID)
Open a dialog frame to create plot and drill files relative to the current board.
DIALOG_BOOK_REPORTER * GetInspectConstraintsDialog()
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
virtual bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
Definition: pcb_group.cpp:95
virtual bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:80
Net inspection panel for pcbnew.
Generic tool for picking an item.
Parameters and options when plotting/printing a board.
void SetFormat(PLOT_FORMAT aFormat)
Tool that displays edit points allowing to modify items by dragging the points.
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:
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:511
Tool useful for viewing footprints.
virtual ENV_VAR_MAP & GetLocalEnvVariables() const
Definition: pgm_base.cpp:923
virtual const wxString & GetExecutablePath() const
Definition: pgm_base.cpp:1038
The interactive edit tool.
A progress reporter interface for use in multi-threaded environments.
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:70
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 PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:172
void IncrementNetclassesTicker()
Definition: project.h:98
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:166
void IncrementTextVarsTicker()
Definition: project.h:95
float SplitterProportion() const
Action handler for the Properties panel.
PNS::PNS_MODE GetRouterMode()
bool RoutingInProgress()
Returns whether routing is currently active.
Tool relating to pads and pad settings.
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.
EDA_ITEM * Front() const
Definition: selection.h:172
int Size() const
Returns the number of selected parts.
Definition: selection.h:116
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:253
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:169
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
ACTIONS * m_actions
Definition: tools_holder.h:168
Represent a single user action.
Definition: tool_action.h:269
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:167
void SetHasPosition(bool aHasPosition)
Returns if the action associated with this event should be treated as immediate regardless of the cur...
Definition: tool_event.h:257
Master controller class:
Definition: tool_manager.h:62
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:302
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:235
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
std::vector< TOOL_BASE * > Tools()
Definition: tool_manager.h:337
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void InitTools()
Initializes all registered tools.
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
wxString wx_str() const
Definition: utf8.cpp:45
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:75
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: wx_infobar.cpp:301
@ OUTDATED_SAVE
OUTDATED_SAVE Messages that should be cleared on save.
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: wx_infobar.cpp:291
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: wx_infobar.cpp:154
Handle actions specific to filling copper zones.
PROGRESS_REPORTER * GetProgressReporter()
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
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:130
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:195
This file is part of the common library.
#define CHECK(x)
#define ENABLE(x)
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:42
bool InvokeExportSVG(PCB_EDIT_FRAME *aCaller, BOARD *aBoard)
Function InvokeExportSVG shows the Export SVG dialog.
#define _HKI(x)
#define _(s)
Declaration of the eda_3d_viewer class.
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:437
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define PCB_EDIT_FRAME_NAME
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectHighlightChoice EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnUpdateLayerSelectBox) void GERBVIEW_FRAME
KiCad executable names.
const wxString EESCHEMA_EXE
bool ExportBoardToHyperlynx(BOARD *aBoard, const wxFileName &aPath)
@ FP_ALLOW_SOLDERMASK_BRIDGES
Definition: footprint.h:78
#define CURRENT_EDIT_TOOL(action)
@ 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
@ ID_MAIN_MENUBAR
Definition: gerbview_id.h:38
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition: gestfich.cpp:139
bool m_ShowEventCounters
Shows debugging event counters in various places.
static const std::string LegacySchematicFileExtension
static const std::string LegacyPcbFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string AutoSaveFilePrefix
static const std::string KiCadPcbFileExtension
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
const wxChar *const traceApi
Flag to enable debug output related to the API plugin system.
@ ID_ON_GRID_SELECT
Definition: id.h:145
@ ID_GEN_PLOT_DXF
Definition: id.h:96
@ ID_FILE_LIST_CLEAR
Definition: id.h:87
@ ID_EDA_SOCKET_EVENT
Definition: id.h:163
@ ID_GEN_PLOT_PS
Definition: id.h:92
@ ID_EDA_SOCKET_EVENT_SERV
Definition: id.h:162
@ ID_GEN_PLOT_GERBER
Definition: id.h:94
@ ID_ON_ZOOM_SELECT
Definition: id.h:143
@ ID_GEN_PLOT
Definition: id.h:91
@ ID_GEN_PLOT_SVG
Definition: id.h:95
@ ID_GEN_PLOT_HPGL
Definition: id.h:93
@ ID_FILEMAX
Definition: id.h:85
@ ID_FILE1
Definition: id.h:84
@ ID_GEN_PLOT_PDF
Definition: id.h:97
@ ID_AUTO_SAVE_TIMER
Definition: id.h:79
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
PROJECT & Prj()
Definition: kicad.cpp:595
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:1022
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:194
@ LAYER_GRID
Definition: layer_ids.h:209
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored)
Definition: layer_ids.h:235
@ LAYER_RATSNEST
Definition: layer_ids.h:208
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ F_Paste
Definition: layer_ids.h:101
@ B_Mask
Definition: layer_ids.h:106
@ B_Cu
Definition: layer_ids.h:95
@ F_Mask
Definition: layer_ids.h:107
@ B_Paste
Definition: layer_ids.h:100
@ 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:57
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:54
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:58
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition: definitions.h:49
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:90
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:79
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
@ RM_Walkaround
Only walk around.
@ RM_Shove
Only shove.
static void processTextItem(const PCB_TEXT &aSrc, PCB_TEXT &aDest, bool aResetText, bool aResetTextLayers, bool aResetTextEffects, bool *aUpdated)
copy text settings from aSrc to aDest
#define FOOTPRINT_DIFF_DIALOG_NAME
static PCB_TEXT * getMatchingTextItem(PCB_TEXT *aRefItem, FOOTPRINT *aFootprint)
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
bool ExportBoardToHyperlynx(BOARD *aBoard, const wxFileName &aPath)
#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:25
@ ID_POPUP_PCB_SELECT_WIDTH1
Definition: pcbnew_id.h:29
@ ID_POPUP_PCB_SELECT_VIASIZE8
Definition: pcbnew_id.h:52
@ ID_GEN_EXPORT_FILE_HYPERLYNX
Definition: pcbnew_id.h:88
@ ID_IMPORT_NON_KICAD_BOARD
Definition: pcbnew_id.h:19
@ ID_MENU_RECOVER_BOARD_AUTOSAVE
Definition: pcbnew_id.h:81
@ ID_AUX_TOOLBAR_PCB_VIA_SIZE
Definition: pcbnew_id.h:22
@ ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH
Definition: pcbnew_id.h:24
@ ID_PCB_GEN_CMP_FILE
Definition: pcbnew_id.h:93
@ ID_MENU_EXPORT_FOOTPRINTS_TO_NEW_LIBRARY
Definition: pcbnew_id.h:83
@ ID_POPUP_PCB_SELECT_WIDTH_END_RANGE
Definition: pcbnew_id.h:79
@ ID_MENU_EXPORT_FOOTPRINTS_TO_LIBRARY
Definition: pcbnew_id.h:82
@ ID_GEN_EXPORT_FILE_VRML
Definition: pcbnew_id.h:86
@ ID_POPUP_PCB_SELECT_VIASIZE1
Definition: pcbnew_id.h:45
@ ID_GEN_EXPORT_FILE_STEP
Definition: pcbnew_id.h:87
@ ID_TOOLBARH_PCB_SELECT_LAYER
Definition: pcbnew_id.h:96
@ ID_GEN_EXPORT_FILE_IDF3
Definition: pcbnew_id.h:85
@ ID_AUX_TOOLBAR_PCB_TRACK_WIDTH
Definition: pcbnew_id.h:23
@ ID_GEN_EXPORT_FILE_GENCADFORMAT
Definition: pcbnew_id.h:89
void ScriptingOnDestructPcbEditFrame(PCB_EDIT_FRAME *aPcbEditFrame)
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
@ SHOW_WITH_VIA_ALWAYS
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Definition: project.h:39
LAST_PATH_TYPE
For storing PcbNew MRU paths of various types.
Definition: project_file.h:47
@ RPT_SEVERITY_EXCLUSION
#define SKIP_SET_DIRTY
Definition: sch_commit.h:43
#define SKIP_UNDO
Definition: sch_commit.h:41
#define CURRENT_TOOL(action)
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
KIWAY Kiway(KFCTL_STANDALONE)
const int scale
wxString UnescapeString(const wxString &aSource)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:391
const double IU_PER_MILS
Definition: base_units.h:77
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:120
TRACK_CLEARANCE_MODE m_TrackClearance
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition: tool_action.h:48
@ AS_ACTIVE
All active tools.
Definition: tool_action.h:47
@ TA_MODEL_CHANGE
Definition: tool_event.h:120
@ TC_COMMAND
Definition: tool_event.h:56
wxLogTrace helper definitions.
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition: typeinfo.h:91
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:110
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:107
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition: typeinfo.h:90
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
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.