From 9aa4fb6955b1262944a2a6b84f3fa9288e3dbb2b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 1 Jan 2015 16:46:11 +0100 Subject: [PATCH] Cvpcb: force project name in stand alone mode, to allow access to project fp lib table. In project mode: disable the read netlist option (the netlist is read when Cvpcb is started by eeschema) Dialog fp lib table editor: now shows the table full filenames, to help users. --- cvpcb/cvframe.cpp | 44 ++- cvpcb/menubar.cpp | 53 ++- cvpcb/tool_cvpcb.cpp | 9 +- pcbnew/dialogs/dialog_fp_lib_table.cpp | 4 + pcbnew/dialogs/dialog_fp_lib_table_base.cpp | 32 ++ pcbnew/dialogs/dialog_fp_lib_table_base.fbp | 368 ++++++++++++++++++++ pcbnew/dialogs/dialog_fp_lib_table_base.h | 13 +- 7 files changed, 475 insertions(+), 48 deletions(-) diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 3fde5b30ac..52ea015f58 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -438,25 +438,39 @@ void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event ) bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector& aFileSet, int aCtl ) { - if( aFileSet.size() == 1 ) + if( aFileSet.size() != 1 ) // Unexpected comand + return false; + + m_NetlistFileName = aFileSet[0]; + ReadNetListAndLinkFiles(); + + UpdateTitle(); + + // Resize the components list box. This is needed in case the + // contents have shrunk compared to the previous netlist. + m_compListBox->UpdateWidth(); + + // OSX need it since some objects are "rebuild" just make aware AUI + // Fixes #1258081 + m_auimgr.Update(); + + if( Kiface().IsSingle() ) { - m_NetlistFileName = aFileSet[0]; - ReadNetListAndLinkFiles(); + // PROJECT::SetProjectFullName() is an impactful function. It should only be + // called under carefully considered circumstances. - UpdateTitle(); - - // Resize the components list box. This is needed in case the - // contents have shrunk compared to the previous netlist. - m_compListBox->UpdateWidth(); - - // OSX need it since some objects are "rebuild" just make aware AUI - // Fixes #1258081 - m_auimgr.Update(); - - return true; + // The calling code should know not to ask me here to change projects unless + // it knows what consequences that will have on other KIFACEs running and using + // this same PROJECT. It can be very harmful if that calling code is stupid. + // + // In Cvpcb, we call SetProjectFullName only in Single mode, i.e. it is not + // called from a project + wxFileName pro = m_NetlistFileName; + pro.SetExt( ProjectFileExtension ); + Prj().SetProjectFullName( pro.GetFullPath() ); } - return false; + return true; } diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index ff9e7fa390..66b6b9a16c 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -64,50 +64,49 @@ void CVPCB_MAINFRAME::ReCreateMenuBar() // Menu File: wxMenu* filesMenu = new wxMenu; - // Open - AddMenuItem( filesMenu, - ID_LOAD_PROJECT, - _( "&Open Netlist" ), LOAD_FILE_HELP, KiBitmap( open_document_xpm ) ); + // Open files can be used only outside a project, because opening a netlist + // which is not the project netlist is a non sense. + if( Kiface().IsSingle() ) + { + AddMenuItem( filesMenu, ID_LOAD_PROJECT, + _( "&Open Netlist" ), LOAD_FILE_HELP, KiBitmap( open_document_xpm ) ); - // Open Recent submenu - static wxMenu* openRecentMenu; + // Open Recent submenu + static wxMenu* openRecentMenu; - // Add this menu to list menu managed by m_fileHistory - // (the file history will be updated when adding/removing files in history - if( openRecentMenu ) - Kiface().GetFileHistory().RemoveMenu( openRecentMenu ); + // Add this menu to list menu managed by m_fileHistory + // (the file history will be updated when adding/removing files in history + if( openRecentMenu ) + Kiface().GetFileHistory().RemoveMenu( openRecentMenu ); - openRecentMenu = new wxMenu(); + openRecentMenu = new wxMenu(); - Kiface().GetFileHistory().UseMenu( openRecentMenu ); - Kiface().GetFileHistory().AddFilesToMenu(); + Kiface().GetFileHistory().UseMenu( openRecentMenu ); + Kiface().GetFileHistory().AddFilesToMenu(); - AddMenuItem( filesMenu, openRecentMenu, -1, - _( "Open &Recent" ), - _( "Open recent netlist" ), - KiBitmap( open_project_xpm ) ); + AddMenuItem( filesMenu, openRecentMenu, -1, + _( "Open &Recent" ), + _( "Open recent netlist" ), + KiBitmap( open_project_xpm ) ); - // Separator - filesMenu->AppendSeparator(); + // Separator + filesMenu->AppendSeparator(); + } // Save the .cmp file - AddMenuItem( filesMenu, - wxID_SAVE, + AddMenuItem( filesMenu, wxID_SAVE, _( "&Save\tCtrl+S" ), SAVE_HLP_MSG, KiBitmap( save_xpm ) ); // Save as the .cmp file - AddMenuItem( filesMenu, - wxID_SAVEAS, + AddMenuItem( filesMenu, wxID_SAVEAS, _( "Save &As...\tCtrl+Shift+S" ), SAVE_AS_HLP_MSG, KiBitmap( save_xpm ) ); // Separator filesMenu->AppendSeparator(); // Quit - AddMenuItem( filesMenu, - wxID_EXIT, - _( "&Quit" ), - _( "Quit CvPcb" ), + AddMenuItem( filesMenu, wxID_EXIT, + _( "&Quit" ), _( "Quit CvPcb" ), KiBitmap( exit_xpm ) ); // Menu Preferences: diff --git a/cvpcb/tool_cvpcb.cpp b/cvpcb/tool_cvpcb.cpp index 451e7b83ee..061601f7a8 100644 --- a/cvpcb/tool_cvpcb.cpp +++ b/cvpcb/tool_cvpcb.cpp @@ -49,8 +49,13 @@ void CVPCB_MAINFRAME::ReCreateHToolbar() m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT ); - m_mainToolBar->AddTool( ID_CVPCB_READ_INPUT_NETLIST, wxEmptyString, - KiBitmap( open_document_xpm ), LOAD_FILE_HELP ); + // Open files can be used only outside a project, because opening a netlist + // which is not the project netlist is a non sense. + if( Kiface().IsSingle() ) + { + m_mainToolBar->AddTool( ID_CVPCB_READ_INPUT_NETLIST, wxEmptyString, + KiBitmap( open_document_xpm ), LOAD_FILE_HELP ); + } m_mainToolBar->AddTool( wxID_SAVE, wxEmptyString, KiBitmap( save_xpm ), SAVE_HLP_MSG ); diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/dialog_fp_lib_table.cpp index a24f6e448c..2fca34e02b 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table.cpp @@ -295,6 +295,10 @@ public: m_global( aGlobal ), m_project( aProject ) { + // For user info, shows the table filenames: + m_PrjTableFilename->SetLabel( Prj().FootprintLibTblName() ); + m_GblTableFilename->SetLabel( FP_LIB_TABLE::GetGlobalTableFileName() ); + // wxGrid only supports user owned tables if they exist past end of ~wxGrid(), // so make it a grid owned table. m_global_grid->SetTable( new FP_TBL_MODEL( *aGlobal ), true ); diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.cpp b/pcbnew/dialogs/dialog_fp_lib_table_base.cpp index d9daaaffb9..7aa81c4a27 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.cpp @@ -24,6 +24,22 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID wxBoxSizer* m_global_sizer; m_global_sizer = new wxBoxSizer( wxVERTICAL ); + wxFlexGridSizer* fgSizer1; + fgSizer1 = new wxFlexGridSizer( 1, 2, 0, 0 ); + fgSizer1->SetFlexibleDirection( wxBOTH ); + fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticText3 = new wxStaticText( m_global_panel, wxID_ANY, _("Table:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText3->Wrap( -1 ); + fgSizer1->Add( m_staticText3, 0, wxRIGHT|wxLEFT, 5 ); + + m_GblTableFilename = new wxStaticText( m_global_panel, wxID_ANY, _("Table Name"), wxDefaultPosition, wxDefaultSize, 0 ); + m_GblTableFilename->Wrap( -1 ); + fgSizer1->Add( m_GblTableFilename, 0, wxRIGHT|wxLEFT, 5 ); + + + m_global_sizer->Add( fgSizer1, 0, wxEXPAND, 5 ); + m_global_grid = new wxGrid( m_global_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid @@ -60,6 +76,22 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID wxBoxSizer* m_project_sizer; m_project_sizer = new wxBoxSizer( wxVERTICAL ); + wxFlexGridSizer* fgSizer2; + fgSizer2 = new wxFlexGridSizer( 1, 2, 0, 0 ); + fgSizer2->SetFlexibleDirection( wxBOTH ); + fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticText4 = new wxStaticText( m_project_panel, wxID_ANY, _("Table:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText4->Wrap( -1 ); + fgSizer2->Add( m_staticText4, 0, wxRIGHT|wxLEFT, 5 ); + + m_PrjTableFilename = new wxStaticText( m_project_panel, wxID_ANY, _("Table Name"), wxDefaultPosition, wxDefaultSize, 0 ); + m_PrjTableFilename->Wrap( -1 ); + fgSizer2->Add( m_PrjTableFilename, 0, wxRIGHT|wxLEFT, 5 ); + + + m_project_sizer->Add( fgSizer2, 0, wxEXPAND, 5 ); + m_project_grid = new wxGrid( m_project_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.fbp b/pcbnew/dialogs/dialog_fp_lib_table_base.fbp index 7d3f2fdef8..e73011552a 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.fbp +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.fbp @@ -277,6 +277,190 @@ m_global_sizer wxVERTICAL none + + 5 + wxEXPAND + 0 + + 2 + wxBOTH + + + 0 + + fgSizer1 + wxFLEX_GROWMODE_SPECIFIED + none + 1 + 0 + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Table: + + 0 + + + 0 + + 1 + m_staticText3 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Table Name + + 0 + + + 0 + + 1 + m_GblTableFilename + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALL|wxEXPAND @@ -506,6 +690,190 @@ m_project_sizer wxVERTICAL none + + 5 + wxEXPAND + 0 + + 2 + wxBOTH + + + 0 + + fgSizer2 + wxFLEX_GROWMODE_SPECIFIED + none + 1 + 0 + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Table: + + 0 + + + 0 + + 1 + m_staticText4 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Table Name + + 0 + + + 0 + + 1 + m_PrjTableFilename + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALL|wxEXPAND diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.h b/pcbnew/dialogs/dialog_fp_lib_table_base.h index 50ea6afa55..3f1a005670 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.h +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.h @@ -14,13 +14,14 @@ class DIALOG_SHIM; #include "dialog_shim.h" +#include +#include +#include +#include #include #include -#include -#include -#include -#include #include +#include #include #include #include @@ -43,8 +44,12 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM protected: wxAuiNotebook* m_auinotebook; wxPanel* m_global_panel; + wxStaticText* m_staticText3; + wxStaticText* m_GblTableFilename; wxGrid* m_global_grid; wxPanel* m_project_panel; + wxStaticText* m_staticText4; + wxStaticText* m_PrjTableFilename; wxGrid* m_project_grid; wxButton* m_append_button; wxButton* m_buttonWizard;