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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2018-01-30 08:56:43 +00:00
|
|
|
#include <sch_screen.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <lib_edit_frame.h>
|
2019-11-06 19:15:42 +00:00
|
|
|
#include <class_libentry.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_library.h>
|
2019-06-16 16:07:15 +00:00
|
|
|
#include <plotter.h>
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2013-05-18 09:38:23 +00:00
|
|
|
void LIB_EDIT_FRAME::SVG_PlotComponent( const wxString& aFullFileName )
|
2012-03-06 14:08:59 +00:00
|
|
|
{
|
2018-11-02 08:23:16 +00:00
|
|
|
const bool plotColor = true;
|
2013-05-18 09:38:23 +00:00
|
|
|
const PAGE_INFO& pageInfo = GetScreen()->GetPageSettings();
|
|
|
|
|
|
|
|
SVG_PLOTTER* plotter = new SVG_PLOTTER();
|
|
|
|
plotter->SetPageSettings( pageInfo );
|
|
|
|
plotter->SetDefaultLineWidth( GetDefaultLineThickness() );
|
2018-11-02 08:23:16 +00:00
|
|
|
plotter->SetColorMode( plotColor );
|
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
|
|
|
|
|
|
|
// Plot lib fields, not plotted by m_component->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
|
|
|
|
2019-06-01 19:48:01 +00:00
|
|
|
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC )
|
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
|
|
|
|
* In libedit, the component is centered at 0,0 coordinates.
|
|
|
|
* 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
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
m_my_part->Print( aDC, plot_offset, m_unit, m_convert, PART_DRAW_OPTIONS::Default() );
|
2010-03-18 20:35:29 +00:00
|
|
|
}
|