diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index 21d100b9c5..47a5dc54be 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -537,13 +537,12 @@ void MoveMarkedItems( MODULE* module, wxPoint offset ) */ void DeleteMarkedItems( MODULE* module ) { - BOARD_ITEM* next_item; - D_PAD* next_pad; - BOARD* board = module->GetBoard(); - if( module == NULL ) return; + D_PAD* next_pad; + BOARD* board = module->GetBoard(); + for( D_PAD* pad = module->Pads(); pad; pad = next_pad ) { next_pad = pad->Next(); @@ -557,6 +556,8 @@ void DeleteMarkedItems( MODULE* module ) pad->DeleteStructure(); } + BOARD_ITEM* next_item; + for( BOARD_ITEM* item = module->GraphicalItems(); item; item = next_item ) { next_item = item->Next(); diff --git a/pcbnew/dialogs/dialog_select_pretty_lib.cpp b/pcbnew/dialogs/dialog_select_pretty_lib.cpp index 0c330cd30c..4cd9ad05fd 100644 --- a/pcbnew/dialogs/dialog_select_pretty_lib.cpp +++ b/pcbnew/dialogs/dialog_select_pretty_lib.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors. * * * This program is free software; you can redistribute it and/or @@ -30,6 +30,7 @@ * footprints are .kicad_mod files inside this folder */ +#include #include #include @@ -52,3 +53,22 @@ void DIALOG_SELECT_PRETTY_LIB::OnSelectFolder( wxFileDirPickerEvent& event ) event.Skip(); } + + +const wxString DIALOG_SELECT_PRETTY_LIB::GetFullPrettyLibName() +{ + wxFileName fn = m_libName->GetValue(); + + if( !fn.IsAbsolute() ) + fn.MakeAbsolute( m_dirCtrl->GetPath() ); + + // Enforce the extension: + fn.SetExt( KiCadFootprintLibPathExtension ); + + return fn.GetFullPath(); +} + +void DIALOG_SELECT_PRETTY_LIB::OnOKButton( wxCommandEvent& event ) +{ + event.Skip(); +} diff --git a/pcbnew/dialogs/dialog_select_pretty_lib.h b/pcbnew/dialogs/dialog_select_pretty_lib.h index 7beb20e39e..0188c19587 100644 --- a/pcbnew/dialogs/dialog_select_pretty_lib.h +++ b/pcbnew/dialogs/dialog_select_pretty_lib.h @@ -43,10 +43,15 @@ public: const wxString& aDefaultPath ); ~DIALOG_SELECT_PRETTY_LIB() {}; - const wxString GetPath() { return m_libName->GetValue(); } + /** + * @return the full .pretty lib name, which is an absolute path + *, ending wityh ".pretty" + */ + const wxString GetFullPrettyLibName(); private: virtual void OnSelectFolder( wxFileDirPickerEvent& event ); + virtual void OnOKButton( wxCommandEvent& event ); }; diff --git a/pcbnew/dialogs/dialog_select_pretty_lib_base.cpp b/pcbnew/dialogs/dialog_select_pretty_lib_base.cpp index 78dcbd9137..17b70a1eb0 100644 --- a/pcbnew/dialogs/dialog_select_pretty_lib_base.cpp +++ b/pcbnew/dialogs/dialog_select_pretty_lib_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Jun 17 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -22,17 +22,21 @@ DIALOG_SELECT_PRETTY_LIB_BASE::DIALOG_SELECT_PRETTY_LIB_BASE( wxWindow* parent, bSizerMain->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + m_staticText3 = new wxStaticText( this, wxID_ANY, _("Path base:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText3->Wrap( -1 ); + bSizerMain->Add( m_staticText3, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + m_dirCtrl = new wxDirPickerCtrl( this, wxID_ANY, wxEmptyString, _("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE ); - bSizerMain->Add( m_dirCtrl, 0, wxALL|wxEXPAND, 5 ); + bSizerMain->Add( m_dirCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_SizerNewLibName = new wxBoxSizer( wxVERTICAL ); - m_staticTextDirname = new wxStaticText( this, wxID_ANY, _("Library Path (.pretty will be appended to folder)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextDirname = new wxStaticText( this, wxID_ANY, _("Library folder (.pretty will be added to name, if missing)"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextDirname->Wrap( -1 ); m_SizerNewLibName->Add( m_staticTextDirname, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_libName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_SizerNewLibName->Add( m_libName, 0, wxALL|wxEXPAND, 5 ); + m_SizerNewLibName->Add( m_libName, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bSizerMain->Add( m_SizerNewLibName, 0, wxEXPAND, 5 ); @@ -58,11 +62,13 @@ DIALOG_SELECT_PRETTY_LIB_BASE::DIALOG_SELECT_PRETTY_LIB_BASE( wxWindow* parent, // Connect Events m_dirCtrl->Connect( wxEVT_COMMAND_DIRPICKER_CHANGED, wxFileDirPickerEventHandler( DIALOG_SELECT_PRETTY_LIB_BASE::OnSelectFolder ), NULL, this ); + m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_PRETTY_LIB_BASE::OnOKButton ), NULL, this ); } DIALOG_SELECT_PRETTY_LIB_BASE::~DIALOG_SELECT_PRETTY_LIB_BASE() { // Disconnect Events m_dirCtrl->Disconnect( wxEVT_COMMAND_DIRPICKER_CHANGED, wxFileDirPickerEventHandler( DIALOG_SELECT_PRETTY_LIB_BASE::OnSelectFolder ), NULL, this ); + m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_PRETTY_LIB_BASE::OnOKButton ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_select_pretty_lib_base.fbp b/pcbnew/dialogs/dialog_select_pretty_lib_base.fbp index eee16410c6..34d665b9e0 100644 --- a/pcbnew/dialogs/dialog_select_pretty_lib_base.fbp +++ b/pcbnew/dialogs/dialog_select_pretty_lib_base.fbp @@ -178,7 +178,90 @@ 5 - wxALL|wxEXPAND + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Path base: + + 0 + + + 0 + + 1 + m_staticText3 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -305,7 +388,7 @@ 0 0 wxID_ANY - Library Path (.pretty will be appended to folder) + Library folder (.pretty will be added to name, if missing) 0 @@ -358,7 +441,7 @@ 5 - wxALL|wxEXPAND + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -551,7 +634,7 @@ - + OnOKButton diff --git a/pcbnew/dialogs/dialog_select_pretty_lib_base.h b/pcbnew/dialogs/dialog_select_pretty_lib_base.h index 972825d7c3..9c5893db1d 100644 --- a/pcbnew/dialogs/dialog_select_pretty_lib_base.h +++ b/pcbnew/dialogs/dialog_select_pretty_lib_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Jun 17 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -39,6 +39,7 @@ class DIALOG_SELECT_PRETTY_LIB_BASE : public DIALOG_SHIM protected: wxStaticText* m_staticText; + wxStaticText* m_staticText3; wxDirPickerCtrl* m_dirCtrl; wxBoxSizer* m_SizerNewLibName; wxStaticText* m_staticTextDirname; @@ -50,6 +51,7 @@ class DIALOG_SELECT_PRETTY_LIB_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnSelectFolder( wxFileDirPickerEvent& event ) { event.Skip(); } + virtual void OnOKButton( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 6f7ed87d5d..362c340f40 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -76,7 +76,6 @@ #define FMT_MOD_DELETED _( "Footprint %s deleted from library '%s'" ) #define FMT_MOD_CREATE _( "New Footprint" ) -#define FMT_NO_MODULES _( "No footprints to archive!" ) #define FMT_MOD_EXISTS _( "Footprint %s already exists in library '%s'" ) #define FMT_NO_REF_ABORTED _( "No footprint name defined." ) #define FMT_SELECT_LIB _( "Select Library" ) @@ -387,23 +386,15 @@ bool FOOTPRINT_EDIT_FRAME::SaveCurrentModule( const wxString* aLibPath ) wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary() { - wxFileName fn; - wxConfigBase* config = Kiface().KifaceSettings(); - - if( config ) - { - wxString path; - config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path ); - fn.SetPath( path ); - } - // Kicad cannot write legacy format libraries, only .pretty new format // because the legacy format cannot handle current features. - // The lib is actually a directory + // The footprint library is actually a directory wxString wildcard = wxGetTranslation( KiCadFootprintLibPathWildcard ); - // prompt user for libPath -// wxDirDialog dlg( this, FMT_CREATE_LIB, fn.GetPath(), wxDD_DEFAULT_STYLE ); + // prompt user for footprint library name, ending by ".pretty" + // Because there are constraints for the directory name to create, + // (the name should have the extension ".pretty", and the folder cannot be inside + // a footprint library), we do not use the standard wxDirDialog. wxString initialPath = wxPathOnly( Prj().GetProjectFullName() ); DIALOG_SELECT_PRETTY_LIB dlg( this, initialPath ); @@ -411,21 +402,11 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary() if( dlg.ShowModal() != wxID_OK ) return wxEmptyString; - fn = dlg.GetPath(); + wxString libPath = dlg.GetFullPrettyLibName(); - if( config ) // Save file path without filename, save user typing. - { - config->Write( EXPORT_IMPORT_LASTPATH_KEY, fn.GetPath() ); - } - - // wildcard's filter index has legacy in position 0. + // We can save fp libs only using IO_MGR::KICAD format (.pretty libraries) IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD; - // wxFileDialog does not supply nor enforce the file extension, add it here. - fn.SetExt( KiCadFootprintLibPathExtension ); - - wxString libPath = fn.GetFullPath(); - try { PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) ); @@ -537,7 +518,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aNewModulesOnly ) { if( GetBoard()->m_Modules == NULL ) { - DisplayInfoMessage( this, FMT_NO_MODULES ); + DisplayInfoMessage( this, _( "No footprints to archive!" ) ); return; }