KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_control.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014-2016 CERN
5 * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <kiplatform/ui.h>
27#include <tools/edit_tool.h>
29#include <router/router_tool.h>
30#include <pgm_base.h>
31#include <tools/pcb_actions.h>
32#include <tools/pcb_control.h>
37#include <board_commit.h>
38#include <board.h>
40#include <board_item.h>
42#include <pcb_dimension.h>
44#include <footprint.h>
45#include <pcb_group.h>
46#include <pcb_textbox.h>
47#include <pcb_track.h>
49#include <zone.h>
50#include <confirm.h>
52#include <core/kicad_algo.h>
54#include <kicad_clipboard.h>
55#include <origin_viewitem.h>
56#include <pcb_edit_frame.h>
57#include <pcb_painter.h>
58#include <string_utf8_map.h>
60#include <string>
61#include <tool/tool_manager.h>
65#include <widgets/wx_infobar.h>
66#include <wx/hyperlink.h>
67
68using namespace std::placeholders;
69
70
71// files.cpp
72extern bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, int aCtl = 0 );
73
74
76 PCB_TOOL_BASE( "pcbnew.Control" ),
77 m_frame( nullptr ),
78 m_pickerItem( nullptr )
79{
81}
82
83
85{
86}
87
88
90{
91 m_frame = getEditFrame<PCB_BASE_FRAME>();
92
93 if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW )
94 {
95 m_gridOrigin->SetPosition( board()->GetDesignSettings().GetGridOrigin() );
96 m_gridOrigin->SetColor( m_frame->GetGridColor() );
97 getView()->Remove( m_gridOrigin.get() );
98 getView()->Add( m_gridOrigin.get() );
99 }
100}
101
102
104{
106 {
107 if( aEvent.IsAction( &ACTIONS::newLibrary ) )
108 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
109 else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
110 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
111 }
112
113 return 0;
114}
115
116
118{
119 const wxString fn = *aEvent.Parameter<wxString*>();
120 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary( fn );
121 return 0;
122}
123
124
126{
127 const wxString fn = *aEvent.Parameter<wxString*>();
128 static_cast<FOOTPRINT_EDIT_FRAME*>( m_frame )->ImportFootprint( fn );
129 m_frame->Zoom_Automatique( false );
130 return 0;
131}
132
133
134int PCB_CONTROL::Quit( const TOOL_EVENT& aEvent )
135{
136 m_frame->Close( false );
137 return 0;
138}
139
140
141template<class T> void Flip( T& aValue )
142{
143 aValue = !aValue;
144}
145
146
148{
149 Flip( displayOptions().m_DisplayPcbTrackFill );
150
151 for( PCB_TRACK* track : board()->Tracks() )
152 {
153 if( track->Type() == PCB_TRACE_T || track->Type() == PCB_ARC_T )
154 view()->Update( track, KIGFX::REPAINT );
155 }
156
157 for( BOARD_ITEM* shape : board()->Drawings() )
158 {
159 if( shape->Type() == PCB_SHAPE_T && static_cast<PCB_SHAPE*>( shape )->IsOnCopperLayer() )
160 view()->Update( shape, KIGFX::REPAINT );
161 }
162
163 canvas()->Refresh();
164
165 return 0;
166}
167
168
170{
171 if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
172 {
173 // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
174 Flip( displayOptions().m_ShowGlobalRatsnest );
175 getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
176 displayOptions().m_ShowGlobalRatsnest );
177
178 }
179 else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
180 {
181 Flip( displayOptions().m_DisplayRatsnestLinesCurved );
182 }
183
185
187 canvas()->Refresh();
188
189 return 0;
190}
191
192
194{
195 Flip( displayOptions().m_DisplayViaFill );
196
197 for( PCB_TRACK* track : board()->Tracks() )
198 {
199 if( track->Type() == PCB_VIA_T )
200 view()->Update( track, KIGFX::REPAINT );
201 }
202
203 canvas()->Refresh();
204 return 0;
205}
206
207
214{
215 if( Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning )
216 return;
217
218 bool unfilledZones = false;
219
220 for( const ZONE* zone : board()->Zones() )
221 {
222 if( !zone->GetIsRuleArea() && !zone->IsFilled() )
223 {
224 unfilledZones = true;
225 break;
226 }
227 }
228
229 if( unfilledZones )
230 {
231 WX_INFOBAR* infobar = frame()->GetInfoBar();
232 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Don't show again" ),
233 wxEmptyString );
234
235 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
236 [&]( wxHyperlinkEvent& aEvent )
237 {
238 Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning = true;
239 frame()->GetInfoBar()->Dismiss();
240 } ) );
241
242 infobar->RemoveAllButtons();
243 infobar->AddButton( button );
244
245 wxString msg;
246 msg.Printf( _( "Not all zones are filled. Use Edit > Fill All Zones (%s) "
247 "if you wish to see all fills." ),
249
250 infobar->ShowMessageFor( msg, 5000, wxICON_WARNING );
251 }
252}
253
254
256{
258
259 // Apply new display options to the GAL canvas
261 {
263
264 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
265 }
266 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutline ) )
267 {
268 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE;
269 }
270 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayFractured ) )
271 {
272 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS;
273 }
275 {
276 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_TRIANGULATION;
277 }
278 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
279 {
280 if( opts.m_ZoneDisplayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
281 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE;
282 else
283 opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
284 }
285 else
286 {
287 wxFAIL;
288 }
289
290 m_frame->SetDisplayOptions( opts );
291
292 for( ZONE* zone : board()->Zones() )
293 view()->Update( zone, KIGFX::REPAINT );
294
295 canvas()->Refresh();
296
297 return 0;
298}
299
300
302{
304
305 opts.m_ContrastModeDisplay = opts.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::NORMAL
306 ? HIGH_CONTRAST_MODE::DIMMED
307 : HIGH_CONTRAST_MODE::NORMAL;
308
309 m_frame->SetDisplayOptions( opts );
310 return 0;
311}
312
313
315{
317
318 switch( opts.m_ContrastModeDisplay )
319 {
320 case HIGH_CONTRAST_MODE::NORMAL: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::DIMMED; break;
321 case HIGH_CONTRAST_MODE::DIMMED: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::HIDDEN; break;
322 case HIGH_CONTRAST_MODE::HIDDEN: opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL; break;
323 }
324
325 m_frame->SetDisplayOptions( opts );
326
328 return 0;
329}
330
331
333{
334 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
335 return 0;
336
338
339 wxArrayString labels;
340 labels.Add( _( "Normal" ) );
341 labels.Add( _( "Dimmed" ) );
342 labels.Add( _( "Hidden" ) );
343
344 if( !m_frame->GetHotkeyPopup() )
346
348
349 if( popup )
350 {
351 popup->Popup( _( "Inactive Layer Display" ), labels,
352 static_cast<int>( opts.m_ContrastModeDisplay ) );
353 }
354
355 return 0;
356}
357
358
360{
362
363 switch( opts.m_NetColorMode )
364 {
365 case NET_COLOR_MODE::ALL: opts.m_NetColorMode = NET_COLOR_MODE::RATSNEST; break;
366 case NET_COLOR_MODE::RATSNEST: opts.m_NetColorMode = NET_COLOR_MODE::OFF; break;
367 case NET_COLOR_MODE::OFF: opts.m_NetColorMode = NET_COLOR_MODE::ALL; break;
368 }
369
370 m_frame->SetDisplayOptions( opts );
371 return 0;
372}
373
374
376{
377 if( !displayOptions().m_ShowGlobalRatsnest )
378 {
380 displayOptions().m_RatsnestMode = RATSNEST_MODE::ALL;
381 }
382 else if( displayOptions().m_RatsnestMode == RATSNEST_MODE::ALL )
383 {
384 displayOptions().m_RatsnestMode = RATSNEST_MODE::VISIBLE;
385 }
386 else
387 {
389 }
390
391 getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
392 displayOptions().m_ShowGlobalRatsnest );
393
395
397 canvas()->Refresh();
398 return 0;
399}
400
401
403{
405
406 return 0;
407}
408
409
411{
412 PCB_BASE_FRAME* editFrame = m_frame;
413 BOARD* brd = board();
414 int layer = editFrame->GetActiveLayer();
415 int startLayer = layer;
416
417 while( startLayer != ++layer )
418 {
419 if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
420 break;
421
422 if( layer >= B_Cu )
423 layer = F_Cu - 1;
424 }
425
426 wxCHECK( IsCopperLayer( layer ), 0 );
427 editFrame->SwitchLayer( ToLAYER_ID( layer ) );
428
429 return 0;
430}
431
432
434{
435 PCB_BASE_FRAME* editFrame = m_frame;
436 BOARD* brd = board();
437 int layer = editFrame->GetActiveLayer();
438 int startLayer = layer;
439
440 while( startLayer != --layer )
441 {
442 if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
443 && brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
444 {
445 break;
446 }
447
448 if( layer <= F_Cu )
449 layer = B_Cu + 1;
450 }
451
452 wxCHECK( IsCopperLayer( layer ), 0 );
453 editFrame->SwitchLayer( ToLAYER_ID( layer ) );
454
455 return 0;
456}
457
458
460{
461 int currentLayer = m_frame->GetActiveLayer();
462 PCB_SCREEN* screen = m_frame->GetScreen();
463
464 if( currentLayer == screen->m_Route_Layer_TOP )
466 else
468
469 return 0;
470}
471
472
473// It'd be nice to share the min/max with the DIALOG_COLOR_PICKER, but those are
474// set in wxFormBuilder.
475#define ALPHA_MIN 0.20
476#define ALPHA_MAX 1.00
477#define ALPHA_STEP 0.05
478
479
481{
483 int currentLayer = m_frame->GetActiveLayer();
484 KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
485
486 if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
487 {
488 currentColor.a += ALPHA_STEP;
489 settings->SetColor( currentLayer, currentColor );
491
493 view->UpdateLayerColor( currentLayer );
494 view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
495
496 if( IsCopperLayer( currentLayer ) )
497 view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
498 }
499 else
500 {
501 wxBell();
502 }
503
504 return 0;
505}
506
507
509{
511 int currentLayer = m_frame->GetActiveLayer();
512 KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
513
514 if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
515 {
516 currentColor.a -= ALPHA_STEP;
517 settings->SetColor( currentLayer, currentColor );
519
521 view->UpdateLayerColor( currentLayer );
522 view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
523
524 if( IsCopperLayer( currentLayer ) )
525 view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
526 }
527 else
528 {
529 wxBell();
530 }
531
532 return 0;
533}
534
535
537 EDA_ITEM* originViewItem, const VECTOR2D& aPoint )
538{
539 aFrame->GetDesignSettings().SetGridOrigin( VECTOR2I( aPoint ) );
540 aView->GetGAL()->SetGridOrigin( aPoint );
541 originViewItem->SetPosition( aPoint );
542 aView->MarkDirty();
543 aFrame->OnModify();
544}
545
546
548{
549 VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
550
551 if( origin )
552 {
553 // We can't undo the other grid dialog settings, so no sense undoing just the origin
554 DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
555 delete origin;
556 }
557 else
558 {
559 if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
560 return 0;
561
563
564 if( !picker ) // Happens in footprint wizard
565 return 0;
566
567 // Deactivate other tools; particularly important if another PICKER is currently running
568 Activate();
569
570 picker->SetClickHandler(
571 [this]( const VECTOR2D& pt ) -> bool
572 {
573 m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
575 return false; // drill origin is a one-shot; don't continue with tool
576 } );
577
579 }
580
581 return 0;
582}
583
584
586{
587 m_frame->SaveCopyInUndoList( m_gridOrigin.get(), UNDO_REDO::GRIDORIGIN );
589 return 0;
590}
591
592
593#define HITTEST_THRESHOLD_PIXELS 5
594
595
597{
599 return 0;
600
602
603 m_pickerItem = nullptr;
605
606 // Deactivate other tools; particularly important if another PICKER is currently running
607 Activate();
608
609 picker->SetCursor( KICURSOR::REMOVE );
610
611 picker->SetClickHandler(
612 [this]( const VECTOR2D& aPosition ) -> bool
613 {
614 if( m_pickerItem )
615 {
617 {
618 m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
619 m_statusPopup->SetText( _( "Item locked." ) );
620 m_statusPopup->PopupFor( 2000 );
621 m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition()
622 + wxPoint( 20, 20 ) );
623 return true;
624 }
625
627 selectionTool->UnbrightenItem( m_pickerItem );
628
629 PCB_SELECTION items;
630 items.Add( m_pickerItem );
631
632 EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
633 editTool->DeleteItems( items, false );
634
635 m_pickerItem = nullptr;
636 }
637
638 return true;
639 } );
640
641 picker->SetMotionHandler(
642 [this]( const VECTOR2D& aPos )
643 {
647 GENERAL_COLLECTOR collector;
648 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
649
651 collector.Collect( board, GENERAL_COLLECTOR::FootprintItems, aPos, guide );
652 else
653 collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, aPos, guide );
654
655 // Remove unselectable items
656 for( int i = collector.GetCount() - 1; i >= 0; --i )
657 {
658 if( !selectionTool->Selectable( collector[ i ] ) )
659 collector.Remove( i );
660 }
661
662 if( collector.GetCount() > 1 )
663 selectionTool->GuessSelectionCandidates( collector, aPos );
664
665 BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
666
667 if( m_pickerItem != item )
668 {
669 if( m_pickerItem )
670 selectionTool->UnbrightenItem( m_pickerItem );
671
672 m_pickerItem = item;
673
674 if( m_pickerItem )
675 selectionTool->BrightenItem( m_pickerItem );
676 }
677 } );
678
679 picker->SetFinalizeHandler(
680 [this]( const int& aFinalState )
681 {
682 if( m_pickerItem )
683 m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
684
685 m_statusPopup.reset();
686
687 // Ensure the cursor gets changed&updated
688 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
690 } );
691
693
694 return 0;
695}
696
697
698static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBoard,
699 std::vector<BOARD_ITEM*>& aPastedItems )
700{
701 FOOTPRINT* editorFootprint = aBoard->GetFirstFootprint();
702
703 aClipFootprint->SetParent( aBoard );
704
705 for( PAD* pad : aClipFootprint->Pads() )
706 {
707 pad->SetParent( editorFootprint );
708 aPastedItems.push_back( pad );
709 }
710
711 aClipFootprint->Pads().clear();
712
713 // Not all graphic items can be added to the current footprint:
714 // Reference and value are already existing in the current footprint, and must be unique.
715 // So they will be skipped
716 for( BOARD_ITEM* item : aClipFootprint->GraphicalItems() )
717 {
718 if( item->Type() == PCB_TEXT_T )
719 {
720 PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
721
722 text->SetTextAngle( text->GetTextAngle() - aClipFootprint->GetOrientation() );
723 text->SetTextAngle( text->GetTextAngle() + editorFootprint->GetOrientation() );
724 }
725
726 VECTOR2I pos = item->GetFPRelativePosition();
727 item->SetParent( editorFootprint );
728 item->SetFPRelativePosition( pos );
729
730 aPastedItems.push_back( item );
731 }
732
733 aClipFootprint->GraphicalItems().clear();
734
735 for( ZONE* zone : aClipFootprint->Zones() )
736 {
737 zone->SetParent( editorFootprint );
738 aPastedItems.push_back( zone );
739 }
740
741 aClipFootprint->Zones().clear();
742
743 for( PCB_GROUP* group : aClipFootprint->Groups() )
744 {
745 group->SetParent( editorFootprint );
746 aPastedItems.push_back( group );
747 }
748
749 aClipFootprint->Groups().clear();
750}
751
752
753void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
754{
755 // Do not prune items or layers when copying to the FP editor, because all
756 // layers are accepted, even if they are not enabled in the dummy board
757 // This is mainly true for internal copper layers: all are allowed but only one
758 // (In1.cu) is enabled for the GUI.
760 return;
761
762 LSET enabledLayers = board()->GetEnabledLayers();
763 std::vector<BOARD_ITEM*> returnItems;
764 bool fpItemDeleted = false;
765
766 auto processFPItem =
767 [&]( FOOTPRINT* aFootprint, BOARD_ITEM* aItem )
768 {
769 LSET allowed = aItem->GetLayerSet() & enabledLayers;
770
771 if( allowed.any() )
772 {
773 // Don't prune internal copper layers on items with holes
774 if( aItem->HasHole() && aItem->IsOnCopperLayer() )
775 allowed |= LSET::InternalCuMask();
776
777 aItem->SetLayerSet( allowed );
778 }
779 else
780 {
781 aFootprint->Remove( aItem );
782 fpItemDeleted = true;
783 }
784 };
785
786 for( BOARD_ITEM* item : aItems )
787 {
788
789 if( item->Type() == PCB_FOOTPRINT_T )
790 {
791 FOOTPRINT* fp = static_cast<FOOTPRINT*>( item );
792
793 if( !enabledLayers.test( fp->Reference().GetLayer() ) )
794 fp->Reference().SetLayer( fp->IsFlipped() ? B_SilkS : F_SilkS );
795
796 if( !enabledLayers.test( fp->Value().GetLayer() ) )
797 fp->Value().SetLayer( fp->IsFlipped() ? B_Fab : F_Fab );
798
799 // NOTE: all traversals from the back as processFPItem() might delete the item
800
801 for( int ii = static_cast<int>( fp->Pads().size() ) - 1; ii >= 0; ii-- )
802 processFPItem( fp, fp->Pads()[ii] );
803
804 for( int ii = static_cast<int>( fp->Zones().size() ) - 1; ii >= 0; ii-- )
805 processFPItem( fp, fp->Zones()[ii] );
806
807 for( int ii = static_cast<int>( fp->GraphicalItems().size() ) - 1; ii >= 0; ii-- )
808 processFPItem( fp, fp->GraphicalItems()[ii] );
809
810 if( fp->GraphicalItems().size() || fp->Pads().size() || fp->Zones().size() )
811 returnItems.push_back( fp );
812 }
813 else if( item->Type() == PCB_GROUP_T )
814 {
815 returnItems.push_back( item );
816 }
817 else
818 {
819 LSET allowed = item->GetLayerSet() & enabledLayers;
820
821 if( allowed.any() )
822 {
823 item->SetLayerSet( allowed );
824 returnItems.push_back( item );
825 }
826 }
827 }
828
829 if( ( returnItems.size() < aItems.size() ) || fpItemDeleted )
830 {
831 DisplayError( m_frame, _( "Warning: some pasted items were on layers which are not "
832 "present in the current board.\n"
833 "These items could not be pasted.\n" ) );
834 }
835
836 aItems = returnItems;
837}
838
839
840int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
841{
842 CLIPBOARD_IO pi;
843 BOARD_ITEM* clipItem = pi.Parse();
844
845 if( !clipItem )
846 return 0;
847
848 // The viewer frames cannot paste
849 if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
850 return 0;
851
852 PASTE_MODE mode = PASTE_MODE::KEEP_ANNOTATIONS;
853 const wxString defaultRef = wxT( "REF**" );
854
855 if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
856 {
857 DIALOG_PASTE_SPECIAL dlg( m_frame, &mode, defaultRef );
858
859 if( dlg.ShowModal() == wxID_CANCEL )
860 return 0;
861 }
862
863 bool isFootprintEditor = m_isFootprintEditor || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
864
865 if( clipItem->Type() == PCB_T )
866 {
867 if( isFootprintEditor )
868 {
869 for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
870 item->SetNet( NETINFO_LIST::OrphanedItem() );
871 }
872 else
873 {
874 static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
875 }
876 }
877
878 // The clipboard can contain two different things, an entire kicad_pcb or a single footprint
879 if( isFootprintEditor && ( !board() || !footprint() ) )
880 return 0;
881
882 BOARD_COMMIT commit( frame() );
883 bool cancelled = false;
884
885 switch( clipItem->Type() )
886 {
887 case PCB_T:
888 {
889 BOARD* clipBoard = static_cast<BOARD*>( clipItem );
890
891 if( isFootprintEditor )
892 {
893 FOOTPRINT* editorFootprint = board()->GetFirstFootprint();
894 std::vector<BOARD_ITEM*> pastedItems;
895
896 for( PCB_GROUP* group : clipBoard->Groups() )
897 {
898 group->SetParent( editorFootprint );
899 pastedItems.push_back( group );
900 }
901
902 clipBoard->Groups().clear();
903
904 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
905 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
906
907 for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
908 {
909 switch( clipDrawItem->Type() )
910 {
911 case PCB_TEXT_T:
912 case PCB_TEXTBOX_T:
913 case PCB_SHAPE_T:
915 case PCB_DIM_CENTER_T:
916 case PCB_DIM_LEADER_T:
918 case PCB_DIM_RADIAL_T:
919 clipDrawItem->SetParent( editorFootprint );
920 pastedItems.push_back( clipDrawItem );
921 break;
922
923 default:
924 if( PCB_GROUP* parentGroup = clipDrawItem->GetParentGroup() )
925 parentGroup->RemoveItem( clipDrawItem );
926
927 break;
928 }
929 }
930
931 clipBoard->Drawings().clear();
932
933 clipBoard->Visit(
934 [&]( EDA_ITEM* item, void* testData )
935 {
936 // Anything still on the clipboard didn't get copied and needs to be
937 // removed from the pasted groups.
938 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
939 PCB_GROUP* parentGroup = boardItem->GetParentGroup();
940
941 if( parentGroup )
942 parentGroup->RemoveItem( boardItem );
943
944 return INSPECT_RESULT::CONTINUE;
945 },
947
948 delete clipBoard;
949
950 pruneItemLayers( pastedItems );
951
952 cancelled = !placeBoardItems( &commit, pastedItems, true, true,
953 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
954 }
955 else
956 {
957 if( mode == PASTE_MODE::REMOVE_ANNOTATIONS )
958 {
959 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
960 clipFootprint->SetReference( defaultRef );
961 }
962
963 cancelled = !placeBoardItems( &commit, clipBoard, true,
964 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
965 }
966
967 break;
968 }
969
970 case PCB_FOOTPRINT_T:
971 {
972 FOOTPRINT* clipFootprint = static_cast<FOOTPRINT*>( clipItem );
973 std::vector<BOARD_ITEM*> pastedItems;
974
975 if( isFootprintEditor )
976 {
977 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
978 delete clipFootprint;
979 }
980 else
981 {
982 if( mode == PASTE_MODE::REMOVE_ANNOTATIONS )
983 clipFootprint->SetReference( defaultRef );
984
985 clipFootprint->SetParent( board() );
986 pastedItems.push_back( clipFootprint );
987 }
988
989 pruneItemLayers( pastedItems );
990
991 cancelled = !placeBoardItems( &commit, pastedItems, true, true,
992 mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
993 break;
994 }
995
996 default:
997 m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
998 break;
999 }
1000
1001 if( cancelled )
1002 commit.Revert();
1003 else
1004 commit.Push( _( "Paste" ) );
1005
1006 return 1;
1007}
1008
1009
1011{
1012 wxString fileName;
1013
1014 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1015
1016 if( !editFrame )
1017 return 1;
1018
1019 // Pick a file to append
1020 if( !AskLoadBoardFileName( editFrame, &fileName, true ) )
1021 return 1;
1022
1023 IO_MGR::PCB_FILE_T pluginType =
1025 PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
1026
1027 if( !pi )
1028 return 1;
1029
1030 return AppendBoard( *pi, fileName );
1031}
1032
1033
1034template<typename T>
1035static void moveUnflaggedItems( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
1036 bool aIsNew )
1037{
1038 std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
1039 [aIsNew]( T aItem )
1040 {
1041 bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
1042
1043 aItem->ClearFlags( SKIP_STRUCT );
1044 aItem->SetFlags( aIsNew ? IS_NEW : 0 );
1045
1046 return doCopy;
1047 } );
1048
1049 if( aIsNew )
1050 aList.clear();
1051}
1052
1053
1054static void moveUnflaggedItems( ZONES& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
1055{
1056 if( aList.size() == 0 )
1057 return;
1058
1059 auto obj = aList.front();
1060 int idx = 0;
1061
1062 if( aIsNew )
1063 {
1064 obj = aList.back();
1065 aList.pop_back();
1066 }
1067
1068 for( ; obj ; )
1069 {
1070 if( obj->HasFlag( SKIP_STRUCT ) )
1071 obj->ClearFlags( SKIP_STRUCT );
1072 else
1073 aTarget.push_back( obj );
1074
1075 if( aIsNew )
1076 {
1077 if( aList.size() )
1078 {
1079 obj = aList.back();
1080 aList.pop_back();
1081 }
1082 else
1083 {
1084 obj = nullptr;
1085 }
1086 }
1087 else
1088 {
1089 obj = idx < int(aList.size()-1) ? aList[++idx] : nullptr;
1090 }
1091 }
1092}
1093
1094
1095
1096bool PCB_CONTROL::placeBoardItems( BOARD_COMMIT* aCommit, BOARD* aBoard, bool aAnchorAtOrigin,
1097 bool aReannotateDuplicates )
1098{
1099 // items are new if the current board is not the board source
1100 bool isNew = board() != aBoard;
1101 std::vector<BOARD_ITEM*> items;
1102
1103 moveUnflaggedItems( aBoard->Tracks(), items, isNew );
1104 moveUnflaggedItems( aBoard->Footprints(), items, isNew );
1105 moveUnflaggedItems( aBoard->Drawings(), items, isNew );
1106 moveUnflaggedItems( aBoard->Zones(), items, isNew );
1107
1108 // Subtlety: When selecting a group via the mouse,
1109 // PCB_SELECTION_TOOL::highlightInternal runs, which does a SetSelected() on all
1110 // descendants. In PCB_CONTROL::placeBoardItems, below, we skip that and
1111 // mark items non-recursively. That works because the saving of the
1112 // selection created aBoard that has the group and all descendants in it.
1113 moveUnflaggedItems( aBoard->Groups(), items, isNew );
1114
1115 pruneItemLayers( items );
1116
1117 return placeBoardItems( aCommit, items, isNew, aAnchorAtOrigin, aReannotateDuplicates );
1118}
1119
1120
1121bool PCB_CONTROL::placeBoardItems( BOARD_COMMIT* aCommit, std::vector<BOARD_ITEM*>& aItems,
1122 bool aIsNew, bool aAnchorAtOrigin, bool aReannotateDuplicates )
1123{
1125
1127
1128 std::vector<BOARD_ITEM*> itemsToSel;
1129 itemsToSel.reserve( aItems.size() );
1130
1131 for( BOARD_ITEM* item : aItems )
1132 {
1133 if( aIsNew )
1134 {
1135 const_cast<KIID&>( item->m_Uuid ) = KIID();
1136
1137 // Even though BOARD_COMMIT::Push() will add any new items to the group, we're
1138 // going to run PCB_ACTIONS::move first, and the move tool will throw out any
1139 // items that aren't in the entered group.
1140 if( selectionTool->GetEnteredGroup() && !item->GetParentGroup() )
1141 selectionTool->GetEnteredGroup()->AddItem( item );
1142 }
1143
1144 // Update item attributes if needed
1145 if( BaseType( item->Type() ) == PCB_DIMENSION_T )
1146 {
1147 static_cast<PCB_DIMENSION_BASE*>( item )->UpdateUnits();
1148 }
1149 else if( item->Type() == PCB_FOOTPRINT_T )
1150 {
1151 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
1152
1153 // Update the footprint path with the new KIID path if the footprint is new
1154 if( aIsNew )
1156
1157 for( BOARD_ITEM* dwg : footprint->GraphicalItems() )
1158 {
1159 if( BaseType( dwg->Type() ) == PCB_DIMENSION_T )
1160 static_cast<PCB_DIMENSION_BASE*>( dwg )->UpdateUnits();
1161 }
1162 }
1163
1164 // We only need to add the items that aren't inside a group currently selected
1165 // to the selection. If an item is inside a group and that group is selected,
1166 // then the selection tool will select it for us.
1167 if( !item->GetParentGroup() || !alg::contains( aItems, item->GetParentGroup() ) )
1168 itemsToSel.push_back( item );
1169 }
1170
1171 // Select the items that should be selected
1172 EDA_ITEMS toSel( itemsToSel.begin(), itemsToSel.end() );
1174
1175 // Reannotate duplicate footprints (make sense only in board editor )
1176 if( aReannotateDuplicates && m_isBoardEditor )
1177 m_toolMgr->GetTool<BOARD_REANNOTATE_TOOL>()->ReannotateDuplicatesInSelection();
1178
1179 for( BOARD_ITEM* item : aItems )
1180 {
1181 if( aIsNew )
1182 aCommit->Add( item );
1183 else
1184 aCommit->Added( item );
1185 }
1186
1187 PCB_SELECTION& selection = selectionTool->GetSelection();
1188
1189 if( selection.Size() > 0 )
1190 {
1191 if( aAnchorAtOrigin )
1192 {
1194 }
1195 else
1196 {
1197 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
1199 }
1200
1201 getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
1202
1204
1206 }
1207
1208 return true;
1209}
1210
1211
1212int PCB_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
1213{
1214 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1215
1216 if( !editFrame )
1217 return 1;
1218
1219 BOARD* brd = board();
1220
1221 if( !brd )
1222 return 1;
1223
1224 BOARD_COMMIT commit( editFrame );
1225
1226 // Mark existing items, in order to know what are the new items so we can select only
1227 // the new items after loading
1228 for( PCB_TRACK* track : brd->Tracks() )
1229 track->SetFlags( SKIP_STRUCT );
1230
1231 for( FOOTPRINT* footprint : brd->Footprints() )
1233
1234 for( PCB_GROUP* group : brd->Groups() )
1235 group->SetFlags( SKIP_STRUCT );
1236
1237 for( BOARD_ITEM* drawing : brd->Drawings() )
1238 drawing->SetFlags( SKIP_STRUCT );
1239
1240 for( ZONE* zone : brd->Zones() )
1241 zone->SetFlags( SKIP_STRUCT );
1242
1243 std::map<wxString, wxString> oldProperties = brd->GetProperties();
1244 std::map<wxString, wxString> newProperties;
1245
1246 PAGE_INFO oldPageInfo = brd->GetPageSettings();
1247 TITLE_BLOCK oldTitleBlock = brd->GetTitleBlock();
1248
1249 // Keep also the count of copper layers, to adjust if necessary
1250 int initialCopperLayerCount = brd->GetCopperLayerCount();
1251 LSET initialEnabledLayers = brd->GetEnabledLayers();
1252
1253 // Load the data
1254 try
1255 {
1256 STRING_UTF8_MAP props;
1257
1258 // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
1259
1260 props["page_width"] = std::to_string( editFrame->GetPageSizeIU().x );
1261 props["page_height"] = std::to_string( editFrame->GetPageSizeIU().y );
1262
1264 [&]( wxString aTitle, int aIcon, wxString aMessage, wxString aAction ) -> bool
1265 {
1266 KIDIALOG dlg( editFrame, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
1267
1268 if( !aAction.IsEmpty() )
1269 dlg.SetOKLabel( aAction );
1270
1271 dlg.DoNotShowCheckbox( aMessage, 0 );
1272
1273 return dlg.ShowModal() == wxID_OK;
1274 } );
1275
1276 WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Loading PCB" ), 1 );
1277
1278 editFrame->GetDesignSettings().m_NetSettings->m_NetClasses.clear();
1279 pi.LoadBoard( fileName, brd, &props, nullptr, &progressReporter );
1280 }
1281 catch( const IO_ERROR& ioe )
1282 {
1283 wxString msg = wxString::Format( _( "Error loading board.\n%s" ), ioe.What() );
1284 DisplayError( editFrame, msg );
1285
1286 return 0;
1287 }
1288
1289 newProperties = brd->GetProperties();
1290
1291 for( const std::pair<const wxString, wxString>& prop : oldProperties )
1292 newProperties[ prop.first ] = prop.second;
1293
1294 brd->SetProperties( newProperties );
1295
1296 brd->SetPageSettings( oldPageInfo );
1297 brd->SetTitleBlock( oldTitleBlock );
1298
1299 // rebuild nets and ratsnest before any use of nets
1300 brd->BuildListOfNets();
1301 brd->SynchronizeNetsAndNetClasses( true );
1302 brd->BuildConnectivity();
1303
1304 // Synchronize layers
1305 // we should not ask PLUGINs to do these items:
1306 int copperLayerCount = brd->GetCopperLayerCount();
1307
1308 if( copperLayerCount > initialCopperLayerCount )
1309 brd->SetCopperLayerCount( copperLayerCount );
1310
1311 // Enable all used layers, and make them visible:
1312 LSET enabledLayers = brd->GetEnabledLayers();
1313 enabledLayers |= initialEnabledLayers;
1314 brd->SetEnabledLayers( enabledLayers );
1315 brd->SetVisibleLayers( enabledLayers );
1316
1317 if( placeBoardItems( &commit, brd, false, false /* Don't reannotate dupes on Append Board */ ) )
1318 commit.Push( _( "Append Board" ) );
1319 else
1320 commit.Revert();
1321
1322 return 0;
1323}
1324
1325
1326int PCB_CONTROL::Undo( const TOOL_EVENT& aEvent )
1327{
1328 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1329 wxCommandEvent dummy;
1330
1331 if( editFrame )
1332 editFrame->RestoreCopyFromUndoList( dummy );
1333
1334 return 0;
1335}
1336
1337
1338int PCB_CONTROL::Redo( const TOOL_EVENT& aEvent )
1339{
1340 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1341 wxCommandEvent dummy;
1342
1343 if( editFrame )
1344 editFrame->RestoreCopyFromRedoList( dummy );
1345
1346 return 0;
1347}
1348
1349
1351{
1355 bool& snapMode = settings.allLayers;
1356
1358 snapMode = false;
1359 else if( aEvent.IsAction( &PCB_ACTIONS::magneticSnapAllLayers ) )
1360 snapMode = true;
1361 else
1362 snapMode = !snapMode;
1363
1365
1366 return 0;
1367}
1368
1369
1371{
1372 if( !Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
1373 return 0;
1374
1375 wxArrayString labels;
1376 labels.Add( _( "Active Layer" ) );
1377 labels.Add( _( "All Layers" ) );
1378
1379 if( !m_frame->GetHotkeyPopup() )
1381
1383
1387
1388 if( popup )
1389 popup->Popup( _( "Object Snapping" ), labels, static_cast<int>( settings.allLayers ) );
1390
1391 return 0;
1392}
1393
1394
1396{
1398 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
1399 PCB_SELECTION& selection = selTool->GetSelection();
1400 PCB_EDIT_FRAME* pcbFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1401 std::shared_ptr<DRC_ENGINE> drcEngine = m_frame->GetBoard()->GetDesignSettings().m_DRCEngine;
1402 DRC_CONSTRAINT constraint;
1403
1404 std::vector<MSG_PANEL_ITEM> msgItems;
1405
1406 if( routerTool && routerTool->RoutingInProgress() )
1407 {
1408 routerTool->UpdateMessagePanel();
1409 return 0;
1410 }
1411
1412 if( !pcbFrame && !m_frame->GetModel() )
1413 return 0;
1414
1415 if( selection.Empty() )
1416 {
1417 if( !pcbFrame )
1418 {
1419 FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_frame->GetModel() );
1420 fp->GetMsgPanelInfo( m_frame, msgItems );
1421 }
1422 else
1423 {
1425 }
1426 }
1427 else if( selection.GetSize() == 1 )
1428 {
1429 EDA_ITEM* item = selection.Front();
1430
1431 item->GetMsgPanelInfo( m_frame, msgItems );
1432 }
1433 else if( pcbFrame && selection.GetSize() == 2 )
1434 {
1435 // Pair selection broken into multiple, optional data, starting with the selected item
1436 // names
1437
1438 BOARD_ITEM* a = static_cast<BOARD_ITEM*>( selection[0] );
1439 BOARD_ITEM* b = static_cast<BOARD_ITEM*>( selection[1] );
1440
1441 msgItems.emplace_back( MSG_PANEL_ITEM( a->GetItemDescription( m_frame ),
1442 b->GetItemDescription( m_frame ) ) );
1443
1444 BOARD_CONNECTED_ITEM* a_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( a );
1445 BOARD_CONNECTED_ITEM* b_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( b );
1446
1447 if( a_conn && b_conn )
1448 {
1449 LSET overlap = a_conn->GetLayerSet() & b_conn->GetLayerSet() & LSET::AllCuMask();
1450 int a_netcode = a_conn->GetNetCode();
1451 int b_netcode = b_conn->GetNetCode();
1452
1453 if( overlap.count() > 0
1454 && ( a_netcode != b_netcode || a_netcode < 0 || b_netcode < 0 ) )
1455 {
1456 PCB_LAYER_ID layer = overlap.CuStack().front();
1457
1458 constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b, layer );
1459
1460 std::shared_ptr<SHAPE> a_shape( a_conn->GetEffectiveShape( layer ) );
1461 std::shared_ptr<SHAPE> b_shape( b_conn->GetEffectiveShape( layer ) );
1462
1463 int actual_clearance = a_shape->GetClearance( b_shape.get() );
1464
1465 msgItems.emplace_back( _( "Resolved clearance" ),
1466 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1467
1468 if( actual_clearance > -1 && actual_clearance < std::numeric_limits<int>::max() )
1469 {
1470 msgItems.emplace_back( _( "Actual clearance" ),
1471 m_frame->MessageTextFromValue( actual_clearance ) );
1472 }
1473 }
1474 }
1475
1476 if( ( a->HasHole() || b->HasHole() ) )
1477 {
1480
1481 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1482 layer = active;
1483 else if( b->HasHole() && a->IsOnLayer( active ) && IsCopperLayer( active ) )
1484 layer = active;
1485 else if( a->HasHole() && b->IsOnCopperLayer() )
1486 layer = b->GetLayer();
1487 else if( b->HasHole() && a->IsOnCopperLayer() )
1488 layer = a->GetLayer();
1489
1490 if( IsCopperLayer( layer ) )
1491 {
1492 int actual = std::numeric_limits<int>::max();
1493
1494 if( a->HasHole() && b->IsOnCopperLayer() )
1495 {
1496 std::shared_ptr<SHAPE_SEGMENT> hole = a->GetEffectiveHoleShape();
1497 std::shared_ptr<SHAPE> other( b->GetEffectiveShape( layer ) );
1498
1499 actual = std::min( actual, hole->GetClearance( other.get() ) );
1500 }
1501
1502 if( b->HasHole() && a->IsOnCopperLayer() )
1503 {
1504 std::shared_ptr<SHAPE_SEGMENT> hole = b->GetEffectiveHoleShape();
1505 std::shared_ptr<SHAPE> other( a->GetEffectiveShape( layer ) );
1506
1507 actual = std::min( actual, hole->GetClearance( other.get() ) );
1508 }
1509
1510 if( actual < std::numeric_limits<int>::max() )
1511 {
1512 constraint = drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, a, b, layer );
1513 msgItems.emplace_back( _( "Resolved hole clearance" ),
1514 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1515
1516 if( actual > -1 && actual < std::numeric_limits<int>::max() )
1517 {
1518 msgItems.emplace_back( _( "Actual hole clearance" ),
1519 m_frame->MessageTextFromValue( actual ) );
1520 }
1521 }
1522 }
1523 }
1524
1525 for( PCB_LAYER_ID edgeLayer : { Edge_Cuts, Margin } )
1526 {
1529
1530 if( a->IsOnLayer( edgeLayer ) && b->Type() != PCB_FOOTPRINT_T )
1531 {
1532 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1533 layer = active;
1534 else if( IsCopperLayer( b->GetLayer() ) )
1535 layer = b->GetLayer();
1536 }
1537 else if( b->IsOnLayer( edgeLayer ) && a->Type() != PCB_FOOTPRINT_T )
1538 {
1539 if( a->IsOnLayer( active ) && IsCopperLayer( active ) )
1540 layer = active;
1541 else if( IsCopperLayer( a->GetLayer() ) )
1542 layer = a->GetLayer();
1543 }
1544
1545 if( layer >= 0 )
1546 {
1547 constraint = drcEngine->EvalRules( EDGE_CLEARANCE_CONSTRAINT, a, b, layer );
1548
1549 if( edgeLayer == Edge_Cuts )
1550 {
1551 msgItems.emplace_back( _( "Resolved edge clearance" ),
1552 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1553 }
1554 else
1555 {
1556 msgItems.emplace_back( _( "Resolved margin clearance" ),
1557 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1558 }
1559 }
1560 }
1561 }
1562
1563 if( msgItems.empty() )
1564 {
1565 if( selection.GetSize() )
1566 {
1567 msgItems.emplace_back( _( "Selected Items" ),
1568 wxString::Format( wxT( "%d" ), selection.GetSize() ) );
1569
1570 std::set<wxString> netNames;
1571 std::set<wxString> netClasses;
1572
1573 for( EDA_ITEM* item : selection )
1574 {
1575 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
1576 {
1577 netNames.insert( UnescapeString( bci->GetNetname() ) );
1578 netClasses.insert( UnescapeString( bci->GetEffectiveNetClass()->GetName() ) );
1579
1580 if( netNames.size() > 1 && netClasses.size() > 1 )
1581 break;
1582 }
1583 }
1584
1585 if( netNames.size() == 1 )
1586 msgItems.emplace_back( _( "Net" ), *netNames.begin() );
1587
1588 if( netClasses.size() == 1 )
1589 msgItems.emplace_back( _( "Resolved Netclass" ), *netClasses.begin() );
1590 }
1591 else
1592 {
1593 m_frame->GetBoard()->GetMsgPanelInfo( m_frame, msgItems );
1594 }
1595 }
1596
1597 m_frame->SetMsgPanel( msgItems );
1598
1599 return 0;
1600}
1601
1602
1604{
1605 wxFileName fileName = wxFileName( *aEvent.Parameter<wxString*>() );
1606
1607 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1608
1609 if( !editFrame )
1610 return 1;
1611
1612 wxString filePath = fileName.GetFullPath();
1614 PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
1615
1616 if( !pi )
1617 return 1;
1618
1619 return AppendBoard( *pi, filePath );
1620}
1621
1622
1624{
1625 view()->SetMirror( !view()->IsMirroredX(), false );
1626 view()->RecacheAllItems();
1629 return 0;
1630}
1631
1632
1634{
1637 Go( &PCB_CONTROL::Print, ACTIONS::print.MakeEvent() );
1638 Go( &PCB_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1639
1640 // Display modes
1656
1657 // Layer control
1695
1696 // Grid control
1699
1700 Go( &PCB_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1701 Go( &PCB_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1702
1703 // Snapping control
1708
1709 // Miscellaneous
1711
1712 // Append control
1715
1716 Go( &PCB_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1718
1725
1726 // Add library by dropping file
1729}
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION addLibrary
Definition: actions.h:49
static TOOL_ACTION pickerTool
Definition: actions.h:165
static TOOL_ACTION gridResetOrigin
Definition: actions.h:146
static TOOL_ACTION pasteSpecial
Definition: actions.h:70
static TOOL_ACTION highContrastModeCycle
Definition: actions.h:110
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION highContrastMode
Definition: actions.h:109
static TOOL_ACTION quit
Definition: actions.h:59
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION deleteTool
Definition: actions.h:75
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION newLibrary
Definition: actions.h:48
static TOOL_ACTION gridSetOrigin
Definition: actions.h:145
static TOOL_ACTION ddAddLibrary
Definition: actions.h:60
virtual void Revert() override
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) 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,...
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:77
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:204
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:91
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:269
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:238
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:227
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:209
virtual bool IsLocked() const
Definition: board_item.cpp:73
virtual bool IsOnCopperLayer() const
Definition: board_item.h:142
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
Definition: board_item.cpp:237
virtual bool HasHole() const
Definition: board_item.h:147
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:271
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:1435
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:614
void BuildListOfNets()
Definition: board.h:782
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:634
const PAGE_INFO & GetPageSettings() const
Definition: board.h:641
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: board.h:341
ZONES & Zones()
Definition: board.h:319
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:168
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1630
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:406
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:647
FOOTPRINTS & Footprints()
Definition: board.h:313
int GetCopperLayerCount() const
Definition: board.cpp:590
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:340
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:335
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:642
TRACKS & Tracks()
Definition: board.h:310
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:646
void SetCopperLayerCount(int aCount)
Definition: board.cpp:596
DRAWINGS & Drawings()
Definition: board.h:316
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:620
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:1397
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:731
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:649
BOARD_ITEM * Parse()
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:109
int m_Threshold
Definition: collector.h:234
Color settings are a bit different than most of the settings objects in that there can be more than o...
void SetColor(int aLayer, const COLOR4D &aColor)
COLOR4D GetColor(int aLayer) const
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition: commit.h:84
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
Definition: commit.h:78
MINOPTMAX< int > m_Value
Definition: drc_rule.h:172
bool IsType(FRAME_T aType) const
WX_INFOBAR * GetInfoBar()
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:85
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:239
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:240
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:123
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
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:199
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const
Return a user-visible description string of this item.
Definition: eda_item.cpp:108
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
The interactive edit tool.
Definition: edit_tool.h:55
void DeleteItems(const PCB_SELECTION &aItems, bool aIsCut)
Definition: edit_tool.cpp:1994
static const TOOL_EVENT ClearedEvent
Definition: actions.h:234
static const TOOL_EVENT SelectedEvent
Definition: actions.h:232
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:239
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:231
static const TOOL_EVENT ContrastModeChangedByKeyEvent
Definition: actions.h:253
static const TOOL_EVENT ConnectivityChangedEvent
Selected item had a property changed (except movement)
Definition: actions.h:236
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:233
EDA_ANGLE GetOrientation() const
Definition: footprint.h:209
ZONES & Zones()
Definition: footprint.h:194
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: footprint.cpp:767
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:243
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:592
bool IsFlipped() const
Definition: footprint.h:351
PADS & Pads()
Definition: footprint.h:188
void SetReference(const wxString &aReference)
Definition: footprint.h:562
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:1240
PCB_FIELD & Reference()
Definition: footprint.h:593
GROUPS & Groups()
Definition: footprint.h:197
DRAWINGS & GraphicalItems()
Definition: footprint.h:191
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:321
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:204
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:235
static const std::vector< KICAD_T > AllBoardItems
A scan list for all editable board items.
Definition: collectors.h:224
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:472
static const std::vector< KICAD_T > FootprintItems
A scan list for primary footprint items.
Definition: collectors.h:250
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)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written,...
Definition: io_mgr.h:54
static PCB_FILE_T FindPluginTypeFromBoardPath(const wxString &aFileName, int aCtl=0)
Return a plugin type given a path for a board file.
Definition: io_mgr.cpp:116
static PLUGIN * PluginFind(PCB_FILE_T aFileType)
Return a PLUGIN which the caller can use to import, export, save, or load design documents.
Definition: io_mgr.cpp:63
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:47
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: confirm.cpp:56
int ShowModal() override
Definition: confirm.cpp:100
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
double a
Alpha component.
Definition: color4d.h:379
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:93
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
void SetMirror(bool aMirrorX, bool aMirrorY)
Control the mirroring of the VIEW.
Definition: view.cpp:534
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:313
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:350
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:194
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1400
void UpdateLayerColor(int aLayer)
Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.
Definition: view.cpp:736
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:640
Definition: kiid.h:49
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:552
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
Definition: lset.cpp:170
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
Definition: lset.cpp:733
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
T Min() const
Definition: minoptmax.h:33
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
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:395
Definition: pad.h:58
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
MAGNETIC_SETTINGS m_MagneticItems
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:356
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:332
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:328
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:316
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:323
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:353
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:305
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:374
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:322
static TOOL_ACTION magneticSnapAllLayers
Definition: pcb_actions.h:229
static TOOL_ACTION ddAppendBoard
Drag and drop.
Definition: pcb_actions.h:560
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:345
static TOOL_ACTION magneticSnapActiveLayer
Snapping controls.
Definition: pcb_actions.h:228
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:355
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:312
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:344
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:311
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:68
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:349
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:331
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:354
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:336
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:346
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:338
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:334
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:309
static TOOL_ACTION magneticSnapToggle
Definition: pcb_actions.h:230
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:326
static TOOL_ACTION ddImportFootprint
Definition: pcb_actions.h:561
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:315
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:342
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:325
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:314
static TOOL_ACTION ratsnestModeCycle
Definition: pcb_actions.h:308
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:340
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:327
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:347
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:516
static TOOL_ACTION netColorModeCycle
Definition: pcb_actions.h:307
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:321
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:330
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:335
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:337
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:360
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:351
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:313
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:306
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:339
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:329
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:119
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:350
static TOOL_ACTION layerTop
Definition: pcb_actions.h:320
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Definition: pcb_actions.h:75
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:324
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:333
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:341
static TOOL_ACTION layerNext
Definition: pcb_actions.h:352
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:343
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:348
Common, abstract interface for edit frames.
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:205
void RestoreCopyFromRedoList(wxCommandEvent &aEvent)
Redo the last edit:
Definition: undo_redo.cpp:235
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
virtual void OnDisplayOptionsChanged()
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual void SwitchLayer(PCB_LAYER_ID aLayer)
Change the active layer in the frame.
virtual PCB_LAYER_ID GetActiveLayer() const
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)
Create a new entry in undo list of commands.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Updates the current display options from the given options struct.
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
int AppendBoard(PLUGIN &pi, wxString &fileName)
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 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 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:154
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:150
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:147
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:89
int DeleteItemCursor(const TOOL_EVENT &aEvent)
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:152
int LayerPrev(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
void unfilledZoneCheck()
We have bug reports indicating that some new users confuse zone filling/unfilling with the display mo...
int LayerSwitch(const TOOL_EVENT &aEvent)
Abstract dimension API.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
NET_COLOR_MODE m_NetColorMode
How to use color overrides on specific nets and netclasses.
ZONE_DISPLAY_MODE m_ZoneDisplayMode
void UpdateColors()
Update the color settings in the painter and GAL.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
The main frame for Pcbnew.
static const TOOL_EVENT SnappingModeChangedByKeyEvent
Hotkey feedback.
Definition: pcb_actions.h:570
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
Definition: pcb_group.cpp:87
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:72
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
PCB_GROUP * GetEnteredGroup()
PCB_SELECTION & GetSelection()
EDA_ITEM * GetTopLeftItem(bool aFootprintsOnly=false) const override
KIGFX::PCB_VIEW * view() const
PCB_BASE_EDIT_FRAME * frame() 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
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:82
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:62
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:102
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
Definition: io_mgr.h:610
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:270
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: io_mgr.h:313
virtual BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Load information from some input file format that this PLUGIN implementation knows about into either ...
Definition: plugin.cpp:144
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:99
EDA_ITEM * Front() const
Definition: selection.h:208
int Size() const
Returns the number of selected parts.
Definition: selection.h:115
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:260
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
A name/value tuple with unique names and optional values.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:41
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
@ REDRAW
Full drawing refresh.
Definition: tool_base.h:83
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition: tool_base.h:80
@ GAL_SWITCH
Rendering engine changes.
Definition: tool_base.h:82
Generic, UI-independent tool event.
Definition: tool_event.h:167
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:81
T Parameter() const
Return a parameter assigned to the event.
Definition: tool_event.h:461
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:145
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:192
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:75
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: wx_infobar.cpp:301
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:260
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:187
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:72
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
This file is part of the common library.
#define ALPHA_MAX
@ EDGE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:50
@ CLEARANCE_CONSTRAINT
Definition: drc_rule.h:47
@ HOLE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:48
std::vector< ZONE * > ZONES
Definition: eagle_plugin.h:44
#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:513
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define HITTEST_THRESHOLD_PIXELS
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
#define KICTL_KICAD_ONLY
chosen file is from KiCad according to user
Definition: kiway_player.h:76
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:988
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:847
@ LAYER_RATSNEST
Definition: layer_ids.h:205
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ Edge_Cuts
Definition: layer_ids.h:114
@ B_Cu
Definition: layer_ids.h:96
@ F_Fab
Definition: layer_ids.h:121
@ Margin
Definition: layer_ids.h:115
@ F_SilkS
Definition: layer_ids.h:105
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ B_SilkS
Definition: layer_ids.h:104
@ F_Cu
Definition: layer_ids.h:65
@ B_Fab
Definition: layer_ids.h:120
#define ZONE_LAYER_FOR(boardLayer)
Definition: layer_ids.h:269
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:932
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
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)
static void moveUnflaggedItems(std::deque< T > &aList, std::vector< BOARD_ITEM * > &aTarget, bool aIsNew)
#define ALPHA_MIN
void Flip(T &aValue)
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.
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
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:252
@ 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:102
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:99
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:94
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:100
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:107
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:92
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
@ 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:98
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:95
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
Definition: typeinfo.h:97
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:93
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:101
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588
Definition of file extensions used in Kicad.