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
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
class CMP_LIBRARY;
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
ROOT, /* This is a true component standard LIB_COMPONENT */
|
2008-12-31 09:27:19 +00:00
|
|
|
ALIAS /* This is an alias of a true component */
|
|
|
|
};
|
|
|
|
|
2010-02-17 13:22:25 +00:00
|
|
|
/* 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-09-18 14:56:05 +00:00
|
|
|
class CMP_LIB_ENTRY : public EDA_BaseStruct
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
wxString name;
|
|
|
|
|
|
|
|
/** Library object that entry is attached to. */
|
|
|
|
CMP_LIBRARY* library;
|
|
|
|
|
|
|
|
/** Entry type, either ROOT or ALIAS. */
|
|
|
|
LibrEntryType type;
|
|
|
|
|
|
|
|
wxString description; /* documentation for info */
|
|
|
|
wxString keyWords; /* keyword list (used for search for
|
|
|
|
* components by keyword) */
|
|
|
|
wxString docFileName; /* Associate doc file name */
|
2008-12-31 09:27:19 +00:00
|
|
|
|
|
|
|
public:
|
2009-12-15 21:11:05 +00:00
|
|
|
CMP_LIB_ENTRY( LibrEntryType aType, const wxString& aName,
|
|
|
|
CMP_LIBRARY* aLibrary = NULL );
|
|
|
|
CMP_LIB_ENTRY( CMP_LIB_ENTRY& aEntry, CMP_LIBRARY* aLibrary = NULL );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
virtual ~CMP_LIB_ENTRY();
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
return wxT( "CMP_LIB_ENTRY" );
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
wxString GetLibraryName();
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2010-02-17 13:22:25 +00:00
|
|
|
CMP_LIBRARY* GetLibrary() {return library;}
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual const wxString& GetName() const { return name; }
|
|
|
|
|
|
|
|
virtual void SetName( const wxString& aName ) { name = aName; }
|
|
|
|
|
|
|
|
bool isComponent() { return type == ROOT; }
|
|
|
|
|
|
|
|
bool isAlias() { return type == ALIAS; }
|
|
|
|
|
|
|
|
int GetType() { return type; }
|
|
|
|
|
|
|
|
void SetDescription( const wxString& aDescription )
|
|
|
|
{
|
|
|
|
description = aDescription;
|
|
|
|
}
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
wxString GetDescription() { return description; }
|
|
|
|
|
|
|
|
void SetKeyWords( const wxString& aKeyWords )
|
|
|
|
{
|
|
|
|
keyWords = aKeyWords;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString GetKeyWords() { return keyWords; }
|
|
|
|
|
|
|
|
void SetDocFileName( const wxString& aDocFileName )
|
|
|
|
{
|
|
|
|
docFileName = aDocFileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString GetDocFileName() { return docFileName; }
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
/**
|
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-10-30 19:26:25 +00:00
|
|
|
* @return True if success writing else false.
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
|
|
|
bool SaveDoc( FILE* aFile );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Case insensitive comparison of the component entry name.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool operator==( const wxChar* aName ) const;
|
|
|
|
bool operator!=( const wxChar* aName ) const
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return !( *this == aName );
|
2009-08-27 11:41:56 +00:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
typedef boost::ptr_vector< CMP_LIB_ENTRY > LIB_ENTRY_LIST;
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
extern bool operator<( const CMP_LIB_ENTRY& aItem1, const CMP_LIB_ENTRY& aItem2 );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
extern int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY* aItem2 );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
|
|
|
* Library component object definition.
|
|
|
|
*
|
2010-02-14 18:14:33 +00:00
|
|
|
* Library component object definition.
|
|
|
|
*
|
|
|
|
* A library component object is typically saved and loaded
|
|
|
|
* in a component library file (.lib).
|
|
|
|
* Library components are different from schematic components.
|
2009-08-19 19:34:03 +00:00
|
|
|
*/
|
2009-09-18 14:56:05 +00:00
|
|
|
class LIB_COMPONENT : public CMP_LIB_ENTRY
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-04-05 20:49:15 +00:00
|
|
|
wxArrayString m_AliasList; /* ALIAS list for the component */
|
|
|
|
wxArrayString m_FootprintList; /* list of suitable footprint names
|
|
|
|
* for the component (wildcard names
|
|
|
|
* accepted) */
|
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-10-08 13:19:28 +00:00
|
|
|
long m_LastDate; // Last change Date
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
protected:
|
2010-02-16 17:49:17 +00:00
|
|
|
LibrEntryOptions m_options; // special features (i.e. Entry is a POWER)
|
2009-12-15 21:11:05 +00:00
|
|
|
int unitCount; /* Units (parts) per package */
|
|
|
|
LIB_DRAW_ITEM_LIST drawings; /* How to draw this part */
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
public:
|
2010-02-17 13:22:25 +00:00
|
|
|
/* Offsets used in editing library component,
|
|
|
|
* for handle aliases data in m_AliasListData array string
|
|
|
|
* when editing a library component, aliases data is stored
|
|
|
|
* in m_AliasListData.
|
|
|
|
* 4 strings by alias are stored:
|
|
|
|
* name, doc, keywords and doc filename
|
|
|
|
* these constants are indexes in m_AliasListData
|
|
|
|
* to read/write strings for a given alias
|
|
|
|
*/
|
|
|
|
enum alias_idx
|
|
|
|
{
|
|
|
|
ALIAS_NAME_IDX = 0,
|
|
|
|
ALIAS_DOC_IDX = 1,
|
|
|
|
ALIAS_KEYWORD_IDX = 2,
|
|
|
|
ALIAS_DOC_FILENAME_IDX = 3,
|
|
|
|
ALIAS_NEXT_IDX = 4
|
|
|
|
};
|
|
|
|
private:
|
|
|
|
wxArrayString m_aliasListData; /* ALIAS data (name, doc, keywords and doc filename).
|
|
|
|
* Used only by the component editor LibEdit
|
|
|
|
* to store aliases info during edition
|
|
|
|
* usually void outside the component editor */
|
|
|
|
public:
|
|
|
|
LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary = NULL );
|
|
|
|
LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary = NULL );
|
|
|
|
|
|
|
|
~LIB_COMPONENT();
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
return wxT( "LIB_COMPONENT" );
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual void SetName( const wxString& aName )
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
CMP_LIB_ENTRY::SetName( aName );
|
|
|
|
GetValueField().m_Text = aName;
|
2009-10-21 20:02:25 +00:00
|
|
|
}
|
|
|
|
|
2010-02-17 13:22:25 +00:00
|
|
|
/* accessors to aliases data, used by the component editor, during edition
|
|
|
|
*/
|
|
|
|
/** Function CollectAliasesData
|
|
|
|
* store in m_aliasListData alias data (doc, keywords, docfile)
|
|
|
|
* for each alias found in m_AliasList
|
|
|
|
*/
|
|
|
|
void CollectAliasesData( CMP_LIBRARY* aLibrary );
|
|
|
|
|
|
|
|
/** Function LocateAliasData
|
|
|
|
* @return an index in array string to the alias data (doc, keywords, docfile)
|
|
|
|
* or -1 if not found
|
|
|
|
* @param aAliasName = the alias name
|
|
|
|
* @param aCreateIfNotExist = true if the alias data must be created, when not exists
|
|
|
|
*/
|
|
|
|
int LocateAliasData( const wxString & aAliasName, bool aCreateIfNotExist = false);
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2010-02-17 13:22:25 +00:00
|
|
|
/** Function GetAliasDataDoc
|
|
|
|
* @param aAliasName = the alias name
|
|
|
|
* @return the Doc string
|
|
|
|
*/
|
|
|
|
wxString GetAliasDataDoc( const wxString & aAliasName );
|
|
|
|
|
|
|
|
/** Function GetAliasDataKeyWords
|
|
|
|
* @param aAliasName = the alias name
|
|
|
|
* @return aAliasData = the keywords string
|
|
|
|
*/
|
|
|
|
wxString GetAliasDataKeyWords( const wxString & aAliasName );
|
|
|
|
|
|
|
|
/** Function GetAliasDataDocFileName
|
|
|
|
* @param aAliasName = the alias name
|
|
|
|
* @return the Doc filename string
|
|
|
|
*/
|
|
|
|
wxString GetAliasDataDocFileName( const wxString & aAliasName );
|
|
|
|
|
|
|
|
/** Function SetAliasDataDoc
|
|
|
|
* @param aAliasName = the alias name
|
|
|
|
* @return aAliasData = the Doc string
|
|
|
|
*/
|
|
|
|
void SetAliasDataDoc( const wxString & aAliasName, const wxString & aAliasData );
|
|
|
|
|
|
|
|
/** Function SetAliasDataKeywords
|
|
|
|
* @param aAliasName = the alias name
|
|
|
|
* @param aAliasData = the keywords string
|
|
|
|
*/
|
|
|
|
void SetAliasDataKeywords( const wxString & aAliasName, const wxString & aAliasData );
|
|
|
|
|
|
|
|
/** Function SetAliasDataDocFileName
|
|
|
|
* @param aAliasName = the alias name
|
|
|
|
* @param aAliasData = the Doc filename string
|
|
|
|
*/
|
|
|
|
void SetAliasDataDocFileName( const wxString & aAliasName, const wxString & aAliasData );
|
|
|
|
|
|
|
|
/** Function ClearAliasDataDoc
|
|
|
|
* clear aliases data list
|
|
|
|
*/
|
|
|
|
void ClearAliasDataDoc( ) { m_aliasListData.Clear(); }
|
|
|
|
|
|
|
|
/** Function RemoveAliasData
|
|
|
|
* remove an alias data from list
|
|
|
|
* @param aAliasName = the alias name
|
|
|
|
*/
|
|
|
|
void RemoveAliasData(const wxString & aAliasName );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
EDA_Rect GetBoundaryBox( int aUnit, int aConvert );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
bool SaveDateAndTime( FILE* aFile );
|
|
|
|
bool LoadDateAndTime( char* aLine );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
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.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return True if success writing else false.
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
bool Save( FILE* aFile );
|
|
|
|
|
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Load component definition from /a aFile.
|
2009-04-05 20:49:15 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aFile - File descriptor of file to load form.
|
|
|
|
* @param aLine - The first line of the component definition.
|
|
|
|
* @param aLineNum - The current line number in the file.
|
|
|
|
* @param aErrorMsg - Description of error on load failure.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return True if the load was successful, false if there was an error.
|
2009-04-05 20:49:15 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool Load( FILE* aFile, char* aLine, int* aLineNum, wxString& aErrorMsg );
|
|
|
|
bool LoadField( char* aLine, wxString& aErrorMsg );
|
|
|
|
bool LoadDrawEntries( FILE* aFile, char* aLine,
|
|
|
|
int* aLineNum, wxString& aErrorMsg );
|
|
|
|
bool LoadAliases( char* aLine, wxString& aErrorMsg );
|
|
|
|
bool LoadFootprints( FILE* aFile, char* aLine,
|
|
|
|
int* aLineNum, wxString& aErrorMsg );
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2010-02-16 17:49:17 +00:00
|
|
|
bool isPower() { return m_options == ENTRY_POWER; }
|
|
|
|
bool isNormal() { return m_options == ENTRY_NORMAL; }
|
|
|
|
|
|
|
|
void SetPower() { m_options = ENTRY_POWER; }
|
|
|
|
void SetNormal() { m_options = ENTRY_NORMAL; }
|
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
|
|
|
* Initialize fields from a vector of fields.
|
|
|
|
*
|
2009-10-08 13:19:28 +00:00
|
|
|
* @param aFields - a std::vector <LIB_FIELD> to import.
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2009-10-08 13:19:28 +00:00
|
|
|
void SetFields( const std::vector <LIB_FIELD> aFields );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2009-10-21 20:02:25 +00:00
|
|
|
/**
|
|
|
|
* Return list of field references of component.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aList - List to add field references to.
|
2009-10-21 20:02:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void GetFields( LIB_FIELD_LIST& aList );
|
2009-10-21 20:02:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return pointer to the requested field.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aId - Id of field to return.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return The field if found, otherwise NULL.
|
2009-10-21 20:02:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_FIELD* GetField( int aId );
|
2009-10-21 20:02:25 +00:00
|
|
|
|
|
|
|
/** Return reference to the value field. */
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_FIELD& GetValueField();
|
2009-10-21 20:02:25 +00:00
|
|
|
|
|
|
|
/** Return reference to the reference designator field. */
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_FIELD& GetReferenceField();
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/**
|
|
|
|
* Draw component.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aPanel - Window to draw on.
|
|
|
|
* @param aDc - Device context to draw on.
|
|
|
|
* @param aOffset - Position to component.
|
|
|
|
* @param aMulti - Component unit if multiple parts per component.
|
|
|
|
* @param aConvert - Component conversion (DeMorgan) if available.
|
|
|
|
* @param aDrawMode - Device context drawing mode, see wxDC.
|
|
|
|
* @param aColor - Color to draw component.
|
|
|
|
* @param aTransformMatrix - Coordinate adjustment settings.
|
|
|
|
* @param aShowPinText - Show pin text if true.
|
|
|
|
* @param aDrawFields - Draw field text if true otherwise just draw
|
|
|
|
* body items (useful to draw a body in schematic,
|
|
|
|
* because fields of schematic components replace
|
|
|
|
* the lib component fields).
|
|
|
|
* @param aOnlySelected - Draws only the body items that are selected.
|
|
|
|
* Used for block move redraws.
|
|
|
|
*/
|
|
|
|
void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDc, const wxPoint& aOffset,
|
|
|
|
int aMulti, int aConvert, int aDrawMode, int aColor = -1,
|
|
|
|
const int aTransform[2][2] = DefaultTransformMatrix,
|
|
|
|
bool aShowPinText = true, bool aDrawFields = true,
|
|
|
|
bool aOnlySelected = false );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/**
|
|
|
|
* Plot component to plotter.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aPlotter - Plotter object to plot to.
|
|
|
|
* @param aUnit - Component part to plot.
|
|
|
|
* @param aConvert - Component alternate body style to plot.
|
|
|
|
* @param aTransform - Component plot transform matrix.
|
2009-10-05 17:52:41 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const wxPoint& aOffset,
|
|
|
|
const int aTransform[2][2] );
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Add a new draw /a aItem to the draw object list.
|
2009-09-29 18:38:21 +00:00
|
|
|
*
|
|
|
|
* @param item - New draw object to add to component.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void AddDrawItem( LIB_DRAW_ITEM* aItem );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Remove draw /a aItem from list.
|
2009-09-04 18:57:37 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aItem - Draw item to remove from list.
|
|
|
|
* @param aPanel - Panel to remove part from.
|
|
|
|
* @param aDc - Device context to remove part from.
|
2009-09-04 18:57:37 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void RemoveDrawItem( LIB_DRAW_ITEM* aItem,
|
|
|
|
WinEDA_DrawPanel* aPanel = NULL,
|
|
|
|
wxDC* aDc = NULL );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-09-29 18:38:21 +00:00
|
|
|
* Return the next draw object pointer.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aItem - Pointer to the current draw item. Setting item NULL
|
|
|
|
* with return the first item of type in the list.
|
|
|
|
* @param aType - type of searched item (filter).
|
|
|
|
* if TYPE_NOT_INIT search for all items types
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return - The next drawing object in the list if found, otherwise NULL.
|
2009-09-29 18:38:21 +00:00
|
|
|
*/
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_DRAW_ITEM* GetNextDrawItem( LIB_DRAW_ITEM* aItem = NULL,
|
|
|
|
KICAD_T aType = TYPE_NOT_INIT );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
/**
|
|
|
|
* Return the next pin object from the draw list.
|
|
|
|
*
|
|
|
|
* This is just a pin object specific version of GetNextDrawItem().
|
|
|
|
*
|
|
|
|
* @param item - Pointer to the previous pin item, or NULL to get the
|
|
|
|
* first pin in the draw object list.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return - The next pin object in the list if found, otherwise NULL.
|
2009-10-14 19:43:31 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_PIN* GetNextPin( LIB_PIN* aItem = NULL )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return (LIB_PIN*) GetNextDrawItem( (LIB_DRAW_ITEM*) aItem,
|
2009-10-08 13:19:28 +00:00
|
|
|
COMPONENT_PIN_DRAW_TYPE );
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a list of pin object pointers from the draw item list.
|
|
|
|
*
|
|
|
|
* Note pin objects are owned by the draw list of the component.
|
|
|
|
* Deleting any of the objects will leave list in a unstable state
|
|
|
|
* and will likely segfault when the list is destroyed.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aList - Pin list to place pin object pointers into.
|
|
|
|
* @param aUnit - Unit number of pin to add to list. Set to 0 to
|
|
|
|
* get pins from any component part.
|
|
|
|
* @param aConvert - Convert number of pin to add to list. Set to 0 to
|
|
|
|
* get pins from any convert of component.
|
2009-10-14 19:43:31 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void GetPins( LIB_PIN_LIST& aList, int aUnit = 0, int aConvert = 0 );
|
2009-10-14 19:43:31 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Return pin object with the requested pin /a aNumber.
|
2009-10-30 19:26:25 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aNumber - Number of the pin to find.
|
|
|
|
* @param aUnit - Unit of the component to find. Set to 0 if a specific
|
|
|
|
* unit number is not required.
|
|
|
|
* @param aConvert - Alternate body style filter (DeMorgan). Set to 0 if
|
|
|
|
* no alternate body style is required.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return The pin object if found. Otherwise NULL.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aConvert = 0 );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Move the component /a aOffset.
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aOffset - Offset displacement.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetOffset( const wxPoint& aOffset );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove duplicate draw items from list.
|
|
|
|
*/
|
|
|
|
void RemoveDuplicateDrawItems();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if component has more than one body conversion type (DeMorgan).
|
|
|
|
*
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return True if component has more than one conversion.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
|
|
|
bool HasConversion() const;
|
|
|
|
|
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Test if alias /a aName is in component alias list.
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
|
|
|
* Alias name comparisons are case insensitive.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aName - Name of alias.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return True if alias name in alias list.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool HasAlias( const wxChar* aName )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
wxASSERT( aName != NULL );
|
|
|
|
return m_AliasList.Index( aName ) != wxNOT_FOUND;
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
|
|
|
* Clears the status flag all draw objects in this component.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void ClearStatus();
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
/**
|
|
|
|
* Checks all draw objects of component to see if they are with block.
|
|
|
|
*
|
|
|
|
* Use this method to mark draw objects as selected during block
|
|
|
|
* functions.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aRect - The bounding rectangle to test in draw items are inside.
|
|
|
|
* @param aUnit - The current unit number to test against.
|
|
|
|
* @param aConvert - Are the draw items being selected a conversion.
|
|
|
|
* @param aEditPinByPin - Used to ignore pin selections when in edit pin
|
|
|
|
* by pin mode is enabled.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return The number of draw objects found inside the block select
|
|
|
|
* rectangle.
|
2009-09-25 18:49:04 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
int SelectItems( EDA_Rect& aRect, int aUnit, int aConvert,
|
|
|
|
bool aEditPinByPin );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears all the draw items marked by a block select.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void ClearSelectedItems();
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes the select draw items marked by a block select.
|
|
|
|
*
|
|
|
|
* The name and reference field will not be deleted. They are the
|
2009-10-30 19:26:25 +00:00
|
|
|
* minimum drawing items required for any component. Their properties
|
2009-09-25 18:49:04 +00:00
|
|
|
* can be changed but the cannot be removed.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void DeleteSelectedItems();
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Move the selected draw items marked by a block select.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void MoveSelectedItems( const wxPoint& aOffset );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Make a copy of the selected draw items marked by a block select.
|
|
|
|
*
|
|
|
|
* Fields are not copied. Only component body items are copied.
|
|
|
|
* Copying fields would result in duplicate fields which does not
|
|
|
|
* make sense in this context.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void CopySelectedItems( const wxPoint& aOffset );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Horizontally (X axis) mirror selected draw items about a point.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aCenter - Center point to mirror around.
|
2009-09-29 18:38:21 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void MirrorSelectedItemsH( const wxPoint& aCenter );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Locate a draw object.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aUnit - Unit number of draw item.
|
|
|
|
* @param aConvert - Body style of draw item.
|
|
|
|
* @param aType - Draw object type, set to 0 to search for any type.
|
|
|
|
* @param aPoint - Coordinate for hit testing.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return The draw object if found. Otherwise NULL.
|
2009-09-29 18:38:21 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_DRAW_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
|
|
|
|
const wxPoint& aPoint );
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-10-06 13:52:43 +00:00
|
|
|
/**
|
|
|
|
* Locate a draw object (overlaid)
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aUnit - Unit number of draw item.
|
|
|
|
* @param aConvert - Body style of draw item.
|
|
|
|
* @param aType - Draw object type, set to 0 to search for any type.
|
|
|
|
* @param aPoint - Coordinate for hit testing.
|
|
|
|
* @param aTransform = the transform matrix
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return The draw object if found. Otherwise NULL.
|
2009-10-06 13:52:43 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_DRAW_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
|
|
|
|
const wxPoint& aPoint,
|
|
|
|
const int aTransfrom[2][2] );
|
2009-10-06 13:52:43 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/**
|
|
|
|
* Return a reference to the draw item list.
|
|
|
|
*
|
|
|
|
* @return LIB_DRAW_ITEM_LIST& - Reference to the draw item object list.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_DRAW_ITEM_LIST& GetDrawItemList() { return drawings; }
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the part per package count.
|
|
|
|
*
|
|
|
|
* If the count is greater than the current count, then the all of the
|
|
|
|
* current draw items are duplicated for each additional part. If the
|
|
|
|
* count is less than the current count, all draw objects for parts
|
|
|
|
* greater that count are removed from the component.
|
|
|
|
*
|
|
|
|
* @param count - Number of parts per package.
|
|
|
|
*/
|
|
|
|
void SetPartCount( int count );
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
int GetPartCount() { return unitCount; }
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2010-04-24 11:27:38 +00:00
|
|
|
/** function IsMulti
|
|
|
|
* @return true if the component has multiple parts per package.
|
|
|
|
* When happens, the reference has a sub reference ti identify part
|
|
|
|
*/
|
|
|
|
bool IsMulti() { return unitCount > 1; }
|
|
|
|
|
|
|
|
/** function IsMulti
|
|
|
|
* @return the sub reference for component having multiple parts per package.
|
|
|
|
* The sub reference identify the part (or unit)
|
|
|
|
* @param aUnit = the part identifier ( 1 to max count)
|
|
|
|
* Note: this is a static function.
|
|
|
|
*/
|
|
|
|
static wxString ReturnSubReference( int aUnit );
|
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/**
|
|
|
|
* Set or clear the alternate body style (DeMorgan) for the component.
|
|
|
|
*
|
|
|
|
* If the component already has an alternate body style set and a
|
|
|
|
* asConvert if false, all of the existing draw items for the alternate
|
|
|
|
* body style are remove. If the alternate body style is not set and
|
|
|
|
* asConvert is true, than the base draw items are duplicated and
|
|
|
|
* added to the component.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aSetConvert - Set or clear the component alternate body style.
|
2009-10-05 17:52:41 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetConversion( bool aSetConvert );
|
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.
|
|
|
|
*/
|
2009-09-18 14:56:05 +00:00
|
|
|
class LIB_ALIAS : public CMP_LIB_ENTRY
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
protected:
|
2009-12-15 21:11:05 +00:00
|
|
|
/**
|
|
|
|
* The actual component of the alias.
|
|
|
|
*
|
|
|
|
* @note - Do not delete the root component. The root component is owned
|
|
|
|
* by library the component is part of. Deleting the root component
|
|
|
|
* will likely cause EESchema to crash.
|
2009-12-22 14:08:24 +00:00
|
|
|
* Or, if the root component is deleted, aliases must be deleted or their .root member
|
|
|
|
* must be changed to point a new root component
|
2009-12-15 21:11:05 +00:00
|
|
|
*/
|
|
|
|
LIB_COMPONENT* root;
|
2008-12-31 09:27:19 +00:00
|
|
|
|
|
|
|
public:
|
2009-12-22 14:08:24 +00:00
|
|
|
LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent,
|
2009-12-15 21:11:05 +00:00
|
|
|
CMP_LIBRARY* aLibrary = NULL );
|
|
|
|
LIB_ALIAS( LIB_ALIAS& aAlias, CMP_LIBRARY* aLibrary = NULL );
|
2009-09-18 14:56:05 +00:00
|
|
|
~LIB_ALIAS();
|
2009-08-19 19:34:03 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
return wxT( "LIB_ALIAS" );
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the alias root component.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_COMPONENT* GetComponent() const
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return root;
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the alias root component.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetComponent( LIB_COMPONENT* aComponent );
|
2008-12-31 09:27:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CLASS_LIBENTRY_H
|