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.

128 lines
4.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
  5. * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.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 render_3d_base.h
  26. */
  27. #ifndef RENDER_3D_BASE_H
  28. #define RENDER_3D_BASE_H
  29. #include <pcb_base_frame.h>
  30. #include "3d_canvas/board_adapter.h"
  31. #include <reporter.h>
  32. #include <widgets/busy_indicator.h>
  33. /**
  34. * This is a base class to hold data and functions for render targets.
  35. */
  36. class RENDER_3D_BASE
  37. {
  38. public:
  39. explicit RENDER_3D_BASE( BOARD_ADAPTER& aBoardAdapter, CAMERA& aCamera );
  40. virtual ~RENDER_3D_BASE() = 0;
  41. /**
  42. * Before each render, the canvas will tell the render what is the size of its windows,
  43. * so render can take actions if it changed.
  44. *
  45. * @param aSize the current size of the render window
  46. */
  47. virtual void SetCurWindowSize( const wxSize& aSize ) = 0;
  48. /**
  49. * Redraw the view.
  50. *
  51. * @param aIsMoving if the user is moving the scene, it should be render in preview mode.
  52. * @param aStatusReporter a pointer to the status progress reporter.
  53. * @return true if the render would like to redraw again.
  54. */
  55. virtual bool Redraw( bool aIsMoving, REPORTER* aStatusReporter = nullptr,
  56. REPORTER* aWarningReporter = nullptr ) = 0;
  57. /**
  58. * @todo This must be reviewed to add flags to improve specific render.
  59. */
  60. void ReloadRequest() { m_reloadRequested = true; }
  61. /**
  62. * Query if there is a pending reload request.
  63. *
  64. * @return true if it wants to reload, false if there is no reload pending
  65. */
  66. bool IsReloadRequestPending() const { return m_reloadRequested; }
  67. /**
  68. * Give the interface the time (in ms) that it should wait for editing or movements before
  69. * (this works for display preview mode).
  70. *
  71. * @return a value in milliseconds
  72. */
  73. virtual int GetWaitForEditingTimeOut() = 0;
  74. /**
  75. * Set a new busy indicator factory.
  76. *
  77. * When set, this factory will be used to generate busy indicators when
  78. * suitable. If not set, no busy indicator will be used.
  79. */
  80. void SetBusyIndicatorFactory( BUSY_INDICATOR::FACTORY aNewFactory );
  81. protected:
  82. /**
  83. * Return a created busy indicator, if a factory has been set, else a null pointer.
  84. */
  85. std::unique_ptr<BUSY_INDICATOR> CreateBusyIndicator() const;
  86. ///< Settings reference in use for this render.
  87. BOARD_ADAPTER& m_boardAdapter;
  88. CAMERA& m_camera;
  89. ///< Flag if the canvas specific for this render was already initialized.
  90. bool m_canvasInitialized;
  91. ///< @todo This must be reviewed in order to flag change types.
  92. bool m_reloadRequested;
  93. ///< The window size that this camera is working.
  94. wxSize m_windowSize;
  95. /**
  96. * Trace mask used to enable or disable the trace output of this class.
  97. * The debug output can be turned on by setting the WXTRACE environment variable to
  98. * "KI_TRACE_3D_RENDER". See the wxWidgets documentation on wxLogTrace for
  99. * more information.
  100. */
  101. static const wxChar* m_logTrace;
  102. private:
  103. ///< Factory that returns a suitable busy indicator for the context.
  104. BUSY_INDICATOR::FACTORY m_busyIndicatorFactory;
  105. };
  106. #endif // RENDER_3D_BASE_H