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.

196 lines
5.5 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file gbr_layout.h
  26. * @brief Class CLASS_GBR_LAYOUT to handle info to draw/print loaded Gerber images
  27. * and page frame reference
  28. */
  29. #ifndef GBR_LAYOUT_H
  30. #define GBR_LAYOUT_H
  31. #include <dlist.h>
  32. #include <colors_design_settings.h>
  33. #include <common.h> // PAGE_INFO
  34. #include <gerbview.h> // GERBER_DRAWLAYERS_COUNT
  35. #include <title_block.h>
  36. #include <gerber_draw_item.h>
  37. #include <gbr_display_options.h>
  38. #include <gr_basic.h>
  39. #include <eda_rect.h>
  40. class GERBER_FILE_IMAGE_LIST;
  41. /**
  42. * Class GBR_LAYOUT
  43. * holds list of GERBER_DRAW_ITEM currently loaded.
  44. */
  45. class GBR_LAYOUT : public EDA_ITEM
  46. {
  47. private:
  48. mutable EDA_RECT m_BoundingBox;
  49. TITLE_BLOCK m_titles;
  50. wxPoint m_originAxisPosition;
  51. std::vector<int> m_printLayersList; // When printing: the list of graphic layers Id to print
  52. public:
  53. GBR_LAYOUT();
  54. ~GBR_LAYOUT();
  55. wxString GetClass() const override
  56. {
  57. return wxT( "GBR_LAYOUT" );
  58. }
  59. // Accessor to the GERBER_FILE_IMAGE_LIST,
  60. // which handles the list of gerber files (and drill files) images loaded
  61. GERBER_FILE_IMAGE_LIST* GetImagesList() const;
  62. const wxPoint& GetAuxOrigin() const
  63. {
  64. return m_originAxisPosition;
  65. }
  66. void SetAuxOrigin( const wxPoint& aPosition )
  67. {
  68. m_originAxisPosition = aPosition;
  69. }
  70. TITLE_BLOCK& GetTitleBlock()
  71. {
  72. return m_titles;
  73. }
  74. void SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
  75. {
  76. m_titles = aTitleBlock;
  77. }
  78. /**
  79. * Function ComputeBoundingBox
  80. * calculates the bounding box containing all Gerber items.
  81. * @return EDA_RECT - the full item list bounding box
  82. */
  83. EDA_RECT ComputeBoundingBox() const;
  84. /**
  85. * Function GetBoundingBox
  86. */
  87. const EDA_RECT GetBoundingBox() const override
  88. {
  89. return ComputeBoundingBox();
  90. }
  91. void SetBoundingBox( const EDA_RECT& aBox ) { m_BoundingBox = aBox; }
  92. /**
  93. * Function Draw.
  94. * Redraw the CLASS_GBR_LAYOUT items but not cursors, axis or grid.
  95. * @param aPanel = the draw canvas
  96. * @param aDC = the current device context
  97. * @param aDrawMode = GR_COPY, GR_OR ... (not always used)
  98. * @param aOffset = an draw offset value
  99. * @param aDisplayOptions = a GBR_DISPLAY_OPTIONS for draw/print display opts
  100. */
  101. void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
  102. GR_DRAWMODE aDrawMode, const wxPoint& aOffset,
  103. GBR_DISPLAY_OPTIONS* aDisplayOptions );
  104. /**
  105. * Function DrawItemsDCodeID
  106. * Draw the DCode value (if exists) corresponding to gerber item
  107. * (polygons do not have a DCode)
  108. * @param aPanel = the draw canvas
  109. * @param aDC = the current device context
  110. * @param aDrawMode = GR_COPY, GR_OR ...
  111. * @param aDrawColor = the color of dcode texts
  112. */
  113. void DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
  114. GR_DRAWMODE aDrawMode, COLOR4D aDrawColor );
  115. /**
  116. * Function SetPrintableLayers
  117. * Set the list of printable graphic layers
  118. * @param aLayerList = the new list (std::vector) of printable layer id
  119. */
  120. void SetPrintableLayers( const std::vector<int>& aLayerList )
  121. {
  122. m_printLayersList = aLayerList;
  123. }
  124. /**
  125. * Function GetPrintableLayers
  126. * @return the list of printable layers
  127. */
  128. std::vector<int> GetPrintableLayers()
  129. {
  130. return m_printLayersList;
  131. }
  132. /**
  133. * Function ClearPrintableLayers
  134. * Clear the list of graphic layers to print
  135. */
  136. void ClearPrintableLayers()
  137. {
  138. m_printLayersList.clear();
  139. }
  140. /**
  141. * Function AddLayerToPrintableList
  142. * Add a layer to the list of graphic layers to print
  143. * @param aLayer = the id of the graphic layer.
  144. */
  145. void AddLayerToPrintableList( int aLayer)
  146. {
  147. m_printLayersList.push_back( aLayer );
  148. }
  149. /**
  150. * Function IsLayerPrintable
  151. * tests whether a given layer is visible
  152. * @param aLayer = The layer to be tested
  153. * @return bool - true if the layer is in print list.
  154. */
  155. bool IsLayerPrintable( int aLayer ) const;
  156. ///> @copydoc EDA_ITEM::Visit()
  157. SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
  158. #if defined(DEBUG)
  159. void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  160. #endif
  161. };
  162. #endif // #ifndef GBR_LAYOUT_H