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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <pgm_base.h>
23#include <api/common/commands/cross_probe_commands.pb.h>
25#include <api/api_utils.h>
26#include <bitmaps.h>
27#include <confirm.h>
29#include <kiface_base.h>
30#include <kiplatform/app.h>
31#include <kiway_mail.h>
32#include <string_utils.h>
36#include <numeric>
37#include <richio.h>
38#include <tool/action_manager.h>
39#include <tool/action_toolbar.h>
40#include <tool/common_control.h>
43#include <tool/tool_manager.h>
44#include <widgets/kistatusbar.h>
46
47#include <cvpcb_association.h>
48#include <cvpcb_id.h>
49#include <cvpcb_mainframe.h>
54#include <footprint_info_impl.h>
55#include <kiplatform/ui.h>
56#include <listboxes.h>
57#include <tools/cvpcb_actions.h>
59#include <tools/cvpcb_control.h>
60#include <project_pcb.h>
61#include <toolbars_cvpcb.h>
62
63#include <wx/statline.h>
64#include <wx/stattext.h>
65#include <wx/button.h>
66#include <wx/msgdlg.h>
67#include <wx/ffile.h>
68
69
70CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
71 KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
72 wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, wxT( "CvpcbFrame" ),
73 unityScale ),
74 m_footprintListBox( nullptr ),
75 m_librariesListBox( nullptr ),
76 m_symbolsListBox( nullptr ),
77 m_tcFilterString( nullptr ),
79{
80 m_modified = false;
81 m_cannotClose = false;
85 m_initialized = false;
86 m_aboutTitle = _( "Assign Footprints" );
87
88 // Give an icon
89 wxIcon icon;
90 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_cvpcb ) );
91 SetIcon( icon );
92
93 SetAutoLayout( true );
94
96
97 setupTools();
99
104
107
110
113
115
116 m_auimgr.SetManagedWindow( this );
117
118 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( "TopMainToolbar" ).Top().Layer(6) );
119
120 m_auimgr.AddPane( m_librariesListBox, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(1)
121 .Caption( _( "Footprint Libraries" ) )
122 .BestSize((int) ( m_frameSize.x * 0.20 ), m_frameSize.y ) );
123
124 m_auimgr.AddPane( m_symbolsListBox, EDA_PANE().Palette().Name( "Symbols" ).Center().Layer(0)
125 .Caption( _( "Symbol : Footprint Assignments" ) ) );
126
127 m_auimgr.AddPane( m_footprintListBox, EDA_PANE().Palette().Name( "Footprints" ).Right().Layer(1)
128 .Caption( _( "Filtered Footprints" ) )
129 .BestSize((int) ( m_frameSize.x * 0.30 ), m_frameSize.y ) );
130
131 // Build the bottom panel, to display 2 status texts and the buttons:
132 auto bottomPanel = new wxPanel( this );
133 auto panelSizer = new wxBoxSizer( wxVERTICAL );
134
135 wxFlexGridSizer* fgSizerStatus = new wxFlexGridSizer( 3, 1, 0, 0 );
136 fgSizerStatus->SetFlexibleDirection( wxBOTH );
137 fgSizerStatus->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
138
139 m_statusLine1 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
140 fgSizerStatus->Add( m_statusLine1, 0, 0, 5 );
141
142 m_statusLine2 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
143 fgSizerStatus->Add( m_statusLine2, 0, 0, 5 );
144
145 m_statusLine3 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
146 fgSizerStatus->Add( m_statusLine3, 0, 0, 5 );
147
148 panelSizer->Add( fgSizerStatus, 1, wxEXPAND|wxLEFT, 2 );
149
150 m_statusLine1->SetFont( KIUI::GetStatusFont( this ) );
151 m_statusLine2->SetFont( KIUI::GetStatusFont( this ) );
152 m_statusLine3->SetFont( KIUI::GetStatusFont( this ) );
153
154 // Add buttons:
155 auto buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
156 auto sdbSizer = new wxStdDialogButtonSizer();
157
158 m_saveAndContinue = new wxButton( bottomPanel, wxID_ANY, _( "Apply, Save Schematic && Continue" ) );
159 buttonsSizer->Add( m_saveAndContinue, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 20 );
160
161 auto sdbSizerOK = new wxButton( bottomPanel, wxID_OK );
162 sdbSizer->AddButton( sdbSizerOK );
163 auto sdbSizerCancel = new wxButton( bottomPanel, wxID_CANCEL );
164 sdbSizer->AddButton( sdbSizerCancel );
165 sdbSizer->Realize();
166
167 buttonsSizer->Add( sdbSizer, 0, 0, 5 );
168 panelSizer->Add( buttonsSizer, 0, wxALIGN_RIGHT|wxALL, 5 );
169
170 bottomPanel->SetSizer( panelSizer );
171 bottomPanel->Fit();
172
173 sdbSizerOK->SetDefault();
175
176 m_auimgr.AddPane( bottomPanel, EDA_PANE().HToolbar().Name( "Buttons" ).Bottom().Layer(6) );
177
178 m_auimgr.Update();
179 m_initialized = true;
180
181 auto setPaneWidth =
182 [this]( wxAuiPaneInfo& pane, int width )
183 {
184 // wxAUI hack: force width by setting MinSize() and then Fixed()
185 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
186 pane.MinSize( width, -1 );
187 pane.BestSize( width, -1 );
188 pane.MaxSize( width, -1 );
189 pane.Fixed();
190 m_auimgr.Update();
191
192 // now make it resizable again
193 pane.MinSize( 20, -1 );
194 pane.Resizable();
195 m_auimgr.Update();
196 };
197
198 if( CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( config() ) )
199 {
200 m_tcFilterString->ChangeValue( cfg->m_FilterString );
201
202 if( cfg->m_LibrariesWidth > 0 )
203 setPaneWidth( m_auimgr.GetPane( "Libraries" ), cfg->m_LibrariesWidth );
204
205 if( cfg->m_FootprintsWidth > 0 )
206 setPaneWidth( m_auimgr.GetPane( "Footprints" ), cfg->m_FootprintsWidth );
207 }
208
209 // Connect Events
211
212 // Toolbar events
213 Bind( wxEVT_TEXT, &CVPCB_MAINFRAME::onTextFilterChanged, this );
214
215 // Attach the events to the tool dispatcher
217 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
218
219 m_filterTimer = new wxTimer( this );
220 Bind( wxEVT_TIMER, &CVPCB_MAINFRAME::onTextFilterChangedTimer, this, m_filterTimer->GetId() );
221
222 // Start the main processing loop
223 m_toolManager->InvokeTool( "cvpcb.Control" );
224
225 m_filterTimer->StartOnce( 100 );
226
227 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Symbol to footprint changes are unsaved" ) );
228}
229
230
232{
233 Unbind( wxEVT_TEXT, &CVPCB_MAINFRAME::onTextFilterChanged, this );
235 Unbind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
236
237 Unbind( wxEVT_TIMER, &CVPCB_MAINFRAME::onTextFilterChangedTimer, this, m_filterTimer->GetId() );
238 Unbind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintViewerOnIdle, this );
239
240 // Clean up the tool infrastructure
241 delete m_actions;
242 delete m_toolManager;
243 delete m_toolDispatcher;
244 delete m_FootprintsList;
245
246 m_auimgr.UnInit();
247}
248
249
251{
252 // Create the manager
253 m_actions = new CVPCB_ACTIONS();
255 m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
257
258 // Register tools
259 m_toolManager->RegisterTool( new COMMON_CONTROL );
260 m_toolManager->RegisterTool( new CVPCB_CONTROL );
261 m_toolManager->RegisterTool( new CVPCB_ASSOCIATION_TOOL );
262 m_toolManager->InitTools();
263
264 CVPCB_CONTROL* tool = m_toolManager->GetTool<CVPCB_CONTROL>();
265
266 // Even though these menus will open with the right-click, we treat them as a normal
267 // menu instead of a context menu because we don't care about their position and want
268 // to be able to tell the difference between a menu click and a hotkey activation.
269
270 // Create the context menu for the symbols list box
271 m_symbolsContextMenu = new ACTION_MENU( false, tool );
273 m_symbolsContextMenu->AppendSeparator();
277 m_symbolsContextMenu->AppendSeparator();
279
280 // Create the context menu for the footprint list box
281 m_footprintContextMenu = new ACTION_MENU( false, tool );
283}
284
285
287{
289
290 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
291 EDITOR_CONDITIONS cond( this );
292
293 wxASSERT( mgr );
294
295#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
296#define CHECK( x ) ACTION_CONDITIONS().Check( x )
297
302
303 auto compFilter =
304 [this] ( const SELECTION& )
305 {
307 };
308
309 auto libFilter =
310 [this] ( const SELECTION& )
311 {
313 };
314
315 auto pinFilter =
316 [this] ( const SELECTION& )
317 {
319 };
320
324
325#undef CHECK
326#undef ENABLE
327}
328
329
331{
332 // Connect the handlers to launch the context menus in the listboxes
333 m_footprintListBox->Bind( wxEVT_RIGHT_DOWN,
334 [this]( wxMouseEvent& )
335 {
336 PopupMenu( m_footprintContextMenu );
337 } );
338
339 m_symbolsListBox->Bind( wxEVT_RIGHT_DOWN,
340 [this]( wxMouseEvent& )
341 {
342 PopupMenu( m_symbolsContextMenu );
343 } );
344
345 // Connect the handler for the save button
346 m_saveAndContinue->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
347 [this]( wxCommandEvent& )
348 {
349 // saveAssociations must be run immediately
351 } );
352
353 // Connect the handlers for the ok/cancel buttons
354 Bind( wxEVT_BUTTON,
355 [this]( wxCommandEvent& )
356 {
357 // saveAssociations must be run immediately, before running Close( true )
359 Close( true );
360 }, wxID_OK );
361
362 Bind( wxEVT_BUTTON,
363 [this]( wxCommandEvent& )
364 {
365 Close( false );
366 }, wxID_CANCEL );
367
368 // Connect the handlers for the close events
369 Bind( wxEVT_MENU,
370 [this]( wxCommandEvent& )
371 {
372 Close( false );
373 }, wxID_CLOSE );
374 Bind( wxEVT_MENU,
375 [this]( wxCommandEvent& )
376 {
377 Close( false );
378 }, wxID_EXIT );
379
380 // Just skip the resize events
381 Bind( wxEVT_SIZE,
382 []( wxSizeEvent& aEvent )
383 {
384 aEvent.Skip();
385 } );
386}
387
388
389bool CVPCB_MAINFRAME::canCloseWindow( wxCloseEvent& aEvent )
390{
391 if( m_modified )
392 {
393 // Shutdown blocks must be determined and vetoed as early as possible
394 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION )
395 return false;
396
397 if( !HandleUnsavedChanges( this, _( "Symbol to Footprint links have been modified. Save changes?" ),
398 [&]() -> bool
399 {
400 return SaveFootprintAssociation( false );
401 } ) )
402 {
403 return false;
404 }
405 }
406
407 if( m_cannotClose )
408 return false;
409
410 return true;
411}
412
413
415{
416 m_symbolsListBox->Shutdown();
417 m_footprintListBox->Shutdown();
418
420 GetFootprintViewerFrame()->Close( true );
421
422 m_modified = false;
423
424 // Stop the timer during destruction early to avoid potential race conditions (that do happen)
425 m_filterTimer->Stop();
426
427 // Shutdown all running tools
428 if( m_toolManager )
429 m_toolManager->ShutdownAllTools();
430
431 // clear symbol selection in schematic:
433}
434
435
436void CVPCB_MAINFRAME::onTextFilterChanged( wxCommandEvent& event )
437{
438 // Called when changing the filter string in main toolbar.
439 // If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list
440 // of available footprints which match the filter
441
442 m_filterTimer->StartOnce( 200 );
443}
444
445
447{
448 // GTK loses the search-control's focus on a Refresh event, so we record the focus and
449 // insertion point here and then restore them at the end.
450 bool searchCtrlHasFocus = m_tcFilterString->HasFocus();
451 long pos = m_tcFilterString->GetInsertionPoint();
452
454 wxString libraryName = m_librariesListBox->GetSelectedLibrary();
455
456 m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, symbol,
458
459 if( symbol && symbol->GetFPID().IsValid() )
460 m_footprintListBox->SetSelectedFootprint( symbol->GetFPID() );
461 else if( m_footprintListBox->GetSelection() >= 0 )
462 m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false );
463
465
467
468 if( searchCtrlHasFocus && !m_tcFilterString->HasFocus() )
469 {
470 m_tcFilterString->SetFocus();
471 m_tcFilterString->SetInsertionPoint( pos );
472 }
473}
474
475
476void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
477{
479 return;
480
482 wxString libraryName = m_librariesListBox->GetSelectedLibrary();
483
484 m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, symbol,
486
487 if( symbol && symbol->GetFPID().IsValid() )
488 m_footprintListBox->SetSelectedFootprint( symbol->GetFPID() );
489 else if( m_footprintListBox->GetSelection() >= 0 )
490 m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false );
491
493
494 refreshAfterSymbolSearch( symbol );
495}
496
497
506
507
509{
510 Unbind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintViewerOnIdle, this );
511 m_viewerPendingUpdate = false;
512
513 // On some platforms (OSX) the focus is lost when the viewers (fp and 3D viewers)
514 // are opened and refreshed when a new footprint is selected.
515 // If the listbox has the focus before selecting a new footprint, it will be forced
516 // after selection.
517 bool footprintListHasFocus = m_footprintListBox->HasFocus();
518 bool symbolListHasFocus = m_symbolsListBox->HasFocus();
519
520 // If the footprint view window is displayed, update the footprint.
523
525
526 if( footprintListHasFocus )
527 m_footprintListBox->SetFocus();
528 else if( symbolListHasFocus )
529 m_symbolsListBox->SetFocus();
530}
531
532
534{
536
537 if( CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg ) )
538 m_filteringOptions = cfg->m_FilterFlags;
539}
540
541
543{
545
546 if( CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg ) )
547 {
548 cfg->m_FilterFlags = m_filteringOptions;
549 cfg->m_FilterString = m_tcFilterString->GetValue();
550
551 cfg->m_LibrariesWidth = m_librariesListBox->GetSize().x;
552 cfg->m_FootprintsWidth = m_footprintListBox->GetSize().x;
553 }
554}
555
556
558{
559 if( m_undoList.size() == 0 )
560 return;
561
562 CVPCB_UNDO_REDO_ENTRIES redoEntries;
563 CVPCB_UNDO_REDO_ENTRIES curEntry = m_undoList.back();
564 m_undoList.pop_back();
565
566 // Iterate over the entries to undo
567 for( const auto& assoc : curEntry )
568 {
569 AssociateFootprint( assoc, true, false );
570 redoEntries.emplace_back( assoc.Reverse() );
571 }
572
573 // Add the redo entries to the redo stack
574 m_redoList.emplace_back( redoEntries );
575}
576
577
579{
580 if( m_redoList.size() == 0 )
581 return;
582
583 CVPCB_UNDO_REDO_ENTRIES curEntry = m_redoList.back();
584 m_redoList.pop_back();
585
586 // Iterate over the entries to undo
587 bool firstAssoc = true;
588
589 for( const auto& assoc : curEntry )
590 {
591 AssociateFootprint( assoc, firstAssoc );
592 firstAssoc = false;
593 }
594}
595
596
597wxString CVPCB_MAINFRAME::formatSymbolDesc( int idx, const wxString& aReference,
598 const wxString& aValue, const wxString& aFootprint )
599{
600 // Work around a bug in wxString::Format with double-byte chars (and double-quote, for some
601 // reason).
602 wxString desc = wxString::Format( wxT( "%3d " ), idx );
603
604 for( int ii = aReference.Length(); ii < 8; ++ii )
605 desc += wxS( " " );
606
607 desc += aReference + wxT( " - " );
608
609 for( int ii = aValue.Length(); ii < 16; ++ii )
610 desc += wxS( " " );
611
612 desc += aValue + wxT( " : " ) + aFootprint;
613
614 return desc;
615}
616
617
619 bool aNewEntry, bool aAddUndoItem )
620{
621 if( m_netlist.IsEmpty() )
622 return;
623
624 COMPONENT* symbol = m_netlist.GetComponent( aAssociation.GetComponentIndex() );
625
626 if( symbol == nullptr )
627 return;
628
629 LIB_ID fpid = aAssociation.GetNewFootprint();
630 LIB_ID oldFpid = symbol->GetFPID();
631
632 // Test for validity of the requested footprint
633 if( !fpid.empty() && !fpid.IsValid() )
634 {
635 wxString msg = wxString::Format( _( "'%s' is not a valid footprint." ),
636 fpid.Format().wx_str() );
637 DisplayErrorMessage( this, msg );
638 return;
639 }
640
641 const KIID& id = symbol->GetKIIDs().front();
642
643 // Set new footprint to all instances of the selected symbol
644 for( unsigned int idx : GetComponentIndices() )
645 {
646 COMPONENT* candidate = m_netlist.GetComponent( idx );
647 const std::vector<KIID>& kiids = candidate->GetKIIDs();
648
649 if( std::find( kiids.begin(), kiids.end(), id ) != kiids.end() )
650 {
651 // Set the new footprint
652 candidate->SetFPID( fpid );
653
654 // create the new symbol description and set it
655 wxString description = formatSymbolDesc( idx + 1,
656 candidate->GetReference(),
657 candidate->GetValue(),
658 candidate->GetFPID().Format().wx_str() );
659 m_symbolsListBox->SetString( idx, description );
660
661 if( !m_FootprintsList->GetFootprintInfo( symbol->GetFPID().Format().wx_str() ) )
662 m_symbolsListBox->AppendWarning( idx );
663 else
664 m_symbolsListBox->RemoveWarning( idx );
665 }
666 }
667
668 // Mark the data as being modified
669 m_modified = true;
670
671 // Update the statusbar and refresh the list
673 m_symbolsListBox->Refresh();
674
675 if( !aAddUndoItem )
676 return;
677
678 // Update the undo list
679 if ( aNewEntry )
680 {
681 // Create a new entry for this association
683 newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid,
684 aAssociation.GetNewFootprint() ) );
685 m_undoList.emplace_back( newEntry );
686
687 // Clear the redo list
688 m_redoList.clear();
689 }
690 else
691 {
692 m_undoList.back().emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(),
693 oldFpid,
694 aAssociation.GetNewFootprint() ) );
695 }
696
697}
698
699
700bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
701{
702 return true;
703}
704
705
707{
708 // Tell AuiMgr that objects are changed !
709 if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
710 m_auimgr.Update(); // (could be not the case when starting CvPcb)
711
712 if( aSymbol == nullptr )
713 {
715 return;
716 }
717
718 // Preview of the already assigned footprint.
719 // Find the footprint that was already chosen for this aSymbol and select it,
720 // but only if the selection is made from the aSymbol list or the library list.
721 // If the selection is made from the footprint list, do not change the current
722 // selected footprint.
723 if( FindFocus() == m_symbolsListBox || FindFocus() == m_librariesListBox )
724 {
725 wxString footprintName = From_UTF8( aSymbol->GetFPID().Format().c_str() );
726
727 m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false );
728
729 for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
730 {
731 wxString candidateName;
732 wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
733 msg.Trim( true );
734 msg.Trim( false );
735 candidateName = msg.AfterFirst( wxChar( ' ' ) );
736
737 if( footprintName.Cmp( candidateName ) == 0 )
738 {
739 m_footprintListBox->SetSelection( ii, true );
740 break;
741 }
742 }
743 }
744
747}
748
749
752{
753 int option = aFilter;
754
755 // Apply the filter accordingly
756 switch( aAction )
757 {
761 }
762
763 wxListEvent l_event;
764 OnSelectComponent( l_event );
765}
766
767
769{
770 if( !m_initialized )
771 return;
772
773 wxString filters, msg;
775
777 {
778 msg.Empty();
779
780 if( symbol )
781 {
782 for( unsigned ii = 0; ii < symbol->GetFootprintFilters().GetCount(); ii++ )
783 {
784 if( msg.IsEmpty() )
785 msg += symbol->GetFootprintFilters()[ii];
786 else
787 msg += wxT( ", " ) + symbol->GetFootprintFilters()[ii];
788 }
789 }
790
791 filters += _( "Keywords" );
792
793 if( !msg.IsEmpty() )
794 filters += wxString::Format( wxT( " (%s)" ), msg );
795 }
796
798 {
799 msg.Empty();
800
801 if( symbol )
802 {
803 int pc = symbol->GetPinCount();
804 wxLogTrace( "CVPCB_PINCOUNT", wxT( "DisplayStatus: selected '%s' pinCount=%d" ),
805 symbol->GetReference(), pc );
806 msg = wxString::Format( wxT( "%i" ), pc );
807 }
808
809 if( !filters.IsEmpty() )
810 filters += wxT( ", " );
811
812 filters += _( "Pin Count" );
813
814 if( !msg.IsEmpty() )
815 filters += wxString::Format( wxT( " (%s)" ), msg );
816 }
817
819 {
820 msg = m_librariesListBox->GetSelectedLibrary();
821
822 if( !filters.IsEmpty() )
823 filters += wxT( ", " );
824
825 filters += _( "Library" );
826
827 if( !msg.IsEmpty() )
828 filters += wxString::Format( wxT( " (%s)" ), msg );
829 }
830
831 wxString textFilter = m_tcFilterString->GetValue();
832
833 if( !textFilter.IsEmpty() )
834 {
835 if( !filters.IsEmpty() )
836 filters += wxT( ", " );
837
838 filters += _( "Search Text" ) + wxString::Format( wxT( " (%s)" ), textFilter );
839 }
840
841 if( filters.IsEmpty() )
842 msg = _( "No Filtering" );
843 else
844 msg.Printf( _( "Filtered by %s" ), filters );
845
846 msg += wxString::Format( _( ": %i matching footprints" ), m_footprintListBox->GetCount() );
847
848 SetStatusText( msg );
849
850
851 msg.Empty();
852 wxString footprintName = GetSelectedFootprint();
853
854 FOOTPRINT_INFO* fp = m_FootprintsList->GetFootprintInfo( footprintName );
855
856 if( fp ) // can be NULL if no netlist loaded
857 {
858 msg = wxString::Format( _( "Description: %s; Keywords: %s" ),
859 fp->GetDesc(),
860 fp->GetKeywords() );
861 }
862
863 SetStatusText( msg, 1 );
864
865 msg.Empty();
866 wxString lib;
867
868 // Choose the footprint to get the information on
869 if( fp )
870 {
871 // Use the footprint in the footprint viewer
872 lib = fp->GetLibNickname();
873 }
875 {
876 // Use the footprint of the selected symbol
877 if( symbol )
878 lib = symbol->GetFPID().GetUniStringLibNickname();
879 }
881 {
882 // Use the library that is selected
883 lib = m_librariesListBox->GetSelectedLibrary();
884 }
885
886 // Extract the library information
888
889 if( std::optional<LIBRARY_TABLE_ROW*> optRow = adapter->GetRow( lib ); optRow )
890 msg = wxString::Format( _( "Library location: %s" ), LIBRARY_MANAGER::GetFullURI( *optRow ) );
891
892 SetStatusText( msg, 2 );
893}
894
895
897{
899
900 // Check if there are footprint libraries in the footprint library table.
901 if( !adapter || !adapter->Rows().size() )
902 {
903 wxMessageBox( _( "No PCB footprint libraries are listed in the current footprint "
904 "library table." ), _( "Configuration Error" ), wxOK | wxICON_ERROR );
905 return false;
906 }
907
908 WX_PROGRESS_REPORTER progressReporter( this, _( "Load Footprint Libraries" ), 1, PR_CAN_ABORT );
909
910 m_FootprintsList->ReadFootprintFiles( adapter, nullptr, &progressReporter );
911
912 if( m_FootprintsList->GetErrorCount() )
913 {
914 if( KISTATUSBAR* statusBar = dynamic_cast<KISTATUSBAR*>( GetStatusBar() ) )
915 statusBar->AddWarningMessages( "load", m_FootprintsList->GetErrorMessages() );
916 }
917
918 return true;
919}
920
921
922void CVPCB_MAINFRAME::SendComponentSelectionToSch( bool aClearSelectionOnly )
923{
924 if( m_netlist.IsEmpty() && !aClearSelectionOnly )
925 return;
926
927 kiapi::common::commands::SyncSelection sync;
928
929 if( !aClearSelectionOnly )
930 {
931 int selection = m_symbolsListBox->GetSelection();
932
933 if( selection < 0 ) // Nothing selected
934 return;
935
936 if( m_netlist.GetComponent( selection ) == nullptr )
937 return;
938
939 // Now select the corresponding symbol on the schematic:
940 wxString ref = m_netlist.GetComponent( selection )->GetReference();
941
942 sync.set_mode( kiapi::common::commands::SSM_ITEMS_ONLY );
943 sync.add_items()->mutable_footprint()->set_reference( ref.ToUTF8() );
944 }
945
946 if( Kiface().IsSingle() )
947 {
949 }
950 else
951 {
952 std::string payload;
953 kiapi::common::PackKiwayApiMessage( sync, payload );
954 Kiway().ExpressMail( FRAME_SCH, MAIL_SELECTION, payload, this );
955 }
956}
957
958
959int CVPCB_MAINFRAME::readSchematicNetlist( const std::string& aNetlist )
960{
961 STRING_LINE_READER* stringReader = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
962 KICAD_NETLIST_READER netlistReader( stringReader, &m_netlist );
963
964 m_netlist.Clear();
965
966 // Trace basic payload characteristics to verify libparts are present and visible here
967 wxLogTrace( "CVPCB_PINCOUNT",
968 wxT( "readSchematicNetlist: payload size=%zu has_libparts=%d has_libpart=%d" ),
969 aNetlist.size(), aNetlist.find( "(libparts" ) != std::string::npos,
970 aNetlist.find( "(libpart" ) != std::string::npos );
971
972 try
973 {
974 netlistReader.LoadNetlist();
975 }
976 catch( const IO_ERROR& ioe )
977 {
978 wxString msg = wxString::Format( _( "Error loading schematic.\n%s" ),
979 ioe.What().GetData() );
980 wxMessageBox( msg, _( "Load Error" ), wxOK | wxICON_ERROR );
981 return 1;
982 }
983
984 // We also remove footprint name if it is "$noname" because this is a dummy name,
985 // not the actual name of the footprint.
986 for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
987 {
988 if( m_netlist.GetComponent( ii )->GetFPID().GetLibItemName() == std::string( "$noname" ) )
989 m_netlist.GetComponent( ii )->SetFPID( LIB_ID() );
990 }
991
992 // Sort symbols by reference:
993 m_netlist.SortByReference();
994
995 return 0;
996}
997
998
1000{
1001 m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, nullptr, wxEmptyString,
1003 DisplayStatus();
1004}
1005
1006
1008{
1012
1013 // Use same sorting algorithm as LIB_TREE_NODE::AssignIntrinsicRanks
1014 struct library_sort
1015 {
1016 bool operator()( const wxString& lhs, const wxString& rhs ) const
1017 {
1018 return StrNumCmp( lhs, rhs, true ) < 0;
1019 }
1020 };
1021
1022 std::set<wxString, library_sort> pinnedMatches;
1023 std::set<wxString, library_sort> otherMatches;
1024
1025 m_librariesListBox->ClearList();
1026
1027 auto process =
1028 [&]( const wxString& aNickname )
1029 {
1030 if( alg::contains( project.m_PinnedFootprintLibs, aNickname )
1031 || alg::contains( cfg->m_Session.pinned_fp_libs, aNickname ) )
1032 {
1033 pinnedMatches.insert( aNickname );
1034 }
1035 else
1036 {
1037 otherMatches.insert( aNickname );
1038 }
1039 };
1040
1041
1042 if( adapter )
1043 {
1044 std::vector<wxString> libNickNames = adapter->GetLibraryNames();
1045
1046 for( const wxString& libNickName : libNickNames )
1047 process( libNickName );
1048 }
1049
1050 for( const wxString& nickname : pinnedMatches )
1052
1053 for( const wxString& nickname : otherMatches )
1054 m_librariesListBox->AppendLine( nickname );
1055
1056 m_librariesListBox->Finish();
1057}
1058
1059
1061{
1062 int selection = m_symbolsListBox->GetSelection();
1063
1064 if( selection >= 0 && selection < (int) m_netlist.GetCount() )
1065 return m_netlist.GetComponent( selection );
1066
1067 return nullptr;
1068}
1069
1070
1071void CVPCB_MAINFRAME::SetSelectedComponent( int aIndex, bool aSkipUpdate )
1072{
1073 m_skipComponentSelect = aSkipUpdate;
1074
1075 if( aIndex < 0 )
1076 {
1077 m_symbolsListBox->DeselectAll();
1078 }
1079 else if( aIndex < m_symbolsListBox->GetCount() )
1080 {
1081 m_symbolsListBox->DeselectAll();
1082 m_symbolsListBox->SetSelection( aIndex );
1084 }
1085
1086 m_skipComponentSelect = false;
1087}
1088
1089
1090std::vector<unsigned int>
1092{
1093 std::vector<unsigned int> idx;
1094 int lastIdx;
1095
1096 // Make sure a netlist has been loaded and the box has contents
1097 if( m_netlist.IsEmpty() || m_symbolsListBox->GetCount() == 0 )
1098 return idx;
1099
1100 switch( aCriteria )
1101 {
1103 idx.resize( m_netlist.GetCount() );
1104 std::iota( idx.begin(), idx.end(), 0 );
1105 break;
1106
1108 // Check to see if anything is selected
1109 if( m_symbolsListBox->GetSelectedItemCount() < 1 )
1110 break;
1111
1112 // Get the symbols
1113 lastIdx = m_symbolsListBox->GetFirstSelected();
1114 idx.emplace_back( lastIdx );
1115
1116 lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
1117 while( lastIdx > 0 )
1118 {
1119 idx.emplace_back( lastIdx );
1120 lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
1121 }
1122 break;
1123
1125 for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
1126 {
1127 if( m_netlist.GetComponent( i )->GetFPID().empty() )
1128 idx.emplace_back( i );
1129 }
1130 break;
1131
1133 for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
1134 {
1135 if( !m_netlist.GetComponent( i )->GetFPID().empty() )
1136 idx.emplace_back( i );
1137 }
1138 break;
1139
1140 default:
1141 wxASSERT_MSG( false, "Invalid symbol selection criteria" );
1142 }
1143
1144 return idx;
1145}
1146
1147
1149{
1150 // returns the Footprint Viewer frame, if exists, or NULL
1151 wxWindow* window = wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME );
1152 return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>( window );
1153}
1154
1155
1157{
1158 return GetFootprintViewerFrame();
1159}
1160
1161
1169
1170
1172{
1173 switch( aLB )
1174 {
1178 default: break;
1179 }
1180}
1181
1182
1184{
1185 // returns the LIB_ID of the selected footprint in footprint listview
1186 // or a empty string
1187 return m_footprintListBox->GetSelectedFootprint();
1188}
1189
1190
1191void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber )
1192{
1193 switch( aNumber )
1194 {
1195 case 0: m_statusLine1->SetLabel( aText ); break;
1196 case 1: m_statusLine2->SetLabel( aText ); break;
1197 case 2: m_statusLine3->SetLabel( aText ); break;
1198 default: wxFAIL_MSG( wxT( "Invalid status row number" ) ); break;
1199 }
1200}
1201
1202
1209
1210
1212{
1213 const std::string& payload = mail.GetPayload();
1214
1215 switch( mail.Command() )
1216 {
1218 // Disable Close events during readNetListAndFpFiles() to avoid crash when updating widgets:
1219 m_cannotClose = true;
1220 readNetListAndFpFiles( payload );
1221 m_cannotClose = false;
1222 break;
1223
1224 case MAIL_RELOAD_LIB:
1225 if( m_cannotClose )
1226 break;
1227
1228 m_cannotClose = true;
1232 m_cannotClose = false;
1233 break;
1234
1235 default:
1236 ; // ignore most
1237 }
1238}
constexpr EDA_IU_SCALE unityScale
Definition base_units.h:131
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:100
static TOOL_ACTION paste
Definition actions.h:76
static TOOL_ACTION copy
Definition actions.h:74
static TOOL_ACTION undo
Definition actions.h:71
static TOOL_ACTION redo
Definition actions.h:72
static TOOL_ACTION cut
Definition actions.h:73
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...
Define the structure of a menu based on ACTIONs.
Definition action_menu.h:43
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Handle actions that are shared between different applications.
Store all of the related component information found in a netlist.
const wxString & GetReference() const
const wxString & GetValue() const
void SetFPID(const LIB_ID &aFPID)
const wxArrayString & GetFootprintFilters() const
const std::vector< KIID > & GetKIIDs() const
const LIB_ID & GetFPID() const
static bool SendToFrame(FRAME_T aTarget, const google::protobuf::Message &aRequest)
Gather all the actions that are shared by tools.
static TOOL_ACTION saveAssociationsToFile
static TOOL_ACTION FilterFPbyLibrary
static TOOL_ACTION filterFPbyPin
static TOOL_ACTION deleteAssoc
static TOOL_ACTION FilterFPbyFPFilters
Footprint Filtering actions.
static TOOL_ACTION saveAssociationsToSchematic
Management actions.
static TOOL_ACTION showFootprintViewer
Open the footprint viewer.
Handles action in main CvPcb window.
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.
Handles actions in main CvPcb window.
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 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.
void KiwayMailIn(KIWAY_MAIL_EVENT &aEvent) override
Receive KIWAY_MAIL_EVENT messages from other players.
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 configureToolbars() override
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.
Toolbar configuration for cvpcb.
virtual APP_SETTINGS_BASE * config() const
Return 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.
TOOLBAR_SETTINGS * m_toolbarSettings
wxAuiManager m_auimgr
virtual void RecreateToolbars()
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.
ACTION_TOOLBAR * m_tbTopMain
wxString m_aboutTitle
void ReCreateMenuBar()
Recreate 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.
virtual 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.
FP_FILTER_T
Filter setting constants.
Definition listboxes.h:95
@ FILTERING_BY_COMPONENT_FP_FILTERS
Definition listboxes.h:97
Helper class to handle the list of footprints available in libraries.
wxString GetLibNickname() const override
wxString GetKeywords()
wxString GetDesc() override
An interface to the global shared library manager that is schematic-specific and linked to one projec...
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
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:46
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
Definition kistatusbar.h:50
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.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition kiway_mail.h:34
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition kiway_mail.h:52
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition kiway_mail.h:44
KIWAY_PLAYER(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:348
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr, bool aFromOtherThread=false)
Send aPayload to aDestination from aSource.
Definition kiway.cpp:486
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition kiway.cpp:201
std::vector< LIBRARY_TABLE_ROW * > Rows(LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH, bool aIncludeInvalid=false) const
Like LIBRARY_MANAGER::Rows but filtered to the LIBRARY_TABLE_TYPE of this adapter.
std::optional< LIBRARY_TABLE_ROW * > GetRow(const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
Like LIBRARY_MANAGER::GetRow but filtered to the LIBRARY_TABLE_TYPE of this adapter.
std::vector< wxString > GetLibraryNames() const
Returns a list of library nicknames that are available (skips any that failed to load)
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
bool IsValid() const
Check if this LID_ID is valid.
Definition lib_id.h:168
bool empty() const
Definition lib_id.h:189
UTF8 Format() const
Definition lib_id.cpp:132
const wxString GetUniStringLibNickname() const
Definition lib_id.h:84
static const wxString GetPinningSymbol()
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:546
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:123
The backing store for a PROJECT, in JSON format.
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
virtual PROJECT_FILE & GetProjectFile() const
Definition project.h:201
T * GetToolbarSettings(const wxString &aFilename)
Return a handle to the given toolbar settings.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition richio.h:225
TOOL_MANAGER * m_toolManager
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
ACTIONS * m_actions
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
Master controller class:
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
const char * c_str() const
Definition utf8.h:104
wxString wx_str() const
Definition utf8.cpp:41
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:146
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
This file is part of the common library.
@ ID_CVPCB_LIBRARY_LIST
Definition cvpcb_id.h:29
@ ID_CVPCB_FOOTPRINT_LIST
Definition cvpcb_id.h:28
@ ID_CVPCB_COMPONENT_LIST
Definition cvpcb_id.h:27
#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
@ FRAME_SCH
Definition frame_type.h:30
@ FRAME_CVPCB
Definition frame_type.h:48
static wxString From_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition idf_helpers.h:44
@ MAIL_SELECTION
Definition mail_type.h:36
@ MAIL_RELOAD_LIB
Definition mail_type.h:54
@ MAIL_EESCHEMA_NETLIST
Definition mail_type.h:40
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition unix/app.cpp:102
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition unix/app.cpp:91
void FixupCancelButtonCmdKeyCollision(wxWindow *aWindow)
Definition wxgtk/ui.cpp:266
KICOMMON_API wxFont GetStatusFont(wxWindow *aWindow)
KICOMMON_API wxFont GetMonospacedUIFont(int aRelativeSize=0)
Definition ui_common.cpp:93
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:96
KICOMMON_API bool PackKiwayApiMessage(const google::protobuf::Message &aMessage, std::string &aBytes)
static PGM_BASE * process
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
static const std::vector< std::string > filters
Definition plugin.cpp:64
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
std::vector< wxString > pinned_fp_libs
#define PR_CAN_ABORT