1 // Copyright (C) 2010-2014 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, or (at your option) any later version.
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"
26 #include "PARAVIS_version.h"
29 #include <omnithread.h>
30 #include CORBA_SERVER_HEADER(SALOME_Session)
31 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
33 #include <CAM_Module.h>
34 #include "PVGUI_Module.h"
35 #include <SalomeApp_Application.h>
36 #include <SUIT_ResourceMgr.h>
38 #include <SALOMEDS_Tool.hxx>
41 #include "PV_Events.h"
44 #include "QDomDocument"
46 #include "QDomElement"
49 #include "QTextStream"
51 #ifdef PARAVIS_WITH_FULL_CORBA
52 // List of VTK classes wrapped into IDL:
53 # include "vtkWrapIDL.h"
57 #include <pqServerResource.h>
61 static int MYDEBUG = 1;
63 static int MYDEBUG = 0;
68 extern PARAVIS::PARAVIS_Base_i* CreateInstance(::vtkObjectBase* Inst, const QString&);
71 PARAVIS_I_EXPORT PARAVIS::PARAVIS_Gen_ptr GetImpl(CORBA::ORB_ptr theORB,
72 PortableServer::POA_ptr thePOA,
73 SALOME_NamingService* theNamingService,
76 if(MYDEBUG) MESSAGE("extern 'C' GetImpl");
77 PARAVIS::PARAVIS_Gen_i *aPARAVIS_Gen = new PARAVIS::PARAVIS_Gen_i(theORB,
81 return aPARAVIS_Gen->_this();
89 const char* checkNullStr(const char* theStr)
91 if (strcmp(theStr, "NULL") == 0)
97 std::string tabify( const std::string& source, bool isTabify )
99 std::string result = source;
100 if ( isTabify && !result.empty() ) {
101 std::string caret = "\n";
102 int idx = result.rfind( caret );
103 while ( idx != std::string::npos ) {
104 result.replace( idx, caret.size(), "\n\t" );
105 idx = result.rfind( caret, idx-1 );
107 result.insert(0, "\t" );
112 PARAVIS_Base_i::~PARAVIS_Base_i() {
113 if(mySmartPointer != NULL) mySmartPointer->Delete();
116 void PARAVIS_Base_i::Init(::vtkObjectBase* base) {
117 if (mySmartPointer != NULL) mySmartPointer->Delete();
118 mySmartPointer = base;
121 ::vtkObjectBase* PARAVIS_Base_i::getVTKObject(PARAVIS_Base_ptr theBase) {
122 PARAVIS_Base_i* aBase = GET_SERVANT(theBase);
123 return (aBase != NULL)? aBase->getVTKObject() : NULL;
126 CORBA::Boolean PARAVIS_Base_i::IsSame(PARAVIS_Base_ptr theOther)
128 PARAVIS_Base_i* aBase = GET_SERVANT(theOther);
131 return mySmartPointer.GetPointer() == aBase->getVTKObject();
137 PARAVIS_Gen_i* PARAVIS_Gen_i::myParavisGenImpl;
138 CORBA::ORB_var PARAVIS_Gen_i::myOrb;
139 PortableServer::POA_var PARAVIS_Gen_i::myPoa;
140 SALOME_LifeCycleCORBA* PARAVIS_Gen_i::myEnginesLifeCycle;
141 SALOME_NamingService* PARAVIS_Gen_i::myNamingService;
142 QMutex* PARAVIS_Gen_i::myMutex;
143 SalomeApp_Application* PARAVIS_Gen_i::mySalomeApp = 0;
146 //----------------------------------------------------------------------------
147 PARAVIS_Gen_i::PARAVIS_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
148 SALOME_NamingService* theNamingService, QMutex* theMutex) :
149 Engines_Component_i()
151 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PARAVIS_Gen_i");
152 if (mySalomeApp) return;
155 myOrb = CORBA::ORB::_duplicate(theORB);
156 myPoa = PortableServer::POA::_duplicate(thePOA);
157 myParavisGenImpl = this;
158 myNamingService = theNamingService;
160 static SALOME_LifeCycleCORBA aEnginesLifeCycle(theNamingService);
161 myEnginesLifeCycle = &aEnginesLifeCycle;
163 CORBA::Object_var anObj = myNamingService->Resolve("/myStudyManager");
164 if (!CORBA::is_nil(anObj)) {
165 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(anObj);
166 SALOMEDS::ListOfOpenStudies_var aListOfOpenStudies = aStudyManager->GetOpenStudies();
167 if(aListOfOpenStudies->length() > 0) {
168 CORBA::String_var aStudyName = aListOfOpenStudies[0];
169 myStudyDocument = aStudyManager->GetStudyByName(aStudyName);
170 if (!myStudyDocument->_is_nil()) {
171 mySalomeApp = ProcessEvent(new TGetGUIApplication(myStudyDocument->StudyId()));
172 if(!myStudyDocument->GetProperties()->IsLocked())
173 FindOrCreateParaVisComponent(myStudyDocument);
176 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PARAVIS_Gen_i : there is no opened study in StudyManager !!!");
178 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PARAVIS_Gen_i : Can't find StudyManager !!!");
182 //----------------------------------------------------------------------------
183 PARAVIS_Gen_i::~PARAVIS_Gen_i()
185 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::~PARAVIS_Gen_i");
188 //----------------------------------------------------------------------------
189 char* PARAVIS_Gen_i::GetIOR()
192 CORBA::Object_var anObject = _this();
193 CORBA::String_var anIOR = myOrb->object_to_string(anObject);
196 return CORBA::string_dup(myIOR.c_str());
199 //----------------------------------------------------------------------------
200 void PARAVIS_Gen_i::ImportFile(const char* theFileName)
202 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::ImportFile: " <<theFileName);
203 ProcessVoidEvent(new TImportFile(mySalomeApp, theFileName));
206 void PARAVIS_Gen_i::ExecuteScript(const char* script)
208 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::ExecuteScript: " <<script);
209 ProcessVoidEvent(new TExecuteScript(mySalomeApp, script));
212 //----------------------------------------------------------------------------
213 char* PARAVIS_Gen_i::GetTrace()
215 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PrintTrace: ");
216 return CORBA::string_dup(ProcessEvent(new TGetTrace(mySalomeApp)).c_str());
219 //----------------------------------------------------------------------------
220 void PARAVIS_Gen_i::SaveTrace(const char* theFileName)
222 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::SaveTrace: " <<theFileName);
223 ProcessVoidEvent(new TSaveTrace(mySalomeApp, theFileName));
226 //----------------------------------------------------------------------------
227 void processElements(QDomNode& thePropertyNode, QStringList& theFileNames, const char* theNewPath, bool theRestore)
229 QDomNode aElementNode = thePropertyNode.firstChild();
230 while (aElementNode.isElement()) {
231 QDomElement aElement = aElementNode.toElement();
232 if (aElement.tagName() == "Element") {
233 QString aIndex = aElement.attribute("index");
235 QString aValue = aElement.attribute("value");
236 if (!aValue.isNull()) {
238 QFileInfo aFInfo(aValue);
239 if (aFInfo.exists()) {
240 theFileNames<<aValue;
241 aElement.setAttribute("value", aFInfo.fileName());
246 aElement.setAttribute("value", QString(theNewPath) + aValue);
251 aElementNode = aElementNode.nextSibling();
256 //----------------------------------------------------------------------------
257 void processProperties(QDomNode& theProxyNode, QStringList& theFileNames, const char* theNewPath, bool theRestore)
259 QDomNode aPropertyNode = theProxyNode.firstChild();
260 while (aPropertyNode.isElement()) {
261 QDomElement aProperty = aPropertyNode.toElement();
262 QString aName = aProperty.attribute("name");
263 if ((aName == "FileName") || (aName == "FileNameInfo") || (aName == "FileNames")) {
264 processElements(aPropertyNode, theFileNames, theNewPath, theRestore);
266 aPropertyNode = aPropertyNode.nextSibling();
271 //----------------------------------------------------------------------------
272 void processProxies(QDomNode& theNode, QStringList& theFileNames, const char* theNewPath, bool theRestore)
274 QDomNode aProxyNode = theNode.firstChild();
275 while (aProxyNode.isElement()) {
276 QDomElement aProxy = aProxyNode.toElement();
277 if (aProxy.tagName() == "Proxy") {
278 QString aGroup = aProxy.attribute("group");
279 if (aGroup == "sources") {
280 processProperties(aProxyNode, theFileNames, theNewPath, theRestore);
283 aProxyNode = aProxyNode.nextSibling();
287 //----------------------------------------------------------------------------
288 bool processAllFilesInState(const char* aFileName, QStringList& theFileNames,
289 const char* theNewPath, bool theRestore = false)
291 QFile aFile(aFileName);
292 if (!aFile.open(QFile::ReadOnly)) {
293 MESSAGE("Can't open state file "<<aFileName);
297 bool aRes = aDoc.setContent(&aFile);
301 MESSAGE("File "<<aFileName<<" is not XML document");
305 QDomElement aRoot = aDoc.documentElement();
306 if ( aRoot.isNull() ) {
307 MESSAGE( "Invalid XML root" );
311 QDomNode aNode = aRoot.firstChild();
312 while (aRes && !aNode.isNull() ) {
313 aRes = aNode.isElement();
315 QDomElement aSection = aNode.toElement();
316 if (aSection.tagName() == "ServerManagerState") {
317 processProxies(aNode, theFileNames, theNewPath, theRestore);
320 aNode = aNode.nextSibling();
322 if (!aFile.open(QFile::WriteOnly | QFile::Truncate)) {
323 MESSAGE("Can't open state file "<<aFileName<<" for writing");
326 QTextStream out(&aFile);
333 //----------------------------------------------------------------------------
334 QStringList getAllSavedStates(SALOMEDS::SComponent_ptr theComponent,
335 QString theNewPath = QString())
337 QStringList aStateFiles;
339 if (!CORBA::is_nil(theComponent)) {
340 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
341 SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
342 for (; anIter->More(); anIter->Next()) {
343 SALOMEDS::SObject_var aSObj = anIter->Value();
344 SALOMEDS::GenericAttribute_var anAttr;
345 if (!aSObj->FindAttribute(anAttr, "AttributeLocalID")) {
348 SALOMEDS::AttributeLocalID_var anID = SALOMEDS::AttributeLocalID::_narrow(anAttr);
349 if (!anID->Value() == PVSTATEID) {
352 if (aSObj->FindAttribute(anAttr, "AttributeString")) {
353 SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
354 QString aStateFile(aStringAttr->Value());
355 printf("getAllSavedStates, aStateFile = %s\n", aStateFile.toLatin1().constData());
356 // Replace the old path with the new one
357 if (!theNewPath.isEmpty()) {
358 QFileInfo aFileInfo(aStateFile);
359 QString aPath = aFileInfo.path();
360 aStateFile.replace(aPath, theNewPath);
361 aStringAttr->SetValue(aStateFile.toLatin1().constData());
363 printf("getAllSavedStates, aStateFile NEW = %s\n", aStateFile.toLatin1().constData());
365 aStateFiles<<aStateFile;
373 SALOMEDS::TMPFile* SaveState(long thePID, SalomeApp_Application* theApp, SALOMEDS::SComponent_ptr theComponent,
374 const char* theURL, bool isMultiFile)
376 std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
378 std::ostringstream aStream;
379 aStream<<"paravisstate:"<<thePID;
380 std::string aFileName = "_" + aStream.str();
381 if(MYDEBUG) MESSAGE("aFileName = '"<<aFileName);
383 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
385 std::string aFile = aTmpDir + aFileName;
386 ProcessVoidEvent(new TSaveStateFile(theApp, aFile.c_str()));
389 QStringList aSavedStates = getAllSavedStates(theComponent);
391 // Collect all files from state
392 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
393 int aSavingType = aResourceMgr->integerValue( "PARAVIS", "savestate_type", 0 );
395 QStringList aFileNames;
398 switch (aSavingType) {
399 case 0: // Save referenced files only for builin server
401 MESSAGE("Save as built in;")
402 bool aIsBuiltIn = true;
403 pqServer* aServer = ProcessEvent(new TGetActiveServer(theApp));
405 aIsBuiltIn != aServer->isRemote();
409 // Find referenced files and collect their paths nullyfying references:
412 foreach (QString aState, aSavedStates) {
413 processAllFilesInState(aState.toLatin1().constData(), aFileNames, 0);
417 processAllFilesInState(aFile.c_str(), aFileNames, 0);
419 SetRestoreParam(theComponent, true);
421 SetRestoreParam(theComponent, false);
425 case 1: //Save referenced files when they are accessible
427 // Find referenced files and collect their paths nullyfying references
430 foreach (QString aState, aSavedStates) {
431 processAllFilesInState(aState.toLatin1().constData(), aFileNames, 0);
435 processAllFilesInState(aFile.c_str(), aFileNames, 0);
436 SetRestoreParam(theComponent, true);
439 case 2: //Never save referenced files
440 SetRestoreParam(theComponent, false);
445 foreach (QString aSavedState, aSavedStates) {
446 aFileNames<<aSavedState;
449 // Add main state to the end of the list
450 aFileNames<<QString(aFile.c_str());
452 // File names for main state and its data files
453 foreach(QString aFile, aFileNames) {
454 QFileInfo aInfo(aFile);
455 aNames<<aInfo.fileName();
457 SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames);
458 SALOMEDS::ListOfFileNames_var aListOfNames = GetListOfFileNames(aNames);
460 aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFileNames.in(), aListOfNames.in());
462 return aStreamFile._retn();
465 //----------------------------------------------------------------------------
466 SALOMEDS::TMPFile* PARAVIS_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
467 const char* theURL, bool isMultiFile)
469 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::Save - theURL = '"<<theURL<<"'");
470 return SaveState((long) this, mySalomeApp, theComponent, theURL, isMultiFile);
473 //----------------------------------------------------------------------------
474 SALOMEDS::TMPFile* PARAVIS_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
475 const char* theURL, bool isMultiFile)
477 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::Save - theURL = '"<<theURL<<"'");
478 return SaveState((long) this, mySalomeApp, theComponent, theURL, isMultiFile);
482 //----------------------------------------------------------------------------
483 bool LoadState(SalomeApp_Application* theApp, SALOMEDS::SComponent_ptr theComponent,
484 const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile)
486 std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
487 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::Load - "<<aTmpDir);
489 SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false);
490 if (aSeq->length() == 0)
493 bool aRestore = GetRestoreParam(theComponent);
494 MESSAGE("PARAVIS_Gen_i::Restore path - "<<aRestore);
496 // Process main state
497 std::string aFile = aTmpDir + std::string(aSeq[aSeq->length() - 1]);
498 QStringList aEmptyList;
499 processAllFilesInState(aFile.c_str(), aEmptyList, aTmpDir.c_str(), aRestore);
500 ProcessVoidEvent(new TLoadStateFile(theApp, aFile.c_str()));
502 // Process saved states
503 QStringList aSavedStates = getAllSavedStates(theComponent, QString(aTmpDir.c_str()));
504 foreach(QString aState, aSavedStates) {
505 processAllFilesInState(aState.toLatin1().constData(),
506 aEmptyList, aTmpDir.c_str(), aRestore);
512 //----------------------------------------------------------------------------
513 bool PARAVIS_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream,
514 const char* theURL, bool isMultiFile)
516 return LoadState(mySalomeApp, theComponent, theStream, theURL, isMultiFile);
519 //----------------------------------------------------------------------------
520 bool PARAVIS_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
521 const SALOMEDS::TMPFile& theStream,
522 const char* theURL, bool isMultiFile)
524 return LoadState(mySalomeApp, theComponent, theStream, theURL, isMultiFile);
527 //----------------------------------------------------------------------------
528 void PARAVIS_Gen_i::Close(SALOMEDS::SComponent_ptr IORSComponent)
532 //----------------------------------------------------------------------------
533 char* PARAVIS_Gen_i::ComponentDataType()
535 return CORBA::string_dup("PARAVIS");
538 //----------------------------------------------------------------------------
539 char* PARAVIS_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString,
540 CORBA::Boolean isMultiFile, CORBA::Boolean isASCII)
542 CORBA::String_var aString("");
543 return aString._retn();
546 //----------------------------------------------------------------------------
547 char* PARAVIS_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
548 const char* aLocalPersistentID,
549 CORBA::Boolean isMultiFile,
550 CORBA::Boolean isASCII)
552 CORBA::String_var aString("");
553 return aString._retn();
556 //----------------------------------------------------------------------------
557 bool PARAVIS_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
562 //----------------------------------------------------------------------------
563 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
564 SALOMEDS::SObject_ptr theSObject,
565 CORBA::Object_ptr theObject,
567 throw (SALOME::SALOME_Exception)
569 SALOMEDS::SObject_var aResultSO;
570 return aResultSO._retn();
573 //----------------------------------------------------------------------------
574 CORBA::Boolean PARAVIS_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
579 //----------------------------------------------------------------------------
580 SALOMEDS::TMPFile* PARAVIS_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID)
582 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
583 return aStreamFile._retn();
586 //----------------------------------------------------------------------------
587 CORBA::Boolean PARAVIS_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID)
592 //----------------------------------------------------------------------------
593 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
594 CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject)
596 return SALOMEDS::SObject::_nil();
599 #ifdef PARAVIS_WITH_FULL_CORBA
600 //----------------------------------------------------------------------------
601 PARAVIS::string_array* PARAVIS_Gen_i::GetClassesList()
604 for (k = 0; strcmp(wrapped_classes[k], "") != 0; k++);
605 PARAVIS::string_array_var aNames = new PARAVIS::string_array();
607 for (CORBA::ULong i = 0; i < k; i++)
608 aNames[i] = CORBA::string_dup(wrapped_classes[i]);
609 return aNames._retn();
612 //----------------------------------------------------------------------------
613 PARAVIS_Base_ptr PARAVIS_Gen_i::CreateClass(const char* theClassName)
615 PARAVIS::PARAVIS_Base_i* aClass = CreateInstance(NULL, QString(theClassName));
616 return aClass->_this();
620 //----------------------------------------------------------------------------
621 void PARAVIS_Gen_i::GetConnectionParameters(CORBA::Long& theId,
622 CORBA::String_out theDHost, CORBA::Long& theDPort,
623 CORBA::String_out theRHost, CORBA::Long& theRPort,
624 CORBA::Long& theReversed)
626 pqServer* aServer = ProcessEvent(new TGetActiveServer(mySalomeApp));
628 theId = static_cast<int>(aServer->GetConnectionID());
630 pqServerResource serverRes = aServer->getResource();
631 theReversed = (serverRes.scheme() == "csrc" || serverRes.scheme() == "cdsrsrc")? 1 : 0;
633 theDPort = serverRes.dataServerPort() < 0? serverRes.port() : serverRes.dataServerPort();
634 theRPort = serverRes.renderServerPort() < 0 ? 0 : serverRes.renderServerPort();
636 QString dsHost = serverRes.dataServerHost().isEmpty()? serverRes.host() : serverRes.dataServerHost();
637 QString rsHost = serverRes.renderServerHost();
639 theDHost = CORBA::string_dup(qPrintable(dsHost));
640 theRHost = CORBA::string_dup(qPrintable(rsHost));
645 //----------------------------------------------------------------------------
646 Engines::TMPFile* PARAVIS_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
647 CORBA::Boolean theIsPublished,
648 CORBA::Boolean theIsMultiFile,
649 CORBA::Boolean& theIsValidScript)
651 theIsValidScript = true;
653 if ( theIsMultiFile )
654 aResult += "\ndef RebuildData(theStudy):\n";
655 aResult += tabify(ProcessEvent(new TGetTrace(mySalomeApp)), theIsMultiFile );
656 if ( theIsMultiFile )
657 aResult += "\n\tpass\n";
658 CORBA::ULong aSize = aResult.size() + 1;
659 char* aBuffer = new char[aSize];
660 memset(aBuffer, 0, aSize);
661 strcpy(aBuffer, &aResult[0]);
662 Engines::TMPFile_var aDump = new Engines::TMPFile(aSize,aSize,(CORBA::Octet*)aBuffer,1);
663 return aDump._retn();
666 //----------------------------------------------------------------------------
667 void PARAVIS_Gen_i::ActivateModule()
669 ProcessVoidEvent(new TActivateModule(mySalomeApp));
672 //----------------------------------------------------------------------------
673 struct TSetStudyEvent: public SALOME_Event {
674 std::string myStudyName;
675 typedef SalomeApp_Application* TResult;
678 TSetStudyEvent(const std::string theStudyName):myStudyName(theStudyName), myResult(0) {}
679 virtual void Execute()
681 bool isActive = false;
682 SUIT_Session* aSession = SUIT_Session::session();
683 QList<SUIT_Application*> anApplications = aSession->applications();
684 QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
685 SUIT_Application* aFirstApp = *anIter;
686 while (anIter != anApplications.end()) {
687 SUIT_Application* anApp = *anIter;
688 if (SUIT_Study* aSStudy = anApp->activeStudy()) {
689 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
690 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
691 if(MYDEBUG) MESSAGE("There is an application with active study : StudyId = "
692 << aCStudy->StudyId() << "; Name = '" << aCStudy->Name() << "'");
693 if (myStudyName == aCStudy->Name()) {
702 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aFirstApp);
704 MESSAGE("!!! anApp->onLoadDoc(myStudyName) !!!");
705 // Has to be loaded in an empty or in a new application
706 anApp->onLoadDoc(myStudyName.c_str());
712 void PARAVIS_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
714 if (!CORBA::is_nil(theStudy)) {
715 CORBA::String_var aName = theStudy->Name();
716 std::string aStudyName (aName.in());
718 myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
719 SalomeApp_Application* anApp = ProcessEvent(new TSetStudyEvent(aStudyName));
723 INFOS("CORBA::is_nil(theStudy)");
728 //----------------------------------------------------------------------------
729 SALOMEDS::Study_ptr PARAVIS_Gen_i::GetCurrentStudy()
731 return SALOMEDS::Study::_duplicate(myStudyDocument);
734 // Version information
735 char* PARAVIS_Gen_i::getVersion()
737 #ifdef PARAVIS_DEVELOPMENT
738 return CORBA::string_dup( PARAVIS_VERSION_STR"dev" );
740 return CORBA::string_dup( PARAVIS_VERSION_STR );