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.

139 lines
4.2 KiB

4 years ago
4 years ago
4 years ago
4 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Lorenzo Marcantonio, <l.marcantonio@logossrl.com>
  5. * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  6. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file pcbnew/pcbplot.h
  27. */
  28. #ifndef PLOTCONTROLLER_H_
  29. #define PLOTCONTROLLER_H_
  30. #include <pcb_plot_params.h>
  31. #include <layer_ids.h>
  32. class PLOTTER;
  33. class BOARD;
  34. class LSEQ;
  35. /**
  36. * Batch plotter state object. Keeps the plot options and handles multiple
  37. * plot requests. Useful in Python scripts.
  38. */
  39. class PLOT_CONTROLLER
  40. {
  41. public:
  42. /** Batch plotter constructor, nothing interesting here */
  43. PLOT_CONTROLLER( BOARD *aBoard );
  44. /**
  45. * Ensure that the last plot is closed.
  46. */
  47. ~PLOT_CONTROLLER();
  48. /**
  49. * Accessor to the plot parameters and options
  50. */
  51. PCB_PLOT_PARAMS& GetPlotOptions() { return m_plotOptions; }
  52. void SetLayer( int aLayer ) { m_plotLayer = aLayer; }
  53. int GetLayer() { return m_plotLayer; }
  54. /**
  55. * @return true if a plotter is initialized and can be used.
  56. */
  57. bool IsPlotOpen() const { return m_plotter != nullptr; }
  58. /**
  59. * Close the current plot, nothing happens if it isn't open.
  60. */
  61. void ClosePlot();
  62. /** Open a new plotfile; works as a factory for plotter objects/
  63. *
  64. * @param aSuffix is a string added to the base filename (derived from
  65. * the board filename) to identify the plot file.
  66. * @param aFormat is the plot file format identifier.
  67. * @param aSheetName is the text to be displayed in the title block that replaces ${SHEETNAME}
  68. * @param aSheetPath is the text to be displayed in the title block that replaces ${SHEETPATH}
  69. */
  70. bool OpenPlotfile( const wxString& aSuffix, PLOT_FORMAT aFormat,
  71. const wxString& aSheetName = wxEmptyString,
  72. const wxString& aSheetPath = wxEmptyString );
  73. /**
  74. * Plot a single layer on the current plotfile m_plotLayer is the layer to plot.
  75. */
  76. bool PlotLayer();
  77. /**
  78. * Plot a sequence of board layer IDs in the given order.
  79. *
  80. * @param aLayerSequence is the sequence of layer IDs to plot.
  81. *
  82. * @return true if the layers plotted correctly othewise false.
  83. */
  84. bool PlotLayers( const LSEQ& aLayerSequence );
  85. /**
  86. * @return the current plot full filename, set by OpenPlotfile
  87. */
  88. const wxString GetPlotFileName() { return m_plotFile.GetFullPath(); }
  89. /**
  90. * @return the current plot full filename, set by OpenPlotfile
  91. */
  92. const wxString GetPlotDirName() { return m_plotFile.GetPathWithSep(); }
  93. /**
  94. * Choose color or bland and white plot mode.
  95. *
  96. * @param aColorMode set to true to activate the plot color mode or false for black and white.
  97. */
  98. void SetColorMode( bool aColorMode );
  99. /**
  100. * @return true if the current plot color mode is color or false if the current plot color
  101. * mode is black and white.
  102. */
  103. bool GetColorMode();
  104. PLOTTER* GetPlotter() { return m_plotter; }
  105. private:
  106. int m_plotLayer;
  107. PCB_PLOT_PARAMS m_plotOptions;
  108. /// This is the plotter object; it starts NULL and become instantiated when a plotfile is
  109. // requested
  110. PLOTTER* m_plotter;
  111. BOARD* m_board;
  112. wxFileName m_plotFile;
  113. };
  114. #endif