Move 3d viewer board outline warning to the status bar

This is less intrusive than a dialog that is constantly opening
whenever the 3d view is refreshed.
This commit is contained in:
Ian McInerney 2020-02-03 22:09:14 +00:00
parent a1c2abaff5
commit 5053f58bfc
12 changed files with 51 additions and 31 deletions

View File

@ -271,7 +271,7 @@ double CINFO3D_VISU::GetCircleCorrectionFactor( int aNrSides ) const
}
void CINFO3D_VISU::InitSettings( REPORTER *aStatusTextReporter )
void CINFO3D_VISU::InitSettings( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter )
{
wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::InitSettings" ) );
@ -427,7 +427,10 @@ void CINFO3D_VISU::InitSettings( REPORTER *aStatusTextReporter )
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Build board body" ) );
createBoardPolygon();
if( !createBoardPolygon() )
aWarningTextReporter->Report( _( "Warning: Board outline is not closed" ) );
else
aWarningTextReporter->Report( wxEmptyString );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_stopCreateBoardPolyTime = GetRunningMicroSecs();
@ -452,18 +455,13 @@ void CINFO3D_VISU::InitSettings( REPORTER *aStatusTextReporter )
}
void CINFO3D_VISU::createBoardPolygon()
bool CINFO3D_VISU::createBoardPolygon()
{
m_board_poly.RemoveAllContours();
wxString errmsg;
if( !m_board->GetBoardPolygonOutlines( m_board_poly, /*allLayerHoles,*/ &errmsg ) )
{
errmsg.append( wxT( "\n\n" ) );
errmsg.append( _( "Cannot determine the board outline." ) );
wxLogMessage( errmsg );
}
return m_board->GetBoardPolygonOutlines( m_board_poly, /*allLayerHoles,*/ &errmsg );
}

View File

@ -131,8 +131,9 @@ class CINFO3D_VISU
* @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
*/
void InitSettings( REPORTER *aStatusTextReporter );
void InitSettings( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter );
/**
* @brief BiuTo3Dunits - Board integer units To 3D units
@ -418,7 +419,12 @@ class CINFO3D_VISU
const MAP_POLY &GetPolyMapHoles_Outer() const { return m_layers_outer_holes_poly; }
private:
void createBoardPolygon();
/**
* Create the board outline polygon.
*
* @return false if the outline could not be created
*/
bool createBoardPolygon();
void createLayers( REPORTER *aStatusTextReporter );
void destroyLayers();

View File

@ -311,10 +311,10 @@ void EDA_3D_CANVAS::DisplayStatus()
wxString msg;
msg.Printf( "dx %3.2f", m_settings.CameraGet().GetCameraPos().x );
m_parentStatusBar->SetStatusText( msg, 1 );
m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::X_POS ) );
msg.Printf( "dy %3.2f", m_settings.CameraGet().GetCameraPos().y );
m_parentStatusBar->SetStatusText( msg, 2 );
m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::Y_POS ) );
}
}
@ -346,7 +346,10 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
// !TODO: implement error reporter
//WX_STRING_REPORTER errorReporter( &err_messages );
STATUS_TEXT_REPORTER activityReporter( m_parentStatusBar, 0 );
STATUS_TEXT_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();
@ -438,8 +441,8 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
{
m_3d_render->SetCurWindowSize( clientSize );
requested_redraw = m_3d_render->Redraw( m_mouse_was_moved || m_camera_is_moving,
&activityReporter );
requested_redraw = m_3d_render->Redraw(
m_mouse_was_moved || m_camera_is_moving, &activityReporter, &warningReporter );
}
if( m_render_pivot )

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 )
void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter )
{
m_reloadRequested = false;
@ -348,7 +348,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER *aStatusTextReporter )
unsigned stats_startReloadTime = GetRunningMicroSecs();
m_settings.InitSettings( aStatusTextReporter );
m_settings.InitSettings( aStatusTextReporter, aWarningTextReporter );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_endReloadTime = GetRunningMicroSecs();

View File

@ -516,8 +516,8 @@ void init_lights(void)
}
bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving,
REPORTER *aStatusTextReporter )
bool C3D_RENDER_OGL_LEGACY::Redraw(
bool aIsMoving, REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter )
{
// Initialize openGL
if( !m_is_opengl_initialized )
@ -533,7 +533,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving,
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Loading..." ) );
reload( aStatusTextReporter );
reload( aStatusTextReporter, aWarningTextReporter );
setupMaterials();
// generate a new 3D grid as the size of the board may had changed

View File

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

View File

@ -255,7 +255,7 @@ void C3D_RENDER_RAYTRACING::create_3d_object_from( CCONTAINER& aDstContainer,
}
void C3D_RENDER_RAYTRACING::reload( REPORTER *aStatusTextReporter )
void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter )
{
m_reloadRequested = false;
@ -270,7 +270,7 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER *aStatusTextReporter )
unsigned stats_startReloadTime = GetRunningMicroSecs();
m_settings.InitSettings( aStatusTextReporter );
m_settings.InitSettings( aStatusTextReporter, aWarningTextReporter );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_endReloadTime = GetRunningMicroSecs();

View File

@ -147,7 +147,8 @@ static inline void SetPixel( GLubyte *p, const CCOLORRGB &v )
}
bool C3D_RENDER_RAYTRACING::Redraw( bool aIsMoving, REPORTER *aStatusTextReporter )
bool C3D_RENDER_RAYTRACING::Redraw(
bool aIsMoving, REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter )
{
bool requestRedraw = false;
@ -178,7 +179,7 @@ bool C3D_RENDER_RAYTRACING::Redraw( bool aIsMoving, REPORTER *aStatusTextReporte
//aIsMoving = true;
requestRedraw = true;
reload( aStatusTextReporter );
reload( aStatusTextReporter, aWarningTextReporter );
}

View File

@ -65,7 +65,8 @@ public:
// Imported from C3D_RENDER_BASE
void SetCurWindowSize( const wxSize &aSize ) override;
bool Redraw(bool aIsMoving, REPORTER *aStatusTextReporter ) override;
bool Redraw( bool aIsMoving, REPORTER* aStatusTextReporter,
REPORTER* aWarningTextReporter ) override;
int GetWaitForEditingTimeOut() override;
@ -74,7 +75,7 @@ private:
void initializeNewWindowSize();
void opengl_init_pbo();
void opengl_delete_pbo();
void reload( REPORTER *aStatusTextReporter );
void reload( REPORTER* aStatusTextReporter, REPORTER* aWarningTextReporter );
void restart_render_state();
void rt_render_tracing( GLubyte *ptrPBO , REPORTER *aStatusTextReporter );

View File

@ -66,7 +66,8 @@ public:
* @param aStatusTextReporter: 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 ) = 0;
virtual bool Redraw( bool aIsMoving, REPORTER* aStatusTextReporter = NULL,
REPORTER* aWarningTextReporter = NULL ) = 0;
/**
* @brief ReloadRequest - !TODO: this must be reviewed to add flags to

View File

@ -167,7 +167,7 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
// Create the status line
static const int status_dims[4] = { -1, 130, 130, 170 };
static const int status_dims[5] = { -1, -1, 130, 130, 170 };
wxStatusBar *status_bar = CreateStatusBar( arrayDim( status_dims ) );
SetStatusWidths( arrayDim( status_dims ), status_dims );

View File

@ -50,6 +50,15 @@
#define QUALIFIED_VIEWER3D_FRAMENAME( parent ) \
( wxString( VIEWER3D_FRAMENAME ) + wxT( ":" ) + parent->GetName() )
enum EDA_3D_VIEWER_STATUSBAR
{
STATUS_TEXT = 0,
WARN_TEXT,
X_POS,
Y_POS
};
/**
* Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard
*/