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-2023 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, PCB_BASE_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 = _HKI( "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 // Create the manager and dispatcher & route draw panel events to the dispatcher
220 m_toolManager = new TOOL_MANAGER;
221 m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
222 drawPanel->GetViewControls(), config(), this );
223 m_actions = new PCB_ACTIONS();
224 m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
225 drawPanel->SetEventDispatcher( m_toolDispatcher );
226
227 m_toolManager->RegisterTool( new PCB_CONTROL );
228 m_toolManager->RegisterTool( new PCB_SELECTION_TOOL );
229 m_toolManager->RegisterTool( new COMMON_TOOLS ); // for std context menus (zoom & grid)
230 m_toolManager->RegisterTool( new COMMON_CONTROL );
231 m_toolManager->RegisterTool( new PCB_PICKER_TOOL ); // for setting grid origin
232 m_toolManager->RegisterTool( new ZOOM_TOOL );
233 m_toolManager->RegisterTool( new PCB_VIEWER_TOOLS );
234
235 m_toolManager->GetTool<PCB_VIEWER_TOOLS>()->SetFootprintFrame( true );
236
237 m_toolManager->InitTools();
238 m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
239
240 setupUIConditions();
241 ReCreateMenuBar();
242 ReCreateHToolbar();
243 ReCreateVToolbar();
244 ReCreateOptToolbar();
245
246 ReCreateLibraryList();
247 UpdateTitle();
248
249 // Call resolveCanvasType after loading settings:
250 resolveCanvasType();
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
377 FOOTPRINT* fp = static_cast<FOOTPRINT*>( GetModel() );
378
379 if( fp )
380 {
381 std::vector<MSG_PANEL_ITEM> msgItems;
382 fp->GetMsgPanelInfo( this, msgItems );
383 SetMsgPanel( msgItems );
384 }
385}
386
387
389{
391
393 PCB_EDITOR_CONDITIONS cond( this );
394
395 wxASSERT( mgr );
396
397#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
398#define CHECK( x ) ACTION_CONDITIONS().Check( x )
399
405
406
413
419
420#undef ENABLE
421#undef CHECK
422}
423
424
426{
427 // A workaround to avoid flicker, in modal mode when modview frame is destroyed,
428 // when the aui toolbar is not docked (i.e. shown in a miniframe)
429 // (useful on windows only)
430 m_mainToolBar->SetFocus();
431
433
434 if( IsModal() )
435 {
436 // Only dismiss a modal frame once, so that the return values set by
437 // the prior DismissModal() are not bashed for ShowModal().
438 if( !IsDismissed() )
439 DismissModal( false );
440
441 // window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
442 }
443 else
444 {
445 Destroy();
446 }
447}
448
449
450void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
451{
452 if( m_auimgr.GetManagedWindow() )
453 m_auimgr.Update();
454
455 SizeEv.Skip();
456}
457
458
460{
461 m_libList->Clear();
462
463 COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
465 std::vector<wxString> nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
466 std::vector<wxString> pinnedMatches;
467 std::vector<wxString> otherMatches;
468
469 auto process =
470 [&]( const wxString& aNickname )
471 {
472 if( alg::contains( project.m_PinnedFootprintLibs, aNickname )
473 || alg::contains( cfg->m_Session.pinned_fp_libs, aNickname ) )
474 {
475 pinnedMatches.push_back( aNickname );
476 }
477 else
478 {
479 otherMatches.push_back( aNickname );
480 }
481 };
482
483 if( m_libFilter->GetValue().IsEmpty() )
484 {
485 for( const wxString& nickname : nicknames )
486 process( nickname );
487 }
488 else
489 {
490 wxStringTokenizer tokenizer( m_libFilter->GetValue() );
491
492 while( tokenizer.HasMoreTokens() )
493 {
494 const wxString term = tokenizer.GetNextToken().Lower();
495 EDA_COMBINED_MATCHER matcher( term, CTX_LIBITEM );
496 int matches, position;
497
498 for( const wxString& nickname : nicknames )
499 {
500 if( matcher.Find( nickname.Lower(), matches, position ) )
501 process( nickname );
502 }
503 }
504 }
505
506 for( const wxString& nickname : pinnedMatches )
508
509 for( const wxString& nickname : otherMatches )
510 m_libList->Append( nickname );
511
512 // Search for a previous selection:
513 int index = m_libList->FindString( getCurNickname(), true );
514
515 if( index == wxNOT_FOUND )
516 {
517 if( m_libList->GetCount() > 0 )
518 {
519 m_libList->SetSelection( 0 );
520 wxCommandEvent dummy;
522 }
523 else
524 {
525 setCurNickname( wxEmptyString );
526 setCurFootprintName( wxEmptyString );
527 }
528 }
529 else
530 {
531 m_libList->SetSelection( index, true );
532 wxCommandEvent dummy;
534 }
535
536 GetCanvas()->Refresh();
537}
538
539
541{
542 m_fpList->Clear();
543
544 if( !getCurNickname() )
545 setCurFootprintName( wxEmptyString );
546
547 auto fp_info_list = FOOTPRINT_LIST::GetInstance( Kiway() );
548
549 wxString nickname = getCurNickname();
550
551 fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? nullptr : &nickname );
552
553 if( fp_info_list->GetErrorCount() )
554 {
555 fp_info_list->DisplayErrors( this );
556
557 // For footprint libraries that support one footprint per file, there may have been
558 // valid footprints read so show the footprints that loaded properly.
559 if( fp_info_list->GetList().empty() )
560 return;
561 }
562
563 std::set<wxString> excludes;
564
565 if( !m_fpFilter->GetValue().IsEmpty() )
566 {
567 wxStringTokenizer tokenizer( m_fpFilter->GetValue() );
568
569 while( tokenizer.HasMoreTokens() )
570 {
571 const wxString term = tokenizer.GetNextToken().Lower();
572 EDA_COMBINED_MATCHER matcher( term, CTX_LIBITEM );
573 int matches, position;
574
575 for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
576 {
577 wxString search = footprint->GetFootprintName() + wxS( " " ) + footprint->GetSearchText();
578 bool matched = matcher.Find( search.Lower(), matches, position );
579
580 if( !matched && term.IsNumber() )
581 matched = ( wxAtoi( term ) == (int)footprint->GetPadCount() );
582
583 if( !matched )
584 excludes.insert( footprint->GetFootprintName() );
585 }
586 }
587 }
588
589 for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
590 {
591 if( !excludes.count( footprint->GetFootprintName() ) )
592 m_fpList->Append( footprint->GetFootprintName() );
593 }
594
595 int index = m_fpList->FindString( getCurFootprintName(), true );
596
597 if( index == wxNOT_FOUND )
598 {
599 if( m_fpList->GetCount() > 0 )
600 {
601 m_fpList->SetSelection( 0 );
602 m_fpList->EnsureVisible( 0 );
603
604 wxCommandEvent dummy;
606 }
607 else
608 {
609 setCurFootprintName( wxEmptyString );
610 }
611 }
612 else
613 {
614 m_fpList->SetSelection( index, true );
615 m_fpList->EnsureVisible( index );
616 }
617}
618
619
620void FOOTPRINT_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
621{
623
624 // Required to avoid interaction with SetHint()
625 // See documentation for wxTextEntry::SetHint
626 aEvent.Skip();
627}
628
629
630void FOOTPRINT_VIEWER_FRAME::OnFPFilter( wxCommandEvent& aEvent )
631{
633
634 // Required to avoid interaction with SetHint()
635 // See documentation for wxTextEntry::SetHint
636 aEvent.Skip();
637}
638
639
640void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
641{
642 if( aEvent.GetKeyCode() == WXK_UP )
643 {
644 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
646 else
648 }
649 else if( aEvent.GetKeyCode() == WXK_DOWN )
650 {
651 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
653 else
655 }
656 else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
657 {
658 if( !aEvent.ShiftDown() )
659 m_fpFilter->SetFocus();
660 else
661 aEvent.Skip();
662 }
663 else if( aEvent.GetKeyCode() == WXK_TAB && m_fpFilter->HasFocus() )
664 {
665 if( aEvent.ShiftDown() )
666 m_libFilter->SetFocus();
667 else
668 aEvent.Skip();
669 }
670 else if( aEvent.GetKeyCode() == WXK_RETURN && m_fpList->GetSelection() >= 0 )
671 {
672 wxCommandEvent dummy;
674 }
675 else
676 {
677 aEvent.Skip();
678 }
679}
680
681
683{
684 int prev = aListBox->GetSelection() - 1;
685
686 if( prev >= 0 )
687 {
688 aListBox->SetSelection( prev );
689 aListBox->EnsureVisible( prev );
690
691 wxCommandEvent dummy;
692
693 if( aListBox == m_libList )
695 else
697 }
698}
699
700
702{
703 int next = aListBox->GetSelection() + 1;
704
705 if( next < (int)aListBox->GetCount() )
706 {
707 aListBox->SetSelection( next );
708 aListBox->EnsureVisible( next );
709
710 wxCommandEvent dummy;
711
712 if( aListBox == m_libList )
714 else
716 }
717}
718
719
720void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& aEvent )
721{
722 int ii = m_libList->GetSelection();
723
724 if( ii < 0 )
725 return;
726
727 wxString name = m_libList->GetBaseString( ii );
728
729 if( getCurNickname() == name )
730 return;
731
733
735 UpdateTitle();
736}
737
738
740{
741 if( m_fpList->GetCount() == 0 )
742 return;
743
744 int ii = m_fpList->GetSelection();
745
746 if( ii < 0 )
747 return;
748
749 wxString name = m_fpList->GetBaseString( ii );
750
751 if( getCurFootprintName().CmpNoCase( name ) != 0 )
752 {
754
755 // Delete the current footprint (MUST reset tools first)
757
760
761 LIB_ID id;
763 id.SetLibItemName( getCurFootprintName() );
764
765 FOOTPRINT* footprint = nullptr;
766
767 try
768 {
769 footprint = loadFootprint( id );
770 }
771 catch( const IO_ERROR& ioe )
772 {
773 wxString msg = wxString::Format( _( "Could not load footprint '%s' from library '%s'."
774 "\n\n%s" ),
777 ioe.Problem() );
778 DisplayError( this, msg );
779 }
780
781 if( footprint )
782 displayFootprint( footprint );
783
784 UpdateTitle();
785
786 updateView();
787
788 GetCanvas()->Refresh();
789 Update3DView( true, true );
790 }
791}
792
793
795{
796 for( PAD* pad : aFootprint->Pads() )
797 {
798 const COMPONENT_NET& net = m_comp.GetNet( pad->GetNumber() );
799
800 if( !net.GetPinFunction().IsEmpty() )
801 {
802 NETINFO_ITEM* netinfo = new NETINFO_ITEM( GetBoard() );
803 netinfo->SetNetname( net.GetPinFunction() );
804 GetBoard()->Add( netinfo );
805 pad->SetNet( netinfo );
806 }
807 }
808
809 GetBoard()->Add( aFootprint );
810}
811
812
814{
815 wxCommandEvent evt;
816 AddFootprintToPCB( evt );
817}
818
819
820void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
821{
822 if( IsModal() )
823 {
824 if( m_fpList->GetSelection() >= 0 )
825 {
827 DismissModal( true, fpid.Format() );
828 }
829 else
830 {
831 DismissModal( false );
832 }
833 }
834 else if( GetBoard()->GetFirstFootprint() )
835 {
836 PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
837 PCBNEW_SETTINGS* cfg = pcbframe->GetPcbNewSettings();
838
839 if( pcbframe == nullptr ) // happens when the board editor is not active (or closed)
840 {
841 DisplayErrorMessage( this, _( "No board currently open." ) );
842 return;
843 }
844
845 TOOL_MANAGER* toolMgr = pcbframe->GetToolManager();
846
848 {
849 DisplayError( this, _( "Previous footprint placement still in progress." ) );
850 return;
851 }
852
853 wxWindow* blocking_dialog = pcbframe->Kiway().GetBlockingDialog();
854
855 if( blocking_dialog )
856 blocking_dialog->Close( true );
857
858 toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
859 BOARD_COMMIT commit( pcbframe );
860
861 // Create the "new" footprint
862 FOOTPRINT* newFootprint = (FOOTPRINT*) GetBoard()->GetFirstFootprint()->Duplicate();
863 newFootprint->SetParent( pcbframe->GetBoard() );
864 newFootprint->SetLink( niluuid );
865 newFootprint->SetFlags(IS_NEW ); // whatever
866
867 for( PAD* pad : newFootprint->Pads() )
868 {
869 // Set the pads ratsnest settings to the global settings
870 pad->SetLocalRatsnestVisible( cfg->m_Display.m_ShowGlobalRatsnest );
871
872 // Pads in the library all have orphaned nets. Replace with Default.
873 pad->SetNetCode( 0 );
874 }
875
876 // Put it on FRONT layer,
877 // (Can be stored flipped if the lib is an archive built from a board)
878 if( newFootprint->IsFlipped() )
879 newFootprint->Flip( newFootprint->GetPosition(), cfg->m_FlipLeftRight );
880
881 KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
882 VECTOR2D cursorPos = viewControls->GetCursorPosition();
883
884 commit.Add( newFootprint );
885 viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
886 pcbframe->PlaceFootprint( newFootprint );
887
888 newFootprint->SetPosition( wxPoint( 0, 0 ) );
889 viewControls->SetCrossHairCursorPosition( cursorPos, false );
890 commit.Push( wxT( "Insert footprint" ) );
891
892 pcbframe->Raise();
893 toolMgr->RunAction( PCB_ACTIONS::placeFootprint, false, newFootprint );
894
895 newFootprint->ClearFlags();
896 }
897}
898
899
901{
902 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
903 wxCHECK( cfg, /*void*/ );
904
905 // We don't allow people to change this right now, so make sure it's on
907
909
910 // Fetch display and grid settings from Footprint Editor
911 auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
912 m_displayOptions = fpedit->m_Display;
913 GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
914
917
918 // Set parameters to a reasonable value.
919 int maxWidth = cfg->m_FootprintViewer.state.size_x - 80;
920
921 if( m_libListWidth + m_fpListWidth > maxWidth )
922 {
924 m_fpListWidth = maxWidth - m_libListWidth;
925 }
926}
927
928
930{
931 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
932 wxCHECK( cfg, /*void*/ );
933
935
936 // We don't want to store anything other than the window settings
938
939 if( GetCanvas() && GetCanvas()->GetView() )
941
942 wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
943 cfg->m_FootprintViewerAutoZoomOnSelect = ( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED );
944
946 m_libListWidth = m_libList->GetSize().x;
947
948 m_fpListWidth = m_fpList->GetSize().x;
949
952
953}
954
955
957{
958 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
959 wxCHECK_MSG( cfg, nullptr, wxT( "config not existing" ) );
960
961 return &cfg->m_FootprintViewer;
962}
963
964
966{
967 auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
968
969 if( settings )
970 return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
971 else
972 return Pgm().GetSettingsManager().GetColorSettings();
973}
974
975
976void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
977{
978 PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
979
981
982 if( aEnvVarsChanged )
984}
985
986
988{
990}
991
992
993void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
994{
996}
997
998
1000{
1002}
1003
1004
1006{
1008}
1009
1010
1011void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
1012{
1013 if( event.GetActive() )
1014 {
1015 // Ensure we have the right library list:
1016 std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
1017 bool stale = false;
1018
1019 if( libNicknames.size() != m_libList->GetCount() )
1020 stale = true;
1021 else
1022 {
1023 for( unsigned ii = 0; ii < libNicknames.size(); ii++ )
1024 {
1025 if( libNicknames[ii] != m_libList->GetBaseString( ii ) )
1026 {
1027 stale = true;
1028 break;
1029 }
1030 }
1031 }
1032
1033 if( stale )
1034 {
1036 UpdateTitle();
1037 }
1038 }
1039
1040 event.Skip(); // required under wxMAC
1041}
1042
1043
1045{
1046 aEvent.Enable( GetBoard()->GetFirstFootprint() != nullptr );
1047}
1048
1049
1051{
1052 const std::string& payload = mail.GetPayload();
1053
1054 switch( mail.Command() )
1055 {
1057 {
1058 /*
1059 * Symbol netlist format:
1060 * library:footprint
1061 * reference
1062 * value
1063 * pinName,netName,pinFunction,pinType
1064 * pinName,netName,pinFunction,pinType
1065 * ...
1066 */
1067 std::vector<std::string> strings = split( payload, "\r" );
1068 LIB_ID libid;
1069
1070 if( strings.size() >= 3 )
1071 {
1072 libid.Parse( strings[0] );
1073
1074 m_comp.SetFPID( libid );
1075 m_comp.SetReference( strings[1] );
1076 m_comp.SetValue( strings[2] );
1077
1078 m_comp.ClearNets();
1079
1080 for( size_t ii = 3; ii < strings.size(); ++ii )
1081 {
1082 std::vector<std::string> pinData = split( strings[ii], "," );
1083 m_comp.AddNet( pinData[0], pinData[1], pinData[2], pinData[3] );
1084 }
1085 }
1086
1087 break;
1088 }
1089
1090 default:
1091 ;
1092 }
1093}
1094
1095
1096bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
1097{
1098 if( aFootprint && !aFootprint->IsEmpty() )
1099 {
1100 wxString msg;
1101 LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
1102 LIB_ID fpid;
1103
1104 fpid.Parse( *aFootprint, true );
1105
1106 if( fpid.IsValid() )
1107 {
1108 wxString libraryName = fpid.GetLibNickname();
1109
1110 if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
1111 {
1112 msg.sprintf( _( "The current configuration does not include library '%s'. Use "
1113 "Manage Footprint Libraries to edit the configuration." ),
1114 libraryName );
1115 DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
1116 }
1117 else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
1118 {
1119 msg.sprintf( _( "Library '%s' is not enabled in the current configuration. Use "
1120 "Manage Footprint Libraries to edit the configuration." ),
1121 libraryName );
1122 DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
1123 }
1124 else
1125 {
1126 // Update last selection:
1127 setCurNickname( libraryName );
1129 m_libList->SetStringSelection( libraryName );
1130 }
1131 }
1132 }
1133
1134 // Rebuild the fp list from the last selected library,
1135 // and show the last selected footprint
1138
1139 bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
1140
1141 m_libFilter->SetFocus();
1142 return retval;
1143}
1144
1145
1146void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
1147{
1148 wxString title = _( "3D Viewer" ) + wxT( " \u2014 " ) + getCurFootprintName();
1149 PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title );
1150}
1151
1152
1154{
1156}
1157
1158
1160{
1161 switch( event.GetId() )
1162 {
1163 case ID_MODVIEW_NEXT:
1165 break;
1166
1169 break;
1170
1171 default:
1172 wxString id = wxString::Format( wxT( "%i" ), event.GetId() );
1173 wxFAIL_MSG( wxT( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " ) + id );
1174 }
1175}
1176
1177
1179{
1180 wxString title;
1181
1182 if( !getCurNickname().IsEmpty() )
1183 {
1184 try
1185 {
1186 FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
1187 const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
1188
1189 title = getCurNickname() + wxT( " \u2014 " ) + row->GetFullURI( true );
1190 }
1191 catch( ... )
1192 {
1193 title = _( "[no library selected]" );
1194 }
1195 }
1196 else
1197 {
1198 title = _( "[no library selected]" );
1199 }
1200
1201 title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );
1202
1203 SetTitle( title );
1204}
1205
1206
1208{
1209 if( !getCurNickname() )
1210 return;
1211
1212 int selection = m_fpList->FindString( getCurFootprintName(), true );
1213
1214 if( aMode == NEXT_PART )
1215 {
1216 if( selection != wxNOT_FOUND && selection < (int)m_fpList->GetCount() - 1 )
1217 selection++;
1218 }
1219
1220 if( aMode == PREVIOUS_PART )
1221 {
1222 if( selection != wxNOT_FOUND && selection > 0 )
1223 selection--;
1224 }
1225
1226 if( selection != wxNOT_FOUND )
1227 {
1228 m_fpList->SetSelection( selection );
1229 m_fpList->EnsureVisible( selection );
1230
1232
1233 // Delete the current footprint
1236
1239
1240 if( footprint )
1241 displayFootprint( footprint );
1242
1243 Update3DView( true, true );
1244 updateView();
1245 }
1246
1247 UpdateTitle();
1248
1249 GetCanvas()->Refresh();
1250}
1251
1252
1254{
1257
1259
1260 wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
1261
1262 if( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED )
1264 else
1266
1268}
1269
1270
1271void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event )
1272{
1273 Kiway().OnKiCadExit();
1274}
1275
1276
1278{
1279 Close( false );
1280}
1281
1282
1284{
1285 return GetBoard()->GetFirstFootprint();
1286}
1287
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:110
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:765
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:750
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:614
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition: board.cpp:988
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:682
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)
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
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:139
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
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 UpdateMsgPanel() override
Redraw the message panel.
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:1670
void SetLink(const KIID &aLink)
Definition: footprint.h:681
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of pads.
Definition: footprint.cpp:1210
BOARD_ITEM * Duplicate() const override
Create a copy of this BOARD_ITEM.
Definition: footprint.cpp:1856
bool IsFlipped() const
Definition: footprint.h:324
PADS & Pads()
Definition: footprint.h:170
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:1017
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1586
VECTOR2I GetPosition() const override
Definition: footprint.h:188
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:1099
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:159
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:274
void OnKiCadExit()
Definition: kiway.cpp:668
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:620
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:172
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:102
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:67
void SetNetname(const wxString &aNewName)
Set the long netname to aNetName, the short netname to the last token in the long netname's path,...
Definition: netinfo.h:145
void RemoveUnusedNets()
Definition: pad.h:59
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:280
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:438
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:441
static TOOL_ACTION showPadNumbers
Definition: pcb_actions.h:287
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:190
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:177
@ PCB_FOOTPRINT_VIEWER_LIB_NICKNAME
Definition: project.h:178
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:324
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:149
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:254
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:265
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:300
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
This file is part of the common library.
#define _HKI(x)
#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
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
std::vector< FAB_LAYER_COLOR > dummy
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:92
CURSOR_SETTINGS cursor
Definition: app_settings.h:98
WINDOW_STATE state
Definition: app_settings.h:93
VECTOR2< double > VECTOR2D
Definition: vector2d.h:617
Definition of file extensions used in Kicad.