1 // VISU OBJECT : interactive object for VISU entities implementation
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : VISUConfig.cc
24 // Author : Alexey PETROV
27 #include "VISUConfig.hh"
29 #include "SUIT_ResourceMgr.h"
30 #include "SUIT_Session.h"
32 #include "SALOMEDSClient_GenericAttribute.hxx"
33 #include "SALOMEDSClient_AttributeIOR.hxx"
35 #include "SalomeApp_Application.h"
36 #include "SalomeApp_Study.h"
38 #include "SALOME_Event.hxx"
45 static int MYDEBUG = 0;
47 static int MYDEBUG = 0;
57 return SUIT_Session::session();
63 return GetSession()->resourceMgr();
66 //---------------------------------------------------------------------------
68 QMutex* Base_i::myMutex = NULL; //apo - &VISUMutex;
69 CORBA::ORB_var Base_i::myOrb;
70 PortableServer::POA_var Base_i::myPoa;
71 SALOME_NamingService* Base_i::myNamingService;
72 SALOME_LifeCycleCORBA* Base_i::myEnginesLifeCycle;
73 VISU_Gen_i* Base_i::myVisuGenImpl;
79 char* Base_i::GetID(){
81 CORBA::Object_var anObject = _this();
82 CORBA::String_var anIOR = myOrb->object_to_string(anObject);
85 return CORBA::string_dup(myID.c_str());
88 //---------------------------------------------------------------------------
89 static int mySCnt = 0;
90 static QMutex aMutex(TRUE);
92 Mutex::Mutex(QMutex* theMutex): myMutex(&aMutex)
94 if(MYDEBUG) MESSAGE("Mutex::Mutex : "<<!mySCnt);
103 if(MYDEBUG) MESSAGE("Mutex::~Mutex : "<<!mySCnt);
107 //---------------------------------------------------------------------------
108 Storable::TStorableEngineMap Storable::myStorableEngineMap;
114 ostringstream anOutputStream;
115 Storable::DataToStream( anOutputStream, "myComment", GetComment() );
116 ToStream(anOutputStream);
117 anOutputStream<<ends;
118 if(MYDEBUG) MESSAGE("Storable::ToString - "<<anOutputStream.str());
119 return anOutputStream.str();
123 //---------------------------------------------------------------
126 ::CanCopy(SALOMEDS::SObject_ptr theObject)
132 //---------------------------------------------------------------
135 ::CopyFrom(SALOMEDS::SObject_ptr theObject,
136 CORBA::Long& theObjectID,
137 const std::string& theTmpDir,
138 TFileNames& theFileNames)
140 TFileName aFileName("copy_persistent");
141 std::string aCopyPersist = theTmpDir + aFileName;
142 std::ofstream anOutputFileStream(aCopyPersist.c_str(), ios::out);
143 anOutputFileStream<<ToString()<<endl;
145 theFileNames.push_back(aFileName);
152 //---------------------------------------------------------------
155 ::RegistryStorableEngine(const std::string& theComment,
156 TStorableEngine theEngine)
158 if(!myStorableEngineMap.insert(TStorableEngineMap::value_type(theComment, theEngine)).second)
159 throw std::logic_error("Storable::Registry >> dupliacte registring !!!");
163 //---------------------------------------------------------------
166 ::Create(SALOMEDS::SObject_ptr theSObject,
167 const std::string& theLocalPersistentID,
168 const std::string& thePrefix,
169 CORBA::Boolean theIsMultiFile)
172 QString aString( CorrectPersistentString( theLocalPersistentID ) );
173 TRestoringMap aRestoringMap;
174 StringToMap(aString, aRestoringMap);
176 QString aComment = VISU::Storable::FindValue(aRestoringMap, "myComment", &anIsExists);
178 TStorableEngineMap::const_iterator anIter = myStorableEngineMap.find(aComment.latin1());
179 if(MYDEBUG) MESSAGE("Storable::Create - "<<aComment.latin1()<<" "<<(anIter != myStorableEngineMap.end()));
180 if(anIter == myStorableEngineMap.end())
182 TStorableEngine aStorableEngine = anIter->second;
183 return aStorableEngine(theSObject, aRestoringMap, thePrefix, theIsMultiFile);
185 }catch(std::exception& exc){
186 INFOS("Follow exception was occured :\n"<<exc.what());
188 INFOS("Unknown exception was occured!");
194 //---------------------------------------------------------------
197 ::Comment2Type(const std::string& theComment)
199 if ( theComment == "CURVE" )
201 if ( theComment == "TABLE" )
203 if ( theComment == "CONTAINER" )
204 return VISU::TCONTAINER;
205 if ( theComment == "MESH" )
207 if ( theComment == "SCALARMAP" )
208 return VISU::TSCALARMAP;
209 if ( theComment == "PRSMERGER" )
210 return VISU::TSCALARMAP;
211 if ( theComment == "ISOSURFACE" )
212 return VISU::TISOSURFACES;
213 if ( theComment == "DEFORMEDSHAPE" )
214 return VISU::TDEFORMEDSHAPE;
215 if ( theComment == "SCALARMAPONDEFORMEDSHAPE" )
216 return VISU::TSCALARMAPONDEFORMEDSHAPE;
217 if ( theComment == "GAUSSPOINTS" )
218 return VISU::TGAUSSPOINTS;
219 if ( theComment == "PLOT3D" )
220 return VISU::TPLOT3D;
221 if ( theComment == "CUTPLANES" )
222 return VISU::TCUTPLANES;
223 if ( theComment == "CUTLINES" )
224 return VISU::TCUTLINES;
225 if ( theComment == "VECTORS" )
226 return VISU::TVECTORS;
227 if ( theComment == "STREAMLINES" )
228 return VISU::TSTREAMLINES;
229 if ( theComment == "VISUGEN" )
230 return VISU::TVISUGEN;
231 if ( theComment == "VIEWMANAGER" )
232 return VISU::TVIEWMANAGER;
233 if ( theComment == "RESULT" )
234 return VISU::TRESULT;
235 if ( theComment == "XYPLOT" )
236 return VISU::TXYPLOT;
237 if ( theComment == "TABLEVIEW" )
238 return VISU::TTABLEVIEW;
239 if ( theComment == "VIEW3D" )
240 return VISU::TVIEW3D;
241 if ( theComment == "GAUSSVIEW" )
242 return VISU::TGAUSSVIEW;
243 if ( theComment == "ENTITY" )
244 return VISU::TENTITY;
245 if ( theComment == "FAMILY" )
246 return VISU::TFAMILY;
247 if ( theComment == "PART" )
248 return VISU::TPART; // MULTIPR
249 if ( theComment == "GROUP" )
251 if ( theComment == "FIELD" )
253 if ( theComment == "TIMESTAMP" )
254 return VISU::TTIMESTAMP;
255 if ( theComment == "ANIMATION" )
256 return VISU::TANIMATION;
257 if ( theComment == "ALL" )
264 //---------------------------------------------------------------
267 ::RestoringMap2Type(const TRestoringMap& theRestoringMap)
269 QString aComment = Storable::FindValue( theRestoringMap, "myComment", "" );
270 return Comment2Type(aComment.latin1());
274 //---------------------------------------------------------------
277 ::Stream2Type(const std::string& thePersistentString)
279 QString aString(thePersistentString.c_str());
280 if(aString.isEmpty())
283 VISU::Storable::TRestoringMap aRestoringMap;
284 Storable::StringToMap( aString, aRestoringMap );
285 return RestoringMap2Type( aRestoringMap );
289 //---------------------------------------------------------------
292 ::SObject2Type(const _PTR(SObject)& theSObject)
294 _PTR(GenericAttribute) anAttr;
295 if (theSObject->FindAttribute(anAttr, "AttributeString")) {
296 _PTR(AttributeString) aDataAttr(anAttr);
297 std::string aData = aDataAttr->Value();
298 return Stream2Type(aData);
305 //---------------------------------------------------------------
308 ::CorrectPersistentString(const std::string& thePersistentString)
310 QString aString(thePersistentString.c_str());
311 if(aString.isEmpty())
312 return aString.latin1();
314 VISU::Storable::TRestoringMap aRestoringMap;
315 Storable::StringToMap( aString, aRestoringMap );
317 bool anIsFound = false;
318 QString aComment = Storable::FindValue( aRestoringMap, "myComment", &anIsFound );
320 if ( aComment == "PRSMERGER" )
321 aString.replace( "myComment=PRSMERGER", "myComment=SCALARMAP" );
324 return aString.latin1();
328 //---------------------------------------------------------------
331 ::FindEntry(SALOMEDS::Study_ptr theStudyDocument,
332 const std::string& theStartEntry,
333 const TRestoringMap& theRestoringMap,
336 SALOMEDS::SObject_var aSObject = theStudyDocument->FindObjectID(theStartEntry.c_str());
337 SALOMEDS::ChildIterator_var anIter = theStudyDocument->NewChildIterator(aSObject);
338 anIter->InitEx(IsAllLevels);
339 for(; anIter->More(); anIter->Next()) {
340 aSObject = anIter->Value();
341 SALOMEDS::GenericAttribute_var anAttr;
342 if (aSObject->FindAttribute(anAttr,"AttributeString")) {
343 SALOMEDS::AttributeString_var aDataAttr = SALOMEDS::AttributeString::_narrow(anAttr);
344 CORBA::String_var aString = aDataAttr->Value();
345 VISU::Storable::TRestoringMap aRestoringMap;
346 Storable::StringToMap( aString.in(), aRestoringMap );
347 bool anIsSame = true;
348 TRestoringMap::const_iterator anIter = theRestoringMap.begin();
349 for(; anIter != theRestoringMap.end(); anIter++){
350 const TRestoringMap::key_type& aKey = anIter->first;
351 TRestoringMap::const_iterator anIter2 = aRestoringMap.find(aKey);
352 if(anIter2 != aRestoringMap.end()){
353 if (anIter->second == anIter2->second)
360 CORBA::String_var anEntry = aSObject->GetID();
369 //----------------------------------------------------------------------------
372 ::StringToMap(const QString& theString,
373 TRestoringMap& theMap)
375 if(0 && MYDEBUG) MESSAGE("Storable::StringToMap : string="<<theString);
376 QStringList strList = QStringList::split( ";", theString, false );
377 for ( int i = 0; i < strList.count(); i++ ) {
378 QString next = strList[ i ];
379 int pos = next.find("=");
380 QString aName, aValue;
382 aName = next.stripWhiteSpace();
386 aName = next.left( pos ).stripWhiteSpace();
387 aValue = next.mid( pos+1 );
388 if ( aValue.isNull() )
391 if ( !aName.isEmpty() )
392 theMap.insert( TRestoringMap::value_type( aName.latin1(), aValue ) );
397 //----------------------------------------------------------------------------
398 Storable::TRestoringMap
400 ::GetStorableMap(_PTR(SObject) theSObject)
402 Storable::TRestoringMap aRestoringMap;
404 _PTR(GenericAttribute) anAttr;
405 if(theSObject->FindAttribute(anAttr,"AttributeString")){
406 _PTR(AttributeString) aComment (anAttr);
407 std::string aValue = aComment->Value();
408 VISU::Storable::StringToMap(aValue.c_str(), aRestoringMap);
411 return aRestoringMap;
415 //----------------------------------------------------------------------------
418 ::DataToStream(std::ostringstream& theStr,
419 const QString& theName,
420 const QString& theVal)
422 QString output = ( !theName.isNull() ? theName : QString("") )
424 + ( !theVal.isNull() ? theVal : QString("") );
425 theStr<<output.latin1()<<";";
429 //---------------------------------------------------------------
432 ::DataToStream(std::ostringstream& theStr,
433 const QString& theName,
436 QString output = ( !theName.isNull() ? theName : QString("") )
438 + QString::number( theVal );
439 theStr<<output.latin1()<<";";
443 //---------------------------------------------------------------
446 ::DataToStream(std::ostringstream& theStr,
447 const QString& theName,
450 QString output = ( !theName.isNull() ? theName : QString("") )
452 + QString::number( theVal );
453 theStr<<output.latin1()<<";";
457 //---------------------------------------------------------------
460 ::DataToStream(std::ostringstream& theStr,
461 const QString& theName,
464 QString output = ( !theName.isNull() ? theName : QString("") )
466 + QString::number( theVal );
467 theStr<<output.latin1()<<";";
471 //---------------------------------------------------------------
474 ::FindValue(const TRestoringMap& theMap,
475 const std::string& theArg,
478 TRestoringMap::const_iterator anIter = theMap.find(theArg);
479 if(anIter == theMap.end()) {
480 if(MYDEBUG) MESSAGE("Storable::Init >> there is no value for "<<theArg);
481 if(theIsFind != NULL)
483 //throw std::logic_error(string("Storable::Init >> there is no value for ") + theArg);
484 static QString BAD_VALUE("NULL");
487 if(theIsFind != NULL)
489 return anIter->second;
493 //---------------------------------------------------------------
496 ::FindValue(const TRestoringMap& theMap,
497 const std::string& theArg,
498 const QString& theDefaultValue)
500 bool anIsFound = false;
501 QString aValue = FindValue(theMap,theArg,&anIsFound);
504 return theDefaultValue;
508 //---------------------------------------------------------------------------
509 PortableServer::ServantBase_var
510 GetServant(CORBA::Object_ptr theObject)
512 if(CORBA::is_nil(theObject))
515 PortableServer::POA_ptr aPOA = Base_i::GetPOA();
516 PortableServer::Servant aServant = aPOA->reference_to_servant(theObject);
519 INFOS("GetServant - Unknown exception was occured!!!");
525 //---------------------------------------------------------------------------
527 SObjectToObject(SALOMEDS::SObject_ptr theSObject)
529 SALOMEDS::GenericAttribute_var anAttr;
530 CORBA::Object_var anObject;
531 if(CORBA::is_nil(theSObject))
534 if(theSObject->FindAttribute(anAttr, "AttributeIOR")){
535 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
536 CORBA::String_var aValue = anIOR->Value();
537 CORBA::ORB_ptr anORB = Base_i::GetORB();
538 if(strcmp(aValue,"") != 0)
539 anObject = anORB->string_to_object(aValue);
542 INFOS("SObjectToObject - Unknown exception was occured!!!");
547 //---------------------------------------------------------------------------
549 ClientSObjectToObject(_PTR(SObject) theSObject)
551 _PTR(GenericAttribute) anAttr;
552 CORBA::Object_var anObject;
556 if(theSObject->FindAttribute(anAttr, "AttributeIOR")){
557 _PTR(AttributeIOR) anIOR = anAttr;
558 CORBA::String_var aValue = anIOR->Value().c_str();
559 CORBA::ORB_ptr anORB = Base_i::GetORB();
560 if(strcmp(aValue,"") != 0)
561 anObject = anORB->string_to_object(aValue);
564 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
570 //---------------------------------------------------------------------------
572 CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
573 const std::string& theFatherEntry,
574 const std::string& theIconName,
575 const std::string& theIOR,
576 const std::string& theName,
577 const std::string& thePersistentRef,
578 const std::string& theComment,
579 CORBA::Boolean theCreateNew)
581 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
582 SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str());
583 SALOMEDS::SObject_var aNewSObject;
585 aNewSObject = aStudyBuilder->NewObject(aFather);
587 aNewSObject = aFather;
588 SALOMEDS::GenericAttribute_var anAttr;
589 if(theIOR != NO_IOR){
590 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeIOR");
591 SALOMEDS::AttributeIOR_var aCustomAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
592 aCustomAttr->SetValue(theIOR.c_str());
594 if(theName != NO_NAME){
595 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeName");
596 SALOMEDS::AttributeName_var aCustomAttr = SALOMEDS::AttributeName::_narrow(anAttr);
597 aCustomAttr->SetValue(theName.c_str());
599 if(thePersistentRef != NO_PERFSITENT_REF){
600 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePersistentRef");
601 SALOMEDS::AttributePersistentRef_var aCustomAttr = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
602 aCustomAttr->SetValue(thePersistentRef.c_str());
604 if(theComment != NO_COMMENT){
605 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeString");
606 SALOMEDS::AttributeString_var aCustomAttr = SALOMEDS::AttributeString::_narrow(anAttr);
607 aCustomAttr->SetValue(theComment.c_str());
609 if(theIconName != NO_ICON){
610 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePixMap");
611 SALOMEDS::AttributePixMap_var aCustomAttr = SALOMEDS::AttributePixMap::_narrow(anAttr);
612 aCustomAttr->SetPixMap(theIconName.c_str());
614 CORBA::String_var anEntry = aNewSObject->GetID();
615 std::string aRet(anEntry);
617 INFOS("CreateAttributes - StudyId = "<<theStudyDocument->StudyId()<<"; anEntry = "<<aRet<<"; IOR = '"<<theIOR<<"'");
622 CreateAttributes(_PTR(Study) theStudyDocument,
623 const std::string& theFatherEntry,
624 const std::string& theIconName,
625 const std::string& theIOR,
626 const std::string& theName,
627 const std::string& thePersistentRef,
628 const std::string& theComment,
629 CORBA::Boolean theCreateNew)
631 _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
632 _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry);
633 _PTR(SObject) aNewSObject;
636 aNewSObject = aStudyBuilder->NewObject(aFather);
639 aNewSObject = aFather;
641 _PTR(GenericAttribute) anAttr;
642 if (theIOR != NO_IOR) {
643 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeIOR");
644 _PTR(AttributeIOR) aCustomAttr (anAttr);
645 aCustomAttr->SetValue(theIOR);
647 if (theName != NO_NAME) {
648 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeName");
649 _PTR(AttributeName) aCustomAttr (anAttr);
650 aCustomAttr->SetValue(theName);
652 if (thePersistentRef != NO_PERFSITENT_REF) {
653 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePersistentRef");
654 _PTR(AttributePersistentRef) aCustomAttr (anAttr);
655 aCustomAttr->SetValue(thePersistentRef);
657 if (theComment != NO_COMMENT) {
658 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeString");
659 _PTR(AttributeString) aCustomAttr (anAttr);
660 aCustomAttr->SetValue(theComment);
662 if (theIconName != NO_ICON) {
663 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePixMap");
664 _PTR(AttributePixMap) aCustomAttr (anAttr);
665 aCustomAttr->SetPixMap(theIconName);
667 std::string aRet = aNewSObject->GetID();
669 INFOS("CreateAttributes - StudyId = " << theStudyDocument->StudyId()
670 << "; anEntry = " << aRet << "; IOR = '" << theIOR << "'");
675 //---------------------------------------------------------------
677 GenerateName(const std::string& theFmt, int theId)
681 aName.sprintf("%s:%d", theFmt.c_str(), theId);
683 aName.sprintf("%s", theFmt.c_str());
688 //---------------------------------------------------------------
689 SALOMEDS::StudyManager_var
692 static SALOMEDS::StudyManager_var aStudyManager;
693 if(CORBA::is_nil(aStudyManager)){
694 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
695 CORBA::Object_var anObject = aNamingService->Resolve("/myStudyManager");
696 aStudyManager = SALOMEDS::StudyManager::_narrow(anObject);
698 return aStudyManager;
702 //---------------------------------------------------------------
704 GetDSStudy(_PTR(Study) theStudy)
706 int aStudyID = theStudy->StudyId();
707 return GetStudyManager()->GetStudyByID(aStudyID);
711 //---------------------------------------------------------------
712 struct TGetStudyEvent: public SALOME_Event
714 SALOMEDS::Study_var myStudy;
716 typedef SalomeApp_Study* TResult;
719 TGetStudyEvent(SALOMEDS::Study_ptr theStudy):
720 myStudy(SALOMEDS::Study::_duplicate(theStudy)),
728 if(CORBA::is_nil(myStudy))
731 int aStudyId = myStudy->StudyId();
732 SUIT_Session* aSession = SUIT_Session::session();
733 QPtrList<SUIT_Application> anApplications = aSession->applications();
734 QPtrListIterator<SUIT_Application> anIter (anApplications);
735 while (SUIT_Application* anApp = anIter.current()) {
737 if (SUIT_Study* aSStudy = anApp->activeStudy()) {
738 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
739 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
740 if (aStudyId == aCStudy->StudyId()) {
752 //---------------------------------------------------------------
754 GetGUIStudy(SALOMEDS::Study_ptr theStudy)
756 return ProcessEvent(new TGetStudyEvent(theStudy));
760 //---------------------------------------------------------------
762 GetStudy(SALOMEDS::Study_ptr theStudy)
764 if(SalomeApp_Study* aStudy = ProcessEvent(new TGetStudyEvent(theStudy)))
765 return aStudy->studyDS();
767 return _PTR(Study)();
771 //---------------------------------------------------------------
772 SALOMEDS::SObject_var
773 GetSObject( _PTR(SObject) obj )
775 _PTR(Study) aStudy = obj->GetStudy();
776 SALOMEDS::Study_var aSalomeDSStudy = GetDSStudy( aStudy );
777 std::string id = obj->GetID();
778 return aSalomeDSStudy->FindObjectID( id.c_str() );
781 //---------------------------------------------------------------
783 GetClientSObject(SALOMEDS::SObject_ptr theSObject,
784 _PTR(Study) theStudy)
786 CORBA::String_var anEntry = theSObject->GetID();
787 return theStudy->FindObjectID( anEntry.in() );
791 //---------------------------------------------------------------
793 RemoveFromStudy (SALOMEDS::SObject_ptr theSObject,
795 bool theDestroySubObjects)
797 if (theSObject->_is_nil()) return;
799 SALOMEDS::Study_var aStudyDocument = theSObject->GetStudy();
800 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDocument->NewBuilder();
802 aStudyBuilder->RemoveAttribute(theSObject,"AttributeIOR");
806 // Remove possible sub-objects
807 SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(theSObject);
808 for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
809 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
810 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
811 if (CORBA::is_nil(aChildObj)) continue;
813 VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(aChildObj);
814 if (CORBA::is_nil(aRemovableObject)) continue;
816 aRemovableObject->RemoveFromStudy();
819 // asl, fix for PAL10455: Remove references to SObject
820 SALOMEDS::Study::ListOfSObject_var aRefs = aStudyDocument->FindDependances( theSObject );
821 for( int i=0, n=aRefs->length(); i<n; i++ )
823 SALOMEDS::SObject_var o = aRefs[i];
824 if( o->GetFatherComponent()->ComponentDataType()==theSObject->GetFatherComponent()->ComponentDataType() )
826 aStudyBuilder->RemoveReference( o );
827 aStudyBuilder->RemoveObjectWithChildren( o );
831 // Remove the SObject itself
832 aStudyBuilder->RemoveObjectWithChildren(theSObject);
836 //---------------------------------------------------------------
838 RemoveFromStudy (_PTR(SObject) theSObject,
840 bool theDestroySubObjects)
842 if (!theSObject) return;
844 _PTR(Study) aStudyDocument = theSObject->GetStudy();
845 _PTR(StudyBuilder) aStudyBuilder = aStudyDocument->NewBuilder();
847 aStudyBuilder->RemoveAttribute(theSObject,"AttributeIOR");
851 // Remove possible sub-objects
852 _PTR(ChildIterator) aChildIter = aStudyDocument->NewChildIterator(theSObject);
853 for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
854 _PTR(SObject) aChildSObject = aChildIter->Value();
855 CORBA::Object_var aChildObj = VISU::ClientSObjectToObject(aChildSObject);
856 if (CORBA::is_nil(aChildObj))
859 VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(aChildObj);
860 if (CORBA::is_nil(aRemovableObject))
863 aRemovableObject->RemoveFromStudy();
866 // Remove the SObject itself
867 aStudyBuilder->RemoveObjectWithChildren(theSObject);