From 37ee239449d9ed3d2f75bb073eecc3da0fa7286b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 31 Aug 2012 09:43:37 +0200 Subject: [PATCH] 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 --- common/dcsvg.cpp | 71 +-- eeschema/dialogs/dialog_SVG_print.cpp | 581 +++++++++--------- .../dialogs/dialog_plot_schematic_DXF.cpp | 4 +- .../dialogs/dialog_plot_schematic_HPGL.cpp | 4 +- .../dialogs/dialog_plot_schematic_PDF.cpp | 4 +- eeschema/dialogs/dialog_plot_schematic_PS.cpp | 2 +- eeschema/getpart.cpp | 14 +- eeschema/viewlib_frame.cpp | 6 +- include/dcsvg.h | 22 +- pcbnew/dialogs/dialog_SVG_print.cpp | 122 ++-- pcbnew/dialogs/dialog_SVG_print.h | 85 +-- pcbnew/dialogs/dialog_SVG_print_base.cpp | 39 +- pcbnew/dialogs/dialog_SVG_print_base.fbp | 162 ++--- pcbnew/dialogs/dialog_SVG_print_base.h | 9 +- pcbnew/moduleframe.cpp | 2 + 15 files changed, 553 insertions(+), 574 deletions(-) diff --git a/common/dcsvg.cpp b/common/dcsvg.cpp index 2940db5ae3..7693052204 100644 --- a/common/dcsvg.cpp +++ b/common/dcsvg.cpp @@ -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("") + wxString(wxT("\n")); @@ -166,9 +167,11 @@ void KicadSVGFileDCImpl::Init (const wxString &filename, int Width, int Height, write(s); s = wxT(" \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("SVG Picture created as ") + wxFileName(filename).GetFullName() + wxT(" ") + wxT("\n"); + s = wxT("SVG Picture created as ") + wxFileName(m_filename).GetFullName() + wxT(" ") + wxT("\n"); write(s); s = wxString (wxT("Picture generated by wxSVG ")) + wxSVGVersion + wxT(" ")+ wxT("\n"); write(s); @@ -738,27 +741,28 @@ 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; m_userScaleX = m_userScaleY = m_deviceOriginX = m_deviceOriginY = 0; - m_OriginX = m_OriginY = 0; + m_OriginX = m_OriginY = 0; m_logicalOriginX = m_logicalOriginY = 0; m_logicalScaleX = m_logicalScaleY = 0; m_scaleX = m_scaleY = 1.0; @@ -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( "" ); 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( " SVG Picture created as " ) + wxFileNameFromPath( f ) + + s = wxT( " SVG Picture created as " ) + wxFileNameFromPath( aFilename ) + wxT( " " ) + newline; write( s ); s = wxString( wxT( " 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() diff --git a/eeschema/dialogs/dialog_SVG_print.cpp b/eeschema/dialogs/dialog_SVG_print.cpp index d174312eaa..07612f3f05 100644 --- a/eeschema/dialogs/dialog_SVG_print.cpp +++ b/eeschema/dialogs/dialog_SVG_print.cpp @@ -1,290 +1,291 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/** - * @file eeschema/dialogs/dialog_SVG_print.cpp - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - - -// Keys for configuration -#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" ) - -#define WIDTH_MAX_VALUE 100 -#define WIDTH_MIN_VALUE 1 - -// Variables locales -static bool s_Print_Frame_Ref = true; -static int s_PlotBlackAndWhite = 0; - - -/*! - * DIALOG_SVG_PRINT functions - */ -DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent ) : - DIALOG_SVG_PRINT_base( parent ) -{ - m_Parent = parent; - m_Config = wxGetApp().GetSettings(); -} - - -void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) -{ - SetFocus(); // Make ESC key working - - if( m_Config ) - { - m_Config->Read( PLOTSVGMODECOLOR_KEY, &s_PlotBlackAndWhite ); - } - - m_ModeColorOption->SetSelection( s_PlotBlackAndWhite ); - - AddUnitSymbol( *m_TextPenWidth, g_UserUnit ); - m_DialogPenWidth->SetValue( - ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness ) ); - m_Print_Sheet_Ref->SetValue( s_Print_Frame_Ref ); - - if( GetSizer() ) - { - GetSizer()->SetSizeHints( this ); - } -} - - -void DIALOG_SVG_PRINT::SetPenWidth() -{ - g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DialogPenWidth ); - - if( g_DrawDefaultLineThickness > WIDTH_MAX_VALUE ) - { - g_DrawDefaultLineThickness = WIDTH_MAX_VALUE; - } - - if( g_DrawDefaultLineThickness < WIDTH_MIN_VALUE ) - { - g_DrawDefaultLineThickness = WIDTH_MIN_VALUE; - } - - m_DialogPenWidth->SetValue( - ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness ) ); -} - - -void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) -{ - wxString msg; - wxFileName fn; - - SetPenWidth(); - - g_DrawDefaultLineThickness = - ReturnValueFromTextCtrl( *m_DialogPenWidth ); - - SCH_SCREEN* screen = (SCH_SCREEN*) m_Parent->GetScreen(); - - if( aPrintAll && m_Parent->IsType( SCHEMATIC_FRAME ) ) - { - SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_Parent; - SCH_SHEET_PATH* sheetpath; - SCH_SHEET_PATH oldsheetpath = schframe->GetCurrentSheet(); - SCH_SCREEN* schscreen = schframe->GetScreen(); - SCH_SHEET_LIST SheetList( NULL ); - sheetpath = SheetList.GetFirst(); - SCH_SHEET_PATH list; - - for( ; ; ) - { - if( sheetpath == NULL ) - break; - - list.Clear(); - - if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) - { - schframe->SetCurrentSheet( list ); - schframe->GetCurrentSheet().UpdateAllScreenReferences(); - schframe->SetSheetNumberAndCount(); - schscreen = schframe->GetCurrentSheet().LastScreen(); - } - else // Should not happen - return; - - sheetpath = SheetList.GetNext(); - - fn = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".svg" ); - - bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), ( SCH_SCREEN* ) schscreen, - m_ModeColorOption->GetSelection() == 0 ? false : true, - aPrint_Sheet_Ref ); - msg = _( "Create file " ) + fn.GetFullPath(); - if( !success ) - msg += _( " error" ); - msg += wxT( "\n" ); - m_MessagesBox->AppendText( msg ); - } - - schframe->SetCurrentSheet( oldsheetpath ); - schframe->GetCurrentSheet().UpdateAllScreenReferences(); - schframe->SetSheetNumberAndCount(); - } - else - { - fn = m_FileNameCtrl->GetValue(); - - if( !fn.IsOk() ) - fn = screen->GetFileName(); - - fn.SetExt( wxT( "svg" ) ); - fn.MakeAbsolute(); - - bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), ( SCH_SCREEN* ) screen, - m_ModeColorOption->GetSelection() == 0 ? false : true, - aPrint_Sheet_Ref ); - msg = _( "Create file " ) + fn.GetFullPath(); - - if( !success ) - msg += _( " error" ); - - msg += wxT( "\n" ); - m_MessagesBox->AppendText( msg ); - } -} - - -bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame, - const wxString& FullFileName, - SCH_SCREEN* screen, - bool aPrintBlackAndWhite, - bool aPrint_Sheet_Ref ) -{ - int tmpzoom; - wxPoint tmp_startvisu; - wxSize sheetSize; // Sheet size in internal units - wxPoint old_org; - bool success = true; - - tmp_startvisu = screen->m_StartVisu; - tmpzoom = screen->GetZoom(); - old_org = screen->m_DrawOrg; - screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0; - screen->m_StartVisu.x = screen->m_StartVisu.y = 0; - - sheetSize = screen->GetPageSettings().GetSizeIU(); // page size in 1/1000 inch, ie in internal units - - screen->SetScalingFactor( 1.0 ); - EDA_DRAW_PANEL* panel = frame->GetCanvas(); - - LOCALE_IO toggle; - - float dpi = 1000.0; - KicadSVGFileDC dc( FullFileName, sheetSize.x, sheetSize.y, dpi ); - - EDA_RECT tmp = *panel->GetClipBox(); - GRResetPenAndBrush( &dc ); - GRForceBlackPen( aPrintBlackAndWhite ); - - - panel->SetClipBox( EDA_RECT( wxPoint( -0x3FFFFF0, -0x3FFFFF0 ), - wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) ); - - screen->m_IsPrinting = true; - - if( frame->IsType( SCHEMATIC_FRAME ) ) - screen->Draw( panel, &dc, GR_COPY ); - - if( frame->IsType( LIBEDITOR_FRAME ) ) - ((LIB_EDIT_FRAME*)frame)->RedrawComponent( &dc, - wxPoint(sheetSize.x/2, - sheetSize.y/2) ); - - if( aPrint_Sheet_Ref ) - frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness, - IU_PER_MILS, frame->GetScreenDesc() ); - - screen->m_IsPrinting = false; - panel->SetClipBox( tmp ); - - GRForceBlackPen( false ); - - screen->m_StartVisu = tmp_startvisu; - screen->m_DrawOrg = old_org; - screen->SetZoom( tmpzoom ); - - return success; -} - - -void DIALOG_SVG_PRINT::OnButtonPlotAllClick( wxCommandEvent& event ) -{ - PrintSVGDoc( true, m_Print_Sheet_Ref->GetValue() ); -} - - -void DIALOG_SVG_PRINT::OnButtonPlotCurrentClick( wxCommandEvent& event ) -{ - PrintSVGDoc( false, m_Print_Sheet_Ref->GetValue() ); -} - - -void DIALOG_SVG_PRINT::OnButtonCancelClick( wxCommandEvent& event ) -{ - Close(); -} - - -void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) -{ - if( m_Config ) - { - s_PlotBlackAndWhite = m_ModeColorOption->GetSelection(); - m_Config->Write( PLOTSVGMODECOLOR_KEY, s_PlotBlackAndWhite ); - } - EndModal( 0 ); -} - - -/* called on radiobox color/black and white selection - */ -void DIALOG_SVG_PRINT::OnSetColorModeSelected( wxCommandEvent& event ) -{ - s_PlotBlackAndWhite = m_ModeColorOption->GetSelection(); -} +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2011 Wayne Stambaugh + * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * @file eeschema/dialogs/dialog_SVG_print.cpp + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + + +// Keys for configuration +#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" ) + +#define WIDTH_MAX_VALUE 100 +#define WIDTH_MIN_VALUE 1 + +// Variables locales +static bool s_Print_Frame_Ref = true; +static int s_PlotBlackAndWhite = 0; + + +/*! + * DIALOG_SVG_PRINT functions + */ +DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent ) : + DIALOG_SVG_PRINT_base( parent ) +{ + m_Parent = parent; + m_Config = wxGetApp().GetSettings(); +} + + +void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) +{ + SetFocus(); // Make ESC key working + + if( m_Config ) + { + m_Config->Read( PLOTSVGMODECOLOR_KEY, &s_PlotBlackAndWhite ); + } + + m_ModeColorOption->SetSelection( s_PlotBlackAndWhite ); + + AddUnitSymbol( *m_TextPenWidth, g_UserUnit ); + m_DialogPenWidth->SetValue( + ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness ) ); + m_Print_Sheet_Ref->SetValue( s_Print_Frame_Ref ); + + if( GetSizer() ) + { + GetSizer()->SetSizeHints( this ); + } +} + + +void DIALOG_SVG_PRINT::SetPenWidth() +{ + g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DialogPenWidth ); + + if( g_DrawDefaultLineThickness > WIDTH_MAX_VALUE ) + { + g_DrawDefaultLineThickness = WIDTH_MAX_VALUE; + } + + if( g_DrawDefaultLineThickness < WIDTH_MIN_VALUE ) + { + g_DrawDefaultLineThickness = WIDTH_MIN_VALUE; + } + + m_DialogPenWidth->SetValue( + ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness ) ); +} + + +void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) +{ + wxString msg; + wxFileName fn; + + SetPenWidth(); + + g_DrawDefaultLineThickness = + ReturnValueFromTextCtrl( *m_DialogPenWidth ); + + SCH_SCREEN* screen = (SCH_SCREEN*) m_Parent->GetScreen(); + + if( aPrintAll && m_Parent->IsType( SCHEMATIC_FRAME ) ) + { + SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_Parent; + SCH_SHEET_PATH* sheetpath; + SCH_SHEET_PATH oldsheetpath = schframe->GetCurrentSheet(); + SCH_SCREEN* schscreen = schframe->GetScreen(); + SCH_SHEET_LIST SheetList( NULL ); + sheetpath = SheetList.GetFirst(); + SCH_SHEET_PATH list; + + for( ; ; ) + { + if( sheetpath == NULL ) + break; + + list.Clear(); + + if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) + { + schframe->SetCurrentSheet( list ); + schframe->GetCurrentSheet().UpdateAllScreenReferences(); + schframe->SetSheetNumberAndCount(); + schscreen = schframe->GetCurrentSheet().LastScreen(); + } + else // Should not happen + return; + + sheetpath = SheetList.GetNext(); + + fn = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".svg" ); + + bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), ( SCH_SCREEN* ) schscreen, + m_ModeColorOption->GetSelection() == 0 ? false : true, + aPrint_Sheet_Ref ); + msg = _( "Create file " ) + fn.GetFullPath(); + if( !success ) + msg += _( " error" ); + msg += wxT( "\n" ); + m_MessagesBox->AppendText( msg ); + } + + schframe->SetCurrentSheet( oldsheetpath ); + schframe->GetCurrentSheet().UpdateAllScreenReferences(); + schframe->SetSheetNumberAndCount(); + } + else + { + fn = m_FileNameCtrl->GetValue(); + + if( !fn.IsOk() ) + fn = screen->GetFileName(); + + fn.SetExt( wxT( "svg" ) ); + fn.MakeAbsolute(); + + bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), ( SCH_SCREEN* ) screen, + m_ModeColorOption->GetSelection() == 0 ? false : true, + aPrint_Sheet_Ref ); + msg = _( "Create file " ) + fn.GetFullPath(); + + if( !success ) + msg += _( " error" ); + + msg += wxT( "\n" ); + m_MessagesBox->AppendText( msg ); + } +} + + +bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame, + const wxString& FullFileName, + SCH_SCREEN* screen, + bool aPrintBlackAndWhite, + bool aPrint_Sheet_Ref ) +{ + int tmpzoom; + wxPoint tmp_startvisu; + wxSize sheetSize; // Sheet size in internal units + wxPoint old_org; + bool success = true; + + tmp_startvisu = screen->m_StartVisu; + tmpzoom = screen->GetZoom(); + old_org = screen->m_DrawOrg; + screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0; + screen->m_StartVisu.x = screen->m_StartVisu.y = 0; + + sheetSize = screen->GetPageSettings().GetSizeIU(); // page size in 1/1000 inch, ie in internal units + + screen->SetScalingFactor( 1.0 ); + EDA_DRAW_PANEL* panel = frame->GetCanvas(); + + LOCALE_IO toggle; + + double dpi = 1000.0*IU_PER_MILS; + wxPoint origin; + KicadSVGFileDC dc( FullFileName, origin, sheetSize, dpi ); + + EDA_RECT tmp = *panel->GetClipBox(); + GRResetPenAndBrush( &dc ); + GRForceBlackPen( aPrintBlackAndWhite ); + + + panel->SetClipBox( EDA_RECT( wxPoint( -0x3FFFFF0, -0x3FFFFF0 ), + wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) ); + + screen->m_IsPrinting = true; + + if( frame->IsType( SCHEMATIC_FRAME ) ) + screen->Draw( panel, &dc, GR_COPY ); + + if( frame->IsType( LIBEDITOR_FRAME ) ) + ((LIB_EDIT_FRAME*)frame)->RedrawComponent( &dc, + wxPoint(sheetSize.x/2, + sheetSize.y/2) ); + + if( aPrint_Sheet_Ref ) + frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness, + IU_PER_MILS, frame->GetScreenDesc() ); + + screen->m_IsPrinting = false; + panel->SetClipBox( tmp ); + + GRForceBlackPen( false ); + + screen->m_StartVisu = tmp_startvisu; + screen->m_DrawOrg = old_org; + screen->SetZoom( tmpzoom ); + + return success; +} + + +void DIALOG_SVG_PRINT::OnButtonPlotAllClick( wxCommandEvent& event ) +{ + PrintSVGDoc( true, m_Print_Sheet_Ref->GetValue() ); +} + + +void DIALOG_SVG_PRINT::OnButtonPlotCurrentClick( wxCommandEvent& event ) +{ + PrintSVGDoc( false, m_Print_Sheet_Ref->GetValue() ); +} + + +void DIALOG_SVG_PRINT::OnButtonCancelClick( wxCommandEvent& event ) +{ + Close(); +} + + +void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) +{ + if( m_Config ) + { + s_PlotBlackAndWhite = m_ModeColorOption->GetSelection(); + m_Config->Write( PLOTSVGMODECOLOR_KEY, s_PlotBlackAndWhite ); + } + EndModal( 0 ); +} + + +/* called on radiobox color/black and white selection + */ +void DIALOG_SVG_PRINT::OnSetColorModeSelected( wxCommandEvent& event ) +{ + s_PlotBlackAndWhite = m_ModeColorOption->GetSelection(); +} diff --git a/eeschema/dialogs/dialog_plot_schematic_DXF.cpp b/eeschema/dialogs/dialog_plot_schematic_DXF.cpp index 79537a4ca1..34fd693fbc 100644 --- a/eeschema/dialogs/dialog_plot_schematic_DXF.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_DXF.cpp @@ -188,8 +188,8 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( ) plot_offset.x = 0; plot_offset.y = 0; - plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + '.' - + DXF_PLOTTER::GetDefaultFileExtension(); + plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT(".") + + DXF_PLOTTER::GetDefaultFileExtension(); PlotOneSheetDXF( plotFileName, screen, plot_offset, 1 ); diff --git a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp index fffc916e8a..630c55f300 100644 --- a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp @@ -336,8 +336,8 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll ) plotOffset.x = -s_Offset.x; plotOffset.y = -s_Offset.y; - plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.' - + HPGL_PLOTTER::GetDefaultFileExtension(); + plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT(".") + + HPGL_PLOTTER::GetDefaultFileExtension(); LOCALE_IO toggle; diff --git a/eeschema/dialogs/dialog_plot_schematic_PDF.cpp b/eeschema/dialogs/dialog_plot_schematic_PDF.cpp index 25799aef05..b160ee4bc8 100644 --- a/eeschema/dialogs/dialog_plot_schematic_PDF.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_PDF.cpp @@ -218,8 +218,8 @@ void DIALOG_PLOT_SCHEMATIC_PDF::createPDFFile() if( first_page ) { wxString msg; - wxString plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.' - + PDF_PLOTTER::GetDefaultFileExtension(); + wxString plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT(".") + + PDF_PLOTTER::GetDefaultFileExtension(); msg.Printf( _( "Plot: %s " ), GetChars( plotFileName ) ); m_MsgBox->AppendText( msg ); diff --git a/eeschema/dialogs/dialog_plot_schematic_PS.cpp b/eeschema/dialogs/dialog_plot_schematic_PS.cpp index 94068191d8..902e30d5d7 100644 --- a/eeschema/dialogs/dialog_plot_schematic_PS.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_PS.cpp @@ -242,7 +242,7 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile() plot_offset.x = 0; plot_offset.y = 0; - plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.' + plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT(".") + PS_PLOTTER::GetDefaultFileExtension(); plotOneSheetPS( plotFileName, screen, plotPage, plot_offset, scale ); diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index d599f785d7..3e25dab8db 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2008-2011 Wayne Stambaugh - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2008-2012 Wayne Stambaugh + * Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,7 +25,7 @@ /** * @file getpart.cpp - * @brief Cod to handle get & place library component. + * @brief functions to get and place library components. */ #include @@ -69,11 +69,15 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( void ) m_ViewlibFrame = new LIB_VIEW_FRAME( this, NULL, &semaphore ); // Show the library viewer frame until it is closed - while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event + // and disable the current frame, until the library viewer is closed + Enable(false); + // Wait for viewer closing event: + while( semaphore.TryWait() == wxSEMA_BUSY ) { wxYield(); wxMilliSleep( 50 ); } + Enable(true); cmpname = m_ViewlibFrame->GetSelectedComponent(); m_ViewlibFrame->Destroy(); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 984cb11737..274998f5da 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -122,9 +122,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph m_Semaphore = semaphore; m_exportToEeschemaCmpName.Empty(); - if( m_Semaphore ) - MakeModal(true); - SetScreen( new SCH_SCREEN() ); GetScreen()->m_Center = true; // Center coordinate origins on screen. LoadSettings(); @@ -270,9 +267,8 @@ void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) if( m_Semaphore ) { m_Semaphore->Post(); - MakeModal(false); // This window will be destroyed by the calling function, - // to avoid side effects + // if needed } else { diff --git a/include/dcsvg.h b/include/dcsvg.h index 0fffcde175..dee08fb245 100644 --- a/include/dcsvg.h +++ b/include/dcsvg.h @@ -26,8 +26,8 @@ class WXDLLIMPEXP_FWD_CORE KicadSVGFileDC; class WXDLLIMPEXP_CORE KicadSVGFileDCImpl : public wxDCImpl { public: - KicadSVGFileDCImpl( KicadSVGFileDC *owner, const wxString &filename, - int width=320, int height=240, double dpi=72.0 ); + KicadSVGFileDCImpl( KicadSVGFileDC *owner, const wxString &aFilename, + wxPoint aOrigin, wxSize aSize, double aDpi ); virtual ~KicadSVGFileDCImpl(); @@ -175,7 +175,7 @@ private: virtual wxSize GetPPI() const; - void Init (const wxString &filename, int width, int height, double dpi); + void Init (const wxString &aFilename, wxPoint aOrigin, wxSize aSize, double aDpi); void NewGraphics(); @@ -198,11 +198,9 @@ private: class WXDLLIMPEXP_CORE KicadSVGFileDC : public wxDC { public: - KicadSVGFileDC(const wxString& filename, - int width = 320, - int height = 240, - double dpi = 72.0) - : wxDC(new KicadSVGFileDCImpl(this, filename, width, height, dpi)) + KicadSVGFileDC(const wxString& aFilename, + wxPoint aOrigin, wxSize aSize, double aDpi = 300.0) + : wxDC(new KicadSVGFileDCImpl(this, aFilename, aOrigin, aSize, aDpi)) { } }; @@ -309,7 +307,8 @@ private: wxT( "wxSVGFILEDC::DoSetClippingRegionAsRegion Call not yet implemented" ) ); return; }; - void Init( wxString f, int Width, int Height, float dpi ); + void Init( const wxString& aFilename, + wxPoint aOrigin, wxSize aSize, double aDpi ); void NewGraphics(); @@ -421,9 +420,8 @@ private: public: - wxSVGFileDC( wxString f ); - wxSVGFileDC( wxString f, int Width, int Height ); - wxSVGFileDC( wxString f, int Width, int Height, float dpi ); + wxSVGFileDC( const wxString& aFilename, + wxPoint aOrigin, wxSize aSize, double aDpi ); ~wxSVGFileDC(); diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index 4a03ed178b..ba4b10e850 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -1,20 +1,39 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dialog_svg_print.cpp -// Author: jean-pierre Charras -// Modified by: -// Licence: GPL -///////////////////////////////////////////////////////////////////////////// +/** + * @file dialog_svg_print.cpp + */ + +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + #include #include #include #include -#include -#include #include #include #include -#include #include #include @@ -22,26 +41,23 @@ #include #include -#include -#include -#include -#include -#include #include // Keys for configuration #define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" ) +#define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" ) +#define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" ) -// reasonnable values for default pen width (in 1/10000 inch) -#define WIDTH_MAX_VALUE 500 -#define WIDTH_MIN_VALUE 1 +// reasonnable values for default pen width +#define WIDTH_MAX_VALUE (2 *IU_PER_MM) +#define WIDTH_MIN_VALUE (0.05 *IU_PER_MM) // Local variables: static PRINT_PARAMETERS s_Parameters; -static long s_SelectedLayers = LAYER_BACK | LAYER_FRONT | - SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK; +static long s_SelectedLayers = LAYER_BACK | LAYER_FRONT | + SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK; /*! @@ -66,15 +82,23 @@ void DIALOG_SVG_PRINT::initDialog( ) if( m_Config ) { m_Config->Read( PLOTSVGMODECOLOR_KEY, &s_Parameters.m_Print_Black_and_White ); + long ltmp; + m_Config->Read( PLOTSVGPAGESIZEOPT_KEY, <mp, 0 ); + m_rbSvgPageSizeOpt->SetSelection( ltmp ); + m_Config->Read( PLOTSVGPLOT_BRD_EDGE_KEY, <mp, 1 ); + m_PrintBoardEdgesCtrl->SetValue(ltmp ); } + if( s_Parameters.m_Print_Black_and_White ) + m_ModeColorOption->SetSelection( 1 ); + else + m_ModeColorOption->SetSelection( 0 ); + s_Parameters.m_PenDefaultSize = g_DrawDefaultLineThickness; AddUnitSymbol( *m_TextPenWidth, g_UserUnit ); - m_DialogPenWidth->SetValue( + m_DialogDefaultPenSize->SetValue( ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize ) ); - m_Print_Frame_Ref_Ctrl->SetValue( s_Parameters.m_Print_Sheet_Ref ); - // Create layers list BOARD* board = m_Parent->GetBoard(); int layer; @@ -135,7 +159,7 @@ void DIALOG_SVG_PRINT::initDialog( ) void DIALOG_SVG_PRINT::SetPenWidth() { - s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth ); + s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogDefaultPenSize ); if( s_Parameters.m_PenDefaultSize > WIDTH_MAX_VALUE ) { @@ -148,16 +172,17 @@ void DIALOG_SVG_PRINT::SetPenWidth() } g_DrawDefaultLineThickness = s_Parameters.m_PenDefaultSize; - m_DialogPenWidth->SetValue( + m_DialogDefaultPenSize->SetValue( ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize ) ); } -void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref ) +void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll ) { wxFileName fn; wxString msg; + s_Parameters.m_Print_Black_and_White = m_ModeColorOption->GetSelection(); SetPenWidth(); PCB_SCREEN* screen = m_Parent->GetScreen(); @@ -202,7 +227,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref ) fn.SetExt( wxT( "svg" ) ); - bool success = DrawPage( fn.GetFullPath(), screen, aPrint_Frame_Ref ); + bool success = DrawPage( fn.GetFullPath(), screen ); msg = _( "Create file " ) + fn.GetFullPath(); if( !success ) msg += _( " error" ); @@ -219,11 +244,8 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref ) * Actual print function. */ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, - BASE_SCREEN* screen, - bool aPrint_Frame_Ref ) + BASE_SCREEN* screen ) { - // const PAGE_INFO& pageInfo = m_Parent->GetPageSettings(); - LOCALE_IO toggle; int tmpzoom; wxPoint tmp_startvisu; @@ -240,24 +262,23 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, screen->SetScalingFactor( 1.0 ); - float dpi; - -#if defined( USE_PCBNEW_NANOMETRES ) - dpi = 25.4e6; -#else - dpi = 10000.0; -#endif + double dpi = IU_PER_MILS * 1000.0; EDA_DRAW_PANEL* panel = m_Parent->GetCanvas(); // paper pageSize is in internal units, either nanometers or deci-mils - wxSize pageSize = m_Parent->GetPageSizeIU(); + EDA_RECT rect; + rect.SetSize( m_Parent->GetPageSizeIU() ); + if( PageIsBoardBoundarySize() ) + { + rect = m_Parent->GetBoard()->ComputeBoundingBox(); + } - KicadSVGFileDC dc( FullFileName, pageSize.x, pageSize.y, dpi ); + KicadSVGFileDC dc( FullFileName, rect.GetOrigin(), rect.GetSize(), dpi ); - EDA_RECT tmp = *panel->GetClipBox(); + EDA_RECT tmp = *panel->GetClipBox(); GRResetPenAndBrush( &dc ); - GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? false : true ); + GRForceBlackPen( s_Parameters.m_Print_Black_and_White ); s_Parameters.m_DrillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE; // Set clip box to the max size @@ -270,7 +291,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, int bg_color = g_DrawBgColor; g_DrawBgColor = WHITE; - if( aPrint_Frame_Ref ) + if( PrintPageRef() ) m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize, IU_PER_MILS, wxT( "" ) ); @@ -292,15 +313,13 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, void DIALOG_SVG_PRINT::OnButtonPrintBoardClick( wxCommandEvent& event ) { - s_Parameters.m_Print_Sheet_Ref = m_Print_Frame_Ref_Ctrl->IsChecked(); - PrintSVGDoc( true, s_Parameters.m_Print_Sheet_Ref ); + PrintSVGDoc( true ); } void DIALOG_SVG_PRINT::OnButtonPrintSelectedClick( wxCommandEvent& event ) { - s_Parameters.m_Print_Sheet_Ref = m_Print_Frame_Ref_Ctrl->IsChecked(); - PrintSVGDoc( false, s_Parameters.m_Print_Sheet_Ref ); + PrintSVGDoc( false ); } @@ -317,6 +336,9 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) if( m_Config ) { m_Config->Write( PLOTSVGMODECOLOR_KEY, s_Parameters.m_Print_Black_and_White ); + m_Config->Write( PLOTSVGPAGESIZEOPT_KEY, m_rbSvgPageSizeOpt->GetSelection() ); + m_Config->Write( PLOTSVGPLOT_BRD_EDGE_KEY, m_PrintBoardEdgesCtrl->GetValue() ); + wxString layerKey; for( int layer = 0; layerGetSelection(); -} diff --git a/pcbnew/dialogs/dialog_SVG_print.h b/pcbnew/dialogs/dialog_SVG_print.h index 8eec0fb1af..236272e8b4 100644 --- a/pcbnew/dialogs/dialog_SVG_print.h +++ b/pcbnew/dialogs/dialog_SVG_print.h @@ -1,39 +1,46 @@ - -#ifndef _DIALOG_SVG_PRINT_H_ -#define _DIALOG_SVG_PRINT_H_ - - -#include - - -class BASE_SCREEN; -class PCB_BASE_FRAME; -class wxConfig; - - -class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base -{ -private: - PCB_BASE_FRAME* m_Parent; - wxConfig* m_Config; - long m_PrintMaskLayer; - wxCheckBox* m_BoxSelectLayer[32]; - -public: - DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent ); - ~DIALOG_SVG_PRINT() {} - -private: - void OnCloseWindow( wxCloseEvent& event ); - void initDialog( ); - void OnButtonPrintSelectedClick( wxCommandEvent& event ); - void OnButtonPrintBoardClick( wxCommandEvent& event ); - void OnButtonCancelClick( wxCommandEvent& event ); - void OnSetColorModeSelected( wxCommandEvent& event ); - void SetPenWidth(); - void PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref ); - bool DrawPage( const wxString& FullFileName, BASE_SCREEN* screen, bool aPrint_Frame_Ref ); -}; - - -#endif // _DIALOG_SVG_PRINT_H_ + +#ifndef _DIALOG_SVG_PRINT_H_ +#define _DIALOG_SVG_PRINT_H_ + + +#include + + +class BASE_SCREEN; +class PCB_BASE_FRAME; +class wxConfig; + + +class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base +{ +private: + PCB_BASE_FRAME* m_Parent; + wxConfig* m_Config; + long m_PrintMaskLayer; + wxCheckBox* m_BoxSelectLayer[32]; + +public: + DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent ); + ~DIALOG_SVG_PRINT() {} + +private: + void OnCloseWindow( wxCloseEvent& event ); + void initDialog( ); + void OnButtonPrintSelectedClick( wxCommandEvent& event ); + void OnButtonPrintBoardClick( wxCommandEvent& event ); + void OnButtonCancelClick( wxCommandEvent& event ); + void SetPenWidth(); + void PrintSVGDoc( bool aPrintAll ); + bool PageIsBoardBoundarySize() + { + return m_rbSvgPageSizeOpt->GetSelection() == 2; + } + bool PrintPageRef() + { + return m_rbSvgPageSizeOpt->GetSelection() == 0; + } + bool DrawPage( const wxString& FullFileName, BASE_SCREEN* screen ); +}; + + +#endif // _DIALOG_SVG_PRINT_H_ diff --git a/pcbnew/dialogs/dialog_SVG_print_base.cpp b/pcbnew/dialogs/dialog_SVG_print_base.cpp index 681d167d5f..21b8b5349c 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.cpp +++ b/pcbnew/dialogs/dialog_SVG_print_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 30 2011) +// C++ code generated with wxFormBuilder (version Apr 10 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -24,52 +24,56 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c m_CopperLayersBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Copper Layers:") ), wxVERTICAL ); + sbLayersSizer->Add( m_CopperLayersBoxSizer, 1, wxEXPAND, 5 ); m_TechnicalBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Technical Layers:") ), wxVERTICAL ); + sbLayersSizer->Add( m_TechnicalBoxSizer, 1, wxEXPAND, 5 ); + bUpperSizer->Add( sbLayersSizer, 1, wxEXPAND, 5 ); wxStaticBoxSizer* sbOptionsSizer; sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Print SVG options:") ), wxVERTICAL ); - m_TextPenWidth = new wxStaticText( this, wxID_ANY, _("Pen width mini"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TextPenWidth = new wxStaticText( this, wxID_ANY, _("Default pen size"), wxDefaultPosition, wxDefaultSize, 0 ); m_TextPenWidth->Wrap( -1 ); sbOptionsSizer->Add( m_TextPenWidth, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - m_DialogPenWidth = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_DialogPenWidth->SetToolTip( _("Selection of the minimum pen thickness used to draw items.") ); + m_DialogDefaultPenSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_DialogDefaultPenSize->SetToolTip( _("Selection of the pen size used to draw items which have no pen size speicfied.") ); - sbOptionsSizer->Add( m_DialogPenWidth, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + sbOptionsSizer->Add( m_DialogDefaultPenSize, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and White") }; + wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and white") }; int m_ModeColorOptionNChoices = sizeof( m_ModeColorOptionChoices ) / sizeof( wxString ); m_ModeColorOption = new wxRadioBox( this, wxID_ANY, _("Print mode"), wxDefaultPosition, wxDefaultSize, m_ModeColorOptionNChoices, m_ModeColorOptionChoices, 1, wxRA_SPECIFY_COLS ); - m_ModeColorOption->SetSelection( 0 ); + m_ModeColorOption->SetSelection( 1 ); m_ModeColorOption->SetToolTip( _("Choose if you want to draw the sheet like it appears on screen,\nor in black and white mode, better to print it when using black and white printers") ); sbOptionsSizer->Add( m_ModeColorOption, 0, wxALL|wxEXPAND, 5 ); - m_Print_Frame_Ref_Ctrl = new wxCheckBox( this, wxID_ANY, _("Print Frame Ref"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Print_Frame_Ref_Ctrl->SetValue(true); - m_Print_Frame_Ref_Ctrl->SetToolTip( _("Print (or not) the Frame references.") ); + wxString m_rbSvgPageSizeOptChoices[] = { _("Full page with frame ref"), _("Current page size"), _("Board area only") }; + int m_rbSvgPageSizeOptNChoices = sizeof( m_rbSvgPageSizeOptChoices ) / sizeof( wxString ); + m_rbSvgPageSizeOpt = new wxRadioBox( this, wxID_ANY, _("SVG Page Size"), wxDefaultPosition, wxDefaultSize, m_rbSvgPageSizeOptNChoices, m_rbSvgPageSizeOptChoices, 1, wxRA_SPECIFY_COLS ); + m_rbSvgPageSizeOpt->SetSelection( 0 ); + sbOptionsSizer->Add( m_rbSvgPageSizeOpt, 0, wxALL|wxEXPAND, 5 ); - sbOptionsSizer->Add( m_Print_Frame_Ref_Ctrl, 0, wxALL, 5 ); - - m_PrintBoardEdgesCtrl = new wxCheckBox( this, wxID_ANY, _("Print Board Edges"), wxDefaultPosition, wxDefaultSize, 0 ); - m_PrintBoardEdgesCtrl->SetValue(true); - m_PrintBoardEdgesCtrl->SetToolTip( _("Print (or not) the edges layer with others layers") ); + m_PrintBoardEdgesCtrl = new wxCheckBox( this, wxID_ANY, _("Print board edges"), wxDefaultPosition, wxDefaultSize, 0 ); + m_PrintBoardEdgesCtrl->SetToolTip( _("Print (or not) the edges layer on others layers") ); sbOptionsSizer->Add( m_PrintBoardEdgesCtrl, 0, wxALL, 5 ); + bUpperSizer->Add( sbOptionsSizer, 1, wxEXPAND, 5 ); wxBoxSizer* bButtonsSizer; bButtonsSizer = new wxBoxSizer( wxVERTICAL ); m_buttonPrintSelected = new wxButton( this, wxID_PRINT_CURRENT, _("Print Selected"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonPrintSelected->SetDefault(); bButtonsSizer->Add( m_buttonPrintSelected, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); m_buttonBoard = new wxButton( this, wxID_PRINT_BOARD, _("Print Board"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -78,8 +82,10 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Quit"), wxDefaultPosition, wxDefaultSize, 0 ); bButtonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + bUpperSizer->Add( bButtonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); + bMainSizer->Add( bUpperSizer, 0, wxEXPAND, 5 ); m_staticText1 = new wxStaticText( this, wxID_ANY, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -101,12 +107,12 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c bMainSizer->Add( m_MessagesBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + this->SetSizer( bMainSizer ); this->Layout(); // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) ); - m_ModeColorOption->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnSetColorModeSelected ), NULL, this ); m_buttonPrintSelected->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintSelectedClick ), NULL, this ); m_buttonBoard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintBoardClick ), NULL, this ); m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this ); @@ -116,7 +122,6 @@ DIALOG_SVG_PRINT_base::~DIALOG_SVG_PRINT_base() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) ); - m_ModeColorOption->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnSetColorModeSelected ), NULL, this ); m_buttonPrintSelected->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintSelectedClick ), NULL, this ); m_buttonBoard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintBoardClick ), NULL, this ); m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_SVG_print_base.fbp b/pcbnew/dialogs/dialog_SVG_print_base.fbp index 01e67ef493..9c13aec67c 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.fbp +++ b/pcbnew/dialogs/dialog_SVG_print_base.fbp @@ -1,11 +1,12 @@ - + C++ 1 source_name + 0 0 res UTF-8 @@ -19,66 +20,33 @@ . 1 + 1 1 1 0 - 1 - 1 - 1 - 1 0 - - + wxAUI_MGR_DEFAULT - - 1 - 0 - 1 1 - 0 - Dock - 0 - Left 1 impl_virtual - 1 - 0 0 wxID_ANY - - - 0 - - 0 -1,350 - 1 DIALOG_SVG_PRINT_base - 1 - - - 1 - - Resizable - - 1 507,375 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER Create SVG file - 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -195,7 +163,10 @@ 1 1 1 + + + @@ -215,8 +186,7 @@ 0 0 wxID_ANY - Pen width mini - + Default pen size 0 @@ -231,19 +201,13 @@ protected 1 - Resizable - 1 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -282,7 +246,10 @@ 1 1 1 + + + @@ -302,7 +269,6 @@ 0 0 wxID_ANY - 0 @@ -311,22 +277,20 @@ 0 1 - m_DialogPenWidth + m_DialogDefaultPenSize 1 protected 1 - Resizable - 1 0 - Selection of the minimum pen thickness used to draw items. + Selection of the pen size used to draw items which have no pen size speicfied. wxFILTER_NONE wxDefaultValidator @@ -373,13 +337,16 @@ 1 1 1 + + + 1 0 - "Color" "Black and White" + "Color" "Black and white" 1 1 @@ -395,7 +362,6 @@ 0 wxID_ANY Print mode - 1 0 @@ -411,10 +377,8 @@ protected 1 - Resizable - - 0 + 1 1 wxRA_SPECIFY_COLS @@ -445,7 +409,7 @@ - OnSetColorModeSelected + @@ -456,20 +420,23 @@ 5 - wxALL + wxALL|wxEXPAND 0 - + 1 1 1 1 + + + 1 0 - 1 + "Full page with frame ref" "Current page size" "Board area only" 1 1 @@ -484,8 +451,8 @@ 0 0 wxID_ANY - Print Frame Ref - + SVG Page Size + 1 0 @@ -493,22 +460,21 @@ 0 1 - m_Print_Frame_Ref_Ctrl + m_rbSvgPageSizeOpt 1 protected 1 - Resizable - + 0 1 - + wxRA_SPECIFY_COLS 0 - Print (or not) the Frame references. + wxFILTER_NONE wxDefaultValidator @@ -517,7 +483,6 @@ - @@ -534,6 +499,7 @@ + @@ -551,13 +517,16 @@ 1 1 1 + + + 1 0 - 1 + 0 1 1 @@ -572,8 +541,7 @@ 0 0 wxID_ANY - Print Board Edges - + Print board edges 0 @@ -588,15 +556,13 @@ protected 1 - Resizable - 1 0 - Print (or not) the edges layer with others layers + Print (or not) the edges layer on others layers wxFILTER_NONE wxDefaultValidator @@ -650,7 +616,10 @@ 1 1 1 + + + @@ -659,7 +628,7 @@ 1 1 - 0 + 1 0 Dock 0 @@ -672,7 +641,6 @@ 0 wxID_PRINT_CURRENT Print Selected - 0 @@ -687,9 +655,7 @@ protected 1 - Resizable - 1 @@ -738,7 +704,10 @@ 1 1 1 + + + @@ -760,7 +729,6 @@ 0 wxID_PRINT_BOARD Print Board - 0 @@ -775,9 +743,7 @@ protected 1 - Resizable - 1 @@ -826,7 +792,10 @@ 1 1 1 + + + @@ -848,7 +817,6 @@ 0 wxID_CANCEL Quit - 0 @@ -863,9 +831,7 @@ protected 1 - Resizable - 1 @@ -918,7 +884,10 @@ 1 1 1 + + + @@ -939,7 +908,6 @@ 0 wxID_ANY Filename: - 0 @@ -954,19 +922,13 @@ protected 1 - Resizable - 1 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -1005,7 +967,10 @@ 1 1 1 + + + @@ -1025,7 +990,6 @@ 0 0 wxID_ANY - 0 @@ -1041,9 +1005,7 @@ protected 1 - Resizable - 1 @@ -1096,7 +1058,10 @@ 1 1 1 + + + @@ -1117,7 +1082,6 @@ 0 wxID_ANY Messages: - 0 @@ -1132,19 +1096,13 @@ protected 1 - Resizable - 1 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -1183,7 +1141,10 @@ 1 1 1 + + + @@ -1203,7 +1164,6 @@ 0 0 wxID_ANY - 0 @@ -1219,9 +1179,7 @@ protected 1 - Resizable - 1 wxTE_MULTILINE diff --git a/pcbnew/dialogs/dialog_SVG_print_base.h b/pcbnew/dialogs/dialog_SVG_print_base.h index 41fddd4210..35ab66fa1a 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.h +++ b/pcbnew/dialogs/dialog_SVG_print_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 30 2011) +// C++ code generated with wxFormBuilder (version Apr 10 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -38,15 +38,15 @@ class DIALOG_SVG_PRINT_base : public wxDialog enum { wxID_PRINT_CURRENT = 1000, - wxID_PRINT_BOARD, + wxID_PRINT_BOARD }; wxStaticBoxSizer* m_CopperLayersBoxSizer; wxStaticBoxSizer* m_TechnicalBoxSizer; wxStaticText* m_TextPenWidth; - wxTextCtrl* m_DialogPenWidth; + wxTextCtrl* m_DialogDefaultPenSize; wxRadioBox* m_ModeColorOption; - wxCheckBox* m_Print_Frame_Ref_Ctrl; + wxRadioBox* m_rbSvgPageSizeOpt; wxCheckBox* m_PrintBoardEdgesCtrl; wxButton* m_buttonPrintSelected; wxButton* m_buttonBoard; @@ -58,7 +58,6 @@ class DIALOG_SVG_PRINT_base : public wxDialog // Virtual event handlers, overide them in your derived class virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); } - virtual void OnSetColorModeSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonPrintSelectedClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonPrintBoardClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 43beb1120b..d86733f7d1 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -180,6 +180,8 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent, GetScreen()->SetCurItem( NULL ); LoadSettings(); + GetBoard()->SetVisibleAlls(); + GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );