Salome HOME
Added method GetExpression( in boolean forceConvert )
authorouv <ouv@opencascade.com>
Thu, 26 Nov 2009 08:37:46 +0000 (08:37 +0000)
committerouv <ouv@opencascade.com>
Thu, 26 Nov 2009 08:37:46 +0000 (08:37 +0000)
idl/SALOME_Notebook.idl
src/Notebook/SALOME_Notebook.cxx
src/Notebook/SALOME_Parameter.cxx
src/Notebook/SALOME_Parameter.hxx

index 199be1cedbb5ff7ff721a0389b91d9be8bd7c44a..39068ab8631440ea9f607c130679f4f582942d63 100644 (file)
@@ -122,6 +122,9 @@ module SALOME
 
 
 
+    //! change expression of the parameter
+    string GetExpression( in boolean forceConvert );
+
     //! return type of parameter
     ParamType GetType();
 
index c811839fa5ae3b81c4b7d7fe808835c391980002..6cc8a8418fbe688d3013243ec1d6c7e932c8c3f9 100644 (file)
@@ -396,7 +396,7 @@ void SALOME_Notebook::Remove( const char* theParamName )
   {
     std::string anExpr;
     if( aParam->IsCalculable() )
-      anExpr = aParam->Expression();
+      anExpr = aParam->GetExpression( false );
     else
       anExpr = aParam->AsString();
     AddSubstitution( theParamName, anExpr, false );
@@ -815,7 +815,7 @@ char* SALOME_Notebook::DumpPython()
     if( aParam->IsCalculable() )
     {
       aRes += "\"";
-      aRes += aParam->Expression();
+      aRes += aParam->GetExpression( false );
       aRes += "\"";
     }
     else
@@ -899,7 +899,7 @@ char* SALOME_Notebook::Dump()
     if( pit->second->IsAnonymous() )
       aStr += "[A] ";
     if( pit->second->IsCalculable() )
-      aStr += pit->second->Expression() + " (val=" + pit->second->AsString() + ")";
+      aStr += std::string( pit->second->GetExpression( false ) ) + " (val=" + pit->second->AsString() + ")";
     else
       aStr += pit->second->AsString();
     aStr += "\n";
index e99d259f8272eb603d5c5ec6db3a780dc7232ec2..a2f9a2980c2e72e9727c279159424554c815261d 100644 (file)
@@ -277,9 +277,14 @@ bool SALOME_Parameter::IsCalculable() const
   return myIsCalculable;
 }
 
-std::string SALOME_Parameter::Expression() const
+char* SALOME_Parameter::GetExpression( CORBA::Boolean theForceConvert )
 {
-  return myExpr.expression();
+  const char* aRes;
+  if( IsCalculable() )
+    aRes = myExpr.expression().c_str();
+  else
+    aRes = theForceConvert ? myResult.toString().c_str() : "";
+  return CORBA::string_dup( aRes );
 }
 
 void SALOME_Parameter::Substitute( const std::string& theName, const SALOME_EvalExpr& theExpr )
index 1630a0435dafe5964b54f98a55065393afee90a7..fde123eac6a1588d9927373f6807749c736198d2 100644 (file)
@@ -71,6 +71,8 @@ public:
   virtual CORBA::Double  AsReal();
   virtual CORBA::Boolean AsBoolean();
 
+  virtual char* GetExpression( CORBA::Boolean theForceConvert );
+
   SALOME_StringList Dependencies() const;
 
   std::string Save() const;
@@ -79,7 +81,6 @@ public:
   bool IsAnonymous() const;
   bool IsCalculable() const;
 
-  std::string Expression() const;
   void Substitute( const std::string& theName, const SALOME_EvalExpr& theExpr );
 
 private: