Commit 6bb62a71 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Remove duplicate files.

Page layout editor: Add bitmap items to the page layout existing items.
Now a bitmap image can be added to a page layout description. Currently the bitmap is expected having a 300 ppi definition.
Note: not all plotters can plot a bitmap, and in this case the bounding box is plotted instead of the bitmap
parents 9e9450e2 7acc3e67
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -492,7 +492,7 @@ void EDA_3D_CANVAS::InitGL()
        glEnable( GL_DEPTH_TEST );      // Enable z-buferring
        glEnable( GL_ALPHA_TEST );
        glEnable( GL_LINE_SMOOTH );
        glEnable(GL_POLYGON_SMOOTH);
//        glEnable(GL_POLYGON_SMOOTH);  // creates issues with some graphic cards
        glShadeModel( GL_SMOOTH );
        glEnable( GL_COLOR_MATERIAL );
        glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
+33 −0
Original line number Diff line number Diff line
@@ -121,6 +121,35 @@ bool BITMAP_BASE::SaveData( FILE* aFile ) const
    return true;
}

void BITMAP_BASE::SaveData( wxArrayString& aPngStrings ) const
{
    if( m_image )
    {
        wxMemoryOutputStream stream;
        m_image->SaveFile( stream, wxBITMAP_TYPE_PNG );

        // Write binary data in hexadecimal form (ASCII)
        wxStreamBuffer* buffer = stream.GetOutputStreamBuffer();
        char*           begin  = (char*) buffer->GetBufferStart();
        wxString line;
        for( int ii = 0; begin <= buffer->GetBufferEnd(); begin++, ii++ )
        {
            if( ii >= 32 )
            {
                ii = 0;
                aPngStrings.Add( line );
                line.Empty();
            }

            line << wxString::Format( wxT("%2.2X "), *begin & 0xFF );
        }

        // Add last line:
        if( !line.IsEmpty() )
            aPngStrings.Add( line );
    }
}


bool BITMAP_BASE::LoadData( LINE_READER& aLine, wxString& aErrorMsg )
{
@@ -130,9 +159,13 @@ bool BITMAP_BASE::LoadData( LINE_READER& aLine, wxString& aErrorMsg )
    while( true )
    {
        if( !aLine.ReadLine() )
        {
            aErrorMsg = wxT("Unexpected end of data");
            return false;
        }

        line = aLine.Line();

        if( strnicmp( line, "EndData", 4 ) == 0 )
        {
            // all the PNG date is read.
+15 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <drawtxt.h>
#include <class_title_block.h>
#include "worksheet_shape_builder.h"
#include "class_worksheet_dataitem.h"
#include <wx/filename.h>


@@ -137,6 +138,20 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
                                   poly->IsFilled() ? FILLED_SHAPE : NO_FILL );
            }
            break;

        case WS_DRAW_ITEM_BASE::wsg_bitmap:
            {
                WS_DRAW_ITEM_BITMAP* bm = (WS_DRAW_ITEM_BITMAP*) item;

                WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)bm->GetParent();

                if( parent->m_ImageBitmap == NULL )
                    break;

                parent->m_ImageBitmap->PlotImage( plotter, bm->GetPosition(),
                               plotColor, PLOTTER::DEFAULT_LINE_WIDTH );
            }
            break;
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -316,6 +316,7 @@ const wxString WORKSHEET_DATAITEM::GetClassName() const
        case WS_SEGMENT: name = wxT("Line"); break;
        case WS_RECT: name = wxT("Rect"); break;
        case WS_POLYPOLYGON: name = wxT("Poly"); break;
        case WS_BITMAP: name = wxT("Bitmap"); break;
    }

    return name;
@@ -539,3 +540,4 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
    }
}

+65 −9
Original line number Diff line number Diff line
@@ -156,6 +156,18 @@ void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC )
                }
            }
            break;

        case WS_DRAW_ITEM_BASE::wsg_bitmap:
            {
                WS_DRAW_ITEM_BITMAP* bitmap = (WS_DRAW_ITEM_BITMAP*) item;

                if( markerSize )
                {
                    drawMarker( aClipBox, aDC, bitmap->GetPosition(),
                                markerSize );
                }
            }
            break;
        }
    }
}
@@ -274,10 +286,10 @@ bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition)
 */
bool WS_DRAW_ITEM_RECT::HitTestStartPoint( const wxPoint& aPosition)
{
    wxPoint pos = GetStart();
    wxPoint dist = GetStart() - aPosition;

    if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
        std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
    if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
        std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
        return true;

    return false;
@@ -313,10 +325,10 @@ bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition)
 */
bool WS_DRAW_ITEM_LINE::HitTestStartPoint( const wxPoint& aPosition)
{
    wxPoint pos = GetStart();
    wxPoint dist = GetStart() - aPosition;

    if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
        std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
    if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
        std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
        return true;

    return false;
@@ -326,10 +338,10 @@ bool WS_DRAW_ITEM_LINE::HitTestStartPoint( const wxPoint& aPosition)
 */
bool WS_DRAW_ITEM_LINE::HitTestEndPoint( const wxPoint& aPosition)
{
    wxPoint pos = GetEnd();
    wxPoint dist = GetEnd() - aPosition;

    if( std::abs( pos.x - aPosition.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
        std::abs( pos.y - aPosition.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
    if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
        std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
        return true;

    return false;
@@ -365,3 +377,47 @@ void WS_DRAW_ITEM_LIST::Locate( std::vector <WS_DRAW_ITEM_BASE*>& aList,
        }
    }
}

/** The function to draw a WS_DRAW_ITEM_BITMAP
 */
void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC )
{
    WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)GetParent();

    if( parent->m_ImageBitmap  )
    {
        parent->m_ImageBitmap->DrawBitmap( NULL, aDC, m_pos );
    }
}

/**
 * Virtual function
 * return true if the point aPosition is on bitmap
 */
bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition)
{
    WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)GetParent();

    if( parent->m_ImageBitmap == NULL )
        return false;

    EDA_RECT rect = parent->m_ImageBitmap->GetBoundingBox();
    rect.Move( m_pos );
    return rect.Contains( aPosition );
}


/**
 * return true if the point aPosition is on the reference point of this item.
 */
bool WS_DRAW_ITEM_BITMAP::HitTestStartPoint( const wxPoint& aPosition)
{
    wxPoint dist = m_pos - aPosition;

    if( std::abs( dist.x) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 &&
        std::abs( dist.y) <= WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 )
        return true;

    return false;
}
Loading