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 item->RunOnDescendants(
1352 []( BOARD_ITEM* aChild )
1353 {
1354 const_cast<KIID&>( aChild->m_Uuid ) = KIID();
1355 } );
1356
1357 // Even though BOARD_COMMIT::Push() will add any new items to the group, we're
1358 // going to run PCB_ACTIONS::move first, and the move tool will throw out any
1359 // items that aren't in the entered group.
1360 if( selectionTool->GetEnteredGroup() && !item->GetParentGroup() )
1361 selectionTool->GetEnteredGroup()->AddItem( item );
1362
1363 item->SetParent( board() );
1364 }
1365
1366 // Update item attributes if needed
1367 if( BaseType( item->Type() ) == PCB_DIMENSION_T )
1368 {
1369 static_cast<PCB_DIMENSION_BASE*>( item )->UpdateUnits();
1370 }
1371 else if( item->Type() == PCB_FOOTPRINT_T )
1372 {
1373 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
1374
1375 // Update the footprint path with the new KIID path if the footprint is new
1376 if( aIsNew )
1378
1379 for( BOARD_ITEM* dwg : footprint->GraphicalItems() )
1380 {
1381 if( BaseType( dwg->Type() ) == PCB_DIMENSION_T )
1382 static_cast<PCB_DIMENSION_BASE*>( dwg )->UpdateUnits();
1383 }
1384 }
1385
1386 // We only need to add the items that aren't inside a group currently selected
1387 // to the selection. If an item is inside a group and that group is selected,
1388 // then the selection tool will select it for us.
1389 if( !item->GetParentGroup() || !alg::contains( aItems, item->GetParentGroup() ) )
1390 itemsToSel.push_back( item );
1391 }
1392
1393 // Select the items that should be selected
1394 EDA_ITEMS toSel( itemsToSel.begin(), itemsToSel.end() );
1396
1397 // Reannotate duplicate footprints (make sense only in board editor )
1398 if( aReannotateDuplicates && m_isBoardEditor )
1399 m_toolMgr->GetTool<BOARD_REANNOTATE_TOOL>()->ReannotateDuplicatesInSelection();
1400
1401 for( BOARD_ITEM* item : aItems )
1402 {
1403 if( aIsNew )
1404 aCommit->Add( item );
1405 else
1406 aCommit->Added( item );
1407 }
1408
1409 PCB_SELECTION& selection = selectionTool->GetSelection();
1410
1411 if( selection.Size() > 0 )
1412 {
1413 if( aAnchorAtOrigin )
1414 {
1416 }
1417 else
1418 {
1419 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
1421 }
1422
1423 getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
1424
1426
1428 }
1429
1430 return true;
1431}
1432
1433
1434int PCB_CONTROL::AppendBoard( PCB_IO& pi, wxString& fileName )
1435{
1436 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1437
1438 if( !editFrame )
1439 return 1;
1440
1441 BOARD* brd = board();
1442
1443 if( !brd )
1444 return 1;
1445
1446 BOARD_COMMIT commit( editFrame );
1447
1448 // Mark existing items, in order to know what are the new items so we can select only
1449 // the new items after loading
1450 for( PCB_TRACK* track : brd->Tracks() )
1451 track->SetFlags( SKIP_STRUCT );
1452
1453 for( FOOTPRINT* footprint : brd->Footprints() )
1455
1456 for( PCB_GROUP* group : brd->Groups() )
1457 group->SetFlags( SKIP_STRUCT );
1458
1459 for( BOARD_ITEM* drawing : brd->Drawings() )
1460 drawing->SetFlags( SKIP_STRUCT );
1461
1462 for( ZONE* zone : brd->Zones() )
1463 zone->SetFlags( SKIP_STRUCT );
1464
1465 for( PCB_GENERATOR* generator : brd->Generators() )
1466 generator->SetFlags( SKIP_STRUCT );
1467
1468 std::map<wxString, wxString> oldProperties = brd->GetProperties();
1469 std::map<wxString, wxString> newProperties;
1470
1471 PAGE_INFO oldPageInfo = brd->GetPageSettings();
1472 TITLE_BLOCK oldTitleBlock = brd->GetTitleBlock();
1473
1474 // Keep also the count of copper layers, to adjust if necessary
1475 int initialCopperLayerCount = brd->GetCopperLayerCount();
1476 LSET initialEnabledLayers = brd->GetEnabledLayers();
1477
1478 // Load the data
1479 try
1480 {
1481 std::map<std::string, UTF8> props;
1482
1483 // PCB_IO_EAGLE can use this info to center the BOARD, but it does not yet.
1484
1485 props["page_width"] = std::to_string( editFrame->GetPageSizeIU().x );
1486 props["page_height"] = std::to_string( editFrame->GetPageSizeIU().y );
1487
1489 [&]( wxString aTitle, int aIcon, wxString aMessage, wxString aAction ) -> bool
1490 {
1491 KIDIALOG dlg( editFrame, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
1492
1493 if( !aAction.IsEmpty() )
1494 dlg.SetOKLabel( aAction );
1495
1496 dlg.DoNotShowCheckbox( aMessage, 0 );
1497
1498 return dlg.ShowModal() == wxID_OK;
1499 } );
1500
1501 WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Loading PCB" ), 1 );
1502
1503 editFrame->GetDesignSettings().m_NetSettings->ClearNetclasses();
1504 pi.SetProgressReporter( &progressReporter );
1505 pi.LoadBoard( fileName, brd, &props, nullptr );
1506 }
1507 catch( const IO_ERROR& ioe )
1508 {
1509 DisplayErrorMessage( editFrame, _( "Error loading board." ), ioe.What() );
1510
1511 return 0;
1512 }
1513
1514 newProperties = brd->GetProperties();
1515
1516 for( const std::pair<const wxString, wxString>& prop : oldProperties )
1517 newProperties[ prop.first ] = prop.second;
1518
1519 brd->SetProperties( newProperties );
1520
1521 brd->SetPageSettings( oldPageInfo );
1522 brd->SetTitleBlock( oldTitleBlock );
1523
1524 // rebuild nets and ratsnest before any use of nets
1525 brd->BuildListOfNets();
1526 brd->SynchronizeNetsAndNetClasses( true );
1527 brd->BuildConnectivity();
1528
1529 // Synchronize layers
1530 // we should not ask PLUGINs to do these items:
1531 int copperLayerCount = brd->GetCopperLayerCount();
1532
1533 if( copperLayerCount > initialCopperLayerCount )
1534 brd->SetCopperLayerCount( copperLayerCount );
1535
1536 // Enable all used layers, and make them visible:
1537 LSET enabledLayers = brd->GetEnabledLayers();
1538 enabledLayers |= initialEnabledLayers;
1539 brd->SetEnabledLayers( enabledLayers );
1540 brd->SetVisibleLayers( enabledLayers );
1541
1542 if( placeBoardItems( &commit, brd, false, false /* Don't reannotate dupes on Append Board */ ) )
1543 commit.Push( _( "Append Board" ) );
1544 else
1545 commit.Revert();
1546
1547 // Refresh the UI for the updated board properties
1548 editFrame->GetAppearancePanel()->OnBoardChanged();
1549
1550 return 0;
1551}
1552
1553
1554int PCB_CONTROL::Undo( const TOOL_EVENT& aEvent )
1555{
1556 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1557 wxCommandEvent dummy;
1558
1559 if( editFrame )
1560 editFrame->RestoreCopyFromUndoList( dummy );
1561
1562 return 0;
1563}
1564
1565
1566int PCB_CONTROL::Redo( const TOOL_EVENT& aEvent )
1567{
1568 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1569 wxCommandEvent dummy;
1570
1571 if( editFrame )
1572 editFrame->RestoreCopyFromRedoList( dummy );
1573
1574 return 0;
1575}
1576
1577
1579{
1583 bool& snapMode = settings.allLayers;
1584
1586 snapMode = false;
1587 else if( aEvent.IsAction( &PCB_ACTIONS::magneticSnapAllLayers ) )
1588 snapMode = true;
1589 else
1590 snapMode = !snapMode;
1591
1593
1594 return 0;
1595}
1596
1597
1599{
1600 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
1601 return 0;
1602
1603 wxArrayString labels;
1604 labels.Add( _( "Active Layer" ) );
1605 labels.Add( _( "All Layers" ) );
1606
1607 if( !m_frame->GetHotkeyPopup() )
1609
1611
1615
1616 if( popup )
1617 popup->Popup( _( "Object Snapping" ), labels, static_cast<int>( settings.allLayers ) );
1618
1619 return 0;
1620}
1621
1622
1624{
1626 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
1627 PCB_SELECTION& selection = selTool->GetSelection();
1628 PCB_EDIT_FRAME* pcbFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1629 std::shared_ptr<DRC_ENGINE> drcEngine = m_frame->GetBoard()->GetDesignSettings().m_DRCEngine;
1630 DRC_CONSTRAINT constraint;
1631
1632 std::vector<MSG_PANEL_ITEM> msgItems;
1633
1634 if( routerTool && routerTool->RoutingInProgress() )
1635 {
1636 routerTool->UpdateMessagePanel();
1637 return 0;
1638 }
1639
1640 if( !pcbFrame && !m_frame->GetModel() )
1641 return 0;
1642
1643 if( selection.Empty() )
1644 {
1645 if( !pcbFrame )
1646 {
1647 FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_frame->GetModel() );
1648 fp->GetMsgPanelInfo( m_frame, msgItems );
1649 }
1650 else
1651 {
1653 }
1654 }
1655 else if( selection.GetSize() == 1 )
1656 {
1657 EDA_ITEM* item = selection.Front();
1658
1659 item->GetMsgPanelInfo( m_frame, msgItems );
1660
1661 PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item );
1662 NETINFO_ITEM* net = track ? track->GetNet() : nullptr;
1663 NETINFO_ITEM* coupledNet = net ? m_frame->GetBoard()->DpCoupledNet( net ) : nullptr;
1664
1665 if( coupledNet )
1666 {
1667 SEG trackSeg( track->GetStart(), track->GetEnd() );
1668 PCB_TRACK* coupledItem = nullptr;
1669 SEG::ecoord closestDist_sq = VECTOR2I::ECOORD_MAX;
1670
1671 for( PCB_TRACK* candidate : m_frame->GetBoard()->Tracks() )
1672 {
1673 if( candidate->GetNet() != coupledNet )
1674 continue;
1675
1676 SEG::ecoord dist_sq = trackSeg.SquaredDistance( SEG( candidate->GetStart(),
1677 candidate->GetEnd() ) );
1678
1679 if( !coupledItem || dist_sq < closestDist_sq )
1680 {
1681 coupledItem = candidate;
1682 closestDist_sq = dist_sq;
1683 }
1684 }
1685
1686 constraint = drcEngine->EvalRules( DIFF_PAIR_GAP_CONSTRAINT, track, coupledItem,
1687 track->GetLayer() );
1688
1689 wxString msg = m_frame->MessageTextFromMinOptMax( constraint.Value() );
1690
1691 if( !msg.IsEmpty() )
1692 {
1693 msgItems.emplace_back( wxString::Format( _( "DP Gap Constraints: %s" ), msg ),
1694 wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
1695 }
1696
1697 constraint = drcEngine->EvalRules( MAX_UNCOUPLED_CONSTRAINT, track,
1698 coupledItem, track->GetLayer() );
1699
1700 if( constraint.Value().HasMax() )
1701 {
1702 msg = m_frame->MessageTextFromValue( constraint.Value().Max() );
1703 msgItems.emplace_back( wxString::Format( _( "DP Max Uncoupled-length: %s" ), msg ),
1704 wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
1705 }
1706 }
1707 }
1708 else if( pcbFrame && selection.GetSize() == 2 )
1709 {
1710 // Pair selection broken into multiple, optional data, starting with the selected item
1711 // names
1712
1713 BOARD_ITEM* a = static_cast<BOARD_ITEM*>( selection[0] );
1714 BOARD_ITEM* b = static_cast<BOARD_ITEM*>( selection[1] );
1715
1716 msgItems.emplace_back( MSG_PANEL_ITEM( a->GetItemDescription( m_frame, false ),
1717 b->GetItemDescription( m_frame, false ) ) );
1718
1719 BOARD_CONNECTED_ITEM* a_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( a );
1720 BOARD_CONNECTED_ITEM* b_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( b );
1721
1722 if( a_conn && b_conn )
1723 {
1724 LSET overlap = a_conn->GetLayerSet() & b_conn->GetLayerSet() & LSET::AllCuMask();
1725 int a_netcode = a_conn->GetNetCode();
1726 int b_netcode = b_conn->GetNetCode();
1727
1728 if( overlap.count() > 0
1729 && ( a_netcode != b_netcode || a_netcode < 0 || b_netcode < 0 ) )
1730 {
1731 PCB_LAYER_ID layer = overlap.CuStack().front();
1732
1733 constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b, layer );
1734 msgItems.emplace_back( _( "Resolved clearance" ),
1735 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1736
1737 std::shared_ptr<SHAPE> a_shape( a_conn->GetEffectiveShape( layer ) );
1738 std::shared_ptr<SHAPE> b_shape( b_conn->GetEffectiveShape( layer ) );
1739
1740 int actual_clearance = a_shape->GetClearance( b_shape.get() );
1741
1742 if( actual_clearance > -1 && actual_clearance < std::numeric_limits<int>::max() )
1743 {
1744 msgItems.emplace_back( _( "Actual clearance" ),
1745 m_frame->MessageTextFromValue( actual_clearance ) );
1746 }
1747 }
1748 }
1749
1750 if( ( a->HasHole() || b->HasHole() ) )
1751 {
1754
1755 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1756 layer = active;
1757 else if( b->HasHole() && a->IsOnLayer( active ) && IsCopperLayer( active ) )
1758 layer = active;
1759 else if( a->HasHole() && b->IsOnCopperLayer() )
1760 layer = b->GetLayer();
1761 else if( b->HasHole() && a->IsOnCopperLayer() )
1762 layer = a->GetLayer();
1763
1764 if( IsCopperLayer( layer ) )
1765 {
1766 int actual = std::numeric_limits<int>::max();
1767
1768 if( a->HasHole() && b->IsOnCopperLayer() )
1769 {
1770 std::shared_ptr<SHAPE_SEGMENT> hole = a->GetEffectiveHoleShape();
1771 std::shared_ptr<SHAPE> other( b->GetEffectiveShape( layer ) );
1772
1773 actual = std::min( actual, hole->GetClearance( other.get() ) );
1774 }
1775
1776 if( b->HasHole() && a->IsOnCopperLayer() )
1777 {
1778 std::shared_ptr<SHAPE_SEGMENT> hole = b->GetEffectiveHoleShape();
1779 std::shared_ptr<SHAPE> other( a->GetEffectiveShape( layer ) );
1780
1781 actual = std::min( actual, hole->GetClearance( other.get() ) );
1782 }
1783
1784 if( actual < std::numeric_limits<int>::max() )
1785 {
1786 constraint = drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, a, b, layer );
1787 msgItems.emplace_back( _( "Resolved hole clearance" ),
1788 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1789
1790 if( actual > -1 && actual < std::numeric_limits<int>::max() )
1791 {
1792 msgItems.emplace_back( _( "Actual hole clearance" ),
1793 m_frame->MessageTextFromValue( actual ) );
1794 }
1795 }
1796 }
1797 }
1798
1799 for( PCB_LAYER_ID edgeLayer : { Edge_Cuts, Margin } )
1800 {
1803
1804 if( a->IsOnLayer( edgeLayer ) && b->Type() != PCB_FOOTPRINT_T )
1805 {
1806 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1807 layer = active;
1808 else if( IsCopperLayer( b->GetLayer() ) )
1809 layer = b->GetLayer();
1810 }
1811 else if( b->IsOnLayer( edgeLayer ) && a->Type() != PCB_FOOTPRINT_T )
1812 {
1813 if( a->IsOnLayer( active ) && IsCopperLayer( active ) )
1814 layer = active;
1815 else if( IsCopperLayer( a->GetLayer() ) )
1816 layer = a->GetLayer();
1817 }
1818
1819 if( layer >= 0 )
1820 {
1821 constraint = drcEngine->EvalRules( EDGE_CLEARANCE_CONSTRAINT, a, b, layer );
1822
1823 if( edgeLayer == Edge_Cuts )
1824 {
1825 msgItems.emplace_back( _( "Resolved edge clearance" ),
1826 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1827 }
1828 else
1829 {
1830 msgItems.emplace_back( _( "Resolved margin clearance" ),
1831 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1832 }
1833 }
1834 }
1835 }
1836
1837 if( msgItems.empty() )
1838 {
1839 if( selection.GetSize() )
1840 {
1841 msgItems.emplace_back( _( "Selected Items" ),
1842 wxString::Format( wxT( "%d" ), selection.GetSize() ) );
1843
1844 if( m_isBoardEditor )
1845 {
1846 std::set<wxString> netNames;
1847 std::set<wxString> netClasses;
1848
1849 for( EDA_ITEM* item : selection )
1850 {
1851 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
1852 {
1853 netNames.insert( UnescapeString( bci->GetNetname() ) );
1854 netClasses.insert( UnescapeString( bci->GetEffectiveNetClass()->GetName() ) );
1855
1856 if( netNames.size() > 1 && netClasses.size() > 1 )
1857 break;
1858 }
1859 }
1860
1861 if( netNames.size() == 1 )
1862 msgItems.emplace_back( _( "Net" ), *netNames.begin() );
1863
1864 if( netClasses.size() == 1 )
1865 msgItems.emplace_back( _( "Resolved Netclass" ), *netClasses.begin() );
1866 }
1867 }
1868 else
1869 {
1870 m_frame->GetBoard()->GetMsgPanelInfo( m_frame, msgItems );
1871 }
1872 }
1873
1874 m_frame->SetMsgPanel( msgItems );
1875
1876 return 0;
1877}
1878
1879
1881{
1882 wxFileName fileName = wxFileName( *aEvent.Parameter<wxString*>() );
1883
1884 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1885
1886 if( !editFrame )
1887 return 1;
1888
1889 wxString filePath = fileName.GetFullPath();
1891 IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( pluginType ) );
1892
1893 if( !pi )
1894 return 1;
1895
1896 return AppendBoard( *pi, filePath );
1897}
1898
1899
1901{
1902 view()->SetMirror( !view()->IsMirroredX(), false );
1903 view()->RecacheAllItems();
1904 frame()->GetCanvas()->ForceRefresh();
1905 frame()->OnDisplayOptionsChanged();
1906 return 0;
1907}
1908
1909// clang-format off
1911{
1914 Go( &PCB_CONTROL::Print, ACTIONS::print.MakeEvent() );
1915 Go( &PCB_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1916
1917 // Display modes
1933
1934 // Layer control
1972
1975
1976 // Grid control
1979
1980 Go( &PCB_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1981 Go( &PCB_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1982
1983 // Snapping control
1988
1989 // Miscellaneous
1991
1992 // Append control
1995
1996 Go( &PCB_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1998
2005
2006 // Add library by dropping file
2009}
2010// 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:204
static TOOL_ACTION gridResetOrigin
Definition: actions.h:185
static TOOL_ACTION pasteSpecial
Definition: actions.h:74
static TOOL_ACTION highContrastModeCycle
Definition: actions.h:146
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION highContrastMode
Definition: actions.h:145
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:184
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:79
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:237
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:90
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:319
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:278
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:257
virtual bool IsLocked() const
Definition: board_item.cpp:75
virtual bool IsOnCopperLayer() const
Definition: board_item.h:150
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
Definition: board_item.cpp:288
virtual bool HasHole() const
Definition: board_item.h:155
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:1773
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:778
NETINFO_ITEM * DpCoupledNet(const NETINFO_ITEM *aNet)
Definition: board.cpp:1993
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:2640
void BuildListOfNets()
Definition: board.h:834
const GENERATORS & Generators() const
Definition: board.h:337
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
Definition: board.cpp:2614
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:798
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:2055
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:741
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:1248
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:810
void SetCopperLayerCount(int aCount)
Definition: board.cpp:747
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:784
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:1735
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:895
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
int ShowModal() override
wxString GetName() const
Definition: drc_rule.h:160
MINOPTMAX< int > & Value()
Definition: drc_rule.h:153
MINOPTMAX< int > m_Value
Definition: drc_rule.h:190
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
const KIID m_Uuid
Definition: eda_item.h:489
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:2444
static const TOOL_EVENT ClearedEvent
Definition: actions.h:294
static const TOOL_EVENT SelectedEvent
Definition: actions.h:292
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:299
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:291
static const TOOL_EVENT ContrastModeChangedByKeyEvent
Definition: actions.h:313
static const TOOL_EVENT ConnectivityChangedEvent
Selected item had a property changed (except movement)
Definition: actions.h:296
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:293
EDA_ANGLE GetOrientation() const
Definition: footprint.h:227
ZONES & Zones()
Definition: footprint.h:212
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:264
std::deque< PAD * > & Pads()
Definition: footprint.h:206
void SetReference(const wxString &aReference)
Definition: footprint.h:628
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:1573
GROUPS & Groups()
Definition: footprint.h:215
PCB_FIELDS & Fields()
Definition: footprint.h:203
DRAWINGS & GraphicalItems()
Definition: footprint.h:209
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:549
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:299
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:334
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:199
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1435
void UpdateLayerColor(int aLayer)
Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.
Definition: view.cpp:744
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:656
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:809
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
Definition: lset.cpp:250
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:686
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:386
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:362
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:358
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:346
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:353
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:383
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:335
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:408
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:352
static TOOL_ACTION magneticSnapAllLayers
Definition: pcb_actions.h:248
static TOOL_ACTION ddAppendBoard
Drag and drop.
Definition: pcb_actions.h:589
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:375
static TOOL_ACTION magneticSnapActiveLayer
Snapping controls.
Definition: pcb_actions.h:247
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:385
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:342
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:374
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:341
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:68
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:379
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:361
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:384
static TOOL_ACTION layerPairPresetsCycle
Definition: pcb_actions.h:387
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:366
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:376
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:368
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:364
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:339
static TOOL_ACTION magneticSnapToggle
Definition: pcb_actions.h:249
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:356
static TOOL_ACTION ddImportFootprint
Definition: pcb_actions.h:590
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:345
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:372
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:355
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:344
static TOOL_ACTION ratsnestModeCycle
Definition: pcb_actions.h:338
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:370
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:357
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:377
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:545
static TOOL_ACTION netColorModeCycle
Definition: pcb_actions.h:337
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:351
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:360
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:365
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:367
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:394
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:381
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:343
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:336
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:369
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:359
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:120
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:380
static TOOL_ACTION layerTop
Definition: pcb_actions.h:350
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:354
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:363
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:371
static TOOL_ACTION layerNext
Definition: pcb_actions.h:382
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:373
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:378
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:600
static const TOOL_EVENT LayerPairPresetChangedByKeyEvent
Definition: pcb_actions.h:601
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:999
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
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:195
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:706
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:531
@ LAYER_RATSNEST
Definition: layer_ids.h:205
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:276
@ 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.