KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 <maciej.suminski@cern.ch>
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 <advanced_config.h>
33#include <bitmaps.h>
34#include <pcb_painter.h>
35#include <board.h>
36#include <board_commit.h>
38#include <pcb_generator.h>
39#include <footprint.h>
40#include <pad.h>
41#include <pcb_target.h>
42#include <pcb_track.h>
43#include <zone.h>
44#include <pcb_marker.h>
45#include <confirm.h>
49#include <kiface_base.h>
50#include <kiway.h>
52#include <origin_viewitem.h>
53#include <pcb_edit_frame.h>
54#include <pcbnew_id.h>
55#include <project.h>
56#include <project/project_file.h> // LAST_PATH_TYPE
57#include <tool/tool_manager.h>
58#include <tool/tool_event.h>
59#include <tools/drawing_tool.h>
60#include <tools/pcb_actions.h>
65#include <tools/edit_tool.h>
68#include <richio.h>
69#include <router/router_tool.h>
70#include <view/view_controls.h>
71#include <view/view_group.h>
75#include <wx/filedlg.h>
76#include <wx/msgdlg.h>
77#include <wx/log.h>
78
80
81using namespace std::placeholders;
82
83
85{
86public:
88 ACTION_MENU( true )
89 {
90 SetIcon( BITMAPS::add_zone );
91 SetTitle( _( "Zones" ) );
92
97
98 AppendSeparator();
99
104
105 AppendSeparator();
106
108 }
109
110protected:
111 ACTION_MENU* create() const override
112 {
113 return new ZONE_CONTEXT_MENU();
114 }
115};
116
117
119{
120public:
122 CONDITIONAL_MENU( aTool )
123 {
124 SetIcon( BITMAPS::locked );
125 SetTitle( _( "Locking" ) );
126
130 }
131
132 ACTION_MENU* create() const override
133 {
134 return new LOCK_CONTEXT_MENU( this->m_tool );
135 }
136};
137
138
140 PCB_TOOL_BASE( "pcbnew.EditorControl" ),
141 m_frame( nullptr ),
142 m_inPlaceFootprint( false ),
143 m_placingFootprint( false ),
144 m_inPlaceTarget( false )
145{
146 m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
148}
149
150
152{
153}
154
155
157{
158 m_frame = getEditFrame<PCB_EDIT_FRAME>();
159
160 if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW )
161 {
162 m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().GetAuxOrigin() );
163 getView()->Remove( m_placeOrigin.get() );
164 getView()->Add( m_placeOrigin.get() );
165 }
166}
167
168
170{
171 auto activeToolCondition =
172 [this]( const SELECTION& aSel )
173 {
174 return ( !m_frame->ToolStackIsEmpty() );
175 };
176
177 auto inactiveStateCondition =
178 [this]( const SELECTION& aSel )
179 {
180 return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
181 };
182
183 auto placeModuleCondition =
184 [this]( const SELECTION& aSel )
185 {
186 return m_frame->IsCurrentTool( PCB_ACTIONS::placeFootprint ) && aSel.GetSize() == 0;
187 };
188
189 auto& ctxMenu = m_menu->GetMenu();
190
191 // "Cancel" goes at the top of the context menu when a tool is active
192 ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
193 ctxMenu.AddSeparator( 1 );
194
195 // "Get and Place Footprint" should be available for Place Footprint tool
196 ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
197 ctxMenu.AddSeparator( 1000 );
198
199 // Finally, add the standard zoom & grid items
200 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( *m_menu.get() );
201
202 std::shared_ptr<ZONE_CONTEXT_MENU> zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
203 zoneMenu->SetTool( this );
204
205 std::shared_ptr<LOCK_CONTEXT_MENU> lockMenu = std::make_shared<LOCK_CONTEXT_MENU>( this );
206
207 // Add the PCB control menus to relevant other tools
208
210
211 if( selTool )
212 {
213 TOOL_MENU& toolMenu = selTool->GetToolMenu();
214 CONDITIONAL_MENU& menu = toolMenu.GetMenu();
215
216 // Add "Get and Place Footprint" when Selection tool is in an inactive state
217 menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
218 menu.AddSeparator();
219
220 toolMenu.RegisterSubMenu( zoneMenu );
221 toolMenu.RegisterSubMenu( lockMenu );
222
223 menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
224
225 menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyTypes( { PCB_ZONE_T } ), 100 );
226 }
227
228 DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
229
230 if( drawingTool )
231 {
232 TOOL_MENU& toolMenu = drawingTool->GetToolMenu();
233 CONDITIONAL_MENU& menu = toolMenu.GetMenu();
234
235 toolMenu.RegisterSubMenu( zoneMenu );
236
237 // Functor to say if the PCB_EDIT_FRAME is in a given mode
238 // Capture the tool pointer and tool mode by value
239 auto toolActiveFunctor =
240 [=]( DRAWING_TOOL::MODE aMode )
241 {
242 return [=]( const SELECTION& sel )
243 {
244 return drawingTool->GetDrawingMode() == aMode;
245 };
246 };
247
248 menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 300 );
249 }
250
251 return true;
252}
253
254
256{
258 return 0;
259}
260
261
263{
265 return 0;
266}
267
268
270{
272 return 0;
273}
274
275
277{
279 return 0;
280}
281
282
284{
286 return 0;
287}
288
289
291{
293 return 0;
294}
295
296
298{
299 PICKED_ITEMS_LIST undoCmd;
301 ITEM_PICKER wrapper( nullptr, undoItem, UNDO_REDO::PAGESETTINGS );
302
303 undoCmd.PushItem( wrapper );
304 undoCmd.SetDescription( _( "Page Settings" ) );
305 m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS );
306
310
311 if( dlg.ShowModal() == wxID_OK )
312 {
314 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
315 {
316 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
317
318 if( text && text->HasTextVars() )
319 {
320 text->ClearRenderCache();
321 text->ClearBoundingBoxCache();
323 }
324
325 return 0;
326 } );
327
328 m_frame->OnModify();
329 }
330 else
331 {
333 }
334
335 return 0;
336}
337
338
340{
342 return 0;
343}
344
345
347{
349 return 0;
350}
351
352
354{
356 return 0;
357}
358
359
361{
363 return 0;
364}
365
366
368{
369 getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
370 return 0;
371}
372
373
375{
376 getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
377 return 0;
378}
379
380
382{
383 wxString fullFileName = frame()->GetBoard()->GetFileName();
384 wxString path;
385 wxString name;
386 wxString ext;
387
388 wxFileName::SplitPath( fullFileName, &path, &name, &ext );
389 name += wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension );
390
391 fullFileName = wxFileSelector( _( "Specctra Session File" ), path, name,
392 wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension ),
393 FILEEXT::SpecctraSessionFileWildcard(), wxFD_OPEN | wxFD_CHANGE_DIR,
394 frame() );
395
396 if( !fullFileName.IsEmpty() )
397 getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
398
399 return 0;
400}
401
402
404{
405 wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
406 wxFileName fn;
407
408 if( fullFileName.IsEmpty() )
409 {
410 fn = m_frame->GetBoard()->GetFileName();
412 }
413 else
414 {
415 fn = fullFileName;
416 }
417
418 fullFileName = wxFileSelector( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
420 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR, frame() );
421
422 if( !fullFileName.IsEmpty() )
423 {
424 m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
425 getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
426 }
427
428 return 0;
429}
430
431
433{
434 wxCHECK( m_frame, 0 );
435
436 wxFileName fn = m_frame->Prj().GetProjectFullName();
437
438 // Use a different file extension for the board netlist so the schematic netlist file
439 // is accidentally overwritten.
440 fn.SetExt( wxT( "pcb_net" ) );
441
442 wxFileDialog dlg( m_frame, _( "Export Board Netlist" ), fn.GetPath(), fn.GetFullName(),
443 _( "KiCad board netlist files" ) + AddFileExtListToFilter( { "pcb_net" } ),
444 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
445
446 dlg.SetExtraControlCreator( &LEGACYFILEDLG_NETLIST_OPTIONS::Create );
447
448 if( dlg.ShowModal() == wxID_CANCEL )
449 return 0;
450
451 fn = dlg.GetPath();
452
453 if( !fn.IsDirWritable() )
454 {
455 wxString msg;
456
457 msg.Printf( _( "Path `%s` is read only." ), fn.GetPath() );
458 wxMessageDialog( m_frame, msg, _( "I/O Error" ), wxOK | wxCENTER | wxICON_EXCLAMATION );
459 return 0;
460 }
461
463 dynamic_cast<const LEGACYFILEDLG_NETLIST_OPTIONS*>( dlg.GetExtraControl() );
464 wxCHECK( noh, 0 );
465
467
468 for( const FOOTPRINT* footprint : board()->Footprints() )
469 {
472 { footprint->m_Uuid } );
473
474 for( const PAD* pad : footprint->Pads() )
475 {
476 const wxString& netname = pad->GetShortNetname();
477
478 if( !netname.IsEmpty() )
479 {
480 component->AddNet( pad->GetNumber(), netname, pad->GetPinFunction(),
481 pad->GetPinType() );
482 }
483 }
484
485 nlohmann::ordered_map<wxString, wxString> fields;
486
487 for( PCB_FIELD* field : footprint->GetFields() )
488 fields[field->GetCanonicalName()] = field->GetText();
489
490 component->SetFields( fields );
491
492 netlist.AddComponent( component );
493 }
494
495 FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
496
497 netlist.Format( "pcb_netlist", &formatter, 0, noh->GetNetlistOptions() );
498
499 return 0;
500}
501
502
504{
505 wxCommandEvent dummy;
506
509 else if( aEvent.IsAction( &PCB_ACTIONS::generateReportFile ) )
511 else if( aEvent.IsAction( &PCB_ACTIONS::generateD356File ) )
513 else if( aEvent.IsAction( &PCB_ACTIONS::generateBOM ) )
515 else if( aEvent.IsAction( &PCB_ACTIONS::generateIPC2581File ) )
517 else if( aEvent.IsAction( &PCB_ACTIONS::generateODBPPFile ) )
519 else
520 wxFAIL_MSG( wxT( "GenerateFabFiles(): unexpected request" ) );
521
522 return 0;
523}
524
525
527{
528 int errors = 0;
529 wxString details;
530 bool quiet = aEvent.Parameter<bool>();
531
532 // Repair duplicate IDs and missing nets.
533 std::set<KIID> ids;
534 int duplicates = 0;
535
536 auto processItem =
537 [&]( EDA_ITEM* aItem )
538 {
539 if( ids.count( aItem->m_Uuid ) )
540 {
541 duplicates++;
542 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
543 }
544
545 ids.insert( aItem->m_Uuid );
546
547 BOARD_CONNECTED_ITEM* cItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
548
549 if( cItem && cItem->GetNetCode() )
550 {
551 NETINFO_ITEM* netinfo = cItem->GetNet();
552
553 if( netinfo && !board()->FindNet( netinfo->GetNetname() ) )
554 {
555 board()->Add( netinfo );
556
557 details += wxString::Format( _( "Orphaned net %s re-parented.\n" ),
558 netinfo->GetNetname() );
559 errors++;
560 }
561 }
562 };
563
564 // Footprint IDs are the most important, so give them the first crack at "claiming" a
565 // particular KIID.
566
567 for( FOOTPRINT* footprint : board()->Footprints() )
568 processItem( footprint );
569
570 // After that the principal use is for DRC marker pointers, which are most likely to pads
571 // or tracks.
572
573 for( FOOTPRINT* footprint : board()->Footprints() )
574 {
575 for( PAD* pad : footprint->Pads() )
576 processItem( pad );
577 }
578
579 for( PCB_TRACK* track : board()->Tracks() )
580 processItem( track );
581
582 // From here out I don't think order matters much.
583
584 for( FOOTPRINT* footprint : board()->Footprints() )
585 {
586 processItem( &footprint->Reference() );
587 processItem( &footprint->Value() );
588
589 for( BOARD_ITEM* item : footprint->GraphicalItems() )
590 processItem( item );
591
592 for( ZONE* zone : footprint->Zones() )
593 processItem( zone );
594
595 for( PCB_GROUP* group : footprint->Groups() )
596 processItem( group );
597 }
598
599 for( BOARD_ITEM* drawing : board()->Drawings() )
600 processItem( drawing );
601
602 for( ZONE* zone : board()->Zones() )
603 processItem( zone );
604
605 for( PCB_MARKER* marker : board()->Markers() )
606 processItem( marker );
607
608 for( PCB_GROUP* group : board()->Groups() )
609 processItem( group );
610
611 if( duplicates )
612 {
613 errors += duplicates;
614 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
615 }
616
617 /*******************************
618 * Your test here
619 */
620
621 /*******************************
622 * Inform the user
623 */
624
625 if( errors )
626 {
627 m_frame->OnModify();
628
629 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
630
631 if( !quiet )
632 DisplayInfoMessage( m_frame, msg, details );
633 }
634 else if( !quiet )
635 {
636 DisplayInfoMessage( m_frame, _( "No board problems found." ) );
637 }
638
639 return 0;
640}
641
642
644{
646
647 if( m_frame->FetchNetlistFromSchematic( netlist, _( "Updating PCB requires a fully annotated "
648 "schematic." ) ) )
649 {
650 DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
651 updateDialog.ShowModal();
652 }
653
654 return 0;
655}
656
658{
659 if( Kiface().IsSingle() )
660 {
661 DisplayErrorMessage( m_frame, _( "Cannot update schematic because Pcbnew is opened in "
662 "stand-alone mode. In order to create or update PCBs "
663 "from schematics, you must launch the KiCad project "
664 "manager and create a project." ) );
665 return 0;
666 }
667
670
671 if( frame )
672 {
673 std::string payload;
674
675 if( wxWindow* blocking_win = frame->Kiway().GetBlockingDialog() )
676 blocking_win->Close( true );
677
679 }
680 return 0;
681}
682
683
685{
687 return 0;
688}
689
690
692{
693 getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
694 return 0;
695}
696
697
699{
700 getEditFrame<PCB_EDIT_FRAME>()->ToggleProperties();
701 return 0;
702}
703
704
706{
707 getEditFrame<PCB_EDIT_FRAME>()->ToggleNetInspector();
708 return 0;
709}
710
711
713{
714 getEditFrame<PCB_EDIT_FRAME>()->ToggleLibraryTree();
715 return 0;
716}
717
718
720{
721 getEditFrame<PCB_EDIT_FRAME>()->ToggleSearch();
722 return 0;
723}
724
725
727{
729 return 0;
730}
731
732
733// Track & via size control
735{
736 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
738
740 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
741 {
742 BOARD_COMMIT commit( this );
743
744 for( EDA_ITEM* item : selection )
745 {
746 if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
747 {
748 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
749
750 for( int i = 0; i < (int) bds.m_TrackWidthList.size(); ++i )
751 {
752 int candidate = bds.m_NetSettings->GetDefaultNetclass()->GetTrackWidth();
753
754 if( i > 0 )
755 candidate = bds.m_TrackWidthList[ i ];
756
757 if( candidate > track->GetWidth() )
758 {
759 commit.Modify( track );
760 track->SetWidth( candidate );
761 break;
762 }
763 }
764 }
765 }
766
767 commit.Push( _( "Increase Track Width" ) );
768 return 0;
769 }
770
771 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
772
773 if( routerTool && routerTool->IsToolActive()
774 && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
775 {
776 int widthIndex = (int) bds.GetDiffPairIndex() + 1;
777
778 // If we go past the last track width entry in the list, start over at the beginning
779 if( widthIndex >= (int) bds.m_DiffPairDimensionsList.size() )
780 widthIndex = 0;
781
782 bds.SetDiffPairIndex( widthIndex );
783 bds.UseCustomDiffPairDimensions( false );
784
786 }
787 else
788 {
789 int widthIndex = (int) bds.GetTrackWidthIndex();
790
791 if( routerTool && routerTool->IsToolActive()
794 {
795 bds.m_TempOverrideTrackWidth = true;
796 }
797 else
798 {
799 widthIndex++;
800 }
801
802 // If we go past the last track width entry in the list, start over at the beginning
803 if( widthIndex >= (int) bds.m_TrackWidthList.size() )
804 widthIndex = 0;
805
806 bds.SetTrackWidthIndex( widthIndex );
807 bds.UseCustomTrackViaSize( false );
808
810 }
811
812 return 0;
813}
814
815
817{
818 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
820
822 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
823 {
824 BOARD_COMMIT commit( this );
825
826 for( EDA_ITEM* item : selection )
827 {
828 if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
829 {
830 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
831
832 for( int i = (int) bds.m_TrackWidthList.size() - 1; i >= 0; --i )
833 {
834 int candidate = bds.m_NetSettings->GetDefaultNetclass()->GetTrackWidth();
835
836 if( i > 0 )
837 candidate = bds.m_TrackWidthList[ i ];
838
839 if( candidate < track->GetWidth() )
840 {
841 commit.Modify( track );
842 track->SetWidth( candidate );
843 break;
844 }
845 }
846 }
847 }
848
849 commit.Push( _( "Decrease Track Width" ) );
850 return 0;
851 }
852
853 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
854
855 if( routerTool && routerTool->IsToolActive()
856 && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
857 {
858 int widthIndex = (int) bds.GetDiffPairIndex() - 1;
859
860 // If we get to the lowest entry start over at the highest
861 if( widthIndex < 0 )
862 widthIndex = (int) bds.m_DiffPairDimensionsList.size() - 1;
863
864 bds.SetDiffPairIndex( widthIndex );
865 bds.UseCustomDiffPairDimensions( false );
866
868 }
869 else
870 {
871 int widthIndex = (int) bds.GetTrackWidthIndex();
872
873 if( routerTool && routerTool->IsToolActive()
876 {
877 bds.m_TempOverrideTrackWidth = true;
878 }
879 else
880 {
881 widthIndex--;
882 }
883
884 // If we get to the lowest entry start over at the highest
885 if( widthIndex < 0 )
886 widthIndex = (int) bds.m_TrackWidthList.size() - 1;
887
888 bds.SetTrackWidthIndex( widthIndex );
889 bds.UseCustomTrackViaSize( false );
890
892 }
893
894 return 0;
895}
896
897
899{
900 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
902
904 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
905 {
906 BOARD_COMMIT commit( this );
907
908 for( EDA_ITEM* item : selection )
909 {
910 if( item->Type() == PCB_VIA_T )
911 {
912 PCB_VIA* via = static_cast<PCB_VIA*>( item );
913
914 for( int i = 0; i < (int) bds.m_ViasDimensionsList.size(); ++i )
915 {
916 VIA_DIMENSION dims( bds.m_NetSettings->GetDefaultNetclass()->GetViaDiameter(),
917 bds.m_NetSettings->GetDefaultNetclass()->GetViaDrill() );
918
919 if( i> 0 )
920 dims = bds.m_ViasDimensionsList[ i ];
921
922 // TODO(JE) padstacks
923 if( dims.m_Diameter > via->GetWidth( PADSTACK::ALL_LAYERS ) )
924 {
925 commit.Modify( via );
926 via->SetWidth( PADSTACK::ALL_LAYERS, dims.m_Diameter );
927 via->SetDrill( dims.m_Drill );
928 break;
929 }
930 }
931 }
932 }
933
934 commit.Push( _( "Increase Via Size" ) );
935 }
936 else
937 {
938 int sizeIndex = (int) bds.GetViaSizeIndex() + 1;
939
940 // If we go past the last via entry in the list, start over at the beginning
941 if( sizeIndex >= (int) bds.m_ViasDimensionsList.size() )
942 sizeIndex = 0;
943
944 bds.SetViaSizeIndex( sizeIndex );
945 bds.UseCustomTrackViaSize( false );
946
948 }
949
950 return 0;
951}
952
953
955{
956 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
958
960 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
961 {
962 BOARD_COMMIT commit( this );
963
964 for( EDA_ITEM* item : selection )
965 {
966 if( item->Type() == PCB_VIA_T )
967 {
968 PCB_VIA* via = static_cast<PCB_VIA*>( item );
969
970 for( int i = (int) bds.m_ViasDimensionsList.size() - 1; i >= 0; --i )
971 {
972 VIA_DIMENSION dims( bds.m_NetSettings->GetDefaultNetclass()->GetViaDiameter(),
973 bds.m_NetSettings->GetDefaultNetclass()->GetViaDrill() );
974
975 if( i > 0 )
976 dims = bds.m_ViasDimensionsList[ i ];
977
978 // TODO(JE) padstacks
979 if( dims.m_Diameter < via->GetWidth( PADSTACK::ALL_LAYERS ) )
980 {
981 commit.Modify( via );
982 via->SetWidth( PADSTACK::ALL_LAYERS, dims.m_Diameter );
983 via->SetDrill( dims.m_Drill );
984 break;
985 }
986 }
987 }
988 }
989
990 commit.Push( "Decrease Via Size" );
991 }
992 else
993 {
994 int sizeIndex = 0; // Assume we only have a single via size entry
995
996 // If there are more, cycle through them backwards
997 if( bds.m_ViasDimensionsList.size() > 0 )
998 {
999 sizeIndex = (int) bds.GetViaSizeIndex() - 1;
1000
1001 // If we get to the lowest entry start over at the highest
1002 if( sizeIndex < 0 )
1003 sizeIndex = (int) bds.m_ViasDimensionsList.size() - 1;
1004 }
1005
1006 bds.SetViaSizeIndex( sizeIndex );
1007 bds.UseCustomTrackViaSize( false );
1008
1010 }
1011
1012 return 0;
1013}
1014
1015
1017{
1018 BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
1019
1020 if( bds.UseCustomTrackViaSize() )
1021 {
1022 bds.UseCustomTrackViaSize( false );
1023 bds.m_UseConnectedTrackWidth = true;
1024 }
1025 else
1026 {
1028 }
1029
1030 return 0;
1031}
1032
1033
1035{
1036 if( m_inPlaceFootprint )
1037 return 0;
1038
1040
1041 FOOTPRINT* fp = aEvent.Parameter<FOOTPRINT*>();
1042 bool fromOtherCommand = fp != nullptr;
1044 BOARD_COMMIT commit( m_frame );
1045 BOARD* board = getModel<BOARD>();
1046 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
1047
1049
1050 m_frame->PushTool( aEvent );
1051
1052 auto setCursor =
1053 [&]()
1054 {
1055 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
1056 };
1057
1058 auto cleanup =
1059 [&] ()
1060 {
1062 commit.Revert();
1063
1064 if( fromOtherCommand )
1065 {
1067
1068 if( undo )
1069 {
1072 delete undo;
1073 }
1074 }
1075
1076 fp = nullptr;
1077 m_placingFootprint = false;
1078 };
1079
1080 Activate();
1081 // Must be done after Activate() so that it gets set into the correct context
1082 controls->ShowCursor( true );
1083 // Set initial cursor
1084 setCursor();
1085
1086 VECTOR2I cursorPos = controls->GetCursorPosition();
1087 bool ignorePrimePosition = false;
1088 bool reselect = false;
1089
1090 // Prime the pump
1091 if( fp )
1092 {
1093 m_placingFootprint = true;
1094 fp->SetPosition( cursorPos );
1097 }
1098 else if( aEvent.HasPosition() )
1099 {
1100 m_toolMgr->PrimeTool( aEvent.Position() );
1101 }
1102 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
1103 {
1104 m_toolMgr->PrimeTool( { 0, 0 } );
1105 ignorePrimePosition = true;
1106 }
1107
1108 // Main loop: keep receiving events
1109 while( TOOL_EVENT* evt = Wait() )
1110 {
1111 setCursor();
1112 cursorPos = controls->GetCursorPosition( !evt->DisableGridSnapping() );
1113
1114 if( reselect && fp )
1116
1117 if( evt->IsCancelInteractive() || ( fp && evt->IsAction( &ACTIONS::undo ) ) )
1118 {
1119 if( fp )
1120 {
1121 cleanup();
1122 }
1123 else
1124 {
1125 m_frame->PopTool( aEvent );
1126 break;
1127 }
1128 }
1129 else if( evt->IsActivate() )
1130 {
1131 if( fp )
1132 cleanup();
1133
1134 if( evt->IsMoveTool() )
1135 {
1136 // leave ourselves on the stack so we come back after the move
1137 break;
1138 }
1139 else
1140 {
1141 frame()->PopTool( aEvent );
1142 break;
1143 }
1144 }
1145 else if( evt->IsClick( BUT_LEFT ) )
1146 {
1147 if( !fp )
1148 {
1149 // Pick the footprint to be placed
1151
1152 if( fp == nullptr )
1153 continue;
1154
1155 // If we started with a hotkey which has a position then warp back to that.
1156 // Otherwise update to the current mouse position pinned inside the autoscroll
1157 // boundaries.
1158 if( evt->IsPrime() && !ignorePrimePosition )
1159 {
1160 cursorPos = evt->Position();
1161 getViewControls()->WarpMouseCursor( cursorPos, true );
1162 }
1163 else
1164 {
1166 cursorPos = getViewControls()->GetMousePosition();
1167 }
1168
1169 m_placingFootprint = true;
1170
1171 fp->SetLink( niluuid );
1172
1173 fp->SetFlags( IS_NEW ); // whatever
1174
1175 // Set parent so that clearance can be loaded
1176 fp->SetParent( board );
1178
1179 for( PAD* pad : fp->Pads() )
1180 {
1181 pad->SetLocalRatsnestVisible( m_frame->GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
1182
1183 // Pads in the library all have orphaned nets. Replace with Default.
1184 pad->SetNetCode( 0 );
1185 }
1186
1187 // Put it on FRONT layer,
1188 // (Can be stored flipped if the lib is an archive built from a board)
1189 if( fp->IsFlipped() )
1191
1192 fp->SetOrientation( ANGLE_0 );
1193 fp->SetPosition( cursorPos );
1194
1195 commit.Add( fp );
1197
1199 }
1200 else
1201 {
1203 commit.Push( _( "Place Footprint" ) );
1204 fp = nullptr; // to indicate that there is no footprint that we currently modify
1205 m_placingFootprint = false;
1206 }
1207 }
1208 else if( evt->IsClick( BUT_RIGHT ) )
1209 {
1210 m_menu->ShowContextMenu( selection() );
1211 }
1212 else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
1213 {
1214 fp->SetPosition( cursorPos );
1215 selection().SetReferencePoint( cursorPos );
1216 getView()->Update( &selection() );
1217 getView()->Update( fp );
1218 }
1219 else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) )
1220 {
1221 // Calling 'Properties' action clears the selection, so we need to restore it
1222 reselect = true;
1223 }
1224 else if( fp && ( ZONE_FILLER_TOOL::IsZoneFillAction( evt )
1225 || evt->IsAction( &ACTIONS::redo ) ) )
1226 {
1227 wxBell();
1228 }
1229 else
1230 {
1231 evt->SetPassEvent();
1232 }
1233
1234 // Enable autopanning and cursor capture only when there is a footprint to be placed
1235 controls->SetAutoPan( fp != nullptr );
1236 controls->CaptureCursor( fp != nullptr );
1237 }
1238
1239 controls->SetAutoPan( false );
1240 controls->CaptureCursor( false );
1241 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
1242
1243 return 0;
1244}
1245
1246
1248{
1249 return modifyLockSelected( TOGGLE );
1250}
1251
1252
1254{
1255 return modifyLockSelected( ON );
1256}
1257
1258
1260{
1261 return modifyLockSelected( OFF );
1262}
1263
1264
1266{
1268 const PCB_SELECTION& selection = selTool->GetSelection();
1269 BOARD_COMMIT commit( m_frame );
1270
1271 if( selection.Empty() )
1273
1274 // Resolve TOGGLE mode
1275 if( aMode == TOGGLE )
1276 {
1277 aMode = ON;
1278
1279 for( EDA_ITEM* item : selection )
1280 {
1281 if( !item->IsBOARD_ITEM() )
1282 continue;
1283
1284 if( static_cast<BOARD_ITEM*>( item )->IsLocked() )
1285 {
1286 aMode = OFF;
1287 break;
1288 }
1289 }
1290 }
1291
1292 for( EDA_ITEM* item : selection )
1293 {
1294 if( !item->IsBOARD_ITEM() )
1295 continue;
1296
1297 BOARD_ITEM* const board_item = static_cast<BOARD_ITEM*>( item );
1298
1299 // Disallow locking free pads - it's confusing and not persisted
1300 // through save/load anyway.
1301 if( board_item->Type() == PCB_PAD_T )
1302 continue;
1303
1304 PCB_GROUP* parent_group = board_item->GetParentGroup();
1305
1306 if( parent_group && parent_group->Type() == PCB_GENERATOR_T )
1307 {
1308 PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( parent_group );
1309
1310 if( generator && commit.GetStatus( generator ) != CHT_MODIFY )
1311 {
1312 commit.Modify( generator );
1313
1314 if( aMode == ON )
1315 generator->SetLocked( true );
1316 else
1317 generator->SetLocked( false );
1318 }
1319 }
1320
1321 commit.Modify( board_item );
1322
1323 if( aMode == ON )
1324 board_item->SetLocked( true );
1325 else
1326 board_item->SetLocked( false );
1327 }
1328
1329 if( !commit.Empty() )
1330 {
1331 commit.Push( aMode == ON ? _( "Lock" ) : _( "Unlock" ) );
1332
1334 m_frame->OnModify();
1335 }
1336
1337 return 0;
1338}
1339
1340
1341static bool mergeZones( EDA_DRAW_FRAME* aFrame, BOARD_COMMIT& aCommit,
1342 std::vector<ZONE*>& aOriginZones, std::vector<ZONE*>& aMergedZones )
1343{
1344 aCommit.Modify( aOriginZones[0] );
1345
1346 for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1347 {
1348 aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline() );
1349 }
1350
1351 aOriginZones[0]->Outline()->Simplify();
1352
1353 // We should have one polygon, possibly with holes. If we end up with two polygons (either
1354 // because the intersection was a single point or because the intersection was within one of
1355 // the zone's holes) then we can't merge.
1356 if( aOriginZones[0]->Outline()->IsSelfIntersecting()
1357 || aOriginZones[0]->Outline()->OutlineCount() > 1 )
1358 {
1359 DisplayErrorMessage( aFrame, _( "Zones have insufficient overlap for merging." ) );
1360 aCommit.Revert();
1361 return false;
1362 }
1363
1364 for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1365 aCommit.Remove( aOriginZones[i] );
1366
1367 aMergedZones.push_back( aOriginZones[0] );
1368
1369 aOriginZones[0]->SetLocalFlags( 1 );
1370 aOriginZones[0]->HatchBorder();
1371 aOriginZones[0]->CacheTriangulation();
1372
1373 return true;
1374}
1375
1376
1378{
1379 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1380 BOARD* board = getModel<BOARD>();
1381 BOARD_COMMIT commit( m_frame );
1382
1383 if( selection.Size() < 2 )
1384 return 0;
1385
1386 int netcode = -1;
1387
1388 ZONE* firstZone = nullptr;
1389 std::vector<ZONE*> toMerge, merged;
1390
1391 for( EDA_ITEM* item : selection )
1392 {
1393 ZONE* curr_area = dynamic_cast<ZONE*>( item );
1394
1395 if( !curr_area )
1396 continue;
1397
1398 if( !firstZone )
1399 firstZone = curr_area;
1400
1401 netcode = curr_area->GetNetCode();
1402
1403 if( firstZone->GetNetCode() != netcode )
1404 {
1405 wxLogMessage( _( "Some zone netcodes did not match and were not merged." ) );
1406 continue;
1407 }
1408
1409 if( curr_area->GetAssignedPriority() != firstZone->GetAssignedPriority() )
1410 {
1411 wxLogMessage( _( "Some zone priorities did not match and were not merged." ) );
1412 continue;
1413 }
1414
1415 if( curr_area->GetIsRuleArea() != firstZone->GetIsRuleArea() )
1416 {
1417 wxLogMessage( _( "Some zones were rule areas and were not merged." ) );
1418 continue;
1419 }
1420
1421 if( curr_area->GetLayerSet() != firstZone->GetLayerSet() )
1422 {
1423 wxLogMessage( _( "Some zone layer sets did not match and were not merged." ) );
1424 continue;
1425 }
1426
1427 bool intersects = curr_area == firstZone;
1428
1429 for( ZONE* candidate : toMerge )
1430 {
1431 if( intersects )
1432 break;
1433
1434 if( board->TestZoneIntersection( curr_area, candidate ) )
1435 intersects = true;
1436 }
1437
1438 if( !intersects )
1439 {
1440 wxLogMessage( _( "Some zones did not intersect and were not merged." ) );
1441 continue;
1442 }
1443
1444 toMerge.push_back( curr_area );
1445 }
1446
1448
1449 if( !toMerge.empty() )
1450 {
1451 if( mergeZones( m_frame, commit, toMerge, merged ) )
1452 {
1453 commit.Push( _( "Merge Zones" ) );
1454
1455 for( EDA_ITEM* item : merged )
1457 }
1458 }
1459
1460 return 0;
1461}
1462
1463
1465{
1467 const PCB_SELECTION& selection = selTool->GetSelection();
1468
1469 // because this pops up the zone editor, it would be confusing to handle multiple zones,
1470 // so just handle single selections containing exactly one zone
1471 if( selection.Size() != 1 )
1472 return 0;
1473
1474 ZONE* oldZone = dynamic_cast<ZONE*>( selection[0] );
1475
1476 if( !oldZone )
1477 return 0;
1478
1479 ZONE_SETTINGS zoneSettings;
1480 zoneSettings << *oldZone;
1481 int dialogResult;
1482
1483 if( oldZone->GetIsRuleArea() )
1484 dialogResult = InvokeRuleAreaEditor( m_frame, &zoneSettings, board() );
1485 else if( oldZone->IsOnCopperLayer() )
1486 dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
1487 else
1488 dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1489
1490 if( dialogResult != wxID_OK )
1491 return 0;
1492
1493 // duplicate the zone
1494 BOARD_COMMIT commit( m_frame );
1495
1496 std::unique_ptr<ZONE> newZone = std::make_unique<ZONE>( *oldZone );
1497 newZone->ClearSelected();
1498 newZone->UnFill();
1499 zoneSettings.ExportSetting( *newZone );
1500
1501 // If the new zone is on the same layer(s) as the initial zone,
1502 // offset it a bit so it can more easily be picked.
1503 if( oldZone->GetLayerSet() == zoneSettings.m_Layers )
1504 newZone->Move( VECTOR2I( pcbIUScale.IU_PER_MM, pcbIUScale.IU_PER_MM ) );
1505
1506 commit.Add( newZone.release() );
1507 commit.Push( _( "Duplicate Zone" ) );
1508
1509 return 0;
1510}
1511
1512
1514{
1515 doCrossProbePcbToSch( aEvent, false );
1516 return 0;
1517}
1518
1519
1521{
1522 doCrossProbePcbToSch( aEvent, true );
1523 return 0;
1524}
1525
1526
1528{
1529 // Don't get in an infinite loop PCB -> SCH -> PCB -> SCH -> ...
1531 return;
1532
1534 const PCB_SELECTION& selection = selTool->GetSelection();
1535 EDA_ITEM* focusItem = nullptr;
1536
1537 if( aEvent.Matches( EVENTS::PointSelectedEvent ) )
1538 focusItem = selection.GetLastAddedItem();
1539
1540 m_frame->SendSelectItemsToSch( selection.GetItems(), focusItem, aForce );
1541
1542 // Update 3D viewer highlighting
1543 m_frame->Update3DView( false, frame()->GetPcbNewSettings()->m_Display.m_Live3DRefresh );
1544}
1545
1546
1548{
1550
1551 const PCB_SELECTION& selection = selectionTool->RequestSelection(
1552 []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1553 {
1554 // Iterate from the back so we don't have to worry about removals.
1555 for( int i = aCollector.GetCount() - 1; i >= 0; --i )
1556 {
1557 if( !dynamic_cast<BOARD_CONNECTED_ITEM*>( aCollector[ i ] ) )
1558 aCollector.Remove( aCollector[ i ] );
1559 }
1560 },
1561 true /* prompt user regarding locked items */ );
1562
1563 int netCode = -1;
1564 wxString netName;
1565
1566 for( EDA_ITEM* item : selection )
1567 {
1568 NETINFO_ITEM* net = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNet();
1569
1570 if( !net->HasAutoGeneratedNetname() )
1571 {
1572 netCode = net->GetNetCode();
1573 netName = net->GetNetname();
1574 break;
1575 }
1576 }
1577
1578 if( netName.IsEmpty() )
1579 {
1580 m_frame->ShowInfoBarError( _( "Selection contains no items with labeled nets." ) );
1581 return 0;
1582 }
1583
1584 selectionTool->ClearSelection();
1586 canvas()->ForceRefresh();
1587
1588 DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, board()->GetNetClassAssignmentCandidates(),
1589 [this]( const std::vector<wxString>& aNetNames )
1590 {
1592 selTool->ClearSelection();
1593
1594 for( const wxString& curr_netName : aNetNames )
1595 {
1596 int curr_netCode = board()->GetNetInfo().GetNetItem( curr_netName )->GetNetCode();
1597
1598 if( curr_netCode > 0 )
1599 selTool->SelectAllItemsOnNet( curr_netCode );
1600 }
1601
1602 canvas()->ForceRefresh();
1604 } );
1605
1606 if( dlg.ShowModal() == wxID_OK )
1607 {
1609 // Refresh UI that depends on netclasses, such as the properties panel
1611 }
1612
1613 return 0;
1614}
1615
1616
1618{
1621
1622 if( selection.Empty() )
1623 {
1624 // Giant hack: by default we assign Edit Table to the same hotkey, so give the table
1625 // tool a chance to handle it if we can't.
1627 tableTool->EditTable( aEvent );
1628
1629 return 0;
1630 }
1631
1633
1634 if( !fp )
1635 return 0;
1636
1637 PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1638
1639 if( KIWAY_PLAYER* frame = editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ) )
1640 {
1641 FOOTPRINT_EDIT_FRAME* fp_editor = static_cast<FOOTPRINT_EDIT_FRAME*>( frame );
1642
1644 fp_editor->LoadFootprintFromBoard( fp );
1645 else if( aEvent.IsAction( &PCB_ACTIONS::editLibFpInFpEditor ) )
1646 fp_editor->LoadFootprintFromLibrary( fp->GetFPID() );
1647
1648 fp_editor->Show( true );
1649 fp_editor->Raise(); // Iconize( false );
1650 }
1651
1652 if( selection.IsHover() )
1654
1655 return 0;
1656}
1657
1658
1660 EDA_ITEM* originViewItem, const VECTOR2D& aPosition )
1661{
1662 aFrame->GetDesignSettings().SetAuxOrigin( VECTOR2I( aPosition ) );
1663 originViewItem->SetPosition( aPosition );
1664 aView->MarkDirty();
1665 aFrame->OnModify();
1666}
1667
1668
1670{
1672 {
1673 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::GRIDORIGIN );
1675 return 0;
1676 }
1677
1678 if( aEvent.IsAction( &PCB_ACTIONS::drillSetOrigin ) )
1679 {
1680 VECTOR2I origin = aEvent.Parameter<VECTOR2I>();
1681 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::GRIDORIGIN );
1682 DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), origin );
1683 return 0;
1684 }
1685
1687
1688 // Deactivate other tools; particularly important if another PICKER is currently running
1689 Activate();
1690
1691 picker->SetClickHandler(
1692 [this] ( const VECTOR2D& pt ) -> bool
1693 {
1694 m_frame->SaveCopyInUndoList( m_placeOrigin.get(), UNDO_REDO::DRILLORIGIN );
1696 return false; // drill origin is a one-shot; don't continue with tool
1697 } );
1698
1700
1701 return 0;
1702}
1703
1704
1706{
1715
1720
1725
1726 if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist && m_frame
1728 {
1730 }
1731
1740
1741 // Track & via size control
1747
1748 // Zone actions
1751
1752 // Placing tools
1757
1760
1761 // Cross-select
1767
1768 // Other
1772
1774
1785}
1786
1787
1788const int BOARD_EDITOR_CONTROL::WIDTH_STEP = 100000;
const char * name
Definition: DXF_plotter.cpp:59
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
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:218
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION pickerTool
Definition: actions.h:208
static TOOL_ACTION findPrevious
Definition: actions.h:112
static TOOL_ACTION plot
Definition: actions.h:58
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION findNext
Definition: actions.h:111
static TOOL_ACTION pageSettings
Definition: actions.h:56
static TOOL_ACTION showSearch
Definition: actions.h:108
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION redo
Definition: actions.h:69
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:219
static TOOL_ACTION showProperties
Definition: actions.h:220
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION saveCopy
Definition: actions.h:53
static TOOL_ACTION refreshPreview
Definition: actions.h:149
static TOOL_ACTION find
Definition: actions.h:109
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)
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 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 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 GenerateFabFiles(const TOOL_EVENT &aEvent)
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)
static const int WIDTH_STEP
How does line width change after one -/+ key press.
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 ViaSizeInc(const TOOL_EVENT &aEvent)
int New(const TOOL_EVENT &aEvent)
int Find(const TOOL_EVENT &aEvent)
void doCrossProbePcbToSch(const TOOL_EVENT &aEvent, bool aForce)
int Plot(const TOOL_EVENT &aEvent)
int TrackWidthDec(const TOOL_EVENT &aEvent)
int Revert(const TOOL_EVENT &aEvent)
int Search(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 ToggleProperties(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:78
virtual void SetLocked(bool aLocked)
Definition: board_item.h:326
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:94
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:297
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:897
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition: board.cpp:2584
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:1060
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
Definition: board.cpp:1413
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:2011
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:2144
const wxString & GetFileName() const
Definition: board.h:334
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:82
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:110
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition: commit.h:92
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Modify a given item in the model.
Definition: commit.h:108
bool Empty() const
Definition: commit.h:150
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Definition: commit.h:80
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
Definition: commit.cpp:130
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:88
void SetFields(nlohmann::ordered_map< wxString, wxString > &aFields)
Definition: pcb_netlist.h:135
void AddNet(const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction, const wxString &aPinType)
Definition: pcb_netlist.h:107
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)
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 base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:95
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:249
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:131
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:107
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:110
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
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:3132
static const TOOL_EVENT ClearedEvent
Definition: actions.h:298
static const TOOL_EVENT SelectedEvent
Definition: actions.h:296
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:303
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:295
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:297
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:2456
void SetLink(const KIID &aLink)
Definition: footprint.h:845
ZONES & Zones()
Definition: footprint.h:217
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2538
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:655
std::deque< PAD * > & Pads()
Definition: footprint.h:211
bool IsFlipped() const
Definition: footprint.h:396
const LIB_ID & GetFPID() const
Definition: footprint.h:253
PCB_FIELD & Reference()
Definition: footprint.h:656
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: footprint.cpp:2397
GROUPS & Groups()
Definition: footprint.h:220
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly) const
Populate a std::vector with PCB_TEXTs.
Definition: footprint.cpp:627
const wxString & GetValue() const
Definition: footprint.h:641
const wxString & GetReference() const
Definition: footprint.h:619
const KIID_PATH & GetPath() const
Definition: footprint.h:268
VECTOR2I GetPosition() const override
Definition: footprint.h:229
DRAWINGS & GraphicalItems()
Definition: footprint.h:214
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:202
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:67
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:297
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:332
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:1673
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:655
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:1559
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:406
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:527
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:255
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition: padstack.h:144
Definition: pad.h:54
DISPLAY_OPTIONS m_Display
FLIP_DIRECTION m_FlipDirection
static TOOL_ACTION zonesManager
Definition: pcb_actions.h:461
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:451
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:412
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:458
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:400
static TOOL_ACTION generateDrillFiles
Definition: pcb_actions.h:445
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:66
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:450
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:406
static TOOL_ACTION exportSpecctraDSN
Definition: pcb_actions.h:442
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:399
static TOOL_ACTION autoTrackWidth
Definition: pcb_actions.h:404
static TOOL_ACTION generateIPC2581File
Definition: pcb_actions.h:448
static TOOL_ACTION getAndPlace
Find an item and start moving.
Definition: pcb_actions.h:595
static TOOL_ACTION generateODBPPFile
Definition: pcb_actions.h:449
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:225
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:402
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:411
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:181
static TOOL_ACTION editFpInFpEditor
Definition: pcb_actions.h:455
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:69
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:547
static TOOL_ACTION drillResetOrigin
Definition: pcb_actions.h:563
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:401
static TOOL_ACTION zoneUnfill
Definition: pcb_actions.h:414
static TOOL_ACTION generatePosFile
Definition: pcb_actions.h:446
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:562
static TOOL_ACTION assignNetClass
Definition: pcb_actions.h:408
static TOOL_ACTION repairBoard
Definition: pcb_actions.h:569
static TOOL_ACTION showNetInspector
Definition: pcb_actions.h:459
static TOOL_ACTION generateGerbers
Definition: pcb_actions.h:444
static TOOL_ACTION generateReportFile
Definition: pcb_actions.h:447
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:419
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:439
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:226
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:425
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:566
static TOOL_ACTION showDesignBlockPanel
Definition: pcb_actions.h:465
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:415
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: pcb_actions.h:72
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
Definition: pcb_actions.h:97
static TOOL_ACTION editLibFpInFpEditor
Definition: pcb_actions.h:456
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:416
static TOOL_ACTION drillSetOrigin
Definition: pcb_actions.h:564
static TOOL_ACTION unlock
Definition: pcb_actions.h:549
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:229
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:460
static TOOL_ACTION importSpecctraSession
Definition: pcb_actions.h:441
static TOOL_ACTION selectOnSchematic
Select symbols/pins on schematic corresponding to selected footprints/pads.
Definition: pcb_actions.h:115
static TOOL_ACTION lock
Definition: pcb_actions.h:548
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:683
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
Definition: undo_redo.cpp:699
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Used in undo or redo command.
Definition: undo_redo.cpp:259
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
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 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.
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 GenIPC2581File(wxCommandEvent &event)
Create and IPC2581 output file.
void OnModify() override
Must be called after a board change to set the modified flag.
void RecreateBOMFileFromBoard(wxCommandEvent &aEvent)
Create a BOM file from the current loaded board.
void GenD356File(wxCommandEvent &event)
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
bool Files_io_from_id(int aId)
Read and write board files according to aId.
void GenODBPPFiles(wxCommandEvent &event)
Create and Generate ODB++ output files.
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...
void GenFootprintsReport(wxCommandEvent &event)
Call DoGenFootprintsReport to create a footprint report file.
void ToPlotter(int aID)
Open a dialog frame to create plot and drill files relative to the current board.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:52
void SetLocked(bool aLocked) override
Definition: pcb_group.cpp:184
Generic tool for picking an item.
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:687
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:73
ROUTER_MODE Mode() const
Definition: pns_router.h:143
RouterState GetState() const
Definition: pns_router.h:145
ROUTER * Router() const
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:140
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:188
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:121
EDA_ITEM * GetLastAddedItem() const
Definition: selection.h:126
bool IsHover() const
Definition: selection.h:84
int Size() const
Returns the number of selected parts.
Definition: selection.h:116
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.cpp:178
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:110
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:87
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:752
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:521
unsigned GetAssignedPriority() const
Definition: zone.h:126
@ CHT_MODIFY
Definition: commit.h:44
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:221
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:401
#define IS_NEW
New item, just created.
@ FRAME_SCH
Definition: frame_type.h:34
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:43
static const std::string SpecctraDsnFileExtension
static const std::string SpecctraSessionFileExtension
static wxString SpecctraSessionFileWildcard()
static wxString SpecctraDsnFileWildcard()
@ ID_NEW_BOARD
Definition: id.h:73
@ ID_SAVE_BOARD
Definition: id.h:74
@ ID_LOAD_FILE
Definition: id.h:72
@ ID_GEN_PLOT_GERBER
Definition: id.h:91
@ ID_GEN_PLOT
Definition: id.h:88
@ ID_SAVE_BOARD_AS
Definition: id.h:75
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
@ ID_REVERT_BOARD
Definition: pcbnew_id.h:18
@ ID_COPY_BOARD_AS
Definition: pcbnew_id.h:17
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1071
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.