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, 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>
38#include <numeric>
39#include <tool/action_manager.h>
40#include <tool/action_toolbar.h>
41#include <tool/common_control.h>
44#include <tool/tool_manager.h>
46
47#include <cvpcb_association.h>
48#include <cvpcb_id.h>
49#include <cvpcb_mainframe.h>
53#include <kiplatform/ui.h>
54#include <listboxes.h>
55#include <tools/cvpcb_actions.h>
57#include <tools/cvpcb_control.h>
58#include <project_pcb.h>
59#include <toolbars_cvpcb.h>
60
61#include <wx/statline.h>
62#include <wx/stattext.h>
63#include <wx/button.h>
64#include <wx/msgdlg.h>
65
66
67CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
68 KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
69 wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, wxT( "CvpcbFrame" ),
70 unityScale ),
71 m_footprintListBox( nullptr ),
72 m_librariesListBox( nullptr ),
73 m_symbolsListBox( nullptr ),
74 m_tcFilterString( nullptr ),
75 m_viewerPendingUpdate( false )
76{
77 m_modified = false;
78 m_cannotClose = false;
82 m_initialized = false;
83 m_aboutTitle = _( "Assign Footprints" );
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();
96
101
104
107
110
112
113 m_auimgr.SetManagedWindow( this );
114
115 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( "TopMainToolbar" ).Top().Layer(6) );
116
117 m_auimgr.AddPane( m_librariesListBox, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(1)
118 .Caption( _( "Footprint Libraries" ) )
119 .BestSize((int) ( m_frameSize.x * 0.20 ), m_frameSize.y ) );
120
121 m_auimgr.AddPane( m_symbolsListBox, EDA_PANE().Palette().Name( "Symbols" ).Center().Layer(0)
122 .Caption( _( "Symbol : Footprint Assignments" ) ) );
123
124 m_auimgr.AddPane( m_footprintListBox, EDA_PANE().Palette().Name( "Footprints" ).Right().Layer(1)
125 .Caption( _( "Filtered Footprints" ) )
126 .BestSize((int) ( m_frameSize.x * 0.30 ), m_frameSize.y ) );
127
128 // Build the bottom panel, to display 2 status texts and the buttons:
129 auto bottomPanel = new wxPanel( this );
130 auto panelSizer = new wxBoxSizer( wxVERTICAL );
131
132 wxFlexGridSizer* fgSizerStatus = new wxFlexGridSizer( 3, 1, 0, 0 );
133 fgSizerStatus->SetFlexibleDirection( wxBOTH );
134 fgSizerStatus->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
135
136 m_statusLine1 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
137 fgSizerStatus->Add( m_statusLine1, 0, 0, 5 );
138
139 m_statusLine2 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
140 fgSizerStatus->Add( m_statusLine2, 0, 0, 5 );
141
142 m_statusLine3 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
143 fgSizerStatus->Add( m_statusLine3, 0, wxBOTTOM, 3 );
144
145 panelSizer->Add( fgSizerStatus, 1, wxEXPAND|wxLEFT, 2 );
146
147 m_statusLine1->SetFont( KIUI::GetStatusFont( this ) );
148 m_statusLine2->SetFont( KIUI::GetStatusFont( this ) );
149 m_statusLine3->SetFont( KIUI::GetStatusFont( this ) );
150
151 // Add buttons:
152 auto buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
153 auto sdbSizer = new wxStdDialogButtonSizer();
154
155 m_saveAndContinue = new wxButton( bottomPanel, wxID_ANY,
156 _( "Apply, Save Schematic && Continue" ) );
157 buttonsSizer->Add( m_saveAndContinue, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 20 );
158
159 auto sdbSizerOK = new wxButton( bottomPanel, wxID_OK );
160 sdbSizer->AddButton( sdbSizerOK );
161 auto sdbSizerCancel = new wxButton( bottomPanel, wxID_CANCEL );
162 sdbSizer->AddButton( sdbSizerCancel );
163 sdbSizer->Realize();
164
165 buttonsSizer->Add( sdbSizer, 0, 0, 5 );
166 panelSizer->Add( buttonsSizer, 0, wxALIGN_RIGHT|wxALL, 5 );
167
168 bottomPanel->SetSizer( panelSizer );
169 bottomPanel->Fit();
170
171 sdbSizerOK->SetDefault();
173
174 m_auimgr.AddPane( bottomPanel, EDA_PANE().HToolbar().Name( "Buttons" ).Bottom().Layer(6) );
175
176 m_auimgr.Update();
177 m_initialized = true;
178
179 auto setPaneWidth =
180 [this]( wxAuiPaneInfo& pane, int width )
181 {
182 // wxAUI hack: force width by setting MinSize() and then Fixed()
183 // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
184 pane.MinSize( width, -1 );
185 pane.BestSize( width, -1 );
186 pane.MaxSize( width, -1 );
187 pane.Fixed();
188 m_auimgr.Update();
189
190 // now make it resizable again
191 pane.MinSize( 20, -1 );
192 pane.Resizable();
193 m_auimgr.Update();
194 };
195
196 if( CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( config() ) )
197 {
198 m_tcFilterString->ChangeValue( cfg->m_FilterString );
199
200 if( cfg->m_LibrariesWidth > 0 )
201 setPaneWidth( m_auimgr.GetPane( "Libraries" ), cfg->m_LibrariesWidth );
202
203 if( cfg->m_FootprintsWidth > 0 )
204 setPaneWidth( m_auimgr.GetPane( "Footprints" ), cfg->m_FootprintsWidth );
205 }
206
207 // Connect Events
209
210 // Toolbar events
211 Bind( wxEVT_TEXT, &CVPCB_MAINFRAME::onTextFilterChanged, this );
212
213 // Attach the events to the tool dispatcher
215 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
216
217 m_filterTimer = new wxTimer( this );
218 Bind( wxEVT_TIMER, &CVPCB_MAINFRAME::onTextFilterChangedTimer, this, m_filterTimer->GetId() );
219
220 // Start the main processing loop
221 m_toolManager->InvokeTool( "cvpcb.Control" );
222
223 m_filterTimer->StartOnce( 100 );
224
225 KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Symbol to footprint changes are unsaved" ) );
226}
227
228
230{
231 Unbind( wxEVT_TEXT, &CVPCB_MAINFRAME::onTextFilterChanged, this );
233 Unbind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
234
235 Unbind( wxEVT_TIMER, &CVPCB_MAINFRAME::onTextFilterChangedTimer, this, m_filterTimer->GetId() );
236 Unbind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintViewerOnIdle, this );
237
238 // Clean up the tool infrastructure
239 delete m_actions;
240 delete m_toolManager;
241 delete m_toolDispatcher;
242
243 m_auimgr.UnInit();
244}
245
246
248{
249 // Create the manager
250 m_actions = new CVPCB_ACTIONS();
252 m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
254
255 // Register tools
260
262
263 // Even though these menus will open with the right-click, we treat them as a normal
264 // menu instead of a context menu because we don't care about their position and want
265 // to be able to tell the difference between a menu click and a hotkey activation.
266
267 // Create the context menu for the symbols list box
268 m_symbolsContextMenu = new ACTION_MENU( false, tool );
270 m_symbolsContextMenu->AppendSeparator();
274 m_symbolsContextMenu->AppendSeparator();
276
277 // Create the context menu for the footprint list box
278 m_footprintContextMenu = new ACTION_MENU( false, tool );
280}
281
282
284{
286
288 EDITOR_CONDITIONS cond( this );
289
290 wxASSERT( mgr );
291
292#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
293#define CHECK( x ) ACTION_CONDITIONS().Check( x )
294
299
300 auto compFilter =
301 [this] ( const SELECTION& )
302 {
304 };
305
306 auto libFilter =
307 [this] ( const SELECTION& )
308 {
310 };
311
312 auto pinFilter =
313 [this] ( const SELECTION& )
314 {
316 };
317
321
322#undef CHECK
323#undef ENABLE
324}
325
326
328{
329 // Connect the handlers to launch the context menus in the listboxes
330 m_footprintListBox->Bind( wxEVT_RIGHT_DOWN,
331 [this]( wxMouseEvent& )
332 {
333 PopupMenu( m_footprintContextMenu );
334 } );
335
336 m_symbolsListBox->Bind( wxEVT_RIGHT_DOWN,
337 [this]( wxMouseEvent& )
338 {
339 PopupMenu( m_symbolsContextMenu );
340 } );
341
342 // Connect the handler for the save button
343 m_saveAndContinue->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
344 [this]( wxCommandEvent& )
345 {
346 // saveAssociations must be run immediately
348 } );
349
350 // Connect the handlers for the ok/cancel buttons
351 Bind( wxEVT_BUTTON,
352 [this]( wxCommandEvent& )
353 {
354 // saveAssociations must be run immediately, before running Close( true )
356 Close( true );
357 }, wxID_OK );
358
359 Bind( wxEVT_BUTTON,
360 [this]( wxCommandEvent& )
361 {
362 Close( false );
363 }, wxID_CANCEL );
364
365 // Connect the handlers for the close events
366 Bind( wxEVT_MENU,
367 [this]( wxCommandEvent& )
368 {
369 Close( false );
370 }, wxID_CLOSE );
371 Bind( wxEVT_MENU,
372 [this]( wxCommandEvent& )
373 {
374 Close( false );
375 }, wxID_EXIT );
376
377 // Just skip the resize events
378 Bind( wxEVT_SIZE,
379 []( wxSizeEvent& aEvent )
380 {
381 aEvent.Skip();
382 } );
383}
384
385
386bool CVPCB_MAINFRAME::canCloseWindow( wxCloseEvent& aEvent )
387{
388 if( m_modified )
389 {
390 // Shutdown blocks must be determined and vetoed as early as possible
391 if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION )
392 return false;
393
394 if( !HandleUnsavedChanges( this, _( "Symbol to Footprint links have been modified. Save changes?" ),
395 [&]() -> bool
396 {
397 return SaveFootprintAssociation( false );
398 } ) )
399 {
400 return false;
401 }
402 }
403
404 if( m_cannotClose )
405 return false;
406
407 return true;
408}
409
410
412{
415
417 GetFootprintViewerFrame()->Close( true );
418
419 m_modified = false;
420
421 // Stop the timer during destruction early to avoid potential race conditions (that do happen)
422 m_filterTimer->Stop();
423
424 // Shutdown all running tools
425 if( m_toolManager )
427
428 // clear symbol selection in schematic:
430}
431
432
433void CVPCB_MAINFRAME::onTextFilterChanged( wxCommandEvent& event )
434{
435 // Called when changing the filter string in main toolbar.
436 // If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list
437 // of available footprints which match the filter
438
439 m_filterTimer->StartOnce( 200 );
440}
441
442
444{
445 // GTK loses the search-control's focus on a Refresh event, so we record the focus and
446 // insertion point here and then restore them at the end.
447 bool searchCtrlHasFocus = m_tcFilterString->HasFocus();
448 long pos = m_tcFilterString->GetInsertionPoint();
449
451 wxString libraryName = m_librariesListBox->GetSelectedLibrary();
452
453 m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, symbol,
455
456 if( symbol && symbol->GetFPID().IsValid() )
458 else if( m_footprintListBox->GetSelection() >= 0 )
460
462
464
465 if( searchCtrlHasFocus && !m_tcFilterString->HasFocus() )
466 {
467 m_tcFilterString->SetFocus();
468 m_tcFilterString->SetInsertionPoint( pos );
469 }
470}
471
472
473void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
474{
476 return;
477
479 wxString libraryName = m_librariesListBox->GetSelectedLibrary();
480
481 m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, symbol,
483
484 if( symbol && symbol->GetFPID().IsValid() )
486 else if( m_footprintListBox->GetSelection() >= 0 )
488
490
491 refreshAfterSymbolSearch( symbol );
492}
493
494
496{
498 {
499 Bind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintViewerOnIdle, this );
501 }
502}
503
504
506{
507 Unbind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintViewerOnIdle, this );
508 m_viewerPendingUpdate = false;
509
510 // On some platforms (OSX) the focus is lost when the viewers (fp and 3D viewers)
511 // are opened and refreshed when a new footprint is selected.
512 // If the listbox has the focus before selecting a new footprint, it will be forced
513 // after selection.
514 bool footprintListHasFocus = m_footprintListBox->HasFocus();
515 bool symbolListHasFocus = m_symbolsListBox->HasFocus();
516
517 // If the footprint view window is displayed, update the footprint.
520
522
523 if( footprintListHasFocus )
524 m_footprintListBox->SetFocus();
525 else if( symbolListHasFocus )
526 m_symbolsListBox->SetFocus();
527}
528
529
531{
533
534 if( CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg ) )
535 m_filteringOptions = cfg->m_FilterFlags;
536}
537
538
540{
542
543 if( CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg ) )
544 {
545 cfg->m_FilterFlags = m_filteringOptions;
546 cfg->m_FilterString = m_tcFilterString->GetValue();
547
548 cfg->m_LibrariesWidth = m_librariesListBox->GetSize().x;
549 cfg->m_FootprintsWidth = m_footprintListBox->GetSize().x;
550 }
551}
552
553
555{
556 if( m_undoList.size() == 0 )
557 return;
558
559 CVPCB_UNDO_REDO_ENTRIES redoEntries;
560 CVPCB_UNDO_REDO_ENTRIES curEntry = m_undoList.back();
561 m_undoList.pop_back();
562
563 // Iterate over the entries to undo
564 for( const auto& assoc : curEntry )
565 {
566 AssociateFootprint( assoc, true, false );
567 redoEntries.emplace_back( assoc.Reverse() );
568 }
569
570 // Add the redo entries to the redo stack
571 m_redoList.emplace_back( redoEntries );
572}
573
574
576{
577 if( m_redoList.size() == 0 )
578 return;
579
580 CVPCB_UNDO_REDO_ENTRIES curEntry = m_redoList.back();
581 m_redoList.pop_back();
582
583 // Iterate over the entries to undo
584 bool firstAssoc = true;
585
586 for( const auto& assoc : curEntry )
587 {
588 AssociateFootprint( assoc, firstAssoc );
589 firstAssoc = false;
590 }
591}
592
593
594wxString CVPCB_MAINFRAME::formatSymbolDesc( int idx, const wxString& aReference,
595 const wxString& aValue, const wxString& aFootprint )
596{
597 // Work around a bug in wxString::Format with double-byte chars (and double-quote, for some
598 // reason).
599 wxString desc = wxString::Format( wxT( "%3d " ), idx );
600
601 for( int ii = aReference.Length(); ii < 8; ++ii )
602 desc += wxS( " " );
603
604 desc += aReference + wxT( " - " );
605
606 for( int ii = aValue.Length(); ii < 16; ++ii )
607 desc += wxS( " " );
608
609 desc += aValue + wxT( " : " ) + aFootprint;
610
611 return desc;
612}
613
614
616 bool aNewEntry, bool aAddUndoItem )
617{
618 if( m_netlist.IsEmpty() )
619 return;
620
621 COMPONENT* symbol = m_netlist.GetComponent( aAssociation.GetComponentIndex() );
622
623 if( symbol == nullptr )
624 return;
625
626 LIB_ID fpid = aAssociation.GetNewFootprint();
627 LIB_ID oldFpid = symbol->GetFPID();
628
629 // Test for validity of the requested footprint
630 if( !fpid.empty() && !fpid.IsValid() )
631 {
632 wxString msg = wxString::Format( _( "'%s' is not a valid footprint." ),
633 fpid.Format().wx_str() );
634 DisplayErrorMessage( this, msg );
635 return;
636 }
637
638 const KIID& id = symbol->GetKIIDs().front();
639
640 // Set new footprint to all instances of the selected symbol
641 for( unsigned int idx : GetComponentIndices() )
642 {
643 COMPONENT* candidate = m_netlist.GetComponent( idx );
644 const std::vector<KIID>& kiids = candidate->GetKIIDs();
645
646 if( std::find( kiids.begin(), kiids.end(), id ) != kiids.end() )
647 {
648 // Set the new footprint
649 candidate->SetFPID( fpid );
650
651 // create the new symbol description and set it
652 wxString description = formatSymbolDesc( idx + 1,
653 candidate->GetReference(),
654 candidate->GetValue(),
655 candidate->GetFPID().Format().wx_str() );
656 m_symbolsListBox->SetString( idx, description );
657
658 if( !m_FootprintsList->GetFootprintInfo( symbol->GetFPID().Format().wx_str() ) )
660 else
662 }
663 }
664
665 // Mark the data as being modified
666 m_modified = true;
667
668 // Update the statusbar and refresh the list
670 m_symbolsListBox->Refresh();
671
672 if( !aAddUndoItem )
673 return;
674
675 // Update the undo list
676 if ( aNewEntry )
677 {
678 // Create a new entry for this association
680 newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid,
681 aAssociation.GetNewFootprint() ) );
682 m_undoList.emplace_back( newEntry );
683
684 // Clear the redo list
685 m_redoList.clear();
686 }
687 else
688 {
689 m_undoList.back().emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(),
690 oldFpid,
691 aAssociation.GetNewFootprint() ) );
692 }
693
694}
695
696
697bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
698{
699 return true;
700}
701
702
704{
705 // Tell AuiMgr that objects are changed !
706 if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
707 m_auimgr.Update(); // (could be not the case when starting CvPcb)
708
709 if( aSymbol == nullptr )
710 {
712 return;
713 }
714
715 // Preview of the already assigned footprint.
716 // Find the footprint that was already chosen for this aSymbol and select it,
717 // but only if the selection is made from the aSymbol list or the library list.
718 // If the selection is made from the footprint list, do not change the current
719 // selected footprint.
720 if( FindFocus() == m_symbolsListBox || FindFocus() == m_librariesListBox )
721 {
722 wxString footprintName = From_UTF8( aSymbol->GetFPID().Format().c_str() );
723
725
726 for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
727 {
728 wxString candidateName;
729 wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
730 msg.Trim( true );
731 msg.Trim( false );
732 candidateName = msg.AfterFirst( wxChar( ' ' ) );
733
734 if( footprintName.Cmp( candidateName ) == 0 )
735 {
736 m_footprintListBox->SetSelection( ii, true );
737 break;
738 }
739 }
740 }
741
744}
745
746
749{
750 int option = aFilter;
751
752 // Apply the filter accordingly
753 switch( aAction )
754 {
758 }
759
760 wxListEvent l_event;
761 OnSelectComponent( l_event );
762}
763
764
766{
767 if( !m_initialized )
768 return;
769
770 wxString filters, msg;
772
774 {
775 msg.Empty();
776
777 if( symbol )
778 {
779 for( unsigned ii = 0; ii < symbol->GetFootprintFilters().GetCount(); ii++ )
780 {
781 if( msg.IsEmpty() )
782 msg += symbol->GetFootprintFilters()[ii];
783 else
784 msg += wxT( ", " ) + symbol->GetFootprintFilters()[ii];
785 }
786 }
787
788 filters += _( "Keywords" );
789
790 if( !msg.IsEmpty() )
791 filters += wxString::Format( wxT( " (%s)" ), msg );
792 }
793
795 {
796 msg.Empty();
797
798 if( symbol )
799 msg = wxString::Format( wxT( "%i" ), symbol->GetPinCount() );
800
801 if( !filters.IsEmpty() )
802 filters += wxT( ", " );
803
804 filters += _( "Pin Count" );
805
806 if( !msg.IsEmpty() )
807 filters += wxString::Format( wxT( " (%s)" ), msg );
808 }
809
811 {
813
814 if( !filters.IsEmpty() )
815 filters += wxT( ", " );
816
817 filters += _( "Library" );
818
819 if( !msg.IsEmpty() )
820 filters += wxString::Format( wxT( " (%s)" ), msg );
821 }
822
823 wxString textFilter = m_tcFilterString->GetValue();
824
825 if( !textFilter.IsEmpty() )
826 {
827 if( !filters.IsEmpty() )
828 filters += wxT( ", " );
829
830 filters += _( "Search Text" ) + wxString::Format( wxT( " (%s)" ), textFilter );
831 }
832
833 if( filters.IsEmpty() )
834 msg = _( "No Filtering" );
835 else
836 msg.Printf( _( "Filtered by %s" ), filters );
837
838 msg += wxString::Format( _( ": %i matching footprints" ), m_footprintListBox->GetCount() );
839
840 SetStatusText( msg );
841
842
843 msg.Empty();
844 wxString footprintName = GetSelectedFootprint();
845
846 FOOTPRINT_INFO* fp = m_FootprintsList->GetFootprintInfo( footprintName );
847
848 if( fp ) // can be NULL if no netlist loaded
849 {
850 msg = wxString::Format( _( "Description: %s; Keywords: %s" ),
851 fp->GetDesc(),
852 fp->GetKeywords() );
853 }
854
855 SetStatusText( msg, 1 );
856
857 msg.Empty();
858 wxString lib;
859
860 // Choose the footprint to get the information on
861 if( fp )
862 {
863 // Use the footprint in the footprint viewer
864 lib = fp->GetLibNickname();
865 }
867 {
868 // Use the footprint of the selected symbol
869 if( symbol )
870 lib = symbol->GetFPID().GetUniStringLibNickname();
871 }
873 {
874 // Use the library that is selected
876 }
877
878 // Extract the library information
880
881 if( fptbl->HasLibrary( lib ) )
882 msg = wxString::Format( _( "Library location: %s" ), fptbl->GetFullURI( lib ) );
883 else
884 msg = wxString::Format( _( "Library location: unknown" ) );
885
886 SetStatusText( msg, 2 );
887}
888
889
891{
893
894 // Check if there are footprint libraries in the footprint library table.
895 if( !fptbl || !fptbl->GetLogicalLibs().size() )
896 {
897 wxMessageBox( _( "No PCB footprint libraries are listed in the current footprint "
898 "library table." ), _( "Configuration Error" ), wxOK | wxICON_ERROR );
899 return false;
900 }
901
902 WX_PROGRESS_REPORTER progressReporter( this, _( "Load Footprint Libraries" ), 1, PR_CAN_ABORT );
903
904 m_FootprintsList->ReadFootprintFiles( fptbl, nullptr, &progressReporter );
905
908
909 return true;
910}
911
912
913void CVPCB_MAINFRAME::SendComponentSelectionToSch( bool aClearSelectionOnly )
914{
915 if( m_netlist.IsEmpty() )
916 return;
917
918 std::string command = "$SELECT: ";
919
920 if( aClearSelectionOnly )
921 {
922 // Sending an empty list means clearing the selection.
923 if( Kiface().IsSingle() )
924 SendCommand( MSG_TO_SCH, command );
925 else
926 Kiway().ExpressMail( FRAME_SCH, MAIL_SELECTION, command, this );
927
928 return;
929 }
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 // The prefix 0,F before the reference is for selecting the symbol
943 // (one can select a pin with a different prefix)
944 command += wxT( "0,F" ) + EscapeString( ref, CTX_IPC );
945
946 if( Kiface().IsSingle() )
947 SendCommand( MSG_TO_SCH, command );
948 else
949 Kiway().ExpressMail( FRAME_SCH, MAIL_SELECTION, command, this );
950}
951
952
953int CVPCB_MAINFRAME::readSchematicNetlist( const std::string& aNetlist )
954{
955 STRING_LINE_READER* stringReader = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
956 KICAD_NETLIST_READER netlistReader( stringReader, &m_netlist );
957
959
960 try
961 {
962 netlistReader.LoadNetlist();
963 }
964 catch( const IO_ERROR& ioe )
965 {
966 wxString msg = wxString::Format( _( "Error loading schematic.\n%s" ),
967 ioe.What().GetData() );
968 wxMessageBox( msg, _( "Load Error" ), wxOK | wxICON_ERROR );
969 return 1;
970 }
971
972 // We also remove footprint name if it is "$noname" because this is a dummy name,
973 // not the actual name of the footprint.
974 for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
975 {
976 if( m_netlist.GetComponent( ii )->GetFPID().GetLibItemName() == std::string( "$noname" ) )
978 }
979
980 // Sort symbols by reference:
982
983 return 0;
984}
985
986
988{
989 m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, nullptr, wxEmptyString,
992}
993
994
996{
1000
1001 // Use same sorting algorithm as LIB_TREE_NODE::AssignIntrinsicRanks
1002 struct library_sort
1003 {
1004 bool operator()( const wxString& lhs, const wxString& rhs ) const
1005 {
1006 return StrNumCmp( lhs, rhs, true ) < 0;
1007 }
1008 };
1009
1010 std::set<wxString, library_sort> pinnedMatches;
1011 std::set<wxString, library_sort> otherMatches;
1012
1014
1015 auto process =
1016 [&]( const wxString& aNickname )
1017 {
1018 if( alg::contains( project.m_PinnedFootprintLibs, aNickname )
1019 || alg::contains( cfg->m_Session.pinned_fp_libs, aNickname ) )
1020 {
1021 pinnedMatches.insert( aNickname );
1022 }
1023 else
1024 {
1025 otherMatches.insert( aNickname );
1026 }
1027 };
1028
1029
1030 if( tbl )
1031 {
1032 std::vector<wxString> libNickNames = tbl->GetLogicalLibs();
1033
1034 for( const wxString& libNickName : libNickNames )
1035 process( libNickName );
1036 }
1037
1038 for( const wxString& nickname : pinnedMatches )
1040
1041 for( const wxString& nickname : otherMatches )
1042 m_librariesListBox->AppendLine( nickname );
1043
1045}
1046
1047
1049{
1050 int selection = m_symbolsListBox->GetSelection();
1051
1052 if( selection >= 0 && selection < (int) m_netlist.GetCount() )
1053 return m_netlist.GetComponent( selection );
1054
1055 return nullptr;
1056}
1057
1058
1059void CVPCB_MAINFRAME::SetSelectedComponent( int aIndex, bool aSkipUpdate )
1060{
1061 m_skipComponentSelect = aSkipUpdate;
1062
1063 if( aIndex < 0 )
1064 {
1066 }
1067 else if( aIndex < m_symbolsListBox->GetCount() )
1068 {
1070 m_symbolsListBox->SetSelection( aIndex );
1072 }
1073
1074 m_skipComponentSelect = false;
1075}
1076
1077
1078std::vector<unsigned int>
1080{
1081 std::vector<unsigned int> idx;
1082 int lastIdx;
1083
1084 // Make sure a netlist has been loaded and the box has contents
1085 if( m_netlist.IsEmpty() || m_symbolsListBox->GetCount() == 0 )
1086 return idx;
1087
1088 switch( aCriteria )
1089 {
1091 idx.resize( m_netlist.GetCount() );
1092 std::iota( idx.begin(), idx.end(), 0 );
1093 break;
1094
1096 // Check to see if anything is selected
1097 if( m_symbolsListBox->GetSelectedItemCount() < 1 )
1098 break;
1099
1100 // Get the symbols
1101 lastIdx = m_symbolsListBox->GetFirstSelected();
1102 idx.emplace_back( lastIdx );
1103
1104 lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
1105 while( lastIdx > 0 )
1106 {
1107 idx.emplace_back( lastIdx );
1108 lastIdx = m_symbolsListBox->GetNextSelected( lastIdx );
1109 }
1110 break;
1111
1113 for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
1114 {
1115 if( m_netlist.GetComponent( i )->GetFPID().empty() )
1116 idx.emplace_back( i );
1117 }
1118 break;
1119
1121 for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
1122 {
1123 if( !m_netlist.GetComponent( i )->GetFPID().empty() )
1124 idx.emplace_back( i );
1125 }
1126 break;
1127
1128 default:
1129 wxASSERT_MSG( false, "Invalid symbol selection criteria" );
1130 }
1131
1132 return idx;
1133}
1134
1135
1137{
1138 // returns the Footprint Viewer frame, if exists, or NULL
1139 wxWindow* window = wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME );
1140 return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>( window );
1141}
1142
1143
1145{
1146 return GetFootprintViewerFrame();
1147}
1148
1149
1151{
1153 else if( m_symbolsListBox->HasFocus() ) return CVPCB_MAINFRAME::CONTROL_COMPONENT;
1154 else if( m_footprintListBox->HasFocus() ) return CVPCB_MAINFRAME::CONTROL_FOOTPRINT;
1156}
1157
1158
1160{
1161 switch( aLB )
1162 {
1166 default: break;
1167 }
1168}
1169
1170
1172{
1173 // returns the LIB_ID of the selected footprint in footprint listview
1174 // or a empty string
1176}
1177
1178
1179void CVPCB_MAINFRAME::SetStatusText( const wxString& aText, int aNumber )
1180{
1181 switch( aNumber )
1182 {
1183 case 0: m_statusLine1->SetLabel( aText ); break;
1184 case 1: m_statusLine2->SetLabel( aText ); break;
1185 case 2: m_statusLine3->SetLabel( aText ); break;
1186 default: wxFAIL_MSG( wxT( "Invalid status row number" ) ); break;
1187 }
1188}
1189
1190
1192{
1195 DisplayStatus();
1196}
1197
1198
1200{
1201 const std::string& payload = mail.GetPayload();
1202
1203 switch( mail.Command() )
1204 {
1206 // Disable Close events during readNetListAndFpFiles() to avoid crash when updating
1207 // widgets:
1208 m_cannotClose = true;
1209 readNetListAndFpFiles( payload );
1210 m_cannotClose = false;
1211
1212 /* @todo
1213 Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.
1214 */
1215 break;
1216
1217 case MAIL_RELOAD_LIB:
1218 m_cannotClose = true;
1222 m_cannotClose = false;
1223 break;
1224
1225 default:
1226 ; // ignore most
1227 }
1228}
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:115
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:104
static TOOL_ACTION paste
Definition: actions.h:80
static TOOL_ACTION copy
Definition: actions.h:78
static TOOL_ACTION undo
Definition: actions.h:75
static TOOL_ACTION redo
Definition: actions.h:76
static TOOL_ACTION cut
Definition: actions.h:77
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: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:108
Handle actions that are shared between different applications.
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:100
const wxString & GetReference() const
Definition: pcb_netlist.h:143
const wxString & GetValue() const
Definition: pcb_netlist.h:146
int GetPinCount() const
Definition: pcb_netlist.h:174
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:160
const wxArrayString & GetFootprintFilters() const
Definition: pcb_netlist.h:171
const std::vector< KIID > & GetKIIDs() const
Definition: pcb_netlist.h:168
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:161
Gather all the actions that are shared by tools.
Definition: cvpcb_actions.h:38
static TOOL_ACTION saveAssociationsToFile
Definition: cvpcb_actions.h:56
static TOOL_ACTION FilterFPbyLibrary
Definition: cvpcb_actions.h:68
static TOOL_ACTION filterFPbyPin
Definition: cvpcb_actions.h:67
static TOOL_ACTION deleteAssoc
Definition: cvpcb_actions.h:63
static TOOL_ACTION FilterFPbyFPFilters
Footprint Filtering actions.
Definition: cvpcb_actions.h:66
static TOOL_ACTION saveAssociationsToSchematic
Management actions.
Definition: cvpcb_actions.h:55
static TOOL_ACTION showFootprintViewer
Open the footprint viewer.
Definition: cvpcb_actions.h:48
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.
Definition: cvpcb_control.h:34
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.
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.
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:99
@ FILTERING_BY_COMPONENT_FP_FILTERS
Definition: listboxes.h:101
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 GetKeywords()
wxString GetDesc() override
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:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
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:49
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:40
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition: kiway_express.h:58
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition: kiway_express.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.
Definition: kiway_holder.h:55
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:286
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:499
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:192
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:119
const wxString GetUniStringLibNickname() const
Definition: lib_id.h:88
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
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:295
bool IsEmpty() const
Definition: pcb_netlist.h:285
void Clear()
Remove all components from the netlist.
Definition: pcb_netlist.h:290
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
Definition: pcb_netlist.h:303
void SortByReference()
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:565
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:68
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
Definition: project_pcb.cpp:37
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:204
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:253
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:171
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
ACTIONS * m_actions
Definition: tools_holder.h:172
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:62
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
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:306
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()
Initialize 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:109
wxString wx_str() const
Definition: utf8.cpp:45
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:129
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:194
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 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:52
@ MAIL_SELECTION
Definition: mail_type.h:40
@ MAIL_RELOAD_LIB
Definition: mail_type.h:57
@ 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: unix/app.cpp:90
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: unix/app.cpp:79
void FixupCancelButtonCmdKeyCollision(wxWindow *aWindow)
Definition: wxgtk/ui.cpp:157
KICOMMON_API wxFont GetMonospacedUIFont()
Definition: ui_common.cpp:93
KICOMMON_API 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:100
static PGM_BASE * process
Definition: pgm_base.cpp:899
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:902
see class PGM_BASE
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
wxString From_UTF8(const char *cstring)
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:56
std::vector< wxString > pinned_fp_libs
#define PR_CAN_ABORT