Commit 6566b0c5 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Schematic component library object improvements and other minor fixes.

parent 9afa8926
...@@ -4,6 +4,21 @@ KiCad ChangeLog 2010 ...@@ -4,6 +4,21 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2010-oct-25 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++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 <stambaughw@verizon.net> 2010-oct-22 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================ ================================================================================
Component library editor bug fixes and other minor fixes. Component library editor bug fixes and other minor fixes.
......
...@@ -932,9 +932,9 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, ...@@ -932,9 +932,9 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ); wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
/* Skip items not used for this part */ /* Skip items not used for this part */
if( Multi && Pin->m_Unit && ( Pin->m_Unit != Multi ) ) if( Multi && Pin->GetUnit() && ( Pin->GetUnit() != Multi ) )
continue; continue;
if( convert && Pin->m_Convert && ( Pin->m_Convert != convert ) ) if( convert && Pin->GetConvert() && ( Pin->GetConvert() != convert ) )
continue; continue;
/* Calculate the pin position (according to the component orientation) /* Calculate the pin position (according to the component orientation)
......
This diff is collapsed.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
class CMP_LIBRARY; class CMP_LIBRARY;
class LIB_ALIAS; class LIB_ALIAS;
class LIB_COMPONENT;
class LIB_FIELD; class LIB_FIELD;
...@@ -32,15 +33,6 @@ typedef std::map< wxString, LIB_ALIAS*, AliasMapSort > LIB_ALIAS_MAP; ...@@ -32,15 +33,6 @@ typedef std::map< wxString, LIB_ALIAS*, AliasMapSort > LIB_ALIAS_MAP;
typedef std::vector< LIB_ALIAS* > LIB_ALIAS_LIST; 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 */ /* values for member .m_options */
enum LibrEntryOptions enum LibrEntryOptions
{ {
...@@ -50,51 +42,60 @@ enum LibrEntryOptions ...@@ -50,51 +42,60 @@ enum LibrEntryOptions
/** /**
* Class CMP_LIB_ENTRY * Component library alias object definition.
* is a base class to describe library components and aliases.
* *
* 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
{ {
protected: /**
wxString name; * The actual component of the alias.
*
/// Library object that entry is attached to. * @note - Do not delete the root component. The root component is actually shared by
CMP_LIBRARY* library; * 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;
/// Entry type, either ROOT or ALIAS. friend class LIB_COMPONENT;
LibrEntryType type;
protected:
wxString name;
wxString description; ///< documentation for info wxString description; ///< documentation for info
wxString keyWords; ///< keyword list (used for search for components by keyword) wxString keyWords; ///< keyword list (used for search for components by keyword)
wxString docFileName; ///< Associate doc file name wxString docFileName; ///< Associate doc file name
public: public:
CMP_LIB_ENTRY( LibrEntryType aType, const wxString& aName, CMP_LIBRARY* aLibrary = NULL ); LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent );
CMP_LIB_ENTRY( CMP_LIB_ENTRY& aEntry, CMP_LIBRARY* aLibrary = NULL ); LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_COMPONENT* aRootComponent = NULL );
virtual ~CMP_LIB_ENTRY(); virtual ~LIB_ALIAS();
virtual wxString GetClass() const 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(); virtual wxString GetLibraryName();
CMP_LIBRARY* GetLibrary() { return library; } bool IsRoot() const;
CMP_LIBRARY* GetLibrary();
virtual const wxString& GetName() const { return name; } virtual const wxString& GetName() const { return name; }
virtual void SetName( const wxString& aName ) { name = aName; } 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 ) void SetDescription( const wxString& aDescription )
{ {
description = aDescription; description = aDescription;
...@@ -133,12 +134,12 @@ public: ...@@ -133,12 +134,12 @@ public:
return !( *this == aName ); 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 ...@@ -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). * A library component object is typically saved and loaded in a component library file (.lib).
* Library components are different from schematic components. * 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 int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to 0
///< to draw the pin name above the pin. ///< to draw the pin name above the pin.
bool m_unitsLocked; ///< True if component has multiple parts and changing bool m_unitsLocked; ///< True if component has multiple parts and changing
...@@ -157,12 +159,13 @@ class LIB_COMPONENT : public CMP_LIB_ENTRY ...@@ -157,12 +159,13 @@ class LIB_COMPONENT : public CMP_LIB_ENTRY
bool m_showPinNumbers; ///< Determines if component pin numbers are visible. bool m_showPinNumbers; ///< Determines if component pin numbers are visible.
long m_dateModified; ///< Date the component was last modified. long m_dateModified; ///< Date the component was last modified.
LibrEntryOptions m_options; ///< Special component features such as POWER or NORMAL.) 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. LIB_DRAW_ITEM_LIST drawings; ///< How to draw this part.
wxArrayString m_FootprintList; /**< List of suitable footprint names for the wxArrayString m_FootprintList; /**< List of suitable footprint names for the
component (wild card names accepted). */ component (wild card names accepted). */
LIB_ALIAS_LIST m_aliases; ///< List of alias object pointers associated with the LIB_ALIAS_LIST m_aliases; ///< List of alias object pointers associated with the
///< component. ///< component.
CMP_LIBRARY* m_library; ///< Library the component belongs to if any.
void deleteAllFields(); void deleteAllFields();
...@@ -183,7 +186,11 @@ public: ...@@ -183,7 +186,11 @@ public:
virtual void SetName( const wxString& aName ); 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; wxArrayString GetAliasNames( bool aIncludeRoot = true ) const;
...@@ -512,13 +519,13 @@ public: ...@@ -512,13 +519,13 @@ public:
*/ */
void SetPartCount( int count ); void SetPartCount( int count );
int GetPartCount() { return unitCount; } int GetPartCount() { return m_unitCount; }
/** function IsMulti /** function IsMulti
* @return true if the component has multiple parts per package. * @return true if the component has multiple parts per package.
* When happens, the reference has a sub reference ti identify part * When happens, the reference has a sub reference ti identify part
*/ */
bool IsMulti() { return unitCount > 1; } bool IsMulti() { return m_unitCount > 1; }
/** function IsMulti /** function IsMulti
* @return the sub reference for component having multiple parts per package. * @return the sub reference for component having multiple parts per package.
...@@ -574,52 +581,4 @@ public: ...@@ -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 #endif // CLASS_LIBENTRY_H
...@@ -174,13 +174,13 @@ bool CMP_LIBRARY::Conflicts( LIB_COMPONENT* aComponent ) ...@@ -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 ) ); LIB_ALIAS_MAP::iterator it = aliases.find( wxString( aName ) );
if( it != aliases.end() ) if( it != aliases.end() )
return ( CMP_LIB_ENTRY* ) (*it).second; return (*it).second;
return NULL; return NULL;
} }
...@@ -190,10 +190,10 @@ CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* aName ) ...@@ -190,10 +190,10 @@ CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* aName )
* Return the first entry in the library. * Return the first entry in the library.
* @return The first entry or NULL if the library has no entries. * @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() ) if( aliases.size() )
return ( LIB_ALIAS* ) (*aliases.begin()).second; return (*aliases.begin()).second;
else else
return NULL; return NULL;
} }
...@@ -201,16 +201,10 @@ CMP_LIB_ENTRY* CMP_LIBRARY::GetFirstEntry() ...@@ -201,16 +201,10 @@ CMP_LIB_ENTRY* CMP_LIBRARY::GetFirstEntry()
LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxChar* aName ) LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxChar* aName )
{ {
LIB_COMPONENT* component = NULL; LIB_COMPONENT* component = NULL;
CMP_LIB_ENTRY* entry = FindEntry( aName ); LIB_ALIAS* entry = FindEntry( aName );
if( entry != NULL ) if( entry != NULL )
{ component = entry->GetComponent();
wxCHECK_MSG( entry->isAlias(), NULL,
wxT( "Component found in library entry list, bad programmer!" ) );
LIB_ALIAS* alias = (LIB_ALIAS*) entry;
component = alias->GetComponent();
}
return component; return component;
} }
...@@ -276,7 +270,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) ...@@ -276,7 +270,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
LIB_ALIAS* alias = FindAlias( aliasname ); LIB_ALIAS* alias = FindAlias( aliasname );
if( alias != NULL ) if( alias != NULL )
RemoveEntry( (CMP_LIB_ENTRY*) alias ); RemoveEntry( alias );
aliases[ aliasname ] = newCmp->m_aliases[i]; aliases[ aliasname ] = newCmp->m_aliases[i];
} }
...@@ -287,10 +281,9 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) ...@@ -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, wxCHECK_MSG( aEntry != NULL, NULL, wxT( "NULL pointer cannot be removed from library." ) );
wxT( "Only LIB_ALIAS pointers can be removed from library." ) );
LIB_ALIAS_MAP::iterator it = aliases.find( aEntry->GetName() ); LIB_ALIAS_MAP::iterator it = aliases.find( aEntry->GetName() );
...@@ -326,7 +319,7 @@ CMP_LIB_ENTRY* CMP_LIBRARY::RemoveEntry( CMP_LIB_ENTRY* aEntry ) ...@@ -326,7 +319,7 @@ CMP_LIB_ENTRY* CMP_LIBRARY::RemoveEntry( CMP_LIB_ENTRY* aEntry )
aliases.erase( it ); aliases.erase( it );
isModified = true; isModified = true;
return (CMP_LIB_ENTRY*) alias; return alias;
} }
...@@ -354,7 +347,7 @@ LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent, ...@@ -354,7 +347,7 @@ LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent,
while( i != 0 ) while( i != 0 )
{ {
i -= 1; i -= 1;
RemoveEntry( (CMP_LIB_ENTRY*) aOldComponent->m_aliases[ i ] ); RemoveEntry( aOldComponent->m_aliases[ i ] );
} }
LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aNewComponent, this ); LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aNewComponent, this );
...@@ -371,7 +364,7 @@ LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent, ...@@ -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() ) if( aliases.empty() )
return NULL; return NULL;
...@@ -383,11 +376,11 @@ CMP_LIB_ENTRY* CMP_LIBRARY::GetNextEntry( const wxChar* aName ) ...@@ -383,11 +376,11 @@ CMP_LIB_ENTRY* CMP_LIBRARY::GetNextEntry( const wxChar* aName )
if( it == aliases.end() ) if( it == aliases.end() )
it = aliases.begin(); 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() ) if( aliases.empty() )
return NULL; return NULL;
...@@ -399,7 +392,7 @@ CMP_LIB_ENTRY* CMP_LIBRARY::GetPreviousEntry( const wxChar* aName ) ...@@ -399,7 +392,7 @@ CMP_LIB_ENTRY* CMP_LIBRARY::GetPreviousEntry( const wxChar* aName )
it--; it--;
return ( CMP_LIB_ENTRY* ) (*it).second; return (*it).second;
} }
...@@ -551,7 +544,7 @@ the current schematic." ), ...@@ -551,7 +544,7 @@ the current schematic." ),
void CMP_LIBRARY::LoadAliases( LIB_COMPONENT* component ) 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!" ) ); wxT( "Cannot load aliases of NULL component object. Bad programmer!" ) );
for( size_t i = 0; i < component->m_aliases.size(); i++ ) for( size_t i = 0; i < component->m_aliases.size(); i++ )
...@@ -589,12 +582,12 @@ bool CMP_LIBRARY::LoadHeader( FILE* libfile, int* LineNum ) ...@@ -589,12 +582,12 @@ bool CMP_LIBRARY::LoadHeader( FILE* libfile, int* LineNum )
bool CMP_LIBRARY::LoadDocs( wxString& aErrorMsg ) bool CMP_LIBRARY::LoadDocs( wxString& aErrorMsg )
{ {
int lineNumber = 0; int lineNumber = 0;
char line[LINE_BUFFER_LEN_LARGE], * name, * text; char line[LINE_BUFFER_LEN_LARGE], * name, * text;
CMP_LIB_ENTRY* entry; LIB_ALIAS* entry;
FILE* file; FILE* file;
wxString msg; wxString msg;
wxFileName fn = fileName; wxFileName fn = fileName;
fn.SetExt( DOC_EXT ); fn.SetExt( DOC_EXT );
...@@ -647,8 +640,6 @@ bool CMP_LIBRARY::LoadDocs( wxString& aErrorMsg ) ...@@ -647,8 +640,6 @@ bool CMP_LIBRARY::LoadDocs( wxString& aErrorMsg )
if( entry ) if( entry )
{ {
wxASSERT( entry->isAlias() );
switch( line[0] ) switch( line[0] )
{ {
case 'D': case 'D':
...@@ -979,9 +970,9 @@ LIB_COMPONENT* CMP_LIBRARY::FindLibraryComponent( const wxString& aName, ...@@ -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 ) BOOST_FOREACH( CMP_LIBRARY& lib, libraryList )
{ {
......
...@@ -71,7 +71,6 @@ class CMP_LIBRARY ...@@ -71,7 +71,6 @@ class CMP_LIBRARY
static CMP_LIBRARY_LIST libraryList; static CMP_LIBRARY_LIST libraryList;
static wxArrayString libraryListSortOrder; static wxArrayString libraryListSortOrder;
friend class CMP_LIB_ENTRY;
friend class LIB_COMPONENT; friend class LIB_COMPONENT;
public: public:
...@@ -217,12 +216,12 @@ public: ...@@ -217,12 +216,12 @@ public:
* @param aName - Name of entry, case insensitive. * @param aName - Name of entry, case insensitive.
* @return Entry if found. NULL if not found. * @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. * 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. * a LIB_COMPONENT pointer is not required.
* *
* @param aName - Name of component, case insensitive. * @param aName - Name of component, case insensitive.
...@@ -233,7 +232,7 @@ public: ...@@ -233,7 +232,7 @@ public:
/** /**
* Find alias by \a nName. * 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. * a LIB_ALIAS pointer is not required.
* *
* @param aName - Name of alias, case insensitive. * @param aName - Name of alias, case insensitive.
...@@ -280,7 +279,7 @@ public: ...@@ -280,7 +279,7 @@ public:
* @param aEntry - Entry to remove from library. * @param aEntry - Entry to remove from library.
* @return The next entry in the library or NULL if the library is empty. * @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. * Replace an existing component entry in the library.
...@@ -297,7 +296,7 @@ public: ...@@ -297,7 +296,7 @@ public:
* *
* @return The first entry or NULL if the library has no entries. * @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. * Find next library entry by \a aName.
...@@ -308,7 +307,7 @@ public: ...@@ -308,7 +307,7 @@ public:
* @param aName - Name of current entry. * @param aName - Name of current entry.
* @return Next entry if entry name is found. Otherwise NULL. * @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: ...@@ -320,7 +319,7 @@ public:
* @param aName - Name of current entry. * @param aName - Name of current entry.
* @return Previous entry if entry name is found, otherwise NULL. * @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. * Return the file name without path or extension.
...@@ -471,8 +470,8 @@ public: ...@@ -471,8 +470,8 @@ public:
* @param aLibraryName - Name of the library to search. * @param aLibraryName - Name of the library to search.
* @return The entry object if found, otherwise NULL. * @return The entry object if found, otherwise NULL.
*/ */
static CMP_LIB_ENTRY* FindLibraryEntry( const wxString& aEntryName, static LIB_ALIAS* FindLibraryEntry( const wxString& aEntryName,
const wxString& aLibraryName = wxEmptyString ); const wxString& aLibraryName = wxEmptyString );
/** /**
* Function RemoveCacheLibrary * Function RemoveCacheLibrary
......
...@@ -43,8 +43,8 @@ void CreateDummyCmp() ...@@ -43,8 +43,8 @@ void CreateDummyCmp()
LIB_RECTANGLE* Square = new LIB_RECTANGLE( DummyCmp ); LIB_RECTANGLE* Square = new LIB_RECTANGLE( DummyCmp );
Square->m_Pos = wxPoint( -200, 200 ); Square->Move( wxPoint( -200, 200 ) );
Square->m_End = wxPoint( 200, -200 ); Square->SetEndPosition( wxPoint( 200, -200 ) );
LIB_TEXT* Text = new LIB_TEXT( DummyCmp ); LIB_TEXT* Text = new LIB_TEXT( DummyCmp );
...@@ -537,8 +537,6 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number ) ...@@ -537,8 +537,6 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number )
if( Entry == NULL ) if( Entry == NULL )
return NULL; return NULL;
wxASSERT( Entry->isComponent() );
return Entry->GetPin( number, m_Multi, m_Convert ); return Entry->GetPin( number, m_Multi, m_Convert );
} }
...@@ -1127,10 +1125,10 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1127,10 +1125,10 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
// search for the component in lib // search for the component in lib
// Entry and root_component can differ if Entry is an alias // 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 ); LIB_COMPONENT* root_component = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( (Entry == NULL) || (root_component == NULL) ) if( (alias == NULL) || (root_component == NULL) )
return; return;
wxString msg; wxString msg;
...@@ -1149,13 +1147,13 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1149,13 +1147,13 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
// Display component reference in library and library // Display component reference in library and library
frame->AppendMsgPanel( _( "Component" ), m_ChipName, BROWN ); 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( _( "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 // Display description of the component, and keywords found in lib
frame->AppendMsgPanel( _( "Description" ), Entry->GetDescription(), DARKCYAN ); frame->AppendMsgPanel( _( "Description" ), alias->GetDescription(), DARKCYAN );
frame->AppendMsgPanel( _( "Key words" ), Entry->GetKeyWords(), DARKCYAN ); frame->AppendMsgPanel( _( "Key words" ), alias->GetKeyWords(), DARKCYAN );
} }
......
...@@ -346,12 +346,11 @@ void RebuildEndPointsList( std::vector <DANGLING_END_ITEM>& aItemList, SCH_ITEM* ...@@ -346,12 +346,11 @@ void RebuildEndPointsList( std::vector <DANGLING_END_ITEM>& aItemList, SCH_ITEM*
{ {
wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ); wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
if( Pin->m_Unit && STRUCT->m_Multi if( Pin->GetUnit() && STRUCT->m_Multi && ( STRUCT->m_Multi != Pin->GetUnit() ) )
&& ( STRUCT->m_Multi != Pin->m_Unit ) )
continue; continue;
if( Pin->m_Convert && STRUCT->m_Convert if( Pin->GetConvert() && STRUCT->m_Convert
&& ( STRUCT->m_Convert != Pin->m_Convert ) ) && ( STRUCT->m_Convert != Pin->GetConvert() ) )
continue; continue;
DANGLING_END_ITEM item( PIN_END, Pin ); DANGLING_END_ITEM item( PIN_END, Pin );
......
...@@ -76,7 +76,7 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys, ...@@ -76,7 +76,7 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
void DisplayCmpDoc( wxString& Name ) void DisplayCmpDoc( wxString& Name )
{ {
CMP_LIB_ENTRY* CmpEntry = NULL; LIB_ALIAS* CmpEntry = NULL;
CmpEntry = CMP_LIBRARY::FindLibraryEntry( Name ); CmpEntry = CMP_LIBRARY::FindLibraryEntry( Name );
......
...@@ -154,5 +154,5 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel() ...@@ -154,5 +154,5 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
m_SelNumberOfUnits->SetValue( component->GetPartCount() ); m_SelNumberOfUnits->SetValue( component->GetPartCount() );
m_SetSkew->SetValue( component->GetPinNameOffset() ); m_SetSkew->SetValue( component->GetPinNameOffset() );
m_OptionPower->SetValue( component->IsPower() ); m_OptionPower->SetValue( component->IsPower() );
m_OptionPartsLocked->SetValue( component->UnitsLocked() ); m_OptionPartsLocked->SetValue( component->UnitsLocked() && component->GetPartCount() > 1 );
} }
...@@ -35,8 +35,8 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( wxWindow* aParent, wxFindReplaceData* aData, ...@@ -35,8 +35,8 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( wxWindow* aParent, wxFindReplaceData* aData,
m_checkWrap->SetValue( flags & FR_SEARCH_WRAP ); m_checkWrap->SetValue( flags & FR_SEARCH_WRAP );
m_checkCurrentSheetOnly->SetValue( flags & FR_CURRENT_SHEET_ONLY ); m_checkCurrentSheetOnly->SetValue( flags & FR_CURRENT_SHEET_ONLY );
m_buttonFind->SetDefault();
m_comboFind->SetFocus(); m_comboFind->SetFocus();
SetPosition( aPosition ); SetPosition( aPosition );
SetSize( aSize ); SetSize( aSize );
} }
......
...@@ -33,35 +33,27 @@ ...@@ -33,35 +33,27 @@
void WinEDA_LibeditFrame::OnEditComponentProperties( wxCommandEvent& event ) void WinEDA_LibeditFrame::OnEditComponentProperties( wxCommandEvent& event )
{ {
bool partLocked = GetComponent()->UnitsLocked(); 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 ); DIALOG_EDIT_COMPONENT_IN_LIBRARY dlg( this );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; 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(); UpdateAliasSelectList();
UpdatePartSelectList(); UpdatePartSelectList();
DisplayLibInfos(); DisplayLibInfos();
DisplayCmpDoc(); DisplayCmpDoc();
OnModify( ); OnModify();
DrawPanel->Refresh();
} }
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
{ {
...@@ -144,14 +136,23 @@ 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) ) void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED (event) )
{ {
if( m_Parent == NULL )
return;
LIB_ALIAS* alias;
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
if( component == NULL ) if( component == NULL )
return; return;
m_DocCtrl->SetValue( component->GetDescription() ); alias = component->GetAlias( m_Parent->GetAliasName() );
m_DocfileCtrl->SetValue( component->GetDocFileName() );
m_KeywordsCtrl->SetValue( component->GetKeyWords() ); if( alias == NULL )
return;
m_DocCtrl->SetValue( alias->GetDescription() );
m_DocfileCtrl->SetValue( alias->GetDocFileName() );
m_KeywordsCtrl->SetValue( alias->GetKeyWords() );
} }
......
...@@ -62,9 +62,9 @@ void Dialog_BodyGraphicText_Properties::InitDialog( ) ...@@ -62,9 +62,9 @@ void Dialog_BodyGraphicText_Properties::InitDialog( )
m_TextSize->SetValue( msg ); m_TextSize->SetValue( msg );
m_TextValue->SetValue( m_GraphicText->m_Text ); m_TextValue->SetValue( m_GraphicText->m_Text );
if ( m_GraphicText->m_Unit == 0 ) if ( m_GraphicText->GetUnit() == 0 )
m_CommonUnit->SetValue( TRUE ); m_CommonUnit->SetValue( TRUE );
if ( m_GraphicText->m_Convert == 0 ) if ( m_GraphicText->GetConvert() == 0 )
m_CommonConvert->SetValue( TRUE ); m_CommonConvert->SetValue( TRUE );
if ( m_GraphicText->m_Orient == TEXT_ORIENT_VERT ) if ( m_GraphicText->m_Orient == TEXT_ORIENT_VERT )
m_Orient->SetValue( TRUE ); m_Orient->SetValue( TRUE );
...@@ -163,14 +163,14 @@ void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event ) ...@@ -163,14 +163,14 @@ void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event )
m_GraphicText->m_Orient = m_Parent->m_textOrientation; m_GraphicText->m_Orient = m_Parent->m_textOrientation;
if( m_Parent->m_drawSpecificUnit ) if( m_Parent->m_drawSpecificUnit )
m_GraphicText->m_Unit = m_Parent->GetUnit(); m_GraphicText->SetUnit( m_Parent->GetUnit() );
else else
m_GraphicText->m_Unit = 0; m_GraphicText->SetUnit( 0 );
if( m_Parent->m_drawSpecificConvert ) if( m_Parent->m_drawSpecificConvert )
m_GraphicText->m_Convert = m_Parent->GetConvert(); m_GraphicText->SetConvert( m_Parent->GetConvert() );
else else
m_GraphicText->m_Convert = 0; m_GraphicText->SetConvert( 0 );
if ( (m_TextShapeOpt->GetSelection() & 1 ) != 0 ) if ( (m_TextShapeOpt->GetSelection() & 1 ) != 0 )
m_GraphicText->m_Italic = true; m_GraphicText->m_Italic = true;
......
...@@ -182,7 +182,7 @@ bool LIB_ARC::HitTest( const wxPoint& aRefPoint ) ...@@ -182,7 +182,7 @@ bool LIB_ARC::HitTest( const wxPoint& aRefPoint )
bool LIB_ARC::HitTest( wxPoint aReferencePoint, int aThreshold, const TRANSFORM& aTransform ) 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; wxPoint relativePosition = aReferencePoint;
NEGATE( relativePosition.y ); // reverse Y axis NEGATE( relativePosition.y ); // reverse Y axis
...@@ -271,7 +271,7 @@ void LIB_ARC::DoOffset( const wxPoint& aOffset ) ...@@ -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 ) return aRect.Inside( m_ArcStart.x, -m_ArcStart.y )
|| aRect.Inside( m_ArcEnd.x, -m_ArcEnd.y ); || aRect.Inside( m_ArcEnd.x, -m_ArcEnd.y );
...@@ -335,7 +335,7 @@ int LIB_ARC::GetPenSize() ...@@ -335,7 +335,7 @@ int LIB_ARC::GetPenSize()
void LIB_ARC::drawEditGraphics( EDA_Rect* aClipBox, wxDC* aDC, int aColor ) 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 ) if( ( m_Flags & IS_NEW ) == 0 )
return; return;
...@@ -356,7 +356,7 @@ void LIB_ARC::drawEditGraphics( EDA_Rect* aClipBox, wxDC* aDC, int aColor ) ...@@ -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, void LIB_ARC::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform ) 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. // get drawn at this time.
if( ( m_Flags & IS_NEW ) && m_lastEditState == 1 ) if( ( m_Flags & IS_NEW ) && m_lastEditState == 1 )
return; return;
...@@ -539,7 +539,7 @@ void LIB_ARC::BeginEdit( int aEditMode, const wxPoint aPosition ) ...@@ -539,7 +539,7 @@ void LIB_ARC::BeginEdit( int aEditMode, const wxPoint aPosition )
} }
else else
{ {
// Save the current arc positions in case the resize ia aborted. // Save the current arc positions in case the resize is aborted.
saveAttributes(); saveAttributes();
// The arc center point has to be rotated with while adjusting the // The arc center point has to be rotated with while adjusting the
......
...@@ -21,6 +21,13 @@ class LIB_ARC : public LIB_DRAW_ITEM ...@@ -21,6 +21,13 @@ class LIB_ARC : public LIB_DRAW_ITEM
OUTLINE, 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_savedStartPos;
wxPoint m_savedEndPos; wxPoint m_savedEndPos;
int m_savedAngle1; int m_savedAngle1;
...@@ -66,15 +73,6 @@ class LIB_ARC : public LIB_DRAW_ITEM ...@@ -66,15 +73,6 @@ class LIB_ARC : public LIB_DRAW_ITEM
*/ */
void calcRadiusAngles(); 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: public:
LIB_ARC( LIB_COMPONENT * aParent ); LIB_ARC( LIB_COMPONENT * aParent );
LIB_ARC( const LIB_ARC& aArc ); LIB_ARC( const LIB_ARC& aArc );
...@@ -149,13 +147,13 @@ protected: ...@@ -149,13 +147,13 @@ protected:
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); 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 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 DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ); const TRANSFORM& aTransform );
virtual int DoGetWidth() { return m_Width; } virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
}; };
......
...@@ -158,7 +158,7 @@ void LIB_BEZIER::DoOffset( const wxPoint& aOffset ) ...@@ -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++ ) for( size_t i = 0; i < m_PolyPoints.size(); i++ )
{ {
......
...@@ -11,17 +11,16 @@ ...@@ -11,17 +11,16 @@
/**************************************************/ /**************************************************/
class LIB_BEZIER : public LIB_DRAW_ITEM class LIB_BEZIER : public LIB_DRAW_ITEM
{ {
int m_Width; // Line width
std::vector<wxPoint> m_BezierPoints; // list of parameter (3|4)
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
/** /**
* Draw the bezier curve. * Draw the bezier curve.
*/ */
void drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, void drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform ); int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform );
public:
int m_Width; /* Line width */
std::vector<wxPoint> m_BezierPoints; // list of parameter (3|4)
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
public: public:
LIB_BEZIER( LIB_COMPONENT * aParent ); LIB_BEZIER( LIB_COMPONENT * aParent );
LIB_BEZIER( const LIB_BEZIER& aBezier ); LIB_BEZIER( const LIB_BEZIER& aBezier );
...@@ -90,13 +89,13 @@ protected: ...@@ -90,13 +89,13 @@ protected:
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); 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 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 DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ); const TRANSFORM& aTransform );
virtual int DoGetWidth() { return m_Width; } virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
}; };
......
...@@ -145,10 +145,10 @@ void LIB_CIRCLE::DoOffset( const wxPoint& aOffset ) ...@@ -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. * point.
*/ */
return aRect.Inside( m_Pos.x, -m_Pos.y ); return aRect.Inside( m_Pos.x, -m_Pos.y );
......
...@@ -11,7 +11,11 @@ ...@@ -11,7 +11,11 @@
class LIB_CIRCLE : public LIB_DRAW_ITEM 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. * Draws the arc.
...@@ -36,12 +40,6 @@ class LIB_CIRCLE : public LIB_DRAW_ITEM ...@@ -36,12 +40,6 @@ class LIB_CIRCLE : public LIB_DRAW_ITEM
*/ */
void calcEdit( const wxPoint& aPosition ); 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: public:
LIB_CIRCLE( LIB_COMPONENT * aParent ); LIB_CIRCLE( LIB_COMPONENT * aParent );
LIB_CIRCLE( const LIB_CIRCLE& aCircle ); LIB_CIRCLE( const LIB_CIRCLE& aCircle );
...@@ -115,13 +113,13 @@ protected: ...@@ -115,13 +113,13 @@ protected:
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); 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 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 DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ); const TRANSFORM& aTransform );
virtual int DoGetWidth() { return m_Width; } virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
}; };
......
...@@ -127,7 +127,7 @@ void LIB_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aO ...@@ -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 ); 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 ); calcEdit( aOffset );
// Draw the items using the new attributes. // Draw the items using the new attributes.
......
...@@ -21,11 +21,6 @@ class LIB_PIN; ...@@ -21,11 +21,6 @@ class LIB_PIN;
extern const int fill_tab[]; 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 #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; ...@@ -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 * 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. * deleted when the container is deleted.
*/ */
typedef std::vector< LIB_PIN* > LIB_PIN_LIST; typedef std::vector< LIB_PIN* > LIB_PIN_LIST;
...@@ -84,7 +79,6 @@ class LIB_DRAW_ITEM : public EDA_BaseStruct ...@@ -84,7 +79,6 @@ class LIB_DRAW_ITEM : public EDA_BaseStruct
*/ */
virtual void calcEdit( const wxPoint& aPosition ) {} virtual void calcEdit( const wxPoint& aPosition ) {}
/** /**
* Save the current item attributes while editing. * Save the current item attributes while editing.
* *
...@@ -100,12 +94,10 @@ class LIB_DRAW_ITEM : public EDA_BaseStruct ...@@ -100,12 +94,10 @@ class LIB_DRAW_ITEM : public EDA_BaseStruct
bool m_eraseLastDrawItem; ///< Used when editing a new draw item to prevent drawing bool m_eraseLastDrawItem; ///< Used when editing a new draw item to prevent drawing
///< artifacts. ///< 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 * Unit identification for multiple parts per package. Set to 0 if the
* item is common to all units. * item is common to all units.
...@@ -125,7 +117,11 @@ public: ...@@ -125,7 +117,11 @@ public:
*/ */
FILL_T m_Fill; 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: public:
...@@ -139,13 +135,15 @@ public: ...@@ -139,13 +135,15 @@ public:
virtual ~LIB_DRAW_ITEM() { } virtual ~LIB_DRAW_ITEM() { }
wxString GetTypeName() { return m_typeName; }
/** /**
* Begin an editing a component library draw item in \a aEditMode at \a aPosition. * 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. * 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 * 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 * 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. * edited. Call AbortEdit() to quit the editing mode.
* *
* @param aEditMode - The editing mode being performed. See base_struct.h for a list * @param aEditMode - The editing mode being performed. See base_struct.h for a list
...@@ -223,7 +221,7 @@ public: ...@@ -223,7 +221,7 @@ public:
* *
* Derived classes should override this function. * 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 * @return - true if a hit, else false
*/ */
virtual bool HitTest( const wxPoint& aPosition ) virtual bool HitTest( const wxPoint& aPosition )
...@@ -283,7 +281,7 @@ public: ...@@ -283,7 +281,7 @@ public:
/** /**
* Set drawing object offset from the current position. * 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 ); } void SetOffset( const wxPoint& aOffset ) { DoOffset( aOffset ); }
...@@ -296,7 +294,7 @@ public: ...@@ -296,7 +294,7 @@ public:
* @param aRect - Rectangle to check against. * @param aRect - Rectangle to check against.
* @return - True if object is inside rectangle. * @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. * Move a draw object to a new \a aPosition.
...@@ -310,7 +308,7 @@ public: ...@@ -310,7 +308,7 @@ public:
/** /**
* Return the current draw object start position. * 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. * Mirror the draw object along the horizontal (X) axis about a point.
...@@ -345,7 +343,7 @@ public: ...@@ -345,7 +343,7 @@ public:
* *
* @return Width of draw object. * @return Width of draw object.
*/ */
int GetWidth() { return DoGetWidth(); } int GetWidth() const { return DoGetWidth(); }
void SetWidth( int aWidth ) { DoSetWidth( aWidth ); } void SetWidth( int aWidth ) { DoSetWidth( aWidth ); }
/** /**
...@@ -356,30 +354,14 @@ public: ...@@ -356,30 +354,14 @@ public:
* *
* @return - True if draw object can be fill. Default is false. * @return - True if draw object can be fill. Default is false.
*/ */
bool IsFillable() { return m_isFillable; } bool IsFillable() const { 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 ); }
/** /**
* Return the draw item editing mode status. * Return the draw item editing mode status.
* *
* @return - True if the item is being edited. * @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; } void SetEraseLastDrawItem( bool aErase = true ) { m_eraseLastDrawItem = aErase; }
...@@ -387,11 +369,15 @@ public: ...@@ -387,11 +369,15 @@ public:
void SetUnit( int aUnit ) { m_Unit = aUnit; } 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; } 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: protected:
virtual LIB_DRAW_ITEM* DoGenCopy() = 0; virtual LIB_DRAW_ITEM* DoGenCopy() = 0;
...@@ -409,13 +395,13 @@ protected: ...@@ -409,13 +395,13 @@ protected:
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const = 0; virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const = 0;
virtual void DoOffset( const wxPoint& aOffset ) = 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 void DoMove( const wxPoint& aPosition ) = 0;
virtual wxPoint DoGetPosition() = 0; virtual wxPoint DoGetPosition() const = 0;
virtual void DoMirrorHorizontal( const wxPoint& aCenter ) = 0; virtual void DoMirrorHorizontal( const wxPoint& aCenter ) = 0;
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ) = 0; const TRANSFORM& aTransform ) = 0;
virtual int DoGetWidth() = 0; virtual int DoGetWidth() const = 0;
virtual void DoSetWidth( int aWidth ) = 0; virtual void DoSetWidth( int aWidth ) = 0;
/** Flag to indicate if draw item is fillable. Default is false. */ /** Flag to indicate if draw item is fillable. Default is false. */
......
...@@ -34,10 +34,10 @@ extern int ExportPartId; ...@@ -34,10 +34,10 @@ extern int ExportPartId;
*/ */
void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event ) void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event )
{ {
wxString errMsg; wxString errMsg;
wxFileName fn; wxFileName fn;
CMP_LIBRARY* LibTmp; CMP_LIBRARY* LibTmp;
CMP_LIB_ENTRY* LibEntry; LIB_ALIAS* LibEntry;
m_lastDrawItem = NULL; m_lastDrawItem = NULL;
...@@ -61,8 +61,7 @@ void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event ) ...@@ -61,8 +61,7 @@ void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Component library file <%s> is empty." ), msg.Printf( _( "Component library file <%s> is empty." ), GetChars( fn.GetFullPath() ) );
GetChars( fn.GetFullPath() ) );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
......
...@@ -484,7 +484,7 @@ void LIB_FIELD::DoOffset( const wxPoint& offset ) ...@@ -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 * FIXME: This fails to take into acount the size and/or orientation of
......
...@@ -214,13 +214,13 @@ protected: ...@@ -214,13 +214,13 @@ protected:
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); 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 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 DoMirrorHorizontal( const wxPoint& center );
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const TRANSFORM& aTransform ); 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; } virtual void DoSetWidth( int width ) { m_Width = width; }
}; };
......
...@@ -1465,7 +1465,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER *plotter, ...@@ -1465,7 +1465,7 @@ void LIB_PIN::PlotPinTexts( PLOTTER *plotter,
/* return the pin end position, for a component in normal orient */ /* return the pin end position, for a component in normal orient */
wxPoint LIB_PIN::ReturnPinEndPoint() wxPoint LIB_PIN::ReturnPinEndPoint() const
{ {
wxPoint pos = m_Pos; wxPoint pos = m_Pos;
...@@ -1642,7 +1642,7 @@ void LIB_PIN::DoOffset( const wxPoint& offset ) ...@@ -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(); wxPoint end = ReturnPinEndPoint();
......
...@@ -155,7 +155,7 @@ public: ...@@ -155,7 +155,7 @@ public:
virtual void DisplayInfo( WinEDA_DrawFrame* frame ); virtual void DisplayInfo( WinEDA_DrawFrame* frame );
virtual EDA_Rect GetBoundingBox(); virtual EDA_Rect GetBoundingBox();
wxPoint ReturnPinEndPoint(); wxPoint ReturnPinEndPoint() const;
int ReturnPinDrawOrient( const TRANSFORM& aTransform ); int ReturnPinDrawOrient( const TRANSFORM& aTransform );
...@@ -433,13 +433,13 @@ protected: ...@@ -433,13 +433,13 @@ protected:
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); 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 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 DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ); const TRANSFORM& aTransform );
virtual int DoGetWidth() { return m_Width; } virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
}; };
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "plot_common.h" #include "plot_common.h"
#include "trigo.h" #include "trigo.h"
#include "bezier_curves.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
...@@ -155,7 +154,7 @@ void LIB_POLYLINE::DoOffset( const wxPoint& aOffset ) ...@@ -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++ ) 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 ...@@ -252,7 +251,7 @@ void LIB_POLYLINE::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoi
else else
color = aColor; color = aColor;
// Set the size of the buffer od coordinates // Set the size of the buffer of coordinates
if( Buf_Poly_Drawings == NULL ) if( Buf_Poly_Drawings == NULL )
{ {
Buf_Poly_Size = m_PolyPoints.size(); Buf_Poly_Size = m_PolyPoints.size();
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
class LIB_POLYLINE : public LIB_DRAW_ITEM class LIB_POLYLINE : public LIB_DRAW_ITEM
{ {
int m_Width; // Line width
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
int m_ModifyIndex; // Index of the polyline point to modify
std::vector<wxPoint> m_savedPolyPoints; std::vector<wxPoint> m_savedPolyPoints;
/** /**
...@@ -30,17 +34,13 @@ class LIB_POLYLINE : public LIB_DRAW_ITEM ...@@ -30,17 +34,13 @@ class LIB_POLYLINE : public LIB_DRAW_ITEM
void restoreAttributes(); 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. * @param aPosition - Edit position in drawing units.
*/ */
void calcEdit( const wxPoint& aPosition ); void calcEdit( const wxPoint& aPosition );
public: public:
int m_Width; /* Line width */
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
int m_ModifyIndex; // Index of the polyline point to modify
public: public:
LIB_POLYLINE( LIB_COMPONENT * aParent ); LIB_POLYLINE( LIB_COMPONENT * aParent );
LIB_POLYLINE( const LIB_POLYLINE& aPolyline ); LIB_POLYLINE( const LIB_POLYLINE& aPolyline );
...@@ -120,7 +120,7 @@ protected: ...@@ -120,7 +120,7 @@ protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); 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: * The sort order for each polyline segment point is as follows:
* - Line segment point horizontal (X) position. * - Line segment point horizontal (X) position.
...@@ -129,13 +129,13 @@ protected: ...@@ -129,13 +129,13 @@ protected:
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); 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 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 DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ); const TRANSFORM& aTransform );
virtual int DoGetWidth() { return m_Width; } virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
}; };
......
...@@ -116,7 +116,7 @@ void LIB_RECTANGLE::DoOffset( const wxPoint& aOffset ) ...@@ -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 ); return aRect.Inside( m_Pos.x, -m_Pos.y ) || aRect.Inside( m_End.x, -m_End.y );
} }
......
...@@ -11,7 +11,14 @@ ...@@ -11,7 +11,14 @@
class LIB_RECTANGLE : public LIB_DRAW_ITEM 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. * Draw the rectangle.
...@@ -30,20 +37,13 @@ class LIB_RECTANGLE : public LIB_DRAW_ITEM ...@@ -30,20 +37,13 @@ class LIB_RECTANGLE : public LIB_DRAW_ITEM
void restoreAttributes(); 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. * @param aPosition - Edit position in drawing units.
*/ */
void calcEdit( const wxPoint& aPosition ); void calcEdit( const wxPoint& aPosition );
public: 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: public:
LIB_RECTANGLE( LIB_COMPONENT * aParent ); LIB_RECTANGLE( LIB_COMPONENT * aParent );
LIB_RECTANGLE( const LIB_RECTANGLE& aRect ); LIB_RECTANGLE( const LIB_RECTANGLE& aRect );
...@@ -53,6 +53,7 @@ public: ...@@ -53,6 +53,7 @@ public:
return wxT( "LIB_RECTANGLE" ); return wxT( "LIB_RECTANGLE" );
} }
void SetEndPosition( const wxPoint& aPosition ) { m_End = aPosition; }
/** /**
* Write rectangle object out to a FILE in "*.lib" format. * Write rectangle object out to a FILE in "*.lib" format.
...@@ -118,15 +119,15 @@ protected: ...@@ -118,15 +119,15 @@ protected:
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); 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 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 DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ); const TRANSFORM& aTransform );
virtual int DoGetWidth() { return m_Width; } virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
}; };
#endif // _LIB_REACTANGLE_H_ #endif // _LIB_RECTANGLE_H_
...@@ -227,7 +227,7 @@ void LIB_TEXT::DoOffset( const wxPoint& offset ) ...@@ -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 * FIXME: This should calculate the text size and justification and
......
...@@ -144,13 +144,13 @@ protected: ...@@ -144,13 +144,13 @@ protected:
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); 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 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 DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ); const TRANSFORM& aTransform );
virtual int DoGetWidth() { return m_Width; } virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; } virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
}; };
......
...@@ -59,15 +59,15 @@ void WinEDA_LibeditFrame::SelectActiveLibrary() ...@@ -59,15 +59,15 @@ void WinEDA_LibeditFrame::SelectActiveLibrary()
*/ */
void WinEDA_LibeditFrame::LoadOneLibraryPart( wxCommandEvent& event ) void WinEDA_LibeditFrame::LoadOneLibraryPart( wxCommandEvent& event )
{ {
int i; int i;
wxString msg; wxString msg;
wxString CmpName; wxString CmpName;
CMP_LIB_ENTRY* LibEntry = NULL; LIB_ALIAS* LibEntry = NULL;
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
if( GetBaseScreen()->IsModify() && !IsOK( this, _( "Current part not \ if( GetBaseScreen()->IsModify()
saved.\n\nDiscard current changes?" ) ) ) && !IsOK( this, _( "Current part not saved.\n\nDiscard current changes?" ) ) )
return; return;
// No current lib, ask user for the library to use. // No current lib, ask user for the library to use.
...@@ -97,7 +97,7 @@ saved.\n\nDiscard current changes?" ) ) ) ...@@ -97,7 +97,7 @@ saved.\n\nDiscard current changes?" ) ) )
if( LibEntry == NULL ) 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( CmpName ),
GetChars( m_library->GetName() ) ); GetChars( m_library->GetName() ) );
DisplayError( this, msg ); DisplayError( this, msg );
...@@ -125,7 +125,7 @@ saved.\n\nDiscard current changes?" ) ) ) ...@@ -125,7 +125,7 @@ saved.\n\nDiscard current changes?" ) ) )
* 1 if error * 1 if error
* m_component advanced copy and created * 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; wxString msg, cmpName, rootName;
LIB_COMPONENT* component; LIB_COMPONENT* component;
...@@ -142,21 +142,14 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* aEntry, CMP_LIBR ...@@ -142,21 +142,14 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* aEntry, CMP_LIBR
cmpName = m_aliasName = aEntry->GetName(); 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>\"" ), wxLogDebug( wxT( "\"<%s>\" is alias of \"<%s>\"" ),
GetChars( cmpName ), GetChars( cmpName ),
GetChars( component->GetName() ) ); GetChars( component->GetName() ) );
}
else
{
component = (LIB_COMPONENT*) aEntry;
}
if( m_component ) if( m_component )
{ {
...@@ -376,10 +369,10 @@ void WinEDA_LibeditFrame::DisplayCmpDoc() ...@@ -376,10 +369,10 @@ void WinEDA_LibeditFrame::DisplayCmpDoc()
*/ */
void WinEDA_LibeditFrame::DeleteOnePart( wxCommandEvent& event ) void WinEDA_LibeditFrame::DeleteOnePart( wxCommandEvent& event )
{ {
wxString CmpName; wxString CmpName;
CMP_LIB_ENTRY* LibEntry; LIB_ALIAS* LibEntry;
wxArrayString ListNames; wxArrayString ListNames;
wxString msg; wxString msg;
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
...@@ -448,7 +441,7 @@ void WinEDA_LibeditFrame::DeleteOnePart( wxCommandEvent& event ) ...@@ -448,7 +441,7 @@ void WinEDA_LibeditFrame::DeleteOnePart( wxCommandEvent& event )
All changes will be lost. Discard changes?" ) ) ) All changes will be lost. Discard changes?" ) ) )
return; return;
CMP_LIB_ENTRY* nextEntry = m_library->RemoveEntry( LibEntry ); LIB_ALIAS* nextEntry = m_library->RemoveEntry( LibEntry );
if( nextEntry != NULL ) if( nextEntry != NULL )
{ {
...@@ -618,8 +611,6 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory() ...@@ -618,8 +611,6 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory()
m_drawItem = m_lastDrawItem = NULL; m_drawItem = m_lastDrawItem = NULL;
wxASSERT( m_component->isComponent() );
if( oldComponent != NULL ) if( oldComponent != NULL )
Component = m_library->ReplaceComponent( oldComponent, m_component ); Component = m_library->ReplaceComponent( oldComponent, m_component );
else else
......
...@@ -161,7 +161,9 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -161,7 +161,9 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
} }
if( m_drawItem == NULL ) if( m_drawItem == NULL )
{ {
EditComponentProperties(); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetId( ID_LIBEDIT_GET_FRAME_EDIT_PART );
GetEventHandler()->ProcessEvent( cmd );
} }
} }
......
...@@ -24,9 +24,9 @@ class Dialog_BodyGraphicText_Properties; ...@@ -24,9 +24,9 @@ class Dialog_BodyGraphicText_Properties;
class WinEDA_LibeditFrame : public WinEDA_DrawFrame class WinEDA_LibeditFrame : public WinEDA_DrawFrame
{ {
LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit. LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit.
wxString m_oldRootName; ///< The actual pointer of the component loaded from wxString m_oldRootName; ///< The actual pointer of the component loaded from
///< a library. Do not do anything with this pointer. ///< a library. Do not do anything with this pointer.
///< It is to be used for reference purposes only. ///< It is to be used for reference purposes only.
public: public:
WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any) WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any)
...@@ -210,10 +210,9 @@ private: ...@@ -210,10 +210,9 @@ private:
void SelectActiveLibrary(); void SelectActiveLibrary();
void SaveActiveLibrary( wxCommandEvent& event ); void SaveActiveLibrary( wxCommandEvent& event );
bool LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry, CMP_LIBRARY* Library ); bool LoadOneLibraryPartAux( LIB_ALIAS* LibEntry, CMP_LIBRARY* Library );
void DisplayCmpDoc(); void DisplayCmpDoc();
void EditComponentProperties();
// General editing // General editing
public: public:
......
...@@ -722,11 +722,11 @@ XNODE* EXPORT_HELP::makeGenericLibParts() ...@@ -722,11 +722,11 @@ XNODE* EXPORT_HELP::makeGenericLibParts()
xlibpart->AddAttribute( sPart, lcomp->GetName() ); xlibpart->AddAttribute( sPart, lcomp->GetName() );
//----- show the important properties ------------------------- //----- show the important properties -------------------------
if( !lcomp->GetDescription().IsEmpty() ) if( !lcomp->GetAlias( 0 )->GetDescription().IsEmpty() )
xlibpart->AddChild( node( sDescr, lcomp->GetDescription() ) ); xlibpart->AddChild( node( sDescr, lcomp->GetAlias( 0 )->GetDescription() ) );
if( !lcomp->GetDocFileName().IsEmpty() ) if( !lcomp->GetAlias( 0 )->GetDocFileName().IsEmpty() )
xlibpart->AddChild( node( sDocs, lcomp->GetDocFileName() ) ); xlibpart->AddChild( node( sDocs, lcomp->GetAlias( 0 )->GetDocFileName() ) );
// Write the footprint list // Write the footprint list
if( lcomp->GetFootPrints().GetCount() ) if( lcomp->GetFootPrints().GetCount() )
...@@ -1581,10 +1581,10 @@ void EXPORT_HELP::findAllInstancesOfComponent( SCH_COMPONENT* aComponent, ...@@ -1581,10 +1581,10 @@ void EXPORT_HELP::findAllInstancesOfComponent( SCH_COMPONENT* aComponent,
{ {
wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE ); wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
if( pin->m_Unit && pin->m_Unit != unit2 ) if( pin->GetUnit() && pin->GetUnit() != unit2 )
continue; continue;
if( pin->m_Convert && pin->m_Convert != comp2->m_Convert ) if( pin->GetConvert() && pin->GetConvert() != comp2->m_Convert )
continue; continue;
// A suitable pin is found: add it to the current list // A suitable pin is found: add it to the current list
......
...@@ -594,12 +594,11 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -594,12 +594,11 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
{ {
wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE ); wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
if( pin->m_Unit && if( pin->GetUnit() &&
( pin->m_Unit != DrawLibItem->GetUnitSelection( sheetlist ) ) ) ( pin->GetUnit() != DrawLibItem->GetUnitSelection( sheetlist ) ) )
continue; continue;
if( pin->m_Convert && if( pin->GetConvert() && ( pin->GetConvert() != DrawLibItem->m_Convert ) )
( pin->m_Convert != DrawLibItem->m_Convert ) )
continue; continue;
wxPoint pos2 = DrawLibItem->m_Transform.TransformCoordinate( pin->m_Pos ) + wxPoint pos2 = DrawLibItem->m_Transform.TransformCoordinate( pin->m_Pos ) +
......
...@@ -244,18 +244,13 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) ...@@ -244,18 +244,13 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
} }
wxString msg; wxString msg;
CMP_LIB_ENTRY* libEntry; LIB_ALIAS* libEntry;
LIB_COMPONENT* libComponent = NULL; LIB_COMPONENT* libComponent = NULL;
libEntry = CMP_LIBRARY::FindLibraryEntry( Component->m_ChipName ); libEntry = CMP_LIBRARY::FindLibraryEntry( Component->m_ChipName );
if( libEntry ) if( libEntry )
{ libComponent = libEntry->GetComponent();
if( libEntry->isAlias() )
libComponent = ( (LIB_ALIAS*) libEntry )->GetComponent();
else
libComponent = (LIB_COMPONENT*) libEntry;
}
if( !Component->m_Flags ) if( !Component->m_Flags )
{ {
......
...@@ -105,8 +105,8 @@ void WinEDA_LibeditFrame::OnEditPin( wxCommandEvent& event ) ...@@ -105,8 +105,8 @@ void WinEDA_LibeditFrame::OnEditPin( wxCommandEvent& event )
dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->m_PinLen, dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->m_PinLen,
m_InternalUnits ) ); m_InternalUnits ) );
dlg.SetLengthUnits( units ); dlg.SetLengthUnits( units );
dlg.SetAddToAllParts( pin->m_Unit == 0 ); dlg.SetAddToAllParts( pin->GetUnit() == 0 );
dlg.SetAddToAllBodyStyles( pin->m_Convert == 0 ); dlg.SetAddToAllBodyStyles( pin->GetConvert() == 0 );
dlg.SetVisible( pin->IsVisible() ); dlg.SetVisible( pin->IsVisible() );
/* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier
...@@ -429,9 +429,9 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC ) ...@@ -429,9 +429,9 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
m_drawItem = pin; m_drawItem = pin;
pin->m_Flags = IS_NEW; pin->m_Flags = IS_NEW;
pin->m_Unit = m_unit; pin->SetUnit( m_unit );
pin->m_Convert = m_convert; pin->SetConvert( m_convert );
/* Flag pins to consider */ /* Flag pins to consider */
if( g_EditPinByPinIsOn == false ) if( g_EditPinByPinIsOn == false )
...@@ -447,14 +447,14 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC ) ...@@ -447,14 +447,14 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
pin->m_PinNumSize = LastPinNumSize; pin->m_PinNumSize = LastPinNumSize;
if( LastPinCommonConvert ) if( LastPinCommonConvert )
pin->m_Convert = 0; pin->SetConvert( 0 );
else else
pin->m_Convert = m_convert; pin->SetConvert( m_convert );
if( LastPinCommonUnit ) if( LastPinCommonUnit )
pin->m_Unit = 0; pin->SetUnit( 0 );
else else
pin->m_Unit = m_unit; pin->SetUnit( m_unit );
if( LastPinVisible ) if( LastPinVisible )
pin->m_Attributs &= ~PINNOTDRAW; pin->m_Attributs &= ~PINNOTDRAW;
...@@ -497,38 +497,38 @@ static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorga ...@@ -497,38 +497,38 @@ static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorga
if( g_EditPinByPinIsOn ) if( g_EditPinByPinIsOn )
return; return;
if( asDeMorgan && ( Pin->m_Convert != 0 ) ) if( asDeMorgan && ( Pin->GetConvert() != 0 ) )
CreateConv = true; CreateConv = true;
/* Create "convert" pin at the current position. */ /* Create "convert" pin at the current position. */
if( CreateConv == true ) if( CreateConv == true )
{ {
NewPin = (LIB_PIN*) Pin->GenCopy(); NewPin = (LIB_PIN*) Pin->GenCopy();
if( Pin->m_Convert > 1 ) if( Pin->GetConvert() > 1 )
NewPin->m_Convert = 1; NewPin->SetConvert( 1 );
else else
NewPin->m_Convert = 2; NewPin->SetConvert( 2 );
Pin->GetParent()->AddDrawItem( NewPin ); Pin->GetParent()->AddDrawItem( NewPin );
} }
for( ii = 1; ii <= Pin->GetParent()->GetPartCount(); ii++ ) 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. */ continue; /* Pin common to all units. */
NewPin = (LIB_PIN*) Pin->GenCopy(); NewPin = (LIB_PIN*) Pin->GenCopy();
if( convert != 0 ) if( convert != 0 )
NewPin->m_Convert = 1; NewPin->SetConvert( 1 );
NewPin->m_Unit = ii; NewPin->SetUnit( ii );
Pin->GetParent()->AddDrawItem( NewPin ); Pin->GetParent()->AddDrawItem( NewPin );
if( CreateConv == false ) if( CreateConv == false )
continue; continue;
NewPin = (LIB_PIN*) Pin->GenCopy(); NewPin = (LIB_PIN*) Pin->GenCopy();
NewPin->m_Convert = 2; NewPin->SetConvert( 2 );
if( Pin->m_Unit != 0 ) if( Pin->GetUnit() != 0 )
NewPin->m_Unit = ii; NewPin->SetUnit( ii );
Pin->GetParent()->AddDrawItem( NewPin ); Pin->GetParent()->AddDrawItem( NewPin );
} }
} }
...@@ -558,7 +558,7 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id ) ...@@ -558,7 +558,7 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id )
Pin = m_component->GetNextPin(); Pin = m_component->GetNextPin();
for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) ) 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; continue;
// Is it the "selected mode" ? // Is it the "selected mode" ?
...@@ -639,11 +639,11 @@ bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst ) ...@@ -639,11 +639,11 @@ bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst )
if( test == 0 ) if( test == 0 )
{ {
test = ref->m_Convert - tst->m_Convert; test = ref->GetConvert() - tst->GetConvert();
} }
if( test == 0 ) if( test == 0 )
{ {
test = ref->m_Unit - tst->m_Unit; test = ref->GetUnit() - tst->GetUnit();
} }
return test < 0; return test < 0;
} }
...@@ -693,8 +693,8 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event ) ...@@ -693,8 +693,8 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event )
Pin = PinList[ii - 1]; Pin = PinList[ii - 1];
if( Pin->m_PinNum != curr_pin->m_PinNum if( Pin->m_PinNum != curr_pin->m_PinNum
|| Pin->m_Convert != curr_pin->m_Convert || Pin->GetConvert() != curr_pin->GetConvert()
|| Pin->m_Unit != curr_pin->m_Unit ) || Pin->GetUnit() != curr_pin->GetUnit() )
continue; continue;
dup_error++; dup_error++;
...@@ -713,13 +713,13 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event ) ...@@ -713,13 +713,13 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event )
if( m_component->GetPartCount() > 1 ) 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; msg += aux_msg;
} }
if( m_showDeMorgan ) if( m_showDeMorgan )
{ {
if( curr_pin->m_Convert ) if( curr_pin->GetConvert() )
msg += _( " of converted" ); msg += _( " of converted" );
else else
msg += _( " of normal" ); msg += _( " of normal" );
...@@ -752,13 +752,13 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event ) ...@@ -752,13 +752,13 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event )
if( m_component->GetPartCount() > 1 ) 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; msg += aux_msg;
} }
if( m_showDeMorgan ) if( m_showDeMorgan )
{ {
if( Pin->m_Convert ) if( Pin->GetConvert() )
msg += _( " of converted" ); msg += _( " of converted" );
else else
msg += _( " of normal" ); msg += _( " of normal" );
......
...@@ -637,14 +637,14 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -637,14 +637,14 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
if( screen->GetCurItem() == NULL ) if( screen->GetCurItem() == NULL )
break; break;
{ {
CMP_LIB_ENTRY* LibEntry; LIB_ALIAS* LibEntry;
LibEntry = CMP_LIBRARY::FindLibraryEntry( LibEntry = CMP_LIBRARY::FindLibraryEntry(
( (SCH_COMPONENT*) screen->GetCurItem() )->m_ChipName ); ( (SCH_COMPONENT*) screen->GetCurItem() )->m_ChipName );
if( LibEntry && LibEntry->GetDocFileName() != wxEmptyString ) if( LibEntry && LibEntry->GetDocFileName() != wxEmptyString )
{ {
GetAssociatedDocument( this, LibEntry->GetDocFileName(), GetAssociatedDocument( this, LibEntry->GetDocFileName(),
&wxGetApp().GetLibraryPathList() ); &wxGetApp().GetLibraryPathList() );
} }
} }
break; break;
......
...@@ -36,7 +36,7 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) ...@@ -36,7 +36,7 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
LIB_COMPONENT* component = DrawItem->GetParent(); 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 ) ); dialog.SetWidthUnits( ReturnUnitSymbol( g_UserUnit ) );
...@@ -47,7 +47,7 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) ...@@ -47,7 +47,7 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
dialog.SetApplyToAllConversions( !m_drawSpecificConvert ); dialog.SetApplyToAllConversions( !m_drawSpecificConvert );
dialog.EnableApplyToAllConversions( component && component->HasConversion() ); dialog.EnableApplyToAllConversions( component && component->HasConversion() );
// dialog.SetFillStyle( m_drawFillStyle ); // could better to show the current setting // dialog.SetFillStyle( m_drawFillStyle ); // could better to show the current setting
dialog.SetFillStyle( DrawItem->m_Fill); dialog.SetFillStyle( DrawItem->GetFillMode() );
dialog.EnableFillStyle( DrawItem->IsFillable() ); dialog.EnableFillStyle( DrawItem->IsFillable() );
if( dialog.ShowModal() == wxID_CANCEL ) if( dialog.ShowModal() == wxID_CANCEL )
...@@ -73,17 +73,17 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) ...@@ -73,17 +73,17 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
SaveCopyInUndoList( DrawItem->GetParent() ); SaveCopyInUndoList( DrawItem->GetParent() );
if( m_drawSpecificUnit ) if( m_drawSpecificUnit )
DrawItem->m_Unit = GetUnit(); DrawItem->SetUnit( GetUnit() );
else else
DrawItem->m_Unit = 0; DrawItem->SetUnit( 0 );
if( m_drawSpecificConvert ) if( m_drawSpecificConvert )
DrawItem->m_Convert = GetConvert(); DrawItem->SetConvert( GetConvert() );
else else
DrawItem->m_Convert = 0; DrawItem->SetConvert( 0 );
if( DrawItem->IsFillable() ) if( DrawItem->IsFillable() )
DrawItem->m_Fill = (FILL_T) dialog.GetFillStyle(); DrawItem->SetFillMode( (FILL_T) dialog.GetFillStyle() );
DrawItem->SetWidth( m_drawLineWidth ); DrawItem->SetWidth( m_drawLineWidth );
...@@ -183,12 +183,12 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry, ...@@ -183,12 +183,12 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
{ {
m_drawItem->BeginEdit( IS_NEW, drawPos ); m_drawItem->BeginEdit( IS_NEW, drawPos );
m_drawItem->SetWidth( m_drawLineWidth ); m_drawItem->SetWidth( m_drawLineWidth );
m_drawItem->m_Fill = m_drawFillStyle; m_drawItem->SetFillMode( m_drawFillStyle );
if( m_drawSpecificUnit ) if( m_drawSpecificUnit )
m_drawItem->m_Unit = m_unit; m_drawItem->SetUnit( m_unit );
if( m_drawSpecificConvert ) if( m_drawSpecificConvert )
m_drawItem->m_Convert = m_convert; m_drawItem->SetConvert( m_convert );
// Draw initial symbol: // Draw initial symbol:
DrawPanel->ManageCurseur( DrawPanel, DC, false ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
...@@ -253,8 +253,8 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC ) ...@@ -253,8 +253,8 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
SetCursor( wxCURSOR_HAND ); SetCursor( wxCURSOR_HAND );
if( m_drawItem->m_Unit != m_unit ) if( m_drawItem->GetUnit() != m_unit )
m_drawItem->m_Unit = m_unit; m_drawItem->SetUnit( m_unit );
TempCopyComponent(); TempCopyComponent();
m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCursorDrawPosition() ); m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCursorDrawPosition() );
......
...@@ -91,10 +91,10 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) ...@@ -91,10 +91,10 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
{ {
if( item.Type() == COMPONENT_FIELD_DRAW_TYPE ) if( item.Type() == COMPONENT_FIELD_DRAW_TYPE )
continue; continue;
if( item.m_Unit ) if( item.GetUnit() )
item.m_Unit = m_unit; item.SetUnit( m_unit );
if( item.m_Convert ) if( item.GetConvert() )
item.m_Convert = m_convert; item.SetConvert( m_convert );
item.m_Flags = IS_NEW; item.m_Flags = IS_NEW;
item.m_Selected = IS_SELECTED; item.m_Selected = IS_SELECTED;
...@@ -202,9 +202,9 @@ void WinEDA_LibeditFrame::SaveOneSymbol() ...@@ -202,9 +202,9 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
if( item.Type() == COMPONENT_FIELD_DRAW_TYPE ) if( item.Type() == COMPONENT_FIELD_DRAW_TYPE )
continue; continue;
/* Don't save unused parts or alternate body styles. */ /* 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; continue;
if( m_convert && item.m_Convert && ( item.m_Convert != m_convert ) ) if( m_convert && item.GetConvert() && ( item.GetConvert() != m_convert ) )
continue; continue;
if( !item.Save( file.fp() ) ) if( !item.Save( file.fp() ) )
......
...@@ -17,16 +17,16 @@ ...@@ -17,16 +17,16 @@
void WinEDA_ViewlibFrame::ReCreateHToolbar() void WinEDA_ViewlibFrame::ReCreateHToolbar()
{ {
int ii; wxString msg; int ii;
wxString msg;
CMP_LIBRARY* lib; CMP_LIBRARY* lib;
LIB_COMPONENT* component = NULL; LIB_COMPONENT* component = NULL;
CMP_LIB_ENTRY* entry = NULL; LIB_ALIAS* entry = NULL;
bool asdeMorgan = false; bool asdeMorgan = false;
if( m_HToolBar == NULL ) if( m_HToolBar == NULL )
{ {
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true );
true );
// Set up toolbar // Set up toolbar
m_HToolBar->AddTool( ID_LIBVIEW_SELECT_LIB, wxEmptyString, m_HToolBar->AddTool( ID_LIBVIEW_SELECT_LIB, wxEmptyString,
...@@ -105,8 +105,7 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar() ...@@ -105,8 +105,7 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
m_HToolBar->Realize(); m_HToolBar->Realize();
} }
if( (m_libraryName != wxEmptyString) if( (m_libraryName != wxEmptyString) && (m_entryName != wxEmptyString) )
&& (m_entryName != wxEmptyString) )
{ {
lib = CMP_LIBRARY::FindLibrary( m_libraryName ); lib = CMP_LIBRARY::FindLibrary( m_libraryName );
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event ) void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
wxString msg; wxString msg;
CMP_LIB_ENTRY* LibEntry; LIB_ALIAS* LibEntry;
int ii, id = event.GetId(); int ii, id = event.GetId();
switch( id ) switch( id )
{ {
...@@ -48,8 +48,7 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -48,8 +48,7 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_LIBVIEW_VIEWDOC: case ID_LIBVIEW_VIEWDOC:
LibEntry = CMP_LIBRARY::FindLibraryEntry( m_entryName, LibEntry = CMP_LIBRARY::FindLibraryEntry( m_entryName, m_libraryName );
m_libraryName );
if( LibEntry && ( !LibEntry->GetDocFileName().IsEmpty() ) ) if( LibEntry && ( !LibEntry->GetDocFileName().IsEmpty() ) )
GetAssociatedDocument( this, LibEntry->GetDocFileName(), GetAssociatedDocument( this, LibEntry->GetDocFileName(),
...@@ -168,7 +167,7 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option ) ...@@ -168,7 +167,7 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option )
return; return;
} }
CMP_LIB_ENTRY* LibEntry = Lib->FindEntry( m_entryName ); LIB_ALIAS* LibEntry = Lib->FindEntry( m_entryName );
if( LibEntry == NULL ) if( LibEntry == NULL )
return; return;
...@@ -186,9 +185,9 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option ) ...@@ -186,9 +185,9 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option )
/*************************************************/ /*************************************************/
void WinEDA_ViewlibFrame::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag ) void WinEDA_ViewlibFrame::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag )
{ {
int NumOfParts = 0; int NumOfParts = 0;
CMP_LIB_ENTRY* LibEntry; LIB_ALIAS* LibEntry;
wxString CmpName; wxString CmpName;
if( Lib ) if( Lib )
NumOfParts = Lib->GetCount(); NumOfParts = Lib->GetCount();
...@@ -249,7 +248,7 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag ) ...@@ -249,7 +248,7 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag )
void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{ {
LIB_COMPONENT* component; LIB_COMPONENT* component;
CMP_LIB_ENTRY* entry; LIB_ALIAS* entry;
CMP_LIBRARY* lib; CMP_LIBRARY* lib;
wxString msg; wxString msg;
wxString tmp; wxString tmp;
...@@ -266,22 +265,17 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -266,22 +265,17 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( entry == NULL ) if( entry == NULL )
return; return;
wxCHECK_RET( entry->isAlias(), component = entry->GetComponent();
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();
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
if( !alias->IsRoot() ) if( !entry->IsRoot() )
{ {
if( component == NULL ) // Should not occur if( component == NULL ) // Should not occur
return; return;
// Temporarily change the name field text to reflect the alias name. // Temporarily change the name field text to reflect the alias name.
msg = alias->GetName(); msg = entry->GetName();
tmp = component->GetName(); tmp = component->GetName();
component->SetName( msg ); component->SetName( msg );
......
...@@ -71,7 +71,8 @@ enum KICAD_T { ...@@ -71,7 +71,8 @@ enum KICAD_T {
* If you add a new draw item, type, please make sure you add it so the * If you add a new draw item, type, please make sure you add it so the
* sort order is logical. * sort order is logical.
*/ */
LIBCOMPONENT_STRUCT_TYPE, LIB_COMPONENT_T,
LIB_ALIAS_T,
COMPONENT_ARC_DRAW_TYPE, COMPONENT_ARC_DRAW_TYPE,
COMPONENT_CIRCLE_DRAW_TYPE, COMPONENT_CIRCLE_DRAW_TYPE,
COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, COMPONENT_GRAPHIC_TEXT_DRAW_TYPE,
...@@ -258,32 +259,25 @@ class DHEAD; ...@@ -258,32 +259,25 @@ class DHEAD;
// These define are used for the .m_Flags and .m_UndoRedoStatus member of the // These define are used for the .m_Flags and .m_UndoRedoStatus member of the
// class EDA_BaseStruct // class EDA_BaseStruct
#define IS_CHANGED (1 << 0) #define IS_CHANGED (1 << 0)
#define IS_LINKED (1 << 1) #define IS_LINKED (1 << 1)
#define IN_EDIT (1 << 2) #define IN_EDIT (1 << 2)
#define IS_MOVED (1 << 3) #define IS_MOVED (1 << 3)
#define IS_NEW (1 << 4) #define IS_NEW (1 << 4)
#define IS_RESIZED (1 << 5) #define IS_RESIZED (1 << 5)
#define IS_DRAGGED (1 << 6) #define IS_DRAGGED (1 << 6)
#define IS_DELETED (1 << 7) #define IS_DELETED (1 << 7)
#define IS_WIRE_IMAGE (1 << 8) #define IS_WIRE_IMAGE (1 << 8)
#define STARTPOINT (1 << 9) #define STARTPOINT (1 << 9)
#define ENDPOINT (1 << 10) #define ENDPOINT (1 << 10)
#define SELECTED (1 << 11) #define SELECTED (1 << 11)
#define SELECTEDNODE (1 << 12) ///< flag indicating that the structure #define SELECTEDNODE (1 << 12) ///< flag indicating that the structure has already selected
// 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 STRUCT_DELETED (1 << 13) ///< flag indication structures to be #define SKIP_STRUCT (1 << 15) ///< flag indicating that the structure should be ignored
// erased #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
#define CANDIDATE (1 << 14) ///< flag indicating that the structure ///< new object
// 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 class EDA_BaseStruct
{ {
...@@ -350,6 +344,10 @@ public: ...@@ -350,6 +344,10 @@ public:
void SetSon( EDA_BaseStruct* aSon ) { m_Son = aSon; } void SetSon( EDA_BaseStruct* aSon ) { m_Son = aSon; }
void SetList( DHEAD* aList ) { m_List = aList; } 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 int GetState( int type ) const
{ {
......
...@@ -20,7 +20,6 @@ class SCH_ITEM; ...@@ -20,7 +20,6 @@ class SCH_ITEM;
class SCH_NO_CONNECT; class SCH_NO_CONNECT;
class CMP_LIBRARY; class CMP_LIBRARY;
class LIB_COMPONENT; class LIB_COMPONENT;
class CMP_LIB_ENTRY;
class LIB_DRAW_ITEM; class LIB_DRAW_ITEM;
class EDA_BaseStruct; class EDA_BaseStruct;
class SCH_BUS_ENTRY; class SCH_BUS_ENTRY;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment