Commit 3803b79a authored by stambaughw's avatar stambaughw
Browse files

Component library editor improvements, build fix, and bug fixes.

* Add offset and block hit testing to library component objects.
* Improved search for library entries.
* Fixed library component editor component removal and addition.
* Library editor now uses wxUpdateUIEvents for updating all UI objects.
* Added version check to cmake find boost macro.
* Removed unused code in file libalias.cpp.
* Added method to WinEDA_DrawPanel to take mouse out of managed mode.
parent 7a0f7bda
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ check_find_package_result(OPENGL_FOUND "OpenGL")
######################
# Find Boost library #
######################
find_package(Boost QUIET)
find_package(Boost 1.36 QUIET)
check_find_package_result(Boost_FOUND "Boost")

##########################
+12 −0
Original line number Diff line number Diff line
@@ -1377,3 +1377,15 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event )
    Scroll( x, y );
    MouseToCursorSchema();
}


void WinEDA_DrawPanel::UnManageCursor( void )
{
    wxClientDC dc( this );

    if( ManageCurseur && ForceCloseManageCurseur )
    {
        ForceCloseManageCurseur( this, &dc );
        m_AutoPAN_Request = false;
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ set(EESCHEMA_SRCS
    getpart.cpp
    hierarch.cpp
    hotkeys.cpp
    libalias.cpp
    libarch.cpp
    libedit.cpp
    libedit_onleftclick.cpp
+5 −137
Original line number Diff line number Diff line
@@ -93,101 +93,11 @@ int MarkItemsInBloc( EDA_LibComponentStruct* LibComponent,
                continue;
        }

        switch( item->Type() )
        {
        case COMPONENT_ARC_DRAW_TYPE:
        {
            pos = ( (LibDrawArc*) item )->m_ArcStart; pos.y = -pos.y;
            if( Rect.Inside( pos ) )
            {
                item->m_Selected = IS_SELECTED;
                ItemsCount++;
            }
            pos = ( (LibDrawArc*) item )->m_ArcEnd; pos.y = -pos.y;
            if( Rect.Inside( pos ) )
            {
                item->m_Selected = IS_SELECTED;
                ItemsCount++;
            }
            break;
        }

        case COMPONENT_CIRCLE_DRAW_TYPE:
            pos = ( (LibDrawCircle*) item )->m_Pos; pos.y = -pos.y;
            if( Rect.Inside( pos ) )
            {
                item->m_Selected = IS_SELECTED;
                ItemsCount++;
            }
            break;

        case COMPONENT_RECT_DRAW_TYPE:
            pos = ( (LibDrawSquare*) item )->m_Pos; pos.y = -pos.y;
            if( Rect.Inside( pos ) )
            {
                item->m_Selected = IS_SELECTED;
                ItemsCount++;
            }
            pos = ( (LibDrawSquare*) item )->m_End; pos.y = -pos.y;
            if( Rect.Inside( pos ) )
        if( item->Inside( Rect ) )
        {
            item->m_Selected = IS_SELECTED;
            ItemsCount++;
        }
            break;

        case COMPONENT_POLYLINE_DRAW_TYPE:
        {
            int  ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount();
            for( ii = 0; ii < imax; ii ++ )
            {
                pos = ( (LibDrawPolyline*) item )->m_PolyPoints[ii];
                NEGATE( pos.y );
                if( Rect.Inside( pos ) )
                {
                    item->m_Selected = IS_SELECTED;
                    ItemsCount++;
                    break;
                }
            }
        }
            break;

        case COMPONENT_LINE_DRAW_TYPE:
            break;

        case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
            pos = ( (LibDrawText*) item )->m_Pos; pos.y = -pos.y;
            if( Rect.Inside( pos ) )
            {
                item->m_Selected = IS_SELECTED;
                ItemsCount++;
            }
            break;

        case COMPONENT_PIN_DRAW_TYPE:
                #undef STRUCT
                #define STRUCT ( (LibDrawPin*) item )
            pos = STRUCT->m_Pos; pos.y = -pos.y;
            if( Rect.Inside( pos ) )
            {
                item->m_Selected = IS_SELECTED;
                ItemsCount++;
            }
            pos = STRUCT->ReturnPinEndPoint(); pos.y = -pos.y;
            if( Rect.Inside( pos ) )
            {
                item->m_Selected = IS_SELECTED;
                ItemsCount++;
            }
            break;

        case COMPONENT_FIELD_DRAW_TYPE:
            break;

        default:
            break;
        }
    }

    return ItemsCount;
@@ -513,54 +423,12 @@ void MoveMarkedItems( EDA_LibComponentStruct* LibEntry, wxPoint offset )
        return;

    NEGATE( offset.y );  // Y axis for lib items is Down to Up: reverse y offset value
    item = LibEntry->m_Drawings;
    for( ; item != NULL; item = item->Next() )
    for( item = LibEntry->m_Drawings; item != NULL; item = item->Next() )
    {
        if( item->m_Selected == 0 )
            continue;

        switch( item->Type() )
        {
        case COMPONENT_PIN_DRAW_TYPE:
            ( (LibDrawPin*) item )->m_Pos += offset;
            break;

        case COMPONENT_ARC_DRAW_TYPE:
        {
            ( (LibDrawArc*) item )->m_Pos      += offset;
            ( (LibDrawArc*) item )->m_ArcStart += offset;
            ( (LibDrawArc*) item )->m_ArcEnd   += offset;
            break;
        }

        case COMPONENT_CIRCLE_DRAW_TYPE:
            ( (LibDrawCircle*) item )->m_Pos += offset;
            break;

        case COMPONENT_RECT_DRAW_TYPE:
            ( (LibDrawSquare*) item )->m_Pos += offset;
            ( (LibDrawSquare*) item )->m_End += offset;
            break;

        case COMPONENT_POLYLINE_DRAW_TYPE:
        {
            unsigned ii, imax = ( (LibDrawPolyline*) item )->GetCornerCount();
            for( ii = 0; ii < imax; ii ++ )
                ( (LibDrawPolyline*) item )->m_PolyPoints[ii] += offset;
        }
            break;

        case COMPONENT_LINE_DRAW_TYPE:
            break;

        case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
            ( (LibDrawText*) item )->m_Pos += offset;
            break;

        default:
            break;
        }

        item->SetOffset( offset );
        item->m_Flags = item->m_Selected = 0;
    }
}
+36 −8
Original line number Diff line number Diff line
@@ -39,11 +39,13 @@ bool LibDrawText::Save( FILE* ExportFile ) const
    // changed to '~'
    text.Replace( wxT( " " ), wxT( "~" ) );

    fprintf( ExportFile, "T %d %d %d %d %d %d %d %s ", m_Orient,
    if( fprintf( ExportFile, "T %d %d %d %d %d %d %d %s ", m_Orient,
                 m_Pos.x, m_Pos.y, m_Size.x, m_Attributs, m_Unit, m_Convert,
            CONV_TO_UTF8( text ) );
    fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal",
             ( m_Bold>0 ) ? 1 : 0 );
                 CONV_TO_UTF8( text ) ) < 0 )
        return false;
    if( fprintf( ExportFile, " %s %d", m_Italic ? "Italic" : "Normal",
                 ( m_Bold > 0 ) ? 1 : 0 ) < 0 )
        return false;

    char hjustify = 'C';
    if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
@@ -57,9 +59,8 @@ bool LibDrawText::Save( FILE* ExportFile ) const
    else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
        vjustify = 'T';

    fprintf( ExportFile, " %c %c", hjustify, vjustify );

    fprintf( ExportFile, "\n" );
    if( fprintf( ExportFile, " %c %c\n", hjustify, vjustify ) < 0 )
        return false;

    return true;
}
@@ -192,6 +193,33 @@ LibEDA_BaseStruct* LibDrawText::DoGenCopy()
}


bool LibDrawText::DoCompare( const LibEDA_BaseStruct& other ) const
{
    wxASSERT( other.Type() == COMPONENT_GRAPHIC_TEXT_DRAW_TYPE );

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

    return ( ( m_Pos == tmp->m_Pos ) && ( m_Size == tmp->m_Size )
             && ( m_Text == tmp->m_Text ) );
}


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


bool LibDrawText::DoTestInside( EDA_Rect& rect )
{
    /*
     * FIXME: This should calculate the text size and justification and
     *        use rectangle instect.
     */
    return rect.Inside( m_Pos.x, -m_Pos.y );
}


/** Function GetPenSize
 * @return the size of the "pen" that be used to draw or plot this item
 */
Loading