2012-09-17 17:42:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-06-14 18:00:08 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-09-17 17:42:27 +00:00
|
|
|
*
|
|
|
|
* 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>
|
2021-08-18 20:38:14 +00:00
|
|
|
#include <plotters/plotters_pslike.h>
|
2024-04-05 21:35:32 +00:00
|
|
|
#include <sch_plotter.h>
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2024-04-05 21:35:32 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName, const VECTOR2I& aOffset )
|
2012-03-06 14:08:59 +00:00
|
|
|
{
|
2024-04-02 17:28:17 +00:00
|
|
|
SCH_RENDER_SETTINGS renderSettings;
|
2020-04-14 12:25:00 +00:00
|
|
|
renderSettings.LoadColors( GetColorSettings() );
|
|
|
|
renderSettings.SetDefaultPenWidth( GetRenderSettings()->GetDefaultPenWidth() );
|
|
|
|
|
2013-05-18 09:38:23 +00:00
|
|
|
const PAGE_INFO& pageInfo = GetScreen()->GetPageSettings();
|
|
|
|
|
|
|
|
SVG_PLOTTER* plotter = new SVG_PLOTTER();
|
2020-04-14 12:25:00 +00:00
|
|
|
plotter->SetRenderSettings( &renderSettings );
|
2013-05-18 09:38:23 +00:00
|
|
|
plotter->SetPageSettings( pageInfo );
|
2020-04-14 12:25:00 +00:00
|
|
|
plotter->SetColorMode( true );
|
2013-05-18 09:38:23 +00:00
|
|
|
|
2022-12-13 03:42:22 +00:00
|
|
|
VECTOR2I plot_offset;
|
2013-05-18 09:38:23 +00:00
|
|
|
const double scale = 1.0;
|
2016-06-05 11:49:25 +00:00
|
|
|
|
|
|
|
// 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 );
|
2013-05-18 09:38:23 +00:00
|
|
|
|
|
|
|
// Init :
|
|
|
|
plotter->SetCreator( wxT( "Eeschema-SVG" ) );
|
|
|
|
|
2024-04-05 21:35:32 +00:00
|
|
|
if( !plotter->OpenFile( aFullFileName ) )
|
2013-05-18 09:38:23 +00:00
|
|
|
{
|
|
|
|
delete plotter;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-04-05 21:35:32 +00:00
|
|
|
LOCALE_IO toggle;
|
|
|
|
SCH_PLOT_OPTS plotOpts;
|
2013-05-18 09:38:23 +00:00
|
|
|
|
2022-08-27 18:14:57 +00:00
|
|
|
plotter->StartPlot( wxT( "1" ) );
|
2013-05-18 09:38:23 +00:00
|
|
|
|
2021-06-15 12:31:28 +00:00
|
|
|
if( m_symbol )
|
2013-05-18 09:38:23 +00:00
|
|
|
{
|
2022-02-10 19:49:25 +00:00
|
|
|
constexpr bool background = true;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
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,
|
2024-04-08 11:26:56 +00:00
|
|
|
false );
|
2013-05-18 09:38:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
plotter->EndPlot();
|
|
|
|
delete plotter;
|
2012-03-06 14:08:59 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 13:32:13 +00:00
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings )
|
2010-03-18 20:35:29 +00:00
|
|
|
{
|
2021-06-15 12:31:28 +00:00
|
|
|
if( !m_symbol )
|
2010-03-19 20:15:30 +00:00
|
|
|
return;
|
|
|
|
|
2024-04-02 17:28:17 +00:00
|
|
|
const SCH_RENDER_SETTINGS* cfg = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
|
2023-02-19 03:40:07 +00:00
|
|
|
VECTOR2I pagesize = GetScreen()->GetPageSettings().GetSizeIU( schIUScale.IU_PER_MILS );
|
2012-01-05 08:07:11 +00:00
|
|
|
|
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 );
|
2010-03-18 20:35:29 +00:00
|
|
|
}
|