kicad/eeschema/symbol_editor/symbol_editor_plotter.cpp

91 lines
3.1 KiB
C++
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2021 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
*/
2020-04-14 12:25:00 +00:00
#include <sch_painter.h>
2020-10-31 01:27:16 +00:00
#include <symbol_edit_frame.h>
2020-10-24 01:38:50 +00:00
#include <locale_io.h>
#include <plotters/plotters_pslike.h>
2024-04-05 21:35:32 +00:00
#include <sch_plotter.h>
2024-04-05 21:35:32 +00:00
void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName, const VECTOR2I& aOffset )
{
SCH_RENDER_SETTINGS renderSettings;
2020-04-14 12:25:00 +00:00
renderSettings.LoadColors( GetColorSettings() );
renderSettings.SetDefaultPenWidth( GetRenderSettings()->GetDefaultPenWidth() );
const PAGE_INFO& pageInfo = GetScreen()->GetPageSettings();
SVG_PLOTTER* plotter = new SVG_PLOTTER();
2020-04-14 12:25:00 +00:00
plotter->SetRenderSettings( &renderSettings );
plotter->SetPageSettings( pageInfo );
2020-04-14 12:25:00 +00:00
plotter->SetColorMode( true );
VECTOR2I plot_offset;
const double scale = 1.0;
// Currently, plot units are in decimil
2022-09-16 23:25:07 +00:00
plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS/10, scale, false );
// Init :
plotter->SetCreator( wxT( "Eeschema-SVG" ) );
2024-04-05 21:35:32 +00:00
if( !plotter->OpenFile( aFullFileName ) )
{
delete plotter;
return;
}
2024-04-05 21:35:32 +00:00
LOCALE_IO toggle;
SCH_PLOT_OPTS plotOpts;
plotter->StartPlot( wxT( "1" ) );
if( m_symbol )
{
constexpr bool background = true;
2024-04-05 21:35:32 +00:00
m_symbol->Plot( plotter, background, plotOpts, GetUnit(), GetBodyStyle(), aOffset, false );
m_symbol->Plot( plotter, !background, plotOpts, GetUnit(), GetBodyStyle(), aOffset, false );
m_symbol->PlotFields( plotter, !background, plotOpts, GetUnit(), GetBodyStyle(), aOffset,
false, GetShowInvisibleFields() );
}
plotter->EndPlot();
delete plotter;
}
2020-12-20 18:18:54 +00:00
void SYMBOL_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings )
{
if( !m_symbol )
return;
const SCH_RENDER_SETTINGS* cfg = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
VECTOR2I pagesize = GetScreen()->GetPageSettings().GetSizeIU( schIUScale.IU_PER_MILS );
2024-04-05 21:35:32 +00:00
// Print item centered to the page.
m_symbol->PrintBackground( cfg, m_unit, m_bodyStyle, pagesize / 2, false );
m_symbol->Print( cfg, m_unit, m_bodyStyle, pagesize / 2, false, false );
}