Salome HOME
Dump python extension.
authorrnv <rnv@opencascade.com>
Thu, 4 Dec 2008 14:48:57 +0000 (14:48 +0000)
committerrnv <rnv@opencascade.com>
Thu, 4 Dec 2008 14:48:57 +0000 (14:48 +0000)
idl/SMESH_Hypothesis.idl
src/SMESH/SMESH_Hypothesis.cxx
src/SMESH/SMESH_Hypothesis.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

index cf226ef9fcd4608564af2c5cda4ae3b2a422cd23..0396338abee322884c1c5000ba3676c54c22cbaf 100644 (file)
@@ -76,6 +76,18 @@ module SMESH
      */
     ListOfParameters GetLastParameters();
 
      */
     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 
      */
     /*!
      * Verify whether hypothesis supports given entity type 
      */
index 0d522463d2de17eac4ba97043948b9f3dfc1ce28..4f447be5bf53ecf3fd06ab546045a21565589376 100644 (file)
@@ -159,7 +159,23 @@ void SMESH_Hypothesis::SetLibName(const char* theLibName)
 //=============================================================================
 void SMESH_Hypothesis::SetParameters(const char *theParameters)
 {
 //=============================================================================
 void SMESH_Hypothesis::SetParameters(const char *theParameters)
 {
-  _parameters = string(theParameters);
+  string aNewParameters(theParameters);
+  if(aNewParameters.size()==0 && _parameters.size()==0)
+    aNewParameters = " ";
+  if(_parameters.size()>0)
+    _parameters +="|";
+  _parameters +=aNewParameters;
+  SetLastParameters(theParameters);
+}
+
+//=============================================================================
+/*!
+ * 
+ */
+//=============================================================================
+void SMESH_Hypothesis::ClearParameters()
+{
+  _parameters = string();
 }
 
 //=============================================================================
 }
 
 //=============================================================================
@@ -171,3 +187,23 @@ char* SMESH_Hypothesis::GetParameters() const
 {
   return (char*)_parameters.c_str();
 }
 {
   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);
+}
index 2e043186f724599ad0f547849247586fa800cacf..f11a51567ab2daf62b460cadd27b8f01aa96b19d 100644 (file)
@@ -71,8 +71,12 @@ public:
   void  SetLibName(const char* theLibName);
 
   void  SetParameters(const char *theParameters);
   void  SetLibName(const char* theLibName);
 
   void  SetParameters(const char *theParameters);
-  char* GetParameters() const;  
+  char* 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
   /*!
    * \brief Initialize my parameter values by the mesh built on the geometry
     * \param theMesh - the built mesh
@@ -101,6 +105,7 @@ protected:
 private:
   std::string _libName;
   std::string _parameters;
 private:
   std::string _libName;
   std::string _parameters;
+  std::string _lastParameters;
 };
 
 #endif
 };
 
 #endif
index 0eaa31f61a4f59dabaa678d9bdffb2929688d766..03b6ac9683fbbb27699ea0721d13c6ad237183d1 100644 (file)
@@ -866,7 +866,7 @@ bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr         theStudy
 }
 
 //=======================================================================
 }
 
 //=======================================================================
-//function : UpdateSObject
+//function : UpdateParameters
 //purpose  : 
 //=======================================================================
 void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters)
 //purpose  : 
 //=======================================================================
 void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters)
@@ -914,7 +914,7 @@ void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theP
 }
 
 //=======================================================================
 }
 
 //=======================================================================
-//function : GetParameters
+//function : ParseParameters
 //purpose  : 
 //=======================================================================
 char* SMESH_Gen_i::ParseParameters(const char* theParameters)
 //purpose  : 
 //=======================================================================
 char* SMESH_Gen_i::ParseParameters(const char* theParameters)
@@ -924,14 +924,16 @@ char* SMESH_Gen_i::ParseParameters(const char* theParameters)
   SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
   if( !aStudy->_is_nil() ) {
     SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
   SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
   if( !aStudy->_is_nil() ) {
     SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
-    if(aSections->length() > 0) {
-      SALOMEDS::ListOfStrings aVars= aSections[0];
+    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+=":";
       }
       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+="|";
     }
   }
   return CORBA::string_dup(anInputParams.ToCString());
     }
   }
   return CORBA::string_dup(anInputParams.ToCString());
index a65b84362c8aabfa89a20e6a9c2f66a3a9967679..2031cdfc0f5065863e10be820ace74b24129d5b8 100644 (file)
@@ -191,7 +191,12 @@ SMESH::ListOfParameters* SMESH_Hypothesis_i::GetLastParameters()
   SMESH::ListOfParameters_var aResult = new SMESH::ListOfParameters();
   SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
   if(gen) {
   SMESH::ListOfParameters_var aResult = new SMESH::ListOfParameters();
   SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
   if(gen) {
-    char *aParameters = GetParameters();
+    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); 
     SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy();
     if(!aStudy->_is_nil()) {
       SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters); 
@@ -206,6 +211,31 @@ SMESH::ListOfParameters* SMESH_Hypothesis_i::GetLastParameters()
   return aResult._retn();
 }
 
   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();
+  }
+}
+
 //=============================================================================
 /*!
  *  SMESH_Hypothesis_i::GetImpl
 //=============================================================================
 /*!
  *  SMESH_Hypothesis_i::GetImpl
index e93554ae6cebf0cdde0b27fc46a527180cb2eba4..c176aba30af8a9d4d82862fb246c4756980a0bac 100644 (file)
@@ -75,6 +75,13 @@ public:
   //Return list of last notebook variables used for Hypothesis creation.
   SMESH::ListOfParameters* GetLastParameters();
 
   //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 true if hypothesis was published in study
   bool IsPublished();
 
   //Return true if hypothesis was published in study
   bool IsPublished();
 
index ac3ae0c152a29c3cc10b9c56e718277b0f5ea948..91ae27deff7e793c876943e25cb3098dcb941de2 100644 (file)
@@ -41,6 +41,7 @@ static int MYDEBUG = 0;
 using namespace std;
 
 
 using namespace std;
 
 
+void SetVariable(Handle(_pyCommand) theCommand,const ObjectStates* theStates, int position, int theArgNb);
 
 //================================================================================
 /*!
 
 //================================================================================
 /*!
@@ -295,6 +296,8 @@ void SMESH_NoteBook::ReplaceVariables()
         if(aMethod == "SetLayerDistribution"){
           LayerDistributionStates* aLDStates = (LayerDistributionStates*)(aStates);
           aLDStates->AddDistribution(aCmd->GetArg(1));
         if(aMethod == "SetLayerDistribution"){
           LayerDistributionStates* aLDStates = (LayerDistributionStates*)(aStates);
           aLDStates->AddDistribution(aCmd->GetArg(1));
+          if(MYDEBUG)
+            cout<<"Add Distribution :"<<aCmd->GetArg(1)<<endl;
         }
       }
       
         }
       }
       
@@ -573,7 +576,8 @@ void SMESH_NoteBook::ReplaceVariables()
       cout<<"Command after: "<< aCmd->GetString()<<endl;
     }
   }
       cout<<"Command after: "<< aCmd->GetString()<<endl;
     }
   }
-  //  ProcessLayerDistribution();
+  
+  ProcessLayerDistribution();
 }
 //================================================================================
 /*!
 }
 //================================================================================
 /*!
@@ -618,8 +622,9 @@ void SMESH_NoteBook::InitObjectMap()
       if(MYDEBUG)
         cout<<"The object Type : "<<anObjType<<endl;
       ObjectStates *aState = NULL;
       if(MYDEBUG)
         cout<<"The object Type : "<<anObjType<<endl;
       ObjectStates *aState = NULL;
-      if(anObjType == "LayerDistribution")
+      if(anObjType == "LayerDistribution") {
         aState = new LayerDistributionStates();
         aState = new LayerDistributionStates();
+      }
       else
         aState = new  ObjectStates(anObjType);
       
       else
         aState = new  ObjectStates(anObjType);
       
@@ -672,10 +677,15 @@ void SMESH_NoteBook::ProcessLayerDistribution()
   // 1) Find all LayerDistribution states
   vector<LayerDistributionStates*> aLDS;
   TVariablesMap::const_iterator it = _objectMap.begin();
   // 1) Find all LayerDistribution states
   vector<LayerDistributionStates*> aLDS;
   TVariablesMap::const_iterator it = _objectMap.begin();
-  for(;it != _objectMap.end();it++)
-    if(LayerDistributionStates* aLDStates = (LayerDistributionStates*)((*it).second)) {
+  for(;it != _objectMap.end();it++) {
+    LayerDistributionStates* aLDStates = dynamic_cast<LayerDistributionStates*>(((*it).second));
+    if(aLDStates!=NULL) {
       aLDS.push_back(aLDStates);
     }
       aLDS.push_back(aLDStates);
     }
+  }
+  
+  if(!aLDS.size())
+    return;
   
   // 2) Initialize all type of 1D Distribution hypothesis
   for(int i=0;i<_commands.size();i++){
   
   // 2) Initialize all type of 1D Distribution hypothesis
   for(int i=0;i<_commands.size();i++){
@@ -700,13 +710,39 @@ void SMESH_NoteBook::ProcessLayerDistribution()
         TCollection_AsciiString aMethod = _commands[i]->GetMethod();
         if(aType == "LocalLength") {
           if(aMethod == "SetLength") {
         TCollection_AsciiString aMethod = _commands[i]->GetMethod();
         if(aType == "LocalLength") {
           if(aMethod == "SetLength") {
-            if(!aLDS[j]->GetCurrectState().at(0).IsEmpty() )
-              _commands[i]->SetArg(1,aLDS[j]->GetCurrectState().at(0));
+            SetVariable(_commands[i], aLDS[j],0,1);
             aLDS[j]->IncrementState();
           }
           else if(aMethod == "SetPrecision") {
             aLDS[j]->IncrementState();
           }
           else if(aMethod == "SetPrecision") {
-            if(!aLDS[j]->GetCurrectState().at(1).IsEmpty() )
-              _commands[i]->SetArg(1,aLDS[j]->GetCurrectState().at(1));
+            SetVariable(_commands[i], aLDS[j],1,1);
+            aLDS[j]->IncrementState();
+          }
+        }
+
+        // Case for NumberOfSegments hypothesis
+        else if(aType == "NumberOfSegments"){
+          if(aMethod == "SetNumberOfSegments") {
+            SetVariable(_commands[i], aLDS[j],0,1);
+            if(aLDS[j]->GetCurrectState().size()==1)
+              aLDS[j]->IncrementState();
+          }
+          else if (aMethod == "SetScaleFactor") {
+            SetVariable(_commands[i], aLDS[j],1,1);
+            aLDS[j]->IncrementState();
+          }
+        }
+        
+        else if( aType == "Deflection1D" ){
+          if(aMethod == "SetDeflection"){
+            SetVariable(_commands[i], aLDS[j],0,1);
+            aLDS[j]->IncrementState();
+          }
+        }
+        // Case for Arithmetic1D and StartEndLength hypothesis
+        else if(aType == "Arithmetic1D" || aType == "StartEndLength") {
+          if(aMethod == "SetLength") {
+            int anArgNb = (_commands[i]->GetArg(2) == "1") ? 0 : 1;
+            SetVariable(_commands[i], aLDS[j],anArgNb,1);
             aLDS[j]->IncrementState();
           }
         }
             aLDS[j]->IncrementState();
           }
         }
@@ -758,3 +794,15 @@ bool SMESH_NoteBook::GetReal(const TCollection_AsciiString& theVarName, double&
 
   return ok;
 }
 
   return ok;
 }
+
+
+/*!
+ *  Set variable of the ObjectStates from position to the _pyCommand
+ *  method as nbArg argument
+ */
+void SetVariable(Handle(_pyCommand) theCommand, const ObjectStates* theStates, int position, int theArgNb)
+{
+  if(theStates->GetCurrectState().size() > position)
+    if(!theStates->GetCurrectState().at(position).IsEmpty())
+      theCommand->SetArg(theArgNb,theStates->GetCurrectState().at(position));
+}
index 5c0d2d7b034de693751d0867492bdd23a5637d45..dfeb3b50a23123e704fce386104e7b1b8b6bf0c0 100644 (file)
@@ -41,7 +41,7 @@ class ObjectStates{
 public:
   
   ObjectStates(TCollection_AsciiString theType);
 public:
   
   ObjectStates(TCollection_AsciiString theType);
-  ~ObjectStates();
+  virtual ~ObjectStates();
 
   void AddState(const TState &theState);
 
 
   void AddState(const TState &theState);
 
@@ -63,7 +63,7 @@ class LayerDistributionStates : public ObjectStates
 public:
   typedef std::map<TCollection_AsciiString,TCollection_AsciiString> TDistributionMap;
   LayerDistributionStates();
 public:
   typedef std::map<TCollection_AsciiString,TCollection_AsciiString> TDistributionMap;
   LayerDistributionStates();
-  ~LayerDistributionStates();
+  virtual ~LayerDistributionStates();
 
   void AddDistribution(const TCollection_AsciiString& theDistribution);
   bool HasDistribution(const TCollection_AsciiString& theDistribution) const;
 
   void AddDistribution(const TCollection_AsciiString& theDistribution);
   bool HasDistribution(const TCollection_AsciiString& theDistribution) const;
index 9d8cfb94ce92b0550277b311024a232bf606aa93..ff5a6c35f2a07987c245bc3c9d5698db01c3b756 100644 (file)
@@ -4350,6 +4350,17 @@ class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
 
 
 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
 
 
+#Wrapper class for StdMeshers_LayerDistribution hypothesis
+class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
+    
+    def SetLayerDistribution(self, hypo):
+        StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
+        hypo.ClearParameters();
+        StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
+
+#Registering the new proxy for LayerDistribution
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
+
 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
     
 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
     
@@ -4398,8 +4409,8 @@ omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_Repository
 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
     
     ## Set Length parameter value
 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
     
     ## Set Length parameter value
-    #  @param length   numerical value or name of variable from notebook
-    #  @param isStart  true is length is Start Length, otherwise false
+    #  @param length  numerical value or name of variable from notebook
+    #  @param isStart true is length is Start Length, otherwise false
     def SetLength(self, length, isStart):
         nb = 2
         if isStart:
     def SetLength(self, length, isStart):
         nb = 2
         if isStart:
index c7b62ea1440d8d2d920c2135f0f98edc74934a76..651d87f33302ecd9db39f816d3208bcb57ae80ee 100644 (file)
@@ -488,10 +488,8 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
       
       h->SetLayerDistribution( w->GetHypothesis() );
         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
       
       h->SetLayerDistribution( w->GetHypothesis() );
-      /*      h->SetParameters(w->GetHypothesis()->GetParameters());
-      if(QString(w->GetHypothesis()->GetName()) == "LocalLength")
-        h->SetParameters(w->GetHypothesis()->GetParameters());
-      */
+      h->SetParameters(w->GetHypothesis()->GetParameters());
+      w->GetHypothesis()->ClearParameters();
     }
     else if( hypType()=="ProjectionSource1D" )
     {
     }
     else if( hypType()=="ProjectionSource1D" )
     {
@@ -684,13 +682,13 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
     
     //Set into not published hypo last variables
     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
     
     //Set into not published hypo last variables
-    /*    QStringList aLastVarsList;
+    QStringList aLastVarsList;
     for(int i = 0;i<aParameters->length();i++) 
       aLastVarsList.append(QString(aParameters[i].in()));
 
     if(!aLastVarsList.isEmpty())
     for(int i = 0;i<aParameters->length();i++) 
       aLastVarsList.append(QString(aParameters[i].in()));
 
     if(!aLastVarsList.isEmpty())
-      h->GetLayerDistribution()->SetParameters(SMESHGUI::JoinObjectParameters(aLastVarsList));
-    */    
+      h->GetLayerDistribution()->SetLastParameters(SMESHGUI::JoinObjectParameters(aLastVarsList));
+    
     customWidgets()->append
       ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
   }
     customWidgets()->append
       ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
   }