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 }
578 else
579 {
580 wxBell();
581 }
582
583 return 0;
584}
585
586
588{
590 int currentLayer = m_frame->GetActiveLayer();
591 KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
592
593 if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
594 {
595 currentColor.a -= ALPHA_STEP;
596 settings->SetColor( currentLayer, currentColor );
598
600 view->UpdateLayerColor( currentLayer );
601 view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
602
603 if( IsCopperLayer( currentLayer ) )
604 view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
605 }
606 else
607 {
608 wxBell();
609 }
610
611 return 0;
612}
613
614
616{
617 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
618
619 if( !editFrame )
620 return 0;
621
622 LAYER_PAIR_SETTINGS* settings = editFrame->GetLayerPairSettings();
623
624 if( !settings )
625 return 0;
626
627 int currentIndex;
628 std::vector<LAYER_PAIR_INFO> presets = settings->GetEnabledLayerPairs( currentIndex );
629
630 if( presets.size() < 2 )
631 return 0;
632
633 if( currentIndex < 0 )
634 {
635 wxASSERT_MSG( false, "Current layer pair not found in layer settings" );
636 currentIndex = 0;
637 }
638
639 const int nextIndex = ( currentIndex + 1 ) % presets.size();
640 const LAYER_PAIR& nextPair = presets[nextIndex].GetLayerPair();
641
642 settings->SetCurrentLayerPair( nextPair );
643
645 return 0;
646}
647
648
650{
651 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
652 return 0;
653
654 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
655
656 if( !editFrame )
657 return 0;
658
659 LAYER_PAIR_SETTINGS* settings = editFrame->GetLayerPairSettings();
660
661 if( !settings )
662 return 0;
663
664 PCB_LAYER_PRESENTATION layerPresentation( editFrame );
665
666 int currentIndex;
667 std::vector<LAYER_PAIR_INFO> presets = settings->GetEnabledLayerPairs( currentIndex );
668
669 wxArrayString labels;
670 for( const LAYER_PAIR_INFO& layerPairInfo : presets )
671 {
672 wxString label = layerPresentation.getLayerPairName( layerPairInfo.GetLayerPair() );
673
674 if( layerPairInfo.GetName() )
675 {
676 label += wxT( " (" ) + *layerPairInfo.GetName() + wxT( ")" );
677 }
678
679 labels.Add( label );
680 }
681
682 if( !editFrame->GetHotkeyPopup() )
683 editFrame->CreateHotkeyPopup();
684
685 HOTKEY_CYCLE_POPUP* popup = editFrame->GetHotkeyPopup();
686
687 if( popup )
688 {
689 int selection = currentIndex;
690 popup->Popup( _( "Preset Layer Pairs" ), labels, selection );
691 }
692
693 return 0;
694}
695
696
698 EDA_ITEM* originViewItem, const VECTOR2D& aPoint )
699{
700 aFrame->GetDesignSettings().SetGridOrigin( VECTOR2I( aPoint ) );
701 aView->GetGAL()->SetGridOrigin( aPoint );
702 originViewItem->SetPosition( aPoint );
703 aView->MarkDirty();
704 aFrame->OnModify();
705}
706
707
709{
710 VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
711
712 if( origin )
713 {
714 // We can't undo the other grid dialog settings, so no sense undoing just the origin
715 DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
716 delete origin;
717 }
718 else
719 {
720 if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
721 return 0;
722
724
725 if( !picker ) // Happens in footprint wizard
726 return 0;
727
728 // Deactivate other tools; particularly important if another PICKER is currently running
729 Activate();
730
731 picker->SetClickHandler(
732 [this]( const VECTOR2D& pt ) -> bool
733 {
734 m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
736 return false; // drill origin is a one-shot; don't continue with tool
737 } );
738
740 }
741
742 return 0;
743}
744
745
747{
748 m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
750 return 0;
751}
752
753
754#define HITTEST_THRESHOLD_PIXELS 5
755
756
758{
760 return 0;
761
763
764 m_pickerItem = nullptr;
766
767 // Deactivate other tools; particularly important if another PICKER is currently running
768 Activate();
769
770 picker->SetCursor( KICURSOR::REMOVE );
771
772 picker->SetClickHandler(
773 [this]( const VECTOR2D& aPosition ) -> bool
774 {
775 if( m_pickerItem )
776 {
778 {
779 m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
780 m_statusPopup->SetText( _( "Item locked." ) );
781 m_statusPopup->PopupFor( 2000 );
782 m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition()
783 + wxPoint( 20, 20 ) );
784 return true;
785 }
786
788 selectionTool->UnbrightenItem( m_pickerItem );
789
790 PCB_SELECTION items;
791 items.Add( m_pickerItem );
792
793 EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
794 editTool->DeleteItems( items, false );
795
796 m_pickerItem = nullptr;
797 }
798
799 return true;
800 } );
801
802 picker->SetMotionHandler(
803 [this]( const VECTOR2D& aPos )
804 {
808 GENERAL_COLLECTOR collector;
809 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
810
812 collector.Collect( board, GENERAL_COLLECTOR::FootprintItems, aPos, guide );
813 else
814 collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, aPos, guide );
815
816 // Remove unselectable items
817 for( int i = collector.GetCount() - 1; i >= 0; --i )
818 {
819 if( !selectionTool->Selectable( collector[ i ] ) )
820 collector.Remove( i );
821 }
822
823 selectionTool->FilterCollectorForHierarchy( collector, false );
824 selectionTool->FilterCollectedItems( collector, false );
825
826 if( collector.GetCount() > 1 )
827 selectionTool->GuessSelectionCandidates( collector, aPos );
828
829 BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
830
831 if( m_pickerItem != item )
832 {
833 if( m_pickerItem )
834 selectionTool->UnbrightenItem( m_pickerItem );
835
836 m_pickerItem = item;
837
838 if( m_pickerItem )
839 selectionTool->BrightenItem( m_pickerItem );
840 }
841 } );
842
843 picker->SetFinalizeHandler(
844 [this]( const int& aFinalState )
845 {
846 if( m_pickerItem )
847 m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
848
849 m_statusPopup.reset();
850
851 // Ensure the cursor gets changed&updated
852 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
854 } );
855
857
858 return 0;
859}
860
861
862static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBoard,
863 std::vector<BOARD_ITEM*>& aPastedItems )
864{
865 FOOTPRINT* editorFootprint = aBoard->GetFirstFootprint();
866
867 aClipFootprint->SetParent( aBoard );
868
869 for( PAD* pad : aClipFootprint->Pads() )
870 {
871 pad->SetParent( editorFootprint );
872 aPastedItems.push_back( pad );
873 }
874
875 aClipFootprint->Pads().clear();
876
877 // Not all items can be added to the current footprint: mandatory fields are already existing
878 // in the current footprint.
879 //
880 for( PCB_FIELD* field : aClipFootprint->GetFields() )
881 {
882 if( field->IsMandatoryField() )
883 {
884 if( PCB_GROUP* parentGroup = field->GetParentGroup() )
885 parentGroup->RemoveItem( field );
886 }
887 else
888 {
889 PCB_TEXT* text = static_cast<PCB_TEXT*>( field );
890
891 text->SetTextAngle( text->GetTextAngle() - aClipFootprint->GetOrientation() );
892 text->SetTextAngle( text->GetTextAngle() + editorFootprint->GetOrientation() );
893
894 VECTOR2I pos = field->GetFPRelativePosition();
895 field->SetParent( editorFootprint );
896 field->SetFPRelativePosition( pos );
897
898 aPastedItems.push_back( field );
899 }
900 }
901
902 aClipFootprint->ClearFields();
903
904 for( BOARD_ITEM* item : aClipFootprint->GraphicalItems() )
905 {
906 if( item->Type() == PCB_TEXT_T )
907 {
908 PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
909
910 text->SetTextAngle( text->GetTextAngle() - aClipFootprint->GetOrientation() );
911 text->SetTextAngle( text->GetTextAngle() + editorFootprint->GetOrientation() );
912 }
913
914 item->Rotate( item->GetPosition(), -aClipFootprint->GetOrientation() );
915 item->Rotate( item->GetPosition(), editorFootprint->GetOrientation() );
916
917 VECTOR2I pos = item->GetFPRelativePosition();
918 item->SetParent( editorFootprint );
919 item->SetFPRelativePosition( pos );
920
921 aPastedItems.push_back( item );
922 }
923
924 aClipFootprint->GraphicalItems().clear();
925
926 for( ZONE* zone : aClipFootprint->Zones() )
927 {
928 zone->SetParent( editorFootprint );
929 aPastedItems.push_back( zone );
930 }
931
932 aClipFootprint->Zones().clear();
933
934 for( PCB_GROUP* group : aClipFootprint->Groups() )
935 {
936 group->SetParent( editorFootprint );
937 aPastedItems.push_back( group );
938 }
939
940 aClipFootprint->Groups().clear();
941}
942
943
944void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
945{
946 // Do not prune items or layers when copying to the FP editor, because all
947 // layers are accepted, even if they are not enabled in the dummy board
948 // This is mainly true for internal copper layers: all are allowed but only one
949 // (In1.cu) is enabled for the GUI.
951 return;
952
953 LSET enabledLayers = board()->GetEnabledLayers();
954 std::vector<BOARD_ITEM*> returnItems;
955 bool fpItemDeleted = false;
956
957 for( BOARD_ITEM* item : aItems )
958 {
959 if( item->Type() == PCB_FOOTPRINT_T )
960 {
961 FOOTPRINT* fp = static_cast<FOOTPRINT*>( item );
962
963 // Items living in a parent footprint are never removed, even if their
964 // layer does not exist in the board editor
965 // Otherwise the parent footprint could be seriously broken especially
966 // if some layers are later re-enabled.
967 // Moreover a fp lives in a fp library, that does not know the enabled
968 // layers of a given board, so fp items are just ignored when on not
969 // enabled layers in board editor
970 returnItems.push_back( fp );
971 }
972 else if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
973 {
974 returnItems.push_back( item );
975 }
976 else
977 {
978 LSET allowed = item->GetLayerSet() & enabledLayers;
979 bool item_valid = true;
980
981 // Ensure, for vias, the top and bottom layers are compatible with
982 // the current board copper layers.
983 // Otherwise they must be skipped, even is one layer is valid
984 if( item->Type() == PCB_VIA_T )
985 item_valid = static_cast<PCB_VIA*>( item )->HasValidLayerPair(
987
988 if( allowed.any() && item_valid )
989 {
990 item->SetLayerSet( allowed );
991 returnItems.push_back( item );
992 }
993 else
994 {
995 if( PCB_GROUP* parentGroup = item->GetParentGroup() )
996 parentGroup->RemoveItem( item );
997 }
998 }
999 }
1000
1001 if( ( returnItems.size() < aItems.size() ) || fpItemDeleted )
1002 {
1003 DisplayError( m_frame, _( "Warning: some pasted items were on layers which are not "
1004 "present in the current board.\n"
1005 "These items could not be pasted.\n" ) );
1006 }
1007
1008 aItems = returnItems;
1009}
1010
1011
1012int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
1013{
1014 // The viewer frames cannot paste
1015 if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
1016 return 0;
1017
1018 bool isFootprintEditor = m_isFootprintEditor || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
1019 // The clipboard can contain two different things, an entire kicad_pcb or a single footprint
1020 if( isFootprintEditor && ( !board() || !footprint() ) )
1021 return 0;
1022
1023 // We should never get here if a modal dialog is up... but we do on MacOS.
1024 // https://gitlab.com/kicad/code/kicad/-/issues/18912
1025#ifdef __WXMAC__
1026 if( wxDialog::OSXHasModalDialogsOpen() )
1027 {
1028 wxBell();
1029 return 0;
1030 }
1031#endif
1032
1033 BOARD_COMMIT commit( frame() );
1034
1035 CLIPBOARD_IO pi;
1036 BOARD_ITEM* clipItem = pi.Parse();
1037
1038 if( !clipItem )
1039 {
1040 // When the clipboard doesn't parse, create a PCB item with the clipboard contents
1041 std::vector<BOARD_ITEM*> newItems;
1042
1043 if( std::unique_ptr<wxImage> clipImg = GetImageFromClipboard() )
1044 {
1045 auto refImg = std::make_unique<PCB_REFERENCE_IMAGE>( m_frame->GetModel() );
1046
1047 if( refImg->GetReferenceImage().SetImage( *clipImg ) )
1048 newItems.push_back( refImg.release() );
1049 }
1050 else
1051 {
1052 const wxString clipText = GetClipboardUTF8();
1053
1054 if( clipText.empty() )
1055 return 0;
1056
1057 std::unique_ptr<PCB_TEXT> item;
1058
1059 item = std::make_unique<PCB_TEXT>( m_frame->GetModel() );
1060 item->SetText( clipText );
1061
1062 newItems.push_back( item.release() );
1063 }
1064
1065 bool cancelled = !placeBoardItems( &commit, newItems, true, false, false );
1066
1067 if( cancelled )
1068 commit.Revert();
1069 else
1070 commit.Push( _( "Paste Text" ) );
1071 return 0;
1072 }
1073
1074 // If we get here, we have a parsed board/FP to paste
1075
1076 PASTE_MODE mode = PASTE_MODE::KEEP_ANNOTATIONS;
1077 bool clear_nets = false;
1078 const wxString defaultRef = wxT( "REF**" );
1079
1080 if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1081 {
1082 DIALOG_PASTE_SPECIAL dlg( m_frame, &mode, defaultRef );
1083
1084 if( clipItem->Type() != PCB_T )
1085 dlg.HideClearNets();
1086
1087 if( dlg.ShowModal() == wxID_CANCEL )
1088 return 0;
1089
1090 clear_nets = dlg.GetClearNets();
1091 }
1092
1093 if( clipItem->Type() == PCB_T )
1094 {
1095 BOARD* clipBoard = static_cast<BOARD*>( clipItem );
1096
1097 if( isFootprintEditor || clear_nets )
1098 {
1099 for( BOARD_CONNECTED_ITEM* item : clipBoard->AllConnectedItems() )
1100 item->SetNet( NETINFO_LIST::OrphanedItem() );
1101 }
1102 else
1103 {
1104 clipBoard->MapNets( m_frame->GetBoard() );
1105 }
1106 }
1107
1108 bool cancelled = false;
1109
1110 switch( clipItem->Type() )
1111 {
1112 case PCB_T:
1113 {
1114 BOARD* clipBoard = static_cast<BOARD*>( clipItem );
1115
1116 if( isFootprintEditor )
1117 {
1118 FOOTPRINT* editorFootprint = board()->GetFirstFootprint();
1119 std::vector<BOARD_ITEM*> pastedItems;
1120
1121 for( PCB_GROUP* group : clipBoard->Groups() )
1122 {
1123 group->SetParent( editorFootprint );
1124 pastedItems.push_back( group );
1125 }
1126
1127 clipBoard->RemoveAll( { PCB_GROUP_T } );
1128
1129 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
1130 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
1131
1132 for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
1133 {
1134 switch( clipDrawItem->Type() )
1135 {
1136 case PCB_TEXT_T:
1137 case PCB_TEXTBOX_T:
1138 case PCB_TABLE_T:
1139 case PCB_SHAPE_T:
1140 case PCB_DIM_ALIGNED_T:
1141 case PCB_DIM_CENTER_T:
1142 case PCB_DIM_LEADER_T:
1144 case PCB_DIM_RADIAL_T:
1145 clipDrawItem->SetParent( editorFootprint );
1146 pastedItems.push_back( clipDrawItem );
1147 break;
1148
1149 default:
1150 // Everything we *didn't* put into pastedItems is going to get nuked, so
1151 // make sure it's not still included in its parent group.
1152 if( PCB_GROUP* parentGroup = clipDrawItem->GetParentGroup() )
1153 parentGroup->RemoveItem( clipDrawItem );
1154
1155 break;
1156 }
1157 }
1158
1159 // NB: PCB_SHAPE_T actually removes everything in Drawings() (including PCB_TEXTs,
1160 // PCB_TABLES, dimensions, etc.), not just PCB_SHAPEs.)
1161 clipBoard->RemoveAll( { PCB_SHAPE_T } );
1162
1163 clipBoard->Visit(
1164 [&]( EDA_ITEM* item, void* testData )
1165 {
1166 // Anything still on the clipboard didn't get copied and needs to be
1167 // removed from the pasted groups.
1168 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
1169 PCB_GROUP* parentGroup = boardItem->GetParentGroup();
1170
1171 if( parentGroup )
1172 parentGroup->RemoveItem( boardItem );
1173
1174 return INSPECT_RESULT::CONTINUE;
1175 },
1177
1178 delete clipBoard;
1179
1180 pruneItemLayers( pastedItems );
1181
1182 cancelled = !placeBoardItems( &commit, pastedItems, true, true,
1183 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
1184 }
1185 else // isBoardEditor
1186 {
1187 if( mode == PASTE_MODE::REMOVE_ANNOTATIONS )
1188 {
1189 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
1190 clipFootprint->SetReference( defaultRef );
1191 }
1192
1193 cancelled = !placeBoardItems( &commit, clipBoard, true,
1194 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
1195 }
1196
1197 break;
1198 }
1199
1200 case PCB_FOOTPRINT_T:
1201 {
1202 FOOTPRINT* clipFootprint = static_cast<FOOTPRINT*>( clipItem );
1203 std::vector<BOARD_ITEM*> pastedItems;
1204
1205 if( isFootprintEditor )
1206 {
1207 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
1208 delete clipFootprint;
1209 }
1210 else
1211 {
1212 if( mode == PASTE_MODE::REMOVE_ANNOTATIONS )
1213 clipFootprint->SetReference( defaultRef );
1214
1215 clipFootprint->SetParent( board() );
1216 pastedItems.push_back( clipFootprint );
1217 }
1218
1219 pruneItemLayers( pastedItems );
1220
1221 cancelled = !placeBoardItems( &commit, pastedItems, true, true,
1222 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
1223 break;
1224 }
1225
1226 default:
1227 m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
1228 break;
1229 }
1230
1231 if( cancelled )
1232 commit.Revert();
1233 else
1234 commit.Push( _( "Paste" ) );
1235
1236 return 1;
1237}
1238
1239
1241{
1242 wxString fileName;
1243
1244 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1245
1246 if( !editFrame )
1247 return 1;
1248
1249 // Pick a file to append
1250 if( !AskLoadBoardFileName( editFrame, &fileName, KICTL_KICAD_ONLY ) )
1251 return 1;
1252
1253 PCB_IO_MGR::PCB_FILE_T pluginType =
1255 IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( pluginType ) );
1256
1257 if( !pi )
1258 return 1;
1259
1260 return AppendBoard( *pi, fileName );
1261}
1262
1263
1264template<typename T>
1265static void moveUnflaggedItems( const std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
1266 bool aIsNew )
1267{
1268 std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
1269 [aIsNew]( T aItem )
1270 {
1271 bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
1272
1273 aItem->ClearFlags( SKIP_STRUCT );
1274 aItem->SetFlags( aIsNew ? IS_NEW : 0 );
1275
1276 return doCopy;
1277 } );
1278}
1279
1280
1281template<typename T>
1282static void moveUnflaggedItems( const std::vector<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
1283 bool aIsNew )
1284{
1285 std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
1286 [aIsNew]( T aItem )
1287 {
1288 bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
1289
1290 aItem->ClearFlags( SKIP_STRUCT );
1291 aItem->SetFlags( aIsNew ? IS_NEW : 0 );
1292
1293 return doCopy;
1294 } );
1295}
1296
1297
1298bool PCB_CONTROL::placeBoardItems( BOARD_COMMIT* aCommit, BOARD* aBoard, bool aAnchorAtOrigin,
1299 bool aReannotateDuplicates )
1300{
1301 // items are new if the current board is not the board source
1302 bool isNew = board() != aBoard;
1303 std::vector<BOARD_ITEM*> items;
1304
1305 moveUnflaggedItems( aBoard->Tracks(), items, isNew );
1306 moveUnflaggedItems( aBoard->Footprints(), items, isNew );
1307 moveUnflaggedItems( aBoard->Drawings(), items, isNew );
1308 moveUnflaggedItems( aBoard->Zones(), items, isNew );
1309
1310 // Subtlety: When selecting a group via the mouse,
1311 // PCB_SELECTION_TOOL::highlightInternal runs, which does a SetSelected() on all
1312 // descendants. In PCB_CONTROL::placeBoardItems, below, we skip that and
1313 // mark items non-recursively. That works because the saving of the
1314 // selection created aBoard that has the group and all descendants in it.
1315 moveUnflaggedItems( aBoard->Groups(), items, isNew );
1316
1317 moveUnflaggedItems( aBoard->Generators(), items, isNew );
1318
1319 if( isNew )
1320 aBoard->RemoveAll();
1321
1322 // Reparent before calling pruneItemLayers, as SetLayer can have a dependence on the
1323 // item's parent board being set correctly.
1324 if( isNew )
1325 {
1326 for( BOARD_ITEM* item : items )
1327 item->SetParent( board() );
1328 }
1329
1330 pruneItemLayers( items );
1331
1332 return placeBoardItems( aCommit, items, isNew, aAnchorAtOrigin, aReannotateDuplicates );
1333}
1334
1335
1336bool PCB_CONTROL::placeBoardItems( BOARD_COMMIT* aCommit, std::vector<BOARD_ITEM*>& aItems,
1337 bool aIsNew, bool aAnchorAtOrigin, bool aReannotateDuplicates )
1338{
1340
1342
1343 std::vector<BOARD_ITEM*> itemsToSel;
1344 itemsToSel.reserve( aItems.size() );
1345
1346 for( BOARD_ITEM* item : aItems )
1347 {
1348 if( aIsNew )
1349 {
1350 const_cast<KIID&>( item->m_Uuid ) = KIID();
1351
1352 item->RunOnDescendants(
1353 []( BOARD_ITEM* aChild )
1354 {
1355 const_cast<KIID&>( aChild->m_Uuid ) = KIID();
1356 } );
1357
1358 // Even though BOARD_COMMIT::Push() will add any new items to the group, we're
1359 // going to run PCB_ACTIONS::move first, and the move tool will throw out any
1360 // items that aren't in the entered group.
1361 if( selectionTool->GetEnteredGroup() && !item->GetParentGroup() )
1362 selectionTool->GetEnteredGroup()->AddItem( item );
1363
1364 item->SetParent( board() );
1365 }
1366
1367 // Update item attributes if needed
1368 if( BaseType( item->Type() ) == PCB_DIMENSION_T )
1369 {
1370 static_cast<PCB_DIMENSION_BASE*>( item )->UpdateUnits();
1371 }
1372 else if( item->Type() == PCB_FOOTPRINT_T )
1373 {
1374 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
1375
1376 // Update the footprint path with the new KIID path if the footprint is new
1377 if( aIsNew )
1379
1380 for( BOARD_ITEM* dwg : footprint->GraphicalItems() )
1381 {
1382 if( BaseType( dwg->Type() ) == PCB_DIMENSION_T )
1383 static_cast<PCB_DIMENSION_BASE*>( dwg )->UpdateUnits();
1384 }
1385 }
1386
1387 // We only need to add the items that aren't inside a group currently selected
1388 // to the selection. If an item is inside a group and that group is selected,
1389 // then the selection tool will select it for us.
1390 if( !item->GetParentGroup() || !alg::contains( aItems, item->GetParentGroup() ) )
1391 itemsToSel.push_back( item );
1392 }
1393
1394 // Select the items that should be selected
1395 EDA_ITEMS toSel( itemsToSel.begin(), itemsToSel.end() );
1397
1398 // Reannotate duplicate footprints (make sense only in board editor )
1399 if( aReannotateDuplicates && m_isBoardEditor )
1400 m_toolMgr->GetTool<BOARD_REANNOTATE_TOOL>()->ReannotateDuplicatesInSelection();
1401
1402 for( BOARD_ITEM* item : aItems )
1403 {
1404 if( aIsNew )
1405 aCommit->Add( item );
1406 else
1407 aCommit->Added( item );
1408 }
1409
1410 PCB_SELECTION& selection = selectionTool->GetSelection();
1411
1412 if( selection.Size() > 0 )
1413 {
1414 if( aAnchorAtOrigin )
1415 {
1417 }
1418 else
1419 {
1420 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
1422 }
1423
1424 getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
1425
1427
1429 }
1430
1431 return true;
1432}
1433
1434
1435int PCB_CONTROL::AppendBoard( PCB_IO& pi, wxString& fileName )
1436{
1437 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1438
1439 if( !editFrame )
1440 return 1;
1441
1442 BOARD* brd = board();
1443
1444 if( !brd )
1445 return 1;
1446
1447 BOARD_COMMIT commit( editFrame );
1448
1449 // Mark existing items, in order to know what are the new items so we can select only
1450 // the new items after loading
1451 for( PCB_TRACK* track : brd->Tracks() )
1452 track->SetFlags( SKIP_STRUCT );
1453
1454 for( FOOTPRINT* footprint : brd->Footprints() )
1456
1457 for( PCB_GROUP* group : brd->Groups() )
1458 group->SetFlags( SKIP_STRUCT );
1459
1460 for( BOARD_ITEM* drawing : brd->Drawings() )
1461 drawing->SetFlags( SKIP_STRUCT );
1462
1463 for( ZONE* zone : brd->Zones() )
1464 zone->SetFlags( SKIP_STRUCT );
1465
1466 for( PCB_GENERATOR* generator : brd->Generators() )
1467 generator->SetFlags( SKIP_STRUCT );
1468
1469 std::map<wxString, wxString> oldProperties = brd->GetProperties();
1470 std::map<wxString, wxString> newProperties;
1471
1472 PAGE_INFO oldPageInfo = brd->GetPageSettings();
1473 TITLE_BLOCK oldTitleBlock = brd->GetTitleBlock();
1474
1475 // Keep also the count of copper layers, to adjust if necessary
1476 int initialCopperLayerCount = brd->GetCopperLayerCount();
1477 LSET initialEnabledLayers = brd->GetEnabledLayers();
1478
1479 // Load the data
1480 try
1481 {
1482 std::map<std::string, UTF8> props;
1483
1484 // PCB_IO_EAGLE can use this info to center the BOARD, but it does not yet.
1485
1486 props["page_width"] = std::to_string( editFrame->GetPageSizeIU().x );
1487 props["page_height"] = std::to_string( editFrame->GetPageSizeIU().y );
1488
1490 [&]( wxString aTitle, int aIcon, wxString aMessage, wxString aAction ) -> bool
1491 {
1492 KIDIALOG dlg( editFrame, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
1493
1494 if( !aAction.IsEmpty() )
1495 dlg.SetOKLabel( aAction );
1496
1497 dlg.DoNotShowCheckbox( aMessage, 0 );
1498
1499 return dlg.ShowModal() == wxID_OK;
1500 } );
1501
1502 WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Loading PCB" ), 1 );
1503
1504 editFrame->GetDesignSettings().m_NetSettings->ClearNetclasses();
1505 pi.SetProgressReporter( &progressReporter );
1506 pi.LoadBoard( fileName, brd, &props, nullptr );
1507 }
1508 catch( const IO_ERROR& ioe )
1509 {
1510 DisplayErrorMessage( editFrame, _( "Error loading board." ), ioe.What() );
1511
1512 return 0;
1513 }
1514
1515 newProperties = brd->GetProperties();
1516
1517 for( const std::pair<const wxString, wxString>& prop : oldProperties )
1518 newProperties[ prop.first ] = prop.second;
1519
1520 brd->SetProperties( newProperties );
1521
1522 brd->SetPageSettings( oldPageInfo );
1523 brd->SetTitleBlock( oldTitleBlock );
1524
1525 // rebuild nets and ratsnest before any use of nets
1526 brd->BuildListOfNets();
1527 brd->SynchronizeNetsAndNetClasses( true );
1528 brd->BuildConnectivity();
1529
1530 // Synchronize layers
1531 // we should not ask PLUGINs to do these items:
1532 int copperLayerCount = brd->GetCopperLayerCount();
1533
1534 if( copperLayerCount > initialCopperLayerCount )
1535 brd->SetCopperLayerCount( copperLayerCount );
1536
1537 // Enable all used layers, and make them visible:
1538 LSET enabledLayers = brd->GetEnabledLayers();
1539 enabledLayers |= initialEnabledLayers;
1540 brd->SetEnabledLayers( enabledLayers );
1541 brd->SetVisibleLayers( enabledLayers );
1542
1543 if( placeBoardItems( &commit, brd, false, false /* Don't reannotate dupes on Append Board */ ) )
1544 commit.Push( _( "Append Board" ) );
1545 else
1546 commit.Revert();
1547
1548 // Refresh the UI for the updated board properties
1549 editFrame->GetAppearancePanel()->OnBoardChanged();
1550
1551 return 0;
1552}
1553
1554
1555int PCB_CONTROL::Undo( const TOOL_EVENT& aEvent )
1556{
1557 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1558 wxCommandEvent dummy;
1559
1560 if( editFrame )
1561 editFrame->RestoreCopyFromUndoList( dummy );
1562
1563 return 0;
1564}
1565
1566
1567int PCB_CONTROL::Redo( const TOOL_EVENT& aEvent )
1568{
1569 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1570 wxCommandEvent dummy;
1571
1572 if( editFrame )
1573 editFrame->RestoreCopyFromRedoList( dummy );
1574
1575 return 0;
1576}
1577
1578
1580{
1584 bool& snapMode = settings.allLayers;
1585
1587 snapMode = false;
1588 else if( aEvent.IsAction( &PCB_ACTIONS::magneticSnapAllLayers ) )
1589 snapMode = true;
1590 else
1591 snapMode = !snapMode;
1592
1594
1595 return 0;
1596}
1597
1598
1600{
1601 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
1602 return 0;
1603
1604 wxArrayString labels;
1605 labels.Add( _( "Active Layer" ) );
1606 labels.Add( _( "All Layers" ) );
1607
1608 if( !m_frame->GetHotkeyPopup() )
1610
1612
1616
1617 if( popup )
1618 popup->Popup( _( "Object Snapping" ), labels, static_cast<int>( settings.allLayers ) );
1619
1620 return 0;
1621}
1622
1623
1625{
1627 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
1628 PCB_SELECTION& selection = selTool->GetSelection();
1629 PCB_EDIT_FRAME* pcbFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1630 std::shared_ptr<DRC_ENGINE> drcEngine = m_frame->GetBoard()->GetDesignSettings().m_DRCEngine;
1631 DRC_CONSTRAINT constraint;
1632
1633 std::vector<MSG_PANEL_ITEM> msgItems;
1634
1635 if( routerTool && routerTool->RoutingInProgress() )
1636 {
1637 routerTool->UpdateMessagePanel();
1638 return 0;
1639 }
1640
1641 if( !pcbFrame && !m_frame->GetModel() )
1642 return 0;
1643
1644 if( selection.Empty() )
1645 {
1646 if( !pcbFrame )
1647 {
1648 FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_frame->GetModel() );
1649 fp->GetMsgPanelInfo( m_frame, msgItems );
1650 }
1651 else
1652 {
1654 }
1655 }
1656 else if( selection.GetSize() == 1 )
1657 {
1658 EDA_ITEM* item = selection.Front();
1659
1660 if( std::optional<wxString> uuid = GetMsgPanelDisplayUuid( item->m_Uuid ) )
1661 msgItems.emplace_back( _( "UUID" ), *uuid );
1662
1663 item->GetMsgPanelInfo( m_frame, msgItems );
1664
1665 PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item );
1666 NETINFO_ITEM* net = track ? track->GetNet() : nullptr;
1667 NETINFO_ITEM* coupledNet = net ? m_frame->GetBoard()->DpCoupledNet( net ) : nullptr;
1668
1669 if( coupledNet )
1670 {
1671 SEG trackSeg( track->GetStart(), track->GetEnd() );
1672 PCB_TRACK* coupledItem = nullptr;
1673 SEG::ecoord closestDist_sq = VECTOR2I::ECOORD_MAX;
1674
1675 for( PCB_TRACK* candidate : m_frame->GetBoard()->Tracks() )
1676 {
1677 if( candidate->GetNet() != coupledNet )
1678 continue;
1679
1680 SEG::ecoord dist_sq = trackSeg.SquaredDistance( SEG( candidate->GetStart(),
1681 candidate->GetEnd() ) );
1682
1683 if( !coupledItem || dist_sq < closestDist_sq )
1684 {
1685 coupledItem = candidate;
1686 closestDist_sq = dist_sq;
1687 }
1688 }
1689
1690 constraint = drcEngine->EvalRules( DIFF_PAIR_GAP_CONSTRAINT, track, coupledItem,
1691 track->GetLayer() );
1692
1693 wxString msg = m_frame->MessageTextFromMinOptMax( constraint.Value() );
1694
1695 if( !msg.IsEmpty() )
1696 {
1697 msgItems.emplace_back( wxString::Format( _( "DP Gap Constraints: %s" ), msg ),
1698 wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
1699 }
1700
1701 constraint = drcEngine->EvalRules( MAX_UNCOUPLED_CONSTRAINT, track,
1702 coupledItem, track->GetLayer() );
1703
1704 if( constraint.Value().HasMax() )
1705 {
1706 msg = m_frame->MessageTextFromValue( constraint.Value().Max() );
1707 msgItems.emplace_back( wxString::Format( _( "DP Max Uncoupled-length: %s" ), msg ),
1708 wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
1709 }
1710 }
1711 }
1712 else if( pcbFrame && selection.GetSize() == 2 )
1713 {
1714 // Pair selection broken into multiple, optional data, starting with the selected item
1715 // names
1716
1717 BOARD_ITEM* a = static_cast<BOARD_ITEM*>( selection[0] );
1718 BOARD_ITEM* b = static_cast<BOARD_ITEM*>( selection[1] );
1719
1720 msgItems.emplace_back( MSG_PANEL_ITEM( a->GetItemDescription( m_frame, false ),
1721 b->GetItemDescription( m_frame, false ) ) );
1722
1723 BOARD_CONNECTED_ITEM* a_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( a );
1724 BOARD_CONNECTED_ITEM* b_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( b );
1725
1726 if( a_conn && b_conn )
1727 {
1728 LSET overlap = a_conn->GetLayerSet() & b_conn->GetLayerSet() & LSET::AllCuMask();
1729 int a_netcode = a_conn->GetNetCode();
1730 int b_netcode = b_conn->GetNetCode();
1731
1732 if( overlap.count() > 0
1733 && ( a_netcode != b_netcode || a_netcode < 0 || b_netcode < 0 ) )
1734 {
1735 PCB_LAYER_ID layer = overlap.CuStack().front();
1736
1737 constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b, layer );
1738 msgItems.emplace_back( _( "Resolved clearance" ),
1739 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1740
1741 std::shared_ptr<SHAPE> a_shape( a_conn->GetEffectiveShape( layer ) );
1742 std::shared_ptr<SHAPE> b_shape( b_conn->GetEffectiveShape( layer ) );
1743
1744 int actual_clearance = a_shape->GetClearance( b_shape.get() );
1745
1746 if( actual_clearance > -1 && actual_clearance < std::numeric_limits<int>::max() )
1747 {
1748 msgItems.emplace_back( _( "Actual clearance" ),
1749 m_frame->MessageTextFromValue( actual_clearance ) );
1750 }
1751 }
1752 }
1753
1754 if( ( a->HasHole() || b->HasHole() ) )
1755 {
1758
1759 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1760 layer = active;
1761 else if( b->HasHole() && a->IsOnLayer( active ) && IsCopperLayer( active ) )
1762 layer = active;
1763 else if( a->HasHole() && b->IsOnCopperLayer() )
1764 layer = b->GetLayer();
1765 else if( b->HasHole() && a->IsOnCopperLayer() )
1766 layer = a->GetLayer();
1767
1768 if( IsCopperLayer( layer ) )
1769 {
1770 int actual = std::numeric_limits<int>::max();
1771
1772 if( a->HasHole() && b->IsOnCopperLayer() )
1773 {
1774 std::shared_ptr<SHAPE_SEGMENT> hole = a->GetEffectiveHoleShape();
1775 std::shared_ptr<SHAPE> other( b->GetEffectiveShape( layer ) );
1776
1777 actual = std::min( actual, hole->GetClearance( other.get() ) );
1778 }
1779
1780 if( b->HasHole() && a->IsOnCopperLayer() )
1781 {
1782 std::shared_ptr<SHAPE_SEGMENT> hole = b->GetEffectiveHoleShape();
1783 std::shared_ptr<SHAPE> other( a->GetEffectiveShape( layer ) );
1784
1785 actual = std::min( actual, hole->GetClearance( other.get() ) );
1786 }
1787
1788 if( actual < std::numeric_limits<int>::max() )
1789 {
1790 constraint = drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, a, b, layer );
1791 msgItems.emplace_back( _( "Resolved hole clearance" ),
1792 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1793
1794 if( actual > -1 && actual < std::numeric_limits<int>::max() )
1795 {
1796 msgItems.emplace_back( _( "Actual hole clearance" ),
1797 m_frame->MessageTextFromValue( actual ) );
1798 }
1799 }
1800 }
1801 }
1802
1803 for( PCB_LAYER_ID edgeLayer : { Edge_Cuts, Margin } )
1804 {
1807
1808 if( a->IsOnLayer( edgeLayer ) && b->Type() != PCB_FOOTPRINT_T )
1809 {
1810 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1811 layer = active;
1812 else if( IsCopperLayer( b->GetLayer() ) )
1813 layer = b->GetLayer();
1814 }
1815 else if( b->IsOnLayer( edgeLayer ) && a->Type() != PCB_FOOTPRINT_T )
1816 {
1817 if( a->IsOnLayer( active ) && IsCopperLayer( active ) )
1818 layer = active;
1819 else if( IsCopperLayer( a->GetLayer() ) )
1820 layer = a->GetLayer();
1821 }
1822
1823 if( layer >= 0 )
1824 {
1825 constraint = drcEngine->EvalRules( EDGE_CLEARANCE_CONSTRAINT, a, b, layer );
1826
1827 if( edgeLayer == Edge_Cuts )
1828 {
1829 msgItems.emplace_back( _( "Resolved edge clearance" ),
1830 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1831 }
1832 else
1833 {
1834 msgItems.emplace_back( _( "Resolved margin clearance" ),
1835 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1836 }
1837 }
1838 }
1839 }
1840
1841 if( selection.GetSize() )
1842 {
1843 if( msgItems.empty() )
1844 {
1845 msgItems.emplace_back( _( "Selected Items" ),
1846 wxString::Format( wxT( "%d" ), selection.GetSize() ) );
1847
1848 if( m_isBoardEditor )
1849 {
1850 std::set<wxString> netNames;
1851 std::set<wxString> netClasses;
1852
1853 for( EDA_ITEM* item : selection )
1854 {
1855 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
1856 {
1857 netNames.insert( UnescapeString( bci->GetNetname() ) );
1858 netClasses.insert( UnescapeString(
1859 bci->GetEffectiveNetClass()->GetHumanReadableName() ) );
1860
1861 if( netNames.size() > 1 && netClasses.size() > 1 )
1862 break;
1863 }
1864 }
1865
1866 if( netNames.size() == 1 )
1867 msgItems.emplace_back( _( "Net" ), *netNames.begin() );
1868
1869 if( netClasses.size() == 1 )
1870 msgItems.emplace_back( _( "Resolved Netclass" ), *netClasses.begin() );
1871 }
1872 }
1873
1874 if( selection.GetSize() >= 2 )
1875 {
1876 bool lengthValid = true;
1877 double selectedLength = 0;
1878
1879 // Lambda to accumulate track length if item is a track or arc, otherwise mark invalid
1880 std::function<void( EDA_ITEM* )> accumulateTrackLength;
1881
1882 accumulateTrackLength = [&]( EDA_ITEM* aItem )
1883 {
1884 if( PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( aItem ) )
1885 {
1886 selectedLength += track->GetLength();
1887 }
1888 else if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
1889 {
1890 const SHAPE_T shapeType = shape->GetShape();
1891 if( shapeType == SHAPE_T::SEGMENT || shapeType == SHAPE_T::ARC
1892 || shapeType == SHAPE_T::BEZIER )
1893 {
1894 selectedLength += shape->GetLength();
1895 }
1896 else
1897 {
1898 lengthValid = false;
1899 }
1900 }
1901 else if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( aItem ) )
1902 {
1903 group->RunOnChildren( accumulateTrackLength );
1904 }
1905 else
1906 {
1907 lengthValid = false;
1908 }
1909 };
1910
1911 for( EDA_ITEM* item : selection )
1912 accumulateTrackLength( item );
1913
1914 if( lengthValid )
1915 {
1916 msgItems.emplace_back( _( "Selected 2D Length" ),
1917 m_frame->MessageTextFromValue( selectedLength ) );
1918 }
1919 }
1920 }
1921 else
1922 {
1923 m_frame->GetBoard()->GetMsgPanelInfo( m_frame, msgItems );
1924 }
1925
1926 m_frame->SetMsgPanel( msgItems );
1927
1928 return 0;
1929}
1930
1931
1933{
1934 wxFileName fileName = wxFileName( *aEvent.Parameter<wxString*>() );
1935
1936 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1937
1938 if( !editFrame )
1939 return 1;
1940
1941 wxString filePath = fileName.GetFullPath();
1943 IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( pluginType ) );
1944
1945 if( !pi )
1946 return 1;
1947
1948 return AppendBoard( *pi, filePath );
1949}
1950
1951
1953{
1954 view()->SetMirror( !view()->IsMirroredX(), false );
1955 view()->RecacheAllItems();
1956 frame()->GetCanvas()->ForceRefresh();
1957 frame()->OnDisplayOptionsChanged();
1958 return 0;
1959}
1960
1961// clang-format off
1963{
1966 Go( &PCB_CONTROL::Print, ACTIONS::print.MakeEvent() );
1967 Go( &PCB_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1968
1969 // Display modes
1985
1986 // Layer control
2024
2027
2028 // Grid control
2031
2032 Go( &PCB_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
2033 Go( &PCB_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
2034
2035 // Snapping control
2040
2041 // Miscellaneous
2043
2044 // Append control
2047
2048 Go( &PCB_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
2050
2057
2058 // Add library by dropping file
2061}
2062// 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:1812
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:817
NETINFO_ITEM * DpCoupledNet(const NETINFO_ITEM *aNet)
Definition: board.cpp:2032
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:2687
void BuildListOfNets()
Definition: board.h:842
const GENERATORS & Generators() const
Definition: board.h:342
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
Definition: board.cpp:2661
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:837
const PAGE_INFO & GetPageSettings() const
Definition: board.h:697
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:187
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:2094
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:456
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:703
int GetCopperLayerCount() const
Definition: board.cpp:780
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:1287
const TRACKS & Tracks() const
Definition: board.h:334
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:698
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:849
void SetCopperLayerCount(int aCount)
Definition: board.cpp:786
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:823
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:1774
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:934
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:705
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 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:2442
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 SetReference(const wxString &aReference)
Definition: footprint.h:626
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:1627
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:667
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:688
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
Definition: lset.cpp:245
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:562
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:320
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:139
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: wx_infobar.cpp:278
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:756
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition: layer_ids.h:581
@ LAYER_RATSNEST
Definition: layer_ids.h:215
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:321
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)
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.