KiCad PCB EDA Suite
footprint_viewer_frame.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) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2008-2016 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
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
27#include <bitmaps.h>
28#include <board_commit.h>
29#include <board.h>
30#include <footprint.h>
31#include <confirm.h>
32#include <eda_pattern_match.h>
33#include <footprint_info.h>
35#include <fp_lib_table.h>
36#include <kiway.h>
37#include <kiway_express.h>
39#include <widgets/msgpanel.h>
40#include <widgets/wx_listbox.h>
41#include <pcb_draw_panel_gal.h>
42#include <pcb_painter.h>
43#include <pcbnew_id.h>
45#include <pgm_base.h>
48#include <tool/action_toolbar.h>
49#include <tool/common_control.h>
50#include <tool/common_tools.h>
51#include <tool/selection.h>
53#include <tool/tool_manager.h>
54#include <tool/zoom_tool.h>
56#include <tools/pcb_actions.h>
58#include <tools/pcb_control.h>
64#include <wx/srchctrl.h>
65#include <wx/tokenzr.h>
66#include <wx/choice.h>
67
68using namespace std::placeholders;
69
70
71#define NEXT_PART 1
72#define NEW_PART 0
73#define PREVIOUS_PART -1
74
75
76BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
77 // Window events
80
81 EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::OnExitKiCad )
83
84 // Toolbar events
91
93
96
97 // listbox events
100
101END_EVENT_TABLE()
102
103
104/*
105 * Note: FOOTPRINT_VIEWER_FRAME can be created in "modal mode", or as a usual frame.
106 */
107#define PARENT_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
108#define MODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP )
109#define NONMODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
110
111
113 FRAME_T aFrameType ) :
114 PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
115 wxDefaultPosition, wxDefaultSize,
116 aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL ? ( aParent ? PARENT_STYLE : MODAL_STYLE )
120 m_comp( LIB_ID(), wxEmptyString, wxEmptyString, KIID_PATH(), {} )
121{
122 wxASSERT( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL || aFrameType == FRAME_FOOTPRINT_VIEWER );
123
124 if( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL )
125 SetModal( true );
126
127 m_aboutTitle = _( "KiCad Footprint Library Viewer" );
128
129 // Force the items to always snap
130 m_magneticItems.pads = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
131 m_magneticItems.tracks = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
132 m_magneticItems.graphics = true;
133
134 // Force the frame name used in config. the footprint viewer frame has a name
135 // depending on aFrameType (needed to identify the frame by wxWidgets),
136 // but only one configuration is preferable.
137 m_configName = FOOTPRINT_VIEWER_FRAME_NAME;
138
139 // Give an icon
140 wxIcon icon;
141 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_footprint_browser ) );
142 SetIcon( icon );
143
144 m_libListWidth = 200;
145 m_fpListWidth = 300;
146
147 wxPanel* libPanel = new wxPanel( this );
148 wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
149
150 m_libFilter = new wxSearchCtrl( libPanel, ID_MODVIEW_LIB_FILTER, wxEmptyString,
151 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
152 m_libFilter->SetDescriptiveText( _( "Filter" ) );
153 libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
154
155 m_libList = new WX_LISTBOX( libPanel, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
156 0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
157 libSizer->Add( m_libList, 1, wxEXPAND, 5 );
158
159 libPanel->SetSizer( libSizer );
160 libPanel->Fit();
161
162 wxPanel* fpPanel = new wxPanel( this );
163 wxSizer* fpSizer = new wxBoxSizer( wxVERTICAL );
164
165 m_fpFilter = new wxSearchCtrl( fpPanel, ID_MODVIEW_FOOTPRINT_FILTER, wxEmptyString,
166 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
167 m_fpFilter->SetDescriptiveText( _( "Filter" ) );
168 m_fpFilter->SetToolTip(
169 _( "Filter on footprint name, keywords, description and pad count.\n"
170 "Search terms are separated by spaces. All search terms must match.\n"
171 "A term which is a number will also match against the pad count." ) );
172 fpSizer->Add( m_fpFilter, 0, wxEXPAND, 5 );
173
174#ifdef __WXGTK__
175 // wxSearchCtrl vertical height is not calculated correctly on some GTK setups
176 // See https://gitlab.com/kicad/code/kicad/-/issues/9019
177 m_libFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
178 m_fpFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT( "qb" ) ).y + 10 ) );
179#endif
180
181 m_fpList = new WX_LISTBOX( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
182 0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
183
184 m_fpList->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList ), nullptr, this );
185 fpSizer->Add( m_fpList, 1, wxEXPAND, 5 );
186
187 fpPanel->SetSizer( fpSizer );
188 fpPanel->Fit();
189
190 // Create GAL canvas
191 m_canvasType = loadCanvasTypeSetting();
192
193 PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
194 GetGalDisplayOptions(), m_canvasType );
195 SetCanvas( drawPanel );
196
197 SetBoard( new BOARD() );
198
199 // This board will only be used to hold a footprint for viewing
201
202 // In viewer, the default net clearance is not known (it depends on the actual board).
203 // So we do not show the default clearance, by setting it to 0
204 // The footprint or pad specific clearance will be shown
205 GetBoard()->GetDesignSettings().m_NetSettings->m_DefaultNetClass->SetClearance( 0 );
206
207 // Don't show the default board solder mask clearance in the footprint viewer. Only the
208 // footprint or pad clearance setting should be shown if it is not 0.
210
211 // Ensure all layers and items are visible:
213 SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
214
215 GetScreen()->m_Center = true; // Center coordinate origins on screen.
216 LoadSettings( config() );
217 GetGalDisplayOptions().m_axesEnabled = true;
218
219 // Call resolveCanvasType after loading settings:
220 resolveCanvasType();
221
222 // Create the manager and dispatcher & route draw panel events to the dispatcher
223 m_toolManager = new TOOL_MANAGER;
224 m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
225 drawPanel->GetViewControls(), config(), this );
226 m_actions = new PCB_ACTIONS();
227 m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
228 drawPanel->SetEventDispatcher( m_toolDispatcher );
229
230 m_toolManager->RegisterTool( new PCB_CONTROL );
231 m_toolManager->RegisterTool( new PCB_SELECTION_TOOL );
232 m_toolManager->RegisterTool( new COMMON_TOOLS ); // for std context menus (zoom & grid)
233 m_toolManager->RegisterTool( new COMMON_CONTROL );
234 m_toolManager->RegisterTool( new PCB_PICKER_TOOL ); // for setting grid origin
235 m_toolManager->RegisterTool( new ZOOM_TOOL );
236 m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS );
237
238 m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
239
240 m_toolManager->InitTools();
241 m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
242
243 setupUIConditions();
244 ReCreateMenuBar();
245 ReCreateHToolbar();
246 ReCreateVToolbar();
247 ReCreateOptToolbar();
248
249 ReCreateLibraryList();
250 UpdateTitle();
251
252 // If a footprint was previously loaded, reload it
253 if( getCurNickname().size() && getCurFootprintName().size() )
254 {
255 LIB_ID id;
256
257 id.SetLibNickname( getCurNickname() );
258 id.SetLibItemName( getCurFootprintName() );
259
260 FOOTPRINT* footprint = loadFootprint( id );
261
262 if( footprint )
263 GetBoard()->Add( footprint );
264 }
265
266 drawPanel->DisplayBoard( m_pcb );
267
268 m_auimgr.SetManagedWindow( this );
269
270 // Horizontal items; layers 4 - 6
271 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().VToolbar().Name( "MainToolbar" ).Top().Layer(6) );
272 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
273 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
274
275 // Vertical items; layers 1 - 3
276 m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
277 .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
278 m_auimgr.AddPane( fpPanel, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer(1)
279 .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
280
281 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
282
283 // after changing something to the aui manager call Update() to reflect the changes
284 m_auimgr.Update();
285
286 if( m_libListWidth > 0 )
287 {
288 wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Libraries" );
289
290 // wxAUI hack: force width by setting MinSize() and then Fixed()
291 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
292 treePane.MinSize( m_libListWidth, -1 );
293 treePane.Fixed();
294 m_auimgr.Update();
295
296 // now make it resizable again
297 treePane.Resizable();
298 m_auimgr.Update();
299
300 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
301 // back to minimum.
302 treePane.MinSize( 100, -1 );
303 }
304
305 if( m_fpListWidth > 0 )
306 {
307 wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
308
309 // wxAUI hack: force width by setting MinSize() and then Fixed()
310 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
311 treePane.MinSize( m_fpListWidth, -1 );
312 treePane.Fixed();
313 m_auimgr.Update();
314
315 // now make it resizable again
316 treePane.Resizable();
317 m_auimgr.Update();
318
319 // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
320 // back to minimum.
321 treePane.MinSize( 100, -1 );
322 }
323
324 // The canvas should not steal the focus from the list boxes
325 GetCanvas()->SetCanFocus( false );
326 GetCanvas()->GetGAL()->SetAxesEnabled( true );
327 ActivateGalCanvas();
328
329 // Restore last zoom and auto zoom option. (If auto-zooming we'll adjust when we load the footprint.)
330 PCBNEW_SETTINGS* cfg = GetPcbNewSettings();
331 wxASSERT( cfg );
332 GetCanvas()->GetView()->SetScale( cfg->m_FootprintViewerZoom );
333
334 wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
335
337 toolOpt->SetState( wxAUI_BUTTON_STATE_CHECKED );
338 else
339 toolOpt->SetState( 0 );
340
341 updateView();
342 setupUnits( config() );
343
344 if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
345 {
346 ReCreateFootprintList();
347 Raise(); // On some window managers, this is needed
348 Show( true );
349 }
350}
351
352
354{
355 // Shutdown all running tools
356 if( m_toolManager )
358
360 GetCanvas()->GetView()->Clear();
361 // Be sure any event cannot be fired after frame deletion:
362 GetCanvas()->SetEvtHandlerEnabled( false );
363 m_fpList->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList ), nullptr, this );
364}
365
366
368{
369 return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
370}
371
372
374{
376
378 PCB_EDITOR_CONDITIONS cond( this );
379
380 wxASSERT( mgr );
381
382#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
383#define CHECK( x ) ACTION_CONDITIONS().Check( x )
384
390
391
398
404
405#undef ENABLE
406#undef CHECK
407}
408
409
411{
412 // A workaround to avoid flicker, in modal mode when modview frame is destroyed,
413 // when the aui toolbar is not docked (i.e. shown in a miniframe)
414 // (useful on windows only)
415 m_mainToolBar->SetFocus();
416
418
419 if( IsModal() )
420 {
421 // Only dismiss a modal frame once, so that the return values set by
422 // the prior DismissModal() are not bashed for ShowModal().
423 if( !IsDismissed() )
424 DismissModal( false );
425
426 // window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
427 }
428 else
429 {
430 Destroy();
431 }
432}
433
434
435void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
436{
437 if( m_auimgr.GetManagedWindow() )
438 m_auimgr.Update();
439
440 SizeEv.Skip();
441}
442
443
445{
446 m_libList->Clear();
447
448 COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
450 std::vector<wxString> nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
451 std::set<wxString> pinnedMatches;
452 std::set<wxString> otherMatches;
453
454 auto process =
455 [&]( const wxString& aNickname )
456 {
457 if( alg::contains( project.m_PinnedFootprintLibs, aNickname )
458 || alg::contains( cfg->m_Session.pinned_fp_libs, aNickname ) )
459 {
460 pinnedMatches.insert( aNickname );
461 }
462 else
463 {
464 otherMatches.insert( aNickname );
465 }
466 };
467
468 if( m_libFilter->GetValue().IsEmpty() )
469 {
470 for( const wxString& nickname : nicknames )
471 process( nickname );
472 }
473 else
474 {
475 wxStringTokenizer tokenizer( m_libFilter->GetValue() );
476
477 while( tokenizer.HasMoreTokens() )
478 {
479 const wxString term = tokenizer.GetNextToken().Lower();
480 EDA_COMBINED_MATCHER matcher( term, CTX_LIBITEM );
481 int matches, position;
482
483 for( const wxString& nickname : nicknames )
484 {
485 if( matcher.Find( nickname.Lower(), matches, position ) )
486 process( nickname );
487 }
488 }
489 }
490
491 for( const wxString& nickname : pinnedMatches )
493
494 for( const wxString& nickname : otherMatches )
495 m_libList->Append( nickname );
496
497 // Search for a previous selection:
498 int index = m_libList->FindString( getCurNickname(), true );
499
500 if( index == wxNOT_FOUND )
501 {
502 if( m_libList->GetCount() > 0 )
503 {
504 m_libList->SetSelection( 0 );
505 wxCommandEvent dummy;
507 }
508 else
509 {
510 setCurNickname( wxEmptyString );
511 setCurFootprintName( wxEmptyString );
512 }
513 }
514 else
515 {
516 m_libList->SetSelection( index, true );
517 wxCommandEvent dummy;
519 }
520
521 GetCanvas()->Refresh();
522}
523
524
526{
527 m_fpList->Clear();
528
529 if( !getCurNickname() )
530 setCurFootprintName( wxEmptyString );
531
532 auto fp_info_list = FOOTPRINT_LIST::GetInstance( Kiway() );
533
534 wxString nickname = getCurNickname();
535
536 fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? nullptr : &nickname );
537
538 if( fp_info_list->GetErrorCount() )
539 {
540 fp_info_list->DisplayErrors( this );
541
542 // For footprint libraries that support one footprint per file, there may have been
543 // valid footprints read so show the footprints that loaded properly.
544 if( fp_info_list->GetList().empty() )
545 return;
546 }
547
548 std::set<wxString> excludes;
549
550 if( !m_fpFilter->GetValue().IsEmpty() )
551 {
552 wxStringTokenizer tokenizer( m_fpFilter->GetValue() );
553
554 while( tokenizer.HasMoreTokens() )
555 {
556 const wxString term = tokenizer.GetNextToken().Lower();
557 EDA_COMBINED_MATCHER matcher( term, CTX_LIBITEM );
558 int matches, position;
559
560 for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
561 {
562 wxString search = footprint->GetFootprintName() + wxS( " " ) + footprint->GetSearchText();
563 bool matched = matcher.Find( search.Lower(), matches, position );
564
565 if( !matched && term.IsNumber() )
566 matched = ( wxAtoi( term ) == (int)footprint->GetPadCount() );
567
568 if( !matched )
569 excludes.insert( footprint->GetFootprintName() );
570 }
571 }
572 }
573
574 for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
575 {
576 if( !excludes.count( footprint->GetFootprintName() ) )
577 m_fpList->Append( footprint->GetFootprintName() );
578 }
579
580 int index = m_fpList->FindString( getCurFootprintName(), true );
581
582 if( index == wxNOT_FOUND )
583 {
584 if( m_fpList->GetCount() > 0 )
585 {
586 m_fpList->SetSelection( 0 );
587 m_fpList->EnsureVisible( 0 );
588
589 wxCommandEvent dummy;
591 }
592 else
593 {
594 setCurFootprintName( wxEmptyString );
595 }
596 }
597 else
598 {
599 m_fpList->SetSelection( index, true );
600 m_fpList->EnsureVisible( index );
601 }
602}
603
604
605void FOOTPRINT_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
606{
608
609 // Required to avoid interaction with SetHint()
610 // See documentation for wxTextEntry::SetHint
611 aEvent.Skip();
612}
613
614
615void FOOTPRINT_VIEWER_FRAME::OnFPFilter( wxCommandEvent& aEvent )
616{
618
619 // Required to avoid interaction with SetHint()
620 // See documentation for wxTextEntry::SetHint
621 aEvent.Skip();
622}
623
624
625void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
626{
627 if( aEvent.GetKeyCode() == WXK_UP )
628 {
629 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
631 else
633 }
634 else if( aEvent.GetKeyCode() == WXK_DOWN )
635 {
636 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
638 else
640 }
641 else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
642 {
643 if( !aEvent.ShiftDown() )
644 m_fpFilter->SetFocus();
645 else
646 aEvent.Skip();
647 }
648 else if( aEvent.GetKeyCode() == WXK_TAB && m_fpFilter->HasFocus() )
649 {
650 if( aEvent.ShiftDown() )
651 m_libFilter->SetFocus();
652 else
653 aEvent.Skip();
654 }
655 else if( aEvent.GetKeyCode() == WXK_RETURN && m_fpList->GetSelection() >= 0 )
656 {
657 wxCommandEvent dummy;
659 }
660 else
661 {
662 aEvent.Skip();
663 }
664}
665
666
668{
669 int prev = aListBox->GetSelection() - 1;
670
671 if( prev >= 0 )
672 {
673 aListBox->SetSelection( prev );
674 aListBox->EnsureVisible( prev );
675
676 wxCommandEvent dummy;
677
678 if( aListBox == m_libList )
680 else
682 }
683}
684
685
687{
688 int next = aListBox->GetSelection() + 1;
689
690 if( next < (int)aListBox->GetCount() )
691 {
692 aListBox->SetSelection( next );
693 aListBox->EnsureVisible( next );
694
695 wxCommandEvent dummy;
696
697 if( aListBox == m_libList )
699 else
701 }
702}
703
704
705void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& aEvent )
706{
707 int ii = m_libList->GetSelection();
708
709 if( ii < 0 )
710 return;
711
712 wxString name = m_libList->GetBaseString( ii );
713
714 if( getCurNickname() == name )
715 return;
716
718
720 UpdateTitle();
721}
722
723
725{
726 if( m_fpList->GetCount() == 0 )
727 return;
728
729 int ii = m_fpList->GetSelection();
730
731 if( ii < 0 )
732 return;
733
734 wxString name = m_fpList->GetBaseString( ii );
735
736 if( getCurFootprintName().CmpNoCase( name ) != 0 )
737 {
739
740 // Delete the current footprint (MUST reset tools first)
742
745
746 LIB_ID id;
748 id.SetLibItemName( getCurFootprintName() );
749
750 FOOTPRINT* footprint = nullptr;
751
752 try
753 {
754 footprint = loadFootprint( id );
755 }
756 catch( const IO_ERROR& ioe )
757 {
758 wxString msg = wxString::Format( _( "Could not load footprint '%s' from library '%s'."
759 "\n\n%s" ),
762 ioe.Problem() );
763 DisplayError( this, msg );
764 }
765
766 if( footprint )
767 displayFootprint( footprint );
768
769 UpdateTitle();
770
771 updateView();
772
773 GetCanvas()->Refresh();
774 Update3DView( true, true );
775 }
776}
777
778
780{
781 for( PAD* pad : aFootprint->Pads() )
782 {
783 const COMPONENT_NET& net = m_comp.GetNet( pad->GetNumber() );
784
785 if( !net.GetPinFunction().IsEmpty() )
786 {
787 NETINFO_ITEM* netinfo = new NETINFO_ITEM( GetBoard() );
788 netinfo->SetNetname( net.GetPinFunction() );
789 GetBoard()->Add( netinfo );
790 pad->SetNet( netinfo );
791 }
792 }
793
794 GetBoard()->Add( aFootprint );
795}
796
797
799{
800 wxCommandEvent evt;
801 AddFootprintToPCB( evt );
802}
803
804
805void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
806{
807 if( IsModal() )
808 {
809 if( m_fpList->GetSelection() >= 0 )
810 {
812 DismissModal( true, fpid.Format() );
813 }
814 else
815 {
816 DismissModal( false );
817 }
818 }
819 else if( GetBoard()->GetFirstFootprint() )
820 {
821 PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
822 PCBNEW_SETTINGS* cfg = pcbframe->GetPcbNewSettings();
823
824 if( pcbframe == nullptr ) // happens when the board editor is not active (or closed)
825 {
826 DisplayErrorMessage( this, _( "No board currently open." ) );
827 return;
828 }
829
830 TOOL_MANAGER* toolMgr = pcbframe->GetToolManager();
831
833 {
834 DisplayError( this, _( "Previous footprint placement still in progress." ) );
835 return;
836 }
837
838 wxWindow* blocking_dialog = pcbframe->Kiway().GetBlockingDialog();
839
840 if( blocking_dialog )
841 blocking_dialog->Close( true );
842
843 toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
844 BOARD_COMMIT commit( pcbframe );
845
846 // Create the "new" footprint
847 FOOTPRINT* newFootprint = (FOOTPRINT*) GetBoard()->GetFirstFootprint()->Duplicate();
848 newFootprint->SetParent( pcbframe->GetBoard() );
849 newFootprint->SetLink( niluuid );
850 newFootprint->SetFlags(IS_NEW ); // whatever
851
852 for( PAD* pad : newFootprint->Pads() )
853 {
854 // Set the pads ratsnest settings to the global settings
855 pad->SetLocalRatsnestVisible( cfg->m_Display.m_ShowGlobalRatsnest );
856
857 // Pads in the library all have orphaned nets. Replace with Default.
858 pad->SetNetCode( 0 );
859 }
860
861 // Put it on FRONT layer,
862 // (Can be stored flipped if the lib is an archive built from a board)
863 if( newFootprint->IsFlipped() )
864 newFootprint->Flip( newFootprint->GetPosition(), cfg->m_FlipLeftRight );
865
866 KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
867 VECTOR2D cursorPos = viewControls->GetCursorPosition();
868
869 commit.Add( newFootprint );
870 viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
871 pcbframe->PlaceFootprint( newFootprint );
872
873 newFootprint->SetPosition( wxPoint( 0, 0 ) );
874 viewControls->SetCrossHairCursorPosition( cursorPos, false );
875 commit.Push( wxT( "Insert footprint" ) );
876
877 pcbframe->Raise();
878 toolMgr->RunAction( PCB_ACTIONS::placeFootprint, false, newFootprint );
879
880 newFootprint->ClearFlags();
881 }
882}
883
884
886{
887 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
888 wxCHECK( cfg, /*void*/ );
889
890 // We don't allow people to change this right now, so make sure it's on
892
894
895 // Fetch display and grid settings from Footprint Editor
896 auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
897 m_displayOptions = fpedit->m_Display;
898 GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
899
902
903 // Set parameters to a reasonable value.
904 int maxWidth = cfg->m_FootprintViewer.state.size_x - 80;
905
906 if( m_libListWidth + m_fpListWidth > maxWidth )
907 {
909 m_fpListWidth = maxWidth - m_libListWidth;
910 }
911}
912
913
915{
916 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
917 wxCHECK( cfg, /*void*/ );
918
920
921 // We don't want to store anything other than the window settings
923
924 if( GetCanvas() && GetCanvas()->GetView() )
926
927 wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
928 cfg->m_FootprintViewerAutoZoomOnSelect = ( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED );
929
931 m_libListWidth = m_libList->GetSize().x;
932
933 m_fpListWidth = m_fpList->GetSize().x;
934
937
938}
939
940
942{
943 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
944 wxCHECK_MSG( cfg, nullptr, wxT( "config not existing" ) );
945
946 return &cfg->m_FootprintViewer;
947}
948
949
951{
952 auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
953
954 if( settings )
955 return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
956 else
957 return Pgm().GetSettingsManager().GetColorSettings();
958}
959
960
961void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
962{
963 PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
964
966
967 if( aEnvVarsChanged )
969}
970
971
973{
975}
976
977
978void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
979{
981}
982
983
985{
987}
988
989
991{
993}
994
995
996void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
997{
998 if( event.GetActive() )
999 {
1000 // Ensure we have the right library list:
1001 std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
1002 bool stale = false;
1003
1004 if( libNicknames.size() != m_libList->GetCount() )
1005 stale = true;
1006 else
1007 {
1008 for( unsigned ii = 0; ii < libNicknames.size(); ii++ )
1009 {
1010 if( libNicknames[ii] != m_libList->GetBaseString( ii ) )
1011 {
1012 stale = true;
1013 break;
1014 }
1015 }
1016 }
1017
1018 if( stale )
1019 {
1021 UpdateTitle();
1022 }
1023 }
1024
1025 event.Skip(); // required under wxMAC
1026}
1027
1028
1030{
1031 aEvent.Enable( GetBoard()->GetFirstFootprint() != nullptr );
1032}
1033
1034
1036{
1037 const std::string& payload = mail.GetPayload();
1038
1039 switch( mail.Command() )
1040 {
1042 {
1043 /*
1044 * Symbol netlist format:
1045 * library:footprint
1046 * reference
1047 * value
1048 * pinName,netName,pinFunction,pinType
1049 * pinName,netName,pinFunction,pinType
1050 * ...
1051 */
1052 std::vector<std::string> strings = split( payload, "\r" );
1053 LIB_ID libid;
1054
1055 if( strings.size() >= 3 )
1056 {
1057 libid.Parse( strings[0] );
1058
1059 m_comp.SetFPID( libid );
1060 m_comp.SetReference( strings[1] );
1061 m_comp.SetValue( strings[2] );
1062
1063 m_comp.ClearNets();
1064
1065 for( size_t ii = 3; ii < strings.size(); ++ii )
1066 {
1067 std::vector<std::string> pinData = split( strings[ii], "," );
1068 m_comp.AddNet( pinData[0], pinData[1], pinData[2], pinData[3] );
1069 }
1070 }
1071
1072 break;
1073 }
1074
1075 default:
1076 ;
1077 }
1078}
1079
1080
1081bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
1082{
1083 if( aFootprint && !aFootprint->IsEmpty() )
1084 {
1085 wxString msg;
1086 LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
1087 LIB_ID fpid;
1088
1089 fpid.Parse( *aFootprint, true );
1090
1091 if( fpid.IsValid() )
1092 {
1093 wxString libraryName = fpid.GetLibNickname();
1094
1095 if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
1096 {
1097 msg.sprintf( _( "The current configuration does not include library '%s'. Use "
1098 "Manage Footprint Libraries to edit the configuration." ),
1099 libraryName );
1100 DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
1101 }
1102 else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
1103 {
1104 msg.sprintf( _( "Library '%s' is not enabled in the current configuration. Use "
1105 "Manage Footprint Libraries to edit the configuration." ),
1106 libraryName );
1107 DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
1108 }
1109 else
1110 {
1111 // Update last selection:
1112 setCurNickname( libraryName );
1114 m_libList->SetStringSelection( libraryName );
1115 }
1116 }
1117 }
1118
1119 // Rebuild the fp list from the last selected library,
1120 // and show the last selected footprint
1123
1124 bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
1125
1126 m_libFilter->SetFocus();
1127 return retval;
1128}
1129
1130
1131void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
1132{
1133 wxString title = _( "3D Viewer" ) + wxT( " \u2014 " ) + getCurFootprintName();
1134 PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title );
1135}
1136
1137
1139{
1141}
1142
1143
1145{
1146 switch( event.GetId() )
1147 {
1148 case ID_MODVIEW_NEXT:
1150 break;
1151
1154 break;
1155
1156 default:
1157 wxString id = wxString::Format( wxT( "%i" ), event.GetId() );
1158 wxFAIL_MSG( wxT( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " ) + id );
1159 }
1160}
1161
1162
1164{
1165 wxString title;
1166
1167 if( !getCurNickname().IsEmpty() )
1168 {
1169 try
1170 {
1171 FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
1172 const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
1173
1174 title = getCurNickname() + wxT( " \u2014 " ) + row->GetFullURI( true );
1175 }
1176 catch( ... )
1177 {
1178 title = _( "[no library selected]" );
1179 }
1180 }
1181 else
1182 {
1183 title = _( "[no library selected]" );
1184 }
1185
1186 title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );
1187
1188 SetTitle( title );
1189}
1190
1191
1193{
1194 if( !getCurNickname() )
1195 return;
1196
1197 int selection = m_fpList->FindString( getCurFootprintName(), true );
1198
1199 if( aMode == NEXT_PART )
1200 {
1201 if( selection != wxNOT_FOUND && selection < (int)m_fpList->GetCount() - 1 )
1202 selection++;
1203 }
1204
1205 if( aMode == PREVIOUS_PART )
1206 {
1207 if( selection != wxNOT_FOUND && selection > 0 )
1208 selection--;
1209 }
1210
1211 if( selection != wxNOT_FOUND )
1212 {
1213 m_fpList->SetSelection( selection );
1214 m_fpList->EnsureVisible( selection );
1215
1217
1218 // Delete the current footprint
1221
1224
1225 if( footprint )
1226 displayFootprint( footprint );
1227
1228 Update3DView( true, true );
1229 updateView();
1230 }
1231
1232 UpdateTitle();
1233
1234 GetCanvas()->Refresh();
1235}
1236
1237
1239{
1242
1244
1245 wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
1246
1247 if( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED )
1249 else
1251
1253}
1254
1255
1256void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event )
1257{
1258 Kiway().OnKiCadExit();
1259}
1260
1261
1263{
1264 Close( false );
1265}
1266
1267
1269{
1270 return GetBoard()->GetFirstFootprint();
1271}
1272
const char * name
Definition: DXF_plotter.cpp:56
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ icon_footprint_browser
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
static TOOL_ACTION milsUnits
Definition: actions.h:148
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:107
static TOOL_ACTION centerContents
Definition: actions.h:102
static TOOL_ACTION inchesUnits
Definition: actions.h:147
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:104
static TOOL_ACTION measureTool
Definition: actions.h:157
static TOOL_ACTION selectionTool
Definition: actions.h:156
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION zoomTool
Definition: actions.h:101
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:101
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
std::shared_ptr< NET_SETTINGS > m_NetSettings
Handle actions specific to the board editor in PcbNew.
bool PlacingFootprint() const
Re-entrancy checker for above.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:763
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:670
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:277
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:397
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:534
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition: board.cpp:908
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:602
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
Definition: commit.h:78
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
Definition: common_tools.h:38
Used to store the component pin name to net name (and pin function) associations stored in a netlist.
Definition: pcb_netlist.h:44
const wxString & GetPinFunction() const
Definition: pcb_netlist.h:59
const COMPONENT_NET & GetNet(unsigned aIndex) const
Definition: pcb_netlist.h:111
void SetValue(const wxString &aValue)
Definition: pcb_netlist.h:128
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:137
void ClearNets()
Definition: pcb_netlist.h:115
void AddNet(const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction, const wxString &aPinType)
Definition: pcb_netlist.h:103
void SetReference(const wxString &aReference)
Definition: pcb_netlist.h:125
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
wxAuiManager m_auimgr
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
The base class for create windows for drawing purpose.
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
ACTION_TOOLBAR * m_mainToolBar
virtual void UpdateMsgPanel()
Redraw the message panel.
void OnGridSettings(wxCommandEvent &event)
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
void ForceRefresh()
Force a redraw.
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...
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:156
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:157
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:114
Specialization of the wxAuiPaneInfo class for KiCad panels.
SELECTION_CONDITION BoundingBoxes()
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
static FOOTPRINT_LIST * GetInstance(KIWAY &aKiway)
Factory function to return a FOOTPRINT_LIST via Kiway.
Component library viewer main window.
void displayFootprint(FOOTPRINT *aFootprint)
BOARD_ITEM_CONTAINER * GetModel() const override
void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr) override
Update the 3D view, if the viewer is opened by this frame.
void OnLibFilter(wxCommandEvent &aEvent)
void DClickOnFootprintList(wxMouseEvent &aEvent)
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Receive KIWAY_EXPRESS messages from other players.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
void OnCharHook(wxKeyEvent &aEvent) override
Capture the key event before it is sent to the GUI.
void selectPrev(WX_LISTBOX *aListBox)
void ReCreateLibraryList()
Create or recreate the list of current loaded libraries.
void CloseFootprintViewer(wxCommandEvent &event)
void OnIterateFootprintList(wxCommandEvent &event)
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
virtual COLOR4D GetGridColor() override
void SelectAndViewFootprint(int aMode)
Select and load the next or the previous footprint.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
void OnUpdateFootprintButton(wxUpdateUIEvent &aEvent)
Update the ID_ADD_FOOTPRINT_TO_BOARD tool state in main toolbar.
bool ShowModal(wxString *aFootprint, wxWindow *aParent) override
Run the footprint viewer as a modal dialog.
void OnActivate(wxActivateEvent &event)
Called when the frame frame is activate to reload the libraries and component lists that can be chang...
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
FOOTPRINT_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType)
void setCurFootprintName(const wxString &aName)
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
void OnExitKiCad(wxCommandEvent &event)
void setCurNickname(const wxString &aNickname)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void OnFPFilter(wxCommandEvent &aEvent)
void AddFootprintToPCB(wxCommandEvent &aEvent)
Export the current footprint name and close the library browser.
void UpdateTitle()
Update the window title with current library information.
void selectNext(WX_LISTBOX *aListBox)
void ClickOnLibList(wxCommandEvent &aEvent)
void ClickOnFootprintList(wxCommandEvent &aEvent)
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:1636
void SetLink(const KIID &aLink)
Definition: footprint.h:630
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of pads.
Definition: footprint.cpp:1187
BOARD_ITEM * Duplicate() const override
Create a copy of this BOARD_ITEM.
Definition: footprint.cpp:1819
bool IsFlipped() const
Definition: footprint.h:319
PADS & Pads()
Definition: footprint.h:174
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1553
VECTOR2I GetPosition() const override
Definition: footprint.h:192
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName, bool aKeepUUID=false)
Load a footprint having aFootprintName from the library given by aNickname.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString Problem() const
what was the problem?
Definition: exceptions.cpp:46
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
bool m_axesEnabled
Fullscreen crosshair or small cross.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
double GetScale() const
Definition: view.h:269
void Clear()
Remove all items from the view.
Definition: view.cpp:1096
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:39
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition: kiway_express.h:57
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition: kiway_express.h:49
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
bool IsDismissed()
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
bool IsModal() const override
Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame...
Definition: kiway_player.h:173
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:267
void OnKiCadExit()
Definition: kiway.cpp:657
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
Definition: kiway.cpp:617
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:192
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:50
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:165
UTF8 Format() const
Definition: lib_id.cpp:117
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:98
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
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
static const wxString GetPinningSymbol()
Handle the data for a net.
Definition: netinfo.h:66
void SetNetname(const wxString &aNewName)
Set the long netname to aNetName, and the short netname to the last token in the long netname's path.
Definition: netinfo.h:139
void RemoveUnusedNets()
Definition: pad.h:58
double m_FootprintViewerZoom
The last zoom level used (0 for auto)
DISPLAY_OPTIONS m_Display
bool m_FootprintViewerAutoZoomOnSelect
true to use automatic zoom on fp selection
WINDOW_SETTINGS m_FootprintViewer
int m_FootprintViewerFPListWidth
int m_FootprintViewerLibListWidth
Gather all the actions that are shared by tools.
Definition: pcb_actions.h:49
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:269
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
Definition: pcb_actions.h:427
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:430
static TOOL_ACTION showPadNumbers
Definition: pcb_actions.h:276
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:183
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
PCBNEW_SETTINGS * GetPcbNewSettings() const
FOOTPRINT * loadFootprint(const LIB_ID &aFootprintId)
Attempts to load aFootprintId from the footprint library table.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
BOARD * GetBoard() const
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
Places aFootprint at the current cursor position and updates footprint coordinates with the new posit...
PCB_DISPLAY_OPTIONS m_displayOptions
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
Handle actions that are shared between different frames in PcbNew.
Definition: pcb_control.h:47
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 DisplayBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
Group generic conditions for PCB editor states.
SELECTION_CONDITION PadFillDisplay()
Create a functor that tests if the frame fills the pads.
SELECTION_CONDITION GraphicsFillDisplay()
Create a functor that tests if the frame fills graphics items.
SELECTION_CONDITION PadNumbersDisplay()
Create a functor that tests if the pad numbers are displayed.
SELECTION_CONDITION TextFillDisplay()
Create a functor that tests if the frame fills text items.
The main frame for Pcbnew.
Generic tool for picking an item.
The selection tool: currently supports:
Tool useful for viewing footprints.
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:65
@ PCB_FOOTPRINT_VIEWER_FP_NAME
Definition: project.h:176
@ PCB_FOOTPRINT_VIEWER_LIB_NICKNAME
Definition: project.h:177
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:318
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:148
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
Definition: project.cpp:253
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:264
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
@ MODEL_RELOAD
Model changes (required full reload)
Definition: tool_base.h:80
Master controller class:
Definition: tool_manager.h:55
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:196
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
wxString GetBaseString(int n) const
Definition: wx_listbox.cpp:61
int FindString(const wxString &s, bool bCase=false) const override
Definition: wx_listbox.cpp:72
wxString GetStringSelection() const override
Definition: wx_listbox.cpp:32
bool SetStringSelection(const wxString &s) override
Definition: wx_listbox.cpp:43
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:299
This file is part of the common library.
#define _(s)
#define FOOTPRINT_VIEWER_FRAME_NAME_MODAL
#define FOOTPRINT_VIEWER_FRAME_NAME
#define IS_NEW
New item, just created.
Abstract pattern-matching tool and implementations.
@ CTX_LIBITEM
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectDisplayMode EVT_CHOICE(ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice) EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
#define PARENT_STYLE
#define MODAL_STYLE
#define NEW_PART
#define CHECK(x)
#define NONMODAL_STYLE
#define PREVIOUS_PART
#define NEXT_PART
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_FOOTPRINT_VIEWER_MODAL
Definition: frame_type.h:43
@ FRAME_FOOTPRINT_VIEWER
Definition: frame_type.h:42
@ ID_ON_GRID_SELECT
Definition: id.h:145
@ ID_ON_ZOOM_SELECT
Definition: id.h:143
@ ID_GRID_SETTINGS
Definition: id.h:146
KIID niluuid(0)
@ LAYER_GRID
Definition: layer_ids.h:205
@ MAIL_SYMBOL_NETLIST
Definition: mail_type.h:45
Message panel definition file.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
@ ID_ADD_FOOTPRINT_TO_BOARD
Definition: pcbnew_id.h:116
@ ID_MODVIEW_FOOTPRINT_LIST
Definition: pcbnew_id.h:103
@ ID_MODVIEW_PREVIOUS
Definition: pcbnew_id.h:104
@ ID_FPVIEWER_AUTOZOOM_TOOL
Definition: pcbnew_id.h:106
@ ID_MODVIEW_FOOTPRINT_FILTER
Definition: pcbnew_id.h:102
@ ID_MODVIEW_LIB_FILTER
Definition: pcbnew_id.h:100
@ ID_MODVIEW_LIB_LIST
Definition: pcbnew_id.h:101
@ ID_MODVIEW_NEXT
Definition: pcbnew_id.h:105
BOARD * GetBoard()
see class PGM_BASE
void process(const BOARD_CONNECTED_ITEM *item, int net)
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
CITER next(CITER it)
Definition: ptree.cpp:126
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
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Split the input string into a vector of output strings.
Definition: string_utils.h:296
std::vector< wxString > pinned_fp_libs
bool always_show_cursor
Definition: app_settings.h:43
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:83
CURSOR_SETTINGS cursor
Definition: app_settings.h:89
WINDOW_STATE state
Definition: app_settings.h:84
VECTOR2< double > VECTOR2D
Definition: vector2d.h:617
Definition of file extensions used in Kicad.