KiCad PCB EDA Suite
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-2022 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 <tools/edit_tool.h>
28#include <router/router_tool.h>
29#include <pgm_base.h>
30#include <tools/pcb_actions.h>
31#include <tools/pcb_control.h>
36#include <board_commit.h>
37#include <board.h>
39#include <board_item.h>
41#include <pcb_dimension.h>
42#include <footprint.h>
43#include <pcb_group.h>
44#include <pcb_textbox.h>
45#include <pcb_track.h>
47#include <zone.h>
48#include <fp_shape.h>
49#include <fp_textbox.h>
50#include <confirm.h>
52#include <core/kicad_algo.h>
53#include <kicad_clipboard.h>
54#include <origin_viewitem.h>
55#include <pcb_edit_frame.h>
56#include <pcb_painter.h>
57#include <string_utf8_map.h>
59#include <tool/tool_manager.h>
62#include <widgets/infobar.h>
63#include <wx/hyperlink.h>
64
65using namespace std::placeholders;
66
67
68// files.cpp
69extern bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, int* aCtl, wxString* aFileName,
70 bool aKicadFilesOnly = false );
71extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl );
72
73
75 PCB_TOOL_BASE( "pcbnew.Control" ),
76 m_frame( nullptr ),
77 m_pickerItem( nullptr )
78{
80}
81
82
84{
85}
86
87
89{
90 m_frame = getEditFrame<PCB_BASE_FRAME>();
91
92 if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
93 {
94 m_gridOrigin->SetPosition( board()->GetDesignSettings().GetGridOrigin() );
95 m_gridOrigin->SetColor( m_frame->GetGridColor() );
96 getView()->Remove( m_gridOrigin.get() );
97 getView()->Add( m_gridOrigin.get() );
98 }
99}
100
101
103{
105 {
106 if( aEvent.IsAction( &ACTIONS::newLibrary ) )
107 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
108 else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
109 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
110 }
111
112 return 0;
113}
114
115
117{
118 const wxString fn = *aEvent.Parameter<wxString*>();
119 static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary( fn );
120 return 0;
121}
122
123
125{
126 const wxString fn = *aEvent.Parameter<wxString*>();
127 static_cast<FOOTPRINT_EDIT_FRAME*>( m_frame )->ImportFootprint( fn );
128 m_frame->Zoom_Automatique( false );
129 return 0;
130}
131
132
133int PCB_CONTROL::Quit( const TOOL_EVENT& aEvent )
134{
135 m_frame->Close( false );
136 return 0;
137}
138
139
140template<class T> void Flip( T& aValue )
141{
142 aValue = !aValue;
143}
144
145
147{
148 Flip( displayOptions().m_DisplayPcbTrackFill );
149
150 for( PCB_TRACK* track : board()->Tracks() )
151 {
152 if( track->Type() == PCB_TRACE_T || track->Type() == PCB_ARC_T )
153 view()->Update( track, KIGFX::REPAINT );
154 }
155
156 canvas()->Refresh();
157
158 return 0;
159}
160
161
163{
164 if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
165 {
166 // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
167 Flip( displayOptions().m_ShowGlobalRatsnest );
168 getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
169 displayOptions().m_ShowGlobalRatsnest );
170
171 }
172 else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
173 {
174 Flip( displayOptions().m_DisplayRatsnestLinesCurved );
175 }
176
178 canvas()->Refresh();
179
180 return 0;
181}
182
183
185{
186 Flip( displayOptions().m_DisplayViaFill );
187
188 for( PCB_TRACK* track : board()->Tracks() )
189 {
190 if( track->Type() == PCB_VIA_T )
191 view()->Update( track, KIGFX::REPAINT );
192 }
193
194 canvas()->Refresh();
195
196 return 0;
197}
198
199
206{
207 if( Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning )
208 return;
209
210 bool unfilledZones = false;
211
212 for( const ZONE* zone : board()->Zones() )
213 {
214 if( !zone->GetIsRuleArea() && !zone->IsFilled() )
215 {
216 unfilledZones = true;
217 break;
218 }
219 }
220
221 if( unfilledZones )
222 {
223 WX_INFOBAR* infobar = frame()->GetInfoBar();
224 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Don't show again" ),
225 wxEmptyString );
226
227 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
228 [&]( wxHyperlinkEvent& aEvent )
229 {
230 Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning = true;
231 frame()->GetInfoBar()->Dismiss();
232 } ) );
233
234 infobar->RemoveAllButtons();
235 infobar->AddButton( button );
236
237 wxString msg;
238 msg.Printf( _( "Not all zones are filled. Use Edit > Fill All Zones (%s) "
239 "if you wish to see all fills." ),
241
242 infobar->ShowMessageFor( msg, 5000, wxICON_WARNING );
243 }
244}
245
246
248{
250
251 // Apply new display options to the GAL canvas
253 {
255
257 }
258 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutline ) )
259 {
261 }
262 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayFractured ) )
263 {
265 }
267 {
269 }
270 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
271 {
274 else
276 }
277 else
278 {
279 wxFAIL;
280 }
281
282 m_frame->SetDisplayOptions( opts );
283
284 for( ZONE* zone : board()->Zones() )
285 view()->Update( zone, KIGFX::REPAINT );
286
287 canvas()->Refresh();
288
289 return 0;
290}
291
292
294{
296
300
301 m_frame->SetDisplayOptions( opts );
302
303 return 0;
304}
305
306
308{
310
311 switch( opts.m_ContrastModeDisplay )
312 {
316 }
317
318 m_frame->SetDisplayOptions( opts );
319
320 return 0;
321}
322
323
325{
327
328 switch( opts.m_NetColorMode )
329 {
333 }
334
335 m_frame->SetDisplayOptions( opts );
336
337 return 0;
338}
339
340
342{
343 if( !displayOptions().m_ShowGlobalRatsnest )
344 {
347 }
348 else if( displayOptions().m_RatsnestMode == RATSNEST_MODE::ALL )
349 {
351 }
352 else
353 {
355 }
356
357 return 0;
358}
359
360
362{
364
365 return 0;
366}
367
368
370{
371 PCB_BASE_FRAME* editFrame = m_frame;
372 BOARD* brd = board();
373 int layer = editFrame->GetActiveLayer();
374 int startLayer = layer;
375
376 while( startLayer != ++layer )
377 {
378 if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
379 break;
380
381 if( layer >= B_Cu )
382 layer = F_Cu - 1;
383 }
384
385 wxCHECK( IsCopperLayer( layer ), 0 );
386 editFrame->SwitchLayer( ToLAYER_ID( layer ) );
387
388 return 0;
389}
390
391
393{
394 PCB_BASE_FRAME* editFrame = m_frame;
395 BOARD* brd = board();
396 int layer = editFrame->GetActiveLayer();
397 int startLayer = layer;
398
399 while( startLayer != --layer )
400 {
401 if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
402 && brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
403 {
404 break;
405 }
406
407 if( layer <= F_Cu )
408 layer = B_Cu + 1;
409 }
410
411 wxCHECK( IsCopperLayer( layer ), 0 );
412 editFrame->SwitchLayer( ToLAYER_ID( layer ) );
413
414 return 0;
415}
416
417
419{
420 int currentLayer = m_frame->GetActiveLayer();
421 PCB_SCREEN* screen = m_frame->GetScreen();
422
423 if( currentLayer == screen->m_Route_Layer_TOP )
425 else
427
428 return 0;
429}
430
431
432// It'd be nice to share the min/max with the DIALOG_COLOR_PICKER, but those are
433// set in wxFormBuilder.
434#define ALPHA_MIN 0.20
435#define ALPHA_MAX 1.00
436#define ALPHA_STEP 0.05
437
438
440{
442 int currentLayer = m_frame->GetActiveLayer();
443 KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
444
445 if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
446 {
447 currentColor.a += ALPHA_STEP;
448 settings->SetColor( currentLayer, currentColor );
450
452 view->UpdateLayerColor( currentLayer );
453 view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
454
455 if( IsCopperLayer( currentLayer ) )
456 view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
457 }
458 else
459 {
460 wxBell();
461 }
462
463 return 0;
464}
465
466
468{
470 int currentLayer = m_frame->GetActiveLayer();
471 KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
472
473 if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
474 {
475 currentColor.a -= ALPHA_STEP;
476 settings->SetColor( currentLayer, currentColor );
478
480 view->UpdateLayerColor( currentLayer );
481 view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
482
483 if( IsCopperLayer( currentLayer ) )
484 view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
485 }
486 else
487 {
488 wxBell();
489 }
490
491 return 0;
492}
493
494
496 EDA_ITEM* originViewItem, const VECTOR2D& aPoint )
497{
498 aFrame->GetDesignSettings().SetGridOrigin( wxPoint( aPoint ) );
499 aView->GetGAL()->SetGridOrigin( aPoint );
500 originViewItem->SetPosition( aPoint );
501 aView->MarkDirty();
502 aFrame->OnModify();
503}
504
505
507{
508 VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
509
510 if( origin )
511 {
512 // We can't undo the other grid dialog settings, so no sense undoing just the origin
513 DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
514 delete origin;
515 }
516 else
517 {
518 if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
519 return 0;
520
522
523 if( !picker ) // Happens in footprint wizard
524 return 0;
525
526 // Deactivate other tools; particularly important if another PICKER is currently running
527 Activate();
528
529 picker->SetClickHandler(
530 [this]( const VECTOR2D& pt ) -> bool
531 {
534 return false; // drill origin is a one-shot; don't continue with tool
535 } );
536
538 }
539
540 return 0;
541}
542
543
545{
548 return 0;
549}
550
551
552#define HITTEST_THRESHOLD_PIXELS 5
553
554
556{
558 return 0;
559
561
562 m_pickerItem = nullptr;
564
565 // Deactivate other tools; particularly important if another PICKER is currently running
566 Activate();
567
568 picker->SetCursor( KICURSOR::REMOVE );
569
570 picker->SetClickHandler(
571 [this]( const VECTOR2D& aPosition ) -> bool
572 {
573 if( m_pickerItem )
574 {
576 {
577 m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
578 m_statusPopup->SetText( _( "Item locked." ) );
579 m_statusPopup->PopupFor( 2000 );
580 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
581 return true;
582 }
583
585 selectionTool->UnbrightenItem( m_pickerItem );
586
587 PCB_SELECTION items;
588 items.Add( m_pickerItem );
589
590 EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
591 editTool->DeleteItems( items, false );
592
593 m_pickerItem = nullptr;
594 }
595
596 return true;
597 } );
598
599 picker->SetMotionHandler(
600 [this]( const VECTOR2D& aPos )
601 {
605 GENERAL_COLLECTOR collector;
606 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
607
609 collector.Collect( board, GENERAL_COLLECTOR::FootprintItems, aPos, guide );
610 else
611 collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, aPos, guide );
612
613 // Remove unselectable items
614 for( int i = collector.GetCount() - 1; i >= 0; --i )
615 {
616 if( !selectionTool->Selectable( collector[ i ] ) )
617 collector.Remove( i );
618 }
619
620 if( collector.GetCount() > 1 )
621 selectionTool->GuessSelectionCandidates( collector, aPos );
622
623 BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
624
625 if( m_pickerItem != item )
626 {
627 if( m_pickerItem )
628 selectionTool->UnbrightenItem( m_pickerItem );
629
630 m_pickerItem = item;
631
632 if( m_pickerItem )
633 selectionTool->BrightenItem( m_pickerItem );
634 }
635 } );
636
637 picker->SetFinalizeHandler(
638 [this]( const int& aFinalState )
639 {
640 if( m_pickerItem )
641 m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
642
643 m_statusPopup.reset();
644
645 // Ensure the cursor gets changed&updated
648 } );
649
651
652 return 0;
653}
654
655
656static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBoard,
657 std::vector<BOARD_ITEM*>& aPastedItems )
658{
659 FOOTPRINT* editorFootprint = aBoard->GetFirstFootprint();
660
661 aClipFootprint->SetParent( aBoard );
662
663 for( PAD* pad : aClipFootprint->Pads() )
664 {
665 pad->SetParent( editorFootprint );
666 aPastedItems.push_back( pad );
667 }
668
669 aClipFootprint->Pads().clear();
670
671 // Not all graphic items can be added to the current footprint:
672 // Reference and value are already existing in the current footprint, and
673 // must be unique.
674 // So they will be skipped
675 for( BOARD_ITEM* item : aClipFootprint->GraphicalItems() )
676 {
677 if( item->Type() == PCB_FP_SHAPE_T || item->Type() == PCB_FP_TEXTBOX_T )
678 {
679 FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
680
681 shape->SetParent( nullptr );
682 shape->SetLocalCoord();
683 }
684 else if( item->Type() == PCB_FP_TEXT_T )
685 {
686 FP_TEXT* text = static_cast<FP_TEXT*>( item );
687
688 if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
689 continue;
690
691 text->SetTextAngle( text->GetTextAngle() + aClipFootprint->GetOrientation() );
692
693 text->SetParent( nullptr );
694 text->SetLocalCoord();
695 }
696
697 item->SetParent( editorFootprint );
698 aPastedItems.push_back( item );
699 }
700
701 aClipFootprint->GraphicalItems().clear();
702
703 for( FP_ZONE* zone : aClipFootprint->Zones() )
704 {
705 zone->SetParent( editorFootprint );
706 aPastedItems.push_back( zone );
707 }
708
709 aClipFootprint->Zones().clear();
710
711 for( PCB_GROUP* group : aClipFootprint->Groups() )
712 {
713 group->SetParent( editorFootprint );
714 aPastedItems.push_back( group );
715 }
716
717 aClipFootprint->Groups().clear();
718}
719
720
721void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
722{
723 LSET enabledLayers = board()->GetEnabledLayers();
724 std::vector<BOARD_ITEM*> returnItems;
725 bool fpItemDeleted = false;
726
727 auto processFPItem =
728 [&]( FOOTPRINT* aFootprint, BOARD_ITEM* aItem )
729 {
730 LSET allowed = aItem->GetLayerSet() & enabledLayers;
731
732 if( allowed.any() )
733 {
734 // Don't prune internal copper layers on items with holes
735 if( aItem->HasHole() && aItem->IsOnCopperLayer() )
736 allowed |= LSET::InternalCuMask();
737
738 aItem->SetLayerSet( allowed );
739 }
740 else
741 {
742 aFootprint->Remove( aItem );
743 fpItemDeleted = true;
744 }
745 };
746
747 for( BOARD_ITEM* item : aItems )
748 {
749 if( item->Type() == PCB_FOOTPRINT_T )
750 {
751 FOOTPRINT* fp = static_cast<FOOTPRINT*>( item );
752
753 if( !enabledLayers.test( fp->Reference().GetLayer() ) )
754 fp->Reference().SetLayer( fp->IsFlipped() ? B_SilkS : F_SilkS );
755
756 if( !enabledLayers.test( fp->Value().GetLayer() ) )
757 fp->Value().SetLayer( fp->IsFlipped() ? B_Fab : F_Fab );
758
759 // NOTE: all traversals from the back as processFPItem() might delete the item
760
761 for( int ii = static_cast<int>( fp->Pads().size() ) - 1; ii >= 0; ii-- )
762 processFPItem( fp, fp->Pads()[ii] );
763
764 for( int ii = static_cast<int>( fp->Zones().size() ) - 1; ii >= 0; ii-- )
765 processFPItem( fp, fp->Zones()[ii] );
766
767 for( int ii = static_cast<int>( fp->GraphicalItems().size() ) - 1; ii >= 0; ii-- )
768 processFPItem( fp, fp->GraphicalItems()[ii] );
769
770 if( fp->GraphicalItems().size() || fp->Pads().size() || fp->Zones().size() )
771 returnItems.push_back( fp );
772 }
773 else if( item->Type() == PCB_GROUP_T )
774 {
775 returnItems.push_back( item );
776 }
777 else
778 {
779 LSET allowed = item->GetLayerSet() & enabledLayers;
780
781 if( allowed.any() )
782 {
783 item->SetLayerSet( allowed );
784 returnItems.push_back( item );
785 }
786 }
787 }
788
789 if( ( returnItems.size() < aItems.size() ) || fpItemDeleted )
790 {
791 DisplayError( m_frame, _( "Warning: some pasted items were on layers which are not "
792 "present in the current board.\n"
793 "These items could not be pasted.\n" ) );
794 }
795
796 aItems = returnItems;
797}
798
799
800int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
801{
802 CLIPBOARD_IO pi;
803 BOARD_ITEM* clipItem = pi.Parse();
804
805 if( !clipItem )
806 return 0;
807
808 // The viewer frames cannot paste
809 if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
810 return 0;
811
813 const wxString defaultRef = wxT( "REF**" );
814
815 if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
816 {
817 DIALOG_PASTE_SPECIAL dlg( m_frame, &mode, defaultRef );
818
819 if( dlg.ShowModal() == wxID_CANCEL )
820 return 0;
821 }
822
823 bool isFootprintEditor = m_isFootprintEditor || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
824
825 if( clipItem->Type() == PCB_T )
826 {
827 if( isFootprintEditor )
828 {
829 for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
830 item->SetNet( NETINFO_LIST::OrphanedItem() );
831 }
832 else
833 {
834 static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
835 }
836 }
837
838 // The clipboard can contain two different things, an entire kicad_pcb or a single footprint
839 if( isFootprintEditor && ( !board() || !footprint() ) )
840 {
841 return 0;
842 }
843
844 switch( clipItem->Type() )
845 {
846 case PCB_T:
847 {
848 BOARD* clipBoard = static_cast<BOARD*>( clipItem );
849
850 if( isFootprintEditor )
851 {
852 FOOTPRINT* editorFootprint = board()->GetFirstFootprint();
853 std::vector<BOARD_ITEM*> pastedItems;
854
855 for( PCB_GROUP* group : clipBoard->Groups() )
856 {
857 group->SetParent( editorFootprint );
858 pastedItems.push_back( group );
859 }
860
861 clipBoard->Groups().clear();
862
863 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
864 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
865
866 for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
867 {
868 if( clipDrawItem->Type() == PCB_SHAPE_T )
869 {
870 PCB_SHAPE* clipShape = static_cast<PCB_SHAPE*>( clipDrawItem );
871 PCB_GROUP* parentGroup = clipDrawItem->GetParentGroup();
872
873 if( parentGroup )
874 parentGroup->RemoveItem( clipDrawItem );
875
876 // Convert to PCB_FP_SHAPE_T
877 FP_SHAPE* pastedShape = new FP_SHAPE( editorFootprint );
878 static_cast<PCB_SHAPE*>( pastedShape )->SwapItemData( clipShape );
879 pastedShape->SetLocalCoord();
880
881 if( parentGroup )
882 parentGroup->AddItem( pastedShape );
883
884 pastedItems.push_back( pastedShape );
885 }
886 else if( clipDrawItem->Type() == PCB_TEXT_T )
887 {
888 PCB_TEXT* clipTextItem = static_cast<PCB_TEXT*>( clipDrawItem );
889 PCB_GROUP* parentGroup = clipDrawItem->GetParentGroup();
890
891 if( parentGroup )
892 parentGroup->RemoveItem( clipDrawItem );
893
894 // Convert to PCB_FP_TEXT_T
895 FP_TEXT* pastedTextItem = new FP_TEXT( editorFootprint );
896 static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
897 static_cast<EDA_TEXT*>( pastedTextItem )->SwapAttributes( *clipTextItem );
898
899 if( parentGroup )
900 parentGroup->AddItem( pastedTextItem );
901
902 pastedItems.push_back( pastedTextItem );
903 }
904 else if( clipDrawItem->Type() == PCB_TEXTBOX_T )
905 {
906 PCB_TEXTBOX* clipTextBox = static_cast<PCB_TEXTBOX*>( clipDrawItem );
907 PCB_GROUP* parentGroup = clipDrawItem->GetParentGroup();
908
909 if( parentGroup )
910 parentGroup->RemoveItem( clipDrawItem );
911
912 // Convert to PCB_FP_TEXTBOX_T
913 FP_TEXTBOX* pastedTextBox = new FP_TEXTBOX( editorFootprint );
914
915 // Handle shape data
916 static_cast<PCB_SHAPE*>( pastedTextBox )->SwapItemData( clipTextBox );
917 pastedTextBox->SetLocalCoord();
918
919 // Handle text data
920 static_cast<EDA_TEXT*>( pastedTextBox )->SwapText( *clipTextBox );
921 static_cast<EDA_TEXT*>( pastedTextBox )->SwapAttributes( *clipTextBox );
922
923 if( parentGroup )
924 parentGroup->AddItem( pastedTextBox );
925
926 pastedItems.push_back( pastedTextBox );
927 }
928 }
929
930 delete clipBoard;
931
932 pruneItemLayers( pastedItems );
933
934 placeBoardItems( pastedItems, true, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
935 }
936 else
937 {
939 {
940 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
941 clipFootprint->SetReference( defaultRef );
942 }
943
944 placeBoardItems( clipBoard, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
945 }
946
947 break;
948 }
949
950 case PCB_FOOTPRINT_T:
951 {
952 FOOTPRINT* clipFootprint = static_cast<FOOTPRINT*>( clipItem );
953 std::vector<BOARD_ITEM*> pastedItems;
954
955 if( isFootprintEditor )
956 {
957 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
958 delete clipFootprint;
959 }
960 else
961 {
963 clipFootprint->SetReference( defaultRef );
964
965 clipFootprint->SetParent( board() );
966 pastedItems.push_back( clipFootprint );
967 }
968
969 pruneItemLayers( pastedItems );
970
971 placeBoardItems( pastedItems, true, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
972 break;
973 }
974
975 default:
976 m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
977 break;
978 }
979
980 return 1;
981}
982
983
985{
986 int open_ctl;
987 wxString fileName;
988
989 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
990
991 if( !editFrame )
992 return 1;
993
994 // Pick a file to append
995 if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
996 return 1;
997
998 IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
999 PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
1000
1001 return AppendBoard( *pi, fileName );
1002}
1003
1004
1005// Helper function for PCB_CONTROL::placeBoardItems()
1006template<typename T>
1007static void moveUnflaggedItems( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
1008 bool aIsNew )
1009{
1010 std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
1011 [aIsNew]( T aItem )
1012 {
1013 bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
1014
1015 aItem->ClearFlags( SKIP_STRUCT );
1016 aItem->SetFlags( aIsNew ? IS_NEW : 0 );
1017
1018 return doCopy;
1019 } );
1020
1021 if( aIsNew )
1022 aList.clear();
1023}
1024
1025
1026static void moveUnflaggedItems( ZONES& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
1027{
1028 if( aList.size() == 0 )
1029 return;
1030
1031 auto obj = aList.front();
1032 int idx = 0;
1033
1034 if( aIsNew )
1035 {
1036 obj = aList.back();
1037 aList.pop_back();
1038 }
1039
1040 for( ; obj ; )
1041 {
1042 if( obj->HasFlag( SKIP_STRUCT ) )
1043 obj->ClearFlags( SKIP_STRUCT );
1044 else
1045 aTarget.push_back( obj );
1046
1047 if( aIsNew )
1048 {
1049 if( aList.size() )
1050 {
1051 obj = aList.back();
1052 aList.pop_back();
1053 }
1054 else
1055 {
1056 obj = nullptr;
1057 }
1058 }
1059 else
1060 {
1061 obj = idx < int(aList.size()-1) ? aList[++idx] : nullptr;
1062 }
1063 }
1064}
1065
1066
1067
1068int PCB_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin, bool aReannotateDuplicates )
1069{
1070 // items are new if the current board is not the board source
1071 bool isNew = board() != aBoard;
1072 std::vector<BOARD_ITEM*> items;
1073
1074 moveUnflaggedItems( aBoard->Tracks(), items, isNew );
1075 moveUnflaggedItems( aBoard->Footprints(), items, isNew );
1076 moveUnflaggedItems( aBoard->Drawings(), items, isNew );
1077 moveUnflaggedItems( aBoard->Zones(), items, isNew );
1078
1079 // Subtlety: When selecting a group via the mouse,
1080 // PCB_SELECTION_TOOL::highlightInternal runs, which does a SetSelected() on all
1081 // descendants. In PCB_CONTROL::placeBoardItems, below, we skip that and
1082 // mark items non-recursively. That works because the saving of the
1083 // selection created aBoard that has the group and all descendants in it.
1084 moveUnflaggedItems( aBoard->Groups(), items, isNew );
1085
1086 pruneItemLayers( items );
1087
1088 return placeBoardItems( items, isNew, aAnchorAtOrigin, aReannotateDuplicates );
1089}
1090
1091
1092int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
1093 bool aAnchorAtOrigin, bool aReannotateDuplicates )
1094{
1096
1098 EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
1099
1100 std::vector<BOARD_ITEM*> itemsToSel;
1101 itemsToSel.reserve( aItems.size() );
1102
1103 auto updateDimensionUnits =
1104 [this]( PCB_DIMENSION_BASE* dimension )
1105 {
1106 // Dimensions need to have their units updated if they are automatic
1107 if( dimension->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC )
1108 dimension->SetUnits( frame()->GetUserUnits() );
1109 };
1110
1111 for( BOARD_ITEM* item : aItems )
1112 {
1113 if( aIsNew )
1114 {
1115 const_cast<KIID&>( item->m_Uuid ) = KIID();
1116
1117 // Even though BOARD_COMMIT::Push() will add any new items to the group, we're
1118 // going to run PCB_ACTIONS::move first, and the move tool will throw out any
1119 // items that aren't in the entered group.
1120 if( selectionTool->GetEnteredGroup() && !item->GetParentGroup() )
1121 selectionTool->GetEnteredGroup()->AddItem( item );
1122 }
1123
1124 // Update item attributes if needed
1125 if( BaseType( item->Type() ) == PCB_DIMENSION_T )
1126 {
1127 updateDimensionUnits( static_cast<PCB_DIMENSION_BASE*>( item ) );
1128 }
1129 else if( item->Type() == PCB_FOOTPRINT_T )
1130 {
1131 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
1132
1133 // Update the footprint path with the new KIID path if the footprint is new
1134 if( aIsNew )
1136
1137 for( BOARD_ITEM* dwg : footprint->GraphicalItems() )
1138 {
1139 if( BaseType( dwg->Type() ) == PCB_DIMENSION_T )
1140 updateDimensionUnits( static_cast<PCB_DIMENSION_BASE*>( dwg ) );
1141 }
1142 }
1143
1144 // We only need to add the items that aren't inside a group currently selected
1145 // to the selection. If an item is inside a group and that group is selected,
1146 // then the selection tool will select it for us.
1147 if( !item->GetParentGroup() || !alg::contains( aItems, item->GetParentGroup() ) )
1148 itemsToSel.push_back( item );
1149 }
1150
1151 // Select the items that should be selected
1152 m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &itemsToSel );
1153
1154 // Reannotate duplicate footprints (make sense only in board editor )
1155 if( aReannotateDuplicates && m_isBoardEditor )
1156 m_toolMgr->GetTool<BOARD_REANNOTATE_TOOL>()->ReannotateDuplicatesInSelection();
1157
1158 for( BOARD_ITEM* item : aItems )
1159 {
1160 // Commit after reannotation
1161 if( aIsNew )
1162 editTool->GetCurrentCommit()->Add( item );
1163 else
1164 editTool->GetCurrentCommit()->Added( item );
1165 }
1166
1167 PCB_SELECTION& selection = selectionTool->GetSelection();
1168
1169 if( selection.Size() > 0 )
1170 {
1171 if( aAnchorAtOrigin )
1172 {
1174 }
1175 else
1176 {
1177 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
1179 }
1180
1181 getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
1182
1185 }
1186
1187 return 0;
1188}
1189
1190
1191int PCB_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
1192{
1193 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1194
1195 if( !editFrame )
1196 return 1;
1197
1198 BOARD* brd = board();
1199
1200 if( !brd )
1201 return 1;
1202
1203 // Mark existing items, in order to know what are the new items so we can select only
1204 // the new items after loading
1205 for( PCB_TRACK* track : brd->Tracks() )
1206 track->SetFlags( SKIP_STRUCT );
1207
1208 for( FOOTPRINT* footprint : brd->Footprints() )
1210
1211 for( PCB_GROUP* group : brd->Groups() )
1212 group->SetFlags( SKIP_STRUCT );
1213
1214 for( BOARD_ITEM* drawing : brd->Drawings() )
1215 drawing->SetFlags( SKIP_STRUCT );
1216
1217 for( ZONE* zone : brd->Zones() )
1218 zone->SetFlags( SKIP_STRUCT );
1219
1220 std::map<wxString, wxString> oldProperties = brd->GetProperties();
1221 std::map<wxString, wxString> newProperties;
1222
1223 PAGE_INFO oldPageInfo = brd->GetPageSettings();
1224 TITLE_BLOCK oldTitleBlock = brd->GetTitleBlock();
1225
1226 // Keep also the count of copper layers, to adjust if necessary
1227 int initialCopperLayerCount = brd->GetCopperLayerCount();
1228 LSET initialEnabledLayers = brd->GetEnabledLayers();
1229
1230 // Load the data
1231 try
1232 {
1233 STRING_UTF8_MAP props;
1234 char xbuf[30];
1235 char ybuf[30];
1236
1237 // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
1238 sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
1239 sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
1240
1241 props["page_width"] = xbuf;
1242 props["page_height"] = ybuf;
1243
1245 [&]( wxString aTitle, int aIcon, wxString aMessage, wxString aAction ) -> bool
1246 {
1247 KIDIALOG dlg( editFrame, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
1248
1249 if( !aAction.IsEmpty() )
1250 dlg.SetOKLabel( aAction );
1251
1252 dlg.DoNotShowCheckbox( aMessage, 0 );
1253
1254 return dlg.ShowModal() == wxID_OK;
1255 } );
1256
1257 WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Loading PCB" ), 1 );
1258
1259 editFrame->GetDesignSettings().m_NetSettings->m_NetClasses.clear();
1260 pi.Load( fileName, brd, &props, nullptr, &progressReporter );
1261 }
1262 catch( const IO_ERROR& ioe )
1263 {
1264 wxString msg = wxString::Format( _( "Error loading board.\n%s" ), ioe.What() );
1265 DisplayError( editFrame, msg );
1266
1267 return 0;
1268 }
1269
1270 newProperties = brd->GetProperties();
1271
1272 for( const std::pair<const wxString, wxString>& prop : oldProperties )
1273 newProperties[ prop.first ] = prop.second;
1274
1275 brd->SetProperties( newProperties );
1276
1277 brd->SetPageSettings( oldPageInfo );
1278 brd->SetTitleBlock( oldTitleBlock );
1279
1280 // rebuild nets and ratsnest before any use of nets
1281 brd->BuildListOfNets();
1282 brd->SynchronizeNetsAndNetClasses( true );
1283 brd->BuildConnectivity();
1284
1285 // Synchronize layers
1286 // we should not ask PLUGINs to do these items:
1287 int copperLayerCount = brd->GetCopperLayerCount();
1288
1289 if( copperLayerCount > initialCopperLayerCount )
1290 brd->SetCopperLayerCount( copperLayerCount );
1291
1292 // Enable all used layers, and make them visible:
1293 LSET enabledLayers = brd->GetEnabledLayers();
1294 enabledLayers |= initialEnabledLayers;
1295 brd->SetEnabledLayers( enabledLayers );
1296 brd->SetVisibleLayers( enabledLayers );
1297
1298 return placeBoardItems( brd, false, false ); // Do not reannotate duplicates on Append Board
1299}
1300
1301
1302int PCB_CONTROL::Undo( const TOOL_EVENT& aEvent )
1303{
1304 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1305 wxCommandEvent dummy;
1306
1307 if( editFrame )
1308 editFrame->RestoreCopyFromUndoList( dummy );
1309
1310 return 0;
1311}
1312
1313
1314int PCB_CONTROL::Redo( const TOOL_EVENT& aEvent )
1315{
1316 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1317 wxCommandEvent dummy;
1318
1319 if( editFrame )
1320 editFrame->RestoreCopyFromRedoList( dummy );
1321
1322 return 0;
1323}
1324
1325
1327{
1329 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
1330 PCB_SELECTION& selection = selTool->GetSelection();
1331 PCB_EDIT_FRAME* pcbFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1332 std::shared_ptr<DRC_ENGINE> drcEngine = m_frame->GetBoard()->GetDesignSettings().m_DRCEngine;
1333 DRC_CONSTRAINT constraint;
1334
1335 std::vector<MSG_PANEL_ITEM> msgItems;
1336
1337 if( routerTool && routerTool->RoutingInProgress() )
1338 {
1339 routerTool->UpdateMessagePanel();
1340 return 0;
1341 }
1342
1343 if( !pcbFrame && !m_frame->GetModel() )
1344 return 0;
1345
1346 if( selection.Empty() )
1347 {
1348 if( !pcbFrame )
1349 {
1350 FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_frame->GetModel() );
1351 size_t padCount = fp->GetPadCount( DO_NOT_INCLUDE_NPTH );
1352
1353 msgItems.emplace_back( _( "Library" ), fp->GetFPID().GetLibNickname().wx_str() );
1354
1355 msgItems.emplace_back( _( "Footprint Name" ), fp->GetFPID().GetLibItemName().wx_str() );
1356
1357 msgItems.emplace_back( _( "Pads" ), wxString::Format( wxT( "%zu" ), padCount ) );
1358
1359 msgItems.emplace_back( wxString::Format( _( "Doc: %s" ), fp->GetDescription() ),
1360 wxString::Format( _( "Keywords: %s" ), fp->GetKeywords() ) );
1361 }
1362 else
1363 {
1365 }
1366 }
1367 else if( selection.GetSize() == 1 )
1368 {
1369 EDA_ITEM* item = selection.Front();
1370
1371 item->GetMsgPanelInfo( m_frame, msgItems );
1372 }
1373 else if( pcbFrame && selection.GetSize() == 2 )
1374 {
1375 // Pair selection broken into multiple, optional data, starting with the selected item
1376 // names
1377
1378 BOARD_ITEM* a = static_cast<BOARD_ITEM*>( selection[0] );
1379 BOARD_ITEM* b = static_cast<BOARD_ITEM*>( selection[1] );
1380
1381 msgItems.emplace_back( MSG_PANEL_ITEM( a->GetSelectMenuText( m_frame ),
1382 b->GetSelectMenuText( m_frame ) ) );
1383
1384 BOARD_CONNECTED_ITEM* a_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( a );
1385 BOARD_CONNECTED_ITEM* b_conn = dyn_cast<BOARD_CONNECTED_ITEM*>( b );
1386
1387 if( a_conn && b_conn )
1388 {
1389 LSET overlap = a_conn->GetLayerSet() & b_conn->GetLayerSet() & LSET::AllCuMask();
1390 int a_netcode = a_conn->GetNetCode();
1391 int b_netcode = b_conn->GetNetCode();
1392
1393 if( overlap.count() > 0
1394 && ( a_netcode != b_netcode || a_netcode < 0 || b_netcode < 0 ) )
1395 {
1396 PCB_LAYER_ID layer = overlap.CuStack().front();
1397
1398 constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b, layer );
1399
1400 std::shared_ptr<SHAPE> a_shape( a_conn->GetEffectiveShape( layer ) );
1401 std::shared_ptr<SHAPE> b_shape( b_conn->GetEffectiveShape( layer ) );
1402
1403 int actual_clearance = a_shape->GetClearance( b_shape.get() );
1404
1405 msgItems.emplace_back( _( "Resolved clearance" ),
1406 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1407
1408 if( actual_clearance > -1 && actual_clearance < std::numeric_limits<int>::max() )
1409 {
1410 msgItems.emplace_back( _( "Actual clearance" ),
1411 m_frame->MessageTextFromValue( actual_clearance ) );
1412 }
1413 }
1414 }
1415
1416 if( ( a->HasHole() || b->HasHole() ) )
1417 {
1420
1421 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1422 layer = active;
1423 else if( b->HasHole() && a->IsOnLayer( active ) && IsCopperLayer( active ) )
1424 layer = active;
1425 else if( a->HasHole() && b->IsOnCopperLayer() )
1426 layer = b->GetLayer();
1427 else if( b->HasHole() && a->IsOnCopperLayer() )
1428 layer = a->GetLayer();
1429
1430 if( IsCopperLayer( layer ) )
1431 {
1432 int actual = std::numeric_limits<int>::max();
1433
1434 if( a->HasHole() && b->IsOnCopperLayer() )
1435 {
1436 std::shared_ptr<SHAPE_SEGMENT> hole = a->GetEffectiveHoleShape();
1437 std::shared_ptr<SHAPE> other( b->GetEffectiveShape( layer ) );
1438
1439 actual = std::min( actual, hole->GetClearance( other.get() ) );
1440 }
1441
1442 if( b->HasHole() && a->IsOnCopperLayer() )
1443 {
1444 std::shared_ptr<SHAPE_SEGMENT> hole = b->GetEffectiveHoleShape();
1445 std::shared_ptr<SHAPE> other( a->GetEffectiveShape( layer ) );
1446
1447 actual = std::min( actual, hole->GetClearance( other.get() ) );
1448 }
1449
1450 if( actual < std::numeric_limits<int>::max() )
1451 {
1452 constraint = drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, a, b, layer );
1453 msgItems.emplace_back( _( "Resolved hole clearance" ),
1454 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1455
1456 if( actual > -1 && actual < std::numeric_limits<int>::max() )
1457 {
1458 msgItems.emplace_back( _( "Actual hole clearance" ),
1459 m_frame->MessageTextFromValue( actual ) );
1460 }
1461 }
1462 }
1463 }
1464
1465 for( PCB_LAYER_ID edgeLayer : { Edge_Cuts, Margin } )
1466 {
1469
1470 if( a->IsOnLayer( edgeLayer ) && b->Type() != PCB_FOOTPRINT_T )
1471 {
1472 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1473 layer = active;
1474 else if( IsCopperLayer( b->GetLayer() ) )
1475 layer = b->GetLayer();
1476 }
1477 else if( b->IsOnLayer( edgeLayer ) && a->Type() != PCB_FOOTPRINT_T )
1478 {
1479 if( a->IsOnLayer( active ) && IsCopperLayer( active ) )
1480 layer = active;
1481 else if( IsCopperLayer( a->GetLayer() ) )
1482 layer = a->GetLayer();
1483 }
1484
1485 if( layer >= 0 )
1486 {
1487 constraint = drcEngine->EvalRules( EDGE_CLEARANCE_CONSTRAINT, a, b, layer );
1488
1489 if( edgeLayer == Edge_Cuts )
1490 {
1491 msgItems.emplace_back( _( "Resolved edge clearance" ),
1492 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1493 }
1494 else
1495 {
1496 msgItems.emplace_back( _( "Resolved margin clearance" ),
1497 m_frame->MessageTextFromValue( constraint.m_Value.Min() ) );
1498 }
1499 }
1500 }
1501 }
1502
1503 if( msgItems.empty() )
1504 {
1505 if( selection.GetSize() )
1506 {
1507 msgItems.emplace_back( _( "Selected Items" ),
1508 wxString::Format( wxT( "%d" ), selection.GetSize() ) );
1509
1510 std::set<wxString> netNames;
1511 std::set<wxString> netClasses;
1512
1513 for( EDA_ITEM* item : selection )
1514 {
1515 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
1516 {
1517 netNames.insert( UnescapeString( bci->GetNetname() ) );
1518 netClasses.insert( UnescapeString( bci->GetEffectiveNetClass()->GetName() ) );
1519
1520 if( netNames.size() > 1 && netClasses.size() > 1 )
1521 break;
1522 }
1523 }
1524
1525 if( netNames.size() == 1 )
1526 msgItems.emplace_back( _( "Net" ), *netNames.begin() );
1527
1528 if( netClasses.size() == 1 )
1529 msgItems.emplace_back( _( "Resolved Netclass" ), *netClasses.begin() );
1530 }
1531 else
1532 {
1533 m_frame->GetBoard()->GetMsgPanelInfo( m_frame, msgItems );
1534 }
1535 }
1536
1537 m_frame->SetMsgPanel( msgItems );
1538
1539 return 0;
1540}
1541
1542
1544{
1545 wxFileName fileName = wxFileName( *aEvent.Parameter<wxString*>() );
1546
1547 int open_ctl = fileName.GetExt() == KiCadPcbFileExtension ? 0 : KICTL_EAGLE_BRD;
1548
1549 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1550
1551 if( !editFrame )
1552 return 1;
1553
1554 wxString filePath = fileName.GetFullPath();
1555 IO_MGR::PCB_FILE_T pluginType = plugin_type( filePath, open_ctl );
1556 PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
1557
1558 return AppendBoard( *pi, filePath );
1559}
1560
1561
1563{
1564 view()->SetMirror( !view()->IsMirroredX(), false );
1565 view()->RecacheAllItems();
1568 return 0;
1569}
1570
1571
1573{
1576 Go( &PCB_CONTROL::Print, ACTIONS::print.MakeEvent() );
1577 Go( &PCB_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1578
1579 // Display modes
1594
1595 // Layer control
1633
1634 // Grid control
1637
1638 Go( &PCB_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1639 Go( &PCB_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1640
1641 // Miscellaneous
1643
1644 // Append control
1647
1648 Go( &PCB_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1650
1657
1658 // Add library by dropping file
1661}
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
@ HIDDEN
Inactive layers are hidden.
@ DIMMED
Inactive layers are dimmed (old high-contrast mode)
@ RATSNEST
Net/netclass colors are shown on ratsnest lines only.
@ ALL
Net/netclass colors are shown on all net copper.
@ OFF
Net (and netclass) colors are not shown.
@ VISIBLE
Ratsnest lines are drawn to items on visible layers only.
@ ALL
Ratsnest lines are drawn to items on all layers (default)
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION addLibrary
Definition: actions.h:49
static TOOL_ACTION pickerTool
Definition: actions.h:158
static TOOL_ACTION gridResetOrigin
Definition: actions.h:141
static TOOL_ACTION pasteSpecial
Definition: actions.h:70
static TOOL_ACTION highContrastModeCycle
Definition: actions.h:106
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION highContrastMode
Definition: actions.h:105
static TOOL_ACTION quit
Definition: actions.h:59
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION deleteTool
Definition: actions.h:74
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION newLibrary
Definition: actions.h:48
static TOOL_ACTION gridSetOrigin
Definition: actions.h:140
static TOOL_ACTION ddAddLibrary
Definition: actions.h:60
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:58
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:180
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:72
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:245
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:214
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:219
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:185
virtual bool IsLocked() const
Definition: board_item.cpp:71
virtual bool IsOnCopperLayer() const
Definition: board_item.h:123
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
Definition: board_item.cpp:229
virtual bool HasHole() const
Definition: board_item.h:128
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:526
void BuildListOfNets()
Definition: board.h:744
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:546
const PAGE_INFO & GetPageSettings() const
Definition: board.h:626
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: board.h:333
ZONES & Zones()
Definition: board.h:313
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1485
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:397
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:632
FOOTPRINTS & Footprints()
Definition: board.h:307
int GetCopperLayerCount() const
Definition: board.cpp:502
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:332
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:327
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:627
TRACKS & Tracks()
Definition: board.h:304
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:558
void SetCopperLayerCount(int aCount)
Definition: board.cpp:508
DRAWINGS & Drawings()
Definition: board.h:310
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:532
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:1253
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:643
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:634
void BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition: board.cpp:162
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
MINOPTMAX< int > m_Value
Definition: drc_rule.h:170
bool IsType(FRAME_T aType) const
WX_INFOBAR * GetInfoBar()
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.
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
Update the board display after modifying it by a python script (note: it is automatically called by a...
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:251
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:252
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:142
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:211
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
virtual wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: eda_item.cpp:108
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
The interactive edit tool.
Definition: edit_tool.h:65
void DeleteItems(const PCB_SELECTION &aItems, bool aIsCut)
Definition: edit_tool.cpp:1797
static const TOOL_EVENT ClearedEvent
Definition: actions.h:208
static const TOOL_EVENT SelectedEvent
Definition: actions.h:206
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:213
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:205
static const TOOL_EVENT ConnectivityChangedEvent
Selected item had a property changed (except movement)
Definition: actions.h:210
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:207
EDA_ANGLE GetOrientation() const
Definition: footprint.h:191
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: footprint.cpp:621
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of pads.
Definition: footprint.cpp:1198
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:225
wxString GetDescription() const
Definition: footprint.h:218
FP_GROUPS & Groups()
Definition: footprint.h:179
bool IsFlipped() const
Definition: footprint.h:324
PADS & Pads()
Definition: footprint.h:170
const LIB_ID & GetFPID() const
Definition: footprint.h:212
void SetReference(const wxString &aReference)
Definition: footprint.h:528
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:567
FP_ZONES & Zones()
Definition: footprint.h:176
wxString GetKeywords() const
Definition: footprint.h:221
DRAWINGS & GraphicalItems()
Definition: footprint.h:173
FP_TEXT & Reference()
Definition: footprint.h:568
virtual void SetLocalCoord()
Set relative coordinates from draw coordinates.
Definition: fp_shape.cpp:52
@ TEXT_is_DIVERS
Definition: fp_text.h:51
A specialization of ZONE for use in footprints.
Definition: zone.h:910
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:326
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
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:596
static const std::vector< KICAD_T > FootprintItems
A scan list for primary footprint items.
Definition: collectors.h:250
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 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:58
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:46
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:387
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:92
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:69
void SetMirror(bool aMirrorX, bool aMirrorY)
Control the mirroring of the VIEW.
Definition: view.cpp:535
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:346
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:195
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1381
void UpdateLayerColor(int aLayer)
Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.
Definition: view.cpp:737
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:641
Definition: kiid.h:48
const UTF8 & GetLibItemName() const
Definition: lib_id.h:101
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
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()
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString,...
Definition: netinfo.h:381
Definition: pad.h:59
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:322
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:298
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:294
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:282
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:289
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:319
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:271
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:340
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:288
static TOOL_ACTION ddAppendBoard
Drag and drop.
Definition: pcb_actions.h:524
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:311
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:321
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:278
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:310
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:277
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:315
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:297
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:320
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:302
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:312
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:304
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:300
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:275
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:292
static TOOL_ACTION ddImportFootprint
Definition: pcb_actions.h:525
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:281
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:308
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:291
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:280
static TOOL_ACTION ratsnestModeCycle
Definition: pcb_actions.h:274
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:306
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:293
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:313
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:482
static TOOL_ACTION netColorModeCycle
Definition: pcb_actions.h:273
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:287
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:296
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:301
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:303
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:326
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:317
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:279
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:272
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:305
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:295
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:110
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:316
static TOOL_ACTION layerTop
Definition: pcb_actions.h:286
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Definition: pcb_actions.h:66
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:290
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:299
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:307
static TOOL_ACTION layerNext
Definition: pcb_actions.h:318
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:309
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:314
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:313
void RestoreCopyFromRedoList(wxCommandEvent &aEvent)
Redo the last edit:
Definition: undo_redo.cpp:343
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...
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 ...
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
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)=0
Create a new entry in undo list of commands.
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 placeBoardItems(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 DdImportFootprint(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:147
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:143
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:140
int GridSetOrigin(const TOOL_EVENT &aEvent)
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 FlipPcbView(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:88
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:145
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.
Definition: pcb_dimension.h:96
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.
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:95
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:80
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:564
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:285
virtual BOARD * Load(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:46
void BrightenItem(EDA_ITEM *aItem)
void UnbrightenItem(EDA_ITEM *aItem)
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:32
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:97
EDA_ITEM * Front() const
Definition: selection.h:206
int Size() const
Returns the number of selected parts.
Definition: selection.h:113
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:258
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:107
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:214
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
@ MODEL_RELOAD
Model changes (required full reload)
Definition: tool_base.h:80
@ GAL_SWITCH
Rendering engine changes.
Definition: tool_base.h:81
Generic, UI-independent tool event.
Definition: tool_event.h:156
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
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:88
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).
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
EDA_UNITS GetUserUnits() const
wxString wx_str() const
Definition: utf8.cpp:46
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:75
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:286
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: infobar.cpp:128
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:245
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
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:57
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.
@ REMOVE_ANNOTATIONS
@ UNIQUE_ANNOTATIONS
@ EDGE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:49
@ CLEARANCE_CONSTRAINT
Definition: drc_rule.h:46
@ HOLE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:47
std::vector< ZONE * > ZONES
Definition: eagle_plugin.h:44
#define _(s)
#define SKIP_STRUCT
flag indicating that the structure should be ignored
@ DO_NOT_INCLUDE_NPTH
Definition: footprint.h:57
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
const std::string KiCadPcbFileExtension
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
#define KICTL_EAGLE_BRD
chosen *.brd file is Eagle according to user.
Definition: kiway_player.h:81
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:966
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:825
@ LAYER_RATSNEST
Definition: layer_ids.h:204
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ Edge_Cuts
Definition: layer_ids.h:113
@ B_Cu
Definition: layer_ids.h:95
@ F_Fab
Definition: layer_ids.h:120
@ Margin
Definition: layer_ids.h:114
@ F_SilkS
Definition: layer_ids.h:104
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ B_SilkS
Definition: layer_ids.h:103
@ F_Cu
Definition: layer_ids.h:64
@ B_Fab
Definition: layer_ids.h:119
#define ZONE_LAYER_FOR(boardLayer)
Definition: layer_ids.h:268
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:932
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:52
SGLIB_API S3DMODEL * GetModel(SCENEGRAPH *aNode)
Function GetModel creates an S3DMODEL representation of aNode (raw data, no transforms)
Definition: ifsg_api.cpp:338
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
#define HITTEST_THRESHOLD_PIXELS
#define ALPHA_STEP
static void pasteFootprintItemsToFootprintEditor(FOOTPRINT *aClipFootprint, BOARD *aBoard, std::vector< BOARD_ITEM * > &aPastedItems)
bool AskLoadBoardFileName(PCB_EDIT_FRAME *aParent, int *aCtl, wxString *aFileName, bool aKicadFilesOnly=false)
Show a wxFileDialog asking for a BOARD filename to open.
static void moveUnflaggedItems(std::deque< T > &aList, std::vector< BOARD_ITEM * > &aTarget, bool aIsNew)
#define ALPHA_MAX
#define ALPHA_MIN
IO_MGR::PCB_FILE_T plugin_type(const wxString &aFileName, int aCtl)
void Flip(T &aValue)
see class PGM_BASE
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
wxString UnescapeString(const wxString &aSource)
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
Definition: typeinfo.h:253
@ PCB_T
Definition: typeinfo.h:82
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
Definition: typeinfo.h:105
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
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:618
Definition of file extensions used in Kicad.