Add missing files
This commit is contained in:
parent
16064881be
commit
996bf80d1f
|
@ -0,0 +1,151 @@
|
|||
/** @file plot_schematic_DXF.cpp
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2010 Lorenzo Marcantonio
|
||||
* Copyright (C) 1992-2010 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 <fctsys.h>
|
||||
#include <plot_common.h>
|
||||
#include <worksheet.h>
|
||||
#include <class_sch_screen.h>
|
||||
#include <wxEeschemaStruct.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <dialog_plot_schematic.h>
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( )
|
||||
{
|
||||
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_parent;
|
||||
SCH_SCREEN* screen = schframe->GetScreen();
|
||||
SCH_SHEET_PATH* sheetpath;
|
||||
SCH_SHEET_PATH oldsheetpath = schframe->GetCurrentSheet();
|
||||
wxString plotFileName;
|
||||
wxPoint plot_offset;
|
||||
|
||||
/* When printing all pages, the printed page is not the current page.
|
||||
* In complex hierarchies, we must setup references and others parameters
|
||||
* in the printed SCH_SCREEN
|
||||
* because in complex hierarchies a SCH_SCREEN (a schematic drawings)
|
||||
* is shared between many sheets
|
||||
*/
|
||||
SCH_SHEET_LIST SheetList( NULL );
|
||||
|
||||
sheetpath = SheetList.GetFirst();
|
||||
SCH_SHEET_PATH list;
|
||||
|
||||
while( true )
|
||||
{
|
||||
if( m_select_PlotAll )
|
||||
{
|
||||
if( sheetpath == NULL )
|
||||
break;
|
||||
|
||||
list.Clear();
|
||||
|
||||
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
|
||||
{
|
||||
schframe->SetCurrentSheet( list );
|
||||
schframe->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
schframe->SetSheetNumberAndCount();
|
||||
screen = schframe->GetCurrentSheet().LastScreen();
|
||||
}
|
||||
else // Should not happen
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sheetpath = SheetList.GetNext();
|
||||
}
|
||||
|
||||
plot_offset.x = 0;
|
||||
plot_offset.y = 0;
|
||||
|
||||
plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT(".")
|
||||
+ DXF_PLOTTER::GetDefaultFileExtension();
|
||||
|
||||
PlotOneSheetDXF( plotFileName, screen, plot_offset, 1 );
|
||||
|
||||
if( !m_select_PlotAll )
|
||||
break;
|
||||
}
|
||||
|
||||
schframe->SetCurrentSheet( oldsheetpath );
|
||||
schframe->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
schframe->SetSheetNumberAndCount();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF( const wxString& FileName,
|
||||
SCH_SCREEN* screen,
|
||||
wxPoint plot_offset,
|
||||
double scale )
|
||||
{
|
||||
|
||||
|
||||
wxString msg;
|
||||
FILE* output_file = wxFopen( FileName, wxT( "wt" ) );
|
||||
|
||||
if( output_file == NULL )
|
||||
{
|
||||
msg = wxT( "\n** " );
|
||||
msg += _( "Unable to create " ) + FileName + wxT( " **\n" );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
return;
|
||||
}
|
||||
|
||||
msg.Printf( _( "Plot: %s " ), GetChars( FileName ) );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
|
||||
LOCALE_IO toggle;
|
||||
|
||||
DXF_PLOTTER* plotter = new DXF_PLOTTER();
|
||||
|
||||
const PAGE_INFO& pageInfo = screen->GetPageSettings();
|
||||
plotter->SetPageSettings( pageInfo );
|
||||
plotter->SetColorMode( getModeColor() );
|
||||
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false );
|
||||
|
||||
// Init :
|
||||
plotter->SetCreator( wxT( "Eeschema-DXF" ) );
|
||||
plotter->SetFilename( FileName );
|
||||
plotter->StartPlot( output_file );
|
||||
|
||||
if( getPlotFrameRef() )
|
||||
{
|
||||
plotter->SetColor( BLACK );
|
||||
PlotWorkSheet( plotter, m_parent->GetTitleBlock(),
|
||||
m_parent->GetPageSettings(),
|
||||
screen->m_ScreenNumber, screen->m_NumberOfScreens,
|
||||
m_parent->GetScreenDesc(),
|
||||
screen->GetFileName() );
|
||||
}
|
||||
|
||||
screen->Plot( plotter );
|
||||
|
||||
// finish
|
||||
plotter->EndPlot();
|
||||
delete plotter;
|
||||
|
||||
m_MessagesBox->AppendText( wxT( "Ok\n" ) );
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
/** @file plot_schematic_HPGL.cpp
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2010 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr
|
||||
* Copyright (C) 1992-2010 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 <fctsys.h>
|
||||
#include <plot_common.h>
|
||||
#include <worksheet.h>
|
||||
#include <class_sch_screen.h>
|
||||
#include <wxEeschemaStruct.h>
|
||||
#include <base_units.h>
|
||||
#include <sch_sheet_path.h>
|
||||
|
||||
#include <dialog_plot_schematic.h>
|
||||
|
||||
|
||||
enum HPGL_PAGEZ_T {
|
||||
PAGE_DEFAULT = 0,
|
||||
HPGL_PAGE_SIZE_A4,
|
||||
HPGL_PAGE_SIZE_A3,
|
||||
HPGL_PAGE_SIZE_A2,
|
||||
HPGL_PAGE_SIZE_A1,
|
||||
HPGL_PAGE_SIZE_A0,
|
||||
HPGL_PAGE_SIZE_A,
|
||||
HPGL_PAGE_SIZE_B,
|
||||
HPGL_PAGE_SIZE_C,
|
||||
HPGL_PAGE_SIZE_D,
|
||||
HPGL_PAGE_SIZE_E,
|
||||
};
|
||||
|
||||
|
||||
static const wxChar* plot_sheet_list( int aSize )
|
||||
{
|
||||
const wxChar* ret;
|
||||
|
||||
switch( aSize )
|
||||
{
|
||||
default:
|
||||
case PAGE_DEFAULT:
|
||||
ret = NULL; break;
|
||||
|
||||
case HPGL_PAGE_SIZE_A4:
|
||||
ret = wxT( "A4" ); break;
|
||||
|
||||
case HPGL_PAGE_SIZE_A3:
|
||||
ret = wxT( "A3" ); break;
|
||||
|
||||
case HPGL_PAGE_SIZE_A2:
|
||||
ret = wxT( "A2" ); break;
|
||||
|
||||
case HPGL_PAGE_SIZE_A1:
|
||||
ret = wxT( "A1" ); break;
|
||||
|
||||
case HPGL_PAGE_SIZE_A0:
|
||||
ret = wxT( "A0" ); break;
|
||||
|
||||
case HPGL_PAGE_SIZE_A:
|
||||
ret = wxT( "A" ); break;
|
||||
|
||||
case HPGL_PAGE_SIZE_B:
|
||||
ret = wxT( "B" ); break;
|
||||
|
||||
case HPGL_PAGE_SIZE_C:
|
||||
ret = wxT( "C" ); break;
|
||||
|
||||
case HPGL_PAGE_SIZE_D:
|
||||
ret = wxT( "D" ); break;
|
||||
|
||||
case HPGL_PAGE_SIZE_E:
|
||||
ret = wxT( "E" ); break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::SetHPGLPenWidth()
|
||||
{
|
||||
g_HPGL_Pen_Descr.m_Pen_Diam = ReturnValueFromTextCtrl( *m_penHPGLWidthCtrl );
|
||||
|
||||
if( g_HPGL_Pen_Descr.m_Pen_Diam > Millimeter2iu( 2 ) )
|
||||
g_HPGL_Pen_Descr.m_Pen_Diam = Millimeter2iu( 2 );
|
||||
|
||||
if( g_HPGL_Pen_Descr.m_Pen_Diam < Millimeter2iu( 0.01 ) )
|
||||
g_HPGL_Pen_Descr.m_Pen_Diam = Millimeter2iu( 0.01 );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll )
|
||||
{
|
||||
wxString plotFileName;
|
||||
SCH_SCREEN* screen = m_parent->GetScreen();
|
||||
SCH_SHEET_PATH* sheetpath;
|
||||
SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet();
|
||||
|
||||
/* When printing all pages, the printed page is not the current page.
|
||||
* In complex hierarchies, we must setup references and other parameters
|
||||
* in the printed SCH_SCREEN
|
||||
* because in complex hierarchies a SCH_SCREEN (a schematic drawings)
|
||||
* is shared between many sheets
|
||||
*/
|
||||
SCH_SHEET_LIST SheetList( NULL );
|
||||
|
||||
sheetpath = SheetList.GetFirst();
|
||||
SCH_SHEET_PATH list;
|
||||
|
||||
SetHPGLPenWidth();
|
||||
|
||||
while( true )
|
||||
{
|
||||
if( aPlotAll )
|
||||
{
|
||||
if( sheetpath == NULL )
|
||||
break;
|
||||
|
||||
list.Clear();
|
||||
|
||||
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
|
||||
{
|
||||
m_parent->SetCurrentSheet( list );
|
||||
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
m_parent->SetSheetNumberAndCount();
|
||||
|
||||
screen = m_parent->GetCurrentSheet().LastScreen();
|
||||
|
||||
if( !screen ) // LastScreen() may return NULL
|
||||
screen = m_parent->GetScreen();
|
||||
}
|
||||
else // Should not happen
|
||||
return;
|
||||
|
||||
sheetpath = SheetList.GetNext();
|
||||
}
|
||||
|
||||
const PAGE_INFO& curPage = screen->GetPageSettings();
|
||||
|
||||
PAGE_INFO plotPage = curPage;
|
||||
|
||||
// if plotting on a page size other than curPage
|
||||
if( m_HPGLPaperSizeOption->GetSelection() != PAGE_DEFAULT )
|
||||
plotPage.SetType( plot_sheet_list( m_HPGLPaperSizeOption->GetSelection() ) );
|
||||
|
||||
// Calculation of conversion scales.
|
||||
double plot_scale = (double) plotPage.GetWidthMils() / curPage.GetWidthMils();
|
||||
|
||||
// Calculate offsets
|
||||
wxPoint plotOffset;
|
||||
|
||||
if( GetPlotOriginCenter() )
|
||||
{
|
||||
plotOffset.x = -plotPage.GetWidthIU() / 2;
|
||||
plotOffset.y = -plotPage.GetHeightIU() / 2;
|
||||
}
|
||||
|
||||
plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." )
|
||||
+ HPGL_PLOTTER::GetDefaultFileExtension();
|
||||
|
||||
LOCALE_IO toggle;
|
||||
|
||||
Plot_1_Page_HPGL( plotFileName, screen, plotPage, plotOffset, plot_scale );
|
||||
|
||||
if( !aPlotAll )
|
||||
break;
|
||||
}
|
||||
|
||||
m_parent->SetCurrentSheet( oldsheetpath );
|
||||
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
m_parent->SetSheetNumberAndCount();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL( const wxString& FileName,
|
||||
SCH_SCREEN* screen,
|
||||
const PAGE_INFO& pageInfo,
|
||||
wxPoint& offset,
|
||||
double plot_scale )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
FILE* output_file = wxFopen( FileName, wxT( "wt" ) );
|
||||
|
||||
if( output_file == NULL )
|
||||
{
|
||||
msg = wxT( "\n** " );
|
||||
msg += _( "Unable to create " ) + FileName + wxT( " **\n" );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
return;
|
||||
}
|
||||
|
||||
LOCALE_IO toggle;
|
||||
|
||||
msg.Printf( _( "Plot: %s " ), FileName.GetData() );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
|
||||
HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
|
||||
|
||||
plotter->SetPageSettings( pageInfo );
|
||||
plotter->SetViewport( offset, IU_PER_DECIMILS, plot_scale, false );
|
||||
|
||||
// Init :
|
||||
plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
|
||||
plotter->SetFilename( FileName );
|
||||
plotter->SetPenSpeed( g_HPGL_Pen_Descr.m_Pen_Speed );
|
||||
plotter->SetPenNumber( g_HPGL_Pen_Descr.m_Pen_Num );
|
||||
plotter->SetPenDiameter( g_HPGL_Pen_Descr.m_Pen_Diam );
|
||||
plotter->SetPenOverlap( g_HPGL_Pen_Descr.m_Pen_Diam / 2 );
|
||||
plotter->StartPlot( output_file );
|
||||
|
||||
plotter->SetColor( BLACK );
|
||||
|
||||
if( getPlotFrameRef() )
|
||||
PlotWorkSheet( plotter, m_parent->GetTitleBlock(),
|
||||
m_parent->GetPageSettings(),
|
||||
screen->m_ScreenNumber, screen->m_NumberOfScreens,
|
||||
m_parent->GetScreenDesc(),
|
||||
screen->GetFileName() );
|
||||
|
||||
screen->Plot( plotter );
|
||||
|
||||
plotter->EndPlot();
|
||||
delete plotter;
|
||||
|
||||
m_MessagesBox->AppendText( wxT( "Ok\n" ) );
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
/** @file plot_schematic_PDF.cpp
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2010 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr
|
||||
* Copyright (C) 1992-2010 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 <fctsys.h>
|
||||
#include <worksheet.h>
|
||||
#include <plot_common.h>
|
||||
#include <class_sch_screen.h>
|
||||
#include <wxEeschemaStruct.h>
|
||||
#include <base_units.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <dialog_plot_schematic.h>
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::createPDFFile()
|
||||
{
|
||||
SCH_SCREEN* screen = m_parent->GetScreen();
|
||||
SCH_SHEET_PATH* sheetpath;
|
||||
SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet(); // sheetpath is saved here
|
||||
wxPoint plot_offset;
|
||||
|
||||
/* When printing all pages, the printed page is not the current page. In
|
||||
* complex hierarchies, we must update component references and others
|
||||
* parameters in the given printed SCH_SCREEN, accordint to the sheet path
|
||||
* because in complex hierarchies a SCH_SCREEN (a drawing ) is shared
|
||||
* between many sheets and component references depend on the actual sheet
|
||||
* path used
|
||||
*/
|
||||
SCH_SHEET_LIST SheetList( NULL );
|
||||
|
||||
sheetpath = SheetList.GetFirst();
|
||||
|
||||
// Allocate the plotter and set the job level parameter
|
||||
PDF_PLOTTER* plotter = new PDF_PLOTTER();
|
||||
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
|
||||
plotter->SetColorMode( getModeColor() );
|
||||
plotter->SetCreator( wxT( "Eeschema-PDF" ) );
|
||||
|
||||
// First page handling is different
|
||||
bool first_page = true;
|
||||
|
||||
do
|
||||
{
|
||||
// Step over the schematic hierarchy
|
||||
if( m_select_PlotAll )
|
||||
{
|
||||
SCH_SHEET_PATH list;
|
||||
|
||||
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
|
||||
{
|
||||
m_parent->SetCurrentSheet( list );
|
||||
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
m_parent->SetSheetNumberAndCount();
|
||||
screen = m_parent->GetCurrentSheet().LastScreen();
|
||||
}
|
||||
else // Should not happen
|
||||
wxASSERT( 0 );
|
||||
|
||||
sheetpath = SheetList.GetNext();
|
||||
}
|
||||
|
||||
if( first_page )
|
||||
{
|
||||
wxString msg;
|
||||
wxString plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." )
|
||||
+ PDF_PLOTTER::GetDefaultFileExtension();
|
||||
msg.Printf( _( "Plot: %s " ), GetChars( plotFileName ) );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
|
||||
FILE* output_file = wxFopen( plotFileName, wxT( "wb" ) );
|
||||
|
||||
if( output_file == NULL )
|
||||
{
|
||||
msg = wxT( "\n** " );
|
||||
msg += _( "Unable to create " ) + plotFileName + wxT( " **\n" );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
wxBell();
|
||||
return;
|
||||
}
|
||||
|
||||
// Open the plotter and do the first page
|
||||
SetLocaleTo_C_standard();
|
||||
plotter->SetFilename( plotFileName );
|
||||
setupPlotPage( plotter, screen );
|
||||
plotter->StartPlot( output_file );
|
||||
first_page = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For the following pages you need to close the (finished) page,
|
||||
* reconfigure, and then start a new one */
|
||||
plotter->ClosePage();
|
||||
setupPlotPage( plotter, screen );
|
||||
plotter->StartPage();
|
||||
}
|
||||
|
||||
plotOneSheetPDF( plotter, screen );
|
||||
} while( m_select_PlotAll && sheetpath );
|
||||
|
||||
// Everything done, close the plot and restore the environment
|
||||
plotter->EndPlot();
|
||||
delete plotter;
|
||||
SetLocaleTo_Default();
|
||||
|
||||
// Restore the previous sheet
|
||||
m_parent->SetCurrentSheet( oldsheetpath );
|
||||
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
m_parent->SetSheetNumberAndCount();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF( PLOTTER* plotter, SCH_SCREEN* screen )
|
||||
{
|
||||
if( getPlotFrameRef() )
|
||||
{
|
||||
plotter->SetColor( BLACK );
|
||||
PlotWorkSheet( plotter, m_parent->GetTitleBlock(),
|
||||
m_parent->GetPageSettings(),
|
||||
screen->m_ScreenNumber, screen->m_NumberOfScreens,
|
||||
m_parent->GetScreenDesc(),
|
||||
screen->GetFileName() );
|
||||
}
|
||||
|
||||
screen->Plot( plotter );
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/** @file plot_schematic_PS.cpp
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2010 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 <fctsys.h>
|
||||
#include <plot_common.h>
|
||||
#include <class_sch_screen.h>
|
||||
#include <wxEeschemaStruct.h>
|
||||
#include <base_units.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <dialog_plot_schematic.h>
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::createPSFile()
|
||||
{
|
||||
SCH_SCREEN* screen = m_parent->GetScreen();
|
||||
SCH_SHEET_PATH* sheetpath;
|
||||
SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet(); // sheetpath is saved here
|
||||
wxString plotFileName;
|
||||
PAGE_INFO actualPage; // page size selected in schematic
|
||||
PAGE_INFO plotPage; // page size selected to plot
|
||||
|
||||
/* When printing all pages, the printed page is not the current page.
|
||||
* In complex hierarchies, we must update component references
|
||||
* and others parameters in the given printed SCH_SCREEN, accordint to the sheet path
|
||||
* because in complex hierarchies a SCH_SCREEN (a drawing )
|
||||
* is shared between many sheets and component references depend on the actual sheet path used
|
||||
*/
|
||||
SCH_SHEET_LIST SheetList( NULL );
|
||||
|
||||
sheetpath = SheetList.GetFirst();
|
||||
SCH_SHEET_PATH list;
|
||||
|
||||
while( true )
|
||||
{
|
||||
if( m_select_PlotAll )
|
||||
{
|
||||
if( sheetpath == NULL )
|
||||
break;
|
||||
|
||||
list.Clear();
|
||||
|
||||
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
|
||||
{
|
||||
m_parent->SetCurrentSheet( list );
|
||||
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
m_parent->SetSheetNumberAndCount();
|
||||
screen = m_parent->GetCurrentSheet().LastScreen();
|
||||
}
|
||||
else // Should not happen
|
||||
return;
|
||||
|
||||
sheetpath = SheetList.GetNext();
|
||||
}
|
||||
|
||||
actualPage = screen->GetPageSettings();
|
||||
|
||||
switch( m_pageSizeSelect )
|
||||
{
|
||||
case PAGE_SIZE_A:
|
||||
plotPage.SetType( wxT( "A" ) );
|
||||
plotPage.SetPortrait( actualPage.IsPortrait() );
|
||||
break;
|
||||
|
||||
case PAGE_SIZE_A4:
|
||||
plotPage.SetType( wxT( "A4" ) );
|
||||
plotPage.SetPortrait( actualPage.IsPortrait() );
|
||||
break;
|
||||
|
||||
case PAGE_SIZE_AUTO:
|
||||
default:
|
||||
plotPage = actualPage;
|
||||
break;
|
||||
}
|
||||
|
||||
double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
|
||||
double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
|
||||
|
||||
double scale = MIN( scalex, scaley );
|
||||
|
||||
wxPoint plot_offset;
|
||||
plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." )
|
||||
+ PS_PLOTTER::GetDefaultFileExtension();
|
||||
|
||||
plotOneSheetPS( plotFileName, screen, plotPage, plot_offset, scale );
|
||||
|
||||
if( !m_select_PlotAll )
|
||||
break;
|
||||
}
|
||||
|
||||
m_parent->SetCurrentSheet( oldsheetpath );
|
||||
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
m_parent->SetSheetNumberAndCount();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& FileName,
|
||||
SCH_SCREEN* screen,
|
||||
const PAGE_INFO& pageInfo,
|
||||
wxPoint plot_offset,
|
||||
double scale )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
FILE* output_file = wxFopen( FileName, wxT( "wt" ) );
|
||||
|
||||
if( output_file == NULL )
|
||||
{
|
||||
msg = wxT( "\n** " );
|
||||
msg += _( "Unable to create " ) + FileName + wxT( " **\n" );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
return;
|
||||
}
|
||||
|
||||
msg.Printf( _( "Plot: %s " ), GetChars( FileName ) );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
|
||||
SetLocaleTo_C_standard();
|
||||
PS_PLOTTER* plotter = new PS_PLOTTER();
|
||||
plotter->SetPageSettings( pageInfo );
|
||||
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
|
||||
plotter->SetColorMode( getModeColor() );
|
||||
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false );
|
||||
|
||||
// Init :
|
||||
plotter->SetCreator( wxT( "Eeschema-PS" ) );
|
||||
plotter->SetFilename( FileName );
|
||||
plotter->StartPlot( output_file );
|
||||
|
||||
if( getPlotFrameRef() )
|
||||
{
|
||||
plotter->SetColor( BLACK );
|
||||
PlotWorkSheet( plotter, m_parent->GetTitleBlock(),
|
||||
m_parent->GetPageSettings(),
|
||||
screen->m_ScreenNumber, screen->m_NumberOfScreens,
|
||||
m_parent->GetScreenDesc(),
|
||||
screen->GetFileName() );
|
||||
}
|
||||
|
||||
screen->Plot( plotter );
|
||||
|
||||
plotter->EndPlot();
|
||||
delete plotter;
|
||||
SetLocaleTo_Default();
|
||||
|
||||
m_MessagesBox->AppendText( wxT( "Ok\n" ) );
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* 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 plot_schematic_SVG.cpp
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <appl_wxstruct.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <class_sch_screen.h>
|
||||
#include <wxEeschemaStruct.h>
|
||||
#include <dcsvg.h>
|
||||
#include <base_units.h>
|
||||
#include <libeditframe.h>
|
||||
#include <sch_sheet_path.h>
|
||||
|
||||
#include <dialog_plot_schematic.h>
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef )
|
||||
{
|
||||
wxString msg;
|
||||
wxFileName fn;
|
||||
|
||||
if( aPrintAll )
|
||||
{
|
||||
SCH_SHEET_PATH* sheetpath;
|
||||
SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet();
|
||||
SCH_SHEET_LIST SheetList( NULL );
|
||||
sheetpath = SheetList.GetFirst();
|
||||
SCH_SHEET_PATH list;
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
if( sheetpath == NULL )
|
||||
break;
|
||||
|
||||
SCH_SCREEN* screen;
|
||||
list.Clear();
|
||||
|
||||
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
|
||||
{
|
||||
m_parent->SetCurrentSheet( list );
|
||||
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
m_parent->SetSheetNumberAndCount();
|
||||
screen = m_parent->GetCurrentSheet().LastScreen();
|
||||
}
|
||||
else // Should not happen
|
||||
return;
|
||||
|
||||
sheetpath = SheetList.GetNext();
|
||||
|
||||
fn = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( ".svg" );
|
||||
|
||||
bool success = plotOneSheetSVG( m_parent, fn.GetFullPath(), screen,
|
||||
getModeColor() ? false : true,
|
||||
aPrintFrameRef );
|
||||
msg = _( "Create file " ) + fn.GetFullPath();
|
||||
|
||||
if( !success )
|
||||
msg += _( " error" );
|
||||
|
||||
msg += wxT( "\n" );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
}
|
||||
|
||||
m_parent->SetCurrentSheet( oldsheetpath );
|
||||
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
m_parent->SetSheetNumberAndCount();
|
||||
}
|
||||
else // Print current sheet
|
||||
{
|
||||
SCH_SCREEN* screen = (SCH_SCREEN*) m_parent->GetScreen();
|
||||
|
||||
fn = screen->GetFileName();
|
||||
fn.SetExt( wxT( "svg" ) );
|
||||
fn.MakeAbsolute();
|
||||
|
||||
bool success = plotOneSheetSVG( m_parent, fn.GetFullPath(), screen,
|
||||
getModeColor() ? false : true,
|
||||
aPrintFrameRef );
|
||||
msg = _( "Create file " ) + fn.GetFullPath();
|
||||
|
||||
if( !success )
|
||||
msg += _( " error" );
|
||||
|
||||
msg += wxT( "\n" );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( EDA_DRAW_FRAME* frame,
|
||||
const wxString& FullFileName,
|
||||
SCH_SCREEN* aScreen,
|
||||
bool aPrintBlackAndWhite,
|
||||
bool aPrintFrameRef )
|
||||
{
|
||||
int tmpzoom;
|
||||
wxPoint tmp_startvisu;
|
||||
wxSize sheetSize; // Sheet size in internal units
|
||||
wxPoint old_org;
|
||||
bool success = true;
|
||||
|
||||
tmp_startvisu = aScreen->m_StartVisu;
|
||||
tmpzoom = aScreen->GetZoom();
|
||||
old_org = aScreen->m_DrawOrg;
|
||||
aScreen->m_DrawOrg.x = aScreen->m_DrawOrg.y = 0;
|
||||
aScreen->m_StartVisu.x = aScreen->m_StartVisu.y = 0;
|
||||
|
||||
sheetSize = aScreen->GetPageSettings().GetSizeIU();
|
||||
aScreen->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 ) ) );
|
||||
|
||||
aScreen->m_IsPrinting = true;
|
||||
|
||||
if( frame->IsType( SCHEMATIC_FRAME_TYPE ) )
|
||||
aScreen->Draw( panel, &dc, GR_COPY );
|
||||
|
||||
if( frame->IsType( LIBEDITOR_FRAME_TYPE ) )
|
||||
( (LIB_EDIT_FRAME*) frame )->RedrawComponent( &dc,
|
||||
wxPoint( sheetSize.x / 2,
|
||||
sheetSize.y / 2 ) );
|
||||
|
||||
if( aPrintFrameRef )
|
||||
frame->TraceWorkSheet( &dc, aScreen, g_DrawDefaultLineThickness,
|
||||
IU_PER_MILS, frame->GetScreenDesc() );
|
||||
|
||||
aScreen->m_IsPrinting = false;
|
||||
panel->SetClipBox( tmp );
|
||||
|
||||
GRForceBlackPen( false );
|
||||
|
||||
aScreen->m_StartVisu = tmp_startvisu;
|
||||
aScreen->m_DrawOrg = old_org;
|
||||
aScreen->SetZoom( tmpzoom );
|
||||
|
||||
return success;
|
||||
}
|
Loading…
Reference in New Issue