1 // SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOMEDS_SObject_i.cxx
25 // Author : Yves FRICAUD
29 #include "utilities.h"
30 #include "SALOMEDS_SObject_i.hxx"
32 #include "SALOMEDS_SComponent_i.hxx"
33 #include "SALOMEDS_IORAttribute.hxx"
34 #include "SALOMEDS_PersRefAttribute.hxx"
35 #include "SALOMEDS_SequenceOfRealAttribute.hxx"
36 #include "SALOMEDS_SequenceOfIntegerAttribute.hxx"
37 #include "SALOMEDS_TableOfRealAttribute.hxx"
38 #include "SALOMEDS_TableOfIntegerAttribute.hxx"
39 #include "SALOMEDS_IORAttribute.hxx"
40 #include "SALOMEDS_PersRefAttribute.hxx"
41 #include "SALOMEDS_StudyPropertiesAttribute.hxx"
42 #include "SALOMEDS_PythonObjectAttribute.hxx"
43 #include "SALOMEDS_AttributePersistentRef_i.hxx"
44 #include "SALOMEDS_AttributeIOR_i.hxx"
45 #include "SALOMEDS_AttributeComment_i.hxx"
46 #include "SALOMEDS_AttributeExternalFileDef_i.hxx"
47 #include "SALOMEDS_AttributeFileType_i.hxx"
48 #include "SALOMEDS_AttributeName_i.hxx"
49 #include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
50 #include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
51 #include "SALOMEDS_AttributeInteger_i.hxx"
52 #include "SALOMEDS_AttributeReal_i.hxx"
53 #include "SALOMEDS_AttributeDrawable_i.hxx"
54 #include "SALOMEDS_AttributeSelectable_i.hxx"
55 #include "SALOMEDS_AttributeExpandable_i.hxx"
56 #include "SALOMEDS_AttributeOpened_i.hxx"
57 #include "SALOMEDS_AttributeTextColor_i.hxx"
58 #include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
59 #include "SALOMEDS_AttributePixMap_i.hxx"
60 #include "SALOMEDS_AttributeTreeNode_i.hxx"
61 #include "SALOMEDS_AttributeLocalID_i.hxx"
62 #include "SALOMEDS_AttributeUserID_i.hxx"
63 #include "SALOMEDS_AttributeTarget_i.hxx"
64 #include "SALOMEDS_AttributeTableOfInteger_i.hxx"
65 #include "SALOMEDS_AttributeTableOfReal_i.hxx"
66 #include "SALOMEDS_AttributeTableOfString_i.hxx"
67 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
68 #include "SALOMEDS_AttributePythonObject_i.hxx"
69 #include <TDF_AttributeIterator.hxx>
72 //============================================================================
73 /*! Function : ReturnGUIDForAttribute
76 //============================================================================
79 SALOMEDS_SObject_i::ReturnGUIDForAttribute(const char* aTypeOfAttribute)
83 if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) return TDataStd_Real::GetID();
84 else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) return TDataStd_Integer::GetID();
85 else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) return SALOMEDS_SequenceOfRealAttribute::GetID();
86 else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) return SALOMEDS_SequenceOfIntegerAttribute::GetID();
87 else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) return TDataStd_Name::GetID();
88 else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) return TDataStd_Comment::GetID();
89 else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) return SALOMEDS_ExternalFileDef::GetID();
90 else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) return SALOMEDS_FileType::GetID();
91 else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) return SALOMEDS_IORAttribute::GetID();
92 else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) return SALOMEDS_PersRefAttribute::GetID();
93 else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) return SALOMEDS_DrawableAttribute::GetID();
94 else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) return SALOMEDS_SelectableAttribute::GetID();
95 else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) return SALOMEDS_ExpandableAttribute::GetID();
96 else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) return SALOMEDS_OpenedAttribute::GetID();
97 else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) return SALOMEDS_TextColorAttribute::GetID();
98 else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) return SALOMEDS_TextHighlightColorAttribute::GetID();
99 else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) return SALOMEDS_PixMapAttribute::GetID();
100 else if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0 ) return TDataStd_TreeNode::GetDefaultTreeID();
101 else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) return SALOMEDS_LocalIDAttribute::GetID();
102 else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) return SALOMEDS_TargetAttribute::GetID();
103 else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) return SALOMEDS_TableOfIntegerAttribute::GetID();
104 else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) return SALOMEDS_TableOfRealAttribute::GetID();
105 else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) return SALOMEDS_TableOfStringAttribute::GetID();
106 else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) return SALOMEDS_StudyPropertiesAttribute::GetID();
107 else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) return SALOMEDS_PythonObjectAttribute::GetID();
108 else if (strcmp(aTypeOfAttribute, "AttributeUserID") == 0 ) return SALOMEDS_AttributeUserID_i::DefaultID();
109 else if (strncmp(aTypeOfAttribute,"AttributeTreeNodeGUID",21) == 0) {
110 char* aGUIDString = new char[40];
111 sprintf(aGUIDString, &(aTypeOfAttribute[21]));
112 Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name
116 else Standard_NoSuchObject::Raise("SALOMEDS_SObject_i::ReturnGUIDForAttribute");
119 //============================================================================
120 /*! Function : AttributeIDToType
123 //============================================================================
124 char* SALOMEDS_SObject_i::AttributeIDToType(Standard_GUID ID)
126 if (ID == TDataStd_Name::GetID()) return "AttributeName";
127 else if (ID == TDataStd_Comment::GetID()) return "AttributeComment";
128 else if (ID == SALOMEDS_ExternalFileDef::GetID()) return "AttributeExternalFileDef";
129 else if (ID == SALOMEDS_FileType::GetID()) return "AttributeFileType";
130 else if (ID == SALOMEDS_IORAttribute::GetID()) return "AttributeIOR";
131 else if (ID == SALOMEDS_PersRefAttribute::GetID()) return "AttributePersistentRef";
132 else if (ID == TDataStd_Real::GetID()) return "AttributeReal";
133 else if (ID == TDataStd_Integer::GetID()) return "AttributeInteger";
134 else if (ID == SALOMEDS_SequenceOfRealAttribute::GetID()) return "AttributeSequenceOfReal";
135 else if (ID == SALOMEDS_SequenceOfIntegerAttribute::GetID()) return "AttributeSequenceOfInteger";
136 else if (ID == SALOMEDS_DrawableAttribute::GetID()) return "AttributeDrawable";
137 else if (ID == SALOMEDS_SelectableAttribute::GetID()) return "AttributeSelectable";
138 else if (ID == SALOMEDS_ExpandableAttribute::GetID()) return "AttributeExpandable";
139 else if (ID == SALOMEDS_OpenedAttribute::GetID()) return "AttributeOpened";
140 else if (ID == SALOMEDS_TextColorAttribute::GetID()) return "AttributeTextColor";
141 else if (ID == SALOMEDS_TextHighlightColorAttribute::GetID()) return "AttributeTextHighlightColor";
142 else if (ID == SALOMEDS_PixMapAttribute::GetID()) return "AttributePixMap";
143 else if (ID == TDataStd_TreeNode::GetDefaultTreeID()) return "AttributeTreeNode";
144 else if (ID == SALOMEDS_LocalIDAttribute::GetID()) return "AttributeLocalID";
145 else if (ID == SALOMEDS_TargetAttribute::GetID()) return "AttributeTarget";
146 else if (ID == SALOMEDS_TableOfIntegerAttribute::GetID()) return "AttributeTableOfInteger";
147 else if (ID == SALOMEDS_TableOfRealAttribute::GetID()) return "AttributeTableOfReal";
148 else if (ID == SALOMEDS_TableOfStringAttribute::GetID()) return "AttributeTableOfString";
149 else if (ID == SALOMEDS_StudyPropertiesAttribute::GetID()) return "AttributeStudyProperties";
150 else if (ID == SALOMEDS_PythonObjectAttribute::GetID()) return "AttributePythonObject";
151 else if (ID == SALOMEDS_AttributeUserID_i::DefaultID()) return "AttributeUserID";
152 // 08.01.2003 mpv: this method must be called only for attributes with constant GUID
153 else Standard_NoSuchObject::Raise("SALOMEDS_SObject_i::AttributeIDToType");
157 //============================================================================
158 /*! Function : constructor
161 //============================================================================
162 SALOMEDS_SObject_i::SALOMEDS_SObject_i(const TDF_Label lab, CORBA::ORB_ptr orb)
165 _orb = CORBA::ORB::_duplicate(orb);
169 _liste_ba_type.resize(0);
173 //============================================================================
174 /*! Function : destructor
177 //============================================================================
178 SALOMEDS_SObject_i::~SALOMEDS_SObject_i()
180 CORBA::string_free(_value);
181 CORBA::string_free(_type);
182 CORBA::string_free(_name);
186 //============================================================================
190 //============================================================================
191 char* SALOMEDS_SObject_i::GetID()
193 TCollection_AsciiString anEntry;
194 TDF_Tool::Entry (_lab,anEntry);
195 return CORBA::string_dup(anEntry.ToCString());
198 //============================================================================
202 //============================================================================
203 SALOMEDS::SComponent_ptr SALOMEDS_SObject_i::GetFatherComponent()
206 while (!SALOMEDS_SComponent_i::IsA(LF) && !LF.IsRoot()) {
209 SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (LF,_orb);
210 SALOMEDS::SComponent_var so;
211 so= SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this());
215 //============================================================================
219 //============================================================================
220 SALOMEDS::SObject_ptr SALOMEDS_SObject_i::GetFather()
222 TDF_Label LF = _lab.Father();
224 SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (LF,_orb);
225 SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this());
229 //============================================================================
233 //============================================================================
234 SALOMEDS::Study_ptr SALOMEDS_SObject_i::GetStudy()
236 TDF_Label Root = _lab.Root();
237 Handle(SALOMEDS_IORAttribute) Att;
239 if (Root.FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){
240 TCollection_AsciiString ch(Att->Get());
241 IOR = CORBA::string_dup(ch.ToCString());
242 CORBA::Object_var obj = _orb->string_to_object(IOR);
243 SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(obj) ;
244 ASSERT(!CORBA::is_nil(Study));
245 return SALOMEDS::Study::_duplicate(Study); //return Study = abort...
247 INFOS("Problem GetStudy");
248 return SALOMEDS::Study::_nil();
251 //============================================================================
252 /*! Function : FindAttribute
253 * Purpose : Find attribute of given type on this SObject
255 //============================================================================
256 CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out anAttribute,
257 const char* aTypeOfAttribute)
259 Handle(TDF_Attribute) anAttr;
260 Standard_Boolean found = _lab.FindAttribute(SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute), anAttr);
262 if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) {
263 SALOMEDS_AttributeReal_i* Attr = new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb);
264 anAttribute = Attr->AttributeReal::_this();
265 return Standard_True;
267 else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) {
268 SALOMEDS_AttributeInteger_i* Attr = new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb);
269 anAttribute = Attr->AttributeInteger::_this();
270 return Standard_True;
272 else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) {
273 SALOMEDS_AttributeSequenceOfReal_i* Attr = new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb);
274 anAttribute = Attr->AttributeSequenceOfReal::_this();
275 return Standard_True;
277 else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) {
278 SALOMEDS_AttributeSequenceOfInteger_i* Attr = new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb);
279 anAttribute = Attr->AttributeSequenceOfInteger::_this();
280 return Standard_True;
282 else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) {
283 SALOMEDS_AttributeName_i* Attr = new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb);
284 anAttribute = Attr->AttributeName::_this();
285 return Standard_True;
287 else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) {
288 SALOMEDS_AttributeComment_i* Attr = new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb);
289 anAttribute = Attr->AttributeComment::_this();
290 return Standard_True;
292 else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) {
293 SALOMEDS_AttributeExternalFileDef_i* Attr = new SALOMEDS_AttributeExternalFileDef_i(Handle(SALOMEDS_ExternalFileDef)::DownCast(anAttr), _orb);
294 anAttribute = Attr->AttributeExternalFileDef::_this();
295 return Standard_True;
297 else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) {
298 SALOMEDS_AttributeFileType_i* Attr = new SALOMEDS_AttributeFileType_i(Handle(SALOMEDS_FileType)::DownCast(anAttr), _orb);
299 anAttribute = Attr->AttributeFileType::_this();
300 return Standard_True;
302 else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) {
303 SALOMEDS_AttributeIOR_i* Attr = new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb);
304 anAttribute = Attr->AttributeIOR::_this();
305 return Standard_True;
307 else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) {
308 SALOMEDS_AttributePersistentRef_i* Attr = new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb);
309 anAttribute = Attr->AttributePersistentRef::_this();
310 return Standard_True;
312 else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) {
313 SALOMEDS_AttributeDrawable_i* Attr = new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb);
314 anAttribute = Attr->AttributeDrawable::_this();
315 return Standard_True;
317 else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) {
318 SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb);
319 anAttribute = Attr->AttributeSelectable::_this();
320 return Standard_True;
322 else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) {
323 SALOMEDS_AttributeExpandable_i* Attr = new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb);
324 anAttribute = Attr->AttributeExpandable::_this();
325 return Standard_True;
327 else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) {
328 SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb);
329 anAttribute = Attr->AttributeOpened::_this();
330 return Standard_True;
332 else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) {
333 SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb);
334 anAttribute = Attr->AttributeTextColor::_this();
335 return Standard_True;
337 else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) {
338 SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb);
339 anAttribute = Attr->AttributeTextHighlightColor::_this();
340 return Standard_True;
342 else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) {
343 SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb);
344 anAttribute = Attr->AttributePixMap::_this();
345 return Standard_True;
347 else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) {
348 SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb);
349 anAttribute = Attr->AttributeTreeNode::_this();
350 return Standard_True;
352 else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) {
353 SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb);
354 anAttribute = Attr->AttributeLocalID::_this();
355 return Standard_True;
357 else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) {
358 SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb);
359 anAttribute = Attr->AttributeUserID::_this();
360 return Standard_True;
362 else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) {
363 SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb);
364 anAttribute = Attr->AttributeTarget::_this();
365 return Standard_True;
367 else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) {
368 SALOMEDS_AttributeTableOfInteger_i* Attr = new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb);
369 anAttribute = Attr->AttributeTableOfInteger::_this();
370 return Standard_True;
372 else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) {
373 SALOMEDS_AttributeTableOfReal_i* Attr = new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb);
374 anAttribute = Attr->AttributeTableOfReal::_this();
375 return Standard_True;
377 else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) {
378 SALOMEDS_AttributeTableOfString_i* Attr = new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb);
379 anAttribute = Attr->AttributeTableOfString::_this();
380 return Standard_True;
382 else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) {
383 SALOMEDS_AttributeStudyProperties_i* Attr = new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb);
384 anAttribute = Attr->AttributeStudyProperties::_this();
385 return Standard_True;
387 else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) {
388 SALOMEDS_AttributePythonObject_i* Attr = new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb);
389 anAttribute = Attr->AttributePythonObject::_this();
390 return Standard_True;
392 } else return Standard_False;
395 //============================================================================
396 /*! Function : GetAllAttributes
397 * Purpose : Returns list of all attributes for this sobject
399 //============================================================================
401 SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes()
403 Standard_Integer NumAttr = _lab.NbAttributes();
404 SALOMEDS::ListOfAttributes_var SeqOfAttr = new SALOMEDS::ListOfAttributes;
405 SeqOfAttr->length(NumAttr);
407 Standard_Integer i = 0;
408 for(TDF_AttributeIterator iter(_lab);iter.More();iter.Next()) {
409 Handle(TDF_Attribute) anAttr = iter.Value();
410 SALOMEDS::GenericAttribute_var anAttribute;
411 if (ReturnGUIDForAttribute("AttributeReal") == anAttr->ID()) {
412 SALOMEDS_AttributeReal_i* Attr= new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb);
413 anAttribute = Attr->AttributeReal::_this();
415 else if (ReturnGUIDForAttribute("AttributeInteger") == anAttr->ID()) {
416 SALOMEDS_AttributeInteger_i* Attr= new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb);
417 anAttribute = Attr->AttributeInteger::_this();
419 else if (ReturnGUIDForAttribute("AttributeSequenceOfReal") == anAttr->ID()) {
420 SALOMEDS_AttributeSequenceOfReal_i* Attr= new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb);
421 anAttribute = Attr->AttributeSequenceOfReal::_this();
423 else if (ReturnGUIDForAttribute("AttributeSequenceOfInteger") == anAttr->ID()) {
424 SALOMEDS_AttributeSequenceOfInteger_i* Attr= new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb);
425 anAttribute = Attr->AttributeSequenceOfInteger::_this();
427 else if (ReturnGUIDForAttribute("AttributeName") == anAttr->ID()) {
428 SALOMEDS_AttributeName_i* Attr= new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb);
429 anAttribute = Attr->AttributeName::_this();
431 else if (ReturnGUIDForAttribute("AttributeComment") == anAttr->ID()) {
432 SALOMEDS_AttributeComment_i* Attr= new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb);
433 anAttribute = Attr->AttributeComment::_this();
435 else if (ReturnGUIDForAttribute("AttributeExternalFileDef") == anAttr->ID()) {
436 SALOMEDS_AttributeExternalFileDef_i* Attr= new SALOMEDS_AttributeExternalFileDef_i(Handle(SALOMEDS_ExternalFileDef)::DownCast(anAttr), _orb);
437 anAttribute = Attr->AttributeExternalFileDef::_this();
439 else if (ReturnGUIDForAttribute("AttributeFileType") == anAttr->ID()) {
440 SALOMEDS_AttributeFileType_i* Attr= new SALOMEDS_AttributeFileType_i(Handle(SALOMEDS_FileType)::DownCast(anAttr), _orb);
441 anAttribute = Attr->AttributeFileType::_this();
443 else if (ReturnGUIDForAttribute("AttributeIOR") == anAttr->ID()) {
444 SALOMEDS_AttributeIOR_i* Attr= new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb);
445 anAttribute = Attr->AttributeIOR::_this();
447 else if (ReturnGUIDForAttribute("AttributePersistentRef") == anAttr->ID()) {
448 SALOMEDS_AttributePersistentRef_i* Attr= new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb);
449 anAttribute = Attr->AttributePersistentRef::_this();
451 else if (ReturnGUIDForAttribute("AttributeDrawable") == anAttr->ID()) {
452 SALOMEDS_AttributeDrawable_i* Attr= new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb);
453 anAttribute = Attr->AttributeDrawable::_this();
455 else if (ReturnGUIDForAttribute("AttributeSelectable") == anAttr->ID()) {
456 SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb);
457 anAttribute = Attr->AttributeSelectable::_this();
459 else if (ReturnGUIDForAttribute("AttributeExpandable") == anAttr->ID()) {
460 SALOMEDS_AttributeExpandable_i* Attr= new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb);
461 anAttribute = Attr->AttributeExpandable::_this();
463 else if (ReturnGUIDForAttribute("AttributeOpened") == anAttr->ID()) {
464 SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb);
465 anAttribute = Attr->AttributeOpened::_this();
467 else if (ReturnGUIDForAttribute("AttributeTextColor") == anAttr->ID()) {
468 SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb);
469 anAttribute = Attr->AttributeTextColor::_this();
471 else if (ReturnGUIDForAttribute("AttributeTextHighlightColor") == anAttr->ID()) {
472 SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb);
473 anAttribute = Attr->AttributeTextHighlightColor::_this();
475 else if (ReturnGUIDForAttribute("AttributePixMap") == anAttr->ID()) {
476 SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb);
477 anAttribute = Attr->AttributePixMap::_this();
479 else if (ReturnGUIDForAttribute("AttributeTreeNode") == anAttr->ID()) {
480 SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb);
481 anAttribute = Attr->AttributeTreeNode::_this();
483 else if (ReturnGUIDForAttribute("AttributeLocalID") == anAttr->ID()) {
484 SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb);
485 anAttribute = Attr->AttributeLocalID::_this();
487 else if (ReturnGUIDForAttribute("AttributeTarget") == anAttr->ID()) {
488 SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb);
489 anAttribute = Attr->AttributeTarget::_this();
491 else if (ReturnGUIDForAttribute("AttributeTableOfInteger") == anAttr->ID()) {
492 SALOMEDS_AttributeTableOfInteger_i* Attr= new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb);
493 anAttribute = Attr->AttributeTableOfInteger::_this();
495 else if (ReturnGUIDForAttribute("AttributeTableOfReal") == anAttr->ID()) {
496 SALOMEDS_AttributeTableOfReal_i* Attr= new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb);
497 anAttribute = Attr->AttributeTableOfReal::_this();
499 else if (ReturnGUIDForAttribute("AttributeTableOfString") == anAttr->ID()) {
500 SALOMEDS_AttributeTableOfString_i* Attr= new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb);
501 anAttribute = Attr->AttributeTableOfString::_this();
503 else if (ReturnGUIDForAttribute("AttributeStudyProperties") == anAttr->ID()) {
504 SALOMEDS_AttributeStudyProperties_i* Attr= new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb);
505 anAttribute = Attr->AttributeStudyProperties::_this();
507 else if (ReturnGUIDForAttribute("AttributePythonObject") == anAttr->ID()) {
508 SALOMEDS_AttributePythonObject_i* Attr= new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb);
509 anAttribute = Attr->AttributePythonObject::_this();
511 else if (!Handle(TDataStd_UAttribute)::DownCast(anAttr).IsNull()) {
512 SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb);
513 anAttribute = Attr->AttributeUserID::_this();
515 else if (!Handle(TDataStd_TreeNode)::DownCast(anAttr).IsNull()) {
516 SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb);
517 anAttribute = Attr->AttributeTreeNode::_this();
519 // references attributes, for an example, never returns
523 SeqOfAttr[i] = anAttribute;
527 return SeqOfAttr._retn();
531 //============================================================================
532 /*! Function : ReferencedObject
535 //============================================================================
536 CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out obj)
538 Handle(TDF_Reference) Ref;
539 if (!_lab.FindAttribute(TDF_Reference::GetID(),Ref))
542 SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (Ref->Get(),_orb);
543 obj = SALOMEDS::SObject::_narrow(so_servant->_this());
547 //============================================================================
551 //============================================================================
552 CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(CORBA::Long atag, SALOMEDS::SObject_out obj)
554 TDF_Label L = _lab.FindChild(atag,false);
555 if (L.IsNull()) return false;
557 SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (L,_orb);
558 obj = SALOMEDS::SObject::_narrow(so_servant->_this());
563 //============================================================================
567 //============================================================================
568 char* SALOMEDS_SObject_i::Name()
570 return CORBA::string_dup(_name);
573 //============================================================================
577 //============================================================================
578 void SALOMEDS_SObject_i::Name(const char* name)
580 _name = CORBA::string_dup(name);
583 //============================================================================
587 //============================================================================
588 CORBA::Short SALOMEDS_SObject_i::Tag()