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 The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include "pcb_control.h"
27
28#include <kiplatform/ui.h>
29#include <tools/edit_tool.h>
31#include <router/router_tool.h>
32#include <pgm_base.h>
33#include <tools/pcb_actions.h>
38#include <board_commit.h>
39#include <board.h>
41#include <board_item.h>
42#include <clipboard.h>
44#include <pcb_dimension.h>
46#include <footprint.h>
47#include <layer_pairs.h>
48#include <pcb_group.h>
50#include <pcb_reference_image.h>
51#include <pcb_textbox.h>
52#include <pcb_track.h>
53#include <pcb_generator.h>
55#include <zone.h>
56#include <confirm.h>
57#include <kidialog.h>
59#include <core/kicad_algo.h>
61#include <kicad_clipboard.h>
62#include <origin_viewitem.h>
63#include <pcb_edit_frame.h>
64#include <pcb_painter.h>
66#include <string>
67#include <tool/tool_manager.h>
72#include <widgets/wx_infobar.h>
73#include <wx/hyperlink.h>
74
75
76using namespace std::placeholders;
77
78
79// files.cpp
80extern bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, int aCtl = 0 );
81
82
84 PCB_TOOL_BASE( "pcbnew.Control" ),
85 m_frame( nullptr ),
86 m_pickerItem( nullptr )
87{
89}
90
91
93{
94}
95
96
98{
99 m_frame = getEditFrame<PCB_BASE_FRAME>();
100
101 if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW )
102 {
103 m_gridOrigin->SetPosition( board()->GetDesignSettings().GetGridOrigin() );
104 m_gridOrigin->SetColor( m_frame->GetGridColor() );
105 getView()->Remove( m_gridOrigin.get() );
106 getView()->Add( m_gridOrigin.get() );
107 }
108}
109
110
112{
114 {
115 if( aEvent.IsAction( &ACTIONS::newLibrary ) )
116 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
117 else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
118 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
119 }
120
121 return 0;
122}
123
124
126{
127 const wxString fn = *aEvent.Parameter<wxString*>();
128 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary( fn );
129 return 0;
130}
131
132
134{
135 const wxString fn = *aEvent.Parameter<wxString*>();
136 static_cast<FOOTPRINT_EDIT_FRAME*>( m_frame )->ImportFootprint( fn );
137 m_frame->Zoom_Automatique( false );
138 return 0;
139}
140
141
142int PCB_CONTROL::Quit( const TOOL_EVENT& aEvent )
143{
144 m_frame->Close( false );
145 return 0;
146}
147
148
149template<class T> void Flip( T& aValue )
150{
151 aValue = !aValue;
152}
153
154
156{
157 Flip( displayOptions().m_DisplayPcbTrackFill );
158
159 for( PCB_TRACK* track : board()->Tracks() )
160 {
161 if( track->Type() == PCB_TRACE_T || track->Type() == PCB_ARC_T )
162 view()->Update( track, KIGFX::REPAINT );
163 }
164
165 for( BOARD_ITEM* shape : board()->Drawings() )
166 {
167 if( shape->Type() == PCB_SHAPE_T && static_cast<PCB_SHAPE*>( shape )->IsOnCopperLayer() )
168 view()->Update( shape, KIGFX::REPAINT );
169 }
170
171 canvas()->Refresh();
172
173 return 0;
174}
175
176
178{
179 if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
180 {
181 // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
182 Flip( displayOptions().m_ShowGlobalRatsnest );
183 getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
184 displayOptions().m_ShowGlobalRatsnest );
185
186 }
187 else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
188 {
189 Flip( displayOptions().m_DisplayRatsnestLinesCurved );
190 }
191
192 frame()->OnDisplayOptionsChanged();
193
195 canvas()->Refresh();
196
197 return 0;
198}
199
200
202{
203 Flip( displayOptions().m_DisplayViaFill );
204
205 for( PCB_TRACK* track : board()->Tracks() )
206 {
207 if( track->Type() == PCB_VIA_T )
208 view()->Update( track, KIGFX::REPAINT );
209 }
210
211 canvas()->Refresh();
212 return 0;
213}
214
215
222{
223 if( Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning )
224 return;
225
226 bool unfilledZones = false;
227
228 for( const ZONE* zone : board()->Zones() )
229 {
230 if( !zone->GetIsRuleArea() && !zone->IsFilled() )
231 {
232 unfilledZones = true;
233 break;
234 }
235 }
236
237 if( unfilledZones )
238 {
239 WX_INFOBAR* infobar = frame()->GetInfoBar();
240 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Don't show again" ),
241 wxEmptyString );
242
243 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
244 [&]( wxHyperlinkEvent& aEvent )
245 {
247 frame()->GetInfoBar()->Dismiss();
248 } ) );
249
250 infobar->RemoveAllButtons();
251 infobar->AddButton( button );
252
253 wxString msg;
254 msg.Printf( _( "Not all zones are filled. Use Edit > Fill All Zones (%s) "
255 "if you wish to see all fills." ),
257
258 infobar->ShowMessageFor( msg, 5000, wxICON_WARNING );
259 }
260}
261
262
264{
265 PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
266
267 // Apply new display options to the GAL canvas
269 {
271
272 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
273 }
274 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutline ) )
275 {
276 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE;
277 }
278 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayFractured ) )
279 {
280 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS;
281 }
283 {
284 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_TRIANGULATION;
285 }
286 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
287 {
288 if( opts.m_ZoneDisplayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
289 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE;
290 else
291 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
292 }
293 else
294 {
295 wxFAIL;
296 }
297
298 m_frame->SetDisplayOptions( opts );
299
300 for( ZONE* zone : board()->Zones() )
301 view()->Update( zone, KIGFX::REPAINT );
302
303 canvas()->Refresh();
304
305 return 0;
306}
307
308
310{
311 PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
312
313 opts.m_ContrastModeDisplay = opts.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::NORMAL
314 ? HIGH_CONTRAST_MODE::DIMMED
315 : HIGH_CONTRAST_MODE::NORMAL;
316
317 m_frame->SetDisplayOptions( opts );
318 return 0;
319}
320
321
323{
324 PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
325
326 switch( opts.m_ContrastModeDisplay )
327 {
328 case HIGH_CONTRAST_MODE::NORMAL: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::DIMMED; break;
329 case HIGH_CONTRAST_MODE::DIMMED: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::HIDDEN; break;
330 case HIGH_CONTRAST_MODE::HIDDEN: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL; break;
331 }
332
333 m_frame->SetDisplayOptions( opts );
334
336 return 0;
337}
338
339
341{
342 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
343 return 0;
344
345 PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
346
347 wxArrayString labels;
348 labels.Add( _( "Normal" ) );
349 labels.Add( _( "Dimmed" ) );
350 labels.Add( _( "Hidden" ) );
351
352 if( !m_frame->GetHotkeyPopup() )
354
356
357 if( popup )
358 {
359 popup->Popup( _( "Inactive Layer Display" ), labels,
360 static_cast<int>( opts.m_ContrastModeDisplay ) );
361 }
362
363 return 0;
364}
365
366
368{
369 PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions();
370
371 switch( opts.m_NetColorMode )
372 {
373 case NET_COLOR_MODE::ALL: opts.m_NetColorMode = NET_COLOR_MODE::RATSNEST; break;
374 case NET_COLOR_MODE::RATSNEST: opts.m_NetColorMode = NET_COLOR_MODE::OFF; break;
375 case NET_COLOR_MODE::OFF: opts.m_NetColorMode = NET_COLOR_MODE::ALL; break;
376 }
377
378 m_frame->SetDisplayOptions( opts );
379 return 0;
380}
381
382
384{
385 if( !displayOptions().m_ShowGlobalRatsnest )
386 {
388 displayOptions().m_RatsnestMode = RATSNEST_MODE::ALL;
389 }
390 else if( displayOptions().m_RatsnestMode == RATSNEST_MODE::ALL )
391 {
392 displayOptions().m_RatsnestMode = RATSNEST_MODE::VISIBLE;
393 }
394 else
395 {
397 }
398
399 getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
400 displayOptions().m_ShowGlobalRatsnest );
401
402 frame()->OnDisplayOptionsChanged();
403
405 canvas()->Refresh();
406 return 0;
407}
408
409
411{
413
414 return 0;
415}
416
417
419{
420 PCB_BASE_FRAME* editFrame = m_frame;
421 BOARD* brd = board();
422 PCB_LAYER_ID layer = editFrame->GetActiveLayer();
423 bool wraparound = false;
424
425 if( !IsCopperLayer( layer ) )
426 {
427 editFrame->SwitchLayer( B_Cu );
428 return 0;
429 }
430
431 LSET cuMask = LSET::AllCuMask( brd->GetCopperLayerCount() );
432 LSEQ layerStack = cuMask.UIOrder();
433
434 int ii = 0;
435
436 // Find the active layer in list
437 for( ; ii < (int)layerStack.size(); ii++ )
438 {
439 if( layer == layerStack[ii] )
440 break;
441 }
442
443 // Find the next visible layer in list
444 for( ; ii < (int)layerStack.size(); ii++ )
445 {
446 int jj = ii+1;
447
448 if( jj >= (int)layerStack.size() )
449 jj = 0;
450
451 layer = layerStack[jj];
452
453 if( brd->IsLayerVisible( layer ) )
454 break;
455
456 if( jj == 0 ) // the end of list is reached. Try from the beginning
457 {
458 if( wraparound )
459 {
460 wxBell();
461 return 0;
462 }
463 else
464 {
465 wraparound = true;
466 ii = -1;
467 }
468 }
469 }
470
471 wxCHECK( IsCopperLayer( layer ), 0 );
472 editFrame->SwitchLayer( layer );
473
474 return 0;
475}
476
477
479{
480 PCB_BASE_FRAME* editFrame = m_frame;
481 BOARD* brd = board();
482 PCB_LAYER_ID layer = editFrame->GetActiveLayer();
483 bool wraparound = false;
484
485 if( !IsCopperLayer( layer ) )
486 {
487 editFrame->SwitchLayer( F_Cu );
488 return 0;
489 }
490
491 LSET cuMask = LSET::AllCuMask( brd->GetCopperLayerCount() );
492 LSEQ layerStack = cuMask.UIOrder();
493
494 int ii = 0;
495
496 // Find the active layer in list
497 for( ; ii < (int)layerStack.size(); ii++ )
498 {
499 if( layer == layerStack[ii] )
500 break;
501 }
502
503 // Find the previous visible layer in list
504 for( ; ii >= 0; ii-- )
505 {
506 int jj = ii - 1;
507
508 if( jj < 0 )
509 jj = (int)layerStack.size() - 1;
510
511 layer = layerStack[jj];
512
513 if( brd->IsLayerVisible( layer ) )
514 break;
515
516 if( ii == 0 ) // the start of list is reached. Try from the last
517 {
518 if( wraparound )
519 {
520 wxBell();
521 return 0;
522 }
523 else
524 {
525 wraparound = true;
526 ii = 1;
527 }
528 }
529 }
530
531 wxCHECK( IsCopperLayer( layer ), 0 );
532 editFrame->SwitchLayer( layer );
533
534 return 0;
535}
536
537
539{
540 int currentLayer = m_frame->GetActiveLayer();
541 PCB_SCREEN* screen = m_frame->GetScreen();
542
543 if( currentLayer == screen->m_Route_Layer_TOP )
545 else
547
548 return 0;
549}
550
551
552// It'd be nice to share the min/max with the DIALOG_COLOR_PICKER, but those are
553// set in wxFormBuilder.
554#define ALPHA_MIN 0.20
555#define ALPHA_MAX 1.00
556#define ALPHA_STEP 0.05
557
558
560{
562 int currentLayer = m_frame->GetActiveLayer();
563 KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
564
565 if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
566 {
567 currentColor.a += ALPHA_STEP;
568 settings->SetColor( currentLayer, currentColor );
570
572 view->UpdateLayerColor( currentLayer );
573 view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
574
575 if( IsCopperLayer( currentLayer ) )
576 view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
577
579 }
580 else
581 {
582 wxBell();
583 }
584
585 return 0;
586}
587
588
590{
592 int currentLayer = m_frame->GetActiveLayer();
593 KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
594
595 if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
596 {
597 currentColor.a -= ALPHA_STEP;
598 settings->SetColor( currentLayer, currentColor );
600
602 view->UpdateLayerColor( currentLayer );
603 view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
604
605 if( IsCopperLayer( currentLayer ) )
606 view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
607
609 }
610 else
611 {
612 wxBell();
613 }
614
615 return 0;
616}
617
618
620{
621 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
622
623 if( !editFrame )
624 return 0;
625
626 LAYER_PAIR_SETTINGS* settings = editFrame->GetLayerPairSettings();
627
628 if( !settings )
629 return 0;
630
631 int currentIndex;
632 std::vector<LAYER_PAIR_INFO> presets = settings->GetEnabledLayerPairs( currentIndex );
633
634 if( presets.size() < 2 )
635 return 0;
636
637 if( currentIndex < 0 )
638 {
639 wxASSERT_MSG( false, "Current layer pair not found in layer settings" );
640 currentIndex = 0;
641 }
642
643 const int nextIndex = ( currentIndex + 1 ) % presets.size();
644 const LAYER_PAIR& nextPair = presets[nextIndex].GetLayerPair();
645
646 settings->SetCurrentLayerPair( nextPair );
647
649 return 0;
650}
651
652
654{
655 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
656 return 0;
657
658 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
659
660 if( !editFrame )
661 return 0;
662
663 LAYER_PAIR_SETTINGS* settings = editFrame->GetLayerPairSettings();
664
665 if( !settings )
666 return 0;
667
668 PCB_LAYER_PRESENTATION layerPresentation( editFrame );
669
670 int currentIndex;
671 std::vector<LAYER_PAIR_INFO> presets = settings->GetEnabledLayerPairs( currentIndex );
672
673 wxArrayString labels;
674 for( const LAYER_PAIR_INFO& layerPairInfo : presets )
675 {
676 wxString label = layerPresentation.getLayerPairName( layerPairInfo.GetLayerPair() );
677
678 if( layerPairInfo.GetName() )
679 {
680 label += wxT( " (" ) + *layerPairInfo.GetName() + wxT( ")" );
681 }
682
683 labels.Add( label );
684 }
685
686 if( !editFrame->GetHotkeyPopup() )
687 editFrame->CreateHotkeyPopup();
688
689 HOTKEY_CYCLE_POPUP* popup = editFrame->GetHotkeyPopup();
690
691 if( popup )
692 {
693 int selection = currentIndex;
694 popup->Popup( _( "Preset Layer Pairs" ), labels, selection );
695 }
696
697 return 0;
698}
699
700
702 EDA_ITEM* originViewItem, const VECTOR2D& aPoint )
703{
704 aFrame->GetDesignSettings().SetGridOrigin( VECTOR2I( aPoint ) );
705 aView->GetGAL()->SetGridOrigin( aPoint );
706 originViewItem->SetPosition( aPoint );
707 aView->MarkDirty();
708 aFrame->OnModify();
709}
710
711
713{
714 VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
715
716 if( origin )
717 {
718 // We can't undo the other grid dialog settings, so no sense undoing just the origin
719 DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
720 delete origin;
721 }
722 else
723 {
724 if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
725 return 0;
726
728
729 if( !picker ) // Happens in footprint wizard
730 return 0;
731
732 // Deactivate other tools; particularly important if another PICKER is currently running
733 Activate();
734
735 picker->SetClickHandler(
736 [this]( const VECTOR2D& pt ) -> bool
737 {
738 m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
740 return false; // drill origin is a one-shot; don't continue with tool
741 } );
742
744 }
745
746 return 0;
747}
748
749
751{
752 m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
754 return 0;
755}
756
757
758#define HITTEST_THRESHOLD_PIXELS 5
759
760
762{
764 return 0;
765
767
768 m_pickerItem = nullptr;
770
771 // Deactivate other tools; particularly important if another PICKER is currently running
772 Activate();
773
774 picker->SetCursor( KICURSOR::REMOVE );
775
776 picker->SetClickHandler(
777 [this]( const VECTOR2D& aPosition ) -> bool
778 {
779 if( m_pickerItem )
780 {
782 {
783 m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
784 m_statusPopup->SetText( _( "Item locked." ) );
785 m_statusPopup->PopupFor( 2000 );
786 m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition()
787 + wxPoint( 20, 20 ) );
788 return true;
789 }
790
792 selectionTool->UnbrightenItem( m_pickerItem );
793
794 PCB_SELECTION items;
795 items.Add( m_pickerItem );
796
797 EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
798 editTool->DeleteItems( items, false );
799
800 m_pickerItem = nullptr;
801 }
802
803 return true;
804 } );
805
806 picker->SetMotionHandler(
807 [this]( const VECTOR2D& aPos )
808 {
812 GENERAL_COLLECTOR collector;
813 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
814
816 collector.Collect( board, GENERAL_COLLECTOR::FootprintItems, aPos, guide );
817 else
818 collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, aPos, guide );
819
820 // Remove unselectable items
821 for( int i = collector.GetCount() - 1; i >= 0; --i )
822 {
823 if( !selectionTool->Selectable( collector[ i ] ) )
824 collector.Remove( i );
825 }
826
827 selectionTool->FilterCollectorForHierarchy( collector, false );
828 selectionTool->FilterCollectedItems( collector, false );
829
830 if( collector.GetCount() > 1 )
831 selectionTool->GuessSelectionCandidates( collector, aPos );
832
833 BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
834
835 if( m_pickerItem != item )
836 {
837 if( m_pickerItem )
838 selectionTool->UnbrightenItem( m_pickerItem );
839
840 m_pickerItem = item;
841
842 if( m_pickerItem )
843 selectionTool->BrightenItem( m_pickerItem );
844 }
845 } );
846
847 picker->SetFinalizeHandler(
848 [this]( const int& aFinalState )
849 {
850 if( m_pickerItem )
851 m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
852
853 m_statusPopup.reset();
854
855 // Ensure the cursor gets changed&updated
856 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
858 } );
859
861
862 return 0;
863}
864
865
866static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBoard,
867 std::vector<BOARD_ITEM*>& aPastedItems )
868{
869 FOOTPRINT* editorFootprint = aBoard->GetFirstFootprint();
870
871 aClipFootprint->SetParent( aBoard );
872
873 for( PAD* pad : aClipFootprint->Pads() )
874 {
875 pad->SetParent( editorFootprint );
876 aPastedItems.push_back( pad );
877 }
878
879 aClipFootprint->Pads().clear();
880
881 // Not all items can be added to the current footprint: mandatory fields are already existing
882 // in the current footprint.
883 //
884 for( PCB_FIELD* field : aClipFootprint->GetFields() )
885 {
886 if( field->IsMandatory() )
887 {
888 if( PCB_GROUP* parentGroup = field->GetParentGroup() )
889 parentGroup->RemoveItem( field );
890 }
891 else
892 {
893 PCB_TEXT* text = static_cast<PCB_TEXT*>( field );
894
895 text->SetTextAngle( text->GetTextAngle() - aClipFootprint->GetOrientation() );
896 text->SetTextAngle( text->GetTextAngle() + editorFootprint->GetOrientation() );
897
898 VECTOR2I pos = field->GetFPRelativePosition();
899 field->SetParent( editorFootprint );
900 field->SetFPRelativePosition( pos );
901
902 aPastedItems.push_back( field );
903 }
904 }
905
906 aClipFootprint->ClearFields();
907
908 for( BOARD_ITEM* item : aClipFootprint->GraphicalItems() )
909 {
910 if( item->Type() == PCB_TEXT_T )
911 {
912 PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
913
914 text->SetTextAngle( text->GetTextAngle() - aClipFootprint->GetOrientation() );
915 text->SetTextAngle( text->GetTextAngle() + editorFootprint->GetOrientation() );
916 }
917
918 item->Rotate( item->GetPosition(), -aClipFootprint->GetOrientation() );
919 item->Rotate( item->GetPosition(), editorFootprint->GetOrientation() );
920
921 VECTOR2I pos = item->GetFPRelativePosition();
922 item->SetParent( editorFootprint );
923 item->SetFPRelativePosition( pos );
924
925 aPastedItems.push_back( item );
926 }
927
928 aClipFootprint->GraphicalItems().clear();
929
930 for( ZONE* zone : aClipFootprint->Zones() )
931 {
932 zone->SetParent( editorFootprint );
933 aPastedItems.push_back( zone );
934 }
935
936 aClipFootprint->Zones().clear();
937
938 for( PCB_GROUP* group : aClipFootprint->Groups() )
939 {
940 group->SetParent( editorFootprint );
941 aPastedItems.push_back( group );
942 }
943
944 aClipFootprint->Groups().clear();
945}
946
947
948void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
949{
950 // Do not prune items or layers when copying to the FP editor, because all
951 // layers are accepted, even if they are not enabled in the dummy board
952 // This is mainly true for internal copper layers: all are allowed but only one
953 // (In1.cu) is enabled for the GUI.
955 return;
956
957 LSET enabledLayers = board()->GetEnabledLayers();
958 std::vector<BOARD_ITEM*> returnItems;
959 bool fpItemDeleted = false;
960
961 for( BOARD_ITEM* item : aItems )
962 {
963 if( item->Type() == PCB_FOOTPRINT_T )
964 {
965 FOOTPRINT* fp = static_cast<FOOTPRINT*>( item );
966
967 // Items living in a parent footprint are never removed, even if their
968 // layer does not exist in the board editor
969 // Otherwise the parent footprint could be seriously broken especially
970 // if some layers are later re-enabled.
971 // Moreover a fp lives in a fp library, that does not know the enabled
972 // layers of a given board, so fp items are just ignored when on not
973 // enabled layers in board editor
974 returnItems.push_back( fp );
975 }
976 else if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
977 {
978 returnItems.push_back( item );
979 }
980 else
981 {
982 LSET allowed = item->GetLayerSet() & enabledLayers;
983 bool item_valid = true;
984
985 // Ensure, for vias, the top and bottom layers are compatible with
986 // the current board copper layers.
987 // Otherwise they must be skipped, even is one layer is valid
988 if( item->Type() == PCB_VIA_T )
989 item_valid = static_cast<PCB_VIA*>( item )->HasValidLayerPair(
991
992 if( allowed.any() && item_valid )
993 {
994 item->SetLayerSet( allowed );
995 returnItems.push_back( item );
996 }
997 else
998 {
999 if( PCB_GROUP* parentGroup = item->GetParentGroup() )
1000 parentGroup->RemoveItem( item );
1001 }
1002 }
1003 }
1004
1005 if( ( returnItems.size() < aItems.size() ) || fpItemDeleted )
1006 {
1007 DisplayError( m_frame, _( "Warning: some pasted items were on layers which are not "
1008 "present in the current board.\n"
1009 "These items could not be pasted.\n" ) );
1010 }
1011
1012 aItems = returnItems;
1013}
1014
1015
1016int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
1017{
1018 // The viewer frames cannot paste
1019 if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
1020 return 0;
1021
1022 bool isFootprintEditor = m_isFootprintEditor || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
1023 // The clipboard can contain two different things, an entire kicad_pcb or a single footprint
1024 if( isFootprintEditor && ( !board() || !footprint() ) )
1025 return 0;
1026
1027 // We should never get here if a modal dialog is up... but we do on MacOS.
1028 // https://gitlab.com/kicad/code/kicad/-/issues/18912
1029#ifdef __WXMAC__
1030 if( wxDialog::OSXHasModalDialogsOpen() )
1031 {
1032 wxBell();
1033 return 0;
1034 }
1035#endif
1036
1037 BOARD_COMMIT commit( frame() );
1038
1039 CLIPBOARD_IO pi;
1040 BOARD_ITEM* clipItem = pi.Parse();
1041
1042 if( !clipItem )
1043 {
1044 // When the clipboard doesn't parse, create a PCB item with the clipboard contents
1045 std::vector<BOARD_ITEM*> newItems;
1046
1047 if( std::unique_ptr<wxImage> clipImg = GetImageFromClipboard() )
1048 {
1049 auto refImg = std::make_unique<PCB_REFERENCE_IMAGE>( m_frame->GetModel() );
1050
1051 if( refImg->GetReferenceImage().SetImage( *clipImg ) )
1052 newItems.push_back( refImg.release() );
1053 }
1054 else
1055 {
1056 const wxString clipText = GetClipboardUTF8();
1057
1058 if( clipText.empty() )
1059 return 0;
1060
1061 std::unique_ptr<PCB_TEXT> item;
1062
1063 item = std::make_unique<PCB_TEXT>( m_frame->GetModel() );
1064 item->SetText( clipText );
1065
1066 newItems.push_back( item.release() );
1067 }
1068
1069 bool cancelled = !placeBoardItems( &commit, newItems, true, false, false );
1070
1071 if( cancelled )
1072 commit.Revert();
1073 else
1074 commit.Push( _( "Paste Text" ) );
1075 return 0;
1076 }
1077
1078 // If we get here, we have a parsed board/FP to paste
1079
1080 PASTE_MODE mode = PASTE_MODE::KEEP_ANNOTATIONS;
1081 bool clear_nets = false;
1082 const wxString defaultRef = wxT( "REF**" );
1083
1084 if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1085 {
1086 DIALOG_PASTE_SPECIAL dlg( m_frame, &mode, defaultRef );
1087
1088 if( clipItem->Type() != PCB_T )
1089 dlg.HideClearNets();
1090
1091 if( dlg.ShowModal() == wxID_CANCEL )
1092 return 0;
1093
1094 clear_nets = dlg.GetClearNets();
1095 }
1096
1097 if( clipItem->Type() == PCB_T )
1098 {
1099 BOARD* clipBoard = static_cast<BOARD*>( clipItem );
1100
1101 if( isFootprintEditor || clear_nets )
1102 {
1103 for( BOARD_CONNECTED_ITEM* item : clipBoard->AllConnectedItems() )
1104 item->SetNet( NETINFO_LIST::OrphanedItem() );
1105 }
1106 else
1107 {
1108 clipBoard->MapNets( m_frame->GetBoard() );
1109 }
1110 }
1111
1112 bool cancelled = false;
1113
1114 switch( clipItem->Type() )
1115 {
1116 case PCB_T:
1117 {
1118 BOARD* clipBoard = static_cast<BOARD*>( clipItem );
1119
1120 if( isFootprintEditor )
1121 {
1122 FOOTPRINT* editorFootprint = board()->GetFirstFootprint();
1123 std::vector<BOARD_ITEM*> pastedItems;
1124
1125 for( PCB_GROUP* group : clipBoard->Groups() )
1126 {
1127 group->SetParent( editorFootprint );
1128 pastedItems.push_back( group );
1129 }
1130
1131 clipBoard->RemoveAll( { PCB_GROUP_T } );
1132
1133 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
1134 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
1135
1136 for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
1137 {
1138 switch( clipDrawItem->Type() )
1139 {
1140 case PCB_TEXT_T:
1141 case PCB_TEXTBOX_T:
1142 case PCB_TABLE_T:
1143 case PCB_SHAPE_T:
1144 case PCB_DIM_ALIGNED_T:
1145 case PCB_DIM_CENTER_T:
1146 case PCB_DIM_LEADER_T:
1148 case PCB_DIM_RADIAL_T:
1149 clipDrawItem->SetParent( editorFootprint );
1150 pastedItems.push_back( clipDrawItem );
1151 break;
1152
1153 default:
1154 // Everything we *didn't* put into pastedItems is going to get nuked, so
1155 // make sure it's not still included in its parent group.
1156 if( PCB_GROUP* parentGroup = clipDrawItem->GetParentGroup() )
1157 parentGroup->RemoveItem( clipDrawItem );
1158
1159 break;
1160 }
1161 }
1162
1163 // NB: PCB_SHAPE_T actually removes everything in Drawings() (including PCB_TEXTs,
1164 // PCB_TABLES, dimensions, etc.), not just PCB_SHAPEs.)
1165 clipBoard->RemoveAll( { PCB_SHAPE_T } );
1166
1167 clipBoard->Visit(
1168 [&]( EDA_ITEM* item, void* testData )
1169 {
1170 // Anything still on the clipboard didn't get copied and needs to be
1171 // removed from the pasted groups.
1172 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
1173 PCB_GROUP* parentGroup = boardItem->GetParentGroup();
1174
1175 if( parentGroup )
1176 parentGroup->RemoveItem( boardItem );
1177
1178 return INSPECT_RESULT::CONTINUE;
1179 },
1181
1182 delete clipBoard;
1183
1184 pruneItemLayers( pastedItems );
1185
1186 cancelled = !placeBoardItems( &commit, pastedItems, true, true,
1187 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
1188 }
1189 else // isBoardEditor
1190 {
1191 // Fixup footprint component classes
1192 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
1193 {
1194 clipFootprint->ResolveComponentClassNames(
1195 board(), clipFootprint->GetTransientComponentClassNames() );
1196 clipFootprint->ClearTransientComponentClassNames();
1197 }
1198
1199 if( mode == PASTE_MODE::REMOVE_ANNOTATIONS )
1200 {
1201 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
1202 clipFootprint->SetReference( defaultRef );
1203 }
1204
1205 cancelled = !placeBoardItems( &commit, clipBoard, true,
1206 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
1207 }
1208
1209 break;
1210 }
1211
1212 case PCB_FOOTPRINT_T:
1213 {
1214 FOOTPRINT* clipFootprint = static_cast<FOOTPRINT*>( clipItem );
1215 std::vector<BOARD_ITEM*> pastedItems;
1216
1217 if( isFootprintEditor )
1218 {
1219 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
1220 delete clipFootprint;
1221 }
1222 else
1223 {
1224 if( mode == PASTE_MODE::REMOVE_ANNOTATIONS )
1225 clipFootprint->SetReference( defaultRef );
1226
1227 clipFootprint->SetParent( board() );
1228 clipFootprint->ResolveComponentClassNames(
1229 board(), clipFootprint->GetTransientComponentClassNames() );
1230 clipFootprint->ClearTransientComponentClassNames();
1231 pastedItems.push_back( clipFootprint );
1232 }
1233
1234 pruneItemLayers( pastedItems );
1235
1236 cancelled = !placeBoardItems( &commit, pastedItems, true, true,
1237 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
1238 break;
1239 }
1240
1241 default:
1242 m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
1243 break;
1244 }
1245
1246 if( cancelled )
1247 commit.Revert();
1248 else
1249 commit.Push( _( "Paste" ) );
1250
1251 return 1;
1252}
1253
1254
1256{
1257 wxString fileName;
1258
1259 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1260
1261 if( !editFrame )
1262 return 1;
1263
1264 // Pick a file to append
1265 if( !AskLoadBoardFileName( editFrame, &fileName, KICTL_KICAD_ONLY ) )
1266 return 1;
1267
1268 PCB_IO_MGR::PCB_FILE_T pluginType =
1270 IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( pluginType ) );
1271
1272 if( !pi )
1273 return 1;
1274
1275 return AppendBoard( *pi, fileName );
1276}
1277
1278
1279template<typename T>
1280static void moveUnflaggedItems( const std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
1281 bool aIsNew )
1282{
1283 std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
1284 [aIsNew]( T aItem )
1285 {
1286 bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
1287
1288 aItem->ClearFlags( SKIP_STRUCT );
1289 aItem->SetFlags( aIsNew ? IS_NEW : 0 );
1290
1291 return doCopy;
1292 } );
1293}
1294
1295
1296template<typename T>
1297static void moveUnflaggedItems( const std::vector<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
1298 bool aIsNew )
1299{
1300 std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
1301 [aIsNew]( T aItem )
1302 {
1303 bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
1304
1305 aItem->ClearFlags( SKIP_STRUCT );
1306 aItem->SetFlags( aIsNew ? IS_NEW : 0 );
1307
1308 return doCopy;
1309 } );
1310}
1311
1312
1313bool PCB_CONTROL::placeBoardItems( BOARD_COMMIT* aCommit, BOARD* aBoard, bool aAnchorAtOrigin,
1314 bool aReannotateDuplicates )
1315{
1316 // items are new if the current board is not the board source
1317 bool isNew = board() != aBoard;
1318 std::vector<BOARD_ITEM*> items;
1319
1320 moveUnflaggedItems( aBoard->Tracks(), items, isNew );
1321 moveUnflaggedItems( aBoard->Footprints(), items, isNew );
1322 moveUnflaggedItems( aBoard->Drawings(), items, isNew );
1323 moveUnflaggedItems( aBoard->Zones(), items, isNew );
1324
1325 // Subtlety: When selecting a group via the mouse,
1326 // PCB_SELECTION_TOOL::highlightInternal runs, which does a SetSelected() on all
1327 // descendants. In PCB_CONTROL::placeBoardItems, below, we skip that and
1328 // mark items non-recursively. That works because the saving of the
1329 // selection created aBoard that has the group and all descendants in it.
1330 moveUnflaggedItems( aBoard->Groups(), items, isNew );
1331
1332 moveUnflaggedItems( aBoard->Generators(), items, isNew );
1333
1334 if( isNew )
1335 aBoard->RemoveAll();
1336
1337 // Reparent before calling pruneItemLayers, as SetLayer can have a dependence on the
1338 // item's parent board being set correctly.
1339 if( isNew )
1340 {
1341 for( BOARD_ITEM* item : items )
1342 item->SetParent( board() );
1343 }
1344
1345 pruneItemLayers( items );
1346
1347 return placeBoardItems( aCommit, items, isNew, aAnchorAtOrigin, aReannotateDuplicates );
1348}
1349
1350
1351bool PCB_CONTROL::placeBoardItems( BOARD_COMMIT* aCommit, std::vector<BOARD_ITEM*>& aItems,
1352 bool aIsNew, bool aAnchorAtOrigin, bool aReannotateDuplicates )
1353{
1355
1357
1358 std::vector<BOARD_ITEM*> itemsToSel;
1359 itemsToSel.reserve( aItems.size() );
1360
1361 for( BOARD_ITEM* item : aItems )
1362 {
1363 if( aIsNew )
1364 {
1365 const_cast<KIID&>( item->m_Uuid ) = KIID();
1366
1367 item->RunOnDescendants(
1368 []( BOARD_ITEM* aChild )
1369 {
1370 const_cast<KIID&>( aChild->m_Uuid ) = KIID();
1371 } );
1372
1373 // Even though BOARD_COMMIT::Push() will add any new items to the group, we're
1374 // going to run PCB_ACTIONS::move first, and the move tool will throw out any
1375 // items that aren't in the entered group.
1376 if( selectionTool->GetEnteredGroup() && !item->GetParentGroup() )
1377 selectionTool->GetEnteredGroup()->AddItem( item );
1378
1379 item->SetParent( board() );
1380 }
1381
1382 // Update item attributes if needed
1383 if( BaseType( item->Type() ) == PCB_DIMENSION_T )
1384 {
1385 static_cast<PCB_DIMENSION_BASE*>( item )->UpdateUnits();
1386 }
1387 else if( item->Type() == PCB_FOOTPRINT_T )
1388 {
1389 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
1390
1391 // Update the footprint path with the new KIID path if the footprint is new
1392 if( aIsNew )
1394
1395 for( BOARD_ITEM* dwg : footprint->GraphicalItems() )
1396 {
1397 if( BaseType( dwg->Type() ) == PCB_DIMENSION_T )
1398 static_cast<PCB_DIMENSION_BASE*>( dwg )->UpdateUnits();
1399 }
1400 }
1401
1402 // We only need to add the items that aren't inside a group currently selected
1403 // to the selection. If an item is inside a group and that group is selected,
1404 // then the selection tool will select it for us.
1405 if( !item->GetParentGroup() || !alg::contains( aItems, item->GetParentGroup() ) )
1406 itemsToSel.push_back( item );
1407 }
1408
1409 // Select the items that should be selected
1410 EDA_ITEMS toSel( itemsToSel.begin(), itemsToSel.end() );
1412
1413 // Reannotate duplicate footprints (make sense only in board editor )
1414 if( aReannotateDuplicates && m_isBoardEditor )
1415 m_toolMgr->GetTool<BOARD_REANNOTATE_TOOL>()->ReannotateDuplicatesInSelection();
1416
1417 for( BOARD_ITEM* item : aItems )
1418 {
1419 if( aIsNew )
1420 aCommit->Add( item );
1421 else
1422 aCommit->Added( item );
1423 }
1424
1425 PCB_SELECTION& selection = selectionTool->GetSelection();
1426
1427 if( selection.Size() > 0 )
1428 {
1429 if( aAnchorAtOrigin )
1430 {
1432 }
1433 else
1434 {
1435 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
1437 }
1438
1439 getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
1440
1442
1444 }
1445
1446 return true;
1447}
1448
1449
1450int PCB_CONTROL::AppendBoard( PCB_IO& pi, wxString& fileName )
1451{
1452 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1453
1454 if( !editFrame )
1455 return 1;
1456
1457 BOARD* brd = board();
1458
1459 if( !brd )
1460 return 1;
1461
1462 BOARD_COMMIT commit( editFrame );
1463
1464 // Mark existing items, in order to know what are the new items so we can select only
1465 // the new items after loading
1466 for( PCB_TRACK* track : brd->Tracks() )
1467 track->SetFlags( SKIP_STRUCT );
1468
1469 for( FOOTPRINT* footprint : brd->Footprints() )
1471
1472 for( PCB_GROUP* group : brd->Groups() )
1473 group->SetFlags( SKIP_STRUCT );
1474
1475 for( BOARD_ITEM* drawing : brd->Drawings() )
1476 drawing->SetFlags( SKIP_STRUCT );
1477
1478 for( ZONE* zone : brd->Zones() )
1479 zone->SetFlags( SKIP_STRUCT );
1480
1481 for( PCB_GENERATOR* generator : brd->Generators() )
1482 generator->SetFlags( SKIP_STRUCT );
1483
1484 std::map<wxString, wxString> oldProperties = brd->GetProperties();
1485 std::map<wxString, wxString> newProperties;
1486
1487 PAGE_INFO oldPageInfo = brd->GetPageSettings();
1488 TITLE_BLOCK oldTitleBlock = brd->GetTitleBlock();
1489
1490 // Keep also the count of copper layers, to adjust if necessary
1491 int initialCopperLayerCount = brd->GetCopperLayerCount();
1492 LSET initialEnabledLayers = brd->GetEnabledLayers();
1493
1494 // Load the data
1495 try
1496 {
1497 std::map<std::string, UTF8> props;
1498
1499 // PCB_IO_EAGLE can use this info to center the BOARD, but it does not yet.
1500
1501 props["page_width"] = std::to_string( editFrame->GetPageSizeIU().x );
1502 props["page_height"] = std::to_string( editFrame->GetPageSizeIU().y );
1503
1505 [&]( wxString aTitle, int aIcon, wxString aMessage, wxString aAction ) -> bool
1506 {
1507 KIDIALOG dlg( editFrame, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
1508
1509 if( !aAction.IsEmpty() )
1510 dlg.SetOKLabel( aAction );
1511
1512 dlg.DoNotShowCheckbox( aMessage, 0 );
1513
1514 return dlg.ShowModal() == wxID_OK;
1515 } );
1516
1517 WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Loading PCB" ), 1 );
1518
1519 editFrame->GetDesignSettings().m_NetSettings->ClearNetclasses();
1520 pi.SetProgressReporter( &progressReporter );
1521 pi.LoadBoard( fileName, brd, &props, nullptr );
1522 }
1523 catch( const IO_ERROR& ioe )
1524 {
1525 DisplayErrorMessage( editFrame, _( "Error loading board." ), ioe.What() );
1526
1527 return 0;
1528 }
1529
1530 newProperties = brd->GetProperties();
1531
1532 for( const std::pair<const wxString, wxString>& prop : oldProperties )
1533 newProperties[ prop.first ] = prop.second;
1534
1535 brd->SetProperties( newProperties );
1536
1537 brd->SetPageSettings( oldPageInfo );
1538 brd->SetTitleBlock( oldTitleBlock );
1539
1540 // rebuild nets and ratsnest before any use of nets
1541 brd->BuildListOfNets();
1542 brd->SynchronizeNetsAndNetClasses( true );
1543 brd->BuildConnectivity();
1544
1545 // Synchronize layers
1546 // we should not ask PLUGINs to do these items:
1547 int copperLayerCount = brd->GetCopperLayerCount();
1548
1549 if( copperLayerCount > initialCopperLayerCount )
1550 brd->SetCopperLayerCount( copperLayerCount );
1551
1552 // Enable all used layers, and make them visible:
1553 LSET enabledLayers = brd->GetEnabledLayers();
1554 enabledLayers |= initialEnabledLayers;
1555 brd->SetEnabledLayers( enabledLayers );
1556 brd->SetVisibleLayers( enabledLayers );
1557
1558 if( placeBoardItems( &commit, brd, false, false /* Don't reannotate dupes on Append Board */ ) )
1559 commit.Push( _( "Append Board" ) );
1560 else
1561 commit.Revert();
1562
1563 // Refresh the UI for the updated board properties
1564 editFrame->GetAppearancePanel()->OnBoardChanged();
1565
1566 return 0;
1567}
1568
1569
1570int PCB_CONTROL::Undo( const TOOL_EVENT& aEvent )
1571{
1572 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1573 wxCommandEvent dummy;
1574
1575 if( editFrame )
1576 editFrame->RestoreCopyFromUndoList( dummy );
1577
1578 return 0;
1579}
1580
1581
1582int PCB_CONTROL::Redo( const TOOL_EVENT& aEvent )
1583{
1584 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1585 wxCommandEvent dummy;
1586
1587 if( editFrame )
1588 editFrame->RestoreCopyFromRedoList( dummy );
1589
1590 return 0;
1591}
1592
1593
1595{
1599 bool& snapMode = settings.allLayers;
1600
1602 snapMode = false;
1603 else if( aEvent.IsAction( &PCB_ACTIONS::magneticSnapAllLayers ) )
1604 snapMode = true;
1605 else
1606 snapMode = !snapMode;
1607
1609
1610 return 0;
1611}
1612
1613
1615{
1616 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
1617 return 0;
1618
1619 wxArrayString labels;
1620 labels.Add( _( "Active Layer" ) );
1621 labels.Add( _( "All Layers" ) );
1622
1623 if( !m_frame->GetHotkeyPopup() )
1625
1627
1631
1632 if( popup )
1633 popup->Popup( _( "Object Snapping" ), labels, static_cast<int>( settings.allLayers ) );
1634
1635 return 0;
1636}
1637
1638
1640{
1642 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
1643 PCB_SELECTION& selection = selTool->GetSelection();
1644 PCB_EDIT_FRAME* pcbFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1645 std::shared_ptr<DRC_ENGINE> drcEngine = m_frame->GetBoard()->GetDesignSettings().m_DRCEngine;
1646 DRC_CONSTRAINT constraint;
1647
1648 std::vector<MSG_PANEL_ITEM> msgItems;
1649
1650 if( routerTool && routerTool->RoutingInProgress() )
1651 {
1652 routerTool->UpdateMessagePanel();
1653 return 0;
1654 }
1655
1656 if( !pcbFrame && !m_frame->GetModel() )
1657 return 0;
1658
1659 if( selection.Empty() )
1660 {
1661 if( !pcbFrame )
1662 {
1663 FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_frame->GetModel() );
1664 fp->GetMsgPanelInfo( m_frame, msgItems );
1665 }
1666 else
1667 {
1669 }
1670 }
1671 else if( selection.GetSize() == 1 )
1672 {
1673 EDA_ITEM* item = selection.Front();
1674
1675 if( std::optional<wxString> uuid = GetMsgPanelDisplayUuid( item->m_Uuid ) )
1676 msgItems.emplace_back( _( "UUID" ), *uuid );
1677
1678 item->GetMsgPanelInfo( m_frame, msgItems );
1679
1680 PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item );
1681 NETINFO_ITEM* net = track ? track->GetNet() : nullptr;
1682 NETINFO_ITEM* coupledNet = net ? m_frame->GetBoard()->DpCoupledNet( net ) : nullptr;
1683
1684 if( coupledNet )
1685 {
1686 SEG trackSeg( track->GetStart(), track->GetEnd() );
1687 PCB_TRACK* coupledItem = nullptr;
1688 SEG::ecoord closestDist_sq = VECTOR2I::ECOORD_MAX;
1689
1690 for( PCB_TRACK* candidate : m_frame->GetBoard()->Tracks() )
1691 {
1692 if( candidate->GetNet() != coupledNet )
1693 continue;
1694
1695 SEG::ecoord dist_sq = trackSeg.SquaredDistance( SEG( candidate->GetStart(),
1696 candidate->GetEnd() ) );
1697
1698 if( !coupledItem || dist_sq < closestDist_sq )
1699 {
1700 coupledItem = candidate;
1701 closestDist_sq = dist_sq;
1702 }
1703 }
1704
1705 constraint = drcEngine->EvalRules( DIFF_PAIR_GAP_CONSTRAINT, track, coupledItem,
1706 track->GetLayer() );
1707
1708 wxString msg = m_frame->MessageTextFromMinOptMax( constraint.Value() );
1709
1710 if( !msg.IsEmpty() )
1711 {
1712 msgItems.emplace_back( wxString::Format( _( "DP Gap Constraints: %s" ), msg ),
1713 wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
1714 }
1715
1716 constraint = drcEngine->EvalRules( MAX_UNCOUPLED_CONSTRAINT, track,
1717 coupledItem, track->GetLayer() );
1718
1719 if( constraint.Value().HasMax() )
1720 {
1721 msg = m_frame->MessageTextFromValue( constraint.Value().Max() );
1722 msgItems.emplace_back( wxString::Format( _( "DP Max Uncoupled-length: %s" ), msg ),
1723 wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
1724 }
1725 }
1726 }
1727 else if( pcbFrame && selection.GetSize() == 2 )
1728 {
1729 // Pair selection broken into multiple, optional data, starting with the selected item
1730 // names
1731
1732 BOARD_ITEM* a = static_cast<BOARD_ITEM*>( selection[0] );
1733 BOARD_ITEM* b = static_cast<BOARD_ITEM*>( selection[1] );
1734
1735 msgItems.emplace_back( MSG_PANEL_ITEM( a->GetItemDescription( m_frame, false ),
1736 b->GetItemDescription( m_frame, false ) ) );
1737
1738 BOARD_CONNECTED_ITEM* a_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( a );
1739 BOARD_CONNECTED_ITEM* b_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( b );
1740
1741 if( a_conn && b_conn )
1742 {
1743 LSET overlap = a_conn->GetLayerSet() & b_conn->GetLayerSet() & LSET::AllCuMask();
1744 int a_netcode = a_conn->GetNetCode();
1745 int b_netcode = b_conn->GetNetCode();
1746
1747 if( overlap.count() > 0
1748 && ( a_netcode != b_netcode || a_netcode < 0 || b_netcode < 0 ) )
1749 {
1750 PCB_LAYER_ID layer = overlap.CuStack().front();
1751
1752 constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b, layer );
1753 msgItems.emplace_back( _( "Resolved clearance" ),
1754 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1755
1756 std::shared_ptr<SHAPE> a_shape( a_conn->GetEffectiveShape( layer ) );
1757 std::shared_ptr<SHAPE> b_shape( b_conn->GetEffectiveShape( layer ) );
1758
1759 int actual_clearance = a_shape->GetClearance( b_shape.get() );
1760
1761 if( actual_clearance > -1 && actual_clearance < std::numeric_limits<int>::max() )
1762 {
1763 msgItems.emplace_back( _( "Actual clearance" ),
1764 m_frame->MessageTextFromValue( actual_clearance ) );
1765 }
1766 }
1767 }
1768
1769 if( ( a->HasHole() || b->HasHole() ) )
1770 {
1773
1774 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1775 layer = active;
1776 else if( b->HasHole() && a->IsOnLayer( active ) && IsCopperLayer( active ) )
1777 layer = active;
1778 else if( a->HasHole() && b->IsOnCopperLayer() )
1779 layer = b->GetLayer();
1780 else if( b->HasHole() && a->IsOnCopperLayer() )
1781 layer = a->GetLayer();
1782
1783 if( IsCopperLayer( layer ) )
1784 {
1785 int actual = std::numeric_limits<int>::max();
1786
1787 if( a->HasHole() && b->IsOnCopperLayer() )
1788 {
1789 std::shared_ptr<SHAPE_SEGMENT> hole = a->GetEffectiveHoleShape();
1790 std::shared_ptr<SHAPE> other( b->GetEffectiveShape( layer ) );
1791
1792 actual = std::min( actual, hole->GetClearance( other.get() ) );
1793 }
1794
1795 if( b->HasHole() && a->IsOnCopperLayer() )
1796 {
1797 std::shared_ptr<SHAPE_SEGMENT> hole = b->GetEffectiveHoleShape();
1798 std::shared_ptr<SHAPE> other( a->GetEffectiveShape( layer ) );
1799
1800 actual = std::min( actual, hole->GetClearance( other.get() ) );
1801 }
1802
1803 if( actual < std::numeric_limits<int>::max() )
1804 {
1805 constraint = drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, a, b, layer );
1806 msgItems.emplace_back( _( "Resolved hole clearance" ),
1807 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1808
1809 if( actual > -1 && actual < std::numeric_limits<int>::max() )
1810 {
1811 msgItems.emplace_back( _( "Actual hole clearance" ),
1813 }
1814 }
1815 }
1816 }
1817
1818 for( PCB_LAYER_ID edgeLayer : { Edge_Cuts, Margin } )
1819 {
1822
1823 if( a->IsOnLayer( edgeLayer ) && b->Type() != PCB_FOOTPRINT_T )
1824 {
1825 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1826 layer = active;
1827 else if( IsCopperLayer( b->GetLayer() ) )
1828 layer = b->GetLayer();
1829 }
1830 else if( b->IsOnLayer( edgeLayer ) && a->Type() != PCB_FOOTPRINT_T )
1831 {
1832 if( a->IsOnLayer( active ) && IsCopperLayer( active ) )
1833 layer = active;
1834 else if( IsCopperLayer( a->GetLayer() ) )
1835 layer = a->GetLayer();
1836 }
1837
1838 if( layer >= 0 )
1839 {
1840 constraint = drcEngine->EvalRules( EDGE_CLEARANCE_CONSTRAINT, a, b, layer );
1841
1842 if( edgeLayer == Edge_Cuts )
1843 {
1844 msgItems.emplace_back( _( "Resolved edge clearance" ),
1845 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1846 }
1847 else
1848 {
1849 msgItems.emplace_back( _( "Resolved margin clearance" ),
1850 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1851 }
1852 }
1853 }
1854 }
1855
1856 if( selection.GetSize() )
1857 {
1858 if( msgItems.empty() )
1859 {
1860 msgItems.emplace_back( _( "Selected Items" ),
1861 wxString::Format( wxT( "%d" ), selection.GetSize() ) );
1862
1863 if( m_isBoardEditor )
1864 {
1865 std::set<wxString> netNames;
1866 std::set<wxString> netClasses;
1867
1868 for( EDA_ITEM* item : selection )
1869 {
1870 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
1871 {
1872 netNames.insert( UnescapeString( bci->GetNetname() ) );
1873 netClasses.insert( UnescapeString(
1874 bci->GetEffectiveNetClass()->GetHumanReadableName() ) );
1875
1876 if( netNames.size() > 1 && netClasses.size() > 1 )
1877 break;
1878 }
1879 }
1880
1881 if( netNames.size() == 1 )
1882 msgItems.emplace_back( _( "Net" ), *netNames.begin() );
1883
1884 if( netClasses.size() == 1 )
1885 msgItems.emplace_back( _( "Resolved Netclass" ), *netClasses.begin() );
1886 }
1887 }
1888
1889 if( selection.GetSize() >= 2 )
1890 {
1891 bool lengthValid = true;
1892 double selectedLength = 0;
1893
1894 // Lambda to accumulate track length if item is a track or arc, otherwise mark invalid
1895 std::function<void( EDA_ITEM* )> accumulateTrackLength;
1896
1897 accumulateTrackLength = [&]( EDA_ITEM* aItem )
1898 {
1899 if( PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( aItem ) )
1900 {
1901 selectedLength += track->GetLength();
1902 }
1903 else if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
1904 {
1905 const SHAPE_T shapeType = shape->GetShape();
1906 if( shapeType == SHAPE_T::SEGMENT || shapeType == SHAPE_T::ARC
1907 || shapeType == SHAPE_T::BEZIER )
1908 {
1909 selectedLength += shape->GetLength();
1910 }
1911 else
1912 {
1913 lengthValid = false;
1914 }
1915 }
1916 else if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( aItem ) )
1917 {
1918 group->RunOnChildren( accumulateTrackLength );
1919 }
1920 else
1921 {
1922 lengthValid = false;
1923 }
1924 };
1925
1926 for( EDA_ITEM* item : selection )
1927 accumulateTrackLength( item );
1928
1929 if( lengthValid )
1930 {
1931 msgItems.emplace_back( _( "Selected 2D Length" ),
1932 m_frame->MessageTextFromValue( selectedLength ) );
1933 }
1934 }
1935 }
1936 else
1937 {
1938 m_frame->GetBoard()->GetMsgPanelInfo( m_frame, msgItems );
1939 }
1940
1941 m_frame->SetMsgPanel( msgItems );
1942
1943 return 0;
1944}
1945
1946
1948{
1949 wxFileName fileName = wxFileName( *aEvent.Parameter<wxString*>() );
1950
1951 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1952
1953 if( !editFrame )
1954 return 1;
1955
1956 wxString filePath = fileName.GetFullPath();
1958 IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( pluginType ) );
1959
1960 if( !pi )
1961 return 1;
1962
1963 return AppendBoard( *pi, filePath );
1964}
1965
1966
1968{
1969 view()->SetMirror( !view()->IsMirroredX(), false );
1970 view()->RecacheAllItems();
1971 frame()->GetCanvas()->ForceRefresh();
1972 frame()->OnDisplayOptionsChanged();
1973 return 0;
1974}
1975
1976// clang-format off
1978{
1981 Go( &PCB_CONTROL::Print, ACTIONS::print.MakeEvent() );
1982 Go( &PCB_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1983
1984 // Display modes
2000
2001 // Layer control
2039
2042
2043 // Grid control
2046
2047 Go( &PCB_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
2048 Go( &PCB_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
2049
2050 // Snapping control
2055
2056 // Miscellaneous
2058
2059 // Append control
2062
2063 Go( &PCB_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
2065
2072
2073 // Add library by dropping file
2076}
2077// 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
Execute the changes.
virtual void Revert() override
Revert the commit by restoring the modified items state.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
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:239
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:321
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:259
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:295
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:1826
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:831
NETINFO_ITEM * DpCoupledNet(const NETINFO_ITEM *aNet)
Definition: board.cpp:2046
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:2701
void BuildListOfNets()
Definition: board.h:845
const GENERATORS & Generators() const
Definition: board.h:342
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
Definition: board.cpp:2675
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:851
const PAGE_INFO & GetPageSettings() const
Definition: board.h:700
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: board.h:368
const ZONES & Zones() const
Definition: board.h:340
const GROUPS & Groups() const
The groups must maintain the following invariants.
Definition: board.h:363
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:190
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:2108
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:456
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:706
int GetCopperLayerCount() const
Definition: board.cpp:783
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:367
const FOOTPRINTS & Footprints() const
Definition: board.h:336
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:1301
const TRACKS & Tracks() const
Definition: board.h:334
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:701
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:863
void SetCopperLayerCount(int aCount)
Definition: board.cpp:789
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:837
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:1788
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:948
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:708
const DRAWINGS & Drawings() const
Definition: board.h:338
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)
Notify observers that aItem has been added.
Definition: commit.h:86
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
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 ForceRefresh()
Force a redraw.
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:244
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:245
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:490
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:204
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:2449
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:225
ZONES & Zones()
Definition: footprint.h:210
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:262
std::deque< PAD * > & Pads()
Definition: footprint.h:204
void ResolveComponentClassNames(BOARD *aBoard, const std::unordered_set< wxString > &aComponentClassNames)
Resolves a set of component class names to this footprint's actual component class.
Definition: footprint.cpp:4038
const std::unordered_set< wxString > & GetTransientComponentClassNames()
Gets the transient component class names.
Definition: footprint.h:1039
void SetReference(const wxString &aReference)
Definition: footprint.h:626
void ClearTransientComponentClassNames()
Remove the transient component class names.
Definition: footprint.h:1045
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:1651
GROUPS & Groups()
Definition: footprint.h:213
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly) const
Populate a std::vector with PCB_TEXTs.
Definition: footprint.cpp:657
DRAWINGS & GraphicalItems()
Definition: footprint.h:207
void ClearFields()
Clears all fields from the footprint.
Definition: footprint.h:721
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:89
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)
Shows the 'do not show again' checkbox.
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:67
void SetMirror(bool aMirrorX, bool aMirrorY)
Control the mirroring of the VIEW.
Definition: view.cpp:547
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:297
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:332
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:198
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1439
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:655
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:37
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
Definition: lset.cpp:703
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
Definition: lset.cpp:247
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:564
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
Return the BOARD_DESIGN_SETTINGS for the open project.
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Update the current display options.
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:97
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.
static const TOOL_EVENT & LayerPairPresetChangedByKeyEvent()
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:91
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:689
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:178
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:44
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:38
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
@ REDRAW
Full drawing refresh.
Definition: tool_base.h:83
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition: tool_base.h:80
@ GAL_SWITCH
Rendering engine changes.
Definition: tool_base.h:82
Generic, UI-independent tool event.
Definition: tool_event.h:168
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:82
T Parameter() const
Return a parameter assigned to the event.
Definition: tool_event.h:465
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
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:351
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:307
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:538
#define SKIP_STRUCT
flag indicating that the structure should be ignored
SHAPE_T
Definition: eda_shape.h:43
#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)
Return a netname layer corresponding to the given layer.
Definition: layer_ids.h:794
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition: layer_ids.h:618
@ LAYER_RATSNEST
Definition: layer_ids.h:252
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:358
std::optional< wxString > GetMsgPanelDisplayUuid(const KIID &aKiid)
Get a formatted UUID string for display in the message panel, according to the current advanced confi...
Definition: msgpanel.cpp:245
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:58
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:1073
see class PGM_BASE
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
int actual
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:695
Definition of file extensions used in Kicad.