2009-08-19 19:34:03 +00:00
|
|
|
/******************************************/
|
|
|
|
/* Library component object definitions. */
|
|
|
|
/******************************************/
|
2008-12-31 09:27:19 +00:00
|
|
|
|
|
|
|
#ifndef CLASS_LIBENTRY_H
|
|
|
|
#define CLASS_LIBENTRY_H
|
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
#include "dlist.h"
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
#include "classes_body_items.h"
|
|
|
|
#include "class_libentry_fields.h"
|
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
#include <boost/ptr_container/ptr_vector.hpp>
|
|
|
|
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
/* Types for components in libraries
|
|
|
|
* components can be a true component or an alias of a true component.
|
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
enum LibrEntryType
|
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
ROOT, /* This is a true component standard EDA_LibComponentStruct */
|
|
|
|
ALIAS /* This is an alias of a true component */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* values for member .m_Options */
|
2009-09-02 18:12:45 +00:00
|
|
|
enum LibrEntryOptions
|
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
ENTRY_NORMAL, // Libentry is a standard component (real or alias)
|
|
|
|
ENTRY_POWER // Libentry is a power symbol
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
|
|
|
* Base class to describe library components and aliases.
|
|
|
|
*
|
2009-09-02 18:12:45 +00:00
|
|
|
* This class is not to be used directly.
|
2009-08-19 19:34:03 +00:00
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
class LibCmpEntry : public EDA_BaseStruct
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
LibrEntryType Type; /* Type = ROOT;
|
|
|
|
* = ALIAS pour struct LibraryAliasType */
|
2009-08-19 19:34:03 +00:00
|
|
|
LibDrawField m_Name; // name (74LS00 ..) in lib ( = VALUE )
|
2008-12-31 09:27:19 +00:00
|
|
|
wxString m_Doc; /* documentation for info */
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString m_KeyWord; /* keyword list (used to select a group of
|
|
|
|
* components by keyword) */
|
2009-08-19 19:34:03 +00:00
|
|
|
wxString m_DocFile; /* Associate doc file name */
|
2008-12-31 09:27:19 +00:00
|
|
|
LibrEntryOptions m_Options; // special features (i.e. Entry is a POWER)
|
|
|
|
|
|
|
|
public:
|
|
|
|
LibCmpEntry( LibrEntryType CmpType, const wxChar* CmpName );
|
|
|
|
virtual ~LibCmpEntry();
|
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
|
|
|
return wxT( "LibCmpEntry" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-08-27 11:41:56 +00:00
|
|
|
* Write the entry document information to a FILE in "*.dcm" format.
|
2009-08-19 19:34:03 +00:00
|
|
|
*
|
2008-12-31 09:27:19 +00:00
|
|
|
* @param aFile The FILE to write to.
|
2009-08-19 19:34:03 +00:00
|
|
|
*
|
2008-12-31 09:27:19 +00:00
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
*/
|
|
|
|
bool SaveDoc( FILE* aFile );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Case insensitive comparison of the component entry name.
|
|
|
|
*/
|
|
|
|
bool operator==( const wxChar* name ) const;
|
|
|
|
bool operator!=( const wxChar* name ) const
|
|
|
|
{
|
|
|
|
return !( *this == name );
|
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
typedef boost::ptr_vector< LibCmpEntry > LIB_ENTRY_LIST;
|
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
extern bool operator<( const LibCmpEntry& item1, const LibCmpEntry& item2 );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
extern int LibraryEntryCompare( const LibCmpEntry* LE1,
|
|
|
|
const LibCmpEntry* LE2 );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
|
|
|
* Library component object definition.
|
|
|
|
*
|
|
|
|
* A library component object is typically save and loaded in a component
|
|
|
|
* library file (.lib). Library components are different from schematic
|
|
|
|
* components.
|
|
|
|
*/
|
2008-12-31 09:27:19 +00:00
|
|
|
class EDA_LibComponentStruct : public LibCmpEntry
|
|
|
|
{
|
|
|
|
public:
|
2009-04-05 20:49:15 +00:00
|
|
|
LibDrawField m_Prefix; /* Prefix ( U, IC ... ) = REFERENCE */
|
|
|
|
wxArrayString m_AliasList; /* ALIAS list for the component */
|
|
|
|
wxArrayString m_FootprintList; /* list of suitable footprint names
|
|
|
|
* for the component (wildcard names
|
|
|
|
* accepted) */
|
|
|
|
int m_UnitCount; /* Units (or sections) per package */
|
2009-08-19 19:34:03 +00:00
|
|
|
bool m_UnitSelectionLocked; /* True if units are different
|
2009-04-05 20:49:15 +00:00
|
|
|
* and their selection is
|
|
|
|
* locked (i.e. if part A cannot
|
|
|
|
* be automatically changed in
|
|
|
|
* part B */
|
|
|
|
int m_TextInside; /* if 0: pin name drawn on the pin
|
|
|
|
* itself if > 0 pin name drawn inside
|
|
|
|
* the component, with a distance of
|
|
|
|
* m_TextInside in mils */
|
2008-12-31 09:27:19 +00:00
|
|
|
bool m_DrawPinNum;
|
|
|
|
bool m_DrawPinName;
|
2009-08-19 19:34:03 +00:00
|
|
|
DLIST<LibDrawField> m_Fields; /* Auxiliary Field list (id >= 2 ) */
|
2009-04-05 20:49:15 +00:00
|
|
|
LibEDA_BaseStruct* m_Drawings; /* How to draw this part */
|
|
|
|
long m_LastDate; // Last change Date
|
2008-12-31 09:27:19 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
|
|
|
return wxT( "EDA_LibComponentStruct" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EDA_LibComponentStruct( const wxChar* CmpName );
|
|
|
|
~EDA_LibComponentStruct();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
EDA_Rect GetBoundaryBox( int Unit, int Convert );
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
void SortDrawItems();
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
bool SaveDateAndTime( FILE* ExportFile );
|
|
|
|
bool LoadDateAndTime( char* Line );
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
/**
|
2009-08-19 19:34:03 +00:00
|
|
|
* Write the data structures out to a FILE in "*.lib" format.
|
|
|
|
*
|
|
|
|
* @param aFile - The FILE to write to.
|
|
|
|
*
|
2008-12-31 09:27:19 +00:00
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
bool Save( FILE* aFile );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load component definition from file.
|
|
|
|
*
|
2009-08-19 19:34:03 +00:00
|
|
|
* @param file - File descriptor of file to load form.
|
2009-04-05 20:49:15 +00:00
|
|
|
* @param line - The first line of the component definition.
|
|
|
|
* @param lineNum - The current line number in the file.
|
2009-08-19 19:34:03 +00:00
|
|
|
* @param errorMsg - Description of error on load failure.
|
2009-04-05 20:49:15 +00:00
|
|
|
*
|
|
|
|
* @return bool - Result of the load, false if there was an error.
|
|
|
|
*/
|
|
|
|
bool Load( FILE* file, char* line, int* lineNum, wxString& errorMsg );
|
|
|
|
bool LoadField( char* line, wxString& errorMsg );
|
|
|
|
bool LoadDrawEntries( FILE* f, char* line,
|
|
|
|
int* lineNum, wxString& errorMsg );
|
|
|
|
bool LoadAliases( char* line, wxString& Error );
|
|
|
|
bool LoadFootprints( FILE* file, char* line,
|
|
|
|
int* lineNum, wxString& errorMsg );
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
|
|
|
* Initialize fields from a vector of fields.
|
|
|
|
*
|
|
|
|
* @param aFields - a std::vector <LibDrawField> to import.
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
void SetFields( const std::vector <LibDrawField> aFields );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw component.
|
|
|
|
*
|
|
|
|
* @param panel - Window to draw on.
|
|
|
|
* @param dc - Device context to draw on.
|
|
|
|
* @param offset - Position to component.
|
|
|
|
* @param multi - Component unit if multiple parts per component.
|
|
|
|
* @param convert - Component conversion (DeMorgan) if available.
|
|
|
|
* @param drawMode - Device context drawing mode, see wxDC.
|
|
|
|
* @param color - Color to draw component.
|
|
|
|
* @param transformMatrix - Cooridinate adjustment settings.
|
|
|
|
* @param showPinText - Show pin text if true.
|
|
|
|
* @param drawFields - Draw field text if true otherwise just draw
|
|
|
|
* body items.
|
|
|
|
* @param onlySelected - Draws only the body items that are selected.
|
|
|
|
* Used for block move redraws.
|
|
|
|
*/
|
|
|
|
void Draw( WinEDA_DrawPanel* panel, wxDC* dc, const wxPoint& offset,
|
|
|
|
int multi, int convert, int drawMode, int color = -1,
|
|
|
|
const int transformMatrix[2][2] = DefaultTransformMatrix,
|
|
|
|
bool showPinText = true, bool drawFields = true,
|
|
|
|
bool onlySelected = false );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove draw item from list.
|
|
|
|
*
|
|
|
|
* @param item - Draw item to remove from list.
|
|
|
|
* @param panel - Panel to remove part from.
|
|
|
|
* @param dc - Device context to remove part from.
|
|
|
|
*/
|
|
|
|
void RemoveDrawItem( LibEDA_BaseStruct* item,
|
|
|
|
WinEDA_DrawPanel* panel = NULL,
|
|
|
|
wxDC* dc = NULL );
|
2008-12-31 09:27:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
|
|
|
* Component library alias object definition.
|
|
|
|
*
|
|
|
|
* Component aliases are not really components. They are references
|
|
|
|
* to an actual component object.
|
|
|
|
*
|
|
|
|
* @todo Alias objects should really be defined as children of a component
|
|
|
|
* object not as children of a library object. This would greatly
|
2009-09-02 18:12:45 +00:00
|
|
|
* simplify searching for components in libraries.
|
2009-08-19 19:34:03 +00:00
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
class EDA_LibCmpAliasStruct : public LibCmpEntry
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxString m_RootName; /* Root component Part name */
|
|
|
|
|
|
|
|
public:
|
|
|
|
EDA_LibCmpAliasStruct( const wxChar* CmpName, const wxChar* CmpRootName );
|
|
|
|
~EDA_LibCmpAliasStruct();
|
2009-08-19 19:34:03 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
|
|
|
return wxT( "EDA_LibCmpAliasStruct" );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CLASS_LIBENTRY_H
|