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.

123 lines
4.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2014 CERN
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * @author Maciej Suminski <maciej.suminski@cern.ch>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #ifndef PCB_DRAW_PANEL_GAL_H_
  27. #define PCB_DRAW_PANEL_GAL_H_
  28. #include <class_draw_panel_gal.h>
  29. #include <layer_ids.h>
  30. #include <pcb_view.h>
  31. class DS_PROXY_VIEW_ITEM;
  32. class RATSNEST_VIEW_ITEM;
  33. class PROGRESS_REPORTER;
  34. class PCB_DRAW_PANEL_GAL : public EDA_DRAW_PANEL_GAL
  35. {
  36. public:
  37. PCB_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId, const wxPoint& aPosition,
  38. const wxSize& aSize, KIGFX::GAL_DISPLAY_OPTIONS& aOptions,
  39. GAL_TYPE aGalType = GAL_TYPE_OPENGL );
  40. virtual ~PCB_DRAW_PANEL_GAL();
  41. /**
  42. * Add all items from the current board to the VIEW, so they can be displayed by GAL.
  43. *
  44. * @param aBoard is the PCB to be loaded.
  45. */
  46. void DisplayBoard( BOARD* aBoard, PROGRESS_REPORTER* aReporter = nullptr );
  47. /**
  48. * Sets (or updates) drawing-sheet used by the draw panel.
  49. *
  50. * @param aDrawingSheet is the drawing-sheet to be used. The object is then owned by
  51. * #PCB_DRAW_PANEL_GAL.
  52. */
  53. void SetDrawingSheet( DS_PROXY_VIEW_ITEM* aDrawingSheet );
  54. DS_PROXY_VIEW_ITEM* GetDrawingSheet() const { return m_drawingSheet.get(); }
  55. // TODO(JE) Look at optimizing this out
  56. /**
  57. * Update the color settings in the painter and GAL.
  58. */
  59. void UpdateColors();
  60. ///< @copydoc EDA_DRAW_PANEL_GAL::SetHighContrastLayer()
  61. virtual void SetHighContrastLayer( int aLayer ) override
  62. {
  63. SetHighContrastLayer( static_cast< PCB_LAYER_ID >( aLayer ) );
  64. }
  65. ///< SetHighContrastLayer(), with some extra smarts for PCB.
  66. void SetHighContrastLayer( PCB_LAYER_ID aLayer );
  67. ///< @copydoc EDA_DRAW_PANEL_GAL::SetTopLayer()
  68. virtual void SetTopLayer( int aLayer ) override
  69. {
  70. SetTopLayer( static_cast< PCB_LAYER_ID >( aLayer ) );
  71. }
  72. ///< SetTopLayer(), with some extra smarts for PCB.
  73. void SetTopLayer( PCB_LAYER_ID aLayer );
  74. /**
  75. * Update "visibility" property of each layer of a given #BOARD.
  76. *
  77. * @param aBoard contains layers visibility settings to be applied.
  78. */
  79. void SyncLayersVisibility( const BOARD* aBoard );
  80. ///< @copydoc EDA_DRAW_PANEL_GAL::GetMsgPanelInfo()
  81. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  82. ///< @copydoc EDA_DRAW_PANEL_GAL::OnShow()
  83. void OnShow() override;
  84. bool SwitchBackend( GAL_TYPE aGalType ) override;
  85. ///< Force refresh of the ratsnest visual representation.
  86. void RedrawRatsnest();
  87. ///< @copydoc EDA_DRAW_PANEL_GAL::GetDefaultViewBBox()
  88. BOX2I GetDefaultViewBBox() const override;
  89. virtual KIGFX::PCB_VIEW* GetView() const override;
  90. protected:
  91. ///< Reassign layer order to the initial settings.
  92. void setDefaultLayerOrder();
  93. ///< Set rendering targets & dependencies for layers.
  94. void setDefaultLayerDeps();
  95. protected:
  96. std::unique_ptr<DS_PROXY_VIEW_ITEM> m_drawingSheet; ///< Currently used drawing-sheet.
  97. std::unique_ptr<RATSNEST_VIEW_ITEM> m_ratsnest; ///< Ratsnest view item
  98. };
  99. #endif /* PCB_DRAW_PANEL_GAL_H_ */