Salome HOME
Fix make check with Python 2.7
[modules/yacs.git] / src / salomewrap / SuitWrapper.cxx
index fd54bb9eb16888e526fbf31bcaad0e853d1bcdbd..7ff7417499520484bdd3049caf1916e2af3fec78 100644 (file)
@@ -1,21 +1,22 @@
-//  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2012  CEA/DEN, EDF R&D
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 /*!
  *  only one declaration in src/genericgui,
  *  implementations in salomewrap and standalonegui
 #include "SalomeWrap_DataModel.hxx"
 
 #include <SalomeApp_Module.h>
+#include <SalomeApp_Application.h>
+#include "SUIT_Session.h"
+#include "SUIT_ResourceMgr.h"
+
 #include <QxScene_ViewManager.h>
 #include <QxScene_ViewModel.h>
 #include <QxScene_ViewWindow.h>
@@ -51,7 +56,7 @@ SuitWrapper::~SuitWrapper()
 
 QWidget* SuitWrapper::getNewWindow(QGraphicsScene *scene)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->getNewWindow(scene);
 }
 
@@ -60,12 +65,12 @@ QWidget* SuitWrapper::getNewWindow(QGraphicsScene *scene)
  */
 int SuitWrapper::AssociateViewToWindow(QGraphicsView* gView, QWidget* viewWindow)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   QxScene_ViewWindow *svw = dynamic_cast<QxScene_ViewWindow*>(viewWindow);
-  assert(svw);
+  YASSERT(svw);
   int studyId = module->AssociateViewToWindow(gView, svw);
   WrapGraphicsView* wgv = dynamic_cast<WrapGraphicsView*>(gView);
-  assert(wgv);
+  YASSERT(wgv);
   QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::FitAllId),
                       SIGNAL(triggered(bool)),
                       svw, SLOT(onViewFitAll()));
@@ -112,10 +117,16 @@ int SuitWrapper::AssociateViewToWindow(QGraphicsView* gView, QWidget* viewWindow
 
 int SuitWrapper::activeStudyId()
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->activeStudyId();
 }
 
+QDockWidget* SuitWrapper::objectBrowser()
+{
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
+  return module->objectBrowser();
+}
+
 QAction* SuitWrapper::createAction(const int id,
                                     const QString& toolTip,
                                     const QIcon& icon,
@@ -127,7 +138,7 @@ QAction* SuitWrapper::createAction(const int id,
                                     QObject* receiver,
                                     const char* member)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateAction(id, toolTip, icon, menu, status, shortCut,
                                parent, checkable, receiver, member);
 }
@@ -138,7 +149,7 @@ int SuitWrapper::createMenu(const QString& subMenu,
                              const int groupId,
                              const int index)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateMenu(subMenu, parentMenuId, menuId, groupId, index);
 }
 
@@ -148,7 +159,7 @@ int SuitWrapper::createMenu(const QString& subMenu,
                              const int groupId,
                              const int index)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateMenu(subMenu, parentMenu, menuId, groupId, index);
 }
 
@@ -157,7 +168,7 @@ int SuitWrapper::createMenu(const int actionId,
                              const int groupId,
                              const int index)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateMenu(actionId, menuId, groupId, index);
 }
 
@@ -166,7 +177,7 @@ int SuitWrapper:: createMenu(const int actionId,
                              const int groupId,
                              const int index)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateMenu(actionId, menu, groupId, index);
 }
 
@@ -176,7 +187,7 @@ int SuitWrapper::createMenu(QAction* action,
                              const int groupId,
                              const int index)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateMenu(action, menuId, actionId, groupId, index);
 }
 
@@ -186,13 +197,13 @@ int SuitWrapper::createMenu(QAction* action,
                              const int groupId,
                              const int index)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateMenu(action, menu, actionId, groupId, index);
 }
 
 int SuitWrapper::createTool(const QString& name)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateTool(name);
 }
 
@@ -200,7 +211,7 @@ int SuitWrapper::createTool(const int actionId,
                              const int toolbarId, 
                              const int index)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateTool(actionId, toolbarId, index);
 }
 
@@ -208,7 +219,7 @@ int SuitWrapper::createTool(const int actionId,
                              const QString& toolbar,
                              const int index)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateTool(actionId, toolbar, index);
 }
 
@@ -217,7 +228,7 @@ int SuitWrapper::createTool(QAction* action,
                              const int actionId,
                              const int index)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateTool(action, toolbarId, actionId, index);
 }
 
@@ -226,7 +237,7 @@ int SuitWrapper::createTool(QAction* action,
                              const int actionId,
                              const int index)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   return module->wCreateTool(action, toolbar, actionId, index);
 }
 
@@ -237,20 +248,20 @@ QAction* SuitWrapper::separator()
 
 void SuitWrapper::setMenuShown(QAction* act, bool show)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   module->setMenuShown(act, show);
 }
 
 void SuitWrapper::setToolShown(QAction* act, bool show)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   module->setToolShown(act, show);
 }
 
 void SuitWrapper::createNewSchema(const QString& schemaName,
                                   QWidget* viewWindow)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   module->getDataModel()->createNewSchema(schemaName, viewWindow);
 }
 
@@ -258,8 +269,14 @@ bool SuitWrapper::renameSchema(const QString& oldName,
                                const QString& newName,
                                QWidget* viewWindow)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
-  module->getDataModel()->renameSchema(oldName, newName, viewWindow);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
+  return module->getDataModel()->renameSchema(oldName, newName, viewWindow);
+}
+
+bool SuitWrapper::deleteSchema(QWidget* viewWindow)
+{
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
+  return module->getDataModel()->deleteSchema(viewWindow);
 }
 
 void SuitWrapper::createNewRun(const QString& schemaName,
@@ -267,6 +284,23 @@ void SuitWrapper::createNewRun(const QString& schemaName,
                                QWidget* refWindow,
                                QWidget* viewWindow)
 {
-  SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
+  SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
   module->getDataModel()->createNewRun(schemaName, runName, refWindow, viewWindow);
 }
+
+QStringList SuitWrapper::getQuickDirList()
+{
+  QStringList dirList;
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  if ( resMgr )
+    dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
+  return dirList;
+}
+
+void SuitWrapper::onHelpContextModule( const QString& theComponentName, const QString& theFileName, const QString& theContext )
+{
+  LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
+  if(app)
+    app->onHelpContextModule( theComponentName, theFileName, theContext );
+}
+