Salome HOME
Copyright update: 2016
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI.cxx
index 7bab2d81a4bfa9a015e7785f1c37b44328a70c00..faced0468ed8584b4bc384595d7f042820f3aed1 100755 (executable)
@@ -1,9 +1,9 @@
-// Copyright (C) 2009-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2009-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
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 //#define _DEVDEBUG_
 
-// #include <Python.h>
-
 #include <cassert>
 
-
-// #include "klinkitemselectionmodel.h"
-
-
+#include <QDir>
 #include <QInputDialog>
 #include <QIcon>
 #include <QStackedWidget>
-
-
+#include <QMenu>
+#include <QSplitter>
 
 #include <QtxTreeView.h>
 #include <SUIT_MessageBox.h>
@@ -44,7 +39,6 @@
 #include <SUIT_DataBrowser.h>
 #include <SUIT_FileDlg.h>
 
-// #include <QxScene_ViewManager.h>
 #include <SVTK_ViewManager.h>
 #include <SVTK_ViewModel.h>
 #include <SVTK_ViewWindow.h>
@@ -60,9 +54,9 @@
 #include <SOCC_ViewModel.h>
 #include <SOCC_ViewWindow.h>
 #include <OCCViewer_ViewWindow.h>
-
-#include <GEOM_Constants.h>
-
+#include <SALOME_Prs.h>
+#include <SOCC_Prs.h>
+#include <SOCC.h>
 
 // SALOME KERNEL includes
 #include <SALOMEDS_Study.hxx>
@@ -80,7 +74,6 @@
 
 
 #include <SALOME_ListIO.hxx>
-#include <SALOME_ListIteratorOfListIO.hxx>
 
 
 #include <SALOME_LifeCycleCORBA.hxx>
 
 #include <OCCViewer_ViewManager.h>
 
-#include <GeometryGUI.h>
-
 #include <QtxPopupMgr.h>
 
-
 #include "Resource.hxx"
-// #include "QtGuiContext.hxx"
 
 #include "HEXABLOCKGUI.hxx"
 #include "HEXABLOCKGUI_Export.hxx"
 #include "HEXABLOCKGUI_Trace.hxx"
 #include "HEXABLOCKGUI_Resource.hxx"
-#include "GEOMBase.h"
-// #include "HEXABLOCKGUI_DataModel.hxx"
 
 #include "HEXABLOCKGUI_DocumentModel.hxx"
 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
-#include "HEXABLOCKGUI_DocumentDelegate.hxx"
+//#include "HEXABLOCKGUI_DocumentDelegate.hxx"
 #include "HEXABLOCKGUI_DocumentPanel.hxx"
 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
 #include "HEXABLOCKGUI_OccGraphicView.hxx"
 #include "HEXABLOCKGUI_GraphicViewsHandler.hxx"
 
-#include <HEXABLOCK_version.h>
+#include "HEXABLOCK_version.h"
 
 #include "MyBasicGUI_PointDlg.hxx"
 
-// #include CORBA_CLIENT_HEADER(HEXABLOCKPlugin_Algorithm)
-
-#include "HEXABLOCK.hxx"
-#include "HexDocument_impl.hxx"
+// #include "HEXABLOCK.hxx"                del Hexa6
+// #include "HexDocument_impl.hxx"         del Hexa6
 #include "Hex.hxx"
 
 
+#include <Visual3d_ViewManager.hxx>
+//#include <V3d_PerspectiveView.hxx>
+#include <V3d_AmbientLight.hxx>
+#include <V3d_DirectionalLight.hxx>
+#include <Xw_Window.hxx>
+#include <V3d_TypeOfShadingModel.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+#include <BRepAlgoAPI_Fuse.hxx>
+
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+
+#include <utilities.h>
+
 #define DW_MINIMUM_WIDTH       50
 #define DWINPUT_MINIMUM_HEIGHT 50
 #define DWINPUT_MINIMUM_WIDTH  50//255
@@ -131,26 +130,17 @@ using namespace std;
 using namespace HEXABLOCK::GUI;
 
 int  HEXABLOCKGUI::_oldStudyId = -1;
-//bool jepeux = false;
-
-HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine  = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
-// SMESH::SMESH_Gen_var             HEXABLOCKGUI::_smeshEngine = SMESH::SMESH_Gen::_nil();
- GEOM::GEOM_Gen_var               HEXABLOCKGUI::_geomEngine  = GEOM::GEOM_Gen::_nil();
-
-// std::map<HEXABLOCK::GUI::DocumentModel*,  SVTK_ViewWindow*> HEXABLOCKGUI::svtkViews;
-// std::map<const QAbstractItemModel*,  SVTK_ViewWindow*> HEXABLOCKGUI::svtkViews;
-// std::map<const QAbstractItemModel*,  SUIT_ViewWindow*> HEXABLOCKGUI::salomeViews;
-// HEXABLOCK::GUI::DocumentModel       *HEXABLOCKGUI::getCurrentModel() = NULL;
 
+// HEXABLOCK_ORB::HEXABLOCK_Gen_var HEXABLOCKGUI::_hexaEngine  = HEXABLOCK_ORB::HEXABLOCK_Gen::_nil();
+//
 VtkDocumentGraphicView* HEXABLOCKGUI::currentDocGView = NULL;
 OccGraphicView*         HEXABLOCKGUI::currentOccGView = NULL;
-MyGEOMBase_Helper*      HEXABLOCKGUI::geomBaseHelper = NULL;
 bool                    HEXABLOCKGUI::assocInProgress = false;
 SalomeApp_Application*  HEXABLOCKGUI::myApplication = NULL;
-GEOMGUI_OCCSelector*    HEXABLOCKGUI::currentOccSelector = NULL;
 
 HEXABLOCKGUI::HEXABLOCKGUI() :
-          SalomeApp_Module( "HEXABLOCK" ), // default name
+          SalomeApp_Module( "HEXABLOCK" ),
+//          LightApp_Module( "HEXABLOCK" ),
           _menuId(190),
           _dwPattern(0),
           _dwAssociation(0),
@@ -159,14 +149,14 @@ HEXABLOCKGUI::HEXABLOCKGUI() :
           _dwObjectBrowser(0),
           _dwInputPanel(0),
           _patternDataTreeView(0),
-          _patternBuilderTreeView(0),
+//          _patternBuilderTreeView(0),
           _patternGeomTreeView(0),
-          _associationTreeView(0),
           _groupsTreeView(0),
           _meshTreeView(0),
-          _treeViewDelegate(0),
+//          _treeViewDelegate(0),
           _isSaved( false ),
           moduleActivatedOnce(false),
+          menusEnabled(true),
           _vertexDiag(0),
           _edgeDiag(0),
           _quadDiag(0),
@@ -201,19 +191,28 @@ HEXABLOCKGUI::HEXABLOCKGUI() :
           _makeHemiSphereDiag(0),
           _modelInfoDiag(NULL),
           _addShapeDiag(NULL),
-          currentDialog(NULL)
+          _vertexInfoDialog(NULL),
+          _edgeInfoDialog(NULL),
+          _quadInfoDialog(NULL),
+          _hexaInfoDialog(NULL),
+          _vectorInfoDialog(NULL),
+          _groupInfoDialog(NULL),
+          _lawInfoDialog(NULL),
+          _propagationInfoDialog(NULL),
+          currentDialog(NULL),
+          lastOccPrs(NULL),
+          lastVtkDocGView(NULL)
 {
     DEBTRACE("HEXABLOCKGUI::HEXABLOCKGUI");
-    //   _studyContextMap.clear();
+
     graphicViewsHandler = new GraphicViewsHandler();
     loadDocLastPath = new QDir();
     saveDocLastPath = new QDir();
+    hexa_root       = HEXA_NS::Hex::getInstance ();
 }
 
 HEXABLOCKGUI::~HEXABLOCKGUI()
 {
-    //   if ( getApp() )
-    //     disconnect( getApp(), SIGNAL(studyClosed()), _genericGui, SLOT  (onCleanOnExit()));
 }
 
 
@@ -228,6 +227,7 @@ SalomeApp_Study* HEXABLOCKGUI::activeStudy()
 
 
 // Gets an reference to the module's engine
+/****************************************************
 HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Application* app )
 {
     Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer", "HEXABLOCK" );
@@ -235,35 +235,15 @@ HEXABLOCK_ORB::HEXABLOCK_Gen_ptr HEXABLOCKGUI::InitHEXABLOCKGen( SalomeApp_Appli
     ASSERT(!CORBA::is_nil(clr));
     return clr;
 }
-
-// // Gets an reference to SMESH's engine CS_TO_DELETE
-// SMESH::SMESH_Gen_ptr HEXABLOCKGUI::InitSMESHGen( SalomeApp_Application* app,
-//                                                  const std::string& container )
-// {
-//   Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( container.c_str(), "SMESH" );
-//   SMESH::SMESH_Gen_ptr          clr = SMESH::SMESH_Gen::_narrow(comp);
-//   ASSERT(!CORBA::is_nil(clr));
-//   return clr;
-// }
-//
-// // Gets an reference to GEOM's engine CS_TO_DELETE
-GEOM::GEOM_Gen_ptr HEXABLOCKGUI::InitGEOMGen( SalomeApp_Application* app,
-        const std::string& container )
-{
-    Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( container.c_str(), "GEOM" );
-    GEOM::GEOM_Gen_ptr            clr = GEOM::GEOM_Gen::_narrow(comp);
-    ASSERT(!CORBA::is_nil(clr));
-    return clr;
-}
-
+ **************************************************** */
 
 void HEXABLOCKGUI::initialize( CAM_Application* app )
 {
+       MESSAGE("HEXABLOCKGUI::initialize");
     DEBTRACE("HEXABLOCKGUI::initialize");
     SalomeApp_Module::initialize( app );
 
-    _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
-    _geomEngine = InitGEOMGen( dynamic_cast<SalomeApp_Application*>( app ) );
+    // _hexaEngine = InitHEXABLOCKGen( dynamic_cast<SalomeApp_Application*>( app ) );
 
     DEBTRACE(app << "  " << application() << " " << application()->desktop() << " " << aParent);
 
@@ -275,52 +255,16 @@ void HEXABLOCKGUI::initialize( CAM_Application* app )
     createMenus();
     createTools();
     studyActivated();
-    // add component to study
-//    if (createSComponent()) updateObjBrowser()
-//    createSComponent();
-
-    if (_dwInputPanel != NULL)
-        geomBaseHelper = new MyGEOMBase_Helper(dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent()));
 }
 
 void HEXABLOCKGUI::viewManagers( QStringList& list ) const
 {
     DEBTRACE("HEXABLOCKGUI::viewManagers");
-    //   foreach (const QString &str, list)
-    //     MESSAGE("HEXABLOCKGUI::viewManagers"<<str.toStdString() );
     //   list.append( QxScene_Viewer::Type() );
     //   list.append( OCCViewer_Viewer::Type() );
     //   list.append( SVTK_Viewer::Type() );
 }
 
-void HEXABLOCKGUI::restoreGraphicViews()
-{
-
-    //Init OCC
-    if (currentOccGView == NULL)
-    {
-        currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
-                application()->desktop());
-        currentOccGView->getViewWindow()->installEventFilter(this);
-    }
-    else if (currentOccGView->getViewWindow() == NULL)
-    {
-        currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
-        currentOccGView->getViewWindow()->installEventFilter(this);
-    }
-
-
-    //Init VTK
-    if (currentDocGView == NULL)
-        newDocument();
-    else if (currentDocGView->getViewWindow() == NULL)
-    {
-        currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
-        currentDocGView->getViewWindow()->installEventFilter(this);
-    }
-
-}
-
 
 bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
 {
@@ -339,16 +283,12 @@ bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
     bool bOk = SalomeApp_Module::activateModule( theStudy );
     if ( !bOk ) return false;
 
-    //   setMenuShown( true );
-    //   setToolShown( true );
-    //   showDockWidgets(false);
     showDockWidgets(true);
 
     connect( getApp()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
             this, SLOT(onWindowActivated( SUIT_ViewWindow* )), Qt::UniqueConnection );
     connect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
             this, SLOT( onObjectBrowserClick(const QModelIndex&) ), Qt::UniqueConnection );
-    //       connect( getApp(),   SIGNAL(studyClosed()), _genericGui,SLOT  (onCleanOnExit()));
 
     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
 
@@ -358,7 +298,7 @@ bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
     application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
     QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
     while ( itOCC.hasNext() && (vm = itOCC.next()) )
-        myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
+        myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
 
     application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
     QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
@@ -372,9 +312,9 @@ bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
 
     // disable OCC selectors
     getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
-    QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
+    QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
     while ( itOCCSel.hasNext() )
-        if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
+        if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
             sr->setEnabled(true);
 
     // disable VTK selectors
@@ -402,18 +342,18 @@ bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
                 this, SLOT( onWindowClosed(SUIT_ViewWindow *) ), Qt::UniqueConnection );
     }
 
+    /* ************************************   TODO Hexa6
     _hexaEngine->SetCurrentStudy(SALOMEDS::Study::_nil());
     if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( theStudy ))
         if ( _PTR(Study) aStudy = s->studyDS()) {
-            //define _CAST(Class, shared_ptr_Obj) dynamic_cast<SALOMEDS_##Class*>(shared_ptr_Obj.get())
             _hexaEngine->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
             updateObjBrowser(); // objects can be removed
         }
+     ************************************ */
 
     if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
             currentOccGView->getViewWindow()->installEventFilter(this);
 
-
     if (currentDocGView != NULL)
     {
         switchModel(currentDocGView);
@@ -423,7 +363,10 @@ bool HEXABLOCKGUI::activateModule( SUIT_Study* theStudy )
             currentDocGView->getViewWindow()->installEventFilter(this);
     }
     else
-        initialMenus();
+    {
+        newDocument();
+//        initialMenus();
+    }
 
     return bOk;
 }
@@ -435,21 +378,24 @@ bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
             this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
     disconnect( getApp()->objectBrowser()->treeView(),SIGNAL( clicked(const QModelIndex&) ),
             this, SLOT( onObjectBrowserClick(const QModelIndex&) ) );
-    //       connect( getApp(),   SIGNAL(studyClosed()), _genericGui,SLOT  (onCleanOnExit()));
 
-
-    if ( currentDocGView != NULL && currentDocGView->getViewWindow() != NULL )
+    SVTK_ViewWindow* vtkView = (currentDocGView != NULL) ? currentDocGView->getViewWindow() : NULL;
+    if ( vtkView != NULL)
+    {
         //default selectionMode in VTKView
-        currentDocGView->getViewWindow()->SetSelectionMode( ActorSelection );
+        vtkView->SetSelectionMode( ActorSelection );
+        vtkView->removeEventFilter(this);
+//        vtkView->close();
+    }
 
-    if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
+    OCCViewer_ViewWindow* occView = (currentOccGView != NULL) ? currentOccGView->getViewWindow() : NULL;
+    if (occView != NULL)
     {
         //defaut selectionMode in OccView
-        getApp()->selectionMgr()->clearSelected();
-        geomBaseHelper->globalSelection(currentOccGView->getViewWindow());
-//        geomBaseHelper->localSelection(GEOM::GEOM_Object::_nil(), TopAbs_SHAPE);
-        if (currentOccGView != NULL)
-            geomBaseHelper->localSelection(currentOccGView->getViewWindow(), TopAbs_SHAPE);
+        selectionMgr()->clearSelected();
+        currentOccGView->globalSelection();
+        occView->removeEventFilter(this);
+//        occView->close();
     }
 
     qDeleteAll(myOCCSelectors);
@@ -462,13 +408,6 @@ bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
 
     bool bOk = SalomeApp_Module::deactivateModule( theStudy );
 
-    //Must be done for all views later
-    if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
-        currentOccGView->getViewWindow()->removeEventFilter(this);
-
-    if (currentDocGView != NULL && currentDocGView->getViewWindow() != NULL)
-        currentDocGView->getViewWindow()->removeEventFilter(this);
-
     //switch off current document graphic view
     switchOffGraphicView(currentDocGView);
 
@@ -476,42 +415,79 @@ bool HEXABLOCKGUI::deactivateModule( SUIT_Study* theStudy )
     setMenuShown( false );
     setToolShown( false );
     showDockWidgets( false );
-    if (_dwInputPanel) _dwInputPanel->close();
+    if (_dwInputPanel)
+        _dwInputPanel->close();
 
-    //hide the current document actor
     hideActor();
 
     return bOk;
 }
 
-QString HEXABLOCKGUI::addInStudy(QString& fileName)
+SALOMEDS::Study_var HEXABLOCKGUI::ClientStudyToStudy (_PTR(Study) theStudy)
 {
-    QString objStudyEntry;
-
-    if ( !fileName.isEmpty() ) {
+  SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
+  CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
+  SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
+  int aStudyID = theStudy->StudyId();
+  SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
+  return aDSStudy._retn();
+}
 
-        SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
-        SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : NULL;
-        if(!appStudy) return objStudyEntry;
+void HEXABLOCKGUI::addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
+                              QMap<QString, QString>& docShapesEntry,
+                              QMap<QString, QString>& docShapesName)
+{
+    if (topo_shapes.size() == 0 || currentOccGView == NULL || currentDocGView == NULL)
+        return; //there's nothing to publish in this case
 
-        _PTR(Study) aStudy = appStudy->studyDS();
-        SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy );
+    SalomeApp_Study* appStudy = HEXABLOCKGUI::activeStudy();
+    if(!appStudy) return;
+    _PTR(Study) aStudy = appStudy->studyDS();
+    SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( aStudy );
+    SALOMEDS::StudyBuilder_var     aBuilder (aDSStudy->NewBuilder());
+    QString entry = currentDocGView->getDocumentModel()->documentEntry();
+    SALOMEDS::SObject_var aFatherSO = aDSStudy->FindObjectID( qPrintable(entry) );
+    if (aFatherSO->_is_nil())
+        return;
 
-        GEOM::GEOM_IInsertOperations_var aInsOp = _geomEngine->GetIInsertOperations( aStudy->StudyId() );
-        GEOM::GEOM_Object_var anObj = aInsOp->ImportFile(fileName.toStdString().c_str(), "BREP");
-        if ( !anObj->_is_nil() && aInsOp->IsDone() )
-        {
-            QStringList sList = fileName.split(".");
-            SALOMEDS::SObject_var aSO = _geomEngine->PublishInStudy( aDSStudy,
-                                         SALOMEDS::SObject::_nil(),
-                                         anObj,
-                                         sList[0].toStdString().c_str() );
-            objStudyEntry = aSO->GetID();
-        }
+    // * get a presentation
+    bool isNewPrs = false;
+    SOCC_Prs* prs = getOccPrs(currentDocGView);
+    if (prs == NULL)
+    {
+        prs = new SOCC_Prs(0);
+        isNewPrs = true;
     }
-    return objStudyEntry;
+
+    // * init the presentation with the given shapes
+    QMap<QString, TopoDS_Shape>::const_iterator i = topo_shapes.constBegin();
+    while (i != topo_shapes.constEnd())
+    {
+        QString shapeName  = i.key();
+        TopoDS_Shape shapeValue = i.value();
+        Handle(AIS_Shape) ais_shape = new AIS_Shape(shapeValue);
+        SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
+        QString objStudyEntry = aSO->GetID(); //the entry of the published object
+        Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject(objStudyEntry.toStdString().c_str(),
+                                                                    "HEXABLOCK", shapeName.toStdString().c_str());
+        ais_shape->SetOwner(io);
+        prs->AddObject(ais_shape);
+        aSO->SetAttrString("AttributeName", shapeName.toStdString().c_str());
+        docShapesEntry[shapeName] = objStudyEntry;
+        docShapesName[objStudyEntry] = shapeName;
+        currentOccGView->addShape(objStudyEntry, ais_shape);
+        i++; //handle next shape
+    }
+    // * set the preview
+    if (isNewPrs)
+        prs->AddObject(currentOccGView->getPreviewShape());
+
+    occPrs[currentDocGView] = prs;
+    getApp()->updateObjectBrowser();
+    showOnlyActor();
 }
 
+
 bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
 {
     SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
@@ -524,8 +500,13 @@ bool HEXABLOCKGUI::renameAllowed( const QString& entry) const
 
 bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
 {
-
     bool result = false;
+
+    // Pas de renommage des shapes pour le moment, juste les documents
+    VtkDocumentGraphicView* dgview = getDocGViewByEntry(entry);
+    if (dgview == NULL || dgview->getDocumentModel() == NULL)
+        return result;
+
     SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication());
     SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
 
@@ -542,17 +523,11 @@ bool HEXABLOCKGUI::renameObject( const QString& entry, const QString& name)
     if ( obj ){
         if ( obj->FindAttribute(anAttr, "AttributeName") ){
             _PTR(AttributeName) aName (anAttr);
-            //       GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
-            //
-            //       HEXABLOCK_Gen_i::Document_var aDoc = HEXABLOCK_Gen_i::Document::_narrow( theIOR );
-            //       if (!CORBA::is_nil(aDoc)) {
-//            aName->SetValue( name.toLatin1().data() ); // rename the SObject
-            //         aDoc->setName( name.toLatin1().data() );  // Rename the corresponding GEOM_Object
-            DocumentModel* currentModel = getCurrentModel();
-            if (currentModel == NULL) return result;
-            currentModel->setName( name/*.toLatin1().data()*/ );
-            aName->SetValue( getCurrentModel()->getName().toLatin1().data() );
-            //         _currentGraphicView->setWindowTitle( getCurrentModel()->getName() );
+            DocumentModel* docModel = dgview->getDocumentModel();
+            docModel->setName( name );
+            aName->SetValue( name.toLatin1().data() );
+            getApp()->updateObjectBrowser();
+//            _dwPattern->setWindowTitle( name );
             result = true;
         }
     }
@@ -565,27 +540,24 @@ void HEXABLOCKGUI::windows( QMap<int, int>& theMap ) const
     DEBTRACE("HEXABLOCKGUI::windows");
     theMap.clear();
     theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
+#ifndef DISABLE_PYCONSOLE
     theMap.insert( SalomeApp_Application::WT_PyConsole,     Qt::BottomDockWidgetArea );
+#endif
 }
 
-
-// QString  HEXABLOCKGUI::engineIOR() const
-// {
-//   DEBTRACE("HEXABLOCKGUI::engineIOR");
-// //   return getApp()->defaultEngineIOR();
-// }
-
-
 QString  HEXABLOCKGUI::engineIOR() const
 {
     DEBTRACE("HEXABLOCKGUI::engineIOR");
+
+    /* ************************************   TODO Hexa6
     CORBA::ORB_var anORB = getApp()->orb();
     CORBA::String_var anIOR = anORB->object_to_string(_hexaEngine);
     return QString( anIOR.in() );
+       ************************************ */
+    return "";
 }
 
-
-VtkDocumentGraphicView* HEXABLOCKGUI::getDocument(SalomeApp_DataObject* studyObject)
+VtkDocumentGraphicView* HEXABLOCKGUI::getOrCreateDocument(SalomeApp_DataObject* studyObject)
 {
     if (docs.count(studyObject->entry()) == 0)
     {
@@ -597,53 +569,48 @@ VtkDocumentGraphicView* HEXABLOCKGUI::getDocument(SalomeApp_DataObject* studyObj
 
         //------------------ Load the document -----------------
         HEXA_NS::Document* document = directory->findDocument(studyObject->name().toStdString());
-        if (document == NULL) return NULL;    //No document found
+        if (document == NULL)
+            return NULL;    //No document found
 
         DocumentModel* docModel = new DocumentModel(document, studyObject->entry(), this );
         if (!docModel) {
             MESSAGE("Doc model creation failed!");
             return NULL;
         }
-        dgview = graphicViewsHandler->createDocumentGraphicView(
-                                                       docModel,
-                                                       NULL/*viewWindow*/,
-                                                       application()->desktop() );
+        dgview = graphicViewsHandler->createDocumentGraphicView( docModel, NULL, application()->desktop() );
         if (dgview == NULL) return NULL;
 
         //update the data tree
-//        dgview->loadDocument();
         docs[studyObject->entry()] = dgview;
     }
 
     return docs[studyObject->entry()];
 }
 
-
-
 void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
 {
-    DEBTRACE("HEXABLOCKGUI::onObjectBrowserClick");
-    // we want to switch automatically to the right view windows
-//    QWidget *viewWindow = NULL;
+    // ** we want to switch automatically to the right view windows
 
     //first, find selected item
     QString itemEntry;
     DataObjectList dol = getApp()->objectBrowser()->getSelected();
     if (dol.isEmpty()) return;
     SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
-    if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0) return;
-    VtkDocumentGraphicView* docGView = getDocument(item);
-    if (docGView == NULL)
-    {
-//        currentDocGView = NULL;
+    if (!item || item->parent()->name().compare(tr("HEXABLOCK")) != 0 ||
+            item->entry().isEmpty())
         return;
-    }
+
+    // find the document corresponding to it
+    VtkDocumentGraphicView* docGView = NULL;
+    if (docs.contains(item->entry()))
+        docGView = docs[item->entry()];
+    else
+        docGView = getOrCreateDocument(item);
 
     //Init OCC if necessary
     if (currentOccGView == NULL)
     {
-        currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(),
-                application()->desktop());
+        currentOccGView = new OccGraphicView(graphicViewsHandler->createOccWindow(), application()->desktop());
         currentOccGView->getViewWindow()->installEventFilter(this);
     }
     else if (currentOccGView->getViewWindow() == NULL)
@@ -659,66 +626,54 @@ void HEXABLOCKGUI::onObjectBrowserClick(const QModelIndex& index)
         {
             docGView->setViewWindow(graphicViewsHandler->createVtkWindow());
             docGView->getViewWindow()->installEventFilter(this);
+            showAllMenus();
+            if (!menusEnabled)
+                setAllMenusEnabled(true);
         }
         else
             docGView->setViewWindow(currentDocGView->getViewWindow());
 
-        if (docGView->getDocumentActor() == NULL) docGView->update();
+        if (docGView->getDocumentActor() == NULL)
+            docGView->update();
+    }
+
+    if (docGView == NULL || docGView == currentDocGView)
+    {
+        showOnlyActor();
+        return;
     }
 
-//    setOpen (const QModelIndex &theObject, const bool theOpen=true)
-//    updateTree (SUIT_DataObject *=0, const bool=true)
     //update the current document
     switchModel(docGView);
-
 }
 
 
 void HEXABLOCKGUI::onWindowActivated( SUIT_ViewWindow* svw)
 {
     DEBTRACE("HEXABLOCKGUI::onWindowActivated");
-//    OCCViewer_ViewWindow* anOccVw = dynamic_cast<OCCViewer_ViewWindow*>(svw);
-
-    //update the current occ view
-//    if (anOccVw != NULL)
-//        currentOccGView->getViewWindow() = anOccVw;
-
-    //set event filter for the occ view
-//    if (currentOccGView != NULL && currentOccGView->getViewWindow() != NULL)
-//        currentOccGView->getViewWindow()->installEventFilter(this);
-
-    // we want to switch automatically to the right model
-    // only VTK view
-//    SVTK_ViewWindow* viewWindow = dynamic_cast<SVTK_ViewWindow*>(svw);
-//    if (viewWindow == NULL) return;
-//
-//    if (getApp()->activeModule() && getApp()->activeModule()->moduleName().compare("HEXABLOCK") != 0) //CS_TODO?
-//        getApp()->activateModule("HEXABLOCK");
-
-    //update the current model and the current vtk view
-//    switchModel( viewWindow );
 }
 
 void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
 {
     DEBTRACE("HEXABLOCKGUI::onWindowClosed");
 
-
     //Decharger le model correspondant (VTK)
     SVTK_ViewWindow* window = dynamic_cast<SVTK_ViewWindow*>(svw);
     if (window != NULL)
     {
-
         //VTK clean close
         if (currentDocGView != NULL && currentDocGView->getViewWindow() == window)
         { //HexaBlock Vtk Window has been closed
 
             if (currentDialog != NULL) currentDialog->close();
-            if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
+//            if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
             if (currentDocGView != NULL)
                 currentDocGView->setViewWindow(NULL);
 
-            initialMenus();
+//            initialMenus();
+            setAllMenusEnabled(false);
+            enableDocumentMenus(true);
+
             return;
         }
 
@@ -753,7 +708,7 @@ void HEXABLOCKGUI::onWindowClosed( SUIT_ViewWindow* svw)
         if (_edgeAssocDiag != NULL) _edgeAssocDiag->clear();
         if (_quadAssocDiag != NULL) _quadAssocDiag->clear();
         if (currentDialog != NULL) currentDialog->close();
-        if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
+//        if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
 
         currentOccGView->getViewWindow()->removeEventFilter(this);
         currentOccGView->setViewWindow(NULL);
@@ -770,13 +725,12 @@ void HEXABLOCKGUI::onViewManagerAdded( SUIT_ViewManager*  vm)
     if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
       {
         LightApp_SelectionMgr* sm = getApp()->selectionMgr();
-        myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
-
+        myOCCSelectors.append( new HEXABLOCKGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
         // disable OCC selectors
         getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
-        QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
+        QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
         while ( itOCCSel.hasNext() )
-          if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
+          if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
             sr->setEnabled(true);
       }
       else if ( vm->getType() == SVTK_Viewer::Type() )
@@ -812,7 +766,7 @@ void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
             {
                 //close opened dialog
                 if (currentDialog != NULL) currentDialog->close();
-                if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
+//                if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
 
                 initialMenus();
             }
@@ -834,9 +788,9 @@ void HEXABLOCKGUI::onViewManagerRemoved( SUIT_ViewManager* vm)
     if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
     {
         //OCC View removed: remove its selector
-        QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
+        QListIterator<HEXABLOCKGUI_OCCSelector*> itOCCSel( myOCCSelectors );
         while ( itOCCSel.hasNext() )
-            if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
+            if ( HEXABLOCKGUI_OCCSelector* sr = itOCCSel.next() )
                 if ( sr->viewer() == viewer )
                 {
                     delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
@@ -856,9 +810,11 @@ void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QI
     QTreeView* theTree = NULL;
     if ( sender() == currentGraphicView->getPatternDataSelectionModel() ){
         theTree = _patternDataTreeView;
-    } else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
+    }
+    /*else if ( sender() == currentGraphicView->getPatternBuilderSelectionModel() ){
         theTree = _patternBuilderTreeView;
-    } else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
+    }*/
+    else if ( sender() == currentGraphicView->getPatternGeomSelectionModel() ) {
         theTree =  _patternGeomTreeView;
     }
     else if ( sender() == currentGraphicView->getGroupsSelectionModel() ){
@@ -871,19 +827,6 @@ void HEXABLOCKGUI::onSelectionChanged( const QItemSelection & selected, const QI
     }
 }
 
-// void HEXABLOCKGUI::onTryClose(bool &isClosed, QxScene_ViewWindow* window) //CS_TODO
-// {
-//   DEBTRACE("HEXABLOCKGUI::onTryClose");
-//   isClosed = _genericGui->closeContext(window);
-// }
-
-// CAM_DataModel* HEXABLOCKGUI::createDataModel()
-// {
-//   DEBTRACE("HEXABLOCKGUI::createDataModel");
-//   return new HEXABLOCKGUI_DataModel(this);
-// //   return NULL;
-// }
-
 bool HEXABLOCKGUI::createSComponent() //addComponent
 {
     DEBTRACE("HEXABLOCKGUI::createSComponent");
@@ -904,38 +847,15 @@ bool HEXABLOCKGUI::createSComponent() //addComponent
 
         anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
         _PTR(AttributePixMap) aPixmap(anAttr);
-        //    aPixmap->SetPixMap("share/salome/resources/hexablock/ModuleHexablock.png");
         aPixmap->SetPixMap(tr("ICO_MODULE_HEXABLOCK_SMALL").toStdString());
 
         aBuilder->DefineComponentInstance(aComponent, engineIOR().toStdString());
         DEBTRACE("HEXABLOCKGUI::createSComponent engineIOR=>"<<engineIOR().toStdString());
-        //      aBuilder->DefineComponentInstance(aComponent, getApp()->defaultEngineIOR().toStdString());
-        //      DEBTRACE("HEXABLOCKGUI::createSComponent defaultEngineIOR=>"<<getApp()->defaultEngineIOR().toStdString());
-
-        //     SalomeApp_DataModel::synchronize( aComponent, HEXABLOCKGUI::activeStudy() );
         return true;
     }
     return false;
 }
 
-// bool HEXABLOCKGUI::isSelectionCompatible()
-// {
-//   DEBTRACE("HEXABLOCKGUI::isSelectionCompatible");
-//
-//   bool isCompatible = true;
-//   SALOME_ListIO selected;
-//   if ( LightApp_SelectionMgr *Sel = selectionMgr() )
-//     Sel->selectedObjects( selected );
-//
-//   SALOME_ListIteratorOfListIO It( selected );
-//   for ( ; isCompatible && It.More(); It.Next())
-//     isCompatible =
-//       ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
-//       ( strcmp("HEXABLOCK", It.Value()->getComponentDataType()) == 0 );
-//
-//   return isCompatible;
-// }
-
 void HEXABLOCKGUI::setResource(SUIT_ResourceMgr* r)
 {
     DEBTRACE("HEXABLOCKGUI::setResource");
@@ -953,35 +873,30 @@ void HEXABLOCKGUI::preferencesChanged( const QString& sect, const QString& name
 {
     DEBTRACE("HEXABLOCKGUI::preferencesChanged");
     _myresource->preferencesChanged(sect, name);
-    if(name=="userCatalog")
-    {
-        //       _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
-    }
+//    if(name=="userCatalog")
+//        _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
 }
 
 void HEXABLOCKGUI::studyActivated() //CS_TODO
 {
     int newStudyId = getApp()->activeStudy()->id();
     DEBTRACE("HEXABLOCKGUI::studyActivated " << _oldStudyId << " " << newStudyId);
-
-    if (_oldStudyId != -1)
-    {
-        //       _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
-        //       if (_studyContextMap.count(newStudyId))
-        //         {
-        //           DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
-        //           QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
-        //         }
-        //       else
-        //         {
-        //           DEBTRACE("no switch to null context");
-        //         }
-    }
+//    if (_oldStudyId != -1)
+//    {
+//        _studyContextMap[_oldStudyId] = QtGuiContext::getQtCurrent();
+//        if (_studyContextMap.count(newStudyId))
+//        {
+//            DEBTRACE("switch to valid context " << QtGuiContext::getQtCurrent() << " " << _studyContextMap[newStudyId]);
+//            QtGuiContext::setQtCurrent(_studyContextMap[newStudyId]);
+//        }
+//        else
+//        {
+//            DEBTRACE("no switch to null context");
+//        }
+//    }
     _oldStudyId = newStudyId;
 }
 
-
-
 void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
 {
     QModelIndex currentIndex = _patternDataTreeView->currentIndex();
@@ -991,7 +906,6 @@ void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
     currentAssocVariant = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE );
     currentAssocEntry    = currentIndex.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
     if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() ){
-        //   getCurrentModel()->allowEdition();
         QMenu menu( _patternDataTreeView );
         //Remove association
         QAction *clearAct = menu.addAction( "Remove association(s)" );
@@ -1031,34 +945,27 @@ void HEXABLOCKGUI::treeContextMenu(const QPoint& aPosition)
 
 void HEXABLOCKGUI::createAndFillDockWidget()
 {
+
     QMainWindow *aParent = application()->desktop();
 
     // Create dock widget (3 dock)
 
     //1) *********** user input panel ( contain user's edit dialog box )
     _dwInputPanel = new QDockWidget(aParent);
-    //  QLayout* inputLayout = new QVBoxLayout(aParent);
-    //  _dwInputPanel->setLayout(inputLayout);
-    //   _dwInputPanel->setWindowFlags(Qt::FramelessWindowHint);
-    //   _dwInputPanel->setWindowFlags(Qt::WindowTitleHint);
     _dwInputPanel->setVisible(false);
     _dwInputPanel->setWindowTitle("Input Panel");
-    //   _dwInputPanel->setMinimumHeight(DWINPUT_MINIMUM_HEIGHT);
-    _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
-//    _dwInputPanel->raise();
+    _dwInputPanel->setObjectName("hexablockInputPanelDock");
+//    _dwInputPanel->setMinimumWidth(DWINPUT_MINIMUM_WIDTH); // --- force a minimum until display
 
-    //   _stacked = new QStackedWidget(_dwInputPanel);
-    //   _dwInputPanel->setWidget(_stacked);
-
-    _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
+//    _treeViewDelegate = new DocumentDelegate(_dwInputPanel);
 
     //2) ************* document data ( Pattern, Association, Mesh ) in treeview representation
     //      Pattern
     _dwPattern = new QDockWidget(aParent);
-    //   _dwPattern->installEventFilter(this);
     _dwPattern->setVisible(false);
     _dwPattern->setWindowTitle("Model");
     _dwPattern->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
+    _dwPattern->setObjectName("hexablockModelDock");
 
     QFrame*      patternFrame  = new QFrame(_dwPattern);
     patternFrame->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
@@ -1066,105 +973,86 @@ void HEXABLOCKGUI::createAndFillDockWidget()
     patternLayout->setSizeConstraint(QLayout::SetMaximumSize);
     QSplitter *splitter = new QSplitter(Qt::Vertical,patternFrame);
     _patternDataTreeView    = new QTreeView(patternFrame);//_dwPattern);
-    _patternBuilderTreeView = new QTreeView(patternFrame);
+//    _patternBuilderTreeView = new QTreeView(patternFrame);                  // ---> TO REMOVE
     _patternGeomTreeView    = new QTreeView(patternFrame);
     splitter->addWidget(_patternDataTreeView);
-    splitter->addWidget(_patternBuilderTreeView);
+//    splitter->addWidget(_patternBuilderTreeView);                           // ---> TO REMOVE
     splitter->addWidget(_patternGeomTreeView);
     patternLayout->addWidget(splitter);
-    //   _patternDataTreeView->setMinimumHeight(DW_MINIMUM_WIDTH);
 
-    _patternDataTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers/*QAbstractItemView::DoubleClicked*/);
-    _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);//);//QAbstractItemView::DoubleClicked, QAbstractItemView::SelectedClicked)
-    _patternDataTreeView->setItemDelegate(_treeViewDelegate);
+    _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers/*QAbstractItemView::DoubleClicked*/);
+    _patternDataTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
+//    _patternDataTreeView->setItemDelegate(_treeViewDelegate);
 
 
-    _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
-    _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
+//    _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
+//    _patternBuilderTreeView->setItemDelegate(_treeViewDelegate);
 
     _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
     _patternGeomTreeView->setSelectionMode(QAbstractItemView::SingleSelection/*QAbstractItemView::MultiSelection*/);
 
     _dwPattern->setWidget(patternFrame);
     patternFrame->show();
-    //_dwPattern->raise();
 
     //      Groups
     _dwGroups = new QDockWidget(aParent);
-    //   _dwGroups->installEventFilter(this);
 
     _dwGroups->setVisible(false);
     _dwGroups->setWindowTitle("Groups");
     _dwGroups->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
+    _dwGroups->setObjectName("hexablockGroupsDock");
     _groupsTreeView = new QTreeView(_dwGroups);
-    //   _associationTreeView->setMinimumHeight(DW_MINIMUM_WIDTH);
-    _groupsTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
-    _groupsTreeView->setItemDelegate(_treeViewDelegate);
+    _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+//    _groupsTreeView->setItemDelegate(_treeViewDelegate);
     _dwGroups->setWidget(_groupsTreeView);
     _groupsTreeView->show();
 
     //      Mesh
     _dwMesh = new QDockWidget(aParent);
-    //   _dwMesh->installEventFilter(this);
     _dwMesh->setVisible(false);
     _dwMesh->setWindowTitle("Mesh");
     _dwMesh->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
+    _dwMesh->setObjectName("hexablockMeshDock");
     _meshTreeView = new QTreeView(_dwMesh);
-    //   _meshTreeView->setMinimumHeight(DW_MINIMUM_WIDTH);
-    _meshTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
+    _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
     _meshTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
-    _meshTreeView->setItemDelegate(_treeViewDelegate);
+//    _meshTreeView->setItemDelegate(_treeViewDelegate);
     _dwMesh->setWidget(_meshTreeView);
     _meshTreeView->show();
-    //   _dwMesh->raise();
-
 
-
-    //3) ************* documents ( salome objectbrowser )
-    QDockWidget *_dwObjectBrowser = 0;
+//    QDockWidget *_dwObjectBrowser = 0;
     QWidget* wid = getApp()->objectBrowser()->treeView();
-    //   QWidget *wid = application()->objectBrowser()->treeView();
     QWidget *w   = wid->parentWidget();
     while ( w && !_dwObjectBrowser ) {
         _dwObjectBrowser = ::qobject_cast<QDockWidget*>( w );
         w = w->parentWidget();
     }
-    //   _dwObjectBrowser->installEventFilter(this);
-    //   _dwObjectBrowser->setVisible(false);
     _dwObjectBrowser->setMinimumWidth(DW_MINIMUM_WIDTH); // --- force a minimum until display
     _dwObjectBrowser->setWindowTitle("Study");
 
-
     // dock widget position
-    //   aParent->addDockWidget(Qt::LeftDockWidgetArea,  _dwPattern);
-    //   aParent->addDockWidget(Qt::RightDockWidgetArea, _dwInputPanel);
-    //   aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwPattern );
     aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwObjectBrowser );
-    aParent->addDockWidget( Qt::LeftDockWidgetArea, _dwInputPanel );
+    aParent->addDockWidget( Qt::RightDockWidgetArea, _dwInputPanel );
+
+//    aParent->tabifyDockWidget( _dwPattern, _dwObjectBrowser );
+//    aParent->tabifyDockWidget( _dwGroups, _dwPattern );
+//    aParent->tabifyDockWidget( _dwMesh, _dwGroups );
 
     aParent->tabifyDockWidget( _dwObjectBrowser, _dwPattern );
-    //  aParent->tabifyDockWidget( _dwPattern, /*_dwAssociation );
-    //  aParent->tabifyDockWidget( _dwAssociation, */_dwGroups );
     aParent->tabifyDockWidget( _dwPattern, _dwGroups );
     aParent->tabifyDockWidget( _dwGroups, _dwMesh );
 
-
 #if QT_VERSION >= 0x040500
     aParent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
 #endif
 
-
-    //   connect( _dwPattern, SIGNAL( visibilityChanged(bool) ),     this, SLOT( showPatternMenus(bool) ) );
-    // //   connect( _dwAssociation, SIGNAL( visibilityChanged(bool) ), this, SLOT( showAssociationMenus(bool) ) );
-    //   connect( _dwGroups, SIGNAL( visibilityChanged(bool) ),      this, SLOT( showGroupsMenus(bool) ) );
-    //   connect( _dwMesh, SIGNAL( visibilityChanged(bool) ),        this, SLOT( showMeshMenus(bool) ) );
-
     // popup menu on data tree view
     _patternDataTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
     connect(_patternDataTreeView,
             SIGNAL(customContextMenuRequested(const QPoint &)),
             this,
-            SLOT(treeContextMenu(const QPoint &)), Qt::UniqueConnection);
+            SLOT(treeContextMenu(const QPoint &)),
+            Qt::UniqueConnection );
 }
 
 void HEXABLOCKGUI::createActions()
@@ -1196,10 +1084,6 @@ void HEXABLOCKGUI::createActions()
             tr("Save the document"),
             0, aParent, false, this, SLOT(saveDocument()));
 
-    //  _testAct = createAction(_menuId++, tr("Test"), resMgr->loadPixmap("HEXABLOCK", tr("ICON_TEST")),
-    //                          tr("Test"),  tr("New test"),
-    //                          0, aParent, false, this, SLOT(test_association()));
-
     // Pattern Data creation
     _addVertex = createAction(_menuId++,
             tr("Create a vertex"),
@@ -1237,19 +1121,19 @@ void HEXABLOCKGUI::createActions()
             tr("Create a new vector"),
             0, aParent, false, this, SLOT(addVector()));
 
-    _addCylinder = createAction(_menuId++,
-            tr("Create a cylinder"),
-            resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
-            tr("Add Cylinder"),
-            tr("Create a new cylinder"),
-            0, aParent, false, this,  SLOT(addCylinder()));
+//    _addCylinder = createAction(_menuId++,
+//            tr("Create a cylinder"),
+//            resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_CYLINDER")),
+//            tr("Add Cylinder"),
+//            tr("Create a new cylinder"),
+//            0, aParent, false, this,  SLOT(addCylinder()));
 
-    _addPipe = createAction(_menuId++,
-            tr("Create a pipe"),
-            resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
-            tr("Add Pipe"),
-            tr("Create a new pipe"),
-            0, aParent, false, this, SLOT(addPipe()));
+//    _addPipe = createAction(_menuId++,
+//            tr("Create a pipe"),
+//            resMgr->loadPixmap("HEXABLOCK", tr("ICON_ADD_PIPE")),
+//            tr("Add Pipe"),
+//            tr("Create a new pipe"),
+//            0, aParent, false, this, SLOT(addPipe()));
 
     _makeGrid = createAction(_menuId++,
             tr("Make a grid"),
@@ -1286,10 +1170,6 @@ void HEXABLOCKGUI::createActions()
             tr("Make pipes"),
             0, aParent, false, this, SLOT(makePipes()));
 
-    // //   _makeRind     = createAction( _menuId++, tr("Make rind"), resMgr->loadPixmap( "HEXABLOCK", tr("ICON_MAKE_RIND")),
-    // //                                             tr("Make rind"),  tr("Make rind"),
-    // //                                             0, aParent, false, this, SLOT(makeRind()));
-
     _makeHemiSphere = createAction(_menuId++,
             tr("Make an hemisphere"),
             resMgr->loadPixmap("HEXABLOCK", tr("ICON_MAKE_HEMISPHERE")),
@@ -1398,10 +1278,10 @@ void HEXABLOCKGUI::createActions()
             0, aParent, false, this, SLOT(assocEdge()));
 
     _assocQuad = createAction(_menuId++,
-            tr("Make quadrangle association"),
+            tr("Make quad association"),
             resMgr->loadPixmap("HEXABLOCK", tr("ICON_QUAD_ASSOCIATION")),
-            tr("Make Quadrangle Association"),
-            tr("Make quadrangle association"),
+            tr("Make Quad Association"),
+            tr("Make quad association"),
             0, aParent, false, this, SLOT(assocQuad()));
 
     // Group
@@ -1448,76 +1328,55 @@ void HEXABLOCKGUI::createActions()
             tr("Compute mesh"),
             0, aParent, false, this, SLOT(computeMesh()));
 
-    QPixmap pix;
     _showModelInfoAct = createAction(_menuId++,
             tr("Show Model Info"),
-            QIcon(pix),
-            tr("MODEL_INFO"),//TODO: must be added in translation file
+            resMgr->loadPixmap("HEXABLOCK", tr("ICON_MODEL_INFO")),
+            tr("MODEL_INFO"),
             tr("MODEL_INFO"),
             0, aParent, false, this, SLOT(showModelInfo()));
 
     _addShapeAct = createAction(_menuId++,
             tr("Add Shape"),
-            QIcon(pix),
-            tr("ADD_SHAPE"),//TODO: must be added in translation file
+            resMgr->loadPixmap("HEXABLOCK", tr("ICON_GEOM_ASSOCIATION")),
+            tr("ADD_SHAPE"),
             tr("ADD_SHAPE"),
             0, aParent, false, this, SLOT(addShape()));
 
-    //Show actor
-//    _showAct = createAction(_menuId++,
-//            tr("Show"),
-//            QIcon(pix),
-//            tr("Show"),
-//            tr("Show the actor"),
-//            0, aParent, false, this, SLOT(showActor()));
-    //Hide actor
-//    _hideAct = createAction(_menuId++,
-//            tr("Hide"),
-//            QIcon(pix),
-//            tr("Hide"),
-//            tr("Hide the actor"),
-//            0, aParent, false, this, SLOT(hideActor()));
-
-    //Show only
-//    _showOnlyAct = createAction(_menuId++,
-//            tr("Show Only"),
-//            QIcon(pix),
-//            tr("Show Only"),
-//            tr("Show only this actor"),
-//            0, aParent, false, this, SLOT(showOnlyActor()));
-
-
-    //   _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
-    //       QAction* createAction(const int id,
-    //                             const QString& toolTip,
-    //                             const QIcon& icon,
-    //                             const QString& menu,
-    //                             const QString& status,
-    //                             const int shortCut,
-    //                             QObject* parent =0,
-    //                             bool checkable = false,
-    //                             QObject* receiver =0,
-    //                             const char* member =0);
+//   _newAct->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_N ); // --- QKeySequence::New ambiguous in SALOME
+//   QAction* createAction(const int id,
+//                         const QString& toolTip,
+//                         const QIcon& icon,
+//                         const QString& menu,
+//                         const QString& status,
+//                         const int shortCut,
+//                         QObject* parent =0,
+//                         bool checkable = false,
+//                         QObject* receiver =0,
+//                         const char* member =0);
+
+    _sep1 =  separator();
+    _sep2 =  separator();
+    _sep3 =  separator();
+    _sep4 =  separator();
 }
 
 
 void HEXABLOCKGUI::createMenus()
 {
-    int aMenuId, subMenuId;
-    aMenuId = createMenu( tr("MEN_FILE"), -1, -1 );
-    createMenu( separator(), aMenuId, -1, 10 );
-    aMenuId = createMenu( tr("HEXABLOCK"), aMenuId, -1, 10 );
-    createMenu( _newAct, aMenuId );
-    createMenu( _importAct, aMenuId );
-    createMenu( _saveAct, aMenuId );
-    //   createMenu( _testAct, aMenuId );
+    int aMenuId, subMenuId,aMenuIdMain;
 
-    //   aMenuId = createMenu( tr( "HEXABLOCK" ), -1, -1, 30 );
-    aMenuId = createMenu( tr( "Document" ), -1, -1, 30 );
-    createMenu( _newAct, aMenuId );//, 10
-    createMenu( _importAct, aMenuId );
+    aMenuIdMain = createMenu( tr("MEN_FILE"), -1, -1);
+
+    aMenuId = createMenu( tr("HEXABLOCK"), aMenuIdMain, -1, 10 );
+    createMenu( actionId(_newAct), aMenuId );
+    createMenu( actionId(_importAct), aMenuId );
     createMenu( _saveAct, aMenuId );
-    //   createMenu( _testAct, aMenuId );
+
+
+    int aMenuDocId = createMenu( tr( "Document" ), -1, -1, 30 );
+    createMenu( _newAct, aMenuDocId );//, 10
+    createMenu( _importAct, aMenuDocId );
+    createMenu( _saveAct, aMenuDocId );
 
     aMenuId = createMenu( tr("Model"), -1, -1, 30 );
     subMenuId = createMenu( tr( "Construction" ), aMenuId, -1 );
@@ -1525,39 +1384,45 @@ void HEXABLOCKGUI::createMenus()
     createMenu( _addEdge,   subMenuId );
     createMenu( _addQuad,   subMenuId );
     createMenu( _addHexa,   subMenuId );
-    createMenu( separator(), subMenuId );
+    createMenu( _sep1, subMenuId);
 
     // Pattern Builder
     createMenu( _addVector, subMenuId );
-    createMenu( _addCylinder, subMenuId );
-    createMenu( _addPipe, subMenuId );
-    createMenu( separator(), subMenuId);
+//    createMenu( _addCylinder, subMenuId );
+//    createMenu( _addPipe, subMenuId );
+
+    createMenu( _sep2, subMenuId);
+
     createMenu( _makeGrid,  subMenuId ); //Cartesian, Cylindrical, Spherical
     createMenu( _makeHemiSphere,subMenuId );
-    createMenu( separator(), subMenuId);
+
+    createMenu( _sep3, subMenuId);
+
     createMenu( _makeCylinder, subMenuId );
     createMenu( _makePipe,     subMenuId );
     createMenu( _makeCylinders,subMenuId );
     createMenu( _makePipes,    subMenuId );
-    //   createMenu( _makeRind,  aMenuId );
 
     // Pattern Data Edition
     subMenuId = createMenu( tr( "Operation" ), aMenuId, -1 );
     createMenu( _removeHexa, subMenuId );
     createMenu( _prismQuad,  subMenuId );
     createMenu( _joinQuad,   subMenuId );
-    createMenu( _merge,      subMenuId );//   createMenu( _mergeVertices,   aMenuId ); //   createMenu( _mergeEdges,   aMenuId );
+    createMenu( _merge,      subMenuId );
     createMenu( _disconnect, subMenuId );
     createMenu( _cutEdge,    subMenuId );
-    createMenu( _makeTransformation, subMenuId ); //   createMenu( _makeTranslation,   aMenuId );
+    createMenu( _makeTransformation, subMenuId );
     createMenu( _makeSymmetry,       subMenuId );
     createMenu( _performTransformation,   subMenuId );
     createMenu( _performSymmetry,         subMenuId );
     createMenu( _replaceHexa,    subMenuId );
     createMenu( _quadRevolution, subMenuId );
+    createMenu( _sep4, aMenuId );
+    createMenu( _showModelInfoAct, aMenuId );
 
     // Association
     aMenuId = createMenu( tr("Association"), -1, -1, 30 );
+    createMenu( _addShapeAct, aMenuId );
     createMenu( _assocVertex, aMenuId );
     createMenu( _assocEdge,   aMenuId );
     createMenu( _assocQuad,   aMenuId );
@@ -1576,7 +1441,7 @@ void HEXABLOCKGUI::createMenus()
 
     //show model infomation menu
     QString aRule = "$component={'HEXABLOCK'}";
-    popupMgr()->insert( _showModelInfoAct, -1, -1 ); // link the model information action to context menu
+    popupMgr()->insert( _showModelInfoAct, -1, -1 );
     popupMgr()->setRule( _showModelInfoAct, aRule);
 
     //associate shape to a document menu
@@ -1616,7 +1481,6 @@ void HEXABLOCKGUI::createMenus()
 //    popupMgr()->setRule(_showOnlyAct, aRule.arg( "" ), QtxPopupMgr::VisibleRule );
 //
 //    popupMgr()->insert( separator(), -1, -1 );
-
 }
 
 
@@ -1624,39 +1488,42 @@ void HEXABLOCKGUI::createTools()
 {
     int aToolId;
 
-    aToolId = createTool ( tr( "HexaBlock Toolbar" ) );
+    aToolId = createTool ( tr( "HexaBlock Toolbar" ), QString( "HexaBlockMain" ) );
     createTool( _newAct, aToolId );
     createTool( _importAct, aToolId );
     createTool( _saveAct, aToolId );
+    createTool( _showModelInfoAct, aToolId );
     //   createTool( _testAct, aToolId );
     //createTool( separator(), aToolId );
 
     // Pattern Data
-    aToolId = createTool ( tr( "Construction" ) );
+    aToolId = createTool ( tr( "Construction" ), QString( "HexaBlockConstruction" ) );
     createTool( _addVertex, aToolId );
     createTool( _addEdge, aToolId );
     createTool( _addQuad, aToolId );
     createTool( _addHexa, aToolId );
-    createTool( separator(), aToolId );
+
+    createTool( _sep1, aToolId );
 
     // Pattern Builder
     createTool( _addVector, aToolId );
-    createTool( _addCylinder, aToolId );
-    createTool( _addPipe, aToolId );
-    createTool( separator(), aToolId );
+//    createTool( _addCylinder, aToolId );
+//    createTool( _addPipe, aToolId );
+
+    createTool( _sep2, aToolId );
 
     createTool( _makeGrid,  aToolId );
     createTool( _makeHemiSphere,   aToolId );
-    createTool( separator(), aToolId );
+
+    createTool( _sep3, aToolId );
+
     createTool( _makeCylinder, aToolId );
     createTool( _makePipe,     aToolId );
     createTool( _makeCylinders,aToolId );
     createTool( _makePipes,    aToolId );
-    //   createTool( _makeRind,     aToolId);
-//    createTool( separator(), aToolId );
 
     // Pattern Data Edition
-    aToolId = createTool ( tr( "Operation" ) );
+    aToolId = createTool ( tr( "Operation" ), QString( "HexaBlockOperation" ) );
     createTool( _removeHexa, aToolId );
     createTool( _prismQuad,  aToolId );
     createTool( _joinQuad,   aToolId );
@@ -1669,23 +1536,21 @@ void HEXABLOCKGUI::createTools()
     createTool( _performSymmetry,         aToolId );
     createTool( _replaceHexa,    aToolId );
     createTool( _quadRevolution, aToolId );
-    //createTool( separator(), aToolId );
 
     // Association
-    aToolId = createTool ( tr( "Association" ) );
+    aToolId = createTool ( tr( "Association" ), QString( "HexaBlockAssociation" ) );
     createTool( _assocVertex, aToolId );
     createTool( _assocEdge, aToolId );
     createTool( _assocQuad, aToolId );
-    //createTool( separator(), aToolId );
+    createTool( _addShapeAct, aToolId );
 
     // Group
-    aToolId = createTool ( tr( "Group" ) );
+    aToolId = createTool ( tr( "Group" ), QString( "HexaBlockGroup" ) );
     createTool( _addGroup,    aToolId );
     createTool( _removeGroup, aToolId ); //CS_TODO
-    //createTool( separator(), aToolId );
 
     // Law
-    aToolId = createTool ( tr( "Mesh" ) );
+    aToolId = createTool ( tr( "Mesh" ), QString( "HexaBlockMesh" ) );
     createTool( _addLaw,    aToolId );
     createTool( _removeLaw, aToolId );
     createTool( _setPropagation, aToolId );
@@ -1711,6 +1576,16 @@ void HEXABLOCKGUI::showAllMenus()
     showMeshMenus( true );
 }
 
+void HEXABLOCKGUI::setAllMenusEnabled(bool enable)
+{
+    enableDocumentMenus( enable );
+    enablePatternMenus( enable );
+    enableAssociationMenus( enable );
+    enableGroupsMenus( enable );
+    enableMeshMenus( enable );
+
+    menusEnabled = enable;
+}
 
 void HEXABLOCKGUI::showDocumentMenus(bool show)
 {
@@ -1720,75 +1595,188 @@ void HEXABLOCKGUI::showDocumentMenus(bool show)
     setToolShown(_newAct, show);
     setMenuShown(_importAct, show);
     setToolShown(_importAct, show);
+    setMenuShown(_showModelInfoAct, show);
+    setToolShown(_showModelInfoAct, show);
     setMenuShown(_saveAct, show);
     setToolShown(_saveAct, show);
-    //   setMenuShown(_testAct, show);
-    //   setToolShown(_testAct, show);
 }
 
+void HEXABLOCKGUI::enableDocumentMenus(bool enable)
+{
+    _newAct->setEnabled(enable);
+//    setToolShown(_newAct, enable);
+
+    _importAct->setEnabled(enable);
+//    setToolShown(_importAct, enable);
+
+    _showModelInfoAct->setEnabled(enable);
+//    setToolShown(_showModelInfoAct, enable);
+
+    _saveAct->setEnabled(enable);
+//    setToolShown(_saveAct, enable);
+}
+
+
 void HEXABLOCKGUI::showPatternMenus(bool show)
 {
     DEBTRACE("HEXABLOCKGUI::showPatternMenus " << show);
     DEBTRACE("getCurrentModel()  " << getCurrentModel()  );
     if ( show && !getCurrentModel() ) return;
 
-    setMenuShown(_addVertex, show );//true);
+    setMenuShown(_addVertex, show );
     setToolShown(_addVertex, show);
-    setMenuShown(_addEdge,  show );//true);
+    setMenuShown(_addEdge,  show );
     setToolShown(_addEdge, show);
-    setMenuShown(_addQuad,  show );//true);
+    setMenuShown(_addQuad,  show );
     setToolShown(_addQuad, show);
-    setMenuShown(_addHexa,  show );//true);
+    setMenuShown(_addHexa,  show );
     setToolShown(_addHexa, show);
 
+    setMenuShown(_sep1, show );
+    setToolShown(_sep1, show);
 
-    setMenuShown( _addVector,  show );//true);
+    setMenuShown( _addVector,  show );
     setToolShown( _addVector, show);
-    setMenuShown( _addCylinder,  show );//true);
-    setToolShown( _addCylinder, show);
-    setMenuShown( _addPipe,  show );//true);
-    setToolShown( _addPipe, show);
-    setMenuShown( _makeGrid,  show );//true);
+//    setMenuShown( _addCylinder,  show );
+//    setToolShown( _addCylinder, show);
+//    setMenuShown( _addPipe,  show );
+//    setToolShown( _addPipe, show);
+
+    setMenuShown(_sep2, show );
+    setToolShown(_sep2, show);
+
+    setMenuShown( _makeGrid,  show );
     setToolShown( _makeGrid, show);
-    setMenuShown( _makeCylinder,  show );//true);
-    setToolShown( _makeCylinder, show);
-    setMenuShown( _makePipe,  show );//true);
+    setMenuShown( _makePipe,  show );
     setToolShown( _makePipe, show);
-    setMenuShown( _makeCylinders,  show );//true);
+
+    setMenuShown(_sep3, show );
+    setToolShown(_sep3, show);
+
+    setMenuShown( _makeCylinder,  show );
+    setToolShown( _makeCylinder, show);
+    setMenuShown( _makeCylinders,  show );
     setToolShown( _makeCylinders, show);
-    setMenuShown( _makePipes,  show );//true);
+    setMenuShown( _makePipes,  show );
     setToolShown( _makePipes, show);
-    //   setMenuShown( _makeRind,  show );//true);
-    //   setToolShown( _makeRind, show);
-    setMenuShown( _makeHemiSphere,  show );//true);
+    setMenuShown( _makeHemiSphere,  show );
     setToolShown( _makeHemiSphere, show);
 
     // Pattern Data Edition
-    setMenuShown( _removeHexa,  show );//true);
+    setMenuShown( _removeHexa,  show );
     setToolShown( _removeHexa, show);
-    setMenuShown( _prismQuad,  show );//true);
+    setMenuShown( _prismQuad,  show );
     setToolShown( _prismQuad, show);
-    setMenuShown( _joinQuad,  show );//true);
+    setMenuShown( _joinQuad,  show );
     setToolShown( _joinQuad, show);
-    setMenuShown( _merge,  show );//true);
+    setMenuShown( _merge,  show );
     setToolShown( _merge, show);
-    setMenuShown( _disconnect,  show );//true);
+    setMenuShown( _disconnect,  show );
     setToolShown( _disconnect, show);
-    setMenuShown( _cutEdge,  show );//true);
+    setMenuShown( _cutEdge,  show );
     setToolShown( _cutEdge, show);
-    setMenuShown( _makeTransformation,  show );//true);
+    setMenuShown( _makeTransformation,  show );
     setToolShown( _makeTransformation, show);
-    setMenuShown( _makeSymmetry,  show );//true);
+    setMenuShown( _makeSymmetry,  show );
     setToolShown( _makeSymmetry, show);
-    setMenuShown( _performTransformation,  show );//true);
+    setMenuShown( _performTransformation,  show );
     setToolShown( _performTransformation, show);
-    setMenuShown( _performSymmetry,  show );//true);
+    setMenuShown( _performSymmetry,  show );
     setToolShown( _performSymmetry, show);
-    setMenuShown( _replaceHexa,  show );//true);
+    setMenuShown( _replaceHexa,  show );
     setToolShown( _replaceHexa, show);
-    setMenuShown( _quadRevolution,  show );//true);
+    setMenuShown( _quadRevolution,  show );
     setToolShown( _quadRevolution, show);
 
+    setMenuShown( _sep4, show );
+    setMenuShown( _showModelInfoAct, show );
+}
+
+void HEXABLOCKGUI::enablePatternMenus(bool enable)
+{
+    if ( enable && !getCurrentModel() ) return;
+
+    _addVertex->setEnabled(enable);
+//    setToolShown(_addVertex, enable);
+
+    _addEdge->setEnabled(enable);
+//    setToolShown(_addEdge, enable);
+
+    _addQuad->setEnabled(enable);
+//    setToolShown(_addQuad, enable);
+
+    _addHexa->setEnabled(enable);
+//    setToolShown(_addHexa, enable);
+
+//    setMenuShown(_sep1, enable );
+//    setToolShown(_sep1, enable);
+
+    _addVector->setEnabled(enable);
+//    setToolShown( _addVector, enable);
+
+//    setMenuShown(_sep2, enable );
+//    setToolShown(_sep2, enable);
+
+    _makeGrid->setEnabled(enable);
+//    setToolShown( _makeGrid, enable);
+
+    _makePipe->setEnabled(enable);
+//    setToolShown( _makePipe, enable);
+
+//    setMenuShown(_sep3, enable );
+//    setToolShown(_sep3, enable);
+
+    _makeCylinder->setEnabled(enable);
+//    setToolShown( _makeCylinder, enable);
+
+    _makeCylinders->setEnabled(enable);
+//    setToolShown( _makeCylinders, enable);
+
+    _makePipes->setEnabled(enable);
+//    setToolShown( _makePipes, enable);
+
+    _makeHemiSphere->setEnabled(enable);
+//    setToolShown( _makeHemiSphere, enable);
+
+    // Pattern Data Edition
+    _removeHexa->setEnabled(enable);
+//    setToolShown( _removeHexa, enable);
+
+    _prismQuad->setEnabled(enable);
+//    setToolShown( _prismQuad, enable);
+
+    _joinQuad->setEnabled(enable);
+//    setToolShown( _joinQuad, enable);
+
+    _merge->setEnabled(enable);
+//    setToolShown( _merge, enable);
+
+    _disconnect->setEnabled(enable);
+//    setToolShown( _disconnect, enable);
+
+    _cutEdge->setEnabled(enable);
+//    setToolShown( _cutEdge, enable);
+
+    _makeTransformation->setEnabled(enable);
+//    setToolShown( _makeTransformation, enable);
+
+    _makeSymmetry->setEnabled(enable);
+//    setToolShown( _makeSymmetry, enable);
+
+    _performTransformation->setEnabled(enable);
+//    setToolShown( _performTransformation, enable);
+
+    _performSymmetry->setEnabled(enable);
+//    setToolShown( _performSymmetry, enable);
+
+    _replaceHexa->setEnabled(enable);
+//    setToolShown( _replaceHexa, enable);
+
+    _quadRevolution->setEnabled(enable);
+//    setToolShown( _quadRevolution, enable);
+
+//    setMenuShown( _sep4, enable );
+    _showModelInfoAct->setEnabled(enable);
 }
 
 
@@ -1799,165 +1787,161 @@ void HEXABLOCKGUI::showAssociationMenus(bool show)
 
     // Association Edition
     setMenuShown( _assocVertex,  show );
-    setToolShown( _assocVertex, show);
+    setToolShown( _assocVertex, show );
+
     setMenuShown( _assocEdge,  show );
-    setToolShown( _assocEdge, show);
+    setToolShown( _assocEdge, show );
+
     setMenuShown( _assocQuad,  show );
-    setToolShown( _assocQuad, show);
+    setToolShown( _assocQuad, show );
+
+    setMenuShown( _addShapeAct, show );
+    setToolShown( _addShapeAct, show );
+}
+
+void HEXABLOCKGUI::enableAssociationMenus(bool enable)
+{
+    if ( enable && !getCurrentModel() )
+        return;
+
+    // Association Edition
+     _assocVertex->setEnabled(enable);
+ //    setToolShown( _assocVertex, enable );
+
+     _assocEdge->setEnabled(enable);
+ //    setToolShown( _assocEdge, enable );
 
+     _assocQuad->setEnabled(enable);
+ //    setToolShown( _assocQuad, enable );
+
+     _addShapeAct->setEnabled(enable);
+ //    setToolShown( _addShapeAct, enable );
 }
 
 void HEXABLOCKGUI::showGroupsMenus(bool show)
 {
     DEBTRACE("HEXABLOCKGUI::showGroupsMenus" << show);
     if ( show && !getCurrentModel() ) return;
-    setMenuShown( _addGroup,  show );//true);
+    setMenuShown( _addGroup,  show );
     setToolShown( _addGroup, show);
-    setMenuShown( _removeGroup ,  show );//true);
+    setMenuShown( _removeGroup ,  show );
     setToolShown( _removeGroup , show);
 }
 
+void HEXABLOCKGUI::enableGroupsMenus(bool enable)
+{
+    if ( enable && !getCurrentModel() )
+        return;
+
+    _addGroup->setEnabled(enable);
+//    setToolShown( _addGroup, enable);
+
+    _removeGroup->setEnabled(enable);
+//    setToolShown( _removeGroup , enable);
+}
+
 void HEXABLOCKGUI::showMeshMenus(bool show)
 {
     DEBTRACE("HEXABLOCKGUI::showMeshMenus" << show);
     if ( show && !getCurrentModel() ) return;
-    setMenuShown( _addLaw,  show );//true);
+    setMenuShown( _addLaw,  show );
     setToolShown( _addLaw, show);
-    setMenuShown( _removeLaw,  show );//true);
+    setMenuShown( _removeLaw,  show );
     setToolShown( _removeLaw, show);;
-    setMenuShown( _setPropagation,  show );//true);
+    setMenuShown( _setPropagation,  show );
     setToolShown( _setPropagation, show);
-    setMenuShown( _computeMesh, show); //true);
+    setMenuShown( _computeMesh, show);
     setToolShown( _computeMesh, show);
 }
 
-void HEXABLOCKGUI::showActor()
+void HEXABLOCKGUI::enableMeshMenus(bool enable)
 {
-    //TODO: Implement the real one (this is not show only actor, but show actor)
-    VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
-    if (currentVtkGView == NULL || currentVtkGView->getViewWindow() == NULL ||
-                currentVtkGView->isEmpty() || currentVtkGView->getDocumentActor() == NULL)
+    if ( enable && !getCurrentModel() )
         return;
 
-    currentVtkGView->getViewWindow()->setFocus();
-    currentVtkGView->getViewWindow()->Display(currentVtkGView->getDocumentActor()->getIO());
-    currentVtkGView->update();
-    currentVtkGView->getViewWindow()->onFitAll();
+    _addLaw->setEnabled(enable);
+//    setToolShown( _addLaw, enable);
 
-    //update the visibility state now
-    SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
-    SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
-    if (aStudy == NULL || vman == NULL) return;
+    _removeLaw->setEnabled(enable);
+//    setToolShown( _removeLaw, enable);
 
-    Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
-    aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), GEOM::propertyName(GEOM::Visibility), 1 );
-    displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
+    _setPropagation->setEnabled(enable);
+//    setToolShown( _setPropagation, enable);
+
+    _computeMesh->setEnabled(enable);
+//    setToolShown( _computeMesh, enable);
 }
 
-void HEXABLOCKGUI::showOnlyActor()
+void HEXABLOCKGUI::showVtkActor()
 {
     VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
-    if (currentVtkGView == NULL || currentVtkGView->getViewWindow() == NULL ||
-            currentVtkGView->isEmpty() || currentVtkGView->getDocumentActor() == NULL)
+    if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
+            currentVtkGView->getDocumentActor() == NULL)
         return;
 
-    SALOME_Actor *actor = NULL;
-    vtkActor     *aVTKActor  = NULL;
-    Handle(SALOME_InteractiveObject) anIO;
+    SVTK_ViewWindow* vtkView = currentVtkGView->getViewWindow();
+    if (vtkView == NULL)
+        return;
 
-    SUIT_ViewManager* vman = currentVtkGView->getViewWindow()->getViewManager();
+    SUIT_ViewManager* vman = vtkView->getViewManager();
     SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
-    vtkRenderer *aRenderer = currentDocGView->getViewWindow()->getRenderer();
-    if (aStudy == NULL || vman == NULL || aRenderer == NULL) return;
-
-    //update the visibility state for all actors -----------
-    VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
-    vtkActorCollection *aCollection = aCopy.GetActors();
-    if (aCollection == NULL) return;
-    aCollection->InitTraversal();
-
-    while( aVTKActor = aCollection->GetNextActor() ){
-        actor = dynamic_cast<SALOME_Actor*>( aVTKActor );
-        if ( actor && actor->hasIO() ){
-            anIO = actor->getIO();
-            if( anIO->hasEntry())
-            {
-                aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), GEOM::propertyName(GEOM::Visibility), 0 );
-                displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
-            }//if
-        }//if
-    }//while
 
     //show only the current actor -----------------
-    currentVtkGView->getViewWindow()->setFocus();
-    currentVtkGView->getViewWindow()->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
+    vtkView->setFocus();
+    //    vtkView->DisplayOnly(currentVtkGView->getDocumentActor()->getIO());
+    Document_Actor *lastDocActor;
+    if (lastVtkDocGView != NULL)
+    {
+        lastDocActor = lastVtkDocGView->getDocumentActor();
+        Handle(SALOME_InteractiveObject) lastActorIO = lastDocActor->getIO();
+        if (!lastActorIO.IsNull() && lastActorIO->hasEntry())
+        {
+            vtkView->Erase(lastActorIO);
+            aStudy->setObjectProperty(vman->getId(), lastActorIO->getEntry(),  "Visibility", 0 );
+            displayer()->setVisibilityState(lastActorIO->getEntry(), Qtx::HiddenState);
+        }
+    }
     currentVtkGView->update();
-    currentVtkGView->getViewWindow()->onFitAll();
-    anIO = currentVtkGView->getDocumentActor()->getIO();
-    aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), GEOM::propertyName(GEOM::Visibility), 1 );
-    displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
-
-
-    //showOnly in occ viewer -------------
+    Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
+    if (!anIO.IsNull() && anIO->hasEntry())
+    {
+        vtkView->Display(anIO);
+        aStudy->setObjectProperty(vman->getId(), anIO->getEntry(),  "Visibility", 1 );
+        displayer()->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
+    }
+    vtkView->onFitAll();
+}
 
-    OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
-    DocumentModel* docModel = currentVtkGView->getDocumentModel();
-    if (occView == NULL || docModel == NULL) return;
+void HEXABLOCKGUI::showOccActor()
+{
+    if (currentOccGView == NULL)
+        return;
+    OCCViewer_ViewWindow* occView = currentOccGView->getViewWindow();
+    if (occView == NULL)
+        return;
     SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
-    if (vf == NULL) return;
-
-    GEOM_Displayer*  disp = geomBaseHelper->getDisplayer();
-    if (disp == NULL)
-    {
-        MESSAGE("Displayer IS NULL");
+    if (vf == NULL)
         return;
-    }
-    _PTR(Study) aStudyDS = aStudy->studyDS();
-    if (aStudyDS == NULL) return;
 
-    //erase all shapes from the occ viewer
-    disp->EraseAll(false, true, vf);
+    if (lastOccPrs != NULL)
+        vf->Erase(lastOccPrs);
+    currentOccGView->globalSelection();
+    SOCC_Prs* prs = getOccPrs(currentDocGView);
+    currentOccGView->setPrs(prs);
+    vf->Display(prs);
+    vf->Repaint();
+    occView->onFitAll();
+}
 
-    //show only the shapes of the document
-    QList<QString> entries = docModel->getShapesEntries();
+void HEXABLOCKGUI::hideVtkActor()
+{
+    VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
+    if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
+        currentVtkGView->getViewWindow() == NULL ||
+        currentVtkGView->getDocumentActor() == NULL) return;
 
-    CORBA::Object_var     aCorbaObj = CORBA::Object::_nil();
-    GEOM::GEOM_Object_var aGeomObj  = GEOM::GEOM_Object::_nil();
-    HEXABLOCKGUI::geomBaseHelper->erasePreview(true);
-
-    foreach(const QString& entry, entries)
-    {
-        if (!entry.isEmpty())
-        {
-            _PTR(SObject) aSChild = aStudyDS->FindObjectID( entry.toStdString() );
-            aCorbaObj = corbaObj( aSChild );
-            aGeomObj = GEOM::GEOM_Object::_narrow( aCorbaObj );
-            if ( !CORBA::is_nil(aGeomObj) ){
-                geomBaseHelper->display(aGeomObj._retn());
-//                QString objIOR = GEOMBase::GetIORFromObject( aGeomObj._retn() );
-//                Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIORinGEOMAISShape( objIOR );//, true )
-//                if ( !aSh.IsNull() )
-//                    disp->Display(aSh->getIO(), true, vf);
-//                else
-//                {
-//                    MESSAGE("aSh IS NULL");
-//                }
-            }
-        }
-    }
-    occView->onResetView ();
-}
-
-void HEXABLOCKGUI::hideActor()
-{
-    VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
-    if (currentVtkGView == NULL || currentVtkGView->isEmpty() ||
-          currentVtkGView->getViewWindow() == NULL ||
-          currentVtkGView->getDocumentActor() == NULL) return;
-
-//    currentVtkGView->getViewWindow()->setFocus();
-    currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
-    currentVtkGView->getViewWindow()->onFitAll();
+    currentVtkGView->getViewWindow()->Erase(currentVtkGView->getDocumentActor()->getIO());
+    currentVtkGView->getViewWindow()->onResetView();
 
     //update the visibility state now
     SalomeApp_Study* aStudy = HEXABLOCKGUI::activeStudy();
@@ -1965,18 +1949,41 @@ void HEXABLOCKGUI::hideActor()
     if (aStudy == NULL || vman == NULL) return;
 
     Handle(SALOME_InteractiveObject) anIO = currentVtkGView->getDocumentActor()->getIO();
-    aStudy->setObjectProperty(vman->getId(), anIO->getEntry(), GEOM::propertyName(GEOM::Visibility), 0 );
+    aStudy->setObjectProperty(vman->getId(), anIO->getEntry(),  "Visibility", 0 );
     displayer()->setVisibilityState(anIO->getEntry(), Qtx::HiddenState);
 }
 
+void HEXABLOCKGUI::hideOccActor()
+{
+    OCCViewer_ViewWindow* occView = currentOccGView == NULL ? NULL : currentOccGView->getViewWindow();
+    VtkDocumentGraphicView* currentVtkGView = getCurrentVtkGraphicView();
+    DocumentModel* docModel = (currentVtkGView == NULL ? NULL : currentVtkGView->getDocumentModel());
+    if (occView == NULL || docModel == NULL)
+        return;
+    SALOME_View* vf = dynamic_cast<SALOME_View*>(occView->getViewManager()->getViewModel());
+    if (vf == NULL)
+        return;
+
+    SOCC_Prs* currentOccPrs = getOccPrs(currentDocGView);
+    if (currentOccPrs != NULL)
+        vf->Erase(currentOccPrs);
+    vf->Repaint();
+    occView->onResetView();
+}
+
+void HEXABLOCKGUI::showOnlyActor()
+{
+    showVtkActor();
+    showOccActor();
+}
 
-VtkDocumentGraphicView* HEXABLOCKGUI::getCurrentVtkGraphicView()
+void HEXABLOCKGUI::hideActor()
 {
-//    VtkDocumentGraphicView* gv = graphicViewsHandler->getDocumentGraphicView(currentVtkView);
-//    return graphicViewsHandler->getDocumentGraphicView(currentVtkView);
-    return currentDocGView;
+    hideVtkActor();
+    hideOccActor();
 }
 
+
 void HEXABLOCKGUI::showDockWidgets(bool isVisible)
 {
     DEBTRACE("HEXABLOCKGUI::showDockWidgets " << isVisible);
@@ -1987,480 +1994,219 @@ void HEXABLOCKGUI::showDockWidgets(bool isVisible)
     if (_dwPattern) _dwPattern->setVisible(isVisible);
     if (_dwPattern) _dwPattern->toggleViewAction()->setVisible(isVisible);
 
-    //   if (_dwAssociation) _dwAssociation->setVisible(isVisible);
-    //   if (_dwAssociation) _dwAssociation->toggleViewAction()->setVisible(isVisible);
-
     if (_dwMesh) _dwMesh->setVisible(isVisible);
     if (_dwMesh) _dwMesh->toggleViewAction()->setVisible(isVisible);
 
     if (_dwGroups) _dwGroups->setVisible(isVisible);
     if (_dwGroups) _dwGroups->toggleViewAction()->setVisible(isVisible);
+}
+
 
-//    if (_dwInputPanel) _dwInputPanel->setVisible(isVisible);
-//    if (_dwInputPanel) _dwInputPanel->toggleViewAction()->setVisible(isVisible);
+//clear all used dialogs by the current model
+void HEXABLOCKGUI::clearDialogs()
+{
+    std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
+                                              fin   (currentModelDialogs.end());
+    for(;debut!=fin;++debut) (*debut)->clear();
 
-//    QWidget* w = _dwInputPanel->widget();
-//    if (w) w->show();
-    //   if ( isVisible ) _dwObjectBrowser->raise();//_dwPattern->raise();
+    currentModelDialogs.clear(); //empty the used dialogs list
 }
 
+HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
+{
+    if (!gViewDlgBox.contains(dgview)) return NULL;
+    return gViewDlgBox[dgview];
+}
 
-// void HEXABLOCKGUI::raiseStacked()
-// {
-// //   if (_dwStacked) _dwStacked->raise();
-// }
+void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
+{
+   if (dgview == NULL) return;
 
+   switchOffGraphicView(dgview, false); //to avoid double connect
 
-void HEXABLOCKGUI::testDocument()
-{
-    //CS_TEST
-    // ----------
-    //   QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
-    //   QStandardItem *myItem =  new QStandardItem("MyItem");
-    //   parentItem->appendRow(myItem);
-    // //   ----------
-    //   QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
-    //   QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
-    //   QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
-    //   QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
-    //   QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
-    //   QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
-    //   QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
-    //   QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
-    // //
-    // //
-    //   QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
-    //   QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
-    //   QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
-    //   QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
-    //   QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
-    //   QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
-    //
-    //   QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
-    //   QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
-    //   QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
-    //   QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
-    //
+   //connect signals
+   connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
+         dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
+   connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
+         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
+//   connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
+//         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
+   connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
+            this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
+   connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
+         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
+   connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
+         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
 
+   showAllMenus();
+}
 
+void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
+{
+   if (dgview == NULL) return;
 
-    // //   QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
-    // //   QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
-    // //   QModelIndex vz    = getCurrentModel()->addVector (0,0,1);
-    // //   QModelIndex vx    = getCurrentModel()->addVector (1,0,0);
-    // //
-    // //   int nr  = 4;
-    // //   int nri = 3;
-    // //   int nre = nr;
-    // //   int na = 9;
-    // //   int nl = 5;
-    // //
-    // //   QModelIndex  cyl  = getCurrentModel()->addCylinder   (orig1, vz, nr, nl);
-    // //   QModelIndex  pipe = getCurrentModel()->addPipe       (orig2, vz, nri, nre, nl);
-    // //
-    // //   getCurrentModel()->makeCylinder (cyl,  vx, nr, na, nl);
-    // //   getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
+   //disconnect signals
+   disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
+         dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
+   disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
+         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
+//   disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
+//         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
+   disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
+            this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
+   disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
+         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
+   disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
+         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
+
+   if (saveCurrentDlg)
+       gViewDlgBox[dgview] = currentDialog;
 
+   //close opened dialog
+   if (currentDialog != NULL) currentDialog->close();
+//   if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
 
+   initialMenus();
 
-    //   newMesh( "toto", 3, "FactoryServer");
-    // newMesh
 }
 
-void HEXABLOCKGUI::test_make_cart_grid()
+void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
 {
-    QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
-    QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
-    QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
-    QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
-    QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
-    QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
+    DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
 
-    QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
-    QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
+    if (dgview == NULL)
+    {
+        MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
+        return;
+    }
 
-    //int dr = 1;
-    //int dl = 1;
-    //int nr = 2;
-    //int nl = 3;
+    //switch off the current document graphic view (disconnect signals...)
+    if (currentDocGView != NULL)
+    {
+        //Hide current actor
+        hideActor();
+        switchOffGraphicView(currentDocGView);
+    }
 
-    // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
-    // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
-    // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
-    // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
-    // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
-    // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
+    //clear the dialogs used by the current model so they can be used by the new model
+    if (currentDocGView != dgview) clearDialogs();
 
-}
+    _patternDataTreeView->setModel(dgview->getPatternDataModel());
+//    _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
+    _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
+    _groupsTreeView->setModel(dgview->getGroupsModel());
+    _meshTreeView->setModel(dgview->getMeshModel());
 
+    _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
+    _patternDataTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
 
-void HEXABLOCKGUI::test_make_elmts_transform()
-{
+//    _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
+//    _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
 
-    int size_x = 1;
-    int size_y = 1;
-    int size_z = 2;
+    _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
+    _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
 
-    QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
-    QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
+    _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
+    _groupsTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
 
-    QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
-    // orig.setScalar(2);
+    _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
+    _meshTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
 
-    // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
-    // getCurrentModel()->saveVtk(file_name)
 
-    QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
-    QModelIndex grid2  = getCurrentModel()->makeTranslation(grid, devant);
+    // = * init occ view * =
+    if (currentOccGView != NULL && currentOccGView->getViewWindow() == NULL)
+    {
+        currentOccGView->setViewWindow(graphicViewsHandler->createOccWindow());
+        currentOccGView->getViewWindow()->installEventFilter(this);
+    }
+    // ==
+
 
-    // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
-    // getCurrentModel()->saveVtk(file_name)
+    // = * init vtk view * =
+    if (currentDocGView != NULL)
+    {
+        if (currentDocGView->getViewWindow() != NULL)
+            dgview->setViewWindow(currentDocGView->getViewWindow());
+        else
+        {
+            dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
+            dgview->getViewWindow()->installEventFilter(this);
+        }
+    }
 
-    QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
+    // ==
 
+    switchOnGraphicView(dgview);
 
-    // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
-    // getCurrentModel()->saveVtk(file_name);
+    if (currentDocGView != NULL)
+    {
+        lastVtkDocGView = currentDocGView;
+        lastOccPrs = getOccPrs(currentDocGView);
+    }
+    else
+    {
+        lastVtkDocGView = dgview;
+        lastOccPrs = getOccPrs(dgview);
+    }
 
+    currentDocGView = dgview;
+    showOnlyActor();
+    currentDocGView->getDocumentModel()->refresh();
+//    _dwPattern->setWindowTitle(currentDocGView->getDocumentModel()->getName());
+    showAllMenus();
+    if (!menusEnabled)
+        setAllMenusEnabled(true);
+}
 
-    // print "...test make elements by transforming elements OK"
+DocumentModel* HEXABLOCKGUI::getCurrentModel()
+{
+    if (currentDocGView == NULL) return NULL;
+    return currentDocGView->getDocumentModel();
 }
 
 
-void HEXABLOCKGUI::test()
+HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
 {
-    DEBTRACE("HEXABLOCKGUI::test");
-    VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
-    if (currentDGView == NULL) return;
-    currentDGView->update();
+    SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+    if (anApp == NULL) return UNKNOWN;
+    SUIT_ViewManager* activeVm = anApp->activeViewManager();
+    if (activeVm == NULL) return UNKNOWN;
+
+   QString vmType = activeVm->getType();
+   if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
+       return VTK;
+   else if ( vmType == OCCViewer_Viewer::Type() )
+       return OCC;
 
+   return UNKNOWN;
 }
 
-void HEXABLOCKGUI::test_association()
+HEXABLOCKGUI* HEXABLOCKGUI::getInstance()
 {
-    DEBTRACE("HEXABLOCKGUI::test_association");
-    newDocument();
-
-    QModelIndex v0, v1, v2, v3, e0, e1, q0;
+    SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+    if (anApp == NULL)
+        return NULL;
 
-    DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
-    DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
-    DocumentModel::GeomObj q0AssocA, q0AssocB;
+    return  dynamic_cast<HEXABLOCKGUI*>(anApp->activeModule());
+}
 
-    DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
-    QList<DocumentModel::GeomObj> e1Assocs_test;
-    DocumentModel::GeomObj q0Assoc_test;
+pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
+{
+    // Create Document from HEXABLOCK ENGINE
+    // WARNING : IN HEXABLOCK component,  GUI and ENGINE share the same process
+    // HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default"); // Perime  Hexa6
 
-    v0 = getCurrentModel()->addVertex(0, 0, 0);
-    v1 = getCurrentModel()->addVertex(1, 0, 0);
-    v2 = getCurrentModel()->addVertex(1, 1, 0);
-    v3 = getCurrentModel()->addVertex(0, 1, 0);
-    e0  = getCurrentModel()->addEdgeVertices(v0, v1);
-    e1  = getCurrentModel()->addEdgeVertices(v1, v2);
-    q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
+    // looking doc impl ( c++ )
+    // ^Hexa6 Document_impl* dServant = DownCast<Document_impl*>( docIn );
+    // ^Hexa6 ASSERT( dServant );
+    // ^Hexa6 if ( dServant)
+        // ^Hexa6 doc = dServant->GetImpl();
 
-
-    // >>> face3.GetEntry()'0:1:4'
-    // >>> e1.GetEntry()'0:1:8'
-    // >>> e2.GetEntry()'0:1:9'
-    // >>> e3.GetEntry()'0:1:10'
-    // >>> e4.GetEntry()'0:1:11'
-    // >>> v1.GetEntry()'0:1:12'
-    // >>> v2.GetEntry()'0:1:13'
-    // >>> v3.GetEntry()'0:1:14'
-    // >>> v4.GetEntry()'0:1:15'
-
-
-    //   v0Assoc.name  = "geomV0";
-    //   v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
-    //   v0Assoc.brep  = "brepV0";
-    //   v1Assoc.name  = "geomV1";
-    //   v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
-    //   v1Assoc.brep  = "brepV1";
-    //   v2Assoc.name  = "geomV2";
-    //   v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
-    //   v2Assoc.brep  = "brepV2";
-    //   v3Assoc.name  = "geomV3";
-    //   v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
-    //   v3Assoc.brep  = "brepV3";
-    //
-    //
-    //
-    //   e0AssocA.name   = "geomE0a";
-    //   e0AssocA.entry  = "0:1:1:1:3:5";//"0:1:8";
-    //   e0AssocA.brep  = "brepE0a";
-    //   e0AssocA.start  = 0.10;
-    //   e0AssocA.end    = 0.95;
-    //
-    //
-    //
-    //   e1AssocA.name   = "geomE1a";
-    //   e1AssocA.entry  = "0:1:1:1:3:2";//"0:1:8";
-    //   e1AssocA.brep  = "brepE1a";
-    //   e1AssocA.start  = 0.12;
-    //   e1AssocA.end    = 0.89;
-    //   e1AssocB.name   = "geomE1b";
-    //   e1AssocB.entry  = "0:1:1:1:3:3";//"0:1:9";
-    //   e1AssocB.brep  = "brepE1b";
-    //   e1AssocB.start  = 0.20;
-    //   e1AssocB.end    = 0.80;
-    //   e1AssocC.name   = "geomE1c";
-    //   e1AssocC.entry  = "0:1:1:1:3:4";//"0:1:10";
-    //   e1AssocC.brep  = "brepE1c";
-    //   e1AssocC.start  = 0.16;
-    //   e1AssocC.end    = 0.96;
-    //
-    //   q0AssocA.name   = "geomQuad";
-    //   q0AssocA.entry  = "0:1:1:1:3";
-    //   q0AssocA.brep   = "brepq0";
-    //
-    //   q0AssocB.name   = "geomQuad";
-    //   q0AssocB.entry  = "0:1:1:1:4";
-    //   q0AssocB.brep   = "brepq0";
-    //
-    //   getCurrentModel()->addAssociation( v0, v0Assoc );
-    //   getCurrentModel()->addAssociation( v1, v1Assoc );
-    //   getCurrentModel()->addAssociation( v2, v2Assoc );
-    //   getCurrentModel()->addAssociation( v3, v3Assoc );
-    //
-    //
-    //   getCurrentModel()->addAssociation( e0, e0AssocA );
-    //
-    //   getCurrentModel()->addAssociation( e1, e1AssocA );
-    //   getCurrentModel()->addAssociation( e1, e1AssocB );
-    //   getCurrentModel()->addAssociation( e1, e1AssocC );
-    //
-    //   getCurrentModel()->addAssociation( q0, q0AssocA );
-    //   getCurrentModel()->addAssociation( q0, q0AssocB );
-
-
-
-
-
-    //   v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
-    //   v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
-    //   v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
-    //   v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
-    //   ASSERT( v0Assoc.name == v0Assoc_test.name );
-    //   ASSERT( v1Assoc.name == v1Assoc_test.name );
-    //   ASSERT( v2Assoc.name == v2Assoc_test.name );
-    //   ASSERT( v3Assoc.name == v3Assoc_test.name );
-    //   ASSERT( v0Assoc.entry == v0Assoc_test.entry );
-    //   ASSERT( v1Assoc.entry == v1Assoc_test.entry );
-    //   ASSERT( v2Assoc.entry == v2Assoc_test.entry );
-    //   ASSERT( v3Assoc.entry == v3Assoc_test.entry );
-    //
-    //
-    //   e1Assocs_test = getCurrentModel()->getAssociations( e1 );
-    //   ASSERT( e1Assocs_test[0].name == e1AssocA.name );
-    //   ASSERT( e1Assocs_test[1].name == e1AssocB.name );
-    //   ASSERT( e1Assocs_test[2].name == e1AssocC.name );
-    //   ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
-    //   ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
-    //   ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
-    //   ASSERT( e1Assocs_test[0].start == e1AssocA.start );
-    //   ASSERT( e1Assocs_test[1].start == e1AssocB.start );
-    //   ASSERT( e1Assocs_test[2].start == e1AssocC.start );
-    //   ASSERT( e1Assocs_test[0].end == e1AssocA.end );
-    //   ASSERT( e1Assocs_test[1].end == e1AssocB.end );
-    //   ASSERT( e1Assocs_test[2].end == e1AssocC.end );
-    //
-    //   q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
-    //   ASSERT( q0Assoc_test.name  == q0Assoc.name );
-    //   ASSERT( q0Assoc_test.entry == q0Assoc.entry );
-
-
-    DEBTRACE("HEXABLOCKGUI::test_association fin");
-}
-
-//clear all used dialogs by the current model
-void HEXABLOCKGUI::clearDialogs()
-{
-    std::set<HexaBaseDialog*>::const_iterator debut (currentModelDialogs.begin()),
-                                  fin   (currentModelDialogs.end());
-    for(;debut!=fin;++debut) (*debut)->clear();
-
-    if (_vertexAssocDiag != NULL) _vertexAssocDiag->clear(); //not a subclass of HexaBaseDialog
-
-    currentModelDialogs.clear(); //empty the used dialogs list
-}
-
-HexaBaseDialog* HEXABLOCKGUI::getDlgBox(VtkDocumentGraphicView* dgview)
-{
-    if (!gViewDlgBox.contains(dgview)) return NULL;
-    return gViewDlgBox[dgview];
-}
-
-void HEXABLOCKGUI::switchOnGraphicView(VtkDocumentGraphicView* dgview)
-{
-   if (dgview == NULL) return;
-
-   switchOffGraphicView(dgview, false); //to avoid double connect
-
-   //connect signals
-   connect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
-         dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ), Qt::UniqueConnection );
-   connect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
-         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
-   connect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
-         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
-   connect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
-            this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
-   connect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
-         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
-   connect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
-         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
-
-   if (currentDocGView != NULL)
-   {
-       if (currentDocGView->getViewWindow() != NULL)
-           dgview->setViewWindow(currentDocGView->getViewWindow());
-       else
-       {
-           dgview->setViewWindow(graphicViewsHandler->createVtkWindow());
-           dgview->getViewWindow()->installEventFilter(this);
-       }
-   }
-   dgview->getViewWindow()->setFocus();
-
-   showAllMenus();
-   //_showDialogBox(getDlgBox(dgview));
-}
-
-void HEXABLOCKGUI::switchOffGraphicView(VtkDocumentGraphicView* dgview, bool saveCurrentDlg)
-{
-   if (dgview == NULL) return;
-
-   //disconnect signals
-   disconnect( selectionMgr(), SIGNAL( currentSelectionChanged() ),
-         dgview->getPatternDataSelectionModel(), SLOT( salomeSelectionChanged() ) );
-   disconnect( dgview->getPatternDataSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
-         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
-   disconnect( dgview->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
-         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
-   disconnect( dgview->getPatternGeomSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
-            this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
-   disconnect( dgview->getGroupsSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
-         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
-   disconnect( dgview->getMeshSelectionModel(), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
-         this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
-
-   if (saveCurrentDlg)
-       gViewDlgBox[dgview] = currentDialog;
-
-   //close opened dialog
-   if (currentDialog != NULL) currentDialog->close();
-   if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
-
-   initialMenus();
-
-}
-
-void HEXABLOCKGUI::switchModel(VtkDocumentGraphicView* dgview)
-{
-    DEBTRACE("HEXABLOCKGUI::switchModel " << dgview);
-
-    if (dgview == NULL /*|| dgview == currentDocGView*/ ) //Need to switch?
-    {
-        MESSAGE("HEXABLOCKGUI::switchModel : no need to switch!");
-        return;
-    }
-
-    //switch off the current document graphic view (disconnect signals...)
-    if (currentDocGView != NULL)
-    {
-        //Hide current actor
-        hideActor();
-        switchOffGraphicView(currentDocGView);
-    }
-
-    //clear the dialogs used by the current model so they can be used by the new model
-    if (currentDocGView != dgview) clearDialogs();
-
-
-    _patternDataTreeView->setModel(dgview->getPatternDataModel());
-    _patternBuilderTreeView->setModel(dgview->getPatternBuilderModel());
-    _patternGeomTreeView->setModel(dgview->getPatternGeomModel());
-    _groupsTreeView->setModel(dgview->getGroupsModel());
-    _meshTreeView->setModel(dgview->getMeshModel());
-
-    _patternDataTreeView->setSelectionModel(dgview->getPatternDataSelectionModel());
-    _patternDataTreeView->setEditTriggers(/*QAbstractItemView::EditKeyPressed*/QAbstractItemView::AllEditTriggers /*QAbstractItemView::NoEditTriggers*/);
-
-    _patternBuilderTreeView->setSelectionModel(dgview->getPatternBuilderSelectionModel());
-    _patternBuilderTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
-
-    _patternGeomTreeView->setSelectionModel(dgview->getPatternGeomSelectionModel());
-    _patternGeomTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
-
-    _groupsTreeView->setSelectionModel(dgview->getGroupsSelectionModel());
-    _groupsTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
-
-    _meshTreeView->setSelectionModel(dgview->getMeshSelectionModel());
-    _meshTreeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
-
-    //switch on this graphic view (connect signals...)
-    switchOnGraphicView(dgview);
-    currentDocGView = dgview;
-    if (_vertexAssocDiag != NULL)
-    {
-        _vertexAssocDiag->setDocumentModel(getCurrentModel());
-        _vertexAssocDiag->setPatternDataSelectionModel(currentDocGView->getPatternDataSelectionModel());
-    }
-    currentDocGView->getViewWindow()->setFocus();
-    showOnlyActor();
-    currentDocGView->getDocumentModel()->refresh();
-    showAllMenus();
-}
-
-// void detruitDialog() {
-   // currentDialog = NULL;
-
-   // if (_sdjfgjh) delete _sdjfgjh;
-
-
-// }
-
-
-
-DocumentModel* HEXABLOCKGUI::getCurrentModel()
-{
-    if (currentDocGView == NULL) return NULL;
-    return currentDocGView->getDocumentModel();
-}
-
-
-HEXABLOCKGUI::ViewType HEXABLOCKGUI::getActiveViewType()
-{
-    SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
-    if (anApp == NULL) return UNKNOWN;
-    SUIT_ViewManager* activeVm = anApp->activeViewManager();
-    if (activeVm == NULL) return UNKNOWN;
-
-   QString vmType = activeVm->getType();
-   if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
-       return VTK;
-   else if ( vmType == OCCViewer_Viewer::Type() )
-       return OCC;
-
-   return UNKNOWN;
-}
-
-pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
-{
-    // Create Document from HEXABLOCK ENGINE
-    // WARNING : IN HEXABLOCK component,  GUI and ENGINE share the same process
-    HEXABLOCK_ORB::Document_ptr docIn = _hexaEngine->addDocument("default");
-
-    HEXA_NS::Document* doc = NULL;
-    QString            docEntry;
-
-    // looking doc impl ( c++ )
-    Document_impl* dServant = DownCast<Document_impl*>( docIn );
-    ASSERT( dServant );
-    if ( dServant) doc = dServant->GetImpl();
+    HEXA_NS::Document* doc = hexa_root->addDocument ("default");
+    QString docEntry = addDocInStudy (doc);
 
     // looking for docEntry
+    /* ****************************************************************
     if ( !CORBA::is_nil(docIn) ){
         CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( docIn );
         QString docIOR = anIOR.in();
@@ -2471,6 +2217,7 @@ pair <QString, HEXA_NS::Document*> HEXABLOCKGUI::newHexaDocument()
                 docEntry = SO->GetID().c_str();
         }
     }
+       **************************************************************** */
     DEBTRACE("HEXABLOCKGUI::newHexaDocument docEntry "<<docEntry.toStdString());
 
     return make_pair (docEntry, doc);
@@ -2481,8 +2228,6 @@ void HEXABLOCKGUI::newDocument()
 {
     DEBTRACE("HEXABLOCKGUI::newDocument");
 
-//    MESSAGE("===== NEW DOCUMENT: je commence ! " << jepeux);
-
     createSComponent();
     QMainWindow *aParent = application()->desktop();
     QWidget *central = aParent->centralWidget();
@@ -2508,7 +2253,7 @@ void HEXABLOCKGUI::newDocument()
     // Create Document from HEXABLOCK ENGINE
     pair <QString, HEXA_NS::Document*> docEntry_Doc ( newHexaDocument() );
 
-    VtkDocumentGraphicView* newGraphicView;
+    VtkDocumentGraphicView* newGraphicView = NULL;
     //One document at a time
     if (currentDocGView != NULL)
     {
@@ -2544,19 +2289,8 @@ void HEXABLOCKGUI::newDocument()
     docs[docEntry_Doc.first] = newGraphicView;
     switchModel(newGraphicView); //select the corresponding document in the browser instead
 
-//    showAllMenus();
-//    _dwPattern->raise();
-
-//    _PTR(Study)            aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
-//    _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
-//    SalomeApp_DataModel::updateTree (aComponent, HEXABLOCKGUI::activeStudy());
     getApp()->updateObjectBrowser();
     showAllMenus();
-//    jepeux = true;
-//    for (double i=0; i < 10000000000000000; ++i);
-
-//    MESSAGE("===== NEW DOCUMENT: j'ai fini!");
-
 }
 
 
@@ -2589,43 +2323,34 @@ void HEXABLOCKGUI::loadDocument( const QString &inFile )
     } else
         selectedFile = inFile;
 
-    if (! selectedFile.isEmpty())
+    if (selectedFile.isEmpty())
+        return;
+
+    //we create a new document if necessary
+    if (currentDocGView == NULL)
+        //Need a new document
+        newDocument();
+    else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
     {
-        //we create a new document if necessary
-        if (currentDocGView == NULL)
-            //Need a new document
-           newDocument();
-        else if (currentDocGView->getViewWindow() == NULL) //there's a document without a view
-        {
-           currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
-           currentDocGView->getViewWindow()->installEventFilter(this);
-        }
+        currentDocGView->setViewWindow(graphicViewsHandler->createVtkWindow());
+        currentDocGView->getViewWindow()->installEventFilter(this);
+    }
 
-        if (!currentDocGView->isEmpty())
-            //we can only have one document for a graphic view
-            newDocument();
+    if (!currentDocGView->isEmpty())
+        //we can only have one document for a graphic view
+        newDocument();
 
-        //we load the selected file in the current graphic view
-        currentDocGView->loadDocument(selectedFile);
-        DocumentModel* currentModel = getCurrentModel();
-        renameObject( currentModel->documentEntry(), currentModel->getName() );
+    //we load the selected file in the current graphic view
+    currentDocGView->loadDocument(selectedFile);
+    DocumentModel* currentModel = getCurrentModel();
+    renameObject( currentModel->documentEntry(), currentModel->getName() );
 
-//        _PTR(Study)            aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
-//        _PTR(SComponent) aComponent = aStudy->FindComponent("HEXABLOCK");
-//        SalomeApp_DataModel::updateTree (aComponent, HEXABLOCKGUI::activeStudy());
-        getApp()->updateObjectBrowser();
-    }
     showOnlyActor();
 }
 
 void HEXABLOCKGUI::saveDocument()
 {
     QMainWindow *aParent = application()->desktop();
-//    QString anInitialPath = "";
-//    if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
-//        anInitialPath = QDir::currentPath();
-    //   QString aMeshName = anIO->getName();
-
 
     QString aDocName = "document", aFilename;
     QStringList filter;
@@ -2658,19 +2383,7 @@ void HEXABLOCKGUI::saveDocument()
 
 void HEXABLOCKGUI::slot_modelChanged(const QModelIndex &topLeft, const QModelIndex  &bottomRight)
 {
-    //std::cout << "HHHHHHHHHHHHHHHHHH  Model changed." << std::endl;
-    //std::cout << "HHHHHHHHHHHHHHHHHH  slot_modelChanged topLeft -> " << topLeft.data().toString().toStdString()<<std::endl;
-    //std::cout << "HHHHHHHHHHHHHHHHHH  slot_modelChanged bottomRight ->" << bottomRight.data().toString().toStdString()<<std::endl;
-
     _patternDataTreeView->openPersistentEditor( topLeft );
-
-    //   // Make the combo boxes always displayed.
-    //   for ( int i = 0; i < getCurrentModel()->rowCount(); ++i )
-    //     {
-    //       QModelIndex ind = getCurrentModel()->index(i);
-    //     _patternDataTreeView->openPersistentEditor( ind );
-    //     std::cout << "ind" << ind.data() << std::endl;
-    //     }
 }
 
 void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
@@ -2678,36 +2391,143 @@ void HEXABLOCKGUI::_showDialogBox( HexaBaseDialog* diag )
     if (diag == NULL || _dwInputPanel == NULL ||
             getCurrentVtkGraphicView() == NULL) return;
 
-    //mark this dialog as used by the current model
-    currentModelDialogs.insert(diag);
+    //mark this dialog as used by the current model
+    currentModelDialogs.insert(diag);
+
+    //close the current dialog box info
+//    if (_treeViewDelegate != NULL)
+//        _treeViewDelegate->closeDialog();
+
+//    if (_dwInputPanel->widget())
+//        _dwInputPanel->widget()->close();
+
+    //Temporary for debugging EdgeAssoc Faked InfoDialog
+    if (diag == _edgeAssocDiag)
+        diag->debugEdgeAssoc = true;
+    else
+        diag->debugEdgeAssoc = false;
+
+    if (diag == _vertexAssocDiag || diag ==  _edgeAssocDiag ||
+               diag ==  _quadAssocDiag || diag == _addShapeDiag)
+        assocInProgress = true;
+    else
+        assocInProgress = false;
+
+    //show the dialog box in the dockwidget
+    diag->resetSizeAndShow(_dwInputPanel);
+
+    //clear the current selections
+    selectionMgr()->clearSelected();
+
+    currentDialog = diag;
+    diag->setFocus();
+
+    if (currentDocGView != NULL)
+        currentDocGView->getPatternDataSelectionModel()->setInfoMode(false);
+}
+
+void HEXABLOCKGUI::showVertexInfoDialog(HEXA_NS::Vertex* vertex)
+{
+    if (vertex == NULL || _dwInputPanel == NULL)
+        return;
+
+    if (_vertexInfoDialog == NULL)
+        _vertexInfoDialog = new VertexDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
+
+    _vertexInfoDialog->setValue(vertex);
+    _vertexInfoDialog->resetSizeAndShow(_dwInputPanel);
+    currentDialog = _vertexInfoDialog;
+}
+
+void HEXABLOCKGUI::showEdgeInfoDialog(HEXA_NS::Edge* edge)
+{
+    if (edge == NULL || _dwInputPanel == NULL)
+        return;
+
+    if (_edgeInfoDialog == NULL)
+        _edgeInfoDialog = new EdgeDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
+
+    _edgeInfoDialog->setValue(edge);
+    _edgeInfoDialog->resetSizeAndShow(_dwInputPanel);
+    currentDialog = _edgeInfoDialog;
+}
+
+void HEXABLOCKGUI::showQuadInfoDialog(HEXA_NS::Quad* quad)
+{
+    if (quad == NULL || _dwInputPanel == NULL)
+        return;
+
+    if (_quadInfoDialog == NULL)
+        _quadInfoDialog = new QuadDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
+
+    _quadInfoDialog->setValue(quad);
+    _quadInfoDialog->resetSizeAndShow(_dwInputPanel);
+    currentDialog = _quadInfoDialog;
+}
+
+void HEXABLOCKGUI::showHexaInfoDialog(HEXA_NS::Hexa* hexa)
+{
+    if (hexa == NULL || _dwInputPanel == NULL)
+        return;
+
+    if (_hexaInfoDialog == NULL)
+        _hexaInfoDialog = new HexaDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
+
+    _hexaInfoDialog->setValue(hexa);
+    _hexaInfoDialog->resetSizeAndShow(_dwInputPanel);
+    currentDialog = _hexaInfoDialog;
+}
+
+void HEXABLOCKGUI::showVectorInfoDialog(HEXA_NS::Vector* vector)
+{
+    if (vector == NULL || _dwInputPanel == NULL)
+        return;
+
+    if (_vectorInfoDialog == NULL)
+        _vectorInfoDialog = new VectorDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
+
+    _vectorInfoDialog->setValue(vector);
+    _vectorInfoDialog->resetSizeAndShow(_dwInputPanel);
+    currentDialog = _vectorInfoDialog;
+}
+
+void HEXABLOCKGUI::showGroupInfoDialog(HEXA_NS::Group* group)
+{
+    if (group == NULL || _dwInputPanel == NULL)
+        return;
+
+    if (_groupInfoDialog == NULL)
+        _groupInfoDialog = new GroupDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
 
-    //close the current dialog box info
-    if (_treeViewDelegate != NULL)
-        _treeViewDelegate->closeDialog();
+    _groupInfoDialog->setValue(group);
+    _groupInfoDialog->resetSizeAndShow(_dwInputPanel);
+    currentDialog = _groupInfoDialog;
+}
 
-    if (_dwInputPanel->widget())
-        _dwInputPanel->widget()->close();
+void HEXABLOCKGUI::showLawInfoDialog(HEXA_NS::Law* law)
+{
+    if (law == NULL || _dwInputPanel == NULL)
+        return;
 
-    //Temporary for debugging EdgeAssoc Faked InfoDialog
-    if (diag == _edgeAssocDiag)
-        diag->debugEdgeAssoc = true;
-    else
-        diag->debugEdgeAssoc = false;
+    if (_lawInfoDialog == NULL)
+        _lawInfoDialog = new LawDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
 
-    if (diag ==  _quadAssocDiag || diag ==  _edgeAssocDiag || diag == _addShapeDiag)
-        assocInProgress = true;
-    else
-        assocInProgress = false;
+    _lawInfoDialog->setValue(law);
+    _lawInfoDialog->resetSizeAndShow(_dwInputPanel);
+    currentDialog = _lawInfoDialog;
+}
 
-    //show the dialog box in the dockwidget
-    diag->resetSizeAndShow(_dwInputPanel);
+void HEXABLOCKGUI::showPropagationInfoDialog(HEXA_NS::Propagation* propagation)
+{
+    if (propagation == NULL || _dwInputPanel == NULL)
+        return;
 
-    //clear the current selections
-    if (HEXABLOCKGUI::selectionMgr() != NULL)
-        HEXABLOCKGUI::selectionMgr()->clearSelected();
+    if (_propagationInfoDialog == NULL)
+        _propagationInfoDialog = new PropagationDialog(_dwInputPanel, HexaBaseDialog::INFO_MODE);
 
-    currentDialog = diag;
-    diag->setFocus();
+    _propagationInfoDialog->setValue(propagation);
+    _propagationInfoDialog->resetSizeAndShow(_dwInputPanel);
+    currentDialog = _propagationInfoDialog;
 }
 
 void HEXABLOCKGUI::addVertex()
@@ -2776,32 +2596,32 @@ void HEXABLOCKGUI::addVector()
         _vectorDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_VECTOR).c_str());
 }
 
-void HEXABLOCKGUI::addCylinder()
-{
-    if ( !_cylinderDiag ){
-        _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
-    }
-    _showDialogBox( _cylinderDiag );
-
-    //set default name
-    HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
-    if (_cylinderDiag != NULL && doc != NULL)
-        _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
-}
-
+//void HEXABLOCKGUI::addCylinder()
+//{
+//    if ( !_cylinderDiag ){
+//        _cylinderDiag = new CylinderDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
+//    }
+//    _showDialogBox( _cylinderDiag );
+//
+//    //set default name
+//    HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
+//    if (_cylinderDiag != NULL && doc != NULL)
+//        _cylinderDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
+//}
 
-void HEXABLOCKGUI::addPipe()
-{
-    if ( !_pipeDiag){
-        _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
-    }
-    _showDialogBox( _pipeDiag );
 
-    //set default name
-    HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
-    if (_pipeDiag != NULL && doc != NULL)
-        _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
-}
+//void HEXABLOCKGUI::addPipe()
+//{
+//    if ( !_pipeDiag){
+//        _pipeDiag = new PipeDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
+//    }
+//    _showDialogBox( _pipeDiag );
+//
+//    //set default name
+//    HEXA_NS::Document* doc = getCurrentModel() ? getCurrentModel()->getHexaDocument() : NULL;
+//    if (_pipeDiag != NULL && doc != NULL)
+//        _pipeDiag->name_le->setText(doc->getNextName(HEXA_NS::EL_CYLINDER).c_str());
+//}
 
 
 void HEXABLOCKGUI::makeGrid()
@@ -2959,59 +2779,27 @@ void HEXABLOCKGUI::quadRevolution() // NEW HEXA3
 }
 
 
-// void HEXABLOCKGUI::assocVertex()
-// {
-//   if ( !_vertexAssocDiag ){
-//     _vertexAssocDiag = new VertexAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
-//   }
-//   _showDialogBox( vertexAssocDiag );
-// }
-
-
 void HEXABLOCKGUI::assocVertex()
 {
-    if (!_dwInputPanel) return;
-    QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
-
-    VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
-    if (currentDGView == NULL) return;
-
-    if ( !_vertexAssocDiag  ){
-        _vertexAssocDiag  = new VertexAssocDialog( NULL, d );
-        if (!_vertexAssocDiag) return;
-    }
-    _vertexAssocDiag->setDocumentModel(getCurrentModel());
-    _vertexAssocDiag->setPatternDataSelectionModel(currentDGView->getPatternDataSelectionModel());
-
-    //close current widget
-    if (_treeViewDelegate != NULL) _treeViewDelegate->closeDialog();
-    if (_dwInputPanel->widget()) _dwInputPanel->widget()->close();
-
-    //add the vertex assoc dialog in the dockwidget
-    if ( !_dwInputPanel->isVisible() ) _dwInputPanel->setVisible(true);
-    _dwInputPanel->setWidget(_vertexAssocDiag);
-    _dwInputPanel->setWindowTitle(_vertexAssocDiag->windowTitle());
-    _vertexAssocDiag->adjustSize();
-    assocInProgress = true;
-    _vertexAssocDiag->show();
+       if (!_dwInputPanel) return;
+       QWidget* d = dynamic_cast<SUIT_Desktop*>(_dwInputPanel->parent());
+       if ( !_vertexAssocDiag  )
+               _vertexAssocDiag  = new VertexAssocDialog( d /*_dwInputPanel*/);
+       _showDialogBox( _vertexAssocDiag );
 }
 
 
-
 void HEXABLOCKGUI::assocEdge()
 {
-    if ( !_edgeAssocDiag ){
+    if ( !_edgeAssocDiag )
         _edgeAssocDiag = new EdgeAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
-        //    _edgeAssocDiag->setGeomEngine( _geomEngine );
-    }
     _showDialogBox( _edgeAssocDiag );
 }
 
 void HEXABLOCKGUI::assocQuad()
 {
-    if ( !_quadAssocDiag ){
+    if ( !_quadAssocDiag )
         _quadAssocDiag = new QuadAssocDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
-    }
     _showDialogBox( _quadAssocDiag );
 }
 
@@ -3130,28 +2918,26 @@ void HEXABLOCKGUI::removeLaw()
     }
     if (!nbLawsRemoved)
         SUIT_MessageBox::information( 0, tr( "CANNOT REMOVE LAW" ),
-                tr( "No law selected!" ) );
+                                         tr( "No law selected!" ) );
 
 }
 
 
 void HEXABLOCKGUI::setPropagation()
 {
-    if ( !_propagationDiag ){
+    if ( !_propagationDiag )
         _propagationDiag = new PropagationDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
-    }
+
     _showDialogBox( _propagationDiag );
 }
 
-
 // Dialog box to compute a mesh from a document
 // --------------------------------------------
 void HEXABLOCKGUI::computeMesh()
 {
-    if ( !_computeMeshDiag ){
+    if ( !_computeMeshDiag )
         _computeMeshDiag = new ComputeMeshDialog(_dwInputPanel, HexaBaseDialog::NEW_MODE);
-    }
-    _computeMeshDiag->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+
     _showDialogBox( _computeMeshDiag );
 }
 
@@ -3185,292 +2971,438 @@ void HEXABLOCKGUI::addShape()
     if (_addShapeDiag == NULL)
         _addShapeDiag = new AddShapeDialog(_dwInputPanel);
 
-    //show the model informations dialog
-    _showDialogBox( _addShapeDiag );
+    //show the model informations dialog
+    _showDialogBox( _addShapeDiag );
+}
+
+void HEXABLOCKGUI::clearAllAssociations()
+{
+    VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
+    if (currentDGView == NULL) return;
+
+    QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
+    if (!currentIndex.isValid()) return;
+    QVariant currentAssocVariant;
+    QString currentAssocEntry;
+
+    //Confirm the deletion of the associations
+    QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
+    if ( !treeVariant.isValid() ) return;
+    int eltType = treeVariant.toInt();
+    QString typeStr = "";
+    HEXA_NS::EnumElt hexaType;
+    if (eltType == VERTEX_DIR_TREE)
+    {
+        typeStr = tr("TREE_ITEM_VERTEX").toUpper();
+        hexaType = HEXA_NS::EL_VERTEX;
+    }
+    else if (eltType == EDGE_DIR_TREE)
+    {
+        typeStr = tr("TREE_ITEM_EDGE").toUpper();
+        hexaType = HEXA_NS::EL_EDGE;
+    }
+    else if (eltType == QUAD_DIR_TREE)
+    {
+        typeStr = tr("TREE_ITEM_QUAD").toUpper();
+        hexaType = HEXA_NS::EL_QUAD;
+    }
+
+    if (SUIT_MessageBox::question(
+            0,
+            tr("CLEAR_ASSOCIATIONS"),
+            tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
+            SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
+            SUIT_MessageBox::Cancel
+    ) == SUIT_MessageBox::Cancel) return;
+
+
+    DocumentModel* docModel = getCurrentModel();
+    if (docModel == NULL) return;
+    docModel->clearAssociation(hexaType);
+}
+
+void HEXABLOCKGUI::showAssociations()
+{
+    VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
+    if (currentDGView == NULL) return;
+
+    QModelIndexList elts;
+    int currentChildIndex = 0;
+    QVariant currentAssocVariant;
+    QString currentAssocEntry;
+    QModelIndex currentIndex = _patternDataTreeView->currentIndex();
+    QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
+
+    while( currentChild.isValid() ) {
+
+        currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
+        currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
+        if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
+            elts << currentChild;
+
+        currentChild = currentChild.sibling(currentChildIndex++, 0);
+    }
+    currentDocGView->highlight(elts);
+    currentOccGView->highlight(elts, false);
+}
+
+
+LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
+{
+    SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+    if( anApp )
+        return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
+    else
+        return NULL;
+}
+
+bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
+{
+    if ( event->type() == QEvent::Enter )
+    {   // *** ENTER EVENT
+
+        if (currentDialog == NULL || !currentDialog->isVisible())
+            return QObject::eventFilter(obj, event);
+
+        //  ** The window acquire the focus when the cursor enter
+
+            //OCC - window enter
+        OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
+        if ( occWindow != NULL)
+            currentDialog->onWindowActivated(occWindow->getViewManager());
+        else
+            //VTK - window enter
+        {
+            SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
+            if ( vtkWindow != NULL)
+                currentDialog->onWindowActivated(vtkWindow->getViewManager());
+        }
+    }
+
+    //standard event processing
+    return QObject::eventFilter(obj, event);
+}
+
+QStringList HEXABLOCKGUI::getQuickDirList()
+{
+    QStringList dirList;
+    SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+    if ( resMgr )
+        dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
+
+    return dirList;
+}
+
+
+// --- Export the module
+
+extern "C"
+{
+    HEXABLOCK_EXPORT CAM_Module* createModule()
+    {
+        return new HEXABLOCKGUI();
+    }
+
+    HEXABLOCK_EXPORT char* getModuleVersion()
+    {
+        return (char*)HEXABLOCK_VERSION_STR;
+    }
+}
+
+
+
+// ******************** TESTS ***************************************************
+
+void HEXABLOCKGUI::testDocument()
+{
+    //CS_TEST
+    // ----------
+    //   QStandardItem *parentItem = getCurrentModel()->invisibleRootItem();
+    //   QStandardItem *myItem =  new QStandardItem("MyItem");
+    //   parentItem->appendRow(myItem);
+    // //   ----------
+    //   QModelIndex v0 = getCurrentModel()->addVertex(0., 0., 0.);
+    //   QModelIndex v1 = getCurrentModel()->addVertex(5., 0., 0.);
+    //   QModelIndex v2 = getCurrentModel()->addVertex(5., 5., 0.);
+    //   QModelIndex v3 = getCurrentModel()->addVertex(0., 5., 0.);
+    //   QModelIndex v4 = getCurrentModel()->addVertex(0., 0., 5.);
+    //   QModelIndex v5 = getCurrentModel()->addVertex(5., 0., 5.);
+    //   QModelIndex v6 = getCurrentModel()->addVertex(5., 5., 5.);
+    //   QModelIndex v7 = getCurrentModel()->addVertex(0., 5., 5.);
+    // //
+    // //
+    //   QModelIndex q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
+    //   QModelIndex q1 = getCurrentModel()->addQuadVertices( v4, v5, v6, v7 );
+    //   QModelIndex q2 = getCurrentModel()->addQuadVertices( v0, v3, v7, v4 );
+    //   QModelIndex q3 = getCurrentModel()->addQuadVertices( v1, v2, v6, v5 );
+    //   QModelIndex q4 = getCurrentModel()->addQuadVertices( v0, v1, v5, v4 );
+    //   QModelIndex q5 = getCurrentModel()->addQuadVertices( v3, v2, v6, v7 );
+    //
+    //   QModelIndex h0 = getCurrentModel()->addHexaQuad( q0, q1, q2, q3, q4, q5 );
+    //   QModelIndex vx = getCurrentModel()->addVector(1., 0., 0.);
+    //   QModelIndex vy = getCurrentModel()->addVector(0., 1., 0.);
+    //   QModelIndex vz = getCurrentModel()->addVector(0., 0., 1.);
+    //
+
+
+
+    // //   QModelIndex orig1 = getCurrentModel()->addVertex (0, 0,0);
+    // //   QModelIndex orig2 = getCurrentModel()->addVertex (50,0,0);
+    // //   QModelIndex vz    = getCurrentModel()->addVector (0,0,1);
+    // //   QModelIndex vx    = getCurrentModel()->addVector (1,0,0);
+    // //
+    // //   int nr  = 4;
+    // //   int nri = 3;
+    // //   int nre = nr;
+    // //   int na = 9;
+    // //   int nl = 5;
+    // //
+    // //   QModelIndex  cyl  = getCurrentModel()->addCylinder   (orig1, vz, nr, nl);
+    // //   QModelIndex  pipe = getCurrentModel()->addPipe       (orig2, vz, nri, nre, nl);
+    // //
+    // //   getCurrentModel()->makeCylinder (cyl,  vx, nr, na, nl);
+    // //   getCurrentModel()->makePipe(pipe, vx, nr, na, nl);
+
+
+
+    //   newMesh( "toto", 3, "FactoryServer");
+    // newMesh
+}
+
+void HEXABLOCKGUI::test_make_cart_grid()
+{
+    QModelIndex orig1 = getCurrentModel()->addVertex( 0, 0, 0);
+    QModelIndex orig2 = getCurrentModel()->addVertex( 10, 0, 0);
+    QModelIndex orig3 = getCurrentModel()->addVertex( 0, 10, 0);
+    QModelIndex orig4 = getCurrentModel()->addVertex( 10, 10, 0);
+    QModelIndex orig5 = getCurrentModel()->addVertex( 0, 20, 0);
+    QModelIndex orig6 = getCurrentModel()->addVertex( 10, 20, 0);
+
+    QModelIndex vz = getCurrentModel()->addVector(0, 0, 1);
+    QModelIndex vx = getCurrentModel()->addVector(1, 0, 0);
+
+    //int dr = 1;
+    //int dl = 1;
+    //int nr = 2;
+    //int nl = 3;
+
+    // QModelIndex c1 = getCurrentModel()->makeCylindrical(orig1, vx, vz, dr, 360, dl, nr, 4, nl, true);
+    // QModelIndex c2 = getCurrentModel()->makeCylindrical(orig2, vx, vz, dr, 360, dl, nr, 8, nl, true);
+    // QModelIndex c3 = getCurrentModel()->makeCylindrical(orig3, vx, vz, dr, 270, dl, nr, 8, nl, true);
+    // QModelIndex c4 = getCurrentModel()->makeCylindrical(orig4, vx, vz, dr, 270, dl, nr, 7, nl, true);
+    // QModelIndex c5 = getCurrentModel()->makeCylindrical(orig5, vx, vz, dr, 360, dl, nr, 5, nl, true);
+    // QModelIndex c6 = getCurrentModel()->makeCylindrical(orig6, vx, vz, dr, 360, dl, nr, 6, nl, true);
+
 }
 
-void HEXABLOCKGUI::clearAllAssociations()
+
+void HEXABLOCKGUI::test_make_elmts_transform()
 {
-    VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
-    if (currentDGView == NULL) return;
 
-    int currentChildIndex = 0;
-    QModelIndex currentIndex = currentDGView->getPatternDataModel()->mapToSource(_patternDataTreeView->currentIndex());
-    if (!currentIndex.isValid()) return;
-    QVariant currentAssocVariant;
-    QString currentAssocEntry;
+//    int size_x = 1;
+//    int size_y = 1;
+//    int size_z = 2;
+//
+//    QModelIndex orig = getCurrentModel()->addVertex(0, 0, 0);
+//    QModelIndex dirVr = getCurrentModel()->addVector(1, 1, 1);
 
-    //Confirm the deletion of the associations
-    QVariant treeVariant = currentIndex.data( HEXA_TREE_ROLE );
-    if ( !treeVariant.isValid() ) return;
-    int eltType = treeVariant.toInt();
-    QString typeStr = "";
-    HEXA_NS::EnumElt hexaType;
-    if (eltType == VERTEX_DIR_TREE)
-    {
-        typeStr = tr("TREE_ITEM_VERTEX").toUpper();
-        hexaType = HEXA_NS::EL_VERTEX;
-    }
-    else if (eltType == EDGE_DIR_TREE)
-    {
-        typeStr = tr("TREE_ITEM_EDGE").toUpper();
-        hexaType = HEXA_NS::EL_EDGE;
-    }
-    else if (eltType == QUAD_DIR_TREE)
-    {
-        typeStr = tr("TREE_ITEM_QUAD").toUpper();
-        hexaType = HEXA_NS::EL_QUAD;
-    }
+    //obsolete
+//    QModelIndex grid = getCurrentModel()->makeCartesian(orig, dirVr, size_x, size_y, size_z);//, 0, 0, 0);
+    // orig.setScalar(2);
 
-    if (SUIT_MessageBox::question(
-            0,
-            tr("CLEAR_ASSOCIATIONS"),
-            tr("CLEAR_ALL_ASSOCIATIONS_ON") + " " + typeStr + "?",
-            SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
-            SUIT_MessageBox::Cancel
-    ) == SUIT_MessageBox::Cancel) return;
+    // file_name = os.path.join(os.environ['TMP'], 'transfo0.vtk')
+    // getCurrentModel()->saveVtk(file_name)
 
+//    QModelIndex devant = getCurrentModel()->addVector(5, 0, 0);
+//    QModelIndex grid2  = getCurrentModel()->makeTranslation(grid, devant);
 
-    DocumentModel* docModel = getCurrentModel();
-    if (docModel == NULL) return;
-    docModel->clearAssociation(hexaType);
+    // file_name = os.path.join(os.environ['TMP'], 'transfo_translation.vtk')
+    // getCurrentModel()->saveVtk(file_name)
 
-//    QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
-//    while( currentChild.isValid() ) {
-//
-//        currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
-//        currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
-//        if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
-//            getCurrentModel()->clearEltAssociations(currentChild);
-//
-//        currentChild = currentChild.sibling(currentChildIndex++, 0);
-//    }
+//    QModelIndex grid4 = getCurrentModel()->makeRotation(grid2, orig, dirVr, 45);
 
-    //SUIT_MessageBox::information( 0, tr( "HEXA_INFO" ), tr( "ASSOCIATION CLEARED" ) );
-}
 
-void HEXABLOCKGUI::showAssociations()
+    // file_name = os.path.join(os.environ['TMP'], 'transfo_rotation.vtk');
+    // getCurrentModel()->saveVtk(file_name);
+
+
+    // print "...test make elements by transforming elements OK"
+}
+// =============================================================== addDocInSudy
+QString HEXABLOCKGUI::addDocInStudy (HEXA_NS::Document* document)
 {
-    VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
-    if (currentDGView == NULL) return;
+    QString docEntry;
 
-    QModelIndexList elts;
-    int currentChildIndex = 0;
-    QVariant currentAssocVariant;
-    QString currentAssocEntry;
-    QModelIndex currentIndex = _patternDataTreeView->currentIndex();
-    QModelIndex currentChild = currentIndex.child(currentChildIndex++, 0);
+    if (document == NULL)
+        return docEntry;
 
-    while( currentChild.isValid() ) {
+    QString docName  = document->getName ();
 
-        currentAssocVariant = currentChild.data( HEXA_ASSOC_ENTRY_ROLE );
-        currentAssocEntry = currentChild.data( HEXA_ASSOC_ENTRY_ROLE ).toString();
-        if ( currentAssocVariant.isValid() && !currentAssocEntry.isEmpty() )
-            elts << currentChild;
+    SalomeApp_Study* app_study = HEXABLOCKGUI::activeStudy();
+    if (app_study == NULL)
+        return docEntry;
 
-        currentChild = currentChild.sibling(currentChildIndex++, 0);
-    }
-    currentDGView->getPatternDataSelectionModel()->highlightEltsWithAssocs(elts);
+    _PTR(Study)         study    = app_study->studyDS();
+    SALOMEDS::Study_var ds_study = ClientStudyToStudy (study);
+    SALOMEDS::StudyBuilder_var aBuilder (ds_study->NewBuilder());
+    QString entry = app_study->centry("HEXABLOCK");
+    SALOMEDS::SObject_var aFatherSO = ds_study->FindObjectID( qPrintable(entry) );
+    if (aFatherSO->_is_nil())
+        return docEntry;
+
+    SALOMEDS::SObject_var aSO = aBuilder->NewObject(aFatherSO);
+    if (aSO->_is_nil())
+        return docEntry;
+    aSO->SetAttrString("AttributeName", docName.toStdString().c_str());
+    docEntry = aSO->GetID(); //the entry of the published object
+
+    return docEntry;
 }
 
+//--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 
-LightApp_SelectionMgr* HEXABLOCKGUI::selectionMgr()
+void HEXABLOCKGUI::test()
 {
-    SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
-    if( anApp )
-        return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
-    else
-        return NULL;
+    DEBTRACE("HEXABLOCKGUI::test");
+    VtkDocumentGraphicView* currentDGView = getCurrentVtkGraphicView();
+    if (currentDGView == NULL) return;
+    currentDGView->update();
+
 }
 
-bool HEXABLOCKGUI::eventFilter(QObject *obj, QEvent *event)
+void HEXABLOCKGUI::test_association()
 {
-    if ( currentDialog == NULL ) return false;
+    DEBTRACE("HEXABLOCKGUI::test_association");
+    newDocument();
 
-    if ( event->type() == QEvent::Enter ){ // ENTER EVENT
+    QModelIndex v0, v1, v2, v3, e0, e1, q0;
 
-        // The window acquire the focus when the cursor enter
+    DocumentModel::GeomObj v0Assoc, v1Assoc, v2Assoc, v3Assoc;
+    DocumentModel::GeomObj e0AssocA, e1AssocA, e1AssocB, e1AssocC;
+    DocumentModel::GeomObj q0AssocA, q0AssocB;
 
-        //OCC - window enter
-        OCCViewer_ViewWindow* occWindow = dynamic_cast<OCCViewer_ViewWindow*>(obj);
-        if ( occWindow != NULL)
-        {
-            if (!occWindow->hasFocus()) occWindow->setFocus();
-            if (currentDialog != NULL && !currentDialog->isHidden())
-                currentDialog->onWindowActivated(occWindow->getViewManager());
-        }
+    DocumentModel::GeomObj v0Assoc_test, v1Assoc_test, v2Assoc_test, v3Assoc_test;
+    QList<DocumentModel::GeomObj> e1Assocs_test;
+    DocumentModel::GeomObj q0Assoc_test;
 
-        //VTK
-        SVTK_ViewWindow* vtkWindow = dynamic_cast<SVTK_ViewWindow*>(obj);
-        if ( vtkWindow != NULL)
-        {
-            if (!vtkWindow->hasFocus()) vtkWindow->setFocus();
-            if (currentDialog != NULL && !currentDialog->isHidden())
-                currentDialog->onWindowActivated(vtkWindow->getViewManager());
-        }
+    v0 = getCurrentModel()->addVertex(0, 0, 0);
+    v1 = getCurrentModel()->addVertex(1, 0, 0);
+    v2 = getCurrentModel()->addVertex(1, 1, 0);
+    v3 = getCurrentModel()->addVertex(0, 1, 0);
+    e0  = getCurrentModel()->addEdgeVertices(v0, v1);
+    e1  = getCurrentModel()->addEdgeVertices(v1, v2);
+    q0 = getCurrentModel()->addQuadVertices( v0, v1, v2, v3 );
 
-        //Don't pass the signal
-        return true;
-    }
-    else
-        //standard event processing
-        return QObject::eventFilter(obj, event);
-}
 
-QStringList HEXABLOCKGUI::getQuickDirList()
-{
-    QStringList dirList;
-    SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-    if ( resMgr )
-        dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
+    // >>> face3.GetEntry()'0:1:4'
+    // >>> e1.GetEntry()'0:1:8'
+    // >>> e2.GetEntry()'0:1:9'
+    // >>> e3.GetEntry()'0:1:10'
+    // >>> e4.GetEntry()'0:1:11'
+    // >>> v1.GetEntry()'0:1:12'
+    // >>> v2.GetEntry()'0:1:13'
+    // >>> v3.GetEntry()'0:1:14'
+    // >>> v4.GetEntry()'0:1:15'
 
-    return dirList;
-}
 
+    //   v0Assoc.name  = "geomV0";
+    //   v0Assoc.entry = "0:1:1:1:3:6";//"0:1:12";
+    //   v0Assoc.brep  = "brepV0";
+    //   v1Assoc.name  = "geomV1";
+    //   v1Assoc.entry = "0:1:1:1:3:7";//"0:1:13";
+    //   v1Assoc.brep  = "brepV1";
+    //   v2Assoc.name  = "geomV2";
+    //   v2Assoc.entry = "0:1:1:1:3:8";//"0:1:14";
+    //   v2Assoc.brep  = "brepV2";
+    //   v3Assoc.name  = "geomV3";
+    //   v3Assoc.entry = "0:1:1:1:3:9";//"0:1:15";
+    //   v3Assoc.brep  = "brepV3";
+    //
+    //
+    //
+    //   e0AssocA.name   = "geomE0a";
+    //   e0AssocA.entry  = "0:1:1:1:3:5";//"0:1:8";
+    //   e0AssocA.brep  = "brepE0a";
+    //   e0AssocA.start  = 0.10;
+    //   e0AssocA.end    = 0.95;
+    //
+    //
+    //
+    //   e1AssocA.name   = "geomE1a";
+    //   e1AssocA.entry  = "0:1:1:1:3:2";//"0:1:8";
+    //   e1AssocA.brep  = "brepE1a";
+    //   e1AssocA.start  = 0.12;
+    //   e1AssocA.end    = 0.89;
+    //   e1AssocB.name   = "geomE1b";
+    //   e1AssocB.entry  = "0:1:1:1:3:3";//"0:1:9";
+    //   e1AssocB.brep  = "brepE1b";
+    //   e1AssocB.start  = 0.20;
+    //   e1AssocB.end    = 0.80;
+    //   e1AssocC.name   = "geomE1c";
+    //   e1AssocC.entry  = "0:1:1:1:3:4";//"0:1:10";
+    //   e1AssocC.brep  = "brepE1c";
+    //   e1AssocC.start  = 0.16;
+    //   e1AssocC.end    = 0.96;
+    //
+    //   q0AssocA.name   = "geomQuad";
+    //   q0AssocA.entry  = "0:1:1:1:3";
+    //   q0AssocA.brep   = "brepq0";
+    //
+    //   q0AssocB.name   = "geomQuad";
+    //   q0AssocB.entry  = "0:1:1:1:4";
+    //   q0AssocB.brep   = "brepq0";
+    //
+    //   getCurrentModel()->addAssociation( v0, v0Assoc );
+    //   getCurrentModel()->addAssociation( v1, v1Assoc );
+    //   getCurrentModel()->addAssociation( v2, v2Assoc );
+    //   getCurrentModel()->addAssociation( v3, v3Assoc );
+    //
+    //
+    //   getCurrentModel()->addAssociation( e0, e0AssocA );
+    //
+    //   getCurrentModel()->addAssociation( e1, e1AssocA );
+    //   getCurrentModel()->addAssociation( e1, e1AssocB );
+    //   getCurrentModel()->addAssociation( e1, e1AssocC );
+    //
+    //   getCurrentModel()->addAssociation( q0, q0AssocA );
+    //   getCurrentModel()->addAssociation( q0, q0AssocB );
 
 
-// --- Export the module
 
-extern "C"
-{
-HEXABLOCKGUI_EXPORT CAM_Module* createModule()
-          {
-    return new HEXABLOCKGUI();
-          }
 
-HEXABLOCKGUI_EXPORT char* getModuleVersion()
-          {
-    return (char*)HEXABLOCK_VERSION_STR;
-          }
-}
 
+    //   v0Assoc_test = getCurrentModel()->getAssociations( v0 )[0];
+    //   v1Assoc_test = getCurrentModel()->getAssociations( v1 )[0];
+    //   v2Assoc_test = getCurrentModel()->getAssociations( v2 )[0];
+    //   v3Assoc_test = getCurrentModel()->getAssociations( v3 )[0];
+    //   ASSERT( v0Assoc.name == v0Assoc_test.name );
+    //   ASSERT( v1Assoc.name == v1Assoc_test.name );
+    //   ASSERT( v2Assoc.name == v2Assoc_test.name );
+    //   ASSERT( v3Assoc.name == v3Assoc_test.name );
+    //   ASSERT( v0Assoc.entry == v0Assoc_test.entry );
+    //   ASSERT( v1Assoc.entry == v1Assoc_test.entry );
+    //   ASSERT( v2Assoc.entry == v2Assoc_test.entry );
+    //   ASSERT( v3Assoc.entry == v3Assoc_test.entry );
+    //
+    //
+    //   e1Assocs_test = getCurrentModel()->getAssociations( e1 );
+    //   ASSERT( e1Assocs_test[0].name == e1AssocA.name );
+    //   ASSERT( e1Assocs_test[1].name == e1AssocB.name );
+    //   ASSERT( e1Assocs_test[2].name == e1AssocC.name );
+    //   ASSERT( e1Assocs_test[0].entry == e1AssocA.entry );
+    //   ASSERT( e1Assocs_test[1].entry == e1AssocB.entry );
+    //   ASSERT( e1Assocs_test[2].entry == e1AssocC.entry );
+    //   ASSERT( e1Assocs_test[0].start == e1AssocA.start );
+    //   ASSERT( e1Assocs_test[1].start == e1AssocB.start );
+    //   ASSERT( e1Assocs_test[2].start == e1AssocC.start );
+    //   ASSERT( e1Assocs_test[0].end == e1AssocA.end );
+    //   ASSERT( e1Assocs_test[1].end == e1AssocB.end );
+    //   ASSERT( e1Assocs_test[2].end == e1AssocC.end );
+    //
+    //   q0Assoc_test = getCurrentModel()->getAssociations( q0 )[0];
+    //   ASSERT( q0Assoc_test.name  == q0Assoc.name );
+    //   ASSERT( q0Assoc_test.entry == q0Assoc.entry );
 
-// void  HEXABLOCKGUI::newMesh( const std::string& meshName,
-//                                             int dim,
-//                              const std::string& container )
-// {
 
-//   SalomeApp_Application* app = getApp();
-//   int activeStudyId = app->activeStudy()->id();
-//
-//   if ( CORBA::is_nil(_hexaEngine) ) _hexaEngine  = InitHEXABLOCKGen( app );
-//   if ( CORBA::is_nil(_smeshEngine)) _smeshEngine = InitSMESHGen( app, container );
-//   if ( CORBA::is_nil(_geomEngine) ) _geomEngine  = InitGEOMGen( app, container );
-//
-//   std::cout << "_hexaEngine =>" << _hexaEngine << std::endl;
-//   std::cout << "_smeshEngine =>" << _smeshEngine << std::endl;
-//   std::cout << "_geomEngine =>" << _geomEngine << std::endl;
-//
-//   HEXA_NS::Document* docImpl = getCurrentModel()->documentImpl();
-//   std::cout << "docImpl =>" << docImpl << std::endl;
-//   std::cout << "docImpl->getFile() =>" << docImpl->getFile() << std::endl;
-//   HEXABLOCK_ORB::Document_var anDocObj=  _hexaEngine->loadDocument( docImpl->getFile() );
-//   std::cout << "anDocObj =>" << anDocObj << std::endl;
-//
-//
-//   GEOM::GEOM_I3DPrimOperations_var anGeomOper = _geomEngine->GetI3DPrimOperations( activeStudyId );
-//   if ( CORBA::is_nil(anGeomOper) ) return;  //!anGeomOper->_is_nil() ) {
-//   std::cout << "anGeomOper =>" << anGeomOper << std::endl;
-//   GEOM::GEOM_Object_var            anGeomObj = anGeomOper->MakeBoxDXDYDZ( 5., 5., 5. );
-//   std::cout << "anGeomObj =>" << anGeomObj << std::endl;
-//
-//
-//   SALOMEDS::SObject _geomEngine->AddInStudy (in SALOMEDS::Study theStudy,
-//                                   in GEOM_Object theObject,
-//                                   in string theName,
-//
-//
-//
-// // void GEOMBase::PublishSubObject( GEOM::GEOM_Object_ptr object )
-// // {
-//   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
-//   if ( study && !CORBA::is_nil( object ) ) {
-//     _PTR(Study) studyDS = study->studyDS();
-//     QString entry = GetEntry( object );
-//     GEOM::GEOM_Object_var father = object->GetMainShape();
-//     QString fatherEntry = GetEntry( father );
-//     if ( entry.isEmpty() && !CORBA::is_nil( father ) && !fatherEntry.isEmpty() ) {
-//       QString name = GetName( object );
-//       GeometryGUI::GetGeomGen()->AddInStudy( GeometryGUI::ClientStudyToStudy( studyDS ),
-//                                          object, name.toLatin1().data(), father.in() );
-//     }
-//   }
-// }
-//
-//
-// //     geompy = smesh.geompy
-// //     #fkl: shape  = doc.getShape()
-// //     shape  = geompy.MakeBox(0, 0, 0,  1, 1, 1)
-// //     geompy.addToStudy(shape, name)
-// //
-// //     component = salome.lcc.FindOrLoadComponent(container, "SMESH")
-// //     component.init_smesh(salome.myStudy, geompy.geom)
-// //     mesh = component.Mesh(shape, name)
-// //
-// //     so = "libHexaBlockEngine.so"
-// //
-// //     algo = smesh.SMESH._objref_SMESH_Gen.CreateHypothesis(component, "HEXABLOCK_3D", so)
-//     SMESH::SMESH_Hypothesis_var algo = _smeshEngine->CreateHypothesis( "HEXABLOCK_3D", "libHexaBlockEngine.so");
-// //       raises ( SALOME::SALOME_Exception );
-// //     mesh.mesh.AddHypothesis(shape, algo)
-// //
-// //     hypo = smesh.SMESH._objref_SMESH_Gen.CreateHypothesis(component, "HEXABLOCK_Parameters", so)
-//     //HEXABLOCKPlugin::HEXABLOCKPlugin_Hypothesis_var
-//      SMESH::SMESH_Hypothesis_var hypo = _smeshEngine->CreateHypothesis( "HEXABLOCK_Parameters", "libHexaBlockEngine.so");
-//
-//      HEXABLOCKPlugin::HEXABLOCKPlugin_Hypothesis_var hexHypo = HEXABLOCKPlugin::HEXABLOCKPlugin_Hypothesis::_narrow(hypo);
-//     ASSERT(!CORBA::is_nil(hexHypo));
-//
-// //     mesh.mesh.AddHypothesis(shape, hypo)
-// //
-// //     hexHypo->SetDocument(anDocObj);
-// //     hexHypo->SetDimension(dim);
-// //
-// //     mesh.Compute()
-// //
-// //     return mesh
-//
-// }
-//
-//
-//
-// void  newMesh( const std::string& meshName, int dim )// const std::string& container )
-// {
-//
-// //     _smeshEngine.init_smesh(salome.myStudy, geompy.geom)
-// SMESH::SMESH_var mesh = _smeshEngine->Mesh(shape, name);
-// SMESH::SMESH_Hypothesis_var algo = _smeshEngine->CreateHypothesis( "HEXABLOCK_3D", "libHexaBlockEngine.so");
-// SMESH::SMESH_Hypothesis_var hypo = _smeshEngine->CreateHypothesis( "HEXABLOCK_Parameters", "libHexaBlockEngine.so");
-// HEXABLOCKPlugin::HEXABLOCKPlugin_Hypothesis_var hexHypo = HEXABLOCKPlugin::HEXABLOCKPlugin_Hypothesis::_narrow(hypo);
-// hexHypo->SetDocument(anDocObj);
-// hexHypo->SetDimension(dim);
-// }
-
-/*
-SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
-{
-  _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
-  if ( CORBA::is_nil( myComponentSMESH ) )
-    {
-      SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
-      if ( aStudy )
-        aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
-      return aGUI.myComponentSMESH;
-    }
-  if ( aStudy )
-    myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
-  return myComponentSMESH;
-}*/
-
-
-// try {
-// //   throw SALOME_Exception(LOCALIZED("assocVertex"));
-//   } catch ( SALOME::SALOME_Exception& exc ){
-//       INFOS("Following exception was cought:\n\t"<<exc.details.text);
-//   } catch( const std::exception& exc){
-//       INFOS("Following exception was cought:\n\t"<<exc.what());
-//   } catch (Standard_Failure& exc) {
-//       MESSAGE("OCCT Exception in SMESH_Pattern: " << exc.GetMessageString());
-//   } catch(...){
-//       MESSAGE("Unknown exception was cought !!!");
-//   }
+    DEBTRACE("HEXABLOCKGUI::test_association fin");
+}