Commit 37ee2394 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Pcbnew: in SVG export, add option to export only the board area, not the full page.

dialog plot functions: fix compil warnings with wxWidgets 2.8
parent ba6da604
Loading
Loading
Loading
Loading
+33 −38
Original line number Diff line number Diff line
@@ -119,24 +119,25 @@ wxString wxBrushString(wxColour c, int style = wxBRUSHSTYLE_SOLID)

IMPLEMENT_ABSTRACT_CLASS(KicadSVGFileDCImpl, wxDC)

KicadSVGFileDCImpl::KicadSVGFileDCImpl( KicadSVGFileDC *owner, const wxString &filename,
                    int width, int height, double dpi ) :
KicadSVGFileDCImpl::KicadSVGFileDCImpl( KicadSVGFileDC *owner, const wxString &aFilename,
                    wxPoint aOrigin, wxSize aSize, double aDpi ) :
        wxDCImpl( owner )
    {
        Init( filename, width, height, dpi );
        Init( aFilename, aOrigin, aSize, aDpi );
    }

void KicadSVGFileDCImpl::Init (const wxString &filename, int Width, int Height, double dpi)
void KicadSVGFileDCImpl::Init ( const wxString &aFilename,
                                wxPoint aOrigin, wxSize aSize, double aDpi)
{
    m_width = Width;
    m_height = Height;
    m_width = aSize.x;
    m_height = aSize.y;

    m_dpi = dpi;
    m_dpi = aDpi;

    m_OK = true;

    m_mm_to_pix_x = dpi/25.4;
    m_mm_to_pix_y = dpi/25.4;
    m_mm_to_pix_x = m_dpi/25.4;
    m_mm_to_pix_y = m_dpi/25.4;

    m_backgroundBrush = *wxTRANSPARENT_BRUSH;
    m_textForegroundColour = *wxBLACK;
@@ -151,11 +152,11 @@ void KicadSVGFileDCImpl::Init (const wxString &filename, int Width, int Height,

    ////////////////////code here

    m_outfile = new wxFileOutputStream(filename);
    m_outfile = new wxFileOutputStream(aFilename);
    m_OK = m_outfile->IsOk();
    if (m_OK)
    {
        m_filename = filename;
        m_filename = aFilename;
        m_sub_images = 0;
        wxString s;
        s = wxT("<?xml version=\"1.0\" standalone=\"no\"?>") + wxString(wxT("\n"));
@@ -166,9 +167,11 @@ void KicadSVGFileDCImpl::Init (const wxString &filename, int Width, int Height,
        write(s);
        s = wxT("<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" ") + wxString(wxT("\n"));
        write(s);
        s.Printf( wxT("    width=\"%scm\" height=\"%scm\" viewBox=\"0 0 %d %d \"> \n"), NumStr(float(Width)/dpi*2.54), NumStr(float(Height)/dpi*2.54), Width, Height );
        s.Printf( wxT("    width=\"%scm\" height=\"%scm\" viewBox=\"%d %d %d %d \"> \n"),
                  NumStr(float(m_width)/m_dpi*2.54), NumStr(float(m_height)/m_dpi*2.54),
                  aOrigin.x, aOrigin.y, m_width, m_height );
        write(s);
        s = wxT("<title>SVG Picture created as ") + wxFileName(filename).GetFullName() + wxT(" </title>") + wxT("\n");
        s = wxT("<title>SVG Picture created as ") + wxFileName(m_filename).GetFullName() + wxT(" </title>") + wxT("\n");
        write(s);
        s = wxString (wxT("<desc>Picture generated by wxSVG ")) + wxSVGVersion + wxT(" </desc>")+ wxT("\n");
        write(s);
@@ -738,20 +741,21 @@ wxString wxBrushString( wxColour c, int style )


/***********************************************************************/
void wxSVGFileDC::Init( wxString f, int Width, int Height, float dpi )
void wxSVGFileDC::Init( const wxString& aFilename,
                        wxPoint aOrigin, wxSize aSize, double aDpi )
/***********************************************************************/

/* set up things first  wxDCBase does all this?
 */
{
    m_width  = Width;
    m_height = Height;
    m_width  = aSize.x;
    m_height = aSize.y;

    m_clipping = false;
    m_OK = true;

    m_mm_to_pix_x = dpi / 25.4;
    m_mm_to_pix_y = dpi / 25.4;
    m_mm_to_pix_x = aDpi / 25.4;
    m_mm_to_pix_y = aDpi / 25.4;

    m_signX = m_signY = 1;

@@ -780,11 +784,11 @@ void wxSVGFileDC::Init( wxString f, int Width, int Height, float dpi )

    ////////////////////code here

    m_outfile = new wxFileOutputStream( f );
    m_outfile = new wxFileOutputStream( aFilename );
    m_OK = m_outfile->Ok();
    if( m_OK )
    {
        m_filename   = f;
        m_filename   = aFilename;
        m_sub_images = 0;
        wxString s;
        s = wxT( "<?xml version=\"1.0\" standalone=\"no\"?>" ); s = s + newline;
@@ -800,13 +804,14 @@ void wxSVGFileDC::Init( wxString f, int Width, int Height, float dpi )
        write( s );
        s.Printf( wxT( "  version=\"1.1\"\n" ) );
        write( s );
        s.Printf( wxT( "  width=\"%gin\" height=\"%gin\" viewBox=\"0 0 %d %d \"\n" ),
                  double (Width) / dpi, double (Height) / dpi, Width, Height );
        s.Printf( wxT( "  width=\"%gin\" height=\"%gin\" viewBox=\"%d %d %d %d \"\n" ),
                  double (m_width) / aDpi, double (m_height) / aDpi,
                  aOrigin.x, aOrigin.y, aSize.x, aSize.y );
        write( s );
        s.Printf( wxT( ">\n" ) );
        write( s );

        s = wxT( "  <title>SVG Picture created as " ) + wxFileNameFromPath( f ) +
        s = wxT( "  <title>SVG Picture created as " ) + wxFileNameFromPath( aFilename ) +
            wxT( " </title>" ) + newline;
        write( s );
        s = wxString( wxT( "  <desc>Picture generated by wxSVG " ) ) + wxSVGVersion + wxT(
@@ -818,21 +823,11 @@ void wxSVGFileDC::Init( wxString f, int Width, int Height, float dpi )
}


// constructors
wxSVGFileDC::wxSVGFileDC( wxString f )
// constructor
wxSVGFileDC::wxSVGFileDC( const wxString &aFilename,
                          wxPoint aOrigin, wxSize aSize, double aDpi )
{
    // quarter 640x480 screen display at 72 dpi
    Init( f, 320, 240, 72.0 );
}

wxSVGFileDC::wxSVGFileDC( wxString f, int Width, int Height )
{
    Init( f, Width, Height, 72.0 );
}

wxSVGFileDC::wxSVGFileDC( wxString f, int Width, int Height, float dpi )
{
    Init( f, Width, Height, dpi );
    Init( aFilename, aOrigin, aSize, aDpi);
}

wxSVGFileDC::~wxSVGFileDC()
+291 −290
Original line number Diff line number Diff line
@@ -215,8 +215,9 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,

    LOCALE_IO   toggle;

    float       dpi = 1000.0;
    KicadSVGFileDC dc( FullFileName, sheetSize.x, sheetSize.y, dpi );
    double dpi = 1000.0*IU_PER_MILS;
    wxPoint origin;
    KicadSVGFileDC dc( FullFileName, origin, sheetSize, dpi );

    EDA_RECT    tmp = *panel->GetClipBox();
    GRResetPenAndBrush( &dc );
+2 −2
Original line number Diff line number Diff line
@@ -188,7 +188,7 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
        plot_offset.x = 0;
        plot_offset.y = 0;

        plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + '.'
        plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT(".")
                       + DXF_PLOTTER::GetDefaultFileExtension();

        PlotOneSheetDXF( plotFileName, screen, plot_offset, 1 );
+2 −2
Original line number Diff line number Diff line
@@ -336,7 +336,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll )
        plotOffset.x = -s_Offset.x;
        plotOffset.y = -s_Offset.y;

        plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.'
        plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT(".")
                       + HPGL_PLOTTER::GetDefaultFileExtension();

        LOCALE_IO   toggle;
+2 −2
Original line number Diff line number Diff line
@@ -218,7 +218,7 @@ void DIALOG_PLOT_SCHEMATIC_PDF::createPDFFile()

	if( first_page ) {
	    wxString msg;
	    wxString plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.'
	    wxString plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT(".")
                                + PDF_PLOTTER::GetDefaultFileExtension();
	    msg.Printf( _( "Plot: %s " ), GetChars( plotFileName ) );
	    m_MsgBox->AppendText( msg );
Loading