From 927447f2ef3379740c5435294cc488a2318b6a8d Mon Sep 17 00:00:00 2001 From: asl Date: Tue, 24 Nov 2009 10:19:57 +0000 Subject: [PATCH] new methods calculate() - calculation of expressions using Notebook's parameters and convert() - conversion of Notebook's parameter into QVariant --- src/SalomeApp/SalomeApp_Notebook.cxx | 29 ++++++++++++++++++++++++++-- src/SalomeApp/SalomeApp_Notebook.h | 3 +++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/SalomeApp/SalomeApp_Notebook.cxx b/src/SalomeApp/SalomeApp_Notebook.cxx index f2681ea69..bf53ab5af 100644 --- a/src/SalomeApp/SalomeApp_Notebook.cxx +++ b/src/SalomeApp/SalomeApp_Notebook.cxx @@ -95,10 +95,31 @@ void SalomeApp_Notebook::set( const QString& theName, const QVariant& theValue ) } QVariant SalomeApp_Notebook::get( const QString& theName ) const +{ + return convert( myNotebook->GetParameter( theName.toLatin1().constData() ) ); +} + +QVariant SalomeApp_Notebook::calculate( const QString& theExpr ) const +{ + if( CORBA::is_nil( myTmp ) ) + { + static const char TMP_NAME[] = "__notebook__tmp__"; + myTmp = myNotebook->GetParameter( TMP_NAME ); + if( CORBA::is_nil( myTmp ) ) + { + myNotebook->AddReal( TMP_NAME, 0 ); + myTmp = myNotebook->GetParameter( TMP_NAME ); + } + } + myTmp->SetExpression( theExpr ); + myTmp->Update(); + return convert( myTmp ); +} + +QVariant SalomeApp_Notebook::convert( SALOME::Parameter_ptr theParam ) const { QVariant aRes; - SALOME::Parameter_ptr aParam = myNotebook->GetParameter( theName.toLatin1().constData() ); - if( !CORBA::is_nil( aParam ) ) + if( !CORBA::is_nil( theParam ) ) switch( aParam->GetType() ) { case SALOME::TBoolean: @@ -117,6 +138,10 @@ QVariant SalomeApp_Notebook::get( const QString& theName ) const return aRes; } +QVariant SalomeApp_Notebook::calculate( const QString& theExpr ) const +{ +} + void SalomeApp_Notebook::update() { myNotebook->Update(); diff --git a/src/SalomeApp/SalomeApp_Notebook.h b/src/SalomeApp/SalomeApp_Notebook.h index 08a45ba18..8ffc0f312 100644 --- a/src/SalomeApp/SalomeApp_Notebook.h +++ b/src/SalomeApp/SalomeApp_Notebook.h @@ -49,6 +49,7 @@ public: bool isParameter( const QString& theName ) const; void set( const QString& theName, const QVariant& theValue ); QVariant get( const QString& theName ) const; + QVariant calculate( const QString& theExpr ) const; void update(); @@ -59,9 +60,11 @@ public: protected: QStringList convert( SALOME::StringArray* theArray ) const; + QVariant convert( SALOME::Parameter_ptr theParam ) const; private: SALOME::Notebook_ptr myNotebook; + SALOME::Parameter_ptr myTmp; }; #endif -- 2.39.2