From: asl Date: Tue, 24 Nov 2009 10:19:57 +0000 (+0000) Subject: new methods calculate() - calculation of expressions using Notebook's parameters... X-Git-Tag: PHASE_17_Part1_V1~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=927447f2ef3379740c5435294cc488a2318b6a8d;p=modules%2Fgui.git new methods calculate() - calculation of expressions using Notebook's parameters and convert() - conversion of Notebook's parameter into QVariant --- 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