Salome HOME
SMH: 3.0.0 preparation - merged and adopted version (POLYWORK+HEAD)
[modules/visu.git] / src / VISUGUI / VisuGUI_Selection.cxx
index 68b15a96f5deb7d555099e7e8ae6ea83f3c41819..2f59ddf6c58a1a1de0b0633dc369ecd8e4576e65 100644 (file)
@@ -1,48 +1,64 @@
 //  VISU VISUGUI : GUI of VISU component
 //
 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
 //
 //
 //
 //  File   : VisuGUI_Selection.cxx
-//  Author : Laurent CORNABE & Hubert ROLLAND 
+//  Author : Laurent CORNABE & Hubert ROLLAND
 //  Module : VISU
 //  $Header$
 
 #include "VisuGUI_Selection.h"
 
-#include "SALOME_ListIteratorOfListIO.hxx"
-#include "SALOME_Selection.h"
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+
 #include "VISU_Actor.h"
 #include "VISU_PrsObject_i.hh"
 #include "VISU_Prs3d_i.hh"
 #include "VISU_PipeLine.hxx"
-#include "VisuGUI.h"
-#include "QAD_MessageBox.h"
-#include "QAD_RightFrame.h"
-#include "VTKViewer_ViewFrame.h"
 
-#include <TColStd_IndexedMapOfInteger.hxx>
+#include "SalomeApp_Study.h"
+#include "SalomeApp_Application.h"
+#include "SalomeApp_SelectionMgr.h"
+#include "SalomeApp_VTKSelector.h"
 
-#include <map>
+#include "SUIT_MessageBox.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_Session.h"
+
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
+
+#include "SVTK_ViewWindow.h"
+#include "SVTK_ViewModel.h"
+#include "SVTK_Selector.h"
+
+#include "utilities.h"
+
+// OCCT Includes
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
 
+// QT Includes
 #include <qstring.h>
 #include <qlabel.h>
 #include <qspinbox.h>
 #include <qradiobutton.h>
 #include <qvalidator.h>
 #include <qpushbutton.h>
+#include <qwidgetstack.h>
+#include <qvbox.h>
+#include <qgroupbox.h>
+#include <qlineedit.h>
+#include <qvalidator.h>
+#include <qtable.h>
+#include <qlistview.h>
 
+// VTK Includes
 #include <vtkDataSetMapper.h>
 #include <vtkDataSet.h>
 #include <vtkPointData.h>
 #include <vtkCellData.h>
 #include <vtkCell.h>
 
-#include "utilities.h"
+// STL Includes
+#include <map>
 
 using namespace std;
 
-extern VisuGUI *visuGUI;
-static QAD_Study* myStudy = NULL;
+//extern VisuGUI *visuGUI;
 static VisuGUI_SelectionDlg* mySelectionDlg = NULL;
 
-VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()    
-  : QDialog( QAD_Application::getDesktop(), 0, false, 
-            WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose)
+VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (QWidget* parent)
+     : QDialog(parent, 0, false, WStyle_Customize | WStyle_NormalBorder |
+               WStyle_Title | WStyle_SysMenu | WDestructiveClose),
+       mySelectionMgr(NULL)
 {
-  if(mySelectionDlg)
+  //MESSAGE("VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()");
+  if (mySelectionDlg)
     mySelectionDlg->close(true);
 
   setCaption( "Data on elements" );
   setSizeGripEnabled( TRUE );
-  
+
   QGridLayout* TopLayout = new QGridLayout(this);
   TopLayout->setSpacing(6);
   TopLayout->setMargin(11);
@@ -85,15 +111,15 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
   TopLayout->setRowStretch(2, 1);
   TopLayout->setRowStretch(3, 0);
 
-  QHButtonGroup* aTypeBox = new QHButtonGroup("Selection", this);  
-  
+  QHButtonGroup* aTypeBox = new QHButtonGroup("Selection", this);
+
   QRadioButton* aPointBtn = new QRadioButton("Point", aTypeBox);
   QRadioButton* aCellBtn = new QRadioButton("Cell", aTypeBox);
   QRadioButton* aActorBtn = new QRadioButton("Actor", aTypeBox);
   aPointBtn->setChecked(true);
 
   connect(aTypeBox, SIGNAL(clicked(int)), this, SLOT(onSelectionChange(int)));
-  
+
   TopLayout->addWidget(aTypeBox, 0, 0);
 
   QWidget* aNamePane = new QWidget(this);
@@ -113,11 +139,11 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
   TopLayout->addWidget(aNamePane, 1, 0);
 
   myWidgetStack = new QWidgetStack(this);
-  
+
   // Create Points pane
   myPointsPane = new QVBox(myWidgetStack);
   myPointsPane->layout()->setSpacing(6);
-  
+
   QGroupBox* aDataGrp = new QGroupBox(2, Qt::Horizontal, "Data of Point", myPointsPane);
   aDataGrp->layout()->setSpacing(6);
 
@@ -130,7 +156,7 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
 
   QLabel* aValueLbl = new QLabel("Scalar Value:", aDataGrp);
   myScalarValLbl = new QLabel("", aDataGrp);
-  QLabel* aVectorLbl = new QLabel("Vector Value:", aDataGrp); 
+  QLabel* aVectorLbl = new QLabel("Vector Value:", aDataGrp);
   myVectorValLbl = new QLabel("", aDataGrp);
   myVectorValLbl->setMinimumWidth(150);
 
@@ -140,12 +166,12 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
   myXValLbl = new QLabel("", aCoordGrp);
   QLabel* aYLbl = new QLabel("Y:", aCoordGrp);
   myYValLbl = new QLabel("", aCoordGrp);
-  QLabel* aZLbl = new QLabel("Z:",aCoordGrp );  
+  QLabel* aZLbl = new QLabel("Z:",aCoordGrp );
   myZValLbl = new QLabel("", aCoordGrp);
 
 
   myWidgetStack->addWidget(myPointsPane, 0);
-  
+
   // Create Cells pane
   myCellsPane = new QWidget(myWidgetStack);
   QGridLayout* aCellLayout = new QGridLayout(myCellsPane);
@@ -154,7 +180,7 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
   aCellLayout->setRowStretch(1, 1);
 
   QGroupBox* aCellGrp = new QGroupBox(2, Qt::Horizontal, "Data of Cell", myCellsPane);
-  
+
   QLabel* aCellIDLbl = new QLabel("ID:", aCellGrp);
   myCellIDValLbl = new QLineEdit("", aCellGrp);
   myCellIDValLbl->setValidator(aIntValidator);
@@ -162,7 +188,7 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
 
   QLabel* aCellValueLbl = new QLabel("Scalar Value:", aCellGrp);
   myCellScalarValLbl = new QLabel("", aCellGrp);
-  QLabel* aCellVectorLbl = new QLabel("Vector Value:", aCellGrp);  
+  QLabel* aCellVectorLbl = new QLabel("Vector Value:", aCellGrp);
   myCellVectorValLbl = new QLabel("", aCellGrp);
 
   aCellLayout->addWidget(aCellGrp, 0, 0);
@@ -187,7 +213,7 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
   aCellLayout->addWidget(myListPoints, 1, 0);
 
   myWidgetStack->addWidget(myCellsPane, 1);
-  
+
   // Actor Pane
   myActorsPane = new QVBox(myWidgetStack);
   myActorsPane->layout()->setSpacing(6);
@@ -198,7 +224,7 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
   myXPosLbl = new QLabel("0", aPosGrp);
   QLabel* aYPosLbl = new QLabel("Y:", aPosGrp);
   myYPosLbl = new QLabel("0", aPosGrp);
-  QLabel* aZPosLbl = new QLabel("Z:", aPosGrp);  
+  QLabel* aZPosLbl = new QLabel("Z:", aPosGrp);
   myZPosLbl = new QLabel("0", aPosGrp);
 
   QGroupBox* aSizeGrp = new QGroupBox(2, Qt::Horizontal, "Size", myActorsPane);
@@ -207,7 +233,7 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
   myDXLbl = new QLabel("0", aSizeGrp);
   QLabel* aYSizeLbl = new QLabel("dY:", aSizeGrp);
   myDYLbl = new QLabel("0", aSizeGrp);
-  QLabel* aZSizeLbl = new QLabel("dZ:",aSizeGrp );  
+  QLabel* aZSizeLbl = new QLabel("dZ:",aSizeGrp );
   myDZLbl = new QLabel("0", aSizeGrp);
 
   myWidgetStack->addWidget(myActorsPane, 2);
@@ -217,55 +243,75 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg()
 
   // Create buttons group
   QHBox* aBtnBox = new QHBox(this);
-  QHBoxLayout* aBtnLayout = (QHBoxLayout*)aBtnBox->layout(); 
+  QHBoxLayout* aBtnLayout = (QHBoxLayout*)aBtnBox->layout();
   aBtnLayout->addStretch();
 
   QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox);
   connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close()));
-  
+
   TopLayout->addWidget(aBtnBox, 3, 0);
 
-  myStudy = visuGUI->GetActiveStudy();
-  mySelection = SALOME_Selection::Selection(myStudy->getSelection());
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionEvent()));
+  SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
+    (SUIT_Session::session()->activeApplication());
+  mySelectionMgr = anApp->selectionMgr();
+  connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionEvent()));
 
-  connect(visuGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(close()));
+  //connect(visuGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(close()));
 
   myFl = false;
-  onSelectionChange(0);
+
+  //onSelectionChange(0);
+  SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
+  // Activate Points pane
+  myWidgetStack->raiseWidget(myPointsPane);
+  aSVTKVW->SetSelectionMode(NodeSelection);
+  //onPointIdEdit(myIDValLbl->text());
+  onSelectionEvent();
 
   mySelectionDlg = this;
 }
 
+VisuGUI_SelectionDlg::~VisuGUI_SelectionDlg()
+{
+  //MESSAGE("VisuGUI_SelectionDlg::~VisuGUI_SelectionDlg()");
+}
+
+void VisuGUI_SelectionDlg::onSelectionChange (int theId)
+{
+  //MESSAGE("VisuGUI_SelectionDlg::onSelectionChange()");
+  SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
 
-void VisuGUI_SelectionDlg::onSelectionChange(int theId) {
-  //  clearFields();
   switch (theId) {
   case 0: // Points
-    myWidgetStack->raiseWidget(myPointsPane);    
-    QAD_Application::getDesktop()->SetSelectionMode(NodeSelection, true);
+    myWidgetStack->raiseWidget(myPointsPane);
+    //mySelectionMgr->setSelectionModes(NodeSelection);
+    aSVTKVW->SetSelectionMode(NodeSelection);
     onPointIdEdit(myIDValLbl->text());
     break;
   case 1: // Cells
     myWidgetStack->raiseWidget(myCellsPane);
-    QAD_Application::getDesktop()->SetSelectionMode(CellSelection, true);
+    //mySelectionMgr->setSelectionModes(CellSelection);
+    aSVTKVW->SetSelectionMode(CellSelection);
     onCellIdEdit(myCellIDValLbl->text());
     break;
   case 2: // Actor
     myWidgetStack->raiseWidget(myActorsPane);
-    QAD_Application::getDesktop()->SetSelectionMode(ActorSelection, true);  
+    //mySelectionMgr->setSelectionModes(ActorSelection);
+    aSVTKVW->SetSelectionMode(ActorSelection);
+    onSelectionEvent();
   }
-  onSelectionEvent();
-//   if (VTKViewer_ViewFrame* vf = visuGUI->GetVtkViewFrame())
-//     vf->Repaint();
 }
 
 
-void VisuGUI_SelectionDlg::closeEvent(QCloseEvent* theEvent) {
+void VisuGUI_SelectionDlg::closeEvent (QCloseEvent* theEvent)
+{
+  //MESSAGE("VisuGUI_SelectionDlg::closeEvent()");
+  SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
+
   mySelectionDlg = NULL;
-  myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->SetSelectionMode( ActorSelection );
-  QAD_Application::getDesktop()->SetSelectionMode(ActorSelection, true);
-  disconnect(mySelection,0,0,0);
+  //mySelectionMgr->setSelectionModes(ActorSelection);
+  aSVTKVW->SetSelectionMode(ActorSelection);
+  disconnect(mySelectionMgr,0,0,0);
   QDialog::closeEvent(theEvent);
 }
 
@@ -274,123 +320,168 @@ template<class TData> QString getValue(TData* theData, int theId){
     float aVal = aScalar->GetTuple1(theId);
     return QString::number(aVal);
   } else {
-    return QString("No data");     
+    return QString("No data");
   }
 }
 
 template<class TData> QString getVector(TData* theData, int theId){
   if (vtkDataArray *aVector = theData->GetVectors()) {
     float *aVal = aVector->GetTuple3(theId);
-    return QString("%1; %2; %3").arg(aVal[0]).arg(aVal[1]).arg(aVal[2]); 
+    return QString("%1; %2; %3").arg(aVal[0]).arg(aVal[1]).arg(aVal[2]);
   } else {
     return QString("No data");
   }
 }
 
-
 #define ABS(a) (a>=0)?a:-a
 
 void VisuGUI_SelectionDlg::onSelectionEvent() {
+  //MESSAGE("VisuGUI_SelectionDlg::onSelectionEvent()");
   if (myFl) return;
-  myFl = true;  
-  Handle(SALOME_InteractiveObject) anIO;
+  myFl = true;
   int aType = myWidgetStack->id(myWidgetStack->visibleWidget());
-  if(VISU::Prs3d_i* aPrs3d = visuGUI->GetSelectedPrs3d(&anIO)){
-    SALOMEDS::SObject_var aSObject = visuGUI->GetStudyDocument()->FindObjectID(anIO->getEntry());
-    QString aMeshName = VisuGUI::getValue(aSObject, "myMeshName");
-    QString aFieldName = VisuGUI::getValue(aSObject, "myFieldName");
-    myMeshName->setText((aMeshName == "NULL")? QString("No name") : aMeshName);
-    myFieldName->setText((aFieldName == "NULL")? QString("No name") : aFieldName);
-    
-    VISU_Actor* anVISUActor = visuGUI->GetActor(aPrs3d);
+
+  SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
+    (SUIT_Session::session()->activeApplication());
+
+  SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
+  SVTK_Selector* aSelector = aSVTKVW->GetSelector();
+
+  VISU::Prs3d_i* aPrs3d = NULL;
+  _PTR(SObject) aSObject;
+  Handle(SALOME_InteractiveObject) anIO;
+
+  //SALOME_ListIO aListIO;
+  //mySelectionMgr->selectedObjects(aListIO, SVTK_Viewer::Type());
+
+  const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
+
+  //MESSAGE("aListIO.Extent() = " << aListIO.Extent());
+  if (aListIO.Extent() == 1) {
+    anIO = aListIO.First();
+
+    if (anIO->hasEntry()) {
+      SalomeApp_Study* theStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
+      _PTR(Study) aStudy = theStudy->studyDS();
+      aSObject = aStudy->FindObjectID(anIO->getEntry());
+      //MESSAGE("anIO->hasEntry(): " << anIO->getEntry());
+
+      if (aSObject) {
+       CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+
+        if (!CORBA::is_nil(anObject)) {
+          PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+
+          if (aServant.in()) {
+            aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+          }
+        }
+      }
+    }
+  }
+
+  if (aPrs3d) {
+    VISU::Storable::TRestoringMap aMap;
+    if (aSObject) {
+      _PTR(GenericAttribute) anAttr;
+      if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
+        _PTR(AttributeComment) aComment (anAttr);
+        std::string aString = aComment->Value();
+        QString strIn (aString);
+        VISU::Storable::StrToMap(strIn, aMap);
+      }
+    }
+
+    QString aMeshName("NULL"), aFieldName("NULL");
+    if (!aMap.empty()) {
+      aMeshName  = VISU::Storable::FindValue(aMap, "myMeshName");
+      aFieldName = VISU::Storable::FindValue(aMap, "myFieldName");
+    }
+
+    myMeshName ->setText((aMeshName  == "NULL") ? QString("No name") : aMeshName);
+    myFieldName->setText((aFieldName == "NULL") ? QString("No name") : aFieldName);
+
+    VISU_Actor* anVISUActor =
+      VISU::FindActor(aSVTKVW, aSObject->GetID().c_str());
     if (anVISUActor) {
       float aCoord[6];
       anVISUActor->GetBounds(aCoord);
       myXPosLbl->setText(QString::number( aCoord[0] ));
       myYPosLbl->setText(QString::number( aCoord[2] ));
       myZPosLbl->setText(QString::number( aCoord[4] ));
-      
+
       myDXLbl->setText(QString::number( ABS(aCoord[1]-aCoord[0]) ));
       myDYLbl->setText(QString::number( ABS(aCoord[3]-aCoord[2]) ));
       myDZLbl->setText(QString::number( ABS(aCoord[5]-aCoord[4]) ));
-    }
 
-    TColStd_IndexedMapOfInteger aMapIndex;
-    typedef map<int,float*> PointsMap;
-    PointsMap aPointsMap;
-    mySelection->GetIndex(anIO, aMapIndex);
-    
-    VISU_Actor* anActor = visuGUI->GetActor(aPrs3d);  
-    if(!anActor)
-      return;
-    vtkDataSet* aDataSet = anActor->GetInput();
-    vtkPointData* aPntData = aDataSet->GetPointData();
-
-    for ( int ind = 1; ind <= aMapIndex.Extent(); ind++){
-      int aID = aMapIndex( ind );
-      
-      switch (aType) {
-      case 0:
-       {
-         float aCoord[3];
-         aDataSet->GetPoint(aID, aCoord);
-         myXValLbl->setText( QString::number( aCoord[0] ) );
-         myYValLbl->setText( QString::number( aCoord[1] ) );
-         myZValLbl->setText( QString::number( aCoord[2] ) );
-         myIDValLbl->setText( QString::number(aID) );
-         myScalarValLbl->setText(getValue(aPntData, aID));
-         myVectorValLbl->setText(getVector(aPntData, aID));
-         //      adjustSize();
-         //qApp->processEvents();
-       }
-       break;
-      case 1:
-       {
-         //int aMaxId = aDataSet->GetNumberOfCells();
-         //cout<<"### MaxId="<<aMaxId<<endl;
-         //cout<<"### SelectedId="<<aID<<endl;
-         vtkCellData* aData = aDataSet->GetCellData();
-         vtkCell* aCell = aDataSet->GetCell(aID);
-         if (aCell != NULL) {
-           int aNbOfPoints = aCell->GetNumberOfPoints();
-           if (aNbOfPoints <=1 ) { // Cell is point
-             clearFields();
-           }
-           else {
-             myCellIDValLbl->setText( QString::number(aID) );
-             myCellScalarValLbl->setText(getValue(aData, aID));
-             myCellVectorValLbl->setText(getVector(aData, aID));
-         
-             float* aCoord;
-             vtkIdList *aPointList = aCell->GetPointIds();
-             QListViewItem* anItem = NULL;
-        
-             for(int i = 0; i < aNbOfPoints; i++){
-               int idCurrent = aPointList->GetId(i);
-               aCoord = aDataSet->GetPoint(idCurrent);
-               aPointsMap.insert(PointsMap::value_type(idCurrent,aCoord));
-             }
-           }
-         }
-       }
-       break;
+      TColStd_IndexedMapOfInteger aMapIndex;
+      typedef map<int,float*> PointsMap;
+      PointsMap aPointsMap;
+
+      aSelector->GetIndex(anIO, aMapIndex);
+
+      vtkDataSet* aDataSet = anVISUActor->GetInput();
+      vtkPointData* aPntData = aDataSet->GetPointData();
+
+      for (int ind = 1; ind <= aMapIndex.Extent(); ind++) {
+        int aID = aMapIndex(ind);
+
+        switch (aType) {
+        case 0:
+          {
+            float aCoord[3];
+            aDataSet->GetPoint(aID, aCoord);
+            myXValLbl->setText( QString::number( aCoord[0] ) );
+            myYValLbl->setText( QString::number( aCoord[1] ) );
+            myZValLbl->setText( QString::number( aCoord[2] ) );
+            myIDValLbl->setText( QString::number(aID) );
+            myScalarValLbl->setText(getValue(aPntData, aID));
+            myVectorValLbl->setText(getVector(aPntData, aID));
+          }
+          break;
+        case 1:
+          {
+            vtkCellData* aData = aDataSet->GetCellData();
+            vtkCell* aCell = aDataSet->GetCell(aID);
+            if (aCell != NULL) {
+              int aNbOfPoints = aCell->GetNumberOfPoints();
+              if (aNbOfPoints <=1 ) { // Cell is point
+                clearFields();
+              } else {
+                myCellIDValLbl->setText( QString::number(aID) );
+                myCellScalarValLbl->setText(getValue(aData, aID));
+                myCellVectorValLbl->setText(getVector(aData, aID));
+
+                float* aCoord;
+                vtkIdList *aPointList = aCell->GetPointIds();
+                QListViewItem* anItem = NULL;
+
+                for (int i = 0; i < aNbOfPoints; i++) {
+                  int idCurrent = aPointList->GetId(i);
+                  aCoord = aDataSet->GetPoint(idCurrent);
+                  aPointsMap.insert(PointsMap::value_type(idCurrent,aCoord));
+                }
+              }
+            }
+          }
+          break;
+        }
       }
-    }
 
-    myListPoints->setNumRows(aPointsMap.size());
-    PointsMap::const_iterator It = aPointsMap.begin();
-    for(int i=0; It!=aPointsMap.end()&&i<myListPoints->numRows() ; It++,i++){
-      myListPoints->verticalHeader()->setLabel(i, QString::number( i ));
-      int id = It->first;
-      myListPoints->setText(i, 0, QString::number( id ));
-      float* aCoord = It->second;
-      myListPoints->setText(i, 1, QString::number( aCoord[0] ));
-      myListPoints->setText(i, 2, QString::number( aCoord[1] ));
-      myListPoints->setText(i, 3, QString::number( aCoord[2] ));
-      myListPoints->setText(i, 4, getValue(aPntData, id));
-      myListPoints->setText(i, 5, getVector(aPntData, id));
+      myListPoints->setNumRows(aPointsMap.size());
+      PointsMap::const_iterator It = aPointsMap.begin();
+      for (int i = 0; It != aPointsMap.end() && i < myListPoints->numRows(); It++, i++) {
+        myListPoints->verticalHeader()->setLabel(i, QString::number( i ));
+        int id = It->first;
+        myListPoints->setText(i, 0, QString::number( id ));
+        float* aCoord = It->second;
+        myListPoints->setText(i, 1, QString::number( aCoord[0] ));
+        myListPoints->setText(i, 2, QString::number( aCoord[1] ));
+        myListPoints->setText(i, 3, QString::number( aCoord[2] ));
+        myListPoints->setText(i, 4, getValue(aPntData, id));
+        myListPoints->setText(i, 5, getVector(aPntData, id));
+      }
     }
-    
   } else {
     clearFields();
   }
@@ -400,6 +491,7 @@ void VisuGUI_SelectionDlg::onSelectionEvent() {
 
 
 void VisuGUI_SelectionDlg::clearFields() {
+  //MESSAGE("VisuGUI_SelectionDlg::clearFields()");
   int aType = myWidgetStack->id(myWidgetStack->visibleWidget());
   switch (aType) {
   case 0:
@@ -419,7 +511,7 @@ void VisuGUI_SelectionDlg::clearFields() {
   case 2:
     myXPosLbl->setText("");
     myYPosLbl->setText("");
-    myZPosLbl->setText("");      
+    myZPosLbl->setText("");
     myDXLbl->setText("");
     myDYLbl->setText("");
     myDZLbl->setText("");
@@ -428,48 +520,95 @@ void VisuGUI_SelectionDlg::clearFields() {
 
 typedef  vtkIdType (vtkDataSet::* TDataSetMethod)();
 
-bool onIdEdit(const QString& theText, 
-             TDataSetMethod theMethod, 
-             bool theIsCell,
-             SALOME_Selection* theSelection, 
-             QLabel* theMeshName, 
-             QString theValue,
-             QLabel* theFieldName)
+bool onIdEdit (const QString& theText,
+               TDataSetMethod theMethod,
+               bool theIsCell,
+               SalomeApp_SelectionMgr* theSelectionMgr,
+               QLabel* theMeshName,
+               QString theValue,
+               QLabel* theFieldName)
 {
+  //MESSAGE("onIdEdit()");
+  SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
+    (SUIT_Session::session()->activeApplication());
+  SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow();
+  SVTK_Selector* aSelector = aSVTKVW->GetSelector();
+
+  VISU::Prs3d_i* aPrs3d = NULL;
   Handle(SALOME_InteractiveObject) anIO;
-  if(VISU::Prs3d_i* aPrs3d = visuGUI->GetSelectedPrs3d(&anIO)){
+
+  //SALOME_ListIO aListIO;
+  //theSelectionMgr->selectedObjects(aListIO, SVTK_Viewer::Type());
+
+  const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
+
+  if (aListIO.Extent() == 1) {
+    anIO = aListIO.First();
+
+    if (anIO->hasEntry()) {
+      SalomeApp_Study* theStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
+      _PTR(Study) aStudy = theStudy->studyDS();
+      _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
+
+      if (aSObject) {
+       CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+
+        if (!CORBA::is_nil(anObject)) {
+          PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+
+          if (aServant.in()) {
+            aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+          }
+        }
+      }
+    }
+  }
+
+  if (aPrs3d) {
     int anId = theText.toInt();
     vtkDataSet* aDataSet = aPrs3d->GetPL()->GetMapper()->GetInput();
     int aMaxId = (aDataSet->*theMethod)();
-    if(anId < 0) anId = 0;
-    if(anId >= aMaxId) anId = aMaxId-1;
-    theSelection->ClearIObjects();
-    theSelection->AddIObject(anIO);
-    theSelection->AddOrRemoveIndex( anIO, anId, false );
+    if (anId < 0) anId = 0;
+    if (anId >= aMaxId) anId = aMaxId - 1;
+
+    //SALOME_ListIO sel;
+    //sel.Append(anIO);
+    //theSelectionMgr->setSelectedObjects(sel);
+
+    TColStd_MapOfInteger newIndices;
+    newIndices.Add(anId);
+    aSelector->AddOrRemoveIndex(anIO, newIndices, false);
+    aSVTKVW->highlight(anIO, true, true);
+
     return true;
-  }else{
+
+  } else {
     theMeshName->setText(theValue);
     theFieldName->setText("");
   }
   return false;
 }
 
-void VisuGUI_SelectionDlg::onPointIdEdit(const QString& theText){
+void VisuGUI_SelectionDlg::onPointIdEdit (const QString& theText)
+{
+  //MESSAGE("onPointIdEdit()");
   if (myFl) return;
   TDataSetMethod aMethod = &vtkDataSet::GetNumberOfPoints;
-  bool anIsSelected = onIdEdit(theText,aMethod,false,mySelection,
+  bool anIsSelected = onIdEdit(theText,aMethod,false,mySelectionMgr,
                               myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
                               myFieldName);
-  if(!anIsSelected)
+  if (!anIsSelected)
     clearFields();
 }
 
-void VisuGUI_SelectionDlg::onCellIdEdit(const QString& theText){
+void VisuGUI_SelectionDlg::onCellIdEdit (const QString& theText)
+{
+  //MESSAGE("onCellIdEdit()");
   if (myFl) return;
   TDataSetMethod aMethod = &vtkDataSet::GetNumberOfCells;
-  bool anIsSelected = onIdEdit(theText,aMethod,true,mySelection,
+  bool anIsSelected = onIdEdit(theText,aMethod,true,mySelectionMgr,
                               myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
                               myFieldName);
-  if(!anIsSelected)
+  if (!anIsSelected)
     clearFields();
 }