Salome HOME
abbe1d00da7a9bee58a487a714afc1ebe1f87fc2
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_PreviewDlg.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI_PreviewDlg.cxx
25 // Author : Roman NIKOLAEV, Open CASCADE S.A.S.
26 // SMESH includes
27 //
28
29 //SMESH includes
30 #include "SMESHGUI.h"
31 #include "SMESHGUI_PreviewDlg.h"
32 #include "SMESHGUI_MeshEditPreview.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_Utils.h"
35
36 //GUI includes
37 #include <SUIT_Desktop.h>
38
39 //QT includes
40 #include <QCheckBox>
41
42
43 //=================================================================================
44 // class    : SMESHGUI_SMESHGUI_PreviewDlg()
45 // purpose  :
46 //=================================================================================
47 SMESHGUI_PreviewDlg::SMESHGUI_PreviewDlg(SMESHGUI* theModule) :
48   mySMESHGUI(theModule),
49   QDialog(SMESH::GetDesktop( theModule )),
50   myIsApplyAndClose( false )
51 {
52   mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
53 }
54
55 //=================================================================================
56 // function : ~SMESHGUI_PreviewDlg()
57 // purpose  : Destroys the object and frees any allocated resources
58 //=================================================================================
59 SMESHGUI_PreviewDlg::~SMESHGUI_PreviewDlg()
60 {
61   delete mySimulation;
62 }
63
64 //=================================================================================
65 // function : showPreview
66 // purpose  : Show preview in the viewer
67 //=================================================================================
68 void SMESHGUI_PreviewDlg::showPreview(){
69   if(mySimulation)
70     mySimulation->SetVisibility(true);
71 }
72
73 //=================================================================================
74 // function : hidePreview
75 // purpose  : Hide preview in the viewer
76 //=================================================================================
77 void SMESHGUI_PreviewDlg::hidePreview(){
78   if(mySimulation)
79     mySimulation->SetVisibility(false);
80 }
81
82 //=================================================================================
83 // function : connectPreviewControl
84 // purpose  : Connect the preview check box
85 //=================================================================================
86 void SMESHGUI_PreviewDlg::connectPreviewControl(){
87   connect(myPreviewCheckBox, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool)));
88 }
89
90
91 //=================================================================================
92 // function : toDisplaySimulation
93 // purpose  : 
94 //=================================================================================
95 void SMESHGUI_PreviewDlg::toDisplaySimulation() {
96   onDisplaySimulation(true);
97 }
98
99 //=================================================================================
100 // function : onDisplaySimulation
101 // purpose  : 
102 //=================================================================================
103 void SMESHGUI_PreviewDlg::onDisplaySimulation(bool toDisplayPreview) {
104   //Empty implementation here
105 }
106
107 //================================================================
108 // Function : setIsApplyAndClose
109 // Purpose  : Set value of the flag indicating that the dialog is
110 //            accepted by Apply & Close button
111 //================================================================
112 void SMESHGUI_PreviewDlg::setIsApplyAndClose( const bool theFlag )
113 {
114   myIsApplyAndClose = theFlag;
115 }
116
117 //================================================================
118 // Function : isApplyAndClose
119 // Purpose  : Get value of the flag indicating that the dialog is
120 //            accepted by Apply & Close button
121 //================================================================
122 bool SMESHGUI_PreviewDlg::isApplyAndClose() const
123 {
124   return myIsApplyAndClose;
125 }