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 KiCad Developers, see CHANGELOG.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 <errno.h>
31 
32 #include <wx/string.h>
33 #include <wx/filename.h>
34 #include <wx/xml/xml.h>
35 
36 #include <pcad_plugin.h>
37 #include <s_expr_loader.h>
38 #include <pcb.h>
39 
40 #include <common.h>
41 #include <macros.h>
42 #include <fctsys.h>
43 
44 using namespace PCAD2KICAD;
45 
47 {
48  m_board = NULL;
49  m_props = NULL;
50 }
51 
52 
54 {
55 }
56 
57 
58 const wxString PCAD_PLUGIN::PluginName() const
59 {
60  return wxT( "P-Cad" );
61 }
62 
63 
64 const wxString PCAD_PLUGIN::GetFileExtension() const
65 {
66  return wxT( "pcb" );
67 }
68 
69 
70 BOARD* PCAD_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
71 {
72  wxXmlDocument xmlDoc;
73 
74  m_props = aProperties;
75 
76  m_board = aAppendToMe ? aAppendToMe : new BOARD();
77 
78  // Give the filename to the board if it's new
79  if( !aAppendToMe )
80  m_board->SetFileName( aFileName );
81 
82  PCB pcb( m_board );
83 
84  LOCALE_IO toggle; // toggles on, then off, the C locale.
85 
86  LoadInputFile( aFileName, &xmlDoc );
87  pcb.Parse( NULL, &xmlDoc, wxT( "PCB" ) );
88  pcb.AddToBoard();
89 
90  return m_board;
91 }
void Parse(wxStatusBar *aStatusBar, wxXmlDocument *aXmlDoc, wxString aActualConversion)
Definition: pcb.cpp:669
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
void LoadInputFile(wxString aFileName, wxXmlDocument *aXmlDoc)
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=NULL) override
Function Load loads information from some input file format that this PLUGIN implementation knows abo...
Definition: pcad_plugin.cpp:70
Class PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
This file contains miscellaneous commonly used macros and functions.
void AddToBoard() override
Definition: pcb.cpp:917
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
Pcbnew PLUGIN for P-Cad 200x ASCII *.pcb format.
const wxString GetFileExtension() const override
Function GetFileExtension returns the file extension for the PLUGIN.
Definition: pcad_plugin.cpp:64
The common library.
const wxString PluginName() const override
Function PluginName returns a brief hard coded name for this PLUGIN.
Definition: pcad_plugin.cpp:58