KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_editor_control.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) 2014 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
27
28#include <functional>
29#include <memory>
30
31#include <pgm_base.h>
32#include <executable_names.h>
33#include <advanced_config.h>
34#include <bitmaps.h>
35#include <gestfich.h>
36#include <pcb_painter.h>
37#include <board.h>
38#include <board_commit.h>
40#include <pcb_generator.h>
41#include <footprint.h>
42#include <pad.h>
43#include <pcb_target.h>
44#include <pcb_track.h>
45#include <zone.h>
46#include <pcb_marker.h>
47#include <confirm.h>
51#include <dialog_plot.h>
52#include <kiface_base.h>
53#include <kiway.h>
55#include <origin_viewitem.h>
56#include <pcb_edit_frame.h>
57#include <pcbnew_id.h>
58#include <project.h>
59#include <project/project_file.h> // LAST_PATH_TYPE
61#include <pcbnew_settings.h>
62#include <tool/tool_manager.h>
63#include <tool/tool_event.h>
64#include <tools/drawing_tool.h>
65#include <tools/pcb_actions.h>
70#include <tools/edit_tool.h>
73#include <richio.h>
74#include <router/router_tool.h>
75#include <view/view_controls.h>
76#include <view/view_group.h>
80#include <wx/filedlg.h>
81#include <wx/msgdlg.h>
82#include <wx/log.h>
83
85
86using namespace std::placeholders;
87
88
90{
91public:
93 ACTION_MENU( true )
94 {
96 SetTitle( _( "Zones" ) );
97
102
103 AppendSeparator();
104
109
110 AppendSeparator();
111
113 }
114
115protected:
116 ACTION_MENU* create() const override
117 {
118 return new ZONE_CONTEXT_MENU();
119 }
120};
121
122
142
143
145 PCB_TOOL_BASE( "pcbnew.EditorControl" ),
146 m_frame( nullptr ),
147 m_inPlaceFootprint( false ),
148 m_placingFootprint( false )
149{
150 m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
152}
153
154
158
159
161{
163
164 if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW )
165 {
166 m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().GetAuxOrigin() );
167 getView()->Remove( m_placeOrigin.get() );
168 getView()->Add( m_placeOrigin.get() );
169 }
170}
171
172// Update left-toolbar Line modes group icon based on current settings
174{
176
177 if( !f )
178 return 0;
179
180 LEADER_MODE mode = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" )->m_AngleSnapMode;
181
182 switch( mode )
183 {
186 default:
188 }
189
190 return 0;
191}
192
194{
195 LEADER_MODE mode = aEvent.Parameter<LEADER_MODE>();
196 GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" )->m_AngleSnapMode = mode;
197 m_toolMgr->PostAction( ACTIONS::refreshPreview );
199 return 0;
200}
201
202
204{
205 auto activeToolCondition =
206 [this]( const SELECTION& aSel )
207 {
208 return ( !m_frame->ToolStackIsEmpty() );
209 };
210
211 auto inactiveStateCondition =
212 [this]( const SELECTION& aSel )
213 {
214 return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
215 };
216
217 auto placeModuleCondition =
218 [this]( const SELECTION& aSel )
219 {
220 return m_frame->IsCurrentTool( PCB_ACTIONS::placeFootprint ) && aSel.GetSize() == 0;
221 };
222
223 auto& ctxMenu = m_menu->GetMenu();
224
225 // "Cancel" goes at the top of the context menu when a tool is active
226 ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
227 ctxMenu.AddSeparator( 1 );
228
229 // "Get and Place Footprint" should be available for Place Footprint tool
230 ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
231 ctxMenu.AddSeparator( 1000 );
232
233 // Finally, add the standard zoom & grid items
234 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( *m_menu.get() );
235
236 std::shared_ptr<ZONE_CONTEXT_MENU> zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
237 zoneMenu->SetTool( this );
238
239 std::shared_ptr<LOCK_CONTEXT_MENU> lockMenu = std::make_shared<LOCK_CONTEXT_MENU>( this );
240
241 // Add the PCB control menus to relevant other tools
242
243 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
244
245 if( selTool )
246 {
247 TOOL_MENU& toolMenu = selTool->GetToolMenu();
248 CONDITIONAL_MENU& menu = toolMenu.GetMenu();
249
250 // Add "Get and Place Footprint" when Selection tool is in an inactive state
251 menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
252 menu.AddSeparator();
253
254 toolMenu.RegisterSubMenu( zoneMenu );
255 toolMenu.RegisterSubMenu( lockMenu );
256
257 menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
258
259 menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyTypes( { PCB_ZONE_T } ), 100 );
260 }
261
262 DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
263
264 if( drawingTool )
265 {
266 TOOL_MENU& toolMenu = drawingTool->GetToolMenu();
267 CONDITIONAL_MENU& menu = toolMenu.GetMenu();
268
269 toolMenu.RegisterSubMenu( zoneMenu );
270
271 // Functor to say if the PCB_EDIT_FRAME is in a given mode
272 // Capture the tool pointer and tool mode by value
273 auto toolActiveFunctor =
274 [=]( DRAWING_TOOL::MODE aMode )
275 {
276 return [=]( const SELECTION& sel )
277 {
278 return drawingTool->GetDrawingMode() == aMode;
279 };
280 };
281
282 menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 300 );
283 }
284
285 // Ensure the left toolbar's Line modes group reflects the current setting at startup
286 if( m_toolMgr )
288
289 return true;
290}
291
292
294{
295 m_frame->SaveBoard();
296 return 0;
297}
298
299
301{
302 m_frame->SaveBoard( true );
303 return 0;
304}
305
306
308{
309 m_frame->SaveBoard( true, true );
310 return 0;
311}
312
313
315{
316 m_frame->ExportFootprintsToLibrary( false );
317 return 0;
318}
319
320
322{
323 PICKED_ITEMS_LIST undoCmd;
325 ITEM_PICKER wrapper( nullptr, undoItem, UNDO_REDO::PAGESETTINGS );
326
327 undoCmd.PushItem( wrapper );
328 undoCmd.SetDescription( _( "Page Settings" ) );
329 m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS );
330
331 DIALOG_PAGES_SETTINGS dlg( m_frame, m_frame->GetBoard()->GetEmbeddedFiles(), pcbIUScale.IU_PER_MILS,
334
335 if( dlg.ShowModal() == wxID_OK )
336 {
337 m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally(
338 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
339 {
340 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
341
342 if( text && text->HasTextVars() )
343 {
344 text->ClearRenderCache();
345 text->ClearBoundingBoxCache();
347 }
348
349 return 0;
350 } );
351
352 m_frame->OnModify();
353 }
354 else
355 {
356 m_frame->RollbackFromUndo();
357 }
358
359 return 0;
360}
361
362
364{
365 DIALOG_PLOT dlg( m_frame );
366 dlg.ShowQuasiModal();
367 return 0;
368}
369
370
372{
373 m_frame->ToggleSearch();
374 return 0;
375}
376
377
379{
380 m_frame->ShowFindDialog();
381 return 0;
382}
383
384
386{
387 m_frame->FindNext( aEvent.IsAction( &ACTIONS::findPrevious ) );
388 return 0;
389}
390
391
393{
394 getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
395 return 0;
396}
397
398
400{
401 getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
402 return 0;
403}
404
405
407{
408 wxString fullFileName = frame()->GetBoard()->GetFileName();
409 wxString path;
410 wxString name;
411 wxString ext;
412
413 wxFileName::SplitPath( fullFileName, &path, &name, &ext );
414 name += wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension );
415
416 fullFileName = wxFileSelector( _( "Specctra Session File" ), path, name,
417 wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension ),
418 FILEEXT::SpecctraSessionFileWildcard(), wxFD_OPEN | wxFD_CHANGE_DIR,
419 frame() );
420
421 if( !fullFileName.IsEmpty() )
422 getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
423
424 return 0;
425}
426
427
429{
430 wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
431 wxFileName fn;
432
433 if( fullFileName.IsEmpty() )
434 {
435 fn = m_frame->GetBoard()->GetFileName();
437 }
438 else
439 {
440 fn = fullFileName;
441 }
442
443 fullFileName = wxFileSelector( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
445 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR, frame() );
446
447 if( !fullFileName.IsEmpty() )
448 {
449 m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
450 getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
451 }
452
453 return 0;
454}
455
456
458{
459 wxCHECK( m_frame, 0 );
460
461 wxFileName fn = m_frame->Prj().GetProjectFullName();
462
463 // Use a different file extension for the board netlist so the schematic netlist file
464 // is accidentally overwritten.
465 fn.SetExt( wxT( "pcb_net" ) );
466
467 wxFileDialog dlg( m_frame, _( "Export Board Netlist" ), fn.GetPath(), fn.GetFullName(),
468 _( "KiCad board netlist files" ) + AddFileExtListToFilter( { "pcb_net" } ),
469 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
470
471 dlg.SetExtraControlCreator( &LEGACYFILEDLG_NETLIST_OPTIONS::Create );
472
473 if( dlg.ShowModal() == wxID_CANCEL )
474 return 0;
475
476 fn = dlg.GetPath();
477
478 if( !fn.IsDirWritable() )
479 {
480 DisplayErrorMessage( m_frame, wxString::Format( _( "Insufficient permissions to folder '%s'." ),
481 fn.GetPath() ) );
482 return 0;
483 }
484
486 dynamic_cast<const LEGACYFILEDLG_NETLIST_OPTIONS*>( dlg.GetExtraControl() );
487 wxCHECK( noh, 0 );
488
490
491 for( const FOOTPRINT* footprint : board()->Footprints() )
492 {
493 COMPONENT* component = new COMPONENT( footprint->GetFPID(), footprint->GetReference(),
494 footprint->GetValue(), footprint->GetPath(),
495 { footprint->m_Uuid } );
496
497 for( const PAD* pad : footprint->Pads() )
498 {
499 const wxString& netname = pad->GetShortNetname();
500
501 if( !netname.IsEmpty() )
502 component->AddNet( pad->GetNumber(), netname, pad->GetPinFunction(), pad->GetPinType() );
503 }
504
505 nlohmann::ordered_map<wxString, wxString> fields;
506
507 for( PCB_FIELD* field : footprint->GetFields() )
508 fields[field->GetCanonicalName()] = field->GetText();
509
510 component->SetFields( fields );
511
512 netlist.AddComponent( component );
513 }
514
515 FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
516
517 netlist.Format( "pcb_netlist", &formatter, 0, noh->GetNetlistOptions() );
518
519 return 0;
520}
521
522
524{
525 PCB_PLOT_PARAMS plotSettings = m_frame->GetPlotSettings();
526
527 plotSettings.SetFormat( PLOT_FORMAT::GERBER );
528
529 m_frame->SetPlotSettings( plotSettings );
530
531 DIALOG_PLOT dlg( m_frame );
532 dlg.ShowQuasiModal( );
533
534 return 0;
535}
536
537
539{
540 int errors = 0;
541 wxString details;
542 bool quiet = aEvent.Parameter<bool>();
543
544 // Repair duplicate IDs and missing nets.
545 std::set<KIID> ids;
546 int duplicates = 0;
547
548 auto processItem =
549 [&]( EDA_ITEM* aItem )
550 {
551 if( ids.count( aItem->m_Uuid ) )
552 {
553 duplicates++;
554 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
555 }
556
557 ids.insert( aItem->m_Uuid );
558
559 BOARD_CONNECTED_ITEM* cItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
560
561 if( cItem && cItem->GetNetCode() )
562 {
563 NETINFO_ITEM* netinfo = cItem->GetNet();
564
565 if( netinfo && !board()->FindNet( netinfo->GetNetname() ) )
566 {
567 board()->Add( netinfo );
568
569 details += wxString::Format( _( "Orphaned net %s re-parented.\n" ),
570 netinfo->GetNetname() );
571 errors++;
572 }
573 }
574 };
575
576 // Footprint IDs are the most important, so give them the first crack at "claiming" a
577 // particular KIID.
578
579 for( FOOTPRINT* footprint : board()->Footprints() )
580 processItem( footprint );
581
582 // After that the principal use is for DRC marker pointers, which are most likely to pads
583 // or tracks.
584
585 for( FOOTPRINT* footprint : board()->Footprints() )
586 {
587 for( PAD* pad : footprint->Pads() )
588 processItem( pad );
589 }
590
591 for( PCB_TRACK* track : board()->Tracks() )
592 processItem( track );
593
594 // From here out I don't think order matters much.
595
596 for( FOOTPRINT* footprint : board()->Footprints() )
597 {
598 processItem( &footprint->Reference() );
599 processItem( &footprint->Value() );
600
601 for( BOARD_ITEM* item : footprint->GraphicalItems() )
602 processItem( item );
603
604 for( ZONE* zone : footprint->Zones() )
605 processItem( zone );
606
607 for( PCB_GROUP* group : footprint->Groups() )
608 processItem( group );
609 }
610
611 for( BOARD_ITEM* drawing : board()->Drawings() )
612 processItem( drawing );
613
614 for( ZONE* zone : board()->Zones() )
615 processItem( zone );
616
617 for( PCB_MARKER* marker : board()->Markers() )
618 processItem( marker );
619
620 for( PCB_GROUP* group : board()->Groups() )
621 processItem( group );
622
623 if( duplicates )
624 {
625 errors += duplicates;
626 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
627 }
628
629 /*******************************
630 * Your test here
631 */
632
633 /*******************************
634 * Inform the user
635 */
636
637 if( errors )
638 {
639 m_frame->OnModify();
640
641 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
642
643 if( !quiet )
644 DisplayInfoMessage( m_frame, msg, details );
645 }
646 else if( !quiet )
647 {
648 DisplayInfoMessage( m_frame, _( "No board problems found." ) );
649 }
650
651 return 0;
652}
653
654
656{
658
659 if( m_frame->FetchNetlistFromSchematic( netlist, _( "Updating PCB requires a fully annotated "
660 "schematic." ) ) )
661 {
662 DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
663 updateDialog.ShowModal();
664 }
665
666 return 0;
667}
668
670{
671 if( Kiface().IsSingle() )
672 {
673 DisplayErrorMessage( m_frame, _( "Cannot update schematic because Pcbnew is opened in "
674 "stand-alone mode. In order to create or update PCBs "
675 "from schematics, you must launch the KiCad project "
676 "manager and create a project." ) );
677 return 0;
678 }
679
682
683 KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_SCH, false );
684
685 if( frame )
686 {
687 std::string payload;
688
689 if( wxWindow* blocking_win = frame->Kiway().GetBlockingDialog() )
690 blocking_win->Close( true );
691
692 m_frame->Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_UPDATE, payload, m_frame );
693 }
694 return 0;
695}
696
697
699{
700 wxString msg;
701 PCB_EDIT_FRAME* boardFrame = m_frame;
702 PROJECT& project = boardFrame->Prj();
703 wxFileName schematic( project.GetProjectPath(), project.GetProjectName(),
705
706 if( !schematic.FileExists() )
707 {
708 wxFileName legacySchematic( project.GetProjectPath(), project.GetProjectName(),
710
711 if( legacySchematic.FileExists() )
712 {
713 schematic = legacySchematic;
714 }
715 else
716 {
717 msg.Printf( _( "Schematic file '%s' not found." ), schematic.GetFullPath() );
719 return 0;
720 }
721 }
722
723 if( Kiface().IsSingle() )
724 {
725 ExecuteFile( EESCHEMA_EXE, schematic.GetFullPath() );
726 }
727 else
728 {
729 KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_SCH, false );
730
731 // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
732 // Kiway.Player( FRAME_SCH, true )
733 // therefore, the schematic editor is sometimes running, but the schematic project
734 // is not loaded, if the library editor was called, and the dialog field editor was used.
735 // On Linux, it happens the first time the schematic editor is launched, if
736 // library editor was running, and the dialog field editor was open
737 // On Windows, it happens always after the library editor was called,
738 // and the dialog field editor was used
739 if( !frame )
740 {
741 try
742 {
743 frame = boardFrame->Kiway().Player( FRAME_SCH, true );
744 }
745 catch( const IO_ERROR& err )
746 {
747
748 DisplayErrorMessage( boardFrame, _( "Eeschema failed to load." ) + wxS( "\n" ) + err.What() );
749 return 0;
750 }
751 }
752
753 wxEventBlocker blocker( boardFrame );
754
755 // If Kiway() cannot create the eeschema frame, it shows a error message, and
756 // frame is null
757 if( !frame )
758 return 0;
759
760 if( !frame->IsShownOnScreen() ) // the frame exists, (created by the dialog field editor)
761 // but no project loaded.
762 {
763 frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFullPath() ) );
764 frame->Show( true );
765 }
766
767 // On Windows, Raise() does not bring the window on screen, when iconized or not shown
768 // On Linux, Raise() brings the window on screen, but this code works fine
769 if( frame->IsIconized() )
770 {
771 frame->Iconize( false );
772
773 // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
774 // to show the frame at its normal size: Maximize should be called.
775 frame->Maximize( false );
776 }
777
778 frame->Raise();
779 }
780
781 return 0;
782}
783
784
786{
787 getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
788 return 0;
789}
790
791
793{
794 getEditFrame<PCB_EDIT_FRAME>()->ToggleProperties();
795 return 0;
796}
797
798
800{
801 getEditFrame<PCB_EDIT_FRAME>()->ToggleNetInspector();
802 return 0;
803}
804
805
807{
808 getEditFrame<PCB_EDIT_FRAME>()->ToggleLibraryTree();
809 return 0;
810}
811
812
814{
815 getEditFrame<PCB_EDIT_FRAME>()->ToggleSearch();
816 return 0;
817}
818
819
821{
822 m_frame->ScriptingConsoleEnableDisable();
823 return 0;
824}
825
826
827// Track & via size control
829{
830 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
831 PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
832
833 if( m_frame->ToolStackIsEmpty()
834 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
835 {
836 BOARD_COMMIT commit( this );
837
838 for( EDA_ITEM* item : selection )
839 {
840 if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
841 {
842 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
843
844 for( int i = 0; i < (int) bds.m_TrackWidthList.size(); ++i )
845 {
846 int candidate = bds.m_NetSettings->GetDefaultNetclass()->GetTrackWidth();
847
848 if( i > 0 )
849 candidate = bds.m_TrackWidthList[ i ];
850
851 if( candidate > track->GetWidth() )
852 {
853 commit.Modify( track );
854 track->SetWidth( candidate );
855 break;
856 }
857 }
858 }
859 }
860
861 commit.Push( _( "Increase Track Width" ) );
862 return 0;
863 }
864
865 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
866
867 if( routerTool && routerTool->IsToolActive()
868 && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
869 {
870 int widthIndex = bds.GetDiffPairIndex() + 1;
871
872 // If we go past the last track width entry in the list, start over at the beginning
873 if( widthIndex >= (int) bds.m_DiffPairDimensionsList.size() )
874 widthIndex = 0;
875
876 bds.SetDiffPairIndex( widthIndex );
877 bds.UseCustomDiffPairDimensions( false );
878
880 }
881 else
882 {
883 int widthIndex = bds.GetTrackWidthIndex();
884
885 if( routerTool && routerTool->IsToolActive()
888 {
889 bds.m_TempOverrideTrackWidth = true;
890 }
891 else
892 {
893 widthIndex++;
894 }
895
896 // If we go past the last track width entry in the list, start over at the beginning
897 if( widthIndex >= (int) bds.m_TrackWidthList.size() )
898 widthIndex = 0;
899
900 bds.SetTrackWidthIndex( widthIndex );
901 bds.UseCustomTrackViaSize( false );
902
904 }
905
906 return 0;
907}
908
909
911{
912 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
913 PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
914
915 if( m_frame->ToolStackIsEmpty()
916 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
917 {
918 BOARD_COMMIT commit( this );
919
920 for( EDA_ITEM* item : selection )
921 {
922 if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
923 {
924 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
925
926 for( int i = (int) bds.m_TrackWidthList.size() - 1; i >= 0; --i )
927 {
928 int candidate = bds.m_NetSettings->GetDefaultNetclass()->GetTrackWidth();
929
930 if( i > 0 )
931 candidate = bds.m_TrackWidthList[ i ];
932
933 if( candidate < track->GetWidth() )
934 {
935 commit.Modify( track );
936 track->SetWidth( candidate );
937 break;
938 }
939 }
940 }
941 }
942
943 commit.Push( _( "Decrease Track Width" ) );
944 return 0;
945 }
946
947 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
948
949 if( routerTool && routerTool->IsToolActive()
950 && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
951 {
952 int widthIndex = bds.GetDiffPairIndex() - 1;
953
954 // If we get to the lowest entry start over at the highest
955 if( widthIndex < 0 )
956 widthIndex = bds.m_DiffPairDimensionsList.size() - 1;
957
958 bds.SetDiffPairIndex( widthIndex );
959 bds.UseCustomDiffPairDimensions( false );
960
962 }
963 else
964 {
965 int widthIndex = bds.GetTrackWidthIndex();
966
967 if( routerTool && routerTool->IsToolActive()
970 {
971 bds.m_TempOverrideTrackWidth = true;
972 }
973 else
974 {
975 widthIndex--;
976 }
977
978 // If we get to the lowest entry start over at the highest
979 if( widthIndex < 0 )
980 widthIndex = (int) bds.m_TrackWidthList.size() - 1;
981
982 bds.SetTrackWidthIndex( widthIndex );
983 bds.UseCustomTrackViaSize( false );
984
986 }
987
988 return 0;
989}
990
991
993{
994 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
995 PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
996
997 if( m_frame->ToolStackIsEmpty()
998 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
999 {
1000 BOARD_COMMIT commit( this );
1001
1002 for( EDA_ITEM* item : selection )
1003 {
1004 if( item->Type() == PCB_VIA_T )
1005 {
1006 PCB_VIA* via = static_cast<PCB_VIA*>( item );
1007
1008 for( int i = 0; i < (int) bds.m_ViasDimensionsList.size(); ++i )
1009 {
1012
1013 if( i> 0 )
1014 dims = bds.m_ViasDimensionsList[ i ];
1015
1016 // TODO(JE) padstacks
1017 if( dims.m_Diameter > via->GetWidth( PADSTACK::ALL_LAYERS ) )
1018 {
1019 commit.Modify( via );
1020 via->SetWidth( PADSTACK::ALL_LAYERS, dims.m_Diameter );
1021 via->SetDrill( dims.m_Drill );
1022 break;
1023 }
1024 }
1025 }
1026 }
1027
1028 commit.Push( _( "Increase Via Size" ) );
1029 }
1030 else
1031 {
1032 int sizeIndex = bds.GetViaSizeIndex() + 1;
1033
1034 // If we go past the last via entry in the list, start over at the beginning
1035 if( sizeIndex >= (int) bds.m_ViasDimensionsList.size() )
1036 sizeIndex = 0;
1037
1038 bds.SetViaSizeIndex( sizeIndex );
1039 bds.UseCustomTrackViaSize( false );
1040
1042 }
1043
1044 return 0;
1045}
1046
1047
1049{
1050 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
1051 PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1052
1053 if( m_frame->ToolStackIsEmpty()
1054 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
1055 {
1056 BOARD_COMMIT commit( this );
1057
1058 for( EDA_ITEM* item : selection )
1059 {
1060 if( item->Type() == PCB_VIA_T )
1061 {
1062 PCB_VIA* via = static_cast<PCB_VIA*>( item );
1063
1064 for( int i = (int) bds.m_ViasDimensionsList.size() - 1; i >= 0; --i )
1065 {
1068
1069 if( i > 0 )
1070 dims = bds.m_ViasDimensionsList[ i ];
1071
1072 // TODO(JE) padstacks
1073 if( dims.m_Diameter < via->GetWidth( PADSTACK::ALL_LAYERS ) )
1074 {
1075 commit.Modify( via );
1076 via->SetWidth( PADSTACK::ALL_LAYERS, dims.m_Diameter );
1077 via->SetDrill( dims.m_Drill );
1078 break;
1079 }
1080 }
1081 }
1082 }
1083
1084 commit.Push( "Decrease Via Size" );
1085 }
1086 else
1087 {
1088 int sizeIndex = 0; // Assume we only have a single via size entry
1089
1090 // If there are more, cycle through them backwards
1091 if( bds.m_ViasDimensionsList.size() > 0 )
1092 {
1093 sizeIndex = bds.GetViaSizeIndex() - 1;
1094
1095 // If we get to the lowest entry start over at the highest
1096 if( sizeIndex < 0 )
1097 sizeIndex = bds.m_ViasDimensionsList.size() - 1;
1098 }
1099
1100 bds.SetViaSizeIndex( sizeIndex );
1101 bds.UseCustomTrackViaSize( false );
1102
1104 }
1105
1106 return 0;
1107}
1108
1109
1111{
1112 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
1113
1114 if( bds.UseCustomTrackViaSize() )
1115 {
1116 bds.UseCustomTrackViaSize( false );
1117 bds.m_UseConnectedTrackWidth = true;
1118 }
1119 else
1120 {
1122 }
1123
1124 return 0;
1125}
1126
1127
1129{
1130 if( m_inPlaceFootprint )
1131 return 0;
1132
1134
1135 FOOTPRINT* fp = aEvent.Parameter<FOOTPRINT*>();
1136 bool fromOtherCommand = fp != nullptr;
1138 BOARD_COMMIT commit( m_frame );
1140 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
1141
1142 m_toolMgr->RunAction( ACTIONS::selectionClear );
1143
1144 TOOL_EVENT pushedEvent = aEvent;
1145 m_frame->PushTool( aEvent );
1146
1147 auto setCursor =
1148 [&]()
1149 {
1150 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
1151 };
1152
1153 auto cleanup =
1154 [&] ()
1155 {
1156 m_toolMgr->RunAction( ACTIONS::selectionClear );
1157 commit.Revert();
1158
1159 if( fromOtherCommand )
1160 {
1161 PICKED_ITEMS_LIST* undo = m_frame->PopCommandFromUndoList();
1162
1163 if( undo )
1164 {
1165 m_frame->PutDataInPreviousState( undo );
1166 m_frame->ClearListAndDeleteItems( undo );
1167 delete undo;
1168 }
1169 }
1170
1171 fp = nullptr;
1172 m_placingFootprint = false;
1173 };
1174
1175 Activate();
1176 // Must be done after Activate() so that it gets set into the correct context
1177 controls->ShowCursor( true );
1178 // Set initial cursor
1179 setCursor();
1180
1181 VECTOR2I cursorPos = controls->GetCursorPosition();
1182 bool ignorePrimePosition = false;
1183 bool reselect = false;
1184
1185 // Prime the pump
1186 if( fp )
1187 {
1188 m_placingFootprint = true;
1189 fp->SetPosition( cursorPos );
1190 m_toolMgr->RunAction<EDA_ITEM*>( ACTIONS::selectItem, fp );
1191 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1192 }
1193 else if( aEvent.HasPosition() )
1194 {
1195 m_toolMgr->PrimeTool( aEvent.Position() );
1196 }
1197 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
1198 {
1199 m_toolMgr->PrimeTool( { 0, 0 } );
1200 ignorePrimePosition = true;
1201 }
1202
1203 // Main loop: keep receiving events
1204 while( TOOL_EVENT* evt = Wait() )
1205 {
1206 setCursor();
1207 cursorPos = controls->GetCursorPosition( !evt->DisableGridSnapping() );
1208
1209 if( reselect && fp )
1210 m_toolMgr->RunAction<EDA_ITEM*>( ACTIONS::selectItem, fp );
1211
1212 if( evt->IsCancelInteractive() || ( fp && evt->IsAction( &ACTIONS::undo ) ) )
1213 {
1214 if( fp )
1215 {
1216 cleanup();
1217 }
1218 else
1219 {
1220 m_frame->PopTool( pushedEvent );
1221 break;
1222 }
1223 }
1224 else if( evt->IsActivate() )
1225 {
1226 if( fp )
1227 cleanup();
1228
1229 if( evt->IsMoveTool() )
1230 {
1231 // leave ourselves on the stack so we come back after the move
1232 break;
1233 }
1234 else
1235 {
1236 frame()->PopTool( pushedEvent );
1237 break;
1238 }
1239 }
1240 else if( evt->IsClick( BUT_LEFT ) )
1241 {
1242 if( !fp )
1243 {
1244 // Pick the footprint to be placed
1245 fp = m_frame->SelectFootprintFromLibrary();
1246
1247 if( fp == nullptr )
1248 continue;
1249
1250 // If we started with a hotkey which has a position then warp back to that.
1251 // Otherwise update to the current mouse position pinned inside the autoscroll
1252 // boundaries.
1253 if( evt->IsPrime() && !ignorePrimePosition )
1254 {
1255 cursorPos = evt->Position();
1256 getViewControls()->WarpMouseCursor( cursorPos, true );
1257 }
1258 else
1259 {
1261 cursorPos = getViewControls()->GetMousePosition();
1262 }
1263
1264 m_placingFootprint = true;
1265
1266 fp->SetLink( niluuid );
1267
1268 fp->SetFlags( IS_NEW ); // whatever
1269
1270 // Set parent so that clearance can be loaded
1271 fp->SetParent( board );
1272 board->UpdateUserUnits( fp, m_frame->GetCanvas()->GetView() );
1273
1274 for( PAD* pad : fp->Pads() )
1275 {
1276 pad->SetLocalRatsnestVisible( m_frame->GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
1277
1278 // Pads in the library all have orphaned nets. Replace with Default.
1279 pad->SetNetCode( 0 );
1280 }
1281
1282 // Put it on FRONT layer,
1283 // (Can be stored flipped if the lib is an archive built from a board)
1284 if( fp->IsFlipped() )
1285 fp->Flip( fp->GetPosition(), m_frame->GetPcbNewSettings()->m_FlipDirection );
1286
1287 fp->SetOrientation( ANGLE_0 );
1288 fp->SetPosition( cursorPos );
1289
1290 commit.Add( fp );
1291 m_toolMgr->RunAction<EDA_ITEM*>( ACTIONS::selectItem, fp );
1292
1293 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1294 }
1295 else
1296 {
1297 m_toolMgr->RunAction( ACTIONS::selectionClear );
1298 commit.Push( _( "Place Footprint" ) );
1299 fp = nullptr; // to indicate that there is no footprint that we currently modify
1300 m_placingFootprint = false;
1301 }
1302 }
1303 else if( evt->IsClick( BUT_RIGHT ) )
1304 {
1305 m_menu->ShowContextMenu( selection() );
1306 }
1307 else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
1308 {
1309 fp->SetPosition( cursorPos );
1310 selection().SetReferencePoint( cursorPos );
1311 getView()->Update( &selection() );
1312 getView()->Update( fp );
1313 }
1314 else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) )
1315 {
1316 // Calling 'Properties' action clears the selection, so we need to restore it
1317 reselect = true;
1318 }
1319 else if( fp && ( ZONE_FILLER_TOOL::IsZoneFillAction( evt )
1320 || evt->IsAction( &ACTIONS::redo ) ) )
1321 {
1322 wxBell();
1323 }
1324 else
1325 {
1326 evt->SetPassEvent();
1327 }
1328
1329 // Enable autopanning and cursor capture only when there is a footprint to be placed
1330 controls->SetAutoPan( fp != nullptr );
1331 controls->CaptureCursor( fp != nullptr );
1332 }
1333
1334 controls->SetAutoPan( false );
1335 controls->CaptureCursor( false );
1336 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
1337
1338 return 0;
1339}
1340
1341
1343{
1344 return modifyLockSelected( TOGGLE );
1345}
1346
1347
1349{
1350 return modifyLockSelected( ON );
1351}
1352
1353
1355{
1356 return modifyLockSelected( OFF );
1357}
1358
1359
1361{
1362 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
1363 const PCB_SELECTION& selection = selTool->GetSelection();
1364 BOARD_COMMIT commit( m_frame );
1365
1366 if( selection.Empty() )
1367 m_toolMgr->RunAction( ACTIONS::selectionCursor );
1368
1369 // Resolve TOGGLE mode
1370 if( aMode == TOGGLE )
1371 {
1372 aMode = ON;
1373
1374 for( EDA_ITEM* item : selection )
1375 {
1376 if( !item->IsBOARD_ITEM() )
1377 continue;
1378
1379 if( static_cast<BOARD_ITEM*>( item )->IsLocked() )
1380 {
1381 aMode = OFF;
1382 break;
1383 }
1384 }
1385 }
1386
1387 for( EDA_ITEM* item : selection )
1388 {
1389 if( !item->IsBOARD_ITEM() )
1390 continue;
1391
1392 BOARD_ITEM* const board_item = static_cast<BOARD_ITEM*>( item );
1393
1394 // Disallow locking free pads - it's confusing and not persisted
1395 // through save/load anyway.
1396 if( board_item->Type() == PCB_PAD_T )
1397 continue;
1398
1399 EDA_GROUP* parent_group = board_item->GetParentGroup();
1400
1401 if( parent_group && parent_group->AsEdaItem()->Type() == PCB_GENERATOR_T )
1402 {
1403 PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( parent_group );
1404
1405 if( generator && commit.GetStatus( generator ) != CHT_MODIFY )
1406 {
1407 commit.Modify( generator );
1408
1409 if( aMode == ON )
1410 generator->SetLocked( true );
1411 else
1412 generator->SetLocked( false );
1413 }
1414 }
1415
1416 commit.Modify( board_item );
1417
1418 if( aMode == ON )
1419 board_item->SetLocked( true );
1420 else
1421 board_item->SetLocked( false );
1422 }
1423
1424 if( !commit.Empty() )
1425 {
1426 commit.Push( aMode == ON ? _( "Lock" ) : _( "Unlock" ), SKIP_TEARDROPS );
1427
1428 m_toolMgr->PostEvent( EVENTS::SelectedEvent );
1429 m_frame->OnModify();
1430 }
1431
1432 return 0;
1433}
1434
1435
1436static bool mergeZones( EDA_DRAW_FRAME* aFrame, BOARD_COMMIT& aCommit,
1437 std::vector<ZONE*>& aOriginZones, std::vector<ZONE*>& aMergedZones )
1438{
1439 aCommit.Modify( aOriginZones[0] );
1440
1441 aOriginZones[0]->Outline()->ClearArcs();
1442
1443 for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1444 {
1445 SHAPE_POLY_SET otherOutline = aOriginZones[i]->Outline()->CloneDropTriangulation();
1446 otherOutline.ClearArcs();
1447 aOriginZones[0]->Outline()->BooleanAdd( otherOutline );
1448 }
1449
1450 aOriginZones[0]->Outline()->Simplify();
1451
1452 // We should have one polygon, possibly with holes. If we end up with two polygons (either
1453 // because the intersection was a single point or because the intersection was within one of
1454 // the zone's holes) then we can't merge.
1455 if( aOriginZones[0]->Outline()->IsSelfIntersecting() || aOriginZones[0]->Outline()->OutlineCount() > 1 )
1456 {
1457 DisplayErrorMessage( aFrame, _( "Zones have insufficient overlap for merging." ) );
1458 aCommit.Revert();
1459 return false;
1460 }
1461
1462 for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1463 aCommit.Remove( aOriginZones[i] );
1464
1465 aMergedZones.push_back( aOriginZones[0] );
1466
1467 aOriginZones[0]->SetLocalFlags( 1 );
1468 aOriginZones[0]->HatchBorder();
1469 aOriginZones[0]->CacheTriangulation();
1470
1471 return true;
1472}
1473
1474
1476{
1477 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1479 BOARD_COMMIT commit( m_frame );
1480
1481 if( selection.Size() < 2 )
1482 return 0;
1483
1484 int netcode = -1;
1485
1486 ZONE* firstZone = nullptr;
1487 std::vector<ZONE*> toMerge, merged;
1488
1489 for( EDA_ITEM* item : selection )
1490 {
1491 ZONE* curr_area = dynamic_cast<ZONE*>( item );
1492
1493 if( !curr_area )
1494 continue;
1495
1496 if( !firstZone )
1497 firstZone = curr_area;
1498
1499 netcode = curr_area->GetNetCode();
1500
1501 if( firstZone->GetNetCode() != netcode )
1502 {
1503 wxLogMessage( _( "Some zone netcodes did not match and were not merged." ) );
1504 continue;
1505 }
1506
1507 if( curr_area->GetAssignedPriority() != firstZone->GetAssignedPriority() )
1508 {
1509 wxLogMessage( _( "Some zone priorities did not match and were not merged." ) );
1510 continue;
1511 }
1512
1513 if( curr_area->GetIsRuleArea() != firstZone->GetIsRuleArea() )
1514 {
1515 wxLogMessage( _( "Some zones were rule areas and were not merged." ) );
1516 continue;
1517 }
1518
1519 if( curr_area->GetLayerSet() != firstZone->GetLayerSet() )
1520 {
1521 wxLogMessage( _( "Some zone layer sets did not match and were not merged." ) );
1522 continue;
1523 }
1524
1525 bool intersects = curr_area == firstZone;
1526
1527 for( ZONE* candidate : toMerge )
1528 {
1529 if( intersects )
1530 break;
1531
1532 if( board->TestZoneIntersection( curr_area, candidate ) )
1533 intersects = true;
1534 }
1535
1536 if( !intersects )
1537 {
1538 wxLogMessage( _( "Some zones did not intersect and were not merged." ) );
1539 continue;
1540 }
1541
1542 toMerge.push_back( curr_area );
1543 }
1544
1545 m_toolMgr->RunAction( ACTIONS::selectionClear );
1546
1547 if( !toMerge.empty() )
1548 {
1549 if( mergeZones( m_frame, commit, toMerge, merged ) )
1550 {
1551 commit.Push( _( "Merge Zones" ) );
1552
1553 for( EDA_ITEM* item : merged )
1554 m_toolMgr->RunAction( ACTIONS::selectItem, item );
1555 }
1556 }
1557
1558 return 0;
1559}
1560
1561
1563{
1564 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
1565 const PCB_SELECTION& selection = selTool->GetSelection();
1566
1567 // because this pops up the zone editor, it would be confusing to handle multiple zones,
1568 // so just handle single selections containing exactly one zone
1569 if( selection.Size() != 1 )
1570 return 0;
1571
1572 ZONE* oldZone = dynamic_cast<ZONE*>( selection[0] );
1573
1574 if( !oldZone )
1575 return 0;
1576
1577 ZONE_SETTINGS zoneSettings;
1578 zoneSettings << *oldZone;
1579 int dialogResult;
1580
1581 if( oldZone->GetIsRuleArea() )
1582 dialogResult = InvokeRuleAreaEditor( m_frame, &zoneSettings, board() );
1583 else if( oldZone->IsOnCopperLayer() )
1584 dialogResult = InvokeCopperZonesEditor( m_frame, nullptr, &zoneSettings );
1585 else
1586 dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1587
1588 if( dialogResult != wxID_OK )
1589 return 0;
1590
1591 // duplicate the zone
1592 BOARD_COMMIT commit( m_frame );
1593
1594 std::unique_ptr<ZONE> newZone = std::make_unique<ZONE>( *oldZone );
1595 newZone->ClearSelected();
1596 newZone->UnFill();
1597 zoneSettings.ExportSetting( *newZone );
1598
1599 // If the new zone is on the same layer(s) as the initial zone,
1600 // offset it a bit so it can more easily be picked.
1601 if( oldZone->GetLayerSet() == zoneSettings.m_Layers )
1602 newZone->Move( VECTOR2I( pcbIUScale.IU_PER_MM, pcbIUScale.IU_PER_MM ) );
1603
1604 commit.Add( newZone.release() );
1605 commit.Push( _( "Duplicate Zone" ) );
1606
1607 return 0;
1608}
1609
1610
1612{
1613 doCrossProbePcbToSch( aEvent, false );
1614 return 0;
1615}
1616
1617
1619{
1620 doCrossProbePcbToSch( aEvent, true );
1621 return 0;
1622}
1623
1624
1626{
1627 // Don't get in an infinite loop PCB -> SCH -> PCB -> SCH -> ...
1628 if( m_frame->m_probingSchToPcb )
1629 return;
1630
1631 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
1632 const PCB_SELECTION& selection = selTool->GetSelection();
1633 EDA_ITEM* focusItem = nullptr;
1634
1635 if( aEvent.Matches( EVENTS::PointSelectedEvent ) )
1636 focusItem = selection.GetLastAddedItem();
1637
1638 m_frame->SendSelectItemsToSch( selection.GetItems(), focusItem, aForce );
1639
1640 // Update 3D viewer highlighting
1641 m_frame->Update3DView( false, frame()->GetPcbNewSettings()->m_Display.m_Live3DRefresh );
1642}
1643
1644
1646{
1647 PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
1648
1649 const PCB_SELECTION& selection = selectionTool->RequestSelection(
1650 []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1651 {
1652 // Iterate from the back so we don't have to worry about removals.
1653 for( int i = aCollector.GetCount() - 1; i >= 0; --i )
1654 {
1655 if( !dynamic_cast<BOARD_CONNECTED_ITEM*>( aCollector[ i ] ) )
1656 aCollector.Remove( aCollector[ i ] );
1657 }
1658
1659 sTool->FilterCollectorForLockedItems( aCollector );
1660 } );
1661
1662 std::set<wxString> netNames;
1663 std::set<int> netCodes;
1664
1665 for( EDA_ITEM* item : selection )
1666 {
1667 const NETINFO_ITEM& net = *static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNet();
1668
1669 if( !net.HasAutoGeneratedNetname() )
1670 {
1671 netNames.insert( net.GetNetname() );
1672 netCodes.insert( net.GetNetCode() );
1673 }
1674 }
1675
1676 if( netNames.empty() )
1677 {
1678 m_frame->ShowInfoBarError( _( "Selection contains no items with labeled nets." ) );
1679 return 0;
1680 }
1681
1682 selectionTool->ClearSelection();
1683 for( const int& code : netCodes )
1684 {
1685 m_toolMgr->RunAction( PCB_ACTIONS::selectNet, code );
1686 }
1687 canvas()->ForceRefresh();
1688
1689 DIALOG_ASSIGN_NETCLASS dlg( m_frame, netNames, board()->GetNetClassAssignmentCandidates(),
1690 [this]( const std::vector<wxString>& aNetNames )
1691 {
1692 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
1693 selTool->ClearSelection();
1694
1695 for( const wxString& curr_netName : aNetNames )
1696 {
1697 int curr_netCode = board()->GetNetInfo().GetNetItem( curr_netName )->GetNetCode();
1698
1699 if( curr_netCode > 0 )
1700 selTool->SelectAllItemsOnNet( curr_netCode );
1701 }
1702
1703 canvas()->ForceRefresh();
1704 m_frame->UpdateMsgPanel();
1705 } );
1706
1707 if( dlg.ShowModal() == wxID_OK )
1708 {
1710 // Refresh UI that depends on netclasses, such as the properties panel
1712 }
1713
1714 return 0;
1715}
1716
1717
1719{
1720 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
1721 const PCB_SELECTION& selection = selTool->RequestSelection( EDIT_TOOL::FootprintFilter );
1722
1723 if( selection.Empty() )
1724 {
1725 // Giant hack: by default we assign Edit Table to the same hotkey, so give the table
1726 // tool a chance to handle it if we can't.
1727 if( PCB_EDIT_TABLE_TOOL* tableTool = m_toolMgr->GetTool<PCB_EDIT_TABLE_TOOL>() )
1728 tableTool->EditTable( aEvent );
1729
1730 return 0;
1731 }
1732
1733 FOOTPRINT* fp = selection.FirstOfKind<FOOTPRINT>();
1734
1735 if( !fp )
1736 return 0;
1737
1739
1740 if( KIWAY_PLAYER* frame = editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ) )
1741 {
1742 FOOTPRINT_EDIT_FRAME* fp_editor = static_cast<FOOTPRINT_EDIT_FRAME*>( frame );
1743
1745 fp_editor->LoadFootprintFromBoard( fp );
1746 else if( aEvent.IsAction( &PCB_ACTIONS::editLibFpInFpEditor ) )
1747 fp_editor->LoadFootprintFromLibrary( fp->GetFPID() );
1748
1749 fp_editor->Show( true );
1750 fp_editor->Raise(); // Iconize( false );
1751 }
1752
1753 if( selection.IsHover() )
1754 m_toolMgr->RunAction( ACTIONS::selectionClear );
1755
1756 return 0;
1757}
1758
1759
1761 EDA_ITEM* originViewItem, const VECTOR2D& aPosition )
1762{
1763 aFrame->GetDesignSettings().SetAuxOrigin( VECTOR2I( aPosition ) );
1764 originViewItem->SetPosition( aPosition );
1765 aView->MarkDirty();
1766 aFrame->OnModify();
1767}
1768
1769
1771{
1773 {
1774 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::GRIDORIGIN );
1776 return 0;
1777 }
1778
1779 if( aEvent.IsAction( &PCB_ACTIONS::drillSetOrigin ) )
1780 {
1781 VECTOR2I origin = aEvent.Parameter<VECTOR2I>();
1782 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::GRIDORIGIN );
1783 DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), origin );
1784 return 0;
1785 }
1786
1787 PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
1788
1789 // Deactivate other tools; particularly important if another PICKER is currently running
1790 Activate();
1791
1792 picker->SetCursor( KICURSOR::PLACE );
1793 picker->ClearHandlers();
1794
1795 picker->SetClickHandler(
1796 [this] ( const VECTOR2D& pt ) -> bool
1797 {
1798 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::DRILLORIGIN );
1800 return false; // drill origin is a one-shot; don't continue with tool
1801 } );
1802
1803 m_toolMgr->RunAction( ACTIONS::pickerTool, &aEvent );
1804
1805 return 0;
1806}
1807
1808
1810{
1819
1824
1831
1832 if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist && m_frame && m_frame->GetExportNetlistAction() )
1833 Go( &BOARD_EDITOR_CONTROL::ExportNetlist, m_frame->GetExportNetlistAction()->MakeEvent() );
1834
1843
1850
1851 // Track & via size control
1857
1858 // Zone actions
1861
1862 // Placing tools
1867
1870
1871 // Cross-select
1877
1878 // Other
1882
1884
1895 // Line modes: explicit, next, and notification
1900}
const char * name
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
#define SKIP_TEARDROPS
static bool mergeZones(EDA_DRAW_FRAME *aFrame, BOARD_COMMIT &aCommit, std::vector< ZONE * > &aOriginZones, std::vector< ZONE * > &aMergedZones)
static TOOL_ACTION updatePcbFromSchematic
Definition actions.h:264
static TOOL_ACTION cancelInteractive
Definition actions.h:72
static TOOL_ACTION revert
Definition actions.h:62
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition actions.h:227
static TOOL_ACTION saveAs
Definition actions.h:59
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition actions.h:217
static TOOL_ACTION pickerTool
Definition actions.h:253
static TOOL_ACTION findPrevious
Definition actions.h:120
static TOOL_ACTION plot
Definition actions.h:65
static TOOL_ACTION open
Definition actions.h:57
static TOOL_ACTION findNext
Definition actions.h:119
static TOOL_ACTION pageSettings
Definition actions.h:63
static TOOL_ACTION showSearch
Definition actions.h:116
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION updateSchematicFromPcb
Definition actions.h:265
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:224
static TOOL_ACTION showProperties
Definition actions.h:266
static TOOL_ACTION doNew
Definition actions.h:54
static TOOL_ACTION saveCopy
Definition actions.h:60
static TOOL_ACTION refreshPreview
Definition actions.h:159
static TOOL_ACTION find
Definition actions.h:117
ACTION_MENU(bool isContextMenu, TOOL_INTERACTIVE *aTool=nullptr)
Default constructor.
void SetTitle(const wxString &aTitle) override
Set title for the menu.
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
friend class TOOL_INTERACTIVE
TOOL_INTERACTIVE * m_tool
Creator of the menu.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
Definition base_screen.h:85
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
virtual void Revert() 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,...
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
Container for design settings for a BOARD object.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
std::shared_ptr< NET_SETTINGS > m_NetSettings
void SetViaSizeIndex(int aIndex)
Set the current via size list index to aIndex.
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
void SetAuxOrigin(const VECTOR2I &aOrigin)
void SetTrackWidthIndex(int aIndex)
Set the current track width list index to aIndex.
void UseCustomDiffPairDimensions(bool aEnabled)
Enables/disables custom differential pair dimensions.
std::vector< int > m_TrackWidthList
std::vector< VIA_DIMENSION > m_ViasDimensionsList
int ExportNetlist(const TOOL_EVENT &aEvent)
int UnlockSelected(const TOOL_EVENT &aEvent)
Run the drill origin tool for setting the origin for drill and pick-and-place files.
int Save(const TOOL_EVENT &aEvent)
int ImportNetlist(const TOOL_EVENT &aEvent)
int GenerateDrillFiles(const TOOL_EVENT &aEvent)
int ZoneMerge(const TOOL_EVENT &aEvent)
Duplicate a zone onto a layer (prompts for new layer)
int CrossProbeToSch(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
int TogglePythonConsole(const TOOL_EVENT &aEvent)
int GenBOMFileFromBoard(const TOOL_EVENT &aEvent)
static void DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *aItem, const VECTOR2D &aPoint)
int UpdatePCBFromSchematic(const TOOL_EVENT &aEvent)
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
int ShowEeschema(const TOOL_EVENT &aEvent)
int ExportFootprints(const TOOL_EVENT &aEvent)
int SaveAs(const TOOL_EVENT &aEvent)
int AssignNetclass(const TOOL_EVENT &aEvent)
int ToggleNetInspector(const TOOL_EVENT &aEvent)
int UpdateSchematicFromPCB(const TOOL_EVENT &aEvent)
int ExplicitCrossProbeToSch(const TOOL_EVENT &aEvent)
Assign a netclass to a labelled net.
int ExportHyperlynx(const TOOL_EVENT &aEvent)
int ToggleSearch(const TOOL_EVENT &aEvent)
int DrillOrigin(const TOOL_EVENT &aEvent)
Low-level access (below undo) to setting the drill origin.
MODIFY_MODE
< How to modify a property for selected items.
int ViaSizeDec(const TOOL_EVENT &aEvent)
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int RepairBoard(const TOOL_EVENT &aEvent)
int ZoneDuplicate(const TOOL_EVENT &aEvent)
int ToggleLayersManager(const TOOL_EVENT &aEvent)
int ImportSpecctraSession(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
int PlaceFootprint(const TOOL_EVENT &aEvent)
Display a dialog to select a footprint to be added and allows the user to set its position.
int BoardSetup(const TOOL_EVENT &aEvent)
int modifyLockSelected(MODIFY_MODE aMode)
Set up handlers for various events.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int TrackWidthInc(const TOOL_EVENT &aEvent)
int GenerateODBPPFiles(const TOOL_EVENT &aEvent)
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Lock selected items.
int AutoTrackWidth(const TOOL_EVENT &aEvent)
int LockSelected(const TOOL_EVENT &aEvent)
Unlock selected items.
int PageSettings(const TOOL_EVENT &aEvent)
int ExportSpecctraDSN(const TOOL_EVENT &aEvent)
int FindNext(const TOOL_EVENT &aEvent)
int ToggleLibraryTree(const TOOL_EVENT &aEvent)
int ExportGenCAD(const TOOL_EVENT &aEvent)
Export GenCAD 1.4 format.
int ViaSizeInc(const TOOL_EVENT &aEvent)
int New(const TOOL_EVENT &aEvent)
int OnAngleSnapModeChanged(const TOOL_EVENT &aEvent)
int ExportCmpFile(const TOOL_EVENT &aEvent)
int Find(const TOOL_EVENT &aEvent)
int GenFootprintsReport(const TOOL_EVENT &aEvent)
void doCrossProbePcbToSch(const TOOL_EVENT &aEvent, bool aForce)
int GenD356File(const TOOL_EVENT &aEvent)
int Plot(const TOOL_EVENT &aEvent)
int ExportIDF(const TOOL_EVENT &aEvent)
int TrackWidthDec(const TOOL_EVENT &aEvent)
int Revert(const TOOL_EVENT &aEvent)
int Search(const TOOL_EVENT &aEvent)
int GenIPC2581File(const TOOL_EVENT &aEvent)
int ExportVRML(const TOOL_EVENT &aEvent)
int Open(const TOOL_EVENT &aEvent)
int SaveCopy(const TOOL_EVENT &aEvent)
int ChangeLineMode(const TOOL_EVENT &aEvent)
int GeneratePosFile(const TOOL_EVENT &aEvent)
int EditFpInFpEditor(const TOOL_EVENT &aEvent)
Notify Eeschema about selected items.
int GenerateGerbers(const TOOL_EVENT &aEvent)
int ToggleProperties(const TOOL_EVENT &aEvent)
int OpenNonKicadBoard(const TOOL_EVENT &aEvent)
int ExportSTEP(const TOOL_EVENT &aEvent)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:83
void SetLocked(bool aLocked) override
Definition board_item.h:327
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
const NETINFO_LIST & GetNetInfo() const
Definition board.h:996
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1222
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition board.cpp:2664
int GetCount() const
Return the number of objects in the list.
Definition collector.h:83
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition collector.h:111
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition commit.h:90
bool Empty() const
Definition commit.h:137
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:106
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Definition commit.h:78
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
Definition commit.cpp:167
Store all of the related component information found in a netlist.
void AddNet(const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction, const wxString &aPinType)
void SetFields(nlohmann::ordered_map< wxString, wxString > aFields)
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Add a submenu to the menu.
CONDITIONAL_MENU(TOOL_INTERACTIVE *aTool)
void SetWksFileName(const wxString &aFilename)
A dialog to set the plot options and create plot files in various formats.
Definition dialog_plot.h:41
int ShowModal() override
Tool responsible for drawing graphical elements like lines, arcs, circles, etc.
MODE GetDrawingMode() const
Return the current drawing mode of the DRAWING_TOOL or MODE::NONE if not currently in any drawing mod...
void SelectToolbarAction(const TOOL_ACTION &aAction)
Select the given action in the toolbar group which contains it, if any.
The base class for create windows for drawing purpose.
void ForceRefresh()
Force a redraw.
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:46
virtual EDA_ITEM * AsEdaItem()=0
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual void SetPosition(const VECTOR2I &aPos)
Definition eda_item.h:279
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition eda_item.h:148
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:116
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.h:113
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:80
static const TOOL_EVENT ClearedEvent
Definition actions.h:347
static const TOOL_EVENT SelectedEvent
Definition actions.h:345
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition actions.h:352
static const TOOL_EVENT PointSelectedEvent
Definition actions.h:344
static const TOOL_EVENT UnselectedEvent
Definition actions.h:346
Used for text file output.
Definition richio.h:469
void LoadFootprintFromLibrary(LIB_ID aFPID)
bool LoadFootprintFromBoard(FOOTPRINT *aFootprint)
Load a footprint from the main board into the Footprint Editor.
void SetPosition(const VECTOR2I &aPos) override
void SetLink(const KIID &aLink)
Definition footprint.h:1066
void SetOrientation(const EDA_ANGLE &aNewAngle)
std::deque< PAD * > & Pads()
Definition footprint.h:304
bool IsFlipped() const
Definition footprint.h:514
const LIB_ID & GetFPID() const
Definition footprint.h:349
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I GetPosition() const override
Definition footprint.h:325
Used when the right click button is pressed, or when the select tool is in effect.
Definition collectors.h:207
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
virtual void PinCursorInsideNonAutoscrollArea(bool aWarpMouseCursor)=0
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:86
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:66
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition view.cpp:298
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition view.cpp:341
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:1685
void MarkDirty()
Force redraw of view on the next rendering.
Definition view.h:659
Definition kiid.h:49
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:403
Helper widget to add controls to a wxFileDialog to set netlist configuration options.
static wxWindow * Create(wxWindow *aParent)
ACTION_MENU * create() const override
Return an instance of this class. It has to be overridden in inheriting classes.
LOCK_CONTEXT_MENU(TOOL_INTERACTIVE *aTool)
int GetViaDiameter() const
Definition netclass.h:133
int GetViaDrill() const
Definition netclass.h:141
int GetTrackWidth() const
Definition netclass.h:125
Handle the data for a net.
Definition netinfo.h:54
const wxString & GetNetname() const
Definition netinfo.h:112
int GetNetCode() const
Definition netinfo.h:106
bool HasAutoGeneratedNetname() const
NETINFO_ITEM * GetNetItem(int aNetCode) const
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
std::shared_ptr< NETCLASS > GetDefaultNetclass()
Gets the default netclass for the project.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:177
Definition pad.h:55
static TOOL_ACTION lineModeFree
Unconstrained angle mode (icon lines_any)
static TOOL_ACTION zonesManager
static TOOL_ACTION generateBOM
static TOOL_ACTION exportGenCAD
static TOOL_ACTION zoneFillAll
static TOOL_ACTION showLayersManager
static TOOL_ACTION trackWidthDec
static TOOL_ACTION generateDrillFiles
static TOOL_ACTION exportVRML
static TOOL_ACTION generateD356File
static TOOL_ACTION exportCmpFile
static TOOL_ACTION trackViaSizeChanged
static TOOL_ACTION exportSpecctraDSN
static TOOL_ACTION trackWidthInc
static TOOL_ACTION autoTrackWidth
static TOOL_ACTION generateIPC2581File
static TOOL_ACTION getAndPlace
Find an item and start moving.
static TOOL_ACTION generateODBPPFile
static TOOL_ACTION drawZoneCutout
static TOOL_ACTION openNonKicadBoard
static TOOL_ACTION viaSizeDec
static TOOL_ACTION zoneFill
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION editFpInFpEditor
static TOOL_ACTION toggleLock
static TOOL_ACTION drillResetOrigin
static TOOL_ACTION lineMode45
45-degree-or-orthogonal mode (icon hv45mode)
static TOOL_ACTION viaSizeInc
static TOOL_ACTION angleSnapModeChanged
Notification event when angle mode changes.
static TOOL_ACTION zoneUnfill
static TOOL_ACTION generatePosFile
static TOOL_ACTION drillOrigin
static TOOL_ACTION assignNetClass
static TOOL_ACTION repairBoard
static TOOL_ACTION exportSTEP
static TOOL_ACTION showNetInspector
static TOOL_ACTION generateGerbers
static TOOL_ACTION generateReportFile
static TOOL_ACTION exportHyperlynx
static TOOL_ACTION exportIDF
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
static TOOL_ACTION importNetlist
static TOOL_ACTION drawSimilarZone
static TOOL_ACTION boardSetup
static TOOL_ACTION showEeschema
static TOOL_ACTION showDesignBlockPanel
static TOOL_ACTION zoneUnfillAll
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
Definition pcb_actions.h:82
static TOOL_ACTION lineMode90
90-degree-only mode (icon lines90)
static TOOL_ACTION editLibFpInFpEditor
static TOOL_ACTION zoneMerge
static TOOL_ACTION drillSetOrigin
static TOOL_ACTION unlock
static TOOL_ACTION exportFootprints
static TOOL_ACTION placeFootprint
static TOOL_ACTION showPythonConsole
static TOOL_ACTION importSpecctraSession
static TOOL_ACTION selectOnSchematic
Select symbols/pins on schematic corresponding to selected footprints/pads.
static TOOL_ACTION lock
Common, abstract interface for edit frames.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Return the BOARD_DESIGN_SETTINGS for the open project.
The main frame for Pcbnew.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:53
void SetLocked(bool aLocked) override
Generic tool for picking an item.
Parameters and options when plotting/printing a board.
void SetFormat(PLOT_FORMAT aFormat)
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:
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Return the current selection, filtered according to aClientFilter.
int ClearSelection(const TOOL_EVENT &aEvent)
PCB_SELECTION & GetSelection()
void FilterCollectorForLockedItems(GENERAL_COLLECTOR &aCollector)
In the PCB editor strip out any locked items unless the OverrideLocks checkbox is set.
void SelectAllItemsOnNet(int aNetCode, bool aSelect=true)
Select all items with the given net code.
T * frame() const
KIGFX::VIEW_CONTROLS * controls() const
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
BOARD * board() const
PCB_DRAW_PANEL_GAL * canvas() const
const PCB_SELECTION & selection() const
FOOTPRINT * footprint() const
virtual void SetWidth(int aWidth)
Definition pcb_track.h:147
virtual int GetWidth() const
Definition pcb_track.h:148
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:547
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
void SetDescription(const wxString &aDescription)
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition picker_tool.h:81
void SetCursor(KICURSOR aCursor)
Definition picker_tool.h:64
ROUTER_MODE Mode() const
Definition pns_router.h:150
RouterState GetState() const
Definition pns_router.h:152
ROUTER * Router() const
Container for project specific data.
Definition project.h:65
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
void SetReferencePoint(const VECTOR2I &aP)
Represent a set of closed polygons.
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition tool_base.h:186
T * getModel() const
Return the model object if it matches the requested type.
Definition tool_base.h:198
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition tool_base.cpp:44
TOOL_MANAGER * m_toolMgr
Definition tool_base.h:220
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition tool_base.cpp:38
bool IsToolActive() const
Definition tool_base.cpp:32
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:78
@ REDRAW
Full drawing refresh.
Definition tool_base.h:83
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:80
@ GAL_SWITCH
Rendering engine changes.
Definition tool_base.h:82
Generic, UI-independent tool event.
Definition tool_event.h:171
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition tool_event.h:260
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition tool_event.h:392
const VECTOR2D Position() const
Return mouse cursor position in world coordinates.
Definition tool_event.h:293
bool IsReactivate() const
Control whether the tool is first being pushed to the stack or being reactivated after a pause.
Definition tool_event.h:273
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
T Parameter() const
Return a parameter assigned to the event.
Definition tool_event.h:473
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
TOOL_MENU & GetToolMenu()
std::unique_ptr< TOOL_MENU > m_menu
The functions below are not yet implemented - their interface may change.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
void Activate()
Run the tool.
Manage a CONDITIONAL_MENU and some number of CONTEXT_MENUs as sub-menus.
Definition tool_menu.h:43
CONDITIONAL_MENU & GetMenu()
Definition tool_menu.cpp:44
void RegisterSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition tool_menu.cpp:50
ACTION_MENU * create() const override
Return an instance of this class. It has to be overridden in inheriting classes.
static bool IsZoneFillAction(const TOOL_EVENT *aEvent)
ZONE_SETTINGS handles zones parameters.
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
Handle a list of polygons defining a copper zone.
Definition zone.h:74
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition zone.h:701
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition zone.h:136
bool IsOnCopperLayer() const override
Definition zone.cpp:511
unsigned GetAssignedPriority() const
Definition zone.h:126
@ CHT_MODIFY
Definition commit.h:44
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:230
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:202
This file is part of the common library.
@ PLACE
Definition cursors.h:98
@ ARROW
Definition cursors.h:46
@ PENCIL
Definition cursors.h:52
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE *aZone, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aZoneSettings, BOARD *aBoard, CONVERT_SETTINGS *aConvertSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:411
#define IS_NEW
New item, just created.
KiCad executable names.
const wxString EESCHEMA_EXE
@ FRAME_SCH
Definition frame_type.h:34
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:43
LEADER_MODE
The kind of the leader line.
@ DEG45
45 Degree only
@ DIRECT
Unconstrained point-to-point.
@ DEG90
90 Degree only
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition gestfich.cpp:145
static const std::string LegacySchematicFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string SpecctraDsnFileExtension
static const std::string SpecctraSessionFileExtension
static wxString SpecctraSessionFileWildcard()
static wxString SpecctraDsnFileWildcard()
KIID niluuid(0)
@ MAIL_SCH_UPDATE
Definition mail_type.h:47
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:58
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:55
@ PNS_MODE_ROUTE_DIFF_PAIR
Definition pns_router.h:64
#define MAX_PAGE_SIZE_PCBNEW_MILS
Definition page_info.h:35
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
@ LAST_PATH_SPECCTRADSN
T * GetAppSettings(const char *aFilename)
std::vector< FAB_LAYER_COLOR > dummy
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
std::string path
@ BUT_LEFT
Definition tool_event.h:132
@ BUT_RIGHT
Definition tool_event.h:133
@ 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_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:87
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
VECTOR2< double > VECTOR2D
Definition vector2d.h:694
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Definition of file extensions used in Kicad.