Give the 3D viewer an infobar & Infobar upgrades

ADDED: Infobar warning in 3d viewer for board outline issues
This commit is contained in:
Ian McInerney 2020-06-04 00:00:40 +01:00
parent 3fa2bad3c5
commit d46f9a5273
24 changed files with 388 additions and 183 deletions

View File

@ -274,7 +274,7 @@ double BOARD_ADAPTER::GetCircleCorrectionFactor( int aNrSides ) const
}
void BOARD_ADAPTER::InitSettings( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter )
void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningReporter )
{
wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::InitSettings" ) );
@ -426,23 +426,23 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusTextReporter, REPORTER* aWarn
unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
#endif
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Build board body" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Build board body" ) );
if( !createBoardPolygon() )
aWarningTextReporter->Report( _( "Warning: Board outline is not closed" ) );
aWarningReporter->Report( _( "Board outline is not closed" ), RPT_SEVERITY_WARNING );
else
aWarningTextReporter->Report( wxEmptyString );
aWarningReporter->Report( wxEmptyString );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_stopCreateBoardPolyTime = GetRunningMicroSecs();
unsigned stats_startCreateLayersTime = stats_stopCreateBoardPolyTime;
#endif
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Create layers" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Create layers" ) );
createLayers( aStatusTextReporter );
createLayers( aStatusReporter );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_stopCreateLayersTime = GetRunningMicroSecs();

View File

@ -145,10 +145,10 @@ class BOARD_ADAPTER
/**
* @brief InitSettings - Function to be called by the render when it need to
* reload the settings for the board.
* @param aStatusTextReporter: the pointer for the status reporter
* @param aWarningTextReporter: pointer for the warning reporter
* @param aStatusReporter: the pointer for the status reporter
* @param aWarningReporter: pointer for the warning reporter
*/
void InitSettings( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter );
void InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningReporter );
/**
* @brief BiuTo3Dunits - Board integer units To 3D units
@ -266,7 +266,7 @@ class BOARD_ADAPTER
* @param aAAmode = antialiasing mode value
*/
void AntiAliasingSet( ANTIALIASING_MODE aAAmode ) { m_antialiasing_mode = aAAmode; }
/**
* @brief RenderEngineSet
* @param aRenderEngine = the render engine mode selected
@ -543,7 +543,7 @@ class BOARD_ADAPTER
* @return false if the outline could not be created
*/
bool createBoardPolygon();
void createLayers( REPORTER *aStatusTextReporter );
void createLayers( REPORTER* aStatusReporter );
void destroyLayers();
// Helper functions to create the board

View File

@ -113,7 +113,7 @@ void BOARD_ADAPTER::destroyLayers()
}
void BOARD_ADAPTER::createLayers( REPORTER *aStatusTextReporter )
void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
destroyLayers();
@ -211,8 +211,8 @@ void BOARD_ADAPTER::createLayers( REPORTER *aStatusTextReporter )
start_Time = GetRunningMicroSecs();
#endif
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Create tracks and vias" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Create tracks and vias" ) );
// Create tracks as objects and add it to container
// /////////////////////////////////////////////////////////////////////////
@ -685,8 +685,8 @@ void BOARD_ADAPTER::createLayers( REPORTER *aStatusTextReporter )
if( GetFlag( FL_ZONE ) )
{
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Create zones" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Create zones" ) );
// Add zones objects
// /////////////////////////////////////////////////////////////////////
@ -754,8 +754,8 @@ void BOARD_ADAPTER::createLayers( REPORTER *aStatusTextReporter )
// Simplify layer polygons
// /////////////////////////////////////////////////////////////////////////
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Simplifying copper layers polygons" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Simplifying copper layers polygons" ) );
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS )
&& ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) )
@ -798,8 +798,8 @@ void BOARD_ADAPTER::createLayers( REPORTER *aStatusTextReporter )
// Simplify holes polygon contours
// /////////////////////////////////////////////////////////////////////////
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Simplify holes contours" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Simplify holes contours" ) );
for( PCB_LAYER_ID layer : layer_id )
{
@ -840,8 +840,8 @@ void BOARD_ADAPTER::createLayers( REPORTER *aStatusTextReporter )
unsigned stats_startTechLayersTime = GetRunningMicroSecs();
#endif
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Build Tech layers" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Build Tech layers" ) );
// draw graphic items, on technical layers
static const PCB_LAYER_ID teckLayerList[] = {
@ -1036,8 +1036,8 @@ void BOARD_ADAPTER::createLayers( REPORTER *aStatusTextReporter )
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_startHolesBVHTime = GetRunningMicroSecs();
#endif
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Build BVH for holes and vias" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Build BVH for holes and vias" ) );
m_through_holes_inner.BuildBVH();
m_through_holes_outer.BuildBVH();

View File

@ -37,7 +37,7 @@
#include <3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h>
#include <3d_viewer_id.h>
#include <class_board.h>
#include <status_text_reporter.h>
#include <reporter.h>
#include <gl_context_mgr.h>
#include <profile.h> // To use GetRunningMicroSecs or another profiling utility
#include <bitmaps.h>
@ -359,10 +359,9 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
// !TODO: implement error reporter
//WX_STRING_REPORTER errorReporter( &err_messages );
STATUS_TEXT_REPORTER activityReporter(
INFOBAR_REPORTER warningReporter( m_parentInfoBar );
STATUSBAR_REPORTER activityReporter(
m_parentStatusBar, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::STATUS_TEXT ) );
STATUS_TEXT_REPORTER warningReporter(
m_parentStatusBar, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::WARN_TEXT ) );
unsigned strtime = GetRunningMicroSecs();
@ -486,6 +485,8 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
// This will reset the flag of camera parameters changed
m_camera.ParametersChanged();
warningReporter.Finalize();
if( !err_messages.IsEmpty() )
wxLogMessage( err_messages );

View File

@ -34,6 +34,7 @@
#include <wx/timer.h>
class WX_INFOBAR;
class wxStatusBar;
class BOARD;
class C3D_RENDER_RAYTRACING;
@ -67,7 +68,15 @@ class EDA_3D_CANVAS : public HIDPI_GL_CANVAS
*/
void SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher );
void SetStatusBar( wxStatusBar *aStatusBar ) { m_parentStatusBar = aStatusBar; }
void SetStatusBar( wxStatusBar* aStatusBar )
{
m_parentStatusBar = aStatusBar;
}
void SetInfoBar( WX_INFOBAR* aInfoBar )
{
m_parentInfoBar = aInfoBar;
}
void ReloadRequest( BOARD *aBoard = NULL, S3D_CACHE *aCachePointer = NULL );
@ -218,6 +227,7 @@ private:
TOOL_DISPATCHER* m_eventDispatcher;
wxStatusBar* m_parentStatusBar; // Parent statusbar to report progress
WX_INFOBAR* m_parentInfoBar;
wxGLContext* m_glRC; // Current OpenGL context
bool m_is_opengl_initialized;

View File

@ -1,68 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2016 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file status_text_reporter.h
* @brief
*/
#ifndef STATUS_TEXT_REPORTER_H_
#define STATUS_TEXT_REPORTER_H_
#include <reporter.h>
/**
* STATUS_TEXT_REPORTER
* is a wrapper for reporting to a wxString in a wxFrame status text.
*/
class STATUS_TEXT_REPORTER : public REPORTER
{
private:
wxStatusBar *m_parentStatusBar;
int m_position;
bool m_hasMessage;
public:
STATUS_TEXT_REPORTER( wxStatusBar* aParentStatusBar, int aPosition = 0 ) :
REPORTER(),
m_parentStatusBar( aParentStatusBar ), m_position( aPosition )
{
m_hasMessage = false;
}
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override
{
if( !aText.IsEmpty() )
m_hasMessage = true;
if( m_parentStatusBar )
m_parentStatusBar->SetStatusText( aText, m_position );
return *this;
}
bool HasMessage() const override { return m_hasMessage; }
};
#endif // STATUS_TEXT_REPORTER_H_

View File

@ -334,7 +334,7 @@ CLAYERS_OGL_DISP_LISTS *C3D_RENDER_OGL_LEGACY::generate_holes_display_list(
}
void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter )
void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningReporter )
{
m_reloadRequested = false;
@ -348,7 +348,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa
unsigned stats_startReloadTime = GetRunningMicroSecs();
m_boardAdapter.InitSettings( aStatusTextReporter, aWarningTextReporter );
m_boardAdapter.InitSettings( aStatusReporter, aWarningReporter );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_endReloadTime = GetRunningMicroSecs();
@ -361,8 +361,8 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa
unsigned stats_start_OpenGL_Load_Time = GetRunningMicroSecs();
#endif
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Load OpenGL: board" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Load OpenGL: board" ) );
// Create Board
// /////////////////////////////////////////////////////////////////////////
@ -433,8 +433,8 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa
// Create Through Holes and vias
// /////////////////////////////////////////////////////////////////////////
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Load OpenGL: holes and vias" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Load OpenGL: holes and vias" ) );
m_ogl_disp_list_through_holes_outer = generate_holes_display_list(
m_boardAdapter.GetThroughHole_Outer().GetList(),
@ -523,8 +523,8 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa
// Add layers maps
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Load OpenGL: layers" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Load OpenGL: layers" ) );
for( MAP_CONTAINER_2D::const_iterator ii = m_boardAdapter.GetMapLayers().begin();
ii != m_boardAdapter.GetMapLayers().end();
@ -623,10 +623,10 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa
unsigned stats_start_models_Load_Time = GetRunningMicroSecs();
#endif
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Loading 3D models" ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Loading 3D models" ) );
load_3D_models( aStatusTextReporter );
load_3D_models( aStatusReporter );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_end_models_Load_Time = GetRunningMicroSecs();
@ -642,14 +642,13 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWa
COBJECT2D_STATS::Instance().PrintStats();
#endif
if( aStatusTextReporter )
if( aStatusReporter )
{
// Calculation time in seconds
const double calculation_time = (double)( GetRunningMicroSecs() -
stats_startReloadTime) / 1e6;
aStatusTextReporter->Report( wxString::Format( _( "Reload time %.3f s" ),
calculation_time ) );
aStatusReporter->Report( wxString::Format( _( "Reload time %.3f s" ), calculation_time ) );
}
}
@ -894,7 +893,7 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads()
* cache for this render. (cache based on C_OGL_3DMODEL with associated
* openGL lists in GPU memory)
*/
void C3D_RENDER_OGL_LEGACY::load_3D_models( REPORTER *aStatusTextReporter )
void C3D_RENDER_OGL_LEGACY::load_3D_models( REPORTER* aStatusReporter )
{
if((!m_boardAdapter.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL )) &&
(!m_boardAdapter.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT )) &&
@ -914,14 +913,14 @@ void C3D_RENDER_OGL_LEGACY::load_3D_models( REPORTER *aStatusTextReporter )
{
if( sM->m_Show && !sM->m_Filename.empty() )
{
if( aStatusTextReporter )
if( aStatusReporter )
{
// Display the short filename of the 3D model loaded:
// (the full name is usually too long to be displayed)
wxFileName fn( sM->m_Filename );
wxString msg;
msg.Printf( _( "Loading %s" ), fn.GetFullName() );
aStatusTextReporter->Report( msg );
aStatusReporter->Report( msg );
}
// Check if the model is not present in our cache map

View File

@ -527,7 +527,7 @@ void init_lights(void)
bool C3D_RENDER_OGL_LEGACY::Redraw(
bool aIsMoving, REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter )
bool aIsMoving, REPORTER* aStatusReporter, REPORTER* aWarningReporter )
{
// Initialize openGL
if( !m_is_opengl_initialized )
@ -540,10 +540,10 @@ bool C3D_RENDER_OGL_LEGACY::Redraw(
{
std::unique_ptr<BUSY_INDICATOR> busy = CreateBusyIndicator();
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Loading..." ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Loading..." ) );
reload( aStatusTextReporter, aWarningTextReporter );
reload( aStatusReporter, aWarningReporter );
setupMaterials();
// generate a new 3D grid as the size of the board may had changed

View File

@ -65,14 +65,13 @@ public:
// Imported from C3D_RENDER_BASE
void SetCurWindowSize( const wxSize &aSize ) override;
bool Redraw( bool aIsMoving, REPORTER* aStatusTextReporter,
REPORTER* aWarningTextReporter ) override;
bool Redraw( bool aIsMoving, REPORTER* aStatusReporter, REPORTER* aWarningReporter ) override;
int GetWaitForEditingTimeOut() override;
private:
bool initializeOpenGL();
void reload( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter );
void reload( REPORTER* aStatusReporter, REPORTER* aWarningReporter );
void ogl_set_arrow_material();
@ -173,7 +172,7 @@ private:
void generate_3D_Vias_and_Pads();
void load_3D_models( REPORTER *aStatusTextReporter );
void load_3D_models( REPORTER* aStatusReporter );
/**
* @brief render_3D_models

View File

@ -257,7 +257,7 @@ void C3D_RENDER_RAYTRACING::create_3d_object_from( CCONTAINER& aDstContainer,
}
void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter )
void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusReporter, REPORTER* aWarningReporter )
{
m_reloadRequested = false;
@ -272,7 +272,7 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa
unsigned stats_startReloadTime = GetRunningMicroSecs();
m_boardAdapter.InitSettings( aStatusTextReporter, aWarningTextReporter );
m_boardAdapter.InitSettings( aStatusReporter, aWarningReporter );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_endReloadTime = GetRunningMicroSecs();
@ -1041,14 +1041,13 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa
COBJECT3D_STATS::Instance().PrintStats();
#endif
if( aStatusTextReporter )
if( aStatusReporter )
{
// Calculation time in seconds
const double calculation_time = (double)( GetRunningMicroSecs() -
stats_startReloadTime ) / 1e6;
aStatusTextReporter->Report( wxString::Format( _( "Reload time %.3f s" ),
calculation_time ) );
aStatusReporter->Report( wxString::Format( _( "Reload time %.3f s" ), calculation_time ) );
}
}

View File

@ -148,7 +148,7 @@ static inline void SetPixel( GLubyte *p, const CCOLORRGB &v )
bool C3D_RENDER_RAYTRACING::Redraw(
bool aIsMoving, REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter )
bool aIsMoving, REPORTER* aStatusReporter, REPORTER* aWarningReporter )
{
bool requestRedraw = false;
@ -174,12 +174,12 @@ bool C3D_RENDER_RAYTRACING::Redraw(
// /////////////////////////////////////////////////////////////////////////
if( m_reloadRequested )
{
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Loading..." ) );
if( aStatusReporter )
aStatusReporter->Report( _( "Loading..." ) );
//aIsMoving = true;
requestRedraw = true;
reload( aStatusTextReporter, aWarningTextReporter );
reload( aStatusReporter, aWarningReporter );
}
@ -260,7 +260,7 @@ bool C3D_RENDER_RAYTRACING::Redraw(
if( ptrPBO )
{
render( ptrPBO, aStatusTextReporter );
render( ptrPBO, aStatusReporter );
if( m_rt_render_state != RT_RENDER_STATE_FINISH )
requestRedraw = true;
@ -299,7 +299,7 @@ bool C3D_RENDER_RAYTRACING::Redraw(
}
void C3D_RENDER_RAYTRACING::render( GLubyte *ptrPBO , REPORTER *aStatusTextReporter )
void C3D_RENDER_RAYTRACING::render( GLubyte* ptrPBO, REPORTER* aStatusReporter )
{
if( (m_rt_render_state == RT_RENDER_STATE_FINISH) ||
(m_rt_render_state >= RT_RENDER_STATE_MAX) )
@ -332,15 +332,15 @@ void C3D_RENDER_RAYTRACING::render( GLubyte *ptrPBO , REPORTER *aStatusTextRepor
switch( m_rt_render_state )
{
case RT_RENDER_STATE_TRACING:
rt_render_tracing( ptrPBO, aStatusTextReporter );
rt_render_tracing( ptrPBO, aStatusReporter );
break;
case RT_RENDER_STATE_POST_PROCESS_SHADE:
rt_render_post_process_shade( ptrPBO, aStatusTextReporter );
rt_render_post_process_shade( ptrPBO, aStatusReporter );
break;
case RT_RENDER_STATE_POST_PROCESS_BLUR_AND_FINISH:
rt_render_post_process_blur_finish( ptrPBO, aStatusTextReporter );
rt_render_post_process_blur_finish( ptrPBO, aStatusReporter );
break;
default:
@ -349,20 +349,20 @@ void C3D_RENDER_RAYTRACING::render( GLubyte *ptrPBO , REPORTER *aStatusTextRepor
break;
}
if( aStatusTextReporter && (m_rt_render_state == RT_RENDER_STATE_FINISH) )
if( aStatusReporter && ( m_rt_render_state == RT_RENDER_STATE_FINISH ) )
{
// Calculation time in seconds
const double calculation_time = (double)( GetRunningMicroSecs() -
m_stats_start_rendering_time ) / 1e6;
aStatusTextReporter->Report( wxString::Format( _( "Rendering time %.3f s" ),
aStatusReporter->Report( wxString::Format( _( "Rendering time %.3f s" ),
calculation_time ) );
}
}
void C3D_RENDER_RAYTRACING::rt_render_tracing( GLubyte *ptrPBO ,
REPORTER *aStatusTextReporter )
void C3D_RENDER_RAYTRACING::rt_render_tracing( GLubyte* ptrPBO ,
REPORTER* aStatusReporter )
{
m_isPreview = false;
@ -409,8 +409,8 @@ void C3D_RENDER_RAYTRACING::rt_render_tracing( GLubyte *ptrPBO ,
m_nrBlocksRenderProgress += numBlocksRendered;
if( aStatusTextReporter )
aStatusTextReporter->Report( wxString::Format( _( "Rendering: %.0f %%" ),
if( aStatusReporter )
aStatusReporter->Report( wxString::Format( _( "Rendering: %.0f %%" ),
(float)(m_nrBlocksRenderProgress * 100) /
(float)m_blockPositions.size() ) );
@ -906,15 +906,15 @@ void C3D_RENDER_RAYTRACING::rt_render_trace_block( GLubyte *ptrPBO ,
}
void C3D_RENDER_RAYTRACING::rt_render_post_process_shade( GLubyte *ptrPBO,
REPORTER *aStatusTextReporter )
void C3D_RENDER_RAYTRACING::rt_render_post_process_shade( GLubyte* ptrPBO,
REPORTER* aStatusReporter )
{
(void)ptrPBO; // unused
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
{
if( aStatusTextReporter )
aStatusTextReporter->Report( _("Rendering: Post processing shader") );
if( aStatusReporter )
aStatusReporter->Report( _( "Rendering: Post processing shader" ) );
std::atomic<size_t> nextBlock( 0 );
std::atomic<size_t> threadsFinished( 0 );
@ -958,9 +958,9 @@ void C3D_RENDER_RAYTRACING::rt_render_post_process_shade( GLubyte *ptrPBO,
void C3D_RENDER_RAYTRACING::rt_render_post_process_blur_finish( GLubyte *ptrPBO,
REPORTER *aStatusTextReporter )
REPORTER *aStatusReporter )
{
(void)aStatusTextReporter; //unused
(void) aStatusReporter; //unused
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
{

View File

@ -65,8 +65,7 @@ public:
// Imported from C3D_RENDER_BASE
void SetCurWindowSize( const wxSize &aSize ) override;
bool Redraw( bool aIsMoving, REPORTER* aStatusTextReporter,
REPORTER* aWarningTextReporter ) override;
bool Redraw( bool aIsMoving, REPORTER* aStatusReporter, REPORTER* aWarningReporter ) override;
int GetWaitForEditingTimeOut() override;
@ -75,12 +74,12 @@ private:
void initializeNewWindowSize();
void opengl_init_pbo();
void opengl_delete_pbo();
void reload( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter );
void reload( REPORTER* aStatusReporter, REPORTER* aWarningReporter );
void restart_render_state();
void rt_render_tracing( GLubyte *ptrPBO , REPORTER *aStatusTextReporter );
void rt_render_post_process_shade( GLubyte *ptrPBO , REPORTER *aStatusTextReporter );
void rt_render_post_process_blur_finish( GLubyte *ptrPBO , REPORTER *aStatusTextReporter );
void rt_render_tracing( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void rt_render_post_process_shade( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void rt_render_post_process_blur_finish( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void rt_render_trace_block( GLubyte *ptrPBO , signed int iBlock );
void rt_final_color( GLubyte *ptrPBO, const SFVEC3F &rgbColor, bool applyColorSpaceConversion );
@ -205,7 +204,7 @@ private:
void initialize_block_positions();
void render( GLubyte *ptrPBO, REPORTER *aStatusTextReporter );
void render( GLubyte* ptrPBO, REPORTER* aStatusReporter );
void render_preview( GLubyte *ptrPBO );
};

View File

@ -63,11 +63,11 @@ public:
* @brief Redraw - Ask to redraw the view
* @param aIsMoving: if the user is moving the scene, it should be render in
* preview mode
* @param aStatusTextReporter: a pointer to the status progress reporter
* @param aStatusReporter: a pointer to the status progress reporter
* @return it will return true if the render would like to redraw again
*/
virtual bool Redraw( bool aIsMoving, REPORTER* aStatusTextReporter = NULL,
REPORTER* aWarningTextReporter = NULL ) = 0;
virtual bool Redraw( bool aIsMoving, REPORTER* aStatusReporter = NULL,
REPORTER* aWarningReporter = NULL ) = 0;
/**
* @brief ReloadRequest - !TODO: this must be reviewed to add flags to

View File

@ -48,6 +48,7 @@
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/action_toolbar.h>
#include <widgets/infobar.h>
#include <wildcards_and_files_ext.h>
/**
@ -103,7 +104,7 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxSt
SetIcon( icon );
// Create the status line
static const int status_dims[5] = { -1, -1, 130, 130, 170 };
static const int status_dims[4] = { -1, 130, 130, 170 };
wxStatusBar *status_bar = CreateStatusBar( arrayDim( status_dims ) );
SetStatusWidths( arrayDim( status_dims ), status_dims );
@ -112,9 +113,6 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxSt
aParent->GetBoard(), m_boardAdapter, m_currentCamera,
Prj().Get3DCacheManager() );
if( m_canvas )
m_canvas->SetStatusBar( status_bar );
auto config = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
LoadSettings( config );
@ -140,13 +138,32 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxSt
CreateMenuBar();
ReCreateMainToolbar();
// Create the infobar
m_infoBar = new WX_INFOBAR( this, &m_auimgr );
m_auimgr.SetManagedWindow( this );
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
m_auimgr.AddPane( m_mainToolBar,
EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
m_auimgr.AddPane( m_infoBar,
EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
m_auimgr.AddPane( m_canvas,
EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
// Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
// hidding it.
m_auimgr.Update();
// We don't want the infobar displayed right away
m_auimgr.GetPane( "InfoBar" ).Hide();
m_auimgr.Update();
if( m_canvas )
{
m_canvas->SetInfoBar( m_infoBar );
m_canvas->SetStatusBar( status_bar );
}
// Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
// in order to receive mouse events. Otherwise, the user has to click somewhere on
// the canvas before it will respond to mouse wheel events.

View File

@ -55,7 +55,6 @@
enum EDA_3D_VIEWER_STATUSBAR
{
STATUS_TEXT = 0,
WARN_TEXT,
X_POS,
Y_POS
};

View File

@ -72,19 +72,20 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString& aFrameName, KIWAY* aKiway ) :
wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ),
TOOLS_HOLDER(),
KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ),
m_Ident( aFrameType ),
m_infoBar( nullptr ),
m_settingsManager( nullptr ),
m_fileHistory( nullptr ),
m_hasAutoSave( false ),
m_autoSaveState( false ),
m_autoSaveInterval(-1 ),
m_userUnits( EDA_UNITS::MILLIMETRES )
{
m_Ident = aFrameType;
m_hasAutoSave = false;
m_autoSaveState = false;
m_autoSaveInterval = -1;
m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
m_mruPath = wxStandardPaths::Get().GetDocumentsDir();
m_toolManager = nullptr;
m_settingsManager = nullptr;
m_FrameSize = wxSize( s_minsize_x, s_minsize_y );
m_mruPath = wxStandardPaths::Get().GetDocumentsDir();
m_FrameSize = wxSize( s_minsize_x, s_minsize_y );
// Set a reasonable minimal size for the frame
SetSizeHints( s_minsize_x, s_minsize_y, -1, -1, -1, -1 );

View File

@ -80,7 +80,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
m_canvas = NULL;
m_toolDispatcher = NULL;
m_messagePanel = NULL;
m_infoBar = nullptr;
m_currentScreen = NULL;
m_showBorderAndTitleBlock = false; // true to display reference sheet.
m_LastGridSizeId = 0;

View File

@ -27,6 +27,7 @@
#include <macros.h>
#include <reporter.h>
#include <widgets/infobar.h>
#include <wx_html_report_panel.h>
REPORTER& REPORTER::Report( const char* aText, SEVERITY aSeverity )
@ -140,3 +141,66 @@ REPORTER& STDOUT_REPORTER::GetInstance()
return *s_stdoutReporter;
}
REPORTER& STATUSBAR_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{
if( m_statusBar )
m_statusBar->SetStatusText( aText, m_position );
return *this;
}
bool STATUSBAR_REPORTER::HasMessage() const
{
if( m_statusBar )
return m_statusBar->GetStatusText().IsEmpty();
return false;
}
REPORTER& INFOBAR_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{
m_message = aText;
m_severity = aSeverity;
m_messageSet = true;
return *this;
}
bool INFOBAR_REPORTER::HasMessage() const
{
return !m_message.IsEmpty();
}
void INFOBAR_REPORTER::Finalize()
{
// Don't do anything if no message was ever given
if( !m_infoBar || !m_messageSet )
return;
// Short circuit if the message is empty and it is already hidden
if( !HasMessage() && !m_infoBar->IsShown() )
return;
int icon = wxICON_NONE;
switch( m_severity )
{
case RPT_SEVERITY_UNDEFINED: icon = wxICON_INFORMATION; break;
case RPT_SEVERITY_INFO: icon = wxICON_INFORMATION; break;
case RPT_SEVERITY_EXCLUSION: icon = wxICON_WARNING; break;
case RPT_SEVERITY_ACTION: icon = wxICON_WARNING; break;
case RPT_SEVERITY_WARNING: icon = wxICON_WARNING; break;
case RPT_SEVERITY_ERROR: icon = wxICON_ERROR; break;
case RPT_SEVERITY_IGNORE: icon = wxICON_INFORMATION; break;
}
if( HasMessage() )
m_infoBar->QueueShowMessage( m_message, icon );
else
m_infoBar->QueueDismiss();
}

View File

@ -28,15 +28,22 @@
#include <wx/timer.h>
wxDEFINE_EVENT( KIEVT_SHOW_INFOBAR, wxCommandEvent );
wxDEFINE_EVENT( KIEVT_DISMISS_INFOBAR, wxCommandEvent );
BEGIN_EVENT_TABLE( WX_INFOBAR, wxInfoBarGeneric )
EVT_COMMAND( wxID_ANY, KIEVT_SHOW_INFOBAR, WX_INFOBAR::OnShowInfoBar )
EVT_COMMAND( wxID_ANY, KIEVT_DISMISS_INFOBAR, WX_INFOBAR::OnDismissInfoBar )
EVT_BUTTON( ID_CLOSE_INFOBAR, WX_INFOBAR::OnCloseButton )
EVT_TIMER( ID_CLOSE_INFOBAR, WX_INFOBAR::OnTimer )
END_EVENT_TABLE()
WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager *aMgr, wxWindowID aWinid )
WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr, wxWindowID aWinid )
: wxInfoBarGeneric( aParent, aWinid ),
m_showTime( 0 ),
m_updateLock( false ),
m_showTimer( nullptr ),
m_auiManager( aMgr )
{
@ -58,18 +65,52 @@ WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager *aMgr, wxWindowID aWinid
sizer->SetItemMinSize( (size_t) 0, iconSize.x, sy );
// Forcefully remove all existing buttons added by the wx constructors.
// The default close button doesn't work with the AUI manager update scheme, so this
// ensures any close button displayed is ours.
RemoveAllButtons();
Layout();
}
WX_INFOBAR::~WX_INFOBAR()
{
delete m_showTimer;
}
void WX_INFOBAR::SetShowTime( int aTime )
{
m_showTime = aTime;
}
void WX_INFOBAR::QueueShowMessage( const wxString& aMessage, int aFlags )
{
wxCommandEvent* evt = new wxCommandEvent( KIEVT_SHOW_INFOBAR );
evt->SetString( aMessage.c_str() );
evt->SetInt( aFlags );
GetEventHandler()->QueueEvent( evt );
}
void WX_INFOBAR::QueueDismiss()
{
wxCommandEvent* evt = new wxCommandEvent( KIEVT_DISMISS_INFOBAR );
GetEventHandler()->QueueEvent( evt );
}
void WX_INFOBAR::ShowMessageFor( const wxString& aMessage, int aTime, int aFlags )
{
// Don't do anything if we requested the UI update
if( m_updateLock )
return;
m_showTime = aTime;
ShowMessage( aMessage, aFlags );
}
@ -77,6 +118,12 @@ void WX_INFOBAR::ShowMessageFor( const wxString& aMessage, int aTime, int aFlags
void WX_INFOBAR::ShowMessage( const wxString& aMessage, int aFlags )
{
// Don't do anything if we requested the UI update
if( m_updateLock )
return;
m_updateLock = true;
wxInfoBarGeneric::ShowMessage( aMessage, aFlags );
if( m_auiManager )
@ -84,15 +131,25 @@ void WX_INFOBAR::ShowMessage( const wxString& aMessage, int aFlags )
if( m_showTime > 0 )
m_showTimer->StartOnce( m_showTime );
m_updateLock = false;
}
void WX_INFOBAR::Dismiss()
{
// Don't do anything if we requested the UI update
if( m_updateLock )
return;
m_updateLock = true;
wxInfoBarGeneric::Dismiss();
if( m_auiManager )
UpdateAuiLayout( false );
m_updateLock = false;
}
@ -176,6 +233,20 @@ void WX_INFOBAR::RemoveAllButtons()
}
void WX_INFOBAR::OnShowInfoBar( wxCommandEvent& aEvent )
{
RemoveAllButtons();
AddCloseButton();
ShowMessage( aEvent.GetString(), aEvent.GetInt() );
}
void WX_INFOBAR::OnDismissInfoBar( wxCommandEvent& aEvent )
{
Dismiss();
}
void WX_INFOBAR::OnCloseButton( wxCommandEvent& aEvent )
{
Dismiss();

View File

@ -79,6 +79,7 @@ class PANEL_HOTKEYS_EDITOR;
class FILE_HISTORY;
class SETTINGS_MANAGER;
class APP_SETTINGS_BASE;
class WX_INFOBAR;
struct WINDOW_SETTINGS;
enum id_librarytype {
@ -133,6 +134,8 @@ protected:
wxAuiManager m_auimgr;
wxString m_perspective; // wxAuiManager perspective.
WX_INFOBAR* m_infoBar; // Infobar for the frame
wxString m_configName; // Prefix used to identify some params (frame size...)
// and to name some config files (legacy hotkey files)

View File

@ -41,7 +41,6 @@ class COLOR_SETTINGS;
class TOOL_MENU;
class APP_SETTINGS_BASE;
class EDA_INFOBAR_PANEL;
class WX_INFOBAR;
namespace KIGFX
{
@ -115,8 +114,6 @@ protected:
EDA_MSG_PANEL* m_messagePanel;
int m_MsgFrameHeight;
WX_INFOBAR* m_infoBar;
COLOR_SETTINGS* m_colorSettings;
/// The current canvas type

View File

@ -111,9 +111,6 @@ enum main_id
ID_OPT_TOOLBAR,
ID_AUX_TOOLBAR,
// ID for the close button on the frame's infobar
ID_CLOSE_INFOBAR,
ID_EDIT_HOTKEY,
ID_NO_TOOL_SELECTED,

View File

@ -35,9 +35,11 @@
* me to write this.
*/
class wxStatusBar;
class wxTextCtrl;
class wxHtmlListbox;
class WX_HTML_REPORT_PANEL;
class WX_INFOBAR;
/**
@ -224,6 +226,7 @@ public:
bool HasMessage() const override { return false; }
};
/**
* STDOUT_REPORTER
*
@ -247,4 +250,61 @@ public:
bool HasMessage() const override { return false; }
};
/**
* STATUSBAR_REPORTER
* is a wrapper for reporting to a specific text location in a statusbar
*/
class STATUSBAR_REPORTER : public REPORTER
{
private:
wxStatusBar* m_statusBar;
int m_position;
public:
STATUSBAR_REPORTER( wxStatusBar* aStatusBar, int aPosition = 0 )
: REPORTER(), m_statusBar( aStatusBar ), m_position( aPosition )
{
}
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override;
};
/**
* INFOBAR_REPORTER
* is a wrapper for reporting to a WX_INFOBAR UI element.
*
* The infobar is not updated until the @c Finalize() method is called. That method will
* queue either a show message or a dismiss event for the infobar - so this reporter is
* safe to use inside a paint event without causing an infinite paint event loop.
*
* No action is taken if no message is given to the reporter.
*/
class INFOBAR_REPORTER : public REPORTER
{
private:
bool m_messageSet;
WX_INFOBAR* m_infoBar;
wxString m_message;
SEVERITY m_severity;
public:
INFOBAR_REPORTER( WX_INFOBAR* aInfoBar )
: REPORTER(), m_messageSet( false ), m_infoBar( aInfoBar )
{
}
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override;
/**
* Update the infobar with the reported text.
*/
void Finalize();
};
#endif // _REPORTER_H_

View File

@ -21,20 +21,49 @@
#ifndef INFOBAR_H_
#define INFOBAR_H_
#include <wx/event.h>
#include <wx/infobar.h>
#include <wx/wx.h>
class wxAuiManager;
enum
{
/// ID for the close button on the frame's infobar
ID_CLOSE_INFOBAR = 2000,
};
wxDECLARE_EVENT( KIEVT_SHOW_INFOBAR, wxCommandEvent );
wxDECLARE_EVENT( KIEVT_DISMISS_INFOBAR, wxCommandEvent );
/**
* A modified version of the wxInfoBar class that allows us to:
* * Show the close button along with the other buttons
* * Remove all user-provided buttons at once
* * Allow automaticly hiding the infobar after a time period
* * Show/hide using events
* * Place it inside an AUI manager
*
* This inherits from the generic infobar because the native infobar
* on GTK doesn't include the icon on the left and it looks worse.
*
* There are 2 events associated with the infobar:
*
* KIEVT_SHOW_INFOBAR:
* An event that tells the infobar to show a message.
*
* The message text is contained inside the string component,
* and the message flag is contained inside the int component.
*
* Sample event creation code:
* wxCommandEvent* evt = new wxCommandEvent( KIEVT_SHOW_INFOBAR );
* evt->SetString( "A message to show" );
* evt->SetInt( wxICON_WARNING );
*
* KIEVT_DISMISS_INFOBAR:
* An event that tells the infobar to hide itself.
*/
class WX_INFOBAR : public wxInfoBarGeneric
{
@ -48,6 +77,8 @@ public:
*/
WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr = nullptr, wxWindowID aWinid = wxID_ANY );
~WX_INFOBAR();
/**
* Set the time period to show the infobar.
*
@ -112,7 +143,33 @@ public:
*/
void Dismiss() override;
/**
* Send the infobar an event telling it to show a message.
*
* @param aMessage is the message to display
* @param aFlags is the flag containing the icon to display on the left side of the infobar
*/
void QueueShowMessage( const wxString& aMessage, int aFlags = wxICON_INFORMATION );
/**
* Send the infobar an event telling it to hide itself.
*/
void QueueDismiss();
protected:
/**
* Event handler for showing the infobar using a wxCommandEvent of the type
* KIEVT_SHOW_INFOBAR. The message is stored inside the string field, and the
* icon flag is stored inside the int field.
*/
void OnShowInfoBar( wxCommandEvent& aEvent );
/**
* Event handler for dismissing the infobar using a wxCommandEvent of the type
* KIEVT_DISMISS_INFOBAR.
*/
void OnDismissInfoBar( wxCommandEvent& aEvent );
/**
* Event handler for the close button.
* This is bound to ID_CLOSE_INFOBAR on the infobar.
@ -132,6 +189,7 @@ protected:
void UpdateAuiLayout( bool aShow );
int m_showTime; ///< The time to show the infobar. 0 = don't auto hide
bool m_updateLock; ///< True if this infobar requested the UI update
wxTimer* m_showTimer; ///< The timer counting the autoclose period
wxAuiManager* m_auiManager; ///< The AUI manager that contains this infobar