Salome HOME
Introduction de la doculmentation en anglais - phase 3
[modules/homard.git] / src / HOMARDGUI / MonIterInfo.cxx
1 // Copyright (C) 2011-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 using namespace std;
21
22 #include "MonIterInfo.h"
23
24 #include <QFile>
25 #include <QTextStream>
26 #include <QFileDialog>
27 #include <QMessageBox>
28
29 #include "SalomeApp_Tools.h"
30 #include "HOMARDGUI_Utils.h"
31 #include "HomardQtCommun.h"
32 #include "MonEditFile.h"
33 #include <utilities.h>
34
35
36 // -----------------------------------------------------------------------------------------
37 MonIterInfo::MonIterInfo(QWidget* parent, bool modal, HOMARD::HOMARD_Gen_var myHomardGen, QString IterName)
38 // -----------------------------------------------------------------------------------------
39 /* Constructs a MonIterInfo
40  * Inherits from CasHomard
41  * Sets attributes to default values
42  */
43     :
44     Ui_IterInfo(),
45     _IterName(IterName),
46     _aCaseName(""),
47     _BlockSize(0),
48     _Connection(0),
49     _Diametre(0),
50     _Entanglement(0),
51     _Quality(0),
52     _Option(-1)
53 {
54     MESSAGE("appel de _duplicate");
55       _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
56       setupUi(this);
57       setModal(modal);
58       InitConnect();
59
60       adjustSize();
61 }
62
63 // ------------------------------------------------------------------------
64 MonIterInfo::~MonIterInfo()
65 // ------------------------------------------------------------------------
66 {
67     // no need to delete child widgets, Qt does it all for us
68 }
69 // ------------------------------------------------------------------------
70 void MonIterInfo::InitConnect()
71 // ------------------------------------------------------------------------
72 {
73     MESSAGE("InitConnect");
74     connect( CBBlockSize,    SIGNAL(stateChanged(int)), this, SLOT(SetBlockSize()));
75     connect( CBConnection,   SIGNAL(stateChanged(int)), this, SLOT(SetConnection()));
76     connect( CBDiametre,     SIGNAL(stateChanged(int)), this, SLOT(SetDiametre()));
77     connect( CBEntanglement, SIGNAL(stateChanged(int)), this, SLOT(SetEntanglement()));
78     connect( CBQuality,      SIGNAL(stateChanged(int)), this, SLOT(SetQuality()));
79
80     connect( buttonOk,       SIGNAL(pressed()), this, SLOT(PushOnOK()));
81     connect( buttonApply,    SIGNAL(pressed()), this, SLOT(PushOnApply()));
82     connect( buttonCancel,   SIGNAL(pressed()), this, SLOT(close()));
83     connect( buttonHelp,     SIGNAL(pressed()), this, SLOT(PushOnHelp()));
84 }
85 // -------------------------------
86 bool MonIterInfo::PushOnApply()
87 // --------------------------------
88 {
89   MESSAGE("PushOnApply");
90
91   // Au moins une option a ete choisie
92   if ( ( _Quality == 0 ) and ( _Diametre == 0 ) and ( _Connection == 0 ) and ( _BlockSize == 0 ) and ( _Entanglement == 0 ) )
93   {
94     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
95                               QObject::tr("HOM_MESH_INFO_1") );
96     return false;
97   }
98
99   // Recuperation de l'iteration
100   aIter = _myHomardGen->GetIteration(_IterName.toStdString().c_str()) ;
101
102   // Lancement de l'analyse
103   try
104   {
105     aIter->MeshInfoOption( _Quality, _Diametre, _Connection, _BlockSize, _Entanglement, _Option );
106   }
107   catch( SALOME::SALOME_Exception& S_ex )
108   {
109     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
110                               QObject::tr(CORBA::string_dup(S_ex.details.text)) );
111     return false;
112   }
113
114   // Le bilan de l'analyse a afficher
115   QString aFileName = aIter->GetFileInfo() ;
116   MonEditFile *aDlg = new MonEditFile( 0, true, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen), aFileName ) ;
117   if ( aDlg->_codret == 0 ) { aDlg->show(); }
118
119
120   HOMARD_UTILS::updateObjBrowser();
121   return true;
122 }
123 // ---------------------------
124 void MonIterInfo::PushOnOK()
125 // ---------------------------
126 {
127      bool bOK = PushOnApply();
128      if ( bOK )  this->close();
129 }
130 //------------------------------
131 void MonIterInfo::PushOnHelp()
132 //-------------------------------
133 {
134   HOMARD_UTILS::PushOnHelp(QString("gui_mesh_info.html"), QString(""));
135 }
136 // ------------------------------------------------------------------------
137 void MonIterInfo::SetBlockSize()
138 // ------------------------------------------------------------------------
139 {
140   MESSAGE("Debut de SetBlockSize ");
141   if ( CBBlockSize->isChecked() ) { _BlockSize = 1 ; }
142   else                            { _BlockSize = 0 ; }
143 }
144 // ------------------------------------------------------------------------
145 void MonIterInfo::SetConnection()
146 // ------------------------------------------------------------------------
147 {
148   MESSAGE("Debut de SetConnection ");
149   if ( CBConnection->isChecked() ) { _Connection = 1 ; }
150   else                             { _Connection = 0 ; }
151 }
152 // ------------------------------------------------------------------------
153 void MonIterInfo::SetDiametre()
154 // ------------------------------------------------------------------------
155 {
156   MESSAGE("Debut de SetDiametre ");
157   if ( CBDiametre->isChecked() ) { _Diametre = 1 ; }
158   else                           { _Diametre = 0 ; }
159 }
160 // ------------------------------------------------------------------------
161 void MonIterInfo::SetEntanglement()
162 // ------------------------------------------------------------------------
163 {
164   MESSAGE("Debut de SetEntanglement ");
165   if ( CBEntanglement->isChecked() ) { _Entanglement = 1 ; }
166   else                               { _Entanglement = 0 ; }
167 }
168 // ------------------------------------------------------------------------
169 void MonIterInfo::SetQuality()
170 // ------------------------------------------------------------------------
171 {
172   MESSAGE("Debut de SetQuality ");
173   if ( CBQuality->isChecked() ) { _Quality = 1 ; }
174   else                          { _Quality = 0 ; }
175 }