Salome HOME
studyActivated() virtual method has been added
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.cxx
index 61a264035b96d31e28617e64405008bfcf4969c0..8638fdc51777b071f773dc2f3da17605e15c1f36 100644 (file)
@@ -524,6 +524,22 @@ bool SalomeApp_Application::onOpenDoc( const QString& aName )
   return res;
 }
 
+bool SalomeApp_Application::onLoadDoc( const QString& aName )
+{
+  bool res = CAM_Application::onLoadDoc( aName );
+
+  /*jfa tmp:QAction* a = action( MRUId );
+  if ( a && a->inherits( "QtxMRUAction" ) )
+  {
+    QtxMRUAction* mru = (QtxMRUAction*)a;
+    if ( res )
+      mru->insert( aName );
+    else
+      mru->remove( aName );
+  }*/
+  return res;
+}
+
 void SalomeApp_Application::onSelection()
 {
   onSelectionChanged();
@@ -629,7 +645,11 @@ void SalomeApp_Application::onOpenWith()
   SALOME_ListIO aList;
   SalomeApp_SelectionMgr* mgr = selectionMgr();
   mgr->selectedObjects(aList);
-  if (aList.Extent() > 1) return;
+  if (aList.Extent() != 1)
+    {
+      QApplication::restoreOverrideCursor();
+      return;
+    }
   Handle(SALOME_InteractiveObject) aIObj = aList.First();
   QString aModuleName(aIObj->getComponentDataType());
   QString aModuleTitle = moduleTitle(aModuleName);
@@ -637,6 +657,18 @@ void SalomeApp_Application::onOpenWith()
   QApplication::restoreOverrideCursor();
 }
 
+bool SalomeApp_Application::useStudy(const QString& theName)
+{
+  createEmptyStudy();
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
+  bool res = false;
+  if (aStudy)
+    res = aStudy->loadDocument( theName );
+  updateDesktopTitle();
+  updateCommandsStatus();
+  return res;
+}
+
 void SalomeApp_Application::setActiveStudy( SUIT_Study* study )
 {
   CAM_Application::setActiveStudy( study );
@@ -888,7 +920,7 @@ SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmTyp
     vm->isos( u, v );
     u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
     v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
-    //    vm->setIsos( u, v );
+    vm->setIsos( u, v );
     viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
     new SalomeApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
   }
@@ -1293,7 +1325,7 @@ void SalomeApp_Application::preferencesChanged( const QString& sec, const QStrin
       vtkVM->Repaint();
     }
   }
-  /*
+  
   if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
   {
     QPtrList<SUIT_ViewManager> lst;
@@ -1303,7 +1335,7 @@ void SalomeApp_Application::preferencesChanged( const QString& sec, const QStrin
     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
       ((OCCViewer_Viewer*)it.current())->setIsos( u, v );
   }
-  */
+  
 }
 
 void SalomeApp_Application::afterCloseDoc()
@@ -1536,6 +1568,22 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t
   CAM_Application::contextMenuPopup( type, thePopup, title );
   thePopup->insertSeparator();
   thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
+  
+  // "Activate module" item should appear only if it's necessary
+  OB_Browser* ob = objectBrowser();
+  if ( !ob || type != ob->popupClientType() )
+    return;
+  SALOME_ListIO aList;
+  SalomeApp_SelectionMgr* mgr = selectionMgr();
+  mgr->selectedObjects(aList);
+  if (aList.Extent() != 1)
+    return;
+  Handle(SALOME_InteractiveObject) aIObj = aList.First();
+  QString aModuleName(aIObj->getComponentDataType());
+  QString aModuleTitle = moduleTitle(aModuleName);
+  CAM_Module* currentModule = activeModule();
+  if (currentModule && currentModule->moduleName() == aModuleTitle)
+    return;
   thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) );
 }
 
@@ -1553,3 +1601,13 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
   if ( objectBrowser() )
     objectBrowser()->updateTree();
 }
+
+
+//************************************************************
+void SalomeApp_Application::onDesktopActivated()
+{
+  CAM_Application::onDesktopActivated();
+  SalomeApp_Module* aModule = dynamic_cast<SalomeApp_Module*>(activeModule());
+  if(aModule)
+    aModule->studyActivated();
+}