2013-03-15 13:27:18 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <miguelangel@ajo.es>
|
2021-06-04 13:04:30 +00:00
|
|
|
* Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-03-15 13:27:18 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
/**
|
2018-01-30 19:23:06 +00:00
|
|
|
* @file footprint_wizard.h
|
|
|
|
* @brief Class FOOTPRINT_WIZARD and FOOTPRINT_WIZARDS
|
2012-05-09 17:37:25 +00:00
|
|
|
*/
|
|
|
|
|
2018-01-30 19:23:06 +00:00
|
|
|
#ifndef FOOTPRINT_WIZARD_H
|
|
|
|
#define FOOTPRINT_WIZARD_H
|
|
|
|
|
2012-05-09 17:37:25 +00:00
|
|
|
#include <vector>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-05-09 17:37:25 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
// Allowable parameter types for PCB wizards
|
2022-02-04 22:44:59 +00:00
|
|
|
const wxString WIZARD_PARAM_UNITS_MM = wxT( "mm" ); // Millimetres
|
|
|
|
const wxString WIZARD_PARAM_UNITS_MILS = wxT( "mils" ); // Mils / thou
|
|
|
|
const wxString WIZARD_PARAM_UNITS_FLOAT = wxT( "float" ); // Floating point (dimensionless)
|
|
|
|
const wxString WIZARD_PARAM_UNITS_INTEGER = wxT( "integer" ); // Integer (dimensionless)
|
|
|
|
const wxString WIZARD_PARAM_UNITS_BOOL = wxT( "bool" ); // Boolean option
|
|
|
|
const wxString WIZARD_PARAM_UNITS_RADIANS = wxT( "radians" ); // Angle (radians)
|
|
|
|
const wxString WIZARD_PARAM_UNITS_DEGREES = wxT( "degrees" ); // Angle (degrees)
|
|
|
|
const wxString WIZARD_PARAM_UNITS_PERCENT = wxT( "%" ); // Percent (0% -> 100%)
|
|
|
|
const wxString WIZARD_PARAM_UNITS_STRING = wxT( "string" ); // String
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2012-07-06 19:10:55 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* The parent class from where any footprint wizard class must derive.
|
2020-11-13 11:17:15 +00:00
|
|
|
*/
|
2012-05-09 17:37:25 +00:00
|
|
|
class FOOTPRINT_WIZARD
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FOOTPRINT_WIZARD() {}
|
2013-03-16 03:27:48 +00:00
|
|
|
virtual ~FOOTPRINT_WIZARD();
|
2012-09-12 17:28:55 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return the name of the wizard.
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual wxString GetName() = 0;
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2012-06-27 21:19:19 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return an svg image of the wizard to be rendered.
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual wxString GetImage() = 0;
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2012-06-27 21:19:19 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return a description of the footprint wizard.
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual wxString GetDescription() = 0;
|
2012-09-12 17:28:55 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @return the number of parameter pages that this wizard will show to the user.
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual int GetNumParameterPages() = 0;
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2012-06-27 21:19:19 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aPage is the page we want the name of.
|
|
|
|
* @return a string with the page name.
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual wxString GetParameterPageName( int aPage ) = 0;
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2012-06-27 21:19:19 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aPage is the page we want the parameter names of.
|
|
|
|
* @return an array string with the parameter names on a certain page.
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual wxArrayString GetParameterNames( int aPage ) = 0;
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2012-07-22 22:23:17 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aPage is the page we want the parameter types of.
|
2012-07-22 22:23:17 +00:00
|
|
|
* @return an array string with the parameter types on a certain page
|
2021-06-04 13:04:30 +00:00
|
|
|
* "IU" for internal units, "UNITS" for units (0,1,2,3...,N).
|
2012-07-22 22:23:17 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual wxArrayString GetParameterTypes( int aPage ) = 0;
|
2012-09-12 17:28:55 +00:00
|
|
|
|
|
|
|
|
2012-06-27 21:19:19 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aPage is the page we want the parameter values of.
|
|
|
|
* @return an array of parameter values.
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual wxArrayString GetParameterValues( int aPage ) = 0;
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2012-06-27 21:19:19 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @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.
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual wxArrayString GetParameterErrors( int aPage ) = 0;
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aPage is the page we want to know the hints of.
|
|
|
|
* @return an array of hints (if any) for the parameters, empty string for no hints.
|
2017-01-03 15:01:47 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual wxArrayString GetParameterHints( int aPage ) = 0;
|
2017-01-03 15:01:47 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aPage is the page we want to know the designators of.
|
|
|
|
* @return an array of designators (blank strings for no designators.
|
2017-01-03 15:01:47 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual wxArrayString GetParameterDesignators( int aPage ) = 0;
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2012-06-27 21:19:19 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @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.
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual wxString SetParameterValues( int aPage, wxArrayString& aValues ) = 0;
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Reset all wizard parameters to default values.
|
2017-01-03 15:01:47 +00:00
|
|
|
*/
|
|
|
|
virtual void ResetParameters() = 0;
|
|
|
|
|
2012-09-12 17:28:55 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Build the footprint itself and returns it to the caller function.
|
|
|
|
*
|
|
|
|
* @param aMessage is storage for messages (if any) generated by the footprint generator.
|
|
|
|
* @return a footprint built from the parameters given to the class.
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
virtual FOOTPRINT* GetFootprint( wxString* aMessage ) = 0;
|
2013-03-16 03:27:48 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Get the object from where this wizard constructs.
|
|
|
|
*
|
|
|
|
* @return it's a void pointer as it could be a PyObject or any other.
|
2013-03-16 03:27:48 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
virtual void* GetObject() = 0;
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2012-06-27 21:19:19 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* The standard method of a "FOOTPRINT_WIZARD" to register itself into
|
2018-01-30 19:23:06 +00:00
|
|
|
* the FOOTPRINT_WIZARD_LIST singleton manager
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2020-11-13 11:17:15 +00:00
|
|
|
void register_wizard();
|
2012-05-09 17:37:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-01-30 19:23:06 +00:00
|
|
|
class FOOTPRINT_WIZARD_LIST
|
2012-05-09 17:37:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2012-06-27 21:19:19 +00:00
|
|
|
/**
|
|
|
|
* A footprint wizard calls this static method when it wants to register itself
|
2021-06-04 13:04:30 +00:00
|
|
|
* into the system wizards.
|
|
|
|
*
|
|
|
|
* @note If it is already registered, this function does nothing if an existing wizard
|
|
|
|
* with the same name exists, this existing wizard will be unregistered.
|
|
|
|
*
|
|
|
|
* @param aWizard is the footprint wizard to be registered.
|
2012-06-27 21:19:19 +00:00
|
|
|
*/
|
2013-03-16 03:27:48 +00:00
|
|
|
static void register_wizard( FOOTPRINT_WIZARD* aWizard );
|
|
|
|
|
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* Unregister an object which builds a wizard.
|
|
|
|
*
|
|
|
|
* Lookup in the vector calling GetObject until find, then removed and deleted.
|
2013-03-16 03:27:48 +00:00
|
|
|
*
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aObject is the footprint wizard object to be unregistered.
|
2013-03-16 03:27:48 +00:00
|
|
|
*/
|
|
|
|
static bool deregister_object( void* aObject );
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2012-06-27 21:19:19 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aName is the footprint wizard name.
|
2012-06-27 21:19:19 +00:00
|
|
|
* @return a wizard object by it's name or NULL if it isn't available.
|
|
|
|
*/
|
2017-09-23 09:20:10 +00:00
|
|
|
static FOOTPRINT_WIZARD* GetWizard( const wxString& aName );
|
2012-09-12 17:28:55 +00:00
|
|
|
|
2012-06-27 21:19:19 +00:00
|
|
|
/**
|
2021-06-04 13:04:30 +00:00
|
|
|
* @param aIndex is the wizard index in list.
|
2012-06-27 21:19:19 +00:00
|
|
|
* @return a wizard object by it's number or NULL if it isn't available.
|
|
|
|
*/
|
2013-03-16 03:27:48 +00:00
|
|
|
static FOOTPRINT_WIZARD* GetWizard( int aIndex );
|
2012-09-12 17:28:55 +00:00
|
|
|
|
|
|
|
/**
|
2012-06-27 21:19:19 +00:00
|
|
|
* @return the number of wizards available into the system
|
|
|
|
*/
|
2015-04-26 16:32:16 +00:00
|
|
|
static int GetWizardsCount();
|
2021-06-04 13:04:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* FOOTPRINT_WIZARD system wide static list
|
|
|
|
*/
|
|
|
|
static std::vector<FOOTPRINT_WIZARD*> m_FootprintWizards;
|
2012-05-09 17:37:25 +00:00
|
|
|
};
|
|
|
|
|
2013-03-16 03:27:48 +00:00
|
|
|
#endif /* PCBNEW_FOOTPRINT_WIZARDS_H */
|