X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_PreviewDlg.cxx;h=8dc5f52c936104e0451554d3ae1b8ec8c3cbf321;hp=0a9bf6842499a8ab605b2e2d8cd96df17e2601ad;hb=8301b1e71a0a9833c5bcf7951b426949f647ae9f;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6 diff --git a/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx b/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx index 0a9bf6842..8dc5f52c9 100644 --- a/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_PreviewDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 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 @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -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 : @@ -123,3 +124,140 @@ 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 ) : + QDialog( SMESH::GetDesktop( theModule ) ), + mySMESHGUI( theModule ), + myIsApplyAndClose( false ) +{ + mySimulationList.clear(); + connect(mySMESHGUI, SIGNAL(SignalCloseView()), this, SLOT(onCloseView())); +} + +//================================================================================= +// function : ~SMESHGUI_MultiPreviewDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_MultiPreviewDlg::~SMESHGUI_MultiPreviewDlg() +{ + qDeleteAll( mySimulationList ); +} + +//================================================================================= +// function : showPreview +// purpose : Show preview in the viewer +//================================================================================= +void SMESHGUI_MultiPreviewDlg::showPreview() +{ + for ( int i = 0; i < mySimulationList.count(); i++ ) + if(mySimulationList[i] && mySimulationList[i]->GetActor()) + mySimulationList[i]->SetVisibility( true ); +} + +//================================================================================= +// function : hidePreview +// purpose : Hide preview in the viewer +//================================================================================= +void SMESHGUI_MultiPreviewDlg::hidePreview() +{ + for ( int i = 0; i < mySimulationList.count(); i++ ) + if(mySimulationList[i] && mySimulationList[i]->GetActor()) + mySimulationList[i]->SetVisibility( false ); +} + +//================================================================================= +// function : connectPreviewControl +// purpose : Connect the preview check box +//================================================================================= +void SMESHGUI_MultiPreviewDlg::connectPreviewControl() +{ + connect( myPreviewCheckBox, SIGNAL( toggled( bool ) ), this, SLOT( onDisplaySimulation( bool ) ) ); +} + +//================================================================================= +// function : toDisplaySimulation +// purpose : +//================================================================================= +void SMESHGUI_MultiPreviewDlg::toDisplaySimulation() +{ + onDisplaySimulation( true ); +} + +//================================================================================= +// function : onDisplaySimulation +// purpose : +//================================================================================= +void SMESHGUI_MultiPreviewDlg::onDisplaySimulation( bool toDisplayPreview ) +{ + //Empty implementation here +} + +//================================================================ +// Function : setIsApplyAndClose +// Purpose : Set value of the flag indicating that the dialog is +// accepted by Apply & Close button +//================================================================ +void SMESHGUI_MultiPreviewDlg::setIsApplyAndClose( const bool theFlag ) +{ + myIsApplyAndClose = theFlag; +} + +//================================================================ +// Function : isApplyAndClose +// Purpose : Get value of the flag indicating that the dialog is +// accepted by Apply & Close button +//================================================================ +bool SMESHGUI_MultiPreviewDlg::isApplyAndClose() const +{ + return myIsApplyAndClose; +} + +//================================================================ +// Function : setSimulationPreview +// Purpose : +//================================================================ +void SMESHGUI_MultiPreviewDlg::setSimulationPreview( QList& theMeshPreviewStruct ) +{ + hidePreview(); + qDeleteAll( mySimulationList ); + mySimulationList.clear(); + for ( int i = 0; i < theMeshPreviewStruct.count(); i++ ) { + mySimulationList << new SMESHGUI_MeshEditPreview( SMESH::GetViewWindow( mySMESHGUI ) ); + mySimulationList[i]->SetData( theMeshPreviewStruct[i].operator->() ); + } +} + +//================================================================================= +// function : onCloseView() +// purpose : SLOT called when close view +//================================================================================= +void SMESHGUI_MultiPreviewDlg::onCloseView() +{ + qDeleteAll( mySimulationList ); + mySimulationList.clear(); +}