return Base_i::GetID();
}
- void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){
- if(!CORBA::is_nil(theStudy)){
+ void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
+ {
+ if (!CORBA::is_nil(theStudy))
+ {
CORBA::String_var aName = theStudy->Name();
- MESSAGE("VISU_Gen_i::SetCurrentStudy - StudyId = "<<theStudy->StudyId()<<"; Name = '"<<aName.in()<<"'");
+ QString aStudyName (aName.in());
+ MESSAGE("VISU_Gen_i::SetCurrentStudy - StudyId = " <<
+ theStudy->StudyId() << "; Name = '" << aName.in() << "'");
myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
- }else{
+
+ MESSAGE("Find application for study : " << aName.in());
+ bool isActive = false;
+ SUIT_Session* aSession = SUIT_Session::session();
+ QPtrList<SUIT_Application> anApplications = aSession->applications();
+ QPtrListIterator<SUIT_Application> anIter (anApplications);
+ SUIT_Application* aFirstApp = anIter.current();
+ while (SUIT_Application* anApp = anIter.current()) {
+ ++anIter;
+ if (SUIT_Study* aSStudy = anApp->activeStudy()) {
+ if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+ MESSAGE("There is an application with active study : " << aStudy->studyName());
+ if (aStudyName == aStudy->studyName()) {
+ isActive = true;
+ break;
+ }
+ }
+ }
+ }
+ if (!isActive) {
+ // Has to be loaded in an empty or in a new application
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aFirstApp);
+ anApp->onLoadDoc(aName.in());
+ }
+ } else {
MESSAGE("VISU_Gen_i::SetCurrentStudy : CORBA::is_nil(theStudy)");
}
}
void
Execute()
{
+ MESSAGE("Find application for study : " << myStudyName);
+ QString aStudyName (myStudyName);
SUIT_Session* aSession = SUIT_Session::session();
QPtrList<SUIT_Application> anApplications = aSession->applications();
- QPtrListIterator<SUIT_Application> anIter(anApplications);
- while(SUIT_Application* anApp = anIter.current()){
+ 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)){
- if(_PTR(Study) aCStudy = aStudy->studyDS()){
- if(myStudyName == aCStudy->Name()){
- myResult = dynamic_cast<SalomeApp_Application*>(anApp);
- break;
- }
+ 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 (!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
}
};
template<class TViewFrame>
struct TCreateViewFrameEvent: public SALOME_Event
{
- //const SUIT_Application* myApplication;
SalomeApp_Application* myApplication;
typedef typename TViewFrame::TInterface TInterface;
typedef typename TInterface::_ptr_type TResult;
TResult myResult;
- //TCreateViewFrameEvent (const SUIT_Application* theApplication):
TCreateViewFrameEvent (SalomeApp_Application* theApplication):
myApplication(theApplication),
myResult(TInterface::_nil())
void
Execute()
{
- //if (CheckStudy(myStudyDocument)){
+ //if (CheckStudy(myStudyDocument)) {
+ if (myApplication) {
TViewFrame* pView = new TViewFrame (myApplication);
if (pView->Create(1))
myResult = pView->_this();
- //}
+ }
}
};
//===========================================================================
XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication)
- : View_i(theApplication, theApplication->getViewManager(Plot2d_Viewer::Type(), true))
+ : View_i(theApplication, NULL)
{
if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
+ if (theApplication) {
+ myViewManager = theApplication->getViewManager(Plot2d_Viewer::Type(), true);
+ }
}
Storable* XYPlot_i::Create (int theNew)
}
View3D_i::View3D_i (SalomeApp_Application* theApplication)
- : View_i(theApplication, theApplication->getViewManager(SVTK_Viewer::Type(), true))
+ : View_i(theApplication, NULL)
{
if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
+ if (theApplication) {
+ myViewManager = theApplication->getViewManager(SVTK_Viewer::Type(), true);
+ }
}
Storable* View3D_i::Create (int theNew)