Commit 08af5772 authored by Miguel Angel Ajo's avatar Miguel Angel Ajo
Browse files

code cleanup and comments

parent db427cb2
Loading
Loading
Loading
Loading
+0 −12
Original line number Original line Diff line number Diff line
@@ -47,18 +47,6 @@ void FOOTPRINT_WIZARDS::register_wizard(FOOTPRINT_WIZARD *aWizard)
    
    
    printf("Registered footprint wizard '%s'\n",(const char*)name.mb_str() );
    printf("Registered footprint wizard '%s'\n",(const char*)name.mb_str() );
    
    
#if 0 
    /* just to test if it works correctly */
    int pages = fw->GetNumParameterPages();
    printf("             %d pages\n",pages);
    
    for (int n=0; n<pages; n++)
    {
        printf("                      page %d->'%s'\n",n,
            (const char*)fw->GetParameterPageName(n).mb_str());
    }
#endif    
    
    
    
}
}


+90 −0
Original line number Original line Diff line number Diff line
@@ -16,16 +16,80 @@ class FOOTPRINT_WIZARD
public:
public:
    FOOTPRINT_WIZARD() {}
    FOOTPRINT_WIZARD() {}
    ~FOOTPRINT_WIZARD() {}
    ~FOOTPRINT_WIZARD() {}
    
    /** 
     * Function GetName
     * @return the name of the wizard
     */
    virtual wxString      GetName()=0;
    virtual wxString      GetName()=0;
    
    /**
     * Function GetImage
     * @return an svg image of the wizard to be rendered
     */
    virtual wxString      GetImage()=0;  
    virtual wxString      GetImage()=0;  
    
    /**
     * Function GetDescription
     * @return a description of the footprint wizard 
     */
    virtual wxString      GetDescription()=0;
    virtual wxString      GetDescription()=0;
    
    /** 
     * Function GetNumParameterPages
     * @return the number of parameter pages that this wizard will show to the user
     */
    virtual int           GetNumParameterPages()=0;
    virtual int           GetNumParameterPages()=0;
    
    /**
     * Function GetParameterPageName
     * @param aPage is the page we want the name of
     * @return a string with the page name
     */
    virtual wxString      GetParameterPageName(int aPage)=0;
    virtual wxString      GetParameterPageName(int aPage)=0;
    
    /**
     * Function GetParameterNames
     * @param aPage is the page we want the parameter names of
     * @return an array string with the parameter names on a certain page 
     */
    virtual wxArrayString GetParameterNames(int aPage)=0;
    virtual wxArrayString GetParameterNames(int aPage)=0;
    
    /**
     * Function GetParameterValues
     * @param aPage is the page we want the parameter values of
     * @return an array of parameter values
     */
    virtual wxArrayString GetParameterValues(int aPage)=0;
    virtual wxArrayString GetParameterValues(int aPage)=0;
    
    /**
     * Function GetParameterErrors
     * @param aPAge is the page we want to know the errors of
     * @return an array of errors (if any) for the parameters, empty strings for OK parameters
     */
    virtual wxArrayString GetParameterErrors(int aPage)=0;
    virtual wxArrayString GetParameterErrors(int aPage)=0;
    
    /**
     * Function SetParameterValues
     * @param aPage is the page we want to set the parameters in
     * @param aValues are the values we want to set into the parameters
     * @return an array of parameter values
     */
    virtual wxString      SetParameterValues(int aPage,wxArrayString& aValues)=0;
    virtual wxString      SetParameterValues(int aPage,wxArrayString& aValues)=0;
    
    /** 
     * Function GetModule
     * This method builds the module itself and returns it to the caller function 
     * @return  PCB module built from the parameters given to the class
     */
    virtual MODULE       *GetModule()=0;
    virtual MODULE       *GetModule()=0;
    
    /**
     * Function register_wizard
     * It's the standard method of a "FOOTPRINT_WIZARD" to register itself into
     * the FOOTPRINT_WIZARDS singleton manager
     * 
     */
    void register_wizard();
    void register_wizard();
        
        
};
};
@@ -37,9 +101,35 @@ private:
    static    std::vector<FOOTPRINT_WIZARD*>  m_FootprintWizards;
    static    std::vector<FOOTPRINT_WIZARD*>  m_FootprintWizards;


public:
public:
    
    /**
     * Function register_wizard
     * A footprint wizard calls this static method when it wants to register itself
     * into the system wizards
     * 
     * @param aWizard is the footprint wizard to be registered
     * 
     */
    static void register_wizard(FOOTPRINT_WIZARD *wizard);
    static void register_wizard(FOOTPRINT_WIZARD *wizard);
    
    /**
     * Function GetWizard
     * @return a wizard object by it's name or NULL if it isn't available.
     * 
     */
    static FOOTPRINT_WIZARD* GetWizard(wxString aName);
    static FOOTPRINT_WIZARD* GetWizard(wxString aName);
    
    /**
     * Function GetWizard
     * @return a wizard object by it's number or NULL if it isn't available.
     * 
     */
    static FOOTPRINT_WIZARD* GetWizard(int aIndex);
    static FOOTPRINT_WIZARD* GetWizard(int aIndex);
    
    /** 
     * Function GetSize
     * @return the number of wizards available into the system
     */
    static int GetSize();
    static int GetSize();


};
};
+10 −3
Original line number Original line Diff line number Diff line
/**
/**
 * @file footprint wizard.cpp
 * @file footprint_wizard.cpp
 */
 */


#include <fctsys.h>
#include <fctsys.h>
@@ -49,12 +49,18 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event )
    }
    }
}
}



/* Function OnLeftClick
 * Captures a left click event in the dialog
 * 
 */
void FOOTPRINT_WIZARD_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
void FOOTPRINT_WIZARD_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
{
}
}



/* Function OnRightClick
 * Captures a right click event in the dialog 
 * 
 */
bool FOOTPRINT_WIZARD_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
bool FOOTPRINT_WIZARD_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
{
{
    return true;
    return true;
@@ -163,6 +169,7 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event )
 * Function RedrawActiveWindow
 * Function RedrawActiveWindow
 * Display the current selected component.
 * Display the current selected component.
 * If the component is an alias, the ROOT component is displayed
 * If the component is an alias, the ROOT component is displayed
 * 
*/
*/
void FOOTPRINT_WIZARD_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
void FOOTPRINT_WIZARD_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
{
+29 −4
Original line number Original line Diff line number Diff line
/*
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 * This program source code file is part of KiCad, a free EDA CAD application.
 * 
 * 
 * Copyright (C) 2012 Miguel Angel Ajo Pelayo <miguelangel@nbee.es>
 * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras
 * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras
 * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
 * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
@@ -99,7 +100,10 @@ static wxAcceleratorEntry accels[] =


#define EXTRA_BORDER_SIZE 2
#define EXTRA_BORDER_SIZE 2



/* Function FOOTPRINT_WIZARD_FRAME
 * it's the constructor for the footprint wizard frame, it creates everything inside
 * 
 */
FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* semaphore ) :
FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* semaphore ) :
    PCB_BASE_FRAME( parent, MODULE_VIEWER_FRAME, _( "Footprint Wizard" ),
    PCB_BASE_FRAME( parent, MODULE_VIEWER_FRAME, _( "Footprint Wizard" ),
                    wxDefaultPosition, wxDefaultSize )
                    wxDefaultPosition, wxDefaultSize )
@@ -259,6 +263,10 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
}
}




/* Function OnCloseWindow
 * Handles the close event, saving settings an destroying or releasing a semaphore from caller
 * 
 */
void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
{
    SaveSettings();
    SaveSettings();
@@ -277,6 +285,9 @@ void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
}




/* Function OnSashDrag
 * handles the horizontal separator (sash) drag, updating the pagelist or parameter list 
 */
void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event )
void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event )
{
{
    if( event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE )
    if( event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE )
@@ -309,6 +320,10 @@ void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event )
}
}




/* Function OnSize
 * It handles a dialog resize event, asking for an update 
 * 
 */
void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
{
{
    if( m_auimgr.GetManagedWindow() )
    if( m_auimgr.GetManagedWindow() )
@@ -317,14 +332,20 @@ void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
    SizeEv.Skip();
    SizeEv.Skip();
}
}



/* Function OnSetRelativeOffset
 * Updates the cursor position and the status bar 
 * 
 */
void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
{
{
    GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition();
    GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition();
    UpdateStatusBar();
    UpdateStatusBar();
}
}



/* Function ReCreatePageList
 * It recreates the list of pages for a new loaded wizard
 * 
 */
void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
{
{
    if( m_PageList == NULL )
    if( m_PageList == NULL )
@@ -349,6 +370,10 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
    m_canvas->Refresh();
    m_canvas->Refresh();
}
}


/* Function ReCreateParameterList
 * It creates the parameter grid for a certain wizard page of the current wizard
 * 
 */


void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
{
{
+3 −18
Original line number Original line Diff line number Diff line
* Implement iterator for NETCLASSES (NETCLASS) see class_netclass.h
* finish wizard implementation

* cleanup
* Saving modules to library (in librairi.cpp)
* better build script helpers
 
     see:
        - void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewModulesOnly )


	- bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
                                             MODULE*         aModule,
                                             bool            aOverwrite,
                                             bool            aDisplayDialog )
   
   What do we do about this?, ask Dick, these functions should be transplanted
   to kicad plugin?
   

     void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewModulesOnly )


Loading