1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_PreviewDlg.cxx
25 // Author : Roman NIKOLAEV, Open CASCADE S.A.S.
31 #include "SMESHGUI_PreviewDlg.h"
32 #include "SMESHGUI_MeshEditPreview.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_Utils.h"
37 #include <SUIT_Desktop.h>
43 //=================================================================================
44 // class : SMESHGUI_SMESHGUI_PreviewDlg()
46 //=================================================================================
47 SMESHGUI_PreviewDlg::SMESHGUI_PreviewDlg(SMESHGUI* theModule) :
48 QDialog(SMESH::GetDesktop( theModule )),
49 mySMESHGUI(theModule),
50 myIsApplyAndClose( false )
52 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
53 connect(mySMESHGUI, SIGNAL(SignalCloseView()), this, SLOT(onCloseView()));
54 connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), this, SLOT(onOpenView()));
57 //=================================================================================
58 // function : ~SMESHGUI_PreviewDlg()
59 // purpose : Destroys the object and frees any allocated resources
60 //=================================================================================
61 SMESHGUI_PreviewDlg::~SMESHGUI_PreviewDlg()
66 //=================================================================================
67 // function : showPreview
68 // purpose : Show preview in the viewer
69 //=================================================================================
70 void SMESHGUI_PreviewDlg::showPreview(){
71 if(mySimulation && mySimulation->GetActor())
72 mySimulation->SetVisibility(true);
75 //=================================================================================
76 // function : hidePreview
77 // purpose : Hide preview in the viewer
78 //=================================================================================
79 void SMESHGUI_PreviewDlg::hidePreview(){
80 if(mySimulation && mySimulation->GetActor())
81 mySimulation->SetVisibility(false);
84 //=================================================================================
85 // function : connectPreviewControl
86 // purpose : Connect the preview check box
87 //=================================================================================
88 void SMESHGUI_PreviewDlg::connectPreviewControl(){
89 connect(myPreviewCheckBox, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool)));
92 //=================================================================================
93 // function : toDisplaySimulation
95 //=================================================================================
96 void SMESHGUI_PreviewDlg::toDisplaySimulation() {
97 onDisplaySimulation(true);
100 //=================================================================================
101 // function : onDisplaySimulation
103 //=================================================================================
104 void SMESHGUI_PreviewDlg::onDisplaySimulation(bool /*toDisplayPreview*/) {
105 //Empty implementation here
108 //================================================================
109 // Function : setIsApplyAndClose
110 // Purpose : Set value of the flag indicating that the dialog is
111 // accepted by Apply & Close button
112 //================================================================
113 void SMESHGUI_PreviewDlg::setIsApplyAndClose( const bool theFlag )
115 myIsApplyAndClose = theFlag;
118 //================================================================
119 // Function : isApplyAndClose
120 // Purpose : Get value of the flag indicating that the dialog is
121 // accepted by Apply & Close button
122 //================================================================
123 bool SMESHGUI_PreviewDlg::isApplyAndClose() const
125 return myIsApplyAndClose;
128 //=================================================================================
129 // function : onCloseView()
130 // purpose : SLOT called when close view
131 //=================================================================================
132 void SMESHGUI_PreviewDlg::onCloseView()
134 if ( mySimulation && mySimulation->GetActor())
135 mySimulation->SetVisibility(false);
140 //=================================================================================
141 // function : onOpenView()
142 // purpose : SLOT called when open view
143 //=================================================================================
144 void SMESHGUI_PreviewDlg::onOpenView()
147 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
149 //=================================================================================
150 // class : SMESHGUI_SMESHGUI_MultiPreviewDlg()
152 //=================================================================================
153 SMESHGUI_MultiPreviewDlg::SMESHGUI_MultiPreviewDlg( SMESHGUI* theModule ) :
154 QDialog( SMESH::GetDesktop( theModule ) ),
155 mySMESHGUI( theModule ),
156 myIsApplyAndClose( false )
158 mySimulationList.clear();
159 connect(mySMESHGUI, SIGNAL(SignalCloseView()), this, SLOT(onCloseView()));
162 //=================================================================================
163 // function : ~SMESHGUI_MultiPreviewDlg()
164 // purpose : Destroys the object and frees any allocated resources
165 //=================================================================================
166 SMESHGUI_MultiPreviewDlg::~SMESHGUI_MultiPreviewDlg()
168 qDeleteAll( mySimulationList );
171 //=================================================================================
172 // function : showPreview
173 // purpose : Show preview in the viewer
174 //=================================================================================
175 void SMESHGUI_MultiPreviewDlg::showPreview()
177 for ( int i = 0; i < mySimulationList.count(); i++ )
178 if(mySimulationList[i] && mySimulationList[i]->GetActor())
179 mySimulationList[i]->SetVisibility( true );
182 //=================================================================================
183 // function : hidePreview
184 // purpose : Hide preview in the viewer
185 //=================================================================================
186 void SMESHGUI_MultiPreviewDlg::hidePreview()
188 for ( int i = 0; i < mySimulationList.count(); i++ )
189 if(mySimulationList[i] && mySimulationList[i]->GetActor())
190 mySimulationList[i]->SetVisibility( false );
193 //=================================================================================
194 // function : connectPreviewControl
195 // purpose : Connect the preview check box
196 //=================================================================================
197 void SMESHGUI_MultiPreviewDlg::connectPreviewControl()
199 connect( myPreviewCheckBox, SIGNAL( toggled( bool ) ), this, SLOT( onDisplaySimulation( bool ) ) );
202 //=================================================================================
203 // function : toDisplaySimulation
205 //=================================================================================
206 void SMESHGUI_MultiPreviewDlg::toDisplaySimulation()
208 onDisplaySimulation( true );
211 //=================================================================================
212 // function : onDisplaySimulation
214 //=================================================================================
215 void SMESHGUI_MultiPreviewDlg::onDisplaySimulation( bool /*toDisplayPreview*/ )
217 //Empty implementation here
220 //================================================================
221 // Function : setIsApplyAndClose
222 // Purpose : Set value of the flag indicating that the dialog is
223 // accepted by Apply & Close button
224 //================================================================
225 void SMESHGUI_MultiPreviewDlg::setIsApplyAndClose( const bool theFlag )
227 myIsApplyAndClose = theFlag;
230 //================================================================
231 // Function : isApplyAndClose
232 // Purpose : Get value of the flag indicating that the dialog is
233 // accepted by Apply & Close button
234 //================================================================
235 bool SMESHGUI_MultiPreviewDlg::isApplyAndClose() const
237 return myIsApplyAndClose;
240 //================================================================
241 // Function : setSimulationPreview
243 //================================================================
244 void SMESHGUI_MultiPreviewDlg::setSimulationPreview( QList<SMESH::MeshPreviewStruct_var>& theMeshPreviewStruct )
247 qDeleteAll( mySimulationList );
248 mySimulationList.clear();
249 for ( int i = 0; i < theMeshPreviewStruct.count(); i++ ) {
250 mySimulationList << new SMESHGUI_MeshEditPreview( SMESH::GetViewWindow( mySMESHGUI ) );
251 mySimulationList[i]->SetData( theMeshPreviewStruct[i].in() );
255 //=================================================================================
256 // function : onCloseView()
257 // purpose : SLOT called when close view
258 //=================================================================================
259 void SMESHGUI_MultiPreviewDlg::onCloseView()
261 qDeleteAll( mySimulationList );
262 mySimulationList.clear();