interface ChildIterator;
interface Driver;
interface AttributeStudyProperties;
+ interface AttributeParameter;
interface UseCaseIterator;
interface UseCaseBuilder;
boolean DumpStudy(in string thePath, in string theBaseName, in boolean isPublished);
+/*!
+ Returns an AttributeParameter used to store common parameters for given %theSavePoint.
+ \param theID identifies a common parameters set (Example: "Interface Applicative")
+ \param theSavePoint is number of a set of parameters as there can be several sets
+*/
+ AttributeParameter GetCommonParameters(in string theID, in long theSavePoint);
+
+/*!
+ Returns an AttributeParameter used to store parameters for given %theModuleName.
+ \param theID identifies a common parameters set (Example: "Interface Applicative")
+ \param theModuleName is a name of the module (Example: "Geometry")
+ \param theSavePoint is number of a set of parameters as there can be several sets
+*/
+ AttributeParameter GetModuleParameters(in string theID, in string theModuleName, in long theSavePoint);
+
+
+/*!
+ Returns a default Python script to restore visual parameters for given %theModuleName.
+ \param theID identifies a common parameters set (Example: "Interface Applicative")
+ \param theModuleName is a name of the module (Example: "Geometry")
+*/
+ string GetDefaultScript(in string theID, in string theModuleName);
+
/*!
Private method, returns an implementation of this Study.
\param theHostname is a hostname of the caller
*/
boolean IsScript();
};
+ //==========================================================================
+/*! \brief %AttributeParameter interface
+
+ Attribute is a universal container of basic types
+*/
+ //==========================================================================
+ interface AttributeParameter : GenericAttribute
+ {
+/*!
+ Associates a integer value with the ID
+ \param theID An ID of a parameter.
+ \param theValue A value of the parameter
+*/
+ void SetInt(in string theID, in long theValue);
+/*!
+ Returns a int value associated with the given ID
+ \param theID An ID of a parameter.
+*/
+ long GetInt(in string theID);
+
+/*!
+ Associates a real value with the ID
+ \param theID An ID of a parameter.
+ \param theValue A value of the parameter
+*/
+ void SetReal(in string theID, in double theValue);
+/*!
+ Returns a real value associated with the given ID
+ \param theID An ID of a parameter.
+*/
+ double GetReal(in string theID);
+
+/*!
+ Associates a string value with the ID
+ \param theID An ID of a parameter.
+ \param theValue A value of the parameter
+*/
+ void SetString(in string theID, in string theValue);
+/*!
+ Returns a string value associated with the given ID
+ \param theID An ID of a parameter.
+*/
+ string GetString(in string theID);
+
+/*!
+ Associates a boolean value with the ID
+ \param theID An ID of a parameter.
+ \param theValue A value of the parameter
+*/
+ void SetBool(in string theID, in boolean theValue);
+/*!
+ Returns a boolean value associated with the given ID
+ \param theID An ID of a parameter.
+*/
+ boolean GetBool(in string theID);
+
+/*!
+ Associates an array of real values with the ID
+ \param theID An ID of a parameter.
+ \param theArray The array of real values
+*/
+ void SetRealArray(in string theID, in DoubleSeq theArray);
+/*!
+ Returns an array of real values associated with the ID
+ \param theID An ID of a parameter.
+*/
+ DoubleSeq GetRealArray(in string theID);
+
+/*!
+ Associates an array of integer values with the ID
+ \param theID An ID of a parameter.
+ \param theArray The array of integer values
+*/
+ void SetIntArray(in string theID, in LongSeq theArray);
+/*!
+ Returns an array of integer values associated with the ID
+ \param theID An ID of a parameter.
+*/
+ LongSeq GetIntArray(in string theID);
+
+/*!
+ Associates an array of string values with the ID
+ \param theID An ID of a parameter.
+ \param theArray The array of string values
+*/
+ void SetStrArray(in string theID, in StringSeq theArray);
+/*!
+ Returns an array of string values associated with the ID
+ \param theID An ID of a parameter.
+*/
+ StringSeq GetStrArray(in string theID);
+/*!
+ Returns True if for the ID of given type was assigned a value in the attribute
+ \param theID An ID of a parameter.
+ \param theType A type of parameter [0(Int), 1(Real), 2(Boolean), 3(String), 4(RealArray), 5(IntArray), 6(StrArray)].
+*/
+ boolean IsSet(in string theID, in long theType);
+/*!
+ Removes a parameter with given ID and Type, returns True if succeded
+ \param theID An ID of a parameter.
+ \param theType A type of parameter [0(Int), 1(Real), 2(Boolean), 3(String), 4(RealArray), 5(IntArray), 6(StrArray)].
+*/
+ boolean RemoveID(in string theID, in long theType);
+/*!
+ Returns a father attribute of this attribute
+*/
+ AttributeParameter GetFather();
+/*!
+ Returns True if this attribute has a father attribute
+*/
+ boolean HasFather();
+/*!
+ Returns True if this attribute is a root attribute
+*/
+ boolean IsRoot();
+/*!
+ Clears the content of the attribute
+*/
+ void Clear();
+/*!
+ Returns a sequence of ID's of the give type
+ \param theType A type of parameter [0(Int), 1(Real), 2(Boolean), 3(String), 4(RealArray), 5(IntArray), 6(StrArray)].
+ */
+ StringSeq GetIDs(in long theType);
+ };
};
#endif
SALOMEDS_SComponent_i.hxx \
SALOMEDS_SComponent.hxx \
SALOMEDS_GenericAttribute_i.hxx \
- SALOMEDS_GenericAttribute.hxx
+ SALOMEDS_GenericAttribute.hxx \
+ SALOMEDS_IParameters.hxx
# Libraries targets
SALOMEDS_AttributeTableOfString_i.cxx \
SALOMEDS_AttributeStudyProperties_i.cxx \
SALOMEDS_AttributePythonObject_i.cxx \
+ SALOMEDS_AttributeParameter_i.cxx \
SALOMEDS_SObject.cxx \
SALOMEDS_SComponent.cxx \
SALOMEDS_GenericAttribute.cxx \
SALOMEDS_AttributeTextHighlightColor.cxx \
SALOMEDS_AttributeTreeNode.cxx \
SALOMEDS_AttributeUserID.cxx \
- SALOMEDS_TMPFile_i.cxx
+ SALOMEDS_TMPFile_i.cxx \
+ SALOMEDS_AttributeParameter.cxx \
+ SALOMEDS_IParameters.cxx
# Executables targets
BIN = SALOMEDS_Server SALOMEDS_Client
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+// File : SALOMEDS_AttributeParameter.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#include "SALOMEDS_AttributeParameter.hxx"
+#include "SALOMEDS.hxx"
+
+#include <string>
+#include <TCollection_AsciiString.hxx>
+
+//=======================================================================
+/*!
+ * Function : Constructor
+ * Purpose : Creates a new instance of SALOMEDS_AttributeParameter
+ */
+//=======================================================================
+SALOMEDS_AttributeParameter::SALOMEDS_AttributeParameter(const Handle(SALOMEDSImpl_AttributeParameter)& theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+//=======================================================================
+/*!
+ * Function : Constructor
+ * Purpose : Creates a new instance of SALOMEDS_AttributeParameter
+ */
+//=======================================================================
+SALOMEDS_AttributeParameter::SALOMEDS_AttributeParameter(SALOMEDS::AttributeParameter_ptr theAttr)
+:SALOMEDS_GenericAttribute(theAttr)
+{}
+
+//=======================================================================
+/*!
+ * Function : Destructor
+ * Purpose : Destroys the instance of SALOMEDS_AttributeParameter
+ */
+//=======================================================================
+SALOMEDS_AttributeParameter::~SALOMEDS_AttributeParameter()
+{}
+
+//=======================================================================
+/*!
+ * Function : SetInt
+ * Purpose : Associates a integer value with the ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter::SetInt(const string& theID, const int theValue)
+{
+ CheckLocked();
+
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->SetInt(theID, theValue);
+ }
+ else
+ SALOMEDS::AttributeParameter::_narrow(_corba_impl)->SetInt(theID.c_str(), theValue);
+}
+
+//=======================================================================
+/*!
+ * Function : GetInt
+ * Purpose : Returns a int value associated with the given ID
+ */
+//=======================================================================
+int SALOMEDS_AttributeParameter::GetInt(const string& theID)
+{
+ int aValue;
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ aValue = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->GetInt(theID);
+ }
+ else
+ aValue = SALOMEDS::AttributeParameter::_narrow(_corba_impl)->GetInt(theID.c_str());
+ return aValue;
+}
+
+//=======================================================================
+/*!
+ * Function : SetReal
+ * Purpose : Associates a double value with the ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter::SetReal(const string& theID, const double& theValue)
+{
+ CheckLocked();
+
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->SetReal(theID, theValue);
+ }
+ else
+ SALOMEDS::AttributeParameter::_narrow(_corba_impl)->SetReal(theID.c_str(), theValue);
+}
+
+//=======================================================================
+/*!
+ * Function : GetReal
+ * Purpose : Returns a double value associated with the given ID
+ */
+//=======================================================================
+double SALOMEDS_AttributeParameter::GetReal(const string& theID)
+{
+ double aValue;
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ aValue = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->GetReal(theID);
+ }
+ else
+ aValue = SALOMEDS::AttributeParameter::_narrow(_corba_impl)->GetReal(theID.c_str());
+ return aValue;
+}
+
+//=======================================================================
+/*!
+ * Function : SetString
+ * Purpose : Associates a string with the ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter::SetString(const string& theID, const string& theValue)
+{
+ CheckLocked();
+
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->SetString(theID, theValue);
+ }
+ else
+ SALOMEDS::AttributeParameter::_narrow(_corba_impl)->SetString(theID.c_str(), theValue.c_str());
+}
+
+//=======================================================================
+/*!
+ * Function : GetString
+ * Purpose : Returns a string associated with the given ID
+ */
+//=======================================================================
+string SALOMEDS_AttributeParameter::GetString(const string& theID)
+{
+ string aValue;
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ aValue = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->GetString(theID);
+ }
+ else
+ aValue = SALOMEDS::AttributeParameter::_narrow(_corba_impl)->GetString(theID.c_str());
+ return aValue;
+}
+
+//=======================================================================
+/*!
+ * Function : SetBool
+ * Purpose : Associates a bool value with the ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter::SetBool(const string& theID, const bool& theValue)
+{
+ CheckLocked();
+
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->SetBool(theID, theValue);
+ }
+ else
+ SALOMEDS::AttributeParameter::_narrow(_corba_impl)->SetBool(theID.c_str(), theValue);
+}
+
+//=======================================================================
+/*!
+ * Function : GetBool
+ * Purpose : Returns a bool value associated with the ID
+ */
+//=======================================================================
+bool SALOMEDS_AttributeParameter::GetBool(const string& theID)
+{
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->GetBool(theID);
+ }
+ else
+ return SALOMEDS::AttributeParameter::_narrow(_corba_impl)->GetBool(theID.c_str());
+}
+
+//=======================================================================
+/*!
+ * Function : SetRealArray
+ * Purpose : Associates an array of double values with the given ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter::SetRealArray(const string& theID, const vector<double>& theArray)
+{
+ CheckLocked();
+
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->SetRealArray(theID, theArray);
+ }
+ else {
+ SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq;
+ int length = theArray.size();
+ if(length) {
+ aSeq->length(length);
+ for(int i = 0; i<length; i++) aSeq[i] = theArray[i];
+ }
+ SALOMEDS::AttributeParameter::_narrow(_corba_impl)->SetRealArray(theID.c_str(), aSeq);
+ }
+}
+
+//=======================================================================
+/*!
+ * Function : GetRealArray
+ * Purpose : Returns an array of double values associated with the ID
+ */
+//=======================================================================
+vector<double> SALOMEDS_AttributeParameter::GetRealArray(const string& theID)
+{
+ vector<double> v;
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->GetRealArray(theID);
+ }
+ else {
+ SALOMEDS::DoubleSeq_var aSeq = SALOMEDS::AttributeParameter::_narrow(_corba_impl)->GetRealArray(theID.c_str());
+ int length = aSeq->length();
+ if(length) {
+ v.resize(length);
+ for(int i = 0; i < length; i++) v[i] = aSeq[i];
+ }
+ }
+ return v;
+}
+
+//=======================================================================
+/*!
+ * Function : SetIntArray
+ * Purpose : Associates an array of int values with the given ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter::SetIntArray(const string& theID, const vector<int>& theArray)
+{
+ CheckLocked();
+
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->SetIntArray(theID, theArray);
+ }
+ else {
+ SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq;
+ int length = theArray.size();
+ if(length) {
+ aSeq->length(length);
+ for(int i = 0; i<length; i++) aSeq[i] = theArray[i];
+ }
+ SALOMEDS::AttributeParameter::_narrow(_corba_impl)->SetIntArray(theID.c_str(), aSeq);
+ }
+}
+
+//=======================================================================
+/*!
+ * Function : GetIntArray
+ * Purpose : Returns an array of int values associated with the ID
+ */
+//=======================================================================
+vector<int> SALOMEDS_AttributeParameter::GetIntArray(const string& theID)
+{
+ vector<int> v;
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->GetIntArray(theID);
+ }
+ else {
+ SALOMEDS::LongSeq_var aSeq = SALOMEDS::AttributeParameter::_narrow(_corba_impl)->GetIntArray(theID.c_str());
+ int length = aSeq->length();
+ if(length) {
+ v.resize(length);
+ for(int i = 0; i < length; i++) v[i] = aSeq[i];
+ }
+ }
+ return v;
+}
+
+//=======================================================================
+/*!
+ * Function : SetStrArray
+ * Purpose : Associates an array of string values with the given ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter::SetStrArray(const string& theID, const vector<string>& theArray)
+{
+ CheckLocked();
+
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->SetStrArray(theID, theArray);
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq;
+ int length = theArray.size();
+ if(length) {
+ aSeq->length(length);
+ for(int i = 0; i<length; i++) aSeq[i] = CORBA::string_dup(theArray[i].c_str());
+ }
+ SALOMEDS::AttributeParameter::_narrow(_corba_impl)->SetStrArray(theID.c_str(), aSeq);
+ }
+}
+
+//=======================================================================
+/*!
+ * Function : GetStrArray
+ * Purpose : Returns an array of string values associated with the ID
+ */
+//=======================================================================
+vector<string> SALOMEDS_AttributeParameter::GetStrArray(const string& theID)
+{
+ vector<string> v;
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->GetStrArray(theID);
+ }
+ else {
+ SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeParameter::_narrow(_corba_impl)->GetStrArray(theID.c_str());
+ int length = aSeq->length();
+ if(length) {
+ v.resize(length);
+ for(int i = 0; i < length; i++) v[i] = string(aSeq[i].in());
+ }
+ }
+ return v;
+}
+
+
+//=======================================================================
+/*!
+ * Function : IsSet
+ * Purpose : Returns true if for the ID of given type was assigned \n
+ * a value in the attribute
+ */
+//=======================================================================
+bool SALOMEDS_AttributeParameter::IsSet(const string& theID, const int theType)
+{
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->IsSet(theID, (Parameter_Types)theType);
+ }
+ else
+ return SALOMEDS::AttributeParameter::_narrow(_corba_impl)->IsSet(theID.c_str(), theType);
+}
+
+//=======================================================================
+/*!
+ * Function : RemoveID
+ * Purpose : Removes a parameter with given ID
+ */
+//=======================================================================
+bool SALOMEDS_AttributeParameter::RemoveID(const string& theID, const int theType)
+{
+ CheckLocked();
+
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->RemoveID(theID, (Parameter_Types)theType);
+ }
+ else
+ return SALOMEDS::AttributeParameter::_narrow(_corba_impl)->RemoveID(theID.c_str(), theType);
+}
+
+//=======================================================================
+/*!
+ * Function : GetFather
+ * Purpose : Returns a father attribute for this attribute
+ */
+//=======================================================================
+_PTR(AttributeParameter) SALOMEDS_AttributeParameter::GetFather()
+{
+ SALOMEDSClient_AttributeParameter* AP = NULL;
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter) AP_impl = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->GetFather();
+ if(AP_impl.IsNull()) return _PTR(AttributeParameter)(AP);
+ AP = new SALOMEDS_AttributeParameter(AP_impl);
+ }
+ else {
+ SALOMEDS::AttributeParameter_var AP_impl = SALOMEDS::AttributeParameter::_narrow(_corba_impl)->GetFather();
+ if(CORBA::is_nil(AP_impl)) return _PTR(AttributeParameter)(AP);
+ AP = new SALOMEDS_AttributeParameter(AP_impl);
+ }
+
+ return _PTR(AttributeParameter)(AP);
+}
+
+//=======================================================================
+/*!
+ * Function : HasFather
+ * Purpose : Returns True if the attribute has a father attribute
+ */
+//=======================================================================
+bool SALOMEDS_AttributeParameter::HasFather()
+{
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->HasFather();
+ }
+ else
+ return SALOMEDS::AttributeParameter::_narrow(_corba_impl)->HasFather();
+}
+
+//=======================================================================
+/*!
+ * Function : IsRoot
+ * Purpose : Returns True is the attribute is highest in an hierachy
+ */
+//=======================================================================
+bool SALOMEDS_AttributeParameter::IsRoot()
+{
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->IsRoot();
+ }
+ else
+ return SALOMEDS::AttributeParameter::_narrow(_corba_impl)->IsRoot();
+}
+
+//=======================================================================
+/*!
+ * Function : Clear
+ * Purpose : Clears the content of the attribute
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter::Clear()
+{
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl)->Clear();
+ }
+ else
+ SALOMEDS::AttributeParameter::_narrow(_corba_impl)->Clear();
+}
+
+//=======================================================================
+/*!
+ * Function : GetIDs
+ * Purpose : Returns an array of all ID's of the given type
+ */
+//=======================================================================
+vector<string> SALOMEDS_AttributeParameter::GetIDs(const int theType)
+{
+ vector<string> v;
+ if(_isLocal) {
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter) AP_impl = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_local_impl);
+ return AP_impl->GetIDs((Parameter_Types)theType);
+ }
+ else {
+ SALOMEDS::AttributeParameter_var AP_impl = SALOMEDS::AttributeParameter::_narrow(_corba_impl);
+ SALOMEDS::StringSeq_var CorbaSeq = AP_impl->GetIDs(theType);
+ int length = CorbaSeq->length();
+ if(length) {
+ v.resize(length);
+ for(int i = 0; i <length; i++) v[i] = string(CorbaSeq[i].in());
+ }
+ }
+
+ return v;
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+// File : SALOMEDS_AttributeParameter.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef SALOMEDS_AttributeParameter_HeaderFile
+#define SALOMEDS_AttributeParameter_HeaderFile
+
+#include "SALOMEDSClient_AttributeParameter.hxx"
+#include "SALOMEDS_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeParameter.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class SALOMEDS_AttributeParameter: public SALOMEDS_GenericAttribute, public SALOMEDSClient_AttributeParameter
+{
+public:
+ SALOMEDS_AttributeParameter(const Handle(SALOMEDSImpl_AttributeParameter)& theAttr);
+ SALOMEDS_AttributeParameter(SALOMEDS::AttributeParameter_ptr theAttr);
+ ~SALOMEDS_AttributeParameter();
+
+ virtual void SetInt(const std::string& theID, const int theValue);
+ virtual int GetInt(const std::string& theID);
+
+ virtual void SetReal(const std::string& theID, const double& theValue);
+ virtual double GetReal(const std::string& theID);
+
+ virtual void SetString(const std::string& theID, const std::string& theValue);
+ virtual std::string GetString(const std::string& theID);
+
+ virtual void SetBool(const std::string& theID, const bool& theValue);
+ virtual bool GetBool(const std::string& theID);
+
+ virtual void SetRealArray(const std::string& theID, const std::vector<double>& theArray);
+ virtual std::vector<double> GetRealArray(const std::string& theID);
+
+ virtual void SetIntArray(const std::string& theID, const std::vector<int>& theArray);
+ virtual std::vector<int> GetIntArray(const std::string& theID);
+
+ virtual void SetStrArray(const std::string& theID, const std::vector<std::string>& theArray);
+ virtual std::vector<std::string> GetStrArray(const std::string& theID);
+
+ virtual bool IsSet(const std::string& theID, const int theType);
+
+ virtual bool RemoveID(const std::string& theID, const int theType);
+
+ virtual _PTR(AttributeParameter) GetFather();
+ virtual bool HasFather();
+ virtual bool IsRoot();
+
+ virtual void Clear();
+
+ virtual std::vector<std::string> GetIDs(const int theType);
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+// File : SALOMEDS_AttributeParameter_i.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+
+#include "SALOMEDS_AttributeParameter_i.hxx"
+#include "SALOMEDS.hxx"
+#include <TCollection_AsciiString.hxx>
+
+#include <vector>
+
+using namespace std;
+
+//=======================================================================
+/*!
+ * Function : SetInt
+ * Purpose : Associates a integer value with the ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter_i::SetInt(const char* theID, CORBA::Long theValue)
+{
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetInt(theID, theValue);
+}
+
+//=======================================================================
+/*!
+ * Function : GetInt
+ * Purpose : Returns a int value associated with the given ID
+ */
+//=======================================================================
+CORBA::Long SALOMEDS_AttributeParameter_i::GetInt(const char* theID)
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetInt(theID);
+}
+
+//=======================================================================
+/*!
+ * Function : SetReal
+ * Purpose : Associates a double value with the ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter_i::SetReal(const char* theID, const CORBA::Double theValue)
+{
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetReal(theID, theValue);
+}
+
+//=======================================================================
+/*!
+ * Function : GetReal
+ * Purpose : Returns a double value associated with the given ID
+ */
+//=======================================================================
+CORBA::Double SALOMEDS_AttributeParameter_i::GetReal(const char* theID)
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetReal(theID);
+}
+
+//=======================================================================
+/*!
+ * Function : SetString
+ * Purpose : Associates a string with the ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter_i::SetString(const char* theID, const char* theValue)
+{
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ Handle(SALOMEDSImpl_AttributeParameter) impl = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl);
+ impl->SetString(theID, theValue);
+}
+
+//=======================================================================
+/*!
+ * Function : GetString
+ * Purpose : Returns a string associated with the given ID
+ */
+//=======================================================================
+char* SALOMEDS_AttributeParameter_i::GetString(const char* theID)
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter) impl = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl);
+ CORBA::String_var c_s = CORBA::string_dup(impl->GetString(theID).c_str());
+ return c_s._retn();
+}
+
+//=======================================================================
+/*!
+ * Function : SetBool
+ * Purpose : Associates a bool value with the ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter_i::SetBool(const char* theID, CORBA::Boolean theValue)
+{
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetBool(theID, theValue);
+}
+
+//=======================================================================
+/*!
+ * Function : GetBool
+ * Purpose : Returns a bool value associated with the ID
+ */
+//=======================================================================
+CORBA::Boolean SALOMEDS_AttributeParameter_i::GetBool(const char* theID)
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetBool(theID);
+}
+
+//=======================================================================
+/*!
+ * Function : SetRealArray
+ * Purpose : Associates an array of double values with the given ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter_i::SetRealArray(const char* theID, const SALOMEDS::DoubleSeq& theArray)
+{
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ vector<double> v;
+ int length = theArray.length();
+ if(length) {
+ v.resize(length);
+ for(int i = 0; i<length; i++) v[i] = theArray[i];
+ }
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetRealArray(theID, v);
+}
+
+//=======================================================================
+/*!
+ * Function : GetRealArray
+ * Purpose : Returns an array of double values associated with the ID
+ */
+//=======================================================================
+SALOMEDS::DoubleSeq* SALOMEDS_AttributeParameter_i::GetRealArray(const char* theID)
+{
+ SALOMEDS::Locker lock;
+ SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq;
+ vector<double> v = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetRealArray(theID);
+ int length = v.size();
+ if(length) {
+ aSeq->length(length);
+ for(int i = 0; i<length; i++) aSeq[i] = v[i];
+ }
+ return aSeq._retn();
+}
+
+//=======================================================================
+/*!
+ * Function : SetIntArray
+ * Purpose : Associates an array of int values with the given ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter_i::SetIntArray(const char* theID, const SALOMEDS::LongSeq& theArray)
+{
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ vector<int> v;
+ int length = theArray.length();
+ if(length) {
+ v.resize(length);
+ for(int i = 0; i<length; i++) v[i] = theArray[i];
+ }
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetIntArray(theID, v);
+}
+
+//=======================================================================
+/*!
+ * Function : GetIntArray
+ * Purpose : Returns an array of int values associated with the ID
+ */
+//=======================================================================
+SALOMEDS::LongSeq* SALOMEDS_AttributeParameter_i::GetIntArray(const char* theID)
+{
+ SALOMEDS::Locker lock;
+ SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq;
+ vector<int> v = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetIntArray(theID);
+ int length = v.size();
+ if(length) {
+ aSeq->length(length);
+ for(int i = 0; i<length; i++) aSeq[i] = v[i];
+ }
+ return aSeq._retn();
+}
+
+//=======================================================================
+/*!
+ * Function : SetStrArray
+ * Purpose : Associates an array of string values with the given ID
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter_i::SetStrArray(const char* theID, const SALOMEDS::StringSeq& theArray)
+{
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ vector<string> v;
+ int length = theArray.length();
+ if(length) {
+ v.resize(length);
+ for(int i = 0; i<length; i++) v[i] = string(theArray[i].in());
+ }
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetStrArray(theID, v);
+}
+
+//=======================================================================
+/*!
+ * Function : GetStrArray
+ * Purpose : Returns an array of string values associated with the ID
+ */
+//=======================================================================
+SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetStrArray(const char* theID)
+{
+ SALOMEDS::Locker lock;
+ SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq;
+ vector<string> v = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetStrArray(theID);
+ int length = v.size();
+ if(length) {
+ aSeq->length(length);
+ for(int i = 0; i<length; i++) aSeq[i] = CORBA::string_dup(v[i].c_str());
+ }
+ return aSeq._retn();
+}
+
+
+//=======================================================================
+/*!
+ * Function : IsSet
+ * Purpose : Returns true if for the ID of given type was assigned \n
+ * a value in the attribute
+ */
+//=======================================================================
+CORBA::Boolean SALOMEDS_AttributeParameter_i::IsSet(const char* theID, CORBA::Long theType)
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->IsSet(theID, (Parameter_Types)theType);
+}
+
+//=======================================================================
+/*!
+ * Function : RemoveID
+ * Purpose : Removes a parameter with given ID
+ */
+//=======================================================================
+CORBA::Boolean SALOMEDS_AttributeParameter_i::RemoveID(const char* theID, CORBA::Long theType)
+{
+ SALOMEDS::Locker lock;
+ CheckLocked();
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->RemoveID(theID, (Parameter_Types)theType);
+}
+
+//=======================================================================
+/*!
+ * Function : GetFather
+ * Purpose : Returns a father attribute for this attribute
+ */
+//=======================================================================
+SALOMEDS::AttributeParameter_ptr SALOMEDS_AttributeParameter_i::GetFather()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter) impl = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl);
+ SALOMEDS_AttributeParameter_i* attr = new SALOMEDS_AttributeParameter_i(impl, _orb);
+ return attr->AttributeParameter::_this();
+}
+
+//=======================================================================
+/*!
+ * Function : HasFather
+ * Purpose : Returns True if the attribute has a father attribute
+ */
+//=======================================================================
+CORBA::Boolean SALOMEDS_AttributeParameter_i::HasFather()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->HasFather();
+}
+
+//=======================================================================
+/*!
+ * Function : IsRoot
+ * Purpose : Returns True is the attribute is highest in an hierachy
+ */
+//=======================================================================
+CORBA::Boolean SALOMEDS_AttributeParameter_i::IsRoot()
+{
+ SALOMEDS::Locker lock;
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->IsRoot();
+}
+
+//=======================================================================
+/*!
+ * Function : IsRoot
+ * Purpose : Clears the content of the attribute
+ */
+//=======================================================================
+void SALOMEDS_AttributeParameter_i::Clear()
+{
+ SALOMEDS::Locker lock;
+ Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->Clear();
+}
+
+
+//=======================================================================
+/*!
+ * Function : GetIDs
+ * Purpose : Returns an array of all ID's of the given type
+ */
+//=======================================================================
+SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetIDs(CORBA::Long theType)
+{
+ SALOMEDS::Locker lock;
+ SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
+ vector<string> A = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetIDs((Parameter_Types)theType);
+
+ if(A.size()) {
+ int length = A.size();
+ CorbaSeq->length(length);
+ for (int i = 0; i < length; i++) CorbaSeq[i] = CORBA::string_dup(A[i].c_str());;
+ }
+
+ return CorbaSeq._retn();
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+// File : SALOMEDS_AttributeParameter_i.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+// $Header:
+
+#ifndef SALOMEDS_AttributeParameter_i_HeaderFile
+#define SALOMEDS_AttributeParameter_i_HeaderFile
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDSImpl_AttributeParameter.hxx"
+
+/*!
+ Class: SALOMEDS_AttributeParameter
+ Description : AttributeParameter is a universal container of basic types
+*/
+
+class SALOMEDS_AttributeParameter_i: public virtual POA_SALOMEDS::AttributeParameter,
+ public virtual SALOMEDS_GenericAttribute_i
+{
+public:
+
+ SALOMEDS_AttributeParameter_i(const Handle(SALOMEDSImpl_AttributeParameter)& theAttr, CORBA::ORB_ptr orb)
+ :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
+ ~SALOMEDS_AttributeParameter_i() {};
+
+
+ virtual void SetInt(const char* theID, CORBA::Long theValue);
+ virtual CORBA::Long GetInt(const char* theID);
+
+ virtual void SetReal(const char* theID, const CORBA::Double theValue);
+ virtual CORBA::Double GetReal(const char* theID);
+
+ virtual void SetString(const char* theID, const char* theValue);
+ virtual char* GetString(const char* theID);
+
+ virtual void SetBool(const char* theID, CORBA::Boolean theValue);
+ virtual CORBA::Boolean GetBool(const char* theID);
+
+ virtual void SetRealArray(const char* theID, const SALOMEDS::DoubleSeq& theArray);
+ virtual SALOMEDS::DoubleSeq* GetRealArray(const char* theID);
+
+ virtual void SetIntArray(const char* theID, const SALOMEDS::LongSeq& theArray);
+ virtual SALOMEDS::LongSeq* GetIntArray(const char* theID);
+
+ virtual void SetStrArray(const char* theID, const SALOMEDS::StringSeq& theArray);
+ virtual SALOMEDS::StringSeq* GetStrArray(const char* theID);
+
+ virtual CORBA::Boolean IsSet(const char* theID, CORBA::Long theType);
+
+ virtual CORBA::Boolean RemoveID(const char* theID, CORBA::Long theType);
+
+ virtual SALOMEDS::AttributeParameter_ptr GetFather();
+ virtual CORBA::Boolean HasFather();
+ virtual CORBA::Boolean IsRoot();
+
+ virtual void Clear();
+
+ virtual SALOMEDS::StringSeq* GetIDs(CORBA::Long theType);
+
+};
+
+
+
+
+#endif
#include "SALOMEDSImpl_AttributeFileType.hxx"
#include "SALOMEDSImpl_AttributeFlags.hxx"
#include "SALOMEDSImpl_AttributeGraphic.hxx"
+#include "SALOMEDSImpl_AttributeParameter.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
#include "SALOMEDS_AttributeName_i.hxx"
#include "SALOMEDS_AttributeFileType_i.hxx"
#include "SALOMEDS_AttributeFlags_i.hxx"
#include "SALOMEDS_AttributeGraphic_i.hxx"
+#include "SALOMEDS_AttributeParameter_i.hxx"
#define __CreateCORBAAttribute(CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
Handle(SALOMEDSImpl_##CORBA_Name) A = Handle(SALOMEDSImpl_##CORBA_Name)::DownCast(theAttr); \
__CreateCORBAAttribute(AttributeFlags) \
__CreateCORBAAttribute(AttributeGraphic) \
__CreateCORBAAttribute(AttributeTreeNode) \
-__CreateCORBAAttribute(AttributeUserID)
+__CreateCORBAAttribute(AttributeUserID) \
+__CreateCORBAAttribute(AttributeParameter)
#endif
#include "SALOMEDSImpl_AttributeFileType.hxx"
#include "SALOMEDSImpl_AttributeFlags.hxx"
#include "SALOMEDSImpl_AttributeGraphic.hxx"
+#include "SALOMEDSImpl_AttributeParameter.hxx"
#include "SALOMEDS_GenericAttribute.hxx"
#include "SALOMEDS_AttributeName.hxx"
#include "SALOMEDS_AttributeFileType.hxx"
#include "SALOMEDS_AttributeFlags.hxx"
#include "SALOMEDS_AttributeGraphic.hxx"
+#include "SALOMEDS_AttributeParameter.hxx"
#define __CreateClientAttributeLocal(CORBA_Name) if (strcmp(aTypeOfAttribute.c_str(), #CORBA_Name) == 0) { \
Handle(SALOMEDSImpl_##CORBA_Name) A = Handle(SALOMEDSImpl_##CORBA_Name)::DownCast(theGA); \
__CreateClientAttributeLocal(AttributeFlags) \
__CreateClientAttributeLocal(AttributeGraphic) \
__CreateClientAttributeLocal(AttributeTreeNode) \
-__CreateClientAttributeLocal(AttributeUserID)
+__CreateClientAttributeLocal(AttributeUserID) \
+__CreateClientAttributeLocal(AttributeParameter)
#define __CreateGenericClientAttributeCORBA \
__CreateClientAttributeCORBA(AttributeReal) \
__CreateClientAttributeCORBA(AttributeFlags) \
__CreateClientAttributeCORBA(AttributeGraphic) \
__CreateClientAttributeCORBA(AttributeTreeNode) \
-__CreateClientAttributeCORBA(AttributeUserID)
+__CreateClientAttributeCORBA(AttributeUserID) \
+__CreateClientAttributeCORBA(AttributeParameter)
#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+#include "SALOMEDS_IParameters.hxx"
+#include <utilities.h>
+
+#include <TCollection_AsciiString.hxx>
+
+using namespace std;
+
+#define PT_INTEGER 0
+#define PT_REAL 1
+#define PT_BOOLEAN 2
+#define PT_STRING 3
+#define PT_REALARRAY 4
+#define PT_INTARRAY 5
+#define PT_STRARRAY 6
+
+#define _AP_LISTS_LIST_ "AP_LISTS_LIST"
+#define _AP_ENTRIES_LIST_ "AP_ENTRIES_LIST"
+#define _AP_PROPERTIES_LIST_ "AP_PROPERTIES_LIST"
+#define _AP_DUMP_PYTHON_ "AP_DUMP_PYTHON"
+
+/*!
+ Constructor
+*/
+SALOMEDS_IParameters::SALOMEDS_IParameters(const _PTR(AttributeParameter)& ap)
+{
+ if(!ap) return;
+ _ap = ap;
+ _PTR(SObject) so = _ap->GetSObject();
+ _study = so->GetStudy();
+}
+
+SALOMEDS_IParameters::~SALOMEDS_IParameters()
+{
+ _compNames.clear();
+}
+
+int SALOMEDS_IParameters::append(const string& listName, const string& value)
+{
+ if(!_ap) return -1;
+ vector<string> v;
+ if(!_ap->IsSet(listName, PT_STRARRAY)) {
+ if(!_ap->IsSet(_AP_LISTS_LIST_, PT_STRARRAY)) _ap->SetStrArray(_AP_LISTS_LIST_, v);
+ if(listName != _AP_ENTRIES_LIST_ &&
+ listName != _AP_PROPERTIES_LIST_) {
+ append(_AP_LISTS_LIST_, listName);
+ }
+ _ap->SetStrArray(listName, v);
+ }
+ v = _ap->GetStrArray(listName);
+ v.push_back(value);
+ _ap->SetStrArray(listName, v);
+ return (v.size()-1);
+}
+
+int SALOMEDS_IParameters::nbValues(const string& listName)
+{
+ if(!_ap) return -1;
+ if(!_ap->IsSet(listName, PT_STRARRAY)) return 0;
+ vector<string> v = _ap->GetStrArray(listName);
+ return v.size();
+}
+
+vector<string> SALOMEDS_IParameters::getValues(const string& listName)
+{
+ vector<string> v;
+ if(!_ap) return v;
+ if(!_ap->IsSet(listName, PT_STRARRAY)) return v;
+ return _ap->GetStrArray(listName);
+}
+
+
+string SALOMEDS_IParameters::getValue(const string& listName, int index)
+{
+ if(!_ap) return "";
+ if(!_ap->IsSet(listName, PT_STRARRAY)) return "";
+ vector<string> v = _ap->GetStrArray(listName);
+ if(index >= v.size()) return "";
+ return v[index];
+}
+
+vector<string> SALOMEDS_IParameters::getLists()
+{
+ vector<string> v;
+ if(!_ap->IsSet(_AP_LISTS_LIST_, PT_STRARRAY)) return v;
+ return _ap->GetStrArray(_AP_LISTS_LIST_);
+}
+
+void SALOMEDS_IParameters::setParameter(const string& entry, const string& parameterName, const string& value)
+{
+ if(!_ap) return;
+ vector<string> v;
+ if(!_ap->IsSet(entry, PT_STRARRAY)) {
+ append(_AP_ENTRIES_LIST_, entry); //Add the entry to the internal list of entries
+ _ap->SetStrArray(entry, v);
+ }
+ v = _ap->GetStrArray(entry);
+ v.push_back(parameterName);
+ v.push_back(value);
+ _ap->SetStrArray(entry, v);
+}
+
+
+string SALOMEDS_IParameters::getParameter(const string& entry, const string& parameterName)
+{
+ if(!_ap) return "";
+ if(!_ap->IsSet(entry, PT_STRARRAY)) return "";
+ vector<string> v = _ap->GetStrArray(entry);
+ int length = v.size();
+ for(int i = 0; i<length; i+=1) {
+ if(v[i] == parameterName) return v[i+1];
+ }
+ return "";
+}
+
+
+vector<string> SALOMEDS_IParameters::getAllParameterNames(const string& entry)
+{
+ vector<string> v, names;
+ if(!_ap) return v;
+ if(!_ap->IsSet(entry, PT_STRARRAY)) return v;
+ v = _ap->GetStrArray(entry);
+ int length = v.size();
+ for(int i = 0; i<length; i+=2) {
+ names.push_back(v[i]);
+ }
+ return names;
+}
+
+vector<string> SALOMEDS_IParameters::getAllParameterValues(const string& entry)
+{
+ vector<string> v, values;
+ if(!_ap) return v;
+ if(!_ap->IsSet(entry, PT_STRARRAY)) return v;
+ v = _ap->GetStrArray(entry);
+ int length = v.size();
+ for(int i = 1; i<length; i+=2) {
+ values.push_back(v[i]);
+ }
+ return values;
+}
+
+int SALOMEDS_IParameters::getNbParameters(const string& entry)
+{
+ if(!_ap) return -1;
+ if(!_ap->IsSet(entry, PT_STRARRAY)) return -1;
+ return _ap->GetStrArray(entry).size()/2;
+}
+
+vector<string> SALOMEDS_IParameters::getEntries()
+{
+ vector<string> v;
+ if(!_ap) return v;
+ if(!_ap->IsSet(_AP_ENTRIES_LIST_, PT_STRARRAY)) return v;
+ return _ap->GetStrArray(_AP_ENTRIES_LIST_);
+}
+
+void SALOMEDS_IParameters::setProperty(const string& name, const std::string& value)
+{
+ if(!_ap) return;
+ if(!_ap->IsSet(name, PT_STRING)) {
+ append(_AP_PROPERTIES_LIST_, name); //Add the property to the internal list of properties
+ }
+ _ap->SetString(name, value);
+}
+
+string SALOMEDS_IParameters::getProperty(const string& name)
+{
+ if(!_ap) return "";
+ if(!_ap->IsSet(name, PT_STRING)) return "";
+ return _ap->GetString(name);
+}
+
+vector<string> SALOMEDS_IParameters::getProperties()
+{
+ vector<string> v;
+ if(!_ap) return v;
+ if(!_ap->IsSet(_AP_PROPERTIES_LIST_, PT_STRARRAY)) return v;
+ return _ap->GetStrArray(_AP_PROPERTIES_LIST_);
+}
+
+
+vector<string> SALOMEDS_IParameters::parseValue(const string& value, const char separator, bool fromEnd)
+{
+ TCollection_AsciiString val((char*)value.c_str());
+ vector<string> v;
+ int pos;
+ if(fromEnd) pos = val.SearchFromEnd(separator);
+ else pos = val.Search(separator);
+
+ if(pos < 0) {
+ v.push_back(value);
+ return v;
+ }
+
+ TCollection_AsciiString part1, part2;
+ part1 = val.SubString(1, pos-1);
+ part2 = val.SubString(pos+1, val.Length());
+ v.push_back(part1.ToCString());
+ v.push_back(part2.ToCString());
+ return v;
+}
+
+string SALOMEDS_IParameters::encodeEntry(const string& entry, const string& compName)
+{
+ string tail(entry, 6, entry.length()-1);
+ string newEntry(compName);
+ newEntry+=("_"+tail);
+ return newEntry;
+}
+
+string SALOMEDS_IParameters::decodeEntry(const string& entry)
+{
+ if(!_study) return entry;
+ int pos = entry.rfind("_");
+ if(pos < 0 || pos >= entry.length()) return entry;
+
+ string compName(entry, 0, pos), compID, tail(entry, pos+1, entry.length()-1);
+
+ if(_compNames.find(compName) == _compNames.end()) {
+ _PTR(SObject) so = _study->FindComponent(compName);
+ if(!so) return entry;
+ compID = so->GetID();
+ _compNames[compName] = compID;
+ }
+ else compID = _compNames[compName];
+
+ string newEntry(compID);
+ newEntry += (":"+tail);
+
+ return newEntry;
+}
+
+void SALOMEDS_IParameters::setDumpPython(_PTR(Study) study, const string& theID)
+{
+ string anID;
+ if(theID == "") anID = getDefaultVisualComponent();
+ else anID = theID;
+
+ _PTR(AttributeParameter) ap = study->GetCommonParameters(anID, 0);
+ ap->SetBool(_AP_DUMP_PYTHON_, true);
+}
+
+bool SALOMEDS_IParameters::isDumpPython(_PTR(Study) study, const string& theID)
+{
+ string anID;
+ if(theID == "") anID = getDefaultVisualComponent();
+ else anID = theID;
+
+ _PTR(AttributeParameter) ap = study->GetCommonParameters(anID, 0);
+ if(!ap) return false;
+ if(!ap->IsSet(_AP_DUMP_PYTHON_, PT_BOOLEAN)) return false;
+ return (bool)ap->GetBool(_AP_DUMP_PYTHON_);
+}
+
+string SALOMEDS_IParameters::getDefaultVisualComponent()
+{
+ return "Interface Applicative";
+}
+
+
+
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+#ifndef SALOMEDS_IParameters_H
+#define SALOMEDS_IParameters_H
+
+#include <string>
+#include <vector>
+#include <map>
+
+#include "SALOMEDSClient.hxx"
+
+/*!
+ Class which an interface to store the parameters of the objects
+*/
+class SALOMEDS_IParameters
+{
+public:
+ SALOMEDS_IParameters(const _PTR(AttributeParameter)& ap);
+
+ virtual ~SALOMEDS_IParameters();
+
+ /*!
+ Appends a string value to a named list.
+ Returns a number of the added value.
+ Note: the name of the list MUST be unique
+ */
+ virtual int append(const std::string& listName, const std::string& value);
+
+ /*!
+ Returns a number elements in the list
+ */
+ virtual int nbValues(const std::string& listName);
+
+ /*!
+ Returns a list of values in the list
+ */
+ virtual std::vector<std::string> getValues(const std::string& listName);
+
+ /*!
+ Returns a value with given %index, where %index is in range [0:nbValues-1]
+ */
+ virtual std::string getValue(const std::string& listName, int index);
+
+ /*!
+ Returns a list all entries lists
+ */
+ virtual std::vector<std::string> getLists();
+
+ /*!
+ Sets a new named parameter value for the given entry
+ */
+ virtual void setParameter(const std::string& entry, const std::string& parameterName, const std::string& value);
+
+ /*!
+ Gets a named parameter value for the given entry
+ */
+ virtual std::string getParameter(const std::string& entry, const std::string& parameterName);
+
+ /*!
+ Returns all parameter names of the given entry
+ */
+ virtual std::vector<std::string> getAllParameterNames(const std::string& entry);
+
+ /*!
+ Returns all parameter values of the given entry
+ */
+ virtual std::vector<std::string> getAllParameterValues(const std::string& entry);
+
+ /*!
+ Returns a number of parameters of the given entry
+ */
+ virtual int getNbParameters(const std::string& entry);
+
+ /*!
+ Returns a list all entries
+ */
+ virtual std::vector<std::string> getEntries();
+
+ /*!
+ Sets a global named property value
+ */
+ virtual void setProperty(const std::string& name, const std::string& value);
+
+ /*!
+ Gets a value of global named property
+ */
+ virtual std::string getProperty(const std::string& name);
+
+ /*!
+ Returns a list all properties
+ */
+ virtual std::vector<std::string> getProperties();
+
+ /*!
+ Breaks a value string in two parts which is divided by %separator.
+ If fromEnd is True the search of separator starts from the end of the string
+ */
+ virtual std::vector<std::string> parseValue(const std::string& value, const char separator, bool fromEnd = true);
+
+
+ /*!
+ Returns encoded entry that is a relative entry for the component
+ */
+ virtual std::string encodeEntry(const std::string& entry, const std::string& compName);
+
+ /*!
+ Returns decoded entry that is an absolute entry
+ */
+ virtual std::string decodeEntry(const std::string& entry);
+
+ /*!
+ Enables/Disables the dumping visual parameters
+ */
+ static void setDumpPython(_PTR(Study) study, const std::string& theID = "");
+
+ /*!
+ Returns whether there is the dumping visual parameters
+ */
+ static bool isDumpPython(_PTR(Study) study, const std::string& theID = "");
+
+ /*!
+ Returns a default name of the component where the visula parameters are stored.
+ */
+ static std::string getDefaultVisualComponent();
+
+private:
+ _PTR(AttributeParameter) _ap;
+ _PTR(Study) _study;
+ std::map<std::string, std::string> _compNames;
+};
+
+
+#endif
#include "SALOMEDS_ChildIterator.hxx"
#include "SALOMEDS_SComponentIterator.hxx"
#include "SALOMEDS_AttributeStudyProperties.hxx"
+#include "SALOMEDS_AttributeParameter.hxx"
#include "SALOMEDS_UseCaseBuilder.hxx"
#include "SALOMEDSImpl_SComponent.hxx"
#include "SALOMEDSImpl_ChildIterator.hxx"
#include "SALOMEDSImpl_SComponentIterator.hxx"
#include "SALOMEDSImpl_AttributeStudyProperties.hxx"
+#include "SALOMEDSImpl_AttributeParameter.hxx"
#include "SALOMEDSImpl_UseCaseBuilder.hxx"
#include "SALOMEDS_Driver_i.hxx"
else _corba_impl->EnableUseCaseAutoFilling(isEnabled);
}
-bool SALOMEDS_Study::DumpStudy(const std::string& thePath, const std::string& theBaseName, bool isPublished)
+bool SALOMEDS_Study::DumpStudy(const string& thePath, const string& theBaseName, bool isPublished)
{
//SRN: Pure CORBA DumpStudy as it does more cleaning than the local one
- bool ret = _corba_impl->DumpStudy((char*)thePath.c_str(), (char*)theBaseName.c_str(), isPublished);
+ bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished);
return ret;
}
return SALOMEDS::Study::_nil();
}
+
+_PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const string& theID, int theSavePoint)
+{
+ SALOMEDSClient_AttributeParameter* AP = NULL;
+ if(theSavePoint >= 0) {
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint));
+ }
+ else {
+ AP = new SALOMEDS_AttributeParameter(_corba_impl->GetCommonParameters(theID.c_str(), theSavePoint));
+ }
+ }
+ return _PTR(AttributeParameter)(AP);
+}
+
+_PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const string& theID,
+ const string& theModuleName, int theSavePoint)
+{
+ SALOMEDSClient_AttributeParameter* AP = NULL;
+ if(theSavePoint > 0) {
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ AP = new SALOMEDS_AttributeParameter(_local_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
+ }
+ else {
+ AP = new SALOMEDS_AttributeParameter(_corba_impl->GetModuleParameters(theID.c_str(), theModuleName.c_str(), theSavePoint));
+ }
+ }
+ return _PTR(AttributeParameter)(AP);
+}
virtual _PTR(UseCaseBuilder) GetUseCaseBuilder();
virtual void Close();
virtual void EnableUseCaseAutoFilling(bool isEnabled);
- virtual bool DumpStudy(const std::string& thePath, const std::string& theBaseName, bool isPublished);
-
+ virtual bool DumpStudy(const std::string& thePath,const std::string& theBaseName,bool isPublished);
+ virtual _PTR(AttributeParameter) GetCommonParameters(const std::string& theID, int theSavePoint);
+ virtual _PTR(AttributeParameter) GetModuleParameters(const std::string& theID,
+ const std::string& theModuleName, int theSavePoint);
std::string ConvertObjectToIOR(CORBA::Object_ptr theObject);
CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR);
#include "SALOMEDS_UseCaseIterator_i.hxx"
#include "SALOMEDS_GenericAttribute_i.hxx"
#include "SALOMEDS_AttributeStudyProperties_i.hxx"
+#include "SALOMEDS_AttributeParameter_i.hxx"
#include "SALOMEDS_ChildIterator_i.hxx"
#include "SALOMEDS_Driver_i.hxx"
#include "SALOMEDS.hxx"
#include "SALOMEDSImpl_SComponent.hxx"
#include "SALOMEDSImpl_UseCaseBuilder.hxx"
#include "SALOMEDSImpl_AttributeStudyProperties.hxx"
+#include "SALOMEDSImpl_AttributeParameter.hxx"
#include "SALOMEDSImpl_ChildIterator.hxx"
+#include "SALOMEDSImpl_IParameters.hxx"
#include <TColStd_SequenceOfExtendedString.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
* Purpose :
*/
//============================================================================
-CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished)
+CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath,
+ const char* theBaseName,
+ CORBA::Boolean isPublished)
{
SALOMEDS::Locker lock;
return ret;
}
+//============================================================================
+/*! Function : GetCommonParameters
+ * Purpose :
+ */
+//============================================================================
+SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetCommonParameters(const char* theID, CORBA::Long theSavePoint)
+{
+ SALOMEDS::Locker lock;
+
+ Handle(SALOMEDSImpl_AttributeParameter) anAttr = _impl->GetCommonParameters(theID, theSavePoint);
+ SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
+ return SP->AttributeParameter::_this();
+}
+
+//============================================================================
+/*! Function : GetCommonModuleParameters
+ * Purpose :
+ */
+//============================================================================
+SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const char* theID,
+ const char* theModuleName,
+ CORBA::Long theSavePoint)
+{
+ SALOMEDS::Locker lock;
+
+ Handle(SALOMEDSImpl_AttributeParameter) anAttr = _impl->GetModuleParameters(theID, theModuleName, theSavePoint);
+ SALOMEDS_AttributeParameter_i* SP = new SALOMEDS_AttributeParameter_i(anAttr, _orb);
+ return SP->AttributeParameter::_this();
+}
+
+//============================================================================
+/*! Function : GetDefaultScript
+ * Purpose :
+ */
+//============================================================================
+char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift)
+{
+ SALOMEDS::Locker lock;
+
+ string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift);
+ return CORBA::string_dup(script.c_str());
+}
+
//===========================================================================
// PRIVATE FUNCTIONS
//===========================================================================
// theWay = -1: get back to the list of postponed
#endif
- virtual CORBA::Boolean DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished);
+ virtual SALOMEDS::AttributeParameter_ptr GetCommonParameters(const char* theID, CORBA::Long theSavePoint);
+ virtual SALOMEDS::AttributeParameter_ptr GetModuleParameters(const char* theID,
+ const char* theModuleName,
+ CORBA::Long theSavePoint);
+
+ virtual char* GetDefaultScript(const char* theModuleName, const char* theShift);
+
+ virtual CORBA::Boolean DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished);
virtual Handle(SALOMEDSImpl_Study) GetImpl() { return _impl; }
virtual long GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
+
};
#endif
SALOMEDSClient_AttributeTextHighlightColor.hxx \
SALOMEDSClient_AttributeTreeNode.hxx \
SALOMEDSClient_AttributeUserID.hxx \
+ SALOMEDSClient_AttributeParameter.hxx \
SALOMEDSClient_ChildIterator.hxx \
SALOMEDSClient_GenericAttribute.hxx \
SALOMEDSClient_SComponent.hxx \
#include "SALOMEDSClient_AttributeTextHighlightColor.hxx"
#include "SALOMEDSClient_AttributeTreeNode.hxx"
#include "SALOMEDSClient_AttributeUserID.hxx"
+#include "SALOMEDSClient_AttributeParameter.hxx"
#include "SALOMEDSClient_ChildIterator.hxx"
#include "SALOMEDSClient_GenericAttribute.hxx"
#include "SALOMEDSClient_SComponent.hxx"
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+// File : SALOMEDSImpl_AttributeIOR.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef _SALOMEDSClient_AttributeParameter_HeaderFile
+#define _SALOMEDSClient_AttributeParameter_HeaderFile
+
+#include "SALOMEDSClient_definitions.hxx"
+#include "SALOMEDSClient_GenericAttribute.hxx"
+#include <string>
+#include <vector>
+
+class SALOMEDSClient_AttributeParameter : public virtual SALOMEDSClient_GenericAttribute
+{
+
+public:
+
+ virtual void SetInt(const std::string& theID, const int theValue) = 0;
+ virtual int GetInt(const std::string& theID) = 0;
+
+ virtual void SetReal(const std::string& theID, const double& theValue) = 0;
+ virtual double GetReal(const std::string& theID) = 0;
+
+ virtual void SetString(const std::string& theID, const std::string& theValue) = 0;
+ virtual std::string GetString(const std::string& theID) = 0;
+
+ virtual void SetBool(const std::string& theID, const bool& theValue) = 0;
+ virtual bool GetBool(const std::string& theID) = 0;
+
+ virtual void SetRealArray(const std::string& theID, const std::vector<double>& theArray) = 0;
+ virtual std::vector<double> GetRealArray(const std::string& theID) = 0;
+
+ virtual void SetIntArray(const std::string& theID, const std::vector<int>& theArray) = 0;
+ virtual std::vector<int> GetIntArray(const std::string& theID) = 0;
+
+ virtual void SetStrArray(const std::string& theID, const std::vector<std::string>& theArray) = 0;
+ virtual std::vector<std::string> GetStrArray(const std::string& theID) = 0;
+
+ virtual bool IsSet(const std::string& theID, const int theType) = 0;
+
+ virtual bool RemoveID(const std::string& theID, const int theType) = 0;
+
+ virtual _PTR(AttributeParameter) GetFather() = 0;
+ virtual bool HasFather() = 0;
+ virtual bool IsRoot() = 0;
+
+ virtual void Clear() = 0;
+
+ virtual std::vector<std::string> GetIDs(const int theType) = 0;
+};
+
+#endif
#include "SALOMEDSClient_definitions.hxx"
#include "SALOMEDSClient_SComponentIterator.hxx"
#include "SALOMEDSClient_StudyBuilder.hxx"
+#include "SALOMEDSClient_AttributeParameter.hxx"
#include "SALOMEDSClient_SObject.hxx"
#include "SALOMEDSClient_SComponent.hxx"
#include "SALOMEDSClient_UseCaseBuilder.hxx"
virtual _PTR(UseCaseBuilder) GetUseCaseBuilder() = 0;
virtual void Close() = 0;
virtual void EnableUseCaseAutoFilling(bool isEnabled) = 0;
- virtual bool DumpStudy(const std::string& thePath, const std::string& theBaseName, bool isPublished) = 0;
+ virtual bool DumpStudy(const std::string& thePath,
+ const std::string& theBaseName,
+ bool isPublished) = 0;
+ virtual _PTR(AttributeParameter) GetCommonParameters(const std::string& theID, int theSavePoint) = 0;
+ virtual _PTR(AttributeParameter) GetModuleParameters(const std::string& theID,
+ const std::string& theModuleName, int theSavePoint) = 0;
};
SALOMEDSImpl_AttributeName.hxx \
SALOMEDSImpl_AttributeComment.hxx \
SALOMEDSImpl_AttributeReference.hxx \
+ SALOMEDSImpl_AttributeParameter.hxx \
SALOMEDSImpl_UseCaseBuilder.hxx \
SALOMEDSImpl_UseCaseIterator.hxx \
SALOMEDSImpl_SComponentIterator.hxx \
SALOMEDSImpl_StudyManager.hxx \
SALOMEDSImpl_OCAFApplication.hxx \
SALOMEDSImpl_ChildNodeIterator.hxx \
+ SALOMEDSImpl_IParameters.hxx \
SALOMEDSImpl_TMPFile.hxx
LIB_CLIENT_IDL =
SALOMEDSImpl_AttributeName.cxx \
SALOMEDSImpl_AttributeComment.cxx \
SALOMEDSImpl_AttributeReference.cxx \
+ SALOMEDSImpl_AttributeParameter.cxx \
SALOMEDSImpl_ChildNodeIterator.cxx \
SALOMEDSImpl_UseCaseBuilder.cxx \
SALOMEDSImpl_UseCaseIterator.cxx \
SALOMEDSImpl_StudyBuilder.cxx \
SALOMEDSImpl_Study.cxx \
SALOMEDSImpl_StudyManager.cxx \
+ SALOMEDSImpl_IParameters.cxx \
SALOMEDSImpl_TMPFile.cxx
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+// File : SALOMEDSImpl_AttributeParameter.cxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+
+#include "SALOMEDSImpl_AttributeParameter.hxx"
+#include <Standard_Failure.hxx>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <strstream>
+
+using namespace std;
+
+
+
+IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeParameter, SALOMEDSImpl_GenericAttribute )
+IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeParameter, SALOMEDSImpl_GenericAttribute )
+
+
+// Purpose: Each character in the string is replaced by 3 characters: '%' and hex number
+// of the character (2 characters)
+string convertString(const string& S)
+{
+ int length = S.size();
+ const char *s = S.c_str();
+ char *c = new char[3], *buffer = new char[length*3+1];
+ buffer[length*3] = (char)0;
+ for(int i = 0, pos = 0; i<length; i++, pos+=3) {
+ int val = (int)s[i];
+ buffer[pos] = '%';
+ sprintf(c, "%x", val);
+ buffer[pos+1] = c[0];
+ buffer[pos+2] = c[1];
+ }
+
+ string RS(buffer);
+ delete c;
+ delete buffer;
+ return RS;
+}
+
+//Restors a string converted by the function convertString
+string restoreString(const string& S)
+{
+ int length = S.size();
+ char *c = new char[3], *buffer = new char[length/3+1];
+ buffer[length/3] = (char)0;
+ const char *s = S.c_str();
+ for(int i = 0, pos = 0; i<length; i+=3, pos++) {
+ c[0] = s[i+1];
+ c[1] = s[i+2];
+ c[2] = (char)0;
+ int val = strtol(c, NULL, 16);
+ buffer[pos] = (char)val;
+ }
+
+ string RS(buffer);
+ delete c;
+ delete buffer;
+ return RS;
+}
+
+//=======================================================================
+/*!
+ * Function : GetID
+ * Purpose : Returns GUID of the attribute
+ */
+//=======================================================================
+const Standard_GUID& SALOMEDSImpl_AttributeParameter::GetID ()
+{
+ static Standard_GUID ParemeterID ("BA75F3A1-E40B-46b8-8D24-B1D3C3BB1A8C");
+ return ParemeterID;
+}
+
+//=======================================================================
+/*!
+ * Function : Set
+ * Purpose : Adds an attribute to the label
+ */
+//=======================================================================
+Handle(SALOMEDSImpl_AttributeParameter) SALOMEDSImpl_AttributeParameter::Set (const TDF_Label& L)
+{
+ Handle(SALOMEDSImpl_AttributeParameter) A;
+ if (!L.FindAttribute(SALOMEDSImpl_AttributeParameter::GetID(), A)) {
+ A = new SALOMEDSImpl_AttributeParameter();
+ L.AddAttribute(A);
+ }
+
+ return A;
+}
+
+//=======================================================================
+/*!
+ * Function : SetInt
+ * Purpose : Associates a integer value with the ID
+ */
+//=======================================================================
+void SALOMEDSImpl_AttributeParameter::SetInt(const string& theID, const int& theValue)
+{
+ CheckLocked();
+
+ Backup();
+
+ _ints[theID] = theValue;
+
+ SetModifyFlag();
+}
+
+//=======================================================================
+/*!
+ * Function : GetInt
+ * Purpose : Returns a int value associated with the given ID
+ */
+//=======================================================================
+int SALOMEDSImpl_AttributeParameter::GetInt(const string& theID)
+{
+ if(!IsSet(theID, PT_INTEGER)) Standard_Failure::Raise("Invalid ID");
+ return _ints[theID];
+}
+
+//=======================================================================
+/*!
+ * Function : SetReal
+ * Purpose : Associates a double value with the ID
+ */
+//=======================================================================
+void SALOMEDSImpl_AttributeParameter::SetReal(const string& theID, const double& theValue)
+{
+ CheckLocked();
+
+ Backup();
+
+ _reals[theID] = theValue;
+
+ SetModifyFlag();
+}
+
+//=======================================================================
+/*!
+ * Function : GetReal
+ * Purpose : Returns a double value associated with the given ID
+ */
+//=======================================================================
+double SALOMEDSImpl_AttributeParameter::GetReal(const string& theID)
+{
+ if(!IsSet(theID, PT_REAL)) Standard_Failure::Raise("Invalid ID");
+ return _reals[theID];
+}
+
+//=======================================================================
+/*!
+ * Function : SetString
+ * Purpose : Associates a string with the ID
+ */
+//=======================================================================
+void SALOMEDSImpl_AttributeParameter::SetString(const string& theID, const string& theValue)
+{
+ CheckLocked();
+
+ Backup();
+
+ _strings[theID] = theValue;
+
+ SetModifyFlag();
+}
+
+//=======================================================================
+/*!
+ * Function : GetString
+ * Purpose : Returns a string associated with the given ID
+ */
+//=======================================================================
+string SALOMEDSImpl_AttributeParameter::GetString(const string& theID)
+{
+ if(!IsSet(theID, PT_STRING)) Standard_Failure::Raise("Invalid ID");
+ return _strings[theID];
+}
+
+//=======================================================================
+/*!
+ * Function : SetBool
+ * Purpose : Associates a bool value with the ID
+ */
+//=======================================================================
+void SALOMEDSImpl_AttributeParameter::SetBool(const string& theID, const bool& theValue)
+{
+ CheckLocked();
+
+ Backup();
+
+ _bools[theID] = theValue;
+
+ SetModifyFlag();
+}
+
+//=======================================================================
+/*!
+ * Function : GetBool
+ * Purpose : Returns a bool value associated with the ID
+ */
+//=======================================================================
+bool SALOMEDSImpl_AttributeParameter::GetBool(const string& theID)
+{
+ if(!IsSet(theID, PT_BOOLEAN)) Standard_Failure::Raise("Invalid ID");
+ return _bools[theID];
+}
+
+//=======================================================================
+/*!
+ * Function : SetRealArray
+ * Purpose : Associates an array of double values with the given ID
+ */
+//=======================================================================
+void SALOMEDSImpl_AttributeParameter::SetRealArray(const string& theID, const vector<double>& theArray)
+{
+ CheckLocked();
+
+ Backup();
+
+ _realarrays[theID] = theArray;
+
+ SetModifyFlag();
+}
+
+//=======================================================================
+/*!
+ * Function : GetRealArray
+ * Purpose : Returns double values associated with the ID
+ */
+//=======================================================================
+vector<double> SALOMEDSImpl_AttributeParameter::GetRealArray(const string& theID)
+{
+ if(!IsSet(theID, PT_REALARRAY)) Standard_Failure::Raise("Invalid ID");
+ return _realarrays[theID];
+}
+
+
+//=======================================================================
+/*!
+ * Function : SetIntArray
+ * Purpose : Associates an array of int values with the given ID
+ */
+//=======================================================================
+void SALOMEDSImpl_AttributeParameter::SetIntArray(const string& theID, const vector<int>& theArray)
+{
+ CheckLocked();
+
+ Backup();
+
+ _intarrays[theID] = theArray;
+
+ SetModifyFlag();
+}
+
+//=======================================================================
+/*!
+ * Function : GetIntArray
+ * Purpose : Returns int values associated with the ID
+ */
+//=======================================================================
+vector<int> SALOMEDSImpl_AttributeParameter::GetIntArray(const string& theID)
+{
+ if(!IsSet(theID, PT_INTARRAY)) Standard_Failure::Raise("Invalid ID");
+ return _intarrays[theID];
+}
+
+
+//=======================================================================
+/*!
+ * Function : SetStrArray
+ * Purpose : Associates an array of string values with the given ID
+ */
+//=======================================================================
+void SALOMEDSImpl_AttributeParameter::SetStrArray(const string& theID, const vector<string>& theArray)
+{
+ CheckLocked();
+
+ Backup();
+
+ _strarrays[theID] = theArray;
+
+ SetModifyFlag();
+}
+
+//=======================================================================
+/*!
+ * Function : GetStrArray
+ * Purpose : Returns string values associated with the ID
+ */
+//=======================================================================
+vector<string> SALOMEDSImpl_AttributeParameter::GetStrArray(const string& theID)
+{
+ if(!IsSet(theID, PT_STRARRAY)) Standard_Failure::Raise("Invalid ID");
+ return _strarrays[theID];
+}
+
+
+//=======================================================================
+/*!
+ * Function : IsSet
+ * Purpose : Returns true if for the ID of given type was assigned \n
+ * a value in the attribute
+ */
+//=======================================================================
+bool SALOMEDSImpl_AttributeParameter::IsSet(const string& theID, const Parameter_Types theType)
+{
+ switch(theType) {
+ case PT_INTEGER: {
+ if(_ints.find(theID) != _ints.end()) return true;
+ break;
+ }
+ case PT_REAL: {
+ if(_reals.find(theID) != _reals.end()) return true;
+ break;
+ }
+ case PT_BOOLEAN: {
+ if(_bools.find(theID) != _bools.end()) return true;
+ break;
+ }
+ case PT_STRING: {
+ if(_strings.find(theID) != _strings.end()) return true;
+ break;
+ }
+ case PT_REALARRAY: {
+ if(_realarrays.find(theID) != _realarrays.end()) return true;
+ break;
+ }
+ case PT_INTARRAY: {
+ if(_intarrays.find(theID) != _intarrays.end()) return true;
+ break;
+ }
+ case PT_STRARRAY: {
+ if(_strarrays.find(theID) != _strarrays.end()) return true;
+ break;
+ }
+ default: return false;
+ }
+
+ return false;
+}
+
+//=======================================================================
+/*!
+ * Function : RemoveID
+ * Purpose : Removes a parameter with given ID
+ */
+//=======================================================================
+bool SALOMEDSImpl_AttributeParameter::RemoveID(const string& theID, const Parameter_Types theType)
+{
+ Backup();
+ SetModifyFlag();
+
+ switch(theType) {
+ case PT_INTEGER: {
+ if(_ints.erase(theID)) return true;
+ break;
+ }
+ case PT_REAL: {
+ if(_reals.erase(theID)) return true;
+ break;
+ }
+ case PT_BOOLEAN: {
+ if(_bools.erase(theID)) return true;
+ break;
+ }
+ case PT_STRING: {
+ if(_strings.erase(theID)) return true;
+ break;
+ }
+ case PT_REALARRAY: {
+ if(_realarrays.erase(theID)) return true;
+ break;
+ }
+ case PT_INTARRAY: {
+ if(_intarrays.erase(theID)) return true;
+ break;
+ }
+ case PT_STRARRAY: {
+ if(_strarrays.erase(theID)) return true;
+ break;
+ }
+ default: return false;
+ }
+
+
+ return false;
+}
+
+
+//=======================================================================
+/*!
+ * Function : GetFather
+ * Purpose : Returns a father attribute for this attribute
+ */
+//=======================================================================
+Handle(SALOMEDSImpl_AttributeParameter) SALOMEDSImpl_AttributeParameter::GetFather()
+{
+ Handle(SALOMEDSImpl_AttributeParameter) aFather;
+ TDF_Label L = Label();
+ if(L.IsRoot()) return aFather;
+
+ while(!L.IsRoot()) {
+ L = L.Father();
+ if(L.FindAttribute(SALOMEDSImpl_AttributeParameter::GetID(), aFather)) break;
+ }
+
+ return aFather;
+}
+
+//=======================================================================
+/*!
+ * Function : HasFather
+ * Purpose : Returns True if the attribute has a father attribute
+ */
+//=======================================================================
+bool SALOMEDSImpl_AttributeParameter::HasFather()
+{
+ TDF_Label L = Label();
+ if(L.IsRoot()) return false;
+ while(!L.IsRoot()) {
+ L = L.Father();
+ if(L.IsAttribute(SALOMEDSImpl_AttributeParameter::GetID())) return true;
+ }
+
+ return false;
+}
+
+//=======================================================================
+/*!
+ * Function : IsRoot
+ * Purpose : Returns True is the attribute is highest in an hierachy
+ */
+//=======================================================================
+bool SALOMEDSImpl_AttributeParameter::IsRoot()
+{
+ return ((HasFather())?false:true);
+}
+
+//=======================================================================
+/*!
+ * Function : Clear
+ * Purpose : Clears the content of the attribute
+ */
+//=======================================================================
+void SALOMEDSImpl_AttributeParameter::Clear()
+{
+ Backup();
+
+ _ints.clear();
+ _reals.clear();
+ _bools.clear();
+ _strings.clear();
+ _realarrays.clear();
+ _intarrays.clear();
+ _strarrays.clear();
+
+ SetModifyFlag();
+}
+
+//=======================================================================
+/*!
+ * Function : GetIDs
+ * Purpose : Returns an array of all ID's of the given type
+ */
+//=======================================================================
+vector<string> SALOMEDSImpl_AttributeParameter::GetIDs(const Parameter_Types theType)
+{
+
+ vector<string> anArray;
+ int i = 0;
+
+ switch(theType) {
+ case PT_INTEGER: {
+ if(_ints.size()) {
+ anArray.resize(_ints.size());
+ for(map<string,int>::const_iterator p = _ints.begin(); p != _ints.end(); p++, i++)
+ anArray[i] = p->first;
+ }
+ break;
+ }
+ case PT_REAL: {
+ if(_reals.size()) {
+ anArray.resize(_reals.size());
+ for(map<string,double>::const_iterator p = _reals.begin(); p != _reals.end(); p++, i++)
+ anArray[i] = p->first;
+ }
+ break;
+ }
+ case PT_BOOLEAN: {
+ if(_bools.size()) {
+ anArray.resize(_bools.size());
+ for(map<string,bool>::const_iterator p = _bools.begin(); p != _bools.end(); p++, i++)
+ anArray[i] = p->first;
+ }
+ break;
+ }
+ case PT_STRING: {
+ if(_strings.size()) {
+ anArray.resize(_strings.size());
+ for(map<string,string>::const_iterator p = _strings.begin(); p!= _strings.end(); p++)
+ anArray[i] = p->first;
+ }
+ break;
+ }
+ case PT_REALARRAY: {
+ if(_realarrays.size()) {
+ anArray.resize(_realarrays.size());
+ for(map< string, vector<double> >::const_iterator p = _realarrays.begin(); p!= _realarrays.end(); p++)
+ anArray[i] = p->first;
+ }
+ break;
+ }
+ case PT_INTARRAY: {
+ if(_intarrays.size()) {
+ anArray.resize(_intarrays.size());
+ for(map< string, vector<int> >::const_iterator p = _intarrays.begin(); p!= _intarrays.end(); p++)
+ anArray[i] = p->first;
+ }
+ break;
+ }
+ case PT_STRARRAY: {
+ if(_strarrays.size()) {
+ anArray.resize(_strarrays.size());
+ for(map< string, vector<string> >::const_iterator p = _strarrays.begin(); p!= _strarrays.end(); p++)
+ anArray[i] = p->first;
+ }
+ break;
+ }
+ default: return anArray;
+ }
+
+ return anArray;
+}
+
+//=======================================================================
+/*!
+ * Function : ID
+ * Purpose : Rteurns an GUID of the attribute
+ */
+//=======================================================================
+const Standard_GUID& SALOMEDSImpl_AttributeParameter::ID () const { return GetID(); }
+
+
+Handle(TDF_Attribute) SALOMEDSImpl_AttributeParameter::NewEmpty () const
+{
+ return new SALOMEDSImpl_AttributeParameter();
+}
+
+//=======================================================================
+/*!
+ * Function : Restore
+ * Purpose : Restors the content of the attribute from another
+ */
+//=======================================================================
+void SALOMEDSImpl_AttributeParameter::Restore(const Handle(TDF_Attribute)& with)
+{
+ Handle(SALOMEDSImpl_AttributeParameter) A = Handle(SALOMEDSImpl_AttributeParameter)::DownCast (with);
+ _ints.clear();
+ _reals.clear();
+ _bools.clear();
+ _strings.clear();
+ _realarrays.clear();
+ _intarrays.clear();
+ _strarrays.clear();
+
+ for(map<string,int>::const_iterator p = A->_ints.begin(); p!= A->_ints.end(); p++) _ints[p->first] = p->second;
+ for(map<string,double>::const_iterator p = A->_reals.begin(); p!= A->_reals.end(); p++) _reals[p->first] = p->second;
+ for(map<string,bool>::const_iterator p = A->_bools.begin(); p!= A->_bools.end(); p++) _bools[p->first] = p->second;
+ for(map<string,string>::const_iterator p = A->_strings.begin(); p!= A->_strings.end(); p++)
+ _strings[p->first] = p->second;
+ for(map< string,vector<double> >::const_iterator p = A->_realarrays.begin(); p!= A->_realarrays.end(); p++)
+ _realarrays[p->first] = p->second;
+ for(map< string,vector<int> >::const_iterator p = A->_intarrays.begin(); p!= A->_intarrays.end(); p++)
+ _intarrays[p->first] = p->second;
+ for(map< string,vector<string> >::const_iterator p = A->_strarrays.begin(); p!= A->_strarrays.end(); p++)
+ _strarrays[p->first] = p->second;
+}
+
+//=======================================================================
+/*!
+ * Function : Paste
+ * Purpose : Pastes the content of attribute to another
+ */
+//=======================================================================
+void SALOMEDSImpl_AttributeParameter::Paste (const Handle(TDF_Attribute)& into,
+ const Handle(TDF_RelocationTable)& RT) const
+{
+ into->Restore(this);
+}
+
+//=======================================================================
+/*!
+ * Function : Save
+ * Purpose : Saves a content of the attribute as a string
+ */
+//=======================================================================
+TCollection_AsciiString SALOMEDSImpl_AttributeParameter::Save()
+{
+ ostrstream buffer;
+ char *tmpBuffer = new char[255];
+
+ buffer << _ints.size() << " ";
+
+ for(map<string,int>::const_iterator p = _ints.begin(); p != _ints.end(); p++) {
+ buffer << convertString(p->first) << " " << p->second << " ";
+ }
+
+ buffer << _reals.size() << " ";
+ for(map<string,double>::const_iterator p =_reals.begin(); p != _reals.end(); p++) {
+ sprintf(tmpBuffer, "%.64e", p->second);
+ buffer << convertString(p->first) << " " << tmpBuffer << " ";
+ }
+
+ buffer << _bools.size() << " ";
+ for(map<string,bool>::const_iterator p = _bools.begin(); p != _bools.end(); p++) {
+ buffer << convertString(p->first) << " " << p->second << " ";
+ }
+
+ buffer << _strings.size() << " ";
+ for(map<string,string>::const_iterator p = _strings.begin(); p != _strings.end(); p++) {
+ buffer << convertString(p->first) << " " << convertString(p->second) << " ";
+ }
+
+ buffer << _realarrays.size() << " ";
+ for(map< string,vector<double> >::const_iterator p = _realarrays.begin(); p != _realarrays.end(); p++) {
+ vector<double> v(p->second);
+ sprintf(tmpBuffer, " %s %d ", convertString(p->first).c_str(), v.size());
+ buffer << tmpBuffer;
+ for(int i = 0; i<v.size(); i++) {
+ sprintf(tmpBuffer, " %.64e ", v[i]);
+ buffer << tmpBuffer;
+ }
+ }
+
+ buffer << _intarrays.size() << " ";
+ for(map< string,vector<int> >::const_iterator p = _intarrays.begin(); p != _intarrays.end(); p++) {
+ vector<int> v(p->second);
+ sprintf(tmpBuffer, " %s %d ", convertString(p->first).c_str(), v.size());
+ buffer << tmpBuffer;
+ for(int i = 0; i<v.size(); i++) {
+ sprintf(tmpBuffer, " %d ", v[i]);
+ buffer << tmpBuffer;
+ }
+ }
+
+ buffer << _strarrays.size() << " ";
+ for(map< string,vector<string> >::const_iterator p = _strarrays.begin(); p != _strarrays.end(); p++) {
+ vector<string> v(p->second);
+ sprintf(tmpBuffer, " %s %d ", convertString(p->first).c_str(), v.size());
+ buffer << tmpBuffer;
+ for(int i = 0; i<v.size(); i++) {
+ buffer << " " << convertString(v[i]) << " ";
+ }
+ }
+
+ delete tmpBuffer;
+
+ TCollection_AsciiString AS((char*)buffer.rdbuf()->str());
+
+ return AS;
+}
+
+//=======================================================================
+/*!
+ * Function : Load
+ * Purpose : Restores the attribute from the string
+ */
+//=======================================================================
+void SALOMEDSImpl_AttributeParameter::Load(const TCollection_AsciiString& theValue)
+{
+ Backup();
+
+ _ints.clear();
+ _reals.clear();
+ _bools.clear();
+ _strings.clear();
+ _realarrays.clear();
+ _intarrays.clear();
+
+ istrstream buffer(theValue.ToCString(), strlen(theValue.ToCString()));
+
+ int size, val, ival;
+ double val2;
+ string s, id;
+
+ buffer >> size;
+ for(int i = 1; i<=size; i++) {
+ buffer >> id >> val;
+ _ints[restoreString(id)] = val;
+ }
+
+ buffer >> size;
+ for(int i = 1; i<=size; i++) {
+ buffer >> id >> val2;
+ _reals[restoreString(id)] = val2;
+ }
+
+ buffer >> size;
+ for(int i = 1; i<=size; i++) {
+ buffer >> id >> val;
+ _bools[restoreString(id)] = val;
+ }
+
+ buffer >> size;
+ for(int i = 1; i<=size; i++) {
+ buffer >> id >> s;
+ _strings[restoreString(id)] = restoreString(s);
+ }
+
+ buffer >> size;
+ for(int i = 1; i<=size; i++) {
+ buffer >> id >> val;
+ vector<double> v;
+ v.resize(val);
+ for(int j = 0; j<val; j++) {
+ buffer >> val2;
+ v[j] = val2;
+ }
+ _realarrays[restoreString(id)] = v;
+ }
+
+ buffer >> size;
+ for(int i = 1; i<=size; i++) {
+ buffer >> id >> val;
+ vector<int> v;
+ v.resize(val);
+ for(int j = 0; j<val; j++) {
+ buffer >> ival;
+ v[j] = ival;
+ }
+ _intarrays[restoreString(id)] = v;
+ }
+
+ buffer >> size;
+ for(int i = 1; i<=size; i++) {
+ buffer >> id >> val;
+ vector<string> v;
+ v.resize(val);
+ for(int j = 0; j<val; j++) {
+ buffer >> s;
+ v[j] = restoreString(s);
+ }
+ _strarrays[restoreString(id)] = v;
+ }
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+// File : SALOMEDSImpl_AttributeIOR.hxx
+// Author : Sergey RUIN
+// Module : SALOME
+
+#ifndef _SALOMEDSImpl_AttributeParameter_HeaderFile
+#define _SALOMEDSImpl_AttributeParameter_HeaderFile
+
+#include <Standard_DefineHandle.hxx>
+#include <TDF_Attribute.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TDF_Label.hxx>
+#include "SALOMEDSImpl_GenericAttribute.hxx"
+
+#include <vector>
+#include <string>
+#include <map>
+
+class Standard_GUID;
+class Handle(TDF_Attribute);
+class Handle(TDF_RelocationTable);
+
+
+DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeParameter, SALOMEDSImpl_GenericAttribute )
+
+enum Parameter_Types {PT_INTEGER, PT_REAL, PT_BOOLEAN, PT_STRING, PT_REALARRAY, PT_INTARRAY, PT_STRARRAY};
+
+/*!
+ Class: SALOMEDSImpl_AttributeParameter
+ Description : AttributeParameter is a universal container of basic types
+*/
+
+class SALOMEDSImpl_AttributeParameter : public SALOMEDSImpl_GenericAttribute
+{
+
+private:
+
+ std::map<std::string, int> _ints;
+ std::map<std::string, double> _reals;
+ std::map<std::string, std::string> _strings;
+ std::map<std::string, bool> _bools;
+ std::map< std::string, vector<double> > _realarrays;
+ std::map< std::string, vector<int> > _intarrays;
+ std::map< std::string, vector<std::string> > _strarrays;
+
+public:
+ Standard_EXPORT static const Standard_GUID& GetID() ;
+
+ Standard_EXPORT SALOMEDSImpl_AttributeParameter():SALOMEDSImpl_GenericAttribute("AttributeParameter") {}
+ Standard_EXPORT static Handle(SALOMEDSImpl_AttributeParameter) Set (const TDF_Label& L);
+
+
+ Standard_EXPORT void SetInt(const std::string& theID, const int& theValue);
+ Standard_EXPORT int GetInt(const std::string& theID);
+
+ Standard_EXPORT void SetReal(const std::string& theID, const double& theValue);
+ Standard_EXPORT double GetReal(const std::string& theID);
+
+ Standard_EXPORT void SetString(const std::string& theID, const std::string& theValue);
+ Standard_EXPORT std::string GetString(const std::string& theID);
+
+ Standard_EXPORT void SetBool(const std::string& theID, const bool& theValue);
+ Standard_EXPORT bool GetBool(const std::string& theID);
+
+ Standard_EXPORT void SetRealArray(const std::string& theID, const std::vector<double>& theArray);
+ Standard_EXPORT std::vector<double> GetRealArray(const std::string& theID);
+
+ Standard_EXPORT void SetIntArray(const std::string& theID, const std::vector<int>& theArray);
+ Standard_EXPORT std::vector<int> GetIntArray(const std::string& theID);
+
+ Standard_EXPORT void SetStrArray(const std::string& theID, const std::vector<std::string>& theArray);
+ Standard_EXPORT std::vector<std::string> GetStrArray(const std::string& theID);
+
+ Standard_EXPORT bool IsSet(const std::string& theID, const Parameter_Types theType);
+
+ Standard_EXPORT bool RemoveID(const std::string& theID, const Parameter_Types theType);
+
+ Standard_EXPORT Handle(SALOMEDSImpl_AttributeParameter) GetFather();
+ Standard_EXPORT bool HasFather();
+ Standard_EXPORT bool IsRoot();
+
+ Standard_EXPORT std::vector<std::string> GetIDs(const Parameter_Types theType);
+
+ Standard_EXPORT void Clear();
+
+ Standard_EXPORT virtual TCollection_AsciiString Save();
+ Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue);
+
+ Standard_EXPORT const Standard_GUID& ID() const;
+ Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ;
+ Standard_EXPORT Handle_TDF_Attribute NewEmpty() const;
+ Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const;
+
+ Standard_EXPORT ~SALOMEDSImpl_AttributeParameter() {}
+
+public:
+ DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeParameter )
+};
+
+#endif
#include "SALOMEDSImpl_AttributeFileType.hxx"
#include "SALOMEDSImpl_AttributeFlags.hxx"
#include "SALOMEDSImpl_AttributeGraphic.hxx"
+#include "SALOMEDSImpl_AttributeParameter.hxx"
#define __AttributeTypeToGUIDForSObject \
if(theType == "AttributeFileType") return SALOMEDSImpl_AttributeFileType::GetID(); \
if(theType == "AttributeFlags") return SALOMEDSImpl_AttributeFlags::GetID(); \
if(theType == "AttributeGraphic") return SALOMEDSImpl_AttributeGraphic::GetID(); \
- if(theType == "AttributeReference") return SALOMEDSImpl_AttributeReference::GetID();
+ if(theType == "AttributeReference") return SALOMEDSImpl_AttributeReference::GetID(); \
+ if(theType == "AttributeParameter") return SALOMEDSImpl_AttributeParameter::GetID();
#define __FindOrCreateAttributeLocked(ClassName) if (strcmp(aTypeOfAttribute.ToCString(), #ClassName) == 0) { \
__FindOrCreateAttributeLocked(AttributeTableOfReal) \
__FindOrCreateAttributeLocked(AttributeTableOfString) \
__FindOrCreateAttributeLocked(AttributePythonObject) \
+__FindOrCreateAttributeLocked(AttributeParameter) \
__FindOrCreateAttribute(AttributePersistentRef) \
__FindOrCreateAttribute(AttributeDrawable) \
__FindOrCreateAttribute(AttributeSelectable) \
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+#include "SALOMEDSImpl_IParameters.hxx"
+#include <utilities.h>
+
+#include <TCollection_AsciiString.hxx>
+
+#include "SALOMEDSImpl_SObject.hxx"
+#include "SALOMEDSImpl_ChildIterator.hxx"
+
+using namespace std;
+
+#define _AP_LISTS_LIST_ "AP_LISTS_LIST"
+#define _AP_ENTRIES_LIST_ "AP_ENTRIES_LIST"
+#define _AP_PROPERTIES_LIST_ "AP_PROPERTIES_LIST"
+#define _AP_DUMP_PYTHON_ "AP_DUMP_PYTHON"
+
+/*!
+ Constructor
+*/
+SALOMEDSImpl_IParameters::SALOMEDSImpl_IParameters(const Handle(SALOMEDSImpl_AttributeParameter)& ap)
+{
+ if(ap.IsNull()) return;
+ _ap = ap;
+ Handle(SALOMEDSImpl_SObject) so = _ap->GetSObject();
+ _study = so->GetStudy();
+}
+
+SALOMEDSImpl_IParameters::~SALOMEDSImpl_IParameters()
+{
+ _compNames.clear();
+}
+
+int SALOMEDSImpl_IParameters::append(const string& listName, const string& value)
+{
+ if(_ap.IsNull()) return -1;
+ vector<string> v;
+ if(!_ap->IsSet(listName, PT_STRARRAY)) {
+ if(!_ap->IsSet(_AP_LISTS_LIST_, PT_STRARRAY)) _ap->SetStrArray(_AP_LISTS_LIST_, v);
+ if(listName != _AP_ENTRIES_LIST_ &&
+ listName != _AP_PROPERTIES_LIST_) {
+ append(_AP_LISTS_LIST_, listName);
+ }
+ _ap->SetStrArray(listName, v);
+ }
+ v = _ap->GetStrArray(listName);
+ v.push_back(value);
+ _ap->SetStrArray(listName, v);
+ return (v.size()-1);
+}
+
+int SALOMEDSImpl_IParameters::nbValues(const string& listName)
+{
+ if(_ap.IsNull()) return -1;
+ if(!_ap->IsSet(listName, PT_STRARRAY)) return 0;
+ vector<string> v = _ap->GetStrArray(listName);
+ return v.size();
+}
+
+vector<string> SALOMEDSImpl_IParameters::getValues(const string& listName)
+{
+ vector<string> v;
+ if(_ap.IsNull()) return v;
+ if(!_ap->IsSet(listName, PT_STRARRAY)) return v;
+ return _ap->GetStrArray(listName);
+}
+
+
+string SALOMEDSImpl_IParameters::getValue(const string& listName, int index)
+{
+ if(_ap.IsNull()) return "";
+ if(!_ap->IsSet(listName, PT_STRARRAY)) return "";
+ vector<string> v = _ap->GetStrArray(listName);
+ if(index >= v.size()) return "";
+ return v[index];
+}
+
+vector<string> SALOMEDSImpl_IParameters::getLists()
+{
+ vector<string> v;
+ if(!_ap->IsSet(_AP_LISTS_LIST_, PT_STRARRAY)) return v;
+ return _ap->GetStrArray(_AP_LISTS_LIST_);
+}
+
+void SALOMEDSImpl_IParameters::setParameter(const string& entry, const string& parameterName, const string& value)
+{
+ if(_ap.IsNull()) return;
+ vector<string> v;
+ if(!_ap->IsSet(entry, PT_STRARRAY)) {
+ append(_AP_ENTRIES_LIST_, entry); //Add the entry to the internal list of entries
+ _ap->SetStrArray(entry, v);
+ }
+ v = _ap->GetStrArray(entry);
+ v.push_back(parameterName);
+ v.push_back(value);
+ _ap->SetStrArray(entry, v);
+}
+
+
+string SALOMEDSImpl_IParameters::getParameter(const string& entry, const string& parameterName)
+{
+ if(_ap.IsNull()) return "";
+ if(!_ap->IsSet(entry, PT_STRARRAY)) return "";
+ vector<string> v = _ap->GetStrArray(entry);
+ int length = v.size();
+ for(int i = 0; i<length; i+=1) {
+ if(v[i] == parameterName) return v[i+1];
+ }
+ return "";
+}
+
+
+vector<string> SALOMEDSImpl_IParameters::getAllParameterNames(const string& entry)
+{
+ vector<string> v, names;
+ if(_ap.IsNull()) return v;
+ if(!_ap->IsSet(entry, PT_STRARRAY)) return v;
+ v = _ap->GetStrArray(entry);
+ int length = v.size();
+ for(int i = 0; i<length; i+=2) {
+ names.push_back(v[i]);
+ }
+ return names;
+}
+
+vector<string> SALOMEDSImpl_IParameters::getAllParameterValues(const string& entry)
+{
+ vector<string> v, values;
+ if(_ap.IsNull()) return v;
+ if(!_ap->IsSet(entry, PT_STRARRAY)) return v;
+ v = _ap->GetStrArray(entry);
+ int length = v.size();
+ for(int i = 1; i<length; i+=2) {
+ values.push_back(v[i]);
+ }
+ return values;
+}
+
+int SALOMEDSImpl_IParameters::getNbParameters(const string& entry)
+{
+ if(_ap.IsNull()) return -1;
+ if(!_ap->IsSet(entry, PT_STRARRAY)) return -1;
+ return _ap->GetStrArray(entry).size()/2;
+}
+
+vector<string> SALOMEDSImpl_IParameters::getEntries()
+{
+ vector<string> v;
+ if(_ap.IsNull()) return v;
+ if(!_ap->IsSet(_AP_ENTRIES_LIST_, PT_STRARRAY)) return v;
+ return _ap->GetStrArray(_AP_ENTRIES_LIST_);
+}
+
+void SALOMEDSImpl_IParameters::setProperty(const string& name, const std::string& value)
+{
+ if(_ap.IsNull()) return;
+ if(!_ap->IsSet(name, PT_STRING)) {
+ append(_AP_PROPERTIES_LIST_, name); //Add the property to the internal list of properties
+ }
+ _ap->SetString(name, value);
+}
+
+string SALOMEDSImpl_IParameters::getProperty(const string& name)
+{
+ if(_ap.IsNull()) return "";
+ if(!_ap->IsSet(name, PT_STRING)) return "";
+ return _ap->GetString(name);
+}
+
+vector<string> SALOMEDSImpl_IParameters::getProperties()
+{
+ vector<string> v;
+ if(_ap.IsNull()) return v;
+ if(!_ap->IsSet(_AP_PROPERTIES_LIST_, PT_STRARRAY)) return v;
+ return _ap->GetStrArray(_AP_PROPERTIES_LIST_);
+}
+
+string SALOMEDSImpl_IParameters::decodeEntry(const string& entry)
+{
+ if(!_study) return entry;
+ int pos = entry.rfind("_");
+ if(pos < 0 || pos >= entry.length()) return entry;
+
+ string compName(entry, 0, pos), compID, tail(entry, pos+1, entry.length()-1);
+
+ if(_compNames.find(compName) == _compNames.end()) {
+ Handle(SALOMEDSImpl_SObject) so = _study->FindComponent((char*)compName.c_str());
+ if(!so) return entry;
+ compID = so->GetID().ToCString();
+ _compNames[compName] = compID;
+ }
+ else compID = _compNames[compName];
+
+ string newEntry(compID);
+ newEntry += (":"+tail);
+
+ return newEntry;
+}
+
+
+bool SALOMEDSImpl_IParameters::isDumpPython(const Handle(SALOMEDSImpl_Study)& study, const string& theID)
+{
+ string anID;
+ if(theID == "") anID = getDefaultVisualComponent();
+ else anID = theID;
+
+ Handle(SALOMEDSImpl_AttributeParameter) ap = study->GetCommonParameters((char*)anID.c_str(), 0);
+ if(ap.IsNull()) return false;
+ if(!ap->IsSet(_AP_DUMP_PYTHON_, PT_BOOLEAN)) return false;
+ return (bool)ap->GetBool(_AP_DUMP_PYTHON_);
+}
+
+
+int SALOMEDSImpl_IParameters::getLastSavePoint(const Handle(SALOMEDSImpl_Study)& study, const string& theID)
+{
+ string anID;
+ if(theID == "") anID = getDefaultVisualComponent();
+ else anID = theID;
+
+
+ Handle(SALOMEDSImpl_SObject) so = study->FindComponent((char*)anID.c_str());
+ if(so.IsNull()) return -1;
+
+ Handle(SALOMEDSImpl_StudyBuilder) builder = study->NewBuilder();
+ Handle(SALOMEDSImpl_ChildIterator) anIter ( study->NewChildIterator( so ) );
+ int tag = -1;
+ for(; anIter->More(); anIter->Next())
+ {
+ Handle(SALOMEDSImpl_SObject) val( anIter->Value() );
+ Handle(SALOMEDSImpl_GenericAttribute) genAttr;
+ if(builder->FindAttribute(val, genAttr, "AttributeParameter")) tag = val->Tag();
+ }
+
+ return tag;
+}
+
+
+
+string SALOMEDSImpl_IParameters::getStudyScript(const Handle(SALOMEDSImpl_Study)& study, int savePoint, const std::string& theID)
+{
+ string anID;
+ if(theID == "") anID = getDefaultVisualComponent();
+ else anID = theID;
+
+ Handle(SALOMEDSImpl_AttributeParameter) ap = study->GetCommonParameters((char*)anID.c_str(), savePoint);
+ SALOMEDSImpl_IParameters ip(ap);
+
+ string dump("");
+
+ dump += "import iparameters\n";
+ dump += "ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters(\""+anID+"\", 1))\n\n";
+
+
+ vector<string> v = ip.getProperties();
+ if(v.size() > 0) {
+ dump += "#Set up visual properties:\n";
+ for(int i = 0; i<v.size(); i++) {
+ string prp = ip.getProperty(v[i]);
+ dump += "ipar.setProperty(\""+v[i]+"\", \""+prp+"\")\n";
+ }
+ }
+
+ v = ip.getLists();
+ if(v.size() > 0) {
+ dump += "#Set up lists:\n";
+ for(int i = 0; i<v.size(); i++) {
+ vector<string> lst = ip.getValues(v[i]);
+ dump += "# fill list "+v[i]+"\n";
+ for(int j = 0; j < lst.size(); j++)
+ dump += "ipar.append(\""+v[i]+"\", \""+lst[j]+"\")\n";
+ }
+ }
+
+ return dump;
+}
+
+string SALOMEDSImpl_IParameters::getDefaultScript(const Handle(SALOMEDSImpl_Study)& study,
+ const string& moduleName,
+ const string& shift,
+ const string& theID)
+{
+ string anID;
+ if(theID == "") anID = getDefaultVisualComponent();
+ else anID = theID;
+
+ string dump("");
+
+ int savePoint = SALOMEDSImpl_IParameters::getLastSavePoint(study, anID);
+ if(savePoint < 0) return dump;
+ SALOMEDSImpl_IParameters ip = SALOMEDSImpl_IParameters(study->GetCommonParameters(anID.c_str(), savePoint));
+ if(!isDumpPython(study)) return dump;
+
+ Handle(SALOMEDSImpl_AttributeParameter) ap = study->GetModuleParameters(anID.c_str(), moduleName.c_str(), savePoint);
+ ip = SALOMEDSImpl_IParameters(ap);
+
+
+ dump += shift +"import iparameters\n";
+ dump += shift + "ipar = iparameters.IParameters(theStudy.GetModuleParameters(\""+anID+"\", \""+moduleName+"\", 1))\n\n";
+
+ vector<string> v = ip.getProperties();
+ if(v.size() > 0) {
+ dump += shift +"#Set up visual properties:\n";
+ for(int i = 0; i<v.size(); i++) {
+ string prp = ip.getProperty(v[i]);
+ dump += shift +"ipar.setProperty(\""+v[i]+"\", \""+prp+"\")\n";
+ }
+ }
+
+ v = ip.getLists();
+ if(v.size() > 0) {
+ dump += shift +"#Set up lists:\n";
+ for(int i = 0; i<v.size(); i++) {
+ vector<string> lst = ip.getValues(v[i]);
+ dump += shift +"# fill list "+v[i]+"\n";
+ for(int j = 0; j < lst.size(); j++)
+ dump += shift +"ipar.append(\""+v[i]+"\", \""+lst[j]+"\")\n";
+ }
+ }
+
+ v = ip.getEntries();
+ if(v.size() > 0) {
+ dump += shift + "#Set up entries:\n";
+ for(int i = 0; i<v.size(); i++) {
+ vector<string> names = ip.getAllParameterNames(v[i]);
+ vector<string> values = ip.getAllParameterValues(v[i]);
+ string decodedEntry = ip.decodeEntry(v[i]);
+ Handle(SALOMEDSImpl_SObject) so = study->FindObjectID((char*)decodedEntry.c_str());
+ string so_name("");
+ if(!so.IsNull()) so_name = so->GetName().ToCString();
+ dump += shift + "# set up entry " + v[i] +" ("+so_name+")" + " parameters" + "\n";
+ for(int j = 0; j < names.size() && j < values.size(); j++)
+ dump += shift + "ipar.setParameter(\"" + v[i] + "\", \"" + names[j] + "\", \"" + values[j] + "\")\n";
+ }
+ }
+
+ return dump;
+}
+
+
+string SALOMEDSImpl_IParameters::getDefaultVisualComponent()
+{
+ return "Interface Applicative";
+}
+
+
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+#ifndef SALOMEDSImpl_IParameters_H
+#define SALOMEDSImpl_IParameters_H
+
+#include <string>
+#include <vector>
+#include <map>
+
+#include "SALOMEDSImpl_AttributeParameter.hxx"
+#include "SALOMEDSImpl_Study.hxx"
+
+/*!
+ Class which an interface to store the parameters of the objects
+*/
+class SALOMEDSImpl_IParameters
+{
+public:
+ SALOMEDSImpl_IParameters(const Handle(SALOMEDSImpl_AttributeParameter)& ap);
+
+ virtual ~SALOMEDSImpl_IParameters();
+
+ /*!
+ Appends a string value to a named list.
+ Returns a number of the added value.
+ Note: the name of the list MUST be unique
+ */
+ virtual int append(const std::string& listName, const std::string& value);
+
+ /*!
+ Returns a number elements in the list
+ */
+ virtual int nbValues(const std::string& listName);
+
+ /*!
+ Returns a list of values in the list
+ */
+ virtual std::vector<std::string> getValues(const std::string& listName);
+
+ /*!
+ Returns a value with given %index, where %index is in range [0:nbValues-1]
+ */
+ virtual std::string getValue(const std::string& listName, int index);
+
+ /*!
+ Returns a list all entries lists
+ */
+ virtual std::vector<std::string> getLists();
+
+ /*!
+ Sets a new named parameter value for the given entry
+ */
+ virtual void setParameter(const std::string& entry, const std::string& parameterName, const std::string& value);
+
+ /*!
+ Gets a named parameter value for the given entry
+ */
+ virtual std::string getParameter(const std::string& entry, const std::string& parameterName);
+
+ /*!
+ Returns all parameter names of the given entry
+ */
+ virtual std::vector<std::string> SALOMEDSImpl_IParameters::getAllParameterNames(const std::string& entry);
+
+ /*!
+ Returns all parameter values of the given entry
+ */
+ virtual std::vector<std::string> SALOMEDSImpl_IParameters::getAllParameterValues(const std::string& entry);
+
+ /*!
+ Returns a number of parameters of the given entry
+ */
+ virtual int getNbParameters(const std::string& entry);
+
+ /*!
+ Returns a list all entries
+ */
+ virtual std::vector<std::string> getEntries();
+
+ /*!
+ Sets a global named property value
+ */
+ virtual void setProperty(const std::string& name, const std::string& value);
+
+ /*!
+ Gets a value of global named property
+ */
+ virtual std::string getProperty(const std::string& name);
+
+ /*!
+ Returns a list all properties
+ */
+ virtual std::vector<std::string> getProperties();
+
+ /*!
+ Returns decoded entry that is an absolute entry
+ */
+ virtual std::string decodeEntry(const std::string& entry);
+
+
+ /*!
+ Returns whether there is the dumping visual parameters
+ */
+ static bool isDumpPython(const Handle(SALOMEDSImpl_Study)& study, const string& theID = "");
+
+ /*!
+ Returns an ID of the last save point
+ */
+ static int getLastSavePoint(const Handle(SALOMEDSImpl_Study)& study, const std::string& theID = "");
+
+ /*!
+ Returns a Python script for the study, which sets up visual parameters
+ */
+ static std::string getStudyScript(const Handle(SALOMEDSImpl_Study)& study, int savePoint, const std::string& theID = "");
+
+ /*!
+ Returns a default Python script that set ups visual parameters for the given module
+ shift is a string that contain spaces to make valid Python script indentaion
+ */
+ static std::string getDefaultScript(const Handle(SALOMEDSImpl_Study)& study,
+ const std::string& moduleName,
+ const std::string& shift,
+ const std::string& theID = "");
+
+ /*!
+ Returns a default name of the component where the visula parameters are stored.
+ */
+ static std::string getDefaultVisualComponent();
+
+private:
+ Handle(SALOMEDSImpl_AttributeParameter) _ap;
+ Handle(SALOMEDSImpl_Study) _study;
+ std::map<std::string, std::string> _compNames;
+};
+
+
+#endif
#include "SALOMEDSImpl_AttributeReference.hxx"
#include "SALOMEDSImpl_StudyHandle.hxx"
#include "SALOMEDSImpl_Tool.hxx"
+#include "SALOMEDSImpl_IParameters.hxx"
IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_Study, MMgt_TShared )
IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_Study, MMgt_TShared )
fp << "import " << aBatchModeScript << "\n" << endl;
fp << "sys.path.insert( 0, \'" << thePath << "\')\n" << endl;
+
+ //Check if it's necessary to dump visual parameters
+ bool isDumpVisuals = SALOMEDSImpl_IParameters::isDumpPython(this);
+ int lastSavePoint = -1;
+ if(isDumpVisuals) {
+ lastSavePoint = SALOMEDSImpl_IParameters::getLastSavePoint(this);
+ if(lastSavePoint > 0) {
+ fp << SALOMEDSImpl_IParameters::getStudyScript(this, lastSavePoint);
+ fp << "\n" << endl;
+ }
+ }
+
+
Handle(TColStd_HSequenceOfAsciiString) aSeqOfFileNames = new TColStd_HSequenceOfAsciiString;
//Iterate all components and create the componponents specific scripts.
fp << aScriptName << ".RebuildData(" << aBatchModeScript << ".myStudy)" << endl;
}
+ if(isDumpVisuals) { //Output the call to Session's method restoreVisualState
+ fp << "iparameters.getSession().restoreVisualState(1)" << endl;
+ }
+
fp << "salome.sg.updateObjBrowser(1)" << endl;
fp.close();
_errorCode = "";
_doc->Modify();
}
+
+//============================================================================
+/*! Function :
+ * Purpose :
+ */
+//============================================================================
+Handle(SALOMEDSImpl_AttributeParameter) SALOMEDSImpl_Study::GetCommonParameters(const char* theID, int theSavePoint)
+{
+ if(theSavePoint < 0) return NULL;
+ Handle(SALOMEDSImpl_StudyBuilder) builder = NewBuilder();
+ Handle(SALOMEDSImpl_SObject) so = FindComponent((char*)theID);
+ if(so.IsNull()) so = builder->NewComponent((char*)theID);
+ Handle(SALOMEDSImpl_SObject) newSO;
+ if(theSavePoint == 0) //Get an attribute that is placed on the component itself.
+ newSO = so;
+ else
+ newSO = builder->NewObjectToTag(so, theSavePoint);
+ return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(builder->FindOrCreateAttribute(newSO, "AttributeParameter"));
+}
+
+//============================================================================
+/*! Function :
+ * Purpose :
+ */
+//============================================================================
+Handle(SALOMEDSImpl_AttributeParameter) SALOMEDSImpl_Study::GetModuleParameters(const char* theID,
+ const char* theModuleName,
+ int theSavePoint)
+{
+ if(theSavePoint <= 0) return NULL;
+ Handle(SALOMEDSImpl_AttributeParameter) main_ap = GetCommonParameters(theID, theSavePoint);
+ Handle(SALOMEDSImpl_SObject) main_so = main_ap->GetSObject();
+ Handle(SALOMEDSImpl_AttributeParameter) par;
+
+ Handle(SALOMEDSImpl_ChildIterator) it = NewChildIterator(main_so);
+ string moduleName(theModuleName);
+ for(; it->More(); it->Next()) {
+ Handle(SALOMEDSImpl_SObject) so(it->Value());
+ Handle(SALOMEDSImpl_GenericAttribute) ga;
+ if(so->FindAttribute(ga, "AttributeParameter")) {
+ par = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(ga);
+ if(!par->IsSet("AP_MODULE_NAME", (Parameter_Types)3)) continue; //3 -> PT_STRING
+ if(par->GetString("AP_MODULE_NAME") == moduleName) return par;
+ }
+ }
+
+ Handle(SALOMEDSImpl_StudyBuilder) builder = NewBuilder();
+ Handle(SALOMEDSImpl_SObject) so = builder->NewObject(main_so);
+ par = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(builder->FindOrCreateAttribute(so, "AttributeParameter"));
+ par->SetString("AP_MODULE_NAME", moduleName);
+ return par;
+}
#include "SALOMEDSImpl_UseCaseBuilder.hxx"
#include "SALOMEDSImpl_AttributeStudyProperties.hxx"
#include "SALOMEDSImpl_AttributeIOR.hxx"
+#include "SALOMEDSImpl_AttributeParameter.hxx"
#include "SALOMEDSImpl_Callback.hxx"
#include "SALOMEDSImpl_Driver.hxx"
#include "SALOMEDSImpl_ChildIterator.hxx"
Standard_EXPORT virtual bool HasCurrentContext() { return !_current.IsNull(); }
Standard_EXPORT virtual bool DumpStudy(const TCollection_AsciiString& thePath,
- const TCollection_AsciiString& theBaseName,
- bool isPublished,
- SALOMEDSImpl_DriverFactory* theFactory);
+ const TCollection_AsciiString& theBaseName,
+ bool isPublished,
+ SALOMEDSImpl_DriverFactory* theFactory);
Standard_EXPORT static TCollection_AsciiString GetDumpStudyComment(const char* theComponentName = 0);
//This method marks the study as being modified
Standard_EXPORT void Modify();
+ Standard_EXPORT Handle(SALOMEDSImpl_AttributeParameter) GetCommonParameters(const char* theID, int theSavePoint);
+
+ Standard_EXPORT Handle(SALOMEDSImpl_AttributeParameter) GetModuleParameters(const char* theID,
+ const char* theModuleName,
+ int theSavePoint);
+
public:
DEFINE_STANDARD_RTTI( SALOMEDSImpl_Study )
#include <stdio.h>
#include <iostream>
+#include <vector>
#include <TColStd_HSequenceOfTransient.hxx>
#include <TCollection_AsciiString.hxx>
#include "SALOMEDSImpl_StudyBuilder.hxx"
#include "SALOMEDSImpl_SObject.hxx"
#include "SALOMEDSImpl_SComponent.hxx"
+#include "SALOMEDSImpl_AttributeParameter.hxx"
+
//#include "SALOMEDSImpl_.hxx"
int main (int argc, char * argv[])
aBuilder->RemoveObject(aSubSO);
cout << "Remove: done" << endl;
+ cout << "Check AttributeTreeNode " << endl;
+ aTDFAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeTreeNode");
+ cout << Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aTDFAttr)->Type() << endl;
+ cout << "Check AttributeTreeNode : done " << endl;
+
+ aTDFAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeParameter");
+ cout << Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aTDFAttr)->Type() << endl;
+
cout << "Check the attributes on SObject" << endl;
Handle(TColStd_HSequenceOfTransient) aSeq = aSO->GetAllAttributes();
for(int i = 1; i <= aSeq->Length(); i++)
cout << "Found: " << Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aSeq->Value(i))->Type() << endl;
- cout << "Check AttributeTreeNode " << endl;
- aTDFAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeTreeNode");
- cout << Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aTDFAttr)->Type() << endl;
- cout << "Check AttributeTreeNode : done " << endl;
+
+
+ cout << "Check AttributeParameter " << endl;
+
+ Handle(SALOMEDSImpl_AttributeParameter) AP = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(aTDFAttr);
+
+ cout << "AttributeParameter with type : " << AP->Type() << endl;
+
+ AP->SetInt("1", 123);
+ cout << "IsSet for int: " << AP->IsSet("1", PT_INTEGER) << " value : " << AP->GetInt("1") << endl;
+ //for(int i = 2; i < 5; i++) AP->SetInt(i, i*i);
+
+ AP->SetReal("1", 123.123);
+ cout << "IsSet for real: " << AP->IsSet("1", PT_REAL) << " value : " << AP->GetReal("1") << endl;
+ //for(int i = 2; i < 5; i++) AP->SetReal(i, 0.1);
+
+ AP->SetString("1", "value is 123.123!");
+ cout << "IsSet for string: " << AP->IsSet("1", PT_STRING) << " value : " << AP->GetString("1") << endl;
+ /*
+ for(int i = 2; i < 5; i++) {
+ TCollection_AsciiString s((double)(1.0/i));
+ cout << "Setting for " << i << " value : " << s << endl;
+ AP->SetString(i, s);
+ }
+ */
+
+ AP->SetBool("1", true);
+ cout << "IsSet for bool: " << AP->IsSet("1", PT_BOOLEAN) << " value : " << AP->GetBool("1") << endl;
+ //for(int i = 2; i < 5; i++) AP->SetBool(i, 0);
+
+ vector<double> v;
+ v.push_back(111.111);
+ v.push_back(222.22222);
+ v.push_back(333.3333333);
+ AP->SetRealArray("1", v);
+ cout << "IsSet for array: " << AP->IsSet("1", PT_REALARRAY);
+ vector<double> v2 = AP->GetRealArray("1");
+ cout.precision(10);
+ cout << " values : ";
+ for(int i = 0; i<v2.size(); i++) cout << v2[i] << " ";
+ cout << endl;
+
+ v[0] = 211.111;
+ v[1] = 422.22222;
+ v[2] = 633.3333333;
+ AP->SetRealArray("2", v);
+
+ vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ AP->SetIntArray("2", vi);
+
+ vector<string> vs;
+ vs.push_back("hello, ");
+ vs.push_back("world!");
+ AP->SetStrArray("3", vs);
+
+ TCollection_AsciiString as = AP->Save();
+ cout << "AS = " << as << endl;
+ AP->Load(as);
+
+ cout << "Restored string with id = 1 is: " << AP->GetString("1") << endl;
+ cout << "Restored int with id = 2 is: " << AP->GetInt("1") << endl;
+ cout << "Restored real with id = 3 is: " << AP->GetReal("1") << endl;
+ cout << "Restored bool with id = 1 is: " << AP->GetBool("1") << endl;
+
+ v2 = AP->GetRealArray("2");
+ cout << "Restored real array with id = 2 is: ";
+ for(int i = 0; i<v2.size(); i++) cout << v2[i] << " ";
+ cout << endl;
+
+ vi = AP->GetIntArray("2");
+ cout << "Restored int array with id = 2 is: ";
+ for(int i = 0; i<vi.size(); i++) cout << vi[i] << " ";
+ cout << endl;
+
+ vs = AP->GetStrArray("3");
+ cout << "Restored string array with id = 2 is: ";
+ for(int i = 0; i<vs.size(); i++) cout << vs[i] << " ";
+ cout << endl;
+
+ cout << "Check RemoveID 1 with type PT_INTEGER" << endl;
+ AP->RemoveID("1", PT_INTEGER);
+ cout << "IsSet with id = 1, type = PT_INTEGER : " << AP->IsSet("1", PT_INTEGER) << endl;
+ cout << "Check RemoveID is done" << endl;
+
+ cout << "Check AttributeParameter : done" << endl;
cout << "Test finished " << endl;
return 0;