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.
This commit is contained in:
parent
7a0f7bda9c
commit
3803b79ac5
|
@ -107,7 +107,7 @@ check_find_package_result(OPENGL_FOUND "OpenGL")
|
|||
######################
|
||||
# Find Boost library #
|
||||
######################
|
||||
find_package(Boost QUIET)
|
||||
find_package(Boost 1.36 QUIET)
|
||||
check_find_package_result(Boost_FOUND "Boost")
|
||||
|
||||
##########################
|
||||
|
|
|
@ -1377,3 +1377,15 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event )
|
|||
Scroll( x, y );
|
||||
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
|
|||
getpart.cpp
|
||||
hierarch.cpp
|
||||
hotkeys.cpp
|
||||
libalias.cpp
|
||||
libarch.cpp
|
||||
libedit.cpp
|
||||
libedit_onleftclick.cpp
|
||||
|
|
|
@ -93,100 +93,10 @@ int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent,
|
|||
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();
|
||||
for( ii = 0; ii < imax; ii ++ )
|
||||
{
|
||||
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;
|
||||
item->m_Selected = IS_SELECTED;
|
||||
ItemsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -513,54 +423,12 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
|
|||
return;
|
||||
|
||||
NEGATE( offset.y ); // Y axis for lib items is Down to Up: reverse y offset value
|
||||
item = LibEntry->m_Drawings;
|
||||
for( ; item != NULL; item = item->Next() )
|
||||
for( item = LibEntry->m_Drawings; item != NULL; item = item->Next() )
|
||||
{
|
||||
if( item->m_Selected == 0 )
|
||||
continue;
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
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->SetOffset( offset );
|
||||
item->m_Flags = item->m_Selected = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,11 +39,13 @@ bool LibDrawText::Save( FILE* ExportFile ) const
|
|||
// changed to '~'
|
||||
text.Replace( wxT( " " ), wxT( "~" ) );
|
||||
|
||||
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,
|
||||
CONV_TO_UTF8( text ) );
|
||||
fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal",
|
||||
( m_Bold>0 ) ? 1 : 0 );
|
||||
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,
|
||||
CONV_TO_UTF8( text ) ) < 0 )
|
||||
return false;
|
||||
if( fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal",
|
||||
( m_Bold > 0 ) ? 1 : 0 ) < 0 )
|
||||
return false;
|
||||
|
||||
char hjustify = 'C';
|
||||
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
|
||||
|
@ -57,9 +59,8 @@ bool LibDrawText::Save( FILE* ExportFile ) const
|
|||
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
|
||||
vjustify = 'T';
|
||||
|
||||
fprintf( ExportFile, " %c %c", hjustify, vjustify );
|
||||
|
||||
fprintf( ExportFile, "\n" );
|
||||
if( fprintf( ExportFile, " %c %c\n", hjustify, vjustify ) < 0 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -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
|
||||
* @return the size of the "pen" that be used to draw or plot this item
|
||||
*/
|
||||
|
|
|
@ -228,15 +228,15 @@ EDA_LibCmpAliasStruct::~EDA_LibCmpAliasStruct()
|
|||
EDA_LibComponentStruct:: EDA_LibComponentStruct( const wxChar* CmpName ) :
|
||||
LibCmpEntry( ROOT, CmpName )
|
||||
{
|
||||
m_Drawings = NULL;
|
||||
m_LastDate = 0;
|
||||
m_UnitCount = 1;
|
||||
m_TextInside = 40;
|
||||
m_Options = ENTRY_NORMAL;
|
||||
m_Drawings = NULL;
|
||||
m_LastDate = 0;
|
||||
m_UnitCount = 1;
|
||||
m_TextInside = 40;
|
||||
m_Options = ENTRY_NORMAL;
|
||||
m_UnitSelectionLocked = FALSE;
|
||||
m_DrawPinNum = 1;
|
||||
m_DrawPinName = 1;
|
||||
m_Prefix.m_FieldId = REFERENCE;
|
||||
m_DrawPinNum = 1;
|
||||
m_DrawPinName = 1;
|
||||
m_Prefix.m_FieldId = REFERENCE;
|
||||
m_Prefix.SetParent( this );
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ void EDA_LibComponentStruct::RemoveDrawItem( LibEDA_BaseStruct* item,
|
|||
|
||||
if( dc != NULL )
|
||||
item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
|
||||
DefaultTransformMatrix );
|
||||
DefaultTransformMatrix );
|
||||
|
||||
if( m_Drawings == item )
|
||||
{
|
||||
|
@ -404,59 +404,86 @@ bool EDA_LibComponentStruct::Save( FILE* aFile )
|
|||
return false;
|
||||
|
||||
/* 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 */
|
||||
fprintf( aFile, "DEF" );
|
||||
if( fprintf( aFile, "DEF" ) < 0 )
|
||||
return false;
|
||||
|
||||
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
|
||||
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() )
|
||||
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
|
||||
fprintf( aFile, " ~" );
|
||||
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' );
|
||||
{
|
||||
if( fprintf( aFile, " ~" ) < 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
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 */
|
||||
m_Prefix.Save( aFile );
|
||||
m_Name.Save( aFile );
|
||||
if( !SaveDateAndTime( aFile ) || !m_Prefix.Save( aFile )
|
||||
|| !m_Name.Save( aFile ) )
|
||||
return false;
|
||||
|
||||
for( Field = m_Fields; Field != NULL; Field = Field->Next() )
|
||||
{
|
||||
if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() )
|
||||
continue;
|
||||
Field->Save( aFile );
|
||||
if( !Field->Save( aFile ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Save the alias list: a line starting by "ALIAS" */
|
||||
if( m_AliasList.GetCount() != 0 )
|
||||
{
|
||||
fprintf( aFile, "ALIAS" );
|
||||
unsigned ii;
|
||||
for( ii = 0; ii < m_AliasList.GetCount(); ii++ )
|
||||
fprintf( aFile, " %s", CONV_TO_UTF8( m_AliasList[ii] ) );
|
||||
if( fprintf( aFile, "ALIAS" ) < 0 )
|
||||
return false;
|
||||
|
||||
fprintf( aFile, "\n" );
|
||||
for( size_t ii = 0; ii < m_AliasList.GetCount(); ii++ )
|
||||
{
|
||||
if( fprintf( aFile, " %s", CONV_TO_UTF8( m_AliasList[ii] ) ) < 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( fprintf( aFile, "\n" ) < 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Write the footprint filter list */
|
||||
if( m_FootprintList.GetCount() != 0 )
|
||||
{
|
||||
fprintf( aFile, "$FPLIST\n" );
|
||||
unsigned ii;
|
||||
for( ii = 0; ii < m_FootprintList.GetCount(); ii++ )
|
||||
fprintf( aFile, " %s\n", CONV_TO_UTF8( m_FootprintList[ii] ) );
|
||||
if( fprintf( aFile, "$FPLIST\n" ) < 0 )
|
||||
return false;
|
||||
|
||||
fprintf( aFile, "$ENDFPLIST\n" );
|
||||
for( size_t ii = 0; ii < m_FootprintList.GetCount(); ii++ )
|
||||
{
|
||||
if( fprintf( aFile, " %s\n",
|
||||
CONV_TO_UTF8( m_FootprintList[ii] ) ) < 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( fprintf( aFile, "$ENDFPLIST\n" ) < 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Save graphics items (including pins) */
|
||||
|
@ -466,17 +493,23 @@ bool EDA_LibComponentStruct::Save( FILE* aFile )
|
|||
* when a file editing "by hand" is made */
|
||||
SortDrawItems();
|
||||
|
||||
fprintf( aFile, "DRAW\n" );
|
||||
if( fprintf( aFile, "DRAW\n" ) < 0 )
|
||||
return false;
|
||||
|
||||
DrawEntry = m_Drawings;
|
||||
while( DrawEntry )
|
||||
{
|
||||
DrawEntry->Save( aFile );
|
||||
if( !DrawEntry->Save( aFile ) )
|
||||
return false;
|
||||
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;
|
||||
}
|
||||
|
@ -890,14 +923,14 @@ bool EDA_LibComponentStruct::SaveDateAndTime( FILE* file )
|
|||
return true;
|
||||
|
||||
sec = m_LastDate & 63;
|
||||
min = (m_LastDate >> 6) & 63;
|
||||
hour = (m_LastDate >> 12) & 31;
|
||||
day = (m_LastDate >> 17) & 31;
|
||||
mon = (m_LastDate >> 22) & 15;
|
||||
year = (m_LastDate >> 26) + 1990;
|
||||
min = ( m_LastDate >> 6 ) & 63;
|
||||
hour = ( m_LastDate >> 12 ) & 31;
|
||||
day = ( m_LastDate >> 17 ) & 31;
|
||||
mon = ( m_LastDate >> 22 ) & 15;
|
||||
year = ( m_LastDate >> 26 ) + 1990;
|
||||
|
||||
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 true;
|
||||
|
@ -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
|
||||
* writes the doc info out to a FILE in "*.dcm" format.
|
||||
|
@ -941,17 +1049,23 @@ bool LibCmpEntry::SaveDoc( FILE* aFile )
|
|||
return true;
|
||||
|
||||
/* 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() )
|
||||
fprintf( aFile, "D %s\n", CONV_TO_UTF8( m_Doc ) );
|
||||
if( ! m_Doc.IsEmpty()
|
||||
&& fprintf( aFile, "D %s\n", CONV_TO_UTF8( m_Doc ) ) < 0 )
|
||||
return false;
|
||||
|
||||
if( ! m_KeyWord.IsEmpty() )
|
||||
fprintf( aFile, "K %s\n", CONV_TO_UTF8( m_KeyWord ) );
|
||||
if( ! m_KeyWord.IsEmpty()
|
||||
&& 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 ) );
|
||||
if( ! m_DocFile.IsEmpty()
|
||||
&& fprintf( aFile, "F %s\n", CONV_TO_UTF8( m_DocFile ) ) < 0 )
|
||||
return false;
|
||||
|
||||
if( fprintf( aFile, "$ENDCMP\n" ) < 0 )
|
||||
return false;
|
||||
|
||||
fprintf( aFile, "$ENDCMP\n" );
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ public:
|
|||
}
|
||||
|
||||
|
||||
const wxString& GetName() { return m_Name.m_Text; }
|
||||
|
||||
/**
|
||||
* Write the entry document information to a FILE in "*.dcm" format.
|
||||
*
|
||||
|
@ -127,7 +129,7 @@ public:
|
|||
|
||||
EDA_Rect GetBoundaryBox( int Unit, int Convert );
|
||||
|
||||
void SortDrawItems();
|
||||
void SortDrawItems();
|
||||
|
||||
bool SaveDateAndTime( FILE* ExportFile );
|
||||
bool LoadDateAndTime( char* Line );
|
||||
|
@ -199,6 +201,40 @@ public:
|
|||
void RemoveDrawItem( LibEDA_BaseStruct* item,
|
||||
WinEDA_DrawPanel* panel = 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 ) :
|
|||
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
|
||||
}
|
||||
|
||||
|
||||
LibDrawField::~LibDrawField()
|
||||
{
|
||||
}
|
||||
|
@ -74,13 +75,14 @@ bool LibDrawField::Save( FILE* ExportFile ) const
|
|||
vjustify = 'T';
|
||||
if( text.IsEmpty() )
|
||||
text = wxT( "~" );
|
||||
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_Orient == 0 ? 'H' : 'V',
|
||||
(m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V',
|
||||
hjustify, vjustify,
|
||||
m_Italic ? 'I' : 'N',
|
||||
m_Bold ? 'B' : 'N' );
|
||||
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_Orient == 0 ? 'H' : 'V',
|
||||
(m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V',
|
||||
hjustify, vjustify,
|
||||
m_Italic ? 'I' : 'N',
|
||||
m_Bold ? 'B' : 'N' ) < 0 )
|
||||
return false;
|
||||
|
||||
/* Save field name, if necessary
|
||||
* Field name is saved only if it is not the default name.
|
||||
|
@ -88,10 +90,13 @@ bool LibDrawField::Save( FILE* ExportFile ) const
|
|||
* a country to an other
|
||||
*/
|
||||
if( m_FieldId >= FIELD1 && !m_Name.IsEmpty()
|
||||
&& m_Name != ReturnDefaultFieldName( m_FieldId ))
|
||||
fprintf( ExportFile, " \"%s\"", CONV_TO_UTF8( m_Name ) );
|
||||
&& m_Name != ReturnDefaultFieldName( m_FieldId )
|
||||
&& fprintf( ExportFile, " \"%s\"", CONV_TO_UTF8( m_Name ) ) < 0 )
|
||||
return false;
|
||||
|
||||
if( fprintf( ExportFile, "\n" ) < 0 )
|
||||
return false;
|
||||
|
||||
fprintf( ExportFile, "\n" );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -312,10 +317,12 @@ bool LibDrawField::HitTest( const wxPoint& refPos )
|
|||
* @param aThreshold = unused here (TextHitTest calculates its threshold )
|
||||
* @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;
|
||||
// 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 )
|
||||
{
|
||||
extraCharCount++;
|
||||
|
@ -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
|
||||
* Return the default field name from its index (REFERENCE, VALUE ..)
|
||||
|
|
|
@ -105,6 +105,9 @@ public:
|
|||
|
||||
protected:
|
||||
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
|
||||
|
|
|
@ -68,7 +68,7 @@ void LibraryStruct::GetEntryNames( wxArrayString& names, bool sort,
|
|||
if( makeUpperCase )
|
||||
names.Add( entry.m_Name.m_Text.MakeUpper() );
|
||||
else
|
||||
names.Add( entry.m_Name.m_Text );
|
||||
names.Add( entry.GetName() );
|
||||
}
|
||||
|
||||
if( sort )
|
||||
|
@ -84,11 +84,11 @@ void LibraryStruct::SearchEntryNames( wxArrayString& names,
|
|||
BOOST_FOREACH( LibCmpEntry& entry, m_Entries )
|
||||
{
|
||||
if( !keySearch.IsEmpty() && KeyWordOk( keySearch, entry.m_KeyWord ) )
|
||||
names.Add( entry.m_Name.m_Text );
|
||||
names.Add( entry.GetName() );
|
||||
if( !nameSearch.IsEmpty() && WildCompareString( nameSearch,
|
||||
entry.m_Name.m_Text,
|
||||
entry.GetName(),
|
||||
false ) )
|
||||
names.Add( entry.m_Name.m_Text );
|
||||
names.Add( entry.GetName() );
|
||||
}
|
||||
|
||||
if( sort )
|
||||
|
@ -100,7 +100,7 @@ LibCmpEntry* LibraryStruct::FindEntry( const wxChar* name )
|
|||
{
|
||||
BOOST_FOREACH( LibCmpEntry& entry, m_Entries )
|
||||
{
|
||||
if( entry.m_Name.m_Text.CmpNoCase( name ) == 0 )
|
||||
if( entry.GetName().CmpNoCase( name ) == 0 )
|
||||
return &entry;
|
||||
}
|
||||
|
||||
|
@ -110,19 +110,56 @@ LibCmpEntry* LibraryStruct::FindEntry( const wxChar* name )
|
|||
|
||||
LibCmpEntry* LibraryStruct::FindEntry( const wxChar* name, LibrEntryType type )
|
||||
{
|
||||
LibCmpEntry* entry = FindEntry( name );
|
||||
|
||||
if( entry && entry->Type != ROOT && type == ROOT )
|
||||
BOOST_FOREACH( LibCmpEntry& entry, m_Entries )
|
||||
{
|
||||
EDA_LibCmpAliasStruct* alias = ( EDA_LibCmpAliasStruct* ) entry;
|
||||
|
||||
entry = FindEntry( alias->m_RootName );
|
||||
|
||||
if( entry && entry->Type != ROOT )
|
||||
return NULL;
|
||||
if( entry.GetName().CmpNoCase( name ) == 0 && entry.Type == type )
|
||||
return &entry;
|
||||
}
|
||||
|
||||
return entry;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
EDA_LibComponentStruct* LibraryStruct::FindComponent( const wxChar* name,
|
||||
bool searchAliases )
|
||||
{
|
||||
if( !searchAliases )
|
||||
return (EDA_LibComponentStruct*) FindEntry( name, ROOT );
|
||||
|
||||
EDA_LibComponentStruct* component = NULL;
|
||||
LibCmpEntry* entry = FindEntry( name );
|
||||
|
||||
if( entry != NULL && entry->Type == ALIAS )
|
||||
{
|
||||
EDA_LibCmpAliasStruct* alias = (EDA_LibCmpAliasStruct*) entry;
|
||||
component = (EDA_LibComponentStruct*) FindEntry( alias->m_RootName,
|
||||
ROOT );
|
||||
}
|
||||
else
|
||||
{
|
||||
component = (EDA_LibComponentStruct*) entry;
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
|
||||
bool LibraryStruct::AddAlias( EDA_LibCmpAliasStruct* alias )
|
||||
{
|
||||
wxASSERT( alias != NULL );
|
||||
|
||||
if( FindEntry( alias->GetName() ) != NULL )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
msg.Printf( _( "Cannot add duplicate alias <%s> to library <%s>." ),
|
||||
(const wxChar*) alias->GetName(), (const wxChar*) m_Name );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Entries.push_back( (LibCmpEntry*) alias );
|
||||
m_IsModified = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -130,25 +167,32 @@ EDA_LibComponentStruct* LibraryStruct::AddComponent( EDA_LibComponentStruct* cmp
|
|||
{
|
||||
wxASSERT( cmp != NULL );
|
||||
|
||||
EDA_LibCmpAliasStruct* Alias;
|
||||
EDA_LibComponentStruct* newCmp = CopyLibEntryStruct( cmp );
|
||||
|
||||
if( newCmp == NULL )
|
||||
return NULL;
|
||||
|
||||
newCmp->m_AliasList.Clear();
|
||||
m_Entries.push_back( (LibCmpEntry*) newCmp );
|
||||
m_IsModified = true;
|
||||
|
||||
for( unsigned ii = 0; ii < cmp->m_AliasList.GetCount(); ii += ALIAS_NEXT )
|
||||
for( size_t i = 0; i < newCmp->m_AliasList.GetCount(); i++ )
|
||||
{
|
||||
wxString aliasname = cmp->m_AliasList[ii + ALIAS_NAME];
|
||||
newCmp->m_AliasList.Add( aliasname );
|
||||
Alias = new EDA_LibCmpAliasStruct( aliasname, newCmp->m_Name.m_Text );
|
||||
Alias->m_Doc = cmp->m_AliasList[ii + ALIAS_DOC];
|
||||
Alias->m_KeyWord = cmp->m_AliasList[ii + ALIAS_KEYWORD];
|
||||
Alias->m_DocFile = cmp->m_AliasList[ii + ALIAS_DOC_FILENAME];
|
||||
m_Entries.push_back( (LibCmpEntry *) Alias );
|
||||
EDA_LibCmpAliasStruct* alias = FindAlias( newCmp->m_AliasList[ i ] );
|
||||
|
||||
if( alias == NULL )
|
||||
{
|
||||
alias = new EDA_LibCmpAliasStruct( newCmp->m_AliasList[ i ],
|
||||
newCmp->GetName() );
|
||||
m_Entries.push_back( alias );
|
||||
}
|
||||
else if( alias->m_RootName != newCmp->GetName() )
|
||||
{
|
||||
wxLogError( _( "Conflict in library <%s>: alias <%s> already has \
|
||||
root name <%s> and will not be assigned to root name <%s>." ),
|
||||
(const wxChar*) m_Name,
|
||||
(const wxChar*) alias->m_RootName,
|
||||
(const wxChar*) newCmp->GetName() );
|
||||
}
|
||||
}
|
||||
|
||||
m_Entries.sort();
|
||||
|
@ -163,7 +207,7 @@ void LibraryStruct::RemoveEntry( const wxString& name )
|
|||
|
||||
for( i = m_Entries.begin(); i < m_Entries.end(); i++ )
|
||||
{
|
||||
if( i->m_Name.m_Text.CmpNoCase( name ) == 0 )
|
||||
if( i->GetName().CmpNoCase( name ) == 0 )
|
||||
{
|
||||
m_Entries.erase( i );
|
||||
return;
|
||||
|
@ -184,31 +228,31 @@ void LibraryStruct::RemoveEntry( LibCmpEntry* entry )
|
|||
if( entry->Type == ALIAS )
|
||||
{
|
||||
Alias = (EDA_LibCmpAliasStruct*) entry;
|
||||
Root = ( EDA_LibComponentStruct* ) FindEntry( Alias->m_RootName, ROOT );
|
||||
Root = FindComponent( Alias->m_RootName );
|
||||
|
||||
/* Remove alias name from the root component alias list */
|
||||
if( Root == NULL )
|
||||
{
|
||||
wxLogWarning( wxT( "No root component found for alias <%s> in \
|
||||
library <%s>." ),
|
||||
( const wxChar* ) entry->m_Name.m_Text,
|
||||
( const wxChar* ) entry->GetName(),
|
||||
( const wxChar* ) m_Name );
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = Root->m_AliasList.Index( entry->m_Name.m_Text, false );
|
||||
int index = Root->m_AliasList.Index( entry->GetName(), false );
|
||||
|
||||
if( index == wxNOT_FOUND )
|
||||
wxLogWarning( wxT( "Alias <%s> not found in component <%s> \
|
||||
alias list in library <%s>" ),
|
||||
( const wxChar* ) entry->m_Name.m_Text,
|
||||
( const wxChar* ) Root->m_Name.m_Text,
|
||||
( const wxChar* ) entry->GetName(),
|
||||
( const wxChar* ) Root->GetName(),
|
||||
( const wxChar* ) m_Name );
|
||||
else
|
||||
Root->m_AliasList.RemoveAt( index );
|
||||
}
|
||||
|
||||
RemoveEntry( Alias->m_Name.m_Text );
|
||||
RemoveEntry( Alias->GetName() );
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -218,7 +262,7 @@ alias list in library <%s>" ),
|
|||
/* Entry is a component with no aliases so removal is simple. */
|
||||
if( Root->m_AliasList.GetCount() == 0 )
|
||||
{
|
||||
RemoveEntry( Root->m_Name.m_Text );
|
||||
RemoveEntry( Root->GetName() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -227,14 +271,14 @@ alias list in library <%s>" ),
|
|||
|
||||
/* The root component is not really deleted, it is renamed with the first
|
||||
* alias name. */
|
||||
Alias = (EDA_LibCmpAliasStruct*) FindEntry( AliasName, ALIAS );
|
||||
Alias = FindAlias( AliasName );
|
||||
|
||||
if( Alias == NULL || Alias->Type == ROOT )
|
||||
if( Alias == NULL )
|
||||
{
|
||||
wxLogWarning( wxT( "Alias <%s> for component <%s> not found in \
|
||||
library <%s>" ),
|
||||
( const wxChar* ) AliasName,
|
||||
( const wxChar* ) Root->m_Name.m_Text,
|
||||
( const wxChar* ) Root->GetName(),
|
||||
( const wxChar* ) m_Name );
|
||||
return;
|
||||
}
|
||||
|
@ -254,27 +298,93 @@ library <%s>" ),
|
|||
/* Change the "RootName" for all other aliases */
|
||||
for( size_t ii = 0; ii < Root->m_AliasList.GetCount(); ii++ )
|
||||
{
|
||||
Alias = (EDA_LibCmpAliasStruct*) FindEntry( Root->m_AliasList[ii],
|
||||
ALIAS );
|
||||
Alias = FindAlias( Root->m_AliasList[ii] );
|
||||
|
||||
/* Should not occur if library was saved by the library editor.
|
||||
* However, it is possible if the library was edited by hand or
|
||||
* some other program or a there is a bug in the library editor. */
|
||||
if( Alias == NULL || Alias->Type != ALIAS )
|
||||
if( Alias == NULL )
|
||||
{
|
||||
wxLogWarning( wxT( "Alias <%s> for component <%s> not found in \
|
||||
library <%s>." ),
|
||||
( const wxChar* ) AliasName,
|
||||
( const wxChar* ) Root->m_Name.m_Text,
|
||||
( const wxChar* ) Root->GetName(),
|
||||
( const wxChar* ) m_Name );
|
||||
continue;
|
||||
}
|
||||
|
||||
Alias->m_RootName = Root->m_Name.m_Text;
|
||||
Alias->m_RootName = Root->GetName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EDA_LibComponentStruct* LibraryStruct::ReplaceComponent(
|
||||
EDA_LibComponentStruct* oldComponent,
|
||||
EDA_LibComponentStruct* newComponent )
|
||||
{
|
||||
wxASSERT( oldComponent != NULL && newComponent != NULL
|
||||
&& oldComponent->GetName().CmpNoCase( newComponent->GetName() )== 0 );
|
||||
|
||||
size_t i;
|
||||
int index;
|
||||
EDA_LibCmpAliasStruct* alias;
|
||||
|
||||
if( oldComponent->m_AliasList != newComponent->m_AliasList )
|
||||
{
|
||||
/* Remove extra aliases. */
|
||||
for( i = 0; i < oldComponent->m_AliasList.GetCount(); i++ )
|
||||
{
|
||||
index =
|
||||
newComponent->m_AliasList.Index( oldComponent->m_AliasList[ i ] );
|
||||
|
||||
if( index != wxNOT_FOUND )
|
||||
continue;
|
||||
|
||||
wxLogDebug( wxT( "Removing extra alias <%s> from component <%s> \
|
||||
in library <%s>." ),
|
||||
(const wxChar*) oldComponent->m_AliasList[ i ],
|
||||
(const wxChar*) oldComponent->GetName(),
|
||||
(const wxChar*) m_Name );
|
||||
|
||||
RemoveEntry( oldComponent->m_AliasList[ i ] );
|
||||
}
|
||||
|
||||
/* Add new aliases. */
|
||||
for( i = 0; i < newComponent->m_AliasList.GetCount(); i++ )
|
||||
{
|
||||
index =
|
||||
oldComponent->m_AliasList.Index( newComponent->m_AliasList[ i ] );
|
||||
|
||||
if( index != wxNOT_FOUND
|
||||
|| FindEntry( newComponent->m_AliasList[ i ] ) != NULL )
|
||||
continue;
|
||||
|
||||
wxLogDebug( wxT( "Adding extra alias <%s> from component <%s> \
|
||||
in library <%s>." ),
|
||||
(const wxChar*) newComponent->m_AliasList[ i ],
|
||||
(const wxChar*) newComponent->GetName(),
|
||||
(const wxChar*) m_Name );
|
||||
|
||||
alias = new EDA_LibCmpAliasStruct( newComponent->m_AliasList[ i ],
|
||||
newComponent->GetName() );
|
||||
m_Entries.push_back( alias );
|
||||
}
|
||||
}
|
||||
|
||||
RemoveEntry( oldComponent->GetName() );
|
||||
|
||||
EDA_LibComponentStruct* newCmp = CopyLibEntryStruct( newComponent );
|
||||
|
||||
if( newCmp == NULL )
|
||||
return NULL;
|
||||
|
||||
m_Entries.push_back( (LibCmpEntry*) newCmp );
|
||||
m_Entries.sort();
|
||||
m_IsModified = true;
|
||||
return newCmp;
|
||||
}
|
||||
|
||||
|
||||
LibCmpEntry* LibraryStruct::GetNextEntry( const wxChar* name )
|
||||
{
|
||||
size_t i;
|
||||
|
@ -282,7 +392,7 @@ LibCmpEntry* LibraryStruct::GetNextEntry( const wxChar* name )
|
|||
|
||||
for( i = 0; i < m_Entries.size(); i++ )
|
||||
{
|
||||
if( m_Entries[i].m_Name.m_Text.CmpNoCase( name ) == 0 )
|
||||
if( m_Entries[i].GetName().CmpNoCase( name ) == 0 )
|
||||
{
|
||||
if( i < m_Entries.size() - 1 )
|
||||
{
|
||||
|
@ -306,7 +416,7 @@ LibCmpEntry* LibraryStruct::GetPreviousEntry( const wxChar* name )
|
|||
|
||||
for( i = 0; i < m_Entries.size(); i++ )
|
||||
{
|
||||
if( m_Entries[i].m_Name.m_Text.CmpNoCase( name ) == 0 && entry )
|
||||
if( m_Entries[i].GetName().CmpNoCase( name ) == 0 && entry )
|
||||
break;
|
||||
|
||||
entry = &m_Entries[i];
|
||||
|
@ -407,7 +517,7 @@ void LibraryStruct::LoadAliases( EDA_LibComponentStruct* component )
|
|||
{
|
||||
AliasEntry =
|
||||
new EDA_LibCmpAliasStruct( component->m_AliasList[ii],
|
||||
component->m_Name.m_Text );
|
||||
component->GetName() );
|
||||
m_Entries.push_back( AliasEntry );
|
||||
}
|
||||
}
|
||||
|
@ -484,7 +594,7 @@ document file." ),
|
|||
|
||||
wxString cmpname = CONV_FROM_UTF8( Name );
|
||||
|
||||
Entry = FindEntry( cmpname, ALIAS );
|
||||
Entry = FindEntry( cmpname );
|
||||
|
||||
while( GetLine( f, Line, &LineNum, sizeof(Line) ) )
|
||||
{
|
||||
|
|
|
@ -137,11 +137,6 @@ public:
|
|||
/**
|
||||
* 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 type - Type of entry, root or alias.
|
||||
*
|
||||
|
@ -149,6 +144,52 @@ public:
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
@ -172,6 +213,16 @@ public:
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
|
|
@ -33,14 +33,14 @@ const wxChar* MsgPinElectricType[] =
|
|||
LibDrawPin::LibDrawPin(EDA_LibComponentStruct * aParent) :
|
||||
LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE, aParent )
|
||||
{
|
||||
m_PinLen = 300; /* default Pin len */
|
||||
m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */
|
||||
m_PinShape = NONE; /* Bit a bit: Pin shape (voir enum prec) */
|
||||
m_PinType = PIN_UNSPECIFIED; /* electrical type of pin */
|
||||
m_Attributs = 0; /* bit 0 != 0: pin invisible */
|
||||
m_PinNum = 0; /*pin number ( i.e. 4 codes ASCII ) */
|
||||
m_PinLen = 300; /* default Pin len */
|
||||
m_Orient = PIN_RIGHT; /* Pin oprient: Up, Down, Left, Right */
|
||||
m_PinShape = NONE; /* Bit a bit: Pin shape (voir enum prec) */
|
||||
m_PinType = PIN_UNSPECIFIED; /* electrical type of pin */
|
||||
m_Attributs = 0; /* bit 0 != 0: pin invisible */
|
||||
m_PinNum = 0; /* pin number ( i.e. 4 codes ASCII ) */
|
||||
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_typeName = _( "Pin" );
|
||||
m_PinNumShapeOpt = 0;
|
||||
|
@ -137,29 +137,46 @@ bool LibDrawPin::Save( FILE* ExportFile ) const
|
|||
StringPinNum = wxT( "~" );
|
||||
|
||||
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
|
||||
fprintf( ExportFile, "X ~" );
|
||||
{
|
||||
if( fprintf( ExportFile, "X ~" ) < 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
fprintf( ExportFile, " %s %d %d %d %c %d %d %d %d %c",
|
||||
CONV_TO_UTF8( StringPinNum ), m_Pos.x, m_Pos.y,
|
||||
(int) m_PinLen, (int) m_Orient, m_PinNumSize, m_PinNameSize,
|
||||
m_Unit, m_Convert, Etype );
|
||||
if( fprintf( ExportFile, " %s %d %d %d %c %d %d %d %d %c",
|
||||
CONV_TO_UTF8( StringPinNum ), m_Pos.x, m_Pos.y,
|
||||
(int) m_PinLen, (int) m_Orient, m_PinNumSize, m_PinNameSize,
|
||||
m_Unit, m_Convert, Etype ) < 0 )
|
||||
return false;
|
||||
|
||||
if( (m_PinShape) || (m_Attributs & PINNOTDRAW) )
|
||||
fprintf( ExportFile, " " );
|
||||
if( m_Attributs & PINNOTDRAW )
|
||||
fprintf( ExportFile, "N" );
|
||||
if( m_PinShape & INVERT )
|
||||
fprintf( ExportFile, "I" );
|
||||
if( m_PinShape & CLOCK )
|
||||
fprintf( ExportFile, "C" );
|
||||
if( m_PinShape & LOWLEVEL_IN )
|
||||
fprintf( ExportFile, "L" );
|
||||
if( m_PinShape & LOWLEVEL_OUT )
|
||||
fprintf( ExportFile, "V" );
|
||||
if( ( m_PinShape ) || ( m_Attributs & PINNOTDRAW ) )
|
||||
{
|
||||
if( fprintf( ExportFile, " " ) < 0 )
|
||||
return false;
|
||||
}
|
||||
if( m_Attributs & PINNOTDRAW
|
||||
&& fprintf( ExportFile, "N" ) < 0 )
|
||||
return false;
|
||||
if( m_PinShape & INVERT
|
||||
&& fprintf( ExportFile, "I" ) < 0 )
|
||||
return false;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1037,13 +1054,36 @@ LibEDA_BaseStruct* LibDrawPin::DoGenCopy()
|
|||
newpin->m_Convert = m_Convert;
|
||||
newpin->m_Flags = m_Flags;
|
||||
newpin->m_Width = m_Width;
|
||||
|
||||
newpin->m_PinName = m_PinName;
|
||||
newpin->m_PinName = m_PinName;
|
||||
|
||||
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
|
||||
* Displays info (pin num and name, orientation ...
|
||||
* on the Info window
|
||||
|
|
|
@ -70,6 +70,15 @@ void LibEDA_BaseStruct::DisplayInfo( WinEDA_DrawFrame* frame )
|
|||
}
|
||||
|
||||
|
||||
bool LibEDA_BaseStruct::operator==( const LibEDA_BaseStruct& other ) const
|
||||
{
|
||||
return ( ( Type() == other.Type() )
|
||||
&& ( m_Unit == other.m_Unit )
|
||||
&& ( m_Convert == other.m_Convert )
|
||||
&& DoCompare( other ) );
|
||||
}
|
||||
|
||||
|
||||
/**********************/
|
||||
/** class LibDrawArc **/
|
||||
/**********************/
|
||||
|
@ -77,8 +86,9 @@ void LibEDA_BaseStruct::DisplayInfo( WinEDA_DrawFrame* frame )
|
|||
LibDrawArc::LibDrawArc( EDA_LibComponentStruct* aParent ) :
|
||||
LibEDA_BaseStruct( COMPONENT_ARC_DRAW_TYPE, aParent )
|
||||
{
|
||||
m_Rayon = 0;
|
||||
t1 = t2 = 0;
|
||||
m_Radius = 0;
|
||||
m_t1 = 0;
|
||||
m_t2 = 0;
|
||||
m_Width = 0;
|
||||
m_Fill = NO_FILL;
|
||||
m_typeName = _( "Arc" );
|
||||
|
@ -92,20 +102,21 @@ LibDrawArc::LibDrawArc( EDA_LibComponentStruct* aParent ) :
|
|||
*/
|
||||
bool LibDrawArc::Save( FILE* ExportFile ) const
|
||||
{
|
||||
int x1 = t1;
|
||||
int x1 = m_t1;
|
||||
|
||||
if( x1 > 1800 )
|
||||
x1 -= 3600;
|
||||
|
||||
int x2 = t2;
|
||||
int x2 = m_t2;
|
||||
|
||||
if( x2 > 1800 )
|
||||
x2 -= 3600;
|
||||
|
||||
fprintf( ExportFile, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n",
|
||||
m_Pos.x, m_Pos.y, m_Rayon, x1, x2, m_Unit, m_Convert, m_Width,
|
||||
fill_tab[m_Fill], m_ArcStart.x, m_ArcStart.y, m_ArcEnd.x,
|
||||
m_ArcEnd.y );
|
||||
if( fprintf( ExportFile, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n",
|
||||
m_Pos.x, m_Pos.y, m_Radius, x1, x2, m_Unit, m_Convert, m_Width,
|
||||
fill_tab[m_Fill], m_ArcStart.x, m_ArcStart.y, m_ArcEnd.x,
|
||||
m_ArcEnd.y ) < 0 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -117,8 +128,8 @@ bool LibDrawArc::Load( char* line, wxString& errorMsg )
|
|||
char tmp[256];
|
||||
|
||||
cnt = sscanf( &line[2], "%d %d %d %d %d %d %d %d %s %d %d %d %d",
|
||||
&m_Pos.x, &m_Pos.y, &m_Rayon, &t1, &t2, &m_Unit, &m_Convert,
|
||||
&m_Width, tmp, &startx, &starty, &endx, &endy );
|
||||
&m_Pos.x, &m_Pos.y, &m_Radius, &m_t1, &m_t2, &m_Unit,
|
||||
&m_Convert, &m_Width, tmp, &startx, &starty, &endx, &endy );
|
||||
if( cnt < 8 )
|
||||
{
|
||||
errorMsg.Printf( _( "arc only had %d parameters of the required 8" ),
|
||||
|
@ -131,8 +142,8 @@ bool LibDrawArc::Load( char* line, wxString& errorMsg )
|
|||
if( tmp[0] == 'f' )
|
||||
m_Fill = FILLED_WITH_BG_BODYCOLOR;
|
||||
|
||||
NORMALIZE_ANGLE( t1 );
|
||||
NORMALIZE_ANGLE( t2 );
|
||||
NORMALIZE_ANGLE( m_t1 );
|
||||
NORMALIZE_ANGLE( m_t2 );
|
||||
|
||||
// Actual Coordinates of arc ends are read from file
|
||||
if( cnt >= 13 )
|
||||
|
@ -146,14 +157,14 @@ bool LibDrawArc::Load( char* line, wxString& errorMsg )
|
|||
{
|
||||
// Actual Coordinates of arc ends are not read from file
|
||||
// (old library), calculate them
|
||||
m_ArcStart.x = m_Rayon;
|
||||
m_ArcStart.x = m_Radius;
|
||||
m_ArcStart.y = 0;
|
||||
m_ArcEnd.x = m_Rayon;
|
||||
m_ArcEnd.x = m_Radius;
|
||||
m_ArcEnd.y = 0;
|
||||
RotatePoint( &m_ArcStart.x, &m_ArcStart.y, -t1 );
|
||||
RotatePoint( &m_ArcStart.x, &m_ArcStart.y, -m_t1 );
|
||||
m_ArcStart.x += m_Pos.x;
|
||||
m_ArcStart.y += m_Pos.y;
|
||||
RotatePoint( &m_ArcEnd.x, &m_ArcEnd.y, -t2 );
|
||||
RotatePoint( &m_ArcEnd.x, &m_ArcEnd.y, -m_t2 );
|
||||
m_ArcEnd.x += m_Pos.x;
|
||||
m_ArcEnd.y += m_Pos.y;
|
||||
}
|
||||
|
@ -199,13 +210,13 @@ bool LibDrawArc::HitTest( wxPoint aRefPoint, int aThreshold,
|
|||
int dist = wxRound( sqrt( ( (double) relpos.x * (double) relpos.x ) +
|
||||
( (double) relpos.y * (double) relpos.y ) ) );
|
||||
|
||||
if( abs( dist - m_Rayon ) > aThreshold )
|
||||
if( abs( dist - m_Radius ) > aThreshold )
|
||||
return false;
|
||||
|
||||
// We are on the circle, ensure we are only on the arc, i.e. between
|
||||
// m_ArcStart and m_ArcEnd
|
||||
int astart = t1; // arc starting point ( in 0.1 degree)
|
||||
int aend = t2; // arc ending point ( in 0.1 degree)
|
||||
int astart = m_t1; // arc starting point ( in 0.1 degree)
|
||||
int aend = m_t2; // arc ending point ( in 0.1 degree)
|
||||
int atest = wxRound( atan2( (double) relpos.y,
|
||||
(double) relpos.x ) * 1800.0 / M_PI );
|
||||
NORMALIZE_ANGLE_180( atest );
|
||||
|
@ -226,12 +237,12 @@ LibEDA_BaseStruct* LibDrawArc::DoGenCopy()
|
|||
{
|
||||
LibDrawArc* newitem = new LibDrawArc( GetParent() );
|
||||
|
||||
newitem->m_Pos = m_Pos;
|
||||
newitem->m_Pos = m_Pos;
|
||||
newitem->m_ArcStart = m_ArcStart;
|
||||
newitem->m_ArcEnd = m_ArcEnd;
|
||||
newitem->m_Rayon = m_Rayon;
|
||||
newitem->t1 = t1;
|
||||
newitem->t2 = t2;
|
||||
newitem->m_Radius = m_Radius;
|
||||
newitem->m_t1 = m_t1;
|
||||
newitem->m_t2 = m_t2;
|
||||
newitem->m_Width = m_Width;
|
||||
newitem->m_Unit = m_Unit;
|
||||
newitem->m_Convert = m_Convert;
|
||||
|
@ -242,6 +253,32 @@ LibEDA_BaseStruct* LibDrawArc::DoGenCopy()
|
|||
}
|
||||
|
||||
|
||||
bool LibDrawArc::DoCompare( const LibEDA_BaseStruct& other ) const
|
||||
{
|
||||
wxASSERT( other.Type() == COMPONENT_ARC_DRAW_TYPE );
|
||||
|
||||
const LibDrawArc* tmp = ( LibDrawArc* ) &other;
|
||||
|
||||
return ( ( m_Pos == tmp->m_Pos ) && ( m_t1 == tmp->m_t1 )
|
||||
&& ( m_t2 == tmp->m_t2 ) );
|
||||
}
|
||||
|
||||
|
||||
void LibDrawArc::DoOffset( const wxPoint& offset )
|
||||
{
|
||||
m_Pos += offset;
|
||||
m_ArcStart += offset;
|
||||
m_ArcEnd += offset;
|
||||
}
|
||||
|
||||
|
||||
bool LibDrawArc::DoTestInside( EDA_Rect& rect )
|
||||
{
|
||||
return rect.Inside( m_ArcStart.x, -m_ArcStart.y )
|
||||
|| rect.Inside( m_ArcEnd.x, -m_ArcEnd.y );
|
||||
}
|
||||
|
||||
|
||||
/** Function GetPenSize
|
||||
* @return the size of the "pen" that be used to draw or plot this item
|
||||
*/
|
||||
|
@ -271,8 +308,8 @@ void LibDrawArc::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
|
|||
pos1 = TransformCoordinate( aTransformMatrix, m_ArcEnd ) + aOffset;
|
||||
pos2 = TransformCoordinate( aTransformMatrix, m_ArcStart ) + aOffset;
|
||||
posc = TransformCoordinate( aTransformMatrix, m_Pos ) + aOffset;
|
||||
int pt1 = t1;
|
||||
int pt2 = t2;
|
||||
int pt1 = m_t1;
|
||||
int pt2 = m_t2;
|
||||
bool swap = MapAngles( &pt1, &pt2, aTransformMatrix );
|
||||
if( swap )
|
||||
{
|
||||
|
@ -288,17 +325,17 @@ void LibDrawArc::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
|
|||
|
||||
if( fill == FILLED_WITH_BG_BODYCOLOR )
|
||||
GRFilledArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2,
|
||||
m_Rayon, GetPenSize( ), color,
|
||||
m_Radius, GetPenSize( ), color,
|
||||
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
|
||||
else if( fill == FILLED_SHAPE && !aData )
|
||||
GRFilledArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2,
|
||||
m_Rayon, color, color );
|
||||
m_Radius, color, color );
|
||||
else
|
||||
{
|
||||
#ifdef DRAW_ARC_WITH_ANGLE
|
||||
|
||||
GRArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2,
|
||||
m_Rayon, GetPenSize( ), color );
|
||||
m_Radius, GetPenSize( ), color );
|
||||
#else
|
||||
|
||||
GRArc1( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
|
||||
|
@ -325,20 +362,20 @@ EDA_Rect LibDrawArc::GetBoundingBox()
|
|||
wxPoint normEnd = m_ArcEnd - m_Pos;
|
||||
|
||||
if( ( normStart == nullPoint ) || ( normEnd == nullPoint )
|
||||
|| ( m_Rayon == 0 ) )
|
||||
|| ( m_Radius == 0 ) )
|
||||
{
|
||||
wxLogDebug( wxT("Invalid arc drawing definition, center(%d, %d) \
|
||||
start(%d, %d), end(%d, %d), radius %d" ),
|
||||
m_Pos.x, m_Pos.y, m_ArcStart.x, m_ArcStart.y, m_ArcEnd.x,
|
||||
m_ArcEnd.y, m_Rayon );
|
||||
m_ArcEnd.y, m_Radius );
|
||||
return rect;
|
||||
}
|
||||
|
||||
endPos = TransformCoordinate( DefaultTransformMatrix, m_ArcEnd );
|
||||
startPos = TransformCoordinate( DefaultTransformMatrix, m_ArcStart );
|
||||
centerPos = TransformCoordinate( DefaultTransformMatrix, m_Pos );
|
||||
angleStart = t1;
|
||||
angleEnd = t2;
|
||||
angleStart = m_t1;
|
||||
angleEnd = m_t2;
|
||||
|
||||
if( MapAngles( &angleStart, &angleEnd, DefaultTransformMatrix ) )
|
||||
{
|
||||
|
@ -354,20 +391,20 @@ start(%d, %d), end(%d, %d), radius %d" ),
|
|||
|
||||
/* Zero degrees is a special case. */
|
||||
if( angleStart == 0 )
|
||||
maxX = centerPos.x + m_Rayon;
|
||||
maxX = centerPos.x + m_Radius;
|
||||
|
||||
/* Arc end angle wrapped passed 360. */
|
||||
if( angleStart > angleEnd )
|
||||
angleEnd += 3600;
|
||||
|
||||
if( angleStart <= 900 && angleEnd >= 900 ) /* 90 deg */
|
||||
maxY = centerPos.y + m_Rayon;
|
||||
maxY = centerPos.y + m_Radius;
|
||||
if( angleStart <= 1800 && angleEnd >= 1800 ) /* 180 deg */
|
||||
minX = centerPos.x - m_Rayon;
|
||||
minX = centerPos.x - m_Radius;
|
||||
if( angleStart <= 2700 && angleEnd >= 2700 ) /* 270 deg */
|
||||
minY = centerPos.y - m_Rayon;
|
||||
minY = centerPos.y - m_Radius;
|
||||
if( angleStart <= 3600 && angleEnd >= 3600 ) /* 0 deg */
|
||||
maxX = centerPos.x + m_Rayon;
|
||||
maxX = centerPos.x + m_Radius;
|
||||
|
||||
rect.SetOrigin( minX, minY );
|
||||
rect.SetEnd( maxX, maxY );
|
||||
|
@ -403,7 +440,7 @@ void LibDrawArc::DisplayInfo( WinEDA_DrawFrame* frame )
|
|||
LibDrawCircle::LibDrawCircle( EDA_LibComponentStruct* aParent ) :
|
||||
LibEDA_BaseStruct( COMPONENT_CIRCLE_DRAW_TYPE, aParent )
|
||||
{
|
||||
m_Rayon = 0;
|
||||
m_Radius = 0;
|
||||
m_Fill = NO_FILL;
|
||||
m_typeName = _( "Circle" );
|
||||
}
|
||||
|
@ -411,8 +448,9 @@ LibDrawCircle::LibDrawCircle( EDA_LibComponentStruct* aParent ) :
|
|||
|
||||
bool LibDrawCircle::Save( FILE* ExportFile ) const
|
||||
{
|
||||
fprintf( ExportFile, "C %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y,
|
||||
m_Rayon, m_Unit, m_Convert, m_Width, fill_tab[m_Fill] );
|
||||
if( fprintf( ExportFile, "C %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y,
|
||||
m_Radius, m_Unit, m_Convert, m_Width, fill_tab[m_Fill] ) < 0 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -423,7 +461,7 @@ bool LibDrawCircle::Load( char* line, wxString& errorMsg )
|
|||
char tmp[256];
|
||||
|
||||
int cnt = sscanf( &line[2], "%d %d %d %d %d %d %s", &m_Pos.x, &m_Pos.y,
|
||||
&m_Rayon, &m_Unit, &m_Convert, &m_Width, tmp );
|
||||
&m_Radius, &m_Unit, &m_Convert, &m_Width, tmp );
|
||||
|
||||
if( cnt < 6 )
|
||||
{
|
||||
|
@ -462,10 +500,12 @@ bool LibDrawCircle::HitTest( const wxPoint& aPosRef )
|
|||
/** Function HitTest
|
||||
* @return true if the point aPosRef is near this object
|
||||
* @param aPosRef = a wxPoint to test
|
||||
* @param aThreshold = max distance to this object (usually the half thickness of a line)
|
||||
* @param aThreshold = max distance to this object (usually the half
|
||||
* thickness of a line)
|
||||
* @param aTransMat = the transform matrix
|
||||
*/
|
||||
bool LibDrawCircle::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] )
|
||||
bool LibDrawCircle::HitTest( wxPoint aPosRef, int aThreshold,
|
||||
const int aTransMat[2][2] )
|
||||
{
|
||||
wxPoint relpos = aPosRef - TransformCoordinate( aTransMat, m_Pos );
|
||||
|
||||
|
@ -473,7 +513,7 @@ bool LibDrawCircle::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMa
|
|||
wxRound( sqrt( ( (double) relpos.x * relpos.x ) +
|
||||
( (double) relpos.y * relpos.y ) ) );
|
||||
|
||||
if( abs( dist - m_Rayon ) <= aThreshold )
|
||||
if( abs( dist - m_Radius ) <= aThreshold )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -484,7 +524,7 @@ LibEDA_BaseStruct* LibDrawCircle::DoGenCopy()
|
|||
LibDrawCircle* newitem = new LibDrawCircle( GetParent() );
|
||||
|
||||
newitem->m_Pos = m_Pos;
|
||||
newitem->m_Rayon = m_Rayon;
|
||||
newitem->m_Radius = m_Radius;
|
||||
newitem->m_Width = m_Width;
|
||||
newitem->m_Unit = m_Unit;
|
||||
newitem->m_Convert = m_Convert;
|
||||
|
@ -495,6 +535,32 @@ LibEDA_BaseStruct* LibDrawCircle::DoGenCopy()
|
|||
}
|
||||
|
||||
|
||||
bool LibDrawCircle::DoCompare( const LibEDA_BaseStruct& other ) const
|
||||
{
|
||||
wxASSERT( other.Type() == COMPONENT_CIRCLE_DRAW_TYPE );
|
||||
|
||||
const LibDrawCircle* tmp = ( LibDrawCircle* ) &other;
|
||||
|
||||
return ( ( m_Pos == tmp->m_Pos ) && ( m_Radius == tmp->m_Radius ) );
|
||||
}
|
||||
|
||||
|
||||
void LibDrawCircle::DoOffset( const wxPoint& offset )
|
||||
{
|
||||
m_Pos += offset;
|
||||
}
|
||||
|
||||
|
||||
bool LibDrawCircle::DoTestInside( EDA_Rect& rect )
|
||||
{
|
||||
/*
|
||||
* FIXME: This fails to take into acount the radius around the center
|
||||
* point.
|
||||
*/
|
||||
return rect.Inside( m_Pos.x, -m_Pos.y );
|
||||
}
|
||||
|
||||
|
||||
/** Function GetPenSize
|
||||
* @return the size of the "pen" that be used to draw or plot this item
|
||||
*/
|
||||
|
@ -529,14 +595,14 @@ void LibDrawCircle::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
|
|||
|
||||
if( fill == FILLED_WITH_BG_BODYCOLOR )
|
||||
GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y,
|
||||
m_Rayon, GetPenSize( ), color,
|
||||
m_Radius, GetPenSize( ), color,
|
||||
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
|
||||
else if( fill == FILLED_SHAPE )
|
||||
GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y,
|
||||
m_Rayon, 0, color, color );
|
||||
m_Radius, 0, color, color );
|
||||
else
|
||||
GRCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y,
|
||||
m_Rayon, GetPenSize( ), color );
|
||||
m_Radius, GetPenSize( ), color );
|
||||
}
|
||||
|
||||
|
||||
|
@ -544,8 +610,8 @@ EDA_Rect LibDrawCircle::GetBoundingBox()
|
|||
{
|
||||
EDA_Rect rect;
|
||||
|
||||
rect.SetOrigin( m_Pos.x - m_Rayon, ( m_Pos.y - m_Rayon ) * -1 );
|
||||
rect.SetEnd( m_Pos.x + m_Rayon, ( m_Pos.y + m_Rayon ) * -1 );
|
||||
rect.SetOrigin( m_Pos.x - m_Radius, ( m_Pos.y - m_Radius ) * -1 );
|
||||
rect.SetEnd( m_Pos.x + m_Radius, ( m_Pos.y + m_Radius ) * -1 );
|
||||
rect.Inflate( m_Width / 2, m_Width / 2 );
|
||||
|
||||
return rect;
|
||||
|
@ -564,7 +630,7 @@ void LibDrawCircle::DisplayInfo( WinEDA_DrawFrame* frame )
|
|||
|
||||
frame->MsgPanel->Affiche_1_Parametre( 20, _( "Line width" ), msg, BLUE );
|
||||
|
||||
msg = ReturnStringFromValue( g_UnitMetric, m_Rayon,
|
||||
msg = ReturnStringFromValue( g_UnitMetric, m_Radius,
|
||||
EESCHEMA_INTERNAL_UNIT, true );
|
||||
frame->MsgPanel->Affiche_1_Parametre( 40, _( "Radius" ), msg, RED );
|
||||
|
||||
|
@ -590,8 +656,10 @@ LibDrawSquare::LibDrawSquare( EDA_LibComponentStruct* aParent ) :
|
|||
|
||||
bool LibDrawSquare::Save( FILE* ExportFile ) const
|
||||
{
|
||||
fprintf( ExportFile, "S %d %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y,
|
||||
m_End.x, m_End.y, m_Unit, m_Convert, m_Width, fill_tab[m_Fill] );
|
||||
if( fprintf( ExportFile, "S %d %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y,
|
||||
m_End.x, m_End.y, m_Unit, m_Convert, m_Width,
|
||||
fill_tab[m_Fill] ) < 0 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -637,6 +705,29 @@ LibEDA_BaseStruct* LibDrawSquare::DoGenCopy()
|
|||
}
|
||||
|
||||
|
||||
bool LibDrawSquare::DoCompare( const LibEDA_BaseStruct& other ) const
|
||||
{
|
||||
wxASSERT( other.Type() == COMPONENT_RECT_DRAW_TYPE );
|
||||
|
||||
const LibDrawSquare* tmp = ( LibDrawSquare* ) &other;
|
||||
|
||||
return ( ( m_Pos == tmp->m_Pos ) && ( m_End == tmp->m_End ) );
|
||||
}
|
||||
|
||||
|
||||
void LibDrawSquare::DoOffset( const wxPoint& offset )
|
||||
{
|
||||
m_Pos += offset;
|
||||
m_End += offset;
|
||||
}
|
||||
|
||||
|
||||
bool LibDrawSquare::DoTestInside( EDA_Rect& rect )
|
||||
{
|
||||
return rect.Inside( m_Pos.x, -m_Pos.y ) || rect.Inside( m_End.x, -m_End.y );
|
||||
}
|
||||
|
||||
|
||||
/** Function GetPenSize
|
||||
* @return the size of the "pen" that be used to draw or plot this item
|
||||
*/
|
||||
|
@ -782,7 +873,8 @@ LibDrawSegment::LibDrawSegment( EDA_LibComponentStruct* aParent ) :
|
|||
|
||||
bool LibDrawSegment::Save( FILE* ExportFile ) const
|
||||
{
|
||||
fprintf( ExportFile, "L %d %d %d", m_Unit, m_Convert, m_Width );
|
||||
if( fprintf( ExportFile, "L %d %d %d", m_Unit, m_Convert, m_Width ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -809,6 +901,29 @@ LibEDA_BaseStruct* LibDrawSegment::DoGenCopy()
|
|||
}
|
||||
|
||||
|
||||
bool LibDrawSegment::DoCompare( const LibEDA_BaseStruct& other ) const
|
||||
{
|
||||
wxASSERT( other.Type() == COMPONENT_LINE_DRAW_TYPE );
|
||||
|
||||
const LibDrawSegment* tmp = ( LibDrawSegment* ) &other;
|
||||
|
||||
return ( ( m_Pos == tmp->m_Pos ) && ( m_End == tmp->m_End ) );
|
||||
}
|
||||
|
||||
|
||||
void LibDrawSegment::DoOffset( const wxPoint& offset )
|
||||
{
|
||||
m_Pos += offset;
|
||||
m_End += offset;
|
||||
}
|
||||
|
||||
|
||||
bool LibDrawSegment::DoTestInside( EDA_Rect& rect )
|
||||
{
|
||||
return rect.Inside( m_Pos.x, -m_Pos.y ) || rect.Inside( m_End.x, -m_End.y );
|
||||
}
|
||||
|
||||
|
||||
/** Function GetPenSize
|
||||
* @return the size of the "pen" that be used to draw or plot this item
|
||||
*/
|
||||
|
@ -913,14 +1028,19 @@ bool LibDrawPolyline::Save( FILE* ExportFile ) const
|
|||
{
|
||||
int ccount = GetCornerCount();
|
||||
|
||||
fprintf( ExportFile, "P %d %d %d %d", ccount, m_Unit, m_Convert, m_Width );
|
||||
if( fprintf( ExportFile, "P %d %d %d %d",
|
||||
ccount, m_Unit, m_Convert, m_Width ) < 0 )
|
||||
return false;
|
||||
|
||||
for( unsigned i = 0; i < GetCornerCount(); i++ )
|
||||
{
|
||||
fprintf( ExportFile, " %d %d", m_PolyPoints[i].x, m_PolyPoints[i].y );
|
||||
if( fprintf( ExportFile, " %d %d",
|
||||
m_PolyPoints[i].x, m_PolyPoints[i].y ) < 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
fprintf( ExportFile, " %c\n", fill_tab[m_Fill] );
|
||||
if( fprintf( ExportFile, " %c\n", fill_tab[m_Fill] ) < 0 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1001,6 +1121,43 @@ LibEDA_BaseStruct* LibDrawPolyline::DoGenCopy()
|
|||
}
|
||||
|
||||
|
||||
bool LibDrawPolyline::DoCompare( const LibEDA_BaseStruct& other ) const
|
||||
{
|
||||
wxASSERT( other.Type() == COMPONENT_POLYLINE_DRAW_TYPE );
|
||||
|
||||
const LibDrawPolyline* tmp = ( LibDrawPolyline* ) &other;
|
||||
|
||||
if( m_PolyPoints.size() != tmp->m_PolyPoints.size() )
|
||||
return false;
|
||||
|
||||
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
|
||||
{
|
||||
if( m_PolyPoints[i] != tmp->m_PolyPoints[i] )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void LibDrawPolyline::DoOffset( const wxPoint& offset )
|
||||
{
|
||||
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
|
||||
m_PolyPoints[i] += offset;
|
||||
}
|
||||
|
||||
|
||||
bool LibDrawPolyline::DoTestInside( EDA_Rect& rect )
|
||||
{
|
||||
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
|
||||
{
|
||||
if( rect.Inside( m_PolyPoints[i].x, -m_PolyPoints[i].y ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void LibDrawPolyline::AddPoint( const wxPoint& point )
|
||||
{
|
||||
m_PolyPoints.push_back( point );
|
||||
|
@ -1176,15 +1333,19 @@ bool LibDrawBezier::Save( FILE* ExportFile ) const
|
|||
{
|
||||
int ccount = GetCornerCount();
|
||||
|
||||
fprintf( ExportFile, "B %d %d %d %d", ccount, m_Unit, m_Convert, m_Width );
|
||||
if( fprintf( ExportFile, "B %d %d %d %d",
|
||||
ccount, m_Unit, m_Convert, m_Width ) < 0 )
|
||||
return false;
|
||||
|
||||
for( unsigned i = 0; i < GetCornerCount(); i++ )
|
||||
{
|
||||
fprintf( ExportFile, " %d %d", m_BezierPoints[i].x,
|
||||
m_BezierPoints[i].y );
|
||||
if( fprintf( ExportFile, " %d %d", m_BezierPoints[i].x,
|
||||
m_BezierPoints[i].y ) < 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
fprintf( ExportFile, " %c\n", fill_tab[m_Fill] );
|
||||
if( fprintf( ExportFile, " %c\n", fill_tab[m_Fill] ) < 0 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1262,6 +1423,50 @@ LibEDA_BaseStruct* LibDrawBezier::DoGenCopy()
|
|||
return (LibEDA_BaseStruct*) newitem;
|
||||
}
|
||||
|
||||
|
||||
bool LibDrawBezier::DoCompare( const LibEDA_BaseStruct& other ) const
|
||||
{
|
||||
wxASSERT( other.Type() == COMPONENT_BEZIER_DRAW_TYPE );
|
||||
|
||||
const LibDrawBezier* tmp = ( LibDrawBezier* ) &other;
|
||||
|
||||
if( m_BezierPoints.size() != tmp->m_BezierPoints.size() )
|
||||
return false;
|
||||
|
||||
for( size_t i = 0; i < m_BezierPoints.size(); i++ )
|
||||
{
|
||||
if( m_BezierPoints[i] != tmp->m_BezierPoints[i] )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void LibDrawBezier::DoOffset( const wxPoint& offset )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for( i = 0; i < m_BezierPoints.size(); i++ )
|
||||
m_BezierPoints[i] += offset;
|
||||
|
||||
for( i = 0; i < m_PolyPoints.size(); i++ )
|
||||
m_PolyPoints[i] += offset;
|
||||
}
|
||||
|
||||
|
||||
bool LibDrawBezier::DoTestInside( EDA_Rect& rect )
|
||||
{
|
||||
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
|
||||
{
|
||||
if( rect.Inside( m_PolyPoints[i].x, -m_PolyPoints[i].y ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** Function GetPenSize
|
||||
* @return the size of the "pen" that be used to draw or plot this item
|
||||
*/
|
||||
|
|
|
@ -154,7 +154,7 @@ public:
|
|||
* @param refPos A wxPoint to test
|
||||
* @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
|
||||
}
|
||||
|
@ -189,8 +189,49 @@ public:
|
|||
*/
|
||||
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:
|
||||
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:
|
|||
|
||||
protected:
|
||||
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:
|
|||
class LibDrawArc : public LibEDA_BaseStruct
|
||||
{
|
||||
public:
|
||||
int m_Rayon;
|
||||
int t1, t2; /* position des 2 extremites de l'arc en 0.1 degres */
|
||||
int m_Radius;
|
||||
int m_t1;
|
||||
int m_t2; /* position des 2 extremites de l'arc en 0.1 degres */
|
||||
wxPoint m_ArcStart;
|
||||
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
|
||||
|
@ -386,6 +431,9 @@ public:
|
|||
|
||||
protected:
|
||||
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:
|
|||
class LibDrawCircle : public LibEDA_BaseStruct
|
||||
{
|
||||
public:
|
||||
int m_Rayon;
|
||||
int m_Radius;
|
||||
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start
|
||||
* point (segments) */
|
||||
int m_Width; /* Line width */
|
||||
|
@ -451,6 +499,9 @@ public:
|
|||
|
||||
protected:
|
||||
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:
|
|||
|
||||
protected:
|
||||
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:
|
|||
|
||||
protected:
|
||||
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:
|
|||
|
||||
protected:
|
||||
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:
|
|||
|
||||
protected:
|
||||
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:
|
|||
|
||||
protected:
|
||||
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
|
||||
|
|
|
@ -397,7 +397,6 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe
|
|||
}
|
||||
|
||||
UpdateStatusBar(); /* Affichage des coord curseur */
|
||||
SetToolbars();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "protos.h"
|
||||
|
||||
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_RecreateToolbar = false;
|
||||
|
@ -44,27 +44,26 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::Init( )
|
|||
{
|
||||
SetFocus();
|
||||
m_AliasLocation = -1;
|
||||
|
||||
if( CurrentLibEntry == NULL )
|
||||
{
|
||||
SetTitle( _( "Lib Component Properties" ) );
|
||||
SetTitle( _( "Library Component Properties" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
wxString title = _( "Properties for " );
|
||||
|
||||
if( !CurrentAliasName.IsEmpty() )
|
||||
{
|
||||
m_AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList, CurrentAliasName );
|
||||
title += CurrentAliasName +
|
||||
_( "(alias of " ) +
|
||||
wxString( CurrentLibEntry->m_Name.m_Text )
|
||||
+ wxT( ")" );
|
||||
title += CurrentAliasName + _( " (alias of " ) +
|
||||
wxString( CurrentLibEntry->m_Name.m_Text )+ wxT( ")" );
|
||||
}
|
||||
else
|
||||
{
|
||||
title += CurrentLibEntry->m_Name.m_Text;
|
||||
CurrentAliasName.Empty();
|
||||
}
|
||||
|
||||
|
||||
SetTitle( title );
|
||||
|
||||
InitPanelDoc();
|
||||
|
@ -76,34 +75,33 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::Init( )
|
|||
/* Place list of alias names in listbox */
|
||||
if( CurrentLibEntry )
|
||||
{
|
||||
for( unsigned ii = 0; ii < CurrentLibEntry->m_AliasList.GetCount(); ii += ALIAS_NEXT )
|
||||
m_PartAliasList->Append( CurrentLibEntry->m_AliasList[ii + ALIAS_NAME] );
|
||||
m_PartAliasList->Append( CurrentLibEntry->m_AliasList );
|
||||
}
|
||||
|
||||
if( (CurrentLibEntry == NULL) || (CurrentLibEntry->m_AliasList.GetCount() == 0) )
|
||||
if( ( CurrentLibEntry == NULL )
|
||||
|| ( CurrentLibEntry->m_AliasList.GetCount() == 0 ) )
|
||||
{
|
||||
m_ButtonDeleteAllAlias->Enable( false );
|
||||
m_ButtonDeleteOneAlias->Enable( false );
|
||||
}
|
||||
|
||||
|
||||
/* Read the Footprint Filter list */
|
||||
if( CurrentLibEntry )
|
||||
{
|
||||
for( unsigned ii = 0; ii < CurrentLibEntry->m_FootprintList.GetCount(); ii++ )
|
||||
m_FootprintFilterListBox->Append( CurrentLibEntry->m_FootprintList[ii] );
|
||||
m_FootprintFilterListBox->Append( CurrentLibEntry->m_FootprintList );
|
||||
}
|
||||
|
||||
if( (CurrentLibEntry == NULL) || (CurrentLibEntry->m_FootprintList.GetCount() == 0) )
|
||||
if( ( CurrentLibEntry == NULL )
|
||||
|| ( CurrentLibEntry->m_FootprintList.GetCount() == 0 ) )
|
||||
{
|
||||
m_ButtonDeleteAllFootprintFilter->Enable( false );
|
||||
m_ButtonDeleteOneFootprintFilter->Enable( false );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
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
|
|||
/* A new name could be entered in VALUE field.
|
||||
* Must not be an existing alias name in alias list box */
|
||||
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( *libname ) == 0 )
|
||||
if( newvalue->CmpNoCase( m_LibEntry->m_AliasList[i] ) == 0 )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf(
|
||||
_(
|
||||
"A new name is entered for this component\nAn alias %s already exists!\nCannot update this component" ),
|
||||
newvalue->GetData() );
|
||||
msg.Printf( _( "A new name is entered for this component\nAn \
|
||||
alias %s already exists!\nCannot update this component" ),
|
||||
newvalue->GetData() );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
@ -236,7 +234,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event
|
|||
m_Parent->SaveCopyInUndoList( m_LibEntry, IS_CHANGED );
|
||||
|
||||
// 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() )
|
||||
{
|
||||
|
|
|
@ -30,70 +30,59 @@ extern int CurrentUnit;
|
|||
#include "dialog_edit_component_in_lib.h"
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
void WinEDA_LibeditFrame::InstallLibeditFrame( void )
|
||||
/*****************************************************************/
|
||||
void WinEDA_LibeditFrame::OnEditComponentProperties( wxCommandEvent& event )
|
||||
{
|
||||
DIALOG_EDIT_COMPONENT_IN_LIBRARY* frame =
|
||||
new DIALOG_EDIT_COMPONENT_IN_LIBRARY( this );
|
||||
EditComponentProperties();
|
||||
}
|
||||
|
||||
int IsModified = frame->ShowModal(); frame->Destroy();
|
||||
|
||||
if( IsModified )
|
||||
Refresh();
|
||||
void WinEDA_LibeditFrame::EditComponentProperties()
|
||||
{
|
||||
wxASSERT( CurrentLibEntry != NULL && CurrentLib != NULL );
|
||||
|
||||
DIALOG_EDIT_COMPONENT_IN_LIBRARY dlg( this );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return;
|
||||
|
||||
UpdateAliasSelectList();
|
||||
UpdatePartSelectList();
|
||||
DisplayLibInfos();
|
||||
GetScreen()->SetModify();
|
||||
SaveCopyInUndoList( CurrentLibEntry );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************/
|
||||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
|
||||
/*****************************************************/
|
||||
|
||||
/* create the panel for component doc editing
|
||||
*/
|
||||
{
|
||||
wxString msg_text;
|
||||
LibCmpEntry* entry;
|
||||
|
||||
if( m_AliasLocation >= 0 )
|
||||
msg_text = CurrentLibEntry->m_AliasList[m_AliasLocation + ALIAS_DOC];
|
||||
if( CurrentLibEntry == NULL )
|
||||
return;
|
||||
|
||||
if( CurrentAliasName.IsEmpty() )
|
||||
{
|
||||
entry = CurrentLibEntry;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( CurrentLibEntry )
|
||||
msg_text = CurrentLibEntry->m_Doc;
|
||||
}
|
||||
m_Doc->SetValue( msg_text );
|
||||
entry = ( LibCmpEntry* ) CurrentLib->FindAlias( CurrentAliasName );
|
||||
|
||||
msg_text.Empty();
|
||||
if( m_AliasLocation >= 0 )
|
||||
msg_text = CurrentLibEntry->m_AliasList[m_AliasLocation + ALIAS_KEYWORD];
|
||||
else
|
||||
{
|
||||
if( CurrentLibEntry )
|
||||
msg_text = CurrentLibEntry->m_KeyWord;
|
||||
if( entry == NULL )
|
||||
return;
|
||||
}
|
||||
m_Keywords->SetValue( msg_text );
|
||||
|
||||
msg_text.Empty();
|
||||
if( m_AliasLocation >= 0 )
|
||||
msg_text = CurrentLibEntry->m_AliasList[m_AliasLocation + ALIAS_DOC_FILENAME];
|
||||
else
|
||||
{
|
||||
if( CurrentLibEntry )
|
||||
msg_text = CurrentLibEntry->m_DocFile;
|
||||
}
|
||||
m_Docfile->SetValue( msg_text );
|
||||
|
||||
if( m_AliasLocation < 0 )
|
||||
m_ButtonCopyDoc->Enable( FALSE );
|
||||
m_Doc->SetValue( entry->m_Doc );
|
||||
m_Keywords->SetValue( entry->m_KeyWord );
|
||||
m_Docfile->SetValue( entry->m_DocFile );
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************/
|
||||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
|
||||
/*****************************************************/
|
||||
|
||||
/* create the basic panel for component properties editing
|
||||
/*
|
||||
* create the basic panel for component properties editing
|
||||
*/
|
||||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
|
||||
{
|
||||
if( g_AsDeMorgan )
|
||||
m_AsConvertButt->SetValue( TRUE );
|
||||
|
@ -135,101 +124,96 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
|
|||
number = 40;
|
||||
m_SetSkew->SetValue( number );
|
||||
|
||||
if( CurrentLibEntry )
|
||||
{
|
||||
if( CurrentLibEntry->m_Options == ENTRY_POWER )
|
||||
m_OptionPower->SetValue( TRUE );
|
||||
}
|
||||
if( CurrentLibEntry && CurrentLibEntry->m_Options == ENTRY_POWER )
|
||||
m_OptionPower->SetValue( TRUE );
|
||||
|
||||
if( CurrentLibEntry )
|
||||
{
|
||||
if( CurrentLibEntry->m_UnitSelectionLocked )
|
||||
m_OptionPartsLocked->SetValue( TRUE );
|
||||
}
|
||||
if( CurrentLibEntry && CurrentLibEntry->m_UnitSelectionLocked )
|
||||
m_OptionPartsLocked->SetValue( TRUE );
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
|
||||
/**************************************************************************/
|
||||
|
||||
/* Updaye the current component parameters
|
||||
*/
|
||||
{
|
||||
int ii, jj;
|
||||
|
||||
if( CurrentLibEntry == NULL )
|
||||
{
|
||||
Close(); return;
|
||||
}
|
||||
|
||||
m_Parent->GetScreen()->SetModify();
|
||||
m_Parent->SaveCopyInUndoList( CurrentLibEntry );
|
||||
|
||||
/* Update the doc, keyword and doc filename strings */
|
||||
if( m_AliasLocation < 0 )
|
||||
size_t i;
|
||||
int index;
|
||||
LibCmpEntry* entry;
|
||||
|
||||
if( CurrentAliasName.IsEmpty() )
|
||||
{
|
||||
CurrentLibEntry->m_Doc = m_Doc->GetValue();
|
||||
CurrentLibEntry->m_KeyWord = m_Keywords->GetValue();
|
||||
CurrentLibEntry->m_DocFile = m_Docfile->GetValue();
|
||||
entry = CurrentLibEntry;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentLibEntry->m_AliasList[m_AliasLocation + ALIAS_DOC] = m_Doc->GetValue();
|
||||
CurrentLibEntry->m_AliasList[m_AliasLocation + ALIAS_KEYWORD] = m_Keywords->GetValue();
|
||||
CurrentLibEntry->m_AliasList[m_AliasLocation + ALIAS_DOC_FILENAME] = m_Docfile->GetValue();
|
||||
entry = CurrentLib->FindEntry( CurrentAliasName );
|
||||
}
|
||||
|
||||
/* Update the alias list */
|
||||
/* 1 - Add names: test for a not existing name in old alias list: */
|
||||
jj = m_PartAliasList->GetCount();
|
||||
for( ii = 0; ii < jj; ii++ )
|
||||
if( entry == NULL )
|
||||
{
|
||||
if( LocateAlias( CurrentLibEntry->m_AliasList, m_PartAliasList->GetString( ii ) ) < 0 )
|
||||
{
|
||||
// new alias must be created
|
||||
CurrentLibEntry->m_AliasList.Add( m_PartAliasList->GetString( ii ) );
|
||||
CurrentLibEntry->m_AliasList.Add( wxEmptyString ); // Add a void doc string
|
||||
CurrentLibEntry->m_AliasList.Add( wxEmptyString ); // Add a void keyword list string
|
||||
CurrentLibEntry->m_AliasList.Add( wxEmptyString ); // Add a void doc filename string
|
||||
}
|
||||
wxString msg;
|
||||
msg.Printf( _( "Alias <%s> not found for component <%s> in library <%s>." ),
|
||||
(const wxChar*) CurrentAliasName,
|
||||
(const wxChar*) CurrentLibEntry->GetName(),
|
||||
(const wxChar*) CurrentLib->m_Name );
|
||||
wxMessageBox( msg, _( "Component Library Error" ),
|
||||
wxID_OK | wxICON_ERROR, this );
|
||||
}
|
||||
else
|
||||
{
|
||||
entry->m_Doc = m_Doc->GetValue();
|
||||
entry->m_KeyWord = m_Keywords->GetValue();
|
||||
entry->m_DocFile = m_Docfile->GetValue();
|
||||
}
|
||||
|
||||
/* 2 - Remove delete names: test for an non existing name in new alias list: */
|
||||
int kk, kkmax = CurrentLibEntry->m_AliasList.GetCount();
|
||||
for( kk = 0; kk < kkmax; )
|
||||
if( m_PartAliasList->GetStrings() != CurrentLibEntry->m_AliasList )
|
||||
{
|
||||
jj = m_PartAliasList->GetCount();
|
||||
wxString aliasname = CurrentLibEntry->m_AliasList[kk];
|
||||
for( ii = 0; ii < jj; ii++ )
|
||||
EDA_LibCmpAliasStruct* alias;
|
||||
wxArrayString aliases = m_PartAliasList->GetStrings();
|
||||
|
||||
/* Add names not existing in the old alias list. */
|
||||
for( i = 0; i < aliases.GetCount(); i++ )
|
||||
{
|
||||
if( aliasname.CmpNoCase( m_PartAliasList->GetString( ii ).GetData() ) == 0 )
|
||||
index = CurrentLibEntry->m_AliasList.Index( aliases[ i ], false );
|
||||
|
||||
if( index != wxNOT_FOUND )
|
||||
continue;
|
||||
|
||||
alias = new EDA_LibCmpAliasStruct( aliases[ i ],
|
||||
CurrentLibEntry->GetName() );
|
||||
if( !CurrentLib->AddAlias( alias ) )
|
||||
{
|
||||
kk += ALIAS_NEXT; // Alias exist in new list. keep it and test next old name
|
||||
break;
|
||||
delete alias;
|
||||
alias = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if( ii == jj ) // Alias not found in new list, remove it (4 strings in kk position)
|
||||
/* Remove names and library alias entries not in the new alias list. */
|
||||
for( i = 0; CurrentLibEntry->m_AliasList.GetCount(); i++ )
|
||||
{
|
||||
for( ii = 0; ii < ALIAS_NEXT; ii++ )
|
||||
CurrentLibEntry->m_AliasList.RemoveAt( kk );
|
||||
index = aliases.Index( CurrentLibEntry->m_AliasList[ i ], false );
|
||||
|
||||
kkmax = CurrentLibEntry->m_AliasList.GetCount();
|
||||
if( index == wxNOT_FOUND )
|
||||
continue;
|
||||
|
||||
LibCmpEntry* alias =
|
||||
CurrentLib->FindAlias( CurrentLibEntry->m_AliasList[ i ] );
|
||||
if( alias != NULL )
|
||||
CurrentLib->RemoveEntry( alias );
|
||||
}
|
||||
|
||||
CurrentLibEntry->m_AliasList = aliases;
|
||||
}
|
||||
|
||||
ii = m_SelNumberOfUnits->GetValue();
|
||||
if( ChangeNbUnitsPerPackage( ii ) )
|
||||
m_RecreateToolbar = TRUE;
|
||||
index = m_SelNumberOfUnits->GetValue();
|
||||
ChangeNbUnitsPerPackage( index );
|
||||
|
||||
if( m_AsConvertButt->GetValue() )
|
||||
{
|
||||
if( !g_AsDeMorgan )
|
||||
{
|
||||
g_AsDeMorgan = 1;
|
||||
if( SetUnsetConvert() )
|
||||
m_RecreateToolbar = TRUE;
|
||||
SetUnsetConvert();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -237,8 +221,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
|
|||
if( g_AsDeMorgan )
|
||||
{
|
||||
g_AsDeMorgan = 0;
|
||||
if( SetUnsetConvert() )
|
||||
m_RecreateToolbar = TRUE;
|
||||
SetUnsetConvert();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,18 +244,11 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
|
|||
if( CurrentLibEntry->m_UnitCount <= 1 )
|
||||
CurrentLibEntry->m_UnitSelectionLocked = FALSE;
|
||||
|
||||
if( m_RecreateToolbar )
|
||||
m_Parent->ReCreateHToolbar();
|
||||
|
||||
m_Parent->DisplayLibInfos();
|
||||
|
||||
/* Update the footprint filter list */
|
||||
CurrentLibEntry->m_FootprintList.Clear();
|
||||
jj = m_FootprintFilterListBox->GetCount();
|
||||
for( ii = 0; ii < jj; ii++ )
|
||||
CurrentLibEntry->m_FootprintList.Add( m_FootprintFilterListBox->GetString( ii ) );
|
||||
CurrentLibEntry->m_FootprintList = m_FootprintFilterListBox->GetStrings();
|
||||
|
||||
EndModal( 1 );
|
||||
EndModal( wxID_OK );
|
||||
}
|
||||
|
||||
|
||||
|
@ -280,9 +256,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
|
|||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED (event) )
|
||||
/******************************************************************************/
|
||||
{
|
||||
if( CurrentLibEntry == NULL )
|
||||
return;
|
||||
if( CurrentAliasName.IsEmpty() )
|
||||
if( CurrentLibEntry == NULL || CurrentAliasName.IsEmpty() )
|
||||
return;
|
||||
|
||||
m_Doc->SetValue( CurrentLibEntry->m_Doc );
|
||||
|
@ -296,16 +270,23 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart(
|
|||
wxCommandEvent& WXUNUSED (event) )
|
||||
/**********************************************************/
|
||||
{
|
||||
CurrentAliasName.Empty();
|
||||
if( CurrentLibEntry )
|
||||
if( m_PartAliasList->FindString( CurrentAliasName ) != wxNOT_FOUND )
|
||||
{
|
||||
if( IsOK( this, _( "Ok to Delete Alias LIST" ) ) )
|
||||
{
|
||||
m_PartAliasList->Clear();
|
||||
m_RecreateToolbar = TRUE;
|
||||
m_ButtonDeleteAllAlias->Enable( FALSE );
|
||||
m_ButtonDeleteOneAlias->Enable( FALSE );
|
||||
}
|
||||
wxString msg;
|
||||
msg.Printf( _( "Alias <%s> cannot be removed while it is being \
|
||||
edited!" ),
|
||||
(const wxChar*) CurrentAliasName );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentAliasName.Empty();
|
||||
|
||||
if( IsOK( this, _( "Remove all aliases from list?" ) ) )
|
||||
{
|
||||
m_PartAliasList->Clear();
|
||||
m_ButtonDeleteAllAlias->Enable( FALSE );
|
||||
m_ButtonDeleteOneAlias->Enable( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,56 +311,49 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
|
|||
Line.Replace( wxT( " " ), wxT( "_" ) );
|
||||
aliasname = Line;
|
||||
|
||||
if( CurrentLibEntry->m_Name.m_Text.CmpNoCase( Line ) == 0 )
|
||||
if( m_PartAliasList->FindString( aliasname ) != wxNOT_FOUND
|
||||
|| CurrentLib->FindEntry( aliasname ) != NULL )
|
||||
{
|
||||
DisplayError( this, _( "This is the Root Part" ), 10 ); return;
|
||||
}
|
||||
|
||||
/* test for an existing name: */
|
||||
int ii, jj = m_PartAliasList->GetCount();
|
||||
for( ii = 0; ii < jj; ii++ )
|
||||
{
|
||||
if( aliasname.CmpNoCase( m_PartAliasList->GetString( ii ) ) == 0 )
|
||||
{
|
||||
DisplayError( this, _( "Already in use" ), 10 );
|
||||
return;
|
||||
}
|
||||
wxString msg;
|
||||
msg.Printf( _( "Alias or component name <%s> already exists in \
|
||||
library <%s>." ),
|
||||
(const wxChar*) aliasname,
|
||||
(const wxChar*) CurrentLib->m_Name );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
m_PartAliasList->Append( aliasname );
|
||||
if( CurrentAliasName.IsEmpty() )
|
||||
m_ButtonDeleteAllAlias->Enable( TRUE );
|
||||
m_ButtonDeleteOneAlias->Enable( TRUE );
|
||||
|
||||
m_RecreateToolbar = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************/
|
||||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart(
|
||||
wxCommandEvent& WXUNUSED (event) )
|
||||
/********************************************************/
|
||||
{
|
||||
wxString aliasname = m_PartAliasList->GetStringSelection();
|
||||
|
||||
if( aliasname.IsEmpty() )
|
||||
return;
|
||||
if( aliasname == CurrentAliasName )
|
||||
if( aliasname.CmpNoCase( CurrentAliasName ) == 0 )
|
||||
{
|
||||
wxString msg = CurrentAliasName + _( " is Current Selected Alias!" );
|
||||
wxString msg;
|
||||
msg.Printf( _( "Alias <%s> cannot be removed while it is being \
|
||||
edited!" ),
|
||||
(const wxChar*) aliasname );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
int ii = m_PartAliasList->GetSelection();
|
||||
m_PartAliasList->Delete( ii );
|
||||
m_PartAliasList->Delete( m_PartAliasList->GetSelection() );
|
||||
|
||||
if( !CurrentLibEntry || (CurrentLibEntry->m_AliasList.GetCount() == 0) )
|
||||
if( m_PartAliasList->IsEmpty() )
|
||||
{
|
||||
m_ButtonDeleteAllAlias->Enable( FALSE );
|
||||
m_ButtonDeleteOneAlias->Enable( FALSE );
|
||||
}
|
||||
m_RecreateToolbar = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -602,20 +576,23 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNU
|
|||
if( CurrentLibEntry == NULL )
|
||||
return;
|
||||
|
||||
if( Get_Message( _( "New FootprintFilter:" ), _( "Footprint Filter" ), Line, this ) != 0 )
|
||||
if( Get_Message( _( "Add Footprint Filter" ), _( "Footprint Filter" ),
|
||||
Line, this ) != 0 )
|
||||
return;
|
||||
|
||||
Line.Replace( wxT( " " ), wxT( "_" ) );
|
||||
|
||||
/* test for an existing name: */
|
||||
int ii, jj = m_FootprintFilterListBox->GetCount();
|
||||
for( ii = 0; ii < jj; ii++ )
|
||||
int index = m_FootprintFilterListBox->FindString( Line );
|
||||
|
||||
if( index != wxNOT_FOUND )
|
||||
{
|
||||
if( Line.CmpNoCase( m_FootprintFilterListBox->GetString( ii ) ) == 0 )
|
||||
{
|
||||
DisplayError( this, _( "Already in use" ), 10 );
|
||||
return;
|
||||
}
|
||||
wxString msg;
|
||||
|
||||
msg.Printf( _( "Foot print filter <%s> is already defined." ),
|
||||
(const wxChar*) Line );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
m_FootprintFilterListBox->Append( Line );
|
||||
|
|
|
@ -73,7 +73,10 @@ LibCmpEntry* FindLibPart( const wxChar* Name, const wxString& LibName,
|
|||
if( Lib == NULL )
|
||||
break;
|
||||
|
||||
Entry = Lib->FindEntry( Name, type );
|
||||
if( type == ROOT )
|
||||
Entry = (LibCmpEntry*) Lib->FindComponent( Name );
|
||||
else
|
||||
Entry = Lib->FindEntry( Name );
|
||||
|
||||
if( Entry != NULL )
|
||||
{
|
||||
|
|
|
@ -459,8 +459,6 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
|
|||
|
||||
bool ItemInEdit = GetScreen()->GetCurItem()
|
||||
&& GetScreen()->GetCurItem()->m_Flags;
|
||||
bool RefreshToolBar = FALSE; /* Refresh tool bar when the undo/redo
|
||||
* tool state is modified. */
|
||||
|
||||
if( hotkey == 0 )
|
||||
return;
|
||||
|
@ -578,7 +576,4 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if( RefreshToolBar )
|
||||
SetToolbars();
|
||||
}
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
/****************************/
|
||||
/* 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 @@
|
|||
#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 {
|
||||
LOCATE_COMPONENT_ARC_DRAW_TYPE = 1,
|
||||
LOCATE_COMPONENT_CIRCLE_DRAW_TYPE = 2,
|
||||
|
|
|
@ -25,9 +25,13 @@
|
|||
/* Affiche dans la zone messages la librairie , et le composant edite */
|
||||
void WinEDA_LibeditFrame::DisplayLibInfos()
|
||||
{
|
||||
wxString msg = wxT( "Libedit: " );
|
||||
wxString msg = _( "Component Library Editor: " );
|
||||
|
||||
if( CurrentLib )
|
||||
msg += CurrentLib->m_FullFileName;
|
||||
else
|
||||
msg += _( "no library selected" );
|
||||
|
||||
msg += CurrentLib ? CurrentLib->m_FullFileName : wxT( "No Lib" );
|
||||
SetTitle( msg );
|
||||
|
||||
msg = _( " Part: " );
|
||||
|
@ -37,19 +41,19 @@ void WinEDA_LibeditFrame::DisplayLibInfos()
|
|||
}
|
||||
else
|
||||
{
|
||||
msg += CurrentLibEntry->m_Name.m_Text;
|
||||
msg += CurrentLibEntry->GetName();
|
||||
if( !CurrentAliasName.IsEmpty() )
|
||||
msg << wxT( " Alias " ) << CurrentAliasName;
|
||||
msg << _( " Alias " ) << CurrentAliasName;
|
||||
}
|
||||
static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
|
||||
msg << wxT( " Unit " ) << UnitLetter[CurrentUnit];
|
||||
msg << _( " Unit " ) << UnitLetter[CurrentUnit];
|
||||
|
||||
if( CurrentConvert > 1 )
|
||||
msg += _( " Convert" );
|
||||
else
|
||||
msg += _( " Normal" );
|
||||
|
||||
if( CurrentLibEntry && (CurrentLibEntry->m_Options == ENTRY_POWER) )
|
||||
if( CurrentLibEntry && ( CurrentLibEntry->m_Options == ENTRY_POWER ) )
|
||||
msg += _( " (Power Symbol)" );
|
||||
|
||||
SetStatusText( msg, 0 );
|
||||
|
@ -111,14 +115,16 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart()
|
|||
}
|
||||
|
||||
/* Load the new library component */
|
||||
LibEntry = CurrentLib->FindEntry( CmpName, ALIAS );
|
||||
LibEntry = CurrentLib->FindEntry( CmpName );
|
||||
|
||||
if( LibEntry == NULL )
|
||||
{
|
||||
msg = _( "Component \"" );
|
||||
msg << CmpName << _( "\" not found." );
|
||||
msg.Printf( _( "Component or alias name \"%s\" not found in \
|
||||
library \"%s\"." ),
|
||||
(const wxChar*) CmpName,
|
||||
(const wxChar*) CurrentLib->m_Name );
|
||||
DisplayError( this, msg );
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
GetScreen()->ClearUndoRedoList();
|
||||
|
@ -126,7 +132,6 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPart()
|
|||
if( !LoadOneLibraryPartAux( LibEntry, CurrentLib ) )
|
||||
return false;
|
||||
|
||||
ReCreateHToolbar();
|
||||
Zoom_Automatique( FALSE );
|
||||
DrawPanel->Refresh();
|
||||
return TRUE;
|
||||
|
@ -144,18 +149,19 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( LibCmpEntry* LibEntry,
|
|||
LibraryStruct* Library )
|
||||
{
|
||||
wxString msg, cmpName, rootName;
|
||||
EDA_LibComponentStruct* component;
|
||||
|
||||
if( ( LibEntry == NULL ) || ( Library == NULL ) )
|
||||
return false;
|
||||
|
||||
if( LibEntry->m_Name.m_Text.IsEmpty() )
|
||||
if( LibEntry->GetName().IsEmpty() )
|
||||
{
|
||||
wxLogWarning( wxT( "Entry in library <%s> has empty name field." ),
|
||||
(const wxChar*) LibEntry );
|
||||
return false;
|
||||
}
|
||||
|
||||
cmpName = LibEntry->m_Name.m_Text;
|
||||
cmpName = LibEntry->GetName();
|
||||
CurrentAliasName.Empty();
|
||||
|
||||
if( LibEntry->Type != ROOT )
|
||||
|
@ -165,9 +171,9 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( LibCmpEntry* LibEntry,
|
|||
wxLogDebug( wxT( "\"<%s>\" is alias of \"<%s>\"" ),
|
||||
(const wxChar*) cmpName, (const wxChar*) rootName );
|
||||
|
||||
LibEntry = Library->FindEntry( rootName, ROOT );
|
||||
component = Library->FindComponent( rootName );
|
||||
|
||||
if( LibEntry == NULL )
|
||||
if( component == NULL )
|
||||
{
|
||||
msg.Printf( wxT( "Root entry <%s> for alias <%s> not found in \
|
||||
library <%s>." ),
|
||||
|
@ -180,18 +186,20 @@ library <%s>." ),
|
|||
|
||||
CurrentAliasName = cmpName;
|
||||
}
|
||||
|
||||
if( CurrentLibEntry )
|
||||
else
|
||||
{
|
||||
SAFE_DELETE( CurrentLibEntry );
|
||||
component = (EDA_LibComponentStruct*) LibEntry;
|
||||
}
|
||||
|
||||
CurrentLibEntry = CopyLibEntryStruct( (EDA_LibComponentStruct*) LibEntry );
|
||||
if( CurrentLibEntry )
|
||||
SAFE_DELETE( CurrentLibEntry );
|
||||
|
||||
CurrentLibEntry = CopyLibEntryStruct( component );
|
||||
|
||||
if( CurrentLibEntry == NULL )
|
||||
{
|
||||
msg.Printf( _( "Could not create copy of part <%s> in library <%s>." ),
|
||||
(const wxChar*) LibEntry->m_Name.m_Text,
|
||||
(const wxChar*) LibEntry->GetName(),
|
||||
(const wxChar*) Library->m_Name );
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
|
@ -199,16 +207,21 @@ library <%s>." ),
|
|||
|
||||
CurrentUnit = 1;
|
||||
CurrentConvert = 1;
|
||||
DisplayLibInfos();
|
||||
|
||||
BuildAliasData( Library, CurrentLibEntry );
|
||||
|
||||
g_ScreenLib->ClrModify();
|
||||
g_AsDeMorgan = 0;
|
||||
|
||||
if( LookForConvertPart( CurrentLibEntry ) > 1 )
|
||||
g_AsDeMorgan = 1;
|
||||
|
||||
g_ScreenLib->ClrModify();
|
||||
DisplayLibInfos();
|
||||
UpdateAliasSelectList();
|
||||
UpdatePartSelectList();
|
||||
|
||||
/* Display the document information based on the entry selected just in
|
||||
* case the entry is an alias. */
|
||||
DisplayCmpDoc( LibEntry->GetName() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -257,14 +270,23 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
|||
* Save (on disk) the current library
|
||||
* if exists the old file is renamed (.bak)
|
||||
*/
|
||||
void WinEDA_LibeditFrame::SaveActiveLibrary()
|
||||
void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn;
|
||||
wxString msg;
|
||||
|
||||
DrawPanel->UnManageCursor();
|
||||
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
||||
|
||||
if( GetScreen()->IsModify() )
|
||||
{
|
||||
if( IsOK( this, _( "Include last component changes?" ) ) )
|
||||
SaveOnePartInMemory();
|
||||
}
|
||||
|
||||
if( CurrentLib == NULL )
|
||||
{
|
||||
DisplayError( this, wxT( "No library specified" ) );
|
||||
DisplayError( this, wxT( "No library specified." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -354,14 +376,14 @@ void WinEDA_LibeditFrame::DeleteOnePart()
|
|||
|
||||
if( ListNames.IsEmpty() )
|
||||
{
|
||||
msg.Printf( _( "Component library <%s> does not have any entries to delete." ),
|
||||
msg.Printf( _( "Component library <%s> is empty." ),
|
||||
( const wxChar* ) CurrentLib->m_Name );
|
||||
wxMessageBox( msg, _( "Delete Entry Error" ),
|
||||
wxID_OK | wxICON_EXCLAMATION, this );
|
||||
return;
|
||||
}
|
||||
|
||||
msg.Printf( _( "Select 1 of %d components to\ndelete from library <%s>." ),
|
||||
msg.Printf( _( "Select 1 of %d components to delete\nfrom library <%s>." ),
|
||||
ListNames.GetCount(), ( const wxChar* ) CurrentLib->m_Name );
|
||||
|
||||
wxSingleChoiceDialog dlg( this, msg, _( "Delete Component" ), ListNames );
|
||||
|
@ -380,12 +402,67 @@ void WinEDA_LibeditFrame::DeleteOnePart()
|
|||
return;
|
||||
}
|
||||
|
||||
msg = _( "Delete component \"" ) + LibEntry->m_Name.m_Text +
|
||||
_( "\" from library \"" ) + CurrentLib->m_Name + wxT( "\"?" );
|
||||
msg.Printf( _( "Delete component \"%s\" from library \"%s\"?" ),
|
||||
(const wxChar*) LibEntry->GetName(),
|
||||
(const wxChar*) CurrentLib->m_Name );
|
||||
|
||||
if( IsOK( this, msg ) )
|
||||
if( !IsOK( this, msg ) )
|
||||
return;
|
||||
|
||||
if( CurrentLibEntry == NULL
|
||||
|| ( CurrentLibEntry->GetName().CmpNoCase( LibEntry->GetName() ) != 0
|
||||
&& !CurrentLibEntry->HasAlias( LibEntry->GetName() ) ) )
|
||||
{
|
||||
CurrentLib->RemoveEntry( LibEntry );
|
||||
return;
|
||||
}
|
||||
|
||||
/* If deleting the current entry or removing one of the aliases for
|
||||
* the current entry, sync the changes in the current entry as well.
|
||||
*/
|
||||
|
||||
if( GetScreen()->IsModify()
|
||||
&& !IsOK( this, _( "The component being deleted has been modified. \
|
||||
All changes will be lost. Discard changes?" ) ) )
|
||||
return;
|
||||
|
||||
wxString newCmpName;
|
||||
LibCmpEntry* nextEntry;
|
||||
|
||||
/*
|
||||
* If the current component has no aliases, then the next entry
|
||||
* in the library will be shown. If the current component has
|
||||
* aliases, the updated component will be shown
|
||||
*/
|
||||
if( CurrentLibEntry->GetName().CmpNoCase( LibEntry->GetName() ) == 0 )
|
||||
{
|
||||
if( CurrentLibEntry->m_AliasList.IsEmpty() )
|
||||
{
|
||||
nextEntry = CurrentLib->GetNextEntry( CurrentLibEntry->GetName() );
|
||||
|
||||
if( nextEntry != NULL )
|
||||
newCmpName = nextEntry->GetName();
|
||||
}
|
||||
else
|
||||
{
|
||||
newCmpName = CurrentLibEntry->m_AliasList[ 0 ];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newCmpName = CurrentLibEntry->GetName();
|
||||
}
|
||||
|
||||
CurrentLib->RemoveEntry( LibEntry );
|
||||
|
||||
if( !newCmpName.IsEmpty() )
|
||||
{
|
||||
nextEntry = CurrentLib->FindEntry( newCmpName );
|
||||
|
||||
if( nextEntry != NULL && LoadOneLibraryPartAux( nextEntry, CurrentLib ) )
|
||||
Zoom_Automatique( false );
|
||||
|
||||
DrawPanel->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,9 +478,9 @@ void WinEDA_LibeditFrame::CreateNewLibraryPart()
|
|||
EDA_LibComponentStruct* NewStruct;
|
||||
int diag;
|
||||
|
||||
if( CurrentLibEntry
|
||||
&& !IsOK( this,
|
||||
_( "Clear old component from screen (changes will be lost)?" ) ) )
|
||||
if( CurrentLibEntry && GetScreen()->IsModify()
|
||||
&& !IsOK( this,
|
||||
_( "Clear old component from screen (changes will be lost)?" ) ) )
|
||||
return;
|
||||
|
||||
CurrentDrawItem = NULL;
|
||||
|
@ -424,9 +501,9 @@ void WinEDA_LibeditFrame::CreateNewLibraryPart()
|
|||
if( CurrentLib->FindEntry( msg ) )
|
||||
{
|
||||
wxString msg;
|
||||
msg << _( "Component \"" ) << Dialogbox.ReturnCmpName() <<
|
||||
_( "\" exists in library \"" ) << CurrentLib->m_Name <<
|
||||
_( "\"." );
|
||||
msg.Printf( _( "Component \"%s\" exists in library \"%s\"." ),
|
||||
(const wxChar*) Dialogbox.ReturnCmpName(),
|
||||
(const wxChar*) CurrentLib->m_Name );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
@ -446,9 +523,8 @@ void WinEDA_LibeditFrame::CreateNewLibraryPart()
|
|||
CurrentLibEntry = NewStruct;
|
||||
CurrentUnit = 1;
|
||||
CurrentConvert = 1;
|
||||
ReCreateHToolbar();
|
||||
|
||||
DisplayLibInfos();
|
||||
DisplayCmpDoc( CurrentLibEntry->GetName() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -461,10 +537,9 @@ void WinEDA_LibeditFrame::CreateNewLibraryPart()
|
|||
*/
|
||||
void WinEDA_LibeditFrame::SaveOnePartInMemory()
|
||||
{
|
||||
LibCmpEntry* Entry;
|
||||
EDA_LibComponentStruct* oldComponent;
|
||||
EDA_LibComponentStruct* Component;
|
||||
wxString msg;
|
||||
bool NewCmp = TRUE;
|
||||
wxString msg;
|
||||
|
||||
if( CurrentLibEntry == NULL )
|
||||
{
|
||||
|
@ -483,44 +558,29 @@ void WinEDA_LibeditFrame::SaveOnePartInMemory()
|
|||
|
||||
g_ScreenLib->ClrModify();
|
||||
|
||||
Entry = CurrentLib->FindEntry( CurrentLibEntry->m_Name.m_Text, ROOT );
|
||||
oldComponent = CurrentLib->FindComponent( CurrentLibEntry->GetName() );
|
||||
|
||||
if( Entry != NULL )
|
||||
if( oldComponent != NULL )
|
||||
{
|
||||
msg.Printf( _( "Component \"%s\" exists. Change it?" ),
|
||||
(const wxChar*) Entry->m_Name.m_Text );
|
||||
(const wxChar*) oldComponent->GetName() );
|
||||
if( !IsOK( this, msg ) )
|
||||
return;
|
||||
NewCmp = FALSE;
|
||||
}
|
||||
|
||||
wxASSERT( CurrentLibEntry->Type == ROOT );
|
||||
|
||||
/* Effacement des alias deja existants en librairie */
|
||||
for( unsigned ii = 0;
|
||||
ii < CurrentLibEntry->m_AliasList.GetCount();
|
||||
ii += ALIAS_NEXT )
|
||||
{
|
||||
LibCmpEntry* LocalEntry;
|
||||
wxString aliasname = CurrentLibEntry->m_AliasList[ii];
|
||||
LocalEntry = CurrentLib->FindEntry( aliasname, ALIAS );
|
||||
|
||||
while( LocalEntry != NULL && LocalEntry->Type == ALIAS )
|
||||
{
|
||||
CurrentLib->RemoveEntry( LocalEntry );
|
||||
}
|
||||
}
|
||||
|
||||
if( !NewCmp )
|
||||
CurrentLib->RemoveEntry( Entry );
|
||||
|
||||
Component = CurrentLib->AddComponent( CurrentLibEntry );
|
||||
if( oldComponent != NULL )
|
||||
Component = CurrentLib->ReplaceComponent( oldComponent,
|
||||
CurrentLibEntry );
|
||||
else
|
||||
Component = CurrentLib->AddComponent( CurrentLibEntry );
|
||||
|
||||
if( Component == NULL )
|
||||
return;
|
||||
|
||||
msg.Printf( _( "Component %s saved in library %s" ),
|
||||
( const wxChar* ) Component->m_Name.m_Text,
|
||||
( const wxChar* ) Component->GetName(),
|
||||
( const wxChar* ) CurrentLib->m_Name );
|
||||
Affiche_Message( msg );
|
||||
}
|
||||
|
|
|
@ -79,9 +79,10 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
|||
|
||||
else
|
||||
{
|
||||
EraseMsgBox();
|
||||
AfficheDoc( this, CurrentLibEntry->m_Doc.GetData(),
|
||||
CurrentLibEntry->m_KeyWord.GetData() );
|
||||
if( CurrentAliasName.IsEmpty() )
|
||||
DisplayCmpDoc( CurrentAliasName );
|
||||
else
|
||||
DisplayCmpDoc( CurrentLibEntry->GetName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,8 +152,10 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
|||
}
|
||||
if( DrawEntry == NULL )
|
||||
{
|
||||
AfficheDoc( this, CurrentLibEntry->m_Doc.GetData(),
|
||||
CurrentLibEntry->m_KeyWord.GetData() );
|
||||
if( CurrentAliasName.IsEmpty() )
|
||||
DisplayCmpDoc( CurrentLibEntry->GetName() );
|
||||
else
|
||||
DisplayCmpDoc( CurrentAliasName );
|
||||
break;
|
||||
}
|
||||
SaveCopyInUndoList( CurrentLibEntry );
|
||||
|
@ -224,7 +227,7 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
|
|||
}
|
||||
if( DrawEntry == NULL )
|
||||
{
|
||||
InstallLibeditFrame( );
|
||||
EditComponentProperties();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,9 +67,6 @@ void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event)
|
|||
CurrentLibEntry->SetNext( NULL );
|
||||
CurrentDrawItem = NULL;
|
||||
GetScreen()->SetModify();
|
||||
ReCreateHToolbar();
|
||||
SetToolbars();
|
||||
|
||||
DrawPanel->Refresh();
|
||||
}
|
||||
|
||||
|
@ -101,8 +98,5 @@ void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event)
|
|||
CurrentLibEntry->SetNext( NULL );
|
||||
CurrentDrawItem = NULL;
|
||||
GetScreen()->SetModify();
|
||||
ReCreateHToolbar();
|
||||
SetToolbars();
|
||||
|
||||
DrawPanel->Refresh();
|
||||
}
|
||||
|
|
|
@ -193,18 +193,32 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LibDrawField* Field )
|
|||
*/
|
||||
if( Field->m_FieldId == VALUE )
|
||||
{
|
||||
/* test for an existing name in alias list: */
|
||||
for( unsigned ii = 0; ii < CurrentLibEntry->m_AliasList.GetCount();
|
||||
ii += ALIAS_NEXT )
|
||||
{
|
||||
wxString aliasname = CurrentLibEntry->m_AliasList[ii + ALIAS_NAME];
|
||||
wxString msg;
|
||||
|
||||
if( Text.CmpNoCase( aliasname ) == 0 )
|
||||
{
|
||||
DisplayError( this, _( "This name is an existing alias of \
|
||||
the component\nAborting" ) );
|
||||
return;
|
||||
}
|
||||
/* 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 )
|
||||
{
|
||||
msg.Printf( _( "The field name <%s> conflicts with an existing \
|
||||
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 );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,9 +247,7 @@ the component\nAborting" ) );
|
|||
DefaultTransformMatrix );
|
||||
|
||||
GetScreen()->SetModify();
|
||||
|
||||
if( Field->m_FieldId == VALUE )
|
||||
ReCreateHToolbar();
|
||||
UpdateAliasSelectList();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,67 +39,88 @@ BEGIN_EVENT_TABLE( WinEDA_LibeditFrame, WinEDA_DrawFrame )
|
|||
EVT_CLOSE( WinEDA_LibeditFrame::OnCloseWindow )
|
||||
EVT_SIZE( WinEDA_LibeditFrame::OnSize )
|
||||
|
||||
/* Main horizontal toolbar. */
|
||||
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_LibeditFrame::OnZoom )
|
||||
|
||||
// Tools et boutons de Libedit:
|
||||
|
||||
/* Main horizontal toolbar */
|
||||
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_LIB,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::SaveActiveLibrary )
|
||||
EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_LIBEDIT_DELETE_PART,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_LIBEDIT_NEW_PART,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_LIBEDIT_SELECT_PART,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_LIBEDIT_UNDO,
|
||||
WinEDA_LibeditFrame::GetComponentFromUndoList )
|
||||
WinEDA_LibeditFrame::GetComponentFromUndoList )
|
||||
EVT_TOOL( ID_LIBEDIT_REDO,
|
||||
WinEDA_LibeditFrame::GetComponentFromRedoList )
|
||||
WinEDA_LibeditFrame::GetComponentFromRedoList )
|
||||
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_PART,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::OnEditComponentProperties )
|
||||
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_LIBEDIT_CHECK_PART,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_LIBEDIT_VIEW_DOC,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_PIN,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL( ExportPartId, WinEDA_LibeditFrame::OnExportPart )
|
||||
EVT_TOOL( CreateNewLibAndSavePartId, WinEDA_LibeditFrame::OnExportPart )
|
||||
EVT_TOOL( ImportPartId, WinEDA_LibeditFrame::OnImportPart )
|
||||
|
||||
|
||||
EVT_KICAD_CHOICEBOX( ID_LIBEDIT_SELECT_PART_NUMBER,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::OnSelectPart )
|
||||
EVT_KICAD_CHOICEBOX( ID_LIBEDIT_SELECT_ALIAS,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
WinEDA_LibeditFrame::OnSelectAlias )
|
||||
|
||||
/* Right Vertical toolbar */
|
||||
/* Right vertical toolbar. */
|
||||
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
EVT_TOOL_RANGE( ID_LIBEDIT_START_V_TOOL, ID_LIBEDIT_END_V_TOOL,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
|
||||
/* PopUp events and commands: */
|
||||
/* Context menu events and commands. */
|
||||
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
|
||||
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
|
||||
WinEDA_LibeditFrame::Process_Special_Functions )
|
||||
|
||||
EVT_TOOL( ExportPartId, WinEDA_LibeditFrame::OnExportPart )
|
||||
EVT_TOOL( CreateNewLibAndSavePartId, WinEDA_LibeditFrame::OnExportPart )
|
||||
EVT_TOOL( ImportPartId, WinEDA_LibeditFrame::OnImportPart )
|
||||
/* Update user interface elements. */
|
||||
EVT_UPDATE_UI( ExportPartId, WinEDA_LibeditFrame::OnUpdateEditingPart )
|
||||
EVT_UPDATE_UI( CreateNewLibAndSavePartId,
|
||||
WinEDA_LibeditFrame::OnUpdateEditingPart )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_PART,
|
||||
WinEDA_LibeditFrame::OnUpdateEditingPart )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
|
||||
WinEDA_LibeditFrame::OnUpdateEditingPart )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART,
|
||||
WinEDA_LibeditFrame::OnUpdateEditingPart )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_UNDO, WinEDA_LibeditFrame::OnUpdateUndo )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_REDO, WinEDA_LibeditFrame::OnUpdateRedo )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB,
|
||||
WinEDA_LibeditFrame::OnUpdateSaveCurrentLib )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, WinEDA_LibeditFrame::OnUpdateViewDoc )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_PIN,
|
||||
WinEDA_LibeditFrame::OnUpdatePinByPin )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER,
|
||||
WinEDA_LibeditFrame::OnUpdatePartNumber )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_ALIAS,
|
||||
WinEDA_LibeditFrame::OnUpdateSelectAlias )
|
||||
EVT_UPDATE_UI( ID_DE_MORGAN_NORMAL_BUTT,
|
||||
WinEDA_LibeditFrame::OnUpdateDeMorganNormal )
|
||||
EVT_UPDATE_UI( ID_DE_MORGAN_CONVERT_BUTT,
|
||||
WinEDA_LibeditFrame::OnUpdateDeMorganConvert )
|
||||
EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_EXPORT_BODY_BUTT,
|
||||
WinEDA_LibeditFrame::OnUpdateEditingPart )
|
||||
|
||||
// PopUp Menus pour Zooms trait<69>s dans drawpanel.cpp
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
@ -126,14 +147,14 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
|
|||
ReCreateHToolbar();
|
||||
ReCreateVToolbar();
|
||||
DisplayLibInfos();
|
||||
UpdateAliasSelectList();
|
||||
UpdatePartSelectList();
|
||||
BestZoom();
|
||||
Show( true );
|
||||
}
|
||||
|
||||
|
||||
/**********************************************/
|
||||
WinEDA_LibeditFrame::~WinEDA_LibeditFrame()
|
||||
/**********************************************/
|
||||
{
|
||||
WinEDA_SchematicFrame* frame =
|
||||
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
|
||||
|
@ -216,123 +237,6 @@ void WinEDA_LibeditFrame::OnCloseWindow( wxCloseEvent& Event )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Enable or disable tools of the differents toolbars, according to the
|
||||
* current conditions or options.
|
||||
*
|
||||
* FIXME: Get rid of this function and use WX_UPDATE_UI to handle enabling of
|
||||
* menu and toolbar items.
|
||||
*/
|
||||
void WinEDA_LibeditFrame::SetToolbars()
|
||||
{
|
||||
if( m_HToolBar == NULL )
|
||||
return;
|
||||
|
||||
if( CurrentLib == NULL )
|
||||
{
|
||||
if( m_HToolBar )
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_SAVE_CURRENT_LIB, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_HToolBar )
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_SAVE_CURRENT_LIB, true );
|
||||
}
|
||||
|
||||
if( CurrentLibEntry == NULL )
|
||||
{
|
||||
if( m_HToolBar )
|
||||
{
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_SAVE_CURRENT_PART, false );
|
||||
m_HToolBar->EnableTool( ID_DE_MORGAN_CONVERT_BUTT, false );
|
||||
m_HToolBar->EnableTool( ID_DE_MORGAN_NORMAL_BUTT, false );
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, false );
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_VIEW_DOC, false );
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_CHECK_PART, false );
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, false );
|
||||
m_SelpartBox->Enable( false );
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_UNDO, false );
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_REDO, false );
|
||||
}
|
||||
g_EditPinByPinIsOn = false;
|
||||
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );
|
||||
|
||||
if( m_VToolBar )
|
||||
{
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_BODY_TEXT_BUTT, false );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_BODY_LINE_BUTT, false );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_BODY_RECT_BUTT, false );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_BODY_CIRCLE_BUTT, false );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_BODY_ARC_BUTT, false );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_DELETE_ITEM_BUTT, false );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_ANCHOR_ITEM_BUTT, false );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_IMPORT_BODY_BUTT, false );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_EXPORT_BODY_BUTT, false );
|
||||
}
|
||||
}
|
||||
else // if we have a current entry to edit:
|
||||
{
|
||||
if( m_HToolBar )
|
||||
{
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_SAVE_CURRENT_PART, true );
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, true );
|
||||
if( (CurrentLibEntry->m_UnitCount > 1) || g_AsDeMorgan )
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, true );
|
||||
else
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, false );
|
||||
|
||||
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN,
|
||||
g_EditPinByPinIsOn );
|
||||
|
||||
m_HToolBar->EnableTool( ID_DE_MORGAN_CONVERT_BUTT, g_AsDeMorgan );
|
||||
m_HToolBar->EnableTool( ID_DE_MORGAN_NORMAL_BUTT, g_AsDeMorgan );
|
||||
/* Enable the "get doc" tool */
|
||||
bool enable_dtool = false;
|
||||
if( !CurrentAliasName.IsEmpty() )
|
||||
{
|
||||
int AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList,
|
||||
CurrentAliasName );
|
||||
if( AliasLocation >= 0 )
|
||||
if( !CurrentLibEntry->m_AliasList[AliasLocation +
|
||||
ALIAS_DOC_FILENAME].IsEmpty() )
|
||||
enable_dtool = true;
|
||||
}
|
||||
else if( !CurrentLibEntry->m_DocFile.IsEmpty() )
|
||||
enable_dtool = true;
|
||||
if( enable_dtool )
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_VIEW_DOC, true );
|
||||
else
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_VIEW_DOC, false );
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_CHECK_PART, true );
|
||||
m_SelpartBox->Enable( (CurrentLibEntry->m_UnitCount > 1 ) ? true : false );
|
||||
|
||||
if( GetScreen() )
|
||||
{
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_UNDO,
|
||||
GetScreen()->GetUndoCommandCount() );
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_REDO,
|
||||
GetScreen()->GetRedoCommandCount() );
|
||||
}
|
||||
}
|
||||
|
||||
if( m_VToolBar )
|
||||
{
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_BODY_TEXT_BUTT, true );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_BODY_LINE_BUTT, true );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_BODY_RECT_BUTT, true );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_BODY_CIRCLE_BUTT, true );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_BODY_ARC_BUTT, true );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_DELETE_ITEM_BUTT, true );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_ANCHOR_ITEM_BUTT, true );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_IMPORT_BODY_BUTT, true );
|
||||
m_VToolBar->EnableTool( ID_LIBEDIT_EXPORT_BODY_BUTT, true );
|
||||
}
|
||||
}
|
||||
|
||||
DisplayUnitsMsg();
|
||||
}
|
||||
|
||||
|
||||
int WinEDA_LibeditFrame::BestZoom()
|
||||
{
|
||||
int dx, dy, ii, jj;
|
||||
|
@ -374,17 +278,200 @@ int WinEDA_LibeditFrame::BestZoom()
|
|||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::UpdateAliasSelectList()
|
||||
{
|
||||
if( m_SelAliasBox == NULL )
|
||||
return;
|
||||
|
||||
m_SelAliasBox->Clear();
|
||||
|
||||
if( CurrentLibEntry == NULL )
|
||||
return;
|
||||
|
||||
m_SelAliasBox->Append( CurrentLibEntry->GetName() );
|
||||
m_SelAliasBox->SetSelection( 0 );
|
||||
|
||||
if( !CurrentLibEntry->m_AliasList.IsEmpty() )
|
||||
{
|
||||
m_SelAliasBox->Append( CurrentLibEntry->m_AliasList );
|
||||
|
||||
int index = m_SelAliasBox->FindString( CurrentAliasName );
|
||||
|
||||
if( index != wxNOT_FOUND )
|
||||
m_SelAliasBox->SetSelection( index );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::UpdatePartSelectList()
|
||||
{
|
||||
if( m_SelpartBox == NULL )
|
||||
return;
|
||||
|
||||
|
||||
if( !m_SelpartBox->IsEmpty() )
|
||||
m_SelpartBox->Clear();
|
||||
|
||||
if( CurrentLibEntry == NULL || CurrentLibEntry->m_UnitCount <= 1 )
|
||||
{
|
||||
m_SelpartBox->Append( wxEmptyString );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < CurrentLibEntry->m_UnitCount; i++ )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Part %c" ), 'A' + i );
|
||||
m_SelpartBox->Append( msg );
|
||||
}
|
||||
}
|
||||
|
||||
m_SelpartBox->SetSelection( ( CurrentUnit > 0 ) ? CurrentUnit - 1 : 0 );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnUpdateEditingPart( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Enable( CurrentLibEntry != NULL );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnUpdateNotEditingPart( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Enable( CurrentLibEntry == NULL );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnUpdateUndo( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Enable( CurrentLibEntry != NULL && GetScreen() != NULL
|
||||
&& GetScreen()->GetUndoCommandCount() != 0 );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnUpdateRedo( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Enable( CurrentLibEntry != NULL && GetScreen() != NULL
|
||||
&& GetScreen()->GetRedoCommandCount() != 0 );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnUpdateSaveCurrentLib( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Enable( CurrentLib != NULL );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event )
|
||||
{
|
||||
bool enable = false;
|
||||
|
||||
if( CurrentLibEntry != NULL && CurrentLib != NULL )
|
||||
{
|
||||
if( !CurrentAliasName.IsEmpty() )
|
||||
{
|
||||
LibCmpEntry* entry = CurrentLib->FindEntry( CurrentAliasName );
|
||||
|
||||
if( entry != NULL )
|
||||
enable = !entry->m_DocFile.IsEmpty();
|
||||
}
|
||||
else if( !CurrentLibEntry->m_DocFile.IsEmpty() )
|
||||
{
|
||||
enable = true;
|
||||
}
|
||||
}
|
||||
|
||||
event.Enable( enable );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnUpdatePinByPin( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Enable( ( CurrentLibEntry != NULL )
|
||||
&& ( ( CurrentLibEntry->m_UnitCount > 1 ) || g_AsDeMorgan ) );
|
||||
|
||||
if( m_HToolBar )
|
||||
m_HToolBar->ToggleTool( event.GetId(), g_EditPinByPinIsOn );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnUpdatePartNumber( wxUpdateUIEvent& event )
|
||||
{
|
||||
if( m_SelpartBox == NULL )
|
||||
return;
|
||||
|
||||
/* Using the typical event.Enable() call dosen't seem to work with wxGTK
|
||||
* so use the pointer to alias combobox to directly enable or disable.
|
||||
*/
|
||||
m_SelpartBox->Enable( CurrentLibEntry != NULL
|
||||
&& CurrentLibEntry->m_UnitCount > 1 );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
|
||||
{
|
||||
if( m_HToolBar == NULL )
|
||||
return;
|
||||
|
||||
event.Enable( CurrentLibEntry != NULL && CurrentLibEntry->HasConversion() );
|
||||
m_HToolBar->ToggleTool( event.GetId(), CurrentConvert <= 1 );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnUpdateDeMorganConvert( wxUpdateUIEvent& event )
|
||||
{
|
||||
if( m_HToolBar == NULL )
|
||||
return;
|
||||
|
||||
event.Enable( CurrentLibEntry != NULL && CurrentLibEntry->HasConversion() );
|
||||
m_HToolBar->ToggleTool( event.GetId(), CurrentConvert > 1 );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnUpdateSelectAlias( wxUpdateUIEvent& event )
|
||||
{
|
||||
if( m_SelAliasBox == NULL )
|
||||
return;
|
||||
|
||||
/* Using the typical event.Enable() call dosen't seem to work with wxGTK
|
||||
* so use the pointer to alias combobox to directly enable or disable.
|
||||
*/
|
||||
m_SelAliasBox->Enable( CurrentLibEntry != NULL
|
||||
&& !CurrentLibEntry->m_AliasList.IsEmpty() );
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnSelectAlias( wxCommandEvent& event )
|
||||
{
|
||||
if( m_SelAliasBox == NULL
|
||||
|| m_SelAliasBox->GetStringSelection().CmpNoCase( CurrentAliasName ) == 0 )
|
||||
return;
|
||||
|
||||
LibItemToRepeat = NULL;
|
||||
|
||||
if( m_SelAliasBox->GetStringSelection().CmpNoCase(CurrentLibEntry->GetName() ) == 0 )
|
||||
CurrentAliasName.Empty();
|
||||
else
|
||||
{
|
||||
CurrentAliasName = m_SelAliasBox->GetStringSelection();
|
||||
DisplayCmpDoc( CurrentAliasName );
|
||||
}
|
||||
|
||||
DrawPanel->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::OnSelectPart( wxCommandEvent& event )
|
||||
{
|
||||
int i = event.GetSelection();
|
||||
if( i < 0 )
|
||||
return;
|
||||
LibItemToRepeat = NULL;
|
||||
CurrentUnit = i + 1;
|
||||
DrawPanel->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||
{
|
||||
int id = event.GetId();
|
||||
|
@ -434,23 +521,15 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
switch( id )
|
||||
{
|
||||
case ID_LIBEDIT_SAVE_CURRENT_LIB:
|
||||
if( GetScreen()->IsModify() )
|
||||
{
|
||||
if( IsOK( this, _( "Include last component changes?" ) ) )
|
||||
SaveOnePartInMemory();
|
||||
}
|
||||
SaveActiveLibrary();
|
||||
break;
|
||||
|
||||
case ID_LIBEDIT_NEW_PART:
|
||||
{
|
||||
g_EditPinByPinIsOn = false;
|
||||
LibItemToRepeat = NULL;
|
||||
CreateNewLibraryPart();
|
||||
UpdateAliasSelectList();
|
||||
UpdatePartSelectList();
|
||||
GetScreen()->ClearUndoRedoList();
|
||||
DrawPanel->Refresh();
|
||||
SetToolbars();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -464,7 +543,6 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
|
|||
{
|
||||
g_EditPinByPinIsOn = false;
|
||||
GetScreen()->ClearUndoRedoList();
|
||||
SetToolbars();
|
||||
}
|
||||
DrawPanel->Refresh();
|
||||
break;
|
||||
|
@ -473,12 +551,10 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
|
|||
SaveOnePartInMemory();
|
||||
break;
|
||||
|
||||
case ID_LIBEDIT_GET_FRAME_EDIT_PART:
|
||||
InstallLibeditFrame( );
|
||||
break;
|
||||
|
||||
case ID_LIBEDIT_GET_FRAME_EDIT_FIELDS:
|
||||
InstallFieldsEditorDialog( );
|
||||
UpdateAliasSelectList();
|
||||
UpdatePartSelectList();
|
||||
break;
|
||||
|
||||
case ID_LIBEDIT_DELETE_PART:
|
||||
|
@ -487,22 +563,17 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_LIBEDIT_CHECK_PART:
|
||||
if( CurrentLibEntry )
|
||||
if( TestPins( CurrentLibEntry ) == false )
|
||||
DisplayInfoMessage( this, _( " Pins Test OK!" ) );
|
||||
if( CurrentLibEntry && TestPins( CurrentLibEntry ) == false )
|
||||
DisplayInfoMessage( this, _( " Pins Test OK!" ) );
|
||||
break;
|
||||
|
||||
case ID_DE_MORGAN_NORMAL_BUTT:
|
||||
m_HToolBar->ToggleTool( ID_DE_MORGAN_NORMAL_BUTT, true );
|
||||
m_HToolBar->ToggleTool( ID_DE_MORGAN_CONVERT_BUTT, false );
|
||||
LibItemToRepeat = NULL;
|
||||
CurrentConvert = 1;
|
||||
DrawPanel->Refresh();
|
||||
break;
|
||||
|
||||
case ID_DE_MORGAN_CONVERT_BUTT:
|
||||
m_HToolBar->ToggleTool( ID_DE_MORGAN_NORMAL_BUTT, false );
|
||||
m_HToolBar->ToggleTool( ID_DE_MORGAN_CONVERT_BUTT, true );
|
||||
LibItemToRepeat = NULL;
|
||||
CurrentConvert = 2;
|
||||
DrawPanel->Refresh();
|
||||
|
@ -514,11 +585,9 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
|
|||
wxString docfilename;
|
||||
if( !CurrentAliasName.IsEmpty() )
|
||||
{
|
||||
int AliasLocation = LocateAlias( CurrentLibEntry->m_AliasList,
|
||||
CurrentAliasName );
|
||||
if( AliasLocation >= 0 )
|
||||
docfilename =
|
||||
CurrentLibEntry->m_AliasList[AliasLocation + ALIAS_DOC_FILENAME];
|
||||
LibCmpEntry* entry = CurrentLib->FindEntry( CurrentAliasName );
|
||||
if( entry != NULL )
|
||||
docfilename = entry->m_DocFile;
|
||||
}
|
||||
else
|
||||
docfilename = CurrentLibEntry->m_DocFile;
|
||||
|
@ -531,32 +600,6 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
case ID_LIBEDIT_EDIT_PIN_BY_PIN:
|
||||
g_EditPinByPinIsOn = g_EditPinByPinIsOn ? false : true;
|
||||
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );
|
||||
break;
|
||||
|
||||
case ID_LIBEDIT_SELECT_PART_NUMBER:
|
||||
{
|
||||
int ii = m_SelpartBox->GetChoice();
|
||||
if( ii < 0 )
|
||||
return;
|
||||
LibItemToRepeat = NULL;
|
||||
CurrentUnit = ii + 1;
|
||||
DrawPanel->Refresh();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_LIBEDIT_SELECT_ALIAS:
|
||||
{
|
||||
int ii = m_SelAliasBox->GetChoice();
|
||||
if( ii < 0 )
|
||||
return;
|
||||
LibItemToRepeat = NULL;
|
||||
if( ii > 0 )
|
||||
CurrentAliasName = m_SelAliasBox->GetValue();
|
||||
else
|
||||
CurrentAliasName.Empty();
|
||||
DrawPanel->Refresh();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_POPUP_LIBEDIT_PIN_EDIT:
|
||||
|
@ -752,7 +795,7 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
|
|||
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
||||
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
|
||||
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
|
||||
if( (CurrentDrawItem == NULL)
|
||||
if( (CurrentDrawItem == NULL )
|
||||
|| (CurrentDrawItem->Type() != COMPONENT_PIN_DRAW_TYPE) )
|
||||
break;
|
||||
SaveCopyInUndoList( CurrentLibEntry );
|
||||
|
|
|
@ -83,20 +83,17 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
|
|||
case COMPONENT_ARC_DRAW_TYPE:
|
||||
{
|
||||
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;
|
||||
MapAngles( &t1, &t2, TransMat );
|
||||
if( draw_bgfill && Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR )
|
||||
{
|
||||
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->arc( pos,
|
||||
-t2,
|
||||
-t1,
|
||||
Arc->m_Rayon,
|
||||
Arc->m_Fill,
|
||||
plotter->arc( pos, -t2, -t1, Arc->m_Radius, Arc->m_Fill,
|
||||
thickness );
|
||||
}
|
||||
break;
|
||||
|
@ -108,11 +105,11 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
|
|||
if( draw_bgfill && Circle->m_Fill == FILLED_WITH_BG_BODYCOLOR )
|
||||
{
|
||||
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->circle( pos,
|
||||
Circle->m_Rayon * 2,
|
||||
Circle->m_Radius * 2,
|
||||
Circle->m_Fill,
|
||||
thickness );
|
||||
}
|
||||
|
|
|
@ -223,15 +223,6 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry );
|
|||
* 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 */
|
||||
/**************/
|
||||
|
@ -365,18 +356,6 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint );
|
|||
|
||||
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 */
|
||||
/***************/
|
||||
|
|
|
@ -36,7 +36,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry )
|
|||
if( OldEntry->Type != ROOT )
|
||||
{
|
||||
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 );
|
||||
return NULL;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( EDA_LibComponentStruct* OldEntry )
|
|||
msg.Printf( wxT( "Error attempting to copy draw item <%s> from \
|
||||
component <%s>." ),
|
||||
(const wxChar*) OldDrawings->GetClass(),
|
||||
(const wxChar*) OldEntry->m_Name.m_Text );
|
||||
(const wxChar*) OldEntry->GetName() );
|
||||
wxLogError( msg );
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -572,7 +572,7 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
|||
case COMPONENT_CIRCLE_DRAW_TYPE:
|
||||
dx = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.x - curr_pos.x;
|
||||
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 ) );
|
||||
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
|
||||
break;
|
||||
|
@ -741,13 +741,16 @@ static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre )
|
|||
int cX, cY; /* Coord centre de l'arc */
|
||||
int angle;
|
||||
|
||||
cX = ArcCentre.x; cY = ArcCentre.y;
|
||||
cX = ArcCentre.x;
|
||||
cY = ArcCentre.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 */
|
||||
dx = ArcEndX - ArcStartX; dy = ArcEndY - ArcStartY;
|
||||
cX -= ArcStartX; cY -= ArcStartY;
|
||||
dx = ArcEndX - ArcStartX;
|
||||
dy = ArcEndY - ArcStartY;
|
||||
cX -= ArcStartX;
|
||||
cY -= ArcStartY;
|
||||
angle = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
|
||||
RotatePoint( &dx, &dy, angle ); /* Le segment dx, dy est horizontal */
|
||||
/* -> dx = longueur, dy = 0 */
|
||||
|
@ -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 */
|
||||
|
||||
RotatePoint( &cX, &cY, -angle );
|
||||
cX += ArcStartX; cY += ArcStartY;
|
||||
|
||||
DrawItem->m_Pos.x = cX; DrawItem->m_Pos.y = cY;
|
||||
cX += ArcStartX;
|
||||
cY += ArcStartY;
|
||||
DrawItem->m_Pos.x = cX;
|
||||
DrawItem->m_Pos.y = cY;
|
||||
|
||||
dx = ArcStartX - DrawItem->m_Pos.x;
|
||||
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;
|
||||
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.y = ArcStartY;
|
||||
DrawItem->m_ArcEnd.x = ArcEndX;
|
||||
DrawItem->m_ArcEnd.y = ArcEndY;
|
||||
|
||||
NORMALIZE_ANGLE( DrawItem->t1 );
|
||||
NORMALIZE_ANGLE( DrawItem->t2 ); // angles = 0 .. 3600
|
||||
NORMALIZE_ANGLE( DrawItem->m_t1 );
|
||||
NORMALIZE_ANGLE( DrawItem->m_t2 ); // angles = 0 .. 3600
|
||||
|
||||
// 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
|
||||
// son orientation apres rot, miroir...
|
||||
if( (DrawItem->t2 - DrawItem->t1) > 1800 )
|
||||
DrawItem->t2 -= 3600;
|
||||
else if( (DrawItem->t2 - DrawItem->t1) <= -1800 )
|
||||
DrawItem->t2 += 3600;
|
||||
if( (DrawItem->m_t2 - DrawItem->m_t1) > 1800 )
|
||||
DrawItem->m_t2 -= 3600;
|
||||
else if( (DrawItem->m_t2 - DrawItem->m_t1) <= -1800 )
|
||||
DrawItem->m_t2 += 3600;
|
||||
|
||||
wxString msg;
|
||||
angle = DrawItem->t2 - DrawItem->t1;
|
||||
angle = DrawItem->m_t2 - DrawItem->m_t1;
|
||||
msg.Printf( _( "Arc %.1f deg" ), (float) angle / 10 );
|
||||
WinEDA_SchematicFrame* frame =
|
||||
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
|
||||
frame->m_LibeditFrame->PrintMsg( msg );
|
||||
|
||||
while( (DrawItem->t2 - DrawItem->t1) >= 1800 )
|
||||
while( (DrawItem->m_t2 - DrawItem->m_t1) >= 1800 )
|
||||
{
|
||||
DrawItem->t2--;
|
||||
DrawItem->t1++;
|
||||
DrawItem->m_t2--;
|
||||
DrawItem->m_t1++;
|
||||
}
|
||||
|
||||
while( (DrawItem->t1 - DrawItem->t2) >= 1800 )
|
||||
while( (DrawItem->m_t1 - DrawItem->m_t2) >= 1800 )
|
||||
{
|
||||
DrawItem->t2++;
|
||||
DrawItem->t1--;
|
||||
DrawItem->m_t2++;
|
||||
DrawItem->m_t1--;
|
||||
}
|
||||
|
||||
NORMALIZE_ANGLE( DrawItem->t1 );
|
||||
NORMALIZE_ANGLE( DrawItem->t2 );
|
||||
NORMALIZE_ANGLE( DrawItem->m_t1 );
|
||||
NORMALIZE_ANGLE( DrawItem->m_t2 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,10 +21,6 @@
|
|||
#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
|
||||
* items) to the current component.
|
||||
|
@ -124,7 +120,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
|
|||
}
|
||||
|
||||
// Remove duplicated drawings:
|
||||
SuppressDuplicateDrawItem( CurrentLibEntry );
|
||||
CurrentLibEntry->RemoveDuplicateDrawItems();
|
||||
|
||||
// Clear flags
|
||||
DrawEntry = CurrentLibEntry->m_Drawings;
|
||||
|
@ -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 */
|
||||
/* le trace) du composant courant */
|
||||
|
@ -398,76 +251,14 @@ static bool CompareSymbols( LibEDA_BaseStruct* DEntryRef,
|
|||
/***************************************************************************/
|
||||
void WinEDA_LibeditFrame::PlaceAncre()
|
||||
{
|
||||
EDA_LibComponentStruct* LibEntry;
|
||||
LibEDA_BaseStruct* DrawEntry;
|
||||
|
||||
LibEntry = CurrentLibEntry;
|
||||
if( LibEntry == NULL )
|
||||
if( CurrentLibEntry == NULL )
|
||||
return;
|
||||
|
||||
wxSize offset( -GetScreen()->m_Curseur.x, GetScreen()->m_Curseur.y );
|
||||
wxPoint offset( -GetScreen()->m_Curseur.x, GetScreen()->m_Curseur.y );
|
||||
|
||||
GetScreen()->SetModify();
|
||||
|
||||
LibEntry->m_Name.m_Pos += 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();
|
||||
}
|
||||
CurrentLibEntry->SetOffset( offset );
|
||||
|
||||
/* Redraw the symbol */
|
||||
GetScreen()->m_Curseur.x = GetScreen()->m_Curseur.y = 0;
|
||||
|
|
|
@ -18,11 +18,6 @@
|
|||
#define LISTBOX_WIDTH 120
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// resources
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// USE_XPM_BITMAPS
|
||||
#include "bitmaps.h"
|
||||
|
||||
#include "id.h"
|
||||
|
@ -32,244 +27,186 @@ extern int ImportPartId;
|
|||
extern int CreateNewLibAndSavePartId;
|
||||
|
||||
|
||||
/****************************************************/
|
||||
void WinEDA_LibeditFrame::ReCreateVToolbar()
|
||||
/****************************************************/
|
||||
{
|
||||
if( m_VToolBar == NULL )
|
||||
{
|
||||
m_VToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE );
|
||||
if( m_VToolBar != NULL )
|
||||
return;
|
||||
|
||||
// Set up toolbar
|
||||
m_VToolBar->AddTool( ID_NO_SELECT_BUTT, wxEmptyString,
|
||||
wxBitmap( cursor_xpm ),
|
||||
_( "deselect current tool" ), wxITEM_CHECK );
|
||||
m_VToolBar->ToggleTool( ID_NO_SELECT_BUTT, TRUE );
|
||||
m_VToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this, ID_V_TOOLBAR, false );
|
||||
|
||||
m_VToolBar->AddSeparator();
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_PIN_BUTT, wxEmptyString,
|
||||
wxBitmap( pin_xpm ),
|
||||
_( "Add Pins" ), wxITEM_CHECK );
|
||||
// Set up toolbar
|
||||
m_VToolBar->AddTool( ID_NO_SELECT_BUTT, wxEmptyString,
|
||||
wxBitmap( cursor_xpm ),
|
||||
_( "Deselect current tool" ), wxITEM_CHECK );
|
||||
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_BODY_TEXT_BUTT, wxEmptyString,
|
||||
wxBitmap( add_text_xpm ),
|
||||
_( "Add graphic text" ), wxITEM_CHECK );
|
||||
m_VToolBar->AddSeparator();
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_PIN_BUTT, wxEmptyString,
|
||||
wxBitmap( pin_xpm ),
|
||||
_( "Add Pins" ), wxITEM_CHECK );
|
||||
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_BODY_RECT_BUTT, wxEmptyString,
|
||||
wxBitmap( add_rectangle_xpm ),
|
||||
_( "Add rectangles" ), wxITEM_CHECK );
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_BODY_TEXT_BUTT, wxEmptyString,
|
||||
wxBitmap( add_text_xpm ),
|
||||
_( "Add graphic text" ), wxITEM_CHECK );
|
||||
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_BODY_CIRCLE_BUTT, wxEmptyString,
|
||||
wxBitmap( add_circle_xpm ),
|
||||
_( "Add circles" ), wxITEM_CHECK );
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_BODY_RECT_BUTT, wxEmptyString,
|
||||
wxBitmap( add_rectangle_xpm ),
|
||||
_( "Add rectangle" ), wxITEM_CHECK );
|
||||
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_BODY_ARC_BUTT, wxEmptyString,
|
||||
wxBitmap( add_arc_xpm ),
|
||||
_( "Add arcs" ), wxITEM_CHECK );
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_BODY_CIRCLE_BUTT, wxEmptyString,
|
||||
wxBitmap( add_circle_xpm ),
|
||||
_( "Add circle" ), wxITEM_CHECK );
|
||||
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_BODY_LINE_BUTT, wxEmptyString,
|
||||
wxBitmap( add_polygon_xpm ),
|
||||
_( "Add lines and polygons" ), wxITEM_CHECK );
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_BODY_ARC_BUTT, wxEmptyString,
|
||||
wxBitmap( add_arc_xpm ),
|
||||
_( "Add arc" ), wxITEM_CHECK );
|
||||
|
||||
m_VToolBar->AddSeparator();
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_ANCHOR_ITEM_BUTT, wxEmptyString,
|
||||
wxBitmap( anchor_xpm ),
|
||||
_( "Move part anchor" ), wxITEM_CHECK );
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_BODY_LINE_BUTT, wxEmptyString,
|
||||
wxBitmap( add_polygon_xpm ),
|
||||
_( "Add lines and polygons" ), wxITEM_CHECK );
|
||||
|
||||
m_VToolBar->AddSeparator();
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_IMPORT_BODY_BUTT, wxEmptyString,
|
||||
wxBitmap( import_xpm ),
|
||||
_( "Import existing drawings" ), wxITEM_CHECK );
|
||||
m_VToolBar->AddSeparator();
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_ANCHOR_ITEM_BUTT, wxEmptyString,
|
||||
wxBitmap( anchor_xpm ),
|
||||
_( "Move part anchor" ), wxITEM_CHECK );
|
||||
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_EXPORT_BODY_BUTT, wxEmptyString,
|
||||
wxBitmap( export_xpm ),
|
||||
_( "Export current drawing" ), wxITEM_CHECK );
|
||||
m_VToolBar->AddSeparator();
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_IMPORT_BODY_BUTT, wxEmptyString,
|
||||
wxBitmap( import_xpm ),
|
||||
_( "Import existing drawings" ), wxITEM_CHECK );
|
||||
|
||||
m_VToolBar->AddSeparator();
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_DELETE_ITEM_BUTT, wxEmptyString,
|
||||
wxBitmap( delete_body_xpm ),
|
||||
_( "Delete items" ), wxITEM_CHECK );
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_EXPORT_BODY_BUTT, wxEmptyString,
|
||||
wxBitmap( export_xpm ),
|
||||
_( "Export current drawing" ), wxITEM_CHECK );
|
||||
|
||||
m_VToolBar->Realize();
|
||||
}
|
||||
m_VToolBar->AddSeparator();
|
||||
m_VToolBar->AddTool( ID_LIBEDIT_DELETE_ITEM_BUTT, wxEmptyString,
|
||||
wxBitmap( delete_body_xpm ),
|
||||
_( "Delete items" ), wxITEM_CHECK );
|
||||
|
||||
SetToolbars();
|
||||
m_VToolBar->Realize();
|
||||
}
|
||||
|
||||
|
||||
/*************************************************/
|
||||
void WinEDA_LibeditFrame::ReCreateHToolbar()
|
||||
/*************************************************/
|
||||
|
||||
/* Create or update the main Horizontal Toolbar for the schematic library editor
|
||||
*/
|
||||
{
|
||||
int ii;
|
||||
wxString msg;
|
||||
|
||||
// Create the toolbar if not exists
|
||||
if( m_HToolBar == NULL )
|
||||
{
|
||||
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
|
||||
SetToolBar( m_HToolBar );
|
||||
if( m_HToolBar != NULL )
|
||||
return;
|
||||
|
||||
// Set up toolbar
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_LIB, wxEmptyString,
|
||||
wxBitmap( save_library_xpm ),
|
||||
_( "Save current loaded library on disk (file update)" ) );
|
||||
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true );
|
||||
SetToolBar( m_HToolBar );
|
||||
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_SELECT_CURRENT_LIB, wxEmptyString, wxBitmap( library_xpm ),
|
||||
_( "Select working library" ) );
|
||||
// Set up toolbar
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_LIB, wxEmptyString,
|
||||
wxBitmap( save_library_xpm ),
|
||||
_( "Save current library to disk" ) );
|
||||
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_DELETE_PART, wxEmptyString, wxBitmap( delete_xpm ),
|
||||
_( "Delete component in current library" ) );
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_SELECT_CURRENT_LIB, wxEmptyString,
|
||||
wxBitmap( library_xpm ),
|
||||
_( "Select working library" ) );
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString, wxBitmap( new_component_xpm ),
|
||||
_( "New component" ) );
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_DELETE_PART, wxEmptyString,
|
||||
wxBitmap( delete_xpm ),
|
||||
_( "Delete component in current library" ) );
|
||||
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_SELECT_PART, wxEmptyString,
|
||||
wxBitmap( add_component_xpm ),
|
||||
_( "Select component to edit" ) );
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString,
|
||||
wxBitmap( new_component_xpm ),
|
||||
_( "New component" ) );
|
||||
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_PART, wxEmptyString,
|
||||
wxBitmap( save_part_in_mem_xpm ),
|
||||
_( "Save current component into current loaded library (in memory)" ) );
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_SELECT_PART, wxEmptyString,
|
||||
wxBitmap( add_component_xpm ),
|
||||
_( "Select component to edit" ) );
|
||||
|
||||
m_HToolBar->AddTool( ImportPartId, wxEmptyString, wxBitmap( import_xpm ),
|
||||
_( "import component" ) );
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_PART, wxEmptyString,
|
||||
wxBitmap( save_part_in_mem_xpm ),
|
||||
_( "Update current component in current library" ) );
|
||||
|
||||
m_HToolBar->AddTool( ExportPartId, wxEmptyString, wxBitmap( export_xpm ),
|
||||
_( "export component" ) );
|
||||
m_HToolBar->AddTool( ImportPartId, wxEmptyString, wxBitmap( import_xpm ),
|
||||
_( "Import component" ) );
|
||||
|
||||
m_HToolBar->AddTool( CreateNewLibAndSavePartId, wxEmptyString,
|
||||
wxBitmap( new_library_xpm ),
|
||||
_( "Create a new library an save current component into" ) );
|
||||
m_HToolBar->AddTool( ExportPartId, wxEmptyString, wxBitmap( export_xpm ),
|
||||
_( "Export component" ) );
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
msg = AddHotkeyName( _( "Undo last edition" ), s_Schematic_Hokeys_Descr, HK_UNDO );
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_UNDO, wxEmptyString, wxBitmap( undo_xpm ), msg );
|
||||
msg = AddHotkeyName( _( "Redo the last undo command" ), s_Schematic_Hokeys_Descr, HK_REDO );
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_REDO, wxEmptyString, wxBitmap( redo_xpm ), msg );
|
||||
m_HToolBar->AddTool( CreateNewLibAndSavePartId, wxEmptyString,
|
||||
wxBitmap( new_library_xpm ),
|
||||
_( "Save current component to new library" ) );
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_PART, wxEmptyString,
|
||||
wxBitmap( part_properties_xpm ),
|
||||
_( "Edit component properties" ) );
|
||||
m_HToolBar->AddSeparator();
|
||||
msg = AddHotkeyName( _( "Undo last command" ), s_Schematic_Hokeys_Descr,
|
||||
HK_UNDO );
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_UNDO, wxEmptyString, wxBitmap( undo_xpm ),
|
||||
msg );
|
||||
msg = AddHotkeyName( _( "Redo the last command" ), s_Schematic_Hokeys_Descr,
|
||||
HK_REDO );
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_REDO, wxEmptyString, wxBitmap( redo_xpm ),
|
||||
msg );
|
||||
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, wxEmptyString,
|
||||
wxBitmap( add_text_xpm ),
|
||||
_( "Add, remove fields and edit fields properties" ) );
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_PART, wxEmptyString,
|
||||
wxBitmap( part_properties_xpm ),
|
||||
_( "Edit component properties" ) );
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString,
|
||||
wxBitmap( erc_xpm ),
|
||||
_( "Test duplicate pins" ) );
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, wxEmptyString,
|
||||
wxBitmap( add_text_xpm ),
|
||||
_( "Add and remove fields and edit field properties" ) );
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
msg = AddHotkeyName( _( "Zoom in" ), s_Libedit_Hokeys_Descr, HK_ZOOM_IN );
|
||||
m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, wxBitmap( zoom_in_xpm ),
|
||||
msg );
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString,
|
||||
wxBitmap( erc_xpm ), _( "Test for duplicate pins" ) );
|
||||
|
||||
msg = AddHotkeyName( _( "Zoom out" ), s_Libedit_Hokeys_Descr, HK_ZOOM_OUT );
|
||||
m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, wxBitmap( zoom_out_xpm ),
|
||||
msg );
|
||||
m_HToolBar->AddSeparator();
|
||||
msg = AddHotkeyName( _( "Zoom in" ), s_Libedit_Hokeys_Descr, HK_ZOOM_IN );
|
||||
m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, wxBitmap( zoom_in_xpm ),
|
||||
msg );
|
||||
|
||||
msg = AddHotkeyName( _( "Redraw view" ), s_Libedit_Hokeys_Descr, HK_ZOOM_REDRAW );
|
||||
m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, wxBitmap( zoom_redraw_xpm ),
|
||||
msg );
|
||||
msg = AddHotkeyName( _( "Zoom out" ), s_Libedit_Hokeys_Descr, HK_ZOOM_OUT );
|
||||
m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, wxBitmap( zoom_out_xpm ),
|
||||
msg );
|
||||
|
||||
m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
|
||||
wxBitmap( zoom_auto_xpm ),
|
||||
_( "Zoom auto" ) );
|
||||
msg = AddHotkeyName( _( "Redraw view" ), s_Libedit_Hokeys_Descr,
|
||||
HK_ZOOM_REDRAW );
|
||||
m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
|
||||
wxBitmap( zoom_redraw_xpm ), msg );
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString,
|
||||
wxBitmap( morgan1_xpm ),
|
||||
_( "show as \"De Morgan\" normal part" ), wxITEM_CHECK );
|
||||
m_HToolBar->ToggleTool( ID_DE_MORGAN_NORMAL_BUTT,
|
||||
(CurrentConvert <= 1) ? TRUE : FALSE );
|
||||
m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
|
||||
wxBitmap( zoom_auto_xpm ), _( "Zoom page" ) );
|
||||
|
||||
m_HToolBar->AddTool( ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString,
|
||||
wxBitmap( morgan2_xpm ),
|
||||
_( "show as \"De Morgan\" convert part" ), wxITEM_CHECK );
|
||||
m_HToolBar->ToggleTool( ID_DE_MORGAN_CONVERT_BUTT,
|
||||
(CurrentConvert >= 2) ? TRUE : FALSE );
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString,
|
||||
wxBitmap( morgan1_xpm ),
|
||||
_( "Show as \"De Morgan\" normal part" ),
|
||||
wxITEM_CHECK );
|
||||
m_HToolBar->AddTool( ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString,
|
||||
wxBitmap( morgan2_xpm ),
|
||||
_( "Show as \"De Morgan\" convert part" ),
|
||||
wxITEM_CHECK );
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_VIEW_DOC, wxEmptyString,
|
||||
wxBitmap( datasheet_xpm ),
|
||||
_( "Documents" ) );
|
||||
m_HToolBar->EnableTool( ID_LIBEDIT_VIEW_DOC, FALSE );
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_VIEW_DOC, wxEmptyString,
|
||||
wxBitmap( datasheet_xpm ), _( "Edit document file" ) );
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_SelpartBox = new WinEDAChoiceBox( m_HToolBar, ID_LIBEDIT_SELECT_PART_NUMBER,
|
||||
wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ) );
|
||||
m_HToolBar->AddControl( m_SelpartBox );
|
||||
m_HToolBar->AddSeparator();
|
||||
m_SelpartBox = new WinEDAChoiceBox( m_HToolBar,
|
||||
ID_LIBEDIT_SELECT_PART_NUMBER,
|
||||
wxDefaultPosition,
|
||||
wxSize( LISTBOX_WIDTH, -1 ) );
|
||||
m_HToolBar->AddControl( m_SelpartBox );
|
||||
|
||||
m_SelAliasBox = new WinEDAChoiceBox( m_HToolBar, ID_LIBEDIT_SELECT_ALIAS,
|
||||
wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ) );
|
||||
m_HToolBar->AddControl( m_SelAliasBox );
|
||||
m_SelAliasBox = new WinEDAChoiceBox( m_HToolBar, ID_LIBEDIT_SELECT_ALIAS,
|
||||
wxDefaultPosition,
|
||||
wxSize( LISTBOX_WIDTH, -1 ) );
|
||||
m_HToolBar->AddControl( m_SelAliasBox );
|
||||
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, wxEmptyString,
|
||||
wxBitmap( pin2pin_xpm ),
|
||||
_( "Edit pins part per part (Carefully use!)" ), wxITEM_CHECK );
|
||||
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );
|
||||
m_HToolBar->AddSeparator();
|
||||
m_HToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, wxEmptyString,
|
||||
wxBitmap( pin2pin_xpm ),
|
||||
_( "Edit pins part per part ( Use carefully!)" ),
|
||||
wxITEM_CHECK );
|
||||
|
||||
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
||||
m_HToolBar->Realize();
|
||||
}
|
||||
else /* Toolbar already created, it only must be updated */
|
||||
{
|
||||
m_SelAliasBox->Clear();
|
||||
m_SelpartBox->Clear();
|
||||
}
|
||||
|
||||
/* Update the part selection box */
|
||||
int jj = 1;
|
||||
if( CurrentLibEntry )
|
||||
jj = CurrentLibEntry->m_UnitCount;
|
||||
if( jj > 1 )
|
||||
for( ii = 0; ii < jj; ii++ )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Part %c" ), 'A' + ii );
|
||||
m_SelpartBox->Append( msg );
|
||||
}
|
||||
|
||||
else
|
||||
m_SelpartBox->Append( wxEmptyString );
|
||||
m_SelpartBox->SetSelection( ( CurrentUnit > 0 ) ? CurrentUnit - 1 : 0 );
|
||||
|
||||
if( CurrentLibEntry )
|
||||
{
|
||||
if( CurrentLibEntry->m_UnitCount > 1 )
|
||||
m_SelpartBox->Enable( TRUE );
|
||||
else
|
||||
m_SelpartBox->Enable( FALSE );
|
||||
m_SelAliasBox->Append( CurrentLibEntry->m_Name.m_Text );
|
||||
m_SelAliasBox->SetSelection( 0 );
|
||||
int count = CurrentLibEntry->m_AliasList.GetCount();
|
||||
if( count > 0 ) /* Update the part selection box */
|
||||
{
|
||||
m_SelAliasBox->Enable( TRUE );
|
||||
for( ii = 0, jj = 1; ii < count; ii += ALIAS_NEXT, jj++ )
|
||||
{
|
||||
m_SelAliasBox->Append( CurrentLibEntry->m_AliasList[ii] );
|
||||
if( CurrentAliasName == CurrentLibEntry->m_AliasList[ii] )
|
||||
m_SelAliasBox->SetSelection( jj );
|
||||
}
|
||||
}
|
||||
else
|
||||
m_SelAliasBox->Enable( FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_SelAliasBox->Enable( FALSE );
|
||||
m_SelpartBox->Enable( FALSE );
|
||||
}
|
||||
|
||||
// Must be called AFTER Realize():
|
||||
SetToolbars();
|
||||
// after adding the buttons to the toolbar, must call Realize() to reflect
|
||||
// the changes
|
||||
m_HToolBar->Realize();
|
||||
}
|
||||
|
|
|
@ -17,34 +17,18 @@
|
|||
|
||||
#include "id.h"
|
||||
|
||||
/****************************************************/
|
||||
|
||||
void WinEDA_ViewlibFrame::ReCreateHToolbar()
|
||||
/****************************************************/
|
||||
{
|
||||
int ii;
|
||||
EDA_LibComponentStruct* RootLibEntry = NULL, * CurrentLibEntry = NULL;
|
||||
bool asdeMorgan = FALSE, state;
|
||||
|
||||
if( (g_CurrentViewLibraryName != wxEmptyString)
|
||||
&& (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 );
|
||||
}
|
||||
LibraryStruct* lib;
|
||||
EDA_LibComponentStruct* component = NULL;
|
||||
LibCmpEntry* entry = NULL;
|
||||
bool asdeMorgan = false;
|
||||
|
||||
if( m_HToolBar == NULL )
|
||||
{
|
||||
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN,
|
||||
this,
|
||||
ID_H_TOOLBAR,
|
||||
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR,
|
||||
TRUE );
|
||||
SetToolBar( m_HToolBar );
|
||||
|
||||
|
@ -116,11 +100,27 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
|
|||
_( "Insert component in schematic" ) );
|
||||
}
|
||||
|
||||
// after adding the buttons to the toolbar, must call Realize() to reflect
|
||||
// the changes
|
||||
// after adding the buttons to the toolbar, must call Realize() to
|
||||
// reflect the changes
|
||||
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():
|
||||
m_HToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT,
|
||||
(g_ViewConvert <= 1) ? TRUE : FALSE );
|
||||
|
@ -130,8 +130,8 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
|
|||
m_HToolBar->EnableTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, asdeMorgan );
|
||||
|
||||
int jj = 1;
|
||||
if( RootLibEntry )
|
||||
jj = MAX( RootLibEntry->m_UnitCount, 1 );
|
||||
if( component )
|
||||
jj = MAX( component->m_UnitCount, 1 );
|
||||
SelpartBox->Clear();
|
||||
for( ii = 0; ii < jj; ii++ )
|
||||
{
|
||||
|
@ -141,20 +141,13 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
|
|||
}
|
||||
|
||||
SelpartBox->SetSelection( 0 );
|
||||
state = FALSE;
|
||||
if( CurrentLibEntry && jj > 1 )
|
||||
state = TRUE;
|
||||
SelpartBox->Enable( state );
|
||||
SelpartBox->Enable( component && component->HasConversion() );
|
||||
|
||||
state = FALSE;
|
||||
if( CurrentLibEntry && (CurrentLibEntry->m_DocFile != wxEmptyString) )
|
||||
state = TRUE;
|
||||
m_HToolBar->EnableTool( ID_LIBVIEW_VIEWDOC, state );
|
||||
m_HToolBar->EnableTool( ID_LIBVIEW_VIEWDOC,
|
||||
entry && ( entry->m_DocFile != wxEmptyString ) );
|
||||
}
|
||||
|
||||
|
||||
/****************************************************/
|
||||
void WinEDA_ViewlibFrame::ReCreateVToolbar()
|
||||
/****************************************************/
|
||||
{
|
||||
}
|
||||
|
|
|
@ -277,13 +277,21 @@ int WinEDA_ViewlibFrame::BestZoom()
|
|||
{
|
||||
int bestzoom, ii, jj;
|
||||
wxSize size, itemsize;
|
||||
EDA_LibComponentStruct* CurrentLibEntry = NULL;
|
||||
EDA_LibComponentStruct* component;
|
||||
LibraryStruct* lib;
|
||||
|
||||
CurrentLibEntry =
|
||||
( EDA_LibComponentStruct* ) FindLibPart( g_CurrentViewComponentName,
|
||||
g_CurrentViewLibraryName );
|
||||
GetScreen()->m_Curseur.x = 0;
|
||||
GetScreen()->m_Curseur.y = 0;
|
||||
bestzoom = 16;
|
||||
|
||||
if( CurrentLibEntry == NULL )
|
||||
lib = FindLibrary( g_CurrentViewLibraryName );
|
||||
|
||||
if( lib == NULL )
|
||||
return bestzoom;
|
||||
|
||||
component = lib->FindComponent( g_CurrentViewComponentName );
|
||||
|
||||
if( component == NULL )
|
||||
{
|
||||
bestzoom = 16;
|
||||
GetScreen()->m_Curseur.x = 0;
|
||||
|
@ -291,14 +299,13 @@ int WinEDA_ViewlibFrame::BestZoom()
|
|||
return bestzoom;
|
||||
}
|
||||
|
||||
EDA_Rect BoundaryBox = CurrentLibEntry->GetBoundaryBox( g_ViewUnit,
|
||||
g_ViewConvert );
|
||||
EDA_Rect BoundaryBox = component->GetBoundaryBox( g_ViewUnit,
|
||||
g_ViewConvert );
|
||||
itemsize = BoundaryBox.GetSize();
|
||||
|
||||
size = DrawPanel->GetClientSize();
|
||||
size -= wxSize( 100, 100 ); // reserve a 100 mils margin
|
||||
ii = itemsize.x / size.x;
|
||||
jj = itemsize.y / size.y;
|
||||
size -= wxSize( 25, 25 ); // reserve a 25 mils margin.
|
||||
ii = wxRound( double( itemsize.x ) / double( size.x ) );
|
||||
jj = wxRound( double( itemsize.y ) / double( size.y ) );
|
||||
bestzoom = MAX( ii, jj ) + 1;
|
||||
|
||||
GetScreen()->m_Curseur = BoundaryBox.Centre();
|
||||
|
|
|
@ -172,9 +172,7 @@ void WinEDA_ViewlibFrame::SelectAndViewLibraryPart( int option )
|
|||
return;
|
||||
}
|
||||
|
||||
LibCmpEntry* LibEntry = FindLibPart( g_CurrentViewComponentName,
|
||||
g_CurrentViewLibraryName,
|
||||
ALIAS );
|
||||
LibCmpEntry* LibEntry = Lib->FindEntry( g_CurrentViewComponentName );
|
||||
|
||||
if( LibEntry == NULL )
|
||||
return;
|
||||
|
@ -258,18 +256,23 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( LibraryStruct* Lib, int Flag )
|
|||
/*****************************************************************************/
|
||||
void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
||||
{
|
||||
EDA_LibComponentStruct* LibEntry = NULL;
|
||||
LibCmpEntry* ViewCmpEntry = NULL;
|
||||
const wxChar* RootName, * CmpName;
|
||||
wxString Msg;
|
||||
EDA_LibComponentStruct* component;
|
||||
LibCmpEntry* entry;
|
||||
LibraryStruct* lib;
|
||||
wxString msg;
|
||||
wxString tmp;
|
||||
|
||||
ActiveScreen = GetScreen();
|
||||
|
||||
LibEntry =
|
||||
( EDA_LibComponentStruct* ) FindLibPart( g_CurrentViewComponentName,
|
||||
g_CurrentViewLibraryName,
|
||||
ALIAS );
|
||||
ViewCmpEntry = (LibCmpEntry*) LibEntry;
|
||||
lib = FindLibrary( g_CurrentViewLibraryName );
|
||||
|
||||
if( lib == NULL )
|
||||
return;
|
||||
|
||||
entry = lib->FindEntry( g_CurrentViewComponentName );
|
||||
|
||||
if( entry == NULL )
|
||||
return;
|
||||
|
||||
/* Forcage de la reinit de la brosse et plume courante */
|
||||
GRResetPenAndBrush( DC );
|
||||
|
@ -281,51 +284,52 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
|||
|
||||
DrawPanel->DrawBackGround( DC );
|
||||
|
||||
if( LibEntry )
|
||||
if( entry->Type != ROOT )
|
||||
{
|
||||
CmpName = LibEntry->m_Name.m_Text.GetData();
|
||||
if( LibEntry->Type != ROOT )
|
||||
{
|
||||
RootName =
|
||||
( (EDA_LibCmpAliasStruct*) LibEntry )->m_RootName.GetData();
|
||||
Msg.Printf( _( "Current Part: <%s> (is Alias of <%s>)" ),
|
||||
CmpName, RootName );
|
||||
LibEntry =
|
||||
( EDA_LibComponentStruct* ) FindLibPart( RootName,
|
||||
g_CurrentViewLibraryName,
|
||||
ROOT );
|
||||
EDA_LibCmpAliasStruct* alias = (EDA_LibCmpAliasStruct*) entry;
|
||||
|
||||
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
|
||||
component = lib->FindComponent( alias->m_RootName );
|
||||
|
||||
if( component == NULL )
|
||||
{
|
||||
Msg.Printf( _( "Current Part: <%s>" ),
|
||||
ViewCmpEntry->m_Name.m_Text.GetData() );
|
||||
LibEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_ViewUnit,
|
||||
g_ViewConvert, GR_DEFAULT_DRAWMODE );
|
||||
msg.Printf( _( "Root component <%s> for alias <%s> not found in \
|
||||
library." ),
|
||||
(const wxChar*) alias->m_RootName,
|
||||
(const wxChar*) entry->GetName(),
|
||||
(const wxChar*) lib->m_Name );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
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 );
|
||||
}
|
||||
|
|
|
@ -149,6 +149,14 @@ public:
|
|||
void CursorOff( wxDC* DC ); // remove the grid cursor from the display
|
||||
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()
|
||||
};
|
||||
|
||||
|
|
|
@ -474,9 +474,24 @@ public:
|
|||
void Process_Special_Functions( wxCommandEvent& event );
|
||||
void OnImportPart( wxCommandEvent& event );
|
||||
void OnExportPart( wxCommandEvent& event );
|
||||
void OnSelectAlias( wxCommandEvent& event );
|
||||
void OnSelectPart( wxCommandEvent& event );
|
||||
void OnEditComponentProperties( wxCommandEvent& event );
|
||||
|
||||
void OnUpdateEditingPart( 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 RedrawActiveWindow( wxDC* DC, bool EraseBg );
|
||||
void OnCloseWindow( wxCloseEvent& Event );
|
||||
|
@ -485,7 +500,6 @@ public:
|
|||
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
|
||||
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
|
||||
int BestZoom(); // Retourne le meilleur zoom
|
||||
void SetToolbars();
|
||||
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
|
||||
|
||||
SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) GetBaseScreen(); }
|
||||
|
@ -506,13 +520,13 @@ private:
|
|||
void SaveOnePartInMemory();
|
||||
void SelectActiveLibrary();
|
||||
bool LoadOneLibraryPart();
|
||||
void SaveActiveLibrary();
|
||||
void SaveActiveLibrary( wxCommandEvent& event );
|
||||
|
||||
bool LoadOneLibraryPartAux( LibCmpEntry* LibEntry,
|
||||
LibraryStruct* Library );
|
||||
|
||||
void DisplayCmpDoc( const wxString& Name );
|
||||
void InstallLibeditFrame();
|
||||
void EditComponentProperties();
|
||||
|
||||
// General editing
|
||||
public:
|
||||
|
@ -537,13 +551,15 @@ private:
|
|||
void PlaceAncre();
|
||||
|
||||
// Edition des graphismes:
|
||||
LibEDA_BaseStruct* CreateGraphicItem( EDA_LibComponentStruct * LibEntry, wxDC* DC );
|
||||
LibEDA_BaseStruct* CreateGraphicItem( EDA_LibComponentStruct* LibEntry,
|
||||
wxDC* DC );
|
||||
void GraphicItemBeginDraw( wxDC* DC );
|
||||
void StartMoveDrawSymbol( wxDC* DC );
|
||||
void EndDrawGraphicItem( wxDC* DC );
|
||||
void LoadOneSymbol();
|
||||
void SaveOneSymbol();
|
||||
void EditGraphicSymbol( wxDC* DC, LibEDA_BaseStruct* DrawItem );
|
||||
void EditGraphicSymbol( wxDC* DC,
|
||||
LibEDA_BaseStruct* DrawItem );
|
||||
void EditSymbolText( wxDC* DC, LibEDA_BaseStruct* DrawItem );
|
||||
void RotateSymbolText( wxDC* DC );
|
||||
void DeleteDrawPoly( wxDC* DC );
|
||||
|
|
Loading…
Reference in New Issue