Commit ee918d7d authored by stambaughw's avatar stambaughw
Browse files

Replace library editor new component dialog and minor updates.

* Replace component library editor new component dialog using wxFormBuilder.
* Rename component library draw items to conform to current coding standards.
* Add GetWidth() method to component library draw objects.
* Add regular expression key word search capability to component library object.
parent 498f0c91
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ set(EESCHEMA_SRCS
    dialog_build_BOM.cpp
    dialog_build_BOM_base.cpp
#   dialog_cmp_graphic_properties.cpp
    dialog_create_component.cpp
    dialog_edit_component_in_lib.cpp
    dialog_edit_component_in_lib_base.cpp
    dialog_edit_component_in_schematic_fbp.cpp
@@ -57,6 +56,8 @@ set(EESCHEMA_SRCS
    dialog_erc.cpp
    dialog_erc_base.cpp
#   dialog_find.cpp
    dialog_lib_new_component.cpp
    dialog_lib_new_component_base.cpp
    dialog_options.cpp
    dialog_print_using_printer_base.cpp
    dialog_print_using_printer.cpp
+2 −2
Original line number Diff line number Diff line
@@ -861,10 +861,10 @@ static LIB_DRAW_ITEM* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
 */
{
    static LIB_COMPONENT* Entry;
    static LibDrawPin* NextPin;
    static LIB_PIN* NextPin;
    static int Multi, convert, TransMat[2][2];
    int orient;
    LibDrawPin* Pin;
    LIB_PIN* Pin;
    static wxPoint CmpPosition;

    if( aDrawLibItem )
+3 −3
Original line number Diff line number Diff line
@@ -795,7 +795,7 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
 */
{
    EDA_BaseStruct* item;
    LibDrawPin*             pin;
    LIB_PIN*        pin;
    SCH_COMPONENT*  LibItem = NULL;
    Hierarchical_PIN_Sheet_Struct*   pinsheet;
    wxPoint itempos;
+23 −23
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
/***************************/

/**
* class LibDrawText : describes a graphic text used to draw component shapes
* class LIB_TEXT : describes a graphic text used to draw component shapes
* This is only a graphic item
*/

@@ -21,7 +21,7 @@
#include "protos.h"


LibDrawText::LibDrawText(LIB_COMPONENT * aParent) :
LIB_TEXT::LIB_TEXT(LIB_COMPONENT * aParent) :
    LIB_DRAW_ITEM( COMPONENT_GRAPHIC_TEXT_DRAW_TYPE, aParent ),
    EDA_TextStruct()
{
@@ -30,7 +30,7 @@ LibDrawText::LibDrawText(LIB_COMPONENT * aParent) :
}


bool LibDrawText::Save( FILE* ExportFile ) const
bool LIB_TEXT::Save( FILE* ExportFile ) const
{
    wxString text = m_Text;

@@ -65,7 +65,7 @@ bool LibDrawText::Save( FILE* ExportFile ) const
}


bool LibDrawText::Load( char* line, wxString& errorMsg )
bool LIB_TEXT::Load( char* line, wxString& errorMsg )
{
    int  cnt, thickness;
    char hjustify = 'C', vjustify = 'C';
@@ -139,7 +139,7 @@ bool LibDrawText::Load( char* line, wxString& errorMsg )
 * @param refPos A wxPoint to test
 * @return bool - true if a hit, else false
 */
bool LibDrawText::HitTest( const wxPoint& refPos )
bool LIB_TEXT::HitTest( const wxPoint& refPos )
{
    return HitTest( refPos, 0, DefaultTransformMatrix );
}
@@ -151,7 +151,7 @@ bool LibDrawText::HitTest( const wxPoint& refPos )
 * @param aThreshold = unused here (TextHitTest calculates its threshold )
 * @param aTransMat = the transform matrix
 */
bool LibDrawText::HitTest( wxPoint aPosRef, int aThreshold,
bool LIB_TEXT::HitTest( wxPoint aPosRef, int aThreshold,
                        const int aTransMat[2][2] )
{
    wxPoint physicalpos = TransformCoordinate( aTransMat, m_Pos );
@@ -171,9 +171,9 @@ bool LibDrawText::HitTest( wxPoint aPosRef, int aThreshold,
}


LIB_DRAW_ITEM* LibDrawText::DoGenCopy()
LIB_DRAW_ITEM* LIB_TEXT::DoGenCopy()
{
    LibDrawText* newitem = new LibDrawText(NULL);
    LIB_TEXT* newitem = new LIB_TEXT(NULL);

    newitem->m_Pos       = m_Pos;
    newitem->m_Orient    = m_Orient;
@@ -192,11 +192,11 @@ LIB_DRAW_ITEM* LibDrawText::DoGenCopy()
}


int LibDrawText::DoCompare( const LIB_DRAW_ITEM& other ) const
int LIB_TEXT::DoCompare( const LIB_DRAW_ITEM& other ) const
{
    wxASSERT( other.Type() == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE );

    const LibDrawText* tmp = ( LibDrawText* ) &other;
    const LIB_TEXT* tmp = ( LIB_TEXT* ) &other;

    int result = m_Text.CmpNoCase( tmp->m_Text );

@@ -219,13 +219,13 @@ int LibDrawText::DoCompare( const LIB_DRAW_ITEM& other ) const
}


void LibDrawText::DoOffset( const wxPoint& offset )
void LIB_TEXT::DoOffset( const wxPoint& offset )
{
    m_Pos += offset;
}


bool LibDrawText::DoTestInside( EDA_Rect& rect )
bool LIB_TEXT::DoTestInside( EDA_Rect& rect )
{
    /*
     * FIXME: This should calculate the text size and justification and
@@ -235,13 +235,13 @@ bool LibDrawText::DoTestInside( EDA_Rect& rect )
}


void LibDrawText::DoMove( const wxPoint& newPosition )
void LIB_TEXT::DoMove( const wxPoint& newPosition )
{
    m_Pos = newPosition;
}


void LibDrawText::DoMirrorHorizontal( const wxPoint& center )
void LIB_TEXT::DoMirrorHorizontal( const wxPoint& center )
{
    m_Pos.x -= center.x;
    m_Pos.x *= -1;
@@ -249,7 +249,7 @@ void LibDrawText::DoMirrorHorizontal( const wxPoint& center )
}


void LibDrawText::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
void LIB_TEXT::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
                       const int transform[2][2] )
{
    wxASSERT( plotter != NULL );
@@ -269,7 +269,7 @@ void LibDrawText::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
/** Function GetPenSize
 * @return the size of the "pen" that be used to draw or plot this item
 */
int LibDrawText::GetPenSize( )
int LIB_TEXT::GetPenSize( )
{
    int     pensize = m_Width;

@@ -285,7 +285,7 @@ int LibDrawText::GetPenSize( )
    return pensize;
}

void LibDrawText::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
void LIB_TEXT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
                     const wxPoint& aOffset, int aColor, int aDrawMode,
                     void* aData, const int aTransformMatrix[2][2] )
{
@@ -318,7 +318,7 @@ void LibDrawText::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
}


void LibDrawText::DisplayInfo( WinEDA_DrawFrame* frame )
void LIB_TEXT::DisplayInfo( WinEDA_DrawFrame* frame )
{
    wxString msg;

@@ -331,7 +331,7 @@ void LibDrawText::DisplayInfo( WinEDA_DrawFrame* frame )
}


EDA_Rect LibDrawText::GetBoundingBox()
EDA_Rect LIB_TEXT::GetBoundingBox()
{
    EDA_Rect rect = GetTextBox();
    rect.m_Pos.y *= -1;
+29 −43
Original line number Diff line number Diff line
@@ -193,8 +193,8 @@ LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& component, CMP_LIBRARY* lib ) :
    CMP_LIB_ENTRY( component, lib )
{
    LIB_DRAW_ITEM* newItem;
    LibDrawField*  oldField;
    LibDrawField*  newField;
    LIB_FIELD*     oldField;
    LIB_FIELD*     newField;

    m_Prefix              = component.m_Prefix;
    m_AliasList           = component.m_AliasList;
@@ -221,7 +221,7 @@ LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& component, CMP_LIBRARY* lib ) :
    for( oldField = component.m_Fields; oldField != NULL;
         oldField = oldField->Next() )
    {
        newField = (LibDrawField*) oldField->GenCopy();
        newField = (LIB_FIELD*) oldField->GenCopy();
        newField->SetParent( this );
        m_Fields.PushBack( newField );
    }
@@ -240,8 +240,6 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,
                          bool showPinText, bool drawFields,
                          bool onlySelected )
{
    wxString       fieldText;
    LibDrawField*  Field;
    BASE_SCREEN*   screen = panel->GetScreen();

    GRSetDrawMode( dc, drawMode );
@@ -282,25 +280,13 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* dc,

    if( drawFields )
    {
        /* The reference designator field is a special case for naming
        LIB_FIELD* Field;

        /*
         * The reference designator field is a special case for naming
         * convention.
         *
         * FIXME: This should be handled by the LibDrawField class.
         */
        if( m_UnitCount > 1 )
        {
#if defined(KICAD_GOST)
            fieldText.Printf( wxT( "%s?.%c" ), (const wxChar*) m_Prefix.m_Text,
                              multi + '1' - 1 );
#else
            fieldText.Printf( wxT( "%s?%c" ), (const wxChar*) m_Prefix.m_Text,
                              multi + 'A' - 1 );
#endif
        }
        else
        {
            fieldText = m_Prefix.m_Text + wxT( "?" );
        }
        wxString      fieldText = m_Prefix.GetFullText( multi );

        if( !( onlySelected && m_Prefix.m_Selected == 0 ) )
            m_Prefix.Draw( panel, dc, offset, color, drawMode, &fieldText,
@@ -384,7 +370,7 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* item,
    }
    else
    {
        LibDrawField* field;
        LIB_FIELD* field;

        for( field = m_Fields; field != NULL; field = field->Next() )
        {
@@ -438,7 +424,7 @@ LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* item,
 */
bool LIB_COMPONENT::Save( FILE* aFile )
{
    LibDrawField*  Field;
    LIB_FIELD*  Field;

    /* 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 )
@@ -689,31 +675,31 @@ bool LIB_COMPONENT::LoadDrawEntries( FILE* f, char* line,
        switch( line[0] )
        {
        case 'A':    /* Arc */
            newEntry = ( LIB_DRAW_ITEM* ) new LibDrawArc(this);
            newEntry = ( LIB_DRAW_ITEM* ) new LIB_ARC(this);
            break;

        case 'C':    /* Circle */
            newEntry = ( LIB_DRAW_ITEM* ) new LibDrawCircle(this);
            newEntry = ( LIB_DRAW_ITEM* ) new LIB_CIRCLE(this);
            break;

        case 'T':    /* Text */
            newEntry = ( LIB_DRAW_ITEM* ) new LibDrawText(this);
            newEntry = ( LIB_DRAW_ITEM* ) new LIB_TEXT(this);
            break;

        case 'S':    /* Square */
            newEntry = ( LIB_DRAW_ITEM* ) new LibDrawSquare(this);
            newEntry = ( LIB_DRAW_ITEM* ) new LIB_RECTANGLE(this);
            break;

        case 'X':    /* Pin Description */
            newEntry = ( LIB_DRAW_ITEM* ) new LibDrawPin(this);
            newEntry = ( LIB_DRAW_ITEM* ) new LIB_PIN(this);
            break;

        case 'P':    /* Polyline */
            newEntry = ( LIB_DRAW_ITEM* ) new LibDrawPolyline(this);
            newEntry = ( LIB_DRAW_ITEM* ) new LIB_POLYLINE(this);
            break;

        case 'B':    /* Bezier Curves */
            newEntry = ( LIB_DRAW_ITEM* ) new LibDrawBezier(this);
            newEntry = ( LIB_DRAW_ITEM* ) new LIB_BEZIER(this);
            break;

        default:
@@ -766,7 +752,7 @@ bool LIB_COMPONENT::LoadAliases( char* line, wxString& errorMsg )

bool LIB_COMPONENT::LoadField( char* line, wxString& errorMsg )
{
    LibDrawField* field = new LibDrawField( this );
    LIB_FIELD* field = new LIB_FIELD( this );

    if ( !field->Load( line, errorMsg ) )
    {
@@ -846,9 +832,9 @@ EDA_Rect LIB_COMPONENT::GetBoundaryBox( int Unit, int Convert )

/** Function SetFields
 * initialize fields from a vector of fields
 * @param aFields a std::vector <LibDrawField> to import.
 * @param aFields a std::vector <LIB_FIELD> to import.
 */
void LIB_COMPONENT::SetFields( const std::vector <LibDrawField> aFields )
void LIB_COMPONENT::SetFields( const std::vector <LIB_FIELD> aFields )
{
    // Init basic fields (Value = name in lib, and reference):
    aFields[VALUE].Copy( &m_Name );
@@ -867,7 +853,7 @@ void LIB_COMPONENT::SetFields( const std::vector <LibDrawField> aFields )
            create = TRUE;
        if( create )
        {
            LibDrawField*Field = new LibDrawField( this, ii );
            LIB_FIELD*Field = new LIB_FIELD( this, ii );
            aFields[ii].Copy( Field );
            m_Fields.PushBack( Field );
        }
@@ -879,7 +865,7 @@ void LIB_COMPONENT::SetFields( const std::vector <LibDrawField> aFields )
     * text is like a void text and for non editable names, remove the name
     * (set to the default name)
     */
    for( LibDrawField* Field = m_Fields; Field; Field = Field->Next() )
    for( LIB_FIELD* Field = m_Fields; Field; Field = Field->Next() )
    {
        Field->SetParent( this );
        if( Field->m_FieldId >= FIELD1 )
@@ -947,7 +933,7 @@ void LIB_COMPONENT::SetOffset( const wxPoint& offset )
    m_Name.SetOffset( offset );
    m_Prefix.SetOffset( offset );

    for( LibDrawField* field = m_Fields; field != NULL; field = field->Next() )
    for( LIB_FIELD* field = m_Fields; field != NULL; field = field->Next() )
    {
        field->SetOffset( offset );
    }
@@ -979,7 +965,7 @@ bool LIB_COMPONENT::HasConversion() const

void LIB_COMPONENT::ClearStatus( void )
{
    LibDrawField* field;
    LIB_FIELD* field;

    BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
        item.m_Flags = 0;
@@ -1032,7 +1018,7 @@ int LIB_COMPONENT::SelectItems( EDA_Rect& rect, int unit, int convert,
        ItemsCount++;
    }

    for( LibDrawField* field = m_Fields.GetFirst(); field != NULL;
    for( LIB_FIELD* field = m_Fields.GetFirst(); field != NULL;
         field = field->Next() )
    {
        if( field->Inside( rect ) )
@@ -1048,7 +1034,7 @@ int LIB_COMPONENT::SelectItems( EDA_Rect& rect, int unit, int convert,

void LIB_COMPONENT::MoveSelectedItems( const wxPoint& offset )
{
    LibDrawField*  field;
    LIB_FIELD*  field;

    BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
    {
@@ -1086,7 +1072,7 @@ void LIB_COMPONENT::MoveSelectedItems( const wxPoint& offset )

void LIB_COMPONENT::ClearSelectedItems( void )
{
    LibDrawField* field;
    LIB_FIELD* field;

    BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
        item.m_Flags = item.m_Selected = 0;
@@ -1132,7 +1118,7 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& offset )

void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& center )
{
    LibDrawField*  field;
    LIB_FIELD*  field;

    BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
    {
@@ -1183,7 +1169,7 @@ void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& center )
LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert,
                                              KICAD_T type, const wxPoint& pt )
{
    LibDrawField*  field;
    LIB_FIELD*  field;

    BOOST_FOREACH( LIB_DRAW_ITEM& item, m_Drawings )
    {
Loading