KiCad PCB EDA Suite
pcad_plugin.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) 2012 Alexander Lunev <al.lunev@yahoo.com>
5  * Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors.
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 
30 #include <pcad/pcad_plugin.h>
31 #include <pcad/pcb.h>
32 #include <pcad/s_expr_loader.h>
33 
34 #include <board.h>
35 #include <locale_io.h>
36 
37 #include <cerrno>
38 #include <wx/string.h>
39 #include <wx/filename.h>
40 #include <wx/xml/xml.h>
41 
42 using namespace PCAD2KICAD;
43 
44 
46 {
47  m_board = nullptr;
48  m_props = nullptr;
49 }
50 
51 
53 {
54 }
55 
56 
57 const wxString PCAD_PLUGIN::PluginName() const
58 {
59  return wxT( "P-Cad" );
60 }
61 
62 
63 const wxString PCAD_PLUGIN::GetFileExtension() const
64 {
65  return wxT( "pcb" );
66 }
67 
68 
69 BOARD* PCAD_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
70  const PROPERTIES* aProperties, PROJECT* aProject,
71  PROGRESS_REPORTER* aProgressReporter )
72 {
73  wxXmlDocument xmlDoc;
74 
75  m_props = aProperties;
76 
77  m_board = aAppendToMe ? aAppendToMe : new BOARD();
78 
79  // Give the filename to the board if it's new
80  if( !aAppendToMe )
81  m_board->SetFileName( aFileName );
82 
83  PCB pcb( m_board );
84 
85  LOCALE_IO toggle; // toggles on, then off, the C locale.
86 
87  LoadInputFile( aFileName, &xmlDoc );
88  pcb.ParseBoard( nullptr, &xmlDoc, wxT( "PCB" ) );
89  pcb.AddToBoard();
90 
91  return m_board;
92 }
void ParseBoard(wxStatusBar *aStatusBar, wxXmlDocument *aXmlDoc, const wxString &aActualConversion)
Definition: pcb.cpp:690
Container for project specific data.
Definition: project.h:62
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
A progress reporter interface for use in multi-threaded environments.
A name/value tuple with unique names and optional values.
Definition: properties.h:33
void LoadInputFile(const wxString &aFileName, wxXmlDocument *aXmlDoc)
void AddToBoard() override
Definition: pcb.cpp:942
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
Pcbnew PLUGIN for Altium *.PcbDoc format.
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
Definition: pcad_plugin.cpp:69
const wxString GetFileExtension() const override
Returns the file extension for the PLUGIN.
Definition: pcad_plugin.cpp:63
const wxString PluginName() const override
Return a brief hard coded name for this PLUGIN.
Definition: pcad_plugin.cpp:57