Commit b762f6aa authored by stambaughw's avatar stambaughw

Component library editor improvements.

* Eliminate external direct manipulation of component draw item pointer.
* Add draw item remove, add, and locate methods to library component object.
* Remove redundant locate pin, field, and draw item code.
* Fix add new pin drawing bug that left initial pin draw in place.
* Improved best zoom calculations for small components.
* Library component bounding box calculation now includes fields.
* Removed unnecessary header file "libcmp.h".
* Fixed potential locate draw item bug in library editor hot key handler.
parent d1e137d6
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
#include "libcmp.h"
#include "protos.h" #include "protos.h"
/* Constructor and destructor for SCH_ITEM */ /* Constructor and destructor for SCH_ITEM */
......
...@@ -861,51 +861,47 @@ static LIB_DRAW_ITEM* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, ...@@ -861,51 +861,47 @@ static LIB_DRAW_ITEM* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
*/ */
{ {
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
static LIB_DRAW_ITEM* NextItem; static LibDrawPin* NextPin;
static int Multi, convert, TransMat[2][2]; static int Multi, convert, TransMat[2][2];
LIB_DRAW_ITEM* DEntry;
int orient; int orient;
LibDrawPin* Pin; LibDrawPin* Pin;
static wxPoint CmpPosition; static wxPoint CmpPosition;
if( aDrawLibItem ) if( aDrawLibItem )
{ {
NextItem = NULL; NextPin = NULL;
Entry = CMP_LIBRARY::FindLibraryComponent( aDrawLibItem->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( aDrawLibItem->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
return NULL; return NULL;
DEntry = Entry->m_Drawings; Pin = Entry->GetNextPin();
Multi = aDrawLibItem->m_Multi; Multi = aDrawLibItem->m_Multi;
convert = aDrawLibItem->m_Convert; convert = aDrawLibItem->m_Convert;
CmpPosition = aDrawLibItem->m_Pos; CmpPosition = aDrawLibItem->m_Pos;
memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) ); memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) );
} }
else else
DEntry = NextItem; Pin = NextPin;
for( ; DEntry != NULL; DEntry = DEntry->Next() ) for( ; Pin != NULL; NextPin = Entry->GetNextPin( Pin ) )
{ {
wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
/* Elimination des elements non relatifs a l'unite */ /* Elimination des elements non relatifs a l'unite */
if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) ) if( Multi && Pin->m_Unit && ( Pin->m_Unit != Multi ) )
continue;
if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) )
continue; continue;
if( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE ) if( convert && Pin->m_Convert && ( Pin->m_Convert != convert ) )
continue; continue;
Pin = (LibDrawPin*) DEntry;
/* Calcul de l'orientation reelle de la Pin */ /* Calcul de l'orientation reelle de la Pin */
orient = Pin->ReturnPinDrawOrient( TransMat ); orient = Pin->ReturnPinDrawOrient( TransMat );
/* Calcul de la position du point de reference */ /* Calcul de la position du point de reference */
aPosition = TransformCoordinate( TransMat, Pin->m_Pos ) + CmpPosition; aPosition = TransformCoordinate( TransMat, Pin->m_Pos ) + CmpPosition;
NextItem = DEntry->Next(); return Pin;
return DEntry;
} }
NextItem = NULL; NextPin = NULL;
return NULL; return NULL;
} }
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase ); bool erase );
static void MirrorMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset );
/* /*
...@@ -77,6 +76,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -77,6 +76,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
{ {
int ItemCount = 0; int ItemCount = 0;
int MustDoPlace = 0; int MustDoPlace = 0;
wxPoint pt;
if( GetScreen()->m_BlockLocate.GetCount() ) if( GetScreen()->m_BlockLocate.GetCount() )
{ {
...@@ -147,7 +147,9 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -147,7 +147,9 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
g_EditPinByPinIsOn ); g_EditPinByPinIsOn );
if( ItemCount ) if( ItemCount )
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
MirrorMarkedItems( m_component, GetScreen()->m_BlockLocate.Centre() ); pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1;
m_component->MirrorSelectedItemsH( pt );
break; break;
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: /* Window Zoom */
...@@ -191,7 +193,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -191,7 +193,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC ) void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
{ {
bool err = FALSE; bool err = FALSE;
wxPoint offset; wxPoint pt;
if( DrawPanel->ManageCurseur == NULL ) if( DrawPanel->ManageCurseur == NULL )
{ {
...@@ -212,18 +214,18 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -212,18 +214,18 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
offset = GetScreen()->m_BlockLocate.m_MoveVector; pt = GetScreen()->m_BlockLocate.m_MoveVector;
offset.y *= -1; pt.y *= -1;
m_component->MoveSelectedItems( offset ); m_component->MoveSelectedItems( pt );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
offset = GetScreen()->m_BlockLocate.m_MoveVector; pt = GetScreen()->m_BlockLocate.m_MoveVector;
offset.y *= -1; pt.y *= -1;
m_component->CopySelectedItems( offset ); m_component->CopySelectedItems( pt );
break; break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
...@@ -232,7 +234,9 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -232,7 +234,9 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_MIRROR_Y: /* Invert by popup menu, from block move */ case BLOCK_MIRROR_Y: /* Invert by popup menu, from block move */
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
MirrorMarkedItems( m_component, GetScreen()->m_BlockLocate.Centre() ); pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1;
m_component->MirrorSelectedItemsH( pt );
break; break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd case BLOCK_ZOOM: // Handled by HandleBlockEnd
...@@ -305,88 +309,3 @@ void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -305,88 +309,3 @@ void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
g_XorMode, -1, DefaultTransformMatrix, g_XorMode, -1, DefaultTransformMatrix,
true, true, true ); true, true, true );
} }
/*
* Mirror marked items, refer to a Vertical axis at position offset
*/
void MirrorMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset )
{
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
LIB_DRAW_ITEM* item;
if( LibEntry == NULL )
return;
offset.y = -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() )
{
if( item->m_Selected == 0 )
continue;
switch( item->Type() )
{
case COMPONENT_PIN_DRAW_TYPE:
SETMIRROR( ( (LibDrawPin*) item )->m_Pos.x );
switch( ( (LibDrawPin*) item )->m_Orient )
{
case PIN_RIGHT:
( (LibDrawPin*) item )->m_Orient = PIN_LEFT;
break;
case PIN_LEFT:
( (LibDrawPin*) item )->m_Orient = PIN_RIGHT;
break;
case PIN_UP:
case PIN_DOWN:
break;
}
break;
case COMPONENT_ARC_DRAW_TYPE:
{
SETMIRROR( ( (LibDrawArc*) item )->m_Pos.x );
SETMIRROR( ( (LibDrawArc*) item )->m_ArcStart.x );
SETMIRROR( ( (LibDrawArc*) item )->m_ArcEnd.x );
EXCHG( ( (LibDrawArc*) item )->m_ArcStart,
( (LibDrawArc*) item )->m_ArcEnd );
break;
}
case COMPONENT_CIRCLE_DRAW_TYPE:
SETMIRROR( ( (LibDrawCircle*) item )->m_Pos.x );
break;
case COMPONENT_RECT_DRAW_TYPE:
SETMIRROR( ( (LibDrawSquare*) item )->m_Pos.x );
SETMIRROR( ( (LibDrawSquare*) item )->m_End.x );
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
{
unsigned ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount();
for( ii = 0; ii < imax; ii ++ )
{
SETMIRROR( ( (LibDrawPolyline*) item )->m_PolyPoints[ii].x );
}
}
break;
case COMPONENT_LINE_DRAW_TYPE:
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
SETMIRROR( ( (LibDrawText*) item )->m_Pos.x );
break;
default:
break;
}
item->m_Flags = item->m_Selected = 0;
}
}
...@@ -226,6 +226,14 @@ void LibDrawText::DoMove( const wxPoint& newPosition ) ...@@ -226,6 +226,14 @@ void LibDrawText::DoMove( const wxPoint& newPosition )
} }
void LibDrawText::DoMirrorHorizontal( const wxPoint& center )
{
m_Pos.x -= center.x;
m_Pos.x *= -1;
m_Pos.x += center.x;
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
......
...@@ -326,7 +326,6 @@ LIB_COMPONENT::LIB_COMPONENT( const LIB_COMPONENT& component, ...@@ -326,7 +326,6 @@ LIB_COMPONENT::LIB_COMPONENT( const LIB_COMPONENT& component,
LibDrawField* oldField; LibDrawField* oldField;
LibDrawField* newField; LibDrawField* newField;
m_Prefix = component.m_Prefix; m_Prefix = component.m_Prefix;
m_AliasList = component.m_AliasList; m_AliasList = component.m_AliasList;
m_FootprintList = component.m_FootprintList; m_FootprintList = component.m_FootprintList;
...@@ -336,6 +335,7 @@ LIB_COMPONENT::LIB_COMPONENT( const LIB_COMPONENT& component, ...@@ -336,6 +335,7 @@ LIB_COMPONENT::LIB_COMPONENT( const LIB_COMPONENT& component,
m_DrawPinNum = component.m_DrawPinNum; m_DrawPinNum = component.m_DrawPinNum;
m_DrawPinName = component.m_DrawPinName; m_DrawPinName = component.m_DrawPinName;
m_LastDate = component.m_LastDate; m_LastDate = component.m_LastDate;
m_Drawings = NULL;
m_Prefix.SetParent( this ); m_Prefix.SetParent( this );
...@@ -505,24 +505,83 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item, ...@@ -505,24 +505,83 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item,
item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
DefaultTransformMatrix ); DefaultTransformMatrix );
if( m_Drawings == item ) if( item->Type() != COMPONENT_FIELD_DRAW_TYPE )
{ {
m_Drawings = item->Next(); if( m_Drawings == item )
SAFE_DELETE( item ); {
return; m_Drawings = item->Next();
} SAFE_DELETE( item );
return;
}
while( prevItem ) while( prevItem )
{
if( prevItem->Next() == item )
{
prevItem->SetNext( item->Next() );
SAFE_DELETE( item );
break;
}
prevItem = prevItem->Next();
}
}
else
{ {
if( prevItem->Next() == item ) LibDrawField* field;
for( field = m_Fields; field != NULL; field = field->Next() )
{ {
prevItem->SetNext( item->Next() ); if( field == item )
SAFE_DELETE( item ); {
break; m_Fields.Remove( field );
delete field;
break;
}
} }
}
}
prevItem = prevItem->Next(); void LIB_COMPONENT::AddDrawItem( LIB_DRAW_ITEM* item )
{
wxASSERT( item != NULL );
if( m_Drawings == NULL )
{
m_Drawings = item;
item->SetNext( NULL );
return;
} }
LIB_DRAW_ITEM* i = m_Drawings;
while( i->Next() != NULL )
i = i->Next();
i->SetNext( item );
item->SetNext( NULL );
SortDrawItems();
}
LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* item,
KICAD_T type )
{
if( type == TYPE_NOT_INIT )
return ( item == NULL ) ? m_Drawings : item->Next();
LIB_DRAW_ITEM* i = ( item == NULL ) ? m_Drawings : item->Next();
while( i != NULL )
{
if( i->Type() == type )
return i;
i = i->Next();
}
return i;
} }
...@@ -535,7 +594,7 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item, ...@@ -535,7 +594,7 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item,
bool LIB_COMPONENT::Save( FILE* aFile ) bool LIB_COMPONENT::Save( FILE* aFile )
{ {
LIB_DRAW_ITEM* DrawEntry; LIB_DRAW_ITEM* DrawEntry;
LibDrawField* Field; LibDrawField* Field;
/* Sort just in clase sorting was not done properly. */ /* Sort just in clase sorting was not done properly. */
SortDrawItems(); SortDrawItems();
...@@ -940,7 +999,7 @@ void LIB_COMPONENT::SortDrawItems() ...@@ -940,7 +999,7 @@ void LIB_COMPONENT::SortDrawItems()
if( Entry == NULL ) if( Entry == NULL )
return; /* Pas d'alias pour ce composant */ return; /* Pas d'alias pour ce composant */
/* calcul du nombre d'items */
for( nbitems = 0; Entry != NULL; Entry = Entry->Next() ) for( nbitems = 0; Entry != NULL; Entry = Entry->Next() )
nbitems++; nbitems++;
...@@ -978,23 +1037,25 @@ void LIB_COMPONENT::SortDrawItems() ...@@ -978,23 +1037,25 @@ void LIB_COMPONENT::SortDrawItems()
/**********************************************************************/ /**********************************************************************/
EDA_Rect LIB_COMPONENT::GetBoundaryBox( int Unit, int Convert ) EDA_Rect LIB_COMPONENT::GetBoundaryBox( int Unit, int Convert )
{ {
LIB_DRAW_ITEM* DrawEntry; LIB_DRAW_ITEM* item;
EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
for( DrawEntry = m_Drawings; DrawEntry != NULL; for( item = m_Drawings; item != NULL; item = item->Next() )
DrawEntry = DrawEntry->Next() )
{ {
if( DrawEntry->m_Unit > 0 ) // The item is non common to units if( ( item->m_Unit > 0 )
if( ( m_UnitCount > 1 ) && ( Unit > 0 ) && ( ( m_UnitCount > 1 ) && ( Unit > 0 )
&& ( Unit != DrawEntry->m_Unit ) ) && ( Unit != item->m_Unit ) ) )
continue; continue;
if( DrawEntry->m_Convert > 0 ) // The item is not common to all convert if( item->m_Convert > 0
if( ( Convert > 0 ) && ( Convert != DrawEntry->m_Convert ) ) && ( ( Convert > 0 ) && ( Convert != item->m_Convert ) ) )
continue; continue;
bBox.Merge( DrawEntry->GetBoundingBox() ); bBox.Merge( item->GetBoundingBox() );
} }
bBox.Merge( m_Name.GetBoundingBox() );
bBox.Merge( m_Prefix.GetBoundingBox() );
return bBox; return bBox;
} }
...@@ -1172,6 +1233,22 @@ bool LIB_COMPONENT::HasConversion() const ...@@ -1172,6 +1233,22 @@ bool LIB_COMPONENT::HasConversion() const
} }
void LIB_COMPONENT::ClearStatus( void )
{
LIB_DRAW_ITEM* item;
LibDrawField* field;
for( item = m_Drawings; item != NULL; item = item->Next() )
item->m_Flags = 0;
m_Name.m_Flags = 0;
m_Prefix.m_Flags = 0;
for( field = m_Fields.GetFirst(); field != NULL; field = field->Next() )
field->m_Flags = 0;
}
int LIB_COMPONENT::SelectItems( EDA_Rect& rect, int unit, int convert, int LIB_COMPONENT::SelectItems( EDA_Rect& rect, int unit, int convert,
bool editPinByPin ) bool editPinByPin )
{ {
...@@ -1318,3 +1395,77 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& offset ) ...@@ -1318,3 +1395,77 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& offset )
MoveSelectedItems( offset ); MoveSelectedItems( offset );
SortDrawItems(); SortDrawItems();
} }
void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& center )
{
LIB_DRAW_ITEM* item;
LibDrawField* field;
for( item = m_Drawings; item != NULL; item = item->Next() )
{
if( item->m_Selected == 0 )
continue;
item->SetOffset( center );
item->m_Flags = item->m_Selected = 0;
}
if( m_Name.m_Selected )
{
m_Name.SetOffset( center );
m_Name.m_Flags = m_Name.m_Selected = 0;
}
if( m_Prefix.m_Selected )
{
m_Prefix.SetOffset( center );
m_Prefix.m_Flags = m_Prefix.m_Selected = 0;
}
for( field = m_Fields.GetFirst(); field != NULL; field = field->Next() )
{
if( field->m_Selected )
{
field->SetOffset( center );
field->m_Flags = field->m_Selected = 0;
}
}
SortDrawItems();
}
LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert,
KICAD_T type, const wxPoint& pt )
{
LIB_DRAW_ITEM* item;
LibDrawField* field;
for( item = m_Drawings; item != NULL; item = item->Next() )
{
if( ( unit && item->m_Unit && ( unit != item->m_Unit) )
|| ( convert && item->m_Convert && ( convert != item->m_Convert ) )
|| ( ( item->Type() != type ) && ( type != TYPE_NOT_INIT ) ) )
continue;
if( item->HitTest( pt ) )
return item;
}
if( type == COMPONENT_FIELD_DRAW_TYPE || type == TYPE_NOT_INIT )
{
if( m_Name.HitTest( pt ) )
return &m_Name;
if( m_Prefix.HitTest( pt ) )
return &m_Prefix;
for( field = m_Fields.GetFirst(); field != NULL; field = field->Next() )
{
if( field->HitTest( pt ) )
return field;
}
}
return NULL;
}
...@@ -204,6 +204,13 @@ public: ...@@ -204,6 +204,13 @@ public:
bool showPinText = true, bool drawFields = true, bool showPinText = true, bool drawFields = true,
bool onlySelected = false ); bool onlySelected = false );
/**
* Add a new draw item to the draw object list.
*
* @param item - New draw object to add to component.
*/
void AddDrawItem( LIB_DRAW_ITEM* item );
/** /**
* Remove draw item from list. * Remove draw item from list.
* *
...@@ -215,6 +222,23 @@ public: ...@@ -215,6 +222,23 @@ public:
WinEDA_DrawPanel* panel = NULL, WinEDA_DrawPanel* panel = NULL,
wxDC* dc = NULL ); wxDC* dc = NULL );
/**
* Return the next draw object pointer.
*
* @param item - Pointer to the current draw item. Setting item NULL
* with return the first item of type in the list.
*
*/
LIB_DRAW_ITEM* GetNextDrawItem( LIB_DRAW_ITEM* item = NULL,
KICAD_T type = TYPE_NOT_INIT );
LibDrawPin* GetNextPin( LibDrawPin* item = NULL )
{
return (LibDrawPin*) GetNextDrawItem( (LIB_DRAW_ITEM*) item,
COMPONENT_PIN_DRAW_TYPE );
}
/** /**
* Move the component offset. * Move the component offset.
* *
...@@ -249,6 +273,11 @@ public: ...@@ -249,6 +273,11 @@ public:
return m_AliasList.Index( name ) != wxNOT_FOUND; return m_AliasList.Index( name ) != wxNOT_FOUND;
} }
/**
* Clears the status flag all draw objects in this component.
*/
void ClearStatus( void );
/** /**
* Checks all draw objects of component to see if they are with block. * Checks all draw objects of component to see if they are with block.
* *
...@@ -294,6 +323,27 @@ public: ...@@ -294,6 +323,27 @@ public:
* make sense in this context. * make sense in this context.
*/ */
void CopySelectedItems( const wxPoint& offset ); void CopySelectedItems( const wxPoint& offset );
/**
* Horizontally (X axis) mirror selected draw items about a point.
*
* @param center - Center point to mirror around.
*/
void MirrorSelectedItemsH( const wxPoint& center );
/**
* Locate a draw object.
*
* @param unit - Unit number of draw item.
* @param convert - Body style of draw item.
* @param type - Draw object type, set to 0 to search for any type.
* @param pt - Coordinate for hit testing.
*
* @return LIB_DRAW_ITEM - Pointer the the draw object if found.
* Otherwise NULL.
*/
LIB_DRAW_ITEM* LocateDrawItem( int unit, int convert, KICAD_T type,
const wxPoint& pt );
}; };
......
...@@ -437,6 +437,14 @@ void LibDrawField::DoMove( const wxPoint& newPosition ) ...@@ -437,6 +437,14 @@ void LibDrawField::DoMove( const wxPoint& newPosition )
} }
void LibDrawField::DoMirrorHorizontal( const wxPoint& center )
{
m_Pos.x -= center.x;
m_Pos.x *= -1;
m_Pos.x += center.x;
}
/* /*
* If the field is the reference, return reference like schematic, * If the field is the reference, return reference like schematic,
* i.e U -> U? or U?A or the field text for others * i.e U -> U? or U?A or the field text for others
......
...@@ -74,6 +74,13 @@ public: ...@@ -74,6 +74,13 @@ public:
int aColor, int aDrawMode, void* aData, int aColor, int aDrawMode, void* aData,
const int aTransformMatrix[2][2] ); const int aTransformMatrix[2][2] );
/**
* Return the bounding rectangle of the field text.
*
* @return EDA_Rect - Bounding rectangle.
*/
virtual EDA_Rect GetBoundingBox() { return GetTextBox(); }
/** /**
* Function HitTest * Function HitTest
* tests if the given wxPoint is within the bounds of this object. * tests if the given wxPoint is within the bounds of this object.
...@@ -82,13 +89,16 @@ public: ...@@ -82,13 +89,16 @@ public:
*/ */
bool HitTest( const wxPoint& refPos ); bool HitTest( const wxPoint& refPos );
/** Function HitTest /**
* Function HitTest
* @return true if the point aPosRef is near this object * @return true if the point aPosRef is near this object
* @param aPosRef = a wxPoint to test * @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 * @param aTransMat = the transform matrix
*/ */
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ); virtual bool HitTest( wxPoint aPosRef, int aThreshold,
const int aTransMat[2][2] );
void operator=( const LibDrawField& field ) void operator=( const LibDrawField& field )
{ {
...@@ -127,6 +137,7 @@ protected: ...@@ -127,6 +137,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition ); virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; } virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
}; };
#endif // CLASS_LIBENTRY_FIELDS_H #endif // CLASS_LIBENTRY_FIELDS_H
...@@ -1113,6 +1113,19 @@ void LibDrawPin::DoMove( const wxPoint& newPosition ) ...@@ -1113,6 +1113,19 @@ void LibDrawPin::DoMove( const wxPoint& newPosition )
} }
void LibDrawPin::DoMirrorHorizontal( const wxPoint& center )
{
m_Pos.x -= center.x;
m_Pos.x *= -1;
m_Pos.x += center.x;
if( m_Orient == PIN_RIGHT )
m_Orient = PIN_LEFT;
else if( m_Orient == PIN_LEFT )
m_Orient = PIN_RIGHT;
}
/** Function LibDrawPin::DisplayInfo /** Function LibDrawPin::DisplayInfo
* Displays info (pin num and name, orientation ... * Displays info (pin num and name, orientation ...
* on the Info window * on the Info window
......
...@@ -45,8 +45,8 @@ void CreateDummyCmp() ...@@ -45,8 +45,8 @@ void CreateDummyCmp()
Text->m_Size.x = Text->m_Size.y = 150; Text->m_Size.x = Text->m_Size.y = 150;
Text->m_Text = wxT( "??" ); Text->m_Text = wxT( "??" );
DummyCmp->m_Drawings = Square; DummyCmp->AddDrawItem( Square );
Square->SetNext( Text ); DummyCmp->AddDrawItem( Text );
} }
......
...@@ -311,6 +311,21 @@ void LibDrawArc::DoMove( const wxPoint& newPosition ) ...@@ -311,6 +311,21 @@ void LibDrawArc::DoMove( const wxPoint& newPosition )
} }
void LibDrawArc::DoMirrorHorizontal( const wxPoint& center )
{
m_Pos.x -= center.x;
m_Pos.x *= -1;
m_Pos.x += center.x;
m_ArcStart.x -= center.x;
m_ArcStart.x *= -1;
m_ArcStart.x += center.x;
m_ArcEnd.x -= center.x;
m_ArcEnd.x *= -1;
m_ArcEnd.x += center.x;
EXCHG( m_ArcStart, m_ArcEnd );
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
...@@ -608,6 +623,14 @@ void LibDrawCircle::DoMove( const wxPoint& newPosition ) ...@@ -608,6 +623,14 @@ void LibDrawCircle::DoMove( const wxPoint& newPosition )
} }
void LibDrawCircle::DoMirrorHorizontal( const wxPoint& center )
{
m_Pos.x -= center.x;
m_Pos.x *= -1;
m_Pos.x += center.x;
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
...@@ -793,6 +816,17 @@ void LibDrawSquare::DoMove( const wxPoint& newPosition ) ...@@ -793,6 +816,17 @@ void LibDrawSquare::DoMove( const wxPoint& newPosition )
} }
void LibDrawSquare::DoMirrorHorizontal( const wxPoint& center )
{
m_Pos.x -= center.x;
m_Pos.x *= -1;
m_Pos.x += center.x;
m_End.x -= center.x;
m_End.x *= -1;
m_End.x += center.x;
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
...@@ -1006,6 +1040,17 @@ void LibDrawSegment::DoMove( const wxPoint& newPosition ) ...@@ -1006,6 +1040,17 @@ void LibDrawSegment::DoMove( const wxPoint& newPosition )
} }
void LibDrawSegment::DoMirrorHorizontal( const wxPoint& center )
{
m_Pos.x -= center.x;
m_Pos.x *= -1;
m_Pos.x += center.x;
m_End.x -= center.x;
m_End.x *= -1;
m_End.x += center.x;
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
...@@ -1255,6 +1300,19 @@ void LibDrawPolyline::DoMove( const wxPoint& newPosition ) ...@@ -1255,6 +1300,19 @@ void LibDrawPolyline::DoMove( const wxPoint& newPosition )
} }
void LibDrawPolyline::DoMirrorHorizontal( const wxPoint& center )
{
size_t i, imax = m_PolyPoints.size();
for( i = 0; i < imax; i++ )
{
m_PolyPoints[i].x -= center.x;
m_PolyPoints[i].x *= -1;
m_PolyPoints[i].x += center.x;
}
}
void LibDrawPolyline::AddPoint( const wxPoint& point ) void LibDrawPolyline::AddPoint( const wxPoint& point )
{ {
m_PolyPoints.push_back( point ); m_PolyPoints.push_back( point );
...@@ -1580,6 +1638,27 @@ void LibDrawBezier::DoMove( const wxPoint& newPosition ) ...@@ -1580,6 +1638,27 @@ void LibDrawBezier::DoMove( const wxPoint& newPosition )
} }
void LibDrawBezier::DoMirrorHorizontal( const wxPoint& center )
{
size_t i, imax = m_PolyPoints.size();
for( i = 0; i < imax; i++ )
{
m_PolyPoints[i].x -= center.x;
m_PolyPoints[i].x *= -1;
m_PolyPoints[i].x += center.x;
}
imax = m_BezierPoints.size();
for( i = 0; i < imax; i++ )
{
m_BezierPoints[i].x -= center.x;
m_BezierPoints[i].x *= -1;
m_BezierPoints[i].x += center.x;
}
}
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
......
...@@ -114,7 +114,9 @@ public: ...@@ -114,7 +114,9 @@ public:
LIB_DRAW_ITEM( const LIB_DRAW_ITEM& item ); LIB_DRAW_ITEM( const LIB_DRAW_ITEM& item );
virtual ~LIB_DRAW_ITEM() { } virtual ~LIB_DRAW_ITEM() { }
/** Function Draw (virtual pure) /**
* Function Draw (virtual pure)
*
* Draw A body item * Draw A body item
* @param aPanel = DrawPanel to use (can be null) mainly used for clipping * @param aPanel = DrawPanel to use (can be null) mainly used for clipping
* purposes * purposes
...@@ -241,6 +243,16 @@ public: ...@@ -241,6 +243,16 @@ public:
*/ */
wxPoint GetPosition( void ) { return DoGetPosition(); } wxPoint GetPosition( void ) { return DoGetPosition(); }
/**
* Mirror the draw object along the horizontal (X) axis about a point.
*
* @param center - Point to mirror around.
*/
void MirrorHorizontal( const wxPoint& center )
{
DoMirrorHorizontal( center );
}
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy() = 0; virtual LIB_DRAW_ITEM* DoGenCopy() = 0;
...@@ -254,6 +266,7 @@ protected: ...@@ -254,6 +266,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect ) = 0; virtual bool DoTestInside( EDA_Rect& rect ) = 0;
virtual void DoMove( const wxPoint& newPosition ) = 0; virtual void DoMove( const wxPoint& newPosition ) = 0;
virtual wxPoint DoGetPosition( void ) = 0; virtual wxPoint DoGetPosition( void ) = 0;
virtual void DoMirrorHorizontal( const wxPoint& center ) = 0;
}; };
...@@ -387,6 +400,7 @@ protected: ...@@ -387,6 +400,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition ); virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; } virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
}; };
...@@ -462,6 +476,7 @@ protected: ...@@ -462,6 +476,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition ); virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; } virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
}; };
...@@ -533,6 +548,7 @@ protected: ...@@ -533,6 +548,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition ); virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; } virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
}; };
...@@ -611,6 +627,7 @@ protected: ...@@ -611,6 +627,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition ); virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; } virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
}; };
...@@ -681,6 +698,7 @@ protected: ...@@ -681,6 +698,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition ); virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; } virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
}; };
/**********************************/ /**********************************/
...@@ -750,6 +768,7 @@ protected: ...@@ -750,6 +768,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition ); virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; } virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
}; };
...@@ -830,6 +849,7 @@ protected: ...@@ -830,6 +849,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition ); virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_PolyPoints[0]; } virtual wxPoint DoGetPosition( void ) { return m_PolyPoints[0]; }
virtual void DoMirrorHorizontal( const wxPoint& center );
}; };
/**********************************************************/ /**********************************************************/
...@@ -910,6 +930,7 @@ protected: ...@@ -910,6 +930,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect ); virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition ); virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_PolyPoints[0]; } virtual wxPoint DoGetPosition( void ) { return m_PolyPoints[0]; }
virtual void DoMirrorHorizontal( const wxPoint& center );
}; };
#endif // CLASSES_BODY_ITEMS_H #endif // CLASSES_BODY_ITEMS_H
...@@ -215,9 +215,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin ...@@ -215,9 +215,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
} }
/*************************************************************************************/ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ) wxPoint MousePositionInPixels )
/*************************************************************************************/
{ {
wxRealPoint delta; wxRealPoint delta;
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
...@@ -309,11 +308,10 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPi ...@@ -309,11 +308,10 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPi
} }
/*************************************************************************************/ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ) wxPoint MousePositionInPixels )
/*************************************************************************************/
{ {
wxRealPoint delta; wxRealPoint delta;
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
wxPoint curpos, oldpos; wxPoint curpos, oldpos;
int hotkey = 0; int hotkey = 0;
...@@ -402,11 +400,10 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe ...@@ -402,11 +400,10 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe
} }
/*****************************************************************************/
void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
wxPoint MousePositionInPixels ) wxPoint MousePositionInPixels )
{ {
wxRealPoint delta; wxRealPoint delta;
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
wxPoint curpos, oldpos; wxPoint curpos, oldpos;
int hotkey = 0; int hotkey = 0;
......
...@@ -392,20 +392,17 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ) ...@@ -392,20 +392,17 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
if( Entry == NULL ) if( Entry == NULL )
break; break;
LIB_DRAW_ITEM* DrawLibItem = Entry->m_Drawings; for( LibDrawPin* Pin = Entry->GetNextPin(); Pin != NULL;
for( ; DrawLibItem != NULL; DrawLibItem = DrawLibItem->Next() ) Pin = Entry->GetNextPin( Pin ) )
{ {
if( DrawLibItem->Type() != COMPONENT_PIN_DRAW_TYPE ) wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
continue;
LibDrawPin* Pin = (LibDrawPin*) DrawLibItem;
if( Pin->m_Unit && DrawLibItem->m_Unit if( Pin->m_Unit && STRUCT->m_Multi
&& (DrawLibItem->m_Unit != Pin->m_Unit) ) && ( STRUCT->m_Multi != Pin->m_Unit ) )
continue; continue;
if( Pin->m_Convert && DrawLibItem->m_Convert if( Pin->m_Convert && STRUCT->m_Convert
&& (DrawLibItem->m_Convert != Pin->m_Convert) ) && ( STRUCT->m_Convert != Pin->m_Convert ) )
continue; continue;
item = new DanglingEndHandle( PIN_END ); item = new DanglingEndHandle( PIN_END );
......
...@@ -680,7 +680,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() ...@@ -680,7 +680,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
convertCheckBox->SetValue( true ); convertCheckBox->SetValue( true );
} }
if( m_LibEntry == NULL || LookForConvertPart( m_LibEntry ) <= 1 ) if( m_LibEntry == NULL || !m_LibEntry->HasConversion() )
{ {
convertCheckBox->Enable( false ); convertCheckBox->Enable( false );
} }
......
...@@ -377,7 +377,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit ) ...@@ -377,7 +377,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
/* Traitement des unites enlevees ou rajoutees */ /* Traitement des unites enlevees ou rajoutees */
if( OldNumUnits > component->m_UnitCount ) if( OldNumUnits > component->m_UnitCount )
{ {
DrawItem = component->m_Drawings; DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = NextDrawItem ) for( ; DrawItem != NULL; DrawItem = NextDrawItem )
{ {
NextDrawItem = DrawItem->Next(); NextDrawItem = DrawItem->Next();
...@@ -410,7 +410,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit ) ...@@ -410,7 +410,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
if( OldNumUnits < component->m_UnitCount ) if( OldNumUnits < component->m_UnitCount )
{ {
DrawItem = component->m_Drawings; DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() ) for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
{ {
/* Duplication des items pour autres elements */ /* Duplication des items pour autres elements */
...@@ -419,13 +419,13 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit ) ...@@ -419,13 +419,13 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
for( ii = OldNumUnits + 1; ii <= MaxUnit; ii++ ) for( ii = OldNumUnits + 1; ii <= MaxUnit; ii++ )
{ {
NextDrawItem = DrawItem->GenCopy(); NextDrawItem = DrawItem->GenCopy();
NextDrawItem->SetNext( component->m_Drawings );
component->m_Drawings = NextDrawItem;
NextDrawItem->m_Unit = ii; NextDrawItem->m_Unit = ii;
component->AddDrawItem( NextDrawItem );
} }
} }
} }
} }
return TRUE; return TRUE;
} }
...@@ -446,7 +446,8 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert() ...@@ -446,7 +446,8 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
{ {
/* Traitement des elements a ajouter ( pins seulement ) */ /* Traitement des elements a ajouter ( pins seulement ) */
if( component ) if( component )
DrawItem = component->m_Drawings; DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() ) for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
{ {
/* Duplication des items pour autres elements */ /* Duplication des items pour autres elements */
...@@ -456,7 +457,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert() ...@@ -456,7 +457,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
{ {
if( FlagDel == 0 ) if( FlagDel == 0 )
{ {
if( IsOK( this, _( "Create pins for Convert items" ) ) ) if( IsOK( this, _( "Create pins for convert items." ) ) )
FlagDel = 1; FlagDel = 1;
else else
{ {
...@@ -467,10 +468,10 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert() ...@@ -467,10 +468,10 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
return FALSE; return FALSE;
} }
} }
NextDrawItem = DrawItem->GenCopy(); NextDrawItem = DrawItem->GenCopy();
NextDrawItem->SetNext( component->m_Drawings ); NextDrawItem->m_Convert = 2;
component->m_Drawings = NextDrawItem; component->AddDrawItem( NextDrawItem );
NextDrawItem->m_Convert = 2;
} }
} }
} }
...@@ -478,7 +479,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert() ...@@ -478,7 +479,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
{ {
/* Traitement des elements � supprimer */ /* Traitement des elements � supprimer */
if( component ) if( component )
DrawItem = component->m_Drawings; DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = NextDrawItem ) for( ; DrawItem != NULL; DrawItem = NextDrawItem )
{ {
NextDrawItem = DrawItem->Next(); NextDrawItem = DrawItem->Next();
......
...@@ -402,7 +402,7 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent, ...@@ -402,7 +402,7 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
if( LibEntry == NULL ) if( LibEntry == NULL )
return; return;
if( ( ii = LookForConvertPart( LibEntry ) ) < 2 ) if( !LibEntry->HasConversion() )
{ {
DisplayError( this, wxT( "No convert found" ) ); DisplayError( this, wxT( "No convert found" ) );
return; return;
...@@ -430,32 +430,6 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent, ...@@ -430,32 +430,6 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
} }
/*
* Retourne la plus grande valeur trouvee dans la liste des elements
* "drawings" du composant LibEntry, pour le membre .Convert
* Si il n'y a pas de representation type "convert", la valeur
* retournee est 0 ou 1
* Si il y a une representation type "convert",
* la valeur retournee est > 1 (typiquement 2)
*/
int LookForConvertPart( LIB_COMPONENT* LibEntry )
{
int ii;
LIB_DRAW_ITEM* DrawLibEntry;
DrawLibEntry = LibEntry->m_Drawings;
ii = 0;
while( DrawLibEntry )
{
if( ii < DrawLibEntry->m_Convert )
ii = DrawLibEntry->m_Convert;
DrawLibEntry = DrawLibEntry->Next();
}
return ii;
}
void WinEDA_SchematicFrame::StartMovePart( SCH_COMPONENT* Component, void WinEDA_SchematicFrame::StartMovePart( SCH_COMPONENT* Component,
wxDC* DC ) wxDC* DC )
{ {
......
...@@ -471,16 +471,13 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -471,16 +471,13 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
cmd.SetEventObject( this ); cmd.SetEventObject( this );
wxPoint MousePos = GetScreen()->m_MousePosition;
bool ItemInEdit = GetScreen()->GetCurItem() bool ItemInEdit = GetScreen()->GetCurItem()
&& GetScreen()->GetCurItem()->m_Flags; && GetScreen()->GetCurItem()->m_Flags;
if( hotkey == 0 ) if( hotkey == 0 )
return; return;
wxPoint MousePos = GetScreen()->m_MousePosition;
LIB_DRAW_ITEM* DrawEntry = LocateItemUsingCursor();
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to // Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to
// handle...) // handle...)
if( (hotkey & GR_KB_CTRL) != 0 ) if( (hotkey & GR_KB_CTRL) != 0 )
...@@ -564,18 +561,16 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -564,18 +561,16 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_EDIT_PIN: case HK_EDIT_PIN:
if( DrawEntry ) m_drawItem = LocateItemUsingCursor();
m_drawItem = DrawEntry;
if( m_drawItem ) if( m_drawItem && m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
{ InstallPineditFrame( this, DC, MousePos );
if( m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
InstallPineditFrame( this, DC, MousePos );
}
break; break;
case HK_DELETE_PIN: case HK_DELETE_PIN:
if( DrawEntry ) m_drawItem = LocateItemUsingCursor();
m_drawItem = DrawEntry;
if( m_drawItem ) if( m_drawItem )
{ {
wxCommandEvent evt; wxCommandEvent evt;
...@@ -585,8 +580,8 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -585,8 +580,8 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_MOVE_PIN: case HK_MOVE_PIN:
if( DrawEntry ) m_drawItem = LocateItemUsingCursor();
m_drawItem = DrawEntry;
if( m_drawItem ) if( m_drawItem )
{ {
wxCommandEvent evt; wxCommandEvent evt;
......
/*****************************************************************/
/* Headers for library definition and lib component definitions */
/*****************************************************************/
#ifndef LIBCMP_H
#define LIBCMP_H
enum LocateDrawStructType
{
LOCATE_COMPONENT_ARC_DRAW_TYPE = 1,
LOCATE_COMPONENT_CIRCLE_DRAW_TYPE = 2,
LOCATE_COMPONENT_GRAPHIC_TEXT_DRAW_TYPE = 4,
LOCATE_COMPONENT_RECT_DRAW_TYPE = 8,
LOCATE_LINE_DRAW_TYPE = 0x10,
LOCATE_COMPONENT_POLYLINE_DRAW_TYPE = 0x20,
LOCATE_COMPONENT_LINE_DRAW_TYPE = 0x40
};
#define LOCATE_ALL_DRAW_ITEM 0xFFFFFFFF
#endif // LIBCMP_H
...@@ -179,7 +179,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry, ...@@ -179,7 +179,7 @@ bool WinEDA_LibeditFrame::LoadOneLibraryPartAux( CMP_LIB_ENTRY* LibEntry,
m_showDeMorgan = false; m_showDeMorgan = false;
if( LookForConvertPart( m_component ) > 1 ) if( m_component->HasConversion() )
m_showDeMorgan = true; m_showDeMorgan = true;
GetBaseScreen()->ClrModify(); GetBaseScreen()->ClrModify();
...@@ -265,7 +265,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event ) ...@@ -265,7 +265,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
bool success = m_library->Save( fn.GetFullPath() ); bool success = m_library->Save( fn.GetFullPath(), true );
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
#include "libcmp.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_libentry.h" #include "class_libentry.h"
...@@ -51,25 +50,16 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -51,25 +50,16 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
} }
else else
{ {
DrawEntry = LocatePin( GetScreen()->m_MousePosition, m_component, DrawEntry =
m_unit, m_convert ); m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
if( DrawEntry == NULL ) GetScreen()->m_MousePosition );
{
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(),
GetScreen()->m_MousePosition,
m_component, m_unit, m_convert,
LOCATE_ALL_DRAW_ITEM );
}
if( DrawEntry == NULL )
DrawEntry = LocatePin( GetScreen()->m_Curseur, m_component,
m_unit, m_convert );
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(), DrawEntry =
GetScreen()->m_Curseur, m_component->LocateDrawItem( m_unit, m_convert,
m_component, m_unit, m_convert, TYPE_NOT_INIT,
LOCATE_ALL_DRAW_ITEM ); GetScreen()->m_Curseur );
} }
if( DrawEntry ) if( DrawEntry )
...@@ -121,26 +111,16 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -121,26 +111,16 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_LIBEDIT_DELETE_ITEM_BUTT: case ID_LIBEDIT_DELETE_ITEM_BUTT:
DrawEntry = LocatePin( GetScreen()->m_MousePosition, m_component, DrawEntry =
m_unit, m_convert ); m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
if( DrawEntry == NULL ) GetScreen()->m_MousePosition );
{
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(),
GetScreen()->m_MousePosition,
m_component, m_unit, m_convert,
LOCATE_ALL_DRAW_ITEM );
}
if( DrawEntry == NULL )
DrawEntry = LocatePin( GetScreen()->m_Curseur,
m_component, m_unit,
m_convert );
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(), DrawEntry =
GetScreen()->m_Curseur, m_component->LocateDrawItem( m_unit, m_convert,
m_component, m_unit, m_convert, TYPE_NOT_INIT,
LOCATE_ALL_DRAW_ITEM ); GetScreen()->m_Curseur );
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
DisplayCmpDoc(); DisplayCmpDoc();
...@@ -185,29 +165,14 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -185,29 +165,14 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
if( ( DrawEntry == NULL ) || ( DrawEntry->m_Flags == 0 ) ) if( ( DrawEntry == NULL ) || ( DrawEntry->m_Flags == 0 ) )
{ // We can locate an item { // We can locate an item
DrawEntry = LocatePin( GetScreen()->m_MousePosition, m_component, DrawEntry = m_drawItem =
m_unit, m_convert ); m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
if( DrawEntry == NULL ) GetScreen()->m_MousePosition );
DrawEntry = LocatePin( GetScreen()->m_Curseur, m_component,
m_unit, m_convert );
if( DrawEntry == NULL )
{
DrawEntry = m_drawItem =
LocateDrawItem( (SCH_SCREEN*) GetScreen(),
GetScreen()->m_MousePosition, m_component,
m_unit, m_convert, LOCATE_ALL_DRAW_ITEM );
}
if( DrawEntry == NULL )
{
DrawEntry = m_drawItem =
LocateDrawItem( (SCH_SCREEN*) GetScreen(),
GetScreen()->m_Curseur, m_component, m_unit,
m_convert, LOCATE_ALL_DRAW_ITEM );
}
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = m_drawItem = DrawEntry = m_drawItem =
(LIB_DRAW_ITEM*) LocateField( m_component ); m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->m_Curseur );
} }
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
......
...@@ -31,9 +31,9 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, ...@@ -31,9 +31,9 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
ITEM_PICKER wrapper(CopyItem, UR_LIBEDIT); ITEM_PICKER wrapper(CopyItem, UR_LIBEDIT);
lastcmd->PushItem(wrapper); lastcmd->PushItem(wrapper);
GetScreen()->PushCommandToUndoList( lastcmd ); GetScreen()->PushCommandToUndoList( lastcmd );
/* Clear current flags (which can be temporary set by a current edit command) */ /* Clear current flags (which can be temporary set by a current edit
for( item = CopyItem->m_Drawings; item != NULL; item = item->Next() ) * command) */
item->m_Flags = 0; CopyItem->ClearStatus();
/* Clear redo list, because after new save there is no redo to do */ /* Clear redo list, because after new save there is no redo to do */
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList ); GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
......
...@@ -110,10 +110,7 @@ public: ...@@ -110,10 +110,7 @@ public:
LIB_DRAW_ITEM* GetDrawItem( void ) { return m_drawItem; } LIB_DRAW_ITEM* GetDrawItem( void ) { return m_drawItem; }
void SetDrawItem( LIB_DRAW_ITEM* drawItem ) void SetDrawItem( LIB_DRAW_ITEM* drawItem );
{
m_drawItem = drawItem;
}
bool GetShowDeMorgan( void ) { return m_showDeMorgan; } bool GetShowDeMorgan( void ) { return m_showDeMorgan; }
...@@ -163,7 +160,6 @@ private: ...@@ -163,7 +160,6 @@ private:
void EditSymbolText( wxDC* DC, LIB_DRAW_ITEM* DrawItem ); void EditSymbolText( wxDC* DC, LIB_DRAW_ITEM* DrawItem );
void RotateSymbolText( wxDC* DC ); void RotateSymbolText( wxDC* DC );
void DeleteDrawPoly( wxDC* DC ); void DeleteDrawPoly( wxDC* DC );
LibDrawField* LocateField( LIB_COMPONENT* LibEntry );
LIB_DRAW_ITEM* LocateItemUsingCursor(); LIB_DRAW_ITEM* LocateItemUsingCursor();
void RotateField( wxDC* DC, LibDrawField* Field ); void RotateField( wxDC* DC, LibDrawField* Field );
void PlaceField( wxDC* DC, LibDrawField* Field ); void PlaceField( wxDC* DC, LibDrawField* Field );
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
#include "libcmp.h"
#include "protos.h" #include "protos.h"
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_library.h" #include "class_library.h"
...@@ -263,38 +262,6 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field ) ...@@ -263,38 +262,6 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field )
} }
/*
* Locate the component fiels (ref, name or auxiliary fields) under the
* mouse cursor
* return:
* pointer on the field (or NULL )
*/
LibDrawField* WinEDA_LibeditFrame::LocateField( LIB_COMPONENT* LibEntry )
{
wxPoint refpos = GetScreen()->m_Curseur;
/* Test reference */
if( LibEntry->m_Name.HitTest( refpos ) )
return &LibEntry->m_Name;
/* Test Prefix */
if( LibEntry->m_Prefix.HitTest( refpos ) )
return &LibEntry->m_Prefix;
/* Test others fields */
for( LibDrawField* field = LibEntry->m_Fields; field != NULL;
field = field->Next() )
{
if( field->m_Text.IsEmpty() )
continue;
if( field->HitTest( refpos ) )
return field;
}
return NULL;
}
LIB_DRAW_ITEM* WinEDA_LibeditFrame::LocateItemUsingCursor() LIB_DRAW_ITEM* WinEDA_LibeditFrame::LocateItemUsingCursor()
{ {
LIB_DRAW_ITEM* DrawEntry = m_drawItem; LIB_DRAW_ITEM* DrawEntry = m_drawItem;
...@@ -304,26 +271,15 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::LocateItemUsingCursor() ...@@ -304,26 +271,15 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::LocateItemUsingCursor()
if( ( DrawEntry == NULL ) || ( DrawEntry->m_Flags == 0 ) ) if( ( DrawEntry == NULL ) || ( DrawEntry->m_Flags == 0 ) )
{ {
DrawEntry = LocatePin( GetScreen()->m_Curseur, m_component, DrawEntry = m_drawItem =
m_unit, m_convert ); m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
if( DrawEntry == NULL ) GetScreen()->m_MousePosition );
{
DrawEntry = m_drawItem =
LocateDrawItem( (SCH_SCREEN*) GetScreen(),
GetScreen()->m_MousePosition, m_component,
m_unit, m_convert, LOCATE_ALL_DRAW_ITEM );
}
if( DrawEntry == NULL )
{
DrawEntry = m_drawItem =
LocateDrawItem( (SCH_SCREEN*) GetScreen(),
GetScreen()->m_Curseur, m_component,
m_unit, m_convert, LOCATE_ALL_DRAW_ITEM );
}
if( DrawEntry == NULL ) if( DrawEntry == NULL )
{ {
DrawEntry = m_drawItem = DrawEntry = m_drawItem =
(LIB_DRAW_ITEM*) LocateField( m_component ); m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->m_Curseur );
} }
} }
......
...@@ -203,6 +203,12 @@ void WinEDA_LibeditFrame::LoadSettings() ...@@ -203,6 +203,12 @@ void WinEDA_LibeditFrame::LoadSettings()
} }
void WinEDA_LibeditFrame::SetDrawItem( LIB_DRAW_ITEM* drawItem )
{
m_drawItem = drawItem;
}
/** /**
* Save library editor frame specific configuration settings. * Save library editor frame specific configuration settings.
* *
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "trigo.h" #include "trigo.h"
#include "macros.h" #include "macros.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
#include "protos.h" #include "protos.h"
...@@ -25,13 +24,14 @@ static bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, ...@@ -25,13 +24,14 @@ static bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
SCH_ITEM* DrawList, double aScaleFactor ); SCH_ITEM* DrawList, double aScaleFactor );
/*********************************************************************/ /**
SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen ) * Search the smaller (considering its area) component under the mouse
/*********************************************************************/ * cursor or the pcb cursor
*
/* Search the smaller (considering its area) component under the mouse cursor or the pcb cursor * If more than 1 component is found, a pointer to the smaller component is
* If more than 1 component is found, a pointer to the smaller component is returned * returned
*/ */
SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen )
{ {
SCH_COMPONENT* component = NULL, * lastcomponent = NULL; SCH_COMPONENT* component = NULL, * lastcomponent = NULL;
SCH_ITEM* DrawList; SCH_ITEM* DrawList;
...@@ -111,7 +111,8 @@ SCH_ITEM* PickStruct( const wxPoint& refpos, BASE_SCREEN* screen, int SearchMask ...@@ -111,7 +111,8 @@ SCH_ITEM* PickStruct( const wxPoint& refpos, BASE_SCREEN* screen, int SearchMask
return NULL; return NULL;
if( ( Snapped = SnapPoint2( refpos, SearchMask, if( ( Snapped = SnapPoint2( refpos, SearchMask,
screen->EEDrawList, screen->GetScalingFactor() ) ) != FALSE ) screen->EEDrawList,
screen->GetScalingFactor() ) ) != FALSE )
{ {
return LastSnappedStruct; return LastSnappedStruct;
} }
...@@ -162,12 +163,12 @@ int PickItemsInBlock( BLOCK_SELECTOR& aBlock, BASE_SCREEN* aScreen ) ...@@ -162,12 +163,12 @@ int PickItemsInBlock( BLOCK_SELECTOR& aBlock, BASE_SCREEN* aScreen )
/***************************************************************************** /*****************************************************************************
* Routine to search all objects for the closest point to a given point, in * * Routine to search all objects for the closest point to a given point, in *
* drawing space, and snap it to that points if closer than SnapDistance. * * drawing space, and snap it to that points if closer than SnapDistance. *
* Note we use L1 norm as distance measure, as it is the fastest. * * Note we use L1 norm as distance measure, as it is the fastest. *
* This routine updates LastSnappedStruct to the last object used in to snap * * This routine updates LastSnappedStruct to the last object used in to snap *
* a point. This variable is global to this module only (see above). * * a point. This variable is global to this module only (see above). *
* The routine returns TRUE if point was snapped. * * The routine returns TRUE if point was snapped. *
*****************************************************************************/ *****************************************************************************/
bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
SCH_ITEM* DrawList, double aScaleFactor ) SCH_ITEM* DrawList, double aScaleFactor )
...@@ -371,9 +372,9 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, ...@@ -371,9 +372,9 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
/***************************************************************************** /*****************************************************************************
* Routine to test if an object has non empty intersection with the box * * Routine to test if an object has non empty intersection with the box *
* defined by x1/y1 and x2/y2 (x1 < x2, y1 < y2), and return TRUE if so. This * * defined by x1/y1 and x2/y2 (x1 < x2, y1 < y2), and return TRUE if so. This *
* routine is used to pick all points in a given box. * * routine is used to pick all points in a given box. *
*****************************************************************************/ *****************************************************************************/
bool DrawStructInBox( int x1, int y1, int x2, int y2, SCH_ITEM* DrawStruct ) bool DrawStructInBox( int x1, int y1, int x2, int y2, SCH_ITEM* DrawStruct )
{ {
...@@ -613,114 +614,15 @@ static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1, ...@@ -613,114 +614,15 @@ static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
} }
/**
/*********************************************************************************/ * Find a PIN in a component
LIB_DRAW_ITEM* LocateDrawItem( SCH_SCREEN* Screen,
const wxPoint& aRefPoint,
LIB_COMPONENT* LibEntry,
int Unit,
int Convert,
int masque )
/*********************************************************************************/
/* Locates a body item( not pins )
* Unit = part number (if Unit = 0, all parts are considered)
* Convert = convert value for shape (si Convert = 0, all shapes are considered)
* remember the Y axis is from bottom to top in library entries for graphic items.
*/
{
LIB_DRAW_ITEM* DrawItem;
if( LibEntry == NULL )
return NULL;
if( LibEntry->Type != ROOT )
{
wxMessageBox( wxT( "Error in LocateDrawItem: Entry is ALIAS" ) );
return NULL;
}
DrawItem = LibEntry->m_Drawings;
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
{
if( Unit && DrawItem->m_Unit && (Unit != DrawItem->m_Unit) )
continue;
if( Convert && DrawItem->m_Convert && (Convert != DrawItem->m_Convert) )
continue;
switch( DrawItem->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
if( (masque & LOCATE_COMPONENT_ARC_DRAW_TYPE) == 0 )
break;
if( DrawItem->HitTest( aRefPoint ) )
return DrawItem;
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
if( (masque & LOCATE_COMPONENT_CIRCLE_DRAW_TYPE) == 0 )
break;
if( DrawItem->HitTest( aRefPoint ) )
return DrawItem;
break;
case COMPONENT_RECT_DRAW_TYPE: // Locate a rect if the mouse cursor is on a side of this rectangle
if( (masque & LOCATE_COMPONENT_RECT_DRAW_TYPE) == 0 )
break;
if( DrawItem->HitTest( aRefPoint ) )
return DrawItem;
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
if( (masque & LOCATE_COMPONENT_POLYLINE_DRAW_TYPE) == 0 )
break;
if( DrawItem->HitTest( aRefPoint ) )
return DrawItem;
break;
case COMPONENT_BEZIER_DRAW_TYPE:
if( (masque & LOCATE_COMPONENT_POLYLINE_DRAW_TYPE) == 0 )
break;
if( DrawItem->HitTest( aRefPoint ) )
return DrawItem;
break;
case COMPONENT_LINE_DRAW_TYPE:
if( (masque & LOCATE_COMPONENT_LINE_DRAW_TYPE) == 0 )
break;
if( DrawItem->HitTest( aRefPoint ) )
return DrawItem;
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
if( (masque & LOCATE_COMPONENT_GRAPHIC_TEXT_DRAW_TYPE) == 0 )
break;
if( DrawItem->HitTest( aRefPoint ) )
return DrawItem;
break;
default:
;
}
}
return NULL;
}
/*******************************************************************/
LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
SCH_COMPONENT* eComponent )
/*******************************************************************/
/** Find a PIN in a component
* @param pin_number = pin number (string) * @param pin_number = pin number (string)
* @param pin_number = pin number (string) * @param pin_number = pin number (string)
* @return a pointer on the pin, or NULL if not found * @return a pointer on the pin, or NULL if not found
*/ */
LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
SCH_COMPONENT* eComponent )
{ {
LIB_DRAW_ITEM* DrawItem;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
LibDrawPin* Pin; LibDrawPin* Pin;
int Unit, Convert; int Unit, Convert;
...@@ -730,103 +632,42 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number, ...@@ -730,103 +632,42 @@ LibDrawPin* LocatePinByNumber( const wxString& ePin_Number,
if( Entry == NULL ) if( Entry == NULL )
return NULL; return NULL;
if( Entry->Type != ROOT ) wxASSERT( Entry->Type == ROOT );
{
wxMessageBox( wxT( "LocatePinByNumber() error: Entry is ALIAS" ) );
return NULL;
}
Unit = eComponent->m_Multi; Unit = eComponent->m_Multi;
Convert = eComponent->m_Convert; Convert = eComponent->m_Convert;
DrawItem = Entry->m_Drawings; for( Pin = Entry->GetNextPin(); Pin != NULL;
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() ) Pin = Entry->GetNextPin( Pin ) )
{
if( DrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) /* Pin Trouvee */
{
Pin = (LibDrawPin*) DrawItem;
if( Unit && DrawItem->m_Unit && (DrawItem->m_Unit != Unit) )
continue;
if( Convert && DrawItem->m_Convert && (DrawItem->m_Convert != Convert) )
continue;
wxString pNumber;
Pin->ReturnPinStringNum( pNumber );
if( ePin_Number == pNumber )
return Pin;
}
}
return NULL;
}
/*******************************************************************/
LIB_DRAW_ITEM* LocatePin( const wxPoint& RefPos, LIB_COMPONENT* Entry,
int Unit, int convert, SCH_COMPONENT* DrawLibItem )
/*******************************************************************/
/* Routine de localisation d'une PIN de la PartLib pointee par Entry
* retourne un pointeur sur la pin, ou NULL si pas trouve
* Si Unit = 0, le numero d'unite n'est pas teste
* Si convert = 0, le numero convert n'est pas teste
*/
{
if( Entry == NULL )
return NULL;
if( Entry->Type != ROOT )
{
wxMessageBox( wxT( "LocatePin() error: Entry is ALIAS" ) );
return NULL;
}
LIB_DRAW_ITEM* DrawItem = Entry->m_Drawings;
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
{ {
if( DrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) /* Pin Trouvee */ wxASSERT( Pin->Type() != COMPONENT_PIN_DRAW_TYPE );
{
LibDrawPin* Pin = (LibDrawPin*) DrawItem;
if( Unit && DrawItem->m_Unit && (DrawItem->m_Unit != Unit) ) if( Unit && Pin->m_Unit && ( Pin->m_Unit != Unit ) )
continue; continue;
if( convert && DrawItem->m_Convert && (DrawItem->m_Convert != convert) ) if( Convert && Pin->m_Convert && ( Pin->m_Convert != Convert ) )
continue; continue;
if( DrawLibItem == NULL ) wxString pNumber;
{ Pin->ReturnPinStringNum( pNumber );
if ( Pin->HitTest( RefPos ) )
return DrawItem;
}
else if( ePin_Number == pNumber )
{ return Pin;
int mindist = Pin->m_Width ? Pin->m_Width / 2 : g_DrawDefaultLineThickness / 2;
// Have a minimal tolerance for hit test
if( mindist < 3 )
mindist = 3; // = 3 mils
if ( Pin->HitTest( RefPos - DrawLibItem->m_Pos, mindist, DrawLibItem->m_Transform ) )
return DrawItem;
}
}
} }
return NULL; return NULL;
} }
/***********************************************************************************/ Hierarchical_PIN_Sheet_Struct* LocateSheetLabel( DrawSheetStruct* Sheet,
Hierarchical_PIN_Sheet_Struct* LocateSheetLabel( DrawSheetStruct* Sheet, const wxPoint& pos ) const wxPoint& pos )
/***********************************************************************************/
{ {
int size, dy, minx, maxx; int size, dy, minx, maxx;
Hierarchical_PIN_Sheet_Struct* SheetLabel; Hierarchical_PIN_Sheet_Struct* SheetLabel;
SheetLabel = Sheet->m_Label; SheetLabel = Sheet->m_Label;
while( (SheetLabel) && (SheetLabel->Type()==DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE) ) while( SheetLabel
&& SheetLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{ {
size = ( SheetLabel->GetLength() + 1 ) * SheetLabel->m_Size.x; size = ( SheetLabel->GetLength() + 1 ) * SheetLabel->m_Size.x;
if( SheetLabel->m_Edge ) if( SheetLabel->m_Edge )
...@@ -846,17 +687,16 @@ Hierarchical_PIN_Sheet_Struct* LocateSheetLabel( DrawSheetStruct* Sheet, const w ...@@ -846,17 +687,16 @@ Hierarchical_PIN_Sheet_Struct* LocateSheetLabel( DrawSheetStruct* Sheet, const w
} }
/**************************************************************************/
LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos, LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos,
SCH_COMPONENT** libpart ) SCH_COMPONENT** libpart )
/**************************************************************************/
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* DrawStruct;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
SCH_COMPONENT* LibItem = NULL; SCH_COMPONENT* LibItem = NULL;
LibDrawPin* Pin = NULL; LibDrawPin* Pin = NULL;
for( DrawStruct = DrawList; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) for( DrawStruct = DrawList; DrawStruct != NULL;
DrawStruct = DrawStruct->Next() )
{ {
if( DrawStruct->Type() != TYPE_SCH_COMPONENT ) if( DrawStruct->Type() != TYPE_SCH_COMPONENT )
continue; continue;
...@@ -865,8 +705,10 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos, ...@@ -865,8 +705,10 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos,
if( Entry == NULL ) if( Entry == NULL )
continue; continue;
Pin = (LibDrawPin*) LocatePin( RefPos, Entry, LibItem->m_Multi, Pin = (LibDrawPin*) Entry->LocateDrawItem( LibItem->m_Multi,
LibItem->m_Convert, LibItem ); LibItem->m_Convert,
COMPONENT_PIN_DRAW_TYPE,
RefPos );
if( Pin ) if( Pin )
break; break;
} }
...@@ -877,20 +719,20 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos, ...@@ -877,20 +719,20 @@ LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, const wxPoint& RefPos,
} }
/***************************************************************/
Hierarchical_PIN_Sheet_Struct* LocateAnyPinSheet( const wxPoint& RefPos, Hierarchical_PIN_Sheet_Struct* LocateAnyPinSheet( const wxPoint& RefPos,
SCH_ITEM* DrawList ) SCH_ITEM* DrawList )
/***************************************************************/
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* DrawStruct;
Hierarchical_PIN_Sheet_Struct* PinSheet = NULL; Hierarchical_PIN_Sheet_Struct* PinSheet = NULL;
for( DrawStruct = DrawList; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) for( DrawStruct = DrawList; DrawStruct != NULL;
DrawStruct = DrawStruct->Next() )
{ {
if( DrawStruct->Type() != DRAW_SHEET_STRUCT_TYPE ) if( DrawStruct->Type() != DRAW_SHEET_STRUCT_TYPE )
continue; continue;
PinSheet = LocateSheetLabel( (DrawSheetStruct*) DrawStruct, PinSheet = LocateSheetLabel( (DrawSheetStruct*) DrawStruct,
RefPos ); RefPos );
if( PinSheet ) if( PinSheet )
break; break;
} }
......
...@@ -18,12 +18,14 @@ ...@@ -18,12 +18,14 @@
/* Routines locales */ /* Routines locales */
static void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, const wxString& FullFileName ); static void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
const wxString& FullFileName );
static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, static void WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f,
bool with_pcbnew ); bool with_pcbnew );
static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ); static void WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f );
static void WriteListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ); static void WriteListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList );
static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, bool use_netnames ); static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
bool use_netnames );
static void WriteGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ); static void WriteGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList );
static void AddPinToComponentPinList( SCH_COMPONENT* Component, static void AddPinToComponentPinList( SCH_COMPONENT* Component,
...@@ -97,21 +99,19 @@ void WriteNetList( WinEDA_SchematicFrame* frame, const wxString& FileNameNL, ...@@ -97,21 +99,19 @@ void WriteNetList( WinEDA_SchematicFrame* frame, const wxString& FileNameNL,
} }
/****************************************************************************/ /* Find a "suitable" component from the DrawList
static SCH_COMPONENT* FindNextComponentAndCreatPinList(
EDA_BaseStruct* DrawList, DrawSheetPath* sheet )
/****************************************************************************/
/* Find a "suitable" component from the DrawList
* build its pin list s_SortedComponentPinList. * build its pin list s_SortedComponentPinList.
* The list is sorted by pin num * The list is sorted by pin num
* A suitable component is a "new" real component (power symbols are not considered) * A suitable component is a "new" real component (power symbols are not
* considered)
* Must be deallocated by the user * Must be deallocated by the user
*/ */
static SCH_COMPONENT* FindNextComponentAndCreatPinList( EDA_BaseStruct* DrawList,
DrawSheetPath* sheet )
{ {
SCH_COMPONENT* Component = NULL; SCH_COMPONENT* Component = NULL;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
LIB_DRAW_ITEM* DEntry; LibDrawPin* Pin;
s_SortedComponentPinList.clear(); s_SortedComponentPinList.clear();
for( ; DrawList != NULL; DrawList = DrawList->Next() ) for( ; DrawList != NULL; DrawList = DrawList->Next() )
...@@ -129,14 +129,16 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( ...@@ -129,14 +129,16 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
//if( Component->m_FlagControlMulti == 1 ) //if( Component->m_FlagControlMulti == 1 )
// continue; /* yes */ // continue; /* yes */
// removed because with multiple instances of one schematic // removed because with multiple instances of one schematic
// (several sheets pointing to 1 screen), this will be erroneously be toggled. // (several sheets pointing to 1 screen), this will be erroneously be
// toggled.
Entry = CMP_LIBRARY::FindLibraryComponent( Component->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( Component->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
continue; continue;
if( Entry->m_UnitCount > 1 ) // Multi parts per package: test if already visited: // Multi parts per package: test if already visited:
if( Entry->m_UnitCount > 1 )
{ {
bool found = false; bool found = false;
for( unsigned jj = 0; jj < s_ReferencesAlreadyFound.GetCount(); jj++ ) for( unsigned jj = 0; jj < s_ReferencesAlreadyFound.GetCount(); jj++ )
...@@ -156,29 +158,29 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( ...@@ -156,29 +158,29 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList(
} }
} }
DEntry = Entry->m_Drawings;
if( Entry->m_UnitCount <= 1 ) // One part per package if( Entry->m_UnitCount <= 1 ) // One part per package
{ {
for( ; DEntry != NULL; DEntry = DEntry->Next() ) for( Pin = Entry->GetNextPin(); Pin != NULL;
Pin = Entry->GetNextPin( Pin ) )
{ {
if( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE ) wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
continue;
if( DEntry->m_Unit if( Pin->m_Unit
&& ( DEntry->m_Unit != Component->GetUnitSelection( sheet ) ) ) && ( Pin->m_Unit != Component->GetUnitSelection( sheet ) ) )
continue; continue;
if( DEntry->m_Convert if( Pin->m_Convert
&& (DEntry->m_Convert != Component->m_Convert) ) && ( Pin->m_Convert != Component->m_Convert ) )
continue; continue;
{
AddPinToComponentPinList( Component, sheet, (LibDrawPin*) DEntry ); AddPinToComponentPinList( Component, sheet, Pin );
}
} }
} }
else // Multiple parts per package: Collect all parts ans pins for this reference else // Multiple parts per package: Collect all parts ans pins for this reference
FindAllsInstancesOfComponent( Component, Entry, sheet ); FindAllsInstancesOfComponent( Component, Entry, sheet );
/* Sort Pins in s_SortedComponentPinList by pin number */ /* Sort Pins in s_SortedComponentPinList by pin number */
sort( s_SortedComponentPinList.begin(), s_SortedComponentPinList.end(),SortPinsByNum ); sort( s_SortedComponentPinList.begin(),
s_SortedComponentPinList.end(), SortPinsByNum );
/* Remove duplicate Pins in s_SortedComponentPinList */ /* Remove duplicate Pins in s_SortedComponentPinList */
EraseDuplicatePins( s_SortedComponentPinList ); EraseDuplicatePins( s_SortedComponentPinList );
...@@ -373,7 +375,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, ...@@ -373,7 +375,7 @@ static void WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
/* Routine de generation du fichier netliste ( Format PSPICE ) /* Routine de generation du fichier netliste ( Format PSPICE )
* si use_netnames = TRUE * si use_netnames = TRUE
* les nodes sont identifies par le netname * les nodes sont identifies par le netname
* sinon les nodes sont identifies par le netnumber * sinon les nodes sont identifies par le netnumber
* *
* tous les textes graphiques commen�ant par [.-+]pspice ou [.-+]gnucap * tous les textes graphiques commen�ant par [.-+]pspice ou [.-+]gnucap
* sont consideres comme des commandes a placer dans la netliste * sont consideres comme des commandes a placer dans la netliste
...@@ -754,29 +756,30 @@ static void EraseDuplicatePins( NETLIST_OBJECT_LIST& aPinList ) ...@@ -754,29 +756,30 @@ static void EraseDuplicatePins( NETLIST_OBJECT_LIST& aPinList )
} }
/**********************************************************************************/
static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in,
LIB_COMPONENT* Entry,
DrawSheetPath* Sheet_in )
/**********************************************************************************/
/** /**
* Used for multiple parts per package components * Used for multiple parts per package components.
*
* Search all instances of Component_in, * Search all instances of Component_in,
* Calls AddPinToComponentPinList() to and pins founds to the current component pin list * Calls AddPinToComponentPinList() to and pins founds to the current
* component pin list
*/ */
static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in,
LIB_COMPONENT* Entry,
DrawSheetPath* Sheet_in )
{ {
EDA_BaseStruct* SchItem; EDA_BaseStruct* SchItem;
SCH_COMPONENT* Component2; SCH_COMPONENT* Component2;
LIB_DRAW_ITEM* DEntry; LibDrawPin* pin;
DrawSheetPath* sheet; DrawSheetPath* sheet;
wxString str, Reference = Component_in->GetRef( Sheet_in ); wxString str, Reference = Component_in->GetRef( Sheet_in );
EDA_SheetList SheetList; EDA_SheetList SheetList;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) for( sheet = SheetList.GetFirst(); sheet != NULL;
sheet = SheetList.GetNext() )
{ {
for( SchItem = sheet->LastDrawList(); SchItem; SchItem = SchItem->Next() ) for( SchItem = sheet->LastDrawList(); SchItem;
SchItem = SchItem->Next() )
{ {
if( SchItem->Type() != TYPE_SCH_COMPONENT ) if( SchItem->Type() != TYPE_SCH_COMPONENT )
continue; continue;
...@@ -787,41 +790,40 @@ static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in, ...@@ -787,41 +790,40 @@ static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in,
if( str.CmpNoCase( Reference ) != 0 ) if( str.CmpNoCase( Reference ) != 0 )
continue; continue;
if( Entry && Entry->m_Drawings != NULL ) if( Entry == NULL )
continue;
for( pin = Entry->GetNextPin(); pin != NULL;
pin = Entry->GetNextPin( pin ) )
{ {
DEntry = Entry->m_Drawings; wxASSERT( pin->Type() != COMPONENT_PIN_DRAW_TYPE );
for( ; DEntry != NULL; DEntry = DEntry->Next() )
{ if( pin->m_Unit
if( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE ) && ( pin->m_Unit != Component2->GetUnitSelection( sheet ) ) )
continue; continue;
if( DEntry->m_Unit
&& ( DEntry->m_Unit != Component2->GetUnitSelection( sheet ) ) ) if( pin->m_Convert
continue; && ( pin->m_Convert != Component2->m_Convert ) )
if( DEntry->m_Convert
&& (DEntry->m_Convert != Component2->m_Convert) )
continue; continue;
// A suitable pin in found: add it to the current list // A suitable pin in found: add it to the current list
AddPinToComponentPinList( Component2, sheet, (LibDrawPin*) DEntry ); AddPinToComponentPinList( Component2, sheet, pin );
}
} }
} }
} }
} }
/**************************************************************************/ /*
static bool SortPinsByNum( NETLIST_OBJECT* Pin1, NETLIST_OBJECT* Pin2 ) Routine de comparaison pour le tri des pins par numero croissant
/**************************************************************************/
/* Routine de comparaison pour le tri des pins par numero croissant
* du tableau des pins s_SortedComponentPinList par qsort() * du tableau des pins s_SortedComponentPinList par qsort()
*/ */
static bool SortPinsByNum( NETLIST_OBJECT* Pin1, NETLIST_OBJECT* Pin2 )
{ {
int Num1, Num2; int Num1, Num2;
char Line[5]; char Line[5];
Num1 = Pin1->m_PinNum; Num1 = Pin1->m_PinNum;
Num2 = Pin2->m_PinNum; Num2 = Pin2->m_PinNum;
Line[4] = 0; Line[4] = 0;
memcpy( Line, &Num1, 4 ); Num1 = atoi( Line ); memcpy( Line, &Num1, 4 ); Num1 = atoi( Line );
...@@ -1055,7 +1057,7 @@ static void WriteListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ) ...@@ -1055,7 +1057,7 @@ static void WriteListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList )
+ NetcodeName; + NetcodeName;
//NetcodeName << wxT("_") << //NetcodeName << wxT("_") <<
// g_NetObjectslist[jj].m_SheetList.PathHumanReadable(); // g_NetObjectslist[jj].m_SheetList.PathHumanReadable();
} }
} }
else // this net has no name: create a default name $<net number> else // this net has no name: create a default name $<net number>
...@@ -1113,7 +1115,7 @@ static void WriteListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ) ...@@ -1113,7 +1115,7 @@ static void WriteListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList )
aObjectsList[ii]->m_Flag = 1; aObjectsList[ii]->m_Flag = 1;
// Recherche des pins redondantes et mise a 1 de m_Flag, // Recherche des pins redondantes et mise a 1 de m_Flag,
// pour ne pas generer plusieurs fois la connexion // pour ne pas generer plusieurs fois la connexion
for( jj = ii + 1; jj < aObjectsList.size(); jj++ ) for( jj = ii + 1; jj < aObjectsList.size(); jj++ )
{ {
if( aObjectsList[jj]->GetNet() != NetCode ) if( aObjectsList[jj]->GetNet() != NetCode )
......
...@@ -355,7 +355,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist, ...@@ -355,7 +355,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
NETLIST_OBJECT* new_item; NETLIST_OBJECT* new_item;
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
LIB_DRAW_ITEM* DEntry; LibDrawPin* pin;
Hierarchical_PIN_Sheet_Struct* SheetLabel; Hierarchical_PIN_Sheet_Struct* SheetLabel;
DrawSheetPath list; DrawSheetPath list;
...@@ -479,43 +479,38 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist, ...@@ -479,43 +479,38 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
if( Entry == NULL ) if( Entry == NULL )
break; break;
if( Entry->m_Drawings == NULL ) for( pin = Entry->GetNextPin(); pin != NULL;
break; pin = Entry->GetNextPin( pin ) )
DEntry = Entry->m_Drawings;
for( ; DEntry; DEntry = DEntry->Next() )
{ {
LibDrawPin* Pin = (LibDrawPin*) DEntry; wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
if( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( DEntry->m_Unit && ( DEntry->m_Unit != DrawLibItem->GetUnitSelection( sheetlist ) ) ) if( pin->m_Unit
&& ( pin->m_Unit != DrawLibItem->GetUnitSelection( sheetlist ) ) )
continue; continue;
if( DEntry->m_Convert if( pin->m_Convert
&& (DEntry->m_Convert != DrawLibItem->m_Convert) ) && ( pin->m_Convert != DrawLibItem->m_Convert ) )
continue; continue;
wxPoint pos2 = wxPoint pos2 =
TransformCoordinate( DrawLibItem->m_Transform, TransformCoordinate( DrawLibItem->m_Transform,
Pin->m_Pos ) + DrawLibItem->m_Pos; pin->m_Pos ) + DrawLibItem->m_Pos;
new_item = new NETLIST_OBJECT(); new_item = new NETLIST_OBJECT();
new_item->m_SheetListInclude = *sheetlist; new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = DEntry; new_item->m_Comp = pin;
new_item->m_SheetList = *sheetlist; new_item->m_SheetList = *sheetlist;
new_item->m_Type = NET_PIN; new_item->m_Type = NET_PIN;
new_item->m_Link = DrawLibItem; new_item->m_Link = DrawLibItem;
new_item->m_ElectricalType = Pin->m_PinType; new_item->m_ElectricalType = pin->m_PinType;
new_item->m_PinNum = Pin->m_PinNum; new_item->m_PinNum = pin->m_PinNum;
new_item->m_Label = &Pin->m_PinName; new_item->m_Label = &pin->m_PinName;
new_item->m_Start = new_item->m_End = pos2; new_item->m_Start = new_item->m_End = pos2;
aNetItemBuffer.push_back( new_item ); aNetItemBuffer.push_back( new_item );
if( ( (int) Pin->m_PinType == (int) PIN_POWER_IN ) if( ( (int) pin->m_PinType == (int) PIN_POWER_IN )
&& ( Pin->m_Attributs & PINNOTDRAW ) ) && ( pin->m_Attributs & PINNOTDRAW ) )
{ {
/* Il y a un PIN_LABEL Associe */ /* Il y a un PIN_LABEL Associe */
new_item = new NETLIST_OBJECT(); new_item = new NETLIST_OBJECT();
...@@ -523,7 +518,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist, ...@@ -523,7 +518,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
new_item->m_Comp = NULL; new_item->m_Comp = NULL;
new_item->m_SheetList = *sheetlist; new_item->m_SheetList = *sheetlist;
new_item->m_Type = NET_PINLABEL; new_item->m_Type = NET_PINLABEL;
new_item->m_Label = &Pin->m_PinName; new_item->m_Label = &pin->m_PinName;
new_item->m_Start = pos2; new_item->m_Start = pos2;
new_item->m_End = new_item->m_Start; new_item->m_End = new_item->m_Start;
...@@ -545,8 +540,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist, ...@@ -545,8 +540,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
list = *sheetlist; list = *sheetlist;
list.Push( STRUCT ); list.Push( STRUCT );
SheetLabel = STRUCT->m_Label; SheetLabel = STRUCT->m_Label;
for( ; SheetLabel != NULL; for( ; SheetLabel != NULL; SheetLabel = SheetLabel->Next() )
SheetLabel = SheetLabel->Next() )
{ {
ii = IsBusLabel( SheetLabel->m_Text ); ii = IsBusLabel( SheetLabel->m_Text );
new_item = new NETLIST_OBJECT(); new_item = new NETLIST_OBJECT();
...@@ -573,7 +567,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist, ...@@ -573,7 +567,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
{ {
wxString msg; wxString msg;
msg.Printf( wxT( "Netlist: unexpected struct type %d" ), msg.Printf( wxT( "Netlist: unexpected struct type %d" ),
DrawList->Type() ); DrawList->Type() );
wxMessageBox( msg ); wxMessageBox( msg );
break; break;
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "libcmp.h"
#include "general.h" #include "general.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "libeditfrm.h" #include "libeditfrm.h"
...@@ -133,8 +132,8 @@ public: ...@@ -133,8 +132,8 @@ public:
void NewSizePin(int newsize); void NewSizePin(int newsize);
void SetPinShape( int newshape); void SetPinShape( int newshape);
void SetPinType(int newtype); void SetPinType(int newtype);
void SetPinOrient(int neworient); void SetPinOrientation(int neworient);
void SetAttributsPin(bool draw, bool unit, bool convert); void SetPinAttributes(bool draw, bool unit, bool convert);
////@begin WinEDA_PinPropertiesFrame member variables ////@begin WinEDA_PinPropertiesFrame member variables
wxTextCtrl* m_PinNameCtrl; wxTextCtrl* m_PinNameCtrl;
......
...@@ -102,8 +102,11 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event ) ...@@ -102,8 +102,11 @@ void WinEDA_PinPropertiesFrame::PinPropertiesAccept( wxCommandEvent& event )
NewSizePin( LastPinSize ); NewSizePin( LastPinSize );
SetPinShape( LastPinShape ); SetPinShape( LastPinShape );
SetPinType( LastPinType ); SetPinType( LastPinType );
SetPinOrient( LastPinOrient ); SetPinOrientation( LastPinOrient );
SetAttributsPin( true, true, true ); // Set all attributes (visibility, common to units and common to convert options)
// Set all attributes (visibility, common to units and common to
// convert options)
SetPinAttributes( true, true, true );
item->DisplayInfo( m_Parent ); item->DisplayInfo( m_Parent );
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
...@@ -125,22 +128,19 @@ void WinEDA_LibeditFrame::InitEditOnePin() ...@@ -125,22 +128,19 @@ void WinEDA_LibeditFrame::InitEditOnePin()
LibDrawPin* Pin; LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem; LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem;
if( m_component == NULL || CurrentPin == NULL ) if( m_component == NULL || CurrentPin == NULL
|| m_drawItem->Type() != COMPONENT_PIN_DRAW_TYPE )
return; return;
/* Marquage des pins a traiter,Si edition d'une pin non deja selectionnee */ for( Pin = m_component->GetNextPin(); Pin != NULL;
Pin = (LibDrawPin*) m_component->m_Drawings; Pin = m_component->GetNextPin( Pin ) )
for( ; Pin != NULL; Pin = Pin->Next() )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( Pin == CurrentPin ) if( Pin == CurrentPin )
continue; continue;
if( ( Pin->m_Pos == CurrentPin->m_Pos ) if( ( Pin->m_Pos == CurrentPin->m_Pos )
&& ( Pin->m_Orient == CurrentPin->m_Orient ) && ( Pin->m_Orient == CurrentPin->m_Orient )
&& ( !( CurrentPin->m_Flags & IS_NEW ) ) && ( !( CurrentPin->m_Flags & IS_NEW ) )
&& ( g_EditPinByPinIsOn == false ) // This is set by the tool of the main toolbar && ( g_EditPinByPinIsOn == false ) )
)
Pin->m_Flags |= IS_LINKED | IN_EDIT; Pin->m_Flags |= IS_LINKED | IN_EDIT;
else else
Pin->m_Flags = 0; Pin->m_Flags = 0;
...@@ -150,12 +150,10 @@ void WinEDA_LibeditFrame::InitEditOnePin() ...@@ -150,12 +150,10 @@ void WinEDA_LibeditFrame::InitEditOnePin()
} }
/*************************************************************/ /**
static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC ) * Clean up after aborting a move pin command.
/*************************************************************/
/* Used to abort the move pin command.
*/ */
static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) Panel->GetParent(); WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) Panel->GetParent();
...@@ -164,14 +162,15 @@ static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -164,14 +162,15 @@ static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC )
LibDrawPin* CurrentPin = (LibDrawPin*) parent->GetDrawItem(); LibDrawPin* CurrentPin = (LibDrawPin*) parent->GetDrawItem();
if( CurrentPin && ( CurrentPin->m_Flags & IS_NEW ) ) if( CurrentPin == NULL || CurrentPin->Type() != COMPONENT_PIN_DRAW_TYPE )
CurrentPin->GetParent()->RemoveDrawItem( CurrentPin, Panel, DC ); return;
/* clear edit flags */ if( CurrentPin->m_Flags & IS_NEW )
LIB_DRAW_ITEM* item = CurrentPin->GetParent()->m_Drawings; delete CurrentPin;
for( ; item != NULL; item = item->Next() ) else
item->m_Flags = 0; CurrentPin->m_Flags = 0;
/* clear edit flags */
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
parent->SetDrawItem( NULL ); parent->SetDrawItem( NULL );
...@@ -180,10 +179,10 @@ static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -180,10 +179,10 @@ static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC )
} }
/********************************************/ /**
* Managed cursor callback for placing component pins.
*/
void WinEDA_LibeditFrame::PlacePin( wxDC* DC ) void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
/********************************************/
/* Routine de fin de deplacement de la pin selectionnee */
{ {
LibDrawPin* Pin; LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem; LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem;
...@@ -197,23 +196,18 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC ) ...@@ -197,23 +196,18 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
newpos.x = GetScreen()->m_Curseur.x; newpos.x = GetScreen()->m_Curseur.x;
newpos.y = -GetScreen()->m_Curseur.y; newpos.y = -GetScreen()->m_Curseur.y;
Pin = (LibDrawPin*) m_component->m_Drawings;
// Tst for an other pin in same new position: // Tst for an other pin in same new position:
for( ; Pin != NULL; Pin = Pin->Next() ) for( Pin = m_component->GetNextPin(); Pin != NULL;
Pin = m_component->GetNextPin( Pin ) )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) if( Pin == CurrentPin || newpos != Pin->m_Pos || Pin->m_Flags )
continue;
if( Pin == CurrentPin )
continue;
if( newpos != Pin->m_Pos )
continue;
if( Pin->m_Flags )
continue; continue;
if( ask_for_pin && !g_EditPinByPinIsOn ) if( ask_for_pin && !g_EditPinByPinIsOn )
{ {
DrawPanel->m_IgnoreMouseEvents = true; DrawPanel->m_IgnoreMouseEvents = true;
status = IsOK( this, _( "Occupied by other pin. Continue?" ) ); status = IsOK( this, _( "This position is already occupied by \
another pin. Continue?" ) );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = false; DrawPanel->m_IgnoreMouseEvents = false;
if( !status ) if( !status )
...@@ -226,24 +220,22 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC ) ...@@ -226,24 +220,22 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
CurrentPin->m_Pos = newpos; CurrentPin->m_Pos = newpos;
if( CurrentPin->m_Flags & IS_NEW ) if( CurrentPin->m_Flags & IS_NEW )
{ {
LastPinOrient = CurrentPin->m_Orient; LastPinOrient = CurrentPin->m_Orient;
LastPinType = CurrentPin->m_PinType; LastPinType = CurrentPin->m_PinType;
LastPinShape = CurrentPin->m_PinShape; LastPinShape = CurrentPin->m_PinShape;
CreateImagePins( CurrentPin, m_unit, m_convert, CreateImagePins( CurrentPin, m_unit, m_convert, m_showDeMorgan );
m_showDeMorgan );
m_lastDrawItem = CurrentPin; m_lastDrawItem = CurrentPin;
m_component->AddDrawItem( m_drawItem );
} }
/* Put linked pins in new position, and clear flags */ /* Put linked pins in new position, and clear flags */
Pin = (LibDrawPin*) m_component->m_Drawings; for( Pin = m_component->GetNextPin(); Pin != NULL;
for( ; Pin != NULL; Pin = Pin->Next() ) Pin = m_component->GetNextPin( Pin ) )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( Pin->m_Flags == 0 ) if( Pin->m_Flags == 0 )
continue; continue;
Pin->m_Pos = CurrentPin->m_Pos; Pin->m_Pos = CurrentPin->m_Pos;
...@@ -259,17 +251,13 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC ) ...@@ -259,17 +251,13 @@ void WinEDA_LibeditFrame::PlacePin( wxDC* DC )
m_drawItem = NULL; m_drawItem = NULL;
}; };
/***********************************************************/
void WinEDA_PinPropertiesFrame::SetPinOrient( int neworient ) void WinEDA_PinPropertiesFrame::SetPinOrientation( int neworient )
/***********************************************************/
/* Routine de Rotation de la pin courante*/
{ {
LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem(); LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
LibDrawPin* Pin, * RefPin = CurrentPin; LibDrawPin* Pin, * RefPin = CurrentPin;
if( CurrentPin == NULL || CurrentPin->GetParent() == NULL ) if( CurrentPin == NULL || CurrentPin->GetParent() == NULL || RefPin == NULL )
return;
if( RefPin == NULL )
return; return;
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
...@@ -277,8 +265,9 @@ void WinEDA_PinPropertiesFrame::SetPinOrient( int neworient ) ...@@ -277,8 +265,9 @@ void WinEDA_PinPropertiesFrame::SetPinOrient( int neworient )
/* Rotation */ /* Rotation */
RefPin->m_Orient = neworient; RefPin->m_Orient = neworient;
Pin = (LibDrawPin*) CurrentPin->GetParent()->m_Drawings; Pin = CurrentPin->GetParent()->GetNextPin();
for( ; Pin != NULL; Pin = Pin->Next() )
for( ; Pin != NULL; Pin = CurrentPin->GetParent()->GetNextPin( Pin ) )
{ {
if( Pin->m_Flags == 0 ) if( Pin->m_Flags == 0 )
continue; continue;
...@@ -289,26 +278,22 @@ void WinEDA_PinPropertiesFrame::SetPinOrient( int neworient ) ...@@ -289,26 +278,22 @@ void WinEDA_PinPropertiesFrame::SetPinOrient( int neworient )
} }
/*************************************************/ /**
void WinEDA_LibeditFrame::StartMovePin( wxDC* DC ) * Prepare le deplacement d'une pin :
/*************************************************/ * Localise la pin pointee par le curseur, et si elle existe active
* la fonction de gestion curseur ( DrawMovePin() ).
/* Prepare le deplacement d'une pin :
* Localise la pin pointee par le curseur, et si elle existe active
* la fonction de gestion curseur ( DrawMovePin() ).
*/ */
void WinEDA_LibeditFrame::StartMovePin( wxDC* DC )
{ {
LibDrawPin* Pin; LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem; LibDrawPin* CurrentPin = (LibDrawPin*) m_drawItem;
wxPoint startPos; wxPoint startPos;
/* Marquage des pins a traiter */ /* Marquage des pins a traiter */
Pin = (LibDrawPin*) m_component->m_Drawings; Pin = m_component->GetNextPin();
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
{ {
Pin->m_Flags = 0; Pin->m_Flags = 0;
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( Pin == CurrentPin ) if( Pin == CurrentPin )
continue; continue;
if( ( Pin->m_Pos == CurrentPin->m_Pos ) if( ( Pin->m_Pos == CurrentPin->m_Pos )
...@@ -346,12 +331,18 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -346,12 +331,18 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
return; return;
LibDrawPin* CurrentPin = (LibDrawPin*) parent->GetDrawItem(); LibDrawPin* CurrentPin = (LibDrawPin*) parent->GetDrawItem();
wxPoint pinpos = CurrentPin->m_Pos;
bool showPinText = true; if( CurrentPin == NULL || CurrentPin->Type() != COMPONENT_PIN_DRAW_TYPE )
return;
wxPoint pinpos = CurrentPin->m_Pos;
bool showPinText = true;
/* Erase pin in old position */ /* Erase pin in old position */
if( erase || ( CurrentPin->m_Flags & IS_NEW ) ) if( erase || ( CurrentPin->m_Flags & IS_NEW ) )
{ {
wxLogDebug( _( "Initial pin position (%d, %d)" ),
PinPreviousPos.x, PinPreviousPos.y );
CurrentPin->m_Pos = PinPreviousPos; CurrentPin->m_Pos = PinPreviousPos;
CurrentPin->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, CurrentPin->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&showPinText, DefaultTransformMatrix ); &showPinText, DefaultTransformMatrix );
...@@ -360,14 +351,14 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -360,14 +351,14 @@ static void DrawMovePin( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/* Redraw pin in new position */ /* Redraw pin in new position */
CurrentPin->m_Pos.x = panel->GetScreen()->m_Curseur.x; CurrentPin->m_Pos.x = panel->GetScreen()->m_Curseur.x;
CurrentPin->m_Pos.y = -panel->GetScreen()->m_Curseur.y; CurrentPin->m_Pos.y = -panel->GetScreen()->m_Curseur.y;
CurrentPin->Draw( panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, CurrentPin->Draw( panel, DC, wxPoint( 0, 0 ), -1, wxCOPY,
&showPinText, DefaultTransformMatrix ); &showPinText, DefaultTransformMatrix );
PinPreviousPos = CurrentPin->m_Pos; PinPreviousPos = CurrentPin->m_Pos;
/* Keep the original position for existing pin (for Undo command) /* Keep the original position for existing pin (for Undo command)
* and the current position for a new pin */ * and the current position for a new pin */
if( (CurrentPin->m_Flags & IS_NEW) == 0 ) if( ( CurrentPin->m_Flags & IS_NEW ) == 0 )
CurrentPin->m_Pos = pinpos; CurrentPin->m_Pos = pinpos;
} }
...@@ -390,14 +381,10 @@ void WinEDA_PinPropertiesFrame::SetPinShape( int newshape ) ...@@ -390,14 +381,10 @@ void WinEDA_PinPropertiesFrame::SetPinShape( int newshape )
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
CurrentPin->DisplayInfo( m_Parent ); CurrentPin->DisplayInfo( m_Parent );
Pin = (LibDrawPin*) CurrentPin->GetParent()->m_Drawings; Pin = CurrentPin->GetParent()->GetNextPin();
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = CurrentPin->GetParent()->GetNextPin( Pin ) )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) if( Pin->m_Flags == 0 || Pin->m_Convert != CurrentPin->m_Convert )
continue;
if( Pin->m_Flags == 0 )
continue;
if( Pin->m_Convert != CurrentPin->m_Convert )
continue; continue;
Pin->m_PinShape = newshape; Pin->m_PinShape = newshape;
} }
...@@ -423,11 +410,9 @@ void WinEDA_PinPropertiesFrame::SetPinType( int newtype ) ...@@ -423,11 +410,9 @@ void WinEDA_PinPropertiesFrame::SetPinType( int newtype )
CurrentPin->m_PinType = newtype; CurrentPin->m_PinType = newtype;
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
Pin = (LibDrawPin*) CurrentPin->GetParent()->m_Drawings; Pin = CurrentPin->GetParent()->GetNextPin();
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = CurrentPin->GetParent()->GetNextPin( Pin ) )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( Pin->m_Flags == 0 ) if( Pin->m_Flags == 0 )
continue; continue;
Pin->m_PinType = newtype; Pin->m_PinType = newtype;
...@@ -462,11 +447,9 @@ void WinEDA_PinPropertiesFrame::SetPinName( const wxString& newname, int newsize ...@@ -462,11 +447,9 @@ void WinEDA_PinPropertiesFrame::SetPinName( const wxString& newname, int newsize
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
/* Traitement des autres pins */ /* Traitement des autres pins */
Pin = (LibDrawPin*) CurrentPin->GetParent()->m_Drawings; Pin = CurrentPin->GetParent()->GetNextPin();
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = CurrentPin->GetParent()->GetNextPin( Pin ) )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( (Pin->m_Flags & IS_LINKED) == 0 ) if( (Pin->m_Flags & IS_LINKED) == 0 )
continue; continue;
if( newsize >= 0 ) if( newsize >= 0 )
...@@ -504,14 +487,11 @@ void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize ) ...@@ -504,14 +487,11 @@ void WinEDA_PinPropertiesFrame::SetPinNum( const wxString& newnum, int newsize )
CurrentPin->SetPinNumFromString( buf ); CurrentPin->SetPinNumFromString( buf );
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
Pin = (LibDrawPin*) CurrentPin->GetParent()->m_Drawings; Pin = CurrentPin->GetParent()->GetNextPin();
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = CurrentPin->GetParent()->GetNextPin( Pin ) )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE ) if( ( Pin->m_Flags & IS_LINKED ) == 0
continue; || Pin->m_Unit != CurrentPin->m_Unit )
if( ( Pin->m_Flags & IS_LINKED ) == 0 )
continue;
if( Pin->m_Unit != CurrentPin->m_Unit )
continue; continue;
if( newsize >= 0 ) if( newsize >= 0 )
Pin->m_PinNumSize = newsize; Pin->m_PinNumSize = newsize;
...@@ -532,8 +512,8 @@ void WinEDA_LibeditFrame::DeletePin( wxDC* DC, ...@@ -532,8 +512,8 @@ void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
* Sinon seule la pin de l'unite en convert courante sera effacee * Sinon seule la pin de l'unite en convert courante sera effacee
*/ */
{ {
LIB_DRAW_ITEM* DrawItem; LibDrawPin* tmp;
wxPoint PinPos; wxPoint PinPos;
if( LibEntry == NULL || Pin == NULL ) if( LibEntry == NULL || Pin == NULL )
return; return;
...@@ -544,46 +524,43 @@ void WinEDA_LibeditFrame::DeletePin( wxDC* DC, ...@@ -544,46 +524,43 @@ void WinEDA_LibeditFrame::DeletePin( wxDC* DC,
/* Effacement des autres pins de meme coordonnees */ /* Effacement des autres pins de meme coordonnees */
if( g_EditPinByPinIsOn == false ) if( g_EditPinByPinIsOn == false )
{ {
DrawItem = LibEntry->m_Drawings; tmp = LibEntry->GetNextPin();
for( ; DrawItem != NULL; )
while( tmp != NULL )
{ {
if( DrawItem->Type() != COMPONENT_PIN_DRAW_TYPE ) Pin = tmp;
{ tmp = LibEntry->GetNextPin( Pin );
DrawItem = DrawItem->Next();
continue;
}
Pin = (LibDrawPin*) DrawItem;
DrawItem = DrawItem->Next();
if( Pin->m_Pos != PinPos ) if( Pin->m_Pos != PinPos )
continue; continue;
LibEntry->RemoveDrawItem( (LIB_DRAW_ITEM*) Pin ); LibEntry->RemoveDrawItem( (LIB_DRAW_ITEM*) Pin );
} }
} }
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
/*********************************************/ /*
* Create a new pin.
*/
void WinEDA_LibeditFrame::CreatePin( wxDC* DC ) void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
/*********************************************/
/* Creation d'une nouvelle pin */
{ {
LIB_DRAW_ITEM* DrawItem; LibDrawPin* CurrentPin;
LibDrawPin* CurrentPin; bool showPinText = true;
bool showPinText = true;
if( m_component == NULL ) if( m_component == NULL )
return; return;
/* Effacement des flags */ /* Effacement des flags */
DrawItem = m_component->m_Drawings; m_component->ClearStatus();
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
DrawItem->m_Flags = 0;
CurrentPin = new LibDrawPin(m_component); CurrentPin = new LibDrawPin( m_component );
m_drawItem = CurrentPin; m_drawItem = CurrentPin;
if( CurrentPin == NULL )
if( CurrentPin == NULL || CurrentPin->Type() != COMPONENT_PIN_DRAW_TYPE )
return; return;
CurrentPin->m_Flags = IS_NEW; CurrentPin->m_Flags = IS_NEW;
CurrentPin->m_Unit = m_unit; CurrentPin->m_Unit = m_unit;
...@@ -614,21 +591,17 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC ) ...@@ -614,21 +591,17 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
else else
CurrentPin->m_Attributs &= ~PINNOTDRAW; CurrentPin->m_Attributs &= ~PINNOTDRAW;
CurrentPin->SetNext( m_component->m_Drawings );
m_component->m_Drawings = CurrentPin;
m_component->SortDrawItems();
if( DC ) if( DC )
CurrentPin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, CurrentPin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, wxCOPY,
&showPinText, DefaultTransformMatrix ); &showPinText, DefaultTransformMatrix );
PinPreviousPos = CurrentPin->m_Pos;
wxLogDebug( _( "Initial pin position (%d, %d)" ),
PinPreviousPos.x, PinPreviousPos.y );
DrawPanel->m_IgnoreMouseEvents = true; DrawPanel->m_IgnoreMouseEvents = true;
InstallPineditFrame( this, DC, wxPoint( -1, -1 ) ); InstallPineditFrame( this, DC, wxPoint( -1, -1 ) );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = false; DrawPanel->m_IgnoreMouseEvents = false;
PinPreviousPos = CurrentPin->m_Pos;
DrawPanel->ManageCurseur = DrawMovePin; DrawPanel->ManageCurseur = DrawMovePin;
DrawPanel->ForceCloseManageCurseur = AbortPinMove; DrawPanel->ForceCloseManageCurseur = AbortPinMove;
...@@ -637,27 +610,25 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC ) ...@@ -637,27 +610,25 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
} }
/*********************************************************/
void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
bool unit, bool convert )
/*********************************************************/
/* si draw == true /* si draw == true
* - Ajuste le flag visible / invisible (.U.Pin.Flags bit 0 ) de la pin * - Ajuste le flag visible / invisible (.U.Pin.Flags bit 0 ) de la pin
* editee * editee
* *
* si unit == true * si unit == true
* - Modifie l'attribut Commun / Particulier U.Pin.Unit = 0 ou Num Unite * - Modifie l'attribut Commun / Particulier U.Pin.Unit = 0 ou Num Unite
* de la pin editee * de la pin editee
* *
* si convert == true * si convert == true
* - Modifie l'attribut Commun / Particulier U.Pin.Convert = 0 ou Num Unite * - Modifie l'attribut Commun / Particulier U.Pin.Convert = 0 ou Num Unite
* de la pin editee * de la pin editee
* *
*/ */
void WinEDA_PinPropertiesFrame::SetPinAttributes( bool draw, bool unit,
bool convert )
{ {
LIB_DRAW_ITEM* DrawItem; LibDrawPin* tmp;
LibDrawPin* Pin, * CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem(); LibDrawPin* Pin;
LibDrawPin* CurrentPin = (LibDrawPin*) m_Parent->GetDrawItem();
if( CurrentPin == NULL ) if( CurrentPin == NULL )
return; return;
...@@ -671,23 +642,19 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw, ...@@ -671,23 +642,19 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
else else
CurrentPin->m_Unit = m_Parent->GetUnit(); CurrentPin->m_Unit = m_Parent->GetUnit();
Pin = (LibDrawPin*) CurrentPin->GetParent()->m_Drawings;
if( CurrentPin->m_Unit == 0 ) if( CurrentPin->m_Unit == 0 )
{ {
DrawItem = CurrentPin->GetParent()->m_Drawings; tmp = CurrentPin->GetParent()->GetNextPin();
for( ; DrawItem != NULL; )
while( tmp != NULL )
{ {
Pin = (LibDrawPin*) DrawItem; Pin = tmp;
DrawItem = DrawItem->Next(); tmp = CurrentPin->GetParent()->GetNextPin( Pin );
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue; if( Pin->m_Flags == 0 || Pin == CurrentPin )
if( Pin->m_Flags == 0 )
continue;
if( Pin == CurrentPin )
continue; continue;
if( CurrentPin->m_Convert if( CurrentPin->m_Convert
&& (CurrentPin->m_Convert != Pin->m_Convert) ) && ( CurrentPin->m_Convert != Pin->m_Convert ) )
continue; continue;
if( CurrentPin->m_Pos != Pin->m_Pos ) if( CurrentPin->m_Pos != Pin->m_Pos )
continue; continue;
...@@ -708,18 +675,18 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw, ...@@ -708,18 +675,18 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
if( CurrentPin->m_Convert == 0 ) /* Effacement des pins redondantes */ if( CurrentPin->m_Convert == 0 ) /* Effacement des pins redondantes */
{ {
DrawItem = CurrentPin->GetParent()->m_Drawings; tmp = CurrentPin->GetParent()->GetNextPin();
for( ; DrawItem != NULL; )
while( tmp != NULL )
{ {
Pin = (LibDrawPin*) DrawItem; Pin = tmp;
DrawItem = DrawItem->Next(); tmp = CurrentPin->GetParent()->GetNextPin( Pin );
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( Pin->m_Flags == 0 ) if( Pin->m_Flags == 0 )
continue; continue;
if( Pin == CurrentPin ) if( Pin == CurrentPin )
continue; continue;
if( CurrentPin->m_Unit && (CurrentPin->m_Unit != Pin->m_Unit) ) if( CurrentPin->m_Unit && ( CurrentPin->m_Unit != Pin->m_Unit ) )
continue; continue;
if( CurrentPin->m_Pos != Pin->m_Pos ) if( CurrentPin->m_Pos != Pin->m_Pos )
continue; continue;
...@@ -738,8 +705,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw, ...@@ -738,8 +705,8 @@ void WinEDA_PinPropertiesFrame::SetAttributsPin( bool draw,
else else
CurrentPin->m_Attributs &= ~PINNOTDRAW; CurrentPin->m_Attributs &= ~PINNOTDRAW;
Pin = (LibDrawPin*) CurrentPin->GetParent()->m_Drawings; Pin = CurrentPin->GetParent()->GetNextPin();
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = CurrentPin->GetParent()->GetNextPin( Pin ) )
{ {
if( Pin->m_Flags == 0 ) if( Pin->m_Flags == 0 )
continue; continue;
...@@ -777,11 +744,9 @@ void WinEDA_PinPropertiesFrame::NewSizePin( int newsize ) ...@@ -777,11 +744,9 @@ void WinEDA_PinPropertiesFrame::NewSizePin( int newsize )
if( g_EditPinByPinIsOn == false ) if( g_EditPinByPinIsOn == false )
{ {
Pin = (LibDrawPin*) Pin->GetParent()->m_Drawings; Pin = Pin->GetParent()->GetNextPin();
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = Pin->GetParent()->GetNextPin( Pin ) )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( Pin->m_Pos != RefPin->m_Pos ) if( Pin->m_Pos != RefPin->m_Pos )
continue; continue;
if( Pin->m_Orient != RefPin->m_Orient ) if( Pin->m_Orient != RefPin->m_Orient )
...@@ -815,8 +780,7 @@ static void CreateImagePins( LibDrawPin* Pin, int unit, int convert, ...@@ -815,8 +780,7 @@ static void CreateImagePins( LibDrawPin* Pin, int unit, int convert,
NewPin->m_Convert = 1; NewPin->m_Convert = 1;
else else
NewPin->m_Convert = 2; NewPin->m_Convert = 2;
NewPin->SetNext( Pin->GetParent()->m_Drawings ); Pin->GetParent()->AddDrawItem( NewPin );
Pin->GetParent()->m_Drawings = NewPin;
} }
for( ii = 1; ii <= Pin->GetParent()->m_UnitCount; ii++ ) for( ii = 1; ii <= Pin->GetParent()->m_UnitCount; ii++ )
...@@ -829,8 +793,7 @@ static void CreateImagePins( LibDrawPin* Pin, int unit, int convert, ...@@ -829,8 +793,7 @@ static void CreateImagePins( LibDrawPin* Pin, int unit, int convert,
if( convert != 0 ) if( convert != 0 )
NewPin->m_Convert = 1; NewPin->m_Convert = 1;
NewPin->m_Unit = ii; NewPin->m_Unit = ii;
NewPin->SetNext( Pin->GetParent()->m_Drawings ); Pin->GetParent()->AddDrawItem( NewPin );
Pin->GetParent()->m_Drawings = NewPin;
/* Creation pour la representation "Convert" */ /* Creation pour la representation "Convert" */
if( CreateConv == false ) if( CreateConv == false )
...@@ -840,8 +803,7 @@ static void CreateImagePins( LibDrawPin* Pin, int unit, int convert, ...@@ -840,8 +803,7 @@ static void CreateImagePins( LibDrawPin* Pin, int unit, int convert,
NewPin->m_Convert = 2; NewPin->m_Convert = 2;
if( Pin->m_Unit != 0 ) if( Pin->m_Unit != 0 )
NewPin->m_Unit = ii; NewPin->m_Unit = ii;
NewPin->SetNext( Pin->GetParent()->m_Drawings ); Pin->GetParent()->AddDrawItem( NewPin );
Pin->GetParent()->m_Drawings = NewPin;
} }
} }
...@@ -869,16 +831,14 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC, ...@@ -869,16 +831,14 @@ void WinEDA_LibeditFrame::GlobalSetPins( wxDC* DC,
GetScreen()->SetModify(); GetScreen()->SetModify();
Pin = (LibDrawPin*) m_component->m_Drawings; Pin = m_component->GetNextPin();
for( ; Pin != NULL; Pin = Pin->Next() ) for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
{ {
if( Pin->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( ( Pin->m_Convert ) && ( Pin->m_Convert != m_convert ) ) if( ( Pin->m_Convert ) && ( Pin->m_Convert != m_convert ) )
continue; continue;
// Is it the "selected mode" ? // Is it the "selected mode" ?
if( selected && (Pin->m_Selected & IS_SELECTED) == 0 ) if( selected && ( Pin->m_Selected & IS_SELECTED ) == 0 )
continue; continue;
Pin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, Pin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
...@@ -919,10 +879,9 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin ) ...@@ -919,10 +879,9 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LibDrawPin* SourcePin )
return; return;
Pin = (LibDrawPin*)SourcePin->GenCopy(); Pin = (LibDrawPin*)SourcePin->GenCopy();
Pin->SetNext( m_component->m_Drawings ); m_component->AddDrawItem( Pin );
m_component->m_Drawings = Pin;
Pin->m_Flags = IS_NEW;
Pin->m_Flags = IS_NEW;
Pin->m_Pos.x += g_RepeatStep.x; Pin->m_Pos.x += g_RepeatStep.x;
ox = Pin->m_Pos.x; ox = Pin->m_Pos.x;
Pin->m_Pos.y += -g_RepeatStep.y; Pin->m_Pos.y += -g_RepeatStep.y;
...@@ -975,16 +934,15 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event ) ...@@ -975,16 +934,15 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event )
return; return;
// Construction de la liste des pins: // Construction de la liste des pins:
Pin = (LibDrawPin*) m_component->m_Drawings; Pin = m_component->GetNextPin();
for( nb_pins = 0; Pin != NULL; Pin = Pin->Next() ) for( nb_pins = 0; Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
{ {
if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ) nb_pins++;
nb_pins++;
} }
PinList = (LibDrawPin**) MyZMalloc( (nb_pins + 1) * sizeof(LibDrawPin*) ); PinList = (LibDrawPin**) MyZMalloc( (nb_pins + 1) * sizeof(LibDrawPin*) );
Pin = (LibDrawPin*) m_component->m_Drawings; Pin = m_component->GetNextPin();
for( ii = 0; Pin != NULL; Pin = Pin->Next() ) for( ii = 0; Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
{ {
if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE ) if( Pin->Type() == COMPONENT_PIN_DRAW_TYPE )
PinList[ii++] = Pin; PinList[ii++] = Pin;
...@@ -1010,10 +968,10 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event ) ...@@ -1010,10 +968,10 @@ void WinEDA_LibeditFrame::OnCheckComponent( wxCommandEvent& event )
curr_pin->ReturnPinStringNum( StringPinNum ); curr_pin->ReturnPinStringNum( StringPinNum );
msg.Printf( _( "Duplicate pin %s at location (%d, %d) conflicts \ msg.Printf( _( "Duplicate pin %s at location (%d, %d) conflicts \
with pin %s at location (%d, %d)" ), with pin %s at location (%d, %d)" ),
(const wxChar*)StringPinNum, (const wxChar*) StringPinNum,
(const wxChar*)curr_pin->m_PinName, (const wxChar*) curr_pin->m_PinName,
curr_pin->m_Pos.x, -curr_pin->m_Pos.y, curr_pin->m_Pos.x, -curr_pin->m_Pos.y,
(const wxChar*)Pin->m_PinName, (const wxChar*) Pin->m_PinName,
Pin->m_Pos.x, -Pin->m_Pos.y ); Pin->m_Pos.x, -Pin->m_Pos.y );
if( m_component->m_UnitCount > 1 ) if( m_component->m_UnitCount > 1 )
......
...@@ -65,7 +65,7 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem ) ...@@ -65,7 +65,7 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
Multi = DrawLibItem->m_Multi; Multi = DrawLibItem->m_Multi;
convert = DrawLibItem->m_Convert; convert = DrawLibItem->m_Convert;
for( LIB_DRAW_ITEM* DEntry = Entry->m_Drawings; for( LIB_DRAW_ITEM* DEntry = Entry->GetNextDrawItem();
DEntry != NULL; DEntry = DEntry->Next() ) DEntry != NULL; DEntry = DEntry->Next() )
{ {
/* Elimination des elements non relatifs a l'unite */ /* Elimination des elements non relatifs a l'unite */
......
...@@ -21,14 +21,6 @@ class DrawSheetStruct; ...@@ -21,14 +21,6 @@ class DrawSheetStruct;
class LibDrawPin; class LibDrawPin;
LIB_DRAW_ITEM* LocatePin( const wxPoint& RefPos,
LIB_COMPONENT* Entry,
int Unit,
int Convert,
SCH_COMPONENT* DrawItem = NULL );
/* Routine de localisation d'une PIN de la PartLib pointee par Entry */
wxString ReturnDefaultFieldName( int aFieldNdx ); wxString ReturnDefaultFieldName( int aFieldNdx );
...@@ -158,13 +150,6 @@ SCH_ITEM* PickStruct( const wxPoint& refpos, ...@@ -158,13 +150,6 @@ SCH_ITEM* PickStruct( const wxPoint& refpos,
int SearchMask ); int SearchMask );
LIB_DRAW_ITEM* LocateDrawItem( SCH_SCREEN* Screen,
const wxPoint& refpoint,
LIB_COMPONENT* LibEntry,
int Unit,
int Convert,
int masque );
Hierarchical_PIN_Sheet_Struct* LocateSheetLabel( DrawSheetStruct* Sheet, Hierarchical_PIN_Sheet_Struct* LocateSheetLabel( DrawSheetStruct* Sheet,
const wxPoint& pos ); const wxPoint& pos );
LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList, LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList,
...@@ -252,20 +237,6 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Window ); ...@@ -252,20 +237,6 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Window );
void DeleteAllMarkers( int type ); void DeleteAllMarkers( int type );
/**************/
/* GETPART.CPP */
/**************/
int LookForConvertPart( LIB_COMPONENT* LibEntry );
/* Retourne la plus grande valeur trouvee dans la liste des elements
* "drawings" du composant LibEntry, pour le membre .Convert
* Si il n'y a pas de representation type "convert", la valeur
* retournee est 0 ou 1
* Si il y a une representation type "convert",
* la valeur retournee est > 1 (typiquement 2) */
/**************/ /**************/
/* PINEDIT.CPP */ /* PINEDIT.CPP */
/**************/ /**************/
......
...@@ -140,13 +140,12 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) ...@@ -140,13 +140,12 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
} }
/****************************************************************/
static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC ) static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
/****************************************************************/
{ {
LIB_DRAW_ITEM* item; LIB_DRAW_ITEM* item;
WinEDA_LibeditFrame* parent = ( WinEDA_LibeditFrame* ) Panel->GetParent();
item = ( ( WinEDA_LibeditFrame* ) Panel->GetParent() )->GetDrawItem(); item = parent->GetDrawItem();
if( item == NULL ) if( item == NULL )
return; return;
...@@ -164,6 +163,7 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -164,6 +163,7 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
DefaultTransformMatrix ); DefaultTransformMatrix );
SAFE_DELETE( item ); SAFE_DELETE( item );
parent->SetDrawItem( NULL );
} }
else else
{ {
...@@ -297,12 +297,10 @@ error" ) ); ...@@ -297,12 +297,10 @@ error" ) );
} }
/********************************************************/ /*
void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC ) * Routine de creation d'un nouvel element type LibraryDrawStruct
/********************************************************/
/* Routine de creation d'un nouvel element type LibraryDrawStruct
*/ */
void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC )
{ {
if( m_drawItem == NULL ) if( m_drawItem == NULL )
return; return;
...@@ -520,16 +518,14 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -520,16 +518,14 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
} }
/******************************************************/ /*
void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC ) * Place la structure courante en liste des structures du composant
/******************************************************/ * courant, si elle existe et redessine toujours celle ci
/* Place la structure courante en liste des structures du composant
* courant, si elle existe et redessine toujours celle ci
* Parametres: (tous globaux) * Parametres: (tous globaux)
* m_drawItem * m_drawItem
* m_component * m_component
*/ */
void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
{ {
if( m_component == NULL || m_drawItem == NULL ) if( m_component == NULL || m_drawItem == NULL )
return; return;
...@@ -538,11 +534,12 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC ) ...@@ -538,11 +534,12 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
{ {
if( StateDrawArc == 1 ) /* Trace d'arc en cours: doit etre termine */ if( StateDrawArc == 1 ) /* Trace d'arc en cours: doit etre termine */
{ {
DisplayError( this, wxT( "Arc in progress.." ), 10 ); return; DisplayError( this, wxT( "Arc in progress.." ) );
return;
} }
else else
{ {
if( (m_drawItem->m_Flags & IS_MOVED) == 0 ) if( ( m_drawItem->m_Flags & IS_MOVED ) == 0 )
SymbolDisplayDraw( DrawPanel, DC, FALSE ); SymbolDisplayDraw( DrawPanel, DC, FALSE );
} }
} }
...@@ -552,8 +549,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC ) ...@@ -552,8 +549,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
if( m_drawItem->m_Flags & IS_NEW ) if( m_drawItem->m_Flags & IS_NEW )
{ {
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
m_drawItem->SetNext( m_component->m_Drawings ); m_component->AddDrawItem( m_drawItem );
m_component->m_Drawings = m_drawItem;
switch( m_drawItem->Type() ) switch( m_drawItem->Type() )
{ {
...@@ -581,8 +577,6 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC ) ...@@ -581,8 +577,6 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
default: default:
; ;
} }
m_component->SortDrawItems();
} }
if( m_ID_current_state ) if( m_ID_current_state )
...@@ -590,7 +584,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC ) ...@@ -590,7 +584,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
else else
SetCursor( wxCURSOR_ARROW ); SetCursor( wxCURSOR_ARROW );
if( (m_drawItem->m_Flags & IS_MOVED) ) if( m_drawItem->m_Flags & IS_MOVED )
{ {
wxPoint pos; wxPoint pos;
pos.x = GetScreen()->m_Curseur.x + InitPosition.x - StartCursor.x, pos.x = GetScreen()->m_Curseur.x + InitPosition.x - StartCursor.x,
...@@ -702,12 +696,10 @@ static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre ) ...@@ -702,12 +696,10 @@ static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre )
} }
/***************************************************/ /*
void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC ) * Used for deleting last entered segment while creating a Polyline
/**************************************************/
/* Used for deleting last entered segment while creating a Polyline
*/ */
void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
{ {
if( m_drawItem == NULL if( m_drawItem == NULL
|| m_drawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE ) || m_drawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE )
...@@ -718,7 +710,8 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC ) ...@@ -718,7 +710,8 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
m_drawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL, m_drawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
DefaultTransformMatrix ); DefaultTransformMatrix );
while( Poly->GetCornerCount() > 2 ) // First segment is kept, only its end point is changed // First segment is kept, only its end point is changed
while( Poly->GetCornerCount() > 2 )
{ {
Poly->m_PolyPoints.pop_back(); Poly->m_PolyPoints.pop_back();
unsigned idx = Poly->GetCornerCount() - 1; unsigned idx = Poly->GetCornerCount() - 1;
......
...@@ -96,9 +96,9 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) ...@@ -96,9 +96,9 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
DisplayError( this, _( "Warning: more than 1 part in Symbol File" ) ); DisplayError( this, _( "Warning: more than 1 part in Symbol File" ) );
Component = (LIB_COMPONENT*) Lib->GetFirstEntry(); Component = (LIB_COMPONENT*) Lib->GetFirstEntry();
DrawEntry = Component->m_Drawings; DrawEntry = Component->GetNextDrawItem();
while( DrawEntry ) while( DrawEntry != NULL )
{ {
if( DrawEntry->m_Unit ) if( DrawEntry->m_Unit )
DrawEntry->m_Unit = m_unit; DrawEntry->m_Unit = m_unit;
...@@ -107,14 +107,9 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) ...@@ -107,14 +107,9 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
DrawEntry->m_Flags = IS_NEW; DrawEntry->m_Flags = IS_NEW;
DrawEntry->m_Selected = IS_SELECTED; DrawEntry->m_Selected = IS_SELECTED;
if( DrawEntry->Next() == NULL ) /* Fin de liste trouvee */ LIB_DRAW_ITEM* newItem = DrawEntry->GenCopy();
{ newItem->SetParent( m_component );
DrawEntry->SetNext( m_component->m_Drawings ); m_component->AddDrawItem( newItem );
m_component->m_Drawings = Component->m_Drawings;
Component->m_Drawings = NULL;
break;
}
DrawEntry = DrawEntry->Next(); DrawEntry = DrawEntry->Next();
} }
...@@ -122,13 +117,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) ...@@ -122,13 +117,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
m_component->RemoveDuplicateDrawItems(); m_component->RemoveDuplicateDrawItems();
// Clear flags // Clear flags
DrawEntry = m_component->m_Drawings; m_component->ClearSelectedItems();
while( DrawEntry )
{
DrawEntry->m_Flags = 0;
DrawEntry->m_Selected = 0;
DrawEntry = DrawEntry->Next();
}
GetScreen()->SetModify(); GetScreen()->SetModify();
DrawPanel->Refresh(); DrawPanel->Refresh();
...@@ -151,7 +140,7 @@ void WinEDA_LibeditFrame::SaveOneSymbol() ...@@ -151,7 +140,7 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
wxString msg; wxString msg;
FILE* ExportFile; FILE* ExportFile;
if( m_component->m_Drawings == NULL ) if( m_component->GetNextDrawItem() == NULL )
return; return;
/* Creation du fichier symbole */ /* Creation du fichier symbole */
...@@ -215,11 +204,12 @@ void WinEDA_LibeditFrame::SaveOneSymbol() ...@@ -215,11 +204,12 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
/* Position / orientation / visibilite des champs */ /* Position / orientation / visibilite des champs */
m_component->m_Prefix.Save( ExportFile ); m_component->m_Prefix.Save( ExportFile );
m_component->m_Name.Save( ExportFile ); m_component->m_Name.Save( ExportFile );
DrawEntry = m_component->m_Drawings; DrawEntry = m_component->GetNextDrawItem();
if( DrawEntry ) if( DrawEntry )
{ {
fprintf( ExportFile, "DRAW\n" ); fprintf( ExportFile, "DRAW\n" );
for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() ) for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() )
{ {
/* Elimination des elements non relatifs a l'unite */ /* Elimination des elements non relatifs a l'unite */
......
...@@ -255,7 +255,7 @@ protected: ...@@ -255,7 +255,7 @@ protected:
public: public:
int m_Flags; // flags for editing and other misc. uses int m_Flags; // flags for editing and other uses.
unsigned long m_TimeStamp; // Time stamp used for logical links unsigned long m_TimeStamp; // Time stamp used for logical links
int m_Selected; /* Used by block commands, and selective editing */ int m_Selected; /* Used by block commands, and selective editing */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment