1 // Copyright (C) 2011-2012 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "MonEditBoundaryAn.h"
24 #include "SalomeApp_Tools.h"
25 #include "HOMARDGUI_Utils.h"
26 #include <utilities.h>
29 // ------------------------------------------------------------------------
30 MonEditBoundaryAn::MonEditBoundaryAn( MonCreateCase* parent, bool modal,
31 HOMARD::HOMARD_Gen_var myHomardGen,
32 QString caseName, QString boundaryName ):
33 // ------------------------------------------------------------------------
34 /* Constructs a MonEditBoundaryAn
35 herite de MonCreateBoundaryAn
37 MonCreateBoundaryAn(parent, myHomardGen, caseName)
39 MESSAGE("Debut de MonEditBoundaryAn pour " << boundaryName.toStdString().c_str());
40 setWindowTitle(QObject::tr("HOM_BOUN_A_EDIT_WINDOW_TITLE"));
42 aBoundaryAn = _myHomardGen->GetBoundary(_aName.toStdString().c_str());
45 // ------------------------------------------------------------------------
46 MonEditBoundaryAn::~MonEditBoundaryAn()
47 // ------------------------------------------------------------------------
49 // no need to delete child widgets, Qt does it all for us
51 // ------------------------------------------------------------------------
52 void MonEditBoundaryAn::InitValEdit()
53 // ------------------------------------------------------------------------
55 LEBoundaryName->setText(_aName);
56 LEBoundaryName->setReadOnly(true);
57 _Type = aBoundaryAn->GetType();
58 MESSAGE("_Type : "<<_Type);
59 InitValBoundaryAnLimit();
60 if (_aCaseName != QString("")) InitValBoundaryAn();
63 case 1 : // il s agit d un cylindre
65 InitValBoundaryAnCylindre();
69 case 2: // il s agit d une sphere
71 InitValBoundaryAnSphere();
77 // ------------------------------------------------------------------------
78 void MonEditBoundaryAn::InitValBoundaryAnLimit()
79 // ------------------------------------------------------------------------
81 HOMARD::double_array_var mesCoordLimits = aBoundaryAn->GetLimit();
82 ASSERT(mesCoordLimits->length() == 3 );
83 _Xincr=mesCoordLimits[0];
84 _Yincr=mesCoordLimits[1];
85 _Zincr=mesCoordLimits[2];
87 // ------------------------------------------------------------------------
88 void MonEditBoundaryAn::InitValBoundaryAnCylindre()
89 // ------------------------------------------------------------------------
91 HOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
92 ASSERT(mesCoordBoundary->length() == 7 );
93 _BoundaryAnXcentre=mesCoordBoundary[0];
94 _BoundaryAnYcentre=mesCoordBoundary[1];
95 _BoundaryAnZcentre=mesCoordBoundary[2];
96 _BoundaryAnXaxis=mesCoordBoundary[3];
97 _BoundaryAnYaxis=mesCoordBoundary[4];
98 _BoundaryAnZaxis=mesCoordBoundary[5];
99 _BoundaryAnRayon=mesCoordBoundary[6];
101 // ------------------------------------------------------------------------
102 void MonEditBoundaryAn::InitValBoundaryAnSphere()
103 // ------------------------------------------------------------------------
105 HOMARD::double_array_var mesCoordBoundary = aBoundaryAn->GetCoords();
106 ASSERT(mesCoordBoundary->length() == 4 );
107 _BoundaryAnXcentre=mesCoordBoundary[0];
108 _BoundaryAnYcentre=mesCoordBoundary[1];
109 _BoundaryAnZcentre=mesCoordBoundary[2];
110 _BoundaryAnRayon=mesCoordBoundary[3];
112 // ------------------------------------------------------------------------
113 void MonEditBoundaryAn::SetCylinder()
114 // ------------------------------------------------------------------------
116 gBCylindre->setVisible(1);
117 gBSphere->setVisible(0);
118 RBCylindre->setChecked(1);
121 RBSphere->setDisabled(true);
124 SpinBox_Xcent->setValue(_BoundaryAnXcentre);
125 SpinBox_Ycent->setValue(_BoundaryAnYcentre);
126 SpinBox_Zcent->setValue(_BoundaryAnZcentre);
128 SpinBox_Xaxis->setValue(_BoundaryAnXaxis);
129 SpinBox_Yaxis->setValue(_BoundaryAnYaxis);
130 SpinBox_Zaxis->setValue(_BoundaryAnZaxis);
133 SpinBox_Xaxis->setSingleStep(0.1);
134 SpinBox_Xcentre->setSingleStep(_Xincr);
135 SpinBox_Yaxis->setSingleStep(0.1);
136 SpinBox_Ycentre->setSingleStep(_Yincr);
137 SpinBox_Zaxis->setSingleStep(0.1);
138 SpinBox_Zcentre->setSingleStep(_Zincr);
140 SpinBox_Radius->setValue(_BoundaryAnRayon);
141 SpinBox_Radius->setSingleStep(_BoundaryAnRayon/10.);
144 // ------------------------------------------------------------------------
145 void MonEditBoundaryAn::SetSphere()
146 // ------------------------------------------------------------------------
148 gBCylindre->setVisible(0);
149 gBSphere->setVisible(1);
150 RBSphere->setChecked(1);
151 RBCylindre->setDisabled(true);
155 SpinBox_Xcentre->setValue(_BoundaryAnXcentre);
156 if ( _Xincr > 0) { SpinBox_Xcentre->setSingleStep(_Xincr); }
157 else { SpinBox_Xcentre->setSingleStep(1) ; }
159 SpinBox_Ycentre->setValue(_BoundaryAnYcentre);
160 if ( _Yincr > 0) { SpinBox_Ycentre->setSingleStep(_Yincr); }
161 else { SpinBox_Ycentre->setSingleStep(1) ; }
163 SpinBox_Zcentre->setValue(_BoundaryAnZcentre);
164 if ( _Zincr > 0) { SpinBox_Zcentre->setSingleStep(_Zincr); }
165 else { SpinBox_Zcentre->setSingleStep(1);}
167 SpinBox_Rayon->setMinimum(0.);
168 SpinBox_Rayon->setValue(_BoundaryAnRayon);
170 // ---------------------------------------------------
171 bool MonEditBoundaryAn::CreateOrUpdateBoundaryAn()
172 //----------------------------------------------------
173 // Mise a jour des attributs de la BoundaryAn
177 case 1 : // il s agit d un cylindre
179 aBoundaryAn->SetCylinder(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
182 case 2 : // il s agit d une sphere
184 aBoundaryAn->SetSphere(_BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
188 if (Chgt) _myHomardGen->InvalideBoundary(_aName.toStdString().c_str());
189 HOMARD_UTILS::updateObjBrowser();