You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.2 KiB

  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. /**
  25. * @file pcad_plugin.cpp
  26. * @brief Pcbnew PLUGIN for P-Cad 200x ASCII *.pcb format.
  27. */
  28. #include <errno.h>
  29. #include <wx/string.h>
  30. #include <wx/filename.h>
  31. #include <wx/xml/xml.h>
  32. #include <pcad_plugin.h>
  33. #include <s_expr_loader.h>
  34. #include <pcb.h>
  35. #include <common.h>
  36. #include <macros.h>
  37. #include <fctsys.h>
  38. using namespace PCAD2KICAD;
  39. PCAD_PLUGIN::PCAD_PLUGIN()
  40. {
  41. m_board = NULL;
  42. m_props = NULL;
  43. }
  44. PCAD_PLUGIN::~PCAD_PLUGIN()
  45. {
  46. }
  47. const wxString PCAD_PLUGIN::PluginName() const
  48. {
  49. return wxT( "P-Cad" );
  50. }
  51. const wxString PCAD_PLUGIN::GetFileExtension() const
  52. {
  53. return wxT( "pcb" );
  54. }
  55. BOARD* PCAD_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
  56. {
  57. wxXmlDocument xmlDoc;
  58. m_props = aProperties;
  59. m_board = aAppendToMe ? aAppendToMe : new BOARD();
  60. // Give the filename to the board if it's new
  61. if( !aAppendToMe )
  62. m_board->SetFileName( aFileName );
  63. PCB pcb( m_board );
  64. LOCALE_IO toggle; // toggles on, then off, the C locale.
  65. LoadInputFile( aFileName, &xmlDoc );
  66. pcb.Parse( NULL, &xmlDoc, wxT( "PCB" ) );
  67. pcb.AddToBoard();
  68. return m_board;
  69. }