Eeschema, libedit: fixed last problems when editing alias info.
Now alias changes can be undone, and are correctly updated in lib
This commit is contained in:
parent
124074c6f7
commit
d8fae88f36
|
@ -4,6 +4,16 @@ KiCad ChangeLog 2010
|
|||
Please add newer entries at the top, list the date and your name with
|
||||
email address.
|
||||
|
||||
2010-Feb-17 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
||||
================================================================================
|
||||
Eeschema, libedit: fixed last problems when editing alias info.
|
||||
Now alias changes can be undone, and are correctly updated in lib
|
||||
when updating the current edited component in memory
|
||||
New code could be a good starting point to store all aliases info in the
|
||||
root component,
|
||||
and also easily store it to the *.lib files and remove the .dcm associated files
|
||||
(most of code is done)
|
||||
|
||||
|
||||
2010-Feb-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
||||
================================================================================
|
||||
|
|
|
@ -126,7 +126,7 @@ int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY* aItem
|
|||
|
||||
/* Class to define an alias of a component
|
||||
* An alias uses the component definition (graphic, pins...)
|
||||
* but has its own name and documentation.
|
||||
* but has its own name, keywords and documentation.
|
||||
* Therefore, when the component is modified, alias of this component are
|
||||
* modified.
|
||||
* This is a simple method to create components with differs very few
|
||||
|
@ -140,6 +140,8 @@ LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent,
|
|||
wxASSERT( aRootComponent != NULL && aRootComponent->isComponent() );
|
||||
|
||||
root = aRootComponent;
|
||||
if( aLibrary == NULL )
|
||||
library = aRootComponent->GetLibrary();
|
||||
}
|
||||
|
||||
|
||||
|
@ -201,6 +203,7 @@ LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary )
|
|||
LIB_DRAW_ITEM* newItem;
|
||||
|
||||
m_AliasList = aComponent.m_AliasList;
|
||||
m_aliasListData = aComponent.m_aliasListData;
|
||||
m_FootprintList = aComponent.m_FootprintList;
|
||||
unitCount = aComponent.unitCount;
|
||||
m_UnitSelectionLocked = aComponent.m_UnitSelectionLocked;
|
||||
|
@ -1304,3 +1307,143 @@ void LIB_COMPONENT::SetConversion( bool aSetConvert )
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* accessors to aliases data, used by the component editor, during edition
|
||||
*/
|
||||
/** Function LocateAliasData
|
||||
* @return an index in array string to the alias data (doc, keywords, docfile)
|
||||
* or -1 if not found
|
||||
* @param aAliasName = the alias name
|
||||
* @param aCreateIfNotExist = true if the alias data must be created, when not exists
|
||||
*/
|
||||
int LIB_COMPONENT::LocateAliasData( const wxString & aAliasName, bool aCreateIfNotExist)
|
||||
{
|
||||
int idx = -1;
|
||||
for( unsigned ii = 0; ii < m_aliasListData.size(); ii += ALIAS_NEXT_IDX )
|
||||
{
|
||||
if( aAliasName.CmpNoCase( m_aliasListData[ii] ) != 0 )
|
||||
continue;
|
||||
// Found!
|
||||
idx = (int) ii;
|
||||
break;
|
||||
}
|
||||
|
||||
// Alias not found, create on demand
|
||||
if( aCreateIfNotExist && (idx < 0) )
|
||||
{
|
||||
idx = (int) m_aliasListData.size();
|
||||
m_aliasListData.Add(aAliasName);
|
||||
// Add void strinds for data:
|
||||
m_aliasListData.Add(wxEmptyString); //Doc string
|
||||
m_aliasListData.Add(wxEmptyString); //keywords string
|
||||
m_aliasListData.Add(wxEmptyString); //Doc fliname string
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
/** Function GetAliasDataDoc
|
||||
* @param aAliasName = the alias name
|
||||
* @return the Doc string
|
||||
*/
|
||||
wxString LIB_COMPONENT::GetAliasDataDoc( const wxString & aAliasName )
|
||||
{
|
||||
wxString data;
|
||||
int idx = LocateAliasData( aAliasName);
|
||||
if ( idx >= 0 )
|
||||
data = m_aliasListData[idx + ALIAS_DOC_IDX];
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
/** Function GetAliasDataKeyWords
|
||||
* @param aAliasName = the alias name
|
||||
* @return aAliasData = the keywords string
|
||||
*/
|
||||
wxString LIB_COMPONENT::GetAliasDataKeyWords( const wxString & aAliasName )
|
||||
{
|
||||
wxString data;
|
||||
int idx = LocateAliasData( aAliasName);
|
||||
if ( idx >= 0 )
|
||||
data = m_aliasListData[idx + ALIAS_KEYWORD_IDX];
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
/** Function GetAliasDataDocFileName
|
||||
* @param aAliasName = the alias name
|
||||
* @return the Doc filename string
|
||||
*/
|
||||
wxString LIB_COMPONENT::GetAliasDataDocFileName( const wxString & aAliasName )
|
||||
{
|
||||
wxString data;
|
||||
int idx = LocateAliasData( aAliasName);
|
||||
if ( idx >= 0 )
|
||||
data = m_aliasListData[idx + ALIAS_DOC_FILENAME_IDX];
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Function SetAliasDataDoc
|
||||
* @param aAliasName = the alias name
|
||||
* @param aAliasData = the Doc string
|
||||
*/
|
||||
void LIB_COMPONENT::SetAliasDataDoc( const wxString & aAliasName, const wxString & aAliasData )
|
||||
{
|
||||
int idx = LocateAliasData( aAliasName, true);
|
||||
m_aliasListData[idx + ALIAS_DOC_IDX] = aAliasData;
|
||||
}
|
||||
|
||||
/** Function SetAliasDataKeywords
|
||||
* @param aAliasName = the alias name
|
||||
* @param aAliasData = the keywords string
|
||||
*/
|
||||
void LIB_COMPONENT::SetAliasDataKeywords( const wxString & aAliasName, const wxString & aAliasData )
|
||||
{
|
||||
int idx = LocateAliasData( aAliasName, true);
|
||||
m_aliasListData[idx + ALIAS_KEYWORD_IDX] = aAliasData;
|
||||
}
|
||||
|
||||
/** Function SetAliasDataDocFileName
|
||||
* @param aAliasName = the alias name
|
||||
* @param aAliasData = the Doc filename string
|
||||
*/
|
||||
void LIB_COMPONENT::SetAliasDataDocFileName( const wxString & aAliasName, const wxString & aAliasData )
|
||||
{
|
||||
int idx = LocateAliasData( aAliasName, true);
|
||||
m_aliasListData[idx + ALIAS_DOC_FILENAME_IDX] = aAliasData;
|
||||
}
|
||||
|
||||
|
||||
/** Function RemoveAliasData
|
||||
* remove an alias data from list
|
||||
* @param aAliasName = the alias name
|
||||
*/
|
||||
void LIB_COMPONENT::RemoveAliasData(const wxString & aAliasName )
|
||||
{
|
||||
int idx = LocateAliasData( aAliasName);
|
||||
if ( idx >= 0 )
|
||||
m_aliasListData.RemoveAt(idx + ALIAS_NAME_IDX, ALIAS_NEXT_IDX);
|
||||
}
|
||||
|
||||
/** Function CollectAliasesData
|
||||
* store in m_aliasListData alias data (doc, keywords, docfile)
|
||||
* for each alias found in m_AliasList
|
||||
*/
|
||||
void LIB_COMPONENT::CollectAliasesData( CMP_LIBRARY* aLibrary )
|
||||
{
|
||||
for( unsigned ii = 0; ii < m_AliasList.GetCount(); ii++ )
|
||||
{
|
||||
CMP_LIB_ENTRY* entry = aLibrary->FindEntry( m_AliasList[ii] );
|
||||
if ( ! entry ) continue;
|
||||
SetAliasDataDoc( m_AliasList[ii], entry->GetDescription() );
|
||||
SetAliasDataKeywords( m_AliasList[ii], entry->GetKeyWords() );
|
||||
SetAliasDataDocFileName( m_AliasList[ii], entry->GetDocFileName() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ enum LibrEntryType
|
|||
ALIAS /* This is an alias of a true component */
|
||||
};
|
||||
|
||||
/* values for member .m_Options */
|
||||
/* values for member .m_options */
|
||||
enum LibrEntryOptions
|
||||
{
|
||||
ENTRY_NORMAL, // Libentry is a standard component (real or alias)
|
||||
|
@ -67,6 +67,8 @@ public:
|
|||
|
||||
wxString GetLibraryName();
|
||||
|
||||
CMP_LIBRARY* GetLibrary() {return library;}
|
||||
|
||||
virtual const wxString& GetName() const { return name; }
|
||||
|
||||
virtual void SetName( const wxString& aName ) { name = aName; }
|
||||
|
@ -159,6 +161,34 @@ protected:
|
|||
LIB_DRAW_ITEM_LIST drawings; /* How to draw this part */
|
||||
|
||||
public:
|
||||
/* Offsets used in editing library component,
|
||||
* for handle aliases data in m_AliasListData array string
|
||||
* when editing a library component, aliases data is stored
|
||||
* in m_AliasListData.
|
||||
* 4 strings by alias are stored:
|
||||
* name, doc, keywords and doc filename
|
||||
* these constants are indexes in m_AliasListData
|
||||
* to read/write strings for a given alias
|
||||
*/
|
||||
enum alias_idx
|
||||
{
|
||||
ALIAS_NAME_IDX = 0,
|
||||
ALIAS_DOC_IDX = 1,
|
||||
ALIAS_KEYWORD_IDX = 2,
|
||||
ALIAS_DOC_FILENAME_IDX = 3,
|
||||
ALIAS_NEXT_IDX = 4
|
||||
};
|
||||
private:
|
||||
wxArrayString m_aliasListData; /* ALIAS data (name, doc, keywords and doc filename).
|
||||
* Used only by the component editor LibEdit
|
||||
* to store aliases info during edition
|
||||
* usually void outside the component editor */
|
||||
public:
|
||||
LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary = NULL );
|
||||
LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary = NULL );
|
||||
|
||||
~LIB_COMPONENT();
|
||||
|
||||
virtual wxString GetClass() const
|
||||
{
|
||||
return wxT( "LIB_COMPONENT" );
|
||||
|
@ -171,10 +201,68 @@ public:
|
|||
GetValueField().m_Text = aName;
|
||||
}
|
||||
|
||||
LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary = NULL );
|
||||
LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary = NULL );
|
||||
/* accessors to aliases data, used by the component editor, during edition
|
||||
*/
|
||||
/** Function CollectAliasesData
|
||||
* store in m_aliasListData alias data (doc, keywords, docfile)
|
||||
* for each alias found in m_AliasList
|
||||
*/
|
||||
void CollectAliasesData( CMP_LIBRARY* aLibrary );
|
||||
|
||||
~LIB_COMPONENT();
|
||||
/** Function LocateAliasData
|
||||
* @return an index in array string to the alias data (doc, keywords, docfile)
|
||||
* or -1 if not found
|
||||
* @param aAliasName = the alias name
|
||||
* @param aCreateIfNotExist = true if the alias data must be created, when not exists
|
||||
*/
|
||||
int LocateAliasData( const wxString & aAliasName, bool aCreateIfNotExist = false);
|
||||
|
||||
/** Function GetAliasDataDoc
|
||||
* @param aAliasName = the alias name
|
||||
* @return the Doc string
|
||||
*/
|
||||
wxString GetAliasDataDoc( const wxString & aAliasName );
|
||||
|
||||
/** Function GetAliasDataKeyWords
|
||||
* @param aAliasName = the alias name
|
||||
* @return aAliasData = the keywords string
|
||||
*/
|
||||
wxString GetAliasDataKeyWords( const wxString & aAliasName );
|
||||
|
||||
/** Function GetAliasDataDocFileName
|
||||
* @param aAliasName = the alias name
|
||||
* @return the Doc filename string
|
||||
*/
|
||||
wxString GetAliasDataDocFileName( const wxString & aAliasName );
|
||||
|
||||
/** Function SetAliasDataDoc
|
||||
* @param aAliasName = the alias name
|
||||
* @return aAliasData = the Doc string
|
||||
*/
|
||||
void SetAliasDataDoc( const wxString & aAliasName, const wxString & aAliasData );
|
||||
|
||||
/** Function SetAliasDataKeywords
|
||||
* @param aAliasName = the alias name
|
||||
* @param aAliasData = the keywords string
|
||||
*/
|
||||
void SetAliasDataKeywords( const wxString & aAliasName, const wxString & aAliasData );
|
||||
|
||||
/** Function SetAliasDataDocFileName
|
||||
* @param aAliasName = the alias name
|
||||
* @param aAliasData = the Doc filename string
|
||||
*/
|
||||
void SetAliasDataDocFileName( const wxString & aAliasName, const wxString & aAliasData );
|
||||
|
||||
/** Function ClearAliasDataDoc
|
||||
* clear aliases data list
|
||||
*/
|
||||
void ClearAliasDataDoc( ) { m_aliasListData.Clear(); }
|
||||
|
||||
/** Function RemoveAliasData
|
||||
* remove an alias data from list
|
||||
* @param aAliasName = the alias name
|
||||
*/
|
||||
void RemoveAliasData(const wxString & aAliasName );
|
||||
|
||||
EDA_Rect GetBoundaryBox( int aUnit, int aConvert );
|
||||
|
||||
|
|
|
@ -232,6 +232,7 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
|
|||
wxASSERT( aComponent != NULL );
|
||||
|
||||
LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aComponent, this );
|
||||
newCmp->ClearAliasDataDoc(); // Remove data used only in edition
|
||||
|
||||
if( newCmp == NULL )
|
||||
return NULL;
|
||||
|
@ -283,20 +284,25 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
|
|||
|
||||
for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ )
|
||||
{
|
||||
LIB_ALIAS* alias = FindAlias( newCmp->m_AliasList[ i ] );
|
||||
wxString aliasname = newCmp->m_AliasList[ i ];
|
||||
LIB_ALIAS* alias = FindAlias( aliasname );
|
||||
|
||||
if( alias == NULL )
|
||||
{
|
||||
alias = new LIB_ALIAS( newCmp->m_AliasList[ i ], newCmp );
|
||||
alias = new LIB_ALIAS( aliasname, newCmp );
|
||||
entries.push_back( alias );
|
||||
}
|
||||
else if( alias->GetComponent()->GetName().CmpNoCase( newCmp->GetName() ) != 0 )
|
||||
{
|
||||
// Remove alias from library and alias list of its root component
|
||||
RemoveEntry( alias );
|
||||
alias = new LIB_ALIAS( newCmp->m_AliasList[ i ], newCmp );
|
||||
alias = new LIB_ALIAS( aliasname, newCmp );
|
||||
entries.push_back( alias );
|
||||
}
|
||||
// Update alias data:
|
||||
alias->SetDescription( aComponent->GetAliasDataDoc( aliasname ) );
|
||||
alias->SetKeyWords( aComponent->GetAliasDataKeyWords( aliasname ) );
|
||||
alias->SetDocFileName( aComponent->GetAliasDataDocFileName( aliasname ) );
|
||||
}
|
||||
|
||||
entries.push_back( (CMP_LIB_ENTRY*) newCmp );
|
||||
|
@ -442,29 +448,26 @@ LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent,
|
|||
size_t i;
|
||||
|
||||
LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aNewComponent, this );
|
||||
newCmp->ClearAliasDataDoc( ); // this data is currently used only when editing the component
|
||||
|
||||
/* We want to remove the old root component, so we must remove old aliases.
|
||||
* even if they are not modified, because their root component will be removed
|
||||
*/
|
||||
for( i = 0; i < aOldComponent->m_AliasList.GetCount(); i++ )
|
||||
{
|
||||
/* wxLogDebug( wxT( "Removing alias <%s> from component <%s> in library <%s>." ),
|
||||
GetChars( aOldComponent->m_AliasList[ i ] ),
|
||||
GetChars( aOldComponent->GetName() ),
|
||||
GetChars( fileName.GetName() ) );
|
||||
*/
|
||||
RemoveEntryName( aOldComponent->m_AliasList[ i ] );
|
||||
}
|
||||
|
||||
/* Now, add current aliases. */
|
||||
for( i = 0; i < aNewComponent->m_AliasList.GetCount(); i++ )
|
||||
{
|
||||
/* wxLogDebug( wxT( "Adding alias <%s> from component <%s> in library <%s>." ),
|
||||
GetChars( aNewComponent->m_AliasList[ i ] ),
|
||||
GetChars( aNewComponent->GetName() ),
|
||||
GetChars( fileName.GetName() ) );
|
||||
*/
|
||||
LIB_ALIAS* alias = new LIB_ALIAS( aNewComponent->m_AliasList[ i ], newCmp );
|
||||
wxString aliasname = aNewComponent->m_AliasList[ i ];
|
||||
LIB_ALIAS* alias = new LIB_ALIAS( aliasname, newCmp );
|
||||
// Update alias data:
|
||||
alias->SetDescription( aNewComponent->GetAliasDataDoc( aliasname ) );
|
||||
alias->SetKeyWords( aNewComponent->GetAliasDataKeyWords( aliasname ) );
|
||||
alias->SetDocFileName( aNewComponent->GetAliasDataDocFileName( aliasname ) );
|
||||
// Add it in library
|
||||
entries.push_back( alias );
|
||||
}
|
||||
|
||||
|
@ -589,7 +592,7 @@ bool CMP_LIBRARY::Load( wxString& aErrorMsg )
|
|||
|| !vers.GetNextToken().ToLong( & minor ) || minor < 0L
|
||||
|| minor > 99 )
|
||||
{
|
||||
#if 0 // Note for defeloppers:
|
||||
#if 0 // Note for developers:
|
||||
// Not sure this warning is very useful: old designs *must* be always loadable
|
||||
wxLogWarning( wxT( "The component library <%s> header version \
|
||||
number is invalid.\n\nIn future versions of EESchema this library may not \
|
||||
|
|
|
@ -1097,9 +1097,12 @@ EDA_Rect SCH_COMPONENT::GetBoundingBox()
|
|||
|
||||
void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
|
||||
{
|
||||
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
// search for the component in lib
|
||||
// Entry and root_component can differ if Entry is an alias
|
||||
CMP_LIB_ENTRY* Entry = CMP_LIBRARY::FindLibraryEntry( m_ChipName );
|
||||
LIB_COMPONENT* root_component = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
|
||||
if( Entry == NULL )
|
||||
if( (Entry == NULL) || (root_component == NULL) )
|
||||
return;
|
||||
|
||||
wxString msg;
|
||||
|
@ -1110,17 +1113,19 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
|
|||
GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()),
|
||||
DARKCYAN );
|
||||
|
||||
if( Entry->isPower() )
|
||||
if( root_component->isPower() )
|
||||
msg = _( "Power symbol" );
|
||||
else
|
||||
msg = _( "Name" );
|
||||
|
||||
frame->AppendMsgPanel( msg, GetField( VALUE )->m_Text, DARKCYAN );
|
||||
|
||||
// Display component reference in library and library
|
||||
frame->AppendMsgPanel( _( "Component" ), m_ChipName, BROWN );
|
||||
if( Entry->isAlias( ) )
|
||||
frame->AppendMsgPanel( _( "Alias of" ), root_component->GetName(), BROWN );
|
||||
frame->AppendMsgPanel( _( "Library" ), Entry->GetLibraryName(), BROWN );
|
||||
|
||||
msg = Entry->GetLibraryName();
|
||||
|
||||
frame->AppendMsgPanel( _( "Library" ), msg, DARKRED );
|
||||
// Display description of the component, and keywords found in lib
|
||||
frame->AppendMsgPanel( _( "Description" ), Entry->GetDescription(), DARKCYAN );
|
||||
frame->AppendMsgPanel( _( "Key words" ), Entry->GetKeyWords(), DARKCYAN );
|
||||
}
|
||||
|
|
|
@ -102,29 +102,24 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnCancelClick( wxCommandEvent& event )
|
|||
|
||||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
|
||||
{
|
||||
CMP_LIB_ENTRY* entry;
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
CMP_LIBRARY* library = m_Parent->GetLibrary();
|
||||
|
||||
if( component == NULL )
|
||||
return;
|
||||
|
||||
if( m_Parent->GetAliasName().IsEmpty() )
|
||||
wxString aliasname = m_Parent->GetAliasName();
|
||||
if( aliasname.IsEmpty() ) // The root component is selected
|
||||
{
|
||||
entry = component;
|
||||
m_DocCtrl->SetValue( component->GetDescription() );
|
||||
m_KeywordsCtrl->SetValue( component->GetKeyWords() );
|
||||
m_DocfileCtrl->SetValue( component->GetDocFileName() );
|
||||
}
|
||||
else
|
||||
else // An alias is currently selected
|
||||
{
|
||||
entry =
|
||||
( CMP_LIB_ENTRY* ) library->FindAlias( m_Parent->GetAliasName() );
|
||||
|
||||
if( entry == NULL )
|
||||
return;
|
||||
m_DocCtrl->SetValue( component->GetAliasDataDoc( aliasname ) );
|
||||
m_KeywordsCtrl->SetValue( component->GetAliasDataKeyWords( aliasname ) );
|
||||
m_DocfileCtrl->SetValue( component->GetAliasDataDocFileName( aliasname ) );
|
||||
}
|
||||
|
||||
m_DocCtrl->SetValue( entry->GetDescription() );
|
||||
m_KeywordsCtrl->SetValue( entry->GetKeyWords() );
|
||||
m_DocfileCtrl->SetValue( entry->GetDocFileName() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
|
|||
/* Update the doc, keyword and doc filename strings */
|
||||
size_t i;
|
||||
int index;
|
||||
CMP_LIB_ENTRY* entry = NULL;
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
if( component == NULL )
|
||||
{
|
||||
|
@ -68,33 +67,20 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
|
|||
|
||||
m_Parent->SaveCopyInUndoList( component );
|
||||
|
||||
CMP_LIBRARY* library = m_Parent->GetLibrary();
|
||||
wxString aliasname = m_Parent->GetAliasName();
|
||||
|
||||
if( m_Parent->GetAliasName().IsEmpty() )
|
||||
if( aliasname.IsEmpty() ) // The root component is selected
|
||||
{
|
||||
entry = (CMP_LIB_ENTRY*) component;
|
||||
}
|
||||
else if ( library )
|
||||
{
|
||||
entry = library->FindEntry( m_Parent->GetAliasName() );
|
||||
component->SetDescription( m_DocCtrl->GetValue() );
|
||||
component->SetKeyWords( m_KeywordsCtrl->GetValue() );
|
||||
component->SetDocFileName( m_DocfileCtrl->GetValue() );
|
||||
}
|
||||
|
||||
if( entry == NULL )
|
||||
else // An alias is selected: update keyworks (if thias alias is new, it will be added in aliacd data list)
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Alias <%s> not found for component <%s> in library \
|
||||
<%s>." ),
|
||||
GetChars( m_Parent->GetAliasName() ),
|
||||
GetChars( component->GetName() ),
|
||||
GetChars( library->GetName() ) );
|
||||
wxMessageBox( msg, _( "Component Library Error" ),
|
||||
wxID_OK | wxICON_ERROR, this );
|
||||
}
|
||||
else
|
||||
{
|
||||
entry->SetDescription( m_DocCtrl->GetValue() );
|
||||
entry->SetKeyWords( m_KeywordsCtrl->GetValue() );
|
||||
entry->SetDocFileName( m_DocfileCtrl->GetValue() );
|
||||
component->SetAliasDataDoc(aliasname, m_DocCtrl->GetValue() );
|
||||
component->SetAliasDataKeywords(aliasname, m_KeywordsCtrl->GetValue() );
|
||||
component->SetAliasDataDocFileName(aliasname, m_DocfileCtrl->GetValue() );
|
||||
}
|
||||
|
||||
if( m_PartAliasListCtrl->GetStrings() != component->m_AliasList )
|
||||
|
@ -110,7 +96,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
|
|||
continue;
|
||||
|
||||
component->m_AliasList.Add( aliases[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove names in the current component that are not in the new alias list. */
|
||||
for( i = 0; i < component->m_AliasList.GetCount(); i++ )
|
||||
|
@ -210,6 +196,7 @@ edited!" ),
|
|||
return;
|
||||
}
|
||||
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
m_Parent->GetAliasName().Empty();
|
||||
|
||||
if( IsOK( this, _( "Remove all aliases from list?" ) ) )
|
||||
|
@ -217,6 +204,8 @@ edited!" ),
|
|||
m_PartAliasListCtrl->Clear();
|
||||
m_ButtonDeleteAllAlias->Enable( false );
|
||||
m_ButtonDeleteOneAlias->Enable( false );
|
||||
if( component )
|
||||
component->ClearAliasDataDoc();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,6 +270,9 @@ edited!" ),
|
|||
}
|
||||
|
||||
m_PartAliasListCtrl->Delete( m_PartAliasListCtrl->GetSelection() );
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
if( component )
|
||||
component->RemoveAliasData(aliasname);
|
||||
|
||||
if( m_PartAliasListCtrl->IsEmpty() )
|
||||
{
|
||||
|
|
|
@ -197,9 +197,12 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
|
|||
|
||||
Component = new SCH_COMPONENT( *Entry, GetSheet(), unit, convert,
|
||||
GetScreen()->m_Curseur, true );
|
||||
// Set the m_ChipName value, from component name in lib, for aliases
|
||||
// Note if Entry is found, and if Name is an alias of a component,
|
||||
// alias exists because its root component was found
|
||||
Component->m_ChipName = Name;
|
||||
|
||||
// Set the component value (that can differ from component name in lib,
|
||||
// for aliases)
|
||||
// Set the component value that can differ from component name in lib, for aliases
|
||||
Component->GetField( VALUE )->m_Text = Name;
|
||||
Component->DisplayInfo( this );
|
||||
|
||||
|
|
|
@ -180,6 +180,9 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry,
|
|||
if( m_component->HasConversion() )
|
||||
m_showDeMorgan = true;
|
||||
|
||||
// Collect aliases data and store it in the root component, for edition:
|
||||
m_component->CollectAliasesData( Library );
|
||||
|
||||
GetBaseScreen()->ClrModify();
|
||||
DisplayLibInfos();
|
||||
UpdateAliasSelectList();
|
||||
|
@ -279,7 +282,6 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
|
|||
void WinEDA_LibeditFrame::DisplayCmpDoc()
|
||||
{
|
||||
wxString msg;
|
||||
LIB_ALIAS* alias = NULL;
|
||||
|
||||
ClearMsgPanel();
|
||||
|
||||
|
@ -291,14 +293,9 @@ void WinEDA_LibeditFrame::DisplayCmpDoc()
|
|||
AppendMsgPanel( _( "Part" ), msg, BLUE, 8 );
|
||||
|
||||
if( m_aliasName.IsEmpty() )
|
||||
{
|
||||
msg = _( "None" );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = m_aliasName;
|
||||
alias = m_library->FindAlias( m_aliasName );
|
||||
}
|
||||
|
||||
AppendMsgPanel( _( "Alias" ), msg, RED, 8 );
|
||||
|
||||
|
@ -321,19 +318,27 @@ void WinEDA_LibeditFrame::DisplayCmpDoc()
|
|||
|
||||
AppendMsgPanel( _( "Type" ), msg, MAGENTA, 8 );
|
||||
|
||||
if( alias != NULL )
|
||||
msg = alias->GetDescription();
|
||||
else
|
||||
if( m_aliasName.IsEmpty() )
|
||||
|
||||
msg = m_component->GetDescription();
|
||||
else
|
||||
msg = m_component->GetAliasDataDoc( m_aliasName );
|
||||
|
||||
AppendMsgPanel( _( "Description" ), msg, CYAN, 8 );
|
||||
|
||||
if( alias != NULL )
|
||||
msg = alias->GetKeyWords();
|
||||
else
|
||||
if( m_aliasName.IsEmpty() )
|
||||
msg = m_component->GetKeyWords();
|
||||
else
|
||||
msg = m_component->GetAliasDataKeyWords( m_aliasName );
|
||||
|
||||
AppendMsgPanel( _( "Key words" ), msg, DARKDARKGRAY );
|
||||
|
||||
if( m_aliasName.IsEmpty() )
|
||||
msg = m_component->GetDocFileName();
|
||||
else
|
||||
msg = m_component->GetAliasDataDocFileName( m_aliasName );
|
||||
|
||||
AppendMsgPanel( _( "datasheet" ), msg, DARKDARKGRAY );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -469,10 +469,7 @@ void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event )
|
|||
{
|
||||
if( !m_aliasName.IsEmpty() )
|
||||
{
|
||||
CMP_LIB_ENTRY* entry = m_library->FindEntry( m_aliasName );
|
||||
|
||||
if( entry != NULL )
|
||||
enable = !entry->GetDocFileName().IsEmpty();
|
||||
enable = !m_component->GetAliasDataDocFileName(m_aliasName).IsEmpty();
|
||||
}
|
||||
else if( !m_component->GetDocFileName().IsEmpty() )
|
||||
{
|
||||
|
@ -582,17 +579,9 @@ void WinEDA_LibeditFrame::OnViewEntryDoc( wxCommandEvent& event )
|
|||
wxString fileName;
|
||||
|
||||
if( !m_aliasName.IsEmpty() )
|
||||
{
|
||||
CMP_LIB_ENTRY* entry =
|
||||
m_library->FindEntry( m_aliasName );
|
||||
|
||||
if( entry != NULL )
|
||||
fileName = entry->GetDocFileName();
|
||||
}
|
||||
fileName = m_component->GetAliasDataDocFileName(m_aliasName);
|
||||
else
|
||||
{
|
||||
fileName = m_component->GetDocFileName();
|
||||
}
|
||||
|
||||
if( !fileName.IsEmpty() )
|
||||
GetAssociatedDocument( this, fileName,
|
||||
|
|
Loading…
Reference in New Issue