1 // Copyright (C) 2010-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File : PARAVIS_Gen_i.cc
20 // Author : Vitaly Smetannikov
25 #include "PARAVIS_Gen_i.hh"
28 #include <omnithread.h>
29 #include CORBA_SERVER_HEADER(SALOME_Session)
30 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
32 #include <CAM_Module.h>
33 #include "PVGUI_Module.h"
34 #include <SalomeApp_Application.h>
35 #include <SUIT_ResourceMgr.h>
37 #include <SALOMEDS_Tool.hxx>
40 #include "PV_Events.h"
43 #include "QDomDocument"
45 #include "QDomElement"
48 #include "QTextStream"
50 #include "vtkWrapIDL.h"
53 #include <pqServerResource.h>
57 static int MYDEBUG = 1;
59 static int MYDEBUG = 0;
64 extern PARAVIS::PARAVIS_Base_i* CreateInstance(::vtkObjectBase* Inst, const QString&);
67 PARAVIS_I_EXPORT PARAVIS::PARAVIS_Gen_ptr GetImpl(CORBA::ORB_ptr theORB,
68 PortableServer::POA_ptr thePOA,
69 SALOME_NamingService* theNamingService,
72 if(MYDEBUG) MESSAGE("extern 'C' GetImpl");
73 PARAVIS::PARAVIS_Gen_i *aPARAVIS_Gen = new PARAVIS::PARAVIS_Gen_i(theORB,
77 return aPARAVIS_Gen->_this();
85 const char* checkNullStr(const char* theStr)
87 if (strcmp(theStr, "NULL") == 0)
93 std::string tabify( const std::string& source, bool isTabify )
95 std::string result = source;
96 if ( isTabify && !result.empty() ) {
97 std::string caret = "\n";
98 int idx = result.rfind( caret );
99 while ( idx != std::string::npos ) {
100 result.replace( idx, caret.size(), "\n\t" );
101 idx = result.rfind( caret, idx-1 );
103 result.insert(0, "\t" );
108 PARAVIS_Base_i::~PARAVIS_Base_i() {
109 if(mySmartPointer != NULL) mySmartPointer->Delete();
112 void PARAVIS_Base_i::Init(::vtkObjectBase* base) {
113 if (mySmartPointer != NULL) mySmartPointer->Delete();
114 mySmartPointer = base;
117 ::vtkObjectBase* PARAVIS_Base_i::getVTKObject(PARAVIS_Base_ptr theBase) {
118 PARAVIS_Base_i* aBase = GET_SERVANT(theBase);
119 return (aBase != NULL)? aBase->getVTKObject() : NULL;
122 CORBA::Boolean PARAVIS_Base_i::IsSame(PARAVIS_Base_ptr theOther)
124 PARAVIS_Base_i* aBase = GET_SERVANT(theOther);
127 return mySmartPointer.GetPointer() == aBase->getVTKObject();
133 PARAVIS_Gen_i* PARAVIS_Gen_i::myParavisGenImpl;
134 CORBA::ORB_var PARAVIS_Gen_i::myOrb;
135 PortableServer::POA_var PARAVIS_Gen_i::myPoa;
136 SALOME_LifeCycleCORBA* PARAVIS_Gen_i::myEnginesLifeCycle;
137 SALOME_NamingService* PARAVIS_Gen_i::myNamingService;
138 QMutex* PARAVIS_Gen_i::myMutex;
139 SalomeApp_Application* PARAVIS_Gen_i::mySalomeApp = 0;
142 //----------------------------------------------------------------------------
143 PARAVIS_Gen_i::PARAVIS_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
144 SALOME_NamingService* theNamingService, QMutex* theMutex) :
145 Engines_Component_i()
147 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PARAVIS_Gen_i");
148 if (mySalomeApp) return;
151 myOrb = CORBA::ORB::_duplicate(theORB);
152 myPoa = PortableServer::POA::_duplicate(thePOA);
153 myParavisGenImpl = this;
154 myNamingService = theNamingService;
156 static SALOME_LifeCycleCORBA aEnginesLifeCycle(theNamingService);
157 myEnginesLifeCycle = &aEnginesLifeCycle;
159 CORBA::Object_var anObj = myNamingService->Resolve("/myStudyManager");
160 if (!CORBA::is_nil(anObj)) {
161 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(anObj);
162 SALOMEDS::ListOfOpenStudies_var aListOfOpenStudies = aStudyManager->GetOpenStudies();
163 if(aListOfOpenStudies->length() > 0) {
164 CORBA::String_var aStudyName = aListOfOpenStudies[0];
165 myStudyDocument = aStudyManager->GetStudyByName(aStudyName);
166 if (!myStudyDocument->_is_nil()) {
167 mySalomeApp = ProcessEvent(new TGetGUIApplication(myStudyDocument->StudyId()));
168 if(!myStudyDocument->GetProperties()->IsLocked())
169 FindOrCreateParaVisComponent(myStudyDocument);
172 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PARAVIS_Gen_i : there is no opened study in StudyManager !!!");
174 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PARAVIS_Gen_i : Can't find StudyManager !!!");
178 //----------------------------------------------------------------------------
179 PARAVIS_Gen_i::~PARAVIS_Gen_i()
181 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::~PARAVIS_Gen_i");
184 //----------------------------------------------------------------------------
185 char* PARAVIS_Gen_i::GetIOR()
188 CORBA::Object_var anObject = _this();
189 CORBA::String_var anIOR = myOrb->object_to_string(anObject);
192 return CORBA::string_dup(myIOR.c_str());
195 //----------------------------------------------------------------------------
196 void PARAVIS_Gen_i::ImportFile(const char* theFileName)
198 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::ImportFile: " <<theFileName);
199 ProcessVoidEvent(new TImportFile(mySalomeApp, theFileName));
202 void PARAVIS_Gen_i::ExecuteScript(const char* script)
204 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::ExecuteScript: " <<script);
205 ProcessVoidEvent(new TExecuteScript(mySalomeApp, script));
208 //----------------------------------------------------------------------------
209 char* PARAVIS_Gen_i::GetTrace()
211 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PrintTrace: ");
212 return CORBA::string_dup(ProcessEvent(new TGetTrace(mySalomeApp)).c_str());
215 //----------------------------------------------------------------------------
216 void PARAVIS_Gen_i::SaveTrace(const char* theFileName)
218 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::SaveTrace: " <<theFileName);
219 ProcessVoidEvent(new TSaveTrace(mySalomeApp, theFileName));
222 //----------------------------------------------------------------------------
223 void processElements(QDomNode& thePropertyNode, QStringList& theFileNames, const char* theNewPath, bool theRestore)
225 QDomNode aElementNode = thePropertyNode.firstChild();
226 while (aElementNode.isElement()) {
227 QDomElement aElement = aElementNode.toElement();
228 if (aElement.tagName() == "Element") {
229 QString aIndex = aElement.attribute("index");
231 QString aValue = aElement.attribute("value");
232 if (!aValue.isNull()) {
234 QFileInfo aFInfo(aValue);
235 if (aFInfo.exists()) {
236 theFileNames<<aValue;
237 aElement.setAttribute("value", aFInfo.fileName());
242 aElement.setAttribute("value", QString(theNewPath) + aValue);
247 aElementNode = aElementNode.nextSibling();
252 //----------------------------------------------------------------------------
253 void processProperties(QDomNode& theProxyNode, QStringList& theFileNames, const char* theNewPath, bool theRestore)
255 QDomNode aPropertyNode = theProxyNode.firstChild();
256 while (aPropertyNode.isElement()) {
257 QDomElement aProperty = aPropertyNode.toElement();
258 QString aName = aProperty.attribute("name");
259 if ((aName == "FileName") || (aName == "FileNameInfo") || (aName == "FileNames")) {
260 processElements(aPropertyNode, theFileNames, theNewPath, theRestore);
262 aPropertyNode = aPropertyNode.nextSibling();
267 //----------------------------------------------------------------------------
268 void processProxies(QDomNode& theNode, QStringList& theFileNames, const char* theNewPath, bool theRestore)
270 QDomNode aProxyNode = theNode.firstChild();
271 while (aProxyNode.isElement()) {
272 QDomElement aProxy = aProxyNode.toElement();
273 if (aProxy.tagName() == "Proxy") {
274 QString aGroup = aProxy.attribute("group");
275 if (aGroup == "sources") {
276 processProperties(aProxyNode, theFileNames, theNewPath, theRestore);
279 aProxyNode = aProxyNode.nextSibling();
283 //----------------------------------------------------------------------------
284 bool processAllFilesInState(const char* aFileName, QStringList& theFileNames,
285 const char* theNewPath, bool theRestore = false)
287 QFile aFile(aFileName);
288 if (!aFile.open(QFile::ReadOnly)) {
289 MESSAGE("Can't open state file "<<aFileName);
293 bool aRes = aDoc.setContent(&aFile);
297 MESSAGE("File "<<aFileName<<" is not XML document");
301 QDomElement aRoot = aDoc.documentElement();
302 if ( aRoot.isNull() ) {
303 MESSAGE( "Invalid XML root" );
307 QDomNode aNode = aRoot.firstChild();
308 while (aRes && !aNode.isNull() ) {
309 aRes = aNode.isElement();
311 QDomElement aSection = aNode.toElement();
312 if (aSection.tagName() == "ServerManagerState") {
313 processProxies(aNode, theFileNames, theNewPath, theRestore);
316 aNode = aNode.nextSibling();
318 if (!aFile.open(QFile::WriteOnly | QFile::Truncate)) {
319 MESSAGE("Can't open state file "<<aFileName<<" for writing");
322 QTextStream out(&aFile);
329 //----------------------------------------------------------------------------
330 QStringList getAllSavedStates(SALOMEDS::SComponent_ptr theComponent,
331 QString theNewPath = QString())
333 QStringList aStateFiles;
335 if (!CORBA::is_nil(theComponent)) {
336 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
337 SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
338 for (; anIter->More(); anIter->Next()) {
339 SALOMEDS::SObject_var aSObj = anIter->Value();
340 SALOMEDS::GenericAttribute_var anAttr;
341 if (!aSObj->FindAttribute(anAttr, "AttributeLocalID")) {
344 SALOMEDS::AttributeLocalID_var anID = SALOMEDS::AttributeLocalID::_narrow(anAttr);
345 if (!anID->Value() == PVSTATEID) {
348 if (aSObj->FindAttribute(anAttr, "AttributeString")) {
349 SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
350 QString aStateFile(aStringAttr->Value());
351 printf("getAllSavedStates, aStateFile = %s\n", aStateFile.toLatin1().constData());
352 // Replace the old path with the new one
353 if (!theNewPath.isEmpty()) {
354 QFileInfo aFileInfo(aStateFile);
355 QString aPath = aFileInfo.path();
356 aStateFile.replace(aPath, theNewPath);
357 aStringAttr->SetValue(aStateFile.toLatin1().constData());
359 printf("getAllSavedStates, aStateFile NEW = %s\n", aStateFile.toLatin1().constData());
361 aStateFiles<<aStateFile;
369 SALOMEDS::TMPFile* SaveState(long thePID, SalomeApp_Application* theApp, SALOMEDS::SComponent_ptr theComponent,
370 const char* theURL, bool isMultiFile)
372 std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
374 std::ostringstream aStream;
375 aStream<<"paravisstate:"<<thePID;
376 std::string aFileName = "_" + aStream.str();
377 if(MYDEBUG) MESSAGE("aFileName = '"<<aFileName);
379 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
381 std::string aFile = aTmpDir + aFileName;
382 ProcessVoidEvent(new TSaveStateFile(theApp, aFile.c_str()));
385 QStringList aSavedStates = getAllSavedStates(theComponent);
387 // Collect all files from state
388 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
389 int aSavingType = aResourceMgr->integerValue( "PARAVIS", "savestate_type", 0 );
391 QStringList aFileNames;
394 switch (aSavingType) {
395 case 0: // Save referenced files only for builin server
397 MESSAGE("Save as built in;")
398 bool aIsBuiltIn = true;
399 pqServer* aServer = ProcessEvent(new TGetActiveServer(theApp));
401 aIsBuiltIn != aServer->isRemote();
405 // Find referenced files and collect their paths nullyfying references:
408 foreach (QString aState, aSavedStates) {
409 processAllFilesInState(aState.toLatin1().constData(), aFileNames, 0);
413 processAllFilesInState(aFile.c_str(), aFileNames, 0);
415 SetRestoreParam(theComponent, true);
417 SetRestoreParam(theComponent, false);
421 case 1: //Save referenced files when they are accessible
423 // Find referenced files and collect their paths nullyfying references
426 foreach (QString aState, aSavedStates) {
427 processAllFilesInState(aState.toLatin1().constData(), aFileNames, 0);
431 processAllFilesInState(aFile.c_str(), aFileNames, 0);
432 SetRestoreParam(theComponent, true);
435 case 2: //Never save referenced files
436 SetRestoreParam(theComponent, false);
441 foreach (QString aSavedState, aSavedStates) {
442 aFileNames<<aSavedState;
445 // Add main state to the end of the list
446 aFileNames<<QString(aFile.c_str());
448 // File names for main state and its data files
449 foreach(QString aFile, aFileNames) {
450 QFileInfo aInfo(aFile);
451 aNames<<aInfo.fileName();
453 SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames);
454 SALOMEDS::ListOfFileNames_var aListOfNames = GetListOfFileNames(aNames);
456 aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFileNames.in(), aListOfNames.in());
458 return aStreamFile._retn();
461 //----------------------------------------------------------------------------
462 SALOMEDS::TMPFile* PARAVIS_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
463 const char* theURL, bool isMultiFile)
465 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::Save - theURL = '"<<theURL<<"'");
466 return SaveState((long) this, mySalomeApp, theComponent, theURL, isMultiFile);
469 //----------------------------------------------------------------------------
470 SALOMEDS::TMPFile* PARAVIS_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
471 const char* theURL, bool isMultiFile)
473 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::Save - theURL = '"<<theURL<<"'");
474 return SaveState((long) this, mySalomeApp, theComponent, theURL, isMultiFile);
478 //----------------------------------------------------------------------------
479 bool LoadState(SalomeApp_Application* theApp, SALOMEDS::SComponent_ptr theComponent,
480 const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile)
482 std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
483 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::Load - "<<aTmpDir);
485 SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false);
486 if (aSeq->length() == 0)
489 bool aRestore = GetRestoreParam(theComponent);
490 MESSAGE("PARAVIS_Gen_i::Restore path - "<<aRestore);
492 // Process main state
493 std::string aFile = aTmpDir + std::string(aSeq[aSeq->length() - 1]);
494 QStringList aEmptyList;
495 processAllFilesInState(aFile.c_str(), aEmptyList, aTmpDir.c_str(), aRestore);
496 ProcessVoidEvent(new TLoadStateFile(theApp, aFile.c_str()));
498 // Process saved states
499 QStringList aSavedStates = getAllSavedStates(theComponent, QString(aTmpDir.c_str()));
500 foreach(QString aState, aSavedStates) {
501 processAllFilesInState(aState.toLatin1().constData(),
502 aEmptyList, aTmpDir.c_str(), aRestore);
508 //----------------------------------------------------------------------------
509 bool PARAVIS_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream,
510 const char* theURL, bool isMultiFile)
512 return LoadState(mySalomeApp, theComponent, theStream, theURL, isMultiFile);
515 //----------------------------------------------------------------------------
516 bool PARAVIS_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
517 const SALOMEDS::TMPFile& theStream,
518 const char* theURL, bool isMultiFile)
520 return LoadState(mySalomeApp, theComponent, theStream, theURL, isMultiFile);
523 //----------------------------------------------------------------------------
524 void PARAVIS_Gen_i::Close(SALOMEDS::SComponent_ptr IORSComponent)
528 //----------------------------------------------------------------------------
529 char* PARAVIS_Gen_i::ComponentDataType()
531 return CORBA::string_dup("PARAVIS");
534 //----------------------------------------------------------------------------
535 char* PARAVIS_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString,
536 CORBA::Boolean isMultiFile, CORBA::Boolean isASCII)
538 CORBA::String_var aString("");
539 return aString._retn();
542 //----------------------------------------------------------------------------
543 char* PARAVIS_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
544 const char* aLocalPersistentID,
545 CORBA::Boolean isMultiFile,
546 CORBA::Boolean isASCII)
548 CORBA::String_var aString("");
549 return aString._retn();
552 //----------------------------------------------------------------------------
553 bool PARAVIS_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
558 //----------------------------------------------------------------------------
559 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
560 SALOMEDS::SObject_ptr theSObject,
561 CORBA::Object_ptr theObject,
563 throw (SALOME::SALOME_Exception)
565 SALOMEDS::SObject_var aResultSO;
566 return aResultSO._retn();
569 //----------------------------------------------------------------------------
570 CORBA::Boolean PARAVIS_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
575 //----------------------------------------------------------------------------
576 SALOMEDS::TMPFile* PARAVIS_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID)
578 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
579 return aStreamFile._retn();
582 //----------------------------------------------------------------------------
583 CORBA::Boolean PARAVIS_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID)
588 //----------------------------------------------------------------------------
589 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
590 CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject)
592 return SALOMEDS::SObject::_nil();
595 //----------------------------------------------------------------------------
596 PARAVIS::string_array* PARAVIS_Gen_i::GetClassesList()
599 for (k = 0; strcmp(wrapped_classes[k], "") != 0; k++);
600 PARAVIS::string_array_var aNames = new PARAVIS::string_array();
602 for (CORBA::ULong i = 0; i < k; i++)
603 aNames[i] = CORBA::string_dup(wrapped_classes[i]);
604 return aNames._retn();
607 //----------------------------------------------------------------------------
608 PARAVIS_Base_ptr PARAVIS_Gen_i::CreateClass(const char* theClassName)
610 PARAVIS::PARAVIS_Base_i* aClass = CreateInstance(NULL, QString(theClassName));
611 return aClass->_this();
614 //----------------------------------------------------------------------------
615 void PARAVIS_Gen_i::GetConnectionParameters(CORBA::Long& theId,
616 CORBA::String_out theDHost, CORBA::Long& theDPort,
617 CORBA::String_out theRHost, CORBA::Long& theRPort,
618 CORBA::Long& theReversed)
620 pqServer* aServer = ProcessEvent(new TGetActiveServer(mySalomeApp));
622 theId = static_cast<int>(aServer->GetConnectionID());
624 pqServerResource serverRes = aServer->getResource();
625 theReversed = (serverRes.scheme() == "csrc" || serverRes.scheme() == "cdsrsrc")? 1 : 0;
627 theDPort = serverRes.dataServerPort() < 0? serverRes.port() : serverRes.dataServerPort();
628 theRPort = serverRes.renderServerPort() < 0 ? 0 : serverRes.renderServerPort();
630 QString dsHost = serverRes.dataServerHost().isEmpty()? serverRes.host() : serverRes.dataServerHost();
631 QString rsHost = serverRes.renderServerHost();
633 theDHost = CORBA::string_dup(qPrintable(dsHost));
634 theRHost = CORBA::string_dup(qPrintable(rsHost));
639 //----------------------------------------------------------------------------
640 Engines::TMPFile* PARAVIS_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
641 CORBA::Boolean theIsPublished,
642 CORBA::Boolean theIsMultiFile,
643 CORBA::Boolean& theIsValidScript)
645 theIsValidScript = true;
647 if ( theIsMultiFile )
648 aResult += "\ndef RebuildData(theStudy):\n";
649 aResult += tabify(ProcessEvent(new TGetTrace(mySalomeApp)), theIsMultiFile );
650 if ( theIsMultiFile )
651 aResult += "\n\tpass\n";
652 CORBA::ULong aSize = aResult.size() + 1;
653 char* aBuffer = new char[aSize];
654 memset(aBuffer, 0, aSize);
655 strcpy(aBuffer, &aResult[0]);
656 Engines::TMPFile_var aDump = new Engines::TMPFile(aSize,aSize,(CORBA::Octet*)aBuffer,1);
657 return aDump._retn();
660 //----------------------------------------------------------------------------
661 void PARAVIS_Gen_i::ActivateModule()
663 ProcessVoidEvent(new TActivateModule(mySalomeApp));
666 //----------------------------------------------------------------------------
667 struct TSetStudyEvent: public SALOME_Event {
668 std::string myStudyName;
669 typedef SalomeApp_Application* TResult;
672 TSetStudyEvent(const std::string theStudyName):myStudyName(theStudyName), myResult(0) {}
673 virtual void Execute()
675 bool isActive = false;
676 SUIT_Session* aSession = SUIT_Session::session();
677 QList<SUIT_Application*> anApplications = aSession->applications();
678 QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
679 SUIT_Application* aFirstApp = *anIter;
680 while (anIter != anApplications.end()) {
681 SUIT_Application* anApp = *anIter;
682 if (SUIT_Study* aSStudy = anApp->activeStudy()) {
683 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
684 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
685 if(MYDEBUG) MESSAGE("There is an application with active study : StudyId = "
686 << aCStudy->StudyId() << "; Name = '" << aCStudy->Name() << "'");
687 if (myStudyName == aCStudy->Name()) {
696 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aFirstApp);
698 MESSAGE("!!! anApp->onLoadDoc(myStudyName) !!!");
699 // Has to be loaded in an empty or in a new application
700 anApp->onLoadDoc(myStudyName.c_str());
706 void PARAVIS_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
708 if (!CORBA::is_nil(theStudy)) {
709 CORBA::String_var aName = theStudy->Name();
710 std::string aStudyName (aName.in());
712 myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
713 SalomeApp_Application* anApp = ProcessEvent(new TSetStudyEvent(aStudyName));
717 INFOS("CORBA::is_nil(theStudy)");
722 //----------------------------------------------------------------------------
723 SALOMEDS::Study_ptr PARAVIS_Gen_i::GetCurrentStudy()
725 return SALOMEDS::Study::_duplicate(myStudyDocument);