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
*/ */
......
This diff is collapsed.
...@@ -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
*/ */
......
This diff is collapsed.
...@@ -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( MaxUnit < component->GetPartCount()
if( OldNumUnits < 1 ) && !IsOK( this, _( "Delete extra parts from component?" ) ) )
OldNumUnits = 1; return false;
component->m_UnitCount = MaxUnit; component->SetPartCount( MaxUnit );
return true;
/* 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( 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;
} }
/*****************************************************/ /*
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 \
/* Duplication des items pour autres elements */ ( DeMorgan ) to component?" ) ) )
if( DrawItem->Type() != COMPONENT_PIN_DRAW_TYPE ) {
continue; m_Parent->SetShowDeMorgan( false );
if( DrawItem->m_Convert == 1 ) return false;
{
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 );
return FALSE;
}
}
NextDrawItem = DrawItem->GenCopy();
NextDrawItem->m_Convert = 2;
component->AddDrawItem( NextDrawItem );
}
}
} }
else /* Representation convertie a supprimer */
if( !m_Parent->GetShowDeMorgan()
&& !IsOK( this, _( "Delete alternate body style (DeMorgan) draw \
items from component?" ) ) )
{ {
/* Traitement des elements � supprimer */ m_Parent->SetShowDeMorgan( true );
if( component ) return false;
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 );
return FALSE;
}
}
m_Parent->GetScreen()->SetModify();
component->RemoveDrawItem( DrawItem );
}
}
} }
return TRUE;
component->SetConversion( m_Parent->GetShowDeMorgan() );
m_Parent->GetScreen()->SetModify();
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 */
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 */ memcpy( TransMat, DrawLibItem->m_Transform, sizeof(TransMat) );
}
/* 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,8 +216,8 @@ static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem, ...@@ -396,8 +216,8 @@ 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 )
/**************************************************************************/ /**************************************************************************/
/* Trace la pin du symbole en cours de trace /* Trace la pin du symbole en cours de trace
......
...@@ -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" );
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawList )
{ {
fprintf( ExportFile, "DRAW\n" ); /* Elimination des elements non relatifs a l'unite */
if( m_unit && item.m_Unit && ( item.m_Unit != m_unit ) )
for( ; DrawEntry != NULL; DrawEntry = DrawEntry->Next() ) continue;
{ if( m_convert && item.m_Convert && ( item.m_Convert != m_convert ) )
/* Elimination des elements non relatifs a l'unite */ continue;
if( m_unit && DrawEntry->m_Unit
&& ( DrawEntry->m_Unit != m_unit ) ) item.Save( ExportFile );
continue;
if( m_convert && DrawEntry->m_Convert
&& ( DrawEntry->m_Convert != m_convert ) )
continue;
DrawEntry->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