2012-09-17 17:42:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-06-16 16:07:15 +00:00
|
|
|
* Copyright (C) 1992-2019 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>
|
2020-09-23 18:58:13 +00:00
|
|
|
#include <plotters_specific.h>
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2020-11-15 16:08:31 +00:00
|
|
|
void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName )
|
2012-03-06 14:08:59 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
KIGFX::SCH_RENDER_SETTINGS renderSettings;
|
|
|
|
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
|
|
|
|
|
|
|
wxPoint plot_offset;
|
|
|
|
const double scale = 1.0;
|
2016-06-05 11:49:25 +00:00
|
|
|
|
|
|
|
// Currently, plot units are in decimil
|
|
|
|
plotter->SetViewport( plot_offset, IU_PER_MILS/10, scale, false );
|
2013-05-18 09:38:23 +00:00
|
|
|
|
|
|
|
// Init :
|
|
|
|
plotter->SetCreator( wxT( "Eeschema-SVG" ) );
|
|
|
|
|
|
|
|
if( ! plotter->OpenFile( aFullFileName ) )
|
|
|
|
{
|
|
|
|
delete plotter;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOCALE_IO toggle;
|
|
|
|
|
|
|
|
plotter->StartPlot();
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
if( m_my_part )
|
2013-05-18 09:38:23 +00:00
|
|
|
{
|
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
|
|
|
TRANSFORM temp; // Uses default transform
|
|
|
|
wxPoint plotPos;
|
|
|
|
|
2013-05-18 09:38:23 +00:00
|
|
|
plotPos.x = pageInfo.GetWidthIU() /2;
|
|
|
|
plotPos.y = pageInfo.GetHeightIU()/2;
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
m_my_part->Plot( plotter, GetUnit(), GetConvert(), plotPos, temp );
|
2013-05-18 09:38:23 +00:00
|
|
|
|
2020-12-18 17:41:56 +00:00
|
|
|
// Plot lib fields, not plotted by m_my_part->Plot():
|
2019-11-06 19:15:42 +00:00
|
|
|
m_my_part->PlotLibFields( plotter, GetUnit(), GetConvert(), plotPos, temp );
|
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
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
if( !m_my_part )
|
2010-03-19 20:15:30 +00:00
|
|
|
return;
|
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
wxSize pagesize = GetScreen()->GetPageSettings().GetSizeIU();
|
|
|
|
|
2010-03-19 20:15:30 +00:00
|
|
|
/* Plot item centered to the page
|
2020-10-31 01:27:16 +00:00
|
|
|
* In symbol_editor, the component is centered at 0,0 coordinates.
|
2010-03-19 20:15:30 +00:00
|
|
|
* So we must plot it with an offset = pagesize/2.
|
|
|
|
*/
|
|
|
|
wxPoint plot_offset;
|
2018-11-09 13:32:13 +00:00
|
|
|
plot_offset.x = pagesize.x / 2;
|
|
|
|
plot_offset.y = pagesize.y / 2;
|
2010-03-19 20:15:30 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
m_my_part->Print( aSettings, plot_offset, m_unit, m_convert, PART_DRAW_OPTIONS() );
|
2010-03-18 20:35:29 +00:00
|
|
|
}
|