KiCad PCB EDA Suite
EDA_3D_CANVAS Class Reference

Implement a canvas based on a wxGLCanvas. More...

#include <eda_3d_canvas.h>

Inheritance diagram for EDA_3D_CANVAS:
HIDPI_GL_CANVAS

Public Member Functions

 EDA_3D_CANVAS (wxWindow *aParent, const int *aAttribList, BOARD *aBoard, BOARD_ADAPTER &aSettings, CCAMERA &aCamera, S3D_CACHE *a3DCachePointer)
 EDA_3D_CANVAS - Creates a new 3D Canvas with a attribute list. More...
 
 ~EDA_3D_CANVAS ()
 
void SetEventDispatcher (TOOL_DISPATCHER *aEventDispatcher)
 Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools. More...
 
void SetStatusBar (wxStatusBar *aStatusBar)
 
void SetInfoBar (WX_INFOBAR *aInfoBar)
 
void ReloadRequest (BOARD *aBoard=NULL, S3D_CACHE *aCachePointer=NULL)
 
bool IsReloadRequestPending () const
 IsReloadRequestPending - Query if there is a pending reload request. More...
 
void RenderRaytracingRequest ()
 RenderRaytracingRequest - Request to render the current view in Raytracing mode. More...
 
void GetScreenshot (wxImage &aDstImage)
 Request a screenshot and output it to the aDstImage. More...
 
bool SetView3D (int aKeycode)
 SetView3D - Helper function to call view commands. More...
 
void AnimationEnabledSet (bool aAnimationEnabled)
 AnimationEnabledSet - Enable or disable camera animation when switching to a pre-defined view. More...
 
bool AnimationEnabledGet () const
 AnimationEnabledGet - Returns whether camera animation is enabled when switching to a pre-defined view. More...
 
void MovingSpeedMultiplierSet (int aMovingSpeedMultiplier)
 MovingSpeedMultiplierSet - Set the camera animation moving speed multiplier option. More...
 
int MovingSpeedMultiplierGet () const
 MovingSpeedMultiplierGet - Return the current camera animation moving speed multiplier option. More...
 
void RenderEngineChanged ()
 RenderEngineChanged - Notify that the render engine was changed. More...
 
void DisplayStatus ()
 DisplayStatus - Update the status bar with the position information. More...
 
void Request_refresh (bool aRedrawImmediately=true)
 Request_refresh - Schedule a refresh update of the canvas. More...
 
void OnEvent (wxEvent &aEvent)
 Used to forward events to the canvas from popups, etc. More...
 
virtual wxSize GetNativePixelSize () const
 
void SetScaleFactor (double aFactor)
 Set the canvas scale factor, probably for a hi-DPI display. More...
 
double GetScaleFactor () const
 Get the current scale factor. More...
 

Private Member Functions

void OnPaint (wxPaintEvent &event)
 
void OnEraseBackground (wxEraseEvent &event)
 
void OnMouseWheel (wxMouseEvent &event)
 
void OnMouseMove (wxMouseEvent &event)
 
void OnLeftDown (wxMouseEvent &event)
 
void OnLeftUp (wxMouseEvent &event)
 
void OnMiddleUp (wxMouseEvent &event)
 
void OnMiddleDown (wxMouseEvent &event)
 
void OnTimerTimeout_Editing (wxTimerEvent &event)
 
void OnCloseWindow (wxCloseEvent &event)
 
void OnResize (wxSizeEvent &event)
 
void OnTimerTimeout_Redraw (wxTimerEvent &event)
 
void stop_editingTimeOut_Timer ()
 stop_editingTimeOut_Timer - stop the editing time, so it will not timeout More...
 
void restart_editingTimeOut_Timer ()
 restart_editingTimeOut_Timer - reset the editing timer More...
 
void request_start_moving_camera (float aMovingSpeed=2.0f, bool aRenderPivot=true)
 request_start_moving_camera - start a camera movement More...
 
void move_pivot_based_on_cur_mouse_position ()
 move_pivot_based_on_cur_mouse_position - This function hits a ray to the board and start a moviment More...
 
void render_pivot (float t, float aScale)
 render_pivot - render the pivot cursor More...
 
bool initializeOpenGL ()
 initializeOpenGL More...
 
void releaseOpenGL ()
 releaseOpenGL - free created targets and openGL context More...
 

Private Attributes

TOOL_DISPATCHERm_eventDispatcher
 
wxStatusBar * m_parentStatusBar
 
WX_INFOBARm_parentInfoBar
 
wxGLContext * m_glRC
 
bool m_is_opengl_initialized
 
wxTimer m_editing_timeout_timer
 
wxTimer m_redraw_trigger_timer
 
bool m_mouse_is_moving
 
bool m_mouse_was_moved
 
bool m_camera_is_moving
 
bool m_render_pivot
 
float m_camera_moving_speed
 
unsigned m_strtime_camera_movement
 
bool m_animation_enabled
 
int m_moving_speed_multiplier
 
BOARD_ADAPTERm_boardAdapter
 
CCAMERAm_camera
 
C3D_RENDER_BASEm_3d_render
 
C3D_RENDER_RAYTRACINGm_3d_render_raytracing
 
C3D_RENDER_OGL_LEGACYm_3d_render_ogl_legacy
 
bool m_opengl_supports_raytracing
 
bool m_render_raytracing_was_requested
 

Static Private Attributes

static const float m_delta_move_step_factor = 0.7f
 
static const wxChar * m_logTrace = wxT( "KI_TRACE_EDA_3D_CANVAS" )
 Trace mask used to enable or disable the trace output of this class. More...
 

Detailed Description

Implement a canvas based on a wxGLCanvas.

Definition at line 47 of file eda_3d_canvas.h.

Constructor & Destructor Documentation

◆ EDA_3D_CANVAS()

EDA_3D_CANVAS::EDA_3D_CANVAS ( wxWindow *  aParent,
const int *  aAttribList,
BOARD aBoard,
BOARD_ADAPTER aSettings,
CCAMERA aCamera,
S3D_CACHE a3DCachePointer 
)

EDA_3D_CANVAS - Creates a new 3D Canvas with a attribute list.

Parameters
aParentthe parent creator of this canvas
aAttribLista list of openGL options created by GetOpenGL_AttributesList
aBoardThe board
aSettingsthe settings options to be used by this canvas

Definition at line 88 of file eda_3d_canvas.cpp.

91  : HIDPI_GL_CANVAS( aParent, wxID_ANY, aAttribList, wxDefaultPosition, wxDefaultSize,
92  wxFULL_REPAINT_ON_RESIZE ),
93  m_eventDispatcher( nullptr ),
94  m_parentStatusBar( nullptr ),
95  m_parentInfoBar( nullptr ),
96  m_glRC( nullptr ),
97  m_is_opengl_initialized( false ),
98  m_mouse_is_moving( false ),
99  m_mouse_was_moved( false ),
100  m_camera_is_moving( false ),
101  m_render_pivot( false ),
102  m_camera_moving_speed( 1.0f ),
104  m_animation_enabled( true ),
106  m_boardAdapter( aBoardAdapter ),
107  m_camera( aCamera ),
108  m_3d_render( nullptr ),
111 {
112  wxLogTrace( m_logTrace, "EDA_3D_CANVAS::EDA_3D_CANVAS" );
113 
114  m_editing_timeout_timer.SetOwner( this );
115  Connect( m_editing_timeout_timer.GetId(),
116  wxEVT_TIMER,
117  wxTimerEventHandler( EDA_3D_CANVAS::OnTimerTimeout_Editing ),
118  NULL,
119  this );
120 
121  m_redraw_trigger_timer.SetOwner( this );
122  Connect( m_redraw_trigger_timer.GetId(),
123  wxEVT_TIMER,
124  wxTimerEventHandler( EDA_3D_CANVAS::OnTimerTimeout_Redraw ),
125  NULL,
126  this );
127 
130 
131  wxASSERT( m_3d_render_raytracing != NULL );
132  wxASSERT( m_3d_render_ogl_legacy != NULL );
133 
134  auto busy_indicator_factory = []() { return std::make_unique<WX_BUSY_INDICATOR>(); };
135 
136  m_3d_render_raytracing->SetBusyIndicatorFactory( busy_indicator_factory );
137  m_3d_render_ogl_legacy->SetBusyIndicatorFactory( busy_indicator_factory );
138 
140 
141  wxASSERT( aBoard != NULL );
142  m_boardAdapter.SetBoard( aBoard );
143 
144  m_boardAdapter.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() );
145 
146  wxASSERT( a3DCachePointer != NULL );
147  m_boardAdapter.Set3DCacheManager( a3DCachePointer );
148 
149  const wxEventType events[] =
150  {
151  // Binding both EVT_CHAR and EVT_CHAR_HOOK ensures that all key events,
152  // especially special key like arrow keys, are handled by the GAL event dispatcher,
153  // and not sent to GUI without filtering, because they have a default action (scroll)
154  // that must not be called.
155  wxEVT_LEFT_UP, wxEVT_LEFT_DOWN, wxEVT_LEFT_DCLICK,
156  wxEVT_RIGHT_UP, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_DCLICK,
157  wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_DCLICK,
158  wxEVT_MOTION, wxEVT_MOUSEWHEEL, wxEVT_CHAR, wxEVT_CHAR_HOOK,
159 #if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
160  wxEVT_MAGNIFY,
161 #endif
162  wxEVT_MENU_OPEN, wxEVT_MENU_CLOSE, wxEVT_MENU_HIGHLIGHT
163  };
164 
165  for( wxEventType eventType : events )
166  Connect( eventType, wxEventHandler( EDA_3D_CANVAS::OnEvent ), NULL, m_eventDispatcher );
167 }
C3D_RENDER_RAYTRACING * m_3d_render_raytracing
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
bool m_mouse_is_moving
unsigned m_strtime_camera_movement
WX_INFOBAR * m_parentInfoBar
wxStatusBar * m_parentStatusBar
wxGLContext * m_glRC
wxTimer m_editing_timeout_timer
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
C3D_RENDER_OGL_LEGACY * m_3d_render_ogl_legacy
void SetBoard(BOARD *aBoard) noexcept
SetBoard - Set current board to be rendered.
BOARD_ADAPTER & m_boardAdapter
float m_camera_moving_speed
HIDPI_GL_CANVAS(wxWindow *parent, wxWindowID id=wxID_ANY, const int *attribList=NULL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxGLCanvasName, const wxPalette &palette=wxNullPalette)
void SetBusyIndicatorFactory(BUSY_INDICATOR::FACTORY aNewFactory)
Set a new busy indicator factory.
#define NULL
CCAMERA & m_camera
bool m_mouse_was_moved
void RenderEngineChanged()
RenderEngineChanged - Notify that the render engine was changed.
bool m_camera_is_moving
void OnTimerTimeout_Redraw(wxTimerEvent &event)
SETTINGS_MANAGER * GetSettingsManager()
bool m_animation_enabled
void Set3DCacheManager(S3D_CACHE *aCachePointer) noexcept
Set3DCacheManager - Update the Cache manager pointer.
Definition: board_adapter.h:80
bool m_is_opengl_initialized
C3D_RENDER_BASE * m_3d_render
The C3D_RENDER_OGL_LEGACY class render the board using openGL legacy mode.
TOOL_DISPATCHER * m_eventDispatcher
int m_moving_speed_multiplier
void OnEvent(wxEvent &aEvent)
Used to forward events to the canvas from popups, etc.
bool m_opengl_supports_raytracing
void OnTimerTimeout_Editing(wxTimerEvent &event)
void SetColorSettings(COLOR_SETTINGS *aSettings) noexcept
wxTimer m_redraw_trigger_timer
bool m_render_raytracing_was_requested

References GetSettingsManager(), NULL, OnEvent(), OnTimerTimeout_Editing(), OnTimerTimeout_Redraw(), and Pgm().

◆ ~EDA_3D_CANVAS()

EDA_3D_CANVAS::~EDA_3D_CANVAS ( )

Definition at line 170 of file eda_3d_canvas.cpp.

171 {
172  wxLogTrace( m_logTrace, "EDA_3D_CANVAS::~EDA_3D_CANVAS" );
173 
174  releaseOpenGL();
175 }
void releaseOpenGL()
releaseOpenGL - free created targets and openGL context
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.

References m_logTrace, and releaseOpenGL().

Member Function Documentation

◆ AnimationEnabledGet()

bool EDA_3D_CANVAS::AnimationEnabledGet ( ) const
inline

AnimationEnabledGet - Returns whether camera animation is enabled when switching to a pre-defined view.

Returns
true if animation is enabled

Definition at line 124 of file eda_3d_canvas.h.

124 { return m_animation_enabled; }
bool m_animation_enabled

References m_animation_enabled.

Referenced by EDA_3D_VIEWER::SaveSettings(), and DIALOG_3D_VIEW_OPTIONS::TransferDataToWindow().

◆ AnimationEnabledSet()

void EDA_3D_CANVAS::AnimationEnabledSet ( bool  aAnimationEnabled)
inline

AnimationEnabledSet - Enable or disable camera animation when switching to a pre-defined view.

Parameters
aAnimationEnabledAnimation enabled state to set

Definition at line 118 of file eda_3d_canvas.h.

118 { m_animation_enabled = aAnimationEnabled; }
bool m_animation_enabled

References m_animation_enabled.

Referenced by EDA_3D_VIEWER::LoadSettings(), and DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow().

◆ DisplayStatus()

void EDA_3D_CANVAS::DisplayStatus ( )

DisplayStatus - Update the status bar with the position information.

Definition at line 318 of file eda_3d_canvas.cpp.

319 {
320  if( m_parentStatusBar )
321  {
322  wxString msg;
323 
324  msg.Printf( "dx %3.2f", m_camera.GetCameraPos().x );
325  m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::X_POS ) );
326 
327  msg.Printf( "dy %3.2f", m_camera.GetCameraPos().y );
328  m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::Y_POS ) );
329  }
330 }
wxStatusBar * m_parentStatusBar
CCAMERA & m_camera
const SFVEC3F & GetCameraPos() const
Definition: ccamera.h:134

References CCAMERA::GetCameraPos(), m_camera, m_parentStatusBar, X_POS, and Y_POS.

Referenced by EDA_3D_CONTROLLER::doZoomInOut(), OnMouseMove(), OnMouseWheel(), OnPaint(), request_start_moving_camera(), SetView3D(), and EDA_3D_CONTROLLER::ZoomFitScreen().

◆ GetNativePixelSize()

wxSize HIDPI_GL_CANVAS::GetNativePixelSize ( ) const
virtualinherited

Definition at line 46 of file hidpi_gl_canvas.cpp.

47 {
48  wxSize size = wxGLCanvas::GetClientSize();
49 
50  const double scaleFactor = GetScaleFactor();
51  size.x *= scaleFactor;
52  size.y *= scaleFactor;
53 
54  return size;
55 }
double GetScaleFactor() const
Get the current scale factor.

References HIDPI_GL_CANVAS::GetScaleFactor().

Referenced by OnMouseMove(), OnPaint(), and KIGFX::OPENGL_GAL::OPENGL_GAL().

◆ GetScaleFactor()

double HIDPI_GL_CANVAS::GetScaleFactor ( ) const
inherited

◆ GetScreenshot()

void EDA_3D_CANVAS::GetScreenshot ( wxImage &  aDstImage)

Request a screenshot and output it to the aDstImage.

Parameters
aDstImage- Screenshot destination image

Definition at line 283 of file eda_3d_canvas.cpp.

284 {
285  OGL_GetScreenshot( aDstImage );
286 }
void OGL_GetScreenshot(wxImage &aDstImage)
OGL_GetScreenshot - got the pixel data of current OpenGL image.
Definition: ogl_utils.cpp:36

References OGL_GetScreenshot().

Referenced by EDA_3D_VIEWER::takeScreenshot().

◆ initializeOpenGL()

bool EDA_3D_CANVAS::initializeOpenGL ( )
private

initializeOpenGL

Returns
if OpenGL initialization succeed

Definition at line 214 of file eda_3d_canvas.cpp.

215 {
216  wxLogTrace( m_logTrace, "EDA_3D_CANVAS::initializeOpenGL" );
217 
218  const GLenum err = glewInit();
219 
220  if( GLEW_OK != err )
221  {
222  const wxString msgError = (const char*) glewGetErrorString( err );
223 
224  wxLogMessage( msgError );
225 
226  return false;
227  }
228  else
229  {
230  wxLogTrace( m_logTrace, "EDA_3D_CANVAS::initializeOpenGL Using GLEW version %s",
231  FROM_UTF8( (char*) glewGetString( GLEW_VERSION ) ) );
232  }
233 
234  wxString version = FROM_UTF8( (char *) glGetString( GL_VERSION ) );
235 
236  wxLogTrace( m_logTrace, "EDA_3D_CANVAS::%s OpenGL version string %s.",
237  __WXFUNCTION__, version );
238 
239  // Extract OpenGL version from string. This method is used because prior to OpenGL 2,
240  // getting the OpenGL major and minor version as integers didn't exist.
241  wxString tmp;
242 
243  wxStringTokenizer tokenizer( version );
244 
246 
247  if( tokenizer.HasMoreTokens() )
248  {
249  long major = 0;
250  long minor = 0;
251 
252  tmp = tokenizer.GetNextToken();
253 
254  tokenizer.SetString( tmp, wxString( "." ) );
255 
256  if( tokenizer.HasMoreTokens() )
257  tokenizer.GetNextToken().ToLong( &major );
258 
259  if( tokenizer.HasMoreTokens() )
260  tokenizer.GetNextToken().ToLong( &minor );
261 
262  if( major < 2 || ( (major == 2 ) && (minor < 1) ) )
263  {
264  wxLogTrace( m_logTrace, "EDA_3D_CANVAS::%s OpenGL ray tracing not supported.",
265  __WXFUNCTION__ );
266 
267  if( GetParent() )
268  {
269  wxCommandEvent evt( wxEVT_MENU, ID_DISABLE_RAY_TRACING );
270  GetParent()->ProcessWindowEvent( evt );
271  }
272 
274  }
275  }
276 
278 
279  return true;
280 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:114
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
bool m_is_opengl_initialized
bool m_opengl_supports_raytracing

References FROM_UTF8(), ID_DISABLE_RAY_TRACING, m_is_opengl_initialized, m_logTrace, and m_opengl_supports_raytracing.

Referenced by OnPaint().

◆ IsReloadRequestPending()

bool EDA_3D_CANVAS::IsReloadRequestPending ( ) const
inline

IsReloadRequestPending - Query if there is a pending reload request.

Returns
true if it wants to reload, false if there is no reload pending

Definition at line 87 of file eda_3d_canvas.h.

88  {
89  if( m_3d_render )
91  else
92  return false;
93  }
bool IsReloadRequestPending() const
IsReloadRequestPending - Query if there is a pending reload request.
C3D_RENDER_BASE * m_3d_render

References C3D_RENDER_BASE::IsReloadRequestPending(), and m_3d_render.

Referenced by EDA_3D_VIEWER::OnActivate().

◆ move_pivot_based_on_cur_mouse_position()

void EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position ( )
private

move_pivot_based_on_cur_mouse_position - This function hits a ray to the board and start a moviment

Definition at line 787 of file eda_3d_canvas.cpp.

788 {
789  SFVEC3F rayOrigin;
790  SFVEC3F rayDir;
791 
792  // Generate a ray origin and direction based on current mouser position and camera
793  m_camera.MakeRayAtCurrrentMousePosition( rayOrigin, rayDir );
794 
795  RAY mouseRay;
796  mouseRay.Init( rayOrigin, rayDir );
797 
798  float hit_t;
799 
800  // Test it with the board bounding box
801  if( m_boardAdapter.GetBBox3DU().Intersect( mouseRay, &hit_t ) )
802  {
805  m_camera.SetLookAtPos_T1( mouseRay.at( hit_t ) );
807 
809  }
810 }
void SetLookAtPos_T1(const SFVEC3F &aLookAtPos)
Definition: ccamera.h:128
void request_start_moving_camera(float aMovingSpeed=2.0f, bool aRenderPivot=true)
request_start_moving_camera - start a camera movement
virtual void SetT0_and_T1_current_T()
SetT0_and_T1_current_T - This will set T0 and T1 with the current values.
Definition: ccamera.cpp:555
void ResetXYpos_T1()
Definition: ccamera.cpp:412
void Init(const SFVEC3F &o, const SFVEC3F &d)
Definition: ray.cpp:40
const CBBOX & GetBBox3DU() const noexcept
GetBBox3DU - Get the bbox of the pcb board.
Definition: ray.h:67
SFVEC3F at(float t) const
Definition: ray.h:89
BOARD_ADAPTER & m_boardAdapter
CCAMERA & m_camera
void MakeRayAtCurrrentMousePosition(SFVEC3F &aOutOrigin, SFVEC3F &aOutDirection) const
MakeRayAtCurrrentMousePosition - Make a ray based on the latest mouse position.
Definition: ccamera.cpp:380
bool Intersect(const RAY &aRay, float *t) const
Function Intersect.
Definition: cbbox_ray.cpp:46
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void SetInterpolateMode(CAMERA_INTERPOLATION aInterpolateMode)
Definition: ccamera.h:200

References RAY::at(), BEZIER, BOARD_ADAPTER::GetBBox3DU(), RAY::Init(), CBBOX::Intersect(), m_boardAdapter, m_camera, CCAMERA::MakeRayAtCurrrentMousePosition(), request_start_moving_camera(), CCAMERA::ResetXYpos_T1(), CCAMERA::SetInterpolateMode(), CCAMERA::SetLookAtPos_T1(), and CCAMERA::SetT0_and_T1_current_T().

Referenced by OnMiddleUp(), and SetView3D().

◆ MovingSpeedMultiplierGet()

int EDA_3D_CANVAS::MovingSpeedMultiplierGet ( ) const
inline

MovingSpeedMultiplierGet - Return the current camera animation moving speed multiplier option.

Returns
current moving speed multiplier option, one of [1,2,3,4,5]

Definition at line 136 of file eda_3d_canvas.h.

136 { return m_moving_speed_multiplier; }
int m_moving_speed_multiplier

References m_moving_speed_multiplier.

Referenced by EDA_3D_VIEWER::SaveSettings(), and DIALOG_3D_VIEW_OPTIONS::TransferDataToWindow().

◆ MovingSpeedMultiplierSet()

void EDA_3D_CANVAS::MovingSpeedMultiplierSet ( int  aMovingSpeedMultiplier)
inline

MovingSpeedMultiplierSet - Set the camera animation moving speed multiplier option.

Parameters
aMovingSpeedMultiplierOne of the possible integer options: [1,2,3,4,5]

Definition at line 130 of file eda_3d_canvas.h.

130 { m_moving_speed_multiplier = aMovingSpeedMultiplier; }
int m_moving_speed_multiplier

References m_moving_speed_multiplier.

Referenced by EDA_3D_VIEWER::LoadSettings(), and DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow().

◆ OnCloseWindow()

void EDA_3D_CANVAS::OnCloseWindow ( wxCloseEvent &  event)
private

Definition at line 200 of file eda_3d_canvas.cpp.

201 {
202  releaseOpenGL();
203 
204  event.Skip();
205 }
void releaseOpenGL()
releaseOpenGL - free created targets and openGL context

References releaseOpenGL().

◆ OnEraseBackground()

void EDA_3D_CANVAS::OnEraseBackground ( wxEraseEvent &  event)
private

Definition at line 530 of file eda_3d_canvas.cpp.

531 {
532  wxLogTrace( m_logTrace, "EDA_3D_CANVAS::OnEraseBackground" );
533  // Do nothing, to avoid flashing.
534 }
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.

References m_logTrace.

◆ OnEvent()

void EDA_3D_CANVAS::OnEvent ( wxEvent &  aEvent)

Used to forward events to the canvas from popups, etc.

Definition at line 519 of file eda_3d_canvas.cpp.

520 {
521  if( !m_eventDispatcher )
522  aEvent.Skip();
523  else
525 
526  Refresh();
527 }
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
virtual void DispatchWxEvent(wxEvent &aEvent)
Function DispatchWxEvent() Processes wxEvents (mostly UI events), translates them to TOOL_EVENTs,...
TOOL_DISPATCHER * m_eventDispatcher

References TOOL_DISPATCHER::DispatchWxEvent(), m_eventDispatcher, and Refresh().

Referenced by EDA_3D_CANVAS().

◆ OnLeftDown()

void EDA_3D_CANVAS::OnLeftDown ( wxMouseEvent &  event)
private

Definition at line 654 of file eda_3d_canvas.cpp.

655 {
656  SetFocus();
658 }
void stop_editingTimeOut_Timer()
stop_editingTimeOut_Timer - stop the editing time, so it will not timeout

References stop_editingTimeOut_Timer().

◆ OnLeftUp()

void EDA_3D_CANVAS::OnLeftUp ( wxMouseEvent &  event)
private

Definition at line 661 of file eda_3d_canvas.cpp.

662 {
663  if( m_camera_is_moving )
664  return;
665 
666  if( m_mouse_is_moving )
667  {
668  m_mouse_is_moving = false;
670  }
671 }
bool m_mouse_is_moving
void restart_editingTimeOut_Timer()
restart_editingTimeOut_Timer - reset the editing timer
bool m_camera_is_moving

References m_camera_is_moving, m_mouse_is_moving, and restart_editingTimeOut_Timer().

◆ OnMiddleDown()

void EDA_3D_CANVAS::OnMiddleDown ( wxMouseEvent &  event)
private

Definition at line 674 of file eda_3d_canvas.cpp.

675 {
676  SetFocus();
678 }
void stop_editingTimeOut_Timer()
stop_editingTimeOut_Timer - stop the editing time, so it will not timeout

References stop_editingTimeOut_Timer().

◆ OnMiddleUp()

void EDA_3D_CANVAS::OnMiddleUp ( wxMouseEvent &  event)
private

Definition at line 681 of file eda_3d_canvas.cpp.

682 {
683  if( m_camera_is_moving )
684  return;
685 
686  if( m_mouse_is_moving )
687  {
688  m_mouse_is_moving = false;
690  }
691  else
692  {
694  }
695 }
bool m_mouse_is_moving
void restart_editingTimeOut_Timer()
restart_editingTimeOut_Timer - reset the editing timer
bool m_camera_is_moving
void move_pivot_based_on_cur_mouse_position()
move_pivot_based_on_cur_mouse_position - This function hits a ray to the board and start a moviment

References m_camera_is_moving, m_mouse_is_moving, move_pivot_based_on_cur_mouse_position(), and restart_editingTimeOut_Timer().

◆ OnMouseMove()

void EDA_3D_CANVAS::OnMouseMove ( wxMouseEvent &  event)
private

Definition at line 625 of file eda_3d_canvas.cpp.

626 {
627  //wxLogTrace( m_logTrace, wxT( "EDA_3D_CANVAS::OnMouseMove" ) );
628 
629  if( m_camera_is_moving )
630  return;
631 
633 
634  if( event.Dragging() )
635  {
636  if( event.LeftIsDown() ) // Drag
637  m_camera.Drag( event.GetPosition() );
638  else if( event.MiddleIsDown() ) // Pan
639  m_camera.Pan( event.GetPosition() );
640 
641  m_mouse_is_moving = true;
642  m_mouse_was_moved = true;
643 
644  // orientation has changed, redraw mesh
645  DisplayStatus();
646  Request_refresh();
647  }
648 
649  const wxPoint eventPosition = event.GetPosition();
650  m_camera.SetCurMousePosition( eventPosition );
651 }
virtual wxSize GetNativePixelSize() const
bool m_mouse_is_moving
void DisplayStatus()
DisplayStatus - Update the status bar with the position information.
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.
void SetCurMousePosition(const wxPoint &aPosition)
It updates the current mouse position without make any new recalculations on camera.
Definition: ccamera.cpp:431
CCAMERA & m_camera
bool m_mouse_was_moved
bool m_camera_is_moving
virtual void Drag(const wxPoint &aNewMousePosition)=0
Calculate a new mouse drag position.
bool SetCurWindowSize(const wxSize &aSize)
SetCurWindowSize - update the windows size of the camera.
Definition: ccamera.cpp:448
virtual void Pan(const wxPoint &aNewMousePosition)=0

References DisplayStatus(), CCAMERA::Drag(), HIDPI_GL_CANVAS::GetNativePixelSize(), m_camera, m_camera_is_moving, m_mouse_is_moving, m_mouse_was_moved, CCAMERA::Pan(), Request_refresh(), CCAMERA::SetCurMousePosition(), and CCAMERA::SetCurWindowSize().

◆ OnMouseWheel()

void EDA_3D_CANVAS::OnMouseWheel ( wxMouseEvent &  event)
private

Definition at line 537 of file eda_3d_canvas.cpp.

538 {
539  bool mouseActivity = false;
540 
541  wxLogTrace( m_logTrace, "EDA_3D_CANVAS::OnMouseWheel" );
542 
543  if( m_camera_is_moving )
544  return;
545 
546  float delta_move = m_delta_move_step_factor * m_camera.ZoomGet();
547 
549  delta_move *= (0.01f * event.GetWheelRotation());
550  else
551  if( event.GetWheelRotation() < 0 )
552  delta_move = -delta_move;
553 
554  // mousewheel_panning enabled:
555  // wheel -> pan;
556  // wheel + shift -> horizontal scrolling;
557  // wheel + ctrl -> zooming;
558  // mousewheel_panning disabled:
559  // wheel + shift -> vertical scrolling;
560  // wheel + ctrl -> horizontal scrolling;
561  // wheel -> zooming.
562 
563  if( m_boardAdapter.GetFlag( FL_MOUSEWHEEL_PANNING ) && !event.ControlDown() )
564  {
565  if( event.GetWheelAxis() == wxMOUSE_WHEEL_HORIZONTAL || event.ShiftDown() )
566  m_camera.Pan( SFVEC3F( -delta_move, 0.0f, 0.0f ) );
567  else
568  m_camera.Pan( SFVEC3F( 0.0f, -delta_move, 0.0f ) );
569 
570  mouseActivity = true;
571  }
572  else if( event.ShiftDown() && !m_boardAdapter.GetFlag( FL_MOUSEWHEEL_PANNING ) )
573  {
574  m_camera.Pan( SFVEC3F( 0.0f, -delta_move, 0.0f ) );
575  mouseActivity = true;
576  }
577  else if( event.ControlDown() && !m_boardAdapter.GetFlag( FL_MOUSEWHEEL_PANNING ) )
578  {
579  m_camera.Pan( SFVEC3F( delta_move, 0.0f, 0.0f ) );
580  mouseActivity = true;
581  }
582  else
583  {
584  mouseActivity = m_camera.Zoom( event.GetWheelRotation() > 0 ? 1.1f : 1/1.1f );
585  }
586 
587  // If it results on a camera movement
588  if( mouseActivity )
589  {
590  DisplayStatus();
591  Request_refresh();
592 
593  m_mouse_is_moving = true;
594  m_mouse_was_moved = true;
595 
597  }
598 
599  // Update the cursor current mouse position on the camera
600  m_camera.SetCurMousePosition( event.GetPosition() );
601 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
bool m_mouse_is_moving
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
void DisplayStatus()
DisplayStatus - Update the status bar with the position information.
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.
void SetCurMousePosition(const wxPoint &aPosition)
It updates the current mouse position without make any new recalculations on camera.
Definition: ccamera.cpp:431
BOARD_ADAPTER & m_boardAdapter
bool Zoom(float aFactor)
Definition: ccamera.cpp:474
void restart_editingTimeOut_Timer()
restart_editingTimeOut_Timer - reset the editing timer
float ZoomGet() const
Definition: ccamera.cpp:510
CCAMERA & m_camera
bool m_mouse_was_moved
bool m_camera_is_moving
virtual void Pan(const wxPoint &aNewMousePosition)=0
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
static const float m_delta_move_step_factor

References DisplayStatus(), FL_MOUSEWHEEL_PANNING, BOARD_ADAPTER::GetFlag(), m_boardAdapter, m_camera, m_camera_is_moving, m_delta_move_step_factor, m_logTrace, m_mouse_is_moving, m_mouse_was_moved, CCAMERA::Pan(), Request_refresh(), restart_editingTimeOut_Timer(), CCAMERA::SetCurMousePosition(), CCAMERA::Zoom(), and CCAMERA::ZoomGet().

◆ OnPaint()

void EDA_3D_CANVAS::OnPaint ( wxPaintEvent &  event)
private

Definition at line 333 of file eda_3d_canvas.cpp.

334 {
335  // Please have a look at:
336  // https://lists.launchpad.net/kicad-developers/msg25149.html
337  // wxPaintDC( this );
338  // event.Skip( false );
339 
340  // SwapBuffer requires the window to be shown before calling
341  if( !IsShownOnScreen() )
342  {
343  wxLogTrace( m_logTrace, "EDA_3D_CANVAS::OnPaint !IsShown" );
344  return;
345  }
346 
347  // Because the board to draw is handled by the parent viewer frame,
348  // ensure this parent is still alive. When it is closed before the viewer
349  // frame, a paint event can be generated after the parent is closed,
350  // therefore with invalid board.
351  // This is dependent of the platform.
352  // Especially on OSX, but also on Windows, it frequently happens
353  if( !GetParent()->GetParent()->IsShown() )
354  return; // The parent board editor frame is no more alive
355 
356  wxString err_messages;
357 
358  // !TODO: implement error reporter
359  //WX_STRING_REPORTER errorReporter( &err_messages );
360  INFOBAR_REPORTER warningReporter( m_parentInfoBar );
361  STATUSBAR_REPORTER activityReporter(
363 
364  unsigned strtime = GetRunningMicroSecs();
365 
366  // "Makes the OpenGL state that is represented by the OpenGL rendering
367  // context context current, i.e. it will be used by all subsequent OpenGL calls.
368  // This function may only be called when the window is shown on screen"
369 
370  // Explicitly create a new rendering context instance for this canvas.
371  if( m_glRC == NULL )
373 
375 
376  // Set the OpenGL viewport according to the client size of this canvas.
377  // This is done here rather than in a wxSizeEvent handler because our
378  // OpenGL rendering context (and thus viewport setting) is used with
379  // multiple canvases: If we updated the viewport in the wxSizeEvent
380  // handler, changing the size of one canvas causes a viewport setting that
381  // is wrong when next another canvas is repainted.
382  wxSize clientSize = GetNativePixelSize();
383 
384  const bool windows_size_changed = m_camera.SetCurWindowSize( clientSize );
385 
386  // Initialize openGL if need
387  // /////////////////////////////////////////////////////////////////////////
389  {
390  if( !initializeOpenGL() )
391  {
393 
394  return;
395  }
396  }
397 
398  // Don't attend to ray trace if OpenGL doesn't support it.
400  {
404  }
405 
406  // Check if a raytacing was requested and need to switch to raytracing mode
408  {
409  const bool was_camera_changed = m_camera.ParametersChanged();
410 
411  // It reverts back to OpenGL mode if it was requested a raytracing
412  // render of the current scene. AND the mouse / camera is moving
413  if( ( m_mouse_is_moving ||
415  was_camera_changed ||
416  windows_size_changed ) &&
418  {
421  }
422  }
423 
424  float curtime_delta_s = 0.0f;
425 
426  if( m_camera_is_moving )
427  {
428  const unsigned curtime_delta = GetRunningMicroSecs() - m_strtime_camera_movement;
429  curtime_delta_s = (curtime_delta / 1e6) * m_camera_moving_speed;
430  m_camera.Interpolate( curtime_delta_s );
431 
432  if( curtime_delta_s > 1.0f )
433  {
434  m_render_pivot = false;
435  m_camera_is_moving = false;
436  m_mouse_was_moved = true;
437 
439  DisplayStatus();
440  }
441  else
442  {
443  Request_refresh();
444  }
445  }
446 
447  // It will return true if the render request a new redraw
448  bool requested_redraw = false;
449 
450  if( m_3d_render )
451  {
452  m_3d_render->SetCurWindowSize( clientSize );
453 
454  requested_redraw = m_3d_render->Redraw( m_mouse_was_moved || m_camera_is_moving,
455  &activityReporter, &warningReporter );
456  }
457 
458  if( m_render_pivot )
459  {
460  const float scale = glm::min( m_camera.ZoomGet(), 1.0f );
461  render_pivot( curtime_delta_s, scale * scale );
462  }
463 
464  // "Swaps the double-buffer of this window, making the back-buffer the
465  // front-buffer and vice versa, so that the output of the previous OpenGL
466  // commands is displayed on the window."
467  SwapBuffers();
468 
470 
471  if( !activityReporter.HasMessage() )
472  {
474  {
475  // Calculation time in milliseconds
476  const double calculation_time = (double)( GetRunningMicroSecs() - strtime) / 1e3;
477 
478  activityReporter.Report( wxString::Format( _( "Render time %.0f ms ( %.1f fps)" ),
479  calculation_time, 1000.0 / calculation_time ) );
480  }
481  }
482 
483  // This will reset the flag of camera parameters changed
485 
486  warningReporter.Finalize();
487 
488  if( !err_messages.IsEmpty() )
489  wxLogMessage( err_messages );
490 
491  if( (!m_camera_is_moving) && requested_redraw )
492  {
493  m_mouse_was_moved = false;
494  Request_refresh( false );
495  }
496 }
STATUSBAR_REPORTER is a wrapper for reporting to a specific text location in a statusbar.
Definition: reporter.h:258
virtual wxSize GetNativePixelSize() const
bool m_mouse_is_moving
unsigned m_strtime_camera_movement
WX_INFOBAR * m_parentInfoBar
wxStatusBar * m_parentStatusBar
virtual bool Redraw(bool aIsMoving, REPORTER *aStatusReporter=NULL, REPORTER *aWarningReporter=NULL)=0
Redraw - Ask to redraw the view.
wxGLContext * m_glRC
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
void DisplayStatus()
DisplayStatus - Update the status bar with the position information.
C3D_RENDER_OGL_LEGACY * m_3d_render_ogl_legacy
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.
void UnlockCtx(wxGLContext *aContext)
Function UnlockCtx allows other canvases to bind an OpenGL context.
void RenderEngineSet(RENDER_ENGINE aRenderEngine) noexcept
RenderEngineSet.
BOARD_ADAPTER & m_boardAdapter
float m_camera_moving_speed
static GL_CONTEXT_MANAGER & Get()
Function Get returns the GL_CONTEXT_MANAGER instance (singleton).
void restart_editingTimeOut_Timer()
restart_editingTimeOut_Timer - reset the editing timer
float ZoomGet() const
Definition: ccamera.cpp:510
#define NULL
CCAMERA & m_camera
bool m_mouse_was_moved
bool m_camera_is_moving
virtual void Interpolate(float t)
Interpolate - It will update the matrix to interpolate between T0 and T1 values.
Definition: ccamera.cpp:569
RENDER_ENGINE RenderEngineGet() const noexcept
RenderEngineGet.
bool SetCurWindowSize(const wxSize &aSize)
SetCurWindowSize - update the windows size of the camera.
Definition: ccamera.cpp:448
void LockCtx(wxGLContext *aContext, wxGLCanvas *aCanvas)
Function LockCtx sets a context as current and prevents other canvases from switching it.
bool m_is_opengl_initialized
C3D_RENDER_BASE * m_3d_render
const int scale
bool initializeOpenGL()
initializeOpenGL
bool m_opengl_supports_raytracing
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33
unsigned GetRunningMicroSecs()
Function GetRunningMicroSecs An alternate way to calculate an elapset time (in microsecondes) to clas...
wxGLContext * CreateCtx(wxGLCanvas *aCanvas, const wxGLContext *aOther=NULL)
Function CreateCtx creates a managed OpenGL context.
virtual void SetCurWindowSize(const wxSize &aSize)=0
SetCurWindowSize - Before each render, the canvas will tell the render what is the size of its window...
void render_pivot(float t, float aScale)
render_pivot - render the pivot cursor
INFOBAR_REPORTER is a wrapper for reporting to a WX_INFOBAR UI element.
Definition: reporter.h:286
bool ParametersChanged()
Function ParametersChanged.
Definition: ccamera.cpp:587
bool m_render_raytracing_was_requested

References _, GL_CONTEXT_MANAGER::CreateCtx(), DisplayStatus(), INFOBAR_REPORTER::Finalize(), Format(), GL_CONTEXT_MANAGER::Get(), HIDPI_GL_CANVAS::GetNativePixelSize(), GetRunningMicroSecs(), STATUSBAR_REPORTER::HasMessage(), initializeOpenGL(), CCAMERA::Interpolate(), GL_CONTEXT_MANAGER::LockCtx(), m_3d_render, m_3d_render_ogl_legacy, m_boardAdapter, m_camera, m_camera_is_moving, m_camera_moving_speed, m_glRC, m_is_opengl_initialized, m_logTrace, m_mouse_is_moving, m_mouse_was_moved, m_opengl_supports_raytracing, m_parentInfoBar, m_parentStatusBar, m_render_pivot, m_render_raytracing_was_requested, m_strtime_camera_movement, NULL, OPENGL_LEGACY, CCAMERA::ParametersChanged(), C3D_RENDER_BASE::Redraw(), render_pivot(), BOARD_ADAPTER::RenderEngineGet(), BOARD_ADAPTER::RenderEngineSet(), STATUSBAR_REPORTER::Report(), Request_refresh(), restart_editingTimeOut_Timer(), scale, C3D_RENDER_BASE::SetCurWindowSize(), CCAMERA::SetCurWindowSize(), STATUS_TEXT, GL_CONTEXT_MANAGER::UnlockCtx(), and CCAMERA::ZoomGet().

◆ OnResize()

void EDA_3D_CANVAS::OnResize ( wxSizeEvent &  event)
private

Definition at line 208 of file eda_3d_canvas.cpp.

209 {
210  this->Request_refresh();
211 }
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.

References Request_refresh().

◆ OnTimerTimeout_Editing()

void EDA_3D_CANVAS::OnTimerTimeout_Editing ( wxTimerEvent &  event)
private

Definition at line 698 of file eda_3d_canvas.cpp.

699 {
700  (void)event;
701 
702  m_mouse_is_moving = false;
703  m_mouse_was_moved = false;
704 
705  Request_refresh();
706 }
bool m_mouse_is_moving
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.
bool m_mouse_was_moved

References m_mouse_is_moving, m_mouse_was_moved, and Request_refresh().

Referenced by EDA_3D_CANVAS().

◆ OnTimerTimeout_Redraw()

void EDA_3D_CANVAS::OnTimerTimeout_Redraw ( wxTimerEvent &  event)
private

Definition at line 721 of file eda_3d_canvas.cpp.

722 {
723  wxPaintEvent redrawEvent;
724  wxPostEvent( this, redrawEvent );
725 }

Referenced by EDA_3D_CANVAS().

◆ releaseOpenGL()

void EDA_3D_CANVAS::releaseOpenGL ( )
private

releaseOpenGL - free created targets and openGL context

Definition at line 178 of file eda_3d_canvas.cpp.

179 {
180  if( m_glRC )
181  {
183 
184  delete m_3d_render_raytracing;
186 
187  delete m_3d_render_ogl_legacy;
189 
190  // This is just a copy of a pointer, can safely be set to NULL
191  m_3d_render = NULL;
192 
195  m_glRC = NULL;
196  }
197 }
C3D_RENDER_RAYTRACING * m_3d_render_raytracing
wxGLContext * m_glRC
C3D_RENDER_OGL_LEGACY * m_3d_render_ogl_legacy
void UnlockCtx(wxGLContext *aContext)
Function UnlockCtx allows other canvases to bind an OpenGL context.
static GL_CONTEXT_MANAGER & Get()
Function Get returns the GL_CONTEXT_MANAGER instance (singleton).
#define NULL
void LockCtx(wxGLContext *aContext, wxGLCanvas *aCanvas)
Function LockCtx sets a context as current and prevents other canvases from switching it.
C3D_RENDER_BASE * m_3d_render
void DestroyCtx(wxGLContext *aContext)
Function DestroyCtx destroys a managed OpenGL context.

References GL_CONTEXT_MANAGER::DestroyCtx(), GL_CONTEXT_MANAGER::Get(), GL_CONTEXT_MANAGER::LockCtx(), m_3d_render, m_3d_render_ogl_legacy, m_3d_render_raytracing, m_glRC, NULL, and GL_CONTEXT_MANAGER::UnlockCtx().

Referenced by OnCloseWindow(), and ~EDA_3D_CANVAS().

◆ ReloadRequest()

void EDA_3D_CANVAS::ReloadRequest ( BOARD aBoard = NULL,
S3D_CACHE aCachePointer = NULL 
)

Definition at line 289 of file eda_3d_canvas.cpp.

290 {
291  if( aCachePointer != NULL )
292  m_boardAdapter.Set3DCacheManager( aCachePointer );
293 
294  if( aBoard != NULL )
295  m_boardAdapter.SetBoard( aBoard );
296 
297  m_boardAdapter.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() );
298 
299  if( m_3d_render )
301 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
void SetBoard(BOARD *aBoard) noexcept
SetBoard - Set current board to be rendered.
BOARD_ADAPTER & m_boardAdapter
#define NULL
SETTINGS_MANAGER * GetSettingsManager()
void Set3DCacheManager(S3D_CACHE *aCachePointer) noexcept
Set3DCacheManager - Update the Cache manager pointer.
Definition: board_adapter.h:80
C3D_RENDER_BASE * m_3d_render
void SetColorSettings(COLOR_SETTINGS *aSettings) noexcept
void ReloadRequest()
ReloadRequest - !TODO: this must be reviewed to add flags to improve specific render.

References GetSettingsManager(), m_3d_render, m_boardAdapter, NULL, Pgm(), C3D_RENDER_BASE::ReloadRequest(), BOARD_ADAPTER::Set3DCacheManager(), BOARD_ADAPTER::SetBoard(), and BOARD_ADAPTER::SetColorSettings().

Referenced by EDA_3D_VIEWER::ReloadRequest(), PANEL_PREV_3D::UpdateDummyModule(), and PANEL_PREV_3D::View3DUpdate().

◆ render_pivot()

void EDA_3D_CANVAS::render_pivot ( float  t,
float  aScale 
)
private

render_pivot - render the pivot cursor

Parameters
ttime between 0.0 and 1.0
aScalescale to apply on the cursor

Definition at line 76 of file eda_3d_canvas_pivot.cpp.

77 {
78  wxASSERT( aScale >= 0.0f );
79  wxASSERT( t >= 0.0f );
80 
81  if( t > 1.0f )
82  t = 1.0f;
83 
84  const SFVEC3F &lookAtPos = m_camera.GetLookAtPos_T1();
85 
86  glDisable( GL_LIGHTING );
87  glDisable( GL_DEPTH_TEST );
88  glDisable( GL_CULL_FACE );
89 
90  // Set projection and modelview matrixes
91  // /////////////////////////////////////////////////////////////////////////
92  glMatrixMode( GL_PROJECTION );
93  glLoadMatrixf( glm::value_ptr( m_camera.GetProjectionMatrix() ) );
94 
95  glMatrixMode( GL_MODELVIEW );
96  glLoadIdentity();
97  glLoadMatrixf( glm::value_ptr( m_camera.GetViewMatrix() ) );
98 
99  glEnable( GL_COLOR_MATERIAL );
100  glColor4f( 0.0f, 1.0f, 0.0f, 0.75f - t * 0.75f );
101 
102  // Translate to the look at position
103  glTranslatef( lookAtPos.x, lookAtPos.y, lookAtPos.z );
104 
105  glScalef( aScale, aScale, aScale );
106 
107  pivot_render_triangles( t * 0.5f );
108 
109  t = t * 0.80f;
110  glScalef( 1.0f - t, 1.0f - t, 1.0f - t );
111  glColor4f( 0.0f, 1.0f, 0.0f, 0.8f - t );
112 
113  glPushMatrix();
114  glRotatef( t * 90.0f, 0.0f, 0.0f, 1.0f );
115  pivot_render_triangles( t * 0.5f );
116  glPopMatrix();
117 
118  glPushMatrix();
119  glRotatef( -t * 90.0f, 0.0f, 0.0f, 1.0f );
120  pivot_render_triangles( t * 0.5f );
121  glPopMatrix();
122 }
const SFVEC3F & GetLookAtPos_T1() const
Definition: ccamera.h:132
CCAMERA & m_camera
const glm::mat4 & GetViewMatrix() const
Definition: ccamera.cpp:419
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
static void pivot_render_triangles(float t)
const glm::mat4 & GetProjectionMatrix() const
Definition: ccamera.cpp:389

References CCAMERA::GetLookAtPos_T1(), CCAMERA::GetProjectionMatrix(), CCAMERA::GetViewMatrix(), m_camera, and pivot_render_triangles().

Referenced by OnPaint().

◆ RenderEngineChanged()

void EDA_3D_CANVAS::RenderEngineChanged ( )

RenderEngineChanged - Notify that the render engine was changed.

Definition at line 974 of file eda_3d_canvas.cpp.

975 {
976  switch( m_boardAdapter.RenderEngineGet() )
977  {
980  default: m_3d_render = NULL; break;
981  }
982 
983  if( m_3d_render )
985 
986  m_mouse_was_moved = false;
987 
988  Request_refresh();
989 }
C3D_RENDER_RAYTRACING * m_3d_render_raytracing
C3D_RENDER_OGL_LEGACY * m_3d_render_ogl_legacy
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.
BOARD_ADAPTER & m_boardAdapter
#define NULL
bool m_mouse_was_moved
RENDER_ENGINE RenderEngineGet() const noexcept
RenderEngineGet.
C3D_RENDER_BASE * m_3d_render
void ReloadRequest()
ReloadRequest - !TODO: this must be reviewed to add flags to improve specific render.

References m_3d_render, m_3d_render_ogl_legacy, m_3d_render_raytracing, m_boardAdapter, m_mouse_was_moved, NULL, OPENGL_LEGACY, RAYTRACING, C3D_RENDER_BASE::ReloadRequest(), BOARD_ADAPTER::RenderEngineGet(), and Request_refresh().

Referenced by EDA_3D_VIEWER::RenderEngineChanged().

◆ RenderRaytracingRequest()

void EDA_3D_CANVAS::RenderRaytracingRequest ( )

RenderRaytracingRequest - Request to render the current view in Raytracing mode.

Definition at line 304 of file eda_3d_canvas.cpp.

305 {
307 
308  if( m_3d_render )
310 
312  //m_mouse_was_moved = true;
313 
314  Request_refresh();
315 }
C3D_RENDER_RAYTRACING * m_3d_render_raytracing
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.
C3D_RENDER_BASE * m_3d_render
void ReloadRequest()
ReloadRequest - !TODO: this must be reviewed to add flags to improve specific render.
bool m_render_raytracing_was_requested

References m_3d_render, m_3d_render_raytracing, m_render_raytracing_was_requested, C3D_RENDER_BASE::ReloadRequest(), and Request_refresh().

Referenced by EDA_3D_CONTROLLER::RotateView(), and EDA_3D_CONTROLLER::ToggleOrtho().

◆ Request_refresh()

void EDA_3D_CANVAS::Request_refresh ( bool  aRedrawImmediately = true)

Request_refresh - Schedule a refresh update of the canvas.

Parameters
aRedrawImmediately- true will request a redraw, false will schedule a redraw, after a short timeout.

Definition at line 728 of file eda_3d_canvas.cpp.

729 {
730  if( aRedrawImmediately )
731  {
732  // On some systems, just calling Refresh does not work always
733  // (Issue experienced on Win7 MSYS2)
734  //Refresh();
735  //Update();
736 
737  // Using PostEvent will take priority to other events like mouse movements, keys, etc.
738  wxPaintEvent redrawEvent;
739  wxPostEvent( this, redrawEvent );
740 
741  // This behaves the same
742  // wxQueueEvent( this,
743  // From wxWidget documentation: "The heap-allocated and
744  // non-NULL event to queue, the function takes ownership of it."
745  // new wxPaintEvent()
746  // );
747  }
748  else
749  {
750  // Schedule a timed redraw
751  m_redraw_trigger_timer.Start( 10 , wxTIMER_ONE_SHOT );
752  }
753 }
wxTimer m_redraw_trigger_timer

References m_redraw_trigger_timer.

Referenced by EDA_3D_CONTROLLER::On3DGridSelection(), EDA_3D_VIEWER::OnActivate(), OnMouseMove(), OnMouseWheel(), OnPaint(), OnResize(), OnTimerTimeout_Editing(), EDA_3D_VIEWER::Process_Special_Functions(), RenderEngineChanged(), RenderRaytracingRequest(), request_start_moving_camera(), EDA_3D_CONTROLLER::RotateView(), SetView3D(), EDA_3D_VIEWER::takeScreenshot(), EDA_3D_CONTROLLER::ToggleOrtho(), EDA_3D_CONTROLLER::ToggleVisibility(), PANEL_PREV_3D::UpdateDummyModule(), and EDA_3D_CONTROLLER::ZoomRedraw().

◆ request_start_moving_camera()

void EDA_3D_CANVAS::request_start_moving_camera ( float  aMovingSpeed = 2.0f,
bool  aRenderPivot = true 
)
private

request_start_moving_camera - start a camera movement

Parameters
aMovingSpeedthe time speed
aRenderPivotif it should display pivot cursor while move

Definition at line 756 of file eda_3d_canvas.cpp.

757 {
758  wxASSERT( aMovingSpeed > FLT_EPSILON );
759 
760  // Fast forward the animation if the animation is disabled
761  if( !m_animation_enabled )
762  {
763  m_camera.Interpolate( 1.0f );
764  DisplayStatus();
765  Request_refresh();
766  return;
767  }
768 
769  // Map speed multipler option to actual multiplier value
770  // [1,2,3,4,5] -> [0.25, 0.5, 1, 2, 4]
771  aMovingSpeed *= ( 1 << m_moving_speed_multiplier ) / 8.0f;
772 
773  m_render_pivot = aRenderPivot;
774  m_camera_moving_speed = aMovingSpeed;
775 
777 
778  DisplayStatus();
779  Request_refresh();
780 
781  m_camera_is_moving = true;
782 
784 }
unsigned m_strtime_camera_movement
void stop_editingTimeOut_Timer()
stop_editingTimeOut_Timer - stop the editing time, so it will not timeout
void DisplayStatus()
DisplayStatus - Update the status bar with the position information.
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.
float m_camera_moving_speed
CCAMERA & m_camera
bool m_camera_is_moving
virtual void Interpolate(float t)
Interpolate - It will update the matrix to interpolate between T0 and T1 values.
Definition: ccamera.cpp:569
bool m_animation_enabled
int m_moving_speed_multiplier
unsigned GetRunningMicroSecs()
Function GetRunningMicroSecs An alternate way to calculate an elapset time (in microsecondes) to clas...

References DisplayStatus(), GetRunningMicroSecs(), CCAMERA::Interpolate(), m_animation_enabled, m_camera, m_camera_is_moving, m_camera_moving_speed, m_moving_speed_multiplier, m_render_pivot, m_strtime_camera_movement, Request_refresh(), and stop_editingTimeOut_Timer().

Referenced by move_pivot_based_on_cur_mouse_position(), and SetView3D().

◆ restart_editingTimeOut_Timer()

void EDA_3D_CANVAS::restart_editingTimeOut_Timer ( )
private

restart_editingTimeOut_Timer - reset the editing timer

Definition at line 715 of file eda_3d_canvas.cpp.

716 {
717  m_editing_timeout_timer.Start( m_3d_render->GetWaitForEditingTimeOut() , wxTIMER_ONE_SHOT );
718 }
wxTimer m_editing_timeout_timer
virtual int GetWaitForEditingTimeOut()=0
GetWaitForEditingTimeOut - Give the interface the time (in ms) that it should wait for editing or mov...
C3D_RENDER_BASE * m_3d_render

References C3D_RENDER_BASE::GetWaitForEditingTimeOut(), m_3d_render, and m_editing_timeout_timer.

Referenced by OnLeftUp(), OnMiddleUp(), OnMouseWheel(), OnPaint(), and SetView3D().

◆ SetEventDispatcher()

void EDA_3D_CANVAS::SetEventDispatcher ( TOOL_DISPATCHER aEventDispatcher)

Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.

Parameters
aEventDispatcheris the object that will be used for dispatching events. DRAW_PANEL_GAL does not take over the ownership. Passing NULL disconnects all event handlers from the DRAW_PANEL_GAL and parent frame.

Definition at line 499 of file eda_3d_canvas.cpp.

500 {
501  m_eventDispatcher = aEventDispatcher;
502 
503  if( m_eventDispatcher )
504  {
505  m_parent->Connect( wxEVT_TOOL,
506  wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
508  }
509  else
510  {
511  // While loop is used to be sure that all event handlers are removed.
512  while( m_parent->Disconnect( wxEVT_TOOL,
513  wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
514  NULL, m_eventDispatcher ) );
515  }
516 }
#define NULL
TOOL_DISPATCHER * m_eventDispatcher
virtual void DispatchWxCommand(wxCommandEvent &aEvent)
Function DispatchWxCommand() Processes wxCommands (mostly menu related events) and runs appropriate a...

References TOOL_DISPATCHER::DispatchWxCommand(), m_eventDispatcher, and NULL.

Referenced by PANEL_PREV_3D::PANEL_PREV_3D(), and EDA_3D_VIEWER::~EDA_3D_VIEWER().

◆ SetInfoBar()

void EDA_3D_CANVAS::SetInfoBar ( WX_INFOBAR aInfoBar)
inline

Definition at line 76 of file eda_3d_canvas.h.

77  {
78  m_parentInfoBar = aInfoBar;
79  }
WX_INFOBAR * m_parentInfoBar

References m_parentInfoBar.

◆ SetScaleFactor()

void HIDPI_GL_CANVAS::SetScaleFactor ( double  aFactor)
inherited

Set the canvas scale factor, probably for a hi-DPI display.

Definition at line 58 of file hidpi_gl_canvas.cpp.

59 {
60  m_scale_factor = aNewScaleFactor;
61 }
double m_scale_factor
The current scale factor (e.g.

References HIDPI_GL_CANVAS::m_scale_factor.

Referenced by PANEL_PREV_3D::loadCommonSettings(), EDA_3D_VIEWER::loadCommonSettings(), and KIGFX::OPENGL_GAL::updatedGalDisplayOptions().

◆ SetStatusBar()

void EDA_3D_CANVAS::SetStatusBar ( wxStatusBar *  aStatusBar)
inline

Definition at line 71 of file eda_3d_canvas.h.

72  {
73  m_parentStatusBar = aStatusBar;
74  }
wxStatusBar * m_parentStatusBar

References m_parentStatusBar.

◆ SetView3D()

bool EDA_3D_CANVAS::SetView3D ( int  aKeycode)

SetView3D - Helper function to call view commands.

Parameters
aKeycodeascii key commands
Returns
true if the key code was handled, false if no command found for this code.

Definition at line 813 of file eda_3d_canvas.cpp.

814 {
815  if( m_camera_is_moving )
816  return false;
817 
818  const float delta_move = m_delta_move_step_factor * m_camera.ZoomGet();
819  const float arrow_moving_time_speed = 8.0f;
820  bool handled = false;
821 
822  switch( aKeycode )
823  {
824  case WXK_SPACE:
826  return true;
827 
828  case WXK_LEFT:
831  m_camera.Pan_T1( SFVEC3F( -delta_move, 0.0f, 0.0f ) );
832  request_start_moving_camera( arrow_moving_time_speed, false );
833  return true;
834 
835  case WXK_RIGHT:
838  m_camera.Pan_T1( SFVEC3F( +delta_move, 0.0f, 0.0f ) );
839  request_start_moving_camera( arrow_moving_time_speed, false );
840  return true;
841 
842  case WXK_UP:
845  m_camera.Pan_T1( SFVEC3F( 0.0f, +delta_move, 0.0f ) );
846  request_start_moving_camera( arrow_moving_time_speed, false );
847  return true;
848 
849  case WXK_DOWN:
852  m_camera.Pan_T1( SFVEC3F( 0.0f, -delta_move, 0.0f ) );
853  request_start_moving_camera( arrow_moving_time_speed, false );
854  return true;
855 
856  case WXK_HOME:
859  m_camera.Reset_T1();
860  request_start_moving_camera( glm::min( glm::max( m_camera.ZoomGet(), 1/1.26f ), 1.26f ) );
861  return true;
862 
863  case WXK_END:
864  break;
865 
866  case WXK_TAB:
869  m_camera.RotateZ_T1( glm::radians( 45.0f ) );
871  handled = true;
872  break;
873 
874  case WXK_F1:
877 
878  if( m_camera.Zoom_T1( 1.26f ) ) // 3 steps per doubling
880 
881  return true;
882 
883  case WXK_F2:
886 
887  if( m_camera.Zoom_T1( 1/1.26f ) ) // 3 steps per halving
889 
890  return true;
891 
892  case ID_VIEW3D_RESET:
895  m_camera.Reset_T1();
896  request_start_moving_camera( glm::min( glm::max( m_camera.ZoomGet(), 0.5f ), 1.125f ) );
897  return true;
898 
899  case ID_VIEW3D_RIGHT:
902  m_camera.Reset_T1();
903  m_camera.RotateZ_T1( glm::radians( -90.0f ) );
904  m_camera.RotateX_T1( glm::radians( -90.0f ) );
906  return true;
907 
908  case ID_VIEW3D_LEFT:
911  m_camera.Reset_T1();
912  m_camera.RotateZ_T1( glm::radians( 90.0f ) );
913  m_camera.RotateX_T1( glm::radians( -90.0f ) );
915  return true;
916 
917  case ID_VIEW3D_FRONT:
920  m_camera.Reset_T1();
921  m_camera.RotateX_T1( glm::radians( -90.0f ) );
923  return true;
924 
925  case ID_VIEW3D_BACK:
928  m_camera.Reset_T1();
929  m_camera.RotateX_T1( glm::radians( -90.0f ) );
930  // The rotation angle should be 180.
931  // We use 179.999 (180 - epsilon) to avoid a full 360 deg rotation when
932  // using 180 deg if the previous rotated position was already 180 deg
933  m_camera.RotateZ_T1( glm::radians( 179.999f ) );
935  return true;
936 
937  case ID_VIEW3D_TOP:
940  m_camera.Reset_T1();
941  request_start_moving_camera( glm::min( glm::max( m_camera.ZoomGet(), 0.5f ), 1.125f ) );
942  return true;
943 
944  case ID_VIEW3D_BOTTOM:
947  m_camera.Reset_T1();
948  m_camera.RotateY_T1( glm::radians( 179.999f ) ); // Rotation = 180 - epsilon
949  request_start_moving_camera( glm::min( glm::max( m_camera.ZoomGet(), 0.5f ), 1.125f ) );
950  return true;
951 
952  case ID_VIEW3D_FLIP:
955  m_camera.RotateY_T1( glm::radians( 179.999f ) );
957  return true;
958 
959  default:
960  return false;
961  }
962 
963  m_mouse_was_moved = true;
964 
966 
967  DisplayStatus();
968  Request_refresh();
969 
970  return handled;
971 }
void request_start_moving_camera(float aMovingSpeed=2.0f, bool aRenderPivot=true)
request_start_moving_camera - start a camera movement
virtual void SetT0_and_T1_current_T()
SetT0_and_T1_current_T - This will set T0 and T1 with the current values.
Definition: ccamera.cpp:555
void DisplayStatus()
DisplayStatus - Update the status bar with the position information.
void Request_refresh(bool aRedrawImmediately=true)
Request_refresh - Schedule a refresh update of the canvas.
void restart_editingTimeOut_Timer()
restart_editingTimeOut_Timer - reset the editing timer
float ZoomGet() const
Definition: ccamera.cpp:510
CCAMERA & m_camera
bool m_mouse_was_moved
bool m_camera_is_moving
bool Zoom_T1(float aFactor)
Definition: ccamera.cpp:493
virtual void Pan_T1(const SFVEC3F &aDeltaOffsetInc)=0
void RotateX_T1(float aAngleInRadians)
Definition: ccamera.cpp:537
virtual void Reset_T1()
Definition: ccamera.cpp:103
void RotateY_T1(float aAngleInRadians)
Definition: ccamera.cpp:543
void move_pivot_based_on_cur_mouse_position()
move_pivot_based_on_cur_mouse_position - This function hits a ray to the board and start a moviment
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void RotateZ_T1(float aAngleInRadians)
Definition: ccamera.cpp:549
static const float m_delta_move_step_factor
void SetInterpolateMode(CAMERA_INTERPOLATION aInterpolateMode)
Definition: ccamera.h:200

References BEZIER, DisplayStatus(), EASING_IN_OUT, ID_VIEW3D_BACK, ID_VIEW3D_BOTTOM, ID_VIEW3D_FLIP, ID_VIEW3D_FRONT, ID_VIEW3D_LEFT, ID_VIEW3D_RESET, ID_VIEW3D_RIGHT, ID_VIEW3D_TOP, LINEAR, m_camera, m_camera_is_moving, m_delta_move_step_factor, m_mouse_was_moved, move_pivot_based_on_cur_mouse_position(), CCAMERA::Pan_T1(), Request_refresh(), request_start_moving_camera(), CCAMERA::Reset_T1(), restart_editingTimeOut_Timer(), CCAMERA::RotateX_T1(), CCAMERA::RotateY_T1(), CCAMERA::RotateZ_T1(), CCAMERA::SetInterpolateMode(), CCAMERA::SetT0_and_T1_current_T(), CCAMERA::Zoom_T1(), and CCAMERA::ZoomGet().

Referenced by EDA_3D_CONTROLLER::doZoomInOut(), EDA_3D_CONTROLLER::PanControl(), PANEL_PREV_3D::View3DBack(), PANEL_PREV_3D::View3DBottom(), PANEL_PREV_3D::View3DFront(), PANEL_PREV_3D::View3DLeft(), PANEL_PREV_3D::View3DRight(), PANEL_PREV_3D::View3DTop(), EDA_3D_CONTROLLER::ViewControl(), and EDA_3D_CONTROLLER::ZoomFitScreen().

◆ stop_editingTimeOut_Timer()

void EDA_3D_CANVAS::stop_editingTimeOut_Timer ( )
private

stop_editingTimeOut_Timer - stop the editing time, so it will not timeout

Definition at line 709 of file eda_3d_canvas.cpp.

710 {
712 }
wxTimer m_editing_timeout_timer

References m_editing_timeout_timer.

Referenced by OnLeftDown(), OnMiddleDown(), and request_start_moving_camera().

Member Data Documentation

◆ m_3d_render

◆ m_3d_render_ogl_legacy

C3D_RENDER_OGL_LEGACY* EDA_3D_CANVAS::m_3d_render_ogl_legacy
private

Definition at line 252 of file eda_3d_canvas.h.

Referenced by OnPaint(), releaseOpenGL(), and RenderEngineChanged().

◆ m_3d_render_raytracing

C3D_RENDER_RAYTRACING* EDA_3D_CANVAS::m_3d_render_raytracing
private

Definition at line 251 of file eda_3d_canvas.h.

Referenced by releaseOpenGL(), RenderEngineChanged(), and RenderRaytracingRequest().

◆ m_animation_enabled

bool EDA_3D_CANVAS::m_animation_enabled
private

◆ m_boardAdapter

BOARD_ADAPTER& EDA_3D_CANVAS::m_boardAdapter
private

◆ m_camera

◆ m_camera_is_moving

bool EDA_3D_CANVAS::m_camera_is_moving
private

◆ m_camera_moving_speed

float EDA_3D_CANVAS::m_camera_moving_speed
private

Definition at line 243 of file eda_3d_canvas.h.

Referenced by OnPaint(), and request_start_moving_camera().

◆ m_delta_move_step_factor

const float EDA_3D_CANVAS::m_delta_move_step_factor = 0.7f
staticprivate

Definition at line 254 of file eda_3d_canvas.h.

Referenced by OnMouseWheel(), and SetView3D().

◆ m_editing_timeout_timer

wxTimer EDA_3D_CANVAS::m_editing_timeout_timer
private

Definition at line 235 of file eda_3d_canvas.h.

Referenced by restart_editingTimeOut_Timer(), and stop_editingTimeOut_Timer().

◆ m_eventDispatcher

TOOL_DISPATCHER* EDA_3D_CANVAS::m_eventDispatcher
private

Definition at line 228 of file eda_3d_canvas.h.

Referenced by OnEvent(), and SetEventDispatcher().

◆ m_glRC

wxGLContext* EDA_3D_CANVAS::m_glRC
private

Definition at line 232 of file eda_3d_canvas.h.

Referenced by OnPaint(), and releaseOpenGL().

◆ m_is_opengl_initialized

bool EDA_3D_CANVAS::m_is_opengl_initialized
private

Definition at line 233 of file eda_3d_canvas.h.

Referenced by initializeOpenGL(), and OnPaint().

◆ m_mouse_is_moving

bool EDA_3D_CANVAS::m_mouse_is_moving
private

◆ m_mouse_was_moved

bool EDA_3D_CANVAS::m_mouse_was_moved
private

◆ m_moving_speed_multiplier

int EDA_3D_CANVAS::m_moving_speed_multiplier
private

◆ m_opengl_supports_raytracing

bool EDA_3D_CANVAS::m_opengl_supports_raytracing
private

Definition at line 257 of file eda_3d_canvas.h.

Referenced by initializeOpenGL(), and OnPaint().

◆ m_parentInfoBar

WX_INFOBAR* EDA_3D_CANVAS::m_parentInfoBar
private

Definition at line 230 of file eda_3d_canvas.h.

Referenced by OnPaint(), and SetInfoBar().

◆ m_parentStatusBar

wxStatusBar* EDA_3D_CANVAS::m_parentStatusBar
private

Definition at line 229 of file eda_3d_canvas.h.

Referenced by DisplayStatus(), OnPaint(), and SetStatusBar().

◆ m_redraw_trigger_timer

wxTimer EDA_3D_CANVAS::m_redraw_trigger_timer
private

Definition at line 237 of file eda_3d_canvas.h.

Referenced by Request_refresh().

◆ m_render_pivot

bool EDA_3D_CANVAS::m_render_pivot
private

Definition at line 242 of file eda_3d_canvas.h.

Referenced by OnPaint(), and request_start_moving_camera().

◆ m_render_raytracing_was_requested

bool EDA_3D_CANVAS::m_render_raytracing_was_requested
private

Definition at line 258 of file eda_3d_canvas.h.

Referenced by OnPaint(), and RenderRaytracingRequest().

◆ m_strtime_camera_movement

unsigned EDA_3D_CANVAS::m_strtime_camera_movement
private

Definition at line 244 of file eda_3d_canvas.h.

Referenced by OnPaint(), and request_start_moving_camera().


The documentation for this class was generated from the following files: