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/wx_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 || aReason == REDRAW )
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
180 canvas()->Refresh();
181
182 return 0;
183}
184
185
187{
188 Flip( displayOptions().m_DisplayViaFill );
189
190 for( PCB_TRACK* track : board()->Tracks() )
191 {
192 if( track->Type() == PCB_VIA_T )
193 view()->Update( track, KIGFX::REPAINT );
194 }
195
196 canvas()->Refresh();
197
198 return 0;
199}
200
201
208{
209 if( Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning )
210 return;
211
212 bool unfilledZones = false;
213
214 for( const ZONE* zone : board()->Zones() )
215 {
216 if( !zone->GetIsRuleArea() && !zone->IsFilled() )
217 {
218 unfilledZones = true;
219 break;
220 }
221 }
222
223 if( unfilledZones )
224 {
225 WX_INFOBAR* infobar = frame()->GetInfoBar();
226 wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Don't show again" ),
227 wxEmptyString );
228
229 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
230 [&]( wxHyperlinkEvent& aEvent )
231 {
232 Pgm().GetCommonSettings()->m_DoNotShowAgain.zone_fill_warning = true;
233 frame()->GetInfoBar()->Dismiss();
234 } ) );
235
236 infobar->RemoveAllButtons();
237 infobar->AddButton( button );
238
239 wxString msg;
240 msg.Printf( _( "Not all zones are filled. Use Edit > Fill All Zones (%s) "
241 "if you wish to see all fills." ),
243
244 infobar->ShowMessageFor( msg, 5000, wxICON_WARNING );
245 }
246}
247
248
250{
252
253 // Apply new display options to the GAL canvas
255 {
257
259 }
260 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutline ) )
261 {
263 }
264 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayFractured ) )
265 {
267 }
269 {
271 }
272 else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
273 {
276 else
278 }
279 else
280 {
281 wxFAIL;
282 }
283
284 m_frame->SetDisplayOptions( opts );
285
286 for( ZONE* zone : board()->Zones() )
287 view()->Update( zone, KIGFX::REPAINT );
288
289 canvas()->Refresh();
290
291 return 0;
292}
293
294
296{
298
302
303 m_frame->SetDisplayOptions( opts );
304
305 return 0;
306}
307
308
310{
312
313 switch( opts.m_ContrastModeDisplay )
314 {
318 }
319
320 m_frame->SetDisplayOptions( opts );
321
322 return 0;
323}
324
325
327{
329
330 switch( opts.m_NetColorMode )
331 {
335 }
336
337 m_frame->SetDisplayOptions( opts );
338
339 return 0;
340}
341
342
344{
345 if( !displayOptions().m_ShowGlobalRatsnest )
346 {
349 }
350 else if( displayOptions().m_RatsnestMode == RATSNEST_MODE::ALL )
351 {
353 }
354 else
355 {
357 }
358
359 getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
360 displayOptions().m_ShowGlobalRatsnest );
361
363
365 canvas()->Refresh();
366 return 0;
367}
368
369
371{
373
374 return 0;
375}
376
377
379{
380 PCB_BASE_FRAME* editFrame = m_frame;
381 BOARD* brd = board();
382 int layer = editFrame->GetActiveLayer();
383 int startLayer = layer;
384
385 while( startLayer != ++layer )
386 {
387 if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
388 break;
389
390 if( layer >= B_Cu )
391 layer = F_Cu - 1;
392 }
393
394 wxCHECK( IsCopperLayer( layer ), 0 );
395 editFrame->SwitchLayer( ToLAYER_ID( layer ) );
396
397 return 0;
398}
399
400
402{
403 PCB_BASE_FRAME* editFrame = m_frame;
404 BOARD* brd = board();
405 int layer = editFrame->GetActiveLayer();
406 int startLayer = layer;
407
408 while( startLayer != --layer )
409 {
410 if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
411 && brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
412 {
413 break;
414 }
415
416 if( layer <= F_Cu )
417 layer = B_Cu + 1;
418 }
419
420 wxCHECK( IsCopperLayer( layer ), 0 );
421 editFrame->SwitchLayer( ToLAYER_ID( layer ) );
422
423 return 0;
424}
425
426
428{
429 int currentLayer = m_frame->GetActiveLayer();
430 PCB_SCREEN* screen = m_frame->GetScreen();
431
432 if( currentLayer == screen->m_Route_Layer_TOP )
434 else
436
437 return 0;
438}
439
440
441// It'd be nice to share the min/max with the DIALOG_COLOR_PICKER, but those are
442// set in wxFormBuilder.
443#define ALPHA_MIN 0.20
444#define ALPHA_MAX 1.00
445#define ALPHA_STEP 0.05
446
447
449{
451 int currentLayer = m_frame->GetActiveLayer();
452 KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
453
454 if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
455 {
456 currentColor.a += ALPHA_STEP;
457 settings->SetColor( currentLayer, currentColor );
459
461 view->UpdateLayerColor( currentLayer );
462 view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
463
464 if( IsCopperLayer( currentLayer ) )
465 view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
466 }
467 else
468 {
469 wxBell();
470 }
471
472 return 0;
473}
474
475
477{
479 int currentLayer = m_frame->GetActiveLayer();
480 KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
481
482 if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
483 {
484 currentColor.a -= ALPHA_STEP;
485 settings->SetColor( currentLayer, currentColor );
487
489 view->UpdateLayerColor( currentLayer );
490 view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
491
492 if( IsCopperLayer( currentLayer ) )
493 view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
494 }
495 else
496 {
497 wxBell();
498 }
499
500 return 0;
501}
502
503
505 EDA_ITEM* originViewItem, const VECTOR2D& aPoint )
506{
507 aFrame->GetDesignSettings().SetGridOrigin( VECTOR2I( aPoint ) );
508 aView->GetGAL()->SetGridOrigin( aPoint );
509 originViewItem->SetPosition( aPoint );
510 aView->MarkDirty();
511 aFrame->OnModify();
512}
513
514
516{
517 VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
518
519 if( origin )
520 {
521 // We can't undo the other grid dialog settings, so no sense undoing just the origin
522 DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
523 delete origin;
524 }
525 else
526 {
527 if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
528 return 0;
529
531
532 if( !picker ) // Happens in footprint wizard
533 return 0;
534
535 // Deactivate other tools; particularly important if another PICKER is currently running
536 Activate();
537
538 picker->SetClickHandler(
539 [this]( const VECTOR2D& pt ) -> bool
540 {
543 return false; // drill origin is a one-shot; don't continue with tool
544 } );
545
547 }
548
549 return 0;
550}
551
552
554{
557 return 0;
558}
559
560
561#define HITTEST_THRESHOLD_PIXELS 5
562
563
565{
567 return 0;
568
570
571 m_pickerItem = nullptr;
573
574 // Deactivate other tools; particularly important if another PICKER is currently running
575 Activate();
576
577 picker->SetCursor( KICURSOR::REMOVE );
578
579 picker->SetClickHandler(
580 [this]( const VECTOR2D& aPosition ) -> bool
581 {
582 if( m_pickerItem )
583 {
585 {
586 m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
587 m_statusPopup->SetText( _( "Item locked." ) );
588 m_statusPopup->PopupFor( 2000 );
589 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
590 return true;
591 }
592
594 selectionTool->UnbrightenItem( m_pickerItem );
595
596 PCB_SELECTION items;
597 items.Add( m_pickerItem );
598
599 EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
600 editTool->DeleteItems( items, false );
601
602 m_pickerItem = nullptr;
603 }
604
605 return true;
606 } );
607
608 picker->SetMotionHandler(
609 [this]( const VECTOR2D& aPos )
610 {
614 GENERAL_COLLECTOR collector;
615 collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
616
618 collector.Collect( board, GENERAL_COLLECTOR::FootprintItems, aPos, guide );
619 else
620 collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, aPos, guide );
621
622 // Remove unselectable items
623 for( int i = collector.GetCount() - 1; i >= 0; --i )
624 {
625 if( !selectionTool->Selectable( collector[ i ] ) )
626 collector.Remove( i );
627 }
628
629 if( collector.GetCount() > 1 )
630 selectionTool->GuessSelectionCandidates( collector, aPos );
631
632 BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
633
634 if( m_pickerItem != item )
635 {
636 if( m_pickerItem )
637 selectionTool->UnbrightenItem( m_pickerItem );
638
639 m_pickerItem = item;
640
641 if( m_pickerItem )
642 selectionTool->BrightenItem( m_pickerItem );
643 }
644 } );
645
646 picker->SetFinalizeHandler(
647 [this]( const int& aFinalState )
648 {
649 if( m_pickerItem )
650 m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
651
652 m_statusPopup.reset();
653
654 // Ensure the cursor gets changed&updated
657 } );
658
660
661 return 0;
662}
663
664
665static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBoard,
666 std::vector<BOARD_ITEM*>& aPastedItems )
667{
668 FOOTPRINT* editorFootprint = aBoard->GetFirstFootprint();
669
670 aClipFootprint->SetParent( aBoard );
671
672 for( PAD* pad : aClipFootprint->Pads() )
673 {
674 pad->SetParent( editorFootprint );
675 aPastedItems.push_back( pad );
676 }
677
678 aClipFootprint->Pads().clear();
679
680 // Not all graphic items can be added to the current footprint:
681 // Reference and value are already existing in the current footprint, and
682 // must be unique.
683 // So they will be skipped
684 for( BOARD_ITEM* item : aClipFootprint->GraphicalItems() )
685 {
686 if( item->Type() == PCB_FP_SHAPE_T || item->Type() == PCB_FP_TEXTBOX_T )
687 {
688 FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
689
690 shape->SetParent( nullptr );
691 shape->SetLocalCoord();
692 }
693 else if( item->Type() == PCB_FP_TEXT_T )
694 {
695 FP_TEXT* text = static_cast<FP_TEXT*>( item );
696
697 if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
698 continue;
699
700 text->SetTextAngle( text->GetTextAngle() + aClipFootprint->GetOrientation() );
701
702 text->SetParent( nullptr );
703 text->SetLocalCoord();
704 }
705
706 item->SetParent( editorFootprint );
707 aPastedItems.push_back( item );
708 }
709
710 aClipFootprint->GraphicalItems().clear();
711
712 for( FP_ZONE* zone : aClipFootprint->Zones() )
713 {
714 zone->SetParent( editorFootprint );
715 aPastedItems.push_back( zone );
716 }
717
718 aClipFootprint->Zones().clear();
719
720 for( PCB_GROUP* group : aClipFootprint->Groups() )
721 {
722 group->SetParent( editorFootprint );
723 aPastedItems.push_back( group );
724 }
725
726 aClipFootprint->Groups().clear();
727}
728
729
730void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
731{
732 // Do not prune items or layers when copying to the FP editor, because all
733 // layers are accepted, even if they are not enabled in the dummy board
734 // This is mainly true for internal copper layers: all are allowed but only one
735 // (In1.cu) is enabled for the GUI.
737 return;
738
739 LSET enabledLayers = board()->GetEnabledLayers();
740 std::vector<BOARD_ITEM*> returnItems;
741 bool fpItemDeleted = false;
742
743 auto processFPItem =
744 [&]( FOOTPRINT* aFootprint, BOARD_ITEM* aItem )
745 {
746 LSET allowed = aItem->GetLayerSet() & enabledLayers;
747
748 if( allowed.any() )
749 {
750 // Don't prune internal copper layers on items with holes
751 if( aItem->HasHole() && aItem->IsOnCopperLayer() )
752 allowed |= LSET::InternalCuMask();
753
754 aItem->SetLayerSet( allowed );
755 }
756 else
757 {
758 aFootprint->Remove( aItem );
759 fpItemDeleted = true;
760 }
761 };
762
763 for( BOARD_ITEM* item : aItems )
764 {
765
766 if( item->Type() == PCB_FOOTPRINT_T )
767 {
768 FOOTPRINT* fp = static_cast<FOOTPRINT*>( item );
769
770 if( !enabledLayers.test( fp->Reference().GetLayer() ) )
771 fp->Reference().SetLayer( fp->IsFlipped() ? B_SilkS : F_SilkS );
772
773 if( !enabledLayers.test( fp->Value().GetLayer() ) )
774 fp->Value().SetLayer( fp->IsFlipped() ? B_Fab : F_Fab );
775
776 // NOTE: all traversals from the back as processFPItem() might delete the item
777
778 for( int ii = static_cast<int>( fp->Pads().size() ) - 1; ii >= 0; ii-- )
779 processFPItem( fp, fp->Pads()[ii] );
780
781 for( int ii = static_cast<int>( fp->Zones().size() ) - 1; ii >= 0; ii-- )
782 processFPItem( fp, fp->Zones()[ii] );
783
784 for( int ii = static_cast<int>( fp->GraphicalItems().size() ) - 1; ii >= 0; ii-- )
785 processFPItem( fp, fp->GraphicalItems()[ii] );
786
787 if( fp->GraphicalItems().size() || fp->Pads().size() || fp->Zones().size() )
788 returnItems.push_back( fp );
789 }
790 else if( item->Type() == PCB_GROUP_T )
791 {
792 returnItems.push_back( item );
793 }
794 else
795 {
796 LSET allowed = item->GetLayerSet() & enabledLayers;
797
798 if( allowed.any() )
799 {
800 item->SetLayerSet( allowed );
801 returnItems.push_back( item );
802 }
803 }
804 }
805
806 if( ( returnItems.size() < aItems.size() ) || fpItemDeleted )
807 {
808 DisplayError( m_frame, _( "Warning: some pasted items were on layers which are not "
809 "present in the current board.\n"
810 "These items could not be pasted.\n" ) );
811 }
812
813 aItems = returnItems;
814}
815
816
817int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
818{
819 CLIPBOARD_IO pi;
820 BOARD_ITEM* clipItem = pi.Parse();
821
822 if( !clipItem )
823 return 0;
824
825 // The viewer frames cannot paste
826 if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
827 return 0;
828
830 const wxString defaultRef = wxT( "REF**" );
831
832 if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
833 {
834 DIALOG_PASTE_SPECIAL dlg( m_frame, &mode, defaultRef );
835
836 if( dlg.ShowModal() == wxID_CANCEL )
837 return 0;
838 }
839
840 bool isFootprintEditor = m_isFootprintEditor || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
841
842 if( clipItem->Type() == PCB_T )
843 {
844 if( isFootprintEditor )
845 {
846 for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
847 item->SetNet( NETINFO_LIST::OrphanedItem() );
848 }
849 else
850 {
851 static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
852 }
853 }
854
855 // The clipboard can contain two different things, an entire kicad_pcb or a single footprint
856 if( isFootprintEditor && ( !board() || !footprint() ) )
857 {
858 return 0;
859 }
860
861 switch( clipItem->Type() )
862 {
863 case PCB_T:
864 {
865 BOARD* clipBoard = static_cast<BOARD*>( clipItem );
866
867 if( isFootprintEditor )
868 {
869 FOOTPRINT* editorFootprint = board()->GetFirstFootprint();
870 std::vector<BOARD_ITEM*> pastedItems;
871
872 for( PCB_GROUP* group : clipBoard->Groups() )
873 {
874 group->SetParent( editorFootprint );
875 pastedItems.push_back( group );
876 }
877
878 clipBoard->Groups().clear();
879
880 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
881 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
882
883 for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
884 {
885 if( clipDrawItem->Type() == PCB_SHAPE_T )
886 {
887 PCB_SHAPE* clipShape = static_cast<PCB_SHAPE*>( clipDrawItem );
888 PCB_GROUP* parentGroup = clipDrawItem->GetParentGroup();
889
890 if( parentGroup )
891 parentGroup->RemoveItem( clipDrawItem );
892
893 // Convert to PCB_FP_SHAPE_T
894 FP_SHAPE* pastedShape = new FP_SHAPE( editorFootprint );
895 static_cast<PCB_SHAPE*>( pastedShape )->SwapItemData( clipShape );
896 pastedShape->SetLocalCoord();
897
898 if( parentGroup )
899 parentGroup->AddItem( pastedShape );
900
901 pastedItems.push_back( pastedShape );
902 }
903 else if( clipDrawItem->Type() == PCB_TEXT_T )
904 {
905 PCB_TEXT* clipTextItem = static_cast<PCB_TEXT*>( clipDrawItem );
906 PCB_GROUP* parentGroup = clipDrawItem->GetParentGroup();
907
908 if( parentGroup )
909 parentGroup->RemoveItem( clipDrawItem );
910
911 // Convert to PCB_FP_TEXT_T
912 FP_TEXT* pastedTextItem = new FP_TEXT( editorFootprint );
913 static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
914 static_cast<EDA_TEXT*>( pastedTextItem )->SwapAttributes( *clipTextItem );
915
916 if( parentGroup )
917 parentGroup->AddItem( pastedTextItem );
918
919 pastedItems.push_back( pastedTextItem );
920 }
921 else if( clipDrawItem->Type() == PCB_TEXTBOX_T )
922 {
923 PCB_TEXTBOX* clipTextBox = static_cast<PCB_TEXTBOX*>( clipDrawItem );
924 PCB_GROUP* parentGroup = clipDrawItem->GetParentGroup();
925
926 if( parentGroup )
927 parentGroup->RemoveItem( clipDrawItem );
928
929 // Convert to PCB_FP_TEXTBOX_T
930 FP_TEXTBOX* pastedTextBox = new FP_TEXTBOX( editorFootprint );
931
932 // Handle shape data
933 static_cast<PCB_SHAPE*>( pastedTextBox )->SwapItemData( clipTextBox );
934 pastedTextBox->SetLocalCoord();
935
936 // Handle text data
937 static_cast<EDA_TEXT*>( pastedTextBox )->SwapText( *clipTextBox );
938 static_cast<EDA_TEXT*>( pastedTextBox )->SwapAttributes( *clipTextBox );
939
940 if( parentGroup )
941 parentGroup->AddItem( pastedTextBox );
942
943 pastedItems.push_back( pastedTextBox );
944 }
945 }
946
947 delete clipBoard;
948
949 pruneItemLayers( pastedItems );
950
951 placeBoardItems( pastedItems, true, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
952 }
953 else
954 {
956 {
957 for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
958 clipFootprint->SetReference( defaultRef );
959 }
960
961 placeBoardItems( clipBoard, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
962 }
963
964 break;
965 }
966
967 case PCB_FOOTPRINT_T:
968 {
969 FOOTPRINT* clipFootprint = static_cast<FOOTPRINT*>( clipItem );
970 std::vector<BOARD_ITEM*> pastedItems;
971
972 if( isFootprintEditor )
973 {
974 pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
975 delete clipFootprint;
976 }
977 else
978 {
980 clipFootprint->SetReference( defaultRef );
981
982 clipFootprint->SetParent( board() );
983 pastedItems.push_back( clipFootprint );
984 }
985
986 pruneItemLayers( pastedItems );
987
988 placeBoardItems( pastedItems, true, true, mode == PASTE_MODE::UNIQUE_ANNOTATIONS );
989 break;
990 }
991
992 default:
993 m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
994 break;
995 }
996
997 return 1;
998}
999
1000
1002{
1003 int open_ctl;
1004 wxString fileName;
1005
1006 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1007
1008 if( !editFrame )
1009 return 1;
1010
1011 // Pick a file to append
1012 if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
1013 return 1;
1014
1015 IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
1016 PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
1017
1018 return AppendBoard( *pi, fileName );
1019}
1020
1021
1022// Helper function for PCB_CONTROL::placeBoardItems()
1023template<typename T>
1024static void moveUnflaggedItems( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
1025 bool aIsNew )
1026{
1027 std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
1028 [aIsNew]( T aItem )
1029 {
1030 bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
1031
1032 aItem->ClearFlags( SKIP_STRUCT );
1033 aItem->SetFlags( aIsNew ? IS_NEW : 0 );
1034
1035 return doCopy;
1036 } );
1037
1038 if( aIsNew )
1039 aList.clear();
1040}
1041
1042
1043static void moveUnflaggedItems( ZONES& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
1044{
1045 if( aList.size() == 0 )
1046 return;
1047
1048 auto obj = aList.front();
1049 int idx = 0;
1050
1051 if( aIsNew )
1052 {
1053 obj = aList.back();
1054 aList.pop_back();
1055 }
1056
1057 for( ; obj ; )
1058 {
1059 if( obj->HasFlag( SKIP_STRUCT ) )
1060 obj->ClearFlags( SKIP_STRUCT );
1061 else
1062 aTarget.push_back( obj );
1063
1064 if( aIsNew )
1065 {
1066 if( aList.size() )
1067 {
1068 obj = aList.back();
1069 aList.pop_back();
1070 }
1071 else
1072 {
1073 obj = nullptr;
1074 }
1075 }
1076 else
1077 {
1078 obj = idx < int(aList.size()-1) ? aList[++idx] : nullptr;
1079 }
1080 }
1081}
1082
1083
1084
1085int PCB_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin, bool aReannotateDuplicates )
1086{
1087 // items are new if the current board is not the board source
1088 bool isNew = board() != aBoard;
1089 std::vector<BOARD_ITEM*> items;
1090
1091 moveUnflaggedItems( aBoard->Tracks(), items, isNew );
1092 moveUnflaggedItems( aBoard->Footprints(), items, isNew );
1093 moveUnflaggedItems( aBoard->Drawings(), items, isNew );
1094 moveUnflaggedItems( aBoard->Zones(), items, isNew );
1095
1096 // Subtlety: When selecting a group via the mouse,
1097 // PCB_SELECTION_TOOL::highlightInternal runs, which does a SetSelected() on all
1098 // descendants. In PCB_CONTROL::placeBoardItems, below, we skip that and
1099 // mark items non-recursively. That works because the saving of the
1100 // selection created aBoard that has the group and all descendants in it.
1101 moveUnflaggedItems( aBoard->Groups(), items, isNew );
1102
1103 pruneItemLayers( items );
1104
1105 return placeBoardItems( items, isNew, aAnchorAtOrigin, aReannotateDuplicates );
1106}
1107
1108
1109int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
1110 bool aAnchorAtOrigin, bool aReannotateDuplicates )
1111{
1113
1115 EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
1116
1117 std::vector<BOARD_ITEM*> itemsToSel;
1118 itemsToSel.reserve( aItems.size() );
1119
1120 for( BOARD_ITEM* item : aItems )
1121 {
1122 if( aIsNew )
1123 {
1124 const_cast<KIID&>( item->m_Uuid ) = KIID();
1125
1126 // Even though BOARD_COMMIT::Push() will add any new items to the group, we're
1127 // going to run PCB_ACTIONS::move first, and the move tool will throw out any
1128 // items that aren't in the entered group.
1129 if( selectionTool->GetEnteredGroup() && !item->GetParentGroup() )
1130 selectionTool->GetEnteredGroup()->AddItem( item );
1131 }
1132
1133 // Update item attributes if needed
1134 if( BaseType( item->Type() ) == PCB_DIMENSION_T )
1135 {
1136 static_cast<PCB_DIMENSION_BASE*>( item )->UpdateUnits();
1137 }
1138 else if( item->Type() == PCB_FOOTPRINT_T )
1139 {
1140 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
1141
1142 // Update the footprint path with the new KIID path if the footprint is new
1143 if( aIsNew )
1145
1146 for( BOARD_ITEM* dwg : footprint->GraphicalItems() )
1147 {
1148 if( BaseType( dwg->Type() ) == PCB_DIMENSION_T )
1149 static_cast<PCB_DIMENSION_BASE*>( dwg )->UpdateUnits();
1150 }
1151 }
1152
1153 // We only need to add the items that aren't inside a group currently selected
1154 // to the selection. If an item is inside a group and that group is selected,
1155 // then the selection tool will select it for us.
1156 if( !item->GetParentGroup() || !alg::contains( aItems, item->GetParentGroup() ) )
1157 itemsToSel.push_back( item );
1158 }
1159
1160 // Select the items that should be selected
1161 m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &itemsToSel );
1162
1163 // Reannotate duplicate footprints (make sense only in board editor )
1164 if( aReannotateDuplicates && m_isBoardEditor )
1165 m_toolMgr->GetTool<BOARD_REANNOTATE_TOOL>()->ReannotateDuplicatesInSelection();
1166
1167 for( BOARD_ITEM* item : aItems )
1168 {
1169 // Commit after reannotation
1170 if( aIsNew )
1171 editTool->GetCurrentCommit()->Add( item );
1172 else
1173 editTool->GetCurrentCommit()->Added( item );
1174 }
1175
1176 PCB_SELECTION& selection = selectionTool->GetSelection();
1177
1178 if( selection.Size() > 0 )
1179 {
1180 if( aAnchorAtOrigin )
1181 {
1183 }
1184 else
1185 {
1186 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
1188 }
1189
1190 getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
1191
1194 }
1195
1196 return 0;
1197}
1198
1199
1200int PCB_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
1201{
1202 PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1203
1204 if( !editFrame )
1205 return 1;
1206
1207 BOARD* brd = board();
1208
1209 if( !brd )
1210 return 1;
1211
1212 // Mark existing items, in order to know what are the new items so we can select only
1213 // the new items after loading
1214 for( PCB_TRACK* track : brd->Tracks() )
1215 track->SetFlags( SKIP_STRUCT );
1216
1217 for( FOOTPRINT* footprint : brd->Footprints() )
1219
1220 for( PCB_GROUP* group : brd->Groups() )
1221 group->SetFlags( SKIP_STRUCT );
1222
1223 for( BOARD_ITEM* drawing : brd->Drawings() )
1224 drawing->SetFlags( SKIP_STRUCT );
1225
1226 for( ZONE* zone : brd->Zones() )
1227 zone->SetFlags( SKIP_STRUCT );
1228
1229 std::map<wxString, wxString> oldProperties = brd->GetProperties();
1230 std::map<wxString, wxString> newProperties;
1231
1232 PAGE_INFO oldPageInfo = brd->GetPageSettings();
1233 TITLE_BLOCK oldTitleBlock = brd->GetTitleBlock();
1234
1235 // Keep also the count of copper layers, to adjust if necessary
1236 int initialCopperLayerCount = brd->GetCopperLayerCount();
1237 LSET initialEnabledLayers = brd->GetEnabledLayers();
1238
1239 // Load the data
1240 try
1241 {
1242 STRING_UTF8_MAP props;
1243 char xbuf[30];
1244 char ybuf[30];
1245
1246 // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
1247 snprintf( xbuf, sizeof(xbuf), "%d", editFrame->GetPageSizeIU().x );
1248 snprintf( ybuf, sizeof(ybuf), "%d", editFrame->GetPageSizeIU().y );
1249
1250 props["page_width"] = xbuf;
1251 props["page_height"] = ybuf;
1252
1254 [&]( wxString aTitle, int aIcon, wxString aMessage, wxString aAction ) -> bool
1255 {
1256 KIDIALOG dlg( editFrame, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
1257
1258 if( !aAction.IsEmpty() )
1259 dlg.SetOKLabel( aAction );
1260
1261 dlg.DoNotShowCheckbox( aMessage, 0 );
1262
1263 return dlg.ShowModal() == wxID_OK;
1264 } );
1265
1266 WX_PROGRESS_REPORTER progressReporter( editFrame, _( "Loading PCB" ), 1 );
1267
1268 editFrame->GetDesignSettings().m_NetSettings->m_NetClasses.clear();
1269 pi.Load( fileName, brd, &props, nullptr, &progressReporter );
1270 }
1271 catch( const IO_ERROR& ioe )
1272 {
1273 wxString msg = wxString::Format( _( "Error loading board.\n%s" ), ioe.What() );
1274 DisplayError( editFrame, msg );
1275
1276 return 0;
1277 }
1278
1279 newProperties = brd->GetProperties();
1280
1281 for( const std::pair<const wxString, wxString>& prop : oldProperties )
1282 newProperties[ prop.first ] = prop.second;
1283
1284 brd->SetProperties( newProperties );
1285
1286 brd->SetPageSettings( oldPageInfo );
1287 brd->SetTitleBlock( oldTitleBlock );
1288
1289 // rebuild nets and ratsnest before any use of nets
1290 brd->BuildListOfNets();
1291 brd->SynchronizeNetsAndNetClasses( true );
1292 brd->BuildConnectivity();
1293
1294 // Synchronize layers
1295 // we should not ask PLUGINs to do these items:
1296 int copperLayerCount = brd->GetCopperLayerCount();
1297
1298 if( copperLayerCount > initialCopperLayerCount )
1299 brd->SetCopperLayerCount( copperLayerCount );
1300
1301 // Enable all used layers, and make them visible:
1302 LSET enabledLayers = brd->GetEnabledLayers();
1303 enabledLayers |= initialEnabledLayers;
1304 brd->SetEnabledLayers( enabledLayers );
1305 brd->SetVisibleLayers( enabledLayers );
1306
1307 return placeBoardItems( brd, false, false ); // Do not reannotate duplicates on Append Board
1308}
1309
1310
1311int PCB_CONTROL::Undo( const TOOL_EVENT& aEvent )
1312{
1313 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1314 wxCommandEvent dummy;
1315
1316 if( editFrame )
1317 editFrame->RestoreCopyFromUndoList( dummy );
1318
1319 return 0;
1320}
1321
1322
1323int PCB_CONTROL::Redo( const TOOL_EVENT& aEvent )
1324{
1325 PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1326 wxCommandEvent dummy;
1327
1328 if( editFrame )
1329 editFrame->RestoreCopyFromRedoList( dummy );
1330
1331 return 0;
1332}
1333
1334
1336{
1338 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
1339 PCB_SELECTION& selection = selTool->GetSelection();
1340 PCB_EDIT_FRAME* pcbFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1341 std::shared_ptr<DRC_ENGINE> drcEngine = m_frame->GetBoard()->GetDesignSettings().m_DRCEngine;
1342 DRC_CONSTRAINT constraint;
1343
1344 std::vector<MSG_PANEL_ITEM> msgItems;
1345
1346 if( routerTool && routerTool->RoutingInProgress() )
1347 {
1348 routerTool->UpdateMessagePanel();
1349 return 0;
1350 }
1351
1352 if( !pcbFrame && !m_frame->GetModel() )
1353 return 0;
1354
1355 if( selection.Empty() )
1356 {
1357 if( !pcbFrame )
1358 {
1359 FOOTPRINT* fp = static_cast<FOOTPRINT*>( m_frame->GetModel() );
1360 fp->GetMsgPanelInfo( m_frame, msgItems );
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->GetItemDescription( m_frame ),
1382 b->GetItemDescription( 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:159
static TOOL_ACTION gridResetOrigin
Definition: actions.h:142
static TOOL_ACTION pasteSpecial
Definition: actions.h:70
static TOOL_ACTION highContrastModeCycle
Definition: actions.h:107
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION highContrastMode
Definition: actions.h:106
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:141
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:70
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:192
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:84
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:226
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:197
virtual bool IsLocked() const
Definition: board_item.cpp:71
virtual bool IsOnLayer(PCB_LAYER_ID aLayer, bool aIncludeCourtyards=false) const
Test to see if this object is on the given layer.
Definition: board_item.h:257
virtual bool IsOnCopperLayer() const
Definition: board_item.h:135
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
Definition: board_item.cpp:229
virtual bool HasHole() const
Definition: board_item.h:140
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:269
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:587
void BuildListOfNets()
Definition: board.h:763
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:607
const PAGE_INFO & GetPageSettings() const
Definition: board.h:632
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: board.h:339
ZONES & Zones()
Definition: board.h:317
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:166
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1546
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:403
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:638
FOOTPRINTS & Footprints()
Definition: board.h:311
int GetCopperLayerCount() const
Definition: board.cpp:563
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:338
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:333
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:633
TRACKS & Tracks()
Definition: board.h:308
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:619
void SetCopperLayerCount(int aCount)
Definition: board.cpp:569
DRAWINGS & Drawings()
Definition: board.h:314
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:593
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:1314
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:704
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:640
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:172
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:249
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:250
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
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:209
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
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:1814
static const TOOL_EVENT ClearedEvent
Definition: actions.h:209
static const TOOL_EVENT SelectedEvent
Definition: actions.h:207
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:206
static const TOOL_EVENT ConnectivityChangedEvent
Selected item had a property changed (except movement)
Definition: actions.h:211
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:208
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:628
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:225
FP_GROUPS & Groups()
Definition: footprint.h:179
bool IsFlipped() const
Definition: footprint.h:324
PADS & Pads()
Definition: footprint.h:170
void SetReference(const wxString &aReference)
Definition: footprint.h:528
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:1026
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:567
FP_ZONES & Zones()
Definition: footprint.h:176
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:916
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:76
int ShowModal() override
Definition: confirm.cpp:120
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
double a
Alpha component.
Definition: color4d.h:375
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:538
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:349
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:1384
void UpdateLayerColor(int aLayer)
Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.
Definition: view.cpp:740
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:641
Definition: kiid.h:48
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:532
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:395
Definition: pad.h:60
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:326
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:302
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:298
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:286
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:293
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:323
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:275
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:344
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:292
static TOOL_ACTION ddAppendBoard
Drag and drop.
Definition: pcb_actions.h:528
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:315
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:325
static TOOL_ACTION zoneDisplayFilled
Definition: pcb_actions.h:282
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:314
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:281
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:319
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:301
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:324
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:306
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:316
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:308
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:304
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:279
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:296
static TOOL_ACTION ddImportFootprint
Definition: pcb_actions.h:529
static TOOL_ACTION zoneDisplayTriangulated
Definition: pcb_actions.h:285
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:312
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:295
static TOOL_ACTION zoneDisplayFractured
Definition: pcb_actions.h:284
static TOOL_ACTION ratsnestModeCycle
Definition: pcb_actions.h:278
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:310
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:297
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:317
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:486
static TOOL_ACTION netColorModeCycle
Definition: pcb_actions.h:277
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:291
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:300
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:305
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:307
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:330
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:321
static TOOL_ACTION zoneDisplayOutline
Definition: pcb_actions.h:283
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:276
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:309
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:299
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:110
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:320
static TOOL_ACTION layerTop
Definition: pcb_actions.h:290
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:294
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:303
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:311
static TOOL_ACTION layerNext
Definition: pcb_actions.h:322
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:313
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:318
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...
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
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
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.
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: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:215
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:82
@ 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:81
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().
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:289
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:128
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: wx_infobar.cpp:248
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_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:300
This file is part of the common library.
@ REMOVE_ANNOTATIONS
@ UNIQUE_ANNOTATIONS
@ 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)
#define SKIP_STRUCT
flag indicating that the structure should be ignored
@ 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:968
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:827
@ 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
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
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: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:590
Definition of file extensions used in Kicad.