Salome HOME
Refactoring
authorouv <ouv@opencascade.com>
Wed, 9 Dec 2009 12:30:43 +0000 (12:30 +0000)
committerouv <ouv@opencascade.com>
Wed, 9 Dec 2009 12:30:43 +0000 (12:30 +0000)
idl/SMESH_Hypothesis.idl
idl/SMESH_Mesh.idl
src/SMESH/SMESH_Hypothesis.cxx
src/SMESH/SMESH_Hypothesis.hxx
src/SMESH_I/SMESH_Gen_i.hxx
src/SMESH_I/SMESH_Gen_i_1.cxx
src/SMESH_I/SMESH_Hypothesis_i.cxx
src/SMESH_I/SMESH_Hypothesis_i.hxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx

index 56ae48b0cfed28db8767c589560f11ab2949c2ba..d7be98fca8ad487e83b5575654a322f0b7028b8c 100644 (file)
@@ -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<string> 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 
      */
index 8a5c37daa91e4dd4348f67488e87d4b30da0e87c..9f52f0cc226b51c36e44b6327468abeb9cdf5d85 100644 (file)
@@ -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
index c731f60cf391bd187a30118645a3edfd447bdea4..691dff2f8cba1da57b5767d92613f3403d977d1a 100644 (file)
@@ -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<std::string>& 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<std::string> 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;
 }
index 55ed9dd5fb2f84970161c6d1c523350965caa0db..26e1a080edda497d2a9c85546457854ab1bf764d 100644 (file)
@@ -32,6 +32,8 @@
 
 #include "SMESHDS_Hypothesis.hxx"
 
+#include <list>
+
 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<std::string>& theParameters);
+  std::list<std::string> 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<std::string> _parameters;
 };
 
 #endif
index 13bca294ab715d73c53b84258e6d3a3733d1c9c6..ed872eee3304b8a3db83319b2327002f3c71b021 100644 (file)
@@ -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,
index 7fed0cced7f8c0f2f019f9371ded93bf34a4ffe6..cb761b89befb174d1f1ec3f233a8006a522deee7 100644 (file)
@@ -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 : "<<theParameters<<endl;
-  SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
-  if(aStudy->_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 "<<hasAttr<<endl;
-
-  SALOMEDS::GenericAttribute_var anAttr;
-  anAttr = aStudyBuilder->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 : "<<anInputParams<<endl;
-    cout<<"Old Parameters : "<<aOldParameters<<endl;
-    cout<<"New Parameters : "<<aNewParams<<endl;
-  }
-
-  aStringAttr->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;j<aSections->length();j++) {
-//       SALOMEDS::ListOfStrings aVars= aSections[j];
-//       for(int i=0;i<aVars.length();i++ ) {
-//         anInputParams += aStudy->IsVariable(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() );
-}
index cacae2503e0b2bb8f947f8f38241fe3fb4eca2ff..5202b4abfc648e2d8bd7165ce3b3c1ef56ae3155 100644 (file)
@@ -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;
 }
 
 //=============================================================================
index 13bd7742fd3b07ecdc9faf4447c8a89bc9053762..7f738567e3723a04c9f1379a8f7713b0be476009 100644 (file)
@@ -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();
index 4236db2696a4f47e2b8e5740fe741f9981af65e8..09ef926b5279367e370df869fb1a0a516e3deb82 100644 (file)
@@ -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;
 }
 
 //=============================================================================
index e8598de3479d7af7f5d348a14cae49db0ca7e3fe..fb6df768d1bca174b662cd6559bd948bfe497b40 100644 (file)
@@ -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