]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_SelectionPanel.cxx
Salome HOME
IPAL21035 It's impossible to hide scalar bar for gauss points
[modules/visu.git] / src / VISUGUI / VisuGUI_SelectionPanel.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  VISU VISUGUI : GUI of VISU component
23 //  File   : VisuGUI_SelectionPanel.h
24 //  Author : Laurent CORNABE & Hubert ROLLAND
25 //  Module : VISU
26 //  $Header$
27 //
28 #include "VisuGUI_SelectionPanel.h"
29
30 #include "VisuGUI.h"
31 #include "VisuGUI_Tools.h"
32 #include "VisuGUI_ViewTools.h"
33 #include "VisuGUI_SelectionPrefDlg.h"
34 #include "VisuGUI_GaussPointsSelectionPane.h"
35 #include "VisuGUI_FindPane.h"
36
37 #include "VISU_Event.h"
38 #include "VISU_ConvertorUtils.hxx"
39
40 #include "VISU_Actor.h"
41 #include "VISU_PrsObject_i.hh"
42 #include "VISU_Prs3d_i.hh"
43 #include "VISU_PipeLine.hxx"
44 #include "VISU_GaussPointsPL.hxx"
45 #include "VISU_GaussPtsSettings.h"
46 #include "VISU_PickingSettings.h"
47
48 #include "SalomeApp_Study.h"
49 #include "SalomeApp_Application.h"
50 #include "LightApp_Application.h"
51 #include "LightApp_SelectionMgr.h"
52 #include "LightApp_VTKSelector.h"
53
54 #include "SUIT_Desktop.h"
55 #include "SUIT_MessageBox.h"
56 #include "SUIT_ViewWindow.h"
57 #include "SUIT_Session.h"
58 #include "SUIT_ResourceMgr.h"
59
60 #include "SALOME_ListIO.hxx"
61 #include "SALOME_ListIteratorOfListIO.hxx"
62
63 #include "SVTK_ViewWindow.h"
64 #include "SVTK_Selector.h"
65 #include "SVTK_RenderWindowInteractor.h"
66
67 #include "utilities.h"
68
69 // OCCT Includes
70 #include <TColStd_IndexedMapOfInteger.hxx>
71 #include <TColStd_MapOfInteger.hxx>
72
73 // QT Includes
74 #include <QLabel>
75 #include <QSpinBox>
76 #include <QListWidget>
77 #include <QLayout>
78 #include <QButtonGroup>
79 #include <QRadioButton>
80 #include <QValidator>
81 #include <QPushButton>
82 #include <QToolButton>
83 #include <QGroupBox>
84 #include <QLineEdit>
85 #include <QValidator>
86 #include <QTableWidget>
87 #include <QVBoxLayout>
88 #include <QHBoxLayout>
89 #include <QKeyEvent>
90 #include <QHeaderView>
91 #include <QTabWidget>
92 #include <QScrollArea>
93 #include <QStackedWidget>
94
95 // VTK Includes
96 #include <vtkDataSetMapper.h>
97 #include <vtkDataSet.h>
98 #include <vtkPointData.h>
99 #include <vtkCellData.h>
100 #include <vtkCell.h>
101
102 // STL Includes
103 #include <map>
104
105 using namespace std;
106
107 class CustomIntValidator: public QIntValidator
108 {
109 public:
110   CustomIntValidator( QObject * theParent ):
111     QIntValidator( 0, VTK_LARGE_ID, theParent )
112   {}
113
114   virtual 
115   State
116   validate( QString& theInput, int& thePos ) const
117   {
118     if( theInput.isEmpty() )
119       return QValidator::Acceptable;
120
121     return QIntValidator::validate( theInput, thePos );
122   }
123 };
124
125 VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const VisuGUI* theModule, QWidget* theParent ) :
126   VisuGUI_Panel( tr("WINDOW_TITLE" ), theModule, theParent, CloseBtn | HelpBtn ),
127   myPreferencesDlg( 0 )
128 {
129   QVBoxLayout* TopLayout = new QVBoxLayout ( mainFrame() );
130
131   QWidget* aNamePane = new QWidget (mainFrame());
132   QGridLayout* aNameLay = new QGridLayout (aNamePane);
133
134   QLabel* aMeshLbl = new QLabel (tr("MESH_NAME_LBL"), aNamePane);
135   myMeshName = new QLabel (aNamePane);
136   myMeshName->setText(tr("WRN_NO_AVAILABLE_DATA"));
137
138   QLabel* aFieldLbl = new QLabel (tr("FIELD_NAME_LBL"), aNamePane);
139   myFieldName = new QLabel (aNamePane);
140
141   aNameLay->addWidget(aMeshLbl, 0, 0);
142   aNameLay->addWidget(myMeshName, 0, 1);
143   aNameLay->addWidget(aFieldLbl, 1, 0);
144   aNameLay->addWidget(myFieldName, 1, 1);
145
146   TopLayout->addWidget(aNamePane);
147
148   myTabWidget = new QTabWidget( mainFrame() );
149
150   QTableWidget* aTable;
151
152   // Fill column data
153   myColumnData.insert( CellStdCell,  QList<int>() << Cell << Scalar << Vector );
154   myColumnData.insert( CellStdPoint, QList<int>() << Point << X << Y << Z << I << J << K << Scalar << Vector );
155   myColumnData.insert( PointStd,     QList<int>() << Point << X << Y << Z << I << J << K << Scalar << Vector );
156   myColumnData.insert( CellElno,     QList<int>() << Cell << Point << X << Y << Z << I << J << K << Scalar << Vector );
157   myColumnData.insert( PointElno,    QList<int>() << Point << X << Y << Z << I << J << K << Cell << Scalar << Vector );
158
159   QMap<int, QString> aColumnHeaders;
160   aColumnHeaders.insert( Cell, tr( "CELL_ID_HDR" ) );
161   aColumnHeaders.insert( Point, tr( "POINT_ID_HDR" ) );
162   aColumnHeaders.insert( X, "X" );
163   aColumnHeaders.insert( Y, "Y" );
164   aColumnHeaders.insert( Z, "Z" );
165   aColumnHeaders.insert( I, "I" );
166   aColumnHeaders.insert( J, "J" );
167   aColumnHeaders.insert( K, "K" );
168   aColumnHeaders.insert( Scalar, tr( "DATA_SCALAR_HDR" ) );
169   aColumnHeaders.insert( Vector, tr( "DATA_VECTOR_HDR" ) );
170
171   // Create Points pane
172   myPointsPane = new QWidget (mainFrame());
173   QVBoxLayout* aVBoxLayout = new QVBoxLayout(myPointsPane);
174
175   QGroupBox* aDataGrp = new QGroupBox ( tr("POINT_DATA_TITLE"), myPointsPane);
176   QGridLayout* aGridLay = new QGridLayout (aDataGrp);
177
178   aGridLay->addWidget( new QLabel (tr("DATA_ID_LBL"), aDataGrp), 0, 0 );
179   
180   myIDValLbl = new QLineEdit ("", aDataGrp);
181   aGridLay->addWidget( myIDValLbl, 0, 1 );
182   CustomIntValidator* aIntValidator = new CustomIntValidator (myIDValLbl);
183   aIntValidator->setBottom(0);
184   myIDValLbl->setValidator(aIntValidator);
185   connect(myIDValLbl, SIGNAL(returnPressed()), this, SLOT(onPointIdEdit()));
186
187   QToolButton* anIDBtn = new QToolButton( aDataGrp );
188   anIDBtn->setIcon( VISU::GetResourceMgr()->loadPixmap("VISU", tr( "ICON_OK" ) ) );
189   aGridLay->addWidget( anIDBtn, 0, 2 );
190   connect(anIDBtn, SIGNAL(clicked()), this, SLOT(onPointIdEdit()));
191
192   aVBoxLayout->addWidget( aDataGrp );
193
194   myPointStackedWg = new QStackedWidget( myPointsPane );
195
196   aTable = new QTableWidget( myPointStackedWg );
197   myPointStackedWg->insertWidget( StdMesh, aTable );
198   myTables.insert( PointStd, aTable );
199
200   aTable = new QTableWidget( myPointStackedWg );
201   myPointStackedWg->insertWidget( ElnoMesh, aTable );
202   myTables.insert( PointElno, aTable );
203
204   aVBoxLayout->addWidget(myPointStackedWg, 1, 0);
205
206   // Create Cells pane
207   myCellsPane = new QWidget (mainFrame());
208   QGridLayout* aCellLayout = new QGridLayout (myCellsPane);
209   aCellLayout->setRowStretch(0, 0);
210   aCellLayout->setRowStretch(1, 1);
211
212   QGroupBox* aCellGrp = new QGroupBox( tr("CELL_DATA_TITLE"), myCellsPane);
213   aGridLay = new QGridLayout (aCellGrp);
214
215   aGridLay->addWidget( new QLabel (tr("DATA_ID_LBL"), aCellGrp), 0, 0);
216   myCellIDValLbl = new QLineEdit ("", aCellGrp);
217   myCellIDValLbl->setValidator(aIntValidator);
218   aGridLay->addWidget( myCellIDValLbl, 0, 1);
219   connect(myCellIDValLbl, SIGNAL(returnPressed()), this, SLOT(onCellIdEdit()));
220
221   QToolButton* aCellIDBtn = new QToolButton( aDataGrp );
222   aCellIDBtn->setIcon( VISU::GetResourceMgr()->loadPixmap("VISU", tr( "ICON_OK" ) ) );
223   aGridLay->addWidget( aCellIDBtn, 0, 2 );
224   connect(aCellIDBtn, SIGNAL(clicked()), this, SLOT(onCellIdEdit()));
225
226   aCellLayout->addWidget(aCellGrp, 0, 0);
227
228   myCellStackedWg = new QStackedWidget( myCellsPane );
229
230   QTabWidget* aStdTabWidget = new QTabWidget( myCellStackedWg );
231   myCellStackedWg->insertWidget( StdMesh, aStdTabWidget );
232
233   aTable = new QTableWidget( aStdTabWidget );
234   aStdTabWidget->addTab( aTable, tr("CELL_INFO") );
235   myTables.insert( CellStdCell, aTable );
236
237   aTable = new QTableWidget( aStdTabWidget );
238   aStdTabWidget->addTab( aTable, tr("POINT_INFO") );
239   myTables.insert( CellStdPoint, aTable );
240
241   aTable = new QTableWidget( myCellStackedWg );
242   myCellStackedWg->insertWidget( ElnoMesh, aTable );
243   myTables.insert( CellElno, aTable );
244
245   aCellLayout->addWidget(myCellStackedWg, 1, 0);
246
247   // Common operations for all tables
248   QMap<int, QTableWidget*>::iterator it = myTables.begin(), itEnd = myTables.end();
249   for( ; it != itEnd; ++it )
250   {
251     aTable = it.value();
252     if( !aTable )
253       continue;
254
255     int aTableId = it.key();
256     if( !myColumnData.contains( aTableId ) )
257       continue;
258
259     QStringList aHorizontalHeaderLabels;
260     QList<int> aColumns = myColumnData[ aTableId ];
261     QListIterator<int> aColumnIter( aColumns );
262     while( aColumnIter.hasNext() )
263     {
264       int aColumnId = aColumnIter.next();
265       if( aColumnId >= 0 && aColumnId < aColumnHeaders.size() )
266         aHorizontalHeaderLabels << aColumnHeaders[ aColumnId ];
267     }
268     aTable->setColumnCount( aHorizontalHeaderLabels.size() );
269     aTable->setHorizontalHeaderLabels( aHorizontalHeaderLabels );
270
271     aTable->setEditTriggers( QAbstractItemView::NoEditTriggers );
272     aTable->setSelectionMode( QAbstractItemView::SingleSelection );
273     aTable->resizeColumnsToContents();
274
275     connect( aTable, SIGNAL( doubleClicked( const QModelIndex& ) ),
276              this, SLOT( onDoubleClicked( const QModelIndex& ) ) );
277   }
278
279   // Actor Pane
280   myActorsPane = new QWidget (mainFrame());
281   aVBoxLayout = new QVBoxLayout(myActorsPane);  
282
283   QGroupBox* aPosGrp = new QGroupBox (tr("ACTOR_DATA_POSITION_TITLE"), myActorsPane);
284   aGridLay = new QGridLayout (aPosGrp);
285   aGridLay->addWidget( new QLabel ("X:", aPosGrp), 0, 0);
286   myXPosLbl = new QLabel ("0", aPosGrp);
287   aGridLay->addWidget( myXPosLbl, 0, 1);
288   aGridLay->addWidget( new QLabel ("Y:", aPosGrp), 1, 0);
289   myYPosLbl = new QLabel ("0", aPosGrp);
290   aGridLay->addWidget( myYPosLbl, 1, 1);
291   aGridLay->addWidget( new QLabel ("Z:", aPosGrp), 2, 0);
292   myZPosLbl = new QLabel ("0", aPosGrp);
293   aGridLay->addWidget( myZPosLbl, 2, 1);
294
295   aVBoxLayout->addWidget( aPosGrp );
296
297   QGroupBox* aSizeGrp = new QGroupBox ( tr("ACTOR_DATA_SIZE_TITLE"), myActorsPane);
298   aGridLay = new QGridLayout (aSizeGrp);
299   aGridLay->addWidget( new QLabel ("dX:", aSizeGrp ), 0, 0);
300   myDXLbl = new QLabel ("0", aSizeGrp);
301   aGridLay->addWidget( myDXLbl, 0, 1);
302   aGridLay->addWidget( new QLabel ("dY:", aSizeGrp ), 1, 0);
303   myDYLbl = new QLabel ("0", aSizeGrp);
304   aGridLay->addWidget( myDYLbl, 1, 1);
305   aGridLay->addWidget( new QLabel ("dZ:", aSizeGrp ), 2, 0);
306   myDZLbl = new QLabel ("0", aSizeGrp);
307   aGridLay->addWidget( myDZLbl, 2, 1);
308
309   aVBoxLayout->addWidget( aSizeGrp );
310   aVBoxLayout->addStretch();
311
312   // Gauss Points Pane
313   myGaussPointsPane = new VisuGUI_GaussPointsSelectionPane( myModule, mainFrame() );
314
315   // Add panes to tab widget
316   myTabWidget->addTab(myActorsPane, tr("MODE_ACTOR"));
317   myTabWidget->addTab(myCellsPane,  tr("MODE_CELL"));
318   myTabWidget->addTab(myPointsPane, tr("MODE_POINT"));
319   myTabWidget->addTab(myGaussPointsPane, tr("MODE_GAUSS_POINT"));
320
321   connect( myTabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( onSelectionModeChanged( int ) ) );
322
323   TopLayout->addWidget( myTabWidget );
324
325   // Find Pane
326   myFindPane = new VisuGUI_FindPane( mainFrame() );
327
328   connect( myFindPane, SIGNAL( idChanged( int, int ) ), this, SLOT( onIdChanged( int, int ) ) );
329
330   TopLayout->addWidget( myFindPane );
331
332   // Preferences button
333   QPushButton* aPrefBtn = new QPushButton( tr( "SELECTION_PREFERENCES" ),  mainFrame() );
334   connect( aPrefBtn, SIGNAL( clicked() ), this, SLOT( onPreferences() ) );
335
336   TopLayout->addWidget( aPrefBtn );
337
338   SalomeApp_Application* anApp =
339     dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
340   LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
341   connect( aSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionEvent() ) );
342
343   connect( this, SIGNAL( selectionModeChanged( int ) ), myModule, SLOT( OnSwitchSelectionMode( int ) ) );
344
345   myFl = false;
346
347   // Activate Points pane
348   myTabWidget->setCurrentWidget(myActorsPane);
349   if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule))
350     aViewWindow->SetSelectionMode(ActorSelection);
351   onSelectionEvent();
352 }
353
354 VisuGUI_SelectionPanel::~VisuGUI_SelectionPanel()
355 {
356   if( myPreferencesDlg )
357   {
358     delete myPreferencesDlg;
359     myPreferencesDlg = 0;
360   }
361 }
362
363 int VisuGUI_SelectionPanel::column( int theTableId, int theColumnId )
364 {
365   if( !myColumnData.contains( theTableId ) )
366     return -1;
367
368   const QList<int>& aColumnList = myColumnData[ theTableId ];
369   return aColumnList.indexOf( theColumnId );
370 }
371
372 QVariant VisuGUI_SelectionPanel::data( int theTableId, int theRow, int theColumnId )
373 {
374   if( !myTables.contains( theTableId ) )
375     return QVariant();
376
377   if( QTableWidget* aTable = myTables[ theTableId ] )
378     if( QAbstractItemModel* aModel = aTable->model() )
379       return aModel->data( aModel->index( theRow, column( theTableId, theColumnId ) ) );
380
381   return QVariant();
382 }
383
384 void VisuGUI_SelectionPanel::setData( int theTableId, int theRow, int theColumnId, const QVariant& theValue )
385 {
386   if( !myTables.contains( theTableId ) )
387     return;
388
389   if( QTableWidget* aTable = myTables[ theTableId ] )
390     if( QAbstractItemModel* aModel = aTable->model() )
391       aModel->setData( aModel->index( theRow, column( theTableId, theColumnId ) ), theValue );
392 }
393
394 void VisuGUI_SelectionPanel::setRowSpan( int theTableId, int theRow, int theColumnId, int theRowSpan )
395 {
396   if( !myTables.contains( theTableId ) )
397     return;
398
399   if( QTableWidget* aTable = myTables[ theTableId ] )
400     aTable->setSpan( theRow, column( theTableId, theColumnId ), theRowSpan, 1 );
401 }
402
403 VisuGUI_SelectionPrefDlg* VisuGUI_SelectionPanel::preferencesDlg()
404 {
405   if( !myPreferencesDlg )
406     myPreferencesDlg = new VisuGUI_SelectionPrefDlg();
407   myPreferencesDlg->update();
408   return myPreferencesDlg;
409 }
410
411 void VisuGUI_SelectionPanel::setSelectionMode( int theId )
412 {
413   myTabWidget->setCurrentIndex( theId );
414 }
415
416 void VisuGUI_SelectionPanel::onSelectionModeChanged( int theId )
417 {
418   SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule);
419   if (!aViewWindow) return;
420
421   switch (theId) {
422   case 0: // Actor
423     aViewWindow->SetSelectionMode(ActorSelection);
424     onSelectionEvent();
425     break;
426   case 1: // Cells
427     aViewWindow->SetSelectionMode(CellSelection);
428     onCellIdEdit();
429     break;
430   case 2: // Points
431     aViewWindow->SetSelectionMode(NodeSelection);
432     onPointIdEdit();
433     break;
434   case 3: // Gauss Points
435     aViewWindow->SetSelectionMode(GaussPointSelection);
436     myGaussPointsPane->update();
437     onSelectionEvent();
438     break;
439   }
440
441   myFindPane->setSelectionMode( aViewWindow->SelectionMode() );
442
443   emit selectionModeChanged( theId );
444 }
445
446 void VisuGUI_SelectionPanel::showEvent( QShowEvent* theEvent )
447 {
448   VisuGUI_Panel::showEvent(theEvent);
449 }
450
451 void VisuGUI_SelectionPanel::closeEvent( QCloseEvent* theEvent )
452 {
453   onClose();
454   VisuGUI_Panel::closeEvent(theEvent);
455 }
456
457 template<class TData> QString getScalar(TData* theData, int theId){
458   if (vtkDataArray *aScalar = theData->GetScalars()){
459     vtkFloatingPointType aVal = aScalar->GetTuple1(theId);
460     return QString::number(aVal);
461   } else {
462     return QString("No data");
463   }
464 }
465
466 template<class TData> QString getVector(TData* theData, int theId){
467   if (vtkDataArray *aVector = theData->GetVectors()) {
468     vtkFloatingPointType *aVal = aVector->GetTuple3(theId);
469     return QString("%1; %2; %3").arg(aVal[0]).arg(aVal[1]).arg(aVal[2]);
470   } else {
471     return QString("No data");
472   }
473 }
474
475 template<class TData> TValueData getValueData( TPointID thePointVTKID, VISU_Actor* theActor, TData* theData )
476 {
477   TValueData aValueData;
478
479   aValueData.Scalar = getScalar( theData, thePointVTKID );
480   aValueData.Vector = getVector( theData, thePointVTKID );
481
482   return aValueData;
483 }
484
485 TPointData getPointData( TPointID thePointVTKID, VISU_Actor* theActor, const VISU::PIDMapper& theMapper,
486                          bool theIsValueData )
487 {
488   TPointData aPointData;
489
490   vtkDataSet* aDataSet = theActor->GetMapper()->GetInput();
491
492   vtkFloatingPointType* aCoord = aDataSet->GetPoint( thePointVTKID );
493   aPointData.X = aCoord[0];
494   aPointData.Y = aCoord[1];
495   aPointData.Z = aCoord[2];
496
497   TPointID aPointObjID = theActor->GetNodeObjId( thePointVTKID );
498   VISU::TStructuredId aVec = theMapper->GetIndexesOfNode( aPointObjID );
499   aPointData.I = aVec[0];
500   aPointData.J = aVec[1];
501   aPointData.K = aVec[2];
502
503   if( theIsValueData )
504     aPointData.ValueData = getValueData( thePointVTKID, theActor, aDataSet->GetPointData() );
505
506   return aPointData;
507 }
508
509 void VisuGUI_SelectionPanel::onSelectionEvent() {
510   SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule);
511   if (!aViewWindow)
512     return;
513
514   switch (aViewWindow->SelectionMode()) {
515   case ActorSelection:
516   case CellSelection:
517   case NodeSelection:
518   case GaussPointSelection:
519     break;
520   default:
521     close();
522     return;
523   }
524
525   if (myFl)
526     return;
527   myFl = true;
528
529   int aType = myTabWidget->currentIndex();
530
531   SVTK_RenderWindowInteractor* anInteractor = aViewWindow->GetInteractor();
532   myGaussPointsPane->setInteractor(anInteractor);
533
534   SVTK_Selector* aSelector = aViewWindow->GetSelector();
535
536   _PTR(SObject) aSObject;
537   VISU::Prs3d_i* aPrs3d = NULL;
538   Handle(SALOME_InteractiveObject) anIO;
539
540   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(myModule);
541   if(aSelectionInfo.size() == 1){
542     // Get selected SObject
543     VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
544     VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo;
545     aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
546     if(aPrs3d){
547       anIO = aSelectionItem.myIO;
548       aSObject = anObjectInfo.mySObject;
549     }
550   }
551   
552   clearFields();
553
554   if (aPrs3d) {
555     QString aMeshName("NULL"), aFieldName("NULL");
556     if (aSObject) {
557       VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aSObject);
558       if (!aMap.empty()) {
559         aMeshName  = VISU::Storable::FindValue(aMap, "myMeshName");
560         aFieldName = VISU::Storable::FindValue(aMap, "myFieldName");
561       }
562     }
563
564     myMeshName ->setText((aMeshName  == "NULL") ? QString("No name") : aMeshName);
565     myFieldName->setText((aFieldName == "NULL") ? QString("No name") : aFieldName);
566
567     VISU_Actor* anVISUActor =
568       VISU::FindActor(VISU::GetAppStudy(myModule), aViewWindow, aSObject->GetID().c_str());
569     myFindPane->setActor( anVISUActor );
570     if (anVISUActor) {
571       vtkFloatingPointType aCoord[6];
572       anVISUActor->GetBounds(aCoord);
573       myXPosLbl->setText(QString::number( aCoord[0] ));
574       myYPosLbl->setText(QString::number( aCoord[2] ));
575       myZPosLbl->setText(QString::number( aCoord[4] ));
576
577       myDXLbl->setText(QString::number( fabs(aCoord[1]-aCoord[0]) ));
578       myDYLbl->setText(QString::number( fabs(aCoord[3]-aCoord[2]) ));
579       myDZLbl->setText(QString::number( fabs(aCoord[5]-aCoord[4]) ));
580
581       TColStd_IndexedMapOfInteger aMapIndex;
582       aSelector->GetIndex(anIO, aMapIndex);
583       bool aSingleSelection = aMapIndex.Extent() == 1;
584
585       vtkDataSet* aDataSet = anVISUActor->GetMapper()->GetInput();
586       bool isElno = VISU::IsElnoData( aDataSet );
587
588       const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper();
589       bool isStructured = aMapper->IsStructured();
590
591       TCellToPointDataMap aCellToPointDataMap;
592       TPointToCellDataMap aPointToCellDataMap;
593       TPointDataMap aGlobalPointDataMap;
594
595       for (int ind = 1; ind <= aMapIndex.Extent(); ind++) {
596         int anID = aMapIndex(ind);
597
598         switch( aType )
599         {
600           case 1:
601           {
602             if( aSingleSelection )
603               myCellIDValLbl->setText( QString::number( anID ) );
604
605             vtkCell* aCell = anVISUActor->GetElemCell( anID );
606             int aCellVTKID = anVISUActor->GetElemVTKID( anID );
607             if( !aCell || aCellVTKID < 0 )
608               break;
609
610             int aNbOfPoints = aCell->GetNumberOfPoints();
611             if( aNbOfPoints < 1 )
612               break;
613
614             TPointDataMap aPointDataMap;
615
616             vtkIdList* aPointList = aCell->GetPointIds();
617             for( int i = 0; i < aNbOfPoints; i++ )
618             {
619               int aPointVTKID = aPointList->GetId(i);
620
621               TPointID aPointID = anVISUActor->GetNodeObjId( aPointVTKID );
622               TPointData aPointData = getPointData( aPointVTKID, anVISUActor, aMapper, true );
623               aPointDataMap[ aPointID ] = aPointData;
624               aGlobalPointDataMap[ aPointID ] = aPointData;
625             }
626
627             TCellToPointData aCellToPointData;
628             aCellToPointData.CellData = getValueData( aCellVTKID, anVISUActor, aDataSet->GetCellData() );
629             aCellToPointData.PointDataMap = aPointDataMap;
630             aCellToPointDataMap[ anID ] = aCellToPointData;
631             break;
632           }
633           case 2:
634           {
635             if( aSingleSelection )
636               myIDValLbl->setText( QString::number( anID ) );
637
638             int aPointVTKID = anVISUActor->GetNodeVTKID( anID );
639             if( aPointVTKID < 0 )
640               break;
641
642             TCellDataMap aCellDataMap;
643
644             VISU::TElnoPoints anElnoPoints = VISU::GetElnoPoints( aDataSet, anID );
645             VISU::TElnoPoints::iterator anElnoIter = anElnoPoints.begin();
646             for( ; anElnoIter != anElnoPoints.end(); anElnoIter++ )
647             {
648               VISU::TElnoPointID anElnoPointID = *anElnoIter;
649               VISU::TVTKPointID aVTKPointID = anElnoPointID.first;
650               VISU::TVTKCellID aVTKCellID = anElnoPointID.second;
651
652               TCellID aCellID = anVISUActor->GetElemObjId( aVTKCellID );
653               TValueData aValueData = getValueData( aVTKPointID, anVISUActor, aDataSet->GetPointData() );
654               aCellDataMap[ aCellID ] = aValueData;
655             }
656
657             TPointToCellData aPointToCellData;
658             aPointToCellData.PointData = getPointData( aPointVTKID, anVISUActor, aMapper, !isElno );
659             aPointToCellData.CellDataMap = aCellDataMap;
660             aPointToCellDataMap[ anID ] = aPointToCellData;
661             break;
662           }
663         }
664       }
665
666       // Fill tables
667       QList<int> aTableIds;
668       switch( aType )
669       {
670         case 1:
671           if( isElno )
672             aTableIds.append( CellElno );
673           else
674           {
675             aTableIds.append( CellStdCell );
676             aTableIds.append( CellStdPoint );
677           }
678           break;
679         case 2:
680           aTableIds.append( isElno ? PointElno : PointStd );
681           break;
682       }
683
684       QListIterator<int> aTableIter( aTableIds );
685       while( aTableIter.hasNext() )
686       {
687         int aTableId = aTableIter.next();
688         if( !myTables.contains( aTableId ) )
689           continue;
690
691         QTableWidget* aTable = myTables[ aTableId ];
692         if( !aTable )
693           continue;
694
695         int aRow = -1;
696         switch( aTableId )
697         {
698           case CellStdPoint:
699           {
700             int aRowCount = aGlobalPointDataMap.size();
701             aTable->setRowCount( aRowCount );
702
703             TPointDataMap::const_iterator aPointIter = aGlobalPointDataMap.begin();
704             for( ; aPointIter != aGlobalPointDataMap.end(); aPointIter++ )
705             {
706               aRow++;
707               TPointID aPointID = aPointIter.key();
708               const TPointData& aPointData = aPointIter.value();
709               const TValueData& aValueData = aPointData.ValueData;
710
711               setData( aTableId, aRow, Point, aPointID );
712               setData( aTableId, aRow, X, aPointData.X );
713               setData( aTableId, aRow, Y, aPointData.Y );
714               setData( aTableId, aRow, Z, aPointData.Z );
715               setData( aTableId, aRow, I, aPointData.I );
716               setData( aTableId, aRow, J, aPointData.J );
717               setData( aTableId, aRow, K, aPointData.K );
718               setData( aTableId, aRow, Scalar, aValueData.Scalar );
719               setData( aTableId, aRow, Vector, aValueData.Vector );
720             }
721             break;
722           }
723           case CellStdCell:
724           case CellElno:
725           {
726             int aRowCount = 0;
727             TCellToPointDataMap::const_iterator aCellToPointIter = aCellToPointDataMap.begin();
728             for( ; aCellToPointIter != aCellToPointDataMap.end(); aCellToPointIter++ )
729             {
730               if( aTableId == CellStdCell )
731                 aRowCount++;
732               else if( aTableId == CellElno )
733               {
734                 const TCellToPointData& aCellToPointData = aCellToPointIter.value();
735                 const TPointDataMap& aPointDataMap = aCellToPointData.PointDataMap;
736                 int aNbPoints = aPointDataMap.size();
737
738                 aRowCount += aNbPoints;
739               }
740             }
741             aTable->setRowCount( aRowCount );
742
743             aCellToPointIter = aCellToPointDataMap.begin();
744             for( ; aCellToPointIter != aCellToPointDataMap.end(); aCellToPointIter++ )
745             {
746               aRow++;
747
748               TCellID aCellID = aCellToPointIter.key();
749               const TCellToPointData& aCellToPointData = aCellToPointIter.value();
750               const TValueData& aCellData = aCellToPointData.CellData;
751
752               setData( aTableId, aRow, Cell, aCellID );
753               if( aTableId == CellStdCell )
754               {
755                 setData( aTableId, aRow, Scalar, aCellData.Scalar );
756                 setData( aTableId, aRow, Vector, aCellData.Vector );
757               }
758               else if( aTableId == CellElno )
759               {
760                 const TPointDataMap& aPointDataMap = aCellToPointData.PointDataMap;
761                 int aNbPoints = aPointDataMap.size();
762                 if( aNbPoints > 1 )
763                   setRowSpan( aTableId, aRow, Cell, aNbPoints );
764
765                 TPointDataMap::const_iterator aPointIter = aPointDataMap.begin();
766                 for( aRow--; aPointIter != aPointDataMap.end(); aPointIter++ )
767                 {
768                   aRow++;
769                   TPointID aPointID = aPointIter.key();
770                   const TPointData& aPointData = aPointIter.value();
771                   const TValueData& aValueData = aPointData.ValueData;
772
773                   setData( aTableId, aRow, Point, aPointID );
774                   setData( aTableId, aRow, X, aPointData.X );
775                   setData( aTableId, aRow, Y, aPointData.Y );
776                   setData( aTableId, aRow, Z, aPointData.Z );
777                   setData( aTableId, aRow, I, aPointData.I );
778                   setData( aTableId, aRow, J, aPointData.J );
779                   setData( aTableId, aRow, K, aPointData.K );
780                   setData( aTableId, aRow, Scalar, aValueData.Scalar );
781                   setData( aTableId, aRow, Vector, aValueData.Vector );
782                 }
783               }
784             }
785             break;
786           }
787           case PointStd:
788           case PointElno:
789           {
790             int aRowCount = 0;
791             TPointToCellDataMap::const_iterator aPointToCellIter = aPointToCellDataMap.begin();
792             for( ; aPointToCellIter != aPointToCellDataMap.end(); aPointToCellIter++ )
793             {
794               const TPointToCellData& aPointToCellData = aPointToCellIter.value();
795               const TCellDataMap& aCellDataMap = aPointToCellData.CellDataMap;
796               int aNbCells = aCellDataMap.size();
797               if( aNbCells > 1 )
798                 aRowCount += aNbCells;
799               else
800                 aRowCount++;          
801             }
802             aTable->setRowCount( aRowCount );
803
804             aPointToCellIter = aPointToCellDataMap.begin();
805             for( ; aPointToCellIter != aPointToCellDataMap.end(); aPointToCellIter++ )
806             {
807               aRow++;
808
809               TPointID aPointID = aPointToCellIter.key();
810               const TPointToCellData& aPointToCellData = aPointToCellIter.value();
811               const TPointData& aPointData = aPointToCellData.PointData;
812
813               setData( aTableId, aRow, Point, aPointID );
814               setData( aTableId, aRow, X, aPointData.X );
815               setData( aTableId, aRow, Y, aPointData.Y );
816               setData( aTableId, aRow, Z, aPointData.Z );
817               setData( aTableId, aRow, I, aPointData.I );
818               setData( aTableId, aRow, J, aPointData.J );
819               setData( aTableId, aRow, K, aPointData.K );
820
821               if( aTableId == PointElno )
822               {
823                 const TCellDataMap& aCellDataMap = aPointToCellData.CellDataMap;
824                 int aNbCells = aCellDataMap.size();
825                 if( aNbCells > 1 )
826                   for( int aColumnId = Point; aColumnId <= K; aColumnId++ )
827                     setRowSpan( aTableId, aRow, aColumnId, aNbCells );
828
829                 TCellDataMap::const_iterator aCellIter = aCellDataMap.begin();
830                 for( aRow--; aCellIter != aCellDataMap.end(); aCellIter++ )
831                 {
832                   aRow++;
833                   TCellID aCellID = aCellIter.key();
834                   const TValueData& aCellData = aCellIter.value();
835
836                   setData( aTableId, aRow, Cell, aCellID );
837                   setData( aTableId, aRow, Scalar, aCellData.Scalar );
838                   setData( aTableId, aRow, Vector, aCellData.Vector );
839                 }
840               }
841               else
842               {
843                 const TValueData& aValueData = aPointData.ValueData;
844                 setData( aTableId, aRow, Scalar, aValueData.Scalar );
845                 setData( aTableId, aRow, Vector, aValueData.Vector );
846               }
847             }
848             break;
849           }
850         }
851
852         for( int aCol = column( aTableId, I ), aLastCol = column( aTableId, K ); aCol <= aLastCol; aCol++ )
853           if( aCol != -1 )
854             aTable->setColumnHidden( aCol, !isStructured );
855         aTable->resizeColumnsToContents();
856       }
857
858       int stackId = isElno ? ElnoMesh : StdMesh;
859       QStackedWidget* aStackedWg = aType == 1 ? myCellStackedWg : aType == 2 ? myPointStackedWg : 0;
860       if( aStackedWg )
861         aStackedWg->setCurrentIndex( stackId );
862     }
863   }
864   myFl = false;
865 }
866
867 void VisuGUI_SelectionPanel::clearFields() {
868   int aType = myTabWidget->currentIndex();
869   switch (aType) {
870   case 0:
871     myXPosLbl->setText("");
872     myYPosLbl->setText("");
873     myZPosLbl->setText("");
874     myDXLbl->setText("");
875     myDYLbl->setText("");
876     myDZLbl->setText("");
877     break;
878   case 1:
879     myCellIDValLbl->setText( "" );
880     break;
881   case 2:
882     myIDValLbl->setText( "" );
883     break;
884   }
885
886   QMap<int, QTableWidget*>::iterator it = myTables.begin(), itEnd = myTables.end();
887   for( ; it != itEnd; ++it )
888     if( QTableWidget* aTable = *it )
889     {
890       aTable->clearSpans();
891       aTable->setRowCount(0);
892       aTable->resizeColumnsToContents();
893     }
894 }
895
896 typedef  vtkIdType (VISU_PipeLine::* TGetVTKIdMethod)(vtkIdType theID);
897
898 bool onIdEdit (const QString& theText,
899                TGetVTKIdMethod theMethod,
900                bool theIsCell,
901                const SalomeApp_Module* theModule,
902                QLabel* theMeshName,
903                QString theValue,
904                QLabel* theFieldName)
905 {
906   SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(theModule);
907   if (!aViewWindow) 
908     return false;
909   SVTK_Selector* aSelector = aViewWindow->GetSelector();
910
911   _PTR(SObject) aSObject;
912   VISU::Prs3d_i* aPrs3d = NULL;
913   Handle(SALOME_InteractiveObject) anIO;
914
915   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
916   if(aSelectionInfo.size() == 1){
917     // Get selected SObject
918     VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
919     VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo;
920     aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
921     if(aPrs3d){
922       anIO = aSelectionItem.myIO;
923       aSObject = anObjectInfo.mySObject;
924     }
925   }
926   if (aPrs3d) {
927     bool ok = false;
928     int anObjId = theText.toInt( &ok );
929     if( !ok )
930       anObjId = -1;
931
932     VISU_PipeLine* aPipeLine = aPrs3d->GetPipeLine();
933
934     if( dynamic_cast<VISU_GaussPointsPL*>( aPipeLine ) )
935       return false;
936
937     if( anObjId < 0 )
938       aSelector->ClearIndex();
939     else
940     {
941       int aVTKId = (aPipeLine->*theMethod)(anObjId);
942       if(aVTKId < 0)
943         return false;
944
945       TColStd_MapOfInteger newIndices;
946       newIndices.Add(anObjId);
947       aSelector->AddOrRemoveIndex(anIO, newIndices, false);
948     }
949
950     aViewWindow->highlight(anIO, true, true);
951
952     SVTK_RenderWindowInteractor* anInteractor = aViewWindow->GetInteractor();
953     VISU_Actor* anActor = SVTK::Find<VISU_Actor>(anInteractor->getRenderer()->GetActors(),
954                                                  SVTK::TIsSameIObject<VISU_Actor>( anIO ));
955     anActor->Highlight( anIO );
956
957     return true;
958
959   } else {
960     theMeshName->setText(theValue);
961     theFieldName->setText("");
962   }
963   return false;
964 }
965
966 void VisuGUI_SelectionPanel::onPointIdEdit ()
967 {
968   if (myFl) return;
969   TGetVTKIdMethod aMethod = &VISU_PipeLine::GetNodeVTKID;
970   bool anIsSelected = onIdEdit(myIDValLbl->text(),
971                                aMethod,
972                                false,
973                                myModule,
974                                myMeshName,
975                                tr("WRN_NO_AVAILABLE_DATA"),
976                                myFieldName);
977   if (anIsSelected)
978     // as selection manager doesn't send signal currentSelectionChanged()
979     onSelectionEvent();
980   else
981     clearFields();
982 }
983
984 void VisuGUI_SelectionPanel::onCellIdEdit ()
985 {
986   if (myFl) return;
987   TGetVTKIdMethod aMethod = &VISU_PipeLine::GetElemVTKID;
988   bool anIsSelected = onIdEdit(myCellIDValLbl->text(),
989                                aMethod,
990                                true,
991                                myModule,
992                                myMeshName,
993                                tr("WRN_NO_AVAILABLE_DATA"),
994                                myFieldName);
995   if (anIsSelected)
996     // as selection manager doesn't send signal currentSelectionChanged()
997     onSelectionEvent();
998   else
999     clearFields();
1000 }
1001
1002 void VisuGUI_SelectionPanel::onDoubleClicked( const QModelIndex& theIndex )
1003 {
1004   QTableWidget* aTable = dynamic_cast<QTableWidget*>( sender() );
1005   if( !aTable )
1006     return;
1007
1008   int aTableId = myTables.key( aTable, -1 );
1009   if( aTableId == -1 )
1010     return;
1011
1012   int aRow = theIndex.row(), aCol = theIndex.column();
1013   const QList<int>& aColumnList = myColumnData[ aTableId ];
1014
1015   if( aCol >= aColumnList.size() )
1016     return;
1017
1018   int aColumnId = aColumnList[ aCol ];
1019
1020   bool anIsCellSelection = true;
1021   switch( aColumnId )
1022   {
1023     case Cell:
1024       anIsCellSelection = true;
1025       break;
1026     case Point:
1027     case X:
1028     case Y:
1029     case Z:
1030     case I:
1031     case J:
1032     case K:
1033       anIsCellSelection = false;
1034       break;
1035     case Scalar:
1036     case Vector:
1037       anIsCellSelection = aTableId == CellStdCell || aTableId == PointElno;
1038       break;
1039     default:
1040       return;
1041   }
1042
1043   int anIdColumnId = anIsCellSelection ? Cell : Point;
1044   QVariant anId = data( aTableId, aRow, anIdColumnId );
1045
1046   bool ok = false;
1047   anId.toInt( &ok );
1048   if( !ok )
1049     return;
1050
1051   if( anIsCellSelection )
1052   {
1053     setSelectionMode( 1 );
1054     myCellIDValLbl->setText( anId.toString() );
1055     onCellIdEdit();
1056   }
1057   else
1058   {
1059     setSelectionMode( 2 );
1060     myIDValLbl->setText( anId.toString() );
1061     onPointIdEdit();
1062   }
1063 }
1064
1065 void VisuGUI_SelectionPanel::onIdChanged( int theFirstId, int theSecondId )
1066 {
1067   int aType = myTabWidget->currentIndex();
1068   if( aType == 1 )
1069   {
1070     myCellIDValLbl->setText( theFirstId < 0 ? "" : QString::number( theFirstId ) );
1071     onCellIdEdit();
1072   }
1073   else if( aType == 2 )
1074   {
1075     myIDValLbl->setText( theFirstId < 0 ? "" : QString::number( theFirstId ) );
1076     onPointIdEdit();
1077   }
1078   else if( aType == 3 )
1079     myGaussPointsPane->setIds( theFirstId, theSecondId );
1080 }
1081
1082 void VisuGUI_SelectionPanel::onPreferences()
1083 {
1084   preferencesDlg()->exec();
1085 }
1086
1087 void VisuGUI_SelectionPanel::onApply()
1088 {
1089   VisuGUI_Panel::onApply();
1090 }
1091
1092 void VisuGUI_SelectionPanel::onClose()
1093 {
1094   close();
1095   VisuGUI_Panel::onClose();
1096 }
1097
1098 void VisuGUI_SelectionPanel::onHelp()
1099 {
1100   QString aHelpFileName = "selection_info_page.html";
1101   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1102   if (app)
1103     app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName);
1104   else {
1105     QString platform;
1106 #ifdef WIN32
1107     platform = "winapplication";
1108 #else
1109     platform = "application";
1110 #endif
1111     SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
1112                              QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1113                              arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
1114   }
1115
1116   VisuGUI_Panel::onHelp();
1117 }
1118
1119 void VisuGUI_SelectionPanel::keyPressEvent( QKeyEvent* e )
1120 {
1121   VisuGUI_Panel::keyPressEvent( e );
1122   if ( e->isAccepted() )
1123     return;
1124
1125   if ( e->key() == Qt::Key_F1 )
1126     {
1127       e->accept();
1128       onHelp();
1129     }
1130 }