From 1d552bfd2c0e1b0262a5ea5d0e1dd03b16ea90a8 Mon Sep 17 00:00:00 2001 From: rnv Date: Sat, 1 Nov 2008 12:55:44 +0000 Subject: [PATCH] To show notebook variables in the Object Browser. --- idl/GEOM_Gen.idl | 14 ++++++++++++++ src/GEOM/GEOM_Object.hxx | 9 +++++++++ src/GEOM_I/GEOM_Gen_i.cc | 26 ++++++++++++++++++++++++++ src/GEOM_I/GEOM_I3DPrimOperations_i.cc | 3 ++- src/GEOM_I/GEOM_Object_i.cc | 11 +++++++++++ src/GEOM_I/GEOM_Object_i.hh | 5 +++++ 6 files changed, 67 insertions(+), 1 deletion(-) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 7c2ffe0df..9a8569e61 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -231,6 +231,20 @@ module GEOM * For example, method return false for GEOM_MARKER */ boolean IsShape(); + + + /*! + * Set list of parameters + * \param theParameters is a string containing the notebook variables separated by ":" symbol, + * used for object creation + */ + void SetParameters (in string theParameters); + + /*! + * Return list of notebook variables used for object creation separated by ":" symbol + */ + string GetParameters(); + }; diff --git a/src/GEOM/GEOM_Object.hxx b/src/GEOM/GEOM_Object.hxx index 7d8eda71b..403956933 100644 --- a/src/GEOM/GEOM_Object.hxx +++ b/src/GEOM/GEOM_Object.hxx @@ -219,6 +219,14 @@ class GEOM_Object : public MMgt_TShared //Returns an auxiliary data Standard_EXPORT TCollection_AsciiString GetAuxData(); + //Set a notebook variables used for object creation + Standard_EXPORT void SetParameters(const TCollection_AsciiString& theParameters) + {_parameters = theParameters;} + + //Get a notebook variables used for object creation + Standard_EXPORT TCollection_AsciiString GetParameters() const + {return _parameters;} + //########################################################### // Sub shape methods //########################################################### @@ -270,6 +278,7 @@ class GEOM_Object : public MMgt_TShared Handle(TDataStd_TreeNode) _root; TDF_Label _label; TCollection_AsciiString _ior; + TCollection_AsciiString _parameters; }; #endif diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index 75d163a21..b36a652f7 100644 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -272,6 +272,32 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName"); SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr); aNameAttrib->SetValue(aShapeName.ToCString()); + + //Set NoteBook variables used in the object creation + TCollection_AsciiString aParams(aShape->GetParameters()); + if(!aParams.IsEmpty()) { + TCollection_AsciiString aVars; + int nbVars = 0; + int n = 1; + TCollection_AsciiString aParam = aParams.Token(":",1); + while( aParam.Length() != 0 ) { + aParam = aParams.Token(":",n); + if(theStudy->IsVariable(aParam.ToCString())){ + aVars+=aParam; + nbVars++; + } + if(aParam.Length() == 0) + break; + aVars+=":"; + n++; + } + aVars.Remove(aVars.Length(),1); + if(nbVars > 0 ) { + anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeString"); + SALOMEDS::AttributeString_var aStringAttrib = SALOMEDS::AttributeString::_narrow(anAttr); + aStringAttrib->SetValue(aVars.ToCString()); + } + } //Set a name of the GEOM object aShape->SetName(theName); diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index ae0ba98c6..a455d0f5b 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -68,7 +68,8 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxDXDYDZ (CORBA::Double the Handle(GEOM_Object) anObject = GetOperations()->MakeBoxDXDYDZ(theDX, theDY, theDZ); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); - + GetObject(anObject)->SetParameters(GetParameters()); + return GetObject(anObject); } diff --git a/src/GEOM_I/GEOM_Object_i.cc b/src/GEOM_I/GEOM_Object_i.cc index 4a86443b6..97ad13b5c 100644 --- a/src/GEOM_I/GEOM_Object_i.cc +++ b/src/GEOM_I/GEOM_Object_i.cc @@ -360,3 +360,14 @@ bool GEOM_Object_i::IsShape() { return !_impl->GetValue().IsNull() && _impl->GetType() != GEOM_MARKER; } + +void GEOM_Object_i::SetParameters(const char* theParameters) +{ + _impl->SetParameters((char*)theParameters); +} + +char* GEOM_Object_i::GetParameters() +{ + return CORBA::string_dup(_impl->GetParameters().ToCString()); +} + diff --git a/src/GEOM_I/GEOM_Object_i.hh b/src/GEOM_I/GEOM_Object_i.hh index 56631b7f0..4325622a2 100644 --- a/src/GEOM_I/GEOM_Object_i.hh +++ b/src/GEOM_I/GEOM_Object_i.hh @@ -81,11 +81,16 @@ class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public virtual bool IsShape(); + virtual void SetParameters(const char* theParameters); + + virtual char* GetParameters(); + Handle(GEOM_Object) GetImpl() { return _impl; } private: GEOM::GEOM_Gen_var _engine; + TCollection_AsciiString _parameters; Handle(GEOM_Object) _impl; TopoDS_Shape _geom; }; -- 2.39.2