#include "VISU_CutLines_i.hh"
#include "VISU_Vectors_i.hh"
#include "VISU_StreamLines_i.hh"
+#include "VISU_GaussPoints_i.hh"
#include "VISU_Plot3D_i.hh"
#include "VISU_Table_i.hh"
#include "VISU_TimeAnimation.h"
+#include "VISU_ScalarMapOnDeformedShape_i.hh"
#include "VISU_Actor.h"
#include <strstream>
#include "Utils_ExceptHandlers.hxx"
+#include "CASCatch.hxx"
using namespace std;
static QFileInfo aFileInfo;
#ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
+//#define _DEXCEPT_
#else
static int MYDEBUG = 0;
#endif
return aVISU_Gen->_this();
}
-namespace VISU{
+namespace VISU
+{
static string VisuTmpDir;
static CORBA::Boolean myIsMultiFile;
Storable::Registry(Result_i::myComment.c_str(),&(Result_i::Restore));
Storable::Registry(Mesh_i::myComment.c_str(),&(Restore<Mesh_i>));
Storable::Registry(ScalarMap_i::myComment.c_str(),&(Restore<ScalarMap_i>));
+ Storable::Registry(GaussPoints_i::myComment.c_str(),&(Restore<GaussPoints_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(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));
+ Storable::Registry(ScalarMapOnDeformedShape_i::myComment.c_str(),&(Restore<ScalarMapOnDeformedShape_i>));
}
if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : there is no opened study in StudyManager !!!");
}
+ bool
+ CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Double theIteration)
+ {
+ CASCatch_TRY{
+#ifndef _DEXCEPT_
+ try{
+#endif
+ if(theColoredPrs3d->Create(theMeshName,theEntity,theFieldName,int(theIteration)))
+ return true;
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!");
+ }
+#endif
+ }CASCatch_CATCH(Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
+ }
+ return false;
+ }
+
VISU_Gen_i::~VISU_Gen_i(){
if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
}
Mutex mt(myMutex);
SALOMEDS::Study_var aStudy = theComponent->GetStudy();
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
- const char* aDir = isMultiFile? theURL: SALOMEDS_Tool::GetTmpDir().c_str();
- TCollection_AsciiString aTmpDir(const_cast<char*>(aDir));
+ string aDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
+ TCollection_AsciiString aTmpDir (const_cast<char*>(aDir.c_str()));
VisuTmpDir = aTmpDir.ToCString();
SALOMEDS::ListOfFileNames_var aSeq =
SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString(),isMultiFile);
//===========================================================================
SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
const char* theURL,
- bool isMultiFile)
+ bool theIsMultiFile)
{
Mutex mt(myMutex);
- const char* aDir = isMultiFile? theURL: SALOMEDS_Tool::GetTmpDir().c_str();
- TCollection_AsciiString aTmpDir(const_cast<char*>(aDir));
+ string aTmpDir = theURL;
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
- int aCounter = 0;
- TColStd_SequenceOfAsciiString aFileNames;
- SALOMEDS::Study_var aStudy = theComponent->GetStudy();
-
- //CORBA::Boolean anIsValidScript;
- //Engines::TMPFile_var aDump = DumpPython(aStudy,false,anIsValidScript);
+
+ typedef std::vector<std::string> TFileNames;
+ TFileNames aFileNames;
+ TFileNames aFiles;
- SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
- for (; itBig->More(); itBig->Next()) {
- SALOMEDS::SObject_var gotBranch = itBig->Value();
+ SALOMEDS::Study_var aStudy = theComponent->GetStudy();
+ SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
+ for (; anIter->More(); anIter->Next()) {
+ SALOMEDS::SObject_var gotBranch = anIter->Value();
CORBA::Object_var anObj = SObjectToObject(gotBranch);
if(CORBA::is_nil(anObj)) continue;
- if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
- switch(pResult->GetCreationId()){
+ if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
+ switch(aResult->GetCreationId()){
case Result_i::eImportFile:
case Result_i::eCopyAndImportFile: {
- const QFileInfo& aFileInfo = pResult->GetFileInfo();
- QString aPrefix("");
- if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()).c_str();
- QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str();
- static QString aCommand;
- aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1());
-
- 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 = "<<aCommand);
-
- TCollection_AsciiString aString(strdup(aFileName.latin1()));
- aFileNames.Append(aString);
+ const QFileInfo& aFileInfo = aResult->GetFileInfo();
+ const std::string& aName = aResult->GetName();
+ std::string aFileName = std::string("_") + aName;
+ std::string aFile = aFileInfo.filePath().latin1();
+ if(theIsMultiFile){
+ aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()) + aFileName;
+
+ std::ostringstream aStream;
+ aStream<<"cp "<<aFile<<" "<<aTmpDir<<aFileName;
+ std::string aCommand = aStream.str();
+ if(system(aCommand.c_str()) != 0){
+ INFOS("VISU_Gen_i::Save - Cann't execute the command :"<<aCommand);
+ continue;
+ }
+ }
+ aFileNames.push_back(aFileName);
+ aFiles.push_back(aFile);
}}
}
}
- 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);
+
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.size() - "<<aFileNames.size());
+
+ SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames;
+ if(!aFileNames.empty()){
+ aListOfFileNames->length(aFileNames.size());
+ for(int aCounter = aFileNames.size(); aCounter > 0; aCounter--)
+ aListOfFileNames[aCounter-1] = aFileNames[aCounter-1].c_str();
}
+
+ SALOMEDS::ListOfFileNames_var aListOfFiles = new SALOMEDS::ListOfFileNames;
+ aListOfFiles->length(aFiles.size());
+ if(!aFiles.empty()){
+ for(int aCounter = aFileNames.size(); aCounter > 0; aCounter--)
+ aListOfFiles[aCounter-1] = aFiles[aCounter-1].c_str();
+ }
+
+ SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
+ if(theIsMultiFile)
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aListOfFiles.in(), theIsMultiFile);
+ else
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFiles.in(), aListOfFileNames.in());
+
return aStreamFile._retn();
}
bool isMultiFile)
{
Mutex mt(myMutex);
- const char* aDir = isMultiFile? theURL: SALOMEDS_Tool::GetTmpDir().c_str();
- TCollection_AsciiString aTmpDir(const_cast<char*>(aDir));
+ string aDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
+ TCollection_AsciiString aTmpDir (const_cast<char*>(aDir.c_str()));
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
int aCounter = 0;
TColStd_SequenceOfAsciiString aFileNames;
if (SUIT_Study* aSStudy = anApp->activeStudy()) {
if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
if (_PTR(Study) aCStudy = aStudy->studyDS()) {
- MESSAGE("There is an application with active study : StudyId = "
- << aCStudy->StudyId() << "; Name = '" << aCStudy->Name() << "'");
+ if(MYDEBUG) MESSAGE("There is an application with active study : StudyId = "
+ << aCStudy->StudyId() << "; Name = '" << aCStudy->Name() << "'");
if (myStudyName == aCStudy->Name()) {
isActive = true;
break;
{
CORBA::String_var aName = theStudy->Name();
std::string aStudyName (aName.in());
- MESSAGE("StudyId = " << theStudy->StudyId() << "; Name = '" << aName.in() << "'");
+ if(MYDEBUG) MESSAGE("StudyId = " << theStudy->StudyId() << "; Name = '" << aName.in() << "'");
myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
ProcessVoidEvent(new TEvent(aStudyName));
} else {
- MESSAGE("CORBA::is_nil(theStudy)");
+ INFOS("CORBA::is_nil(theStudy)");
}
}
}
}
+ Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){
+ if(myStudyDocument->GetProperties()->IsLocked())
+ return Result::_nil();
+ Mutex mt(myMutex);
+ aFileInfo.setFile(theFileName);
+ Result_i* pResult = new Result_i(myStudyDocument,
+ Result_i::eFile,
+ Result_i::eImportFile,
+ false);
+ if(pResult->Create(theFileName) != NULL)
+ return pResult->_this();
+ else{
+ pResult->_remove_ref();
+ return VISU::Result::_nil();
+ }
+ }
+
Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
if(myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
return Prs3dOnField<VISU::ScalarMap_i>(theResult,theMeshName,theEntity,theFieldName,theIteration,true)._retn();
}
+ GaussPoints_ptr VISU_Gen_i::GaussPointsOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Double theIteration)
+ {
+ return Prs3dOnField<VISU::GaussPoints_i>(theResult,theMeshName,theEntity,theFieldName,theIteration,true)._retn();
+ }
+
DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult,
const char* theMeshName,
VISU::Entity theEntity,
return Prs3dOnField<VISU::DeformedShape_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
+ ScalarMapOnDeformedShape_ptr VISU_Gen_i::ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Double theIteration)
+ {
+ return Prs3dOnField<VISU::ScalarMapOnDeformedShape_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+ }
+
Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult,
const char* theMeshName,
VISU::Entity theEntity,
void VISU_Gen_i::DeleteResult (Result_ptr theResult)
{
- class TEvent: public SALOME_Event {
- Result_ptr myResult;
- public:
- TEvent(Result_ptr theResult): myResult(theResult) {}
- virtual void Execute()
- {
- if (Result_i* aResult = dynamic_cast<Result_i*>(GetServant(myResult).in())) {
- SALOMEDS::SObject_var aSObject = aResult->GetSObject();
- VISU::RemoveFromStudy(aSObject,
- false, // not only attribute
- true); // destroy sub-objects
-
- //jfa tmp:if (QAD_Desktop* aDesktop = QAD_Application::getDesktop())
- //jfa tmp: if (QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument))
- //jfa tmp: aStudy->updateObjBrowser(); //update Object browser
- }
-
- myResult->Destroy();
- }
- };
-
- if (myStudyDocument->GetProperties()->IsLocked())
- return;
- Mutex mt(myMutex); // jfa ???
-
- ProcessVoidEvent(new TEvent(theResult));
+ theResult->RemoveFromStudy();
}
void VISU_Gen_i::DeletePrs3d (Prs3d_ptr thePrs3d)
{
- class TEvent: public SALOME_Event {
- Prs3d_ptr myPrs3d;
- public:
- TEvent(Prs3d_ptr thePrs3d): myPrs3d(thePrs3d) {}
- virtual void Execute() {
- myPrs3d->RemoveFromStudy();
-
- //update Object browser
- /*jfa tmp:if (QAD_Desktop* aDesktop = QAD_Application::getDesktop()) {
- if (Prs3d_i* aPrs3d = dynamic_cast<Prs3d_i*>(GetServant(myPrs3d).in())) {
- SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject();
- SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
- if (QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument))
- aStudy->updateObjBrowser();
- }
- }*/
-
- myPrs3d->Destroy();
- }
- };
-
- if (myStudyDocument->GetProperties()->IsLocked())
- return;
- Mutex mt(myMutex); // jfa ???
-
- ProcessVoidEvent(new TEvent(thePrs3d));
+ thePrs3d->RemoveFromStudy();
}
void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){