#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 "SUIT_Session.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_Application.h"
-#include "SalomeApp_SelectionMgr.h"
+#include "LightApp_SelectionMgr.h"
#include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h"
#include "SALOME_Event.hxx"
#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(IsoSurfaces_i::myComment.c_str(),&(Restore<IsoSurfaces_i>));
Storable::Registry(StreamLines_i::myComment.c_str(),&(Restore<StreamLines_i>));
+ Storable::Registry(Plot3D_i::myComment.c_str(),&(Restore<Plot3D_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));
+ 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;
void VISU_Gen_i::SetCurrentStudy (SALOMEDS::Study_ptr theStudy)
{
- class TEvent: public SALOME_Event {
+ class TEvent: public SALOME_Event {
std::string myStudyName;
public:
- TEvent(const std::string theStudyName):myStudyName(theStudyName)
- {}
+ TEvent(const std::string theStudyName):myStudyName(theStudyName)
+ {}
virtual void Execute()
{
bool isActive = false;
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;
MESSAGE("!!! anApp->onLoadDoc(myStudyName) !!!");
// Has to be loaded in an empty or in a new application
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aFirstApp);
- anApp->onLoadDoc(myStudyName);
+ anApp->onLoadDoc(myStudyName.c_str());
}
}
};
-
+
if (!CORBA::is_nil(theStudy))
{
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));
+ 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,
return Prs3dOnField<VISU::StreamLines_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
+ Plot3D_ptr VISU_Gen_i::Plot3DOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Double theIteration)
+ {
+ return Prs3dOnField<VISU::Plot3D_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+ }
+
CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult,
const char* theMeshName,
VISU::Entity theEntity,
return VISU::Animation::_nil();
}
- void DeletePrs3d (Prs3d_ptr thePrs3d)
- {
- Prs3d_i* aPrs3d = dynamic_cast<Prs3d_i*>(GetServant(thePrs3d).in());
- if (!aPrs3d)
- return;
-
- // 1. Find appropriate application (code like in VISU_ViewManager_i.cxx)
- SALOMEDS::Study_var myStudyDocument = aPrs3d->GetStudyDocument();
- SalomeApp_Application* anApp = NULL;
- CORBA::String_var studyName = myStudyDocument->Name();
- std::string aStudyName = studyName.in();
- SUIT_Session* aSession = SUIT_Session::session();
- QPtrList<SUIT_Application> anApplications = aSession->applications();
- QPtrListIterator<SUIT_Application> anIter (anApplications);
- while (SUIT_Application* aSUITApp = anIter.current()) {
- ++anIter;
- if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
- if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
- if (_PTR(Study) aCStudy = aStudy->studyDS()) {
- if (aStudyName == aCStudy->Name()) {
- anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
- break;
- }
- }
- }
- }
- }
- if (!anApp)
- return;
-
- // 2. Remove corresponding IO from selection
- SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject();
- CORBA::String_var anEntry = aSObject->GetID();
-
- SalomeApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
- SALOME_ListIO aListIO, aNewListIO;
- aSelectionMgr->selectedObjects(aListIO);
-
- for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
- if (it.Value()->hasEntry()) {
- std::string aCurEntry (it.Value()->getEntry());
- if (aCurEntry != std::string( anEntry.in() ) ) {
- aNewListIO.Append(it.Value());
- }
- }
- }
-
- aSelectionMgr->setSelectedObjects(aNewListIO);
-
- // 3. Remove Actors
- ViewManagerList aViewManagerList;
- anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
- QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
- for (; anVMIter.current(); ++anVMIter) {
- SUIT_ViewManager* aViewManager = anVMIter.current();
- QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
- for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
- if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
- if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
- //VISU_Actor* anActor = aVISUViewManager->GetActor(aPrs3d, vw);
- VISU_Actor* anActor = NULL;
- vtkActorCollection *anActColl = vw->getRenderer()->GetActors();
- anActColl->InitTraversal();
- vtkActor *aVTKActor = anActColl->GetNextActor();
- for (; !anActor && aVTKActor; aVTKActor = anActColl->GetNextActor()) {
- if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(aVTKActor)) {
- if (aPrs3d == anVISUActor->GetPrs3d()) {
- anActor = anVISUActor->GetParent();
- }
- }
- }
- if (anActor) {
- vw->RemoveActor(anActor);
- anActor->Delete();
- }
- }
- }
- }
- }
-
- aPrs3d->RemoveFromStudy();
- aPrs3d->Destroy();
-
- //jfa tmp:theModule->updateObjBrowser(); //update Object browser
- }
-
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();
- SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
- SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(aSObject);
- for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
- SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
- CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
- if(CORBA::is_nil(aChildObj)) continue;
- VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
- if(CORBA::is_nil(aPrs3d)) continue;
- VISU::DeletePrs3d(aPrs3d);
- }
-
- aResult->RemoveFromStudy();
- aResult->Destroy();
-
- //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
- }
- }
- };
-
- 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() {
- VISU::DeletePrs3d(myPrs3d);
- }
- };
-
- if (myStudyDocument->GetProperties()->IsLocked())
- return;
- Mutex mt(myMutex); // jfa ???
-
- ProcessVoidEvent(new TEvent(thePrs3d));
+ thePrs3d->RemoveFromStudy();
}
void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){