Pcbnew: update immediately the 3D viewer opened from the footprint editor/viewer/wizard after a change.

This commit is contained in:
jean-pierre charras 2017-05-13 08:17:06 +02:00
parent b823d0b784
commit 305a166e95
9 changed files with 46 additions and 24 deletions

View File

@ -224,15 +224,23 @@ EDA_3D_VIEWER::~EDA_3D_VIEWER()
//m_canvas = 0; //m_canvas = 0;
} }
void EDA_3D_VIEWER::ReloadRequest() void EDA_3D_VIEWER::ReloadRequest()
{ {
// This will schedule a request to load later // This will schedule a request to load later
if( m_canvas ) if( m_canvas )
m_canvas->ReloadRequest( GetBoard(), Prj().Get3DCacheManager() ); 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 void EDA_3D_VIEWER::NewDisplay( bool aForceImmediateRedraw )
//m_canvas->Refresh(); {
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();
} }

View File

@ -63,12 +63,27 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER
BOARD* GetBoard() { return Parent()->GetBoard(); } 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(); void ReloadRequest();
// !TODO: review this function // !TODO: review this function: it need a way to tell what changed,
// !TODO: this need a way to tell what changed to the reload will only // to only reload/rebuild things that have really changed
// change the things on a need base /**
void NewDisplay( int dummy = 0 ) { ReloadRequest(); } * 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 * Function SetDefaultFileName

View File

@ -539,7 +539,7 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame ) if( draw3DFrame )
draw3DFrame->NewDisplay(); draw3DFrame->NewDisplay( true );
} }

View File

@ -25,6 +25,9 @@
One component per line One component per line
Fields are Fields are
Ref,Value, Footprint, Datasheet, Field5, Field4, price Ref,Value, Footprint, Datasheet, Field5, Field4, price
Command line
xsltproc -o "%O.csv" "pathToFile/bom2csv.xsl" "%I"
--> -->
<!DOCTYPE xsl:stylesheet [ <!DOCTYPE xsl:stylesheet [

View File

@ -24,12 +24,12 @@
--> -->
<!-- <!--
@package @package
Command line:
xsltproc -o "%O.csv" "pathToFile/bom2csv.xsl" "%I"
Output format Output format
Reference, Value, Fields[n], Library, Library Ref Reference, Value, Fields[n], Library, Library Ref
U1, PIC32MX, Fields[n], KicadLib, PIC U1, PIC32MX, Fields[n], KicadLib, PIC
Command line:
xsltproc -o "%O.csv" "pathToFile/bom2csv.xsl" "%I"
--> -->
<!DOCTYPE xsl:stylesheet [ <!DOCTYPE xsl:stylesheet [

View File

@ -637,11 +637,8 @@ void FOOTPRINT_WIZARD_FRAME::Update3D_Frame( bool aForceReloadFootprint )
if( aForceReloadFootprint ) if( aForceReloadFootprint )
{ {
draw3DFrame->ReloadRequest();
// Force 3D screen refresh immediately // Force 3D screen refresh immediately
if( GetBoard()->m_Modules ) draw3DFrame->NewDisplay( true );
draw3DFrame->NewDisplay();
} }
} }

View File

@ -190,7 +190,7 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard( wxCommandEvent& event )
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame ) 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(); EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame ) if( draw3DFrame )
draw3DFrame->NewDisplay(); draw3DFrame->NewDisplay( true );
GetScreen()->ClrModify(); GetScreen()->ClrModify();
} }
@ -494,7 +494,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame ) if( draw3DFrame )
draw3DFrame->NewDisplay(); draw3DFrame->NewDisplay( true );
} }
break; break;
@ -556,7 +556,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame ) if( draw3DFrame )
draw3DFrame->NewDisplay(); draw3DFrame->NewDisplay( true );
} }
GetScreen()->ClrModify(); GetScreen()->ClrModify();

View File

@ -765,7 +765,9 @@ void FOOTPRINT_EDIT_FRAME::OnModify()
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame ) if( draw3DFrame )
draw3DFrame->ReloadRequest(); {
draw3DFrame->NewDisplay( true );
}
} }

View File

@ -689,11 +689,8 @@ void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint )
if( aForceReloadFootprint ) if( aForceReloadFootprint )
{ {
draw3DFrame->ReloadRequest();
// Force 3D screen refresh immediately // Force 3D screen refresh immediately
if( GetBoard()->m_Modules ) draw3DFrame->NewDisplay( true );
draw3DFrame->NewDisplay();
} }
} }