Commit 76d04d6a authored by stambaughw's avatar stambaughw
Browse files

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
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -505,7 +505,7 @@ static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsLi
        }

        /* 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 )
            {
@@ -520,7 +520,7 @@ static void ComputeReferenceNumber( std::vector <OBJ_CMP_TO_LIST>& aComponentsLi

        /* Annotation of multi-part components ( n parts per package )
         * (complex case) */
        NumberOfUnits = aComponentsList[ii].m_Entry->m_UnitCount;
        NumberOfUnits = aComponentsList[ii].m_Entry->GetPartCount();

        if( aComponentsList[ii].m_IsNew )
        {
@@ -709,7 +709,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
        }

        // 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 )
                Buff << ComponentsList[ii].m_NumRef;
@@ -721,7 +721,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne
                       Buff.GetData() );

            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;
            if( aMessageList )
            {
@@ -777,7 +777,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOne

        /* 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) */
        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 )
                Buff << ComponentsList[ii].m_NumRef;
+2 −2
Original line number Diff line number Diff line
@@ -650,7 +650,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
        Unit  = ' ';
        Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
        if( Entry )
            Multi = Entry->m_UnitCount;
            Multi = Entry->GetPartCount();

        if( ( Multi > 1 ) && aIncludeSubComponents )
#if defined (KICAD_GOST)
@@ -749,7 +749,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal(
        Unit  = ' ';
        Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
        if( Entry )
            Multi = Entry->m_UnitCount;
            Multi = Entry->GetPartCount();

        if( ( Multi > 1 ) && aIncludeSubComponents )
        {
+18 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include "gr_basic.h"
#include "common.h"
#include "class_drawpanel.h"
#include "plot_common.h"
#include "drawtxt.h"
#include "trigo.h"

@@ -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
 * @return the size of the "pen" that be used to draw or plot this item
 */
+193 −382

File changed.

Preview size limit exceeded, changes collapsed.

+52 −7
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ public:
public:
    CMP_LIB_ENTRY( LibrEntryType CmpType, const wxString& name,
                   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();

@@ -112,7 +112,6 @@ public:
    wxArrayString      m_FootprintList;  /* list of suitable footprint names
                                          * for the component (wildcard names
                                          * accepted) */
    int                m_UnitCount;      /* Units (or sections) per package */
    bool               m_UnitSelectionLocked;  /* True if units are different
                                                * and their selection is
                                                * locked (i.e. if part A cannot
@@ -125,9 +124,12 @@ public:
    bool               m_DrawPinNum;
    bool               m_DrawPinName;
    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

protected:
    int                m_UnitCount;      /* Units (or sections) per package */
    LIB_DRAW_ITEM_LIST m_Drawings;       /* How to draw this part */

public:
    virtual wxString GetClass() const
    {
@@ -136,14 +138,12 @@ public:


    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();

    EDA_Rect GetBoundaryBox( int Unit, int Convert );

    void SortDrawItems();

    bool SaveDateAndTime( FILE* ExportFile );
    bool LoadDateAndTime( char* Line );

@@ -204,6 +204,17 @@ public:
               bool showPinText = true, bool drawFields = true,
               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.
     *
@@ -344,6 +355,40 @@ public:
     */
    LIB_DRAW_ITEM* LocateDrawItem( int unit, int convert, KICAD_T type,
                                   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:
public:
    LIB_ALIAS( const wxString& name, LIB_COMPONENT* root,
               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();

    virtual wxString GetClass() const
Loading