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"
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 #include "vtkWrapIDL.h"
54 #include <pqServerResource.h>
58 static int MYDEBUG = 1;
60 static int MYDEBUG = 0;
65 extern PARAVIS::PARAVIS_Base_i* CreateInstance(::vtkObjectBase* Inst, const QString&);
68 PARAVIS_I_EXPORT PARAVIS::PARAVIS_Gen_ptr GetImpl(CORBA::ORB_ptr theORB,
69 PortableServer::POA_ptr thePOA,
70 SALOME_NamingService* theNamingService,
73 if(MYDEBUG) MESSAGE("extern 'C' GetImpl");
74 PARAVIS::PARAVIS_Gen_i *aPARAVIS_Gen = new PARAVIS::PARAVIS_Gen_i(theORB,
78 return aPARAVIS_Gen->_this();
86 const char* checkNullStr(const char* theStr)
88 if (strcmp(theStr, "NULL") == 0)
94 std::string tabify( const std::string& source, bool isTabify )
96 std::string result = source;
97 if ( isTabify && !result.empty() ) {
98 std::string caret = "\n";
99 int idx = result.rfind( caret );
100 while ( idx != std::string::npos ) {
101 result.replace( idx, caret.size(), "\n\t" );
102 idx = result.rfind( caret, idx-1 );
104 result.insert(0, "\t" );
109 PARAVIS_Base_i::~PARAVIS_Base_i() {
110 if(mySmartPointer != NULL) mySmartPointer->Delete();
113 void PARAVIS_Base_i::Init(::vtkObjectBase* base) {
114 if (mySmartPointer != NULL) mySmartPointer->Delete();
115 mySmartPointer = base;
118 ::vtkObjectBase* PARAVIS_Base_i::getVTKObject(PARAVIS_Base_ptr theBase) {
119 PARAVIS_Base_i* aBase = GET_SERVANT(theBase);
120 return (aBase != NULL)? aBase->getVTKObject() : NULL;
123 CORBA::Boolean PARAVIS_Base_i::IsSame(PARAVIS_Base_ptr theOther)
125 PARAVIS_Base_i* aBase = GET_SERVANT(theOther);
128 return mySmartPointer.GetPointer() == aBase->getVTKObject();
134 PARAVIS_Gen_i* PARAVIS_Gen_i::myParavisGenImpl;
135 CORBA::ORB_var PARAVIS_Gen_i::myOrb;
136 PortableServer::POA_var PARAVIS_Gen_i::myPoa;
137 SALOME_LifeCycleCORBA* PARAVIS_Gen_i::myEnginesLifeCycle;
138 SALOME_NamingService* PARAVIS_Gen_i::myNamingService;
139 QMutex* PARAVIS_Gen_i::myMutex;
140 SalomeApp_Application* PARAVIS_Gen_i::mySalomeApp = 0;
143 //----------------------------------------------------------------------------
144 PARAVIS_Gen_i::PARAVIS_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
145 SALOME_NamingService* theNamingService, QMutex* theMutex) :
146 Engines_Component_i()
148 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PARAVIS_Gen_i");
149 if (mySalomeApp) return;
152 myOrb = CORBA::ORB::_duplicate(theORB);
153 myPoa = PortableServer::POA::_duplicate(thePOA);
154 myParavisGenImpl = this;
155 myNamingService = theNamingService;
157 static SALOME_LifeCycleCORBA aEnginesLifeCycle(theNamingService);
158 myEnginesLifeCycle = &aEnginesLifeCycle;
160 CORBA::Object_var anObj = myNamingService->Resolve("/myStudyManager");
161 if (!CORBA::is_nil(anObj)) {
162 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(anObj);
163 SALOMEDS::ListOfOpenStudies_var aListOfOpenStudies = aStudyManager->GetOpenStudies();
164 if(aListOfOpenStudies->length() > 0) {
165 CORBA::String_var aStudyName = aListOfOpenStudies[0];
166 myStudyDocument = aStudyManager->GetStudyByName(aStudyName);
167 if (!myStudyDocument->_is_nil()) {
168 mySalomeApp = ProcessEvent(new TGetGUIApplication(myStudyDocument->StudyId()));
169 if(!myStudyDocument->GetProperties()->IsLocked())
170 FindOrCreateParaVisComponent(myStudyDocument);
173 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PARAVIS_Gen_i : there is no opened study in StudyManager !!!");
175 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PARAVIS_Gen_i : Can't find StudyManager !!!");
179 //----------------------------------------------------------------------------
180 PARAVIS_Gen_i::~PARAVIS_Gen_i()
182 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::~PARAVIS_Gen_i");
185 //----------------------------------------------------------------------------
186 char* PARAVIS_Gen_i::GetIOR()
189 CORBA::Object_var anObject = _this();
190 CORBA::String_var anIOR = myOrb->object_to_string(anObject);
193 return CORBA::string_dup(myIOR.c_str());
196 //----------------------------------------------------------------------------
197 void PARAVIS_Gen_i::ImportFile(const char* theFileName)
199 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::ImportFile: " <<theFileName);
200 ProcessVoidEvent(new TImportFile(mySalomeApp, theFileName));
203 void PARAVIS_Gen_i::ExecuteScript(const char* script)
205 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::ExecuteScript: " <<script);
206 ProcessVoidEvent(new TExecuteScript(mySalomeApp, script));
209 //----------------------------------------------------------------------------
210 char* PARAVIS_Gen_i::GetTrace()
212 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::PrintTrace: ");
213 return CORBA::string_dup(ProcessEvent(new TGetTrace(mySalomeApp)).c_str());
216 //----------------------------------------------------------------------------
217 void PARAVIS_Gen_i::SaveTrace(const char* theFileName)
219 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::SaveTrace: " <<theFileName);
220 ProcessVoidEvent(new TSaveTrace(mySalomeApp, theFileName));
223 //----------------------------------------------------------------------------
224 void processElements(QDomNode& thePropertyNode, QStringList& theFileNames, const char* theNewPath, bool theRestore)
226 QDomNode aElementNode = thePropertyNode.firstChild();
227 while (aElementNode.isElement()) {
228 QDomElement aElement = aElementNode.toElement();
229 if (aElement.tagName() == "Element") {
230 QString aIndex = aElement.attribute("index");
232 QString aValue = aElement.attribute("value");
233 if (!aValue.isNull()) {
235 QFileInfo aFInfo(aValue);
236 if (aFInfo.exists()) {
237 theFileNames<<aValue;
238 aElement.setAttribute("value", aFInfo.fileName());
243 aElement.setAttribute("value", QString(theNewPath) + aValue);
248 aElementNode = aElementNode.nextSibling();
253 //----------------------------------------------------------------------------
254 void processProperties(QDomNode& theProxyNode, QStringList& theFileNames, const char* theNewPath, bool theRestore)
256 QDomNode aPropertyNode = theProxyNode.firstChild();
257 while (aPropertyNode.isElement()) {
258 QDomElement aProperty = aPropertyNode.toElement();
259 QString aName = aProperty.attribute("name");
260 if ((aName == "FileName") || (aName == "FileNameInfo") || (aName == "FileNames")) {
261 processElements(aPropertyNode, theFileNames, theNewPath, theRestore);
263 aPropertyNode = aPropertyNode.nextSibling();
268 //----------------------------------------------------------------------------
269 void processProxies(QDomNode& theNode, QStringList& theFileNames, const char* theNewPath, bool theRestore)
271 QDomNode aProxyNode = theNode.firstChild();
272 while (aProxyNode.isElement()) {
273 QDomElement aProxy = aProxyNode.toElement();
274 if (aProxy.tagName() == "Proxy") {
275 QString aGroup = aProxy.attribute("group");
276 if (aGroup == "sources") {
277 processProperties(aProxyNode, theFileNames, theNewPath, theRestore);
280 aProxyNode = aProxyNode.nextSibling();
284 //----------------------------------------------------------------------------
285 bool processAllFilesInState(const char* aFileName, QStringList& theFileNames,
286 const char* theNewPath, bool theRestore = false)
288 QFile aFile(aFileName);
289 if (!aFile.open(QFile::ReadOnly)) {
290 MESSAGE("Can't open state file "<<aFileName);
294 bool aRes = aDoc.setContent(&aFile);
298 MESSAGE("File "<<aFileName<<" is not XML document");
302 QDomElement aRoot = aDoc.documentElement();
303 if ( aRoot.isNull() ) {
304 MESSAGE( "Invalid XML root" );
308 QDomNode aNode = aRoot.firstChild();
309 while (aRes && !aNode.isNull() ) {
310 aRes = aNode.isElement();
312 QDomElement aSection = aNode.toElement();
313 if (aSection.tagName() == "ServerManagerState") {
314 processProxies(aNode, theFileNames, theNewPath, theRestore);
317 aNode = aNode.nextSibling();
319 if (!aFile.open(QFile::WriteOnly | QFile::Truncate)) {
320 MESSAGE("Can't open state file "<<aFileName<<" for writing");
323 QTextStream out(&aFile);
330 //----------------------------------------------------------------------------
331 QStringList getAllSavedStates(SALOMEDS::SComponent_ptr theComponent,
332 QString theNewPath = QString())
334 QStringList aStateFiles;
336 if (!CORBA::is_nil(theComponent)) {
337 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
338 SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
339 for (; anIter->More(); anIter->Next()) {
340 SALOMEDS::SObject_var aSObj = anIter->Value();
341 SALOMEDS::GenericAttribute_var anAttr;
342 if (!aSObj->FindAttribute(anAttr, "AttributeLocalID")) {
345 SALOMEDS::AttributeLocalID_var anID = SALOMEDS::AttributeLocalID::_narrow(anAttr);
346 if (!anID->Value() == PVSTATEID) {
349 if (aSObj->FindAttribute(anAttr, "AttributeString")) {
350 SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
351 QString aStateFile(aStringAttr->Value());
352 printf("getAllSavedStates, aStateFile = %s\n", aStateFile.toLatin1().constData());
353 // Replace the old path with the new one
354 if (!theNewPath.isEmpty()) {
355 QFileInfo aFileInfo(aStateFile);
356 QString aPath = aFileInfo.path();
357 aStateFile.replace(aPath, theNewPath);
358 aStringAttr->SetValue(aStateFile.toLatin1().constData());
360 printf("getAllSavedStates, aStateFile NEW = %s\n", aStateFile.toLatin1().constData());
362 aStateFiles<<aStateFile;
370 SALOMEDS::TMPFile* SaveState(long thePID, SalomeApp_Application* theApp, SALOMEDS::SComponent_ptr theComponent,
371 const char* theURL, bool isMultiFile)
373 std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
375 std::ostringstream aStream;
376 aStream<<"paravisstate:"<<thePID;
377 std::string aFileName = "_" + aStream.str();
378 if(MYDEBUG) MESSAGE("aFileName = '"<<aFileName);
380 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
382 std::string aFile = aTmpDir + aFileName;
383 ProcessVoidEvent(new TSaveStateFile(theApp, aFile.c_str()));
386 QStringList aSavedStates = getAllSavedStates(theComponent);
388 // Collect all files from state
389 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
390 int aSavingType = aResourceMgr->integerValue( "PARAVIS", "savestate_type", 0 );
392 QStringList aFileNames;
395 switch (aSavingType) {
396 case 0: // Save referenced files only for builin server
398 MESSAGE("Save as built in;")
399 bool aIsBuiltIn = true;
400 pqServer* aServer = ProcessEvent(new TGetActiveServer(theApp));
402 aIsBuiltIn != aServer->isRemote();
406 // Find referenced files and collect their paths nullyfying references:
409 foreach (QString aState, aSavedStates) {
410 processAllFilesInState(aState.toLatin1().constData(), aFileNames, 0);
414 processAllFilesInState(aFile.c_str(), aFileNames, 0);
416 SetRestoreParam(theComponent, true);
418 SetRestoreParam(theComponent, false);
422 case 1: //Save referenced files when they are accessible
424 // Find referenced files and collect their paths nullyfying references
427 foreach (QString aState, aSavedStates) {
428 processAllFilesInState(aState.toLatin1().constData(), aFileNames, 0);
432 processAllFilesInState(aFile.c_str(), aFileNames, 0);
433 SetRestoreParam(theComponent, true);
436 case 2: //Never save referenced files
437 SetRestoreParam(theComponent, false);
442 foreach (QString aSavedState, aSavedStates) {
443 aFileNames<<aSavedState;
446 // Add main state to the end of the list
447 aFileNames<<QString(aFile.c_str());
449 // File names for main state and its data files
450 foreach(QString aFile, aFileNames) {
451 QFileInfo aInfo(aFile);
452 aNames<<aInfo.fileName();
454 SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames);
455 SALOMEDS::ListOfFileNames_var aListOfNames = GetListOfFileNames(aNames);
457 aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFileNames.in(), aListOfNames.in());
459 return aStreamFile._retn();
462 //----------------------------------------------------------------------------
463 SALOMEDS::TMPFile* PARAVIS_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
464 const char* theURL, bool isMultiFile)
466 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::Save - theURL = '"<<theURL<<"'");
467 return SaveState((long) this, mySalomeApp, theComponent, theURL, isMultiFile);
470 //----------------------------------------------------------------------------
471 SALOMEDS::TMPFile* PARAVIS_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
472 const char* theURL, bool isMultiFile)
474 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::Save - theURL = '"<<theURL<<"'");
475 return SaveState((long) this, mySalomeApp, theComponent, theURL, isMultiFile);
479 //----------------------------------------------------------------------------
480 bool LoadState(SalomeApp_Application* theApp, SALOMEDS::SComponent_ptr theComponent,
481 const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile)
483 std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
484 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::Load - "<<aTmpDir);
486 SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false);
487 if (aSeq->length() == 0)
490 bool aRestore = GetRestoreParam(theComponent);
491 MESSAGE("PARAVIS_Gen_i::Restore path - "<<aRestore);
493 // Process main state
494 std::string aFile = aTmpDir + std::string(aSeq[aSeq->length() - 1]);
495 QStringList aEmptyList;
496 processAllFilesInState(aFile.c_str(), aEmptyList, aTmpDir.c_str(), aRestore);
497 ProcessVoidEvent(new TLoadStateFile(theApp, aFile.c_str()));
499 // Process saved states
500 QStringList aSavedStates = getAllSavedStates(theComponent, QString(aTmpDir.c_str()));
501 foreach(QString aState, aSavedStates) {
502 processAllFilesInState(aState.toLatin1().constData(),
503 aEmptyList, aTmpDir.c_str(), aRestore);
509 //----------------------------------------------------------------------------
510 bool PARAVIS_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream,
511 const char* theURL, bool isMultiFile)
513 return LoadState(mySalomeApp, theComponent, theStream, theURL, isMultiFile);
516 //----------------------------------------------------------------------------
517 bool PARAVIS_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
518 const SALOMEDS::TMPFile& theStream,
519 const char* theURL, bool isMultiFile)
521 return LoadState(mySalomeApp, theComponent, theStream, theURL, isMultiFile);
524 //----------------------------------------------------------------------------
525 void PARAVIS_Gen_i::Close(SALOMEDS::SComponent_ptr IORSComponent)
529 //----------------------------------------------------------------------------
530 char* PARAVIS_Gen_i::ComponentDataType()
532 return CORBA::string_dup("PARAVIS");
535 //----------------------------------------------------------------------------
536 char* PARAVIS_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString,
537 CORBA::Boolean isMultiFile, CORBA::Boolean isASCII)
539 CORBA::String_var aString("");
540 return aString._retn();
543 //----------------------------------------------------------------------------
544 char* PARAVIS_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
545 const char* aLocalPersistentID,
546 CORBA::Boolean isMultiFile,
547 CORBA::Boolean isASCII)
549 CORBA::String_var aString("");
550 return aString._retn();
553 //----------------------------------------------------------------------------
554 bool PARAVIS_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
559 //----------------------------------------------------------------------------
560 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
561 SALOMEDS::SObject_ptr theSObject,
562 CORBA::Object_ptr theObject,
564 throw (SALOME::SALOME_Exception)
566 SALOMEDS::SObject_var aResultSO;
567 return aResultSO._retn();
570 //----------------------------------------------------------------------------
571 CORBA::Boolean PARAVIS_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
576 //----------------------------------------------------------------------------
577 SALOMEDS::TMPFile* PARAVIS_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID)
579 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
580 return aStreamFile._retn();
583 //----------------------------------------------------------------------------
584 CORBA::Boolean PARAVIS_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID)
589 //----------------------------------------------------------------------------
590 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
591 CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject)
593 return SALOMEDS::SObject::_nil();
596 //----------------------------------------------------------------------------
597 PARAVIS::string_array* PARAVIS_Gen_i::GetClassesList()
600 for (k = 0; strcmp(wrapped_classes[k], "") != 0; k++);
601 PARAVIS::string_array_var aNames = new PARAVIS::string_array();
603 for (CORBA::ULong i = 0; i < k; i++)
604 aNames[i] = CORBA::string_dup(wrapped_classes[i]);
605 return aNames._retn();
608 //----------------------------------------------------------------------------
609 PARAVIS_Base_ptr PARAVIS_Gen_i::CreateClass(const char* theClassName)
611 PARAVIS::PARAVIS_Base_i* aClass = CreateInstance(NULL, QString(theClassName));
612 return aClass->_this();
615 //----------------------------------------------------------------------------
616 void PARAVIS_Gen_i::GetConnectionParameters(CORBA::Long& theId,
617 CORBA::String_out theDHost, CORBA::Long& theDPort,
618 CORBA::String_out theRHost, CORBA::Long& theRPort,
619 CORBA::Long& theReversed)
621 pqServer* aServer = ProcessEvent(new TGetActiveServer(mySalomeApp));
623 theId = static_cast<int>(aServer->GetConnectionID());
625 pqServerResource serverRes = aServer->getResource();
626 theReversed = (serverRes.scheme() == "csrc" || serverRes.scheme() == "cdsrsrc")? 1 : 0;
628 theDPort = serverRes.dataServerPort() < 0? serverRes.port() : serverRes.dataServerPort();
629 theRPort = serverRes.renderServerPort() < 0 ? 0 : serverRes.renderServerPort();
631 QString dsHost = serverRes.dataServerHost().isEmpty()? serverRes.host() : serverRes.dataServerHost();
632 QString rsHost = serverRes.renderServerHost();
634 theDHost = CORBA::string_dup(qPrintable(dsHost));
635 theRHost = CORBA::string_dup(qPrintable(rsHost));
640 //----------------------------------------------------------------------------
641 Engines::TMPFile* PARAVIS_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
642 CORBA::Boolean theIsPublished,
643 CORBA::Boolean theIsMultiFile,
644 CORBA::Boolean& theIsValidScript)
646 theIsValidScript = true;
648 if ( theIsMultiFile )
649 aResult += "\ndef RebuildData(theStudy):\n";
650 aResult += tabify(ProcessEvent(new TGetTrace(mySalomeApp)), theIsMultiFile );
651 if ( theIsMultiFile )
652 aResult += "\n\tpass\n";
653 CORBA::ULong aSize = aResult.size() + 1;
654 char* aBuffer = new char[aSize];
655 memset(aBuffer, 0, aSize);
656 strcpy(aBuffer, &aResult[0]);
657 Engines::TMPFile_var aDump = new Engines::TMPFile(aSize,aSize,(CORBA::Octet*)aBuffer,1);
658 return aDump._retn();
661 //----------------------------------------------------------------------------
662 void PARAVIS_Gen_i::ActivateModule()
664 ProcessVoidEvent(new TActivateModule(mySalomeApp));
667 //----------------------------------------------------------------------------
668 struct TSetStudyEvent: public SALOME_Event {
669 std::string myStudyName;
670 typedef SalomeApp_Application* TResult;
673 TSetStudyEvent(const std::string theStudyName):myStudyName(theStudyName), myResult(0) {}
674 virtual void Execute()
676 bool isActive = false;
677 SUIT_Session* aSession = SUIT_Session::session();
678 QList<SUIT_Application*> anApplications = aSession->applications();
679 QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
680 SUIT_Application* aFirstApp = *anIter;
681 while (anIter != anApplications.end()) {
682 SUIT_Application* anApp = *anIter;
683 if (SUIT_Study* aSStudy = anApp->activeStudy()) {
684 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
685 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
686 if(MYDEBUG) MESSAGE("There is an application with active study : StudyId = "
687 << aCStudy->StudyId() << "; Name = '" << aCStudy->Name() << "'");
688 if (myStudyName == aCStudy->Name()) {
697 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aFirstApp);
699 MESSAGE("!!! anApp->onLoadDoc(myStudyName) !!!");
700 // Has to be loaded in an empty or in a new application
701 anApp->onLoadDoc(myStudyName.c_str());
707 void PARAVIS_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
709 if (!CORBA::is_nil(theStudy)) {
710 CORBA::String_var aName = theStudy->Name();
711 std::string aStudyName (aName.in());
713 myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
714 SalomeApp_Application* anApp = ProcessEvent(new TSetStudyEvent(aStudyName));
718 INFOS("CORBA::is_nil(theStudy)");
723 //----------------------------------------------------------------------------
724 SALOMEDS::Study_ptr PARAVIS_Gen_i::GetCurrentStudy()
726 return SALOMEDS::Study::_duplicate(myStudyDocument);
729 // Version information
730 char* PARAVIS_Gen_i::getVersion()
732 #if PARAVIS_DEVELOPMENT
733 return CORBA::string_dup( PARAVIS_VERSION_STR"dev" );
735 return CORBA::string_dup( PARAVIS_VERSION_STR );