Commit 3803b79a authored by stambaughw's avatar stambaughw

Component library editor improvements, build fix, and bug fixes.

* Add offset and block hit testing to library component objects.
* Improved search for library entries.
* Fixed library component editor component removal and addition.
* Library editor now uses wxUpdateUIEvents for updating all UI objects.
* Added version check to cmake find boost macro.
* Removed unused code in file libalias.cpp.
* Added method to WinEDA_DrawPanel to take mouse out of managed mode.
parent 7a0f7bda
...@@ -107,7 +107,7 @@ check_find_package_result(OPENGL_FOUND "OpenGL") ...@@ -107,7 +107,7 @@ check_find_package_result(OPENGL_FOUND "OpenGL")
###################### ######################
# Find Boost library # # Find Boost library #
###################### ######################
find_package(Boost QUIET) find_package(Boost 1.36 QUIET)
check_find_package_result(Boost_FOUND "Boost") check_find_package_result(Boost_FOUND "Boost")
########################## ##########################
......
...@@ -1377,3 +1377,15 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event ) ...@@ -1377,3 +1377,15 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event )
Scroll( x, y ); Scroll( x, y );
MouseToCursorSchema(); MouseToCursorSchema();
} }
void WinEDA_DrawPanel::UnManageCursor( void )
{
wxClientDC dc( this );
if( ManageCurseur && ForceCloseManageCurseur )
{
ForceCloseManageCurseur( this, &dc );
m_AutoPAN_Request = false;
}
}
...@@ -77,7 +77,6 @@ set(EESCHEMA_SRCS ...@@ -77,7 +77,6 @@ set(EESCHEMA_SRCS
getpart.cpp getpart.cpp
hierarch.cpp hierarch.cpp
hotkeys.cpp hotkeys.cpp
libalias.cpp
libarch.cpp libarch.cpp
libedit.cpp libedit.cpp
libedit_onleftclick.cpp libedit_onleftclick.cpp
......
...@@ -93,100 +93,10 @@ int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent, ...@@ -93,100 +93,10 @@ int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent,
continue; continue;
} }
switch( item->Type() ) if( item->Inside( Rect ) )
{
case COMPONENT_ARC_DRAW_TYPE:
{
pos = ( (LibDrawArc*) item )->m_ArcStart; pos.y = -pos.y;
if( Rect.Inside( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
pos = ( (LibDrawArc*) item )->m_ArcEnd; pos.y = -pos.y;
if( Rect.Inside( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
break;
}
case COMPONENT_CIRCLE_DRAW_TYPE:
pos = ( (LibDrawCircle*) item )->m_Pos; pos.y = -pos.y;
if( Rect.Inside( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
break;
case COMPONENT_RECT_DRAW_TYPE:
pos = ( (LibDrawSquare*) item )->m_Pos; pos.y = -pos.y;
if( Rect.Inside( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
pos = ( (LibDrawSquare*) item )->m_End; pos.y = -pos.y;
if( Rect.Inside( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
{ {
int ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount(); item->m_Selected = IS_SELECTED;
for( ii = 0; ii < imax; ii ++ ) ItemsCount++;
{
pos = ( (LibDrawPolyline*) item )->m_PolyPoints[ii];
NEGATE( pos.y );
if( Rect.Inside( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
break;
}
}
}
break;
case COMPONENT_LINE_DRAW_TYPE:
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
pos = ( (LibDrawText*) item )->m_Pos; pos.y = -pos.y;
if( Rect.Inside( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
break;
case COMPONENT_PIN_DRAW_TYPE:
#undef STRUCT
#define STRUCT ( (LibDrawPin*) item )
pos = STRUCT->m_Pos; pos.y = -pos.y;
if( Rect.Inside( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
pos = STRUCT->ReturnPinEndPoint(); pos.y = -pos.y;
if( Rect.Inside( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
break;
case COMPONENT_FIELD_DRAW_TYPE:
break;
default:
break;
} }
} }
...@@ -513,54 +423,12 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset ) ...@@ -513,54 +423,12 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
return; return;
NEGATE( offset.y ); // Y axis for lib items is Down to Up: reverse y offset value NEGATE( offset.y ); // Y axis for lib items is Down to Up: reverse y offset value
item = LibEntry->m_Drawings; for( item = LibEntry->m_Drawings; item != NULL; item = item->Next() )
for( ; item != NULL; item = item->Next() )
{ {
if( item->m_Selected == 0 ) if( item->m_Selected == 0 )
continue; continue;
switch( item->Type() ) item->SetOffset( offset );
{
case COMPONENT_PIN_DRAW_TYPE:
( (LibDrawPin*) item )->m_Pos += offset;
break;
case COMPONENT_ARC_DRAW_TYPE:
{
( (LibDrawArc*) item )->m_Pos += offset;
( (LibDrawArc*) item )->m_ArcStart += offset;
( (LibDrawArc*) item )->m_ArcEnd += offset;
break;
}
case COMPONENT_CIRCLE_DRAW_TYPE:
( (LibDrawCircle*) item )->m_Pos += offset;
break;
case COMPONENT_RECT_DRAW_TYPE:
( (LibDrawSquare*) item )->m_Pos += offset;
( (LibDrawSquare*) item )->m_End += offset;
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
{
unsigned ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount();
for( ii = 0; ii < imax; ii ++ )
( (LibDrawPolyline*) item )->m_PolyPoints[ii] += offset;
}
break;
case COMPONENT_LINE_DRAW_TYPE:
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
( (LibDrawText*) item )->m_Pos += offset;
break;
default:
break;
}
item->m_Flags = item->m_Selected = 0; item->m_Flags = item->m_Selected = 0;
} }
} }
......
...@@ -39,11 +39,13 @@ bool LibDrawText::Save( FILE* ExportFile ) const ...@@ -39,11 +39,13 @@ bool LibDrawText::Save( FILE* ExportFile ) const
// changed to '~' // changed to '~'
text.Replace( wxT( " " ), wxT( "~" ) ); text.Replace( wxT( " " ), wxT( "~" ) );
fprintf( ExportFile, "T %d %d %d %d %d %d %d %s ", m_Orient, if( fprintf( ExportFile, "T %d %d %d %d %d %d %d %s ", m_Orient,
m_Pos.x, m_Pos.y, m_Size.x, m_Attributs, m_Unit, m_Convert, m_Pos.x, m_Pos.y, m_Size.x, m_Attributs, m_Unit, m_Convert,
CONV_TO_UTF8( text ) ); CONV_TO_UTF8( text ) ) < 0 )
fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal", return false;
( m_Bold>0 ) ? 1 : 0 ); if( fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal",
( m_Bold > 0 ) ? 1 : 0 ) < 0 )
return false;
char hjustify = 'C'; char hjustify = 'C';
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
...@@ -57,9 +59,8 @@ bool LibDrawText::Save( FILE* ExportFile ) const ...@@ -57,9 +59,8 @@ bool LibDrawText::Save( FILE* ExportFile ) const
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
vjustify = 'T'; vjustify = 'T';
fprintf( ExportFile, " %c %c", hjustify, vjustify ); if( fprintf( ExportFile, " %c %c\n", hjustify, vjustify ) < 0 )
return false;
fprintf( ExportFile, "\n" );
return true; return true;
} }
...@@ -192,6 +193,33 @@ LibEDA_BaseStruct* LibDrawText::DoGenCopy() ...@@ -192,6 +193,33 @@ LibEDA_BaseStruct* LibDrawText::DoGenCopy()
} }
bool LibDrawText::DoCompare( const LibEDA_BaseStruct& other ) const
{
wxASSERT( other.Type() == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE );
const LibDrawText* tmp = ( LibDrawText* ) &other;
return ( ( m_Pos == tmp->m_Pos ) && ( m_Size == tmp->m_Size )
&& ( m_Text == tmp->m_Text ) );
}
void LibDrawText::DoOffset( const wxPoint& offset )
{
m_Pos += offset;
}
bool LibDrawText::DoTestInside( EDA_Rect& rect )
{
/*
* FIXME: This should calculate the text size and justification and
* use rectangle instect.
*/
return rect.Inside( m_Pos.x, -m_Pos.y );
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
......
...@@ -228,15 +228,15 @@ EDA_LibCmpAliasStruct::~EDA_LibCmpAliasStruct() ...@@ -228,15 +228,15 @@ EDA_LibCmpAliasStruct::~EDA_LibCmpAliasStruct()
EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) : EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) :
LibCmpEntry( ROOT, CmpName ) LibCmpEntry( ROOT, CmpName )
{ {
m_Drawings = NULL; m_Drawings = NULL;
m_LastDate = 0; m_LastDate = 0;
m_UnitCount = 1; m_UnitCount = 1;
m_TextInside = 40; m_TextInside = 40;
m_Options = ENTRY_NORMAL; m_Options = ENTRY_NORMAL;
m_UnitSelectionLocked = FALSE; m_UnitSelectionLocked = FALSE;
m_DrawPinNum = 1; m_DrawPinNum = 1;
m_DrawPinName = 1; m_DrawPinName = 1;
m_Prefix.m_FieldId = REFERENCE; m_Prefix.m_FieldId = REFERENCE;
m_Prefix.SetParent( this ); m_Prefix.SetParent( this );
} }
...@@ -366,7 +366,7 @@ void EDA_LibComponentStruct::RemoveDrawItem( LibEDA_BaseStruct* item, ...@@ -366,7 +366,7 @@ void EDA_LibComponentStruct::RemoveDrawItem( LibEDA_BaseStruct* item,
if( dc != NULL ) if( dc != NULL )
item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
DefaultTransformMatrix ); DefaultTransformMatrix );
if( m_Drawings == item ) if( m_Drawings == item )
{ {
...@@ -404,59 +404,86 @@ bool EDA_LibComponentStruct::Save( FILE* aFile ) ...@@ -404,59 +404,86 @@ bool EDA_LibComponentStruct::Save( FILE* aFile )
return false; return false;
/* First line: it s a comment (component name for readers) */ /* First line: it s a comment (component name for readers) */
fprintf( aFile, "#\n# %s\n#\n", CONV_TO_UTF8( m_Name.m_Text ) ); if( fprintf( aFile, "#\n# %s\n#\n", CONV_TO_UTF8( m_Name.m_Text ) ) < 0 )
return false;
/* Save data */ /* Save data */
fprintf( aFile, "DEF" ); if( fprintf( aFile, "DEF" ) < 0 )
return false;
if( (m_Name.m_Attributs & TEXT_NO_VISIBLE) == 0 ) if( (m_Name.m_Attributs & TEXT_NO_VISIBLE) == 0 )
fprintf( aFile, " %s", CONV_TO_UTF8( m_Name.m_Text ) ); {
if( fprintf( aFile, " %s", CONV_TO_UTF8( m_Name.m_Text ) ) < 0 )
return false;
}
else else
fprintf( aFile, " ~%s", CONV_TO_UTF8( m_Name.m_Text ) ); {
if( fprintf( aFile, " ~%s", CONV_TO_UTF8( m_Name.m_Text ) ) < 0 )
return false;
}
if( !m_Prefix.m_Text.IsEmpty() ) if( !m_Prefix.m_Text.IsEmpty() )
fprintf( aFile, " %s", CONV_TO_UTF8( m_Prefix.m_Text ) ); {
if( fprintf( aFile, " %s", CONV_TO_UTF8( m_Prefix.m_Text ) ) < 0 )
return false;
}
else else
fprintf( aFile, " ~" ); {
fprintf( aFile, " %d %d %c %c %d %c %c\n", if( fprintf( aFile, " ~" ) < 0 )
0, m_TextInside, return false;
m_DrawPinNum ? 'Y' : 'N', }
m_DrawPinName ? 'Y' : 'N',
m_UnitCount, m_UnitSelectionLocked ? 'L' : 'F',
m_Options == ENTRY_POWER ? 'P' : 'N' );
SaveDateAndTime( aFile ); if( fprintf( aFile, " %d %d %c %c %d %c %c\n",
0, m_TextInside,
m_DrawPinNum ? 'Y' : 'N',
m_DrawPinName ? 'Y' : 'N',
m_UnitCount, m_UnitSelectionLocked ? 'L' : 'F',
m_Options == ENTRY_POWER ? 'P' : 'N' ) < 0 )
return false;
/* Save fields */ if( !SaveDateAndTime( aFile ) || !m_Prefix.Save( aFile )
m_Prefix.Save( aFile ); || !m_Name.Save( aFile ) )
m_Name.Save( aFile ); return false;
for( Field = m_Fields; Field != NULL; Field = Field->Next() ) for( Field = m_Fields; Field != NULL; Field = Field->Next() )
{ {
if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() ) if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() )
continue; continue;
Field->Save( aFile ); if( !Field->Save( aFile ) )
return false;
} }
/* Save the alias list: a line starting by "ALIAS" */ /* Save the alias list: a line starting by "ALIAS" */
if( m_AliasList.GetCount() != 0 ) if( m_AliasList.GetCount() != 0 )
{ {
fprintf( aFile, "ALIAS" ); if( fprintf( aFile, "ALIAS" ) < 0 )
unsigned ii; return false;
for( ii = 0; ii < m_AliasList.GetCount(); ii++ )
fprintf( aFile, " %s", CONV_TO_UTF8( m_AliasList[ii] ) ); for( size_t ii = 0; ii < m_AliasList.GetCount(); ii++ )
{
if( fprintf( aFile, " %s", CONV_TO_UTF8( m_AliasList[ii] ) ) < 0 )
return false;
}
fprintf( aFile, "\n" ); if( fprintf( aFile, "\n" ) < 0 )
return false;
} }
/* Write the footprint filter list */ /* Write the footprint filter list */
if( m_FootprintList.GetCount() != 0 ) if( m_FootprintList.GetCount() != 0 )
{ {
fprintf( aFile, "$FPLIST\n" ); if( fprintf( aFile, "$FPLIST\n" ) < 0 )
unsigned ii; return false;
for( ii = 0; ii < m_FootprintList.GetCount(); ii++ )
fprintf( aFile, " %s\n", CONV_TO_UTF8( m_FootprintList[ii] ) ); for( size_t ii = 0; ii < m_FootprintList.GetCount(); ii++ )
{
if( fprintf( aFile, " %s\n",
CONV_TO_UTF8( m_FootprintList[ii] ) ) < 0 )
return false;
}
fprintf( aFile, "$ENDFPLIST\n" ); if( fprintf( aFile, "$ENDFPLIST\n" ) < 0 )
return false;
} }
/* Save graphics items (including pins) */ /* Save graphics items (including pins) */
...@@ -466,17 +493,23 @@ bool EDA_LibComponentStruct::Save( FILE* aFile ) ...@@ -466,17 +493,23 @@ bool EDA_LibComponentStruct::Save( FILE* aFile )
* when a file editing "by hand" is made */ * when a file editing "by hand" is made */
SortDrawItems(); SortDrawItems();
fprintf( aFile, "DRAW\n" ); if( fprintf( aFile, "DRAW\n" ) < 0 )
return false;
DrawEntry = m_Drawings; DrawEntry = m_Drawings;
while( DrawEntry ) while( DrawEntry )
{ {
DrawEntry->Save( aFile ); if( !DrawEntry->Save( aFile ) )
return false;
DrawEntry = DrawEntry->Next(); DrawEntry = DrawEntry->Next();
} }
fprintf( aFile, "ENDDRAW\n" );
if( fprintf( aFile, "ENDDRAW\n" ) < 0 )
return false;
} }
fprintf( aFile, "ENDDEF\n" ); if( fprintf( aFile, "ENDDEF\n" ) < 0 )
return false;
return true; return true;
} }
...@@ -890,14 +923,14 @@ bool EDA_LibComponentStruct::SaveDateAndTime( FILE* file ) ...@@ -890,14 +923,14 @@ bool EDA_LibComponentStruct::SaveDateAndTime( FILE* file )
return true; return true;
sec = m_LastDate & 63; sec = m_LastDate & 63;
min = (m_LastDate >> 6) & 63; min = ( m_LastDate >> 6 ) & 63;
hour = (m_LastDate >> 12) & 31; hour = ( m_LastDate >> 12 ) & 31;
day = (m_LastDate >> 17) & 31; day = ( m_LastDate >> 17 ) & 31;
mon = (m_LastDate >> 22) & 15; mon = ( m_LastDate >> 22 ) & 15;
year = (m_LastDate >> 26) + 1990; year = ( m_LastDate >> 26 ) + 1990;
if ( fprintf( file, "Ti %d/%d/%d %d:%d:%d\n", if ( fprintf( file, "Ti %d/%d/%d %d:%d:%d\n",
year, mon, day, hour, min, sec ) == EOF ) year, mon, day, hour, min, sec ) < 0 )
return false; return false;
return true; return true;
...@@ -927,6 +960,81 @@ bool EDA_LibComponentStruct::LoadDateAndTime( char* Line ) ...@@ -927,6 +960,81 @@ bool EDA_LibComponentStruct::LoadDateAndTime( char* Line )
} }
void EDA_LibComponentStruct::SetOffset( const wxPoint& offset )
{
LibEDA_BaseStruct* DrawEntry;
m_Name.SetOffset( offset );
m_Prefix.SetOffset( offset );
for( LibDrawField* field = m_Fields; field != NULL; field = field->Next() )
{
field->SetOffset( offset );
}
DrawEntry = m_Drawings;
while( DrawEntry )
{
DrawEntry->SetOffset( offset );
DrawEntry = DrawEntry->Next();
}
}
void EDA_LibComponentStruct::RemoveDuplicateDrawItems()
{
LibEDA_BaseStruct* DEntryRef;
LibEDA_BaseStruct* DEntryCompare;
bool deleted;
DEntryRef = m_Drawings;
while( DEntryRef )
{
if( DEntryRef->Next() == NULL )
return;
DEntryCompare = DEntryRef->Next();
if( DEntryCompare == NULL )
return;
deleted = false;
while( DEntryCompare )
{
if( DEntryRef == DEntryCompare )
{
RemoveDrawItem( DEntryRef, NULL, NULL );
deleted = true;
break;
}
DEntryCompare = DEntryCompare->Next();
}
if( !deleted )
DEntryRef = DEntryRef->Next();
else
DEntryRef = m_Drawings;
}
}
bool EDA_LibComponentStruct::HasConversion() const
{
LibEDA_BaseStruct* entry;
for( entry = m_Drawings; entry != NULL; entry = entry->Next() )
{
if( entry->m_Convert > 1 )
return true;
}
return false;
}
/** /**
* Function SaveDoc * Function SaveDoc
* writes the doc info out to a FILE in "*.dcm" format. * writes the doc info out to a FILE in "*.dcm" format.
...@@ -941,17 +1049,23 @@ bool LibCmpEntry::SaveDoc( FILE* aFile ) ...@@ -941,17 +1049,23 @@ bool LibCmpEntry::SaveDoc( FILE* aFile )
return true; return true;
/* Generation des lignes utiles */ /* Generation des lignes utiles */
fprintf( aFile, "#\n$CMP %s\n", CONV_TO_UTF8( m_Name.m_Text ) ); if( fprintf( aFile, "#\n$CMP %s\n", CONV_TO_UTF8( m_Name.m_Text ) ) < 0 )
return false;
if( ! m_Doc.IsEmpty() ) if( ! m_Doc.IsEmpty()
fprintf( aFile, "D %s\n", CONV_TO_UTF8( m_Doc ) ); && fprintf( aFile, "D %s\n", CONV_TO_UTF8( m_Doc ) ) < 0 )
return false;
if( ! m_KeyWord.IsEmpty() ) if( ! m_KeyWord.IsEmpty()
fprintf( aFile, "K %s\n", CONV_TO_UTF8( m_KeyWord ) ); && fprintf( aFile, "K %s\n", CONV_TO_UTF8( m_KeyWord ) ) < 0 )
return false;
if( ! m_DocFile.IsEmpty()
&& fprintf( aFile, "F %s\n", CONV_TO_UTF8( m_DocFile ) ) < 0 )
return false;
if( ! m_DocFile.IsEmpty() ) if( fprintf( aFile, "$ENDCMP\n" ) < 0 )
fprintf( aFile, "F %s\n", CONV_TO_UTF8( m_DocFile ) ); return false;
fprintf( aFile, "$ENDCMP\n" );
return true; return true;
} }
...@@ -56,6 +56,8 @@ public: ...@@ -56,6 +56,8 @@ public:
} }
const wxString& GetName() { return m_Name.m_Text; }
/** /**
* Write the entry document information to a FILE in "*.dcm" format. * Write the entry document information to a FILE in "*.dcm" format.
* *
...@@ -127,7 +129,7 @@ public: ...@@ -127,7 +129,7 @@ public:
EDA_Rect GetBoundaryBox( int Unit, int Convert ); EDA_Rect GetBoundaryBox( int Unit, int Convert );
void SortDrawItems(); void SortDrawItems();
bool SaveDateAndTime( FILE* ExportFile ); bool SaveDateAndTime( FILE* ExportFile );
bool LoadDateAndTime( char* Line ); bool LoadDateAndTime( char* Line );
...@@ -199,6 +201,40 @@ public: ...@@ -199,6 +201,40 @@ public:
void RemoveDrawItem( LibEDA_BaseStruct* item, void RemoveDrawItem( LibEDA_BaseStruct* item,
WinEDA_DrawPanel* panel = NULL, WinEDA_DrawPanel* panel = NULL,
wxDC* dc = NULL ); wxDC* dc = NULL );
/**
* Move the component offset.
*
* @param offset - Offset displacement.
*/
void SetOffset( const wxPoint& offset );
/**
* Remove duplicate draw items from list.
*/
void RemoveDuplicateDrawItems();
/**
* Test if component has more than one body conversion type (DeMorgan).
*
* @return bool - True if component has more than one conversion.
*/
bool HasConversion() const;
/**
* Test if alias name is in component alias list.
*
* Alias name comparisons are case insensitive.
*
* @param name - Name of alias.
*
* @return bool - True if alias name in alias list.
*/
bool HasAlias( const wxChar* name )
{
wxASSERT( name != NULL );
return m_AliasList.Index( name ) != wxNOT_FOUND;
}
}; };
......
...@@ -52,6 +52,7 @@ LibDrawField::LibDrawField( int idfield ) : ...@@ -52,6 +52,7 @@ LibDrawField::LibDrawField( int idfield ) :
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
} }
LibDrawField::~LibDrawField() LibDrawField::~LibDrawField()
{ {
} }
...@@ -74,13 +75,14 @@ bool LibDrawField::Save( FILE* ExportFile ) const ...@@ -74,13 +75,14 @@ bool LibDrawField::Save( FILE* ExportFile ) const
vjustify = 'T'; vjustify = 'T';
if( text.IsEmpty() ) if( text.IsEmpty() )
text = wxT( "~" ); text = wxT( "~" );
fprintf( ExportFile, "F%d \"%s\" %d %d %d %c %c %c %c%c%c", if( fprintf( ExportFile, "F%d \"%s\" %d %d %d %c %c %c %c%c%c",
m_FieldId, CONV_TO_UTF8( text ), m_Pos.x, m_Pos.y, m_Size.x, m_FieldId, CONV_TO_UTF8( text ), m_Pos.x, m_Pos.y, m_Size.x,
m_Orient == 0 ? 'H' : 'V', m_Orient == 0 ? 'H' : 'V',
(m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V', (m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V',
hjustify, vjustify, hjustify, vjustify,
m_Italic ? 'I' : 'N', m_Italic ? 'I' : 'N',
m_Bold ? 'B' : 'N' ); m_Bold ? 'B' : 'N' ) < 0 )
return false;
/* Save field name, if necessary /* Save field name, if necessary
* Field name is saved only if it is not the default name. * Field name is saved only if it is not the default name.
...@@ -88,10 +90,13 @@ bool LibDrawField::Save( FILE* ExportFile ) const ...@@ -88,10 +90,13 @@ bool LibDrawField::Save( FILE* ExportFile ) const
* a country to an other * a country to an other
*/ */
if( m_FieldId >= FIELD1 && !m_Name.IsEmpty() if( m_FieldId >= FIELD1 && !m_Name.IsEmpty()
&& m_Name != ReturnDefaultFieldName( m_FieldId )) && m_Name != ReturnDefaultFieldName( m_FieldId )
fprintf( ExportFile, " \"%s\"", CONV_TO_UTF8( m_Name ) ); && fprintf( ExportFile, " \"%s\"", CONV_TO_UTF8( m_Name ) ) < 0 )
return false;
if( fprintf( ExportFile, "\n" ) < 0 )
return false;
fprintf( ExportFile, "\n" );
return true; return true;
} }
...@@ -312,10 +317,12 @@ bool LibDrawField::HitTest( const wxPoint& refPos ) ...@@ -312,10 +317,12 @@ bool LibDrawField::HitTest( const wxPoint& refPos )
* @param aThreshold = unused here (TextHitTest calculates its threshold ) * @param aThreshold = unused here (TextHitTest calculates its threshold )
* @param aTransMat = the transform matrix * @param aTransMat = the transform matrix
*/ */
bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ) bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold,
const int aTransMat[2][2] )
{ {
int extraCharCount = 0; int extraCharCount = 0;
// Reference designator text has one or 2 additional character (displays U? or U?A) // Reference designator text has one or 2 additional character (displays
// U? or U?A)
if( m_FieldId == REFERENCE ) if( m_FieldId == REFERENCE )
{ {
extraCharCount++; extraCharCount++;
...@@ -382,6 +389,33 @@ void LibDrawField::Copy( LibDrawField* Target ) const ...@@ -382,6 +389,33 @@ void LibDrawField::Copy( LibDrawField* Target ) const
} }
bool LibDrawField::DoCompare( const LibEDA_BaseStruct& other ) const
{
wxASSERT( other.Type() == COMPONENT_FIELD_DRAW_TYPE );
const LibDrawField* tmp = ( LibDrawField* ) &other;
return ( ( m_FieldId == tmp->m_FieldId ) && ( m_Text == tmp->m_Text )
&& ( m_Pos == tmp->m_Pos ) && ( m_Size == tmp->m_Size ) );
}
void LibDrawField::DoOffset( const wxPoint& offset )
{
m_Pos += offset;
}
bool LibDrawField::DoTestInside( EDA_Rect& rect )
{
/*
* FIXME: This fails to take into acount the size and/or orientation of
* the text.
*/
return rect.Inside( m_Pos.x, -m_Pos.y );
}
/** /**
* Function ReturnDefaultFieldName * Function ReturnDefaultFieldName
* Return the default field name from its index (REFERENCE, VALUE ..) * Return the default field name from its index (REFERENCE, VALUE ..)
......
...@@ -105,6 +105,9 @@ public: ...@@ -105,6 +105,9 @@ public:
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
}; };
#endif // CLASS_LIBENTRY_FIELDS_H #endif // CLASS_LIBENTRY_FIELDS_H
This diff is collapsed.
...@@ -137,11 +137,6 @@ public: ...@@ -137,11 +137,6 @@ public:
/** /**
* Find entry by name and type. * Find entry by name and type.
* *
* If the search type is an alias, the return entry can be either an
* alias or a component object. If the search type is a component
* (root) type, the object returned will be a component. This was
* done to emulate the old search pattern.
*
* @param name - Name of entry, case insensitive. * @param name - Name of entry, case insensitive.
* @param type - Type of entry, root or alias. * @param type - Type of entry, root or alias.
* *
...@@ -149,6 +144,52 @@ public: ...@@ -149,6 +144,52 @@ public:
*/ */
LibCmpEntry* FindEntry( const wxChar* name, LibrEntryType type ); LibCmpEntry* FindEntry( const wxChar* name, LibrEntryType type );
/**
* Find component by name.
*
* This is a helper for FindEntry so casting a LibCmpEntry pointer to
* a EDA_LibComponentStruct pointer is not required.
*
* @param name - Name of component, case insensitive.
* @param searchAliases - Searches for component by alias name as well as
* component name if true.
*
* @return Pointer to component if found. NULL if not found.
*/
EDA_LibComponentStruct* FindComponent( const wxChar* name,
bool searchAliases = true );
/**
* Find alias by name.
*
* This is a helper for FindEntry so casting a LibCmpEntry pointer to
* a EDA_LibCmpAliasStruct pointer is not required.
*
* @param name - Name of alias, case insensitive.
*
* @return Pointer to alias if found. NULL if not found.
*/
EDA_LibCmpAliasStruct* FindAlias( const wxChar* name )
{
return (EDA_LibCmpAliasStruct*) FindEntry( name, ALIAS );
}
/**
* Add a new alias entry to the library.
*
* First check if a component or alias with the same name already exists
* in the library and add alias if no conflict occurs. Once the alias
* is added to the library it is owned by the library. Deleting the
* alias pointer will render the library unstable. Use RemoveEntry to
* remove the alias from the library.
*
* @param alias - Alias to add to library.
*
* @return bool - True if alias added to library. False if conflict
* exists.
*/
bool AddAlias( EDA_LibCmpAliasStruct* alias );
/** /**
* Add component entry to library. * Add component entry to library.
* *
...@@ -172,6 +213,16 @@ public: ...@@ -172,6 +213,16 @@ public:
*/ */
void RemoveEntry( LibCmpEntry* entry ); void RemoveEntry( LibCmpEntry* entry );
/**
* Replace an existing component entry in the library.
*
* @param oldComponent - The component to replace.
* @param newComponent - The new component.
*/
EDA_LibComponentStruct* ReplaceComponent(
EDA_LibComponentStruct* oldComponent,
EDA_LibComponentStruct* newComponent );
/** /**
* Return the first entry in the library. * Return the first entry in the library.
* *
......
...@@ -33,14 +33,14 @@ const wxChar* MsgPinElectricType[] = ...@@ -33,14 +33,14 @@ const wxChar* MsgPinElectricType[] =
LibDrawPin::LibDrawPin(EDA_LibComponentStruct * aParent) : LibDrawPin::LibDrawPin(EDA_LibComponentStruct * aParent) :
LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE, aParent ) LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE, aParent )
{ {
m_PinLen = 300; /* default Pin len */ m_PinLen = 300; /* default Pin len */
m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */ m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */
m_PinShape = NONE; /* Bit a bit: Pin shape (voir enum prec) */ m_PinShape = NONE; /* Bit a bit: Pin shape (voir enum prec) */
m_PinType = PIN_UNSPECIFIED; /* electrical type of pin */ m_PinType = PIN_UNSPECIFIED; /* electrical type of pin */
m_Attributs = 0; /* bit 0 != 0: pin invisible */ m_Attributs = 0; /* bit 0 != 0: pin invisible */
m_PinNum = 0; /*pin number ( i.e. 4 codes ASCII ) */ m_PinNum = 0; /* pin number ( i.e. 4 codes ASCII ) */
m_PinNumSize = 50; m_PinNumSize = 50;
m_PinNameSize = 50; /* Default size for pin name and num */ m_PinNameSize = 50; /* Default size for pin name and num */
m_Width = 0; m_Width = 0;
m_typeName = _( "Pin" ); m_typeName = _( "Pin" );
m_PinNumShapeOpt = 0; m_PinNumShapeOpt = 0;
...@@ -137,29 +137,46 @@ bool LibDrawPin::Save( FILE* ExportFile ) const ...@@ -137,29 +137,46 @@ bool LibDrawPin::Save( FILE* ExportFile ) const
StringPinNum = wxT( "~" ); StringPinNum = wxT( "~" );
if( !m_PinName.IsEmpty() ) if( !m_PinName.IsEmpty() )
fprintf( ExportFile, "X %s", CONV_TO_UTF8( m_PinName ) ); {
if( fprintf( ExportFile, "X %s", CONV_TO_UTF8( m_PinName ) ) < 0 )
return false;
}
else else
fprintf( ExportFile, "X ~" ); {
if( fprintf( ExportFile, "X ~" ) < 0 )
return false;
}
fprintf( ExportFile, " %s %d %d %d %c %d %d %d %d %c", if( fprintf( ExportFile, " %s %d %d %d %c %d %d %d %d %c",
CONV_TO_UTF8( StringPinNum ), m_Pos.x, m_Pos.y, CONV_TO_UTF8( StringPinNum ), m_Pos.x, m_Pos.y,
(int) m_PinLen, (int) m_Orient, m_PinNumSize, m_PinNameSize, (int) m_PinLen, (int) m_Orient, m_PinNumSize, m_PinNameSize,
m_Unit, m_Convert, Etype ); m_Unit, m_Convert, Etype ) < 0 )
return false;
if( (m_PinShape) || (m_Attributs & PINNOTDRAW) ) if( ( m_PinShape ) || ( m_Attributs & PINNOTDRAW ) )
fprintf( ExportFile, " " ); {
if( m_Attributs & PINNOTDRAW ) if( fprintf( ExportFile, " " ) < 0 )
fprintf( ExportFile, "N" ); return false;
if( m_PinShape & INVERT ) }
fprintf( ExportFile, "I" ); if( m_Attributs & PINNOTDRAW
if( m_PinShape & CLOCK ) && fprintf( ExportFile, "N" ) < 0 )
fprintf( ExportFile, "C" ); return false;
if( m_PinShape & LOWLEVEL_IN ) if( m_PinShape & INVERT
fprintf( ExportFile, "L" ); && fprintf( ExportFile, "I" ) < 0 )
if( m_PinShape & LOWLEVEL_OUT ) return false;
fprintf( ExportFile, "V" ); if( m_PinShape & CLOCK
&& fprintf( ExportFile, "C" ) < 0 )
return false;
if( m_PinShape & LOWLEVEL_IN
&& fprintf( ExportFile, "L" ) < 0 )
return false;
if( m_PinShape & LOWLEVEL_OUT
&& fprintf( ExportFile, "V" ) < 0 )
return false;
if( fprintf( ExportFile, "\n" ) < 0 )
return false;
fprintf( ExportFile, "\n" );
return true; return true;
} }
...@@ -1037,13 +1054,36 @@ LibEDA_BaseStruct* LibDrawPin::DoGenCopy() ...@@ -1037,13 +1054,36 @@ LibEDA_BaseStruct* LibDrawPin::DoGenCopy()
newpin->m_Convert = m_Convert; newpin->m_Convert = m_Convert;
newpin->m_Flags = m_Flags; newpin->m_Flags = m_Flags;
newpin->m_Width = m_Width; newpin->m_Width = m_Width;
newpin->m_PinName = m_PinName;
newpin->m_PinName = m_PinName;
return (LibEDA_BaseStruct*) newpin; return (LibEDA_BaseStruct*) newpin;
} }
bool LibDrawPin::DoCompare( const LibEDA_BaseStruct& other ) const
{
wxASSERT( other.Type() == COMPONENT_PIN_DRAW_TYPE );
const LibDrawPin* tmp = ( LibDrawPin* ) &other;
return ( m_Pos == tmp->m_Pos );
}
void LibDrawPin::DoOffset( const wxPoint& offset )
{
m_Pos += offset;
}
bool LibDrawPin::DoTestInside( EDA_Rect& rect )
{
wxPoint end = ReturnPinEndPoint();
return rect.Inside( m_Pos.x, -m_Pos.y ) || rect.Inside( end.x, -end.y );
}
/** Function LibDrawPin::DisplayInfo /** Function LibDrawPin::DisplayInfo
* Displays info (pin num and name, orientation ... * Displays info (pin num and name, orientation ...
* on the Info window * on the Info window
......
This diff is collapsed.
...@@ -154,7 +154,7 @@ public: ...@@ -154,7 +154,7 @@ public:
* @param refPos A wxPoint to test * @param refPos A wxPoint to test
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
virtual bool HitTest( const wxPoint& refPos ) virtual bool HitTest( const wxPoint& refPos )
{ {
return false; // derived classes should override this function return false; // derived classes should override this function
} }
...@@ -189,8 +189,49 @@ public: ...@@ -189,8 +189,49 @@ public:
*/ */
LibEDA_BaseStruct* GenCopy() { return DoGenCopy(); } LibEDA_BaseStruct* GenCopy() { return DoGenCopy(); }
/**
* Test LibEDA_BaseStruct objects for equivalence.
*
* @param tst - Object to test against.
*
* @return bool - True if object is identical to this object.
*/
bool operator==( const LibEDA_BaseStruct& other ) const;
bool operator==( const LibEDA_BaseStruct* other ) const
{
return *this == *other;
}
/**
* Set drawing object offset from the current position.
*
* @param offset - Cooridinates to offset position.
*/
void SetOffset( const wxPoint offset ) { DoOffset( offset ); }
/**
* Test if any part of the draw object is inside rectangle bounds.
*
* This is used for block selection. The real work is done by the
* DoTestInside method for each derived object type.
*
* @param rect - Rectangle to check against.
*
* @return bool - True if object is inside rectangle.
*/
bool Inside( EDA_Rect& rect ) { return DoTestInside( rect ); }
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy() = 0; virtual LibEDA_BaseStruct* DoGenCopy() = 0;
/**
* Provide the draw object specific comparison.
*
* This is called by the == operator.
*/
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const = 0;
virtual void DoOffset( const wxPoint& offset ) = 0;
virtual bool DoTestInside( EDA_Rect& rect ) = 0;
}; };
...@@ -318,6 +359,9 @@ public: ...@@ -318,6 +359,9 @@ public:
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
}; };
...@@ -328,8 +372,9 @@ protected: ...@@ -328,8 +372,9 @@ protected:
class LibDrawArc : public LibEDA_BaseStruct class LibDrawArc : public LibEDA_BaseStruct
{ {
public: public:
int m_Rayon; int m_Radius;
int t1, t2; /* position des 2 extremites de l'arc en 0.1 degres */ int m_t1;
int m_t2; /* position des 2 extremites de l'arc en 0.1 degres */
wxPoint m_ArcStart; wxPoint m_ArcStart;
wxPoint m_ArcEnd; /* position des 2 extremites de l'arc en coord reelles*/ wxPoint m_ArcEnd; /* position des 2 extremites de l'arc en coord reelles*/
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point wxPoint m_Pos; /* Position or centre (Arc and Circle) or start point
...@@ -386,6 +431,9 @@ public: ...@@ -386,6 +431,9 @@ public:
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
}; };
...@@ -395,7 +443,7 @@ protected: ...@@ -395,7 +443,7 @@ protected:
class LibDrawCircle : public LibEDA_BaseStruct class LibDrawCircle : public LibEDA_BaseStruct
{ {
public: public:
int m_Rayon; int m_Radius;
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start wxPoint m_Pos; /* Position or centre (Arc and Circle) or start
* point (segments) */ * point (segments) */
int m_Width; /* Line width */ int m_Width; /* Line width */
...@@ -451,6 +499,9 @@ public: ...@@ -451,6 +499,9 @@ public:
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
}; };
...@@ -523,6 +574,9 @@ public: ...@@ -523,6 +574,9 @@ public:
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
}; };
...@@ -587,6 +641,9 @@ public: ...@@ -587,6 +641,9 @@ public:
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
}; };
/**********************************/ /**********************************/
...@@ -650,6 +707,9 @@ public: ...@@ -650,6 +707,9 @@ public:
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
}; };
...@@ -724,6 +784,9 @@ public: ...@@ -724,6 +784,9 @@ public:
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
}; };
/**********************************************************/ /**********************************************************/
...@@ -798,6 +861,9 @@ public: ...@@ -798,6 +861,9 @@ public:
protected: protected:
virtual LibEDA_BaseStruct* DoGenCopy(); virtual LibEDA_BaseStruct* DoGenCopy();
virtual bool DoCompare( const LibEDA_BaseStruct& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_Rect& rect );
}; };
#endif // CLASSES_BODY_ITEMS_H #endif // CLASSES_BODY_ITEMS_H
...@@ -397,7 +397,6 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe ...@@ -397,7 +397,6 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe
} }
UpdateStatusBar(); /* Affichage des coord curseur */ UpdateStatusBar(); /* Affichage des coord curseur */
SetToolbars();
} }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "protos.h" #include "protos.h"
DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY( WinEDA_LibeditFrame* aParent): DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY( WinEDA_LibeditFrame* aParent):
DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE(aParent) DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE(aParent)
{ {
m_Parent = aParent; m_Parent = aParent;
m_RecreateToolbar = false; m_RecreateToolbar = false;
...@@ -44,27 +44,26 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::Init( ) ...@@ -44,27 +44,26 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::Init( )
{ {
SetFocus(); SetFocus();
m_AliasLocation = -1; m_AliasLocation = -1;
if( CurrentLibEntry == NULL ) if( CurrentLibEntry == NULL )
{ {
SetTitle( _( "Lib Component Properties" ) ); SetTitle( _( "Library Component Properties" ) );
return; return;
} }
wxString title = _( "Properties for " ); wxString title = _( "Properties for " );
if( !CurrentAliasName.IsEmpty() ) if( !CurrentAliasName.IsEmpty() )
{ {
m_AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList, CurrentAliasName ); title += CurrentAliasName + _( " (alias of " ) +
title += CurrentAliasName + wxString( CurrentLibEntry->m_Name.m_Text )+ wxT( ")" );
_( "(alias of " ) +
wxString( CurrentLibEntry->m_Name.m_Text )
+ wxT( ")" );
} }
else else
{ {
title += CurrentLibEntry->m_Name.m_Text; title += CurrentLibEntry->m_Name.m_Text;
CurrentAliasName.Empty(); CurrentAliasName.Empty();
} }
SetTitle( title ); SetTitle( title );
InitPanelDoc(); InitPanelDoc();
...@@ -76,34 +75,33 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::Init( ) ...@@ -76,34 +75,33 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::Init( )
/* Place list of alias names in listbox */ /* Place list of alias names in listbox */
if( CurrentLibEntry ) if( CurrentLibEntry )
{ {
for( unsigned ii = 0; ii < CurrentLibEntry->m_AliasList.GetCount(); ii += ALIAS_NEXT ) m_PartAliasList->Append( CurrentLibEntry->m_AliasList );
m_PartAliasList->Append( CurrentLibEntry->m_AliasList[ii + ALIAS_NAME] );
} }
if( (CurrentLibEntry == NULL) || (CurrentLibEntry->m_AliasList.GetCount() == 0) ) if( ( CurrentLibEntry == NULL )
|| ( CurrentLibEntry->m_AliasList.GetCount() == 0 ) )
{ {
m_ButtonDeleteAllAlias->Enable( false ); m_ButtonDeleteAllAlias->Enable( false );
m_ButtonDeleteOneAlias->Enable( false ); m_ButtonDeleteOneAlias->Enable( false );
} }
/* Read the Footprint Filter list */ /* Read the Footprint Filter list */
if( CurrentLibEntry ) if( CurrentLibEntry )
{ {
for( unsigned ii = 0; ii < CurrentLibEntry->m_FootprintList.GetCount(); ii++ ) m_FootprintFilterListBox->Append( CurrentLibEntry->m_FootprintList );
m_FootprintFilterListBox->Append( CurrentLibEntry->m_FootprintList[ii] );
} }
if( (CurrentLibEntry == NULL) || (CurrentLibEntry->m_FootprintList.GetCount() == 0) ) if( ( CurrentLibEntry == NULL )
|| ( CurrentLibEntry->m_FootprintList.GetCount() == 0 ) )
{ {
m_ButtonDeleteAllFootprintFilter->Enable( false ); m_ButtonDeleteAllFootprintFilter->Enable( false );
m_ButtonDeleteOneFootprintFilter->Enable( false ); m_ButtonDeleteOneFootprintFilter->Enable( false );
} }
} }
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnCancelClick( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnCancelClick( wxCommandEvent& event )
{ {
EndModal(0); EndModal( wxID_CANCEL );
} }
...@@ -217,16 +217,14 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event ...@@ -217,16 +217,14 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event
/* A new name could be entered in VALUE field. /* A new name could be entered in VALUE field.
* Must not be an existing alias name in alias list box */ * Must not be an existing alias name in alias list box */
wxString* newvalue = &m_FieldsBuf[VALUE].m_Text; wxString* newvalue = &m_FieldsBuf[VALUE].m_Text;
for( unsigned ii = 0; ii < m_LibEntry->m_AliasList.GetCount(); ii += ALIAS_NEXT ) for( size_t i = 0; i < m_LibEntry->m_AliasList.GetCount(); i++ )
{ {
wxString* libname = &(m_LibEntry->m_AliasList[ii + ALIAS_NAME]); if( newvalue->CmpNoCase( m_LibEntry->m_AliasList[i] ) == 0 )
if( newvalue->CmpNoCase( *libname ) == 0 )
{ {
wxString msg; wxString msg;
msg.Printf( msg.Printf( _( "A new name is entered for this component\nAn \
_( alias %s already exists!\nCannot update this component" ),
"A new name is entered for this component\nAn alias %s already exists!\nCannot update this component" ), newvalue->GetData() );
newvalue->GetData() );
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
...@@ -236,7 +234,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event ...@@ -236,7 +234,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event
m_Parent->SaveCopyInUndoList( m_LibEntry, IS_CHANGED ); m_Parent->SaveCopyInUndoList( m_LibEntry, IS_CHANGED );
// delete any fields with no name // delete any fields with no name
for( unsigned i = FIELD1; i<m_FieldsBuf.size(); ) for( unsigned i = FIELD1; i < m_FieldsBuf.size(); )
{ {
if( m_FieldsBuf[i].m_Name.IsEmpty() ) if( m_FieldsBuf[i].m_Name.IsEmpty() )
{ {
......
This diff is collapsed.
...@@ -73,7 +73,10 @@ LibCmpEntry* FindLibPart( const wxChar* Name, const wxString& LibName, ...@@ -73,7 +73,10 @@ LibCmpEntry* FindLibPart( const wxChar* Name, const wxString& LibName,
if( Lib == NULL ) if( Lib == NULL )
break; break;
Entry = Lib->FindEntry( Name, type ); if( type == ROOT )
Entry = (LibCmpEntry*) Lib->FindComponent( Name );
else
Entry = Lib->FindEntry( Name );
if( Entry != NULL ) if( Entry != NULL )
{ {
......
...@@ -459,8 +459,6 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -459,8 +459,6 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
bool ItemInEdit = GetScreen()->GetCurItem() bool ItemInEdit = GetScreen()->GetCurItem()
&& GetScreen()->GetCurItem()->m_Flags; && GetScreen()->GetCurItem()->m_Flags;
bool RefreshToolBar = FALSE; /* Refresh tool bar when the undo/redo
* tool state is modified. */
if( hotkey == 0 ) if( hotkey == 0 )
return; return;
...@@ -578,7 +576,4 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -578,7 +576,4 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
} }
break; break;
} }
if( RefreshToolBar )
SetToolbars();
} }
/****************************/
/* EESchema - libalias.cpp */
/****************************/
/* Routines de maintenanace des librairies: gestion des alias des composants
*/
#include "fctsys.h"
#include "common.h"
#include "confirm.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
/* Variables locales */
/**************************************************************************/
bool BuildAliasData( LibraryStruct* Lib, EDA_LibComponentStruct* component )
/**************************************************************************/
/* Create the alias data for the lib component to edit
* Alias data is:
* alias name
* doc string
* keywords string
* doc file name
*
* in .m_AliastList
* Alias data (4 strings) replace each alias name.
*
*/
{
wxArrayString List;
LibCmpEntry* CmpEntry;
unsigned ii;
if( component == NULL || Lib == NULL
|| component->m_AliasList.GetCount() == 0 )
return false;
List = component->m_AliasList;
component->m_AliasList.Clear();
for( ii = 0; ii < List.GetCount(); ii++ )
{
CmpEntry = FindLibPart( List[ii], Lib->m_Name, ALIAS );
if( CmpEntry && CmpEntry->Type != ALIAS )
{
DisplayError( NULL,
wxT( "BuildListAlias err: alias is a ROOT entry!" ) );
}
else
{
if( LocateAlias( component->m_AliasList, List[ii] ) < 0 )
{
/* Alias not found in list: create it (datas must be in this order) */
component->m_AliasList.Add( List[ii] );
component->m_AliasList.Add( CmpEntry->m_Doc );
component->m_AliasList.Add( CmpEntry->m_KeyWord );
component->m_AliasList.Add( CmpEntry->m_DocFile );
}
}
}
return TRUE;
}
/***********************************************************************/
int LocateAlias( const wxArrayString& AliasData, const wxString& Name )
/***********************************************************************/
/* Return an index in alias data list
* ( -1 if not found )
*/
{
int index = -1;
unsigned ii;
for( ii = 0; ii < AliasData.GetCount(); ii += ALIAS_NEXT )
{
if( Name.CmpNoCase( AliasData[ii + ALIAS_NAME].GetData() ) == 0 )
{
index = ii;
break;
}
}
return index;
}
...@@ -13,14 +13,6 @@ ...@@ -13,14 +13,6 @@
#define DOC_EXT wxT( "dcm" ) /* Ext. of documentation files */ #define DOC_EXT wxT( "dcm" ) /* Ext. of documentation files */
//Offsets used in editing library component, for handle alias data
#define ALIAS_NAME 0
#define ALIAS_DOC 1
#define ALIAS_KEYWORD 2
#define ALIAS_DOC_FILENAME 3
#define ALIAS_NEXT 4
enum LocateDrawStructType { enum LocateDrawStructType {
LOCATE_COMPONENT_ARC_DRAW_TYPE = 1, LOCATE_COMPONENT_ARC_DRAW_TYPE = 1,
LOCATE_COMPONENT_CIRCLE_DRAW_TYPE = 2, LOCATE_COMPONENT_CIRCLE_DRAW_TYPE = 2,
......
This diff is collapsed.
...@@ -79,9 +79,10 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -79,9 +79,10 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
else else
{ {
EraseMsgBox(); if( CurrentAliasName.IsEmpty() )
AfficheDoc( this, CurrentLibEntry->m_Doc.GetData(), DisplayCmpDoc( CurrentAliasName );
CurrentLibEntry->m_KeyWord.GetData() ); else
DisplayCmpDoc( CurrentLibEntry->GetName() );
} }
} }
} }
...@@ -151,8 +152,10 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -151,8 +152,10 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
AfficheDoc( this, CurrentLibEntry->m_Doc.GetData(), if( CurrentAliasName.IsEmpty() )
CurrentLibEntry->m_KeyWord.GetData() ); DisplayCmpDoc( CurrentLibEntry->GetName() );
else
DisplayCmpDoc( CurrentAliasName );
break; break;
} }
SaveCopyInUndoList( CurrentLibEntry ); SaveCopyInUndoList( CurrentLibEntry );
...@@ -224,7 +227,7 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -224,7 +227,7 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
InstallLibeditFrame( ); EditComponentProperties();
} }
} }
......
...@@ -67,9 +67,6 @@ void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event) ...@@ -67,9 +67,6 @@ void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event)
CurrentLibEntry->SetNext( NULL ); CurrentLibEntry->SetNext( NULL );
CurrentDrawItem = NULL; CurrentDrawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
ReCreateHToolbar();
SetToolbars();
DrawPanel->Refresh(); DrawPanel->Refresh();
} }
...@@ -101,8 +98,5 @@ void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event) ...@@ -101,8 +98,5 @@ void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event)
CurrentLibEntry->SetNext( NULL ); CurrentLibEntry->SetNext( NULL );
CurrentDrawItem = NULL; CurrentDrawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
ReCreateHToolbar();
SetToolbars();
DrawPanel->Refresh(); DrawPanel->Refresh();
} }
...@@ -193,18 +193,32 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LibDrawField* Field ) ...@@ -193,18 +193,32 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LibDrawField* Field )
*/ */
if( Field->m_FieldId == VALUE ) if( Field->m_FieldId == VALUE )
{ {
/* test for an existing name in alias list: */ wxString msg;
for( unsigned ii = 0; ii < CurrentLibEntry->m_AliasList.GetCount();
ii += ALIAS_NEXT ) /* Test for an existing name in the current components alias list. */
if( CurrentLibEntry->m_AliasList.Index( Text, false ) != wxNOT_FOUND )
{
msg.Printf( _( "The field name <%s> is an existing alias of the \
component <%s>.\nPlease choose another name that does not conflict with any \
names in the alias list." ),
(const wxChar*) Text,
(const wxChar*) CurrentLibEntry->GetName() );
DisplayError( this, msg );
return;
}
/* Test for an existing entry in the library to prevent duplicate
* entry names.
*/
if( CurrentLib && CurrentLib->FindEntry( Text ) != NULL )
{ {
wxString aliasname = CurrentLibEntry->m_AliasList[ii + ALIAS_NAME]; msg.Printf( _( "The field name <%s> conflicts with an existing \
entry in the component library <%s>.\nPlease choose another name that does \
if( Text.CmpNoCase( aliasname ) == 0 ) not conflict with any library entries." ),
{ (const wxChar*) Text,
DisplayError( this, _( "This name is an existing alias of \ (const wxChar*) CurrentLib->m_Name );
the component\nAborting" ) ); DisplayError( this, msg );
return; return;
}
} }
} }
...@@ -233,9 +247,7 @@ the component\nAborting" ) ); ...@@ -233,9 +247,7 @@ the component\nAborting" ) );
DefaultTransformMatrix ); DefaultTransformMatrix );
GetScreen()->SetModify(); GetScreen()->SetModify();
UpdateAliasSelectList();
if( Field->m_FieldId == VALUE )
ReCreateHToolbar();
} }
......
This diff is collapsed.
...@@ -83,20 +83,17 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem ) ...@@ -83,20 +83,17 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
case COMPONENT_ARC_DRAW_TYPE: case COMPONENT_ARC_DRAW_TYPE:
{ {
LibDrawArc* Arc = (LibDrawArc*) DEntry; LibDrawArc* Arc = (LibDrawArc*) DEntry;
t1 = Arc->t1; t2 = Arc->t2; t1 = Arc->m_t1;
t2 = Arc->m_t2;
pos = TransformCoordinate( TransMat, Arc->m_Pos ) + DrawLibItem->m_Pos; pos = TransformCoordinate( TransMat, Arc->m_Pos ) + DrawLibItem->m_Pos;
MapAngles( &t1, &t2, TransMat ); MapAngles( &t1, &t2, TransMat );
if( draw_bgfill && Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR ) if( draw_bgfill && Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{ {
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->arc( pos, -t2, -t1, Arc->m_Rayon, FILLED_SHAPE, 0 ); plotter->arc( pos, -t2, -t1, Arc->m_Radius, FILLED_SHAPE, 0 );
} }
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->arc( pos, plotter->arc( pos, -t2, -t1, Arc->m_Radius, Arc->m_Fill,
-t2,
-t1,
Arc->m_Rayon,
Arc->m_Fill,
thickness ); thickness );
} }
break; break;
...@@ -108,11 +105,11 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem ) ...@@ -108,11 +105,11 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
if( draw_bgfill && Circle->m_Fill == FILLED_WITH_BG_BODYCOLOR ) if( draw_bgfill && Circle->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{ {
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->circle( pos, Circle->m_Rayon * 2, FILLED_SHAPE, 0 ); plotter->circle( pos, Circle->m_Radius * 2, FILLED_SHAPE, 0 );
} }
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) ); plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->circle( pos, plotter->circle( pos,
Circle->m_Rayon * 2, Circle->m_Radius * 2,
Circle->m_Fill, Circle->m_Fill,
thickness ); thickness );
} }
......
...@@ -223,15 +223,6 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry ); ...@@ -223,15 +223,6 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry );
* Parametres de sortie: pointeur sur la structure creee */ * Parametres de sortie: pointeur sur la structure creee */
/***************/
/* SYMBEDIT.CPP */
/***************/
void SuppressDuplicateDrawItem( EDA_LibComponentStruct* LibEntry );
/* Routine de suppression des elements de trace dupliques, situation
* frequente lorsque l'on charge des symboles predessines plusieurs fois
* pour definir un composant */
/**************/ /**************/
/* NETLIST.CPP */ /* NETLIST.CPP */
/**************/ /**************/
...@@ -365,18 +356,6 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint ); ...@@ -365,18 +356,6 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint );
void SetaParent( EDA_BaseStruct* Struct, BASE_SCREEN* Screen ); void SetaParent( EDA_BaseStruct* Struct, BASE_SCREEN* Screen );
/***************/
/* LIBALIAS.CPP */
/***************/
bool BuildAliasData( LibraryStruct* Lib, EDA_LibComponentStruct* component );
/* Create the alias data for the lib component to edit */
int LocateAlias( const wxArrayString& AliasData, const wxString& Name );
/* Return an index in alias data list ( -1 if not found ) */
/***************/ /***************/
/* OPTIONS.CPP */ /* OPTIONS.CPP */
/***************/ /***************/
......
...@@ -36,7 +36,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry ) ...@@ -36,7 +36,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry )
if( OldEntry->Type != ROOT ) if( OldEntry->Type != ROOT )
{ {
msg.Printf( wxT( "Component <%s> must be root type to make copy." ), msg.Printf( wxT( "Component <%s> must be root type to make copy." ),
(const wxChar*) OldEntry->m_Name.m_Text ); (const wxChar*) OldEntry->GetName() );
wxLogError( msg ); wxLogError( msg );
return NULL; return NULL;
} }
...@@ -94,7 +94,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry ) ...@@ -94,7 +94,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry )
msg.Printf( wxT( "Error attempting to copy draw item <%s> from \ msg.Printf( wxT( "Error attempting to copy draw item <%s> from \
component <%s>." ), component <%s>." ),
(const wxChar*) OldDrawings->GetClass(), (const wxChar*) OldDrawings->GetClass(),
(const wxChar*) OldEntry->m_Name.m_Text ); (const wxChar*) OldEntry->GetName() );
wxLogError( msg ); wxLogError( msg );
break; break;
} }
......
...@@ -572,7 +572,7 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -572,7 +572,7 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
case COMPONENT_CIRCLE_DRAW_TYPE: case COMPONENT_CIRCLE_DRAW_TYPE:
dx = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.x - curr_pos.x; dx = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.x - curr_pos.x;
dy = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.y - curr_pos.y; dy = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.y - curr_pos.y;
( (LibDrawCircle*) CurrentDrawItem )->m_Rayon = ( (LibDrawCircle*) CurrentDrawItem )->m_Radius =
(int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) ); (int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill; ( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
break; break;
...@@ -741,13 +741,16 @@ static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre ) ...@@ -741,13 +741,16 @@ static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre )
int cX, cY; /* Coord centre de l'arc */ int cX, cY; /* Coord centre de l'arc */
int angle; int angle;
cX = ArcCentre.x; cY = ArcCentre.y; cX = ArcCentre.x;
cY = ArcCentre.y;
cY = -cY; /* Attention a l'orientation de l'axe Y */ cY = -cY; /* Attention a l'orientation de l'axe Y */
/* calcul de cX et cY pour que l'arc passe par ArcStartX,Y et ArcEndX,Y */ /* calcul de cX et cY pour que l'arc passe par ArcStartX,Y et ArcEndX,Y */
dx = ArcEndX - ArcStartX; dy = ArcEndY - ArcStartY; dx = ArcEndX - ArcStartX;
cX -= ArcStartX; cY -= ArcStartY; dy = ArcEndY - ArcStartY;
cX -= ArcStartX;
cY -= ArcStartY;
angle = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI ); angle = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
RotatePoint( &dx, &dy, angle ); /* Le segment dx, dy est horizontal */ RotatePoint( &dx, &dy, angle ); /* Le segment dx, dy est horizontal */
/* -> dx = longueur, dy = 0 */ /* -> dx = longueur, dy = 0 */
...@@ -755,59 +758,61 @@ static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre ) ...@@ -755,59 +758,61 @@ static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre )
cX = dx / 2; /* cX, cY est sur la mediane du segment 0,0 a dx,0 */ cX = dx / 2; /* cX, cY est sur la mediane du segment 0,0 a dx,0 */
RotatePoint( &cX, &cY, -angle ); RotatePoint( &cX, &cY, -angle );
cX += ArcStartX; cY += ArcStartY; cX += ArcStartX;
cY += ArcStartY;
DrawItem->m_Pos.x = cX; DrawItem->m_Pos.y = cY; DrawItem->m_Pos.x = cX;
DrawItem->m_Pos.y = cY;
dx = ArcStartX - DrawItem->m_Pos.x; dx = ArcStartX - DrawItem->m_Pos.x;
dy = ArcStartY - DrawItem->m_Pos.y; dy = ArcStartY - DrawItem->m_Pos.y;
DrawItem->m_Rayon = (int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) ); DrawItem->m_Radius = (int) sqrt( ( (double) dx * dx ) +
( (double) dy * dy ) );
DrawItem->t1 = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI ); DrawItem->m_t1 = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
dx = ArcEndX - DrawItem->m_Pos.x; dx = ArcEndX - DrawItem->m_Pos.x;
dy = ArcEndY - DrawItem->m_Pos.y; dy = ArcEndY - DrawItem->m_Pos.y;
DrawItem->t2 = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI ); DrawItem->m_t2 = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
DrawItem->m_ArcStart.x = ArcStartX; DrawItem->m_ArcStart.x = ArcStartX;
DrawItem->m_ArcStart.y = ArcStartY; DrawItem->m_ArcStart.y = ArcStartY;
DrawItem->m_ArcEnd.x = ArcEndX; DrawItem->m_ArcEnd.x = ArcEndX;
DrawItem->m_ArcEnd.y = ArcEndY; DrawItem->m_ArcEnd.y = ArcEndY;
NORMALIZE_ANGLE( DrawItem->t1 ); NORMALIZE_ANGLE( DrawItem->m_t1 );
NORMALIZE_ANGLE( DrawItem->t2 ); // angles = 0 .. 3600 NORMALIZE_ANGLE( DrawItem->m_t2 ); // angles = 0 .. 3600
// limitation val abs a < 1800 (1/2 cercle) pour eviter Pbs d'affichage en miroir // limitation val abs a < 1800 (1/2 cercle) pour eviter Pbs d'affichage en miroir
// car en trace on suppose que l'arc fait moins de 180 deg pour trouver // car en trace on suppose que l'arc fait moins de 180 deg pour trouver
// son orientation apres rot, miroir... // son orientation apres rot, miroir...
if( (DrawItem->t2 - DrawItem->t1) > 1800 ) if( (DrawItem->m_t2 - DrawItem->m_t1) > 1800 )
DrawItem->t2 -= 3600; DrawItem->m_t2 -= 3600;
else if( (DrawItem->t2 - DrawItem->t1) <= -1800 ) else if( (DrawItem->m_t2 - DrawItem->m_t1) <= -1800 )
DrawItem->t2 += 3600; DrawItem->m_t2 += 3600;
wxString msg; wxString msg;
angle = DrawItem->t2 - DrawItem->t1; angle = DrawItem->m_t2 - DrawItem->m_t1;
msg.Printf( _( "Arc %.1f deg" ), (float) angle / 10 ); msg.Printf( _( "Arc %.1f deg" ), (float) angle / 10 );
WinEDA_SchematicFrame* frame = WinEDA_SchematicFrame* frame =
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow(); (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
frame->m_LibeditFrame->PrintMsg( msg ); frame->m_LibeditFrame->PrintMsg( msg );
while( (DrawItem->t2 - DrawItem->t1) >= 1800 ) while( (DrawItem->m_t2 - DrawItem->m_t1) >= 1800 )
{ {
DrawItem->t2--; DrawItem->m_t2--;
DrawItem->t1++; DrawItem->m_t1++;
} }
while( (DrawItem->t1 - DrawItem->t2) >= 1800 ) while( (DrawItem->m_t1 - DrawItem->m_t2) >= 1800 )
{ {
DrawItem->t2++; DrawItem->m_t2++;
DrawItem->t1--; DrawItem->m_t1--;
} }
NORMALIZE_ANGLE( DrawItem->t1 ); NORMALIZE_ANGLE( DrawItem->m_t1 );
NORMALIZE_ANGLE( DrawItem->t2 ); NORMALIZE_ANGLE( DrawItem->m_t2 );
} }
......
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
#include "protos.h" #include "protos.h"
static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef,
LibEDA_BaseStruct* DEntryCompare );
/* /*
* Read a component shape file (a symbol file *.sym )and add data (graphic * Read a component shape file (a symbol file *.sym )and add data (graphic
* items) to the current component. * items) to the current component.
...@@ -124,7 +120,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) ...@@ -124,7 +120,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
} }
// Remove duplicated drawings: // Remove duplicated drawings:
SuppressDuplicateDrawItem( CurrentLibEntry ); CurrentLibEntry->RemoveDuplicateDrawItems();
// Clear flags // Clear flags
DrawEntry = CurrentLibEntry->m_Drawings; DrawEntry = CurrentLibEntry->m_Drawings;
...@@ -246,149 +242,6 @@ void WinEDA_LibeditFrame::SaveOneSymbol() ...@@ -246,149 +242,6 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
} }
/*
* Delete redundant graphic items.
*
* Useful after loading asymbole from a file symbol, because some graphic items
* can be duplicated.
*/
void SuppressDuplicateDrawItem( EDA_LibComponentStruct* LibEntry )
{
LibEDA_BaseStruct* DEntryRef, * DEntryCompare;
bool deleted;
wxDC* DC = NULL;
DEntryRef = LibEntry->m_Drawings;
while( DEntryRef )
{
if( DEntryRef->Next() == NULL )
return;
DEntryCompare = DEntryRef->Next();
if( DEntryCompare == NULL )
return;
deleted = 0;
while( DEntryCompare )
{
if( CompareSymbols( DEntryRef, DEntryCompare ) == TRUE )
{
LibEntry->RemoveDrawItem( DEntryRef, NULL, DC );
deleted = TRUE;
break;
}
DEntryCompare = DEntryCompare->Next();
}
if( !deleted )
DEntryRef = DEntryRef->Next();
else
DEntryRef = LibEntry->m_Drawings;
}
}
/*
* Compare 2 graphic items (arc, lines ...).
*
* return FALSE if different
* TRUE if they are identical, and therefore redundant
*/
static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef,
LibEDA_BaseStruct* DEntryCompare )
{
/* Comparaison des proprietes generales */
if( DEntryRef->Type() != DEntryCompare->Type() )
return FALSE;
if( DEntryRef->m_Unit != DEntryCompare->m_Unit )
return FALSE;
if( DEntryRef->m_Convert != DEntryCompare->m_Convert )
return FALSE;
switch( DEntryRef->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
#undef REFSTRUCT
#undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawArc*) DEntryRef )
#define CMPSTRUCT ( (LibDrawArc*) DEntryCompare )
if( REFSTRUCT->m_Pos.x != CMPSTRUCT->m_Pos.x )
return FALSE;
if( REFSTRUCT->m_Pos.y != CMPSTRUCT->m_Pos.y )
return FALSE;
if( REFSTRUCT->t1 != CMPSTRUCT->t1 )
return FALSE;
if( REFSTRUCT->t2 != CMPSTRUCT->t2 )
return FALSE;
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
#undef REFSTRUCT
#undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawCircle*) DEntryRef )
#define CMPSTRUCT ( (LibDrawCircle*) DEntryCompare )
if( REFSTRUCT->m_Pos.x != CMPSTRUCT->m_Pos.x )
return FALSE;
if( REFSTRUCT->m_Pos.y != CMPSTRUCT->m_Pos.y )
return FALSE;
if( REFSTRUCT->m_Rayon != CMPSTRUCT->m_Rayon )
return FALSE;
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
#undef REFSTRUCT
#undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawText*) DEntryRef )
#define CMPSTRUCT ( (LibDrawText*) DEntryCompare )
if( REFSTRUCT->m_Pos != CMPSTRUCT->m_Pos )
return FALSE;
if( REFSTRUCT->m_Size != CMPSTRUCT->m_Size )
return FALSE;
if( REFSTRUCT->m_Text != CMPSTRUCT->m_Text )
return FALSE;
break;
case COMPONENT_RECT_DRAW_TYPE:
#undef REFSTRUCT
#undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawSquare*) DEntryRef )
#define CMPSTRUCT ( (LibDrawSquare*) DEntryCompare )
if( REFSTRUCT->m_Pos != CMPSTRUCT->m_Pos )
return FALSE;
if( REFSTRUCT->m_End != CMPSTRUCT->m_End )
return FALSE;
break;
case COMPONENT_PIN_DRAW_TYPE:
#undef REFSTRUCT
#undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawPin*) DEntryRef )
#define CMPSTRUCT ( (LibDrawPin*) DEntryCompare )
if( REFSTRUCT->m_Pos != CMPSTRUCT->m_Pos )
return FALSE;
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
#undef REFSTRUCT
#undef CMPSTRUCT
#define REFSTRUCT ( (LibDrawPolyline*) DEntryRef )
#define CMPSTRUCT ( (LibDrawPolyline*) DEntryCompare )
if( REFSTRUCT->GetCornerCount() != CMPSTRUCT->GetCornerCount() )
return FALSE;
for( unsigned ii = 0; ii < REFSTRUCT->GetCornerCount(); ii++ )
{
if( REFSTRUCT->m_PolyPoints[ii] != CMPSTRUCT->m_PolyPoints[ii] )
return false;
}
break;
default:
;
}
return TRUE;
}
/***************************************************************************/ /***************************************************************************/
/* Routine de placement du point d'ancrage ( reference des coordonnes pour */ /* Routine de placement du point d'ancrage ( reference des coordonnes pour */
/* le trace) du composant courant */ /* le trace) du composant courant */
...@@ -398,76 +251,14 @@ static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef, ...@@ -398,76 +251,14 @@ static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef,
/***************************************************************************/ /***************************************************************************/
void WinEDA_LibeditFrame::PlaceAncre() void WinEDA_LibeditFrame::PlaceAncre()
{ {
EDA_LibComponentStruct* LibEntry; if( CurrentLibEntry == NULL )
LibEDA_BaseStruct* DrawEntry;
LibEntry = CurrentLibEntry;
if( LibEntry == NULL )
return; return;
wxSize offset( -GetScreen()->m_Curseur.x, GetScreen()->m_Curseur.y ); wxPoint offset( -GetScreen()->m_Curseur.x, GetScreen()->m_Curseur.y );
GetScreen()->SetModify(); GetScreen()->SetModify();
LibEntry->m_Name.m_Pos += offset; CurrentLibEntry->SetOffset( offset );
LibEntry->m_Prefix.m_Pos += offset;
for( LibDrawField* field = LibEntry->m_Fields; field; field = field->Next() )
{
field->m_Pos += offset;
}
DrawEntry = LibEntry->m_Drawings;
while( DrawEntry )
{
switch( DrawEntry->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
#undef STRUCT
#define STRUCT ( (LibDrawArc*) DrawEntry )
STRUCT->m_Pos += offset;
STRUCT->m_ArcStart += offset;
STRUCT->m_ArcEnd += offset;
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
#undef STRUCT
#define STRUCT ( (LibDrawCircle*) DrawEntry )
STRUCT->m_Pos += offset;
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
#undef STRUCT
#define STRUCT ( (LibDrawText*) DrawEntry )
STRUCT->m_Pos += offset;
break;
case COMPONENT_RECT_DRAW_TYPE:
#undef STRUCT
#define STRUCT ( (LibDrawSquare*) DrawEntry )
STRUCT->m_Pos += offset;
STRUCT->m_End += offset;
break;
case COMPONENT_PIN_DRAW_TYPE:
#undef STRUCT
#define STRUCT ( (LibDrawPin*) DrawEntry )
STRUCT->m_Pos += offset;
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
#undef STRUCT
#define STRUCT ( (LibDrawPolyline*) DrawEntry )
for( unsigned ii = 0; ii < STRUCT->GetCornerCount(); ii++ )
STRUCT->m_PolyPoints[ii] += offset;
break;
default:
break;
}
DrawEntry = DrawEntry->Next();
}
/* Redraw the symbol */ /* Redraw the symbol */
GetScreen()->m_Curseur.x = GetScreen()->m_Curseur.y = 0; GetScreen()->m_Curseur.x = GetScreen()->m_Curseur.y = 0;
......
This diff is collapsed.
...@@ -17,34 +17,18 @@ ...@@ -17,34 +17,18 @@
#include "id.h" #include "id.h"
/****************************************************/
void WinEDA_ViewlibFrame::ReCreateHToolbar() void WinEDA_ViewlibFrame::ReCreateHToolbar()
/****************************************************/
{ {
int ii; int ii;
EDA_LibComponentStruct* RootLibEntry = NULL, * CurrentLibEntry = NULL; LibraryStruct* lib;
bool asdeMorgan = FALSE, state; EDA_LibComponentStruct* component = NULL;
LibCmpEntry* entry = NULL;
if( (g_CurrentViewLibraryName != wxEmptyString) bool asdeMorgan = false;
&& (g_CurrentViewComponentName != wxEmptyString) )
{
RootLibEntry =
( EDA_LibComponentStruct* ) FindLibPart( g_CurrentViewComponentName,
g_CurrentViewLibraryName );
if( RootLibEntry && LookForConvertPart( RootLibEntry ) > 1 )
asdeMorgan = TRUE;
CurrentLibEntry =
( EDA_LibComponentStruct* ) FindLibPart( g_CurrentViewComponentName,
g_CurrentViewLibraryName,
ALIAS );
}
if( m_HToolBar == NULL ) if( m_HToolBar == NULL )
{ {
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR,
this,
ID_H_TOOLBAR,
TRUE ); TRUE );
SetToolBar( m_HToolBar ); SetToolBar( m_HToolBar );
...@@ -116,11 +100,27 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar() ...@@ -116,11 +100,27 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
_( "Insert component in schematic" ) ); _( "Insert component in schematic" ) );
} }
// after adding the buttons to the toolbar, must call Realize() to reflect // after adding the buttons to the toolbar, must call Realize() to
// the changes // reflect the changes
m_HToolBar->Realize(); m_HToolBar->Realize();
} }
if( (g_CurrentViewLibraryName != wxEmptyString)
&& (g_CurrentViewComponentName != wxEmptyString) )
{
lib = FindLibrary( g_CurrentViewLibraryName );
if( lib != NULL )
{
component = lib->FindComponent( g_CurrentViewComponentName );
if( component && component->HasConversion() )
asdeMorgan = true;
entry = lib->FindEntry( g_CurrentViewComponentName );
}
}
// Must be AFTER Realize(): // Must be AFTER Realize():
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT,
(g_ViewConvert <= 1) ? TRUE : FALSE ); (g_ViewConvert <= 1) ? TRUE : FALSE );
...@@ -130,8 +130,8 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar() ...@@ -130,8 +130,8 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
m_HToolBar->EnableTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, asdeMorgan ); m_HToolBar->EnableTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, asdeMorgan );
int jj = 1; int jj = 1;
if( RootLibEntry ) if( component )
jj = MAX( RootLibEntry->m_UnitCount, 1 ); jj = MAX( component->m_UnitCount, 1 );
SelpartBox->Clear(); SelpartBox->Clear();
for( ii = 0; ii < jj; ii++ ) for( ii = 0; ii < jj; ii++ )
{ {
...@@ -141,20 +141,13 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar() ...@@ -141,20 +141,13 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
} }
SelpartBox->SetSelection( 0 ); SelpartBox->SetSelection( 0 );
state = FALSE; SelpartBox->Enable( component && component->HasConversion() );
if( CurrentLibEntry && jj > 1 )
state = TRUE; m_HToolBar->EnableTool( ID_LIBVIEW_VIEWDOC,
SelpartBox->Enable( state ); entry && ( entry->m_DocFile != wxEmptyString ) );
state = FALSE;
if( CurrentLibEntry && (CurrentLibEntry->m_DocFile != wxEmptyString) )
state = TRUE;
m_HToolBar->EnableTool( ID_LIBVIEW_VIEWDOC, state );
} }
/****************************************************/
void WinEDA_ViewlibFrame::ReCreateVToolbar() void WinEDA_ViewlibFrame::ReCreateVToolbar()
/****************************************************/
{ {
} }
...@@ -277,13 +277,21 @@ int WinEDA_ViewlibFrame::BestZoom() ...@@ -277,13 +277,21 @@ int WinEDA_ViewlibFrame::BestZoom()
{ {
int bestzoom, ii, jj; int bestzoom, ii, jj;
wxSize size, itemsize; wxSize size, itemsize;
EDA_LibComponentStruct* CurrentLibEntry = NULL; EDA_LibComponentStruct* component;
LibraryStruct* lib;
CurrentLibEntry = GetScreen()->m_Curseur.x = 0;
( EDA_LibComponentStruct* ) FindLibPart( g_CurrentViewComponentName, GetScreen()->m_Curseur.y = 0;
g_CurrentViewLibraryName ); bestzoom = 16;
if( CurrentLibEntry == NULL ) lib = FindLibrary( g_CurrentViewLibraryName );
if( lib == NULL )
return bestzoom;
component = lib->FindComponent( g_CurrentViewComponentName );
if( component == NULL )
{ {
bestzoom = 16; bestzoom = 16;
GetScreen()->m_Curseur.x = 0; GetScreen()->m_Curseur.x = 0;
...@@ -291,14 +299,13 @@ int WinEDA_ViewlibFrame::BestZoom() ...@@ -291,14 +299,13 @@ int WinEDA_ViewlibFrame::BestZoom()
return bestzoom; return bestzoom;
} }
EDA_Rect BoundaryBox = CurrentLibEntry->GetBoundaryBox( g_ViewUnit, EDA_Rect BoundaryBox = component->GetBoundaryBox( g_ViewUnit,
g_ViewConvert ); g_ViewConvert );
itemsize = BoundaryBox.GetSize(); itemsize = BoundaryBox.GetSize();
size = DrawPanel->GetClientSize(); size = DrawPanel->GetClientSize();
size -= wxSize( 100, 100 ); // reserve a 100 mils margin size -= wxSize( 25, 25 ); // reserve a 25 mils margin.
ii = itemsize.x / size.x; ii = wxRound( double( itemsize.x ) / double( size.x ) );
jj = itemsize.y / size.y; jj = wxRound( double( itemsize.y ) / double( size.y ) );
bestzoom = MAX( ii, jj ) + 1; bestzoom = MAX( ii, jj ) + 1;
GetScreen()->m_Curseur = BoundaryBox.Centre(); GetScreen()->m_Curseur = BoundaryBox.Centre();
......
...@@ -172,9 +172,7 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option ) ...@@ -172,9 +172,7 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option )
return; return;
} }
LibCmpEntry* LibEntry = FindLibPart( g_CurrentViewComponentName, LibCmpEntry* LibEntry = Lib->FindEntry( g_CurrentViewComponentName );
g_CurrentViewLibraryName,
ALIAS );
if( LibEntry == NULL ) if( LibEntry == NULL )
return; return;
...@@ -258,18 +256,23 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag ) ...@@ -258,18 +256,23 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag )
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{ {
EDA_LibComponentStruct* LibEntry = NULL; EDA_LibComponentStruct* component;
LibCmpEntry* ViewCmpEntry = NULL; LibCmpEntry* entry;
const wxChar* RootName, * CmpName; LibraryStruct* lib;
wxString Msg; wxString msg;
wxString tmp;
ActiveScreen = GetScreen(); ActiveScreen = GetScreen();
LibEntry = lib = FindLibrary( g_CurrentViewLibraryName );
( EDA_LibComponentStruct* ) FindLibPart( g_CurrentViewComponentName,
g_CurrentViewLibraryName, if( lib == NULL )
ALIAS ); return;
ViewCmpEntry = (LibCmpEntry*) LibEntry;
entry = lib->FindEntry( g_CurrentViewComponentName );
if( entry == NULL )
return;
/* Forcage de la reinit de la brosse et plume courante */ /* Forcage de la reinit de la brosse et plume courante */
GRResetPenAndBrush( DC ); GRResetPenAndBrush( DC );
...@@ -281,51 +284,52 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -281,51 +284,52 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
if( LibEntry ) if( entry->Type != ROOT )
{ {
CmpName = LibEntry->m_Name.m_Text.GetData(); EDA_LibCmpAliasStruct* alias = (EDA_LibCmpAliasStruct*) entry;
if( LibEntry->Type != ROOT )
{ component = lib->FindComponent( alias->m_RootName );
RootName =
( (EDA_LibCmpAliasStruct*) LibEntry )->m_RootName.GetData(); if( component == NULL )
Msg.Printf( _( "Current Part: <%s> (is Alias of <%s>)" ),
CmpName, RootName );
LibEntry =
( EDA_LibComponentStruct* ) FindLibPart( RootName,
g_CurrentViewLibraryName,
ROOT );
if( LibEntry == NULL )
{
Msg.Printf( _( "Error: Root Part <%s> not found" ), RootName );
DisplayError( this, Msg );
}
else
{
/* Affichage du composant ROOT, avec nom de l'alias */
wxString RealName;
RealName = LibEntry->m_Name.m_Text;
LibEntry->m_Name.m_Text = CmpName;
if( g_ViewUnit < 1 )
g_ViewUnit = 1;
if( g_ViewConvert < 1 )
g_ViewConvert = 1;
LibEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_ViewUnit,
g_ViewConvert, GR_DEFAULT_DRAWMODE );
LibEntry->m_Name.m_Text = RealName;
}
}
else
{ {
Msg.Printf( _( "Current Part: <%s>" ), msg.Printf( _( "Root component <%s> for alias <%s> not found in \
ViewCmpEntry->m_Name.m_Text.GetData() ); library." ),
LibEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_ViewUnit, (const wxChar*) alias->m_RootName,
g_ViewConvert, GR_DEFAULT_DRAWMODE ); (const wxChar*) entry->GetName(),
(const wxChar*) lib->m_Name );
DisplayError( this, msg );
return;
} }
AfficheDoc( this, ViewCmpEntry->m_Doc, ViewCmpEntry->m_KeyWord );
msg.Printf( _( "Current Part: <%s> (is Alias of <%s>)" ),
(const wxChar*) entry->GetName(),
(const wxChar*) alias->m_RootName );
/* Temporarily change the name field text to reflect the alias name. */
tmp = component->GetName();
component->m_Name.m_Text = alias->GetName();
if( g_ViewUnit < 1 )
g_ViewUnit = 1;
if( g_ViewConvert < 1 )
g_ViewConvert = 1;
component->m_Name.m_Text = tmp;
}
else
{
component = (EDA_LibComponentStruct*) entry;
msg.Printf( _( "Current Part: <%s>" ),
(const wxChar*) component->GetName() );
} }
SetStatusText( Msg, 0 ); component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_ViewUnit,
g_ViewConvert, GR_DEFAULT_DRAWMODE );
if( !tmp.IsEmpty() )
component->m_Name.m_Text = tmp;
AfficheDoc( this, entry->m_Doc, entry->m_KeyWord );
SetStatusText( msg, 0 );
DrawPanel->Trace_Curseur( DC ); DrawPanel->Trace_Curseur( DC );
} }
...@@ -149,6 +149,14 @@ public: ...@@ -149,6 +149,14 @@ public:
void CursorOff( wxDC* DC ); // remove the grid cursor from the display void CursorOff( wxDC* DC ); // remove the grid cursor from the display
void CursorOn( wxDC* DC ); // display the grid cursor void CursorOn( wxDC* DC ); // display the grid cursor
/**
* Release managed cursor.
*
* Check to see if the cursor is being managed for block or editing
* commands and release it.
*/
void UnManageCursor( void );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
......
...@@ -474,9 +474,24 @@ public: ...@@ -474,9 +474,24 @@ public:
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
void OnImportPart( wxCommandEvent& event ); void OnImportPart( wxCommandEvent& event );
void OnExportPart( wxCommandEvent& event ); void OnExportPart( wxCommandEvent& event );
void OnSelectAlias( wxCommandEvent& event );
void OnSelectPart( wxCommandEvent& event );
void OnEditComponentProperties( wxCommandEvent& event );
void OnUpdateEditingPart( wxUpdateUIEvent& event ); void OnUpdateEditingPart( wxUpdateUIEvent& event );
void OnUpdateNotEditingPart( wxUpdateUIEvent& event ); void OnUpdateNotEditingPart( wxUpdateUIEvent& event );
void OnUpdateUndo( wxUpdateUIEvent& event );
void OnUpdateRedo( wxUpdateUIEvent& event );
void OnUpdateSaveCurrentLib( wxUpdateUIEvent& event );
void OnUpdateViewDoc( wxUpdateUIEvent& event );
void OnUpdatePinByPin( wxUpdateUIEvent& event );
void OnUpdatePartNumber( wxUpdateUIEvent& event );
void OnUpdateDeMorganNormal( wxUpdateUIEvent& event );
void OnUpdateDeMorganConvert( wxUpdateUIEvent& event );
void OnUpdateSelectAlias( wxUpdateUIEvent& event );
void UpdateAliasSelectList();
void UpdatePartSelectList();
void DisplayLibInfos(); void DisplayLibInfos();
void RedrawActiveWindow( wxDC* DC, bool EraseBg ); void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
...@@ -485,7 +500,6 @@ public: ...@@ -485,7 +500,6 @@ public:
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
int BestZoom(); // Retourne le meilleur zoom int BestZoom(); // Retourne le meilleur zoom
void SetToolbars();
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) GetBaseScreen(); } SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) GetBaseScreen(); }
...@@ -506,13 +520,13 @@ private: ...@@ -506,13 +520,13 @@ private:
void SaveOnePartInMemory(); void SaveOnePartInMemory();
void SelectActiveLibrary(); void SelectActiveLibrary();
bool LoadOneLibraryPart(); bool LoadOneLibraryPart();
void SaveActiveLibrary(); void SaveActiveLibrary( wxCommandEvent& event );
bool LoadOneLibraryPartAux( LibCmpEntry* LibEntry, bool LoadOneLibraryPartAux( LibCmpEntry* LibEntry,
LibraryStruct* Library ); LibraryStruct* Library );
void DisplayCmpDoc( const wxString& Name ); void DisplayCmpDoc( const wxString& Name );
void InstallLibeditFrame(); void EditComponentProperties();
// General editing // General editing
public: public:
...@@ -537,13 +551,15 @@ private: ...@@ -537,13 +551,15 @@ private:
void PlaceAncre(); void PlaceAncre();
// Edition des graphismes: // Edition des graphismes:
LibEDA_BaseStruct* CreateGraphicItem( EDA_LibComponentStruct * LibEntry, wxDC* DC ); LibEDA_BaseStruct* CreateGraphicItem( EDA_LibComponentStruct* LibEntry,
wxDC* DC );
void GraphicItemBeginDraw( wxDC* DC ); void GraphicItemBeginDraw( wxDC* DC );
void StartMoveDrawSymbol( wxDC* DC ); void StartMoveDrawSymbol( wxDC* DC );
void EndDrawGraphicItem( wxDC* DC ); void EndDrawGraphicItem( wxDC* DC );
void LoadOneSymbol(); void LoadOneSymbol();
void SaveOneSymbol(); void SaveOneSymbol();
void EditGraphicSymbol( wxDC* DC, LibEDA_BaseStruct* DrawItem ); void EditGraphicSymbol( wxDC* DC,
LibEDA_BaseStruct* DrawItem );
void EditSymbolText( wxDC* DC, LibEDA_BaseStruct* DrawItem ); void EditSymbolText( wxDC* DC, LibEDA_BaseStruct* DrawItem );
void RotateSymbolText( wxDC* DC ); void RotateSymbolText( wxDC* DC );
void DeleteDrawPoly( wxDC* DC ); void DeleteDrawPoly( wxDC* DC );
......
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