From: nri Date: Thu, 10 Jul 2003 16:44:25 +0000 (+0000) Subject: NRI : Merge from V1_2. X-Git-Tag: V_02092003~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3787593f6249b07acb9ead915b5d54e75515e186;p=modules%2Fvisu.git NRI : Merge from V1_2. --- diff --git a/src/VISU_I/VISUConfig.hh b/src/VISU_I/VISUConfig.hh index c4810630..3b5dcd8d 100644 --- a/src/VISU_I/VISUConfig.hh +++ b/src/VISU_I/VISUConfig.hh @@ -26,6 +26,8 @@ using namespace std; #include CORBA_SERVER_HEADER(MED) #include CORBA_SERVER_HEADER(SALOMEDS) #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOME_NamingService.hxx" +#include "SALOME_LifeCycleCORBA.hxx" #include "Utils_CorbaException.hxx" #include "utilities.h" @@ -34,6 +36,7 @@ using namespace std; namespace VISU{ //=========================================================================== + class VISU_Gen_i; class Base_i : public virtual POA_VISU::Base, public virtual PortableServer::RefCountServantBase { @@ -45,6 +48,16 @@ namespace VISU{ static QMutex* myMutex; static CORBA::ORB_var myOrb; static PortableServer::POA_var myPOA; + static SALOME_NamingService* myNamingService; + static VISU_Gen_i* myVisuGenImpl; + static SALOME_LifeCycleCORBA* myEnginesLifeCycle; + public: + static CORBA::ORB_ptr GetORB() { return myOrb;} + static PortableServer::POA_ptr GetPOA() { return myPOA;} + static SALOME_NamingService* GetNS() { return myNamingService;} + static SALOME_LifeCycleCORBA* GetLCC() { return myEnginesLifeCycle;} + static VISU_Gen_i* GetVisuGenImpl() { return myVisuGenImpl;} + static VISU_Gen_var GetVisuGenInter(); }; //=========================================================================== class Mutex{ @@ -60,7 +73,7 @@ namespace VISU{ protected: virtual void ToStream(std::ostringstream& theStr) = 0; public: - const char* ToString(); + string ToString(); virtual const char* GetComment() const = 0; typedef map TRestoringMap; typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject, @@ -79,9 +92,7 @@ namespace VISU{ static void DataToStream(std::ostringstream& theStr, const QString& theName, const double theVal); }; //=========================================================================== - CORBA::ORB_var GetORB(); - PortableServer::POA_var GetPOA(); - VISU_Gen_var GetVisu(); + const CORBA::Boolean IsMultifile(); PortableServer::Servant GetServant(CORBA::Object_ptr theObject); CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject); SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument); @@ -92,7 +103,6 @@ namespace VISU{ CORBA::Boolean theCreateNew = true); string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry, const char* theComment, int IsAllLevels = true); - const CORBA::Boolean IsMultifile(); } #endif diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index c3e557ce..1e8aa09d 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -26,6 +26,7 @@ using namespace std; #include #include CORBA_SERVER_HEADER(SALOME_Session) +#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) #include #include @@ -42,7 +43,7 @@ static int MYDEBUG = 0; //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, + VISUEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, const char *instanceName, const char *interfaceName) { if(MYDEBUG) MESSAGE("VisuEngine_factory : "<_this();} Base_i::~Base_i() {} char* Base_i::GetID(){ //CORBA::Object_var anObject = _this(); @@ -116,6 +121,7 @@ namespace VISU{ //apo - auto_ptr aRet(strOut.str()); return strOut.str(); } + void Storable::Registry(const char* theComment, TStorableEngine theEngine) throw(std::logic_error&) { @@ -124,6 +130,7 @@ namespace VISU{ 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); @@ -140,20 +147,8 @@ namespace VISU{ 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(MYDEBUG) MESSAGE("Storable::StrToMap : string="<reference_to_servant(theObject); @@ -242,12 +237,16 @@ namespace VISU{ CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject){ SALOMEDS::GenericAttribute_var anAttr; CORBA::Object_var anObj; - 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); + 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!"); } return anObj; } @@ -264,7 +263,7 @@ namespace VISU{ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); //NRI aName->SetValue("Visu"); - CORBA::ORB_var anORB = GetORB(); + 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); @@ -277,7 +276,7 @@ namespace VISU{ SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap( "ICON_OBJBROWSER_Visu" ); - VISU_Gen_var aVisuGen = GetVisu(); + VISU_Gen_var aVisuGen = Base_i::GetVisuGenInter(); aStudyBuilder->DefineComponentInstance(aSComponent,aVisuGen); if (aLocked) theStudyDocument->GetProperties()->SetLocked(true); aStudyBuilder->CommitCommand(); @@ -288,7 +287,7 @@ namespace VISU{ string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry, const char* theComment, int IsAllLevels) { - if(MYDEBUG) MESSAGE("FindEntryWithComment - '"<NewChildIterator(theStudyDocument->FindObjectID(theStartEntry)); anIter->InitEx(IsAllLevels); @@ -316,7 +315,7 @@ namespace VISU{ const char* thePersistentRef, const char* theComment, CORBA::Boolean theCreateNew) { - if(MYDEBUG) + if(0 && MYDEBUG) MESSAGE("CreateAttributes - theName = "<GetInterface(); - Engines::Component_var aComponent = aSession->GetVisuGen(); + Engines::Component_var aComponent = aSession->GetVisuComponent(); myVisuGen = VISU::VISU_Gen::_narrow(aComponent); } @@ -407,7 +403,6 @@ namespace VISU{ VISU_Gen_i::~VISU_Gen_i(){ if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i"); } - const CORBA::Boolean IsMultifile() { return myIsMultiFile;} //=========================================================================== bool VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile & theStream, @@ -443,9 +438,9 @@ namespace VISU{ CORBA::Boolean isMultiFile, CORBA::Boolean isASCII) { 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(); @@ -462,8 +457,8 @@ namespace VISU{ if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - myMutex = "<(GetServant(anObj)); - if(pResult){ + if(pResult && abs(pResult->GetSourceId()) == Result_i::eFile){ const QFileInfo& aFileInfo = pResult->GetFileInfo(); QString aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()); - QString aFileName = aPrefix + "_" + pResult->GetName(); + 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){ @@ -564,15 +559,15 @@ namespace VISU{ CORBA::Boolean isASCII) { if(MYDEBUG) MESSAGE("VISU_Gen_i::IORToLocalPersistentID - myMutex = "<string_to_object(aString); if(!CORBA::is_nil(anObj)){ Storable* pStorable = dynamic_cast(GetServant(anObj)); if(pStorable != NULL){ - aString = pStorable->ToString(); + Mutex mt(myMutex,qApp); + aString = pStorable->ToString().c_str(); return aString._retn(); } } @@ -582,45 +577,6 @@ namespace VISU{ return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII); } - //=========================================================================== - 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 : "<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 = aSession->GetVisuGen(); - myVisuGen = VISU::VISU_Gen::_narrow( aSession->GetVisuComponent() ); - } - VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, QMutex* theMutex) : - Engines_Component_i() - { - if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<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) @@ -668,42 +624,18 @@ namespace VISU{ } return myVisuGen->ImportFile(theFileName); } - Result_ptr VISU_Gen_i::ImportMed(SALOME_MED::FIELD_ptr theField){ + + Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){ if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMed : "<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()); - 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 : "<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 : "<GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex,qApp); - Result_i* pResult = new Result_i(myStudyDocument); - if(pResult->Create(theSupport) != NULL) + if(pResult->Create(theMedSObject) != NULL) return Result::_duplicate(pResult->_this()); return Result::_nil(); } - return myVisuGen->ImportMedSupport(theSupport); + return myVisuGen->ImportMed(theMedSObject); } Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){ @@ -904,7 +836,7 @@ namespace VISU{ if(myMutex){ if(myStudyDocument->GetProperties()->IsLocked()) return Curve::_nil(); Mutex mt(myMutex,qApp); - PortableServer::POA_var aPOA = GetPOA(); + PortableServer::POA_ptr aPOA = GetPOA(); Table_i* pTable = dynamic_cast(aPOA->reference_to_servant(theTable)); Curve_i* aPresent = new Curve_i(myStudyDocument,pTable,theHRow,theVRow); if(aPresent->Create() != NULL) { @@ -987,20 +919,10 @@ namespace VISU{ if(myMutex){ Mutex mt(myMutex,qApp); SALOMEDS::SObject_var aResultSO; - PortableServer::POA_var aPOA = GetPOA(); - Result_i* aResultObj = dynamic_cast(aPOA->reference_to_servant(theObject)); + Result_i* aResultObj = dynamic_cast(GetServant(theObject)); if (!aResultObj) return aResultSO._retn(); - - CORBA::String_var anEntry; const QFileInfo& aFileInfo = aResultObj->GetFileInfo(); - 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)); -// } + CORBA::String_var anEntry = aResultObj->Create(aFileInfo.filePath().latin1())->GetID(); aResultSO = theStudy->FindObjectID(anEntry); return aResultSO._retn(); } @@ -1008,22 +930,32 @@ namespace VISU{ } CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) { - if(MYDEBUG) MESSAGE("VISU_Gen_i::CanCopy : "<FindAttribute(anAttr, "AttributeIOR")) return false; try { - 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; + 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(GetServant(aResultObj)); + if(pResult != NULL){ + if(abs(pResult->GetSourceId()) > Result_i::eFile) + if((pResult->GetFileInfo()).filePath() == "Med") return false; + return true; + } + } + } } } catch (...) { - return false; + MESSAGE("Unknown exception was accured!"); } - return true; + return false; } return myVisuGen->CanCopy(theObject); } @@ -1037,7 +969,7 @@ namespace VISU{ SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile; SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - PortableServer::POA_var aPOA = GetPOA(); + PortableServer::POA_ptr aPOA = GetPOA(); SALOMEDS::GenericAttribute_var anAttr; if (!theObject->FindAttribute(anAttr,"AttributeIOR")) return NULL; @@ -1060,20 +992,20 @@ namespace VISU{ } CORBA::String_var aTmpDir = SALOMEDS_Tool::GetTmpDir(); - char* aStr = strdup(pStorable->ToString()); + string aStr = pStorable->ToString().c_str(); ofstream stmOut2((string(aTmpDir) + string("copy_persistent")).c_str(),ios::out); stmOut2<(aPOA->reference_to_servant(aCorbaObj)); if (aResultObj) { - string aStudyPrefix = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + string("_"); - + 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)+aStudyPrefix + string(aResultObj->GetName())).c_str()); + (string(aTmpDir) + aFileName).c_str()); if(system(aCommand) == -1) { if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<length(2); aSeq[0] = "copy_persistent"; - aSeq[1] = (aStudyPrefix + string(aResultObj->GetName())).c_str(); + aSeq[1] = aFileName.c_str(); } else { aSeq->length(1); aSeq[0] = "copy_persistent"; @@ -1099,7 +1031,7 @@ namespace VISU{ 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(MYDEBUG) MESSAGE("VISU_Gen_i::CanPaste : "<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); @@ -1130,23 +1057,28 @@ namespace VISU{ stmIn.read(aString, aLength); aString[aLength] = 0; myIsMultiFile = true; - Storable* aStorable = Storable::Create(theObject,aTmpDir.in(),aString); + + string aFileName(aTmpDir.in()); + if(aSeq->length() > 1) aFileName += aSeq[1].in(); + Storable* aStorable = Storable::Create(theObject,aFileName,aString); SALOMEDS::ListOfFileNames_var aSeqToRm = new SALOMEDS::ListOfFileNames; aSeqToRm->length(1); aSeqToRm[0] = "copy_persistent"; SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeqToRm.in(), true); - CORBA::String_var aComponentIDString(aComponent->GetID()); - if (strcmp(aComponentIDString, theObject->GetID()) == 0) { - // create the new result SObject + 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 { + else aResultSO = SALOMEDS::SObject::_duplicate(theObject); - } - SALOMEDS::AttributeIOR_var anIOR = - SALOMEDS::AttributeIOR::_narrow(aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR")); - anIOR->SetValue(aStorable->GetID()); + 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); return aResultSO._retn(); } return myVisuGen->PasteInto(theStream,theObjectID,theObject); diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index 176f92b9..9604f498 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -25,7 +25,8 @@ namespace VISU{ VISU_Gen_i(); VISU_Gen_i(const VISU::VISU_Gen_i &); public: - VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, QMutex* theMutex); + VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, + SALOME_NamingService* theNamingService, QMutex* theMutex); VISU_Gen_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, diff --git a/src/VISU_I/VISU_Result_i.hh b/src/VISU_I/VISU_Result_i.hh index 9edaca12..d796d86c 100644 --- a/src/VISU_I/VISU_Result_i.hh +++ b/src/VISU_I/VISU_Result_i.hh @@ -31,13 +31,15 @@ namespace VISU{ typedef VISU_Convertor InputType; typedef vtkUnstructuredGridReader OutputType; + enum TSourceId {eRestoredComponent = -2, eRestoredFile = -1, eFile = 1, eComponent = 2}; private: + TSourceId mySourceId; InputType *myInput; string myName; QFileInfo myFileInfo; - int myIsRestored; protected: - virtual Storable* Build(); + virtual Storable* Build(SALOMEDS::SObject_ptr theSObject = NULL) + throw (std::runtime_error&); public: virtual Storable* Create(const char* theFileName); virtual Storable* Create(SALOMEDS::SObject_ptr theMedSObject); @@ -48,10 +50,10 @@ namespace VISU{ virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; static const string myComment; - InputType* GetInput() { return myInput;} - const char* GetName() const { return myName.c_str();} + InputType* GetInput(); + const string& GetName() const { return myName;} const QFileInfo& GetFileInfo() const { return myFileInfo;} - int IsRestored() const { return myIsRestored;} + Result_i::TSourceId GetSourceId() const { return mySourceId;} private: SALOMEDS::SObject_var mySObject; SALOMEDS::Study_var myStudyDocument;