Dialog-ize CvPcb and implement proper Save.

Save now goes to disk (instead of just the in-memory schemaitc),
and the UI attempts to make this clear.
This commit is contained in:
Jeff Young 2018-03-24 18:28:35 +00:00
parent 8d8c422a19
commit b24b0d5dfe
10 changed files with 198 additions and 178 deletions

View File

@ -112,28 +112,39 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
} }
DIALOG_SHIM* findQuasiModalDialog( wxWindowList& aList ) wxWindow* EDA_BASE_FRAME::findQuasiModalDialog()
{ {
for( wxWindowList::iterator iter = aList.begin(); iter != aList.end(); ++iter ) for( auto& iter : GetChildren() )
{ {
DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( *iter ); DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( iter );
if( dlg && dlg->IsQuasiModal() ) if( dlg && dlg->IsQuasiModal() )
return dlg; return dlg;
} }
return NULL;
// FIXME: CvPcb is currently implemented on top of KIWAY_PLAYER rather than DIALOG_SHIM,
// so we have to look for it separately.
if( m_Ident == FRAME_SCH )
{
wxWindow* cvpcb = wxWindow::FindWindowByName( "CvpcbFrame" );
if( cvpcb )
return cvpcb;
}
return nullptr;
} }
void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event ) void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
{ {
DIALOG_SHIM* dlg = findQuasiModalDialog( GetChildren() ); // Don't allow closing when a quasi-modal is open.
if( dlg ) wxWindow* quasiModal = findQuasiModalDialog();
if( quasiModal )
{ {
// Happens when a quasi modal dialog is currently open. // Raise and notify; don't give the user a warning regarding "quasi-modal dialogs"
// For example: if the Kicad manager try to close Kicad. // when they have no idea what those are.
wxMessageBox( _( quasiModal->Raise();
"The program cannot be closed\n" wxBell();
"A quasi-modal dialog window is currently open, please close it first." ) );
event.Veto(); event.Veto();
return; return;
} }
@ -182,7 +193,7 @@ bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
// them. // them.
if( !IsEnabled() && IsActive() ) if( !IsEnabled() && IsActive() )
{ {
DIALOG_SHIM* dlg = findQuasiModalDialog( GetChildren() ); wxWindow* dlg = findQuasiModalDialog();
if( dlg ) if( dlg )
dlg->Raise(); dlg->Raise();
} }

View File

@ -39,9 +39,7 @@
// specific IDs // specific IDs
enum id_cvpcb_frm enum id_cvpcb_frm
{ {
ID_CVPCB_QUIT = ID_END_LIST, ID_CVPCB_CREATE_SCREENCMP = ID_END_LIST,
ID_CVPCB_SAVEQUITCVPCB,
ID_CVPCB_CREATE_SCREENCMP,
ID_CVPCB_GOTO_FIRSTNA, ID_CVPCB_GOTO_FIRSTNA,
ID_CVPCB_GOTO_PREVIOUSNA, ID_CVPCB_GOTO_PREVIOUSNA,
ID_CVPCB_DEL_ASSOCIATIONS, ID_CVPCB_DEL_ASSOCIATIONS,
@ -54,7 +52,6 @@ enum id_cvpcb_frm
ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST,
ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST,
ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME, ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME,
ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
ID_CVPCB_LIBRARY_LIST, ID_CVPCB_LIBRARY_LIST,
ID_CVPCB_EQUFILES_LIST_EDIT, ID_CVPCB_EQUFILES_LIST_EDIT,
ID_CVPCB_LIB_TABLE_EDIT, ID_CVPCB_LIB_TABLE_EDIT,

View File

@ -34,11 +34,8 @@
#include <kiface_i.h> #include <kiface_i.h>
#include <macros.h> #include <macros.h>
#include <confirm.h> #include <confirm.h>
#include <eda_doc.h>
#include <eda_dde.h> #include <eda_dde.h>
#include <gestfich.h>
#include <html_messagebox.h> #include <html_messagebox.h>
#include <wildcards_and_files_ext.h>
#include <fp_lib_table.h> #include <fp_lib_table.h>
#include <netlist_reader.h> #include <netlist_reader.h>
#include <bitmaps.h> #include <bitmaps.h>
@ -58,26 +55,20 @@ wxSize const FRAME_DEFAULT_SIZE_DU( 450, 300 );
///@{ ///@{
/// \ingroup config /// \ingroup config
/// Nonzero if cvpcb should be kept open after saving association in schematic
static const wxString KeepCvpcbOpenEntry = "KeepCvpcbOpen";
static const wxString FilterFootprintEntry = "FilterFootprint"; static const wxString FilterFootprintEntry = "FilterFootprint";
///@} ///@}
BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER ) BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER )
// Menu events // Menu events
EVT_MENU( wxID_SAVE, CVPCB_MAINFRAME::SaveQuitCvpcb ) EVT_MENU( wxID_SAVE, CVPCB_MAINFRAME::OnSaveAndContinue )
EVT_MENU( wxID_EXIT, CVPCB_MAINFRAME::OnQuit ) EVT_MENU( wxID_EXIT, CVPCB_MAINFRAME::OnQuit )
EVT_MENU( wxID_HELP, CVPCB_MAINFRAME::GetKicadHelp ) EVT_MENU( wxID_HELP, CVPCB_MAINFRAME::GetKicadHelp )
EVT_MENU( wxID_ABOUT, CVPCB_MAINFRAME::GetKicadAbout ) EVT_MENU( wxID_ABOUT, CVPCB_MAINFRAME::GetKicadAbout )
EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, CVPCB_MAINFRAME::OnConfigurePaths ) EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, CVPCB_MAINFRAME::OnConfigurePaths )
EVT_MENU( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnKeepOpenOnSave )
EVT_MENU( ID_CVPCB_EQUFILES_LIST_EDIT, CVPCB_MAINFRAME::OnEditEquFilesList ) EVT_MENU( ID_CVPCB_EQUFILES_LIST_EDIT, CVPCB_MAINFRAME::OnEditEquFilesList )
// Toolbar events // Toolbar events
EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit )
EVT_TOOL( ID_CVPCB_LIB_TABLE_EDIT, CVPCB_MAINFRAME::OnEditFootprintLibraryTable ) EVT_TOOL( ID_CVPCB_LIB_TABLE_EDIT, CVPCB_MAINFRAME::OnEditFootprintLibraryTable )
EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP, CVPCB_MAINFRAME::DisplayModule ) EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP, CVPCB_MAINFRAME::DisplayModule )
EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA, CVPCB_MAINFRAME::ToFirstNA ) EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA, CVPCB_MAINFRAME::ToFirstNA )
@ -94,12 +85,15 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER )
CVPCB_MAINFRAME::OnSelectFilteringFootprint ) CVPCB_MAINFRAME::OnSelectFilteringFootprint )
EVT_TEXT( ID_CVPCB_FILTER_TEXT_EDIT, CVPCB_MAINFRAME::OnEnterFilteringText ) EVT_TEXT( ID_CVPCB_FILTER_TEXT_EDIT, CVPCB_MAINFRAME::OnEnterFilteringText )
// Button events
EVT_BUTTON( wxID_OK, CVPCB_MAINFRAME::OnOK )
EVT_BUTTON( wxID_CANCEL, CVPCB_MAINFRAME::OnCancel )
// Frame events // Frame events
EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow ) EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow )
EVT_SIZE( CVPCB_MAINFRAME::OnSize ) EVT_SIZE( CVPCB_MAINFRAME::OnSize )
// UI event handlers // 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, CVPCB_MAINFRAME::OnFilterFPbyKeywords) EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, CVPCB_MAINFRAME::OnFilterFPbyKeywords)
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, CVPCB_MAINFRAME::OnFilterFPbyPinCount ) EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, CVPCB_MAINFRAME::OnFilterFPbyPinCount )
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, CVPCB_MAINFRAME::OnFilterFPbyLibrary ) EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, CVPCB_MAINFRAME::OnFilterFPbyLibrary )
@ -120,8 +114,6 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_libListBox = NULL; m_libListBox = NULL;
m_mainToolBar = NULL; m_mainToolBar = NULL;
m_modified = false; m_modified = false;
m_keepCvpcbOpen = false;
m_undefinedComponentCnt = 0;
m_skipComponentSelect = false; m_skipComponentSelect = false;
m_filteringOptions = 0; m_filteringOptions = 0;
m_tcFilterString = NULL; m_tcFilterString = NULL;
@ -143,12 +135,6 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
// Frame size and position // Frame size and position
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
// create the status bar
static const int dims[3] = { -1, -1, 250 };
CreateStatusBar( 3 );
SetStatusWidths( 3, dims );
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
@ -167,7 +153,6 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
EDA_PANEINFO info; EDA_PANEINFO info;
info.InfoToolbarPane(); info.InfoToolbarPane();
if( m_mainToolBar ) if( m_mainToolBar )
m_auimgr.AddPane( m_mainToolBar, m_auimgr.AddPane( m_mainToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top() ); wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top() );
@ -186,12 +171,55 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
wxAuiPaneInfo( info ).Name( wxT( "m_footprintListBox" ) ). wxAuiPaneInfo( info ).Name( wxT( "m_footprintListBox" ) ).
Right().BestSize( (int) ( m_FrameSize.x * 0.30 ), m_FrameSize.y ) ); Right().BestSize( (int) ( m_FrameSize.x * 0.30 ), m_FrameSize.y ) );
auto bottomPanel = new wxPanel( this );
auto panelSizer = new wxBoxSizer( wxHORIZONTAL );
auto statusSizer = new wxBoxSizer( wxVERTICAL );
m_statusLine1 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
m_statusLine1->SetFont( wxFont( 10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
statusSizer->Add( m_statusLine1, 0, wxTOP, 5 );
m_statusLine2 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
m_statusLine2->SetFont( wxFont( 10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
statusSizer->Add( m_statusLine2, 0, wxTOP, 4 );
panelSizer->Add( statusSizer, 1, wxEXPAND|wxLEFT, 5 );
m_saveAndContinue = new wxButton( bottomPanel, wxID_SAVE,
wxT("Apply, Save Schematic && Continue") );
panelSizer->Add( m_saveAndContinue, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
auto sdbSizer1 = new wxStdDialogButtonSizer();
auto sdbSizer1OK = new wxButton( bottomPanel, wxID_OK );
sdbSizer1->AddButton( sdbSizer1OK );
auto sdbSizer1Cancel = new wxButton( bottomPanel, wxID_CANCEL );
sdbSizer1->AddButton( sdbSizer1Cancel );
sdbSizer1->Realize();
panelSizer->Add( sdbSizer1, 0, wxEXPAND|wxLEFT, 10 );
bottomPanel->SetSizer( panelSizer );
bottomPanel->Fit();
sdbSizer1OK->SetDefault();
m_auimgr.AddPane( bottomPanel, wxAuiPaneInfo( horiz ).Name( wxT( "buttons" ) ).Bottom() );
m_auimgr.Update(); m_auimgr.Update();
// Connect Events
m_saveAndContinue->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CVPCB_MAINFRAME::OnSaveAndContinue ), NULL, this );
} }
CVPCB_MAINFRAME::~CVPCB_MAINFRAME() CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
{ {
// Disconnect Events
m_saveAndContinue->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CVPCB_MAINFRAME::OnSaveAndContinue ), NULL, this );
m_auimgr.UnInit(); m_auimgr.UnInit();
} }
@ -205,7 +233,6 @@ void CVPCB_MAINFRAME::LoadSettings( wxConfigBase* aCfg )
if( m_FrameSize == wxDefaultSize ) if( m_FrameSize == wxDefaultSize )
m_FrameSize = frame_default; m_FrameSize = frame_default;
aCfg->Read( KeepCvpcbOpenEntry, &m_keepCvpcbOpen, true );
aCfg->Read( FilterFootprintEntry, &m_filteringOptions, FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST ); aCfg->Read( FilterFootprintEntry, &m_filteringOptions, FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST );
} }
@ -214,7 +241,6 @@ void CVPCB_MAINFRAME::SaveSettings( wxConfigBase* aCfg )
{ {
EDA_BASE_FRAME::SaveSettings( aCfg ); EDA_BASE_FRAME::SaveSettings( aCfg );
aCfg->Write( KeepCvpcbOpenEntry, m_keepCvpcbOpen );
aCfg->Write( FilterFootprintEntry, m_filteringOptions ); aCfg->Write( FilterFootprintEntry, m_filteringOptions );
} }
@ -225,12 +251,6 @@ void CVPCB_MAINFRAME::OnSize( wxSizeEvent& event )
} }
void CVPCB_MAINFRAME::OnQuit( wxCommandEvent& event )
{
Close( false );
}
void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event ) void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
if( m_modified ) if( m_modified )
@ -248,7 +268,7 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
break; break;
case wxID_YES: case wxID_YES:
SaveFootprintAssociation(); SaveFootprintAssociation( false );
break; break;
} }
} }
@ -260,7 +280,6 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
m_modified = false; m_modified = false;
Destroy(); Destroy();
return;
} }
@ -294,14 +313,14 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
if( m_netlist.IsEmpty() ) if( m_netlist.IsEmpty() )
return; return;
long first_selected = m_compListBox->GetFirstSelected(); int first_selected = m_compListBox->GetFirstSelected();
if( first_selected < 0 ) if( first_selected < 0 )
first_selected = -1; // We will start to 0 for the first search , if no item selected first_selected = -1; // We will start to 0 for the first search , if no item selected
int candidate = -1; int candidate = -1;
for( unsigned jj = first_selected+1; jj < m_netlist.GetCount(); jj++ ) for( int jj = first_selected+1; jj < m_netlist.GetCount(); jj++ )
{ {
if( m_netlist.GetComponent( jj )->GetFPID().empty() ) if( m_netlist.GetComponent( jj )->GetFPID().empty() )
{ {
@ -349,17 +368,39 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
} }
void CVPCB_MAINFRAME::SaveQuitCvpcb( wxCommandEvent& aEvent ) void CVPCB_MAINFRAME::OnOK( wxCommandEvent& aEvent )
{ {
SaveFootprintAssociation(); SaveFootprintAssociation( false );
m_modified = false; m_modified = false;
if( !m_keepCvpcbOpen )
Close( true ); Close( true );
} }
void CVPCB_MAINFRAME::OnSaveAndContinue( wxCommandEvent& aEvent )
{
SaveFootprintAssociation( true );
m_modified = false;
}
void CVPCB_MAINFRAME::OnCancel( wxCommandEvent& event )
{
// Throw away modifications on a Cancel
m_modified = false;
Close( false );
}
void CVPCB_MAINFRAME::OnQuit( wxCommandEvent& event )
{
Close( false );
}
void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event ) void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
{ {
if( IsOK( this, _( "Delete selections" ) ) ) if( IsOK( this, _( "Delete selections" ) ) )
@ -382,7 +423,6 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
m_skipComponentSelect = false; m_skipComponentSelect = false;
m_compListBox->SetSelection( 0 ); m_compListBox->SetSelection( 0 );
m_undefinedComponentCnt = m_netlist.GetCount();
} }
DisplayStatus(); DisplayStatus();
@ -449,12 +489,6 @@ void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent )
} }
void CVPCB_MAINFRAME::OnKeepOpenOnSave( wxCommandEvent& event )
{
m_keepCvpcbOpen = event.IsChecked();
}
void CVPCB_MAINFRAME::DisplayModule( wxCommandEvent& event ) void CVPCB_MAINFRAME::DisplayModule( wxCommandEvent& event )
{ {
CreateScreenCmp(); CreateScreenCmp();
@ -486,7 +520,10 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component )
m_auimgr.Update(); m_auimgr.Update();
if( component == NULL ) if( component == NULL )
{
DisplayStatus();
return; return;
}
// Preview of the already assigned footprint. // Preview of the already assigned footprint.
// Find the footprint that was already chosen for this component and select it, // Find the footprint that was already chosen for this component and select it,
@ -567,12 +604,6 @@ void CVPCB_MAINFRAME::OnSelectFilteringFootprint( wxCommandEvent& event )
} }
void CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event )
{
event.Check( m_keepCvpcbOpen );
}
void CVPCB_MAINFRAME::OnFilterFPbyKeywords( wxUpdateUIEvent& event ) void CVPCB_MAINFRAME::OnFilterFPbyKeywords( wxUpdateUIEvent& event )
{ {
event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD ); event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD );
@ -614,19 +645,16 @@ void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent )
void CVPCB_MAINFRAME::DisplayStatus() void CVPCB_MAINFRAME::DisplayStatus()
{ {
wxString msg; if( !m_libListBox || !m_compListBox || !m_footprintListBox )
COMPONENT* component; return; // still initializing; not ready for status yet
if( wxWindow::FindFocus() == m_compListBox || wxWindow::FindFocus() == m_libListBox ) wxString filters, msg;
COMPONENT* component = GetSelectedComponent();
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD ) )
{ {
msg.Printf( _( "Components: %d, unassigned: %d" ), (int) m_netlist.GetCount(),
m_undefinedComponentCnt );
SetStatusText( msg, 0 );
msg.Empty(); msg.Empty();
component = GetSelectedComponent();
if( component ) if( component )
{ {
for( unsigned ii = 0; ii < component->GetFootprintFilters().GetCount(); ii++ ) for( unsigned ii = 0; ii < component->GetFootprintFilters().GetCount(); ii++ )
@ -636,58 +664,40 @@ void CVPCB_MAINFRAME::DisplayStatus()
else else
msg += wxT( ", " ) + component->GetFootprintFilters()[ii]; msg += wxT( ", " ) + component->GetFootprintFilters()[ii];
} }
msg = _( "Filter list: " ) + msg;
} }
SetStatusText( msg, 1 ); filters += _( "key words" ) + wxString::Format( wxT( " (%s)" ), msg );
} }
else
{
wxString footprintName = GetSelectedFootprint();
FOOTPRINT_INFO* module = m_FootprintsList->GetModuleInfo( footprintName );
if( module ) // can be NULL if no netlist loaded
{
msg = _( "Description: " ) + module->GetDoc();
SetStatusText( msg, 0 );
msg = _( "Key words: " ) + module->GetKeywords();
SetStatusText( msg, 1 );
}
}
msg.Empty();
wxString filters;
if( m_footprintListBox )
{
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD ) )
filters = _( "key words" );
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT ) ) if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT ) )
{ {
if( !filters.IsEmpty() ) msg.Empty();
filters += wxT( "+" );
filters += _( "pin count" ); if( component )
msg = wxString::Format( wxT( "%i" ), component->GetNetCount() );
if( !filters.IsEmpty() )
filters += wxT( ", " );
filters += _( "pin count" ) + wxString::Format( wxT( " (%s)" ), msg );
} }
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY ) ) if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY ) )
{ {
if( !filters.IsEmpty() ) msg = m_libListBox->GetSelectedLibrary();
filters += wxT( "+" );
filters += _( "library" ); if( !filters.IsEmpty() )
filters += wxT( ", " );
filters += _( "library" ) + wxString::Format( wxT( " (%s)" ), msg );
} }
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_NAME ) ) if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_NAME ) )
{ {
if( !filters.IsEmpty() ) if( !filters.IsEmpty() )
filters += wxT( "+" ); filters += wxT( ", " );
filters += _( "name" ); filters += _( "search text" );
} }
if( filters.IsEmpty() ) if( filters.IsEmpty() )
@ -697,8 +707,22 @@ void CVPCB_MAINFRAME::DisplayStatus()
msg << wxT( ": " ) << m_footprintListBox->GetCount(); msg << wxT( ": " ) << m_footprintListBox->GetCount();
SetStatusText( msg, 2 ); m_statusLine1->SetLabel( msg );
msg.Empty();
wxString footprintName = GetSelectedFootprint();
FOOTPRINT_INFO* module = m_FootprintsList->GetModuleInfo( footprintName );
if( module ) // can be NULL if no netlist loaded
{
msg = wxString::Format( _( "Description: %s; Key words: %s" ),
module->GetDoc(),
module->GetKeywords() );
} }
m_statusLine2->SetLabel( msg );
} }
@ -785,8 +809,8 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist( const std::string& aNetlist )
} }
catch( const IO_ERROR& ioe ) catch( const IO_ERROR& ioe )
{ {
wxString msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.What().GetData() ); wxString msg = wxString::Format( _( "Error loading schematic.\n%s" ), ioe.What().GetData() );
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR ); wxMessageBox( msg, _( "Load Error" ), wxOK | wxICON_ERROR );
return 1; return 1;
} }
@ -977,6 +1001,10 @@ void CVPCB_MAINFRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
*/ */
break; break;
case MAIL_STATUS:
m_statusLine2->SetLabel( payload );
break;
default: default:
; // ignore most ; // ignore most
} }

View File

@ -58,9 +58,7 @@ class CVPCB_MAINFRAME : public KIWAY_PLAYER
{ {
friend struct CV::IFACE; friend struct CV::IFACE;
wxArrayString m_footprintListEntries;
wxString m_currentSearchPattern; wxString m_currentSearchPattern;
bool m_keepCvpcbOpen;
NETLIST m_netlist; NETLIST m_netlist;
int m_filteringOptions; int m_filteringOptions;
wxAuiToolBar* m_mainToolBar; wxAuiToolBar* m_mainToolBar;
@ -68,6 +66,9 @@ class CVPCB_MAINFRAME : public KIWAY_PLAYER
LIBRARY_LISTBOX* m_libListBox; LIBRARY_LISTBOX* m_libListBox;
COMPONENTS_LISTBOX* m_compListBox; COMPONENTS_LISTBOX* m_compListBox;
wxTextCtrl* m_tcFilterString; wxTextCtrl* m_tcFilterString;
wxStaticText* m_statusLine1;
wxStaticText* m_statusLine2;
wxButton* m_saveAndContinue;
public: public:
wxArrayString m_ModuleLibNames; wxArrayString m_ModuleLibNames;
@ -111,9 +112,13 @@ public:
*/ */
void OnEditFootprintLibraryTable( wxCommandEvent& event ); void OnEditFootprintLibraryTable( wxCommandEvent& event );
void OnCancel( wxCommandEvent& aEvent );
void OnOK( wxCommandEvent& aEvent );
void OnSaveAndContinue( wxCommandEvent& aEvent );
void OnQuit( wxCommandEvent& event ); void OnQuit( wxCommandEvent& event );
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
void OnSize( wxSizeEvent& SizeEvent ); void OnSize( wxSizeEvent& SizeEvent );
void OnKeyDown( wxKeyEvent& aEvent );
void ReCreateHToolbar(); void ReCreateHToolbar();
virtual void ReCreateMenuBar() override; virtual void ReCreateMenuBar() override;
void ShowChangedLanguage() override; void ShowChangedLanguage() override;
@ -129,8 +134,6 @@ public:
*/ */
void DelAssociations( wxCommandEvent& event ); void DelAssociations( wxCommandEvent& event );
void SaveQuitCvpcb( wxCommandEvent& event );
void OnConfigurePaths( wxCommandEvent& aEvent ); void OnConfigurePaths( wxCommandEvent& aEvent );
/** /**
@ -139,7 +142,6 @@ public:
*/ */
void OnEditEquFilesList( wxCommandEvent& aEvent ); void OnEditEquFilesList( wxCommandEvent& aEvent );
void OnKeepOpenOnSave( wxCommandEvent& event );
void DisplayModule( wxCommandEvent& event ); void DisplayModule( wxCommandEvent& event );
/** /**
@ -152,8 +154,6 @@ public:
*/ */
void AutomaticFootprintMatching( wxCommandEvent& event ); void AutomaticFootprintMatching( wxCommandEvent& event );
void DisplayDocFile( wxCommandEvent& event );
/** /**
* Function OnSelectFilteringFootprint * Function OnSelectFilteringFootprint
* is the command event handler for enabling and disabling footprint filtering. * is the command event handler for enabling and disabling footprint filtering.
@ -197,8 +197,9 @@ public:
* Function SaveFootprintAssociation * Function SaveFootprintAssociation
* saves the edits that the user has done by sending them back to eeschema * saves the edits that the user has done by sending them back to eeschema
* via the kiway. * via the kiway.
* Optionally saves the schematic to disk as well.
*/ */
void SaveFootprintAssociation(); void SaveFootprintAssociation( bool doSaveSchematic );
/** /**
* Function ReadNetListAndFpFiles * Function ReadNetListAndFpFiles
@ -305,7 +306,6 @@ public:
private: private:
// UI event handlers. // UI event handlers.
// Keep consistent the display state of toggle menus or tools in toolbar // Keep consistent the display state of toggle menus or tools in toolbar
void OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event );
void OnFilterFPbyKeywords( wxUpdateUIEvent& event ); void OnFilterFPbyKeywords( wxUpdateUIEvent& event );
void OnFilterFPbyPinCount( wxUpdateUIEvent& event ); void OnFilterFPbyPinCount( wxUpdateUIEvent& event );
void OnFilterFPbyLibrary( wxUpdateUIEvent& event ); void OnFilterFPbyLibrary( wxUpdateUIEvent& event );

View File

@ -62,18 +62,10 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Save the footprints back into eeschema // Save the footprints back into eeschema
AddMenuItem( filesMenu, wxID_SAVE, AddMenuItem( filesMenu, wxID_SAVE,
_( "&Save Footprint Associations\tCtrl+S" ), _( "&Save Schematic\tCtrl+S" ),
SAVE_HLP_MSG, SAVE_HLP_MSG,
KiBitmap( save_xpm ) ); KiBitmap( save_xpm ) );
// Separator
filesMenu->AppendSeparator();
// Quit
AddMenuItem( filesMenu, wxID_EXIT,
_( "&Close" ), _( "Close CvPcb" ),
KiBitmap( exit_xpm ) );
// Preferences Menu : // Preferences Menu :
wxMenu* preferencesMenu = new wxMenu; wxMenu* preferencesMenu = new wxMenu;
@ -100,14 +92,6 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Language submenu // Language submenu
Pgm().AddMenuLanguageList( preferencesMenu ); Pgm().AddMenuLanguageList( preferencesMenu );
// 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 );
// Menu Help: // Menu Help:
wxMenu* helpMenu = new wxMenu; wxMenu* helpMenu = new wxMenu;
@ -129,7 +113,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
KiBitmap( about_xpm ) ); KiBitmap( about_xpm ) );
// Create the menubar and append all submenus // Create the menubar and append all submenus
menuBar->Append( filesMenu, _( "&Save" ) ); menuBar->Append( filesMenu, _( "&File" ) );
menuBar->Append( preferencesMenu, _( "&Preferences" ) ); menuBar->Append( preferencesMenu, _( "&Preferences" ) );
menuBar->Append( helpMenu, _( "&Help" ) ); menuBar->Append( helpMenu, _( "&Help" ) );

View File

@ -34,13 +34,11 @@
#include <macros.h> #include <macros.h>
#include <lib_id.h> #include <lib_id.h>
#include <fp_lib_table.h> #include <fp_lib_table.h>
#include <reporter.h>
#include <html_messagebox.h> #include <html_messagebox.h>
#include <cvpcb.h> #include <cvpcb.h>
#include <cvpcb_mainframe.h> #include <cvpcb_mainframe.h>
#include <listboxes.h> #include <listboxes.h>
#include <wildcards_and_files_ext.h>
#include <fp_conflict_assignment_selector.h> #include <fp_conflict_assignment_selector.h>
@ -97,9 +95,6 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName, int aIndex )
if( component == NULL ) if( component == NULL )
return; return;
// Check to see if the component has already a footprint set.
bool hasFootprint = !component->GetFPID().empty();
LIB_ID fpid; LIB_ID fpid;
if( !aFootprintName.IsEmpty() ) if( !aFootprintName.IsEmpty() )
@ -117,12 +112,6 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName, int aIndex )
GetChars( component->GetValue() ), GetChars( component->GetValue() ),
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ); GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
// If the component hasn't had a footprint associated with it
// it now has, so we decrement the count of components without
// a footprint assigned.
if( !hasFootprint )
m_undefinedComponentCnt -= 1;
// Set the new description and deselect the processed component // Set the new description and deselect the processed component
m_compListBox->SetString( aIndex, description ); m_compListBox->SetString( aIndex, description );
@ -196,7 +185,6 @@ bool CVPCB_MAINFRAME::ReadNetListAndFpFiles( const std::string& aNetlist )
BuildLIBRARY_LISTBOX(); BuildLIBRARY_LISTBOX();
m_compListBox->Clear(); m_compListBox->Clear();
m_undefinedComponentCnt = 0;
if( m_netlist.AnyFootprintsLinked() ) if( m_netlist.AnyFootprintsLinked() )
{ {
@ -391,7 +379,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndFpFiles( const std::string& aNetlist )
} }
void CVPCB_MAINFRAME::SaveFootprintAssociation() void CVPCB_MAINFRAME::SaveFootprintAssociation( bool doSaveSchematic )
{ {
STRING_FORMATTER sf; STRING_FORMATTER sf;
@ -399,5 +387,6 @@ void CVPCB_MAINFRAME::SaveFootprintAssociation()
Kiway().ExpressMail( FRAME_SCH, MAIL_BACKANNOTATE_FOOTPRINTS, sf.GetString() ); Kiway().ExpressMail( FRAME_SCH, MAIL_BACKANNOTATE_FOOTPRINTS, sf.GetString() );
SetStatusText( _("Footprint association sent to Eeschema") ); if( doSaveSchematic )
Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_SAVE, std::string( "" ) );
} }

View File

@ -28,12 +28,9 @@
#include <common.h> #include <common.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <cvpcb.h>
#include <cvpcb_mainframe.h> #include <cvpcb_mainframe.h>
#include <cvpcb_id.h> #include <cvpcb_id.h>
#include <common_help_msg.h>
void CVPCB_MAINFRAME::ReCreateHToolbar() void CVPCB_MAINFRAME::ReCreateHToolbar()
{ {
@ -43,9 +40,6 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize, m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT ); KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
m_mainToolBar->AddTool( wxID_SAVE, wxEmptyString, KiScaledBitmap( save_xpm, this ), SAVE_HLP_MSG );
KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( ID_CVPCB_LIB_TABLE_EDIT, wxEmptyString, m_mainToolBar->AddTool( ID_CVPCB_LIB_TABLE_EDIT, wxEmptyString,
KiScaledBitmap( config_xpm, this ), KiScaledBitmap( config_xpm, this ),
_( "Edit footprint library table" ) ); _( "Edit footprint library table" ) );

View File

@ -276,6 +276,17 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
if( importFormat >= 0 ) if( importFormat >= 0 )
importFile( path, importFormat ); importFile( path, importFormat );
} }
break;
case MAIL_SCH_SAVE:
{
wxCommandEvent dummyEvent;
OnSaveProject( dummyEvent );
if( !isAutoSaveRequired() ) // proxy for save completed
Kiway().ExpressMail( FRAME_CVPCB, MAIL_STATUS, _( "Schematic saved" ).ToStdString() );
}
break;
default: default:
; ;

View File

@ -129,6 +129,8 @@ class EDA_BASE_FRAME : public wxFrame
*/ */
void windowClosing( wxCloseEvent& event ); void windowClosing( wxCloseEvent& event );
wxWindow* findQuasiModalDialog();
/** /**
* Removes border from wxAui panes. * Removes border from wxAui panes.
*/ */

View File

@ -37,15 +37,19 @@
enum MAIL_T enum MAIL_T
{ {
MAIL_CROSS_PROBE, ///< PCB<->SCH, CVPCB->SCH cross-probing. MAIL_CROSS_PROBE, ///< PCB<->SCH, CVPCB->SCH cross-probing.
MAIL_BACKANNOTATE_FOOTPRINTS, ///< CVPCB->SCH footprint stuffing at cvpcb termination MAIL_BACKANNOTATE_FOOTPRINTS, ///< CVPCB->SCH footprint stuffing
MAIL_EESCHEMA_NETLIST, ///< EESCHEMA->CVPCB netlist immediately after launching CVPCB MAIL_SCH_SAVE, ///< CVPCB->SCH save the schematic
MAIL_SCH_PCB_UPDATE, ///< Sch->PCB forward update MAIL_EESCHEMA_NETLIST, ///< SCH->CVPCB netlist immediately after launching CVPCB
MAIL_SCH_PCB_UPDATE, ///< SCH->PCB forward update
MAIL_IMPORT_FILE, ///< Import a different format file MAIL_IMPORT_FILE, ///< Import a different format file
///< Sch->PCB forward update, requests SCH to re-generate netlist and send it to PCB ///< Sch->PCB forward update, requests SCH to re-generate netlist and send it to PCB
///< via another mail (kind of bootstrap) ///< via another mail (kind of bootstrap)
MAIL_SCH_PCB_UPDATE_REQUEST, MAIL_SCH_PCB_UPDATE_REQUEST,
MAIL_SCH_REFRESH ///< The the schematic editor to refresh the display. MAIL_SCH_REFRESH, ///< The the schematic editor to refresh the display.
///< General-puspose messages
MAIL_STATUS
}; };
#endif // MAIL_TYPE_H_ #endif // MAIL_TYPE_H_