Salome HOME
Implementation notebook in the SMESH module.
authorrnv <rnv@opencascade.com>
Tue, 25 Nov 2008 13:58:31 +0000 (13:58 +0000)
committerrnv <rnv@opencascade.com>
Tue, 25 Nov 2008 13:58:31 +0000 (13:58 +0000)
13 files changed:
idl/SMESH_Hypothesis.idl
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI.h
src/SMESHGUI/SMESHGUI_Hypotheses.cxx
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_NoteBook.cxx
src/SMESH_I/SMESH_NoteBook.hxx
src/SMESH_SWIG/smeshDC.py
src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx
src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h

index 45f3c4d5d52ddefde65d6173feadfc0dae3512df..cf226ef9fcd4608564af2c5cda4ae3b2a422cd23 100644 (file)
@@ -39,8 +39,11 @@ module SMESH
     DIM_3D
   };
   
+  typedef sequence<string> ListOfParameters;
+
   interface SMESH_Hypothesis : SALOME::GenericObj
   {
+    
     /*!
      * Get the Hypothesis typeName 
      */
@@ -67,7 +70,12 @@ module SMESH
      *  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();
+
     /*!
      * Verify whether hypothesis supports given entity type 
      */
index b191f63aecc80406d7f31edeb8f4558bdb1258b4..c9e3b9aba73ab1100cdc82fa3aa0323732b7eea0 100644 (file)
@@ -1239,6 +1239,16 @@ SalomeApp_Study* SMESHGUI::activeStudy()
     return NULL;
 }
 
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+char* SMESHGUI::JoinObjectParameters(const QStringList& theParametersList)
+{
+  return theParametersList.join(":").toLatin1().data();
+}
+
 //=============================================================================
 /*!
  *
index 59d134e9e0778fc8aa7b08c79ddba55b639a0b47..735abf81aeea2652ba26639c855d0c1148fbfc17 100644 (file)
@@ -70,6 +70,8 @@ public :
   static SUIT_ResourceMgr*        resourceMgr();
   static SUIT_Desktop*            desktop();
   static SalomeApp_Study*         activeStudy();
+  static char*                    JoinObjectParameters(const QStringList& theParametersList);
+  
   bool                            isActiveStudyLocked();
 
   static bool                     automaticUpdate();
index 25f761469f7b3cfdf9044464ade61f829b559d4a..c93be4d562b70bc1dbdab225cd2e266d97e9b9a1 100644 (file)
@@ -238,7 +238,7 @@ QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
               w = sb;
             }
             else if(aStudy->IsReal(aVar.toLatin1().constData())){
-              SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
+              SalomeApp_DoubleSpinBox* sb = new SalomeApp_DoubleSpinBox( GroupC1 );
               sb->setObjectName( (*anIt).myName );
               attuneStdWidget( sb, i );
               sb->setText( aVar );
@@ -327,34 +327,16 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par
 QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
 {
   QStringList aResult;
-  QString item;
-  _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
-  if(aStudy) {
-    ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
-    for( ; anIt!=aLast; anIt++ ) {
-      if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
-        {
-          SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
-          item = sb->text();
-         bool isVariable = aStudy->IsVariable(item.toLatin1().constData()); 
-          isVariable ? aResult.append( item ) : aResult.append(QString());
-        }
-      
-      else if( (*anIt)->inherits( "QtxDoubleSpinBox" ) )
-      {
-        QtxDoubleSpinBox* sb = ( QtxDoubleSpinBox* )( *anIt );
-        item = sb->text();
-        bool isVariable = aStudy->IsVariable(item.toLatin1().constData());
-       isVariable ? aResult.append( item ) : aResult.append(QString());
-      } 
-    }
-    bool hasVar = false;
-    for (int i = 0;i<aResult.size();i++)
-      if(!aResult[i].isEmpty())
-        hasVar = true;
-
-    if(!hasVar)
-      aResult.clear();
+  ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
+  for( ; anIt!=aLast; anIt++ ) {
+    if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) ) {
+      SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
+      aResult.append(sb->text());
+    } 
+    else if( (*anIt)->inherits( "QtxDoubleSpinBox" ) ) {
+      QtxDoubleSpinBox* sb = ( QtxDoubleSpinBox* )( *anIt );
+      aResult.append(sb->text());
+    } 
   }
   return aResult;
 }
index 64a45c395190c439dbbdfa15aa04b3ac017d642b..151925c49b7cfb4762542e4127a69f733d48712e 100644 (file)
@@ -472,6 +472,7 @@ public:
 
   void UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters);
   char* GetParameters(CORBA::Object_ptr theObject);
+  
  
 private:
   // Create hypothesis of given type
index e088deb942a9fe25068c4858b4cf226c7f9083f2..3846c2247e264ddb6107b554f5c1c30718f2dc80 100644 (file)
@@ -882,14 +882,27 @@ void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theP
 
   if ( !aHyp->_is_nil() ) {
     CORBA::String_var objStr = aHyp->GetParameters();
-    TCollection_AsciiString aParams(theParameters);
-    if(aParams.Length()) {
-      SALOMEDS::GenericAttribute_var anAttr;
-      anAttr = aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString");
-      SALOMEDS::AttributeString::_narrow(anAttr)->SetValue( aParams.ToCString() );
+    TCollection_AsciiString aNewParams;
+    TCollection_AsciiString anInputParams;
+    SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(theParameters);
+    
+    SALOMEDS::GenericAttribute_var anAttr;
+    anAttr = aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString");
+    SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
+    TCollection_AsciiString aOldParameters(aStringAttr->Value());
+    SALOMEDS::ListOfStrings aVars= aSections[0];
+    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+=":";
     }
-    else
-      aStudyBuilder->RemoveAttribute(aSObj,"AttributeString");
+    if(!aOldParameters.Length())
+      aNewParams = anInputParams;
+    else 
+      aNewParams = aOldParameters+"|"+anInputParams;
+
+    aStringAttr->SetValue( aNewParams.ToCString() );
   }
 }
 
index 09e12ce0b734fc6ec547052716b186dc74edb20e..5b8265af92887da183c552e2bc4306cae28a153d 100644 (file)
@@ -130,19 +130,48 @@ CORBA::Long SMESH_Hypothesis_i::GetId()
 //=============================================================================
 void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
 {
-  string aNewParameters(theParameters);
-  string anOldParameters(GetParameters());
-  if(aNewParameters.compare(anOldParameters) != 0)
-    SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Hypothesis::_narrow(_this()), 
-                                                 theParameters);
+  SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Hypothesis::_narrow(_this()),
+                                               CORBA::string_dup(theParameters));
 }
 
+//=============================================================================
+/*!
+ *  SMESH_Hypothesis_i::GetParameters()
+ *
+ */
+//=============================================================================
 char* SMESH_Hypothesis_i::GetParameters()
 {
   SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
   return CORBA::string_dup(gen->GetParameters(SMESH::SMESH_Hypothesis::_narrow(_this())));
 }
 
+//=============================================================================
+/*!
+ *  SMESH_Hypothesis_i::GetLastParameters()
+ *
+ */
+//=============================================================================
+SMESH::ListOfParameters* SMESH_Hypothesis_i::GetLastParameters()
+{
+  SMESH::ListOfParameters_var aResult = new SMESH::ListOfParameters();
+  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();
+}
+
 //=============================================================================
 /*!
  *  SMESH_Hypothesis_i::GetImpl
index 99e3854691dd3c482531cd89b38a5e9a27f8b667..28184a5f5c2d6b11dbe5b841a8fd83a6d8dde57d 100644 (file)
@@ -71,6 +71,9 @@ public:
   
   // 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();
   
   // Get implementation
   ::SMESH_Hypothesis* GetImpl();
index 7f68eeb13f8800e2c3ec162d744f0f122d054634..ffdb9b114350a9f1558be18b0062621be5871965 100644 (file)
@@ -39,6 +39,80 @@ static int MYDEBUG = 0;
 
 using namespace std;
 
+
+
+//================================================================================
+/*!
+ * \brief Constructor
+ */
+//================================================================================
+ObjectStates::ObjectStates(TCollection_AsciiString theType)
+{
+  _type = theType;
+  _dumpstate = 0;
+}
+
+//================================================================================
+/*!
+ * \brief Destructor
+ */
+//================================================================================
+ObjectStates::~ObjectStates()
+{
+}
+
+//================================================================================
+/*!
+ * \brief Add new object state 
+ * \param theState - Object state (vector of notebook variable)
+ */
+//================================================================================
+void ObjectStates::AddState(const TState &theState)
+{
+  _states.push_back(theState);
+}
+
+//================================================================================
+/*!
+ * \brief Return current object state
+ * \\retval state - Object state (vector of notebook variable)
+ */
+//================================================================================
+TState ObjectStates::GetCurrectState() const
+{
+  return _states[_dumpstate];
+}
+
+
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+TAllStates ObjectStates::GetAllStates() const
+{
+  return _states;
+}
+
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+void ObjectStates::IncrementState()
+{
+  _dumpstate++;
+}
+
+//================================================================================
+/*!
+ *
+ */
+//================================================================================
+TCollection_AsciiString ObjectStates::GetObjectType() const{
+  return _type;
+}
+
 //================================================================================
 /*!
  * \brief Constructor
@@ -51,11 +125,16 @@ SMESH_NoteBook::SMESH_NoteBook()
 
 //================================================================================
 /*!
- * \brief Constructor
+ * \brief Destructor
  */
 //================================================================================
 SMESH_NoteBook::~SMESH_NoteBook()
 {
+  TVariablesMap::const_iterator it = _objectMap.begin();
+  for(;it!=_objectMap.end();it++) {
+    if((*it).second)
+      delete (*it).second;
+  }
 }
 
 //================================================================================
@@ -72,12 +151,21 @@ TCollection_AsciiString SMESH_NoteBook::ReplaceVariables(const TCollection_Ascii
   TCollection_AsciiString aObject = aCmd.GetObject();
   TVariablesMap::const_iterator it = _objectMap.find(aObject);
   if(!aMethod.IsEmpty() && it != _objectMap.end() ) {
-    
-    if(aMethod == "SetLength" && !(*it).second.at(0).IsEmpty() ) {
-      aCmd.SetArg(1,(*it).second.at(0));
-    }
-    else if(aMethod == "SetPrecision" && !(*it).second.at(1).IsEmpty() ){
-      aCmd.SetArg(1,(*it).second.at(1));
+    ObjectStates *aStates = (*it).second;
+    bool modified = false;
+    if(MYDEBUG)
+      cout<<"SMESH_NoteBook::ReplaceVariables :Object Type : "<<aStates->GetObjectType()<<endl;
+    if(aStates->GetObjectType().IsEqual("LocalLength")) {
+      if(aMethod == "SetLength") {
+        if(!aStates->GetCurrectState().at(0).IsEmpty() )
+          aCmd.SetArg(1,aStates->GetCurrectState().at(0));
+        aStates->IncrementState();
+      }
+      else if(aMethod == "SetPrecision") {
+        if(!aStates->GetCurrectState().at(1).IsEmpty() )
+          aCmd.SetArg(1,aStates->GetCurrectState().at(1));
+        aStates->IncrementState();
+      }
     }
     return aCmd.GetString();
   }
@@ -102,60 +190,49 @@ void SMESH_NoteBook::InitObjectMap()
   SALOMEDS::SObject_var aSO = aStudy->FindComponent(aGen->ComponentDataType());
   if(CORBA::is_nil(aSO))
     return;
-
+  
   SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
-  TCollection_AsciiString aParameters;
+  char* aParameters;
   for(Itr->InitEx(true); Itr->More(); Itr->Next()) {
     SALOMEDS::SObject_var aSObject = Itr->Value();
     SALOMEDS::GenericAttribute_var anAttr;
     if ( aSObject->FindAttribute(anAttr, "AttributeString")) {
-      aParameters = TCollection_AsciiString(SALOMEDS::AttributeString::_narrow(anAttr)->Value());
-      vector<string> vect = ParseVariables(aParameters.ToCString(),':');
+      aParameters = SALOMEDS::AttributeString::_narrow(anAttr)->Value();
+      SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
       if(MYDEBUG) {
         cout<<"Entry : "<< aSObject->GetID()<<endl;
         cout<<"aParameters : "<<aParameters<<endl;
+      }      
+      TCollection_AsciiString anObjType;
+      CORBA::Object_var anObject = SMESH_Gen_i::SObjectToObject(aSObject);
+      SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(anObject);
+      if(!aHyp->_is_nil()) {
+        anObjType = TCollection_AsciiString(aHyp->GetName());
       }
-      vector<TCollection_AsciiString> aVars;
-      for(int i = 0;i<vect.size();i++) {
-        TCollection_AsciiString aVar(vect[i].c_str());
-        if(!aVar.IsEmpty() && aStudy->IsVariable(vect[i].c_str())) {
-          aVar.InsertBefore(1,"\"");
-          aVar.InsertAfter(aVar.Length(),"\"");
-        }
-        aVars.push_back(aVar);
-        if(MYDEBUG) {
-          cout<<"Variable: "<<aVar<<endl;
+      else if(SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObject)) {
+        anObjType = TCollection_AsciiString("Mesh");
+      }
+      if(MYDEBUG)
+        cout<<"The object Type : "<<anObjType<<endl;
+      
+      ObjectStates *aState = new  ObjectStates(anObjType);
+      for(int i = 0; i < aSections->length(); i++) {
+        TState aVars;
+        SALOMEDS::ListOfStrings aListOfVars = aSections[i];
+        for(int j = 0;j<aListOfVars.length();j++) {
+          TCollection_AsciiString aVar(aListOfVars[j].in());
+          if(!aVar.IsEmpty() && aStudy->IsVariable(aVar.ToCString())) {
+            aVar.InsertBefore(1,"\"");
+            aVar.InsertAfter(aVar.Length(),"\"");
+          }
+          aVars.push_back(aVar);
+          if(MYDEBUG) {
+            cout<<"Variable: '"<<aVar<<"'"<<endl;
+          }
         }
+        aState->AddState(aVars);
       }
-      _objectMap.insert(pair<TCollection_AsciiString,vector<TCollection_AsciiString> >(TCollection_AsciiString(aSObject->GetID()),aVars));
+      _objectMap.insert(pair<TCollection_AsciiString,ObjectStates*>(TCollection_AsciiString(aSObject->GetID()),aState));
     }
   }
 }
-
-//================================================================================
-/*!
- * \brief Private method
- */
-//================================================================================
-vector<string> SMESH_NoteBook::ParseVariables(const string& theVariables, const char sep) const
-{
-  vector<string> aResult;
-  if(theVariables[0] == sep ) aResult.push_back(string());
-  int pos = theVariables.find(sep);
-  if(pos < 0) {
-    aResult.push_back(theVariables);
-    return aResult;
-  }
-
-  string s = theVariables;
-  if(s[0] == sep) s = s.substr(1, s.size());
-  while((pos = s.find(sep)) >= 0) {
-    aResult.push_back(s.substr(0, pos));
-    s = s.substr(pos+1, s.size());
-  }
-
-  if(!s.empty() && s[0] != sep) aResult.push_back(s);
-  if(theVariables[theVariables.size()-1] == sep) aResult.push_back(string());
-
-  return aResult;
-}
index 4bc395586027b3aa0dd79d5ae817c5665bc0306a..e11f3bd5cc036f48c4c52f316fc01e76847c78bd 100644 (file)
 #include <vector>
 #include <string>
 
+typedef std::vector<TCollection_AsciiString>  TState;
+typedef std::vector<TState>                   TAllStates;
+
+class ObjectStates{
+  
+public:
+  
+  ObjectStates(TCollection_AsciiString theType);
+  ~ObjectStates();
+
+  void AddState(const TState &theState);
+
+  TState GetCurrectState() const;
+  TAllStates GetAllStates() const;
+  void IncrementState();
+  TCollection_AsciiString GetObjectType() const;
+
+  
+
+private:
+  TCollection_AsciiString                   _type;
+  TAllStates                                _states;
+  int                                       _dumpstate;
+};
 
 class SMESH_NoteBook
 {
@@ -38,11 +62,10 @@ public:
   ~SMESH_NoteBook();
   TCollection_AsciiString ReplaceVariables(const TCollection_AsciiString& theString) const;
 
-  typedef std::map<TCollection_AsciiString,std::vector<TCollection_AsciiString> > TVariablesMap;
+  typedef std::map<TCollection_AsciiString,ObjectStates*> TVariablesMap;
 
 private:
   void InitObjectMap();
-  std::vector<std::string> ParseVariables(const std::string& theVariables, const char sep) const;
   
 private:
   TVariablesMap _objectMap;
index d6e2f2ae9c188b1aa8d1e9a9edcb9aa7b228bef2..cf62433791f534605581b0114eab0660e5c8d45d 100644 (file)
@@ -155,6 +155,9 @@ DefaultSize, DefaultGeom, Custom = 0,0,1
 
 PrecisionConfusion = 1e-07
 
+# Salome notebook variable separator
+variable_separator = ":"
+
 def IsEqual(val1, val2, tol=PrecisionConfusion):
     if abs(val1 - val2) < tol:
         return True
@@ -164,8 +167,6 @@ NO_NAME = "NoName"
 
 ## Gets object name
 def GetName(obj):
-    if isinstance(obj, BaseWrapper):
-        obj = obj.GetAlgorithm()
     ior  = salome.orb.object_to_string(obj)
     sobj = salome.myStudy.FindObjectIOR(ior)
     if sobj is None:
@@ -176,8 +177,6 @@ def GetName(obj):
 
 ## Sets a name to the object
 def SetName(obj, name):
-    if isinstance(obj, BaseWrapper):
-        obj = obj.GetAlgorithm()
     ior  = salome.orb.object_to_string(obj)
     sobj = salome.myStudy.FindObjectIOR(ior)
     if not sobj is None:
@@ -348,17 +347,6 @@ class smeshDC(SMESH._objref_SMESH_Gen):
         aMesh = Mesh(self, self.geompyD, aSmeshMesh)
         return aMesh
 
-    ## Create hyporthesis
-    #  @return an instance of hypothesis
-    #  @ingroup l2_impexp
-    def CreateHypothesis(self, hyp, so):
-        hypo = SMESH._objref_SMESH_Gen.CreateHypothesis(self, hyp, so)
-        if hyp == "LocalLength":
-            hypo = LocalLength(hypo)
-            
-        return hypo
-        
-
     ## Creates a Mesh object(s) importing data from the given MED file
     #  @return a list of Mesh class instances
     #  @ingroup l2_impexp
@@ -957,7 +945,7 @@ class Mesh:
     #  @return SMESH.Hypothesis_Status
     #  @ingroup l2_hypotheses
     def AddHypothesis(self, hyp, geom=0):
-        if isinstance( hyp, Mesh_Algorithm ) or isinstance( hyp, BaseWrapper):
+        if isinstance( hyp, Mesh_Algorithm ):
             hyp = hyp.GetAlgorithm()
             pass
         if not geom:
@@ -976,7 +964,7 @@ class Mesh:
     #  @return SMESH.Hypothesis_Status
     #  @ingroup l2_hypotheses
     def RemoveHypothesis(self, hyp, geom=0):
-        if isinstance( hyp, Mesh_Algorithm ) or isinstance( hyp, BaseWrapper):
+        if isinstance( hyp, Mesh_Algorithm ):
             hyp = hyp.GetAlgorithm()
             pass
         if not geom:
@@ -2889,12 +2877,7 @@ class Mesh_Algorithm:
                 pass
             SetName(hypo, hyp + a)
             pass
-        bhypo = None
-        if isinstance(hypo,BaseWrapper):
-            bhypo = hypo.GetAlgorithm()
-        else:
-            bhypo = hypo
-        status = self.mesh.mesh.AddHypothesis(self.geom, bhypo)
+        status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
         TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
         return hypo
 
@@ -4034,67 +4017,44 @@ class Mesh_UseExisting(Mesh_Algorithm):
             self.Create(mesh, geom, "UseExisting_2D")
 
 
+import salome_notebook
+notebook = salome_notebook.notebook
 
-
-from salome_notebook import *
-
-##Base class for wrap all StdMeshers interfaces
-class BaseWrapper:
-    
-    ##Return instance of a _objref_StdMeshers hypothesis
-    def GetAlgorithm(self):
-        return self.hypo
-
-    ##Return values of the notebook variables
-    def ParseParameters(self, params ,nbParams, nbParam, arg):
-        result = None
-        strResult = ""
-        isVar = False
-        if isinstance(arg, str):
-            if notebook.isVariable(arg):
-                result = notebook.get(arg)
-                isVar = True
+##Return values of the notebook variables
+def ParseParameters(last, nbParams,nbParam, value):
+    result = None
+    strResult = ""
+    counter = 0
+    listSize = len(last)
+    for n in range(0,nbParams):
+        if n+1 != nbParam:
+            if counter < listSize:
+                strResult = strResult + last[counter]
+            else:
+                strResult = strResult + ""
         else:
-            result = arg
-
-        isEmpty = True
-        paramsList = []
-        if len(params) > 0:
-            paramsList = params.split(":")
-            isEmpty = False
-            
-        for n in range(1,nbParams+1):
-            if n != nbParam and not isEmpty and len(paramsList[n-1])> 0:
-                strResult = paramsList[n-1] + ":"
-                pass
-            if isVar and n == nbParam:
-                if len(strResult) == 0 and nbParam != 1:
-                    strResult = strResult + ":"
-                    pass
-                strResult = strResult+arg
-                if n != nbParams:
-                    strResult = strResult + ":"
-                    
-        return result, strResult
-            
-       
-#Wrapper class for StdMeshers_LocalLength hypothesis
-class LocalLength(BaseWrapper):
-    def __init__(self, hypo):
-        self.hypo = hypo
-
+            if isinstance(value, str) and notebook.isVariable(value):
+                result = notebook.get(value)
+                strResult=strResult+value 
+            else:
+                strResult=strResult+str(value)
+                result = value
+        if nbParams - 1 != counter:
+            strResult=strResult+variable_separator #":"
+        counter = counter+1
+    return result, strResult
+
+class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
+        
     def SetLength(self, length):
-        length,parameters = self.ParseParameters(self.hypo.GetParameters(),2,1,length)
-        self.hypo.SetParameters(parameters)
-        self.hypo.SetLength(length)
+        length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
+        StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
+        StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
 
     def SetPrecision(self, precision):
-        precision,parameters = self.ParseParameters(self.hypo.GetParameters(),2,2,precision)
-        self.hypo.SetParameters(parameters)
-        self.hypo.SetPrecision(precision)
-
-    def GetLength(self):
-        return self.hypo.GetLength()
+        precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
+        StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
+        StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
 
-    def GetPrecision(self):
-        return self.hypo.GetLength()
+#Registering the new proxy for LocalLength
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
index f2bec67af131609c801c44ff4b4cfbc8824fb218..d893462df003937e47f7daef73d61c5c280546df 100644 (file)
@@ -409,15 +409,11 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
     {
       StdMeshers::StdMeshers_LocalLength_var h =
        StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
-      if(!aVariablesList.isEmpty()) {
-        QString aVariables = aVariablesList.join(":");
-        h->SetParameters(aVariables.toLatin1().constData());
-      }
-      else
-        h->SetParameters("");
-        
+
       h->SetLength( params[0].myValue.toDouble() );
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
       h->SetPrecision( params[1].myValue.toDouble() );
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
     }
     else if( hypType()=="SegmentLengthAroundVertex" )
     {
@@ -561,28 +557,23 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
   {
     StdMeshers::StdMeshers_LocalLength_var h =
       StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
-
-    QString aParameters(h->GetParameters());
-    QStringList aParametersList;
-    if(aParameters.length())
-      aParametersList = aParameters.split(":");
-
+    SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
+    
     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
-    QVariant aVariable = parseParameter(aParametersList,0);
-    if(aVariable.type() != QVariant::Invalid) {
-      item.myValue = aVariable;
-      item.isVariable = true;
-    }
+
+    QString aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");
+    item.isVariable = !aVaribaleName.isEmpty();
+    if(item.isVariable) 
+      item.myValue = aVaribaleName;
     else
       item.myValue = h->GetLength();
     p.append( item );
      
     item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
-    aVariable = parseParameter(aParametersList,1);
-    if(aVariable.type() !=  QVariant::Invalid) {
-      item.myValue = aVariable;
-      item.isVariable = true;
-    }
+    aVaribaleName = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString("");
+    item.isVariable = !aVaribaleName.isEmpty();
+    if(item.isVariable)
+      item.myValue = aVaribaleName;
     else
       item.myValue = h->GetPrecision();
     p.append( item );
@@ -948,7 +939,7 @@ void StdMeshersGUI_StdHypothesisCreator::onReject()
  * \brief
  */
 //================================================================================
-QVariant StdMeshersGUI_StdHypothesisCreator::
+/*QVariant StdMeshersGUI_StdHypothesisCreator::
 parseParameter(const QStringList& theList, int theNbParam) const
 {
   _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
@@ -974,3 +965,4 @@ parseParameter(const QStringList& theList, int theNbParam) const
   }
   return aResult;
 }
+*/
index acd2357b5fd8bdddade04dbab27f94cba0a4509f..76586083a09ebe64957f6847ae4a8e16c14433fe 100644 (file)
@@ -58,7 +58,7 @@ protected:
   virtual QWidget* getWidgetForParam( int paramIndex ) const;
   virtual ListOfWidgets* customWidgets() const;
   virtual void     onReject();
-  virtual QVariant parseParameter(const QStringList& theList, int theNbParam) const;
+  //  virtual QVariant parseParameter(const QStringList& theList, int theNbParam) const;
 
   template<class T>
     T* widget(int i) const {