From 1cfc9b3938f17c92bc79745b582812b57325ea97 Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 20 Nov 2009 08:00:02 +0000 Subject: [PATCH] New methods: SetParam(), GetParam(), GetArgsCount() for notebook functionality --- src/GEOM/GEOM_Function.cxx | 47 ++++++++++++++++++++++++++++++++++++++ src/GEOM/GEOM_Function.hxx | 9 ++++++++ 2 files changed, 56 insertions(+) diff --git a/src/GEOM/GEOM_Function.cxx b/src/GEOM/GEOM_Function.cxx index d9d1c321e..142a3a4ca 100644 --- a/src/GEOM/GEOM_Function.cxx +++ b/src/GEOM/GEOM_Function.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -299,6 +300,52 @@ void GEOM_Function::SetDescription(const TCollection_AsciiString& theDescription TDataStd_Comment::Set(aChild, TCollection_ExtendedString(theDescription)); } +//============================================================================= +/*! + * GetArgsCount + */ +//============================================================================= +int GEOM_Function::GetArgsCount() +{ + return _label.FindChild( ARGUMENT_LABEL ).NbChildren(); +} + +//============================================================================= +/*! + * SetParam + */ +//============================================================================= +void GEOM_Function::SetParam( int thePosition, const TCollection_AsciiString& theParamName ) +{ + _isDone = false; + if( thePosition <= 0 ) + return; + + TDF_Label anArgLabel = ARGUMENT( thePosition ); + TDataStd_AsciiString::Set( anArgLabel, theParamName ); + _isDone = true; +} + +//============================================================================= +/*! + * GetParam + */ +//============================================================================= +TCollection_AsciiString GEOM_Function::GetParam(int thePosition) +{ + _isDone = false; + if( thePosition <= 0 ) + return 0.0; + + Handle( TDataStd_AsciiString ) aParam; + TDF_Label anArgLabel = ARGUMENT( thePosition ); + if( !anArgLabel.FindAttribute( TDataStd_AsciiString::GetID(), aParam ) ) + return ""; + + _isDone = true; + return aParam->Get(); +} + //============================================================================= /*! * SetReal diff --git a/src/GEOM/GEOM_Function.hxx b/src/GEOM/GEOM_Function.hxx index 3e1ea6970..7519c8aa8 100644 --- a/src/GEOM/GEOM_Function.hxx +++ b/src/GEOM/GEOM_Function.hxx @@ -189,6 +189,15 @@ public: //Access to arguments + //Return number of function arguments + Standard_EXPORT int GetArgsCount(); + + //Sets a parameter name as argument at position thePosition + Standard_EXPORT void SetParam( int thePosition, const TCollection_AsciiString& theParamName ); + + //Returns a parameter name as argument at position thePosition + Standard_EXPORT TCollection_AsciiString GetParam( int thePosition ); + //Sets a real argument at position thePosition Standard_EXPORT void SetReal(int thePosition, double theValue); -- 2.39.2