// VISU OBJECT : interactive object for VISU entities implementation
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
// File : VISUConfig.cc
Base_i::~Base_i() {}
- char* Base_i::GetID(){
+ char* Base_i::GetID(){
if(myID == ""){
CORBA::Object_var anObject = _this();
CORBA::String_var anIOR = myOrb->object_to_string(anObject);
Mutex::Mutex(QMutex* theMutex): myMutex(&aMutex){
if(MYDEBUG) MESSAGE("Mutex::Mutex : "<<!mySCnt);
- if(!mySCnt++)
+ if(!mySCnt++)
myMutex->lock();
}
ToStream(strOut);
strOut<<ends;
if(MYDEBUG) MESSAGE("Storable::ToString - "<<strOut.str());
- return strOut.str();
+ return strOut.str();
}
void Storable::Registry(const char* theComment, TStorableEngine theEngine)
throw std::logic_error("Storable::Registry >> dupliacte registring !!!");
}
}
-
+
void Storable::StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap){
if(0 && MYDEBUG) MESSAGE("Storable::StrToMap : string="<<theStr);
QStringList strList = QStringList::split( ";", theStr, false );
aValue = "";
}
if ( !aName.isEmpty() )
- theMap.insert( TRestoringMap::value_type( aName.latin1(), aValue ) );
+ theMap.insert( TRestoringMap::value_type( aName.latin1(), aValue ) );
}
}
void Storable::DataToStream(ostringstream& theStr, const QString& theName, const QString& theVal) {
- QString output = ( !theName.isNull() ? theName : QString("") )
- + QString( "=" )
+ QString output = ( !theName.isNull() ? theName : QString("") )
+ + QString( "=" )
+ ( !theVal.isNull() ? theVal : QString("") );
theStr<<output.latin1()<<";";
}
void Storable::DataToStream(ostringstream& theStr, const QString& theName, const int theVal) {
- QString output = ( !theName.isNull() ? theName : QString("") )
- + QString( "=" )
+ QString output = ( !theName.isNull() ? theName : QString("") )
+ + QString( "=" )
+ QString::number( theVal );
theStr<<output.latin1()<<";";
}
void Storable::DataToStream(ostringstream& theStr, const QString& theName, const double theVal) {
- QString output = ( !theName.isNull() ? theName : QString("") )
- + QString( "=" )
+ QString output = ( !theName.isNull() ? theName : QString("") )
+ + QString( "=" )
+ QString::number( theVal );
theStr<<output.latin1()<<";";
}
Storable* Storable::Create(SALOMEDS::SObject_ptr theSObject,
- const string& thePrefix, const string& theLocalPersistentID)
+ const string& thePrefix, const string& theLocalPersistentID)
{
try{
QString strIn( theLocalPersistentID.c_str() );
- TRestoringMap aMap;
+ TRestoringMap aMap;
StrToMap(strIn,aMap);
bool isExist;
QString aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist);
}
return NULL;
}
-
+
const QString& Storable::FindValue(const TRestoringMap& theMap, const string& theArg, bool* isFind)
{
TRestoringMap::const_iterator i = theMap.find(theArg);
if(isFind != NULL) *isFind = true;
return i->second;
}
-
+
//===========================================================================
PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject){
PortableServer::Servant aServant = aPOA->reference_to_servant(theObject);
return aServant;
} catch (...) {
- INFOS("GetServant - Unknown exception was occured!!!");
+ INFOS("GetServant - Unknown exception was occured!!!");
return NULL;
}
}
string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
const char* theComment, int IsAllLevels)
{
- SALOMEDS::ChildIterator_var anIter =
+ SALOMEDS::ChildIterator_var anIter =
theStudyDocument->NewChildIterator(theStudyDocument->FindObjectID(theStartEntry));
anIter->InitEx(IsAllLevels);
SALOMEDS::SObject_var aFieldSO;
return "";
}
//===========================================================================
- string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
+ string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
const char* theFatherEntry, const char* theRefFatherEntry,
- const char* theIOR, const char* theName,
+ const char* theIOR, const char* theName,
const char* thePersistentRef, const char* theComment,
CORBA::Boolean theCreateNew)
{
if(strcmp(theIOR,"") != 0){
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- anIOR->SetValue(theIOR);
+ anIOR->SetValue(theIOR);
}
if(strcmp(theName,"") != 0){
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
- aName->SetValue(theName);
+ aName->SetValue(theName);
}
if(strcmp(thePersistentRef,"") != 0){
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePersistentRef");
SALOMEDS::AttributePersistentRef_var aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
- aPRef->SetValue(thePersistentRef);
+ aPRef->SetValue(thePersistentRef);
}
if(strcmp(theComment,"") != 0){
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeComment");
}
CORBA::String_var anEntry = newObj->GetID();
string aRet(anEntry);
- if(MYDEBUG)
+ if(MYDEBUG)
INFOS("CreateAttributes - StudyId = "<<theStudyDocument->StudyId()<<"; anEntry = "<<aRet<<"; IOR = '"<<theIOR<<"'");
return aRet;
}
+
+ void RemoveFromStudy (SALOMEDS::SObject_ptr theSObject,
+ bool theIsAttrOnly)
+ {
+ if (!theSObject->_is_nil()) {
+ SALOMEDS::Study_var aStudy = theSObject->GetStudy();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ if (theIsAttrOnly)
+ aStudyBuilder->RemoveAttribute(theSObject,"AttributeIOR");
+ else
+ aStudyBuilder->RemoveObjectWithChildren(theSObject);
+ }
+ }
}
// VISU OBJECT : interactive object for VISU entities implementation
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
// File : VISUConfig.hh
#include <stdio.h>
#include <iostream>
#include <string>
-#include <qstring.h>
-#include <qthread.h>
+#include <qstring.h>
+#include <qthread.h>
#include <qfileinfo.h>
#include <qapplication.h>
#include "utilities.h"
#include <stdexcept>
-#include <sstream>
+#include <sstream>
namespace VISU{
//===========================================================================
std::string ToString();
virtual const char* GetComment() const = 0;
typedef std::map<std::string,QString> TRestoringMap;
- typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject,
+ typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject,
const std::string& thePrefix, const TRestoringMap& theMap);
typedef std::map<std::string,TStorableEngine> TCallbackMap;
static void Registry(const char* theComment, TStorableEngine theEngine);
- static Storable* Create(SALOMEDS::SObject_ptr, const std::string& thePrefix, const std::string& theString);
+ static Storable* Create(SALOMEDS::SObject_ptr, const std::string& thePrefix, const std::string& theString);
static const QString& FindValue(const TRestoringMap& theMap, const std::string& theArg, bool* isFind = NULL);
static void StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap);
static SALOMEDS::SObject_ptr GetResultSO(SALOMEDS::SObject_ptr theSObject);
SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
- std::string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
+ std::string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
const char* theFatherEntry, const char* theRefFatherEntry,
- const char* theIOR, const char* theName,
+ const char* theIOR, const char* theName,
const char* thePersistentRef, const char* theComment,
CORBA::Boolean theCreateNew = true);
std::string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
const char* theComment, int IsAllLevels = true);
-}
+ void RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
+ bool theIsAttrOnly = true);
+}
#endif
// VISU OBJECT : interactive object for VISU entities implementation
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
// File : VISU_Result_i.cc
// Module : VISU
#include "VISU_Result_i.hh"
+
#include "VISU_Convertor_impl.hxx"
#include "VISU_CorbaMedConvertor.hxx"
#include "VISU_PipeLine.hxx"
#include "QAD_Config.h"
+
#include "SALOMEDS_Tool.hxx"
#include "HDFascii.hxx"
+// QT Includes
#include <qstring.h>
#include <qfileinfo.h>
-#include <memory>
-#include <fstream>
-
-#include <vtkUnstructuredGridReader.h>
-#include <vtkUnstructuredGridWriter.h>
-
using namespace VISU;
using namespace std;
static int MYDEBUG = 0;
#endif
-VISU::Result_var VISU::FindResult(SALOMEDS::SObject_ptr theSObject){
+VISU::Result_var VISU::FindResult (SALOMEDS::SObject_ptr theSObject)
+{
SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent();
SALOMEDS::SObject_var aFather = theSObject->GetFather();
- CORBA::String_var aComponentID(aSComponent->GetID());
- CORBA::String_var aFatherID(aFather->GetID());
+ CORBA::String_var aComponentID (aSComponent->GetID());
+ CORBA::String_var aFatherID (aFather->GetID());
VISU::Result_var aResult;
- while(strcmp(aComponentID,aFatherID) != 0){
+ while (strcmp(aComponentID, aFatherID) != 0) {
CORBA::Object_var anObject = VISU::SObjectToObject(aFather);
- if(!CORBA::is_nil(anObject)){
+ if (!CORBA::is_nil(anObject)) {
aResult = VISU::Result::_narrow(anObject);
- if(!aResult->_is_nil()) return aResult;
+ if (!aResult->_is_nil()) return aResult;
}
aFather = aFather->GetFather();
+ aFatherID = aFather->GetID();
}
return aResult;
}
-void VISU::RemoveFromStudy(SALOMEDS::SObject_ptr theSObject, int theIsAttrOnly){
- if(!theSObject->_is_nil()){
- SALOMEDS::Study_var aStudy = theSObject->GetStudy();
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
- if(theIsAttrOnly)
- aStudyBuilder->RemoveAttribute(theSObject,"AttributeIOR");
- else
- aStudyBuilder->RemoveObjectWithChildren(theSObject);
- }
-}
-
-QString GenerateName(const char* theName){
+QString GenerateName (const char* theName)
+{
typedef map<string,int> TNameMap;
static TNameMap aMap;
TNameMap::const_iterator i = aMap.find(theName);
QString tmp;
- if(i == aMap.end()) {
+ if (i == aMap.end()) {
aMap[theName] = 0;
tmp = theName;
- }else{
+ } else {
tmp = VISU::GenerateName(theName,++aMap[theName]);
}
if(MYDEBUG) MESSAGE("GenerateName - "<<tmp<<" from - "<<theName<<"; " <<aMap[theName]);
return tmp;
}
-QString GenerateFieldName(const string& theName, const string& theUnits){
+QString GenerateFieldName (const string& theName, const string& theUnits)
+{
static QString aName;
- const string tmp(theUnits.size(),' ');
- if(theUnits == "" || theUnits == tmp)
+ const string tmp (theUnits.size(),' ');
+ if (theUnits == "" || theUnits == tmp)
aName.sprintf("%s, -",theName.c_str());
else
aName.sprintf("%s, %s",theName.c_str(),theUnits.c_str());
return aName.latin1();
}
-void CreateReference(SALOMEDS::Study_ptr theStudyDocument,
- const string& theFatherEntry, const string& theRefEntry)
+void CreateReference (SALOMEDS::Study_ptr theStudyDocument,
+ const string& theFatherEntry, const string& theRefEntry)
{
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str());
aStudyBuilder->Addreference(newObj,aRefSObj);
}
-string GetComponentDataType(SALOMEDS::SObject_ptr theSObject){
+string GetComponentDataType (SALOMEDS::SObject_ptr theSObject)
+{
SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent();
CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
return aDataType.in();
const string VISU::Result_i::myComment = "RESULT";
const char* VISU::Result_i::GetComment() const { return myComment.c_str();}
-VISU::Result_i::Result_i(SALOMEDS::Study_ptr theStudy, const TSourceId& aSourceId) {
+VISU::Result_i::Result_i (SALOMEDS::Study_ptr theStudy,
+ const TSourceId& aSourceId)
+{
myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
mySourceId = aSourceId;
myInput = NULL;
}
-void VISU::Result_i::RemoveFromStudy(){
+void VISU::Result_i::RemoveFromStudy()
+{
VISU::RemoveFromStudy(mySObject,false);
}
-int VISU::Result_i::IsPossible(){
+int
+VISU::Result_i::
+IsPossible()
+{
try{
float aSize = myInput->GetSize();
bool aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
}
-CORBA::Boolean VISU::Result_i::BuildAll(){
+CORBA::Boolean
+VISU::Result_i::
+BuildAll()
+{
if(MYDEBUG) MESSAGE("Result_i::Build - myIsDone = "<<myIsDone);
if(myIsDone) return 1;
if(!IsPossible()) return 0;
return myIsDone;
}
-VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject)
+
+VISU::Storable*
+VISU::Result_i::
+Build(SALOMEDS::SObject_ptr theSObject)
{
SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
if(MYDEBUG) MESSAGE("Result_i::Build");
try{
const TMeshMap& aMeshMap = myInput->GetMeshMap();
- if(aMeshMap.empty())
+ if(aMeshMap.empty())
throw std::runtime_error("Build - There is no any mesh information in the file !!!");
mySComponent = FindOrCreateVisuComponent(myStudyDocument);
CORBA::String_var aSComponentEntry = mySComponent->GetID(), anIOR(GetID());
GetComment(),
VISU::TRESULT,
myFileInfo.filePath().latin1(),
- myInitFileName.c_str()); // Restoring of Python dump
- string aResultEntry =
+ myInitFileName.c_str()); // Restoring of Python dump
+ string aResultEntry =
CreateAttributes(myStudyDocument,
aSComponentEntry,
aRefFatherEntry.c_str(),
default:
throw std::runtime_error("Build >> Value of entity is incorrect!");
}
- aEntity2EntryMap[anEntity] = CreateAttributes(myStudyDocument,aSubMeshesEntry.c_str(),aRefFatherEntry.c_str(),
- "",anEntityName.c_str(),"",aComment.latin1(),true);
+ aEntity2EntryMap[anEntity] = CreateAttributes
+ (myStudyDocument, aSubMeshesEntry.c_str(), aRefFatherEntry.c_str(),
+ "", anEntityName.c_str(), "", aComment.latin1(), true);
const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
aMeshName.c_str(),
anEntity,
aFamilyName.c_str());
- aComment2EntryMap[aComment.latin1()] =
+ aComment2EntryMap[aComment.latin1()] =
CreateAttributes(myStudyDocument,
aEntity2EntryMap[anEntity].c_str(),
aRefFatherEntry.c_str(),
if(aGroupMap.size() > 0){
aComment.sprintf("myComment=GROUPS;myMeshName=%s",
aMeshName.c_str());
- string aGroupsEntry =
+ string aGroupsEntry =
CreateAttributes(myStudyDocument,
aMeshEntry.c_str(),
aRefFatherEntry.c_str(),
if(!isFieldEntryCreated){
aComment.sprintf("myComment=FIELDS;myMeshName=%s",
aMeshName.c_str());
- aFieldsEntry =
+ aFieldsEntry =
CreateAttributes(myStudyDocument,
aMeshEntry.c_str(),
aRefFatherEntry.c_str(),
return this;
}
-VISU::Storable* VISU::Result_i::Create(const char* theFileName){
+
+VISU::Storable*
+VISU::Result_i::
+Create(const char* theFileName)
+{
try{
myFileInfo.setFile(theFileName);
myInitFileName = myFileInfo.filePath().latin1();
myFileInfo.setFile(QString(aTmpDir.get()) + myFileInfo.fileName());
}
myInput = CreateConvertor(myFileInfo.absFilePath().latin1());
- if(!myInput)
- throw std::runtime_error("Create - Cannot create a Convertor for this file!!!"); return Build();
+ if(!myInput)
+ throw std::runtime_error("Create - Cannot create a Convertor for this file!!!");
+ return Build();
}catch(std::exception& exc){
INFOS("Follow exception was occured :\n"<<exc.what());
}catch(...){
return NULL;
}
-VISU::Storable* VISU::Result_i::Create(SALOMEDS::SObject_ptr theMedSObject){
+
+VISU::Storable*
+VISU::Result_i::
+Create(SALOMEDS::SObject_ptr theMedSObject)
+{
if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOMEDS::SObject_ptr");
try{
myInput = CreateMEDConvertor(theMedSObject);
- if(myInput == NULL) return NULL;
+ if(myInput == NULL)
+ return NULL;
+
mySourceId = eComponent;
string aCompDataType = GetComponentDataType(theMedSObject);
myFileInfo.setFile(aCompDataType.c_str());
+
myName = ::GenerateName("aResult").latin1();
+
VISU::Storable* aStorable = Build(theMedSObject);
return aStorable;
}catch(std::exception& exc){
return NULL;
}
-VISU::Storable* VISU::Result_i::Create(SALOME_MED::FIELD_ptr theField){
+VISU::Storable*
+VISU::Result_i::
+Create(SALOME_MED::FIELD_ptr theField)
+{
if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr");
try{
myInput = CreateMEDFieldConvertor(theField);
- if(myInput == NULL) return NULL;
+ if(myInput == NULL)
+ return NULL;
+
mySourceId = eComponent;
string aCompDataType = "MED";
myFileInfo.setFile(aCompDataType.c_str());
myInitFileName = aCompDataType;
+
myName = ::GenerateName("aResult").latin1();
+
CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField);
SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR);
+
VISU::Storable* aStorable = Build(aFieldSObject);
return aStorable;
}catch(std::exception& exc){
return NULL;
}
-VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject,
- const Storable::TRestoringMap& theMap, const string& thePrefix)
+
+VISU::Storable*
+VISU::Result_i::
+Restore(SALOMEDS::SObject_ptr theSObject,
+ const Storable::TRestoringMap& theMap,
+ const string& thePrefix)
{
- if(MYDEBUG) MESSAGE("Result_i::Restore - "<<thePrefix);
- try{
+ if(MYDEBUG) MESSAGE("Result_i::Restore - " << thePrefix);
+ try {
mySObject = SALOMEDS::SObject::_duplicate(theSObject);
myStudyDocument = mySObject->GetStudy();
mySComponent = mySObject->GetFatherComponent();
- myName = VISU::Storable::FindValue(theMap,"myName").latin1();
- myInitFileName = VISU::Storable::FindValue(theMap,"myInitFileName").latin1();
+ myName = VISU::Storable::FindValue(theMap, "myName").latin1();
+ myInitFileName = VISU::Storable::FindValue(theMap, "myInitFileName").latin1();
+
SALOMEDS::SObject_var aRefSObj, aTargetRefSObj;
- if(mySObject->FindSubObject(1,aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)){
+ if (mySObject->FindSubObject(1, aRefSObj) &&
+ aRefSObj->ReferencedObject(aTargetRefSObj)) {
mySourceId = eRestoredComponent;
- if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference.");
+ if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference.");
SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent();
CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
myFileInfo.setFile(aDataType.in());
- if(MYDEBUG) MESSAGE("Result_i::GetInput - aDataType = "<<aDataType);
- Engines::Component_var aEngComp = Base_i::myEnginesLifeCycle->FindOrLoad_Component("FactoryServer", aDataType.in());
- if (CORBA::is_nil(aEngComp))
+ if(MYDEBUG) MESSAGE("Result_i::GetInput - aDataType = " << aDataType);
+ Engines::Component_var aEngComp =
+ Base_i::myEnginesLifeCycle->FindOrLoad_Component("FactoryServer", aDataType.in());
+ if (CORBA::is_nil(aEngComp))
throw std::runtime_error("Restore - There is no aEngComp for the aDataType !!!");
- SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp);
- aStudyBuilder->LoadWith(aCompRefSObj,aDriver);
- if(strcmp(aDataType,"MED") == 0)
+ aStudyBuilder->LoadWith(aCompRefSObj, aDriver);
+ if (strcmp(aDataType, "MED") == 0)
myInput = CreateMEDConvertor(aTargetRefSObj);
else
throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
- }else{
+ } else {
myFileInfo.setFile(thePrefix.c_str());
- string aStudyPrefix("");
- if (IsMultifile()) aStudyPrefix = (SALOMEDS_Tool::GetNameFromPath(myStudyDocument->URL()));
- if(!myFileInfo.isFile()){
+ string aStudyPrefix ("");
+ if (IsMultifile())
+ aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(myStudyDocument->URL());
+ if (!myFileInfo.isFile()) {
string aFileName = thePrefix + aStudyPrefix + "_" + myName;
myFileInfo.setFile(aFileName.c_str());
}
- if(MYDEBUG)
- MESSAGE("Result_i::Restore - aFileName = "<<myFileInfo.filePath()<<"; "<<myFileInfo.isFile());
-
- if (HDFascii::isASCII(myFileInfo.filePath().latin1())) {
- char* aResultPath = HDFascii::ConvertFromASCIIToHDF(myFileInfo.filePath().latin1());
+ if(MYDEBUG)
+ MESSAGE("Result_i::Restore - aFileName = " << myFileInfo.filePath() << "; " << myFileInfo.isFile());
+
+ const char* aPathLatin = myFileInfo.filePath().latin1();
+ if (HDFascii::isASCII(aPathLatin)) {
+ MESSAGE("ConvertFromASCIIToHDF(" << aPathLatin << ")");
+ char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aPathLatin);
+ MESSAGE("ConvertFromASCIIToHDF() DONE : " << aResultPath);
char* aHDFFileName = new char[strlen(aResultPath) + 19];
sprintf(aHDFFileName, "%shdf_from_ascii.hdf", aResultPath);
if (IsMultifile()) { // set this file as new - temporary
static QString aCommand;
aCommand.sprintf("mv %s %s%s",aHDFFileName, aResultPath, myFileInfo.baseName().latin1());
- if(system(aCommand) == -1){
- if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :"<<aCommand);
+ if (system(aCommand) == -1) {
+ if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand);
return NULL;
- } else if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - "<<aCommand);
- myFileInfo.setFile(QString(aResultPath)+QString(myFileInfo.baseName().latin1()));
+ } else {
+ if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand);
+ }
+ myFileInfo.setFile(QString(aResultPath) + QString(myFileInfo.baseName().latin1()));
} else { // change current temporary file to the new: with hdf-format
static QString aCommand;
aCommand.sprintf("mv %s %s\0",aHDFFileName, myFileInfo.filePath().latin1());
- if(system(aCommand.latin1()) == -1) {
- if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :"<<aCommand);
+ if (system(aCommand.latin1()) == -1) {
+ if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand);
return NULL;
- } else if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - "<<aCommand);
+ } else {
+ if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand);
+ }
SALOMEDS::ListOfFileNames_var anEmptyList = new SALOMEDS::ListOfFileNames;
SALOMEDS_Tool::RemoveTemporaryFiles(aResultPath, anEmptyList.in(), true);
}
mySourceId = eRestoredFile;
delete(aResultPath);
delete(aHDFFileName);
- } else if (!IsMultifile())
+ } else if (!IsMultifile()) {
mySourceId = eRestoredFile;
- else
+ } else {
mySourceId = eFile;
- if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = "<<mySourceId);
+ }
+ if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId);
myInput = CreateConvertor(myFileInfo.filePath().latin1());
QString aComment;
aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
- GetComment(),VISU::TRESULT,myFileInfo.filePath().latin1(),
- myInitFileName.c_str()); // Restoring of Python dump
+ GetComment(), VISU::TRESULT, myFileInfo.filePath().latin1(),
+ myInitFileName.c_str()); // Restoring of Python dump
SALOMEDS::GenericAttribute_var anAttr;
- if(!theSObject->FindAttribute(anAttr, "AttributeComment"))
+ if (!theSObject->FindAttribute(anAttr, "AttributeComment"))
throw std::runtime_error("Build - There is no AttributeComment for the SObject !!!");
SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
aCmnt->SetValue(aComment.latin1());
}
QString aIsBuild = QAD_CONFIG->getSetting("Visu:BuildResult");
- if(aIsBuild.isEmpty()? 0 : aIsBuild.toInt())
+ if(aIsBuild.isEmpty()? 0 : aIsBuild.toInt())
BuildAll();
return this;
- }catch(std::exception& exc){
+ } catch(std::exception& exc) {
INFOS("Follow exception was occured :\n"<<exc.what());
- }catch(...){
+ } catch(...) {
INFOS("Unknown exception was occured!!!");
}
return NULL;
}
-VISU::Result_i::TInput* VISU::Result_i::GetInput() {
+VISU::Result_i::TInput* VISU::Result_i::GetInput() {
return myInput;
}
Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str());
}
-VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject,
- const string& thePrefix, const Storable::TRestoringMap& theMap)
+VISU::Storable*
+VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject,
+ const string& thePrefix,
+ const Storable::TRestoringMap& theMap)
{
SALOMEDS::Study_var aStudy = theSObject->GetStudy();
+
VISU::Result_i* pResult = new VISU::Result_i(aStudy);
- if(pResult == NULL) return NULL;
+ if (pResult == NULL)
+ return NULL;
+
return pResult->Restore(theSObject,theMap,thePrefix);
}
-
-string VISU::Result_i::GetRefFatherEntry() {
+
+string VISU::Result_i::GetRefFatherEntry() {
//return QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry();
return "";
}
-string VISU::Result_i::GetEntry(){
+string VISU::Result_i::GetEntry(){
CORBA::String_var anEntry = mySObject->GetID();
return string(anEntry);
}
const SALOMEDS::SObject_var& VISU::Result_i::GetSObject() const { return mySObject;}
const SALOMEDS::Study_var& VISU::Result_i::GetStudyDocument() const { return myStudyDocument;}
const SALOMEDS::SComponent_var& VISU::Result_i::GetSComponent() const { return mySComponent;}
-std::string VISU::Result_i::GetEntry(const std::string& theComment)
-{
+std::string VISU::Result_i::GetEntry(const std::string& theComment)
+{
return FindEntryWithComment(myStudyDocument,GetEntry().c_str(),theComment.c_str());
}
-VISU::Result_i::~Result_i() {
+VISU::Result_i::~Result_i()
+{
MESSAGE("Result_i::~Result_i() - this = "<<this);
- if(GetSourceId() == eRestoredFile){
+ if (GetSourceId() == eRestoredFile) {
static QString aCommand;
aCommand.sprintf("rm %s",myFileInfo.filePath().latin1());
MESSAGE("Result_i::~Result_i - system("<<aCommand<<") = "<<system(aCommand));