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.

87 lines
2.7 KiB

6 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
  5. * Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
  6. * Copyright (C) 2016 Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 3 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef __FOOTPRINT_PREVIEW_PANEL_H
  22. #define __FOOTPRINT_PREVIEW_PANEL_H
  23. #include <map>
  24. #include <deque>
  25. #include <functional>
  26. #include <pcb_draw_panel_gal.h>
  27. #include <gal/color4d.h>
  28. #include <gal/gal_display_options.h>
  29. #include <lib_id.h>
  30. #include <kiway_player.h>
  31. #include <optional>
  32. #include <widgets/footprint_preview_widget.h>
  33. class FOOTPRINT;
  34. class KIWAY;
  35. class IO_MGR;
  36. class BOARD;
  37. /**
  38. * Panel that renders a single footprint via Cairo GAL, meant to be exported
  39. * through Kiface.
  40. */
  41. class FOOTPRINT_PREVIEW_PANEL : public PCB_DRAW_PANEL_GAL,
  42. public KIWAY_HOLDER,
  43. public FOOTPRINT_PREVIEW_PANEL_BASE
  44. {
  45. public:
  46. virtual ~FOOTPRINT_PREVIEW_PANEL( );
  47. virtual bool DisplayFootprint( const LIB_ID& aFPID ) override;
  48. virtual const KIGFX::COLOR4D& GetBackgroundColor() const override;
  49. virtual const KIGFX::COLOR4D& GetForegroundColor() const override;
  50. virtual wxWindow* GetWindow() override;
  51. BOARD* GetBoard() { return m_dummyBoard.get(); }
  52. static FOOTPRINT_PREVIEW_PANEL* New( KIWAY* aKiway, wxWindow* aParent );
  53. private:
  54. /**
  55. * Create a new panel
  56. *
  57. * @param aKiway the connected KIWAY
  58. * @param aParent the owning WX window
  59. * @param aOpts the GAL options (ownership is assumed)
  60. * @param aGalType the displayed GAL type
  61. */
  62. FOOTPRINT_PREVIEW_PANEL( KIWAY* aKiway, wxWindow* aParent,
  63. std::unique_ptr<KIGFX::GAL_DISPLAY_OPTIONS> aOpts,
  64. GAL_TYPE aGalType );
  65. void renderFootprint( std::shared_ptr<FOOTPRINT> aFootprint );
  66. private:
  67. std::unique_ptr<BOARD> m_dummyBoard;
  68. std::unique_ptr<KIGFX::GAL_DISPLAY_OPTIONS> m_displayOptions;
  69. std::shared_ptr<FOOTPRINT> m_currentFootprint;
  70. };
  71. #endif