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, see <https://www.gnu.org/licenses/>.
20 */
21
25
26#include <algorithm>
27#include <climits>
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 <collectors.h>
42#include <pcb_generator.h>
43#include <pcb_grid_item.h>
44#include <footprint.h>
45#include <pad.h>
46#include <pcb_target.h>
47#include <pcb_track.h>
48#include <zone.h>
49#include <pcb_marker.h>
50#include <confirm.h>
55#include <dialog_plot.h>
57#include <kiface_base.h>
58#include <kiway.h>
60#include <origin_viewitem.h>
61#include <pcb_edit_frame.h>
62#include <pcbnew_id.h>
63#include <project.h>
64#include <project/project_file.h> // LAST_PATH_TYPE
66#include <kiplatform/ui.h>
67#include <pcbnew_settings.h>
68#include <tool/tool_manager.h>
69#include <tool/tool_event.h>
70#include <tools/drawing_tool.h>
71#include <tools/pcb_actions.h>
76#include <tools/edit_tool.h>
79#include <richio.h>
80#include <router/router_tool.h>
81#include <view/view_controls.h>
82#include <view/view_group.h>
86#include <wx/filedlg.h>
87#include <wx/msgdlg.h>
88#include <wx/log.h>
89
91
92using namespace std::placeholders;
93
94
95namespace
96{
97
98using ZonePriorityMap = std::map<unsigned, std::vector<ZONE*>>;
99
100
101std::vector<ZONE*> getOverlappingZones( BOARD* aBoard, ZONE* aZone )
102{
103 std::vector<ZONE*> overlapping;
104 BOX2I bbox = aZone->GetBoundingBox();
105
106 for( ZONE* candidate : aBoard->Zones() )
107 {
108 if( candidate == aZone )
109 continue;
110
111 if( candidate->GetIsRuleArea() || candidate->IsTeardropArea() )
112 continue;
113
114 if( !( candidate->GetLayerSet() & aZone->GetLayerSet() ).any() )
115 continue;
116
117 if( !candidate->GetBoundingBox().Intersects( bbox ) )
118 continue;
119
120 // Check edge collision and containment (one zone entirely inside another)
121 SHAPE_POLY_SET aOutline = aZone->GetBoardOutline();
122 SHAPE_POLY_SET candidateOutline = candidate->GetBoardOutline();
123
124 if( aOutline.Collide( &candidateOutline )
125 || ( candidateOutline.TotalVertices() > 0 && aOutline.Contains( candidateOutline.CVertex( 0 ) ) )
126 || ( aOutline.TotalVertices() > 0 && candidateOutline.Contains( aOutline.CVertex( 0 ) ) ) )
127 {
128 overlapping.push_back( candidate );
129 }
130 }
131
132 return overlapping;
133}
134
135
136ZonePriorityMap buildPriorityMap( BOARD* aBoard, ZONE* aExclude )
137{
138 ZonePriorityMap byPriority;
139
140 for( ZONE* z : aBoard->Zones() )
141 {
142 if( z == aExclude || z->GetIsRuleArea() || z->IsTeardropArea() )
143 continue;
144
145 byPriority[z->GetAssignedPriority()].push_back( z );
146 }
147
148 return byPriority;
149}
150
151
164std::vector<ZONE*> findCascadeZones( const ZonePriorityMap& aByPriority,
165 unsigned aFromPriority, bool aCascadeUp,
166 bool& aViable )
167{
168 std::vector<ZONE*> result;
169 unsigned p = aFromPriority;
170 aViable = true;
171
172 for( auto it = aByPriority.find( p ); it != aByPriority.end();
173 it = aByPriority.find( p ) )
174 {
175 for( ZONE* z : it->second )
176 result.push_back( z );
177
178 if( aCascadeUp )
179 {
180 if( p == UINT_MAX )
181 {
182 aViable = false;
183 break;
184 }
185
186 p++;
187 }
188 else
189 {
190 if( p == 0 )
191 {
192 aViable = false;
193 break;
194 }
195
196 p--;
197 }
198 }
199
200 return result;
201}
202
203} // anonymous namespace
204
205
207{
208public:
220
221protected:
222 ACTION_MENU* create() const override
223 {
224 return new ZONE_PRIORITY_CONTEXT_MENU();
225 }
226
227 void update() override
228 {
230
231 if( !selTool )
232 return;
233
234 const PCB_SELECTION& selection = selTool->GetSelection();
235 bool canRaise = false;
236 bool canLower = false;
237
238 if( selection.Size() == 1 )
239 {
240 ZONE* zone = dynamic_cast<ZONE*>( selection[0] );
241
242 if( zone && !zone->GetIsRuleArea() && !zone->IsTeardropArea() )
243 {
244 BOARD* board = zone->GetBoard();
245 std::vector<ZONE*> overlapping = getOverlappingZones( board, zone );
246
247 for( ZONE* other : overlapping )
248 {
249 if( other->GetAssignedPriority() > zone->GetAssignedPriority() )
250 canRaise = true;
251
252 if( other->GetAssignedPriority() < zone->GetAssignedPriority() )
253 canLower = true;
254 }
255 }
256 }
257
258 Enable( PCB_ACTIONS::zonePriorityMoveToTop.GetUIId(), canRaise );
259 Enable( PCB_ACTIONS::zonePriorityRaise.GetUIId(), canRaise );
260 Enable( PCB_ACTIONS::zonePriorityLower.GetUIId(), canLower );
261 Enable( PCB_ACTIONS::zonePriorityMoveToBottom.GetUIId(), canLower );
262 }
263};
264
265
267{
268public:
270 ACTION_MENU( true )
271 {
273 SetTitle( _( "Zones" ) );
274
279
280 AppendSeparator();
281
286
287 AppendSeparator();
288
290
291 AppendSeparator();
292
294 }
295
296protected:
297 ACTION_MENU* create() const override
298 {
299 return new ZONE_CONTEXT_MENU();
300 }
301};
302
303
305{
306public:
317
318 ACTION_MENU* create() const override
319 {
320 return new LOCK_CONTEXT_MENU( this->m_tool );
321 }
322};
323
324
326 PCB_TOOL_BASE( "pcbnew.EditorControl" ),
327 m_frame( nullptr ),
328 m_inPlaceFootprint( false ),
329 m_placingFootprint( false )
330{
331 m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
333}
334
335
339
340
342{
344
345 if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW )
346 {
347 m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().GetAuxOrigin() );
348 getView()->Remove( m_placeOrigin.get() );
349 getView()->Add( m_placeOrigin.get() );
350 }
351}
352
353// Update left-toolbar Line modes group icon based on current settings
355{
357
358 if( !f )
359 return 0;
360
361 LEADER_MODE mode = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" )->m_AngleSnapMode;
362
363 switch( mode )
364 {
367 default:
369 }
370
371 return 0;
372}
373
375{
376 LEADER_MODE mode = aEvent.Parameter<LEADER_MODE>();
377 GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" )->m_AngleSnapMode = mode;
378 m_toolMgr->PostAction( ACTIONS::refreshPreview );
380 return 0;
381}
382
383
385{
386 auto activeToolCondition =
387 [this]( const SELECTION& aSel )
388 {
389 return ( !m_frame->ToolStackIsEmpty() );
390 };
391
392 auto inactiveStateCondition =
393 [this]( const SELECTION& aSel )
394 {
395 return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
396 };
397
398 auto placeModuleCondition =
399 [this]( const SELECTION& aSel )
400 {
401 return m_frame->IsCurrentTool( PCB_ACTIONS::placeFootprint ) && aSel.GetSize() == 0;
402 };
403
404 auto& ctxMenu = m_menu->GetMenu();
405
406 // "Cancel" goes at the top of the context menu when a tool is active
407 ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
408 ctxMenu.AddSeparator( 1 );
409
410 // "Get and Place Footprint" should be available for Place Footprint tool
411 ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
412 ctxMenu.AddSeparator( 1000 );
413
414 // Finally, add the standard zoom & grid items
415 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( *m_menu.get() );
416
417 std::shared_ptr<ZONE_CONTEXT_MENU> zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
418 zoneMenu->SetTool( this );
419
420 std::shared_ptr<LOCK_CONTEXT_MENU> lockMenu = std::make_shared<LOCK_CONTEXT_MENU>( this );
421
422 // Add the PCB control menus to relevant other tools
423
424 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
425
426 if( selTool )
427 {
428 TOOL_MENU& toolMenu = selTool->GetToolMenu();
429 CONDITIONAL_MENU& menu = toolMenu.GetMenu();
430
431 // Add "Get and Place Footprint" when Selection tool is in an inactive state
432 menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
433 menu.AddSeparator();
434
435 toolMenu.RegisterSubMenu( zoneMenu );
436 toolMenu.RegisterSubMenu( lockMenu );
437
438 menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
439
440 menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyTypes( { PCB_ZONE_T } ), 100 );
441 }
442
443 DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
444
445 if( drawingTool )
446 {
447 TOOL_MENU& toolMenu = drawingTool->GetToolMenu();
448 CONDITIONAL_MENU& menu = toolMenu.GetMenu();
449
450 toolMenu.RegisterSubMenu( zoneMenu );
451
452 // Functor to say if the PCB_EDIT_FRAME is in a given mode
453 // Capture the tool pointer and tool mode by value
454 auto toolActiveFunctor =
455 [=]( DRAWING_TOOL::MODE aMode )
456 {
457 return [=]( const SELECTION& sel )
458 {
459 return drawingTool->GetDrawingMode() == aMode;
460 };
461 };
462
463 menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 300 );
464 }
465
466 // Ensure the left toolbar's Line modes group reflects the current setting at startup
467 if( m_toolMgr )
469
470 return true;
471}
472
473
475{
476 const wxString title = _( "Export for Older KiCad Version" );
477
478 // The export reads the files on disk, so they have to match what is on screen.
479 if( m_frame->IsContentModified() )
480 {
481 int answer = wxMessageBox( _( "You have unsaved changes. Save them before exporting?" ), title,
482 wxYES_NO | wxCANCEL | wxICON_WARNING, m_frame );
483
484 if( answer == wxCANCEL )
485 return 0;
486
487 if( answer == wxYES && !m_frame->SaveBoard() )
488 {
489 wxMessageBox( _( "The board was not saved. Nothing was exported." ), title, wxOK | wxICON_ERROR, m_frame );
490 return 0;
491 }
492 }
493
494 const wxString board = m_frame->GetBoard()->GetFileName();
495
497 m_frame,
498 [&]( const DOWNGRADE_EXPORT_PASS& aPass, DOWNGRADE_EXPORT_RESULT& aResult ) -> bool
499 {
501 job.m_filename = board;
502 job.m_variant = aPass.m_variant;
503
504 if( !aPass.m_dryRun )
505 job.m_outputFile = wxFileName( aPass.m_folder, wxFileName( board ).GetFullName() ).GetFullPath();
506
507 return RunDowngradeJob( m_frame->Kiway(), KIWAY::FACE_PCB, job, aPass, aResult );
508 } );
509
510 return 0;
511}
512
513
515{
516 m_frame->SaveBoard();
517 return 0;
518}
519
520
522{
523 m_frame->SaveBoard( true );
524 return 0;
525}
526
527
529{
530 m_frame->SaveBoard( true, true );
531 return 0;
532}
533
534
536{
537 m_frame->ExportFootprintsToLibrary( false );
538 return 0;
539}
540
541
543{
544 PICKED_ITEMS_LIST undoCmd;
546 ITEM_PICKER wrapper( nullptr, undoItem, UNDO_REDO::PAGESETTINGS );
547
548 undoCmd.PushItem( wrapper );
549 undoCmd.SetDescription( _( "Page Settings" ) );
550 m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS );
551
552 DIALOG_PAGES_SETTINGS dlg( m_frame, m_frame->GetBoard()->GetEmbeddedFiles(), pcbIUScale.IU_PER_MILS,
555
556 if( dlg.ShowModal() == wxID_OK )
557 {
558 m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally(
559 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
560 {
561 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
562
563 if( text && text->HasTextVars() )
564 {
565 text->ClearRenderCache();
566 text->ClearBoundingBoxCache();
568 }
569
570 return 0;
571 } );
572
573 m_frame->OnModify();
574 }
575 else
576 {
577 m_frame->RollbackFromUndo();
578 }
579
580 return 0;
581}
582
583
585{
586 DIALOG_PLOT dlg( m_frame );
587 dlg.ShowQuasiModal();
588 return 0;
589}
590
591
593{
594 DIALOG_FOOTPRINT_FIELDS_TABLE* dlg = m_frame->GetFootprintFieldsTableDialog();
595
596 if( !dlg )
597 return 0;
598
599 // Needed at least on Windows. Raise() is not enough
600 dlg->Show( true );
601
602 // Bring it to the top if already open. Dual monitor users need this.
603 dlg->Raise();
604
605 dlg->ShowEditTab();
606
607 return 0;
608}
609
610
612{
613 DIALOG_FOOTPRINT_FIELDS_TABLE* dlg = m_frame->GetFootprintFieldsTableDialog();
614
615 if( !dlg )
616 return 0;
617
618 // Needed at least on Windows. Raise() is not enough
619 dlg->Show( true );
620
621 // Bring it to the top if already open. Dual monitor users need this.
622 dlg->Raise();
623
624 dlg->ShowExportTab();
625
626 return 0;
627}
628
629
631{
632 m_frame->ToggleSearch();
633 return 0;
634}
635
636
638{
639 m_frame->ShowFindDialog();
640 return 0;
641}
642
643
645{
646 m_frame->FindNext( aEvent.IsAction( &ACTIONS::findPrevious ) );
647 return 0;
648}
649
650
652{
653 m_frame->ShowFindByPropertiesDialog();
654 return 0;
655}
656
657
659{
660 getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
661 return 0;
662}
663
664
666{
667 getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog( _( "Clearance" ) );
668 return 0;
669}
670
671
673{
674 getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
675 return 0;
676}
677
678
680{
681 wxString fullFileName = frame()->GetBoard()->GetFileName();
682 wxString path;
683 wxString name;
684 wxString ext;
685
686 wxFileName::SplitPath( fullFileName, &path, &name, &ext );
687 name += wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension );
688
689 fullFileName = wxFileSelector( _( "Specctra Session File" ), path, name,
690 wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension ),
691 FILEEXT::SpecctraSessionFileWildcard(), wxFD_OPEN | wxFD_CHANGE_DIR,
692 frame() );
693
694 if( !fullFileName.IsEmpty() )
695 getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
696
697 return 0;
698}
699
700
702{
703 wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
704 wxFileName fn;
705
706 if( fullFileName.IsEmpty() )
707 {
708 fn = m_frame->GetBoard()->GetFileName();
710 }
711 else
712 {
713 fn = fullFileName;
714 }
715
716 fullFileName = wxFileSelector( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
718 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR, frame() );
719
720 if( !fullFileName.IsEmpty() )
721 {
722 m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
723 getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
724 }
725
726 return 0;
727}
728
729
731{
732 wxCHECK( m_frame, 0 );
733
734 wxFileName fn = m_frame->Prj().GetProjectFullName();
735
736 // Use a different file extension for the board netlist so the schematic netlist file
737 // is accidentally overwritten.
738 fn.SetExt( wxT( "pcb_net" ) );
739
740 wxFileDialog dlg( m_frame, _( "Export Board Netlist" ), fn.GetPath(), fn.GetFullName(),
741 _( "KiCad board netlist files" ) + AddFileExtListToFilter( { "pcb_net" } ),
742 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
743
744 dlg.SetExtraControlCreator( &LEGACYFILEDLG_NETLIST_OPTIONS::Create );
745
747
748 if( dlg.ShowModal() == wxID_CANCEL )
749 return 0;
750
751 fn = dlg.GetPath();
752
753 if( !fn.IsDirWritable() )
754 {
755 DisplayErrorMessage( m_frame, wxString::Format( _( "Insufficient permissions to folder '%s'." ),
756 fn.GetPath() ) );
757 return 0;
758 }
759
761 dynamic_cast<const LEGACYFILEDLG_NETLIST_OPTIONS*>( dlg.GetExtraControl() );
762 wxCHECK( noh, 0 );
763
765
766 for( const FOOTPRINT* footprint : board()->Footprints() )
767 {
768 COMPONENT* component = new COMPONENT( footprint->GetFPID(), footprint->GetReference(),
769 footprint->GetValue(), footprint->GetPath(),
770 { footprint->m_Uuid } );
771
772 for( const PAD* pad : footprint->Pads() )
773 {
774 const wxString& netname = pad->GetShortNetname();
775
776 if( !netname.IsEmpty() )
777 component->AddNet( pad->GetNumber(), netname, pad->GetPinFunction(), pad->GetPinType() );
778 }
779
780 nlohmann::ordered_map<wxString, wxString> fields;
781
782 for( PCB_FIELD* field : footprint->GetFields() )
783 {
784 wxCHECK2( field, continue );
785
786 fields[field->GetUntranslatedName()] = field->GetText();
787 }
788
789 component->SetFields( fields );
790
791 netlist.AddComponent( component );
792 }
793
794 try
795 {
796 FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
797
798 netlist.Format( "pcb_netlist", &formatter, 0, noh->GetNetlistOptions() );
799 formatter.Finish();
800 }
801 catch( const IO_ERROR& ioe )
802 {
803 DisplayErrorMessage( m_frame, wxString::Format( _( "Failed to export netlist to '%s': %s" ),
804 fn.GetFullPath(), ioe.What() ) );
805 }
806
807 return 0;
808}
809
810
812{
813 PCB_PLOT_PARAMS plotSettings = m_frame->GetPlotSettings();
814
815 plotSettings.SetFormat( PLOT_FORMAT::GERBER );
816
817 m_frame->SetPlotSettings( plotSettings );
818
819 DIALOG_PLOT dlg( m_frame );
820 dlg.ShowQuasiModal( );
821
822 return 0;
823}
824
825
827{
828 int errors = 0;
829 wxString details;
830 bool quiet = aEvent.Parameter<bool>();
831
832 int duplicates = board()->RepairDuplicateItemUuids();
833
834 if( duplicates )
835 {
836 errors += duplicates;
837 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
838 }
839
840 for( FOOTPRINT* footprint : board()->Footprints() )
841 {
842 for( PAD* pad : footprint->Pads() )
843 {
844 BOARD_CONNECTED_ITEM* cItem = pad;
845
846 if( cItem->GetNetCode() )
847 {
848 NETINFO_ITEM* netinfo = cItem->GetNet();
849
850 if( netinfo && !board()->FindNet( netinfo->GetNetname() ) )
851 {
852 board()->Add( netinfo );
853
854 details += wxString::Format( _( "Orphaned net %s re-parented.\n" ),
855 netinfo->GetNetname() );
856 errors++;
857 }
858 }
859 }
860 }
861
862 for( PCB_TRACK* track : board()->Tracks() )
863 {
864 BOARD_CONNECTED_ITEM* cItem = track;
865
866 if( cItem->GetNetCode() )
867 {
868 NETINFO_ITEM* netinfo = cItem->GetNet();
869
870 if( netinfo && !board()->FindNet( netinfo->GetNetname() ) )
871 {
872 board()->Add( netinfo );
873
874 details += wxString::Format( _( "Orphaned net %s re-parented.\n" ),
875 netinfo->GetNetname() );
876 errors++;
877 }
878 }
879 }
880
881 /*******************************
882 * Your test here
883 */
884
885 /*******************************
886 * Inform the user
887 */
888
889 if( errors )
890 {
891 m_frame->OnModify();
892
893 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
894
895 if( !quiet )
896 DisplayInfoMessage( m_frame, msg, details );
897 }
898 else if( !quiet )
899 {
900 DisplayInfoMessage( m_frame, _( "No board problems found." ) );
901 }
902
903 return 0;
904}
905
906
908{
910 bool fetched = false;
911
913 [&]()
914 {
915 fetched = m_frame->FetchNetlistFromSchematic(
916 netlist, _( "Updating PCB requires a fully annotated schematic." ) );
917 } );
918
919 if( fetched )
920 {
921 DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
922 updateDialog.ShowModal();
923 }
924
925 return 0;
926}
927
929{
930 if( Kiface().IsSingle() )
931 {
932 DisplayErrorMessage( m_frame, _( "Cannot update schematic because Pcbnew is opened in "
933 "stand-alone mode. In order to create or update PCBs "
934 "from schematics, you must launch the KiCad project "
935 "manager and create a project." ) );
936 return 0;
937 }
938
941
942 KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_SCH, false );
943
944 if( frame )
945 {
946 std::string payload;
947
948 if( wxWindow* blocking_win = frame->Kiway().GetBlockingDialog() )
949 blocking_win->Close( true );
950
951 m_frame->Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_UPDATE, payload, m_frame );
952 }
953 return 0;
954}
955
956
958{
959 wxString msg;
960 PCB_EDIT_FRAME* boardFrame = m_frame;
961 PROJECT& project = boardFrame->Prj();
962 wxFileName schematic( project.GetProjectPath(), project.GetProjectName(),
964
965 if( !schematic.FileExists() )
966 {
967 wxFileName legacySchematic( project.GetProjectPath(), project.GetProjectName(),
969
970 if( legacySchematic.FileExists() )
971 {
972 schematic = legacySchematic;
973 }
974 else
975 {
976 msg.Printf( _( "Schematic file '%s' not found." ), schematic.GetFullPath() );
978 return 0;
979 }
980 }
981
982 if( Kiface().IsSingle() )
983 {
984 ExecuteFile( EESCHEMA_EXE, schematic.GetFullPath() );
985 }
986 else
987 {
989 [&]()
990 {
991 KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_SCH, false );
992
993 // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
994 // Kiway.Player( FRAME_SCH, true )
995 // therefore, the schematic editor is sometimes running, but the schematic project
996 // is not loaded, if the library editor was called, and the dialog field editor was used.
997 // On Linux, it happens the first time the schematic editor is launched, if
998 // library editor was running, and the dialog field editor was open
999 // On Windows, it happens always after the library editor was called,
1000 // and the dialog field editor was used
1001 if( !frame )
1002 frame = boardFrame->Kiway().Player( FRAME_SCH, true );
1003
1004 wxEventBlocker blocker( boardFrame );
1005
1006 // If Kiway() cannot create the eeschema frame, it shows a error message, and
1007 // frame is null
1008 if( !frame )
1009 return;
1010
1011 if( !frame->IsShownOnScreen() ) // the frame exists, (created by the dialog field editor)
1012 // but no project loaded.
1013 {
1014 frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFullPath() ) );
1015 frame->Show( true );
1016 }
1017
1018 // On Windows, Raise() does not bring the window on screen, when iconized or not shown
1019 // On Linux, Raise() brings the window on screen, but this code works fine
1020 if( frame->IsIconized() )
1021 {
1022 frame->Iconize( false );
1023
1024 // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
1025 // to show the frame at its normal size: Maximize should be called.
1026 frame->Maximize( false );
1027 }
1028
1029 frame->Raise();
1030 } );
1031 }
1032
1033 return 0;
1034}
1035
1036
1038{
1039 getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
1040 return 0;
1041}
1042
1043
1045{
1046 getEditFrame<PCB_EDIT_FRAME>()->ToggleProperties();
1047 return 0;
1048}
1049
1050
1052{
1053 getEditFrame<PCB_EDIT_FRAME>()->ToggleNetInspector();
1054 return 0;
1055}
1056
1057
1059{
1060 getEditFrame<PCB_EDIT_FRAME>()->ToggleGitCommitPane();
1061 return 0;
1062}
1063
1064
1066{
1067 getEditFrame<PCB_EDIT_FRAME>()->ToggleLibraryTree();
1068 return 0;
1069}
1070
1071
1073{
1074 getEditFrame<PCB_EDIT_FRAME>()->ToggleSearch();
1075 return 0;
1076}
1077
1078
1080{
1081 getEditFrame<PCB_EDIT_FRAME>()->ToggleConstraintsPanel();
1082 return 0;
1083}
1084
1085
1086// Track & via size control
1088{
1089 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
1090 PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1091
1092 if( m_frame->ToolStackIsEmpty()
1093 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
1094 {
1095 BOARD_COMMIT commit( this );
1096
1097 for( EDA_ITEM* item : selection )
1098 {
1099 if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
1100 {
1101 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
1102
1103 for( int i = 0; i < (int) bds.m_TrackWidthList.size(); ++i )
1104 {
1105 int candidate = bds.m_NetSettings->GetDefaultNetclass()->GetTrackWidth();
1106
1107 if( i > 0 )
1108 candidate = bds.m_TrackWidthList[ i ];
1109
1110 if( candidate > track->GetWidth() )
1111 {
1112 commit.Modify( track );
1113 track->SetWidth( candidate );
1114 break;
1115 }
1116 }
1117 }
1118 }
1119
1120 commit.Push( _( "Increase Track Width" ) );
1121 return 0;
1122 }
1123
1124 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
1125
1126 if( routerTool && routerTool->IsToolActive()
1127 && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
1128 {
1129 int widthIndex = bds.GetNextDiffPairIndex( bds.GetDiffPairIndex(), true );
1130
1131 bds.SetDiffPairIndex( widthIndex );
1132 bds.UseCustomDiffPairDimensions( false );
1133
1135 }
1136 else
1137 {
1138 // Issue #24644: stepping the index unconditionally lets the first press both enter the
1139 // connected-width override and advance into the list, instead of no-op'ing.
1140 if( routerTool && routerTool->IsToolActive()
1143 {
1144 bds.m_TempOverrideTrackWidth = true;
1145 }
1146
1148 bds.UseCustomTrackViaSize( false );
1149
1151 }
1152
1153 return 0;
1154}
1155
1156
1158{
1159 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
1160 PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1161
1162 if( m_frame->ToolStackIsEmpty()
1163 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
1164 {
1165 BOARD_COMMIT commit( this );
1166
1167 for( EDA_ITEM* item : selection )
1168 {
1169 if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
1170 {
1171 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
1172
1173 for( int i = (int) bds.m_TrackWidthList.size() - 1; i >= 0; --i )
1174 {
1175 int candidate = bds.m_NetSettings->GetDefaultNetclass()->GetTrackWidth();
1176
1177 if( i > 0 )
1178 candidate = bds.m_TrackWidthList[ i ];
1179
1180 if( candidate < track->GetWidth() )
1181 {
1182 commit.Modify( track );
1183 track->SetWidth( candidate );
1184 break;
1185 }
1186 }
1187 }
1188 }
1189
1190 commit.Push( _( "Decrease Track Width" ) );
1191 return 0;
1192 }
1193
1194 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
1195
1196 if( routerTool && routerTool->IsToolActive()
1197 && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
1198 {
1199 int widthIndex = bds.GetNextDiffPairIndex( bds.GetDiffPairIndex(), false );
1200
1201 bds.SetDiffPairIndex( widthIndex );
1202 bds.UseCustomDiffPairDimensions( false );
1203
1205 }
1206 else
1207 {
1208 // Issue #24644: mirror TrackWidthInc so the first invocation also advances into the
1209 // predefined list instead of merely flipping the override flag.
1210 if( routerTool && routerTool->IsToolActive()
1213 {
1214 bds.m_TempOverrideTrackWidth = true;
1215 }
1216
1218 bds.UseCustomTrackViaSize( false );
1219
1221 }
1222
1223 return 0;
1224}
1225
1226
1228{
1229 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
1230 PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1231
1232 if( m_frame->ToolStackIsEmpty()
1233 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
1234 {
1235 int complexPadstacks = 0;
1236 int incremented = 0;
1237 BOARD_COMMIT commit( this );
1238
1239 for( EDA_ITEM* item : selection )
1240 {
1241 if( item->Type() == PCB_VIA_T )
1242 {
1243 PCB_VIA* via = static_cast<PCB_VIA*>( item );
1244
1245 if( via->Padstack().Mode() != PADSTACK::MODE::NORMAL )
1246 {
1247 complexPadstacks++;
1248 continue;
1249 }
1250
1251 for( int i = 0; i < (int) bds.m_ViasDimensionsList.size(); ++i )
1252 {
1255
1256 if( i> 0 )
1257 dims = bds.m_ViasDimensionsList[ i ];
1258
1259 if( dims.m_Diameter > via->GetWidth( PADSTACK::ALL_LAYERS ) )
1260 {
1261 commit.Modify( via );
1262 via->SetWidth( PADSTACK::ALL_LAYERS, dims.m_Diameter );
1263 via->SetDrill( dims.m_Drill );
1264 incremented++;
1265 break;
1266 }
1267 }
1268 }
1269 }
1270
1271 if( incremented == 0 && complexPadstacks > 0 )
1272 {
1273 m_frame->ShowInfoBarError( wxString::Format( _( "%s not supported on complex padstacks." ),
1274 PCB_ACTIONS::viaSizeInc.GetFriendlyName() ) );
1275 }
1276
1277 commit.Push( PCB_ACTIONS::viaSizeInc.GetFriendlyName() );
1278 }
1279 else
1280 {
1281 int sizeIndex = bds.GetNextViaSizeIndex( bds.GetViaSizeIndex(), true );
1282
1283 bds.SetViaSizeIndex( sizeIndex );
1284 bds.UseCustomTrackViaSize( false );
1285
1287 }
1288
1289 return 0;
1290}
1291
1292
1294{
1295 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
1296 PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1297
1298 if( m_frame->ToolStackIsEmpty()
1299 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
1300 {
1301 int complexPadstacks = 0;
1302 int decremented = 0;
1303 BOARD_COMMIT commit( this );
1304
1305 for( EDA_ITEM* item : selection )
1306 {
1307 if( item->Type() == PCB_VIA_T )
1308 {
1309 PCB_VIA* via = static_cast<PCB_VIA*>( item );
1310
1311 if( via->Padstack().Mode() != PADSTACK::MODE::NORMAL )
1312 {
1313 complexPadstacks++;
1314 continue;
1315 }
1316
1317 for( int i = (int) bds.m_ViasDimensionsList.size() - 1; i >= 0; --i )
1318 {
1321
1322 if( i > 0 )
1323 dims = bds.m_ViasDimensionsList[ i ];
1324
1325 if( dims.m_Diameter < via->GetWidth( PADSTACK::ALL_LAYERS ) )
1326 {
1327 commit.Modify( via );
1328 via->SetWidth( PADSTACK::ALL_LAYERS, dims.m_Diameter );
1329 via->SetDrill( dims.m_Drill );
1330 decremented++;
1331 break;
1332 }
1333 }
1334 }
1335 }
1336
1337 if( decremented == 0 && complexPadstacks > 0 )
1338 {
1339 m_frame->ShowInfoBarError( wxString::Format( _( "%s not supported on complex padstacks." ),
1340 PCB_ACTIONS::viaSizeDec.GetFriendlyName() ) );
1341 }
1342
1343 commit.Push( PCB_ACTIONS::viaSizeDec.GetFriendlyName() );
1344 }
1345 else
1346 {
1347 int sizeIndex = 0; // Assume we only have a single via size entry
1348
1349 // If there are more, cycle through them backwards
1350 if( bds.m_ViasDimensionsList.size() > 0 )
1351 sizeIndex = bds.GetNextViaSizeIndex( bds.GetViaSizeIndex(), false );
1352
1353 bds.SetViaSizeIndex( sizeIndex );
1354 bds.UseCustomTrackViaSize( false );
1355
1357 }
1358
1359 return 0;
1360}
1361
1362
1364{
1365 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
1366
1367 if( bds.UseCustomTrackViaSize() )
1368 {
1369 bds.UseCustomTrackViaSize( false );
1370 bds.m_UseConnectedTrackWidth = true;
1371 }
1372 else
1373 {
1375 }
1376
1377 return 0;
1378}
1379
1380
1382{
1383 if( m_inPlaceFootprint )
1384 return 0;
1385
1387
1388 FOOTPRINT* fp = aEvent.Parameter<FOOTPRINT*>();
1389 bool fromOtherCommand = fp != nullptr;
1391 BOARD_COMMIT commit( m_frame );
1393 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
1394
1395 m_toolMgr->RunAction( ACTIONS::selectionClear );
1396
1397 TOOL_EVENT originalEvent = aEvent; // This can change out from under us when the event loop runs
1398 SCOPED_TOOL_PUSHER raii( m_frame, originalEvent );
1399
1400 // Frame angle already applied to fp; recaptured whenever fp is (re)acquired, so
1401 // stale state can never leak into the next placement.
1402 EDA_ANGLE prevFrameAngle = ANGLE_0;
1403
1404 auto setCursor =
1405 [&]()
1406 {
1407 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
1408 };
1409
1410 auto cleanup =
1411 [&] ()
1412 {
1413 m_toolMgr->RunAction( ACTIONS::selectionClear );
1414 commit.Revert();
1415
1416 if( fromOtherCommand )
1417 {
1418 PICKED_ITEMS_LIST* undo = m_frame->PopCommandFromUndoList();
1419
1420 if( undo )
1421 {
1422 m_frame->PutDataInPreviousState( undo );
1423 m_frame->ClearListAndDeleteItems( undo );
1424 delete undo;
1425 }
1426 }
1427
1428 fp = nullptr;
1429 m_placingFootprint = false;
1430 };
1431
1432 Activate();
1433 // Must be done after Activate() so that it gets set into the correct context
1434 controls->ShowCursor( true );
1435 // Set initial cursor
1436 setCursor();
1437
1438 VECTOR2I cursorPos = controls->GetCursorPosition();
1439 bool ignorePrimePosition = false;
1440 bool reselect = false;
1441
1442 auto applyPlacementFrameOrientation =
1443 [&]()
1444 {
1445 if( !fp )
1446 return;
1447
1449 EDA_ANGLE delta = GridFrameRotationDelta( prevFrameAngle, newAngle, m_frame->GetRotationAngle() );
1450
1451 prevFrameAngle = newAngle;
1452
1453 if( !delta.IsZero() )
1454 fp->Rotate( fp->GetPosition(), delta );
1455 };
1456
1457 // Prime the pump
1458 if( fp )
1459 {
1460 m_placingFootprint = true;
1461
1462 // A footprint handed over from another command may already carry the frame
1463 // rotation of the grid it sits in; count that as applied, like a move pick-up.
1464 prevFrameAngle = GridFrameAngleAt( *board, fp->GetPosition(), PCB_GRID_ROLE::PLACEMENT );
1465 fp->SetPosition( cursorPos );
1466 applyPlacementFrameOrientation();
1467 m_toolMgr->RunAction<EDA_ITEM*>( ACTIONS::selectItem, fp );
1468 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1469 }
1470 else if( aEvent.HasPosition() )
1471 {
1472 m_toolMgr->PrimeTool( aEvent.Position() );
1473 }
1474 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
1475 {
1476 m_toolMgr->PrimeTool( { 0, 0 } );
1477 ignorePrimePosition = true;
1478 }
1479
1480 // Main loop: keep receiving events
1481 while( TOOL_EVENT* evt = Wait() )
1482 {
1483 setCursor();
1484 cursorPos = controls->GetCursorPosition( !evt->DisableGridSnapping() );
1485
1486 if( reselect && fp )
1487 m_toolMgr->RunAction<EDA_ITEM*>( ACTIONS::selectItem, fp );
1488
1489 if( evt->IsCancelInteractive() || ( fp && evt->IsAction( &ACTIONS::undo ) ) )
1490 {
1491 if( fp )
1492 cleanup();
1493 else
1494 break;
1495 }
1496 else if( evt->IsActivate() )
1497 {
1498 if( fp )
1499 cleanup();
1500
1501 if( evt->IsMoveTool() )
1502 {
1503 // Make sure we come back after the move tool is done
1504 m_frame->PushTool( originalEvent );
1505 }
1506
1507 break;
1508 }
1509 else if( evt->IsClick( BUT_LEFT ) )
1510 {
1511 if( !fp )
1512 {
1513 // Pick the footprint to be placed
1514 fp = m_frame->SelectFootprintFromLibrary();
1515
1516 if( fp == nullptr )
1517 continue;
1518
1519 // If we started with a hotkey which has a position then warp back to that.
1520 // Otherwise update to the current mouse position pinned inside the autoscroll
1521 // boundaries.
1522 if( evt->IsPrime() && !ignorePrimePosition )
1523 {
1524 cursorPos = evt->Position();
1525 getViewControls()->WarpMouseCursor( cursorPos, true );
1526 }
1527 else
1528 {
1530 cursorPos = getViewControls()->GetMousePosition();
1531 }
1532
1533 m_placingFootprint = true;
1534
1535 fp->SetLink( niluuid );
1536
1537 fp->SetFlags( IS_NEW ); // whatever
1538
1539 // Set parent so that clearance can be loaded
1540 fp->SetParent( board );
1541 board->UpdateUserUnits( fp, m_frame->GetCanvas()->GetView() );
1542
1543 for( PAD* pad : fp->Pads() )
1544 {
1545 pad->SetLocalRatsnestVisible( m_frame->GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
1546
1547 // Pads in the library all have orphaned nets. Replace with Default.
1548 pad->SetNetCode( 0 );
1549 }
1550
1551 // Put it on FRONT layer,
1552 // (Can be stored flipped if the lib is an archive built from a board)
1553 if( fp->IsFlipped() )
1554 fp->Flip( fp->GetPosition(), m_frame->GetPcbNewSettings()->m_FlipDirection );
1555
1556 fp->SetOrientation( ANGLE_0 );
1557 fp->SetPosition( cursorPos );
1558 prevFrameAngle = ANGLE_0;
1559 applyPlacementFrameOrientation();
1560
1561 commit.Add( fp );
1562 m_toolMgr->RunAction<EDA_ITEM*>( ACTIONS::selectItem, fp );
1563
1564 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1565 }
1566 else
1567 {
1568 m_toolMgr->RunAction( ACTIONS::selectionClear );
1569 commit.Push( _( "Place Footprint" ) );
1570 fp = nullptr; // to indicate that there is no footprint that we currently modify
1571 m_placingFootprint = false;
1572 }
1573 }
1574 else if( evt->IsClick( BUT_RIGHT ) )
1575 {
1576 m_menu->ShowContextMenu( selection() );
1577 }
1578 else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
1579 {
1580 fp->SetPosition( cursorPos );
1581 applyPlacementFrameOrientation();
1582 selection().SetReferencePoint( cursorPos );
1583 getView()->Update( &selection() );
1584 getView()->Update( fp );
1585 }
1586 else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) )
1587 {
1588 // Calling 'Properties' action clears the selection, so we need to restore it
1589 reselect = true;
1590 }
1591 else if( fp && ( ZONE_FILLER_TOOL::IsZoneFillAction( evt )
1592 || evt->IsAction( &ACTIONS::redo ) ) )
1593 {
1594 wxBell();
1595 }
1596 else
1597 {
1598 evt->SetPassEvent();
1599 }
1600
1601 // Enable autopanning and cursor capture only when there is a footprint to be placed
1602 controls->SetAutoPan( fp != nullptr );
1603 controls->CaptureCursor( fp != nullptr );
1604 }
1605
1606 controls->SetAutoPan( false );
1607 controls->CaptureCursor( false );
1608 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
1609
1610 return 0;
1611}
1612
1613
1615{
1616 return modifyLockSelected( TOGGLE );
1617}
1618
1619
1621{
1622 return modifyLockSelected( ON );
1623}
1624
1625
1627{
1628 return modifyLockSelected( OFF );
1629}
1630
1631
1633{
1634 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
1635
1636 // RequestSelection populates from the cursor when empty and marks it IsHover(), letting us
1637 // clear it afterwards without disturbing a pre-existing selection.
1638 const PCB_SELECTION& selection = selTool->RequestSelection( nullptr );
1639
1640 BOARD_COMMIT commit( m_frame );
1641
1642 if( selection.Empty() )
1643 return 0;
1644
1645 const bool isHover = selection.IsHover();
1646
1647 // Resolve TOGGLE mode
1648 if( aMode == TOGGLE )
1649 {
1650 aMode = ON;
1651
1652 for( EDA_ITEM* item : selection )
1653 {
1654 if( !item->IsBOARD_ITEM() )
1655 continue;
1656
1657 if( static_cast<BOARD_ITEM*>( item )->IsLocked() )
1658 {
1659 aMode = OFF;
1660 break;
1661 }
1662 }
1663 }
1664
1665 for( EDA_ITEM* item : selection )
1666 {
1667 if( !item->IsBOARD_ITEM() )
1668 continue;
1669
1670 BOARD_ITEM* const board_item = static_cast<BOARD_ITEM*>( item );
1671
1672 // Disallow locking free pads - it's confusing and not persisted
1673 // through save/load anyway.
1674 if( board_item->Type() == PCB_PAD_T )
1675 continue;
1676
1677 EDA_GROUP* parent_group = board_item->GetParentGroup();
1678
1679 if( parent_group && parent_group->AsEdaItem()->Type() == PCB_GENERATOR_T )
1680 {
1681 PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( parent_group );
1682
1683 if( generator && commit.GetStatus( generator ) != CHT_MODIFY )
1684 {
1685 commit.Modify( generator );
1686
1687 if( aMode == ON )
1688 generator->SetLocked( true );
1689 else
1690 generator->SetLocked( false );
1691 }
1692 }
1693
1694 commit.Modify( board_item );
1695
1696 if( aMode == ON )
1697 board_item->SetLocked( true );
1698 else
1699 board_item->SetLocked( false );
1700
1701 if( aMode == OFF && board_item->Type() == PCB_FOOTPRINT_T )
1702 {
1703 board_item->RunOnChildren(
1704 []( BOARD_ITEM* child )
1705 {
1706 child->SetLocked( false );
1707 },
1709 }
1710 }
1711
1712 if( !commit.Empty() )
1713 {
1714 commit.Push( aMode == ON ? _( "Lock" ) : _( "Unlock" ), SKIP_TEARDROPS );
1715
1716 m_toolMgr->PostEvent( EVENTS::SelectedEvent );
1717 m_frame->OnModify();
1718 }
1719
1720 if( isHover )
1721 m_toolMgr->RunAction( ACTIONS::selectionClear );
1722
1723 return 0;
1724}
1725
1726
1727static bool mergeZones( EDA_DRAW_FRAME* aFrame, BOARD_COMMIT& aCommit,
1728 std::vector<ZONE*>& aOriginZones, std::vector<ZONE*>& aMergedZones )
1729{
1730 aCommit.Modify( aOriginZones[0] );
1731
1732 aOriginZones[0]->Outline()->ClearArcs();
1733
1734 for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1735 {
1736 SHAPE_POLY_SET otherOutline = aOriginZones[i]->Outline()->CloneDropTriangulation();
1737 otherOutline.ClearArcs();
1738 aOriginZones[0]->Outline()->BooleanAdd( otherOutline );
1739 }
1740
1741 aOriginZones[0]->Outline()->Simplify();
1742
1743 // We should have one polygon, possibly with holes. If we end up with two polygons (either
1744 // because the intersection was a single point or because the intersection was within one of
1745 // the zone's holes) then we can't merge.
1746 if( aOriginZones[0]->Outline()->IsSelfIntersecting() || aOriginZones[0]->Outline()->OutlineCount() > 1 )
1747 {
1748 DisplayErrorMessage( aFrame, _( "Zones have insufficient overlap for merging." ) );
1749 aCommit.Revert();
1750 return false;
1751 }
1752
1753 // Adopt the highest priority from all merged zones so the result maintains
1754 // the most aggressive fill ordering.
1755 unsigned highestPriority = aOriginZones[0]->GetAssignedPriority();
1756
1757 for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1758 {
1759 highestPriority = std::max( highestPriority, aOriginZones[i]->GetAssignedPriority() );
1760 aCommit.Remove( aOriginZones[i] );
1761 }
1762
1763 aOriginZones[0]->SetAssignedPriority( highestPriority );
1764
1765 aMergedZones.push_back( aOriginZones[0] );
1766
1767 aOriginZones[0]->SetLocalFlags( 1 );
1768 aOriginZones[0]->HatchBorder();
1769 aOriginZones[0]->CacheTriangulation();
1770
1771 return true;
1772}
1773
1774
1776{
1777 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1779 BOARD_COMMIT commit( m_frame );
1780
1781 if( selection.Size() < 2 )
1782 return 0;
1783
1784 int netcode = -1;
1785
1786 ZONE* firstZone = nullptr;
1787 std::vector<ZONE*> toMerge, merged;
1788
1789 for( EDA_ITEM* item : selection )
1790 {
1791 ZONE* curr_area = dynamic_cast<ZONE*>( item );
1792
1793 if( !curr_area )
1794 continue;
1795
1796 if( !firstZone )
1797 firstZone = curr_area;
1798
1799 netcode = curr_area->GetNetCode();
1800
1801 if( firstZone->GetNetCode() != netcode )
1802 {
1803 wxLogMessage( _( "Some zone netcodes did not match and were not merged." ) );
1804 continue;
1805 }
1806
1807 if( curr_area->GetIsRuleArea() != firstZone->GetIsRuleArea() )
1808 {
1809 wxLogMessage( _( "Some zones were rule areas and were not merged." ) );
1810 continue;
1811 }
1812
1813 if( curr_area->GetLayerSet() != firstZone->GetLayerSet() )
1814 {
1815 wxLogMessage( _( "Some zone layer sets did not match and were not merged." ) );
1816 continue;
1817 }
1818
1819 bool intersects = curr_area == firstZone;
1820
1821 for( ZONE* candidate : toMerge )
1822 {
1823 if( intersects )
1824 break;
1825
1826 if( board->TestZoneIntersection( curr_area, candidate ) )
1827 intersects = true;
1828 }
1829
1830 if( !intersects )
1831 {
1832 wxLogMessage( _( "Some zones did not intersect and were not merged." ) );
1833 continue;
1834 }
1835
1836 toMerge.push_back( curr_area );
1837 }
1838
1839 m_toolMgr->RunAction( ACTIONS::selectionClear );
1840
1841 if( !toMerge.empty() )
1842 {
1843 if( mergeZones( m_frame, commit, toMerge, merged ) )
1844 {
1845 commit.Push( _( "Merge Zones" ) );
1846
1847 for( EDA_ITEM* item : merged )
1848 m_toolMgr->RunAction( ACTIONS::selectItem, item );
1849 }
1850 }
1851
1852 return 0;
1853}
1854
1855
1857{
1858 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
1859 const PCB_SELECTION& selection = selTool->GetSelection();
1860
1861 // because this pops up the zone editor, it would be confusing to handle multiple zones,
1862 // so just handle single selections containing exactly one zone
1863 if( selection.Size() != 1 )
1864 return 0;
1865
1866 ZONE* oldZone = dynamic_cast<ZONE*>( selection[0] );
1867
1868 if( !oldZone )
1869 return 0;
1870
1871 ZONE_SETTINGS zoneSettings;
1872 zoneSettings << *oldZone;
1873 int dialogResult;
1874
1875 if( oldZone->GetIsRuleArea() )
1876 dialogResult = InvokeRuleAreaEditor( m_frame, &zoneSettings, board() );
1877 else if( oldZone->IsOnCopperLayer() )
1878 dialogResult = InvokeCopperZonesEditor( m_frame, nullptr, &zoneSettings );
1879 else
1880 dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1881
1882 if( dialogResult != wxID_OK )
1883 return 0;
1884
1885 // duplicate the zone
1886 BOARD_COMMIT commit( m_frame );
1887
1888 std::unique_ptr<ZONE> newZone = std::make_unique<ZONE>( *oldZone );
1889 newZone->ClearSelected();
1890 newZone->UnFill();
1891 zoneSettings.ExportSetting( *newZone );
1892
1893 if( !newZone->GetZoneName().IsEmpty() )
1894 newZone->SetZoneName( board()->GetUniqueZoneName( newZone->GetZoneName() ) );
1895
1896 // If the new zone is on the same layer(s) as the initial zone,
1897 // offset it a bit so it can more easily be picked.
1898 if( oldZone->GetLayerSet() == zoneSettings.m_Layers )
1899 newZone->Move( VECTOR2I( pcbIUScale.IU_PER_MM, pcbIUScale.IU_PER_MM ) );
1900
1901 commit.Add( newZone.release() );
1902 commit.Push( _( "Duplicate Zone" ) );
1903
1904 return 0;
1905}
1906
1907
1909{
1910 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1911
1912 if( selection.Size() != 1 )
1913 return 0;
1914
1915 ZONE* zone = dynamic_cast<ZONE*>( selection[0] );
1916
1917 if( !zone || zone->GetIsRuleArea() || zone->IsTeardropArea() )
1918 return 0;
1919
1920 std::vector<ZONE*> overlapping = getOverlappingZones( board(), zone );
1921
1922 unsigned maxOverlapping = zone->GetAssignedPriority();
1923
1924 for( ZONE* other : overlapping )
1925 maxOverlapping = std::max( maxOverlapping, other->GetAssignedPriority() );
1926
1927 if( zone->GetAssignedPriority() >= maxOverlapping )
1928 return 0;
1929
1930 // Two options to place our zone above all overlapping zones.
1931 // Pick whichever viable option displaces fewer other zones.
1932 ZonePriorityMap byPriority = buildPriorityMap( board(), zone );
1933
1934 // Option A: take maxOverlapping, cascade displaced zones down
1935 bool cascadeDownViable = false;
1936 std::vector<ZONE*> cascadeDown =
1937 findCascadeZones( byPriority, maxOverlapping, false, cascadeDownViable );
1938
1939 // Option B: take maxOverlapping + 1, cascade displaced zones up
1940 bool cascadeUpViable = false;
1941 std::vector<ZONE*> cascadeUp;
1942 bool canCascadeUp = ( maxOverlapping < UINT_MAX );
1943
1944 if( canCascadeUp )
1945 cascadeUp = findCascadeZones( byPriority, maxOverlapping + 1, true, cascadeUpViable );
1946
1947 if( !cascadeDownViable && !cascadeUpViable )
1948 return 0;
1949
1950 BOARD_COMMIT commit( m_frame );
1951 commit.Modify( zone );
1952
1953 bool useDown = cascadeDownViable
1954 && ( !cascadeUpViable || cascadeDown.size() <= cascadeUp.size() );
1955
1956 if( useDown )
1957 {
1958 zone->SetAssignedPriority( maxOverlapping );
1959
1960 for( ZONE* z : cascadeDown )
1961 {
1962 commit.Modify( z );
1964 z->SetNeedRefill( true );
1965 }
1966 }
1967 else
1968 {
1969 zone->SetAssignedPriority( maxOverlapping + 1 );
1970
1971 for( ZONE* z : cascadeUp )
1972 {
1973 commit.Modify( z );
1975 z->SetNeedRefill( true );
1976 }
1977 }
1978
1979 zone->SetNeedRefill( true );
1980 commit.Push( _( "Move Zone to Top Priority" ) );
1981
1982 return 0;
1983}
1984
1985
1987{
1988 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1989
1990 if( selection.Size() != 1 )
1991 return 0;
1992
1993 ZONE* zone = dynamic_cast<ZONE*>( selection[0] );
1994
1995 if( !zone || zone->GetIsRuleArea() || zone->IsTeardropArea() )
1996 return 0;
1997
1998 std::vector<ZONE*> overlapping = getOverlappingZones( board(), zone );
1999
2000 // Find the overlapping zone with the lowest priority still above ours
2001 ZONE* target = nullptr;
2002 unsigned zonePriority = zone->GetAssignedPriority();
2003
2004 for( ZONE* other : overlapping )
2005 {
2006 if( other->GetAssignedPriority() > zonePriority )
2007 {
2008 if( !target || other->GetAssignedPriority() < target->GetAssignedPriority() )
2009 target = other;
2010 }
2011 }
2012
2013 if( !target )
2014 return 0;
2015
2016 BOARD_COMMIT commit( m_frame );
2017 commit.Modify( zone );
2018
2019 // Place our zone just above the target without modifying any other zone
2020 if( target->GetAssignedPriority() < UINT_MAX )
2021 {
2022 zone->SetAssignedPriority( target->GetAssignedPriority() + 1 );
2023 }
2024 else
2025 {
2026 // Can't go above UINT_MAX; swap as last resort
2027 commit.Modify( target );
2028 zone->SetAssignedPriority( UINT_MAX );
2029 target->SetAssignedPriority( zonePriority );
2030 target->SetNeedRefill( true );
2031 }
2032
2033 zone->SetNeedRefill( true );
2034 commit.Push( _( "Raise Zone Priority" ) );
2035
2036 return 0;
2037}
2038
2039
2041{
2042 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
2043
2044 if( selection.Size() != 1 )
2045 return 0;
2046
2047 ZONE* zone = dynamic_cast<ZONE*>( selection[0] );
2048
2049 if( !zone || zone->GetIsRuleArea() || zone->IsTeardropArea() )
2050 return 0;
2051
2052 std::vector<ZONE*> overlapping = getOverlappingZones( board(), zone );
2053
2054 // Find the overlapping zone with the highest priority still below ours
2055 ZONE* target = nullptr;
2056 unsigned zonePriority = zone->GetAssignedPriority();
2057
2058 for( ZONE* other : overlapping )
2059 {
2060 if( other->GetAssignedPriority() < zonePriority )
2061 {
2062 if( !target || other->GetAssignedPriority() > target->GetAssignedPriority() )
2063 target = other;
2064 }
2065 }
2066
2067 if( !target )
2068 return 0;
2069
2070 BOARD_COMMIT commit( m_frame );
2071 commit.Modify( zone );
2072
2073 // Place our zone just below the target without modifying any other zone
2074 if( target->GetAssignedPriority() > 0 )
2075 {
2076 zone->SetAssignedPriority( target->GetAssignedPriority() - 1 );
2077 }
2078 else
2079 {
2080 // Can't go below 0; swap as last resort
2081 commit.Modify( target );
2082 zone->SetAssignedPriority( 0 );
2083 target->SetAssignedPriority( zonePriority );
2084 target->SetNeedRefill( true );
2085 }
2086
2087 zone->SetNeedRefill( true );
2088 commit.Push( _( "Lower Zone Priority" ) );
2089
2090 return 0;
2091}
2092
2093
2095{
2096 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
2097
2098 if( selection.Size() != 1 )
2099 return 0;
2100
2101 ZONE* zone = dynamic_cast<ZONE*>( selection[0] );
2102
2103 if( !zone || zone->GetIsRuleArea() || zone->IsTeardropArea() )
2104 return 0;
2105
2106 std::vector<ZONE*> overlapping = getOverlappingZones( board(), zone );
2107
2108 unsigned minOverlapping = zone->GetAssignedPriority();
2109
2110 for( ZONE* other : overlapping )
2111 minOverlapping = std::min( minOverlapping, other->GetAssignedPriority() );
2112
2113 if( zone->GetAssignedPriority() <= minOverlapping )
2114 return 0;
2115
2116 // Two options to place our zone below all overlapping zones.
2117 // Pick whichever viable option displaces fewer other zones.
2118 ZonePriorityMap byPriority = buildPriorityMap( board(), zone );
2119
2120 // Option A: take minOverlapping, cascade displaced zones up
2121 bool cascadeUpViable = false;
2122 std::vector<ZONE*> cascadeUp =
2123 findCascadeZones( byPriority, minOverlapping, true, cascadeUpViable );
2124
2125 // Option B: take minOverlapping - 1, cascade displaced zones down
2126 bool cascadeDownViable = false;
2127 std::vector<ZONE*> cascadeDown;
2128 bool canCascadeDown = ( minOverlapping > 0 );
2129
2130 if( canCascadeDown )
2131 {
2132 cascadeDown =
2133 findCascadeZones( byPriority, minOverlapping - 1, false, cascadeDownViable );
2134 }
2135
2136 if( !cascadeUpViable && !cascadeDownViable )
2137 return 0;
2138
2139 BOARD_COMMIT commit( m_frame );
2140 commit.Modify( zone );
2141
2142 bool useUp = cascadeUpViable
2143 && ( !cascadeDownViable || cascadeUp.size() <= cascadeDown.size() );
2144
2145 if( useUp )
2146 {
2147 zone->SetAssignedPriority( minOverlapping );
2148
2149 for( ZONE* z : cascadeUp )
2150 {
2151 commit.Modify( z );
2153 z->SetNeedRefill( true );
2154 }
2155 }
2156 else
2157 {
2158 zone->SetAssignedPriority( minOverlapping - 1 );
2159
2160 for( ZONE* z : cascadeDown )
2161 {
2162 commit.Modify( z );
2164 z->SetNeedRefill( true );
2165 }
2166 }
2167
2168 zone->SetNeedRefill( true );
2169 commit.Push( _( "Move Zone to Bottom Priority" ) );
2170
2171 return 0;
2172}
2173
2174
2176{
2177 m_frame->GetBoard()->OnBoardSelectionChanged();
2178 doCrossProbePcbToSch( aEvent, false );
2179 return 0;
2180}
2181
2182
2184{
2185 doCrossProbePcbToSch( aEvent, true );
2186 return 0;
2187}
2188
2189
2191{
2192 // Don't get in an infinite loop PCB -> SCH -> PCB -> SCH -> ...
2193 if( m_frame->m_ProbingSchToPcb )
2194 return;
2195
2196 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
2197 const PCB_SELECTION& selection = selTool->GetSelection();
2198 EDA_ITEM* focusItem = nullptr;
2199
2200 if( aEvent.Matches( EVENTS::PointSelectedEvent ) )
2201 focusItem = selection.GetLastAddedItem();
2202
2203 m_frame->SendSelectItemsToSch( selection.GetItems(), focusItem, aForce );
2204
2205 // Update 3D viewer highlighting
2206 m_frame->Update3DView( false, frame()->GetPcbNewSettings()->m_Display.m_Live3DRefresh );
2207}
2208
2209
2211{
2212 PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
2213
2214 const PCB_SELECTION& selection = selectionTool->RequestSelection(
2215 []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
2216 {
2217 // Iterate from the back so we don't have to worry about removals.
2218 for( int i = aCollector.GetCount() - 1; i >= 0; --i )
2219 {
2220 if( !dynamic_cast<BOARD_CONNECTED_ITEM*>( aCollector[ i ] ) )
2221 aCollector.Remove( aCollector[ i ] );
2222 }
2223
2224 sTool->FilterCollectorForLockedItems( aCollector );
2225 } );
2226
2227 if( selectionTool->ReportFilteredLockedItems() )
2228 return 0;
2229
2230 std::set<wxString> netNames;
2231 std::set<int> netCodes;
2232
2233 for( EDA_ITEM* item : selection )
2234 {
2235 const NETINFO_ITEM& net = *static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNet();
2236
2237 if( !net.HasAutoGeneratedNetname() )
2238 {
2239 netNames.insert( net.GetNetname() );
2240 netCodes.insert( net.GetNetCode() );
2241 }
2242 }
2243
2244 if( netNames.empty() )
2245 {
2246 m_frame->ShowInfoBarError( _( "Selection contains no items with labeled nets." ) );
2247 return 0;
2248 }
2249
2250 selectionTool->ClearSelection();
2251 for( const int& code : netCodes )
2252 {
2253 m_toolMgr->RunAction( PCB_ACTIONS::selectNet, code );
2254 }
2255 canvas()->ForceRefresh();
2256
2257 DIALOG_ASSIGN_NETCLASS dlg( m_frame, netNames, board()->GetNetClassAssignmentCandidates(),
2258 [this]( const std::vector<wxString>& aNetNames )
2259 {
2260 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
2261 selTool->ClearSelection();
2262
2263 for( const wxString& curr_netName : aNetNames )
2264 {
2265 int curr_netCode = board()->GetNetInfo().GetNetItem( curr_netName )->GetNetCode();
2266
2267 if( curr_netCode > 0 )
2268 selTool->SelectAllItemsOnNet( curr_netCode );
2269 }
2270
2271 canvas()->ForceRefresh();
2272 m_frame->UpdateMsgPanel();
2273 } );
2274
2275 if( dlg.ShowModal() == wxID_OK )
2276 {
2278 // Refresh UI that depends on netclasses, such as the properties panel
2280 }
2281
2282 return 0;
2283}
2284
2285
2287{
2288 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
2289 const PCB_SELECTION& selection = selTool->RequestSelection( EDIT_TOOL::FootprintFilter );
2290
2291 if( selection.Empty() )
2292 {
2293 // Giant hack: by default we assign Edit Table to the same hotkey, so give the table
2294 // tool a chance to handle it if we can't.
2295 if( PCB_EDIT_TABLE_TOOL* tableTool = m_toolMgr->GetTool<PCB_EDIT_TABLE_TOOL>() )
2296 tableTool->EditTable( aEvent );
2297
2298 return 0;
2299 }
2300
2301 FOOTPRINT* fp = selection.FirstOfKind<FOOTPRINT>();
2302
2303 if( !fp )
2304 return 0;
2305
2307
2308 if( KIWAY_PLAYER* frame = editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ) )
2309 {
2310 FOOTPRINT_EDIT_FRAME* fp_editor = static_cast<FOOTPRINT_EDIT_FRAME*>( frame );
2311
2313 fp_editor->LoadFootprintFromBoard( fp );
2314 else if( aEvent.IsAction( &PCB_ACTIONS::editLibFpInFpEditor ) )
2315 fp_editor->LoadFootprintFromLibrary( fp->GetFPID() );
2316
2317 fp_editor->Show( true );
2318 fp_editor->Raise(); // Iconize( false );
2319 }
2320
2321 if( selection.IsHover() )
2322 m_toolMgr->RunAction( ACTIONS::selectionClear );
2323
2324 return 0;
2325}
2326
2327
2329 EDA_ITEM* originViewItem, const VECTOR2D& aPosition )
2330{
2331 aFrame->GetDesignSettings().SetAuxOrigin( VECTOR2I( aPosition ) );
2332 originViewItem->SetPosition( aPosition );
2333 aView->MarkDirty();
2334 aFrame->OnModify();
2335}
2336
2337
2339{
2341 {
2342 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::GRIDORIGIN );
2344 return 0;
2345 }
2346
2347 if( aEvent.IsAction( &PCB_ACTIONS::drillSetOrigin ) )
2348 {
2349 VECTOR2I origin = aEvent.Parameter<VECTOR2I>();
2350 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::GRIDORIGIN );
2351 DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), origin );
2352 return 0;
2353 }
2354
2355 PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
2356
2357 // Deactivate other tools; particularly important if another PICKER is currently running
2358 Activate();
2359
2360 picker->SetCursor( KICURSOR::PLACE );
2361 picker->ClearHandlers();
2362
2363 picker->SetClickHandler(
2364 [this] ( const VECTOR2D& pt ) -> bool
2365 {
2366 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::DRILLORIGIN );
2368 return false; // drill origin is a one-shot; don't continue with tool
2369 } );
2370
2371 m_toolMgr->RunAction( ACTIONS::pickerTool, &aEvent );
2372
2373 return 0;
2374}
2375
2376
2378{
2388
2394
2403
2404 if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist && m_frame && m_frame->GetExportNetlistAction() )
2405 Go( &BOARD_EDITOR_CONTROL::ExportNetlist, m_frame->GetExportNetlistAction()->MakeEvent() );
2406
2416
2423
2424 // Track & via size control
2430
2431 // Zone actions
2438
2439 // Placing tools
2444
2447
2448 // Cross-select
2454
2455 // Other
2459
2461
2473 // Line modes: explicit, next, and notification
2478}
const char * name
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
#define SKIP_TEARDROPS
static bool mergeZones(EDA_DRAW_FRAME *aFrame, BOARD_COMMIT &aCommit, std::vector< ZONE * > &aOriginZones, std::vector< ZONE * > &aMergedZones)
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
static TOOL_ACTION updatePcbFromSchematic
Definition actions.h:261
static TOOL_ACTION cancelInteractive
Definition actions.h:69
static TOOL_ACTION revert
Definition actions.h:58
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition actions.h:224
static TOOL_ACTION saveAs
Definition actions.h:55
static TOOL_ACTION exportForOlderVersion
Definition actions.h:60
static TOOL_ACTION pickerTool
Definition actions.h:250
static TOOL_ACTION findPrevious
Definition actions.h:117
static TOOL_ACTION plot
Definition actions.h:62
static TOOL_ACTION open
Definition actions.h:53
static TOOL_ACTION findNext
Definition actions.h:116
static TOOL_ACTION pageSettings
Definition actions.h:59
static TOOL_ACTION showSearch
Definition actions.h:113
static TOOL_ACTION undo
Definition actions.h:72
static TOOL_ACTION showGitCommitPane
Definition actions.h:264
static TOOL_ACTION save
Definition actions.h:54
static TOOL_ACTION redo
Definition actions.h:73
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:50
static TOOL_ACTION saveCopy
Definition actions.h:56
static TOOL_ACTION refreshPreview
Definition actions.h:156
static TOOL_ACTION find
Definition actions.h:114
ACTION_MENU(bool isContextMenu, TOOL_INTERACTIVE *aTool=nullptr)
Default constructor.
TOOL_MANAGER * getToolManager() const
Return an instance of TOOL_MANAGER class.
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:81
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
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 NETINFO_ITEM 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
int GetNextDiffPairIndex(int aIndex, bool aForward) const
Compute the next diff pair dimensions list index when cycling predefined sizes, skipping the index-0 ...
void SetViaSizeIndex(int aIndex)
Set the current via size list index to aIndex.
int GetNextTrackWidthIndex(int aIndex, bool aForward) const
Compute the next track width list index when cycling predefined sizes, skipping the index-0 netclass ...
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.
int GetNextViaSizeIndex(int aIndex, bool aForward) const
Compute the next via size list index when cycling predefined sizes, skipping the index-0 netclass pla...
std::vector< int > m_TrackWidthList
std::vector< VIA_DIMENSION > m_ViasDimensionsList
int ExportNetlist(const TOOL_EVENT &aEvent)
int UnlockSelected(const TOOL_EVENT &aEvent)
Unlock selected items.
int Save(const TOOL_EVENT &aEvent)
int ImportNetlist(const TOOL_EVENT &aEvent)
int GenerateDrillFiles(const TOOL_EVENT &aEvent)
int ZoneMerge(const TOOL_EVENT &aEvent)
int CrossProbeToSch(const TOOL_EVENT &aEvent)
Notify Eeschema about selected items.
int ZonePriorityMoveToTop(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)
Low-level access (below undo) to setting the drill origin.
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)
Assign a netclass to a labelled net.
int ToggleNetInspector(const TOOL_EVENT &aEvent)
int UpdateSchematicFromPCB(const TOOL_EVENT &aEvent)
int ZonePriorityRaise(const TOOL_EVENT &aEvent)
int ExplicitCrossProbeToSch(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
int ExportHyperlynx(const TOOL_EVENT &aEvent)
int ToggleSearch(const TOOL_EVENT &aEvent)
int DrillOrigin(const TOOL_EVENT &aEvent)
Run the drill origin tool for setting the origin for drill and pick-and-place files.
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)
Duplicate a zone onto a layer (prompts for new layer)
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 GenerateBOM(const TOOL_EVENT &aEvent)
int ToggleGitCommitPane(const TOOL_EVENT &aEvent)
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 ZonePriorityLower(const TOOL_EVENT &aEvent)
int modifyLockSelected(MODIFY_MODE aMode)
void setTransitions() override
Set up handlers for various events.
int TrackWidthInc(const TOOL_EVENT &aEvent)
int GenerateODBPPFiles(const TOOL_EVENT &aEvent)
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Toggle 'lock' property for selected items.
int ToggleConstraintsPanel(const TOOL_EVENT &aEvent)
int AutoTrackWidth(const TOOL_EVENT &aEvent)
int LockSelected(const TOOL_EVENT &aEvent)
Lock selected items.
int PageSettings(const TOOL_EVENT &aEvent)
int ExportSpecctraDSN(const TOOL_EVENT &aEvent)
int FindByProperties(const TOOL_EVENT &aEvent)
int EditFootprintFields(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 DesignRules(const TOOL_EVENT &aEvent)
int GenFootprintsReport(const TOOL_EVENT &aEvent)
int ExportForOlderVersion(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)
int ZonePriorityMoveToBottom(const TOOL_EVENT &aEvent)
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:99
void SetLocked(bool aLocked) override
Definition board_item.h:441
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
virtual void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const
Invoke a function on all children.
Definition board_item.h:279
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
const NETINFO_LIST & GetNetInfo() const
Definition board.h:1241
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1548
const ZONES & Zones() const
Definition board.h:469
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition board.cpp:3268
int RepairDuplicateItemUuids()
Rebind duplicate attached-item UUIDs so each live board item has a unique ID.
Definition board.cpp:2326
int GetCount() const
Return the number of objects in the list.
Definition collector.h:79
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition collector.h:107
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition commit.h:86
bool Empty() const
Definition commit.h:145
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:102
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Definition commit.h:74
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
Definition commit.cpp:235
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:38
bool Show(bool show) override
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 NONE if not currently in any drawing mode.
MODE
The possible drawing modes of DRAWING_TOOL.
void SelectToolbarAction(const TOOL_ACTION &aAction) override
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:43
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:349
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition eda_item.h:158
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.cpp:153
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:94
static const TOOL_EVENT ClearedEvent
Definition actions.h:349
static const TOOL_EVENT SelectedEvent
Definition actions.h:347
static const TOOL_EVENT SelectedItemsModified
Selected item had a property changed (except movement)
Definition actions.h:354
static const TOOL_EVENT PointSelectedEvent
Definition actions.h:346
static const TOOL_EVENT UnselectedEvent
Definition actions.h:348
Used for text file output.
Definition richio.h:483
bool Finish() override
Flushes the temp file to disk and atomically renames it over the final target path.
Definition richio.cpp:682
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:1157
void SetOrientation(const EDA_ANGLE &aNewAngle)
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
std::deque< PAD * > & Pads()
Definition footprint.h:355
bool IsFlipped() const
Definition footprint.h:620
const LIB_ID & GetFPID() const
Definition footprint.h:417
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I GetPosition() const override
Definition footprint.h:379
Used when the right click button is pressed, or when the select tool is in effect.
Definition collectors.h:203
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()
wxString m_outputFile
Where to write the downgraded copy.
wxString m_filename
Input board file (may be empty to downgrade only libraries)
wxString m_variant
Flatten this variant into the export. Empty means the base design.
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
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:82
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:68
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition view.cpp:365
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition view.cpp:488
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:2630
void MarkDirty()
Force redraw of view on the next rendering.
Definition view.h:779
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:407
@ FACE_PCB
pcbnew DSO
Definition kiway.h:356
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:158
int GetViaDrill() const
Definition netclass.h:166
int GetTrackWidth() const
Definition netclass.h:150
Handle the data for a net.
Definition netinfo.h:50
const wxString & GetNetname() const
Definition netinfo.h:110
int GetNetCode() const
Definition netinfo.h:104
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() const
Gets the default netclass for the project.
@ NORMAL
Shape is the same on all layers.
Definition padstack.h:175
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
Definition padstack.h:184
Definition pad.h:61
static TOOL_ACTION lineModeFree
Unconstrained angle mode (icon lines_any)
static TOOL_ACTION showConstraintsPanel
Toggle the docked constraints pane (board editor).
static TOOL_ACTION zonesManager
static TOOL_ACTION generateBOM
static TOOL_ACTION drcRuleEditor
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 zonePriorityMoveToBottom
static TOOL_ACTION zonePriorityMoveToTop
static TOOL_ACTION viaSizeInc
static TOOL_ACTION angleSnapModeChanged
Notification event when angle mode changes.
static TOOL_ACTION generateBOMLegacy
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 findByProperties
Find items by property criteria or expression.
static TOOL_ACTION generateGerbers
static TOOL_ACTION generateReportFile
static TOOL_ACTION exportHyperlynx
static TOOL_ACTION zonePriorityLower
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 editFootprintFields
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 zonePriorityRaise
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.
void SetLocked(bool aLocked) override
Generic tool for picking an item.
void ClearHandlers()
Handlers only.
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.
bool ReportFilteredLockedItems()
If the most recent FilterCollectorForLockedItems call filtered a locked item, show an InfoBar warning...
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
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:93
virtual int GetWidth() const
Definition pcb_track.h:94
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:600
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:63
ROUTER_MODE Mode() const
Definition pns_router.h:183
RouterState GetState() const
Definition pns_router.h:185
ROUTER * Router() const
Container for project specific data.
Definition project.h:63
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.
int Size() const
Returns the number of selected parts.
Definition selection.h:120
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.
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
int TotalVertices() const
Return total number of vertices stored in the set.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition tool_base.h:182
T * getModel() const
Return the model object if it matches the requested type.
Definition tool_base.h:195
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition tool_base.cpp:40
TOOL_MANAGER * m_toolMgr
Definition tool_base.h:220
KIGFX::VIEW * getView() const
Return the instance of KIGFX::VIEW object used in the application.
Definition tool_base.cpp:34
bool IsToolActive() const
Definition tool_base.cpp:28
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
@ REDRAW
Full drawing refresh.
Definition tool_base.h:79
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:76
@ GAL_SWITCH
Rendering engine changes.
Definition tool_base.h:78
Generic, UI-independent tool event.
Definition tool_event.h:167
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:256
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition tool_event.h:388
const VECTOR2D Position() const
Return mouse cursor position in world coordinates.
Definition tool_event.h:289
bool IsReactivate() const
Control whether the tool is first being pushed to the stack or being reactivated after a pause.
Definition tool_event.h:269
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:484
void RunMainStack(std::function< void()> aFunc)
Call a function using the main stack.
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.
T * GetTool()
Return the tool of given type or nullptr if there is no such tool registered.
Manage a CONDITIONAL_MENU and some number of CONTEXT_MENUs as sub-menus.
Definition tool_menu.h:39
CONDITIONAL_MENU & GetMenu()
Definition tool_menu.cpp:40
void RegisterSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition tool_menu.cpp:46
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)
ACTION_MENU * create() const override
Return an instance of this class. It has to be overridden in inheriting classes.
void update() override
Update menu state stub.
Handle zones parameters.
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Copy settings to a given zone.
Handle a list of polygons defining a copper zone.
Definition zone.h:70
void SetNeedRefill(bool aNeedRefill)
Definition zone.h:310
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition zone.h:834
const BOX2I GetBoundingBox() const override
Definition zone.cpp:824
SHAPE_POLY_SET GetBoardOutline() const
Definition zone.cpp:953
bool IsTeardropArea() const
Definition zone.h:809
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition zone.h:133
bool IsOnCopperLayer() const override
Definition zone.cpp:652
void SetAssignedPriority(unsigned aPriority)
Definition zone.h:117
unsigned GetAssignedPriority() const
Definition zone.h:122
@ CHT_MODIFY
Definition commit.h:40
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:245
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
This file is part of the common library.
@ PLACE
Definition cursors.h:95
@ ARROW
Definition cursors.h:43
@ PENCIL
Definition cursors.h:49
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition cvpcb.cpp:178
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE *aZone, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Invoke a modal dialog window for copper zone editing.
void RunExportForOlderVersion(EDA_BASE_FRAME *aFrame, const DOWNGRADE_EXPORT_RUNNER &aRun)
bool RunDowngradeJob(KIWAY &aKiway, KIWAY::FACE_T aFace, JOB_T &aJob, const DOWNGRADE_EXPORT_PASS &aPass, DOWNGRADE_EXPORT_RESULT &aResult)
Fill in the parts of a downgrade job that every editor sets the same way, run it, and hand back its r...
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Invoke a modal dialog window for non-copper zone editing.
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aZoneSettings, BOARD *aBoard, CONVERT_SETTINGS *aConvertSettings)
Invoke a modal dialog window for copper zone editing.
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:472
@ RECURSE
Definition eda_item.h:51
#define IS_NEW
New item, just created.
KiCad executable names.
const wxString EESCHEMA_EXE
@ FRAME_SCH
Definition frame_type.h:30
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:39
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:170
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:43
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:54
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:51
void AllowNetworkFileSystems(wxDialog *aDialog)
Configure a file dialog to show network and virtual file systems.
Definition wxgtk/ui.cpp:741
@ PNS_MODE_ROUTE_DIFF_PAIR
Definition pns_router.h:70
#define MAX_PAGE_SIZE_PCBNEW_MILS
Definition page_info.h:31
EDA_ANGLE GridFrameAngleAt(const BOARD &aBoard, const VECTOR2I &aPos, PCB_GRID_ROLE aRole)
World frame angle of the grid active for aRole at aPos; ANGLE_0 when no grid applies.
EDA_ANGLE GridFrameRotationDelta(const EDA_ANGLE &aFrom, const EDA_ANGLE &aTo, const EDA_ANGLE &aRotationStep)
Minimal rotation that re-aligns an item from frame angle aFrom to aTo, reduced modulo min( aRotationS...
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
What one pass of an export is asked to do.
wxString m_variant
Variant to flatten, empty for the base design.
bool m_dryRun
Classify only, write nothing.
wxString m_folder
Destination, empty on a dry run.
What the flow needs back from a pass.
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
std::string netlist
std::string path
wxString result
Test unit parsing edge cases and error handling.
int delta
@ BUT_LEFT
Definition tool_event.h:128
@ BUT_RIGHT
Definition tool_event.h:129
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:83
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:89
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:78
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707
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.