KiCad PCB EDA Suite
graphics_importer.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KICAD, a free EDA CAD application.
3  *
4  * Copyright (C) 2016 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include "graphics_importer.h"
26 #include "graphics_import_plugin.h"
27 
29 {
30  m_millimeterToIu = 1.0;
32  m_scale = 1.0;
33  m_originalWidth = 0.0;
34  m_originalHeight = 0.0;
35 }
36 
37 
38 bool GRAPHICS_IMPORTER::Load( const wxString &aFileName )
39 {
40  m_items.clear();
41 
42  if( !m_plugin )
43  {
44  wxASSERT_MSG( false, "Plugin has to be set before load." );
45  return false;
46  }
47 
48  m_plugin->SetImporter( this );
49 
50  return m_plugin->Load( aFileName );
51 }
52 
53 bool GRAPHICS_IMPORTER::Import( double aScale )
54 {
55  if( !m_plugin )
56  {
57  wxASSERT_MSG( false, "Plugin has to be set before import." );
58  return false;
59  }
60 
61  SetScale( aScale );
62 
63  m_plugin->SetImporter( this );
64 
65  return m_plugin->Import();
66 }
static constexpr unsigned int DEFAULT_LINE_WIDTH_DFX
Default line thickness (in mm)
bool Load(const wxString &aFileName)
Load file and get its basic data.
void SetScale(double aScale)
Set the scale factor affecting the imported shapes.
double m_millimeterToIu
factor to convert millimeters to Internal Units
double m_lineWidth
Default line thickness for the imported graphics
double m_originalWidth
Total image width
bool Import(double aScale=1.0)
Imports shapes from loaded file.
std::unique_ptr< GRAPHICS_IMPORT_PLUGIN > m_plugin
Plugin used to load a file
double m_scale
Scale factor applied to the imported graphics.
double m_originalHeight
Total image Height;
std::list< std::unique_ptr< EDA_ITEM > > m_items
List of imported items