@ -44,7 +44,7 @@
# include <cvpcb_mainframe.h>
# include <cvpcb.h>
# include <cvstruct .h>
# include <listview_classes .h>
# include <invoke_pcb_dialog.h>
# include <class_DisplayFootprintsFrame.h>
# include <cvpcb_id.h>
@ -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_K eepCvpcbOpen , true ) ;
aCfg - > Read ( KeepCvpcbOpenEntry , & m_k eepCvpcbOpen , 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_K eepCvpcbOpen ) ;
aCfg - > Write ( KeepCvpcbOpenEntry , m_k eepCvpcbOpen ) ;
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_K eepCvpcbOpen )
if ( ! m_k eepCvpcbOpen )
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 < wxString > ( 1 , newFileName . GetFullPath ( ) ) ) ;
}
*/
bool CVPCB_MAINFRAME : : OpenProjectFiles ( const std : : vector < wxString > & 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_K eepCvpcbOpen = event . IsChecked ( ) ;
m_k eepCvpcbOpen = 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_LIS T ) )
if ( ( m_filteringOptions & FOOTPRINTS_LISTBOX : : FILTERING_BY_PIN_COUN T ) )
{
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 )
{