From: ouv Date: Wed, 9 Dec 2009 12:30:43 +0000 (+0000) Subject: Refactoring X-Git-Tag: PHASE_17_Part1_V3~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f5bfce992fac067f68fcd8ce7a0b0d98031a2c49;p=modules%2Fsmesh.git Refactoring --- diff --git a/idl/SMESH_Hypothesis.idl b/idl/SMESH_Hypothesis.idl index 56ae48b0c..d7be98fca 100644 --- a/idl/SMESH_Hypothesis.idl +++ b/idl/SMESH_Hypothesis.idl @@ -28,6 +28,7 @@ #include "SALOME_Exception.idl" #include "SALOME_GenericObj.idl" +#include "SALOME_Notebook.idl" module SMESH { @@ -41,7 +42,7 @@ module SMESH typedef sequence ListOfParameters; - interface SMESH_Hypothesis : SALOME::GenericObj + interface SMESH_Hypothesis : SALOME::ParameterizedObject { /*! @@ -59,35 +60,6 @@ module SMESH */ long GetId(); - /*! - * Set list of parameters - * \param theParameters is a string containing the notebook variables separated by ":" symbol, - * used for Hypothesis creation - */ - void SetParameters (in string theParameters); - - /*! - * Return list of notebook variables used for Hypothesis creation separated by ":" symbol - */ - string GetParameters(); - - /*! - * Return list of last notebook variables used for Hypothesis creation. - */ - ListOfParameters GetLastParameters(); - - /*! - * Set list of parameters - * \param theParameters is a string containing the last notebook variables separated by ":" symbol, - * used for Hypothesis creation - */ - void SetLastParameters(in string theParameters); - - /*! - * Clear parameters list - */ - void ClearParameters(); - /*! * Verify whether hypothesis supports given entity type */ diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index 8a5c37daa..9f52f0cc2 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -28,6 +28,7 @@ #include "SALOME_Exception.idl" #include "SALOME_GenericObj.idl" +#include "SALOME_Notebook.idl" #include "GEOM_Gen.idl" #include "MED.idl" @@ -263,7 +264,7 @@ module SMESH interface SMESH_GroupOnGeom; interface SMESH_subMesh; interface SMESH_MeshEditor; - interface SMESH_Mesh : SALOME::GenericObj, SMESH_IDSource + interface SMESH_Mesh : SALOME::ParameterizedObject, SMESH_IDSource { /*! * Return true if there is a geometry to be meshed @@ -760,22 +761,6 @@ module SMESH /*! Gets information about imported MED file */ SALOME_MED::MedFileInfo GetMEDFileInfo(); - - /*! - * Sets list of notebook variables used for Mesh operations separated by ":" symbol - * \param theParameters is a string containing the notebook variables - */ - void SetParameters (in string theParameters); - - /*! - * Returns list of notebook variables used for Mesh operations separated by ":" symbol - */ - string GetParameters(); - - /*! - * Returns list of notebook variables used for last Mesh operation - */ - string_array GetLastParameters(); }; interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource diff --git a/src/SMESH/SMESH_Hypothesis.cxx b/src/SMESH/SMESH_Hypothesis.cxx index c731f60cf..691dff2f8 100644 --- a/src/SMESH/SMESH_Hypothesis.cxx +++ b/src/SMESH/SMESH_Hypothesis.cxx @@ -49,7 +49,6 @@ SMESH_Hypothesis::SMESH_Hypothesis(int hypId, _type = PARAM_ALGO; _shapeType = 0; // to be set by algo with TopAbs_Enum _param_algo_dim = -1; // to be set by algo parameter - _parameters = string(); } //============================================================================= @@ -155,15 +154,9 @@ void SMESH_Hypothesis::SetLibName(const char* theLibName) * */ //============================================================================= -void SMESH_Hypothesis::SetParameters(const char *theParameters) +void SMESH_Hypothesis::SetParameters(const std::list& theParameters) { - string aNewParameters(theParameters); - if(aNewParameters.size()==0 && _parameters.size()==0) - aNewParameters = " "; - if(_parameters.size()>0) - _parameters +="|"; - _parameters +=aNewParameters; - SetLastParameters(theParameters); + _parameters = theParameters; } //============================================================================= @@ -171,37 +164,7 @@ void SMESH_Hypothesis::SetParameters(const char *theParameters) * */ //============================================================================= -void SMESH_Hypothesis::ClearParameters() +std::list SMESH_Hypothesis::GetParameters() const { - _parameters = string(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -char* SMESH_Hypothesis::GetParameters() const -{ - return (char*)_parameters.c_str(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -char* SMESH_Hypothesis::GetLastParameters() const -{ - return (char*)_lastParameters.c_str(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESH_Hypothesis::SetLastParameters(const char* theParameters) -{ - _lastParameters = string(theParameters); + return _parameters; } diff --git a/src/SMESH/SMESH_Hypothesis.hxx b/src/SMESH/SMESH_Hypothesis.hxx index 55ed9dd5f..26e1a080e 100644 --- a/src/SMESH/SMESH_Hypothesis.hxx +++ b/src/SMESH/SMESH_Hypothesis.hxx @@ -32,6 +32,8 @@ #include "SMESHDS_Hypothesis.hxx" +#include + class SMESH_Gen; class TopoDS_Shape; class SMESH_Mesh; @@ -77,13 +79,9 @@ public: virtual const char* GetLibName() const; void SetLibName(const char* theLibName); - void SetParameters(const char *theParameters); - char* GetParameters() const; + void SetParameters(const std::list& theParameters); + std::list GetParameters() const; - void SetLastParameters(const char* theParameters); - char* GetLastParameters() const; - void ClearParameters(); - /*! * \brief Initialize my parameter values by the mesh built on the geometry * \param theMesh - the built mesh @@ -122,8 +120,7 @@ protected: private: std::string _libName; - std::string _parameters; - std::string _lastParameters; + std::list _parameters; }; #endif diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index 13bca294a..ed872eee3 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -505,11 +505,6 @@ public: */ SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo); - void UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters); - char* GetParameters(CORBA::Object_ptr theObject); - char* ParseParameters(const char* theParameters); - - private: // Create hypothesis of given type SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName, diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index 7fed0cced..cb761b89b 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -885,128 +885,3 @@ bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy } return true; } - -//======================================================================= -//function : UpdateParameters -//purpose : -//======================================================================= -void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters) -{ - - if(VARIABLE_DEBUG) - cout<<"UpdateParameters : "<_is_nil() || CORBA::is_nil(theObject)) - return; - - SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject); - if(aSObj->_is_nil()) - return; - - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - - SALOMEDS::GenericAttribute_var aFindAttr; - bool hasAttr = aSObj->FindAttribute(aFindAttr, "AttributeString"); - if(VARIABLE_DEBUG) - cout<<"Find Attribute "<FindOrCreateAttribute( aSObj, "AttributeString"); - SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr); - - CORBA::String_var oldparVar = aStringAttr->Value(); - CORBA::String_var inpparVar = ParseParameters(theParameters); - TCollection_AsciiString aNewParams; - TCollection_AsciiString aOldParameters(oldparVar.inout()); - TCollection_AsciiString anInputParams(inpparVar.inout()); - if(!hasAttr) - aNewParams = anInputParams; - else - aNewParams = aOldParameters+"|"+anInputParams; - - if(VARIABLE_DEBUG) - { - cout<<"Input Parameters : "<SetValue( aNewParams.ToCString() ); -} - -//======================================================================= -//function : ParseParameters -//purpose : -//======================================================================= -char* SMESH_Gen_i::ParseParameters(const char* theParameters) -{ - /* ouv: temporarily disabled - //const char* aParameters = theParameters; -// const char* aParameters = CORBA::string_dup(theParameters); - TCollection_AsciiString anInputParams; - SALOMEDS::Study_var aStudy = GetCurrentStudy(); - if( !aStudy->_is_nil() ) { -// SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(theParameters); -// for(int j=0;jlength();j++) { -// SALOMEDS::ListOfStrings aVars= aSections[j]; -// for(int i=0;iIsVariable(aVars[i].in()) ? -// TCollection_AsciiString(aVars[i].in()) : TCollection_AsciiString(""); -// if(i != aVars.length()-1) -// anInputParams+=":"; -// } -// if(j!=aSections->length()-1) -// anInputParams+="|"; -// } - TCollection_AsciiString paramStr( theParameters ); - static TCollection_AsciiString separators(":|"); - int beg = 0, end; - char sep, *pParams = (char*)paramStr.ToCString(); - while ( beg < paramStr.Length() ) - { - end = beg-1; - while ( ++end < paramStr.Length() ) - if ( pParams[end] == ':' || pParams[end] == '|') - break; - if ( end < paramStr.Length()) - { - sep = pParams[end]; - pParams[end] = '\0'; - } - if ( aStudy->IsVariable( pParams+beg )) - anInputParams += pParams+beg; - if ( end < paramStr.Length() ) - anInputParams += sep; - else - break; - beg = end + 1; - } - } - return CORBA::string_dup(anInputParams.ToCString()); - */ - return NULL; -} - -//======================================================================= -//function : GetParameters -//purpose : -//======================================================================= -char* SMESH_Gen_i::GetParameters(CORBA::Object_ptr theObject) -{ - TCollection_AsciiString aResult; - - SALOMEDS::Study_ptr aStudy = GetCurrentStudy(); - SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject); - - if(!aStudy->_is_nil() && - !CORBA::is_nil(theObject) && - !aSObj->_is_nil()){ - - SALOMEDS::GenericAttribute_var anAttr; - if ( aSObj->FindAttribute(anAttr, "AttributeString")) { - aResult = TCollection_AsciiString(SALOMEDS::AttributeString::_narrow(anAttr)->Value()); - } - } - - return CORBA::string_dup( aResult.ToCString() ); -} diff --git a/src/SMESH_I/SMESH_Hypothesis_i.cxx b/src/SMESH_I/SMESH_Hypothesis_i.cxx index cacae2503..5202b4abf 100644 --- a/src/SMESH_I/SMESH_Hypothesis_i.cxx +++ b/src/SMESH_I/SMESH_Hypothesis_i.cxx @@ -144,8 +144,10 @@ bool SMESH_Hypothesis_i::IsPublished(){ * */ //============================================================================= -void SMESH_Hypothesis_i::SetParameters(const char* theParameters) +//void SMESH_Hypothesis_i::SetParameters(const char* theParameters) +void SMESH_Hypothesis_i::SetParameters( SALOME::Notebook_ptr theNotebook, const SALOME::StringArray& theParameters ) { + /* SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); char * aParameters = CORBA::string_dup(theParameters); if(gen){ @@ -156,6 +158,7 @@ void SMESH_Hypothesis_i::SetParameters(const char* theParameters) myBaseImpl->SetParameters(gen->ParseParameters(aParameters)); } } + */ } //============================================================================= @@ -164,8 +167,10 @@ void SMESH_Hypothesis_i::SetParameters(const char* theParameters) * */ //============================================================================= -char* SMESH_Hypothesis_i::GetParameters() +//char* SMESH_Hypothesis_i::GetParameters() +SALOME::StringArray* SMESH_Hypothesis_i::GetParameters() { + /* SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); char* aResult; if(IsPublished()) { @@ -177,64 +182,8 @@ char* SMESH_Hypothesis_i::GetParameters() aResult = myBaseImpl->GetParameters(); } return CORBA::string_dup(aResult); -} - -//============================================================================= -/*! - * SMESH_Hypothesis_i::GetLastParameters() - * - */ -//============================================================================= -SMESH::ListOfParameters* SMESH_Hypothesis_i::GetLastParameters() -{ - SMESH::ListOfParameters_var aResult = new SMESH::ListOfParameters(); - /* ouv: temporarily disabled - SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); - if(gen) { - char *aParameters; - if(IsPublished()) - aParameters = GetParameters(); - else - aParameters = myBaseImpl->GetLastParameters(); - - SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy(); - if(!aStudy->_is_nil()) { - SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters); - if(aSections->length() > 0) { - SALOMEDS::ListOfStrings aVars = aSections[aSections->length()-1]; - aResult->length(aVars.length()); - for(int i = 0;i < aVars.length();i++) - aResult[i] = CORBA::string_dup( aVars[i]); - } - } - } */ - return aResult._retn(); -} - -//============================================================================= -/*! - * SMESH_Hypothesis_i::SetLastParameters() - * - */ -//============================================================================= -void SMESH_Hypothesis_i::SetLastParameters(const char* theParameters) -{ - if(!IsPublished()) { - myBaseImpl->SetLastParameters(theParameters); - } -} -//============================================================================= -/*! - * SMESH_Hypothesis_i::ClearParameters() - * - */ -//============================================================================= -void SMESH_Hypothesis_i::ClearParameters() -{ - if(!IsPublished()) { - myBaseImpl->ClearParameters(); - } + return NULL; } //============================================================================= diff --git a/src/SMESH_I/SMESH_Hypothesis_i.hxx b/src/SMESH_I/SMESH_Hypothesis_i.hxx index 13bd7742f..7f738567e 100644 --- a/src/SMESH_I/SMESH_Hypothesis_i.hxx +++ b/src/SMESH_I/SMESH_Hypothesis_i.hxx @@ -65,21 +65,11 @@ public: // Get unique id of hypothesis CORBA::Long GetId(); - // Set list of parameters separated by ":" symbol, used for Hypothesis creation - void SetParameters (const char* theParameters); + // Set list of parameters, used for Hypothesis creation + virtual void SetParameters( SALOME::Notebook_ptr theNotebook, const SALOME::StringArray& theParameters ); - // Return list of notebook variables used for Hypothesis creation separated by ":" symbol - char* GetParameters(); - - //Return list of last notebook variables used for Hypothesis creation. - SMESH::ListOfParameters* GetLastParameters(); - - //Set last parameters for not published hypothesis - - void SetLastParameters(const char* theParameters); - - // Clear parameters list - void ClearParameters(); + // Return list of notebook variables used for Hypothesis creation + virtual SALOME::StringArray* GetParameters(); //Return true if hypothesis was published in study bool IsPublished(); diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 4236db269..09ef926b5 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -3383,10 +3383,8 @@ void SMESH_Mesh_i::checkGroupNames() * \brief Sets list of notebook variables used for Mesh operations separated by ":" symbol */ //============================================================================= -void SMESH_Mesh_i::SetParameters(const char* theParameters) +void SMESH_Mesh_i::SetParameters( SALOME::Notebook_ptr theNotebook, const SALOME::StringArray& theParameters ) { - SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Mesh::_narrow(_this()), - CORBA::string_dup(theParameters)); } //============================================================================= @@ -3394,37 +3392,9 @@ void SMESH_Mesh_i::SetParameters(const char* theParameters) * \brief Returns list of notebook variables used for Mesh operations separated by ":" symbol */ //============================================================================= -char* SMESH_Mesh_i::GetParameters() +SALOME::StringArray* SMESH_Mesh_i::GetParameters() { - SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); - return CORBA::string_dup(gen->GetParameters(SMESH::SMESH_Mesh::_narrow(_this()))); -} - -//============================================================================= -/*! - * \brief Returns list of notebook variables used for last Mesh operation - */ -//============================================================================= -SMESH::string_array* SMESH_Mesh_i::GetLastParameters() -{ - SMESH::string_array_var aResult = new SMESH::string_array(); - /* ouv: temporarily disabled - SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); - if(gen) { - char *aParameters = GetParameters(); - SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy(); - if(!aStudy->_is_nil()) { - SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters); - if(aSections->length() > 0) { - SALOMEDS::ListOfStrings aVars = aSections[aSections->length()-1]; - aResult->length(aVars.length()); - for(int i = 0;i < aVars.length();i++) - aResult[i] = CORBA::string_dup( aVars[i]); - } - } - } - */ - return aResult._retn(); + return NULL; } //============================================================================= diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index e8598de34..fb6df768d 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -472,20 +472,14 @@ public: virtual SALOME_MED::MedFileInfo* GetMEDFileInfo(); /*! - * Sets list of notebook variables used for Mesh operations separated by ":" symbol + * Sets list of notebook variables used for Mesh operations */ - void SetParameters (const char* theParameters); + virtual void SetParameters( SALOME::Notebook_ptr theNotebook, const SALOME::StringArray& theParameters ); /*! - * Returns list of notebook variables used for Mesh operations separated by ":" symbol + * Returns list of notebook variables used for Mesh operations */ - char* GetParameters(); - - /*! - * Returns list of notebook variables used for last Mesh operation - */ - SMESH::string_array* GetLastParameters(); - + virtual SALOME::StringArray* GetParameters(); /*! * Returns statistic of mesh elements