]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Suppress compilation warnings
authorjfa <jfa@opencascade.com>
Thu, 23 Jun 2005 11:05:36 +0000 (11:05 +0000)
committerjfa <jfa@opencascade.com>
Thu, 23 Jun 2005 11:05:36 +0000 (11:05 +0000)
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_ViewManager_i.cc
src/VISU_I/VISU_View_i.cc

index 9965c30b3d4a97460fff5939b902b6a2067a907b..11ffff01971cb8f75ac337130fd868705091bf2c 100644 (file)
@@ -404,12 +404,40 @@ namespace VISU{
     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)");
     }
   }
index f09e93debbcc98cd5ee427684386ea1ad5c988a6..e501ec10670791781c08ab4733758e7ce2345f2b 100644 (file)
@@ -77,22 +77,34 @@ namespace VISU {
     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
     }
   };
 
@@ -148,13 +160,11 @@ namespace VISU {
   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())
@@ -164,11 +174,12 @@ namespace VISU {
     void
     Execute()
     {
-      //if (CheckStudy(myStudyDocument)){
+      //if (CheckStudy(myStudyDocument)) {
+      if (myApplication) {
        TViewFrame* pView = new TViewFrame (myApplication);
        if (pView->Create(1))
          myResult = pView->_this();
-      //}
+      }
     }
   };
 
index a9b943c318bc1e388abebdcbfcb9fb1040b980c2..73b1d60b287d1c5e534b213844544b6044e16198 100644 (file)
@@ -608,9 +608,12 @@ namespace VISU{
 
   //===========================================================================
   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)
@@ -981,9 +984,12 @@ namespace VISU{
   }
 
   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)