]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for issue 0020111: EDF VISU 917 : Bad values are displayed for ELNO fields
authorouv <ouv@opencascade.com>
Fri, 16 Jan 2009 08:37:22 +0000 (08:37 +0000)
committerouv <ouv@opencascade.com>
Fri, 16 Jan 2009 08:37:22 +0000 (08:37 +0000)
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI_SelectionPanel.cxx
src/VISUGUI/VisuGUI_SelectionPanel.h

index ffcd02751fb51409a8d181c31b34ebd6a79fb5a2..7a8ed00ab06fd8e49d4f4ecbb7b7e14944af601c 100644 (file)
@@ -3392,12 +3392,12 @@ Please, refer to the QT documentation.</translation>
             <translation>ID:</translation>
         </message>
        <message>
-           <source>DATA_SCALAR_LBL</source>
-            <translation>Scalar Value:</translation>
+           <source>POINT_ID_HDR</source>
+            <translation>PointID</translation>
         </message>
        <message>
-           <source>DATA_VECTOR_LBL</source>
-            <translation>Vector Value:</translation>
+           <source>CELL_ID_HDR</source>
+            <translation>CellID</translation>
         </message>
        <message>
            <source>DATA_SCALAR_HDR</source>
@@ -3407,6 +3407,14 @@ Please, refer to the QT documentation.</translation>
            <source>DATA_VECTOR_HDR</source>
             <translation>Vector</translation>
         </message>
+       <message>
+           <source>POINT_INFO</source>
+            <translation>Point Info</translation>
+        </message>
+       <message>
+           <source>CELL_INFO</source>
+            <translation>Cell Info</translation>
+        </message>
         <message>
            <source>POINT_COORD_TITLE</source>
             <translation>Coordinates</translation>
index 315308121d7cd9111eda8050b0f54ebb38a8ef9a..cb8531a3ce5f4f43201c1fbed648b17e2ed1ff8d 100644 (file)
@@ -35,6 +35,7 @@
 #include "VisuGUI_FindPane.h"
 
 #include "VISU_Event.h"
+#include "VISU_ConvertorUtils.hxx"
 
 #include "VISU_Actor.h"
 #include "VISU_PrsObject_i.hh"
@@ -60,7 +61,6 @@
 #include "SALOME_ListIteratorOfListIO.hxx"
 
 #include "SVTK_ViewWindow.h"
-//#include "SVTK_MainWindow.h"
 #include "SVTK_Selector.h"
 #include "SVTK_RenderWindowInteractor.h"
 
@@ -90,6 +90,7 @@
 #include <QHeaderView>
 #include <QTabWidget>
 #include <QScrollArea>
+#include <QStackedWidget>
 
 // VTK Includes
 #include <vtkDataSetMapper.h>
@@ -146,17 +147,26 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const VisuGUI* theModule, QWidge
 
   myTabWidget = new QTabWidget( mainFrame() );
 
-  // Labels for header of points' and cells' tables
-  QStringList aLabels;
-  aLabels.append( "ID" );
-  aLabels.append( "X" );
-  aLabels.append( "Y" );
-  aLabels.append( "Z" );
-  aLabels.append( "I" );
-  aLabels.append( "J" );
-  aLabels.append( "K" );
-  aLabels.append( tr("DATA_SCALAR_HDR") );
-  aLabels.append( tr("DATA_VECTOR_HDR") );
+  QTableWidget* aTable;
+
+  // Fill column data
+  myColumnData.insert( CellStdCell,  QList<int>() << Cell << Scalar << Vector );
+  myColumnData.insert( CellStdPoint, QList<int>() << Point << X << Y << Z << I << J << K << Scalar << Vector );
+  myColumnData.insert( PointStd,     QList<int>() << Point << X << Y << Z << I << J << K << Scalar << Vector );
+  myColumnData.insert( CellElno,     QList<int>() << Cell << Point << X << Y << Z << I << J << K << Scalar << Vector );
+  myColumnData.insert( PointElno,    QList<int>() << Point << X << Y << Z << I << J << K << Cell << Scalar << Vector );
+
+  QMap<int, QString> aColumnHeaders;
+  aColumnHeaders.insert( Cell, tr( "CELL_ID_HDR" ) );
+  aColumnHeaders.insert( Point, tr( "POINT_ID_HDR" ) );
+  aColumnHeaders.insert( X, "X" );
+  aColumnHeaders.insert( Y, "Y" );
+  aColumnHeaders.insert( Z, "Z" );
+  aColumnHeaders.insert( I, "I" );
+  aColumnHeaders.insert( J, "J" );
+  aColumnHeaders.insert( K, "K" );
+  aColumnHeaders.insert( Scalar, tr( "DATA_SCALAR_HDR" ) );
+  aColumnHeaders.insert( Vector, tr( "DATA_VECTOR_HDR" ) );
 
   // Create Points pane
   myPointsPane = new QWidget (mainFrame());
@@ -165,7 +175,7 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const VisuGUI* theModule, QWidge
   QGroupBox* aDataGrp = new QGroupBox ( tr("POINT_DATA_TITLE"), myPointsPane);
   QGridLayout* aGridLay = new QGridLayout (aDataGrp);
 
-  aGridLay->addWidget( new QLabel (tr("DATA_ID_LBL"), aDataGrp) , 0, 0 );
+  aGridLay->addWidget( new QLabel (tr("DATA_ID_LBL"), aDataGrp), 0, 0 );
   
   myIDValLbl = new QLineEdit ("", aDataGrp);
   aGridLay->addWidget( myIDValLbl, 0, 1 );
@@ -181,21 +191,17 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const VisuGUI* theModule, QWidge
 
   aVBoxLayout->addWidget( aDataGrp );
 
-  myListPoints = new QTableWidget (myPointsPane);
-  myListPoints->setEditTriggers( QAbstractItemView::NoEditTriggers );
-  myListPoints->setColumnCount(9);
-  myListPoints->setRowCount(0);
-  myListPoints->setColumnWidth(0, 40);
-  myListPoints->setColumnWidth(1, 40);
-  myListPoints->setColumnWidth(2, 40);
-  myListPoints->setColumnWidth(3, 40);
-  myListPoints->setColumnWidth(4, 40);
-  myListPoints->setColumnWidth(5, 40);
-  myListPoints->setColumnWidth(6, 40);
-  myListPoints->setSelectionMode(QAbstractItemView::NoSelection);
-  myListPoints->setHorizontalHeaderLabels( aLabels );
-
-  aVBoxLayout->addWidget(myListPoints, 1, 0);
+  myPointStackedWg = new QStackedWidget( myPointsPane );
+
+  aTable = new QTableWidget( myPointStackedWg );
+  myPointStackedWg->insertWidget( StdMesh, aTable );
+  myTables.insert( PointStd, aTable );
+
+  aTable = new QTableWidget( myPointStackedWg );
+  myPointStackedWg->insertWidget( ElnoMesh, aTable );
+  myTables.insert( PointElno, aTable );
+
+  aVBoxLayout->addWidget(myPointStackedWg, 1, 0);
 
   // Create Cells pane
   myCellsPane = new QWidget (mainFrame());
@@ -217,30 +223,58 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const VisuGUI* theModule, QWidge
   aGridLay->addWidget( aCellIDBtn, 0, 2 );
   connect(aCellIDBtn, SIGNAL(clicked()), this, SLOT(onCellIdEdit()));
 
-  aGridLay->addWidget( new QLabel (tr("DATA_SCALAR_LBL"), aCellGrp), 1, 0);
-  myCellScalarValLbl = new QLabel ("", aCellGrp);
-  aGridLay->addWidget( myCellScalarValLbl, 1, 1, 1, 2);
-  aGridLay->addWidget( new QLabel (tr("DATA_VECTOR_LBL"), aCellGrp), 2, 0);
-  myCellVectorValLbl = new QLabel ("", aCellGrp);
-  aGridLay->addWidget(myCellVectorValLbl , 2, 1, 1, 2);
-
   aCellLayout->addWidget(aCellGrp, 0, 0);
 
-  myCellListPoints = new QTableWidget (myCellsPane);
-  myCellListPoints->setEditTriggers( QAbstractItemView::NoEditTriggers );
-  myCellListPoints->setColumnCount(9);
-  myCellListPoints->setRowCount(0);
-  myCellListPoints->setColumnWidth(0, 40);
-  myCellListPoints->setColumnWidth(1, 40);
-  myCellListPoints->setColumnWidth(2, 40);
-  myCellListPoints->setColumnWidth(3, 40);
-  myCellListPoints->setColumnWidth(4, 40);
-  myCellListPoints->setColumnWidth(5, 40);
-  myCellListPoints->setColumnWidth(6, 40);
-  myCellListPoints->setSelectionMode(QAbstractItemView::NoSelection);
-  myCellListPoints->setHorizontalHeaderLabels( aLabels );
-
-  aCellLayout->addWidget(myCellListPoints, 1, 0);
+  myCellStackedWg = new QStackedWidget( myCellsPane );
+
+  QTabWidget* aStdTabWidget = new QTabWidget( myCellStackedWg );
+  myCellStackedWg->insertWidget( StdMesh, aStdTabWidget );
+
+  aTable = new QTableWidget( aStdTabWidget );
+  aStdTabWidget->addTab( aTable, tr("CELL_INFO") );
+  myTables.insert( CellStdCell, aTable );
+
+  aTable = new QTableWidget( aStdTabWidget );
+  aStdTabWidget->addTab( aTable, tr("POINT_INFO") );
+  myTables.insert( CellStdPoint, aTable );
+
+  aTable = new QTableWidget( myCellStackedWg );
+  myCellStackedWg->insertWidget( ElnoMesh, aTable );
+  myTables.insert( CellElno, aTable );
+
+  aCellLayout->addWidget(myCellStackedWg, 1, 0);
+
+  // Common operations for all tables
+  QMap<int, QTableWidget*>::iterator it = myTables.begin(), itEnd = myTables.end();
+  for( ; it != itEnd; ++it )
+  {
+    aTable = it.value();
+    if( !aTable )
+      continue;
+
+    int aTableId = it.key();
+    if( !myColumnData.contains( aTableId ) )
+      continue;
+
+    QStringList aHorizontalHeaderLabels;
+    QList<int> aColumns = myColumnData[ aTableId ];
+    QListIterator<int> aColumnIter( aColumns );
+    while( aColumnIter.hasNext() )
+    {
+      int aColumnId = aColumnIter.next();
+      if( aColumnId >= 0 && aColumnId < aColumnHeaders.size() )
+       aHorizontalHeaderLabels << aColumnHeaders[ aColumnId ];
+    }
+    aTable->setColumnCount( aHorizontalHeaderLabels.size() );
+    aTable->setHorizontalHeaderLabels( aHorizontalHeaderLabels );
+
+    aTable->setEditTriggers( QAbstractItemView::NoEditTriggers );
+    aTable->setSelectionMode( QAbstractItemView::SingleSelection );
+    aTable->resizeColumnsToContents();
+
+    connect( aTable, SIGNAL( doubleClicked( const QModelIndex& ) ),
+            this, SLOT( onDoubleClicked( const QModelIndex& ) ) );
+  }
 
   // Actor Pane
   myActorsPane = new QWidget (mainFrame());
@@ -326,6 +360,46 @@ VisuGUI_SelectionPanel::~VisuGUI_SelectionPanel()
   }
 }
 
+int VisuGUI_SelectionPanel::column( int theTableId, int theColumnId )
+{
+  if( !myColumnData.contains( theTableId ) )
+    return -1;
+
+  const QList<int>& aColumnList = myColumnData[ theTableId ];
+  return aColumnList.indexOf( theColumnId );
+}
+
+QVariant VisuGUI_SelectionPanel::data( int theTableId, int theRow, int theColumnId )
+{
+  if( !myTables.contains( theTableId ) )
+    return QVariant();
+
+  if( QTableWidget* aTable = myTables[ theTableId ] )
+    if( QAbstractItemModel* aModel = aTable->model() )
+      return aModel->data( aModel->index( theRow, column( theTableId, theColumnId ) ) );
+
+  return QVariant();
+}
+
+void VisuGUI_SelectionPanel::setData( int theTableId, int theRow, int theColumnId, const QVariant& theValue )
+{
+  if( !myTables.contains( theTableId ) )
+    return;
+
+  if( QTableWidget* aTable = myTables[ theTableId ] )
+    if( QAbstractItemModel* aModel = aTable->model() )
+      aModel->setData( aModel->index( theRow, column( theTableId, theColumnId ) ), theValue );
+}
+
+void VisuGUI_SelectionPanel::setRowSpan( int theTableId, int theRow, int theColumnId, int theRowSpan )
+{
+  if( !myTables.contains( theTableId ) )
+    return;
+
+  if( QTableWidget* aTable = myTables[ theTableId ] )
+    aTable->setSpan( theRow, column( theTableId, theColumnId ), theRowSpan, 1 );
+}
+
 VisuGUI_SelectionPrefDlg* VisuGUI_SelectionPanel::preferencesDlg()
 {
   if( !myPreferencesDlg )
@@ -336,13 +410,11 @@ VisuGUI_SelectionPrefDlg* VisuGUI_SelectionPanel::preferencesDlg()
 
 void VisuGUI_SelectionPanel::setSelectionMode( int theId )
 {
-  //printf( "VisuGUI_SelectionPanel::setSelectionMode( %d )\n", theId );
   myTabWidget->setCurrentIndex( theId );
 }
 
 void VisuGUI_SelectionPanel::onSelectionModeChanged( int theId )
 {
-  //printf( "VisuGUI_SelectionPanel::onSelectionModeChanged( %d )\n", theId );
   SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule);
   if (!aViewWindow) return;
 
@@ -382,7 +454,7 @@ void VisuGUI_SelectionPanel::closeEvent( QCloseEvent* theEvent )
   VisuGUI_Panel::closeEvent(theEvent);
 }
 
-template<class TData> QString getValue(TData* theData, int theId){
+template<class TData> QString getScalar(TData* theData, int theId){
   if (vtkDataArray *aScalar = theData->GetScalars()){
     vtkFloatingPointType aVal = aScalar->GetTuple1(theId);
     return QString::number(aVal);
@@ -400,6 +472,40 @@ template<class TData> QString getVector(TData* theData, int theId){
   }
 }
 
+template<class TData> TValueData getValueData( TPointID thePointVTKID, VISU_Actor* theActor, TData* theData )
+{
+  TValueData aValueData;
+
+  aValueData.Scalar = getScalar( theData, thePointVTKID );
+  aValueData.Vector = getVector( theData, thePointVTKID );
+
+  return aValueData;
+}
+
+TPointData getPointData( TPointID thePointVTKID, VISU_Actor* theActor, const VISU::PIDMapper& theMapper,
+                        bool theIsValueData )
+{
+  TPointData aPointData;
+
+  vtkDataSet* aDataSet = theActor->GetMapper()->GetInput();
+
+  vtkFloatingPointType* aCoord = aDataSet->GetPoint( thePointVTKID );
+  aPointData.X = aCoord[0];
+  aPointData.Y = aCoord[1];
+  aPointData.Z = aCoord[2];
+
+  TPointID aPointObjID = theActor->GetNodeObjId( thePointVTKID );
+  VISU::TStructuredId aVec = theMapper->GetIndexesOfNode( aPointObjID );
+  aPointData.I = aVec[0];
+  aPointData.J = aVec[1];
+  aPointData.K = aVec[2];
+
+  if( theIsValueData )
+    aPointData.ValueData = getValueData( thePointVTKID, theActor, aDataSet->GetPointData() );
+
+  return aPointData;
+}
+
 void VisuGUI_SelectionPanel::onSelectionEvent() {
   SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule);
   if (!aViewWindow)
@@ -422,11 +528,8 @@ void VisuGUI_SelectionPanel::onSelectionEvent() {
 
   int aType = myTabWidget->currentIndex();
 
-  //if(SVTK_MainWindow* aMainWindow = aViewWindow->getMainWindow())
-  //{
-    SVTK_RenderWindowInteractor* anInteractor = aViewWindow->GetInteractor();
-    myGaussPointsPane->setInteractor(anInteractor);
-    //}
+  SVTK_RenderWindowInteractor* anInteractor = aViewWindow->GetInteractor();
+  myGaussPointsPane->setInteractor(anInteractor);
 
   SVTK_Selector* aSelector = aViewWindow->GetSelector();
 
@@ -476,121 +579,286 @@ void VisuGUI_SelectionPanel::onSelectionEvent() {
       myDZLbl->setText(QString::number( fabs(aCoord[5]-aCoord[4]) ));
 
       TColStd_IndexedMapOfInteger aMapIndex;
-      typedef std::vector<vtkFloatingPointType> TCoordArray;
-      typedef map<int, TCoordArray> TPointCoordsMap;
-      TPointCoordsMap aPointCoordsMap;
-
       aSelector->GetIndex(anIO, aMapIndex);
+      bool aSingleSelection = aMapIndex.Extent() == 1;
 
       vtkDataSet* aDataSet = anVISUActor->GetMapper()->GetInput();
-      vtkPointData* aPntData = aDataSet->GetPointData();
-
-      QTableWidget* aTable = 0;
-      if( aType == 1 )
-       aTable = myCellListPoints;
-      else if( aType == 2 )
-       aTable = myListPoints;
+      bool isElno = VISU::IsElnoData( aDataSet );
 
-      if( !aTable )
-      {
-       myFl = false;
-       return;
-      }
+      const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper();
+      bool isStructured = aMapper->IsStructured();
 
-      bool aSingleSelection = aMapIndex.Extent() == 1;
+      TCellToPointDataMap aCellToPointDataMap;
+      TPointToCellDataMap aPointToCellDataMap;
+      TPointDataMap aGlobalPointDataMap;
 
       for (int ind = 1; ind <= aMapIndex.Extent(); ind++) {
         int anID = aMapIndex(ind);
 
-        switch (aType) {
-        case 2:
-          {
-           int aVTKID = anVISUActor->GetNodeVTKID(anID);
-           if(aVTKID >= 0){
-             vtkFloatingPointType* aCoord = anVISUActor->GetNodeCoord(anID);
-
-             if( aSingleSelection )
-               myIDValLbl->setText( QString::number(anID) );
-
-             vtkIdType aNodeObjId = anVISUActor->GetNodeObjId(aVTKID);
-             TCoordArray aCoordArray(aCoord, aCoord + 3);
-             aPointCoordsMap[aNodeObjId] = aCoordArray;
+        switch( aType )
+       {
+          case 1:
+         {
+           if( aSingleSelection )
+             myCellIDValLbl->setText( QString::number( anID ) );
+
+            vtkCell* aCell = anVISUActor->GetElemCell( anID );
+           int aCellVTKID = anVISUActor->GetElemVTKID( anID );
+            if( !aCell || aCellVTKID < 0 )
+             break;
+
+           int aNbOfPoints = aCell->GetNumberOfPoints();
+           if( aNbOfPoints < 1 )
+             break;
+
+           TPointDataMap aPointDataMap;
+
+           vtkIdList* aPointList = aCell->GetPointIds();
+           for( int i = 0; i < aNbOfPoints; i++ )
+           {
+             int aPointVTKID = aPointList->GetId(i);
+
+             TPointID aPointID = anVISUActor->GetNodeObjId( aPointVTKID );
+             TPointData aPointData = getPointData( aPointVTKID, anVISUActor, aMapper, true );
+             aPointDataMap[ aPointID ] = aPointData;
+             aGlobalPointDataMap[ aPointID ] = aPointData;
            }
+
+           TCellToPointData aCellToPointData;
+           aCellToPointData.CellData = getValueData( aCellVTKID, anVISUActor, aDataSet->GetCellData() );
+           aCellToPointData.PointDataMap = aPointDataMap;
+           aCellToPointDataMap[ anID ] = aCellToPointData;
+           break;
           }
-          break;
-        case 1:
+          case 2:
           {
-            vtkCellData* aCellData = aDataSet->GetCellData();
-            vtkCell* aCell = anVISUActor->GetElemCell(anID);
-           int aVTKID = anVISUActor->GetElemVTKID(anID);
-            if (aCell != NULL) {
-              int aNbOfPoints = aCell->GetNumberOfPoints();
-              if ( aNbOfPoints > 0 ) {
-               if( aSingleSelection )
-               {
-                 myCellIDValLbl->setText( QString::number(anID) );
-                 myCellScalarValLbl->setText(getValue(aCellData, aVTKID));
-                 myCellVectorValLbl->setText(getVector(aCellData, aVTKID));
-               }
+           if( aSingleSelection )
+             myIDValLbl->setText( QString::number( anID ) );
+
+           int aPointVTKID = anVISUActor->GetNodeVTKID( anID );
+           if( aPointVTKID < 0 )
+             break;
+
+           TCellDataMap aCellDataMap;
+
+           VISU::TElnoPoints anElnoPoints = VISU::GetElnoPoints( aDataSet, anID );
+           VISU::TElnoPoints::iterator anElnoIter = anElnoPoints.begin();
+           for( ; anElnoIter != anElnoPoints.end(); anElnoIter++ )
+           {
+             VISU::TElnoPointID anElnoPointID = *anElnoIter;
+             VISU::TVTKPointID aVTKPointID = anElnoPointID.first;
+             VISU::TVTKCellID aVTKCellID = anElnoPointID.second;
+
+             TCellID aCellID = anVISUActor->GetElemObjId( aVTKCellID );
+             TValueData aValueData = getValueData( aVTKPointID, anVISUActor, aDataSet->GetPointData() );
+             aCellDataMap[ aCellID ] = aValueData;
+           }
 
-                vtkIdList *aPointList = aCell->GetPointIds();
-                for (int i = 0; i < aNbOfPoints; i++) {
-                  int aNodeVTKId = aPointList->GetId(i);
-                  vtkFloatingPointType* aCoord = aDataSet->GetPoint(aNodeVTKId);
-                 vtkIdType aNodeObjId = anVISUActor->GetNodeObjId(aNodeVTKId);
-                 TCoordArray aCoordArray(aCoord, aCoord + 3);
-                  aPointCoordsMap[aNodeObjId] = aCoordArray;
-                }
-              }
-            }
+           TPointToCellData aPointToCellData;
+           aPointToCellData.PointData = getPointData( aPointVTKID, anVISUActor, aMapper, !isElno );
+           aPointToCellData.CellDataMap = aCellDataMap;
+           aPointToCellDataMap[ anID ] = aPointToCellData;
+           break;
           }
-          break;
         }
       }
 
-      aTable->setRowCount(aPointCoordsMap.size());
-      TPointCoordsMap::const_iterator anIter = aPointCoordsMap.begin();
+      // Fill tables
+      QList<int> aTableIds;
+      switch( aType )
+      {
+        case 1:
+         if( isElno )
+           aTableIds.append( CellElno );
+         else
+         {
+           aTableIds.append( CellStdCell );
+           aTableIds.append( CellStdPoint );
+         }
+         break;
+        case 2:
+         aTableIds.append( isElno ? PointElno : PointStd );
+         break;
+      }
 
-      const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper();
-      for (int i = 0; anIter != aPointCoordsMap.end() && i < aTable->rowCount(); anIter++, i++) {
-       aTable->model()->setHeaderData( i, Qt::Vertical, QVariant(QString::number( i )), Qt::DisplayRole );
-        vtkIdType aNodeObjId = anIter->first;
-       
-       //VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(aNodeObjId);
-       VISU::TStructuredId aVec = aMapper->GetIndexesOfNode(aNodeObjId);
-       QString aI,aJ,aK;
-       aI = "-";
-       aJ = "-";
-       aK = "-";
-       //switch(aVec.size()){
-       //case 3:
-       if (aVec[2] != -1)
-         aK = QString::number(aVec[2]);
-         //case 2:
-       if (aVec[1] != -1)
-         aJ = QString::number(aVec[1]);
-         //case 1:
-       if (aVec[0] != -1)
-         aI = QString::number(aVec[0]);
-         //break;
-         //}
-       
-       QAbstractItemModel* aModel = aTable->model();
-       aModel->setData( aModel->index(i,0), QVariant(QString::number( aNodeObjId )), Qt::DisplayRole );
-        const TCoordArray& aCoordArray = anIter->second;
-       aModel->setData( aModel->index(i,1), QVariant(QString::number( aCoordArray[0] )), Qt::DisplayRole );
-       aModel->setData( aModel->index(i,2), QVariant(QString::number( aCoordArray[1] )), Qt::DisplayRole );
-       aModel->setData( aModel->index(i,3), QVariant(QString::number( aCoordArray[2] )), Qt::DisplayRole );
-       aModel->setData( aModel->index(i,4), QVariant( aI ), Qt::DisplayRole );
-       aModel->setData( aModel->index(i,5), QVariant( aJ ), Qt::DisplayRole );
-       aModel->setData( aModel->index(i,6), QVariant( aK ), Qt::DisplayRole );
-
-       vtkIdType aNodeVTKId = anVISUActor->GetNodeVTKID(aNodeObjId);
-       aModel->setData( aModel->index(i,7), QVariant(getValue(aPntData, aNodeVTKId)), Qt::DisplayRole );
-       aModel->setData( aModel->index(i,8), QVariant(getVector(aPntData, aNodeVTKId)), Qt::DisplayRole );
+      QListIterator<int> aTableIter( aTableIds );
+      while( aTableIter.hasNext() )
+      {
+       int aTableId = aTableIter.next();
+       if( !myTables.contains( aTableId ) )
+         continue;
+
+       QTableWidget* aTable = myTables[ aTableId ];
+       if( !aTable )
+         continue;
+
+       int aRow = -1;
+       switch( aTableId )
+       {
+         case CellStdPoint:
+         {
+           int aRowCount = aGlobalPointDataMap.size();
+           aTable->setRowCount( aRowCount );
+
+           TPointDataMap::const_iterator aPointIter = aGlobalPointDataMap.begin();
+           for( ; aPointIter != aGlobalPointDataMap.end(); aPointIter++ )
+           {
+             aRow++;
+             TPointID aPointID = aPointIter.key();
+             const TPointData& aPointData = aPointIter.value();
+             const TValueData& aValueData = aPointData.ValueData;
+
+             setData( aTableId, aRow, Point, aPointID );
+             setData( aTableId, aRow, X, aPointData.X );
+             setData( aTableId, aRow, Y, aPointData.Y );
+             setData( aTableId, aRow, Z, aPointData.Z );
+             setData( aTableId, aRow, I, aPointData.I );
+             setData( aTableId, aRow, J, aPointData.J );
+             setData( aTableId, aRow, K, aPointData.K );
+             setData( aTableId, aRow, Scalar, aValueData.Scalar );
+             setData( aTableId, aRow, Vector, aValueData.Vector );
+           }
+           break;
+         }
+         case CellStdCell:
+         case CellElno:
+         {
+           int aRowCount = 0;
+           TCellToPointDataMap::const_iterator aCellToPointIter = aCellToPointDataMap.begin();
+           for( ; aCellToPointIter != aCellToPointDataMap.end(); aCellToPointIter++ )
+           {
+             if( aTableId == CellStdCell )
+               aRowCount++;
+             else if( aTableId == CellElno )
+             {
+               const TCellToPointData& aCellToPointData = aCellToPointIter.value();
+               const TPointDataMap& aPointDataMap = aCellToPointData.PointDataMap;
+               int aNbPoints = aPointDataMap.size();
+
+               aRowCount += aNbPoints;
+             }
+           }
+           aTable->setRowCount( aRowCount );
+
+           aCellToPointIter = aCellToPointDataMap.begin();
+           for( ; aCellToPointIter != aCellToPointDataMap.end(); aCellToPointIter++ )
+           {
+             aRow++;
+
+             TCellID aCellID = aCellToPointIter.key();
+             const TCellToPointData& aCellToPointData = aCellToPointIter.value();
+             const TValueData& aCellData = aCellToPointData.CellData;
+
+             setData( aTableId, aRow, Cell, aCellID );
+             if( aTableId == CellStdCell )
+             {
+               setData( aTableId, aRow, Scalar, aCellData.Scalar );
+               setData( aTableId, aRow, Vector, aCellData.Vector );
+             }
+             else if( aTableId == CellElno )
+             {
+               const TPointDataMap& aPointDataMap = aCellToPointData.PointDataMap;
+               int aNbPoints = aPointDataMap.size();
+               if( aNbPoints > 1 )
+                 setRowSpan( aTableId, aRow, Cell, aNbPoints );
+
+               TPointDataMap::const_iterator aPointIter = aPointDataMap.begin();
+               for( aRow--; aPointIter != aPointDataMap.end(); aPointIter++ )
+               {
+                 aRow++;
+                 TPointID aPointID = aPointIter.key();
+                 const TPointData& aPointData = aPointIter.value();
+                 const TValueData& aValueData = aPointData.ValueData;
+
+                 setData( aTableId, aRow, Point, aPointID );
+                 setData( aTableId, aRow, X, aPointData.X );
+                 setData( aTableId, aRow, Y, aPointData.Y );
+                 setData( aTableId, aRow, Z, aPointData.Z );
+                 setData( aTableId, aRow, I, aPointData.I );
+                 setData( aTableId, aRow, J, aPointData.J );
+                 setData( aTableId, aRow, K, aPointData.K );
+                 setData( aTableId, aRow, Scalar, aValueData.Scalar );
+                 setData( aTableId, aRow, Vector, aValueData.Vector );
+               }
+             }
+           }
+           break;
+         }
+         case PointStd:
+         case PointElno:
+         {
+           int aRowCount = 0;
+           TPointToCellDataMap::const_iterator aPointToCellIter = aPointToCellDataMap.begin();
+           for( ; aPointToCellIter != aPointToCellDataMap.end(); aPointToCellIter++ )
+           {
+             const TPointToCellData& aPointToCellData = aPointToCellIter.value();
+             const TCellDataMap& aCellDataMap = aPointToCellData.CellDataMap;
+             int aNbCells = aCellDataMap.size();
+             if( aNbCells > 1 )
+               aRowCount += aNbCells;
+             else
+               aRowCount++;          
+           }
+           aTable->setRowCount( aRowCount );
+
+           aPointToCellIter = aPointToCellDataMap.begin();
+           for( ; aPointToCellIter != aPointToCellDataMap.end(); aPointToCellIter++ )
+           {
+             aRow++;
+
+             TPointID aPointID = aPointToCellIter.key();
+             const TPointToCellData& aPointToCellData = aPointToCellIter.value();
+             const TPointData& aPointData = aPointToCellData.PointData;
+
+             setData( aTableId, aRow, Point, aPointID );
+             setData( aTableId, aRow, X, aPointData.X );
+             setData( aTableId, aRow, Y, aPointData.Y );
+             setData( aTableId, aRow, Z, aPointData.Z );
+             setData( aTableId, aRow, I, aPointData.I );
+             setData( aTableId, aRow, J, aPointData.J );
+             setData( aTableId, aRow, K, aPointData.K );
+
+             if( aTableId == PointElno )
+             {
+               const TCellDataMap& aCellDataMap = aPointToCellData.CellDataMap;
+               int aNbCells = aCellDataMap.size();
+               if( aNbCells > 1 )
+                 for( int aColumnId = Point; aColumnId <= K; aColumnId++ )
+                   setRowSpan( aTableId, aRow, aColumnId, aNbCells );
+
+               TCellDataMap::const_iterator aCellIter = aCellDataMap.begin();
+               for( aRow--; aCellIter != aCellDataMap.end(); aCellIter++ )
+               {
+                 aRow++;
+                 TCellID aCellID = aCellIter.key();
+                 const TValueData& aCellData = aCellIter.value();
+
+                 setData( aTableId, aRow, Cell, aCellID );
+                 setData( aTableId, aRow, Scalar, aCellData.Scalar );
+                 setData( aTableId, aRow, Vector, aCellData.Vector );
+               }
+             }
+             else
+             {
+               const TValueData& aValueData = aPointData.ValueData;
+               setData( aTableId, aRow, Scalar, aValueData.Scalar );
+               setData( aTableId, aRow, Vector, aValueData.Vector );
+             }
+           }
+           break;
+         }
+       }
+
+       for( int aCol = column( aTableId, I ), aLastCol = column( aTableId, K ); aCol <= aLastCol; aCol++ )
+         if( aCol != -1 )
+           aTable->setColumnHidden( aCol, !isStructured );
+       aTable->resizeColumnsToContents();
       }
-      //for(int aColumnId = 0; aColumnId < 9; aColumnId++)
-      aTable->resizeColumnsToContents();
+
+      int stackId = isElno ? ElnoMesh : StdMesh;
+      QStackedWidget* aStackedWg = aType == 1 ? myCellStackedWg : aType == 2 ? myPointStackedWg : 0;
+      if( aStackedWg )
+       aStackedWg->setCurrentIndex( stackId );
     }
   }
   myFl = false;
@@ -599,16 +867,6 @@ void VisuGUI_SelectionPanel::onSelectionEvent() {
 void VisuGUI_SelectionPanel::clearFields() {
   int aType = myTabWidget->currentIndex();
   switch (aType) {
-  case 2:
-    myIDValLbl->setText( "" );
-    myListPoints->setRowCount(0);
-    break;
-  case 1:
-    myCellIDValLbl->setText( "" );
-    myCellScalarValLbl->setText("");
-    myCellVectorValLbl->setText("");
-    myCellListPoints->setRowCount(0);
-    break;
   case 0:
     myXPosLbl->setText("");
     myYPosLbl->setText("");
@@ -616,7 +874,23 @@ void VisuGUI_SelectionPanel::clearFields() {
     myDXLbl->setText("");
     myDYLbl->setText("");
     myDZLbl->setText("");
+    break;
+  case 1:
+    myCellIDValLbl->setText( "" );
+    break;
+  case 2:
+    myIDValLbl->setText( "" );
+    break;
   }
+
+  QMap<int, QTableWidget*>::iterator it = myTables.begin(), itEnd = myTables.end();
+  for( ; it != itEnd; ++it )
+    if( QTableWidget* aTable = *it )
+    {
+      aTable->clearSpans();
+      aTable->setRowCount(0);
+      aTable->resizeColumnsToContents();
+    }
 }
 
 typedef  vtkIdType (VISU_PipeLine::* TGetVTKIdMethod)(vtkIdType theID);
@@ -675,13 +949,10 @@ bool onIdEdit (const QString& theText,
 
     aViewWindow->highlight(anIO, true, true);
 
-    //if( SVTK_MainWindow* aMainWindow = aViewWindow->getMainWindow() )
-    //{
-      SVTK_RenderWindowInteractor* anInteractor = aViewWindow->GetInteractor();
-      VISU_Actor* anActor = SVTK::Find<VISU_Actor>(anInteractor->getRenderer()->GetActors(),
-                                                  SVTK::TIsSameIObject<VISU_Actor>( anIO ));
-      anActor->Highlight( anIO );
-      //}
+    SVTK_RenderWindowInteractor* anInteractor = aViewWindow->GetInteractor();
+    VISU_Actor* anActor = SVTK::Find<VISU_Actor>(anInteractor->getRenderer()->GetActors(),
+                                                SVTK::TIsSameIObject<VISU_Actor>( anIO ));
+    anActor->Highlight( anIO );
 
     return true;
 
@@ -728,9 +999,71 @@ void VisuGUI_SelectionPanel::onCellIdEdit ()
     clearFields();
 }
 
+void VisuGUI_SelectionPanel::onDoubleClicked( const QModelIndex& theIndex )
+{
+  QTableWidget* aTable = dynamic_cast<QTableWidget*>( sender() );
+  if( !aTable )
+    return;
+
+  int aTableId = myTables.key( aTable, -1 );
+  if( aTableId == -1 )
+    return;
+
+  int aRow = theIndex.row(), aCol = theIndex.column();
+  const QList<int>& aColumnList = myColumnData[ aTableId ];
+
+  if( aCol >= aColumnList.size() )
+    return;
+
+  int aColumnId = aColumnList[ aCol ];
+
+  bool anIsCellSelection = true;
+  switch( aColumnId )
+  {
+    case Cell:
+      anIsCellSelection = true;
+      break;
+    case Point:
+    case X:
+    case Y:
+    case Z:
+    case I:
+    case J:
+    case K:
+      anIsCellSelection = false;
+      break;
+    case Scalar:
+    case Vector:
+      anIsCellSelection = aTableId == CellStdCell || aTableId == PointElno;
+      break;
+    default:
+      return;
+  }
+
+  int anIdColumnId = anIsCellSelection ? Cell : Point;
+  QVariant anId = data( aTableId, aRow, anIdColumnId );
+
+  bool ok = false;
+  anId.toInt( &ok );
+  if( !ok )
+    return;
+
+  if( anIsCellSelection )
+  {
+    setSelectionMode( 1 );
+    myCellIDValLbl->setText( anId.toString() );
+    onCellIdEdit();
+  }
+  else
+  {
+    setSelectionMode( 2 );
+    myIDValLbl->setText( anId.toString() );
+    onPointIdEdit();
+  }
+}
+
 void VisuGUI_SelectionPanel::onIdChanged( int theFirstId, int theSecondId )
 {
-  //printf( "VisuGUI_SelectionPanel::onIdChanged( %d, %d )\n", theFirstId, theSecondId );
   int aType = myTabWidget->currentIndex();
   if( aType == 1 )
   {
index 0ebd395635202c6ae30c470432ea73e0d5ad7b2a..3d5faf1b10c6b88b5d8ab8e7730fd9816814f4f7 100644 (file)
 
 #include <VisuGUI_Panel.h>
 
+#include <QMap>
+
+#include <vtkSystemIncludes.h>
+
 class QLabel;
 class QLineEdit;
+class QModelIndex;
+class QStackedWidget;
 class QTableWidget;
 class QTabWidget;
 
@@ -39,10 +45,52 @@ class VisuGUI_GaussPointsSelectionPane;
 class VisuGUI_FindPane;
 class VisuGUI_SelectionPrefDlg;
 
+typedef vtkIdType TPointID;
+typedef vtkIdType TCellID;
+
+struct TValueData
+{
+  QString Scalar;
+  QString Vector;
+};
+
+struct TPointData
+{
+  vtkFloatingPointType X;
+  vtkFloatingPointType Y;
+  vtkFloatingPointType Z;
+  vtkIdType I;
+  vtkIdType J;
+  vtkIdType K;
+  TValueData ValueData;
+};
+
+typedef QMap<TPointID, TPointData> TPointDataMap;
+typedef QMap<TCellID,  TValueData> TCellDataMap;
+
+struct TCellToPointData
+{
+  TValueData CellData;
+  TPointDataMap PointDataMap;
+};
+
+struct TPointToCellData
+{
+  TPointData PointData;
+  TCellDataMap CellDataMap;
+};
+  
+typedef QMap<TCellID,  TCellToPointData> TCellToPointDataMap;
+typedef QMap<TPointID, TPointToCellData> TPointToCellDataMap;
+
 class VisuGUI_SelectionPanel: public VisuGUI_Panel
 {
   Q_OBJECT
 
+  enum MeshType { StdMesh = 0, ElnoMesh };
+  enum TableId { CellStdCell = 0, CellStdPoint, PointStd, CellElno, PointElno };
+  enum ColumnId { Cell = 0, Point, X, Y, Z, I, J, K, Scalar, Vector };
+
 public:
   VisuGUI_SelectionPanel( const VisuGUI* theModule, QWidget* theParent = 0 );
   virtual ~VisuGUI_SelectionPanel ();
@@ -66,6 +114,7 @@ private slots:
   void                      onSelectionEvent();
   void                      onPointIdEdit();
   void                      onCellIdEdit();
+  void                      onDoubleClicked( const QModelIndex& theIndex );
 
   void                      onIdChanged( int theFirstId, int theSecondId );
 
@@ -76,6 +125,11 @@ private:
   VisuGUI_SelectionPrefDlg* preferencesDlg();
   void                      clearFields();
 
+  int                       column( int theTableId, int theColumnId );
+  QVariant                  data( int theTableId, int theRow, int theColumnId );
+  void                      setData( int theTableId, int theRow, int theColumnId, const QVariant& theValue );
+  void                      setRowSpan( int theTableId, int theRow, int theColumnId, int theRowSpan );
+
 private:
   QLabel*                   myMeshName;
   QLabel*                   myFieldName;
@@ -85,12 +139,12 @@ private:
   QWidget*                  myCellsPane;
 
   QLineEdit*                myIDValLbl;
-  QTableWidget*             myListPoints;
+  QStackedWidget*           myPointStackedWg;
 
   QLineEdit*                myCellIDValLbl;
-  QLabel*                   myCellScalarValLbl;
-  QLabel*                   myCellVectorValLbl;
-  QTableWidget*             myCellListPoints;
+  QStackedWidget*           myCellStackedWg;
+
+  QMap<int, QTableWidget*>  myTables;
 
   QWidget*                  myActorsPane;
   QLabel*                   myXPosLbl;
@@ -107,6 +161,8 @@ private:
   VisuGUI_SelectionPrefDlg* myPreferencesDlg;
 
   bool                      myFl;
+
+  QMap< int, QList<int> >   myColumnData;
 };
 
 #endif