Save the footprint editor's last footprint in the PROJECT RString facility.
This commit is contained in:
parent
3d311f831e
commit
1385e39d89
|
@ -134,9 +134,6 @@ public:
|
||||||
/// Accessor for Eeschema search stack.
|
/// Accessor for Eeschema search stack.
|
||||||
VTBL_ENTRY SEARCH_STACK& SchSearchS() { return m_sch_search; }
|
VTBL_ENTRY SEARCH_STACK& SchSearchS() { return m_sch_search; }
|
||||||
|
|
||||||
VTBL_ENTRY wxString GetModuleLibraryNickname() { return m_module_library_nickname; }
|
|
||||||
VTBL_ENTRY void SetModuleLibraryNickname( const wxString& aNickName ) { m_module_library_nickname = aNickName; }
|
|
||||||
|
|
||||||
/// Retain a number of project specific wxStrings, enumerated here:
|
/// Retain a number of project specific wxStrings, enumerated here:
|
||||||
enum RSTRING_T
|
enum RSTRING_T
|
||||||
{
|
{
|
||||||
|
@ -144,6 +141,7 @@ public:
|
||||||
SCH_LIB_PATH,
|
SCH_LIB_PATH,
|
||||||
PCB_LIB_NICKNAME,
|
PCB_LIB_NICKNAME,
|
||||||
VIEWER_3D_PATH,
|
VIEWER_3D_PATH,
|
||||||
|
PCB_FOOTPRINT,
|
||||||
|
|
||||||
RSTRING_COUNT
|
RSTRING_COUNT
|
||||||
};
|
};
|
||||||
|
@ -252,8 +250,6 @@ private:
|
||||||
wxFileName m_project_name; ///< <fullpath>/<basename>.pro
|
wxFileName m_project_name; ///< <fullpath>/<basename>.pro
|
||||||
wxString m_pro_date_and_time;
|
wxString m_pro_date_and_time;
|
||||||
|
|
||||||
wxString m_module_library_nickname; ///< @todo move this into m_rpaths[]
|
|
||||||
|
|
||||||
/// @see this::SetRString(), GetRString(), and enum RSTRING_T.
|
/// @see this::SetRString(), GetRString(), and enum RSTRING_T.
|
||||||
wxString m_rstrings[RSTRING_COUNT];
|
wxString m_rstrings[RSTRING_COUNT];
|
||||||
|
|
||||||
|
|
|
@ -467,7 +467,7 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
|
||||||
|
|
||||||
bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
|
bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
|
||||||
{
|
{
|
||||||
wxString nickname = getLibNickName();
|
wxString nickname = GetCurrentLib();
|
||||||
|
|
||||||
if( !Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname ) )
|
if( !Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -251,11 +251,11 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
|
|
||||||
case ID_MODEDIT_SELECT_CURRENT_LIB:
|
case ID_MODEDIT_SELECT_CURRENT_LIB:
|
||||||
{
|
{
|
||||||
wxString library = SelectLibrary( getLibNickName() );
|
wxString library = SelectLibrary( GetCurrentLib() );
|
||||||
|
|
||||||
if( library.size() )
|
if( library.size() )
|
||||||
{
|
{
|
||||||
setLibNickName( library );
|
Prj().SetRString( PROJECT::PCB_LIB_NICKNAME, library );
|
||||||
updateTitle();
|
updateTitle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,9 +364,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MODEDIT_SAVE_LIBMODULE:
|
case ID_MODEDIT_SAVE_LIBMODULE:
|
||||||
if( GetBoard()->m_Modules && getLibNickName().size() )
|
if( GetBoard()->m_Modules && GetCurrentLib().size() )
|
||||||
{
|
{
|
||||||
Save_Module_In_Library( getLibNickName(), GetBoard()->m_Modules, true, true );
|
Save_Module_In_Library( GetCurrentLib(), GetBoard()->m_Modules, true, true );
|
||||||
GetScreen()->ClrModify();
|
GetScreen()->ClrModify();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -506,7 +506,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
|
|
||||||
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
||||||
|
|
||||||
LoadModuleFromLibrary( getLibNickName(), Prj().PcbFootprintLibs(), true );
|
LoadModuleFromLibrary( GetCurrentLib(), Prj().PcbFootprintLibs(), true );
|
||||||
redraw = true;
|
redraw = true;
|
||||||
|
|
||||||
if( GetBoard()->m_Modules )
|
if( GetBoard()->m_Modules )
|
||||||
|
|
|
@ -245,8 +245,8 @@ public:
|
||||||
UNDO_REDO_T aTypeCommand,
|
UNDO_REDO_T aTypeCommand,
|
||||||
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
|
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
|
||||||
|
|
||||||
wxString GetCurrentLib() const { return getLibNickName(); };
|
/// Return the current library nickname.
|
||||||
|
const wxString GetCurrentLib() const;
|
||||||
|
|
||||||
// Footprint edition
|
// Footprint edition
|
||||||
void RemoveStruct( EDA_ITEM* Item );
|
void RemoveStruct( EDA_ITEM* Item );
|
||||||
|
@ -380,7 +380,7 @@ public:
|
||||||
* Install a dialog to edit a graphic item of a footprint body.
|
* Install a dialog to edit a graphic item of a footprint body.
|
||||||
* @param aItem = a pointer to the graphic item to edit
|
* @param aItem = a pointer to the graphic item to edit
|
||||||
*/
|
*/
|
||||||
void InstallFootprintBodyItemPropertiesDlg(EDGE_MODULE * aItem);
|
void InstallFootprintBodyItemPropertiesDlg( EDGE_MODULE* aItem );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function DlgGlobalChange_PadSettings
|
* Function DlgGlobalChange_PadSettings
|
||||||
|
@ -397,7 +397,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool DeleteModuleFromCurrentLibrary();
|
bool DeleteModuleFromCurrentLibrary();
|
||||||
|
|
||||||
virtual EDA_COLOR_T GetGridColor( void ) const;
|
virtual EDA_COLOR_T GetGridColor() const;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
@ -429,15 +429,11 @@ protected:
|
||||||
*/
|
*/
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
|
|
||||||
/// The library nickName is a short string, for now the same as the library path
|
|
||||||
/// but without path and without extension. After library table support it becomes
|
|
||||||
/// a lookup key.
|
|
||||||
const wxString getLibNickName() const;
|
|
||||||
void setLibNickName( const wxString& aNickname );
|
|
||||||
|
|
||||||
|
|
||||||
/// The libPath is not publicly visible, grab it from the FP_LIB_TABLE if we must.
|
/// The libPath is not publicly visible, grab it from the FP_LIB_TABLE if we must.
|
||||||
wxString getLibPath();
|
const wxString getLibPath();
|
||||||
|
|
||||||
|
void restoreLastFootprint();
|
||||||
|
void retainLastFootprint();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MODULE_EDITOR_FRAME_H_
|
#endif // MODULE_EDITOR_FRAME_H_
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <kiway.h>
|
#include <kiway.h>
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
|
#include <kicad_plugin.h>
|
||||||
#include <class_drawpanel.h>
|
#include <class_drawpanel.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
#include <wxPcbStruct.h>
|
#include <wxPcbStruct.h>
|
||||||
|
@ -168,6 +169,9 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
|
|
||||||
SetBoard( new BOARD() );
|
SetBoard( new BOARD() );
|
||||||
|
|
||||||
|
// restore the last footprint from the project, if any
|
||||||
|
restoreLastFootprint();
|
||||||
|
|
||||||
// Ensure all layers and items are visible:
|
// Ensure all layers and items are visible:
|
||||||
GetBoard()->SetVisibleAlls();
|
GetBoard()->SetVisibleAlls();
|
||||||
|
|
||||||
|
@ -177,7 +181,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
LoadSettings( config() );
|
LoadSettings( config() );
|
||||||
|
|
||||||
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
|
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
|
||||||
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
||||||
|
|
||||||
// In modedit, set the default paper size to A4:
|
// In modedit, set the default paper size to A4:
|
||||||
// this should be OK for all footprint to plot/print
|
// this should be OK for all footprint to plot/print
|
||||||
|
@ -230,26 +234,16 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
|
|
||||||
FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
|
FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
|
||||||
{
|
{
|
||||||
|
// save the footprint in the PROJECT
|
||||||
|
retainLastFootprint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const wxString FOOTPRINT_EDIT_FRAME::getLibNickName() const
|
const wxString FOOTPRINT_EDIT_FRAME::getLibPath()
|
||||||
{
|
|
||||||
return Prj().GetModuleLibraryNickname();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_EDIT_FRAME::setLibNickName( const wxString& aNickname )
|
|
||||||
{
|
|
||||||
Prj().SetModuleLibraryNickname( aNickname );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxString FOOTPRINT_EDIT_FRAME::getLibPath()
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const wxString& nickname = getLibNickName();
|
const wxString& nickname = GetCurrentLib();
|
||||||
|
|
||||||
const FP_LIB_TABLE::ROW* row = Prj().PcbFootprintLibs()->FindRow( nickname );
|
const FP_LIB_TABLE::ROW* row = Prj().PcbFootprintLibs()->FindRow( nickname );
|
||||||
|
|
||||||
|
@ -262,6 +256,57 @@ wxString FOOTPRINT_EDIT_FRAME::getLibPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const wxString FOOTPRINT_EDIT_FRAME::GetCurrentLib() const
|
||||||
|
{
|
||||||
|
return Prj().GetRString( PROJECT::PCB_LIB_NICKNAME );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_EDIT_FRAME::retainLastFootprint()
|
||||||
|
{
|
||||||
|
PCB_IO pcb_io;
|
||||||
|
MODULE* module = GetBoard()->m_Modules;
|
||||||
|
|
||||||
|
if( module )
|
||||||
|
{
|
||||||
|
pcb_io.Format( GetBoard()->m_Modules );
|
||||||
|
|
||||||
|
wxString pretty = FROM_UTF8( pcb_io.GetStringOutput( true ).c_str() );
|
||||||
|
|
||||||
|
Prj().SetRString( PROJECT::PCB_FOOTPRINT, pretty );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_EDIT_FRAME::restoreLastFootprint()
|
||||||
|
{
|
||||||
|
wxString pretty = Prj().GetRString( PROJECT::PCB_FOOTPRINT );
|
||||||
|
|
||||||
|
if( !!pretty )
|
||||||
|
{
|
||||||
|
PCB_IO pcb_io;
|
||||||
|
MODULE* module = NULL;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
module = (MODULE*) pcb_io.Parse( pretty );
|
||||||
|
}
|
||||||
|
catch( const PARSE_ERROR& pe )
|
||||||
|
{
|
||||||
|
// unlikely to be a problem, since we produced the pretty string.
|
||||||
|
wxLogError( wxT( "PARSE_ERROR" ) );
|
||||||
|
}
|
||||||
|
catch( const IO_ERROR& ioe )
|
||||||
|
{
|
||||||
|
// unlikely to be a problem, since we produced the pretty string.
|
||||||
|
wxLogError( wxT( "IO_ERROR" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( module )
|
||||||
|
GetBoard()->Add( module ); // assumes BOARD is empty.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const wxChar* FOOTPRINT_EDIT_FRAME::GetFootprintEditorFrameName()
|
const wxChar* FOOTPRINT_EDIT_FRAME::GetFootprintEditorFrameName()
|
||||||
{
|
{
|
||||||
return FOOTPRINT_EDIT_FRAME_NAME;
|
return FOOTPRINT_EDIT_FRAME_NAME;
|
||||||
|
@ -334,9 +379,9 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
||||||
case wxID_YES:
|
case wxID_YES:
|
||||||
// code from FOOTPRINT_EDIT_FRAME::Process_Special_Functions,
|
// code from FOOTPRINT_EDIT_FRAME::Process_Special_Functions,
|
||||||
// at case ID_MODEDIT_SAVE_LIBMODULE
|
// at case ID_MODEDIT_SAVE_LIBMODULE
|
||||||
if( GetBoard()->m_Modules && getLibNickName().size() )
|
if( GetBoard()->m_Modules && GetCurrentLib().size() )
|
||||||
{
|
{
|
||||||
if( Save_Module_In_Library( getLibNickName(), GetBoard()->m_Modules, true, true ) )
|
if( Save_Module_In_Library( GetCurrentLib(), GetBoard()->m_Modules, true, true ) )
|
||||||
{
|
{
|
||||||
// save was correct
|
// save was correct
|
||||||
GetScreen()->ClrModify();
|
GetScreen()->ClrModify();
|
||||||
|
@ -587,7 +632,7 @@ void FOOTPRINT_EDIT_FRAME::updateTitle()
|
||||||
{
|
{
|
||||||
wxString title = _( "Module Editor " );
|
wxString title = _( "Module Editor " );
|
||||||
|
|
||||||
wxString nickname = getLibNickName();
|
wxString nickname = GetCurrentLib();
|
||||||
|
|
||||||
if( !nickname )
|
if( !nickname )
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
|
#include <kiface_i.h>
|
||||||
#include <help_common_strings.h>
|
#include <help_common_strings.h>
|
||||||
#include <dialog_helpers.h>
|
#include <dialog_helpers.h>
|
||||||
#include <class_layer_box_selector.h>
|
#include <class_layer_box_selector.h>
|
||||||
|
@ -218,10 +219,14 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
|
||||||
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
||||||
|
|
||||||
// Set up toolbar
|
// Set up toolbar
|
||||||
m_mainToolBar->AddTool( ID_NEW_BOARD, wxEmptyString, KiBitmap( new_pcb_xpm ),
|
if( Kiface().IsSingle() )
|
||||||
_( "New board" ) );
|
{
|
||||||
m_mainToolBar->AddTool( ID_LOAD_FILE, wxEmptyString, KiBitmap( open_brd_file_xpm ),
|
m_mainToolBar->AddTool( ID_NEW_BOARD, wxEmptyString, KiBitmap( new_pcb_xpm ),
|
||||||
_( "Open existing board" ) );
|
_( "New board" ) );
|
||||||
|
m_mainToolBar->AddTool( ID_LOAD_FILE, wxEmptyString, KiBitmap( open_brd_file_xpm ),
|
||||||
|
_( "Open existing board" ) );
|
||||||
|
}
|
||||||
|
|
||||||
m_mainToolBar->AddTool( ID_SAVE_BOARD, wxEmptyString, KiBitmap( save_xpm ),
|
m_mainToolBar->AddTool( ID_SAVE_BOARD, wxEmptyString, KiBitmap( save_xpm ),
|
||||||
_( "Save board" ) );
|
_( "Save board" ) );
|
||||||
|
|
||||||
|
@ -501,29 +506,29 @@ void PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar()
|
||||||
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxEmptyString,
|
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxEmptyString,
|
||||||
KiBitmap( mw_add_line_xpm ),
|
KiBitmap( mw_add_line_xpm ),
|
||||||
_( "Create line of specified length for microwave applications" ),
|
_( "Create line of specified length for microwave applications" ),
|
||||||
wxITEM_CHECK );
|
wxITEM_CHECK );
|
||||||
|
|
||||||
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_GAP_CMD, wxEmptyString,
|
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_GAP_CMD, wxEmptyString,
|
||||||
KiBitmap( mw_add_gap_xpm ),
|
KiBitmap( mw_add_gap_xpm ),
|
||||||
_( "Create gap of specified length for microwave applications" ),
|
_( "Create gap of specified length for microwave applications" ),
|
||||||
wxITEM_CHECK );
|
wxITEM_CHECK );
|
||||||
|
|
||||||
m_microWaveToolBar->AddSeparator();
|
m_microWaveToolBar->AddSeparator();
|
||||||
|
|
||||||
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_CMD, wxEmptyString,
|
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_CMD, wxEmptyString,
|
||||||
KiBitmap( mw_add_stub_xpm ),
|
KiBitmap( mw_add_stub_xpm ),
|
||||||
_( "Create stub of specified length for microwave applications" ),
|
_( "Create stub of specified length for microwave applications" ),
|
||||||
wxITEM_CHECK );
|
wxITEM_CHECK );
|
||||||
|
|
||||||
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, wxEmptyString,
|
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, wxEmptyString,
|
||||||
KiBitmap( mw_add_stub_arc_xpm ),
|
KiBitmap( mw_add_stub_arc_xpm ),
|
||||||
_( "Create stub (arc) of specified length for microwave applications" ),
|
_( "Create stub (arc) of specified length for microwave applications" ),
|
||||||
wxITEM_CHECK );
|
wxITEM_CHECK );
|
||||||
|
|
||||||
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD, wxEmptyString,
|
m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD, wxEmptyString,
|
||||||
KiBitmap( mw_add_shape_xpm ),
|
KiBitmap( mw_add_shape_xpm ),
|
||||||
_( "Create a polynomial shape for microwave applications" ),
|
_( "Create a polynomial shape for microwave applications" ),
|
||||||
wxITEM_CHECK );
|
wxITEM_CHECK );
|
||||||
|
|
||||||
m_microWaveToolBar->Realize();
|
m_microWaveToolBar->Realize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue