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.

120 lines
3.2 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. /**
  24. * @file kicadpcb.h
  25. * declares the main PCB object
  26. */
  27. #ifndef KICADPCB_H
  28. #define KICADPCB_H
  29. #include <wx/string.h>
  30. #include <string>
  31. #include <vector>
  32. #include "3d_resolver.h"
  33. #include "base.h"
  34. #ifdef SUPPORTS_IGES
  35. #undef SUPPORTS_IGES
  36. #endif
  37. extern void ReportMessage( const wxString& aMessage );
  38. namespace SEXPR
  39. {
  40. class SEXPR;
  41. }
  42. class KICADMODULE;
  43. class KICADCURVE;
  44. class PCBMODEL;
  45. class KICADPCB
  46. {
  47. private:
  48. S3D_RESOLVER m_resolver;
  49. wxString m_filename;
  50. PCBMODEL* m_pcb_model;
  51. DOUBLET m_origin;
  52. DOUBLET m_gridOrigin;
  53. DOUBLET m_drillOrigin;
  54. bool m_useGridOrigin;
  55. bool m_useDrillOrigin;
  56. // set to TRUE if the origin was actually parsed
  57. bool m_hasGridOrigin;
  58. bool m_hasDrillOrigin;
  59. // minimum distance between points to treat them as separate entities (mm)
  60. double m_minDistance;
  61. // the names of layers in use, and the internal layer ID
  62. std::map<std::string, int> m_layersNames;
  63. // PCB parameters/entities
  64. double m_thickness;
  65. std::vector< KICADMODULE* > m_modules;
  66. std::vector< KICADCURVE* > m_curves;
  67. bool parsePCB( SEXPR::SEXPR* data );
  68. bool parseGeneral( SEXPR::SEXPR* data );
  69. bool parseSetup( SEXPR::SEXPR* data );
  70. bool parseLayers( SEXPR::SEXPR* data );
  71. bool parseModule( SEXPR::SEXPR* data );
  72. bool parseCurve( SEXPR::SEXPR* data, CURVE_TYPE aCurveType );
  73. public:
  74. KICADPCB();
  75. virtual ~KICADPCB();
  76. int GetLayerId( std::string& aLayerName );
  77. void SetOrigin( double aXOrigin, double aYOrigin )
  78. {
  79. m_origin.x = aXOrigin;
  80. m_origin.y = aYOrigin;
  81. }
  82. void UseGridOrigin( bool aUseOrigin )
  83. {
  84. m_useGridOrigin = aUseOrigin;
  85. }
  86. void UseDrillOrigin( bool aUseOrigin )
  87. {
  88. m_useDrillOrigin = aUseOrigin;
  89. }
  90. void SetMinDistance( double aDistance )
  91. {
  92. m_minDistance = aDistance;
  93. }
  94. bool ReadFile( const wxString& aFileName );
  95. bool ComposePCB( bool aComposeVirtual = true );
  96. bool WriteSTEP( const wxString& aFileName );
  97. #ifdef SUPPORTS_IGES
  98. bool WriteIGES( const wxString& aFileName );
  99. #endif
  100. };
  101. #endif // KICADPCB_H