X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_PreviewDlg.cxx;h=96d2e4c7c5fcdd312eeb50a30b75da9c318c2e42;hp=3fc6b4776bec1966066417f5e8eb629f443c0583;hb=cb55604f37e3d2583272fd436bb6557b041948b5;hpb=b0a908c0d20341651771d0249fb10882f54b2aad diff --git a/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx b/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx index 3fc6b4776..96d2e4c7c 100644 --- a/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -45,11 +45,13 @@ // purpose : //================================================================================= SMESHGUI_PreviewDlg::SMESHGUI_PreviewDlg(SMESHGUI* theModule) : - mySMESHGUI(theModule), QDialog(SMESH::GetDesktop( theModule )), + mySMESHGUI(theModule), myIsApplyAndClose( false ) { mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI )); + connect(mySMESHGUI, SIGNAL(SignalCloseView()), this, SLOT(onCloseView())); + connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), this, SLOT(onOpenView())); } //================================================================================= @@ -66,7 +68,7 @@ SMESHGUI_PreviewDlg::~SMESHGUI_PreviewDlg() // purpose : Show preview in the viewer //================================================================================= void SMESHGUI_PreviewDlg::showPreview(){ - if(mySimulation) + if(mySimulation && mySimulation->GetActor()) mySimulation->SetVisibility(true); } @@ -75,7 +77,7 @@ void SMESHGUI_PreviewDlg::showPreview(){ // purpose : Hide preview in the viewer //================================================================================= void SMESHGUI_PreviewDlg::hidePreview(){ - if(mySimulation) + if(mySimulation && mySimulation->GetActor()) mySimulation->SetVisibility(false); } @@ -87,7 +89,6 @@ void SMESHGUI_PreviewDlg::connectPreviewControl(){ connect(myPreviewCheckBox, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool))); } - //================================================================================= // function : toDisplaySimulation // purpose : @@ -100,7 +101,7 @@ void SMESHGUI_PreviewDlg::toDisplaySimulation() { // function : onDisplaySimulation // purpose : //================================================================================= -void SMESHGUI_PreviewDlg::onDisplaySimulation(bool toDisplayPreview) { +void SMESHGUI_PreviewDlg::onDisplaySimulation(bool /*toDisplayPreview*/) { //Empty implementation here } @@ -124,16 +125,38 @@ bool SMESHGUI_PreviewDlg::isApplyAndClose() const return myIsApplyAndClose; } +//================================================================================= +// function : onCloseView() +// purpose : SLOT called when close view +//================================================================================= +void SMESHGUI_PreviewDlg::onCloseView() +{ + if ( mySimulation && mySimulation->GetActor()) + mySimulation->SetVisibility(false); + delete mySimulation; + mySimulation=0; +} +//================================================================================= +// function : onOpenView() +// purpose : SLOT called when open view +//================================================================================= +void SMESHGUI_PreviewDlg::onOpenView() +{ + if ( !mySimulation) + mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI )); +} //================================================================================= // class : SMESHGUI_SMESHGUI_MultiPreviewDlg() // purpose : //================================================================================= SMESHGUI_MultiPreviewDlg::SMESHGUI_MultiPreviewDlg( SMESHGUI* theModule ) : - mySMESHGUI( theModule ), QDialog( SMESH::GetDesktop( theModule ) ), + mySMESHGUI( theModule ), myIsApplyAndClose( false ) { + mySimulationList.clear(); + connect(mySMESHGUI, SIGNAL(SignalCloseView()), this, SLOT(onCloseView())); } //================================================================================= @@ -152,7 +175,8 @@ SMESHGUI_MultiPreviewDlg::~SMESHGUI_MultiPreviewDlg() void SMESHGUI_MultiPreviewDlg::showPreview() { for ( int i = 0; i < mySimulationList.count(); i++ ) - mySimulationList[i]->SetVisibility( true ); + if(mySimulationList[i] && mySimulationList[i]->GetActor()) + mySimulationList[i]->SetVisibility( true ); } //================================================================================= @@ -162,7 +186,8 @@ void SMESHGUI_MultiPreviewDlg::showPreview() void SMESHGUI_MultiPreviewDlg::hidePreview() { for ( int i = 0; i < mySimulationList.count(); i++ ) - mySimulationList[i]->SetVisibility( false ); + if(mySimulationList[i] && mySimulationList[i]->GetActor()) + mySimulationList[i]->SetVisibility( false ); } //================================================================================= @@ -174,7 +199,6 @@ void SMESHGUI_MultiPreviewDlg::connectPreviewControl() connect( myPreviewCheckBox, SIGNAL( toggled( bool ) ), this, SLOT( onDisplaySimulation( bool ) ) ); } - //================================================================================= // function : toDisplaySimulation // purpose : @@ -188,7 +212,7 @@ void SMESHGUI_MultiPreviewDlg::toDisplaySimulation() // function : onDisplaySimulation // purpose : //================================================================================= -void SMESHGUI_MultiPreviewDlg::onDisplaySimulation( bool toDisplayPreview ) +void SMESHGUI_MultiPreviewDlg::onDisplaySimulation( bool /*toDisplayPreview*/ ) { //Empty implementation here } @@ -224,6 +248,16 @@ void SMESHGUI_MultiPreviewDlg::setSimulationPreview( QListSetData( theMeshPreviewStruct[i].operator->() ); + mySimulationList[i]->SetData( theMeshPreviewStruct[i].in() ); } } + +//================================================================================= +// function : onCloseView() +// purpose : SLOT called when close view +//================================================================================= +void SMESHGUI_MultiPreviewDlg::onCloseView() +{ + qDeleteAll( mySimulationList ); + mySimulationList.clear(); +}