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.

216 lines
8.0 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2023 Mark Roszko <mark.roszko@gmail.com>
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software: you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation, either version 3 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <jobs/job_export_sch_plot.h>
  21. #include <jobs/job_registry.h>
  22. #include <i18n_utility.h>
  23. NLOHMANN_JSON_SERIALIZE_ENUM( JOB_PAGE_SIZE,
  24. {
  25. { JOB_PAGE_SIZE::PAGE_SIZE_AUTO, "auto" },
  26. { JOB_PAGE_SIZE::PAGE_SIZE_A4, "A4" },
  27. { JOB_PAGE_SIZE::PAGE_SIZE_A, "A" },
  28. } )
  29. NLOHMANN_JSON_SERIALIZE_ENUM( JOB_HPGL_PAGE_SIZE,
  30. {
  31. { JOB_HPGL_PAGE_SIZE::DEFAULT, "default" },
  32. { JOB_HPGL_PAGE_SIZE::SIZE_A5, "A5" },
  33. { JOB_HPGL_PAGE_SIZE::SIZE_A4, "A4" },
  34. { JOB_HPGL_PAGE_SIZE::SIZE_A3, "A3" },
  35. { JOB_HPGL_PAGE_SIZE::SIZE_A2, "A2" },
  36. { JOB_HPGL_PAGE_SIZE::SIZE_A1, "A1" },
  37. { JOB_HPGL_PAGE_SIZE::SIZE_A0, "A0" },
  38. { JOB_HPGL_PAGE_SIZE::SIZE_A, "A" },
  39. { JOB_HPGL_PAGE_SIZE::SIZE_B, "B" },
  40. { JOB_HPGL_PAGE_SIZE::SIZE_C, "C" },
  41. { JOB_HPGL_PAGE_SIZE::SIZE_D, "D" },
  42. { JOB_HPGL_PAGE_SIZE::SIZE_E, "E" },
  43. } )
  44. NLOHMANN_JSON_SERIALIZE_ENUM( JOB_HPGL_PLOT_ORIGIN_AND_UNITS,
  45. {
  46. { JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT, "default" },
  47. { JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER, "A5" },
  48. { JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE, "A4" },
  49. { JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT, "A3" },
  50. } )
  51. NLOHMANN_JSON_SERIALIZE_ENUM( SCH_PLOT_FORMAT,
  52. {
  53. { SCH_PLOT_FORMAT::HPGL, "hpgl" },
  54. { SCH_PLOT_FORMAT::PDF, "pdf" },
  55. { SCH_PLOT_FORMAT::GERBER, "gerber" },
  56. { SCH_PLOT_FORMAT::POST, "post" },
  57. { SCH_PLOT_FORMAT::SVG, "svg" },
  58. { SCH_PLOT_FORMAT::DXF, "dxf" },
  59. } )
  60. JOB_EXPORT_SCH_PLOT::JOB_EXPORT_SCH_PLOT() :
  61. JOB( "plot", false ),
  62. m_plotFormat( SCH_PLOT_FORMAT::PDF ),
  63. m_filename(),
  64. m_drawingSheet(),
  65. m_plotAll( true ),
  66. m_plotDrawingSheet( true ),
  67. m_blackAndWhite( false ),
  68. m_pageSizeSelect( JOB_PAGE_SIZE::PAGE_SIZE_AUTO ),
  69. m_useBackgroundColor( true ),
  70. m_HPGLPenSize( 1.0 ),
  71. m_HPGLPaperSizeSelect( JOB_HPGL_PAGE_SIZE::DEFAULT ),
  72. m_PDFPropertyPopups( true ),
  73. m_PDFHierarchicalLinks( true ),
  74. m_PDFMetadata( true ),
  75. m_theme(),
  76. m_HPGLPlotOrigin( JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT )
  77. {
  78. m_params.emplace_back(
  79. new JOB_PARAM<SCH_PLOT_FORMAT>( "format", &m_plotFormat, m_plotFormat ) );
  80. m_params.emplace_back(
  81. new JOB_PARAM<wxString>( "drawing_sheet", &m_drawingSheet, m_drawingSheet ) );
  82. m_params.emplace_back( new JOB_PARAM<bool>( "plot_all", &m_plotAll, m_plotAll ) );
  83. m_params.emplace_back(
  84. new JOB_PARAM<bool>( "plot_drawing_sheet", &m_plotDrawingSheet, m_plotDrawingSheet ) );
  85. m_params.emplace_back(
  86. new JOB_PARAM<bool>( "black_and_white", &m_blackAndWhite, m_blackAndWhite ) );
  87. m_params.emplace_back(
  88. new JOB_PARAM<JOB_PAGE_SIZE>( "page_size", &m_pageSizeSelect, m_pageSizeSelect ) );
  89. m_params.emplace_back( new JOB_PARAM<bool>( "use_background_color", &m_useBackgroundColor,
  90. m_useBackgroundColor ) );
  91. m_params.emplace_back(
  92. new JOB_PARAM<double>( "hpgl_pen_size", &m_HPGLPenSize, m_HPGLPenSize ) );
  93. m_params.emplace_back( new JOB_PARAM<JOB_HPGL_PAGE_SIZE>(
  94. "hpgl_page_size", &m_HPGLPaperSizeSelect, m_HPGLPaperSizeSelect ) );
  95. m_params.emplace_back( new JOB_PARAM<bool>( "pdf_property_popups", &m_PDFPropertyPopups,
  96. m_PDFPropertyPopups ) );
  97. m_params.emplace_back( new JOB_PARAM<bool>( "pdf_hierarchical_links", &m_PDFHierarchicalLinks,
  98. m_PDFHierarchicalLinks ) );
  99. m_params.emplace_back( new JOB_PARAM<bool>( "pdf_metadata", &m_PDFMetadata, m_PDFMetadata ) );
  100. m_params.emplace_back( new JOB_PARAM<wxString>( "color_theme", &m_theme, m_theme ) );
  101. m_params.emplace_back( new JOB_PARAM<JOB_HPGL_PLOT_ORIGIN_AND_UNITS>(
  102. "hpgl_plot_origin", &m_HPGLPlotOrigin, m_HPGLPlotOrigin ) );
  103. }
  104. JOB_EXPORT_SCH_PLOT_PDF::JOB_EXPORT_SCH_PLOT_PDF() :
  105. JOB_EXPORT_SCH_PLOT()
  106. {
  107. m_plotFormat = SCH_PLOT_FORMAT::PDF;
  108. }
  109. wxString JOB_EXPORT_SCH_PLOT_PDF::GetDefaultDescription() const
  110. {
  111. return _( "Export PDF" );
  112. }
  113. wxString JOB_EXPORT_SCH_PLOT_PDF::GetOptionsDialogTitle() const
  114. {
  115. return _( "Export PDF Job Options" );
  116. }
  117. JOB_EXPORT_SCH_PLOT_DXF ::JOB_EXPORT_SCH_PLOT_DXF () :
  118. JOB_EXPORT_SCH_PLOT()
  119. {
  120. m_plotFormat = SCH_PLOT_FORMAT::DXF;
  121. }
  122. wxString JOB_EXPORT_SCH_PLOT_DXF::GetDefaultDescription() const
  123. {
  124. return _( "Export DXF" );
  125. }
  126. wxString JOB_EXPORT_SCH_PLOT_DXF::GetOptionsDialogTitle() const
  127. {
  128. return _( "Export DXF Job Options" );
  129. }
  130. JOB_EXPORT_SCH_PLOT_SVG::JOB_EXPORT_SCH_PLOT_SVG() :
  131. JOB_EXPORT_SCH_PLOT()
  132. {
  133. m_plotFormat = SCH_PLOT_FORMAT::SVG;
  134. }
  135. wxString JOB_EXPORT_SCH_PLOT_SVG::GetDefaultDescription() const
  136. {
  137. return _( "Export SVG" );
  138. }
  139. wxString JOB_EXPORT_SCH_PLOT_SVG::GetOptionsDialogTitle() const
  140. {
  141. return _( "Export SVG Job Options" );
  142. }
  143. JOB_EXPORT_SCH_PLOT_PS::JOB_EXPORT_SCH_PLOT_PS() :
  144. JOB_EXPORT_SCH_PLOT()
  145. {
  146. m_plotFormat = SCH_PLOT_FORMAT::POST;
  147. }
  148. wxString JOB_EXPORT_SCH_PLOT_PS::GetDefaultDescription() const
  149. {
  150. return _( "Export Postscript" );
  151. }
  152. wxString JOB_EXPORT_SCH_PLOT_PS::GetOptionsDialogTitle() const
  153. {
  154. return _( "Export Postscript Job Options" );
  155. }
  156. JOB_EXPORT_SCH_PLOT_HPGL::JOB_EXPORT_SCH_PLOT_HPGL() :
  157. JOB_EXPORT_SCH_PLOT()
  158. {
  159. m_plotFormat = SCH_PLOT_FORMAT::HPGL;
  160. }
  161. wxString JOB_EXPORT_SCH_PLOT_HPGL::GetDefaultDescription() const
  162. {
  163. return _( "Export HPGL" );
  164. }
  165. wxString JOB_EXPORT_SCH_PLOT_HPGL::GetOptionsDialogTitle() const
  166. {
  167. return _( "Export HPGL Job Options" );
  168. }
  169. REGISTER_JOB( sch_export_plot_svg, _HKI( "Schematic: Export SVG" ), KIWAY::FACE_SCH,
  170. JOB_EXPORT_SCH_PLOT_SVG );
  171. REGISTER_JOB( sch_export_plot_hpgl, _HKI( "Schematic: Export HPGL" ), KIWAY::FACE_SCH,
  172. JOB_EXPORT_SCH_PLOT_HPGL );
  173. REGISTER_JOB( sch_export_plot_ps, _HKI( "Schematic: Export Postscript" ), KIWAY::FACE_SCH,
  174. JOB_EXPORT_SCH_PLOT_PS );
  175. REGISTER_JOB( sch_export_plot_dxf, _HKI( "Schematic: Export DXF" ), KIWAY::FACE_SCH,
  176. JOB_EXPORT_SCH_PLOT_DXF );
  177. REGISTER_JOB( sch_export_plot_pdf, _HKI( "Schematic: Export PDF" ), KIWAY::FACE_SCH,
  178. JOB_EXPORT_SCH_PLOT_PDF );