Try to fix Bug #1431765 (Pcbnew crashes in GAL when entering 3d display when a board outline is not closed)
This change modify the way warning messages are displayed: now the are displayed outside a paint event.
This commit is contained in:
parent
1d2e2e555b
commit
115cb2d647
|
@ -44,7 +44,7 @@
|
|||
|
||||
#include <3d_struct.h>
|
||||
#include <class_module.h>
|
||||
|
||||
|
||||
class BOARD_DESIGN_SETTINGS;
|
||||
class EDA_3D_FRAME;
|
||||
class CPOLYGONS_LIST;
|
||||
|
@ -132,9 +132,11 @@ public:
|
|||
/**
|
||||
* Function CreateDrawGL_List
|
||||
* Prepares the parameters of the OpenGL draw list
|
||||
* creates the OpenGL draw list items (board, grid ...
|
||||
* creates the OpenGL draw list items (board, grid ...)
|
||||
* @param aErrorMessages = a wxString which will filled with error messages,
|
||||
* if any
|
||||
*/
|
||||
void CreateDrawGL_List();
|
||||
void CreateDrawGL_List( wxString* aErrorMessages );
|
||||
void InitGL();
|
||||
void SetLights();
|
||||
|
||||
|
@ -209,15 +211,17 @@ private:
|
|||
* Called by CreateDrawGL_List()
|
||||
* Populates the OpenGL GL_ID_BOARD draw list with board items only on copper layers.
|
||||
* 3D footprint shapes, tech layers and aux layers are not on this list
|
||||
* Fills aErrorMessages with error messages created by some calculation function
|
||||
*/
|
||||
void BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList);
|
||||
void BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList, wxString* aErrorMessages );
|
||||
|
||||
/**
|
||||
* Function BuildTechLayers3DView
|
||||
* Called by CreateDrawGL_List()
|
||||
* Populates the OpenGL GL_ID_TECH_LAYERS draw list with items on tech layers
|
||||
* Add error messages in aErrorMessages, if any
|
||||
*/
|
||||
void BuildTechLayers3DView();
|
||||
void BuildTechLayers3DView( wxString* aErrorMessages );
|
||||
|
||||
/**
|
||||
* Function BuildShadowList
|
||||
|
@ -301,7 +305,7 @@ private:
|
|||
std::vector<S3D_MODEL_PARSER *>& model_parsers_list,
|
||||
std::vector<wxString>& model_filename_list );
|
||||
|
||||
void GenerateFakeShadowsTextures();
|
||||
void GenerateFakeShadowsTextures( wxString* aErrorMessages );
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
|
|
@ -110,7 +110,7 @@ void EDA_3D_CANVAS::Create_and_Render_Shadow_Buffer( GLuint *aDst_gl_texture,
|
|||
CIMAGE imgDepthBufferAux( aTexture_size, aTexture_size );
|
||||
|
||||
imgDepthBuffer.setPixelsFromNormalizedFloat( depthbufferFloat );
|
||||
|
||||
|
||||
free( depthbufferFloat );
|
||||
|
||||
wxString filename;
|
||||
|
@ -160,7 +160,7 @@ void EDA_3D_CANVAS::Create_and_Render_Shadow_Buffer( GLuint *aDst_gl_texture,
|
|||
|
||||
#define SHADOW_BOARD_SCALE 1.5f
|
||||
|
||||
void EDA_3D_CANVAS::GenerateFakeShadowsTextures()
|
||||
void EDA_3D_CANVAS::GenerateFakeShadowsTextures( wxString* aErrorMessages )
|
||||
{
|
||||
if( m_shadow_init == true )
|
||||
{
|
||||
|
@ -168,7 +168,7 @@ void EDA_3D_CANVAS::GenerateFakeShadowsTextures()
|
|||
}
|
||||
|
||||
// Init info 3d parameters and create gl lists:
|
||||
CreateDrawGL_List();
|
||||
CreateDrawGL_List( aErrorMessages );
|
||||
|
||||
m_shadow_init = true;
|
||||
|
||||
|
@ -225,6 +225,8 @@ void EDA_3D_CANVAS::Redraw()
|
|||
if( !IsShown() )
|
||||
return;
|
||||
|
||||
wxString errorMessages;
|
||||
|
||||
SetCurrent( *m_glRC );
|
||||
|
||||
// Set the OpenGL viewport according to the client size of this canvas.
|
||||
|
@ -240,7 +242,7 @@ void EDA_3D_CANVAS::Redraw()
|
|||
if( isEnabled( FL_MODULE ) && isRealisticMode() &&
|
||||
isEnabled( FL_RENDER_SHADOWS ) )
|
||||
{
|
||||
GenerateFakeShadowsTextures();
|
||||
GenerateFakeShadowsTextures( &errorMessages );
|
||||
}
|
||||
|
||||
// *MUST* be called *after* SetCurrent( ):
|
||||
|
@ -251,9 +253,9 @@ void EDA_3D_CANVAS::Redraw()
|
|||
glClearStencil( 0 );
|
||||
glClearDepth( 1.0 );
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
|
||||
|
||||
|
||||
glShadeModel( GL_SMOOTH );
|
||||
|
||||
|
||||
// Draw background
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
|
@ -336,7 +338,7 @@ void EDA_3D_CANVAS::Redraw()
|
|||
|
||||
|
||||
if( ! m_glLists[GL_ID_BOARD] || ! m_glLists[GL_ID_TECH_LAYERS] )
|
||||
CreateDrawGL_List();
|
||||
CreateDrawGL_List( &errorMessages );
|
||||
|
||||
if( isEnabled( FL_AXIS ) && m_glLists[GL_ID_AXIS] )
|
||||
glCallList( m_glLists[GL_ID_AXIS] );
|
||||
|
@ -352,7 +354,7 @@ void EDA_3D_CANVAS::Redraw()
|
|||
if( isEnabled( FL_MODULE ) )
|
||||
{
|
||||
if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] )
|
||||
CreateDrawGL_List();
|
||||
CreateDrawGL_List( &errorMessages );
|
||||
}
|
||||
|
||||
glEnable( GL_BLEND );
|
||||
|
@ -402,7 +404,7 @@ void EDA_3D_CANVAS::Redraw()
|
|||
if( isEnabled( FL_COMMENTS ) || isEnabled( FL_COMMENTS ) )
|
||||
{
|
||||
if( ! m_glLists[GL_ID_AUX_LAYERS] )
|
||||
CreateDrawGL_List();
|
||||
CreateDrawGL_List( &errorMessages );
|
||||
|
||||
glCallList( m_glLists[GL_ID_AUX_LAYERS] );
|
||||
}
|
||||
|
@ -450,7 +452,7 @@ void EDA_3D_CANVAS::Redraw()
|
|||
if( isEnabled( FL_MODULE ) )
|
||||
{
|
||||
if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] )
|
||||
CreateDrawGL_List();
|
||||
CreateDrawGL_List( &errorMessages );
|
||||
|
||||
glCallList( m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] );
|
||||
}
|
||||
|
@ -492,6 +494,9 @@ void EDA_3D_CANVAS::Redraw()
|
|||
}
|
||||
|
||||
SwapBuffers();
|
||||
|
||||
if( !errorMessages.IsEmpty() )
|
||||
wxLogMessage( errorMessages );
|
||||
}
|
||||
|
||||
|
||||
|
@ -571,7 +576,8 @@ void EDA_3D_CANVAS::BuildShadowList( GLuint aFrontList, GLuint aBacklist, GLuint
|
|||
}
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::BuildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList )
|
||||
void EDA_3D_CANVAS::BuildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
|
||||
wxString* aErrorMessages )
|
||||
{
|
||||
BOARD* pcb = GetBoard();
|
||||
|
||||
|
@ -609,10 +615,12 @@ void EDA_3D_CANVAS::BuildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList )
|
|||
|
||||
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) )
|
||||
{
|
||||
msg << wxT("\n\n") <<
|
||||
_("Unable to calculate the board outlines.\n"
|
||||
"Therefore use the board boundary box.");
|
||||
wxMessageBox( msg );
|
||||
if( aErrorMessages )
|
||||
{
|
||||
*aErrorMessages << msg << wxT("\n") <<
|
||||
_("Unable to calculate the board outlines.\n"
|
||||
"Therefore use the board boundary box.") << wxT("\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
CPOLYGONS_LIST bufferZonesPolys;
|
||||
|
@ -878,7 +886,7 @@ void EDA_3D_CANVAS::BuildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList )
|
|||
}
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::BuildTechLayers3DView()
|
||||
void EDA_3D_CANVAS::BuildTechLayers3DView( wxString* aErrorMessages )
|
||||
{
|
||||
BOARD* pcb = GetBoard();
|
||||
bool useTextures = isRealisticMode() && isEnabled( FL_RENDER_TEXTURES );
|
||||
|
@ -899,15 +907,23 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
|
|||
allLayerHoles.reserve( 20000 );
|
||||
|
||||
CPOLYGONS_LIST bufferPcbOutlines; // stores the board main outlines
|
||||
|
||||
// Build a polygon from edge cut items
|
||||
wxString msg;
|
||||
|
||||
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) )
|
||||
{
|
||||
msg << wxT("\n\n") <<
|
||||
_("Unable to calculate the board outlines.\n"
|
||||
"Therefore use the board boundary box.");
|
||||
wxMessageBox( msg );
|
||||
#if 0
|
||||
// Usually this message is already shown when the copper layers are built
|
||||
// So do not show it twice.
|
||||
// TODO: display it only if when copper layers are not built
|
||||
if( aErrorMessages )
|
||||
{
|
||||
*aErrorMessages << msg << wxT("\n") <<
|
||||
_("Unable to calculate the board outlines.\n"
|
||||
"Therefore use the board boundary box.") << wxT("\n\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int thickness = GetPrm3DVisu().GetCopperThicknessBIU();
|
||||
|
@ -1194,7 +1210,7 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
|
|||
}
|
||||
}
|
||||
|
||||
void EDA_3D_CANVAS::CreateDrawGL_List()
|
||||
void EDA_3D_CANVAS::CreateDrawGL_List( wxString* aErrorMessages)
|
||||
{
|
||||
BOARD* pcb = GetBoard();
|
||||
|
||||
|
@ -1232,7 +1248,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List()
|
|||
{
|
||||
m_glLists[GL_ID_BOARD] = glGenLists( 1 );
|
||||
m_glLists[GL_ID_BODY] = glGenLists( 1 );
|
||||
BuildBoard3DView(m_glLists[GL_ID_BOARD], m_glLists[GL_ID_BODY]);
|
||||
BuildBoard3DView(m_glLists[GL_ID_BOARD], m_glLists[GL_ID_BODY], aErrorMessages );
|
||||
CheckGLError( __FILE__, __LINE__ );
|
||||
}
|
||||
|
||||
|
@ -1240,7 +1256,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List()
|
|||
{
|
||||
m_glLists[GL_ID_TECH_LAYERS] = glGenLists( 1 );
|
||||
glNewList( m_glLists[GL_ID_TECH_LAYERS], GL_COMPILE );
|
||||
BuildTechLayers3DView();
|
||||
BuildTechLayers3DView( aErrorMessages );
|
||||
glEndList();
|
||||
CheckGLError( __FILE__, __LINE__ );
|
||||
}
|
||||
|
|
|
@ -626,9 +626,10 @@ void EDA_3D_FRAME::NewDisplay( int aGlList )
|
|||
m_reloadRequest = false;
|
||||
|
||||
m_canvas->ClearLists( aGlList );
|
||||
m_canvas->CreateDrawGL_List();
|
||||
|
||||
// Rebuild the 3D board and refresh the view:
|
||||
m_canvas->Refresh( true );
|
||||
|
||||
m_canvas->DisplayStatus();
|
||||
}
|
||||
|
||||
|
|
|
@ -1336,13 +1336,18 @@ bool SPECCTRA_DB::GetBoardPolygonOutlines( BOARD* aBoard,
|
|||
// Creates a valid polygon outline is not possible.
|
||||
// So uses the board edge cuts bounding box to create a
|
||||
// rectangular outline
|
||||
// (when no edge cuts items, fillBOUNDARY biuld n outline
|
||||
// (when no edge cuts items, fillBOUNDARY build a contour
|
||||
// from global bounding box
|
||||
success = false;
|
||||
if( aErrorText )
|
||||
*aErrorText = ioe.errorText;
|
||||
|
||||
EDA_RECT bbbox = aBoard->ComputeBoundingBox( true );
|
||||
|
||||
// Ensure non null area. If happen, gives a minimal size.
|
||||
if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
|
||||
bbbox.Inflate( Millimeter2iu( 1.0 ) );
|
||||
|
||||
corner.x = bbbox.GetOrigin().x;
|
||||
corner.y = bbbox.GetOrigin().y;
|
||||
aOutlines.Append( corner );
|
||||
|
|
Loading…
Reference in New Issue