KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_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-2016 CERN
5 * Copyright (C) 2019-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <kiplatform/ui.h>
27#include <tools/edit_tool.h>
29#include <router/router_tool.h>
30#include <pgm_base.h>
31#include <tools/pcb_actions.h>
32#include <tools/pcb_control.h>
37#include <board_commit.h>
38#include <board.h>
40#include <board_item.h>
41#include <clipboard.h>
43#include <pcb_dimension.h>
45#include <footprint.h>
46#include <layer_pairs.h>
47#include <pcb_group.h>
49#include <pcb_reference_image.h>
50#include <pcb_textbox.h>
51#include <pcb_track.h>
52#include <pcb_generator.h>
54#include <zone.h>
55#include <confirm.h>
56#include <kidialog.h>
58#include <core/kicad_algo.h>
60#include <kicad_clipboard.h>
61#include <origin_viewitem.h>
62#include <pcb_edit_frame.h>
63#include <pcb_painter.h>
65#include <string>
66#include <tool/tool_manager.h>
71#include <widgets/wx_infobar.h>
72#include <wx/hyperlink.h>
73
74
75using namespace std::placeholders;
76
77
78// files.cpp
79extern bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, int aCtl = 0 );
80
81
83 PCB_TOOL_BASE( "pcbnew.Control" ),
84 m_frame( nullptr ),
85 m_pickerItem( nullptr )
86{
88}
89
90
92{
93}
94
95
97{
98 m_frame = getEditFrame<PCB_BASE_FRAME>();
99
100 if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW )
101 {
102 m_gridOrigin->SetPosition( board()->GetDesignSettings().GetGridOrigin() );
103 m_gridOrigin->SetColor( m_frame->GetGridColor() );
104 getView()->Remove( m_gridOrigin.get() );
105 getView()->Add( m_gridOrigin.get() );
106 }
107}
108
109
111{
113 {
114 if( aEvent.IsAction( &ACTIONS::newLibrary ) )
115 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
116 else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
117 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
118 }
119
120 return 0;
121}
122
123
125{
126 const wxString fn = *aEvent.Parameter<wxString*>();
127 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary( fn );
128 return 0;
129}
130
131
133{
134 const wxString fn = *aEvent.Parameter<wxString*>();
135 static_cast<FOOTPRINT_EDIT_FRAME*>( m_frame )->ImportFootprint( fn );
136 m_frame->Zoom_Automatique( false );
137 return 0;
138}
139
140
141int PCB_CONTROL::Quit( const TOOL_EVENT& aEvent )
142{
143 m_frame->Close( false );
144 return 0;
145}
146
147
148template<class T> void Flip( T& aValue )
149{
150 aValue = !aValue;
151}
152
153
155{
156 Flip( displayOptions().m_DisplayPcbTrackFill );
157
158 for( PCB_TRACK* track : board()->Tracks() )
159 {
160 if( track->Type() == PCB_TRACE_T || track->Type() == PCB_ARC_T )
161 view()->Update( track, KIGFX::REPAINT );
162 }
163
164 for( BOARD_ITEM* shape : board()->Drawings() )
165 {
166 if( shape->Type() == PCB_SHAPE_T && static_cast<PCB_SHAPE*>( shape )->IsOnCopperLayer() )
167 view()->Update( shape, KIGFX::REPAINT );
168 }
169
170 canvas()->Refresh();
171
172 return 0;
173}
174
175
177{
178 if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
179 {
180 // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
181 Flip( displayOptions().m_ShowGlobalRatsnest );
182 getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
183 displayOptions().m_ShowGlobalRatsnest );
184
185 }
186 else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
187 {
188 Flip( displayOptions().m_DisplayRatsnestLinesCurved );
189 }
190
191 frame()->OnDisplayOptionsChanged();
192
194 canvas()->Refresh();
195
196 return 0;
197}
198
199
201{
202 Flip( displayOptions().m_DisplayViaFill );
203
204 for( PCB_TRACK* track : board()->Tracks() )
205 {
206 if( track->Type() == PCB_VIA_T )
207 view()->Update( track, KIGFX::REPAINT );
208 }
209
210 canvas()->Refresh();
211 return 0;
212}
213
214
221{
222 if( Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning )
223 return;
224
225 bool unfilledZones = false;
226
227 for( const ZONE* zone : board()->Zones() )
228 {
229 if( !zone->GetIsRuleArea() && !zone->IsFilled() )
230 {
231 unfilledZones = true;
232 break;
233 }
234 }
235
236 if( unfilledZones )
237 {
238 WX_INFOBAR* infobar = frame()->GetInfoBar();
239 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Don't show again" ),
240 wxEmptyString );
241
242 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
243 [&]( wxHyperlinkEvent& aEvent )
244 {
246 frame()->GetInfoBar()->Dismiss();
247 } ) );
248
249 infobar->RemoveAllButtons();
250 infobar->AddButton( button );
251
252 wxString msg;
253 msg.Printf( _( "Not all zones are filled. Use Edit > Fill All Zones (%s) "
254 "if you wish to see all fills." ),
256
257 infobar->ShowMessageFor( msg, 5000, wxICON_WARNING );
258 }
259}
260
261
263{
264 PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
265
266 // Apply new display options to the GAL canvas
268 {
270
271 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
272 }
273 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutline ) )
274 {
275 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE;
276 }
277 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayFractured ) )
278 {
279 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS;
280 }
282 {
283 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_TRIANGULATION;
284 }
285 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
286 {
287 if( opts.m_ZoneDisplayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
288 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE;
289 else
290 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
291 }
292 else
293 {
294 wxFAIL;
295 }
296
297 m_frame->SetDisplayOptions( opts );
298
299 for( ZONE* zone : board()->Zones() )
300 view()->Update( zone, KIGFX::REPAINT );
301
302 canvas()->Refresh();
303
304 return 0;
305}
306
307
309{
310 PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
311
312 opts.m_ContrastModeDisplay = opts.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::NORMAL
313 ? HIGH_CONTRAST_MODE::DIMMED
314 : HIGH_CONTRAST_MODE::NORMAL;
315
316 m_frame->SetDisplayOptions( opts );
317 return 0;
318}
319
320
322{
323 PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
324
325 switch( opts.m_ContrastModeDisplay )
326 {
327 case HIGH_CONTRAST_MODE::NORMAL: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::DIMMED; break;
328 case HIGH_CONTRAST_MODE::DIMMED: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::HIDDEN; break;
329 case HIGH_CONTRAST_MODE::HIDDEN: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL; break;
330 }
331
332 m_frame->SetDisplayOptions( opts );
333
335 return 0;
336}
337
338
340{
341 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
342 return 0;
343
344 PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
345
346 wxArrayString labels;
347 labels.Add( _( "Normal" ) );
348 labels.Add( _( "Dimmed" ) );
349 labels.Add( _( "Hidden" ) );
350
351 if( !m_frame->GetHotkeyPopup() )
353
355
356 if( popup )
357 {
358 popup->Popup( _( "Inactive Layer Display" ), labels,
359 static_cast<int>( opts.m_ContrastModeDisplay ) );
360 }
361
362 return 0;
363}
364
365
367{
368 PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
369
370 switch( opts.m_NetColorMode )
371 {
372 case NET_COLOR_MODE::ALL: opts.m_NetColorMode = NET_COLOR_MODE::RATSNEST; break;
373 case NET_COLOR_MODE::RATSNEST: opts.m_NetColorMode = NET_COLOR_MODE::OFF; break;
374 case NET_COLOR_MODE::OFF: opts.m_NetColorMode = NET_COLOR_MODE::ALL; break;
375 }
376
377 m_frame->SetDisplayOptions( opts );
378 return 0;
379}
380
381
383{
384 if( !displayOptions().m_ShowGlobalRatsnest )
385 {
387 displayOptions().m_RatsnestMode = RATSNEST_MODE::ALL;
388 }
389 else if( displayOptions().m_RatsnestMode == RATSNEST_MODE::ALL )
390 {
391 displayOptions().m_RatsnestMode = RATSNEST_MODE::VISIBLE;
392 }
393 else
394 {
396 }
397
398 getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
399 displayOptions().m_ShowGlobalRatsnest );
400
401 frame()->OnDisplayOptionsChanged();
402
404 canvas()->Refresh();
405 return 0;
406}
407
408
410{
412
413 return 0;
414}
415
416
418{
419 PCB_BASE_FRAME* editFrame = m_frame;
420 BOARD* brd = board();
421 PCB_LAYER_ID layer = editFrame->GetActiveLayer();
422 bool wraparound = false;
423
424 if( !IsCopperLayer( layer ) )
425 {
426 editFrame->SwitchLayer( B_Cu );
427 return 0;
428 }
429
430 LSET cuMask = LSET::AllCuMask( brd->GetCopperLayerCount() );
431 LSEQ layerStack = cuMask.UIOrder();
432
433 int ii = 0;
434
435 // Find the active layer in list
436 for( ; ii < (int)layerStack.size(); ii++ )
437 {
438 if( layer == layerStack[ii] )
439 break;
440 }
441
442 // Find the next visible layer in list
443 for( ; ii < (int)layerStack.size(); ii++ )
444 {
445 int jj = ii+1;
446
447 if( jj >= (int)layerStack.size() )
448 jj = 0;
449
450 layer = layerStack[jj];
451
452 if( brd->IsLayerVisible( layer ) )
453 break;
454
455 if( jj == 0 ) // the end of list is reached. Try from the beginning
456 {
457 if( wraparound )
458 {
459 wxBell();
460 return 0;
461 }
462 else
463 {
464 wraparound = true;
465 ii = -1;
466 }
467 }
468 }
469
470 wxCHECK( IsCopperLayer( layer ), 0 );
471 editFrame->SwitchLayer( layer );
472
473 return 0;
474}
475
476
478{
479 PCB_BASE_FRAME* editFrame = m_frame;
480 BOARD* brd = board();
481 PCB_LAYER_ID layer = editFrame->GetActiveLayer();
482 bool wraparound = false;
483
484 if( !IsCopperLayer( layer ) )
485 {
486 editFrame->SwitchLayer( F_Cu );
487 return 0;
488 }
489
490 LSET cuMask = LSET::AllCuMask( brd->GetCopperLayerCount() );
491 LSEQ layerStack = cuMask.UIOrder();
492
493 int ii = 0;
494
495 // Find the active layer in list
496 for( ; ii < (int)layerStack.size(); ii++ )
497 {
498 if( layer == layerStack[ii] )
499 break;
500 }
501
502 // Find the previous visible layer in list
503 for( ; ii >= 0; ii-- )
504 {
505 int jj = ii - 1;
506
507 if( jj < 0 )
508 jj = (int)layerStack.size() - 1;
509
510 layer = layerStack[jj];
511
512 if( brd->IsLayerVisible( layer ) )
513 break;
514
515 if( ii == 0 ) // the start of list is reached. Try from the last
516 {
517 if( wraparound )
518 {
519 wxBell();
520 return 0;
521 }
522 else
523 {
524 wraparound = true;
525 ii = 1;
526 }
527 }
528 }
529
530 wxCHECK( IsCopperLayer( layer ), 0 );
531 editFrame->SwitchLayer( layer );
532
533 return 0;
534}
535
536
538{
539 int currentLayer = m_frame->GetActiveLayer();
540 PCB_SCREEN* screen = m_frame->GetScreen();
541
542 if( currentLayer == screen->m_Route_Layer_TOP )
544 else
546
547 return 0;
548}
549
550
551// It'd be nice to share the min/max with the DIALOG_COLOR_PICKER, but those are
552// set in wxFormBuilder.
553#define ALPHA_MIN 0.20
554#define ALPHA_MAX 1.00
555#define ALPHA_STEP 0.05
556
557
559{
561 int currentLayer = m_frame->GetActiveLayer();
562 KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
563
564 if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
565 {
566 currentColor.a += ALPHA_STEP;
567 settings->SetColor( currentLayer, currentColor );
569
571 view->UpdateLayerColor( currentLayer );
572 view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
573
574 if( IsCopperLayer( currentLayer ) )
575 view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
576 }
577 else
578 {
579 wxBell();
580 }
581
582 return 0;
583}
584
585
587{
589 int currentLayer = m_frame->GetActiveLayer();
590 KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
591
592 if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
593 {
594 currentColor.a -= ALPHA_STEP;
595 settings->SetColor( currentLayer, currentColor );
597
599 view->UpdateLayerColor( currentLayer );
600 view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
601
602 if( IsCopperLayer( currentLayer ) )
603 view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
604 }
605 else
606 {
607 wxBell();
608 }
609
610 return 0;
611}
612
613
615{
616 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
617
618 if( !editFrame )
619 return 0;
620
621 LAYER_PAIR_SETTINGS* settings = editFrame->GetLayerPairSettings();
622
623 if( !settings )
624 return 0;
625
626 int currentIndex;
627 std::vector<LAYER_PAIR_INFO> presets = settings->GetEnabledLayerPairs( currentIndex );
628
629 if( presets.size() < 2 )
630 return 0;
631
632 if( currentIndex < 0 )
633 {
634 wxASSERT_MSG( false, "Current layer pair not found in layer settings" );
635 currentIndex = 0;
636 }
637
638 const int nextIndex = ( currentIndex + 1 ) % presets.size();
639 const LAYER_PAIR& nextPair = presets[nextIndex].GetLayerPair();
640
641 settings->SetCurrentLayerPair( nextPair );
642
644 return 0;
645}
646
647
649{
650 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
651 return 0;
652
653 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
654
655 if( !editFrame )
656 return 0;
657
658 LAYER_PAIR_SETTINGS* settings = editFrame->GetLayerPairSettings();
659
660 if( !settings )
661 return 0;
662
663 PCB_LAYER_PRESENTATION layerPresentation( editFrame );
664
665 int currentIndex;
666 std::vector<LAYER_PAIR_INFO> presets = settings->GetEnabledLayerPairs( currentIndex );
667
668 wxArrayString labels;
669 for( const LAYER_PAIR_INFO& layerPairInfo : presets )
670 {
671 wxString label = layerPresentation.getLayerPairName( layerPairInfo.GetLayerPair() );
672
673 if( layerPairInfo.GetName() )
674 {
675 label += wxT( " (" ) + *layerPairInfo.GetName() + wxT( ")" );
676 }
677
678 labels.Add( label );
679 }
680
681 if( !editFrame->GetHotkeyPopup() )
682 editFrame->CreateHotkeyPopup();
683
684 HOTKEY_CYCLE_POPUP* popup = editFrame->GetHotkeyPopup();
685
686 if( popup )
687 {
688 int selection = currentIndex;
689 popup->Popup( _( "Preset Layer Pairs" ), labels, selection );
690 }
691
692 return 0;
693}
694
695
697 EDA_ITEM* originViewItem, const VECTOR2D& aPoint )
698{
699 aFrame->GetDesignSettings().SetGridOrigin( VECTOR2I( aPoint ) );
700 aView->GetGAL()->SetGridOrigin( aPoint );
701 originViewItem->SetPosition( aPoint );
702 aView->MarkDirty();
703 aFrame->OnModify();
704}
705
706
708{
709 VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
710
711 if( origin )
712 {
713 // We can't undo the other grid dialog settings, so no sense undoing just the origin
714 DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
715 delete origin;
716 }
717 else
718 {
719 if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
720 return 0;
721
723
724 if( !picker ) // Happens in footprint wizard
725 return 0;
726
727 // Deactivate other tools; particularly important if another PICKER is currently running
728 Activate();
729
730 picker->SetClickHandler(
731 [this]( const VECTOR2D& pt ) -> bool
732 {
733 m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
735 return false; // drill origin is a one-shot; don't continue with tool
736 } );
737
739 }
740
741 return 0;
742}
743
744
746{
747 m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
749 return 0;
750}
751
752
753#define HITTEST_THRESHOLD_PIXELS 5
754
755
757{
759 return 0;
760
762
763 m_pickerItem = nullptr;
765
766 // Deactivate other tools; particularly important if another PICKER is currently running
767 Activate();
768
769 picker->SetCursor( KICURSOR::REMOVE );
770
771 picker->SetClickHandler(
772 [this]( const VECTOR2D& aPosition ) -> bool
773 {
774 if( m_pickerItem )
775 {
777 {
778 m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
779 m_statusPopup->SetText( _( "Item locked." ) );
780 m_statusPopup->PopupFor( 2000 );
781 m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition()
782 + wxPoint( 20, 20 ) );
783 return true;
784 }
785
787 selectionTool->UnbrightenItem( m_pickerItem );
788
789 PCB_SELECTION items;
790 items.Add( m_pickerItem );
791
792 EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
793 editTool->DeleteItems( items, false );
794
795 m_pickerItem = nullptr;
796 }
797
798 return true;
799 } );
800
801 picker->SetMotionHandler(
802 [this]( const VECTOR2D& aPos )
803 {
807 GENERAL_COLLECTOR collector;
808 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
809
811 collector.Collect( board, GENERAL_COLLECTOR::FootprintItems, aPos, guide );
812 else
813 collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, aPos, guide );
814
815 // Remove unselectable items
816 for( int i = collector.GetCount() - 1; i >= 0; --i )
817 {
818 if( !selectionTool->Selectable( collector[ i ] ) )
819 collector.Remove( i );
820 }
821
822 selectionTool->FilterCollectorForHierarchy( collector, false );
823 selectionTool->FilterCollectedItems( collector, false );
824
825 if( collector.GetCount() > 1 )
826 selectionTool->GuessSelectionCandidates( collector, aPos );
827
828 BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
829
830 if( m_pickerItem != item )
831 {
832 if( m_pickerItem )
833 selectionTool->UnbrightenItem( m_pickerItem );
834
835 m_pickerItem = item;
836
837 if( m_pickerItem )
838 selectionTool->BrightenItem( m_pickerItem );
839 }
840 } );
841
842 picker->SetFinalizeHandler(
843 [this]( const int& aFinalState )
844 {
845 if( m_pickerItem )
846 m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
847
848 m_statusPopup.reset();
849
850 // Ensure the cursor gets changed&updated
851 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
853 } );
854
856
857 return 0;
858}
859
860
861static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBoard,
862 std::vector<BOARD_ITEM*>& aPastedItems )
863{
864 FOOTPRINT* editorFootprint = aBoard->GetFirstFootprint();
865
866 aClipFootprint->SetParent( aBoard );
867
868 for( PAD* pad : aClipFootprint->Pads() )
869 {
870 pad->SetParent( editorFootprint );
871 aPastedItems.push_back( pad );
872 }
873
874 aClipFootprint->Pads().clear();
875
876 // Not all items can be added to the current footprint: mandatory fields are already existing
877 // in the current footprint.
878 //
879 for( PCB_FIELD* field : aClipFootprint->Fields() )
880 {
881 if( field->IsMandatoryField() )
882 {
883 if( PCB_GROUP* parentGroup = field->GetParentGroup() )
884 parentGroup->RemoveItem( field );
885 }
886 else
887 {
888 PCB_TEXT* text = static_cast<PCB_TEXT*>( field );
889
890 text->SetTextAngle( text->GetTextAngle() - aClipFootprint->GetOrientation() );
891 text->SetTextAngle( text->GetTextAngle() + editorFootprint->GetOrientation() );
892
893 VECTOR2I pos = field->GetFPRelativePosition();
894 field->SetParent( editorFootprint );
895 field->SetFPRelativePosition( pos );
896
897 aPastedItems.push_back( field );
898 }
899 }
900
901 aClipFootprint->Fields().clear();
902
903 for( BOARD_ITEM* item : aClipFootprint->GraphicalItems() )
904 {
905 if( item->Type() == PCB_TEXT_T )
906 {
907 PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
908
909 text->SetTextAngle( text->GetTextAngle() - aClipFootprint->GetOrientation() );
910 text->SetTextAngle( text->GetTextAngle() + editorFootprint->GetOrientation() );
911 }
912
913 item->Rotate( item->GetPosition(), -aClipFootprint->GetOrientation() );
914 item->Rotate( item->GetPosition(), editorFootprint->GetOrientation() );
915
916 VECTOR2I pos = item->GetFPRelativePosition();
917 item->SetParent( editorFootprint );
918 item->SetFPRelativePosition( pos );
919
920 aPastedItems.push_back( item );
921 }
922
923 aClipFootprint->GraphicalItems().clear();
924
925 for( ZONE* zone : aClipFootprint->Zones() )
926 {
927 zone->SetParent( editorFootprint );
928 aPastedItems.push_back( zone );
929 }
930
931 aClipFootprint->Zones().clear();
932
933 for( PCB_GROUP* group : aClipFootprint->Groups() )
934 {
935 group->SetParent( editorFootprint );
936 aPastedItems.push_back( group );
937 }
938
939 aClipFootprint->Groups().clear();
940}
941
942
943void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
944{
945 // Do not prune items or layers when copying to the FP editor, because all
946 // layers are accepted, even if they are not enabled in the dummy board
947 // This is mainly true for internal copper layers: all are allowed but only one
948 // (In1.cu) is enabled for the GUI.
950 return;
951
952 LSET enabledLayers = board()->GetEnabledLayers();
953 std::vector<BOARD_ITEM*> returnItems;
954 bool fpItemDeleted = false;
955
956 for( BOARD_ITEM* item : aItems )
957 {
958 if( item->Type() == PCB_FOOTPRINT_T )
959 {
960 FOOTPRINT* fp = static_cast<FOOTPRINT*>( item );
961
962 // Items living in a parent footprint are never removed, even if their
963 // layer does not exist in the board editor
964 // Otherwise the parent footprint could be seriously broken especially
965 // if some layers are later re-enabled.
966 // Moreover a fp lives in a fp library, that does not know the enabled
967 // layers of a given board, so fp items are just ignored when on not
968 // enabled layers in board editor
969 returnItems.push_back( fp );
970 }
971 else if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
972 {
973 returnItems.push_back( item );
974 }
975 else
976 {
977 LSET allowed = item->GetLayerSet() & enabledLayers;
978 bool item_valid = true;
979
980 // Ensure, for vias, the top and bottom layers are compatible with
981 // the current board copper layers.
982 // Otherwise they must be skipped, even is one layer is valid
983 if( item->Type() == PCB_VIA_T )
984 item_valid = static_cast<PCB_VIA*>( item )->HasValidLayerPair(
986
987 if( allowed.any() && item_valid )
988 {
989 item->SetLayerSet( allowed );
990 returnItems.push_back( item );
991 }
992 else
993 {
994 if( PCB_GROUP* parentGroup = item->GetParentGroup() )
995 parentGroup->RemoveItem( item );
996 }
997 }
998 }
999
1000 if( ( returnItems.size() < aItems.size() ) || fpItemDeleted )
1001 {
1002 DisplayError( m_frame, _( "Warning: some pasted items were on layers which are not "
1003 "present in the current board.\n"
1004 "These items could not be pasted.\n" ) );
1005 }
1006
1007 aItems = returnItems;
1008}
1009
1010
1011int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
1012{
1013 // The viewer frames cannot paste
1014 if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
1015 return 0;
1016
1017 bool isFootprintEditor = m_isFootprintEditor || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
1018 // The clipboard can contain two different things, an entire kicad_pcb or a single footprint
1019 if( isFootprintEditor && ( !board() || !footprint() ) )
1020 return 0;
1021
1022 // We should never get here if a modal dialog is up... but we do on MacOS.
1023 // https://gitlab.com/kicad/code/kicad/-/issues/18912
1024#ifdef __WXMAC__
1025 if( wxDialog::OSXHasModalDialogsOpen() )
1026 {
1027 wxBell();
1028 return 0;
1029 }
1030#endif
1031
1032 BOARD_COMMIT commit( frame() );
1033
1034 CLIPBOARD_IO pi;
1035 BOARD_ITEM* clipItem = pi.Parse();
1036
1037 if( !clipItem )
1038 {
1039 // When the clipboard doesn't parse, create a PCB item with the clipboard contents
1040 std::vector<BOARD_ITEM*> newItems;
1041
1042 if( std::unique_ptr<wxImage> clipImg = GetImageFromClipboard() )
1043 {
1044 auto refImg = std::make_unique<PCB_REFERENCE_IMAGE>( m_frame->GetModel() );
1045
1046 if( refImg->GetReferenceImage().SetImage( *clipImg ) )
1047 newItems.push_back( refImg.release() );
1048 }
1049 else
1050 {
1051 const wxString clipText = GetClipboardUTF8();
1052
1053 if( clipText.empty() )
1054 return 0;
1055
1056 std::unique_ptr<PCB_TEXT> item;
1057
1058 item = std::make_unique<PCB_TEXT>( m_frame->GetModel() );
1059 item->SetText( clipText );
1060
1061 newItems.push_back( item.release() );
1062 }
1063
1064 bool cancelled = !placeBoardItems( &commit, newItems, true, false, false );
1065
1066 if( cancelled )
1067 commit.Revert();
1068 else
1069 commit.Push( _( "Paste Text" ) );
1070 return 0;
1071 }
1072
1073 // If we get here, we have a parsed board/FP to paste
1074
1075 PASTE_MODE mode = PASTE_MODE::KEEP_ANNOTATIONS;
1076 bool clear_nets = false;
1077 const wxString defaultRef = wxT( "REF**" );
1078
1079 if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1080 {
1081 DIALOG_PASTE_SPECIAL dlg( m_frame, &mode, defaultRef );
1082
1083 if( clipItem->Type() != PCB_T )
1084 dlg.HideClearNets();
1085
1086 if( dlg.ShowModal() == wxID_CANCEL )
1087 return 0;
1088
1089 clear_nets = dlg.GetClearNets();
1090 }
1091
1092 if( clipItem->Type() == PCB_T )
1093 {
1094 BOARD* clipBoard = static_cast<BOARD*>( clipItem );
1095
1096 if( isFootprintEditor || clear_nets )
1097 {
1098 for( BOARD_CONNECTED_ITEM* item : clipBoard->AllConnectedItems() )
1099 item->SetNet( NETINFO_LIST::OrphanedItem() );
1100 }
1101 else
1102 {
1103 clipBoard->MapNets( m_frame->GetBoard() );
1104 }
1105 }
1106
1107 bool cancelled = false;
1108
1109 switch( clipItem->Type() )
1110 {
1111 case PCB_T:
1112 {
1113 BOARD* clipBoard = static_cast<BOARD*>( clipItem );
1114
1115 if( isFootprintEditor )
1116 {
1117 FOOTPRINT* editorFootprint = board()->GetFirstFootprint();
1118 std::vector<BOARD_ITEM*> pastedItems;
1119
1120 for( PCB_GROUP* group : clipBoard->Groups() )
1121 {
1122 group->SetParent( editorFootprint );
1123 pastedItems.push_back( group );
1124 }
1125
1126 clipBoard->RemoveAll( { PCB_GROUP_T } );
1127
1128 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
1129 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
1130
1131 for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
1132 {
1133 switch( clipDrawItem->Type() )
1134 {
1135 case PCB_TEXT_T:
1136 case PCB_TEXTBOX_T:
1137 case PCB_TABLE_T:
1138 case PCB_SHAPE_T:
1139 case PCB_DIM_ALIGNED_T:
1140 case PCB_DIM_CENTER_T:
1141 case PCB_DIM_LEADER_T:
1143 case PCB_DIM_RADIAL_T:
1144 clipDrawItem->SetParent( editorFootprint );
1145 pastedItems.push_back( clipDrawItem );
1146 break;
1147
1148 default:
1149 // Everything we *didn't* put into pastedItems is going to get nuked, so
1150 // make sure it's not still included in its parent group.
1151 if( PCB_GROUP* parentGroup = clipDrawItem->GetParentGroup() )
1152 parentGroup->RemoveItem( clipDrawItem );
1153
1154 break;
1155 }
1156 }
1157
1158 // NB: PCB_SHAPE_T actually removes everything in Drawings() (including PCB_TEXTs,
1159 // PCB_TABLES, dimensions, etc.), not just PCB_SHAPEs.)
1160 clipBoard->RemoveAll( { PCB_SHAPE_T } );
1161
1162 clipBoard->Visit(
1163 [&]( EDA_ITEM* item, void* testData )
1164 {
1165 // Anything still on the clipboard didn't get copied and needs to be
1166 // removed from the pasted groups.
1167 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
1168 PCB_GROUP* parentGroup = boardItem->GetParentGroup();
1169
1170 if( parentGroup )
1171 parentGroup->RemoveItem( boardItem );
1172
1173 return INSPECT_RESULT::CONTINUE;
1174 },
1176
1177 delete clipBoard;
1178
1179 pruneItemLayers( pastedItems );
1180
1181 cancelled = !placeBoardItems( &commit, pastedItems, true, true,
1182 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
1183 }
1184 else // isBoardEditor
1185 {
1186 if( mode == PASTE_MODE::REMOVE_ANNOTATIONS )
1187 {
1188 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
1189 clipFootprint->SetReference( defaultRef );
1190 }
1191
1192 cancelled = !placeBoardItems( &commit, clipBoard, true,
1193 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
1194 }
1195
1196 break;
1197 }
1198
1199 case PCB_FOOTPRINT_T:
1200 {
1201 FOOTPRINT* clipFootprint = static_cast<FOOTPRINT*>( clipItem );
1202 std::vector<BOARD_ITEM*> pastedItems;
1203
1204 if( isFootprintEditor )
1205 {
1206 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
1207 delete clipFootprint;
1208 }
1209 else
1210 {
1211 if( mode == PASTE_MODE::REMOVE_ANNOTATIONS )
1212 clipFootprint->SetReference( defaultRef );
1213
1214 clipFootprint->SetParent( board() );
1215 pastedItems.push_back( clipFootprint );
1216 }
1217
1218 pruneItemLayers( pastedItems );
1219
1220 cancelled = !placeBoardItems( &commit, pastedItems, true, true,
1221 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
1222 break;
1223 }
1224
1225 default:
1226 m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
1227 break;
1228 }
1229
1230 if( cancelled )
1231 commit.Revert();
1232 else
1233 commit.Push( _( "Paste" ) );
1234
1235 return 1;
1236}
1237
1238
1240{
1241 wxString fileName;
1242
1243 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1244
1245 if( !editFrame )
1246 return 1;
1247
1248 // Pick a file to append
1249 if( !AskLoadBoardFileName( editFrame, &fileName, KICTL_KICAD_ONLY ) )
1250 return 1;
1251
1252 PCB_IO_MGR::PCB_FILE_T pluginType =
1254 IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( pluginType ) );
1255
1256 if( !pi )
1257 return 1;
1258
1259 return AppendBoard( *pi, fileName );
1260}
1261
1262
1263template<typename T>
1264static void moveUnflaggedItems( const std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
1265 bool aIsNew )
1266{
1267 std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
1268 [aIsNew]( T aItem )
1269 {
1270 bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
1271
1272 aItem->ClearFlags( SKIP_STRUCT );
1273 aItem->SetFlags( aIsNew ? IS_NEW : 0 );
1274
1275 return doCopy;
1276 } );
1277}
1278
1279
1280template<typename T>
1281static void moveUnflaggedItems( const std::vector<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
1282 bool aIsNew )
1283{
1284 std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
1285 [aIsNew]( T aItem )
1286 {
1287 bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
1288
1289 aItem->ClearFlags( SKIP_STRUCT );
1290 aItem->SetFlags( aIsNew ? IS_NEW : 0 );
1291
1292 return doCopy;
1293 } );
1294}
1295
1296
1297bool PCB_CONTROL::placeBoardItems( BOARD_COMMIT* aCommit, BOARD* aBoard, bool aAnchorAtOrigin,
1298 bool aReannotateDuplicates )
1299{
1300 // items are new if the current board is not the board source
1301 bool isNew = board() != aBoard;
1302 std::vector<BOARD_ITEM*> items;
1303
1304 moveUnflaggedItems( aBoard->Tracks(), items, isNew );
1305 moveUnflaggedItems( aBoard->Footprints(), items, isNew );
1306 moveUnflaggedItems( aBoard->Drawings(), items, isNew );
1307 moveUnflaggedItems( aBoard->Zones(), items, isNew );
1308
1309 // Subtlety: When selecting a group via the mouse,
1310 // PCB_SELECTION_TOOL::highlightInternal runs, which does a SetSelected() on all
1311 // descendants. In PCB_CONTROL::placeBoardItems, below, we skip that and
1312 // mark items non-recursively. That works because the saving of the
1313 // selection created aBoard that has the group and all descendants in it.
1314 moveUnflaggedItems( aBoard->Groups(), items, isNew );
1315
1316 moveUnflaggedItems( aBoard->Generators(), items, isNew );
1317
1318 if( isNew )
1319 aBoard->RemoveAll();
1320
1321 // Reparent before calling pruneItemLayers, as SetLayer can have a dependence on the
1322 // item's parent board being set correctly.
1323 if( isNew )
1324 {
1325 for( BOARD_ITEM* item : items )
1326 item->SetParent( board() );
1327 }
1328
1329 pruneItemLayers( items );
1330
1331 return placeBoardItems( aCommit, items, isNew, aAnchorAtOrigin, aReannotateDuplicates );
1332}
1333
1334
1335bool PCB_CONTROL::placeBoardItems( BOARD_COMMIT* aCommit, std::vector<BOARD_ITEM*>& aItems,
1336 bool aIsNew, bool aAnchorAtOrigin, bool aReannotateDuplicates )
1337{
1339
1341
1342 std::vector<BOARD_ITEM*> itemsToSel;
1343 itemsToSel.reserve( aItems.size() );
1344
1345 for( BOARD_ITEM* item : aItems )
1346 {
1347 if( aIsNew )
1348 {
1349 const_cast<KIID&>( item->m_Uuid ) = KIID();
1350
1351 // Even though BOARD_COMMIT::Push() will add any new items to the group, we're
1352 // going to run PCB_ACTIONS::move first, and the move tool will throw out any
1353 // items that aren't in the entered group.
1354 if( selectionTool->GetEnteredGroup() && !item->GetParentGroup() )
1355 selectionTool->GetEnteredGroup()->AddItem( item );
1356
1357 item->SetParent( board() );
1358 }
1359
1360 // Update item attributes if needed
1361 if( BaseType( item->Type() ) == PCB_DIMENSION_T )
1362 {
1363 static_cast<PCB_DIMENSION_BASE*>( item )->UpdateUnits();
1364 }
1365 else if( item->Type() == PCB_FOOTPRINT_T )
1366 {
1367 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
1368
1369 // Update the footprint path with the new KIID path if the footprint is new
1370 if( aIsNew )
1372
1373 for( BOARD_ITEM* dwg : footprint->GraphicalItems() )
1374 {
1375 if( BaseType( dwg->Type() ) == PCB_DIMENSION_T )
1376 static_cast<PCB_DIMENSION_BASE*>( dwg )->UpdateUnits();
1377 }
1378 }
1379
1380 // We only need to add the items that aren't inside a group currently selected
1381 // to the selection. If an item is inside a group and that group is selected,
1382 // then the selection tool will select it for us.
1383 if( !item->GetParentGroup() || !alg::contains( aItems, item->GetParentGroup() ) )
1384 itemsToSel.push_back( item );
1385 }
1386
1387 // Select the items that should be selected
1388 EDA_ITEMS toSel( itemsToSel.begin(), itemsToSel.end() );
1390
1391 // Reannotate duplicate footprints (make sense only in board editor )
1392 if( aReannotateDuplicates && m_isBoardEditor )
1393 m_toolMgr->GetTool<BOARD_REANNOTATE_TOOL>()->ReannotateDuplicatesInSelection();
1394
1395 for( BOARD_ITEM* item : aItems )
1396 {
1397 if( aIsNew )
1398 aCommit->Add( item );
1399 else
1400 aCommit->Added( item );
1401 }
1402
1403 PCB_SELECTION& selection = selectionTool->GetSelection();
1404
1405 if( selection.Size() > 0 )
1406 {
1407 if( aAnchorAtOrigin )
1408 {
1410 }
1411 else
1412 {
1413 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
1415 }
1416
1417 getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
1418
1420
1422 }
1423
1424 return true;
1425}
1426
1427
1428int PCB_CONTROL::AppendBoard( PCB_IO& pi, wxString& fileName )
1429{
1430 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1431
1432 if( !editFrame )
1433 return 1;
1434
1435 BOARD* brd = board();
1436
1437 if( !brd )
1438 return 1;
1439
1440 BOARD_COMMIT commit( editFrame );
1441
1442 // Mark existing items, in order to know what are the new items so we can select only
1443 // the new items after loading
1444 for( PCB_TRACK* track : brd->Tracks() )
1445 track->SetFlags( SKIP_STRUCT );
1446
1447 for( FOOTPRINT* footprint : brd->Footprints() )
1449
1450 for( PCB_GROUP* group : brd->Groups() )
1451 group->SetFlags( SKIP_STRUCT );
1452
1453 for( BOARD_ITEM* drawing : brd->Drawings() )
1454 drawing->SetFlags( SKIP_STRUCT );
1455
1456 for( ZONE* zone : brd->Zones() )
1457 zone->SetFlags( SKIP_STRUCT );
1458
1459 for( PCB_GENERATOR* generator : brd->Generators() )
1460 generator->SetFlags( SKIP_STRUCT );
1461
1462 std::map<wxString, wxString> oldProperties = brd->GetProperties();
1463 std::map<wxString, wxString> newProperties;
1464
1465 PAGE_INFO oldPageInfo = brd->GetPageSettings();
1466 TITLE_BLOCK oldTitleBlock = brd->GetTitleBlock();
1467
1468 // Keep also the count of copper layers, to adjust if necessary
1469 int initialCopperLayerCount = brd->GetCopperLayerCount();
1470 LSET initialEnabledLayers = brd->GetEnabledLayers();
1471
1472 // Load the data
1473 try
1474 {
1475 std::map<std::string, UTF8> props;
1476
1477 // PCB_IO_EAGLE can use this info to center the BOARD, but it does not yet.
1478
1479 props["page_width"] = std::to_string( editFrame->GetPageSizeIU().x );
1480 props["page_height"] = std::to_string( editFrame->GetPageSizeIU().y );
1481
1483 [&]( wxString aTitle, int aIcon, wxString aMessage, wxString aAction ) -> bool
1484 {
1485 KIDIALOG dlg( editFrame, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
1486
1487 if( !aAction.IsEmpty() )
1488 dlg.SetOKLabel( aAction );
1489
1490 dlg.DoNotShowCheckbox( aMessage, 0 );
1491
1492 return dlg.ShowModal() == wxID_OK;
1493 } );
1494
1495 WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Loading PCB" ), 1 );
1496
1497 editFrame->GetDesignSettings().m_NetSettings->ClearNetclasses();
1498 pi.SetProgressReporter( &progressReporter );
1499 pi.LoadBoard( fileName, brd, &props, nullptr );
1500 }
1501 catch( const IO_ERROR& ioe )
1502 {
1503 wxString msg = wxString::Format( _( "Error loading board.\n%s" ), ioe.What() );
1504 DisplayError( editFrame, msg );
1505
1506 return 0;
1507 }
1508
1509 newProperties = brd->GetProperties();
1510
1511 for( const std::pair<const wxString, wxString>& prop : oldProperties )
1512 newProperties[ prop.first ] = prop.second;
1513
1514 brd->SetProperties( newProperties );
1515
1516 brd->SetPageSettings( oldPageInfo );
1517 brd->SetTitleBlock( oldTitleBlock );
1518
1519 // rebuild nets and ratsnest before any use of nets
1520 brd->BuildListOfNets();
1521 brd->SynchronizeNetsAndNetClasses( true );
1522 brd->BuildConnectivity();
1523
1524 // Synchronize layers
1525 // we should not ask PLUGINs to do these items:
1526 int copperLayerCount = brd->GetCopperLayerCount();
1527
1528 if( copperLayerCount > initialCopperLayerCount )
1529 brd->SetCopperLayerCount( copperLayerCount );
1530
1531 // Enable all used layers, and make them visible:
1532 LSET enabledLayers = brd->GetEnabledLayers();
1533 enabledLayers |= initialEnabledLayers;
1534 brd->SetEnabledLayers( enabledLayers );
1535 brd->SetVisibleLayers( enabledLayers );
1536
1537 if( placeBoardItems( &commit, brd, false, false /* Don't reannotate dupes on Append Board */ ) )
1538 commit.Push( _( "Append Board" ) );
1539 else
1540 commit.Revert();
1541
1542 // Refresh the UI for the updated board properties
1543 editFrame->GetAppearancePanel()->OnBoardChanged();
1544
1545 return 0;
1546}
1547
1548
1549int PCB_CONTROL::Undo( const TOOL_EVENT& aEvent )
1550{
1551 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1552 wxCommandEvent dummy;
1553
1554 if( editFrame )
1555 editFrame->RestoreCopyFromUndoList( dummy );
1556
1557 return 0;
1558}
1559
1560
1561int PCB_CONTROL::Redo( const TOOL_EVENT& aEvent )
1562{
1563 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1564 wxCommandEvent dummy;
1565
1566 if( editFrame )
1567 editFrame->RestoreCopyFromRedoList( dummy );
1568
1569 return 0;
1570}
1571
1572
1574{
1578 bool& snapMode = settings.allLayers;
1579
1581 snapMode = false;
1582 else if( aEvent.IsAction( &PCB_ACTIONS::magneticSnapAllLayers ) )
1583 snapMode = true;
1584 else
1585 snapMode = !snapMode;
1586
1588
1589 return 0;
1590}
1591
1592
1594{
1595 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
1596 return 0;
1597
1598 wxArrayString labels;
1599 labels.Add( _( "Active Layer" ) );
1600 labels.Add( _( "All Layers" ) );
1601
1602 if( !m_frame->GetHotkeyPopup() )
1604
1606
1610
1611 if( popup )
1612 popup->Popup( _( "Object Snapping" ), labels, static_cast<int>( settings.allLayers ) );
1613
1614 return 0;
1615}
1616
1617
1619{
1621 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
1622 PCB_SELECTION& selection = selTool->GetSelection();
1623 PCB_EDIT_FRAME* pcbFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1624 std::shared_ptr<DRC_ENGINE> drcEngine = m_frame->GetBoard()->GetDesignSettings().m_DRCEngine;
1625 DRC_CONSTRAINT constraint;
1626
1627 std::vector<MSG_PANEL_ITEM> msgItems;
1628
1629 if( routerTool && routerTool->RoutingInProgress() )
1630 {
1631 routerTool->UpdateMessagePanel();
1632 return 0;
1633 }
1634
1635 if( !pcbFrame && !m_frame->GetModel() )
1636 return 0;
1637
1638 if( selection.Empty() )
1639 {
1640 if( !pcbFrame )
1641 {
1642 FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_frame->GetModel() );
1643 fp->GetMsgPanelInfo( m_frame, msgItems );
1644 }
1645 else
1646 {
1648 }
1649 }
1650 else if( selection.GetSize() == 1 )
1651 {
1652 EDA_ITEM* item = selection.Front();
1653
1654 item->GetMsgPanelInfo( m_frame, msgItems );
1655
1656 PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item );
1657 NETINFO_ITEM* net = track ? track->GetNet() : nullptr;
1658 NETINFO_ITEM* coupledNet = net ? m_frame->GetBoard()->DpCoupledNet( net ) : nullptr;
1659
1660 if( coupledNet )
1661 {
1662 SEG trackSeg( track->GetStart(), track->GetEnd() );
1663 PCB_TRACK* coupledItem = nullptr;
1664 SEG::ecoord closestDist_sq = VECTOR2I::ECOORD_MAX;
1665
1666 for( PCB_TRACK* candidate : m_frame->GetBoard()->Tracks() )
1667 {
1668 if( candidate->GetNet() != coupledNet )
1669 continue;
1670
1671 SEG::ecoord dist_sq = trackSeg.SquaredDistance( SEG( candidate->GetStart(),
1672 candidate->GetEnd() ) );
1673
1674 if( !coupledItem || dist_sq < closestDist_sq )
1675 {
1676 coupledItem = candidate;
1677 closestDist_sq = dist_sq;
1678 }
1679 }
1680
1681 constraint = drcEngine->EvalRules( DIFF_PAIR_GAP_CONSTRAINT, track, coupledItem,
1682 track->GetLayer() );
1683
1684 wxString msg = m_frame->MessageTextFromMinOptMax( constraint.Value() );
1685
1686 if( !msg.IsEmpty() )
1687 {
1688 msgItems.emplace_back( wxString::Format( _( "DP Gap Constraints: %s" ), msg ),
1689 wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
1690 }
1691
1692 constraint = drcEngine->EvalRules( MAX_UNCOUPLED_CONSTRAINT, track,
1693 coupledItem, track->GetLayer() );
1694
1695 if( constraint.Value().HasMax() )
1696 {
1697 msg = m_frame->MessageTextFromValue( constraint.Value().Max() );
1698 msgItems.emplace_back( wxString::Format( _( "DP Max Uncoupled-length: %s" ), msg ),
1699 wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
1700 }
1701 }
1702 }
1703 else if( pcbFrame && selection.GetSize() == 2 )
1704 {
1705 // Pair selection broken into multiple, optional data, starting with the selected item
1706 // names
1707
1708 BOARD_ITEM* a = static_cast<BOARD_ITEM*>( selection[0] );
1709 BOARD_ITEM* b = static_cast<BOARD_ITEM*>( selection[1] );
1710
1711 msgItems.emplace_back( MSG_PANEL_ITEM( a->GetItemDescription( m_frame, false ),
1712 b->GetItemDescription( m_frame, false ) ) );
1713
1714 BOARD_CONNECTED_ITEM* a_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( a );
1715 BOARD_CONNECTED_ITEM* b_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( b );
1716
1717 if( a_conn && b_conn )
1718 {
1719 LSET overlap = a_conn->GetLayerSet() & b_conn->GetLayerSet() & LSET::AllCuMask();
1720 int a_netcode = a_conn->GetNetCode();
1721 int b_netcode = b_conn->GetNetCode();
1722
1723 if( overlap.count() > 0
1724 && ( a_netcode != b_netcode || a_netcode < 0 || b_netcode < 0 ) )
1725 {
1726 PCB_LAYER_ID layer = overlap.CuStack().front();
1727
1728 constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b, layer );
1729 msgItems.emplace_back( _( "Resolved clearance" ),
1730 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1731
1732 std::shared_ptr<SHAPE> a_shape( a_conn->GetEffectiveShape( layer ) );
1733 std::shared_ptr<SHAPE> b_shape( b_conn->GetEffectiveShape( layer ) );
1734
1735 int actual_clearance = a_shape->GetClearance( b_shape.get() );
1736
1737 if( actual_clearance > -1 && actual_clearance < std::numeric_limits<int>::max() )
1738 {
1739 msgItems.emplace_back( _( "Actual clearance" ),
1740 m_frame->MessageTextFromValue( actual_clearance ) );
1741 }
1742 }
1743 }
1744
1745 if( ( a->HasHole() || b->HasHole() ) )
1746 {
1749
1750 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1751 layer = active;
1752 else if( b->HasHole() && a->IsOnLayer( active ) && IsCopperLayer( active ) )
1753 layer = active;
1754 else if( a->HasHole() && b->IsOnCopperLayer() )
1755 layer = b->GetLayer();
1756 else if( b->HasHole() && a->IsOnCopperLayer() )
1757 layer = a->GetLayer();
1758
1759 if( IsCopperLayer( layer ) )
1760 {
1761 int actual = std::numeric_limits<int>::max();
1762
1763 if( a->HasHole() && b->IsOnCopperLayer() )
1764 {
1765 std::shared_ptr<SHAPE_SEGMENT> hole = a->GetEffectiveHoleShape();
1766 std::shared_ptr<SHAPE> other( b->GetEffectiveShape( layer ) );
1767
1768 actual = std::min( actual, hole->GetClearance( other.get() ) );
1769 }
1770
1771 if( b->HasHole() && a->IsOnCopperLayer() )
1772 {
1773 std::shared_ptr<SHAPE_SEGMENT> hole = b->GetEffectiveHoleShape();
1774 std::shared_ptr<SHAPE> other( a->GetEffectiveShape( layer ) );
1775
1776 actual = std::min( actual, hole->GetClearance( other.get() ) );
1777 }
1778
1779 if( actual < std::numeric_limits<int>::max() )
1780 {
1781 constraint = drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, a, b, layer );
1782 msgItems.emplace_back( _( "Resolved hole clearance" ),
1783 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1784
1785 if( actual > -1 && actual < std::numeric_limits<int>::max() )
1786 {
1787 msgItems.emplace_back( _( "Actual hole clearance" ),
1788 m_frame->MessageTextFromValue( actual ) );
1789 }
1790 }
1791 }
1792 }
1793
1794 for( PCB_LAYER_ID edgeLayer : { Edge_Cuts, Margin } )
1795 {
1798
1799 if( a->IsOnLayer( edgeLayer ) && b->Type() != PCB_FOOTPRINT_T )
1800 {
1801 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1802 layer = active;
1803 else if( IsCopperLayer( b->GetLayer() ) )
1804 layer = b->GetLayer();
1805 }
1806 else if( b->IsOnLayer( edgeLayer ) && a->Type() != PCB_FOOTPRINT_T )
1807 {
1808 if( a->IsOnLayer( active ) && IsCopperLayer( active ) )
1809 layer = active;
1810 else if( IsCopperLayer( a->GetLayer() ) )
1811 layer = a->GetLayer();
1812 }
1813
1814 if( layer >= 0 )
1815 {
1816 constraint = drcEngine->EvalRules( EDGE_CLEARANCE_CONSTRAINT, a, b, layer );
1817
1818 if( edgeLayer == Edge_Cuts )
1819 {
1820 msgItems.emplace_back( _( "Resolved edge clearance" ),
1821 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1822 }
1823 else
1824 {
1825 msgItems.emplace_back( _( "Resolved margin clearance" ),
1826 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1827 }
1828 }
1829 }
1830 }
1831
1832 if( msgItems.empty() )
1833 {
1834 if( selection.GetSize() )
1835 {
1836 msgItems.emplace_back( _( "Selected Items" ),
1837 wxString::Format( wxT( "%d" ), selection.GetSize() ) );
1838
1839 if( m_isBoardEditor )
1840 {
1841 std::set<wxString> netNames;
1842 std::set<wxString> netClasses;
1843
1844 for( EDA_ITEM* item : selection )
1845 {
1846 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
1847 {
1848 netNames.insert( UnescapeString( bci->GetNetname() ) );
1849 netClasses.insert( UnescapeString( bci->GetEffectiveNetClass()->GetName() ) );
1850
1851 if( netNames.size() > 1 && netClasses.size() > 1 )
1852 break;
1853 }
1854 }
1855
1856 if( netNames.size() == 1 )
1857 msgItems.emplace_back( _( "Net" ), *netNames.begin() );
1858
1859 if( netClasses.size() == 1 )
1860 msgItems.emplace_back( _( "Resolved Netclass" ), *netClasses.begin() );
1861 }
1862 }
1863 else
1864 {
1865 m_frame->GetBoard()->GetMsgPanelInfo( m_frame, msgItems );
1866 }
1867 }
1868
1869 m_frame->SetMsgPanel( msgItems );
1870
1871 return 0;
1872}
1873
1874
1876{
1877 wxFileName fileName = wxFileName( *aEvent.Parameter<wxString*>() );
1878
1879 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1880
1881 if( !editFrame )
1882 return 1;
1883
1884 wxString filePath = fileName.GetFullPath();
1886 IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( pluginType ) );
1887
1888 if( !pi )
1889 return 1;
1890
1891 return AppendBoard( *pi, filePath );
1892}
1893
1894
1896{
1897 view()->SetMirror( !view()->IsMirroredX(), false );
1898 view()->RecacheAllItems();
1899 frame()->GetCanvas()->ForceRefresh();
1900 frame()->OnDisplayOptionsChanged();
1901 return 0;
1902}
1903
1904// clang-format off
1906{
1909 Go( &PCB_CONTROL::Print, ACTIONS::print.MakeEvent() );
1910 Go( &PCB_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1911
1912 // Display modes
1928
1929 // Layer control
1967
1970
1971 // Grid control
1974
1975 Go( &PCB_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1976 Go( &PCB_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1977
1978 // Snapping control
1983
1984 // Miscellaneous
1986
1987 // Append control
1990
1991 Go( &PCB_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1993
2000
2001 // Add library by dropping file
2004}
2005// clang-format on
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
static TOOL_ACTION paste
Definition: actions.h:73
static TOOL_ACTION addLibrary
Definition: actions.h:49
static TOOL_ACTION pickerTool
Definition: actions.h:195
static TOOL_ACTION gridResetOrigin
Definition: actions.h:176
static TOOL_ACTION pasteSpecial
Definition: actions.h:74
static TOOL_ACTION highContrastModeCycle
Definition: actions.h:137
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION highContrastMode
Definition: actions.h:136
static TOOL_ACTION quit
Definition: actions.h:59
static TOOL_ACTION redo
Definition: actions.h:69
static TOOL_ACTION deleteTool
Definition: actions.h:79
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION newLibrary
Definition: actions.h:48
static TOOL_ACTION gridSetOrigin
Definition: actions.h:175
static TOOL_ACTION ddAddLibrary
Definition: actions.h:60
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
virtual void Revert() override
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.
std::shared_ptr< NET_SETTINGS > m_NetSettings
void SetGridOrigin(const VECTOR2I &aOrigin)
std::shared_ptr< DRC_ENGINE > m_DRCEngine
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:238
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:91
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:320
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: board_item.cpp:279
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:258
virtual bool IsLocked() const
Definition: board_item.cpp:75
virtual bool IsOnCopperLayer() const
Definition: board_item.h:151
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
Definition: board_item.cpp:289
virtual bool HasHole() const
Definition: board_item.h:156
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: board.cpp:1767
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:773
NETINFO_ITEM * DpCoupledNet(const NETINFO_ITEM *aNet)
Definition: board.cpp:1987
void MapNets(BOARD *aDestBoard)
Map all nets in the given board to nets with the same name (if any) in the destination board.
Definition: board.cpp:2634
void BuildListOfNets()
Definition: board.h:834
const GENERATORS & Generators() const
Definition: board.h:337
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
Definition: board.cpp:2608
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:793
const PAGE_INFO & GetPageSettings() const
Definition: board.h:689
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: board.h:363
const ZONES & Zones() const
Definition: board.h:335
const GROUPS & Groups() const
The groups must maintain the following invariants.
Definition: board.h:358
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition: board.cpp:187
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:2049
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:448
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:695
int GetCopperLayerCount() const
Definition: board.cpp:736
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:362
const FOOTPRINTS & Footprints() const
Definition: board.h:331
void RemoveAll(std::initializer_list< KICAD_T > aTypes={ PCB_NETINFO_T, PCB_MARKER_T, PCB_GROUP_T, PCB_ZONE_T, PCB_GENERATOR_T, PCB_FOOTPRINT_T, PCB_TRACE_T, PCB_SHAPE_T })
An efficient way to remove all items of a certain type from the board.
Definition: board.cpp:1242
const TRACKS & Tracks() const
Definition: board.h:329
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:690
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:805
void SetCopperLayerCount(int aCount)
Definition: board.cpp:742
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:779
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: board.cpp:1729
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:890
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:697
const DRAWINGS & Drawings() const
Definition: board.h:333
BOARD_ITEM * Parse()
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:109
int m_Threshold
Definition: collector.h:234
Color settings are a bit different than most of the settings objects in that there can be more than o...
void SetColor(int aLayer, const COLOR4D &aColor)
COLOR4D GetColor(int aLayer) const
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition: commit.h:86
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
Definition: commit.h:80
DO_NOT_SHOW_AGAIN m_DoNotShowAgain
wxString GetName() const
Definition: drc_rule.h:159
MINOPTMAX< int > & Value()
Definition: drc_rule.h:152
MINOPTMAX< int > m_Value
Definition: drc_rule.h:189
bool IsType(FRAME_T aType) const
HOTKEY_CYCLE_POPUP * GetHotkeyPopup()
void DisplayToolMsg(const wxString &msg) override
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual COLOR4D GetGridColor()
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
virtual void CreateHotkeyPopup()
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:243
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:244
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:127
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const
Return a user-visible description string of this item.
Definition: eda_item.cpp:111
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
virtual void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: eda_item.h:203
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:104
The interactive edit tool.
Definition: edit_tool.h:56
void DeleteItems(const PCB_SELECTION &aItem, bool aIsCut)
Definition: edit_tool.cpp:2396
static const TOOL_EVENT ClearedEvent
Definition: actions.h:275
static const TOOL_EVENT SelectedEvent
Definition: actions.h:273
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:280
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:272
static const TOOL_EVENT ContrastModeChangedByKeyEvent
Definition: actions.h:294
static const TOOL_EVENT ConnectivityChangedEvent
Selected item had a property changed (except movement)
Definition: actions.h:277
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:274
EDA_ANGLE GetOrientation() const
Definition: footprint.h:226
ZONES & Zones()
Definition: footprint.h:211
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:263
std::deque< PAD * > & Pads()
Definition: footprint.h:205
void SetReference(const wxString &aReference)
Definition: footprint.h:607
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: footprint.cpp:1523
GROUPS & Groups()
Definition: footprint.h:214
PCB_FIELDS & Fields()
Definition: footprint.h:202
DRAWINGS & GraphicalItems()
Definition: footprint.h:208
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:319
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:202
static const std::vector< KICAD_T > BoardLevelItems
A scan list for all primary board items, omitting items which are subordinate to a FOOTPRINT,...
Definition: collectors.h:233
static const std::vector< KICAD_T > AllBoardItems
A scan list for all editable board items.
Definition: collectors.h:222
void Collect(BOARD_ITEM *aItem, const std::vector< KICAD_T > &aScanList, const VECTOR2I &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
Definition: collectors.cpp:482
static const std::vector< KICAD_T > FootprintItems
A scan list for primary footprint items.
Definition: collectors.h:248
Similar to EDA_VIEW_SWITCHER, this dialog is a popup that shows feedback when using a hotkey to cycle...
void Popup(const wxString &aTitle, const wxArrayString &aItems, int aSelection)
virtual void SetProgressReporter(PROGRESS_REPORTER *aReporter)
Set an optional progress reporter.
Definition: io_base.h:85
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: kidialog.h:43
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: kidialog.cpp:51
int ShowModal() override
Definition: kidialog.cpp:95
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
double a
Alpha component.
Definition: color4d.h:395
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:91
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
void SetMirror(bool aMirrorX, bool aMirrorY)
Control the mirroring of the VIEW.
Definition: view.cpp:574
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:317
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:357
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:203
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1454
void UpdateLayerColor(int aLayer)
Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.
Definition: view.cpp:783
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:649
Definition: kiid.h:49
All information about a layer pair as stored in the layer pair store.
Management class for layer pairs in a PCB.
Definition: layer_pairs.h:47
std::vector< LAYER_PAIR_INFO > GetEnabledLayerPairs(int &aCurrentIndex) const
Get a vector of all enabled layer pairs, in order.
void SetCurrentLayerPair(const LAYER_PAIR &aPair)
Set the "active" layer pair.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: lseq.h:47
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:36
LSEQ UIOrder() const
Returns the copper, technical and user layers in the order shown in layer widget.
Definition: lset.cpp:799
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
Definition: lset.cpp:240
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:676
T Min() const
Definition: minoptmax.h:33
bool HasMax() const
Definition: minoptmax.h:38
T Max() const
Definition: minoptmax.h:34
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
Handle the data for a net.
Definition: netinfo.h:56
static NETINFO_ITEM * OrphanedItem()
NETINFO_ITEM meaning that there was no net assigned for an item, as there was no board storing net li...
Definition: netinfo.h:389
Definition: pad.h:54
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:59
MAGNETIC_SETTINGS m_MagneticItems
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:383
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:359
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:355
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:343
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:350
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:380
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:332
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:405
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:349
static TOOL_ACTION magneticSnapAllLayers
Definition: pcb_actions.h:245
static TOOL_ACTION ddAppendBoard
Drag and drop.
Definition: pcb_actions.h:586
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:372
static TOOL_ACTION magneticSnapActiveLayer
Snapping controls.
Definition: pcb_actions.h:244
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:382
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:339
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:371
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:338
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:68
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:376
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:358
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:381
static TOOL_ACTION layerPairPresetsCycle
Definition: pcb_actions.h:384
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:363
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:373
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:365
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:361
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:336
static TOOL_ACTION magneticSnapToggle
Definition: pcb_actions.h:246
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:353
static TOOL_ACTION ddImportFootprint
Definition: pcb_actions.h:587
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:342
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:369
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:352
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:341
static TOOL_ACTION ratsnestModeCycle
Definition: pcb_actions.h:335
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:367
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:354
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:374
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:542
static TOOL_ACTION netColorModeCycle
Definition: pcb_actions.h:334
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:348
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:357
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:362
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:364
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:391
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:378
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:340
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:333
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:366
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:356
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:120
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:377
static TOOL_ACTION layerTop
Definition: pcb_actions.h:347
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Definition: pcb_actions.h:76
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:351
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:360
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:368
static TOOL_ACTION layerNext
Definition: pcb_actions.h:379
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:370
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:375
Common, abstract interface for edit frames.
LAYER_PAIR_SETTINGS * GetLayerPairSettings()
Acess to the layer pair settings controller of the board, if available.
bool AddLibrary(const wxString &aLibName=wxEmptyString, FP_LIB_TABLE *aTable=nullptr)
Add an existing library to either the global or project library table.
void RestoreCopyFromUndoList(wxCommandEvent &aEvent)
Undo the last edit:
Definition: undo_redo.cpp:198
APPEARANCE_CONTROLS * GetAppearancePanel()
void RestoreCopyFromRedoList(wxCommandEvent &aEvent)
Redo the last edit:
Definition: undo_redo.cpp:228
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual void SwitchLayer(PCB_LAYER_ID aLayer)
Change the active layer in the frame.
virtual PCB_LAYER_ID GetActiveLayer() const
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)
Create a new entry in undo list of commands.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Updates the current display options from the given options struct.
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
void setTransitions() override
< Sets up handlers for various events.
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
int AddLibrary(const TOOL_EVENT &aEvent)
int DdAppendBoard(const TOOL_EVENT &aEvent)
int AppendBoard(PCB_IO &pi, wxString &fileName)
int DdImportFootprint(const TOOL_EVENT &aEvent)
int SnapModeFeedback(const TOOL_EVENT &aEvent)
int NetColorModeCycle(const TOOL_EVENT &aEvent)
int RatsnestModeCycle(const TOOL_EVENT &aEvent)
int TrackDisplayMode(const TOOL_EVENT &aEvent)
int DdAddLibrary(const TOOL_EVENT &aEvent)
int Redo(const TOOL_EVENT &aEvent)
int LayerPresetFeedback(const TOOL_EVENT &aEvent)
int UpdateMessagePanel(const TOOL_EVENT &aEvent)
int LayerAlphaDec(const TOOL_EVENT &aEvent)
int LayerNext(const TOOL_EVENT &aEvent)
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Definition: pcb_control.h:156
int ToggleRatsnest(const TOOL_EVENT &aEvent)
int LayerAlphaInc(const TOOL_EVENT &aEvent)
int HighContrastModeCycle(const TOOL_EVENT &aEvent)
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Definition: pcb_control.h:152
int Quit(const TOOL_EVENT &aEvent)
int HighContrastMode(const TOOL_EVENT &aEvent)
int Undo(const TOOL_EVENT &aEvent)
int ViaDisplayMode(const TOOL_EVENT &aEvent)
PCB_BASE_FRAME * m_frame
Grid origin marker.
Definition: pcb_control.h:149
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *originViewItem, const VECTOR2D &aPoint)
void pruneItemLayers(std::vector< BOARD_ITEM * > &aItems)
Helper for pasting.
int GridPlaceOrigin(const TOOL_EVENT &aEvent)
int FlipPcbView(const TOOL_EVENT &aEvent)
int SnapMode(const TOOL_EVENT &aEvent)
bool placeBoardItems(BOARD_COMMIT *aCommit, std::vector< BOARD_ITEM * > &aItems, bool aIsNew, bool aAnchorAtOrigin, bool aReannotateDuplicates)
Add and select or just select for move/place command a list of board items.
int ContrastModeFeedback(const TOOL_EVENT &aEvent)
int LayerToggle(const TOOL_EVENT &aEvent)
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Definition: pcb_control.cpp:96
int Print(const TOOL_EVENT &aEvent)
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
int GridResetOrigin(const TOOL_EVENT &aEvent)
BOARD_ITEM * m_pickerItem
Definition: pcb_control.h:154
int InteractiveDelete(const TOOL_EVENT &aEvent)
int LayerPrev(const TOOL_EVENT &aEvent)
int CycleLayerPresets(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
void unfilledZoneCheck()
We have bug reports indicating that some new users confuse zone filling/unfilling with the display mo...
int LayerSwitch(const TOOL_EVENT &aEvent)
Abstract dimension API.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
NET_COLOR_MODE m_NetColorMode
How to use color overrides on specific nets and netclasses.
ZONE_DISPLAY_MODE m_ZoneDisplayMode
void UpdateColors()
Update the color settings in the painter and GAL.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
The main frame for Pcbnew.
static const TOOL_EVENT SnappingModeChangedByKeyEvent
Hotkey feedback.
Definition: pcb_actions.h:597
static const TOOL_EVENT LayerPairPresetChangedByKeyEvent
Definition: pcb_actions.h:598
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:52
virtual bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
Definition: pcb_group.cpp:96
virtual bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:81
static PCB_IO * PluginFind(PCB_FILE_T aFileType)
Return a #PLUGIN which the caller can use to import, export, save, or load design documents.
Definition: pcb_io_mgr.cpp:69
PCB_FILE_T
The set of file types that the PCB_IO_MGR knows about, and for which there has been a plugin written,...
Definition: pcb_io_mgr.h:56
static PCB_FILE_T FindPluginTypeFromBoardPath(const wxString &aFileName, int aCtl=0)
Return a plugin type given a path for a board file.
Definition: pcb_io_mgr.cpp:112
A base class that BOARD loading and saving plugins should derive from.
Definition: pcb_io.h:71
virtual void SetQueryUserCallback(std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aAction)> aCallback)
Registers a KIDIALOG callback for collecting info from the user.
Definition: pcb_io.h:97
virtual BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr)
Load information from some input file format that this PCB_IO implementation knows about into either ...
Definition: pcb_io.cpp:74
Class that manages the presentation of PCB layers in a PCB frame.
wxString getLayerPairName(const LAYER_PAIR &aPair) const
Definition: sel_layer.cpp:90
Generic tool for picking an item.
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:43
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:44
The selection tool: currently supports:
void GuessSelectionCandidates(GENERAL_COLLECTOR &aCollector, const VECTOR2I &aWhere) const
Try to guess best selection candidates in case multiple items are clicked, by doing some brain-dead h...
bool Selectable(const BOARD_ITEM *aItem, bool checkVisibilityOnly=false) const
void FilterCollectedItems(GENERAL_COLLECTOR &aCollector, bool aMultiSelect)
Apply the SELECTION_FITLER_OPTIONS to the collector.
PCB_GROUP * GetEnteredGroup()
void FilterCollectorForHierarchy(GENERAL_COLLECTOR &aCollector, bool aMultiselect) const
In general we don't want to select both a parent and any of it's children.
PCB_SELECTION & GetSelection()
EDA_ITEM * GetTopLeftItem(bool aFootprintsOnly=false) const override
T * frame() const
KIGFX::PCB_VIEW * view() const
BOARD * board() const
PCB_DRAW_PANEL_GAL * canvas() const
PCBNEW_SETTINGS::DISPLAY_OPTIONS & displayOptions() const
bool m_isFootprintEditor
const PCB_SELECTION & selection() const
FOOTPRINT * footprint() const
const VECTOR2I & GetStart() const
Definition: pcb_track.h:122
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:119
bool HasValidLayerPair(int aCopperLayerCount)
Definition: pcb_track.cpp:975
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:679
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:84
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:73
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:64
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:104
Definition: seg.h:42
ecoord SquaredDistance(const SEG &aSeg) const
Definition: seg.cpp:75
VECTOR2I::extended_type ecoord
Definition: seg.h:44
void BrightenItem(EDA_ITEM *aItem)
void UnbrightenItem(EDA_ITEM *aItem)
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:42
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:100
EDA_ITEM * Front() const
Definition: selection.h:172
int Size() const
Returns the number of selected parts.
Definition: selection.h:116
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.cpp:180
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:110
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:41
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
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:167
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:460
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).
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
bool RunSynchronousAction(const TOOL_ACTION &aAction, COMMIT *aCommit, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:197
wxString MessageTextFromMinOptMax(const MINOPTMAX< int > &aValue) const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
static constexpr extended_type ECOORD_MAX
Definition: vector2d.h:76
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:76
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: wx_infobar.cpp:304
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
Definition: wx_infobar.cpp:140
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: wx_infobar.cpp:263
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
Handle a list of polygons defining a copper zone.
Definition: zone.h:73
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
Definition: clipboard.cpp:51
std::unique_ptr< wxImage > GetImageFromClipboard()
Get image data from the clipboard, if there is any.
Definition: clipboard.cpp:77
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
This file is part of the common library.
#define ALPHA_MAX
@ DIFF_PAIR_GAP_CONSTRAINT
Definition: drc_rule.h:70
@ EDGE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:53
@ CLEARANCE_CONSTRAINT
Definition: drc_rule.h:49
@ MAX_UNCOUPLED_CONSTRAINT
Definition: drc_rule.h:71
@ HOLE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:51
#define _(s)
Declaration of the eda_3d_viewer class.
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:536
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define HITTEST_THRESHOLD_PIXELS
@ FRAME_PCB_EDITOR
Definition: frame_type.h:42
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:43
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition: io_mgr.h:33
This file is part of the common library.
#define KICTL_KICAD_ONLY
chosen file is from KiCad according to user
Definition: kiway_player.h:75
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:696
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:532
@ LAYER_RATSNEST
Definition: layer_ids.h:206
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ Edge_Cuts
Definition: layer_ids.h:112
@ B_Cu
Definition: layer_ids.h:65
@ Margin
Definition: layer_ids.h:113
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:64
#define ZONE_LAYER_FOR(boardLayer)
Definition: layer_ids.h:277
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:100
bool AskLoadBoardFileName(PCB_EDIT_FRAME *aParent, wxString *aFileName, int aCtl=0)
Show a wxFileDialog asking for a BOARD filename to open.
#define ALPHA_STEP
static void pasteFootprintItemsToFootprintEditor(FOOTPRINT *aClipFootprint, BOARD *aBoard, std::vector< BOARD_ITEM * > &aPastedItems)
#define ALPHA_MIN
void Flip(T &aValue)
static void moveUnflaggedItems(const std::deque< T > &aList, std::vector< BOARD_ITEM * > &aTarget, bool aIsNew)
Class to handle a set of BOARD_ITEMs.
bool AskLoadBoardFileName(PCB_EDIT_FRAME *aParent, wxString *aFileName, int aCtl=0)
Show a wxFileDialog asking for a BOARD filename to open.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
Definition: typeinfo.h:249
@ PCB_T
Definition: typeinfo.h:82
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:105
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:102
@ 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_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:103
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:110
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:93
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:101
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
Definition: typeinfo.h:100
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition: typeinfo.h:94
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:104
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691
Definition of file extensions used in Kicad.