Now that we allow multiple 3DViewers, we need to make sure we have the right one.

Note that FindWindow() searches children, whereas FindWindowByName() searches
all windows.
This commit is contained in:
Jeff Young 2019-06-04 11:28:05 +01:00
parent 7c337ec45d
commit ea3c29e3ec
3 changed files with 10 additions and 24 deletions

View File

@ -101,7 +101,7 @@ public:
~PCB_BASE_FRAME();
/**
* @return a reference to the 3D viewer frame, when exists, or NULL
* @return a reference to the child 3D viewer frame, when exists, or NULL
*/
EDA_3D_VIEWER* Get3DViewerFrame();

View File

@ -587,10 +587,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
onBoardLoaded();
// Refresh the 3D view, if any
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame )
draw3DFrame->NewDisplay();
Update3DView( false );
#if 0 && defined(DEBUG)
// Output the board object tree to stdout, but please run from command prompt:

View File

@ -114,26 +114,21 @@ PCB_BASE_FRAME::~PCB_BASE_FRAME()
EDA_3D_VIEWER* PCB_BASE_FRAME::Get3DViewerFrame()
{
// return the 3D viewer frame, when exists, or NULL
return static_cast<EDA_3D_VIEWER*>
( wxWindow::FindWindowByName( VIEWER3D_FRAMENAME ) );
return dynamic_cast<EDA_3D_VIEWER*>( FindWindow( VIEWER3D_FRAMENAME ) );
}
void PCB_BASE_FRAME::Update3DView( bool aForceReload, const wxString* aTitle )
{
// Update the 3D view only if the viewer is opened by this frame
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
// if I am not the owner, do not use the current viewer instance
// JEY TODO: need to keep looking for one that is ours....
if( !draw3DFrame || draw3DFrame->Parent() != this )
return;
if( draw3DFrame )
{
if( aTitle )
draw3DFrame->SetTitle( *aTitle );
if( aTitle )
draw3DFrame->SetTitle( *aTitle );
draw3DFrame->NewDisplay( aForceReload );
draw3DFrame->NewDisplay( aForceReload );
}
}
@ -395,10 +390,6 @@ EDA_3D_VIEWER* PCB_BASE_FRAME::CreateAndShow3D_Frame()
{
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
// if I am not the owner, do not use the current viewer instance
if( draw3DFrame && draw3DFrame->Parent() != this )
draw3DFrame = nullptr;
if( !draw3DFrame )
draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
@ -772,13 +763,11 @@ void PCB_BASE_FRAME::CommonSettingsChanged()
ReCreateVToolbar();
ReCreateOptToolbar();
// The 3D viewer isn't in the Kiway, so send its update manually
EDA_3D_VIEWER* viewer = Get3DViewerFrame();
if( viewer )
{
// The 3D viewer isn't in the Kiway, so send its update manually
viewer->CommonSettingsChanged();
}
}