Salome HOME
debug IPAL9411: redefine virtual methods createEmptyStudy and activateModule
[modules/gui.git] / src / CAM / CAM_Application.cxx
index f9e7a3dd62d1eec8a094f62cbe66377282b74435..d13c53ef5f85fca528ab2b5cc740e1185b53a79f 100755 (executable)
@@ -10,6 +10,8 @@
 #include <qfile.h> 
 #include <qfileinfo.h>
 #include <qtextstream.h>
+#include <qlabel.h>
+#include <qfont.h>
 
 #ifdef WIN32
 #include <windows.h>
@@ -231,8 +233,12 @@ bool CAM_Application::activateModule( CAM_Module* mod )
     return true;
 
   if ( myModule )
-    myModule->deactivateModule( activeStudy() );
-
+  {
+    if ( !myModule->deactivateModule( activeStudy() ) )
+    {
+      // ....      
+    }    
+  }    
   myModule = mod;
 
   if ( myModule ){
@@ -251,7 +257,14 @@ bool CAM_Application::activateModule( CAM_Module* mod )
        prev = dm;
       }
     }
-    myModule->activateModule( activeStudy() );
+    if ( !myModule->activateModule( activeStudy() ) )
+    {
+      myModule->setMenuShown( false );
+      myModule->setToolShown( false );
+      SUIT_MessageBox::error1( desktop(), tr( "ERROR_TLT" ), tr( "ERROR_ACTIVATE_MODULE_MSG" ).arg( myModule->moduleName() ), tr( "BUT_OK" ) );
+      myModule = 0;
+      return false;
+    }
   }
 
   updateCommandsStatus();
@@ -377,9 +390,24 @@ void CAM_Application::readModuleList()
     SUIT_MessageBox::error1( 0, tr( "Error" ), tr( "Can not load modules configuration file " ), tr( "Ok" ) );
 }
 
-void CAM_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup )
+void CAM_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
 {
   // to do : add common items for popup menu ( if they are exist )
   if ( activeModule() ) 
-    activeModule()->contextMenuPopup( type, thePopup );
+    activeModule()->contextMenuPopup( type, thePopup, title );
+}
+
+void CAM_Application::createEmptyStudy()
+{
+  SUIT_Study* study = activeStudy();
+
+  STD_Application::createEmptyStudy();
+
+  SUIT_Study* newStudy = activeStudy();
+  if ( study != newStudy ) 
+  {
+    CAM_Study* camStudy = dynamic_cast<CAM_Study*>( newStudy );
+    for ( ModuleListIterator it( myModules ); it.current(); ++it )
+      camStudy->insertDataModel( it.current()->dataModel() );
+  }
 }