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.

108 lines
4.5 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015-2022 KiCad Developers, see AUTHORS.txt for contributors.
  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. #ifndef EXPORT_FOOTPRINTS_PLACEFILE_H
  24. #define EXPORT_FOOTPRINTS_PLACEFILE_H
  25. #include <board.h>
  26. #include <footprint.h>
  27. /**
  28. * The ASCII format of the kicad place file is:
  29. * ### Module positions - created on 04/12/2012 15:24:24 ###
  30. * ### Printed by Pcbnew version pcbnew (2012-11-30 BZR 3828)-testing
  31. * ## Unit = inches, Angle = deg.
  32. * or
  33. * ## Unit = mm, Angle = deg.
  34. * ## Side : top
  35. * or
  36. * ## Side : bottom
  37. * or
  38. * ## Side : all
  39. * # Ref Val Package PosX PosY Rot Side
  40. * C123 0,1uF/50V SM0603 1.6024 -2.6280 180.0 Front
  41. * C124 0,1uF/50V SM0603 1.6063 -2.7579 180.0 Front
  42. * C125 0,1uF/50V SM0603 1.6010 -2.8310 180.0 Front
  43. * ## End
  44. */
  45. class PLACE_FILE_EXPORTER
  46. {
  47. public:
  48. /** Create a PLACE_FILE_EXPORTER
  49. * @param aBoard is the board
  50. * @param aUnitsMM is the unit option: true foo mm, false for inches
  51. * @param aOnlySMD true to force only footprints flagged smd to be in the list
  52. * @param aExcludeAllTH true to include only footprints with no TH pads no matter
  53. * the footprint flag
  54. * @param aExcludeDNP true to exclude footprints flagged DNP
  55. * @param aTopSide true to generate top side info
  56. * @param aBottomSide true to generate bottom side info
  57. * @param aFormatCSV true to generate a csv format info, false to generate a ascii info
  58. * @param aNegateBottomX true to negate X coordinates for bottom side of the placement file
  59. * @param aUseAuxOrigin true to use auxiliary axis as an origin for the position data
  60. */
  61. PLACE_FILE_EXPORTER( BOARD* aBoard, bool aUnitsMM, bool aOnlySMD, bool aExcludeAllTH,
  62. bool aExcludeDNP, bool aTopSide, bool aBottomSide, bool aFormatCSV,
  63. bool aUseAuxOrigin, bool aNegateBottomX );
  64. /**
  65. * build a string filled with the position data
  66. */
  67. std::string GenPositionData();
  68. /**
  69. * build a string filled with the pad report data
  70. * This report does not used options aForceSmdItems,aTopSide, aBottomSide
  71. * and aFormatCSV.
  72. * All footprints and their pads on board are reported.
  73. */
  74. std::string GenReportData();
  75. /** @return the footprint count found on board by GenPositionData()
  76. * must be called only after GenPositionData() is run
  77. */
  78. int GetFootprintCount() { return m_fpCount; }
  79. // Use standard board side name. do not translate them,
  80. // they are keywords in place file
  81. static std::string GetFrontSideName() { return std::string( "top" ); }
  82. static std::string GetBackSideName() { return std::string( "bottom" ); }
  83. private:
  84. BOARD* m_board;
  85. bool m_unitsMM; // true for mm, false for inches
  86. bool m_onlySMD; // Include only SMD components
  87. bool m_excludeDNP; // Exclude DNP components
  88. bool m_excludeAllTH; // Exclude any footprints with through-hole pads
  89. int m_side; // PCB_BACK_SIDE, PCB_FRONT_SIDE, PCB_BOTH_SIDES
  90. bool m_formatCSV; // true for csv format, false for ascii (utf8) format
  91. bool m_negateBottomX; // true to negate X coordinate on bottom side
  92. int m_fpCount; // Number of footprints in list, for info
  93. VECTOR2I m_place_Offset; // Offset for coordinates in generated data.
  94. };
  95. #endif // #ifndef EXPORT_FOOTPRINTS_PLACEFILE_H