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,
}
/*
* 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()
/***********************/
......
......@@ -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 );
......@@ -1387,5 +1388,12 @@ void WinEDA_DrawPanel::UnManageCursor( void )
{
ForceCloseManageCurseur( this, &dc );
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()
}
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 )
/*************************************************/
......@@ -80,6 +94,36 @@ void WinEDA_MsgPanel::OnPaint( wxPaintEvent& event )
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,
......
......@@ -72,9 +72,9 @@ void ReAnnotatePowerSymbolsOnly( void )
{
if( DrawList->Type() != TYPE_SCH_COMPONENT )
continue;
SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) DrawList;
EDA_LibComponentStruct* Entry =
( EDA_LibComponentStruct* )FindLibPart( DrawLibItem->m_ChipName );
SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) DrawList;
LIB_COMPONENT* Entry =
CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( (Entry == NULL) || (Entry->m_Options != ENTRY_POWER) )
continue;
......@@ -344,17 +344,18 @@ int AddComponentsInSheetToList( std::vector <OBJ_CMP_TO_LIST>& aComponentsList,
* @param the DrawSheetPath sheet to analyse
*/
{
int NbrCmp = 0;
EDA_BaseStruct* DrawList = aSheet->LastDrawList();
SCH_COMPONENT* DrawLibItem;
EDA_LibComponentStruct* Entry;
int NbrCmp = 0;
EDA_BaseStruct* DrawList = aSheet->LastDrawList();
SCH_COMPONENT* DrawLibItem;
LIB_COMPONENT* Entry;
for( ; DrawList != NULL; DrawList = DrawList->Next() )
{
if( DrawList->Type() == TYPE_SCH_COMPONENT )
{
DrawLibItem = (SCH_COMPONENT*) DrawList;
Entry = ( EDA_LibComponentStruct* )FindLibPart( DrawLibItem->m_ChipName );
Entry =
CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry == NULL )
continue;
......
......@@ -855,7 +855,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
* @return a pointer to the pin
*/
{
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
static LibEDA_BaseStruct* NextItem;
static int Multi, convert, TransMat[2][2];
LibEDA_BaseStruct* DEntry;
......@@ -866,8 +866,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
if( aDrawLibItem )
{
NextItem = NULL;
Entry =
( EDA_LibComponentStruct* )FindLibPart( aDrawLibItem->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( aDrawLibItem->m_ChipName );
if( Entry == NULL )
return NULL;
......
......@@ -18,18 +18,18 @@
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase );
static int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent,
EDA_Rect& Rect );
static int MarkItemsInBloc( LIB_COMPONENT* LibComponent,
EDA_Rect& Rect );
static void ClearMarkItems( EDA_LibComponentStruct* LibComponent );
static void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset );
static void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset );
static void MirrorMarkedItems( EDA_LibComponentStruct* LibEntry,
static void ClearMarkItems( LIB_COMPONENT* LibComponent );
static void CopyMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset );
static void MoveMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset );
static void MirrorMarkedItems( LIB_COMPONENT* LibEntry,
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;
......@@ -55,8 +55,8 @@ void ClearMarkItems( EDA_LibComponentStruct* LibComponent )
* only the pins specific to current part and current convert are marked
* - all specific to current convert pins are marked;
*/
int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent,
EDA_Rect& Rect )
int MarkItemsInBloc( LIB_COMPONENT* LibComponent,
EDA_Rect& Rect )
{
LibEDA_BaseStruct* item;
int ItemsCount = 0;
......@@ -389,7 +389,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
/*
* 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;
......@@ -415,7 +415,7 @@ void CopyMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint 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;
......@@ -437,7 +437,7 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
/*
* Delete marked items
*/
void DeleteMarkedItems( EDA_LibComponentStruct* LibEntry )
void DeleteMarkedItems( LIB_COMPONENT* LibEntry )
{
LibEDA_BaseStruct* item, * next_item;
......@@ -458,7 +458,7 @@ void DeleteMarkedItems( EDA_LibComponentStruct* LibEntry )
/*
* 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;
LibEDA_BaseStruct* item;
......
......@@ -576,12 +576,12 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
/* Print the B.O.M sorted by reference
*/
{
int Multi, Unit;
EDA_BaseStruct* DrawList;
SCH_COMPONENT* DrawLibItem;
EDA_LibComponentStruct* Entry;
char CmpName[80];
wxString msg;
int Multi, Unit;
EDA_BaseStruct* DrawList;
SCH_COMPONENT* DrawLibItem;
LIB_COMPONENT* Entry;
char CmpName[80];
wxString msg;
if( CompactForm )
{
......@@ -649,7 +649,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
Multi = 0;
Unit = ' ';
Entry = ( EDA_LibComponentStruct* ) FindLibPart( DrawLibItem->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry )
Multi = Entry->m_UnitCount;
......@@ -714,17 +714,16 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
int DIALOG_BUILD_BOM::PrintComponentsListByVal(
FILE* f,
std::vector <OBJ_CMP_TO_LIST>& aList,
bool
aIncludeSubComponents )
bool aIncludeSubComponents )
/**********************************************************************************************/
{
int Multi;
wxChar Unit;
EDA_BaseStruct* DrawList;
SCH_COMPONENT* DrawLibItem;
EDA_LibComponentStruct* Entry;
char CmpName[80];
wxString msg;
int Multi;
wxChar Unit;
EDA_BaseStruct* DrawList;
SCH_COMPONENT* DrawLibItem;
LIB_COMPONENT* Entry;
char CmpName[80];
wxString msg;
msg = _( "\n#Cmp ( order = Value )" );
......@@ -749,7 +748,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal(
Multi = 0;
Unit = ' ';
Entry = ( EDA_LibComponentStruct* ) FindLibPart( DrawLibItem->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry )
Multi = Entry->m_UnitCount;
......
......@@ -22,7 +22,7 @@
LibDrawText::LibDrawText(EDA_LibComponentStruct * aParent) :
LibDrawText::LibDrawText(LIB_COMPONENT * aParent) :
LibEDA_BaseStruct( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, aParent ),
EDA_TextStruct()
{
......
This diff is collapsed.
......@@ -13,12 +13,15 @@
#include <boost/ptr_container/ptr_vector.hpp>
class CMP_LIBRARY;
/* Types for components in libraries
* components can be a true component or an alias of a true component.
*/
enum LibrEntryType
{
ROOT, /* This is a true component standard EDA_LibComponentStruct */
ROOT, /* This is a true component standard LIB_COMPONENT */
ALIAS /* This is an alias of a true component */
};
......@@ -35,7 +38,7 @@ enum LibrEntryOptions
*
* This class is not to be used directly.
*/
class LibCmpEntry : public EDA_BaseStruct
class CMP_LIB_ENTRY : public EDA_BaseStruct
{
public:
LibrEntryType Type; /* Type = ROOT;
......@@ -48,13 +51,16 @@ public:
LibrEntryOptions m_Options; // special features (i.e. Entry is a POWER)
public:
LibCmpEntry( LibrEntryType CmpType, const wxChar* CmpName );
virtual ~LibCmpEntry();
CMP_LIB_ENTRY( LibrEntryType CmpType, const wxString& name,
CMP_LIBRARY* lib = NULL );
virtual ~CMP_LIB_ENTRY();
virtual wxString GetClass() const
{
return wxT( "LibCmpEntry" );
return wxT( "CMP_LIB_ENTRY" );
}
wxString GetLibraryName();
const wxString& GetName() { return m_Name.m_Text; }
......@@ -75,15 +81,18 @@ public:
{
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,
const LibCmpEntry* LE2 );
extern int LibraryEntryCompare( const CMP_LIB_ENTRY* LE1,
const CMP_LIB_ENTRY* LE2 );
/**
......@@ -93,7 +102,7 @@ extern int LibraryEntryCompare( const LibCmpEntry* LE1,
* library file (.lib). Library components are different from schematic
* components.
*/
class EDA_LibComponentStruct : public LibCmpEntry
class LIB_COMPONENT : public CMP_LIB_ENTRY
{
public:
LibDrawField m_Prefix; /* Prefix ( U, IC ... ) = REFERENCE */
......@@ -120,12 +129,12 @@ public:
public:
virtual wxString GetClass() const
{
return wxT( "EDA_LibComponentStruct" );
return wxT( "LIB_COMPONENT" );
}
EDA_LibComponentStruct( const wxChar* CmpName );
~EDA_LibComponentStruct();
LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib = NULL );
~LIB_COMPONENT();
EDA_Rect GetBoundaryBox( int Unit, int Convert );
......@@ -248,19 +257,33 @@ public:
* object not as children of a library object. This would greatly
* simplify searching for components in libraries.
*/
class EDA_LibCmpAliasStruct : public LibCmpEntry
class LIB_ALIAS : public CMP_LIB_ENTRY
{
public:
wxString m_RootName; /* Root component Part name */
protected:
LIB_COMPONENT* m_root; /* Root component of the alias. */
public:
EDA_LibCmpAliasStruct( const wxChar* CmpName, const wxChar* CmpRootName );
~EDA_LibCmpAliasStruct();
LIB_ALIAS( const wxString& name, LIB_COMPONENT* root,
CMP_LIBRARY* lib = NULL );
~LIB_ALIAS();
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 @@
*
* others = free fields
*/
LibDrawField::LibDrawField(EDA_LibComponentStruct * aParent, int idfield ) :
LibDrawField::LibDrawField(LIB_COMPONENT * aParent, int idfield ) :
LibEDA_BaseStruct( COMPONENT_FIELD_DRAW_TYPE, aParent )
{
m_FieldId = idfield;
......@@ -327,7 +327,7 @@ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold,
{
extraCharCount++;
m_Text.Append('?');
EDA_LibComponentStruct* parent = (EDA_LibComponentStruct*)m_Parent;
LIB_COMPONENT* parent = (LIB_COMPONENT*)m_Parent;
if ( parent && ( parent->m_UnitCount > 1 ) )
{
m_Text.Append('A');
......
......@@ -35,7 +35,7 @@ public:
LibDrawField( int idfield = 2 );
LibDrawField( EDA_LibComponentStruct * aParent, int idfield = 2 );
LibDrawField( LIB_COMPONENT * aParent, int idfield = 2 );
~LibDrawField();
virtual wxString GetClass() const
{
......
This diff is collapsed.
This diff is collapsed.
......@@ -30,7 +30,7 @@ const wxChar* MsgPinElectricType[] =
wxT( "?????" )
};
LibDrawPin::LibDrawPin(EDA_LibComponentStruct * aParent) :
LibDrawPin::LibDrawPin(LIB_COMPONENT * aParent) :
LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE, aParent )
{
m_PinLen = 300; /* default Pin len */
......@@ -324,7 +324,7 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
return;
}
EDA_LibComponentStruct* Entry = GetParent();
LIB_COMPONENT* Entry = GetParent();
bool DrawPinText = true;
if( ( aData != NULL ) && ( (bool*) aData == false ) )
......
......@@ -405,7 +405,7 @@ bool SCH_CMP_FIELD::Save( FILE* aFile ) const
void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
{
int fieldNdx;
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL;
......@@ -424,7 +424,7 @@ void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
m_AddExtraText = 0;
if( fieldNdx == REFERENCE )
{
Entry = ( EDA_LibComponentStruct* ) FindLibPart( component->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( component->m_ChipName );
if( Entry != NULL )
{
if( Entry->m_UnitCount > 1 )
......
......@@ -17,7 +17,7 @@
/* Local variables */
static EDA_LibComponentStruct* DummyCmp;
static LIB_COMPONENT* DummyCmp;
/* Descr component <DUMMY> used when a component is not found in library,
* to draw a dummy shape
......@@ -33,7 +33,7 @@ static EDA_LibComponentStruct* DummyCmp;
*/
void CreateDummyCmp()
{
DummyCmp = new EDA_LibComponentStruct( NULL );
DummyCmp = new LIB_COMPONENT( wxEmptyString );
LibDrawSquare* Square = new LibDrawSquare(DummyCmp);
......@@ -58,8 +58,7 @@ void CreateDummyCmp()
*****************************************************************************/
/* DrawMode = GrXOR, GrOR ..*/
void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_COMPONENT* Component,
EDA_LibComponentStruct* Entry,
SCH_COMPONENT* Component, LIB_COMPONENT* Entry,
const wxPoint& Pos, const int TransMat[2][2],
int Multi, int convert, int DrawMode,
int Color, bool DrawPinText )
......@@ -165,11 +164,11 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) :
void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color )
{
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
int ii;
bool dummy = FALSE;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( Entry == NULL )
{
......@@ -477,8 +476,7 @@ void SCH_COMPONENT::AddField( const SCH_CMP_FIELD& aField )
EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
{
EDA_LibComponentStruct* Entry =
( EDA_LibComponentStruct* ) FindLibPart( m_ChipName );
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
EDA_Rect BoundaryBox;
int x0, xm, y0, ym;
......@@ -587,13 +585,13 @@ void SCH_COMPONENT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
*/
void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet )
{
wxString defRef = m_PrefixString;
bool KeepMulti = false;
EDA_LibComponentStruct* Entry;
wxString separators( wxT( " " ) );
wxArrayString reference_fields;
wxString defRef = m_PrefixString;
bool KeepMulti = false;
LIB_COMPONENT* Entry;
wxString separators( wxT( " " ) );
wxArrayString reference_fields;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( Entry && Entry->m_UnitSelectionLocked )
KeepMulti = true;
......@@ -1025,8 +1023,7 @@ EDA_Rect SCH_COMPONENT::GetBoundingBox()
void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
{
EDA_LibComponentStruct* Entry =
( EDA_LibComponentStruct* ) FindLibPart( m_ChipName );
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
wxString msg;
......@@ -1045,7 +1042,8 @@ void SCH_COMPONENT::DisplayInfo( WinEDA_DrawFrame* frame )
Affiche_1_Parametre( frame, 28, _( "RefLib" ), m_ChipName.GetData(), BROWN );
msg = FindLibName;
msg = Entry->GetLibraryName();
Affiche_1_Parametre( frame, 40, _( "Lib" ), msg, DARKRED );
if( Entry )
......
......@@ -14,8 +14,7 @@
extern void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_COMPONENT* Component,
EDA_LibComponentStruct* Entry,
SCH_COMPONENT* Component, LIB_COMPONENT* Entry,
const wxPoint& Pos, const int TransMat[2][2],
int Multi, int convert, int DrawMode,
int Color = -1, bool DrawPinText = TRUE );
......
......@@ -23,7 +23,7 @@ static int fill_tab[3] = { 'N', 'F', 'f' };
/* Base class (abstract) for components bodies items */
LibEDA_BaseStruct::LibEDA_BaseStruct( KICAD_T struct_type,
EDA_LibComponentStruct* aParent ) :
LIB_COMPONENT* aParent ) :
EDA_BaseStruct( struct_type )
{
m_Unit = 0; /* Unit identification (for multi part per package)
......@@ -83,7 +83,7 @@ bool LibEDA_BaseStruct::operator==( const LibEDA_BaseStruct& other ) const
/** class LibDrawArc **/
/**********************/
LibDrawArc::LibDrawArc( EDA_LibComponentStruct* aParent ) :
LibDrawArc::LibDrawArc( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_ARC_DRAW_TYPE, aParent )
{
m_Radius = 0;
......@@ -437,7 +437,7 @@ void LibDrawArc::DisplayInfo( WinEDA_DrawFrame* frame )
/** class LibDrawCircle **/
/*************************/
LibDrawCircle::LibDrawCircle( EDA_LibComponentStruct* aParent ) :
LibDrawCircle::LibDrawCircle( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_CIRCLE_DRAW_TYPE, aParent )
{
m_Radius = 0;
......@@ -645,7 +645,7 @@ void LibDrawCircle::DisplayInfo( WinEDA_DrawFrame* frame )
/** class LibDrawSquare **/
/*************************/
LibDrawSquare::LibDrawSquare( EDA_LibComponentStruct* aParent ) :
LibDrawSquare::LibDrawSquare( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_RECT_DRAW_TYPE, aParent )
{
m_Width = 0;
......@@ -863,7 +863,7 @@ bool LibDrawSquare::HitTest( wxPoint aRefPoint, int aThreshold,
/**************************/
/** class LibDrawSegment **/
/**************************/
LibDrawSegment::LibDrawSegment( EDA_LibComponentStruct* aParent ) :
LibDrawSegment::LibDrawSegment( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_LINE_DRAW_TYPE, aParent )
{
m_Width = 0;
......@@ -1015,7 +1015,7 @@ bool LibDrawSegment::HitTest( wxPoint aPosRef, int aThreshold,
/***************************/
/** class LibDrawPolyline **/
/***************************/
LibDrawPolyline::LibDrawPolyline( EDA_LibComponentStruct* aParent ) :
LibDrawPolyline::LibDrawPolyline( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_POLYLINE_DRAW_TYPE, aParent )
{
m_Fill = NO_FILL;
......@@ -1320,7 +1320,7 @@ void LibDrawPolyline::DisplayInfo( WinEDA_DrawFrame* frame )
/***************************/
/** class LibDrawBezier **/
/***************************/
LibDrawBezier::LibDrawBezier( EDA_LibComponentStruct* aParent ) :
LibDrawBezier::LibDrawBezier( LIB_COMPONENT* aParent ) :
LibEDA_BaseStruct( COMPONENT_BEZIER_DRAW_TYPE, aParent )
{
m_Fill = NO_FILL;
......
......@@ -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() { }
/** Function Draw (virtual pure)
......@@ -143,9 +143,9 @@ public:
virtual bool Save( FILE* aFile ) const = 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:
int m_Width; /* Line width */
public:
LibDrawPin(EDA_LibComponentStruct * aParent);
LibDrawPin(LIB_COMPONENT * aParent);
~LibDrawPin() { }
LibDrawPin* Next() const { return (LibDrawPin*) Pnext; }
......@@ -382,7 +382,7 @@ public:
int m_Width; /* Line width */
public:
LibDrawArc(EDA_LibComponentStruct * aParent);
LibDrawArc(LIB_COMPONENT * aParent);
~LibDrawArc() { }
virtual wxString GetClass() const
{
......@@ -449,7 +449,7 @@ public:
int m_Width; /* Line width */
public:
LibDrawCircle(EDA_LibComponentStruct * aParent);
LibDrawCircle(LIB_COMPONENT * aParent);
~LibDrawCircle() { }
virtual wxString GetClass() const
{
......@@ -514,7 +514,7 @@ protected:
class LibDrawText : public LibEDA_BaseStruct, public EDA_TextStruct
{
public:
LibDrawText(EDA_LibComponentStruct * aParent);
LibDrawText(LIB_COMPONENT * aParent);
~LibDrawText() { }
virtual wxString GetClass() const
{
......@@ -591,7 +591,7 @@ public:
int m_Width; /* Line width */
public:
LibDrawSquare(EDA_LibComponentStruct * aParent);
LibDrawSquare(LIB_COMPONENT * aParent);
~LibDrawSquare() { }
virtual wxString GetClass() const
{
......@@ -658,7 +658,7 @@ public:
int m_Width; /* Line width */
public:
LibDrawSegment(EDA_LibComponentStruct * aParent);
LibDrawSegment(LIB_COMPONENT * aParent);
~LibDrawSegment() { }
virtual wxString GetClass() const
{
......@@ -723,7 +723,7 @@ public:
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
public:
LibDrawPolyline(EDA_LibComponentStruct * aParent);
LibDrawPolyline(LIB_COMPONENT * aParent);
~LibDrawPolyline() { }
virtual wxString GetClass() const
......@@ -800,7 +800,7 @@ public:
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
public:
LibDrawBezier(EDA_LibComponentStruct * aParent);
LibDrawBezier(LIB_COMPONENT * aParent);
~LibDrawBezier() { }
virtual wxString GetClass() const
......
......@@ -387,8 +387,8 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
{
#undef STRUCT
#define STRUCT ( (SCH_COMPONENT*) DrawItem )
EDA_LibComponentStruct* Entry;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( STRUCT->m_ChipName );
LIB_COMPONENT* Entry;
Entry = CMP_LIBRARY::FindLibraryComponent( STRUCT->m_ChipName );
if( Entry == NULL )
break;
......
......@@ -15,9 +15,10 @@
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include <boost/foreach.hpp>
/*
* Routine de selection du nom d'un composant en librairie pour chargement,
......@@ -34,7 +35,6 @@
wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
wxString& BufName )
{
LibraryStruct* Lib;
wxArrayString nameList;
wxString msg;
......@@ -42,9 +42,9 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
Keys.MakeUpper();
/* 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() )
......@@ -77,14 +77,9 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
void DisplayCmpDoc( wxString& Name )
{
LibCmpEntry* CmpEntry = NULL;
LibraryStruct* Lib = g_LibraryList;
CMP_LIB_ENTRY* CmpEntry = NULL;
while( Lib != NULL && CmpEntry == NULL )
{
CmpEntry = Lib->FindEntry( Name );
Lib = Lib->m_Pnext;
}
CmpEntry = CMP_LIBRARY::FindLibraryEntry( Name );
if( CmpEntry == NULL )
return;
......
......@@ -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();
......
......@@ -94,7 +94,7 @@ public:
{
return m_CmpName->GetValue();
}
void SetComponentData( EDA_LibComponentStruct & component );
void SetComponentData( LIB_COMPONENT & component );
////@begin WinEDA_CreateCmpDialog event handler declarations
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
......
......@@ -171,7 +171,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
else if( newname.CmpNoCase( m_Cmp->m_ChipName ) )
{
if( FindLibPart( newname, wxEmptyString, ALIAS ) == NULL )
if( CMP_LIBRARY::FindLibraryEntry( newname ) == NULL )
{
wxString message;
message.Printf( _( "Component [%s] not found!" ), newname.GetData() );
......@@ -263,8 +263,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
++i;
}
EDA_LibComponentStruct* entry =
( EDA_LibComponentStruct* ) FindLibPart( m_Cmp->m_ChipName );
LIB_COMPONENT* entry =
CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName );
if( entry && entry->m_Options == ENTRY_POWER )
m_FieldsBuf[VALUE].m_Text = m_Cmp->m_ChipName;
......@@ -411,7 +411,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* 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)
for( int i = 0; i<aComponent->GetFieldCount(); ++i )
......@@ -700,12 +700,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
/* reinitialise components parametres to default values found in lib
*/
{
EDA_LibComponentStruct* entry;
LIB_COMPONENT* entry;
if( m_Cmp == NULL )
return;
entry = ( EDA_LibComponentStruct* ) FindLibPart( m_Cmp->m_ChipName );
entry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName );
if( entry == NULL )
return;
......
......@@ -15,18 +15,18 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEM
friend void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
SCH_COMPONENT* aComponent );
WinEDA_SchematicFrame* m_Parent;
SCH_COMPONENT* m_Cmp;
EDA_LibComponentStruct* m_LibEntry;
bool m_skipCopyFromPanel;
WinEDA_SchematicFrame* m_Parent;
SCH_COMPONENT* m_Cmp;
LIB_COMPONENT* m_LibEntry;
bool m_skipCopyFromPanel;
static int s_SelectedRow;
static int s_SelectedRow;
/// The size of the dialog window last time it was displayed;
static wxSize s_LastSize;
static wxSize s_LastSize;
/// a copy of the edited component's SCH_CMP_FIELDs
SCH_CMP_FIELDS m_FieldsBuf;
SCH_CMP_FIELDS m_FieldsBuf;
void setSelectedFieldNdx( int aFieldNdx );
......
......@@ -28,15 +28,15 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN
{
private:
WinEDA_LibeditFrame* m_Parent;
EDA_LibComponentStruct* m_LibEntry;
LIB_COMPONENT* m_LibEntry;
bool m_skipCopyFromPanel;
/// a copy of the edited component's LibDrawFields
std::vector <LibDrawField> m_FieldsBuf;
public:
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( WinEDA_LibeditFrame* aParent,
EDA_LibComponentStruct* aLibEntry );
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( WinEDA_LibeditFrame* aParent,
LIB_COMPONENT* aLibEntry );
~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB();
private:
......@@ -121,8 +121,8 @@ void WinEDA_LibeditFrame::InstallFieldsEditorDialog( void )
/***********************************************************************/
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB(
WinEDA_LibeditFrame* aParent,
EDA_LibComponentStruct* aLibEntry ) :
WinEDA_LibeditFrame* aParent,
LIB_COMPONENT* aLibEntry ) :
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent )
/***********************************************************************/
{
......
......@@ -161,7 +161,7 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
m_Parent->m_ComponentLibFiles.Add(m_ListLibr->GetString(ii) );
// take new list in account
LoadLibraries( m_Parent );
m_Parent->LoadLibraries();
if( m_Parent->m_ViewlibFrame )
m_Parent->m_ViewlibFrame->ReCreateListLib();
}
......
......@@ -56,7 +56,7 @@ void WinEDA_LibeditFrame::EditComponentProperties()
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
{
LibCmpEntry* entry;
CMP_LIB_ENTRY* entry;
if( CurrentLibEntry == NULL )
return;
......@@ -67,7 +67,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
}
else
{
entry = ( LibCmpEntry* ) CurrentLib->FindAlias( CurrentAliasName );
entry = ( CMP_LIB_ENTRY* ) CurrentLib->FindAlias( CurrentAliasName );
if( entry == NULL )
return;
......@@ -138,7 +138,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
/* Update the doc, keyword and doc filename strings */
size_t i;
int index;
LibCmpEntry* entry;
CMP_LIB_ENTRY* entry;
if( CurrentAliasName.IsEmpty() )
{
......@@ -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>." ),
(const wxChar*) CurrentAliasName,
(const wxChar*) CurrentLibEntry->GetName(),
(const wxChar*) CurrentLib->m_Name );
(const wxChar*) CurrentLib->GetName() );
wxMessageBox( msg, _( "Component Library Error" ),
wxID_OK | wxICON_ERROR, this );
}
......@@ -168,7 +168,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
if( m_PartAliasList->GetStrings() != CurrentLibEntry->m_AliasList )
{
EDA_LibCmpAliasStruct* alias;
LIB_ALIAS* alias;
wxArrayString aliases = m_PartAliasList->GetStrings();
/* Add names not existing in the old alias list. */
......@@ -179,8 +179,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
if( index != wxNOT_FOUND )
continue;
alias = new EDA_LibCmpAliasStruct( aliases[ i ],
CurrentLibEntry->GetName() );
alias = new LIB_ALIAS( aliases[ i ], CurrentLibEntry );
if( !CurrentLib->AddAlias( alias ) )
{
delete alias;
......@@ -196,7 +196,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
if( index == wxNOT_FOUND )
continue;
LibCmpEntry* alias =
CMP_LIB_ENTRY* alias =
CurrentLib->FindAlias( CurrentLibEntry->m_AliasList[ i ] );
if( alias != NULL )
CurrentLib->RemoveEntry( alias );
......@@ -318,7 +318,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
msg.Printf( _( "Alias or component name <%s> already exists in \
library <%s>." ),
(const wxChar*) aliasname,
(const wxChar*) CurrentLib->m_Name );
(const wxChar*) CurrentLib->GetName() );
DisplayError( this, msg );
return;
}
......
......@@ -27,7 +27,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
/* Prepare le deplacement du texte en cours d'edition
*/
{
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
SetCurrentField( aField );
if( aField == NULL )
......@@ -68,7 +68,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
m_Multiflag = 0;
if( aField->m_FieldId == REFERENCE )
{
Entry = ( EDA_LibComponentStruct* ) FindLibPart( comp->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( comp->m_ChipName );
if( Entry != NULL )
{
......@@ -91,7 +91,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
/* Edit the field Field (text, size) */
{
int fieldNdx, flag;
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
if( Field == NULL )
{
......@@ -104,7 +104,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
fieldNdx = Field->m_FieldId;
if( fieldNdx == VALUE )
{
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Cmp->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
if( Entry && (Entry->m_Options == ENTRY_POWER) )
{
......@@ -119,7 +119,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
flag = 0;
if( fieldNdx == REFERENCE )
{
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Cmp->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
if( Entry != NULL )
{
......@@ -249,7 +249,7 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
/*********************************************************************************/
{
int fieldNdx, flag;
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
if( Field == NULL )
return;
......@@ -262,7 +262,8 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
flag = 0;
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 )
{
......@@ -293,13 +294,13 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
/**************************************************************************************************/
/* Edit the component text reference*/
{
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
int flag = 0;
if( Cmp == NULL )
return;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Cmp->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
if( Entry == NULL )
return;
......@@ -334,12 +335,12 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
/* Routine de changement du texte selectionne */
{
wxString message;
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
if( Cmp == NULL )
return;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Cmp->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
if( Entry == NULL )
return;
......@@ -372,13 +373,13 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
/*****************************************************************************************/
{
wxString message;
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
bool wasEmpty = false;
if( Cmp == NULL )
return;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Cmp->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( Cmp->m_ChipName );
if( Entry == NULL )
return;
......
......@@ -233,9 +233,6 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName,
wxFileName fn;
bool IsRead = TRUE;
wxArrayString liblist_tmp = m_ComponentLibFiles;
WinEDA_SchematicFrame* frame;
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow();
if( CfgFileName.IsEmpty() )
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
......@@ -265,12 +262,8 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName,
if( m_ComponentLibFiles.GetCount() == 0 )
m_ComponentLibFiles.Add( wxT( "power" ) );
if( frame )
{
frame->SetDrawBgColor( g_DrawBgColor );
}
LoadLibraries( frame );
SetDrawBgColor( g_DrawBgColor );
LoadLibraries();
return IsRead;
}
......
......@@ -10,11 +10,12 @@
#include "libcmp.h"
#include "general.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],
}
/*****************************************************************************/
/*
* 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. *
* Input (and output) angles must be as follows: *
......@@ -162,9 +112,9 @@ bool MapAngles( int* Angle1, int* Angle2, const int TransMat[2][2] )
* This routine is applied by the PlaceLibItem routine above. *
*****************************************************************************/
void DrawingLibInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
EDA_LibComponentStruct* LibEntry,
SCH_COMPONENT* DrawLibItem, int PartX, int PartY,
int multi, int convert, int Color, bool DrawPinText )
LIB_COMPONENT* LibEntry, SCH_COMPONENT* DrawLibItem,
int PartX, int PartY, int multi, int convert,
int Color, bool DrawPinText )
{
int DrawMode = g_XorMode;
......
......@@ -3,113 +3,52 @@
/*****************************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "appl_wxstruct.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.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
*
* Clear all already loaded libraries and load all librairies
* given in frame->m_ComponentLibFiles
* Clear all already loaded libraries and load all of the project libraries.
*/
void LoadLibraries( WinEDA_SchematicFrame* frame )
void WinEDA_SchematicFrame::LoadLibraries( void )
{
size_t ii;
wxFileName fn;
wxString msg, tmp;
wxString msg, tmp, errMsg;
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
LibraryStruct* nextlib, * lib = g_LibraryList;
CMP_LIBRARY_LIST::iterator i = CMP_LIBRARY::GetLibraryList().begin();
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( lib->m_IsLibCache )
if( i->IsCache() )
{
i++;
continue;
}
// is this library in "wanted list" frame->m_ComponentLibFiles ?
if( frame->m_ComponentLibFiles.Index( lib->m_Name ) == wxNOT_FOUND )
FreeCmpLibrary( frame, lib->m_Name );
if( m_ComponentLibFiles.Index( i->GetName(), false ) == wxNOT_FOUND )
i = CMP_LIBRARY::GetLibraryList().erase( i );
else
i++;
}
// Load missing libraries (if any)
for( ii = 0; ii < iimax; ii++ )
/* Load missing libraries. */
for( ii = 0; ii < m_ComponentLibFiles.GetCount(); ii++ )
{
fn = frame->m_ComponentLibFiles[ii];
fn = m_ComponentLibFiles[ii];
fn.SetExt( CompLibFileExtension );
/* Skip if the file name is not valid.. */
if( !fn.IsOk() )
continue;
......@@ -129,164 +68,46 @@ void LoadLibraries( WinEDA_SchematicFrame* frame )
// Loaded library statusbar message
msg = _( "Library " ) + tmp;
fn = tmp;
if( LoadLibraryName( frame, tmp, fn.GetName() ) )
if( CMP_LIBRARY::AddLibrary( fn, errMsg ) )
{
msg += _( " loaded" );
}
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!" );
}
frame->PrintMsg( msg );
PrintMsg( msg );
}
/* Print the libraries not found */
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.ListSet( libraries_not_found );
libraries_not_found.empty();
dialog.ShowModal();
}
// reorder the linked list to match the order filename list:
int NumOfLibs = 0;
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;
/* Put the libraries in the correct order. */
CMP_LIBRARY::SetSortOrder( m_ComponentLibFiles );
CMP_LIBRARY::GetLibraryList().sort();
for( ii = 0; Lib != NULL; Lib = Lib->m_Pnext )
ii++;
#ifdef __WXDEBUG__
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
case TYPE_SCH_COMPONENT:
{
EDA_LibComponentStruct* LibEntry;
SCH_COMPONENT* Struct;
LIB_COMPONENT* LibEntry;
SCH_COMPONENT* Struct;
Struct = (SCH_COMPONENT*) aItem;
LibEntry = ( EDA_LibComponentStruct* ) FindLibPart( Struct->m_ChipName );
LibEntry = CMP_LIBRARY::FindLibraryComponent( Struct->m_ChipName );
if( LibEntry == NULL )
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_Convert, g_GhostColor, FALSE );
break;
......
......@@ -21,8 +21,6 @@
// Global variables
LibraryStruct* g_LibraryList; // All part libs are saved here.
int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que
* les numeros (netlist PSPICE seulement) */
SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure
......@@ -103,8 +101,8 @@ int g_InvisibleItemColor = DARKGRAY;
LibEDA_BaseStruct* LibItemToRepeat = NULL; /* pointer on a graphic item than
* can be duplicated by the Ins key
* (usually the last created item */
LibraryStruct* CurrentLib = NULL; /* Current opened library */
EDA_LibComponentStruct* CurrentLibEntry = NULL; /* Current component */
CMP_LIBRARY* CurrentLib = NULL; /* Current opened library */
LIB_COMPONENT* CurrentLibEntry = NULL; /* Current component */
LibEDA_BaseStruct* CurrentDrawItem = NULL; /* current edited item */
// Current selected alias (for components which have aliases)
......@@ -115,9 +113,6 @@ bool g_AsDeMorgan;
int CurrentUnit = 1;
int CurrentConvert = 1;
/* Library (name) containing the last component find by FindLibPart() */
wxString FindLibName;
int DefaultTransformMatrix[2][2] = { { 1, 0 }, { 0, -1 } };
......
/****************************/
/* EESCHEMA - files-io.cpp */
/* EESCHEMA - files-io.cpp */
/****************************/
#include "fctsys.h"
......@@ -45,19 +45,18 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event )
}
/************************************************************************************/
/*
* Load an entire project
*
* Schematic root file and its subhierarchies, the configuration and the libs
* which are not already loaded)
*/
int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
bool IsNew )
/************************************************************************************/
{
/*
* Load an entire project
* ( schematic root file and its subhierarchies, the configuration and the libs
* which are not already loaded)
*/
SCH_SCREEN* screen;
wxString FullFileName, msg;
bool LibCacheExist = FALSE;
bool LibCacheExist = false;
EDA_ScreenList ScreenList;
......@@ -133,13 +132,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
LoadProjectFile( wxEmptyString, FALSE );
// Delete old caches.
LibraryStruct* nextlib, * lib = g_LibraryList;
for( ; lib != NULL; lib = nextlib )
{
nextlib = lib->m_Pnext;
if( lib->m_IsLibCache )
FreeCmpLibrary( this, lib->m_Name );
}
CMP_LIBRARY::RemoveCacheLibrary();
if( IsNew )
{
......@@ -164,29 +157,44 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
fn.SetExt( wxT( "cache.lib" ) );
use_oldcachename = true;
}
if( fn.FileExists() )
{
wxString errMsg;
wxLogDebug( wxT( "Load schematic cache library file <%s>" ),
fn.GetFullPath().c_str() );
msg = wxT( "Load " ) + fn.GetFullPath();
LibraryStruct* LibCache = LoadLibraryName( this, fn.GetFullPath(),
fn.GetName() );
CMP_LIBRARY* LibCache = CMP_LIBRARY::LoadLibrary( fn, errMsg );
if( LibCache )
{
LibCache->m_IsLibCache = TRUE;
LibCache->SetCache();
msg += wxT( " OK" );
if ( use_oldcachename ) // set the new name
{
fn.SetName(cachename);
fn.SetExt( CompLibFileExtension );
LibCache->m_Name = fn.GetName();
LibCache->m_FullFileName = fn.GetFullPath();
LibCache->SetFileName( fn );
}
LibCacheExist = true;
CMP_LIBRARY::GetLibraryList().push_back( LibCache );
}
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" );
}
PrintMsg( msg );
LibCacheExist = TRUE;
}
if( !wxFileExists( g_RootSheet->m_AssociatedScreen->m_FileName )
......@@ -194,7 +202,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName,
{
Zoom_Automatique( FALSE );
msg.Printf( _( "File <%s> not found." ),
g_RootSheet->m_AssociatedScreen->m_FileName.GetData() );
g_RootSheet->m_AssociatedScreen->m_FileName.GetData() );
DisplayInfoMessage( this, msg, 0 );
return -1;
}
......
......@@ -8,18 +8,21 @@
* in current sheet or whole the project
*/
#include "fctsys.h"
//#include "gr_basic.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "class_marker_sch.h"
#include "protos.h"
#include <boost/foreach.hpp>
/* Variables Locales */
static int s_ItemsCount, s_MarkerCount;
......@@ -28,9 +31,6 @@ static wxString s_OldStringFound;
#include "dialog_find.cpp"
#include "protos.h"
/**************************************************************/
void WinEDA_FindFrame::FindMarker( wxCommandEvent& event )
/**************************************************************/
......@@ -645,25 +645,25 @@ void WinEDA_FindFrame::LocatePartInLibs( wxCommandEvent& event )
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();
return;
}
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() )
continue;
nbitemsFound += nameList.GetCount();
if( !Lib->m_IsLibCache )
if( !lib.IsCache() )
FoundInLib = true;
for( size_t i = 0; i < nameList.GetCount(); i++ )
......@@ -671,7 +671,7 @@ void WinEDA_FindFrame::LocatePartInLibs( wxCommandEvent& event )
if( !FindList.IsEmpty() )
FindList += wxT( "\n" );
FindList << _( "Found " ) + nameList[i] + _( " in library " )
+ Lib->m_Name;
+ lib.GetName();
}
}
......
......@@ -94,8 +94,6 @@ typedef enum {
/* 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
* les numeros (netlist PSPICE seulement) */
extern SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure
......
......@@ -8,11 +8,15 @@
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "get_component_dialog.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "class_library.h"
#include <boost/foreach.hpp>
/* Routines Locales */
......@@ -65,36 +69,28 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
wxArrayString& HistoryList,
bool UseLibBrowser )
{
int ii, CmpCount = 0;
EDA_LibComponentStruct* Entry = NULL;
SCH_COMPONENT* Component = NULL;
LibraryStruct* Library = NULL;
wxString Name, keys, msg;
bool AllowWildSeach = TRUE;
int ii, CmpCount = 0;
LIB_COMPONENT* Entry = NULL;
SCH_COMPONENT* Component = NULL;
CMP_LIBRARY* Library = NULL;
wxString Name, keys, msg;
bool AllowWildSeach = TRUE;
g_ItemToRepeat = NULL;
DrawPanel->m_IgnoreMouseEvents = TRUE;
if( !libname.IsEmpty() )
{
Library = g_LibraryList;
while( Library )
{
if( Library->GetName().CmpNoCase( libname ) == 0 )
{
CmpCount = Library->GetCount();
break;
}
Library = Library->m_Pnext;
}
Library = CMP_LIBRARY::FindLibrary( libname );
if( Library != NULL )
CmpCount = Library->GetCount();
}
else
{
LibraryStruct* lib = g_LibraryList;
while( lib )
BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
{
CmpCount += lib->GetCount();
lib = lib->m_Pnext;
CmpCount += lib.GetCount();
}
}
......@@ -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 */
{
......@@ -155,7 +151,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
Name = DataBaseGetName( this, keys, Name );
if( !Name.IsEmpty() )
Entry = ( EDA_LibComponentStruct* ) FindLibPart( Name, libname );
Entry = CMP_LIBRARY::FindLibraryComponent( Name, libname );
if( Entry == NULL )
{
......@@ -347,12 +343,12 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent,
int unit, wxDC* DC )
{
int m_UnitCount;
EDA_LibComponentStruct* LibEntry;
LIB_COMPONENT* LibEntry;
if( DrawComponent == NULL )
return;
LibEntry = ( EDA_LibComponentStruct* ) FindLibPart( DrawComponent->m_ChipName );
LibEntry = CMP_LIBRARY::FindLibraryComponent( DrawComponent->m_ChipName );
if( LibEntry == NULL )
return;
......@@ -395,12 +391,12 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
wxDC* DC )
{
int ii;
EDA_LibComponentStruct* LibEntry;
LIB_COMPONENT* LibEntry;
if( DrawComponent == NULL )
return;
LibEntry = ( EDA_LibComponentStruct* ) FindLibPart( DrawComponent->m_ChipName );
LibEntry = CMP_LIBRARY::FindLibraryComponent( DrawComponent->m_ChipName );
if( LibEntry == NULL )
return;
......@@ -441,7 +437,7 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
* Si il y a une representation type "convert",
* la valeur retournee est > 1 (typiquement 2)
*/
int LookForConvertPart( EDA_LibComponentStruct* LibEntry )
int LookForConvertPart( LIB_COMPONENT* LibEntry )
{
int ii;
LibEDA_BaseStruct* DrawLibEntry;
......
......@@ -13,15 +13,13 @@
#include "class_drawpanel.h"
#include "confirm.h"
#include "gestfich.h"
#include "id.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "id.h"
#include <wx/filename.h>
......@@ -37,10 +35,10 @@ extern int ExportPartId;
/*************************************************/
void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event )
{
wxString errMsg;
wxFileName fn;
LibraryStruct* LibTmp;
LibCmpEntry* LibEntry;
bool entryLoaded = false;
CMP_LIBRARY* LibTmp;
CMP_LIB_ENTRY* LibEntry;
LibItemToRepeat = NULL;
......@@ -51,33 +49,35 @@ void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event )
if( dlg.ShowModal() == wxID_CANCEL )
return;
LibTmp = g_LibraryList;
g_LibraryList = NULL;
fn = dlg.GetPath();
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();
if( LibEntry )
entryLoaded = LoadOneLibraryPartAux( LibEntry, g_LibraryList );
FreeCmpLibrary( this, g_LibraryList->m_Name );
if( entryLoaded )
{
fn = dlg.GetPath();
m_LastLibImportPath = fn.GetPath();
ReCreateHToolbar();
DisplayLibInfos();
GetScreen()->ClearUndoRedoList();
DrawPanel->Refresh();
}
else
DisplayError( this, _( "File is empty" ) );
wxString msg;
msg.Printf( _( "Component library file <%s> is empty." ),
(const wxChar*) fn.GetFullPath() );
DisplayError( this, msg );
return;
}
g_LibraryList = LibTmp;
if( LoadOneLibraryPartAux( LibEntry, LibTmp ) )
{
fn = dlg.GetPath();
m_LastLibImportPath = fn.GetPath();
DisplayLibInfos();
GetScreen()->ClearUndoRedoList();
DrawPanel->Refresh();
}
delete LibTmp;
}
......@@ -90,18 +90,18 @@ void WinEDA_LibeditFrame::OnImportPart( wxCommandEvent& event )
*/
void WinEDA_LibeditFrame::OnExportPart( wxCommandEvent& event )
{
wxFileName fn;
wxString Name, mask, title;
LibraryStruct* NewLib, * LibTmp, * CurLibTmp;
bool createLib = ( event.GetId() == ExportPartId ) ? false : true;
wxFileName fn;
wxString msg, title;
CMP_LIBRARY* CurLibTmp;
bool createLib = ( event.GetId() != ExportPartId ) ? false : true;
if( CurrentLibEntry == NULL )
{
DisplayError( this, _( "No Part to Save" ), 10 );
DisplayError( this, _( "There is no component selected to save." ) );
return;
}
fn = CurrentLibEntry->m_Name.m_Text.Lower();
fn = CurrentLibEntry->GetName().Lower();
fn.SetExt( CompLibFileExtension );
title = createLib ? _( "New Library" ) : _( "Export Component" );
......@@ -114,38 +114,26 @@ void WinEDA_LibeditFrame::OnExportPart( wxCommandEvent& event )
fn = dlg.GetPath();
/* Creation d'une librairie standard pour sauvegarde */
LibTmp = g_LibraryList;
CurLibTmp = CurrentLib;
NewLib = new LibraryStruct( LIBRARY_TYPE_EESCHEMA, wxT( "$libTmp$" ),
fn.GetFullName() );
CurrentLib = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, fn );
g_LibraryList = NewLib;
/* Sauvegarde du composant: */
CurrentLib = NewLib;
SaveOnePartInMemory();
bool success = NewLib->Save( fn.GetFullPath() );
bool success = CurrentLib->Save( fn.GetFullPath() );
if( success )
{
m_LastLibExportPath = fn.GetPath();
}
/* Suppression de la librarie temporaire */
FreeCmpLibrary( this, NewLib->m_Name );
g_LibraryList = LibTmp;
CurrentLib = CurLibTmp;
delete CurrentLib;
CurrentLib = CurLibTmp;
wxString msg;
if( createLib && success )
{
msg = fn.GetFullPath() + _( " - OK" );
DisplayInfoMessage( this,
_( "Note: this new library will be available only \
if it is loaded by eeschema.\nModify eeschema config if you want use it." ) );
DisplayInfoMessage( this, _( "This library will not be available \
until it is loaded by EESchema.\nModify the EESchema library configuration \
if you want to include it as part of this project." ) );
}
else
msg = _( "Error creating " ) + fn.GetFullName();
......
......@@ -2,123 +2,61 @@
/* libarch.cc */
/* Module de generation du fichier d'archivage des composants */
/**************************************************************/
#include <algorithm> // to use sort vector
#include <vector>
#include "fctsys.h"
#include "common.h"
#include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "netlist.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
*/
bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName )
{
wxFileName docFileName;
wxString msg;
char Line[256];
FILE* ArchiveFile, * DocFile;
EDA_LibComponentStruct* Entry;
std::vector <EDA_LibComponentStruct*> ListEntry;
wxString msg;
LIB_COMPONENT* Entry;
CMP_LIBRARY* libCache;
EDA_ScreenList ScreenList;
/* 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
libCache = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, ArchFullFileName );
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 )
continue;
SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) SchItem;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( DrawLibItem->m_ChipName );
SCH_COMPONENT* component = (SCH_COMPONENT*) SchItem;
Entry = CMP_LIBRARY::FindLibraryComponent( component->m_ChipName );
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 );
return false;
}
fprintf( ArchiveFile, "%s %s\n#\n", LIBFILE_IDENT, DateAndTime( Line ) );
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;
return true;
}
......@@ -8,19 +8,33 @@
#define LIB_VERSION_MAJOR 2
#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 {
LOCATE_COMPONENT_ARC_DRAW_TYPE = 1,
LOCATE_COMPONENT_CIRCLE_DRAW_TYPE = 2,
#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_CIRCLE_DRAW_TYPE = 2,
LOCATE_COMPONENT_GRAPHIC_TEXT_DRAW_TYPE = 4,
LOCATE_COMPONENT_RECT_DRAW_TYPE = 8,
LOCATE_LINE_DRAW_TYPE = 0x10,
LOCATE_COMPONENT_POLYLINE_DRAW_TYPE = 0x20,
LOCATE_COMPONENT_LINE_DRAW_TYPE = 0x40
LOCATE_COMPONENT_RECT_DRAW_TYPE = 8,
LOCATE_LINE_DRAW_TYPE = 0x10,
LOCATE_COMPONENT_POLYLINE_DRAW_TYPE = 0x20,
LOCATE_COMPONENT_LINE_DRAW_TYPE = 0x40
};
#define LOCATE_ALL_DRAW_ITEM 0xFFFFFFFF
......@@ -29,21 +43,17 @@ enum LocateDrawStructType {
#include "class_library.h"
/* Variables */
extern LibraryStruct* LibraryList; /* All part libs are saved here. */
/* Variables used by LibEdit */
extern LibEDA_BaseStruct* LibItemToRepeat; /* pointer on a graphic item than can be duplicated by the Ins key
* (usually the last created item */
extern LibraryStruct* CurrentLib; /* Current opened library */
extern EDA_LibComponentStruct* CurrentLibEntry; /* Current component */
extern LibEDA_BaseStruct* CurrentDrawItem; /* current edited item */
extern LibEDA_BaseStruct* LibItemToRepeat; /* pointer on a graphic item than
* can be duplicated by the Ins key
* (usually the last created item */
extern CMP_LIBRARY* CurrentLib; /* Current opened library */
extern LIB_COMPONENT* CurrentLibEntry; /* Current component */
extern LibEDA_BaseStruct* CurrentDrawItem; /* current edited item */
extern wxString CurrentAliasName;
extern bool g_AsDeMorgan;
extern int CurrentUnit;
extern int CurrentConvert;
extern wxString FindLibName;
#endif // LIBCMP_H
This diff is collapsed.
......@@ -78,12 +78,7 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawEntry->DisplayInfo( this );
else
{
if( CurrentAliasName.IsEmpty() )
DisplayCmpDoc( CurrentAliasName );
else
DisplayCmpDoc( CurrentLibEntry->GetName() );
}
DisplayCmpDoc();
}
}
......@@ -151,13 +146,7 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
LOCATE_ALL_DRAW_ITEM );
}
if( DrawEntry == NULL )
{
if( CurrentAliasName.IsEmpty() )
DisplayCmpDoc( CurrentLibEntry->GetName() );
else
DisplayCmpDoc( CurrentAliasName );
break;
}
DisplayCmpDoc();
SaveCopyInUndoList( CurrentLibEntry );
if( DrawEntry->Type() == COMPONENT_PIN_DRAW_TYPE )
DeletePin( DC, CurrentLibEntry, (LibDrawPin*) DrawEntry );
......
......@@ -19,11 +19,11 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
int unused_flag )
/*************************************************************************/
{
EDA_BaseStruct* item;
EDA_LibComponentStruct* CopyItem;
EDA_BaseStruct* item;
LIB_COMPONENT* CopyItem;
PICKED_ITEMS_LIST* lastcmd;
CopyItem = CopyLibEntryStruct( (EDA_LibComponentStruct*) ItemToCopy );
CopyItem = CopyLibEntryStruct( (LIB_COMPONENT*) ItemToCopy );
if( CopyItem == NULL )
return;
......@@ -62,7 +62,7 @@ void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event)
lastcmd = GetScreen()->PopCommandFromRedoList( );
wrapper = lastcmd->PopItem();
CurrentLibEntry = (EDA_LibComponentStruct*) wrapper.m_PickedItem;
CurrentLibEntry = (LIB_COMPONENT*) wrapper.m_PickedItem;
if( CurrentLibEntry )
CurrentLibEntry->SetNext( NULL );
CurrentDrawItem = NULL;
......@@ -92,7 +92,7 @@ void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event)
lastcmd = GetScreen()->PopCommandFromUndoList( );
wrapper = lastcmd->PopItem();
CurrentLibEntry = (EDA_LibComponentStruct*) wrapper.m_PickedItem;
CurrentLibEntry = (LIB_COMPONENT*) wrapper.m_PickedItem;
if( CurrentLibEntry )
CurrentLibEntry->SetNext( NULL );
......
......@@ -216,7 +216,7 @@ names in the alias list." ),
entry in the component library <%s>.\nPlease choose another name that does \
not conflict with any library entries." ),
(const wxChar*) Text,
(const wxChar*) CurrentLib->m_Name );
(const wxChar*) CurrentLib->GetName() );
DisplayError( this, msg );
return;
}
......@@ -294,7 +294,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field )
* return:
* 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;
/* Test reference */
......
......@@ -17,6 +17,9 @@
#include "bitmaps.h"
#include "protos.h"
#include "id.h"
#include "class_library.h"
#include <boost/foreach.hpp>
/* Library editor wxConfig entry names. */
......@@ -147,6 +150,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
ReCreateHToolbar();
ReCreateVToolbar();
DisplayLibInfos();
DisplayCmpDoc();
UpdateAliasSelectList();
UpdatePartSelectList();
BestZoom();
......@@ -204,8 +208,6 @@ void WinEDA_LibeditFrame::SaveSettings()
void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
{
LibraryStruct* Lib;
if( GetScreen()->IsModify() )
{
if( !IsOK( this, _( "Component was modified!\nDiscard changes?" ) ) )
......@@ -217,13 +219,13 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
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;
msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ),
Lib->m_Name.GetData() );
(const wxChar*) lib.GetName() );
if( !IsOK( this, msg ) )
{
Event.Veto();
......@@ -358,7 +360,8 @@ void WinEDA_LibeditFrame::OnUpdateRedo( 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 )
{
if( !CurrentAliasName.IsEmpty() )
{
LibCmpEntry* entry = CurrentLib->FindEntry( CurrentAliasName );
CMP_LIB_ENTRY* entry = CurrentLib->FindEntry( CurrentAliasName );
if( entry != NULL )
enable = !entry->m_DocFile.IsEmpty();
......@@ -452,11 +455,9 @@ void WinEDA_LibeditFrame::OnSelectAlias( wxCommandEvent& event )
if( m_SelAliasBox->GetStringSelection().CmpNoCase(CurrentLibEntry->GetName() ) == 0 )
CurrentAliasName.Empty();
else
{
CurrentAliasName = m_SelAliasBox->GetStringSelection();
DisplayCmpDoc( CurrentAliasName );
}
DisplayCmpDoc();
DrawPanel->Refresh();
}
......@@ -464,11 +465,14 @@ void WinEDA_LibeditFrame::OnSelectAlias( wxCommandEvent& event )
void WinEDA_LibeditFrame::OnSelectPart( wxCommandEvent& event )
{
int i = event.GetSelection();
if( i < 0 )
if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == CurrentUnit ) )
return;
LibItemToRepeat = NULL;
CurrentUnit = i + 1;
DrawPanel->Refresh();
DisplayCmpDoc();
}
......@@ -585,7 +589,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
wxString docfilename;
if( !CurrentAliasName.IsEmpty() )
{
LibCmpEntry* entry = CurrentLib->FindEntry( CurrentAliasName );
CMP_LIB_ENTRY* entry = CurrentLib->FindEntry( CurrentAliasName );
if( entry != NULL )
docfilename = entry->m_DocFile;
}
......
......@@ -612,12 +612,12 @@ static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
/*********************************************************************************/
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
const wxPoint& aRefPoint,
EDA_LibComponentStruct* LibEntry,
int Unit,
int Convert,
int masque )
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
const wxPoint& aRefPoint,
LIB_COMPONENT* LibEntry,
int Unit,
int Convert,
int masque )
/*********************************************************************************/
/* Locates a body item( not pins )
......@@ -718,11 +718,11 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
*/
{
LibEDA_BaseStruct* DrawItem;
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
LibDrawPin* Pin;
int Unit, Convert;
Entry = ( EDA_LibComponentStruct* )FindLibPart( eComponent->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( eComponent->m_ChipName );
if( Entry == NULL )
return NULL;
......@@ -760,8 +760,7 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
/*******************************************************************/
LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos,
EDA_LibComponentStruct* Entry,
LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos, LIB_COMPONENT* Entry,
int Unit, int convert, SCH_COMPONENT* DrawLibItem )
/*******************************************************************/
......@@ -850,7 +849,7 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos,
/**************************************************************************/
{
SCH_ITEM* DrawStruct;
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
SCH_COMPONENT* LibItem = NULL;
LibDrawPin* Pin = NULL;
......@@ -859,7 +858,7 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos,
if( DrawStruct->Type() != TYPE_SCH_COMPONENT )
continue;
LibItem = (SCH_COMPONENT*) DrawStruct;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( LibItem->m_ChipName );
Entry = CMP_LIBRARY::FindLibraryComponent( LibItem->m_ChipName );
if( Entry == NULL )
continue;
......
......@@ -28,9 +28,9 @@ static void WriteGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList )
static void AddPinToComponentPinList( SCH_COMPONENT* Component,
DrawSheetPath* sheet,
LibDrawPin* PinEntry );
static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component,
EDA_LibComponentStruct* Entry,
DrawSheetPath* Sheet_in );
static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component,
LIB_COMPONENT* Entry,
DrawSheetPath* Sheet_in );
static bool SortPinsByNum( NETLIST_OBJECT* Pin1, NETLIST_OBJECT* Pin2 );
static void EraseDuplicatePins( NETLIST_OBJECT_LIST& aPinList );
......@@ -108,9 +108,9 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
* Must be deallocated by the user
*/
{
SCH_COMPONENT* Component = NULL;
EDA_LibComponentStruct* Entry;
LibEDA_BaseStruct* DEntry;
SCH_COMPONENT* Component = NULL;
LIB_COMPONENT* Entry;
LibEDA_BaseStruct* DEntry;
s_SortedComponentPinList.clear();
for( ; DrawList != NULL; DrawList = DrawList->Next() )
......@@ -130,7 +130,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
// removed because with multiple instances of one schematic
// (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 )
continue;
......@@ -550,8 +550,8 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
break;
/* Get the Component FootprintFilter and put the component in CmpList if filter is not void */
EDA_LibComponentStruct* Entry =
( EDA_LibComponentStruct* ) FindLibPart( Component->m_ChipName );
LIB_COMPONENT* Entry =
CMP_LIBRARY::FindLibraryComponent( Component->m_ChipName );
if( Entry != NULL )
{
......@@ -628,11 +628,11 @@ static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with
if( with_pcbnew && CmpList )
{
fprintf( f, "{ Allowed footprints by component:\n" );
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
for( int ii = 0; ii < CmpListCount; ii++ )
{
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.Replace( wxT( " " ), wxT( "_" ) );
......@@ -754,9 +754,9 @@ static void EraseDuplicatePins( NETLIST_OBJECT_LIST& aPinList )
/**********************************************************************************/
static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in,
EDA_LibComponentStruct* Entry,
DrawSheetPath* Sheet_in )
static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in,
LIB_COMPONENT* Entry,
DrawSheetPath* Sheet_in )
/**********************************************************************************/
/**
......
......@@ -353,7 +353,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
SCH_ITEM* DrawList;
NETLIST_OBJECT* new_item;
SCH_COMPONENT* DrawLibItem;
EDA_LibComponentStruct* Entry;
LIB_COMPONENT* Entry;
LibEDA_BaseStruct* DEntry;
Hierarchical_PIN_Sheet_Struct* SheetLabel;
DrawSheetPath list;
......@@ -472,8 +472,8 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) DrawList;
Entry = ( EDA_LibComponentStruct* )FindLibPart(
DrawLibItem->m_ChipName );
Entry =
CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry == NULL )
break;
......
......@@ -43,11 +43,11 @@ enum TypeNetForm {
class OBJ_CMP_TO_LIST
{
public:
SCH_COMPONENT* m_RootCmp; // the component in schematic
EDA_LibComponentStruct* m_Entry; // the source component in library
int m_Unit; /* Selected part (For multi parts per package) depending on sheet path */
DrawSheetPath m_SheetPath; /* the sheet path for this component */
unsigned long m_TimeStamp; /* unique identification number depending on sheet path */
SCH_COMPONENT* m_RootCmp; // the component in schematic
LIB_COMPONENT* m_Entry; // the source component in library
int m_Unit; /* Selected part (For multi parts per package) depending on sheet path */
DrawSheetPath m_SheetPath; /* the sheet path for this component */
unsigned long m_TimeStamp; /* unique identification number depending on sheet path */
bool m_IsNew; /* true for not yet annotated components */
wxString* m_Value; /* Component value (same for all instances) */
char m_Reference[32]; /* Component reference prefix, without number (for IC1, this is IC) ) */
......
This diff is collapsed.
......@@ -501,9 +501,9 @@ void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize )
/*************************************************/
void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
EDA_LibComponentStruct* LibEntry,
LibDrawPin* Pin )
void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
LIB_COMPONENT* LibEntry,
LibDrawPin* Pin )
/*************************************************/
/* Routine d'effacement de la pin pointee par la souris
......@@ -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...)
......
......@@ -50,14 +50,14 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
/*************************************************/
/* Polt a component */
{
int ii, t1, t2, * Poly, orient;
EDA_LibComponentStruct* Entry;
int TransMat[2][2], Multi, convert;
EDA_Colors CharColor = UNSPECIFIED_COLOR;
wxPoint pos;
bool draw_bgfill = false;
Entry = ( EDA_LibComponentStruct* ) FindLibPart( DrawLibItem->m_ChipName );
int ii, t1, t2, * Poly, orient;
LIB_COMPONENT* Entry;
int TransMat[2][2], Multi, convert;
EDA_Colors CharColor = UNSPECIFIED_COLOR;
wxPoint pos;
bool draw_bgfill = false;
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry == NULL )
return;;
memcpy( TransMat, DrawLibItem->m_Transform, sizeof(TransMat) );
......
......@@ -2,11 +2,11 @@
/* prototypage des fonctions de EESchema */
/*****************************************/
LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos,
EDA_LibComponentStruct* Entry,
int Unit,
int Convert,
SCH_COMPONENT* DrawItem = NULL );
LibEDA_BaseStruct* LocatePin( const wxPoint& RefPos,
LIB_COMPONENT* Entry,
int Unit,
int Convert,
SCH_COMPONENT* DrawItem = NULL );
/* Routine de localisation d'une PIN de la PartLib pointee par Entry */
......@@ -40,22 +40,16 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
/******************************/
/* EELIBS_DRAW_COMPONENTS.CPP */
/******************************/
int NumOfLibraries();
LibCmpEntry* FindLibPart( const wxChar* Name,
const wxString& LibName = wxEmptyString,
LibrEntryType Alias = ROOT );
void DrawingLibInGhost( WinEDA_DrawPanel* panel,
wxDC* DC,
EDA_LibComponentStruct* LibEntry,
SCH_COMPONENT* DrawLibItem,
int PartX,
int PartY,
int Multi,
int convert,
int Color,
bool DrawPinText );
void DrawingLibInGhost( WinEDA_DrawPanel* panel,
wxDC* DC,
LIB_COMPONENT* LibEntry,
SCH_COMPONENT* DrawLibItem,
int PartX,
int PartY,
int Multi,
int convert,
int Color,
bool DrawPinText );
bool MapAngles( int* Angle1,
int* Angle2,
......@@ -73,14 +67,6 @@ bool MapAngles( int* Angle1,
wxPoint TransformCoordinate( const int aTransformMatrix[2][2],
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,
int OrigY,
int* ClosestX,
......@@ -153,12 +139,12 @@ SCH_ITEM* PickStruct( const wxPoint& refpos,
int SearchMask );
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
const wxPoint& refpoint,
EDA_LibComponentStruct* LibEntry,
int Unit,
int Convert,
int masque );
LibEDA_BaseStruct* LocateDrawItem( SCH_SCREEN* Screen,
const wxPoint& refpoint,
LIB_COMPONENT* LibEntry,
int Unit,
int Convert,
int masque );
Hierarchical_PIN_Sheet_Struct* LocateSheetLabel( DrawSheetStruct* Sheet,
const wxPoint& pos );
......@@ -216,7 +202,7 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose );
/* SAVELIB.CPP */
/**************/
EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry );
LIB_COMPONENT* CopyLibEntryStruct( LIB_COMPONENT* OldEntry );
/* Routine de copie d'une partlib
* Parametres d'entree: pointeur sur la structure de depart
......@@ -262,7 +248,7 @@ void DeleteAllMarkers( int type );
/* GETPART.CPP */
/**************/
int LookForConvertPart( EDA_LibComponentStruct* LibEntry );
int LookForConvertPart( LIB_COMPONENT* LibEntry );
/* Retourne la plus grande valeur trouvee dans la liste des elements
* "drawings" du composant LibEntry, pour le membre .Convert
......@@ -295,7 +281,7 @@ void InstallPineditFrame( WinEDA_LibeditFrame* parent,
* 0 si commande annulee
*/
int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
LibraryStruct* Library,
CMP_LIBRARY* Library,
wxString& Buffer,
wxString& OldName );
......@@ -305,7 +291,7 @@ int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
* a library
* 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
......@@ -319,7 +305,7 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame );
* BufName
*/
int GetNameOfPartToLoad( WinEDA_DrawFrame* frame,
LibraryStruct* Lib,
CMP_LIBRARY* Lib,
wxString& BufName );
/**************/
......
......@@ -8,12 +8,16 @@
#include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "macros.h"
#include "protos.h"
#include "class_library.h"
#include <boost/foreach.hpp>
/* Fonctions Locales */
static void SaveLayers( FILE* f );
......@@ -119,11 +123,12 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
wxString datetime = DateAndTime( );
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 )
Name += wxT( "," );
Name += Lib->m_Name;
Name += lib.GetName();
first = false;
}
......
......@@ -25,13 +25,13 @@
* Parametres de sortie: pointeur sur la structure creee
* 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;
EDA_LibComponentStruct* NewStruct;
LibEDA_BaseStruct* NewDrawings, * OldDrawings;
LibEDA_BaseStruct* LastItem;
LibDrawField* OldField, * NewField;
wxString msg;
LIB_COMPONENT* NewStruct;
LibEDA_BaseStruct* NewDrawings, * OldDrawings;
LibEDA_BaseStruct* LastItem;
LibDrawField* OldField, * NewField;
if( OldEntry->Type != ROOT )
{
......@@ -41,7 +41,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry )
return NULL;
}
NewStruct = new EDA_LibComponentStruct( NULL );
NewStruct = new LIB_COMPONENT( wxEmptyString );
OldEntry->m_Prefix.Copy( &NewStruct->m_Prefix );
OldEntry->m_Name.Copy( &NewStruct->m_Name );
......
......@@ -649,10 +649,10 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
if( screen->GetCurItem() == NULL )
break;
{
LibCmpEntry* LibEntry;
LibEntry = FindLibPart(
( (SCH_COMPONENT*) screen->GetCurItem() )->m_ChipName,
wxEmptyString, ALIAS );
CMP_LIB_ENTRY* LibEntry;
LibEntry = CMP_LIBRARY::FindLibraryEntry(
( (SCH_COMPONENT*) screen->GetCurItem() )->m_ChipName );
if( LibEntry && LibEntry->m_DocFile != wxEmptyString )
{
GetAssociatedDocument( this, LibEntry->m_DocFile ,
......
......@@ -13,37 +13,23 @@
#include "protos.h"
LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame )
CMP_LIBRARY* SelectLibraryFromList( WinEDA_DrawFrame* frame )
{
static wxString OldLibName;
wxString LibName, msg;
int count = NumOfLibraries();
LibraryStruct* Lib = NULL;
wxString msg;
wxArrayString libNamesList;
int count = CMP_LIBRARY::GetLibraryCount();
CMP_LIBRARY* Lib = NULL;
if( count == 0 )
{
DisplayError( frame, _( "No libraries are loaded" ) );
DisplayError( frame, _( "No component libraries are loaded." ) );
return NULL;
}
msg.Printf( _( " Select 1 of %d libraries." ), count );
wxArrayString libNamesList;
LibraryStruct* libcache = NULL;
libNamesList = CMP_LIBRARY::GetLibraryNames();
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 );
msg.Printf( _( " Select 1 of %d libraries." ), count );
wxSingleChoiceDialog dlg( frame, msg, _( "Select Library" ), libNamesList );
......@@ -55,7 +41,7 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame )
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() )
return NULL;
Lib = FindLibrary( dlg.GetStringSelection() );
Lib = CMP_LIBRARY::FindLibrary( dlg.GetStringSelection() );
if( Lib != NULL )
OldLibName = dlg.GetStringSelection();
......@@ -65,7 +51,7 @@ LibraryStruct* SelectLibraryFromList( WinEDA_DrawFrame* frame )
int DisplayComponentsNamesInLib( WinEDA_DrawFrame* frame,
LibraryStruct* Library,
CMP_LIBRARY* Library,
wxString& Buffer, wxString& OldName )
{
size_t i;
......@@ -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 )
{
int ii;
......
......@@ -179,8 +179,8 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
/*******************************************************************************************/
LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( EDA_LibComponentStruct* LibEntry,
wxDC* DC )
LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry,
wxDC* DC )
/*******************************************************************************************/
/* Routine de creation d'un nouvel element type LibraryDrawStruct
......
......@@ -30,11 +30,11 @@
*/
void WinEDA_LibeditFrame::LoadOneSymbol( void )
{
EDA_LibComponentStruct* Component;
LibEDA_BaseStruct* DrawEntry;
FILE* ImportFile;
wxString msg, err;
LibraryStruct* Lib;
LIB_COMPONENT* Component;
LibEDA_BaseStruct* DrawEntry;
FILE* ImportFile;
wxString msg, err;
CMP_LIBRARY* Lib;
/* Exit if no library entry is selected or a command is in progress. */
if( CurrentLibEntry == NULL
......@@ -70,8 +70,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
return;
}
Lib = new LibraryStruct( LIBRARY_TYPE_SYMBOL, fn.GetName(),
fn.GetFullPath() );
Lib = new CMP_LIBRARY( LIBRARY_TYPE_SYMBOL, fn );
if( !Lib->Load( err ) )
{
......@@ -96,7 +95,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
if( Lib->GetCount() > 1 )
DisplayError( this, _( "Warning: more than 1 part in Symbol File" ) );
Component = (EDA_LibComponentStruct*) Lib->GetFirstEntry();
Component = (LIB_COMPONENT*) Lib->GetFirstEntry();
DrawEntry = Component->m_Drawings;
while( DrawEntry )
......
......@@ -3,27 +3,23 @@
/****************************************************************/
#include "fctsys.h"
#include "common.h"
#include "bitmaps.h"
#include "id.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "wx/spinctrl.h"
#include "protos.h"
#include "bitmaps.h"
#include "id.h"
#include "class_library.h"
void WinEDA_ViewlibFrame::ReCreateHToolbar()
{
int ii;
LibraryStruct* lib;
EDA_LibComponentStruct* component = NULL;
LibCmpEntry* entry = NULL;
CMP_LIBRARY* lib;
LIB_COMPONENT* component = NULL;
CMP_LIB_ENTRY* entry = NULL;
bool asdeMorgan = false;
if( m_HToolBar == NULL )
......@@ -108,7 +104,7 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
if( (g_CurrentViewLibraryName != wxEmptyString)
&& (g_CurrentViewComponentName != wxEmptyString) )
{
lib = FindLibrary( g_CurrentViewLibraryName );
lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
if( lib != NULL )
{
......
......@@ -5,13 +5,15 @@
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "id.h"
#include "class_drawpanel.h"
#include "bitmaps.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "bitmaps.h"
#include "protos.h"
#include "id.h"
/*****************************/
/* class WinEDA_ViewlibFrame */
......@@ -60,9 +62,9 @@ static wxAcceleratorEntry accels[] =
#define EXTRA_BORDER_SIZE 2
WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
LibraryStruct* Library,
wxSemaphore* semaphore ) :
WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
CMP_LIBRARY* Library,
wxSemaphore* semaphore ) :
WinEDA_DrawFrame( father, VIEWER_FRAME, _( "Library browser" ),
wxDefaultPosition, wxDefaultSize )
{
......@@ -117,7 +119,7 @@ WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
}
else
{
g_CurrentViewLibraryName = Library->m_Name;
g_CurrentViewLibraryName = Library->GetName();
m_LibListSize.x = 0;
}
......@@ -277,14 +279,14 @@ int WinEDA_ViewlibFrame::BestZoom()
{
int bestzoom, ii, jj;
wxSize size, itemsize;
EDA_LibComponentStruct* component;
LibraryStruct* lib;
LIB_COMPONENT* component;
CMP_LIBRARY* lib;
GetScreen()->m_Curseur.x = 0;
GetScreen()->m_Curseur.y = 0;
bestzoom = 16;
lib = FindLibrary( g_CurrentViewLibraryName );
lib = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
if( lib == NULL )
return 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.
* This list is sorted, with the library cache always at end of the list
*/
*/
void WinEDA_ViewlibFrame::ReCreateListLib()
{
LibraryStruct * libcache = NULL;
bool found = FALSE;
wxArrayString libNamesList;
bool found = false;
if( m_LibList == NULL )
return;
m_LibList->Clear();
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 );
libNamesList = CMP_LIBRARY::GetLibraryNames();
m_LibList->Append( libNamesList );
// Search for a previous selection:
......@@ -379,7 +366,7 @@ void WinEDA_ViewlibFrame::ReCreateListCmp()
if( m_CmpList == NULL )
return;
LibraryStruct* Library = FindLibrary( g_CurrentViewLibraryName );
CMP_LIBRARY* Library = CMP_LIBRARY::FindLibrary( g_CurrentViewLibraryName );
wxArrayString nameList;
m_CmpList->Clear();
......
This diff is collapsed.
......@@ -155,7 +155,8 @@ public:
* Check to see if the cursor is being managed for block or editing
* commands and release it.
*/
void UnManageCursor( void );
void UnManageCursor( int id = -1, int cursor = -1,
const wxString& title = wxEmptyString );
DECLARE_EVENT_TABLE()
};
......
......@@ -289,9 +289,6 @@ void Affiche_1_Parametre( WinEDA_DrawFrame* frame,
const wxString& texte_L,
int color );
void AfficheDoc( WinEDA_DrawFrame* frame, const wxString& Doc,
const wxString& KeyW );
/* Routine d'affichage de la documentation associee a un composant */
int GetTimeStamp();
......
This diff is collapsed.
......@@ -362,6 +362,10 @@ protected:
*/
static wxSize computeFontSize();
/**
* Calculate the width and height of a text string using the system UI font.
*/
wxSize computeTextSize( const wxString& text );
public:
WinEDA_DrawFrame* m_Parent;
......@@ -386,6 +390,21 @@ public:
void Affiche_1_Parametre( int pos_X, const wxString& texte_H,
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()
};
......
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