#include "QAD_Desktop.h"
#include "QAD_Study.h"
#include "SALOMEDS_Tool.hxx"
-
#include <strstream>
#include <TCollection_AsciiString.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
//static int IS_LOADED = (cout<<"\n----------------- VisuEngine_factory is loaded -----------------\n", 1);
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() ;
- }
+ 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_var orb, PortableServer::POA_var poa, QMutex* theMutex){
+// if(MYDEBUG) MESSAGE("extern \"C\" GetVisuGen");
+// VISU::VISU_Gen_i * aVISU_Gen = new VISU::VISU_Gen_i(orb,poa,theMutex);
+// return VISU::VISU_Gen::_duplicate(aVISU_Gen->_this());
+// }
+
Engines::Component_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 Engines::Component::_narrow( VISU::VISU_Gen::_duplicate(aVISU_Gen->_this()));
- //return aVISU_Gen->_this();
- }
+ GetVisuGen(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex* theMutex){
+ if(MYDEBUG) MESSAGE("extern \"C\" GetVisuGen");
+ VISU::VISU_Gen_i * aVISU_Gen = new VISU::VISU_Gen_i(orb,poa,theMutex);
+ return Engines::Component::_narrow( VISU::VISU_Gen::_duplicate(aVISU_Gen->_this()) );
+ }
}
namespace VISU{
QMutex* Base_i::myMutex = NULL;
CORBA::ORB_var Base_i::myOrb;
PortableServer::POA_var Base_i::myPOA;
- SALOME_NamingService* Base_i::myNamingService;
- SALOME_LifeCycleCORBA* Base_i::myEnginesLifeCycle;
- VISU_Gen_i* Base_i::myVisuGenImpl;
- VISU_Gen_var Base_i::GetVisuGenInter() { return myVisuGenImpl->_this();}
Base_i::~Base_i() {}
char* Base_i::GetID(){
//CORBA::Object_var anObject = _this();
}
//===========================================================================
static Storable::TCallbackMap VisuStoreMap;
- string Storable::ToString(){
+ const char* Storable::ToString(){
ostrstream strOut;
Storable::DataToStream( strOut, "myComment", GetComment() );
ToStream(strOut);
strOut<<ends;
if(MYDEBUG) MESSAGE("Storable::ToString - "<<strOut.str());
- auto_ptr<char> aRet(strOut.str());
- return aRet.get();
+ return strOut.str();
}
-
void Storable::Registry(const char* theComment, TStorableEngine theEngine)
throw(std::logic_error&)
{
throw std::logic_error("Storable::Registry >> dupliacte registring !!!");
}
}
-
void RegistryStorable() throw(std::logic_error&) {
//Storable::Registry(View3D_i::myComment.c_str(),&View3DRestore);
Storable::Registry(Result_i::myComment.c_str(),&ResultRestore);
Storable::Registry(Container_i::myComment.c_str(),&ContainerRestore);
}
+ SALOMEDS::SObject_ptr Storable::GetResultSO(SALOMEDS::SObject_ptr theSObject) {
+ CORBA::String_var aComponentID(theSObject->GetFatherComponent()->GetID());
+ SALOMEDS::SObject_var aResult = SALOMEDS::SObject::_duplicate(theSObject);
+ CORBA::String_var aFatherID(aResult->GetFather()->GetID());
+ while(strcmp(aComponentID, aFatherID)) {
+ aResult = aResult->GetFather();
+ aFatherID = aResult->GetFather()->GetID();
+ if (strlen(aFatherID) < 3) break;
+ }
+ return aResult._retn();
+ }
+
void Storable::StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap){
- if(0 && MYDEBUG) MESSAGE("Storable::StrToMap : string="<<theStr);
+ if(MYDEBUG) MESSAGE("Storable::StrToMap : string="<<theStr);
QStringList strList = QStringList::split( ";", theStr, false );
for ( int i = 0; i < strList.count(); i++ ) {
QString next = strList[ i ];
//===========================================================================
PortableServer::Servant GetServant(CORBA::Object_ptr theObject){
- PortableServer::POA_ptr aPOA = Base_i::GetPOA();
+ PortableServer::POA_var aPOA = GetPOA();
if(CORBA::is_nil(theObject))
if(MYDEBUG) MESSAGE("GetServant - CORBA::is_nil(theObject)");
return aPOA->reference_to_servant(theObject);
CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject){
SALOMEDS::GenericAttribute_var anAttr;
CORBA::Object_var anObj;
- try{
- if(theSObject->FindAttribute(anAttr, "AttributeIOR")){
- SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- CORBA::String_var aValue = anIOR->Value();
- CORBA::ORB_ptr anORB = Base_i::GetORB();
- if(strcmp(aValue,"") != 0)
- anObj = anORB->string_to_object(aValue);
- }
- }catch(...){
- MESSAGE("SObjectToObject - Unknown exception was accured!");
+ if(theSObject->FindAttribute(anAttr, "AttributeIOR")){
+ SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ CORBA::String_var aValue = anIOR->Value();
+ CORBA::ORB_var anORB = GetORB();
+ if(strcmp(aValue,"") != 0)
+ anObj = anORB->string_to_object(aValue);
}
return anObj;
}
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_OBJBROWSER_Visu" );
- VISU_Gen_var aVisuGen = Base_i::GetVisuGenInter();
+ VISU_Gen_var aVisuGen = GetVisu();
aStudyBuilder->DefineComponentInstance(aSComponent,aVisuGen);
if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
aStudyBuilder->CommitCommand();
string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
const char* theComment, int IsAllLevels)
{
- if(0 && MYDEBUG) MESSAGE("FindEntryWithComment - '"<<theComment<<"'");
+ if(MYDEBUG) MESSAGE("FindEntryWithComment - '"<<theComment<<"'");
SALOMEDS::ChildIterator_var anIter =
theStudyDocument->NewChildIterator(theStudyDocument->FindObjectID(theStartEntry));
anIter->InitEx(IsAllLevels);
const char* thePersistentRef, const char* theComment,
CORBA::Boolean theCreateNew)
{
- if(0 && MYDEBUG)
+ if(MYDEBUG)
MESSAGE("CreateAttributes - theName = "<<theName<<"; theComment = '"<<theComment<<
"'; theFatherEntry = "<<theFatherEntry);
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
}
CORBA::String_var anEntry = newObj->GetID();
string aRet(anEntry);
- if(0 && MYDEBUG) MESSAGE("CreateAttributes - anEntry = "<<aRet<<"; IOR = "<<theIOR);
+ if(MYDEBUG) MESSAGE("CreateAttributes - anEntry = "<<aRet<<"; IOR = "<<theIOR);
return aRet;
}
//===========================================================================
+ static CORBA::ORB_var VisuORB;
+ static PortableServer::POA_var VisuPOA;
static SALOMEDS::SComponent_var VisuSComponent;
static string VisuTmpDir;
+ static VISU_Gen_i* VisuGen;
static CORBA::Boolean myIsMultiFile;
- const CORBA::Boolean IsMultifile() {
- return myIsMultiFile;
- }
- //===========================================================================
- 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();
- myVisuGen = VISU::VISU_Gen::_narrow( aSession->GetVisuComponent() );
- }
-
- 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;
- Base_i::myOrb = CORBA::ORB::_duplicate(theORB);
- Base_i::myPOA = PortableServer::POA::_duplicate(thePOA);
- Base_i::myNamingService = theNamingService;
- static SALOME_LifeCycleCORBA aEnginesLifeCycle(theNamingService);
- Base_i::myEnginesLifeCycle = &aEnginesLifeCycle;
- Base_i::myVisuGenImpl = this;
- RegistryStorable();
- if(!QAD_Application::getDesktop()->getActiveStudy())
- QAD_Application::getDesktop()->createStudy();
- myStudyDocument =
- QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
- Base_i::myPOA->activate_object(this);
- }
-
- VISU_Gen_i::~VISU_Gen_i(){
- if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
+ CORBA::ORB_var GetORB() { return VisuORB;}
+ PortableServer::POA_var GetPOA() { return VisuPOA;}
+ VISU_Gen_var GetVisu() {
+ return VISU_Gen::_duplicate(VisuGen->_this());
+ //return VisuGen->_this();
}
+ const CORBA::Boolean IsMultifile() { return myIsMultiFile;}
//===========================================================================
bool VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
const SALOMEDS::TMPFile & theStream,
const char* aLocalPersistentID,
CORBA::Boolean isMultiFile) {
if(myMutex){
+ Mutex mt(myMutex,qApp);
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();
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();
+ TCollection_AsciiString aTmpDir =
+ (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
int aCounter = 0;
TColStd_SequenceOfAsciiString aFileNames;
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){
+ if(pResult){
const QFileInfo& aFileInfo = pResult->GetFileInfo();
QString aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
- QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str();
+ QString aFileName = aPrefix + "_" + pResult->GetName();
static QString aCommand;
aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1());
if(system(aCommand) == -1){
CORBA::Boolean isMultiFile) {
if(MYDEBUG) MESSAGE("VISU_Gen_i::IORToLocalPersistentID - myMutex = "<<myMutex);
if(myMutex){
+ Mutex mt(myMutex,qApp);
+ CORBA::ORB_var anORB = GetORB();
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();
+ aString = pStorable->ToString();
return aString._retn();
}
}
return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile);
}
+ //===========================================================================
+ 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);
+ SALOME::Session_var aSession(SALOME::Session::_narrow(aNamingService.Resolve("/Kernel/Session")));
+ //aSession->GetInterface();
+ //myVisuGen = aSession->GetVisuGen();
+ myVisuGen = VISU::VISU_Gen::_narrow( aSession->GetVisuComponent() );
+ }
+ VISU_Gen_i::VISU_Gen_i(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex* theMutex) :
+ Engines_Component_i()
+ {
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<<theMutex);
+ Base_i::myMutex = theMutex;
+ Base_i::myOrb = CORBA::ORB::_duplicate(orb);
+ Base_i::myPOA = PortableServer::POA::_duplicate(poa);
+ Mutex mt(myMutex,qApp);
+ VisuORB = orb;
+ VisuPOA = poa;
+ VisuGen = this;
+ VisuPOA->activate_object(this);
+ RegistryStorable();
+ if(!QAD_Application::getDesktop()->getActiveStudy())
+ QAD_Application::getDesktop()->createStudy();
+ myStudyDocument =
+ QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
+ }
+ VISU_Gen_i::~VISU_Gen_i(){
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
+ }
void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){
//if(MYDEBUG) MESSAGE("VISU_Gen_i::SetCurrentStudy : "<<(!theStudy->_is_nil()));
if(myMutex)
}
return myVisuGen->ImportFile(theFileName);
}
-
- Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){
+ Result_ptr VISU_Gen_i::ImportMed(SALOME_MED::FIELD_ptr theField){
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)
+ if(pResult->Create(theField) != NULL)
+ return Result::_duplicate(pResult->_this());
+ return Result::_nil();
+ }
+ return myVisuGen->ImportMed(theField);
+ }
+ Result_ptr VISU_Gen_i::ImportMedMesh(SALOME_MED::MESH_ptr theMesh){
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMedMesh : "<<myMutex);
+ if(myMutex){
+ if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil();
+ Mutex mt(myMutex,qApp);
+ Result_i* pResult = new Result_i(myStudyDocument);
+ if(pResult->Create(theMesh) != NULL)
+ return Result::_duplicate(pResult->_this());
+ return Result::_nil();
+ }
+ return myVisuGen->ImportMedMesh(theMesh);
+ }
+
+ Result_ptr VISU_Gen_i::ImportMedSupport(SALOME_MED::SUPPORT_ptr theSupport){
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMedSupport : "<<myMutex);
+ if(myMutex){
+ if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil();
+ Mutex mt(myMutex,qApp);
+ Result_i* pResult = new Result_i(myStudyDocument);
+ if(pResult->Create(theSupport) != NULL)
return Result::_duplicate(pResult->_this());
return Result::_nil();
}
- return myVisuGen->ImportMed(theMedSObject);
+ return myVisuGen->ImportMedSupport(theSupport);
}
Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity){
if(myMutex){
if(myStudyDocument->GetProperties()->IsLocked()) return Curve::_nil();
Mutex mt(myMutex,qApp);
- PortableServer::POA_ptr aPOA = GetPOA();
+ PortableServer::POA_var 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) {
CORBA::Object_var anObj = SObjectToObject(gotBranch);
if(CORBA::is_nil(anObj)) continue;
Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj));
- if(pResult->GetSourceId() == Result_i::eRestoredFile){ //Try remove its file and directory
+ if(pResult->IsRestored()){ //Try remove its file and directory
const QFileInfo& aFileInfo = pResult->GetFileInfo();
static QString aCommand;
aCommand.sprintf("rm %s",aFileInfo.filePath().latin1());
if(myMutex){
Mutex mt(myMutex,qApp);
SALOMEDS::SObject_var aResultSO;
- Result_i* aResultObj = dynamic_cast<Result_i*>(GetServant(theObject));
+ PortableServer::POA_var aPOA = GetPOA();
+ Result_i* aResultObj = dynamic_cast<Result_i*>(aPOA->reference_to_servant(theObject));
if (!aResultObj) return aResultSO._retn();
+
+ CORBA::String_var anEntry;
const QFileInfo& aFileInfo = aResultObj->GetFileInfo();
- CORBA::String_var anEntry = aResultObj->Create(aFileInfo.filePath().latin1())->GetID();
+ anEntry = strdup(aResultObj->Create(aFileInfo.filePath().latin1())->GetID());
+// if (CORBA::is_nil(theSObject)) {
+// anEntry = strdup(aResultObj->Create(SALOMEDS::SObject::_nil(), theName));
+// } else {
+// if (!theSObject->ReferencedObject(aResultSO))
+// THROW_SALOME_CORBA_EXCEPTION("Publish error: bad referenced SObject",SALOME::BAD_PARAM);
+// anEntry = strdup(aResultObj->Create(aResultSO, (const char *)theName));
+// }
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(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;
- }
- }
- }
+ CORBA::Object_var anObj = GetORB()->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
+ if (CORBA::is_nil(anObj)) return false;
+ else {
+ Result_var aResultObj = Result::_narrow(anObj);
+ if (aResultObj->_is_nil()) return false;
}
} catch (...) {
- MESSAGE("Unknown exception was accured!");
+ return false;
}
- return false;
+ return true;
}
return myVisuGen->CanCopy(theObject);
}
SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- PortableServer::POA_ptr aPOA = GetPOA();
+ PortableServer::POA_var aPOA = GetPOA();
SALOMEDS::GenericAttribute_var anAttr;
if (!theObject->FindAttribute(anAttr,"AttributeIOR")) return NULL;
}
CORBA::String_var aTmpDir = SALOMEDS_Tool::GetTmpDir();
- string aStr = pStorable->ToString().c_str();
+ char* aStr = strdup(pStorable->ToString());
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())) + "_";
+ string aStudyPrefix = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + string("_");
+
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());
+ (string(aTmpDir)+aStudyPrefix + string(aResultObj->GetName())).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();
+ aSeq[1] = (aStudyPrefix + string(aResultObj->GetName())).c_str();
} else {
aSeq->length(1);
aSeq[0] = "copy_persistent";
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(MYDEBUG) MESSAGE("VISU_Gen_i::CanPaste : "<<myMutex);
if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1) return false;
return true;
}
SALOMEDS::SObject_var aResultSO;
if (theObjectID != 1) return aResultSO._retn();
- CORBA::String_var aTmpDir = (const char*)SALOMEDS_Tool::GetTmpDir();
+ CORBA::String_var aTmpDir = strdup(SALOMEDS_Tool::GetTmpDir());
SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false);
+ SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent();
+ SALOMEDS::Study_var aStudy = theObject->GetStudy();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ CORBA::ORB_var anORB = GetORB();
+
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);
stmIn.read(aString, aLength);
aString[aLength] = 0;
myIsMultiFile = true;
-
- string aFileName(aTmpDir.in());
- if(aSeq->length() > 1) aFileName += aSeq[1].in();
- Storable* aStorable = Storable::Create(theObject,aFileName,aString);
+ Storable* aStorable = Storable::Create(theObject,aTmpDir.in(),aString);
SALOMEDS::ListOfFileNames_var aSeqToRm = new SALOMEDS::ListOfFileNames;
aSeqToRm->length(1);
aSeqToRm[0] = "copy_persistent";
SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeqToRm.in(), true);
- 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
+ CORBA::String_var aComponentIDString(aComponent->GetID());
+ if (strcmp(aComponentIDString, theObject->GetID()) == 0) {
+ // create the new result SObject
aResultSO = aStudyBuilder->NewObject(aComponent);
- else
+ } else {
aResultSO = SALOMEDS::SObject::_duplicate(theObject);
- SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
- SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- CORBA::String_var anIORValue(aStorable->GetID());
- anIOR->SetValue(anIORValue);
+ }
+ SALOMEDS::AttributeIOR_var anIOR =
+ SALOMEDS::AttributeIOR::_narrow(aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR"));
+ anIOR->SetValue(aStorable->GetID());
return aResultSO._retn();
}
return myVisuGen->PasteInto(theStream,theObjectID,theObject);