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.
This commit is contained in:
jean-pierre charras 2015-03-17 08:39:15 +01:00
parent eef494d9c5
commit 9a3a92f93a
5 changed files with 1142 additions and 1115 deletions

View File

@ -79,6 +79,7 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList ) :
wxFULL_REPAINT_ON_RESIZE )
{
m_init = false;
m_reportWarnings = true;
m_shadow_init = false;
// set an invalide value to not yet initialized indexes managing
// textures created to enhance 3D rendering

View File

@ -1,9 +1,9 @@
/*
* 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) 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
* modify it under the terms of the GNU General Public License
@ -78,7 +78,9 @@ class EDA_3D_CANVAS : public wxGLCanvas
{
private:
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;
wxRealPoint m_draw3dOffset; // offset to draw the 3D mesh.
double m_ZBottom; // position of the back layer
@ -135,9 +137,13 @@ public:
* creates the OpenGL draw list items (board, grid ...)
* @param aErrorMessages = a wxString which will filled with error messages,
* 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 ReportWarnings( bool aReport ) { m_reportWarnings = aReport; }
void SetLights();
void SetOffset(double aPosX, double aPosY)
@ -212,16 +218,24 @@ private:
* 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
* @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
* 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
* @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
@ -305,7 +319,15 @@ private:
std::vector<S3D_MODEL_PARSER *>& model_parsers_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()
};

View File

@ -1,7 +1,7 @@
/*
* 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
* 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,
#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 )
{
@ -168,7 +168,7 @@ void EDA_3D_CANVAS::GenerateFakeShadowsTextures( wxString* aErrorMessages )
}
// Init info 3d parameters and create gl lists:
CreateDrawGL_List( aErrorMessages );
CreateDrawGL_List( aErrorMessages, aShowWarnings );
m_shadow_init = true;
@ -226,6 +226,7 @@ void EDA_3D_CANVAS::Redraw()
return;
wxString errorMessages;
bool showWarnings = m_reportWarnings;
SetCurrent( *m_glRC );
@ -242,7 +243,7 @@ void EDA_3D_CANVAS::Redraw()
if( isEnabled( FL_MODULE ) && isRealisticMode() &&
isEnabled( FL_RENDER_SHADOWS ) )
{
GenerateFakeShadowsTextures( &errorMessages );
GenerateFakeShadowsTextures( &errorMessages, showWarnings );
}
// *MUST* be called *after* SetCurrent( ):
@ -338,7 +339,7 @@ void EDA_3D_CANVAS::Redraw()
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] )
glCallList( m_glLists[GL_ID_AXIS] );
@ -354,7 +355,7 @@ void EDA_3D_CANVAS::Redraw()
if( isEnabled( FL_MODULE ) )
{
if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] )
CreateDrawGL_List( &errorMessages );
CreateDrawGL_List( &errorMessages, showWarnings );
}
glEnable( GL_BLEND );
@ -404,7 +405,7 @@ void EDA_3D_CANVAS::Redraw()
if( isEnabled( FL_COMMENTS ) || isEnabled( FL_COMMENTS ) )
{
if( ! m_glLists[GL_ID_AUX_LAYERS] )
CreateDrawGL_List( &errorMessages );
CreateDrawGL_List( &errorMessages, showWarnings );
glCallList( m_glLists[GL_ID_AUX_LAYERS] );
}
@ -452,7 +453,7 @@ void EDA_3D_CANVAS::Redraw()
if( isEnabled( FL_MODULE ) )
{
if( ! m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] )
CreateDrawGL_List( &errorMessages );
CreateDrawGL_List( &errorMessages, showWarnings );
glCallList( m_glLists[GL_ID_3DSHAPES_SOLID_FRONT] );
}
@ -497,6 +498,8 @@ void EDA_3D_CANVAS::Redraw()
if( !errorMessages.IsEmpty() )
wxLogMessage( errorMessages );
ReportWarnings( false );
}
@ -577,7 +580,7 @@ void EDA_3D_CANVAS::BuildShadowList( GLuint aFrontList, GLuint aBacklist, GLuint
void EDA_3D_CANVAS::BuildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
wxString* aErrorMessages )
wxString* aErrorMessages, bool aShowWarnings )
{
BOARD* pcb = GetBoard();
@ -615,7 +618,7 @@ void EDA_3D_CANVAS::BuildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) )
{
if( aErrorMessages )
if( aErrorMessages && aShowWarnings )
{
*aErrorMessages << msg << wxT("\n") <<
_("Unable to calculate the board outlines.\n"
@ -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();
bool useTextures = isRealisticMode() && isEnabled( FL_RENDER_TEXTURES );
@ -913,17 +916,12 @@ void EDA_3D_CANVAS::BuildTechLayers3DView( wxString* aErrorMessages )
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &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 )
if( aErrorMessages && aShowWarnings )
{
*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();
@ -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();
@ -1248,7 +1246,7 @@ void EDA_3D_CANVAS::CreateDrawGL_List( wxString* aErrorMessages)
{
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], aErrorMessages );
BuildBoard3DView(m_glLists[GL_ID_BOARD], m_glLists[GL_ID_BODY], aErrorMessages, aShowWarnings );
CheckGLError( __FILE__, __LINE__ );
}
@ -1256,7 +1254,9 @@ void EDA_3D_CANVAS::CreateDrawGL_List( wxString* aErrorMessages)
{
m_glLists[GL_ID_TECH_LAYERS] = glGenLists( 1 );
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();
CheckGLError( __FILE__, __LINE__ );
}
@ -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_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__ );
}

View File

@ -5,7 +5,7 @@
/*
* 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
* modify it under the terms of the GNU General Public License
@ -410,6 +410,7 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_RELOAD3D_BOARD:
m_reloadRequest = true;
NewDisplay();
return;
break;
@ -623,20 +624,22 @@ void EDA_3D_FRAME::On3DGridSelection( wxCommandEvent& event )
void EDA_3D_FRAME::NewDisplay( int aGlList )
{
m_reloadRequest = false;
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->DisplayStatus();
m_reloadRequest = false;
}
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
if( m_reloadRequest )
NewDisplay();

File diff suppressed because it is too large Load Diff