#include <omnithread.h>
#include CORBA_SERVER_HEADER(SALOME_Session)
+#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
#include <qstring.h>
#include <qfileinfo.h>
+#include "Utils_ExceptHandlers.hxx"
using namespace std;
static QFileInfo aFileInfo;
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
-extern "C" {
- PortableServer::ObjectId *
- VisuEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId,
- const char *instanceName, const char *interfaceName)
- {
- if(MYDEBUG) MESSAGE("VisuEngine_factory : "<<interfaceName);
- VISU::VISU_Gen_i * pVISU_Gen = new VISU::VISU_Gen_i(orb, poa, contId, instanceName, interfaceName);
- return pVISU_Gen->getId() ;
- }
- VISU::VISU_Gen_ptr
- GetVisuGen(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
- SALOME_NamingService* theNamingService, QMutex* theMutex)
- {
- if(MYDEBUG) MESSAGE("extern \"C\" GetVisuGen");
- VISU::VISU_Gen_i *aVISU_Gen = new VISU::VISU_Gen_i(theORB,thePOA,theNamingService,theMutex);
- return VISU::VISU_Gen::_duplicate(aVISU_Gen->_this());
- //return aVISU_Gen->_this();
- }
+UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
+
+extern "C" VISU::VISU_Gen_ptr GetImpl(CORBA::ORB_ptr theORB,
+ PortableServer::POA_ptr thePOA,
+ SALOME_NamingService* theNamingService,
+ QMutex* theMutex)
+{
+ if(MYDEBUG) MESSAGE("extern \"C\" GetImpl");
+ VISU::VISU_Gen_i *aVISU_Gen = new VISU::VISU_Gen_i(theORB,thePOA,theNamingService,theMutex);
+ //return VISU::VISU_Gen::_duplicate(aVISU_Gen->_this());
+ return aVISU_Gen->_this();
}
namespace VISU{
aSComponent = aStudyBuilder->NewComponent("VISU");
SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
- aName->SetValue("Visu");
+
+ //NRI aName->SetValue("Visu");
+ CORBA::ORB_var anORB = Base_i::GetORB();
+ SALOME_NamingService *NamingService = new SALOME_NamingService( anORB );
+ CORBA::Object_var objVarN = NamingService->Resolve("/Kernel/ModulCatalog");
+ SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
+ SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "VISU" );
+ if ( !Comp->_is_nil() ) {
+ aName->SetValue( Comp->componentusername() );
+ }
anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aStudyBuilder->CommitCommand();
}
return aSComponent;
- }
+ }
-
- void RegistryStorable() throw(std::logic_error&) {
+ void RegistryStorable() {
Storable::Registry(Result_i::myComment.c_str(),&(Result_i::Restore));
- Storable::Registry(Mesh_i::myComment.c_str(),&(Mesh_i::Restore));
- Storable::Registry(ScalarMap_i::myComment.c_str(),&(ScalarMap_i::Restore));
- Storable::Registry(DeformedShape_i::myComment.c_str(),&(DeformedShape_i::Restore));
- Storable::Registry(CutPlanes_i::myComment.c_str(),&(CutPlanes_i::Restore));
- Storable::Registry(CutLines_i::myComment.c_str(),&(CutLines_i::Restore));
- Storable::Registry(IsoSurfaces_i::myComment.c_str(),&(IsoSurfaces_i::Restore));
- Storable::Registry(StreamLines_i::myComment.c_str(),&(StreamLines_i::Restore));
- Storable::Registry(Vectors_i::myComment.c_str(),&(Vectors_i::Restore));
+ Storable::Registry(Mesh_i::myComment.c_str(),&(Restore<Mesh_i>));
+ Storable::Registry(ScalarMap_i::myComment.c_str(),&(Restore<ScalarMap_i>));
+ Storable::Registry(DeformedShape_i::myComment.c_str(),&(Restore<DeformedShape_i>));
+ Storable::Registry(CutPlanes_i::myComment.c_str(),&(Restore<CutPlanes_i>));
+ Storable::Registry(CutLines_i::myComment.c_str(),&(Restore<CutLines_i>));
+ Storable::Registry(IsoSurfaces_i::myComment.c_str(),&(Restore<IsoSurfaces_i>));
+ Storable::Registry(StreamLines_i::myComment.c_str(),&(Restore<StreamLines_i>));
+ Storable::Registry(Vectors_i::myComment.c_str(),&(Restore<Vectors_i>));
Storable::Registry(Table_i::myComment.c_str(),&(Table_i::Restore));
Storable::Registry(Curve_i::myComment.c_str(),&(Curve_i::Restore));
Storable::Registry(Container_i::myComment.c_str(),&(Container_i::Restore));
//===========================================================================
- VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr orb,
- PortableServer::POA_ptr poa,
- PortableServer::ObjectId * contId,
- const char *instanceName,
- const char *interfaceName) :
- Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
- {
- if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<<myMutex);
- _thisObj = this ;
- _id = _poa->activate_object(_thisObj);
- SALOME_NamingService aNamingService(orb);
- CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session");
- SALOME::Session_var aSession = SALOME::Session::_narrow(anObject);
- //aSession->GetInterface();
- Engines::Component_var aComponent = aSession->GetVisuGen();
- myVisuGen = VISU::VISU_Gen::_narrow(aComponent);
- }
-
VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
SALOME_NamingService* theNamingService, QMutex* theMutex) :
Engines_Component_i()
{
if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<<theMutex);
- Mutex mt(theMutex,qApp);
Base_i::myMutex = theMutex; //apo
Base_i::myOrb = CORBA::ORB::_duplicate(theORB);
- Base_i::myPOA = PortableServer::POA::_duplicate(thePOA);
+ Base_i::myPoa = PortableServer::POA::_duplicate(thePOA);
Base_i::myNamingService = theNamingService;
static SALOME_LifeCycleCORBA aEnginesLifeCycle(theNamingService);
Base_i::myEnginesLifeCycle = &aEnginesLifeCycle;
SALOMEDS::ListOfOpenStudies_var aListOfOpenStudies = aStudyManager->GetOpenStudies();
if(aListOfOpenStudies->length() > 0) {
CORBA::String_var aStudyName = aListOfOpenStudies[0];
- aFileInfo.setFile(aStudyName.in());
- myStudyDocument = aStudyManager->GetStudyByName(aFileInfo.baseName());
- }else{
+ //aFileInfo.setFile(aStudyName.in());
+ myStudyDocument = aStudyManager->GetStudyByName(aStudyName/*aFileInfo.baseName()*/);
+ }else
if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : there is no opened study in StudyManager !!!");
- }
-
- Base_i::myPOA->activate_object(this);
}
VISU_Gen_i::~VISU_Gen_i(){
if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
}
//===========================================================================
- bool VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
- const SALOMEDS::TMPFile & theStream,
- const char* theURL,
- bool isMultiFile)
+ CORBA::Boolean VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile & theStream,
+ const char* theURL,
+ bool isMultiFile)
{
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Load - myMutex = "<<myMutex);
- if(myMutex){
- Mutex mt(myMutex,qApp);
- SALOMEDS::Study_var aStudy = theComponent->GetStudy();
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
- TCollection_AsciiString aTmpDir =
- isMultiFile?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
- VisuTmpDir = aTmpDir.ToCString();
- SALOMEDS::ListOfFileNames_var aSeq =
- SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString(),isMultiFile);
- myIsMultiFile = isMultiFile;
- return true;
- }
- return myVisuGen->Load(theComponent,theStream,theURL,isMultiFile);
+ Mutex mt(myMutex);
+ SALOMEDS::Study_var aStudy = theComponent->GetStudy();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ TCollection_AsciiString aTmpDir =
+ isMultiFile?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
+ VisuTmpDir = aTmpDir.ToCString();
+ SALOMEDS::ListOfFileNames_var aSeq =
+ SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString(),isMultiFile);
+ myIsMultiFile = isMultiFile;
+ return true;
}
- bool VISU_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
- const SALOMEDS::TMPFile & theStream,
- const char* theURL,
- bool isMultiFile)
+ CORBA::Boolean VISU_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile & theStream,
+ const char* theURL,
+ bool isMultiFile)
{
return Load(theComponent, theStream, theURL, isMultiFile);
}
CORBA::Boolean isMultiFile,
CORBA::Boolean isASCII)
{
- if(myMutex){
- CORBA::String_var aString("");
- if(strcmp(aLocalPersistentID,"") != 0) {
- Mutex mt(myMutex,qApp);
- Storable* aStorable =
- Storable::Create(theSObject,VisuTmpDir.c_str(),aLocalPersistentID);
- if(aStorable != NULL) aString = aStorable->GetID();
- }
- return aString._retn();
+ CORBA::String_var aString("");
+ if(strcmp(aLocalPersistentID,"") != 0) {
+ Mutex mt(myMutex);
+ Storable* aStorable =
+ Storable::Create(theSObject,VisuTmpDir.c_str(),aLocalPersistentID);
+ if(aStorable != NULL) aString = aStorable->GetID();
}
- return myVisuGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII);
+ return aString._retn();
}
//===========================================================================
SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
const char* theURL,
bool isMultiFile)
{
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - myMutex = "<<myMutex);
- if(myMutex){
- Mutex mt(myMutex,qApp);
- CORBA::String_var aString = SALOMEDS_Tool::GetTmpDir();
- TCollection_AsciiString aTmpDir = isMultiFile? (const Standard_CString)theURL: (const Standard_CString)aString.in();
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
- int aCounter = 0;
- TColStd_SequenceOfAsciiString aFileNames;
- SALOMEDS::Study_var aStudy = theComponent->GetStudy();
- SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
- for (; itBig->More(); itBig->Next()) {
- SALOMEDS::SObject_var gotBranch = itBig->Value();
- CORBA::Object_var anObj = SObjectToObject(gotBranch);
- if(CORBA::is_nil(anObj)) continue;
- Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj));
- if(pResult && abs(pResult->GetSourceId()) == Result_i::eFile){
+ Mutex mt(myMutex);
+ TCollection_AsciiString aTmpDir = isMultiFile? strdup(theURL): SALOMEDS_Tool::GetTmpDir();
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
+ int aCounter = 0;
+ TColStd_SequenceOfAsciiString aFileNames;
+ SALOMEDS::Study_var aStudy = theComponent->GetStudy();
+ SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
+ for (; itBig->More(); itBig->Next()) {
+ SALOMEDS::SObject_var gotBranch = itBig->Value();
+ CORBA::Object_var anObj = SObjectToObject(gotBranch);
+ if(CORBA::is_nil(anObj)) continue;
+ if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
+ const Result_i::TSourceId& aSourceId = pResult->GetSourceId();
+ if(aSourceId == Result_i::eFile || aSourceId == Result_i::eRestoredFile){
const QFileInfo& aFileInfo = pResult->GetFileInfo();
- QString aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
+ QString aPrefix("");
+ if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str();
static QString aCommand;
aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1());
- if(system(aCommand) == -1){
+
+ int aRes = system(aCommand);
+ if(aRes){
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Cann't execute the command :"<<aCommand);
continue;
}else
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aCommand);
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aCommand = "<<aCommand);
+
TCollection_AsciiString aString(strdup(aFileName.latin1()));
aFileNames.Append(aString);
}
}
- SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.Length() - "<<aFileNames.Length());
- if(aFileNames.Length() > 0){
- SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- aSeq->length(aFileNames.Length());
- for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--)
- aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString());
- aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile);
- if(!isMultiFile)
- SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
- }
- return aStreamFile._retn();
}
- return myVisuGen->Save(theComponent,theURL,isMultiFile);
+ SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.Length() - "<<aFileNames.Length());
+ if(aFileNames.Length() > 0){
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ aSeq->length(aFileNames.Length());
+ for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--)
+ aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString());
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile);
+ if(!isMultiFile)
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+ }
+ return aStreamFile._retn();
}
SALOMEDS::TMPFile* VISU_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
- const char* theURL,
- bool isMultiFile) {
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - myMutex = "<<myMutex);
- if(myMutex){
- Mutex mt(myMutex,qApp);
- CORBA::String_var aString = SALOMEDS_Tool::GetTmpDir();
- TCollection_AsciiString aTmpDir = isMultiFile? (const Standard_CString)theURL: (const Standard_CString)aString.in();
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
- int aCounter = 0;
- TColStd_SequenceOfAsciiString aFileNames;
- SALOMEDS::Study_var aStudy = theComponent->GetStudy();
- SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
- for (; itBig->More(); itBig->Next()) {
- SALOMEDS::SObject_var gotBranch = itBig->Value();
- CORBA::Object_var anObj = SObjectToObject(gotBranch);
- if(CORBA::is_nil(anObj)) continue;
- Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj));
- if(pResult && abs(pResult->GetSourceId()) == Result_i::eFile){
+ const char* theURL,
+ bool isMultiFile)
+ {
+ Mutex mt(myMutex);
+ CORBA::String_var aString = SALOMEDS_Tool::GetTmpDir();
+ TCollection_AsciiString aTmpDir = isMultiFile? (const Standard_CString)theURL: (const Standard_CString)aString.in();
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
+ int aCounter = 0;
+ TColStd_SequenceOfAsciiString aFileNames;
+ SALOMEDS::Study_var aStudy = theComponent->GetStudy();
+ SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
+ for (; itBig->More(); itBig->Next()) {
+ SALOMEDS::SObject_var gotBranch = itBig->Value();
+ CORBA::Object_var anObj = SObjectToObject(gotBranch);
+ if(CORBA::is_nil(anObj)) continue;
+ if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
+ const Result_i::TSourceId& aSourceId = pResult->GetSourceId();
+ if(aSourceId == Result_i::eFile || aSourceId == Result_i::eRestoredFile){
const QFileInfo& aFileInfo = pResult->GetFileInfo();
- QString aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
+ QString aPrefix("");
+ if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str();
static QString aCommand;
aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1());
-
- if(system(aCommand) == -1){
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Cann't execute the command :"<<aCommand);
+
+ int aRes = system(aCommand);
+ if(aRes){
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Can't execute the command :"<<aCommand);
continue;
}else
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aCommand);
- TCollection_AsciiString aString(strdup(aFileName.latin1()));
+ TCollection_AsciiString aString(strdup(aFileName.latin1()));
+
HDFascii::ConvertFromHDFToASCII(strdup((aTmpDir + aString).ToCString()), true);
-
+
aFileNames.Append(aString);
}
}
- SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.Length() - "<<aFileNames.Length());
- if(aFileNames.Length() > 0){
- SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- aSeq->length(aFileNames.Length());
- for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--)
- aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString());
- aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile);
- if(!isMultiFile)
- SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
- }
- return aStreamFile._retn();
}
- return myVisuGen->Save(theComponent,theURL,isMultiFile);
+ SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.Length() - "<<aFileNames.Length());
+ if(aFileNames.Length() > 0){
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ aSeq->length(aFileNames.Length());
+ for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--)
+ aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString());
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile);
+ if(!isMultiFile)
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+ }
+ return aStreamFile._retn();
}
char* VISU_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
const char* IORString,
CORBA::Boolean isMultiFile,
- CORBA::Boolean isASCII) {
- if(MYDEBUG) MESSAGE("VISU_Gen_i::IORToLocalPersistentID - myMutex = "<<myMutex);
- if(myMutex){
- CORBA::String_var aString(IORString);
- if(strcmp(IORString,"") != 0){
- CORBA::ORB_ptr anORB = GetORB();
- CORBA::Object_var anObj = anORB->string_to_object(aString);
- if(!CORBA::is_nil(anObj)){
- Storable* pStorable = dynamic_cast<Storable*>(GetServant(anObj));
- if(pStorable != NULL){
- Mutex mt(myMutex,qApp);
- aString = pStorable->ToString().c_str();
- return aString._retn();
- }
+ CORBA::Boolean isASCII)
+ {
+ CORBA::String_var aString(IORString);
+ if(strcmp(IORString,"") != 0){
+ CORBA::ORB_ptr anORB = GetORB();
+ CORBA::Object_var anObj = anORB->string_to_object(aString);
+ if(!CORBA::is_nil(anObj)){
+ if(Storable* pStorable = dynamic_cast<Storable*>(GetServant(anObj).in())){
+ Mutex mt(myMutex);
+ aString = pStorable->ToString().c_str();
+ return aString._retn();
}
}
- return aString._retn();
}
- return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII);
+ return aString._retn();
}
char* VISU_Gen_i::GetID(){
- if(myMutex)
- return Base_i::GetID();
- return myVisuGen->GetID();
+ return Base_i::GetID();
}
void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){
- if(myMutex){
- if(!CORBA::is_nil(theStudy))
- myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
- }else
- myVisuGen->SetCurrentStudy(SALOMEDS::Study::_duplicate(theStudy));
+ if(!CORBA::is_nil(theStudy)){
+ CORBA::String_var aName = theStudy->Name();
+ MESSAGE("VISU_Gen_i::SetCurrentStudy - StudyId = "<<theStudy->StudyId()<<"; Name = '"<<aName.in()<<"'");
+ myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
+ }else{
+ MESSAGE("VISU_Gen_i::SetCurrentStudy : CORBA::is_nil(theStudy)");
+ }
}
+
SALOMEDS::Study_ptr VISU_Gen_i::GetCurrentStudy(){
- if(myMutex)
- return SALOMEDS::Study::_duplicate(myStudyDocument);
- return myVisuGen->GetCurrentStudy();
+ return SALOMEDS::Study::_duplicate(myStudyDocument);
}
+
ViewManager_ptr VISU_Gen_i::GetViewManager(){
- //omni_mutex aMutex;
- //omni_mutex_lock aMutexLock(aMutex);
- if(MYDEBUG) MESSAGE("VISU_Gen_i::GetViewManager : "<<myMutex);
- if(myMutex){
- Mutex mt(myMutex,qApp);
- ViewManager_i * aViewManager = new ViewManager_i(myStudyDocument);
- return ViewManager::_duplicate(aViewManager->_this());
- }
- return myVisuGen->GetViewManager();
+ Mutex mt(myMutex);
+ ViewManager_i * aViewManager = new ViewManager_i(myStudyDocument);
+ return ViewManager::_duplicate(aViewManager->_this());
}
SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName){
- if(myMutex){
- if(myStudyDocument->GetProperties()->IsLocked()) return SALOMEDS::SObject::_nil();
- Mutex mt(myMutex,qApp);
- SALOMEDS::SObject_var aRes = VISU::ImportTables(theFileName,myStudyDocument);
- return aRes._retn();
- }
- return myVisuGen->ImportTables(theFileName);
+ if(myStudyDocument->GetProperties()->IsLocked())
+ return SALOMEDS::SObject::_nil();
+ Mutex mt(myMutex);
+ SALOMEDS::SObject_var aRes = VISU::ImportTables(theFileName,myStudyDocument);
+ return aRes._retn();
+ }
+
+ CORBA::Boolean VISU_Gen_i::ExportTableToFile(SALOMEDS::SObject_ptr theTable,
+ const char* theFileName)
+ {
+ return VISU::ExportTableToFile(theTable, theFileName);
}
Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){
- if(myMutex){
- if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil();
- Mutex mt(myMutex,qApp);
- VISU::Result_var aResult;
- aFileInfo.setFile(theFileName);
- Result_i* pResult = new Result_i(myStudyDocument);
- if(pResult->Create(theFileName) != NULL)
- aResult = pResult->_this();
- return aResult._retn();
+ if(myStudyDocument->GetProperties()->IsLocked())
+ return Result::_nil();
+ Mutex mt(myMutex);
+ aFileInfo.setFile(theFileName);
+ Result_i* pResult = new Result_i(myStudyDocument);
+ if(pResult->Create(theFileName) != NULL)
+ return pResult->_this();
+ else{
+ pResult->_remove_ref();
+ return VISU::Result::_nil();
}
- return myVisuGen->ImportFile(theFileName);
+ }
+
+ Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
+ if(myStudyDocument->GetProperties()->IsLocked())
+ return Result::_nil();
+ Mutex mt(myMutex);
+ VISU::Result_var aResult;
+ aFileInfo.setFile(theFileName);
+ Result_i* pResult = new Result_i(myStudyDocument,Result_i::eRestoredFile);
+ if(pResult->Create(theFileName) != NULL)
+ aResult = pResult->_this();
+ return aResult._retn();
}
Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){
- if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMed : "<<myMutex);
- if(myMutex){
- if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil();
- Mutex mt(myMutex,qApp);
- Result_i* pResult = new Result_i(myStudyDocument);
- if(pResult->Create(theMedSObject) != NULL)
- return Result::_duplicate(pResult->_this());
+ if(myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
+ Mutex mt(myMutex);
+ Result_i* pResult = new Result_i(myStudyDocument);
+ if(pResult->Create(theMedSObject) != NULL)
+ return pResult->_this();
+ else{
+ pResult->_remove_ref();
+ return VISU::Result::_nil();
}
- return myVisuGen->ImportMed(theMedSObject);
}
Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){
- if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMedField : "<<myMutex);
- if(myMutex){
- if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil();
- Mutex mt(myMutex,qApp);
- Result_i* pResult = new Result_i(myStudyDocument);
- if(pResult->Create(theField) != NULL)
- return Result::_duplicate(pResult->_this());
+ if(myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
+ Mutex mt(myMutex);
+ Result_i* pResult = new Result_i(myStudyDocument);
+ if(pResult->Create(theField) != NULL)
+ return pResult->_this();
+ else{
+ pResult->_remove_ref();
+ return VISU::Result::_nil();
}
- return myVisuGen->ImportMedField(theField);
}
- Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity){
- if(MYDEBUG) MESSAGE("VISU_Gen_i::MeshOnEntity : "<<myMutex);
- if(myMutex){
- if(myStudyDocument->GetProperties()->IsLocked()) return Mesh::_nil();
- Mutex mt(myMutex,qApp);
- Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult));
- Mesh_i* aPresent = new Mesh_i(pResult);
- if(aPresent->Create(theMeshName,theEntity) != NULL)
- return Mesh::_duplicate(aPresent->_this());
+ Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity)
+ {
+ if(myStudyDocument->GetProperties()->IsLocked())
return Mesh::_nil();
+ Mutex mt(myMutex);
+ if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
+ Mesh_i* aPresent = new Mesh_i(pResult);
+ if(aPresent->Create(theMeshName,theEntity) != NULL)
+ return aPresent->_this();
+ else{
+ aPresent->_remove_ref();
+ return VISU::Mesh::_nil();
+ }
}
- return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity);
}
- Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName,
+ Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult,
+ const char* theMeshName,
VISU::Entity theEntity,
- const char* theFamilyName){
- if(MYDEBUG) MESSAGE("VISU_Gen_i::FamilyMeshOnEntity : "<<myMutex);
- if(myMutex){
- if(myStudyDocument->GetProperties()->IsLocked()) return Mesh::_nil();
- Mutex mt(myMutex,qApp);
- Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult));
- Mesh_i* aPresent = new Mesh_i(pResult);
- if(aPresent->Create(theMeshName,theEntity,theFamilyName) != NULL)
- return Mesh::_duplicate(aPresent->_this());
+ const char* theFamilyName)
+ {
+ if(myStudyDocument->GetProperties()->IsLocked())
return Mesh::_nil();
+ Mutex mt(myMutex);
+ if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
+ Mesh_i* aPresent = new Mesh_i(pResult);
+ if(aPresent->Create(theMeshName,theEntity,theFamilyName) != NULL)
+ return aPresent->_this();
+ else{
+ aPresent->_remove_ref();
+ return VISU::Mesh::_nil();
+ }
}
- return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName);
}
- Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult, const char* theMeshName,
- const char* theGroupName){
- if(MYDEBUG) MESSAGE("VISU_Gen_i::GroupMesh : "<<myMutex);
- if(myMutex){
- if(myStudyDocument->GetProperties()->IsLocked()) return Mesh::_nil();
- Mutex mt(myMutex,qApp);
- Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult));
- Mesh_i* aPresent = new Mesh_i(pResult);
- if(aPresent->Create(theMeshName,theGroupName) != NULL)
- return Mesh::_duplicate(aPresent->_this());
+ Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult,
+ const char* theMeshName,
+ const char* theGroupName)
+ {
+ if(myStudyDocument->GetProperties()->IsLocked())
return Mesh::_nil();
+ Mutex mt(myMutex);
+ if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
+ Mesh_i* aPresent = new Mesh_i(pResult);
+ if(aPresent->Create(theMeshName,theGroupName) != NULL)
+ return aPresent->_this();
+ else{
+ aPresent->_remove_ref();
+ return VISU::Mesh::_nil();
+ }
}
- return myVisuGen->GroupMesh(theResult,theMeshName,theGroupName);
}
- ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration)
+ ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Double theIteration)
{
- if(myMutex) return Prs3dOnField<VISU::ScalarMap_i>(theResult,theMeshName,theEntity,theFieldName,theIteration);
- return myVisuGen->ScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
+ return Prs3dOnField<VISU::ScalarMap_i>(theResult,theMeshName,theEntity,theFieldName,theIteration,true)._retn();
}
- DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration)
+ DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Double theIteration)
{
- if(myMutex) return Prs3dOnField<VISU::DeformedShape_i>(theResult,theMeshName,theEntity,theFieldName,theIteration);
- return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
+ return Prs3dOnField<VISU::DeformedShape_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
- Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration)
+ Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Double theIteration)
{
- if(myMutex) return Prs3dOnField<VISU::Vectors_i>(theResult,theMeshName,theEntity,theFieldName,theIteration);
- return myVisuGen->VectorsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
+ return Prs3dOnField<VISU::Vectors_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
- IsoSurfaces_ptr VISU_Gen_i::IsoSurfacesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration)
+ IsoSurfaces_ptr VISU_Gen_i::IsoSurfacesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Double theIteration)
{
- if(myMutex) return Prs3dOnField<VISU::IsoSurfaces_i>(theResult,theMeshName,theEntity,theFieldName,theIteration);
- return myVisuGen->IsoSurfacesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
+ return Prs3dOnField<VISU::IsoSurfaces_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
- StreamLines_ptr VISU_Gen_i::StreamLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration)
+ StreamLines_ptr VISU_Gen_i::StreamLinesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Double theIteration)
{
- if(myMutex) return Prs3dOnField<VISU::StreamLines_i>(theResult,theMeshName,theEntity,theFieldName,theIteration);
- return myVisuGen->StreamLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
+ return Prs3dOnField<VISU::StreamLines_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
- CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration)
+ CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Double theIteration)
{
- if(myMutex) return Prs3dOnField<VISU::CutPlanes_i>(theResult,theMeshName,theEntity,theFieldName,theIteration);
- return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
+ return Prs3dOnField<VISU::CutPlanes_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
- CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration)
+ CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Double theIteration)
{
- if(myMutex) return Prs3dOnField<VISU::CutLines_i>(theResult,theMeshName,theEntity,theFieldName,theIteration);
- return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
+ return Prs3dOnField<VISU::CutLines_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){
- if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateTable : "<<myMutex);
- if(myMutex){
- if(myStudyDocument->GetProperties()->IsLocked()) return Table::_nil();
- Mutex mt(myMutex,qApp);
- Table_i* aPresent = new Table_i(myStudyDocument,theTableEntry);
- if(aPresent->Create() != NULL)
- return Table::_duplicate(aPresent->_this());
+ if(myStudyDocument->GetProperties()->IsLocked())
return Table::_nil();
+ Mutex mt(myMutex);
+ Table_i* pPresent = new Table_i(myStudyDocument,theTableEntry);
+ if(pPresent->Create() != NULL)
+ return pPresent->_this();
+ else{
+ pPresent->_remove_ref();
+ return VISU::Table::_nil();
}
- return myVisuGen->CreateTable(theTableEntry);
- }
-
- Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow){
- if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateCurve : "<<myMutex);
- if(myMutex){
- if(myStudyDocument->GetProperties()->IsLocked()) return Curve::_nil();
- Mutex mt(myMutex,qApp);
- PortableServer::POA_ptr aPOA = GetPOA();
- Table_i* pTable = dynamic_cast<Table_i*>(aPOA->reference_to_servant(theTable));
- Curve_i* aPresent = new Curve_i(myStudyDocument,pTable,theHRow,theVRow);
- if(aPresent->Create() != NULL) {
- return Curve::_duplicate(aPresent->_this());
- }
+ }
+
+ Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable,
+ CORBA::Long theHRow,
+ CORBA::Long theVRow)
+ {
+ if(myStudyDocument->GetProperties()->IsLocked())
return Curve::_nil();
+ Mutex mt(myMutex);
+ PortableServer::POA_ptr aPOA = GetPOA();
+ Table_i* pTable = dynamic_cast<Table_i*>(aPOA->reference_to_servant(theTable));
+ Curve_i* pPresent = new Curve_i(myStudyDocument,pTable,theHRow,theVRow);
+ if(pPresent->Create() != NULL)
+ return pPresent->_this();
+ else{
+ pPresent->_remove_ref();
+ return VISU::Curve::_nil();
}
- return myVisuGen->CreateCurve(theTable,theHRow,theVRow);
}
+
Container_ptr VISU_Gen_i::CreateContainer(){
- if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateContainer : "<<myMutex);
- if(myMutex){
- if(myStudyDocument->GetProperties()->IsLocked()) return Container::_nil();
- Mutex mt(myMutex,qApp);
- Container_i* aPresent = new Container_i(myStudyDocument);
- if(aPresent->Create() != NULL) {
- return Container::_duplicate(aPresent->_this());
- }
+ if(myStudyDocument->GetProperties()->IsLocked())
return Container::_nil();
+ Mutex mt(myMutex);
+ Container_i* pPresent = new Container_i(myStudyDocument);
+ if(pPresent->Create() != NULL)
+ return pPresent->_this();
+ else{
+ pPresent->_remove_ref();
+ return VISU::Container::_nil();
}
- return myVisuGen->CreateContainer();
}
Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){
- if(myMutex){
- if(myStudyDocument->GetProperties()->IsLocked()) return Animation::_nil();
- Mutex mt(myMutex,qApp);
- if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateAnimation : "<<myMutex);
- VISU_TimeAnimation* anAnim = new VISU_TimeAnimation(myStudyDocument,theView3D);
- return Animation::_duplicate(anAnim->_this());
- }
- return myVisuGen->CreateAnimation(theView3D);
+ if(myStudyDocument->GetProperties()->IsLocked())
+ return Animation::_nil();
+ Mutex mt(myMutex);
+ if(VISU_TimeAnimation_i* anAnim = new VISU_TimeAnimation_i(myStudyDocument,theView3D)){
+ return anAnim->_this();
+ }else
+ return VISU::Animation::_nil();
}
void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Close : "<<myMutex);
- if(myMutex){
- Mutex mt(myMutex,qApp);
- SALOMEDS::Study_var aStudy = theComponent->GetStudy();
- if(!aStudy->_is_nil()){
- SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
- for (int i = 0; itBig->More(); itBig->Next(),i++) {
- SALOMEDS::SObject_var gotBranch = itBig->Value();
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Close : itBig->Next() = "<<i);
- CORBA::Object_var anObj = SObjectToObject(gotBranch);
- if(CORBA::is_nil(anObj)) continue;
- Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj));
- if(!pResult) continue;
- if(pResult->GetSourceId() == Result_i::eRestoredFile){ //Try remove its file and directory
- const QFileInfo& aFileInfo = pResult->GetFileInfo();
- static QString aCommand;
- aCommand.sprintf("rm %s",aFileInfo.filePath().latin1());
- if(system(aCommand) != -1 && MYDEBUG) MESSAGE("VISU_Gen_i::Close - "<<aCommand);
- aCommand.sprintf("rmdir --ignore-fail-on-non-empty %s",aFileInfo.dirPath().latin1());
- if(system(aCommand) != -1 && MYDEBUG) MESSAGE("VISU_Gen_i::Close - "<<aCommand);
- }
- }
- }
- return;
- }
- myVisuGen->Close(theComponent);
}
char* VISU_Gen_i::ComponentDataType(){
SALOMEDS::SObject_ptr theSObject,
CORBA::Object_ptr theObject,
const char* theName)
- throw (SALOME::SALOME_Exception)
+ throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SalomeException);
if(MYDEBUG) MESSAGE("VISU_Gen_i::PublishInStudy : "<<myMutex);
- if(myMutex){
- Mutex mt(myMutex,qApp);
- SALOMEDS::SObject_var aResultSO;
- Result_i* aResultObj = dynamic_cast<Result_i*>(GetServant(theObject));
- if (!aResultObj) return aResultSO._retn();
- const QFileInfo& aFileInfo = aResultObj->GetFileInfo();
- CORBA::String_var anEntry = aResultObj->Create(aFileInfo.filePath().latin1())->GetID();
- aResultSO = theStudy->FindObjectID(anEntry);
- return aResultSO._retn();
- }
- return myVisuGen->PublishInStudy(theStudy, theSObject, theObject, theName);
+ Mutex mt(myMutex);
+ SALOMEDS::SObject_var aResultSO;
+ Result_i* aResultObj = dynamic_cast<Result_i*>(GetServant(theObject).in());
+ if (!aResultObj) return aResultSO._retn();
+ const QFileInfo& aFileInfo = aResultObj->GetFileInfo();
+ CORBA::String_var anEntry = aResultObj->Create(aFileInfo.filePath().latin1())->GetID();
+ aResultSO = theStudy->FindObjectID(anEntry);
+ return aResultSO._retn();
}
CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
- if(0 && MYDEBUG) MESSAGE("VISU_Gen_i::CanCopy : "<<myMutex);
- if(myMutex){
- //Mutex mt(myMutex,qApp);
- SALOMEDS::GenericAttribute_var anAttr;
- if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false;
- try {
- SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- CORBA::String_var aValue = anIOR->Value();
- if(strcmp(aValue,"") != 0){
- CORBA::Object_ptr anObj = GetORB()->string_to_object(aValue);
- if (!CORBA::is_nil(anObj)){
- Result_var aResultObj = Result::_narrow(anObj);
- if(!aResultObj->_is_nil()){
- Result_i* pResult = dynamic_cast<Result_i*>(GetServant(aResultObj));
- if(pResult != NULL){
- if(abs(pResult->GetSourceId()) > Result_i::eFile)
- if((pResult->GetFileInfo()).filePath() == "Med") return false;
- return true;
- }
+ Mutex mt(myMutex);
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false;
+ try {
+ SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ CORBA::String_var aValue = anIOR->Value();
+ if(strcmp(aValue,"") != 0){
+ CORBA::Object_ptr anObj = GetORB()->string_to_object(aValue);
+ if (!CORBA::is_nil(anObj)){
+ Result_var aResultObj = Result::_narrow(anObj);
+ if(!aResultObj->_is_nil()){
+ if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(aResultObj).in())){
+ const Result_i::TSourceId& aSourceId = pResult->GetSourceId();
+ if(aSourceId == Result_i::eComponent || aSourceId == Result_i::eRestoredComponent)
+ if((pResult->GetFileInfo()).filePath() == "MED")
+ return false;
+ return true;
}
}
}
- } catch (...) {
- INFOS("Unknown exception was accured!");
}
- return false;
+ }catch (...){
+ INFOS("Unknown exception was accured!");
}
- return myVisuGen->CanCopy(theObject);
+ return false;
}
SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
- if(MYDEBUG) MESSAGE("VISU_Gen_i::CopyFrom : "<<myMutex);
- if(myMutex){
- Mutex mt(myMutex,qApp);
-
- theObjectID = 0;
- SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
- SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ Mutex mt(myMutex);
+ theObjectID = 0;
+ SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- PortableServer::POA_ptr aPOA = GetPOA();
-
- SALOMEDS::GenericAttribute_var anAttr;
- if (!theObject->FindAttribute(anAttr,"AttributeIOR")) return NULL;
- SALOMEDS::AttributeIOR_var anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
- CORBA::Object_var aCorbaObj;
- try {
- aCorbaObj = GetORB()->string_to_object(anIORAttr->Value());
- } catch(...) {
- aStreamFile->length(1);
- aStreamFile[0] = strdup("E")[0];
- return aStreamFile._retn();
- }
- if (CORBA::is_nil(aCorbaObj)) {
- return NULL;
- }
-
- Storable* pStorable = dynamic_cast<Storable*>(GetServant(aCorbaObj));
- if (!pStorable) {
+ PortableServer::POA_ptr aPOA = GetPOA();
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (!theObject->FindAttribute(anAttr,"AttributeIOR")) return NULL;
+ SALOMEDS::AttributeIOR_var anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ CORBA::Object_var aCorbaObj;
+ try {
+ aCorbaObj = GetORB()->string_to_object(anIORAttr->Value());
+ } catch(...) {
+ aStreamFile->length(1);
+ aStreamFile[0] = strdup("E")[0];
+ return aStreamFile._retn();
+ }
+ if (CORBA::is_nil(aCorbaObj)) {
+ return NULL;
+ }
+
+ Storable* pStorable = dynamic_cast<Storable*>(GetServant(aCorbaObj).in());
+ if (!pStorable) {
+ return NULL;
+ }
+ CORBA::String_var aTmpDir = SALOMEDS_Tool::GetTmpDir();
+
+ string aStr = pStorable->ToString().c_str();
+ ofstream stmOut2((string(aTmpDir) + string("copy_persistent")).c_str(),ios::out);
+ stmOut2<<aStr<<endl;
+ stmOut2.close();
+
+ if (Result_i* aResultObj = dynamic_cast<Result_i*>(aPOA->reference_to_servant(aCorbaObj))) {
+ string aFileName = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + "_";
+ const QFileInfo& aFileInfo = aResultObj->GetFileInfo();
+ aFileName += aFileInfo.fileName().latin1();
+ static QString aCommand;
+ aCommand.sprintf("cp %s %s",
+ aFileInfo.filePath().latin1(),
+ (string(aTmpDir) + aFileName).c_str());
+ if(system(aCommand) == -1) {
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand);
return NULL;
}
- CORBA::String_var aTmpDir = SALOMEDS_Tool::GetTmpDir();
-
- string aStr = pStorable->ToString().c_str();
- ofstream stmOut2((string(aTmpDir) + string("copy_persistent")).c_str(),ios::out);
- stmOut2<<aStr<<endl;
- stmOut2.close();
-
- Result_i* aResultObj = dynamic_cast<Result_i*>(aPOA->reference_to_servant(aCorbaObj));
- if (aResultObj) {
- string aFileName = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + "_";
- const QFileInfo& aFileInfo = aResultObj->GetFileInfo();
- aFileName += aFileInfo.fileName().latin1();
- static QString aCommand;
- aCommand.sprintf("cp %s %s",
- aFileInfo.filePath().latin1(),
- (string(aTmpDir) + aFileName).c_str());
- if(system(aCommand) == -1) {
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand);
- return NULL;
- }
-
- aSeq->length(2);
- aSeq[0] = "copy_persistent";
- aSeq[1] = aFileName.c_str();
- } else {
- aSeq->length(1);
- aSeq[0] = "copy_persistent";
- }
- aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), false);
- SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true);
-
- // Assign an ID = 1 the the type VISU::Result
- theObjectID = 1;
-
-
- SALOMEDS::SComponent_var aSComponent = theObject->GetStudy()->FindComponent("VISU");
- return aStreamFile._retn();
+
+ aSeq->length(2);
+ aSeq[0] = "copy_persistent";
+ aSeq[1] = aFileName.c_str();
+ } else {
+ aSeq->length(1);
+ aSeq[0] = "copy_persistent";
}
- return myVisuGen->CopyFrom(theObject, theObjectID);
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), false);
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true);
+
+ // Assign an ID = 1 the the type VISU::Result
+ theObjectID = 1;
+
+
+ SALOMEDS::SComponent_var aSComponent = theObject->GetStudy()->FindComponent("VISU");
+ return aStreamFile._retn();
}
CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
// The VISU component can paste only objects copied by VISU component
// and with the object type = 1
- if(0 && MYDEBUG) MESSAGE("VISU_Gen_i::CanPaste : "<<myMutex);
- if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1) return false;
+ if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1)
+ return false;
return true;
}
SALOMEDS::SObject_ptr VISU_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
CORBA::Long theObjectID,
- SALOMEDS::SObject_ptr theObject) {
- if(MYDEBUG) MESSAGE("VISU_Gen_i::PasteInto : "<<myMutex);
- if(myMutex){
- Mutex mt(myMutex,qApp);
- SALOMEDS::SObject_var aResultSO;
- if (theObjectID != 1) return aResultSO._retn();
-
- CORBA::String_var aTmpDir = (const char*)SALOMEDS_Tool::GetTmpDir();
- SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false);
-
- ifstream stmIn((string(aTmpDir) + string("copy_persistent")).c_str());
-// ifstream stmIn((string(aTmpDir) + string("copy_persistent")).c_str(),ios::in);
- stmIn.seekg(0, ios::end);
- int aLength = stmIn.tellg();
- stmIn.seekg(0, ios::beg);
- char* aString = new char[aLength+1];
- stmIn.read(aString, aLength);
- aString[aLength] = 0;
- myIsMultiFile = true;
-
- string aFileName(aTmpDir.in());
- if(aSeq->length() > 1) aFileName += aSeq[1].in();
-
- SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent();
- SALOMEDS::Study_var aStudy = theObject->GetStudy();
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
- CORBA::String_var aComponentID(aComponent->GetID()), aSObjID(theObject->GetID());
-
- if (strcmp(aComponentID, aSObjID) == 0) //create the new result SObject
- aResultSO = aStudyBuilder->NewObject(aComponent);
- else
- aResultSO = SALOMEDS::SObject::_duplicate(theObject);
-
- //Just for Result::Restore to find the Comment attribute :(
- SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
-
- Storable* aStorable = Storable::Create(aResultSO,aFileName,aString);
-
- SALOMEDS::ListOfFileNames_var aSeqToRm = new SALOMEDS::ListOfFileNames;
- aSeqToRm->length(1);
- aSeqToRm[0] = "copy_persistent";
- SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeqToRm.in(), true);
-
- anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
- SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- CORBA::String_var anIORValue(aStorable->GetID());
- anIOR->SetValue(anIORValue);
+ SALOMEDS::SObject_ptr theObject)
+ {
+ Mutex mt(myMutex);
+ SALOMEDS::SObject_var aResultSO;
+ if (theObjectID != 1)
return aResultSO._retn();
- }
- return myVisuGen->PasteInto(theStream,theObjectID,theObject);
+
+ CORBA::String_var aTmpDir = (const char*)SALOMEDS_Tool::GetTmpDir();
+ SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false);
+
+ ifstream stmIn((string(aTmpDir) + string("copy_persistent")).c_str());
+ stmIn.seekg(0, ios::end);
+ int aLength = stmIn.tellg();
+ stmIn.seekg(0, ios::beg);
+ char* aString = new char[aLength+1];
+ stmIn.read(aString, aLength);
+ aString[aLength] = 0;
+ myIsMultiFile = false;
+
+ string aFileName(aTmpDir.in());
+ if(aSeq->length() > 1) aFileName += aSeq[1].in();
+
+ SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent();
+ SALOMEDS::Study_var aStudy = theObject->GetStudy();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ CORBA::String_var aComponentID(aComponent->GetID()), aSObjID(theObject->GetID());
+
+ if (strcmp(aComponentID, aSObjID) == 0) //create the new result SObject
+ aResultSO = aStudyBuilder->NewObject(aComponent);
+ else
+ aResultSO = SALOMEDS::SObject::_duplicate(theObject);
+
+ //Just for Result::Restore to find the Comment attribute :(
+ SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
+
+ Storable* aStorable = Storable::Create(aResultSO,aFileName,aString);
+
+ SALOMEDS::ListOfFileNames_var aSeqToRm = new SALOMEDS::ListOfFileNames;
+ aSeqToRm->length(1);
+ aSeqToRm[0] = "copy_persistent";
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeqToRm.in(), true);
+
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
+ SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ CORBA::String_var anIORValue(aStorable->GetID());
+ anIOR->SetValue(anIORValue);
+ return aResultSO._retn();
}
};