diff --git a/cvpcb/autosel.cpp b/cvpcb/autosel.cpp index 2dc452f008..5b4f21fb15 100644 --- a/cvpcb/autosel.cpp +++ b/cvpcb/autosel.cpp @@ -42,7 +42,7 @@ #include #include -#include +#include #include #define QUOTE '\'' @@ -215,7 +215,7 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event ) if( equivItem.m_ComponentValue.CmpNoCase( component->GetValue() ) != 0 ) continue; - const FOOTPRINT_INFO *module = m_footprints.GetModuleInfo( equivItem.m_FootprintFPID ); + const FOOTPRINT_INFO *module = m_FootprintsList.GetModuleInfo( equivItem.m_FootprintFPID ); bool equ_is_unique = true; unsigned next = idx+1; @@ -277,7 +277,7 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching( wxCommandEvent& event ) { // we do not need to analyze wildcards: single footprint do not // contain them and if there are wildcards it just will not match any - const FOOTPRINT_INFO* module = m_footprints.GetModuleInfo( component->GetFootprintFilters()[0] ); + const FOOTPRINT_INFO* module = m_FootprintsList.GetModuleInfo( component->GetFootprintFilters()[0] ); if( module ) SetNewPkg( component->GetFootprintFilters()[0] ); diff --git a/cvpcb/cfg.cpp b/cvpcb/cfg.cpp index 3cedd1ecc7..2a8c9198af 100644 --- a/cvpcb/cfg.cpp +++ b/cvpcb/cfg.cpp @@ -52,9 +52,6 @@ PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters() m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "EquName" ), &m_EquFilesNames, GROUP_CVP_EQU ) ); - m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( - wxT( "NetIExt" ), &m_NetlistFileExtension ) ); - return m_projectFileParams; } @@ -67,16 +64,12 @@ void CVPCB_MAINFRAME::LoadProjectFile() m_EquFilesNames.Clear(); prj.ConfigLoad( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters() ); - - if( m_NetlistFileExtension.IsEmpty() ) - m_NetlistFileExtension = wxT( "net" ); } void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent ) { PROJECT& prj = Prj(); - SetTitle( wxString::Format( _( "Project file: '%s'" ), GetChars( prj.GetProjectFullName() ) ) ); wxFileName fn = prj.GetProjectFullName(); if( !IsWritable( fn ) ) diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 073844bac3..48f5df5036 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include <3d_viewer.h> @@ -487,7 +487,7 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() CVPCB_MAINFRAME* parentframe = (CVPCB_MAINFRAME *) GetParent(); - wxString footprintName = parentframe->m_footprintListBox->GetSelectedFootprint(); + wxString footprintName = parentframe->GetSelectedFootprint(); if( !footprintName.IsEmpty() ) { @@ -495,7 +495,7 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() SetTitle( msg ); const FOOTPRINT_INFO* module_info = - parentframe->m_footprints.GetModuleInfo( footprintName ); + parentframe->m_FootprintsList.GetModuleInfo( footprintName ); const wxChar* libname; diff --git a/cvpcb/class_components_listbox.cpp b/cvpcb/class_components_listbox.cpp index c4188f3584..d5944aff29 100644 --- a/cvpcb/class_components_listbox.cpp +++ b/cvpcb/class_components_listbox.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -30,7 +30,7 @@ #include #include -#include +#include #include diff --git a/cvpcb/class_footprints_listbox.cpp b/cvpcb/class_footprints_listbox.cpp index b2db63422a..cc3ab0eb9e 100644 --- a/cvpcb/class_footprints_listbox.cpp +++ b/cvpcb/class_footprints_listbox.cpp @@ -29,13 +29,10 @@ #include #include -#include -#include -#include #include #include -#include +#include #include @@ -138,7 +135,7 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a for( unsigned ii = 0; ii < aList.GetCount(); ii++ ) { - if( aFilterType == UNFILTERED ) + if( aFilterType == UNFILTERED_FP_LIST ) { msg.Printf( wxT( "%3d %s:%s" ), int( newList.GetCount() + 1 ), GetChars( aList.GetItem( ii ).GetNickname() ), @@ -147,22 +144,22 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a continue; } - if( (aFilterType & BY_LIBRARY) && !aLibName.IsEmpty() - && !aList.GetItem( ii ).InLibrary( aLibName ) ) + if( (aFilterType & FILTERING_BY_LIBRARY) && !aLibName.IsEmpty() + && !aList.GetItem( ii ).InLibrary( aLibName ) ) continue; - if( (aFilterType & BY_COMPONENT) && aComponent - && !aComponent->MatchesFootprintFilters( aList.GetItem( ii ).GetFootprintName() ) ) + if( (aFilterType & FILTERING_BY_COMPONENT_KEYWORD) && aComponent + && !aComponent->MatchesFootprintFilters( aList.GetItem( ii ).GetFootprintName() ) ) continue; - if( (aFilterType & BY_PIN_COUNT) && aComponent - && aComponent->GetNetCount() != aList.GetItem( ii ).GetUniquePadCount() ) + if( (aFilterType & FILTERING_BY_PIN_COUNT) && aComponent + && aComponent->GetNetCount() != aList.GetItem( ii ).GetUniquePadCount() ) continue; wxString itemsName = aList.GetItem( ii ).GetNickname().Lower () + aList.GetItem (ii).GetFootprintName().Lower (); - if( (aFilterType & BY_NAME) && !footPrintName.IsEmpty() + if( (aFilterType & FILTERING_BY_NAME) && !footPrintName.IsEmpty() && itemsName.Find (footPrintName.Lower ()) == wxNOT_FOUND) { continue; diff --git a/cvpcb/class_library_listbox.cpp b/cvpcb/class_library_listbox.cpp index 53fe40dd60..0615c8c3b7 100644 --- a/cvpcb/class_library_listbox.cpp +++ b/cvpcb/class_library_listbox.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index ba0c8b0f37..bd7d729160 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include #include @@ -66,7 +66,6 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER ) EVT_MENU( wxID_EXIT, CVPCB_MAINFRAME::OnQuit ) EVT_MENU( wxID_HELP, CVPCB_MAINFRAME::GetKicadHelp ) EVT_MENU( wxID_ABOUT, CVPCB_MAINFRAME::GetKicadAbout ) - EVT_MENU( ID_SAVE_PROJECT, CVPCB_MAINFRAME::SaveProjectFile ) EVT_MENU( ID_FIND_ITEMS, CVPCB_MAINFRAME::OnMenuSearch ) EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, CVPCB_MAINFRAME::OnConfigurePaths ) EVT_MENU( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnKeepOpenOnSave ) @@ -95,7 +94,13 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER ) EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow ) EVT_SIZE( CVPCB_MAINFRAME::OnSize ) + // UI event handlers EVT_UPDATE_UI( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave ) + EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, OnFilterFPbyKeywords) + EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, OnFilterFPbyPinCount ) + EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, OnFilterFPbyLibrary ) + EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME, OnFilterFPbyKeyName ) + END_EVENT_TABLE() @@ -111,11 +116,10 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) : m_libListBox = NULL; m_mainToolBar = NULL; m_modified = false; - m_isEESchemaNetlist = false; - m_KeepCvpcbOpen = false; + m_keepCvpcbOpen = false; m_undefinedComponentCnt = 0; m_skipComponentSelect = false; - m_NetlistFileExtension = wxT( "net" ); + m_filteringOptions = 0; /* Name of the document footprint list * usually located in share/modules/footprints_doc @@ -202,9 +206,10 @@ void CVPCB_MAINFRAME::LoadSettings( wxConfigBase* aCfg ) { EDA_BASE_FRAME::LoadSettings( aCfg ); - aCfg->Read( KeepCvpcbOpenEntry, &m_KeepCvpcbOpen, true ); + aCfg->Read( KeepCvpcbOpenEntry, &m_keepCvpcbOpen, true ); aCfg->Read( FootprintDocFileEntry, &m_DocModulesFileName, DEFAULT_FOOTPRINTS_LIST_FILENAME ); + aCfg->Read( FILTERFOOTPRINTKEY, &m_filteringOptions, FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST ); } @@ -212,24 +217,9 @@ void CVPCB_MAINFRAME::SaveSettings( wxConfigBase* aCfg ) { EDA_BASE_FRAME::SaveSettings( aCfg ); - aCfg->Write( KeepCvpcbOpenEntry, m_KeepCvpcbOpen ); + aCfg->Write( KeepCvpcbOpenEntry, m_keepCvpcbOpen ); aCfg->Write( FootprintDocFileEntry, m_DocModulesFileName ); - - int state = 0; - - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) ) - state |= FOOTPRINTS_LISTBOX::BY_COMPONENT; - - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) ) - state |= FOOTPRINTS_LISTBOX::BY_PIN_COUNT; - - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) ) - state |= FOOTPRINTS_LISTBOX::BY_LIBRARY; - -// if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME ) ) -// state |= FOOTPRINTS_LISTBOX::BY_NAME; - - aCfg->Write( wxT( FILTERFOOTPRINTKEY ), state ); + aCfg->Write( FILTERFOOTPRINTKEY, m_filteringOptions ); } @@ -262,7 +252,7 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event ) break; case wxID_YES: - SaveEdits(); + SaveFootprintAssociation(); break; } } @@ -365,11 +355,11 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event ) void CVPCB_MAINFRAME::SaveQuitCvpcb( wxCommandEvent& aEvent ) { - SaveEdits(); + SaveFootprintAssociation(); m_modified = false; - if( !m_KeepCvpcbOpen ) + if( !m_keepCvpcbOpen ) Close( true ); } @@ -403,36 +393,6 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event ) } -/* Remove in favor of Kiway messaging method of sending netlist -void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event ) -{ - int id = event.GetId(); - wxFileName newFileName; - - if( id >= wxID_FILE1 && id <= wxID_FILE9 ) - { - newFileName = GetFileFromHistory( id, _( "Netlist" ) ); - } - else - { - wxFileDialog dlg( this, _( "Open Net List" ), wxGetCwd(), - wxEmptyString, NetlistFileWildcard, - wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); - - if( dlg.ShowModal() == wxID_CANCEL ) - return; - - newFileName = dlg.GetPath(); - } - - if( newFileName == m_NetlistFileName ) - return; - - OpenProjectFiles( std::vector( 1, newFileName.GetFullPath() ) ); -} -*/ - - bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector& aFileSet, int aCtl ) { return true; @@ -487,14 +447,14 @@ void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent ) if( tableChanged ) { BuildLIBRARY_LISTBOX(); - m_footprints.ReadFootprintFiles( Prj().PcbFootprintLibs() ); + m_FootprintsList.ReadFootprintFiles( Prj().PcbFootprintLibs() ); } } void CVPCB_MAINFRAME::OnKeepOpenOnSave( wxCommandEvent& event ) { - m_KeepCvpcbOpen = event.IsChecked(); + m_keepCvpcbOpen = event.IsChecked(); } @@ -518,25 +478,31 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) wxString libraryName; COMPONENT* component = GetSelectedComponent(); - int filter = getFilterType (); libraryName = m_libListBox->GetSelectedLibrary(); - m_footprintListBox->SetFootprints( m_footprints, libraryName, component, m_currentSearch, filter); + + m_footprintListBox->SetFootprints( m_FootprintsList, libraryName, component, + m_currentSearch, m_filteringOptions); + RefreshAfterComponentSearch (component); } void CVPCB_MAINFRAME::OnToolbarSearch( wxCommandEvent& aEvent ) { - if( m_skipComponentSelect ) - return; + if( m_skipComponentSelect ) + return; - if(m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME ) ) { - SearchDialogAndStore (); - } - else { - m_currentSearch = ""; - } + if(m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME ) ) + { + m_filteringOptions |= FOOTPRINTS_LISTBOX::FILTERING_BY_NAME; + SearchDialogAndStore (); + } + else + { + m_filteringOptions &= ~FOOTPRINTS_LISTBOX::FILTERING_BY_NAME; + m_currentSearch = ""; + } - OnSelectFilteringFootprint (aEvent); + OnSelectFilteringFootprint( aEvent ); } void CVPCB_MAINFRAME::OnMenuSearch( wxCommandEvent& aEvent ) @@ -544,105 +510,138 @@ void CVPCB_MAINFRAME::OnMenuSearch( wxCommandEvent& aEvent ) if( m_skipComponentSelect ) return; - SearchDialogAndStore (); - OnSelectFilteringFootprint (aEvent); + m_filteringOptions |= FOOTPRINTS_LISTBOX::FILTERING_BY_NAME; + SearchDialogAndStore(); + OnSelectFilteringFootprint( aEvent ); } -void CVPCB_MAINFRAME::SearchDialogAndStore () +void CVPCB_MAINFRAME::SearchDialogAndStore() { - wxTextEntryDialog myDialog (this, _ ("Find footprint"), _ ("Find"), ""); - if (myDialog.ShowModal () == wxID_OK) { - m_currentSearch = myDialog.GetValue (); + wxTextEntryDialog myDialog( this, _("Find footprint"), _("Find"), "" ); + + if( myDialog.ShowModal() == wxID_OK ) + { + m_currentSearch = myDialog.GetValue(); } - m_mainToolBar->ToggleTool ( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME, !m_currentSearch.empty ()); + m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME, !m_currentSearch.empty() ); } -int CVPCB_MAINFRAME::getFilterType () -{ - int filter = FOOTPRINTS_LISTBOX::UNFILTERED; - - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) ) - filter |= FOOTPRINTS_LISTBOX::BY_COMPONENT; - - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) ) - filter |= FOOTPRINTS_LISTBOX::BY_PIN_COUNT; - - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) ) - filter |= FOOTPRINTS_LISTBOX::BY_LIBRARY; - - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME) ) - filter |= FOOTPRINTS_LISTBOX::BY_NAME; - - return filter; -} void CVPCB_MAINFRAME::RefreshAfterComponentSearch (COMPONENT* component) { - // Tell AuiMgr that objects are changed ! - if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized - // (could be not the case when starting CvPcb - m_auimgr.Update(); + // Tell AuiMgr that objects are changed ! + if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized + // (could be not the case when starting CvPcb + m_auimgr.Update(); - if( component == NULL ) - return; + if( component == NULL ) + return; - // Preview of the already assigned footprint. - // Find the footprint that was already chosen for this component and select it, - // but only if the selection is made from the component list or the library list. - // If the selection is made from the footprint list, do not change the current - // selected footprint. - if( FindFocus() == m_compListBox || FindFocus() == m_libListBox ) - { - wxString module = FROM_UTF8( component->GetFPID().Format().c_str() ); + // Preview of the already assigned footprint. + // Find the footprint that was already chosen for this component and select it, + // but only if the selection is made from the component list or the library list. + // If the selection is made from the footprint list, do not change the current + // selected footprint. + if( FindFocus() == m_compListBox || FindFocus() == m_libListBox ) + { + wxString module = FROM_UTF8( component->GetFPID().Format().c_str() ); + + bool found = false; - bool found = false; + for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ ) + { + wxString footprintName; + wxString msg = m_footprintListBox->OnGetItemText( ii, 0 ); + msg.Trim( true ); + msg.Trim( false ); + footprintName = msg.AfterFirst( wxChar( ' ' ) ); - for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ ) + if( module.Cmp( footprintName ) == 0 ) { - wxString footprintName; - wxString msg = m_footprintListBox->OnGetItemText( ii, 0 ); - msg.Trim( true ); - msg.Trim( false ); - footprintName = msg.AfterFirst( wxChar( ' ' ) ); - - if( module.Cmp( footprintName ) == 0 ) - { - m_footprintListBox->SetSelection( ii, true ); - found = true; - break; - } + m_footprintListBox->SetSelection( ii, true ); + found = true; + break; } + } - if( !found ) - { - int ii = m_footprintListBox->GetSelection(); + if( !found ) + { + int ii = m_footprintListBox->GetSelection(); - if ( ii >= 0 ) - m_footprintListBox->SetSelection( ii, false ); + if ( ii >= 0 ) + m_footprintListBox->SetSelection( ii, false ); - if( GetFootprintViewerFrame() ) - { - CreateScreenCmp(); - } + if( GetFootprintViewerFrame() ) + { + CreateScreenCmp(); } } + } - SendMessageToEESCHEMA(); - DisplayStatus(); + SendMessageToEESCHEMA(); + DisplayStatus(); } void CVPCB_MAINFRAME::OnSelectFilteringFootprint( wxCommandEvent& event ) { - wxListEvent l_event; + int option = 0; + + switch( event.GetId() ) + { + case ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST: + option = FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD; + break; + + case ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST: + option = FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT; + break; + + case ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST: + option = FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY; + break; + + case ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME: + option = FOOTPRINTS_LISTBOX::FILTERING_BY_NAME; + break; + } + + if( event.IsChecked() ) + m_filteringOptions |= option; + else + m_filteringOptions &= ~option; + wxListEvent l_event; OnSelectComponent( l_event ); } void CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event ) { - event.Check( m_KeepCvpcbOpen ); + event.Check( m_keepCvpcbOpen ); +} + +void CVPCB_MAINFRAME::OnFilterFPbyKeywords( wxUpdateUIEvent& event ) +{ + event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD ); +} + + +void CVPCB_MAINFRAME::OnFilterFPbyPinCount( wxUpdateUIEvent& event ) +{ + event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT ); +} + + +void CVPCB_MAINFRAME::OnFilterFPbyLibrary( wxUpdateUIEvent& event ) +{ + event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY ); +} + + +void CVPCB_MAINFRAME::OnFilterFPbyKeyName( wxUpdateUIEvent& event ) +{ + event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_NAME ); } @@ -678,9 +677,9 @@ void CVPCB_MAINFRAME::DisplayStatus() } else { - wxString footprintName = m_footprintListBox->GetSelectedFootprint(); + wxString footprintName = GetSelectedFootprint(); - FOOTPRINT_INFO* module = m_footprints.GetModuleInfo( footprintName ); + FOOTPRINT_INFO* module = m_FootprintsList.GetModuleInfo( footprintName ); if( module ) // can be NULL if no netlist loaded { @@ -697,10 +696,10 @@ void CVPCB_MAINFRAME::DisplayStatus() if( m_footprintListBox ) { - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) ) + if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD ) ) filters = _( "key words" ); - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) ) + if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT ) ) { if( !filters.IsEmpty() ) filters += wxT( "+" ); @@ -708,7 +707,7 @@ void CVPCB_MAINFRAME::DisplayStatus() filters += _( "pin count" ); } - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) ) + if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY ) ) { if( !filters.IsEmpty() ) filters += wxT( "+" ); @@ -716,7 +715,7 @@ void CVPCB_MAINFRAME::DisplayStatus() filters += _( "library" ); } - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME ) ) + if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_NAME ) ) { if( !filters.IsEmpty() ) filters += wxT( "+" ); @@ -748,11 +747,11 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles() return false; } - m_footprints.ReadFootprintFiles( fptbl ); + m_FootprintsList.ReadFootprintFiles( fptbl ); - if( m_footprints.GetErrorCount() ) + if( m_FootprintsList.GetErrorCount() ) { - m_footprints.DisplayErrors( this ); + m_FootprintsList.DisplayErrors( this ); } return true; @@ -880,8 +879,8 @@ void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX() wxFONTWEIGHT_NORMAL ) ); } - m_footprintListBox->SetFootprints( m_footprints, wxEmptyString, NULL, - wxEmptyString, FOOTPRINTS_LISTBOX::UNFILTERED ); + m_footprintListBox->SetFootprints( m_FootprintsList, wxEmptyString, NULL, + wxEmptyString, FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST ); DisplayStatus(); } @@ -973,6 +972,13 @@ DISPLAY_FOOTPRINTS_FRAME* CVPCB_MAINFRAME::GetFootprintViewerFrame() ( wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME ) ); } +const wxString CVPCB_MAINFRAME::GetSelectedFootprint() +{ + // returns the FPID of the selected footprint in footprint listview + // or a empty string + return m_footprintListBox->GetSelectedFootprint(); +} + void CVPCB_MAINFRAME::OnConfigurePaths( wxCommandEvent& aEvent ) { diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index 0c9f90f9b8..801c6f9f07 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -59,24 +59,23 @@ class CVPCB_MAINFRAME : public KIWAY_PLAYER wxArrayString m_footprintListEntries; wxString m_currentSearch; - -public: - bool m_KeepCvpcbOpen; + bool m_keepCvpcbOpen; + NETLIST m_netlist; + int m_filteringOptions; + wxAuiToolBar* m_mainToolBar; FOOTPRINTS_LISTBOX* m_footprintListBox; LIBRARY_LISTBOX* m_libListBox; COMPONENTS_LISTBOX* m_compListBox; - wxAuiToolBar* m_mainToolBar; + +public: wxArrayString m_ModuleLibNames; wxArrayString m_EquFilesNames; - wxString m_NetlistFileExtension; wxString m_DocModulesFileName; - FOOTPRINT_LIST m_footprints; - NETLIST m_netlist; + FOOTPRINT_LIST m_FootprintsList; protected: int m_undefinedComponentCnt; bool m_modified; - bool m_isEESchemaNetlist; bool m_skipComponentSelect; // true to skip OnSelectComponent event // (in automatic selection/deletion of associations) PARAM_CFG_ARRAY m_projectFileParams; @@ -103,6 +102,7 @@ public: * * Updates the footprint shown in footprint display window (if opened) */ void OnSelectComponent( wxListEvent& event ); + void OnToolbarSearch (wxCommandEvent& aEvent); void OnMenuSearch (wxCommandEvent& aEvent); @@ -133,13 +133,6 @@ public: void SaveProjectFile( wxCommandEvent& aEvent ); void SaveQuitCvpcb( wxCommandEvent& event ); - /** - * Function LoadNetList - * reads a netlist selected by user when clicking on load netlist button or any entry - * in the file history menu. - */ - void LoadNetList( wxCommandEvent& event ); - /** * Function OnEditLibraryTable * envokes the footprint library table edit dialog. @@ -175,6 +168,11 @@ public: */ void OnSelectFilteringFootprint( wxCommandEvent& event ); + /** + * Function OnUpdateKeepOpenOnSave + * Command event handler to choose if CvPcb will be closed as soon as the footprint + * association is saved, or if it is left open. + */ void OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event ); /** @@ -196,11 +194,11 @@ public: void CreateScreenCmp(); /** - * Function SaveEdits + * Function SaveFootprintAssociation * saves the edits that the user has done by sending them back to eeschema * via the kiway. */ - void SaveEdits(); + void SaveFootprintAssociation(); /** * Function ReadNetList @@ -268,10 +266,9 @@ public: * Function UpdateTitle * sets the main window title bar text. *

- * If file name defined by CVPCB_MAINFRAME::m_NetlistFileName is not set, the title is - * set to the application name appended with no file. Otherwise, the title is set to - * the full path and file name and read only is appended to the title if the user does - * not have write access to the file. + * If no current project open( eeschema run outside kicad manager with no schematic loaded), + * the title is set to the application name appended with "no project". + * Otherwise, the title shows the project name. */ void UpdateTitle(); @@ -285,7 +282,18 @@ public: COMPONENT* GetSelectedComponent(); + /** + * @return the FPID of the selected footprint in footprint listview + * or a empty string if no selection + */ + const wxString GetSelectedFootprint(); + private: + // UI event handlers + void OnFilterFPbyKeywords( wxUpdateUIEvent& event ); + void OnFilterFPbyPinCount( wxUpdateUIEvent& event ); + void OnFilterFPbyLibrary( wxUpdateUIEvent& event ); + void OnFilterFPbyKeyName( wxUpdateUIEvent& event ); /** * read the .equ files and populate the list of equvalents @@ -297,8 +305,7 @@ private: int buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wxString * aErrorMessages = NULL ); void RefreshAfterComponentSearch (COMPONENT* component); - int getFilterType (); - void SearchDialogAndStore (); + void SearchDialogAndStore(); DECLARE_EVENT_TABLE() diff --git a/cvpcb/dialogs/dialog_display_options.cpp b/cvpcb/dialogs/dialog_display_options.cpp index 9911ebccc6..7bfea78ff6 100644 --- a/cvpcb/dialogs/dialog_display_options.cpp +++ b/cvpcb/dialogs/dialog_display_options.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include diff --git a/cvpcb/listboxes.cpp b/cvpcb/listboxes.cpp index e06c039f68..61fc11005a 100644 --- a/cvpcb/listboxes.cpp +++ b/cvpcb/listboxes.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include diff --git a/cvpcb/cvstruct.h b/cvpcb/listview_classes.h similarity index 96% rename from cvpcb/cvstruct.h rename to cvpcb/listview_classes.h index 0ebf8d9d2b..3bb57933e1 100644 --- a/cvpcb/cvstruct.h +++ b/cvpcb/listview_classes.h @@ -90,13 +90,14 @@ private: wxArrayString m_footprintList; public: + // OR'ed mask to manage footprint filtering options enum FP_FILTER_T { - UNFILTERED = 0, - BY_COMPONENT = 0x0001, - BY_PIN_COUNT = 0x0002, - BY_LIBRARY = 0x0004, - BY_NAME = 0x0008, + UNFILTERED_FP_LIST = 0, + FILTERING_BY_COMPONENT_KEYWORD = 0x0001, + FILTERING_BY_PIN_COUNT = 0x0002, + FILTERING_BY_LIBRARY = 0x0004, + FILTERING_BY_NAME = 0x0008 }; FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id, diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index 9101ebe418..224b0190b3 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -29,8 +29,6 @@ #include #include #include -#include -#include #include #include @@ -45,8 +43,7 @@ */ void CVPCB_MAINFRAME::ReCreateMenuBar() { - // Create and try to get the current menubar - wxMenuItem* item; + // Create the current menubar if it does not yet exist wxMenuBar* menuBar = GetMenuBar(); if( ! menuBar ) // Delete all menus @@ -66,7 +63,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar() // Save the footprints back into eeschema AddMenuItem( filesMenu, wxID_SAVE, - _( "&Save Edits\tCtrl+S" ), + _( "&Save Footprint Association\tCtrl+S" ), _( "Save footprint association in schematic component footprint fields" ), KiBitmap( save_xpm ) ); @@ -100,27 +97,24 @@ void CVPCB_MAINFRAME::ReCreateMenuBar() _( "Edit path configuration environment variables" ), KiBitmap( editor_xpm ) ); + preferencesMenu->AppendSeparator(); AddMenuItem( preferencesMenu, ID_CVPCB_EQUFILES_LIST_EDIT, _( "Edit &Equ Files List" ), _( "Setup equ files list (.equ files)\n" "They are files which give the footprint name from the component value"), KiBitmap( library_table_xpm ) ); + preferencesMenu->AppendSeparator(); // Language submenu Pgm().AddMenuLanguageList( preferencesMenu ); - // Keep open on save - item = new wxMenuItem( preferencesMenu, ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, + // Keep open on save data + preferencesMenu->AppendSeparator(); + AddMenuItem( preferencesMenu, ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, _( "&Keep Open On Save" ), _( "Prevent CvPcb from exiting after saving netlist file" ), + KiBitmap( exit_xpm ), wxITEM_CHECK ); - preferencesMenu->Append( item ); - SETBITMAPS( window_close_xpm ); - - // Separator - preferencesMenu->AppendSeparator(); - AddMenuItem( preferencesMenu, ID_SAVE_PROJECT, - _( "&Save Project File" ), SAVE_HLP_MSG, KiBitmap( save_setup_xpm ) ); // Menu Help: wxMenu* helpMenu = new wxMenu; diff --git a/cvpcb/readwrite_dlgs.cpp b/cvpcb/readwrite_dlgs.cpp index 0debf31f81..28c6415e80 100644 --- a/cvpcb/readwrite_dlgs.cpp +++ b/cvpcb/readwrite_dlgs.cpp @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include @@ -368,7 +368,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles( const std::string& aNetlist ) } -void CVPCB_MAINFRAME::SaveEdits() +void CVPCB_MAINFRAME::SaveFootprintAssociation() { STRING_FORMATTER sf; @@ -376,5 +376,5 @@ void CVPCB_MAINFRAME::SaveEdits() Kiway().ExpressMail( FRAME_SCH, MAIL_BACKANNOTATE_FOOTPRINTS, sf.GetString() ); - SetStatusText( _("Edits sent to Eeschema") ); + SetStatusText( _("Footprint association sent to Eeschema") ); } diff --git a/cvpcb/tool_cvpcb.cpp b/cvpcb/tool_cvpcb.cpp index 28d6c0112a..c28259072e 100644 --- a/cvpcb/tool_cvpcb.cpp +++ b/cvpcb/tool_cvpcb.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 2007-2013 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2007-2016 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -41,8 +41,6 @@ void CVPCB_MAINFRAME::ReCreateHToolbar() { - wxConfigBase* config = Kiface().KifaceSettings(); - if( m_mainToolBar != NULL ) return; @@ -111,16 +109,6 @@ void CVPCB_MAINFRAME::ReCreateHToolbar() _( "Find footprint by its name\nor filter the footprint list by the partial name\n" "Ctrl+F to call the dialog to enter the filter string" ), wxEmptyString ); - if( config ) - { - wxString key = wxT( FILTERFOOTPRINTKEY ); - int opt = config->Read( key, (long) 1 ); - - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME, opt & 8 ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, opt & 4 ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, opt & 2 ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, opt & 1 ); - } // after adding the buttons to the toolbar, must call Realize() to reflect the changes m_mainToolBar->Realize(); diff --git a/eeschema/schframe.h b/eeschema/schframe.h index 23a9bb0581..95840f5bed 100644 --- a/eeschema/schframe.h +++ b/eeschema/schframe.h @@ -669,7 +669,6 @@ public: void SetPrintSheetReference( bool aShow ) { m_printSheetReference = aShow; } // Plot functions: -// void ToPostProcess( wxCommandEvent& event ); void PlotSchematic( wxCommandEvent& event ); // read and save files diff --git a/include/menus_helpers.h b/include/menus_helpers.h index 97b0ef350d..ace6be52ed 100644 --- a/include/menus_helpers.h +++ b/include/menus_helpers.h @@ -38,20 +38,7 @@ /** - * Definition SETBITMAPS - * is a macro use to add a bitmaps to check menu item. - * @note Do not use with normal menu items or any platform other than Windows. - * @param aImage is the image to add the menu item. - */ -#if defined( USE_IMAGES_IN_MENUS ) && defined( __WINDOWS__ ) -# define SETBITMAPS( aImage ) item->SetBitmaps( KiBitmap( checked_ok_xpm ), KiBitmap( aImage ) ) -#else -# define SETBITMAPS( aImage ) -#endif - -/** - * Definition SETBITMAP - * is a macro use to add a bitmap to a menu items. + * SET_BITMAP is a macro used to add a bitmap to a menu item. * @note Do not use with checked menu items. * @param aImage is the image to add the menu item. */