Commit ccb74b99 authored by Miguel Angel Ajo's avatar Miguel Angel Ajo

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

parent 9d5e2713
...@@ -110,6 +110,11 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() ...@@ -110,6 +110,11 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
m_canvas->Refresh(); m_canvas->Refresh();
} }
MODULE* FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint()
{
return m_FootprintWizard->GetModule();
}
void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard() void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard()
{ {
DIALOG_FOOTPRINT_WIZARD_LIST *selectWizard = DIALOG_FOOTPRINT_WIZARD_LIST *selectWizard =
......
...@@ -69,8 +69,10 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME ) ...@@ -69,8 +69,10 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS, EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS,
FOOTPRINT_WIZARD_FRAME::Process_Special_Functions ) 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, EVT_TOOL( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW,
FOOTPRINT_WIZARD_FRAME::Show3D_Frame ) FOOTPRINT_WIZARD_FRAME::Show3D_Frame )
...@@ -271,6 +273,13 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME() ...@@ -271,6 +273,13 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
*/ */
void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event ) void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
wxCommandEvent fakeEvent;
ExportSelectedFootprint( fakeEvent );
}
void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent )
{
SaveSettings(); SaveSettings();
if( m_Semaphore ) if( m_Semaphore )
...@@ -284,6 +293,8 @@ void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -284,6 +293,8 @@ void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
Destroy(); Destroy();
} }
} }
...@@ -723,16 +734,14 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar() ...@@ -723,16 +734,14 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
HK_ZOOM_AUTO, IS_COMMENT ); HK_ZOOM_AUTO, IS_COMMENT );
m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
KiBitmap( zoom_fit_in_page_xpm ), msg ); KiBitmap( zoom_fit_in_page_xpm ), msg );
#if 0
if( m_Semaphore ) if( m_Semaphore )
{ {
// The library browser is called from a "load component" command // The library browser is called from a "load component" command
m_mainToolBar->AddSeparator(); 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 ), wxEmptyString, KiBitmap( export_footprint_names_xpm ),
_( "Insert footprint in board" ) ); _( "Insert footprint in board" ) );
} }
#endif
// after adding the buttons to the toolbar, must call Realize() to // after adding the buttons to the toolbar, must call Realize() to
// reflect the changes // reflect the changes
......
...@@ -72,11 +72,17 @@ public: ...@@ -72,11 +72,17 @@ public:
~FOOTPRINT_WIZARD_FRAME(); ~FOOTPRINT_WIZARD_FRAME();
MODULE* GetBuiltFootrint( void ); MODULE* GetBuiltFootprint( void );
private: private:
void OnSize( wxSizeEvent& event ); 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 * Function OnSashDrag
......
...@@ -293,14 +293,26 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -293,14 +293,26 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetCurItem( NULL ); SetCurItem( NULL );
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); 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->Show( true );
wizard->Zoom_Automatique( false ); 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 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 // Initialize data relative to nets and netclasses (for a new
// module the defaults are used) // module the defaults are used)
// This is mandatory to handle and draw pads // This is mandatory to handle and draw pads
...@@ -310,9 +322,11 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -310,9 +322,11 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( GetBoard()->m_Modules ) if( GetBoard()->m_Modules )
GetBoard()->m_Modules->ClearFlags(); GetBoard()->m_Modules->ClearFlags();
Zoom_Automatique( false );
} }
wizard->Destroy();
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment