pcbnew: footprint wizards now can export the output module to the library or board

This commit is contained in:
Miguel Angel Ajo 2012-08-05 00:15:57 +02:00
parent 9d5e271334
commit ccb74b99d3
4 changed files with 44 additions and 10 deletions

View File

@ -110,6 +110,11 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
m_canvas->Refresh();
}
MODULE* FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint()
{
return m_FootprintWizard->GetModule();
}
void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard()
{
DIALOG_FOOTPRINT_WIZARD_LIST *selectWizard =

View File

@ -69,8 +69,10 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS,
FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
/* EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE,
FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )*/
EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE,
FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )
EVT_TOOL( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW,
FOOTPRINT_WIZARD_FRAME::Show3D_Frame )
@ -271,6 +273,13 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
*/
void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
wxCommandEvent fakeEvent;
ExportSelectedFootprint( fakeEvent );
}
void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent )
{
SaveSettings();
if( m_Semaphore )
@ -284,6 +293,8 @@ void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
Destroy();
}
}
@ -723,16 +734,14 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
HK_ZOOM_AUTO, IS_COMMENT );
m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
KiBitmap( zoom_fit_in_page_xpm ), msg );
#if 0
if( m_Semaphore )
{
// The library browser is called from a "load component" command
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_FOOTPRINT_EXPORT_TO_BOARD,
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_DONE,
wxEmptyString, KiBitmap( export_footprint_names_xpm ),
_( "Insert footprint in board" ) );
}
#endif
// after adding the buttons to the toolbar, must call Realize() to
// reflect the changes

View File

@ -72,11 +72,17 @@ public:
~FOOTPRINT_WIZARD_FRAME();
MODULE* GetBuiltFootrint( void );
MODULE* GetBuiltFootprint( void );
private:
void OnSize( wxSizeEvent& event );
/**
* Function ExportSelectedFootprint();
* will let the caller exit from the wait loop, and get the built footprint
*
*/
void ExportSelectedFootprint( wxCommandEvent& aEvent );
/**
* Function OnSashDrag

View File

@ -293,14 +293,26 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetCurItem( NULL );
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
MODULE* module = NULL;
FOOTPRINT_WIZARD_FRAME *wizard = new FOOTPRINT_WIZARD_FRAME(this,NULL);
wxSemaphore semaphore( 0, 1 );
FOOTPRINT_WIZARD_FRAME *wizard = new FOOTPRINT_WIZARD_FRAME( this, &semaphore );
wizard->Show( true );
wizard->Zoom_Automatique( false );
while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event
{
wxYield();
wxMilliSleep( 50 );
}
MODULE* module = wizard->GetBuiltFootprint();
if( module ) // i.e. if create module command not aborted
{
/* Here we should make a copy of the object before adding to board*/
module->SetParent( (EDA_ITEM*)GetBoard() );
GetBoard()->m_Modules.Append( module );
// Initialize data relative to nets and netclasses (for a new
// module the defaults are used)
// This is mandatory to handle and draw pads
@ -310,9 +322,11 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( GetBoard()->m_Modules )
GetBoard()->m_Modules->ClearFlags();
Zoom_Automatique( false );
}
wizard->Destroy();
break;
}