Commit 173c9396 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

Remove zip library by switching to wxZlibOutputStream for PDF plotter.

Delete LEGACY_PLUGIN cache after deleting library of same name.
Remove automatically generted freerouter help header.
Add Normalize() to BOX2.
Clamp some values in the virtual space of drawframe.cpp
parent f459e4f7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -257,7 +257,6 @@ set(INC_AFTER

add_subdirectory(bitmaps_png)
add_subdirectory(common)
add_subdirectory(zlib)
add_subdirectory(3d-viewer)
add_subdirectory(cvpcb)
add_subdirectory(eeschema)
+0 −1
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@ include_directories(
    ../3d-viewer
    ../pcbnew
    ../polygon
    ../zlib
    ${INC_AFTER}
    )

+25 −29
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@
#include <plot_common.h>
#include <macros.h>
#include <kicad_string.h>
#include <zlib.h>
#include <wx/zstream.h>
#include <wx/mstream.h>

void PDF_PLOTTER::SetPageSettings( const PAGE_INFO& aPageSettings )
{
@@ -424,41 +425,36 @@ void PDF_PLOTTER::closePdfStream()
    workFile = 0;
    ::wxRemoveFile( workFilename );

    z_stream zstrm;
    zstrm.zalloc = NULL;
    zstrm.zfree = NULL;
    zstrm.opaque = NULL;
    wxMemoryOutputStream    memos;

    /* Somewhat standard parameters to compress in FLATE. The PDF spec is
    {
        /* Somewhat standard parameters to compress in DEFLATE. The PDF spec is
           misleading, it says it wants a FLATE stream but it really want a ZLIB
       stream! (a FLATE stream would be generated with -15 instead of 15) */
           stream! (a DEFLATE stream would be generated with -15 instead of 15)
        rc = deflateInit2( &zstrm, Z_BEST_COMPRESSION, Z_DEFLATED, 15,
                               8, Z_DEFAULT_STRATEGY );
    wxASSERT( rc == Z_OK );
    zstrm.avail_in = stream_len;
    zstrm.next_in = inbuf;
        */

        wxZlibOutputStream      zos( memos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );

    // PDF streams are very compactable, we trust it doesn't expand
    unsigned char *outbuf = new unsigned char[stream_len];
    zstrm.avail_out = stream_len;
    zstrm.next_out = outbuf;
        zos.Write( inbuf, stream_len );

    // Do a full in-memory compaction
    rc = deflate( &zstrm, Z_FINISH );
    wxASSERT( rc == Z_STREAM_END );
    }   // flush the zip stream using destructor

    // Now write the packed stream on the main file and free memory
    stream_len -= zstrm.avail_out;
    fwrite( outbuf, 1, stream_len, outputFile );
    wxStreamBuffer* sb = memos.GetOutputStreamBuffer();

    unsigned out_count = sb->Tell();

    fwrite( sb->GetBufferStart(), 1, out_count, outputFile );

    delete[] inbuf;
    delete[] outbuf;

    fputs( "endstream\n", outputFile );
    closePdfObject();

    // Writing the deferred length as an indirect object
    startPdfObject( streamLengthHandle );
    fprintf( outputFile, "%d\n", stream_len );
    fprintf( outputFile, "%u\n", out_count );
    closePdfObject();
}

+51 −26
Original line number Diff line number Diff line
@@ -661,6 +661,10 @@ bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, int aKey, const wxPoint& aPosi
}


#define VIRT_MIN    double(INT_MIN+100)
#define VIRT_MAX    double(INT_MAX-100)


void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
{
    BASE_SCREEN* screen = GetScreen();
@@ -701,6 +705,23 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
    }

    DBOX    clientRectIU( xIU, yIU, clientSizeIU.x, clientSizeIU.y );
    wxPoint centerPositionIU;

    // put "int" limits on the clientRect
    {
        if( clientRectIU.GetLeft() < VIRT_MIN )
            clientRectIU.MoveLeftTo( VIRT_MIN );
        if( clientRectIU.GetTop() < VIRT_MIN )
            clientRectIU.MoveTopTo( VIRT_MIN );
        if( clientRectIU.GetRight() > VIRT_MAX )
            clientRectIU.MoveRightTo( VIRT_MAX );
        if( clientRectIU.GetBottom() > VIRT_MAX )
            clientRectIU.MoveBottomTo( VIRT_MAX );

        centerPositionIU.x = KiROUND( clientRectIU.x + clientRectIU.width/2 );
        centerPositionIU.y = KiROUND( clientRectIU.y + clientRectIU.height/2 );
    }

    DSIZE   virtualSizeIU;

    if( pageRectIU.GetLeft() < clientRectIU.GetLeft() && pageRectIU.GetRight() > clientRectIU.GetRight() )
@@ -709,26 +730,24 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
    }
    else
    {
        double drawingCenterX = pageRectIU.x   + ( pageRectIU.width / 2 );
        double pageCenterX    = pageRectIU.x   + ( pageRectIU.width / 2 );
        double clientCenterX  = clientRectIU.x + ( clientRectIU.width / 2 );

        if( clientRectIU.width > pageRectIU.width )
        {
            if( drawingCenterX > clientCenterX )
                virtualSizeIU.x = ( drawingCenterX - clientRectIU.GetLeft() ) * 2;
            else if( drawingCenterX < clientCenterX )
                virtualSizeIU.x = ( clientRectIU.GetRight() - drawingCenterX ) * 2;
            if( pageCenterX > clientCenterX )
                virtualSizeIU.x = ( pageCenterX - clientRectIU.GetLeft() ) * 2;
            else if( pageCenterX < clientCenterX )
                virtualSizeIU.x = ( clientRectIU.GetRight() - pageCenterX ) * 2;
            else
                virtualSizeIU.x = clientRectIU.width;
        }
        else
        {
            if( drawingCenterX > clientCenterX )
                virtualSizeIU.x = pageRectIU.width +
                                ( (pageRectIU.GetLeft() - clientRectIU.GetLeft() ) * 2 );
            else if( drawingCenterX < clientCenterX )
                virtualSizeIU.x = pageRectIU.width +
                                ( (clientRectIU.GetRight() - pageRectIU.GetRight() ) * 2 );
            if( pageCenterX > clientCenterX )
                virtualSizeIU.x = pageRectIU.width + ( (pageRectIU.GetLeft() - clientRectIU.GetLeft() ) * 2 );
            else if( pageCenterX < clientCenterX )
                virtualSizeIU.x = pageRectIU.width + ( (clientRectIU.GetRight() - pageRectIU.GetRight() ) * 2 );
            else
                virtualSizeIU.x = pageRectIU.width;
        }
@@ -740,24 +759,24 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
    }
    else
    {
        int drawingCenterY = pageRectIU.y   + ( pageRectIU.height / 2 );
        int clientCenterY  = clientRectIU.y + ( clientRectIU.height / 2 );
        double pageCenterY   = pageRectIU.y   + ( pageRectIU.height / 2 );
        double clientCenterY = clientRectIU.y + ( clientRectIU.height / 2 );

        if( clientRectIU.height > pageRectIU.height )
        {
            if( drawingCenterY > clientCenterY )
                virtualSizeIU.y = ( drawingCenterY - clientRectIU.GetTop() ) * 2;
            else if( drawingCenterY < clientCenterY )
                virtualSizeIU.y = ( clientRectIU.GetBottom() - drawingCenterY ) * 2;
            if( pageCenterY > clientCenterY )
                virtualSizeIU.y = ( pageCenterY - clientRectIU.GetTop() ) * 2;
            else if( pageCenterY < clientCenterY )
                virtualSizeIU.y = ( clientRectIU.GetBottom() - pageCenterY ) * 2;
            else
                virtualSizeIU.y = clientRectIU.height;
        }
        else
        {
            if( drawingCenterY > clientCenterY )
            if( pageCenterY > clientCenterY )
                virtualSizeIU.y = pageRectIU.height +
                                ( ( pageRectIU.GetTop() - clientRectIU.GetTop() ) * 2 );
            else if( drawingCenterY < clientCenterY )
            else if( pageCenterY < clientCenterY )
                virtualSizeIU.y = pageRectIU.height +
                                ( ( clientRectIU.GetBottom() - pageRectIU.GetBottom() ) * 2 );
            else
@@ -767,11 +786,17 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )

    if( screen->m_Center )
    {
        virtualSizeIU.x = std::min( virtualSizeIU.x, VIRT_MAX );
        virtualSizeIU.y = std::min( virtualSizeIU.y, VIRT_MAX );

        screen->m_DrawOrg.x = -KiROUND( virtualSizeIU.x / 2.0 );
        screen->m_DrawOrg.y = -KiROUND( virtualSizeIU.y / 2.0 );
    }
    else
    {
        virtualSizeIU.x = std::min( virtualSizeIU.x, VIRT_MAX );
        virtualSizeIU.y = std::min( virtualSizeIU.y, VIRT_MAX );

        screen->m_DrawOrg.x = -KiROUND( ( virtualSizeIU.x - pageRectIU.width )  / 2.0 );
        screen->m_DrawOrg.y = -KiROUND( ( virtualSizeIU.y - pageRectIU.height ) / 2.0 );
    }
@@ -790,10 +815,10 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )

    // Calculate the scroll bar position in internal units to place the
    // center position at the center of client rectangle.
    screen->SetScrollCenterPosition( aCenterPositionIU );
    screen->SetScrollCenterPosition( centerPositionIU );

    double posX = aCenterPositionIU.x - clientRectIU.width /2.0 - screen->m_DrawOrg.x;
    double posY = aCenterPositionIU.y - clientRectIU.height/2.0 - screen->m_DrawOrg.y;
    double posX = centerPositionIU.x - clientRectIU.width /2.0 - screen->m_DrawOrg.x;
    double posY = centerPositionIU.y - clientRectIU.height/2.0 - screen->m_DrawOrg.y;

    // Convert scroll bar position to device units.
    posX = KiROUND( posX * scale );
@@ -801,25 +826,25 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )

    if( posX < 0 )
    {
        wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %d" ), posX );
        wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.16g" ), posX );
        posX = 0;
    }

    if( posX > unitsX )
    {
        wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %d" ), posX );
        wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.16g" ), posX );
        posX = unitsX;
    }

    if( posY < 0 )
    {
        wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %d" ), posY );
        wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.16g" ), posY );
        posY = 0;
    }

    if( posY > unitsY )
    {
        wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %d" ), posY );
        wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.16g" ), posY );
        posY = unitsY;
    }

+0 −1
Original line number Diff line number Diff line
@@ -220,7 +220,6 @@ target_link_libraries(eeschema
    kbool
    ${wxWidgets_LIBRARIES}
    ${GDI_PLUS_LIBRARIES}
    zlib
    )

install(TARGETS eeschema
Loading