Loading pcbnew/class_footprint_wizard.cpp +34 −9 Original line number Diff line number Diff line Loading @@ -31,11 +31,18 @@ #include "class_footprint_wizard.h" #include <stdio.h> FOOTPRINT_WIZARD::~FOOTPRINT_WIZARD() { } void FOOTPRINT_WIZARD::register_wizard() { FOOTPRINT_WIZARDS::register_wizard( this ); } std::vector<FOOTPRINT_WIZARD*> FOOTPRINT_WIZARDS::m_FootprintWizards; FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( int aIndex ) Loading @@ -43,6 +50,7 @@ FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( int aIndex ) return m_FootprintWizards[aIndex]; } FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName ) { int max = GetSize(); Loading @@ -53,26 +61,43 @@ FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName ) wxString name = wizard->GetName(); if ( name.Cmp( aName ) ) if( name.Cmp( aName )==0 ) return wizard; } return NULL; } int FOOTPRINT_WIZARDS::GetSize() { return m_FootprintWizards.size(); } void FOOTPRINT_WIZARDS::register_wizard( FOOTPRINT_WIZARD* aWizard ) { wxString name = aWizard->GetName(); m_FootprintWizards.push_back( aWizard ); m_FootprintWizards.push_back( aWizard ); } bool FOOTPRINT_WIZARDS::deregister_object( void* aObject ) { int max = GetSize(); for( int i = 0; i<max; i++ ) { FOOTPRINT_WIZARD* wizard = GetWizard( i ); if( wizard->GetObject() == aObject ) { m_FootprintWizards.erase( m_FootprintWizards.begin() + i ); delete wizard; return true; } } return false; } pcbnew/class_footprint_wizard.h +40 −27 Original line number Diff line number Diff line Loading @@ -39,10 +39,9 @@ * derive */ class FOOTPRINT_WIZARD { public: FOOTPRINT_WIZARD() {} ~FOOTPRINT_WIZARD() {} virtual ~FOOTPRINT_WIZARD(); /** * Function GetName Loading Loading @@ -120,6 +119,13 @@ public: */ virtual MODULE* GetModule() = 0; /** * Function GetObject * This method gets the pointer to the object from where this wizard constructs * @return it's a void pointer, as it could be a PyObject or any other */ virtual void* GetObject() = 0; /** * Function register_wizard * It's the standard method of a "FOOTPRINT_WIZARD" to register itself into Loading @@ -127,7 +133,6 @@ public: * */ void register_wizard(); }; Loading @@ -138,7 +143,6 @@ private: * FOOTPRINT_WIZARD system wide static list */ static std::vector<FOOTPRINT_WIZARD*> m_FootprintWizards; public: /** Loading @@ -151,6 +155,17 @@ public: */ static void register_wizard( FOOTPRINT_WIZARD* aWizard ); /** * Function deregister_object * Anyone calls this method to deregister an object which builds a wizard, * it will lookup on the vector calling GetObject until find, then removed * and deleted * * @param aObject is the footprint wizard object to be deregistered * */ static bool deregister_object( void* aObject ); /** * Function GetWizard * @param aName is the footprint wizard name Loading @@ -172,8 +187,6 @@ public: * @return the number of wizards available into the system */ static int GetSize(); }; #endif /* PCBNEW_FOOTPRINT_WIZARDS_H */ pcbnew/footprint_wizard.cpp +44 −13 Original line number Diff line number Diff line Loading @@ -94,13 +94,15 @@ void FOOTPRINT_WIZARD_FRAME::DisplayWizardInfos() void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() { if( m_FootprintWizard == NULL ) FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); if( !footprintWizard ) return; SetCurItem( NULL ); // Delete the current footprint GetBoard()->m_Modules.DeleteAll(); MODULE* m = m_FootprintWizard->GetModule(); MODULE* m = footprintWizard->GetModule(); if( m ) { Loading @@ -112,18 +114,37 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() } else { printf( "m_FootprintWizard->GetModule() returns NULL\n" ); printf( "footprintWizard->GetModule() returns NULL\n" ); } m_canvas->Refresh(); } FOOTPRINT_WIZARD* FOOTPRINT_WIZARD_FRAME::GetMyWizard() { if( m_wizardName.Length()==0 ) return NULL; FOOTPRINT_WIZARD* footprintWizard = FOOTPRINT_WIZARDS::GetWizard( m_wizardName ); if( !footprintWizard ) { wxMessageBox( _( "Couldn't reload footprint wizard" ) ); return NULL; } return footprintWizard; } MODULE* FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint() { if( m_FootprintWizard ) FOOTPRINT_WIZARD* footprintWizard = FOOTPRINT_WIZARDS::GetWizard( m_wizardName ); if( footprintWizard ) { return m_FootprintWizard->GetModule(); return footprintWizard->GetModule(); } else { Loading @@ -139,12 +160,17 @@ void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard() selectWizard->ShowModal(); m_FootprintWizard = selectWizard->GetWizard(); FOOTPRINT_WIZARD* footprintWizard = selectWizard->GetWizard(); if( m_FootprintWizard ) if( footprintWizard ) { m_wizardName = m_FootprintWizard->GetName(); m_wizardDescription = m_FootprintWizard->GetDescription(); m_wizardName = footprintWizard->GetName(); m_wizardDescription = footprintWizard->GetDescription(); } else { m_wizardName = wxT( "" ); m_wizardDescription = wxT( "" ); } ReloadFootprint(); Loading @@ -169,12 +195,17 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) { int page = m_PageList->GetSelection(); FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); if( !footprintWizard ) return; if( page<0 ) return; int n = m_ParameterGrid->GetNumberRows(); wxArrayString arr; wxArrayString ptList = m_FootprintWizard->GetParameterTypes( page ); wxArrayString ptList = footprintWizard->GetParameterTypes( page ); for( int i = 0; i<n; i++ ) { Loading Loading @@ -205,7 +236,7 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) arr.Add( value ); } wxString res = m_FootprintWizard->SetParameterValues( page, arr ); wxString res = footprintWizard->SetParameterValues( page, arr ); ReloadFootprint(); DisplayWizardInfos(); Loading pcbnew/footprint_wizard_frame.cpp +40 −34 Original line number Diff line number Diff line Loading @@ -81,6 +81,8 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME ) EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList ) EVT_GRID_CMD_CELL_CHANGE( ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ParametersUpdated ) EVT_GRID_CMD_EDITOR_HIDDEN( ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ParametersUpdated ) EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset ) END_EVENT_TABLE() Loading Loading @@ -131,7 +133,6 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( FOOTPRINT_EDIT_FRAME* parent, // SetIcon( icon ); m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr; m_FootprintWizard = NULL; m_PageList = NULL; m_ParameterGrid = NULL; m_PageListWindow = NULL; Loading Loading @@ -386,15 +387,18 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() if( m_PageList == NULL ) return; if( m_FootprintWizard == NULL ) FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); if( !footprintWizard ) return; m_PageList->Clear(); int max_page = m_FootprintWizard->GetNumParameterPages(); int max_page = footprintWizard->GetNumParameterPages(); for( int i = 0; i<max_page; i++ ) { wxString name = m_FootprintWizard->GetParameterPageName( i ); wxString name = footprintWizard->GetParameterPageName( i ); m_PageList->Append( name ); } Loading @@ -417,7 +421,9 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() if( m_ParameterGrid == NULL ) return; if( m_FootprintWizard == NULL ) FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); if( footprintWizard == NULL ) return; int page = m_PageList->GetSelection(); Loading @@ -435,9 +441,9 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() m_ParameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Get the list of names, values, and types wxArrayString fpList = m_FootprintWizard->GetParameterNames( page ); wxArrayString fvList = m_FootprintWizard->GetParameterValues( page ); wxArrayString ptList = m_FootprintWizard->GetParameterTypes( page ); wxArrayString fpList = footprintWizard->GetParameterNames( page ); wxArrayString fvList = footprintWizard->GetParameterValues( page ); wxArrayString ptList = footprintWizard->GetParameterTypes( page ); // Dimension the wxGrid m_ParameterGrid->DeleteRows( 0, m_ParameterGrid->GetNumberRows() ); Loading pcbnew/footprint_wizard_frame.h +38 −34 Original line number Diff line number Diff line Loading @@ -60,8 +60,6 @@ private: // Flags wxSemaphore* m_Semaphore; // < != NULL if the frame must emulate a modal dialog wxString m_configPath; // < subpath for configuration FOOTPRINT_WIZARD* m_FootprintWizard; protected: wxString m_wizardName; // < name of the current wizard wxString m_wizardDescription; // < description of the wizard Loading Loading @@ -118,6 +116,12 @@ private: */ void ReloadFootprint(); /** * Function GetMyWizard * Reloads the wizard by name */ FOOTPRINT_WIZARD* GetMyWizard(); void Process_Special_Functions( wxCommandEvent& event ); Loading Loading
pcbnew/class_footprint_wizard.cpp +34 −9 Original line number Diff line number Diff line Loading @@ -31,11 +31,18 @@ #include "class_footprint_wizard.h" #include <stdio.h> FOOTPRINT_WIZARD::~FOOTPRINT_WIZARD() { } void FOOTPRINT_WIZARD::register_wizard() { FOOTPRINT_WIZARDS::register_wizard( this ); } std::vector<FOOTPRINT_WIZARD*> FOOTPRINT_WIZARDS::m_FootprintWizards; FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( int aIndex ) Loading @@ -43,6 +50,7 @@ FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( int aIndex ) return m_FootprintWizards[aIndex]; } FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName ) { int max = GetSize(); Loading @@ -53,26 +61,43 @@ FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard( wxString aName ) wxString name = wizard->GetName(); if ( name.Cmp( aName ) ) if( name.Cmp( aName )==0 ) return wizard; } return NULL; } int FOOTPRINT_WIZARDS::GetSize() { return m_FootprintWizards.size(); } void FOOTPRINT_WIZARDS::register_wizard( FOOTPRINT_WIZARD* aWizard ) { wxString name = aWizard->GetName(); m_FootprintWizards.push_back( aWizard ); m_FootprintWizards.push_back( aWizard ); } bool FOOTPRINT_WIZARDS::deregister_object( void* aObject ) { int max = GetSize(); for( int i = 0; i<max; i++ ) { FOOTPRINT_WIZARD* wizard = GetWizard( i ); if( wizard->GetObject() == aObject ) { m_FootprintWizards.erase( m_FootprintWizards.begin() + i ); delete wizard; return true; } } return false; }
pcbnew/class_footprint_wizard.h +40 −27 Original line number Diff line number Diff line Loading @@ -39,10 +39,9 @@ * derive */ class FOOTPRINT_WIZARD { public: FOOTPRINT_WIZARD() {} ~FOOTPRINT_WIZARD() {} virtual ~FOOTPRINT_WIZARD(); /** * Function GetName Loading Loading @@ -120,6 +119,13 @@ public: */ virtual MODULE* GetModule() = 0; /** * Function GetObject * This method gets the pointer to the object from where this wizard constructs * @return it's a void pointer, as it could be a PyObject or any other */ virtual void* GetObject() = 0; /** * Function register_wizard * It's the standard method of a "FOOTPRINT_WIZARD" to register itself into Loading @@ -127,7 +133,6 @@ public: * */ void register_wizard(); }; Loading @@ -138,7 +143,6 @@ private: * FOOTPRINT_WIZARD system wide static list */ static std::vector<FOOTPRINT_WIZARD*> m_FootprintWizards; public: /** Loading @@ -151,6 +155,17 @@ public: */ static void register_wizard( FOOTPRINT_WIZARD* aWizard ); /** * Function deregister_object * Anyone calls this method to deregister an object which builds a wizard, * it will lookup on the vector calling GetObject until find, then removed * and deleted * * @param aObject is the footprint wizard object to be deregistered * */ static bool deregister_object( void* aObject ); /** * Function GetWizard * @param aName is the footprint wizard name Loading @@ -172,8 +187,6 @@ public: * @return the number of wizards available into the system */ static int GetSize(); }; #endif /* PCBNEW_FOOTPRINT_WIZARDS_H */
pcbnew/footprint_wizard.cpp +44 −13 Original line number Diff line number Diff line Loading @@ -94,13 +94,15 @@ void FOOTPRINT_WIZARD_FRAME::DisplayWizardInfos() void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() { if( m_FootprintWizard == NULL ) FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); if( !footprintWizard ) return; SetCurItem( NULL ); // Delete the current footprint GetBoard()->m_Modules.DeleteAll(); MODULE* m = m_FootprintWizard->GetModule(); MODULE* m = footprintWizard->GetModule(); if( m ) { Loading @@ -112,18 +114,37 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() } else { printf( "m_FootprintWizard->GetModule() returns NULL\n" ); printf( "footprintWizard->GetModule() returns NULL\n" ); } m_canvas->Refresh(); } FOOTPRINT_WIZARD* FOOTPRINT_WIZARD_FRAME::GetMyWizard() { if( m_wizardName.Length()==0 ) return NULL; FOOTPRINT_WIZARD* footprintWizard = FOOTPRINT_WIZARDS::GetWizard( m_wizardName ); if( !footprintWizard ) { wxMessageBox( _( "Couldn't reload footprint wizard" ) ); return NULL; } return footprintWizard; } MODULE* FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint() { if( m_FootprintWizard ) FOOTPRINT_WIZARD* footprintWizard = FOOTPRINT_WIZARDS::GetWizard( m_wizardName ); if( footprintWizard ) { return m_FootprintWizard->GetModule(); return footprintWizard->GetModule(); } else { Loading @@ -139,12 +160,17 @@ void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard() selectWizard->ShowModal(); m_FootprintWizard = selectWizard->GetWizard(); FOOTPRINT_WIZARD* footprintWizard = selectWizard->GetWizard(); if( m_FootprintWizard ) if( footprintWizard ) { m_wizardName = m_FootprintWizard->GetName(); m_wizardDescription = m_FootprintWizard->GetDescription(); m_wizardName = footprintWizard->GetName(); m_wizardDescription = footprintWizard->GetDescription(); } else { m_wizardName = wxT( "" ); m_wizardDescription = wxT( "" ); } ReloadFootprint(); Loading @@ -169,12 +195,17 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) { int page = m_PageList->GetSelection(); FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); if( !footprintWizard ) return; if( page<0 ) return; int n = m_ParameterGrid->GetNumberRows(); wxArrayString arr; wxArrayString ptList = m_FootprintWizard->GetParameterTypes( page ); wxArrayString ptList = footprintWizard->GetParameterTypes( page ); for( int i = 0; i<n; i++ ) { Loading Loading @@ -205,7 +236,7 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) arr.Add( value ); } wxString res = m_FootprintWizard->SetParameterValues( page, arr ); wxString res = footprintWizard->SetParameterValues( page, arr ); ReloadFootprint(); DisplayWizardInfos(); Loading
pcbnew/footprint_wizard_frame.cpp +40 −34 Original line number Diff line number Diff line Loading @@ -81,6 +81,8 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME ) EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList ) EVT_GRID_CMD_CELL_CHANGE( ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ParametersUpdated ) EVT_GRID_CMD_EDITOR_HIDDEN( ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ParametersUpdated ) EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset ) END_EVENT_TABLE() Loading Loading @@ -131,7 +133,6 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( FOOTPRINT_EDIT_FRAME* parent, // SetIcon( icon ); m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr; m_FootprintWizard = NULL; m_PageList = NULL; m_ParameterGrid = NULL; m_PageListWindow = NULL; Loading Loading @@ -386,15 +387,18 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() if( m_PageList == NULL ) return; if( m_FootprintWizard == NULL ) FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); if( !footprintWizard ) return; m_PageList->Clear(); int max_page = m_FootprintWizard->GetNumParameterPages(); int max_page = footprintWizard->GetNumParameterPages(); for( int i = 0; i<max_page; i++ ) { wxString name = m_FootprintWizard->GetParameterPageName( i ); wxString name = footprintWizard->GetParameterPageName( i ); m_PageList->Append( name ); } Loading @@ -417,7 +421,9 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() if( m_ParameterGrid == NULL ) return; if( m_FootprintWizard == NULL ) FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); if( footprintWizard == NULL ) return; int page = m_PageList->GetSelection(); Loading @@ -435,9 +441,9 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() m_ParameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Get the list of names, values, and types wxArrayString fpList = m_FootprintWizard->GetParameterNames( page ); wxArrayString fvList = m_FootprintWizard->GetParameterValues( page ); wxArrayString ptList = m_FootprintWizard->GetParameterTypes( page ); wxArrayString fpList = footprintWizard->GetParameterNames( page ); wxArrayString fvList = footprintWizard->GetParameterValues( page ); wxArrayString ptList = footprintWizard->GetParameterTypes( page ); // Dimension the wxGrid m_ParameterGrid->DeleteRows( 0, m_ParameterGrid->GetNumberRows() ); Loading
pcbnew/footprint_wizard_frame.h +38 −34 Original line number Diff line number Diff line Loading @@ -60,8 +60,6 @@ private: // Flags wxSemaphore* m_Semaphore; // < != NULL if the frame must emulate a modal dialog wxString m_configPath; // < subpath for configuration FOOTPRINT_WIZARD* m_FootprintWizard; protected: wxString m_wizardName; // < name of the current wizard wxString m_wizardDescription; // < description of the wizard Loading Loading @@ -118,6 +116,12 @@ private: */ void ReloadFootprint(); /** * Function GetMyWizard * Reloads the wizard by name */ FOOTPRINT_WIZARD* GetMyWizard(); void Process_Special_Functions( wxCommandEvent& event ); Loading