Salome HOME
Modif Hexablock.py
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI_DocumentSelectionModel.cxx
index 5627b29316525df60f212eb408594ae94281665e..7abc8b7fc6e933b666d8b4327a5e1ccea5638e9d 100755 (executable)
@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2009-2013  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
 #include <SUIT_ViewManager.h>
 #include <SVTK_View.h>
 
-
+#include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
+#include "HEXABLOCKGUI_OccGraphicView.hxx"
 #include "HEXABLOCKGUI_SalomeTools.hxx"
 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
-#include "HEXABLOCKGUI_DocumentModel.hxx"
-#include "HEXABLOCKGUI_DocumentGraphicView.hxx"
 #include "HEXABLOCKGUI_DocumentItem.hxx"
 #include "HEXABLOCKGUI.hxx"
 
 #include <SALOME_Actor.h>
 #include <SALOME_ListIO.hxx>
 #include <SALOME_ListIteratorOfListIO.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
 
 #include <QMultiMap>
 
-#include "GEOMBase.h"
-#include "MyGEOMBase_Helper.hxx"
-
 #include <OCCViewer_ViewModel.h>
 #include <SVTK_ViewModel.h>
 #include <SalomeApp_Study.h>
@@ -86,87 +83,25 @@ using namespace std;
 using namespace HEXABLOCK::GUI;
 
 
+// //===========================================================================
+//                              SelectionModel
+// //===========================================================================
 
-PatternDataSelectionModel::PatternDataSelectionModel( QAbstractItemModel * model ):
-QItemSelectionModel( model ),
-MyGEOMBase_Helper( SUIT_Session::session()->activeApplication()->desktop() ),
-_theModelSelectionChanged(false),
-_theVtkSelectionChanged(false),
-_theGeomSelectionChanged(false),
-salomeNothingSelected(true),
-_selectionFilter(-1),
-_salomeSelectionMgr(0)
-{
-  connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
-           this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
-  connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
-           this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
-
-}
-
-PatternDataSelectionModel::~PatternDataSelectionModel()
-{
-  disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
-          this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
-  disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
-          this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
-
-//   if ( _salomeSelectionMgr )
-//     disconnect( _salomeSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
-  disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
-}
-
-void PatternDataSelectionModel::setVertexSelection()
-{
-  MESSAGE("PatternDataSelectionModel::setVertexSelection(){");
-  SetSelectionMode(NodeSelection);
-// //  NodeSelection,
-// //  CellSelection,
-// //  EdgeOfCellSelection,
-// //  EdgeSelection,
-// //  FaceSelection,
-// //  VolumeSelection,
-// //  ActorSelection };
-  _selectionFilter = VERTEX_TREE;
-  MESSAGE("}");
-}
-
-void PatternDataSelectionModel::setEdgeSelection()
-{
-  MESSAGE("PatternDataSelectionModel::setEdgeSelection(){");
-  SetSelectionMode(EdgeSelection);
-  _selectionFilter = EDGE_TREE;
-  MESSAGE("}");
-}
+bool SelectionModel::infoMode = true;
 
-void PatternDataSelectionModel::setQuadSelection()
+SelectionModel::SelectionModel( QAbstractItemModel * model ):
+QItemSelectionModel( model )
 {
-  MESSAGE("PatternDataSelectionModel::setQuadSelection(){");
-  SetSelectionMode(FaceSelection);
-  _selectionFilter = QUAD_TREE;
-  MESSAGE("}");
-}
 
-void PatternDataSelectionModel::setHexaSelection()
-{
-  MESSAGE("PatternDataSelectionModel::setHexaSelection(){");
-//  SetSelectionMode(VolumeSelection);
-  SetSelectionMode(FaceSelection); //temporary for hexa selection debug
-  _selectionFilter = HEXA_TREE;
-  MESSAGE("}");
 }
 
-
-void PatternDataSelectionModel::setAllSelection()
+SelectionModel::~SelectionModel()
 {
-  MESSAGE("PatternDataSelectionModel::setAllSelection(){");
-  SetSelectionMode(ActorSelection);
-  _selectionFilter = -1;
-  MESSAGE("}");
+  disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
 }
 
 
-QModelIndex PatternDataSelectionModel::indexBy( int role, const QString& value )
+QModelIndex SelectionModel::indexBy( int role, const QString& value )
 {
   QModelIndex eltIndex; // element (vertex, edge, quad) of model
   const QAbstractItemModel* theModel = model();
@@ -182,7 +117,7 @@ QModelIndex PatternDataSelectionModel::indexBy( int role, const QString& value )
 }
 
 
-QModelIndex PatternDataSelectionModel::indexBy( int role, const QVariant& var )
+QModelIndex SelectionModel::indexBy( int role, const QVariant& var )
 {
   QModelIndex eltIndex; // element (vertex, edge, quad) of model
   const QAbstractItemModel* theModel = model();
@@ -197,612 +132,359 @@ QModelIndex PatternDataSelectionModel::indexBy( int role, const QVariant& var )
   return eltIndex;
 }
 
-
-void PatternDataSelectionModel::setSalomeSelectionMgr( LightApp_SelectionMgr* mgr )
+QModelIndex SelectionModel::indexOf( const QString& anEntry, int role )
 {
-  _salomeSelectionMgr = mgr;
-  connect( _salomeSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
+  QModelIndex eltIndex; // element (vertex, edge, quad) of model
+  const QAbstractItemModel* theModel = model();
+  if ( !theModel ) return eltIndex;
+
+  QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
+                                          role,
+                                          anEntry,
+                                          1,
+                                          Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
+  if ( theIndexes.count()>0 )
+    eltIndex = theIndexes[0] ;
+  return eltIndex;
 }
 
 
-void  PatternDataSelectionModel::SetSelectionMode(Selection_Mode theMode)
+QModelIndexList SelectionModel::indexListOf( const QString& anEntry, int role )
 {
-  MESSAGE("PatternDataSelectionModel::SetSelectionMode(){");
-//  SVTK_ViewWindow* aVTKViewWindow = _getVTKViewWindow();
-//   aViewWindow->clearFilters();
-//   _salomeSelectionMgr->clearFilters();
-  if ( _getVTKViewWindow() != NULL )
-         _getVTKViewWindow()->SetSelectionMode( theMode );
-  MESSAGE("}");
+  QModelIndexList theIndexes; // element (vertex, edge, quad) of model
+  const QAbstractItemModel* theModel = model();
+  if ( !theModel ) return theIndexes;
+  theIndexes = theModel->match( theModel->index(0, 0),
+                                role,
+                                anEntry,
+                                -1,
+                                Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
+  return theIndexes;
+}
+
+DocumentModel* SelectionModel::getDocModel() const
+{
+    DocumentModel* docModel = NULL;
+    const QSortFilterProxyModel *pModel   = dynamic_cast<const QSortFilterProxyModel *>( model() );
+    if ( pModel != NULL)
+        docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel() );
+
+    return docModel;
+}
+
+void SelectionModel::showEltInfo(QModelIndex& elt)
+{
+    DocumentModel* docModel = getDocModel();
+    if (!elt.isValid() || docModel == NULL)
+        return;
+
+    HEXA_NS::Vertex* vertex  = docModel->getHexaPtr<HEXA_NS::Vertex*>(elt);
+    HEXA_NS::Edge*   edge    = docModel->getHexaPtr<HEXA_NS::Edge*>(elt);
+    HEXA_NS::Quad*   quad    = docModel->getHexaPtr<HEXA_NS::Quad*>(elt);
+    HEXA_NS::Hexa*   hexa    = docModel->getHexaPtr<HEXA_NS::Hexa*>(elt);
+    HEXA_NS::Vector* vector  = docModel->getHexaPtr<HEXA_NS::Vector*>(elt);
+    HEXA_NS::Group*  group   = docModel->getHexaPtr<HEXA_NS::Group*>(elt);
+    HEXA_NS::Law*    law     = docModel->getHexaPtr<HEXA_NS::Law*>(elt);
+    HEXA_NS::Propagation* propagation = docModel->getHexaPtr<HEXA_NS::Propagation*>(elt);
+
+    HEXABLOCKGUI*    hexagui = HEXABLOCKGUI::getInstance();
+    if (vertex != NULL)
+        hexagui->showVertexInfoDialog(vertex);
+    else if (edge != NULL)
+        hexagui->showEdgeInfoDialog(edge);
+    else if (quad != NULL)
+        hexagui->showQuadInfoDialog(quad);
+    else if (hexa != NULL)
+        hexagui->showHexaInfoDialog(hexa);
+    else if (vector != NULL)
+        hexagui->showVectorInfoDialog(vector);
+    else if (group != NULL)
+        hexagui->showGroupInfoDialog(group);
+    else if (law != NULL)
+        hexagui->showLawInfoDialog(law);
+    else if (propagation != NULL)
+        hexagui->showPropagationInfoDialog(propagation);
+}
+
+void SelectionModel::salomeSelectionChanged()
+{
+    // clear highlights and selections in the trees
+    PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
+//    PatternBuilderSelectionModel* pbsm = HEXABLOCKGUI::currentDocGView->getPatternBuilderSelectionModel();
+    PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
+    pdsm->clearSelection();
+//    pbsm->clearSelection();
+    pgsm->clearSelection();
+    pdsm->unhighlightTreeItems();
+    pgsm->unhighlightTreeItems();
+
+    try {
+        SALOME_ListIO selectedObjects;
+        Handle(SALOME_InteractiveObject) anIObject;
+
+        switch (HEXABLOCKGUI::getActiveViewType())
+        {
+        case HEXABLOCKGUI::VTK:
+        {
+            HEXABLOCKGUI::currentDocGView->getSelected(selectedObjects);
+            if ( selectedObjects.IsEmpty() )
+                return;
+            anIObject = selectedObjects.First();
+            vtkSelectionChanged( anIObject );
+            break;
+        }
+        case HEXABLOCKGUI::OCC:
+            HEXABLOCKGUI::currentOccGView->getSelected(selectedObjects);
+            if ( selectedObjects.IsEmpty() )
+                return;
+            anIObject = selectedObjects.First();
+            geomSelectionChanged( anIObject );
+            break;
+        }
+    } catch ( ... ) {
+        MESSAGE("*  Unknown selection exception!");
+    }
 }
 
 
-//     A) De Salome(OCC, VTK) vers Hexablock(TreeView Data) :
-//         -Vertex:
-//             in:     selection (vertex associé OCC).
-//             out:    (vertex VTK) highlighté, (vertex TreeView) sélectionné.
-// 
-//             in :    selection (vertex associé VTK).
-//             out:    (vertex OCC) highlighté, (vertex TreeView) sélectionné.
-// 
-//         -Edge:
-//             in:     selection (edge associé OCC).
-//             out:    (vertex VTK) highlighté, (vertex TreeView) sélectionné.
-// 
-//             in:     selection (edge associé VTK).
-//             out:    (toute la ligne OCC) highlighté + vertex sur (deb,fin) , (edge TreeView) sélectionné.
-// 
-//         -Face: idem vertex
-void PatternDataSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous )
+QModelIndexList SelectionModel::getSelectionFromModel(const Handle(SALOME_InteractiveObject)& anIObject)
 {
-  MESSAGE("PatternDataSelectionModel::onCurrentChanged(){");
-  MESSAGE("*  current  : " << current.data().toString().toStdString());
-  MESSAGE("*  previous : " << previous.data().toString().toStdString());
+   QModelIndexList selectedIndexes;
 
-  //Setting the selection mode of the selected item from the treeview
-  _setVTKSelectionMode( current);
+   //verify if the IOBject is valid and from VTK selection
+   bool fromVTK  = ( strcmp("HEXABLOCK", anIObject->getComponentDataType()) == 0 );
+   if ( !fromVTK || !anIObject->hasEntry() || HEXABLOCKGUI::currentDocGView->getViewWindow() == NULL)
+      return selectedIndexes;
+
+   QString anIOEntry = anIObject->getEntry();
+   int anhexaElemsId;
+   QString aText = "";
 
-//   _selectSalome( current, true );
-//   _selectSalome( previous, false );
-  MESSAGE("}");
+   //extract vtk selection from the model -----------
+   if ( GetNameOfSelectedElements( HEXABLOCKGUI::currentDocGView->getViewWindow(), anIObject, aText ) <= 0 )
+      return selectedIndexes;
+
+   Document_Actor* docActor = dynamic_cast<Document_Actor*>( findActorByEntry( HEXABLOCKGUI::currentDocGView->getViewWindow(),
+                                                                                       anIOEntry.toLatin1() ) );
+   if ( !docActor ) return selectedIndexes;
+   QStringList idList = aText.split(" ");
+   foreach( const QString& id, idList )
+   {
+      if (!id.isEmpty())
+         {
+            //find selection in the model
+            anhexaElemsId = docActor->hexaElemsId[ id.toInt() ];
+            anIOEntry = QString::number( anhexaElemsId );
+
+            selectedIndexes << indexOf( anIOEntry, HEXA_ENTRY_ROLE );
+         }
+   }
+   return selectedIndexes;
 }
 
-void PatternDataSelectionModel::highlightEltsWithAssocs(const QModelIndexList& elts)
+// //===========================================================================
+//                              PatternDataSelectionModel
+// //===========================================================================
+
+PatternDataSelectionModel::PatternDataSelectionModel( QAbstractItemModel * model ):
+SelectionModel( model )
 {
-       try {
-//             if ( HEXABLOCKGUI::selectionMgr() != NULL) HEXABLOCKGUI::selectionMgr()->clearSelected();
-               highlightVTKElts(elts);
-               for( QModelIndexList::const_iterator i_index = elts.begin(); i_index != elts.end(); ++i_index ){
-                       //            _selectVTK( *i_index );
-                       _highlightGEOM( *i_index );
-               }
-       } catch ( ... ) {
-               MESSAGE("Unknown exception was cought !!!");
-       }
+  connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
+           this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection );
+  connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
+           this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
+
 }
 
-void PatternDataSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
+PatternDataSelectionModel::~PatternDataSelectionModel()
 {
-//  MESSAGE("PatternDataSelectionModel::onSelectionChanged(){");
-//  foreach( const QModelIndex& isel, selected.indexes() ){
-//    MESSAGE("*  selected : " << isel.data().toString().toStdString());
-//  }
-//  foreach( const QModelIndex& iunsel, deselected.indexes() ){
-//    MESSAGE("*  unselected : " << iunsel.data().toString().toStdString());
-//  }
-
-//  _theModelSelectionChanged = true;
-//  try {
-//    if ( _salomeSelectionMgr == NULL ) return;
-////     if ( !_theVtkSelectionChanged and  !_theGeomSelectionChanged ) return;
-//
-//    _salomeSelectionMgr->clearSelected();
-//    //   erasePreview(true);
-//    QModelIndexList indexes = selected.indexes();
-//    for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
-//  //     std::cout << "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() << std::endl;
-//      if ( !_theVtkSelectionChanged )  _selectVTK( *i_index );
-//      if ( !_theGeomSelectionChanged ) _highlightGEOM( *i_index );
-//    }
-//    // CS_BP todo SALOMEGUI_Swig.cxx:370
-//    //   indexes = deselected.indexes();
-//    //   for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index )
-//    //     _unselectSalome( *i_index);
-//  } catch ( ... ) {
-//    MESSAGE("Unknown exception was cought !!!");
-//  }
-//  _theModelSelectionChanged = false;
-
-//  MESSAGE("}");
+  disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
+          this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
+  disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
+          this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
 }
 
-void PatternDataSelectionModel::salomeSelectionChanged()
-{
-  MESSAGE("PatternDataSelectionModel::salomeSelectionChanged(){");
-  try {
-    QModelIndex toSelect;
-
-    if ( _salomeSelectionMgr == NULL ) return;
-    SALOME_ListIO salomeSelected;
-  //   _salomeSelectionMgr->selectedObjects( salomeSelected, SVTK_Viewer::Type() );//salomeSelected.Extent()
-    _salomeSelectionMgr->selectedObjects( salomeSelected, NULL, false );
-    if ( salomeSelected.IsEmpty() ){
-      MESSAGE("*  salomeSelected.IsEmpty()");
-      salomeNothingSelected = true;
-      clearSelection();
-      return;
-    }
 
-    Handle(SALOME_InteractiveObject) anIObject;
-
-    SALOME_ListIteratorOfListIO it(salomeSelected);
-    for( ; it.More(); it.Next()){
-      anIObject = it.Value(); //anIObject->getName()
-      toSelect = _geomSelectionChanged( anIObject );// is it comming from GEOM?
-      if ( !toSelect.isValid() ){
-        toSelect = _vtkSelectionChanged( anIObject ); ;// or VTK?...
-        if ( toSelect.isValid() )
-          MESSAGE("*  OK : selection from VTK");
-      } else {
-        MESSAGE("*  OK : selection from GEOM");
-      }
-    }
-    salomeNothingSelected = false;
-  } catch ( ... ) {
-    MESSAGE("*  Unknown exception was cought !!!");
-  }
-  MESSAGE("}");
+void PatternDataSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous )
+{
+  //Setting the selection mode of the selected item from the treeview
+  HEXABLOCKGUI::currentDocGView->setSelectionMode( current );
+  HEXABLOCKGUI::currentOccGView->setSelectionMode( current );
 }
 
-QModelIndex PatternDataSelectionModel::_geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
+void PatternDataSelectionModel::highlightTreeItems(QModelIndexList& indexes,
+                                                   Qt::GlobalColor bgColor,
+                                                   Qt::GlobalColor fgColor, bool only)
 {
-  MESSAGE("PatternDataSelectionModel::_geomSelectionChanged(){");
-  QModelIndexList assocsIndexes;// elements of the model which is associated to the geom object and that is to be selected
-  QModelIndex assocIndex;
-
-  if (HEXABLOCKGUI::assocInProgress) return assocIndex;
-  bool fromGEOM = ( strcmp("GEOM", anIObject->getComponentDataType()) == 0 );
-  if ( !fromGEOM ) return assocIndex;
-  if (!_salomeSelectionMgr) return assocIndex;
+    if (indexes.count() == 0)
+        return;
 
-  QString aName;
-  GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject( anIObject );
+    if (only)
+        unhighlightTreeItems();
 
-  int anIndex = -1;
-  if ( GEOMBase::IsShape(aGeomObj) ){
-    aName = GEOMBase::GetName(aGeomObj);
-    TColStd_IndexedMapOfInteger anIndexes;
-    _salomeSelectionMgr->GetIndexes(anIObject, anIndexes);
-    if ( anIndexes.Extent() == 1 )
-      anIndex = anIndexes(1);
-      QString aGeomObjStudyEntry = aGeomObj->GetStudyEntry();
-      QString aGeomObjModelEntry = aGeomObjStudyEntry + "," + QString::number(anIndex) + ";";
-      assocsIndexes = _indexListOf( aGeomObjModelEntry, HEXA_ASSOC_ENTRY_ROLE );
-      if ( !_theModelSelectionChanged && assocsIndexes.count()>0 && assocsIndexes[0].isValid() ){ // select in model
-         _theGeomSelectionChanged = true;
-         setCurrentIndex( assocsIndexes[0], QItemSelectionModel::Clear );  //CS_TEST
-         setCurrentIndex( assocsIndexes[0], QItemSelectionModel::SelectCurrent );
-         _theGeomSelectionChanged = false;
-      } else {
-        clearSelection();
-      }
+    // * highlight item
+    QAbstractItemModel* theModel = (QAbstractItemModel*) model();
+    foreach( const QModelIndex& anItemIndex, indexes )
+    {
+        if (anItemIndex.isValid())
+        {
+            theModel->setData(anItemIndex, fgColor, Qt::ForegroundRole);
+            theModel->setData(anItemIndex, bgColor, Qt::BackgroundRole);
+            currentHighlightedItems << anItemIndex;
+        }
     }
 
-  MESSAGE("}");
-
-  if (assocsIndexes.count() > 0)
-  {
-//       HEXABLOCKGUI::currentVtkView->setFocus();
-         highlightVTKElts(assocsIndexes);
-         return assocsIndexes[0];
-  }
-  return assocIndex;
+    // * scroll to the first highlighted item in the tree
+    HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance();
+    if (module != NULL && indexes[0].isValid())
+        module->getPatternDataTreeView()->scrollTo(indexes[0]);
 }
 
-QModelIndex PatternDataSelectionModel::_vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
+void PatternDataSelectionModel::unhighlightTreeItems(bool clearSelected)
 {
-  MESSAGE("PatternDataSelectionModel::_vtkSelectionChanged(){");
-  QModelIndex anIOIndex;// // the element of the model which is associated to the Interactive object and that is to be selected
-
-  bool fromVTK  = ( strcmp("HEXABLOCK", anIObject->getComponentDataType()) == 0 );
-  if ( !fromVTK ) return anIOIndex;
-
-  SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
-  if ( !currentVTKViewWindow )  return anIOIndex;
-  if ( !anIObject->hasEntry() ) return anIOIndex;
-
-  QString anIOEntry = anIObject->getEntry();
-  Document_Actor *anDocActor = NULL;
-  int anhexaElemsId;
-
-  QString aText = "";
-  if ( GetNameOfSelectedElements( currentVTKViewWindow, anIObject, aText ) <= 0 ) return anIOIndex;
-  anDocActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, anIOEntry.toLatin1() ) );
-  if ( !anDocActor ) return anIOIndex;
-  anhexaElemsId = anDocActor->hexaElemsId[ aText.toInt() ];
-  anIOEntry = QString::number( anhexaElemsId );
-  anIOIndex = _indexOf( anIOEntry, HEXA_ENTRY_ROLE );
-
-  if ( !_theModelSelectionChanged && anIOIndex.isValid() ){ // select in model
-    _theVtkSelectionChanged = true;
+    if (clearSelected)
+        clearSelection();
+    if (currentHighlightedItems.count() == 0)
+        return;
 
-    //Temporary Debug for hexa selection -----------------------------------------------------------------
-    if (getSelectionFilter() == HEXA_TREE)
+    QAbstractItemModel* theModel = (QAbstractItemModel*) model();
+    foreach( const QModelIndex& anItemIndex, currentHighlightedItems)
     {
-       DocumentModel               *docModel = NULL;
-       const QSortFilterProxyModel *pModel   = dynamic_cast<const QSortFilterProxyModel *>( model() );
-
-       if ( pModel != NULL){
-               docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel() );
-               if ( docModel != NULL && anIOIndex.isValid())
-               {
-                       //get the selected quad
-                       HEXA_NS::Quad* quad = docModel->getHexaPtr<HEXA_NS::Quad*>(anIOIndex);
-                       if (quad != NULL)
-                       {
-                               //get the hexa the quad belongs to
-                               HEXA_NS::Hexa* hexa = docModel->getQuadHexa(quad);
-                               if (hexa != NULL) //convert the hexa to a QModelIndex so we can select it in the model
-                                       anIOIndex = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(hexa));
-                               else
-                               {
-                                       SUIT_MessageBox::critical( 0,
-                                                                       tr("HexaBlock"),
-                                                                       tr("The Hexahedron This quad belongs to has been deleted!"));
-                                       return anIOIndex;
-                               }
-                       }
-               }
-       }
-    }//end if HEXA_TREE------------------------------------------------------------------------------------
-
-    setCurrentIndex( anIOIndex, QItemSelectionModel::Clear );
-    setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent );
-    _theVtkSelectionChanged = false;
-  } else {
-    clearSelection();
-  }
-
-//  if (anIOIndex.isValid())
-//       _selectVTK(anIOIndex);
-
-//  if (anIOIndex.isValid())
-//  {
-//       QModelIndexList l;
-//       l << anIOIndex;
-//       highlightVTKElts(l);
-//       _highlightGEOM(anIOIndex); // JMD test à faire
-//  }
-  MESSAGE("}");
-  return anIOIndex;
-}
-
-
-SVTK_ViewWindow* PatternDataSelectionModel::_getVTKViewWindow()
-{
-//  SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView;
-  return HEXABLOCKGUI::currentVtkView;
+        if (anItemIndex.isValid())
+        {
+            theModel->setData(anItemIndex, Qt::darkGreen, Qt::ForegroundRole);
+            theModel->setData(anItemIndex, Qt::white, Qt::BackgroundRole);
+        }
+    }
+    currentHighlightedItems.clear();
 }
 
-
-OCCViewer_ViewWindow*  PatternDataSelectionModel::_getOCCViewWindow()
+QModelIndexList PatternDataSelectionModel::getGeomAssociations(const QModelIndex& dataIndex)
 {
-//  OCCViewer_ViewWindow* aOccView = HEXABLOCKGUI::currentOccView;
-//  MESSAGE(" dans OCCViewer" << aOccView);
-  return HEXABLOCKGUI::currentOccView;
-}
-
+    QModelIndexList geomIndexList;
+    DocumentModel*               docModel = getDocModel();
+    PatternGeomSelectionModel*   pGSModel = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
+    if (docModel == NULL || pGSModel == NULL)
+        return geomIndexList;
 
-QModelIndex PatternDataSelectionModel::_indexOf( const QString& anEntry, int role )
-{
-  QModelIndex eltIndex; // element (vertex, edge, quad) of model
-  const QAbstractItemModel* theModel = model();
-  if ( !theModel ) return eltIndex;
-  QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
-                                          role,
-                                          anEntry,
-                                          1,
-                                          Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
-  if ( theIndexes.count()>0 )
-    eltIndex = theIndexes[0] ;
-  return eltIndex;
-}
+    const QSortFilterProxyModel *pModel   = dynamic_cast<const QSortFilterProxyModel *>( model() );
+    HEXA_NS::Vertex* vertex = docModel->getHexaPtr<HEXA_NS::Vertex*>(dataIndex);
+    HEXA_NS::Edge*   edge   = docModel->getHexaPtr<HEXA_NS::Edge*>(dataIndex);
+    HEXA_NS::Quad*   quad   = docModel->getHexaPtr<HEXA_NS::Quad*>(dataIndex);
+    QModelIndex index = pModel->mapToSource(dataIndex);
 
+    if (vertex != NULL)
+        geomIndexList << docModel->getVertexAssociation( index );
+    else if (edge != NULL)
+        geomIndexList = docModel->getEdgeAssociations( index );
+    else if ( quad != NULL)
+        geomIndexList = docModel->getQuadAssociations( index );
 
-QModelIndexList PatternDataSelectionModel::_indexListOf( const QString& anEntry, int role )
-{
-  QModelIndexList theIndexes; // element (vertex, edge, quad) of model
-  const QAbstractItemModel* theModel = model();
-  if ( !theModel ) return theIndexes;
-  theIndexes = theModel->match( theModel->index(0, 0),
-                                          role,
-                                          anEntry,
-                                          -1,
-                                          Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
-  return theIndexes;
+    return geomIndexList;
 }
 
-
-void PatternDataSelectionModel::_setVTKSelectionMode( const QModelIndex& eltIndex )
+void PatternDataSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
 {
-  MESSAGE("PatternDataSelectionModel::_setVTKSelectionMode( "<< eltIndex.data().toString().toStdString() << " )");
-  QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE );
-  if ( !treeVariant.isValid() ) return;
-  int eltType = treeVariant.toInt();
-
-//  if ( (_selectionFilter != -1) and ( _selectionFilter != eltType ) ) return;
-  if ( _selectionFilter == eltType ) return;
-
-  switch ( eltType ){
-    case VERTEX_TREE :
-    case VERTEX_DIR_TREE : setVertexSelection(); MESSAGE("VERTEX"); break;
-    case EDGE_TREE :
-    case EDGE_DIR_TREE :   setEdgeSelection(); MESSAGE("EDGE");     break;
-    case QUAD_TREE :
-    case QUAD_DIR_TREE :   setQuadSelection(); MESSAGE("QUAD");     break;
-    case HEXA_TREE :
-    case HEXA_DIR_TREE :   setHexaSelection();  MESSAGE("HEXA");   break;
-    case PROPAGATION_TREE :
-    case PROPAGATION_DIR_TREE :   setEdgeSelection(); MESSAGE("PROPAGATION");   break;
-//  CellSelection,
-//  EdgeOfCellSelection,
-//  VolumeSelection,
-//  ActorSelection
-  }
-}
-
+    QModelIndexList indexes = selected.indexes();
+    int nbSelected = indexes.count();
+    if (nbSelected == 0)
+        return;
 
-void PatternDataSelectionModel::highlightVTKElts( const QModelIndexList& elts )
-{
-       if (!elts.size()) return;
-
-       SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
-       if ( currentVTKViewWindow == NULL ) return;
-       SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
-       if ( selector == NULL ) return;
-
-       // document selection
-       Document_Actor* docActor = NULL;
-       Handle(SALOME_InteractiveObject) docIO;
-//     Handle(SALOME_InteractiveObject) docIO2; //JMD
-
-       // element highlight
-       TColStd_MapOfInteger aMap;
-//     TColStd_MapOfInteger aMap2;
-       QList<int>::const_iterator anIter;
-       int vtkElemsId;
-
-       // data from model
-       QString docEntry;
-       QVariant docEntryVariant    = elts[0].data( HEXA_DOC_ENTRY_ROLE );
-
-       if ( !docEntryVariant.isValid() ){
-               //INFOS("data from model not valid");
-               return;
-       }
-
-       docEntry = docEntryVariant.toString();
-
-       // Select the document in Salome
-       docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
-       if ( docActor == NULL) return;
-
-
-       //   // Set selection mode in VTK view
-//     currentVTKViewWindow->SetSelectionMode(VolumeSelection);
-       docIO = docActor->getIO();
-
-
-
-//     QString autreDocentry  = "toti";
-//     Associate_Actor* associateActor = dynamic_cast<Associate_Actor*>( findActorByEntry( currentVTKViewWindow, autreDocentry.toLatin1() ) );
-//     docIO2 = associateActor->getIO();
-
-       // Highlight in vtk view the element from document
-       //bool rr = true;
-
-       QString eltEntry;
-       foreach( const QModelIndex& iElt, elts ){
-               eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString();
-               vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ];
-               if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
-//             if (rr) {
-//               if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
-//             }
-//             else
-//             {
-//               if ( vtkElemsId > 0 ) aMap2.Add( vtkElemsId );
-//             }
-//             rr = ! rr;
-       }
-
-       selector->AddOrRemoveIndex( docIO, aMap, false ); //true
-//     selector->RemoveIObject(docActor);
-       currentVTKViewWindow->highlight( docIO, true, true );
-//     Document_Actor* docActor = NULL;
-//             QVariant docEntryVariant    = selected.data( HEXA_DOC_ENTRY_ROLE );
-//             if ( docEntryVariant.isValid() ){
-//                     QString docEntry = docEntryVariant.toString();
-//                     docActor = dynamic_cast<Document_Actor*>( findActorByEntry( HEXABLOCKGUI::currentVtkView, docEntry.toLatin1() ) );
-//                     if ( docActor != NULL) HEXABLOCKGUI::currentVtkView->getView()->highlight( docActor->getIO(), false,  false );
-//             }
-//     currentVTKViewWindow->getView()->SetColor(docIO, QColor("blue"));
-
-
-//     selector->AddOrRemoveIndex( docIO2, aMap2, false );
-//     currentVTKViewWindow->highlight( docIO2, true, true );
-}
+    // ** unhighlight current highlighted items in the trees
+    PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
+    if (pgsm == NULL)
+        return;
+    unhighlightTreeItems(false);
 
-//SUIT_ViewManager* PatternDataSelectionModel::initOccViewManager()
-//{
-//  SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
-//  SUIT_ViewManager* occVm = anApp->getViewManager( OCCViewer_Viewer::Type(), true );
-//  SVTK_ViewWindow* viewWindow = dynamic_cast<SVTK_ViewWindow*>(svw);
-//  return viewWindow;
-//}
-SUIT_ViewWindow* PatternDataSelectionModel::initOccViewManager()
-{
- SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
- SUIT_ViewManager* occVm = anApp->getViewManager( OCCViewer_Viewer::Type(), true );
+    QModelIndexList associatedGeomIndexes = getGeomAssociations(indexes[0]); //Mono Selection
+    if (associatedGeomIndexes.count() == 0)
+        pgsm->unhighlightTreeItems();
 
- QVector<SUIT_ViewWindow*> viewS = occVm->getViews ();
+    // ** highlight association in geometry tree
+    pgsm->highlightTreeItems(associatedGeomIndexes);
 
- int nb = viewS.count();
+    // ** highlight association in the vtk view
+    HEXABLOCKGUI::currentDocGView->highlight(indexes);
 
- MESSAGE("????HexaBaseDialog::initOccView number of : " << nb);
+    // ** highlight association in the occ view
+    HEXABLOCKGUI::currentOccGView->highlight(indexes);
 
- if (nb == 1)
- {
-   MESSAGE(" OK     ????HexaBaseDialog::initOccView number of : " << nb);
-   return viewS.first();
- }
+    if (!infoMode || nbSelected > 1)
+        return;
 
- return NULL;
+    // ** Show informations of the selected element
+    QModelIndex elt = indexes[0];
+    showEltInfo(elt);
 }
 
-// 1 vertex -> 1 point
-// 1 edge   -> n lines + points(deb,fin)
-// 1 quad   -> n faces
-void PatternDataSelectionModel::_highlightGEOM( const QMultiMap<QString, int>&  entrySubIDs )
+void PatternDataSelectionModel::geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
 {
-  MESSAGE("PatternDataSelectionModel::_highlightGEOM( const QMultiMap<QString, int>&  entrySubIDs ){");
-  MESSAGE("debut    entry => "<< entrySubIDs.count());
-
-  OCCViewer_ViewWindow*  occView = _getOCCViewWindow();
-  if ( occView == NULL ) {
-//     occView =  (OCCViewer_ViewWindow*)initOccViewManager();
-//     if ( occView == NULL )
-         return;
-  }
-  MESSAGE("step 1    occView=> " << occView);
-
-  MESSAGE("step 1    entry => ");
-  SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>( occView->getViewManager()->getViewModel() );
-  if (!soccViewer) return;
-  MESSAGE("step 2    entry => ");
-  _PTR(Study) aStudy = GetActiveStudyDocument();
-  if (!aStudy) return;
-  MESSAGE("step 3    entry => ");
-
-  CORBA::Object_var     aCorbaObj = CORBA::Object::_nil();
-  GEOM::GEOM_Object_var aGeomObj  = GEOM::GEOM_Object::_nil();
-  erasePreview(true);
-  MESSAGE("Avant    entry => "<< entrySubIDs.count());
-  foreach ( QString entry, entrySubIDs.keys() ){
-    _PTR(SObject) aSChild = aStudy->FindObjectID( entry.toStdString() );
-    MESSAGE("*    entry => "<< entry.toStdString());
-    aCorbaObj = corbaObj( aSChild );
-    aGeomObj = GEOM::GEOM_Object::_narrow( aCorbaObj );
-    if ( !CORBA::is_nil(aGeomObj) ){
-      MESSAGE("*  !CORBA::is_nil(aGeomObj)");
-      QString objIOR = GEOMBase::GetIORFromObject( aGeomObj._retn() );
-      Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIORinGEOMAISShape( objIOR );//, true );
-      if ( !aSh.IsNull() ){
-        MESSAGE("*  !aSh.IsNull() ");
-        TColStd_IndexedMapOfInteger anIndexes;
-        foreach ( int subid, entrySubIDs.values(entry) ){
-          if ( subid != -1 )
-            anIndexes.Add( subid );
-        }
-        if ( anIndexes.Extent() > 0 ){ // if it's a sub-shape
-          MESSAGE("*  a sub-shape");
-          aSh->highlightSubShapes( anIndexes, true );
-          soccViewer->Repaint();
-        } else {  // or a main shape
-//             std::cout << "aSh->getIO() => " << aSh->getIO() << std::endl;
-//           getDisplayer()->SetDisplayMode(0);
-//           soccViewer->setColor( aSh->getIO(), QColor( Qt::red ), true );
-//           soccViewer->switchRepresentation( aSh->getIO(), 2 );
-          MESSAGE("*  a main shape");
-//           globalSelection();
-          soccViewer->highlight( aSh->getIO(), true, true );
-        }
-      }
-    }
-  }
+//   if (HEXABLOCKGUI::assocInProgress) return;
 
-  MESSAGE("}");
+   PatternGeomSelectionModel*  pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
+   if (pgsm == NULL) return;
+
+   QModelIndex geomModelIndex = pgsm->getModelIndex(anIObject);
+   if (!geomModelIndex.isValid())
+       return;
+   pgsm->select( geomModelIndex, QItemSelectionModel::SelectCurrent );
 }
 
 
-void PatternDataSelectionModel::_highlightGEOM( const QModelIndex & anEltIndex )
+void PatternDataSelectionModel::vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
 {
-  MESSAGE("PatternDataSelectionModel::_highlightGEOM(" << anEltIndex.data().toString().toStdString() << ")");
-  // getting association(s) from model
-  QList<DocumentModel::GeomObj> assocs;
-  QMultiMap< QString, int >     assocEntrySubIDs;
-  DocumentModel               *docModel = NULL;
-  const QSortFilterProxyModel *pModel   = dynamic_cast<const QSortFilterProxyModel *>( model() );
-
-  if ( !pModel ) return;
-  docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel() );
-  if ( !docModel ) return;
-  assocs = docModel->getAssociations( pModel->mapToSource(anEltIndex) );
-  foreach( const DocumentModel::GeomObj& anAssoc, assocs )
-  {
-//       MESSAGE("              dedans " << anAssoc.entry.toStdString());
-//       MESSAGE("                   + " << anAssoc.subid.toInt());
-         assocEntrySubIDs.insert( anAssoc.entry, anAssoc.subid.toInt() );
-
-  }
-  _highlightGEOM( assocEntrySubIDs );
-  MESSAGE("}");
-}
+    QModelIndexList selectedIndexes =  getSelectionFromModel(anIObject);
+    if (selectedIndexes.count() == 0)
+    {
+        clearSelection();
+        return;
+    }
+    QModelIndex anIOIndex = selectedIndexes[0]; //Monoselection
 
+    //Temporary Debug for hexa selection ------------------------------
+    if (HEXABLOCKGUI::currentDocGView->getSelectionMode() == HEXA_TREE)
+    {
+        DocumentModel* docModel = getDocModel();
+        if ( docModel != NULL && anIOIndex.isValid())
+        {
+            //get the selected quad
+            HEXA_NS::Quad* quad = docModel->getHexaPtr<HEXA_NS::Quad*>(anIOIndex);
+
+            if (quad != NULL)
+            {
+                //get the hexa the quad belongs to
+                HEXA_NS::Hexa* hexa = docModel->getQuadHexa(quad);
+                if (hexa != NULL) //convert the hexa to a QModelIndex so we can select it in the model
+                    anIOIndex = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(hexa));
+                else
+                {
+                    SUIT_MessageBox::critical( 0,
+                            tr("HexaBlock"),
+                            tr("The Hexahedron this quad belongs to has been deleted!"));
+                    return;
+                }
+            }
+        }
+    }//end if HEXA_TREE-----------------------------------------------
 
-void PatternDataSelectionModel::_selectVTK( const QModelIndex& eltIndex )
-{
-  MESSAGE("PatternDataSelectionModel::_selectVTK( "<< eltIndex.data().toString().toStdString() << ")");
-  SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
-  if ( currentVTKViewWindow == NULL ) return;
-  SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
-  if ( selector == NULL ) return;
-
-  // document selection
-  Document_Actor* docActor = NULL;
-  Handle(SALOME_InteractiveObject) docIO;
-  SALOME_ListIO aList;
-
-  // element highlight
-  TColStd_MapOfInteger aMap;
-  QList<int>::const_iterator anIter;
-  int vtkElemsId;
-
-  // data from model
-  QString eltEntry;
-  QString docEntry;
-  QVariant entryVariant    = eltIndex.data( HEXA_ENTRY_ROLE );
-  QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE );
-
-  if ( !entryVariant.isValid() ){
-    //INFOS("entryVariant not valid");
-    return;
-  }
-  if ( !docEntryVariant.isValid() ){
-    //INFOS("docEntryVariant not valid");
-    return;
-  }
-
-  eltEntry = entryVariant.toString();
-  docEntry = docEntryVariant.toString();
-
-  // Select the document in Salome
-  docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
-  if ( docActor == NULL ) return;
-
-  // Set selection mode in VTK view
-  //_setVTKSelectionMode( eltIndex, currentVTKViewWindow );
-
-// if ( _salomeSelectionMgr == NULL ) return;
-//   _salomeSelectionMgr->selectedObjects( aList );
-//   std::cout<<"aList.Extent() => " << aList.Extent() << std::endl;
-//   aList.Append(docIO);
-//   _salomeSelectionMgr->setSelectedObjects( aList, true );//false );//true ); //CS_BP false?
-  docIO = docActor->getIO();
-
-  // Highlight in vtk view the element from document
-  vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ];// get vtk ids from actor
-  if ( vtkElemsId > 0 ) // CS_BP ?: erreur si 1er elt == vertex (0,0,0)
-    aMap.Add( vtkElemsId );
-//     for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
-//       aMap.Add(*anIter);
-//     }
-  selector->AddOrRemoveIndex( docIO, aMap, false );
-  currentVTKViewWindow->highlight( docIO, true, true );
-
-  MESSAGE("}");
+    //select the element in the model
+    select( anIOIndex, QItemSelectionModel::SelectCurrent );
 }
 
-GroupsSelectionModel::GroupsSelectionModel( QAbstractItemModel * model ):
-QItemSelectionModel( model )
+// //===========================================================================
+//                              PatternGeomSelectionModel
+// //===========================================================================
+
+PatternGeomSelectionModel::PatternGeomSelectionModel( QAbstractItemModel * model ):
+SelectionModel( model )
 {
   connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
            this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
   connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
-           this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
+           this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
 }
 
-GroupsSelectionModel::~GroupsSelectionModel()
+PatternGeomSelectionModel::~PatternGeomSelectionModel()
 {
   disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
           this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
@@ -810,140 +492,150 @@ GroupsSelectionModel::~GroupsSelectionModel()
           this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
 }
 
+void PatternGeomSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous )
+{
+  //Setting the selection mode of the selected item from the treeview}
+  HEXABLOCKGUI::currentDocGView->setSelectionMode( current );
+  HEXABLOCKGUI::currentOccGView->setSelectionMode( current );
+}
 
+void PatternGeomSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
+{
+    DocumentModel* docModel = NULL;
+    const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
+    if ( pModel != NULL)
+        docModel = dynamic_cast<DocumentModel*>(pModel->sourceModel());
 
+    QModelIndexList indexes = selected.indexes();
+    if (indexes.count() == 0 || docModel == NULL)
+        return;
 
-QModelIndex GroupsSelectionModel::indexBy( int role, const QVariant& var )
-{
-  QModelIndex eltIndex; // element (vertex, edge, quad) of model
-  const QAbstractItemModel* theModel = model();
-  if ( !theModel ) return eltIndex;
-  QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
-                                          role,
-                                          var,
-                                          1,
-                                          Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString );
-  if ( theIndexes.count()>0 )
-    eltIndex = theIndexes[0] ;
-  return eltIndex;
-}
+    // ** unhighlight current highlighted items in the trees
+    PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
+    if (pdsm == NULL)
+        return;
+    unhighlightTreeItems(false);
 
+    //find the corresponding element in the model
+    HEXA_NS::SubShape* eltSubShape = dynamic_cast<HEXA_NS::SubShape*>(docModel->getHexaPtr(indexes[0]));
+    if (eltSubShape == NULL) return;
 
-SVTK_ViewWindow* GroupsSelectionModel::_getVTKViewWindow()
-{
-//  SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView;
-  return HEXABLOCKGUI::currentVtkView;
-}
+    HEXA_NS::NewShape* subShapeParent = eltSubShape->getParentShape();
+    if (subShapeParent == NULL) return;
 
+    QString parentShapeName = subShapeParent->getName();
+    QString subId = QString::number(eltSubShape->getIdent());
+    QString aGeomObjModelEntry = parentShapeName + "," + subId + ";";
 
-void GroupsSelectionModel::_highlightGroups( const QModelIndex& eltIndex )
+    QModelIndexList assocsIndexes = pdsm->indexListOf(aGeomObjModelEntry, HEXA_ASSOC_ENTRY_ROLE);
+    if (assocsIndexes.count() == 0)
+        pdsm->unhighlightTreeItems();
+
+    // ** highlight associations in the data tree
+    pdsm->highlightTreeItems(assocsIndexes);
+
+    // ** highlight associations in the vtk view
+    HEXABLOCKGUI::currentDocGView->highlight(assocsIndexes);
+
+    // ** highlight the selected element in the occ view
+    QMultiMap<QString, int>  entrySubIDs;
+    entrySubIDs.insert(parentShapeName, eltSubShape->getIdent());
+    HEXABLOCKGUI::currentOccGView->highlight(entrySubIDs);
+}
+
+QModelIndex PatternGeomSelectionModel::getModelIndex(const Handle(SALOME_InteractiveObject)& anIObject)
 {
-  const GroupsModel* m = dynamic_cast<const GroupsModel *>( model() );
-
-// ---- VTK ----
-  if ( m == NULL ) return;
-  SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
-  if ( currentVTKViewWindow == NULL ) return;
-  SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
-  if ( selector == NULL ) return;
-
-// ----  vtkActor
-  // document selection
-  Document_Actor* docActor = NULL;
-  Handle(SALOME_InteractiveObject) docIO;
-  SALOME_ListIO aList;
-
-  // element highlight
-  TColStd_MapOfInteger aMap;
-  QList<int>::const_iterator anIter;
-  int vtkElemsId;
-
-
-
-  // debut ** data from model
-  int     eltType;
-  QString docEntry;
-
-  QVariant treeVariant        = eltIndex.data( HEXA_TREE_ROLE );
-  QVariant docEntryVariant    = eltIndex.data( HEXA_DOC_ENTRY_ROLE );
-
-  if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){
-    //INFOS("data from model not valid");
-    return;
-  }
-
-  eltType  = treeVariant.toInt();
-  docEntry = docEntryVariant.toString();
-
-  if ( eltType != GROUP_TREE ){
-    //INFOS("bad element type : not a group item" << eltType );
-    return;
-  }
-  // fin ** data from model
-
-  // Select the document in Salome
-  docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
-  if ( docActor == NULL) return;
-  docIO = docActor->getIO();
-
-  // Highlight in vtk view the element from document
-  DocumentModel::Group kind;
-  QModelIndexList iElements = m->getGroupElements( eltIndex, kind );
-
-  // Set selection mode in VTK view
-  switch (kind){
-  case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: currentVTKViewWindow->SetSelectionMode(VolumeSelection); break;
-  case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: currentVTKViewWindow->SetSelectionMode(FaceSelection);   break;
-  case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: currentVTKViewWindow->SetSelectionMode(EdgeSelection);   break;
-  case HEXA_NS::VertexNode: currentVTKViewWindow->SetSelectionMode(NodeSelection); break;
-  }
-
-  QString eltEntry;
-  foreach( const QModelIndex& iElt, iElements ){
-    eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString();
-    vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ];
-    if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
-  }
-
-  selector->AddOrRemoveIndex( docIO, aMap, false );
-  currentVTKViewWindow->highlight( docIO, true, true );
+    QModelIndex result;
+    DocumentModel               *docModel = NULL;
+    const QSortFilterProxyModel *pModel   = dynamic_cast<const QSortFilterProxyModel *>( model() );
+    if ( pModel != NULL)
+        docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel());
+
+    if ( docModel == NULL || HEXABLOCKGUI::selectionMgr() == NULL ||
+            HEXABLOCKGUI::currentOccGView->getViewWindow() == NULL)
+        return result;
+
+    //extract associated elements in the model
+    TColStd_IndexedMapOfInteger anIndexes;
+    HEXABLOCKGUI::selectionMgr()->GetIndexes(anIObject, anIndexes);
+    if (anIndexes.Extent() == 0) return result;
+    QString aGeomObjStudyEntry = anIObject->getEntry();
+    QString aGeomObjModelEntry = docModel->getGeomObjName(aGeomObjStudyEntry) + "," + QString::number(anIndexes(1));
+
+    HEXA_NS::SubShape*    ssh =  docModel->getGeomPtr(aGeomObjModelEntry);
+    HEXA_NS::VertexShape* vSh =  dynamic_cast<HEXA_NS::VertexShape*>(ssh);
+    HEXA_NS::EdgeShape*   eSh =  dynamic_cast<HEXA_NS::EdgeShape*>(ssh);
+    HEXA_NS::FaceShape*   fSh =  dynamic_cast<HEXA_NS::FaceShape*>(ssh);
 
+    if (vSh != NULL)
+        result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(vSh));
+    else if (eSh != NULL)
+        result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(eSh));
+    else if (fSh != NULL)
+        result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(fSh));
+
+    return result;
 }
 
-void GroupsSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
+void PatternGeomSelectionModel::highlightTreeItems(QModelIndexList& indexes,
+                                                   Qt::GlobalColor bgColor,
+                                                   Qt::GlobalColor fgColor, bool only)
 {
-  MESSAGE("GroupsSelectionModel::onSelectionChanged");
-  try {
-    //     if ( _salomeSelectionMgr == NULL ) return;
-    //     _salomeSelectionMgr->clearSelected();
-    //   erasePreview(true);
-    QModelIndexList indexes = selected.indexes();
-    for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
-      MESSAGE( "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() );
-      _highlightGroups( *i_index );
+    if (indexes.count() == 0)
+        return;
+
+    if (only)
+        unhighlightTreeItems();
+
+    // * highlight items
+    QAbstractItemModel* theModel = (QAbstractItemModel*) model();
+    foreach( const QModelIndex& anItemIndex, indexes )
+    {
+        if (anItemIndex.isValid())
+        {
+            theModel->setData(anItemIndex, fgColor, Qt::ForegroundRole);
+            theModel->setData(anItemIndex, bgColor, Qt::BackgroundRole);
+            currentHighlightedItems << anItemIndex;
+        }
     }
 
-    // CS_BP todo SALOMEGUI_Swig.cxx:370
-    //   indexes = deselected.indexes();
-    //   for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index )
-    //     _unselectSalome( *i_index);
-  } catch ( ... ) {
-    MESSAGE("Unknown exception was cought !!!");
-  }
+    // * scroll to the first highlighted item in the tree
+    HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance();
+    if (module != NULL && indexes[0].isValid())
+        module->getPatternGeomTreeView()->scrollTo(indexes[0]);
+}
 
+void PatternGeomSelectionModel::unhighlightTreeItems(bool clearSelected)
+{
+    if (clearSelected)
+        clearSelection();
+    if (currentHighlightedItems.count() == 0)
+        return;
+    QAbstractItemModel* theModel = (QAbstractItemModel*) model();
+    foreach( const QModelIndex& anItemIndex, currentHighlightedItems)
+    {
+        if (anItemIndex.isValid())
+        {
+            theModel->setData(anItemIndex, Qt::darkGreen, Qt::ForegroundRole);
+            theModel->setData(anItemIndex, Qt::white, Qt::BackgroundRole);
+        }
+    }
+    currentHighlightedItems.clear();
 }
 
-MeshSelectionModel::MeshSelectionModel( QAbstractItemModel * model ):
-QItemSelectionModel( model )
+// //===========================================================================
+//                              GroupsSelectionModel
+// //===========================================================================
+GroupsSelectionModel::GroupsSelectionModel( QAbstractItemModel * model ):
+SelectionModel( model )
 {
   connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
-           this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
+           this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection );
   connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
-           this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
+           this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
 }
 
-
-MeshSelectionModel::~MeshSelectionModel()
+GroupsSelectionModel::~GroupsSelectionModel()
 {
   disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
           this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
@@ -951,499 +643,71 @@ MeshSelectionModel::~MeshSelectionModel()
           this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
 }
 
-
-QModelIndex MeshSelectionModel::indexBy( int role, const QVariant& var )
+void GroupsSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
 {
-  QModelIndex eltIndex; // element (vertex, edge, quad) of model
-  const QAbstractItemModel* theModel = model();
-  if ( !theModel ) return eltIndex;
-  QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
-                                          role,
-                                          var,
-                                          1,
-                                          Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString );
-  if ( theIndexes.count()>0 )
-    eltIndex = theIndexes[0] ;
-  return eltIndex;
-}
+    QModelIndexList indexes = selected.indexes();
+    int nbSelected = indexes.count();
+    if (nbSelected == 0)
+        return;
+
+    // ** Highlight the group in the vtk view **/
+    try {
+        for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
+            HEXABLOCKGUI::currentDocGView->highlightGroups( *i_index );
+        }
+    } catch ( ... ) {
+        MESSAGE("Unknown exception was cought !!!");
+    }
 
+    if (!infoMode || nbSelected > 1)
+        return;
 
+    // ** Show informations of the selected element **/
+    QModelIndex elt = indexes[0];
+    showEltInfo(elt);
+}
 
-SVTK_ViewWindow* MeshSelectionModel::_getVTKViewWindow()
+// //===========================================================================
+//                              MeshSelectionModel
+// //===========================================================================
+MeshSelectionModel::MeshSelectionModel( QAbstractItemModel * model ):
+        SelectionModel( model )
 {
-//  SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView;
-  return HEXABLOCKGUI::currentVtkView;
+    connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
+            this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection );
+    connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
+            this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
 }
 
-
-void MeshSelectionModel::_highlightPropagation( const QModelIndex& eltIndex )
+MeshSelectionModel::~MeshSelectionModel()
 {
-  const MeshModel* m = dynamic_cast<const MeshModel *>( model() );
-  if ( m == NULL ) return;
-  SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
-  if ( currentVTKViewWindow == NULL ) return;
-  SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
-  if ( selector == NULL ) return;
-
-  // document selection
-  Document_Actor* docActor = NULL;
-  Handle(SALOME_InteractiveObject) docIO;
-  SALOME_ListIO aList;
-
-  // element highlight
-  TColStd_MapOfInteger aMap;
-  QList<int>::const_iterator anIter;
-  int vtkElemsId;
-
-  // data from model
-  int     eltType;
-  QString docEntry;
-
-  QVariant treeVariant        = eltIndex.data( HEXA_TREE_ROLE );
-  QVariant docEntryVariant    = eltIndex.data( HEXA_DOC_ENTRY_ROLE );
-
-  if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){
-    //INFOS("data from model not valid");
-    return;
-  }
-
-  eltType  = treeVariant.toInt();
-  docEntry = docEntryVariant.toString();
-
-  if ( eltType != PROPAGATION_TREE ){
-    //INFOS("bad element type : not a propagation item" << eltType );
-    return;
-  }
-
-  // Select the document in Salome
-  docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
-  if ( docActor == NULL) return;
-
-//   // Set selection mode in VTK view
-  currentVTKViewWindow->SetSelectionMode(EdgeSelection);
-  docIO = docActor->getIO();
-
-  // Highlight in vtk view the element from document
-  QModelIndexList iEdges = m->getPropagation( eltIndex );
-
-  QString edgeEntry;
-  foreach( const QModelIndex& iEdge, iEdges ){
-    edgeEntry = iEdge.data( HEXA_ENTRY_ROLE ).toString();
-    vtkElemsId = docActor->vtkElemsId[ edgeEntry.toInt() ];
-    if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
-  }
-
-  selector->AddOrRemoveIndex( docIO, aMap, false );
-  currentVTKViewWindow->highlight( docIO, true, true );
+    disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
+            this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
+    disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
+            this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
 }
 
 
-
 void MeshSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
 {
-  MESSAGE("MeshSelectionModel::onSelectionChanged");
-  try {
-    //     if ( _salomeSelectionMgr == NULL ) return;
-    //     _salomeSelectionMgr->clearSelected();
-    //   erasePreview(true);
     QModelIndexList indexes = selected.indexes();
-    for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
-      MESSAGE( "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() );
-      _highlightPropagation( *i_index );
-    }
-
-    // CS_BP todo SALOMEGUI_Swig.cxx:370
-    //   indexes = deselected.indexes();
-    //   for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index )
-    //     _unselectSalome( *i_index);
-  } catch ( ... ) {
-    MESSAGE("Unknown exception was cought !!!");
-  }
-
-}
+    int nbSelected = indexes.count();
+    if (nbSelected == 0)
+        return;
 
+    try {
+        for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
+            HEXABLOCKGUI::currentDocGView->highlightPropagation( *i_index );
+        }
+    } catch ( ... ) {
+        MESSAGE("Unknown exception was cought !!!");
+    }
 
-// //=================================================================================
-// // function : activateSelection
-// // purpose  : Activate selection in accordance with myEditCurrentArgument
-// //=================================================================================
-// void PatternDataSelectionModel::activateSelection()
-// {
-//   erasePreview(false);
-// 
-//   // local selection
-//   if (!myObject->_is_nil() && !isAllSubShapes())
-//   {
-//     GEOM_Displayer* aDisplayer = getDisplayer();
-//     SALOME_View* view = GEOM_Displayer::GetActiveView();
-//     if (view) {
-//       CORBA::String_var aMainEntry = myObject->GetStudyEntry();
-//       Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
-//       if (view->isVisible(io)) {
-//         aDisplayer->Erase(myObject, false, false);
-//         myIsHiddenMain = true;
-//       }
-//     }
-// 
-//     int prevDisplayMode = aDisplayer->SetDisplayMode(0);
-// 
-//     SUIT_ViewWindow* aViewWindow = 0;
-//     SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
-//     if (activeStudy)
-//       aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
-//     if (aViewWindow == 0) return;
-// 
-//     SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
-//     if (aViewManager->getType() != OCCViewer_Viewer::Type() &&
-//         aViewManager->getType() != SVTK_Viewer::Type())
-//       return;
-// 
-//     SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
-//     SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
-//     if (aView == 0) return;
-// 
-//     //TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject);
-// 
-//     TopTools_IndexedMapOfShape aSubShapesMap;
-//     TopExp::MapShapes(myShape, aSubShapesMap);
-//     CORBA::String_var aMainEntry = myObject->GetStudyEntry();
-//     QString anEntryBase = aMainEntry.in();
-// 
-//     TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType());
-//     for (; anExp.More(); anExp.Next())
-//     {
-//       TopoDS_Shape aSubShape = anExp.Current();
-//       int index = aSubShapesMap.FindIndex(aSubShape);
-//       QString anEntry = anEntryBase + QString("_%1").arg(index);
-// 
-//       SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
-//       if (aPrs) {
-//         displayPreview(aPrs, true, false); // append, do not update
-//       }
-//     }
-//     aDisplayer->UpdateViewer();
-//     aDisplayer->SetDisplayMode(prevDisplayMode);
-//   }
-// 
-//   globalSelection(GEOM_ALLSHAPES);
-// }
-
-
-
-
-// SUIT_DataOwnerPtrList aList;
-//   ObjectList::iterator anIter;
-//   for ( anIter = objects.begin(); anIter != objects.end(); ++anIter )
-//   {
-//     QString anEntry = getEntry( *anIter );
-//     LightApp_DataOwner* anOwher = new LightApp_DataOwner( anEntry );
-//     aList.append( anOwher );
-//   }
-// 
-//   SUIT_Session* session = SUIT_Session::session();
-//   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
-//   if ( !app )
-//     return false;
-// 
-//   LightApp_SelectionMgr* aMgr = app->selectionMgr();
-//   if ( !aMgr )
-//     return false;
-// _getVTKViewWindow()
-//   aMgr->setSelecte_getVTKViewWindow()d( aList, false );
-
-
-
-
-
-//   SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
-//   if (!anActor || !anActor->hasIO())
-//     return;
-// 
-//   Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
-//   //mySelectionMgr->clearSelected();
-//   //mySelectionMgr->AddIObject(anIO, false);
-//   SALOME_ListIO aList;
-//   aList.Append(anIO);
-//   mySelectionMgr->setSelectedObjects(aList, false);
-// 
-//   // Remove filter corresponding to the current type from viewer
-//   int aType = myTable->GetType();
-//   int aFilterId = SMESH::UnknownFilter;
-//   if      (aType == SMESH::EDGE  ) aFilterId = SMESH::EdgeFilter;
-//   else if (aType == SMESH::FACE  ) aFilterId = SMESH::FaceFilter;
-//   else if (aType == SMESH::VOLUME) aFilterId = SMESH::VolumeFilter;
-//   Handle(VTKViewer_Filter) aFilter = SMESH::GetFilter(aFilterId);
-//   SMESH::RemoveFilter(aFilterId);
-// 
-//   // get vtk ids
-//   TColStd_MapOfInteger aMap;
-//   QList<int>::const_iterator anIter;
-//   for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
-//     aMap.Add(*anIter);
-//   }
-// 
-//   // Set new selection
-//   activeViewWindow->AddOrRemoveIndex(anIO, aMap, false);
-//   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-//     aViewWindow->highlight( anIO, true, true );
-// 
-//   // insert previously stored filter in viewer if necessary
-//   if (!aFilter.IsNull())
-//     SMESH::SetFilter(aFilter);
-
-
-
-
-
-
-
-
-
-//     //CS_TEST
-//  if(SVTK_Selector* aSelector = aView->GetSelector()){
-//             const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
-//             SALOME_ListIteratorOfListIO anIter(aListIO);
-//             for(; anIter.More(); anIter.Next()){
-//               Handle(SALOME_InteractiveObject) anIO = anIter.Value();
-//     _PTR(Study) aStudy  = HEXABLOCKGUI::activeStudy()->studyDS();
-//     _PTR(SObject) aSObj = aStudy->FindObjectID( anEntry.toStdString().c_str() );
-//     LightApp_DataObject*      o = HEXABLOCKGUI::activeStudy()->findObjectByEntry(anEntry.toStdString().c_str());
-//     //CS_TEST
-
-
-
-
-
-// void PatternDataSelectionModel::test()
-// {
-//   if (myBusy) return;
-//   myMeshActor = 0;
-// 
-//   SALOME_ListIO aList;
-//   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
-// 
-//   if (aList.Extent() == 1) {
-//     Handle(SALOME_InteractiveObject) anIO = aList.First();
-//     myMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
-//     if(myMeshActor){
-//       QString aText;
-//       if (SMESH::GetNameOfSelectedNodes(activeViewWindow,anIO,aText) == 1) {
-//         if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) {
-//           if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) {
-//             myBusy = true;
-//             myId->setText(aText);
-//             myX->SetValue(aNode->X());
-//             myY->SetValue(aNode->Y());
-//             myZ->SetValue(aNode->Z());
-//             myBusy = false;
-//             erasePreview(); // avoid overlapping of a selection and a preview
-//             updateButtons();
-//             return;
-//           }
-//         }
-//       }
-//     }
-//   }
-// 
-//   reset();
-// }
-
-
-/*
-
-void PatternDataSelectionModel::setGeomEngine( GEOM::GEOM_Gen_var geomEngine )
-{gaumont parnasse
-  _geomEngine = geomEngine;
-}
+    if (!infoMode || nbSelected > 1)
+        return;
 
-GEOM::GEOM_IOperations_ptr PatternDataSelectionModel::createOperation()
-{
-//   return myGeomGUI->GetGeomGen()->GetIBasicOperations(getStudyId());
-  return _geomEngine->GetIBasicOperations(getStudyId());
+    // ** Show informations of the selected element **/
+    QModelIndex elt = indexes[0];
+    showEltInfo(elt);
 }
 
-bool PatternDataSelectionModel::execute(ObjectList& objects)
-{
-  bool res = false;
-
-  _PTR(Study)   aStudy = GetActiveStudyDocument();
-  _PTR(SObject) aSChild;
-  CORBA::Object_var aCorbaObj = CORBA::Object::_nil();
-  GEOM::GEOM_Object_var assoc;
-
-  foreach( const DocumentModel::GeomObj& anAssoc, _assocList ){
-    std::cout << "FOUND=> " << anAssoc.entry.toStdString() << std::endl;
-    aSChild = aStudy->FindObjectID( anAssoc.entry.toStdString() );
-    aCorbaObj = corbaObj(aSChild);
-    assoc = GEOM::GEOM_Object::_narrow(aCorbaObj);
-
-    if ( !CORBA::is_nil(assoc) ){
-      std::cout << "geom to highlight =>" << anAssoc.name.toStdString() << std::endl;
-      objects.push_back( assoc._retn() );
-      res = true;
-    } else {
-      std::cout << "not a geom =>" << anAssoc.name.toStdString()<< std::endl;
-    }
-  }
-
-  return res;
-}
-*/
-
-
-// SVTK_ViewWindow* PatternDataSelectionModel::GetViewWindow()
-// {
-//     SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
-//         (SUIT_Session::session()->activeApplication());
-//     if (anApp) {
-//       if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow()))
-//         return aView;
-// 
-// //       SUIT_ViewManager* aViewManager =
-// //         anApp->getViewManager(SVTK_Viewer::Type(), createIfNotFound);
-// //       if (aViewManager) {
-// //         if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
-// //           if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
-// //             aViewWindow->raise();
-// //             aViewWindow->setFocus();
-// //             return aView;
-// //           }
-// //         }
-// //       }
-//     }
-//     return NULL;
-// }
-
-
-
-
-// void  PatternDataSelectionModel::SetSelectionMode(Selection_Mode theMode)
-// {
-// 
-//   QList<SUIT_Selector*> aSelectors;
-//   _salomeSelectionMgr->selectors( SVTK_Viewer::Type(), aSelectors );
-//   QListIterator<SUIT_Selector*> it( aSelectors );
-//   
-//   std::cout << "PatternDataSelectionModel::SetSelectionMode()" << std::endl;
-//   while ( it.hasNext() )
-//   {
-//   //   SUIT_Selector* selector = it.next();
-//     SVTK_Selector* selector = dynamic_cast<SVTK_Selector*>( it.next() );
-//     if ( selector ){
-//       std::cout << "PatternDataSelectionModel::SetSelectionMode()" << theMode << std::endl;
-//       selector->SetSelectionMode(theMode);
-//     }
-//   }
-// }
-
-// LightApp_SelectionMgr* PatternDataSelectionModel::selectionMgr()
-// {
-//   SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
-//   if( anApp )
-//     return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
-//   else
-//     return 0;
-// }
-
-// //CS_TEST
-// SUIT_DataOwnerPtrList aOList;
-// LightApp_DataOwner* anOwher = new LightApp_DataOwner( "0:1:1:1:2" );
-// aOList.append( anOwher );
-// _salomeSelectionMgr->setSelected( aOList, false );
-// //CS_TEST
-
-// void PatternDataSelectionModel::_highlightGEOM( const QModelIndex & anEltIndex )
-// {
-//   std::cout << "PatternDataSelectionModel::_highlightGEOM go find ASSOCIATION for"<< anEltIndex.data().toString().toStdString()<<std::endl;
-// // HEXABLOCKGUI::currentVtkView
-// 
-//   QList<DocumentModel::GeomObj> assocList;
-// 
-//   DocumentModel               *docModel = NULL;
-//   const QSortFilterProxyModel *pModel   = NULL;
-// //   const QStandardItemModel    *smodel
-// //   const QAbstractItemModel    *theModel = NULL;
-// 
-//   pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
-// 
-//   std::cout << "pModel "<< pModel << std::endl;
-//   if ( pModel ){
-//     std::cout << "if ( pModel ){"<< std::endl;
-//     docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel() ); 
-//     if ( docModel ){
-//       std::cout << "if ( docModel ){"<< std::endl;
-//       assocList = docModel->getAssociations( pModel->mapToSource(anEltIndex) );
-//     }
-//   }
-// 
-// 
-//   _PTR(Study)   aStudy = GetActiveStudyDocument();
-//   _PTR(SObject) aSChild;
-//   CORBA::Object_var aCorbaObj = CORBA::Object::_nil();
-//   GEOM::GEOM_Object_var assoc;
-// //   foreach( const QString& entry, geomEntries ){
-// // struct GeomObj
-// //         {
-// //           QString name;
-// //           QString entry;
-// //           QString brep;
-// //           double  start;
-// //           double  end;
-// //         };
-// 
-//   QVariant treeVariant = pModel->mapToSource(anEltIndex).data( HEXA_TREE_ROLE );
-//   int eltType;
-//   if ( !treeVariant.isValid() ) return;
-//   eltType = treeVariant.toInt();
-// 
-// //   GEOM::GeomObjPtr
-// //   GEOM::GEOM_Object_ptr firstLine;  //firstLine.nullify();//
-//   GEOM::GEOM_Object_var firstLine = GEOM::GEOM_Object::_nil();  //GEOM::GeomObjPtr
-//   GEOM::GEOM_Object_var lastLine  = GEOM::GEOM_Object::_nil();
-//   double firstParameter = 0.2; //CS_TODO
-//   double lastParameter  = 0.4; //CS_TODO
-// 
-//   foreach( const DocumentModel::GeomObj& anAssoc, assocList ){
-//     std::cout << "FOUND=> " << anAssoc.entry.toStdString() << std::endl;
-//     aSChild = aStudy->FindObjectID( anAssoc.entry.toStdString() );
-//     aCorbaObj = corbaObj(aSChild);
-//     assoc = GEOM::GEOM_Object::_narrow(aCorbaObj);
-// 
-//     if ( !CORBA::is_nil(assoc) ){
-//       std::cout << "geom to highlight =>" << anAssoc.name.toStdString() << std::endl;
-// //       objects.push_back(assoc._retn());
-// //       if ( eltType == EDGE_TREE ){
-// //           if ( CORBA::is_nil(firstLine) ){
-// //             firstLine = GEOM::GEOM_Object::_duplicate( assoc._retn() );
-// //           }
-// //           lastLine = GEOM::GEOM_Object::_duplicate( assoc._retn() );
-// //       }
-//       displayPreview( assoc._retn(),
-//                       true, //false, //append,
-//                       false,//true, //false, //activate,
-//                       false,//true,//update,
-//                       4,//lineWidth,
-//                       1,//-1,//displayMode,
-//                       Quantity_NOC_RED );
-//     } else {
-//       std::cout << "not a geom =>" << anAssoc.name.toStdString()<< std::endl;
-//     }
-//   }
-// //     std::cout << "CORBA::is_nil(firstLine) =>" << CORBA::is_nil(firstLine) << std::endl;
-// //     std::cout << "CORBA::is_nil(lastLine) =>"  << CORBA::is_nil(lastLine) << std::endl;
-// //     std::cout << "test" << ( !( CORBA::is_nil(firstLine) and !CORBA::is_nil(lastLine) ) ) << std::endl;
-//  /*
-//   if ( !( CORBA::is_nil(firstLine) and !CORBA::is_nil(lastLine) ) ){
-//     GEOM::GEOM_IBasicOperations_var anOper = _geomEngine->GetIBasicOperations( getStudyId() );
-//     GEOM::GEOM_Object_var firstPoint = anOper->MakePointOnCurve( firstLine, firstParameter );
-//     GEOM::GEOM_Object_var lastPoint  = anOper->MakePointOnCurve( lastLine, lastParameter );
-// 
-// //     std::cout << "firstPoint->_is_nil() =>" << firstPoint->_is_nil() << std::endl;
-//     std::cout << "lastPoint->_is_nil() =>"  << lastPoint->_is_nil() << std::endl;
-//     if ( !( CORBA::is_nil(firstPoint) ) )// !firstPoint->_is_nil() )
-//         displayPreview( firstPoint._retn(), true );
-//     if ( !( CORBA::is_nil(lastPoint) ) )//if ( !lastPoint->_is_nil() )
-//         displayPreview( lastPoint._retn(), true );
-//   }*/
-// }
-//