From: asl Date: Sat, 21 Nov 2009 12:11:14 +0000 (+0000) Subject: Implementation of necessary auxiliary methods X-Git-Tag: PHASE_17_Part1_V1~35 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d57086dbf17c2a3cff39d783e6a57c1ed1fe1a0f;p=modules%2Fkernel.git Implementation of necessary auxiliary methods --- diff --git a/src/Notebook/SALOME_Parameter.cxx b/src/Notebook/SALOME_Parameter.cxx index 04253c23d..aa2cad59a 100644 --- a/src/Notebook/SALOME_Parameter.cxx +++ b/src/Notebook/SALOME_Parameter.cxx @@ -30,15 +30,31 @@ #include #include +SALOME_Parameter::SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theName, bool theValue ) +: myNotebook( theNotebook ), myName( theName ), myResult( theValue ), myIsAnonimous( false ), myIsCalculable( false ) +{ +} + +SALOME_Parameter::SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theName, int theValue ) +: myNotebook( theNotebook ), myName( theName ), myResult( theValue ), myIsAnonimous( false ), myIsCalculable( false ) +{ +} + SALOME_Parameter::SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theName, double theValue ) : myNotebook( theNotebook ), myName( theName ), myResult( theValue ), myIsAnonimous( false ), myIsCalculable( false ) { } -SALOME_Parameter::SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theName, const std::string& theExpr ) -: myNotebook( theNotebook ), myName( theName ), myExpr( theExpr ), myIsAnonimous( false ), myIsCalculable( true ) +SALOME_Parameter::SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theName, const std::string& theData, bool isExpr ) +: myNotebook( theNotebook ), myName( theName ), myIsAnonimous( false ), myIsCalculable( isExpr ) { - Update( SALOME::Notebook_ptr() ); + if( isExpr ) + { + myExpr.setExpression( theData ); + Update( SALOME::Notebook_ptr() ); + } + else + myResult = theData; } SALOME_Parameter::SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theExpr ) @@ -66,6 +82,10 @@ CORBA::Boolean SALOME_Parameter::IsValid() return myResult.isValid(); } +void SALOME_Parameter::SetParameters( SALOME::Notebook_ptr /*theNotebook*/, const SALOME::StringArray& /*theParameters*/ ) +{ +} + void SALOME_Parameter::Update( SALOME::Notebook_ptr /*theNotebook*/ ) { //printf( "Update of %s\n", GetEntry() ); @@ -77,7 +97,7 @@ void SALOME_Parameter::Update( SALOME::Notebook_ptr /*theNotebook*/ ) for( ; it!=last; it++ ) { std::string aName = *it; - SALOME_Parameter* aParam = myNotebook->ParamPtr( const_cast( aName.c_str() ) ); + SALOME_Parameter* aParam = myNotebook->GetParameterPtr( const_cast( aName.c_str() ) ); if( aParam ) { //printf( "\tset %s = %lf\n", aName.c_str(), aParam->AsReal() ); @@ -96,10 +116,10 @@ void SALOME_Parameter::Update( SALOME::Notebook_ptr /*theNotebook*/ ) } } -void SALOME_Parameter::SetExpr( const char* theExpr ) +void SALOME_Parameter::SetExpression( const char* theExpr ) { if( myIsAnonimous ) - myNotebook->AddExpr( theExpr ); + myNotebook->AddExpression( theExpr ); else { @@ -109,6 +129,32 @@ void SALOME_Parameter::SetExpr( const char* theExpr ) } } +void SALOME_Parameter::SetBoolean( CORBA::Boolean theValue ) +{ + if( myIsAnonimous ) + { + } + else + { + myResult = theValue; + myIsCalculable = false; + myNotebook->SetToUpdate( _this() ); + } +} + +void SALOME_Parameter::SetInteger( CORBA::Long theValue ) +{ + if( myIsAnonimous ) + { + } + else + { + myResult = (int)theValue; + myIsCalculable = false; + myNotebook->SetToUpdate( _this() ); + } +} + void SALOME_Parameter::SetReal( CORBA::Double theValue ) { if( myIsAnonimous ) @@ -122,6 +168,19 @@ void SALOME_Parameter::SetReal( CORBA::Double theValue ) } } +void SALOME_Parameter::SetString( const char* theValue ) +{ + if( myIsAnonimous ) + { + } + else + { + myResult = theValue; + myIsCalculable = false; + myNotebook->SetToUpdate( _this() ); + } +} + SALOME::ParamType SALOME_Parameter::GetType() { switch( myResult.type() ) @@ -190,3 +249,18 @@ SALOME_Parameter* SALOME_Parameter::Load( const std::string& theData ) { return 0; } + +bool SALOME_Parameter::IsAnonimous() const +{ + return myIsAnonimous; +} + +bool SALOME_Parameter::IsCalculable() const +{ + return myIsCalculable; +} + +std::string SALOME_Parameter::Expression() const +{ + return myExpr.expression(); +} diff --git a/src/Notebook/SALOME_Parameter.hxx b/src/Notebook/SALOME_Parameter.hxx index fd4ac2124..03efc4a83 100644 --- a/src/Notebook/SALOME_Parameter.hxx +++ b/src/Notebook/SALOME_Parameter.hxx @@ -40,24 +40,27 @@ class SALOME_Parameter : public virtual POA_SALOME::Parameter, public virtual SA { public: //! standard constructor + SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theName, bool theValue ); + SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theName, int theValue ); SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theName, double theValue ); - SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theName, const std::string& theExpr ); + SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theName, const std::string& theData, bool isExpr ); SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theExpr ); //! standard destructor virtual ~SALOME_Parameter(); virtual char* GetEntry(); - virtual char* GetComponent(); - virtual CORBA::Boolean IsValid(); virtual void Update( SALOME::Notebook_ptr theNotebook ); + virtual void SetParameters ( SALOME::Notebook_ptr theNotebook, const SALOME::StringArray& theParameters ); - virtual void SetExpr( const char* theExpr ); - + virtual void SetExpression( const char* theExpr ); + virtual void SetBoolean( CORBA::Boolean theValue ); + virtual void SetInteger( CORBA::Long theValue ); virtual void SetReal( CORBA::Double theValue ); + virtual void SetString( const char* theValue ); virtual SALOME::ParamType GetType(); @@ -71,6 +74,11 @@ public: std::string Save() const; static SALOME_Parameter* Load( const std::string& theData ); + bool IsAnonimous() const; + bool IsCalculable() const; + + std::string Expression() const; + private: SALOME_Notebook* myNotebook; std::string myName;