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
60#include <tool/tool_manager.h>
61#include <tool/tool_event.h>
62#include <tools/drawing_tool.h>
63#include <tools/pcb_actions.h>
68#include <tools/edit_tool.h>
71#include <richio.h>
72#include <router/router_tool.h>
73#include <view/view_controls.h>
74#include <view/view_group.h>
78#include <wx/filedlg.h>
79#include <wx/msgdlg.h>
80#include <wx/log.h>
81
83
84using namespace std::placeholders;
85
86
88{
89public:
91 ACTION_MENU( true )
92 {
93 SetIcon( BITMAPS::add_zone );
94 SetTitle( _( "Zones" ) );
95
100
101 AppendSeparator();
102
107
108 AppendSeparator();
109
111 }
112
113protected:
114 ACTION_MENU* create() const override
115 {
116 return new ZONE_CONTEXT_MENU();
117 }
118};
119
120
122{
123public:
125 CONDITIONAL_MENU( aTool )
126 {
127 SetIcon( BITMAPS::locked );
128 SetTitle( _( "Locking" ) );
129
133 }
134
135 ACTION_MENU* create() const override
136 {
137 return new LOCK_CONTEXT_MENU( this->m_tool );
138 }
139};
140
141
143 PCB_TOOL_BASE( "pcbnew.EditorControl" ),
144 m_frame( nullptr ),
145 m_inPlaceFootprint( false ),
146 m_placingFootprint( false )
147{
148 m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
150}
151
152
154{
155}
156
157
159{
160 m_frame = getEditFrame<PCB_EDIT_FRAME>();
161
162 if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW )
163 {
164 m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().GetAuxOrigin() );
165 getView()->Remove( m_placeOrigin.get() );
166 getView()->Add( m_placeOrigin.get() );
167 }
168}
169
170
172{
173 auto activeToolCondition =
174 [this]( const SELECTION& aSel )
175 {
176 return ( !m_frame->ToolStackIsEmpty() );
177 };
178
179 auto inactiveStateCondition =
180 [this]( const SELECTION& aSel )
181 {
182 return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
183 };
184
185 auto placeModuleCondition =
186 [this]( const SELECTION& aSel )
187 {
188 return m_frame->IsCurrentTool( PCB_ACTIONS::placeFootprint ) && aSel.GetSize() == 0;
189 };
190
191 auto& ctxMenu = m_menu->GetMenu();
192
193 // "Cancel" goes at the top of the context menu when a tool is active
194 ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
195 ctxMenu.AddSeparator( 1 );
196
197 // "Get and Place Footprint" should be available for Place Footprint tool
198 ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
199 ctxMenu.AddSeparator( 1000 );
200
201 // Finally, add the standard zoom & grid items
202 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( *m_menu.get() );
203
204 std::shared_ptr<ZONE_CONTEXT_MENU> zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
205 zoneMenu->SetTool( this );
206
207 std::shared_ptr<LOCK_CONTEXT_MENU> lockMenu = std::make_shared<LOCK_CONTEXT_MENU>( this );
208
209 // Add the PCB control menus to relevant other tools
210
212
213 if( selTool )
214 {
215 TOOL_MENU& toolMenu = selTool->GetToolMenu();
216 CONDITIONAL_MENU& menu = toolMenu.GetMenu();
217
218 // Add "Get and Place Footprint" when Selection tool is in an inactive state
219 menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
220 menu.AddSeparator();
221
222 toolMenu.RegisterSubMenu( zoneMenu );
223 toolMenu.RegisterSubMenu( lockMenu );
224
225 menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
226
227 menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyTypes( { PCB_ZONE_T } ), 100 );
228 }
229
230 DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
231
232 if( drawingTool )
233 {
234 TOOL_MENU& toolMenu = drawingTool->GetToolMenu();
235 CONDITIONAL_MENU& menu = toolMenu.GetMenu();
236
237 toolMenu.RegisterSubMenu( zoneMenu );
238
239 // Functor to say if the PCB_EDIT_FRAME is in a given mode
240 // Capture the tool pointer and tool mode by value
241 auto toolActiveFunctor =
242 [=]( DRAWING_TOOL::MODE aMode )
243 {
244 return [=]( const SELECTION& sel )
245 {
246 return drawingTool->GetDrawingMode() == aMode;
247 };
248 };
249
250 menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 300 );
251 }
252
253 return true;
254}
255
256
258{
260 return 0;
261}
262
263
265{
266 m_frame->SaveBoard( true );
267 return 0;
268}
269
270
272{
273 m_frame->SaveBoard( true, true );
274 return 0;
275}
276
277
279{
281 return 0;
282}
283
284
286{
287 PICKED_ITEMS_LIST undoCmd;
289 ITEM_PICKER wrapper( nullptr, undoItem, UNDO_REDO::PAGESETTINGS );
290
291 undoCmd.PushItem( wrapper );
292 undoCmd.SetDescription( _( "Page Settings" ) );
293 m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS );
294
298
299 if( dlg.ShowModal() == wxID_OK )
300 {
302 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
303 {
304 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
305
306 if( text && text->HasTextVars() )
307 {
308 text->ClearRenderCache();
309 text->ClearBoundingBoxCache();
311 }
312
313 return 0;
314 } );
315
316 m_frame->OnModify();
317 }
318 else
319 {
321 }
322
323 return 0;
324}
325
326
328{
329 DIALOG_PLOT dlg( m_frame );
330 dlg.ShowQuasiModal();
331 return 0;
332}
333
334
336{
338 return 0;
339}
340
341
343{
345 return 0;
346}
347
348
350{
352 return 0;
353}
354
355
357{
358 getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
359 return 0;
360}
361
362
364{
365 getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
366 return 0;
367}
368
369
371{
372 wxString fullFileName = frame()->GetBoard()->GetFileName();
373 wxString path;
374 wxString name;
375 wxString ext;
376
377 wxFileName::SplitPath( fullFileName, &path, &name, &ext );
378 name += wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension );
379
380 fullFileName = wxFileSelector( _( "Specctra Session File" ), path, name,
381 wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension ),
382 FILEEXT::SpecctraSessionFileWildcard(), wxFD_OPEN | wxFD_CHANGE_DIR,
383 frame() );
384
385 if( !fullFileName.IsEmpty() )
386 getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
387
388 return 0;
389}
390
391
393{
394 wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
395 wxFileName fn;
396
397 if( fullFileName.IsEmpty() )
398 {
399 fn = m_frame->GetBoard()->GetFileName();
401 }
402 else
403 {
404 fn = fullFileName;
405 }
406
407 fullFileName = wxFileSelector( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
409 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR, frame() );
410
411 if( !fullFileName.IsEmpty() )
412 {
413 m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
414 getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
415 }
416
417 return 0;
418}
419
420
422{
423 wxCHECK( m_frame, 0 );
424
425 wxFileName fn = m_frame->Prj().GetProjectFullName();
426
427 // Use a different file extension for the board netlist so the schematic netlist file
428 // is accidentally overwritten.
429 fn.SetExt( wxT( "pcb_net" ) );
430
431 wxFileDialog dlg( m_frame, _( "Export Board Netlist" ), fn.GetPath(), fn.GetFullName(),
432 _( "KiCad board netlist files" ) + AddFileExtListToFilter( { "pcb_net" } ),
433 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
434
435 dlg.SetExtraControlCreator( &LEGACYFILEDLG_NETLIST_OPTIONS::Create );
436
437 if( dlg.ShowModal() == wxID_CANCEL )
438 return 0;
439
440 fn = dlg.GetPath();
441
442 if( !fn.IsDirWritable() )
443 {
444 DisplayErrorMessage( m_frame, wxString::Format( _( "Insufficient permissions to folder '%s'." ),
445 fn.GetPath() ) );
446 return 0;
447 }
448
450 dynamic_cast<const LEGACYFILEDLG_NETLIST_OPTIONS*>( dlg.GetExtraControl() );
451 wxCHECK( noh, 0 );
452
454
455 for( const FOOTPRINT* footprint : board()->Footprints() )
456 {
459 { footprint->m_Uuid } );
460
461 for( const PAD* pad : footprint->Pads() )
462 {
463 const wxString& netname = pad->GetShortNetname();
464
465 if( !netname.IsEmpty() )
466 component->AddNet( pad->GetNumber(), netname, pad->GetPinFunction(), pad->GetPinType() );
467 }
468
469 nlohmann::ordered_map<wxString, wxString> fields;
470
471 for( PCB_FIELD* field : footprint->GetFields() )
472 fields[field->GetCanonicalName()] = field->GetText();
473
474 component->SetFields( fields );
475
476 netlist.AddComponent( component );
477 }
478
479 FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
480
481 netlist.Format( "pcb_netlist", &formatter, 0, noh->GetNetlistOptions() );
482
483 return 0;
484}
485
486
488{
489 PCB_PLOT_PARAMS plotSettings = m_frame->GetPlotSettings();
490
491 plotSettings.SetFormat( PLOT_FORMAT::GERBER );
492
493 m_frame->SetPlotSettings( plotSettings );
494
495 DIALOG_PLOT dlg( m_frame );
496 dlg.ShowQuasiModal( );
497
498 return 0;
499}
500
501
503{
504 int errors = 0;
505 wxString details;
506 bool quiet = aEvent.Parameter<bool>();
507
508 // Repair duplicate IDs and missing nets.
509 std::set<KIID> ids;
510 int duplicates = 0;
511
512 auto processItem =
513 [&]( EDA_ITEM* aItem )
514 {
515 if( ids.count( aItem->m_Uuid ) )
516 {
517 duplicates++;
518 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
519 }
520
521 ids.insert( aItem->m_Uuid );
522
523 BOARD_CONNECTED_ITEM* cItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
524
525 if( cItem && cItem->GetNetCode() )
526 {
527 NETINFO_ITEM* netinfo = cItem->GetNet();
528
529 if( netinfo && !board()->FindNet( netinfo->GetNetname() ) )
530 {
531 board()->Add( netinfo );
532
533 details += wxString::Format( _( "Orphaned net %s re-parented.\n" ),
534 netinfo->GetNetname() );
535 errors++;
536 }
537 }
538 };
539
540 // Footprint IDs are the most important, so give them the first crack at "claiming" a
541 // particular KIID.
542
543 for( FOOTPRINT* footprint : board()->Footprints() )
544 processItem( footprint );
545
546 // After that the principal use is for DRC marker pointers, which are most likely to pads
547 // or tracks.
548
549 for( FOOTPRINT* footprint : board()->Footprints() )
550 {
551 for( PAD* pad : footprint->Pads() )
552 processItem( pad );
553 }
554
555 for( PCB_TRACK* track : board()->Tracks() )
556 processItem( track );
557
558 // From here out I don't think order matters much.
559
560 for( FOOTPRINT* footprint : board()->Footprints() )
561 {
562 processItem( &footprint->Reference() );
563 processItem( &footprint->Value() );
564
565 for( BOARD_ITEM* item : footprint->GraphicalItems() )
566 processItem( item );
567
568 for( ZONE* zone : footprint->Zones() )
569 processItem( zone );
570
571 for( PCB_GROUP* group : footprint->Groups() )
572 processItem( group );
573 }
574
575 for( BOARD_ITEM* drawing : board()->Drawings() )
576 processItem( drawing );
577
578 for( ZONE* zone : board()->Zones() )
579 processItem( zone );
580
581 for( PCB_MARKER* marker : board()->Markers() )
582 processItem( marker );
583
584 for( PCB_GROUP* group : board()->Groups() )
585 processItem( group );
586
587 if( duplicates )
588 {
589 errors += duplicates;
590 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
591 }
592
593 /*******************************
594 * Your test here
595 */
596
597 /*******************************
598 * Inform the user
599 */
600
601 if( errors )
602 {
603 m_frame->OnModify();
604
605 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
606
607 if( !quiet )
608 DisplayInfoMessage( m_frame, msg, details );
609 }
610 else if( !quiet )
611 {
612 DisplayInfoMessage( m_frame, _( "No board problems found." ) );
613 }
614
615 return 0;
616}
617
618
620{
622
623 if( m_frame->FetchNetlistFromSchematic( netlist, _( "Updating PCB requires a fully annotated "
624 "schematic." ) ) )
625 {
626 DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
627 updateDialog.ShowModal();
628 }
629
630 return 0;
631}
632
634{
635 if( Kiface().IsSingle() )
636 {
637 DisplayErrorMessage( m_frame, _( "Cannot update schematic because Pcbnew is opened in "
638 "stand-alone mode. In order to create or update PCBs "
639 "from schematics, you must launch the KiCad project "
640 "manager and create a project." ) );
641 return 0;
642 }
643
646
648
649 if( frame )
650 {
651 std::string payload;
652
653 if( wxWindow* blocking_win = frame->Kiway().GetBlockingDialog() )
654 blocking_win->Close( true );
655
657 }
658 return 0;
659}
660
661
663{
664 wxString msg;
665 PCB_EDIT_FRAME* boardFrame = m_frame;
666 PROJECT& project = boardFrame->Prj();
667 wxFileName schematic( project.GetProjectPath(), project.GetProjectName(),
669
670 if( !schematic.FileExists() )
671 {
672 wxFileName legacySchematic( project.GetProjectPath(), project.GetProjectName(),
674
675 if( legacySchematic.FileExists() )
676 {
677 schematic = legacySchematic;
678 }
679 else
680 {
681 msg.Printf( _( "Schematic file '%s' not found." ), schematic.GetFullPath() );
683 return 0;
684 }
685 }
686
687 if( Kiface().IsSingle() )
688 {
689 ExecuteFile( EESCHEMA_EXE, schematic.GetFullPath() );
690 }
691 else
692 {
694
695 // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
696 // Kiway.Player( FRAME_SCH, true )
697 // therefore, the schematic editor is sometimes running, but the schematic project
698 // is not loaded, if the library editor was called, and the dialog field editor was used.
699 // On Linux, it happens the first time the schematic editor is launched, if
700 // library editor was running, and the dialog field editor was open
701 // On Windows, it happens always after the library editor was called,
702 // and the dialog field editor was used
703 if( !frame )
704 {
705 try
706 {
707 frame = boardFrame->Kiway().Player( FRAME_SCH, true );
708 }
709 catch( const IO_ERROR& err )
710 {
711
712 DisplayErrorMessage( boardFrame, _( "Eeschema failed to load." ) + wxS( "\n" ) + err.What() );
713 return 0;
714 }
715 }
716
717 wxEventBlocker blocker( boardFrame );
718
719 // If Kiway() cannot create the eeschema frame, it shows a error message, and
720 // frame is null
721 if( !frame )
722 return 0;
723
724 if( !frame->IsShownOnScreen() ) // the frame exists, (created by the dialog field editor)
725 // but no project loaded.
726 {
727 frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFullPath() ) );
728 frame->Show( true );
729 }
730
731 // On Windows, Raise() does not bring the window on screen, when iconized or not shown
732 // On Linux, Raise() brings the window on screen, but this code works fine
733 if( frame->IsIconized() )
734 {
735 frame->Iconize( false );
736
737 // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
738 // to show the frame at its normal size: Maximize should be called.
739 frame->Maximize( false );
740 }
741
742 frame->Raise();
743 }
744
745 return 0;
746}
747
748
750{
751 getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
752 return 0;
753}
754
755
757{
758 getEditFrame<PCB_EDIT_FRAME>()->ToggleProperties();
759 return 0;
760}
761
762
764{
765 getEditFrame<PCB_EDIT_FRAME>()->ToggleNetInspector();
766 return 0;
767}
768
769
771{
772 getEditFrame<PCB_EDIT_FRAME>()->ToggleLibraryTree();
773 return 0;
774}
775
776
778{
779 getEditFrame<PCB_EDIT_FRAME>()->ToggleSearch();
780 return 0;
781}
782
783
785{
787 return 0;
788}
789
790
791// Track & via size control
793{
794 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
796
798 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
799 {
800 BOARD_COMMIT commit( this );
801
802 for( EDA_ITEM* item : selection )
803 {
804 if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
805 {
806 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
807
808 for( int i = 0; i < (int) bds.m_TrackWidthList.size(); ++i )
809 {
810 int candidate = bds.m_NetSettings->GetDefaultNetclass()->GetTrackWidth();
811
812 if( i > 0 )
813 candidate = bds.m_TrackWidthList[ i ];
814
815 if( candidate > track->GetWidth() )
816 {
817 commit.Modify( track );
818 track->SetWidth( candidate );
819 break;
820 }
821 }
822 }
823 }
824
825 commit.Push( _( "Increase Track Width" ) );
826 return 0;
827 }
828
829 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
830
831 if( routerTool && routerTool->IsToolActive()
832 && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
833 {
834 int widthIndex = (int) bds.GetDiffPairIndex() + 1;
835
836 // If we go past the last track width entry in the list, start over at the beginning
837 if( widthIndex >= (int) bds.m_DiffPairDimensionsList.size() )
838 widthIndex = 0;
839
840 bds.SetDiffPairIndex( widthIndex );
841 bds.UseCustomDiffPairDimensions( false );
842
844 }
845 else
846 {
847 int widthIndex = (int) bds.GetTrackWidthIndex();
848
849 if( routerTool && routerTool->IsToolActive()
852 {
853 bds.m_TempOverrideTrackWidth = true;
854 }
855 else
856 {
857 widthIndex++;
858 }
859
860 // If we go past the last track width entry in the list, start over at the beginning
861 if( widthIndex >= (int) bds.m_TrackWidthList.size() )
862 widthIndex = 0;
863
864 bds.SetTrackWidthIndex( widthIndex );
865 bds.UseCustomTrackViaSize( false );
866
868 }
869
870 return 0;
871}
872
873
875{
876 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
878
880 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
881 {
882 BOARD_COMMIT commit( this );
883
884 for( EDA_ITEM* item : selection )
885 {
886 if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
887 {
888 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
889
890 for( int i = (int) bds.m_TrackWidthList.size() - 1; i >= 0; --i )
891 {
892 int candidate = bds.m_NetSettings->GetDefaultNetclass()->GetTrackWidth();
893
894 if( i > 0 )
895 candidate = bds.m_TrackWidthList[ i ];
896
897 if( candidate < track->GetWidth() )
898 {
899 commit.Modify( track );
900 track->SetWidth( candidate );
901 break;
902 }
903 }
904 }
905 }
906
907 commit.Push( _( "Decrease Track Width" ) );
908 return 0;
909 }
910
911 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
912
913 if( routerTool && routerTool->IsToolActive()
914 && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
915 {
916 int widthIndex = (int) bds.GetDiffPairIndex() - 1;
917
918 // If we get to the lowest entry start over at the highest
919 if( widthIndex < 0 )
920 widthIndex = (int) bds.m_DiffPairDimensionsList.size() - 1;
921
922 bds.SetDiffPairIndex( widthIndex );
923 bds.UseCustomDiffPairDimensions( false );
924
926 }
927 else
928 {
929 int widthIndex = (int) bds.GetTrackWidthIndex();
930
931 if( routerTool && routerTool->IsToolActive()
934 {
935 bds.m_TempOverrideTrackWidth = true;
936 }
937 else
938 {
939 widthIndex--;
940 }
941
942 // If we get to the lowest entry start over at the highest
943 if( widthIndex < 0 )
944 widthIndex = (int) bds.m_TrackWidthList.size() - 1;
945
946 bds.SetTrackWidthIndex( widthIndex );
947 bds.UseCustomTrackViaSize( false );
948
950 }
951
952 return 0;
953}
954
955
957{
958 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
960
962 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
963 {
964 BOARD_COMMIT commit( this );
965
966 for( EDA_ITEM* item : selection )
967 {
968 if( item->Type() == PCB_VIA_T )
969 {
970 PCB_VIA* via = static_cast<PCB_VIA*>( item );
971
972 for( int i = 0; i < (int) bds.m_ViasDimensionsList.size(); ++i )
973 {
974 VIA_DIMENSION dims( bds.m_NetSettings->GetDefaultNetclass()->GetViaDiameter(),
975 bds.m_NetSettings->GetDefaultNetclass()->GetViaDrill() );
976
977 if( i> 0 )
978 dims = bds.m_ViasDimensionsList[ i ];
979
980 // TODO(JE) padstacks
981 if( dims.m_Diameter > via->GetWidth( PADSTACK::ALL_LAYERS ) )
982 {
983 commit.Modify( via );
984 via->SetWidth( PADSTACK::ALL_LAYERS, dims.m_Diameter );
985 via->SetDrill( dims.m_Drill );
986 break;
987 }
988 }
989 }
990 }
991
992 commit.Push( _( "Increase Via Size" ) );
993 }
994 else
995 {
996 int sizeIndex = (int) bds.GetViaSizeIndex() + 1;
997
998 // If we go past the last via entry in the list, start over at the beginning
999 if( sizeIndex >= (int) bds.m_ViasDimensionsList.size() )
1000 sizeIndex = 0;
1001
1002 bds.SetViaSizeIndex( sizeIndex );
1003 bds.UseCustomTrackViaSize( false );
1004
1006 }
1007
1008 return 0;
1009}
1010
1011
1013{
1014 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
1016
1018 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
1019 {
1020 BOARD_COMMIT commit( this );
1021
1022 for( EDA_ITEM* item : selection )
1023 {
1024 if( item->Type() == PCB_VIA_T )
1025 {
1026 PCB_VIA* via = static_cast<PCB_VIA*>( item );
1027
1028 for( int i = (int) bds.m_ViasDimensionsList.size() - 1; i >= 0; --i )
1029 {
1030 VIA_DIMENSION dims( bds.m_NetSettings->GetDefaultNetclass()->GetViaDiameter(),
1031 bds.m_NetSettings->GetDefaultNetclass()->GetViaDrill() );
1032
1033 if( i > 0 )
1034 dims = bds.m_ViasDimensionsList[ i ];
1035
1036 // TODO(JE) padstacks
1037 if( dims.m_Diameter < via->GetWidth( PADSTACK::ALL_LAYERS ) )
1038 {
1039 commit.Modify( via );
1040 via->SetWidth( PADSTACK::ALL_LAYERS, dims.m_Diameter );
1041 via->SetDrill( dims.m_Drill );
1042 break;
1043 }
1044 }
1045 }
1046 }
1047
1048 commit.Push( "Decrease Via Size" );
1049 }
1050 else
1051 {
1052 int sizeIndex = 0; // Assume we only have a single via size entry
1053
1054 // If there are more, cycle through them backwards
1055 if( bds.m_ViasDimensionsList.size() > 0 )
1056 {
1057 sizeIndex = (int) bds.GetViaSizeIndex() - 1;
1058
1059 // If we get to the lowest entry start over at the highest
1060 if( sizeIndex < 0 )
1061 sizeIndex = (int) bds.m_ViasDimensionsList.size() - 1;
1062 }
1063
1064 bds.SetViaSizeIndex( sizeIndex );
1065 bds.UseCustomTrackViaSize( false );
1066
1068 }
1069
1070 return 0;
1071}
1072
1073
1075{
1076 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
1077
1078 if( bds.UseCustomTrackViaSize() )
1079 {
1080 bds.UseCustomTrackViaSize( false );
1081 bds.m_UseConnectedTrackWidth = true;
1082 }
1083 else
1084 {
1086 }
1087
1088 return 0;
1089}
1090
1091
1093{
1094 if( m_inPlaceFootprint )
1095 return 0;
1096
1098
1099 FOOTPRINT* fp = aEvent.Parameter<FOOTPRINT*>();
1100 bool fromOtherCommand = fp != nullptr;
1102 BOARD_COMMIT commit( m_frame );
1103 BOARD* board = getModel<BOARD>();
1104 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
1105
1107
1108 TOOL_EVENT pushedEvent = aEvent;
1109 m_frame->PushTool( aEvent );
1110
1111 auto setCursor =
1112 [&]()
1113 {
1114 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
1115 };
1116
1117 auto cleanup =
1118 [&] ()
1119 {
1121 commit.Revert();
1122
1123 if( fromOtherCommand )
1124 {
1126
1127 if( undo )
1128 {
1131 delete undo;
1132 }
1133 }
1134
1135 fp = nullptr;
1136 m_placingFootprint = false;
1137 };
1138
1139 Activate();
1140 // Must be done after Activate() so that it gets set into the correct context
1141 controls->ShowCursor( true );
1142 // Set initial cursor
1143 setCursor();
1144
1145 VECTOR2I cursorPos = controls->GetCursorPosition();
1146 bool ignorePrimePosition = false;
1147 bool reselect = false;
1148
1149 // Prime the pump
1150 if( fp )
1151 {
1152 m_placingFootprint = true;
1153 fp->SetPosition( cursorPos );
1156 }
1157 else if( aEvent.HasPosition() )
1158 {
1159 m_toolMgr->PrimeTool( aEvent.Position() );
1160 }
1161 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
1162 {
1163 m_toolMgr->PrimeTool( { 0, 0 } );
1164 ignorePrimePosition = true;
1165 }
1166
1167 // Main loop: keep receiving events
1168 while( TOOL_EVENT* evt = Wait() )
1169 {
1170 setCursor();
1171 cursorPos = controls->GetCursorPosition( !evt->DisableGridSnapping() );
1172
1173 if( reselect && fp )
1175
1176 if( evt->IsCancelInteractive() || ( fp && evt->IsAction( &ACTIONS::undo ) ) )
1177 {
1178 if( fp )
1179 {
1180 cleanup();
1181 }
1182 else
1183 {
1184 m_frame->PopTool( pushedEvent );
1185 break;
1186 }
1187 }
1188 else if( evt->IsActivate() )
1189 {
1190 if( fp )
1191 cleanup();
1192
1193 if( evt->IsMoveTool() )
1194 {
1195 // leave ourselves on the stack so we come back after the move
1196 break;
1197 }
1198 else
1199 {
1200 frame()->PopTool( pushedEvent );
1201 break;
1202 }
1203 }
1204 else if( evt->IsClick( BUT_LEFT ) )
1205 {
1206 if( !fp )
1207 {
1208 // Pick the footprint to be placed
1210
1211 if( fp == nullptr )
1212 continue;
1213
1214 // If we started with a hotkey which has a position then warp back to that.
1215 // Otherwise update to the current mouse position pinned inside the autoscroll
1216 // boundaries.
1217 if( evt->IsPrime() && !ignorePrimePosition )
1218 {
1219 cursorPos = evt->Position();
1220 getViewControls()->WarpMouseCursor( cursorPos, true );
1221 }
1222 else
1223 {
1225 cursorPos = getViewControls()->GetMousePosition();
1226 }
1227
1228 m_placingFootprint = true;
1229
1230 fp->SetLink( niluuid );
1231
1232 fp->SetFlags( IS_NEW ); // whatever
1233
1234 // Set parent so that clearance can be loaded
1235 fp->SetParent( board );
1237
1238 for( PAD* pad : fp->Pads() )
1239 {
1240 pad->SetLocalRatsnestVisible( m_frame->GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
1241
1242 // Pads in the library all have orphaned nets. Replace with Default.
1243 pad->SetNetCode( 0 );
1244 }
1245
1246 // Put it on FRONT layer,
1247 // (Can be stored flipped if the lib is an archive built from a board)
1248 if( fp->IsFlipped() )
1250
1251 fp->SetOrientation( ANGLE_0 );
1252 fp->SetPosition( cursorPos );
1253
1254 commit.Add( fp );
1256
1258 }
1259 else
1260 {
1262 commit.Push( _( "Place Footprint" ) );
1263 fp = nullptr; // to indicate that there is no footprint that we currently modify
1264 m_placingFootprint = false;
1265 }
1266 }
1267 else if( evt->IsClick( BUT_RIGHT ) )
1268 {
1269 m_menu->ShowContextMenu( selection() );
1270 }
1271 else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
1272 {
1273 fp->SetPosition( cursorPos );
1274 selection().SetReferencePoint( cursorPos );
1275 getView()->Update( &selection() );
1276 getView()->Update( fp );
1277 }
1278 else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) )
1279 {
1280 // Calling 'Properties' action clears the selection, so we need to restore it
1281 reselect = true;
1282 }
1283 else if( fp && ( ZONE_FILLER_TOOL::IsZoneFillAction( evt )
1284 || evt->IsAction( &ACTIONS::redo ) ) )
1285 {
1286 wxBell();
1287 }
1288 else
1289 {
1290 evt->SetPassEvent();
1291 }
1292
1293 // Enable autopanning and cursor capture only when there is a footprint to be placed
1294 controls->SetAutoPan( fp != nullptr );
1295 controls->CaptureCursor( fp != nullptr );
1296 }
1297
1298 controls->SetAutoPan( false );
1299 controls->CaptureCursor( false );
1300 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
1301
1302 return 0;
1303}
1304
1305
1307{
1308 return modifyLockSelected( TOGGLE );
1309}
1310
1311
1313{
1314 return modifyLockSelected( ON );
1315}
1316
1317
1319{
1320 return modifyLockSelected( OFF );
1321}
1322
1323
1325{
1327 const PCB_SELECTION& selection = selTool->GetSelection();
1328 BOARD_COMMIT commit( m_frame );
1329
1330 if( selection.Empty() )
1332
1333 // Resolve TOGGLE mode
1334 if( aMode == TOGGLE )
1335 {
1336 aMode = ON;
1337
1338 for( EDA_ITEM* item : selection )
1339 {
1340 if( !item->IsBOARD_ITEM() )
1341 continue;
1342
1343 if( static_cast<BOARD_ITEM*>( item )->IsLocked() )
1344 {
1345 aMode = OFF;
1346 break;
1347 }
1348 }
1349 }
1350
1351 for( EDA_ITEM* item : selection )
1352 {
1353 if( !item->IsBOARD_ITEM() )
1354 continue;
1355
1356 BOARD_ITEM* const board_item = static_cast<BOARD_ITEM*>( item );
1357
1358 // Disallow locking free pads - it's confusing and not persisted
1359 // through save/load anyway.
1360 if( board_item->Type() == PCB_PAD_T )
1361 continue;
1362
1363 EDA_GROUP* parent_group = board_item->GetParentGroup();
1364
1365 if( parent_group && parent_group->AsEdaItem()->Type() == PCB_GENERATOR_T )
1366 {
1367 PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( parent_group );
1368
1369 if( generator && commit.GetStatus( generator ) != CHT_MODIFY )
1370 {
1371 commit.Modify( generator );
1372
1373 if( aMode == ON )
1374 generator->SetLocked( true );
1375 else
1376 generator->SetLocked( false );
1377 }
1378 }
1379
1380 commit.Modify( board_item );
1381
1382 if( aMode == ON )
1383 board_item->SetLocked( true );
1384 else
1385 board_item->SetLocked( false );
1386 }
1387
1388 if( !commit.Empty() )
1389 {
1390 commit.Push( aMode == ON ? _( "Lock" ) : _( "Unlock" ) );
1391
1393 m_frame->OnModify();
1394 }
1395
1396 return 0;
1397}
1398
1399
1400static bool mergeZones( EDA_DRAW_FRAME* aFrame, BOARD_COMMIT& aCommit,
1401 std::vector<ZONE*>& aOriginZones, std::vector<ZONE*>& aMergedZones )
1402{
1403 aCommit.Modify( aOriginZones[0] );
1404
1405 aOriginZones[0]->Outline()->ClearArcs();
1406
1407 for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1408 {
1409 SHAPE_POLY_SET otherOutline = aOriginZones[i]->Outline()->CloneDropTriangulation();
1410 otherOutline.ClearArcs();
1411 aOriginZones[0]->Outline()->BooleanAdd( otherOutline );
1412 }
1413
1414 aOriginZones[0]->Outline()->Simplify();
1415
1416 // We should have one polygon, possibly with holes. If we end up with two polygons (either
1417 // because the intersection was a single point or because the intersection was within one of
1418 // the zone's holes) then we can't merge.
1419 if( aOriginZones[0]->Outline()->IsSelfIntersecting() || aOriginZones[0]->Outline()->OutlineCount() > 1 )
1420 {
1421 DisplayErrorMessage( aFrame, _( "Zones have insufficient overlap for merging." ) );
1422 aCommit.Revert();
1423 return false;
1424 }
1425
1426 for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1427 aCommit.Remove( aOriginZones[i] );
1428
1429 aMergedZones.push_back( aOriginZones[0] );
1430
1431 aOriginZones[0]->SetLocalFlags( 1 );
1432 aOriginZones[0]->HatchBorder();
1433 aOriginZones[0]->CacheTriangulation();
1434
1435 return true;
1436}
1437
1438
1440{
1441 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1442 BOARD* board = getModel<BOARD>();
1443 BOARD_COMMIT commit( m_frame );
1444
1445 if( selection.Size() < 2 )
1446 return 0;
1447
1448 int netcode = -1;
1449
1450 ZONE* firstZone = nullptr;
1451 std::vector<ZONE*> toMerge, merged;
1452
1453 for( EDA_ITEM* item : selection )
1454 {
1455 ZONE* curr_area = dynamic_cast<ZONE*>( item );
1456
1457 if( !curr_area )
1458 continue;
1459
1460 if( !firstZone )
1461 firstZone = curr_area;
1462
1463 netcode = curr_area->GetNetCode();
1464
1465 if( firstZone->GetNetCode() != netcode )
1466 {
1467 wxLogMessage( _( "Some zone netcodes did not match and were not merged." ) );
1468 continue;
1469 }
1470
1471 if( curr_area->GetAssignedPriority() != firstZone->GetAssignedPriority() )
1472 {
1473 wxLogMessage( _( "Some zone priorities did not match and were not merged." ) );
1474 continue;
1475 }
1476
1477 if( curr_area->GetIsRuleArea() != firstZone->GetIsRuleArea() )
1478 {
1479 wxLogMessage( _( "Some zones were rule areas and were not merged." ) );
1480 continue;
1481 }
1482
1483 if( curr_area->GetLayerSet() != firstZone->GetLayerSet() )
1484 {
1485 wxLogMessage( _( "Some zone layer sets did not match and were not merged." ) );
1486 continue;
1487 }
1488
1489 bool intersects = curr_area == firstZone;
1490
1491 for( ZONE* candidate : toMerge )
1492 {
1493 if( intersects )
1494 break;
1495
1496 if( board->TestZoneIntersection( curr_area, candidate ) )
1497 intersects = true;
1498 }
1499
1500 if( !intersects )
1501 {
1502 wxLogMessage( _( "Some zones did not intersect and were not merged." ) );
1503 continue;
1504 }
1505
1506 toMerge.push_back( curr_area );
1507 }
1508
1510
1511 if( !toMerge.empty() )
1512 {
1513 if( mergeZones( m_frame, commit, toMerge, merged ) )
1514 {
1515 commit.Push( _( "Merge Zones" ) );
1516
1517 for( EDA_ITEM* item : merged )
1519 }
1520 }
1521
1522 return 0;
1523}
1524
1525
1527{
1529 const PCB_SELECTION& selection = selTool->GetSelection();
1530
1531 // because this pops up the zone editor, it would be confusing to handle multiple zones,
1532 // so just handle single selections containing exactly one zone
1533 if( selection.Size() != 1 )
1534 return 0;
1535
1536 ZONE* oldZone = dynamic_cast<ZONE*>( selection[0] );
1537
1538 if( !oldZone )
1539 return 0;
1540
1541 ZONE_SETTINGS zoneSettings;
1542 zoneSettings << *oldZone;
1543 int dialogResult;
1544
1545 if( oldZone->GetIsRuleArea() )
1546 dialogResult = InvokeRuleAreaEditor( m_frame, &zoneSettings, board() );
1547 else if( oldZone->IsOnCopperLayer() )
1548 dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
1549 else
1550 dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1551
1552 if( dialogResult != wxID_OK )
1553 return 0;
1554
1555 // duplicate the zone
1556 BOARD_COMMIT commit( m_frame );
1557
1558 std::unique_ptr<ZONE> newZone = std::make_unique<ZONE>( *oldZone );
1559 newZone->ClearSelected();
1560 newZone->UnFill();
1561 zoneSettings.ExportSetting( *newZone );
1562
1563 // If the new zone is on the same layer(s) as the initial zone,
1564 // offset it a bit so it can more easily be picked.
1565 if( oldZone->GetLayerSet() == zoneSettings.m_Layers )
1566 newZone->Move( VECTOR2I( pcbIUScale.IU_PER_MM, pcbIUScale.IU_PER_MM ) );
1567
1568 commit.Add( newZone.release() );
1569 commit.Push( _( "Duplicate Zone" ) );
1570
1571 return 0;
1572}
1573
1574
1576{
1577 doCrossProbePcbToSch( aEvent, false );
1578 return 0;
1579}
1580
1581
1583{
1584 doCrossProbePcbToSch( aEvent, true );
1585 return 0;
1586}
1587
1588
1590{
1591 // Don't get in an infinite loop PCB -> SCH -> PCB -> SCH -> ...
1593 return;
1594
1596 const PCB_SELECTION& selection = selTool->GetSelection();
1597 EDA_ITEM* focusItem = nullptr;
1598
1599 if( aEvent.Matches( EVENTS::PointSelectedEvent ) )
1600 focusItem = selection.GetLastAddedItem();
1601
1602 m_frame->SendSelectItemsToSch( selection.GetItems(), focusItem, aForce );
1603
1604 // Update 3D viewer highlighting
1605 m_frame->Update3DView( false, frame()->GetPcbNewSettings()->m_Display.m_Live3DRefresh );
1606}
1607
1608
1610{
1612
1613 const PCB_SELECTION& selection = selectionTool->RequestSelection(
1614 []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1615 {
1616 // Iterate from the back so we don't have to worry about removals.
1617 for( int i = aCollector.GetCount() - 1; i >= 0; --i )
1618 {
1619 if( !dynamic_cast<BOARD_CONNECTED_ITEM*>( aCollector[ i ] ) )
1620 aCollector.Remove( aCollector[ i ] );
1621 }
1622 },
1623 true /* prompt user regarding locked items */ );
1624
1625 int netCode = -1;
1626 wxString netName;
1627
1628 for( EDA_ITEM* item : selection )
1629 {
1630 NETINFO_ITEM* net = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNet();
1631
1632 if( !net->HasAutoGeneratedNetname() )
1633 {
1634 netCode = net->GetNetCode();
1635 netName = net->GetNetname();
1636 break;
1637 }
1638 }
1639
1640 if( netName.IsEmpty() )
1641 {
1642 m_frame->ShowInfoBarError( _( "Selection contains no items with labeled nets." ) );
1643 return 0;
1644 }
1645
1646 selectionTool->ClearSelection();
1648 canvas()->ForceRefresh();
1649
1650 DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, board()->GetNetClassAssignmentCandidates(),
1651 [this]( const std::vector<wxString>& aNetNames )
1652 {
1654 selTool->ClearSelection();
1655
1656 for( const wxString& curr_netName : aNetNames )
1657 {
1658 int curr_netCode = board()->GetNetInfo().GetNetItem( curr_netName )->GetNetCode();
1659
1660 if( curr_netCode > 0 )
1661 selTool->SelectAllItemsOnNet( curr_netCode );
1662 }
1663
1664 canvas()->ForceRefresh();
1666 } );
1667
1668 if( dlg.ShowModal() == wxID_OK )
1669 {
1671 // Refresh UI that depends on netclasses, such as the properties panel
1673 }
1674
1675 return 0;
1676}
1677
1678
1680{
1683
1684 if( selection.Empty() )
1685 {
1686 // Giant hack: by default we assign Edit Table to the same hotkey, so give the table
1687 // tool a chance to handle it if we can't.
1689 tableTool->EditTable( aEvent );
1690
1691 return 0;
1692 }
1693
1695
1696 if( !fp )
1697 return 0;
1698
1699 PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1700
1701 if( KIWAY_PLAYER* frame = editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ) )
1702 {
1703 FOOTPRINT_EDIT_FRAME* fp_editor = static_cast<FOOTPRINT_EDIT_FRAME*>( frame );
1704
1706 fp_editor->LoadFootprintFromBoard( fp );
1707 else if( aEvent.IsAction( &PCB_ACTIONS::editLibFpInFpEditor ) )
1708 fp_editor->LoadFootprintFromLibrary( fp->GetFPID() );
1709
1710 fp_editor->Show( true );
1711 fp_editor->Raise(); // Iconize( false );
1712 }
1713
1714 if( selection.IsHover() )
1716
1717 return 0;
1718}
1719
1720
1722 EDA_ITEM* originViewItem, const VECTOR2D& aPosition )
1723{
1724 aFrame->GetDesignSettings().SetAuxOrigin( VECTOR2I( aPosition ) );
1725 originViewItem->SetPosition( aPosition );
1726 aView->MarkDirty();
1727 aFrame->OnModify();
1728}
1729
1730
1732{
1734 {
1735 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::GRIDORIGIN );
1737 return 0;
1738 }
1739
1740 if( aEvent.IsAction( &PCB_ACTIONS::drillSetOrigin ) )
1741 {
1742 VECTOR2I origin = aEvent.Parameter<VECTOR2I>();
1743 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::GRIDORIGIN );
1744 DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), origin );
1745 return 0;
1746 }
1747
1749
1750 // Deactivate other tools; particularly important if another PICKER is currently running
1751 Activate();
1752
1753 picker->SetCursor( KICURSOR::PLACE );
1754 picker->ClearHandlers();
1755
1756 picker->SetClickHandler(
1757 [this] ( const VECTOR2D& pt ) -> bool
1758 {
1759 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::DRILLORIGIN );
1761 return false; // drill origin is a one-shot; don't continue with tool
1762 } );
1763
1765
1766 return 0;
1767}
1768
1769
1771{
1780
1785
1793
1794 if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist && m_frame && m_frame->GetExportNetlistAction() )
1796
1805
1812
1813 // Track & via size control
1819
1820 // Zone actions
1823
1824 // Placing tools
1829
1832
1833 // Cross-select
1839
1840 // Other
1844
1846
1857}
1858
const char * name
Definition: DXF_plotter.cpp:62
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:112
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
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:261
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:224
static TOOL_ACTION saveAs
Definition: actions.h:59
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: actions.h:214
static TOOL_ACTION pickerTool
Definition: actions.h:250
static TOOL_ACTION findPrevious
Definition: actions.h:119
static TOOL_ACTION plot
Definition: actions.h:65
static TOOL_ACTION open
Definition: actions.h:57
static TOOL_ACTION findNext
Definition: actions.h:118
static TOOL_ACTION pageSettings
Definition: actions.h:63
static TOOL_ACTION showSearch
Definition: actions.h:115
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:262
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: actions.h:221
static TOOL_ACTION showProperties
Definition: actions.h:263
static TOOL_ACTION doNew
Definition: actions.h:54
static TOOL_ACTION saveCopy
Definition: actions.h:60
static TOOL_ACTION refreshPreview
Definition: actions.h:156
static TOOL_ACTION find
Definition: actions.h:116
Define the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:92
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:78
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
TOOL_INTERACTIVE * m_tool
Creator of the menu.
Definition: action_menu.h:278
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.
void SetDiffPairIndex(unsigned aIndex)
std::shared_ptr< NET_SETTINGS > m_NetSettings
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
void SetTrackWidthIndex(unsigned aIndex)
Set the current track width list index to aIndex.
void SetAuxOrigin(const VECTOR2I &aOrigin)
void SetViaSizeIndex(unsigned aIndex)
Set the current via size list index to aIndex.
unsigned GetTrackWidthIndex() const
unsigned GetViaSizeIndex() const
void UseCustomDiffPairDimensions(bool aEnabled)
Enables/disables custom differential pair dimensions.
std::vector< int > m_TrackWidthList
unsigned GetDiffPairIndex() const
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)
int RescueAutosave(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 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 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:79
void SetLocked(bool aLocked) override
Definition: board_item.h:323
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:317
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:934
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition: board.cpp:2657
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:1147
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
Definition: board.cpp:1504
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:2099
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:2234
const wxString & GetFileName() const
Definition: board.h:354
bool TestZoneIntersection(ZONE *aZone1, ZONE *aZone2)
Test for intersection of 2 copper areas.
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:91
bool Empty() const
Definition: commit.h:152
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:107
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Definition: commit.h:79
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
Definition: commit.cpp:142
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:100
void AddNet(const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction, const wxString &aPinType)
Definition: pcb_netlist.h:120
void SetFields(nlohmann::ordered_map< wxString, wxString > aFields)
Definition: pcb_netlist.h:148
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.
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 ShowQuasiModal()
int ShowModal() override
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...
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
The base class for create windows for drawing purpose.
void ScriptingConsoleEnableDisable()
Toggle the scripting console visibility.
virtual void UpdateMsgPanel()
Redraw the message panel.
void ForceRefresh()
Force a redraw.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
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:273
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:142
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:79
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *sTool)
A selection filter which prunes the selection to contain only items of type #PCB_MODULE_T.
Definition: edit_tool.cpp:3186
static const TOOL_EVENT ClearedEvent
Definition: actions.h:344
static const TOOL_EVENT SelectedEvent
Definition: actions.h:342
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:349
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:341
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:343
Used for text file output.
Definition: richio.h:491
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
Definition: footprint.cpp:2513
void SetLink(const KIID &aLink)
Definition: footprint.h:844
ZONES & Zones()
Definition: footprint.h:215
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2595
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:663
std::deque< PAD * > & Pads()
Definition: footprint.h:209
bool IsFlipped() const
Definition: footprint.h:400
const LIB_ID & GetFPID() const
Definition: footprint.h:251
PCB_FIELD & Reference()
Definition: footprint.h:664
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: footprint.cpp:2454
GROUPS & Groups()
Definition: footprint.h:218
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly) const
Populate a std::vector with PCB_TEXTs.
Definition: footprint.cpp:638
const wxString & GetValue() const
Definition: footprint.h:649
const wxString & GetReference() const
Definition: footprint.h:627
const KIID_PATH & GetPath() const
Definition: footprint.h:266
VECTOR2I GetPosition() const override
Definition: footprint.h:227
DRAWINGS & GraphicalItems()
Definition: footprint.h:212
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.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
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
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:1571
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.
Definition: kiway_holder.h:55
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:395
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:499
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)
Handle the data for a net.
Definition: netinfo.h:56
bool HasAutoGeneratedNetname()
Definition: netinfo.h:129
const wxString & GetNetname() const
Definition: netinfo.h:114
int GetNetCode() const
Definition: netinfo.h:108
NETINFO_ITEM * GetNetItem(int aNetCode) const
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:274
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition: padstack.h:145
Definition: pad.h:54
DISPLAY_OPTIONS m_Display
FLIP_DIRECTION m_FlipDirection
static TOOL_ACTION zonesManager
Definition: pcb_actions.h:454
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:423
static TOOL_ACTION exportGenCAD
Definition: pcb_actions.h:425
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:392
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:451
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:380
static TOOL_ACTION generateDrillFiles
Definition: pcb_actions.h:417
static TOOL_ACTION exportVRML
Definition: pcb_actions.h:426
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:422
static TOOL_ACTION exportCmpFile
Definition: pcb_actions.h:429
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:386
static TOOL_ACTION exportSpecctraDSN
Definition: pcb_actions.h:414
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:379
static TOOL_ACTION autoTrackWidth
Definition: pcb_actions.h:384
static TOOL_ACTION generateIPC2581File
Definition: pcb_actions.h:420
static TOOL_ACTION getAndPlace
Find an item and start moving.
Definition: pcb_actions.h:583
static TOOL_ACTION generateODBPPFile
Definition: pcb_actions.h:421
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:212
static TOOL_ACTION openNonKicadBoard
Definition: pcb_actions.h:407
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:382
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:391
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:168
static TOOL_ACTION editFpInFpEditor
Definition: pcb_actions.h:448
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:542
static TOOL_ACTION drillResetOrigin
Definition: pcb_actions.h:551
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:381
static TOOL_ACTION zoneUnfill
Definition: pcb_actions.h:394
static TOOL_ACTION generatePosFile
Definition: pcb_actions.h:418
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:550
static TOOL_ACTION assignNetClass
Definition: pcb_actions.h:388
static TOOL_ACTION repairBoard
Definition: pcb_actions.h:556
static TOOL_ACTION exportSTEP
Definition: pcb_actions.h:428
static TOOL_ACTION showNetInspector
Definition: pcb_actions.h:452
static TOOL_ACTION generateGerbers
Definition: pcb_actions.h:416
static TOOL_ACTION generateReportFile
Definition: pcb_actions.h:419
static TOOL_ACTION exportHyperlynx
Definition: pcb_actions.h:430
static TOOL_ACTION exportIDF
Definition: pcb_actions.h:427
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:399
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:411
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:213
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:409
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:553
static TOOL_ACTION showDesignBlockPanel
Definition: pcb_actions.h:460
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:395
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
Definition: pcb_actions.h:82
static TOOL_ACTION editLibFpInFpEditor
Definition: pcb_actions.h:449
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:396
static TOOL_ACTION drillSetOrigin
Definition: pcb_actions.h:552
static TOOL_ACTION unlock
Definition: pcb_actions.h:544
static TOOL_ACTION exportFootprints
Definition: pcb_actions.h:408
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:216
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:453
static TOOL_ACTION rescueAutosave
Definition: pcb_actions.h:406
static TOOL_ACTION importSpecctraSession
Definition: pcb_actions.h:413
static TOOL_ACTION selectOnSchematic
Select symbols/pins on schematic corresponding to selected footprints/pads.
Definition: pcb_actions.h:100
static TOOL_ACTION lock
Definition: pcb_actions.h:543
Common, abstract interface for edit frames.
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
Definition: undo_redo.cpp:164
void ClearListAndDeleteItems(PICKED_ITEMS_LIST *aList)
Definition: undo_redo.cpp:657
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
Definition: undo_redo.cpp:670
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Used in undo or redo command.
Definition: undo_redo.cpp:263
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.
PCBNEW_SETTINGS * GetPcbNewSettings() const
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
FOOTPRINT * SelectFootprintFromLibrary(LIB_ID aPreselect=LIB_ID())
Open a dialog to select a footprint.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Return the BOARD_DESIGN_SETTINGS for the open project.
virtual void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings)
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
The main frame for Pcbnew.
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.
TOOL_ACTION * GetExportNetlistAction()
void OnModify() override
Must be called after a board change to set the modified flag.
bool SaveBoard(bool aSaveAs=false, bool aSaveCopy=false)
void ExportFootprintsToLibrary(bool aStoreInNewLib, const wxString &aLibName=wxEmptyString, wxString *aLibPath=nullptr)
Save footprints in a library:
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
void ShowFindDialog()
Show the Find dialog.
bool FetchNetlistFromSchematic(NETLIST &aNetlist, const wxString &aAnnotateMessage)
void SendSelectItemsToSch(const std::deque< EDA_ITEM * > &aItems, EDA_ITEM *aFocusItem, bool aForce)
Send a message to the schematic editor to try to find schematic counterparts of specified PCB items a...
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:53
void SetLocked(bool aLocked) override
Definition: pcb_group.cpp:178
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, bool aConfirmLockedItems=false)
Return the current selection, filtered according to aClientFilter.
int ClearSelection(const TOOL_EVENT &aEvent)
PCB_SELECTION & GetSelection()
void SelectAllItemsOnNet(int aNetCode, bool aSelect=true)
Select all items with the given net code.
T * frame() const
KIGFX::VIEW_CONTROLS * controls() const
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:145
virtual int GetWidth() const
Definition: pcb_track.h:146
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:565
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 ClearHandlers()
Definition: picker_tool.h:68
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
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:143
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.
T * FirstOfKind() const
Definition: selection.h:193
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:126
EDA_ITEM * GetLastAddedItem() const
Definition: selection.h:131
bool IsHover() const
Definition: selection.h:89
int Size() const
Returns the number of selected parts.
Definition: selection.h:121
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.cpp:178
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:115
Represent a set of closed polygons.
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
virtual void PopTool(const TOOL_EVENT &aEvent)
Pops a tool from the stack.
virtual void PushTool(const TOOL_EVENT &aEvent)
NB: the definition of "tool" is different at the user level.
bool ToolStackIsEmpty()
Definition: tools_holder.h:125
bool IsCurrentTool(const TOOL_ACTION &aAction) const
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
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:168
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:257
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:389
const VECTOR2D Position() const
Return mouse cursor position in world coordinates.
Definition: tool_event.h:290
bool IsReactivate() const
Control whether the tool is first being pushed to the stack or being reactivated after a pause.
Definition: tool_event.h:270
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:82
T Parameter() const
Return a parameter assigned to the event.
Definition: tool_event.h:465
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.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
void PrimeTool(const VECTOR2D &aPosition)
"Prime" a tool by sending a cursor left-click event with the mouse position set to the passed in posi...
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:235
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.
Definition: zone_settings.h:88
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:704
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:499
unsigned GetAssignedPriority() const
Definition: zone.h:126
@ CHT_MODIFY
Definition: commit.h:45
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:222
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:194
This file is part of the common library.
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, 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
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Definition: gestfich.cpp:143
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:39
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:902
see class PGM_BASE
@ LAST_PATH_SPECCTRADSN
Definition: project_file.h:55
std::vector< FAB_LAYER_COLOR > dummy
const double IU_PER_MM
Definition: base_units.h:76
const double IU_PER_MILS
Definition: base_units.h:77
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
@ 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_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:107
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695
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.