1 // Copyright (C) 2007-2010 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.
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 SMESH_I : idl implementation based on 'SMESH' unit's calsses
24 // File : SMESH_Hypothesis_i.cxx
25 // Author : Paul RASCLE, EDF
31 #include "SMESH_Hypothesis_i.hxx"
32 #include "SMESH_Gen_i.hxx"
33 #include "utilities.h"
37 //=============================================================================
39 * SMESH_Hypothesis_i::SMESH_Hypothesis_i
43 //=============================================================================
45 SMESH_Hypothesis_i::SMESH_Hypothesis_i( PortableServer::POA_ptr thePOA )
46 : SALOME::GenericObj_i( thePOA )
48 MESSAGE( "SMESH_Hypothesis_i::SMESH_Hypothesis_i / Début" );
51 MESSAGE( "SMESH_Hypothesis_i::SMESH_Hypothesis_i / Fin" );
54 //=============================================================================
56 * SMESH_Hypothesis_i::~SMESH_Hypothesis_i
60 //=============================================================================
62 SMESH_Hypothesis_i::~SMESH_Hypothesis_i()
64 MESSAGE( "SMESH_Hypothesis_i::~SMESH_Hypothesis_i" );
69 //=============================================================================
71 * SMESH_Hypothesis_i::GetName
73 * Get type name of hypothesis
75 //=============================================================================
77 char* SMESH_Hypothesis_i::GetName()
79 //MESSAGE( "SMESH_Hypothesis_i::GetName" );
80 return CORBA::string_dup( myBaseImpl->GetName() );
83 //=============================================================================
85 * SMESH_Hypothesis_i::GetLibName
87 * Get plugin library name of hypothesis (required by persistency mechanism)
89 //=============================================================================
91 char* SMESH_Hypothesis_i::GetLibName()
93 MESSAGE( "SMESH_Hypothesis_i::GetLibName" );
94 return CORBA::string_dup( myBaseImpl->GetLibName() );
97 //=============================================================================
99 * SMESH_Hypothesis_i::SetLibName
101 * Set plugin library name of hypothesis (required by persistency mechanism)
103 //=============================================================================
105 void SMESH_Hypothesis_i::SetLibName(const char* theLibName)
107 MESSAGE( "SMESH_Hypothesis_i::SetLibName" );
108 myBaseImpl->SetLibName( theLibName );
111 //=============================================================================
113 * SMESH_Hypothesis_i::GetId
115 * Get unique id of hypothesis
117 //=============================================================================
119 CORBA::Long SMESH_Hypothesis_i::GetId()
121 MESSAGE( "SMESH_Hypothesis_i::GetId" );
122 return myBaseImpl->GetID();
125 //=============================================================================
127 * SMESH_Hypothesis_i::IsPublished()
130 //=============================================================================
131 bool SMESH_Hypothesis_i::IsPublished(){
133 SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
135 SALOMEDS::SObject_var SO =
136 SMESH_Gen_i::ObjectToSObject(gen->GetCurrentStudy() , SMESH::SMESH_Hypothesis::_narrow(_this()));
137 res = !SO->_is_nil();
142 //=============================================================================
144 * SMESH_Hypothesis_i::SetParameters()
147 //=============================================================================
148 void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
150 SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
151 char * aParameters = CORBA::string_dup(theParameters);
154 SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Hypothesis::_narrow(_this()),aParameters);
157 myBaseImpl->SetParameters(gen->ParseParameters(aParameters));
162 //=============================================================================
164 * SMESH_Hypothesis_i::GetParameters()
167 //=============================================================================
168 char* SMESH_Hypothesis_i::GetParameters()
170 SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
173 MESSAGE("SMESH_Hypothesis_i::GetParameters() : Get Parameters from SObject");
174 aResult = gen->GetParameters(SMESH::SMESH_Hypothesis::_narrow(_this()));
177 MESSAGE("SMESH_Hypothesis_i::GetParameters() : Get local parameters");
178 aResult = myBaseImpl->GetParameters();
180 return CORBA::string_dup(aResult);
183 //=============================================================================
185 * SMESH_Hypothesis_i::GetLastParameters()
188 //=============================================================================
189 SMESH::ListOfParameters* SMESH_Hypothesis_i::GetLastParameters()
191 SMESH::ListOfParameters_var aResult = new SMESH::ListOfParameters();
192 SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
196 aParameters = GetParameters();
198 aParameters = myBaseImpl->GetLastParameters();
200 SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy();
201 if(!aStudy->_is_nil()) {
202 SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
203 if(aSections->length() > 0) {
204 SALOMEDS::ListOfStrings aVars = aSections[aSections->length()-1];
205 aResult->length(aVars.length());
206 for(int i = 0;i < aVars.length();i++)
207 aResult[i] = CORBA::string_dup( aVars[i]);
211 return aResult._retn();
214 //=============================================================================
216 * SMESH_Hypothesis_i::SetLastParameters()
219 //=============================================================================
220 void SMESH_Hypothesis_i::SetLastParameters(const char* theParameters)
223 myBaseImpl->SetLastParameters(theParameters);
226 //=============================================================================
228 * SMESH_Hypothesis_i::ClearParameters()
231 //=============================================================================
232 void SMESH_Hypothesis_i::ClearParameters()
235 myBaseImpl->ClearParameters();
239 //=============================================================================
241 * SMESH_Hypothesis_i::GetImpl
245 //=============================================================================
247 ::SMESH_Hypothesis* SMESH_Hypothesis_i::GetImpl()
249 //MESSAGE( "SMESH_Hypothesis_i::GetImpl" );
253 //=============================================================================
255 * SMESH_Hypothesis_i::SaveTo
257 * Persistence: Dumps parameters to the string stream
259 //=============================================================================
261 char* SMESH_Hypothesis_i::SaveTo()
263 MESSAGE( "SMESH_Hypothesis_i::SaveTo" );
264 std::ostringstream os;
265 myBaseImpl->SaveTo( os );
266 return CORBA::string_dup( os.str().c_str() );
269 //=============================================================================
271 * SMESH_Hypothesis_i::LoadFrom
273 * Persistence: Restores parameters from string
275 //=============================================================================
277 void SMESH_Hypothesis_i::LoadFrom( const char* theStream )
279 MESSAGE( "SMESH_Hypothesis_i::LoadFrom" );
280 std::istringstream is( theStream );
281 myBaseImpl->LoadFrom( is );