]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Implementation NoteBook in SMESH module.
authorrnv <rnv@opencascade.com>
Fri, 28 Nov 2008 15:44:49 +0000 (15:44 +0000)
committerrnv <rnv@opencascade.com>
Fri, 28 Nov 2008 15:44:49 +0000 (15:44 +0000)
src/SMESH_I/SMESH_Gen_i_1.cxx
src/SMESH_I/SMESH_NoteBook.cxx
src/SMESH_SWIG/smeshDC.py
src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx

index 556d7e7c1580e4b99b0c1900c7101f4cd4cfa09b..039330044f205246939bdb62e7c77422dfa6e397 100644 (file)
 
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
+static int VARIABLE_DEBUG = 1;
 #else
 static int MYDEBUG = 0;
+static int VARIABLE_DEBUG = 1;
 #endif
 
+
+
+
 //=============================================================================
 /*!
  *  Get...Tag [ static ]
@@ -869,15 +874,24 @@ bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr         theStudy
 //=======================================================================
 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())
+  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);
@@ -886,10 +900,18 @@ void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theP
   TCollection_AsciiString aOldParameters(aStringAttr->Value());
   TCollection_AsciiString anInputParams(ParseParameters(theParameters));
   
-  if(!aOldParameters.Length())
+  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() );
 }
index b143f63b48ca4f00838320fb193dd5f2b0ea3092..57dd307c65c0590b98a6a36564d1f4e19b537af7 100644 (file)
@@ -81,7 +81,10 @@ void ObjectStates::AddState(const TState &theState)
 //================================================================================
 TState ObjectStates::GetCurrectState() const
 {
-  return _states[_dumpstate];
+  if(_states.size() > _dumpstate)
+    return _states[_dumpstate];
+  TState empty;
+  return empty;
 }
 
 
@@ -243,7 +246,7 @@ void SMESH_NoteBook::ReplaceVariables()
     if(it != _objectMap.end() && !aMethod.IsEmpty()) {
       ObjectStates *aStates = (*it).second;
       // Case for LocalLength hypothesis
-      if(aStates->GetObjectType().IsEqual("LocalLength")) {
+      if(aStates->GetObjectType().IsEqual("LocalLength") && aStates->GetCurrectState().size() >= 2) {
         if(aMethod.IsEqual("SetLength")) {
           if(!aStates->GetCurrectState().at(0).IsEmpty() )
             aCmd->SetArg(1,aStates->GetCurrectState().at(0));
@@ -257,13 +260,25 @@ void SMESH_NoteBook::ReplaceVariables()
       }
       
       // Case for SegmentLengthAroundVertex hypothesis
-      else if(aStates->GetObjectType().IsEqual("SegmentLengthAroundVertex")) {
+      else if(aStates->GetObjectType().IsEqual("SegmentLengthAroundVertex")
+              && aStates->GetCurrectState().size() >= 1) {
         if(aMethod == "SetLength") {
           if(!aStates->GetCurrectState().at(0).IsEmpty() )
             aCmd->SetArg(1,aStates->GetCurrectState().at(0));
           aStates->IncrementState();
         }
       }
+
+      else if(aStates->GetObjectType().IsEqual("Arithmetic1D")) {
+        if(aMethod == "SetLength" &&
+           aStates->GetCurrectState().size() >= 2) {
+          if(aCmd->GetArg(2) == "1" && !aStates->GetCurrectState().at(0).IsEmpty())
+            aCmd->SetArg(1,aStates->GetCurrectState().at(0));
+          else if(!aStates->GetCurrectState().at(1).IsEmpty())
+            aCmd->SetArg(1,aStates->GetCurrectState().at(1));
+          aStates->IncrementState();
+        }
+      }
       // Case for LayerDistribution hypothesis (not finished yet)
       else if(aStates->GetObjectType() == "LayerDistribution") {
         if(aMethod == "SetLayerDistribution"){
index 6df514bbf87f33b5222b5dcf2906090f51e58b21..0684cecc422ad664fe925ca0fb9137409c175cfb 100644 (file)
@@ -4116,14 +4116,31 @@ omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryI
 
 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
-    parent = StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex
     
     ## Set length parameter value
     #  @param length numerical value or name of variable from notebook    
     def SetLength(self, length):
-        length,parameters = ParseParameters(parent.GetLastParameters(self),1,1,length)
-        parent.SetParameters(self,parameters)
-        parent.SetLength(self,length)
+        length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
+        StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
+        StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
 
+#Registering the new proxy for SegmentLengthAroundVertex
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
+
+
+#Wrapper class for StdMeshers_Arithmetic1D hypothesis
+class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
+    
+    ## Set length parameter value
+    #  @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:
+            nb = 1
+        length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
+        StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
+        StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
+        
 #Registering the new proxy for LocalLength
-omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, LocalLength)
+omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
index 17795040610dde71ca65acda1a6c862e63c63520..b7bf0f6e58648acc7103177181501f0a3ab123e4 100644 (file)
@@ -429,7 +429,9 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
        StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
 
       h->SetLength( params[0].myValue.toDouble(), true );
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
       h->SetLength( params[1].myValue.toDouble(), false );
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
     }
     else if( hypType()=="MaxElementArea" )
     {
@@ -605,11 +607,25 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
     StdMeshers::StdMeshers_Arithmetic1D_var h =
       StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
 
+    aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");
+    
+    item.isVariable = !aVaribaleName.isEmpty();
+
     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
-    item.myValue = h->GetLength( true );
+    if(item.isVariable)
+      item.myValue = aVaribaleName;
+    else
+      item.myValue = h->GetLength( true );
     p.append( item );
+
+    aVaribaleName = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString("");
+
     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
-    item.myValue = h->GetLength( false );
+
+    if(item.isVariable)
+      item.myValue = aVaribaleName;
+    else
+      item.myValue = h->GetLength( false );
     p.append( item );
   }
   else if( hypType()=="MaxElementArea" )