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
|
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "general.h"
|
2010-10-08 20:40:57 +00:00
|
|
|
#include "lib_draw_item.h"
|
2010-10-20 20:24:26 +00:00
|
|
|
#include "lib_field.h"
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
#include <map>
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
class CMP_LIBRARY;
|
2010-10-04 18:54:14 +00:00
|
|
|
class LIB_ALIAS;
|
2010-10-25 15:43:42 +00:00
|
|
|
class LIB_COMPONENT;
|
2010-10-22 12:11:52 +00:00
|
|
|
class LIB_FIELD;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
/**
|
|
|
|
* LIB_ALIAS map sorting.
|
|
|
|
*/
|
|
|
|
struct AliasMapSort
|
|
|
|
{
|
|
|
|
bool operator() ( const wxString& aItem1, const wxString& aItem2 ) const
|
|
|
|
{ return aItem1.CmpNoCase( aItem2 ) < 0; }
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Alias map used by component library object.
|
|
|
|
*/
|
|
|
|
typedef std::map< wxString, LIB_ALIAS*, AliasMapSort > LIB_ALIAS_MAP;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
typedef std::vector< LIB_ALIAS* > LIB_ALIASES;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
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
|
|
|
/**
|
2010-10-25 15:43:42 +00:00
|
|
|
* Component library alias object definition.
|
2009-08-19 19:34:03 +00:00
|
|
|
*
|
2010-10-25 15:43:42 +00:00
|
|
|
* Component aliases are not really components. They are references
|
|
|
|
* to an actual component object.
|
2009-08-19 19:34:03 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
class LIB_ALIAS : public EDA_ITEM
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
/**
|
|
|
|
* The actual component of the alias.
|
|
|
|
*
|
|
|
|
* @note - Do not delete the root component. The root component is actually shared by
|
|
|
|
* all of the aliases associated with it. The component pointer will be delete
|
|
|
|
* in the destructor of the last alias that shares this component is deleted.
|
2011-09-30 18:15:37 +00:00
|
|
|
* Deleting the root component will likely cause Eeschema to crash.
|
2010-10-25 15:43:42 +00:00
|
|
|
*/
|
|
|
|
LIB_COMPONENT* root;
|
2009-12-15 21:11:05 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
friend class LIB_COMPONENT;
|
2009-12-15 21:11:05 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
protected:
|
|
|
|
wxString name;
|
2010-07-31 23:57:36 +00:00
|
|
|
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:
|
2010-10-25 15:43:42 +00:00
|
|
|
LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent );
|
|
|
|
LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_COMPONENT* aRootComponent = NULL );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
virtual ~LIB_ALIAS();
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
return wxT( "LIB_ALIAS" );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the alias root component.
|
|
|
|
*/
|
|
|
|
LIB_COMPONENT* GetComponent() const
|
|
|
|
{
|
|
|
|
return root;
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 10:28:30 +00:00
|
|
|
virtual wxString GetLibraryName();
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
bool IsRoot() const;
|
|
|
|
|
|
|
|
CMP_LIBRARY* GetLibrary();
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual const wxString& GetName() const { return name; }
|
|
|
|
|
|
|
|
virtual void SetName( const wxString& aName ) { name = aName; }
|
|
|
|
|
|
|
|
void SetDescription( const wxString& aDescription )
|
|
|
|
{
|
|
|
|
description = aDescription;
|
|
|
|
}
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2010-08-04 19:14:51 +00:00
|
|
|
wxString GetDescription() const { return description; }
|
2009-12-15 21:11:05 +00:00
|
|
|
|
|
|
|
void SetKeyWords( const wxString& aKeyWords )
|
|
|
|
{
|
|
|
|
keyWords = aKeyWords;
|
|
|
|
}
|
|
|
|
|
2010-08-04 19:14:51 +00:00
|
|
|
wxString GetKeyWords() const { return keyWords; }
|
2009-12-15 21:11:05 +00:00
|
|
|
|
|
|
|
void SetDocFileName( const wxString& aDocFileName )
|
|
|
|
{
|
|
|
|
docFileName = aDocFileName;
|
|
|
|
}
|
|
|
|
|
2010-08-04 19:14:51 +00:00
|
|
|
wxString GetDocFileName() const { 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
|
|
|
}
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
bool operator==( const LIB_ALIAS* aAlias ) const { return this == aAlias; }
|
2010-10-04 18:54:14 +00:00
|
|
|
};
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
extern bool operator<( const LIB_ALIAS& aItem1, const LIB_ALIAS& aItem2 );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
extern int LibraryEntryCompare( const LIB_ALIAS* aItem1, const LIB_ALIAS* aItem2 );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
|
|
|
* Library component object definition.
|
|
|
|
*
|
2010-06-24 18:31:43 +00:00
|
|
|
* A library component object is typically saved and loaded in a component library file (.lib).
|
2010-02-14 18:14:33 +00:00
|
|
|
* Library components are different from schematic components.
|
2009-08-19 19:34:03 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
class LIB_COMPONENT : public EDA_ITEM
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
wxString m_name;
|
2010-09-09 17:37:25 +00:00
|
|
|
int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to 0
|
|
|
|
///< to draw the pin name above the pin.
|
|
|
|
bool m_unitsLocked; ///< True if component has multiple parts and changing
|
|
|
|
///< one part does not automatically change another part.
|
|
|
|
bool m_showPinNames; ///< Determines if component pin names are visible.
|
|
|
|
bool m_showPinNumbers; ///< Determines if component pin numbers are visible.
|
|
|
|
long m_dateModified; ///< Date the component was last modified.
|
|
|
|
LibrEntryOptions m_options; ///< Special component features such as POWER or NORMAL.)
|
2010-10-25 15:43:42 +00:00
|
|
|
int m_unitCount; ///< Number of units (parts) per package.
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEMS drawings; ///< How to draw this part.
|
2010-09-09 17:37:25 +00:00
|
|
|
wxArrayString m_FootprintList; /**< List of suitable footprint names for the
|
2010-10-04 18:54:14 +00:00
|
|
|
component (wild card names accepted). */
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ALIASES m_aliases; ///< List of alias object pointers associated with the
|
2010-10-04 18:54:14 +00:00
|
|
|
///< component.
|
2010-10-25 15:43:42 +00:00
|
|
|
CMP_LIBRARY* m_library; ///< Library the component belongs to if any.
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2010-09-09 17:37:25 +00:00
|
|
|
void deleteAllFields();
|
|
|
|
|
|
|
|
friend class CMP_LIBRARY;
|
2010-10-04 18:54:14 +00:00
|
|
|
friend class LIB_ALIAS;
|
2010-09-09 17:37:25 +00:00
|
|
|
|
|
|
|
public:
|
2010-02-17 13:22:25 +00:00
|
|
|
LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary = NULL );
|
|
|
|
LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary = NULL );
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
virtual ~LIB_COMPONENT();
|
2010-02-17 13:22:25 +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_COMPONENT" );
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-22 12:11:52 +00:00
|
|
|
virtual void SetName( const wxString& aName );
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
wxString GetName() { return m_name; }
|
|
|
|
|
|
|
|
wxString GetLibraryName();
|
|
|
|
|
|
|
|
CMP_LIBRARY* GetLibrary() { return m_library; }
|
2010-10-12 10:28:30 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
wxArrayString GetAliasNames( bool aIncludeRoot = true ) const;
|
2010-09-09 17:37:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
size_t GetAliasCount() const { return m_aliases.size(); }
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
LIB_ALIAS* GetAlias( size_t aIndex );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
LIB_ALIAS* GetAlias( const wxString& aName );
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-12-02 21:41:56 +00:00
|
|
|
/**
|
|
|
|
* Function AddAlias
|
|
|
|
*
|
|
|
|
* Add an alias \a aName to the component.
|
|
|
|
*
|
|
|
|
* Duplicate alias names are not added to the alias list. Debug builds will raise an
|
|
|
|
* assertion. Release builds will fail silenetly.
|
|
|
|
*
|
|
|
|
* @param aName - Name of alias to add.
|
|
|
|
*/
|
|
|
|
void AddAlias( const wxString& aName );
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
/**
|
|
|
|
* Test if alias \a aName is in component alias list.
|
|
|
|
*
|
|
|
|
* Alias name comparisons are case insensitive.
|
|
|
|
*
|
|
|
|
* @param aName - Name of alias.
|
|
|
|
* @return True if alias name in alias list.
|
2010-02-17 13:22:25 +00:00
|
|
|
*/
|
2010-10-04 18:54:14 +00:00
|
|
|
bool HasAlias( const wxString& aName ) const;
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
void SetAliases( const wxArrayString& aAliasList );
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
void RemoveAlias( const wxString& aName );
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
LIB_ALIAS* RemoveAlias( LIB_ALIAS* aAlias );
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-12-02 21:41:56 +00:00
|
|
|
void RemoveAllAliases();
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
wxArrayString& GetFootPrints() { return m_FootprintList; }
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-02-27 19:54:01 +00:00
|
|
|
/**
|
|
|
|
* Function GetBoundingBox
|
|
|
|
* @return the component boundary box ( in user coordinates )
|
|
|
|
* @param aUnit = unit selection = 0, or 1..n
|
|
|
|
* @param aConvert = 0, 1 or 2
|
|
|
|
* If aUnit == 0, unit is not used
|
|
|
|
* if aConvert == 0 Convert is non used
|
|
|
|
* Invisible fields are not taken in account
|
|
|
|
**/
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT GetBoundingBox( int aUnit, int aConvert ) const;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-02-27 19:54:01 +00:00
|
|
|
/**
|
|
|
|
* Function GetBodyBoundingBox
|
|
|
|
* @return the component boundary box ( in user coordinates ) without fields
|
|
|
|
* @param aUnit = unit selection = 0, or 1..n
|
|
|
|
* @param aConvert = 0, 1 or 2
|
|
|
|
* If aUnit == 0, unit is not used
|
|
|
|
* if aConvert == 0 Convert is non used
|
|
|
|
* Fields are not taken in account
|
|
|
|
**/
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT GetBodyBoundingBox( int aUnit, int aConvert ) const;
|
2011-02-27 19:54:01 +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 );
|
|
|
|
|
|
|
|
/**
|
2010-06-24 18:31:43 +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 );
|
2010-06-24 18:31:43 +00:00
|
|
|
bool LoadDrawEntries( FILE* aFile, char* aLine, int* aLineNum, wxString& aErrorMsg );
|
2009-12-15 21:11:05 +00:00
|
|
|
bool LoadAliases( char* aLine, wxString& aErrorMsg );
|
2010-06-24 18:31:43 +00:00
|
|
|
bool LoadFootprints( FILE* aFile, char* aLine, int* aLineNum, wxString& aErrorMsg );
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
bool IsPower() { return m_options == ENTRY_POWER; }
|
|
|
|
bool IsNormal() { return m_options == ENTRY_NORMAL; }
|
2010-02-16 17:49:17 +00:00
|
|
|
|
|
|
|
void SetPower() { m_options = ENTRY_POWER; }
|
|
|
|
void SetNormal() { m_options = ENTRY_NORMAL; }
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; }
|
|
|
|
bool UnitsLocked() { return m_unitsLocked; }
|
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
/**
|
2010-06-17 16:30:10 +00:00
|
|
|
* Function SetFields
|
|
|
|
* overwrites all the existing in this component with fields supplied
|
|
|
|
* in \a aFieldsList. The only known caller of this function is the
|
|
|
|
* library component field editor, and it establishes needed behavior.
|
2009-08-19 19:34:03 +00:00
|
|
|
*
|
2010-10-04 18:54:14 +00:00
|
|
|
` * @param aFieldsList is a set of fields to import, removing all previous fields.
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2010-06-17 16:30:10 +00:00
|
|
|
void SetFields( const std::vector <LIB_FIELD>& aFieldsList );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2009-10-21 20:02:25 +00:00
|
|
|
/**
|
2010-06-17 16:30:10 +00:00
|
|
|
* Function GetFields
|
|
|
|
* returns a list of fields withing this component. The only known caller of
|
|
|
|
* this function is the library component field editor, and it establishes
|
|
|
|
* needed behavior.
|
2009-10-21 20:02:25 +00:00
|
|
|
*
|
2010-06-17 16:30:10 +00:00
|
|
|
* @param aList - List to add fields to
|
2009-10-21 20:02:25 +00:00
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
void GetFields( LIB_FIELDS& aList );
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/**
|
|
|
|
* Function FindField
|
|
|
|
* finds a field within this component matching \a aFieldName and returns
|
|
|
|
* it or NULL if not found.
|
|
|
|
*/
|
2010-10-04 18:54:14 +00:00
|
|
|
LIB_FIELD* FindField( const wxString& aFieldName );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
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.
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aTransform - Coordinate adjustment settings.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @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.
|
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
|
2009-12-15 21:11:05 +00:00
|
|
|
int aMulti, int aConvert, int aDrawMode, int aColor = -1,
|
2010-10-20 20:24:26 +00:00
|
|
|
const TRANSFORM& aTransform = DefaultTransform,
|
2009-12-15 21:11:05 +00:00
|
|
|
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.
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aOffset - Distance to shift the plot coordinates.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @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,
|
2010-10-20 20:24:26 +00:00
|
|
|
const TRANSFORM& aTransform );
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
2010-06-24 18:31:43 +00:00
|
|
|
* Add a new draw \a aItem to the draw object list.
|
2009-09-29 18:38:21 +00:00
|
|
|
*
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aItem - New draw object to add to component.
|
2009-09-29 18:38:21 +00:00
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
void AddDrawItem( LIB_ITEM* aItem );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/**
|
2010-06-24 18:31:43 +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
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
void RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* 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
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* GetNextDrawItem( LIB_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().
|
|
|
|
*
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aItem - 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
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
return (LIB_PIN*) GetNextDrawItem( (LIB_ITEM*) aItem, LIB_PIN_T );
|
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
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
void GetPins( LIB_PINS& aList, int aUnit = 0, int aConvert = 0 );
|
2009-10-14 19:43:31 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2010-06-24 18:31:43 +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
|
|
|
/**
|
2010-06-24 18:31:43 +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-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
|
|
|
*/
|
2011-03-29 19:33:07 +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
|
|
|
|
2011-05-20 18:29:35 +00:00
|
|
|
/**
|
|
|
|
* Vertically (Y axis) mirror selected draw items about a point.
|
|
|
|
*
|
|
|
|
* @param aCenter - Center point to mirror around.
|
|
|
|
*/
|
|
|
|
void MirrorSelectedItemsV( const wxPoint& aCenter );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rotate CCW selected draw items about a point.
|
|
|
|
*
|
|
|
|
* @param aCenter - Center point to mirror around.
|
|
|
|
*/
|
|
|
|
void RotateSelectedItems( 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
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_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
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
|
|
|
|
const wxPoint& aPoint, const TRANSFORM& aTransform );
|
2009-10-06 13:52:43 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/**
|
|
|
|
* Return a reference to the draw item list.
|
|
|
|
*
|
2011-04-27 19:44:32 +00:00
|
|
|
* @return LIB_ITEMS& - Reference to the draw item object list.
|
2009-10-05 17:52:41 +00:00
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEMS& 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 );
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
int GetPartCount() { return m_unitCount; }
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function IsMulti
|
2010-04-24 11:27:38 +00:00
|
|
|
* @return true if the component has multiple parts per package.
|
|
|
|
* When happens, the reference has a sub reference ti identify part
|
|
|
|
*/
|
2010-10-25 15:43:42 +00:00
|
|
|
bool IsMulti() { return m_unitCount > 1; }
|
2010-04-24 11:27:38 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2011-01-01 17:28:21 +00:00
|
|
|
* Function ReturnSubReference
|
2010-04-24 11:27:38 +00:00
|
|
|
* @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 );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the offset in mils of the pin name text from the pin symbol.
|
|
|
|
*
|
|
|
|
* Set the offset to 0 to draw the pin name above the pin symbol.
|
|
|
|
*
|
|
|
|
* @param aOffset - The offset in mils.
|
|
|
|
*/
|
|
|
|
void SetPinNameOffset( int aOffset ) { m_pinNameOffset = aOffset; }
|
|
|
|
|
|
|
|
int GetPinNameOffset() { return m_pinNameOffset; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set or clear the pin name visibility flag.
|
|
|
|
*
|
|
|
|
* @param aShow - True to make the component pin names visible.
|
|
|
|
*/
|
|
|
|
void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; }
|
|
|
|
|
|
|
|
bool ShowPinNames() { return m_showPinNames; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set or clear the pin number visibility flag.
|
|
|
|
*
|
|
|
|
* @param aShow - True to make the component pin numbers visible.
|
|
|
|
*/
|
|
|
|
void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }
|
|
|
|
|
|
|
|
bool ShowPinNumbers() { return m_showPinNumbers; }
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
bool operator==( const LIB_COMPONENT* aComponent ) const { return this == aComponent; }
|
2008-12-31 09:27:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CLASS_LIBENTRY_H
|