diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 15fd8d9fa2..b777172715 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,21 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. +2010-oct-25 UPDATE Wayne Stambaugh +================================================================================ +++EESchema + * Remove common library component and alias base class CMP_LIB_ENTRY. + * Derive LIB_COMPONENT and LIB_ALIAS directly from EDA_BaseStruct. + * Encapsulate most library draw item object members. + * Make most library draw item get methods constant. + * Merge two edit component properties methods into a single method. + * Update double click left mouse button to use merged edit component + properties method. + * Set schematic find dialog find button as default button. +++include + * Add in-line flag state helpers to EDA_BaseStruct. + + 2010-oct-22 UPDATE Wayne Stambaugh ================================================================================ Component library editor bug fixes and other minor fixes. diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 189cebcecc..2fed57923b 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -932,9 +932,9 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ); /* Skip items not used for this part */ - if( Multi && Pin->m_Unit && ( Pin->m_Unit != Multi ) ) + if( Multi && Pin->GetUnit() && ( Pin->GetUnit() != Multi ) ) continue; - if( convert && Pin->m_Convert && ( Pin->m_Convert != convert ) ) + if( convert && Pin->GetConvert() && ( Pin->GetConvert() != convert ) ) continue; /* Calculate the pin position (according to the component orientation) diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 2acd4b2af4..535438c471 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -34,60 +34,47 @@ #define TRACE_DESTRUCTOR 0 -/** class CMP_LIB_ENTRY - * Base class to describe library components and aliases. - * This class is not to be used directly. - * There are 2 derived classes - * class LIB_COMPONENT that describes a component in library - * class LIB_ALIAS that describes an alias of an existing component - * a LIB_COMPONENT object handle all info to draw a component - * (pins, graphic body items, fields, name, keywords and documentation) - * a LIB_ALIAS object use info of its LIB_COMPONENT parent - * and has just a name, keywords and documentation +/*******************************/ +/* class LIB_ALIAS */ +/*******************************/ + +/* Class to define an alias of a component + * An alias uses the component definition (graphic, pins...) + * but has its own name, keywords and documentation. + * Therefore, when the component is modified, alias of this component are + * modified. + * This is a simple method to create components with differs very few + * (like 74LS00, 74HC00 ... and many op amps ) */ -CMP_LIB_ENTRY::CMP_LIB_ENTRY( LibrEntryType aType, const wxString& aName, - CMP_LIBRARY* aLibrary ) : - EDA_BaseStruct( LIBCOMPONENT_STRUCT_TYPE ) +LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent ): + EDA_BaseStruct( LIB_ALIAS_T ) { - type = aType; + root = aRootComponent; name = aName; - library = aLibrary; } -CMP_LIB_ENTRY::CMP_LIB_ENTRY( CMP_LIB_ENTRY& aEntry, CMP_LIBRARY* aLibrary ) : - EDA_BaseStruct( aEntry ) +LIB_ALIAS::LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_COMPONENT* aRootComponent ) : + EDA_BaseStruct( aAlias ) { - type = aEntry.type; - name = aEntry.name; - description = aEntry.description; - keyWords = aEntry.keyWords; - docFileName = aEntry.docFileName; - library = aLibrary; + name = aAlias.name; + root = aRootComponent; + description = aAlias.description; + keyWords = aAlias.keyWords; + docFileName = aAlias.docFileName; } -CMP_LIB_ENTRY::~CMP_LIB_ENTRY() +LIB_ALIAS::~LIB_ALIAS() { +#if TRACE_DESTRUCTOR + wxLogDebug( wxT( "Destroying alias \"%s\" of component \"%s\" with alais list count %d." ), + GetChars( name ), GetChars( root->GetName() ), root->m_aliases.size() ); +#endif } -wxString CMP_LIB_ENTRY::GetLibraryName() -{ - if( library != NULL ) - return library->GetName(); - - return wxString( _( "none" ) ); -} - -wxString LIB_COMPONENT::GetLibraryName() -{ - if( library != NULL ) - return library->GetName(); - - return wxString( _( "none" ) ); -} wxString LIB_ALIAS::GetLibraryName() { if( GetComponent() ) @@ -96,6 +83,13 @@ wxString LIB_ALIAS::GetLibraryName() return wxString( _( "none" ) ); } + +bool LIB_ALIAS::IsRoot() const +{ + return name.CmpNoCase( root->GetName() ) == 0; +} + + /** * Function SaveDoc * writes the doc info out to a FILE in "*.dcm" format. @@ -104,7 +98,7 @@ wxString LIB_ALIAS::GetLibraryName() * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ -bool CMP_LIB_ENTRY::SaveDoc( FILE* aFile ) +bool LIB_ALIAS::SaveDoc( FILE* aFile ) { if( description.IsEmpty() && keyWords.IsEmpty() && docFileName.IsEmpty() ) return true; @@ -131,59 +125,24 @@ bool CMP_LIB_ENTRY::SaveDoc( FILE* aFile ) } -bool CMP_LIB_ENTRY::operator==( const wxChar* aName ) const +bool LIB_ALIAS::operator==( const wxChar* aName ) const { return name.CmpNoCase( aName ) == 0; } -bool operator<( const CMP_LIB_ENTRY& aItem1, const CMP_LIB_ENTRY& aItem2 ) +bool operator<( const LIB_ALIAS& aItem1, const LIB_ALIAS& aItem2 ) { return aItem1.GetName().CmpNoCase( aItem2.GetName() ) < 0; } -int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY* aItem2 ) +int LibraryEntryCompare( const LIB_ALIAS* aItem1, const LIB_ALIAS* aItem2 ) { return aItem1->GetName().CmpNoCase( aItem2->GetName() ); } -/*******************************/ -/* class LIB_ALIAS */ -/*******************************/ - -/* Class to define an alias of a component - * An alias uses the component definition (graphic, pins...) - * but has its own name, keywords and documentation. - * Therefore, when the component is modified, alias of this component are - * modified. - * This is a simple method to create components with differs very few - * (like 74LS00, 74HC00 ... and many op amps ) - */ - -LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent ) : - CMP_LIB_ENTRY( ALIAS, aName, NULL ) -{ - root = aRootComponent; -} - - -LIB_ALIAS::LIB_ALIAS( LIB_ALIAS& aAlias, LIB_COMPONENT* aRootComponent ) : CMP_LIB_ENTRY( aAlias ) -{ - root = aRootComponent; -} - - -LIB_ALIAS::~LIB_ALIAS() -{ -#if TRACE_DESTRUCTOR - wxLogDebug( wxT( "Destroying alias \"%s\" of component \"%s\" with alais list count %d." ), - GetChars( name ), GetChars( root->GetName() ), root->m_aliases.size() ); -#endif -} - - /***********************/ /* class LIB_COMPONENT */ /***********************/ @@ -196,10 +155,12 @@ LIB_ALIAS::~LIB_ALIAS() * Library components are different from schematic components. */ LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) : - CMP_LIB_ENTRY( ROOT, aName, aLibrary ) + EDA_BaseStruct( LIB_COMPONENT_T ) { + m_name = aName; + m_library = aLibrary; m_dateModified = 0; - unitCount = 1; + m_unitCount = 1; m_pinNameOffset = 40; m_options = ENTRY_NORMAL; m_unitsLocked = FALSE; @@ -223,12 +184,14 @@ LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) : LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary ) : - CMP_LIB_ENTRY( aComponent, aLibrary ) + EDA_BaseStruct( aComponent ) { LIB_DRAW_ITEM* newItem; + m_library = aLibrary; + m_name = aComponent.m_name; m_FootprintList = aComponent.m_FootprintList; - unitCount = aComponent.unitCount; + m_unitCount = aComponent.m_unitCount; m_unitsLocked = aComponent.m_unitsLocked; m_pinNameOffset = aComponent.m_pinNameOffset; m_showPinNumbers = aComponent.m_showPinNumbers; @@ -277,6 +240,15 @@ LIB_COMPONENT::~LIB_COMPONENT() } +wxString LIB_COMPONENT::GetLibraryName() +{ + if( m_library != NULL ) + return m_library->GetName(); + + return wxString( _( "none" ) ); +} + + /** function IsMulti * @return the sub reference for component having multiple parts per package. * The sub reference identify the part (or unit) @@ -296,7 +268,7 @@ wxString LIB_COMPONENT::ReturnSubReference( int aUnit ) void LIB_COMPONENT::SetName( const wxString& aName ) { - CMP_LIB_ENTRY::SetName( aName ); + m_name = aName; GetValueField().m_Text = aName; m_aliases[0]->SetName( aName ); } @@ -600,7 +572,7 @@ bool LIB_COMPONENT::Save( FILE* aFile ) 0, m_pinNameOffset, m_showPinNumbers ? 'Y' : 'N', m_showPinNames ? 'Y' : 'N', - unitCount, m_unitsLocked ? 'L' : 'F', + m_unitCount, m_unitsLocked ? 'L' : 'F', m_options == ENTRY_POWER ? 'P' : 'N' ) < 0 ) return false; @@ -735,8 +707,8 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum, wxString& aEr || sscanf( p, "%c", &drawnum ) != 1 || ( p = strtok( NULL, " \t\n" ) ) == NULL /* DrawNums: */ || sscanf( p, "%c", &drawname ) != 1 - || ( p = strtok( NULL, " \t\n" ) ) == NULL /* unitCount: */ - || sscanf( p, "%d", &unitCount ) != 1 ) + || ( p = strtok( NULL, " \t\n" ) ) == NULL /* m_unitCount: */ + || sscanf( p, "%d", &m_unitCount ) != 1 ) { aErrorMsg.Printf( wxT( "Wrong DEF format in line %d, skipped." ), *aLineNum ); while( GetLine( aFile, aLine, aLineNum, LINE_BUFFER_LEN_LARGE ) ) @@ -749,9 +721,9 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum, wxString& aEr return false; } - // Ensure unitCount is >= 1 (could be read as 0 in old libraries) - if( unitCount < 1 ) - unitCount = 1; + // Ensure m_unitCount is >= 1 (could be read as 0 in old libraries) + if( m_unitCount < 1 ) + m_unitCount = 1; m_showPinNumbers = ( drawnum == 'N' ) ? false : true; m_showPinNames = ( drawname == 'N' ) ? false : true; @@ -762,16 +734,16 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum, wxString& aEr strupper( componentName ); if( componentName[0] != '~' ) { - name = value.m_Text = CONV_FROM_UTF8( componentName ); + m_name = value.m_Text = CONV_FROM_UTF8( componentName ); } else { - name = value.m_Text = CONV_FROM_UTF8( &componentName[1] ); + m_name = value.m_Text = CONV_FROM_UTF8( &componentName[1] ); value.m_Attributs |= TEXT_NO_VISIBLE; } // Add the root alias to the alias list. - m_aliases.push_back( new LIB_ALIAS( name, this ) ); + m_aliases.push_back( new LIB_ALIAS( m_name, this ) ); LIB_FIELD& reference = GetReferenceField(); @@ -952,7 +924,7 @@ bool LIB_COMPONENT::LoadField( char* aLine, wxString& aErrorMsg ) *fixedField = *field; if( field->m_FieldId == VALUE ) - name = field->m_Text; + m_name = field->m_Text; SAFE_DELETE( field ); } @@ -1000,7 +972,7 @@ EDA_Rect LIB_COMPONENT::GetBoundaryBox( int aUnit, int aConvert ) BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) { - if( ( item.m_Unit > 0 ) && ( ( unitCount > 1 ) && ( aUnit > 0 ) + if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 ) && ( aUnit != item.m_Unit ) ) ) continue; @@ -1422,10 +1394,10 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, KICAD_T a void LIB_COMPONENT::SetPartCount( int aCount ) { - if( unitCount == aCount ) + if( m_unitCount == aCount ) return; - if( aCount < unitCount ) + if( aCount < m_unitCount ) { LIB_DRAW_ITEM_LIST::iterator i; i = drawings.begin(); @@ -1440,7 +1412,7 @@ void LIB_COMPONENT::SetPartCount( int aCount ) } else { - int prevCount = unitCount; + int prevCount = m_unitCount; // We cannot use an iterator here, because when adding items in vector // the buffer can be reallocated, that change the previous value of @@ -1462,7 +1434,7 @@ void LIB_COMPONENT::SetPartCount( int aCount ) drawings.sort(); } - unitCount = aCount; + m_unitCount = aCount; } @@ -1540,7 +1512,7 @@ bool LIB_COMPONENT::HasAlias( const wxString& aName ) const void LIB_COMPONENT::SetAliases( const wxArrayString& aAliasList ) { - wxCHECK_RET( library == NULL, + wxCHECK_RET( m_library == NULL, wxT( "Component aliases cannot be changed when they are owned by a library." ) ); if( aAliasList == GetAliasNames() ) @@ -1572,7 +1544,7 @@ void LIB_COMPONENT::SetAliases( const wxArrayString& aAliasList ) void LIB_COMPONENT::RemoveAlias( const wxString& aName ) { - wxCHECK_RET( library == NULL, + wxCHECK_RET( m_library == NULL, wxT( "Component aliases cannot be changed when they are owned by a library." ) ); wxCHECK_RET( !aName.IsEmpty(), wxT( "Cannot get alias with an empty name." ) ); diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 2ee9f87401..13ebf18fa9 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -13,6 +13,7 @@ class CMP_LIBRARY; class LIB_ALIAS; +class LIB_COMPONENT; class LIB_FIELD; @@ -32,15 +33,6 @@ typedef std::map< wxString, LIB_ALIAS*, AliasMapSort > LIB_ALIAS_MAP; typedef std::vector< LIB_ALIAS* > LIB_ALIAS_LIST; -/* Types for components in libraries - * components can be a true component or an alias of a true component. - */ -enum LibrEntryType -{ - ROOT, /* This is a true component standard LIB_COMPONENT */ - ALIAS /* This is an alias of a true component */ -}; - /* values for member .m_options */ enum LibrEntryOptions { @@ -50,51 +42,60 @@ enum LibrEntryOptions /** - * Class CMP_LIB_ENTRY - * is a base class to describe library components and aliases. + * Component library alias object definition. * - * This class is not to be used directly. + * Component aliases are not really components. They are references + * to an actual component object. */ -class CMP_LIB_ENTRY : public EDA_BaseStruct +class LIB_ALIAS : public EDA_BaseStruct { + /** + * 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. + * Deleting the root component will likely cause EESchema to crash. + */ + LIB_COMPONENT* root; + + friend class LIB_COMPONENT; + 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 public: - CMP_LIB_ENTRY( LibrEntryType aType, const wxString& aName, CMP_LIBRARY* aLibrary = NULL ); - CMP_LIB_ENTRY( CMP_LIB_ENTRY& aEntry, CMP_LIBRARY* aLibrary = NULL ); + LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent ); + LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_COMPONENT* aRootComponent = NULL ); - virtual ~CMP_LIB_ENTRY(); + virtual ~LIB_ALIAS(); virtual wxString GetClass() const { - return wxT( "CMP_LIB_ENTRY" ); + return wxT( "LIB_ALIAS" ); + } + + /** + * Get the alias root component. + */ + LIB_COMPONENT* GetComponent() const + { + return root; } virtual wxString GetLibraryName(); - CMP_LIBRARY* GetLibrary() { return library; } + bool IsRoot() const; + + CMP_LIBRARY* GetLibrary(); virtual const wxString& GetName() const { return name; } virtual void SetName( const wxString& aName ) { name = aName; } - bool isComponent() const { return type == ROOT; } - - bool isAlias() const { return type == ALIAS; } - - int GetType() const { return type; } - void SetDescription( const wxString& aDescription ) { description = aDescription; @@ -133,12 +134,12 @@ public: return !( *this == aName ); } - bool operator==( const wxString& aName ) const { return *this == ( const wxChar* ) aName; } + bool operator==( const LIB_ALIAS* aAlias ) const { return this == aAlias; } }; -extern bool operator<( const CMP_LIB_ENTRY& aItem1, const CMP_LIB_ENTRY& aItem2 ); +extern bool operator<( const LIB_ALIAS& aItem1, const LIB_ALIAS& aItem2 ); -extern int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY* aItem2 ); +extern int LibraryEntryCompare( const LIB_ALIAS* aItem1, const LIB_ALIAS* aItem2 ); /** @@ -147,8 +148,9 @@ extern int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY * A library component object is typically saved and loaded in a component library file (.lib). * Library components are different from schematic components. */ -class LIB_COMPONENT : public CMP_LIB_ENTRY +class LIB_COMPONENT : public EDA_BaseStruct { + wxString m_name; 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 @@ -157,12 +159,13 @@ class LIB_COMPONENT : public CMP_LIB_ENTRY 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.) - int unitCount; ///< Number of units (parts) per package. + int m_unitCount; ///< Number of units (parts) per package. LIB_DRAW_ITEM_LIST drawings; ///< How to draw this part. wxArrayString m_FootprintList; /**< List of suitable footprint names for the component (wild card names accepted). */ LIB_ALIAS_LIST m_aliases; ///< List of alias object pointers associated with the ///< component. + CMP_LIBRARY* m_library; ///< Library the component belongs to if any. void deleteAllFields(); @@ -183,7 +186,11 @@ public: virtual void SetName( const wxString& aName ); - virtual wxString GetLibraryName(); + wxString GetName() { return m_name; } + + wxString GetLibraryName(); + + CMP_LIBRARY* GetLibrary() { return m_library; } wxArrayString GetAliasNames( bool aIncludeRoot = true ) const; @@ -512,13 +519,13 @@ public: */ void SetPartCount( int count ); - int GetPartCount() { return unitCount; } + int GetPartCount() { return m_unitCount; } /** 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; } + bool IsMulti() { return m_unitCount > 1; } /** function IsMulti * @return the sub reference for component having multiple parts per package. @@ -574,52 +581,4 @@ public: }; -/** - * Component library alias object definition. - * - * Component aliases are not really components. They are references - * to an actual component object. - */ -class LIB_ALIAS : public CMP_LIB_ENTRY -{ - friend class LIB_COMPONENT; - -protected: - /** - * 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. - * Deleting the root component will likely cause EESchema to crash. - */ - LIB_COMPONENT* root; - -public: - LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent ); - LIB_ALIAS( LIB_ALIAS& aAlias, LIB_COMPONENT* aRootComponent = NULL ); - - virtual ~LIB_ALIAS(); - - virtual wxString GetClass() const - { - return wxT( "LIB_ALIAS" ); - } - - /** - * Get the alias root component. - */ - LIB_COMPONENT* GetComponent() const - { - return root; - } - - virtual wxString GetLibraryName(); - - bool IsRoot() const { return name.CmpNoCase( root->GetName() ) == 0; } - - bool operator==( const LIB_ALIAS* aAlias ) const { return this == aAlias; } -}; - - #endif // CLASS_LIBENTRY_H diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index ba7d471729..711269c3b6 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -174,13 +174,13 @@ bool CMP_LIBRARY::Conflicts( LIB_COMPONENT* aComponent ) } -CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* aName ) +LIB_ALIAS* CMP_LIBRARY::FindEntry( const wxChar* aName ) { LIB_ALIAS_MAP::iterator it = aliases.find( wxString( aName ) ); if( it != aliases.end() ) - return ( CMP_LIB_ENTRY* ) (*it).second; + return (*it).second; return NULL; } @@ -190,10 +190,10 @@ CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* aName ) * Return the first entry in the library. * @return The first entry or NULL if the library has no entries. */ -CMP_LIB_ENTRY* CMP_LIBRARY::GetFirstEntry() +LIB_ALIAS* CMP_LIBRARY::GetFirstEntry() { if( aliases.size() ) - return ( LIB_ALIAS* ) (*aliases.begin()).second; + return (*aliases.begin()).second; else return NULL; } @@ -201,16 +201,10 @@ CMP_LIB_ENTRY* CMP_LIBRARY::GetFirstEntry() LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxChar* aName ) { LIB_COMPONENT* component = NULL; - CMP_LIB_ENTRY* entry = FindEntry( aName ); + LIB_ALIAS* entry = FindEntry( aName ); if( entry != NULL ) - { - wxCHECK_MSG( entry->isAlias(), NULL, - wxT( "Component found in library entry list, bad programmer!" ) ); - - LIB_ALIAS* alias = (LIB_ALIAS*) entry; - component = alias->GetComponent(); - } + component = entry->GetComponent(); return component; } @@ -276,7 +270,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) LIB_ALIAS* alias = FindAlias( aliasname ); if( alias != NULL ) - RemoveEntry( (CMP_LIB_ENTRY*) alias ); + RemoveEntry( alias ); aliases[ aliasname ] = newCmp->m_aliases[i]; } @@ -287,10 +281,9 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) } -CMP_LIB_ENTRY* CMP_LIBRARY::RemoveEntry( CMP_LIB_ENTRY* aEntry ) +LIB_ALIAS* CMP_LIBRARY::RemoveEntry( LIB_ALIAS* aEntry ) { - wxCHECK_MSG( aEntry != NULL && aEntry->isAlias(), NULL, - wxT( "Only LIB_ALIAS pointers can be removed from library." ) ); + wxCHECK_MSG( aEntry != NULL, NULL, wxT( "NULL pointer cannot be removed from library." ) ); LIB_ALIAS_MAP::iterator it = aliases.find( aEntry->GetName() ); @@ -326,7 +319,7 @@ CMP_LIB_ENTRY* CMP_LIBRARY::RemoveEntry( CMP_LIB_ENTRY* aEntry ) aliases.erase( it ); isModified = true; - return (CMP_LIB_ENTRY*) alias; + return alias; } @@ -354,7 +347,7 @@ LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent, while( i != 0 ) { i -= 1; - RemoveEntry( (CMP_LIB_ENTRY*) aOldComponent->m_aliases[ i ] ); + RemoveEntry( aOldComponent->m_aliases[ i ] ); } LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aNewComponent, this ); @@ -371,7 +364,7 @@ LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent, } -CMP_LIB_ENTRY* CMP_LIBRARY::GetNextEntry( const wxChar* aName ) +LIB_ALIAS* CMP_LIBRARY::GetNextEntry( const wxChar* aName ) { if( aliases.empty() ) return NULL; @@ -383,11 +376,11 @@ CMP_LIB_ENTRY* CMP_LIBRARY::GetNextEntry( const wxChar* aName ) if( it == aliases.end() ) it = aliases.begin(); - return ( CMP_LIB_ENTRY* ) (*it).second; + return (*it).second; } -CMP_LIB_ENTRY* CMP_LIBRARY::GetPreviousEntry( const wxChar* aName ) +LIB_ALIAS* CMP_LIBRARY::GetPreviousEntry( const wxChar* aName ) { if( aliases.empty() ) return NULL; @@ -399,7 +392,7 @@ CMP_LIB_ENTRY* CMP_LIBRARY::GetPreviousEntry( const wxChar* aName ) it--; - return ( CMP_LIB_ENTRY* ) (*it).second; + return (*it).second; } @@ -551,7 +544,7 @@ the current schematic." ), void CMP_LIBRARY::LoadAliases( LIB_COMPONENT* component ) { - wxCHECK_RET( component != NULL && component->isComponent(), + wxCHECK_RET( component != NULL, wxT( "Cannot load aliases of NULL component object. Bad programmer!" ) ); for( size_t i = 0; i < component->m_aliases.size(); i++ ) @@ -589,12 +582,12 @@ bool CMP_LIBRARY::LoadHeader( FILE* libfile, int* LineNum ) bool CMP_LIBRARY::LoadDocs( wxString& aErrorMsg ) { - int lineNumber = 0; - char line[LINE_BUFFER_LEN_LARGE], * name, * text; - CMP_LIB_ENTRY* entry; - FILE* file; - wxString msg; - wxFileName fn = fileName; + int lineNumber = 0; + char line[LINE_BUFFER_LEN_LARGE], * name, * text; + LIB_ALIAS* entry; + FILE* file; + wxString msg; + wxFileName fn = fileName; fn.SetExt( DOC_EXT ); @@ -647,8 +640,6 @@ bool CMP_LIBRARY::LoadDocs( wxString& aErrorMsg ) if( entry ) { - wxASSERT( entry->isAlias() ); - switch( line[0] ) { case 'D': @@ -979,9 +970,9 @@ LIB_COMPONENT* CMP_LIBRARY::FindLibraryComponent( const wxString& aName, } -CMP_LIB_ENTRY* CMP_LIBRARY::FindLibraryEntry( const wxString& aName, const wxString& aLibraryName ) +LIB_ALIAS* CMP_LIBRARY::FindLibraryEntry( const wxString& aName, const wxString& aLibraryName ) { - CMP_LIB_ENTRY* entry = NULL; + LIB_ALIAS* entry = NULL; BOOST_FOREACH( CMP_LIBRARY& lib, libraryList ) { diff --git a/eeschema/class_library.h b/eeschema/class_library.h index b1b78e5bbe..77a650d83b 100644 --- a/eeschema/class_library.h +++ b/eeschema/class_library.h @@ -71,7 +71,6 @@ class CMP_LIBRARY static CMP_LIBRARY_LIST libraryList; static wxArrayString libraryListSortOrder; - friend class CMP_LIB_ENTRY; friend class LIB_COMPONENT; public: @@ -217,12 +216,12 @@ public: * @param aName - Name of entry, case insensitive. * @return Entry if found. NULL if not found. */ - CMP_LIB_ENTRY* FindEntry( const wxChar* aName ); + LIB_ALIAS* FindEntry( const wxChar* aName ); /** * Find component by \a aName. * - * This is a helper for FindEntry so casting a CMP_LIB_ENTRY pointer to + * This is a helper for FindEntry so casting a LIB_ALIAS pointer to * a LIB_COMPONENT pointer is not required. * * @param aName - Name of component, case insensitive. @@ -233,7 +232,7 @@ public: /** * Find alias by \a nName. * - * This is a helper for FindEntry so casting a CMP_LIB_ENTRY pointer to + * This is a helper for FindEntry so casting a LIB_ALIAS pointer to * a LIB_ALIAS pointer is not required. * * @param aName - Name of alias, case insensitive. @@ -280,7 +279,7 @@ public: * @param aEntry - Entry to remove from library. * @return The next entry in the library or NULL if the library is empty. */ - CMP_LIB_ENTRY* RemoveEntry( CMP_LIB_ENTRY* aEntry ); + LIB_ALIAS* RemoveEntry( LIB_ALIAS* aEntry ); /** * Replace an existing component entry in the library. @@ -297,7 +296,7 @@ public: * * @return The first entry or NULL if the library has no entries. */ - CMP_LIB_ENTRY* GetFirstEntry(); + LIB_ALIAS* GetFirstEntry(); /** * Find next library entry by \a aName. @@ -308,7 +307,7 @@ public: * @param aName - Name of current entry. * @return Next entry if entry name is found. Otherwise NULL. */ - CMP_LIB_ENTRY* GetNextEntry( const wxChar* aName ); + LIB_ALIAS* GetNextEntry( const wxChar* aName ); /** @@ -320,7 +319,7 @@ public: * @param aName - Name of current entry. * @return Previous entry if entry name is found, otherwise NULL. */ - CMP_LIB_ENTRY* GetPreviousEntry( const wxChar* aName ); + LIB_ALIAS* GetPreviousEntry( const wxChar* aName ); /** * Return the file name without path or extension. @@ -471,8 +470,8 @@ public: * @param aLibraryName - Name of the library to search. * @return The entry object if found, otherwise NULL. */ - static CMP_LIB_ENTRY* FindLibraryEntry( const wxString& aEntryName, - const wxString& aLibraryName = wxEmptyString ); + static LIB_ALIAS* FindLibraryEntry( const wxString& aEntryName, + const wxString& aLibraryName = wxEmptyString ); /** * Function RemoveCacheLibrary diff --git a/eeschema/class_sch_component.cpp b/eeschema/class_sch_component.cpp index dfc69fc5c5..b68865f1c2 100644 --- a/eeschema/class_sch_component.cpp +++ b/eeschema/class_sch_component.cpp @@ -43,8 +43,8 @@ void CreateDummyCmp() LIB_RECTANGLE* Square = new LIB_RECTANGLE( DummyCmp ); - Square->m_Pos = wxPoint( -200, 200 ); - Square->m_End = wxPoint( 200, -200 ); + Square->Move( wxPoint( -200, 200 ) ); + Square->SetEndPosition( wxPoint( 200, -200 ) ); LIB_TEXT* Text = new LIB_TEXT( DummyCmp ); @@ -537,8 +537,6 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number ) if( Entry == NULL ) return NULL; - wxASSERT( Entry->isComponent() ); - return Entry->GetPin( number, m_Multi, m_Convert ); } @@ -1127,10 +1125,10 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) { // search for the component in lib // Entry and root_component can differ if Entry is an alias - CMP_LIB_ENTRY* Entry = CMP_LIBRARY::FindLibraryEntry( m_ChipName ); + LIB_ALIAS* alias = CMP_LIBRARY::FindLibraryEntry( m_ChipName ); LIB_COMPONENT* root_component = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); - if( (Entry == NULL) || (root_component == NULL) ) + if( (alias == NULL) || (root_component == NULL) ) return; wxString msg; @@ -1149,13 +1147,13 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) // Display component reference in library and library frame->AppendMsgPanel( _( "Component" ), m_ChipName, BROWN ); - if( Entry->isAlias() ) + if( alias->GetName() != root_component->GetName() ) frame->AppendMsgPanel( _( "Alias of" ), root_component->GetName(), BROWN ); - frame->AppendMsgPanel( _( "Library" ), Entry->GetLibraryName(), BROWN ); + frame->AppendMsgPanel( _( "Library" ), alias->GetLibraryName(), BROWN ); // Display description of the component, and keywords found in lib - frame->AppendMsgPanel( _( "Description" ), Entry->GetDescription(), DARKCYAN ); - frame->AppendMsgPanel( _( "Key words" ), Entry->GetKeyWords(), DARKCYAN ); + frame->AppendMsgPanel( _( "Description" ), alias->GetDescription(), DARKCYAN ); + frame->AppendMsgPanel( _( "Key words" ), alias->GetKeyWords(), DARKCYAN ); } diff --git a/eeschema/dangling_ends.cpp b/eeschema/dangling_ends.cpp index 59b766da3f..5a3e151178 100644 --- a/eeschema/dangling_ends.cpp +++ b/eeschema/dangling_ends.cpp @@ -346,12 +346,11 @@ void RebuildEndPointsList( std::vector & aItemList, SCH_ITEM* { wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ); - if( Pin->m_Unit && STRUCT->m_Multi - && ( STRUCT->m_Multi != Pin->m_Unit ) ) + if( Pin->GetUnit() && STRUCT->m_Multi && ( STRUCT->m_Multi != Pin->GetUnit() ) ) continue; - if( Pin->m_Convert && STRUCT->m_Convert - && ( STRUCT->m_Convert != Pin->m_Convert ) ) + if( Pin->GetConvert() && STRUCT->m_Convert + && ( STRUCT->m_Convert != Pin->GetConvert() ) ) continue; DANGLING_END_ITEM item( PIN_END, Pin ); diff --git a/eeschema/database.cpp b/eeschema/database.cpp index cb9f539f63..5fcbd93afd 100644 --- a/eeschema/database.cpp +++ b/eeschema/database.cpp @@ -76,7 +76,7 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys, void DisplayCmpDoc( wxString& Name ) { - CMP_LIB_ENTRY* CmpEntry = NULL; + LIB_ALIAS* CmpEntry = NULL; CmpEntry = CMP_LIBRARY::FindLibraryEntry( Name ); diff --git a/eeschema/dialog_edit_component_in_lib.cpp b/eeschema/dialog_edit_component_in_lib.cpp index 5aba9b08c4..6f487b6b9c 100644 --- a/eeschema/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialog_edit_component_in_lib.cpp @@ -154,5 +154,5 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel() m_SelNumberOfUnits->SetValue( component->GetPartCount() ); m_SetSkew->SetValue( component->GetPinNameOffset() ); m_OptionPower->SetValue( component->IsPower() ); - m_OptionPartsLocked->SetValue( component->UnitsLocked() ); + m_OptionPartsLocked->SetValue( component->UnitsLocked() && component->GetPartCount() > 1 ); } diff --git a/eeschema/dialog_schematic_find.cpp b/eeschema/dialog_schematic_find.cpp index ec49b9c640..3258fdb3cf 100644 --- a/eeschema/dialog_schematic_find.cpp +++ b/eeschema/dialog_schematic_find.cpp @@ -35,8 +35,8 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( wxWindow* aParent, wxFindReplaceData* aData, m_checkWrap->SetValue( flags & FR_SEARCH_WRAP ); m_checkCurrentSheetOnly->SetValue( flags & FR_CURRENT_SHEET_ONLY ); + m_buttonFind->SetDefault(); m_comboFind->SetFocus(); - SetPosition( aPosition ); SetSize( aSize ); } diff --git a/eeschema/edit_component_in_lib.cpp b/eeschema/edit_component_in_lib.cpp index 7809f3f2a9..ea5d08f81b 100644 --- a/eeschema/edit_component_in_lib.cpp +++ b/eeschema/edit_component_in_lib.cpp @@ -33,35 +33,27 @@ void WinEDA_LibeditFrame::OnEditComponentProperties( wxCommandEvent& event ) { bool partLocked = GetComponent()->UnitsLocked(); - EditComponentProperties(); - if( partLocked != GetComponent()->UnitsLocked() ) - { // g_EditPinByPinIsOn is set to the better value, - // if m_UnitSelectionLocked has changed - g_EditPinByPinIsOn = GetComponent()->UnitsLocked() ? true : false; - m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn ); - } - m_HToolBar->Refresh(); - DrawPanel->Refresh(); -} - - -void WinEDA_LibeditFrame::EditComponentProperties() -{ DIALOG_EDIT_COMPONENT_IN_LIBRARY dlg( this ); if( dlg.ShowModal() == wxID_CANCEL ) return; + if( partLocked != GetComponent()->UnitsLocked() ) + { + // g_EditPinByPinIsOn is set to the better value, if m_UnitSelectionLocked has changed + g_EditPinByPinIsOn = GetComponent()->UnitsLocked() ? true : false; + } + UpdateAliasSelectList(); UpdatePartSelectList(); DisplayLibInfos(); DisplayCmpDoc(); - OnModify( ); + OnModify(); + DrawPanel->Refresh(); } - void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) { @@ -144,14 +136,23 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED (event) ) { + if( m_Parent == NULL ) + return; + + LIB_ALIAS* alias; LIB_COMPONENT* component = m_Parent->GetComponent(); if( component == NULL ) return; - m_DocCtrl->SetValue( component->GetDescription() ); - m_DocfileCtrl->SetValue( component->GetDocFileName() ); - m_KeywordsCtrl->SetValue( component->GetKeyWords() ); + alias = component->GetAlias( m_Parent->GetAliasName() ); + + if( alias == NULL ) + return; + + m_DocCtrl->SetValue( alias->GetDescription() ); + m_DocfileCtrl->SetValue( alias->GetDocFileName() ); + m_KeywordsCtrl->SetValue( alias->GetKeyWords() ); } diff --git a/eeschema/edit_graphic_bodyitem_text.cpp b/eeschema/edit_graphic_bodyitem_text.cpp index de154659c3..1b25f1013f 100644 --- a/eeschema/edit_graphic_bodyitem_text.cpp +++ b/eeschema/edit_graphic_bodyitem_text.cpp @@ -62,9 +62,9 @@ void Dialog_BodyGraphicText_Properties::InitDialog( ) m_TextSize->SetValue( msg ); m_TextValue->SetValue( m_GraphicText->m_Text ); - if ( m_GraphicText->m_Unit == 0 ) + if ( m_GraphicText->GetUnit() == 0 ) m_CommonUnit->SetValue( TRUE ); - if ( m_GraphicText->m_Convert == 0 ) + if ( m_GraphicText->GetConvert() == 0 ) m_CommonConvert->SetValue( TRUE ); if ( m_GraphicText->m_Orient == TEXT_ORIENT_VERT ) m_Orient->SetValue( TRUE ); @@ -163,14 +163,14 @@ void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event ) m_GraphicText->m_Orient = m_Parent->m_textOrientation; if( m_Parent->m_drawSpecificUnit ) - m_GraphicText->m_Unit = m_Parent->GetUnit(); + m_GraphicText->SetUnit( m_Parent->GetUnit() ); else - m_GraphicText->m_Unit = 0; + m_GraphicText->SetUnit( 0 ); if( m_Parent->m_drawSpecificConvert ) - m_GraphicText->m_Convert = m_Parent->GetConvert(); + m_GraphicText->SetConvert( m_Parent->GetConvert() ); else - m_GraphicText->m_Convert = 0; + m_GraphicText->SetConvert( 0 ); if ( (m_TextShapeOpt->GetSelection() & 1 ) != 0 ) m_GraphicText->m_Italic = true; diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 17ef313f83..de918c43bc 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -182,7 +182,7 @@ bool LIB_ARC::HitTest( const wxPoint& aRefPoint ) bool LIB_ARC::HitTest( wxPoint aReferencePoint, int aThreshold, const TRANSFORM& aTransform ) { - // TODO: use aTransMat to calculmates parameters + // TODO: use aTransMat to calculates parameters wxPoint relativePosition = aReferencePoint; NEGATE( relativePosition.y ); // reverse Y axis @@ -271,7 +271,7 @@ void LIB_ARC::DoOffset( const wxPoint& aOffset ) } -bool LIB_ARC::DoTestInside( EDA_Rect& aRect ) +bool LIB_ARC::DoTestInside( EDA_Rect& aRect ) const { return aRect.Inside( m_ArcStart.x, -m_ArcStart.y ) || aRect.Inside( m_ArcEnd.x, -m_ArcEnd.y ); @@ -335,7 +335,7 @@ int LIB_ARC::GetPenSize() void LIB_ARC::drawEditGraphics( EDA_Rect* aClipBox, wxDC* aDC, int aColor ) { - // Thie edit indicators only get drawn when a new arc is being drawn. + // The edit indicators only get drawn when a new arc is being drawn. if( ( m_Flags & IS_NEW ) == 0 ) return; @@ -356,7 +356,7 @@ void LIB_ARC::drawEditGraphics( EDA_Rect* aClipBox, wxDC* aDC, int aColor ) void LIB_ARC::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform ) { - // DOn't draw the arc until the end point is selected. Only the edit indicators + // Don't draw the arc until the end point is selected. Only the edit indicators // get drawn at this time. if( ( m_Flags & IS_NEW ) && m_lastEditState == 1 ) return; @@ -539,7 +539,7 @@ void LIB_ARC::BeginEdit( int aEditMode, const wxPoint aPosition ) } else { - // Save the current arc positions in case the resize ia aborted. + // Save the current arc positions in case the resize is aborted. saveAttributes(); // The arc center point has to be rotated with while adjusting the diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h index 5f9edfcd69..1bbfeba992 100644 --- a/eeschema/lib_arc.h +++ b/eeschema/lib_arc.h @@ -21,6 +21,13 @@ class LIB_ARC : public LIB_DRAW_ITEM OUTLINE, }; + int m_Radius; + int m_t1; /* First radius angle of the arc in 0.1 degrees. */ + int m_t2; /* Second radius angle of the arc in 0.1 degrees. */ + wxPoint m_ArcStart; + wxPoint m_ArcEnd; /* Arc end position. */ + wxPoint m_Pos; /* Radius center point. */ + int m_Width; /* Line width */ wxPoint m_savedStartPos; wxPoint m_savedEndPos; int m_savedAngle1; @@ -66,15 +73,6 @@ class LIB_ARC : public LIB_DRAW_ITEM */ void calcRadiusAngles(); -public: - int m_Radius; - int m_t1; /* First radius angle of the arc in 0.1 degrees. */ - int m_t2; /* Second radius angle of the arc in 0.1 degrees. */ - wxPoint m_ArcStart; - wxPoint m_ArcEnd; /* Arc end position. */ - wxPoint m_Pos; /* Radius center point. */ - int m_Width; /* Line width */ - public: LIB_ARC( LIB_COMPONENT * aParent ); LIB_ARC( const LIB_ARC& aArc ); @@ -149,13 +147,13 @@ protected: */ virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual void DoOffset( const wxPoint& aOffset ); - virtual bool DoTestInside( EDA_Rect& aRect ); + virtual bool DoTestInside( EDA_Rect& aRect ) const; virtual void DoMove( const wxPoint& aPosition ); - virtual wxPoint DoGetPosition() { return m_Pos; } + virtual wxPoint DoGetPosition() const { return m_Pos; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); - virtual int DoGetWidth() { return m_Width; } + virtual int DoGetWidth() const { return m_Width; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index d76ed0a9ed..27d63af530 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -158,7 +158,7 @@ void LIB_BEZIER::DoOffset( const wxPoint& aOffset ) } -bool LIB_BEZIER::DoTestInside( EDA_Rect& aRect ) +bool LIB_BEZIER::DoTestInside( EDA_Rect& aRect ) const { for( size_t i = 0; i < m_PolyPoints.size(); i++ ) { diff --git a/eeschema/lib_bezier.h b/eeschema/lib_bezier.h index 87fbd928d1..03b3a2f80e 100644 --- a/eeschema/lib_bezier.h +++ b/eeschema/lib_bezier.h @@ -11,17 +11,16 @@ /**************************************************/ class LIB_BEZIER : public LIB_DRAW_ITEM { + int m_Width; // Line width + std::vector m_BezierPoints; // list of parameter (3|4) + std::vector m_PolyPoints; // list of points (>= 2) + /** * Draw the bezier curve. */ void drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform ); -public: - int m_Width; /* Line width */ - std::vector m_BezierPoints; // list of parameter (3|4) - std::vector m_PolyPoints; // list of points (>= 2) - public: LIB_BEZIER( LIB_COMPONENT * aParent ); LIB_BEZIER( const LIB_BEZIER& aBezier ); @@ -90,13 +89,13 @@ protected: virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual void DoOffset( const wxPoint& aOffset ); - virtual bool DoTestInside( EDA_Rect& aRect ); + virtual bool DoTestInside( EDA_Rect& aRect ) const; virtual void DoMove( const wxPoint& aPosition ); - virtual wxPoint DoGetPosition() { return m_PolyPoints[0]; } + virtual wxPoint DoGetPosition() const { return m_PolyPoints[0]; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); - virtual int DoGetWidth() { return m_Width; } + virtual int DoGetWidth() const { return m_Width; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index e0263d93a4..3896a088c3 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -145,10 +145,10 @@ void LIB_CIRCLE::DoOffset( const wxPoint& aOffset ) } -bool LIB_CIRCLE::DoTestInside( EDA_Rect& aRect ) +bool LIB_CIRCLE::DoTestInside( EDA_Rect& aRect ) const { /* - * FIXME: This fails to take into acount the radius around the center + * FIXME: This fails to take into account the radius around the center * point. */ return aRect.Inside( m_Pos.x, -m_Pos.y ); diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h index e85df25dda..ab00ec7f51 100644 --- a/eeschema/lib_circle.h +++ b/eeschema/lib_circle.h @@ -11,7 +11,11 @@ class LIB_CIRCLE : public LIB_DRAW_ITEM { - int m_savedRadius; ///< Temporary storage of radius before editing begins. + int m_Radius; + wxPoint m_Pos; // Position or centre (Arc and Circle) or start point (segments). + int m_Width; // Line width. + + int m_savedRadius; // Temporary storage of radius before editing begins. /** * Draws the arc. @@ -36,12 +40,6 @@ class LIB_CIRCLE : public LIB_DRAW_ITEM */ void calcEdit( const wxPoint& aPosition ); - -public: - int m_Radius; - wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point (segments) */ - int m_Width; /* Line width */ - public: LIB_CIRCLE( LIB_COMPONENT * aParent ); LIB_CIRCLE( const LIB_CIRCLE& aCircle ); @@ -115,13 +113,13 @@ protected: virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual void DoOffset( const wxPoint& aOffset ); - virtual bool DoTestInside( EDA_Rect& aRect ); + virtual bool DoTestInside( EDA_Rect& aRect ) const; virtual void DoMove( const wxPoint& aPosition ); - virtual wxPoint DoGetPosition() { return m_Pos; } + virtual wxPoint DoGetPosition() const { return m_Pos; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); - virtual int DoGetWidth() { return m_Width; } + virtual int DoGetWidth() const { return m_Width; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; diff --git a/eeschema/lib_draw_item.cpp b/eeschema/lib_draw_item.cpp index 2164c0910a..34af6a2255 100644 --- a/eeschema/lib_draw_item.cpp +++ b/eeschema/lib_draw_item.cpp @@ -127,7 +127,7 @@ void LIB_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aO drawGraphic( aPanel, aDC, wxPoint( 0, 0 ), color, g_XorMode, aData, aTransform ); } - // Calculte the new attributes at the current cursor position. + // Calculate the new attributes at the current cursor position. calcEdit( aOffset ); // Draw the items using the new attributes. diff --git a/eeschema/lib_draw_item.h b/eeschema/lib_draw_item.h index bc72cba53c..f164a42a1d 100644 --- a/eeschema/lib_draw_item.h +++ b/eeschema/lib_draw_item.h @@ -21,11 +21,6 @@ class LIB_PIN; extern const int fill_tab[]; -// Set KICAD_USE_LIB_OJBECT_EDIT to 1 to use build in ojbect editing mode. -#if !defined( KICAD_USE_LIB_OJBECT_EDIT ) -#undef KICAD_USE_LIB_OJBECT_EDIT -#define KICAD_USE_LIB_OJBECT_EDIT 1 -#endif #define MINIMUM_SELECTION_DISTANCE 15 // Minimum selection distance in mils @@ -40,7 +35,7 @@ typedef boost::ptr_vector< LIB_DRAW_ITEM > LIB_DRAW_ITEM_LIST; /** * Helper for defining a list of pin object pointers. The list does not - * use a Boost pointer class so the ojbect pointers do not accidently get + * use a Boost pointer class so the object pointers do not accidently get * deleted when the container is deleted. */ typedef std::vector< LIB_PIN* > LIB_PIN_LIST; @@ -84,7 +79,6 @@ class LIB_DRAW_ITEM : public EDA_BaseStruct */ virtual void calcEdit( const wxPoint& aPosition ) {} - /** * Save the current item attributes while editing. * @@ -100,12 +94,10 @@ class LIB_DRAW_ITEM : public EDA_BaseStruct bool m_eraseLastDrawItem; ///< Used when editing a new draw item to prevent drawing ///< artifacts. -protected: - wxPoint m_savedPos; ///< Temporary position when editng an existing item. - wxPoint m_initialPos; ///< Temporary position when moving an existing item. - wxPoint m_initialCursorPos; ///< Iniital cursor position at the begining of a move. -public: + friend class LIB_COMPONENT; + +protected: /** * Unit identification for multiple parts per package. Set to 0 if the * item is common to all units. @@ -125,7 +117,11 @@ public: */ FILL_T m_Fill; - wxString m_typeName; ///< Name of object displayed in the message panel. + wxString m_typeName; ///< Name of object displayed in the message panel. + + wxPoint m_savedPos; ///< Temporary position when editing an existing item. + wxPoint m_initialPos; ///< Temporary position when moving an existing item. + wxPoint m_initialCursorPos; ///< Initial cursor position at the beginning of a move. public: @@ -139,13 +135,15 @@ public: virtual ~LIB_DRAW_ITEM() { } + wxString GetTypeName() { return m_typeName; } + /** * Begin an editing a component library draw item in \a aEditMode at \a aPosition. * * This is used to start an editing action such as resize or move a draw object. * It typically would be called on a left click when a draw tool is selected in * the component library editor and one of the graphics tools is selected. It - * allows the draw item to maintian it's own internal state while it is being + * allows the draw item to maintain it's own internal state while it is being * edited. Call AbortEdit() to quit the editing mode. * * @param aEditMode - The editing mode being performed. See base_struct.h for a list @@ -223,7 +221,7 @@ public: * * Derived classes should override this function. * - * @param aPosition - The coordinats to test. + * @param aPosition - The coordinates to test. * @return - true if a hit, else false */ virtual bool HitTest( const wxPoint& aPosition ) @@ -283,7 +281,7 @@ public: /** * Set drawing object offset from the current position. * - * @param aOffset - Cooridinates to offset position. + * @param aOffset - Coordinates to offset position. */ void SetOffset( const wxPoint& aOffset ) { DoOffset( aOffset ); } @@ -296,7 +294,7 @@ public: * @param aRect - Rectangle to check against. * @return - True if object is inside rectangle. */ - bool Inside( EDA_Rect& aRect ) { return DoTestInside( aRect ); } + bool Inside( EDA_Rect& aRect ) const { return DoTestInside( aRect ); } /** * Move a draw object to a new \a aPosition. @@ -310,7 +308,7 @@ public: /** * Return the current draw object start position. */ - wxPoint GetPosition() { return DoGetPosition(); } + wxPoint GetPosition() const { return DoGetPosition(); } /** * Mirror the draw object along the horizontal (X) axis about a point. @@ -345,7 +343,7 @@ public: * * @return Width of draw object. */ - int GetWidth() { return DoGetWidth(); } + int GetWidth() const { return DoGetWidth(); } void SetWidth( int aWidth ) { DoSetWidth( aWidth ); } /** @@ -356,30 +354,14 @@ public: * * @return - True if draw object can be fill. Default is false. */ - bool IsFillable() { return m_isFillable; } - - /** - * Return the modified status of the draw object. - * - * @return - True if the draw object has been modified. - */ - bool IsModified() { return ( m_Flags & IS_CHANGED ) != 0; } - - /** - * Return the new item status of the draw object. - * - * @return - True if the draw item has been added to the parent component. - */ - bool IsNew() { return ( m_Flags & IS_NEW ) != 0; } - bool IsMoving() { return ( m_Flags & IS_MOVED ); } - bool IsResizing() { return ( m_Flags & IS_RESIZED ); } + bool IsFillable() const { return m_isFillable; } /** * Return the draw item editing mode status. * * @return - True if the item is being edited. */ - bool InEditMode() { return ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0; } + bool InEditMode() const { return ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0; } void SetEraseLastDrawItem( bool aErase = true ) { m_eraseLastDrawItem = aErase; } @@ -387,11 +369,15 @@ public: void SetUnit( int aUnit ) { m_Unit = aUnit; } - int GetUnit() { return m_Unit; } + int GetUnit() const { return m_Unit; } void SetConvert( int aConvert ) { m_Convert = aConvert; } - int GetConvert() { return m_Convert; } + int GetConvert() const { return m_Convert; } + + void SetFillMode( FILL_T aFillMode ) { m_Fill = aFillMode; } + + FILL_T GetFillMode() const { return m_Fill; } protected: virtual LIB_DRAW_ITEM* DoGenCopy() = 0; @@ -409,13 +395,13 @@ protected: */ virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const = 0; virtual void DoOffset( const wxPoint& aOffset ) = 0; - virtual bool DoTestInside( EDA_Rect& aRect ) = 0; + virtual bool DoTestInside( EDA_Rect& aRect ) const = 0; virtual void DoMove( const wxPoint& aPosition ) = 0; - virtual wxPoint DoGetPosition() = 0; + virtual wxPoint DoGetPosition() const = 0; virtual void DoMirrorHorizontal( const wxPoint& aCenter ) = 0; virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) = 0; - virtual int DoGetWidth() = 0; + virtual int DoGetWidth() const = 0; virtual void DoSetWidth( int aWidth ) = 0; /** Flag to indicate if draw item is fillable. Default is false. */ diff --git a/eeschema/lib_export.cpp b/eeschema/lib_export.cpp index 9cca70fc7d..98a8830d29 100644 --- a/eeschema/lib_export.cpp +++ b/eeschema/lib_export.cpp @@ -34,10 +34,10 @@ extern int ExportPartId; */ void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event ) { - wxString errMsg; - wxFileName fn; - CMP_LIBRARY* LibTmp; - CMP_LIB_ENTRY* LibEntry; + wxString errMsg; + wxFileName fn; + CMP_LIBRARY* LibTmp; + LIB_ALIAS* LibEntry; m_lastDrawItem = NULL; @@ -61,8 +61,7 @@ void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event ) { wxString msg; - msg.Printf( _( "Component library file <%s> is empty." ), - GetChars( fn.GetFullPath() ) ); + msg.Printf( _( "Component library file <%s> is empty." ), GetChars( fn.GetFullPath() ) ); DisplayError( this, msg ); return; } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 5f2dc70a72..40c52288aa 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -484,7 +484,7 @@ void LIB_FIELD::DoOffset( const wxPoint& offset ) } -bool LIB_FIELD::DoTestInside( EDA_Rect& rect ) +bool LIB_FIELD::DoTestInside( EDA_Rect& rect ) const { /* * FIXME: This fails to take into acount the size and/or orientation of diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 7aa2794beb..1b26854d4a 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -214,13 +214,13 @@ protected: virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual void DoOffset( const wxPoint& offset ); - virtual bool DoTestInside( EDA_Rect& rect ); + virtual bool DoTestInside( EDA_Rect& rect ) const; virtual void DoMove( const wxPoint& newPosition ); - virtual wxPoint DoGetPosition( void ) { return m_Pos; } + virtual wxPoint DoGetPosition( void ) const { return m_Pos; } virtual void DoMirrorHorizontal( const wxPoint& center ); virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const TRANSFORM& aTransform ); - virtual int DoGetWidth( void ) { return m_Width; } + virtual int DoGetWidth( void ) const { return m_Width; } virtual void DoSetWidth( int width ) { m_Width = width; } }; diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index c41e6a58e2..4e78f0aa26 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1465,7 +1465,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER *plotter, /* return the pin end position, for a component in normal orient */ -wxPoint LIB_PIN::ReturnPinEndPoint() +wxPoint LIB_PIN::ReturnPinEndPoint() const { wxPoint pos = m_Pos; @@ -1642,7 +1642,7 @@ void LIB_PIN::DoOffset( const wxPoint& offset ) } -bool LIB_PIN::DoTestInside( EDA_Rect& rect ) +bool LIB_PIN::DoTestInside( EDA_Rect& rect ) const { wxPoint end = ReturnPinEndPoint(); diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index b255d657c8..aff617c0c0 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -155,7 +155,7 @@ public: virtual void DisplayInfo( WinEDA_DrawFrame* frame ); virtual EDA_Rect GetBoundingBox(); - wxPoint ReturnPinEndPoint(); + wxPoint ReturnPinEndPoint() const; int ReturnPinDrawOrient( const TRANSFORM& aTransform ); @@ -433,13 +433,13 @@ protected: */ virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual void DoOffset( const wxPoint& aOffset ); - virtual bool DoTestInside( EDA_Rect& aRect ); + virtual bool DoTestInside( EDA_Rect& aRect ) const; virtual void DoMove( const wxPoint& aPosition ); - virtual wxPoint DoGetPosition() { return m_Pos; } + virtual wxPoint DoGetPosition() const { return m_Pos; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); - virtual int DoGetWidth() { return m_Width; } + virtual int DoGetWidth() const { return m_Width; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index d19f19e925..77a11f6481 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -8,7 +8,6 @@ #include "class_drawpanel.h" #include "plot_common.h" #include "trigo.h" -#include "bezier_curves.h" #include "general.h" #include "protos.h" @@ -155,7 +154,7 @@ void LIB_POLYLINE::DoOffset( const wxPoint& aOffset ) } -bool LIB_POLYLINE::DoTestInside( EDA_Rect& aRect ) +bool LIB_POLYLINE::DoTestInside( EDA_Rect& aRect ) const { for( size_t i = 0; i < m_PolyPoints.size(); i++ ) { @@ -252,7 +251,7 @@ void LIB_POLYLINE::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoi else color = aColor; - // Set the size of the buffer od coordinates + // Set the size of the buffer of coordinates if( Buf_Poly_Drawings == NULL ) { Buf_Poly_Size = m_PolyPoints.size(); diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h index ed4f957b33..7fc1481876 100644 --- a/eeschema/lib_polyline.h +++ b/eeschema/lib_polyline.h @@ -11,6 +11,10 @@ class LIB_POLYLINE : public LIB_DRAW_ITEM { + int m_Width; // Line width + std::vector m_PolyPoints; // list of points (>= 2) + + int m_ModifyIndex; // Index of the polyline point to modify std::vector m_savedPolyPoints; /** @@ -30,17 +34,13 @@ class LIB_POLYLINE : public LIB_DRAW_ITEM void restoreAttributes(); /** - * Calculate the polyline attributes ralative to \a aPosition while editing. + * Calculate the polyline attributes relative to \a aPosition while editing. * * @param aPosition - Edit position in drawing units. */ void calcEdit( const wxPoint& aPosition ); public: - int m_Width; /* Line width */ - std::vector m_PolyPoints; // list of points (>= 2) - int m_ModifyIndex; // Index of the polyline point to modify - public: LIB_POLYLINE( LIB_COMPONENT * aParent ); LIB_POLYLINE( const LIB_POLYLINE& aPolyline ); @@ -120,7 +120,7 @@ protected: virtual LIB_DRAW_ITEM* DoGenCopy(); /** - * Provide the ployline segment draw object specific comparison. + * Provide the polyline segment draw object specific comparison. * * The sort order for each polyline segment point is as follows: * - Line segment point horizontal (X) position. @@ -129,13 +129,13 @@ protected: virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual void DoOffset( const wxPoint& aOffset ); - virtual bool DoTestInside( EDA_Rect& aRect ); + virtual bool DoTestInside( EDA_Rect& aRect ) const; virtual void DoMove( const wxPoint& aPosition ); - virtual wxPoint DoGetPosition() { return m_PolyPoints[0]; } + virtual wxPoint DoGetPosition() const { return m_PolyPoints[0]; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); - virtual int DoGetWidth() { return m_Width; } + virtual int DoGetWidth() const { return m_Width; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 467cb79396..0175516da6 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -116,7 +116,7 @@ void LIB_RECTANGLE::DoOffset( const wxPoint& aOffset ) } -bool LIB_RECTANGLE::DoTestInside( EDA_Rect& aRect ) +bool LIB_RECTANGLE::DoTestInside( EDA_Rect& aRect ) const { return aRect.Inside( m_Pos.x, -m_Pos.y ) || aRect.Inside( m_End.x, -m_End.y ); } diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index 0c31248702..68be4b3388 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -11,7 +11,14 @@ class LIB_RECTANGLE : public LIB_DRAW_ITEM { - wxPoint m_savedEndPos; ///< Tempory storage of the current end position before editing. + wxPoint m_End; // Rectangle end point. + wxPoint m_Pos; // Rectangle start point. + int m_Width; // Line width + bool m_isWidthLocked; // Flag: Keep width locked + bool m_isHeightLocked; // Flag: Keep height locked + bool m_isStartPointSelected; // Flag: is the upper left edge selected? + + wxPoint m_savedEndPos; // Temporary storage of current end position before editing. /** * Draw the rectangle. @@ -30,20 +37,13 @@ class LIB_RECTANGLE : public LIB_DRAW_ITEM void restoreAttributes(); /** - * Calculate the rectangle attrubites ralative to \a aPosition while editing. + * Calculate the rectangle attributes relative to \a aPosition while editing. * * @param aPosition - Edit position in drawing units. */ void calcEdit( const wxPoint& aPosition ); public: - wxPoint m_End; /* Rectangle end point. */ - wxPoint m_Pos; /* Rectangle start point. */ - int m_Width; /* Line width */ - bool m_isWidthLocked; /* Flag: Keep width locked */ - bool m_isHeightLocked; /* Flag: Keep height locked */ - bool m_isStartPointSelected; /* Flag: is the upper left edge selected ? */ - public: LIB_RECTANGLE( LIB_COMPONENT * aParent ); LIB_RECTANGLE( const LIB_RECTANGLE& aRect ); @@ -53,6 +53,7 @@ public: return wxT( "LIB_RECTANGLE" ); } + void SetEndPosition( const wxPoint& aPosition ) { m_End = aPosition; } /** * Write rectangle object out to a FILE in "*.lib" format. @@ -118,15 +119,15 @@ protected: virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual void DoOffset( const wxPoint& aOffset ); - virtual bool DoTestInside( EDA_Rect& aRect ); + virtual bool DoTestInside( EDA_Rect& aRect ) const; virtual void DoMove( const wxPoint& aPosition ); - virtual wxPoint DoGetPosition() { return m_Pos; } + virtual wxPoint DoGetPosition() const { return m_Pos; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); - virtual int DoGetWidth() { return m_Width; } + virtual int DoGetWidth() const { return m_Width; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; -#endif // _LIB_REACTANGLE_H_ +#endif // _LIB_RECTANGLE_H_ diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index cfd2c8a2f5..ace2fdf141 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -227,7 +227,7 @@ void LIB_TEXT::DoOffset( const wxPoint& offset ) } -bool LIB_TEXT::DoTestInside( EDA_Rect& rect ) +bool LIB_TEXT::DoTestInside( EDA_Rect& rect ) const { /* * FIXME: This should calculate the text size and justification and diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index 1bb901801e..08e8d855a4 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -144,13 +144,13 @@ protected: virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual void DoOffset( const wxPoint& aOffset ); - virtual bool DoTestInside( EDA_Rect& aRect ); + virtual bool DoTestInside( EDA_Rect& aRect ) const; virtual void DoMove( const wxPoint& aPosition ); - virtual wxPoint DoGetPosition() { return m_Pos; } + virtual wxPoint DoGetPosition() const { return m_Pos; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); - virtual int DoGetWidth() { return m_Width; } + virtual int DoGetWidth() const { return m_Width; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } }; diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index 5c171a0bb0..194ada4ce6 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -59,15 +59,15 @@ void WinEDA_LibeditFrame::SelectActiveLibrary() */ void WinEDA_LibeditFrame::LoadOneLibraryPart( wxCommandEvent& event ) { - int i; - wxString msg; - wxString CmpName; - CMP_LIB_ENTRY* LibEntry = NULL; + int i; + wxString msg; + wxString CmpName; + LIB_ALIAS* LibEntry = NULL; DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); - if( GetBaseScreen()->IsModify() && !IsOK( this, _( "Current part not \ -saved.\n\nDiscard current changes?" ) ) ) + if( GetBaseScreen()->IsModify() + && !IsOK( this, _( "Current part not saved.\n\nDiscard current changes?" ) ) ) return; // No current lib, ask user for the library to use. @@ -97,7 +97,7 @@ saved.\n\nDiscard current changes?" ) ) ) if( LibEntry == NULL ) { - msg.Printf( _( "Component or alias name \"%s\" not found in library \"%s\"." ), + msg.Printf( _( "Component name \"%s\" not found in library \"%s\"." ), GetChars( CmpName ), GetChars( m_library->GetName() ) ); DisplayError( this, msg ); @@ -125,7 +125,7 @@ saved.\n\nDiscard current changes?" ) ) ) * 1 if error * m_component advanced copy and created */ -bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* aEntry, CMP_LIBRARY* aLibrary ) +bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLibrary ) { wxString msg, cmpName, rootName; LIB_COMPONENT* component; @@ -142,21 +142,14 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* aEntry, CMP_LIBR cmpName = m_aliasName = aEntry->GetName(); - if( aEntry->isAlias() ) - { - LIB_ALIAS* alias = (LIB_ALIAS*) aEntry; - component = alias->GetComponent(); + LIB_ALIAS* alias = (LIB_ALIAS*) aEntry; + component = alias->GetComponent(); - wxASSERT( component != NULL && component->isComponent() ); + wxASSERT( component != NULL ); - wxLogDebug( wxT( "\"<%s>\" is alias of \"<%s>\"" ), - GetChars( cmpName ), - GetChars( component->GetName() ) ); - } - else - { - component = (LIB_COMPONENT*) aEntry; - } + wxLogDebug( wxT( "\"<%s>\" is alias of \"<%s>\"" ), + GetChars( cmpName ), + GetChars( component->GetName() ) ); if( m_component ) { @@ -376,10 +369,10 @@ void WinEDA_LibeditFrame::DisplayCmpDoc() */ void WinEDA_LibeditFrame::DeleteOnePart( wxCommandEvent& event ) { - wxString CmpName; - CMP_LIB_ENTRY* LibEntry; - wxArrayString ListNames; - wxString msg; + wxString CmpName; + LIB_ALIAS* LibEntry; + wxArrayString ListNames; + wxString msg; DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); @@ -448,7 +441,7 @@ void WinEDA_LibeditFrame::DeleteOnePart( wxCommandEvent& event ) All changes will be lost. Discard changes?" ) ) ) return; - CMP_LIB_ENTRY* nextEntry = m_library->RemoveEntry( LibEntry ); + LIB_ALIAS* nextEntry = m_library->RemoveEntry( LibEntry ); if( nextEntry != NULL ) { @@ -618,8 +611,6 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory() m_drawItem = m_lastDrawItem = NULL; - wxASSERT( m_component->isComponent() ); - if( oldComponent != NULL ) Component = m_library->ReplaceComponent( oldComponent, m_component ); else diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index ad2fcc2fc8..316c085aee 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -161,7 +161,9 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) } if( m_drawItem == NULL ) { - EditComponentProperties(); + wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); + cmd.SetId( ID_LIBEDIT_GET_FRAME_EDIT_PART ); + GetEventHandler()->ProcessEvent( cmd ); } } diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 823578c241..fb24556f7f 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -24,9 +24,9 @@ class Dialog_BodyGraphicText_Properties; class WinEDA_LibeditFrame : public WinEDA_DrawFrame { LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit. - wxString m_oldRootName; ///< The actual pointer of the component loaded from - ///< a library. Do not do anything with this pointer. - ///< It is to be used for reference purposes only. + wxString m_oldRootName; ///< The actual pointer of the component loaded from + ///< a library. Do not do anything with this pointer. + ///< It is to be used for reference purposes only. public: WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any) @@ -210,10 +210,9 @@ private: void SelectActiveLibrary(); void SaveActiveLibrary( wxCommandEvent& event ); - bool LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry, CMP_LIBRARY* Library ); + bool LoadOneLibraryPartAux( LIB_ALIAS* LibEntry, CMP_LIBRARY* Library ); void DisplayCmpDoc(); - void EditComponentProperties(); // General editing public: diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 7cace2008e..7a86bf48a7 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -722,11 +722,11 @@ XNODE* EXPORT_HELP::makeGenericLibParts() xlibpart->AddAttribute( sPart, lcomp->GetName() ); //----- show the important properties ------------------------- - if( !lcomp->GetDescription().IsEmpty() ) - xlibpart->AddChild( node( sDescr, lcomp->GetDescription() ) ); + if( !lcomp->GetAlias( 0 )->GetDescription().IsEmpty() ) + xlibpart->AddChild( node( sDescr, lcomp->GetAlias( 0 )->GetDescription() ) ); - if( !lcomp->GetDocFileName().IsEmpty() ) - xlibpart->AddChild( node( sDocs, lcomp->GetDocFileName() ) ); + if( !lcomp->GetAlias( 0 )->GetDocFileName().IsEmpty() ) + xlibpart->AddChild( node( sDocs, lcomp->GetAlias( 0 )->GetDocFileName() ) ); // Write the footprint list if( lcomp->GetFootPrints().GetCount() ) @@ -1581,10 +1581,10 @@ void EXPORT_HELP::findAllInstancesOfComponent( SCH_COMPONENT* aComponent, { wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE ); - if( pin->m_Unit && pin->m_Unit != unit2 ) + if( pin->GetUnit() && pin->GetUnit() != unit2 ) continue; - if( pin->m_Convert && pin->m_Convert != comp2->m_Convert ) + if( pin->GetConvert() && pin->GetConvert() != comp2->m_Convert ) continue; // A suitable pin is found: add it to the current list diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index 770c9dc6b6..a5bc380a6c 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -594,12 +594,11 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, { wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE ); - if( pin->m_Unit && - ( pin->m_Unit != DrawLibItem->GetUnitSelection( sheetlist ) ) ) + if( pin->GetUnit() && + ( pin->GetUnit() != DrawLibItem->GetUnitSelection( sheetlist ) ) ) continue; - if( pin->m_Convert && - ( pin->m_Convert != DrawLibItem->m_Convert ) ) + if( pin->GetConvert() && ( pin->GetConvert() != DrawLibItem->m_Convert ) ) continue; wxPoint pos2 = DrawLibItem->m_Transform.TransformCoordinate( pin->m_Pos ) + diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 2fa472c076..32ec62f709 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -244,18 +244,13 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) } wxString msg; - CMP_LIB_ENTRY* libEntry; + LIB_ALIAS* libEntry; LIB_COMPONENT* libComponent = NULL; libEntry = CMP_LIBRARY::FindLibraryEntry( Component->m_ChipName ); if( libEntry ) - { - if( libEntry->isAlias() ) - libComponent = ( (LIB_ALIAS*) libEntry )->GetComponent(); - else - libComponent = (LIB_COMPONENT*) libEntry; - } + libComponent = libEntry->GetComponent(); if( !Component->m_Flags ) { diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index df3c58b29a..196fe9b5d7 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -105,8 +105,8 @@ void WinEDA_LibeditFrame::OnEditPin( wxCommandEvent& event ) dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->m_PinLen, m_InternalUnits ) ); dlg.SetLengthUnits( units ); - dlg.SetAddToAllParts( pin->m_Unit == 0 ); - dlg.SetAddToAllBodyStyles( pin->m_Convert == 0 ); + dlg.SetAddToAllParts( pin->GetUnit() == 0 ); + dlg.SetAddToAllBodyStyles( pin->GetConvert() == 0 ); dlg.SetVisible( pin->IsVisible() ); /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier @@ -429,9 +429,9 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC ) m_drawItem = pin; - pin->m_Flags = IS_NEW; - pin->m_Unit = m_unit; - pin->m_Convert = m_convert; + pin->m_Flags = IS_NEW; + pin->SetUnit( m_unit ); + pin->SetConvert( m_convert ); /* Flag pins to consider */ if( g_EditPinByPinIsOn == false ) @@ -447,14 +447,14 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC ) pin->m_PinNumSize = LastPinNumSize; if( LastPinCommonConvert ) - pin->m_Convert = 0; + pin->SetConvert( 0 ); else - pin->m_Convert = m_convert; + pin->SetConvert( m_convert ); if( LastPinCommonUnit ) - pin->m_Unit = 0; + pin->SetUnit( 0 ); else - pin->m_Unit = m_unit; + pin->SetUnit( m_unit ); if( LastPinVisible ) pin->m_Attributs &= ~PINNOTDRAW; @@ -497,38 +497,38 @@ static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorga if( g_EditPinByPinIsOn ) return; - if( asDeMorgan && ( Pin->m_Convert != 0 ) ) + if( asDeMorgan && ( Pin->GetConvert() != 0 ) ) CreateConv = true; /* Create "convert" pin at the current position. */ if( CreateConv == true ) { NewPin = (LIB_PIN*) Pin->GenCopy(); - if( Pin->m_Convert > 1 ) - NewPin->m_Convert = 1; + if( Pin->GetConvert() > 1 ) + NewPin->SetConvert( 1 ); else - NewPin->m_Convert = 2; + NewPin->SetConvert( 2 ); Pin->GetParent()->AddDrawItem( NewPin ); } for( ii = 1; ii <= Pin->GetParent()->GetPartCount(); ii++ ) { - if( ii == unit || Pin->m_Unit == 0 ) + if( ii == unit || Pin->GetUnit() == 0 ) continue; /* Pin common to all units. */ NewPin = (LIB_PIN*) Pin->GenCopy(); if( convert != 0 ) - NewPin->m_Convert = 1; - NewPin->m_Unit = ii; + NewPin->SetConvert( 1 ); + NewPin->SetUnit( ii ); Pin->GetParent()->AddDrawItem( NewPin ); if( CreateConv == false ) continue; NewPin = (LIB_PIN*) Pin->GenCopy(); - NewPin->m_Convert = 2; - if( Pin->m_Unit != 0 ) - NewPin->m_Unit = ii; + NewPin->SetConvert( 2 ); + if( Pin->GetUnit() != 0 ) + NewPin->SetUnit( ii ); Pin->GetParent()->AddDrawItem( NewPin ); } } @@ -558,7 +558,7 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id ) Pin = m_component->GetNextPin(); for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) ) { - if( ( Pin->m_Convert ) && ( Pin->m_Convert != m_convert ) ) + if( ( Pin->GetConvert() ) && ( Pin->GetConvert() != m_convert ) ) continue; // Is it the "selected mode" ? @@ -639,11 +639,11 @@ bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst ) if( test == 0 ) { - test = ref->m_Convert - tst->m_Convert; + test = ref->GetConvert() - tst->GetConvert(); } if( test == 0 ) { - test = ref->m_Unit - tst->m_Unit; + test = ref->GetUnit() - tst->GetUnit(); } return test < 0; } @@ -693,8 +693,8 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event ) Pin = PinList[ii - 1]; if( Pin->m_PinNum != curr_pin->m_PinNum - || Pin->m_Convert != curr_pin->m_Convert - || Pin->m_Unit != curr_pin->m_Unit ) + || Pin->GetConvert() != curr_pin->GetConvert() + || Pin->GetUnit() != curr_pin->GetUnit() ) continue; dup_error++; @@ -713,13 +713,13 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event ) if( m_component->GetPartCount() > 1 ) { - aux_msg.Printf( _( " in part %c" ), 'A' + curr_pin->m_Unit ); + aux_msg.Printf( _( " in part %c" ), 'A' + curr_pin->GetUnit() ); msg += aux_msg; } if( m_showDeMorgan ) { - if( curr_pin->m_Convert ) + if( curr_pin->GetConvert() ) msg += _( " of converted" ); else msg += _( " of normal" ); @@ -752,13 +752,13 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event ) if( m_component->GetPartCount() > 1 ) { - aux_msg.Printf( _( " in part %c" ), 'A' + Pin->m_Unit ); + aux_msg.Printf( _( " in part %c" ), 'A' + Pin->GetUnit() ); msg += aux_msg; } if( m_showDeMorgan ) { - if( Pin->m_Convert ) + if( Pin->GetConvert() ) msg += _( " of converted" ); else msg += _( " of normal" ); diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 52edf78074..16b237fec7 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -637,14 +637,14 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) if( screen->GetCurItem() == NULL ) break; { - CMP_LIB_ENTRY* LibEntry; + LIB_ALIAS* LibEntry; LibEntry = CMP_LIBRARY::FindLibraryEntry( ( (SCH_COMPONENT*) screen->GetCurItem() )->m_ChipName ); if( LibEntry && LibEntry->GetDocFileName() != wxEmptyString ) { GetAssociatedDocument( this, LibEntry->GetDocFileName(), - &wxGetApp().GetLibraryPathList() ); + &wxGetApp().GetLibraryPathList() ); } } break; diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index 4d41db774d..8d1845d25e 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -36,7 +36,7 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) LIB_COMPONENT* component = DrawItem->GetParent(); - DIALOG_LIB_EDIT_DRAW_ITEM dialog( this, DrawItem->m_typeName ); + DIALOG_LIB_EDIT_DRAW_ITEM dialog( this, DrawItem->GetTypeName() ); dialog.SetWidthUnits( ReturnUnitSymbol( g_UserUnit ) ); @@ -47,7 +47,7 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) dialog.SetApplyToAllConversions( !m_drawSpecificConvert ); dialog.EnableApplyToAllConversions( component && component->HasConversion() ); // dialog.SetFillStyle( m_drawFillStyle ); // could better to show the current setting - dialog.SetFillStyle( DrawItem->m_Fill); + dialog.SetFillStyle( DrawItem->GetFillMode() ); dialog.EnableFillStyle( DrawItem->IsFillable() ); if( dialog.ShowModal() == wxID_CANCEL ) @@ -73,17 +73,17 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) SaveCopyInUndoList( DrawItem->GetParent() ); if( m_drawSpecificUnit ) - DrawItem->m_Unit = GetUnit(); + DrawItem->SetUnit( GetUnit() ); else - DrawItem->m_Unit = 0; + DrawItem->SetUnit( 0 ); if( m_drawSpecificConvert ) - DrawItem->m_Convert = GetConvert(); + DrawItem->SetConvert( GetConvert() ); else - DrawItem->m_Convert = 0; + DrawItem->SetConvert( 0 ); if( DrawItem->IsFillable() ) - DrawItem->m_Fill = (FILL_T) dialog.GetFillStyle(); + DrawItem->SetFillMode( (FILL_T) dialog.GetFillStyle() ); DrawItem->SetWidth( m_drawLineWidth ); @@ -183,12 +183,12 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry, { m_drawItem->BeginEdit( IS_NEW, drawPos ); m_drawItem->SetWidth( m_drawLineWidth ); - m_drawItem->m_Fill = m_drawFillStyle; + m_drawItem->SetFillMode( m_drawFillStyle ); if( m_drawSpecificUnit ) - m_drawItem->m_Unit = m_unit; + m_drawItem->SetUnit( m_unit ); if( m_drawSpecificConvert ) - m_drawItem->m_Convert = m_convert; + m_drawItem->SetConvert( m_convert ); // Draw initial symbol: DrawPanel->ManageCurseur( DrawPanel, DC, false ); @@ -253,8 +253,8 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC ) SetCursor( wxCURSOR_HAND ); - if( m_drawItem->m_Unit != m_unit ) - m_drawItem->m_Unit = m_unit; + if( m_drawItem->GetUnit() != m_unit ) + m_drawItem->SetUnit( m_unit ); TempCopyComponent(); m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCursorDrawPosition() ); diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp index de29bf5c07..c6c220c198 100644 --- a/eeschema/symbedit.cpp +++ b/eeschema/symbedit.cpp @@ -91,10 +91,10 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) { if( item.Type() == COMPONENT_FIELD_DRAW_TYPE ) continue; - if( item.m_Unit ) - item.m_Unit = m_unit; - if( item.m_Convert ) - item.m_Convert = m_convert; + if( item.GetUnit() ) + item.SetUnit( m_unit ); + if( item.GetConvert() ) + item.SetConvert( m_convert ); item.m_Flags = IS_NEW; item.m_Selected = IS_SELECTED; @@ -202,9 +202,9 @@ void WinEDA_LibeditFrame::SaveOneSymbol() if( item.Type() == COMPONENT_FIELD_DRAW_TYPE ) continue; /* Don't save unused parts or alternate body styles. */ - if( m_unit && item.m_Unit && ( item.m_Unit != m_unit ) ) + if( m_unit && item.GetUnit() && ( item.GetUnit() != m_unit ) ) continue; - if( m_convert && item.m_Convert && ( item.m_Convert != m_convert ) ) + if( m_convert && item.GetConvert() && ( item.GetConvert() != m_convert ) ) continue; if( !item.Save( file.fp() ) ) diff --git a/eeschema/tool_viewlib.cpp b/eeschema/tool_viewlib.cpp index b28c9002be..e057a7fe2b 100644 --- a/eeschema/tool_viewlib.cpp +++ b/eeschema/tool_viewlib.cpp @@ -17,16 +17,16 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar() { - int ii; wxString msg; + int ii; + wxString msg; CMP_LIBRARY* lib; LIB_COMPONENT* component = NULL; - CMP_LIB_ENTRY* entry = NULL; + LIB_ALIAS* entry = NULL; bool asdeMorgan = false; if( m_HToolBar == NULL ) { - m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, - true ); + m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true ); // Set up toolbar m_HToolBar->AddTool( ID_LIBVIEW_SELECT_LIB, wxEmptyString, @@ -105,8 +105,7 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar() m_HToolBar->Realize(); } - if( (m_libraryName != wxEmptyString) - && (m_entryName != wxEmptyString) ) + if( (m_libraryName != wxEmptyString) && (m_entryName != wxEmptyString) ) { lib = CMP_LIBRARY::FindLibrary( m_libraryName ); diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index e19908cc16..cd01699226 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -25,9 +25,9 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event ) { - wxString msg; - CMP_LIB_ENTRY* LibEntry; - int ii, id = event.GetId(); + wxString msg; + LIB_ALIAS* LibEntry; + int ii, id = event.GetId(); switch( id ) { @@ -48,8 +48,7 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_LIBVIEW_VIEWDOC: - LibEntry = CMP_LIBRARY::FindLibraryEntry( m_entryName, - m_libraryName ); + LibEntry = CMP_LIBRARY::FindLibraryEntry( m_entryName, m_libraryName ); if( LibEntry && ( !LibEntry->GetDocFileName().IsEmpty() ) ) GetAssociatedDocument( this, LibEntry->GetDocFileName(), @@ -168,7 +167,7 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option ) return; } - CMP_LIB_ENTRY* LibEntry = Lib->FindEntry( m_entryName ); + LIB_ALIAS* LibEntry = Lib->FindEntry( m_entryName ); if( LibEntry == NULL ) return; @@ -186,9 +185,9 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option ) /*************************************************/ void WinEDA_ViewlibFrame::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag ) { - int NumOfParts = 0; - CMP_LIB_ENTRY* LibEntry; - wxString CmpName; + int NumOfParts = 0; + LIB_ALIAS* LibEntry; + wxString CmpName; if( Lib ) NumOfParts = Lib->GetCount(); @@ -249,7 +248,7 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag ) void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) { LIB_COMPONENT* component; - CMP_LIB_ENTRY* entry; + LIB_ALIAS* entry; CMP_LIBRARY* lib; wxString msg; wxString tmp; @@ -266,22 +265,17 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) if( entry == NULL ) return; - wxCHECK_RET( entry->isAlias(), - wxT( "Entry \"" ) + entry->GetName() + wxT( "\" found in library <" ) + - lib->GetName() + wxT( "> is not a LIB_ALIAS object." ) ); - - LIB_ALIAS* alias = (LIB_ALIAS*) entry; - component = alias->GetComponent(); + component = entry->GetComponent(); DrawPanel->DrawBackGround( DC ); - if( !alias->IsRoot() ) + if( !entry->IsRoot() ) { if( component == NULL ) // Should not occur return; // Temporarily change the name field text to reflect the alias name. - msg = alias->GetName(); + msg = entry->GetName(); tmp = component->GetName(); component->SetName( msg ); diff --git a/include/base_struct.h b/include/base_struct.h index 7410c3fccf..a0febffc53 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -71,7 +71,8 @@ enum KICAD_T { * If you add a new draw item, type, please make sure you add it so the * sort order is logical. */ - LIBCOMPONENT_STRUCT_TYPE, + LIB_COMPONENT_T, + LIB_ALIAS_T, COMPONENT_ARC_DRAW_TYPE, COMPONENT_CIRCLE_DRAW_TYPE, COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, @@ -258,32 +259,25 @@ class DHEAD; // These define are used for the .m_Flags and .m_UndoRedoStatus member of the // class EDA_BaseStruct -#define IS_CHANGED (1 << 0) -#define IS_LINKED (1 << 1) -#define IN_EDIT (1 << 2) -#define IS_MOVED (1 << 3) -#define IS_NEW (1 << 4) -#define IS_RESIZED (1 << 5) -#define IS_DRAGGED (1 << 6) -#define IS_DELETED (1 << 7) -#define IS_WIRE_IMAGE (1 << 8) -#define STARTPOINT (1 << 9) -#define ENDPOINT (1 << 10) -#define SELECTED (1 << 11) -#define SELECTEDNODE (1 << 12) ///< flag indicating that the structure - // has already selected - -#define STRUCT_DELETED (1 << 13) ///< flag indication structures to be - // erased - -#define CANDIDATE (1 << 14) ///< flag indicating that the structure - // is connected -#define SKIP_STRUCT (1 << 15) ///< flag indicating that the structure - // should be ignored - -#define DO_NOT_DRAW (1 << 16) ///< Used to disable draw function -#define IS_CANCELLED (1 << 17) ///< flag set when edit dialogs are - // canceled when editing a new object +#define IS_CHANGED (1 << 0) +#define IS_LINKED (1 << 1) +#define IN_EDIT (1 << 2) +#define IS_MOVED (1 << 3) +#define IS_NEW (1 << 4) +#define IS_RESIZED (1 << 5) +#define IS_DRAGGED (1 << 6) +#define IS_DELETED (1 << 7) +#define IS_WIRE_IMAGE (1 << 8) +#define STARTPOINT (1 << 9) +#define ENDPOINT (1 << 10) +#define SELECTED (1 << 11) +#define SELECTEDNODE (1 << 12) ///< flag indicating that the structure has already selected +#define STRUCT_DELETED (1 << 13) ///< flag indication structures to be erased +#define CANDIDATE (1 << 14) ///< flag indicating that the structure is connected +#define SKIP_STRUCT (1 << 15) ///< flag indicating that the structure should be ignored +#define DO_NOT_DRAW (1 << 16) ///< Used to disable draw function +#define IS_CANCELLED (1 << 17) ///< flag set when edit dialogs are canceled when editing a + ///< new object class EDA_BaseStruct { @@ -350,6 +344,10 @@ public: void SetSon( EDA_BaseStruct* aSon ) { m_Son = aSon; } void SetList( DHEAD* aList ) { m_List = aList; } + inline bool IsNew() const { return m_Flags & IS_NEW; } + inline bool IsModified() const { return m_Flags & IS_CHANGED; } + inline bool IsMoving() const { return m_Flags & IS_MOVED; } + inline bool IsDragging() const { return m_Flags & IS_DRAGGED; } int GetState( int type ) const { diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index d6a49ba28e..f461724fca 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -20,7 +20,6 @@ class SCH_ITEM; class SCH_NO_CONNECT; class CMP_LIBRARY; class LIB_COMPONENT; -class CMP_LIB_ENTRY; class LIB_DRAW_ITEM; class EDA_BaseStruct; class SCH_BUS_ENTRY;