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.

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