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 @@
#include "program.h"
#include "general.h"
#include "libcmp.h"
#include "protos.h"
/* Constructor and destructor for SCH_ITEM */
......
......@@ -861,51 +861,47 @@ static LIB_DRAW_ITEM* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
*/
{
LIB_COMPONENT* Entry;
static LIB_DRAW_ITEM* NextItem;
static LibDrawPin* NextPin;
static int Multi, convert, TransMat[2][2];
LIB_DRAW_ITEM* DEntry;
int orient;
LibDrawPin* Pin;
static wxPoint CmpPosition;
if( aDrawLibItem )
{
NextItem = NULL;
NextPin = NULL;
Entry = CMP_LIBRARY::FindLibraryComponent( aDrawLibItem->m_ChipName );
if( Entry == NULL )
return NULL;
DEntry = Entry->m_Drawings;
Pin = Entry->GetNextPin();
Multi = aDrawLibItem->m_Multi;
convert = aDrawLibItem->m_Convert;
CmpPosition = aDrawLibItem->m_Pos;
memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) );
}
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 */
if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) )
continue;
if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) )
if( Multi && Pin->m_Unit && ( Pin->m_Unit != Multi ) )
continue;
if( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE )
if( convert && Pin->m_Convert && ( Pin->m_Convert != convert ) )
continue;
Pin = (LibDrawPin*) DEntry;
/* Calcul de l'orientation reelle de la Pin */
orient = Pin->ReturnPinDrawOrient( TransMat );
/* Calcul de la position du point de reference */
aPosition = TransformCoordinate( TransMat, Pin->m_Pos ) + CmpPosition;
NextItem = DEntry->Next();
return DEntry;
return Pin;
}
NextItem = NULL;
NextPin = NULL;
return NULL;
}
......@@ -19,7 +19,6 @@
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase );
static void MirrorMarkedItems( LIB_COMPONENT* LibEntry, wxPoint offset );
/*
......@@ -77,6 +76,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
{
int ItemCount = 0;
int MustDoPlace = 0;
wxPoint pt;
if( GetScreen()->m_BlockLocate.GetCount() )
{
......@@ -147,7 +147,9 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
g_EditPinByPinIsOn );
if( ItemCount )
SaveCopyInUndoList( m_component );
MirrorMarkedItems( m_component, GetScreen()->m_BlockLocate.Centre() );
pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1;
m_component->MirrorSelectedItemsH( pt );
break;
case BLOCK_ZOOM: /* Window Zoom */
......@@ -191,7 +193,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
{
bool err = FALSE;
wxPoint offset;
wxPoint pt;
if( DrawPanel->ManageCurseur == NULL )
{
......@@ -212,18 +214,18 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( m_component );
offset = GetScreen()->m_BlockLocate.m_MoveVector;
offset.y *= -1;
m_component->MoveSelectedItems( offset );
pt = GetScreen()->m_BlockLocate.m_MoveVector;
pt.y *= -1;
m_component->MoveSelectedItems( pt );
DrawPanel->Refresh( TRUE );
break;
case BLOCK_COPY: /* Copy */
GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( m_component );
offset = GetScreen()->m_BlockLocate.m_MoveVector;
offset.y *= -1;
m_component->CopySelectedItems( offset );
pt = GetScreen()->m_BlockLocate.m_MoveVector;
pt.y *= -1;
m_component->CopySelectedItems( pt );
break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
......@@ -232,7 +234,9 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_MIRROR_Y: /* Invert by popup menu, from block move */
SaveCopyInUndoList( m_component );
MirrorMarkedItems( m_component, GetScreen()->m_BlockLocate.Centre() );
pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1;
m_component->MirrorSelectedItemsH( pt );
break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd
......@@ -305,88 +309,3 @@ void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
g_XorMode, -1, DefaultTransformMatrix,
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 )
}
void LibDrawText::DoMirrorHorizontal( const wxPoint& center )
{
m_Pos.x -= center.x;
m_Pos.x *= -1;
m_Pos.x += center.x;
}
/** Function GetPenSize
* @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,
LibDrawField* oldField;
LibDrawField* newField;
m_Prefix = component.m_Prefix;
m_AliasList = component.m_AliasList;
m_FootprintList = component.m_FootprintList;
......@@ -336,6 +335,7 @@ LIB_COMPONENT::LIB_COMPONENT( const LIB_COMPONENT& component,
m_DrawPinNum = component.m_DrawPinNum;
m_DrawPinName = component.m_DrawPinName;
m_LastDate = component.m_LastDate;
m_Drawings = NULL;
m_Prefix.SetParent( this );
......@@ -505,24 +505,83 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item,
item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
DefaultTransformMatrix );
if( m_Drawings == item )
if( item->Type() != COMPONENT_FIELD_DRAW_TYPE )
{
m_Drawings = item->Next();
SAFE_DELETE( item );
return;
}
if( m_Drawings == item )
{
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() );
SAFE_DELETE( item );
break;
if( field == item )
{
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,
bool LIB_COMPONENT::Save( FILE* aFile )
{
LIB_DRAW_ITEM* DrawEntry;
LibDrawField* Field;
LibDrawField* Field;
/* Sort just in clase sorting was not done properly. */
SortDrawItems();
......@@ -940,7 +999,7 @@ void LIB_COMPONENT::SortDrawItems()
if( Entry == NULL )
return; /* Pas d'alias pour ce composant */
/* calcul du nombre d'items */
for( nbitems = 0; Entry != NULL; Entry = Entry->Next() )
nbitems++;
......@@ -978,23 +1037,25 @@ void LIB_COMPONENT::SortDrawItems()
/**********************************************************************/
EDA_Rect LIB_COMPONENT::GetBoundaryBox( int Unit, int Convert )
{
LIB_DRAW_ITEM* DrawEntry;
EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
LIB_DRAW_ITEM* item;
EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
for( DrawEntry = m_Drawings; DrawEntry != NULL;
DrawEntry = DrawEntry->Next() )
for( item = m_Drawings; item != NULL; item = item->Next() )
{
if( DrawEntry->m_Unit > 0 ) // The item is non common to units
if( ( m_UnitCount > 1 ) && ( Unit > 0 )
&& ( Unit != DrawEntry->m_Unit ) )
continue;
if( DrawEntry->m_Convert > 0 ) // The item is not common to all convert
if( ( Convert > 0 ) && ( Convert != DrawEntry->m_Convert ) )
continue;
if( ( item->m_Unit > 0 )
&& ( ( m_UnitCount > 1 ) && ( Unit > 0 )
&& ( Unit != item->m_Unit ) ) )
continue;
if( item->m_Convert > 0
&& ( ( Convert > 0 ) && ( Convert != item->m_Convert ) ) )
continue;
bBox.Merge( DrawEntry->GetBoundingBox() );
bBox.Merge( item->GetBoundingBox() );
}
bBox.Merge( m_Name.GetBoundingBox() );
bBox.Merge( m_Prefix.GetBoundingBox() );
return bBox;
}
......@@ -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,
bool editPinByPin )
{
......@@ -1318,3 +1395,77 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& offset )
MoveSelectedItems( offset );
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:
bool showPinText = true, bool drawFields = true,
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.
*
......@@ -215,6 +222,23 @@ public:
WinEDA_DrawPanel* panel = 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.
*
......@@ -249,6 +273,11 @@ public:
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.
*
......@@ -294,6 +323,27 @@ public:
* make sense in this context.
*/
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 )
}
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,
* i.e U -> U? or U?A or the field text for others
......
......@@ -74,6 +74,13 @@ public:
int aColor, int aDrawMode, void* aData,
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
* tests if the given wxPoint is within the bounds of this object.
......@@ -82,13 +89,16 @@ public:
*/
bool HitTest( const wxPoint& refPos );
/** Function HitTest
/**
* Function HitTest
* @return true if the point aPosRef is near this object
* @param aPosRef = a wxPoint to test
* @param aThreshold = max distance to this object (usually the half thickness of a line)
* @param aThreshold = max distance to this object (usually the half
* thickness of a line)
* @param aTransMat = the transform matrix
*/
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 )
{
......@@ -127,6 +137,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
};
#endif // CLASS_LIBENTRY_FIELDS_H
......@@ -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
* Displays info (pin num and name, orientation ...
* on the Info window
......
......@@ -45,8 +45,8 @@ void CreateDummyCmp()
Text->m_Size.x = Text->m_Size.y = 150;
Text->m_Text = wxT( "??" );
DummyCmp->m_Drawings = Square;
Square->SetNext( Text );
DummyCmp->AddDrawItem( Square );
DummyCmp->AddDrawItem( Text );
}
......
......@@ -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
* @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 )
}
void LibDrawCircle::DoMirrorHorizontal( const wxPoint& center )
{
m_Pos.x -= center.x;
m_Pos.x *= -1;
m_Pos.x += center.x;
}
/** Function GetPenSize
* @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 )
}
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
* @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 )
}
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
* @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 )
}
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 )
{
m_PolyPoints.push_back( point );
......@@ -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
* @return the size of the "pen" that be used to draw or plot this item
*/
......
......@@ -114,7 +114,9 @@ public:
LIB_DRAW_ITEM( const LIB_DRAW_ITEM& item );
virtual ~LIB_DRAW_ITEM() { }
/** Function Draw (virtual pure)
/**
* Function Draw (virtual pure)
*
* Draw A body item
* @param aPanel = DrawPanel to use (can be null) mainly used for clipping
* purposes
......@@ -241,6 +243,16 @@ public:
*/
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:
virtual LIB_DRAW_ITEM* DoGenCopy() = 0;
......@@ -254,6 +266,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect ) = 0;
virtual void DoMove( const wxPoint& newPosition ) = 0;
virtual wxPoint DoGetPosition( void ) = 0;
virtual void DoMirrorHorizontal( const wxPoint& center ) = 0;
};
......@@ -387,6 +400,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
};
......@@ -462,6 +476,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
};
......@@ -533,6 +548,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
};
......@@ -611,6 +627,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
};
......@@ -681,6 +698,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
};
/**********************************/
......@@ -750,6 +768,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
};
......@@ -830,6 +849,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_PolyPoints[0]; }
virtual void DoMirrorHorizontal( const wxPoint& center );
};
/**********************************************************/
......@@ -910,6 +930,7 @@ protected:
virtual bool DoTestInside( EDA_Rect& rect );
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) { return m_PolyPoints[0]; }
virtual void DoMirrorHorizontal( const wxPoint& center );
};
#endif // CLASSES_BODY_ITEMS_H
......@@ -215,9 +215,8 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
}
/*************************************************************************************/
void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
/*************************************************************************************/
void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
wxPoint MousePositionInPixels )
{
wxRealPoint delta;
SCH_SCREEN* screen = GetScreen();
......@@ -309,11 +308,10 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPi
}
/*************************************************************************************/
void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
/*************************************************************************************/
void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
wxPoint MousePositionInPixels )
{
wxRealPoint delta;
wxRealPoint delta;
SCH_SCREEN* screen = GetScreen();
wxPoint curpos, oldpos;
int hotkey = 0;
......@@ -402,11 +400,10 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe
}
/*****************************************************************************/
void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
wxPoint MousePositionInPixels )
{
wxRealPoint delta;
wxRealPoint delta;
SCH_SCREEN* screen = GetScreen();
wxPoint curpos, oldpos;
int hotkey = 0;
......
......@@ -392,20 +392,17 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
if( Entry == NULL )
break;
LIB_DRAW_ITEM* DrawLibItem = Entry->m_Drawings;
for( ; DrawLibItem != NULL; DrawLibItem = DrawLibItem->Next() )
for( LibDrawPin* Pin = Entry->GetNextPin(); Pin != NULL;
Pin = Entry->GetNextPin( Pin ) )
{
if( DrawLibItem->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
LibDrawPin* Pin = (LibDrawPin*) DrawLibItem;
wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
if( Pin->m_Unit && DrawLibItem->m_Unit
&& (DrawLibItem->m_Unit != Pin->m_Unit) )
if( Pin->m_Unit && STRUCT->m_Multi
&& ( STRUCT->m_Multi != Pin->m_Unit ) )
continue;
if( Pin->m_Convert && DrawLibItem->m_Convert
&& (DrawLibItem->m_Convert != Pin->m_Convert) )
if( Pin->m_Convert && STRUCT->m_Convert
&& ( STRUCT->m_Convert != Pin->m_Convert ) )
continue;
item = new DanglingEndHandle( PIN_END );
......
......@@ -680,7 +680,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
convertCheckBox->SetValue( true );
}
if( m_LibEntry == NULL || LookForConvertPart( m_LibEntry ) <= 1 )
if( m_LibEntry == NULL || !m_LibEntry->HasConversion() )
{
convertCheckBox->Enable( false );
}
......
......@@ -377,7 +377,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
/* Traitement des unites enlevees ou rajoutees */
if( OldNumUnits > component->m_UnitCount )
{
DrawItem = component->m_Drawings;
DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = NextDrawItem )
{
NextDrawItem = DrawItem->Next();
......@@ -410,7 +410,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
if( OldNumUnits < component->m_UnitCount )
{
DrawItem = component->m_Drawings;
DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
{
/* Duplication des items pour autres elements */
......@@ -419,13 +419,13 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
for( ii = OldNumUnits + 1; ii <= MaxUnit; ii++ )
{
NextDrawItem = DrawItem->GenCopy();
NextDrawItem->SetNext( component->m_Drawings );
component->m_Drawings = NextDrawItem;
NextDrawItem->m_Unit = ii;
component->AddDrawItem( NextDrawItem );
}
}
}
}
return TRUE;
}
......@@ -446,7 +446,8 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
{
/* Traitement des elements a ajouter ( pins seulement ) */
if( component )
DrawItem = component->m_Drawings;
DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
{
/* Duplication des items pour autres elements */
......@@ -456,7 +457,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
{
if( FlagDel == 0 )
{
if( IsOK( this, _( "Create pins for Convert items" ) ) )
if( IsOK( this, _( "Create pins for convert items." ) ) )
FlagDel = 1;
else
{
......@@ -467,10 +468,10 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
return FALSE;
}
}
NextDrawItem = DrawItem->GenCopy();
NextDrawItem->SetNext( component->m_Drawings );
component->m_Drawings = NextDrawItem;
NextDrawItem->m_Convert = 2;
NextDrawItem->m_Convert = 2;
component->AddDrawItem( NextDrawItem );
}
}
}
......@@ -478,7 +479,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
{
/* Traitement des elements � supprimer */
if( component )
DrawItem = component->m_Drawings;
DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = NextDrawItem )
{
NextDrawItem = DrawItem->Next();
......
......@@ -402,7 +402,7 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
if( LibEntry == NULL )
return;
if( ( ii = LookForConvertPart( LibEntry ) ) < 2 )
if( !LibEntry->HasConversion() )
{
DisplayError( this, wxT( "No convert found" ) );
return;
......@@ -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,
wxDC* DC )
{
......
......@@ -471,16 +471,13 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
cmd.SetEventObject( this );
wxPoint MousePos = GetScreen()->m_MousePosition;
bool ItemInEdit = GetScreen()->GetCurItem()
&& GetScreen()->GetCurItem()->m_Flags;
if( hotkey == 0 )
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
// handle...)
if( (hotkey & GR_KB_CTRL) != 0 )
......@@ -564,18 +561,16 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
break;
case HK_EDIT_PIN:
if( DrawEntry )
m_drawItem = DrawEntry;
if( m_drawItem )
{
if( m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
InstallPineditFrame( this, DC, MousePos );
}
m_drawItem = LocateItemUsingCursor();
if( m_drawItem && m_drawItem->Type() == COMPONENT_PIN_DRAW_TYPE )
InstallPineditFrame( this, DC, MousePos );
break;
case HK_DELETE_PIN:
if( DrawEntry )
m_drawItem = DrawEntry;
m_drawItem = LocateItemUsingCursor();
if( m_drawItem )
{
wxCommandEvent evt;
......@@ -585,8 +580,8 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
break;
case HK_MOVE_PIN:
if( DrawEntry )
m_drawItem = DrawEntry;
m_drawItem = LocateItemUsingCursor();
if( m_drawItem )
{
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,
m_showDeMorgan = false;
if( LookForConvertPart( m_component ) > 1 )
if( m_component->HasConversion() )
m_showDeMorgan = true;
GetBaseScreen()->ClrModify();
......@@ -265,7 +265,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary( wxCommandEvent& event )
if( !IsOK( this, msg ) )
return;
bool success = m_library->Save( fn.GetFullPath() );
bool success = m_library->Save( fn.GetFullPath(), true );
MsgPanel->EraseMsgBox();
......
......@@ -14,7 +14,6 @@
#include "program.h"
#include "general.h"
#include "libcmp.h"
#include "protos.h"
#include "libeditfrm.h"
#include "class_libentry.h"
......@@ -51,25 +50,16 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
}
else
{
DrawEntry = LocatePin( GetScreen()->m_MousePosition, m_component,
m_unit, m_convert );
if( DrawEntry == NULL )
{
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(),
GetScreen()->m_MousePosition,
m_component, m_unit, m_convert,
LOCATE_ALL_DRAW_ITEM );
}
DrawEntry =
m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->m_MousePosition );
if( DrawEntry == NULL )
DrawEntry = LocatePin( GetScreen()->m_Curseur, m_component,
m_unit, m_convert );
if( DrawEntry == NULL )
{
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(),
GetScreen()->m_Curseur,
m_component, m_unit, m_convert,
LOCATE_ALL_DRAW_ITEM );
DrawEntry =
m_component->LocateDrawItem( m_unit, m_convert,
TYPE_NOT_INIT,
GetScreen()->m_Curseur );
}
if( DrawEntry )
......@@ -121,26 +111,16 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break;
case ID_LIBEDIT_DELETE_ITEM_BUTT:
DrawEntry = LocatePin( GetScreen()->m_MousePosition, m_component,
m_unit, m_convert );
if( DrawEntry == NULL )
{
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(),
GetScreen()->m_MousePosition,
m_component, m_unit, m_convert,
LOCATE_ALL_DRAW_ITEM );
}
DrawEntry =
m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->m_MousePosition );
if( DrawEntry == NULL )
DrawEntry = LocatePin( GetScreen()->m_Curseur,
m_component, m_unit,
m_convert );
if( DrawEntry == NULL )
{
DrawEntry = LocateDrawItem( (SCH_SCREEN*)GetScreen(),
GetScreen()->m_Curseur,
m_component, m_unit, m_convert,
LOCATE_ALL_DRAW_ITEM );
DrawEntry =
m_component->LocateDrawItem( m_unit, m_convert,
TYPE_NOT_INIT,
GetScreen()->m_Curseur );
}
if( DrawEntry == NULL )
DisplayCmpDoc();
......@@ -185,29 +165,14 @@ void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
if( ( DrawEntry == NULL ) || ( DrawEntry->m_Flags == 0 ) )
{ // We can locate an item
DrawEntry = LocatePin( GetScreen()->m_MousePosition, m_component,
m_unit, m_convert );
if( DrawEntry == NULL )
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 );
}
DrawEntry = m_drawItem =
m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->m_MousePosition );
if( DrawEntry == NULL )
{
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 )
{
......
......@@ -31,9 +31,9 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
ITEM_PICKER wrapper(CopyItem, UR_LIBEDIT);
lastcmd->PushItem(wrapper);
GetScreen()->PushCommandToUndoList( lastcmd );
/* Clear current flags (which can be temporary set by a current edit command) */
for( item = CopyItem->m_Drawings; item != NULL; item = item->Next() )
item->m_Flags = 0;
/* Clear current flags (which can be temporary set by a current edit
* command) */
CopyItem->ClearStatus();
/* Clear redo list, because after new save there is no redo to do */
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
......
......@@ -110,10 +110,7 @@ public:
LIB_DRAW_ITEM* GetDrawItem( void ) { return m_drawItem; }
void SetDrawItem( LIB_DRAW_ITEM* drawItem )
{
m_drawItem = drawItem;
}
void SetDrawItem( LIB_DRAW_ITEM* drawItem );
bool GetShowDeMorgan( void ) { return m_showDeMorgan; }
......@@ -163,7 +160,6 @@ private:
void EditSymbolText( wxDC* DC, LIB_DRAW_ITEM* DrawItem );
void RotateSymbolText( wxDC* DC );
void DeleteDrawPoly( wxDC* DC );
LibDrawField* LocateField( LIB_COMPONENT* LibEntry );
LIB_DRAW_ITEM* LocateItemUsingCursor();
void RotateField( wxDC* DC, LibDrawField* Field );
void PlaceField( wxDC* DC, LibDrawField* Field );
......
......@@ -10,7 +10,6 @@
#include "program.h"
#include "general.h"
#include "libcmp.h"
#include "protos.h"
#include "libeditfrm.h"
#include "class_library.h"
......@@ -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* DrawEntry = m_drawItem;
......@@ -304,26 +271,15 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::LocateItemUsingCursor()
if( ( DrawEntry == NULL ) || ( DrawEntry->m_Flags == 0 ) )
{
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 );
}
DrawEntry = m_drawItem =
m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
GetScreen()->m_MousePosition );
if( DrawEntry == NULL )
{
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()
}
void WinEDA_LibeditFrame::SetDrawItem( LIB_DRAW_ITEM* drawItem )
{
m_drawItem = drawItem;
}
/**
* Save library editor frame specific configuration settings.
*
......
This diff is collapsed.
This diff is collapsed.
......@@ -355,7 +355,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
NETLIST_OBJECT* new_item;
SCH_COMPONENT* DrawLibItem;
LIB_COMPONENT* Entry;
LIB_DRAW_ITEM* DEntry;
LibDrawPin* pin;
Hierarchical_PIN_Sheet_Struct* SheetLabel;
DrawSheetPath list;
......@@ -479,43 +479,38 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
if( Entry == NULL )
break;
if( Entry->m_Drawings == NULL )
break;
DEntry = Entry->m_Drawings;
for( ; DEntry; DEntry = DEntry->Next() )
for( pin = Entry->GetNextPin(); pin != NULL;
pin = Entry->GetNextPin( pin ) )
{
LibDrawPin* Pin = (LibDrawPin*) DEntry;
if( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
if( DEntry->m_Unit && ( DEntry->m_Unit != DrawLibItem->GetUnitSelection( sheetlist ) ) )
if( pin->m_Unit
&& ( pin->m_Unit != DrawLibItem->GetUnitSelection( sheetlist ) ) )
continue;
if( DEntry->m_Convert
&& (DEntry->m_Convert != DrawLibItem->m_Convert) )
if( pin->m_Convert
&& ( pin->m_Convert != DrawLibItem->m_Convert ) )
continue;
wxPoint pos2 =
TransformCoordinate( DrawLibItem->m_Transform,
Pin->m_Pos ) + DrawLibItem->m_Pos;
pin->m_Pos ) + DrawLibItem->m_Pos;
new_item = new NETLIST_OBJECT();
new_item->m_SheetListInclude = *sheetlist;
new_item->m_Comp = DEntry;
new_item->m_Comp = pin;
new_item->m_SheetList = *sheetlist;
new_item->m_Type = NET_PIN;
new_item->m_Link = DrawLibItem;
new_item->m_ElectricalType = Pin->m_PinType;
new_item->m_PinNum = Pin->m_PinNum;
new_item->m_Label = &Pin->m_PinName;
new_item->m_ElectricalType = pin->m_PinType;
new_item->m_PinNum = pin->m_PinNum;
new_item->m_Label = &pin->m_PinName;
new_item->m_Start = new_item->m_End = pos2;
aNetItemBuffer.push_back( new_item );
if( ( (int) Pin->m_PinType == (int) PIN_POWER_IN )
&& ( Pin->m_Attributs & PINNOTDRAW ) )
if( ( (int) pin->m_PinType == (int) PIN_POWER_IN )
&& ( pin->m_Attributs & PINNOTDRAW ) )
{
/* Il y a un PIN_LABEL Associe */
new_item = new NETLIST_OBJECT();
......@@ -523,7 +518,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
new_item->m_Comp = NULL;
new_item->m_SheetList = *sheetlist;
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_End = new_item->m_Start;
......@@ -545,8 +540,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
list = *sheetlist;
list.Push( STRUCT );
SheetLabel = STRUCT->m_Label;
for( ; SheetLabel != NULL;
SheetLabel = SheetLabel->Next() )
for( ; SheetLabel != NULL; SheetLabel = SheetLabel->Next() )
{
ii = IsBusLabel( SheetLabel->m_Text );
new_item = new NETLIST_OBJECT();
......@@ -573,7 +567,7 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
{
wxString msg;
msg.Printf( wxT( "Netlist: unexpected struct type %d" ),
DrawList->Type() );
DrawList->Type() );
wxMessageBox( msg );
break;
}
......
......@@ -27,7 +27,6 @@
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "eeschema_id.h"
#include "libeditfrm.h"
......@@ -133,8 +132,8 @@ public:
void NewSizePin(int newsize);
void SetPinShape( int newshape);
void SetPinType(int newtype);
void SetPinOrient(int neworient);
void SetAttributsPin(bool draw, bool unit, bool convert);
void SetPinOrientation(int neworient);
void SetPinAttributes(bool draw, bool unit, bool convert);
////@begin WinEDA_PinPropertiesFrame member variables
wxTextCtrl* m_PinNameCtrl;
......
This diff is collapsed.
......@@ -65,7 +65,7 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
Multi = DrawLibItem->m_Multi;
convert = DrawLibItem->m_Convert;
for( LIB_DRAW_ITEM* DEntry = Entry->m_Drawings;
for( LIB_DRAW_ITEM* DEntry = Entry->GetNextDrawItem();
DEntry != NULL; DEntry = DEntry->Next() )
{
/* Elimination des elements non relatifs a l'unite */
......
......@@ -21,14 +21,6 @@ class DrawSheetStruct;
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 );
......@@ -158,13 +150,6 @@ SCH_ITEM* PickStruct( const wxPoint& refpos,
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,
const wxPoint& pos );
LibDrawPin* LocateAnyPin( SCH_ITEM* DrawList,
......@@ -252,20 +237,6 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Window );
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 */
/**************/
......
......@@ -140,13 +140,12 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
}
/****************************************************************/
static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
/****************************************************************/
{
LIB_DRAW_ITEM* item;
WinEDA_LibeditFrame* parent = ( WinEDA_LibeditFrame* ) Panel->GetParent();
item = ( ( WinEDA_LibeditFrame* ) Panel->GetParent() )->GetDrawItem();
item = parent->GetDrawItem();
if( item == NULL )
return;
......@@ -164,6 +163,7 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
DefaultTransformMatrix );
SAFE_DELETE( item );
parent->SetDrawItem( NULL );
}
else
{
......@@ -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 )
return;
......@@ -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)
* m_drawItem
* m_component
*/
void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
{
if( m_component == NULL || m_drawItem == NULL )
return;
......@@ -538,11 +534,12 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
{
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
{
if( (m_drawItem->m_Flags & IS_MOVED) == 0 )
if( ( m_drawItem->m_Flags & IS_MOVED ) == 0 )
SymbolDisplayDraw( DrawPanel, DC, FALSE );
}
}
......@@ -552,8 +549,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
if( m_drawItem->m_Flags & IS_NEW )
{
SaveCopyInUndoList( m_component );
m_drawItem->SetNext( m_component->m_Drawings );
m_component->m_Drawings = m_drawItem;
m_component->AddDrawItem( m_drawItem );
switch( m_drawItem->Type() )
{
......@@ -581,8 +577,6 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
default:
;
}
m_component->SortDrawItems();
}
if( m_ID_current_state )
......@@ -590,7 +584,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
else
SetCursor( wxCURSOR_ARROW );
if( (m_drawItem->m_Flags & IS_MOVED) )
if( m_drawItem->m_Flags & IS_MOVED )
{
wxPoint pos;
pos.x = GetScreen()->m_Curseur.x + InitPosition.x - StartCursor.x,
......@@ -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
|| m_drawItem->Type() != COMPONENT_POLYLINE_DRAW_TYPE )
......@@ -718,7 +710,8 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
m_drawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
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();
unsigned idx = Poly->GetCornerCount() - 1;
......
......@@ -96,9 +96,9 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
DisplayError( this, _( "Warning: more than 1 part in Symbol File" ) );
Component = (LIB_COMPONENT*) Lib->GetFirstEntry();
DrawEntry = Component->m_Drawings;
DrawEntry = Component->GetNextDrawItem();
while( DrawEntry )
while( DrawEntry != NULL )
{
if( DrawEntry->m_Unit )
DrawEntry->m_Unit = m_unit;
......@@ -107,14 +107,9 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
DrawEntry->m_Flags = IS_NEW;
DrawEntry->m_Selected = IS_SELECTED;
if( DrawEntry->Next() == NULL ) /* Fin de liste trouvee */
{
DrawEntry->SetNext( m_component->m_Drawings );
m_component->m_Drawings = Component->m_Drawings;
Component->m_Drawings = NULL;
break;
}
LIB_DRAW_ITEM* newItem = DrawEntry->GenCopy();
newItem->SetParent( m_component );
m_component->AddDrawItem( newItem );
DrawEntry = DrawEntry->Next();
}
......@@ -122,13 +117,7 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
m_component->RemoveDuplicateDrawItems();
// Clear flags
DrawEntry = m_component->m_Drawings;
while( DrawEntry )
{
DrawEntry->m_Flags = 0;
DrawEntry->m_Selected = 0;
DrawEntry = DrawEntry->Next();
}
m_component->ClearSelectedItems();
GetScreen()->SetModify();
DrawPanel->Refresh();
......@@ -151,7 +140,7 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
wxString msg;
FILE* ExportFile;
if( m_component->m_Drawings == NULL )
if( m_component->GetNextDrawItem() == NULL )
return;
/* Creation du fichier symbole */
......@@ -215,11 +204,12 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
/* Position / orientation / visibilite des champs */
m_component->m_Prefix.Save( ExportFile );
m_component->m_Name.Save( ExportFile );
DrawEntry = m_component->m_Drawings;
DrawEntry = m_component->GetNextDrawItem();
if( DrawEntry )
{
fprintf( ExportFile, "DRAW\n" );
for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() )
{
/* Elimination des elements non relatifs a l'unite */
......
......@@ -255,7 +255,7 @@ protected:
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
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