Salome HOME
Return deleted code.
[modules/yacs.git] / src / genericgui / GenericGui.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 5094c4b..cd53c27
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2016  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
@@ -153,18 +153,18 @@ GenericGui::GenericGui(YACS::HMI::SuitWrapper* wrapper, QMainWindow *parent)
   _dwTree = new QDockWidget(_parent);
   _dwTree->setVisible(false);
   _dwTree->setWindowTitle("Tree View: edition mode");
-  _dwTree->setObjectName("Tree View");
+  _dwTree->setObjectName("yacsTreeViewDock");
   _parent->addDockWidget(Qt::LeftDockWidgetArea, _dwTree);
   _dwStacked = new QDockWidget(_parent);
   _dwStacked->setVisible(false);
   _dwStacked->setWindowTitle("Input Panel");
-  _dwStacked->setObjectName("Input Panel");
+  _dwStacked->setObjectName("yacsInputPanelDock");
   _dwStacked->setMinimumWidth(270); // --- force a minimum until display
   _parent->addDockWidget(Qt::RightDockWidgetArea, _dwStacked);
   _dwCatalogs = new QDockWidget(_parent);
   _dwCatalogs->setVisible(false);
   _dwCatalogs->setWindowTitle("Catalogs");
-  _dwCatalogs->setObjectName("Catalogs");
+  _dwCatalogs->setObjectName("yacsCatalogsDock");
   _parent->addDockWidget(Qt::RightDockWidgetArea, _dwCatalogs);
   _catalogsWidget = new CatalogWidget(_dwCatalogs,
                                       _builtinCatalog,
@@ -172,7 +172,8 @@ GenericGui::GenericGui(YACS::HMI::SuitWrapper* wrapper, QMainWindow *parent)
   _dwCatalogs->setWidget(_catalogsWidget);
 
   _parent->tabifyDockWidget(_dwStacked, _dwCatalogs);
-  _parent->tabifyDockWidget(_dwTree, _wrapper->objectBrowser());
+  if (_wrapper->objectBrowser())
+    _parent->tabifyDockWidget(_dwTree, _wrapper->objectBrowser());
 #if QT_VERSION >= 0x040500
   _parent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
 #endif
@@ -307,6 +308,10 @@ void GenericGui::createActions()
                                             tr("Create Container"), tr("Create a New Container"),
                                             0, _parent, false, this,  SLOT(onNewContainer()));
 
+  _newHPContainerAct = _wrapper->createAction(getMenuId(), tr("Create a New HP Container"), QIcon("icons:container.png"),
+                                              tr("Create HP Container"), tr("Create a New Homogeneous Pool Container."),
+                                              0, _parent, false, this,  SLOT(onNewHPContainer()));
+
   _selectComponentInstanceAct = _wrapper->createAction(getMenuId(), tr("Select a Component Instance"), QIcon("icons:icon_select.png"),
                                                        tr("Select a Component Instance"), tr("Select a Component Instance"),
                                                        0, _parent, false, this,  SLOT(onSelectComponentInstance()));
@@ -460,6 +465,14 @@ void GenericGui::createActions()
                                             tr("shrink/expand"), tr("shrink or expand the selected node"),
                                             0, _parent, false, this,  SLOT(onShrinkExpand()));
 
+  _shrinkExpandChildren = _wrapper->createAction(getMenuId(), tr("shrink or expand direct children of the selected node"), QIcon("icons:shrinkExpand.png"),
+                                            tr("shrink/expand children"), tr("shrink or expand direct children of the selected node"),
+                                            0, _parent, false, this,  SLOT(onShrinkExpandChildren()));
+
+  _shrinkExpandElementaryRecursively = _wrapper->createAction(getMenuId(), tr("shrink or expand elementary nodes of the selected node recursively"), QIcon("icons:shrinkExpand.png"),
+                                            tr("shrink/expand elementary"), tr("shrink or expand elementary nodes of the selected node recursively"),
+                                            0, _parent, false, this,  SLOT(onShrinkExpandElementaryRecursively()));
+
   _toggleStraightLinksAct = _wrapper->createAction(getMenuId(), tr("draw straight or orthogonal links"), QIcon("icons:straightLink.png"),
                                                    tr("straight/orthogonal"), tr("draw straight or orthogonal links"),
                                                    0, _parent, true, this,  SLOT(onToggleStraightLinks(bool)));
@@ -670,7 +683,7 @@ void GenericGui::createMenus()
 
 void GenericGui::createTools()
 {
-  int aToolId = _wrapper->createTool ( tr( "YACS Toolbar" ) );
+  int aToolId = _wrapper->createTool ( tr( "YACS Toolbar" ), QString( "YACSToolbar" ) );
   _wrapper->createTool( _newSchemaAct, aToolId );
   _wrapper->createTool( _importSchemaAct, aToolId );
   _wrapper->createTool( _wrapper->separator(), aToolId );
@@ -956,19 +969,15 @@ bool GenericGui::closeContext(QWidget *view, bool onExit)
           break;
         }
     }
-  int studyId = _wrapper->activeStudyId();
-  if (context->getStudyId() == studyId)
+  _wrapper->deleteSchema(view);
+  DEBTRACE("delete context");
+  if (GuiExecutor* exec = context->getGuiExecutor())
     {
-      _wrapper->deleteSchema(view);
-      DEBTRACE("delete context");
-      if (GuiExecutor* exec = context->getGuiExecutor())
-        {
-          exec->closeContext();
-        }
-      delete context;
-      _mapViewContext.erase(view);
-      switchContext(newView, onExit);
+      exec->closeContext();
     }
+  delete context;
+  _mapViewContext.erase(view);
+  switchContext(newView, onExit);
   return true;
 }
 
@@ -1080,11 +1089,7 @@ void GenericGui::createContext(YACS::ENGINE::Proc* proc,
   GraphicsView* gView = new GraphicsView(viewWindow);
   gView->setScene(scene);
   gView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
-  int studyId = _wrapper->AssociateViewToWindow(gView, viewWindow);
-  context->setStudyId(studyId);
-  std::ostringstream value;
-  value << studyId;
-  proc->setProperty("DefaultStudyID",value.str());
+  _wrapper->AssociateViewToWindow(gView, viewWindow);
   context->setScene(scene);
   context->setView(gView);
   context->setWindow(viewWindow);
@@ -1425,11 +1430,11 @@ void GenericGui::onImportSupervSchema()
       QString aCall = "salomeloader."+ fileExt+ " "+ fn + " " + tmpFileName + " > " + tmpOutput;
       DEBTRACE(aCall.toStdString());
       
-      int ret = system(aCall.toAscii());
+      int ret = system(aCall.toLatin1());
       if(ret != 0)
         {
           // --- read file with logs
-          fstream f(tmpOutput.toAscii());
+          fstream f(tmpOutput.toLatin1());
           stringstream hfile;
           hfile << f.rdbuf();
           f.close();
@@ -1504,8 +1509,8 @@ QString GenericGui::getSaveFileName(const QString& fileName)
   filters << "XML files (*.xml)"
           << "Any files (*)";
   dialog.setFileMode(QFileDialog::AnyFile);
-  dialog.setFilters(filters);
-  dialog.selectFilter("(*.xml)");
+  dialog.setNameFilters(filters);
+  dialog.selectNameFilter("(*.xml)");
   dialog.setDefaultSuffix("xml");
   dialog.setConfirmOverwrite(true);
   //dialog.setConfirmOverwrite(false);  // bug Qt4.3.3
@@ -1951,6 +1956,12 @@ void GenericGui::onNewContainer()
   _guiEditor->CreateContainer();
 }
 
+void GenericGui::onNewHPContainer()
+{
+  DEBTRACE("GenericGui::onNewHPContainer");
+  _guiEditor->CreateHPContainer();
+}
+
 void GenericGui::onNewSalomeComponent()
 {
   DEBTRACE("GenericGui::onNewSalomeComponent");
@@ -2182,6 +2193,16 @@ void GenericGui::onShrinkExpand() {
   _guiEditor->shrinkExpand();
 }
 
+void GenericGui::onShrinkExpandChildren() {
+  DEBTRACE("GenericGui::onShrinkExpandChildren");
+  _guiEditor->shrinkExpand(Qt::ControlModifier|Qt::ShiftModifier);
+}
+
+void GenericGui::onShrinkExpandElementaryRecursively() {
+  DEBTRACE("GenericGui::onShrinkExpandElementaryRecursively");
+  _guiEditor->shrinkExpand(Qt::ControlModifier);
+}
+
 void GenericGui::onToggleStraightLinks(bool checked)
 {
   Scene::_straightLinks = checked;
@@ -2527,7 +2548,11 @@ void GenericGui::onUndo()
 {
   DEBTRACE("GenericGui::onUndo");
   if (QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
+  {
     QtGuiContext::getQtCurrent()->getInvoc()->undo();
+    // Empty the clipboard in order to avoid the copy of a destroyed object.
+    QtGuiContext::getQtCurrent()->setSubjectToCopy(NULL);
+  }
   else Message("undo not possible when there are local modifications not confirmed");
 }
 
@@ -2535,7 +2560,11 @@ void GenericGui::onRedo()
 {
   DEBTRACE("GenericGui::onRedo");
   if (QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
+  {
     QtGuiContext::getQtCurrent()->getInvoc()->redo();
+    // Empty the clipboard in order to avoid the copy of a destroyed object.
+    QtGuiContext::getQtCurrent()->setSubjectToCopy(NULL);
+  }
   else Message("redo not possible when there are local modifications not confirmed");
 }
 
@@ -2552,7 +2581,6 @@ void GenericGui::onShowRedo()
 void GenericGui::onCleanOnExit()
 {
   DEBTRACE("GenericGui::onCleanOnExit");
-  int studyId = _wrapper->activeStudyId();
   map<QWidget*, YACS::HMI::QtGuiContext*> mapViewContextCopy = _mapViewContext;
   map<QWidget*, YACS::HMI::QtGuiContext*>::iterator it = mapViewContextCopy.begin();
   for (; it != mapViewContextCopy.end(); ++it)