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.

159 lines
6.0 KiB

  1. /** @file dialog_plot_schematic.h
  2. */
  3. /*
  4. * This program source code file is part of KiCad, a free EDA CAD application.
  5. *
  6. * Copyright (C) 1992-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
  7. * Copyright (C) 1992-2010 Lorenzo Marcantonio
  8. * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
  9. *
  10. * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version 2
  15. * of the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, you may find one here:
  24. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  25. * or you may search the http://www.gnu.org website for the version 2 license,
  26. * or you may write to the Free Software Foundation, Inc.,
  27. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  28. */
  29. #include <fctsys.h>
  30. #include <plotter.h>
  31. #include <sch_screen.h>
  32. #include <sch_edit_frame.h>
  33. #include <dialog_plot_schematic_base.h>
  34. #include <reporter.h>
  35. #include <widgets/unit_binder.h>
  36. enum PageFormatReq {
  37. PAGE_SIZE_AUTO,
  38. PAGE_SIZE_A4,
  39. PAGE_SIZE_A
  40. };
  41. class DIALOG_PLOT_SCHEMATIC : public DIALOG_PLOT_SCHEMATIC_BASE
  42. {
  43. private:
  44. SCH_EDIT_FRAME* m_parent;
  45. wxConfigBase* m_config;
  46. bool m_configChanged; // true if a project config param has changed
  47. PLOT_FORMAT m_plotFormat;
  48. static int m_pageSizeSelect; // Static to keep last option for some format
  49. static int m_HPGLPaperSizeSelect; // for HPGL format only: last selected paper size
  50. double m_HPGLPenSize; // for HPGL format only: pen size
  51. UNIT_BINDER m_defaultLineWidth;
  52. UNIT_BINDER m_penWidth;
  53. public:
  54. // / Constructors
  55. DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent );
  56. bool PrjConfigChanged() { return m_configChanged; } // return true if the prj config was modified
  57. // and therefore should be saved
  58. private:
  59. void OnPageSizeSelected( wxCommandEvent& event ) override;
  60. void OnPlotCurrent( wxCommandEvent& event ) override;
  61. void OnPlotAll( wxCommandEvent& event ) override;
  62. void OnUpdateUI( wxUpdateUIEvent& event ) override;
  63. void initDlg();
  64. // common
  65. void getPlotOptions();
  66. bool getModeColor()
  67. { return m_ModeColorOption->GetSelection() == 0; }
  68. void setModeColor( bool aColor )
  69. { m_ModeColorOption->SetSelection( aColor ? 0 : 1 ); }
  70. /**
  71. * Set the m_outputDirectoryName variable to the selected directory from directory dialog.
  72. */
  73. void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) override;
  74. PLOT_FORMAT GetPlotFileFormat();
  75. bool getPlotFrameRef() { return m_PlotFrameRefOpt->GetValue(); }
  76. void setPlotFrameRef( bool aPlot) {m_PlotFrameRefOpt->SetValue( aPlot ); }
  77. void PlotSchematic( bool aPlotAll );
  78. // PDF
  79. void createPDFFile( bool aPlotAll, bool aPlotFrameRef );
  80. void plotOneSheetPDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen, bool aPlotFrameRef);
  81. void setupPlotPagePDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen );
  82. /**
  83. * Everything done, close the plot and restore the environment
  84. * @param aPlotter the plotter to close and destroy
  85. * @param aOldsheetpath the stored old sheet path for the current sheet before the plot started
  86. */
  87. void restoreEnvironment( PDF_PLOTTER* aPlotter, SCH_SHEET_PATH& aOldsheetpath );
  88. // DXF
  89. void CreateDXFFile( bool aPlotAll, bool aPlotFrameRef );
  90. bool PlotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen,
  91. wxPoint aPlot0ffset, double aScale, bool aPlotFrameRef );
  92. // HPGL
  93. bool GetPlotOriginCenter()
  94. {
  95. return m_plotOriginOpt->GetSelection() == 1;
  96. }
  97. void SetPlotOriginCenter( bool aCenter )
  98. {
  99. m_plotOriginOpt->SetSelection( aCenter ? 1 : 0 );
  100. }
  101. void createHPGLFile( bool aPlotAll, bool aPlotFrameRef );
  102. void SetHPGLPenWidth();
  103. bool Plot_1_Page_HPGL( const wxString& aFileName, SCH_SCREEN* aScreen,
  104. const PAGE_INFO& aPageInfo,
  105. wxPoint aPlot0ffset, double aScale, bool aPlotFrameRef );
  106. // PS
  107. void createPSFile( bool aPlotAll, bool aPlotFrameRef );
  108. bool plotOneSheetPS( const wxString& aFileName, SCH_SCREEN* aScreen,
  109. const PAGE_INFO& aPageInfo,
  110. wxPoint aPlot0ffset, double aScale, bool aPlotFrameRef );
  111. // SVG
  112. void createSVGFile( bool aPlotAll, bool aPlotFrameRef );
  113. /**
  114. * Create a file name with an absolute path name
  115. * @param aOutputDirectoryName the directory name to plot, this can be a relative name of the
  116. * current project directory or an absolute directory name.
  117. * @param aPlotFileName the name for the file to plot without a path
  118. * @param aExtension the extension for the file to plot
  119. * @param aReporter a point to a REPORTER object use to show messages (can be NULL)
  120. * @return the created file name
  121. * @throw IO_ERROR on file I/O errors
  122. */
  123. wxFileName createPlotFileName( wxTextCtrl* aOutputDirectoryName,
  124. wxString& aPlotFileName,
  125. wxString& aExtension, REPORTER* aReporter = NULL );
  126. public:
  127. // This function is static because it is called by libedit
  128. // outside a dialog. This is the reason we need aFrame as parameter
  129. static bool plotOneSheetSVG( EDA_DRAW_FRAME* aFrame, const wxString& aFileName,
  130. SCH_SCREEN* aScreen,
  131. bool aPlotBlackAndWhite, bool aPlotFrameRef );
  132. };