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.

129 lines
3.8 KiB

  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 (C) 1992-2015 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 <layers_id_colors_and_visibility.h>
  32. class PLOTTER;
  33. class BOARD;
  34. /**
  35. * Batch plotter state object. Keeps the plot options and handles multiple
  36. * plot requests
  37. * Especially 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. /** Batch plotter destructor, ensures that the last plot is closed
  45. */
  46. ~PLOT_CONTROLLER();
  47. /**
  48. * Accessor to the plot parameters and options
  49. */
  50. PCB_PLOT_PARAMS& GetPlotOptions() { return m_plotOptions; }
  51. void SetLayer( LAYER_NUM aLayer ) { m_plotLayer = aLayer; }
  52. LAYER_NUM GetLayer() { return m_plotLayer; }
  53. /**
  54. * @return true if a plotter is initialized and can be used
  55. */
  56. bool IsPlotOpen() const { return m_plotter != NULL; }
  57. /** Close the current plot, nothing happens if it isn't open
  58. */
  59. void ClosePlot();
  60. /** Open a new plotfile; works as a factory for plotter objects
  61. * @param aSuffix is a string added to the base filename (derived from
  62. * the board filename) to identify the plot file
  63. * @param aFormat is the plot file format identifier
  64. * @param aSheetDesc
  65. */
  66. bool OpenPlotfile( const wxString &aSuffix, PlotFormat aFormat,
  67. const wxString &aSheetDesc );
  68. /** Plot a single layer on the current plotfile
  69. * m_plotLayer is the layer to plot
  70. */
  71. bool PlotLayer();
  72. /**
  73. * @return the current plot full filename, set by OpenPlotfile
  74. */
  75. const wxString GetPlotFileName() { return m_plotFile.GetFullPath(); }
  76. /**
  77. * @return the current plot full filename, set by OpenPlotfile
  78. */
  79. const wxString GetPlotDirName() { return m_plotFile.GetPathWithSep(); }
  80. /**
  81. * Plotters can plot in Black and White mode or Color mode
  82. * SetColorMode activate/de-actiavte the Color mode.
  83. * @param aColorMode = true to activate the plot color mode
  84. */
  85. void SetColorMode( bool );
  86. /**
  87. * @return true if the current plot color mode is Color,
  88. * false if the current plot color mode is Black and White
  89. */
  90. bool GetColorMode();
  91. private:
  92. /// the layer to plot
  93. LAYER_NUM m_plotLayer;
  94. /// Option bank
  95. PCB_PLOT_PARAMS m_plotOptions;
  96. /// This is the plotter object; it starts NULL and become instantiated
  97. /// when a plotfile is requested
  98. PLOTTER* m_plotter;
  99. /// The board we're plotting
  100. BOARD* m_board;
  101. /// The current plot filename, set by OpenPlotfile
  102. wxFileName m_plotFile;
  103. };
  104. #endif