2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
#ifndef _TEMPLATE_FIELDNAME_H_
|
|
|
|
#define _TEMPLATE_FIELDNAME_H_
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <richio.h>
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <template_fieldnames_lexer.h>
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2010-08-09 02:03:16 +00:00
|
|
|
class TEMPLATE_FIELDNAMES_LEXER;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enum NumFieldType
|
|
|
|
* is the set of all field indices assuming an array like sequence that a
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
* SCH_COMPONENT or LIB_PART can hold.
|
2010-06-17 16:30:10 +00:00
|
|
|
* The first fields are called fixed fields and the quantity of them is
|
|
|
|
* given by MANDATORY_FIELDS. After that come an unlimited number of
|
|
|
|
* user defined fields, only some of which have indices defined here.
|
|
|
|
*/
|
|
|
|
enum NumFieldType {
|
|
|
|
REFERENCE = 0, ///< Field Reference of part, i.e. "IC21"
|
|
|
|
VALUE, ///< Field Value of part, i.e. "3.3K"
|
|
|
|
FOOTPRINT, ///< Field Name Module PCB, i.e. "16DIP300"
|
|
|
|
DATASHEET, ///< name of datasheet
|
|
|
|
|
2010-07-31 15:48:11 +00:00
|
|
|
/// The first 4 are mandatory, and must be instantiated in SCH_COMPONENT
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
/// and LIB_PART constructors
|
2010-07-31 15:48:11 +00:00
|
|
|
MANDATORY_FIELDS,
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
FIELD1 = MANDATORY_FIELDS,
|
|
|
|
FIELD2,
|
|
|
|
FIELD3,
|
|
|
|
FIELD4,
|
|
|
|
FIELD5,
|
|
|
|
FIELD6,
|
|
|
|
FIELD7,
|
2010-10-04 12:58:07 +00:00
|
|
|
FIELD8
|
2010-06-17 16:30:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Struct TEMPLATE_FIELDNAME
|
|
|
|
* holds a name of a component's field, field value, and default visibility.
|
|
|
|
* Template fieldnames are wanted fieldnames for use in the symbol/component
|
|
|
|
* property editors.
|
|
|
|
*/
|
|
|
|
struct TEMPLATE_FIELDNAME
|
|
|
|
{
|
|
|
|
wxString m_Name; ///< The field name
|
|
|
|
wxString m_Value; ///< The default value or empty
|
|
|
|
bool m_Visible; ///< If first appearance of the field's editor has as visible.
|
|
|
|
|
|
|
|
TEMPLATE_FIELDNAME() :
|
|
|
|
m_Visible( false )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TEMPLATE_FIELDNAME( const wxString& aName ) :
|
|
|
|
m_Name( aName ),
|
|
|
|
m_Visible( false )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-09-16 19:34:52 +00:00
|
|
|
TEMPLATE_FIELDNAME( const TEMPLATE_FIELDNAME& ref )
|
|
|
|
{
|
|
|
|
m_Name = ref.m_Name;
|
|
|
|
m_Value = ref.m_Value;
|
|
|
|
m_Visible = ref.m_Visible;
|
|
|
|
}
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/**
|
|
|
|
* Function Format
|
|
|
|
* serializes this object out as text into the given OUTPUTFORMATTER.
|
|
|
|
*/
|
2010-11-09 15:45:11 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Parse
|
|
|
|
* fills this object from information in the input stream \a aSpec, which
|
2010-08-09 02:03:16 +00:00
|
|
|
* is a TEMPLATE_FIELDNAMES_LEXER. The entire textual element spec is <br>
|
2010-06-17 16:30:10 +00:00
|
|
|
* (field (name _yourfieldname_)(value _yourvalue_) visible)) <br>
|
|
|
|
* The presence of value is optional, the presence of visible is optional.
|
|
|
|
* When this function is called, the input token stream given by \a aSpec
|
|
|
|
* is assumed to be positioned at the '^' in the following example, i.e. just after the
|
|
|
|
* identifying keyword and before the content specifying stuff.<br>
|
|
|
|
* (field ^ (....) )
|
|
|
|
*
|
|
|
|
* @param aSpec is the input token stream of keywords and symbols.
|
|
|
|
*/
|
2010-11-09 15:45:11 +00:00
|
|
|
void Parse( TEMPLATE_FIELDNAMES_LEXER* aSpec ) throw( IO_ERROR );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetDefaultFieldName
|
|
|
|
* returns a default symbol field name for field \a aFieldNdx for all components.
|
|
|
|
* These fieldnames are not modifiable, but template fieldnames are.
|
|
|
|
* @param aFieldNdx The field number index, > 0
|
|
|
|
*/
|
|
|
|
static wxString GetDefaultFieldName( int aFieldNdx );
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES;
|
|
|
|
|
|
|
|
|
|
|
|
class TEMPLATES
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
TEMPLATE_FIELDNAMES m_Fields;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Format
|
|
|
|
* serializes this object out as text into the given OUTPUTFORMATTER.
|
|
|
|
*/
|
2010-11-09 15:45:11 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw( IO_ERROR );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Parse
|
2010-08-09 02:03:16 +00:00
|
|
|
* fills this object from information in the input stream handled by TEMPLATE_FIELDNAMES_LEXER
|
2010-06-17 16:30:10 +00:00
|
|
|
*/
|
2010-11-09 15:45:11 +00:00
|
|
|
void Parse( TEMPLATE_FIELDNAMES_LEXER* in ) throw( IO_ERROR );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function AddTemplateFieldName
|
|
|
|
* inserts or appends a wanted symbol field name into the fieldnames
|
|
|
|
* template. Should be used for any symbol property editor. If the name
|
|
|
|
* already exists, it overwrites the same name.
|
|
|
|
*
|
|
|
|
* @param aFieldName is a full description of the wanted field, and it must not match
|
|
|
|
* any of the default fieldnames.
|
|
|
|
* @return int - the index within the config container at which aFieldName was
|
|
|
|
* added, or -1 if the name is illegal because it matches a default fieldname.
|
|
|
|
*/
|
|
|
|
int AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function DeleteAllTemplateFieldNames
|
|
|
|
* deletes the entire contents.
|
|
|
|
*/
|
|
|
|
void DeleteAllTemplateFieldNames()
|
|
|
|
{
|
|
|
|
m_Fields.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetTemplateFieldName
|
|
|
|
* returns a template fieldnames list for read only access.
|
|
|
|
*/
|
|
|
|
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames()
|
|
|
|
{
|
|
|
|
return m_Fields;
|
|
|
|
}
|
2011-08-30 19:24:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function HasFieldName
|
|
|
|
* checks for \a aName in the the template field name list.
|
|
|
|
*
|
|
|
|
* @param aName A wxString object containing the field name to search for.
|
2011-09-01 12:54:34 +00:00
|
|
|
* @return True if \a aName is found in the list.
|
2011-08-30 19:24:28 +00:00
|
|
|
*/
|
|
|
|
bool HasFieldName( const wxString& aName ) const;
|
2010-06-17 16:30:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _TEMPLATE_FIELDNAME_H_
|