#include "SVTK_ViewModel.h"
#include "SPlot2d_Curve.h"
#include "Plot2d_ViewFrame.h"
+#include "Plot2d_ViewWindow.h"
#include "Plot2d_ViewModel.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
#include "SALOME_Event.hxx"
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
#include <vtkCamera.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
+#include <qapplication.h>
+
using namespace std;
#ifdef _DEBUG_
struct TNewViewManagerEvent: public SALOME_Event
{
- std::string myStudyName;
+ int myStudyId;
typedef SalomeApp_Application* TResult;
TResult myResult;
- TNewViewManagerEvent(const char* theStudyName):
- myStudyName(theStudyName),
+ TNewViewManagerEvent (const int theStudyId):
+ myStudyId(theStudyId),
myResult(NULL)
{}
void
Execute()
{
- MESSAGE( "Find application for study : " << myStudyName );
- QString aStudyName( myStudyName.c_str() );
+ MESSAGE("Find application for study with id = : " << myStudyId);
SUIT_Session* aSession = SUIT_Session::session();
QPtrList<SUIT_Application> anApplications = aSession->applications();
QPtrListIterator<SUIT_Application> anIter (anApplications);
- //bool isAnyStudy = false; //jfa tmp
- ////SUIT_Application* aFirstResult = NULL; //jfa tmp
- //SUIT_Application* aFirstResult = anIter.current(); //jfa tmp
while (SUIT_Application* anApp = anIter.current()) {
++anIter;
if (SUIT_Study* aSStudy = anApp->activeStudy()) {
if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
- //isAnyStudy = true; //jfa tmp
- ////aFirstResult = anApp; //jfa tmp
- MESSAGE("There is an application with active study : " << aStudy->studyName());
- if (aStudyName == aStudy->studyName()) {
- myResult = dynamic_cast<SalomeApp_Application*>(anApp);
- break;
+ if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+ //if (myStudyName == aCStudy->Name()) {
+ if (myStudyId == aCStudy->StudyId()) {
+ myResult = dynamic_cast<SalomeApp_Application*>(anApp);
+ break;
+ }
}
}
}
}
- if (!myResult) { //jfa tmp
- MESSAGE("Error: application is not found for study : " << myStudyName);
- ////if (isAnyStudy) { //jfa tmp
- // myResult = dynamic_cast<SalomeApp_Application*>(aFirstResult); //jfa tmp
- ////} //jfa tmp
- } //jfa tmp
+ if (!myResult) {
+ //MESSAGE("Error: application is not found for study : " << myStudyName);
+ MESSAGE("Error: application is not found for study with id = : " << myStudyId);
+ }
}
};
{
if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i - "<<this);
- CORBA::String_var aStudyName = theStudy->Name();
- myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyName.in()));
+ //CORBA::String_var aStudyName = theStudy->Name();
+ //myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyName.in()));
+ int aStudyID = theStudy->StudyId();
+ myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyID));
}
//if (CheckStudy(myStudyDocument)) {
if (myApplication) {
TViewFrame* pView = new TViewFrame (myApplication);
- if (pView->Create(1))
+ if (pView->Create(1)) {
myResult = pView->_this();
+ qApp->processEvents(); // Fix for bug 9929
+ }
}
}
};
return anVISUActor->GetParent();
return NULL;
}
+
+ struct TDeleteActorsEvent: public SALOME_Event
+ {
+ VISU::Curve_i* myPrs;
+
+ TDeleteActorsEvent (VISU::Curve_i* thePrs):
+ myPrs(thePrs)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ if (!myPrs) return;
+
+ // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
+ SALOMEDS::Study_var myStudyDocument = myPrs->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 = myPrs->GetSObject();
+ CORBA::String_var anEntry = aSObject->GetID();
+
+ LightApp_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 (Plot2d_ViewWindow* vw = dynamic_cast<Plot2d_ViewWindow*>(aViewWindow)) {
+ Plot2d_ViewFrame* vf = vw->getViewFrame();
+ QList<Plot2d_Curve> clist;
+ vf->getCurves(clist);
+ for (int i = 0; i < clist.count(); i++) {
+ if (SPlot2d_Curve* cu = dynamic_cast<SPlot2d_Curve*>(clist.at(i))) {
+ if (cu->hasIO() &&
+ strcmp(cu->getIO()->getEntry(), myPrs->GetEntry()) == 0) {
+ vf->eraseCurve(cu);
+ }
+ }
+ }
+ vf->Repaint();
+ //jfa tmp:aViewFrame->unHighlightAll();
+ }
+ }
+ }
+ }
+ }
+ };
+
+ void DeleteActors (VISU::Curve_i* thePrs)
+ {
+ if (!thePrs) return;
+ ProcessVoidEvent(new TDeleteActorsEvent (thePrs));
+
+/* // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
+ SALOMEDS::Study_var myStudyDocument = thePrs->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 = thePrs->GetSObject();
+ CORBA::String_var anEntry = aSObject->GetID();
+
+ LightApp_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 (Plot2d_ViewWindow* vw = dynamic_cast<Plot2d_ViewWindow*>(aViewWindow)) {
+ Plot2d_ViewFrame* vf = vw->getViewFrame();
+ QList<Plot2d_Curve> clist;
+ vf->getCurves(clist);
+ for (int i = 0; i < clist.count(); i++) {
+ if (SPlot2d_Curve* cu = dynamic_cast<SPlot2d_Curve*>(clist.at(i))) {
+ if (cu->hasIO() &&
+ strcmp(cu->getIO()->getEntry(), thePrs->GetEntry()) == 0) {
+ vf->eraseCurve(cu);
+ }
+ }
+ }
+ vf->Repaint();
+ //jfa tmp:aViewFrame->unHighlightAll();
+ }
+ }
+ }
+}*/
+ }
+
+ void DeleteActors (VISU::Prs3d_i* thePrs)
+ {
+ if (!thePrs) return;
+
+ // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
+ SALOMEDS::Study_var myStudyDocument = thePrs->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 = thePrs->GetSObject();
+ CORBA::String_var anEntry = aSObject->GetID();
+
+ LightApp_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 = 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 (thePrs == anVISUActor->GetPrs3d()) {
+ anActor = anVISUActor->GetParent();
+ }
+ }
+ }
+ if (anActor) {
+ vw->RemoveActor(anActor);
+ anActor->Delete();
+ }
+ }
+ }
+ }
+ }
+ }
}