Commit e8e6b1f7 authored by Maciej Suminski's avatar Maciej Suminski Committed by Wayne Stambaugh

Commit Launchpad merge request 194664.

* Modify error handling for OpenGL backend.
* Correct Doxygen comments notation.
parents f10865e5 d250ae5d
...@@ -93,7 +93,10 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin ...@@ -93,7 +93,10 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
Connect( KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE, Connect( KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE,
wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
// Set up timer that prevents too frequent redraw commands
m_refreshTimer.SetOwner( this ); m_refreshTimer.SetOwner( this );
m_pendingRefresh = false;
m_drawing = false;
Connect( wxEVT_TIMER, wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this ); Connect( wxEVT_TIMER, wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this );
this->SetFocus(); this->SetFocus();
...@@ -121,18 +124,25 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) ...@@ -121,18 +124,25 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
m_pendingRefresh = false; m_pendingRefresh = false;
m_lastRefresh = wxGetLocalTimeMillis(); m_lastRefresh = wxGetLocalTimeMillis();
m_gal->BeginDrawing(); if( !m_drawing )
m_gal->SetBackgroundColor( KIGFX::COLOR4D( 0.0, 0.0, 0.0, 1.0 ) ); {
m_gal->ClearScreen(); m_drawing = true;
m_gal->BeginDrawing();
m_gal->SetBackgroundColor( KIGFX::COLOR4D( 0.0, 0.0, 0.0, 1.0 ) );
m_gal->ClearScreen();
m_view->ClearTargets(); m_view->ClearTargets();
// Grid has to be redrawn only when the NONCACHED target is redrawn // Grid has to be redrawn only when the NONCACHED target is redrawn
if( m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) ) if( m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
m_gal->DrawGrid(); m_gal->DrawGrid();
m_view->Redraw(); m_view->Redraw();
m_gal->DrawCursor( m_viewControls->GetCursorPosition() ); m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
m_gal->EndDrawing(); m_gal->EndDrawing();
m_drawing = false;
}
} }
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <gal/opengl/vertex_manager.h> #include <gal/opengl/vertex_manager.h>
#include <gal/opengl/vertex_item.h> #include <gal/opengl/vertex_item.h>
#include <gal/opengl/shader.h> #include <gal/opengl/shader.h>
#include <confirm.h>
#include <wx/log.h> #include <wx/log.h>
#include <list> #include <list>
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
...@@ -315,7 +316,7 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget ) ...@@ -315,7 +316,7 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget )
if( aTarget == NULL ) if( aTarget == NULL )
{ {
wxLogError( wxT( "Run out of memory" ) ); DisplayError( NULL, wxT( "Run out of memory" ) );
return false; return false;
} }
} }
...@@ -439,7 +440,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize ) ...@@ -439,7 +440,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
if( newContainer == NULL ) if( newContainer == NULL )
{ {
wxLogError( wxT( "Run out of memory" ) ); DisplayError( NULL, wxT( "Run out of memory" ) );
return false; return false;
} }
...@@ -458,7 +459,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize ) ...@@ -458,7 +459,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
if( newContainer == NULL ) if( newContainer == NULL )
{ {
wxLogError( wxT( "Run out of memory" ) ); DisplayError( NULL, wxT( "Run out of memory" ) );
return false; return false;
} }
......
...@@ -32,9 +32,12 @@ ...@@ -32,9 +32,12 @@
#include <gal/opengl/noncached_container.h> #include <gal/opengl/noncached_container.h>
#include <gal/opengl/shader.h> #include <gal/opengl/shader.h>
#include <typeinfo> #include <typeinfo>
#include <wx/log.h> #include <wx/msgdlg.h>
#include <confirm.h>
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
#include <profile.h> #include <profile.h>
#include <wx/debug.h>
#include <wx/log.h>
#endif #endif
using namespace KIGFX; using namespace KIGFX;
...@@ -70,7 +73,7 @@ void GPU_MANAGER::SetShader( SHADER& aShader ) ...@@ -70,7 +73,7 @@ void GPU_MANAGER::SetShader( SHADER& aShader )
if( m_shaderAttrib == -1 ) if( m_shaderAttrib == -1 )
{ {
wxLogFatalError( wxT( "Could not get the shader attribute location" ) ); DisplayError( NULL, wxT( "Could not get the shader attribute location" ) );
} }
} }
...@@ -205,7 +208,7 @@ void GPU_CACHED_MANAGER::uploadToGpu() ...@@ -205,7 +208,7 @@ void GPU_CACHED_MANAGER::uploadToGpu()
if( glGetError() != GL_NO_ERROR ) if( glGetError() != GL_NO_ERROR )
{ {
wxLogError( wxT( "Error during data upload to the GPU memory" ) ); DisplayError( NULL, wxT( "Error during data upload to the GPU memory" ) );
} }
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
......
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
*/ */
#include <gal/opengl/opengl_compositor.h> #include <gal/opengl/opengl_compositor.h>
#include <wx/log.h> #include <wx/msgdlg.h>
#include <confirm.h>
using namespace KIGFX; using namespace KIGFX;
...@@ -97,9 +98,9 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer() ...@@ -97,9 +98,9 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
if( usedBuffers() >= m_maxBuffers ) if( usedBuffers() >= m_maxBuffers )
{ {
wxLogError( wxT( "Cannot create more framebuffers. OpenGL rendering backend requires at" DisplayError( NULL, wxT( "Cannot create more framebuffers. OpenGL rendering "
"least 3 framebuffers. You may try to update/change " "backend requires at least 3 framebuffers. You may try to update/change "
"your graphic drivers." ) ); "your graphic drivers." ) );
return 0; // Unfortunately we have no more free buffers left return 0; // Unfortunately we have no more free buffers left
} }
...@@ -131,38 +132,38 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer() ...@@ -131,38 +132,38 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
switch( status ) switch( status )
{ {
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
wxLogFatalError( wxT( "Cannot create the framebuffer." ) ); DisplayError( NULL, wxT( "Cannot create the framebuffer." ) );
break; break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
wxLogFatalError( wxT( "The framebuffer attachment points are incomplete." ) ); DisplayError( NULL, wxT( "The framebuffer attachment points are incomplete." ) );
break; break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
wxLogFatalError( wxT( "The framebuffer does not have at least " DisplayError( NULL, wxT( "The framebuffer does not have at least "
"one image attached to it." ) ); "one image attached to it." ) );
break; break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
wxLogFatalError( wxT( "The framebuffer read buffer is incomplete." ) ); DisplayError( NULL, wxT( "The framebuffer read buffer is incomplete." ) );
break; break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT: case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
wxLogFatalError( wxT( "The combination of internal formats of the attached images " DisplayError( NULL, wxT( "The combination of internal formats of the attached images "
"violates an implementation-dependent set of restrictions." ) ); "violates an implementation-dependent set of restrictions." ) );
break; break;
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT: case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
wxLogFatalError( wxT( "GL_RENDERBUFFER_SAMPLES is not the same " DisplayError( NULL, wxT( "GL_RENDERBUFFER_SAMPLES is not the same "
"for all attached renderbuffers" ) ); "for all attached renderbuffers" ) );
break; break;
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT: case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
wxLogFatalError( wxT( "Framebuffer incomplete layer targets errors." ) ); DisplayError( NULL, wxT( "Framebuffer incomplete layer targets errors." ) );
break; break;
default: default:
wxLogFatalError( wxT( "Cannot create the framebuffer." ) ); DisplayError( NULL, wxT( "Cannot create the framebuffer." ) );
break; break;
} }
...@@ -223,7 +224,7 @@ void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle ) ...@@ -223,7 +224,7 @@ void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
if( aBufferHandle == 0 || aBufferHandle > usedBuffers() ) if( aBufferHandle == 0 || aBufferHandle > usedBuffers() )
{ {
wxLogError( wxT( "Wrong framebuffer handle" ) ); DisplayError( NULL, wxT( "Wrong framebuffer handle" ) );
return; return;
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <wx/log.h> #include <wx/log.h>
#include <macros.h> #include <macros.h>
#include <confirm.h>
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
#include <profile.h> #include <profile.h>
#endif /* __WXDEBUG__ */ #endif /* __WXDEBUG__ */
...@@ -93,7 +94,8 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, ...@@ -93,7 +94,8 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
if( tesselator == NULL ) if( tesselator == NULL )
{ {
wxLogFatalError( wxT( "Could not create the tesselator" ) ); DisplayError( parentWindow, wxT( "Could not create the tesselator" ) );
exit( 1 );
} }
gluTessProperty( tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE ); gluTessProperty( tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE );
...@@ -144,13 +146,22 @@ void OPENGL_GAL::BeginDrawing() ...@@ -144,13 +146,22 @@ void OPENGL_GAL::BeginDrawing()
if( !isShaderInitialized ) if( !isShaderInitialized )
{ {
if( !shader.LoadBuiltinShader( 0, SHADER_TYPE_VERTEX ) ) if( !shader.LoadBuiltinShader( 0, SHADER_TYPE_VERTEX ) )
wxLogFatalError( wxT( "Cannot compile vertex shader!" ) ); {
DisplayError( parentWindow, wxT( "Cannot compile vertex shader!" ) );
exit( 1 );
}
if( !shader.LoadBuiltinShader( 1, SHADER_TYPE_FRAGMENT ) ) if( !shader.LoadBuiltinShader( 1, SHADER_TYPE_FRAGMENT ) )
wxLogFatalError( wxT( "Cannot compile fragment shader!" ) ); {
DisplayError( parentWindow, wxT( "Cannot compile fragment shader!" ) );
exit( 1 );
}
if( !shader.Link() ) if( !shader.Link() )
wxLogFatalError( wxT( "Cannot link the shaders!" ) ); {
DisplayError( parentWindow, wxT( "Cannot link the shaders!" ) );
exit( 1 );
}
// Make VBOs use shaders // Make VBOs use shaders
cachedManager.SetShader( shader ); cachedManager.SetShader( shader );
...@@ -915,7 +926,7 @@ void OPENGL_GAL::initGlew() ...@@ -915,7 +926,7 @@ void OPENGL_GAL::initGlew()
if( GLEW_OK != err ) if( GLEW_OK != err )
{ {
wxLogError( wxString::FromUTF8( (char*) glewGetErrorString( err ) ) ); DisplayError( parentWindow, wxString::FromUTF8( (char*) glewGetErrorString( err ) ) );
exit( 1 ); exit( 1 );
} }
else else
...@@ -931,21 +942,21 @@ void OPENGL_GAL::initGlew() ...@@ -931,21 +942,21 @@ void OPENGL_GAL::initGlew()
} }
else else
{ {
wxLogError( wxT( "OpenGL Version 2.1 is not supported!" ) ); DisplayError( parentWindow, wxT( "OpenGL Version 2.1 is not supported!" ) );
exit( 1 ); exit( 1 );
} }
// Framebuffers have to be supported // Framebuffers have to be supported
if( !GLEW_EXT_framebuffer_object ) if( !GLEW_EXT_framebuffer_object )
{ {
wxLogError( wxT( "Framebuffer objects are not supported!" ) ); DisplayError( parentWindow, wxT( "Framebuffer objects are not supported!" ) );
exit( 1 ); exit( 1 );
} }
// Vertex buffer have to be supported // Vertex buffer have to be supported
if( !GLEW_ARB_vertex_buffer_object ) if( !GLEW_ARB_vertex_buffer_object )
{ {
wxLogError( wxT( "Vertex buffer objects are not supported!" ) ); DisplayError( parentWindow, wxT( "Vertex buffer objects are not supported!" ) );
exit( 1 ); exit( 1 );
} }
...@@ -1040,10 +1051,12 @@ void CALLBACK EdgeCallback( GLboolean aEdgeFlag ) ...@@ -1040,10 +1051,12 @@ void CALLBACK EdgeCallback( GLboolean aEdgeFlag )
void CALLBACK ErrorCallback( GLenum aErrorCode ) void CALLBACK ErrorCallback( GLenum aErrorCode )
{ {
const GLubyte* estring; const GLubyte* eString = gluErrorString( aErrorCode );
DisplayError( NULL, wxString( std::string( "Tessellation error: " ) +
std::string( (const char*)( eString ) ) ) );
estring = gluErrorString( aErrorCode ); exit( 1 );
wxLogError( wxT( "Tessellation Error: %s" ), (char*) estring );
} }
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include <fstream> #include <fstream>
#include <wx/log.h> #include <wx/log.h>
#include <wx/gdicmn.h>
#include <confirm.h>
#include <gal/opengl/shader.h> #include <gal/opengl/shader.h>
#include "shader_src.h" #include "shader_src.h"
...@@ -201,7 +203,7 @@ std::string SHADER::readSource( std::string aShaderSourceName ) ...@@ -201,7 +203,7 @@ std::string SHADER::readSource( std::string aShaderSourceName )
if( !inputFile ) if( !inputFile )
{ {
wxLogError( wxString::FromUTF8( "Can't read the shader source: " ) + DisplayError( NULL, wxString::FromUTF8( "Can't read the shader source: " ) +
wxString( aShaderSourceName.c_str(), wxConvUTF8 ) ); wxString( aShaderSourceName.c_str(), wxConvUTF8 ) );
exit( 1 ); exit( 1 );
} }
...@@ -223,7 +225,7 @@ bool SHADER::addSource( const std::string& aShaderSource, SHADER_TYPE aShaderTyp ...@@ -223,7 +225,7 @@ bool SHADER::addSource( const std::string& aShaderSource, SHADER_TYPE aShaderTyp
{ {
if( isShaderLinked ) if( isShaderLinked )
{ {
wxLogError( wxString::FromUTF8( "Shader is already linked!" ) ); wxLogDebug( wxT( "Shader is already linked!" ) );
} }
// Create the program // Create the program
...@@ -259,7 +261,7 @@ bool SHADER::addSource( const std::string& aShaderSource, SHADER_TYPE aShaderTyp ...@@ -259,7 +261,7 @@ bool SHADER::addSource( const std::string& aShaderSource, SHADER_TYPE aShaderTyp
if( status != GL_TRUE ) if( status != GL_TRUE )
{ {
wxLogError( wxT( "Shader compilation error" ) ); DisplayError( NULL, wxT( "Shader compilation error" ) );
shaderInfo( shaderNumber ); shaderInfo( shaderNumber );
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <gal/opengl/noncached_container.h> #include <gal/opengl/noncached_container.h>
#include <gal/opengl/gpu_manager.h> #include <gal/opengl/gpu_manager.h>
#include <gal/opengl/vertex_item.h> #include <gal/opengl/vertex_item.h>
#include <confirm.h>
using namespace KIGFX; using namespace KIGFX;
...@@ -55,7 +56,7 @@ void VERTEX_MANAGER::Vertex( GLfloat aX, GLfloat aY, GLfloat aZ ) const ...@@ -55,7 +56,7 @@ void VERTEX_MANAGER::Vertex( GLfloat aX, GLfloat aY, GLfloat aZ ) const
if( newVertex == NULL ) if( newVertex == NULL )
{ {
wxLogError( wxT( "Vertex allocation error" ) ); DisplayError( NULL, wxT( "Vertex allocation error" ) );
return; return;
} }
...@@ -70,7 +71,7 @@ void VERTEX_MANAGER::Vertices( const VERTEX aVertices[], unsigned int aSize ) co ...@@ -70,7 +71,7 @@ void VERTEX_MANAGER::Vertices( const VERTEX aVertices[], unsigned int aSize ) co
if( newVertex == NULL ) if( newVertex == NULL )
{ {
wxLogError( wxT( "Vertex allocation error" ) ); DisplayError( NULL, wxT( "Vertex allocation error" ) );
return; return;
} }
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <tool/action_manager.h> #include <tool/action_manager.h>
#include <wxPcbStruct.h> #include <wxPcbStruct.h>
#include <confirm.h>
#include <class_drawpanel_gal.h> #include <class_drawpanel_gal.h>
using boost::optional; using boost::optional;
...@@ -136,11 +137,10 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool ) ...@@ -136,11 +137,10 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
if( aTool->GetType() == INTERACTIVE ) if( aTool->GetType() == INTERACTIVE )
{ {
bool initState = static_cast<TOOL_INTERACTIVE*>( aTool )->Init(); if( !static_cast<TOOL_INTERACTIVE*>( aTool )->Init() )
if( !initState )
{ {
wxLogError( wxT( "Initialization of the %s tool failed" ), aTool->GetName().c_str() ); DisplayError( NULL, wxString( std::string( "Initialization of the %s tool failed" ) +
aTool->GetName() ) );
// Unregister the tool // Unregister the tool
m_toolState.erase( aTool ); m_toolState.erase( aTool );
......
...@@ -99,7 +99,7 @@ public: ...@@ -99,7 +99,7 @@ public:
} }
/// @copydoc wxWindow::Refresh() /// @copydoc wxWindow::Refresh()
virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ); void Refresh( bool eraseBackground = true, const wxRect* rect = NULL );
/** /**
* Function SetEventDispatcher() * Function SetEventDispatcher()
...@@ -121,18 +121,35 @@ protected: ...@@ -121,18 +121,35 @@ protected:
static const int MinRefreshPeriod = 17; ///< 60 FPS. static const int MinRefreshPeriod = 17; ///< 60 FPS.
wxLongLong m_lastRefresh; ///< Last time the panel was refreshed /// Last timestamp when the panel was refreshed
wxLongLong m_lastRefresh;
/// Is there a redraw event requested?
bool m_pendingRefresh; bool m_pendingRefresh;
/// True if GAL is currently redrawing the view
bool m_drawing;
/// Timer responsible for preventing too frequent refresh
wxTimer m_refreshTimer; wxTimer m_refreshTimer;
KIGFX::GAL* m_gal; ///< Interface for drawing objects on a 2D-surface /// Interface for drawing objects on a 2D-surface
KIGFX::VIEW* m_view; ///< Stores view settings (scale, center, etc.) KIGFX::GAL* m_gal;
///< and items to be drawn
KIGFX::PAINTER* m_painter; ///< Contains information about how to draw items /// Stores view settings (scale, center, etc.) and items to be drawn
///< using GAL KIGFX::VIEW* m_view;
KIGFX::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.)
GalType m_currentGal; ///< Currently used GAL /// Contains information about how to draw items using GAL
TOOL_DISPATCHER* m_eventDispatcher; ///< Processes and forwards events to tools KIGFX::PAINTER* m_painter;
/// Control for VIEW (moving, zooming, etc.)
KIGFX::WX_VIEW_CONTROLS* m_viewControls;
/// Currently used GAL
GalType m_currentGal;
/// Processes and forwards events to tools
TOOL_DISPATCHER* m_eventDispatcher;
}; };
#endif #endif
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <class_module.h> #include <class_module.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <view/view_controls.h> #include <view/view_controls.h>
#include <confirm.h>
#include "common_actions.h" #include "common_actions.h"
#include "selection_tool.h" #include "selection_tool.h"
...@@ -68,7 +69,7 @@ bool MOVE_TOOL::Init() ...@@ -68,7 +69,7 @@ bool MOVE_TOOL::Init()
} }
else else
{ {
wxLogError( wxT( "pcbnew.InteractiveSelection tool is not available" ) ); DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) );
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment