From 050190efb1382f739408edf7d94bf0a2b4566c86 Mon Sep 17 00:00:00 2001 From: srn Date: Thu, 17 Mar 2005 07:35:40 +0000 Subject: [PATCH] Local Study --- ...pl_DataMapNodeOfDataMapOfIntegerString.hxx | 80 + ...DSImpl_DataMapNodeOfDataMapStringLabel.hxx | 101 ++ src/SALOMEDSImpl/Makefile.in | 141 ++ .../SALOMEDSImpl_AttributeComment.cxx | 83 ++ .../SALOMEDSImpl_AttributeComment.hxx | 51 + .../SALOMEDSImpl_AttributeDrawable.cxx | 103 ++ .../SALOMEDSImpl_AttributeDrawable.hxx | 48 + .../SALOMEDSImpl_AttributeExpandable.cxx | 102 ++ .../SALOMEDSImpl_AttributeExpandable.hxx | 47 + .../SALOMEDSImpl_AttributeExternalFileDef.cxx | 102 ++ .../SALOMEDSImpl_AttributeExternalFileDef.hxx | 41 + .../SALOMEDSImpl_AttributeFileType.cxx | 107 ++ .../SALOMEDSImpl_AttributeFileType.hxx | 42 + .../SALOMEDSImpl_AttributeFlags.cxx | 138 ++ .../SALOMEDSImpl_AttributeFlags.hxx | 50 + .../SALOMEDSImpl_AttributeGraphic.cxx | 161 +++ .../SALOMEDSImpl_AttributeGraphic.hxx | 58 + .../SALOMEDSImpl_AttributeIOR.cxx | 122 ++ .../SALOMEDSImpl_AttributeIOR.hxx | 45 + .../SALOMEDSImpl_AttributeInteger.cxx | 79 + .../SALOMEDSImpl_AttributeInteger.hxx | 48 + .../SALOMEDSImpl_AttributeLocalID.cxx | 106 ++ .../SALOMEDSImpl_AttributeLocalID.hxx | 48 + .../SALOMEDSImpl_AttributeName.cxx | 83 ++ .../SALOMEDSImpl_AttributeName.hxx | 52 + .../SALOMEDSImpl_AttributeOpened.cxx | 103 ++ .../SALOMEDSImpl_AttributeOpened.hxx | 46 + .../SALOMEDSImpl_AttributePersistentRef.cxx | 106 ++ .../SALOMEDSImpl_AttributePersistentRef.hxx | 48 + .../SALOMEDSImpl_AttributePixMap.cxx | 108 ++ .../SALOMEDSImpl_AttributePixMap.hxx | 50 + .../SALOMEDSImpl_AttributePythonObject.cxx | 98 ++ .../SALOMEDSImpl_AttributePythonObject.hxx | 54 + .../SALOMEDSImpl_AttributeReal.cxx | 82 ++ .../SALOMEDSImpl_AttributeReal.hxx | 48 + .../SALOMEDSImpl_AttributeReference.cxx | 105 ++ .../SALOMEDSImpl_AttributeReference.hxx | 50 + .../SALOMEDSImpl_AttributeSelectable.cxx | 103 ++ .../SALOMEDSImpl_AttributeSelectable.hxx | 49 + ...ALOMEDSImpl_AttributeSequenceOfInteger.cxx | 170 +++ ...ALOMEDSImpl_AttributeSequenceOfInteger.hxx | 54 + .../SALOMEDSImpl_AttributeSequenceOfReal.cxx | 170 +++ .../SALOMEDSImpl_AttributeSequenceOfReal.hxx | 53 + .../SALOMEDSImpl_AttributeStudyProperties.cxx | 304 ++++ .../SALOMEDSImpl_AttributeStudyProperties.hxx | 86 ++ .../SALOMEDSImpl_AttributeTableOfInteger.cxx | 425 ++++++ .../SALOMEDSImpl_AttributeTableOfInteger.hxx | 86 ++ .../SALOMEDSImpl_AttributeTableOfReal.cxx | 430 ++++++ .../SALOMEDSImpl_AttributeTableOfReal.hxx | 89 ++ .../SALOMEDSImpl_AttributeTableOfString.cxx | 449 ++++++ .../SALOMEDSImpl_AttributeTableOfString.hxx | 88 ++ .../SALOMEDSImpl_AttributeTarget.cxx | 152 ++ .../SALOMEDSImpl_AttributeTarget.hxx | 51 + .../SALOMEDSImpl_AttributeTextColor.cxx | 131 ++ .../SALOMEDSImpl_AttributeTextColor.hxx | 45 + ...LOMEDSImpl_AttributeTextHighlightColor.cxx | 133 ++ ...LOMEDSImpl_AttributeTextHighlightColor.hxx | 45 + .../SALOMEDSImpl_AttributeTreeNode.cxx | 548 +++++++ .../SALOMEDSImpl_AttributeTreeNode.hxx | 94 ++ .../SALOMEDSImpl_AttributeUserID.cxx | 87 ++ .../SALOMEDSImpl_AttributeUserID.hxx | 51 + src/SALOMEDSImpl/SALOMEDSImpl_Attributes.hxx | 128 ++ src/SALOMEDSImpl/SALOMEDSImpl_Callback.cxx | 9 + src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx | 42 + .../SALOMEDSImpl_ChildNodeIterator.cxx | 75 + .../SALOMEDSImpl_ChildNodeIterator.hxx | 45 + ...ataMapIteratorOfDataMapOfIntegerString.hxx | 95 ++ ...aMapIteratorOfDataMapOfIntegerString_0.cxx | 45 + ...pl_DataMapIteratorOfDataMapStringLabel.hxx | 113 ++ ..._DataMapIteratorOfDataMapStringLabel_0.cxx | 63 + ...pl_DataMapNodeOfDataMapOfIntegerString.hxx | 132 ++ ..._DataMapNodeOfDataMapOfIntegerString_0.cxx | 94 ++ ...DSImpl_DataMapNodeOfDataMapStringLabel.hxx | 153 ++ ...Impl_DataMapNodeOfDataMapStringLabel_0.cxx | 112 ++ .../SALOMEDSImpl_DataMapOfIntegerString.hxx | 127 ++ .../SALOMEDSImpl_DataMapOfIntegerString_0.cxx | 48 + .../SALOMEDSImpl_DataMapStringLabel.hxx | 145 ++ .../SALOMEDSImpl_DataMapStringLabel_0.cxx | 67 + src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx | 80 + .../SALOMEDSImpl_GenericAttribute.cxx | 43 + .../SALOMEDSImpl_GenericAttribute.hxx | 47 + .../SALOMEDSImpl_OCAFApplication.cxx | 45 + .../SALOMEDSImpl_OCAFApplication.hxx | 32 + src/SALOMEDSImpl/SALOMEDSImpl_SComponent.cxx | 77 + src/SALOMEDSImpl/SALOMEDSImpl_SComponent.hxx | 41 + .../SALOMEDSImpl_SComponentIterator.cxx | 66 + .../SALOMEDSImpl_SComponentIterator.hxx | 36 + src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx | 211 +++ src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx | 66 + src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 1286 +++++++++++++++++ src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx | 232 +++ .../SALOMEDSImpl_StudyBuilder.cxx | 982 +++++++++++++ .../SALOMEDSImpl_StudyBuilder.hxx | 106 ++ src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.cxx | 95 ++ src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.hxx | 50 + .../SALOMEDSImpl_StudyManager.cxx | 1254 ++++++++++++++++ .../SALOMEDSImpl_StudyManager.hxx | 132 ++ src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx | 150 ++ src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx | 62 + .../SALOMEDSImpl_UseCaseBuilder.cxx | 388 +++++ .../SALOMEDSImpl_UseCaseBuilder.hxx | 67 + .../SALOMEDSImpl_UseCaseIterator.cxx | 78 + .../SALOMEDSImpl_UseCaseIterator.hxx | 47 + src/SALOMEDSImpl/testDS.cxx | 78 + 104 files changed, 14073 insertions(+) create mode 100644 src/SALOMEDSImpl/Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx create mode 100644 src/SALOMEDSImpl/Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx create mode 100644 src/SALOMEDSImpl/Makefile.in create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_Attributes.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_Callback.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString_0.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel_0.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_0.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_0.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapOfIntegerString.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapOfIntegerString_0.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapStringLabel.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_DataMapStringLabel_0.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_OCAFApplication.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_OCAFApplication.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_SComponent.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_SComponent.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.cxx create mode 100644 src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.hxx create mode 100644 src/SALOMEDSImpl/testDS.cxx diff --git a/src/SALOMEDSImpl/Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx b/src/SALOMEDSImpl/Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx new file mode 100644 index 000000000..c2a7138c2 --- /dev/null +++ b/src/SALOMEDSImpl/Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx @@ -0,0 +1,80 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx +// Author : Sergey Ruin +// Module : SALOME + +#ifndef _Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#define _Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TCollection_MapNode); +class SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString); + +class Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString) : public Handle(TCollection_MapNode) { + public: + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString)():Handle(TCollection_MapNode)() {} + Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString)(const Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString)(const SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString)& operator=(const Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString)& operator=(const SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString* operator->() + { + return (SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString *)ControlAccess(); + } + + SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString* operator->() const + { + return (SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString)(); + + Standard_EXPORT static const Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDSImpl/Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx b/src/SALOMEDSImpl/Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx new file mode 100644 index 000000000..b0a9a8e6a --- /dev/null +++ b/src/SALOMEDSImpl/Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx @@ -0,0 +1,101 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_HeaderFile +#define _Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TCollection_MapNode); +class SALOMEDSImpl_DataMapNodeOfDataMapStringLabel; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel); + +class Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel) : public Handle(TCollection_MapNode) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel)():Handle(TCollection_MapNode)() {} + Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel)(const Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel)(const SALOMEDSImpl_DataMapNodeOfDataMapStringLabel* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel)& operator=(const Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel)& operator=(const SALOMEDSImpl_DataMapNodeOfDataMapStringLabel* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDSImpl_DataMapNodeOfDataMapStringLabel* operator->() + { + return (SALOMEDSImpl_DataMapNodeOfDataMapStringLabel *)ControlAccess(); + } + + SALOMEDSImpl_DataMapNodeOfDataMapStringLabel* operator->() const + { + return (SALOMEDSImpl_DataMapNodeOfDataMapStringLabel *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel)(); + + Standard_EXPORT static const Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDSImpl/Makefile.in b/src/SALOMEDSImpl/Makefile.in new file mode 100644 index 000000000..975e04332 --- /dev/null +++ b/src/SALOMEDSImpl/Makefile.in @@ -0,0 +1,141 @@ +# File : Makefile.in +# Author : Sergey RUIN +# Module : SALOME + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_srcdir)/idl + + +@COMMENCE@ + +EXPORT_HEADERS= \ + SALOMEDSImpl_Attributes.hxx \ + SALOMEDSImpl_SObject.hxx \ + SALOMEDSImpl_SComponent.hxx \ + SALOMEDSImpl_Driver.hxx \ + SALOMEDSImpl_Callback.hxx \ + SALOMEDSImpl_GenericAttribute.hxx \ + SALOMEDSImpl_AttributeIOR.hxx \ + SALOMEDSImpl_AttributeExternalFileDef.hxx \ + SALOMEDSImpl_AttributeFileType.hxx \ + SALOMEDSImpl_AttributePersistentRef.hxx \ + SALOMEDSImpl_AttributeSequenceOfReal.hxx \ + SALOMEDSImpl_AttributeSequenceOfInteger.hxx \ + SALOMEDSImpl_AttributeDrawable.hxx \ + SALOMEDSImpl_AttributeSelectable.hxx \ + SALOMEDSImpl_AttributeExpandable.hxx \ + SALOMEDSImpl_AttributeOpened.hxx \ + SALOMEDSImpl_AttributeFlags.hxx \ + SALOMEDSImpl_AttributeGraphic.hxx \ + SALOMEDSImpl_AttributeTextColor.hxx \ + SALOMEDSImpl_AttributeTextHighlightColor.hxx \ + SALOMEDSImpl_AttributePixMap.hxx \ + SALOMEDSImpl_AttributeLocalID.hxx \ + SALOMEDSImpl_AttributeTarget.hxx \ + SALOMEDSImpl_AttributeTableOfInteger.hxx \ + SALOMEDSImpl_AttributeTableOfReal.hxx \ + SALOMEDSImpl_AttributeTableOfString.hxx \ + SALOMEDSImpl_AttributeStudyProperties.hxx \ + SALOMEDSImpl_AttributePythonObject.hxx \ + SALOMEDSImpl_AttributeReal.hxx \ + SALOMEDSImpl_AttributeInteger.hxx \ + SALOMEDSImpl_AttributeUserID.hxx \ + SALOMEDSImpl_AttributeTreeNode.hxx \ + SALOMEDSImpl_AttributeName.hxx \ + SALOMEDSImpl_AttributeComment.hxx \ + SALOMEDSImpl_AttributeReference.hxx \ + SALOMEDSImpl_UseCaseBuilder.hxx \ + SALOMEDSImpl_UseCaseIterator.hxx \ + SALOMEDSImpl_SComponentIterator.hxx \ + SALOMEDSImpl_StudyBuilder.hxx \ + SALOMEDSImpl_Study.hxx \ + SALOMEDSImpl_StudyManager.hxx \ + SALOMEDSImpl_OCAFApplication.hxx \ + SALOMEDSImpl_DataMapStringLabel.hxx \ + SALOMEDSImpl_DataMapOfIntegerString.hxx \ + SALOMEDSImpl_ChildNodeIterator.hxx \ + Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx \ + Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx + +LIB_CLIENT_IDL = +LIB_SERVER_IDL = + +# Executables targets +BIN = testDS +BIN_SRC = +BIN_CLIENT_IDL = +BIN_SERVER_IDL = + +# Libraries targets + +LIB = libSalomeDSImpl.la +LIB_SRC = SALOMEDSImpl_Tool.cxx \ + SALOMEDSImpl_Callback.cxx \ + SALOMEDSImpl_StudyHandle.cxx \ + SALOMEDSImpl_GenericAttribute.cxx \ + SALOMEDSImpl_SObject.cxx \ + SALOMEDSImpl_SComponent.cxx \ + SALOMEDSImpl_OCAFApplication.cxx \ + SALOMEDSImpl_AttributeIOR.cxx \ + SALOMEDSImpl_AttributeExternalFileDef.cxx \ + SALOMEDSImpl_AttributeFileType.cxx \ + SALOMEDSImpl_AttributePersistentRef.cxx \ + SALOMEDSImpl_AttributeSequenceOfReal.cxx \ + SALOMEDSImpl_AttributeSequenceOfInteger.cxx \ + SALOMEDSImpl_AttributeDrawable.cxx \ + SALOMEDSImpl_AttributeSelectable.cxx \ + SALOMEDSImpl_AttributeExpandable.cxx \ + SALOMEDSImpl_AttributeOpened.cxx \ + SALOMEDSImpl_AttributeFlags.cxx \ + SALOMEDSImpl_AttributeGraphic.cxx \ + SALOMEDSImpl_AttributeTextColor.cxx \ + SALOMEDSImpl_AttributeTextHighlightColor.cxx \ + SALOMEDSImpl_AttributePixMap.cxx \ + SALOMEDSImpl_AttributeLocalID.cxx \ + SALOMEDSImpl_AttributeTarget.cxx \ + SALOMEDSImpl_AttributeTableOfInteger.cxx \ + SALOMEDSImpl_AttributeTableOfReal.cxx \ + SALOMEDSImpl_AttributeTableOfString.cxx \ + SALOMEDSImpl_AttributeStudyProperties.cxx \ + SALOMEDSImpl_AttributePythonObject.cxx \ + SALOMEDSImpl_AttributeReal.cxx \ + SALOMEDSImpl_AttributeInteger.cxx \ + SALOMEDSImpl_AttributeUserID.cxx \ + SALOMEDSImpl_AttributeTreeNode.cxx \ + SALOMEDSImpl_AttributeName.cxx \ + SALOMEDSImpl_AttributeComment.cxx \ + SALOMEDSImpl_AttributeReference.cxx \ + SALOMEDSImpl_ChildNodeIterator.cxx \ + SALOMEDSImpl_DataMapOfIntegerString_0.cxx \ + SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString_0.cxx \ + SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_0.cxx \ + SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel_0.cxx \ + SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_0.cxx \ + SALOMEDSImpl_DataMapStringLabel_0.cxx \ + SALOMEDSImpl_UseCaseBuilder.cxx \ + SALOMEDSImpl_UseCaseIterator.cxx \ + SALOMEDSImpl_SComponentIterator.cxx \ + SALOMEDSImpl_StudyBuilder.cxx \ + SALOMEDSImpl_Study.cxx \ + SALOMEDSImpl_StudyManager.cxx + + + +CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES) +CXXFLAGS+=$(OCC_CXXFLAGS) +LDFLAGS+= $(HDF5_LIBS) -lSalomeHDFPersist $(CAS_LDPATH) -lTKCAF -lTKBO -lTKStdSchema -lTKernel + +# _CS_gbo_090604 Ajout Spécifique Calibre 3, pour l'utilisation de la version 5.12 de la bibliothèque OCC. +# La bibliothèque OCC5.12 a été compilée sur Calibre 3 avec l'extention Xmu (impossible de compiler sans). +# On est donc obligé ici, pour permettre l'édition de lien avec les bibliothèques OCC, de spécifier le +# chemin d'accès aux bibliothèques Xmu +# +LDXMUFLAGS= -L/usr/X11R6/lib -lXmu +LDFLAGS+=$(LDXMUFLAGS) + + +@CONCLUDE@ + + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.cxx new file mode 100644 index 000000000..403d1ee67 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.cxx @@ -0,0 +1,83 @@ +// File : SALOMEDSImpl_AttributeComment.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeComment.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeComment, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeComment, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeComment::GetID () +{ + static Standard_GUID CommentID ("7AF2F7CC-1CA2-4476-BE95-8ACC996BC7B9"); + return CommentID; +} + +Handle(SALOMEDSImpl_AttributeComment) SALOMEDSImpl_AttributeComment::Set (const TDF_Label& L, + const TCollection_ExtendedString& Val) +{ + Handle(SALOMEDSImpl_AttributeComment) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), A)) { + A = new SALOMEDSImpl_AttributeComment(); + L.AddAttribute(A); + } + + A->Set(Val); + return A; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeComment::Set (const TCollection_ExtendedString& S) +{ + CheckLocked(); + + if(myString == S) return; + + Backup(); + + myString = S; +} + + +//======================================================================= +//function : ID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeComment::ID () const { return GetID(); } + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= +Handle(TDF_Attribute) SALOMEDSImpl_AttributeComment::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeComment(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeComment::Restore(const Handle(TDF_Attribute)& with) +{ + myString = Handle(SALOMEDSImpl_AttributeComment)::DownCast (with)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeComment::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeComment)::DownCast (into)->Set(myString); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.hxx new file mode 100644 index 000000000..ba6c7a6a6 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.hxx @@ -0,0 +1,51 @@ +// File : SALOMEDSImpl_AttributeIOR.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeComment_HeaderFile +#define _SALOMEDSImpl_AttributeComment_HeaderFile + +#include +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeComment, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeComment : public SALOMEDSImpl_GenericAttribute +{ +private: + + TCollection_ExtendedString myString; + +public: + +Standard_EXPORT static const Standard_GUID& GetID() ; + +Standard_EXPORT SALOMEDSImpl_AttributeComment() :SALOMEDSImpl_GenericAttribute("AttributeComment") {} + +Standard_EXPORT static Handle(SALOMEDSImpl_AttributeComment) Set(const TDF_Label& L, const TCollection_ExtendedString& Val); +Standard_EXPORT void Set (const TCollection_ExtendedString& S); +Standard_EXPORT TCollection_ExtendedString Get() const { return myString; } + +Standard_EXPORT virtual TCollection_AsciiString Save() { return myString; } +Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue) { myString = 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_AttributeComment() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeComment ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.cxx new file mode 100644 index 000000000..5e059ecfd --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.cxx @@ -0,0 +1,103 @@ +// File : SALOMEDSImpl_AttributeDrawable.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeDrawable.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeDrawable, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeDrawable, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeDrawable::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeDrawableID ("12837184-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeDrawableID; +} + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDSImpl_AttributeDrawable) SALOMEDSImpl_AttributeDrawable::Set (const TDF_Label& L, + const Standard_Integer value) +{ + Handle(SALOMEDSImpl_AttributeDrawable) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeDrawable::GetID(),A)) { + A = new SALOMEDSImpl_AttributeDrawable(); + L.AddAttribute(A); + } + + A->Set (value); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeDrawable::SALOMEDSImpl_AttributeDrawable() +:SALOMEDSImpl_GenericAttribute("AttributeDrawable") +{ + myValue = 0; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeDrawable::Set(const Standard_Integer theValue) +{ + CheckLocked(); + + Backup(); + + (theValue!=0)?myValue=1:myValue=0; +} + + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeDrawable::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeDrawable::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeDrawable(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeDrawable::Restore(const Handle(TDF_Attribute)& with) +{ + myValue = Handle(SALOMEDSImpl_AttributeDrawable)::DownCast (with)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeDrawable::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeDrawable)::DownCast (into)->Set (myValue); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.hxx new file mode 100644 index 000000000..cec1f2fc4 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.hxx @@ -0,0 +1,48 @@ +// File : SALOMEDSImpl_AttributeDrawable.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeDrawable_HeaderFile +#define _SALOMEDSImpl_AttributeDrawable_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeDrawable, SALOMEDSImpl_GenericAttribute ) + + +class SALOMEDSImpl_AttributeDrawable : public SALOMEDSImpl_GenericAttribute +{ +private: +Standard_Integer myValue; + +public: +Standard_EXPORT virtual TCollection_AsciiString Save() { return (myValue == 0)?(char*)"0":(char*)"1"; } +Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue) { (theValue == "0")?myValue=0:myValue=1; } + +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeDrawable Set(const TDF_Label& label,const Standard_Integer value) ; + +Standard_EXPORT void Set(const Standard_Integer theValue); +Standard_EXPORT Standard_Integer Get() const { return myValue; } +Standard_EXPORT SALOMEDSImpl_AttributeDrawable(); +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_AttributeDrawable() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeDrawable ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.cxx new file mode 100644 index 000000000..82fc82b79 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.cxx @@ -0,0 +1,102 @@ +// File : SALOMEDSImpl_AttributeExpandable.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeExpandable.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeExpandable, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeExpandable, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeExpandable::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeExpandableID ("12837185-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeExpandableID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +Handle(SALOMEDSImpl_AttributeExpandable) SALOMEDSImpl_AttributeExpandable::Set (const TDF_Label& L, + const Standard_Integer value) +{ + Handle(SALOMEDSImpl_AttributeExpandable) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeExpandable::GetID(),A)) { + A = new SALOMEDSImpl_AttributeExpandable(); + L.AddAttribute(A); + } + + A->Set(value); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeExpandable::SALOMEDSImpl_AttributeExpandable() +:SALOMEDSImpl_GenericAttribute("AttributeExpandable") +{ + myValue = 0; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeExpandable::Set(const Standard_Integer theValue) +{ + CheckLocked(); + + Backup(); + + (theValue!=0)?myValue=1:myValue=0; +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeExpandable::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeExpandable::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeExpandable(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeExpandable::Restore(const Handle(TDF_Attribute)& with) +{ + myValue = Handle(SALOMEDSImpl_AttributeExpandable)::DownCast (with)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeExpandable::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeExpandable)::DownCast (into)->Set (myValue); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.hxx new file mode 100644 index 000000000..4f6a360f0 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.hxx @@ -0,0 +1,47 @@ +// File : SALOMEDSImpl_AttributeExpandable.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeExpandable_HeaderFile +#define _SALOMEDSImpl_AttributeExpandable_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeExpandable, SALOMEDSImpl_GenericAttribute ) + + +class SALOMEDSImpl_AttributeExpandable : public SALOMEDSImpl_GenericAttribute +{ +private: +Standard_Integer myValue; + +public: + +Standard_EXPORT virtual TCollection_AsciiString Save() { return (Get() == 0)?(char*)"0":(char*)"1"; } +Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue) { (theValue == "0")?myValue=0:myValue=1; } + +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeExpandable Set(const TDF_Label& label,const Standard_Integer value) ; +Standard_EXPORT SALOMEDSImpl_AttributeExpandable(); +Standard_EXPORT void Set(const Standard_Integer value); +Standard_EXPORT int Get() const { return myValue; } +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_AttributeExpandable() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeExpandable ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.cxx new file mode 100644 index 000000000..5b4a1dd72 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.cxx @@ -0,0 +1,102 @@ +// File : SALOMEDSImpl_AttributeExternalFileDef.cxx +// Author : Sergey RUIN +// Module : SALOME + +#include "SALOMEDSImpl_AttributeExternalFileDef.hxx" + +using namespace std; + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeExternalFileDef, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeExternalFileDef, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeExternalFileDef::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeExternalFileDefID ("7123AD4C-ACDB-4e3a-8FDC-70EA164D2CBE"); + return SALOMEDSImpl_AttributeExternalFileDefID; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +Handle(SALOMEDSImpl_AttributeExternalFileDef) +SALOMEDSImpl_AttributeExternalFileDef::Set (const TDF_Label& L, const TCollection_ExtendedString& S) +{ + + Handle(SALOMEDSImpl_AttributeExternalFileDef) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeExternalFileDef::GetID(),A)) { + A = new SALOMEDSImpl_AttributeExternalFileDef(); + L.AddAttribute(A); + } + + A->Set (S); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeExternalFileDef::SALOMEDSImpl_AttributeExternalFileDef() +:SALOMEDSImpl_GenericAttribute("AttributeExternalFileDef") +{ +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeExternalFileDef::Set (const TCollection_ExtendedString& S) +{ + CheckLocked(); + + if(myString == S) return; + + Backup(); + + myString = S; +} + + + +//======================================================================= +//function : ID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeExternalFileDef::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= +Handle(TDF_Attribute) SALOMEDSImpl_AttributeExternalFileDef::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeExternalFileDef(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeExternalFileDef::Restore(const Handle(TDF_Attribute)& with) +{ + myString = Handle(SALOMEDSImpl_AttributeExternalFileDef)::DownCast (with)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeExternalFileDef::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeExternalFileDef) anAttr = Handle(SALOMEDSImpl_AttributeExternalFileDef)::DownCast(into); + anAttr->Set(myString); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.hxx new file mode 100644 index 000000000..954fc5428 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.hxx @@ -0,0 +1,41 @@ + +#ifndef _SALOMEDSImpl_AttributeExternalFileDef_HeaderFile +#define _SALOMEDSImpl_AttributeExternalFileDef_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeExternalFileDef, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeExternalFileDef : public SALOMEDSImpl_GenericAttribute +{ +private: + + TCollection_ExtendedString myString; + +public: +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeExternalFileDef Set(const TDF_Label& label, + const TCollection_ExtendedString& Name); +Standard_EXPORT SALOMEDSImpl_AttributeExternalFileDef(); +Standard_EXPORT void Set(const TCollection_ExtendedString& value); +Standard_EXPORT TCollection_ExtendedString Get() const { return myString; } +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_AttributeExternalFileDef() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeExternalFileDef ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.cxx new file mode 100644 index 000000000..0a0cbd72c --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.cxx @@ -0,0 +1,107 @@ +// File : SALOMEDSImpl_AttributeFileType.cxx +// Author : Sergey RUIN +// Module : SALOME + +#include "SALOMEDSImpl_AttributeFileType.hxx" + +using namespace std; + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeFileType, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeFileType, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeFileType::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeFileTypeID ("0181B525-3F15-4ab2-9DE3-5E2F54B5F340"); + return SALOMEDSImpl_AttributeFileTypeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDSImpl_AttributeFileType) SALOMEDSImpl_AttributeFileType::Set (const TDF_Label& L, + const TCollection_ExtendedString& S) +{ + + Handle(SALOMEDSImpl_AttributeFileType) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeFileType::GetID(),A)) { + A = new SALOMEDSImpl_AttributeFileType(); + L.AddAttribute(A); + } + + A->Set (S); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeFileType::SALOMEDSImpl_AttributeFileType() +:SALOMEDSImpl_GenericAttribute("AttributeFileType") +{ +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeFileType::Set (const TCollection_ExtendedString& S) +{ + CheckLocked(); + + if(myString == S) return; + + Backup(); + + myString = S; +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeFileType::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeFileType::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeFileType(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeFileType::Restore(const Handle(TDF_Attribute)& with) +{ + myString = Handle(SALOMEDSImpl_AttributeFileType)::DownCast (with)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeFileType::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeFileType)::DownCast (into)->Set (myString); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.hxx new file mode 100644 index 000000000..395e785f5 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.hxx @@ -0,0 +1,42 @@ + +#ifndef _SALOMEDSImpl_AttributeFileType_HeaderFile +#define _SALOMEDSImpl_AttributeFileType_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeFileType, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeFileType : public SALOMEDSImpl_GenericAttribute +{ +private: + + TCollection_ExtendedString myString; + +public: +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeFileType Set(const TDF_Label& label, + const TCollection_ExtendedString& Name) ; +Standard_EXPORT SALOMEDSImpl_AttributeFileType(); +Standard_EXPORT void Set(const TCollection_ExtendedString& value); +Standard_EXPORT TCollection_ExtendedString Get() const { return myString; } +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_AttributeFileType() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeFileType ) +}; + + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.cxx new file mode 100644 index 000000000..0406fef31 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.cxx @@ -0,0 +1,138 @@ +// File : SALOMEDSImpl_AttributeFlags.cxx +// Author : Sergey LITONIN +// Module : SALOME + +#include "SALOMEDSImpl_AttributeFlags.hxx" +#include + +using namespace std; + + +/* + Class : SALOMEDSImpl_AttributeFlags + Description : This class is intended for storing different object attributes that + have only two states (0 and 1). +*/ + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeFlags, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeFlags, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : SALOMEDSImpl_AttributeFlags::GetID +//purpose : Get GUID of this attribute +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeFlags::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeFlagsID( "866EEC9F-A517-4cb4-88E6-E208DB8FC96F" ); + return SALOMEDSImpl_AttributeFlagsID; +} + +//======================================================================= +//function : SALOMEDSImpl_AttributeFlags::Set +//purpose : Set value of the attribute +//======================================================================= +Handle(SALOMEDSImpl_AttributeFlags) SALOMEDSImpl_AttributeFlags::Set(const TDF_Label& L, + const Standard_Integer value ) +{ + Handle(SALOMEDSImpl_AttributeFlags) A; + if ( !L.FindAttribute(SALOMEDSImpl_AttributeFlags::GetID(),A ) ) + { + A = new SALOMEDSImpl_AttributeFlags(); + L.AddAttribute( A ); + } + + A->Set( value ); + return A; +} + +//======================================================================= +//function : SALOMEDSImpl_AttributeFlags::SALOMEDSImpl_AttributeFlags +//purpose : Constructor +//======================================================================= +SALOMEDSImpl_AttributeFlags::SALOMEDSImpl_AttributeFlags() +:SALOMEDSImpl_GenericAttribute("AttributeFlags") +{ + myValue = 0; +} + +SALOMEDSImpl_AttributeFlags::~SALOMEDSImpl_AttributeFlags() +{ +} + +//======================================================================= +//function : SALOMEDSImpl_AttributeFlags::ID +//purpose : Get GUID of this attribute +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeFlags::ID () const +{ + return GetID(); +} + +//======================================================================= +//function : SALOMEDSImpl_AttributeFlags::NewEmpty +//purpose : Create new empty attribute +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeFlags::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeFlags(); +} + +//======================================================================= +//function : SALOMEDSImpl_AttributeFlags::Restore +//purpose : Assign given value to the attribute +//======================================================================= +void SALOMEDSImpl_AttributeFlags::Restore( const Handle(TDF_Attribute)& with ) +{ + myValue = Handle(SALOMEDSImpl_AttributeFlags)::DownCast( with )->Get(); + return; +} + +//======================================================================= +//function : SALOMEDSImpl_AttributeFlags::Paste +//purpose : Assign internal value to the given attribute +//======================================================================= +void SALOMEDSImpl_AttributeFlags::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT ) const +{ + Handle(SALOMEDSImpl_AttributeFlags)::DownCast( into )->Set( myValue ); +} + +//======================================================================= +//function : SALOMEDSImpl_AttributeFlags::Set +//purpose : Set value +//======================================================================= +void SALOMEDSImpl_AttributeFlags::Set( const Standard_Integer v ) +{ + Backup(); + myValue=v; +} + +//======================================================================= +//function : SALOMEDSImpl_AttributeFlags::Get +//purpose : GetValue +//======================================================================= +Standard_Integer SALOMEDSImpl_AttributeFlags::Get() const +{ + return myValue; +} + + + + + + + + + + + + + + + + + + + + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.hxx new file mode 100644 index 000000000..a142b6be4 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.hxx @@ -0,0 +1,50 @@ +// File : SALOMEDSImpl_AttributeFlags.hxx +// Author : Sergey LITONIN +// Module : SALOME + +#ifndef SALOMEDSImpl_AttributeFlags_HeaderFile +#define SALOMEDSImpl_AttributeFlags_HeaderFile + +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +/* + Class : SALOMEDSImpl_AttributeFlags + Description : This class is intended for storing different object attributes that + have only two states (0 and 1). +*/ + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeFlags, SALOMEDSImpl_GenericAttribute ) + +class Standard_EXPORT SALOMEDSImpl_AttributeFlags : public SALOMEDSImpl_GenericAttribute +{ +private: +Standard_Integer myValue; + +public: +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle(SALOMEDSImpl_AttributeFlags) Set(const TDF_Label&, const Standard_Integer ); + + SALOMEDSImpl_AttributeFlags(); +Standard_EXPORT virtual ~SALOMEDSImpl_AttributeFlags(); + +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 void Set( const Standard_Integer ); +Standard_EXPORT Standard_Integer Get() const; + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeFlags ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.cxx new file mode 100644 index 000000000..062a6c75b --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.cxx @@ -0,0 +1,161 @@ +// File : SALOMEDSImpl_AttributeGraphic.cxx +// Author : Sergey LITONIN +// Module : SALOME + +#include "SALOMEDSImpl_AttributeGraphic.hxx" +#include +#include +#include + +/* + Class : SALOMEDSImpl_AttributeGraphic + Description : This class is intended for storing information about + graphic representation of objects in dirrent views +*/ + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeGraphic, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeGraphic, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : Get GUID of this attribute +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeGraphic::GetID() +{ + static Standard_GUID SALOMEDSImpl_AttributeGraphicID( "F17AE8F0-E354-4d6f-8E42-38385C36E67E" ); + return SALOMEDSImpl_AttributeGraphicID; +} + +//======================================================================= +//function : SALOMEDSImpl_AttributeGraphic +//purpose : Empty Constructor +//======================================================================= +SALOMEDSImpl_AttributeGraphic::SALOMEDSImpl_AttributeGraphic() +:SALOMEDSImpl_GenericAttribute("AttributeGraphic") +{ +} + +//======================================================================= +//function : ~SALOMEDSImpl_AttributeGraphic +//purpose : Destructor +//======================================================================= +SALOMEDSImpl_AttributeGraphic::~SALOMEDSImpl_AttributeGraphic() +{ +} + +//======================================================================= +//function : SetVisibility +//purpose : Set visibility of object in given view +//======================================================================= +void SALOMEDSImpl_AttributeGraphic::SetVisibility(const Standard_Integer theViewId, + const Standard_Boolean theValue ) +{ + if ( myVisibility.IsBound( theViewId ) && myVisibility( theViewId ) == theValue ) + return; + + Backup(); + if ( myVisibility.IsBound( theViewId ) ) + myVisibility.ChangeFind( theViewId ) = theValue ? 1 : 0; + else + myVisibility.Bind( theViewId, theValue ? 1 : 0 ); +} + + +//======================================================================= +//function : Get +//purpose : Get visibility of object in given view +//======================================================================= +Standard_Boolean SALOMEDSImpl_AttributeGraphic::GetVisibility(const Standard_Integer theViewId ) const +{ + return myVisibility.IsBound( theViewId ) ? myVisibility( theViewId ) : false; +} + + +//======================================================================= +//function : ID +//purpose : Get GUID of this attribute +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeGraphic::ID () const +{ + return GetID(); +} + + +//======================================================================= +//function : NewEmpty +//purpose : Create new empty attribute +//======================================================================= +Handle(TDF_Attribute) SALOMEDSImpl_AttributeGraphic::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeGraphic (); +} + +//======================================================================= +//function : SetVisibility +//purpose : Set visibility of object in all views +//======================================================================= +void SALOMEDSImpl_AttributeGraphic::SetVisibility( const TColStd_DataMapOfIntegerInteger& theMap ) +{ + myVisibility = theMap; +} + +//======================================================================= +//function : SetVisibility +//purpose : Get visibility of object in all views +//======================================================================= +const TColStd_DataMapOfIntegerInteger& SALOMEDSImpl_AttributeGraphic::GetVisibility() +{ + return myVisibility; +} + +//======================================================================= +//function : Restore +//purpose : Restore value of attribute with value of theWith one +//======================================================================= +void SALOMEDSImpl_AttributeGraphic::Restore( const Handle(TDF_Attribute)& theWith ) +{ + Handle(SALOMEDSImpl_AttributeGraphic) anAttr = + Handle(SALOMEDSImpl_AttributeGraphic)::DownCast( theWith ); + + if ( !anAttr.IsNull() ) + SetVisibility( anAttr->GetVisibility() ); +} + +//======================================================================= +//function : Paste +//purpose : Paste value of current attribute to the value of entry one +//======================================================================= +void SALOMEDSImpl_AttributeGraphic::Paste( const Handle(TDF_Attribute)& theInto, + const Handle(TDF_RelocationTable)& ) const +{ + Handle(SALOMEDSImpl_AttributeGraphic) anAttr = + Handle(SALOMEDSImpl_AttributeGraphic)::DownCast( theInto ); + + if ( !anAttr.IsNull() ) + anAttr->SetVisibility( myVisibility ); +} + +//======================================================================= +//function : Dump +//purpose : Dump +//======================================================================= +Standard_OStream& SALOMEDSImpl_AttributeGraphic::Dump( Standard_OStream& anOS ) const +{ + anOS << "Visibility of object:" << endl; + TColStd_DataMapIteratorOfDataMapOfIntegerInteger anIter( myVisibility ); + for ( ; anIter.More(); anIter.Next() ) + { + char str[ 100 ]; + + if ( GetVisibility( anIter.Key() ) ) + sprintf( str, "Viewer ID = 0x%X State = VISIBLE\n", anIter.Key() ); + else + sprintf( str, "Viewer ID = 0x%X State = INVISIBLE\n", anIter.Key() ); + + anOS << str; + } + + anOS << "Integer"; + return anOS; +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.hxx new file mode 100644 index 000000000..4e958a9ab --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.hxx @@ -0,0 +1,58 @@ +// File : SALOMEDSImpl_AttributeGraphic.hxx +// Author : Sergey LITONIN +// Module : SALOME + +#ifndef SALOMEDSImpl_AttributeGraphic_HeaderFile +#define SALOMEDSImpl_AttributeGraphic_HeaderFile + +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + +/* + Class : SALOMEDSImpl_AttributeGraphic + Description : This class is intended for storing information about + graphic representation of objects in dirrent views +*/ + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeGraphic, SALOMEDSImpl_GenericAttribute) + + + +class Standard_EXPORT SALOMEDSImpl_AttributeGraphic : public SALOMEDSImpl_GenericAttribute +{ + +public: +Standard_EXPORT SALOMEDSImpl_AttributeGraphic(); +Standard_EXPORT ~SALOMEDSImpl_AttributeGraphic(); + +Standard_EXPORT static const Standard_GUID& GetID() ; + +Standard_EXPORT void SetVisibility( const Standard_Integer, + const Standard_Boolean ); +Standard_EXPORT Standard_Boolean GetVisibility( const Standard_Integer ) const; +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore( const Handle(TDF_Attribute)& theWith ); +Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const; +Standard_EXPORT void Paste( const Handle(TDF_Attribute)& theInto, + const Handle(TDF_RelocationTable)& ) const; +Standard_EXPORT virtual Standard_OStream& Dump( Standard_OStream& anOS ) const; + +Standard_EXPORT void SetVisibility( const TColStd_DataMapOfIntegerInteger& ); + +Standard_EXPORT const TColStd_DataMapOfIntegerInteger& GetVisibility(); + +private: + TColStd_DataMapOfIntegerInteger myVisibility; + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeGraphic ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx new file mode 100644 index 000000000..0ee05dc2b --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx @@ -0,0 +1,122 @@ +// File : SALOMEDSImpl_AttributeIOR.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeIOR.hxx" +#include +#include "SALOMEDSImpl_Study.hxx" +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeIOR, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeIOR, SALOMEDSImpl_GenericAttribute ) + + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeIOR::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeIORID ("92888E01-7074-11d5-A690-0800369C8A03"); + return SALOMEDSImpl_AttributeIORID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDSImpl_AttributeIOR) SALOMEDSImpl_AttributeIOR::Set (const TDF_Label& L, + const TCollection_ExtendedString& S) +{ + Handle(SALOMEDSImpl_AttributeIOR) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(),A)) { + A = new SALOMEDSImpl_AttributeIOR(); + L.AddAttribute(A); + } + + A->SetValue(S); + SALOMEDSImpl_Study::IORUpdated(A); + return A; +} + +//======================================================================= +//function : SetValue +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeIOR::SetValue(const TCollection_ExtendedString& theValue) +{ + CheckLocked(); + + Handle(SALOMEDSImpl_Study) aStudy = SALOMEDSImpl_Study::GetStudy(Label()); + aStudy->AddCreatedPostponed(theValue); + aStudy->AddPostponed(theValue); + + Backup(); + myString = theValue; + + SALOMEDSImpl_Study::IORUpdated(this); +} + +//======================================================================= +//function : Value +//purpose : +//======================================================================= +TCollection_ExtendedString SALOMEDSImpl_AttributeIOR::Value() const +{ + return myString; +} + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeIOR::SALOMEDSImpl_AttributeIOR() +:SALOMEDSImpl_GenericAttribute("AttributeIOR") +{ +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeIOR::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeIOR::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeIOR(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeIOR::Restore(const Handle(TDF_Attribute)& with) +{ + myString = Handle(SALOMEDSImpl_AttributeIOR)::DownCast (with)->Value(); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeIOR::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeIOR)::DownCast (into)->SetValue(myString); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.hxx new file mode 100644 index 000000000..692701f9a --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.hxx @@ -0,0 +1,45 @@ +// File : SALOMEDSImpl_AttributeIOR.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeIOR_HeaderFile +#define _SALOMEDSImpl_AttributeIOR_HeaderFile + +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeIOR, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeIOR : public SALOMEDSImpl_GenericAttribute +{ +private: + + TCollection_ExtendedString myString; + +public: + +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeIOR Set(const TDF_Label& label, + const TCollection_ExtendedString& string); +Standard_EXPORT SALOMEDSImpl_AttributeIOR(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void SetValue(const TCollection_ExtendedString& theValue); +Standard_EXPORT TCollection_ExtendedString Value() 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_AttributeIOR() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeIOR ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx new file mode 100644 index 000000000..e3db67af1 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx @@ -0,0 +1,79 @@ +// File : SALOMEDSImpl_AttributeInteger.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeInteger.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeInteger, SALOMEDSImpl_GenericAttribute) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeInteger, SALOMEDSImpl_GenericAttribute ) + + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeInteger::GetID () +{ + static Standard_GUID IntegerID ("8CC3E213-C9B4-47e4-8496-DD5E62E22018"); + return IntegerID; +} + +Handle(SALOMEDSImpl_AttributeInteger) SALOMEDSImpl_AttributeInteger::Set (const TDF_Label& L, Standard_Integer Val) +{ + Handle(SALOMEDSImpl_AttributeInteger) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), A)) { + A = new SALOMEDSImpl_AttributeInteger(); + L.AddAttribute(A); + } + + A->Set(Val); + return A; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeInteger::Set(const Standard_Integer v) +{ + if(myValue == v) return; + + Backup(); + myValue = v; +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeInteger::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= +Handle(TDF_Attribute) SALOMEDSImpl_AttributeInteger::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeInteger(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeInteger::Restore(const Handle(TDF_Attribute)& With) +{ + myValue = Handle(SALOMEDSImpl_AttributeInteger)::DownCast (With)->Get(); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeInteger::Paste (const Handle(TDF_Attribute)& Into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeInteger)::DownCast(Into)->Set(myValue); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.hxx new file mode 100644 index 000000000..4f31946ac --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.hxx @@ -0,0 +1,48 @@ +// File : SALOMEDSImpl_AttributeInteger.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeInteger_HeaderFile +#define _SALOMEDSImpl_AttributeInteger_HeaderFile + +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeInteger, SALOMEDSImpl_GenericAttribute ) + + +class SALOMEDSImpl_AttributeInteger : public SALOMEDSImpl_GenericAttribute +{ +private: +Standard_Integer myValue; + +public: +Standard_EXPORT static const Standard_GUID& GetID() ; + +Standard_EXPORT SALOMEDSImpl_AttributeInteger():SALOMEDSImpl_GenericAttribute("AttributeInteger") {} +Standard_EXPORT static Handle(SALOMEDSImpl_AttributeInteger) Set (const TDF_Label& L, Standard_Integer Val); +Standard_EXPORT void Set(const Standard_Integer theVal); +Standard_EXPORT Standard_Integer Get() const { return myValue; } +Standard_EXPORT virtual TCollection_AsciiString Save() { return TCollection_AsciiString(myValue); } +Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue) { myValue = theValue.IntegerValue(); } + +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_AttributeInteger() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeInteger ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.cxx new file mode 100644 index 000000000..59489e809 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.cxx @@ -0,0 +1,106 @@ +// File : SALOMEDSImpl_AttributeLocalID.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeLocalID.hxx" +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeLocalID, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeLocalID, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeLocalID::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeLocalID ("12837196-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeLocalID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDSImpl_AttributeLocalID) SALOMEDSImpl_AttributeLocalID::Set (const TDF_Label& L, + const Standard_Integer value) +{ + Handle(SALOMEDSImpl_AttributeLocalID) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeLocalID::GetID(),A)) { + A = new SALOMEDSImpl_AttributeLocalID(); + L.AddAttribute(A); + } + + A->SetValue(value); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeLocalID::SALOMEDSImpl_AttributeLocalID() +:SALOMEDSImpl_GenericAttribute("AttributeLocalID") +{ + myValue = 0; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeLocalID::SetValue(const Standard_Integer theValue) +{ + CheckLocked(); + + Backup(); + + myValue = theValue; +} + + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeLocalID::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeLocalID::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeLocalID(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeLocalID::Restore(const Handle(TDF_Attribute)& with) +{ + myValue = Handle(SALOMEDSImpl_AttributeLocalID)::DownCast (with)->Value(); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeLocalID::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeLocalID)::DownCast (into)->SetValue(myValue); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.hxx new file mode 100644 index 000000000..78dadd861 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.hxx @@ -0,0 +1,48 @@ +// File : SALOMEDSImpl_AttributeLocalID.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeLocalID_HeaderFile +#define _SALOMEDSImpl_AttributeLocalID_HeaderFile + +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeLocalID, SALOMEDSImpl_GenericAttribute ) + + + +class SALOMEDSImpl_AttributeLocalID : public SALOMEDSImpl_GenericAttribute +{ +private: +Standard_Integer myValue; + +public: + +Standard_EXPORT virtual TCollection_AsciiString Save() { return TCollection_AsciiString(myValue); } +Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue) { myValue = theValue.IntegerValue(); } + +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeLocalID Set(const TDF_Label& label,const Standard_Integer value) ; +Standard_EXPORT void SetValue(const Standard_Integer value); +Standard_EXPORT Standard_Integer Value() const { return myValue; } +Standard_EXPORT SALOMEDSImpl_AttributeLocalID(); +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_AttributeLocalID() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeLocalID ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.cxx new file mode 100644 index 000000000..934f9d3df --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.cxx @@ -0,0 +1,83 @@ +// File : SALOMEDSImpl_AttributeName.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeName.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeName, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeName, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeName::GetID () +{ + static Standard_GUID NameID ("8650000D-63A0-4651-B621-CC95C9308598"); + return NameID; +} + +Handle(SALOMEDSImpl_AttributeName) SALOMEDSImpl_AttributeName::Set (const TDF_Label& L, + const TCollection_ExtendedString& Val) +{ + Handle(SALOMEDSImpl_AttributeName) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), A)) { + A = new SALOMEDSImpl_AttributeName(); + L.AddAttribute(A); + } + + A->Set(Val); + return A; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeName::Set (const TCollection_ExtendedString& S) +{ + CheckLocked(); + + if(myString == S) return; + + Backup(); + + myString = S; +} + + +//======================================================================= +//function : ID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeName::ID () const { return GetID(); } + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= +Handle(TDF_Attribute) SALOMEDSImpl_AttributeName::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeName(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeName::Restore(const Handle(TDF_Attribute)& with) +{ + myString = Handle(SALOMEDSImpl_AttributeName)::DownCast (with)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeName::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeName)::DownCast (into)->Set(myString); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.hxx new file mode 100644 index 000000000..ff0889100 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.hxx @@ -0,0 +1,52 @@ +// File : SALOMEDSImpl_AttributeIOR.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeName_HeaderFile +#define _SALOMEDSImpl_AttributeName_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeName, SALOMEDSImpl_GenericAttribute ) + + +class SALOMEDSImpl_AttributeName : public SALOMEDSImpl_GenericAttribute +{ + +private: + + TCollection_ExtendedString myString; + +public: +Standard_EXPORT static const Standard_GUID& GetID() ; + +Standard_EXPORT SALOMEDSImpl_AttributeName():SALOMEDSImpl_GenericAttribute("AttributeName") {} +Standard_EXPORT static Handle(SALOMEDSImpl_AttributeName) Set (const TDF_Label& L, const TCollection_ExtendedString& Val); +Standard_EXPORT void Set(const TCollection_ExtendedString& theVal); +Standard_EXPORT TCollection_ExtendedString Get() const { return myString; } + +Standard_EXPORT virtual TCollection_AsciiString Save() { return myString; } +Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue) { myString = 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_AttributeName() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeName ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.cxx new file mode 100644 index 000000000..846285041 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.cxx @@ -0,0 +1,103 @@ +// File : SALOMEDSImpl_AttributeOpened.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeOpened.hxx" +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeOpened, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeOpened, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeOpened::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeOpenedID ("12837186-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeOpenedID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDSImpl_AttributeOpened) SALOMEDSImpl_AttributeOpened::Set (const TDF_Label& L, + const Standard_Integer value) +{ + Handle(SALOMEDSImpl_AttributeOpened) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeOpened::GetID(),A)) { + A = new SALOMEDSImpl_AttributeOpened(); + L.AddAttribute(A); + } + + A->Set (value); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeOpened::SALOMEDSImpl_AttributeOpened() +:SALOMEDSImpl_GenericAttribute("AttributeOpened") +{ + myValue = 0; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeOpened::Set(const Standard_Integer theValue) +{ + Backup(); + + (theValue!=0)?myValue=1:myValue=0; +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeOpened::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeOpened::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeOpened(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeOpened::Restore(const Handle(TDF_Attribute)& with) +{ + myValue = Handle(SALOMEDSImpl_AttributeOpened)::DownCast (with)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeOpened::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeOpened)::DownCast (into)->Set (myValue); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.hxx new file mode 100644 index 000000000..f5cb585a6 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.hxx @@ -0,0 +1,46 @@ +// File : SALOMEDSImpl_AttributeOpened.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeOpened_HeaderFile +#define _SALOMEDSImpl_AttributeOpened_HeaderFile + +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeOpened, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeOpened : public SALOMEDSImpl_GenericAttribute +{ +private: +Standard_Integer myValue; + +public: + +Standard_EXPORT virtual TCollection_AsciiString Save() { return (myValue == 0)?(char*)"0":(char*)"1"; } +Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue) { (theValue == "0")?myValue=0:myValue=1; } + +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeOpened Set(const TDF_Label& label,const Standard_Integer value) ; +Standard_EXPORT SALOMEDSImpl_AttributeOpened(); +Standard_EXPORT void Set(const Standard_Integer value); +Standard_EXPORT int Get() const { return myValue; } +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_AttributeOpened() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeOpened ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.cxx new file mode 100644 index 000000000..e07d6d300 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.cxx @@ -0,0 +1,106 @@ +// File : SALOMEDSImpl_AttributePersistentRef.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributePersistentRef.hxx" +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributePersistentRef, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributePersistentRef, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributePersistentRef::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributePersistentRefID ("92888E06-7074-11d5-A690-0800369C8A03"); + return SALOMEDSImpl_AttributePersistentRefID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDSImpl_AttributePersistentRef) SALOMEDSImpl_AttributePersistentRef::Set (const TDF_Label& L, + const TCollection_ExtendedString& S) +{ + Handle(SALOMEDSImpl_AttributePersistentRef) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributePersistentRef::GetID(),A)) { + A = new SALOMEDSImpl_AttributePersistentRef(); + L.AddAttribute(A); + } + + A->Set (S); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributePersistentRef::SALOMEDSImpl_AttributePersistentRef() +:SALOMEDSImpl_GenericAttribute("AttributePersistentRef") +{ +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributePersistentRef::ID () const { return GetID(); } + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributePersistentRef::Set (const TCollection_ExtendedString& S) +{ + CheckLocked(); + + if(myString == S) return; + + Backup(); + + myString = S; +} + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributePersistentRef::NewEmpty () const +{ + return new SALOMEDSImpl_AttributePersistentRef(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributePersistentRef::Restore(const Handle(TDF_Attribute)& with) +{ + myString = Handle(SALOMEDSImpl_AttributePersistentRef)::DownCast (with)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributePersistentRef::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributePersistentRef)::DownCast (into)->Set(myString); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.hxx new file mode 100644 index 000000000..406349e32 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.hxx @@ -0,0 +1,48 @@ +// File : SALOMEDSImpl_AttributePersistentRef.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributePersistentRef_HeaderFile +#define _SALOMEDSImpl_AttributePersistentRef_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributePersistentRef, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributePersistentRef : public SALOMEDSImpl_GenericAttribute +{ +private: + TCollection_ExtendedString myString; + +public: + +Standard_EXPORT virtual TCollection_AsciiString Save() { return myString; } +Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue) { myString = theValue; } + +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributePersistentRef Set(const TDF_Label& label, + const TCollection_ExtendedString& string) ; +Standard_EXPORT SALOMEDSImpl_AttributePersistentRef(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Set(const TCollection_ExtendedString& value); +Standard_EXPORT TCollection_ExtendedString Get() const { return myString; } +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_AttributePersistentRef() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributePersistentRef ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.cxx new file mode 100644 index 000000000..013c95168 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.cxx @@ -0,0 +1,108 @@ +// File : SALOMEDSImpl_AttributePixMap.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributePixMap.hxx" +#include +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributePixMap, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributePixMap, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributePixMap::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributePixMapID ("12837187-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributePixMapID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDSImpl_AttributePixMap) SALOMEDSImpl_AttributePixMap::Set (const TDF_Label& L, + const TCollection_ExtendedString& S) +{ + Handle(SALOMEDSImpl_AttributePixMap) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributePixMap::GetID(),A)) { + A = new SALOMEDSImpl_AttributePixMap(); + L.AddAttribute(A); + } + + A->Set (S); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributePixMap::SALOMEDSImpl_AttributePixMap() +:SALOMEDSImpl_GenericAttribute("AttributePixMap") +{ + myString = "None"; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributePixMap::Set (const TCollection_ExtendedString& S) +{ + CheckLocked(); + + if(myString == S) return; + + Backup(); + + myString = S; +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributePixMap::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributePixMap::NewEmpty () const +{ + return new SALOMEDSImpl_AttributePixMap(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributePixMap::Restore(const Handle(TDF_Attribute)& with) +{ + myString = Handle(SALOMEDSImpl_AttributePixMap)::DownCast (with)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributePixMap::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributePixMap)::DownCast (into)->Set (myString); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.hxx new file mode 100644 index 000000000..6ccf4b3c9 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.hxx @@ -0,0 +1,50 @@ +// File : SALOMEDSImpl_AttributePixMap.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributePixMap_HeaderFile +#define _SALOMEDSImpl_AttributePixMap_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributePixMap, SALOMEDSImpl_GenericAttribute ) + + + +class SALOMEDSImpl_AttributePixMap : public SALOMEDSImpl_GenericAttribute +{ +private: + + TCollection_ExtendedString myString; +public: + +Standard_EXPORT virtual TCollection_AsciiString Save() { return myString; } +Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue) { myString = theValue; } + +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributePixMap Set(const TDF_Label& label, + const TCollection_ExtendedString& string) ; +Standard_EXPORT SALOMEDSImpl_AttributePixMap(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Set(const TCollection_ExtendedString& value); +Standard_EXPORT TCollection_ExtendedString Get() const { return myString; } +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_AttributePixMap() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributePixMap ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.cxx new file mode 100644 index 000000000..71b12bf0f --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.cxx @@ -0,0 +1,98 @@ +// File : SALOMEDSImpl_AttributePythonObject.cxx +// Author : Michael Ponikarov +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributePythonObject.hxx" +#include +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributePythonObject, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributePythonObject, SALOMEDSImpl_GenericAttribute ) + +const Standard_GUID& SALOMEDSImpl_AttributePythonObject::GetID() +{ + static Standard_GUID SALOMEDSImpl_AttributePythonObjectID ("128371A3-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributePythonObjectID; +} + +Handle(SALOMEDSImpl_AttributePythonObject) SALOMEDSImpl_AttributePythonObject::Set(const TDF_Label& label) +{ + Handle(SALOMEDSImpl_AttributePythonObject) anAttr; + if (!label.FindAttribute(SALOMEDSImpl_AttributePythonObject::GetID(),anAttr)) { + anAttr = new SALOMEDSImpl_AttributePythonObject(); + label.AddAttribute(anAttr); + } + return anAttr; +} + +SALOMEDSImpl_AttributePythonObject::SALOMEDSImpl_AttributePythonObject() +:SALOMEDSImpl_GenericAttribute("AttributePythonObject") +{ +} + +void SALOMEDSImpl_AttributePythonObject::SetObject(const TCollection_AsciiString& theSequence, + const bool theScript) +{ + CheckLocked(); + Backup(); + mySequence = theSequence; + myIsScript = theScript; +} + +TCollection_AsciiString SALOMEDSImpl_AttributePythonObject::GetObject() const +{ + return mySequence; +} + +bool SALOMEDSImpl_AttributePythonObject::IsScript() const +{ + return myIsScript; +} + +int SALOMEDSImpl_AttributePythonObject::GetLength() const +{ + return mySequence.Length(); +} + +const Standard_GUID& SALOMEDSImpl_AttributePythonObject::ID() const +{ + return GetID(); +} + +void SALOMEDSImpl_AttributePythonObject::Restore(const Handle(TDF_Attribute)& with) +{ + Handle(SALOMEDSImpl_AttributePythonObject) anObj = Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(with); + SetObject(anObj->GetObject(),anObj->IsScript()); +} + +Handle(TDF_Attribute) SALOMEDSImpl_AttributePythonObject::NewEmpty() const +{ + return new SALOMEDSImpl_AttributePythonObject(); +} + +void SALOMEDSImpl_AttributePythonObject::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)&) const +{ + Handle(SALOMEDSImpl_AttributePythonObject) anObj = Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(into); + anObj->SetObject(GetObject(),IsScript()); +} + + +TCollection_AsciiString SALOMEDSImpl_AttributePythonObject::Save() +{ + char* aString = (char*)GetObject().ToCString(); + char* aResult = new char[strlen(aString) + 2]; + aResult[0] = IsScript()?'s':'n'; + strcpy(aResult+1, aString); + TCollection_AsciiString ret(aResult); + + delete aResult; + return ret; +} + +void SALOMEDSImpl_AttributePythonObject::Load(const TCollection_AsciiString& value) +{ + char* aString = value.ToCString(); + SetObject(aString + 1, aString[0]=='s'); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.hxx new file mode 100644 index 000000000..460e3023e --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.hxx @@ -0,0 +1,54 @@ +// File : SALOMEDSImpl_AttributePythonObject.hxx +// Author : Michael Ponikarov +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributePythonObject_HeaderFile +#define _SALOMEDSImpl_AttributePythonObject_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributePythonObject, SALOMEDSImpl_GenericAttribute ) + + + +class SALOMEDSImpl_AttributePythonObject : public SALOMEDSImpl_GenericAttribute +{ + +public: +Standard_EXPORT virtual TCollection_AsciiString Save(); +Standard_EXPORT virtual void Load(const TCollection_AsciiString&); + +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributePythonObject Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDSImpl_AttributePythonObject(); +Standard_EXPORT void SetObject(const TCollection_AsciiString& theSequence, const bool theScript) ; +Standard_EXPORT TCollection_AsciiString GetObject() const; +Standard_EXPORT bool IsScript() const; +Standard_EXPORT int GetLength() const; +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_AttributePythonObject() {} + +private: + +TCollection_AsciiString mySequence; +bool myIsScript; + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributePythonObject ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.cxx new file mode 100644 index 000000000..daedd7619 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.cxx @@ -0,0 +1,82 @@ +// File : SALOMEDSImpl_AttributeReal.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeReal.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeReal, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeReal, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeReal::GetID () +{ + static Standard_GUID realID ("1D1992F0-56F4-46b4-8065-CDEA68061CAB"); + return realID; +} + +Handle(SALOMEDSImpl_AttributeReal) SALOMEDSImpl_AttributeReal::Set (const TDF_Label& L, const Standard_Real Val) +{ + Handle(SALOMEDSImpl_AttributeReal) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeReal::GetID(), A)) { + A = new SALOMEDSImpl_AttributeReal(); + L.AddAttribute(A); + } + + A->Set(Val); + return A; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeReal::Set(const Standard_Real v) +{ + CheckLocked(); + + if( myValue == v) return; + + Backup(); + myValue = v; +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeReal::ID () const +{ + return GetID(); +} + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= +Handle(TDF_Attribute) SALOMEDSImpl_AttributeReal::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeReal(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeReal::Restore(const Handle(TDF_Attribute)& with) +{ + myValue = Handle(SALOMEDSImpl_AttributeReal)::DownCast (with)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeReal::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeReal)::DownCast (into)->Set(myValue); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.hxx new file mode 100644 index 000000000..9e8fd9993 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.hxx @@ -0,0 +1,48 @@ +// File : SALOMEDSImpl_AttributeReal.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeReal_HeaderFile +#define _SALOMEDSImpl_AttributeReal_HeaderFile + +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeReal, SALOMEDSImpl_GenericAttribute ) + + +class SALOMEDSImpl_AttributeReal : public SALOMEDSImpl_GenericAttribute +{ +private: + Standard_Real myValue; +public: + +Standard_EXPORT Standard_EXPORT static const Standard_GUID& GetID() ; + +Standard_EXPORT SALOMEDSImpl_AttributeReal():SALOMEDSImpl_GenericAttribute("AttributeReal") {} +Standard_EXPORT static Handle(SALOMEDSImpl_AttributeReal) Set (const TDF_Label& L, const Standard_Real Val); +Standard_EXPORT void Set(const Standard_Real theVal); +Standard_EXPORT Standard_Real Get() const { return myValue; } +Standard_EXPORT virtual TCollection_AsciiString Save() { return TCollection_AsciiString(myValue); } +Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue) { myValue = theValue.RealValue(); } + +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_AttributeReal() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeReal ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.cxx new file mode 100644 index 000000000..6677fddb5 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.cxx @@ -0,0 +1,105 @@ +// File : SALOMEDSImpl_AttributeReference.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeReference.hxx" +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeReference, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeReference, SALOMEDSImpl_GenericAttribute ) + + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeReference::GetID () +{ + static Standard_GUID refID ("D913E0B3-0A9F-4ea6-9480-18A9B72D9D86"); + return refID; +} + +Handle(SALOMEDSImpl_AttributeReference) SALOMEDSImpl_AttributeReference::Set(const TDF_Label& theLabel, + const TDF_Label& theRefLabel) +{ + Handle(SALOMEDSImpl_AttributeReference) A; + if (!theLabel.FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), A)) { + A = new SALOMEDSImpl_AttributeReference(); + theLabel.AddAttribute(A); + } + + A->Set(theRefLabel); + return A; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeReference::Set(const TDF_Label& Origin) +{ + CheckLocked(); + + if(myLabel == Origin) return; + + Backup(); + myLabel = Origin; +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeReference::ID () const { return GetID(); } + + +TCollection_AsciiString SALOMEDSImpl_AttributeReference::Save() +{ + TCollection_AsciiString anEntry; + TDF_Tool::Entry(myLabel, anEntry); + return anEntry; +} + +void SALOMEDSImpl_AttributeReference::Load(const TCollection_AsciiString& value) +{ + TDF_Label aLabel; + TDF_Tool::Label(Label().Data(), value, aLabel); + myLabel = aLabel; +} + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= +Handle(TDF_Attribute) SALOMEDSImpl_AttributeReference::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeReference(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeReference::Restore(const Handle(TDF_Attribute)& With) +{ + myLabel = Handle(SALOMEDSImpl_AttributeReference)::DownCast (With)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeReference::Paste (const Handle(TDF_Attribute)& Into, + const Handle(TDF_RelocationTable)& RT) const +{ + TDF_Label tLab; + if (!myLabel.IsNull()) { + if (!RT->HasRelocation(myLabel,tLab)) tLab = myLabel; + } + Handle(SALOMEDSImpl_AttributeReference)::DownCast(Into)->Set(tLab); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.hxx new file mode 100644 index 000000000..6468c71d9 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.hxx @@ -0,0 +1,50 @@ +// File : SALOMEDSImpl_AttributeIOR.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeReference_HeaderFile +#define _SALOMEDSImpl_AttributeReference_HeaderFile + +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeReference, SALOMEDSImpl_GenericAttribute ) + + + +class SALOMEDSImpl_AttributeReference : public SALOMEDSImpl_GenericAttribute +{ +private: + TDF_Label myLabel; + +public: + +Standard_EXPORT static const Standard_GUID& GetID() ; + +Standard_EXPORT SALOMEDSImpl_AttributeReference():SALOMEDSImpl_GenericAttribute("AttributeReference") {} +Standard_EXPORT static Handle(SALOMEDSImpl_AttributeReference) Set(const TDF_Label& theLabel, const TDF_Label& theRefLabel); +Standard_EXPORT void Set(const TDF_Label& theLabel); +Standard_EXPORT TDF_Label Get() const { return myLabel; } +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_AttributeReference() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeReference ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.cxx new file mode 100644 index 000000000..563c9a8bc --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.cxx @@ -0,0 +1,103 @@ +// File : SALOMEDSImpl_AttributeSelectable.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeSelectable.hxx" +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeSelectable, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeSelectable, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeSelectable::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeSelectableID ("12837188-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeSelectableID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDSImpl_AttributeSelectable) SALOMEDSImpl_AttributeSelectable::Set (const TDF_Label& L, + const Standard_Integer value) +{ + Handle(SALOMEDSImpl_AttributeSelectable) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeSelectable::GetID(),A)) { + A = new SALOMEDSImpl_AttributeSelectable(); + L.AddAttribute(A); + } + + A->Set (value); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeSelectable::SALOMEDSImpl_AttributeSelectable() +:SALOMEDSImpl_GenericAttribute("AttributeSelectable") +{ + myValue = 0; +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeSelectable::Set(const Standard_Integer theValue) +{ + Backup(); + + (theValue!=0)?myValue=1:myValue=0; +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeSelectable::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeSelectable::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeSelectable(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeSelectable::Restore(const Handle(TDF_Attribute)& with) +{ + myValue = Handle(SALOMEDSImpl_AttributeSelectable)::DownCast (with)->Get (); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeSelectable::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeSelectable)::DownCast (into)->Set (myValue); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.hxx new file mode 100644 index 000000000..3897dd08d --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.hxx @@ -0,0 +1,49 @@ +// File : SALOMEDSImpl_AttributeSelectable.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeSelectable_HeaderFile +#define _SALOMEDSImpl_AttributeSelectable_HeaderFile + +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeSelectable, SALOMEDSImpl_GenericAttribute ) + + + +class SALOMEDSImpl_AttributeSelectable : public SALOMEDSImpl_GenericAttribute +{ +private: +Standard_Integer myValue; + +public: + +Standard_EXPORT virtual TCollection_AsciiString Save() { return (myValue == 0)?(char*)"0":(char*)"1"; } +Standard_EXPORT virtual void Load(const TCollection_AsciiString& theValue) { (theValue == "0")?myValue=0:myValue=1; } + +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeSelectable Set(const TDF_Label& label,const Standard_Integer value) ; +Standard_EXPORT SALOMEDSImpl_AttributeSelectable(); +Standard_EXPORT void Set(const Standard_Integer value); +Standard_EXPORT Standard_Integer Get() const { return myValue; } +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_AttributeSelectable() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeDrawable ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx new file mode 100644 index 000000000..47b8ca653 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx @@ -0,0 +1,170 @@ +// File : SALOMEDSImpl_AttributeSequenceOfInteger.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeSequenceOfInteger.hxx" +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeSequenceOfInteger, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeSequenceOfInteger, SALOMEDSImpl_GenericAttribute ) + + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeSequenceOfInteger::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeSequenceOfIntegerID ("12837182-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeSequenceOfIntegerID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDSImpl_AttributeSequenceOfInteger) SALOMEDSImpl_AttributeSequenceOfInteger::Set (const TDF_Label& L) +{ + Handle(SALOMEDSImpl_AttributeSequenceOfInteger) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeSequenceOfInteger::GetID(),A)) { + A = new SALOMEDSImpl_AttributeSequenceOfInteger(); + L.AddAttribute(A); + } + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeSequenceOfInteger::SALOMEDSImpl_AttributeSequenceOfInteger() +:SALOMEDSImpl_GenericAttribute("AttributeSequenceOfInteger") +{ + myValue = new TColStd_HSequenceOfInteger(); +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeSequenceOfInteger::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeSequenceOfInteger::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeSequenceOfInteger(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeSequenceOfInteger::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer i; + Handle(SALOMEDSImpl_AttributeSequenceOfInteger) anSeq = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(with); + if(!anSeq->myValue.IsNull()) { + myValue = new TColStd_HSequenceOfInteger(); + Standard_Integer Len = anSeq->Length(); + for(i = 1; i<=Len; i++) Add(anSeq->Value(i)); + } + else + myValue.Nullify(); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeSequenceOfInteger::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& ) const +{ + if(!myValue.IsNull()) { + Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast (into)->Assign(myValue); + } +} + +void SALOMEDSImpl_AttributeSequenceOfInteger::Assign(const Handle(TColStd_HSequenceOfInteger)& other) +{ + CheckLocked(); + Backup(); + if (myValue.IsNull()) myValue = new TColStd_HSequenceOfInteger; + myValue->ChangeSequence() = other->Sequence(); +} + +void SALOMEDSImpl_AttributeSequenceOfInteger::ChangeValue(const Standard_Integer Index,const Standard_Integer Value) +{ + CheckLocked(); + Backup(); + myValue->SetValue(Index, Value); +} + +void SALOMEDSImpl_AttributeSequenceOfInteger::Add(const Standard_Integer Value) +{ + CheckLocked(); + Backup(); + myValue->Append(Value); +} + +void SALOMEDSImpl_AttributeSequenceOfInteger::Remove(const Standard_Integer Index) +{ + CheckLocked(); + Backup(); + myValue->Remove(Index); +} + +Standard_Integer SALOMEDSImpl_AttributeSequenceOfInteger::Length() +{ + return myValue->Length(); +} +Standard_Integer SALOMEDSImpl_AttributeSequenceOfInteger::Value(const Standard_Integer Index) +{ + return myValue->Value(Index); +} + + + +TCollection_AsciiString SALOMEDSImpl_AttributeSequenceOfInteger::Save() +{ + Standard_Integer aLength = Length(); + char* aResult = new char[aLength * 25]; + aResult[0] = 0; + Standard_Integer aPosition = 0; + for (int i = 1; i <= aLength; i++) { + sprintf(aResult + aPosition , "%d ", Value(i)); + aPosition += strlen(aResult + aPosition); + } + TCollection_AsciiString ret(aResult); + delete aResult; + + return ret; +} + +void SALOMEDSImpl_AttributeSequenceOfInteger::Load(const TCollection_AsciiString& value) +{ + Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger; + + char* aCopy = value.ToCString(); + char* adr = strtok(aCopy, " "); + while (adr) { + int l = atol(adr); + CasCadeSeq->Append(l); + adr = strtok(NULL, " "); + } + Assign(CasCadeSeq); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.hxx new file mode 100644 index 000000000..a24aa5646 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.hxx @@ -0,0 +1,54 @@ +// File : SALOMEDSImpl_AttributeSequenceOfInteger.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeSequenceOfInteger_HeaderFile +#define _SALOMEDSImpl_AttributeSequenceOfInteger_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeSequenceOfInteger, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeSequenceOfInteger : public SALOMEDSImpl_GenericAttribute +{ + +public: + +Standard_EXPORT virtual TCollection_AsciiString Save(); +Standard_EXPORT virtual void Load(const TCollection_AsciiString&); + +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeSequenceOfInteger Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDSImpl_AttributeSequenceOfInteger(); +Standard_EXPORT void Assign(const Handle(TColStd_HSequenceOfInteger)& other) ; +Standard_EXPORT void ChangeValue(const Standard_Integer Index,const Standard_Integer Value) ; +Standard_EXPORT void Add(const Standard_Integer value) ; +Standard_EXPORT Standard_Integer Value(const Standard_Integer Index) ; +Standard_EXPORT void Remove(const Standard_Integer Index) ; +Standard_EXPORT Standard_Integer Length() ; +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_AttributeSequenceOfInteger() {} + +private: + +Handle_TColStd_HSequenceOfInteger myValue; + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeSequenceOfInteger ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx new file mode 100644 index 000000000..5b038b61a --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx @@ -0,0 +1,170 @@ +// File : SALOMEDSImpl_AttributeSequenceOfReal.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeSequenceOfReal.hxx" +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeSequenceOfReal, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeSequenceOfReal, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeSequenceOfReal::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeSequenceOfRealID ("12837183-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeSequenceOfRealID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDSImpl_AttributeSequenceOfReal) SALOMEDSImpl_AttributeSequenceOfReal::Set (const TDF_Label& L) +{ + Handle(SALOMEDSImpl_AttributeSequenceOfReal) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeSequenceOfReal::GetID(),A)) { + A = new SALOMEDSImpl_AttributeSequenceOfReal(); + L.AddAttribute(A); + } + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeSequenceOfReal::SALOMEDSImpl_AttributeSequenceOfReal() +:SALOMEDSImpl_GenericAttribute("AttributeSequenceOfReal") +{ + myValue = new TColStd_HSequenceOfReal(); +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeSequenceOfReal::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeSequenceOfReal::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeSequenceOfReal(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeSequenceOfReal::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer i; + Handle(SALOMEDSImpl_AttributeSequenceOfReal) anSeq = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(with); + if(!anSeq->myValue.IsNull()) { + myValue = new TColStd_HSequenceOfReal(); + Standard_Integer Len = anSeq->Length(); + for(i = 1; i<=Len; i++) Add(anSeq->Value(i)); + } + else + myValue.Nullify(); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeSequenceOfReal::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& ) const +{ + if(!myValue.IsNull()) { + Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast (into)->Assign(myValue); + } +} + +void SALOMEDSImpl_AttributeSequenceOfReal::Assign(const Handle(TColStd_HSequenceOfReal)& other) +{ + CheckLocked(); + Backup(); + if (myValue.IsNull()) myValue = new TColStd_HSequenceOfReal; + myValue->ChangeSequence() = other->Sequence(); +} + +void SALOMEDSImpl_AttributeSequenceOfReal::ChangeValue(const Standard_Integer Index,const Standard_Real Value) +{ + CheckLocked(); + Backup(); + myValue->SetValue(Index, Value); +} + +void SALOMEDSImpl_AttributeSequenceOfReal::Add(const Standard_Real Value) +{ + CheckLocked(); + Backup(); + myValue->Append(Value); +} + +void SALOMEDSImpl_AttributeSequenceOfReal::Remove(const Standard_Integer Index) +{ + CheckLocked(); + Backup(); + myValue->Remove(Index); +} + +Standard_Integer SALOMEDSImpl_AttributeSequenceOfReal::Length() +{ + return myValue->Length(); +} + +Standard_Real SALOMEDSImpl_AttributeSequenceOfReal::Value(const Standard_Integer Index) +{ + return myValue->Value(Index); +} + + +TCollection_AsciiString SALOMEDSImpl_AttributeSequenceOfReal::Save() +{ + Standard_Integer aLength = Length(); + char* aResult = new char[aLength * 25]; + aResult[0] = 0; + Standard_Integer aPosition = 0; + for (int i = 1; i <= aLength; i++) { + sprintf(aResult + aPosition , "%f ", Value(i)); + aPosition += strlen(aResult + aPosition); + } + TCollection_AsciiString ret(aResult); + delete aResult; + + return ret; +} + +void SALOMEDSImpl_AttributeSequenceOfReal::Load(const TCollection_AsciiString& value) +{ + Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal; + + char* aCopy = value.ToCString(); + char* adr = strtok(aCopy, " "); + char *err = NULL; + while (adr) { + Standard_Real r = strtod(adr, &err); + CasCadeSeq->Append(r); + adr = strtok(NULL, " "); + } + Assign(CasCadeSeq); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.hxx new file mode 100644 index 000000000..a7c93716f --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.hxx @@ -0,0 +1,53 @@ +// File : SALOMEDSImpl_AttributeSequenceOfReal.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeSequenceOfReal_HeaderFile +#define _SALOMEDSImpl_AttributeSequenceOfReal_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeSequenceOfReal, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeSequenceOfReal : public SALOMEDSImpl_GenericAttribute +{ + +public: + +Standard_EXPORT virtual TCollection_AsciiString Save(); +Standard_EXPORT virtual void Load(const TCollection_AsciiString&); + +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeSequenceOfReal Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDSImpl_AttributeSequenceOfReal(); +Standard_EXPORT void Assign(const Handle(TColStd_HSequenceOfReal)& other) ; +Standard_EXPORT void ChangeValue(const Standard_Integer Index,const Standard_Real Value) ; +Standard_EXPORT void Add(const Standard_Real Value) ; +Standard_EXPORT Standard_Real Value(const Standard_Integer Index) ; +Standard_EXPORT void Remove(const Standard_Integer Index) ; +Standard_EXPORT Standard_Integer Length() ; +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_AttributeSequenceOfReal() {} + +private: +Handle_TColStd_HSequenceOfReal myValue; + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeSequenceOfReal ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx new file mode 100644 index 000000000..b22df3386 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx @@ -0,0 +1,304 @@ +// File : SALOMEDSImpl_AttributeStudyProperties.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeStudyProperties, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeStudyProperties, SALOMEDSImpl_GenericAttribute ) + +const Standard_GUID& SALOMEDSImpl_AttributeStudyProperties::GetID() +{ + static Standard_GUID SALOMEDSImpl_AttributeStudyPropertiesID ("128371A2-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeStudyPropertiesID; +} + +Handle(SALOMEDSImpl_AttributeStudyProperties) SALOMEDSImpl_AttributeStudyProperties::Set(const TDF_Label& label) +{ + Handle(SALOMEDSImpl_AttributeStudyProperties) anAttr; + if (!label.FindAttribute(SALOMEDSImpl_AttributeStudyProperties::GetID(),anAttr)) { + anAttr = new SALOMEDSImpl_AttributeStudyProperties(); + label.AddAttribute(anAttr); + } + return anAttr; +} + +SALOMEDSImpl_AttributeStudyProperties::SALOMEDSImpl_AttributeStudyProperties() +:SALOMEDSImpl_GenericAttribute("AttributeStudyProperties") +{ + myLocked = Standard_False; + myLockChanged = Standard_False; + Init(); +} + +void SALOMEDSImpl_AttributeStudyProperties::Init() +{ + myUserName = new TColStd_HSequenceOfExtendedString(); + myMinute = new TColStd_HSequenceOfInteger(); + myHour = new TColStd_HSequenceOfInteger(); + myDay = new TColStd_HSequenceOfInteger(); + myMonth = new TColStd_HSequenceOfInteger(); + myYear = new TColStd_HSequenceOfInteger(); +// myModified = 0; + myMode = 0; // none +} + +void SALOMEDSImpl_AttributeStudyProperties::SetUserName(const TCollection_ExtendedString& theName) +{ + CheckLocked(); + Backup(); + myUserName->Append(theName); +} + +void SALOMEDSImpl_AttributeStudyProperties::SetFirstName(const TCollection_ExtendedString& theName) +{ + CheckLocked(); + Backup(); + if (myUserName->Length() == 0) myUserName->Append(theName); + else myUserName->SetValue(1, theName); +} + +TCollection_ExtendedString SALOMEDSImpl_AttributeStudyProperties::GetCreatorName() const +{ + if (myUserName->Length() == 0) return TCollection_ExtendedString(""); + return myUserName->Value(1); +} + +Handle(TColStd_HSequenceOfExtendedString) SALOMEDSImpl_AttributeStudyProperties::GetUserNames() const +{ + return myUserName; +} + +void SALOMEDSImpl_AttributeStudyProperties::SetModificationDate(const Standard_Integer theMinute, + const Standard_Integer theHour, + const Standard_Integer theDay, + const Standard_Integer theMonth, + const Standard_Integer theYear) +{ + CheckLocked(); + Backup(); + if (theMinute<0 || theMinute>60 || theHour<0 || theHour>24 || theDay<0 || theDay>31 || theMonth<0 || theMonth>12) + return; + myMinute->Append(theMinute); + myHour->Append(theHour); + myDay->Append(theDay); + myMonth->Append(theMonth); + myYear->Append(theYear); +} + +Standard_Boolean SALOMEDSImpl_AttributeStudyProperties::GetCreationDate(Standard_Integer& theMinute, + Standard_Integer& theHour, + Standard_Integer& theDay, + Standard_Integer& theMonth, + Standard_Integer& theYear) const +{ + if (myMinute->Length() != 0) { + theMinute = myMinute->Value(1); + theHour = myHour->Value(1); + theDay = myDay->Value(1); + theMonth = myMonth->Value(1); + theYear = myYear->Value(1); + return Standard_True; + } + return Standard_False; +} + +void SALOMEDSImpl_AttributeStudyProperties::GetModificationDates(Handle(TColStd_HSequenceOfInteger)& theMinutes, + Handle(TColStd_HSequenceOfInteger)& theHours, + Handle(TColStd_HSequenceOfInteger)& theDays, + Handle(TColStd_HSequenceOfInteger)& theMonths, + Handle(TColStd_HSequenceOfInteger)& theYears) const +{ + theMinutes = myMinute; + theHours = myHour; + theDays = myDay; + theMonths = myMonth; + theYears = myYear; +} + +void SALOMEDSImpl_AttributeStudyProperties::SetCreationMode(const Standard_Integer theMode) +{ + CheckLocked(); + Backup(); + myMode = theMode; +} + +Standard_Integer SALOMEDSImpl_AttributeStudyProperties::GetCreationMode() const +{ + return myMode; +} + +void SALOMEDSImpl_AttributeStudyProperties::SetModified(const Standard_Integer theModified) +{ + myModified = theModified; +} + +Standard_Boolean SALOMEDSImpl_AttributeStudyProperties::IsModified() const +{ + return (myModified != 0); +} + +Standard_Integer SALOMEDSImpl_AttributeStudyProperties::GetModified() const +{ + return myModified; +} + +void SALOMEDSImpl_AttributeStudyProperties::SetLocked(const Standard_Boolean theLocked) +{ +// Backup(); + if (myLocked != theLocked) { + myLockChanged = Standard_True; + myLocked = theLocked; + } +} + +Standard_Boolean SALOMEDSImpl_AttributeStudyProperties::IsLocked() const +{ + return myLocked; +} + +Standard_Boolean SALOMEDSImpl_AttributeStudyProperties::IsLockChanged(const Standard_Boolean theErase) { + if (!myLockChanged) return Standard_False; + if (theErase) myLockChanged = Standard_False; + return Standard_True; +} + +const Standard_GUID& SALOMEDSImpl_AttributeStudyProperties::ID() const +{ + return GetID(); +} + +void SALOMEDSImpl_AttributeStudyProperties::Restore(const Handle(TDF_Attribute)& with) +{ + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(with); + Init(); + Standard_Integer i; + Handle(TColStd_HSequenceOfExtendedString) aNames = aProp->GetUserNames(); + for(i = aNames->Length(); i > 0; i--) { + myUserName->Prepend(aNames->Value(i)); + } + Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; + aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + for(i = aMinutes->Length(); i > 0; i--) { + myMinute->Prepend(aMinutes->Value(i)); + myHour->Prepend(aHours->Value(i)); + myDay->Prepend(aDays->Value(i)); + myMonth->Prepend(aMonths->Value(i)); + myYear->Prepend(aYears->Value(i)); + } + myMode = aProp->GetCreationMode(); +// myModified = aProp->GetModified(); +// myLocked = aProp->IsLocked(); +} + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeStudyProperties::NewEmpty() const +{ + return new SALOMEDSImpl_AttributeStudyProperties(); +} + +void SALOMEDSImpl_AttributeStudyProperties::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)&) const +{ + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(into); + aProp->Init(); + + Standard_Integer i; + for(i = 1; i <= myUserName->Length(); i++) { + aProp->SetUserName(myUserName->Value(i)); + } + for(i = 1; i <= myMinute->Length(); i++) { + aProp->SetModificationDate(myMinute->Value(i), myHour->Value(i), myDay->Value(i), myMonth->Value(i), myYear->Value(i)); + } + + aProp->SetCreationMode(myMode); +// aProp->SetModified(myModified); +// aProp->SetLocked(myLocked); +} + + +TCollection_AsciiString SALOMEDSImpl_AttributeStudyProperties::Save() +{ + Handle(TColStd_HSequenceOfExtendedString) aNames; + Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; + aNames = GetUserNames(); + GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + + int aLength, anIndex; + for(aLength = 0, anIndex = aNames->Length(); anIndex > 0; anIndex--) aLength += aNames->Value(anIndex).Length() + 1; + + char* aProperty = new char[3 + aLength + 12 * aNames->Length()]; + + char crMode = (char)GetCreationMode(); + + sprintf(aProperty,"%c%c", crMode, IsLocked()?'l':'u'); + + aLength = aNames->Length(); + int a = 2; + for(anIndex = 1; anIndex <= aLength; anIndex++) { + sprintf(&(aProperty[a]),"%2d%2d%2d%2d%4d%s", + (int)(aMinutes->Value(anIndex)), + (int)(aHours->Value(anIndex)), + (int)(aDays->Value(anIndex)), + (int)(aMonths->Value(anIndex)), + (int)(aYears->Value(anIndex)), + (char*)(TCollection_AsciiString(aNames->Value(anIndex)).ToCString())); + a = strlen(aProperty); + aProperty[a++] = 1; + } + aProperty[a] = 0; + TCollection_AsciiString prop(aProperty); + delete aProperty; + + return prop; +} + +void SALOMEDSImpl_AttributeStudyProperties::Load(const TCollection_AsciiString& value) +{ + char* aCopy = value.ToCString(); + + int crMode = (int)aCopy[0]; + SetCreationMode(crMode); + + int anIndex; + for(anIndex = 2; anIndex + 2 < value.Length() ;) { + char str[10]; + Standard_Integer aMinute, aHour, aDay, aMonth, aYear; + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + str[2] = 0; + aMinute = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + aHour = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + aDay = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + aMonth = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + str[2] = aCopy[anIndex++]; + str[3] = aCopy[anIndex++]; + str[4] = 0; + aYear = atoi(str); + + int aNameSize; + for(aNameSize = 0; aCopy[anIndex+aNameSize]!=1; aNameSize++); + char *aName = new char[aNameSize+1]; + strncpy(aName, &(aCopy[anIndex]), aNameSize); + aName[aNameSize] = 0; + SetUserName(aName); + SetModificationDate(aMinute,aHour,aDay,aMonth,aYear); + delete(aName); + anIndex += aNameSize + 1; + } + if (aCopy[1] == 'l') { + SetLocked(Standard_True); + } + SetModified(0); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx new file mode 100644 index 000000000..f9d3c1a16 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx @@ -0,0 +1,86 @@ +// File : SALOMEDSImpl_AttributeStudyProperties.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeStudyProperties_HeaderFile +#define _SALOMEDSImpl_AttributeStudyProperties_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeStudyProperties, SALOMEDSImpl_GenericAttribute ) + +#include +#include + +class SALOMEDSImpl_AttributeStudyProperties : public SALOMEDSImpl_GenericAttribute +{ + +public: +Standard_EXPORT virtual TCollection_AsciiString Save(); +Standard_EXPORT virtual void Load(const TCollection_AsciiString&); +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeStudyProperties Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDSImpl_AttributeStudyProperties(); +Standard_EXPORT void Init() ; +Standard_EXPORT void SetUserName(const TCollection_ExtendedString& theName) ; +Standard_EXPORT void SetFirstName(const TCollection_ExtendedString& theName) ; +Standard_EXPORT TCollection_ExtendedString GetCreatorName() const; +Standard_EXPORT Handle_TColStd_HSequenceOfExtendedString GetUserNames() const; +Standard_EXPORT void SetModificationDate(const Standard_Integer theMinute, + const Standard_Integer theHour, + const Standard_Integer theDay, + const Standard_Integer theMonth, + const Standard_Integer theYear) ; +Standard_EXPORT Standard_Boolean GetCreationDate(Standard_Integer& theMinute, + Standard_Integer& theHour, + Standard_Integer& theDay, + Standard_Integer& theMonth, + Standard_Integer& theYear) const; +Standard_EXPORT void GetModificationDates(Handle(TColStd_HSequenceOfInteger)& theMinutes, + Handle(TColStd_HSequenceOfInteger)& theHours, + Handle(TColStd_HSequenceOfInteger)& theDays, + Handle(TColStd_HSequenceOfInteger)& theMonths, + Handle(TColStd_HSequenceOfInteger)& theYears) const; +Standard_EXPORT void SetCreationMode(const Standard_Integer theMode) ; +Standard_EXPORT Standard_Integer GetCreationMode() const; +Standard_EXPORT void SetModified(const Standard_Integer theModified) ; +Standard_EXPORT Standard_Boolean IsModified() const; +Standard_EXPORT Standard_Integer GetModified() const; +Standard_EXPORT void SetLocked(const Standard_Boolean theLocked) ; +Standard_EXPORT Standard_Boolean IsLocked() const; +Standard_EXPORT Standard_Boolean IsLockChanged(const Standard_Boolean theErase) ; +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_AttributeStudyProperties() {} + +private: + +Handle_TColStd_HSequenceOfExtendedString myUserName; +Handle_TColStd_HSequenceOfInteger myMinute; +Handle_TColStd_HSequenceOfInteger myHour; +Handle_TColStd_HSequenceOfInteger myDay; +Handle_TColStd_HSequenceOfInteger myMonth; +Handle_TColStd_HSequenceOfInteger myYear; +Standard_Integer myMode; +Standard_Integer myModified; +Standard_Boolean myLocked; +Standard_Boolean myLockChanged; + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeStudyProperties ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx new file mode 100644 index 000000000..284e91e5f --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.cxx @@ -0,0 +1,425 @@ +// File : SALOMEDSImpl_AttributeTableOfInteger.cxx +// Author : Michael Ponikarov +// Module : SALOME + +using namespace std; +#include +#include +#include +#include +#include + + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTableOfInteger, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTableOfInteger, SALOMEDSImpl_GenericAttribute ) + +const Standard_GUID& SALOMEDSImpl_AttributeTableOfInteger::GetID() +{ + static Standard_GUID SALOMEDSImpl_AttributeTableOfIntegerID ("128371A0-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeTableOfIntegerID; +} + +Handle(SALOMEDSImpl_AttributeTableOfInteger) SALOMEDSImpl_AttributeTableOfInteger::Set(const TDF_Label& label) +{ + Handle(SALOMEDSImpl_AttributeTableOfInteger) anAttr; + if (!label.FindAttribute(SALOMEDSImpl_AttributeTableOfInteger::GetID(),anAttr)) { + anAttr = new SALOMEDSImpl_AttributeTableOfInteger(); + label.AddAttribute(anAttr); + } + return anAttr; +} + +SALOMEDSImpl_AttributeTableOfInteger::SALOMEDSImpl_AttributeTableOfInteger() +:SALOMEDSImpl_GenericAttribute("AttributeTableOfInteger") +{ + myRows = new TColStd_HSequenceOfExtendedString(); + myCols = new TColStd_HSequenceOfExtendedString(); + myNbRows = 0; + myNbColumns = 0; +} + +void SALOMEDSImpl_AttributeTableOfInteger::SetNbColumns(const Standard_Integer theNbColumns) +{ + CheckLocked(); + Backup(); + + TColStd_DataMapOfIntegerInteger aMap; + aMap = myTable; + myTable.Clear(); + + TColStd_DataMapIteratorOfDataMapOfIntegerInteger anIterator(aMap); + for(; anIterator.More(); anIterator.Next()) { + int aRow = (int)(anIterator.Key()/myNbColumns) + 1; + int aCol = (int)(anIterator.Key() - myNbColumns*(aRow-1)); + if(aCol == 0) { aCol = myNbColumns; aRow--; } + if(aCol > theNbColumns) continue; + int aKey = (aRow-1)*theNbColumns+aCol; + myTable.Bind(aKey, anIterator.Value()); + } + + myNbColumns = theNbColumns; + + while (myCols->Length() < myNbColumns) { // append empty columns titles + myCols->Append(TCollection_ExtendedString("")); + } +} + +void SALOMEDSImpl_AttributeTableOfInteger::SetTitle(const TCollection_ExtendedString& theTitle) +{ + CheckLocked(); + Backup(); + myTitle = theTitle; +} + +TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfInteger::GetTitle() const +{ + return myTitle; +} + +void SALOMEDSImpl_AttributeTableOfInteger::SetRowData(const Standard_Integer theRow, + const Handle(TColStd_HSequenceOfInteger)& theData) +{ + CheckLocked(); + if(theData->Length() > myNbColumns) SetNbColumns(theData->Length()); + + Backup(); + + while (myRows->Length() < theRow) { // append new row titles + myRows->Append(TCollection_ExtendedString("")); + } + + Standard_Integer i, aShift = (theRow-1)*myNbColumns, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(aShift + i, theData->Value(i)); + } + + if(theRow > myNbRows) myNbRows = theRow; +} + +Handle(TColStd_HSequenceOfInteger) SALOMEDSImpl_AttributeTableOfInteger::GetRowData(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger(); + Standard_Integer i, aShift = (theRow-1)*myNbColumns; + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift+i)) + aSeq->Append(myTable.Find(aShift+i)); + else + aSeq->Append(0); + } + + return aSeq; +} + +void SALOMEDSImpl_AttributeTableOfInteger::SetRowTitle(const Standard_Integer theRow, + const TCollection_ExtendedString& theTitle) +{ + CheckLocked(); + Backup(); + myRows->SetValue(theRow,theTitle); +} + +TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfInteger::GetRowTitle(const Standard_Integer theRow) const { + return myRows->Value(theRow); +} + + +void SALOMEDSImpl_AttributeTableOfInteger::SetColumnData(const Standard_Integer theColumn, + const Handle(TColStd_HSequenceOfInteger)& theData) +{ + CheckLocked(); + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Backup(); + + Standard_Integer i, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(myNbColumns*(i-1)+theColumn, theData->Value(i)); + } + + if(aLength > myNbRows) { + myNbRows = aLength; + while (myRows->Length() < myNbRows) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + } +} + + +Handle(TColStd_HSequenceOfInteger) SALOMEDSImpl_AttributeTableOfInteger::GetColumnData(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1) + theColumn; + if(myTable.IsBound(anIndex)) + aSeq->Append(myTable.Find(anIndex)); + else + aSeq->Append(0); + } + + return aSeq; +} + +void SALOMEDSImpl_AttributeTableOfInteger::SetColumnTitle(const Standard_Integer theColumn, + const TCollection_ExtendedString& theTitle) +{ + CheckLocked(); + Backup(); + while(myCols->Length() < theColumn) myCols->Append(TCollection_ExtendedString("")); + myCols->SetValue(theColumn,theTitle); +} + +TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfInteger::GetColumnTitle(const Standard_Integer theColumn) const +{ + if(myCols.IsNull()) return ""; + if(myCols->Length() < theColumn) return ""; + return myCols->Value(theColumn); +} + + +Standard_Integer SALOMEDSImpl_AttributeTableOfInteger::GetNbRows() const +{ + return myNbRows; +} + +Standard_Integer SALOMEDSImpl_AttributeTableOfInteger::GetNbColumns() const +{ + return myNbColumns; +} + +void SALOMEDSImpl_AttributeTableOfInteger::PutValue(const Standard_Integer theValue, + const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + CheckLocked(); + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + myTable.Bind(anIndex, theValue); + + if(theRow > myNbRows) { + while (myRows->Length() < theRow) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + myNbRows = theRow; + } +} + +Standard_Boolean SALOMEDSImpl_AttributeTableOfInteger::HasValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + return myTable.IsBound(anIndex); +} + +Standard_Integer SALOMEDSImpl_AttributeTableOfInteger::GetValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + if(myTable.IsBound(anIndex)) return myTable.Find(anIndex); + + Standard_Failure::Raise("Invalid cell index"); + return 0; +} + +const Standard_GUID& SALOMEDSImpl_AttributeTableOfInteger::ID() const +{ + return GetID(); +} + +void SALOMEDSImpl_AttributeTableOfInteger::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer anIndex; + Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(with); + + myTable.Clear(); + myCols->Clear(); + myRows->Clear(); + + myTable = aTable->myTable; + myNbRows = aTable->myNbRows; + myNbColumns = aTable->myNbColumns; + myTitle = aTable->myTitle; + + for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) + myRows->Append(aTable->GetRowTitle(anIndex)); + + for(anIndex = 1; anIndex <= aTable->GetNbColumns(); anIndex++) + myCols->Append(aTable->GetColumnTitle(anIndex)); +} + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeTableOfInteger::NewEmpty() const +{ + return new SALOMEDSImpl_AttributeTableOfInteger(); +} + +void SALOMEDSImpl_AttributeTableOfInteger::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)&) const +{ + Standard_Integer anIndex; + Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(into); + + aTable->myTable.Clear(); + aTable->myCols->Clear(); + aTable->myRows->Clear(); + + aTable->myTable = myTable; + aTable->myTitle = myTitle; + aTable->myNbRows = myNbRows; + aTable->myNbColumns = myNbColumns; + + for(anIndex = 1; anIndex <= GetNbRows();anIndex++) + aTable->myRows->Append(GetRowTitle(anIndex)); + for(anIndex = 1; anIndex <= GetNbColumns(); anIndex++) + aTable->myCols->Append(GetColumnTitle(anIndex)); +} + + +Handle_TColStd_HSequenceOfInteger SALOMEDSImpl_AttributeTableOfInteger::GetSetRowIndices(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, aShift = myNbColumns*(theRow-1); + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift + i)) aSeq->Append(i); + } + + return aSeq; +} + +Handle_TColStd_HSequenceOfInteger SALOMEDSImpl_AttributeTableOfInteger::GetSetColumnIndices(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1)+theColumn; + if(myTable.IsBound(anIndex)) aSeq->Append(i); + } + + return aSeq; +} + + +void SALOMEDSImpl_AttributeTableOfInteger::ConvertToString(ostrstream& theStream) +{ + int i, j, l; + + theStream.precision(64); + + //Title + l = myTitle.Length(); + theStream << l << "\n"; + for(i=1; i<=l; i++) + theStream << myTitle.Value(i) << "\n"; + + //Nb rows + theStream << myNbRows << "\n"; + + //Rows titles + for(i=1; i<=myNbRows; i++) { + l = myRows->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myRows->Value(i).Value(j) << "\n"; + } + + //Nb columns + theStream << myNbColumns << "\n"; + + //Columns titles + for(i=1; i<=myNbColumns; i++) { + l = myCols->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myCols->Value(i).Value(j) << "\n"; + } + + //Store the table values + l = myTable.Extent(); + theStream << l << "\n"; + TColStd_DataMapIteratorOfDataMapOfIntegerInteger anIterator(myTable); + for(; anIterator.More(); anIterator.Next()) { + theStream << anIterator.Key() << "\n"; + theStream << anIterator.Value() << "\n"; + } + + return; +} + +bool SALOMEDSImpl_AttributeTableOfInteger::RestoreFromString(istrstream& theStream) +{ + Backup(); + + int i, j, l; + + Standard_ExtCharacter anExtChar; + TCollection_ExtendedString aStr; + + //Title + theStream >> l; + + myTitle = TCollection_ExtendedString(l, 0); + for(i=1; i<=l; i++) { + theStream >> anExtChar; + myTitle.SetValue(i, anExtChar); + } + + //Nb rows + theStream >> myNbRows; + + //Rows titles + myRows->Clear(); + for(i=1; i<=myNbRows; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myRows->Append(aStr); + } + + //Nb columns + theStream >> myNbColumns; + + //Columns titles + myCols->Clear(); + for(i=1; i<=myNbColumns; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myCols->Append(aStr); + } + + //Restore the table values + theStream >> l; + myTable.Clear(); + for(i=1; i<=l; i++) { + int aKey, aValue; + theStream >> aKey; + theStream >> aValue; + myTable.Bind(aKey, aValue); + } + + return true; +} + + +TCollection_AsciiString SALOMEDSImpl_AttributeTableOfInteger::Save() +{ + ostrstream ostr; + ConvertToString(ostr); + TCollection_AsciiString aString((char*)ostr.rdbuf()->str()); + return aString; +} + +void SALOMEDSImpl_AttributeTableOfInteger::Load(const TCollection_AsciiString& value) +{ + istrstream aStream(value.ToCString(), strlen(value.ToCString())); + RestoreFromString(aStream); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx new file mode 100644 index 000000000..c2957af96 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx @@ -0,0 +1,86 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SALOMEDSImpl_AttributeTableOfInteger.hxx +// Author : Michael Ponikarov +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeTableOfInteger_HeaderFile +#define _SALOMEDSImpl_AttributeTableOfInteger_HeaderFile + +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + +#include +#include +#include +#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeTableOfInteger, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeTableOfInteger : public SALOMEDSImpl_GenericAttribute +{ + +public: +Standard_EXPORT virtual TCollection_AsciiString Save(); +Standard_EXPORT virtual void Load(const TCollection_AsciiString&); +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeTableOfInteger Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDSImpl_AttributeTableOfInteger(); +Standard_EXPORT void SetNbColumns(const Standard_Integer theNbColumns); +Standard_EXPORT void SetTitle(const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetTitle() const; +Standard_EXPORT void SetRowData(const Standard_Integer theRow,const Handle(TColStd_HSequenceOfInteger)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetRowData(const Standard_Integer theRow) ; +Standard_EXPORT void SetRowTitle(const Standard_Integer theRow,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetRowTitle(const Standard_Integer theRow) const; +Standard_EXPORT void SetColumnData(const Standard_Integer theColumn,const Handle(TColStd_HSequenceOfInteger)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetColumnData(const Standard_Integer theColumn) ; +Standard_EXPORT void SetColumnTitle(const Standard_Integer theColumn,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetColumnTitle(const Standard_Integer theColumn) const; +Standard_EXPORT Standard_Integer GetNbRows() const; +Standard_EXPORT Standard_Integer GetNbColumns() const; + +Standard_EXPORT void PutValue(const Standard_Integer theValue,const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT Standard_Boolean HasValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT Standard_Integer GetValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +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 Handle_TColStd_HSequenceOfInteger GetSetRowIndices(const Standard_Integer theRow); +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetColumnIndices(const Standard_Integer theColumn); + +Standard_EXPORT void ConvertToString(ostrstream& theStream); +Standard_EXPORT bool RestoreFromString(istrstream& theStream); + +Standard_EXPORT ~SALOMEDSImpl_AttributeTableOfInteger() {} + +private: + +TColStd_DataMapOfIntegerInteger myTable; +TCollection_ExtendedString myTitle; +Handle_TColStd_HSequenceOfExtendedString myRows; +Handle_TColStd_HSequenceOfExtendedString myCols; +Standard_Integer myNbRows; +Standard_Integer myNbColumns; + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeTableOfInteger ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx new file mode 100644 index 000000000..9898d8fac --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.cxx @@ -0,0 +1,430 @@ +// File : SALOMEDSImpl_AttributeTableOfReal.cxx +// Author : Michael Ponikarov +// Module : SALOME + +using namespace std; +#include +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTableOfReal, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTableOfReal, SALOMEDSImpl_GenericAttribute ) + +const Standard_GUID& SALOMEDSImpl_AttributeTableOfReal::GetID() +{ + static Standard_GUID SALOMEDSImpl_AttributeTableOfRealID ("128371A1-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeTableOfRealID; +} + +Handle(SALOMEDSImpl_AttributeTableOfReal) SALOMEDSImpl_AttributeTableOfReal::Set(const TDF_Label& label) +{ + Handle(SALOMEDSImpl_AttributeTableOfReal) anAttr; + if (!label.FindAttribute(SALOMEDSImpl_AttributeTableOfReal::GetID(),anAttr)) { + anAttr = new SALOMEDSImpl_AttributeTableOfReal(); + label.AddAttribute(anAttr); + } + return anAttr; +} + +SALOMEDSImpl_AttributeTableOfReal::SALOMEDSImpl_AttributeTableOfReal() +:SALOMEDSImpl_GenericAttribute("AttributeTableOfReal") +{ + myRows = new TColStd_HSequenceOfExtendedString(); + myCols = new TColStd_HSequenceOfExtendedString(); + myNbRows = 0; + myNbColumns = 0; +} + +void SALOMEDSImpl_AttributeTableOfReal::SetNbColumns(const Standard_Integer theNbColumns) +{ + CheckLocked(); + Backup(); + + TColStd_DataMapOfIntegerReal aMap; + aMap = myTable; + myTable.Clear(); + + TColStd_DataMapIteratorOfDataMapOfIntegerReal anIterator(aMap); + for(; anIterator.More(); anIterator.Next()) { + int aRow = (int)(anIterator.Key()/myNbColumns) + 1; + int aCol = (int)(anIterator.Key() - myNbColumns*(aRow-1)); + if(aCol == 0) { aCol = myNbColumns; aRow--; } + if(aCol > theNbColumns) continue; + int aKey = (aRow-1)*theNbColumns+aCol; + myTable.Bind(aKey, anIterator.Value()); + } + + myNbColumns = theNbColumns; + + while (myCols->Length() < myNbColumns) { // append empty columns titles + myCols->Append(TCollection_ExtendedString("")); + } +} + +void SALOMEDSImpl_AttributeTableOfReal::SetTitle(const TCollection_ExtendedString& theTitle) +{ + CheckLocked(); + Backup(); + myTitle = theTitle; +} + +TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfReal::GetTitle() const +{ + return myTitle; +} + +void SALOMEDSImpl_AttributeTableOfReal::SetRowData(const Standard_Integer theRow, + const Handle(TColStd_HSequenceOfReal)& theData) +{ + CheckLocked(); + if(theData->Length() > myNbColumns) SetNbColumns(theData->Length()); + + Backup(); + + while (myRows->Length() < theRow) { // append new row titles + myRows->Append(TCollection_ExtendedString("")); + } + + Standard_Integer i, aShift = (theRow-1)*myNbColumns, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(aShift + i, theData->Value(i)); + } + + if(theRow > myNbRows) myNbRows = theRow; +} + +Handle(TColStd_HSequenceOfReal) SALOMEDSImpl_AttributeTableOfReal::GetRowData(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal(); + Standard_Integer i, aShift = (theRow-1)*myNbColumns; + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift+i)) + aSeq->Append(myTable.Find(aShift+i)); + else + aSeq->Append(0.); + } + + return aSeq; +} + +void SALOMEDSImpl_AttributeTableOfReal::SetRowTitle(const Standard_Integer theRow, + const TCollection_ExtendedString& theTitle) +{ + CheckLocked(); + Backup(); + myRows->SetValue(theRow,theTitle); +} + +TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfReal::GetRowTitle(const Standard_Integer theRow) const +{ + return myRows->Value(theRow); +} + + +void SALOMEDSImpl_AttributeTableOfReal::SetColumnData(const Standard_Integer theColumn, + const Handle(TColStd_HSequenceOfReal)& theData) +{ + CheckLocked(); + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Backup(); + + Standard_Integer i, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(myNbColumns*(i-1)+theColumn, theData->Value(i)); + } + + if(aLength > myNbRows) { + myNbRows = aLength; + while (myRows->Length() < myNbRows) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + } +} + + +Handle(TColStd_HSequenceOfReal) SALOMEDSImpl_AttributeTableOfReal::GetColumnData(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1) + theColumn; + if(myTable.IsBound(anIndex)) + aSeq->Append(myTable.Find(anIndex)); + else + aSeq->Append(0.); + } + + return aSeq; +} + +void SALOMEDSImpl_AttributeTableOfReal::SetColumnTitle(const Standard_Integer theColumn, + const TCollection_ExtendedString& theTitle) +{ + CheckLocked(); + Backup(); + while(myCols->Length() < theColumn) myCols->Append(TCollection_ExtendedString("")); + myCols->SetValue(theColumn,theTitle); +} + +TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfReal::GetColumnTitle(const Standard_Integer theColumn) const +{ + if(myCols.IsNull()) return ""; + if(myCols->Length() < theColumn) return ""; + return myCols->Value(theColumn); +} + + +Standard_Integer SALOMEDSImpl_AttributeTableOfReal::GetNbRows() const +{ + return myNbRows; +} + +Standard_Integer SALOMEDSImpl_AttributeTableOfReal::GetNbColumns() const +{ + return myNbColumns; +} + +void SALOMEDSImpl_AttributeTableOfReal::PutValue(const Standard_Real theValue, + const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + CheckLocked(); + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + myTable.Bind(anIndex, theValue); + + if(theRow > myNbRows) { + while (myRows->Length() < theRow) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + myNbRows = theRow; + } +} + +Standard_Boolean SALOMEDSImpl_AttributeTableOfReal::HasValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + return myTable.IsBound(anIndex); +} + +Standard_Real SALOMEDSImpl_AttributeTableOfReal::GetValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + if(myTable.IsBound(anIndex)) return myTable.Find(anIndex); + + Standard_Failure::Raise("Invalid cell index"); + return 0.; +} + +const Standard_GUID& SALOMEDSImpl_AttributeTableOfReal::ID() const +{ + return GetID(); +} + +void SALOMEDSImpl_AttributeTableOfReal::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer anIndex; + Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(with); + + myTable.Clear(); + myCols->Clear(); + myRows->Clear(); + + myTable = aTable->myTable; + myNbRows = aTable->myNbRows; + myNbColumns = aTable->myNbColumns; + myTitle = aTable->myTitle; + + for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) + myRows->Append(aTable->GetRowTitle(anIndex)); + + for(anIndex = 1; anIndex <= aTable->GetNbColumns(); anIndex++) + myCols->Append(aTable->GetColumnTitle(anIndex)); +} + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeTableOfReal::NewEmpty() const +{ + return new SALOMEDSImpl_AttributeTableOfReal(); +} + +void SALOMEDSImpl_AttributeTableOfReal::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)&) const +{ + Standard_Integer anIndex; + Handle(SALOMEDSImpl_AttributeTableOfReal) aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(into); + + aTable->myTable.Clear(); + aTable->myCols->Clear(); + aTable->myRows->Clear(); + + aTable->myTable = myTable; + aTable->myTitle = myTitle; + aTable->myNbRows = myNbRows; + aTable->myNbColumns = myNbColumns; + + for(anIndex = 1; anIndex <= GetNbRows();anIndex++) + aTable->myRows->Append(GetRowTitle(anIndex)); + for(anIndex = 1; anIndex <= GetNbColumns(); anIndex++) + aTable->myCols->Append(GetColumnTitle(anIndex)); +} + + +Handle_TColStd_HSequenceOfInteger SALOMEDSImpl_AttributeTableOfReal::GetSetRowIndices(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, aShift = myNbColumns*(theRow-1); + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift + i)) aSeq->Append(i); + } + + return aSeq; +} + +Handle_TColStd_HSequenceOfInteger SALOMEDSImpl_AttributeTableOfReal::GetSetColumnIndices(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1)+theColumn; + if(myTable.IsBound(anIndex)) aSeq->Append(i); + } + + return aSeq; +} + + + +void SALOMEDSImpl_AttributeTableOfReal::ConvertToString(ostrstream& theStream) +{ + int i, j, l; + + + //Title + l = myTitle.Length(); + theStream << l << "\n"; + for(i=1; i<=l; i++) + theStream << myTitle.Value(i) << "\n"; + + //Nb rows + theStream << myNbRows << "\n"; + + //Rows titles + for(i=1; i<=myNbRows; i++) { + l = myRows->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myRows->Value(i).Value(j) << "\n"; + } + + //Nb columns + theStream << myNbColumns << "\n"; + + //Columns titles + for(i=1; i<=myNbColumns; i++) { + l = myCols->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myCols->Value(i).Value(j) << "\n"; + } + + //Store the table values + l = myTable.Extent(); + theStream << l << "\n"; + char *aBuffer = new char[128]; + TColStd_DataMapIteratorOfDataMapOfIntegerReal anIterator(myTable); + for(; anIterator.More(); anIterator.Next()) { + theStream << anIterator.Key() << "\n"; + sprintf(aBuffer, "%.64e", anIterator.Value()); + theStream << aBuffer << "\n"; + } + + delete []aBuffer; + + return; +} + +bool SALOMEDSImpl_AttributeTableOfReal::RestoreFromString(istrstream& theStream) +{ + Backup(); + + int i, j, l; + + Standard_ExtCharacter anExtChar; + TCollection_ExtendedString aStr; + + //Title + theStream >> l; + + myTitle = TCollection_ExtendedString(l, 0); + for(i=1; i<=l; i++) { + theStream >> anExtChar; + myTitle.SetValue(i, anExtChar); + } + + //Nb rows + theStream >> myNbRows; + + //Rows titles + myRows->Clear(); + for(i=1; i<=myNbRows; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myRows->Append(aStr); + } + + //Nb columns + theStream >> myNbColumns; + + //Columns titles + myCols->Clear(); + for(i=1; i<=myNbColumns; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myCols->Append(aStr); + } + + //Restore the table values + theStream >> l; + myTable.Clear(); + for(i=1; i<=l; i++) { + Standard_Integer aKey; + Standard_Real aValue; + theStream >> aKey; + theStream >> aValue; + myTable.Bind(aKey, aValue); + } + + return true; +} + +TCollection_AsciiString SALOMEDSImpl_AttributeTableOfReal::Save() +{ + ostrstream ostr; + ConvertToString(ostr); + TCollection_AsciiString aString((char*)ostr.rdbuf()->str()); + return aString; +} + +void SALOMEDSImpl_AttributeTableOfReal::Load(const TCollection_AsciiString& value) +{ + istrstream aStream(value.ToCString(), strlen(value.ToCString())); + RestoreFromString(aStream); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx new file mode 100644 index 000000000..a7fc4f196 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx @@ -0,0 +1,89 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SALOMEDSImpl_AttributeTableOfReal.hxx +// Author : Michael Ponikarov +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeTableOfReal_HeaderFile +#define _SALOMEDSImpl_AttributeTableOfReal_HeaderFile + +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeTableOfReal, SALOMEDSImpl_GenericAttribute ) + +#include +#include +#include +#include +#include +#include + +#include +#include + +class SALOMEDSImpl_AttributeTableOfReal : public SALOMEDSImpl_GenericAttribute +{ + +public: +Standard_EXPORT virtual TCollection_AsciiString Save(); +Standard_EXPORT virtual void Load(const TCollection_AsciiString&); +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeTableOfReal Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDSImpl_AttributeTableOfReal(); +Standard_EXPORT void SetNbColumns(const Standard_Integer theNbColumns); +Standard_EXPORT void SetTitle(const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetTitle() const; +Standard_EXPORT void SetRowData(const Standard_Integer theRow,const Handle(TColStd_HSequenceOfReal)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfReal GetRowData(const Standard_Integer theRow) ; +Standard_EXPORT void SetRowTitle(const Standard_Integer theRow,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetRowTitle(const Standard_Integer theRow) const; +Standard_EXPORT void SetColumnData(const Standard_Integer theColumn,const Handle(TColStd_HSequenceOfReal)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfReal GetColumnData(const Standard_Integer theColumn) ; +Standard_EXPORT void SetColumnTitle(const Standard_Integer theColumn,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetColumnTitle(const Standard_Integer theColumn) const; +Standard_EXPORT Standard_Integer GetNbRows() const; +Standard_EXPORT Standard_Integer GetNbColumns() const; + +Standard_EXPORT void PutValue(const Standard_Real theValue,const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT Standard_Boolean HasValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT Standard_Real GetValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +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 Handle_TColStd_HSequenceOfInteger GetSetRowIndices(const Standard_Integer theRow); +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetColumnIndices(const Standard_Integer theColumn); + +Standard_EXPORT void ConvertToString(ostrstream& theStream); +Standard_EXPORT bool RestoreFromString(istrstream& theStream); + +Standard_EXPORT ~SALOMEDSImpl_AttributeTableOfReal() {} + +private: +TColStd_DataMapOfIntegerReal myTable; +TCollection_ExtendedString myTitle; +Handle_TColStd_HSequenceOfExtendedString myRows; +Handle_TColStd_HSequenceOfExtendedString myCols; +Standard_Integer myNbRows; +Standard_Integer myNbColumns; + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeTableOfReal ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx new file mode 100644 index 000000000..e364ff799 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx @@ -0,0 +1,449 @@ +// File : SALOMEDSImpl_AttributeTableOfString.cxx +// Author : Sergey Ruin +// Module : SALOME + +using namespace std; +#include +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTableOfString, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTableOfString, SALOMEDSImpl_GenericAttribute ) + +const Standard_GUID& SALOMEDSImpl_AttributeTableOfString::GetID() +{ + static Standard_GUID SALOMEDSImpl_AttributeTableOfStringID ("128371A4-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeTableOfStringID; +} + +Handle(SALOMEDSImpl_AttributeTableOfString) SALOMEDSImpl_AttributeTableOfString::Set(const TDF_Label& label) +{ + Handle(SALOMEDSImpl_AttributeTableOfString) anAttr; + if (!label.FindAttribute(SALOMEDSImpl_AttributeTableOfString::GetID(),anAttr)) { + anAttr = new SALOMEDSImpl_AttributeTableOfString(); + label.AddAttribute(anAttr); + } + return anAttr; +} + +SALOMEDSImpl_AttributeTableOfString::SALOMEDSImpl_AttributeTableOfString() +:SALOMEDSImpl_GenericAttribute("AttributeTableOfString") +{ + myRows = new TColStd_HSequenceOfExtendedString(); + myCols = new TColStd_HSequenceOfExtendedString(); + myNbRows = 0; + myNbColumns = 0; +} + +void SALOMEDSImpl_AttributeTableOfString::SetNbColumns(const Standard_Integer theNbColumns) +{ + CheckLocked(); + Backup(); + + SALOMEDSImpl_DataMapOfIntegerString aMap; + aMap = myTable; + myTable.Clear(); + + SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString anIterator(aMap); + for(; anIterator.More(); anIterator.Next()) { + int aRow = (int)(anIterator.Key()/myNbColumns) + 1; + int aCol = (int)(anIterator.Key() - myNbColumns*(aRow-1)); + if(aCol == 0) { aCol = myNbColumns; aRow--; } + if(aCol > theNbColumns) continue; + int aKey = (aRow-1)*theNbColumns+aCol; + myTable.Bind(aKey, anIterator.Value()); + } + + myNbColumns = theNbColumns; + + while (myCols->Length() < myNbColumns) { // append empty columns titles + myCols->Append(TCollection_ExtendedString("")); + } +} + +void SALOMEDSImpl_AttributeTableOfString::SetTitle(const TCollection_ExtendedString& theTitle) +{ + CheckLocked(); + Backup(); + myTitle = theTitle; +} + +TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfString::GetTitle() const +{ + return myTitle; +} + +void SALOMEDSImpl_AttributeTableOfString::SetRowData(const Standard_Integer theRow, + const Handle(TColStd_HSequenceOfExtendedString)& theData) +{ + CheckLocked(); + if(theData->Length() > myNbColumns) SetNbColumns(theData->Length()); + + Backup(); + + while (myRows->Length() < theRow) { // append new row titles + myRows->Append(TCollection_ExtendedString("")); + } + + Standard_Integer i, aShift = (theRow-1)*myNbColumns, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(aShift + i, theData->Value(i)); + } + + if(theRow > myNbRows) myNbRows = theRow; +} + +Handle(TColStd_HSequenceOfExtendedString) SALOMEDSImpl_AttributeTableOfString::GetRowData(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString(); + Standard_Integer i, aShift = (theRow-1)*myNbColumns; + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift+i)) + aSeq->Append(myTable.Find(aShift+i)); + else + aSeq->Append(0.); + } + + return aSeq; +} + +void SALOMEDSImpl_AttributeTableOfString::SetRowTitle(const Standard_Integer theRow, + const TCollection_ExtendedString& theTitle) +{ + CheckLocked(); + Backup(); + myRows->SetValue(theRow,theTitle); +} + +TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfString::GetRowTitle(const Standard_Integer theRow) const +{ + return myRows->Value(theRow); +} + + +void SALOMEDSImpl_AttributeTableOfString::SetColumnData(const Standard_Integer theColumn, + const Handle(TColStd_HSequenceOfExtendedString)& theData) +{ + CheckLocked(); + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Backup(); + + Standard_Integer i, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(myNbColumns*(i-1)+theColumn, theData->Value(i)); + } + + if(aLength > myNbRows) { + myNbRows = aLength; + while (myRows->Length() < myNbRows) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + } +} + + +Handle(TColStd_HSequenceOfExtendedString) SALOMEDSImpl_AttributeTableOfString::GetColumnData(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1) + theColumn; + if(myTable.IsBound(anIndex)) + aSeq->Append(myTable.Find(anIndex)); + else + aSeq->Append(0.); + } + + return aSeq; +} + +void SALOMEDSImpl_AttributeTableOfString::SetColumnTitle(const Standard_Integer theColumn, + const TCollection_ExtendedString& theTitle) +{ + CheckLocked(); + Backup(); + while(myCols->Length() < theColumn) myCols->Append(TCollection_ExtendedString("")); + myCols->SetValue(theColumn,theTitle); +} + +TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfString::GetColumnTitle(const Standard_Integer theColumn) const +{ + if(myCols.IsNull()) return ""; + if(myCols->Length() < theColumn) return ""; + return myCols->Value(theColumn); +} + + +Standard_Integer SALOMEDSImpl_AttributeTableOfString::GetNbRows() const +{ + return myNbRows; +} + +Standard_Integer SALOMEDSImpl_AttributeTableOfString::GetNbColumns() const +{ + return myNbColumns; +} + +void SALOMEDSImpl_AttributeTableOfString::PutValue(const TCollection_ExtendedString& theValue, + const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + CheckLocked(); + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + myTable.Bind(anIndex, theValue); + + if(theRow > myNbRows) { + while (myRows->Length() < theRow) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + myNbRows = theRow; + } +} + +Standard_Boolean SALOMEDSImpl_AttributeTableOfString::HasValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + return myTable.IsBound(anIndex); +} + +TCollection_ExtendedString SALOMEDSImpl_AttributeTableOfString::GetValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + if(myTable.IsBound(anIndex)) return myTable.Find(anIndex); + + Standard_Failure::Raise("Invalid cell index"); + return 0.; +} + +const Standard_GUID& SALOMEDSImpl_AttributeTableOfString::ID() const +{ + return GetID(); +} + +void SALOMEDSImpl_AttributeTableOfString::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer anIndex; + Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(with); + + myTable.Clear(); + myCols->Clear(); + myRows->Clear(); + + myTable = aTable->myTable; + myNbRows = aTable->myNbRows; + myNbColumns = aTable->myNbColumns; + myTitle = aTable->myTitle; + + for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) + myRows->Append(aTable->GetRowTitle(anIndex)); + + for(anIndex = 1; anIndex <= aTable->GetNbColumns(); anIndex++) + myCols->Append(aTable->GetColumnTitle(anIndex)); +} + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeTableOfString::NewEmpty() const +{ + return new SALOMEDSImpl_AttributeTableOfString(); +} + +void SALOMEDSImpl_AttributeTableOfString::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)&) const +{ + Standard_Integer anIndex; + Handle(SALOMEDSImpl_AttributeTableOfString) aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(into); + + aTable->myTable.Clear(); + aTable->myCols->Clear(); + aTable->myRows->Clear(); + + aTable->myTable = myTable; + aTable->myTitle = myTitle; + aTable->myNbRows = myNbRows; + aTable->myNbColumns = myNbColumns; + + for(anIndex = 1; anIndex <= GetNbRows();anIndex++) + aTable->myRows->Append(GetRowTitle(anIndex)); + for(anIndex = 1; anIndex <= GetNbColumns(); anIndex++) + aTable->myCols->Append(GetColumnTitle(anIndex)); +} + + +Handle_TColStd_HSequenceOfInteger SALOMEDSImpl_AttributeTableOfString::GetSetRowIndices(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, aShift = myNbColumns*(theRow-1); + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift + i)) aSeq->Append(i); + } + + return aSeq; +} + +Handle_TColStd_HSequenceOfInteger SALOMEDSImpl_AttributeTableOfString::GetSetColumnIndices(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1)+theColumn; + if(myTable.IsBound(anIndex)) aSeq->Append(i); + } + + return aSeq; +} + + + +void SALOMEDSImpl_AttributeTableOfString::ConvertToString(ostrstream& theStream) +{ + int i, j, l; + + //Title + l = myTitle.Length(); + theStream << l << "\n"; + for(i=1; i<=l; i++) + theStream << myTitle.Value(i) << "\n"; + + //Nb rows + theStream << myNbRows << "\n"; + + //Rows titles + for(i=1; i<=myNbRows; i++) { + l = myRows->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myRows->Value(i).Value(j) << "\n"; + } + + //Nb columns + theStream << myNbColumns << "\n"; + + //Columns titles + for(i=1; i<=myNbColumns; i++) { + l = myCols->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myCols->Value(i).Value(j) << "\n"; + } + + //Store the table values + l = myTable.Extent(); + theStream << l << "\n"; + SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString anIterator(myTable); + for(; anIterator.More(); anIterator.Next()) { + if (anIterator.Value().Length()) { // check empty string in the value table + theStream << anIterator.Key() << "\n"; + unsigned long aValueSize = anIterator.Value().Length(); + theStream<> l; + + myTitle = TCollection_ExtendedString(l, 0); + for(i=1; i<=l; i++) { + theStream >> anExtChar; + myTitle.SetValue(i, anExtChar); + } + + //Nb rows + theStream >> myNbRows; + + //Rows titles + myRows->Clear(); + for(i=1; i<=myNbRows; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myRows->Append(aStr); + } + + //Nb columns + theStream >> myNbColumns; + + //Columns titles + myCols->Clear(); + for(i=1; i<=myNbColumns; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myCols->Append(aStr); + } + + //Restore the table values + TCollection_AsciiString aValue; + theStream >> l; + myTable.Clear(); + theStream.getline(aValueString,aSize,'\n'); + for(i=1; i<=l; i++) { + Standard_Integer aKey; + + theStream.getline(aValueString,aSize,'\n'); + aValue = aValueString; + aKey = aValue.IntegerValue(); + if (aValue.Value(1) == '0') + aValue = ""; + else { + unsigned long aValueSize; + theStream >> aValueSize; + theStream.read(aValueString, 1); // an '\n' omitting + theStream.read(aValueString, aValueSize); + theStream.read(aValueString, 1); // an '\n' omitting + aValue = aValueString; + } + myTable.Bind(aKey, aValue); + } + delete(aValueString); + return true; +} + +TCollection_AsciiString SALOMEDSImpl_AttributeTableOfString::Save() +{ + ostrstream ostr; + ConvertToString(ostr); + TCollection_AsciiString aString((char*)ostr.rdbuf()->str()); + return aString; +} + +void SALOMEDSImpl_AttributeTableOfString::Load(const TCollection_AsciiString& value) +{ + istrstream aStream(value.ToCString(), strlen(value.ToCString())); + RestoreFromString(aStream); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx new file mode 100644 index 000000000..0a3581fb0 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx @@ -0,0 +1,88 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SALOMEDSImpl_AttributeTableOfString.hxx +// Author : Sergey Ruin +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeTableOfString_HeaderFile +#define _SALOMEDSImpl_AttributeTableOfString_HeaderFile + +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeTableOfString, SALOMEDSImpl_GenericAttribute ) + +#include +#include +#include +#include +#include +#include +#include + +class SALOMEDSImpl_AttributeTableOfString : public SALOMEDSImpl_GenericAttribute +{ + +public: +Standard_EXPORT virtual TCollection_AsciiString Save(); +Standard_EXPORT virtual void Load(const TCollection_AsciiString&); +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeTableOfString Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDSImpl_AttributeTableOfString(); +Standard_EXPORT void SetNbColumns(const Standard_Integer theNbColumns); +Standard_EXPORT void SetTitle(const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetTitle() const; +Standard_EXPORT void SetRowData(const Standard_Integer theRow,const Handle(TColStd_HSequenceOfExtendedString)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfExtendedString GetRowData(const Standard_Integer theRow) ; +Standard_EXPORT void SetRowTitle(const Standard_Integer theRow,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetRowTitle(const Standard_Integer theRow) const; +Standard_EXPORT void SetColumnData(const Standard_Integer theColumn,const Handle(TColStd_HSequenceOfExtendedString)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfExtendedString GetColumnData(const Standard_Integer theColumn) ; +Standard_EXPORT void SetColumnTitle(const Standard_Integer theColumn,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetColumnTitle(const Standard_Integer theColumn) const; +Standard_EXPORT Standard_Integer GetNbRows() const; +Standard_EXPORT Standard_Integer GetNbColumns() const; + +Standard_EXPORT void PutValue(const TCollection_ExtendedString& theValue,const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT Standard_Boolean HasValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT TCollection_ExtendedString GetValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +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 Handle_TColStd_HSequenceOfInteger GetSetRowIndices(const Standard_Integer theRow); +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetColumnIndices(const Standard_Integer theColumn); + +Standard_EXPORT void ConvertToString(ostrstream& theStream); +Standard_EXPORT bool RestoreFromString(istrstream& theStream); + +Standard_EXPORT ~SALOMEDSImpl_AttributeTableOfString() {} + +private: + +SALOMEDSImpl_DataMapOfIntegerString myTable; +TCollection_ExtendedString myTitle; +Handle_TColStd_HSequenceOfExtendedString myRows; +Handle_TColStd_HSequenceOfExtendedString myCols; +Standard_Integer myNbRows; +Standard_Integer myNbColumns; + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeTableOfString ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.cxx new file mode 100644 index 000000000..61447c6fb --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.cxx @@ -0,0 +1,152 @@ +// File : SALOMEDSImpl_AttributeTarget.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeTarget.hxx" +#include "SALOMEDSImpl_AttributeReference.hxx" +#include +#include +#include + + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTarget, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTarget, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeTarget::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeTargetID ("12837197-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeTargetID; +} + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDSImpl_AttributeTarget) SALOMEDSImpl_AttributeTarget::Set (const TDF_Label& L) +{ + Handle(SALOMEDSImpl_AttributeTarget) A; + if (!L.FindAttribute(SALOMEDSImpl_AttributeTarget::GetID(),A)) { + A = new SALOMEDSImpl_AttributeTarget(); + L.AddAttribute(A); + } + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeTarget::SALOMEDSImpl_AttributeTarget() +:SALOMEDSImpl_GenericAttribute("AttributeTarget") +{ +} + +void SALOMEDSImpl_AttributeTarget::SetRelation(const TCollection_ExtendedString& theRelation) +{ + CheckLocked(); + if(myRelation == theRelation) return; + + Backup(); + myRelation = theRelation; +} + +//======================================================================= +//function : Append +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeTarget::Append(TDF_Label& theReferencedObject) +{ + Backup(); + Handle(SALOMEDSImpl_AttributeReference) aReference; + if (theReferencedObject.FindAttribute(SALOMEDSImpl_AttributeReference::GetID(),aReference)) { + TDF_ListIteratorOfAttributeList anIter(GetVariables()); + for(;anIter.More();anIter.Next()) if(anIter.Value()->Label() == theReferencedObject) return; //BugID: PAL6192 + GetVariables().Append(aReference); + } +} + +//======================================================================= +//function : Get +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeTarget::Get(TDF_LabelList& theReferencedObjects) +{ + theReferencedObjects.Clear(); + TDF_ListIteratorOfAttributeList anIter(GetVariables()); + for(;anIter.More();anIter.Next()) { + theReferencedObjects.Append(anIter.Value()->Label()); + } +} + +//======================================================================= +//function : Remove +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeTarget::Remove(TDF_Label& theReferencedObject) +{ + Backup(); + TDF_ListIteratorOfAttributeList anIter(GetVariables()); + for(;anIter.More();anIter.Next()) { + if (anIter.Value()->Label() == theReferencedObject) { + GetVariables().Remove(anIter); + return; + } + } +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeTarget::ID () const { return GetID(); } + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeTarget::Restore(const Handle(TDF_Attribute)& With) +{ + Handle(SALOMEDSImpl_AttributeTarget) REL = Handle(SALOMEDSImpl_AttributeTarget)::DownCast (With); + myRelation = REL->GetRelation(); + Handle(SALOMEDSImpl_AttributeReference) V; + myVariables.Clear(); + for (TDF_ListIteratorOfAttributeList it (REL->GetVariables()); it.More(); it.Next()) { + V = Handle(SALOMEDSImpl_AttributeReference)::DownCast(it.Value()); + myVariables.Append(V); + } +} + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= +Handle(TDF_Attribute) SALOMEDSImpl_AttributeTarget::NewEmpty() const +{ + return new SALOMEDSImpl_AttributeTarget(); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeTarget::Paste(const Handle(TDF_Attribute)& Into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeTarget) REL = Handle(SALOMEDSImpl_AttributeTarget)::DownCast (Into); + REL->SetRelation(myRelation); + Handle(SALOMEDSImpl_AttributeReference) V1,V2; + for (TDF_ListIteratorOfAttributeList it (myVariables); it.More(); it.Next()) { + V1 = Handle(SALOMEDSImpl_AttributeReference)::DownCast(it.Value()); + RT->HasRelocation (V1,V2); + REL->GetVariables().Append(V2); + } +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx new file mode 100644 index 000000000..11b40a1be --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx @@ -0,0 +1,51 @@ +// File : SALOMEDSImpl_AttributeTarget.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeTarget_HeaderFile +#define _SALOMEDSImpl_AttributeTarget_HeaderFile + +#include +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeTarget, SALOMEDSImpl_GenericAttribute ) + + +class SALOMEDSImpl_AttributeTarget : public SALOMEDSImpl_GenericAttribute +{ +private: +TCollection_ExtendedString myRelation; +TDF_AttributeList myVariables; + +public: +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeTarget Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDSImpl_AttributeTarget(); +Standard_EXPORT void SALOMEDSImpl_AttributeTarget::Append(TDF_Label& theReferencedObject); +Standard_EXPORT void SALOMEDSImpl_AttributeTarget::Get(TDF_LabelList& theReferencedObjects); +Standard_EXPORT void SALOMEDSImpl_AttributeTarget::Remove(TDF_Label& theReferencedObject); +Standard_EXPORT TCollection_ExtendedString GetRelation() { return myRelation; } +Standard_EXPORT void SetRelation(const TCollection_ExtendedString& theRelation); +Standard_EXPORT TDF_AttributeList& GetVariables() { return myVariables; } +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_AttributeTarget() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeTarget ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.cxx new file mode 100644 index 000000000..f3a3ac7fd --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.cxx @@ -0,0 +1,131 @@ +// File : SALOMEDSImpl_AttributeTextColor.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeTextColor.hxx" +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTextColor, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTextColor, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeTextColor::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeTextColorID ("12837189-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeTextColorID; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeTextColor::SALOMEDSImpl_AttributeTextColor() +:SALOMEDSImpl_GenericAttribute("AttributeTextColor") +{ + myValue = new TColStd_HArray1OfReal(1, 3, RealFirst()); +} + +//======================================================================= +//function : SetTextColor +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeTextColor::SetTextColor(const Standard_Real R, const Standard_Real G, const Standard_Real B) +{ + CheckLocked(); + if(myValue.IsNull()) return; + Backup(); + + myValue->SetValue(1, R); + myValue->SetValue(2, G); + myValue->SetValue(3, B); +} + +//======================================================================= +//function : GetTextColor +//purpose : +//======================================================================= +Handle(TColStd_HArray1OfReal) SALOMEDSImpl_AttributeTextColor::GetTextColor() +{ + return myValue; +} + +//======================================================================= +//function : ChangeArray +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeTextColor::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray) +{ + Backup(); + + for(int i = 1; i <= 3; i++) + myValue->SetValue(i, newArray->Value(i)); +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeTextColor::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeTextColor::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeTextColor(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeTextColor::Restore(const Handle(TDF_Attribute)& with) +{ + Handle(TColStd_HArray1OfReal) s = Handle(SALOMEDSImpl_AttributeTextColor)::DownCast (with)->GetTextColor (); + ChangeArray(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeTextColor::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeTextColor)::DownCast (into)->ChangeArray (myValue); +} + + + +TCollection_AsciiString SALOMEDSImpl_AttributeTextColor::Save() +{ + char *Val = new char[75]; + sprintf(Val, "%f %f %f", (float)myValue->Value(1), + (float)myValue->Value(2), + (float)myValue->Value(3)); + TCollection_AsciiString ret(Val); + delete Val; + return ret; +} + +void SALOMEDSImpl_AttributeTextColor::Load(const TCollection_AsciiString& value) +{ + float r, g, b; + sscanf(value.ToCString(), "%f %f %f", &r, &g, &b); + myValue->SetValue(1, r); + myValue->SetValue(2, g); + myValue->SetValue(3, b); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.hxx new file mode 100644 index 000000000..d4c31c53a --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.hxx @@ -0,0 +1,45 @@ +// File : SALOMEDSImpl_AttributeTextColor.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeTextColor_HeaderFile +#define _SALOMEDSImpl_AttributeTextColor_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeTextColor, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeTextColor : public SALOMEDSImpl_GenericAttribute +{ +private: + Handle(TColStd_HArray1OfReal) myValue; + +public: +Standard_EXPORT virtual TCollection_AsciiString Save(); +Standard_EXPORT virtual void Load(const TCollection_AsciiString&); +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT SALOMEDSImpl_AttributeTextColor(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void SetTextColor(const Standard_Real R, const Standard_Real G, const Standard_Real B); +Standard_EXPORT Handle(TColStd_HArray1OfReal) GetTextColor(); +Standard_EXPORT void ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray); +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_AttributeTextColor() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeTextColor ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.cxx new file mode 100644 index 000000000..93600e88f --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.cxx @@ -0,0 +1,133 @@ +// File : SALOMEDSImpl_AttributeTextHighlightColor.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeTextHighlightColor.hxx" +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTextHighlightColor, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTextHighlightColor, SALOMEDSImpl_GenericAttribute ) + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeTextHighlightColor::GetID () +{ + static Standard_GUID SALOMEDSImpl_AttributeTextHighlightColorID ("12837190-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDSImpl_AttributeTextHighlightColorID; +} + + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDSImpl_AttributeTextHighlightColor::SALOMEDSImpl_AttributeTextHighlightColor() +:SALOMEDSImpl_GenericAttribute("AttributeTextHighlightColor") +{ + myValue = new TColStd_HArray1OfReal(1, 3, RealFirst()); +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDSImpl_AttributeTextHighlightColor::ID () const { return GetID(); } + + +//======================================================================= +//function : SetTextColor +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeTextHighlightColor::SetTextColor(const Standard_Real R, + const Standard_Real G, + const Standard_Real B) +{ + CheckLocked(); + if(myValue.IsNull()) return; + Backup(); + + myValue->SetValue(1, R); + myValue->SetValue(2, G); + myValue->SetValue(3, B); +} + +//======================================================================= +//function : GetTextColor +//purpose : +//======================================================================= +Handle(TColStd_HArray1OfReal) SALOMEDSImpl_AttributeTextHighlightColor::GetTextColor() +{ + return myValue; +} + +//======================================================================= +//function : ChangeArray +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeTextHighlightColor::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray) +{ + Backup(); + + for(int i = 1; i <= 3; i++) + myValue->SetValue(i, newArray->Value(i)); +} + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeTextHighlightColor::NewEmpty () const +{ + return new SALOMEDSImpl_AttributeTextHighlightColor(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeTextHighlightColor::Restore(const Handle(TDF_Attribute)& with) +{ + Handle(TColStd_HArray1OfReal) s = Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast (with)->GetTextColor (); + ChangeArray(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDSImpl_AttributeTextHighlightColor::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& ) const +{ + Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast (into)->ChangeArray (myValue); +} + +TCollection_AsciiString SALOMEDSImpl_AttributeTextHighlightColor::Save() +{ + char *Val = new char[75]; + sprintf(Val, "%f %f %f", (float)myValue->Value(1), + (float)myValue->Value(2), + (float)myValue->Value(3)); + TCollection_AsciiString ret(Val); + delete Val; + return ret; +} + +void SALOMEDSImpl_AttributeTextHighlightColor::Load(const TCollection_AsciiString& value) +{ + float r, g, b; + sscanf(value.ToCString(), "%f %f %f", &r, &g, &b); + myValue->SetValue(1, r); + myValue->SetValue(2, g); + myValue->SetValue(3, b); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.hxx new file mode 100644 index 000000000..b622fb3c3 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.hxx @@ -0,0 +1,45 @@ +// File : SALOMEDSImpl_AttributeTextHighlightColor.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeTextHighlightColor_HeaderFile +#define _SALOMEDSImpl_AttributeTextHighlightColor_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeTextHighlightColor, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeTextHighlightColor : public SALOMEDSImpl_GenericAttribute +{ +private: + Handle(TColStd_HArray1OfReal) myValue; + +public: +Standard_EXPORT virtual TCollection_AsciiString Save(); +Standard_EXPORT virtual void Load(const TCollection_AsciiString&); +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT SALOMEDSImpl_AttributeTextHighlightColor(); +Standard_EXPORT void SetTextColor(const Standard_Real R, const Standard_Real G, const Standard_Real B); +Standard_EXPORT Handle(TColStd_HArray1OfReal) GetTextColor(); +Standard_EXPORT void ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray); +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_AttributeTextHighlightColor() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeTextHighlightColor ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx new file mode 100644 index 000000000..299619443 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx @@ -0,0 +1,548 @@ +// File : SALOMEDSImpl_AttributeTreeNode.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeTreeNode.hxx" +#include +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTreeNode, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTreeNode, SALOMEDSImpl_GenericAttribute ) + +static char* Entry(const TDF_Label& theLabel) +{ + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theLabel, anEntry); + return anEntry.ToCString(); +} + +const Standard_GUID& SALOMEDSImpl_AttributeTreeNode::GetDefaultTreeID() +{ + static Standard_GUID TreeNodeID ("0E1C36E6-379B-4d90-AC37-17A14310E648"); + return TreeNodeID; +} + + +SALOMEDSImpl_AttributeTreeNode::SALOMEDSImpl_AttributeTreeNode() +:SALOMEDSImpl_GenericAttribute("AttributeTreeNode"), myFather(NULL), myPrevious(NULL), myNext(NULL), myFirst(NULL) +{} + + +Handle(SALOMEDSImpl_AttributeTreeNode) SALOMEDSImpl_AttributeTreeNode::Set (const TDF_Label& L, const Standard_GUID& ID) +{ + Handle(SALOMEDSImpl_AttributeTreeNode) TN; + + if (!L.FindAttribute(ID,TN)) { + TN = new SALOMEDSImpl_AttributeTreeNode (); + TN->SetTreeID(ID); + L.AddAttribute(TN); + } + + return TN; +} + +//======================================================================= +//TreeNode : ID +//purpose : Returns GUID of the TreeNode +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeTreeNode::ID() const +{ + return myTreeID; +} + +//======================================================================= +//function : Append +//purpose : Add as last child of me +//======================================================================= +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::Append (const Handle(SALOMEDSImpl_AttributeTreeNode)& TN) +{ + CheckLocked(); + + if (!(TN->ID() == myTreeID) ) + Standard_DomainError::Raise("SALOMEDSImpl_AttributeTreeNode::Append : uncompatible GUID"); + + Handle(SALOMEDSImpl_AttributeTreeNode) bid; + TN->SetNext(bid); // Deconnects from next. + + // Find the last + if (!HasFirst()) { + SetFirst(TN); + TN->SetPrevious(bid); // Deconnects from previous. + } + else { + Handle(SALOMEDSImpl_AttributeTreeNode) Last = GetFirst(); + while (Last->HasNext()) { + Last = Last->GetNext(); + } + Last->SetNext(TN); + TN->SetPrevious(Last); + } + // Set Father + TN->SetFather(this); + return !TN.IsNull(); +} + +//======================================================================= +//function : Prepend +//purpose : Add as first child of me +//======================================================================= +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::Prepend (const Handle(SALOMEDSImpl_AttributeTreeNode)& TN) +{ + CheckLocked(); + + if (!(TN->ID() == myTreeID) ) + Standard_DomainError::Raise("SALOMEDSImpl_AttributeTreeNode::Prepend : uncompatible GUID"); + + Handle(SALOMEDSImpl_AttributeTreeNode) bid; + TN->SetPrevious(bid); + if (HasFirst()) { + TN->SetNext(GetFirst()); + GetFirst()->SetPrevious(TN); + } + else { + TN->SetNext(bid); + } + TN->SetFather(this); + SetFirst(TN); + return !TN.IsNull(); +} + + +//======================================================================= +//function : InsertBefore +//purpose : Inserts the TreeNode before me +//======================================================================= +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::InsertBefore (const Handle(SALOMEDSImpl_AttributeTreeNode)& TN) +{ + CheckLocked(); + + if (!(TN->ID() == myTreeID) ) + Standard_DomainError::Raise("SALOMEDSImpl_AttributeTreeNode::InsertBefore : uncompatible GUID"); + + TN->SetFather(GetFather()); + TN->SetPrevious(GetPrevious()); + TN->SetNext(this); + + if (!HasPrevious()) + GetFather()->SetFirst(TN); + else + GetPrevious()->SetNext(TN); + + SetPrevious(TN); + return !TN.IsNull(); +} + +//======================================================================= +//function : InsertAfter +//purpose : Inserts the TreeNode after me +//======================================================================= +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::InsertAfter (const Handle(SALOMEDSImpl_AttributeTreeNode)& TN) +{ + CheckLocked(); + + if (!(TN->ID() == myTreeID) ) + Standard_DomainError::Raise("SALOMEDSImpl_AttributeTreeNode::InsertAfter : uncompatible GUID"); + + TN->SetFather(GetFather()); + TN->SetPrevious(this); + TN->SetNext(GetNext()); + + if (HasNext()) GetNext()->SetPrevious(TN); + + SetNext(TN); + return !TN.IsNull(); +} + +//======================================================================= +//function : Remove +//purpose : Removees the function from the function tree +//======================================================================= +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::Remove () +{ + CheckLocked(); + + if (IsRoot()) return Standard_True; + + Handle(SALOMEDSImpl_AttributeTreeNode) bid; + if (!HasPrevious()) + GetFather()->SetFirst(GetNext()); + else + GetPrevious()->SetNext(GetNext()); + + if (HasNext()) { + if (HasPrevious()) GetNext()->SetPrevious(GetPrevious()); + else GetNext()->SetPrevious(bid); + } + else { + if (HasPrevious()) GetPrevious()->SetNext(bid); + } + + if (GetFather()->HasFirst()) { + if (Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(this) == GetFather()->GetFirst()) { + if (HasNext()) { + GetFather()->SetFirst(GetNext()); + } + else GetFather()->SetFirst(bid); + } + } + + SetFather(bid); + SetNext(bid); + SetPrevious(bid); + + return Standard_True; +} + +//======================================================================= +//function : Depth +//purpose : +//======================================================================= +Standard_Integer SALOMEDSImpl_AttributeTreeNode::Depth () const +{ + Standard_Integer depth = 0; + Handle(SALOMEDSImpl_AttributeTreeNode) current = this; + while (current->HasFather()) { + depth++; + current = current->GetFather(); + } + return depth; +} + +//======================================================================= +//function : SetTreeID +//purpose : Finds or creates a TreeNode attribute with explicit ID +// : a driver for it +//======================================================================= +void SALOMEDSImpl_AttributeTreeNode::SetTreeID (const Standard_GUID& explicitID) +{ + myTreeID = explicitID; +} + + +//======================================================================= +//function : IsAscendant +//purpose : +//======================================================================= +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::IsAscendant (const Handle(SALOMEDSImpl_AttributeTreeNode)& ofTN) const +{ + return ofTN->IsDescendant(this); +} + +//======================================================================= +//function : IsDescendant +//purpose : +//======================================================================= + +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::IsDescendant (const Handle(SALOMEDSImpl_AttributeTreeNode)& ofTN) const +{ + Handle(SALOMEDSImpl_AttributeTreeNode) current = this; + while (current->HasFather()) { + if (current->GetFather() == ofTN) return Standard_True; + current = current->GetFather(); + } + return Standard_False; +} + +//======================================================================= +//function : IsFather +//purpose : +//======================================================================= + +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::IsFather (const Handle(SALOMEDSImpl_AttributeTreeNode)& ofTN) const +{ + return (ofTN->GetFather() == this); +} + + +//======================================================================= +//function : IsChild +//purpose : +//======================================================================= + +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::IsChild (const Handle(SALOMEDSImpl_AttributeTreeNode)& ofTN) const +{ + return (myFather == ofTN); +} + +//======================================================================= +//TreeNode : IsRoot +//purpose : Returns Standard_True if the TreeNode is not attached to a +// TreeNode tree or hasn't an Father. +//======================================================================= +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::IsRoot() const +{ + if (myFather.IsNull() && + myPrevious.IsNull() && + myNext.IsNull()) + return Standard_True; + return Standard_False; +} + +//======================================================================= +//TreeNode : Root +//purpose : Returns the TreeNode which has no Father +//======================================================================= +Handle(SALOMEDSImpl_AttributeTreeNode) SALOMEDSImpl_AttributeTreeNode::Root() const +{ + Handle(SALOMEDSImpl_AttributeTreeNode) O = this; + while (O->HasFather()) + O = O->GetFather(); + return O; +} + +//======================================================================= +//TreeNode : SetFather +//purpose : Sets the TreeNode F as Father of me +//======================================================================= +void SALOMEDSImpl_AttributeTreeNode::SetFather(const Handle(SALOMEDSImpl_AttributeTreeNode)& F) +{ + CheckLocked(); + Backup(); + myFather = F; +} + +//======================================================================= +//TreeNode : SetNext +//purpose : Sets the TreeNode F next to me +//======================================================================= +void SALOMEDSImpl_AttributeTreeNode::SetNext(const Handle(SALOMEDSImpl_AttributeTreeNode)& F) +{ + CheckLocked(); + Backup(); + myNext = F; +} + + +//======================================================================= +//TreeNode : SetPrevious +//purpose : Sets the TreeNode F previous to me +//======================================================================= +void SALOMEDSImpl_AttributeTreeNode::SetPrevious(const Handle(SALOMEDSImpl_AttributeTreeNode)& F) +{ + CheckLocked(); + Backup(); + myPrevious = F; +} + +//======================================================================= +//TreeNode : SetFirst +//purpose : Sets the TreeNode F as first in the TreeNode tree +//======================================================================= +void SALOMEDSImpl_AttributeTreeNode::SetFirst(const Handle(SALOMEDSImpl_AttributeTreeNode)& F) +{ + CheckLocked(); + Backup(); + myFirst = F; +} + +//======================================================================= +//TreeNode : AfterAddition +//purpose : Connects the TreeNode to the tree. +// Backuped attribute must stay disconnected +//======================================================================= +void SALOMEDSImpl_AttributeTreeNode::AfterAddition() +{ + if (!IsBackuped()) { + if (!myPrevious.IsNull()) { + myPrevious->SetNext(this); + } + else if (!myFather.IsNull()) { + myFather->SetFirst(this); + } + if (!myNext.IsNull()) + myNext->SetPrevious(this); + } +} + +//======================================================================= +//TreeNode : BeforeForget +//purpose : Disconnect the TreeNode from the tree. +// Backuped attribute is normaly not concerned by such an operation +//======================================================================= +void SALOMEDSImpl_AttributeTreeNode::BeforeForget() +{ + if (!IsBackuped()) { + Remove(); + while (HasFirst()) GetFirst()->Remove(); + } +} + +//======================================================================= +//TreeNode : AfterResume +//purpose : Connects the TreeNode to the tree +//======================================================================= +void SALOMEDSImpl_AttributeTreeNode::AfterResume() +{ + AfterAddition(); +} + +//======================================================================= +//TreeNode : BeforeUndo +//purpose : Disconnect the TreeNode from the tree. +//======================================================================= +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::BeforeUndo(const Handle(TDF_AttributeDelta)& anAttDelta, + const Standard_Boolean forceIt) +{ + if (anAttDelta->IsKind(STANDARD_TYPE(TDF_DeltaOnAddition))) BeforeForget(); // Disconnect. + return Standard_True; +} + +//======================================================================= +//TreeNode : AfterUndo +//purpose : Connect the TreeNode from the tree. +//======================================================================= +Standard_Boolean SALOMEDSImpl_AttributeTreeNode::AfterUndo(const Handle(TDF_AttributeDelta)& anAttDelta, + const Standard_Boolean forceIt) +{ + if (anAttDelta->IsKind(STANDARD_TYPE(TDF_DeltaOnRemoval))) AfterAddition(); // Reconnect. + return Standard_True; +} + +//======================================================================= +//TreeNode : Restore +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeTreeNode::Restore(const Handle(TDF_Attribute)& other) +{ + Handle(SALOMEDSImpl_AttributeTreeNode) F = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(other); + myFather = F->myFather; + myPrevious = F->myPrevious; + myNext = F->myNext; + myFirst = F->myFirst; + myTreeID = F->myTreeID; +} + +//======================================================================= +//TreeNode : Paste +//purpose : Method for Copy mechanism +//======================================================================= + +void SALOMEDSImpl_AttributeTreeNode::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeTreeNode) intof = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(into); + Handle(SALOMEDSImpl_AttributeTreeNode) func; + if (!RT->HasRelocation(myFather, func) && RT->AfterRelocate()) { + func.Nullify(); + } + intof->SetFather(func); + if (!RT->HasRelocation(myNext, func) && RT->AfterRelocate()) { + func.Nullify(); + } + intof->SetNext(func); + if (!RT->HasRelocation(myPrevious, func) && RT->AfterRelocate()) { + func.Nullify(); + } + intof->SetPrevious(func); + if (!RT->HasRelocation(myFirst, func) && RT->AfterRelocate()) { + func.Nullify(); + } + + intof->SetFirst(func); + intof->SetTreeID(myTreeID); +} + +//======================================================================= +//TreeNode : NewEmpty +//purpose : Returns new empty TreeNode attribute +//======================================================================= + +Handle(TDF_Attribute) SALOMEDSImpl_AttributeTreeNode::NewEmpty() const +{ + Handle(SALOMEDSImpl_AttributeTreeNode) T = new SALOMEDSImpl_AttributeTreeNode(); + T->SetTreeID(myTreeID); + return T; +} + +//======================================================================= +//TreeNode : References +//purpose : Collects the references +//======================================================================= +void SALOMEDSImpl_AttributeTreeNode::References(const Handle(TDF_DataSet)& aDataSet) const +{ + Handle(SALOMEDSImpl_AttributeTreeNode) fct = myFirst; + while (!fct.IsNull()) { + aDataSet->AddAttribute(fct); + fct = fct->myNext; + } +} + +TCollection_AsciiString SALOMEDSImpl_AttributeTreeNode::Type() +{ + char* aNodeName = new char[60]; + char aGUID[40]; + ID().ToCString(aGUID); + sprintf(aNodeName, "AttributeTreeNodeGUID%s",aGUID); + TCollection_AsciiString ret(aNodeName); + delete aNodeName; + + return ret; +} + +TCollection_AsciiString SALOMEDSImpl_AttributeTreeNode::Save() +{ + TCollection_AsciiString aFather, aPrevious, aNext, aFirst; + + if (HasFather()) aFather = Entry(GetFather()->Label()); else aFather = "!"; + if (HasPrevious()) aPrevious = Entry(GetPrevious()->Label()); else aPrevious = "!"; + if (HasNext()) aNext = Entry(GetNext()->Label()); else aNext = "!"; + if (HasFirst()) aFirst = Entry(GetFirst()->Label()); else aFirst = "!"; + + int aLength = 4; + aLength += aFather.Length() + aPrevious.Length() + aNext.Length() + aFirst.Length(); + char* aResult = new char[aLength]; + sprintf(aResult, "%s %s %s %s", aFather.ToCString(), aPrevious.ToCString(), aNext.ToCString(), aFirst.ToCString()); + TCollection_AsciiString ret(aResult); + delete aResult; + return ret; +} + +void SALOMEDSImpl_AttributeTreeNode::Load(const TCollection_AsciiString& value) +{ + Handle(TDF_Data) DF = Label().Data(); + + char* aCopy = (char*)value.ToCString(); + char* adr = strtok(aCopy, " "); + + TDF_Label aLabel; + Handle(SALOMEDSImpl_AttributeTreeNode) aDepNode; + + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(ID(), aDepNode)) + aDepNode = SALOMEDSImpl_AttributeTreeNode::Set(aLabel, ID()); + + SetFather(aDepNode); + } + + adr = strtok(NULL, " "); + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(ID(), aDepNode)) + aDepNode = SALOMEDSImpl_AttributeTreeNode::Set(aLabel, ID()); + SetPrevious(aDepNode); + } + + adr = strtok(NULL, " "); + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(ID(), aDepNode)) + aDepNode = SALOMEDSImpl_AttributeTreeNode::Set(aLabel, ID()); + SetNext(aDepNode); + } + + adr = strtok(NULL, " "); + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(ID(), aDepNode)) + aDepNode = SALOMEDSImpl_AttributeTreeNode::Set(aLabel, ID()); + SetFirst(aDepNode); + } +} + + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.hxx new file mode 100644 index 000000000..c61715f51 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.hxx @@ -0,0 +1,94 @@ +// File : SALOMEDSImpl_AttributeTreeNode.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeTreeNode_HeaderFile +#define _SALOMEDSImpl_AttributeTreeNode_HeaderFile + +#include +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Handle_TDF_DataSet; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); +class SALOMEDSImpl_ChildNodeIterator; + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeTreeNode, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeTreeNode : public SALOMEDSImpl_GenericAttribute +{ +public: + +Standard_EXPORT const static Standard_GUID& GetDefaultTreeID(); +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeTreeNode Set(const TDF_Label& L, const Standard_GUID& ID); + +Standard_EXPORT SALOMEDSImpl_AttributeTreeNode(); +Standard_EXPORT void SetFather(const Handle(SALOMEDSImpl_AttributeTreeNode)& value); +Standard_EXPORT void SetPrevious(const Handle(SALOMEDSImpl_AttributeTreeNode)& value); +Standard_EXPORT void SetNext(const Handle(SALOMEDSImpl_AttributeTreeNode)& value); +Standard_EXPORT void SetFirst(const Handle(SALOMEDSImpl_AttributeTreeNode)& value); +Standard_EXPORT void SetTreeID(const Standard_GUID& value); + +Standard_EXPORT Standard_Boolean Append(const Handle(SALOMEDSImpl_AttributeTreeNode)& value); +Standard_EXPORT Standard_Boolean Prepend(const Handle(SALOMEDSImpl_AttributeTreeNode)& value); +Standard_EXPORT Standard_Boolean Remove(); +Standard_EXPORT Standard_Boolean InsertBefore(const Handle(SALOMEDSImpl_AttributeTreeNode)& value); +Standard_EXPORT Standard_Boolean InsertAfter(const Handle(SALOMEDSImpl_AttributeTreeNode)& value); + +Standard_EXPORT Handle(SALOMEDSImpl_AttributeTreeNode) GetFather() { return myFather; } +Standard_EXPORT Handle(SALOMEDSImpl_AttributeTreeNode) GetPrevious() { return myPrevious; } +Standard_EXPORT Handle(SALOMEDSImpl_AttributeTreeNode) GetNext() { return myNext; } +Standard_EXPORT Handle(SALOMEDSImpl_AttributeTreeNode) GetFirst() { return myFirst; } + +Standard_EXPORT Standard_Boolean HasFather() { return (!myFather.IsNull()); } +Standard_EXPORT Standard_Boolean HasPrevious() { return (!myPrevious.IsNull()); } +Standard_EXPORT Standard_Boolean HasNext() {return (!myNext.IsNull()); } +Standard_EXPORT Standard_Boolean HasFirst() { return (!myFirst.IsNull()); } +Standard_EXPORT const Standard_GUID& GetTreeID() { return ID(); } +Standard_EXPORT Standard_Integer Depth() const; +Standard_EXPORT Standard_Boolean IsRoot() const ; +Standard_EXPORT Handle(SALOMEDSImpl_AttributeTreeNode) Root() const; +Standard_EXPORT Standard_Boolean IsAscendant (const Handle(SALOMEDSImpl_AttributeTreeNode)& ofTN) const; +Standard_EXPORT Standard_Boolean IsDescendant(const Handle(SALOMEDSImpl_AttributeTreeNode)& value) const; +Standard_EXPORT Standard_Boolean IsFather(const Handle(SALOMEDSImpl_AttributeTreeNode)& value) const; +Standard_EXPORT Standard_Boolean IsChild(const Handle(SALOMEDSImpl_AttributeTreeNode)& value) const; + +Standard_EXPORT virtual TCollection_AsciiString Save(); +Standard_EXPORT virtual void Load(const TCollection_AsciiString&); +Standard_EXPORT virtual TCollection_AsciiString Type(); + +Standard_EXPORT virtual void AfterAddition() ; +Standard_EXPORT virtual void BeforeForget() ; +Standard_EXPORT virtual void AfterResume() ; +Standard_EXPORT virtual Standard_Boolean BeforeUndo(const Handle(TDF_AttributeDelta)& anAttDelta, + const Standard_Boolean forceIt = Standard_False) ; +Standard_EXPORT virtual Standard_Boolean AfterUndo(const Handle(TDF_AttributeDelta)& anAttDelta, + const Standard_Boolean forceIt = Standard_False) ; +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const; +Standard_EXPORT void References(const Handle(TDF_DataSet)& aDataSet) const; +Standard_EXPORT ~SALOMEDSImpl_AttributeTreeNode() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeTreeNode ) + +private: + +Standard_GUID myTreeID; +Handle(SALOMEDSImpl_AttributeTreeNode) myFather; +Handle(SALOMEDSImpl_AttributeTreeNode) myPrevious; +Handle(SALOMEDSImpl_AttributeTreeNode) myNext; +Handle(SALOMEDSImpl_AttributeTreeNode) myFirst; + +friend class SALOMEDSImpl_ChildNodeIterator; + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.cxx new file mode 100644 index 000000000..8eebc2b41 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.cxx @@ -0,0 +1,87 @@ +// File : SALOMEDSImpl_AttributeUAttribute.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_AttributeUserID.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeUserID, SALOMEDSImpl_GenericAttribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeUserID, SALOMEDSImpl_GenericAttribute ) + +Handle(SALOMEDSImpl_AttributeUserID) SALOMEDSImpl_AttributeUserID::Set (const TDF_Label& L, const Standard_GUID& ID) +{ + Handle(SALOMEDSImpl_AttributeUserID) A; + if (!L.FindAttribute(ID, A)) { + A = new SALOMEDSImpl_AttributeUserID(); + A->SetValue(ID); + L.AddAttribute(A); + } + return A; +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= +const Standard_GUID& SALOMEDSImpl_AttributeUserID::ID() const +{ return myID; } + + +//======================================================================= +//function : SetValue +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeUserID::SetValue( const Standard_GUID& guid) +{ + CheckLocked(); + if(myID == guid) return; + + Backup(); + myID = guid; +} + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= +Handle(TDF_Attribute) SALOMEDSImpl_AttributeUserID::NewEmpty () const +{ + Handle(SALOMEDSImpl_AttributeUserID) A = new SALOMEDSImpl_AttributeUserID(); + A->SetValue(myID); + return A; +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeUserID::Restore(const Handle(TDF_Attribute)& with) +{ + Handle(SALOMEDSImpl_AttributeUserID) A = Handle(SALOMEDSImpl_AttributeUserID)::DownCast(with); + SetValue( A->ID() ); +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeUserID::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(SALOMEDSImpl_AttributeUserID) A = Handle(SALOMEDSImpl_AttributeUserID)::DownCast(into); + A->SetValue( myID ); +} + +TCollection_AsciiString SALOMEDSImpl_AttributeUserID::Type() +{ + + char* aUAttrName = new char[60]; + char aGUID[40]; + ID().ToCString(aGUID); + sprintf(aUAttrName, "AttributeUserID_%s",aGUID); + + TCollection_AsciiString ret(aUAttrName); + delete aUAttrName; + + return ret; +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.hxx new file mode 100644 index 000000000..106c973ab --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.hxx @@ -0,0 +1,51 @@ +// File : SALOMEDSImpl_AttributeUAttribute.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_AttributeUserID_HeaderFile +#define _SALOMEDSImpl_AttributeUserID_HeaderFile + +#include +#include +#include +#include +#include +#include "SALOMEDSImpl_GenericAttribute.hxx" + +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeUserID, SALOMEDSImpl_GenericAttribute ) + +class SALOMEDSImpl_AttributeUserID : public SALOMEDSImpl_GenericAttribute +{ +private: +Standard_GUID myID; + +public: +SALOMEDSImpl_AttributeUserID():SALOMEDSImpl_GenericAttribute("AttributeUserID") {} +static Handle(SALOMEDSImpl_AttributeUserID) Set (const TDF_Label& L, const Standard_GUID& ID); +static const Standard_GUID& DefaultID() +{ + static Standard_GUID SALOMEDSImpl_DefaultUserAttributeID ("FFFFFFFF-D9CD-11d6-945D-1050DA506788"); + return SALOMEDSImpl_DefaultUserAttributeID; +} + +Standard_EXPORT const Standard_GUID& Value() const { return ID(); } +Standard_EXPORT void SetValue(const Standard_GUID& value); + +Standard_EXPORT virtual TCollection_AsciiString Type(); + +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_AttributeUserID() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeUserID ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Attributes.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Attributes.hxx new file mode 100644 index 000000000..c37e2a14e --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Attributes.hxx @@ -0,0 +1,128 @@ +// File : SALOMEDSImpl_Attributes.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef __SALOMEDSIMPL_ATTRIBUTES__H__ +#define __SALOMEDSIMPL_ATTRIBUTES__H__ + +#include +class LockProtection +{ +public : + LockProtection(const char *message) { + std::cerr << message << std::endl; + } +}; + +#include "SALOMEDSImpl_GenericAttribute.hxx" +#include "SALOMEDSImpl_AttributeName.hxx" +#include "SALOMEDSImpl_AttributeComment.hxx" +#include "SALOMEDSImpl_AttributeInteger.hxx" +#include "SALOMEDSImpl_AttributeReal.hxx" +#include "SALOMEDSImpl_AttributeTreeNode.hxx" +#include "SALOMEDSImpl_AttributeUserID.hxx" +#include "SALOMEDSImpl_AttributeReference.hxx" +#include "SALOMEDSImpl_AttributeSequenceOfReal.hxx" +#include "SALOMEDSImpl_AttributeSequenceOfInteger.hxx" +#include "SALOMEDSImpl_AttributeIOR.hxx" +#include "SALOMEDSImpl_AttributePersistentRef.hxx" +#include "SALOMEDSImpl_AttributeDrawable.hxx" +#include "SALOMEDSImpl_AttributeSelectable.hxx" +#include "SALOMEDSImpl_AttributeExpandable.hxx" +#include "SALOMEDSImpl_AttributeOpened.hxx" +#include "SALOMEDSImpl_AttributeTextColor.hxx" +#include "SALOMEDSImpl_AttributeTextHighlightColor.hxx" +#include "SALOMEDSImpl_AttributePixMap.hxx" +#include "SALOMEDSImpl_AttributeLocalID.hxx" +#include "SALOMEDSImpl_AttributeTarget.hxx" +#include "SALOMEDSImpl_AttributeTableOfInteger.hxx" +#include "SALOMEDSImpl_AttributeTableOfReal.hxx" +#include "SALOMEDSImpl_AttributeTableOfString.hxx" +#include "SALOMEDSImpl_AttributeStudyProperties.hxx" +#include "SALOMEDSImpl_AttributePythonObject.hxx" +#include "SALOMEDSImpl_AttributeExternalFileDef.hxx" +#include "SALOMEDSImpl_AttributeFileType.hxx" +#include "SALOMEDSImpl_AttributeFlags.hxx" +#include "SALOMEDSImpl_AttributeGraphic.hxx" + + +#define __AttributeTypeToGUIDForSObject \ + if(theType == "AttributeReal") return SALOMEDSImpl_AttributeReal::GetID(); \ + if(theType == "AttributeInteger") return SALOMEDSImpl_AttributeInteger::GetID(); \ + if(theType == "AttributeSequenceOfReal") return SALOMEDSImpl_AttributeSequenceOfReal::GetID(); \ + if(theType == "AttributeSequenceOfInteger") return SALOMEDSImpl_AttributeSequenceOfInteger::GetID(); \ + if(theType == "AttributeName") return SALOMEDSImpl_AttributeName::GetID(); \ + if(theType == "AttributeComment") return SALOMEDSImpl_AttributeComment::GetID(); \ + if(theType == "AttributeIOR") return SALOMEDSImpl_AttributeIOR::GetID(); \ + if(theType == "AttributePersistentRef") return SALOMEDSImpl_AttributePersistentRef::GetID(); \ + if(theType == "AttributeDrawable") return SALOMEDSImpl_AttributeDrawable::GetID(); \ + if(theType == "AttributeSelectable") return SALOMEDSImpl_AttributeSelectable::GetID(); \ + if(theType == "AttributeExpandable") return SALOMEDSImpl_AttributeExpandable::GetID(); \ + if(theType == "AttributeOpened") return SALOMEDSImpl_AttributeOpened::GetID(); \ + if(theType == "AttributeTextColor") return SALOMEDSImpl_AttributeTextColor::GetID(); \ + if(theType == "AttributeTextHighlightColor") return SALOMEDSImpl_AttributeTextHighlightColor::GetID(); \ + if(theType == "AttributePixMap") return SALOMEDSImpl_AttributePixMap::GetID(); \ + if(theType == "AttributeLocalID") return SALOMEDSImpl_AttributeLocalID::GetID(); \ + if(theType == "AttributeTarget") return SALOMEDSImpl_AttributeTarget::GetID(); \ + if(theType == "AttributeTableOfInteger") return SALOMEDSImpl_AttributeTableOfInteger::GetID(); \ + if(theType == "AttributeTableOfReal") return SALOMEDSImpl_AttributeTableOfReal::GetID(); \ + if(theType == "AttributeTableOfString") return SALOMEDSImpl_AttributeTableOfString::GetID(); \ + if(theType == "AttributeStudyProperties") return SALOMEDSImpl_AttributeStudyProperties::GetID(); \ + if(theType == "AttributePythonObject") return SALOMEDSImpl_AttributePythonObject::GetID(); \ + if(theType == "AttributeUserID") return Standard_GUID("FFFFFFFF-D9CD-11d6-945D-1050DA506788"); \ + if(theType == "AttributeExternalFileDef") return SALOMEDSImpl_AttributeExternalFileDef::GetID(); \ + 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(); + + +#define __FindOrCreateAttributeLocked(ClassName) if (strcmp(aTypeOfAttribute.ToCString(), #ClassName) == 0) { \ + Handle(SALOMEDSImpl_##ClassName) anAttr; \ + if (!Lab.FindAttribute(SALOMEDSImpl_##ClassName::GetID(), anAttr)) { \ + CheckLocked(); \ + anAttr = new SALOMEDSImpl_##ClassName; \ + Lab.AddAttribute(anAttr); \ + } \ + return anAttr; \ + } + +#define __FindOrCreateAttribute(ClassName) if (strcmp(aTypeOfAttribute.ToCString(), #ClassName) == 0) { \ + Handle(SALOMEDSImpl_##ClassName) anAttr; \ + if (!Lab.FindAttribute(SALOMEDSImpl_##ClassName::GetID(), anAttr)) { \ + anAttr = new SALOMEDSImpl_##ClassName; \ + Lab.AddAttribute(anAttr); \ + } \ + return anAttr; \ + } + +#define __FindOrCreateAttributeForBuilder \ +__FindOrCreateAttributeLocked(AttributeReal) \ +__FindOrCreateAttributeLocked(AttributeInteger) \ +__FindOrCreateAttributeLocked(AttributeSequenceOfReal) \ +__FindOrCreateAttributeLocked(AttributeSequenceOfInteger) \ +__FindOrCreateAttributeLocked(AttributeName) \ +__FindOrCreateAttributeLocked(AttributeComment) \ +__FindOrCreateAttributeLocked(AttributeIOR) \ +__FindOrCreateAttributeLocked(AttributePixMap) \ +__FindOrCreateAttributeLocked(AttributeLocalID) \ +__FindOrCreateAttributeLocked(AttributeTableOfInteger) \ +__FindOrCreateAttributeLocked(AttributeTableOfReal) \ +__FindOrCreateAttributeLocked(AttributeTableOfString) \ +__FindOrCreateAttributeLocked(AttributePythonObject) \ +__FindOrCreateAttribute(AttributePersistentRef) \ +__FindOrCreateAttribute(AttributeDrawable) \ +__FindOrCreateAttribute(AttributeSelectable) \ +__FindOrCreateAttribute(AttributeExpandable) \ +__FindOrCreateAttribute(AttributeOpened) \ +__FindOrCreateAttribute(AttributeTextColor) \ +__FindOrCreateAttribute(AttributeTextHighlightColor) \ +__FindOrCreateAttribute(AttributeTarget) \ +__FindOrCreateAttribute(AttributeStudyProperties) \ +__FindOrCreateAttribute(AttributeExternalFileDef) \ +__FindOrCreateAttribute(AttributeFileType) \ +__FindOrCreateAttribute(AttributeFlags) \ +__FindOrCreateAttribute(AttributeGraphic) + + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Callback.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Callback.cxx new file mode 100644 index 000000000..8b5563993 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Callback.cxx @@ -0,0 +1,9 @@ +// File : SALOMEDSImpl_Callback.cxx +// Author : Sergey RUIN +// Module : SALOME + +#include "SALOMEDSImpl_Callback.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_Callback, MMgt_TShared ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_Callback, MMgt_TShared ) + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx new file mode 100644 index 000000000..c78054bd7 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx @@ -0,0 +1,42 @@ +// File : SALOMEDSImpl_Callback.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef __SALOMEDSIMPL_CALLBACK_H__ +#define __SALOMEDSIMPL_CALLBACK_H__ + +//Handle definition +#include +#include +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_Callback, MMgt_TShared ) + +#include "SALOMEDSImpl_UseCaseBuilder.hxx" + +class SALOMEDSImpl_Callback : public MMgt_TShared +{ +private: + Handle(SALOMEDSImpl_UseCaseBuilder) _builder; + +public: + + SALOMEDSImpl_Callback(const Handle(SALOMEDSImpl_UseCaseBuilder)& builder) + { + _builder = builder; + } + + virtual void OnAddSObject(Handle(SALOMEDSImpl_SObject) theObject) + { + if(_builder != NULL && theObject != NULL) _builder->Append(theObject); + } + + virtual void OnRemoveSObject(Handle(SALOMEDSImpl_SObject) theObject) + { + if(_builder != NULL && theObject != NULL) _builder->Remove(theObject); + } + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_Callback ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.cxx new file mode 100644 index 000000000..11ce37bd5 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.cxx @@ -0,0 +1,75 @@ +// File: SALOMEDSImpl_ChildNodeIterator.cxx +// Created: Wed Jan 26 16:43:08 2000 +// Author: Denis PASCAL +// + + +#include + +#define ChildNodeIterator_UpToBrother \ +{ \ + while (!myNode.IsNull() && (myNode->Depth() > myFirstLevel) && myNode->myNext == NULL) \ + myNode = myNode->myFather; \ + if (!myNode.IsNull() && (myNode->Depth() > myFirstLevel) && myNode->myFather != NULL) \ + myNode = myNode->myNext; \ + else \ + myNode = NULL; \ +} + +//======================================================================= +//function : SALOMEDSImpl_ChildNodeIterator +//purpose : +//======================================================================= +SALOMEDSImpl_ChildNodeIterator::SALOMEDSImpl_ChildNodeIterator() + : myFirstLevel(0) +{} + +//======================================================================= +//function : SALOMEDSImpl_ChildNodeIterator +//purpose : +//======================================================================= + +SALOMEDSImpl_ChildNodeIterator::SALOMEDSImpl_ChildNodeIterator (const Handle(SALOMEDSImpl_AttributeTreeNode)& aNode, + const Standard_Boolean allLevels) +: myNode(aNode->myFirst), + myFirstLevel(allLevels ? aNode->Depth() : -1) +{} + +//======================================================================= +//function : Initialize +//purpose : +//======================================================================= + +void SALOMEDSImpl_ChildNodeIterator::Initialize(const Handle(SALOMEDSImpl_AttributeTreeNode)& aNode, + const Standard_Boolean allLevels) +{ + myNode = aNode->myFirst; + myFirstLevel = allLevels ? aNode->Depth() : -1; +} + +//======================================================================= +//function : Next +//purpose : +//======================================================================= + +void SALOMEDSImpl_ChildNodeIterator::Next() +{ + if (myFirstLevel == -1) { + myNode = myNode->myNext; + } + else { + if (myNode->myFirst != NULL) myNode = myNode->myFirst; + else ChildNodeIterator_UpToBrother; + } +} + +//======================================================================= +//function : NextBrother +//purpose : +//======================================================================= + +void SALOMEDSImpl_ChildNodeIterator::NextBrother() +{ + if (myNode->myNext != NULL) myNode = myNode->myNext; + else ChildNodeIterator_UpToBrother; +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.hxx new file mode 100644 index 000000000..5b7b5924a --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.hxx @@ -0,0 +1,45 @@ + +#ifndef _SALOMEDSImpl_ChildNodeIterator_HeaderFile +#define _SALOMEDSImpl_ChildNodeIterator_HeaderFile + +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif + +#include "SALOMEDSImpl_AttributeTreeNode.hxx" + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOMEDSImpl_ChildNodeIterator +{ + +public: + +Standard_EXPORT SALOMEDSImpl_ChildNodeIterator(); +Standard_EXPORT SALOMEDSImpl_ChildNodeIterator(const Handle(SALOMEDSImpl_AttributeTreeNode)& aTreeNode, + const Standard_Boolean allLevels = Standard_False); +Standard_EXPORT void Initialize(const Handle(SALOMEDSImpl_AttributeTreeNode)& aTreeNode, + const Standard_Boolean allLevels = Standard_False) ; +Standard_EXPORT Standard_Boolean More() const { return !myNode.IsNull(); } +Standard_EXPORT void Next() ; +Standard_EXPORT void NextBrother() ; +Standard_EXPORT Handle_SALOMEDSImpl_AttributeTreeNode Value() const { return myNode; } + +private: + +Handle_SALOMEDSImpl_AttributeTreeNode myNode; +Standard_Integer myFirstLevel; + +}; + + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString.hxx new file mode 100644 index 000000000..3554c2a1d --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString.hxx @@ -0,0 +1,95 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString.hxx +// Author : Sergey Ruin +// Module : SALOME + +#ifndef _SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString_HeaderFile +#define _SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString_HeaderFile + +#ifndef _TCollection_BasicMapIterator_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class TCollection_ExtendedString; +class TColStd_MapIntegerHasher; +class SALOMEDSImpl_DataMapOfIntegerString; +class SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString : public TCollection_BasicMapIterator { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString(); +Standard_EXPORT SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString(const SALOMEDSImpl_DataMapOfIntegerString& aMap); +Standard_EXPORT void Initialize(const SALOMEDSImpl_DataMapOfIntegerString& aMap) ; +Standard_EXPORT const Standard_Real& Key() const; +Standard_EXPORT const TCollection_ExtendedString& Value() const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString_0.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString_0.cxx new file mode 100644 index 000000000..e5581a721 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString_0.cxx @@ -0,0 +1,45 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString_0.cxx +// Author : Sergey Ruin +// Module : SALOME + +#include + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _SALOMEDSImpl_DataMapOfIntegerString_HeaderFile +#include +#endif +#ifndef _SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#include +#endif + + +#define TheKey Standard_Real +#define TheKey_hxx +#define TheItem TCollection_ExtendedString +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_Type_() SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_Type_() +#define TCollection_DataMap SALOMEDSImpl_DataMapOfIntegerString +#define TCollection_DataMap_hxx +#include + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx new file mode 100644 index 000000000..b95db21e9 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx @@ -0,0 +1,113 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel_HeaderFile +#define _SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel_HeaderFile + +#ifndef _TCollection_BasicMapIterator_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class TCollection_ExtendedString; +class TDF_Label; +class SALOMEDSImpl_DataMapStringLabel; +class SALOMEDSImpl_DataMapNodeOfDataMapStringLabel; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel : public TCollection_BasicMapIterator { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel(); +Standard_EXPORT SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel(const SALOMEDSImpl_DataMapStringLabel& aMap); +Standard_EXPORT void Initialize(const SALOMEDSImpl_DataMapStringLabel& aMap) ; +Standard_EXPORT const TCollection_ExtendedString& Key() const; +Standard_EXPORT const TDF_Label& Value() const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel_0.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel_0.cxx new file mode 100644 index 000000000..1f4520f9d --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel_0.cxx @@ -0,0 +1,63 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel_0.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx" + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _SALOMEDSImpl_DataMapStringLabel_HeaderFile +#include "SALOMEDSImpl_DataMapStringLabel.hxx" +#endif +#ifndef _SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_HeaderFile +#include "SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx" +#endif + + +#define TheKey TCollection_ExtendedString +#define TheKey_hxx +#define TheItem TDF_Label +#define TheItem_hxx +#define Hasher TCollection_ExtendedString +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDSImpl_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_hxx "SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx" +#define TCollection_DataMapIterator SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel +#define TCollection_DataMapIterator_hxx "SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_Type_() SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_Type_() +#define TCollection_DataMap SALOMEDSImpl_DataMapStringLabel +#define TCollection_DataMap_hxx "SALOMEDSImpl_DataMapStringLabel.hxx" +#include + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx new file mode 100644 index 000000000..f892b9a57 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx @@ -0,0 +1,132 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString.hxx +// Author : Sergey Ruin +// Module : SALOME + +#ifndef _SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#define _SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#include +#endif + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class TCollection_ExtendedString; +class TColStd_MapIntegerHasher; +class SALOMEDSImpl_DataMapOfIntegerString; +class SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString; + + +class SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString : public TCollection_MapNode { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString(const Standard_Real& K,const TCollection_ExtendedString& I,const TCollection_MapNodePtr& n); + Standard_Real& Key() const; + TCollection_ExtendedString& Value() const; +Standard_EXPORT ~SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Real myKey; +TCollection_ExtendedString myValue; + + +}; + +#define TheKey Standard_Real +#define TheKey_hxx +#define TheItem TCollection_ExtendedString +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_Type_() SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_Type_() +#define TCollection_DataMap SALOMEDSImpl_DataMapOfIntegerString +#define TCollection_DataMap_hxx + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_DataMapNode +#undef TCollection_DataMapNode_hxx +#undef TCollection_DataMapIterator +#undef TCollection_DataMapIterator_hxx +#undef Handle_TCollection_DataMapNode +#undef TCollection_DataMapNode_Type_ +#undef TCollection_DataMap +#undef TCollection_DataMap_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_0.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_0.cxx new file mode 100644 index 000000000..b887a2ab7 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_0.cxx @@ -0,0 +1,94 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_0.cxx +// Author : Sergey Ruin +// Module : SALOME + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _SALOMEDSImpl_DataMapOfIntegerString_HeaderFile +#include +#endif +#ifndef _SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString_HeaderFile +#include +#endif +SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString::~SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString", + sizeof(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString) Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString))) { + _anOtherObject = Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString)((Handle(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString) ; +} +Standard_Boolean SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString::~Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString() {} +#define TheKey Standard_Real +#define TheKey_hxx +#define TheItem TCollection_ExtendedString +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_Type_() SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_Type_() +#define TCollection_DataMap SALOMEDSImpl_DataMapOfIntegerString +#define TCollection_DataMap_hxx +#include + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx new file mode 100644 index 000000000..24c764188 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx @@ -0,0 +1,153 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_HeaderFile +#define _SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_HeaderFile +#include +#endif + +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class TCollection_ExtendedString; +class TDF_Label; +class SALOMEDSImpl_DataMapStringLabel; +class SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel; + + +class SALOMEDSImpl_DataMapNodeOfDataMapStringLabel : public TCollection_MapNode { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT inline SALOMEDSImpl_DataMapNodeOfDataMapStringLabel(const TCollection_ExtendedString& K,const TDF_Label& I,const TCollection_MapNodePtr& n); +Standard_EXPORT inline TCollection_ExtendedString& Key() const; +Standard_EXPORT inline TDF_Label& Value() const; +Standard_EXPORT ~SALOMEDSImpl_DataMapNodeOfDataMapStringLabel(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +TCollection_ExtendedString myKey; +TDF_Label myValue; + + +}; + +#define TheKey TCollection_ExtendedString +#define TheKey_hxx +#define TheItem TDF_Label +#define TheItem_hxx +#define Hasher TCollection_ExtendedString +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDSImpl_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_hxx "SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx" +#define TCollection_DataMapIterator SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel +#define TCollection_DataMapIterator_hxx "SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_Type_() SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_Type_() +#define TCollection_DataMap SALOMEDSImpl_DataMapStringLabel +#define TCollection_DataMap_hxx "SALOMEDSImpl_DataMapStringLabel.hxx" + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_DataMapNode +#undef TCollection_DataMapNode_hxx +#undef TCollection_DataMapIterator +#undef TCollection_DataMapIterator_hxx +#undef Handle_TCollection_DataMapNode +#undef TCollection_DataMapNode_Type_ +#undef TCollection_DataMap +#undef TCollection_DataMap_hxx + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_0.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_0.cxx new file mode 100644 index 000000000..102d17f15 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_0.cxx @@ -0,0 +1,112 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_0.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _SALOMEDSImpl_DataMapStringLabel_HeaderFile +#include "SALOMEDSImpl_DataMapStringLabel.hxx" +#endif +#ifndef _SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel_HeaderFile +#include "SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx" +#endif +SALOMEDSImpl_DataMapNodeOfDataMapStringLabel::~SALOMEDSImpl_DataMapNodeOfDataMapStringLabel() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDSImpl_DataMapNodeOfDataMapStringLabel", + sizeof(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel) Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel))) { + _anOtherObject = Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel)((Handle(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDSImpl_DataMapNodeOfDataMapStringLabel::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel) ; +} +Standard_Boolean SALOMEDSImpl_DataMapNodeOfDataMapStringLabel::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDSImpl_DataMapNodeOfDataMapStringLabel) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel::~Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel() {} +#define TheKey TCollection_ExtendedString +#define TheKey_hxx +#define TheItem TDF_Label +#define TheItem_hxx +#define Hasher TCollection_ExtendedString +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDSImpl_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_hxx "SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx" +#define TCollection_DataMapIterator SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel +#define TCollection_DataMapIterator_hxx "SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_Type_() SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_Type_() +#define TCollection_DataMap SALOMEDSImpl_DataMapStringLabel +#define TCollection_DataMap_hxx "SALOMEDSImpl_DataMapStringLabel.hxx" +#include + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapOfIntegerString.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapOfIntegerString.hxx new file mode 100644 index 000000000..f8cd820f3 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapOfIntegerString.hxx @@ -0,0 +1,127 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SALOMEDSImpl_DataMapOfIntegerString.hxx +// Author : Sergey Ruin +// Module : SALOME + +#ifndef _SALOMEDSImpl_DataMapOfIntegerString_HeaderFile +#define _SALOMEDSImpl_DataMapOfIntegerString_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_NoSuchObject; +class TCollection_ExtendedString; +class TColStd_MapIntegerHasher; +class SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString; +class SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOMEDSImpl_DataMapOfIntegerString : public TCollection_BasicMap { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT SALOMEDSImpl_DataMapOfIntegerString(const Standard_Integer NbBuckets = 1); +Standard_EXPORT SALOMEDSImpl_DataMapOfIntegerString& Assign(const SALOMEDSImpl_DataMapOfIntegerString& Other) ; + SALOMEDSImpl_DataMapOfIntegerString& operator =(const SALOMEDSImpl_DataMapOfIntegerString& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~SALOMEDSImpl_DataMapOfIntegerString() +{ + Clear(); +} + +Standard_EXPORT Standard_Boolean Bind(const Standard_Real& K,const TCollection_ExtendedString& I) ; +Standard_EXPORT Standard_Boolean IsBound(const Standard_Real& K) const; +Standard_EXPORT Standard_Boolean UnBind(const Standard_Real& K) ; +Standard_EXPORT const TCollection_ExtendedString& Find(const Standard_Real& K) const; + const TCollection_ExtendedString& operator()(const Standard_Real& K) const +{ + return Find(K); +} + +Standard_EXPORT TCollection_ExtendedString& ChangeFind(const Standard_Real& K) ; + TCollection_ExtendedString& operator()(const Standard_Real& K) +{ + return ChangeFind(K); +} + + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT SALOMEDSImpl_DataMapOfIntegerString(const SALOMEDSImpl_DataMapOfIntegerString& Other); + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapOfIntegerString_0.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapOfIntegerString_0.cxx new file mode 100644 index 000000000..38fea18b1 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapOfIntegerString_0.cxx @@ -0,0 +1,48 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SALOMEDSImpl_DataMapOfIntegerString_0.cxx +// Author : Sergey Ruin +// Module : SALOME + +#include + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#include +#endif +#ifndef _SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString_HeaderFile +#include +#endif + + +#define TheKey Standard_Real +#define TheKey_hxx +#define TheItem TCollection_ExtendedString +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator SALOMEDSImpl_DataMapIteratorOfDataMapOfIntegerString +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_Type_() SALOMEDSImpl_DataMapNodeOfDataMapOfIntegerString_Type_() +#define TCollection_DataMap SALOMEDSImpl_DataMapOfIntegerString +#define TCollection_DataMap_hxx +#include + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapStringLabel.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapStringLabel.hxx new file mode 100644 index 000000000..6c84e3786 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapStringLabel.hxx @@ -0,0 +1,145 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOMEDSImpl_DataMapStringLabel.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_DataMapStringLabel_HeaderFile +#define _SALOMEDSImpl_DataMapStringLabel_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_NoSuchObject; +class TCollection_ExtendedString; +class TDF_Label; +class SALOMEDSImpl_DataMapNodeOfDataMapStringLabel; +class SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOMEDSImpl_DataMapStringLabel : public TCollection_BasicMap { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SALOMEDSImpl_DataMapStringLabel(const Standard_Integer NbBuckets = 1); +Standard_EXPORT SALOMEDSImpl_DataMapStringLabel& Assign(const SALOMEDSImpl_DataMapStringLabel& Other) ; + SALOMEDSImpl_DataMapStringLabel& operator =(const SALOMEDSImpl_DataMapStringLabel& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~SALOMEDSImpl_DataMapStringLabel() +{ + Clear(); +} + +Standard_EXPORT Standard_Boolean Bind(const TCollection_ExtendedString& K,const TDF_Label& I) ; +Standard_EXPORT Standard_Boolean IsBound(const TCollection_ExtendedString& K) const; +Standard_EXPORT Standard_Boolean UnBind(const TCollection_ExtendedString& K) ; +Standard_EXPORT const TDF_Label& Find(const TCollection_ExtendedString& K) const; + const TDF_Label& operator()(const TCollection_ExtendedString& K) const +{ + return Find(K); +} + +Standard_EXPORT TDF_Label& ChangeFind(const TCollection_ExtendedString& K) ; + TDF_Label& operator()(const TCollection_ExtendedString& K) +{ + return ChangeFind(K); +} + + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT SALOMEDSImpl_DataMapStringLabel(const SALOMEDSImpl_DataMapStringLabel& Other); + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_DataMapStringLabel_0.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapStringLabel_0.cxx new file mode 100644 index 000000000..714d0aeec --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_DataMapStringLabel_0.cxx @@ -0,0 +1,67 @@ +// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOMEDSImpl_DataMapStringLabel_0.cxx +// Author : Sergey RUIN +// Module : SALOME + + +using namespace std; +#include "SALOMEDSImpl_DataMapStringLabel.hxx" + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_HeaderFile +#include "SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx" +#endif +#ifndef _SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel_HeaderFile +#include "SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx" +#endif + + +#define TheKey TCollection_ExtendedString +#define TheKey_hxx +#define TheItem TDF_Label +#define TheItem_hxx +#define Hasher TCollection_ExtendedString +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDSImpl_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_hxx "SALOMEDSImpl_DataMapNodeOfDataMapStringLabel.hxx" +#define TCollection_DataMapIterator SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel +#define TCollection_DataMapIterator_hxx "SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOMEDSImpl_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_Type_() SALOMEDSImpl_DataMapNodeOfDataMapStringLabel_Type_() +#define TCollection_DataMap SALOMEDSImpl_DataMapStringLabel +#define TCollection_DataMap_hxx "SALOMEDSImpl_DataMapStringLabel.hxx" +#include + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx new file mode 100644 index 000000000..000b0acf5 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx @@ -0,0 +1,80 @@ +#ifndef __SALOMEDSIMPL_DRIVER_H__ +#define __SALOMEDSIMPL_DRIVER_H__ + +#include +#include +#include + + +class SALOMEDSImpl_Driver +{ +public: + + virtual TCollection_AsciiString GetIOR() = 0; + + virtual unsigned char* Save(const Handle(SALOMEDSImpl_SComponent)& theComponent, + const TCollection_AsciiString& theURL, + long& theStreamLength, + bool isMultiFile) = 0; + + virtual unsigned char* SaveASCII(const Handle(SALOMEDSImpl_SComponent)& theComponent, + const TCollection_AsciiString& theURL, + long& theStreamLength, + bool isMultiFile) = 0; + + virtual bool Load(const Handle(SALOMEDSImpl_SComponent)& theComponent, + const unsigned char* theStream, + const long theStreamLength, + const TCollection_AsciiString& theURL, + bool isMultiFile) = 0; + + virtual bool LoadASCII(const Handle(SALOMEDSImpl_SComponent)& theComponent, + const unsigned char* theStream, + const long theStreamLength, + const TCollection_AsciiString& theURL, + bool isMultiFile) = 0; + + virtual void Close(const Handle(SALOMEDSImpl_SComponent)& theComponent) = 0; + + virtual TCollection_AsciiString ComponentDataType() = 0; + + + virtual TCollection_AsciiString IORToLocalPersistentID(const Handle(SALOMEDSImpl_SObject)& theSObject, + const TCollection_AsciiString& IORString, + bool isMultiFile, + bool isASCII) = 0; + + virtual TCollection_AsciiString LocalPersistentIDToIOR(const Handle(SALOMEDSImpl_SObject)& theSObject, + const TCollection_AsciiString& aLocalPersistentID, + bool isMultiFile, + bool isASCII) = 0; + + virtual bool CanCopy(const Handle(SALOMEDSImpl_SObject)& theObject) = 0; + + virtual unsigned char* CopyFrom(const Handle(SALOMEDSImpl_SObject)& theObject, + int& theObjectID, + long& theStreamLength) = 0; + + virtual bool CanPaste(const TCollection_AsciiString& theComponentName, int theObjectID) = 0; + + virtual TCollection_AsciiString PasteInto(const unsigned char* theStream, + const long theStreamLength, + int theObjectID, + const Handle(SALOMEDSImpl_SObject)& theObject) = 0; + + virtual unsigned char* DumpPython(const Handle(SALOMEDSImpl_Study)& theStudy, + bool isPublished, + bool& isValidScript, + long& theStreamLength) = 0; +}; + +class SALOMEDSImpl_DriverFactory +{ +public: + + virtual SALOMEDSImpl_Driver* GetDriverByType(const TCollection_AsciiString& theComponentType) = 0; + + virtual SALOMEDSImpl_Driver* GetDriverByIOR(const TCollection_AsciiString& theIOR) = 0; +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx new file mode 100644 index 000000000..881b9fe24 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx @@ -0,0 +1,43 @@ +// File : SALOMEDSImpl_GenericAttribute.hxx +// Author : SERGEY_RUIN +// Module : SALOME + +using namespace std; + +#include "SALOMEDSImpl_Attributes.hxx" +#include "SALOMEDSImpl_Study.hxx" +#include "SALOMEDSImpl_StudyBuilder.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_GenericAttribute, TDF_Attribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_GenericAttribute, TDF_Attribute ) + +char* SALOMEDSImpl_GenericAttribute::Impl_GetType(const Handle(TDF_Attribute)& theAttr) +{ + Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr); + return ga->Type().ToCString(); +} + +void SALOMEDSImpl_GenericAttribute::Impl_CheckLocked(const Handle(TDF_Attribute)& theAttr) +{ + Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr); + ga->CheckLocked(); +} + +TCollection_AsciiString SALOMEDSImpl_GenericAttribute::Type() +{ + return _type; +} + + +void SALOMEDSImpl_GenericAttribute::CheckLocked() +{ + TDF_Label aLabel = Label(); + if(aLabel.IsNull()) return; + + Handle(SALOMEDSImpl_Study) aStudy = SALOMEDSImpl_Study::GetStudy(aLabel); + if(aStudy.IsNull() || aStudy->NewBuilder()->HasOpenCommand()) return; + if(aStudy->IsLocked()) { + aStudy->_errorCode = "LockProtection"; + throw LockProtection("LockProtection"); + } +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.hxx new file mode 100644 index 000000000..f2df39229 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.hxx @@ -0,0 +1,47 @@ +// File : SALOMEDSImpl_GenericAttribute.hxx +// Author : SERGEY_RUIN +// Module : SALOME + +#ifndef _GENERICIMPL_ATTRIBUTE_HXX_ +#define _GENERICIMPL_ATTRIBUTE_HXX_ + +#include +#include +#include +#include +#include + +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_GenericAttribute, TDF_Attribute ) + +class SALOMEDSImpl_GenericAttribute: public TDF_Attribute +{ +protected: + + TCollection_AsciiString _type; //This field must be filled in each attribute that inherits from this class. + +public: + +Standard_EXPORT SALOMEDSImpl_GenericAttribute(const TCollection_AsciiString& theType) +:_type(theType) +{} + +Standard_EXPORT virtual TCollection_AsciiString Save() { return ""; } +Standard_EXPORT virtual void Load(const TCollection_AsciiString&) {} +Standard_EXPORT virtual TCollection_AsciiString Type(); +Standard_EXPORT virtual void CheckLocked(); +Standard_EXPORT TCollection_AsciiString GetClassType() { return _type; } + +Standard_EXPORT static char* Impl_GetType(const Handle(TDF_Attribute)& theAttr); +Standard_EXPORT static void Impl_CheckLocked(const Handle(TDF_Attribute)& theAttr); + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_GenericAttribute ) + +}; + + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_OCAFApplication.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_OCAFApplication.cxx new file mode 100644 index 000000000..9d5addbf7 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_OCAFApplication.cxx @@ -0,0 +1,45 @@ +// File : SALOMEDSImpl_OCAFApplication.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_OCAFApplication.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_OCAFApplication, TDocStd_Application ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_OCAFApplication, TDocStd_Application ) + +//======================================================================= +//function : SALOMEDSImpl_OCAFApplication +//purpose : +//======================================================================= + +SALOMEDSImpl_OCAFApplication::SALOMEDSImpl_OCAFApplication() +{ +} + + +//======================================================================= +//function : Formats +//purpose : +//======================================================================= + +void SALOMEDSImpl_OCAFApplication::Formats(TColStd_SequenceOfExtendedString& Formats) +{ + Formats.Append(TCollection_ExtendedString ("SALOME_STUDY")); +} + + +//======================================================================= +//function : ResourcesName +//purpose : +//======================================================================= + +Standard_CString SALOMEDSImpl_OCAFApplication::ResourcesName() +{ + return Standard_CString ("SALOMEDSImpl_Resources"); +} + + + + + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_OCAFApplication.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_OCAFApplication.hxx new file mode 100644 index 000000000..e34a1fa09 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_OCAFApplication.hxx @@ -0,0 +1,32 @@ +// File : SALOMEDSImpl_OCAFApplication.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef _SALOMEDSImpl_OCAFApplication_HeaderFile +#define _SALOMEDSImpl_OCAFApplication_HeaderFile + + +//Handle definition +#include +#include +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_OCAFApplication, TDocStd_Application) + +#include +#include + + +class SALOMEDSImpl_OCAFApplication : public TDocStd_Application { + +public: + +Standard_EXPORT SALOMEDSImpl_OCAFApplication(); +Standard_EXPORT virtual void Formats(TColStd_SequenceOfExtendedString& Formats) ; +Standard_EXPORT Standard_CString ResourcesName() ; +Standard_EXPORT ~SALOMEDSImpl_OCAFApplication() {} + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_OCAFApplication ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.cxx new file mode 100644 index 000000000..748033293 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.cxx @@ -0,0 +1,77 @@ +// File : SALOMEDSImpl_SComponent.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_SComponent.hxx" +#include "SALOMEDSImpl_AttributeComment.hxx" +#include "SALOMEDSImpl_AttributeIOR.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_SComponent, SALOMEDSImpl_SObject ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_SComponent, SALOMEDSImpl_SObject ) + +//============================================================================ +/*! Function : constructor + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_SComponent::SALOMEDSImpl_SComponent(const TDF_Label& theLabel) + :SALOMEDSImpl_SObject(theLabel) +{ +} + +//============================================================================ +/*! Function : destructor + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_SComponent::~SALOMEDSImpl_SComponent() +{ +} + + +//============================================================================ +/*! Function : ComponentDataType + * Purpose : + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_SComponent::ComponentDataType() +{ + TCollection_AsciiString res = ""; + Handle(SALOMEDSImpl_AttributeComment) type; + if ( _lab.FindAttribute(SALOMEDSImpl_AttributeComment::GetID(),type) ) { + res = type->Get(); + } + + return res; +} + + +//============================================================================ +/*! Function : ComponentIOR + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_SComponent::ComponentIOR(TCollection_AsciiString& IOR) +{ + Handle(SALOMEDSImpl_AttributeIOR) ior; + if (!_lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(),ior) ) + return false; + IOR = ior->Value(); + return true; +} + + +//============================================================================ +/*! Function : IsA + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_SComponent::IsA(const TDF_Label& theLabel) +{ + // scomponent must contain comment and belong to the 2th depth label + if ( theLabel.IsAttribute(SALOMEDSImpl_AttributeComment::GetID()) && theLabel.Depth() == 2) { + return true; + } + return false; +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.hxx new file mode 100644 index 000000000..bc3c32923 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.hxx @@ -0,0 +1,41 @@ +// File : SALOMEDSImpl_SComponent.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef __SALOMEDSIMPL_SCOMPONENT_H__ +#define __SALOMEDSIMPL_SCOMPONENT_H__ + +//SALOMEDSImpl headers +#include "SALOMEDSImpl_SObject.hxx" + +//Handle definition +#include +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_SComponent, SALOMEDSImpl_SObject ) + +// std C++ headers +#include + +// Cascade headers +#include +#include +#include +#include +#include + +class SALOMEDSImpl_SComponent : public SALOMEDSImpl_SObject +{ +public: + + SALOMEDSImpl_SComponent(const TDF_Label& lab); + + ~SALOMEDSImpl_SComponent(); + + virtual TCollection_AsciiString ComponentDataType(); + virtual bool ComponentIOR(TCollection_AsciiString& theID); + static bool IsA(const TDF_Label& theLabel); + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_SComponent ) + +}; +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.cxx new file mode 100644 index 000000000..792b0f939 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.cxx @@ -0,0 +1,66 @@ +// File : SALOMEDSImpl_SComponentIterator.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_SComponentIterator.hxx" + + +//============================================================================ +/*! Function : constructor + * + */ +//============================================================================ + +SALOMEDSImpl_SComponentIterator::SALOMEDSImpl_SComponentIterator(const Handle(TDocStd_Document)& theDocument) +{ + _lab = theDocument->Main(); + _it.Initialize (_lab); +} + +//============================================================================ +/*! Function : Init + * + */ +//============================================================================ +void SALOMEDSImpl_SComponentIterator::Init() +{ + _it.Initialize (_lab); +} + +//============================================================================ +/*! Function : More + * + */ +//============================================================================ +bool SALOMEDSImpl_SComponentIterator::More() +{ + if (!_it.More()) + return false; + TDF_Label L = _it.Value(); + if (SALOMEDSImpl_SComponent::IsA(L)) + return true; + + return _it.More(); +} + + //============================================================================ +/*! Function : Next + */ +//============================================================================ +void SALOMEDSImpl_SComponentIterator::Next() +{ + _it.Next(); +} + + +//============================================================================ +/*! Function : Value + * + */ +//============================================================================ +Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_SComponentIterator::Value() +{ + return new SALOMEDSImpl_SComponent (_it.Value()); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.hxx new file mode 100644 index 000000000..20b9e237c --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.hxx @@ -0,0 +1,36 @@ +// File : SALOMEDSImpl_SComponentIterator_i.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef __SALOMEDSIMPL_SCOMPONENTITERATOR_H__ +#define __SALOMEDSIMPL_SCOMPONENTITERATOR_H__ + + +//SALOMEDSImpl headers +#include "SALOMEDSImpl_SComponent.hxx" + +// Cascade headers +#include +#include +#include +#include + +class SALOMEDSImpl_SComponentIterator +{ +private: + + TDF_ChildIterator _it; + TDF_Label _lab; + +public: + + SALOMEDSImpl_SComponentIterator(const Handle(TDocStd_Document)& theDocument); + + ~SALOMEDSImpl_SComponentIterator() {}; + + virtual void Init(); + virtual bool More(); + virtual void Next(); + virtual Handle(SALOMEDSImpl_SComponent) Value(); +}; +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx new file mode 100644 index 000000000..107d5f69b --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx @@ -0,0 +1,211 @@ +// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server +// File : SALOMEDSImpl_SObject.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; + +#include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_Attributes.hxx" +#include "SALOMEDSImpl_SComponent.hxx" +#include "SALOMEDSImpl_Study.hxx" + +#include +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_SObject, MMgt_TShared ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_SObject, MMgt_TShared ) + +//============================================================================ +/*! Function : constructor + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_SObject::SALOMEDSImpl_SObject(const TDF_Label& theLabel) + :_lab(theLabel) +{ + _value = ""; + _type = ""; + _name = ""; +} + +//============================================================================ +/*! Function : GetID + * Purpose : + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_SObject::GetID() +{ + TCollection_AsciiString anEntry; + TDF_Tool::Entry (_lab,anEntry); + return anEntry; +} + +//============================================================================ +/*! Function : GetFatherComponent + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_SObject::GetFatherComponent() +{ + TDF_Label LF = _lab; + while (!SALOMEDSImpl_SComponent::IsA(LF) && !LF.IsRoot()) { + LF = LF.Father(); + } + + if(LF.IsRoot()) return NULL; + + return new SALOMEDSImpl_SComponent(LF); +} + +//============================================================================ +/*! Function : GetFather + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_SObject::GetFather() +{ + return new SALOMEDSImpl_SObject(_lab.Father()); +} + + +//============================================================================ +/*! Function : GetStudy + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_Study) SALOMEDSImpl_SObject::GetStudy() +{ + return SALOMEDSImpl_Study::GetStudy(_lab); +} + +//============================================================================ +/*! Function : FindAttribute + * Purpose : Find attribute of given type on this SObject + */ +//============================================================================ +bool SALOMEDSImpl_SObject::FindAttribute(Handle(TDF_Attribute)& theAttribute, + const TCollection_AsciiString& theTypeOfAttribute) +{ + if(_lab.IsNull()) return Standard_False; + Standard_GUID aGUID = GetGUID(theTypeOfAttribute); + if (_lab.FindAttribute(aGUID, theAttribute)) return Standard_True; + return Standard_False; +} + + + +//============================================================================ +/*! Function : GetAllAttributes + * Purpose : Returns list of all attributes for this sobject + */ +//============================================================================ +Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_SObject::GetAllAttributes() +{ + Standard_Integer NumAttr = _lab.NbAttributes(); + Handle(TColStd_HSequenceOfTransient) SeqOfAttr = new TColStd_HSequenceOfTransient(); + Handle(SALOMEDSImpl_GenericAttribute) anAttr; + if (NumAttr != 0) { + for(TDF_AttributeIterator iter(_lab);iter.More();iter.Next()) { + anAttr = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(iter.Value()); + if(!anAttr.IsNull()) + SeqOfAttr->Append(anAttr); + } + } + return SeqOfAttr; +} + + +//============================================================================ +/*! Function : ReferencedObject + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_SObject::ReferencedObject(Handle(SALOMEDSImpl_SObject)& theObject) +{ + Handle(SALOMEDSImpl_AttributeReference) Ref; + if (!_lab.FindAttribute(SALOMEDSImpl_AttributeReference::GetID(),Ref)) + return false; + + theObject = new SALOMEDSImpl_SObject(Ref->Get()); + return true; +} + +//============================================================================ +/*! Function : FindSubObject + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_SObject::FindSubObject(int theTag, Handle(SALOMEDSImpl_SObject)& theObject) +{ + TDF_Label L = _lab.FindChild(theTag, false); + if (L.IsNull()) return false; + + theObject = new SALOMEDSImpl_SObject(L); + return true; + +} + + +//============================================================================ +/*! Function : GetName + * Purpose : + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_SObject::GetName() +{ + TCollection_AsciiString aStr = ""; + Handle(SALOMEDSImpl_AttributeName) aName; + if (_lab.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aName)) { + aStr = aName->Get(); + } + return aStr; +} + +//============================================================================ +/*! Function : GetComment + * Purpose : + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_SObject::GetComment() +{ + TCollection_AsciiString aStr = ""; + Handle(SALOMEDSImpl_AttributeComment) aComment; + if (_lab.FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aComment)) { + aStr = aComment->Get(); + } + return aStr; +} + +//============================================================================ +/*! Function : GetIOR + * Purpose : + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_SObject::GetIOR() +{ + TCollection_AsciiString aStr = ""; + Handle(SALOMEDSImpl_AttributeIOR) anIOR; + if (_lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), anIOR)) { + aStr = anIOR->Value(); + } + return aStr; +} + + +Standard_GUID SALOMEDSImpl_SObject::GetGUID(const TCollection_AsciiString& theType) +{ + __AttributeTypeToGUIDForSObject + + if (strncmp(theType.ToCString(), "AttributeTreeNodeGUID",21) == 0) { + const char* aCType = theType.ToCString(); + char* aGUIDString = new char[40]; + sprintf(aGUIDString, &(aCType[21])); + Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name + delete(aGUIDString); + return aGUID; + } + return Standard_GUID(); +} + + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx new file mode 100644 index 000000000..c6e0bc55a --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx @@ -0,0 +1,66 @@ +// File : SALOMEDSImpl_SObject.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef __SALOMEDSIMPL_SOBJECT_H__ +#define __SALOMEDSIMPL_SOBJECT_H__ + +//Handle definition +#include +#include +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_SObject, MMgt_TShared ) + +class SALOMEDSImpl_SComponent; +class Handle_SALOMEDSImpl_SComponent; +class SALOMEDSImpl_Study; +class Handle_SALOMEDSImpl_Study; + +// Cascade headers +#include +#include +#include +#include +#include +#include +#include + +class SALOMEDSImpl_SObject : public MMgt_TShared +{ +protected: + TDF_Label _lab; + TCollection_AsciiString _name; + TCollection_AsciiString _value; + TCollection_AsciiString _type; + +public: + + SALOMEDSImpl_SObject(const TDF_Label& theLabel); + ~SALOMEDSImpl_SObject() {}; + + virtual TCollection_AsciiString GetID(); + virtual Handle(SALOMEDSImpl_SComponent) GetFatherComponent(); + virtual Handle(SALOMEDSImpl_SObject) GetFather() ; + virtual bool FindAttribute(Handle(TDF_Attribute)& theAttribute, const TCollection_AsciiString& theTypeOfAttribute); + virtual bool ReferencedObject(Handle(SALOMEDSImpl_SObject)& theObject) ; + virtual bool FindSubObject(int theTag, Handle(SALOMEDSImpl_SObject)& theObject); + + virtual Handle(SALOMEDSImpl_Study) GetStudy() ; + virtual TCollection_AsciiString Name() { return _name; } + virtual void Name(TCollection_AsciiString& theName) { _name = theName; } + virtual Handle(TColStd_HSequenceOfTransient) GetAllAttributes(); + + virtual TCollection_AsciiString GetName(); + virtual TCollection_AsciiString GetComment(); + virtual TCollection_AsciiString GetIOR(); + + virtual int Tag() { return _lab.Tag(); } + virtual int Depth() { return _lab.Depth(); } + + virtual TDF_Label GetLabel() { return _lab; } + + static Standard_GUID GetGUID(const TCollection_AsciiString& theTypeOfAttribute); + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_SObject ) +}; +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx new file mode 100644 index 000000000..c1265e25e --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -0,0 +1,1286 @@ +// File : SALOMEDSImpl_Study.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_Study.hxx" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SALOMEDSImpl_DataMapIteratorOfDataMapStringLabel.hxx" +#include "SALOMEDSImpl_ChildNodeIterator.hxx" +#include "SALOMEDSImpl_Attributes.hxx" +#include "SALOMEDSImpl_UseCaseIterator.hxx" +#include "SALOMEDSImpl_AttributeReference.hxx" +#include "SALOMEDSImpl_StudyHandle.hxx" +#include "SALOMEDSImpl_Tool.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_Study, MMgt_TShared ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_Study, MMgt_TShared ) + +#define DIRECTORYID 16661 +#define FILELOCALID 26662 +#define FILEID "FILE: " + +//============================================================================ +/*! Function : SALOMEDSImpl_Study + * Purpose : SALOMEDSImpl_Study constructor + */ +//============================================================================ +SALOMEDSImpl_Study::SALOMEDSImpl_Study(const Handle(TDocStd_Document)& doc, + const TCollection_AsciiString& study_name) +{ + _name = study_name; + _doc = doc; + _Saved = false ; + _URL = ""; + _StudyId = -1; + _autoFill = true; + myNbPostponed.Append(0); + myNbUndos = 0; + _errorCode = ""; + _useCaseBuilder = new SALOMEDSImpl_UseCaseBuilder(_doc); + _builder = new SALOMEDSImpl_StudyBuilder(this); + _cb = new SALOMEDSImpl_Callback(_useCaseBuilder); + //Put on the root label a StudyHandle attribute to store the address of this object + //It will be used to retrieve the study object by TDF_Label that belongs to the study + SALOMEDSImpl_StudyHandle::Set(_doc->Main().Root(), this); +} + + +//============================================================================ +/*! Function : ~SALOMEDSImpl_Study + * Purpose : SALOMEDSImpl_Study destructor + */ +//============================================================================ +SALOMEDSImpl_Study::~SALOMEDSImpl_Study() +{} + +//============================================================================ +/*! Function : GetPersistentReference + * Purpose : Get persistent reference of study (idem URL()) + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_Study::GetPersistentReference() +{ + _errorCode = ""; + return URL(); +} +//============================================================================ +/*! Function : GetTransientReference + * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root) + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_Study::GetTransientReference() +{ + _errorCode = ""; + TCollection_AsciiString IOR = ""; + + Handle(SALOMEDSImpl_AttributeIOR) Att; + TDF_Label _lab = _doc->GetData()->Root(); + if (_lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(),Att)) { + IOR = Att->Value(); + } + else { + _errorCode = "IOR is empty"; + } + + return IOR; +} + +void SALOMEDSImpl_Study::SetTransientReference(const TCollection_AsciiString& theIOR) +{ + _errorCode = ""; + + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = GetProperties(); + int aLocked = aProp->IsLocked(); + if (aLocked) aProp->SetLocked(Standard_False); + + // Assign the value of the IOR in the study->root + SALOMEDSImpl_AttributeIOR::Set(_doc->Main().Root(), theIOR); + + if (aLocked) aProp->SetLocked(Standard_True); +} + +//============================================================================ +/*! Function : IsEmpty + * Purpose : Detect if study is empty + */ +//============================================================================ +bool SALOMEDSImpl_Study::IsEmpty() +{ + _errorCode = ""; + if (_doc.IsNull()) return true; + return _doc->IsEmpty(); +} + +//============================================================================ +/*! Function : FindComponent + * Purpose : Find a Component with ComponentDataType = aComponentName + */ +//============================================================================ +Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::FindComponent (const TCollection_AsciiString& aComponentName) +{ + _errorCode = ""; + bool _find = false; + TCollection_AsciiString name; + SALOMEDSImpl_SComponentIterator itcomp = NewComponentIterator(); + Handle(SALOMEDSImpl_SComponent) compo; + + for (; itcomp.More(); itcomp.Next()) { + Handle(SALOMEDSImpl_SComponent) SC = itcomp.Value(); + name = SC->ComponentDataType(); + if(aComponentName == name) { + _find = true; + return SC; + } + } + + if(!_find) + { + _errorCode = "No component was found"; + return NULL; + } + return compo; +} + +//============================================================================ +/*! Function : FindComponentID + * Purpose : Find a Component from it's ID + */ +//============================================================================ +Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::FindComponentID(const TCollection_AsciiString& aComponentID) +{ + _errorCode = ""; + + // Iterate on each components defined in the study + // Get the component ID and compare with aComponentID + bool _find = false; + TCollection_AsciiString ID; + Handle(SALOMEDSImpl_SComponent) compo; + + SALOMEDSImpl_SComponentIterator itcomp = NewComponentIterator(); + for (; itcomp.More(); itcomp.Next()) { + Handle(SALOMEDSImpl_SComponent) SC = itcomp.Value(); + ID = SC->GetID(); + if(aComponentID == ID) + { + // ComponentID found + _find = true; + compo = SC; + } + } + if(!_find) + { + _errorCode = "No component was found"; + compo = NULL; + } + + return compo; +} + +//============================================================================ +/*! Function : FindObject + * Purpose : Find an Object with SALOMEDSImpl_Name = anObjectName + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObject(const TCollection_AsciiString& anObjectName) +{ + _errorCode = ""; + + // Iterate to all components defined in the study + // After testing the component name, iterate in all objects defined under + // components (function _FindObject) + bool _find = false; + Handle(SALOMEDSImpl_SObject) RefSO = NULL; + + SALOMEDSImpl_SComponentIterator it = NewComponentIterator(); + for (; it.More();it.Next()){ + if(!_find) + { + Handle(SALOMEDSImpl_SComponent) SC = it.Value(); + if (SC->GetName() == anObjectName) + { + _find = true; + RefSO = SC; + + } + if (!_find) RefSO = _FindObject(SC, anObjectName, _find); + } + } + if(RefSO.IsNull()) _errorCode = "No object was found"; + return RefSO; +} + +//============================================================================ +/*! Function : FindObjectID + * Purpose : Find an Object with ID = anObjectID + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectID(const TCollection_AsciiString& anObjectID) +{ + _errorCode = ""; + + // Convert aSO->GetID in TDF_Label. + TDF_Label Lab; + TDF_Tool::Label(_doc->Main().Data(), anObjectID, Lab); + + if (Lab.IsNull()) { + _errorCode = "No label was found by ID"; + return NULL; + } + return new SALOMEDSImpl_SObject(Lab); + +} + +//============================================================================ +/*! Function : CreateObjectID + * Purpose : Creates an Object with ID = anObjectID + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::CreateObjectID(const TCollection_AsciiString& anObjectID) +{ + _errorCode = ""; + + // Convert aSO->GetID in TDF_Label. + TDF_Label Lab; + TDF_Tool::Label(_doc->Main().Data(), anObjectID, Lab, Standard_True); + + if (Lab.IsNull()) { + _errorCode = "Can not create a label"; + return NULL; + } + return new SALOMEDSImpl_SObject(Lab); + +} + +//============================================================================ +/*! Function : FindObjectByName + * Purpose : Find Objects with SALOMEDSImpl_Name = anObjectName in a Component + * : with ComponentDataType = aComponentName + */ +//============================================================================ +Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_Study::FindObjectByName(const TCollection_AsciiString& anObjectName, + const TCollection_AsciiString& aComponentName) +{ + _errorCode = ""; + + Handle(TColStd_HSequenceOfTransient) listSO = new TColStd_HSequenceOfTransient(); + + Handle(SALOMEDSImpl_SComponent) compo = FindComponent(aComponentName) ; + if ( compo.IsNull() ) { + _errorCode = "Can not find the component"; + return listSO; + } + + // Iterate on each object and subobject of the component + // If objectName is found add it to the list of SObjects + TCollection_AsciiString childName ; + + TCollection_AsciiString compoId = compo->GetID(); + TDF_ChildIterator it = NewChildIterator(compo); + for ( ; it.More();it.Next() ) { + + Handle(SALOMEDSImpl_SObject) CSO = new SALOMEDSImpl_SObject(it.Value()); + if ( CSO->GetName() == anObjectName ) { + /* add to list */ + listSO->Append(CSO) ; + } + + /* looks also for eventual children */ + bool found = false ; + CSO = _FindObject( CSO, anObjectName, found ) ; + if( found) { + listSO->Append(CSO) ; + } + } + + return listSO; +} + + + +//============================================================================ +/*! Function : FindObjectIOR + * Purpose : Find an Object with IOR = anObjectIOR + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectIOR(const TCollection_AsciiString& anObjectIOR) +{ + _errorCode = ""; + + // firstly searching in the datamap for optimization + if (myIORLabels.IsBound(anObjectIOR)) { + Handle(SALOMEDSImpl_SObject) aResult = new SALOMEDSImpl_SObject(myIORLabels.Find(anObjectIOR)); + // 11 oct 2002: forbidden attributes must be checked here + if (!aResult->GetLabel().IsAttribute(SALOMEDSImpl_AttributeIOR::GetID())) { + myIORLabels.UnBind(anObjectIOR); + } else + return aResult; + } + // Iterate to all components defined in the study + // After testing the component name, iterate in all objects defined under + // components (function _FindObject) + bool _find = false; + Handle(SALOMEDSImpl_SObject) RefSO = NULL; + + SALOMEDSImpl_SComponentIterator it = NewComponentIterator(); + Handle(SALOMEDSImpl_SComponent) SC; + for (; it.More();it.Next()){ + if(!_find) + { + SC = it.Value(); + TCollection_AsciiString ior = SC->GetIOR(); + if (ior != "") + { + if (ior == anObjectIOR) + { + _find = true; + RefSO = SC; + } + } + if (!_find) + RefSO = _FindObjectIOR(SC, anObjectIOR, _find); + } + } + + if(RefSO.IsNull()) _errorCode = "No object was found"; + return RefSO; +} + +//============================================================================ +/*! Function : FindObjectByPath + * Purpose : Find an Object by its path = thePath + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectByPath(const TCollection_AsciiString& thePath) +{ + _errorCode = ""; + + TCollection_AsciiString aPath(thePath), aToken; + Handle(SALOMEDSImpl_SObject) aSO = NULL; + int i = 1, aLength = aPath.Length(); + bool isRelative = false; + + if(aLength == 0) { //Empty path - return the current context + return new SALOMEDSImpl_SObject (_current); + } + + if(aPath.Value(1) != '/') //Relative path + isRelative = true; + + TDF_ChildIterator anIterator; + TDF_Label aLabel; + Handle(SALOMEDSImpl_AttributeName) anAttr; + + if(isRelative) { + if(_current.IsNull()) return NULL; + anIterator.Initialize(_current, Standard_False); + } + else { + if(aPath.Length() == 1 && aPath.Value(1) == '/') { //Root + return new SALOMEDSImpl_SObject (_doc->Main()); + } + anIterator.Initialize(_doc->Main(), Standard_False); + } + + while(i <= aLength) { + + aToken = aPath.Token("/", i); + if(aToken.Length() == 0) break; + + for ( ; anIterator.More(); anIterator.Next() ) { + aLabel = anIterator.Value(); + if(aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), anAttr)) { + if(anAttr->Get() == aToken) { + aToken = aPath.Token("/", i+1); //Check if it was the last part of the path + if(aToken.Length() == 0) { //The searched label is found (no part of the path is left) + return new SALOMEDSImpl_SObject (aLabel); + } + + anIterator.Initialize(aLabel, Standard_False); + break; + } + } + } + + i++; + } + + if(aSO.IsNull()) _errorCode = "No object was found"; + return aSO; +} + +//============================================================================ +/*! Function : GetObjectPath + * Purpose : + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_Study::GetObjectPath(const Handle(SALOMEDSImpl_SObject)& theObject) +{ + _errorCode = ""; + + TCollection_AsciiString aPath(""); + if(theObject.IsNull()) { + _errorCode = "Null object"; + return aPath.ToCString(); + } + + TCollection_AsciiString aName = theObject->GetName(); + if(!aName.IsEmpty() && aName != "" ) { + TCollection_AsciiString aValue((char*)aName.ToCString()); + aValue.Prepend("/"); + aValue += aPath; + aPath = aValue; + Handle(SALOMEDSImpl_SObject) aFather = theObject->GetFather(); + if(!aFather.IsNull()) { + aName = aFather->GetName(); + if(!aName.IsEmpty() && aName != "") { + aValue = (char*)GetObjectPath(aFather).ToCString(); + aPath = aValue + aPath; + } + } + } + + return aPath; +} + + +//============================================================================ +/*! Function : GetObjectPathByIOR + * Purpose : + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_Study::GetObjectPathByIOR(const TCollection_AsciiString& theIOR) +{ + _errorCode = ""; + + TCollection_AsciiString aPath; + Handle(SALOMEDSImpl_SObject) so = FindObjectIOR(theIOR); + if(so.IsNull()) { + _errorCode = "No SObject was found by IOR"; + return aPath; + } + + return GetObjectPath(so); +} + + +//============================================================================ +/*! Function : SetContext + * Purpose : Sets the current context + */ +//============================================================================ +bool SALOMEDSImpl_Study::SetContext(const TCollection_AsciiString& thePath) +{ + _errorCode = ""; + if(thePath.IsEmpty()) { + _errorCode = "InvalidPath"; + return false; + } + + TCollection_AsciiString aPath(thePath), aContext(""); + bool isInvalid = false; + Handle(SALOMEDSImpl_SObject) aSO; + + if(aPath.Value(1) != '/') { //Relative path + aContext = GetContext(); + aContext += '/'; + aContext += aPath; + } + else + aContext = aPath; + + try { + aSO = FindObjectByPath(aContext.ToCString()); + } + catch( ... ) { + isInvalid = true; + } + + if(isInvalid || aSO.IsNull()) { + _errorCode = "InvalidContext"; + return false; + } + + TDF_Label aLabel = aSO->GetLabel(); + if(aLabel.IsNull()) { + _errorCode = "InvalidContext"; + return false; + } + else + _current = aLabel; //Set the current context + + return true; +} + +//============================================================================ +/*! Function : GetContext + * Purpose : Gets the current context + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_Study::GetContext() +{ + _errorCode = ""; + + if(_current.IsNull()) { + _errorCode = "InvaidContext"; + return ""; + } + Handle(SALOMEDSImpl_SObject) so = new SALOMEDSImpl_SObject (_current); + return GetObjectPath(so); +} + +//============================================================================ +/*! Function : GetObjectNames + * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty) + */ +//============================================================================ +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetObjectNames(const TCollection_AsciiString& theContext) +{ + _errorCode = ""; + + Handle(TColStd_HSequenceOfAsciiString) aResultSeq = new TColStd_HSequenceOfAsciiString; + TDF_Label aLabel; + if (theContext.IsEmpty()) { + if(_current.IsNull()) { + _errorCode = "InvalidContext"; + return aResultSeq; + } + aLabel = _current; + } else { + TDF_Label aTmp = _current; + SetContext(theContext); + aLabel = _current; + _current = aTmp; + } + TDF_ChildIterator anIter(aLabel, Standard_False); // iterate all subchildren at all sublevels + for(; anIter.More(); anIter.Next()) { + TDF_Label aLabel = anIter.Value(); + Handle(SALOMEDSImpl_AttributeName) aName; + if (aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aName)) aResultSeq->Append(aName->Get()); + } + + return aResultSeq; +} + +//============================================================================ +/*! Function : GetDirectoryNames + * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty) + */ +//============================================================================ +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetDirectoryNames(const TCollection_AsciiString& theContext) +{ + _errorCode = ""; + + Handle(TColStd_HSequenceOfAsciiString) aResultSeq = new TColStd_HSequenceOfAsciiString; + TDF_Label aLabel; + if (theContext.IsEmpty()) { + if(_current.IsNull()) { + _errorCode = "InvalidContext"; + return aResultSeq; + } + aLabel = _current; + } else { + TDF_Label aTmp = _current; + SetContext(theContext); + aLabel = _current; + _current = aTmp; + } + TDF_ChildIterator anIter(aLabel, Standard_False); // iterate first-level children at all sublevels + for(; anIter.More(); anIter.Next()) { + TDF_Label aLabel = anIter.Value(); + Handle(SALOMEDSImpl_AttributeLocalID) anID; + if (aLabel.FindAttribute(SALOMEDSImpl_AttributeLocalID::GetID(), anID)) { + if (anID->Value() == DIRECTORYID) { + Handle(SALOMEDSImpl_AttributeName) aName; + if (aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aName)) { + aResultSeq->Append(aName->Get()); + } + } + } + } + + return aResultSeq; +} + +//============================================================================ +/*! Function : GetFileNames + * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty) + */ +//============================================================================ +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetFileNames(const TCollection_AsciiString& theContext) +{ + _errorCode = ""; + + Handle(TColStd_HSequenceOfAsciiString) aResultSeq = new TColStd_HSequenceOfAsciiString; + TDF_Label aLabel; + if (theContext.IsEmpty()) { + if(_current.IsNull()) { + _errorCode = "InvalidContext"; + return aResultSeq; + } + aLabel = _current; + } else { + TDF_Label aTmp = _current; + SetContext(theContext); + aLabel = _current; + _current = aTmp; + } + TDF_ChildIterator anIter(aLabel, Standard_False); // iterate all subchildren at all sublevels + for(; anIter.More(); anIter.Next()) { + TDF_Label aLabel = anIter.Value(); + Handle(SALOMEDSImpl_AttributeLocalID) anID; + if (aLabel.FindAttribute(SALOMEDSImpl_AttributeLocalID::GetID(), anID)) { + if (anID->Value() == FILELOCALID) { + Handle(SALOMEDSImpl_AttributePersistentRef) aName; + if(aLabel.FindAttribute(SALOMEDSImpl_AttributePersistentRef::GetID(), aName)) { + TCollection_ExtendedString aFileName = aName->Get(); + if(aFileName.Length() > 0) + aResultSeq->Append(aFileName.Split(strlen(FILEID))); + } + } + } + } + + return aResultSeq; +} + +//============================================================================ +/*! Function : GetComponentNames + * Purpose : method to get all components names + */ +//============================================================================ +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetComponentNames(const TCollection_AsciiString& theContext) +{ + _errorCode = ""; + + Handle(TColStd_HSequenceOfAsciiString) aResultSeq = new TColStd_HSequenceOfAsciiString; + TDF_ChildIterator anIter(_doc->Main(), Standard_False); // iterate all subchildren at first level + for(; anIter.More(); anIter.Next()) { + TDF_Label aLabel = anIter.Value(); + Handle(SALOMEDSImpl_AttributeName) aName; + if (aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aName)) aResultSeq->Append(aName->Get()); + } + + return aResultSeq; +} + +//============================================================================ +/*! Function : NewChildIterator + * Purpose : Create a ChildIterator from an SObject + */ +//============================================================================ +TDF_ChildIterator SALOMEDSImpl_Study::NewChildIterator(const Handle(SALOMEDSImpl_SObject)& aSO) +{ + _errorCode = ""; + return TDF_ChildIterator(aSO->GetLabel()); +} + + +//============================================================================ +/*! Function : NewComponentIterator + * Purpose : Create a SComponentIterator + */ +//============================================================================ +SALOMEDSImpl_SComponentIterator SALOMEDSImpl_Study::NewComponentIterator() +{ + _errorCode = ""; + return SALOMEDSImpl_SComponentIterator(_doc); +} + + +//============================================================================ +/*! Function : NewBuilder + * Purpose : Create a StudyBuilder + */ +//============================================================================ +Handle(SALOMEDSImpl_StudyBuilder) SALOMEDSImpl_Study::NewBuilder() +{ + _errorCode = ""; + if(_autoFill) { + _builder->SetOnAddSObject(_cb); + _builder->SetOnRemoveSObject(_cb); + } + return _builder; + +} + +//============================================================================ +/*! Function : Name + * Purpose : get study name + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_Study::Name() +{ + _errorCode = ""; + return _name; +} + +//============================================================================ +/*! Function : Name + * Purpose : set study name + */ +//============================================================================ +void SALOMEDSImpl_Study::Name(const TCollection_AsciiString& name) +{ + _errorCode = ""; + _name = name; +} + +//============================================================================ +/*! Function : IsSaved + * Purpose : get if study has been saved + */ +//============================================================================ +bool SALOMEDSImpl_Study::IsSaved() +{ + _errorCode = ""; + return _Saved; +} + +//============================================================================ +/*! Function : IsSaved + * Purpose : set if study has been saved + */ +//============================================================================ +void SALOMEDSImpl_Study::IsSaved(bool save) +{ + _errorCode = ""; + _Saved = save; +} + +//============================================================================ +/*! Function : IsModified + * Purpose : Detect if a Study has been modified since it has been saved + */ +//============================================================================ +bool SALOMEDSImpl_Study::IsModified() +{ + _errorCode = ""; + + // True if is modified and not saved + if (_doc->IsModified()) + if (!_Saved) return true; + else return false; + else return false; +} + +//============================================================================ +/*! Function : URL + * Purpose : get URL of the study (persistent reference of the study) + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_Study::URL() +{ + _errorCode = ""; + return _URL; +} + +//============================================================================ +/*! Function : URL + * Purpose : set URL of the study (persistent reference of the study) + */ +//============================================================================ +void SALOMEDSImpl_Study::URL(const TCollection_AsciiString& url) +{ + _errorCode = ""; + _URL = url; + + TCollection_AsciiString tmp(_URL); + + char *aName = (char*)tmp.ToCString(); + char *adr = strtok(aName, "/"); + while (adr) + { + aName = adr; + adr = strtok(NULL, "/"); + } + Name(aName); +} + + +//============================================================================ +/*! Function : _FindObject + * Purpose : Find an Object with SALOMEDSImpl_Name = anObjectName + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::_FindObject(const Handle(SALOMEDSImpl_SObject)& SO, + const TCollection_AsciiString& theObjectName, + bool& _find) +{ + if(SO.IsNull()) return NULL; + + // Iterate on each objects and subobjects of the component + // If objectName find, stop the loop and get the object reference + Handle(SALOMEDSImpl_SObject) RefSO; + Handle(SALOMEDSImpl_AttributeName) anAttr; + + TCollection_AsciiString soid = SO->GetID(); + TDF_ChildIterator it(SO->GetLabel()); + for (; it.More(); it.Next()){ + if(!_find) + { + if (it.Value().FindAttribute(SALOMEDSImpl_AttributeName::GetID(), anAttr)) + { + TCollection_AsciiString Val(anAttr->Get()); + if (Val == theObjectName) + { + RefSO = new SALOMEDSImpl_SObject(it.Value()); + _find = true; + } + } + if (!_find) RefSO = _FindObject(new SALOMEDSImpl_SObject(it.Value()), theObjectName, _find); + } + } + return RefSO; +} + +//============================================================================ +/*! Function : _FindObjectIOR + * Purpose : Find an Object with SALOMEDSImpl_IOR = anObjectIOR + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) +SALOMEDSImpl_Study::_FindObjectIOR(const Handle(SALOMEDSImpl_SObject)& SO, + const TCollection_AsciiString& theObjectIOR, + bool& _find) +{ + if(SO.IsNull()) return NULL; + + // Iterate on each objects and subobjects of the component + // If objectName find, stop the loop and get the object reference + Handle(SALOMEDSImpl_SObject) RefSO, aSO; + Handle(SALOMEDSImpl_AttributeIOR) anAttr; + + TDF_ChildIterator it(SO->GetLabel()); + for (; it.More();it.Next()){ + if(!_find) + { + if (it.Value().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), anAttr)) + { + TCollection_AsciiString Val(anAttr->Value()); + if (Val == theObjectIOR) + { + RefSO = new SALOMEDSImpl_SObject(it.Value()); + _find = true; + } + } + aSO = new SALOMEDSImpl_SObject(it.Value()); + if (!_find) RefSO = _FindObjectIOR(aSO, theObjectIOR, _find); + } + } + return RefSO; +} + +bool SALOMEDSImpl_Study::IsLocked() +{ + _errorCode = ""; + return GetProperties()->IsLocked(); +} + +int SALOMEDSImpl_Study::StudyId() +{ + _errorCode = ""; + return _StudyId; +} + +void SALOMEDSImpl_Study::StudyId(int id) +{ + _errorCode = ""; + _StudyId = id; +} + +void SALOMEDSImpl_Study::UpdateIORLabelMap(const TCollection_AsciiString& anIOR,const TCollection_AsciiString& anEntry) +{ + _errorCode = ""; + TDF_Label aLabel; + char* anEn = (char*)anEntry.ToCString(); + char* IOR = (char*)anIOR.ToCString(); + TDF_Tool::Label(_doc->GetData(),anEn, aLabel, Standard_True); + if (myIORLabels.IsBound(TCollection_ExtendedString(IOR))) myIORLabels.UnBind(TCollection_ExtendedString(IOR)); + myIORLabels.Bind(TCollection_ExtendedString(IOR), aLabel); +} + +Handle(SALOMEDSImpl_Study) SALOMEDSImpl_Study::GetStudy(const TDF_Label& theLabel) +{ + Handle(SALOMEDSImpl_StudyHandle) Att; + if (theLabel.Root().FindAttribute(SALOMEDSImpl_StudyHandle::GetID(),Att)) { + return Att->GetHandle(); + } + return NULL; +} + +void SALOMEDSImpl_Study::IORUpdated(const Handle(SALOMEDSImpl_AttributeIOR)& theAttribute) +{ + TCollection_AsciiString aString; + TDF_Tool::Entry(theAttribute->Label(), aString); + GetStudy(theAttribute->Label())->UpdateIORLabelMap(theAttribute->Value(), aString); +} + +Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_Study::FindDependances(const Handle(SALOMEDSImpl_SObject)& anObject) +{ + _errorCode = ""; + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + + Handle(SALOMEDSImpl_AttributeTarget) aTarget; + if (anObject->GetLabel().FindAttribute(SALOMEDSImpl_AttributeTarget::GetID(), aTarget)) { + TDF_LabelList aLabelList; + aTarget->Get(aLabelList); + TDF_ListIteratorOfLabelList anIter(aLabelList); + for(; anIter.More();anIter.Next()) { + aSeq->Append(new SALOMEDSImpl_SObject(anIter.Value())); + } + return aSeq; + } + + return aSeq; +} + + +Handle(SALOMEDSImpl_AttributeStudyProperties) SALOMEDSImpl_Study::GetProperties() +{ + _errorCode = ""; + return SALOMEDSImpl_AttributeStudyProperties::Set(_doc->Main()); +} + +TCollection_AsciiString SALOMEDSImpl_Study::GetLastModificationDate() +{ + _errorCode = ""; + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = GetProperties(); + + Handle(TColStd_HSequenceOfExtendedString) aNames; + Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; + aNames = aProp->GetUserNames(); + aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + + int aLastIndex = aNames->Length(); + char aResult[20]; + sprintf(aResult, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d", (int)(aDays->Value(aLastIndex)),(int)(aMonths->Value(aLastIndex)), + (int)(aYears->Value(aLastIndex)), (int)(aHours->Value(aLastIndex)), (int)(aMinutes->Value(aLastIndex))); + TCollection_AsciiString aResStr(aResult); + return aResStr; +} + +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetModificationsDate() +{ + _errorCode = ""; + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = GetProperties(); + + Handle(TColStd_HSequenceOfExtendedString) aNames; + Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; + aNames = aProp->GetUserNames(); + aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + + int anIndex, aLength = aNames->Length(); + Handle(TColStd_HSequenceOfAsciiString) aDates = new TColStd_HSequenceOfAsciiString; + + for(anIndex = 2; anIndex <= aLength; anIndex++) { + char aDate[20]; + sprintf(aDate, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d", (int)(aDays->Value(anIndex)), (int)(aMonths->Value(anIndex)), + (int)(aYears->Value(anIndex)), (int)(aHours->Value(anIndex)), (int)(aMinutes->Value(anIndex))); + aDates->Append(aDate); + } + return aDates; +} + + + +//============================================================================ +/*! Function : GetUseCaseBuilder + * Purpose : Returns a UseCase builder + */ +//============================================================================ +Handle(SALOMEDSImpl_UseCaseBuilder) SALOMEDSImpl_Study::GetUseCaseBuilder() +{ + _errorCode = ""; + return _useCaseBuilder; +} + + +//============================================================================ +/*! Function : Close + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_Study::Close() +{ + _errorCode = ""; + Handle(TDocStd_Application) anApp = Handle(TDocStd_Application)::DownCast(_doc->Application()); + if(!anApp.IsNull()) anApp->Close(_doc); + _doc.Nullify(); +} + +//============================================================================ +/*! Function : AddPostponed + * Purpose : + */ + //============================================================================ +void SALOMEDSImpl_Study::AddPostponed(const TCollection_AsciiString& theIOR) +{ + _errorCode = ""; + if (!NewBuilder()->HasOpenCommand()) return; + TCollection_AsciiString anIOR(theIOR); + anIOR.Prepend("d"); + myPostponedIORs.Append(anIOR); // add prefix: deleted + myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); +} + +//============================================================================ +/*! Function : AddCreatedPostponed + * Purpose : + */ + //============================================================================ +void SALOMEDSImpl_Study::AddCreatedPostponed(const TCollection_AsciiString& theIOR) +{ + _errorCode = ""; + if (!NewBuilder()->HasOpenCommand()) return; + TCollection_AsciiString anIOR(theIOR); + anIOR.Prepend("c"); + myPostponedIORs.Append(anIOR); // add prefix: created + myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); +} + +//============================================================================ +/*! Function : RemovePostponed + * Purpose : + */ +//============================================================================ +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::RemovePostponed(const int theUndoLimit) +{ + _errorCode = ""; + + int anIndex; + int anOld; + + int aUndoLimit = theUndoLimit; + if (theUndoLimit < 0) aUndoLimit = 0; + + Handle(TColStd_HSequenceOfAsciiString) aSeq = new TColStd_HSequenceOfAsciiString; + + if (myNbUndos > 0) { // remove undone + anOld = 0; + for(anIndex = 1; anIndex < myNbPostponed.Length() - myNbUndos; anIndex++) + anOld += myNbPostponed(anIndex); + int aNew = myPostponedIORs.Length() - myNbPostponed.Last(); + + for(anIndex = anOld + 1; anIndex <= aNew; anIndex++) { + TCollection_AsciiString anIOR = myPostponedIORs(anIndex); + if (anIOR.Value(1) == 'c') { + aSeq->Append(anIOR.Split(1).ToCString()); + } + } + if (anOld < aNew) myPostponedIORs.Remove(anOld + 1, aNew); + if (myNbPostponed.Length() > 0) myNbPostponed.Remove(myNbPostponed.Length() - myNbUndos, myNbPostponed.Length() - 1); + + myNbUndos = 0; + } + + if (myNbPostponed.Length() > aUndoLimit) { // remove objects, that can not be undone + anOld = 0; + for(anIndex = myNbPostponed.Length() - aUndoLimit; anIndex >= 1; anIndex--) + anOld += myNbPostponed(anIndex); + for(anIndex = 1; anIndex <= anOld; anIndex++) { + TCollection_AsciiString anIOR = myPostponedIORs(anIndex); + if (anIOR.Value(1) == 'd') { + aSeq->Append(anIOR.Split(1).ToCString()); + } + } + if (anOld > 0) myPostponedIORs.Remove(1, anOld); + myNbPostponed.Remove(1, myNbPostponed.Length() - aUndoLimit); + } + + if (theUndoLimit == -1) { // remove all IORs from the study on the study close + TDF_ChildIDIterator anIter(_doc->GetData()->Root(), SALOMEDSImpl_AttributeIOR::GetID(), Standard_True); + for(; anIter.More(); anIter.Next()) { + Handle(SALOMEDSImpl_AttributeIOR) anAttr = Handle(SALOMEDSImpl_AttributeIOR)::DownCast(anIter.Value()); + aSeq->Append(anAttr->Value()); + } + } else myNbPostponed.Append(0); + + return aSeq; +} + +//============================================================================ +/*! Function : UndoPostponed + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_Study::UndoPostponed(const int theWay) +{ + _errorCode = ""; + + myNbUndos += theWay; + // remove current postponed + if (myNbPostponed.Last() > 0) + myPostponedIORs.Remove(myPostponedIORs.Length() - myNbPostponed.Last() + 1, myPostponedIORs.Length()); + myNbPostponed(myNbPostponed.Length()) = 0; +} + + +//============================================================================ +/*! Function : GetSComponent + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::GetSComponent(const TCollection_AsciiString& theEntry) +{ + TDF_Label aLabel; + TDF_Tool::Label(_doc->GetData(), theEntry, aLabel); + return new SALOMEDSImpl_SComponent(aLabel); +} + +//============================================================================ +/*! Function : GetSObject + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::GetSObject(const TCollection_AsciiString& theEntry) +{ + + TDF_Label aLabel; + TDF_Tool::Label(_doc->GetData(), theEntry, aLabel); + return new SALOMEDSImpl_SObject(aLabel); +} + +//============================================================================ +/*! Function : GetAttribute + * Purpose : + */ +//============================================================================ +Handle(TDF_Attribute) SALOMEDSImpl_Study::GetAttribute(const TCollection_AsciiString& theEntry, + const TCollection_AsciiString& theType) +{ + TDF_Label aLabel; + TDF_Tool::Label(_doc->GetData(), theEntry, aLabel); + Handle(SALOMEDSImpl_SObject) aSO = new SALOMEDSImpl_SObject(aLabel); + Handle(TDF_Attribute) anAttr; + aSO->FindAttribute(anAttr, theType); + return anAttr; +} + +//============================================================================ +/*! Function : DumpStudy + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, + const TCollection_AsciiString& theBaseName, + bool isPublished, + SALOMEDSImpl_DriverFactory* theFactory) +{ + _errorCode = ""; + + if(theFactory == NULL) { + _errorCode = "Null factory for creation of Engines"; + return false; + } + + TColStd_SequenceOfExtendedString aSeq; + TCollection_AsciiString aCompType, aFactoryType; + + //Build a list of all components in the Study + SALOMEDSImpl_SComponentIterator itcomponent = NewComponentIterator(); + + for (; itcomponent.More(); itcomponent.Next()) { + Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value(); + aCompType = sco->ComponentDataType(); + //GEOM and MED are independent components + if(aCompType == "GEOM" || aCompType == "MED") aSeq.Prepend(TCollection_ExtendedString(aCompType)); + else aSeq.Append(TCollection_ExtendedString(aCompType)); + } + +#ifdef WIN32 + TCollection_AsciiString aFileName=thePath+TCollection_AsciiString("\\")+theBaseName+TCollection_AsciiString("_Study.py"); +#else + TCollection_AsciiString aFileName=thePath+TCollection_AsciiString("/")+theBaseName+TCollection_AsciiString("_Study.py"); +#endif + + //Create a file that will contain a main Study script + fstream fp; + fp.open(aFileName.ToCString(), ios::out); + +#ifdef WIN32 + bool isOpened = fp.is_open(); +#else + bool isOpened = fp.rdbuf()->is_open(); +#endif + + if(!isOpened) { + _errorCode = TCollection_AsciiString("Can't create a file ")+aFileName; + return false; + } + + TCollection_AsciiString aBatchModeScript = "batchmode_salome"; + + //Output to the main Study script required Python modules import, set sys.path and add a creation of the study. + fp << "import sys" << endl; + fp << "import " << aBatchModeScript << "\n" << endl; + fp << "sys.path.append(\'" << thePath << "\')\n" << endl; + + Handle(TColStd_HSequenceOfAsciiString) aSeqOfFileNames = new TColStd_HSequenceOfAsciiString; + + //Iterate all components and create the componponents specific scripts. + int aLength = aSeq.Length(); + for(int i = 1; i <= aLength; i++) { + + aCompType = aSeq.Value(i); + + SALOMEDSImpl_Driver* aDriver = theFactory->GetDriverByType(aSeq.Value(i)); + if(aDriver == NULL) continue; + + bool isValidScript; + long aStreamLength = 0; + unsigned char* aStream = aDriver->DumpPython(this, isPublished, isValidScript, aStreamLength); + + //Create a file that will contain the component specific script + fstream fp2; +#ifdef WIN32 + aFileName=thePath+TCollection_AsciiString("\\"); +#else + aFileName=thePath+TCollection_AsciiString("/"); +#endif + TCollection_AsciiString aScriptName; + aScriptName += theBaseName; + aScriptName += "_"; + aScriptName += aCompType; + + aFileName += aScriptName+ TCollection_AsciiString(".py"); + aSeqOfFileNames->Append(aFileName); + + fp2.open(aFileName.ToCString(), ios::out); + +#ifdef WIN32 + isOpened = fp.is_open(); +#else + isOpened = fp.rdbuf()->is_open(); +#endif + + if(!isOpened) { + _errorCode = TCollection_AsciiString("Can't create a file ")+aFileName; + SALOMEDSImpl_Tool::RemoveTemporaryFiles(thePath, aSeqOfFileNames, false); + return false; + } + + //Output the Python script generated by the component in the newly created file. + fp2 << aStream; + fp2.close(); + + //Add to the main script a call to RebuildData of the generated by the component the Python script + fp << "import " << aScriptName << endl; + fp << aScriptName << ".RebuildData(" << aBatchModeScript << ".myStudy)" << endl; + } + + fp.close(); + return true; +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx new file mode 100644 index 000000000..fe143310a --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx @@ -0,0 +1,232 @@ +// File : SALOMEDSImpl_Study.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef __SALOMEDSIMPL_STUDY_I_H__ +#define __SALOMEDSIMPL_STUDY_I_H__ + +//Handle definition +#include +#include +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_Study, MMgt_TShared ) + +// std C++ headers +#include + +// Cascade headers +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//SALOMEDSImpl headers +#include "SALOMEDSImpl_SComponentIterator.hxx" +#include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_StudyBuilder.hxx" +#include "SALOMEDSImpl_DataMapStringLabel.hxx" +#include "SALOMEDSImpl_UseCaseBuilder.hxx" +#include "SALOMEDSImpl_AttributeStudyProperties.hxx" +#include "SALOMEDSImpl_AttributeIOR.hxx" +#include "SALOMEDSImpl_Callback.hxx" +#include "SALOMEDSImpl_Driver.hxx" + +class SALOMEDSImpl_StudyManager; +class SALOMEDSImpl_GenericAttribute; + +class SALOMEDSImpl_Study : public MMgt_TShared +{ +private: + TCollection_AsciiString _name; + Handle(TDocStd_Document) _doc; // OCAF Document + bool _Saved; // True if the Study is saved + TCollection_AsciiString _URL; //URL of the persistent reference of the study + int _StudyId; + TDF_Label _current; + bool _autoFill; + TCollection_AsciiString _errorCode; + Handle(SALOMEDSImpl_Callback) _cb; + Handle(SALOMEDSImpl_StudyBuilder) _builder; + Handle(SALOMEDSImpl_UseCaseBuilder) _useCaseBuilder; + + // data structures for postponed destroying of object functionality + TColStd_SequenceOfAsciiString myPostponedIORs; // ordered set of IORs + TColStd_SequenceOfInteger myNbPostponed; // number of IOR in the each transaction + int myNbUndos; // number of current Undos, made by user + SALOMEDSImpl_DataMapStringLabel myIORLabels; + + + Handle(SALOMEDSImpl_SObject) _FindObject(const Handle(SALOMEDSImpl_SObject)& SO, + const TCollection_AsciiString& anObjectName, + bool& _find); + + Handle(SALOMEDSImpl_SObject) _FindObjectIOR(const Handle(SALOMEDSImpl_SObject)& SO, + const TCollection_AsciiString& anObjectIOR, + bool& _find); + +public: + + static Handle(SALOMEDSImpl_Study) GetStudy(const TDF_Label& theLabel); + static void IORUpdated(const Handle(SALOMEDSImpl_AttributeIOR)& theAttribute); + + //! standard constructor + SALOMEDSImpl_Study(const Handle(TDocStd_Document)&, const TCollection_AsciiString& study_name); + + //! standard destructor + virtual ~SALOMEDSImpl_Study(); + + //! method to Get persistent reference of study (idem URL()) + virtual TCollection_AsciiString GetPersistentReference(); + + //! method to Get transient reference of study + virtual TCollection_AsciiString GetTransientReference(); + + virtual void SetTransientReference(const TCollection_AsciiString& theIOR); + + //! method to detect if a study is empty + virtual bool IsEmpty(); + + //! method to Find a Component with ComponentDataType = aComponentName + virtual Handle(SALOMEDSImpl_SComponent) FindComponent (const TCollection_AsciiString& aComponentName); + + //! method to Find a Component Find a Component from it's ID + virtual Handle(SALOMEDSImpl_SComponent) FindComponentID(const TCollection_AsciiString& aComponentID); + + //! method to Find an Object with SALOMEDSImpl::Name = anObjectName + virtual Handle(SALOMEDSImpl_SObject) FindObject(const TCollection_AsciiString& anObjectName); + + + //! method to Find Object(s) with SALOMEDSImpl::Name=anObjectName in a component with ComponentDataType = aComponentName + virtual Handle(TColStd_HSequenceOfTransient) FindObjectByName( const TCollection_AsciiString& anObjectName, + const TCollection_AsciiString& aComponentName ) ; + + //! method to Find an Object with ID = anObjectID + virtual Handle(SALOMEDSImpl_SObject) FindObjectID(const TCollection_AsciiString& anObjectID); + + //! method to Create an Object with ID = anObjectID + virtual Handle(SALOMEDSImpl_SObject) CreateObjectID(const TCollection_AsciiString& anObjectID); + + //! method to Find an Object with ID = anObjectIOR + virtual Handle(SALOMEDSImpl_SObject) FindObjectIOR(const TCollection_AsciiString& anObjectIOR); + + //! method to Find an Object by its path + virtual Handle(SALOMEDSImpl_SObject) FindObjectByPath(const TCollection_AsciiString& thePath); + + //! method to get a path of SObject + virtual TCollection_AsciiString GetObjectPath(const Handle(SALOMEDSImpl_SObject)& theObject); + + TCollection_AsciiString GetObjectPathByIOR(const TCollection_AsciiString& theIOR); + + //! method to set a context: root ('/') is UserData component + virtual bool SetContext(const TCollection_AsciiString& thePath); + + //! method to get a context + virtual TCollection_AsciiString GetContext(); + + //! method to get all object names in the given context (or in the current context, if 'theContext' is empty) + virtual Handle(TColStd_HSequenceOfAsciiString) GetObjectNames(const TCollection_AsciiString& theContext); + + //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty) + virtual Handle(TColStd_HSequenceOfAsciiString) GetDirectoryNames(const TCollection_AsciiString& theContext); + + //! method to get all file names in the given context (or in the current context, if 'theContext' is empty) + virtual Handle(TColStd_HSequenceOfAsciiString) GetFileNames(const TCollection_AsciiString& theContext); + + //! method to get all components names + virtual Handle(TColStd_HSequenceOfAsciiString) GetComponentNames(const TCollection_AsciiString& theContext); + + //! method to Create a ChildIterator from an SObject + virtual TDF_ChildIterator NewChildIterator(const Handle(SALOMEDSImpl_SObject)& aSO); + + //! method to Create a SComponentIterator + virtual SALOMEDSImpl_SComponentIterator NewComponentIterator(); + + //! method to Create a StudyBuilder + virtual Handle(SALOMEDSImpl_StudyBuilder) NewBuilder(); + + //! method to get study name + virtual TCollection_AsciiString Name(); + + //! method to set study name + virtual void Name(const TCollection_AsciiString& name); + + //! method to get if study has been saved + virtual bool IsSaved(); + + //! method to set if study has been saved + virtual void IsSaved(bool save); + + //! method to Detect if a Study has been modified since it has been saved + virtual bool IsModified(); + + //! method to get URL of the study (idem GetPersistentReference) + virtual TCollection_AsciiString URL(); + + //! method to set URL of the study + virtual void URL(const TCollection_AsciiString& url); + + virtual bool IsLocked(); + + virtual int StudyId(); + + virtual void StudyId(int id); + + virtual void UpdateIORLabelMap(const TCollection_AsciiString& anIOR, const TCollection_AsciiString& aLabel); + + virtual Handle(TColStd_HSequenceOfTransient) FindDependances(const Handle(SALOMEDSImpl_SObject)& anObject); + + virtual Handle(SALOMEDSImpl_AttributeStudyProperties) SALOMEDSImpl_Study::GetProperties(); + + virtual TCollection_AsciiString GetLastModificationDate(); + + virtual Handle(TColStd_HSequenceOfAsciiString) GetModificationsDate(); + + virtual Handle(SALOMEDSImpl_UseCaseBuilder) GetUseCaseBuilder(); + + virtual void Close(); + + void EnableUseCaseAutoFilling(bool isEnabled) { _errorCode = ""; _autoFill = isEnabled; } + + // postponed destroying of object functionality + virtual void AddPostponed(const TCollection_AsciiString& theIOR); + + virtual void AddCreatedPostponed(const TCollection_AsciiString& theIOR); + + virtual Handle(TColStd_HSequenceOfAsciiString) RemovePostponed(const int theUndoLimit); + // removes postponed IORs of old transaction + // if theUndoLimit==0, removes all + virtual void UndoPostponed(const int theWay); // theWay = 1: resurrect objects, + // theWay = -1: get back to the list of postponed + + + virtual TCollection_AsciiString GetErrorCode() { return _errorCode; } + virtual bool IsError() { return _errorCode != ""; } + + virtual Handle(SALOMEDSImpl_SComponent) GetSComponent(const TCollection_AsciiString& theEntry); + virtual Handle(SALOMEDSImpl_SObject) GetSObject(const TCollection_AsciiString& theEntry); + virtual Handle(TDF_Attribute) GetAttribute(const TCollection_AsciiString& theEntry, + const TCollection_AsciiString& theType); + + virtual bool HasCurrentContext() { return !_current.IsNull(); } + + virtual bool DumpStudy(const TCollection_AsciiString& thePath, + const TCollection_AsciiString& theBaseName, + bool isPublished, + SALOMEDSImpl_DriverFactory* theFactory); + + virtual Handle(TDocStd_Document) GetDocument() { return _doc; } + + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_Study ) + +friend class SALOMEDSImpl_StudyManager; +friend class SALOMEDSImpl_GenericAttribute; +}; +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx new file mode 100644 index 000000000..ee11643f1 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -0,0 +1,982 @@ +// File : SALOMEDSImpl_StudyBuilder.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; + +#include "SALOMEDSImpl_Attributes.hxx" + +#include "SALOMEDSImpl_Study.hxx" +#include "SALOMEDSImpl_StudyBuilder.hxx" +#include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_SComponent.hxx" +#include "SALOMEDSImpl_Tool.hxx" + +#include +#include +#include +#include +#include +#include + +#include +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_StudyBuilder, MMgt_TShared ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_StudyBuilder, MMgt_TShared ) + +#define USE_CASE_LABEL_TAG 2 +#define DIRECTORYID 16661 +#define FILELOCALID 26662 + +static void Translate_persistentID_to_IOR(TDF_Label& Lab, SALOMEDSImpl_Driver* driver, bool isMultiFile, bool isASCII); + +//============================================================================ +/*! Function : constructor + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_StudyBuilder::SALOMEDSImpl_StudyBuilder(const Handle(Standard_Transient)& theOwner) +{ + _errorCode = ""; + _study = theOwner; + _doc = Handle(SALOMEDSImpl_Study)::DownCast(theOwner)->GetDocument(); +} + +//============================================================================ +/*! Function : destructor + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_StudyBuilder::~SALOMEDSImpl_StudyBuilder() +{} + +//============================================================================ +/*! Function : NewComponent + * Purpose : Create a new component (Scomponent) + */ +//============================================================================ +Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_StudyBuilder::NewComponent(const TCollection_AsciiString& DataType) +{ + _errorCode = ""; + CheckLocked(); + //Always create component under main label. + TDF_Label L = _doc->Main(); + + int imax = 0; + for (TDF_ChildIterator it(L); it.More(); it.Next()) { + if (it.Value().Tag() > imax) + imax = it.Value().Tag(); + } + imax++; + TDF_Label NL = L.FindChild(imax); + + SALOMEDSImpl_AttributeComment::Set(NL, DataType); + + Handle(SALOMEDSImpl_SComponent) so = new SALOMEDSImpl_SComponent (NL); + + if(!_callbackOnAdd.IsNull()) _callbackOnAdd->OnAddSObject(so); + + return so; +} + +//============================================================================ +/*! Function : DefineComponentInstance + * Purpose : Add IOR attribute of a Scomponent + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::DefineComponentInstance(const Handle(SALOMEDSImpl_SComponent)& aComponent, + const TCollection_AsciiString& IOR) +{ + _errorCode = ""; + + CheckLocked(); + if(aComponent.IsNull() || IOR.IsEmpty()) { + _errorCode = "Invalid arguments"; + return false; + } + //add IOR definition + SALOMEDSImpl_AttributeIOR::Set(aComponent->GetLabel(), IOR); + return true; +} + +//============================================================================ +/*! Function : RemoveComponent + * Purpose : Delete a Scomponent + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::RemoveComponent(const Handle(SALOMEDSImpl_SComponent)& aComponent) +{ + _errorCode = ""; + CheckLocked(); + return RemoveObject(aComponent); +} + +//============================================================================ +/*! Function : NewObject + * Purpose : Create a new SObject + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_StudyBuilder::NewObject(const Handle(SALOMEDSImpl_SObject)& theFatherObject) +{ + _errorCode = ""; + CheckLocked(); + + //Find label of father + TDF_Label Lab = theFatherObject->GetLabel(); + + //Create a new label + int imax = 0; + for (TDF_ChildIterator it(Lab); it.More(); it.Next()) { + if (it.Value().Tag() > imax) + imax = it.Value().Tag(); + } + imax++; + TDF_Label NewLab = Lab.FindChild(imax); + + Handle(SALOMEDSImpl_SObject) so = new SALOMEDSImpl_SObject(NewLab); + if(!_callbackOnAdd.IsNull()) _callbackOnAdd->OnAddSObject(so); + + return so; +} + +//============================================================================ +/*! Function : NewObjectToTag + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_StudyBuilder::NewObjectToTag(const Handle(SALOMEDSImpl_SObject)& theFatherObject, + const int theTag) +{ + _errorCode = ""; + CheckLocked(); + //Find label of father + TDF_Label Lab = theFatherObject->GetLabel(); + + //Create or find label + TDF_Label NewLab = Lab.FindChild(theTag, 1); + + Handle(SALOMEDSImpl_SObject) so = new SALOMEDSImpl_SObject (NewLab); + + if(!_callbackOnAdd.IsNull()) _callbackOnAdd->OnAddSObject(so); + + return so; +} + +//============================================================================ +/*! Function : RemoveObject + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::RemoveObject(const Handle(SALOMEDSImpl_SObject)& anObject) +{ + _errorCode = ""; + CheckLocked(); + if(anObject.IsNull()) { + _errorCode = "Null object"; + return false; + } + + if(!_callbackOnRemove.IsNull()) _callbackOnRemove->OnRemoveSObject(anObject); + + TDF_Label Lab = anObject->GetLabel(); + + Handle(SALOMEDSImpl_AttributeReference) aReference; + if (Lab.FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), aReference)) { + Handle(SALOMEDSImpl_AttributeTarget) aTarget; + if (aReference->Get().FindAttribute(SALOMEDSImpl_AttributeTarget::GetID(),aTarget)) + aTarget->Remove(Lab); + } + + Handle(SALOMEDSImpl_AttributeIOR) anAttr; // postponed removing of CORBA objects + if (Lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), anAttr)) + SALOMEDSImpl_Study::GetStudy(_doc->Main())->AddPostponed(TCollection_AsciiString(anAttr->Value()).ToCString()); + + Lab.ForgetAllAttributes(); + return true; +} + +//============================================================================ +/*! Function : RemoveObjectWithChildren + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::RemoveObjectWithChildren(const Handle(SALOMEDSImpl_SObject)& anObject) +{ + _errorCode = ""; + CheckLocked(); + if(anObject.IsNull()) { + _errorCode = "Null object"; + return false; + } + + if(!_callbackOnRemove.IsNull()) _callbackOnRemove->OnRemoveSObject(anObject); + + TDF_Label Lab = anObject->GetLabel(); + + Handle(SALOMEDSImpl_AttributeReference) aReference; + if (Lab.FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), aReference)) { + Handle(SALOMEDSImpl_AttributeTarget) aTarget; + if (aReference->Get().FindAttribute(SALOMEDSImpl_AttributeTarget::GetID(),aTarget)) + aTarget->Remove(Lab); + } + Handle(SALOMEDSImpl_AttributeIOR) anAttr; // postponed removing of CORBA objects + if (Lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), anAttr)) + SALOMEDSImpl_Study::GetStudy(_doc->Main())->AddPostponed(TCollection_AsciiString(anAttr->Value()).ToCString()); + + TDF_ChildIterator it(Lab, Standard_True); + for(;it.More();it.Next()) { + TDF_Label aLabel = it.Value(); + if (aLabel.FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), aReference)) { + Handle(SALOMEDSImpl_AttributeTarget) aTarget; + if (aReference->Get().FindAttribute(SALOMEDSImpl_AttributeTarget::GetID(),aTarget)) + aTarget->Remove(aLabel); + } + Handle(SALOMEDSImpl_AttributeIOR) anAttr; // postponed removing of CORBA objects + if (aLabel.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), anAttr)) + SALOMEDSImpl_Study::GetStudy(_doc->Main())->AddPostponed(TCollection_AsciiString(anAttr->Value()).ToCString()); + } + + Lab.ForgetAllAttributes(Standard_True); + return true; +} + +//============================================================================ +/*! Function : LoadWith + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& anSCO, SALOMEDSImpl_Driver* aDriver) +{ + _errorCode = ""; + + TDF_Label Lab = anSCO->GetLabel(); + Handle(SALOMEDSImpl_AttributePersistentRef) Att; + + //Find the current Url of the study + if (_doc->Main().FindAttribute(SALOMEDSImpl_AttributePersistentRef::GetID(),Att)) { + int aLocked = anSCO->GetStudy()->GetProperties()->IsLocked(); + if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(false); + + TCollection_ExtendedString Res(Att->Get()); + + Handle(SALOMEDSImpl_AttributeComment) type; + TCollection_ExtendedString DataType; + if (Lab.FindAttribute(SALOMEDSImpl_AttributeComment::GetID(),type)) + DataType = type->Get(); + + // associate the driver to the SComponent + if(aDriver == NULL) { + _errorCode = "Driver is null"; + return false; + } + + // mpv 06.03.2003: SAL1927 - if component data if already loaded, it is not necessary to do it again + Handle(SALOMEDSImpl_AttributeIOR) attrIOR; + if (Lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), attrIOR)) { + if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); + return true; + } + + DefineComponentInstance (anSCO, aDriver->GetIOR()); + + TCollection_AsciiString aHDFPath(Res); + + char* aHDFUrl; + bool isASCII = false; + if (HDFascii::isASCII(aHDFPath.ToCString())) { + isASCII = true; + char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aHDFPath.ToCString()); + aHDFUrl = new char[strlen(aResultPath) + 19]; + sprintf(aHDFUrl, "%shdf_from_ascii.hdf", aResultPath); + delete(aResultPath); + } else { + aHDFUrl = aHDFPath.ToCString(); + } + + //Open the Study HDF file + HDFfile *hdf_file = new HDFfile(aHDFUrl); + + char aMultifileState[2]; + char ASCIIfileState[2]; + try { + TCollection_AsciiString scoid = anSCO->GetID(); + hdf_file->OpenOnDisk(HDF_RDONLY); + HDFgroup *hdf_group = new HDFgroup("DATACOMPONENT",hdf_file); + hdf_group->OpenOnDisk(); + HDFgroup *hdf_sco_group = new HDFgroup(scoid.ToCString(), hdf_group); + hdf_sco_group->OpenOnDisk(); + + unsigned char* aStreamFile = NULL; + int aStreamSize = 0; + + if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) { + HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group); + hdf_dataset->OpenOnDisk(); + aStreamSize = hdf_dataset->GetSize(); + aStreamFile = new unsigned char[aStreamSize]; + if(aStreamFile == NULL) throw HDFexception("Unable to open dataset FILE_STREAM"); + hdf_dataset->ReadFromDisk(aStreamFile); + hdf_dataset->CloseOnDisk(); + hdf_dataset = 0; + } else aStreamFile = NULL; + + HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group); + multifile_hdf_dataset->OpenOnDisk(); + multifile_hdf_dataset->ReadFromDisk(aMultifileState); + + HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group); + ascii_hdf_dataset->OpenOnDisk(); + ascii_hdf_dataset->ReadFromDisk(ASCIIfileState); + + // set path without file name from URL + int aFileNameSize = Res.Length(); + char* aDir = new char[aFileNameSize]; + memcpy(aDir, TCollection_AsciiString(Res).ToCString(), aFileNameSize); + for(int aCounter = aFileNameSize-1; aCounter>=0; aCounter--) + if (aDir[aCounter] == '/') { + aDir[aCounter+1] = 0; + break; + } + + bool aResult = (ASCIIfileState[0]=='A')? + aDriver->LoadASCII(anSCO, aStreamFile, aStreamSize, aDir, aMultifileState[0]=='M'): + aDriver->Load(anSCO, aStreamFile, aStreamSize, aDir, aMultifileState[0]=='M'); + + if(aStreamFile != NULL) delete []aStreamFile; + + if(!aResult) { + RemoveAttribute( anSCO, "AttributeIOR" ); + + _errorCode = "Can't load component"; + throw HDFexception("Unable to load component"); + } + + if(aDir != NULL) delete []aDir; + + multifile_hdf_dataset->CloseOnDisk(); + multifile_hdf_dataset = 0; + ascii_hdf_dataset->CloseOnDisk(); + ascii_hdf_dataset = 0; + + hdf_sco_group->CloseOnDisk(); + hdf_sco_group = 0; + hdf_group->CloseOnDisk(); + hdf_group = 0; + hdf_file->CloseOnDisk(); + delete hdf_file; + + if (isASCII) { + Handle(TColStd_HSequenceOfAsciiString) aFilesToRemove = new TColStd_HSequenceOfAsciiString; + aFilesToRemove->Append(aHDFUrl); + SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true); + } + + delete aHDFUrl; + } + catch (HDFexception) { + delete hdf_file; + + if (isASCII) { + Handle(TColStd_HSequenceOfAsciiString) aFilesToRemove = new TColStd_HSequenceOfAsciiString; + aFilesToRemove->Append(aHDFUrl); + SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true); + } + delete aHDFUrl; + + if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); + _errorCode = "No persistent file"; + return false; + } + + try { + Translate_persistentID_to_IOR (Lab, aDriver, aMultifileState[0]=='M', ASCIIfileState[0] == 'A'); + } catch(...) { + _errorCode = "Can not convert persistent IDs to IORs"; + return false; + } + + if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); + } else { + _errorCode = "No persistent file"; + return false; + } + + return true; +} + + +//============================================================================ +/*! Function : Load + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::Load(const Handle(SALOMEDSImpl_SObject)& sco) +{ + _errorCode = "Not implemented"; + return false; +} + +//============================================================================ +/*! Function : FindOrCreateAttribute + * Purpose : Add attribute of given type to SObject, if there is attribute of such type, returns + * existing one + */ +//============================================================================ +Handle(TDF_Attribute) SALOMEDSImpl_StudyBuilder::FindOrCreateAttribute(const Handle(SALOMEDSImpl_SObject)& anObject, + const TCollection_AsciiString& aTypeOfAttribute) +{ + _errorCode = ""; + if(anObject.IsNull()) { + _errorCode = "Invalid arguments"; + return NULL; + } + + TDF_Label Lab = anObject->GetLabel(); + if(Lab.IsNull()) { + _errorCode = "Null label"; + return NULL; + } + + //The macro adds all necessary checks for standardly behaiving attributes + __FindOrCreateAttributeForBuilder + + //Add checks for TreeNode and UserID attributes + if (strncmp(aTypeOfAttribute.ToCString(), "AttributeTreeNode",17) == 0 ) { + Standard_GUID aTreeNodeGUID; + if (strcmp(aTypeOfAttribute.ToCString(), "AttributeTreeNode") == 0) { + aTreeNodeGUID = SALOMEDSImpl_AttributeTreeNode::GetDefaultTreeID(); + } else { + char* aGUIDString = new char[40]; + char* aType = (char*)aTypeOfAttribute.ToCString(); + sprintf(aGUIDString, &(aType[21])); + aTreeNodeGUID = Standard_GUID(aGUIDString); // create tree node GUID by name + delete(aGUIDString); + } + Handle(SALOMEDSImpl_AttributeTreeNode) anAttr; + if (!Lab.FindAttribute(aTreeNodeGUID, anAttr)) { + CheckLocked(); + anAttr = SALOMEDSImpl_AttributeTreeNode::Set(Lab, aTreeNodeGUID); + } + return anAttr; + } + + if (strncmp(aTypeOfAttribute.ToCString(), "AttributeUserID",15) == 0 ) { + Handle(SALOMEDSImpl_AttributeUserID) anAttr; + if (!Lab.FindAttribute(SALOMEDSImpl_AttributeUserID::DefaultID(), anAttr)) { + CheckLocked(); + anAttr = SALOMEDSImpl_AttributeUserID::Set(Lab, SALOMEDSImpl_AttributeUserID::DefaultID()); + } + return anAttr; + } + _errorCode = "Can not create an attribute"; + + return NULL; +} + +//============================================================================ +/*! Function : FindAttribute + * Purpose : Find attribute of given type assigned SObject, returns Standard_True if it is found + */ +//============================================================================ + +bool SALOMEDSImpl_StudyBuilder::FindAttribute(const Handle(SALOMEDSImpl_SObject)& anObject, + Handle(TDF_Attribute)& anAttribute, + const TCollection_AsciiString& aTypeOfAttribute) +{ + _errorCode = ""; + if(anObject.IsNull()) { + _errorCode = "Invalid arguments"; + return false; + } + TDF_Label Lab = anObject->GetLabel(); + if (Lab.FindAttribute(SALOMEDSImpl_SObject::GetGUID(aTypeOfAttribute), anAttribute)) { + return Standard_True; + } + return Standard_False; +} + +//============================================================================ +/*! Function : RemoveAttribute + * Purpose : Remove attribute of given type assigned SObject + */ +//============================================================================ + +bool SALOMEDSImpl_StudyBuilder::RemoveAttribute(const Handle(SALOMEDSImpl_SObject)& anObject, + const TCollection_AsciiString& aTypeOfAttribute) +{ + _errorCode = ""; + CheckLocked(); + if(anObject.IsNull()) { + _errorCode = "Invalid arguments"; + return false; + } + TDF_Label Lab = anObject->GetLabel(); + + if (aTypeOfAttribute == "AttributeIOR") { // postponed removing of CORBA objects + Handle(SALOMEDSImpl_AttributeIOR) anAttr; + if (Lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), anAttr)) + SALOMEDSImpl_Study::GetStudy(_doc->Main())->AddPostponed(anAttr->Value()); + } + + Lab.ForgetAttribute (SALOMEDSImpl_SObject::GetGUID(aTypeOfAttribute)); + return true; +} + +//============================================================================ +/*! Function : Addreference + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::Addreference(const Handle(SALOMEDSImpl_SObject)& me, + const Handle(SALOMEDSImpl_SObject)& theReferencedObject) +{ + _errorCode = ""; + if(me.IsNull() || theReferencedObject.IsNull()) { + _errorCode = "Invalid arguments"; + return false; + } + CheckLocked(); + TDF_Label Lab = me->GetLabel(); + TDF_Label RefLab = theReferencedObject->GetLabel(); + SALOMEDSImpl_AttributeReference::Set(Lab,RefLab); + + SALOMEDSImpl_AttributeTarget::Set(RefLab)->Append(Lab); + + if(!_callbackOnRemove.IsNull() && Lab.IsDescendant(_doc->Main())) _callbackOnRemove->OnRemoveSObject(me); + return true; +} + +//============================================================================ +/*! Function : RemoveReference + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::RemoveReference(const Handle(SALOMEDSImpl_SObject)& me) +{ + _errorCode = ""; + Handle(SALOMEDSImpl_SObject) theReferencedObject; + if(!me->ReferencedObject(theReferencedObject)) return false; //No reference is found + + CheckLocked(); + TDF_Label Lab = me->GetLabel(); + + Lab.ForgetAttribute(SALOMEDSImpl_AttributeReference::GetID()); + + //SRN: 30 Aug, 2004 : fix from Ecole l'ete version + + TDF_Label RefLab = theReferencedObject->GetLabel(); + + Handle(SALOMEDSImpl_AttributeTarget) aTarget; + if(RefLab.FindAttribute(SALOMEDSImpl_AttributeTarget::GetID(), aTarget)) aTarget->Remove(Lab); + return true; +} + + + +//============================================================================ +/*! Function : AddDirectory + * Purpose : adds a new directory with a path = thePath + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::AddDirectory(const TCollection_AsciiString& thePath) +{ + _errorCode = ""; + CheckLocked(); + if(thePath.IsEmpty() || thePath == "") { + _errorCode = "Invalid path"; + return false; + } + + TCollection_AsciiString aPath(thePath), aContext(""), aFatherPath; + TDF_Label aLabel; + Handle(SALOMEDSImpl_Study) aStudy = SALOMEDSImpl_Study::GetStudy(_doc->Main()); + Handle(SALOMEDSImpl_SObject) anObject; + + try { + anObject = aStudy->FindObjectByPath(thePath); //Check if the directory already exists + } + catch(...) { } + + if(!anObject.IsNull()) { + _errorCode = "StudyNameAlreadyUsed"; + return false; + } + + if(aPath.Value(1) != '/') { //Relative path + aPath.Prepend('/'); + aPath = aStudy->GetContext() + aPath; + } + + TCollection_AsciiString aToken = aPath.Token("/", 1); + if(aToken.Length() == 0) aFatherPath = "/"; + + int i = 1; + while(aToken.Length() != 0) { + if(aPath.Token("/", i+1).Length() > 0) { + aFatherPath += "/"; + aFatherPath += aToken; + } + aToken = aPath.Token("/", ++i); + } + + anObject.Nullify(); + try { + anObject = aStudy->FindObjectByPath(aFatherPath); //Check if the father directory exists + } + catch(...) { ; } + if(anObject.IsNull()) { + _errorCode = "StudyInvalidDirectory"; + return false; + } + + Handle(SALOMEDSImpl_SObject) aNewObject = NewObject(anObject); + aLabel = aNewObject->GetLabel(); + if(aLabel.IsNull()) { + _errorCode = "StudyInvalidComponent"; + return false; + } + + SALOMEDSImpl_AttributeName::Set(aLabel, aPath.Token("/", i-1)); + + //Set LocalID attribute to identify the directory object + Handle(SALOMEDSImpl_AttributeLocalID) aLocalID = SALOMEDSImpl_AttributeLocalID::Set(aLabel, DIRECTORYID); + return true; +} + + +//============================================================================ +/*! Function : SetGUID + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::SetGUID(const Handle(SALOMEDSImpl_SObject)& anObject, + const TCollection_AsciiString& theGUID) +{ + _errorCode = ""; + CheckLocked(); + if(anObject.IsNull()) { + _errorCode = "Invalid arguments"; + return false; + } + + TDF_Label aLabel = anObject->GetLabel(); + SALOMEDSImpl_AttributeUserID::Set(aLabel, theGUID.ToCString()); + return true; +} + +//============================================================================ +/*! Function : IsGUID + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::IsGUID(const Handle(SALOMEDSImpl_SObject)& anObject, + const TCollection_AsciiString& theGUID) +{ + _errorCode = ""; + if(anObject.IsNull()) { + _errorCode = "Invalid arguments"; + return false; + } + TDF_Label aLabel = anObject->GetLabel(); + return aLabel.IsAttribute(theGUID.ToCString()); +} + + +//============================================================================ +/*! Function : NewCommand + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_StudyBuilder::NewCommand() +{ + _errorCode = ""; + // mpv: for SAL2114 - unset "lock changed" flag at the operation start + Handle(SALOMEDSImpl_AttributeStudyProperties) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDSImpl_AttributeStudyProperties::GetID(), anAttr)) { + anAttr = new SALOMEDSImpl_AttributeStudyProperties; + _doc->Main().AddAttribute(anAttr); + } + anAttr->IsLockChanged(true); + + _doc->NewCommand(); +} + +//============================================================================ +/*! Function : CommitCommand + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_StudyBuilder::CommitCommand() +{ + _errorCode = ""; + Handle(SALOMEDSImpl_AttributeStudyProperties) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDSImpl_AttributeStudyProperties::GetID(), anAttr)) { + anAttr = new SALOMEDSImpl_AttributeStudyProperties; + _doc->Main().AddAttribute(anAttr); + } + if (anAttr->IsLocked() && !anAttr->IsLockChanged(true)) { + AbortCommand(); + _errorCode = "LockProtection"; + throw LockProtection("LockProtection"); + } else { + SALOMEDSImpl_Study::GetStudy(_doc->Main())->RemovePostponed(_doc->GetUndoLimit()); + + int aModif = anAttr->GetModified(); + if (aModif < 0) aModif = 1000; // if user make undo and then - new transaction "modify" will never be zero + anAttr->SetModified(aModif+1); + _doc->CommitCommand(); + } +} + +//============================================================================ +/*! Function : HasOpenCommand + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::HasOpenCommand() +{ + _errorCode = ""; + return _doc->HasOpenCommand(); +} + +//============================================================================ +/*! Function : AbortCommand + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_StudyBuilder::AbortCommand() +{ + _errorCode = ""; + SALOMEDSImpl_Study::GetStudy(_doc->Main())->UndoPostponed(0); + + _doc->AbortCommand(); +} + +//============================================================================ +/*! Function : Undo + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_StudyBuilder::Undo() +{ + _errorCode = ""; + Handle(SALOMEDSImpl_AttributeStudyProperties) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDSImpl_AttributeStudyProperties::GetID(), anAttr)) { + anAttr = new SALOMEDSImpl_AttributeStudyProperties; + _doc->Main().AddAttribute(anAttr); + } + if (anAttr->IsLocked()) { + _errorCode = "LockProtection"; + throw LockProtection("LockProtection"); + } else { + SALOMEDSImpl_Study::GetStudy(_doc->Main())->UndoPostponed(1); + _doc->Undo(); + anAttr->SetModified(anAttr->GetModified()-1); + } +} + +//============================================================================ +/*! Function : Redo + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_StudyBuilder::Redo() +{ + _errorCode = ""; + Handle(SALOMEDSImpl_AttributeStudyProperties) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDSImpl_AttributeStudyProperties::GetID(), anAttr)) { + anAttr = new SALOMEDSImpl_AttributeStudyProperties; + _doc->Main().AddAttribute(anAttr); + } + + if (anAttr->IsLocked()) { + _errorCode = "LockProtection"; + throw LockProtection("LockProtection"); + } else { + _doc->Redo(); + SALOMEDSImpl_Study::GetStudy(_doc->Main())->UndoPostponed(-1); + anAttr->SetModified(anAttr->GetModified()+1); + } + } + +//============================================================================ +/*! Function : GetAvailableUndos + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::GetAvailableUndos() +{ + _errorCode = ""; + return _doc->GetAvailableUndos(); +} + +//============================================================================ +/*! Function : GetAvailableRedos + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::GetAvailableRedos() +{ + _errorCode = ""; + return _doc->GetAvailableRedos(); +} + +//============================================================================ +/*! Function : UndoLimit + * Purpose : + */ +//============================================================================ +int SALOMEDSImpl_StudyBuilder::UndoLimit() +{ + _errorCode = ""; + return _doc->GetUndoLimit(); +} + +//============================================================================ +/*! Function : UndoLimit + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_StudyBuilder::UndoLimit(int n) +{ + _errorCode = ""; + CheckLocked(); + _doc->SetUndoLimit (n); +} + +//============================================================================ +/*! Function : SetOnAddSObject + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_Callback) +SALOMEDSImpl_StudyBuilder::SetOnAddSObject(const Handle(SALOMEDSImpl_Callback)& theCallback) +{ + _errorCode = ""; + Handle(SALOMEDSImpl_Callback) aRet = _callbackOnAdd; + _callbackOnAdd = theCallback; + return aRet; +} + +//============================================================================ +/*! Function : SetOnNewSObject + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_Callback) +SALOMEDSImpl_StudyBuilder::SetOnRemoveSObject(const Handle(SALOMEDSImpl_Callback)& theCallback) +{ + _errorCode = ""; + Handle(SALOMEDSImpl_Callback) aRet = _callbackOnRemove; + _callbackOnRemove = theCallback; + return aRet; +} + +//============================================================================ +/*! Function : CheckLocked + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_StudyBuilder::CheckLocked() +{ + _errorCode = ""; + if (_doc->HasOpenCommand()) return; + Handle(SALOMEDSImpl_AttributeStudyProperties) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDSImpl_AttributeStudyProperties::GetID(), anAttr)) { + anAttr = new SALOMEDSImpl_AttributeStudyProperties; + _doc->Main().AddAttribute(anAttr); + } + if (anAttr->IsLocked()) { + _errorCode = "LockProtection"; + throw LockProtection("LockProtection"); + } +} + +//============================================================================ +/*! Function : SetName + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::SetName(const Handle(SALOMEDSImpl_SObject)& theSO, + const TCollection_AsciiString& theValue) +{ + _errorCode = ""; + CheckLocked(); + if(theSO.IsNull()) { + _errorCode = "Invalid arguments"; + return false; + } + SALOMEDSImpl_AttributeName::Set(theSO->GetLabel(), theValue); + return true; +} + +//============================================================================ +/*! Function : SetComment + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::SetComment(const Handle(SALOMEDSImpl_SObject)& theSO, + const TCollection_AsciiString& theValue) +{ + _errorCode = ""; + CheckLocked(); + if(theSO.IsNull()) { + _errorCode = "Invalid arguments"; + return false; + } + SALOMEDSImpl_AttributeComment::Set(theSO->GetLabel(), theValue); + return true; +} + +//============================================================================ +/*! Function : SetIOR + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyBuilder::SetIOR(const Handle(SALOMEDSImpl_SObject)& theSO, + const TCollection_AsciiString& theValue) +{ + _errorCode = ""; + CheckLocked(); + if(theSO.IsNull()) { + _errorCode = "Invalid arguments"; + return false; + } + SALOMEDSImpl_AttributeIOR::Set(theSO->GetLabel(), theValue); + return true; +} + + +//============================================================================ +/*! Function : Translate_persistentID_to_IOR + * Purpose : + */ +//============================================================================ +static void Translate_persistentID_to_IOR(TDF_Label& Lab, SALOMEDSImpl_Driver* driver, bool isMultiFile, bool isASCII) +{ + if(driver == NULL) return; + TDF_ChildIterator itchild (Lab); + + for (; itchild.More(); itchild.Next()) { + TDF_Label current = itchild.Value(); + Handle(SALOMEDSImpl_AttributePersistentRef) Att; + if (current.FindAttribute(SALOMEDSImpl_AttributePersistentRef::GetID(),Att)) { + + Handle(SALOMEDSImpl_AttributeLocalID) anID; + if (current.FindAttribute(SALOMEDSImpl_AttributeLocalID::GetID(), anID)) + if (anID->Value() == FILELOCALID) continue; //SRN: This attribute store a file name, skip it + + TCollection_AsciiString persist_ref(Att->Get()); + Handle(SALOMEDSImpl_SObject) so = new SALOMEDSImpl_SObject(current); + TCollection_AsciiString ior_string = driver->LocalPersistentIDToIOR(so, + persist_ref, + isMultiFile, + isASCII); + SALOMEDSImpl_AttributeIOR::Set (current, ior_string); + + } + Translate_persistentID_to_IOR (current, driver, isMultiFile, isASCII); + } +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx new file mode 100644 index 000000000..6fc553ba3 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx @@ -0,0 +1,106 @@ +// File : SALOMEDSImpl_StudyBuilder.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef __SALOMEDSImpl_STUDYBUILDER_H__ +#define __SALOMEDSImpl_STUDYBUILDER_H__ + +//Handle definition +#include +#include +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_StudyBuilder, MMgt_TShared ) + +// std C++ headers +#include + +// Cascade header +#include +#include + +#include "SALOMEDSImpl_Callback.hxx" +#include "SALOMEDSImpl_Driver.hxx" + +class SALOMEDSImpl_StudyBuilder : public MMgt_TShared +{ +private: + Handle(TDocStd_Document) _doc; + Handle(Standard_Transient) _study; + Handle(SALOMEDSImpl_Callback) _callbackOnAdd; + Handle(SALOMEDSImpl_Callback) _callbackOnRemove; + TCollection_AsciiString _errorCode; + +public: + + SALOMEDSImpl_StudyBuilder(const Handle(Standard_Transient)& theOwner); + + ~SALOMEDSImpl_StudyBuilder(); + + virtual Handle(SALOMEDSImpl_SComponent) NewComponent(const TCollection_AsciiString& ComponentDataType); + + virtual bool DefineComponentInstance (const Handle(SALOMEDSImpl_SComponent)&, const TCollection_AsciiString& ComponentIOR); + + virtual bool RemoveComponent(const Handle(SALOMEDSImpl_SComponent)& aComponent); + + virtual Handle(SALOMEDSImpl_SObject) NewObject(const Handle(SALOMEDSImpl_SObject)& theFatherObject); + + virtual Handle(SALOMEDSImpl_SObject) NewObjectToTag(const Handle(SALOMEDSImpl_SObject)& theFatherObject, + const int theTag); + + //! The methods adds a new subdirectory, the path can be absolute or relative (then the current context is used) + virtual bool AddDirectory(const TCollection_AsciiString& thePath); + + virtual bool LoadWith(const Handle(SALOMEDSImpl_SComponent)& sco, SALOMEDSImpl_Driver* Engine); + virtual bool Load(const Handle(SALOMEDSImpl_SObject)& sco); + + virtual bool RemoveObject(const Handle(SALOMEDSImpl_SObject)& anObject); + virtual bool RemoveObjectWithChildren(const Handle(SALOMEDSImpl_SObject)& anObject); + + virtual Handle(TDF_Attribute) FindOrCreateAttribute(const Handle(SALOMEDSImpl_SObject)& anObject, + const TCollection_AsciiString& aTypeOfAttribute); + virtual bool FindAttribute(const Handle(SALOMEDSImpl_SObject)& anObject, + Handle(TDF_Attribute)& anAttribute, + const TCollection_AsciiString& aTypeOfAttribute); + + virtual bool RemoveAttribute(const Handle(SALOMEDSImpl_SObject)& anObject, const TCollection_AsciiString& aTypeOfAttribute); + + virtual bool Addreference(const Handle(SALOMEDSImpl_SObject)& me, + const Handle(SALOMEDSImpl_SObject)& thereferencedObject); + + virtual bool RemoveReference(const Handle(SALOMEDSImpl_SObject)& me); + + virtual bool SetGUID(const Handle(SALOMEDSImpl_SObject)& anObject, const TCollection_AsciiString& theGUID); + virtual bool IsGUID(const Handle(SALOMEDSImpl_SObject)& anObject, const TCollection_AsciiString& theGUID); + + virtual void NewCommand(); + virtual void CommitCommand(); + virtual bool HasOpenCommand(); + virtual void AbortCommand(); + virtual void Undo(); + virtual void Redo(); + bool GetAvailableUndos(); + bool GetAvailableRedos(); + bool IsSaved(); + bool IsModified(); + virtual int UndoLimit(); + virtual void UndoLimit(const int); + + void CheckLocked(); + + virtual Handle(SALOMEDSImpl_Callback) SetOnAddSObject(const Handle(SALOMEDSImpl_Callback)& theCallback); + virtual Handle(SALOMEDSImpl_Callback) SetOnRemoveSObject(const Handle(SALOMEDSImpl_Callback)& theCallback); + + virtual bool SetName(const Handle(SALOMEDSImpl_SObject)& theSO, const TCollection_AsciiString& theValue); + + virtual bool SetComment(const Handle(SALOMEDSImpl_SObject)& theSO, const TCollection_AsciiString& theValue); + + virtual bool SetIOR(const Handle(SALOMEDSImpl_SObject)& theSO, const TCollection_AsciiString& theValue); + + virtual TCollection_AsciiString GetErrorCode() { return _errorCode; } + virtual bool IsError() { return _errorCode != ""; } + + virtual Handle(Standard_Transient) GetOwner() { return _study; } + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_StudyBuilder ) +}; +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.cxx new file mode 100644 index 000000000..4952318e6 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.cxx @@ -0,0 +1,95 @@ +// File : SALOMEDSImpl_StudyHandle.cxx +// Author : Sergey LITONIN +// Module : SALOME + +#include "SALOMEDSImpl_StudyHandle.hxx" +#include +#include + +/* + Class : SALOMEDSImpl_StudyHandle + Description : This class is intended for storing information about + graphic representation of objects in dirrent views +*/ + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_StudyHandle, TDF_Attribute ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_StudyHandle, TDF_Attribute ) + +//======================================================================= +//function : GetID +//purpose : Get GUID of this attribute +//======================================================================= +const Standard_GUID& SALOMEDSImpl_StudyHandle::GetID() +{ + static Standard_GUID SALOMEDSImpl_StudyHandleID( "050C9555-4BA8-49bf-8F1C-086F0469A40B" ); + return SALOMEDSImpl_StudyHandleID; +} + +//======================================================================= +//function : SALOMEDSImpl_StudyHandle +//purpose : Empty Constructor +//======================================================================= +SALOMEDSImpl_StudyHandle::SALOMEDSImpl_StudyHandle() +{ + myHandle.Nullify(); +} + +//======================================================================= +//function : Set +//purpose : +//======================================================================= +Handle(SALOMEDSImpl_StudyHandle) SALOMEDSImpl_StudyHandle::Set(const TDF_Label& theLabel, + const Handle(SALOMEDSImpl_Study)& theStudy) +{ + Handle(SALOMEDSImpl_StudyHandle) A; + if (!theLabel.FindAttribute(GetID(), A)) { + A = new SALOMEDSImpl_StudyHandle(); + theLabel.AddAttribute(A); + } + + A->SetHandle(theStudy); + return A; +} + + +//======================================================================= +//function : ID +//purpose : Get GUID of this attribute +//======================================================================= +const Standard_GUID& SALOMEDSImpl_StudyHandle::ID () const +{ + return GetID(); +} + + +//======================================================================= +//function : NewEmpty +//purpose : Create new empty attribute +//======================================================================= +Handle(TDF_Attribute) SALOMEDSImpl_StudyHandle::NewEmpty () const +{ + return new SALOMEDSImpl_StudyHandle (); +} + + +//======================================================================= +//function : Restore +//purpose : Restore value of attribute with value of theWith one +//======================================================================= +void SALOMEDSImpl_StudyHandle::Restore( const Handle(TDF_Attribute)& theWith ) +{ + Handle(SALOMEDSImpl_StudyHandle) anAttr = Handle(SALOMEDSImpl_StudyHandle)::DownCast( theWith ); + if ( !anAttr.IsNull() ) SetHandle( anAttr->GetHandle() ); +} + +//======================================================================= +//function : Paste +//purpose : Paste value of current attribute to the value of entry one +//======================================================================= +void SALOMEDSImpl_StudyHandle::Paste( const Handle(TDF_Attribute)& theInto, + const Handle(TDF_RelocationTable)& ) const +{ + Handle(SALOMEDSImpl_StudyHandle) anAttr = Handle(SALOMEDSImpl_StudyHandle)::DownCast( theInto ); + if ( !anAttr.IsNull() ) anAttr->SetHandle( myHandle ); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.hxx new file mode 100644 index 000000000..7b60940c9 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.hxx @@ -0,0 +1,50 @@ +// File : SALOMEDSImpl_StudyHandle.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef SALOMEDSImpl_StudyHandle_HeaderFile +#define SALOMEDSImpl_StudyHandle_HeaderFile + +#include +#include +#include + +class Standard_GUID; +class Handle(TDF_Attribute); +class Handle(TDF_RelocationTable); + +/* + Class : SALOMEDSImpl_StudyHandle + Description : PRIVATE: This class is intended for storing of the study handle +*/ + +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_StudyHandle, TDF_Attribute ) + +#include "SALOMEDSImpl_Study.hxx" + +class Standard_EXPORT SALOMEDSImpl_StudyHandle : public TDF_Attribute +{ + +public: + SALOMEDSImpl_StudyHandle(); + ~SALOMEDSImpl_StudyHandle() { myHandle.Nullify(); } + + static Handle(SALOMEDSImpl_StudyHandle) Set(const TDF_Label& theLabel, const Handle(SALOMEDSImpl_Study)& theStudy); + static const Standard_GUID& GetID() ; + + void SetHandle(const Handle(SALOMEDSImpl_Study)& theStudy) { myHandle = theStudy; } + Handle(SALOMEDSImpl_Study) GetHandle() { return myHandle; } + const Standard_GUID& ID() const; + void Restore( const Handle(TDF_Attribute)& theWith ); + Handle(TDF_Attribute) NewEmpty() const; + void Paste( const Handle(TDF_Attribute)& theInto, + const Handle(TDF_RelocationTable)& ) const; + +private: + Handle(SALOMEDSImpl_Study) myHandle; + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_StudyHandle ) +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx new file mode 100644 index 000000000..ef3b6e8a1 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -0,0 +1,1254 @@ +// File : SALOMEDSImpl_StudyManager.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; + +#include "SALOMEDSImpl_StudyManager.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "HDFexplorer.hxx" + +#include "SALOMEDSImpl_Attributes.hxx" +#include "SALOMEDSImpl_Tool.hxx" +#include "SALOMEDSImpl_SComponent.hxx" +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_StudyManager, MMgt_TShared ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_StudyManager, MMgt_TShared ) + +#define USE_CASE_LABEL_ID "0:2" +#define AUTO_SAVE_GUID "128268A3-71C9-4036-89B1-F81BD6A4FCF2" +#define AUTO_SAVE_TAG "0:8" +#define AUTO_SAVE_TIME_OUT_IN_SECONDS 1200 + +static void SaveAttributes(Handle(SALOMEDSImpl_SObject) SO, HDFgroup *hdf_group_sobject); +static void ReadAttributes(const Handle(SALOMEDSImpl_Study)&, const Handle(SALOMEDSImpl_SObject)&, HDFdataset* ); +static void BuildTree (const Handle(SALOMEDSImpl_Study)&, HDFgroup*); +static void Translate_IOR_to_persistentID (const Handle(SALOMEDSImpl_SObject)&, + SALOMEDSImpl_Driver*, bool isMultiFile, bool isASCII); + +//============================================================================ +/*! Function : SALOMEDSImpl_StudyManager + * Purpose : SALOMEDSImpl_StudyManager constructor + */ +//============================================================================ +SALOMEDSImpl_StudyManager::SALOMEDSImpl_StudyManager() +{ + _errorCode = ""; + _OCAFApp = new SALOMEDSImpl_OCAFApplication(); + _IDcounter = 0; + _OCAFApp->NewDocument("SALOME_STUDY", _clipboard); +} + +//============================================================================ +/*! Function : ~SALOMEDSImpl_StudyManager + * Purpose : SALOMEDSImpl_StudyManager destructor + */ +//============================================================================ +SALOMEDSImpl_StudyManager::~SALOMEDSImpl_StudyManager() +{ + // Destroy OCAF application + _OCAFApp.Nullify(); +} + + +//============================================================================ +/*! Function : NewStudy + * Purpose : Create a New Study of name study_name + */ +//==================================================T========================== +Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::NewStudy(const TCollection_AsciiString& study_name) +{ + _errorCode = ""; + + Handle(TDocStd_Document) Doc; + _OCAFApp->NewDocument("SALOME_STUDY",Doc); + + Handle(SALOMEDSImpl_Study) Study = new SALOMEDSImpl_Study(Doc, study_name); + + _IDcounter++; + Study->StudyId( _IDcounter ); + + // set Study properties + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Study->GetProperties(); + OSD_Process aProcess; + Quantity_Date aDate = aProcess.SystemDate(); + aProp->SetModificationDate(aDate.Minute(), aDate.Hour(), aDate.Day(), aDate.Month(), aDate.Year()); + aProp->SetCreationMode(1); //"from scratch" + aProp->SetUserName(aProcess.UserName().ToCString()); + + return Study; +} + +//============================================================================ +/*! Function : Open + * Purpose : Open a Study from it's persistent reference + */ +//============================================================================ +Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::Open(const TCollection_AsciiString& aUrl) +{ + _errorCode = ""; + + // open the HDFFile + HDFfile *hdf_file =0; + HDFgroup *hdf_group_study_structure =0; + + char* aC_HDFUrl; + TCollection_AsciiString aHDFUrl; + bool isASCII = false; + if (HDFascii::isASCII(aUrl.ToCString())) { + isASCII = true; + char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aUrl.ToCString()); + aC_HDFUrl = new char[strlen(aResultPath) + 19]; + sprintf(aC_HDFUrl, "%shdf_from_ascii.hdf", aResultPath); + delete(aResultPath); + aHDFUrl = aC_HDFUrl; + delete aC_HDFUrl; + } else { + aHDFUrl = aUrl; + } + + hdf_file = new HDFfile((char*)aHDFUrl.ToCString()); + try { + hdf_file->OpenOnDisk(HDF_RDONLY);// mpv: was RDWR, but opened file can be write-protected too + } + catch (HDFexception) + { + char eStr[strlen(aUrl.ToCString())+17]; + sprintf(eStr,"Can't open file %s",aUrl.ToCString()); + _errorCode = TCollection_AsciiString(eStr); + return NULL; + } + + // Temporary aStudyUrl in place of study name + Handle(TDocStd_Document) Doc; + _OCAFApp->NewDocument("SALOME_STUDY",Doc); + + Handle(SALOMEDSImpl_Study) Study = new SALOMEDSImpl_Study(Doc, aUrl); + + _IDcounter++; + Study->StudyId( _IDcounter ); + + // Assign the value of the URL in the study object + Study->URL (aUrl); + + SALOMEDSImpl_AttributePersistentRef::Set(Doc->Main(), aUrl); + + if (!hdf_file->ExistInternalObject("STUDY_STRUCTURE")) { + _errorCode = "Study is empty"; + return Study; + } + + //Create the Structure of the OCAF Document + hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file); + + Handle(TDF_Data) DF = Doc->GetData(); + try { + BuildTree (Study, hdf_group_study_structure); + } + catch (HDFexception) + { + char eStr[strlen(aUrl.ToCString())+17]; + sprintf(eStr,"Can't open file %s", aUrl.ToCString()); + _errorCode = TCollection_AsciiString(eStr); + return NULL; + } + + hdf_file->CloseOnDisk(); + + if (isASCII) { + Handle(TColStd_HSequenceOfAsciiString) aFilesToRemove = new TColStd_HSequenceOfAsciiString; + aFilesToRemove->Append(aHDFUrl); + SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true); + } + + delete hdf_file; // all related hdf objects will be deleted + + return Study; +} + + + +//============================================================================ +/*! Function : Close + * Purpose : Close a study. + * If the study hasn't been saved, ask the user to confirm the + * close action without saving + */ + +//============================================================================ +void SALOMEDSImpl_StudyManager::Close(const Handle(SALOMEDSImpl_Study)& aStudy) +{ + _errorCode = ""; + + if(aStudy.IsNull()) { + _errorCode = "Study is null"; + return; + } + + aStudy->Close(); +} + +//============================================================================ +/*! Function : Save + * Purpose : Save a Study to it's persistent reference + */ +//============================================================================ +bool SALOMEDSImpl_StudyManager::Save(const Handle(SALOMEDSImpl_Study)& aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile) +{ + _errorCode = ""; + + TCollection_AsciiString url = aStudy->URL(); + if (url.IsEmpty()) { + _errorCode = "No path specified to save the study. Nothing done"; + return false; + } + else { + return Impl_SaveAs(url,aStudy, aFactory, theMultiFile, false); + } + + return false; +} + +bool SALOMEDSImpl_StudyManager::SaveASCII(const Handle(SALOMEDSImpl_Study)& aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile) +{ + _errorCode = ""; + + TCollection_AsciiString url = aStudy->URL(); + if (url.IsEmpty()) { + _errorCode = "No path specified to save the study. Nothing done"; + return false; + } + else { + return Impl_SaveAs(url,aStudy, aFactory, theMultiFile, true); + } + + return false; +} + +//============================================================================= +/*! Function : SaveAs + * Purpose : Save a study to the persistent reference aUrl + */ +//============================================================================ +bool SALOMEDSImpl_StudyManager::SaveAs(const TCollection_AsciiString& aUrl, + const Handle(SALOMEDSImpl_Study)& aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile) +{ + _errorCode = ""; + return Impl_SaveAs(aUrl,aStudy, aFactory, theMultiFile, false); +} + +bool SALOMEDSImpl_StudyManager::SaveAsASCII(const TCollection_AsciiString& aUrl, + const Handle(SALOMEDSImpl_Study)& aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile) +{ + _errorCode = ""; + return Impl_SaveAs(aUrl,aStudy, aFactory, theMultiFile, true); +} + +//============================================================================ +/*! Function : GetOpenStudies + * Purpose : Get name list of open studies in the session + */ +//============================================================================ +Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_StudyManager::GetOpenStudies() +{ + _errorCode = ""; + Handle(TColStd_HSequenceOfTransient) aList = new TColStd_HSequenceOfTransient; + + int nbDocs = _OCAFApp->NbDocuments(); + + if(nbDocs == 0) { + _errorCode = "No active study in this session"; + return aList; + } + else { + Handle(SALOMEDSImpl_Study) aStudy; + Handle(CDF_Session) S = CDF_Session::CurrentSession(); + CDF_DirectoryIterator it (S->Directory()); + for (;it.MoreDocument();it.NextDocument()) { + Handle(TDocStd_Document) D = Handle(TDocStd_Document)::DownCast(it.Document()); + if(D == _clipboard) continue; + aStudy = SALOMEDSImpl_Study::GetStudy(D->Main()); + if(aStudy.IsNull()) continue; + aList->Append(aStudy); + } + } + + return aList; +} + +//============================================================================ +/*! Function : GetStudyByName + * Purpose : Get a study from its name + */ +//============================================================================ +Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByName(const TCollection_AsciiString& aStudyName) +{ + _errorCode = ""; + + Handle(SALOMEDSImpl_Study) aStudy; + int nbDocs = _OCAFApp->NbDocuments(); + + if(nbDocs == 0) { + _errorCode = "No active study in this session"; + return aStudy; + } + else { + Handle(CDF_Session) S = CDF_Session::CurrentSession(); + CDF_DirectoryIterator it (S->Directory()); + for (;it.MoreDocument();it.NextDocument()) { + Handle(TDocStd_Document) D = Handle(TDocStd_Document)::DownCast(it.Document()); + if(D == _clipboard) continue; + aStudy = SALOMEDSImpl_Study::GetStudy(D->Main()); + if(aStudy.IsNull()) continue; + if(aStudy->Name() == aStudyName) return aStudy; + } + } + + _errorCode = TCollection_AsciiString("Found no study with the name ")+aStudyName; + return aStudy; +} + +//============================================================================ +/*! Function : GetStudyByID + * Purpose : Get a study from its ID + */ +//============================================================================ +Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByID(int aStudyID) +{ + _errorCode = ""; + Handle(SALOMEDSImpl_Study) aStudy; + int nbDocs = _OCAFApp->NbDocuments(); + + if(nbDocs == 0) { + _errorCode = "No active study in this session"; + return aStudy; + } + else { + Handle(CDF_Session) S = CDF_Session::CurrentSession(); + CDF_DirectoryIterator it (S->Directory()); + for (;it.MoreDocument();it.NextDocument()) { + Handle(TDocStd_Document) D = Handle(TDocStd_Document)::DownCast(it.Document()); + if(D == _clipboard) continue; + aStudy = SALOMEDSImpl_Study::GetStudy(D->Main()); + if(aStudy.IsNull()) continue; + if(aStudy->StudyId() == aStudyID) return aStudy; + } + } + + _errorCode = "Found no study with the given ID"; + return aStudy; +} + +//============================================================================= +/*! Function : _SaveProperties + * Purpose : save the study properties in HDF file + */ +//============================================================================ +bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(const Handle(SALOMEDSImpl_Study)& aStudy, HDFgroup *hdf_group) +{ + _errorCode = ""; + + HDFdataset *hdf_dataset = 0; + hdf_size size[1]; + hdf_int32 name_len; + + // add modifications list (user and date of save) + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = aStudy->GetProperties(); + Handle(SALOMEDSImpl_StudyBuilder) SB= aStudy->NewBuilder(); + int aLocked = aProp->IsLocked(); + if (aLocked) aProp->SetLocked(Standard_False); + + OSD_Process aProcess; + Quantity_Date aDate = aProcess.SystemDate(); + aProp->SetUserName(aProcess.UserName().ToCString()); + aProp->SetModificationDate(aDate.Minute(), aDate.Hour(), aDate.Day(), aDate.Month(), aDate.Year()); + + if (aLocked) aProp->SetLocked(Standard_True); + + Handle(TColStd_HSequenceOfExtendedString) aNames; + Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; + + aNames = aProp->GetUserNames(); + aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + + int aLength = 0, anIndex, i; + for(i=1; i<=aNames->Length(); i++) + aLength += aNames->Value(i).Length() + 1; + + //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, "zero" byte + char* aProperty = new char[3 + aLength + 12 * aNames->Length()]; + + + sprintf(aProperty,"%c%c", (char)aProp->GetCreationMode(), (aProp->IsLocked())?'l':'u'); + + aLength = aNames->Length(); + int a = 2; + for(anIndex = 1; anIndex <= aLength; anIndex++) { + sprintf(&(aProperty[a]),"%2d%2d%2d%2d%4d%s", + (int)(aMinutes->Value(anIndex)), + (int)(aHours->Value(anIndex)), + (int)(aDays->Value(anIndex)), + (int)(aMonths->Value(anIndex)), + (int)(aYears->Value(anIndex)), + TCollection_AsciiString(aNames->Value(anIndex)).ToCString()); + a = strlen(aProperty); + aProperty[a++] = 1; + } + aProperty[a] = 0; + + name_len = (hdf_int32) a; + size[0] = name_len + 1 ; + hdf_dataset = new HDFdataset("AttributeStudyProperties",hdf_group,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(aProperty); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + delete [] aProperty; + + aProp->SetModified(0); + return true; +} + +//============================================================================= +/*! Function : _SaveAs + * Purpose : save the study in HDF file + */ +//============================================================================ +bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, + const Handle(SALOMEDSImpl_Study)& aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile, + bool theASCII) +{ + // HDF File will be composed of differents part : + // * For each ComponentDataType, all data created by the component + // Informations in data group hdf_group_datacomponent + // * Study Structure -> Exactly what is contained in OCAF document + // Informations in data group hdf_group_study_structure + + _errorCode = ""; + + HDFfile *hdf_file=0; + HDFgroup *hdf_group_study_structure =0; + HDFgroup *hdf_sco_group =0; + HDFgroup *hdf_sco_group2 =0; + + HDFgroup *hdf_group_datacomponent =0; + HDFdataset *hdf_dataset =0; + hdf_size size[1]; + hdf_int32 name_len = 0; + char *component_name = 0; + + int aLocked = aStudy->GetProperties()->IsLocked(); + if (aLocked) aStudy->GetProperties()->SetLocked(false); + + Handle(SALOMEDSImpl_StudyBuilder) SB= aStudy->NewBuilder(); + map aMapTypeDriver; + + if(aStudy.IsNull()) { + _errorCode = "Study is null"; + return false; + } + + try + { + // mpv 15.12.2003: for saving components we have to load all data from all modules + SALOMEDSImpl_SComponentIterator itcomponent1 = aStudy->NewComponentIterator(); + for (; itcomponent1.More(); itcomponent1.Next()) + { + Handle(SALOMEDSImpl_SComponent) sco = itcomponent1.Value(); + + // if there is an associated Engine call its method for saving + TCollection_AsciiString IOREngine; + try { + if (!sco->ComponentIOR(IOREngine)) { + TCollection_AsciiString aCompType = sco->GetComment(); + if (!aCompType.IsEmpty()) { + + SALOMEDSImpl_Driver* aDriver = aFactory->GetDriverByType(aCompType); + aMapTypeDriver[aCompType.ToCString()] = aDriver; + + if (aDriver != NULL) { + if(!SB->LoadWith(sco, aDriver)) { + _errorCode = SB->GetErrorCode(); + return false; + } + } + } + } + } catch(...) { + _errorCode = "Can not restore information to resave it"; + return false; + } + } + + TCollection_AsciiString anOldName = aStudy->Name(); + aStudy->URL(aUrl); + + // To change for Save + // Do not have to do a new file but just a Open??? Rewrite all informations after erasing evrything?? + hdf_file = new HDFfile(aUrl.ToCString()); + hdf_file->CreateOnDisk(); + + //----------------------------------------------------------------------- + // 1 - Create a groupe for each SComponent and Update the PersistanceRef + //----------------------------------------------------------------------- + hdf_group_datacomponent = new HDFgroup("DATACOMPONENT",hdf_file); + hdf_group_datacomponent->CreateOnDisk(); + + SALOMEDSImpl_SComponentIterator itcomponent = aStudy->NewComponentIterator(); + + //SRN: Added 17 Nov, 2003 + Handle(SALOMEDSImpl_SObject) anAutoSaveSO = aStudy->FindObjectID(AUTO_SAVE_TAG); + //SRN: End + for (; itcomponent.More(); itcomponent.Next()) + { + Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value(); + + TCollection_AsciiString scoid = sco->GetID(); + hdf_sco_group = new HDFgroup(scoid.ToCString(), hdf_group_datacomponent); + hdf_sco_group->CreateOnDisk(); + + TCollection_AsciiString componentDataType = sco->ComponentDataType(); + + //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save + if(!anAutoSaveSO.IsNull() && SB->IsGUID(sco, AUTO_SAVE_GUID)) { + + Handle(SALOMEDSImpl_AttributeTableOfString) aTable; + if(anAutoSaveSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeTableOfString::GetID(), aTable)) { + Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0; + if(nbRows > 0 && aTable->GetNbColumns() > 1) { + + Handle(TColStd_HSequenceOfExtendedString) aRow; + for(k=1; k<=nbRows; k++) { + aRow = aTable->GetRowData(k); + if (aRow->Value(1) == componentDataType) { + TCollection_AsciiString anEntry = TCollection_AsciiString(aRow->Value(2)); + Handle(SALOMEDSImpl_SObject) aCompSpecificSO = aStudy->FindObjectID(anEntry); + if(!aCompSpecificSO.IsNull()) { + Handle(SALOMEDSImpl_AttributeInteger) anInteger; + if(aCompSpecificSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anInteger)) { + anInteger->Set(-1); + while(anInteger->Get() < 0) { sleep(2); if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS) break; } + } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger")) + } // if(!CORBA::is_nil(aCompSpecificSO)) + } // if (strcmp(aRow[0], componentDataType) == 0) + } // for + + } // if(nbRows > 0 && aTable->GetNbColumns() > 1) + + } // if(anAutoSaveSO->FindAttribute(aTable, "AttributeTableOfString") + + } // if(SB->IsGUID(AUTO_SAVE_GUID) + + //SRN: End + TCollection_AsciiString IOREngine; + if (sco->ComponentIOR(IOREngine)) + { + SALOMEDSImpl_Driver* Engine = NULL; + if(aMapTypeDriver.find(componentDataType.ToCString()) != aMapTypeDriver.end()) { + // we have found the associated engine to write the data + Engine = aMapTypeDriver[componentDataType.ToCString()]; + } + else { + Engine = aFactory->GetDriverByIOR(IOREngine); + } + + if (Engine != NULL) + { + unsigned char* aStream; + long length; + + if (theASCII) aStream = Engine->SaveASCII(sco, + SALOMEDSImpl_Tool::GetDirFromPath(aUrl), + length, + theMultiFile); + else aStream = Engine->Save(sco, + SALOMEDSImpl_Tool::GetDirFromPath(aUrl), + length, + theMultiFile); + HDFdataset *hdf_dataset; + hdf_size aHDFSize[1]; + if(length > 0) { //The component saved some auxiliary files, then put them into HDF file + + aHDFSize[0] = length; + + HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(aStream); //Save the stream in the HDF file + hdf_dataset->CloseOnDisk(); + } + + // store multifile state + aHDFSize[0] = 2; + hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((void*)(theMultiFile?"M":"S")); // save: multi or single + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor + // store ASCII state + aHDFSize[0] = 2; + hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((void*)(theASCII?"A":"B")); // save: ASCII or BINARY + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor + // Creation of the persistance reference attribute + Translate_IOR_to_persistentID (sco, Engine, theMultiFile, theASCII); + + if(aStream != NULL) delete [] aStream; + } + } + hdf_sco_group->CloseOnDisk(); + hdf_sco_group=0; // will be deleted by hdf_group_datacomponent destructor + } + hdf_group_datacomponent->CloseOnDisk(); + hdf_group_datacomponent =0; // will be deleted by hdf_file destructor + + //----------------------------------------------------------------------- + //3 - Write the Study Structure + //----------------------------------------------------------------------- + hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file); + hdf_group_study_structure->CreateOnDisk(); + // save component attributes + SALOMEDSImpl_SComponentIterator itcomp = aStudy->NewComponentIterator(); + for (; itcomp.More(); itcomp.Next()) + { + Handle(SALOMEDSImpl_SComponent) SC = itcomp.Value(); + TCollection_AsciiString scid = SC->GetID(); + hdf_sco_group2 = new HDFgroup(scid.ToCString(), hdf_group_study_structure); + hdf_sco_group2->CreateOnDisk(); + SaveAttributes(SC, hdf_sco_group2); + // ComponentDataType treatment + component_name = SC->ComponentDataType().ToCString(); + name_len = (hdf_int32)strlen(component_name); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(component_name); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + Impl_SaveObject(SC, hdf_sco_group2); + hdf_sco_group2->CloseOnDisk(); + hdf_sco_group2=0; // will be deleted by hdf_group_study_structure destructor + } + + //----------------------------------------------------------------------- + //4 - Write the Study UseCases Structure + //----------------------------------------------------------------------- + Handle(SALOMEDSImpl_SObject) aSO = aStudy->FindObjectID(USE_CASE_LABEL_ID); + if (!aSO.IsNull()) { + HDFgroup *hdf_soo_group = new HDFgroup(USE_CASE_LABEL_ID,hdf_group_study_structure); + hdf_soo_group->CreateOnDisk(); + SaveAttributes(aSO, hdf_soo_group); + Impl_SaveObject(aSO, hdf_soo_group); + hdf_soo_group->CloseOnDisk(); + hdf_soo_group=0; // will be deleted by hdf_group_study_structure destructor + } + + if (aLocked) aStudy->GetProperties()->SetLocked(true); + //----------------------------------------------------------------------- + //5 - Write the Study Properties + //----------------------------------------------------------------------- + name_len = (hdf_int32) aStudy->Name().Length(); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("STUDY_NAME",hdf_group_study_structure,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + char* studid = aStudy->Name().ToCString(); + hdf_dataset->WriteOnDisk(studid); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; // will be deleted by hdf_group_study_structure destructor + + Impl_SaveProperties(aStudy, hdf_group_study_structure); + + hdf_group_study_structure->CloseOnDisk(); + hdf_file->CloseOnDisk(); + + aStudy->IsSaved(true); + hdf_group_study_structure =0; // will be deleted by hdf_file destructor + delete hdf_file; // recursively deletes all hdf objects... + } + catch (HDFexception) + { + _errorCode = "HDFexception ! "; + return false; + } + if (theASCII) { // save file in ASCII format + HDFascii::ConvertFromHDFToASCII(aUrl.ToCString(), true); + } + + return true; +} + +//============================================================================ +/*! Function : Impl_SaveObject + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyManager::Impl_SaveObject(const Handle(SALOMEDSImpl_SObject)& SC, + HDFgroup *hdf_group_datatype) +{ + _errorCode = ""; + + // Write in group hdf_group_datatype all informations of SObject SC + // Iterative function to parse all SObjects under a SComponent + + HDFgroup *hdf_group_sobject = 0; + + TDF_ChildIterator itchild(SC->GetLabel()); + for (; itchild.More(); itchild.Next()) + { + + // mpv: don't save empty labels + TDF_AttributeIterator AI1(itchild.Value()); + if (!AI1.More()) { //No attributes on the label + TDF_ChildIterator subchild(SC->GetLabel()); + if (!subchild.More()) { + continue; + } + subchild.Initialize(SC->GetLabel(), true); + bool anEmpty = true; + for (; subchild.More() && anEmpty; subchild.Next()) { + TDF_AttributeIterator AI2(subchild.Value()); + if (AI2.More()) anEmpty = false; //There are attributes on the child label + } + if (anEmpty) continue; + } + + Handle(SALOMEDSImpl_SObject) SO = new SALOMEDSImpl_SObject(itchild.Value()); + + char* scoid = (char*) SO->GetID().ToCString(); + hdf_group_sobject = new HDFgroup(scoid, hdf_group_datatype); + hdf_group_sobject->CreateOnDisk(); + SaveAttributes(SO, hdf_group_sobject); + Impl_SaveObject(SO, hdf_group_sobject); + hdf_group_sobject->CloseOnDisk(); + hdf_group_sobject =0; // will be deleted by father hdf object destructor + } + + return true; +} + +//============================================================================ +/*! Function : Impl_SubstituteSlash + * Purpose : + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_StudyManager::Impl_SubstituteSlash(const TCollection_AsciiString& aUrl) +{ + _errorCode = ""; + + TCollection_ExtendedString theUrl(aUrl); + Standard_ExtCharacter val1 = ToExtCharacter('/'); + Standard_ExtCharacter val2 = ToExtCharacter(':'); + theUrl.ChangeAll(val1,val2); + return theUrl; +} + +//============================================================================ +/*! Function : GetDocumentOfStudy + * Purpose : + */ +//============================================================================ +Handle(TDocStd_Document) SALOMEDSImpl_StudyManager::GetDocumentOfStudy(const Handle(SALOMEDSImpl_Study)& theStudy) +{ + _errorCode = ""; + return theStudy->_doc; +} + +//============================================================================ +/*! Function : CanCopy + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyManager::CanCopy(const Handle(SALOMEDSImpl_SObject)& theObject, + SALOMEDSImpl_Driver* theEngine) +{ + _errorCode = ""; + + Handle(SALOMEDSImpl_SComponent) aComponent = theObject->GetFatherComponent(); + if (aComponent.IsNull()) return false; + if (aComponent->GetLabel() == theObject->GetLabel()) return false; + + TCollection_AsciiString IOREngine; + if (!aComponent->ComponentIOR(IOREngine)) return false; + + if (theEngine == NULL) return false; + return theEngine->CanCopy(theObject); +} + +//============================================================================ +/*! Function : CopyLabel + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyManager::CopyLabel(const Handle(SALOMEDSImpl_Study)& theSourceStudy, + SALOMEDSImpl_Driver* theEngine, + const Standard_Integer theSourceStartDepth, + const TDF_Label& theSource, + const TDF_Label& theDestinationMain) +{ + _errorCode = ""; + + int a; + TDF_Label aTargetLabel = theDestinationMain; + TDF_Label aAuxTargetLabel = theDestinationMain.Father().FindChild(2); + for(a = theSource.Depth() - theSourceStartDepth; a > 0 ; a--) { + TDF_Label aSourceLabel = theSource; + for(int aNbFather = 1; aNbFather < a; aNbFather++) aSourceLabel = aSourceLabel.Father(); + aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag()); + aAuxTargetLabel = aAuxTargetLabel.FindChild(aSourceLabel.Tag()); + } + // iterate attributes + TDF_AttributeIterator anAttrIterator(theSource); + Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable(); + for(; anAttrIterator.More(); anAttrIterator.Next()) { + Handle(TDF_Attribute) anAttr = anAttrIterator.Value(); + if (!Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(anAttr).IsNull()) continue; // never copy tree node attribute + if (!Handle(SALOMEDSImpl_AttributeTarget)::DownCast(anAttr).IsNull()) continue; // and target attribute + + if (!Handle(SALOMEDSImpl_AttributeReference)::DownCast(anAttr).IsNull()) { // reference copied as Comment in aux tree + TDF_Label aReferenced = Handle(SALOMEDSImpl_AttributeReference)::DownCast(anAttr)->Get(); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(aReferenced, anEntry); + // store the value of name attribute of referenced label + Handle(SALOMEDSImpl_AttributeName) aNameAttribute; + if (aReferenced.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aNameAttribute)) { + anEntry += " "; + anEntry += aNameAttribute->Get(); + } + SALOMEDSImpl_AttributeComment::Set(aAuxTargetLabel, TCollection_ExtendedString(anEntry)); + continue; + } + + if (!Handle(SALOMEDSImpl_AttributeIOR)::DownCast(anAttr).IsNull()) { // IOR => ID and TMPFile of Engine + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theSource, anEntry); + Handle(SALOMEDSImpl_SObject) aSO = theSourceStudy->FindObjectID(anEntry.ToCString()); + int anObjID; + long aLen; + unsigned char* aStream = theEngine->CopyFrom(aSO, anObjID, aLen); + TCollection_ExtendedString aResStr(""); + for(a = 0; a < aLen; a++) { + aResStr += TCollection_ExtendedString(ToExtCharacter((Standard_Character)aStream[a])); + } + if(aStream != NULL) delete [] aStream; + SALOMEDSImpl_AttributeInteger::Set(aAuxTargetLabel, anObjID); + SALOMEDSImpl_AttributeName::Set(aAuxTargetLabel, aResStr); + continue; + } + Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty(); + aTargetLabel.AddAttribute(aNewAttribute); + anAttr->Paste(aNewAttribute, aRT); + } + + return true; +} + +//============================================================================ +/*! Function : Copy + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyManager::Copy(const Handle(SALOMEDSImpl_SObject)& theObject, + SALOMEDSImpl_Driver* theEngine) +{ + _errorCode = ""; + + // adoptation for alliances datamodel copy: without IOR attributes !!! + bool aStructureOnly; // copy only SObjects and attributes without component help + aStructureOnly = !theObject->GetLabel().IsAttribute(SALOMEDSImpl_AttributeIOR::GetID()); + + // get component-engine + Handle(SALOMEDSImpl_Study) aStudy = theObject->GetStudy(); + + // CAF document of current study usage + Handle(TDocStd_Document) aDocument = GetDocumentOfStudy(aStudy); + if (aDocument.IsNull()) { + _errorCode = "OCAF document is null"; + return false; + } + + //Clear the clipboard + _clipboard->Main().Root().ForgetAllAttributes(Standard_True); + + // set component data type to the name attribute of root label + if (!aStructureOnly) { + SALOMEDSImpl_AttributeComment::Set(_clipboard->Main().Root(), + TCollection_ExtendedString(theEngine->ComponentDataType())); + } + // set to the Root label integer attribute: study id + SALOMEDSImpl_AttributeInteger::Set(_clipboard->Main().Root(), aStudy->StudyId()); + // iterate all theObject's label children + TDF_Label aStartLabel = theObject->GetLabel(); + Standard_Integer aSourceStartDepth = aStartLabel.Depth(); + + // copy main source label + CopyLabel(aStudy, theEngine, aSourceStartDepth, aStartLabel, _clipboard->Main()); + + // copy all subchildren of the main source label (all levels) + TDF_ChildIterator anIterator(aStartLabel, Standard_True); + for(; anIterator.More(); anIterator.Next()) { + CopyLabel(aStudy, theEngine, aSourceStartDepth, anIterator.Value(), _clipboard->Main()); + } + + return true; +} +//============================================================================ +/*! Function : CanPaste + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_StudyManager::CanPaste(const Handle(SALOMEDSImpl_SObject)& theObject, + SALOMEDSImpl_Driver* theEngine) +{ + _errorCode = ""; + + if (_clipboard.IsNull()) { + _errorCode = "Clipboard is null"; + return false; + } + + Handle(SALOMEDSImpl_AttributeComment) aCompName; + if (!_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aCompName)) { + _errorCode = "Clipboard has no component type"; + return false; + } + Handle(SALOMEDSImpl_AttributeInteger) anObjID; + if (!_clipboard->Main().Father().FindChild(2).FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anObjID)) { + _errorCode = "Clipboard has no object id"; + return false; + } + Handle(SALOMEDSImpl_SComponent) aComponent = theObject->GetFatherComponent(); + if (aComponent.IsNull()) { + _errorCode = "Object doesn't belong to component"; + return false; + } + + TCollection_AsciiString IOREngine; + if (!aComponent->ComponentIOR(IOREngine)) { + _errorCode = "component has no IOR"; + return false; + } + return theEngine->CanPaste(aCompName->Get(), anObjID->Get()); +} + +//============================================================================ +/*! Function : PasteLabel + * Purpose : + */ +//============================================================================ +TDF_Label SALOMEDSImpl_StudyManager::PasteLabel(const Handle(SALOMEDSImpl_Study)& theDestinationStudy, + SALOMEDSImpl_Driver* theEngine, + const TDF_Label& theSource, + const TDF_Label& theDestinationStart, + const int theCopiedStudyID, + const bool isFirstElement) +{ + _errorCode = ""; + + // get corresponding source, target and auxiliary labels + TDF_Label aTargetLabel = theDestinationStart; + + TDF_Label aAuxSourceLabel = theSource.Root().FindChild(2); + int a; + if (!isFirstElement) { + for(a = theSource.Depth() - 1; a > 0 ; a--) { + TDF_Label aSourceLabel = theSource; + for(int aNbFather = 1; aNbFather < a; aNbFather++) aSourceLabel = aSourceLabel.Father(); + aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag()); + aAuxSourceLabel = aAuxSourceLabel.FindChild(aSourceLabel.Tag()); + } + } + + // check auxiliary label for TMPFile => IOR + Handle(SALOMEDSImpl_AttributeName) aNameAttribute; + if (aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aNameAttribute)) { + Handle(SALOMEDSImpl_AttributeInteger) anObjID; + + aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anObjID); + Handle(SALOMEDSImpl_AttributeComment) aComponentName; + theSource.Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aComponentName); + TCollection_AsciiString aCompName = aComponentName->Get(); + + if (theEngine->CanPaste(aCompName, anObjID->Get())) { + TCollection_ExtendedString aTMPStr = aNameAttribute->Get(); + int aLen = aTMPStr.Length(); + unsigned char* aStream = NULL; + if(aLen > 0) { + aStream = new unsigned char[aLen+10]; + for(a = 0; a < aLen; a++) { + aStream[a] = ToCharacter(aTMPStr.Value(a+1)); + } + } + + TCollection_AsciiString anEntry; + TDF_Tool::Entry(aTargetLabel, anEntry); + Handle(SALOMEDSImpl_SObject) aPastedSO = theDestinationStudy->FindObjectID(anEntry); + + if (isFirstElement) { + TCollection_AsciiString aDestEntry = theEngine->PasteInto(aStream, + aLen, + anObjID->Get(), + aPastedSO->GetFatherComponent()); + TDF_Tool::Label(theDestinationStart.Data(), aDestEntry, aTargetLabel); + } else + theEngine->PasteInto(aStream, aLen, anObjID->Get(), aPastedSO); + + if(aStream != NULL) delete []aStream; + } + } + + // iterate attributes + TDF_AttributeIterator anAttrIterator(theSource); + Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable(); + for(; anAttrIterator.More(); anAttrIterator.Next()) { + Handle(TDF_Attribute) anAttr = anAttrIterator.Value(); + if (aTargetLabel.FindAttribute(anAttr->ID(), anAttr)) { + aTargetLabel.ForgetAttribute(anAttr->ID()); + anAttr = anAttrIterator.Value(); + } + Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty(); + aTargetLabel.AddAttribute(aNewAttribute); + anAttr->Paste(aNewAttribute, aRT); + } + + // check auxiliary label for Comment => reference or name attribute of the referenced object + Handle(SALOMEDSImpl_AttributeComment) aCommentAttribute; + if (aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aCommentAttribute)) { + char * anEntry = new char[aCommentAttribute->Get().Length() + 1]; + strcpy(anEntry, TCollection_AsciiString(aCommentAttribute->Get()).ToCString()); + char* aNameStart = strchr(anEntry, ' '); + if (aNameStart) { + *aNameStart = '\0'; + aNameStart++; + } + if (theCopiedStudyID == theDestinationStudy->StudyId()) { // if copy to the same study, reanimate reference + TDF_Label aRefLabel; + TDF_Tool::Label(aTargetLabel.Data(), anEntry, aRefLabel); + SALOMEDSImpl_AttributeReference::Set(aTargetLabel, aRefLabel); + SALOMEDSImpl_AttributeTarget::Set(aRefLabel)->Append(aTargetLabel); // target attributes structure support + } else { + if (aNameStart) SALOMEDSImpl_AttributeName::Set(aTargetLabel, aNameStart); + else SALOMEDSImpl_AttributeName::Set(aTargetLabel, TCollection_ExtendedString("Reference to:")+anEntry); + } + delete [] anEntry; + } + + return aTargetLabel; +} + +//============================================================================ +/*! Function : Paste + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_StudyManager::Paste(const Handle(SALOMEDSImpl_SObject)& theObject, + SALOMEDSImpl_Driver* theEngine) +{ + _errorCode = ""; + + Handle(SALOMEDSImpl_Study) aStudy = theObject->GetStudy(); + + // if study is locked, then paste can't be done + if (aStudy->GetProperties()->IsLocked()) { + _errorCode = "LockProtection"; + throw LockProtection("LockProtection"); + } + + // if there is no component name, then paste only SObjects and attributes: without component help + Handle(SALOMEDSImpl_AttributeComment) aComponentName; + bool aStructureOnly = !_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aComponentName); + + // get copied study ID + Handle(SALOMEDSImpl_AttributeInteger) aStudyIDAttribute; + if (!_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), aStudyIDAttribute)) { + _errorCode = "No study ID was found"; + return NULL; + } + int aCStudyID = aStudyIDAttribute->Get(); + + // CAF document of current study usage + Handle(TDocStd_Document) aDocument = GetDocumentOfStudy(aStudy); + if (aDocument.IsNull()) { + _errorCode = "OCAF document is null"; + return NULL; + } + + Handle(SALOMEDSImpl_SComponent) aComponent = theObject->GetFatherComponent(); + + // fill root inserted SObject + TDF_Label aStartLabel; + if (aStructureOnly) { + TDF_Label anObjectLabel; + TDF_Tool::Label(aDocument->GetData(), theObject->GetID(), anObjectLabel); + aStartLabel = PasteLabel(aStudy, theEngine, _clipboard->Main(), anObjectLabel, aCStudyID, false); + } else { + TDF_Label aComponentLabel; + TDF_Tool::Label(aDocument->GetData(), aComponent->GetID(), aComponentLabel); + aStartLabel = PasteLabel(aStudy, theEngine, _clipboard->Main(), aComponentLabel, aCStudyID, true); + } + + // paste all sublebels + TDF_ChildIterator anIterator(_clipboard->Main(), Standard_True); + for(; anIterator.More(); anIterator.Next()) { + PasteLabel(aStudy, theEngine, anIterator.Value(), aStartLabel, aCStudyID, false); + } + + return new SALOMEDSImpl_SObject (aStartLabel); +} + +//####################################################################################################### +//# STATIC PRIVATE FUNCTIONS +//####################################################################################################### + +//============================================================================ +/*! Function : SaveAttributes + * Purpose : Save attributes for object + */ +//============================================================================ +static void SaveAttributes(Handle(SALOMEDSImpl_SObject) aSO, HDFgroup *hdf_group_sobject) +{ + hdf_size size[1]; + TDF_AttributeIterator Itr(aSO->GetLabel()); + Handle(TDF_Attribute) anAttr; + for(; Itr.More(); Itr.Next()) { + anAttr = Itr.Value(); + //The following attributes are not supposed to be written to the file + if(anAttr->DynamicType() == STANDARD_TYPE(SALOMEDSImpl_AttributeIOR)) continue; + if(anAttr->DynamicType() == STANDARD_TYPE(SALOMEDSImpl_AttributeExternalFileDef)) continue; + if(anAttr->DynamicType() == STANDARD_TYPE(SALOMEDSImpl_AttributeFileType)) continue; + Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(anAttr); + TCollection_AsciiString aSaveStr = ga->Save(); + //cout << "Saving: " << aSO->GetID() << " "<< ga->Type() << " value: " << aSaveStr << endl; + size[0] = (hdf_int32) strlen(aSaveStr.ToCString()) + 1; + HDFdataset *hdf_dataset = new HDFdataset((char*)ga->Type().ToCString(), hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((char*)aSaveStr.ToCString()); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } +} + +//=========================================================================== +//Function : ReadAttributes +//=========================================================================== +static void ReadAttributes(const Handle(SALOMEDSImpl_Study)& theStudy, + const Handle(SALOMEDSImpl_SObject)& aSO, + HDFdataset* hdf_dataset) +{ + hdf_dataset->OpenOnDisk(); + + Handle(TDF_Attribute) anAttr; + + char* current_string = new char[hdf_dataset->GetSize()]; + hdf_dataset->ReadFromDisk(current_string); + + if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) { + anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, "AttributeComment"); + } else if (!strcmp(hdf_dataset->GetName(),"AttributeReference")) { + theStudy->NewBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string)); + delete(current_string); + hdf_dataset->CloseOnDisk(); + return; + } else { + anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName()); + } + + if (!anAttr.IsNull()) { + + Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(anAttr); + ga->Load(current_string); + //cout << "Reading: " << aSO->GetID() << " "<< ga->Type() << " value: " << current_string << endl; + } + + delete(current_string); + hdf_dataset->CloseOnDisk(); +} + +//============================================================================ +//Function : BuildlTree +//============================================================================ +static void BuildTree (const Handle(SALOMEDSImpl_Study)& theStudy, HDFgroup* hdf_current_group) +{ + hdf_current_group->OpenOnDisk(); + Handle(SALOMEDSImpl_SObject) aSO; + char* Entry = hdf_current_group->GetName(); + if (strcmp(Entry,"STUDY_STRUCTURE") == 0) { + aSO = theStudy->CreateObjectID("0:1"); + } + else { + aSO = theStudy->CreateObjectID(Entry); + } + + char name[HDF_NAME_MAX_LEN+1]; + Standard_Integer nbsons = hdf_current_group->nInternalObjects(); + for (Standard_Integer i=0; iInternalObjectIndentify(i,name); + if (strncmp(name, "INTERNAL_COMPLEX",16) == 0) continue; + hdf_object_type type = hdf_current_group->InternalObjectType(name); + + if (type == HDF_DATASET) { + HDFdataset* new_dataset = new HDFdataset(name,hdf_current_group); + ReadAttributes(theStudy,aSO,new_dataset); + new_dataset = 0; // will be deleted by father destructor + + } + else if (type == HDF_GROUP) { + HDFgroup* new_group = new HDFgroup(name,hdf_current_group); + BuildTree (theStudy, new_group); + new_group = 0; // will be deleted by father destructor + } + } + hdf_current_group->CloseOnDisk(); +} + + +//============================================================================ +//Function : Translate_IOR_to_persistentID +//============================================================================ +static void Translate_IOR_to_persistentID (const Handle(SALOMEDSImpl_SObject)& so, + SALOMEDSImpl_Driver* engine, + bool isMultiFile, + bool isASCII) +{ + TDF_ChildIterator itchild(so->GetLabel()); + TCollection_AsciiString ior_string, persistent_string, curid; + + for (; itchild.More(); itchild.Next()) { + Handle(SALOMEDSImpl_SObject) current = new SALOMEDSImpl_SObject(itchild.Value()); + Handle(SALOMEDSImpl_AttributeIOR) IOR; + if (current->GetLabel().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), IOR)) { + ior_string = IOR->Value(); + + persistent_string = engine->IORToLocalPersistentID (current, ior_string, isMultiFile, isASCII); + SALOMEDSImpl_AttributePersistentRef::Set(current->GetLabel(), persistent_string); + } + Translate_IOR_to_persistentID (current, engine, isMultiFile, isASCII); + } +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx new file mode 100644 index 000000000..f838597c9 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx @@ -0,0 +1,132 @@ +// File : SALOMEDSImpl_StudyManager.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef __SALOMEDSImpl_STUDYMANAGER_I_H__ +#define __SALOMEDSImpl_STUDYMANAGER_I_H__ + +//Handle definition +#include +#include +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_StudyManager, MMgt_TShared ) + +// std C++ headers +#include + +// Cascade headers +#include "SALOMEDSImpl_OCAFApplication.hxx" +#include "SALOMEDSImpl_Study.hxx" +#include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_Driver.hxx" +#include +#include +#include +#include +#include + +// HDF +#include +#include "HDFOI.hxx" +#include + +class SALOMEDSImpl_StudyManager : public MMgt_TShared +{ + +private: + + Handle (SALOMEDSImpl_OCAFApplication) _OCAFApp; + int _IDcounter; + Handle(TDocStd_Document) _clipboard; + TCollection_AsciiString _errorCode; + +public: + + //! standard constructor + SALOMEDSImpl_StudyManager(); + + //! standard destructor + virtual ~SALOMEDSImpl_StudyManager(); + + //! method to Create a New Study of name study_name + virtual Handle(SALOMEDSImpl_Study) NewStudy(const TCollection_AsciiString& study_name); + + //! method to Open a Study from it's persistent reference + virtual Handle(SALOMEDSImpl_Study) Open(const TCollection_AsciiString& aStudyUrl); + + //! method to close a Study + virtual void Close(const Handle(SALOMEDSImpl_Study)& aStudy); + + //! method to save a Study + virtual bool Save(const Handle(SALOMEDSImpl_Study)& aStudy, SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile); + + virtual bool SaveASCII(const Handle(SALOMEDSImpl_Study)& aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile); + + //! method to save a Study to the persistent reference aUrl + virtual bool SaveAs(const TCollection_AsciiString& aUrl, + const Handle(SALOMEDSImpl_Study)& aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile); + + virtual bool SaveAsASCII(const TCollection_AsciiString& aUrl, + const Handle(SALOMEDSImpl_Study)& aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile); + + //! method to Get name list of open studies in the session + virtual Handle(TColStd_HSequenceOfTransient) GetOpenStudies(); + + //! method to get a Study from it's name + virtual Handle(SALOMEDSImpl_Study) GetStudyByName(const TCollection_AsciiString& aStudyName) ; + + //! method to get a Study from it's ID + virtual Handle(SALOMEDSImpl_Study) GetStudyByID(int aStudyID) ; + + + Handle(TDocStd_Document) GetDocumentOfStudy(const Handle(SALOMEDSImpl_Study)& theStudy); + + Handle(TDocStd_Document) GetClipboard() { return _clipboard; } + + bool CopyLabel(const Handle(SALOMEDSImpl_Study)& theSourceStudy, + SALOMEDSImpl_Driver* theEngine, + const int theSourceStartDepth, + const TDF_Label& theSource, + const TDF_Label& theDestinationMain); + + TDF_Label PasteLabel(const Handle(SALOMEDSImpl_Study)& theDestinationStudy, + SALOMEDSImpl_Driver* theEngine, + const TDF_Label& theSource, + const TDF_Label& theDestinationStart, + const int theCopiedStudyID, + const bool isFirstElement); + + virtual bool CanCopy(const Handle(SALOMEDSImpl_SObject)& theObject, SALOMEDSImpl_Driver* Engine); + virtual bool Copy(const Handle(SALOMEDSImpl_SObject)& theObject, SALOMEDSImpl_Driver* Engine); + virtual bool CanPaste(const Handle(SALOMEDSImpl_SObject)& theObject, SALOMEDSImpl_Driver* Engine); + virtual Handle(SALOMEDSImpl_SObject) Paste(const Handle(SALOMEDSImpl_SObject)& theObject, SALOMEDSImpl_Driver* Engine); + + // _SaveAs private function called by Save and SaveAs + virtual bool Impl_SaveAs(const TCollection_AsciiString& aUrl, + const Handle(SALOMEDSImpl_Study)& aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile, + bool theASCII); + + // _SaveObject private function called by _SaveAs + virtual bool Impl_SaveObject(const Handle(SALOMEDSImpl_SObject)& SC, HDFgroup *hdf_group_datatype); + + // _SubstituteSlash function called by Open and GetStudyByName + virtual TCollection_AsciiString Impl_SubstituteSlash(const TCollection_AsciiString& aUrl); + + virtual bool Impl_SaveProperties(const Handle(SALOMEDSImpl_Study)& aStudy, HDFgroup *hdf_group); + + TCollection_AsciiString GetErrorCode() { return _errorCode; } + virtual bool IsError() { return _errorCode != ""; } + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_StudyManager ) + +}; + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx new file mode 100644 index 000000000..4a823fd36 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx @@ -0,0 +1,150 @@ +using namespace std; +// File : SALOMEDSImpl_Tool.cxx +// Created : Mon Oct 21 16:24:34 2002 +// Author : Sergey RUIN + +// Project : SALOME +// Module : SALOMEDSImpl +// Copyright : Open CASCADE + +#include "SALOMEDSImpl_Tool.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +//============================================================================ +// function : GetTempDir +// purpose : Return a temp directory to store created files like "/tmp/sub_dir/" +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_Tool::GetTmpDir() +{ + //Find a temporary directory to store a file + + TCollection_AsciiString aTmpDir; + + char *Tmp_dir = getenv("SALOME_TMP_DIR"); + if(Tmp_dir != NULL) { + aTmpDir = TCollection_AsciiString(Tmp_dir); +#ifdef WIN32 + if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\'; +#else + if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/'; +#endif + } + else { +#ifdef WIN32 + aTmpDir = TCollection_AsciiString("C:\\"); +#else + aTmpDir = TCollection_AsciiString("/tmp/"); +#endif + } + + srand((unsigned int)time(NULL)); + int aRND = 999 + (int)(100000.0*rand()/(RAND_MAX+1.0)); //Get a random number to present a name of a sub directory + TCollection_AsciiString aSubDir(aRND); + if(aSubDir.Length() <= 1) aSubDir = TCollection_AsciiString("123409876"); + + aTmpDir += aSubDir; //Get RND sub directory + +#ifdef WIN32 + if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\'; +#else + if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/'; +#endif + + OSD_Path aPath(aTmpDir); + OSD_Directory aDir(aPath); + + for(aRND = 0; aDir.Exists(); aRND++) { + aTmpDir.Insert((aTmpDir.Length() - 1), TCollection_AsciiString(aRND)); //Build a unique directory name + aPath = OSD_Path(aTmpDir); + aDir = OSD_Directory(aPath); + } + + OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX); + aDir.Build(aProtection); + + return aTmpDir; +} + +//============================================================================ +// function : RemoveTemporaryFiles +// purpose : Removes files listed in theFileList +//============================================================================ +void SALOMEDSImpl_Tool::RemoveTemporaryFiles(const TCollection_AsciiString& theDirectory, + const Handle(TColStd_HSequenceOfAsciiString)& theFiles, + const bool IsDirDeleted) +{ + TCollection_AsciiString aDirName = theDirectory; + + int i, aLength = theFiles->Length(); + for(i=1; i<=aLength; i++) { + TCollection_AsciiString aFile(aDirName); + aFile += theFiles->Value(i); + OSD_Path anOSDPath(aFile); + OSD_File anOSDFile(anOSDPath); + if(!anOSDFile.Exists()) continue; + + OSD_Protection aProtection = anOSDFile.Protection(); + aProtection.SetUser(OSD_RW); + anOSDFile.SetProtection(aProtection); + + anOSDFile.Remove(); + } + + if(IsDirDeleted) { + OSD_Path aPath(aDirName); + OSD_Directory aDir(aPath); + OSD_FileIterator anIterator(aPath, '*'); + + if(aDir.Exists() && !anIterator.More()) aDir.Remove(); + } + +} + +//============================================================================ +// function : GetNameFromPath +// purpose : Returns the name by the path +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_Tool::GetNameFromPath(const TCollection_AsciiString& thePath) { + if (thePath.IsEmpty()) return ""; + OSD_Path aPath = OSD_Path(thePath); + TCollection_AsciiString aNameString(aPath.Name()); + return aNameString; +} + +//============================================================================ +// function : GetDirFromPath +// purpose : Returns the dir by the path +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_Tool::GetDirFromPath(const TCollection_AsciiString& thePath) { + if (thePath.IsEmpty()) return ""; + OSD_Path aPath = OSD_Path(thePath); + TCollection_AsciiString aDirString(aPath.Trek()); + aDirString.ChangeAll('|','/'); + return aDirString; +} + + + + + + + + + + + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx new file mode 100644 index 000000000..f842370cd --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx @@ -0,0 +1,62 @@ +// File : SALOMEDSImpl_Tool.hxx +// Created : Mon Oct 21 16:24:50 2002 +// Author : Sergey RUIN + +// Project : SALOME +// Module : SALOMEDSImpl +// Copyright : Open CASCADE + + +#ifndef __SALOMEDSIMPL_TOOL_H__ +#define __SALOMEDSIMPL_TOOL_H__ + +#include +#include +#include + +class SALOMEDSImpl_Tool +{ + +public: + + // Returns the unique temporary directory, that is defined in SALOME_TMP_DIR if this variable is set + // otherwise return /tmp/something/ for Unix or c:\something\ for WNT + static TCollection_AsciiString GetTmpDir(); + + + // Removes files which are in , the files for deletion are listed in + // if is true is also deleted if it is empty + static void RemoveTemporaryFiles(const TCollection_AsciiString& theDirectory, + const Handle(TColStd_HSequenceOfAsciiString)& theFiles, + const bool IsDirDeleted); + + // Returns the name by the path + // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "doc1" + static TCollection_AsciiString GetNameFromPath(const TCollection_AsciiString& thePath); + + // Returns the directory by the path + // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "/tmp/aaa" + static TCollection_AsciiString GetDirFromPath(const TCollection_AsciiString& thePath); + +}; +#endif + + + + + + + + + + + + + + + + + + + + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx new file mode 100644 index 000000000..d178f4a7f --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx @@ -0,0 +1,388 @@ +// File : SALOMEDSImpl_UseCaseBuilder.cxx +// Author : Sergey RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_UseCaseBuilder.hxx" +#include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_SComponent.hxx" +#include "SALOMEDSImpl_Attributes.hxx" + +#include +#include +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_UseCaseBuilder, MMgt_TShared ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_UseCaseBuilder, MMgt_TShared ) + + +#define USE_CASE_LABEL_TAG 2 +#define USE_CASE_GUID "AA43BB12-D9CD-11d6-945D-0050DA506788" + + +//============================================================================ +/*! Function : constructor + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_UseCaseBuilder::SALOMEDSImpl_UseCaseBuilder(const Handle(TDocStd_Document)& theDocument) +:_doc(theDocument) +{ + if(_doc.IsNull()) return; + + TDF_Label aLabel = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG); //Iterate all use cases + if(!aLabel.FindAttribute(Standard_GUID(USE_CASE_GUID), _root)) { + _root = SALOMEDSImpl_AttributeTreeNode::Set(aLabel, Standard_GUID(USE_CASE_GUID)); + } + + Handle(SALOMEDSImpl_AttributeReference) aRef; + if(!_root->FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), aRef)) { + aRef = SALOMEDSImpl_AttributeReference::Set(_root->Label(), _root->Label()); + } + + Handle(SALOMEDSImpl_AttributeName) aNameAttr; + if(!aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aNameAttr)) { + aNameAttr = SALOMEDSImpl_AttributeName::Set(aLabel, "Use cases"); + } +} + +//============================================================================ +/*! Function : destructor + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_UseCaseBuilder::~SALOMEDSImpl_UseCaseBuilder() +{ +} + + +//============================================================================ +/*! Function : Append + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_UseCaseBuilder::Append(const Handle(SALOMEDSImpl_SObject)& theObject) +{ + if(_root.IsNull() || theObject.IsNull()) return false; + + TDF_Label aLabel = theObject->GetLabel(); + if(aLabel.IsNull()) return false; + + Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aCurrentNode; + aNode = SALOMEDSImpl_AttributeTreeNode::Set(aLabel, _root->ID()); + aNode->Remove(); + + Handle(SALOMEDSImpl_AttributeReference) aRef; + if(!_root->FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), aRef)) { + aRef = SALOMEDSImpl_AttributeReference::Set(_root->Label(), _root->Label()); + } + + TDF_Label aCurrent = aRef->Get(); + if(aCurrent.IsNull() || !aCurrent.FindAttribute(_root->ID(), aCurrentNode)) + aCurrentNode = _root; + + aCurrentNode->Append(aNode); + + return true; +} + + //============================================================================ +/*! Function : Remove + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_UseCaseBuilder::Remove(const Handle(SALOMEDSImpl_SObject)& theObject) +{ + if(_root.IsNull() || theObject.IsNull()) return false; + + TDF_Label aLabel = theObject->GetLabel(); + if(aLabel.IsNull()) return false; + + Handle(SALOMEDSImpl_AttributeTreeNode) aNode; + if(!aLabel.FindAttribute(_root->ID(), aNode)) return false; + + aNode->Remove(); + + TDF_AttributeList aList; + aList.Append(aNode); + + Handle(SALOMEDSImpl_AttributeReference) aRef; + if(!_root->FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), aRef)) { + aRef = SALOMEDSImpl_AttributeReference::Set(_root->Label(), _root->Label()); + } + TDF_Label aCurrent = aRef->Get(); + + SALOMEDSImpl_ChildNodeIterator aChildItr(aNode, Standard_True); + for(; aChildItr.More(); aChildItr.Next()) + aList.Append(aChildItr.Value()); + + TDF_ListIteratorOfAttributeList anIterator(aList); + for(; anIterator.More(); anIterator.Next()) { + if(anIterator.Value()->Label() == aCurrent) { //The current node is removed + aRef->Set(_root->Label()); //Reset the current node to the root + } + anIterator.Value()->Label().ForgetAttribute(_root->ID()); + } + + return true; +} + + +//============================================================================ +/*! Function : AppendTo + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_UseCaseBuilder::AppendTo(const Handle(SALOMEDSImpl_SObject)& theFather, + const Handle(SALOMEDSImpl_SObject)& theObject) +{ + if(_root.IsNull() || theFather.IsNull() || theObject.IsNull()) return false; + + TDF_Label aFatherLabel = theFather->GetLabel(), aLabel = theObject->GetLabel(); + Handle(SALOMEDSImpl_AttributeTreeNode) aFather, aNode; + + if(aFatherLabel.IsNull()) return false; + if(!aFatherLabel.FindAttribute(_root->ID(), aFather)) return false; + + if(aLabel.IsNull()) return false; + if(!aLabel.FindAttribute(_root->ID(), aNode)) { + aNode = SALOMEDSImpl_AttributeTreeNode::Set(aLabel, _root->ID()); + } + + aNode->Remove(); + + return aFather->Append(aNode); +} + +//============================================================================ +/*! Function : InsertBefore + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_UseCaseBuilder::InsertBefore(const Handle(SALOMEDSImpl_SObject)& theFirst, + const Handle(SALOMEDSImpl_SObject)& theNext) +{ + if(_root.IsNull() || theFirst.IsNull() || theNext.IsNull()) return false; + + TDF_Label aFirstLabel = theFirst->GetLabel(), aLabel= theNext->GetLabel(); + Handle(SALOMEDSImpl_AttributeTreeNode) aFirstNode, aNode; + + if(aFirstLabel.IsNull()) return false; + if(aFirstLabel.FindAttribute(_root->ID(), aFirstNode)) { + aFirstNode->Remove(); + aFirstLabel.ForgetAttribute(aFirstNode->ID()); + } + + aFirstNode = SALOMEDSImpl_AttributeTreeNode::Set(aFirstLabel, _root->ID()); + + if(aLabel.IsNull()) return false; + if(!aLabel.FindAttribute(_root->ID(), aNode)) return false; + + aFirstNode->Remove(); + + return aNode->InsertBefore(aFirstNode); +} + + +//============================================================================ +/*! Function : SetCurrentObject + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_UseCaseBuilder::SetCurrentObject(const Handle(SALOMEDSImpl_SObject)& theObject) +{ + if(_root.IsNull() || theObject.IsNull()) return false; + + TDF_Label aLabel = theObject->GetLabel(); + Handle(SALOMEDSImpl_AttributeTreeNode) aNode; + if(aLabel.IsNull()) return false; + if(!aLabel.FindAttribute(_root->ID(), aNode)) return false; + + + Handle(SALOMEDSImpl_AttributeReference) aRef; + if(!_root->FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), aRef)) { + aRef = SALOMEDSImpl_AttributeReference::Set(_root->Label(), aNode->Label()); + } + + aRef->Set(aNode->Label()); + + return true; +} + +//============================================================================ +/*! Function : SetRootCurrent + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_UseCaseBuilder::SetRootCurrent() +{ + if(_root.IsNull()) return false; + + Handle(SALOMEDSImpl_AttributeReference) aRef; + if(!_root->FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), aRef)) + aRef = SALOMEDSImpl_AttributeReference::Set(_root->Label(), _root->Label()); + + aRef->Set(_root->Label()); + return true; +} + +//============================================================================ +/*! Function : HasChildren + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_UseCaseBuilder::HasChildren(const Handle(SALOMEDSImpl_SObject)& theObject) +{ + if(_root.IsNull()) return false; + + TDF_Label aLabel; + if (theObject.IsNull()) aLabel = _root->Label(); + else + aLabel = theObject->GetLabel(); + if(aLabel.IsNull()) return false; + + Handle(SALOMEDSImpl_AttributeTreeNode) aNode; + if(!aLabel.FindAttribute(_root->ID(), aNode)) return false; + + return !(aNode->GetFirst().IsNull()); +} + +//============================================================================ +/*! Function : SetName + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_UseCaseBuilder::SetName(const TCollection_AsciiString& theName) { + if(_root.IsNull()) return false; + + Handle(SALOMEDSImpl_AttributeName) aNameAttrib; + + if (!_root->FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aNameAttrib)) + aNameAttrib = SALOMEDSImpl_AttributeName::Set(_root->Label(), theName); + else + aNameAttrib->Set(theName); + + return true; +} + + +//============================================================================ +/*! Function : GetCurrentObject + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_UseCaseBuilder::GetCurrentObject() +{ + if(_root.IsNull()) return NULL; + + Handle(SALOMEDSImpl_AttributeReference) aRef; + if(!_root->FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), aRef)) { + aRef = SALOMEDSImpl_AttributeReference::Set(_root->Label(), _root->Label()); + } + TDF_Label aCurrent = aRef->Get(); + if(aCurrent.IsNull()) return NULL; + + return new SALOMEDSImpl_SObject(aCurrent); +} + +//============================================================================ +/*! Function : GetName + * Purpose : + */ +//============================================================================ +TCollection_AsciiString SALOMEDSImpl_UseCaseBuilder::GetName() +{ + TCollection_AsciiString aString; + if(_root.IsNull()) return aString; + + Handle(SALOMEDSImpl_AttributeName) aName; + if (!_root->FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aName)) return aString; + aString = TCollection_AsciiString(aName->Get()); + return aString; +} + +//============================================================================ +/*! Function : IsUseCase + * Purpose : + */ +//============================================================================ +bool SALOMEDSImpl_UseCaseBuilder::IsUseCase(const Handle(SALOMEDSImpl_SObject)& theObject) +{ + if(theObject.IsNull()) return false; + TDF_Label aFather, aLabel = theObject->GetLabel(); + aFather = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG); + if(aLabel.Father() == aFather) return true; + return false; +} + +//============================================================================ +/*! Function : NewUseCase + * Purpose : + */ +//============================================================================ +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_UseCaseBuilder::AddUseCase(const TCollection_AsciiString& theName) +{ + Standard_GUID aBasicGUID(USE_CASE_GUID); + + //Create a use cases structure if it not exists + + Handle(SALOMEDSImpl_AttributeTreeNode) aFatherNode, aNode; + Handle(SALOMEDSImpl_AttributeInteger) anInteger; + Handle(SALOMEDSImpl_AttributeReference) aRef; + + TDF_Label aLabel = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG); + + if(!_root->FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), aRef)) { + aRef = SALOMEDSImpl_AttributeReference::Set(aLabel, aLabel); + } + + if(!aRef->Get().FindAttribute(aBasicGUID, aFatherNode)) { + aFatherNode = SALOMEDSImpl_AttributeTreeNode::Set(aRef->Get(), aBasicGUID); + } + + if(!_root->FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anInteger)) { + anInteger = SALOMEDSImpl_AttributeInteger::Set(aLabel, 0); + } + + //Create a new use case + anInteger->Set(anInteger->Get()+1); + TDF_Label aChild = aLabel.FindChild(anInteger->Get()); + aNode = SALOMEDSImpl_AttributeTreeNode::Set(aChild, aBasicGUID); + aNode->Remove(); + aFatherNode->Append(aNode); + SALOMEDSImpl_AttributeName::Set(aChild, theName); + + return new SALOMEDSImpl_SObject(aChild); +} + +//============================================================================ +/*! Function : GetUseCaseIterator + * Purpose : Creates a new UseCase iterator, if anObject is null all use cases are iterated + */ +//============================================================================ +Handle(SALOMEDSImpl_UseCaseIterator) +SALOMEDSImpl_UseCaseBuilder::GetUseCaseIterator(const Handle(SALOMEDSImpl_SObject)& theObject) +{ + TDF_Label aLabel; + + if(!theObject.IsNull()) { + aLabel = theObject->GetLabel(); //Iterate only sub tree in the use case + } + else { + aLabel = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG); //Iterate all use cases + } + + return new SALOMEDSImpl_UseCaseIterator(aLabel, USE_CASE_GUID, false); +} + + +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_UseCaseBuilder::GetSObject(const TCollection_AsciiString& theEntry) +{ + TDF_Label aLabel; + TDF_Tool::Label(_doc->GetData(), theEntry, aLabel); + return new SALOMEDSImpl_SObject(aLabel); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx new file mode 100644 index 000000000..12e46468f --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx @@ -0,0 +1,67 @@ +// File : SALOMEDSImpl_UseCaseBuilder.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef __SALOMEDSIMPL_USECaseBuilder_H__ +#define __SALOMEDSIMPL_USECaseBuilder_H__ + +//Handle definition +#include +#include +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_UseCaseBuilder, MMgt_TShared ) + +// Cascade headers +#include +#include +#include +#include + +#include "SALOMEDSImpl_UseCaseIterator.hxx" + +class SALOMEDSImpl_UseCaseBuilder : public MMgt_TShared +{ +private: + + Handle(SALOMEDSImpl_AttributeTreeNode) _root; + Handle(TDocStd_Document) _doc; + +public: + + //! standard constructor + SALOMEDSImpl_UseCaseBuilder(const Handle(TDocStd_Document)& theDocument); + + //! standard destructor + ~SALOMEDSImpl_UseCaseBuilder(); + + virtual bool Append(const Handle(SALOMEDSImpl_SObject)& theObject); + + virtual bool Remove(const Handle(SALOMEDSImpl_SObject)& theObject); + + virtual bool AppendTo(const Handle(SALOMEDSImpl_SObject)& theFather, const Handle(SALOMEDSImpl_SObject)& theObject); + + virtual bool InsertBefore(const Handle(SALOMEDSImpl_SObject)& theFirst, const Handle(SALOMEDSImpl_SObject)& theNext); + + virtual bool SetCurrentObject(const Handle(SALOMEDSImpl_SObject)& theObject); + + virtual bool SetRootCurrent(); + + virtual bool HasChildren(const Handle(SALOMEDSImpl_SObject)& theObject); + + virtual bool IsUseCase(const Handle(SALOMEDSImpl_SObject)& theObject); + + virtual bool SetName(const TCollection_AsciiString& theName); + + virtual Handle(SALOMEDSImpl_SObject) GetCurrentObject(); + + virtual TCollection_AsciiString GetName(); + + virtual Handle(SALOMEDSImpl_SObject) AddUseCase(const TCollection_AsciiString& theName); + + virtual Handle(SALOMEDSImpl_UseCaseIterator) GetUseCaseIterator(const Handle(SALOMEDSImpl_SObject)& anObject); + + Handle(SALOMEDSImpl_SObject) GetSObject(const TCollection_AsciiString& theEntry); + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_UseCaseBuilder ) +}; +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.cxx new file mode 100644 index 000000000..dcfd56dd5 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.cxx @@ -0,0 +1,78 @@ +// File : SALOMEDSImpl_UseCaseIterator.cxx +// Author : Serge RUIN +// Module : SALOME + +using namespace std; +#include "SALOMEDSImpl_UseCaseIterator.hxx" +#include "SALOMEDSImpl_SObject.hxx" + +IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_UseCaseIterator, MMgt_TShared ) +IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_UseCaseIterator, MMgt_TShared ) + +//============================================================================ +/*! Function : constructor + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_UseCaseIterator::SALOMEDSImpl_UseCaseIterator(const TDF_Label& theLabel, + const Standard_GUID& theGUID, + const bool allLevels) +:_guid(theGUID), _levels(allLevels) +{ + if(theLabel.FindAttribute(_guid, _node)) { + _it.Initialize (_node, _levels); + } +} + +//============================================================================ +/*! Function : destructor + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_UseCaseIterator::~SALOMEDSImpl_UseCaseIterator() +{ +} + +//============================================================================ +/*! Function :Init + * + */ +//============================================================================ +void SALOMEDSImpl_UseCaseIterator::Init(bool allLevels) +{ + _it.Initialize (_node, allLevels); +} + +//============================================================================ +/*! Function : More + * + */ +//============================================================================ +bool SALOMEDSImpl_UseCaseIterator::More() +{ + return _it.More(); +} + + //============================================================================ +/*! Function : Next + * + */ +//============================================================================ +void SALOMEDSImpl_UseCaseIterator::Next() +{ + _it.Next(); +} + + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ + +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_UseCaseIterator::Value() +{ + TDF_Label L = _it.Value()->Label(); + return new SALOMEDSImpl_SObject(L); +} + diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.hxx new file mode 100644 index 000000000..171bcc571 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.hxx @@ -0,0 +1,47 @@ +// File : SALOMEDSImpl_UseCaseIterator.hxx +// Author : Sergey RUIN +// Module : SALOME + +#ifndef __SALOMEDSIMPL_USECASEITERATOR_H__ +#define __SALOMEDSIMPL_USECASEITERATOR_H__ + +//Handle definition +#include +#include +DEFINE_STANDARD_HANDLE( SALOMEDSImpl_UseCaseIterator, MMgt_TShared ) + +#include "SALOMEDSImpl_SObject.hxx" + +// Cascade headers +#include +#include +#include + +class SALOMEDSImpl_UseCaseIterator : public MMgt_TShared +{ + +private: + Standard_GUID _guid; + bool _levels; + Handle(SALOMEDSImpl_AttributeTreeNode) _node; + SALOMEDSImpl_ChildNodeIterator _it; + +public: + + //! standard constructor + SALOMEDSImpl_UseCaseIterator(const TDF_Label& theLabel, + const Standard_GUID& theGUID, + const bool allLevels); + + //! standard destructor + ~SALOMEDSImpl_UseCaseIterator(); + + virtual void Init(bool); + virtual bool More(); + virtual void Next(); + virtual Handle(SALOMEDSImpl_SObject) Value(); + +public: + DEFINE_STANDARD_RTTI( SALOMEDSImpl_UseCaseIterator ) +}; +#endif diff --git a/src/SALOMEDSImpl/testDS.cxx b/src/SALOMEDSImpl/testDS.cxx new file mode 100644 index 000000000..55cdbd1b2 --- /dev/null +++ b/src/SALOMEDSImpl/testDS.cxx @@ -0,0 +1,78 @@ +//File: testDS.cxx +//Author: Sergey RUIN + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "SALOMEDSImpl_Attributes.hxx" +#include "SALOMEDSImpl_StudyManager.hxx" +#include "SALOMEDSImpl_Study.hxx" +#include "SALOMEDSImpl_StudyBuilder.hxx" +#include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_SComponent.hxx" +//#include "SALOMEDSImpl_.hxx" + +int main (int argc, char * argv[]) +{ + cout << "Test started " << endl; + + Handle(SALOMEDSImpl_StudyManager) aSM = new SALOMEDSImpl_StudyManager(); + cout << "Manager is created " << endl; + Handle(SALOMEDSImpl_Study) aStudy = aSM->NewStudy("SRN"); + cout << "Study with id = " << aStudy->StudyId() << " is created " << endl; + Handle(SALOMEDSImpl_StudyBuilder) aBuilder = aStudy->NewBuilder(); + cout << "StudyBuilder is created " << endl; + Handle(SALOMEDSImpl_SComponent) aSC = aBuilder->NewComponent("TEST"); + cout << "New component with type " << aSC->ComponentDataType() << " is created " << endl; + Handle(SALOMEDSImpl_SObject) aSO = aBuilder->NewObject(aSC); + cout << "New SObject with ID = " << aSO->GetID() << " is created" << endl; + TCollection_AsciiString anEntry; + TDF_Tool::Entry(aSO->GetLabel(), anEntry); + cout << "An entry of newly created SO is " << anEntry << endl; + Handle(SALOMEDSImpl_AttributeIOR) aIORA = SALOMEDSImpl_AttributeIOR::Set(aSO->GetLabel(), "ior1234"); + cout << "New AttributeIOR is created, it contains " << aIORA->Value() << endl; + Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aIORA); + cout << "Attribute has type: " << ga->Type() << " and value: " << ga->Save() << endl; + cout << "Just another way to create an attribute: official one :) " << endl; + Handle(TDF_Attribute) aTDFAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName"); + Handle(SALOMEDSImpl_AttributeName) aRN = Handle(SALOMEDSImpl_AttributeName)::DownCast(aTDFAttr); + aRN->Set("name_attribute"); + cout << " The type = " << aRN->Type() << endl; + ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aRN); + cout << "Attribute has type: " << ga->Type() << " and value: " << ga->Save() << endl; + cout << "Check GetObjectPath: " << aStudy->GetObjectPath(aSO) << endl; + + Handle(SALOMEDSImpl_SObject) aSubSO = aBuilder->NewObject(aSO); + aTDFAttr = aBuilder->FindOrCreateAttribute(aSubSO, "AttributeIOR"); + Handle(SALOMEDSImpl_AttributeIOR) aIOR2 = Handle(SALOMEDSImpl_AttributeIOR)::DownCast(aTDFAttr); + aIOR2->SetValue("some ior"); + aBuilder->Addreference(aSubSO, aSO); + Handle(SALOMEDSImpl_SObject) aRefObject; + aSubSO->ReferencedObject(aRefObject); + cout << "Check reference : ReferencedObject is " << aRefObject->GetID() << endl; + cout << "Check : Remove object: " << endl; + aBuilder->RemoveObject(aSubSO); + cout << "Remove: done" << 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 << "Test finished " << endl; + return 0; +} + -- 2.39.2