Remove active library concept from footprint editor.
Also bring the menu system and toolbar in line with Pcbnew, eeschema, and the symbol library editor, which includes moving to a standard Save As paradigm for renaming/moving items. Fixes: lp:1748474 * https://bugs.launchpad.net/kicad/+bug/1748474 Fixes: lp:1778202 * https://bugs.launchpad.net/kicad/+bug/1778202
This commit is contained in:
parent
18d2f95fd5
commit
0cca1c6721
|
@ -61,7 +61,7 @@ void LIB_EDIT_FRAME::DisplayLibInfos()
|
|||
wxString title = _( "Symbol Library Editor" );
|
||||
|
||||
if( GetCurPart() )
|
||||
title += wxT( " - " ) + GetCurPart()->GetLibId().Format();
|
||||
title += wxT( " \u2014 " ) + GetCurPart()->GetLibId().Format();
|
||||
|
||||
SetTitle( title );
|
||||
}
|
||||
|
|
|
@ -53,20 +53,21 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
|||
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_NEW_LIBRARY,
|
||||
_( "&New Library..." ),
|
||||
_( "New Library..." ),
|
||||
_( "Creates an empty library" ),
|
||||
KiBitmap( new_library_xpm ) );
|
||||
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_ADD_LIBRARY,
|
||||
_( "Add &Library..." ),
|
||||
_( "Add Library..." ),
|
||||
_( "Adds a previously created library" ),
|
||||
KiBitmap( add_library_xpm ) );
|
||||
|
||||
text = AddHotkeyName( _( "&New Symbol..." ), m_hotkeysDescrList, HK_NEW );
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_NEW_PART,
|
||||
_( "New S&ymbol..." ),
|
||||
_( "Create a new empty symbol" ),
|
||||
text,
|
||||
_( "Create a new symbol" ),
|
||||
KiBitmap( new_component_xpm ) );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
@ -87,7 +88,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
|||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_SAVE_PART_AS,
|
||||
_( "Save Symbol As..." ),
|
||||
_( "Saves a copy of the current symbol" ),
|
||||
_( "Save the current symbol to a new name and/or new library" ),
|
||||
KiBitmap( save_part_xpm ) );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
|
|
@ -112,10 +112,6 @@ bool PANEL_MODEDIT_DEFAULTS::TransferDataToWindow()
|
|||
attr->SetRenderer( new wxGridCellBoolRenderer() );
|
||||
attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
|
||||
attr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
|
||||
|
||||
// 6.0 TODO: flag the Italic Text column for now
|
||||
attr->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INFOBK ) );
|
||||
|
||||
m_grid->SetAttr( i, COL_TEXT_ITALIC, attr );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,11 +88,10 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
|
|||
EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom )
|
||||
EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectGrid )
|
||||
|
||||
EVT_TOOL( ID_MODEDIT_SELECT_CURRENT_LIB, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
|
||||
EVT_TOOL( ID_MODEDIT_SAVE_LIBRARY_AS, FOOTPRINT_EDIT_FRAME::OnSaveLibraryAs )
|
||||
|
||||
EVT_TOOL( ID_MODEDIT_SAVE_LIBMODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_MODEDIT_SAVE_LIBMODULE_AS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_OPEN_MODULE_VIEWER, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
|
||||
EVT_TOOL( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
|
@ -100,8 +99,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
|
|||
EVT_TOOL( ID_MODEDIT_NEW_MODULE_FROM_WIZARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_MODEDIT_IMPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
|
||||
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_MODEDIT_CREATE_NEW_LIB, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_MODEDIT_SHEET_SET, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_GEN_IMPORT_DXF_FILE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( wxID_PRINT, FOOTPRINT_EDIT_FRAME::ToPrinter )
|
||||
|
@ -172,12 +170,10 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
|
|||
EVT_MENU( ID_MENU_CANVAS_OPENGL, PCB_BASE_FRAME::OnSwitchCanvas )
|
||||
|
||||
// UI update events.
|
||||
EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateLibSelected )
|
||||
EVT_UPDATE_UI( ID_MODEDIT_SELECT_CURRENT_LIB, FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib )
|
||||
EVT_UPDATE_UI( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
|
||||
EVT_UPDATE_UI( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
|
||||
FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
|
||||
EVT_UPDATE_UI( ID_MODEDIT_SAVE_LIBMODULE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
|
||||
EVT_UPDATE_UI( ID_MODEDIT_SAVE_LIBMODULE_AS, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
|
||||
EVT_UPDATE_UI( ID_MODEDIT_SAVE_LIBRARY_AS, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
|
||||
EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
|
||||
FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard )
|
||||
EVT_UPDATE_UI( ID_MODEDIT_INSERT_MODULE_IN_BOARD,
|
||||
|
@ -215,9 +211,6 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
|
||||
SetIcon( icon );
|
||||
|
||||
// Show a title (frame title + footprint name):
|
||||
updateTitle();
|
||||
|
||||
// Create GAL canvas
|
||||
bool boardEditorWasRunning = Kiway().Player( FRAME_PCB, false ) != nullptr;
|
||||
PCB_BASE_FRAME* pcbFrame = static_cast<PCB_BASE_FRAME*>( Kiway().Player( FRAME_PCB, true ) );
|
||||
|
@ -343,6 +336,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
pcbFrame->Destroy();
|
||||
|
||||
m_auimgr.Update();
|
||||
updateTitle();
|
||||
|
||||
Raise(); // On some window managers, this is needed
|
||||
Show( true );
|
||||
|
@ -519,7 +513,7 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
break;
|
||||
|
||||
case wxID_YES:
|
||||
if( !SaveFootprintInLibrary( GetCurrentLib(), GetBoard()->m_Modules ) )
|
||||
if( !SaveFootprint( GetBoard()->m_Modules ) )
|
||||
{
|
||||
Event.Veto();
|
||||
return;
|
||||
|
@ -584,14 +578,6 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::OnUpdateLibSelected( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
bool enable = getLibPath() != wxEmptyString;
|
||||
aEvent.Enable( enable );
|
||||
GetMenuBar()->Enable( ID_MODEDIT_SAVE_LIBRARY_AS, enable );
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
aEvent.Enable( GetBoard()->m_Modules != NULL );
|
||||
|
@ -659,14 +645,6 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent
|
|||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
|
||||
|
||||
aEvent.Enable( fptbl && !fptbl->IsEmpty() );
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
|
||||
{
|
||||
bool forceRecreateIfNotOwner = true;
|
||||
|
@ -718,42 +696,31 @@ void FOOTPRINT_EDIT_FRAME::OnModify()
|
|||
|
||||
void FOOTPRINT_EDIT_FRAME::updateTitle()
|
||||
{
|
||||
wxString nickname = GetCurrentLib();
|
||||
wxString nickname_display = _( "no active library" );
|
||||
bool writable = true;
|
||||
wxString title = _( "Footprint Editor" );
|
||||
MODULE* module = GetBoard()->m_Modules;
|
||||
|
||||
if( !!nickname )
|
||||
if( module )
|
||||
{
|
||||
try
|
||||
bool writable = true;
|
||||
const LIB_ID& fpid = module->GetFPID();
|
||||
wxString nickname = fpid.GetLibNickname();
|
||||
|
||||
if( !nickname.IsEmpty() )
|
||||
{
|
||||
writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname );
|
||||
|
||||
nickname_display = nickname;
|
||||
}
|
||||
catch( const IO_ERROR& )
|
||||
{
|
||||
// user may be bewildered as to why after selecting a library it is not showing up
|
||||
// in the title, we could show an error message, but that should have been done at time
|
||||
// of libary selection UI.
|
||||
try
|
||||
{
|
||||
writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname );
|
||||
}
|
||||
catch( const IO_ERROR& )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
title += wxString::Format( wxT( " \u2014 %s %s" ),
|
||||
FROM_UTF8( module->GetFPID().Format().c_str() ),
|
||||
writable ? wxString( wxEmptyString ) : _( "[Read Only]" ) );
|
||||
}
|
||||
|
||||
wxString path_display;
|
||||
if( nickname.size() )
|
||||
{
|
||||
FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
|
||||
const FP_LIB_TABLE_ROW* row = libtable->FindRow( nickname );
|
||||
|
||||
if( row )
|
||||
path_display = L" \u2014 " + row->GetFullURI( true );
|
||||
}
|
||||
|
||||
wxString title;
|
||||
title.Printf( _( "Footprint Editor" ) + wxT( " \u2014 %s%s%s" ),
|
||||
nickname_display,
|
||||
writable ? wxString( wxEmptyString ) : _( " [Read Only]" ),
|
||||
path_display );
|
||||
|
||||
SetTitle( title );
|
||||
}
|
||||
|
||||
|
@ -765,6 +732,7 @@ void FOOTPRINT_EDIT_FRAME::updateView()
|
|||
dp->DisplayBoard( GetBoard() );
|
||||
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
||||
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -182,12 +182,10 @@ public:
|
|||
void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent );
|
||||
|
||||
void OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateLibSelected( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateSelectCurrentLib( wxUpdateUIEvent& aEvent );
|
||||
|
||||
///> @copydoc PCB_BASE_EDIT_FRAME::OnEditItemRequest()
|
||||
void OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) override;
|
||||
|
@ -199,13 +197,13 @@ public:
|
|||
void LoadModuleFromBoard( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Function SaveFootprintInLibrary
|
||||
* Function SaveFootprint
|
||||
* Save in an existing library a given footprint
|
||||
* @param activeLibrary = default library if the footprint has none
|
||||
* @param aModule = the given footprint
|
||||
* @return : true if OK, false if abort
|
||||
*/
|
||||
bool SaveFootprintInLibrary( wxString activeLibrary, MODULE* aModule );
|
||||
bool SaveFootprint( MODULE* aModule );
|
||||
bool SaveFootprintAs( MODULE* aModule );
|
||||
|
||||
/**
|
||||
* Virtual Function OnModify()
|
||||
|
@ -388,10 +386,10 @@ public:
|
|||
void PushPadProperties( D_PAD* aPad );
|
||||
|
||||
/**
|
||||
* Function DeleteModuleFromCurrentLibrary
|
||||
* Function DeleteModuleFromLibrary
|
||||
* prompts user for footprint name, then deletes it from current library.
|
||||
*/
|
||||
bool DeleteModuleFromCurrentLibrary();
|
||||
bool DeleteModuleFromLibrary();
|
||||
|
||||
/**
|
||||
* Function IsElementVisible
|
||||
|
|
|
@ -252,18 +252,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
Close( true );
|
||||
break;
|
||||
|
||||
case ID_MODEDIT_SELECT_CURRENT_LIB:
|
||||
{
|
||||
wxString library = SelectLibrary( GetCurrentLib() );
|
||||
|
||||
if( library.size() )
|
||||
{
|
||||
Prj().SetRString( PROJECT::PCB_LIB_NICKNAME, library );
|
||||
updateTitle();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_OPEN_MODULE_VIEWER:
|
||||
{
|
||||
FOOTPRINT_VIEWER_FRAME* viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, false );
|
||||
|
@ -291,7 +279,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_MODEDIT_DELETE_PART:
|
||||
DeleteModuleFromCurrentLibrary();
|
||||
DeleteModuleFromLibrary();
|
||||
break;
|
||||
|
||||
case ID_MODEDIT_NEW_MODULE:
|
||||
|
@ -385,7 +373,23 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
case ID_MODEDIT_SAVE_LIBMODULE:
|
||||
if( GetBoard()->m_Modules )
|
||||
{
|
||||
SaveFootprintInLibrary( GetCurrentLib(), GetBoard()->m_Modules );
|
||||
SaveFootprint( GetBoard()->m_Modules );
|
||||
|
||||
m_toolManager->GetView()->Update( GetBoard()->m_Modules );
|
||||
|
||||
if( IsGalCanvasActive() && GetGalCanvas() )
|
||||
GetGalCanvas()->ForceRefresh();
|
||||
else
|
||||
GetCanvas()->Refresh();
|
||||
|
||||
GetScreen()->ClrModify();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_MODEDIT_SAVE_LIBMODULE_AS:
|
||||
if( GetBoard()->m_Modules )
|
||||
{
|
||||
SaveFootprintAs( GetBoard()->m_Modules );
|
||||
|
||||
m_toolManager->GetView()->Update( GetBoard()->m_Modules );
|
||||
|
||||
|
@ -510,14 +514,8 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
Export_Module( GetBoard()->m_Modules );
|
||||
break;
|
||||
|
||||
case ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART:
|
||||
if( GetBoard()->m_Modules )
|
||||
{
|
||||
// CreateModuleLibrary() only creates a new library, does not save footprint
|
||||
wxString libPath = CreateNewLibrary();
|
||||
if( libPath.size() )
|
||||
SaveCurrentModule( &libPath );
|
||||
}
|
||||
case ID_MODEDIT_CREATE_NEW_LIB:
|
||||
CreateNewLibrary();
|
||||
break;
|
||||
|
||||
case ID_MODEDIT_SHEET_SET:
|
||||
|
@ -538,7 +536,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
}
|
||||
|
||||
MODULE* module = LoadModuleFromLibrary( GetCurrentLib() );
|
||||
MODULE* module = LoadModuleFromLibrary( wxEmptyString );
|
||||
|
||||
if( !module )
|
||||
break;
|
||||
|
|
|
@ -533,16 +533,25 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary(const wxString& aLibName )
|
|||
}
|
||||
|
||||
|
||||
bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
|
||||
bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary()
|
||||
{
|
||||
wxString nickname = GetCurrentLib();
|
||||
LIB_ID fpid;
|
||||
wxString fpid_txt = PCB_BASE_FRAME::SelectFootprint( this, wxEmptyString, wxEmptyString,
|
||||
wxEmptyString, Prj().PcbFootprintLibs() );
|
||||
|
||||
fpid.Parse( fpid_txt, LIB_ID::ID_PCB );
|
||||
|
||||
if( !fpid.IsValid() )
|
||||
return false;
|
||||
|
||||
wxString nickname = fpid.GetLibNickname();
|
||||
wxString fpname = fpid.GetLibItemName();
|
||||
|
||||
// Legacy libraries are readable, but modifying legacy format is not allowed
|
||||
// So prompt the user if he try to delete a footprint from a legacy lib
|
||||
wxString libfullname = Prj().PcbFootprintLibs()->FindRow(nickname)->GetFullURI();
|
||||
IO_MGR::PCB_FILE_T piType = IO_MGR::GuessPluginTypeFromLibPath( libfullname );
|
||||
wxString libfullname = Prj().PcbFootprintLibs()->FindRow( nickname )->GetFullURI();
|
||||
|
||||
if( piType == IO_MGR::LEGACY )
|
||||
if( IO_MGR::GuessPluginTypeFromLibPath( libfullname ) == IO_MGR::LEGACY )
|
||||
{
|
||||
DisplayInfoMessage( this, INFO_LEGACY_LIB_WARN_DELETE );
|
||||
return false;
|
||||
|
@ -555,17 +564,6 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
|
|||
return false;
|
||||
}
|
||||
|
||||
LIB_ID fpid;
|
||||
wxString fpid_txt = PCB_BASE_FRAME::SelectFootprint( this, nickname, wxEmptyString,
|
||||
wxEmptyString, Prj().PcbFootprintLibs() );
|
||||
|
||||
fpid.Parse( fpid_txt, LIB_ID::ID_PCB );
|
||||
|
||||
if( !fpid.IsValid() )
|
||||
return false;
|
||||
|
||||
wxString fpname = fpid.GetLibItemName();
|
||||
|
||||
// Confirmation
|
||||
wxString msg = wxString::Format( FMT_OK_DELETE, fpname.GetData(), nickname.GetData() );
|
||||
|
||||
|
@ -678,7 +676,47 @@ public:
|
|||
};
|
||||
|
||||
|
||||
bool FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary( wxString activeLibrary, MODULE* aModule )
|
||||
bool FOOTPRINT_EDIT_FRAME::SaveFootprint( MODULE* aModule )
|
||||
{
|
||||
wxString libraryName = aModule->GetFPID().GetLibNickname();
|
||||
wxString footprintName = aModule->GetFPID().GetLibItemName();
|
||||
|
||||
if( libraryName.IsEmpty() || footprintName.IsEmpty() )
|
||||
return SaveFootprintAs( aModule );
|
||||
|
||||
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
|
||||
|
||||
// Legacy libraries are readable, but modifying legacy format is not allowed
|
||||
// So prompt the user if he try to add/replace a footprint in a legacy lib
|
||||
wxString libfullname = tbl->FindRow( libraryName )->GetFullURI();
|
||||
|
||||
if( IO_MGR::GuessPluginTypeFromLibPath( libfullname ) == IO_MGR::LEGACY )
|
||||
{
|
||||
DisplayInfoMessage( this, INFO_LEGACY_LIB_WARN_EDIT );
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
MODULE* m = tbl->FootprintLoad( libraryName, footprintName );
|
||||
|
||||
delete m;
|
||||
|
||||
LIBRARY_NAME_CLEARER temp( aModule );
|
||||
|
||||
// this always overwrites any existing footprint, but should yell on its
|
||||
// own if the library or footprint is not writable.
|
||||
tbl->FootprintSave( libraryName, aModule );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DisplayError( this, ioe.What() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FOOTPRINT_EDIT_FRAME::SaveFootprintAs( MODULE* aModule )
|
||||
{
|
||||
if( aModule == NULL )
|
||||
return false;
|
||||
|
@ -687,21 +725,10 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary( wxString activeLibrary, MODUL
|
|||
|
||||
SetMsgPanel( aModule );
|
||||
|
||||
// For 6.0 Save should silently save the footprint in its own library.
|
||||
// Save As... should allow a rename and/or reparent to a different library.
|
||||
//
|
||||
// However, for 5.0 we need a more limited intervention. We'll always display
|
||||
// the dialog, but add a Library selection widget that will default to saving
|
||||
// in the footprint's own library but allow switching to the active library
|
||||
// (or even some other library).
|
||||
|
||||
wxString libraryName = aModule->GetFPID().GetLibNickname();
|
||||
wxString footprintName = aModule->GetFPID().GetLibItemName();
|
||||
bool updateValue = ( aModule->GetValue() == footprintName );
|
||||
|
||||
if( libraryName.IsEmpty() )
|
||||
libraryName = activeLibrary;
|
||||
|
||||
wxArrayString headers;
|
||||
std::vector<wxArrayString> itemsToDisplay;
|
||||
std::vector<wxString> nicknames = tbl->GetLogicalLibs();
|
||||
|
|
|
@ -53,18 +53,10 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
|||
// Menu File:
|
||||
wxMenu* fileMenu = new wxMenu;
|
||||
|
||||
// Active library selection
|
||||
AddMenuItem( fileMenu, ID_MODEDIT_SELECT_CURRENT_LIB,
|
||||
_("Set Acti&ve Library..."),
|
||||
_( "Select active library" ),
|
||||
KiBitmap( open_library_xpm ) );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
||||
// New module
|
||||
text = AddHotkeyName( _( "&New Footprint..." ), m_hotkeysDescrList, HK_NEW );
|
||||
AddMenuItem( fileMenu, ID_MODEDIT_NEW_MODULE,
|
||||
text, _( "Create new footprint" ),
|
||||
text, _( "Create a new footprint" ),
|
||||
KiBitmap( new_footprint_xpm ) );
|
||||
|
||||
text = AddHotkeyName( _( "&Open Footprint..." ), m_hotkeysDescrList, HK_OPEN );
|
||||
|
@ -77,7 +69,12 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
|||
// Save module
|
||||
text = AddHotkeyName( _( "&Save" ), m_hotkeysDescrList, HK_SAVE );
|
||||
AddMenuItem( fileMenu, ID_MODEDIT_SAVE_LIBMODULE, text,
|
||||
_( "Save footprint" ),
|
||||
_( "Save changes" ),
|
||||
KiBitmap( save_xpm ) );
|
||||
|
||||
AddMenuItem( fileMenu, ID_MODEDIT_SAVE_LIBMODULE_AS,
|
||||
_( "Save Footprint &As..." ),
|
||||
_( "Save footprint to a new name and/or new library" ),
|
||||
KiBitmap( save_library_xpm ) );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
@ -106,26 +103,11 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
|||
_( "Import files" ),
|
||||
KiBitmap( import_xpm ) );
|
||||
|
||||
|
||||
wxMenu* exportSubMenu = new wxMenu();
|
||||
|
||||
AddMenuItem( exportSubMenu, ID_MODEDIT_SAVE_LIBRARY_AS,
|
||||
_( "&Active Library..." ),
|
||||
_( "Export active library" ),
|
||||
KiBitmap( library_archive_xpm ) );
|
||||
|
||||
AddMenuItem( exportSubMenu, ID_MODEDIT_EXPORT_PART,
|
||||
_( "&Footprint..." ),
|
||||
AddMenuItem( fileMenu, ID_MODEDIT_EXPORT_PART,
|
||||
_( "&Export Footprint..." ),
|
||||
_( "Export current footprint to a file" ),
|
||||
KiBitmap( export_module_xpm ) );
|
||||
|
||||
AddMenuItem( fileMenu, exportSubMenu, -1,
|
||||
_( "E&xport" ),
|
||||
_( "Export files" ),
|
||||
KiBitmap( export_xpm ) );
|
||||
|
||||
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
||||
// Print
|
||||
|
@ -134,15 +116,6 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
|||
_( "Print current footprint" ),
|
||||
KiBitmap( print_button_xpm ) );
|
||||
|
||||
// Separator
|
||||
fileMenu->AppendSeparator();
|
||||
|
||||
// Properties
|
||||
AddMenuItem( fileMenu, ID_MODEDIT_EDIT_MODULE_PROPERTIES,
|
||||
_( "P&roperties..." ),
|
||||
_( "Edit footprint properties" ),
|
||||
KiBitmap( module_options_xpm ) );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
||||
// Close editor
|
||||
|
@ -184,10 +157,16 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
|||
editMenu->AppendSeparator();
|
||||
}
|
||||
|
||||
// Delete items tool
|
||||
AddMenuItem( editMenu, ID_MODEDIT_DELETE_TOOL,
|
||||
_( "&Delete" ), _( "Delete items" ),
|
||||
KiBitmap( delete_xpm ) );
|
||||
// Properties
|
||||
AddMenuItem( editMenu, ID_MODEDIT_EDIT_MODULE_PROPERTIES,
|
||||
_( "&Footprint Properties..." ),
|
||||
_( "Edit footprint properties" ),
|
||||
KiBitmap( module_options_xpm ) );
|
||||
|
||||
AddMenuItem( editMenu, ID_MODEDIT_PAD_SETTINGS,
|
||||
_( "Default Pad Properties..." ),
|
||||
_( "Edit default pad properties" ),
|
||||
KiBitmap( module_options_xpm ) );
|
||||
|
||||
//--------- View menu ----------------
|
||||
wxMenu* viewMenu = new wxMenu;
|
||||
|
@ -389,6 +368,10 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
|||
//----- Inspect menu ---------------------
|
||||
wxMenu* inspectMenu = new wxMenu;
|
||||
|
||||
AddMenuItem( inspectMenu, ID_OPEN_MODULE_VIEWER,
|
||||
_( "Footprint Viewer" ),
|
||||
_( "Open the footprint viewer" ),
|
||||
KiBitmap( modview_icon_xpm ) );
|
||||
|
||||
text = AddHotkeyName( _( "&Measure" ), m_hotkeysDescrList, HK_MEASURE_TOOL );
|
||||
AddMenuItem( inspectMenu, ID_MODEDIT_MEASUREMENT_TOOL,
|
||||
|
@ -410,9 +393,19 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
|||
|
||||
toolsMenu->AppendSeparator();
|
||||
|
||||
AddMenuItem( toolsMenu, ID_MODEDIT_CREATE_NEW_LIB,
|
||||
_( "New Library..." ),
|
||||
_( "Create a new library for storing footprints" ),
|
||||
KiBitmap( library_xpm ) );
|
||||
|
||||
AddMenuItem( toolsMenu, ID_MODEDIT_SAVE_LIBRARY_AS,
|
||||
_( "Save &Library As..." ),
|
||||
_( "Save current library to a new name and/or location" ),
|
||||
KiBitmap( save_library_xpm ) );
|
||||
|
||||
AddMenuItem( toolsMenu, ID_MODEDIT_DELETE_PART,
|
||||
_( "&Delete a Footprint in Active Library" ),
|
||||
_( "Choose and delete a footprint from the active library" ),
|
||||
_( "&Delete Footprint from Library..." ),
|
||||
_( "Choose and delete a footprint from a library" ),
|
||||
KiBitmap( delete_xpm ) );
|
||||
|
||||
|
||||
|
|
|
@ -363,8 +363,9 @@ enum pcbnew_ids
|
|||
ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE,
|
||||
ID_POPUP_MODEDIT_EDIT_EDGE,
|
||||
ID_MODEDIT_CHECK,
|
||||
ID_MODEDIT_SELECT_CURRENT_LIB,
|
||||
ID_MODEDIT_CREATE_NEW_LIB,
|
||||
ID_MODEDIT_SAVE_LIBMODULE,
|
||||
ID_MODEDIT_SAVE_LIBMODULE_AS,
|
||||
ID_MODEDIT_SAVE_LIBRARY_AS,
|
||||
ID_MODEDIT_DELETE_PART,
|
||||
ID_MODEDIT_NEW_MODULE,
|
||||
|
@ -382,7 +383,6 @@ enum pcbnew_ids
|
|||
ID_MODEDIT_MODULE_MOVE_EXACT,
|
||||
ID_MODEDIT_IMPORT_PART,
|
||||
ID_MODEDIT_EXPORT_PART,
|
||||
ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
|
||||
ID_POPUP_MODEDIT_EDIT_BODY_ITEM,
|
||||
|
||||
ID_MODVIEW_LIBWINDOW,
|
||||
|
|
|
@ -46,26 +46,9 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
|
|||
wxString msg;
|
||||
|
||||
// Set up toolbar
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_SELECT_CURRENT_LIB, wxEmptyString,
|
||||
KiScaledBitmap( open_library_xpm, this ),
|
||||
_( "Select active library" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_SAVE_LIBMODULE, wxEmptyString, KiScaledBitmap( save_library_xpm, this ),
|
||||
_( "Save footprint in active library" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, wxEmptyString,
|
||||
KiScaledBitmap( new_library_xpm, this ),
|
||||
_( "Create new library and save current footprint" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_OPEN_MODULE_VIEWER, wxEmptyString, KiScaledBitmap( modview_icon_xpm, this ),
|
||||
_( "Open footprint viewer" ) );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_DELETE_PART, wxEmptyString, KiScaledBitmap( delete_xpm, this ),
|
||||
_( "Delete part from active library" ) );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE, wxEmptyString, KiScaledBitmap( new_footprint_xpm, this ),
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_NEW_MODULE, wxEmptyString,
|
||||
KiScaledBitmap( new_footprint_xpm, this ),
|
||||
_( "New footprint" ) );
|
||||
|
||||
#ifdef KICAD_SCRIPTING
|
||||
|
@ -74,31 +57,18 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
|
|||
_( "New footprint using footprint wizard" ) );
|
||||
#endif
|
||||
|
||||
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE, wxEmptyString,
|
||||
KiScaledBitmap( load_module_lib_xpm, this ),
|
||||
_( "Load footprint from library" ) );
|
||||
_( "Open a footprint from a library" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_SAVE_LIBMODULE, wxEmptyString,
|
||||
KiScaledBitmap( save_xpm, this ),
|
||||
_( "Save footprint in existing library" ) );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
|
||||
KiScaledBitmap( load_module_board_xpm, this ),
|
||||
_( "Load footprint from current board" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, wxEmptyString,
|
||||
KiScaledBitmap( update_module_board_xpm, this ),
|
||||
_( "Update footprint into current board" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, wxEmptyString,
|
||||
KiScaledBitmap( insert_module_board_xpm, this ),
|
||||
_( "Insert footprint into current board" ) );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_IMPORT_PART, wxEmptyString, KiScaledBitmap( import_module_xpm, this ),
|
||||
_( "Import footprint" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_EXPORT_PART, wxEmptyString, KiScaledBitmap( export_module_xpm, this ),
|
||||
_( "Export footprint" ) );
|
||||
|
||||
m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString,
|
||||
KiScaledBitmap( print_button_xpm, this ),
|
||||
_( "Print footprint" ) );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiScaledBitmap( undo_xpm, this ),
|
||||
|
@ -107,17 +77,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
|
|||
_( "Redo last undo command" ) );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_EDIT_MODULE_PROPERTIES, wxEmptyString,
|
||||
KiScaledBitmap( module_options_xpm, this ),
|
||||
_( "Footprint properties" ) );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiScaledBitmap( print_button_xpm, this ),
|
||||
_( "Print footprint" ) );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
msg = AddHotkeyName( _( "Redraw view" ), g_Module_Editor_Hotkeys_Descr, HK_ZOOM_REDRAW,
|
||||
IS_COMMENT );
|
||||
msg = AddHotkeyName( _( "Redraw view" ), g_Module_Editor_Hotkeys_Descr, HK_ZOOM_REDRAW, IS_COMMENT );
|
||||
m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiScaledBitmap( zoom_redraw_xpm, this ), msg );
|
||||
|
||||
msg = AddHotkeyName( _( "Zoom in" ), g_Module_Editor_Hotkeys_Descr, HK_ZOOM_IN, IS_COMMENT );
|
||||
|
@ -133,8 +93,26 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
|
|||
_( "Zoom to selection" ), wxITEM_CHECK );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_PAD_SETTINGS, wxEmptyString, KiScaledBitmap( options_pad_xpm, this ),
|
||||
_( "Pad properties" ) );
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_EDIT_MODULE_PROPERTIES, wxEmptyString,
|
||||
KiScaledBitmap( module_options_xpm, this ),
|
||||
_( "Footprint properties" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_PAD_SETTINGS, wxEmptyString,
|
||||
KiScaledBitmap( options_pad_xpm, this ),
|
||||
_( "Default pad properties" ) );
|
||||
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString,
|
||||
KiScaledBitmap( load_module_board_xpm, this ),
|
||||
_( "Load footprint from current board" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, wxEmptyString,
|
||||
KiScaledBitmap( update_module_board_xpm, this ),
|
||||
_( "Update footprint into current board" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_MODEDIT_INSERT_MODULE_IN_BOARD, wxEmptyString,
|
||||
KiScaledBitmap( insert_module_board_xpm, this ),
|
||||
_( "Insert footprint into current board" ) );
|
||||
|
||||
#if 0 // Currently there is no check footprint function defined, so do not show this tool
|
||||
KiScaledSeparator( m_mainToolBar, this );
|
||||
|
@ -211,7 +189,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar()
|
|||
m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
||||
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
|
||||
|
||||
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, KiScaledBitmap( grid_xpm, this ),
|
||||
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
|
||||
KiScaledBitmap( grid_xpm, this ),
|
||||
_( "Hide grid" ), wxITEM_CHECK );
|
||||
|
||||
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
|
||||
|
|
Loading…
Reference in New Issue