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.

174 lines
6.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2010-2018 KiCad Developers, see cAUTHORS.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. /* pcb_layer_widget.h : header for the layers manager */
  27. /************************************************************/
  28. #ifndef PCB_LAYER_WIDGET_H
  29. #define PCB_LAYER_WIDGET_H
  30. #include <layer_widget.h>
  31. /**
  32. * Class PCB_LAYER_WIDGET
  33. * is here to implement the abstract functions of LAYER_WIDGET so they
  34. * may be tied into the PCB_EDIT_FRAME's data and so we can add a popup
  35. * menu which is specific to PCBNEW's needs.
  36. */
  37. class PCB_LAYER_WIDGET : public LAYER_WIDGET
  38. {
  39. public:
  40. /**
  41. * Constructor
  42. * @param aParent is the parent window
  43. * @param aFocusOwner is the window that should be sent the focus after
  44. * @param aFpEditorMode false for the board editor (default), true for fp editor
  45. * when true, some options or layers which cannot be used in editor mode are not
  46. * displayed
  47. */
  48. PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwner, bool aFpEditorMode = false );
  49. void ReFill();
  50. /**
  51. * Function ReFillRender
  52. * rebuilds Render for instance after the config is read
  53. */
  54. void ReFillRender();
  55. /**
  56. * Function SyncLayerVisibilities
  57. * updates each "Layer" checkbox in this layer widget according
  58. * to each layer's current visibility determined by IsLayerVisible(), and is
  59. * helpful immediately after loading a BOARD which may have state information in it.
  60. */
  61. void SyncLayerVisibilities();
  62. /**
  63. * Function SyncLayerAlphaIndicators
  64. * updates each "Layer"s alpha indicator to show if the board is currently being
  65. * rendered with more transparency or less.
  66. */
  67. void SyncLayerAlphaIndicators();
  68. /**
  69. * Function SetLayersManagerTabsText
  70. * Update the layer manager tabs labels
  71. * Useful when changing Language or to set labels to a non default value
  72. */
  73. void SetLayersManagerTabsText();
  74. //-----<implement LAYER_WIDGET abstract callback functions>-----------
  75. void OnLayerColorChange( int aLayer, COLOR4D aColor ) override;
  76. bool OnLayerSelect( int aLayer ) override;
  77. void OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) override;
  78. void OnLayerRightClick( wxMenu& aMenu ) override;
  79. void OnRenderColorChange( int aId, COLOR4D aColor ) override;
  80. void OnRenderEnable( int aId, bool isEnabled ) override;
  81. //-----</implement LAYER_WIDGET abstract callback functions>----------
  82. /**
  83. * Function OnLayerSelected
  84. * ensure the active layer is visible, and other layers not visible
  85. * when m_alwaysShowActiveLayer is true
  86. * Otherwise do nothing.
  87. * @return true m_alwaysShowActiveLayer is true and the canvas is refreshed,
  88. * and false if do nothing
  89. */
  90. bool OnLayerSelected(); // postprocess after an active layer selection
  91. // ensure active layer visible if
  92. // m_alwaysShowActiveCopperLayer is true;
  93. /**
  94. * Function addRightClickMenuItems
  95. * add menu items to a menu that should be shown when right-clicking
  96. * the PCB layer widget.
  97. */
  98. void AddRightClickMenuItems( wxMenu& menu );
  99. protected:
  100. static const LAYER_WIDGET::ROW s_render_rows[];
  101. bool m_alwaysShowActiveCopperLayer; // If true: Only shows the current active layer
  102. // even if it is changed
  103. bool m_fp_editor_mode;
  104. PCB_BASE_FRAME* myframe;
  105. // popup menu ids.
  106. enum POPUP_ID
  107. {
  108. ID_SHOW_ALL_COPPER_LAYERS = LAYER_WIDGET::ID_LAST_VALUE,
  109. ID_SHOW_NO_COPPER_LAYERS,
  110. ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE,
  111. ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE,
  112. ID_SHOW_NO_LAYERS,
  113. ID_SHOW_ALL_LAYERS,
  114. ID_SHOW_ALL_FRONT,
  115. ID_SHOW_ALL_BACK,
  116. ID_HIDE_ALL_NON_COPPER,
  117. ID_SHOW_ALL_NON_COPPER,
  118. ID_LAST_VALUE
  119. };
  120. virtual COLOR4D getBackgroundLayerColor() override;
  121. /**
  122. * Function isAllowedInFpMode
  123. * @return true if item aId has meaning in footprint editor mode.
  124. * and therefore is shown in render panel
  125. */
  126. bool isAllowedInFpMode( int aId );
  127. /**
  128. * Function isLayerAllowedInFpMode
  129. *
  130. * User layers, which are not paired, are not shown in layers manager. However a not
  131. * listed layer can be reachable in the graphic item properties dialog.
  132. *
  133. * @param aLayer is the layer id to test
  134. * @return true if PCB_LAYER_ID aLayer has meaning in footprint editor mode.
  135. * and therefore is shown in render panel
  136. */
  137. bool isLayerAllowedInFpMode( PCB_LAYER_ID aLayer );
  138. /**
  139. * Function OnRightDownLayers
  140. * puts up a popup menu for the layer panel.
  141. */
  142. void onRightDownLayers( wxMouseEvent& event );
  143. void onPopupSelection( wxCommandEvent& event );
  144. /// this is for the popup menu, the right click handler has to be installed
  145. /// on every child control within the layer panel.
  146. void installRightLayerClickHandler();
  147. };
  148. #endif // PCB_LAYER_WIDGET_H