Commit 76d04d6a authored by stambaughw's avatar stambaughw

Library component and draw object improvements and compile warning fix.

* Library component draw items now stored in Boost ptr_vector.
* Updated draw item object comparison to include greater and less than condition.
* Moved set parts per package code from component edit dialog to component object.
* Moved set alternate body style code from component edit dialog to component object.
* Tweaked component library file draw item sort order for improved file readability.
* Documented component object draw item sort ordering.
* Moved plot code to the appropriate library component and draw item objects.
* Fixed compiler type conversion warning in plot_common.h.
parent f765a408
...@@ -505,7 +505,7 @@ static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsLi ...@@ -505,7 +505,7 @@ static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsLi
} }
/* Annotation of one part per package components (trivial case)*/ /* Annotation of one part per package components (trivial case)*/
if( aComponentsList[ii].m_Entry->m_UnitCount <= 1 ) if( aComponentsList[ii].m_Entry->GetPartCount() <= 1 )
{ {
if( aComponentsList[ii].m_IsNew ) if( aComponentsList[ii].m_IsNew )
{ {
...@@ -520,7 +520,7 @@ static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsLi ...@@ -520,7 +520,7 @@ static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsLi
/* Annotation of multi-part components ( n parts per package ) /* Annotation of multi-part components ( n parts per package )
* (complex case) */ * (complex case) */
NumberOfUnits = aComponentsList[ii].m_Entry->m_UnitCount; NumberOfUnits = aComponentsList[ii].m_Entry->GetPartCount();
if( aComponentsList[ii].m_IsNew ) if( aComponentsList[ii].m_IsNew )
{ {
...@@ -709,7 +709,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne ...@@ -709,7 +709,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
} }
// Annotate error // Annotate error
if( MAX( ComponentsList[ii].m_Entry->m_UnitCount, 1 ) < ComponentsList[ii].m_Unit ) if( MAX( ComponentsList[ii].m_Entry->GetPartCount(), 1 ) < ComponentsList[ii].m_Unit )
{ {
if( ComponentsList[ii].m_NumRef >= 0 ) if( ComponentsList[ii].m_NumRef >= 0 )
Buff << ComponentsList[ii].m_NumRef; Buff << ComponentsList[ii].m_NumRef;
...@@ -721,7 +721,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne ...@@ -721,7 +721,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
Buff.GetData() ); Buff.GetData() );
Buff.Printf( _( " unit %d and no more than %d parts" ), Buff.Printf( _( " unit %d and no more than %d parts" ),
ComponentsList[ii].m_Unit, ComponentsList[ii].m_Entry->m_UnitCount ); ComponentsList[ii].m_Unit, ComponentsList[ii].m_Entry->GetPartCount() );
msg << Buff; msg << Buff;
if( aMessageList ) if( aMessageList )
{ {
...@@ -777,7 +777,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne ...@@ -777,7 +777,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
/* Test error if units are different but number of parts per package /* Test error if units are different but number of parts per package
* too hight (ex U3 ( 1 part) and we find U3B this is an error) */ * too hight (ex U3 ( 1 part) and we find U3B this is an error) */
if( ComponentsList[ii].m_Entry->m_UnitCount != ComponentsList[ii + 1].m_Entry->m_UnitCount ) if( ComponentsList[ii].m_Entry->GetPartCount() != ComponentsList[ii + 1].m_Entry->GetPartCount() )
{ {
if( ComponentsList[ii].m_NumRef >= 0 ) if( ComponentsList[ii].m_NumRef >= 0 )
Buff << ComponentsList[ii].m_NumRef; Buff << ComponentsList[ii].m_NumRef;
......
...@@ -650,7 +650,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( ...@@ -650,7 +650,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
Unit = ' '; Unit = ' ';
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry ) if( Entry )
Multi = Entry->m_UnitCount; Multi = Entry->GetPartCount();
if( ( Multi > 1 ) && aIncludeSubComponents ) if( ( Multi > 1 ) && aIncludeSubComponents )
#if defined (KICAD_GOST) #if defined (KICAD_GOST)
...@@ -749,7 +749,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( ...@@ -749,7 +749,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal(
Unit = ' '; Unit = ' ';
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry ) if( Entry )
Multi = Entry->m_UnitCount; Multi = Entry->GetPartCount();
if( ( Multi > 1 ) && aIncludeSubComponents ) if( ( Multi > 1 ) && aIncludeSubComponents )
{ {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "plot_common.h"
#include "drawtxt.h" #include "drawtxt.h"
#include "trigo.h" #include "trigo.h"
...@@ -248,6 +249,23 @@ void LibDrawText::DoMirrorHorizontal( const wxPoint& center ) ...@@ -248,6 +249,23 @@ void LibDrawText::DoMirrorHorizontal( const wxPoint& center )
} }
void LibDrawText::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] )
{
wxASSERT( plotter != NULL );
/* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. */
int t1 = ( transform[0][0] != 0 ) ^ ( m_Orient != 0 );
wxPoint pos = TransformCoordinate( transform, m_Pos ) + offset;
plotter->text( pos, UNSPECIFIED_COLOR, m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
m_Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
GetPenSize(), m_Italic, m_Bold );
}
/** 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
*/ */
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "kicad_string.h" #include "kicad_string.h"
#include "confirm.h" #include "confirm.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "plot_common.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "program.h" #include "program.h"
...@@ -15,134 +16,7 @@ ...@@ -15,134 +16,7 @@
#include "class_library.h" #include "class_library.h"
#include "class_libentry.h" #include "class_libentry.h"
#include <boost/foreach.hpp>
int SortItemsFct(const void* ref, const void* item)
{
#define Ref ( *(LIB_DRAW_ITEM**) (ref) )
#define Item ( *(LIB_DRAW_ITEM**) (item) )
#define BEFORE -1
#define AFTER 1
int fill_ref = 0, fill_item = 0;
switch( Ref->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
{
const LibDrawArc* draw = (const LibDrawArc*) Ref;
fill_ref = draw->m_Fill;
break;
}
case COMPONENT_CIRCLE_DRAW_TYPE:
{
const LibDrawCircle* draw = (const LibDrawCircle*) Ref;
fill_ref = draw->m_Fill;
break;
}
case COMPONENT_RECT_DRAW_TYPE:
{
const LibDrawSquare* draw = (const LibDrawSquare*) Ref;
fill_ref = draw->m_Fill;
break;
}
case COMPONENT_POLYLINE_DRAW_TYPE:
{
const LibDrawPolyline* draw = (const LibDrawPolyline*) Ref;
fill_ref = draw->m_Fill;
break;
}
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
if( Item->Type() == COMPONENT_PIN_DRAW_TYPE )
return BEFORE;
if( Item->Type() == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE )
return 0;
return 1;
break;
case COMPONENT_PIN_DRAW_TYPE:
if( Item->Type() == COMPONENT_PIN_DRAW_TYPE )
{
int ii;
// Sort the pins by orientation
ii = ( (LibDrawPin*) Ref )->m_Orient -
( (LibDrawPin*) Item )->m_Orient;
if( ii )
return ii;
/* We sort the pins by position (x or y).
* note: at this point, most of pins have same x pos or y pos,
* because they are sorted by orientation and generally are
* vertically or horizontally aligned */
wxPoint pos_ref, pos_tst;
pos_ref = ( (LibDrawPin*) Ref )->m_Pos;
pos_tst = ( (LibDrawPin*) Item )->m_Pos;
if( (ii = pos_ref.x - pos_tst.x) )
return ii;
ii = pos_ref.y - pos_tst.y;
return ii;
}
else
return AFTER;
break;
default:
;
}
/* Test de l'item */
switch( Item->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
{
const LibDrawArc* draw = (const LibDrawArc*) Item;
fill_item = draw->m_Fill;
break;
}
case COMPONENT_CIRCLE_DRAW_TYPE:
{
const LibDrawCircle* draw = (const LibDrawCircle*) Item;
fill_item = draw->m_Fill;
break;
}
case COMPONENT_RECT_DRAW_TYPE:
{
const LibDrawSquare* draw = (const LibDrawSquare*) Item;
fill_item = draw->m_Fill;
break;
}
case COMPONENT_POLYLINE_DRAW_TYPE:
{
const LibDrawPolyline* draw = (const LibDrawPolyline*) Item;
fill_item = draw->m_Fill;
break;
}
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
return BEFORE;
break;
case COMPONENT_PIN_DRAW_TYPE:
return BEFORE;
break;
default:
;
}
if( fill_ref & fill_item )
return 0;
if( fill_ref )
return BEFORE;
return AFTER;
}
/*********************/ /*********************/
...@@ -169,7 +43,7 @@ CMP_LIB_ENTRY::CMP_LIB_ENTRY( LibrEntryType type, const wxString& name, ...@@ -169,7 +43,7 @@ CMP_LIB_ENTRY::CMP_LIB_ENTRY( LibrEntryType type, const wxString& name,
} }
CMP_LIB_ENTRY::CMP_LIB_ENTRY( const CMP_LIB_ENTRY& entry, CMP_LIBRARY* lib ) : CMP_LIB_ENTRY::CMP_LIB_ENTRY( CMP_LIB_ENTRY& entry, CMP_LIBRARY* lib ) :
EDA_BaseStruct( entry ) EDA_BaseStruct( entry )
{ {
Type = entry.Type; Type = entry.Type;
...@@ -274,7 +148,7 @@ LIB_ALIAS::LIB_ALIAS( const wxString& name, LIB_COMPONENT* root, ...@@ -274,7 +148,7 @@ LIB_ALIAS::LIB_ALIAS( const wxString& name, LIB_COMPONENT* root,
} }
LIB_ALIAS::LIB_ALIAS( const LIB_ALIAS& alias, CMP_LIBRARY* lib ) : LIB_ALIAS::LIB_ALIAS( LIB_ALIAS& alias, CMP_LIBRARY* lib ) :
CMP_LIB_ENTRY( alias ) CMP_LIB_ENTRY( alias )
{ {
m_root = alias.m_root; m_root = alias.m_root;
...@@ -303,7 +177,6 @@ void LIB_ALIAS::SetComponent( LIB_COMPONENT* root ) ...@@ -303,7 +177,6 @@ void LIB_ALIAS::SetComponent( LIB_COMPONENT* root )
LIB_COMPONENT::LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib ) : LIB_COMPONENT::LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib ) :
CMP_LIB_ENTRY( ROOT, name, lib ) CMP_LIB_ENTRY( ROOT, name, lib )
{ {
m_Drawings = NULL;
m_LastDate = 0; m_LastDate = 0;
m_UnitCount = 1; m_UnitCount = 1;
m_TextInside = 40; m_TextInside = 40;
...@@ -316,13 +189,10 @@ LIB_COMPONENT::LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib ) : ...@@ -316,13 +189,10 @@ LIB_COMPONENT::LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib ) :
} }
LIB_COMPONENT::LIB_COMPONENT( const LIB_COMPONENT& component, LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& component, CMP_LIBRARY* lib ) :
CMP_LIBRARY* lib ) :
CMP_LIB_ENTRY( component, lib ) CMP_LIB_ENTRY( component, lib )
{ {
LIB_DRAW_ITEM* oldItem;
LIB_DRAW_ITEM* newItem; LIB_DRAW_ITEM* newItem;
LIB_DRAW_ITEM* lastItem = NULL;
LibDrawField* oldField; LibDrawField* oldField;
LibDrawField* newField; LibDrawField* newField;
...@@ -335,26 +205,17 @@ LIB_COMPONENT::LIB_COMPONENT( const LIB_COMPONENT& component, ...@@ -335,26 +205,17 @@ 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 );
for( oldItem = component.m_Drawings; oldItem != NULL; BOOST_FOREACH( LIB_DRAW_ITEM& oldItem, component.GetDrawItemList() )
oldItem = oldItem->Next() )
{ {
if( ( oldItem->m_Flags & IS_NEW ) != 0 ) if( ( oldItem.m_Flags & IS_NEW ) != 0 )
continue; continue;
newItem = oldItem->GenCopy(); newItem = oldItem.GenCopy();
if( lastItem == NULL )
m_Drawings = newItem;
else
lastItem->SetNext( newItem );
newItem->SetParent( this ); newItem->SetParent( this );
lastItem = newItem; m_Drawings.push_back( newItem );
newItem->SetNext( NULL );
} }
for( oldField = component.m_Fields; oldField != NULL; for( oldField = component.m_Fields; oldField != NULL;
...@@ -369,19 +230,6 @@ LIB_COMPONENT::LIB_COMPONENT( const LIB_COMPONENT& component, ...@@ -369,19 +230,6 @@ LIB_COMPONENT::LIB_COMPONENT( const LIB_COMPONENT& component,
LIB_COMPONENT::~LIB_COMPONENT() LIB_COMPONENT::~LIB_COMPONENT()
{ {
LIB_DRAW_ITEM* DrawItem;
LIB_DRAW_ITEM* NextDrawItem;
/* suppression des elements dependants */
DrawItem = m_Drawings;
m_Drawings = NULL;
while( DrawItem )
{
NextDrawItem = DrawItem->Next();
SAFE_DELETE( DrawItem );
DrawItem = NextDrawItem;
}
} }
...@@ -399,37 +247,36 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc, ...@@ -399,37 +247,36 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
GRSetDrawMode( dc, drawMode ); GRSetDrawMode( dc, drawMode );
for( drawItem = m_Drawings; drawItem != NULL; drawItem = drawItem->Next() ) BOOST_FOREACH( LIB_DRAW_ITEM& drawItem, m_Drawings )
{ {
if( onlySelected && drawItem->m_Selected == 0 ) if( onlySelected && drawItem.m_Selected == 0 )
continue; continue;
// Do not draw an item while moving (the cursor handler does that) // Do not draw an item while moving (the cursor handler does that)
if( drawItem->m_Flags & IS_MOVED ) if( drawItem.m_Flags & IS_MOVED )
continue; continue;
/* Do not draw items not attached to the current part */ /* Do not draw items not attached to the current part */
if( multi && drawItem->m_Unit && ( drawItem->m_Unit != multi ) ) if( multi && drawItem.m_Unit && ( drawItem.m_Unit != multi ) )
continue; continue;
if( convert && drawItem->m_Convert if( convert && drawItem.m_Convert && ( drawItem.m_Convert != convert ) )
&& ( drawItem->m_Convert != convert ) )
continue; continue;
if( drawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) if( drawItem.Type() == COMPONENT_PIN_DRAW_TYPE )
{ {
drawItem->Draw( panel, dc, offset, color, drawMode, &showPinText, drawItem.Draw( panel, dc, offset, color, drawMode, &showPinText,
transformMatrix ); transformMatrix );
} }
else else
{ {
bool force_nofill = bool force_nofill =
( screen->m_IsPrinting ( screen->m_IsPrinting
&& drawItem->m_Fill == FILLED_WITH_BG_BODYCOLOR && drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR
&& GetGRForceBlackPenState() ); && GetGRForceBlackPenState() );
drawItem->Draw( panel, dc, offset, color, drawMode, drawItem.Draw( panel, dc, offset, color, drawMode,
(void*) force_nofill, transformMatrix ); (void*) force_nofill, transformMatrix );
} }
} }
...@@ -493,13 +340,33 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc, ...@@ -493,13 +340,33 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
} }
void LIB_COMPONENT::Plot( PLOTTER* plotter, int unit, int convert,
const wxPoint& offset, const int transform[2][2] )
{
wxASSERT( plotter != NULL );
BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
{
if( unit && item.m_Unit && ( item.m_Unit != unit ) )
continue;
if( convert && item.m_Convert && ( item.m_Convert != convert ) )
continue;
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
bool fill = plotter->get_color_mode();
item.Plot( plotter, offset, fill, transform );
}
}
void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item, void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item,
WinEDA_DrawPanel* panel, WinEDA_DrawPanel* panel,
wxDC* dc ) wxDC* dc )
{ {
wxASSERT( item != NULL ); wxASSERT( item != NULL );
LIB_DRAW_ITEM* prevItem = m_Drawings; LIB_DRAW_ITEM_LIST::iterator i;
if( dc != NULL ) if( dc != NULL )
item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, item->Draw( panel, dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
...@@ -507,23 +374,13 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item, ...@@ -507,23 +374,13 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item,
if( item->Type() != COMPONENT_FIELD_DRAW_TYPE ) if( item->Type() != COMPONENT_FIELD_DRAW_TYPE )
{ {
if( m_Drawings == item ) for( i = m_Drawings.begin(); i < m_Drawings.end(); i++ )
{
m_Drawings = item->Next();
SAFE_DELETE( item );
return;
}
while( prevItem )
{ {
if( prevItem->Next() == item ) if( *i == item )
{ {
prevItem->SetNext( item->Next() ); m_Drawings.erase( i );
SAFE_DELETE( item );
break; break;
} }
prevItem = prevItem->Next();
} }
} }
else else
...@@ -547,41 +404,30 @@ void LIB_COMPONENT::AddDrawItem( LIB_DRAW_ITEM* item ) ...@@ -547,41 +404,30 @@ void LIB_COMPONENT::AddDrawItem( LIB_DRAW_ITEM* item )
{ {
wxASSERT( item != NULL ); wxASSERT( item != NULL );
if( m_Drawings == NULL ) m_Drawings.push_back( item );
{ m_Drawings.sort();
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, LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* item,
KICAD_T type ) KICAD_T type )
{ {
if( type == TYPE_NOT_INIT ) if( m_Drawings.empty() )
return ( item == NULL ) ? m_Drawings : item->Next(); return NULL;
LIB_DRAW_ITEM* i = ( item == NULL ) ? m_Drawings : item->Next(); if( item == NULL && type == TYPE_NOT_INIT )
return &m_Drawings[0];
while( i != NULL ) for( size_t i = 0; i < m_Drawings.size() - 1; i++ )
{ {
if( i->Type() == type ) if( item != &m_Drawings[i] )
return i; continue;
i = i->Next(); if( type == TYPE_NOT_INIT || m_Drawings[ i + 1 ].Type() == type )
return &m_Drawings[ i + 1 ];
} }
return i; return NULL;
} }
...@@ -593,12 +439,8 @@ LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* item, ...@@ -593,12 +439,8 @@ LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* item,
*/ */
bool LIB_COMPONENT::Save( FILE* aFile ) bool LIB_COMPONENT::Save( FILE* aFile )
{ {
LIB_DRAW_ITEM* DrawEntry;
LibDrawField* Field; LibDrawField* Field;
/* Sort just in clase sorting was not done properly. */
SortDrawItems();
/* First line: it s a comment (component name for readers) */ /* First line: it s a comment (component name for readers) */
if( fprintf( aFile, "#\n# %s\n#\n", CONV_TO_UTF8( m_Name.m_Text ) ) < 0 ) if( fprintf( aFile, "#\n# %s\n#\n", CONV_TO_UTF8( m_Name.m_Text ) ) < 0 )
return false; return false;
...@@ -683,21 +525,19 @@ bool LIB_COMPONENT::Save( FILE* aFile ) ...@@ -683,21 +525,19 @@ bool LIB_COMPONENT::Save( FILE* aFile )
} }
/* Save graphics items (including pins) */ /* Save graphics items (including pins) */
if( m_Drawings ) if( !m_Drawings.empty() )
{ {
/* we sort the draw items, in order to have an edition more easy, /* we sort the draw items, in order to have an edition more easy,
* when a file editing "by hand" is made */ * when a file editing "by hand" is made */
SortDrawItems(); m_Drawings.sort();
if( fprintf( aFile, "DRAW\n" ) < 0 ) if( fprintf( aFile, "DRAW\n" ) < 0 )
return false; return false;
DrawEntry = m_Drawings; BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
while( DrawEntry )
{ {
if( !DrawEntry->Save( aFile ) ) if( !item.Save( aFile ) )
return false; return false;
DrawEntry = DrawEntry->Next();
} }
if( fprintf( aFile, "ENDDRAW\n" ) < 0 ) if( fprintf( aFile, "ENDDRAW\n" ) < 0 )
...@@ -823,7 +663,7 @@ bool LIB_COMPONENT::Load( FILE* file, char* line, int* lineNum, ...@@ -823,7 +663,7 @@ bool LIB_COMPONENT::Load( FILE* file, char* line, int* lineNum,
} }
/* If we are here, this part is O.k. - put it in: */ /* If we are here, this part is O.k. - put it in: */
SortDrawItems(); m_Drawings.sort();
return true; return true;
} }
...@@ -833,8 +673,6 @@ bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line, ...@@ -833,8 +673,6 @@ bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line,
int* lineNum, wxString& errorMsg ) int* lineNum, wxString& errorMsg )
{ {
LIB_DRAW_ITEM* newEntry = NULL; LIB_DRAW_ITEM* newEntry = NULL;
LIB_DRAW_ITEM* headEntry = NULL;
LIB_DRAW_ITEM* tailEntry = NULL;
while( true ) while( true )
{ {
...@@ -881,7 +719,6 @@ bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line, ...@@ -881,7 +719,6 @@ bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line,
default: default:
errorMsg.Printf( wxT( "undefined DRAW command %c" ), line[0] ); errorMsg.Printf( wxT( "undefined DRAW command %c" ), line[0] );
m_Drawings = headEntry;
return false; return false;
} }
...@@ -902,22 +739,14 @@ to flush to end of drawing section." ); ...@@ -902,22 +739,14 @@ to flush to end of drawing section." );
} }
} while( strncmp( line, "ENDDRAW", 7 ) != 0 ); } while( strncmp( line, "ENDDRAW", 7 ) != 0 );
SAFE_DELETE( headEntry );
return false; return false;
} }
else else
{ {
if( headEntry == NULL ) m_Drawings.push_back( newEntry );
headEntry = tailEntry = newEntry;
else
{
tailEntry->SetNext( newEntry );
tailEntry = newEntry;
}
} }
} }
m_Drawings = headEntry;
return true; return true;
} }
...@@ -986,48 +815,6 @@ bool LIB_COMPONENT::LoadFootprints( FILE* file, char* line, ...@@ -986,48 +815,6 @@ bool LIB_COMPONENT::LoadFootprints( FILE* file, char* line,
} }
/* TODO translate comment to english TODO
* Trie les �l�ments graphiques d'un composant lib pour am�liorer
* le trac�:
* items remplis en premier, pins en dernier
* En cas de superposition d'items, c'est plus lisible
*/
void LIB_COMPONENT::SortDrawItems()
{
LIB_DRAW_ITEM** Bufentry, ** BufentryBase, * Entry = m_Drawings;
int ii, nbitems;
if( Entry == NULL )
return; /* Pas d'alias pour ce composant */
for( nbitems = 0; Entry != NULL; Entry = Entry->Next() )
nbitems++;
BufentryBase =
(LIB_DRAW_ITEM**) MyZMalloc( (nbitems + 1) *
sizeof(LIB_DRAW_ITEM*) );
/* memorisation du chainage : */
for( Entry = m_Drawings, ii = 0; Entry != NULL; Entry = Entry->Next() )
BufentryBase[ii++] = Entry;
/* Tri du chainage */
qsort( BufentryBase, nbitems, sizeof(LIB_DRAW_ITEM*), SortItemsFct );
/* Mise a jour du chainage. Remarque:
* le dernier element de BufEntryBase (BufEntryBase[nbitems]) est NULL*/
m_Drawings = *BufentryBase;
Bufentry = BufentryBase;
for( ii = 0; ii < nbitems; ii++ )
{
(*Bufentry)->SetNext( *(Bufentry + 1) );
Bufentry++;
}
MyFree( BufentryBase );
}
/**********************************************************************/ /**********************************************************************/
/* Return the component boundary box ( in user coordinates ) /* Return the component boundary box ( in user coordinates )
* The unit Unit, and the shape Convert are considered. * The unit Unit, and the shape Convert are considered.
...@@ -1037,20 +824,18 @@ void LIB_COMPONENT::SortDrawItems() ...@@ -1037,20 +824,18 @@ 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* item;
EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); EDA_Rect bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
for( item = m_Drawings; item != NULL; item = item->Next() ) BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
{ {
if( ( item->m_Unit > 0 ) if( ( item.m_Unit > 0 ) && ( ( m_UnitCount > 1 ) && ( Unit > 0 )
&& ( ( m_UnitCount > 1 ) && ( Unit > 0 ) && ( Unit != item.m_Unit ) ) )
&& ( Unit != item->m_Unit ) ) )
continue; continue;
if( item->m_Convert > 0 if( item.m_Convert > 0
&& ( ( Convert > 0 ) && ( Convert != item->m_Convert ) ) ) && ( ( Convert > 0 ) && ( Convert != item.m_Convert ) ) )
continue; continue;
bBox.Merge( item->GetBoundingBox() ); bBox.Merge( item.GetBoundingBox() );
} }
bBox.Merge( m_Name.GetBoundingBox() ); bBox.Merge( m_Name.GetBoundingBox() );
...@@ -1160,8 +945,6 @@ bool LIB_COMPONENT::LoadDateAndTime( char* Line ) ...@@ -1160,8 +945,6 @@ bool LIB_COMPONENT::LoadDateAndTime( char* Line )
void LIB_COMPONENT::SetOffset( const wxPoint& offset ) void LIB_COMPONENT::SetOffset( const wxPoint& offset )
{ {
LIB_DRAW_ITEM* DrawEntry;
m_Name.SetOffset( offset ); m_Name.SetOffset( offset );
m_Prefix.SetOffset( offset ); m_Prefix.SetOffset( offset );
...@@ -1170,62 +953,24 @@ void LIB_COMPONENT::SetOffset( const wxPoint& offset ) ...@@ -1170,62 +953,24 @@ void LIB_COMPONENT::SetOffset( const wxPoint& offset )
field->SetOffset( offset ); field->SetOffset( offset );
} }
DrawEntry = m_Drawings; BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
while( DrawEntry )
{ {
DrawEntry->SetOffset( offset ); item.SetOffset( offset );
DrawEntry = DrawEntry->Next();
} }
} }
void LIB_COMPONENT::RemoveDuplicateDrawItems() void LIB_COMPONENT::RemoveDuplicateDrawItems()
{ {
LIB_DRAW_ITEM* DEntryRef; m_Drawings.unique();
LIB_DRAW_ITEM* DEntryCompare;
bool deleted;
DEntryRef = m_Drawings;
while( DEntryRef )
{
if( DEntryRef->Next() == NULL )
return;
DEntryCompare = DEntryRef->Next();
if( DEntryCompare == NULL )
return;
deleted = false;
while( DEntryCompare )
{
if( DEntryRef == DEntryCompare )
{
RemoveDrawItem( DEntryRef, NULL, NULL );
deleted = true;
break;
}
DEntryCompare = DEntryCompare->Next();
}
if( !deleted )
DEntryRef = DEntryRef->Next();
else
DEntryRef = m_Drawings;
}
} }
bool LIB_COMPONENT::HasConversion() const bool LIB_COMPONENT::HasConversion() const
{ {
LIB_DRAW_ITEM* entry; BOOST_FOREACH( const LIB_DRAW_ITEM& item, m_Drawings )
for( entry = m_Drawings; entry != NULL; entry = entry->Next() )
{ {
if( entry->m_Convert > 1 ) if( item.m_Convert > 1 )
return true; return true;
} }
...@@ -1235,11 +980,10 @@ bool LIB_COMPONENT::HasConversion() const ...@@ -1235,11 +980,10 @@ bool LIB_COMPONENT::HasConversion() const
void LIB_COMPONENT::ClearStatus( void ) void LIB_COMPONENT::ClearStatus( void )
{ {
LIB_DRAW_ITEM* item;
LibDrawField* field; LibDrawField* field;
for( item = m_Drawings; item != NULL; item = item->Next() ) BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
item->m_Flags = 0; item.m_Flags = 0;
m_Name.m_Flags = 0; m_Name.m_Flags = 0;
m_Prefix.m_Flags = 0; m_Prefix.m_Flags = 0;
...@@ -1252,28 +996,27 @@ void LIB_COMPONENT::ClearStatus( void ) ...@@ -1252,28 +996,27 @@ void LIB_COMPONENT::ClearStatus( void )
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 )
{ {
LIB_DRAW_ITEM* item;
int ItemsCount = 0; int ItemsCount = 0;
for( item = m_Drawings; item != NULL; item = item->Next() ) BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
{ {
item->m_Selected = 0; item.m_Selected = 0;
if( ( item->m_Unit && item->m_Unit != unit ) if( ( item.m_Unit && item.m_Unit != unit )
|| ( item->m_Convert && item->m_Convert != convert ) ) || ( item.m_Convert && item.m_Convert != convert ) )
{ {
if( item->Type() != COMPONENT_PIN_DRAW_TYPE ) if( item.Type() != COMPONENT_PIN_DRAW_TYPE )
continue; continue;
// Specific rules for pins. // Specific rules for pins.
if( editPinByPin || m_UnitSelectionLocked if( editPinByPin || m_UnitSelectionLocked
|| ( item->m_Convert && item->m_Convert != convert ) ) || ( item.m_Convert && item.m_Convert != convert ) )
continue; continue;
} }
if( item->Inside( rect ) ) if( item.Inside( rect ) )
{ {
item->m_Selected = IS_SELECTED; item.m_Selected = IS_SELECTED;
ItemsCount++; ItemsCount++;
} }
} }
...@@ -1306,16 +1049,15 @@ int LIB_COMPONENT::SelectItems( EDA_Rect& rect, int unit, int convert, ...@@ -1306,16 +1049,15 @@ int LIB_COMPONENT::SelectItems( EDA_Rect& rect, int unit, int convert,
void LIB_COMPONENT::MoveSelectedItems( const wxPoint& offset ) void LIB_COMPONENT::MoveSelectedItems( const wxPoint& offset )
{ {
LIB_DRAW_ITEM* item;
LibDrawField* field; LibDrawField* field;
for( item = m_Drawings; item != NULL; item = item->Next() ) BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
{ {
if( item->m_Selected == 0 ) if( item.m_Selected == 0 )
continue; continue;
item->SetOffset( offset ); item.SetOffset( offset );
item->m_Flags = item->m_Selected = 0; item.m_Flags = item.m_Selected = 0;
} }
if( m_Name.m_Selected ) if( m_Name.m_Selected )
...@@ -1339,17 +1081,16 @@ void LIB_COMPONENT::MoveSelectedItems( const wxPoint& offset ) ...@@ -1339,17 +1081,16 @@ void LIB_COMPONENT::MoveSelectedItems( const wxPoint& offset )
} }
} }
SortDrawItems(); m_Drawings.sort();
} }
void LIB_COMPONENT::ClearSelectedItems( void ) void LIB_COMPONENT::ClearSelectedItems( void )
{ {
LIB_DRAW_ITEM* item;
LibDrawField* field; LibDrawField* field;
for( item = m_Drawings; item != NULL; item = item->Next() ) BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
item->m_Flags = item->m_Selected = 0; item.m_Flags = item.m_Selected = 0;
m_Name.m_Flags = m_Name.m_Selected = 0; m_Name.m_Flags = m_Name.m_Selected = 0;
m_Prefix.m_Flags = m_Prefix.m_Selected = 0; m_Prefix.m_Flags = m_Prefix.m_Selected = 0;
...@@ -1361,53 +1102,46 @@ void LIB_COMPONENT::ClearSelectedItems( void ) ...@@ -1361,53 +1102,46 @@ void LIB_COMPONENT::ClearSelectedItems( void )
void LIB_COMPONENT::DeleteSelectedItems( void ) void LIB_COMPONENT::DeleteSelectedItems( void )
{ {
LIB_DRAW_ITEM* item; LIB_DRAW_ITEM_LIST::iterator i = m_Drawings.begin();
LIB_DRAW_ITEM* nextItem;
for( item = m_Drawings; item != NULL; item = nextItem ) while( i != m_Drawings.end() )
{ {
nextItem = item->Next(); if( i->m_Selected == 0 )
i++;
if( item->m_Selected == 0 ) else
continue; i = m_Drawings.erase( i );
RemoveDrawItem( item );
} }
} }
void LIB_COMPONENT::CopySelectedItems( const wxPoint& offset ) void LIB_COMPONENT::CopySelectedItems( const wxPoint& offset )
{ {
LIB_DRAW_ITEM* item; BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
for( item = m_Drawings; item != NULL; item = item->Next() )
{ {
if( item->m_Selected == 0 ) if( item.m_Selected == 0 )
continue; continue;
item->m_Selected = 0; item.m_Selected = 0;
LIB_DRAW_ITEM* newItem = item->GenCopy(); LIB_DRAW_ITEM* newItem = item.GenCopy();
newItem->m_Selected = IS_SELECTED; newItem->m_Selected = IS_SELECTED;
newItem->SetNext( m_Drawings ); m_Drawings.push_back( newItem );
m_Drawings = newItem;
} }
MoveSelectedItems( offset ); MoveSelectedItems( offset );
SortDrawItems(); m_Drawings.sort();
} }
void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& center ) void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& center )
{ {
LIB_DRAW_ITEM* item;
LibDrawField* field; LibDrawField* field;
for( item = m_Drawings; item != NULL; item = item->Next() ) BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
{ {
if( item->m_Selected == 0 ) if( item.m_Selected == 0 )
continue; continue;
item->SetOffset( center ); item.SetOffset( center );
item->m_Flags = item->m_Selected = 0; item.m_Flags = item.m_Selected = 0;
} }
if( m_Name.m_Selected ) if( m_Name.m_Selected )
...@@ -1431,25 +1165,24 @@ void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& center ) ...@@ -1431,25 +1165,24 @@ void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& center )
} }
} }
SortDrawItems(); m_Drawings.sort();
} }
LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert, LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert,
KICAD_T type, const wxPoint& pt ) KICAD_T type, const wxPoint& pt )
{ {
LIB_DRAW_ITEM* item;
LibDrawField* field; LibDrawField* field;
for( item = m_Drawings; item != NULL; item = item->Next() ) BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
{ {
if( ( unit && item->m_Unit && ( unit != item->m_Unit) ) if( ( unit && item.m_Unit && ( unit != item.m_Unit) )
|| ( convert && item->m_Convert && ( convert != item->m_Convert ) ) || ( convert && item.m_Convert && ( convert != item.m_Convert ) )
|| ( ( item->Type() != type ) && ( type != TYPE_NOT_INIT ) ) ) || ( ( item.Type() != type ) && ( type != TYPE_NOT_INIT ) ) )
continue; continue;
if( item->HitTest( pt ) ) if( item.HitTest( pt ) )
return item; return &item;
} }
if( type == COMPONENT_FIELD_DRAW_TYPE || type == TYPE_NOT_INIT ) if( type == COMPONENT_FIELD_DRAW_TYPE || type == TYPE_NOT_INIT )
...@@ -1466,6 +1199,84 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert, ...@@ -1466,6 +1199,84 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert,
} }
} }
return NULL; return NULL;
} }
void LIB_COMPONENT::SetPartCount( int count )
{
LIB_DRAW_ITEM_LIST::iterator i;
if( m_UnitCount == count )
return;
if( count < m_UnitCount )
{
i = m_Drawings.begin();
while( i != m_Drawings.end() )
{
if( i->m_Unit > count )
i = m_Drawings.erase( i );
else
i++;
}
}
else
{
int prevCount = m_UnitCount;
for( i = m_Drawings.begin(); i != m_Drawings.end(); i++ )
{
if( i->m_Unit != 1 )
continue;
for( int j = prevCount + 1; j <= count; j++ )
{
LIB_DRAW_ITEM* newItem = i->GenCopy();
newItem->m_Unit = j;
m_Drawings.push_back( newItem );
}
}
m_Drawings.sort();
}
m_UnitCount = count;
}
void LIB_COMPONENT::SetConversion( bool asConvert )
{
if( asConvert == HasConversion() )
return;
if( asConvert )
{
BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
{
/* Only pins are duplicated. */
if( item.Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( item.m_Convert == 1 )
{
LIB_DRAW_ITEM* newItem = item.GenCopy();
newItem->m_Convert = 2;
m_Drawings.push_back( newItem );
}
}
}
else
{
LIB_DRAW_ITEM_LIST::iterator i = m_Drawings.begin();
while( i != m_Drawings.end() )
{
if( i->m_Convert > 1 )
i = m_Drawings.erase( i );
else
i++;
}
}
}
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
public: public:
CMP_LIB_ENTRY( LibrEntryType CmpType, const wxString& name, CMP_LIB_ENTRY( LibrEntryType CmpType, const wxString& name,
CMP_LIBRARY* lib = NULL ); CMP_LIBRARY* lib = NULL );
CMP_LIB_ENTRY( const CMP_LIB_ENTRY& entry, CMP_LIBRARY* lib = NULL ); CMP_LIB_ENTRY( CMP_LIB_ENTRY& entry, CMP_LIBRARY* lib = NULL );
virtual ~CMP_LIB_ENTRY(); virtual ~CMP_LIB_ENTRY();
...@@ -112,7 +112,6 @@ public: ...@@ -112,7 +112,6 @@ public:
wxArrayString m_FootprintList; /* list of suitable footprint names wxArrayString m_FootprintList; /* list of suitable footprint names
* for the component (wildcard names * for the component (wildcard names
* accepted) */ * accepted) */
int m_UnitCount; /* Units (or sections) per package */
bool m_UnitSelectionLocked; /* True if units are different bool m_UnitSelectionLocked; /* True if units are different
* and their selection is * and their selection is
* locked (i.e. if part A cannot * locked (i.e. if part A cannot
...@@ -125,9 +124,12 @@ public: ...@@ -125,9 +124,12 @@ public:
bool m_DrawPinNum; bool m_DrawPinNum;
bool m_DrawPinName; bool m_DrawPinName;
DLIST<LibDrawField> m_Fields; /* Auxiliary Field list (id >= 2 ) */ DLIST<LibDrawField> m_Fields; /* Auxiliary Field list (id >= 2 ) */
LIB_DRAW_ITEM * m_Drawings; /* How to draw this part */
long m_LastDate; // Last change Date long m_LastDate; // Last change Date
protected:
int m_UnitCount; /* Units (or sections) per package */
LIB_DRAW_ITEM_LIST m_Drawings; /* How to draw this part */
public: public:
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -136,14 +138,12 @@ public: ...@@ -136,14 +138,12 @@ public:
LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib = NULL ); LIB_COMPONENT( const wxString& name, CMP_LIBRARY* lib = NULL );
LIB_COMPONENT( const LIB_COMPONENT& component, CMP_LIBRARY* lib = NULL ); LIB_COMPONENT( LIB_COMPONENT& component, CMP_LIBRARY* lib = NULL );
~LIB_COMPONENT(); ~LIB_COMPONENT();
EDA_Rect GetBoundaryBox( int Unit, int Convert ); EDA_Rect GetBoundaryBox( int Unit, int Convert );
void SortDrawItems();
bool SaveDateAndTime( FILE* ExportFile ); bool SaveDateAndTime( FILE* ExportFile );
bool LoadDateAndTime( char* Line ); bool LoadDateAndTime( char* Line );
...@@ -204,6 +204,17 @@ public: ...@@ -204,6 +204,17 @@ public:
bool showPinText = true, bool drawFields = true, bool showPinText = true, bool drawFields = true,
bool onlySelected = false ); bool onlySelected = false );
/**
* Plot component to plotter.
*
* @param plotter - Plotter object to plot to.
* @param unit - Component part to plot.
* @param convert - Component alternate body style to plot.
* @param transform - Component plot transform matrix.
*/
void Plot( PLOTTER* plotter, int unit, int convert, const wxPoint& offset,
const int transform[2][2] );
/** /**
* Add a new draw item to the draw object list. * Add a new draw item to the draw object list.
* *
...@@ -344,6 +355,40 @@ public: ...@@ -344,6 +355,40 @@ public:
*/ */
LIB_DRAW_ITEM* LocateDrawItem( int unit, int convert, KICAD_T type, LIB_DRAW_ITEM* LocateDrawItem( int unit, int convert, KICAD_T type,
const wxPoint& pt ); const wxPoint& pt );
/**
* Return a reference to the draw item list.
*
* @return LIB_DRAW_ITEM_LIST& - Reference to the draw item object list.
*/
LIB_DRAW_ITEM_LIST& GetDrawItemList( void ) { return m_Drawings; }
/**
* Set the part per package count.
*
* If the count is greater than the current count, then the all of the
* current draw items are duplicated for each additional part. If the
* count is less than the current count, all draw objects for parts
* greater that count are removed from the component.
*
* @param count - Number of parts per package.
*/
void SetPartCount( int count );
int GetPartCount( void ) { return m_UnitCount; }
/**
* Set or clear the alternate body style (DeMorgan) for the component.
*
* If the component already has an alternate body style set and a
* asConvert if false, all of the existing draw items for the alternate
* body style are remove. If the alternate body style is not set and
* asConvert is true, than the base draw items are duplicated and
* added to the component.
*
* @param asConvert - Set or clear the component alternate body style.
*/
void SetConversion( bool asConvert );
}; };
...@@ -365,7 +410,7 @@ protected: ...@@ -365,7 +410,7 @@ protected:
public: public:
LIB_ALIAS( const wxString& name, LIB_COMPONENT* root, LIB_ALIAS( const wxString& name, LIB_COMPONENT* root,
CMP_LIBRARY* lib = NULL ); CMP_LIBRARY* lib = NULL );
LIB_ALIAS( const LIB_ALIAS& alias, CMP_LIBRARY* lib = NULL ); LIB_ALIAS( LIB_ALIAS& alias, CMP_LIBRARY* lib = NULL );
~LIB_ALIAS(); ~LIB_ALIAS();
virtual wxString GetClass() const virtual wxString GetClass() const
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "drawtxt.h" #include "drawtxt.h"
#include "kicad_string.h" #include "kicad_string.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "plot_common.h"
#include "trigo.h" #include "trigo.h"
#include "program.h" #include "program.h"
...@@ -356,7 +357,7 @@ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold, ...@@ -356,7 +357,7 @@ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold,
extraCharCount++; extraCharCount++;
m_Text.Append('?'); m_Text.Append('?');
LIB_COMPONENT* parent = (LIB_COMPONENT*)m_Parent; LIB_COMPONENT* parent = (LIB_COMPONENT*)m_Parent;
if ( parent && ( parent->m_UnitCount > 1 ) ) if ( parent && ( parent->GetPartCount() > 1 ) )
{ {
m_Text.Append('A'); m_Text.Append('A');
extraCharCount++; extraCharCount++;
...@@ -477,6 +478,12 @@ void LibDrawField::DoMirrorHorizontal( const wxPoint& center ) ...@@ -477,6 +478,12 @@ void LibDrawField::DoMirrorHorizontal( const wxPoint& center )
} }
void LibDrawField::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] )
{
}
/* /*
* 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
...@@ -490,7 +497,7 @@ wxString LibDrawField::GetFullText( int unit ) ...@@ -490,7 +497,7 @@ wxString LibDrawField::GetFullText( int unit )
wxString text = m_Text; wxString text = m_Text;
if( GetParent()->m_UnitCount > 1 ) if( GetParent()->GetPartCount() > 1 )
{ {
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
text.Printf( wxT( "%s?.%c" ), text.Printf( wxT( "%s?.%c" ),
......
...@@ -132,12 +132,28 @@ public: ...@@ -132,12 +132,28 @@ public:
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
/**
* Provide the field draw object specific comparison.
*
* The sort order for field is as follows:
*
* - Field ID, REFERENCE, VALUE, etc.
* - Field string, case insensitive compare.
* - Field horizontal (X) position.
* - Field vertical (Y) position.
* - Field width.
* - Field height.
*/
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
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 ); virtual void DoMirrorHorizontal( const wxPoint& center );
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] );
}; };
#endif // CLASS_LIBENTRY_FIELDS_H #endif // CLASS_LIBENTRY_FIELDS_H
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
#include "class_libentry.h" #include "class_libentry.h"
extern void PlotPinSymbol( PLOTTER* plotter, const wxPoint& pos,
int len, int orient, int Shape );
const wxChar* MsgPinElectricType[] = const wxChar* MsgPinElectricType[] =
{ {
wxT( "input" ), wxT( "input" ),
...@@ -1149,6 +1153,24 @@ void LibDrawPin::DoMirrorHorizontal( const wxPoint& center ) ...@@ -1149,6 +1153,24 @@ void LibDrawPin::DoMirrorHorizontal( const wxPoint& center )
} }
void LibDrawPin::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] )
{
if( m_Attributs & PINNOTDRAW )
return;
int orient = ReturnPinDrawOrient( transform );
wxPoint pos = TransformCoordinate( transform, m_Pos ) + offset;
plotter->set_current_line_width( GetPenSize() );
PlotPinSymbol( plotter, pos, m_PinLen, orient, m_PinShape );
PlotPinTexts( plotter, pos, orient, GetParent()->m_TextInside,
GetParent()->m_DrawPinNum, GetParent()->m_DrawPinName,
GetPenSize() );
}
/** 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
......
...@@ -426,7 +426,7 @@ void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -426,7 +426,7 @@ void SCH_CMP_FIELD::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
Entry = CMP_LIBRARY::FindLibraryComponent( component->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( component->m_ChipName );
if( Entry != NULL ) if( Entry != NULL )
{ {
if( Entry->m_UnitCount > 1 ) if( Entry->GetPartCount() > 1 )
m_AddExtraText = 1; m_AddExtraText = 1;
} }
} }
......
...@@ -191,7 +191,7 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -191,7 +191,7 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if( ( ( field->m_Attributs & TEXT_NO_VISIBLE ) == 0 ) if( ( ( field->m_Attributs & TEXT_NO_VISIBLE ) == 0 )
&& !( field->m_Flags & IS_MOVED ) ) && !( field->m_Flags & IS_MOVED ) )
{ {
if( Entry->m_UnitCount > 1 ) if( Entry->GetPartCount() > 1 )
{ {
field->m_AddExtraText = true; field->m_AddExtraText = true;
field->Draw( panel, DC, offset, DrawMode ); field->Draw( panel, DC, offset, DrawMode );
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "plot_common.h"
#include "drawtxt.h" #include "drawtxt.h"
#include "trigo.h" #include "trigo.h"
#include "bezier_curves.h" #include "bezier_curves.h"
...@@ -91,22 +92,22 @@ bool LIB_DRAW_ITEM::operator==( const LIB_DRAW_ITEM& other ) const ...@@ -91,22 +92,22 @@ bool LIB_DRAW_ITEM::operator==( const LIB_DRAW_ITEM& other ) const
bool LIB_DRAW_ITEM::operator<( const LIB_DRAW_ITEM& other ) const bool LIB_DRAW_ITEM::operator<( const LIB_DRAW_ITEM& other ) const
{ {
int result = Type() - other.Type(); int result = m_Convert - other.m_Convert;
if( result < 0 ) if( result != 0 )
return true; return result < 0;
result = m_Unit - other.m_Unit; result = m_Unit - other.m_Unit;
if( result < 0 ) if( result != 0 )
return true; return result < 0;
result = m_Convert - other.m_Convert; result = Type() - other.Type();
if( result < 0 ) if( result != 0 )
return true; return result < 0;
return DoCompare( other ) < 0; return ( DoCompare( other ) < 0 );
} }
...@@ -358,6 +359,28 @@ void LibDrawArc::DoMirrorHorizontal( const wxPoint& center ) ...@@ -358,6 +359,28 @@ void LibDrawArc::DoMirrorHorizontal( const wxPoint& center )
} }
void LibDrawArc::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] )
{
wxASSERT( plotter != NULL );
int t1 = m_t1;
int t2 = m_t2;
wxPoint pos = TransformCoordinate( transform, m_Pos ) + offset;
MapAngles( &t1, &t2, transform );
if( fill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->arc( pos, -t2, -t1, m_Radius, FILLED_SHAPE, 0 );
}
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->arc( pos, -t2, -t1, m_Radius, m_Fill, GetPenSize() );
}
/** 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
*/ */
...@@ -672,6 +695,22 @@ void LibDrawCircle::DoMirrorHorizontal( const wxPoint& center ) ...@@ -672,6 +695,22 @@ void LibDrawCircle::DoMirrorHorizontal( const wxPoint& center )
} }
void LibDrawCircle::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] )
{
wxPoint pos = TransformCoordinate( transform, m_Pos ) + offset;
if( fill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->circle( pos, m_Radius * 2, FILLED_SHAPE, 0 );
}
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->circle( pos, m_Radius * 2, m_Fill, GetPenSize() );
}
/** 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
*/ */
...@@ -888,6 +927,25 @@ void LibDrawSquare::DoMirrorHorizontal( const wxPoint& center ) ...@@ -888,6 +927,25 @@ void LibDrawSquare::DoMirrorHorizontal( const wxPoint& center )
} }
void LibDrawSquare::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] )
{
wxASSERT( plotter != NULL );
wxPoint pos = TransformCoordinate( transform, m_Pos ) + offset;
wxPoint end = TransformCoordinate( transform, m_End ) + offset;
if( fill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->rect( pos, end, FILLED_WITH_BG_BODYCOLOR, 0 );
}
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->rect( pos, end, m_Fill, GetPenSize() );
}
/** 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
*/ */
...@@ -1133,6 +1191,23 @@ void LibDrawSegment::DoMirrorHorizontal( const wxPoint& center ) ...@@ -1133,6 +1191,23 @@ void LibDrawSegment::DoMirrorHorizontal( const wxPoint& center )
} }
void LibDrawSegment::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] )
{
wxASSERT( plotter != NULL );
int points[4];
wxPoint pos = TransformCoordinate( transform, m_Pos ) + offset;
wxPoint end = TransformCoordinate( transform, m_End ) + offset;
points[0] = pos.x;
points[1] = pos.y;
points[2] = end.x;
points[3] = end.y;
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->poly( 2, points, m_Fill, GetPenSize() );
}
/** 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
*/ */
...@@ -1407,6 +1482,35 @@ void LibDrawPolyline::DoMirrorHorizontal( const wxPoint& center ) ...@@ -1407,6 +1482,35 @@ void LibDrawPolyline::DoMirrorHorizontal( const wxPoint& center )
} }
void LibDrawPolyline::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] )
{
wxASSERT( plotter != NULL );
size_t i;
int* Poly = (int*) MyMalloc( sizeof(int) * 2 * GetCornerCount() );
for( i = 0; i < m_PolyPoints.size(); i++ )
{
wxPoint pos = m_PolyPoints[i];
pos = TransformCoordinate( transform, pos ) + offset;
Poly[i * 2] = pos.x;
Poly[i * 2 + 1] = pos.y;
}
if( fill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->poly( i, Poly, FILLED_WITH_BG_BODYCOLOR, 0 );
}
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->poly( i, Poly, m_Fill, GetPenSize() );
MyFree( Poly );
}
void LibDrawPolyline::AddPoint( const wxPoint& point ) void LibDrawPolyline::AddPoint( const wxPoint& point )
{ {
m_PolyPoints.push_back( point ); m_PolyPoints.push_back( point );
...@@ -1764,6 +1868,35 @@ void LibDrawBezier::DoMirrorHorizontal( const wxPoint& center ) ...@@ -1764,6 +1868,35 @@ void LibDrawBezier::DoMirrorHorizontal( const wxPoint& center )
} }
void LibDrawBezier::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] )
{
wxASSERT( plotter != NULL );
size_t i;
int* Poly = (int*) MyMalloc( sizeof(int) * 2 * GetCornerCount() );
for( i = 0; i < m_PolyPoints.size(); i++ )
{
wxPoint pos = m_PolyPoints[i];
pos = TransformCoordinate( transform, pos ) + offset;
Poly[i * 2] = pos.x;
Poly[i * 2 + 1] = pos.y;
}
if( fill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->poly( i, Poly, FILLED_WITH_BG_BODYCOLOR, 0 );
}
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->poly( i, Poly, m_Fill, GetPenSize() );
MyFree( Poly );
}
/** 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
*/ */
......
...@@ -266,13 +266,30 @@ public: ...@@ -266,13 +266,30 @@ public:
DoMirrorHorizontal( center ); DoMirrorHorizontal( center );
} }
/**
* Plot the draw item using the plot object.
*
* @param plotter - The plot object to plot to.
*/
void Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] )
{
DoPlot( plotter, offset, fill, transform );
}
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy() = 0; virtual LIB_DRAW_ITEM* DoGenCopy() = 0;
/** /**
* Provide the draw object specific comparison. * Provide the draw object specific comparison.
* *
* This is called by the == operator. * This is called by the == and < operators.
*
* The sort order is as follows:
* - Component alternate part (DeMorgan) number.
* - Component part number.
* - KICAD_T enum value.
* - Result of derived classes comparison.
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const = 0; virtual int DoCompare( const LIB_DRAW_ITEM& other ) const = 0;
virtual void DoOffset( const wxPoint& offset ) = 0; virtual void DoOffset( const wxPoint& offset ) = 0;
...@@ -280,6 +297,8 @@ protected: ...@@ -280,6 +297,8 @@ protected:
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; virtual void DoMirrorHorizontal( const wxPoint& center ) = 0;
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] ) = 0;
}; };
...@@ -404,22 +423,35 @@ public: ...@@ -404,22 +423,35 @@ public:
wxPoint& pin_pos, int orient, wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum, int TextInside, bool DrawPinNum,
bool DrawPinName, int Color, int DrawMode ); bool DrawPinName, int Color, int DrawMode );
void PlotPinTexts( PLOTTER *plotter, void PlotPinTexts( PLOTTER *plotter,
wxPoint& pin_pos, wxPoint& pin_pos,
int orient, int orient,
int TextInside, int TextInside,
bool DrawPinNum, bool DrawPinNum,
bool DrawPinNameint, bool DrawPinNameint,
int aWidth); int aWidth );
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
/**
* Provide the pin draw object specific comparison.
*
* The sort order is as follows:
* - Pin number.
* - Pin name, case insensitive compare.
* - Pin horizontal (X) position.
* - Pin vertical (Y) position.
*/
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
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 ); virtual void DoMirrorHorizontal( const wxPoint& center );
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] );
}; };
...@@ -490,12 +522,24 @@ public: ...@@ -490,12 +522,24 @@ public:
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
/**
* Provide the arc draw object specific comparison.
*
* The sort order is as follows:
* - Arc horizontal (X) position.
* - Arc vertical (Y) position.
* - Arc start angle.
* - Arc end angle.
*/
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
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 ); virtual void DoMirrorHorizontal( const wxPoint& center );
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] );
}; };
...@@ -562,12 +606,24 @@ public: ...@@ -562,12 +606,24 @@ public:
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
/**
* Provide the circle draw object specific comparison.
*
* The sort order is as follows:
* - Circle horizontal (X) position.
* - Circle vertical (Y) position.
* - Circle radius.
*/
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
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 ); virtual void DoMirrorHorizontal( const wxPoint& center );
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] );
}; };
...@@ -643,12 +699,26 @@ public: ...@@ -643,12 +699,26 @@ public:
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
/**
* Provide the text draw object specific comparison.
*
* The sort order is as follows:
* - Text string, case insensitive compare.
* - Text horizontal (X) position.
* - Text vertical (Y) position.
* - Text width.
* - Text height.
*/
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
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 ); virtual void DoMirrorHorizontal( const wxPoint& center );
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] );
}; };
...@@ -714,12 +784,25 @@ public: ...@@ -714,12 +784,25 @@ public:
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
/**
* Provide the rectangle draw object specific comparison.
*
* The sort order is as follows:
* - Rectangle horizontal (X) start position.
* - Rectangle vertical (Y) start position.
* - Rectangle horizontal (X) end position.
* - Rectangle vertical (Y) end position.
*/
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
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 ); virtual void DoMirrorHorizontal( const wxPoint& center );
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] );
}; };
/**********************************/ /**********************************/
...@@ -784,12 +867,25 @@ public: ...@@ -784,12 +867,25 @@ public:
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
/**
* Provide the line segment draw object specific comparison.
*
* The sort order is as follows:
* - Line segment horizontal (X) start position.
* - Line segment vertical (Y) start position.
* - Line segment horizontal (X) end position.
* - Line segment vertical (Y) end position.
*/
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
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 ); virtual void DoMirrorHorizontal( const wxPoint& center );
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] );
}; };
...@@ -865,12 +961,23 @@ public: ...@@ -865,12 +961,23 @@ public:
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
/**
* Provide the ployline segment draw object specific comparison.
*
* The sort order for each polyline segment point is as follows:
* - Line segment point horizontal (X) position.
* - Line segment point vertical (Y) position.
*/
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
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 ); virtual void DoMirrorHorizontal( const wxPoint& center );
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] );
}; };
/**********************************************************/ /**********************************************************/
...@@ -946,12 +1053,23 @@ public: ...@@ -946,12 +1053,23 @@ public:
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual LIB_DRAW_ITEM* DoGenCopy();
/**
* Provide the bezier curve draw object specific comparison.
*
* The sort order for each bezier curve segment point is as follows:
* - Bezier point horizontal (X) point position.
* - Bezier point vertical (Y) point position.
*/
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
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 ); virtual void DoMirrorHorizontal( const wxPoint& center );
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const int transform[2][2] );
}; };
#endif // CLASSES_BODY_ITEMS_H #endif // CLASSES_BODY_ITEMS_H
...@@ -107,7 +107,7 @@ void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component ) ...@@ -107,7 +107,7 @@ void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component )
WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) GetParent(); WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) GetParent();
parent->SetShowDeMorgan( m_AsConvert->GetValue() ); parent->SetShowDeMorgan( m_AsConvert->GetValue() );
component.m_UnitCount = m_PartsCount->GetSelection() + 1; component.SetPartCount( m_PartsCount->GetSelection() + 1 );
component.m_Prefix.m_Text = m_Reference->GetValue(); component.m_Prefix.m_Text = m_Reference->GetValue();
if ( m_PinNameInside->GetValue() == FALSE) if ( m_PinNameInside->GetValue() == FALSE)
component.m_TextInside = 0; component.m_TextInside = 0;
...@@ -122,7 +122,7 @@ void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component ) ...@@ -122,7 +122,7 @@ void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component )
/* Set the option "Units locked". /* Set the option "Units locked".
Obviously, cannot be TRUE if there is only one part */ Obviously, cannot be TRUE if there is only one part */
component.m_UnitSelectionLocked = m_PartsAreLocked->GetValue(); component.m_UnitSelectionLocked = m_PartsAreLocked->GetValue();
if ( component.m_UnitCount <= 1 ) if ( component.GetPartCount() <= 1 )
component.m_UnitSelectionLocked = FALSE; component.m_UnitSelectionLocked = FALSE;
} }
......
...@@ -625,7 +625,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() ...@@ -625,7 +625,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
int choiceCount = unitChoice->GetCount(); int choiceCount = unitChoice->GetCount();
// Remove non existing choices (choiceCount must be <= number for parts) // Remove non existing choices (choiceCount must be <= number for parts)
int unitcount = m_LibEntry ? m_LibEntry->m_UnitCount : 1; int unitcount = m_LibEntry ? m_LibEntry->GetPartCount() : 1;
if( unitcount < 1 ) if( unitcount < 1 )
unitcount = 1; unitcount = 1;
......
...@@ -107,7 +107,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel() ...@@ -107,7 +107,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
m_ShowPinNumButt->SetValue( component->m_DrawPinNum ); m_ShowPinNumButt->SetValue( component->m_DrawPinNum );
m_ShowPinNameButt->SetValue( component->m_DrawPinName ); m_ShowPinNameButt->SetValue( component->m_DrawPinName );
m_PinsNameInsideButt->SetValue( component->m_TextInside != 0 ); m_PinsNameInsideButt->SetValue( component->m_TextInside != 0 );
m_SelNumberOfUnits->SetValue( component->m_UnitCount ); m_SelNumberOfUnits->SetValue( component->GetPartCount() );
m_SetSkew->SetValue( component->m_TextInside ); m_SetSkew->SetValue( component->m_TextInside );
m_OptionPower->SetValue( component->m_Options == ENTRY_POWER ); m_OptionPower->SetValue( component->m_Options == ENTRY_POWER );
m_OptionPartsLocked->SetValue( component->m_UnitSelectionLocked ); m_OptionPartsLocked->SetValue( component->m_UnitSelectionLocked );
...@@ -226,7 +226,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -226,7 +226,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
/* Set the option "Units locked". /* Set the option "Units locked".
* Obviously, cannot be TRUE if there is only one part */ * Obviously, cannot be TRUE if there is only one part */
component->m_UnitSelectionLocked = m_OptionPartsLocked->GetValue(); component->m_UnitSelectionLocked = m_OptionPartsLocked->GetValue();
if( component->m_UnitCount <= 1 ) if( component->GetPartCount() <= 1 )
component->m_UnitSelectionLocked = FALSE; component->m_UnitSelectionLocked = FALSE;
/* Update the footprint filter list */ /* Update the footprint filter list */
...@@ -348,163 +348,57 @@ edited!" ), ...@@ -348,163 +348,57 @@ edited!" ),
} }
/********************************************************************/ /*
bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit ) * Change the number of parts per package.
/********************************************************************/
/* Routine de modification du nombre d'unites par package pour le
* composant courant;
*/ */
bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
{ {
int OldNumUnits, ii, FlagDel = -1;
LIB_DRAW_ITEM* DrawItem, * NextDrawItem;
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
if( component == NULL ) if( component == NULL || component->GetPartCount() == MaxUnit
return FALSE; || MaxUnit < 1 )
return false;
/* Si pas de changement: termine */
if( component->m_UnitCount == MaxUnit )
return FALSE;
OldNumUnits = component->m_UnitCount;
if( OldNumUnits < 1 )
OldNumUnits = 1;
component->m_UnitCount = MaxUnit;
/* Traitement des unites enlevees ou rajoutees */
if( OldNumUnits > component->m_UnitCount )
{
DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = NextDrawItem )
{
NextDrawItem = DrawItem->Next();
if( DrawItem->m_Unit > MaxUnit ) /* Item a effacer */
{
if( FlagDel < 0 )
{
if( IsOK( this, _( "Delete units" ) ) )
{
/* Si part selectee n'existe plus: selection 1ere unit */
if( m_Parent->GetUnit() > MaxUnit )
m_Parent->SetUnit( 1 );
FlagDel = 1;
}
else
{
FlagDel = 0;
MaxUnit = OldNumUnits;
component->m_UnitCount = MaxUnit;
return FALSE;
}
}
component->RemoveDrawItem( DrawItem );
}
}
return TRUE; if( MaxUnit < component->GetPartCount()
} && !IsOK( this, _( "Delete extra parts from component?" ) ) )
return false;
if( OldNumUnits < component->m_UnitCount )
{
DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() )
{
/* Duplication des items pour autres elements */
if( DrawItem->m_Unit == 1 )
{
for( ii = OldNumUnits + 1; ii <= MaxUnit; ii++ )
{
NextDrawItem = DrawItem->GenCopy();
NextDrawItem->m_Unit = ii;
component->AddDrawItem( NextDrawItem );
}
}
}
}
return TRUE; component->SetPartCount( MaxUnit );
return true;
} }
/*****************************************************/ /*
bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert() * Set or clear the component alternate body style ( DeMorgan ).
/*****************************************************/
/* cr�e ou efface (selon option AsConvert) les �l�ments
* de la repr�sentation convertie d'un composant
*/ */
bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
{ {
int FlagDel = 0;
LIB_DRAW_ITEM* DrawItem = NULL, * NextDrawItem;
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_COMPONENT* component = m_Parent->GetComponent();
if( m_Parent->GetShowDeMorgan() ) /* Representation convertie a creer */ if( component == NULL
{ || ( m_Parent->GetShowDeMorgan() == component->HasConversion() ) )
/* Traitement des elements a ajouter ( pins seulement ) */ return false;
if( component )
DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = DrawItem->Next() ) if( m_Parent->GetShowDeMorgan()
&& !IsOK( this, _( "Add new pins for alternate body style \
( DeMorgan ) to component?" ) ) )
{ {
/* Duplication des items pour autres elements */
if( DrawItem->Type() != COMPONENT_PIN_DRAW_TYPE )
continue;
if( DrawItem->m_Convert == 1 )
{
if( FlagDel == 0 )
{
if( IsOK( this, _( "Create pins for convert items." ) ) )
FlagDel = 1;
else
{
if( IsOK( this, _( "Part as \"De Morgan\" anymore" ) ) )
return TRUE;
m_Parent->SetShowDeMorgan( false ); m_Parent->SetShowDeMorgan( false );
return FALSE; return false;
}
} }
NextDrawItem = DrawItem->GenCopy(); if( !m_Parent->GetShowDeMorgan()
NextDrawItem->m_Convert = 2; && !IsOK( this, _( "Delete alternate body style (DeMorgan) draw \
component->AddDrawItem( NextDrawItem ); items from component?" ) ) )
}
}
}
else /* Representation convertie a supprimer */
{
/* Traitement des elements � supprimer */
if( component )
DrawItem = component->GetNextDrawItem();
for( ; DrawItem != NULL; DrawItem = NextDrawItem )
{
NextDrawItem = DrawItem->Next();
if( DrawItem->m_Convert > 1 ) /* Item a effacer */
{
if( FlagDel == 0 )
{
if( IsOK( this, _( "Delete Convert items" ) ) )
{
m_Parent->SetConvert( 1 );
FlagDel = 1;
}
else
{ {
m_Parent->SetShowDeMorgan( true ); m_Parent->SetShowDeMorgan( true );
return FALSE; return false;
}
} }
component->SetConversion( m_Parent->GetShowDeMorgan() );
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
component->RemoveDrawItem( DrawItem );
} return true;
}
}
return TRUE;
} }
......
...@@ -71,7 +71,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC ) ...@@ -71,7 +71,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
if( Entry != NULL ) if( Entry != NULL )
{ {
if( Entry->m_UnitCount > 1 ) if( Entry->GetPartCount() > 1 )
m_Multiflag = 1; m_Multiflag = 1;
} }
} }
...@@ -122,7 +122,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -122,7 +122,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
if( Entry != NULL ) if( Entry != NULL )
{ {
if( Entry->m_UnitCount > 1 ) if( Entry->GetPartCount() > 1 )
flag = 1; flag = 1;
} }
} }
...@@ -266,7 +266,7 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -266,7 +266,7 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
if( Entry != NULL ) if( Entry != NULL )
{ {
if( Entry->m_UnitCount > 1 ) if( Entry->GetPartCount() > 1 )
flag = 1; flag = 1;
} }
} }
...@@ -304,7 +304,7 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -304,7 +304,7 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
if( Entry == NULL ) if( Entry == NULL )
return; return;
if( Entry->m_UnitCount > 1 ) if( Entry->GetPartCount() > 1 )
flag = 1; flag = 1;
wxString ref = Cmp->GetRef(GetSheet()); wxString ref = Cmp->GetRef(GetSheet());
......
...@@ -353,7 +353,7 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent, ...@@ -353,7 +353,7 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent,
if( LibEntry == NULL ) if( LibEntry == NULL )
return; return;
m_UnitCount = LibEntry->m_UnitCount; m_UnitCount = LibEntry->GetPartCount();
if( m_UnitCount <= 1 ) if( m_UnitCount <= 1 )
return; return;
......
...@@ -348,13 +348,13 @@ void WinEDA_LibeditFrame::UpdatePartSelectList() ...@@ -348,13 +348,13 @@ void WinEDA_LibeditFrame::UpdatePartSelectList()
if( m_SelpartBox->GetCount() != 0 ) if( m_SelpartBox->GetCount() != 0 )
m_SelpartBox->Clear(); m_SelpartBox->Clear();
if( m_component == NULL || m_component->m_UnitCount <= 1 ) if( m_component == NULL || m_component->GetPartCount() <= 1 )
{ {
m_SelpartBox->Append( wxEmptyString ); m_SelpartBox->Append( wxEmptyString );
} }
else else
{ {
for( int i = 0; i < m_component->m_UnitCount; i++ ) for( int i = 0; i < m_component->GetPartCount(); i++ )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Part %c" ), 'A' + i ); msg.Printf( _( "Part %c" ), 'A' + i );
...@@ -425,7 +425,7 @@ void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event ) ...@@ -425,7 +425,7 @@ void WinEDA_LibeditFrame::OnUpdateViewDoc( wxUpdateUIEvent& event )
void WinEDA_LibeditFrame::OnUpdatePinByPin( wxUpdateUIEvent& event ) void WinEDA_LibeditFrame::OnUpdatePinByPin( wxUpdateUIEvent& event )
{ {
event.Enable( ( m_component != NULL ) event.Enable( ( m_component != NULL )
&& ( ( m_component->m_UnitCount > 1 ) || m_showDeMorgan ) ); && ( ( m_component->GetPartCount() > 1 ) || m_showDeMorgan ) );
if( m_HToolBar ) if( m_HToolBar )
m_HToolBar->ToggleTool( event.GetId(), g_EditPinByPinIsOn ); m_HToolBar->ToggleTool( event.GetId(), g_EditPinByPinIsOn );
...@@ -441,7 +441,7 @@ void WinEDA_LibeditFrame::OnUpdatePartNumber( wxUpdateUIEvent& event ) ...@@ -441,7 +441,7 @@ void WinEDA_LibeditFrame::OnUpdatePartNumber( wxUpdateUIEvent& event )
* so use the pointer to alias combobox to directly enable or disable. * so use the pointer to alias combobox to directly enable or disable.
*/ */
m_SelpartBox->Enable( m_component != NULL m_SelpartBox->Enable( m_component != NULL
&& m_component->m_UnitCount > 1 ); && m_component->GetPartCount() > 1 );
} }
......
...@@ -138,7 +138,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( EDA_BaseStruct* DrawList ...@@ -138,7 +138,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( EDA_BaseStruct* DrawList
continue; continue;
// Multi parts per package: test if already visited: // Multi parts per package: test if already visited:
if( Entry->m_UnitCount > 1 ) if( Entry->GetPartCount() > 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++ )
...@@ -158,7 +158,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( EDA_BaseStruct* DrawList ...@@ -158,7 +158,7 @@ static SCH_COMPONENT* FindNextComponentAndCreatPinList( EDA_BaseStruct* DrawList
} }
} }
if( Entry->m_UnitCount <= 1 ) // One part per package if( Entry->GetPartCount() <= 1 ) // One part per package
{ {
for( Pin = Entry->GetNextPin(); Pin != NULL; for( Pin = Entry->GetNextPin(); Pin != NULL;
Pin = Entry->GetNextPin( Pin ) ) Pin = Entry->GetNextPin( Pin ) )
......
...@@ -332,10 +332,10 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) ...@@ -332,10 +332,10 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CONVERT_CMP, ADD_MENUITEM( editmenu, ID_POPUP_SCH_EDIT_CONVERT_CMP,
_( "Convert" ), component_select_alternate_shape_xpm ); _( "Convert" ), component_select_alternate_shape_xpm );
if( libComponent && ( libComponent->m_UnitCount >= 2 ) ) if( libComponent && ( libComponent->GetPartCount() >= 2 ) )
{ {
wxMenu* sel_unit_menu = new wxMenu; int ii; wxMenu* sel_unit_menu = new wxMenu; int ii;
for( ii = 0; ii < libComponent->m_UnitCount; ii++ ) for( ii = 0; ii < libComponent->GetPartCount(); ii++ )
{ {
wxString num_unit; wxString num_unit;
num_unit.Printf( _( "Unit %d %c" ), ii + 1, num_unit.Printf( _( "Unit %d %c" ), ii + 1,
......
...@@ -783,7 +783,7 @@ static void CreateImagePins( LibDrawPin* Pin, int unit, int convert, ...@@ -783,7 +783,7 @@ static void CreateImagePins( LibDrawPin* Pin, int unit, int convert,
Pin->GetParent()->AddDrawItem( NewPin ); Pin->GetParent()->AddDrawItem( NewPin );
} }
for( ii = 1; ii <= Pin->GetParent()->m_UnitCount; ii++ ) for( ii = 1; ii <= Pin->GetParent()->GetPartCount(); ii++ )
{ {
if( ii == unit || Pin->m_Unit == 0 ) if( ii == unit || Pin->m_Unit == 0 )
continue; /* Pin commune a toutes les unites */ continue; /* Pin commune a toutes les unites */
...@@ -974,7 +974,7 @@ with pin %s at location (%d, %d)" ), ...@@ -974,7 +974,7 @@ with pin %s at location (%d, %d)" ),
(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->GetPartCount() > 1 )
{ {
aux_msg.Printf( _( " in part %c" ), 'A' + curr_pin->m_Unit ); aux_msg.Printf( _( " in part %c" ), 'A' + curr_pin->m_Unit );
msg += aux_msg; msg += aux_msg;
......
...@@ -21,8 +21,6 @@ static void Plot_Hierarchical_PIN_Sheet( PLOTTER* plotter, ...@@ -21,8 +21,6 @@ static void Plot_Hierarchical_PIN_Sheet( PLOTTER* plotter,
Hierarchical_PIN_Sheet_Struct* Struct ); Hierarchical_PIN_Sheet_Struct* Struct );
static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem,
int FieldNumber, int IsMulti, int DrawMode ); int FieldNumber, int IsMulti, int DrawMode );
static void PlotPinSymbol( PLOTTER* plotter, const wxPoint& pos,
int len, int orient, int Shape );
/***/ /***/
...@@ -51,200 +49,22 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem ) ...@@ -51,200 +49,22 @@ static void PlotLibPart( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem )
/*************************************************/ /*************************************************/
/* Polt a component */ /* Polt a component */
{ {
int ii, t1, t2, * Poly, orient;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
int TransMat[2][2], Multi, convert; int TransMat[2][2];
EDA_Colors CharColor = UNSPECIFIED_COLOR;
wxPoint pos;
bool draw_bgfill = false;
Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName ); Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
return;; return;;
memcpy( TransMat, DrawLibItem->m_Transform, sizeof(TransMat) );
Multi = DrawLibItem->m_Multi;
convert = DrawLibItem->m_Convert;
for( LIB_DRAW_ITEM* DEntry = Entry->GetNextDrawItem();
DEntry != NULL; DEntry = DEntry->Next() )
{
/* 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) )
continue;
int thickness = DEntry->GetPenSize();
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
draw_bgfill = plotter->get_color_mode();
switch( DEntry->Type() )
{
case COMPONENT_ARC_DRAW_TYPE:
{
LibDrawArc* Arc = (LibDrawArc*) DEntry;
t1 = Arc->m_t1;
t2 = Arc->m_t2;
pos = TransformCoordinate( TransMat, Arc->m_Pos ) + DrawLibItem->m_Pos;
MapAngles( &t1, &t2, TransMat );
if( draw_bgfill && Arc->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->arc( pos, -t2, -t1, Arc->m_Radius, FILLED_SHAPE, 0 );
}
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->arc( pos, -t2, -t1, Arc->m_Radius, Arc->m_Fill,
thickness );
}
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
{
LibDrawCircle* Circle = (LibDrawCircle*) DEntry;
pos = TransformCoordinate( TransMat, Circle->m_Pos ) + DrawLibItem->m_Pos;
if( draw_bgfill && Circle->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->circle( pos, Circle->m_Radius * 2, FILLED_SHAPE, 0 );
}
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->circle( pos,
Circle->m_Radius * 2,
Circle->m_Fill,
thickness );
}
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
{
LibDrawText* Text = (LibDrawText*) DEntry;
/* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. */
t1 = (TransMat[0][0] != 0) ^ (Text->m_Orient != 0);
pos = TransformCoordinate( TransMat, Text->m_Pos ) + DrawLibItem->m_Pos;
plotter->text( pos, CharColor,
Text->m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
Text->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, Text->m_Italic, Text->m_Bold );
}
break;
case COMPONENT_RECT_DRAW_TYPE:
{
LibDrawSquare* Square = (LibDrawSquare*) DEntry;
pos = TransformCoordinate( TransMat, Square->m_Pos ) + DrawLibItem->m_Pos;
wxPoint end =
TransformCoordinate( TransMat, Square->m_End ) + DrawLibItem->m_Pos;
if( draw_bgfill && Square->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->rect( pos, end, FILLED_WITH_BG_BODYCOLOR, 0 );
}
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->rect( pos, end, Square->m_Fill, thickness );
}
break;
case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */
{
LibDrawPin* Pin = (LibDrawPin*) DEntry;
if( Pin->m_Attributs & PINNOTDRAW )
break;
/* Calcul de l'orientation reelle de la Pin */ memcpy( TransMat, DrawLibItem->m_Transform, sizeof(TransMat) );
orient = Pin->ReturnPinDrawOrient( TransMat );
/* compute Pin Pos */
pos = TransformCoordinate( TransMat, Pin->m_Pos ) + DrawLibItem->m_Pos;
/* Dessin de la pin et du symbole special associe */
thickness = Pin->GetPenSize();
plotter->set_current_line_width( thickness );
PlotPinSymbol( plotter, pos, Pin->m_PinLen, orient, Pin->m_PinShape );
Pin->PlotPinTexts( plotter, pos, orient,
Entry->m_TextInside,
Entry->m_DrawPinNum, Entry->m_DrawPinName,
thickness );
}
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
{
LibDrawPolyline* polyline = (LibDrawPolyline*) DEntry;
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->GetCornerCount() );
for( ii = 0; ii < (int) polyline->GetCornerCount(); ii++ )
{
pos = polyline->m_PolyPoints[ii];
pos = TransformCoordinate( TransMat, pos ) + DrawLibItem->m_Pos;
Poly[ii * 2] = pos.x;
Poly[ii * 2 + 1] = pos.y;
}
if( draw_bgfill && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->poly( ii, Poly, FILLED_WITH_BG_BODYCOLOR, 0 );
}
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->poly( ii, Poly, polyline->m_Fill, thickness );
MyFree( Poly );
}
break;
case COMPONENT_BEZIER_DRAW_TYPE:
{
LibDrawBezier* polyline = (LibDrawBezier*) DEntry;
Poly = (int*) MyMalloc( sizeof(int) * 2 * polyline->GetCornerCount() );
for( ii = 0; ii < (int) polyline->GetCornerCount(); ii++ )
{
pos = polyline->m_PolyPoints[ii];
pos = TransformCoordinate( TransMat, pos ) + DrawLibItem->m_Pos;
Poly[ii * 2] = pos.x;
Poly[ii * 2 + 1] = pos.y;
}
if( draw_bgfill && polyline->m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
plotter->set_color( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
plotter->poly( ii, Poly, FILLED_WITH_BG_BODYCOLOR, 0 );
}
plotter->set_color( ReturnLayerColor( LAYER_DEVICE ) );
plotter->poly( ii, Poly, polyline->m_Fill, thickness );
MyFree( Poly );
}
default:
D( printf( "Drawing Type=%d\n", DEntry->Type() ) );
}
/* Fin Switch */
}
/* Fin Boucle de dessin */
/* Trace des champs, avec placement et orientation selon orient. du
* composant
* Si la reference commence par # elle n'est pas tracee
*/
if( (Entry->m_Prefix.m_Attributs & TEXT_NO_VISIBLE) == 0 )
{
if( Entry->m_UnitCount > 1 )
PlotTextField( plotter, DrawLibItem, REFERENCE, 1, 0 );
else
PlotTextField( plotter, DrawLibItem, REFERENCE, 0, 0 );
}
if( (Entry->m_Name.m_Attributs & TEXT_NO_VISIBLE) == 0 ) Entry->Plot( plotter, DrawLibItem->m_Multi, DrawLibItem->m_Convert,
PlotTextField( plotter, DrawLibItem, VALUE, 0, 0 ); DrawLibItem->m_Pos, TransMat );
for( ii = 2; ii < NUMBER_OF_FIELDS; ii++ ) for( int i = 0; i < NUMBER_OF_FIELDS; i++ )
{ {
PlotTextField( plotter, DrawLibItem, ii, 0, 0 ); PlotTextField( plotter, DrawLibItem, i, 0, 0 );
} }
} }
...@@ -396,7 +216,7 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, ...@@ -396,7 +216,7 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem,
/**************************************************************************/ /**************************************************************************/
static void PlotPinSymbol( PLOTTER* plotter, const wxPoint& pos, void PlotPinSymbol( PLOTTER* plotter, const wxPoint& pos,
int len, int orient, int Shape ) int len, int orient, int Shape )
/**************************************************************************/ /**************************************************************************/
......
...@@ -111,7 +111,7 @@ void WinEDA_bodygraphics_PropertiesFrame::bodygraphics_PropertiesAccept( wxComma ...@@ -111,7 +111,7 @@ void WinEDA_bodygraphics_PropertiesFrame::bodygraphics_PropertiesAccept( wxComma
break; break;
} }
item->GetParent()->SortDrawItems(); item->GetParent()->GetDrawItemList().sort();
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_library.h" #include "class_library.h"
#include <boost/foreach.hpp>
/* /*
* Read a component shape file (a symbol file *.sym )and add data (graphic * Read a component shape file (a symbol file *.sym )and add data (graphic
...@@ -32,7 +34,6 @@ ...@@ -32,7 +34,6 @@
void WinEDA_LibeditFrame::LoadOneSymbol( void ) void WinEDA_LibeditFrame::LoadOneSymbol( void )
{ {
LIB_COMPONENT* Component; LIB_COMPONENT* Component;
LIB_DRAW_ITEM* DrawEntry;
FILE* ImportFile; FILE* ImportFile;
wxString msg, err; wxString msg, err;
CMP_LIBRARY* Lib; CMP_LIBRARY* Lib;
...@@ -93,24 +94,23 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) ...@@ -93,24 +94,23 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
} }
if( Lib->GetCount() > 1 ) if( Lib->GetCount() > 1 )
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->GetNextDrawItem(); LIB_DRAW_ITEM_LIST& drawList = Component->GetDrawItemList();
while( DrawEntry != NULL ) BOOST_FOREACH( LIB_DRAW_ITEM& item, drawList )
{ {
if( DrawEntry->m_Unit ) if( item.m_Unit )
DrawEntry->m_Unit = m_unit; item.m_Unit = m_unit;
if( DrawEntry->m_Convert ) if( item.m_Convert )
DrawEntry->m_Convert = m_convert; item.m_Convert = m_convert;
DrawEntry->m_Flags = IS_NEW; item.m_Flags = IS_NEW;
DrawEntry->m_Selected = IS_SELECTED; item.m_Selected = IS_SELECTED;
LIB_DRAW_ITEM* newItem = DrawEntry->GenCopy(); LIB_DRAW_ITEM* newItem = item.GenCopy();
newItem->SetParent( m_component ); newItem->SetParent( m_component );
m_component->AddDrawItem( newItem ); m_component->AddDrawItem( newItem );
DrawEntry = DrawEntry->Next();
} }
// Remove duplicated drawings: // Remove duplicated drawings:
...@@ -136,11 +136,10 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) ...@@ -136,11 +136,10 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
*/ */
void WinEDA_LibeditFrame::SaveOneSymbol() void WinEDA_LibeditFrame::SaveOneSymbol()
{ {
LIB_DRAW_ITEM* DrawEntry;
wxString msg; wxString msg;
FILE* ExportFile; FILE* ExportFile;
if( m_component->GetNextDrawItem() == NULL ) if( m_component->GetDrawItemList().empty() )
return; return;
/* Creation du fichier symbole */ /* Creation du fichier symbole */
...@@ -204,28 +203,23 @@ void WinEDA_LibeditFrame::SaveOneSymbol() ...@@ -204,28 +203,23 @@ 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->GetNextDrawItem();
if( DrawEntry ) LIB_DRAW_ITEM_LIST& drawList = m_component->GetDrawItemList();
{
fprintf( ExportFile, "DRAW\n" ); fprintf( ExportFile, "DRAW\n" );
for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() ) BOOST_FOREACH( LIB_DRAW_ITEM& item, drawList )
{ {
/* Elimination des elements non relatifs a l'unite */ /* Elimination des elements non relatifs a l'unite */
if( m_unit && DrawEntry->m_Unit if( m_unit && item.m_Unit && ( item.m_Unit != m_unit ) )
&& ( DrawEntry->m_Unit != m_unit ) )
continue; continue;
if( m_convert && DrawEntry->m_Convert if( m_convert && item.m_Convert && ( item.m_Convert != m_convert ) )
&& ( DrawEntry->m_Convert != m_convert ) )
continue; continue;
DrawEntry->Save( ExportFile ); item.Save( ExportFile );
} }
fprintf( ExportFile, "ENDDRAW\n" ); fprintf( ExportFile, "ENDDRAW\n" );
}
fprintf( ExportFile, "ENDDEF\n" ); fprintf( ExportFile, "ENDDEF\n" );
fclose( ExportFile ); fclose( ExportFile );
} }
......
...@@ -128,7 +128,7 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar() ...@@ -128,7 +128,7 @@ void WinEDA_ViewlibFrame::ReCreateHToolbar()
int jj = 1; int jj = 1;
if( component ) if( component )
jj = MAX( component->m_UnitCount, 1 ); jj = MAX( component->GetPartCount(), 1 );
SelpartBox->Clear(); SelpartBox->Clear();
for( ii = 0; ii < jj; ii++ ) for( ii = 0; ii < jj; ii++ )
{ {
......
...@@ -63,7 +63,14 @@ enum KICAD_T { ...@@ -63,7 +63,14 @@ enum KICAD_T {
SCREEN_STRUCT_TYPE, SCREEN_STRUCT_TYPE,
BLOCK_LOCATE_STRUCT_TYPE, BLOCK_LOCATE_STRUCT_TYPE,
// Draw Items in library component /*
* Draw items in library component.
*
* The order of these items effects the sort order for items inside the
* "DRAW/ENDDRAW" section of the component definition in a library file.
* If you add a new draw item, type, please make sure you add it so the
* sort order is logical.
*/
LIBCOMPONENT_STRUCT_TYPE, LIBCOMPONENT_STRUCT_TYPE,
COMPONENT_ARC_DRAW_TYPE, COMPONENT_ARC_DRAW_TYPE,
COMPONENT_CIRCLE_DRAW_TYPE, COMPONENT_CIRCLE_DRAW_TYPE,
...@@ -71,9 +78,14 @@ enum KICAD_T { ...@@ -71,9 +78,14 @@ enum KICAD_T {
COMPONENT_RECT_DRAW_TYPE, COMPONENT_RECT_DRAW_TYPE,
COMPONENT_POLYLINE_DRAW_TYPE, COMPONENT_POLYLINE_DRAW_TYPE,
COMPONENT_LINE_DRAW_TYPE, COMPONENT_LINE_DRAW_TYPE,
COMPONENT_BEZIER_DRAW_TYPE,
COMPONENT_PIN_DRAW_TYPE, COMPONENT_PIN_DRAW_TYPE,
/*
* Fields are not saved inside the "DRAW/ENDDRAW". Add new draw item
* types before this line.
*/
COMPONENT_FIELD_DRAW_TYPE, COMPONENT_FIELD_DRAW_TYPE,
COMPONENT_BEZIER_DRAW_TYPE,
// End value // End value
MAX_STRUCT_TYPE_ID MAX_STRUCT_TYPE_ID
......
...@@ -207,7 +207,7 @@ public: ...@@ -207,7 +207,7 @@ public:
virtual void set_current_line_width( int width ) virtual void set_current_line_width( int width )
{ {
/* Handy override */ /* Handy override */
current_pen_width = pen_diameter; current_pen_width = wxRound( pen_diameter );
}; };
virtual void set_default_line_width( int width ) {}; virtual void set_default_line_width( int width ) {};
virtual void set_dash( bool dashed ); virtual void set_dash( bool dashed );
......
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