Commit 9a3a92f9 authored by jean-pierre charras's avatar jean-pierre charras

3d-viewer: avoid useless warning messages each time a 3d view option is changed.

they are now shown only when a new board is loaded, if there are warnings.
parent eef494d9
...@@ -79,6 +79,7 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) : ...@@ -79,6 +79,7 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) :
wxFULL_REPAINT_ON_RESIZE ) wxFULL_REPAINT_ON_RESIZE )
{ {
m_init = false; m_init = false;
m_reportWarnings = true;
m_shadow_init = false; m_shadow_init = false;
// set an invalide value to not yet initialized indexes managing // set an invalide value to not yet initialized indexes managing
// textures created to enhance 3D rendering // textures created to enhance 3D rendering
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -78,7 +78,9 @@ class EDA_3D_CANVAS : public wxGLCanvas ...@@ -78,7 +78,9 @@ class EDA_3D_CANVAS : public wxGLCanvas
{ {
private: private:
bool m_init; bool m_init;
GLuint m_glLists[GL_ID_END]; // GL lists bool m_reportWarnings; // true to report all wranings when build the 3D scene
// false to report errors only
GLuint m_glLists[GL_ID_END]; // GL lists
wxGLContext* m_glRC; wxGLContext* m_glRC;
wxRealPoint m_draw3dOffset; // offset to draw the 3D mesh. wxRealPoint m_draw3dOffset; // offset to draw the 3D mesh.
double m_ZBottom; // position of the back layer double m_ZBottom; // position of the back layer
...@@ -135,9 +137,13 @@ public: ...@@ -135,9 +137,13 @@ public:
* 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, * @param aErrorMessages = a wxString which will filled with error messages,
* if any * if any
* @param aShowWarnings = true to show all messages, false to show errors only
*/ */
void CreateDrawGL_List( wxString* aErrorMessages ); void CreateDrawGL_List( wxString* aErrorMessages, bool aShowWarnings );
void InitGL(); void InitGL();
void ReportWarnings( bool aReport ) { m_reportWarnings = aReport; }
void SetLights(); void SetLights();
void SetOffset(double aPosX, double aPosY) void SetOffset(double aPosX, double aPosY)
...@@ -212,16 +218,24 @@ private: ...@@ -212,16 +218,24 @@ private:
* Populates the OpenGL GL_ID_BOARD draw list with board items only on copper layers. * 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 * 3D footprint shapes, tech layers and aux layers are not on this list
* Fills aErrorMessages with error messages created by some calculation function * Fills aErrorMessages with error messages created by some calculation function
* @param aBoardList =
* @param aBodyOnlyList =
* @param aErrorMessages = a wxString to add error and warning messages
* created by the build process (can be NULL)
* @param aShowWarnings = true to show all messages, false to show errors only
*/ */
void BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList, wxString* aErrorMessages ); void BuildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
wxString* aErrorMessages, bool aShowWarnings );
/** /**
* Function BuildTechLayers3DView * Function BuildTechLayers3DView
* Called by CreateDrawGL_List() * Called by CreateDrawGL_List()
* Populates the OpenGL GL_ID_TECH_LAYERS draw list with items on tech layers * Populates the OpenGL GL_ID_TECH_LAYERS draw list with items on tech layers
* Add error messages in aErrorMessages, if any * @param aErrorMessages = a wxString to add error and warning messages
* created by the build process (can be NULL)
* @param aShowWarnings = true to show all messages, false to show errors only
*/ */
void BuildTechLayers3DView( wxString* aErrorMessages ); void BuildTechLayers3DView( wxString* aErrorMessages, bool aShowWarnings );
/** /**
* Function BuildShadowList * Function BuildShadowList
...@@ -305,7 +319,15 @@ private: ...@@ -305,7 +319,15 @@ private:
std::vector<S3D_MODEL_PARSER *>& model_parsers_list, std::vector<S3D_MODEL_PARSER *>& model_parsers_list,
std::vector<wxString>& model_filename_list ); std::vector<wxString>& model_filename_list );
void GenerateFakeShadowsTextures( wxString* aErrorMessages ); /**
* function GenerateFakeShadowsTextures
* creates shadows of the board an footprints
* for aesthetical purpose
* @param aErrorMessages = a wxString to add error and warning messages
* created by the build process (can be NULL)
* @param aShowWarnings = true to show all messages, false to show errors only
*/
void GenerateFakeShadowsTextures( wxString* aErrorMessages, bool aShowWarnings );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -160,7 +160,7 @@ void EDA_3D_CANVAS::Create_and_Render_Shadow_Buffer( GLuint *aDst_gl_texture, ...@@ -160,7 +160,7 @@ void EDA_3D_CANVAS::Create_and_Render_Shadow_Buffer( GLuint *aDst_gl_texture,
#define SHADOW_BOARD_SCALE 1.5f #define SHADOW_BOARD_SCALE 1.5f
void EDA_3D_CANVAS::GenerateFakeShadowsTextures( wxString* aErrorMessages ) void EDA_3D_CANVAS::GenerateFakeShadowsTextures( wxString* aErrorMessages, bool aShowWarnings )
{ {
if( m_shadow_init == true ) if( m_shadow_init == true )
{ {
...@@ -168,7 +168,7 @@ void EDA_3D_CANVAS::GenerateFakeShadowsTextures( wxString* aErrorMessages ) ...@@ -168,7 +168,7 @@ void EDA_3D_CANVAS::GenerateFakeShadowsTextures( wxString* aErrorMessages )
} }
// Init info 3d parameters and create gl lists: // Init info 3d parameters and create gl lists:
CreateDrawGL_List( aErrorMessages ); CreateDrawGL_List( aErrorMessages, aShowWarnings );
m_shadow_init = true; m_shadow_init = true;
...@@ -226,6 +226,7 @@ void EDA_3D_CANVAS::Redraw() ...@@ -226,6 +226,7 @@ void EDA_3D_CANVAS::Redraw()
return; return;
wxString errorMessages; wxString errorMessages;
bool showWarnings = m_reportWarnings;
SetCurrent( *m_glRC ); SetCurrent( *m_glRC );
...@@ -242,7 +243,7 @@ void EDA_3D_CANVAS::Redraw() ...@@ -242,7 +243,7 @@ void EDA_3D_CANVAS::Redraw()
if( isEnabled( FL_MODULE ) && isRealisticMode() && if( isEnabled( FL_MODULE ) && isRealisticMode() &&
isEnabled( FL_RENDER_SHADOWS ) ) isEnabled( FL_RENDER_SHADOWS ) )
{ {
GenerateFakeShadowsTextures( &errorMessages ); GenerateFakeShadowsTextures( &errorMessages, showWarnings );
} }
// *MUST* be called *after* SetCurrent( ): // *MUST* be called *after* SetCurrent( ):
...@@ -338,7 +339,7 @@ void EDA_3D_CANVAS::Redraw() ...@@ -338,7 +339,7 @@ void EDA_3D_CANVAS::Redraw()
if( ! m_glLists[GL_ID_BOARD] || ! m_glLists[GL_ID_TECH_LAYERS] ) if( ! m_glLists[GL_ID_BOARD] || ! m_glLists[GL_ID_TECH_LAYERS] )
CreateDrawGL_List( &errorMessages ); CreateDrawGL_List( &errorMessages, showWarnings );
if( isEnabled( FL_AXIS ) && m_glLists[GL_ID_AXIS] ) if( isEnabled( FL_AXIS ) && m_glLists[GL_ID_AXIS] )
glCallList( m_glLists[GL_ID_AXIS] ); glCallList( m_glLists[GL_ID_AXIS] );
...@@ -354,7 +355,7 @@ void EDA_3D_CANVAS::Redraw() ...@@ -354,7 +355,7 @@ void EDA_3D_CANVAS::Redraw()
if( isEnabled( FL_MODULE ) ) if( isEnabled( FL_MODULE ) )
{ {
if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] ) if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] )
CreateDrawGL_List( &errorMessages ); CreateDrawGL_List( &errorMessages, showWarnings );
} }
glEnable( GL_BLEND ); glEnable( GL_BLEND );
...@@ -404,7 +405,7 @@ void EDA_3D_CANVAS::Redraw() ...@@ -404,7 +405,7 @@ void EDA_3D_CANVAS::Redraw()
if( isEnabled( FL_COMMENTS ) || isEnabled( FL_COMMENTS ) ) if( isEnabled( FL_COMMENTS ) || isEnabled( FL_COMMENTS ) )
{ {
if( ! m_glLists[GL_ID_AUX_LAYERS] ) if( ! m_glLists[GL_ID_AUX_LAYERS] )
CreateDrawGL_List( &errorMessages ); CreateDrawGL_List( &errorMessages, showWarnings );
glCallList( m_glLists[GL_ID_AUX_LAYERS] ); glCallList( m_glLists[GL_ID_AUX_LAYERS] );
} }
...@@ -452,7 +453,7 @@ void EDA_3D_CANVAS::Redraw() ...@@ -452,7 +453,7 @@ void EDA_3D_CANVAS::Redraw()
if( isEnabled( FL_MODULE ) ) if( isEnabled( FL_MODULE ) )
{ {
if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] ) if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] )
CreateDrawGL_List( &errorMessages ); CreateDrawGL_List( &errorMessages, showWarnings );
glCallList( m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] ); glCallList( m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] );
} }
...@@ -497,6 +498,8 @@ void EDA_3D_CANVAS::Redraw() ...@@ -497,6 +498,8 @@ void EDA_3D_CANVAS::Redraw()
if( !errorMessages.IsEmpty() ) if( !errorMessages.IsEmpty() )
wxLogMessage( errorMessages ); wxLogMessage( errorMessages );
ReportWarnings( false );
} }
...@@ -577,7 +580,7 @@ void EDA_3D_CANVAS::BuildShadowList( GLuint aFrontList, GLuint aBacklist, GLuint ...@@ -577,7 +580,7 @@ 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 ) wxString* aErrorMessages, bool aShowWarnings )
{ {
BOARD* pcb = GetBoard(); BOARD* pcb = GetBoard();
...@@ -615,7 +618,7 @@ void EDA_3D_CANVAS::BuildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList, ...@@ -615,7 +618,7 @@ void EDA_3D_CANVAS::BuildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) ) if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) )
{ {
if( aErrorMessages ) if( aErrorMessages && aShowWarnings )
{ {
*aErrorMessages << msg << wxT("\n") << *aErrorMessages << msg << wxT("\n") <<
_("Unable to calculate the board outlines.\n" _("Unable to calculate the board outlines.\n"
...@@ -886,7 +889,7 @@ void EDA_3D_CANVAS::BuildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList, ...@@ -886,7 +889,7 @@ void EDA_3D_CANVAS::BuildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
} }
void EDA_3D_CANVAS::BuildTechLayers3DView( wxString* aErrorMessages ) void EDA_3D_CANVAS::BuildTechLayers3DView( wxString* aErrorMessages, bool aShowWarnings )
{ {
BOARD* pcb = GetBoard(); BOARD* pcb = GetBoard();
bool useTextures = isRealisticMode() && isEnabled( FL_RENDER_TEXTURES ); bool useTextures = isRealisticMode() && isEnabled( FL_RENDER_TEXTURES );
...@@ -913,17 +916,12 @@ void EDA_3D_CANVAS::BuildTechLayers3DView( wxString* aErrorMessages ) ...@@ -913,17 +916,12 @@ void EDA_3D_CANVAS::BuildTechLayers3DView( wxString* aErrorMessages )
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) ) if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) )
{ {
#if 0 if( aErrorMessages && aShowWarnings )
// 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") << *aErrorMessages << msg << wxT("\n") <<
_("Unable to calculate the board outlines.\n" _("Unable to calculate the board outlines.\n"
"Therefore use the board boundary box.") << wxT("\n\n"); "Therefore use the board boundary box.") << wxT("\n\n");
} }
#endif
} }
int thickness = GetPrm3DVisu().GetCopperThicknessBIU(); int thickness = GetPrm3DVisu().GetCopperThicknessBIU();
...@@ -1210,7 +1208,7 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers() ...@@ -1210,7 +1208,7 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
} }
} }
void EDA_3D_CANVAS::CreateDrawGL_List( wxString* aErrorMessages) void EDA_3D_CANVAS::CreateDrawGL_List( wxString* aErrorMessages, bool aShowWarnings )
{ {
BOARD* pcb = GetBoard(); BOARD* pcb = GetBoard();
...@@ -1248,7 +1246,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List( wxString* aErrorMessages) ...@@ -1248,7 +1246,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List( wxString* aErrorMessages)
{ {
m_glLists[GL_ID_BOARD] = glGenLists( 1 ); m_glLists[GL_ID_BOARD] = glGenLists( 1 );
m_glLists[GL_ID_BODY] = glGenLists( 1 ); m_glLists[GL_ID_BODY] = glGenLists( 1 );
BuildBoard3DView(m_glLists[GL_ID_BOARD], m_glLists[GL_ID_BODY], aErrorMessages ); BuildBoard3DView(m_glLists[GL_ID_BOARD], m_glLists[GL_ID_BODY], aErrorMessages, aShowWarnings );
CheckGLError( __FILE__, __LINE__ ); CheckGLError( __FILE__, __LINE__ );
} }
...@@ -1256,7 +1254,9 @@ void EDA_3D_CANVAS::CreateDrawGL_List( wxString* aErrorMessages) ...@@ -1256,7 +1254,9 @@ void EDA_3D_CANVAS::CreateDrawGL_List( wxString* aErrorMessages)
{ {
m_glLists[GL_ID_TECH_LAYERS] = glGenLists( 1 ); m_glLists[GL_ID_TECH_LAYERS] = glGenLists( 1 );
glNewList( m_glLists[GL_ID_TECH_LAYERS], GL_COMPILE ); glNewList( m_glLists[GL_ID_TECH_LAYERS], GL_COMPILE );
BuildTechLayers3DView( aErrorMessages ); // when calling BuildTechLayers3DView,
// do not show warnings, which are the same as BuildBoard3DView
BuildTechLayers3DView( aErrorMessages, false );
glEndList(); glEndList();
CheckGLError( __FILE__, __LINE__ ); CheckGLError( __FILE__, __LINE__ );
} }
...@@ -1296,7 +1296,8 @@ void EDA_3D_CANVAS::CreateDrawGL_List( wxString* aErrorMessages) ...@@ -1296,7 +1296,8 @@ void EDA_3D_CANVAS::CreateDrawGL_List( wxString* aErrorMessages)
m_glLists[GL_ID_SHADOW_BACK] = glGenLists( 1 ); m_glLists[GL_ID_SHADOW_BACK] = glGenLists( 1 );
m_glLists[GL_ID_SHADOW_BOARD] = glGenLists( 1 ); m_glLists[GL_ID_SHADOW_BOARD] = glGenLists( 1 );
BuildShadowList(m_glLists[GL_ID_SHADOW_FRONT], m_glLists[GL_ID_SHADOW_BACK], m_glLists[GL_ID_SHADOW_BOARD]); BuildShadowList( m_glLists[GL_ID_SHADOW_FRONT], m_glLists[GL_ID_SHADOW_BACK],
m_glLists[GL_ID_SHADOW_BOARD]);
CheckGLError( __FILE__, __LINE__ ); CheckGLError( __FILE__, __LINE__ );
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -410,6 +410,7 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -410,6 +410,7 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_RELOAD3D_BOARD: case ID_RELOAD3D_BOARD:
m_reloadRequest = true;
NewDisplay(); NewDisplay();
return; return;
break; break;
...@@ -623,20 +624,22 @@ void EDA_3D_FRAME::On3DGridSelection( wxCommandEvent& event ) ...@@ -623,20 +624,22 @@ void EDA_3D_FRAME::On3DGridSelection( wxCommandEvent& event )
void EDA_3D_FRAME::NewDisplay( int aGlList ) void EDA_3D_FRAME::NewDisplay( int aGlList )
{ {
m_reloadRequest = false;
m_canvas->ClearLists( aGlList ); m_canvas->ClearLists( aGlList );
// Rebuild the 3D board and refresh the view: // Rebuild the 3D board and refresh the view on reload request:
if( m_reloadRequest )
m_canvas->ReportWarnings( true );
m_canvas->Refresh( true ); m_canvas->Refresh( true );
m_canvas->DisplayStatus(); m_canvas->DisplayStatus();
m_reloadRequest = false;
} }
void EDA_3D_FRAME::OnActivate( wxActivateEvent& event ) void EDA_3D_FRAME::OnActivate( wxActivateEvent& event )
{ {
// Reload data if 3D frame shows a footprint, // Reload data if 3D frame shows a board,
// because it can be changed since last frame activation // because it can be changed since last frame activation
if( m_reloadRequest ) if( m_reloadRequest )
NewDisplay(); NewDisplay();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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