KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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
402 mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
403 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
404 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
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
497 for( const wxString& nickname : nicknames )
498 {
499 if( matcher.Find( nickname.Lower() ) )
500 process( nickname );
501 }
502 }
503 }
504
505 for( const wxString& nickname : pinnedMatches )
507
508 for( const wxString& nickname : otherMatches )
509 m_libList->Append( nickname );
510
511 // Search for a previous selection:
512 int index = m_libList->FindString( getCurNickname(), true );
513
514 if( index == wxNOT_FOUND )
515 {
516 if( m_libList->GetCount() > 0 )
517 {
518 m_libList->SetSelection( 0 );
519 wxCommandEvent dummy;
521 }
522 else
523 {
524 setCurNickname( wxEmptyString );
525 setCurFootprintName( wxEmptyString );
526 }
527 }
528 else
529 {
530 m_libList->SetSelection( index, true );
531 wxCommandEvent dummy;
533 }
534
535 GetCanvas()->Refresh();
536}
537
538
540{
541 m_fpList->Clear();
542
543 if( !getCurNickname() )
544 setCurFootprintName( wxEmptyString );
545
546 auto fp_info_list = FOOTPRINT_LIST::GetInstance( Kiway() );
547
548 wxString nickname = getCurNickname();
549
550 fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? nullptr : &nickname );
551
552 if( fp_info_list->GetErrorCount() )
553 {
554 fp_info_list->DisplayErrors( this );
555
556 // For footprint libraries that support one footprint per file, there may have been
557 // valid footprints read so show the footprints that loaded properly.
558 if( fp_info_list->GetList().empty() )
559 return;
560 }
561
562 std::set<wxString> excludes;
563
564 if( !m_fpFilter->GetValue().IsEmpty() )
565 {
566 wxStringTokenizer tokenizer( m_fpFilter->GetValue() );
567
568 while( tokenizer.HasMoreTokens() )
569 {
570 const wxString filterTerm = tokenizer.GetNextToken().Lower();
571 EDA_COMBINED_MATCHER matcher( filterTerm, CTX_LIBITEM );
572
573 for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
574 {
575 std::vector<SEARCH_TERM> searchTerms = footprint->GetSearchTerms();
576 int matched = matcher.ScoreTerms( searchTerms );
577
578 if( filterTerm.IsNumber() && wxAtoi( filterTerm ) == (int)footprint->GetPadCount() )
579 matched++;
580
581 if( !matched )
582 excludes.insert( footprint->GetFootprintName() );
583 }
584 }
585 }
586
587 for( const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
588 {
589 if( !excludes.count( footprint->GetFootprintName() ) )
590 m_fpList->Append( footprint->GetFootprintName() );
591 }
592
593 int index = m_fpList->FindString( getCurFootprintName(), true );
594
595 if( index == wxNOT_FOUND )
596 {
597 if( m_fpList->GetCount() > 0 )
598 {
599 m_fpList->SetSelection( 0 );
600 m_fpList->EnsureVisible( 0 );
601
602 wxCommandEvent dummy;
604 }
605 else
606 {
607 setCurFootprintName( wxEmptyString );
608 }
609 }
610 else
611 {
612 m_fpList->SetSelection( index, true );
613 m_fpList->EnsureVisible( index );
614 }
615}
616
617
618void FOOTPRINT_VIEWER_FRAME::OnLibFilter( wxCommandEvent& aEvent )
619{
621
622 // Required to avoid interaction with SetHint()
623 // See documentation for wxTextEntry::SetHint
624 aEvent.Skip();
625}
626
627
628void FOOTPRINT_VIEWER_FRAME::OnFPFilter( wxCommandEvent& aEvent )
629{
631
632 // Required to avoid interaction with SetHint()
633 // See documentation for wxTextEntry::SetHint
634 aEvent.Skip();
635}
636
637
638void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
639{
640 if( aEvent.GetKeyCode() == WXK_UP )
641 {
642 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
644 else
646 }
647 else if( aEvent.GetKeyCode() == WXK_DOWN )
648 {
649 if( m_libFilter->HasFocus() || m_libList->HasFocus() )
651 else
653 }
654 else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
655 {
656 if( !aEvent.ShiftDown() )
657 m_fpFilter->SetFocus();
658 else
659 aEvent.Skip();
660 }
661 else if( aEvent.GetKeyCode() == WXK_TAB && m_fpFilter->HasFocus() )
662 {
663 if( aEvent.ShiftDown() )
664 m_libFilter->SetFocus();
665 else
666 aEvent.Skip();
667 }
668 else if( ( aEvent.GetKeyCode() == WXK_RETURN || aEvent.GetKeyCode() == WXK_NUMPAD_ENTER )
669 && m_fpList->GetSelection() >= 0 )
670 {
671 wxCommandEvent dummy;
673 }
674 else
675 {
676 aEvent.Skip();
677 }
678}
679
680
682{
683 int prev = aListBox->GetSelection() - 1;
684
685 if( prev >= 0 )
686 {
687 aListBox->SetSelection( prev );
688 aListBox->EnsureVisible( prev );
689
690 wxCommandEvent dummy;
691
692 if( aListBox == m_libList )
694 else
696 }
697}
698
699
701{
702 int next = aListBox->GetSelection() + 1;
703
704 if( next < (int)aListBox->GetCount() )
705 {
706 aListBox->SetSelection( next );
707 aListBox->EnsureVisible( next );
708
709 wxCommandEvent dummy;
710
711 if( aListBox == m_libList )
713 else
715 }
716}
717
718
719void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& aEvent )
720{
721 int ii = m_libList->GetSelection();
722
723 if( ii < 0 )
724 return;
725
726 wxString name = m_libList->GetBaseString( ii );
727
728 if( getCurNickname() == name )
729 return;
730
732
733 // Ensure the displayed footprint is loade/reloaded from the new library
734 setCurFootprintName( wxEmptyString );
735
737 UpdateTitle();
738}
739
740
742{
743 if( m_fpList->GetCount() == 0 )
744 return;
745
746 int ii = m_fpList->GetSelection();
747
748 if( ii < 0 )
749 return;
750
751 wxString name = m_fpList->GetBaseString( ii );
752
753 if( getCurFootprintName().CmpNoCase( name ) != 0 )
754 {
756
757 // Delete the current footprint (MUST reset tools first)
759
762
763 LIB_ID id;
765 id.SetLibItemName( getCurFootprintName() );
766
767 FOOTPRINT* footprint = nullptr;
768
769 try
770 {
771 footprint = loadFootprint( id );
772 }
773 catch( const IO_ERROR& ioe )
774 {
775 wxString msg = wxString::Format( _( "Could not load footprint '%s' from library '%s'."
776 "\n\n%s" ),
779 ioe.Problem() );
780 DisplayError( this, msg );
781 }
782
783 if( footprint )
784 displayFootprint( footprint );
785
786 UpdateTitle();
787
788 updateView();
789
790 GetCanvas()->Refresh();
791 Update3DView( true, true );
792 }
793}
794
795
797{
798 for( PAD* pad : aFootprint->Pads() )
799 {
800 const COMPONENT_NET& net = m_comp.GetNet( pad->GetNumber() );
801
802 if( !net.GetPinFunction().IsEmpty() )
803 {
804 NETINFO_ITEM* netinfo = new NETINFO_ITEM( GetBoard() );
805 netinfo->SetNetname( net.GetPinFunction() );
806 GetBoard()->Add( netinfo );
807 pad->SetNet( netinfo );
808 }
809 }
810
811 GetBoard()->Add( aFootprint );
812}
813
814
816{
817 wxCommandEvent evt;
818 AddFootprintToPCB( evt );
819}
820
821
822void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
823{
824 if( IsModal() )
825 {
826 if( m_fpList->GetSelection() >= 0 )
827 {
829 DismissModal( true, fpid.Format() );
830 }
831 else
832 {
833 DismissModal( false );
834 }
835 }
836 else if( GetBoard()->GetFirstFootprint() )
837 {
838 PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
839 PCBNEW_SETTINGS* cfg = pcbframe->GetPcbNewSettings();
840
841 if( pcbframe == nullptr ) // happens when the board editor is not active (or closed)
842 {
843 DisplayErrorMessage( this, _( "No board currently open." ) );
844 return;
845 }
846
847 TOOL_MANAGER* toolMgr = pcbframe->GetToolManager();
848
850 {
851 DisplayError( this, _( "Previous footprint placement still in progress." ) );
852 return;
853 }
854
855 wxWindow* blocking_dialog = pcbframe->Kiway().GetBlockingDialog();
856
857 if( blocking_dialog )
858 blocking_dialog->Close( true );
859
860 toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
861 BOARD_COMMIT commit( pcbframe );
862
863 // Create the "new" footprint
864 FOOTPRINT* newFootprint = (FOOTPRINT*) GetBoard()->GetFirstFootprint()->Duplicate();
865 newFootprint->SetParent( pcbframe->GetBoard() );
866 newFootprint->SetLink( niluuid );
867 newFootprint->SetFlags(IS_NEW ); // whatever
868
869 for( PAD* pad : newFootprint->Pads() )
870 {
871 // Set the pads ratsnest settings to the global settings
872 pad->SetLocalRatsnestVisible( cfg->m_Display.m_ShowGlobalRatsnest );
873
874 // Pads in the library all have orphaned nets. Replace with Default.
875 pad->SetNetCode( 0 );
876 }
877
878 // Put it on FRONT layer,
879 // (Can be stored flipped if the lib is an archive built from a board)
880 if( newFootprint->IsFlipped() )
881 newFootprint->Flip( newFootprint->GetPosition(), cfg->m_FlipLeftRight );
882
883 KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetCanvas()->GetViewControls();
884 VECTOR2D cursorPos = viewControls->GetCursorPosition();
885
886 commit.Add( newFootprint );
887 viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
888 pcbframe->PlaceFootprint( newFootprint );
889
890 newFootprint->SetPosition( VECTOR2I( 0, 0 ) );
891 viewControls->SetCrossHairCursorPosition( cursorPos, false );
892 commit.Push( wxT( "Insert footprint" ) );
893
894 pcbframe->Raise();
895 toolMgr->RunAction( PCB_ACTIONS::placeFootprint, false, newFootprint );
896
897 newFootprint->ClearFlags();
898 }
899}
900
901
903{
904 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
905 wxCHECK( cfg, /*void*/ );
906
907 // We don't allow people to change this right now, so make sure it's on
909
911
912 // Fetch display and grid settings from Footprint Editor
913 auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
914 m_displayOptions = fpedit->m_Display;
915 GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
916
919
920 // Set parameters to a reasonable value.
921 int maxWidth = cfg->m_FootprintViewer.state.size_x - 80;
922
923 if( m_libListWidth + m_fpListWidth > maxWidth )
924 {
926 m_fpListWidth = maxWidth - m_libListWidth;
927 }
928}
929
930
932{
933 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
934 wxCHECK( cfg, /*void*/ );
935
937
938 // We don't want to store anything other than the window settings
940
941 if( GetCanvas() && GetCanvas()->GetView() )
943
944 wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
945 cfg->m_FootprintViewerAutoZoomOnSelect = ( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED );
946
948 m_libListWidth = m_libList->GetSize().x;
949
950 m_fpListWidth = m_fpList->GetSize().x;
951
954
955}
956
957
959{
960 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
961 wxCHECK_MSG( cfg, nullptr, wxT( "config not existing" ) );
962
963 return &cfg->m_FootprintViewer;
964}
965
966
968{
969 auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
970
971 if( settings )
972 return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
973 else
974 return Pgm().GetSettingsManager().GetColorSettings();
975}
976
977
978void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
979{
980 PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
981
983
984 if( aEnvVarsChanged )
986}
987
988
990{
992}
993
994
995void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
996{
998}
999
1000
1002{
1004}
1005
1006
1008{
1010}
1011
1012
1013void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
1014{
1015 if( event.GetActive() )
1016 {
1017 // Ensure we have the right library list:
1018 std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
1019 bool stale = false;
1020
1021 if( libNicknames.size() != m_libList->GetCount() )
1022 stale = true;
1023 else
1024 {
1025 for( unsigned ii = 0; ii < libNicknames.size(); ii++ )
1026 {
1027 if( libNicknames[ii] != m_libList->GetBaseString( ii ) )
1028 {
1029 stale = true;
1030 break;
1031 }
1032 }
1033 }
1034
1035 if( stale )
1036 {
1038 UpdateTitle();
1039 }
1040 }
1041
1042 event.Skip(); // required under wxMAC
1043}
1044
1045
1047{
1048 aEvent.Enable( GetBoard()->GetFirstFootprint() != nullptr );
1049}
1050
1051
1053{
1054 const std::string& payload = mail.GetPayload();
1055
1056 switch( mail.Command() )
1057 {
1059 {
1060 /*
1061 * Symbol netlist format:
1062 * library:footprint
1063 * reference
1064 * value
1065 * pinName,netName,pinFunction,pinType
1066 * pinName,netName,pinFunction,pinType
1067 * ...
1068 */
1069 std::vector<std::string> strings = split( payload, "\r" );
1070 LIB_ID libid;
1071
1072 if( strings.size() >= 3 )
1073 {
1074 libid.Parse( strings[0] );
1075
1076 m_comp.SetFPID( libid );
1077 m_comp.SetReference( strings[1] );
1078 m_comp.SetValue( strings[2] );
1079
1080 m_comp.ClearNets();
1081
1082 for( size_t ii = 3; ii < strings.size(); ++ii )
1083 {
1084 std::vector<std::string> pinData = split( strings[ii], "," );
1085 m_comp.AddNet( pinData[0], pinData[1], pinData[2], pinData[3] );
1086 }
1087 }
1088
1089 break;
1090 }
1091 case MAIL_RELOAD_LIB:
1092 {
1094 break;
1095 }
1096
1097 default:
1098 ;
1099 }
1100}
1101
1102
1103bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
1104{
1105 if( aFootprint && !aFootprint->IsEmpty() )
1106 {
1107 wxString msg;
1108 LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
1109 LIB_ID fpid;
1110
1111 fpid.Parse( *aFootprint, true );
1112
1113 if( fpid.IsValid() )
1114 {
1115 wxString libraryName = fpid.GetLibNickname();
1116
1117 if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
1118 {
1119 msg.sprintf( _( "The current configuration does not include library '%s'. Use "
1120 "Manage Footprint Libraries to edit the configuration." ),
1121 libraryName );
1122 DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
1123 }
1124 else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
1125 {
1126 msg.sprintf( _( "Library '%s' is not enabled in the current configuration. Use "
1127 "Manage Footprint Libraries to edit the configuration." ),
1128 libraryName );
1129 DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
1130 }
1131 else
1132 {
1133 // Update last selection:
1134 setCurNickname( libraryName );
1136 m_libList->SetStringSelection( libraryName );
1137 }
1138 }
1139 }
1140
1141 // Rebuild the fp list from the last selected library,
1142 // and show the last selected footprint
1145
1146 bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
1147
1148 m_libFilter->SetFocus();
1149 return retval;
1150}
1151
1152
1153void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
1154{
1155 wxString title = _( "3D Viewer" ) + wxT( " \u2014 " ) + getCurFootprintName();
1156 PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title );
1157}
1158
1159
1161{
1163}
1164
1165
1167{
1168 switch( event.GetId() )
1169 {
1170 case ID_MODVIEW_NEXT:
1172 break;
1173
1176 break;
1177
1178 default:
1179 wxString id = wxString::Format( wxT( "%i" ), event.GetId() );
1180 wxFAIL_MSG( wxT( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " ) + id );
1181 }
1182}
1183
1184
1186{
1187 wxString title;
1188
1189 if( !getCurNickname().IsEmpty() )
1190 {
1191 try
1192 {
1193 FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
1194 const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
1195
1196 title = getCurNickname() + wxT( " \u2014 " ) + row->GetFullURI( true );
1197 }
1198 catch( ... )
1199 {
1200 title = _( "[no library selected]" );
1201 }
1202 }
1203 else
1204 {
1205 title = _( "[no library selected]" );
1206 }
1207
1208 title += wxT( " \u2014 " ) + _( "Footprint Library Browser" );
1209
1210 SetTitle( title );
1211}
1212
1213
1215{
1216 if( !getCurNickname() )
1217 return;
1218
1219 int selection = m_fpList->FindString( getCurFootprintName(), true );
1220
1221 if( aMode == NEXT_PART )
1222 {
1223 if( selection != wxNOT_FOUND && selection < (int)m_fpList->GetCount() - 1 )
1224 selection++;
1225 }
1226
1227 if( aMode == PREVIOUS_PART )
1228 {
1229 if( selection != wxNOT_FOUND && selection > 0 )
1230 selection--;
1231 }
1232
1233 if( selection != wxNOT_FOUND )
1234 {
1235 m_fpList->SetSelection( selection );
1236 m_fpList->EnsureVisible( selection );
1237
1239
1240 // Delete the current footprint
1243
1246
1247 if( footprint )
1248 displayFootprint( footprint );
1249
1250 Update3DView( true, true );
1251 updateView();
1252 }
1253
1254 UpdateTitle();
1255
1256 GetCanvas()->Refresh();
1257}
1258
1259
1261{
1264
1266
1267 wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
1268
1269 if( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED )
1271 else
1273
1275}
1276
1277
1278void FOOTPRINT_VIEWER_FRAME::OnExitKiCad( wxCommandEvent& event )
1279{
1280 Kiway().OnKiCadExit();
1281}
1282
1283
1285{
1286 Close( false );
1287}
1288
1289
1291{
1292 return GetBoard()->GetFirstFootprint();
1293}
1294
const char * name
Definition: DXF_plotter.cpp:56
static PGM_BASE * process
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:106
@ icon_footprint_browser
static TOOL_ACTION toggleGrid
Definition: actions.h:144
static TOOL_ACTION millimetersUnits
Definition: actions.h:150
static TOOL_ACTION milsUnits
Definition: actions.h:149
static TOOL_ACTION toggleBoundingBoxes
Definition: actions.h:108
static TOOL_ACTION centerContents
Definition: actions.h:103
static TOOL_ACTION inchesUnits
Definition: actions.h:148
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
static TOOL_ACTION measureTool
Definition: actions.h:158
static TOOL_ACTION selectionTool
Definition: actions.h:157
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION zoomTool
Definition: actions.h:102
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:270
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:800
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:796
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:282
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:405
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:660
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition: board.cpp:1060
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:728
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, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
Definition: commit.h:79
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
int ScoreTerms(std::vector< SEARCH_TERM > &aWeightedTerms)
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
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:123
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:125
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:1652
void SetLink(const KIID &aLink)
Definition: footprint.h:692
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of pads.
Definition: footprint.cpp:1223
BOARD_ITEM * Duplicate() const override
Create a copy of this BOARD_ITEM.
Definition: footprint.cpp:1753
bool IsFlipped() const
Definition: footprint.h:326
PADS & Pads()
Definition: footprint.h:172
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:1023
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1596
VECTOR2I GetPosition() const override
Definition: footprint.h:190
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:103
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:1116
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
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:279
void OnKiCadExit()
Definition: kiway.cpp:733
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:432
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
Definition: kiway.cpp:685
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:196
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:150
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:439
static TOOL_ACTION textOutlines
Display texts as lines.
Definition: pcb_actions.h:442
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 (the sheet for a schematic)
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:283
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:308
This file is part of the common library.
#define CHECK(x)
#define _HKI(x)
#define _(s)
Declaration of the eda_3d_viewer class.
#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 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
PROJECT & Prj()
Definition: kicad.cpp:554
KIID niluuid(0)
KIWAY Kiway
@ LAYER_GRID
Definition: layer_ids.h:205
@ MAIL_SYMBOL_NETLIST
Definition: mail_type.h:45
@ MAIL_RELOAD_LIB
Definition: mail_type.h:55
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
CITER next(CITER it)
Definition: ptree.cpp:126
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
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:297
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:587
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588
Definition of file extensions used in Kicad.