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>
29#include <fp_lib_table.h>
30#include <bitmaps.h>
31#include <confirm.h>
32#include <trace_helpers.h>
33#include <pcbnew_id.h>
34#include <pcbnew_settings.h>
37#include <dialog_plot.h>
38#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>
105#include <widgets/wx_aui_utils.h>
106#include <kiplatform/app.h>
107#include <core/profile.h>
111
112#include <action_plugin.h>
114#include "../scripting/python_scripting.h"
115
116#include <wx/filedlg.h>
117
118using namespace std::placeholders;
119
120
121#define INSPECT_DRC_ERROR_DIALOG_NAME wxT( "InspectDrcErrorDialog" )
122#define INSPECT_CLEARANCE_DIALOG_NAME wxT( "InspectClearanceDialog" )
123#define INSPECT_CONSTRAINTS_DIALOG_NAME wxT( "InspectConstraintsDialog" )
124#define FOOTPRINT_DIFF_DIALOG_NAME wxT( "FootprintDiffDialog" )
125
126
127BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
130
131
134
135 EVT_SIZE( PCB_EDIT_FRAME::OnSize )
136
138
139 // Menu Files:
141
145
151
154
155 EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
156 EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
157
158 // menu Postprocess
160
161 // Horizontal toolbar
167
168 // Tracks and vias sizes general options
170 PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
171
172 // User interface update event handlers.
178 PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
180 PCB_EDIT_FRAME::OnUpdateSelectViaSize )
181 // Drop files event
182 EVT_DROP_FILES( PCB_EDIT_FRAME::OnDropFiles )
183END_EVENT_TABLE()
184
185
186PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
187 PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_EDITOR, _( "PCB Editor" ),
188 wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
190 m_exportNetlistAction( nullptr ),
191 m_findDialog( nullptr ),
192 m_inspectDrcErrorDlg( nullptr ),
193 m_inspectClearanceDlg( nullptr ),
194 m_inspectConstraintsDlg( nullptr ),
195 m_footprintDiffDlg( nullptr ),
196 m_netInspectorDlg( nullptr ),
197 m_importProperties( nullptr )
198{
199 m_maximizeByDefault = true;
200 m_showBorderAndTitleBlock = true; // true to display sheet references
201 m_SelTrackWidthBox = nullptr;
202 m_SelViaSizeBox = nullptr;
203 m_SelLayerBox = nullptr;
204 m_show_layer_manager_tools = true;
205 m_supportsAutoSave = true;
206 m_probingSchToPcb = false;
207 m_show_search = false;
208
209 // We don't know what state board was in when it was last saved, so we have to
210 // assume dirty
211 m_ZoneFillsDirty = true;
212
213 m_aboutTitle = _HKI( "KiCad PCB Editor" );
214
215 // Must be created before the menus are created.
216 if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist )
217 m_exportNetlistAction = new TOOL_ACTION( "pcbnew.EditorControl.exportNetlist",
218 AS_GLOBAL, 0, "", _( "Netlist..." ),
219 _( "Export netlist used to update schematics" ) );
220
221 // Create GAL canvas
222 auto canvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
223 GetGalDisplayOptions(),
225
226 SetCanvas( canvas );
227 SetBoard( new BOARD() );
228
229 wxIcon icon;
230 wxIconBundle icon_bundle;
231
232 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 48 ) );
233 icon_bundle.AddIcon( icon );
234 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 128 ) );
235 icon_bundle.AddIcon( icon );
236 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew, 256 ) );
237 icon_bundle.AddIcon( icon );
238 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_32 ) );
239 icon_bundle.AddIcon( icon );
240 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pcbnew_16 ) );
241 icon_bundle.AddIcon( icon );
242
243 SetIcons( icon_bundle );
244
245 // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
246 // initialize parameters in m_LayersManager
247 LoadSettings( config() );
248
249 SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ) ) );
250
251 // PCB drawings start in the upper left corner.
252 GetScreen()->m_Center = false;
253
254 setupTools();
255 setupUIConditions();
256
257 ReCreateMenuBar();
258 ReCreateHToolbar();
259 ReCreateAuxiliaryToolbar();
260 ReCreateVToolbar();
261 ReCreateOptToolbar();
262
263
264 m_propertiesPanel = new PCB_PROPERTIES_PANEL( this, this );
265
266 float proportion = GetPcbNewSettings()->m_AuiPanels.properties_splitter;
267 m_propertiesPanel->SetSplitterProportion( proportion );
268
269 m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
270
271 m_appearancePanel = new APPEARANCE_CONTROLS( this, GetCanvas() );
272 m_searchPane = new PCB_SEARCH_PANE( this );
273
274 m_auimgr.SetManagedWindow( this );
275
276 CreateInfoBar();
277
278 unsigned int auiFlags = wxAUI_MGR_DEFAULT;
279#if !defined( _WIN32 )
280 // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds
281 // of graphical glitches.
282 auiFlags |= wxAUI_MGR_LIVE_RESIZE;
283#endif
284 m_auimgr.SetFlags( auiFlags );
285
286 // Rows; layers 4 - 6
287 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( wxS( "MainToolbar" ) )
288 .Top().Layer( 6 ) );
289 m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( wxS( "AuxToolbar" ) )
290 .Top().Layer( 5 ) );
291 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxS( "MsgPanel" ) )
292 .Bottom().Layer( 6 ) );
293
294 // Columns; layers 1 - 3
295 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( wxS( "OptToolbar" ) )
296 .Left().Layer( 3 ) );
297
298 m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( wxS( "ToolsToolbar" ) )
299 .Right().Layer( 3 ) );
300
301 m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( wxS( "LayersManager" ) )
302 .Right().Layer( 4 )
303 .Caption( _( "Appearance" ) ).PaneBorder( false )
304 .MinSize( FromDIP( 180 ), -1 ).BestSize( FromDIP( 180 ), -1 ) );
305
306 m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Name( wxS( "SelectionFilter" ) )
307 .Right().Layer( 4 ).Position( 2 )
308 .Caption( _( "Selection Filter" ) ).PaneBorder( false )
309 .MinSize( FromDIP( 180 ), -1 ).BestSize( FromDIP( 180 ), -1 ) );
310
311 m_auimgr.AddPane( m_propertiesPanel, EDA_PANE().Name( PropertiesPaneName() )
312 .Left().Layer( 5 )
313 .Caption( _( "Properties" ) ).PaneBorder( false )
314 .MinSize( FromDIP( wxSize( 240, 60 ) ) ).BestSize( FromDIP( wxSize( 300, 200 ) ) ) );
315
316 // Center
317 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxS( "DrawFrame" ) )
318 .Center() );
319
320 m_auimgr.AddPane( m_searchPane, EDA_PANE().Name( SearchPaneName() )
321 .Bottom()
322 .Caption( _( "Search" ) ).PaneBorder( false )
323 .MinSize( FromDIP( wxSize ( 180, 60 ) ) ).BestSize( FromDIP( wxSize ( 180, 100 ) ) )
324 .FloatingSize( FromDIP( wxSize( 480, 200 ) ) )
325 .DestroyOnClose( false ) );
326
327 m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
328 m_auimgr.GetPane( "SelectionFilter" ).Show( m_show_layer_manager_tools );
329 m_auimgr.GetPane( PropertiesPaneName() ).Show( GetPcbNewSettings()->m_AuiPanels.show_properties );
330
331 m_auimgr.GetPane( SearchPaneName() ).Show( m_show_search );
332
333 // The selection filter doesn't need to grow in the vertical direction when docked
334 m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0;
335
336 FinishAUIInitialization();
337
338 if( PCBNEW_SETTINGS* settings = dynamic_cast<PCBNEW_SETTINGS*>( config() ) )
339 {
340 if( settings->m_AuiPanels.right_panel_width > 0 )
341 {
342 wxAuiPaneInfo& layersManager = m_auimgr.GetPane( wxS( "LayersManager" ) );
343 SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
344 }
345
346 if( settings->m_AuiPanels.properties_panel_width > 0 && m_propertiesPanel )
347 {
348 wxAuiPaneInfo& propertiesPanel = m_auimgr.GetPane( PropertiesPaneName() );
349 SetAuiPaneSize( m_auimgr, propertiesPanel,
350 settings->m_AuiPanels.properties_panel_width, -1 );
351 }
352
353 if( settings->m_AuiPanels.search_panel_height > 0
354 && ( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_TOP
355 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_BOTTOM ) )
356 {
357 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
358 searchPane.Direction( settings->m_AuiPanels.search_panel_dock_direction );
359 SetAuiPaneSize( m_auimgr, searchPane, -1, settings->m_AuiPanels.search_panel_height );
360 }
361 else if( settings->m_AuiPanels.search_panel_width > 0
362 && ( settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_LEFT
363 || settings->m_AuiPanels.search_panel_dock_direction == wxAUI_DOCK_RIGHT ) )
364 {
365 wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
366 searchPane.Direction( settings->m_AuiPanels.search_panel_dock_direction );
367 SetAuiPaneSize( m_auimgr, searchPane, settings->m_AuiPanels.search_panel_width, -1 );
368 }
369
370 m_appearancePanel->SetTabIndex( settings->m_AuiPanels.appearance_panel_tab );
371 }
372
373 GetToolManager()->PostAction( ACTIONS::zoomFitScreen );
374
375 // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
376 // to calculate the wrong zoom size. See PCB_EDIT_FRAME::onSize().
377 Bind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
378
379 // Redraw netnames (so that they fall within the current viewport) after the viewport
380 // has stopped changing. Redrawing them without the timer moves them smoothly with scrolling,
381 // making it look like the tracks are being dragged -- which we don't want.
382 m_redrawNetnamesTimer.SetOwner( this );
383 Connect( wxEVT_TIMER, wxTimerEventHandler( PCB_EDIT_FRAME::redrawNetnames ), nullptr, this );
384
385 Bind( wxEVT_IDLE,
386 [this]( wxIdleEvent& aEvent )
387 {
388 if( GetCanvas()->GetView()->GetViewport() != m_lastViewport )
389 {
390 m_lastViewport = GetCanvas()->GetView()->GetViewport();
391 m_redrawNetnamesTimer.StartOnce( 500 );
392 }
393
394 // Do not forget to pass the Idle event to other clients:
395 aEvent.Skip();
396 } );
397
398 resolveCanvasType();
399
400 setupUnits( config() );
401
402 // Ensure the DRC engine is initialized so that constraints can be resolved even before a
403 // board is loaded or saved
404 try
405 {
406 m_toolManager->GetTool<DRC_TOOL>()->GetDRCEngine()->InitEngine( wxFileName() );
407 }
408 catch( PARSE_ERROR& )
409 {
410 }
411
412 // Ensure the Python interpreter is up to date with its environment variables
413 PythonSyncEnvironmentVariables();
414 PythonSyncProjectName();
415
416 // Sync action plugins in case they changed since the last time the frame opened
417 GetToolManager()->RunAction( PCB_ACTIONS::pluginsReload );
418
419 GetCanvas()->SwitchBackend( m_canvasType );
420 ActivateGalCanvas();
421
422 // Default shutdown reason until a file is loaded
423 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New PCB file is unsaved" ) );
424
425 // disable Export STEP item if kicad2step does not exist
426 wxString strK2S = Pgm().GetExecutablePath();
427
428#ifdef __WXMAC__
429 if( strK2S.Find( wxT( "pcbnew.app" ) ) != wxNOT_FOUND )
430 {
431 // On macOS, we have standalone applications inside the main bundle, so we handle that here:
432 strK2S += wxT( "../../" );
433 }
434
435 strK2S += wxT( "Contents/MacOS/" );
436#endif
437
438 wxFileName appK2S( strK2S, wxT( "kicad2step" ) );
439
440#ifdef _WIN32
441 appK2S.SetExt( wxT( "exe" ) );
442#endif
443
444 // Ensure the window is on top
445 Raise();
446
447// if( !appK2S.FileExists() )
448 // GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
449
450 // AUI doesn't refresh properly on wxMac after changes in eb7dc6dd, so force it to
451#ifdef __WXMAC__
452 if( Kiface().IsSingle() )
453 {
454 CallAfter( [this]()
455 {
456 m_appearancePanel->OnBoardChanged();
457 } );
458 }
459#endif
460
461 // Register a call to update the toolbar sizes. It can't be done immediately because
462 // it seems to require some sizes calculated that aren't yet (at least on GTK).
463 CallAfter( [this]()
464 {
465 // Ensure the controls on the toolbars all are correctly sized
466 UpdateToolbarControlSizes();
467 } );
468
470 {
471 m_eventCounterTimer = new wxTimer( this );
472
473 Bind( wxEVT_TIMER,
474 [&]( wxTimerEvent& aEvent )
475 {
476 GetCanvas()->m_PaintEventCounter->Show();
477 GetCanvas()->m_PaintEventCounter->Reset();
478
480 static_cast<KIGFX::WX_VIEW_CONTROLS*>( GetCanvas()->GetViewControls() );
481 vc->m_MotionEventCounter->Show();
482 vc->m_MotionEventCounter->Reset();
483
484 },
485 m_eventCounterTimer->GetId() );
486
487 m_eventCounterTimer->Start( 1000 );
488 }
489
490 Bind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, &PCB_EDIT_FRAME::onCloseModelessBookReporterDialogs,
491 this );
492 Bind( EDA_EVT_CLOSE_NET_INSPECTOR_DIALOG, &PCB_EDIT_FRAME::onCloseNetInspectorDialog, this );
493 Bind( EDA_EVT_UNITS_CHANGED, &PCB_EDIT_FRAME::onUnitsChanged, this );
496 DragAcceptFiles( true );
497}
498
499
501{
503
504 if( ADVANCED_CFG::GetCfg().m_ShowEventCounters )
505 {
506 // Stop the timer during destruction early to avoid potential event race conditions (that
507 // do happen on windows)
508 m_eventCounterTimer->Stop();
509 delete m_eventCounterTimer;
510 }
511
512 // Shutdown all running tools
513 if( m_toolManager )
515
516 if( GetBoard() )
518
520 delete m_appearancePanel;
522 delete m_propertiesPanel;
523}
524
525
526void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard, bool aBuildConnectivity,
527 PROGRESS_REPORTER* aReporter )
528{
529 if( m_pcb )
531
532 PCB_BASE_EDIT_FRAME::SetBoard( aBoard, aReporter );
533
534 aBoard->SetProject( &Prj() );
535
536 if( aBuildConnectivity )
537 aBoard->BuildConnectivity();
538
539 // reload the drawing-sheet
540 SetPageSettings( aBoard->GetPageSettings() );
541}
542
543
545{
546 return m_pcb;
547}
548
549
550void PCB_EDIT_FRAME::redrawNetnames( wxTimerEvent& aEvent )
551{
552 bool needs_refresh = false;
553
554 // Don't stomp on the auto-save timer event.
555 if( aEvent.GetId() == ID_AUTO_SAVE_TIMER )
556 {
557 aEvent.Skip();
558 return;
559 }
560
561 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
562
563 if( !cfg || cfg->m_Display.m_NetNames < 2 )
564 return;
565
566 KIGFX::VIEW* view = GetCanvas()->GetView();
567 double scale = view->GetScale();
568
569 for( PCB_TRACK* track : GetBoard()->Tracks() )
570 {
571 double lod = track->ViewGetLOD( GetNetnameLayer( track->GetLayer() ), view );
572
573 if( lod < scale )
574 continue;
575
576 if( lod != track->GetCachedLOD() || scale != track->GetCachedScale() )
577 {
578 view->Update( track, KIGFX::REPAINT );
579 needs_refresh = true;
580 track->SetCachedLOD( lod );
581 track->SetCachedScale( scale );
582 }
583 }
584
585 if( needs_refresh )
586 GetCanvas()->Refresh();
587}
588
589
590void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
591{
592 PCB_BASE_FRAME::SetPageSettings( aPageSettings );
593
594 // Prepare drawing-sheet template
597 m_pcb->GetProject(),
599 &m_pcb->GetProperties() );
600
601 drawingSheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
602 drawingSheet->SetSheetPath( std::string( GetFullScreenDesc().mb_str() ) );
603
604 // A board is not like a schematic having a main page and sub sheets.
605 // So for the drawing sheet, use only the first page option to display items
606 drawingSheet->SetIsFirstPage( true );
607
608 BASE_SCREEN* screen = GetScreen();
609
610 if( screen != nullptr )
611 {
612 drawingSheet->SetPageNumber(TO_UTF8( screen->GetPageNumber() ) );
613 drawingSheet->SetSheetCount( screen->GetPageCount() );
614 }
615
616 if( BOARD* board = GetBoard() )
617 drawingSheet->SetFileName( TO_UTF8( board->GetFileName() ) );
618
619 // PCB_DRAW_PANEL_GAL takes ownership of the drawing-sheet
620 GetCanvas()->SetDrawingSheet( drawingSheet );
621}
622
623
625{
626 return GetScreen() && GetScreen()->IsContentModified();
627}
628
629
631{
632 return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
633}
634
635
637{
638 // Create the manager and dispatcher & route draw panel events to the dispatcher
641 GetCanvas()->GetViewControls(), config(), this );
642 m_actions = new PCB_ACTIONS();
644
645 // Register tools
675
676 for( TOOL_BASE* tool : m_toolManager->Tools() )
677 {
678 if( PCB_TOOL_BASE* pcbTool = dynamic_cast<PCB_TOOL_BASE*>( tool ) )
679 pcbTool->SetIsBoardEditor( true );
680 }
681
682 // Run the selection tool, it is supposed to be always active
683 m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
684}
685
686
688{
690
692 PCB_EDITOR_CONDITIONS cond( this );
693
694 auto undoCond =
695 [ this ] (const SELECTION& aSel )
696 {
698
699 if( drawingTool && drawingTool->GetDrawingMode() != DRAWING_TOOL::MODE::NONE )
700 return true;
701
703
704 if( routerTool && routerTool->RoutingInProgress() )
705 return true;
706
707 return GetUndoCommandCount() > 0;
708 };
709
710 wxASSERT( mgr );
711
712#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
713#define CHECK( x ) ACTION_CONDITIONS().Check( x )
714
716 mgr->SetConditions( ACTIONS::undo, ENABLE( undoCond ) );
718
723 mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
724 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
725 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
726
727 mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
728 mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );
737
740 { PCB_GROUP_T, PCB_GENERATOR_T } ) ) );
743
749
750 if( SCRIPTING::IsWxAvailable() )
752
753 auto enableZoneControlCondition =
754 [this] ( const SELECTION& )
755 {
758 };
759
761 ENABLE( enableZoneControlCondition )
762 .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FILLED ) ) );
764 ENABLE( enableZoneControlCondition )
765 .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE ) ) );
767 ENABLE( enableZoneControlCondition )
768 .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS ) ) );
770 ENABLE( enableZoneControlCondition )
771 .Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) ) );
772
774
775 auto constrainedDrawingModeCond =
776 [this]( const SELECTION& )
777 {
779 };
780
781 auto boardFlippedCond =
782 [this]( const SELECTION& )
783 {
784 return GetCanvas() && GetCanvas()->GetView()->IsMirroredX();
785 };
786
787 auto layerManagerCond =
788 [this] ( const SELECTION& )
789 {
790 return LayerManagerShown();
791 };
792
793 auto propertiesCond =
794 [this] ( const SELECTION& )
795 {
796 return PropertiesShown();
797 };
798
799 auto searchPaneCond =
800 [this] ( const SELECTION& )
801 {
802 return m_auimgr.GetPane( SearchPaneName() ).IsShown();
803 };
804
805 auto highContrastCond =
806 [this] ( const SELECTION& )
807 {
808 return GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
809 };
810
811 auto globalRatsnestCond =
812 [this] (const SELECTION& )
813 {
815 };
816
817 auto curvedRatsnestCond =
818 [this] (const SELECTION& )
819 {
821 };
822
823 auto netHighlightCond =
824 [this]( const SELECTION& )
825 {
827 return !settings->GetHighlightNetCodes().empty();
828 };
829
830 auto enableNetHighlightCond =
831 [this]( const SELECTION& )
832 {
834 return tool && tool->IsNetHighlightSet();
835 };
836
837 mgr->SetConditions( PCB_ACTIONS::toggleHV45Mode, CHECK( constrainedDrawingModeCond ) );
838 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) );
839 mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) );
840 mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) );
841 mgr->SetConditions( PCB_ACTIONS::showRatsnest, CHECK( globalRatsnestCond ) );
842 mgr->SetConditions( PCB_ACTIONS::ratsnestLineMode, CHECK( curvedRatsnestCond ) );
843 mgr->SetConditions( PCB_ACTIONS::toggleNetHighlight, CHECK( netHighlightCond )
844 .Enable( enableNetHighlightCond ) );
845 mgr->SetConditions( PCB_ACTIONS::showProperties, CHECK( propertiesCond ) );
846 mgr->SetConditions( PCB_ACTIONS::showSearch, CHECK( searchPaneCond ) );
847
848 auto isArcKeepCenterMode =
849 [this]( const SELECTION& )
850 {
851 return GetPcbNewSettings()->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS;
852 };
853
854 auto isArcKeepEndpointMode =
855 [this]( const SELECTION& )
856 {
857 return GetPcbNewSettings()->m_ArcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION;
858 };
859
860 mgr->SetConditions( PCB_ACTIONS::pointEditorArcKeepCenter, CHECK( isArcKeepCenterMode ) );
861 mgr->SetConditions( PCB_ACTIONS::pointEditorArcKeepEndpoint, CHECK( isArcKeepEndpointMode ) );
862
863 auto isHighlightMode =
864 [this]( const SELECTION& )
865 {
867 return tool && tool->GetRouterMode() == PNS::RM_MarkObstacles;
868 };
869
870 auto isShoveMode =
871 [this]( const SELECTION& )
872 {
874 return tool && tool->GetRouterMode() == PNS::RM_Shove;
875 };
876
877 auto isWalkaroundMode =
878 [this]( const SELECTION& )
879 {
881 return tool && tool->GetRouterMode() == PNS::RM_Walkaround;
882 };
883
884 mgr->SetConditions( PCB_ACTIONS::routerHighlightMode, CHECK( isHighlightMode ) );
885 mgr->SetConditions( PCB_ACTIONS::routerShoveMode, CHECK( isShoveMode ) );
886 mgr->SetConditions( PCB_ACTIONS::routerWalkaroundMode, CHECK( isWalkaroundMode ) );
887
888 auto haveNetCond =
889 [] ( const SELECTION& aSel )
890 {
891 for( EDA_ITEM* item : aSel )
892 {
893 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
894 {
895 if( bci->GetNetCode() > 0 )
896 return true;
897 }
898 }
899
900 return false;
901 };
902
907
918
919
922
925
926 mgr->SetConditions( PCB_ACTIONS::zoneDuplicate, ENABLE( singleZoneCond ) );
927 mgr->SetConditions( PCB_ACTIONS::drawZoneCutout, ENABLE( singleZoneCond ) );
928 mgr->SetConditions( PCB_ACTIONS::drawSimilarZone, ENABLE( singleZoneCond ) );
929 mgr->SetConditions( PCB_ACTIONS::zoneMerge, ENABLE( zoneMergeCond ) );
930
932
933#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
934
935 // These tools can be used at any time to inspect the board
940
941
942 auto isDRCIdle =
943 [this] ( const SELECTION& )
944 {
946 return !( tool && tool->IsDRCRunning() );
947 };
948
949#define CURRENT_EDIT_TOOL( action ) \
950 mgr->SetConditions( action, ACTION_CONDITIONS().Check( cond.CurrentTool( action ) ) \
951 .Enable( isDRCIdle ) )
952
953 // These tools edit the board, so they must be disabled during some operations
980
986
987#undef CURRENT_TOOL
988#undef CURRENT_EDIT_TOOL
989#undef ENABLE
990#undef CHECK
991}
992
993
994void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
995{
996 if( event.GetId() == wxID_EXIT )
997 Kiway().OnKiCadExit();
998
999 if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1000 Close( false );
1001}
1002
1003
1004void PCB_EDIT_FRAME::ResolveDRCExclusions( bool aCreateMarkers )
1005{
1006 BOARD_COMMIT commit( this );
1007
1008 for( PCB_MARKER* marker : GetBoard()->ResolveDRCExclusions( aCreateMarkers ) )
1009 {
1010 if( marker->GetMarkerType() == MARKER_BASE::MARKER_DRAWING_SHEET )
1011 marker->GetRCItem()->SetItems( GetCanvas()->GetDrawingSheet() );
1012
1013 commit.Add( marker );
1014 }
1015
1016 commit.Push( wxEmptyString, SKIP_UNDO | SKIP_SET_DIRTY );
1017
1018 for( PCB_MARKER* marker : GetBoard()->Markers() )
1019 {
1020 if( marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
1021 GetCanvas()->GetView()->Update( marker );
1022 }
1023
1025}
1026
1027
1028bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
1029{
1030 // Shutdown blocks must be determined and vetoed as early as possible
1031 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
1032 && IsContentModified() )
1033 {
1034 return false;
1035 }
1036
1038
1039 if( zoneFillerTool->IsBusy() )
1040 {
1041 wxBell();
1042
1043 if( wxWindow* reporter = dynamic_cast<wxWindow*>( zoneFillerTool->GetProgressReporter() ) )
1044 reporter->ShowWithEffect( wxSHOW_EFFECT_EXPAND );
1045
1046 return false;
1047 }
1048
1049 if( Kiface().IsSingle() )
1050 {
1051 auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
1052
1053 if( fpEditor && !fpEditor->Close() ) // Can close footprint editor?
1054 return false;
1055
1056 auto* fpViewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_VIEWER, false );
1057
1058 if( fpViewer && !fpViewer->Close() ) // Can close footprint viewer?
1059 return false;
1060
1061 // FOOTPRINT_CHOOSER_FRAME is always modal so this shouldn't come up, but better safe than
1062 // sorry.
1063 auto* chooser = (FOOTPRINT_CHOOSER_FRAME*) Kiway().Player( FRAME_FOOTPRINT_CHOOSER, false );
1064
1065 if( chooser && !chooser->Close() ) // Can close footprint chooser?
1066 return false;
1067 }
1068 else
1069 {
1070 auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
1071
1072 if( fpEditor && fpEditor->IsCurrentFPFromBoard() )
1073 {
1074 if( !fpEditor->CanCloseFPFromBoard( true ) )
1075 return false;
1076 }
1077 }
1078
1079 if( IsContentModified() )
1080 {
1081 wxFileName fileName = GetBoard()->GetFileName();
1082 wxString msg = _( "Save changes to '%s' before closing?" );
1083
1084 if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
1085 [&]() -> bool
1086 {
1087 return Files_io_from_id( ID_SAVE_BOARD );
1088 } ) )
1089 {
1090 return false;
1091 }
1092 }
1093
1094 return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
1095}
1096
1097
1099{
1100 // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
1101 // when closing this frame if a footprint was selected, and the footprint editor called
1102 // to edit this footprint, and when closing pcbnew if this footprint is still selected
1103 // See https://bugs.launchpad.net/kicad/+bug/1655858
1104 // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
1105 // avoid the crash (JPC)
1106 GetCanvas()->SetEvtHandlerEnabled( false );
1107
1109
1110 // Clean up mode-less dialogs.
1111 Unbind( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER,
1113 Unbind( EDA_EVT_CLOSE_NET_INSPECTOR_DIALOG, &PCB_EDIT_FRAME::onCloseNetInspectorDialog, this );
1114 Unbind( EDA_EVT_UNITS_CHANGED, &PCB_EDIT_FRAME::onUnitsChanged, this );
1115
1116 wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_DRC_WINDOW_NAME );
1117
1118 if( open_dlg )
1119 open_dlg->Close( true );
1120
1121 if( m_findDialog )
1122 {
1123 m_findDialog->Destroy();
1124 m_findDialog = nullptr;
1125 }
1126
1128 {
1129 m_inspectDrcErrorDlg->Destroy();
1130 m_inspectDrcErrorDlg = nullptr;
1131 }
1132
1134 {
1135 m_inspectClearanceDlg->Destroy();
1136 m_inspectClearanceDlg = nullptr;
1137 }
1138
1140 {
1141 m_inspectConstraintsDlg->Destroy();
1142 m_inspectConstraintsDlg = nullptr;
1143 }
1144
1145 if( m_footprintDiffDlg )
1146 {
1147 m_footprintDiffDlg->Destroy();
1148 m_footprintDiffDlg = nullptr;
1149 }
1150
1151 if( m_netInspectorDlg )
1152 {
1154 m_netInspectorDlg->Destroy();
1155 m_netInspectorDlg = nullptr;
1156 }
1157
1158 // Delete the auto save file if it exists.
1159 wxFileName fn = GetBoard()->GetFileName();
1160
1161 // Auto save file name is the normal file name prefixed with 'GetAutoSaveFilePrefix()'.
1162 fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
1163
1164 // When the auto save feature does not have write access to the board file path, it falls
1165 // back to a platform specific user temporary file path.
1166 if( !fn.IsOk() || !fn.IsDirWritable() )
1167 fn.SetPath( wxFileName::GetTempDir() );
1168
1169 wxLogTrace( traceAutoSave, wxT( "Deleting auto save file <" ) + fn.GetFullPath() + wxT( ">" ) );
1170
1171 // Remove the auto save file on a normal close of Pcbnew.
1172 if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
1173 {
1174 wxLogTrace( traceAutoSave, wxT( "The auto save file could not be removed!" ) );
1175 }
1176
1177 // Make sure local settings are persisted
1179
1180 // Do not show the layer manager during closing to avoid flicker
1181 // on some platforms (Windows) that generate useless redraw of items in
1182 // the Layer Manager
1184 {
1185 m_auimgr.GetPane( wxS( "LayersManager" ) ).Show( false );
1186 m_auimgr.GetPane( wxS( "TabbedPanel" ) ).Show( false );
1187 }
1188
1189 // Unlink the old project if needed
1191
1192 // Delete board structs and undo/redo lists, to avoid crash on exit
1193 // when deleting some structs (mainly in undo/redo lists) too late
1194 Clear_Pcb( false, true );
1195
1196 // do not show the window because ScreenPcb will be deleted and we do not
1197 // want any paint event
1198 Show( false );
1199
1201}
1202
1203
1205{
1208 GetCanvas()->Refresh();
1209}
1210
1211
1212void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage )
1213{
1214 std::unique_lock<std::mutex> dialogLock( DIALOG_BOARD_SETUP::g_Mutex, std::try_to_lock );
1215
1216 // One DIALOG_BOARD_SETUP dialog at a time.
1217 if( !dialogLock.owns_lock() )
1218 return;
1219
1220 // Make sure everything's up-to-date
1222
1223 DIALOG_BOARD_SETUP dlg( this );
1224
1225 if( !aInitialPage.IsEmpty() )
1226 dlg.SetInitialPage( aInitialPage, wxEmptyString );
1227
1228 // QuasiModal required for Scintilla auto-complete
1229 if( dlg.ShowQuasiModal() == wxID_OK )
1230 {
1232 // We don't know if anything was modified, so err on the side of requiring a save
1233 OnModify();
1234
1235 Kiway().CommonSettingsChanged( false, true );
1236
1239
1240 PCBNEW_SETTINGS* settings = GetPcbNewSettings();
1241 static LSET maskAndPasteLayers = LSET( 4, F_Mask, F_Paste, B_Mask, B_Paste );
1242
1244 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1245 {
1246 BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aItem );
1247 int flags = 0;
1248
1249 if( !item )
1250 return flags;
1251
1252 if( item->Type() == PCB_VIA_T || item->Type() == PCB_PAD_T )
1253 {
1254 // Note: KIGFX::REPAINT isn't enough for things that go from invisible
1255 // to visible as they won't be found in the view layer's itemset for
1256 // re-painting.
1257 if( ( GetBoard()->GetVisibleLayers() & maskAndPasteLayers ).any() )
1258 flags |= KIGFX::ALL;
1259 }
1260
1261 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T || item->Type() == PCB_VIA_T )
1262 {
1264 flags |= KIGFX::REPAINT;
1265 }
1266
1267 if( item->Type() == PCB_PAD_T )
1268 {
1269 if( settings->m_Display.m_PadClearance )
1270 flags |= KIGFX::REPAINT;
1271 }
1272
1273 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
1274
1275 if( text && text->HasTextVars() )
1276 {
1277 text->ClearRenderCache();
1278 text->ClearBoundingBoxCache();
1280 }
1281
1282 return flags;
1283 } );
1284
1285 GetCanvas()->Refresh();
1286
1290
1291 //this event causes the routing tool to reload its design rules information
1293 toolEvent.SetHasPosition( false );
1294 m_toolManager->ProcessEvent( toolEvent );
1295 }
1296
1297 GetCanvas()->SetFocus();
1298}
1299
1300
1302{
1304
1305 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
1306 wxASSERT( cfg );
1307
1308 if( cfg )
1309 {
1312 }
1313}
1314
1315
1317{
1319
1320 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
1321 wxASSERT( cfg );
1322
1323 if( cfg )
1324 {
1326
1327 if( m_propertiesPanel )
1328 {
1329 cfg->m_AuiPanels.show_properties = m_propertiesPanel->IsShownOnScreen();
1332 }
1333
1334 // ensure m_show_search is up to date (the pane can be closed)
1335 wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
1336 m_show_search = searchPaneInfo.IsShown();
1338 cfg->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
1339 cfg->m_AuiPanels.search_panel_width = m_searchPane->GetSize().x;
1340 cfg->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
1341
1342 if( m_appearancePanel )
1343 {
1348 }
1349 }
1350}
1351
1352
1354{
1355 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( config() );
1356
1357 return cfg ? cfg->m_RotationAngle : ANGLE_90;
1358}
1359
1360
1362{
1364}
1365
1366
1368{
1369
1370 GetColorSettings()->SetColor( LAYER_GRID, aColor );
1371 GetCanvas()->GetGAL()->SetGridColor( aColor );
1372}
1373
1374
1376{
1377 PCB_LAYER_ID oldLayer = GetActiveLayer();
1378
1379 if( oldLayer == aLayer )
1380 return;
1381
1383
1385
1386 m_toolManager->PostAction( PCB_ACTIONS::layerChanged ); // notify other tools
1387 GetCanvas()->SetFocus(); // allow capture of hotkeys
1388 GetCanvas()->SetHighContrastLayer( aLayer );
1389
1391 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
1392 {
1393 BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aItem );
1394
1395 if( !item )
1396 return 0;
1397
1398 // Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible
1399 // as they won't be found in the view layer's itemset for re-painting.
1400 if( GetDisplayOptions().m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN )
1401 {
1402 if( item->IsOnLayer( oldLayer ) || item->IsOnLayer( aLayer ) )
1403 return KIGFX::ALL;
1404 }
1405
1406 if( item->Type() == PCB_VIA_T )
1407 {
1408 PCB_VIA* via = static_cast<PCB_VIA*>( item );
1409
1410 // Vias on a restricted layer set must be redrawn when the active layer
1411 // is changed
1412 if( via->GetViaType() == VIATYPE::BLIND_BURIED
1413 || via->GetViaType() == VIATYPE::MICROVIA )
1414 {
1415 return KIGFX::REPAINT;
1416 }
1417
1418 if( via->GetRemoveUnconnected() )
1419 return KIGFX::ALL;
1420
1421 // Clearances could be layer-dependent so redraw them when the active layer
1422 // is changed
1424 return KIGFX::REPAINT;
1425 }
1426 else if( item->Type() == PCB_PAD_T )
1427 {
1428 PAD* pad = static_cast<PAD*>( item );
1429
1430 if( pad->GetRemoveUnconnected() )
1431 return KIGFX::ALL;
1432
1433 // Clearances could be layer-dependent so redraw them when the active layer
1434 // is changed
1436 {
1437 // Round-corner rects are expensive to draw, but are mostly found on
1438 // SMD pads which only need redrawing on an active-to-not-active
1439 // switch.
1440 if( pad->GetAttribute() == PAD_ATTRIB::SMD )
1441 {
1442 if( ( oldLayer == F_Cu || aLayer == F_Cu ) && pad->IsOnLayer( F_Cu ) )
1443 return KIGFX::REPAINT;
1444
1445 if( ( oldLayer == B_Cu || aLayer == B_Cu ) && pad->IsOnLayer( B_Cu ) )
1446 return KIGFX::REPAINT;
1447 }
1448 else if( pad->IsOnLayer( oldLayer ) || pad->IsOnLayer( aLayer ) )
1449 {
1450 return KIGFX::REPAINT;
1451 }
1452 }
1453 }
1454 else if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
1455 {
1456 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
1457
1458 // Clearances could be layer-dependent so redraw them when the active layer
1459 // is changed
1461 {
1462 // Tracks aren't particularly expensive to draw, but it's an easy check.
1463 if( track->IsOnLayer( oldLayer ) || track->IsOnLayer( aLayer ) )
1464 return KIGFX::REPAINT;
1465 }
1466 }
1467
1468 return 0;
1469 } );
1470
1471 GetCanvas()->Refresh();
1472}
1473
1474
1476{
1478
1479 layerEnum.Choices().Clear();
1480 layerEnum.Undefined( UNDEFINED_LAYER );
1481
1482 for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
1483 {
1484 // Canonical name
1485 layerEnum.Map( *seq, LSET::Name( *seq ) );
1486
1487 // User name
1488 layerEnum.Map( *seq, GetBoard()->GetLayerName( *seq ) );
1489 }
1490
1491 DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
1492
1493 try
1494 {
1495 drcTool->GetDRCEngine()->InitEngine( GetDesignRulesPath() );
1496 }
1497 catch( PARSE_ERROR& )
1498 {
1499 // Not sure this is the best place to tell the user their rules are buggy, so
1500 // we'll stay quiet for now. Feel free to revisit this decision....
1501 }
1502
1503 UpdateTitle();
1504
1505 wxFileName fn = GetBoard()->GetFileName();
1506
1507 // Display a warning that the file is read only
1508 if( fn.FileExists() && !fn.IsFileWritable() )
1509 {
1512 m_infoBar->ShowMessage( _( "Board file is read only." ),
1514 }
1515
1517
1518 // Sync layer and item visibility
1520
1521 SetElementVisibility( LAYER_RATSNEST, GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
1522
1524
1525 // Apply saved display state to the appearance panel after it has been set up
1526 PROJECT_LOCAL_SETTINGS& localSettings = Prj().GetLocalSettings();
1527
1529
1530 if( GetBoard()->GetDesignSettings().IsLayerEnabled( localSettings.m_ActiveLayer ) )
1531 SetActiveLayer( localSettings.m_ActiveLayer );
1532
1533 // Updates any auto dimensions and the auxiliary toolbar tracks/via sizes
1535
1536 // Display the loaded board:
1537 Zoom_Automatique( false );
1538
1539 // Invalidate painting as loading the DRC engine will cause clearances to become valid
1541
1542 Refresh();
1543
1544 SetMsgPanel( GetBoard() );
1545 SetStatusText( wxEmptyString );
1546
1547 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "PCB file changes are unsaved" ) );
1548}
1549
1550
1552{
1554}
1555
1556
1558{
1559 return GetBoard()->IsElementVisible( aElement );
1560}
1561
1562
1564{
1565 // Force the RATSNEST visible
1566 if( aElement == LAYER_RATSNEST )
1567 GetCanvas()->GetView()->SetLayerVisible( aElement, true );
1568 else
1569 GetCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
1570
1571 GetBoard()->SetElementVisibility( aElement, aNewState );
1572}
1573
1574
1576{
1577 // call my base class
1579
1580 m_auimgr.GetPane( m_appearancePanel ).Caption( _( "Appearance" ) );
1581 m_auimgr.GetPane( m_selectionFilterPanel ).Caption( _( "Selection Filter" ) );
1582 m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
1583 m_auimgr.Update();
1584
1585 UpdateTitle();
1586}
1587
1588
1590{
1592
1593 if( project.m_PcbLastPath[ aType ].IsEmpty() )
1594 return wxEmptyString;
1595
1596 wxFileName absoluteFileName = project.m_PcbLastPath[ aType ];
1597 wxFileName pcbFileName = GetBoard()->GetFileName();
1598
1599 absoluteFileName.MakeAbsolute( pcbFileName.GetPath() );
1600 return absoluteFileName.GetFullPath();
1601}
1602
1603
1604void PCB_EDIT_FRAME::SetLastPath( LAST_PATH_TYPE aType, const wxString& aLastPath )
1605{
1607
1608 wxFileName relativeFileName = aLastPath;
1609 wxFileName pcbFileName = GetBoard()->GetFileName();
1610
1611 relativeFileName.MakeRelativeTo( pcbFileName.GetPath() );
1612
1613 if( relativeFileName.GetFullPath() != project.m_PcbLastPath[ aType ] )
1614 {
1615 project.m_PcbLastPath[ aType ] = relativeFileName.GetFullPath();
1616 OnModify();
1617 }
1618}
1619
1620
1622{
1624
1625 Update3DView( true, GetPcbNewSettings()->m_Display.m_Live3DRefresh );
1626
1627 if( !GetTitle().StartsWith( wxT( "*" ) ) )
1628 UpdateTitle();
1629
1630 m_ZoneFillsDirty = true;
1631}
1632
1633
1635{
1636 Update3DView( true, true );
1637}
1638
1639
1640void PCB_EDIT_FRAME::ExportSVG( wxCommandEvent& event )
1641{
1642 InvokeExportSVG( this, GetBoard() );
1643}
1644
1645
1647{
1648 wxFileName fn = GetBoard()->GetFileName();
1649 bool readOnly = false;
1650 bool unsaved = false;
1651
1652 if( fn.IsOk() && fn.FileExists() )
1653 readOnly = !fn.IsFileWritable();
1654 else
1655 unsaved = true;
1656
1657 wxString title;
1658
1659 if( IsContentModified() )
1660 title = wxT( "*" );
1661
1662 title += fn.GetName();
1663
1664 if( readOnly )
1665 title += wxS( " " ) + _( "[Read Only]" );
1666
1667 if( unsaved )
1668 title += wxS( " " ) + _( "[Unsaved]" );
1669
1670 title += wxT( " \u2014 " ) + _( "PCB Editor" );
1671
1672 SetTitle( title );
1673}
1674
1675
1677{
1678 // Update the layer manager and other widgets from the board setup
1679 // (layer and items visibility, colors ...)
1680
1681 // Rebuild list of nets (full ratsnest rebuild)
1683
1684 // Update info shown by the horizontal toolbars
1686
1687 LSET activeLayers = GetBoard()->GetEnabledLayers();
1688
1689 if( !activeLayers.test( GetActiveLayer() ) )
1690 SetActiveLayer( activeLayers.Seq().front() );
1691
1693
1695
1696 layerEnum.Choices().Clear();
1697 layerEnum.Undefined( UNDEFINED_LAYER );
1698
1699 for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
1700 {
1701 // Canonical name
1702 layerEnum.Map( *seq, LSET::Name( *seq ) );
1703
1704 // User name
1705 layerEnum.Map( *seq, GetBoard()->GetLayerName( *seq ) );
1706 }
1707
1708 // Sync visibility with canvas
1709 for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
1710 GetCanvas()->GetView()->SetLayerVisible( layer, GetBoard()->IsLayerVisible( layer ) );
1711
1712 // Stackup and/or color theme may have changed
1714}
1715
1716
1718{
1719 // switches currently used canvas (Cairo / OpenGL).
1720 PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
1721}
1722
1723
1725{
1726 if( !m_findDialog )
1727 {
1728 m_findDialog = new DIALOG_FIND( this );
1731 }
1732
1733 wxString findString;
1734
1735 PCB_SELECTION& selection = m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1736
1737 if( selection.Size() == 1 )
1738 {
1739 EDA_ITEM* front = selection.Front();
1740
1741 switch( front->Type() )
1742 {
1743 case PCB_FOOTPRINT_T:
1744 findString = UnescapeString( static_cast<FOOTPRINT*>( front )->GetValue() );
1745 break;
1746
1747 case PCB_FIELD_T:
1748 case PCB_TEXT_T:
1749 findString = UnescapeString( static_cast<PCB_TEXT*>( front )->GetText() );
1750
1751 if( findString.Contains( wxT( "\n" ) ) )
1752 findString = findString.Before( '\n' );
1753
1754 break;
1755
1756 default:
1757 break;
1758 }
1759 }
1760
1761 m_findDialog->Preload( findString );
1762
1763 m_findDialog->Show( true );
1764}
1765
1766
1767void PCB_EDIT_FRAME::FindNext( bool reverse )
1768{
1769 if( !m_findDialog )
1771
1772 m_findDialog->FindNext( reverse );
1773}
1774
1775
1777{
1778 PCB_PLOT_PARAMS plotSettings = GetPlotSettings();
1779
1780 switch( aID )
1781 {
1782 case ID_GEN_PLOT_GERBER:
1783 plotSettings.SetFormat( PLOT_FORMAT::GERBER );
1784 break;
1785 case ID_GEN_PLOT_DXF:
1786 plotSettings.SetFormat( PLOT_FORMAT::DXF );
1787 break;
1788 case ID_GEN_PLOT_HPGL:
1789 plotSettings.SetFormat( PLOT_FORMAT::HPGL );
1790 break;
1791 case ID_GEN_PLOT_PDF:
1792 plotSettings.SetFormat( PLOT_FORMAT::PDF );
1793 break;
1794 case ID_GEN_PLOT_PS:
1795 plotSettings.SetFormat( PLOT_FORMAT::POST );
1796 break;
1797 case ID_GEN_PLOT:
1798 /* keep the previous setup */
1799 break;
1800 default:
1801 wxFAIL_MSG( wxT( "ToPlotter(): unexpected plot type" ) ); break;
1802 break;
1803 }
1804
1805 SetPlotSettings( plotSettings );
1806
1807 DIALOG_PLOT dlg( this );
1808 dlg.ShowQuasiModal( );
1809}
1810
1811
1813{
1814 if( Kiface().IsSingle() )
1815 return 0;
1816
1817 // Update PCB requires a netlist. Therefore the schematic editor must be running
1818 // If this is not the case, open the schematic editor
1819 KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
1820
1821 // If Kiway() cannot create the eeschema frame, it shows a error message, and
1822 // frame is null
1823 if( !frame )
1824 return -1;
1825
1826 if( !frame->IsShownOnScreen() )
1827 {
1828 wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
1830
1831 // Maybe the file hasn't been converted to the new s-expression file format so
1832 // see if the legacy schematic file is still in play.
1833 if( !fn.FileExists() )
1834 {
1836
1837 if( !fn.FileExists() )
1838 {
1839 DisplayError( this, _( "The schematic for this board cannot be found." ) );
1840 return -2;
1841 }
1842 }
1843
1844 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
1845
1846 // we show the schematic editor frame, because do not show is seen as
1847 // a not yet opened schematic by Kicad manager, which is not the case
1848 frame->Show( true );
1849
1850 // bring ourselves back to the front
1851 Raise();
1852 }
1853
1854 return 1; //Success!
1855}
1856
1857
1859 const wxString& aAnnotateMessage )
1860{
1861 int standalone = TestStandalone();
1862
1863 if( standalone == 0 )
1864 {
1865 DisplayErrorMessage( this, _( "Cannot update the PCB because PCB editor is opened in "
1866 "stand-alone mode. In order to create or update PCBs from "
1867 "schematics, you must launch the KiCad project manager and "
1868 "create a project." ) );
1869 return false; // Not in standalone mode
1870 }
1871
1872 if( standalone < 0 ) // Problem with Eeschema or the schematic
1873 return false;
1874
1875 Raise(); // Show
1876
1877 std::string payload( aAnnotateMessage );
1878
1879 Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
1880
1881 if( payload == aAnnotateMessage )
1882 {
1883 Raise();
1884 DisplayErrorMessage( this, aAnnotateMessage );
1885 return false;
1886 }
1887
1888 try
1889 {
1890 auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
1891 KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
1892 netlistReader.LoadNetlist();
1893 }
1894 catch( const IO_ERROR& e )
1895 {
1896 Raise();
1897
1898 // Do not translate extra_info strings. These are for developers
1899 wxString extra_info = e.Problem() + wxT( " : " ) + e.What() + wxT( " at " ) + e.Where();
1900
1901 DisplayErrorMessage( this, _( "Received an error while reading netlist. Please "
1902 "report this issue to the KiCad team using the menu "
1903 "Help->Report Bug."), extra_info );
1904 return false;
1905 }
1906
1907 return true;
1908}
1909
1910
1912{
1913 wxString msg;
1914 wxFileName schematic( Prj().GetProjectPath(), Prj().GetProjectName(),
1916
1917 if( !schematic.FileExists() )
1918 {
1919 wxFileName legacySchematic( Prj().GetProjectPath(), Prj().GetProjectName(),
1921
1922 if( legacySchematic.FileExists() )
1923 {
1924 schematic = legacySchematic;
1925 }
1926 else
1927 {
1928 msg.Printf( _( "Schematic file '%s' not found." ), schematic.GetFullPath() );
1929 DisplayErrorMessage( this, msg );
1930 return;
1931 }
1932 }
1933
1934 if( Kiface().IsSingle() )
1935 {
1936 ExecuteFile( EESCHEMA_EXE, schematic.GetFullPath() );
1937 }
1938 else
1939 {
1940 KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, false );
1941
1942 // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
1943 // Kiway.Player( FRAME_SCH, true )
1944 // therefore, the schematic editor is sometimes running, but the schematic project
1945 // is not loaded, if the library editor was called, and the dialog field editor was used.
1946 // On Linux, it happens the first time the schematic editor is launched, if
1947 // library editor was running, and the dialog field editor was open
1948 // On Windows, it happens always after the library editor was called,
1949 // and the dialog field editor was used
1950 if( !frame )
1951 {
1952 try
1953 {
1954 frame = Kiway().Player( FRAME_SCH, true );
1955 }
1956 catch( const IO_ERROR& err )
1957 {
1958 DisplayErrorMessage( this, _( "Eeschema failed to load." ) + wxS( "\n" ) + err.What() );
1959 return;
1960 }
1961 }
1962
1963 // If Kiway() cannot create the eeschema frame, it shows a error message, and
1964 // frame is null
1965 if( !frame )
1966 return;
1967
1968 if( !frame->IsShownOnScreen() ) // the frame exists, (created by the dialog field editor)
1969 // but no project loaded.
1970 {
1971 frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFullPath() ) );
1972 frame->Show( true );
1973 }
1974
1975 // On Windows, Raise() does not bring the window on screen, when iconized or not shown
1976 // On Linux, Raise() brings the window on screen, but this code works fine
1977 if( frame->IsIconized() )
1978 {
1979 frame->Iconize( false );
1980
1981 // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
1982 // to show the frame at its normal size: Maximize should be called.
1983 frame->Maximize( false );
1984 }
1985
1986 frame->Raise();
1987 }
1988}
1989
1990
1992{
1993 const ENV_VAR_MAP& vars = Pgm().GetLocalEnvVariables();
1994
1995 // Set the environment variables for python scripts
1996 // note: the string will be encoded UTF8 for python env
1997 for( const std::pair<const wxString, ENV_VAR_ITEM>& var : vars )
1998 UpdatePythonEnvVar( var.first, var.second.GetValue() );
1999
2000 // Because the env vars can be modified by the python scripts (rewritten in UTF8),
2001 // regenerate them (in Unicode) for our normal environment
2002 for( const std::pair<const wxString, ENV_VAR_ITEM>& var : vars )
2003 wxSetEnv( var.first, var.second.GetValue() );
2004}
2005
2006
2008{
2009 wxString evValue;
2010 wxGetEnv( PROJECT_VAR_NAME, &evValue );
2011 UpdatePythonEnvVar( wxString( PROJECT_VAR_NAME ).ToStdString(), evValue );
2012
2013 // Because PROJECT_VAR_NAME can be modified by the python scripts (rewritten in UTF8),
2014 // regenerate it (in Unicode) for our normal environment
2015 wxSetEnv( PROJECT_VAR_NAME, evValue );
2016}
2017
2018
2020{
2021 if( aFootprint == nullptr )
2022 return;
2023
2025
2026 /*
2027 * Make sure dlg is destroyed before GetCanvas->Refresh is called
2028 * later or the refresh will try to modify its properties since
2029 * they share a GL context.
2030 */
2031 {
2032 DIALOG_FOOTPRINT_PROPERTIES dlg( this, aFootprint );
2033
2034 dlg.ShowModal();
2035 retvalue = dlg.GetReturnValue();
2036 }
2037
2038 /*
2039 * retvalue =
2040 * FP_PROPS_UPDATE_FP to show Update Footprints dialog
2041 * FP_PROPS_CHANGE_FP to show Change Footprints dialog
2042 * FP_PROPS_OK for normal edit
2043 * FP_PROPS_CANCEL if aborted
2044 * FP_PROPS_EDIT_BOARD_FP to load board footprint into Footprint Editor
2045 * FP_PROPS_EDIT_LIBRARY_FP to load library footprint into Footprint Editor
2046 */
2047
2049 {
2050 // If something edited, push a refresh request
2051 GetCanvas()->Refresh();
2052 }
2054 {
2056
2057 editor->LoadFootprintFromBoard( aFootprint );
2058
2059 editor->Show( true );
2060 editor->Raise(); // Iconize( false );
2061 }
2063 {
2065
2066 editor->LoadFootprintFromLibrary( aFootprint->GetFPID() );
2067
2068 editor->Show( true );
2069 editor->Raise(); // Iconize( false );
2070 }
2072 {
2073 ShowExchangeFootprintsDialog( aFootprint, true, true );
2074 }
2076 {
2077 ShowExchangeFootprintsDialog( aFootprint, false, true );
2078 }
2079}
2080
2081
2083 bool aSelectedMode )
2084{
2085 DIALOG_EXCHANGE_FOOTPRINTS dialog( this, aFootprint, aUpdateMode, aSelectedMode );
2086
2087 return dialog.ShowQuasiModal();
2088}
2089
2090
2102static void processTextItem( const PCB_TEXT& aSrc, PCB_TEXT& aDest,
2103 bool aResetText, bool aResetTextLayers, bool aResetTextEffects,
2104 bool* aUpdated )
2105{
2106 if( aResetText )
2107 *aUpdated |= aSrc.GetText() != aDest.GetText();
2108 else
2109 aDest.SetText( aSrc.GetText() );
2110
2111 if( aResetTextLayers )
2112 {
2113 *aUpdated |= aSrc.GetLayer() != aDest.GetLayer();
2114 *aUpdated |= aSrc.IsVisible() != aDest.IsVisible();
2115 }
2116 else
2117 {
2118 aDest.SetLayer( aSrc.GetLayer() );
2119 aDest.SetVisible( aSrc.IsVisible() );
2120 }
2121
2122 if( aResetTextEffects )
2123 {
2124 *aUpdated |= aSrc.GetHorizJustify() != aDest.GetHorizJustify();
2125 *aUpdated |= aSrc.GetVertJustify() != aDest.GetVertJustify();
2126 *aUpdated |= aSrc.GetTextSize() != aDest.GetTextSize();
2127 *aUpdated |= aSrc.GetTextThickness() != aDest.GetTextThickness();
2128 *aUpdated |= aSrc.GetTextAngle() != aDest.GetTextAngle();
2129 *aUpdated |= aSrc.GetFPRelativePosition() != aDest.GetFPRelativePosition();
2130 }
2131 else
2132 {
2133 // Careful: the visible bit and position are also set by SetAttributes()
2134 bool visible = aDest.IsVisible();
2135 aDest.SetAttributes( aSrc );
2136 aDest.SetVisible( visible );
2138 }
2139
2140 aDest.SetLocked( aSrc.IsLocked() );
2141}
2142
2143
2144static PCB_TEXT* getMatchingTextItem( PCB_TEXT* aRefItem, FOOTPRINT* aFootprint )
2145{
2146 std::vector<PCB_TEXT*> candidates;
2147
2148 for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
2149 {
2150 PCB_TEXT* candidate = dynamic_cast<PCB_TEXT*>( item );
2151
2152 if( candidate && candidate->GetText() == aRefItem->GetText() )
2153 candidates.push_back( candidate );
2154 }
2155
2156 if( candidates.size() == 0 )
2157 return nullptr;
2158
2159 if( candidates.size() == 1 )
2160 return candidates[0];
2161
2162 // Try refining the match by layer
2163 std::vector<PCB_TEXT*> candidatesOnSameLayer;
2164
2165 for( PCB_TEXT* candidate : candidates )
2166 {
2167 if( candidate->GetLayer() == aRefItem->GetLayer() )
2168 candidatesOnSameLayer.push_back( candidate );
2169 }
2170
2171 if( candidatesOnSameLayer.size() == 1 )
2172 return candidatesOnSameLayer[0];
2173
2174 // Last ditch effort: refine by position
2175 std::vector<PCB_TEXT*> candidatesAtSamePos;
2176
2177 for( PCB_TEXT* candidate : candidatesOnSameLayer.size() ? candidatesOnSameLayer : candidates )
2178 {
2179 if( candidate->GetFPRelativePosition() == aRefItem->GetFPRelativePosition() )
2180 candidatesAtSamePos.push_back( candidate );
2181 }
2182
2183 if( candidatesAtSamePos.size() > 0 )
2184 return candidatesAtSamePos[0];
2185 else if( candidatesOnSameLayer.size() > 0 )
2186 return candidatesOnSameLayer[0];
2187 else
2188 return candidates[0];
2189}
2190
2191
2193 BOARD_COMMIT& aCommit, bool deleteExtraTexts,
2194 bool resetTextLayers, bool resetTextEffects,
2195 bool resetFabricationAttrs, bool reset3DModels,
2196 bool* aUpdated )
2197{
2198 PCB_GROUP* parentGroup = aExisting->GetParentGroup();
2199 bool dummyBool = false;
2200
2201 if( !aUpdated )
2202 aUpdated = &dummyBool;
2203
2204 if( parentGroup )
2205 {
2206 parentGroup->RemoveItem( aExisting );
2207 parentGroup->AddItem( aNew );
2208 }
2209
2210 aNew->SetParent( GetBoard() );
2211
2212 PlaceFootprint( aNew, false );
2213
2214 // PlaceFootprint will move the footprint to the cursor position, which we don't want. Copy
2215 // the original position across.
2216 aNew->SetPosition( aExisting->GetPosition() );
2217
2218 if( aNew->GetLayer() != aExisting->GetLayer() )
2219 aNew->Flip( aNew->GetPosition(), GetPcbNewSettings()->m_FlipLeftRight );
2220
2221 if( aNew->GetOrientation() != aExisting->GetOrientation() )
2222 aNew->SetOrientation( aExisting->GetOrientation() );
2223
2224 aNew->SetLocked( aExisting->IsLocked() );
2225
2226 // Now transfer the net info from "old" pads to the new footprint
2227 for( PAD* pad : aNew->Pads() )
2228 {
2229 PAD* pad_model = nullptr;
2230
2231 // Pads with no copper are never connected to a net
2232 if( !pad->IsOnCopperLayer() )
2233 {
2234 pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
2235 continue;
2236 }
2237
2238 // Pads with no numbers are never connected to a net
2239 if( pad->GetNumber().IsEmpty() )
2240 {
2241 pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
2242 continue;
2243 }
2244
2245 // Search for a similar pad on a copper layer, to reuse net info
2246 PAD* last_pad = nullptr;
2247
2248 while( true )
2249 {
2250 pad_model = aExisting->FindPadByNumber( pad->GetNumber(), last_pad );
2251
2252 if( !pad_model )
2253 break;
2254
2255 if( pad_model->IsOnCopperLayer() ) // a candidate is found
2256 break;
2257
2258 last_pad = pad_model;
2259 }
2260
2261 if( pad_model )
2262 {
2263 pad->SetLocalRatsnestVisible( pad_model->GetLocalRatsnestVisible() );
2264 pad->SetPinFunction( pad_model->GetPinFunction() );
2265 pad->SetPinType( pad_model->GetPinType() );
2266 }
2267
2268 pad->SetNetCode( pad_model ? pad_model->GetNetCode() : NETINFO_LIST::UNCONNECTED );
2269 }
2270
2271 for( BOARD_ITEM* item : aExisting->GraphicalItems() )
2272 {
2273 PCB_TEXT* srcItem = dynamic_cast<PCB_TEXT*>( item );
2274
2275 if( srcItem )
2276 {
2277 // Dimensions have PCB_TEXT base but are not treated like texts in the updater
2278 if( dynamic_cast<PCB_DIMENSION_BASE*>( srcItem ) )
2279 continue;
2280
2281 PCB_TEXT* destItem = getMatchingTextItem( srcItem, aNew );
2282
2283 if( destItem )
2284 {
2285 processTextItem( *srcItem, *destItem, false, resetTextLayers, resetTextEffects,
2286 aUpdated );
2287 }
2288 else if( !deleteExtraTexts )
2289 {
2290 aNew->Add( static_cast<BOARD_ITEM*>( srcItem->Clone() ) );
2291 }
2292 }
2293 }
2294
2295 // Copy reference. The initial text is always used, never resetted
2296 processTextItem( aExisting->Reference(), aNew->Reference(),
2297 false,
2298 resetTextLayers, resetTextEffects, aUpdated );
2299
2300 // Copy value
2301 processTextItem( aExisting->Value(), aNew->Value(),
2302 // reset value text only when it is a proxy for the footprint ID
2303 // (cf replacing value "MountingHole-2.5mm" with "MountingHole-4.0mm")
2304 aExisting->GetValue() == aExisting->GetFPID().GetLibItemName(),
2305 resetTextLayers, resetTextEffects, aUpdated );
2306
2307 // Copy fields in accordance with the reset* flags
2308 for( PCB_FIELD* field : aExisting->GetFields() )
2309 {
2310 // Reference and value are already handled
2311 if( field->IsReference() || field->IsValue() )
2312 continue;
2313
2314 PCB_FIELD* newField = aNew->GetFieldByName( field->GetName() );
2315
2316 if( !newField )
2317 {
2318 newField = new PCB_FIELD( *field );
2319 aNew->Add( newField );
2320 processTextItem( *field, *newField, true, true, true, aUpdated );
2321 }
2322 else
2323 {
2324 processTextItem( *field, *newField, false, resetTextLayers, resetTextEffects, aUpdated );
2325 }
2326
2327 }
2328
2329 if( resetFabricationAttrs )
2330 {
2331 // We've replaced the existing footprint with the library one, so the fabrication attrs
2332 // are already reset.
2333 //
2334 // We only have to do anything if resetFabricationAttrs is *not* set....
2335 }
2336 else
2337 {
2338 // Careful; allow-soldermask-bridges is in the m_attributes field but is not presented
2339 // as a fabrication attribute in the GUI....
2340 int libraryFlagsToKeep = aNew->GetAttributes() & FP_ALLOW_SOLDERMASK_BRIDGES;
2341 int existingFlagsToKeep = aExisting->GetAttributes() & ~FP_ALLOW_SOLDERMASK_BRIDGES;
2342 aNew->SetAttributes( existingFlagsToKeep | libraryFlagsToKeep );
2343 }
2344
2345 if( reset3DModels )
2346 {
2347 // We've replaced the existing footprint with the library one, so the 3D models are
2348 // already reset.
2349 //
2350 // We only have to do anything if reset3DModels is *not* set....
2351 }
2352 else
2353 {
2354 aNew->Models() = aExisting->Models(); // Linked list of 3D models.
2355 }
2356
2357 // Updating other parameters
2358 const_cast<KIID&>( aNew->m_Uuid ) = aExisting->m_Uuid;
2359 aNew->SetPath( aExisting->GetPath() );
2360
2361 aCommit.Remove( aExisting );
2362 aCommit.Add( aNew );
2363
2364 aNew->ClearFlags();
2365}
2366
2367
2368void PCB_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
2369{
2370 PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
2371
2373
2374 SetElementVisibility( LAYER_RATSNEST, GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
2375
2377
2378 // Netclass definitions could have changed, either by us or by Eeschema, so we need to
2379 // recompile the implicit rules
2380 DRC_TOOL* drcTool = m_toolManager->GetTool<DRC_TOOL>();
2381 WX_INFOBAR* infobar = GetInfoBar();
2382
2383 try
2384 {
2385 drcTool->GetDRCEngine()->InitEngine( GetDesignRulesPath() );
2386
2387 if( infobar->GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::DRC_RULES_ERROR )
2388 infobar->Dismiss();
2389 }
2390 catch( PARSE_ERROR& )
2391 {
2392 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Edit design rules" ),
2393 wxEmptyString );
2394
2395 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
2396 [&]( wxHyperlinkEvent& aEvent )
2397 {
2398 ShowBoardSetupDialog( _( "Custom Rules" ) );
2399 } ) );
2400
2401 infobar->RemoveAllButtons();
2402 infobar->AddButton( button );
2403 infobar->AddCloseButton();
2404 infobar->ShowMessage( _( "Could not compile custom design rules." ), wxICON_ERROR,
2406 }
2407
2410
2411 // Update the environment variables in the Python interpreter
2412 if( aEnvVarsChanged )
2414
2415 Layout();
2416 SendSizeEvent();
2417}
2418
2419
2421{
2423}
2424
2425
2427{
2429}
2430
2431
2432bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath );
2433
2434
2435void PCB_EDIT_FRAME::OnExportHyperlynx( wxCommandEvent& event )
2436{
2437 wxString wildcard = wxT( "*.hyp" );
2438 wxFileName fn = GetBoard()->GetFileName();
2439
2440 fn.SetExt( wxT("hyp") );
2441
2442 wxFileDialog dlg( this, _( "Export Hyperlynx Layout" ), fn.GetPath(), fn.GetFullName(),
2443 wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
2444
2445 if( dlg.ShowModal() != wxID_OK )
2446 return;
2447
2448 fn = dlg.GetPath();
2449
2450 // always enforce filename extension, user may not have entered it.
2451 fn.SetExt( wxT( "hyp" ) );
2452
2454}
2455
2456
2458{
2459 return GetBoard()->GetFileName();
2460}
2461
2462
2464{
2465 return m_auimgr.GetPane( wxS( "LayersManager" ) ).IsShown();
2466}
2467
2468
2470{
2471 return m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
2472}
2473
2474
2475void PCB_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
2476{
2477 if( IsShownOnScreen() )
2478 {
2479 // We only need this until the frame is done resizing and the final client size is
2480 // established.
2481 Unbind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this );
2483 }
2484
2485 // Skip() is called in the base class.
2486 EDA_DRAW_FRAME::OnSize( aEvent );
2487}
2488
2489
2491{
2494 _( "Violation Report" ) );
2495
2496 return m_inspectDrcErrorDlg;
2497}
2498
2499
2501{
2504 _( "Clearance Report" ) );
2505
2506 return m_inspectClearanceDlg;
2507}
2508
2509
2511{
2514 _( "Constraints Report" ) );
2515
2517}
2518
2519
2521{
2522 if( !m_footprintDiffDlg )
2524 _( "Compare Footprint with Library" ) );
2525
2526 return m_footprintDiffDlg;
2527}
2528
2529
2531{
2532 if( m_inspectDrcErrorDlg && aEvent.GetString() == INSPECT_DRC_ERROR_DIALOG_NAME )
2533 {
2534 m_inspectDrcErrorDlg->Destroy();
2535 m_inspectDrcErrorDlg = nullptr;
2536 }
2537 else if( m_inspectClearanceDlg && aEvent.GetString() == INSPECT_CLEARANCE_DIALOG_NAME )
2538 {
2539 m_inspectClearanceDlg->Destroy();
2540 m_inspectClearanceDlg = nullptr;
2541 }
2542 else if( m_inspectConstraintsDlg && aEvent.GetString() == INSPECT_CONSTRAINTS_DIALOG_NAME )
2543 {
2544 m_inspectConstraintsDlg->Destroy();
2545 m_inspectConstraintsDlg = nullptr;
2546 }
2547 else if( m_footprintDiffDlg && aEvent.GetString() == INSPECT_CONSTRAINTS_DIALOG_NAME )
2548 {
2549 m_footprintDiffDlg->Destroy();
2550 m_footprintDiffDlg = nullptr;
2551 }
2552}
2553
2554
2556{
2557 if( !m_netInspectorDlg )
2558 {
2561 }
2562
2563 return m_netInspectorDlg;
2564}
2565
2566
2567void PCB_EDIT_FRAME::onCloseNetInspectorDialog( wxCommandEvent& aEvent )
2568{
2569 if( m_netInspectorDlg )
2570 {
2572 m_netInspectorDlg->Destroy();
2573 m_netInspectorDlg = nullptr;
2574 }
2575}
2576
2577
2578void PCB_EDIT_FRAME::onUnitsChanged( wxCommandEvent& aEvent )
2579{
2580 wxCommandEvent evt( EDA_EVT_UNITS_CHANGED );
2581
2582 if( m_netInspectorDlg )
2583 m_netInspectorDlg->HandleWindowEvent( evt );
2584}
Class PCBNEW_ACTION_PLUGINS.
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
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 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:276
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:689
void BuildListOfNets()
Definition: board.h:795
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:755
void RemoveAllListeners()
Remove all listeners.
Definition: board.cpp:2372
const PAGE_INFO & GetPageSettings() const
Definition: board.h:650
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
Definition: board.cpp:749
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:189
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1813
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:656
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:348
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition: board.cpp:199
const wxString & GetFileName() const
Definition: board.h:313
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:761
void ClearProject()
Definition: board.cpp:238
PROJECT * GetProject() const
Definition: board.h:457
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition: board.cpp:298
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
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)
static wxString GetAutoSaveFilePrefix()
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.
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:85
const KIID m_Uuid
Definition: eda_item.h:482
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:125
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
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:80
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:131
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:95
virtual bool IsVisible() const
Definition: eda_text.h:148
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
Definition: eda_text.cpp:292
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:161
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:245
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:164
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:183
int GetTextThickness() const
Definition: eda_text.h:123
VECTOR2I GetTextSize() const
Definition: eda_text.h:219
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:55
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:659
static ENUM_MAP< T > & Instance()
Definition: property.h:653
ENUM_MAP & Undefined(T aValue)
Definition: property.h:666
wxPGChoices & Choices()
Definition: property.h:702
Component library viewer main window.
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:2056
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: footprint.h:400
EDA_ANGLE GetOrientation() const
Definition: footprint.h:209
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2128
PCB_FIELD * GetFieldByName(const wxString &aFieldName)
Return a field in this symbol.
Definition: footprint.cpp:290
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:243
void SetAttributes(int aAttributes)
Definition: footprint.h:270
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:617
int GetAttributes() const
Definition: footprint.h:269
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: footprint.h:218
PADS & Pads()
Definition: footprint.h:188
const LIB_ID & GetFPID() const
Definition: footprint.h:230
bool IsLocked() const override
Definition: footprint.h:390
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with PCB_TEXTs.
Definition: footprint.cpp:317
PCB_FIELD & Reference()
Definition: footprint.h:618
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:720
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:202
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1996
const wxString & GetValue() const
Definition: footprint.h:603
const KIID_PATH & GetPath() const
Definition: footprint.h:242
VECTOR2I GetPosition() const override
Definition: footprint.h:206
DRAWINGS & GraphicalItems()
Definition: footprint.h:191
PAD * FindPadByNumber(const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
Return a PAD with a matching number.
Definition: footprint.cpp:1536
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
bool Contains(GAL_LAYER_ID aPos)
Definition: layer_ids.h:340
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:1636
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:1518
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:1528
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:67
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:115
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:743
virtual void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Call CommonSettingsChanged() on all KIWAY_PLAYERs.
Definition: kiway.cpp:643
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:432
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:553
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:519
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:573
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
Tool relating to pads and pad settings.
Definition: pad_tool.h:37
Definition: pad.h:59
const wxString & GetPinType() const
Definition: pad.h:148
const wxString & GetPinFunction() const
Definition: pad.h:142
bool IsOnCopperLayer() const override
Definition: pad.cpp:772
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:512
static TOOL_ACTION drawRuleArea
Definition: pcb_actions.h:215
static TOOL_ACTION microwaveCreateGap
Definition: pcb_actions.h:501
static TOOL_ACTION placeText
Definition: pcb_actions.h:201
static TOOL_ACTION pointEditorArcKeepCenter
Definition: pcb_actions.h:290
static TOOL_ACTION drawOrthogonalDimension
Definition: pcb_actions.h:211
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:197
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:325
static TOOL_ACTION placeReferenceImage
Definition: pcb_actions.h:200
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:320
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:439
static TOOL_ACTION toggleNetHighlight
Definition: pcb_actions.h:548
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:198
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:246
static TOOL_ACTION tuneDiffPair
Definition: pcb_actions.h:249
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:376
static TOOL_ACTION ddAppendBoard
Drag and drop.
Definition: pcb_actions.h:577
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:546
static TOOL_ACTION drawTable
Definition: pcb_actions.h:203
static TOOL_ACTION drawTextBox
Definition: pcb_actions.h:202
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:265
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:267
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:266
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:216
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:196
static TOOL_ACTION hideNetInRatsnest
Definition: pcb_actions.h:553
static TOOL_ACTION group
Definition: pcb_actions.h:520
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:327
static TOOL_ACTION showNetInRatsnest
Definition: pcb_actions.h:554
static TOOL_ACTION drawRadialDimension
Definition: pcb_actions.h:210
static TOOL_ACTION tuneSingleTrack
Definition: pcb_actions.h:248
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:326
static TOOL_ACTION drawLeader
Definition: pcb_actions.h:212
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:530
static TOOL_ACTION tuneSkew
Definition: pcb_actions.h:250
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:324
static TOOL_ACTION microwaveCreateStubArc
Definition: pcb_actions.h:505
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:330
static TOOL_ACTION ungroup
Definition: pcb_actions.h:521
static TOOL_ACTION selectUnconnected
Select unconnected footprints from ratsnest of selection.
Definition: pcb_actions.h:102
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:329
static TOOL_ACTION drawVia
Definition: pcb_actions.h:214
static TOOL_ACTION drawArc
Definition: pcb_actions.h:199
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:399
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:484
static TOOL_ACTION pluginsReload
Scripting Actions.
Definition: pcb_actions.h:402
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:217
static TOOL_ACTION pointEditorArcKeepEndpoint
Definition: pcb_actions.h:291
static TOOL_ACTION drawCenterDimension
Definition: pcb_actions.h:209
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:503
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:509
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:378
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:328
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:321
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:487
static TOOL_ACTION highlightNetSelection
Definition: pcb_actions.h:549
static TOOL_ACTION microwaveCreateFunctionShape
Definition: pcb_actions.h:507
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:396
static TOOL_ACTION unlock
Definition: pcb_actions.h:517
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:220
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:243
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:440
static TOOL_ACTION drawLine
Definition: pcb_actions.h:195
static TOOL_ACTION localRatsnestTool
Definition: pcb_actions.h:555
static TOOL_ACTION drawAlignedDimension
Definition: pcb_actions.h:208
static TOOL_ACTION drawZone
Definition: pcb_actions.h:213
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:516
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.
void RemoveBoardChangeListener(wxEvtHandler *aListener)
Remove aListener to from the board changed listener list.
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.
void AddBoardChangeListener(wxEvtHandler *aListener)
Add aListener to post #EDA_EVT_BOARD_CHANGED command events to.
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 SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Change the visibility of an element category.
DIALOG_BOOK_REPORTER * m_inspectDrcErrorDlg
void OnClearFileHistory(wxCommandEvent &aEvent)
void onUnitsChanged(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.
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.
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)
void onCloseNetInspectorDialog(wxCommandEvent &aEvent)
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
DIALOG_NET_INSPECTOR * GetNetInspectorDialog()
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
void ExchangeFootprint(FOOTPRINT *aExisting, FOOTPRINT *aNew, BOARD_COMMIT &aCommit, bool deleteExtraTexts=true, bool resetTextLayers=true, bool resetTextEffects=true, bool resetFabricationAttrs=true, bool reset3DModels=true, bool *aUpdated=nullptr)
Replace aExisting footprint by aNew footprint using the Existing footprint settings (position,...
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
DIALOG_NET_INSPECTOR * m_netInspectorDlg
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
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:402
Tool useful for viewing footprints.
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:208
int Size() const
Returns the number of selected parts.
Definition: selection.h:115
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:57
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:145
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:289
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:230
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
std::vector< TOOL_BASE * > Tools()
Definition: tool_manager.h:324
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...
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:280
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:240
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:305
This file is part of the common library.
#define CHECK(x)
#define ENABLE(x)
#define DIALOG_DRC_WINDOW_NAME
Definition: dialog_drc.h:41
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::OnSelectDisplayMode EVT_CHOICE(ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice) EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
KiCad executable names.
const wxString EESCHEMA_EXE
bool ExportBoardToHyperlynx(BOARD *aBoard, const wxFileName &aPath)
@ FP_ALLOW_SOLDERMASK_BRIDGES
Definition: footprint.h:78
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
#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 KiCadPcbFileExtension
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
@ 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:591
KIWAY Kiway
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:1020
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:193
@ LAYER_GRID
Definition: layer_ids.h:208
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored)
Definition: layer_ids.h:234
@ LAYER_RATSNEST
Definition: layer_ids.h:207
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ F_Paste
Definition: layer_ids.h:102
@ B_Mask
Definition: layer_ids.h:107
@ B_Cu
Definition: layer_ids.h:96
@ F_Mask
Definition: layer_ids.h:108
@ B_Paste
Definition: layer_ids.h:101
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:65
@ 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
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:42
#define SKIP_UNDO
Definition: sch_commit.h:40
#define CURRENT_TOOL(action)
std::function< bool(const SELECTION &)> SELECTION_CONDITION
< Functor type that checks a specific condition for selected items.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:119
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:78
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.