KiCad PCB EDA Suite
Loading...
Searching...
No Matches
cvpcb_mainframe.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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <pgm_base.h>
27#include <bitmaps.h>
28#include <confirm.h>
29#include <eda_dde.h>
30#include <fp_lib_table.h>
31#include <kiface_base.h>
32#include <kiplatform/app.h>
33#include <kiway_express.h>
34#include <string_utils.h>
36#include <macros.h>
39#include <numeric>
40#include <tool/action_manager.h>
41#include <tool/action_toolbar.h>
42#include <tool/common_control.h>
45#include <tool/tool_manager.h>
47#include <wx/statline.h>
48#include <wx/stattext.h>
49
50#include <cvpcb_association.h>
51#include <cvpcb_id.h>
52#include <cvpcb_mainframe.h>
55#include <kiplatform/ui.h>
56#include <listboxes.h>
57#include <tools/cvpcb_actions.h>
59#include <tools/cvpcb_control.h>
60#include <wx/button.h>
61#include <wx/settings.h>
62
63
64#define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
65
66CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
67 KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
69 unityScale ),
70 m_viewerPendingUpdate( false )
71{
72 m_symbolsListBox = nullptr;
73 m_footprintListBox = nullptr;
74 m_librariesListBox = nullptr;
75 m_mainToolBar = nullptr;
76 m_modified = false;
77 m_cannotClose = false;
80 m_tcFilterString = nullptr;
82 m_initialized = false;
83 m_aboutTitle = wxS( "CvPcb" );
84
85 // Give an icon
86 wxIcon icon;
87 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_cvpcb ) );
88 SetIcon( icon );
89
90 SetAutoLayout( true );
91
93
94 setupTools();
98
99 // Create list of available footprints and symbols of the schematic
102
105
106 m_auimgr.SetManagedWindow( this );
107
108 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
109
110 m_auimgr.AddPane( m_librariesListBox, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(1)
111 .Caption( _( "Footprint Libraries" ) )
112 .BestSize((int) ( m_frameSize.x * 0.20 ), m_frameSize.y ) );
113
114 m_auimgr.AddPane( m_symbolsListBox, EDA_PANE().Palette().Name( "Symbols" ).Center().Layer(0)
115 .Caption( _( "Symbol : Footprint Assignments" ) ) );
116
117 m_auimgr.AddPane( m_footprintListBox, EDA_PANE().Palette().Name( "Footprints" ).Right().Layer(1)
118 .Caption( _( "Filtered Footprints" ) )
119 .BestSize((int) ( m_frameSize.x * 0.30 ), m_frameSize.y ) );
120
121 // Build the bottom panel, to display 2 status texts and the buttons:
122 auto bottomPanel = new wxPanel( this );
123 auto panelSizer = new wxBoxSizer( wxVERTICAL );
124
125 wxFlexGridSizer* fgSizerStatus = new wxFlexGridSizer( 3, 1, 0, 0 );
126 fgSizerStatus->SetFlexibleDirection( wxBOTH );
127 fgSizerStatus->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
128
129 m_statusLine1 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
130 fgSizerStatus->Add( m_statusLine1, 0, 0, 5 );
131
132 m_statusLine2 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
133 fgSizerStatus->Add( m_statusLine2, 0, 0, 5 );
134
135 m_statusLine3 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
136 fgSizerStatus->Add( m_statusLine3, 0, wxBOTTOM, 3 );
137
138 panelSizer->Add( fgSizerStatus, 1, wxEXPAND|wxLEFT, 2 );
139
140 m_statusLine1->SetFont( KIUI::GetStatusFont( this ) );
141 m_statusLine2->SetFont( KIUI::GetStatusFont( this ) );
142 m_statusLine3->SetFont( KIUI::GetStatusFont( this ) );
143
144 // Add buttons:
145 auto buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
146 auto sdbSizer = new wxStdDialogButtonSizer();
147
148 m_saveAndContinue = new wxButton( bottomPanel, wxID_ANY,
149 _( "Apply, Save Schematic && Continue" ) );
150 buttonsSizer->Add( m_saveAndContinue, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 20 );
151
152 auto sdbSizerOK = new wxButton( bottomPanel, wxID_OK );
153 sdbSizer->AddButton( sdbSizerOK );
154 auto sdbSizerCancel = new wxButton( bottomPanel, wxID_CANCEL );
155 sdbSizer->AddButton( sdbSizerCancel );
156 sdbSizer->Realize();
157
158 buttonsSizer->Add( sdbSizer, 0, 0, 5 );
159 panelSizer->Add( buttonsSizer, 0, wxALIGN_RIGHT|wxALL, 5 );
160
161 bottomPanel->SetSizer( panelSizer );
162 bottomPanel->Fit();
163
164 sdbSizerOK->SetDefault();
166
167 m_auimgr.AddPane( bottomPanel, EDA_PANE().HToolbar().Name( "Buttons" ).Bottom().Layer(6) );
168
169 m_auimgr.Update();
170 m_initialized = true;
171
172 if( CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( config() ) )
173 {
174 m_tcFilterString->ChangeValue( cfg->m_FilterString );
175
176 if( cfg->m_LibrariesWidth > 0 )
177 {
178 wxAuiPaneInfo& librariesPane = m_auimgr.GetPane( "Libraries" );
179
180 // wxAUI hack: force width by setting MinSize() and then Fixed()
181 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
182 librariesPane.MinSize( cfg->m_LibrariesWidth, -1 );
183 librariesPane.BestSize( cfg->m_LibrariesWidth, -1 );
184 librariesPane.MaxSize( cfg->m_LibrariesWidth, -1 );
185 librariesPane.Fixed();
186 m_auimgr.Update();
187
188 // now make it resizable again
189 librariesPane.MinSize( 20, -1 );
190 librariesPane.Resizable();
191 m_auimgr.Update();
192 }
193
194 if( cfg->m_FootprintsWidth > 0 )
195 {
196 wxAuiPaneInfo& footprintsPane = m_auimgr.GetPane( "Footprints" );
197
198 // wxAUI hack: force width by setting MinSize() and then Fixed()
199 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
200 footprintsPane.MinSize( cfg->m_FootprintsWidth, -1 );
201 footprintsPane.BestSize( cfg->m_FootprintsWidth, -1 );
202 footprintsPane.MaxSize( cfg->m_FootprintsWidth, -1 );
203 footprintsPane.Fixed();
204 m_auimgr.Update();
205
206 // now make it resizable again
207 footprintsPane.MinSize( 20, -1 );
208 footprintsPane.Resizable();
209 m_auimgr.Update();
210 }
211 }
212
213 // Connect Events
215
216 // Start the main processing loop
217 m_toolManager->InvokeTool( "cvpcb.Control" );
218
219 m_filterTimer->StartOnce( 100 );
220
221 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Symbol to footprint changes are unsaved" ) );
222}
223
224
226{
227 // Stop the timer during destruction early to avoid potential race conditions (that do happen)
228 m_filterTimer->Stop();
229
230 // Shutdown all running tools
231 if( m_toolManager )
233
234 // Clean up the tool infrastructure
235 delete m_actions;
236 delete m_toolManager;
237 delete m_toolDispatcher;
238
239 m_auimgr.UnInit();
240}
241
242
244{
245 // Create the manager
246 m_actions = new CVPCB_ACTIONS();
248 m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
250
251 // Register tools
256
258
259 // Even though these menus will open with the right-click, we treat them as a normal
260 // menu instead of a context menu because we don't care about their position and want
261 // to be able to tell the difference between a menu click and a hotkey activation.
262
263 // Create the context menu for the symbols list box
264 m_symbolsContextMenu = new ACTION_MENU( false, tool );
266 m_symbolsContextMenu->AppendSeparator();
270 m_symbolsContextMenu->AppendSeparator();
272
273 // Create the context menu for the footprint list box
274 m_footprintContextMenu = new ACTION_MENU( false, tool );
276}
277
278
280{
282
284 EDITOR_CONDITIONS cond( this );
285
286 wxASSERT( mgr );
287
288#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
289#define CHECK( x ) ACTION_CONDITIONS().Check( x )
290
295
296 auto compFilter =
297 [this] ( const SELECTION& )
298 {
300 };
301
302 auto libFilter =
303 [this] ( const SELECTION& )
304 {
306 };
307
308 auto pinFilter =
309 [this] ( const SELECTION& )
310 {
312 };
313
317
318#undef CHECK
319#undef ENABLE
320}
321
322
324{
325 // Connect the handlers to launch the context menus in the listboxes
326 m_footprintListBox->Bind( wxEVT_RIGHT_DOWN,
327 [this]( wxMouseEvent& )
328 {
329 PopupMenu( m_footprintContextMenu );
330 } );
331
332 m_symbolsListBox->Bind( wxEVT_RIGHT_DOWN,
333 [this]( wxMouseEvent& )
334 {
335 PopupMenu( m_symbolsContextMenu );
336 } );
337
338 // Connect the handler for the save button
339 m_saveAndContinue->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
340 [this]( wxCommandEvent& )
341 {
342 // saveAssociations must be run immediately
344 } );
345
346 // Connect the handlers for the ok/cancel buttons
347 Bind( wxEVT_BUTTON,
348 [this]( wxCommandEvent& )
349 {
350 // saveAssociations must be run immediately, before running Close( true )
352 Close( true );
353 }, wxID_OK );
354 Bind( wxEVT_BUTTON,
355 [this]( wxCommandEvent& )
356 {
357 Close( false );
358 }, wxID_CANCEL );
359
360 // Connect the handlers for the close events
361 Bind( wxEVT_MENU,
362 [this]( wxCommandEvent& )
363 {
364 Close( false );
365 }, wxID_CLOSE );
366 Bind( wxEVT_MENU,
367 [this]( wxCommandEvent& )
368 {
369 Close( false );
370 }, wxID_EXIT );
371
372 // Toolbar events
373 Bind( wxEVT_TEXT, &CVPCB_MAINFRAME::onTextFilterChanged, this );
374
375 // Just skip the resize events
376 Bind( wxEVT_SIZE,
377 []( wxSizeEvent& aEvent )
378 {
379 aEvent.Skip();
380 } );
381
382 // Attach the events to the tool dispatcher
384 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
385
386 m_filterTimer = new wxTimer( this );
387 Bind( wxEVT_TIMER, &CVPCB_MAINFRAME::onTextFilterChangedTimer, this, m_filterTimer->GetId() );
388}
389
390
391bool CVPCB_MAINFRAME::canCloseWindow( wxCloseEvent& aEvent )
392{
393 if( m_modified )
394 {
395 // Shutdown blocks must be determined and vetoed as early as possible
397 && aEvent.GetId() == wxEVT_QUERY_END_SESSION )
398 {
399 return false;
400 }
401
402 if( !HandleUnsavedChanges( this, _( "Symbol to Footprint links have been modified. "
403 "Save changes?" ),
404 [&]() -> bool
405 {
406 return SaveFootprintAssociation( false );
407 } ) )
408 {
409 return false;
410 }
411 }
412
413 if( m_cannotClose )
414 return false;
415
416 return true;
417}
418
419
421{
423 GetFootprintViewerFrame()->Close( true );
424
425 m_modified = false;
426
427 // clear symbol selection in schematic:
429}
430
431
432void CVPCB_MAINFRAME::onTextFilterChanged( wxCommandEvent& event )
433{
434 // Called when changing the filter string in main toolbar.
435 // If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list
436 // of available footprints which match the filter
437
438 m_filterTimer->StartOnce( 200 );
439}
440
441
443{
444 // GTK loses the search-control's focus on a Refresh event, so we record the focus and
445 // insertion point here and then restore them at the end.
446 bool searchCtrlHasFocus = m_tcFilterString->HasFocus();
447 long pos = m_tcFilterString->GetInsertionPoint();
448
450 wxString libraryName = m_librariesListBox->GetSelectedLibrary();
451
452 m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, symbol,
454
455 if( symbol && symbol->GetFPID().IsValid() )
457 else if( m_footprintListBox->GetSelection() >= 0 )
459
461
463
464 if( searchCtrlHasFocus && !m_tcFilterString->HasFocus() )
465 {
466 m_tcFilterString->SetFocus();
467 m_tcFilterString->SetInsertionPoint( pos );
468 }
469}
470
471
472void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
473{
475 return;
476
478 wxString libraryName = m_librariesListBox->GetSelectedLibrary();
479
480 m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, symbol,
482
483 if( symbol && symbol->GetFPID().IsValid() )
485 else if( m_footprintListBox->GetSelection() >= 0 )
487
489
490 refreshAfterSymbolSearch( symbol );
491}
492
493
495{
497 {
498 Bind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintViewerOnIdle, this );
500 }
501}
502
503
505{
506 Unbind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintViewerOnIdle, this );
507 m_viewerPendingUpdate = false;
508
509 // On some plateforms (OSX) the focus is lost when the viewers (fp and 3D viewers)
510 // are opened and refreshed when a new footprint is selected.
511 // If the listbox has the focus before selecting a new footprint, it will be forced
512 // after selection.
513 bool footprintListHasFocus = m_footprintListBox->HasFocus();
514 bool symbolListHasFocus = m_symbolsListBox->HasFocus();
515
516 // If the footprint view window is displayed, update the footprint.
519
521
522 if( footprintListHasFocus )
523 m_footprintListBox->SetFocus();
524 else if( symbolListHasFocus )
525 m_symbolsListBox->SetFocus();
526}
527
528
530{
532
533 CVPCB_SETTINGS* cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
534
536}
537
538
540{
542
543 CVPCB_SETTINGS* cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
545 cfg->m_FilterString = m_tcFilterString->GetValue();
546
547 cfg->m_LibrariesWidth = m_librariesListBox->GetSize().x;
548 cfg->m_FootprintsWidth = m_footprintListBox->GetSize().x;
549}
550
551
553{
554 if( m_undoList.size() == 0 )
555 return;
556
557 CVPCB_UNDO_REDO_ENTRIES redoEntries;
558 CVPCB_UNDO_REDO_ENTRIES curEntry = m_undoList.back();
559 m_undoList.pop_back();
560
561 // Iterate over the entries to undo
562 for( const auto& assoc : curEntry )
563 {
564 AssociateFootprint( assoc, true, false );
565 redoEntries.emplace_back( assoc.Reverse() );
566 }
567
568 // Add the redo entries to the redo stack
569 m_redoList.emplace_back( redoEntries );
570}
571
572
574{
575 if( m_redoList.size() == 0 )
576 return;
577
578 CVPCB_UNDO_REDO_ENTRIES curEntry = m_redoList.back();
579 m_redoList.pop_back();
580
581 // Iterate over the entries to undo
582 bool firstAssoc = true;
583
584 for( const auto& assoc : curEntry )
585 {
586 AssociateFootprint( assoc, firstAssoc );
587 firstAssoc = false;
588 }
589}
590
591
592wxString CVPCB_MAINFRAME::formatSymbolDesc( int idx, const wxString& aReference,
593 const wxString& aValue, const wxString& aFootprint )
594{
595 // Work around a bug in wxString::Format with double-byte chars (and double-quote, for some
596 // reason).
597 wxString desc = wxString::Format( wxT( "%3d " ), idx );
598
599 for( int ii = aReference.Length(); ii < 8; ++ii )
600 desc += wxS( " " );
601
602 desc += aReference + wxT( " - " );
603
604 for( int ii = aValue.Length(); ii < 16; ++ii )
605 desc += wxS( " " );
606
607 desc += aValue + wxT( " : " ) + aFootprint;
608
609 return desc;
610}
611
612
614 bool aNewEntry, bool aAddUndoItem )
615{
616 if( m_netlist.IsEmpty() )
617 return;
618
619 COMPONENT* symbol = m_netlist.GetComponent( aAssociation.GetComponentIndex() );
620
621 if( symbol == nullptr )
622 return;
623
624 LIB_ID fpid = aAssociation.GetNewFootprint();
625 LIB_ID oldFpid = symbol->GetFPID();
626
627 // Test for validity of the requested footprint
628 if( !fpid.empty() && !fpid.IsValid() )
629 {
630 wxString msg = wxString::Format( _( "'%s' is not a valid footprint." ),
631 fpid.Format().wx_str() );
632 DisplayErrorMessage( this, msg );
633 return;
634 }
635
636 const KIID& id = symbol->GetKIIDs().front();
637
638 // Set new footprint to all instances of the selected symbol
639 for( unsigned int idx : GetComponentIndices() )
640 {
641 COMPONENT* candidate = m_netlist.GetComponent( idx );
642 const std::vector<KIID>& kiids = candidate->GetKIIDs();
643
644 if( std::find( kiids.begin(), kiids.end(), id ) != kiids.end() )
645 {
646 // Set the new footprint
647 candidate->SetFPID( fpid );
648
649 // create the new symbol description and set it
650 wxString description = formatSymbolDesc( idx + 1,
651 candidate->GetReference(),
652 candidate->GetValue(),
653 candidate->GetFPID().Format().wx_str() );
654 m_symbolsListBox->SetString( idx, description );
655
656 FOOTPRINT_INFO* fp =
658
659 if( !fp )
660 {
662 }
663 else
664 {
666 }
667 }
668 }
669
670 // Mark the data as being modified
671 m_modified = true;
672
673 // Update the statusbar and refresh the list
675 m_symbolsListBox->Refresh();
676
677 if( !aAddUndoItem )
678 return;
679
680 // Update the undo list
681 if ( aNewEntry )
682 {
683 // Create a new entry for this association
685 newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid,
686 aAssociation.GetNewFootprint() ) );
687 m_undoList.emplace_back( newEntry );
688
689 // Clear the redo list
690 m_redoList.clear();
691 }
692 else
693 {
694 m_undoList.back().emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(),
695 oldFpid,
696 aAssociation.GetNewFootprint() ) );
697 }
698
699}
700
701
702bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
703{
704 return true;
705}
706
707
709{
710 // Tell AuiMgr that objects are changed !
711 if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
712 m_auimgr.Update(); // (could be not the case when starting CvPcb)
713
714 if( aSymbol == nullptr )
715 {
717 return;
718 }
719
720 // Preview of the already assigned footprint.
721 // Find the footprint that was already chosen for this aSymbol and select it,
722 // but only if the selection is made from the aSymbol list or the library list.
723 // If the selection is made from the footprint list, do not change the current
724 // selected footprint.
725 if( FindFocus() == m_symbolsListBox || FindFocus() == m_librariesListBox )
726 {
727 wxString footprintName = FROM_UTF8( aSymbol->GetFPID().Format().c_str() );
728
730
731 for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
732 {
733 wxString candidateName;
734 wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
735 msg.Trim( true );
736 msg.Trim( false );
737 candidateName = msg.AfterFirst( wxChar( ' ' ) );
738
739 if( footprintName.Cmp( candidateName ) == 0 )
740 {
741 m_footprintListBox->SetSelection( ii, true );
742 break;
743 }
744 }
745 }
746
749}
750
751
754{
755 int option = aFilter;
756
757 // Apply the filter accordingly
758 switch( aAction )
759 {
763 }
764
765 wxListEvent l_event;
766 OnSelectComponent( l_event );
767}
768
769
771{
772 if( !m_initialized )
773 return;
774
775 wxString filters, msg;
777
779 {
780 msg.Empty();
781
782 if( symbol )
783 {
784 for( unsigned ii = 0; ii < symbol->GetFootprintFilters().GetCount(); ii++ )
785 {
786 if( msg.IsEmpty() )
787 msg += symbol->GetFootprintFilters()[ii];
788 else
789 msg += wxT( ", " ) + symbol->GetFootprintFilters()[ii];
790 }
791 }
792
793 filters += _( "Keywords" );
794
795 if( !msg.IsEmpty() )
796 filters += wxString::Format( wxT( " (%s)" ), msg );
797 }
798
800 {
801 msg.Empty();
802
803 if( symbol )
804 msg = wxString::Format( wxT( "%i" ), symbol->GetPinCount() );
805
806 if( !filters.IsEmpty() )
807 filters += wxT( ", " );
808
809 filters += _( "Pin Count" );
810
811 if( !msg.IsEmpty() )
812 filters += wxString::Format( wxT( " (%s)" ), msg );
813 }
814
816 {
818
819 if( !filters.IsEmpty() )
820 filters += wxT( ", " );
821
822 filters += _( "Library" );
823
824 if( !msg.IsEmpty() )
825 filters += wxString::Format( wxT( " (%s)" ), msg );
826 }
827
828 wxString textFilter = m_tcFilterString->GetValue();
829
830 if( !textFilter.IsEmpty() )
831 {
832 if( !filters.IsEmpty() )
833 filters += wxT( ", " );
834
835 filters += _( "Search Text" ) + wxString::Format( wxT( " (%s)" ), textFilter );
836 }
837
838 if( filters.IsEmpty() )
839 msg = _( "No Filtering" );
840 else
841 msg.Printf( _( "Filtered by %s" ), filters );
842
843 msg << wxT( ": " ) << m_footprintListBox->GetCount();
844
845 SetStatusText( msg );
846
847
848 msg.Empty();
849 wxString footprintName = GetSelectedFootprint();
850
851 FOOTPRINT_INFO* fp = m_FootprintsList->GetFootprintInfo( footprintName );
852
853 if( fp ) // can be NULL if no netlist loaded
854 {
855 msg = wxString::Format( _( "Description: %s; Keywords: %s" ),
856 fp->GetDescription(),
857 fp->GetKeywords() );
858 }
859
860 SetStatusText( msg, 1 );
861
862 msg.Empty();
863 wxString lib;
864
865 // Choose the footprint to get the information on
866 if( fp )
867 {
868 // Use the footprint in the footprint viewer
869 lib = fp->GetLibNickname();
870 }
872 {
873 // Use the footprint of the selected symbol
874 if( symbol )
875 lib = symbol->GetFPID().GetLibNickname();
876 }
878 {
879 // Use the library that is selected
881 }
882
883 // Extract the library information
884 FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
885
886 if( fptbl->HasLibrary( lib ) )
887 msg = wxString::Format( _( "Library location: %s" ), fptbl->GetFullURI( lib ) );
888 else
889 msg = wxString::Format( _( "Library location: unknown" ) );
890
891 SetStatusText( msg, 2 );
892}
893
894
896{
897 FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
898
899 // Check if there are footprint libraries in the footprint library table.
900 if( !fptbl || !fptbl->GetLogicalLibs().size() )
901 {
902 wxMessageBox( _( "No PCB footprint libraries are listed in the current footprint "
903 "library table." ), _( "Configuration Error" ), wxOK | wxICON_ERROR );
904 return false;
905 }
906
907 WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
908
909 m_FootprintsList->ReadFootprintFiles( fptbl, nullptr, &progressReporter );
910
912 {
914 }
915
916 return true;
917}
918
919
920void CVPCB_MAINFRAME::SendComponentSelectionToSch( bool aClearSelectionOnly )
921{
922 if( m_netlist.IsEmpty() )
923 return;
924
925 std::string command = "$SELECT: ";
926
927 if( aClearSelectionOnly )
928 {
929 // Sending an empty list means clearing the selection.
930 if( Kiface().IsSingle() )
931 SendCommand( MSG_TO_SCH, command );
932 else
933 Kiway().ExpressMail( FRAME_SCH, MAIL_SELECTION, command, this );
934
935 return;
936 }
937
938 int selection = m_symbolsListBox->GetSelection();
939
940 if( selection < 0 ) // Nothing selected
941 return;
942
943 if( m_netlist.GetComponent( selection ) == nullptr )
944 return;
945
946 // Now select the corresponding symbol on the schematic:
947 wxString ref = m_netlist.GetComponent( selection )->GetReference();
948
949 // The prefix 0,F before the reference is for selecting the symbol
950 // (one can select a pin with a different prefix)
951 command += wxT( "0,F" ) + EscapeString( ref, CTX_IPC );
952
953 if( Kiface().IsSingle() )
954 SendCommand( MSG_TO_SCH, command );
955 else
956 Kiway().ExpressMail( FRAME_SCH, MAIL_SELECTION, command, this );
957}
958
959
960int CVPCB_MAINFRAME::readSchematicNetlist( const std::string& aNetlist )
961{
962 STRING_LINE_READER* stringReader = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
963 KICAD_NETLIST_READER netlistReader( stringReader, &m_netlist );
964
966
967 try
968 {
969 netlistReader.LoadNetlist();
970 }
971 catch( const IO_ERROR& ioe )
972 {
973 wxString msg = wxString::Format( _( "Error loading schematic.\n%s" ),
974 ioe.What().GetData() );
975 wxMessageBox( msg, _( "Load Error" ), wxOK | wxICON_ERROR );
976 return 1;
977 }
978
979 // We also remove footprint name if it is "$noname" because this is a dummy name,
980 // not the actual name of the footprint.
981 for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
982 {
983 if( m_netlist.GetComponent( ii )->GetFPID().GetLibItemName() == std::string( "$noname" ) )
985 }
986
987 // Sort symbols by reference:
989
990 return 0;
991}
992
993
995{
996 wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
997
998 if( m_footprintListBox == nullptr )
999 {
1002 }
1003
1004 m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, nullptr, wxEmptyString,
1006 DisplayStatus();
1007}
1008
1009
1011{
1012 wxString msg;
1013 COMPONENT* symbol;
1014 wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
1015
1016 if( m_symbolsListBox == nullptr )
1017 {
1020 }
1021
1023
1024 for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
1025 {
1026 symbol = m_netlist.GetComponent( i );
1027
1029 symbol->GetReference(),
1030 symbol->GetValue(),
1031 symbol->GetFPID().Format().wx_str() );
1032 m_symbolsListBox->m_SymbolList.Add( msg );
1033
1034 FOOTPRINT_INFO* fp =
1036
1037 if( !fp )
1038 {
1040 }
1041 }
1042
1043 if( m_symbolsListBox->m_SymbolList.Count() )
1044 {
1045 m_symbolsListBox->SetItemCount( m_symbolsListBox->m_SymbolList.Count() );
1046 m_symbolsListBox->SetSelection( 0, true );
1047 m_symbolsListBox->RefreshItems( 0L, m_symbolsListBox->m_SymbolList.Count() - 1 );
1049 }
1050}
1051
1052
1054{
1055 COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
1058 std::set<wxString> pinnedMatches;
1059 std::set<wxString> otherMatches;
1061
1062 auto process =
1063 [&]( const wxString& aNickname )
1064 {
1065 if( alg::contains( project.m_PinnedFootprintLibs, aNickname )
1066 || alg::contains( cfg->m_Session.pinned_fp_libs, aNickname ) )
1067 {
1068 pinnedMatches.insert( aNickname );
1069 }
1070 else
1071 {
1072 otherMatches.insert( aNickname );
1073 }
1074 };
1075
1076
1077 if( tbl )
1078 {
1079 wxArrayString libNames;
1080
1081 std::vector< wxString > libNickNames = tbl->GetLogicalLibs();
1082
1083 for( const wxString& libNickName : libNickNames )
1084 process( libNickName );
1085 }
1086
1087 for( const wxString& nickname : pinnedMatches )
1089
1090 for( const wxString& nickname : otherMatches )
1091 m_librariesListBox->AppendLine( nickname );
1092
1094}
1095
1096
1098{
1099 int selection = m_symbolsListBox->GetSelection();
1100
1101 if( selection >= 0 && selection < (int) m_netlist.GetCount() )
1102 return m_netlist.GetComponent( selection );
1103
1104 return nullptr;
1105}
1106
1107
1108void CVPCB_MAINFRAME::SetSelectedComponent( int aIndex, bool aSkipUpdate )
1109{
1110 m_skipComponentSelect = aSkipUpdate;
1111
1112 if( aIndex < 0 )
1113 {
1115 }
1116 else if( aIndex < m_symbolsListBox->GetCount() )
1117 {
1119 m_symbolsListBox->SetSelection( aIndex );
1121 }
1122
1123 m_skipComponentSelect = false;
1124}
1125
1126
1128 CVPCB_MAINFRAME::CRITERIA aCriteria )
1129{
1130 std::vector<unsigned int> idx;
1131 int lastIdx;
1132
1133 // Make sure a netlist has been loaded and the box has contents
1134 if( m_netlist.IsEmpty() || m_symbolsListBox->GetCount() == 0 )
1135 return idx;
1136
1137 switch( aCriteria )
1138 {
1140 idx.resize( m_netlist.GetCount() );
1141 std::iota( idx.begin(), idx.end(), 0 );
1142 break;
1143
1145 // Check to see if anything is selected
1146 if( m_symbolsListBox->GetSelectedItemCount() < 1 )
1147 break;
1148
1149 // Get the symbols
1150 lastIdx = m_symbolsListBox->GetFirstSelected();
1151 idx.emplace_back( lastIdx );
1152
1153 lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
1154 while( lastIdx > 0 )
1155 {
1156 idx.emplace_back( lastIdx );
1157 lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
1158 }
1159 break;
1160
1162 for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
1163 {
1164 if( m_netlist.GetComponent( i )->GetFPID().empty() )
1165 idx.emplace_back( i );
1166 }
1167 break;
1168
1170 for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
1171 {
1172 if( !m_netlist.GetComponent( i )->GetFPID().empty() )
1173 idx.emplace_back( i );
1174 }
1175 break;
1176
1177 default:
1178 wxASSERT_MSG( false, "Invalid symbol selection criteria" );
1179 }
1180
1181 return idx;
1182}
1183
1184
1186{
1187 // returns the Footprint Viewer frame, if exists, or NULL
1188 wxWindow* window = wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME );
1189 return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>( window );
1190}
1191
1192
1194{
1195 return GetFootprintViewerFrame();
1196}
1197
1198
1200{
1201 if( m_librariesListBox->HasFocus() )
1203 else if( m_symbolsListBox->HasFocus() )
1205 else if( m_footprintListBox->HasFocus() )
1207
1209}
1210
1211
1213{
1214 switch( aLB )
1215 {
1219 default: break;
1220 }
1221}
1222
1223
1225{
1226 // returns the LIB_ID of the selected footprint in footprint listview
1227 // or a empty string
1229}
1230
1231
1232void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber )
1233{
1234 switch( aNumber )
1235 {
1236 case 0: m_statusLine1->SetLabel( aText ); break;
1237 case 1: m_statusLine2->SetLabel( aText ); break;
1238 case 2: m_statusLine3->SetLabel( aText ); break;
1239 default: wxFAIL_MSG( "Invalid status row number" ); break;
1240 }
1241}
1242
1243
1245{
1248 DisplayStatus();
1249}
1250
1251
1253{
1254 const std::string& payload = mail.GetPayload();
1255
1256 switch( mail.Command() )
1257 {
1259 // Disable Close events during readNetListAndFpFiles() to avoid crash when updating
1260 // widgets:
1261 m_cannotClose = true;
1262 readNetListAndFpFiles( payload );
1263 m_cannotClose = false;
1264 /* @todo
1265 Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.
1266 */
1267 break;
1268 case MAIL_RELOAD_LIB:
1269 m_cannotClose = true;
1273 m_cannotClose = false;
1274 break;
1275 default:
1276 ; // ignore most
1277 }
1278}
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:112
static PGM_BASE * process
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
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
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION copy
Definition: actions.h:68
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION cut
Definition: actions.h:67
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...
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:110
Handle actions that are shared between different applications.
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:85
const wxString & GetReference() const
Definition: pcb_netlist.h:126
const wxString & GetValue() const
Definition: pcb_netlist.h:129
int GetPinCount() const
Definition: pcb_netlist.h:151
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:137
const wxArrayString & GetFootprintFilters() const
Definition: pcb_netlist.h:148
const std::vector< KIID > & GetKIIDs() const
Definition: pcb_netlist.h:145
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:138
Gather all the actions that are shared by tools.
Definition: cvpcb_actions.h:38
static TOOL_ACTION saveAssociationsToFile
Definition: cvpcb_actions.h:57
static TOOL_ACTION FilterFPbyLibrary
Definition: cvpcb_actions.h:69
static TOOL_ACTION filterFPbyPin
Definition: cvpcb_actions.h:68
static TOOL_ACTION deleteAssoc
Definition: cvpcb_actions.h:64
static TOOL_ACTION FilterFPbyFPFilters
Footprint Filtering actions.
Definition: cvpcb_actions.h:67
static TOOL_ACTION saveAssociationsToSchematic
Management actions.
Definition: cvpcb_actions.h:56
static TOOL_ACTION showFootprintViewer
Open the footprint viewer.
Definition: cvpcb_actions.h:49
A class to define a footprint association to be made in cvpcb.
unsigned int GetComponentIndex() const
Get the index of the component to modify the association of.
LIB_ID GetNewFootprint() const
Get the new footprint to associate to the component.
CVPCB_CONTROL.
Definition: cvpcb_control.h:36
bool readNetListAndFpFiles(const std::string &aNetlist)
Load the netlist file built on the fly by Eeschema and loads footprint libraries from fp lib tables.
wxTimer * m_filterTimer
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void ShowChangedLanguage() override
void SendComponentSelectionToSch(bool aClearSelectionOnly=false)
Send a remote command to Eeschema via a socket,.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void doCloseWindow() override
CVPCB_UNDO_REDO_LIST m_redoList
ACTION_MENU * m_symbolsContextMenu
wxStaticText * m_statusLine3
CVPCB_MAINFRAME::CONTROL_TYPE GetFocusedControl() const
Find out which control currently has focus.
CVPCB_FILTER_ACTION
The action to apply to a footprint filter when it is modified.
@ FILTER_DISABLE
Turn off the filter.
@ FILTER_ENABLE
Turn on the filter.
@ FILTER_TOGGLE
Toggle the filter state.
void onTextFilterChangedTimer(wxTimerEvent &aEvent)
void onTextFilterChanged(wxCommandEvent &event)
LIBRARY_LISTBOX * m_librariesListBox
void setupTools()
Setup the tool system for the CVPCB main frame.
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame() const
wxButton * m_saveAndContinue
void RedoAssociation()
Redo the most recently undone association.
bool LoadFootprintFiles()
Read the list of footprint (*.mod files) and generate the list of footprints.
void SetStatusText(const wxString &aText, int aNumber=0) override
wxString GetSelectedFootprint()
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
CVPCB_MAINFRAME(KIWAY *aKiway, wxWindow *aParent)
void SetFootprintFilter(FOOTPRINTS_LISTBOX::FP_FILTER_T aFilter, CVPCB_MAINFRAME::CVPCB_FILTER_ACTION aAction)
Set a filter criteria to either on/off or toggle the criteria.
wxStaticText * m_statusLine1
void setupEventHandlers()
Setup event handlers.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void SetSelectedComponent(int aIndex, bool aSkipUpdate=false)
Set the currently selected component in the components listbox.
ACTION_MENU * m_footprintContextMenu
CONTROL_TYPE
The type of the controls present in the application.
@ CONTROL_NONE
No controls have focus.
@ CONTROL_LIBRARY
Library listbox.
@ CONTROL_FOOTPRINT
Footprint listbox.
@ CONTROL_COMPONENT
Component listbox.
wxString formatSymbolDesc(int idx, const wxString &aReference, const wxString &aValue, const wxString &aFootprint)
void SetFocusedControl(CVPCB_MAINFRAME::CONTROL_TYPE aControl)
Set the focus to a specific control.
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Receive KIWAY_EXPRESS messages from other players.
void OnSelectComponent(wxListEvent &event)
Called when clicking on a component in component list window:
void UndoAssociation()
Undo the most recent associations that were performed.
void DisplayStatus()
Update the information displayed on the status bar at bottom of the main frame.
ACTION_TOOLBAR * m_mainToolBar
CVPCB_UNDO_REDO_LIST m_undoList
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
FOOTPRINT_LIST * m_FootprintsList
wxWindow * GetToolCanvas() const override
Canvas access.
std::vector< unsigned int > GetComponentIndices(CVPCB_MAINFRAME::CRITERIA aCriteria=CVPCB_MAINFRAME::ALL_COMPONENTS)
Get the indices for all the components meeting the specified criteria in the components listbox.
void AssociateFootprint(const CVPCB_ASSOCIATION &aAssociation, bool aNewEntry=true, bool aAddUndoItem=true)
Associate a footprint with a specific component in the list.
void updateFootprintViewerOnIdle(wxIdleEvent &aEvent)
void refreshAfterSymbolSearch(COMPONENT *aSymbol)
wxStaticText * m_statusLine2
FOOTPRINTS_LISTBOX * m_footprintListBox
CRITERIA
Criteria to use to identify sets of components.
@ ALL_COMPONENTS
All components.
@ NA_COMPONENTS
Not associated components.
@ SEL_COMPONENTS
Selected components.
@ ASSOC_COMPONENTS
Associated components.
SYMBOLS_LISTBOX * m_symbolsListBox
TOOL_DISPATCHER * m_toolDispatcher
int readSchematicNetlist(const std::string &aNetlist)
Read the netlist (.net) file built on the fly by Eeschema.
bool SaveFootprintAssociation(bool doSaveSchematic)
Save the edits that the user has done by sending them back to Eeschema via the kiway.
wxTextCtrl * m_tcFilterString
COMPONENT * GetSelectedComponent()
Get the selected component from the component listbox.
wxString m_FilterString
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
wxAuiManager m_auimgr
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
wxString m_aboutTitle
void ReCreateMenuBar()
Recreates the menu bar.
Specialization of the wxAuiPaneInfo class for KiCad panels.
Class that groups generic conditions for editor states.
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
SELECTION_CONDITION ContentModified()
Create a functor that tests if the content of the frame is modified.
void SetSelectedFootprint(const LIB_ID &aFPID)
void SetFootprints(FOOTPRINT_LIST &aList, const wxString &aLibName, COMPONENT *aComponent, const wxString &aFootPrintFilterPattern, int aFilterType)
Populate the wxListCtrl with the footprints from aList that meet the filter criteria defined by aFilt...
FP_FILTER_T
Filter setting constants.
Definition: listboxes.h:93
@ FILTERING_BY_COMPONENT_FP_FILTERS
Definition: listboxes.h:95
wxString OnGetItemText(long item, long column) const override
This overloaded function MUST be provided for the wxLC_VIRTUAL mode because real data is not handled ...
void SetSelection(int aIndex, bool aState=true)
wxString GetLibNickname() const override
wxString GetDescription() override
wxString GetKeywords()
void DisplayErrors(wxTopLevelWindow *aCaller=nullptr)
unsigned GetErrorCount() const
virtual bool ReadFootprintFiles(FP_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)=0
Read all the footprints provided by the combination of aTable and aNickname.
FOOTPRINT_INFO * GetFootprintInfo(const wxString &aFootprintName)
Get info for a footprint by id.
static FOOTPRINT_LIST * GetInstance(KIWAY &aKiway)
Factory function to return a FOOTPRINT_LIST via Kiway.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
void UpdateWidth(int aLine=-1)
Update the width of the column based on its contents.
void DeselectAll()
Remove all selection in lists which can have more than one item selected.
Read the new s-expression based KiCad netlist format.
virtual void LoadNetlist() override
Load the contents of the netlist file into aNetlist.
Definition: kiid.h:48
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
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:66
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:549
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:196
void AppendLine(const wxString &text)
wxString GetSelectedLibrary()
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:172
bool empty() const
Definition: lib_id.h:193
UTF8 Format() const
Definition: lib_id.cpp:117
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
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.
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
static const wxString GetPinningSymbol()
unsigned GetCount() const
Definition: pcb_netlist.h:234
bool IsEmpty() const
Definition: pcb_netlist.h:224
void Clear()
Remove all components from the netlist.
Definition: pcb_netlist.h:229
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
Definition: pcb_netlist.h:242
void SortByReference()
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:65
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
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:253
wxArrayString m_SymbolList
Definition: listboxes.h:227
void SetString(unsigned linecount, const wxString &text)
void SetSelection(int index, bool State=true)
void AppendWarning(int index)
void RemoveWarning(int index)
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
ACTIONS * m_actions
Definition: tools_holder.h:171
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
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
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:196
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
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 InitTools()
Initializes all registered tools.
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
const char * c_str() const
Definition: utf8.h:102
wxString wx_str() const
Definition: utf8.cpp:46
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:243
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.
@ ID_CVPCB_LIBRARY_LIST
Definition: cvpcb_id.h:33
@ ID_CVPCB_FOOTPRINT_LIST
Definition: cvpcb_id.h:32
@ ID_CVPCB_COMPONENT_LIST
Definition: cvpcb_id.h:31
#define CVPCB_MAINFRAME_NAME
#define CHECK(x)
#define ENABLE(x)
std::vector< CVPCB_ASSOCIATION > CVPCB_UNDO_REDO_ENTRIES
#define FOOTPRINTVIEWER_FRAME_NAME
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
bool SendCommand(int aService, const std::string &aMessage)
Used by a client to sent (by a socket connection) a data to a server.
Definition: eda_dde.cpp:310
DDE server & client.
#define MSG_TO_SCH
Definition: eda_dde.h:50
@ FRAME_SCH
Definition: frame_type.h:34
@ FRAME_CVPCB
Definition: frame_type.h:48
This file contains miscellaneous commonly used macros and functions.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
@ MAIL_SELECTION
Definition: mail_type.h:40
@ MAIL_RELOAD_LIB
Definition: mail_type.h:55
@ MAIL_EESCHEMA_NETLIST
Definition: mail_type.h:44
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:83
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:72
void FixupCancelButtonCmdKeyCollision(wxWindow *aWindow)
Definition: gtk/ui.cpp:71
wxFont GetMonospacedUIFont()
Definition: ui_common.cpp:85
wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:132
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_IPC
Definition: string_utils.h:57
std::vector< wxString > pinned_fp_libs