diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.cpp b/3d-viewer/3d_viewer/eda_3d_viewer.cpp index e1d85fbf3b..32231c9cd1 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer.cpp @@ -224,15 +224,23 @@ EDA_3D_VIEWER::~EDA_3D_VIEWER() //m_canvas = 0; } + void EDA_3D_VIEWER::ReloadRequest() { // This will schedule a request to load later if( m_canvas ) m_canvas->ReloadRequest( GetBoard(), Prj().Get3DCacheManager() ); +} - // This function is used by moduleframe.cpp - // while editing the pcb board, so it will not redraw to not slow the pcbnew - //m_canvas->Refresh(); + +void EDA_3D_VIEWER::NewDisplay( bool aForceImmediateRedraw ) +{ + ReloadRequest(); + + // After the ReloadRequest call, the refresh often takes a bit of time, + // and it is made here only on request. + if( aForceImmediateRedraw ) + m_canvas->Refresh(); } diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.h b/3d-viewer/3d_viewer/eda_3d_viewer.h index ec4efc0303..d620a46588 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.h +++ b/3d-viewer/3d_viewer/eda_3d_viewer.h @@ -63,12 +63,27 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER BOARD* GetBoard() { return Parent()->GetBoard(); } + /** + * Request reloading the 3D view. However the request will be executed + * only when the 3D canvas is refreshed. + * It allows to prepare changes and request for 3D rebuild only when all + * changes are committed. + * This is made because the 3D rebuild can take a long time, and this rebuild + * cannot always made after each change, for calculation time reason. + */ void ReloadRequest(); - // !TODO: review this function - // !TODO: this need a way to tell what changed to the reload will only - // change the things on a need base - void NewDisplay( int dummy = 0 ) { ReloadRequest(); } + // !TODO: review this function: it need a way to tell what changed, + // to only reload/rebuild things that have really changed + /** + * Reload and refresh (rebuild) the 3D scene. + * Warning: rebuilding the 3D scene can take a bit of time, so + * rebuilding the scene can be immediate, or made later, during + * the next 3D canvas refresh (on zoom for instance) + * @param aForceImmediateRedraw = true to immediately rebuild the 3D scene, + * false to wait a refresh later. + */ + void NewDisplay( bool aForceImmediateRedraw = false ); /** * Function SetDefaultFileName diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index a9562f0371..21ac6f27b8 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -539,7 +539,7 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); if( draw3DFrame ) - draw3DFrame->NewDisplay(); + draw3DFrame->NewDisplay( true ); } diff --git a/eeschema/plugins/bom2csv.xsl b/eeschema/plugins/bom2csv.xsl index 87cfdd4646..67d588b381 100644 --- a/eeschema/plugins/bom2csv.xsl +++ b/eeschema/plugins/bom2csv.xsl @@ -25,6 +25,9 @@ One component per line Fields are Ref,Value, Footprint, Datasheet, Field5, Field4, price + + Command line + xsltproc -o "%O.csv" "pathToFile/bom2csv.xsl" "%I" --> ReloadRequest(); - // Force 3D screen refresh immediately - if( GetBoard()->m_Modules ) - draw3DFrame->NewDisplay(); + draw3DFrame->NewDisplay( true ); } } diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index d3aa7bee1b..8d99009879 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -190,7 +190,7 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard( wxCommandEvent& event ) EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); if( draw3DFrame ) - draw3DFrame->NewDisplay(); + draw3DFrame->NewDisplay( true ); } @@ -370,7 +370,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); if( draw3DFrame ) - draw3DFrame->NewDisplay(); + draw3DFrame->NewDisplay( true ); GetScreen()->ClrModify(); } @@ -494,7 +494,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); if( draw3DFrame ) - draw3DFrame->NewDisplay(); + draw3DFrame->NewDisplay( true ); } break; @@ -556,7 +556,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); if( draw3DFrame ) - draw3DFrame->NewDisplay(); + draw3DFrame->NewDisplay( true ); } GetScreen()->ClrModify(); diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 7cfa497f9b..052f2d1465 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -765,7 +765,9 @@ void FOOTPRINT_EDIT_FRAME::OnModify() EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); if( draw3DFrame ) - draw3DFrame->ReloadRequest(); + { + draw3DFrame->NewDisplay( true ); + } } diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index d8693c926a..4b4bf5cbcc 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -689,11 +689,8 @@ void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint ) if( aForceReloadFootprint ) { - draw3DFrame->ReloadRequest(); - // Force 3D screen refresh immediately - if( GetBoard()->m_Modules ) - draw3DFrame->NewDisplay(); + draw3DFrame->NewDisplay( true ); } }