Commit f7452ce1 authored by stambaughw's avatar stambaughw

Component library object and other minor improvements.

* Create static component library methods to manage library list.
* Rename component library, component, and alias objects to more readable name.
* Use pointer to component instead of root name to prevent redundant library searches.
* Add append message helper to message panel that calculates string length.
* Initial ground work for merging library and library document files.
* Improved component library file load error checking.
* Minor component library editor improvements.
parent 7776dd61
...@@ -690,28 +690,6 @@ void Affiche_1_Parametre( WinEDA_DrawFrame* frame, int pos_X, ...@@ -690,28 +690,6 @@ void Affiche_1_Parametre( WinEDA_DrawFrame* frame, int pos_X,
} }
/*
* Routine d'affichage de la documentation associee a un composant
*/
/****************************************************************************/
void AfficheDoc( WinEDA_DrawFrame* frame, const wxString& Doc,
const wxString& KeyW )
/****************************************************************************/
{
wxString Line1( wxT( "Doc: " ) ), Line2( wxT( "KeyW: " ) );
int color = BLUE;
if( frame && frame->MsgPanel )
{
frame->MsgPanel->EraseMsgBox();
Line1 += Doc;
Line2 += KeyW;
frame->MsgPanel->Affiche_1_Parametre( 10, Line1, Line2, color );
}
}
/***********************/ /***********************/
int GetTimeStamp() int GetTimeStamp()
/***********************/ /***********************/
......
...@@ -1379,7 +1379,8 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event ) ...@@ -1379,7 +1379,8 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event )
} }
void WinEDA_DrawPanel::UnManageCursor( void ) void WinEDA_DrawPanel::UnManageCursor( int id, int cursor,
const wxString& title )
{ {
wxClientDC dc( this ); wxClientDC dc( this );
...@@ -1387,5 +1388,12 @@ void WinEDA_DrawPanel::UnManageCursor( void ) ...@@ -1387,5 +1388,12 @@ void WinEDA_DrawPanel::UnManageCursor( void )
{ {
ForceCloseManageCurseur( this, &dc ); ForceCloseManageCurseur( this, &dc );
m_AutoPAN_Request = false; m_AutoPAN_Request = false;
if( id != -1 && cursor != -1 )
{
wxASSERT( cursor > wxCURSOR_NONE && cursor < wxCURSOR_MAX );
m_Parent->SetToolID( id, cursor, title );
}
} }
} }
...@@ -61,6 +61,20 @@ int WinEDA_MsgPanel::GetRequiredHeight() ...@@ -61,6 +61,20 @@ int WinEDA_MsgPanel::GetRequiredHeight()
} }
wxSize WinEDA_MsgPanel::computeTextSize( const wxString& text )
{
// Get size of the wxSYS_DEFAULT_GUI_FONT
wxSize textSizeInPixels;
wxScreenDC dc;
dc.SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) );
dc.GetTextExtent( text, &textSizeInPixels.x, &textSizeInPixels.y );
return textSizeInPixels;
}
/*************************************************/ /*************************************************/
void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event ) void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event )
/*************************************************/ /*************************************************/
...@@ -80,6 +94,36 @@ void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event ) ...@@ -80,6 +94,36 @@ void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event )
event.Skip(); event.Skip();
} }
void WinEDA_MsgPanel::AppendMessage( const wxString& textUpper,
const wxString& textLower,
int color, int pad )
{
wxString text;
wxSize drawSize = GetClientSize();
text = ( textUpper.Len() > textLower.Len() ) ? textUpper : textLower;
text.Append( ' ', pad );
MsgItem item;
/* Don't put the first message a window client position 0. Offset by
* one 'W' character width. */
if( m_last_x == 0 )
m_last_x = m_fontSize.x;
item.m_X = m_last_x;
item.m_UpperY = ( drawSize.y / 2 ) - m_fontSize.y;
item.m_LowerY = drawSize.y - m_fontSize.y;
item.m_UpperText = textUpper;
item.m_LowerText = textLower;
item.m_Color = color;
m_Items.push_back( item );
m_last_x += computeTextSize( text ).x;
Refresh();
}
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H, void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H,
......
...@@ -73,8 +73,8 @@ void ReAnnotatePowerSymbolsOnly( void ) ...@@ -73,8 +73,8 @@ void ReAnnotatePowerSymbolsOnly( void )
if( DrawList->Type() != TYPE_SCH_COMPONENT ) if( DrawList->Type() != TYPE_SCH_COMPONENT )
continue; continue;
SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) DrawList; SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) DrawList;
EDA_LibComponentStruct* Entry = LIB_COMPONENT* Entry =
( EDA_LibComponentStruct* )FindLibPart( DrawLibItem->m_ChipName ); CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( (Entry == NULL) || (Entry->m_Options != ENTRY_POWER) ) if( (Entry == NULL) || (Entry->m_Options != ENTRY_POWER) )
continue; continue;
...@@ -347,14 +347,15 @@ int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList, ...@@ -347,14 +347,15 @@ int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList,
int NbrCmp = 0; int NbrCmp = 0;
EDA_BaseStruct* DrawList = aSheet->LastDrawList(); EDA_BaseStruct* DrawList = aSheet->LastDrawList();
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
for( ; DrawList != NULL; DrawList = DrawList->Next() ) for( ; DrawList != NULL; DrawList = DrawList->Next() )
{ {
if( DrawList->Type() == TYPE_SCH_COMPONENT ) if( DrawList->Type() == TYPE_SCH_COMPONENT )
{ {
DrawLibItem = (SCH_COMPONENT*) DrawList; DrawLibItem = (SCH_COMPONENT*) DrawList;
Entry = ( EDA_LibComponentStruct* )FindLibPart( DrawLibItem->m_ChipName ); Entry =
CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
continue; continue;
......
...@@ -855,7 +855,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, ...@@ -855,7 +855,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
* @return a pointer to the pin * @return a pointer to the pin
*/ */
{ {
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
static LibEDA_BaseStruct* NextItem; static LibEDA_BaseStruct* NextItem;
static int Multi, convert, TransMat[2][2]; static int Multi, convert, TransMat[2][2];
LibEDA_BaseStruct* DEntry; LibEDA_BaseStruct* DEntry;
...@@ -866,8 +866,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, ...@@ -866,8 +866,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
if( aDrawLibItem ) if( aDrawLibItem )
{ {
NextItem = NULL; NextItem = NULL;
Entry = Entry = CMP_LIBRARY::FindLibraryComponent( aDrawLibItem->m_ChipName );
( EDA_LibComponentStruct* )FindLibPart( aDrawLibItem->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
return NULL; return NULL;
......
...@@ -18,18 +18,18 @@ ...@@ -18,18 +18,18 @@
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase ); bool erase );
static int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent, static int MarkItemsInBloc( LIB_COMPONENT* LibComponent,
EDA_Rect& Rect ); EDA_Rect& Rect );
static void ClearMarkItems( EDA_LibComponentStruct* LibComponent ); static void ClearMarkItems( LIB_COMPONENT* LibComponent );
static void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ); static void CopyMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset );
static void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ); static void MoveMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset );
static void MirrorMarkedItems( EDA_LibComponentStruct* LibEntry, static void MirrorMarkedItems( LIB_COMPONENT* LibEntry,
wxPoint offset ); wxPoint offset );
static void DeleteMarkedItems( EDA_LibComponentStruct* LibEntry ); static void DeleteMarkedItems( LIB_COMPONENT* LibEntry );
void ClearMarkItems( EDA_LibComponentStruct* LibComponent ) void ClearMarkItems( LIB_COMPONENT* LibComponent )
{ {
LibEDA_BaseStruct* item; LibEDA_BaseStruct* item;
...@@ -55,7 +55,7 @@ void ClearMarkItems( EDA_LibComponentStruct* LibComponent ) ...@@ -55,7 +55,7 @@ void ClearMarkItems( EDA_LibComponentStruct* LibComponent )
* only the pins specific to current part and current convert are marked * only the pins specific to current part and current convert are marked
* - all specific to current convert pins are marked; * - all specific to current convert pins are marked;
*/ */
int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent, int MarkItemsInBloc( LIB_COMPONENT* LibComponent,
EDA_Rect& Rect ) EDA_Rect& Rect )
{ {
LibEDA_BaseStruct* item; LibEDA_BaseStruct* item;
...@@ -389,7 +389,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -389,7 +389,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
/* /*
* Copy marked items, at new position = old position + offset * Copy marked items, at new position = old position + offset
*/ */
void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) void CopyMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset )
{ {
LibEDA_BaseStruct* item; LibEDA_BaseStruct* item;
...@@ -415,7 +415,7 @@ void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) ...@@ -415,7 +415,7 @@ void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
/* /*
* Move marked items, at new position = old position + offset * Move marked items, at new position = old position + offset
*/ */
void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) void MoveMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset )
{ {
LibEDA_BaseStruct* item; LibEDA_BaseStruct* item;
...@@ -437,7 +437,7 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) ...@@ -437,7 +437,7 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
/* /*
* Delete marked items * Delete marked items
*/ */
void DeleteMarkedItems( EDA_LibComponentStruct* LibEntry ) void DeleteMarkedItems( LIB_COMPONENT* LibEntry )
{ {
LibEDA_BaseStruct* item, * next_item; LibEDA_BaseStruct* item, * next_item;
...@@ -458,7 +458,7 @@ void DeleteMarkedItems( EDA_LibComponentStruct* LibEntry ) ...@@ -458,7 +458,7 @@ void DeleteMarkedItems( EDA_LibComponentStruct* LibEntry )
/* /*
* Mirror marked items, refer to a Vertical axis at position offset * Mirror marked items, refer to a Vertical axis at position offset
*/ */
void MirrorMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) void MirrorMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset )
{ {
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x; #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
LibEDA_BaseStruct* item; LibEDA_BaseStruct* item;
......
...@@ -579,7 +579,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( ...@@ -579,7 +579,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
int Multi, Unit; int Multi, Unit;
EDA_BaseStruct* DrawList; EDA_BaseStruct* DrawList;
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
char CmpName[80]; char CmpName[80];
wxString msg; wxString msg;
...@@ -649,7 +649,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( ...@@ -649,7 +649,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
Multi = 0; Multi = 0;
Unit = ' '; Unit = ' ';
Entry = ( EDA_LibComponentStruct* ) FindLibPart( DrawLibItem->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry ) if( Entry )
Multi = Entry->m_UnitCount; Multi = Entry->m_UnitCount;
...@@ -714,15 +714,14 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( ...@@ -714,15 +714,14 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
int DIALOG_BUILD_BOM::PrintComponentsListByVal( int DIALOG_BUILD_BOM::PrintComponentsListByVal(
FILE* f, FILE* f,
std::vector <OBJ_CMP_TO_LIST>& aList, std::vector <OBJ_CMP_TO_LIST>& aList,
bool bool aIncludeSubComponents )
aIncludeSubComponents )
/**********************************************************************************************/ /**********************************************************************************************/
{ {
int Multi; int Multi;
wxChar Unit; wxChar Unit;
EDA_BaseStruct* DrawList; EDA_BaseStruct* DrawList;
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
char CmpName[80]; char CmpName[80];
wxString msg; wxString msg;
...@@ -749,7 +748,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( ...@@ -749,7 +748,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal(
Multi = 0; Multi = 0;
Unit = ' '; Unit = ' ';
Entry = ( EDA_LibComponentStruct* ) FindLibPart( DrawLibItem->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry ) if( Entry )
Multi = Entry->m_UnitCount; Multi = Entry->m_UnitCount;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
LibDrawText::LibDrawText(EDA_LibComponentStruct * aParent) : LibDrawText::LibDrawText(LIB_COMPONENT * aParent) :
LibEDA_BaseStruct( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, aParent ), LibEDA_BaseStruct( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, aParent ),
EDA_TextStruct() EDA_TextStruct()
{ {
......
...@@ -145,53 +145,63 @@ int SortItemsFct(const void* ref, const void* item) ...@@ -145,53 +145,63 @@ int SortItemsFct(const void* ref, const void* item)
/*********************/ /*********************/
/* class LibCmpEntry */ /* class CMP_LIB_ENTRY */
/*********************/ /*********************/
/* Basic class for library component description /* Basic class for library component description
* Not directly used * Not directly used
* Used to create the 2 derived classes : * Used to create the 2 derived classes :
* - EDA_LibCmpAliasStruct * - LIB_ALIAS
* - EDA_LibComponentStruct * - LIB_COMPONENT
*/ */
/********************************************************************/ /********************************************************************/
LibCmpEntry::LibCmpEntry( LibrEntryType CmpType, const wxChar* CmpName ) : CMP_LIB_ENTRY::CMP_LIB_ENTRY( LibrEntryType type, const wxString& name,
CMP_LIBRARY* lib ) :
EDA_BaseStruct( LIBCOMPONENT_STRUCT_TYPE ) EDA_BaseStruct( LIBCOMPONENT_STRUCT_TYPE )
{ {
Type = CmpType; Type = type;
m_Name.m_FieldId = VALUE; m_Name.m_FieldId = VALUE;
m_Name.SetParent( this ); m_Name.SetParent( this );
if( CmpName ) m_Name.m_Text = name;
m_Name.m_Text = CmpName; m_lib = lib;
} }
LibCmpEntry::~LibCmpEntry() CMP_LIB_ENTRY::~CMP_LIB_ENTRY()
{ {
} }
bool LibCmpEntry::operator==( const wxChar* name ) const wxString CMP_LIB_ENTRY::GetLibraryName()
{
if( m_lib != NULL )
return m_lib->GetName();
return wxEmptyString;
}
bool CMP_LIB_ENTRY::operator==( const wxChar* name ) const
{ {
return m_Name.m_Text.CmpNoCase( name ) == 0; return m_Name.m_Text.CmpNoCase( name ) == 0;
} }
bool operator<( const LibCmpEntry& item1, const LibCmpEntry& item2 ) bool operator<( const CMP_LIB_ENTRY& item1, const CMP_LIB_ENTRY& item2 )
{ {
return item1.m_Name.m_Text.CmpNoCase( item2.m_Name.m_Text ) < 0; return item1.m_Name.m_Text.CmpNoCase( item2.m_Name.m_Text ) < 0;
} }
int LibraryEntryCompare( const LibCmpEntry* LE1, const LibCmpEntry* LE2 ) int LibraryEntryCompare( const CMP_LIB_ENTRY* LE1, const CMP_LIB_ENTRY* LE2 )
{ {
return LE1->m_Name.m_Text.CmpNoCase( LE2->m_Name.m_Text ); return LE1->m_Name.m_Text.CmpNoCase( LE2->m_Name.m_Text );
} }
/*******************************/ /*******************************/
/* class EDA_LibCmpAliasStruct */ /* class LIB_ALIAS */
/*******************************/ /*******************************/
/* Class to define an alias of a component /* Class to define an alias of a component
...@@ -203,30 +213,37 @@ int LibraryEntryCompare( const LibCmpEntry* LE1, const LibCmpEntry* LE2 ) ...@@ -203,30 +213,37 @@ int LibraryEntryCompare( const LibCmpEntry* LE1, const LibCmpEntry* LE2 )
* (like 74LS00, 74HC00 ... and many op amps ) * (like 74LS00, 74HC00 ... and many op amps )
*/ */
EDA_LibCmpAliasStruct::EDA_LibCmpAliasStruct( const wxChar* CmpName, LIB_ALIAS::LIB_ALIAS( const wxString& name, LIB_COMPONENT* root,
const wxChar* CmpRootName ) : CMP_LIBRARY* lib ) :
LibCmpEntry( ALIAS, CmpName ) CMP_LIB_ENTRY( ALIAS, name, lib )
{
wxASSERT( root != NULL && root->Type == ROOT );
m_root = root;
}
LIB_ALIAS::~LIB_ALIAS()
{ {
if( CmpRootName == NULL )
m_RootName.Empty();
else
m_RootName = CmpRootName;
} }
EDA_LibCmpAliasStruct::~EDA_LibCmpAliasStruct() void LIB_ALIAS::SetComponent( LIB_COMPONENT* root )
{ {
wxASSERT( root != NULL && root->Type == ROOT );
m_root = root;
} }
/********************************/ /********************************/
/* class EDA_LibComponentStruct */ /* class LIB_COMPONENT */
/********************************/ /********************************/
/* This is a standard component (in library) /* This is a standard component (in library)
*/ */
EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) : LIB_COMPONENT::LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib ) :
LibCmpEntry( ROOT, CmpName ) CMP_LIB_ENTRY( ROOT, name, lib )
{ {
m_Drawings = NULL; m_Drawings = NULL;
m_LastDate = 0; m_LastDate = 0;
...@@ -241,7 +258,7 @@ EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) : ...@@ -241,7 +258,7 @@ EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) :
} }
EDA_LibComponentStruct::~EDA_LibComponentStruct() LIB_COMPONENT::~LIB_COMPONENT()
{ {
LibEDA_BaseStruct* DrawItem; LibEDA_BaseStruct* DrawItem;
LibEDA_BaseStruct* NextDrawItem; LibEDA_BaseStruct* NextDrawItem;
...@@ -259,7 +276,7 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct() ...@@ -259,7 +276,7 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct()
} }
void EDA_LibComponentStruct::Draw( WinEDA_DrawPanel* panel, wxDC* dc, void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
const wxPoint& offset, int multi, const wxPoint& offset, int multi,
int convert, int drawMode, int color, int convert, int drawMode, int color,
const int transformMatrix[2][2], const int transformMatrix[2][2],
...@@ -359,7 +376,7 @@ void EDA_LibComponentStruct::Draw( WinEDA_DrawPanel* panel, wxDC* dc, ...@@ -359,7 +376,7 @@ void EDA_LibComponentStruct::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
} }
void EDA_LibComponentStruct::RemoveDrawItem( LibEDA_BaseStruct* item, void LIB_COMPONENT::RemoveDrawItem( LibEDA_BaseStruct* item,
WinEDA_DrawPanel* panel, WinEDA_DrawPanel* panel,
wxDC* dc ) wxDC* dc )
{ {
...@@ -398,7 +415,7 @@ void EDA_LibComponentStruct::RemoveDrawItem( LibEDA_BaseStruct* item, ...@@ -398,7 +415,7 @@ void EDA_LibComponentStruct::RemoveDrawItem( LibEDA_BaseStruct* item,
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool EDA_LibComponentStruct::Save( FILE* aFile ) bool LIB_COMPONENT::Save( FILE* aFile )
{ {
LibEDA_BaseStruct* DrawEntry; LibEDA_BaseStruct* DrawEntry;
LibDrawField* Field; LibDrawField* Field;
...@@ -517,7 +534,7 @@ bool EDA_LibComponentStruct::Save( FILE* aFile ) ...@@ -517,7 +534,7 @@ bool EDA_LibComponentStruct::Save( FILE* aFile )
return true; return true;
} }
bool EDA_LibComponentStruct::Load( FILE* file, char* line, int* lineNum, bool LIB_COMPONENT::Load( FILE* file, char* line, int* lineNum,
wxString& errorMsg ) wxString& errorMsg )
{ {
int unused; int unused;
...@@ -636,7 +653,7 @@ bool EDA_LibComponentStruct::Load( FILE* file, char* line, int* lineNum, ...@@ -636,7 +653,7 @@ bool EDA_LibComponentStruct::Load( FILE* file, char* line, int* lineNum,
} }
bool EDA_LibComponentStruct::LoadDrawEntries( FILE* f, char* line, bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line,
int* lineNum, wxString& errorMsg ) int* lineNum, wxString& errorMsg )
{ {
LibEDA_BaseStruct* newEntry = NULL; LibEDA_BaseStruct* newEntry = NULL;
...@@ -729,7 +746,7 @@ to flush to end of drawing section." ); ...@@ -729,7 +746,7 @@ to flush to end of drawing section." );
} }
bool EDA_LibComponentStruct::LoadAliases( char* line, wxString& errorMsg ) bool LIB_COMPONENT::LoadAliases( char* line, wxString& errorMsg )
{ {
char* text = strtok( line, " \t\r\n" ); char* text = strtok( line, " \t\r\n" );
...@@ -743,7 +760,7 @@ bool EDA_LibComponentStruct::LoadAliases( char* line, wxString& errorMsg ) ...@@ -743,7 +760,7 @@ bool EDA_LibComponentStruct::LoadAliases( char* line, wxString& errorMsg )
} }
bool EDA_LibComponentStruct::LoadField( char* line, wxString& errorMsg ) bool LIB_COMPONENT::LoadField( char* line, wxString& errorMsg )
{ {
LibDrawField* field = new LibDrawField( this ); LibDrawField* field = new LibDrawField( this );
...@@ -772,7 +789,7 @@ bool EDA_LibComponentStruct::LoadField( char* line, wxString& errorMsg ) ...@@ -772,7 +789,7 @@ bool EDA_LibComponentStruct::LoadField( char* line, wxString& errorMsg )
} }
bool EDA_LibComponentStruct::LoadFootprints( FILE* file, char* line, bool LIB_COMPONENT::LoadFootprints( FILE* file, char* line,
int* lineNum, wxString& errorMsg ) int* lineNum, wxString& errorMsg )
{ {
while( true ) while( true )
...@@ -799,7 +816,7 @@ bool EDA_LibComponentStruct::LoadFootprints( FILE* file, char* line, ...@@ -799,7 +816,7 @@ bool EDA_LibComponentStruct::LoadFootprints( FILE* file, char* line,
* items remplis en premier, pins en dernier * items remplis en premier, pins en dernier
* En cas de superposition d'items, c'est plus lisible * En cas de superposition d'items, c'est plus lisible
*/ */
void EDA_LibComponentStruct::SortDrawItems() void LIB_COMPONENT::SortDrawItems()
{ {
LibEDA_BaseStruct** Bufentry, ** BufentryBase, * Entry = m_Drawings; LibEDA_BaseStruct** Bufentry, ** BufentryBase, * Entry = m_Drawings;
int ii, nbitems; int ii, nbitems;
...@@ -842,7 +859,7 @@ void EDA_LibComponentStruct::SortDrawItems() ...@@ -842,7 +859,7 @@ void EDA_LibComponentStruct::SortDrawItems()
* if Convert == 0 Convert is non used * if Convert == 0 Convert is non used
**/ **/
/**********************************************************************/ /**********************************************************************/
EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) EDA_Rect LIB_COMPONENT::GetBoundaryBox( int Unit, int Convert )
{ {
LibEDA_BaseStruct* DrawEntry; LibEDA_BaseStruct* DrawEntry;
EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
...@@ -869,7 +886,7 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) ...@@ -869,7 +886,7 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
* initialize fields from a vector of fields * initialize fields from a vector of fields
* @param aFields a std::vector <LibDrawField> to import. * @param aFields a std::vector <LibDrawField> to import.
*/ */
void EDA_LibComponentStruct::SetFields( const std::vector <LibDrawField> aFields ) void LIB_COMPONENT::SetFields( const std::vector <LibDrawField> aFields )
{ {
// Init basic fields (Value = name in lib, and reference): // Init basic fields (Value = name in lib, and reference):
aFields[VALUE].Copy( &m_Name ); aFields[VALUE].Copy( &m_Name );
...@@ -918,7 +935,7 @@ void EDA_LibComponentStruct::SetFields( const std::vector <LibDrawField> aFields ...@@ -918,7 +935,7 @@ void EDA_LibComponentStruct::SetFields( const std::vector <LibDrawField> aFields
* lit date et time de modif composant sous le format: * lit date et time de modif composant sous le format:
* "Ti yy/mm/jj hh:mm:ss" * "Ti yy/mm/jj hh:mm:ss"
*/ */
bool EDA_LibComponentStruct::SaveDateAndTime( FILE* file ) bool LIB_COMPONENT::SaveDateAndTime( FILE* file )
{ {
int year, mon, day, hour, min, sec; int year, mon, day, hour, min, sec;
...@@ -942,7 +959,7 @@ bool EDA_LibComponentStruct::SaveDateAndTime( FILE* file ) ...@@ -942,7 +959,7 @@ bool EDA_LibComponentStruct::SaveDateAndTime( FILE* file )
/* lit date et time de modif composant sous le format: /* lit date et time de modif composant sous le format:
* "Ti yy/mm/jj hh:mm:ss" * "Ti yy/mm/jj hh:mm:ss"
*/ */
bool EDA_LibComponentStruct::LoadDateAndTime( char* Line ) bool LIB_COMPONENT::LoadDateAndTime( char* Line )
{ {
int year, mon, day, hour, min, sec; int year, mon, day, hour, min, sec;
char* text; char* text;
...@@ -963,7 +980,7 @@ bool EDA_LibComponentStruct::LoadDateAndTime( char* Line ) ...@@ -963,7 +980,7 @@ bool EDA_LibComponentStruct::LoadDateAndTime( char* Line )
} }
void EDA_LibComponentStruct::SetOffset( const wxPoint& offset ) void LIB_COMPONENT::SetOffset( const wxPoint& offset )
{ {
LibEDA_BaseStruct* DrawEntry; LibEDA_BaseStruct* DrawEntry;
...@@ -985,7 +1002,7 @@ void EDA_LibComponentStruct::SetOffset( const wxPoint& offset ) ...@@ -985,7 +1002,7 @@ void EDA_LibComponentStruct::SetOffset( const wxPoint& offset )
} }
void EDA_LibComponentStruct::RemoveDuplicateDrawItems() void LIB_COMPONENT::RemoveDuplicateDrawItems()
{ {
LibEDA_BaseStruct* DEntryRef; LibEDA_BaseStruct* DEntryRef;
LibEDA_BaseStruct* DEntryCompare; LibEDA_BaseStruct* DEntryCompare;
...@@ -1024,7 +1041,7 @@ void EDA_LibComponentStruct::RemoveDuplicateDrawItems() ...@@ -1024,7 +1041,7 @@ void EDA_LibComponentStruct::RemoveDuplicateDrawItems()
} }
bool EDA_LibComponentStruct::HasConversion() const bool LIB_COMPONENT::HasConversion() const
{ {
LibEDA_BaseStruct* entry; LibEDA_BaseStruct* entry;
...@@ -1046,7 +1063,7 @@ bool EDA_LibComponentStruct::HasConversion() const ...@@ -1046,7 +1063,7 @@ bool EDA_LibComponentStruct::HasConversion() const
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool LibCmpEntry::SaveDoc( FILE* aFile ) bool CMP_LIB_ENTRY::SaveDoc( FILE* aFile )
{ {
if( m_Doc.IsEmpty() && m_KeyWord.IsEmpty() && m_DocFile.IsEmpty() ) if( m_Doc.IsEmpty() && m_KeyWord.IsEmpty() && m_DocFile.IsEmpty() )
return true; return true;
......
...@@ -13,12 +13,15 @@ ...@@ -13,12 +13,15 @@
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
class CMP_LIBRARY;
/* Types for components in libraries /* Types for components in libraries
* components can be a true component or an alias of a true component. * components can be a true component or an alias of a true component.
*/ */
enum LibrEntryType enum LibrEntryType
{ {
ROOT, /* This is a true component standard EDA_LibComponentStruct */ ROOT, /* This is a true component standard LIB_COMPONENT */
ALIAS /* This is an alias of a true component */ ALIAS /* This is an alias of a true component */
}; };
...@@ -35,7 +38,7 @@ enum LibrEntryOptions ...@@ -35,7 +38,7 @@ enum LibrEntryOptions
* *
* This class is not to be used directly. * This class is not to be used directly.
*/ */
class LibCmpEntry : public EDA_BaseStruct class CMP_LIB_ENTRY : public EDA_BaseStruct
{ {
public: public:
LibrEntryType Type; /* Type = ROOT; LibrEntryType Type; /* Type = ROOT;
...@@ -48,13 +51,16 @@ public: ...@@ -48,13 +51,16 @@ public:
LibrEntryOptions m_Options; // special features (i.e. Entry is a POWER) LibrEntryOptions m_Options; // special features (i.e. Entry is a POWER)
public: public:
LibCmpEntry( LibrEntryType CmpType, const wxChar* CmpName ); CMP_LIB_ENTRY( LibrEntryType CmpType, const wxString& name,
virtual ~LibCmpEntry(); CMP_LIBRARY* lib = NULL );
virtual ~CMP_LIB_ENTRY();
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
return wxT( "LibCmpEntry" ); return wxT( "CMP_LIB_ENTRY" );
} }
wxString GetLibraryName();
const wxString& GetName() { return m_Name.m_Text; } const wxString& GetName() { return m_Name.m_Text; }
...@@ -75,15 +81,18 @@ public: ...@@ -75,15 +81,18 @@ public:
{ {
return !( *this == name ); return !( *this == name );
} }
protected:
CMP_LIBRARY* m_lib;
}; };
typedef boost::ptr_vector< LibCmpEntry > LIB_ENTRY_LIST; typedef boost::ptr_vector< CMP_LIB_ENTRY > LIB_ENTRY_LIST;
extern bool operator<( const LibCmpEntry& item1, const LibCmpEntry& item2 ); extern bool operator<( const CMP_LIB_ENTRY& item1, const CMP_LIB_ENTRY& item2 );
extern int LibraryEntryCompare( const LibCmpEntry* LE1, extern int LibraryEntryCompare( const CMP_LIB_ENTRY* LE1,
const LibCmpEntry* LE2 ); const CMP_LIB_ENTRY* LE2 );
/** /**
...@@ -93,7 +102,7 @@ extern int LibraryEntryCompare( const LibCmpEntry* LE1, ...@@ -93,7 +102,7 @@ extern int LibraryEntryCompare( const LibCmpEntry* LE1,
* library file (.lib). Library components are different from schematic * library file (.lib). Library components are different from schematic
* components. * components.
*/ */
class EDA_LibComponentStruct : public LibCmpEntry class LIB_COMPONENT : public CMP_LIB_ENTRY
{ {
public: public:
LibDrawField m_Prefix; /* Prefix ( U, IC ... ) = REFERENCE */ LibDrawField m_Prefix; /* Prefix ( U, IC ... ) = REFERENCE */
...@@ -120,12 +129,12 @@ public: ...@@ -120,12 +129,12 @@ public:
public: public:
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
return wxT( "EDA_LibComponentStruct" ); return wxT( "LIB_COMPONENT" );
} }
EDA_LibComponentStruct( const wxChar* CmpName ); LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib = NULL );
~EDA_LibComponentStruct(); ~LIB_COMPONENT();
EDA_Rect GetBoundaryBox( int Unit, int Convert ); EDA_Rect GetBoundaryBox( int Unit, int Convert );
...@@ -248,19 +257,33 @@ public: ...@@ -248,19 +257,33 @@ public:
* object not as children of a library object. This would greatly * object not as children of a library object. This would greatly
* simplify searching for components in libraries. * simplify searching for components in libraries.
*/ */
class EDA_LibCmpAliasStruct : public LibCmpEntry class LIB_ALIAS : public CMP_LIB_ENTRY
{ {
public: protected:
wxString m_RootName; /* Root component Part name */ LIB_COMPONENT* m_root; /* Root component of the alias. */
public: public:
EDA_LibCmpAliasStruct( const wxChar* CmpName, const wxChar* CmpRootName ); LIB_ALIAS( const wxString& name, LIB_COMPONENT* root,
~EDA_LibCmpAliasStruct(); CMP_LIBRARY* lib = NULL );
~LIB_ALIAS();
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
return wxT( "EDA_LibCmpAliasStruct" ); return wxT( "LIB_ALIAS" );
} }
/**
* Get the alias root component.
*/
LIB_COMPONENT* GetComponent( void ) const
{
return m_root;
}
/**
* Set the alias root component.
*/
void SetComponent( LIB_COMPONENT* component );
}; };
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* *
* others = free fields * others = free fields
*/ */
LibDrawField::LibDrawField(EDA_LibComponentStruct * aParent, int idfield ) : LibDrawField::LibDrawField(LIB_COMPONENT * aParent, int idfield ) :
LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE, aParent ) LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE, aParent )
{ {
m_FieldId = idfield; m_FieldId = idfield;
...@@ -327,7 +327,7 @@ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold, ...@@ -327,7 +327,7 @@ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold,
{ {
extraCharCount++; extraCharCount++;
m_Text.Append('?'); m_Text.Append('?');
EDA_LibComponentStruct* parent = (EDA_LibComponentStruct*)m_Parent; LIB_COMPONENT* parent = (LIB_COMPONENT*)m_Parent;
if ( parent && ( parent->m_UnitCount > 1 ) ) if ( parent && ( parent->m_UnitCount > 1 ) )
{ {
m_Text.Append('A'); m_Text.Append('A');
......
...@@ -35,7 +35,7 @@ public: ...@@ -35,7 +35,7 @@ public:
LibDrawField( int idfield = 2 ); LibDrawField( int idfield = 2 );
LibDrawField( EDA_LibComponentStruct * aParent, int idfield = 2 ); LibDrawField( LIB_COMPONENT * aParent, int idfield = 2 );
~LibDrawField(); ~LibDrawField();
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
......
...@@ -18,52 +18,86 @@ ...@@ -18,52 +18,86 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <wx/tokenzr.h>
bool operator==( const LibraryStruct& lib, const wxChar* name )
static const wxChar* duplicate_name_msg = _( "Component library <%s> has \
duplicate entry name <%s>. This may cause some expected behavior when \
loading components into a schematic." );
static bool DuplicateEntryName( const CMP_LIB_ENTRY& item1,
const CMP_LIB_ENTRY& item2 )
{
return item1.m_Name.m_Text.CmpNoCase( item2.m_Name.m_Text ) == 0;
}
bool operator==( const CMP_LIBRARY& lib, const wxChar* name )
{ {
return lib.m_Name.CmpNoCase( name ) == 0; return lib.GetName().CmpNoCase( name ) == 0;
} }
bool operator!=( const LibraryStruct& lib, const wxChar* name ) bool operator!=( const CMP_LIBRARY& lib, const wxChar* name )
{ {
return !( lib == name ); return !( lib == name );
} }
LibraryStruct::LibraryStruct( int type, const wxString& name, bool operator<( const CMP_LIBRARY& item1, const CMP_LIBRARY& item2 )
const wxString& fullname ) {
/* The cache library always is sorted to the end of the library list. */
if( item1.IsCache() )
return true;
if( item2.IsCache() )
return false;
/* If the sort order array isn't set, then sort alphabetically except. */
if( CMP_LIBRARY::GetSortOrder().IsEmpty() )
return item1.GetName().CmpNoCase( item2.GetName() ) < 0;
int i1 = CMP_LIBRARY::GetSortOrder().Index( item1.GetName(), false );
int i2 = CMP_LIBRARY::GetSortOrder().Index( item2.GetName(), false );
if( i1 == wxNOT_FOUND && i2 == wxNOT_FOUND )
return true;
if( i1 == wxNOT_FOUND && i2 != wxNOT_FOUND )
return false;
if( i1 != wxNOT_FOUND && i2 == wxNOT_FOUND )
return true;
return ( i1 - i2 ) < 0;
}
CMP_LIBRARY::CMP_LIBRARY( int type, const wxFileName& fileName )
{ {
m_Type = type; /* type indicator */ m_Type = type; /* type indicator */
m_Name = name; /* Name of library loaded. */
m_FullFileName = fullname; /* File name (with path) of library loaded. */
m_Pnext = NULL; /* Point to next library in chain. */
m_IsModified = false; /* flag indicateur d'edition */ m_IsModified = false; /* flag indicateur d'edition */
m_TimeStamp = 0; m_TimeStamp = 0;
m_Flags = 0; m_Flags = 0;
m_IsLibCache = false; m_IsCache = false;
m_DateTime = wxDateTime::Now(); m_DateTime = wxDateTime::Now();
}
if( fileName.IsOk() )
LibraryStruct::LibraryStruct( const wxChar* fileName )
{
if( fileName == NULL )
m_fileName = wxT( "unnamed.lib" );
else
m_fileName = fileName; m_fileName = fileName;
else
m_fileName = wxFileName( wxT( "unnamed.lib" ) );
} }
LibraryStruct::~LibraryStruct() CMP_LIBRARY::~CMP_LIBRARY()
{ {
} }
void LibraryStruct::GetEntryNames( wxArrayString& names, bool sort, void CMP_LIBRARY::GetEntryNames( wxArrayString& names, bool sort,
bool makeUpperCase ) bool makeUpperCase )
{ {
BOOST_FOREACH( LibCmpEntry& entry, m_Entries ) BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries )
{ {
if( makeUpperCase ) if( makeUpperCase )
names.Add( entry.m_Name.m_Text.MakeUpper() ); names.Add( entry.m_Name.m_Text.MakeUpper() );
...@@ -76,12 +110,12 @@ void LibraryStruct::GetEntryNames( wxArrayString& names, bool sort, ...@@ -76,12 +110,12 @@ void LibraryStruct::GetEntryNames( wxArrayString& names, bool sort,
} }
void LibraryStruct::SearchEntryNames( wxArrayString& names, void CMP_LIBRARY::SearchEntryNames( wxArrayString& names,
const wxString& nameSearch, const wxString& nameSearch,
const wxString& keySearch, const wxString& keySearch,
bool sort ) bool sort )
{ {
BOOST_FOREACH( LibCmpEntry& entry, m_Entries ) BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries )
{ {
if( !keySearch.IsEmpty() && KeyWordOk( keySearch, entry.m_KeyWord ) ) if( !keySearch.IsEmpty() && KeyWordOk( keySearch, entry.m_KeyWord ) )
names.Add( entry.GetName() ); names.Add( entry.GetName() );
...@@ -96,9 +130,9 @@ void LibraryStruct::SearchEntryNames( wxArrayString& names, ...@@ -96,9 +130,9 @@ void LibraryStruct::SearchEntryNames( wxArrayString& names,
} }
LibCmpEntry* LibraryStruct::FindEntry( const wxChar* name ) CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* name )
{ {
BOOST_FOREACH( LibCmpEntry& entry, m_Entries ) BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries )
{ {
if( entry.GetName().CmpNoCase( name ) == 0 ) if( entry.GetName().CmpNoCase( name ) == 0 )
return &entry; return &entry;
...@@ -108,9 +142,9 @@ LibCmpEntry* LibraryStruct::FindEntry( const wxChar* name ) ...@@ -108,9 +142,9 @@ LibCmpEntry* LibraryStruct::FindEntry( const wxChar* name )
} }
LibCmpEntry* LibraryStruct::FindEntry( const wxChar* name, LibrEntryType type ) CMP_LIB_ENTRY* CMP_LIBRARY::FindEntry( const wxChar* name, LibrEntryType type )
{ {
BOOST_FOREACH( LibCmpEntry& entry, m_Entries ) BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries )
{ {
if( entry.GetName().CmpNoCase( name ) == 0 && entry.Type == type ) if( entry.GetName().CmpNoCase( name ) == 0 && entry.Type == type )
return &entry; return &entry;
...@@ -120,31 +154,26 @@ LibCmpEntry* LibraryStruct::FindEntry( const wxChar* name, LibrEntryType type ) ...@@ -120,31 +154,26 @@ LibCmpEntry* LibraryStruct::FindEntry( const wxChar* name, LibrEntryType type )
} }
EDA_LibComponentStruct* LibraryStruct::FindComponent( const wxChar* name, LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxChar* name )
bool searchAliases )
{ {
if( !searchAliases ) LIB_COMPONENT* component = NULL;
return (EDA_LibComponentStruct*) FindEntry( name, ROOT ); CMP_LIB_ENTRY* entry = FindEntry( name );
EDA_LibComponentStruct* component = NULL;
LibCmpEntry* entry = FindEntry( name );
if( entry != NULL && entry->Type == ALIAS ) if( entry != NULL && entry->Type == ALIAS )
{ {
EDA_LibCmpAliasStruct* alias = (EDA_LibCmpAliasStruct*) entry; LIB_ALIAS* alias = (LIB_ALIAS*) entry;
component = (EDA_LibComponentStruct*) FindEntry( alias->m_RootName, component = alias->GetComponent();
ROOT );
} }
else else
{ {
component = (EDA_LibComponentStruct*) entry; component = (LIB_COMPONENT*) entry;
} }
return component; return component;
} }
bool LibraryStruct::AddAlias( EDA_LibCmpAliasStruct* alias ) bool CMP_LIBRARY::AddAlias( LIB_ALIAS* alias )
{ {
wxASSERT( alias != NULL ); wxASSERT( alias != NULL );
...@@ -153,55 +182,61 @@ bool LibraryStruct::AddAlias( EDA_LibCmpAliasStruct* alias ) ...@@ -153,55 +182,61 @@ bool LibraryStruct::AddAlias( EDA_LibCmpAliasStruct* alias )
wxString msg; wxString msg;
msg.Printf( _( "Cannot add duplicate alias <%s> to library <%s>." ), msg.Printf( _( "Cannot add duplicate alias <%s> to library <%s>." ),
(const wxChar*) alias->GetName(), (const wxChar*) m_Name ); (const wxChar*) alias->GetName(),
(const wxChar*) m_fileName.GetName() );
return false; return false;
} }
m_Entries.push_back( (LibCmpEntry*) alias ); m_Entries.push_back( (CMP_LIB_ENTRY*) alias );
m_IsModified = true; m_IsModified = true;
return true; return true;
} }
EDA_LibComponentStruct* LibraryStruct::AddComponent( EDA_LibComponentStruct* cmp ) LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* cmp )
{ {
wxASSERT( cmp != NULL ); wxASSERT( cmp != NULL );
EDA_LibComponentStruct* newCmp = CopyLibEntryStruct( cmp ); LIB_COMPONENT* newCmp = CopyLibEntryStruct( cmp );
if( newCmp == NULL ) if( newCmp == NULL )
return NULL; return NULL;
m_Entries.push_back( (LibCmpEntry*) newCmp ); m_Entries.push_back( (CMP_LIB_ENTRY*) newCmp );
m_IsModified = true; m_IsModified = true;
/* Cache libraries are component only libraries. Do not create alias
* entries. */
if( !m_IsCache )
{
for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ ) for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ )
{ {
EDA_LibCmpAliasStruct* alias = FindAlias( newCmp->m_AliasList[ i ] ); LIB_ALIAS* alias = FindAlias( newCmp->m_AliasList[ i ] );
if( alias == NULL ) if( alias == NULL )
{ {
alias = new EDA_LibCmpAliasStruct( newCmp->m_AliasList[ i ], alias = new LIB_ALIAS( newCmp->m_AliasList[ i ], newCmp );
newCmp->GetName() );
m_Entries.push_back( alias ); m_Entries.push_back( alias );
} }
else if( alias->m_RootName != newCmp->GetName() ) else if( alias->GetComponent()->GetName().CmpNoCase( newCmp->GetName() ) != 0 )
{ {
wxLogError( _( "Conflict in library <%s>: alias <%s> already has \ wxLogError( _( "Conflict in library <%s>: alias <%s> already \
root name <%s> and will not be assigned to root name <%s>." ), has root name <%s> and will not be assigned to root name <%s>." ),
(const wxChar*) m_Name, (const wxChar*) m_fileName.GetName(),
(const wxChar*) alias->m_RootName, (const wxChar*) alias->GetComponent()->GetName(),
(const wxChar*) newCmp->GetName() ); (const wxChar*) newCmp->GetName() );
} }
} }
}
m_Entries.sort(); m_Entries.sort();
m_Entries.unique( DuplicateEntryName );
return newCmp; return newCmp;
} }
void LibraryStruct::RemoveEntry( const wxString& name ) void CMP_LIBRARY::RemoveEntry( const wxString& name )
{ {
LIB_ENTRY_LIST::iterator i; LIB_ENTRY_LIST::iterator i;
...@@ -216,19 +251,19 @@ void LibraryStruct::RemoveEntry( const wxString& name ) ...@@ -216,19 +251,19 @@ void LibraryStruct::RemoveEntry( const wxString& name )
} }
void LibraryStruct::RemoveEntry( LibCmpEntry* entry ) void CMP_LIBRARY::RemoveEntry( CMP_LIB_ENTRY* entry )
{ {
wxASSERT( entry != NULL ); wxASSERT( entry != NULL );
EDA_LibComponentStruct* Root; LIB_COMPONENT* Root;
EDA_LibCmpAliasStruct* Alias; LIB_ALIAS* Alias;
m_IsModified = true; m_IsModified = true;
if( entry->Type == ALIAS ) if( entry->Type == ALIAS )
{ {
Alias = (EDA_LibCmpAliasStruct*) entry; Alias = (LIB_ALIAS*) entry;
Root = FindComponent( Alias->m_RootName ); Root = Alias->GetComponent();
/* Remove alias name from the root component alias list */ /* Remove alias name from the root component alias list */
if( Root == NULL ) if( Root == NULL )
...@@ -236,7 +271,7 @@ void LibraryStruct::RemoveEntry( LibCmpEntry* entry ) ...@@ -236,7 +271,7 @@ void LibraryStruct::RemoveEntry( LibCmpEntry* entry )
wxLogWarning( wxT( "No root component found for alias <%s> in \ wxLogWarning( wxT( "No root component found for alias <%s> in \
library <%s>." ), library <%s>." ),
( const wxChar* ) entry->GetName(), ( const wxChar* ) entry->GetName(),
( const wxChar* ) m_Name ); ( const wxChar* ) m_fileName.GetName() );
} }
else else
{ {
...@@ -247,7 +282,7 @@ library <%s>." ), ...@@ -247,7 +282,7 @@ library <%s>." ),
alias list in library <%s>" ), alias list in library <%s>" ),
( const wxChar* ) entry->GetName(), ( const wxChar* ) entry->GetName(),
( const wxChar* ) Root->GetName(), ( const wxChar* ) Root->GetName(),
( const wxChar* ) m_Name ); ( const wxChar* ) m_fileName.GetName() );
else else
Root->m_AliasList.RemoveAt( index ); Root->m_AliasList.RemoveAt( index );
} }
...@@ -257,7 +292,7 @@ alias list in library <%s>" ), ...@@ -257,7 +292,7 @@ alias list in library <%s>" ),
return; return;
} }
Root = ( EDA_LibComponentStruct* ) entry; Root = ( LIB_COMPONENT* ) entry;
/* Entry is a component with no aliases so removal is simple. */ /* Entry is a component with no aliases so removal is simple. */
if( Root->m_AliasList.GetCount() == 0 ) if( Root->m_AliasList.GetCount() == 0 )
...@@ -279,7 +314,7 @@ alias list in library <%s>" ), ...@@ -279,7 +314,7 @@ alias list in library <%s>" ),
library <%s>" ), library <%s>" ),
( const wxChar* ) AliasName, ( const wxChar* ) AliasName,
( const wxChar* ) Root->GetName(), ( const wxChar* ) Root->GetName(),
( const wxChar* ) m_Name ); ( const wxChar* ) m_fileName.GetName() );
return; return;
} }
...@@ -293,41 +328,20 @@ library <%s>" ), ...@@ -293,41 +328,20 @@ library <%s>" ),
/* Remove the first alias from library. */ /* Remove the first alias from library. */
RemoveEntry( AliasName ); RemoveEntry( AliasName );
/* Change the root name. */
Root->m_Name.m_Text = AliasName; Root->m_Name.m_Text = AliasName;
/* Change the "RootName" for all other aliases */
for( size_t ii = 0; ii < Root->m_AliasList.GetCount(); ii++ )
{
Alias = FindAlias( Root->m_AliasList[ii] );
/* Should not occur if library was saved by the library editor.
* However, it is possible if the library was edited by hand or
* some other program or a there is a bug in the library editor. */
if( Alias == NULL )
{
wxLogWarning( wxT( "Alias <%s> for component <%s> not found in \
library <%s>." ),
( const wxChar* ) AliasName,
( const wxChar* ) Root->GetName(),
( const wxChar* ) m_Name );
continue;
}
Alias->m_RootName = Root->GetName();
}
} }
EDA_LibComponentStruct* LibraryStruct::ReplaceComponent( LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* oldComponent,
EDA_LibComponentStruct* oldComponent, LIB_COMPONENT* newComponent )
EDA_LibComponentStruct* newComponent )
{ {
wxASSERT( oldComponent != NULL && newComponent != NULL wxASSERT( oldComponent != NULL && newComponent != NULL
&& oldComponent->GetName().CmpNoCase( newComponent->GetName() )== 0 ); && oldComponent->GetName().CmpNoCase( newComponent->GetName() )== 0 );
size_t i; size_t i;
int index; int index;
EDA_LibCmpAliasStruct* alias; LIB_ALIAS* alias;
if( oldComponent->m_AliasList != newComponent->m_AliasList ) if( oldComponent->m_AliasList != newComponent->m_AliasList )
{ {
...@@ -344,7 +358,7 @@ EDA_LibComponentStruct* LibraryStruct::ReplaceComponent( ...@@ -344,7 +358,7 @@ EDA_LibComponentStruct* LibraryStruct::ReplaceComponent(
in library <%s>." ), in library <%s>." ),
(const wxChar*) oldComponent->m_AliasList[ i ], (const wxChar*) oldComponent->m_AliasList[ i ],
(const wxChar*) oldComponent->GetName(), (const wxChar*) oldComponent->GetName(),
(const wxChar*) m_Name ); (const wxChar*) m_fileName.GetName() );
RemoveEntry( oldComponent->m_AliasList[ i ] ); RemoveEntry( oldComponent->m_AliasList[ i ] );
} }
...@@ -363,32 +377,32 @@ in library <%s>." ), ...@@ -363,32 +377,32 @@ in library <%s>." ),
in library <%s>." ), in library <%s>." ),
(const wxChar*) newComponent->m_AliasList[ i ], (const wxChar*) newComponent->m_AliasList[ i ],
(const wxChar*) newComponent->GetName(), (const wxChar*) newComponent->GetName(),
(const wxChar*) m_Name ); (const wxChar*) m_fileName.GetName() );
alias = new EDA_LibCmpAliasStruct( newComponent->m_AliasList[ i ], alias = new LIB_ALIAS( newComponent->m_AliasList[ i ],
newComponent->GetName() ); newComponent );
m_Entries.push_back( alias ); m_Entries.push_back( alias );
} }
} }
RemoveEntry( oldComponent->GetName() ); RemoveEntry( oldComponent->GetName() );
EDA_LibComponentStruct* newCmp = CopyLibEntryStruct( newComponent ); LIB_COMPONENT* newCmp = CopyLibEntryStruct( newComponent );
if( newCmp == NULL ) if( newCmp == NULL )
return NULL; return NULL;
m_Entries.push_back( (LibCmpEntry*) newCmp ); m_Entries.push_back( (CMP_LIB_ENTRY*) newCmp );
m_Entries.sort(); m_Entries.sort();
m_IsModified = true; m_IsModified = true;
return newCmp; return newCmp;
} }
LibCmpEntry* LibraryStruct::GetNextEntry( const wxChar* name ) CMP_LIB_ENTRY* CMP_LIBRARY::GetNextEntry( const wxChar* name )
{ {
size_t i; size_t i;
LibCmpEntry* entry = NULL; CMP_LIB_ENTRY* entry = NULL;
for( i = 0; i < m_Entries.size(); i++ ) for( i = 0; i < m_Entries.size(); i++ )
{ {
...@@ -409,10 +423,10 @@ LibCmpEntry* LibraryStruct::GetNextEntry( const wxChar* name ) ...@@ -409,10 +423,10 @@ LibCmpEntry* LibraryStruct::GetNextEntry( const wxChar* name )
} }
LibCmpEntry* LibraryStruct::GetPreviousEntry( const wxChar* name ) CMP_LIB_ENTRY* CMP_LIBRARY::GetPreviousEntry( const wxChar* name )
{ {
size_t i; size_t i;
LibCmpEntry* entry = NULL; CMP_LIB_ENTRY* entry = NULL;
for( i = 0; i < m_Entries.size(); i++ ) for( i = 0; i < m_Entries.size(); i++ )
{ {
...@@ -426,43 +440,94 @@ LibCmpEntry* LibraryStruct::GetPreviousEntry( const wxChar* name ) ...@@ -426,43 +440,94 @@ LibCmpEntry* LibraryStruct::GetPreviousEntry( const wxChar* name )
} }
bool LibraryStruct::Load( wxString& errMsg ) bool CMP_LIBRARY::Load( wxString& errMsg )
{ {
FILE* f; FILE* f;
int LineNum = 0; int LineNum = 0;
char Line[1024]; char Line[1024];
EDA_LibComponentStruct* LibEntry; LIB_COMPONENT* LibEntry;
wxString msg; wxString msg;
if( m_FullFileName.IsEmpty() ) if( m_fileName.GetFullPath().IsEmpty() )
{ {
errMsg = _( "library file name not set" ); errMsg = _( "The component library file name is not set." );
return false; return false;
} }
f = wxFopen( m_FullFileName, wxT( "rt" ) ); f = wxFopen( m_fileName.GetFullPath(), wxT( "rt" ) );
if( f == NULL ) if( f == NULL )
{ {
errMsg = _( "could not open file" ); errMsg = _( "The file could not be opened." );
return false; return false;
} }
if( GetLine( f, Line, &LineNum, sizeof( Line ) ) == NULL ) if( GetLine( f, Line, &LineNum, sizeof( Line ) ) == NULL )
{ {
errMsg = _( "file is empty!" ); errMsg = _( "The file is empty!" );
return false; return false;
} }
if( strnicmp( Line, LIBFILE_IDENT, 10 ) != 0 ) /* There is no header if this is a symbol library. */
if( m_Type == LIBRARY_TYPE_EESCHEMA )
{ {
errMsg = _( "file is NOT an EESCHEMA library!" ); wxString tmp;
m_Header = CONV_FROM_UTF8( Line );
wxStringTokenizer tkn( m_Header );
/*
* The file header (first line) in library versions 2.0 and lower
* apparently started with EESchema-LIB. Sometime after 2.0, it
* was changed to EESchema-LIBRARY. Therefore, the test for
* EESchema-LIB will work in both cases. Don't change this unless
* backwards compatability is no longer required.
*/
if( !tkn.HasMoreTokens()
|| !tkn.GetNextToken().Upper().StartsWith(wxT( "EESCHEMA-LIB" ) ) )
{
errMsg = _( "The file is NOT an EESCHEMA library!" );
return false; return false;
} }
/* There is no header if this is a symbol library. */ if( !tkn.HasMoreTokens() )
if( m_Type == LIBRARY_TYPE_EESCHEMA ) {
m_Header = CONV_FROM_UTF8( Line ); errMsg = _( "The file header is missing version and time stamp \
information." );
return false;
}
if( tkn.GetNextToken() != wxT( "Version" ) || !tkn.HasMoreTokens() )
{
errMsg = _( "The file header version information is invalid." );
return false;
}
long major, minor;
wxStringTokenizer vers( tkn.GetNextToken(), wxT( "." ) );
if( !vers.HasMoreTokens() || !vers.GetNextToken().ToLong( &major )
|| major < 1L || !vers.HasMoreTokens()
|| !vers.GetNextToken().ToLong( & minor ) || minor < 0L
|| minor > 99 )
{
wxLogWarning( _( "The component library <%s> header version \
number is invalid.\n\nIn future versions of EESchema this library may not \
load correctly.\nTo resolve this problem open the library in the library \
editor and save it.\nIf this library is the project cache library, save \
the current schematic." ),
(const wxChar*) GetName() );
}
else
{
m_verMajor = (int) major;
m_verMinor = (int) minor;
wxLogDebug( wxT( "Component library <%s> is version %d.%d." ),
(const wxChar*) GetName(), m_verMajor, m_verMinor );
}
}
while( GetLine( f, Line, &LineNum, sizeof( Line ) ) ) while( GetLine( f, Line, &LineNum, sizeof( Line ) ) )
{ {
...@@ -471,7 +536,7 @@ bool LibraryStruct::Load( wxString& errMsg ) ...@@ -471,7 +536,7 @@ bool LibraryStruct::Load( wxString& errMsg )
{ {
if( !LoadHeader( f, &LineNum ) ) if( !LoadHeader( f, &LineNum ) )
{ {
errMsg = _( "header read error" ); errMsg = _( "An error occured attempting to read the header." );
return false; return false;
} }
...@@ -481,18 +546,28 @@ bool LibraryStruct::Load( wxString& errMsg ) ...@@ -481,18 +546,28 @@ bool LibraryStruct::Load( wxString& errMsg )
if( strnicmp( Line, "DEF", 3 ) == 0 ) if( strnicmp( Line, "DEF", 3 ) == 0 )
{ {
/* Read one DEF/ENDDEF part entry from library: */ /* Read one DEF/ENDDEF part entry from library: */
LibEntry = new EDA_LibComponentStruct( NULL ); LibEntry = new LIB_COMPONENT( wxEmptyString, this );
if( LibEntry->Load( f, Line, &LineNum, msg ) ) if( LibEntry->Load( f, Line, &LineNum, msg ) )
{ {
/* Check for duplicate entry names and warn the user about
* the potential conflict.
*/
if( FindEntry( LibEntry->GetName() ) != NULL )
{
wxLogWarning( duplicate_name_msg,
(const wxChar*) m_fileName.GetName(),
(const wxChar*) LibEntry->GetName() );
}
/* If we are here, this part is O.k. - put it in: */ /* If we are here, this part is O.k. - put it in: */
m_Entries.push_back( LibEntry ); m_Entries.push_back( LibEntry );
LoadAliases( LibEntry ); LoadAliases( LibEntry );
} }
else else
{ {
wxLogWarning( wxT( "Library <%s> component load error %s." ), wxLogWarning( _( "Library <%s> component load error %s." ),
(const wxChar*) m_Name, (const wxChar*) m_fileName.GetName(),
(const wxChar*) msg ); (const wxChar*) msg );
msg.Clear(); msg.Clear();
delete LibEntry; delete LibEntry;
...@@ -506,24 +581,29 @@ bool LibraryStruct::Load( wxString& errMsg ) ...@@ -506,24 +581,29 @@ bool LibraryStruct::Load( wxString& errMsg )
} }
void LibraryStruct::LoadAliases( EDA_LibComponentStruct* component ) void CMP_LIBRARY::LoadAliases( LIB_COMPONENT* component )
{ {
wxASSERT( component != NULL ); wxASSERT( component != NULL && component->Type == ROOT );
EDA_LibCmpAliasStruct* AliasEntry; LIB_ALIAS* alias;
unsigned ii; unsigned ii;
for( ii = 0; ii < component->m_AliasList.GetCount(); ii++ ) for( ii = 0; ii < component->m_AliasList.GetCount(); ii++ )
{ {
AliasEntry = if( FindEntry( component->m_AliasList[ii] ) != NULL )
new EDA_LibCmpAliasStruct( component->m_AliasList[ii], {
component->GetName() ); wxLogError( duplicate_name_msg,
m_Entries.push_back( AliasEntry ); (const wxChar*) m_fileName.GetName(),
(const wxChar*) component->m_AliasList[ii] );
}
alias = new LIB_ALIAS( component->m_AliasList[ii], component, this );
m_Entries.push_back( alias );
} }
} }
bool LibraryStruct::LoadHeader( FILE* libfile, int* LineNum ) bool CMP_LIBRARY::LoadHeader( FILE* libfile, int* LineNum )
{ {
char Line[1024], * text, * data; char Line[1024], * text, * data;
...@@ -541,16 +621,15 @@ bool LibraryStruct::LoadHeader( FILE* libfile, int* LineNum ) ...@@ -541,16 +621,15 @@ bool LibraryStruct::LoadHeader( FILE* libfile, int* LineNum )
} }
bool LibraryStruct::LoadDocs( wxString& errMsg ) bool CMP_LIBRARY::LoadDocs( wxString& errMsg )
{ {
int LineNum = 0; int LineNum = 0;
char Line[1024], * Name, * Text; char Line[1024], * Name, * Text;
LibCmpEntry* Entry; CMP_LIB_ENTRY* Entry;
FILE* f; FILE* f;
wxString msg; wxString msg;
wxFileName fn; wxFileName fn = m_fileName;
fn = m_FullFileName;
fn.SetExt( DOC_EXT ); fn.SetExt( DOC_EXT );
f = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); f = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
...@@ -627,7 +706,7 @@ document file." ), ...@@ -627,7 +706,7 @@ document file." ),
} }
bool LibraryStruct::Save( const wxString& FullFileName ) bool CMP_LIBRARY::Save( const wxString& FullFileName )
{ {
FILE* libfile, *docfile; FILE* libfile, *docfile;
wxString msg; wxString msg;
...@@ -671,7 +750,8 @@ bool LibraryStruct::Save( const wxString& FullFileName ) ...@@ -671,7 +750,8 @@ bool LibraryStruct::Save( const wxString& FullFileName )
if( libfile == NULL ) if( libfile == NULL )
{ {
msg = wxT( "Failed to create Lib File " ) + libFileName.GetFullPath(); msg = wxT( "Failed to create component library file " ) +
libFileName.GetFullPath();
DisplayError( NULL, msg ); DisplayError( NULL, msg );
return false; return false;
} }
...@@ -680,7 +760,7 @@ bool LibraryStruct::Save( const wxString& FullFileName ) ...@@ -680,7 +760,7 @@ bool LibraryStruct::Save( const wxString& FullFileName )
if( docfile == NULL ) if( docfile == NULL )
{ {
msg = wxT( "Failed to create DocLib File " ) + msg = wxT( "Failed to create component document library file " ) +
docFileName.GetFullPath(); docFileName.GetFullPath();
DisplayError( NULL, msg ); DisplayError( NULL, msg );
} }
...@@ -698,12 +778,11 @@ bool LibraryStruct::Save( const wxString& FullFileName ) ...@@ -698,12 +778,11 @@ bool LibraryStruct::Save( const wxString& FullFileName )
bool success = true; bool success = true;
BOOST_FOREACH( LibCmpEntry& entry, m_Entries ) BOOST_FOREACH( CMP_LIB_ENTRY& entry, m_Entries )
{ {
if ( entry.Type == ROOT ) if ( entry.Type == ROOT )
{ {
EDA_LibComponentStruct* component = LIB_COMPONENT* component = ( LIB_COMPONENT* ) &entry;
( EDA_LibComponentStruct* ) &entry;
if ( ! component->Save( libfile ) ) if ( ! component->Save( libfile ) )
success = false; success = false;
} }
...@@ -723,7 +802,7 @@ bool LibraryStruct::Save( const wxString& FullFileName ) ...@@ -723,7 +802,7 @@ bool LibraryStruct::Save( const wxString& FullFileName )
} }
bool LibraryStruct::SaveHeader( FILE* file ) bool CMP_LIBRARY::SaveHeader( FILE* file )
{ {
char BufLine[1024]; char BufLine[1024];
bool succes = false; bool succes = false;
...@@ -743,7 +822,180 @@ bool LibraryStruct::SaveHeader( FILE* file ) ...@@ -743,7 +822,180 @@ bool LibraryStruct::SaveHeader( FILE* file )
} }
wxString LibraryStruct::GetName() /*
* The static library list and list management methods.
*/
CMP_LIBRARY_LIST CMP_LIBRARY::m_LibraryList;
wxArrayString CMP_LIBRARY::m_LibraryListSortOrder;
CMP_LIBRARY* CMP_LIBRARY::LoadLibrary( const wxFileName& fileName,
wxString& errMsg )
{
CMP_LIBRARY* lib = NULL;
lib = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, fileName );
wxBusyCursor ShowWait;
if( !lib->Load( errMsg ) )
{
delete lib;
return NULL;
}
lib->LoadDocs( errMsg );
return lib;
}
bool CMP_LIBRARY::AddLibrary( const wxFileName& fileName, wxString& errMsg )
{ {
return m_Name; CMP_LIBRARY* lib;
/* Don't reload the library if it is already loaded. */
lib = FindLibrary( fileName.GetName() );
if( lib != NULL )
return true;
lib = LoadLibrary( fileName, errMsg );
if( lib == NULL )
return false;
m_LibraryList.push_back( lib );
return true;
}
bool CMP_LIBRARY::AddLibrary( const wxFileName& fileName, wxString& errMsg,
CMP_LIBRARY_LIST::iterator& i )
{
CMP_LIBRARY* lib;
/* Don't reload the library if it is already loaded. */
lib = FindLibrary( fileName.GetName() );
if( lib != NULL )
return true;
lib = LoadLibrary( fileName, errMsg );
if( lib == NULL )
return false;
if( i >= m_LibraryList.begin() && i < m_LibraryList.end() )
m_LibraryList.insert( i, lib );
else
m_LibraryList.push_back( lib );
return true;
}
void CMP_LIBRARY::RemoveLibrary( const wxString& name )
{
if( name.IsEmpty() )
return;
CMP_LIBRARY_LIST::iterator i;
for ( i = m_LibraryList.begin(); i < m_LibraryList.end(); i++ )
{
if( i->GetName().CmpNoCase( name ) == 0 )
{
CMP_LIBRARY::m_LibraryList.erase( i );
return;
}
}
}
CMP_LIBRARY* CMP_LIBRARY::FindLibrary( const wxString& name )
{
BOOST_FOREACH( CMP_LIBRARY& lib, m_LibraryList )
{
if( lib == name )
return &lib;
}
return NULL;
}
wxArrayString CMP_LIBRARY::GetLibraryNames( bool sorted )
{
wxString cacheName;
wxArrayString names;
BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::m_LibraryList )
{
if( lib.m_IsCache && sorted )
cacheName = lib.GetName();
else
names.Add( lib.GetName() );
}
/* Even sorted, the cache library is always at the end of the list. */
if( sorted )
names.Sort();
if( !cacheName.IsEmpty() )
names.Add( cacheName );
return names;
}
LIB_COMPONENT* CMP_LIBRARY::FindLibraryComponent( const wxString& name,
const wxString& libName )
{
LIB_COMPONENT* component = NULL;
BOOST_FOREACH( CMP_LIBRARY& lib, m_LibraryList )
{
if( !libName.IsEmpty() && lib.GetName() != libName )
continue;
component = lib.FindComponent( name );
if( component != NULL )
break;
}
return component;
}
CMP_LIB_ENTRY* CMP_LIBRARY::FindLibraryEntry( const wxString& name,
const wxString& libName )
{
CMP_LIB_ENTRY* entry = NULL;
BOOST_FOREACH( CMP_LIBRARY& lib, m_LibraryList )
{
if( !libName.IsEmpty() && lib.GetName() != libName )
continue;
entry = lib.FindEntry( name );
if( entry != NULL )
break;
}
return entry;
}
void CMP_LIBRARY::RemoveCacheLibrary( void )
{
CMP_LIBRARY_LIST::iterator i;
for ( i = m_LibraryList.begin(); i < m_LibraryList.end(); i++ )
{
if( i->m_IsCache )
m_LibraryList.erase( i-- );
}
} }
...@@ -9,6 +9,14 @@ ...@@ -9,6 +9,14 @@
#include "class_libentry.h" #include "class_libentry.h"
/* Helpers for creating a list of component libraries. */
class CMP_LIBRARY;
typedef boost::ptr_vector< CMP_LIBRARY > CMP_LIBRARY_LIST;
extern bool operator<( const CMP_LIBRARY& item1, const CMP_LIBRARY& item2 );
/** /**
* Component library object. * Component library object.
* *
...@@ -16,22 +24,21 @@ ...@@ -16,22 +24,21 @@
* component library files. * component library files.
*/ */
class LibraryStruct class CMP_LIBRARY
{ {
public: public:
int m_Type; /* type indicator */ int m_Type; /* type indicator */
wxString m_Name; /* Library file name (without path). */
wxString m_FullFileName; /* Full File Name (with path) of library. */
wxString m_Header; /* first line of loaded library. */ wxString m_Header; /* first line of loaded library. */
LibraryStruct* m_Pnext; /* Point on next lib in chain. */
unsigned long m_TimeStamp; // Signature temporelle unsigned long m_TimeStamp; // Signature temporelle
int m_Flags; // variable used in some functions int m_Flags; // variable used in some functions
bool m_IsLibCache; /* False for the "standard" libraries,
* True for the library cache */
public: public:
LibraryStruct( int type, const wxString& name, const wxString& fullname ); CMP_LIBRARY( int type, const wxFileName& fullname );
~LibraryStruct(); CMP_LIBRARY( int type, const wxString& fullname )
{
CMP_LIBRARY( type, wxFileName( fullname ) );
}
~CMP_LIBRARY();
/** /**
* Save library to file. * Save library to file.
...@@ -63,19 +70,17 @@ private: ...@@ -63,19 +70,17 @@ private:
bool SaveHeader( FILE* file ); bool SaveHeader( FILE* file );
bool LoadHeader( FILE* file, int* LineNum ); bool LoadHeader( FILE* file, int* LineNum );
void LoadAliases( EDA_LibComponentStruct* component ); void LoadAliases( LIB_COMPONENT* component );
void RemoveEntry( const wxString& name ); void RemoveEntry( const wxString& name );
public: public:
LibraryStruct( const wxChar* fileName = NULL );
/** /**
* Get library entry status. * Get library entry status.
* *
* @return true if there are no entries in the library. * @return true if there are no entries in the library.
*/ */
bool IsEmpty() bool IsEmpty() const
{ {
return m_Entries.empty(); return m_Entries.empty();
} }
...@@ -85,16 +90,26 @@ public: ...@@ -85,16 +90,26 @@ public:
* *
* @return The number of component and alias entries. * @return The number of component and alias entries.
*/ */
int GetCount() int GetCount() const
{ {
return m_Entries.size(); return m_Entries.size();
} }
bool IsModified() bool IsModified() const
{ {
return m_IsModified; return m_IsModified;
} }
bool IsCache() const { return m_IsCache; }
void SetModified( void ) { m_IsModified = true; }
void SetCache( void ) { m_IsCache = true; }
/** /**
* Load a string array with the names of all the entries in this library. * Load a string array with the names of all the entries in this library.
* *
...@@ -132,7 +147,7 @@ public: ...@@ -132,7 +147,7 @@ public:
* *
* @return Pointer to entry if found. NULL if not found. * @return Pointer to entry if found. NULL if not found.
*/ */
LibCmpEntry* FindEntry( const wxChar* name ); CMP_LIB_ENTRY* FindEntry( const wxChar* name );
/** /**
* Find entry by name and type. * Find entry by name and type.
...@@ -142,13 +157,13 @@ public: ...@@ -142,13 +157,13 @@ public:
* *
* @return Pointer to entry if found. NULL if not found. * @return Pointer to entry if found. NULL if not found.
*/ */
LibCmpEntry* FindEntry( const wxChar* name, LibrEntryType type ); CMP_LIB_ENTRY* FindEntry( const wxChar* name, LibrEntryType type );
/** /**
* Find component by name. * Find component by name.
* *
* This is a helper for FindEntry so casting a LibCmpEntry pointer to * This is a helper for FindEntry so casting a CMP_LIB_ENTRY pointer to
* a EDA_LibComponentStruct pointer is not required. * a LIB_COMPONENT pointer is not required.
* *
* @param name - Name of component, case insensitive. * @param name - Name of component, case insensitive.
* @param searchAliases - Searches for component by alias name as well as * @param searchAliases - Searches for component by alias name as well as
...@@ -156,22 +171,21 @@ public: ...@@ -156,22 +171,21 @@ public:
* *
* @return Pointer to component if found. NULL if not found. * @return Pointer to component if found. NULL if not found.
*/ */
EDA_LibComponentStruct* FindComponent( const wxChar* name, LIB_COMPONENT* FindComponent( const wxChar* name );
bool searchAliases = true );
/** /**
* Find alias by name. * Find alias by name.
* *
* This is a helper for FindEntry so casting a LibCmpEntry pointer to * This is a helper for FindEntry so casting a CMP_LIB_ENTRY pointer to
* a EDA_LibCmpAliasStruct pointer is not required. * a LIB_ALIAS pointer is not required.
* *
* @param name - Name of alias, case insensitive. * @param name - Name of alias, case insensitive.
* *
* @return Pointer to alias if found. NULL if not found. * @return Pointer to alias if found. NULL if not found.
*/ */
EDA_LibCmpAliasStruct* FindAlias( const wxChar* name ) LIB_ALIAS* FindAlias( const wxChar* name )
{ {
return (EDA_LibCmpAliasStruct*) FindEntry( name, ALIAS ); return (LIB_ALIAS*) FindEntry( name, ALIAS );
} }
/** /**
...@@ -188,7 +202,7 @@ public: ...@@ -188,7 +202,7 @@ public:
* @return bool - True if alias added to library. False if conflict * @return bool - True if alias added to library. False if conflict
* exists. * exists.
*/ */
bool AddAlias( EDA_LibCmpAliasStruct* alias ); bool AddAlias( LIB_ALIAS* alias );
/** /**
* Add component entry to library. * Add component entry to library.
...@@ -197,7 +211,7 @@ public: ...@@ -197,7 +211,7 @@ public:
* *
* @return Pointer to added component if successful. * @return Pointer to added component if successful.
*/ */
EDA_LibComponentStruct* AddComponent( EDA_LibComponentStruct* cmp ); LIB_COMPONENT* AddComponent( LIB_COMPONENT* cmp );
/** /**
* Remove an entry from the library. * Remove an entry from the library.
...@@ -211,7 +225,7 @@ public: ...@@ -211,7 +225,7 @@ public:
* *
* @param entry - Entry to remove from library. * @param entry - Entry to remove from library.
*/ */
void RemoveEntry( LibCmpEntry* entry ); void RemoveEntry( CMP_LIB_ENTRY* entry );
/** /**
* Replace an existing component entry in the library. * Replace an existing component entry in the library.
...@@ -219,16 +233,15 @@ public: ...@@ -219,16 +233,15 @@ public:
* @param oldComponent - The component to replace. * @param oldComponent - The component to replace.
* @param newComponent - The new component. * @param newComponent - The new component.
*/ */
EDA_LibComponentStruct* ReplaceComponent( LIB_COMPONENT* ReplaceComponent( LIB_COMPONENT* oldComponent,
EDA_LibComponentStruct* oldComponent, LIB_COMPONENT* newComponent );
EDA_LibComponentStruct* newComponent );
/** /**
* 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.
*/ */
LibCmpEntry* GetFirstEntry() CMP_LIB_ENTRY* GetFirstEntry()
{ {
return &m_Entries.front(); return &m_Entries.front();
} }
...@@ -241,10 +254,10 @@ public: ...@@ -241,10 +254,10 @@ public:
* *
* @param name - Name of current entry. * @param name - Name of current entry.
* *
* @return LibCmpEntry - Pointer to next entry if entry name is found. * @return CMP_LIB_ENTRY - Pointer to next entry if entry name is found.
* Otherwise NULL. * Otherwise NULL.
*/ */
LibCmpEntry* GetNextEntry( const wxChar* name ); CMP_LIB_ENTRY* GetNextEntry( const wxChar* name );
/** /**
...@@ -255,28 +268,175 @@ public: ...@@ -255,28 +268,175 @@ public:
* *
* @param name - Name of current entry. * @param name - Name of current entry.
* *
* @return LibCmpEntry - Pointer to previous entry if entry name is found. * @return CMP_LIB_ENTRY - Pointer to previous entry if entry name is found.
* Otherwise NULL.
*/
CMP_LIB_ENTRY* GetPreviousEntry( const wxChar* name );
/**
* Return the file name without path or extension.
*
* @return wxString - Name of library file.
*/
wxString GetName() const { return m_fileName.GetName(); }
/**
* Return the full file library name with path and extension.
*
* @return wxString - Full library file name with path and extension.
*/
wxString GetFullFileName() { return m_fileName.GetFullPath(); }
/**
* Set the component library file name.
*
* @param fileName - New library file name.
*/
void SetFileName( const wxFileName fileName )
{
if( fileName != m_fileName )
m_fileName = fileName;
}
/*
* The following static methods are for manipulating the list of
* component libraries. This eliminates the need for yet another
* global variable ( formerly g_LibraryList ) and gives some measure
* of safety from abusing the library list.
*/
/**
* Load a component library file.
*
* @param fileName - File name of the component library to load.
* @param errMsg - Error message if the component library failed to load.
*
* @return Pointer to library object if library file loaded successfully.
* Otherwise NULL. * Otherwise NULL.
*/ */
LibCmpEntry* GetPreviousEntry( const wxChar* name ); static CMP_LIBRARY* LoadLibrary( const wxFileName& fileName,
wxString& errMsg );
wxString GetName(); /**
* Add a compnent library to the library list.
*
* @param fileName - File name object of component library.
* @param errMsg - Error message if the component library failed to load.
*
* @return bool - True if library loaded properly otherwise false.
*/
static bool AddLibrary( const wxFileName& fileName, wxString& errMsg );
/**
* Insert a compnent library to the library list.
*
* @param fileName - File name object of component library.
* @param errMsg - Error message if the component library failed to load.
* @param i - Iterator to insert library in front of.
*
* @return bool - True if library loaded properly otherwise false.
*/
static bool AddLibrary( const wxFileName& fileName, wxString& errMsg,
CMP_LIBRARY_LIST::iterator& i );
/**
* Remove component library from the library list.
*
* @param name - Name of component library to remove.
*/
static void RemoveLibrary( const wxString& name );
/**
* Find component library by name.
*
* @param name - Library file name without path or extension to find.
*
* @return CMP_LIBRARY* - Pointer to component library if found,
* otherwise NULL.
*/
static CMP_LIBRARY* FindLibrary( const wxString& name );
/**
* Get the list of component library file names without path and extension.
*
* @param sorted - Sort the list of name if true. Otherwise use the
* library load order.
*
* @return wxArrayString - The list of library names.
*/
static wxArrayString GetLibraryNames( bool sorted = true );
/**
* Search all libraries in the list for a component.
*
* A component object will always be returned. If the entry found
* is an alias. The root component will be found and returned.
*
* @param name - Name of component to search for.
* @param libNaem - Name of the library to search for component.
*
* @return Pointer to a valid component object if found. Otherwise NULL.
*/
static LIB_COMPONENT* FindLibraryComponent(
const wxString& name, const wxString& libName = wxEmptyString );
/**
* Search all libraries in the list for an entry.
*
* The object can be either a component or an alias.
*
* @param name - Name of component to search for.
* @param libNaem - Name of the library to search for entry.
*
* @return Pointer to a valid entry object if found. Otherwise NULL.
*/
static CMP_LIB_ENTRY* FindLibraryEntry(
const wxString& name,
const wxString& libName = wxEmptyString );
/**
* Remove all cache libraries from library list.
*/
static void RemoveCacheLibrary( void );
static int GetLibraryCount( void ) { return m_LibraryList.size(); }
static CMP_LIBRARY_LIST& GetLibraryList( void )
{
return m_LibraryList;
}
static void SetSortOrder( const wxArrayString& sortOrder )
{
m_LibraryListSortOrder = sortOrder;
}
static wxArrayString& GetSortOrder( void )
{
return m_LibraryListSortOrder;
}
protected: protected:
wxFileName m_fileName; /* Library file name. */ wxFileName m_fileName; /* Library file name. */
wxDateTime m_DateTime; /* Library save time and date. */ wxDateTime m_DateTime; /* Library save time and date. */
wxString m_Version; /* Library save version. */ int m_verMajor; /* Library major version number. */
int m_verMinor; /* Library minor version number. */
LIB_ENTRY_LIST m_Entries; /* Parts themselves are saved here. */ LIB_ENTRY_LIST m_Entries; /* Parts themselves are saved here. */
bool m_IsModified; /* Library modification status. */ bool m_IsModified; /* Library modification status. */
bool m_IsCache; /* False for the "standard" libraries,
* True for the library cache */
static CMP_LIBRARY_LIST m_LibraryList;
static wxArrayString m_LibraryListSortOrder;
friend class EDA_LibComponentStruct; friend class CMP_LIB_ENTRY;
}; };
/** /**
* Case insensitive library name comparison. * Case insensitive library name comparison.
*/ */
extern bool operator==( const LibraryStruct& lib, const wxChar* name ); extern bool operator==( const CMP_LIBRARY& lib, const wxChar* name );
extern bool operator!=( const LibraryStruct& lib, const wxChar* name ); extern bool operator!=( const CMP_LIBRARY& lib, const wxChar* name );
#endif // CLASS_LIBRARY_H #endif // CLASS_LIBRARY_H
...@@ -30,7 +30,7 @@ const wxChar* MsgPinElectricType[] = ...@@ -30,7 +30,7 @@ const wxChar* MsgPinElectricType[] =
wxT( "?????" ) wxT( "?????" )
}; };
LibDrawPin::LibDrawPin(EDA_LibComponentStruct * aParent) : LibDrawPin::LibDrawPin(LIB_COMPONENT * aParent) :
LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE, aParent ) LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE, aParent )
{ {
m_PinLen = 300; /* default Pin len */ m_PinLen = 300; /* default Pin len */
...@@ -324,7 +324,7 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel, ...@@ -324,7 +324,7 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
return; return;
} }
EDA_LibComponentStruct* Entry = GetParent(); LIB_COMPONENT* Entry = GetParent();
bool DrawPinText = true; bool DrawPinText = true;
if( ( aData != NULL ) && ( (bool*) aData == false ) ) if( ( aData != NULL ) && ( (bool*) aData == false ) )
......
...@@ -405,7 +405,7 @@ bool SCH_CMP_FIELD::Save( FILE* aFile ) const ...@@ -405,7 +405,7 @@ bool SCH_CMP_FIELD::Save( FILE* aFile ) const
void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
{ {
int fieldNdx; int fieldNdx;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
frame->DrawPanel->ManageCurseur = NULL; frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL; frame->DrawPanel->ForceCloseManageCurseur = NULL;
...@@ -424,7 +424,7 @@ void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -424,7 +424,7 @@ void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
m_AddExtraText = 0; m_AddExtraText = 0;
if( fieldNdx == REFERENCE ) if( fieldNdx == REFERENCE )
{ {
Entry = ( EDA_LibComponentStruct* ) FindLibPart( component->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( component->m_ChipName );
if( Entry != NULL ) if( Entry != NULL )
{ {
if( Entry->m_UnitCount > 1 ) if( Entry->m_UnitCount > 1 )
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
/* Local variables */ /* Local variables */
static EDA_LibComponentStruct* DummyCmp; static LIB_COMPONENT* DummyCmp;
/* Descr component <DUMMY> used when a component is not found in library, /* Descr component <DUMMY> used when a component is not found in library,
* to draw a dummy shape * to draw a dummy shape
...@@ -33,7 +33,7 @@ static EDA_LibComponentStruct* DummyCmp; ...@@ -33,7 +33,7 @@ static EDA_LibComponentStruct* DummyCmp;
*/ */
void CreateDummyCmp() void CreateDummyCmp()
{ {
DummyCmp = new EDA_LibComponentStruct( NULL ); DummyCmp = new LIB_COMPONENT( wxEmptyString );
LibDrawSquare* Square = new LibDrawSquare(DummyCmp); LibDrawSquare* Square = new LibDrawSquare(DummyCmp);
...@@ -58,8 +58,7 @@ void CreateDummyCmp() ...@@ -58,8 +58,7 @@ void CreateDummyCmp()
*****************************************************************************/ *****************************************************************************/
/* DrawMode = GrXOR, GrOR ..*/ /* DrawMode = GrXOR, GrOR ..*/
void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC, void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_COMPONENT* Component, SCH_COMPONENT* Component, LIB_COMPONENT* Entry,
EDA_LibComponentStruct* Entry,
const wxPoint& Pos, const int TransMat[2][2], const wxPoint& Pos, const int TransMat[2][2],
int Multi, int convert, int DrawMode, int Multi, int convert, int DrawMode,
int Color, bool DrawPinText ) int Color, bool DrawPinText )
...@@ -165,11 +164,11 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) : ...@@ -165,11 +164,11 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) :
void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color ) const wxPoint& offset, int DrawMode, int Color )
{ {
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
int ii; int ii;
bool dummy = FALSE; bool dummy = FALSE;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
{ {
...@@ -477,8 +476,7 @@ void SCH_COMPONENT::AddField( const SCH_CMP_FIELD& aField ) ...@@ -477,8 +476,7 @@ void SCH_COMPONENT::AddField( const SCH_CMP_FIELD& aField )
EDA_Rect SCH_COMPONENT::GetBoundaryBox() const EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
{ {
EDA_LibComponentStruct* Entry = LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
( EDA_LibComponentStruct* ) FindLibPart( m_ChipName );
EDA_Rect BoundaryBox; EDA_Rect BoundaryBox;
int x0, xm, y0, ym; int x0, xm, y0, ym;
...@@ -589,11 +587,11 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet ) ...@@ -589,11 +587,11 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet )
{ {
wxString defRef = m_PrefixString; wxString defRef = m_PrefixString;
bool KeepMulti = false; bool KeepMulti = false;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
wxString separators( wxT( " " ) ); wxString separators( wxT( " " ) );
wxArrayString reference_fields; wxArrayString reference_fields;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( Entry && Entry->m_UnitSelectionLocked ) if( Entry && Entry->m_UnitSelectionLocked )
KeepMulti = true; KeepMulti = true;
...@@ -1025,8 +1023,7 @@ EDA_Rect SCH_COMPONENT::GetBoundingBox() ...@@ -1025,8 +1023,7 @@ EDA_Rect SCH_COMPONENT::GetBoundingBox()
void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
EDA_LibComponentStruct* Entry = LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
( EDA_LibComponentStruct* ) FindLibPart( m_ChipName );
wxString msg; wxString msg;
...@@ -1045,7 +1042,8 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1045,7 +1042,8 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
Affiche_1_Parametre( frame, 28, _( "RefLib" ), m_ChipName.GetData(), BROWN ); Affiche_1_Parametre( frame, 28, _( "RefLib" ), m_ChipName.GetData(), BROWN );
msg = FindLibName; msg = Entry->GetLibraryName();
Affiche_1_Parametre( frame, 40, _( "Lib" ), msg, DARKRED ); Affiche_1_Parametre( frame, 40, _( "Lib" ), msg, DARKRED );
if( Entry ) if( Entry )
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
extern void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC, extern void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_COMPONENT* Component, SCH_COMPONENT* Component, LIB_COMPONENT* Entry,
EDA_LibComponentStruct* Entry,
const wxPoint& Pos, const int TransMat[2][2], const wxPoint& Pos, const int TransMat[2][2],
int Multi, int convert, int DrawMode, int Multi, int convert, int DrawMode,
int Color = -1, bool DrawPinText = TRUE ); int Color = -1, bool DrawPinText = TRUE );
......
...@@ -23,7 +23,7 @@ static int fill_tab[3] = { 'N', 'F', 'f' }; ...@@ -23,7 +23,7 @@ static int fill_tab[3] = { 'N', 'F', 'f' };
/* Base class (abstract) for components bodies items */ /* Base class (abstract) for components bodies items */
LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type, LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type,
EDA_LibComponentStruct* aParent ) : LIB_COMPONENT* aParent ) :
EDA_BaseStruct( struct_type ) EDA_BaseStruct( struct_type )
{ {
m_Unit = 0; /* Unit identification (for multi part per package) m_Unit = 0; /* Unit identification (for multi part per package)
...@@ -83,7 +83,7 @@ bool LibEDA_BaseStruct::operator==( const LibEDA_BaseStruct& other ) const ...@@ -83,7 +83,7 @@ bool LibEDA_BaseStruct::operator==( const LibEDA_BaseStruct& other ) const
/** class LibDrawArc **/ /** class LibDrawArc **/
/**********************/ /**********************/
LibDrawArc::LibDrawArc( EDA_LibComponentStruct* aParent ) : LibDrawArc::LibDrawArc( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_ARC_DRAW_TYPE, aParent ) LibEDA_BaseStruct( COMPONENT_ARC_DRAW_TYPE, aParent )
{ {
m_Radius = 0; m_Radius = 0;
...@@ -437,7 +437,7 @@ void LibDrawArc::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -437,7 +437,7 @@ void LibDrawArc::DisplayInfo( WinEDA_DrawFrame* frame )
/** class LibDrawCircle **/ /** class LibDrawCircle **/
/*************************/ /*************************/
LibDrawCircle::LibDrawCircle( EDA_LibComponentStruct* aParent ) : LibDrawCircle::LibDrawCircle( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_CIRCLE_DRAW_TYPE, aParent ) LibEDA_BaseStruct( COMPONENT_CIRCLE_DRAW_TYPE, aParent )
{ {
m_Radius = 0; m_Radius = 0;
...@@ -645,7 +645,7 @@ void LibDrawCircle::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -645,7 +645,7 @@ void LibDrawCircle::DisplayInfo( WinEDA_DrawFrame* frame )
/** class LibDrawSquare **/ /** class LibDrawSquare **/
/*************************/ /*************************/
LibDrawSquare::LibDrawSquare( EDA_LibComponentStruct* aParent ) : LibDrawSquare::LibDrawSquare( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_RECT_DRAW_TYPE, aParent ) LibEDA_BaseStruct( COMPONENT_RECT_DRAW_TYPE, aParent )
{ {
m_Width = 0; m_Width = 0;
...@@ -863,7 +863,7 @@ bool LibDrawSquare::HitTest( wxPoint aRefPoint, int aThreshold, ...@@ -863,7 +863,7 @@ bool LibDrawSquare::HitTest( wxPoint aRefPoint, int aThreshold,
/**************************/ /**************************/
/** class LibDrawSegment **/ /** class LibDrawSegment **/
/**************************/ /**************************/
LibDrawSegment::LibDrawSegment( EDA_LibComponentStruct* aParent ) : LibDrawSegment::LibDrawSegment( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_LINE_DRAW_TYPE, aParent ) LibEDA_BaseStruct( COMPONENT_LINE_DRAW_TYPE, aParent )
{ {
m_Width = 0; m_Width = 0;
...@@ -1015,7 +1015,7 @@ bool LibDrawSegment::HitTest( wxPoint aPosRef, int aThreshold, ...@@ -1015,7 +1015,7 @@ bool LibDrawSegment::HitTest( wxPoint aPosRef, int aThreshold,
/***************************/ /***************************/
/** class LibDrawPolyline **/ /** class LibDrawPolyline **/
/***************************/ /***************************/
LibDrawPolyline::LibDrawPolyline( EDA_LibComponentStruct* aParent ) : LibDrawPolyline::LibDrawPolyline( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE, aParent ) LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE, aParent )
{ {
m_Fill = NO_FILL; m_Fill = NO_FILL;
...@@ -1320,7 +1320,7 @@ void LibDrawPolyline::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -1320,7 +1320,7 @@ void LibDrawPolyline::DisplayInfo( WinEDA_DrawFrame* frame )
/***************************/ /***************************/
/** class LibDrawBezier **/ /** class LibDrawBezier **/
/***************************/ /***************************/
LibDrawBezier::LibDrawBezier( EDA_LibComponentStruct* aParent ) : LibDrawBezier::LibDrawBezier( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_BEZIER_DRAW_TYPE, aParent ) LibEDA_BaseStruct( COMPONENT_BEZIER_DRAW_TYPE, aParent )
{ {
m_Fill = NO_FILL; m_Fill = NO_FILL;
......
...@@ -105,7 +105,7 @@ public: ...@@ -105,7 +105,7 @@ public:
} }
LibEDA_BaseStruct( KICAD_T struct_type, EDA_LibComponentStruct * aParent ); LibEDA_BaseStruct( KICAD_T struct_type, LIB_COMPONENT * aParent );
virtual ~LibEDA_BaseStruct() { } virtual ~LibEDA_BaseStruct() { }
/** Function Draw (virtual pure) /** Function Draw (virtual pure)
...@@ -143,9 +143,9 @@ public: ...@@ -143,9 +143,9 @@ public:
virtual bool Save( FILE* aFile ) const = 0; virtual bool Save( FILE* aFile ) const = 0;
virtual bool Load( char* line, wxString& errorMsg ) = 0; virtual bool Load( char* line, wxString& errorMsg ) = 0;
EDA_LibComponentStruct * GetParent() LIB_COMPONENT * GetParent()
{ {
return (EDA_LibComponentStruct *)m_Parent; return (LIB_COMPONENT *)m_Parent;
} }
/** /**
...@@ -266,7 +266,7 @@ public: ...@@ -266,7 +266,7 @@ public:
int m_Width; /* Line width */ int m_Width; /* Line width */
public: public:
LibDrawPin(EDA_LibComponentStruct * aParent); LibDrawPin(LIB_COMPONENT * aParent);
~LibDrawPin() { } ~LibDrawPin() { }
LibDrawPin* Next() const { return (LibDrawPin*) Pnext; } LibDrawPin* Next() const { return (LibDrawPin*) Pnext; }
...@@ -382,7 +382,7 @@ public: ...@@ -382,7 +382,7 @@ public:
int m_Width; /* Line width */ int m_Width; /* Line width */
public: public:
LibDrawArc(EDA_LibComponentStruct * aParent); LibDrawArc(LIB_COMPONENT * aParent);
~LibDrawArc() { } ~LibDrawArc() { }
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -449,7 +449,7 @@ public: ...@@ -449,7 +449,7 @@ public:
int m_Width; /* Line width */ int m_Width; /* Line width */
public: public:
LibDrawCircle(EDA_LibComponentStruct * aParent); LibDrawCircle(LIB_COMPONENT * aParent);
~LibDrawCircle() { } ~LibDrawCircle() { }
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -514,7 +514,7 @@ protected: ...@@ -514,7 +514,7 @@ protected:
class LibDrawText : public LibEDA_BaseStruct, public EDA_TextStruct class LibDrawText : public LibEDA_BaseStruct, public EDA_TextStruct
{ {
public: public:
LibDrawText(EDA_LibComponentStruct * aParent); LibDrawText(LIB_COMPONENT * aParent);
~LibDrawText() { } ~LibDrawText() { }
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -591,7 +591,7 @@ public: ...@@ -591,7 +591,7 @@ public:
int m_Width; /* Line width */ int m_Width; /* Line width */
public: public:
LibDrawSquare(EDA_LibComponentStruct * aParent); LibDrawSquare(LIB_COMPONENT * aParent);
~LibDrawSquare() { } ~LibDrawSquare() { }
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -658,7 +658,7 @@ public: ...@@ -658,7 +658,7 @@ public:
int m_Width; /* Line width */ int m_Width; /* Line width */
public: public:
LibDrawSegment(EDA_LibComponentStruct * aParent); LibDrawSegment(LIB_COMPONENT * aParent);
~LibDrawSegment() { } ~LibDrawSegment() { }
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -723,7 +723,7 @@ public: ...@@ -723,7 +723,7 @@ public:
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2) std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
public: public:
LibDrawPolyline(EDA_LibComponentStruct * aParent); LibDrawPolyline(LIB_COMPONENT * aParent);
~LibDrawPolyline() { } ~LibDrawPolyline() { }
virtual wxString GetClass() const virtual wxString GetClass() const
...@@ -800,7 +800,7 @@ public: ...@@ -800,7 +800,7 @@ public:
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2) std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
public: public:
LibDrawBezier(EDA_LibComponentStruct * aParent); LibDrawBezier(LIB_COMPONENT * aParent);
~LibDrawBezier() { } ~LibDrawBezier() { }
virtual wxString GetClass() const virtual wxString GetClass() const
......
...@@ -387,8 +387,8 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ) ...@@ -387,8 +387,8 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
{ {
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_COMPONENT*) DrawItem ) #define STRUCT ( (SCH_COMPONENT*) DrawItem )
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( STRUCT->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( STRUCT->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
break; break;
......
...@@ -15,9 +15,10 @@ ...@@ -15,9 +15,10 @@
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include <boost/foreach.hpp>
/* /*
* Routine de selection du nom d'un composant en librairie pour chargement, * Routine de selection du nom d'un composant en librairie pour chargement,
...@@ -34,7 +35,6 @@ ...@@ -34,7 +35,6 @@
wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys, wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
wxString& BufName ) wxString& BufName )
{ {
LibraryStruct* Lib;
wxArrayString nameList; wxArrayString nameList;
wxString msg; wxString msg;
...@@ -42,9 +42,9 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys, ...@@ -42,9 +42,9 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
Keys.MakeUpper(); Keys.MakeUpper();
/* Examen de la liste des librairies pour comptage */ /* Examen de la liste des librairies pour comptage */
for( Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext ) BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
{ {
Lib->SearchEntryNames( nameList, BufName, Keys ); lib.SearchEntryNames( nameList, BufName, Keys );
} }
if( nameList.IsEmpty() ) if( nameList.IsEmpty() )
...@@ -77,14 +77,9 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys, ...@@ -77,14 +77,9 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
void DisplayCmpDoc( wxString& Name ) void DisplayCmpDoc( wxString& Name )
{ {
LibCmpEntry* CmpEntry = NULL; CMP_LIB_ENTRY* CmpEntry = NULL;
LibraryStruct* Lib = g_LibraryList;
while( Lib != NULL && CmpEntry == NULL ) CmpEntry = CMP_LIBRARY::FindLibraryEntry( Name );
{
CmpEntry = Lib->FindEntry( Name );
Lib = Lib->m_Pnext;
}
if( CmpEntry == NULL ) if( CmpEntry == NULL )
return; return;
......
...@@ -101,7 +101,7 @@ bool WinEDA_CreateCmpDialog::Create( WinEDA_DrawFrame* parent, wxWindowID id, co ...@@ -101,7 +101,7 @@ bool WinEDA_CreateCmpDialog::Create( WinEDA_DrawFrame* parent, wxWindowID id, co
/**********************************************************************************/ /**********************************************************************************/
void WinEDA_CreateCmpDialog::SetComponentData( EDA_LibComponentStruct & component ) void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component )
/**********************************************************************************/ /**********************************************************************************/
{ {
g_AsDeMorgan = m_AsConvert->GetValue(); g_AsDeMorgan = m_AsConvert->GetValue();
......
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
{ {
return m_CmpName->GetValue(); return m_CmpName->GetValue();
} }
void SetComponentData( EDA_LibComponentStruct & component ); void SetComponentData( LIB_COMPONENT & component );
////@begin WinEDA_CreateCmpDialog event handler declarations ////@begin WinEDA_CreateCmpDialog event handler declarations
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
......
...@@ -171,7 +171,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions() ...@@ -171,7 +171,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
else if( newname.CmpNoCase( m_Cmp->m_ChipName ) ) else if( newname.CmpNoCase( m_Cmp->m_ChipName ) )
{ {
if( FindLibPart( newname, wxEmptyString, ALIAS ) == NULL ) if( CMP_LIBRARY::FindLibraryEntry( newname ) == NULL )
{ {
wxString message; wxString message;
message.Printf( _( "Component [%s] not found!" ), newname.GetData() ); message.Printf( _( "Component [%s] not found!" ), newname.GetData() );
...@@ -263,8 +263,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event ...@@ -263,8 +263,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
++i; ++i;
} }
EDA_LibComponentStruct* entry = LIB_COMPONENT* entry =
( EDA_LibComponentStruct* ) FindLibPart( m_Cmp->m_ChipName ); CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName );
if( entry && entry->m_Options == ENTRY_POWER ) if( entry && entry->m_Options == ENTRY_POWER )
m_FieldsBuf[VALUE].m_Text = m_Cmp->m_ChipName; m_FieldsBuf[VALUE].m_Text = m_Cmp->m_ChipName;
...@@ -411,7 +411,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent ...@@ -411,7 +411,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
{ {
m_Cmp = aComponent; m_Cmp = aComponent;
m_LibEntry = ( EDA_LibComponentStruct* ) FindLibPart( m_Cmp->m_ChipName ); m_LibEntry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName );
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
for( int i = 0; i<aComponent->GetFieldCount(); ++i ) for( int i = 0; i<aComponent->GetFieldCount(); ++i )
...@@ -700,12 +700,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) ...@@ -700,12 +700,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
/* reinitialise components parametres to default values found in lib /* reinitialise components parametres to default values found in lib
*/ */
{ {
EDA_LibComponentStruct* entry; LIB_COMPONENT* entry;
if( m_Cmp == NULL ) if( m_Cmp == NULL )
return; return;
entry = ( EDA_LibComponentStruct* ) FindLibPart( m_Cmp->m_ChipName ); entry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName );
if( entry == NULL ) if( entry == NULL )
return; return;
......
...@@ -17,7 +17,7 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEM ...@@ -17,7 +17,7 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEM
WinEDA_SchematicFrame* m_Parent; WinEDA_SchematicFrame* m_Parent;
SCH_COMPONENT* m_Cmp; SCH_COMPONENT* m_Cmp;
EDA_LibComponentStruct* m_LibEntry; LIB_COMPONENT* m_LibEntry;
bool m_skipCopyFromPanel; bool m_skipCopyFromPanel;
static int s_SelectedRow; static int s_SelectedRow;
......
...@@ -28,7 +28,7 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN ...@@ -28,7 +28,7 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN
{ {
private: private:
WinEDA_LibeditFrame* m_Parent; WinEDA_LibeditFrame* m_Parent;
EDA_LibComponentStruct* m_LibEntry; LIB_COMPONENT* m_LibEntry;
bool m_skipCopyFromPanel; bool m_skipCopyFromPanel;
/// a copy of the edited component's LibDrawFields /// a copy of the edited component's LibDrawFields
...@@ -36,7 +36,7 @@ private: ...@@ -36,7 +36,7 @@ private:
public: public:
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( WinEDA_LibeditFrame* aParent, DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( WinEDA_LibeditFrame* aParent,
EDA_LibComponentStruct* aLibEntry ); LIB_COMPONENT* aLibEntry );
~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB(); ~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB();
private: private:
...@@ -122,7 +122,7 @@ void WinEDA_LibeditFrame::InstallFieldsEditorDialog( void ) ...@@ -122,7 +122,7 @@ void WinEDA_LibeditFrame::InstallFieldsEditorDialog( void )
/***********************************************************************/ /***********************************************************************/
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB(
WinEDA_LibeditFrame* aParent, WinEDA_LibeditFrame* aParent,
EDA_LibComponentStruct* aLibEntry ) : LIB_COMPONENT* aLibEntry ) :
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent ) DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent )
/***********************************************************************/ /***********************************************************************/
{ {
......
...@@ -161,7 +161,7 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event ) ...@@ -161,7 +161,7 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
m_Parent->m_ComponentLibFiles.Add(m_ListLibr->GetString(ii) ); m_Parent->m_ComponentLibFiles.Add(m_ListLibr->GetString(ii) );
// take new list in account // take new list in account
LoadLibraries( m_Parent ); m_Parent->LoadLibraries();
if( m_Parent->m_ViewlibFrame ) if( m_Parent->m_ViewlibFrame )
m_Parent->m_ViewlibFrame->ReCreateListLib(); m_Parent->m_ViewlibFrame->ReCreateListLib();
} }
......
...@@ -56,7 +56,7 @@ void WinEDA_LibeditFrame::EditComponentProperties() ...@@ -56,7 +56,7 @@ void WinEDA_LibeditFrame::EditComponentProperties()
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc() void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
{ {
LibCmpEntry* entry; CMP_LIB_ENTRY* entry;
if( CurrentLibEntry == NULL ) if( CurrentLibEntry == NULL )
return; return;
...@@ -67,7 +67,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc() ...@@ -67,7 +67,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
} }
else else
{ {
entry = ( LibCmpEntry* ) CurrentLib->FindAlias( CurrentAliasName ); entry = ( CMP_LIB_ENTRY* ) CurrentLib->FindAlias( CurrentAliasName );
if( entry == NULL ) if( entry == NULL )
return; return;
...@@ -138,7 +138,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -138,7 +138,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
/* Update the doc, keyword and doc filename strings */ /* Update the doc, keyword and doc filename strings */
size_t i; size_t i;
int index; int index;
LibCmpEntry* entry; CMP_LIB_ENTRY* entry;
if( CurrentAliasName.IsEmpty() ) if( CurrentAliasName.IsEmpty() )
{ {
...@@ -155,7 +155,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -155,7 +155,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
msg.Printf( _( "Alias <%s> not found for component <%s> in library <%s>." ), msg.Printf( _( "Alias <%s> not found for component <%s> in library <%s>." ),
(const wxChar*) CurrentAliasName, (const wxChar*) CurrentAliasName,
(const wxChar*) CurrentLibEntry->GetName(), (const wxChar*) CurrentLibEntry->GetName(),
(const wxChar*) CurrentLib->m_Name ); (const wxChar*) CurrentLib->GetName() );
wxMessageBox( msg, _( "Component Library Error" ), wxMessageBox( msg, _( "Component Library Error" ),
wxID_OK | wxICON_ERROR, this ); wxID_OK | wxICON_ERROR, this );
} }
...@@ -168,7 +168,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -168,7 +168,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
if( m_PartAliasList->GetStrings() != CurrentLibEntry->m_AliasList ) if( m_PartAliasList->GetStrings() != CurrentLibEntry->m_AliasList )
{ {
EDA_LibCmpAliasStruct* alias; LIB_ALIAS* alias;
wxArrayString aliases = m_PartAliasList->GetStrings(); wxArrayString aliases = m_PartAliasList->GetStrings();
/* Add names not existing in the old alias list. */ /* Add names not existing in the old alias list. */
...@@ -179,8 +179,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -179,8 +179,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
if( index != wxNOT_FOUND ) if( index != wxNOT_FOUND )
continue; continue;
alias = new EDA_LibCmpAliasStruct( aliases[ i ], alias = new LIB_ALIAS( aliases[ i ], CurrentLibEntry );
CurrentLibEntry->GetName() );
if( !CurrentLib->AddAlias( alias ) ) if( !CurrentLib->AddAlias( alias ) )
{ {
delete alias; delete alias;
...@@ -196,7 +196,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -196,7 +196,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
if( index == wxNOT_FOUND ) if( index == wxNOT_FOUND )
continue; continue;
LibCmpEntry* alias = CMP_LIB_ENTRY* alias =
CurrentLib->FindAlias( CurrentLibEntry->m_AliasList[ i ] ); CurrentLib->FindAlias( CurrentLibEntry->m_AliasList[ i ] );
if( alias != NULL ) if( alias != NULL )
CurrentLib->RemoveEntry( alias ); CurrentLib->RemoveEntry( alias );
...@@ -318,7 +318,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED ...@@ -318,7 +318,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
msg.Printf( _( "Alias or component name <%s> already exists in \ msg.Printf( _( "Alias or component name <%s> already exists in \
library <%s>." ), library <%s>." ),
(const wxChar*) aliasname, (const wxChar*) aliasname,
(const wxChar*) CurrentLib->m_Name ); (const wxChar*) CurrentLib->GetName() );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
......
...@@ -27,7 +27,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC ) ...@@ -27,7 +27,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
/* Prepare le deplacement du texte en cours d'edition /* Prepare le deplacement du texte en cours d'edition
*/ */
{ {
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
SetCurrentField( aField ); SetCurrentField( aField );
if( aField == NULL ) if( aField == NULL )
...@@ -68,7 +68,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC ) ...@@ -68,7 +68,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
m_Multiflag = 0; m_Multiflag = 0;
if( aField->m_FieldId == REFERENCE ) if( aField->m_FieldId == REFERENCE )
{ {
Entry = ( EDA_LibComponentStruct* ) FindLibPart( comp->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( comp->m_ChipName );
if( Entry != NULL ) if( Entry != NULL )
{ {
...@@ -91,7 +91,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -91,7 +91,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
/* Edit the field Field (text, size) */ /* Edit the field Field (text, size) */
{ {
int fieldNdx, flag; int fieldNdx, flag;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
if( Field == NULL ) if( Field == NULL )
{ {
...@@ -104,7 +104,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -104,7 +104,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
fieldNdx = Field->m_FieldId; fieldNdx = Field->m_FieldId;
if( fieldNdx == VALUE ) if( fieldNdx == VALUE )
{ {
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Cmp->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
if( Entry && (Entry->m_Options == ENTRY_POWER) ) if( Entry && (Entry->m_Options == ENTRY_POWER) )
{ {
...@@ -119,7 +119,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -119,7 +119,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
flag = 0; flag = 0;
if( fieldNdx == REFERENCE ) if( fieldNdx == REFERENCE )
{ {
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Cmp->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
if( Entry != NULL ) if( Entry != NULL )
{ {
...@@ -249,7 +249,7 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -249,7 +249,7 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
/*********************************************************************************/ /*********************************************************************************/
{ {
int fieldNdx, flag; int fieldNdx, flag;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
if( Field == NULL ) if( Field == NULL )
return; return;
...@@ -262,7 +262,8 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -262,7 +262,8 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
flag = 0; flag = 0;
if( fieldNdx == REFERENCE ) if( fieldNdx == REFERENCE )
{ {
Entry = ( EDA_LibComponentStruct* ) FindLibPart( ( (SCH_COMPONENT*) Field->GetParent() )->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent(
( (SCH_COMPONENT*) Field->GetParent() )->m_ChipName );
if( Entry != NULL ) if( Entry != NULL )
{ {
...@@ -293,13 +294,13 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -293,13 +294,13 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
/**************************************************************************************************/ /**************************************************************************************************/
/* Edit the component text reference*/ /* Edit the component text reference*/
{ {
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
int flag = 0; int flag = 0;
if( Cmp == NULL ) if( Cmp == NULL )
return; return;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Cmp->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
return; return;
...@@ -334,12 +335,12 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC ) ...@@ -334,12 +335,12 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
/* Routine de changement du texte selectionne */ /* Routine de changement du texte selectionne */
{ {
wxString message; wxString message;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
if( Cmp == NULL ) if( Cmp == NULL )
return; return;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Cmp->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
return; return;
...@@ -372,13 +373,13 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -372,13 +373,13 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
/*****************************************************************************************/ /*****************************************************************************************/
{ {
wxString message; wxString message;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
bool wasEmpty = false; bool wasEmpty = false;
if( Cmp == NULL ) if( Cmp == NULL )
return; return;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Cmp->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
return; return;
......
...@@ -233,9 +233,6 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName, ...@@ -233,9 +233,6 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName,
wxFileName fn; wxFileName fn;
bool IsRead = TRUE; bool IsRead = TRUE;
wxArrayString liblist_tmp = m_ComponentLibFiles; wxArrayString liblist_tmp = m_ComponentLibFiles;
WinEDA_SchematicFrame* frame;
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow();
if( CfgFileName.IsEmpty() ) if( CfgFileName.IsEmpty() )
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->m_AssociatedScreen->m_FileName;
...@@ -265,12 +262,8 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName, ...@@ -265,12 +262,8 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName,
if( m_ComponentLibFiles.GetCount() == 0 ) if( m_ComponentLibFiles.GetCount() == 0 )
m_ComponentLibFiles.Add( wxT( "power" ) ); m_ComponentLibFiles.Add( wxT( "power" ) );
if( frame ) SetDrawBgColor( g_DrawBgColor );
{ LoadLibraries();
frame->SetDrawBgColor( g_DrawBgColor );
}
LoadLibraries( frame );
return IsRead; return IsRead;
} }
......
...@@ -10,11 +10,12 @@ ...@@ -10,11 +10,12 @@
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
//#define DRAW_ARC_WITH_ANGLE // Used to select function to draw arcs #include <boost/foreach.hpp>
/* Local functions */ //#define DRAW_ARC_WITH_ANGLE // Used to select function to draw arcs
/***************************************************************************/ /***************************************************************************/
...@@ -40,57 +41,6 @@ wxPoint TransformCoordinate( const int aTransformMatrix[2][2], ...@@ -40,57 +41,6 @@ wxPoint TransformCoordinate( const int aTransformMatrix[2][2],
} }
/*****************************************************************************/
/*
* Routine to find a part in one of the libraries given its name.
* Name = Name of part.
* LibName = Name of Lib; if "": seach in all libs
* Alias = Flag: si flag != 0, retourne un pointeur sur une part ou un alias
* si flag = 0, retourne un pointeur sur une part meme si le nom
* correspond a un alias
* Alias = FIND_ROOT, ou Alias = FIND_ALIAS
*/
/*****************************************************************************/
LibCmpEntry* FindLibPart( const wxChar* Name, const wxString& LibName,
LibrEntryType type )
{
LibCmpEntry* Entry = NULL;
LibraryStruct* Lib = g_LibraryList;
FindLibName.Empty();
while( Lib )
{
if( !LibName.IsEmpty() )
{
if( Lib->m_Name != LibName )
{
Lib = Lib->m_Pnext;
continue;
}
}
if( Lib == NULL )
break;
if( type == ROOT )
Entry = (LibCmpEntry*) Lib->FindComponent( Name );
else
Entry = Lib->FindEntry( Name );
if( Entry != NULL )
{
FindLibName = Lib->m_Name;
break;
}
Lib = Lib->m_Pnext;
}
return Entry;
}
/***************************************************************************** /*****************************************************************************
* Routine to rotate the given angular direction by the given Transformation. * * Routine to rotate the given angular direction by the given Transformation. *
* Input (and output) angles must be as follows: * * Input (and output) angles must be as follows: *
...@@ -162,9 +112,9 @@ bool MapAngles( int* Angle1, int* Angle2, const int TransMat[2][2] ) ...@@ -162,9 +112,9 @@ bool MapAngles( int* Angle1, int* Angle2, const int TransMat[2][2] )
* This routine is applied by the PlaceLibItem routine above. * * This routine is applied by the PlaceLibItem routine above. *
*****************************************************************************/ *****************************************************************************/
void DrawingLibInGhost( WinEDA_DrawPanel* panel, wxDC* DC, void DrawingLibInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
EDA_LibComponentStruct* LibEntry, LIB_COMPONENT* LibEntry, SCH_COMPONENT* DrawLibItem,
SCH_COMPONENT* DrawLibItem, int PartX, int PartY, int PartX, int PartY, int multi, int convert,
int multi, int convert, int Color, bool DrawPinText ) int Color, bool DrawPinText )
{ {
int DrawMode = g_XorMode; int DrawMode = g_XorMode;
......
...@@ -3,113 +3,52 @@ ...@@ -3,113 +3,52 @@
/*****************************************************************/ /*****************************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h"
#include "dialog_load_error.h" #include "dialog_load_error.h"
/**
* Function LoadLibraryName
*
* Routine to load the given library name. FullLibName should hold full path
* of file name to open, while LibName should hold only its name.
* If library already exists, it is NOT reloaded.
*
* @return : new lib or NULL
*/
LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
const wxString& FullLibName,
const wxString& LibName )
{
LibraryStruct* NewLib;
wxFileName fn;
wxString errMsg;
if( ( NewLib = FindLibrary( LibName ) ) != NULL )
{
if( NewLib->m_FullFileName == FullLibName )
return NewLib;
delete NewLib;
}
NewLib = new LibraryStruct( LIBRARY_TYPE_EESCHEMA, LibName, FullLibName );
wxBusyCursor ShowWait;
if( NewLib->Load( errMsg ) )
{
if( g_LibraryList == NULL )
g_LibraryList = NewLib;
else
{
LibraryStruct* tmplib = g_LibraryList;
while( tmplib->m_Pnext )
tmplib = tmplib->m_Pnext;
tmplib->m_Pnext = NewLib;
}
NewLib->LoadDocs( errMsg );
}
else
{
wxString msg;
msg.Printf( _( "Error <%s> occurred attempting to load component \
library <%s>" ),
( const wxChar* ) errMsg,
( const wxChar* ) FullLibName );
DisplayError( frame, msg );
SAFE_DELETE( NewLib );
}
return NewLib;
}
/** /**
* Function LoadLibraries * Function LoadLibraries
* *
* Clear all already loaded libraries and load all librairies * Clear all already loaded libraries and load all of the project libraries.
* given in frame->m_ComponentLibFiles
*/ */
void LoadLibraries( WinEDA_SchematicFrame* frame ) void WinEDA_SchematicFrame::LoadLibraries( void )
{ {
size_t ii;
wxFileName fn; wxFileName fn;
wxString msg, tmp; wxString msg, tmp, errMsg;
wxString libraries_not_found; wxString libraries_not_found;
unsigned ii, iimax = frame->m_ComponentLibFiles.GetCount();
// Free the unwanted libraries (i.e. not in list) but keep the cache lib CMP_LIBRARY_LIST::iterator i = CMP_LIBRARY::GetLibraryList().begin();
LibraryStruct* nextlib, * lib = g_LibraryList;
for( ; lib != NULL; lib = nextlib ) /* Free the unwanted libraries but keep the cache library. */
while ( i < CMP_LIBRARY::GetLibraryList().end() )
{ {
nextlib = lib->m_Pnext; if( i->IsCache() )
if( lib->m_IsLibCache ) {
i++;
continue; continue;
}
// is this library in "wanted list" frame->m_ComponentLibFiles ? if( m_ComponentLibFiles.Index( i->GetName(), false ) == wxNOT_FOUND )
if( frame->m_ComponentLibFiles.Index( lib->m_Name ) == wxNOT_FOUND ) i = CMP_LIBRARY::GetLibraryList().erase( i );
FreeCmpLibrary( frame, lib->m_Name ); else
i++;
} }
// Load missing libraries (if any) /* Load missing libraries. */
for( ii = 0; ii < iimax; ii++ ) for( ii = 0; ii < m_ComponentLibFiles.GetCount(); ii++ )
{ {
fn = frame->m_ComponentLibFiles[ii]; fn = m_ComponentLibFiles[ii];
fn.SetExt( CompLibFileExtension ); fn.SetExt( CompLibFileExtension );
/* Skip if the file name is not valid.. */
if( !fn.IsOk() ) if( !fn.IsOk() )
continue; continue;
...@@ -129,164 +68,46 @@ void LoadLibraries( WinEDA_SchematicFrame* frame ) ...@@ -129,164 +68,46 @@ void LoadLibraries( WinEDA_SchematicFrame* frame )
// Loaded library statusbar message // Loaded library statusbar message
msg = _( "Library " ) + tmp; msg = _( "Library " ) + tmp;
fn = tmp;
if( LoadLibraryName( frame, tmp, fn.GetName() ) ) if( CMP_LIBRARY::AddLibrary( fn, errMsg ) )
{
msg += _( " loaded" ); msg += _( " loaded" );
}
else else
{
wxString prompt;
prompt.Printf( _( "Component library <%s> failed to load.\n\n\
Error: %s" ),
( const wxChar* ) fn.GetFullPath(),
( const wxChar* ) errMsg );
DisplayError( this, prompt );
msg += _( " error!" ); msg += _( " error!" );
}
frame->PrintMsg( msg ); PrintMsg( msg );
} }
/* Print the libraries not found */ /* Print the libraries not found */
if( !libraries_not_found.IsEmpty() ) if( !libraries_not_found.IsEmpty() )
{ {
DIALOG_LOAD_ERROR dialog( frame ); DIALOG_LOAD_ERROR dialog( this );
dialog.MessageSet( _( "The following libraries could not be found:" ) ); dialog.MessageSet( _( "The following libraries could not be found:" ) );
dialog.ListSet( libraries_not_found ); dialog.ListSet( libraries_not_found );
libraries_not_found.empty(); libraries_not_found.empty();
dialog.ShowModal(); dialog.ShowModal();
} }
// reorder the linked list to match the order filename list: /* Put the libraries in the correct order. */
int NumOfLibs = 0; CMP_LIBRARY::SetSortOrder( m_ComponentLibFiles );
CMP_LIBRARY::GetLibraryList().sort();
for( lib = g_LibraryList; lib != NULL; lib = lib->m_Pnext )
{
lib->m_Flags = 0;
NumOfLibs++;
}
if( NumOfLibs == 0 )
return;
LibraryStruct** libs =
(LibraryStruct**) MyZMalloc( sizeof(LibraryStruct*) * (NumOfLibs + 2) );
int jj = 0;
for( ii = 0; ii < frame->m_ComponentLibFiles.GetCount(); ii++ )
{
if( jj >= NumOfLibs )
break;
fn = frame->m_ComponentLibFiles[ii];
lib = FindLibrary( fn.GetName() );
if( lib )
{
lib->m_Flags = 1;
libs[jj++] = lib;
}
}
/* Put lib cache at end of list */
for( lib = g_LibraryList; lib != NULL; lib = lib->m_Pnext )
{
if( lib->m_Flags == 0 )
libs[jj++] = lib;
}
libs[jj] = NULL;
/* Change the linked list pointers */
for( ii = 0; libs[ii] != NULL; ii++ )
libs[ii]->m_Pnext = libs[ii + 1];
g_LibraryList = libs[0];
MyFree( libs );
for( lib = g_LibraryList; lib != NULL; lib = lib->m_Pnext )
lib->m_Flags = 0;
}
/**
* Function FreeCmpLibrary
*
* Routine to remove and free a library from the current loaded libraries.
*/
void FreeCmpLibrary( wxWindow* frame, const wxString& LibName )
{
int NumOfLibs = NumOfLibraries();
LibraryStruct* Lib, * TempLib;
if( NumOfLibs == 0 )
{
DisplayError( frame, wxT( "No libraries are loaded" ), 20 );
return;
}
/* Search for this library name: */
for( Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
{
if( LibName == Lib->m_Name )
break;
}
if( Lib == NULL )
return;
if( Lib == g_LibraryList )
g_LibraryList = Lib->m_Pnext;
else
{
for( TempLib = g_LibraryList; TempLib->m_Pnext != Lib;
TempLib = TempLib->m_Pnext )
;
TempLib->m_Pnext = TempLib->m_Pnext->m_Pnext;
}
SAFE_DELETE( Lib );
/* The removed librairy can be the current library in libedit.
* If so, clear the current library in libedit */
if( Lib == CurrentLib )
CurrentLib = NULL;
}
/**
* Function LibraryEntryCompare
*
* Routine to compare two EDA_LibComponentStruct for the PriorQue module.
* Comparison (insensitive case) is based on Part name.
*/
int LibraryEntryCompare( EDA_LibComponentStruct* LE1,
EDA_LibComponentStruct* LE2 )
{
return LE1->m_Name.m_Text.CmpNoCase( LE2->m_Name.m_Text );
}
/*****************************************************************************
* Routine to find the library given its name.
*****************************************************************************/
LibraryStruct* FindLibrary( const wxString& Name )
{
LibraryStruct* Lib = g_LibraryList;
while( Lib )
{
if( *Lib == Name )
return Lib;
Lib = Lib->m_Pnext;
}
return NULL;
}
/*****************************************************************************
* Routine to find the number of libraries currently loaded.
*****************************************************************************/
int NumOfLibraries()
{
int ii;
LibraryStruct* Lib = g_LibraryList;
for( ii = 0; Lib != NULL; Lib = Lib->m_Pnext ) #ifdef __WXDEBUG__
ii++; wxLogDebug( wxT( "Component library sort order:" ) );
return ii; for ( i = CMP_LIBRARY::GetLibraryList().begin();
i < CMP_LIBRARY::GetLibraryList().end(); i++ )
wxLogDebug( wxT( " " ) + i->GetName() );
#endif
} }
...@@ -256,14 +256,15 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem ...@@ -256,14 +256,15 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
{ {
EDA_LibComponentStruct* LibEntry; LIB_COMPONENT* LibEntry;
SCH_COMPONENT* Struct; SCH_COMPONENT* Struct;
Struct = (SCH_COMPONENT*) aItem; Struct = (SCH_COMPONENT*) aItem;
LibEntry = ( EDA_LibComponentStruct* ) FindLibPart( Struct->m_ChipName ); LibEntry = CMP_LIBRARY::FindLibraryComponent( Struct->m_ChipName );
if( LibEntry == NULL ) if( LibEntry == NULL )
break; break;
DrawingLibInGhost( aPanel, aDC, LibEntry, Struct, Struct->m_Pos.x + aOffset.x, DrawingLibInGhost( aPanel, aDC, LibEntry, Struct,
Struct->m_Pos.x + aOffset.x,
Struct->m_Pos.y + aOffset.y, Struct->m_Multi, Struct->m_Pos.y + aOffset.y, Struct->m_Multi,
Struct->m_Convert, g_GhostColor, FALSE ); Struct->m_Convert, g_GhostColor, FALSE );
break; break;
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
// Global variables // Global variables
LibraryStruct* g_LibraryList; // All part libs are saved here.
int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que
* les numeros (netlist PSPICE seulement) */ * les numeros (netlist PSPICE seulement) */
SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure
...@@ -103,8 +101,8 @@ int g_InvisibleItemColor = DARKGRAY; ...@@ -103,8 +101,8 @@ int g_InvisibleItemColor = DARKGRAY;
LibEDA_BaseStruct* LibItemToRepeat = NULL; /* pointer on a graphic item than LibEDA_BaseStruct* LibItemToRepeat = NULL; /* pointer on a graphic item than
* can be duplicated by the Ins key * can be duplicated by the Ins key
* (usually the last created item */ * (usually the last created item */
LibraryStruct* CurrentLib = NULL; /* Current opened library */ CMP_LIBRARY* CurrentLib = NULL; /* Current opened library */
EDA_LibComponentStruct* CurrentLibEntry = NULL; /* Current component */ LIB_COMPONENT* CurrentLibEntry = NULL; /* Current component */
LibEDA_BaseStruct* CurrentDrawItem = NULL; /* current edited item */ LibEDA_BaseStruct* CurrentDrawItem = NULL; /* current edited item */
// Current selected alias (for components which have aliases) // Current selected alias (for components which have aliases)
...@@ -115,9 +113,6 @@ bool g_AsDeMorgan; ...@@ -115,9 +113,6 @@ bool g_AsDeMorgan;
int CurrentUnit = 1; int CurrentUnit = 1;
int CurrentConvert = 1; int CurrentConvert = 1;
/* Library (name) containing the last component find by FindLibPart() */
wxString FindLibName;
int DefaultTransformMatrix[2][2] = { { 1, 0 }, { 0, -1 } }; int DefaultTransformMatrix[2][2] = { { 1, 0 }, { 0, -1 } };
......
...@@ -45,19 +45,18 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event ) ...@@ -45,19 +45,18 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event )
} }
/************************************************************************************/ /*
int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
bool IsNew )
/************************************************************************************/
{
/*
* Load an entire project * Load an entire project
* ( schematic root file and its subhierarchies, the configuration and the libs *
* Schematic root file and its subhierarchies, the configuration and the libs
* which are not already loaded) * which are not already loaded)
*/ */
int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
bool IsNew )
{
SCH_SCREEN* screen; SCH_SCREEN* screen;
wxString FullFileName, msg; wxString FullFileName, msg;
bool LibCacheExist = FALSE; bool LibCacheExist = false;
EDA_ScreenList ScreenList; EDA_ScreenList ScreenList;
...@@ -133,13 +132,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, ...@@ -133,13 +132,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
LoadProjectFile( wxEmptyString, FALSE ); LoadProjectFile( wxEmptyString, FALSE );
// Delete old caches. // Delete old caches.
LibraryStruct* nextlib, * lib = g_LibraryList; CMP_LIBRARY::RemoveCacheLibrary();
for( ; lib != NULL; lib = nextlib )
{
nextlib = lib->m_Pnext;
if( lib->m_IsLibCache )
FreeCmpLibrary( this, lib->m_Name );
}
if( IsNew ) if( IsNew )
{ {
...@@ -164,29 +157,44 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, ...@@ -164,29 +157,44 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
fn.SetExt( wxT( "cache.lib" ) ); fn.SetExt( wxT( "cache.lib" ) );
use_oldcachename = true; use_oldcachename = true;
} }
if( fn.FileExists() ) if( fn.FileExists() )
{ {
wxString errMsg;
wxLogDebug( wxT( "Load schematic cache library file <%s>" ), wxLogDebug( wxT( "Load schematic cache library file <%s>" ),
fn.GetFullPath().c_str() ); fn.GetFullPath().c_str() );
msg = wxT( "Load " ) + fn.GetFullPath(); msg = wxT( "Load " ) + fn.GetFullPath();
LibraryStruct* LibCache = LoadLibraryName( this, fn.GetFullPath(),
fn.GetName() ); CMP_LIBRARY* LibCache = CMP_LIBRARY::LoadLibrary( fn, errMsg );
if( LibCache ) if( LibCache )
{ {
LibCache->m_IsLibCache = TRUE; LibCache->SetCache();
msg += wxT( " OK" ); msg += wxT( " OK" );
if ( use_oldcachename ) // set the new name if ( use_oldcachename ) // set the new name
{ {
fn.SetName(cachename); fn.SetName(cachename);
fn.SetExt( CompLibFileExtension ); fn.SetExt( CompLibFileExtension );
LibCache->m_Name = fn.GetName(); LibCache->SetFileName( fn );
LibCache->m_FullFileName = fn.GetFullPath();
} }
LibCacheExist = true;
CMP_LIBRARY::GetLibraryList().push_back( LibCache );
} }
else else
{
wxString prompt;
prompt.Printf( _( "Component library <%s> failed to load.\n\n\
Error: %s" ),
( const wxChar* ) fn.GetFullPath(),
( const wxChar* ) errMsg );
DisplayError( this, prompt );
msg += wxT( " ->Error" ); msg += wxT( " ->Error" );
}
PrintMsg( msg ); PrintMsg( msg );
LibCacheExist = TRUE;
} }
if( !wxFileExists( g_RootSheet->m_AssociatedScreen->m_FileName ) if( !wxFileExists( g_RootSheet->m_AssociatedScreen->m_FileName )
......
...@@ -8,18 +8,21 @@ ...@@ -8,18 +8,21 @@
* in current sheet or whole the project * in current sheet or whole the project
*/ */
#include "fctsys.h" #include "fctsys.h"
//#include "gr_basic.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "gestfich.h" #include "gestfich.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "protos.h"
#include <boost/foreach.hpp>
/* Variables Locales */ /* Variables Locales */
static int s_ItemsCount, s_MarkerCount; static int s_ItemsCount, s_MarkerCount;
...@@ -28,9 +31,6 @@ static wxString s_OldStringFound; ...@@ -28,9 +31,6 @@ static wxString s_OldStringFound;
#include "dialog_find.cpp" #include "dialog_find.cpp"
#include "protos.h"
/**************************************************************/ /**************************************************************/
void WinEDA_FindFrame::FindMarker( wxCommandEvent& event ) void WinEDA_FindFrame::FindMarker( wxCommandEvent& event )
/**************************************************************/ /**************************************************************/
...@@ -645,25 +645,25 @@ void WinEDA_FindFrame::LocatePartInLibs( wxCommandEvent& event ) ...@@ -645,25 +645,25 @@ void WinEDA_FindFrame::LocatePartInLibs( wxCommandEvent& event )
s_OldStringFound = Text; s_OldStringFound = Text;
if( NumOfLibraries() == 0 ) if( CMP_LIBRARY::GetLibraryCount() == 0 )
{ {
DisplayError( this, _( "No libraries are loaded" ) ); DisplayError( this, _( "No component libraries are loaded." ) );
Close(); Close();
return; return;
} }
int nbitemsFound = 0; int nbitemsFound = 0;
for( LibraryStruct* Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext ) BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
{ {
Lib->SearchEntryNames( nameList, Text ); lib.SearchEntryNames( nameList, Text );
if( nameList.IsEmpty() ) if( nameList.IsEmpty() )
continue; continue;
nbitemsFound += nameList.GetCount(); nbitemsFound += nameList.GetCount();
if( !Lib->m_IsLibCache ) if( !lib.IsCache() )
FoundInLib = true; FoundInLib = true;
for( size_t i = 0; i < nameList.GetCount(); i++ ) for( size_t i = 0; i < nameList.GetCount(); i++ )
...@@ -671,7 +671,7 @@ void WinEDA_FindFrame::LocatePartInLibs( wxCommandEvent& event ) ...@@ -671,7 +671,7 @@ void WinEDA_FindFrame::LocatePartInLibs( wxCommandEvent& event )
if( !FindList.IsEmpty() ) if( !FindList.IsEmpty() )
FindList += wxT( "\n" ); FindList += wxT( "\n" );
FindList << _( "Found " ) + nameList[i] + _( " in library " ) FindList << _( "Found " ) + nameList[i] + _( " in library " )
+ Lib->m_Name; + lib.GetName();
} }
} }
......
...@@ -94,8 +94,6 @@ typedef enum { ...@@ -94,8 +94,6 @@ typedef enum {
/* variables generales */ /* variables generales */
extern LibraryStruct* g_LibraryList; // All part libs are saved here.
extern int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que extern int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que
* les numeros (netlist PSPICE seulement) */ * les numeros (netlist PSPICE seulement) */
extern SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure extern SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure
......
...@@ -8,11 +8,15 @@ ...@@ -8,11 +8,15 @@
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "get_component_dialog.h" #include "get_component_dialog.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
#include <boost/foreach.hpp>
/* Routines Locales */ /* Routines Locales */
...@@ -66,9 +70,9 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC, ...@@ -66,9 +70,9 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
bool UseLibBrowser ) bool UseLibBrowser )
{ {
int ii, CmpCount = 0; int ii, CmpCount = 0;
EDA_LibComponentStruct* Entry = NULL; LIB_COMPONENT* Entry = NULL;
SCH_COMPONENT* Component = NULL; SCH_COMPONENT* Component = NULL;
LibraryStruct* Library = NULL; CMP_LIBRARY* Library = NULL;
wxString Name, keys, msg; wxString Name, keys, msg;
bool AllowWildSeach = TRUE; bool AllowWildSeach = TRUE;
...@@ -77,24 +81,16 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC, ...@@ -77,24 +81,16 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
if( !libname.IsEmpty() ) if( !libname.IsEmpty() )
{ {
Library = g_LibraryList; Library = CMP_LIBRARY::FindLibrary( libname );
while( Library )
{ if( Library != NULL )
if( Library->GetName().CmpNoCase( libname ) == 0 )
{
CmpCount = Library->GetCount(); CmpCount = Library->GetCount();
break;
}
Library = Library->m_Pnext;
}
} }
else else
{ {
LibraryStruct* lib = g_LibraryList; BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
while( lib )
{ {
CmpCount += lib->GetCount(); CmpCount += lib.GetCount();
lib = lib->m_Pnext;
} }
} }
...@@ -145,7 +141,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC, ...@@ -145,7 +141,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
} }
} }
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Name, libname ); Entry = CMP_LIBRARY::FindLibraryComponent( Name, libname );
if( (Entry == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */ if( (Entry == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */
{ {
...@@ -155,7 +151,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC, ...@@ -155,7 +151,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
Name = DataBaseGetName( this, keys, Name ); Name = DataBaseGetName( this, keys, Name );
if( !Name.IsEmpty() ) if( !Name.IsEmpty() )
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Name, libname ); Entry = CMP_LIBRARY::FindLibraryComponent( Name, libname );
if( Entry == NULL ) if( Entry == NULL )
{ {
...@@ -347,12 +343,12 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent, ...@@ -347,12 +343,12 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent,
int unit, wxDC* DC ) int unit, wxDC* DC )
{ {
int m_UnitCount; int m_UnitCount;
EDA_LibComponentStruct* LibEntry; LIB_COMPONENT* LibEntry;
if( DrawComponent == NULL ) if( DrawComponent == NULL )
return; return;
LibEntry = ( EDA_LibComponentStruct* ) FindLibPart( DrawComponent->m_ChipName ); LibEntry = CMP_LIBRARY::FindLibraryComponent( DrawComponent->m_ChipName );
if( LibEntry == NULL ) if( LibEntry == NULL )
return; return;
...@@ -395,12 +391,12 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent, ...@@ -395,12 +391,12 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
wxDC* DC ) wxDC* DC )
{ {
int ii; int ii;
EDA_LibComponentStruct* LibEntry; LIB_COMPONENT* LibEntry;
if( DrawComponent == NULL ) if( DrawComponent == NULL )
return; return;
LibEntry = ( EDA_LibComponentStruct* ) FindLibPart( DrawComponent->m_ChipName ); LibEntry = CMP_LIBRARY::FindLibraryComponent( DrawComponent->m_ChipName );
if( LibEntry == NULL ) if( LibEntry == NULL )
return; return;
...@@ -441,7 +437,7 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent, ...@@ -441,7 +437,7 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
* Si il y a une representation type "convert", * Si il y a une representation type "convert",
* la valeur retournee est > 1 (typiquement 2) * la valeur retournee est > 1 (typiquement 2)
*/ */
int LookForConvertPart( EDA_LibComponentStruct* LibEntry ) int LookForConvertPart( LIB_COMPONENT* LibEntry )
{ {
int ii; int ii;
LibEDA_BaseStruct* DrawLibEntry; LibEDA_BaseStruct* DrawLibEntry;
......
...@@ -13,15 +13,13 @@ ...@@ -13,15 +13,13 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "gestfich.h" #include "gestfich.h"
#include "id.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "id.h"
#include <wx/filename.h> #include <wx/filename.h>
...@@ -37,10 +35,10 @@ extern int ExportPartId; ...@@ -37,10 +35,10 @@ extern int ExportPartId;
/*************************************************/ /*************************************************/
void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event ) void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event )
{ {
wxString errMsg;
wxFileName fn; wxFileName fn;
LibraryStruct* LibTmp; CMP_LIBRARY* LibTmp;
LibCmpEntry* LibEntry; CMP_LIB_ENTRY* LibEntry;
bool entryLoaded = false;
LibItemToRepeat = NULL; LibItemToRepeat = NULL;
...@@ -51,33 +49,35 @@ void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event ) ...@@ -51,33 +49,35 @@ void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event )
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; return;
LibTmp = g_LibraryList; fn = dlg.GetPath();
g_LibraryList = NULL;
LibTmp = CMP_LIBRARY::LoadLibrary( fn, errMsg );
if( LibTmp == NULL )
return;
LoadLibraryName( this, dlg.GetPath(), wxT( "$tmplib$" ) ); LibEntry = LibTmp->GetFirstEntry();
if( g_LibraryList ) if( LibEntry == NULL )
{ {
LibEntry = g_LibraryList->GetFirstEntry(); wxString msg;
if( LibEntry ) msg.Printf( _( "Component library file <%s> is empty." ),
entryLoaded = LoadOneLibraryPartAux( LibEntry, g_LibraryList ); (const wxChar*) fn.GetFullPath() );
FreeCmpLibrary( this, g_LibraryList->m_Name ); DisplayError( this, msg );
return;
}
if( entryLoaded ) if( LoadOneLibraryPartAux( LibEntry, LibTmp ) )
{ {
fn = dlg.GetPath(); fn = dlg.GetPath();
m_LastLibImportPath = fn.GetPath(); m_LastLibImportPath = fn.GetPath();
ReCreateHToolbar();
DisplayLibInfos(); DisplayLibInfos();
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
DrawPanel->Refresh(); DrawPanel->Refresh();
} }
else
DisplayError( this, _( "File is empty" ) );
}
g_LibraryList = LibTmp; delete LibTmp;
} }
...@@ -91,17 +91,17 @@ void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event ) ...@@ -91,17 +91,17 @@ void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event )
void WinEDA_LibeditFrame::OnExportPart( wxCommandEvent& event ) void WinEDA_LibeditFrame::OnExportPart( wxCommandEvent& event )
{ {
wxFileName fn; wxFileName fn;
wxString Name, mask, title; wxString msg, title;
LibraryStruct* NewLib, * LibTmp, * CurLibTmp; CMP_LIBRARY* CurLibTmp;
bool createLib = ( event.GetId() == ExportPartId ) ? false : true; bool createLib = ( event.GetId() != ExportPartId ) ? false : true;
if( CurrentLibEntry == NULL ) if( CurrentLibEntry == NULL )
{ {
DisplayError( this, _( "No Part to Save" ), 10 ); DisplayError( this, _( "There is no component selected to save." ) );
return; return;
} }
fn = CurrentLibEntry->m_Name.m_Text.Lower(); fn = CurrentLibEntry->GetName().Lower();
fn.SetExt( CompLibFileExtension ); fn.SetExt( CompLibFileExtension );
title = createLib ? _( "New Library" ) : _( "Export Component" ); title = createLib ? _( "New Library" ) : _( "Export Component" );
...@@ -114,38 +114,26 @@ void WinEDA_LibeditFrame::OnExportPart( wxCommandEvent& event ) ...@@ -114,38 +114,26 @@ void WinEDA_LibeditFrame::OnExportPart( wxCommandEvent& event )
fn = dlg.GetPath(); fn = dlg.GetPath();
/* Creation d'une librairie standard pour sauvegarde */
LibTmp = g_LibraryList;
CurLibTmp = CurrentLib; CurLibTmp = CurrentLib;
NewLib = new LibraryStruct( LIBRARY_TYPE_EESCHEMA, wxT( "$libTmp$" ), CurrentLib = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, fn );
fn.GetFullName() );
g_LibraryList = NewLib;
/* Sauvegarde du composant: */
CurrentLib = NewLib;
SaveOnePartInMemory(); SaveOnePartInMemory();
bool success = NewLib->Save( fn.GetFullPath() );
bool success = CurrentLib->Save( fn.GetFullPath() );
if( success ) if( success )
{
m_LastLibExportPath = fn.GetPath(); m_LastLibExportPath = fn.GetPath();
}
/* Suppression de la librarie temporaire */ delete CurrentLib;
FreeCmpLibrary( this, NewLib->m_Name );
g_LibraryList = LibTmp;
CurrentLib = CurLibTmp; CurrentLib = CurLibTmp;
wxString msg;
if( createLib && success ) if( createLib && success )
{ {
msg = fn.GetFullPath() + _( " - OK" ); msg = fn.GetFullPath() + _( " - OK" );
DisplayInfoMessage( this, DisplayInfoMessage( this, _( "This library will not be available \
_( "Note: this new library will be available only \ until it is loaded by EESchema.\nModify the EESchema library configuration \
if it is loaded by eeschema.\nModify eeschema config if you want use it." ) ); if you want to include it as part of this project." ) );
} }
else else
msg = _( "Error creating " ) + fn.GetFullName(); msg = _( "Error creating " ) + fn.GetFullName();
......
...@@ -2,123 +2,61 @@ ...@@ -2,123 +2,61 @@
/* libarch.cc */ /* libarch.cc */
/* Module de generation du fichier d'archivage des composants */ /* Module de generation du fichier d'archivage des composants */
/**************************************************************/ /**************************************************************/
#include <algorithm> // to use sort vector
#include <vector>
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "netlist.h" #include "netlist.h"
#include "protos.h" #include "protos.h"
/* Local functions*/
static bool SortCmpByName( const EDA_LibComponentStruct* Objet1,
const EDA_LibComponentStruct* Objet2 );
/*******************************************************************/
bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName )
/*******************************************************************/
/* /*
* Creates a library that contains all components used in the whole hierarchy * Creates a library that contains all components used in the schematic.
*
* return true if success * return true if success
*/ */
bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName )
{ {
wxFileName docFileName;
wxString msg; wxString msg;
char Line[256]; LIB_COMPONENT* Entry;
FILE* ArchiveFile, * DocFile; CMP_LIBRARY* libCache;
EDA_LibComponentStruct* Entry;
std::vector <EDA_LibComponentStruct*> ListEntry;
EDA_ScreenList ScreenList; EDA_ScreenList ScreenList;
/* examine all screens (not scheets) used and build the list of components found in lib libCache = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, ArchFullFileName );
* complex hierarchies are not a problem because we just want to know used components in libraries libCache->SetCache();
/* examine all screens (not scheets) used and build the list of components
* found in lib complex hierarchies are not a problem because we just want
* to know used components in libraries
*/ */
for( SCH_SCREEN* screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) for( SCH_SCREEN* screen = ScreenList.GetFirst(); screen != NULL;
screen = ScreenList.GetNext() )
{ {
for( SCH_ITEM* SchItem = screen->EEDrawList; SchItem; SchItem = SchItem->Next() ) for( SCH_ITEM* SchItem = screen->EEDrawList; SchItem;
SchItem = SchItem->Next() )
{ {
if( SchItem->Type() != TYPE_SCH_COMPONENT ) if( SchItem->Type() != TYPE_SCH_COMPONENT )
continue; continue;
SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) SchItem; SCH_COMPONENT* component = (SCH_COMPONENT*) SchItem;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( DrawLibItem->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( component->m_ChipName );
if( Entry ) // if NULL : component not found if( Entry ) // if NULL : component not found
ListEntry.push_back( Entry ); libCache->AddComponent( Entry );
}
} }
// Sort components (libraries entries) by name
// (they are components name in library, not in schematic) :
sort( ListEntry.begin(), ListEntry.end(), SortCmpByName );
/* calculate the file name for the associated doc file */
docFileName = ArchFullFileName;
docFileName.SetExt( DOC_EXT );
if( ( ArchiveFile = wxFopen( ArchFullFileName, wxT( "wt" ) ) ) == NULL )
{
msg = _( "Failed to create archive lib file " ) + ArchFullFileName;
DisplayError( frame, msg );
return FALSE;
} }
if( ( DocFile = wxFopen( docFileName.GetFullPath(), wxT( "wt" ) ) ) == NULL ) if( !libCache->Save( ArchFullFileName ) )
{ {
msg = _( "Failed to create doc lib file " ) + docFileName.GetFullPath(); msg.Printf( _( "An error occurrred attempting to save component \
library <%s>." ), (const wxChar*) ArchFullFileName );
DisplayError( frame, msg ); DisplayError( frame, msg );
return false;
} }
fprintf( ArchiveFile, "%s %s\n#\n", LIBFILE_IDENT, DateAndTime( Line ) ); return true;
if( DocFile )
fprintf( DocFile, "%s %s\n", DOCFILE_IDENT, DateAndTime( Line ) );
/* Save components in file */
for( unsigned ii = 0; ii < ListEntry.size(); ii++ )
{
if( (ii == 0) || ( ListEntry[ii - 1] != ListEntry[ii] ) )
{
if( ListEntry[ii]->Type == ROOT ) // Must be always true, but just in case
ListEntry[ii]->Save( ArchiveFile );
if( DocFile )
ListEntry[ii]->SaveDoc( DocFile );
}
}
fprintf( ArchiveFile, "#\n#EndLibrary\n" );
fclose( ArchiveFile );
if( DocFile )
{
fprintf( DocFile, "#\n#End Doc Library\n" );
fclose( DocFile );
}
return TRUE;
}
/***********************************************************************************************/
bool SortCmpByName( const EDA_LibComponentStruct* Objet1, const EDA_LibComponentStruct* Objet2 )
/***********************************************************************************************/
/* Compare function for sort()
* lib components are sorted by name
*/
{
int ii;
ii = Objet1->m_Name.m_Text.CmpNoCase( Objet2->m_Name.m_Text );
return ii < 0;
} }
...@@ -8,12 +8,26 @@ ...@@ -8,12 +8,26 @@
#define LIB_VERSION_MAJOR 2 #define LIB_VERSION_MAJOR 2
#define LIB_VERSION_MINOR 3 #define LIB_VERSION_MINOR 3
#define LIBFILE_IDENT "EESchema-LIBRARY Version" /* Must be the first line of lib files. */
#define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0" /* Must be the first line of doc files. */
#define DOC_EXT wxT( "dcm" ) /* Ext. of documentation files */
/* Must be the first line of component library (.lib) files. */
#define LIBFILE_IDENT "EESchema-LIBRARY Version"
enum LocateDrawStructType { #define LIB_VERSION( major, minor ) ( major * 100 + minor )
#define IS_LIB_CURRENT_VERSION( major, minor ) \
( \
LIB_VERSION( major1, minor1 ) == \
LIB_VERSION( LIB_VERSION_MAJOR, LIB_VERSION_MINOR) \
)
/* Must be the first line of component library document (.dcm) files. */
#define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0"
#define DOC_EXT wxT( "dcm" )
enum LocateDrawStructType
{
LOCATE_COMPONENT_ARC_DRAW_TYPE = 1, LOCATE_COMPONENT_ARC_DRAW_TYPE = 1,
LOCATE_COMPONENT_CIRCLE_DRAW_TYPE = 2, LOCATE_COMPONENT_CIRCLE_DRAW_TYPE = 2,
LOCATE_COMPONENT_GRAPHIC_TEXT_DRAW_TYPE = 4, LOCATE_COMPONENT_GRAPHIC_TEXT_DRAW_TYPE = 4,
...@@ -29,14 +43,12 @@ enum LocateDrawStructType { ...@@ -29,14 +43,12 @@ enum LocateDrawStructType {
#include "class_library.h" #include "class_library.h"
/* Variables */
extern LibraryStruct* LibraryList; /* All part libs are saved here. */
/* Variables used by LibEdit */ /* Variables used by LibEdit */
extern LibEDA_BaseStruct* LibItemToRepeat; /* pointer on a graphic item than can be duplicated by the Ins key extern LibEDA_BaseStruct* LibItemToRepeat; /* pointer on a graphic item than
* can be duplicated by the Ins key
* (usually the last created item */ * (usually the last created item */
extern LibraryStruct* CurrentLib; /* Current opened library */ extern CMP_LIBRARY* CurrentLib; /* Current opened library */
extern EDA_LibComponentStruct* CurrentLibEntry; /* Current component */ extern LIB_COMPONENT* CurrentLibEntry; /* Current component */
extern LibEDA_BaseStruct* CurrentDrawItem; /* current edited item */ extern LibEDA_BaseStruct* CurrentDrawItem; /* current edited item */
extern wxString CurrentAliasName; extern wxString CurrentAliasName;
...@@ -44,6 +56,4 @@ extern bool g_AsDeMorgan; ...@@ -44,6 +56,4 @@ extern bool g_AsDeMorgan;
extern int CurrentUnit; extern int CurrentUnit;
extern int CurrentConvert; extern int CurrentConvert;
extern wxString FindLibName;
#endif // LIBCMP_H #endif // LIBCMP_H
...@@ -28,42 +28,18 @@ void WinEDA_LibeditFrame::DisplayLibInfos() ...@@ -28,42 +28,18 @@ void WinEDA_LibeditFrame::DisplayLibInfos()
wxString msg = _( "Component Library Editor: " ); wxString msg = _( "Component Library Editor: " );
if( CurrentLib ) if( CurrentLib )
msg += CurrentLib->m_FullFileName; msg += CurrentLib->GetFullFileName();
else else
msg += _( "no library selected" ); msg += _( "no library selected" );
SetTitle( msg ); SetTitle( msg );
msg = _( " Part: " );
if( CurrentLibEntry == NULL )
{
msg += _( "None" );
}
else
{
msg += CurrentLibEntry->GetName();
if( !CurrentAliasName.IsEmpty() )
msg << _( " Alias " ) << CurrentAliasName;
}
static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
msg << _( " Unit " ) << UnitLetter[CurrentUnit];
if( CurrentConvert > 1 )
msg += _( " Convert" );
else
msg += _( " Normal" );
if( CurrentLibEntry && ( CurrentLibEntry->m_Options == ENTRY_POWER ) )
msg += _( " (Power Symbol)" );
SetStatusText( msg, 0 );
} }
/* Function to select the current library (working library) */ /* Function to select the current library (working library) */
void WinEDA_LibeditFrame::SelectActiveLibrary() void WinEDA_LibeditFrame::SelectActiveLibrary()
{ {
LibraryStruct* Lib; CMP_LIBRARY* Lib;
Lib = SelectLibraryFromList( this ); Lib = SelectLibraryFromList( this );
if( Lib ) if( Lib )
...@@ -86,7 +62,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart() ...@@ -86,7 +62,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart()
int i; int i;
wxString msg; wxString msg;
wxString CmpName; wxString CmpName;
LibCmpEntry* LibEntry = NULL; CMP_LIB_ENTRY* LibEntry = NULL;
if( g_ScreenLib->IsModify() ) if( g_ScreenLib->IsModify() )
{ {
...@@ -122,7 +98,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart() ...@@ -122,7 +98,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart()
msg.Printf( _( "Component or alias name \"%s\" not found in \ msg.Printf( _( "Component or alias name \"%s\" not found in \
library \"%s\"." ), library \"%s\"." ),
(const wxChar*) CmpName, (const wxChar*) CmpName,
(const wxChar*) CurrentLib->m_Name ); (const wxChar*) CurrentLib->GetName() );
DisplayError( this, msg ); DisplayError( this, msg );
return false; return false;
} }
...@@ -145,11 +121,11 @@ library \"%s\"." ), ...@@ -145,11 +121,11 @@ library \"%s\"." ),
* 1 si err * 1 si err
* CurrentLibEntry pointe la copie ainsi creee * CurrentLibEntry pointe la copie ainsi creee
*/ */
bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( LibCmpEntry* LibEntry, bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry,
LibraryStruct* Library ) CMP_LIBRARY* Library )
{ {
wxString msg, cmpName, rootName; wxString msg, cmpName, rootName;
EDA_LibComponentStruct* component; LIB_COMPONENT* component;
if( ( LibEntry == NULL ) || ( Library == NULL ) ) if( ( LibEntry == NULL ) || ( Library == NULL ) )
return false; return false;
...@@ -166,29 +142,20 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( LibCmpEntry* LibEntry, ...@@ -166,29 +142,20 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( LibCmpEntry* LibEntry,
if( LibEntry->Type != ROOT ) if( LibEntry->Type != ROOT )
{ {
rootName = ( (EDA_LibCmpAliasStruct*) LibEntry )->m_RootName; LIB_ALIAS* alias = (LIB_ALIAS*) LibEntry;
wxASSERT( !rootName.IsEmpty() ); component = alias->GetComponent();
wxLogDebug( wxT( "\"<%s>\" is alias of \"<%s>\"" ),
(const wxChar*) cmpName, (const wxChar*) rootName );
component = Library->FindComponent( rootName ); wxASSERT( component != NULL && component->Type == ROOT );
if( component == NULL ) wxLogDebug( wxT( "\"<%s>\" is alias of \"<%s>\"" ),
{
msg.Printf( wxT( "Root entry <%s> for alias <%s> not found in \
library <%s>." ),
(const wxChar*) rootName,
(const wxChar*) cmpName, (const wxChar*) cmpName,
(const wxChar*) Library->m_Name ); (const wxChar*) component->GetName() );
DisplayError( this, msg );
return false;
}
CurrentAliasName = cmpName; CurrentAliasName = cmpName;
} }
else else
{ {
component = (EDA_LibComponentStruct*) LibEntry; component = (LIB_COMPONENT*) LibEntry;
} }
if( CurrentLibEntry ) if( CurrentLibEntry )
...@@ -200,7 +167,7 @@ library <%s>." ), ...@@ -200,7 +167,7 @@ library <%s>." ),
{ {
msg.Printf( _( "Could not create copy of part <%s> in library <%s>." ), msg.Printf( _( "Could not create copy of part <%s> in library <%s>." ),
(const wxChar*) LibEntry->GetName(), (const wxChar*) LibEntry->GetName(),
(const wxChar*) Library->m_Name ); (const wxChar*) Library->GetName() );
DisplayError( this, msg ); DisplayError( this, msg );
return false; return false;
} }
...@@ -220,7 +187,7 @@ library <%s>." ), ...@@ -220,7 +187,7 @@ library <%s>." ),
/* Display the document information based on the entry selected just in /* Display the document information based on the entry selected just in
* case the entry is an alias. */ * case the entry is an alias. */
DisplayCmpDoc( LibEntry->GetName() ); DisplayCmpDoc();
return true; return true;
} }
...@@ -275,8 +242,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event ) ...@@ -275,8 +242,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
wxFileName fn; wxFileName fn;
wxString msg; wxString msg;
DrawPanel->UnManageCursor(); DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
if( GetScreen()->IsModify() ) if( GetScreen()->IsModify() )
{ {
...@@ -290,7 +256,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event ) ...@@ -290,7 +256,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
return; return;
} }
fn = wxFileName( CurrentLib->m_FullFileName ); fn = wxFileName( CurrentLib->GetFullFileName() );
msg = _( "Modify library file \"" ) + fn.GetFullPath() + _( "\"?" ); msg = _( "Modify library file \"" ) + fn.GetFullPath() + _( "\"?" );
...@@ -305,7 +271,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event ) ...@@ -305,7 +271,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
{ {
msg = _( "Error while saving library file \"" ) + fn.GetFullPath() + msg = _( "Error while saving library file \"" ) + fn.GetFullPath() +
_( "\"." ); _( "\"." );
Affiche_1_Parametre( this, 1, wxT( " *** ERROR : **" ), msg, BLUE ); MsgPanel->Affiche_1_Parametre( 1, wxT( "*** ERROR: ***" ), msg, RED );
DisplayError( this, msg ); DisplayError( this, msg );
} }
else else
...@@ -314,7 +280,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event ) ...@@ -314,7 +280,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
fn.SetExt( DOC_EXT ); fn.SetExt( DOC_EXT );
wxString msg1 = _( "Document file \"" ) + fn.GetFullPath() + wxString msg1 = _( "Document file \"" ) + fn.GetFullPath() +
wxT( "\" Ok" ); wxT( "\" Ok" );
Affiche_1_Parametre( this, 1, msg, msg1, BLUE ); MsgPanel->Affiche_1_Parametre( 1, msg, msg1, BLUE );
} }
} }
...@@ -323,20 +289,64 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event ) ...@@ -323,20 +289,64 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
* Affiche la documentation du composant selectionne * Affiche la documentation du composant selectionne
* Utilise lors de l'affichage de la liste des composants en librairie * Utilise lors de l'affichage de la liste des composants en librairie
*/ */
void WinEDA_LibeditFrame::DisplayCmpDoc( const wxString& Name ) void WinEDA_LibeditFrame::DisplayCmpDoc()
{ {
LibCmpEntry* CmpEntry; wxString msg;
LIB_ALIAS* alias = NULL;
if( CurrentLib == NULL )
return;
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
CmpEntry = CurrentLib->FindEntry( Name );
if( CmpEntry == NULL ) if( CurrentLib == NULL && CurrentLibEntry == NULL )
return; return;
AfficheDoc( this, CmpEntry->m_Doc, CmpEntry->m_KeyWord ); msg = CurrentLibEntry->GetName();
MsgPanel->AppendMessage( _( "Part" ), msg, BLUE, 8 );
if( CurrentAliasName.IsEmpty() )
{
msg = _( "None" );
}
else
{
msg = CurrentAliasName;
alias = CurrentLib->FindAlias( CurrentAliasName );
}
MsgPanel->AppendMessage( _( "Alias" ), msg, RED, 8 );
static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
msg = UnitLetter[CurrentUnit];
MsgPanel->AppendMessage( _( "Unit" ), msg, BROWN, 8 );
if( CurrentConvert > 1 )
msg = _( "Convert" );
else
msg = _( "Normal" );
MsgPanel->AppendMessage( _( "Body" ), msg, GREEN, 8 );
if( CurrentLibEntry->m_Options == ENTRY_POWER )
msg = _( "Power Symbol" );
else
msg = _( "Component" );
MsgPanel->AppendMessage( _( "Type" ), msg, MAGENTA, 8 );
if( alias != NULL )
msg = alias->m_Doc;
else
msg = CurrentLibEntry->m_Doc;
MsgPanel->AppendMessage( _( "Description" ), msg, CYAN, 8 );
if( alias != NULL )
msg = alias->m_KeyWord;
else
msg = CurrentLibEntry->m_KeyWord;
MsgPanel->AppendMessage( _( "Key words" ), msg, DARKDARKGRAY );
} }
...@@ -355,7 +365,7 @@ void WinEDA_LibeditFrame::DisplayCmpDoc( const wxString& Name ) ...@@ -355,7 +365,7 @@ void WinEDA_LibeditFrame::DisplayCmpDoc( const wxString& Name )
void WinEDA_LibeditFrame::DeleteOnePart() void WinEDA_LibeditFrame::DeleteOnePart()
{ {
wxString CmpName; wxString CmpName;
LibCmpEntry* LibEntry; CMP_LIB_ENTRY* LibEntry;
wxArrayString ListNames; wxArrayString ListNames;
wxString msg; wxString msg;
...@@ -377,14 +387,14 @@ void WinEDA_LibeditFrame::DeleteOnePart() ...@@ -377,14 +387,14 @@ void WinEDA_LibeditFrame::DeleteOnePart()
if( ListNames.IsEmpty() ) if( ListNames.IsEmpty() )
{ {
msg.Printf( _( "Component library <%s> is empty." ), msg.Printf( _( "Component library <%s> is empty." ),
( const wxChar* ) CurrentLib->m_Name ); ( const wxChar* ) CurrentLib->GetName() );
wxMessageBox( msg, _( "Delete Entry Error" ), wxMessageBox( msg, _( "Delete Entry Error" ),
wxID_OK | wxICON_EXCLAMATION, this ); wxID_OK | wxICON_EXCLAMATION, this );
return; return;
} }
msg.Printf( _( "Select 1 of %d components to delete\nfrom library <%s>." ), msg.Printf( _( "Select 1 of %d components to delete\nfrom library <%s>." ),
ListNames.GetCount(), ( const wxChar* ) CurrentLib->m_Name ); ListNames.GetCount(), ( const wxChar* ) CurrentLib->GetName() );
wxSingleChoiceDialog dlg( this, msg, _( "Delete Component" ), ListNames ); wxSingleChoiceDialog dlg( this, msg, _( "Delete Component" ), ListNames );
...@@ -397,14 +407,14 @@ void WinEDA_LibeditFrame::DeleteOnePart() ...@@ -397,14 +407,14 @@ void WinEDA_LibeditFrame::DeleteOnePart()
{ {
msg.Printf( _( "Entry <%s> not found in library <%s>." ), msg.Printf( _( "Entry <%s> not found in library <%s>." ),
( const wxChar* ) dlg.GetStringSelection(), ( const wxChar* ) dlg.GetStringSelection(),
( const wxChar* ) CurrentLib->m_Name ); ( const wxChar* ) CurrentLib->GetName() );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
msg.Printf( _( "Delete component \"%s\" from library \"%s\"?" ), msg.Printf( _( "Delete component \"%s\" from library \"%s\"?" ),
(const wxChar*) LibEntry->GetName(), (const wxChar*) LibEntry->GetName(),
(const wxChar*) CurrentLib->m_Name ); (const wxChar*) CurrentLib->GetName() );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
...@@ -427,7 +437,7 @@ All changes will be lost. Discard changes?" ) ) ) ...@@ -427,7 +437,7 @@ All changes will be lost. Discard changes?" ) ) )
return; return;
wxString newCmpName; wxString newCmpName;
LibCmpEntry* nextEntry; CMP_LIB_ENTRY* nextEntry;
/* /*
* If the current component has no aliases, then the next entry * If the current component has no aliases, then the next entry
...@@ -475,12 +485,13 @@ All changes will be lost. Discard changes?" ) ) ) ...@@ -475,12 +485,13 @@ All changes will be lost. Discard changes?" ) ) )
void WinEDA_LibeditFrame::CreateNewLibraryPart() void WinEDA_LibeditFrame::CreateNewLibraryPart()
{ {
wxString msg; wxString msg;
EDA_LibComponentStruct* NewStruct; LIB_COMPONENT* NewStruct;
int diag; int diag;
if( CurrentLibEntry && GetScreen()->IsModify() if( CurrentLibEntry && GetScreen()->IsModify()
&& !IsOK( this, && !IsOK( this,
_( "Clear old component from screen (changes will be lost)?" ) ) ) _( "All changes to the current component will be lost!\n\n\
Clear the current component from the screen?" ) ) )
return; return;
CurrentDrawItem = NULL; CurrentDrawItem = NULL;
...@@ -503,13 +514,13 @@ void WinEDA_LibeditFrame::CreateNewLibraryPart() ...@@ -503,13 +514,13 @@ void WinEDA_LibeditFrame::CreateNewLibraryPart()
wxString msg; wxString msg;
msg.Printf( _( "Component \"%s\" exists in library \"%s\"." ), msg.Printf( _( "Component \"%s\" exists in library \"%s\"." ),
(const wxChar*) Dialogbox.ReturnCmpName(), (const wxChar*) Dialogbox.ReturnCmpName(),
(const wxChar*) CurrentLib->m_Name ); (const wxChar*) CurrentLib->GetName() );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
} }
NewStruct = new EDA_LibComponentStruct( msg ); NewStruct = new LIB_COMPONENT( msg );
Dialogbox.SetComponentData( *NewStruct ); Dialogbox.SetComponentData( *NewStruct );
if( NewStruct->m_Prefix.m_Text.IsEmpty() ) if( NewStruct->m_Prefix.m_Text.IsEmpty() )
NewStruct->m_Prefix.m_Text = wxT( "U" ); NewStruct->m_Prefix.m_Text = wxT( "U" );
...@@ -524,7 +535,7 @@ void WinEDA_LibeditFrame::CreateNewLibraryPart() ...@@ -524,7 +535,7 @@ void WinEDA_LibeditFrame::CreateNewLibraryPart()
CurrentUnit = 1; CurrentUnit = 1;
CurrentConvert = 1; CurrentConvert = 1;
DisplayLibInfos(); DisplayLibInfos();
DisplayCmpDoc( CurrentLibEntry->GetName() ); DisplayCmpDoc();
} }
...@@ -537,8 +548,8 @@ void WinEDA_LibeditFrame::CreateNewLibraryPart() ...@@ -537,8 +548,8 @@ void WinEDA_LibeditFrame::CreateNewLibraryPart()
*/ */
void WinEDA_LibeditFrame::SaveOnePartInMemory() void WinEDA_LibeditFrame::SaveOnePartInMemory()
{ {
EDA_LibComponentStruct* oldComponent; LIB_COMPONENT* oldComponent;
EDA_LibComponentStruct* Component; LIB_COMPONENT* Component;
wxString msg; wxString msg;
if( CurrentLibEntry == NULL ) if( CurrentLibEntry == NULL )
...@@ -581,6 +592,6 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory() ...@@ -581,6 +592,6 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory()
msg.Printf( _( "Component %s saved in library %s" ), msg.Printf( _( "Component %s saved in library %s" ),
( const wxChar* ) Component->GetName(), ( const wxChar* ) Component->GetName(),
( const wxChar* ) CurrentLib->m_Name ); ( const wxChar* ) CurrentLib->GetName() );
Affiche_Message( msg ); Affiche_Message( msg );
} }
...@@ -78,12 +78,7 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -78,12 +78,7 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawEntry->DisplayInfo( this ); DrawEntry->DisplayInfo( this );
else else
{ DisplayCmpDoc();
if( CurrentAliasName.IsEmpty() )
DisplayCmpDoc( CurrentAliasName );
else
DisplayCmpDoc( CurrentLibEntry->GetName() );
}
} }
} }
...@@ -151,13 +146,7 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -151,13 +146,7 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
LOCATE_ALL_DRAW_ITEM ); LOCATE_ALL_DRAW_ITEM );
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ DisplayCmpDoc();
if( CurrentAliasName.IsEmpty() )
DisplayCmpDoc( CurrentLibEntry->GetName() );
else
DisplayCmpDoc( CurrentAliasName );
break;
}
SaveCopyInUndoList( CurrentLibEntry ); SaveCopyInUndoList( CurrentLibEntry );
if( DrawEntry->Type() == COMPONENT_PIN_DRAW_TYPE ) if( DrawEntry->Type() == COMPONENT_PIN_DRAW_TYPE )
DeletePin( DC, CurrentLibEntry, (LibDrawPin*) DrawEntry ); DeletePin( DC, CurrentLibEntry, (LibDrawPin*) DrawEntry );
......
...@@ -20,10 +20,10 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, ...@@ -20,10 +20,10 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
/*************************************************************************/ /*************************************************************************/
{ {
EDA_BaseStruct* item; EDA_BaseStruct* item;
EDA_LibComponentStruct* CopyItem; LIB_COMPONENT* CopyItem;
PICKED_ITEMS_LIST* lastcmd; PICKED_ITEMS_LIST* lastcmd;
CopyItem = CopyLibEntryStruct( (EDA_LibComponentStruct*) ItemToCopy ); CopyItem = CopyLibEntryStruct( (LIB_COMPONENT*) ItemToCopy );
if( CopyItem == NULL ) if( CopyItem == NULL )
return; return;
...@@ -62,7 +62,7 @@ void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event) ...@@ -62,7 +62,7 @@ void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event)
lastcmd = GetScreen()->PopCommandFromRedoList( ); lastcmd = GetScreen()->PopCommandFromRedoList( );
wrapper = lastcmd->PopItem(); wrapper = lastcmd->PopItem();
CurrentLibEntry = (EDA_LibComponentStruct*) wrapper.m_PickedItem; CurrentLibEntry = (LIB_COMPONENT*) wrapper.m_PickedItem;
if( CurrentLibEntry ) if( CurrentLibEntry )
CurrentLibEntry->SetNext( NULL ); CurrentLibEntry->SetNext( NULL );
CurrentDrawItem = NULL; CurrentDrawItem = NULL;
...@@ -92,7 +92,7 @@ void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event) ...@@ -92,7 +92,7 @@ void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event)
lastcmd = GetScreen()->PopCommandFromUndoList( ); lastcmd = GetScreen()->PopCommandFromUndoList( );
wrapper = lastcmd->PopItem(); wrapper = lastcmd->PopItem();
CurrentLibEntry = (EDA_LibComponentStruct*) wrapper.m_PickedItem; CurrentLibEntry = (LIB_COMPONENT*) wrapper.m_PickedItem;
if( CurrentLibEntry ) if( CurrentLibEntry )
CurrentLibEntry->SetNext( NULL ); CurrentLibEntry->SetNext( NULL );
......
...@@ -216,7 +216,7 @@ names in the alias list." ), ...@@ -216,7 +216,7 @@ names in the alias list." ),
entry in the component library <%s>.\nPlease choose another name that does \ entry in the component library <%s>.\nPlease choose another name that does \
not conflict with any library entries." ), not conflict with any library entries." ),
(const wxChar*) Text, (const wxChar*) Text,
(const wxChar*) CurrentLib->m_Name ); (const wxChar*) CurrentLib->GetName() );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
...@@ -294,7 +294,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field ) ...@@ -294,7 +294,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field )
* return: * return:
* pointer on the field (or NULL ) * pointer on the field (or NULL )
*/ */
LibDrawField* WinEDA_LibeditFrame::LocateField( EDA_LibComponentStruct* LibEntry ) LibDrawField* WinEDA_LibeditFrame::LocateField( LIB_COMPONENT* LibEntry )
{ {
wxPoint refpos = GetScreen()->m_Curseur; wxPoint refpos = GetScreen()->m_Curseur;
/* Test reference */ /* Test reference */
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
#include "bitmaps.h" #include "bitmaps.h"
#include "protos.h" #include "protos.h"
#include "id.h" #include "id.h"
#include "class_library.h"
#include <boost/foreach.hpp>
/* Library editor wxConfig entry names. */ /* Library editor wxConfig entry names. */
...@@ -147,6 +150,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father, ...@@ -147,6 +150,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
ReCreateHToolbar(); ReCreateHToolbar();
ReCreateVToolbar(); ReCreateVToolbar();
DisplayLibInfos(); DisplayLibInfos();
DisplayCmpDoc();
UpdateAliasSelectList(); UpdateAliasSelectList();
UpdatePartSelectList(); UpdatePartSelectList();
BestZoom(); BestZoom();
...@@ -204,8 +208,6 @@ void WinEDA_LibeditFrame::SaveSettings() ...@@ -204,8 +208,6 @@ void WinEDA_LibeditFrame::SaveSettings()
void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event ) void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
{ {
LibraryStruct* Lib;
if( GetScreen()->IsModify() ) if( GetScreen()->IsModify() )
{ {
if( !IsOK( this, _( "Component was modified!\nDiscard changes?" ) ) ) if( !IsOK( this, _( "Component was modified!\nDiscard changes?" ) ) )
...@@ -217,13 +219,13 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -217,13 +219,13 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
GetScreen()->ClrModify(); GetScreen()->ClrModify();
} }
for( Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext ) BOOST_FOREACH( const CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
{ {
if( Lib->IsModified() ) if( lib.IsModified() )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ), msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ),
Lib->m_Name.GetData() ); (const wxChar*) lib.GetName() );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
{ {
Event.Veto(); Event.Veto();
...@@ -358,7 +360,8 @@ void WinEDA_LibeditFrame::OnUpdateRedo( wxUpdateUIEvent& event ) ...@@ -358,7 +360,8 @@ void WinEDA_LibeditFrame::OnUpdateRedo( wxUpdateUIEvent& event )
void WinEDA_LibeditFrame::OnUpdateSaveCurrentLib( wxUpdateUIEvent& event ) void WinEDA_LibeditFrame::OnUpdateSaveCurrentLib( wxUpdateUIEvent& event )
{ {
event.Enable( CurrentLib != NULL ); event.Enable( CurrentLib != NULL
&& ( CurrentLib->IsModified() || GetScreen()->IsModify() ) );
} }
...@@ -370,7 +373,7 @@ void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event ) ...@@ -370,7 +373,7 @@ void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event )
{ {
if( !CurrentAliasName.IsEmpty() ) if( !CurrentAliasName.IsEmpty() )
{ {
LibCmpEntry* entry = CurrentLib->FindEntry( CurrentAliasName ); CMP_LIB_ENTRY* entry = CurrentLib->FindEntry( CurrentAliasName );
if( entry != NULL ) if( entry != NULL )
enable = !entry->m_DocFile.IsEmpty(); enable = !entry->m_DocFile.IsEmpty();
...@@ -452,11 +455,9 @@ void WinEDA_LibeditFrame::OnSelectAlias( wxCommandEvent& event ) ...@@ -452,11 +455,9 @@ void WinEDA_LibeditFrame::OnSelectAlias( wxCommandEvent& event )
if( m_SelAliasBox->GetStringSelection().CmpNoCase(CurrentLibEntry->GetName() ) == 0 ) if( m_SelAliasBox->GetStringSelection().CmpNoCase(CurrentLibEntry->GetName() ) == 0 )
CurrentAliasName.Empty(); CurrentAliasName.Empty();
else else
{
CurrentAliasName = m_SelAliasBox->GetStringSelection(); CurrentAliasName = m_SelAliasBox->GetStringSelection();
DisplayCmpDoc( CurrentAliasName );
}
DisplayCmpDoc();
DrawPanel->Refresh(); DrawPanel->Refresh();
} }
...@@ -464,11 +465,14 @@ void WinEDA_LibeditFrame::OnSelectAlias( wxCommandEvent& event ) ...@@ -464,11 +465,14 @@ void WinEDA_LibeditFrame::OnSelectAlias( wxCommandEvent& event )
void WinEDA_LibeditFrame::OnSelectPart( wxCommandEvent& event ) void WinEDA_LibeditFrame::OnSelectPart( wxCommandEvent& event )
{ {
int i = event.GetSelection(); int i = event.GetSelection();
if( i < 0 )
if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == CurrentUnit ) )
return; return;
LibItemToRepeat = NULL; LibItemToRepeat = NULL;
CurrentUnit = i + 1; CurrentUnit = i + 1;
DrawPanel->Refresh(); DrawPanel->Refresh();
DisplayCmpDoc();
} }
...@@ -585,7 +589,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -585,7 +589,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
wxString docfilename; wxString docfilename;
if( !CurrentAliasName.IsEmpty() ) if( !CurrentAliasName.IsEmpty() )
{ {
LibCmpEntry* entry = CurrentLib->FindEntry( CurrentAliasName ); CMP_LIB_ENTRY* entry = CurrentLib->FindEntry( CurrentAliasName );
if( entry != NULL ) if( entry != NULL )
docfilename = entry->m_DocFile; docfilename = entry->m_DocFile;
} }
......
...@@ -614,7 +614,7 @@ static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1, ...@@ -614,7 +614,7 @@ static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
/*********************************************************************************/ /*********************************************************************************/
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen, LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
const wxPoint& aRefPoint, const wxPoint& aRefPoint,
EDA_LibComponentStruct* LibEntry, LIB_COMPONENT* LibEntry,
int Unit, int Unit,
int Convert, int Convert,
int masque ) int masque )
...@@ -718,11 +718,11 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number, ...@@ -718,11 +718,11 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
*/ */
{ {
LibEDA_BaseStruct* DrawItem; LibEDA_BaseStruct* DrawItem;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
LibDrawPin* Pin; LibDrawPin* Pin;
int Unit, Convert; int Unit, Convert;
Entry = ( EDA_LibComponentStruct* )FindLibPart( eComponent->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( eComponent->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
return NULL; return NULL;
...@@ -760,8 +760,7 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number, ...@@ -760,8 +760,7 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
/*******************************************************************/ /*******************************************************************/
LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos, LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos, LIB_COMPONENT* Entry,
EDA_LibComponentStruct* Entry,
int Unit, int convert, SCH_COMPONENT* DrawLibItem ) int Unit, int convert, SCH_COMPONENT* DrawLibItem )
/*******************************************************************/ /*******************************************************************/
...@@ -850,7 +849,7 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos, ...@@ -850,7 +849,7 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos,
/**************************************************************************/ /**************************************************************************/
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* DrawStruct;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
SCH_COMPONENT* LibItem = NULL; SCH_COMPONENT* LibItem = NULL;
LibDrawPin* Pin = NULL; LibDrawPin* Pin = NULL;
...@@ -859,7 +858,7 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos, ...@@ -859,7 +858,7 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos,
if( DrawStruct->Type() != TYPE_SCH_COMPONENT ) if( DrawStruct->Type() != TYPE_SCH_COMPONENT )
continue; continue;
LibItem = (SCH_COMPONENT*) DrawStruct; LibItem = (SCH_COMPONENT*) DrawStruct;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( LibItem->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( LibItem->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
continue; continue;
......
...@@ -29,7 +29,7 @@ static void AddPinToComponentPinList( SCH_COMPONENT* Component, ...@@ -29,7 +29,7 @@ static void AddPinToComponentPinList( SCH_COMPONENT* Component,
DrawSheetPath* sheet, DrawSheetPath* sheet,
LibDrawPin* PinEntry ); LibDrawPin* PinEntry );
static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component, static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component,
EDA_LibComponentStruct* Entry, LIB_COMPONENT* Entry,
DrawSheetPath* Sheet_in ); DrawSheetPath* Sheet_in );
static bool SortPinsByNum( NETLIST_OBJECT* Pin1, NETLIST_OBJECT* Pin2 ); static bool SortPinsByNum( NETLIST_OBJECT* Pin1, NETLIST_OBJECT* Pin2 );
static void EraseDuplicatePins( NETLIST_OBJECT_LIST& aPinList ); static void EraseDuplicatePins( NETLIST_OBJECT_LIST& aPinList );
...@@ -109,7 +109,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( ...@@ -109,7 +109,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
*/ */
{ {
SCH_COMPONENT* Component = NULL; SCH_COMPONENT* Component = NULL;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
LibEDA_BaseStruct* DEntry; LibEDA_BaseStruct* DEntry;
s_SortedComponentPinList.clear(); s_SortedComponentPinList.clear();
...@@ -130,7 +130,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( ...@@ -130,7 +130,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
// removed because with multiple instances of one schematic // removed because with multiple instances of one schematic
// (several sheets pointing to 1 screen), this will be erroneously be toggled. // (several sheets pointing to 1 screen), this will be erroneously be toggled.
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Component->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( Component->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
continue; continue;
...@@ -550,8 +550,8 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with ...@@ -550,8 +550,8 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
break; break;
/* Get the Component FootprintFilter and put the component in CmpList if filter is not void */ /* Get the Component FootprintFilter and put the component in CmpList if filter is not void */
EDA_LibComponentStruct* Entry = LIB_COMPONENT* Entry =
( EDA_LibComponentStruct* ) FindLibPart( Component->m_ChipName ); CMP_LIBRARY::FindLibraryComponent( Component->m_ChipName );
if( Entry != NULL ) if( Entry != NULL )
{ {
...@@ -628,11 +628,11 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with ...@@ -628,11 +628,11 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
if( with_pcbnew && CmpList ) if( with_pcbnew && CmpList )
{ {
fprintf( f, "{ Allowed footprints by component:\n" ); fprintf( f, "{ Allowed footprints by component:\n" );
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
for( int ii = 0; ii < CmpListCount; ii++ ) for( int ii = 0; ii < CmpListCount; ii++ )
{ {
Component = CmpList[ii].m_RootCmp; Component = CmpList[ii].m_RootCmp;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Component->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( Component->m_ChipName );
//Line.Printf(_("%s"), CmpList[ii].m_Ref); //Line.Printf(_("%s"), CmpList[ii].m_Ref);
//Line.Replace( wxT( " " ), wxT( "_" ) ); //Line.Replace( wxT( " " ), wxT( "_" ) );
...@@ -755,7 +755,7 @@ static void EraseDuplicatePins( NETLIST_OBJECT_LIST& aPinList ) ...@@ -755,7 +755,7 @@ static void EraseDuplicatePins( NETLIST_OBJECT_LIST& aPinList )
/**********************************************************************************/ /**********************************************************************************/
static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in, static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in,
EDA_LibComponentStruct* Entry, LIB_COMPONENT* Entry,
DrawSheetPath* Sheet_in ) DrawSheetPath* Sheet_in )
/**********************************************************************************/ /**********************************************************************************/
......
...@@ -353,7 +353,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist, ...@@ -353,7 +353,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
SCH_ITEM* DrawList; SCH_ITEM* DrawList;
NETLIST_OBJECT* new_item; NETLIST_OBJECT* new_item;
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
LibEDA_BaseStruct* DEntry; LibEDA_BaseStruct* DEntry;
Hierarchical_PIN_Sheet_Struct* SheetLabel; Hierarchical_PIN_Sheet_Struct* SheetLabel;
DrawSheetPath list; DrawSheetPath list;
...@@ -472,8 +472,8 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist, ...@@ -472,8 +472,8 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) DrawList; DrawLibItem = (SCH_COMPONENT*) DrawList;
Entry = ( EDA_LibComponentStruct* )FindLibPart( Entry =
DrawLibItem->m_ChipName ); CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
break; break;
......
...@@ -44,7 +44,7 @@ class OBJ_CMP_TO_LIST ...@@ -44,7 +44,7 @@ class OBJ_CMP_TO_LIST
{ {
public: public:
SCH_COMPONENT* m_RootCmp; // the component in schematic SCH_COMPONENT* m_RootCmp; // the component in schematic
EDA_LibComponentStruct* m_Entry; // the source component in library LIB_COMPONENT* m_Entry; // the source component in library
int m_Unit; /* Selected part (For multi parts per package) depending on sheet path */ int m_Unit; /* Selected part (For multi parts per package) depending on sheet path */
DrawSheetPath m_SheetPath; /* the sheet path for this component */ DrawSheetPath m_SheetPath; /* the sheet path for this component */
unsigned long m_TimeStamp; /* unique identification number depending on sheet path */ unsigned long m_TimeStamp; /* unique identification number depending on sheet path */
......
...@@ -25,8 +25,10 @@ static void AddMenusForWire( wxMenu* PopMenu, EDA_DrawLineStruct* Wire, ...@@ -25,8 +25,10 @@ static void AddMenusForWire( wxMenu* PopMenu, EDA_DrawLineStruct* Wire,
WinEDA_SchematicFrame* frame ); WinEDA_SchematicFrame* frame );
static void AddMenusForBus( wxMenu* PopMenu, EDA_DrawLineStruct* Bus, static void AddMenusForBus( wxMenu* PopMenu, EDA_DrawLineStruct* Bus,
WinEDA_SchematicFrame* frame ); WinEDA_SchematicFrame* frame );
static void AddMenusForHierchicalSheet( wxMenu* PopMenu, DrawSheetStruct* Sheet ); static void AddMenusForHierchicalSheet( wxMenu* PopMenu,
static void AddMenusForPinSheet( wxMenu* PopMenu, Hierarchical_PIN_Sheet_Struct* PinSheet ); DrawSheetStruct* Sheet );
static void AddMenusForPinSheet( wxMenu* PopMenu,
Hierarchical_PIN_Sheet_Struct* PinSheet );
static void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ); static void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text );
static void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label ); static void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label );
static void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel ); static void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel );
...@@ -42,15 +44,15 @@ static void AddMenusForMarkers( wxMenu* aPopMenu, MARKER_SCH* aMarker, ...@@ -42,15 +44,15 @@ static void AddMenusForMarkers( wxMenu* aPopMenu, MARKER_SCH* aMarker,
/*****************************************************************/ /*****************************************************************/
bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
wxMenu* PopMenu ) wxMenu* PopMenu )
{
/*****************************************************************/ /*****************************************************************/
/* Prepare le menu PullUp affich� par un click sur le bouton droit /* Prepare le menu PullUp affich� par un click sur le bouton droit
* de la souris. * de la souris.
* Ce menu est ensuite compl�t� par la liste des commandes de ZOOM * Ce menu est ensuite compl�t� par la liste des commandes de ZOOM
*/ */
{
SCH_ITEM* DrawStruct = (SCH_ITEM*) GetScreen()->GetCurItem(); SCH_ITEM* DrawStruct = (SCH_ITEM*) GetScreen()->GetCurItem();
bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE); bool BlockActive =
(GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu
...@@ -62,8 +64,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -62,8 +64,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
return true; return true;
} }
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) // Just try to locate items at cursor position
{ // Just try to locate items at cursor position {
DrawStruct = SchematicGeneralLocateAndDisplay( false ); DrawStruct = SchematicGeneralLocateAndDisplay( false );
if( DrawStruct && (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) ) if( DrawStruct && (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) )
{ {
...@@ -80,11 +82,13 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -80,11 +82,13 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
{ {
if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel" ), cancel_xpm );
} }
else else
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, _( "End Tool" ), cancel_tool_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_CLOSE_CURRENT_TOOL,
_( "End Tool" ), cancel_tool_xpm );
} }
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
} }
...@@ -92,7 +96,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -92,7 +96,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
{ {
if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel" ), cancel_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
} }
} }
...@@ -101,7 +106,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -101,7 +106,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
{ {
if( GetSheet()->Last() != g_RootSheet ) if( GetSheet()->Last() != g_RootSheet )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_LEAVE_SHEET, _( "Leave Sheet" ), leave_sheet_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_LEAVE_SHEET,
_( "Leave Sheet" ), leave_sheet_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
} }
return true; return true;
...@@ -117,7 +123,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -117,7 +123,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
case DRAW_NOCONNECT_STRUCT_TYPE: case DRAW_NOCONNECT_STRUCT_TYPE:
// if( !flags ) PopMenu->Append(ID_POPUP_SCH_MOVE_ITEM_REQUEST, "Move Noconnect"); // if( !flags ) PopMenu->Append(ID_POPUP_SCH_MOVE_ITEM_REQUEST, "Move Noconnect");
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Noconn" ), delete_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Noconn" ),
delete_xpm );
break; break;
case DRAW_JUNCTION_STRUCT_TYPE: case DRAW_JUNCTION_STRUCT_TYPE:
...@@ -129,9 +136,11 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -129,9 +136,11 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
_( "Move Bus Entry" ), move_xpm ); _( "Move Bus Entry" ), move_xpm );
if( GetBusEntryShape( (DrawBusEntryStruct*) DrawStruct ) == '\\' ) if( GetBusEntryShape( (DrawBusEntryStruct*) DrawStruct ) == '\\' )
PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_SLASH, _( "Set Bus Entry /" ) ); PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_SLASH,
_( "Set Bus Entry /" ) );
else else
PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, _( "Set Bus Entry \\" ) ); PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH,
_( "Set Bus Entry \\" ) );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "Delete Bus Entry" ), delete_bus_xpm ); _( "Delete Bus Entry" ), delete_bus_xpm );
break; break;
...@@ -163,7 +172,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -163,7 +172,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
break; break;
// Many fields are inside a component. If this is the case, add the component menu // Many fields are inside a component. If this is the case, add the component menu
SCH_COMPONENT* Component = LocateSmallestComponent( (SCH_SCREEN*) GetScreen() ); SCH_COMPONENT* Component = LocateSmallestComponent(
(SCH_SCREEN*) GetScreen() );
if( Component ) if( Component )
{ {
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
...@@ -177,6 +187,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -177,6 +187,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
break; break;
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
// if( !flags ) PopMenu->Append(ID_POPUP_SCH_MOVE_ITEM_REQUEST, "Move"); // if( !flags ) PopMenu->Append(ID_POPUP_SCH_MOVE_ITEM_REQUEST, "Move");
switch( DrawStruct->GetLayer() ) switch( DrawStruct->GetLayer() )
{ {
...@@ -190,7 +201,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -190,7 +201,8 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
default: default:
if( is_new ) if( is_new )
ADD_MENUITEM( PopMenu, ID_POPUP_END_LINE, _( "End Drawing" ), apply_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_END_LINE, _( "End Drawing" ),
apply_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "Delete Drawing" ), delete_xpm ); _( "Delete Drawing" ), delete_xpm );
break; break;
...@@ -203,13 +215,14 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -203,13 +215,14 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
break; break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
AddMenusForPinSheet( PopMenu, (Hierarchical_PIN_Sheet_Struct*) DrawStruct ); AddMenusForPinSheet( PopMenu,
(Hierarchical_PIN_Sheet_Struct*) DrawStruct );
break; break;
default: default:
wxString msg; wxString msg;
msg.Printf( msg.Printf( wxT( "WinEDA_SchematicFrame::OnRightClick Error: unknown \
wxT( "WinEDA_SchematicFrame::OnRightClick Error: unknown DrawType %d" ), DrawType %d" ),
DrawStruct->Type() ); DrawStruct->Type() );
DisplayError( this, msg ); DisplayError( this, msg );
break; break;
...@@ -222,25 +235,26 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -222,25 +235,26 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
/*************************************************************************/ /*************************************************************************/
void AddMenusForComponentField( wxMenu* PopMenu, SCH_CMP_FIELD* Field ) void AddMenusForComponentField( wxMenu* PopMenu, SCH_CMP_FIELD* Field )
{
/*************************************************************************/ /*************************************************************************/
/* Add menu commands for a component field (like value, reference) /* Add menu commands for a component field (like value, reference)
*/ */
{
if( !Field->m_Flags ) if( !Field->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Field" ), move_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_FIELD, _( "Rotate Field" ), rotate_field_xpm ); _( "Move Field" ), move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_FIELD, _( "Edit Field" ), edit_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_FIELD,
_( "Rotate Field" ), rotate_field_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_FIELD,
_( "Edit Field" ), edit_text_xpm );
} }
/**************************************************************************/ /**************************************************************************/
void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
{
/**************************************************************************/ /**************************************************************************/
/* Add menu commands for a component /* Add menu commands for a component
*/ */
{
if( Component->Type() != TYPE_SCH_COMPONENT ) if( Component->Type() != TYPE_SCH_COMPONENT )
{ {
wxASSERT( 0 ); wxASSERT( 0 );
...@@ -248,102 +262,128 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) ...@@ -248,102 +262,128 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
} }
wxString msg; wxString msg;
CMP_LIB_ENTRY* libEntry;
LIB_COMPONENT* libComponent = NULL;
EDA_LibComponentStruct* LibEntry; libEntry = CMP_LIBRARY::FindLibraryEntry( Component->m_ChipName );
LibEntry = ( EDA_LibComponentStruct* ) FindLibPart( Component->m_ChipName ); if( libEntry )
{
if( libEntry->Type == ALIAS )
libComponent = ( (LIB_ALIAS*) libEntry )->GetComponent();
else
libComponent = (LIB_COMPONENT*) libEntry;
}
if( !Component->m_Flags ) if( !Component->m_Flags )
{ {
msg = _( "Move Component" ); msg = _( "Move Component" );
msg << wxT(" ") << Component->GetField( REFERENCE )->m_Text; msg << wxT( " " ) << Component->GetField( REFERENCE )->m_Text;
msg = AddHotkeyName( msg, s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT ); msg = AddHotkeyName( msg, s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_CMP_REQUEST,
msg, move_xpm ); msg, move_xpm );
msg = AddHotkeyName( _( "Drag Component" ), s_Schematic_Hokeys_Descr, HK_DRAG_COMPONENT ); msg = AddHotkeyName( _( "Drag Component" ), s_Schematic_Hokeys_Descr,
HK_DRAG_COMPONENT );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST,
msg, move_xpm ); msg, move_xpm );
} }
// add menu orient et sous menu: // add menu orient et sous menu:
wxMenu* orientmenu = new wxMenu; wxMenu* orientmenu = new wxMenu;
msg = AddHotkeyName( _( "Rotate +" ), s_Schematic_Hokeys_Descr, HK_ROTATE_COMPONENT ); msg = AddHotkeyName( _( "Rotate +" ), s_Schematic_Hokeys_Descr,
HK_ROTATE_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE, ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE,
msg, rotate_pos_xpm ); msg, rotate_pos_xpm );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, _( "Rotate -" ), rotate_neg_xpm ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE,
msg = AddHotkeyName( _( "Mirror --" ), s_Schematic_Hokeys_Descr, HK_MIRROR_X_COMPONENT ); _( "Rotate -" ), rotate_neg_xpm );
msg = AddHotkeyName( _( "Mirror --" ), s_Schematic_Hokeys_Descr,
HK_MIRROR_X_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_X_CMP, msg, mirror_V_xpm ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_X_CMP, msg, mirror_V_xpm );
msg = AddHotkeyName( _( "Mirror ||" ), s_Schematic_Hokeys_Descr, HK_MIRROR_Y_COMPONENT ); msg = AddHotkeyName( _( "Mirror ||" ), s_Schematic_Hokeys_Descr,
HK_MIRROR_Y_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_Y_CMP, msg, mirror_H_xpm ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_MIROR_Y_CMP, msg, mirror_H_xpm );
msg = AddHotkeyName( _( "Normal" ), s_Schematic_Hokeys_Descr, HK_ORIENT_NORMAL_COMPONENT ); msg = AddHotkeyName( _( "Normal" ), s_Schematic_Hokeys_Descr,
HK_ORIENT_NORMAL_COMPONENT );
ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ORIENT_NORMAL_CMP, msg, normal_xpm ); ADD_MENUITEM( orientmenu, ID_POPUP_SCH_ORIENT_NORMAL_CMP, msg, normal_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, orientmenu, ADD_MENUITEM_WITH_SUBMENU( PopMenu, orientmenu,
ID_POPUP_SCH_GENERIC_ORIENT_CMP, _( ID_POPUP_SCH_GENERIC_ORIENT_CMP,
"Orient Component" ), orient_xpm ); _( "Orient Component" ), orient_xpm );
wxMenu* editmenu = new wxMenu; wxMenu* editmenu = new wxMenu;
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CMP, _( "Edit" ), edit_component_xpm ); ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CMP, _( "Edit" ),
edit_component_xpm );
if( LibEntry && LibEntry->m_Options != ENTRY_POWER ) if( libEntry && libEntry->m_Options != ENTRY_POWER )
{ {
msg = AddHotkeyName( _( "Value " ), s_Schematic_Hokeys_Descr, HK_EDIT_COMPONENT_VALUE ); msg = AddHotkeyName( _( "Value " ), s_Schematic_Hokeys_Descr,
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_VALUE_CMP, msg, edit_comp_value_xpm ); HK_EDIT_COMPONENT_VALUE );
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_VALUE_CMP, msg,
edit_comp_value_xpm );
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_REF_CMP, _( "Reference" ), edit_comp_ref_xpm ); ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_REF_CMP,
_( "Reference" ), edit_comp_ref_xpm );
msg = AddHotkeyName( _( msg = AddHotkeyName( _( "Footprint " ), s_Schematic_Hokeys_Descr,
"Footprint " ), s_Schematic_Hokeys_Descr,
HK_EDIT_COMPONENT_FOOTPRINT ); HK_EDIT_COMPONENT_FOOTPRINT );
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_FOOTPRINT_CMP, msg, edit_comp_footprint_xpm ); ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_FOOTPRINT_CMP, msg,
edit_comp_footprint_xpm );
} }
if( LibEntry && (LookForConvertPart( LibEntry ) >= 2) )
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CONVERT_CMP,_( "Convert" ), component_select_alternate_shape_xpm );
if( LibEntry && (LibEntry->m_UnitCount >= 2) ) if( libComponent && libComponent->HasConversion() )
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CONVERT_CMP,
_( "Convert" ), component_select_alternate_shape_xpm );
if( libComponent && ( libComponent->m_UnitCount >= 2 ) )
{ {
wxMenu* sel_unit_menu = new wxMenu; int ii; wxMenu* sel_unit_menu = new wxMenu; int ii;
for( ii = 0; ii < LibEntry->m_UnitCount; ii++ ) for( ii = 0; ii < libComponent->m_UnitCount; ii++ )
{ {
wxString num_unit; num_unit.Printf( _( wxString num_unit;
"Unit %d %c" ), ii + 1, num_unit.Printf( _( "Unit %d %c" ), ii + 1,
"?ABCDEFGHIJKLMNOPQRSTUVWXYZ"[ii + 1] ); "?ABCDEFGHIJKLMNOPQRSTUVWXYZ"[ ii + 1 ] );
sel_unit_menu->Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, sel_unit_menu->Append( ID_POPUP_SCH_SELECT_UNIT1 + ii, num_unit );
num_unit );
} }
ADD_MENUITEM_WITH_SUBMENU( editmenu, sel_unit_menu, ID_POPUP_SCH_SELECT_UNIT_CMP, _( "Unit" ), component_select_unit_xpm );
ADD_MENUITEM_WITH_SUBMENU( editmenu, sel_unit_menu,
ID_POPUP_SCH_SELECT_UNIT_CMP,
_( "Unit" ), component_select_unit_xpm );
} }
ADD_MENUITEM_WITH_SUBMENU( PopMenu, editmenu, ADD_MENUITEM_WITH_SUBMENU( PopMenu, editmenu,
ID_POPUP_SCH_GENERIC_EDIT_CMP, _( ID_POPUP_SCH_GENERIC_EDIT_CMP,
"Edit Component" ), edit_component_xpm ); _( "Edit Component" ), edit_component_xpm );
if( !Component->m_Flags ) if( !Component->m_Flags )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_COMPONENT_CMP, _( "Copy Component" ), import_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_COMPONENT_CMP,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CMP, _( "Delete Component" ), delete_xpm ); _( "Copy Component" ), import_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CMP,
_( "Delete Component" ), delete_xpm );
} }
LibEntry = ( EDA_LibComponentStruct* ) FindLibPart( Component->m_ChipName, if( libEntry && !libEntry->m_DocFile.IsEmpty() )
wxEmptyString, ALIAS ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Doc" ),
if( LibEntry && !LibEntry->m_DocFile.IsEmpty() ) datasheet_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Doc" ), datasheet_xpm );
} }
/*******************************************************************/ /*******************************************************************/
void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel ) void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
{
/*******************************************************************/ /*******************************************************************/
/* Add menu commands for a Global Label /* Add menu commands for a Global Label
*/ */
{
wxMenu* menu_change_type = new wxMenu; wxMenu* menu_change_type = new wxMenu;
if( !GLabel->m_Flags ) if( !GLabel->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Global Label" ), move_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate Global Label" ), rotate_glabel_xpm ); _( "Move Global Label" ), move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit Global Label" ), edit_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Global Label" ), delete_text_xpm ); _( "Rotate Global Label" ), rotate_glabel_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
_( "Edit Global Label" ), edit_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "Delete Global Label" ), delete_text_xpm );
// add menu change type text (to label, glabel, text): // add menu change type text (to label, glabel, text):
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
...@@ -353,24 +393,28 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel ) ...@@ -353,24 +393,28 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
_( "Change to Text" ), glabel2text_xpm ); _( "Change to Text" ), glabel2text_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm ); ID_POPUP_SCH_CHANGE_TYPE_TEXT,
_( "Change Type" ), gl_change_xpm );
} }
/*******************************************************************/ /*******************************************************************/
void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel ) void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
{
/*******************************************************************/ /*******************************************************************/
/* Add menu commands for a hierarchical Label /* Add menu commands for a hierarchical Label
*/ */
{
wxMenu* menu_change_type = new wxMenu; wxMenu* menu_change_type = new wxMenu;
if( !HLabel->m_Flags ) if( !HLabel->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Hierarchical Label" ), move_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate Hierarchical Label" ), rotate_glabel_xpm ); _( "Move Hierarchical Label" ), move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit Hierarchical Label" ), edit_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Hierarchical label" ), delete_text_xpm ); _( "Rotate Hierarchical Label" ), rotate_glabel_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
_( "Edit Hierarchical Label" ), edit_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "Delete Hierarchical label" ), delete_text_xpm );
// add menu change type text (to label, glabel, text): // add menu change type text (to label, glabel, text):
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
...@@ -380,24 +424,28 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel ) ...@@ -380,24 +424,28 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
_( "Change to Global Label" ), label2glabel_xpm ); _( "Change to Global Label" ), label2glabel_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm ); ID_POPUP_SCH_CHANGE_TYPE_TEXT,
_( "Change Type" ), gl_change_xpm );
} }
/*****************************************************************/ /*****************************************************************/
void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label ) void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
{
/*****************************************************************/ /*****************************************************************/
/* Add menu commands for a Label /* Add menu commands for a Label
*/ */
{
wxMenu* menu_change_type = new wxMenu; wxMenu* menu_change_type = new wxMenu;
if( !Label->m_Flags ) if( !Label->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Label" ), move_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate Label" ), rotate_pos_xpm ); _( "Move Label" ), move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit Label" ), edit_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Label" ), delete_text_xpm ); _( "Rotate Label" ), rotate_pos_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
_( "Edit Label" ), edit_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
_( "Delete Label" ), delete_text_xpm );
// add menu change type text (to label, glabel, text): // add menu change type text (to label, glabel, text):
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
...@@ -407,38 +455,46 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label ) ...@@ -407,38 +455,46 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
_( "Change to Global Label" ), label2glabel_xpm ); _( "Change to Global Label" ), label2glabel_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm ); ID_POPUP_SCH_CHANGE_TYPE_TEXT,
_( "Change Type" ), gl_change_xpm );
} }
/*****************************************************************/ /*****************************************************************/
void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ) void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
{
/*****************************************************************/ /*****************************************************************/
/* Add menu commands for a Text (a comment) /* Add menu commands for a Text (a comment)
*/ */
{
wxMenu* menu_change_type = new wxMenu; wxMenu* menu_change_type = new wxMenu;
if( !Text->m_Flags ) if( !Text->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Text" ), move_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate Text" ), rotate_pos_xpm ); _( "Move Text" ), move_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit Text" ), edit_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ROTATE_TEXT, _( "Rotate Text" ),
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Text" ), delete_text_xpm ); rotate_pos_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, _( "Edit Text" ),
edit_text_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Text" ),
delete_text_xpm );
/* add menu change type text (to label, glabel, text), /* add menu change type text (to label, glabel, text),
* but only if this is a single line text * but only if this is a single line text
*/ */
if( Text->m_Text.Find( wxT("\n") ) == wxNOT_FOUND ) if( Text->m_Text.Find( wxT( "\n" ) ) == wxNOT_FOUND )
{ {
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL, ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
_( "Change to Label" ), label2text_xpm ); _( "Change to Label" ), label2text_xpm );
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL, ADD_MENUITEM( menu_change_type,
_( "Change to Hierarchical Label" ), label2glabel_xpm ); ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL, _( "Change to Hierarchical Label" ),
label2glabel_xpm );
ADD_MENUITEM( menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
_( "Change to Glabel" ), label2glabel_xpm ); _( "Change to Glabel" ), label2glabel_xpm );
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type, ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_change_type,
ID_POPUP_SCH_CHANGE_TYPE_TEXT, _( "Change Type" ), gl_change_xpm ); ID_POPUP_SCH_CHANGE_TYPE_TEXT,
_( "Change Type" ), gl_change_xpm );
} }
} }
...@@ -446,28 +502,30 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ) ...@@ -446,28 +502,30 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
/*****************************************************************/ /*****************************************************************/
void AddMenusForJunction( wxMenu* PopMenu, DrawJunctionStruct* Junction, void AddMenusForJunction( wxMenu* PopMenu, DrawJunctionStruct* Junction,
WinEDA_SchematicFrame* frame ) WinEDA_SchematicFrame* frame )
{
/*****************************************************************/ /*****************************************************************/
/* Add menu commands for a junction /* Add menu commands for a junction
*/ */
{
bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE; bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE;
if( !is_new ) if( !is_new )
{ {
if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(),
WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) ) WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE,
_( "Break Wire" ), break_line_xpm );
} }
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Junction" ), delete_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Junction" ),
delete_xpm );
if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(),
WIREITEM | BUSITEM ) ) WIREITEM | BUSITEM ) )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), delete_node_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE,
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( _( "Delete Node" ), delete_node_xpm );
"Delete Connection" ), delete_connection_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION,
_( "Delete Connection" ), delete_connection_xpm );
} }
} }
...@@ -475,11 +533,10 @@ void AddMenusForJunction( wxMenu* PopMenu, DrawJunctionStruct* Junction, ...@@ -475,11 +533,10 @@ void AddMenusForJunction( wxMenu* PopMenu, DrawJunctionStruct* Junction,
/*****************************************************************/ /*****************************************************************/
void AddMenusForWire( wxMenu* PopMenu, EDA_DrawLineStruct* Wire, void AddMenusForWire( wxMenu* PopMenu, EDA_DrawLineStruct* Wire,
WinEDA_SchematicFrame* frame ) WinEDA_SchematicFrame* frame )
{
/*****************************************************************/ /*****************************************************************/
/* Add menu commands for a wire /* Add menu commands for a wire
*/ */
{
bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE; bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE;
wxPoint pos = frame->GetScreen()->m_Curseur; wxPoint pos = frame->GetScreen()->m_Curseur;
...@@ -489,37 +546,42 @@ void AddMenusForWire( wxMenu* PopMenu, EDA_DrawLineStruct* Wire, ...@@ -489,37 +546,42 @@ void AddMenusForWire( wxMenu* PopMenu, EDA_DrawLineStruct* Wire,
return; return;
} }
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_WIRE_REQUEST, _( "Drag Wire" ), move_track_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_WIRE_REQUEST, _( "Drag Wire" ),
move_track_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Wire" ), delete_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Wire" ), delete_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), delete_node_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ),
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( delete_node_xpm );
"Delete Connection" ), delete_connection_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION,
_( "Delete Connection" ), delete_connection_xpm );
if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(), if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(),
WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) ) WIREITEM | BUSITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ),
break_line_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add Junction" ), add_junction_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add Junction" ),
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add Label" ), add_line_label_xpm ); add_junction_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add Label" ),
add_line_label_xpm );
// Place Global label command only if the cursor is over one end of the Wire: // Place Global label command only if the cursor is over one end of the Wire:
if( ( pos.x == Wire->m_Start.x && pos.y == Wire->m_Start.y) if( ( pos.x == Wire->m_Start.x && pos.y == Wire->m_Start.y)
|| ( pos.x == Wire->m_End.x && pos.y == Wire->m_End.y ) ) || ( pos.x == Wire->m_End.x && pos.y == Wire->m_End.y ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ), add_glabel_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL,
_( "Add Global Label" ), add_glabel_xpm );
} }
/*****************************************************************/ /*****************************************************************/
void AddMenusForBus( wxMenu* PopMenu, EDA_DrawLineStruct* Bus, void AddMenusForBus( wxMenu* PopMenu, EDA_DrawLineStruct* Bus,
WinEDA_SchematicFrame* frame ) WinEDA_SchematicFrame* frame )
{
/*****************************************************************/ /*****************************************************************/
/* Add menu commands for a Bus /* Add menu commands for a Bus
*/ */
{
bool is_new = (Bus->m_Flags & IS_NEW) ? TRUE : FALSE; bool is_new = (Bus->m_Flags & IS_NEW) ? TRUE : FALSE;
wxPoint pos = frame->GetScreen()->m_Curseur; wxPoint pos = frame->GetScreen()->m_Curseur;
...@@ -529,116 +591,131 @@ void AddMenusForBus( wxMenu* PopMenu, EDA_DrawLineStruct* Bus, ...@@ -529,116 +591,131 @@ void AddMenusForBus( wxMenu* PopMenu, EDA_DrawLineStruct* Bus,
return; return;
} }
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Bus" ),
_( "Delete Bus" ), delete_bus_xpm ); delete_bus_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Bus" ),
_( "Break Bus" ), break_bus_xpm ); break_bus_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add Junction" ), add_junction_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_JUNCTION, _( "Add Junction" ),
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add Label" ), add_line_label_xpm ); add_junction_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_LABEL, _( "Add Label" ),
add_line_label_xpm );
// Place Global label command only if the cursor is over one end of the Bus: // Place Global label command only if the cursor is over one end of the Bus:
if( ( pos.x == Bus->m_Start.x && pos.y == Bus->m_Start.y) if( ( pos.x == Bus->m_Start.x && pos.y == Bus->m_Start.y)
|| ( pos.x == Bus->m_End.x && pos.y == Bus->m_End.y ) ) || ( pos.x == Bus->m_End.x && pos.y == Bus->m_End.y ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ), add_glabel_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ADD_GLABEL,
_( "Add Global Label" ), add_glabel_xpm );
} }
/************************************************************************/ /************************************************************************/
void AddMenusForHierchicalSheet( wxMenu* PopMenu, DrawSheetStruct* Sheet ) void AddMenusForHierchicalSheet( wxMenu* PopMenu, DrawSheetStruct* Sheet )
{
/************************************************************************/ /************************************************************************/
/* Add menu commands for a Sheet /* Add menu commands for a Sheet
*/ */
{
if( !Sheet->m_Flags ) if( !Sheet->m_Flags )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ENTER_SHEET, _( "Enter Sheet" ), enter_sheet_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ENTER_SHEET,
_( "Enter Sheet" ), enter_sheet_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, _( "Move Sheet" ), move_sheet_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
_( "Move Sheet" ), move_sheet_xpm );
} }
if( Sheet->m_Flags ) if( Sheet->m_Flags )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_END_SHEET, _( "Place Sheet" ), apply_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_END_SHEET, _( "Place Sheet" ),
apply_xpm );
} }
else else
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_SHEET, _( "Edit Sheet" ), edit_sheet_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_SHEET, _( "Edit Sheet" ),
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _( "Resize Sheet" ), resize_sheet_xpm ); edit_sheet_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _( "Resize Sheet" ),
resize_sheet_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_IMPORT_GLABEL, _("Import PinSheets"), ADD_MENUITEM( PopMenu, ID_POPUP_IMPORT_GLABEL, _( "Import PinSheets" ),
import_hierarchical_label_xpm ); import_hierarchical_label_xpm );
if( Sheet->m_Label ) // Sheet has pin labels, and can be cleaned if( Sheet->m_Label ) // Sheet has pin labels, and can be cleaned
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, ADD_MENUITEM( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET,
_( "Cleanup PinSheets" ), options_pinsheet_xpm ); _( "Cleanup PinSheets" ), options_pinsheet_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Sheet" ), delete_sheet_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Sheet" ),
delete_sheet_xpm );
} }
} }
/************************************************************************/ /************************************************************************/
void AddMenusForPinSheet( wxMenu* PopMenu, Hierarchical_PIN_Sheet_Struct* PinSheet ) void AddMenusForPinSheet( wxMenu* PopMenu,
Hierarchical_PIN_Sheet_Struct* PinSheet )
{
/************************************************************************/ /************************************************************************/
/* Add menu commands for a Pin Sheet (or Sheet label) /* Add menu commands for a Pin Sheet (or Sheet label)
*/ */
{
if( !PinSheet->m_Flags ) if( !PinSheet->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_PINSHEET, _( "Move PinSheet" ), move_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_PINSHEET,
_( "Move PinSheet" ), move_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _( "Edit PinSheet" ), edit_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _( "Edit PinSheet" ),
edit_xpm );
if( !PinSheet->m_Flags ) if( !PinSheet->m_Flags )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete PinSheet" ), delete_pinsheet_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete PinSheet" ),
delete_pinsheet_xpm );
} }
/**********************************************************************/ /**********************************************************************/
void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ) void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame )
{
/**********************************************************************/ /**********************************************************************/
/* Add menu commands for block /* Add menu commands for block
*/ */
{ ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ), cancel_xpm ); _( "Cancel Block" ), cancel_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE ) if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
ADD_MENUITEM( PopMenu, ID_POPUP_ZOOM_BLOCK, ADD_MENUITEM( PopMenu, ID_POPUP_ZOOM_BLOCK, _( "Window Zoom" ),
_( "Window Zoom" ), zoom_selected_xpm ); zoom_selected_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), apply_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), apply_xpm );
if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE ) if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE ) // After a block move (that is also a block selection) one can reselect a block function:
{ // After a block move (that is also a block selection) one can reselect a block function: {
ADD_MENUITEM( PopMenu, wxID_COPY, _( "Save Block" ), copy_button ); ADD_MENUITEM( PopMenu, wxID_COPY, _( "Save Block" ), copy_button );
ADD_MENUITEM( PopMenu, ID_POPUP_COPY_BLOCK, ADD_MENUITEM( PopMenu, ID_POPUP_COPY_BLOCK, _( "Copy Block" ),
_( "Copy Block" ), copyblock_xpm ); copyblock_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_DRAG_BLOCK, ADD_MENUITEM( PopMenu, ID_POPUP_DRAG_BLOCK, _( "Drag Block" ),
_( "Drag Block" ), move_xpm ); move_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_DELETE_BLOCK, ADD_MENUITEM( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ),
_( "Delete Block" ), delete_xpm ); delete_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, _( ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_Y_BLOCK,
"Mirror Block ||" ), mirror_H_xpm ); _( "Mirror Block ||" ), mirror_H_xpm );
#if 0 #if 0
#ifdef __WINDOWS__ #ifdef __WINDOWS__
ADD_MENUITEM( menu_other_block_commands, ID_GEN_COPY_BLOCK_TO_CLIPBOARD, ADD_MENUITEM( menu_other_block_commands,
ID_GEN_COPY_BLOCK_TO_CLIPBOARD,
_( "Copy to Clipboard" ), copy_button ); _( "Copy to Clipboard" ), copy_button );
#endif #endif
#endif #endif
} }
} }
/**********************************************************************/ /**********************************************************************/
void AddMenusForMarkers( wxMenu* aPopMenu, MARKER_SCH* aMarker, void AddMenusForMarkers( wxMenu* aPopMenu, MARKER_SCH* aMarker,
WinEDA_SchematicFrame* aFrame ) WinEDA_SchematicFrame* aFrame )
/**********************************************************************/
{ {
ADD_MENUITEM( aPopMenu, ID_POPUP_SCH_DELETE, _( "Delete Marker" ), delete_xpm ); /**********************************************************************/
ADD_MENUITEM( aPopMenu, ID_POPUP_SCH_GETINFO_MARKER, _( "Marker Error Info" ), info_xpm ); ADD_MENUITEM( aPopMenu, ID_POPUP_SCH_DELETE, _( "Delete Marker" ),
delete_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_SCH_GETINFO_MARKER,
_( "Marker Error Info" ), info_xpm );
} }
...@@ -502,7 +502,7 @@ void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize ) ...@@ -502,7 +502,7 @@ void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize )
/*************************************************/ /*************************************************/
void WinEDA_LibeditFrame::DeletePin( wxDC* DC, void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
EDA_LibComponentStruct* LibEntry, LIB_COMPONENT* LibEntry,
LibDrawPin* Pin ) LibDrawPin* Pin )
/*************************************************/ /*************************************************/
...@@ -956,7 +956,7 @@ int sort_by_pin_number( const void* ref, const void* tst ) ...@@ -956,7 +956,7 @@ int sort_by_pin_number( const void* ref, const void* tst )
/***************************************************************/ /***************************************************************/
bool WinEDA_LibeditFrame::TestPins( EDA_LibComponentStruct* LibEntry ) bool WinEDA_LibeditFrame::TestPins( LIB_COMPONENT* LibEntry )
/***************************************************************/ /***************************************************************/
// Test des pins ( duplicates...) // Test des pins ( duplicates...)
......
...@@ -51,13 +51,13 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem ) ...@@ -51,13 +51,13 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
/* Polt a component */ /* Polt a component */
{ {
int ii, t1, t2, * Poly, orient; int ii, t1, t2, * Poly, orient;
EDA_LibComponentStruct* Entry; LIB_COMPONENT* Entry;
int TransMat[2][2], Multi, convert; int TransMat[2][2], Multi, convert;
EDA_Colors CharColor = UNSPECIFIED_COLOR; EDA_Colors CharColor = UNSPECIFIED_COLOR;
wxPoint pos; wxPoint pos;
bool draw_bgfill = false; bool draw_bgfill = false;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( DrawLibItem->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
return;; return;;
memcpy( TransMat, DrawLibItem->m_Transform, sizeof(TransMat) ); memcpy( TransMat, DrawLibItem->m_Transform, sizeof(TransMat) );
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/*****************************************/ /*****************************************/
LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos, LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos,
EDA_LibComponentStruct* Entry, LIB_COMPONENT* Entry,
int Unit, int Unit,
int Convert, int Convert,
SCH_COMPONENT* DrawItem = NULL ); SCH_COMPONENT* DrawItem = NULL );
...@@ -40,15 +40,9 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, ...@@ -40,15 +40,9 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
/******************************/ /******************************/
/* EELIBS_DRAW_COMPONENTS.CPP */ /* EELIBS_DRAW_COMPONENTS.CPP */
/******************************/ /******************************/
int NumOfLibraries();
LibCmpEntry* FindLibPart( const wxChar* Name,
const wxString& LibName = wxEmptyString,
LibrEntryType Alias = ROOT );
void DrawingLibInGhost( WinEDA_DrawPanel* panel, void DrawingLibInGhost( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
EDA_LibComponentStruct* LibEntry, LIB_COMPONENT* LibEntry,
SCH_COMPONENT* DrawLibItem, SCH_COMPONENT* DrawLibItem,
int PartX, int PartX,
int PartY, int PartY,
...@@ -73,14 +67,6 @@ bool MapAngles( int* Angle1, ...@@ -73,14 +67,6 @@ bool MapAngles( int* Angle1,
wxPoint TransformCoordinate( const int aTransformMatrix[2][2], wxPoint TransformCoordinate( const int aTransformMatrix[2][2],
const wxPoint& aPosition ); const wxPoint& aPosition );
LibraryStruct* FindLibrary( const wxString& Name );
LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
const wxString& FullLibName,
const wxString& LibName );
void LoadLibraries( WinEDA_SchematicFrame* frame );
void FreeCmpLibrary( wxWindow* frame,
const wxString& LibName );
void SnapLibItemPoint( int OrigX, void SnapLibItemPoint( int OrigX,
int OrigY, int OrigY,
int* ClosestX, int* ClosestX,
...@@ -155,7 +141,7 @@ SCH_ITEM* PickStruct( const wxPoint& refpos, ...@@ -155,7 +141,7 @@ SCH_ITEM* PickStruct( const wxPoint& refpos,
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen, LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
const wxPoint& refpoint, const wxPoint& refpoint,
EDA_LibComponentStruct* LibEntry, LIB_COMPONENT* LibEntry,
int Unit, int Unit,
int Convert, int Convert,
int masque ); int masque );
...@@ -216,7 +202,7 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose ); ...@@ -216,7 +202,7 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose );
/* SAVELIB.CPP */ /* SAVELIB.CPP */
/**************/ /**************/
EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry ); LIB_COMPONENT* CopyLibEntryStruct( LIB_COMPONENT* OldEntry );
/* Routine de copie d'une partlib /* Routine de copie d'une partlib
* Parametres d'entree: pointeur sur la structure de depart * Parametres d'entree: pointeur sur la structure de depart
...@@ -262,7 +248,7 @@ void DeleteAllMarkers( int type ); ...@@ -262,7 +248,7 @@ void DeleteAllMarkers( int type );
/* GETPART.CPP */ /* GETPART.CPP */
/**************/ /**************/
int LookForConvertPart( EDA_LibComponentStruct* LibEntry ); int LookForConvertPart( LIB_COMPONENT* LibEntry );
/* Retourne la plus grande valeur trouvee dans la liste des elements /* Retourne la plus grande valeur trouvee dans la liste des elements
* "drawings" du composant LibEntry, pour le membre .Convert * "drawings" du composant LibEntry, pour le membre .Convert
...@@ -295,7 +281,7 @@ void InstallPineditFrame( WinEDA_LibeditFrame* parent, ...@@ -295,7 +281,7 @@ void InstallPineditFrame( WinEDA_LibeditFrame* parent,
* 0 si commande annulee * 0 si commande annulee
*/ */
int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame, int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
LibraryStruct* Library, CMP_LIBRARY* Library,
wxString& Buffer, wxString& Buffer,
wxString& OldName ); wxString& OldName );
...@@ -305,7 +291,7 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame, ...@@ -305,7 +291,7 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
* a library * a library
* This list is sorted, with the library cache always at end of the list * This list is sorted, with the library cache always at end of the list
*/ */
LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame ); CMP_LIBRARY* SelectLibraryFromList( WinEDA_DrawFrame* frame );
/** /**
* Function GetNameOfPartToLoad * Function GetNameOfPartToLoad
...@@ -319,7 +305,7 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame ); ...@@ -319,7 +305,7 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame );
* BufName * BufName
*/ */
int GetNameOfPartToLoad( WinEDA_DrawFrame* frame, int GetNameOfPartToLoad( WinEDA_DrawFrame* frame,
LibraryStruct* Lib, CMP_LIBRARY* Lib,
wxString& BufName ); wxString& BufName );
/**************/ /**************/
......
...@@ -8,12 +8,16 @@ ...@@ -8,12 +8,16 @@
#include "confirm.h" #include "confirm.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "gestfich.h" #include "gestfich.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "macros.h" #include "macros.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
#include <boost/foreach.hpp>
/* Fonctions Locales */ /* Fonctions Locales */
static void SaveLayers( FILE* f ); static void SaveLayers( FILE* f );
...@@ -119,11 +123,12 @@ bool SCH_SCREEN::Save( FILE* aFile ) const ...@@ -119,11 +123,12 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
wxString datetime = DateAndTime( ); wxString datetime = DateAndTime( );
bool first = true; bool first = true;
for( LibraryStruct* Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
BOOST_FOREACH( const CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
{ {
if( ! first ) if( ! first )
Name += wxT( "," ); Name += wxT( "," );
Name += Lib->m_Name; Name += lib.GetName();
first = false; first = false;
} }
......
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
* Parametres de sortie: pointeur sur la structure creee * Parametres de sortie: pointeur sur la structure creee
* Do not copy new items ( i.e. with m_Flag & IS_NEW) * Do not copy new items ( i.e. with m_Flag & IS_NEW)
*/ */
EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry ) LIB_COMPONENT* CopyLibEntryStruct( LIB_COMPONENT* OldEntry )
{ {
wxString msg; wxString msg;
EDA_LibComponentStruct* NewStruct; LIB_COMPONENT* NewStruct;
LibEDA_BaseStruct* NewDrawings, * OldDrawings; LibEDA_BaseStruct* NewDrawings, * OldDrawings;
LibEDA_BaseStruct* LastItem; LibEDA_BaseStruct* LastItem;
LibDrawField* OldField, * NewField; LibDrawField* OldField, * NewField;
...@@ -41,7 +41,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry ) ...@@ -41,7 +41,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry )
return NULL; return NULL;
} }
NewStruct = new EDA_LibComponentStruct( NULL ); NewStruct = new LIB_COMPONENT( wxEmptyString );
OldEntry->m_Prefix.Copy( &NewStruct->m_Prefix ); OldEntry->m_Prefix.Copy( &NewStruct->m_Prefix );
OldEntry->m_Name.Copy( &NewStruct->m_Name ); OldEntry->m_Name.Copy( &NewStruct->m_Name );
......
...@@ -649,10 +649,10 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -649,10 +649,10 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
if( screen->GetCurItem() == NULL ) if( screen->GetCurItem() == NULL )
break; break;
{ {
LibCmpEntry* LibEntry; CMP_LIB_ENTRY* LibEntry;
LibEntry = FindLibPart( LibEntry = CMP_LIBRARY::FindLibraryEntry(
( (SCH_COMPONENT*) screen->GetCurItem() )->m_ChipName, ( (SCH_COMPONENT*) screen->GetCurItem() )->m_ChipName );
wxEmptyString, ALIAS );
if( LibEntry && LibEntry->m_DocFile != wxEmptyString ) if( LibEntry && LibEntry->m_DocFile != wxEmptyString )
{ {
GetAssociatedDocument( this, LibEntry->m_DocFile , GetAssociatedDocument( this, LibEntry->m_DocFile ,
......
...@@ -13,37 +13,23 @@ ...@@ -13,37 +13,23 @@
#include "protos.h" #include "protos.h"
LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame ) CMP_LIBRARY* SelectLibraryFromList( WinEDA_DrawFrame* frame )
{ {
static wxString OldLibName; static wxString OldLibName;
wxString LibName, msg; wxString msg;
int count = NumOfLibraries(); wxArrayString libNamesList;
LibraryStruct* Lib = NULL; int count = CMP_LIBRARY::GetLibraryCount();
CMP_LIBRARY* Lib = NULL;
if( count == 0 ) if( count == 0 )
{ {
DisplayError( frame, _( "No libraries are loaded" ) ); DisplayError( frame, _( "No component libraries are loaded." ) );
return NULL; return NULL;
} }
msg.Printf( _( " Select 1 of %d libraries." ), count ); libNamesList = CMP_LIBRARY::GetLibraryNames();
wxArrayString libNamesList; msg.Printf( _( " Select 1 of %d libraries." ), count );
LibraryStruct* libcache = NULL;
for( LibraryStruct* Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
{
if( Lib->m_IsLibCache )
libcache = Lib;
else
libNamesList.Add( Lib->m_Name );
}
libNamesList.Sort();
// Add lib cache
if( libcache )
libNamesList.Add( libcache->m_Name );
wxSingleChoiceDialog dlg( frame, msg, _( "Select Library" ), libNamesList ); wxSingleChoiceDialog dlg( frame, msg, _( "Select Library" ), libNamesList );
...@@ -55,7 +41,7 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame ) ...@@ -55,7 +41,7 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame )
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() ) if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() )
return NULL; return NULL;
Lib = FindLibrary( dlg.GetStringSelection() ); Lib = CMP_LIBRARY::FindLibrary( dlg.GetStringSelection() );
if( Lib != NULL ) if( Lib != NULL )
OldLibName = dlg.GetStringSelection(); OldLibName = dlg.GetStringSelection();
...@@ -65,7 +51,7 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame ) ...@@ -65,7 +51,7 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame )
int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame, int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
LibraryStruct* Library, CMP_LIBRARY* Library,
wxString& Buffer, wxString& OldName ) wxString& Buffer, wxString& OldName )
{ {
size_t i; size_t i;
...@@ -105,7 +91,7 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame, ...@@ -105,7 +91,7 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
} }
int GetNameOfPartToLoad( WinEDA_DrawFrame* frame, LibraryStruct* Library, int GetNameOfPartToLoad( WinEDA_DrawFrame* frame, CMP_LIBRARY* Library,
wxString& BufName ) wxString& BufName )
{ {
int ii; int ii;
......
...@@ -179,7 +179,7 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -179,7 +179,7 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
/*******************************************************************************************/ /*******************************************************************************************/
LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( EDA_LibComponentStruct* LibEntry, LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
wxDC* DC ) wxDC* DC )
/*******************************************************************************************/ /*******************************************************************************************/
......
...@@ -30,11 +30,11 @@ ...@@ -30,11 +30,11 @@
*/ */
void WinEDA_LibeditFrame::LoadOneSymbol( void ) void WinEDA_LibeditFrame::LoadOneSymbol( void )
{ {
EDA_LibComponentStruct* Component; LIB_COMPONENT* Component;
LibEDA_BaseStruct* DrawEntry; LibEDA_BaseStruct* DrawEntry;
FILE* ImportFile; FILE* ImportFile;
wxString msg, err; wxString msg, err;
LibraryStruct* Lib; CMP_LIBRARY* Lib;
/* Exit if no library entry is selected or a command is in progress. */ /* Exit if no library entry is selected or a command is in progress. */
if( CurrentLibEntry == NULL if( CurrentLibEntry == NULL
...@@ -70,8 +70,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) ...@@ -70,8 +70,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
return; return;
} }
Lib = new LibraryStruct( LIBRARY_TYPE_SYMBOL, fn.GetName(), Lib = new CMP_LIBRARY( LIBRARY_TYPE_SYMBOL, fn );
fn.GetFullPath() );
if( !Lib->Load( err ) ) if( !Lib->Load( err ) )
{ {
...@@ -96,7 +95,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) ...@@ -96,7 +95,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
if( Lib->GetCount() > 1 ) if( Lib->GetCount() > 1 )
DisplayError( this, _( "Warning: more than 1 part in Symbol File" ) ); DisplayError( this, _( "Warning: more than 1 part in Symbol File" ) );
Component = (EDA_LibComponentStruct*) Lib->GetFirstEntry(); Component = (LIB_COMPONENT*) Lib->GetFirstEntry();
DrawEntry = Component->m_Drawings; DrawEntry = Component->m_Drawings;
while( DrawEntry ) while( DrawEntry )
......
...@@ -3,27 +3,23 @@ ...@@ -3,27 +3,23 @@
/****************************************************************/ /****************************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "bitmaps.h"
#include "id.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "wx/spinctrl.h"
#include "protos.h" #include "protos.h"
#include "class_library.h"
#include "bitmaps.h"
#include "id.h"
void WinEDA_ViewlibFrame::ReCreateHToolbar() void WinEDA_ViewlibFrame::ReCreateHToolbar()
{ {
int ii; int ii;
LibraryStruct* lib; CMP_LIBRARY* lib;
EDA_LibComponentStruct* component = NULL; LIB_COMPONENT* component = NULL;
LibCmpEntry* entry = NULL; CMP_LIB_ENTRY* entry = NULL;
bool asdeMorgan = false; bool asdeMorgan = false;
if( m_HToolBar == NULL ) if( m_HToolBar == NULL )
...@@ -108,7 +104,7 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar() ...@@ -108,7 +104,7 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
if( (g_CurrentViewLibraryName != wxEmptyString) if( (g_CurrentViewLibraryName != wxEmptyString)
&& (g_CurrentViewComponentName != wxEmptyString) ) && (g_CurrentViewComponentName != wxEmptyString) )
{ {
lib = FindLibrary( g_CurrentViewLibraryName ); lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
if( lib != NULL ) if( lib != NULL )
{ {
......
...@@ -5,13 +5,15 @@ ...@@ -5,13 +5,15 @@
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "common.h" #include "common.h"
#include "id.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "bitmaps.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "bitmaps.h"
#include "protos.h" #include "protos.h"
#include "id.h"
/*****************************/ /*****************************/
/* class WinEDA_ViewlibFrame */ /* class WinEDA_ViewlibFrame */
...@@ -61,7 +63,7 @@ static wxAcceleratorEntry accels[] = ...@@ -61,7 +63,7 @@ static wxAcceleratorEntry accels[] =
WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
LibraryStruct* Library, CMP_LIBRARY* Library,
wxSemaphore* semaphore ) : wxSemaphore* semaphore ) :
WinEDA_DrawFrame( father, VIEWER_FRAME, _( "Library browser" ), WinEDA_DrawFrame( father, VIEWER_FRAME, _( "Library browser" ),
wxDefaultPosition, wxDefaultSize ) wxDefaultPosition, wxDefaultSize )
...@@ -117,7 +119,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, ...@@ -117,7 +119,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
} }
else else
{ {
g_CurrentViewLibraryName = Library->m_Name; g_CurrentViewLibraryName = Library->GetName();
m_LibListSize.x = 0; m_LibListSize.x = 0;
} }
...@@ -277,14 +279,14 @@ int WinEDA_ViewlibFrame::BestZoom() ...@@ -277,14 +279,14 @@ int WinEDA_ViewlibFrame::BestZoom()
{ {
int bestzoom, ii, jj; int bestzoom, ii, jj;
wxSize size, itemsize; wxSize size, itemsize;
EDA_LibComponentStruct* component; LIB_COMPONENT* component;
LibraryStruct* lib; CMP_LIBRARY* lib;
GetScreen()->m_Curseur.x = 0; GetScreen()->m_Curseur.x = 0;
GetScreen()->m_Curseur.y = 0; GetScreen()->m_Curseur.y = 0;
bestzoom = 16; bestzoom = 16;
lib = FindLibrary( g_CurrentViewLibraryName ); lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
if( lib == NULL ) if( lib == NULL )
return bestzoom; return bestzoom;
...@@ -314,37 +316,22 @@ int WinEDA_ViewlibFrame::BestZoom() ...@@ -314,37 +316,22 @@ int WinEDA_ViewlibFrame::BestZoom()
} }
/******************************************/ /**
void WinEDA_ViewlibFrame::ReCreateListLib() * Function ReCreateListLib
/******************************************/ *
/** Function ReCreateListLib
* Creates or recreates the list of current loaded libraries. * Creates or recreates the list of current loaded libraries.
* This list is sorted, with the library cache always at end of the list * This list is sorted, with the library cache always at end of the list
*/ */
void WinEDA_ViewlibFrame::ReCreateListLib()
{ {
LibraryStruct * libcache = NULL; wxArrayString libNamesList;
bool found = FALSE; bool found = false;
if( m_LibList == NULL ) if( m_LibList == NULL )
return; return;
m_LibList->Clear(); m_LibList->Clear();
libNamesList = CMP_LIBRARY::GetLibraryNames();
wxArrayString libNamesList;
for( LibraryStruct* Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
{
if ( Lib->m_IsLibCache )
libcache = Lib;
else
libNamesList.Add( Lib->m_Name );
}
libNamesList.Sort();
// Add lib cache
if ( libcache )
libNamesList.Add( libcache->m_Name );
m_LibList->Append( libNamesList ); m_LibList->Append( libNamesList );
// Search for a previous selection: // Search for a previous selection:
...@@ -379,7 +366,7 @@ void WinEDA_ViewlibFrame::ReCreateListCmp() ...@@ -379,7 +366,7 @@ void WinEDA_ViewlibFrame::ReCreateListCmp()
if( m_CmpList == NULL ) if( m_CmpList == NULL )
return; return;
LibraryStruct* Library = FindLibrary( g_CurrentViewLibraryName ); CMP_LIBRARY* Library = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
wxArrayString nameList; wxArrayString nameList;
m_CmpList->Clear(); m_CmpList->Clear();
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "eda_doc.h" #include "eda_doc.h"
#include "id.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
#include "id.h"
#define NEXT_PART 1 #define NEXT_PART 1
#define NEW_PART 0 #define NEW_PART 0
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event ) void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
wxString msg; wxString msg;
EDA_LibComponentStruct* LibEntry; CMP_LIB_ENTRY* LibEntry;
int ii, id = event.GetId(); int ii, id = event.GetId();
wxPoint pos; wxPoint pos;
...@@ -51,10 +51,9 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -51,10 +51,9 @@ void WinEDA_ViewlibFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_LIBVIEW_VIEWDOC: case ID_LIBVIEW_VIEWDOC:
LibEntry = LibEntry = CMP_LIBRARY::FindLibraryEntry( g_CurrentViewComponentName,
( EDA_LibComponentStruct* ) FindLibPart( g_CurrentViewComponentName, g_CurrentViewLibraryName );
g_CurrentViewLibraryName,
ALIAS );
if( LibEntry && ( !LibEntry->m_DocFile.IsEmpty() ) ) if( LibEntry && ( !LibEntry->m_DocFile.IsEmpty() ) )
GetAssociatedDocument( this, LibEntry->m_DocFile, GetAssociatedDocument( this, LibEntry->m_DocFile,
&wxGetApp().GetLibraryPathList() ); &wxGetApp().GetLibraryPathList() );
...@@ -106,15 +105,15 @@ bool WinEDA_ViewlibFrame::OnRightClick( const wxPoint& MousePos, ...@@ -106,15 +105,15 @@ bool WinEDA_ViewlibFrame::OnRightClick( const wxPoint& MousePos,
void WinEDA_ViewlibFrame::DisplayLibInfos() void WinEDA_ViewlibFrame::DisplayLibInfos()
{ {
wxString msg; wxString msg;
LibraryStruct* Lib; CMP_LIBRARY* Lib;
Lib = FindLibrary( g_CurrentViewLibraryName ); Lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
msg = _( "Library browser" ); msg = _( "Library browser" );
msg << wxT( " [" ); msg << wxT( " [" );
if( Lib ) if( Lib )
msg << Lib->m_FullFileName; msg << Lib->GetFullFileName();
else else
msg += _( "none selected" ); msg += _( "none selected" );
...@@ -128,13 +127,13 @@ void WinEDA_ViewlibFrame::DisplayLibInfos() ...@@ -128,13 +127,13 @@ void WinEDA_ViewlibFrame::DisplayLibInfos()
/*****************************************/ /*****************************************/
void WinEDA_ViewlibFrame::SelectCurrentLibrary() void WinEDA_ViewlibFrame::SelectCurrentLibrary()
{ {
LibraryStruct* Lib; CMP_LIBRARY* Lib;
Lib = SelectLibraryFromList( this ); Lib = SelectLibraryFromList( this );
if( Lib ) if( Lib )
{ {
g_CurrentViewComponentName.Empty(); g_CurrentViewComponentName.Empty();
g_CurrentViewLibraryName = Lib->m_Name; g_CurrentViewLibraryName = Lib->GetName();
DisplayLibInfos(); DisplayLibInfos();
if( m_LibList ) if( m_LibList )
{ {
...@@ -155,14 +154,14 @@ void WinEDA_ViewlibFrame::SelectCurrentLibrary() ...@@ -155,14 +154,14 @@ void WinEDA_ViewlibFrame::SelectCurrentLibrary()
*/ */
void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option ) void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option )
{ {
LibraryStruct* Lib; CMP_LIBRARY* Lib;
if( g_CurrentViewLibraryName.IsEmpty() ) if( g_CurrentViewLibraryName.IsEmpty() )
SelectCurrentLibrary(); SelectCurrentLibrary();
if( g_CurrentViewLibraryName.IsEmpty() ) if( g_CurrentViewLibraryName.IsEmpty() )
return; return;
Lib = FindLibrary( g_CurrentViewLibraryName ); Lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
if( Lib == NULL ) if( Lib == NULL )
return; return;
...@@ -172,7 +171,7 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option ) ...@@ -172,7 +171,7 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option )
return; return;
} }
LibCmpEntry* LibEntry = Lib->FindEntry( g_CurrentViewComponentName ); CMP_LIB_ENTRY* LibEntry = Lib->FindEntry( g_CurrentViewComponentName );
if( LibEntry == NULL ) if( LibEntry == NULL )
return; return;
...@@ -188,10 +187,10 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option ) ...@@ -188,10 +187,10 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option )
/*************************************************/ /*************************************************/
/* Routine to view one selected library content. */ /* Routine to view one selected library content. */
/*************************************************/ /*************************************************/
void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag ) void WinEDA_ViewlibFrame::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag )
{ {
int NumOfParts = 0; int NumOfParts = 0;
LibCmpEntry* LibEntry; CMP_LIB_ENTRY* LibEntry;
wxString CmpName; wxString CmpName;
wxClientDC dc( DrawPanel ); wxClientDC dc( DrawPanel );
...@@ -256,15 +255,15 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag ) ...@@ -256,15 +255,15 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag )
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{ {
EDA_LibComponentStruct* component; LIB_COMPONENT* component;
LibCmpEntry* entry; CMP_LIB_ENTRY* entry;
LibraryStruct* lib; CMP_LIBRARY* lib;
wxString msg; wxString msg;
wxString tmp; wxString tmp;
ActiveScreen = GetScreen(); ActiveScreen = GetScreen();
lib = FindLibrary( g_CurrentViewLibraryName ); lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
if( lib == NULL ) if( lib == NULL )
return; return;
...@@ -286,24 +285,12 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -286,24 +285,12 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( entry->Type != ROOT ) if( entry->Type != ROOT )
{ {
EDA_LibCmpAliasStruct* alias = (EDA_LibCmpAliasStruct*) entry; LIB_ALIAS* alias = (LIB_ALIAS*) entry;
component = alias->GetComponent();
component = lib->FindComponent( alias->m_RootName ); wxASSERT( component != NULL && component->Type == ROOT );
if( component == NULL ) msg = alias->GetName();
{
msg.Printf( _( "Root component <%s> for alias <%s> not found in \
library." ),
(const wxChar*) alias->m_RootName,
(const wxChar*) entry->GetName(),
(const wxChar*) lib->m_Name );
DisplayError( this, msg );
return;
}
msg.Printf( _( "Current Part: <%s> (is Alias of <%s>)" ),
(const wxChar*) entry->GetName(),
(const wxChar*) alias->m_RootName );
/* Temporarily change the name field text to reflect the alias name. */ /* Temporarily change the name field text to reflect the alias name. */
tmp = component->GetName(); tmp = component->GetName();
...@@ -316,9 +303,8 @@ library." ), ...@@ -316,9 +303,8 @@ library." ),
} }
else else
{ {
component = (EDA_LibComponentStruct*) entry; component = (LIB_COMPONENT*) entry;
msg.Printf( _( "Current Part: <%s>" ), msg = _( "None" );
(const wxChar*) component->GetName() );
} }
component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_ViewUnit, component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_ViewUnit,
...@@ -327,9 +313,11 @@ library." ), ...@@ -327,9 +313,11 @@ library." ),
if( !tmp.IsEmpty() ) if( !tmp.IsEmpty() )
component->m_Name.m_Text = tmp; component->m_Name.m_Text = tmp;
AfficheDoc( this, entry->m_Doc, entry->m_KeyWord ); MsgPanel->EraseMsgBox();
MsgPanel->AppendMessage( _( "Part" ), component->GetName(), BLUE, 6 );
SetStatusText( msg, 0 ); MsgPanel->AppendMessage( _( "Alias" ), msg, RED, 6 );
MsgPanel->AppendMessage( _( "Description" ), entry->m_Doc, CYAN, 6 );
MsgPanel->AppendMessage( _( "Key words" ), entry->m_KeyWord, DARKDARKGRAY );
DrawPanel->Trace_Curseur( DC ); DrawPanel->Trace_Curseur( DC );
} }
...@@ -155,7 +155,8 @@ public: ...@@ -155,7 +155,8 @@ public:
* Check to see if the cursor is being managed for block or editing * Check to see if the cursor is being managed for block or editing
* commands and release it. * commands and release it.
*/ */
void UnManageCursor( void ); void UnManageCursor( int id = -1, int cursor = -1,
const wxString& title = wxEmptyString );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
......
...@@ -289,9 +289,6 @@ void Affiche_1_Parametre( WinEDA_DrawFrame* frame, ...@@ -289,9 +289,6 @@ void Affiche_1_Parametre( WinEDA_DrawFrame* frame,
const wxString& texte_L, const wxString& texte_L,
int color ); int color );
void AfficheDoc( WinEDA_DrawFrame* frame, const wxString& Doc,
const wxString& KeyW );
/* Routine d'affichage de la documentation associee a un composant */ /* Routine d'affichage de la documentation associee a un composant */
int GetTimeStamp(); int GetTimeStamp();
......
...@@ -18,9 +18,9 @@ class DRAWSEGMENT; ...@@ -18,9 +18,9 @@ class DRAWSEGMENT;
class DrawPickedStruct; class DrawPickedStruct;
class SCH_ITEM; class SCH_ITEM;
class DrawNoConnectStruct; class DrawNoConnectStruct;
class LibraryStruct; class CMP_LIBRARY;
class EDA_LibComponentStruct; class LIB_COMPONENT;
class LibCmpEntry; class CMP_LIB_ENTRY;
class LibEDA_BaseStruct; class LibEDA_BaseStruct;
class EDA_BaseStruct; class EDA_BaseStruct;
class DrawBusEntryStruct; class DrawBusEntryStruct;
...@@ -448,6 +448,11 @@ public: ...@@ -448,6 +448,11 @@ public:
*/ */
int CheckAnnotate( wxArrayString * aMessageList, bool aOneSheetOnly ); int CheckAnnotate( wxArrayString * aMessageList, bool aOneSheetOnly );
/**
* Load component libraries defined in project file.
*/
void LoadLibraries( void );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
...@@ -522,10 +527,10 @@ private: ...@@ -522,10 +527,10 @@ private:
bool LoadOneLibraryPart(); bool LoadOneLibraryPart();
void SaveActiveLibrary( wxCommandEvent& event ); void SaveActiveLibrary( wxCommandEvent& event );
bool LoadOneLibraryPartAux( LibCmpEntry* LibEntry, bool LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry,
LibraryStruct* Library ); CMP_LIBRARY* Library );
void DisplayCmpDoc( const wxString& Name ); void DisplayCmpDoc();
void EditComponentProperties(); void EditComponentProperties();
// General editing // General editing
...@@ -540,19 +545,18 @@ private: ...@@ -540,19 +545,18 @@ private:
// Edition des Pins: // Edition des Pins:
void CreatePin( wxDC* DC ); void CreatePin( wxDC* DC );
void DeletePin( wxDC* DC, void DeletePin( wxDC* DC,
EDA_LibComponentStruct* LibEntry, LIB_COMPONENT* LibEntry,
LibDrawPin* Pin ); LibDrawPin* Pin );
void StartMovePin( wxDC* DC ); void StartMovePin( wxDC* DC );
// Test des pins ( duplicates...) // Test des pins ( duplicates...)
bool TestPins( EDA_LibComponentStruct* LibEntry ); bool TestPins( LIB_COMPONENT* LibEntry );
// Edition de l'ancre // Edition de l'ancre
void PlaceAncre(); void PlaceAncre();
// Edition des graphismes: // Edition des graphismes:
LibEDA_BaseStruct* CreateGraphicItem( EDA_LibComponentStruct* LibEntry, LibEDA_BaseStruct* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC );
wxDC* DC );
void GraphicItemBeginDraw( wxDC* DC ); void GraphicItemBeginDraw( wxDC* DC );
void StartMoveDrawSymbol( wxDC* DC ); void StartMoveDrawSymbol( wxDC* DC );
void EndDrawGraphicItem( wxDC* DC ); void EndDrawGraphicItem( wxDC* DC );
...@@ -563,7 +567,7 @@ private: ...@@ -563,7 +567,7 @@ private:
void EditSymbolText( wxDC* DC, LibEDA_BaseStruct* DrawItem ); void EditSymbolText( wxDC* DC, LibEDA_BaseStruct* DrawItem );
void RotateSymbolText( wxDC* DC ); void RotateSymbolText( wxDC* DC );
void DeleteDrawPoly( wxDC* DC ); void DeleteDrawPoly( wxDC* DC );
LibDrawField* LocateField( EDA_LibComponentStruct* LibEntry ); LibDrawField* LocateField( LIB_COMPONENT* LibEntry );
LibEDA_BaseStruct* LocateItemUsingCursor(); LibEDA_BaseStruct* LocateItemUsingCursor();
void RotateField( wxDC* DC, LibDrawField* Field ); void RotateField( wxDC* DC, LibDrawField* Field );
void PlaceField( wxDC* DC, LibDrawField* Field ); void PlaceField( wxDC* DC, LibDrawField* Field );
...@@ -592,9 +596,6 @@ protected: ...@@ -592,9 +596,6 @@ protected:
}; };
/************************************************************************************************/
/************************************************************************************************/
class LibraryStruct;
class WinEDA_ViewlibFrame : public WinEDA_DrawFrame class WinEDA_ViewlibFrame : public WinEDA_DrawFrame
{ {
private: private:
...@@ -616,7 +617,7 @@ private: ...@@ -616,7 +617,7 @@ private:
public: public:
WinEDA_ViewlibFrame( wxWindow* father, WinEDA_ViewlibFrame( wxWindow* father,
LibraryStruct* Library = NULL, CMP_LIBRARY* Library = NULL,
wxSemaphore* semaphore = NULL ); wxSemaphore* semaphore = NULL );
~WinEDA_ViewlibFrame(); ~WinEDA_ViewlibFrame();
...@@ -647,7 +648,7 @@ private: ...@@ -647,7 +648,7 @@ private:
void SelectCurrentLibrary(); void SelectCurrentLibrary();
void SelectAndViewLibraryPart( int option ); void SelectAndViewLibraryPart( int option );
void ExportToSchematicLibraryPart( wxCommandEvent& event ); void ExportToSchematicLibraryPart( wxCommandEvent& event );
void ViewOneLibraryContent( LibraryStruct* Lib, int Flag ); void ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
......
...@@ -362,6 +362,10 @@ protected: ...@@ -362,6 +362,10 @@ protected:
*/ */
static wxSize computeFontSize(); static wxSize computeFontSize();
/**
* Calculate the width and height of a text string using the system UI font.
*/
wxSize computeTextSize( const wxString& text );
public: public:
WinEDA_DrawFrame* m_Parent; WinEDA_DrawFrame* m_Parent;
...@@ -386,6 +390,21 @@ public: ...@@ -386,6 +390,21 @@ public:
void Affiche_1_Parametre( int pos_X, const wxString& texte_H, void Affiche_1_Parametre( int pos_X, const wxString& texte_H,
const wxString& texte_L, int color ); const wxString& texte_L, int color );
/**
* Append a message to the message panel.
*
* This method automatically adjusts for the width of the text string.
* Making consectutive calls to AppendMessage will append each message
* to the right of the last message. This message is not compatible
* with Affiche_1_Parametre.
*
* @param textUpper - The message upper text.
* @param textLower - The message lower text.
* @param color - A color ID from the Kicad color list (see colors.h).
* @param pad - Number of spaces to pad between messages (default = 4).
*/
void AppendMessage( const wxString& textUpper, const wxString& textLower,
int color, int pad = 4 );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
......
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