1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU VISUGUI : GUI of VISU component
23 // File : VisuGUI_SelectionPanel.h
24 // Author : Laurent CORNABE & Hubert ROLLAND
28 #include "VisuGUI_SelectionPanel.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"
37 #include "VISU_Event.h"
38 #include "VISU_ConvertorUtils.hxx"
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"
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"
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"
60 #include "SALOME_ListIO.hxx"
61 #include "SALOME_ListIteratorOfListIO.hxx"
63 #include "SVTK_ViewWindow.h"
64 #include "SVTK_Selector.h"
65 #include "SVTK_RenderWindowInteractor.h"
67 #include "utilities.h"
70 #include <TColStd_IndexedMapOfInteger.hxx>
71 #include <TColStd_MapOfInteger.hxx>
76 #include <QListWidget>
78 #include <QButtonGroup>
79 #include <QRadioButton>
81 #include <QPushButton>
82 #include <QToolButton>
86 #include <QTableWidget>
87 #include <QVBoxLayout>
88 #include <QHBoxLayout>
90 #include <QHeaderView>
92 #include <QScrollArea>
93 #include <QStackedWidget>
96 #include <vtkDataSetMapper.h>
97 #include <vtkDataSet.h>
98 #include <vtkPointData.h>
99 #include <vtkCellData.h>
107 class CustomIntValidator: public QIntValidator
110 CustomIntValidator( QObject * theParent ):
111 QIntValidator( 0, VTK_LARGE_ID, theParent )
116 validate( QString& theInput, int& thePos ) const
118 if( theInput.isEmpty() )
119 return QValidator::Acceptable;
121 return QIntValidator::validate( theInput, thePos );
125 VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const VisuGUI* theModule, QWidget* theParent ) :
126 VisuGUI_Panel( tr("WINDOW_TITLE" ), theModule, theParent, CloseBtn | HelpBtn ),
127 myPreferencesDlg( 0 )
129 QVBoxLayout* TopLayout = new QVBoxLayout ( mainFrame() );
131 QWidget* aNamePane = new QWidget (mainFrame());
132 QGridLayout* aNameLay = new QGridLayout (aNamePane);
134 QLabel* aMeshLbl = new QLabel (tr("MESH_NAME_LBL"), aNamePane);
135 myMeshName = new QLabel (aNamePane);
136 myMeshName->setText(tr("WRN_NO_AVAILABLE_DATA"));
138 QLabel* aFieldLbl = new QLabel (tr("FIELD_NAME_LBL"), aNamePane);
139 myFieldName = new QLabel (aNamePane);
141 aNameLay->addWidget(aMeshLbl, 0, 0);
142 aNameLay->addWidget(myMeshName, 0, 1);
143 aNameLay->addWidget(aFieldLbl, 1, 0);
144 aNameLay->addWidget(myFieldName, 1, 1);
146 TopLayout->addWidget(aNamePane);
148 myTabWidget = new QTabWidget( mainFrame() );
150 QTableWidget* aTable;
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 );
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" ) );
171 // Create Points pane
172 myPointsPane = new QWidget (mainFrame());
173 QVBoxLayout* aVBoxLayout = new QVBoxLayout(myPointsPane);
175 QGroupBox* aDataGrp = new QGroupBox ( tr("POINT_DATA_TITLE"), myPointsPane);
176 QGridLayout* aGridLay = new QGridLayout (aDataGrp);
178 aGridLay->addWidget( new QLabel (tr("DATA_ID_LBL"), aDataGrp), 0, 0 );
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()));
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()));
192 aVBoxLayout->addWidget( aDataGrp );
194 myPointStackedWg = new QStackedWidget( myPointsPane );
196 aTable = new QTableWidget( myPointStackedWg );
197 myPointStackedWg->insertWidget( StdMesh, aTable );
198 myTables.insert( PointStd, aTable );
200 aTable = new QTableWidget( myPointStackedWg );
201 myPointStackedWg->insertWidget( ElnoMesh, aTable );
202 myTables.insert( PointElno, aTable );
204 aVBoxLayout->addWidget(myPointStackedWg, 1, 0);
207 myCellsPane = new QWidget (mainFrame());
208 QGridLayout* aCellLayout = new QGridLayout (myCellsPane);
209 aCellLayout->setRowStretch(0, 0);
210 aCellLayout->setRowStretch(1, 1);
212 QGroupBox* aCellGrp = new QGroupBox( tr("CELL_DATA_TITLE"), myCellsPane);
213 aGridLay = new QGridLayout (aCellGrp);
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()));
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()));
226 aCellLayout->addWidget(aCellGrp, 0, 0);
228 myCellStackedWg = new QStackedWidget( myCellsPane );
230 QTabWidget* aStdTabWidget = new QTabWidget( myCellStackedWg );
231 myCellStackedWg->insertWidget( StdMesh, aStdTabWidget );
233 aTable = new QTableWidget( aStdTabWidget );
234 aStdTabWidget->addTab( aTable, tr("CELL_INFO") );
235 myTables.insert( CellStdCell, aTable );
237 aTable = new QTableWidget( aStdTabWidget );
238 aStdTabWidget->addTab( aTable, tr("POINT_INFO") );
239 myTables.insert( CellStdPoint, aTable );
241 aTable = new QTableWidget( myCellStackedWg );
242 myCellStackedWg->insertWidget( ElnoMesh, aTable );
243 myTables.insert( CellElno, aTable );
245 aCellLayout->addWidget(myCellStackedWg, 1, 0);
247 // Common operations for all tables
248 QMap<int, QTableWidget*>::iterator it = myTables.begin(), itEnd = myTables.end();
249 for( ; it != itEnd; ++it )
255 int aTableId = it.key();
256 if( !myColumnData.contains( aTableId ) )
259 QStringList aHorizontalHeaderLabels;
260 QList<int> aColumns = myColumnData[ aTableId ];
261 QListIterator<int> aColumnIter( aColumns );
262 while( aColumnIter.hasNext() )
264 int aColumnId = aColumnIter.next();
265 if( aColumnId >= 0 && aColumnId < aColumnHeaders.size() )
266 aHorizontalHeaderLabels << aColumnHeaders[ aColumnId ];
268 aTable->setColumnCount( aHorizontalHeaderLabels.size() );
269 aTable->setHorizontalHeaderLabels( aHorizontalHeaderLabels );
271 aTable->setEditTriggers( QAbstractItemView::NoEditTriggers );
272 aTable->setSelectionMode( QAbstractItemView::SingleSelection );
273 aTable->resizeColumnsToContents();
275 connect( aTable, SIGNAL( doubleClicked( const QModelIndex& ) ),
276 this, SLOT( onDoubleClicked( const QModelIndex& ) ) );
280 myActorsPane = new QWidget (mainFrame());
281 aVBoxLayout = new QVBoxLayout(myActorsPane);
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);
295 aVBoxLayout->addWidget( aPosGrp );
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);
309 aVBoxLayout->addWidget( aSizeGrp );
310 aVBoxLayout->addStretch();
313 myGaussPointsPane = new VisuGUI_GaussPointsSelectionPane( myModule, mainFrame() );
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"));
321 connect( myTabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( onSelectionModeChanged( int ) ) );
323 TopLayout->addWidget( myTabWidget );
326 myFindPane = new VisuGUI_FindPane( mainFrame() );
328 connect( myFindPane, SIGNAL( idChanged( int, int ) ), this, SLOT( onIdChanged( int, int ) ) );
330 TopLayout->addWidget( myFindPane );
332 // Preferences button
333 QPushButton* aPrefBtn = new QPushButton( tr( "SELECTION_PREFERENCES" ), mainFrame() );
334 connect( aPrefBtn, SIGNAL( clicked() ), this, SLOT( onPreferences() ) );
336 TopLayout->addWidget( aPrefBtn );
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() ) );
343 connect( this, SIGNAL( selectionModeChanged( int ) ), myModule, SLOT( OnSwitchSelectionMode( int ) ) );
347 // Activate Points pane
348 myTabWidget->setCurrentWidget(myActorsPane);
349 if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule))
350 aViewWindow->SetSelectionMode(ActorSelection);
354 VisuGUI_SelectionPanel::~VisuGUI_SelectionPanel()
356 if( myPreferencesDlg )
358 delete myPreferencesDlg;
359 myPreferencesDlg = 0;
363 int VisuGUI_SelectionPanel::column( int theTableId, int theColumnId )
365 if( !myColumnData.contains( theTableId ) )
368 const QList<int>& aColumnList = myColumnData[ theTableId ];
369 return aColumnList.indexOf( theColumnId );
372 QVariant VisuGUI_SelectionPanel::data( int theTableId, int theRow, int theColumnId )
374 if( !myTables.contains( theTableId ) )
377 if( QTableWidget* aTable = myTables[ theTableId ] )
378 if( QAbstractItemModel* aModel = aTable->model() )
379 return aModel->data( aModel->index( theRow, column( theTableId, theColumnId ) ) );
384 void VisuGUI_SelectionPanel::setData( int theTableId, int theRow, int theColumnId, const QVariant& theValue )
386 if( !myTables.contains( theTableId ) )
389 if( QTableWidget* aTable = myTables[ theTableId ] )
390 if( QAbstractItemModel* aModel = aTable->model() )
391 aModel->setData( aModel->index( theRow, column( theTableId, theColumnId ) ), theValue );
394 void VisuGUI_SelectionPanel::setRowSpan( int theTableId, int theRow, int theColumnId, int theRowSpan )
396 if( !myTables.contains( theTableId ) )
399 if( QTableWidget* aTable = myTables[ theTableId ] )
400 aTable->setSpan( theRow, column( theTableId, theColumnId ), theRowSpan, 1 );
403 VisuGUI_SelectionPrefDlg* VisuGUI_SelectionPanel::preferencesDlg()
405 if( !myPreferencesDlg )
406 myPreferencesDlg = new VisuGUI_SelectionPrefDlg();
407 myPreferencesDlg->update();
408 return myPreferencesDlg;
411 void VisuGUI_SelectionPanel::setSelectionMode( int theId )
413 myTabWidget->setCurrentIndex( theId );
416 void VisuGUI_SelectionPanel::onSelectionModeChanged( int theId )
418 SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule);
419 if (!aViewWindow) return;
423 aViewWindow->SetSelectionMode(ActorSelection);
427 aViewWindow->SetSelectionMode(CellSelection);
431 aViewWindow->SetSelectionMode(NodeSelection);
434 case 3: // Gauss Points
435 aViewWindow->SetSelectionMode(GaussPointSelection);
436 myGaussPointsPane->update();
441 myFindPane->setSelectionMode( aViewWindow->SelectionMode() );
443 emit selectionModeChanged( theId );
446 void VisuGUI_SelectionPanel::showEvent( QShowEvent* theEvent )
448 VisuGUI_Panel::showEvent(theEvent);
451 void VisuGUI_SelectionPanel::closeEvent( QCloseEvent* theEvent )
454 VisuGUI_Panel::closeEvent(theEvent);
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);
462 return QString("No data");
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]);
471 return QString("No data");
475 template<class TData> TValueData getValueData( TPointID thePointVTKID, VISU_Actor* theActor, TData* theData )
477 TValueData aValueData;
479 aValueData.Scalar = getScalar( theData, thePointVTKID );
480 aValueData.Vector = getVector( theData, thePointVTKID );
485 TPointData getPointData( TPointID thePointVTKID, VISU_Actor* theActor, const VISU::PIDMapper& theMapper,
486 bool theIsValueData )
488 TPointData aPointData;
490 vtkDataSet* aDataSet = theActor->GetMapper()->GetInput();
492 vtkFloatingPointType* aCoord = aDataSet->GetPoint( thePointVTKID );
493 aPointData.X = aCoord[0];
494 aPointData.Y = aCoord[1];
495 aPointData.Z = aCoord[2];
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];
504 aPointData.ValueData = getValueData( thePointVTKID, theActor, aDataSet->GetPointData() );
509 void VisuGUI_SelectionPanel::onSelectionEvent() {
510 SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule);
514 switch (aViewWindow->SelectionMode()) {
518 case GaussPointSelection:
529 int aType = myTabWidget->currentIndex();
531 SVTK_RenderWindowInteractor* anInteractor = aViewWindow->GetInteractor();
532 myGaussPointsPane->setInteractor(anInteractor);
534 SVTK_Selector* aSelector = aViewWindow->GetSelector();
536 _PTR(SObject) aSObject;
537 VISU::Prs3d_i* aPrs3d = NULL;
538 Handle(SALOME_InteractiveObject) anIO;
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);
547 anIO = aSelectionItem.myIO;
548 aSObject = anObjectInfo.mySObject;
555 QString aMeshName("NULL"), aFieldName("NULL");
557 VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aSObject);
559 aMeshName = VISU::Storable::FindValue(aMap, "myMeshName");
560 aFieldName = VISU::Storable::FindValue(aMap, "myFieldName");
564 myMeshName ->setText((aMeshName == "NULL") ? QString("No name") : aMeshName);
565 myFieldName->setText((aFieldName == "NULL") ? QString("No name") : aFieldName);
567 VISU_Actor* anVISUActor =
568 VISU::FindActor(VISU::GetAppStudy(myModule), aViewWindow, aSObject->GetID().c_str());
569 myFindPane->setActor( 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] ));
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]) ));
581 TColStd_IndexedMapOfInteger aMapIndex;
582 aSelector->GetIndex(anIO, aMapIndex);
583 bool aSingleSelection = aMapIndex.Extent() == 1;
585 vtkDataSet* aDataSet = anVISUActor->GetMapper()->GetInput();
586 bool isElno = VISU::IsElnoData( aDataSet );
588 const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper();
589 bool isStructured = aMapper->IsStructured();
591 TCellToPointDataMap aCellToPointDataMap;
592 TPointToCellDataMap aPointToCellDataMap;
593 TPointDataMap aGlobalPointDataMap;
595 for (int ind = 1; ind <= aMapIndex.Extent(); ind++) {
596 int anID = aMapIndex(ind);
602 if( aSingleSelection )
603 myCellIDValLbl->setText( QString::number( anID ) );
605 vtkCell* aCell = anVISUActor->GetElemCell( anID );
606 int aCellVTKID = anVISUActor->GetElemVTKID( anID );
607 if( !aCell || aCellVTKID < 0 )
610 int aNbOfPoints = aCell->GetNumberOfPoints();
611 if( aNbOfPoints < 1 )
614 TPointDataMap aPointDataMap;
616 vtkIdList* aPointList = aCell->GetPointIds();
617 for( int i = 0; i < aNbOfPoints; i++ )
619 int aPointVTKID = aPointList->GetId(i);
621 TPointID aPointID = anVISUActor->GetNodeObjId( aPointVTKID );
622 TPointData aPointData = getPointData( aPointVTKID, anVISUActor, aMapper, true );
623 aPointDataMap[ aPointID ] = aPointData;
624 aGlobalPointDataMap[ aPointID ] = aPointData;
627 TCellToPointData aCellToPointData;
628 aCellToPointData.CellData = getValueData( aCellVTKID, anVISUActor, aDataSet->GetCellData() );
629 aCellToPointData.PointDataMap = aPointDataMap;
630 aCellToPointDataMap[ anID ] = aCellToPointData;
635 if( aSingleSelection )
636 myIDValLbl->setText( QString::number( anID ) );
638 int aPointVTKID = anVISUActor->GetNodeVTKID( anID );
639 if( aPointVTKID < 0 )
642 TCellDataMap aCellDataMap;
644 VISU::TElnoPoints anElnoPoints = VISU::GetElnoPoints( aDataSet, anID );
645 VISU::TElnoPoints::iterator anElnoIter = anElnoPoints.begin();
646 for( ; anElnoIter != anElnoPoints.end(); anElnoIter++ )
648 VISU::TElnoPointID anElnoPointID = *anElnoIter;
649 VISU::TVTKPointID aVTKPointID = anElnoPointID.first;
650 VISU::TVTKCellID aVTKCellID = anElnoPointID.second;
652 TCellID aCellID = anVISUActor->GetElemObjId( aVTKCellID );
653 TValueData aValueData = getValueData( aVTKPointID, anVISUActor, aDataSet->GetPointData() );
654 aCellDataMap[ aCellID ] = aValueData;
657 TPointToCellData aPointToCellData;
658 aPointToCellData.PointData = getPointData( aPointVTKID, anVISUActor, aMapper, !isElno );
659 aPointToCellData.CellDataMap = aCellDataMap;
660 aPointToCellDataMap[ anID ] = aPointToCellData;
667 QList<int> aTableIds;
672 aTableIds.append( CellElno );
675 aTableIds.append( CellStdCell );
676 aTableIds.append( CellStdPoint );
680 aTableIds.append( isElno ? PointElno : PointStd );
684 QListIterator<int> aTableIter( aTableIds );
685 while( aTableIter.hasNext() )
687 int aTableId = aTableIter.next();
688 if( !myTables.contains( aTableId ) )
691 QTableWidget* aTable = myTables[ aTableId ];
700 int aRowCount = aGlobalPointDataMap.size();
701 aTable->setRowCount( aRowCount );
703 TPointDataMap::const_iterator aPointIter = aGlobalPointDataMap.begin();
704 for( ; aPointIter != aGlobalPointDataMap.end(); aPointIter++ )
707 TPointID aPointID = aPointIter.key();
708 const TPointData& aPointData = aPointIter.value();
709 const TValueData& aValueData = aPointData.ValueData;
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 );
727 TCellToPointDataMap::const_iterator aCellToPointIter = aCellToPointDataMap.begin();
728 for( ; aCellToPointIter != aCellToPointDataMap.end(); aCellToPointIter++ )
730 if( aTableId == CellStdCell )
732 else if( aTableId == CellElno )
734 const TCellToPointData& aCellToPointData = aCellToPointIter.value();
735 const TPointDataMap& aPointDataMap = aCellToPointData.PointDataMap;
736 int aNbPoints = aPointDataMap.size();
738 aRowCount += aNbPoints;
741 aTable->setRowCount( aRowCount );
743 aCellToPointIter = aCellToPointDataMap.begin();
744 for( ; aCellToPointIter != aCellToPointDataMap.end(); aCellToPointIter++ )
748 TCellID aCellID = aCellToPointIter.key();
749 const TCellToPointData& aCellToPointData = aCellToPointIter.value();
750 const TValueData& aCellData = aCellToPointData.CellData;
752 setData( aTableId, aRow, Cell, aCellID );
753 if( aTableId == CellStdCell )
755 setData( aTableId, aRow, Scalar, aCellData.Scalar );
756 setData( aTableId, aRow, Vector, aCellData.Vector );
758 else if( aTableId == CellElno )
760 const TPointDataMap& aPointDataMap = aCellToPointData.PointDataMap;
761 int aNbPoints = aPointDataMap.size();
763 setRowSpan( aTableId, aRow, Cell, aNbPoints );
765 TPointDataMap::const_iterator aPointIter = aPointDataMap.begin();
766 for( aRow--; aPointIter != aPointDataMap.end(); aPointIter++ )
769 TPointID aPointID = aPointIter.key();
770 const TPointData& aPointData = aPointIter.value();
771 const TValueData& aValueData = aPointData.ValueData;
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 );
791 TPointToCellDataMap::const_iterator aPointToCellIter = aPointToCellDataMap.begin();
792 for( ; aPointToCellIter != aPointToCellDataMap.end(); aPointToCellIter++ )
794 const TPointToCellData& aPointToCellData = aPointToCellIter.value();
795 const TCellDataMap& aCellDataMap = aPointToCellData.CellDataMap;
796 int aNbCells = aCellDataMap.size();
798 aRowCount += aNbCells;
802 aTable->setRowCount( aRowCount );
804 aPointToCellIter = aPointToCellDataMap.begin();
805 for( ; aPointToCellIter != aPointToCellDataMap.end(); aPointToCellIter++ )
809 TPointID aPointID = aPointToCellIter.key();
810 const TPointToCellData& aPointToCellData = aPointToCellIter.value();
811 const TPointData& aPointData = aPointToCellData.PointData;
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 );
821 if( aTableId == PointElno )
823 const TCellDataMap& aCellDataMap = aPointToCellData.CellDataMap;
824 int aNbCells = aCellDataMap.size();
826 for( int aColumnId = Point; aColumnId <= K; aColumnId++ )
827 setRowSpan( aTableId, aRow, aColumnId, aNbCells );
829 TCellDataMap::const_iterator aCellIter = aCellDataMap.begin();
830 for( aRow--; aCellIter != aCellDataMap.end(); aCellIter++ )
833 TCellID aCellID = aCellIter.key();
834 const TValueData& aCellData = aCellIter.value();
836 setData( aTableId, aRow, Cell, aCellID );
837 setData( aTableId, aRow, Scalar, aCellData.Scalar );
838 setData( aTableId, aRow, Vector, aCellData.Vector );
843 const TValueData& aValueData = aPointData.ValueData;
844 setData( aTableId, aRow, Scalar, aValueData.Scalar );
845 setData( aTableId, aRow, Vector, aValueData.Vector );
852 for( int aCol = column( aTableId, I ), aLastCol = column( aTableId, K ); aCol <= aLastCol; aCol++ )
854 aTable->setColumnHidden( aCol, !isStructured );
855 aTable->resizeColumnsToContents();
858 int stackId = isElno ? ElnoMesh : StdMesh;
859 QStackedWidget* aStackedWg = aType == 1 ? myCellStackedWg : aType == 2 ? myPointStackedWg : 0;
861 aStackedWg->setCurrentIndex( stackId );
867 void VisuGUI_SelectionPanel::clearFields() {
868 int aType = myTabWidget->currentIndex();
871 myXPosLbl->setText("");
872 myYPosLbl->setText("");
873 myZPosLbl->setText("");
874 myDXLbl->setText("");
875 myDYLbl->setText("");
876 myDZLbl->setText("");
879 myCellIDValLbl->setText( "" );
882 myIDValLbl->setText( "" );
886 QMap<int, QTableWidget*>::iterator it = myTables.begin(), itEnd = myTables.end();
887 for( ; it != itEnd; ++it )
888 if( QTableWidget* aTable = *it )
890 aTable->clearSpans();
891 aTable->setRowCount(0);
892 aTable->resizeColumnsToContents();
896 typedef vtkIdType (VISU_PipeLine::* TGetVTKIdMethod)(vtkIdType theID);
898 bool onIdEdit (const QString& theText,
899 TGetVTKIdMethod theMethod,
901 const SalomeApp_Module* theModule,
904 QLabel* theFieldName)
906 SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(theModule);
909 SVTK_Selector* aSelector = aViewWindow->GetSelector();
911 _PTR(SObject) aSObject;
912 VISU::Prs3d_i* aPrs3d = NULL;
913 Handle(SALOME_InteractiveObject) anIO;
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);
922 anIO = aSelectionItem.myIO;
923 aSObject = anObjectInfo.mySObject;
928 int anObjId = theText.toInt( &ok );
932 VISU_PipeLine* aPipeLine = aPrs3d->GetPipeLine();
934 if( dynamic_cast<VISU_GaussPointsPL*>( aPipeLine ) )
938 aSelector->ClearIndex();
941 int aVTKId = (aPipeLine->*theMethod)(anObjId);
945 TColStd_MapOfInteger newIndices;
946 newIndices.Add(anObjId);
947 aSelector->AddOrRemoveIndex(anIO, newIndices, false);
950 aViewWindow->highlight(anIO, true, true);
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 );
960 theMeshName->setText(theValue);
961 theFieldName->setText("");
966 void VisuGUI_SelectionPanel::onPointIdEdit ()
969 TGetVTKIdMethod aMethod = &VISU_PipeLine::GetNodeVTKID;
970 bool anIsSelected = onIdEdit(myIDValLbl->text(),
975 tr("WRN_NO_AVAILABLE_DATA"),
978 // as selection manager doesn't send signal currentSelectionChanged()
984 void VisuGUI_SelectionPanel::onCellIdEdit ()
987 TGetVTKIdMethod aMethod = &VISU_PipeLine::GetElemVTKID;
988 bool anIsSelected = onIdEdit(myCellIDValLbl->text(),
993 tr("WRN_NO_AVAILABLE_DATA"),
996 // as selection manager doesn't send signal currentSelectionChanged()
1002 void VisuGUI_SelectionPanel::onDoubleClicked( const QModelIndex& theIndex )
1004 QTableWidget* aTable = dynamic_cast<QTableWidget*>( sender() );
1008 int aTableId = myTables.key( aTable, -1 );
1009 if( aTableId == -1 )
1012 int aRow = theIndex.row(), aCol = theIndex.column();
1013 const QList<int>& aColumnList = myColumnData[ aTableId ];
1015 if( aCol >= aColumnList.size() )
1018 int aColumnId = aColumnList[ aCol ];
1020 bool anIsCellSelection = true;
1024 anIsCellSelection = true;
1033 anIsCellSelection = false;
1037 anIsCellSelection = aTableId == CellStdCell || aTableId == PointElno;
1043 int anIdColumnId = anIsCellSelection ? Cell : Point;
1044 QVariant anId = data( aTableId, aRow, anIdColumnId );
1051 if( anIsCellSelection )
1053 setSelectionMode( 1 );
1054 myCellIDValLbl->setText( anId.toString() );
1059 setSelectionMode( 2 );
1060 myIDValLbl->setText( anId.toString() );
1065 void VisuGUI_SelectionPanel::onIdChanged( int theFirstId, int theSecondId )
1067 int aType = myTabWidget->currentIndex();
1070 myCellIDValLbl->setText( theFirstId < 0 ? "" : QString::number( theFirstId ) );
1073 else if( aType == 2 )
1075 myIDValLbl->setText( theFirstId < 0 ? "" : QString::number( theFirstId ) );
1078 else if( aType == 3 )
1079 myGaussPointsPane->setIds( theFirstId, theSecondId );
1082 void VisuGUI_SelectionPanel::onPreferences()
1084 preferencesDlg()->exec();
1087 void VisuGUI_SelectionPanel::onApply()
1089 VisuGUI_Panel::onApply();
1092 void VisuGUI_SelectionPanel::onClose()
1095 VisuGUI_Panel::onClose();
1098 void VisuGUI_SelectionPanel::onHelp()
1100 QString aHelpFileName = "selection_info_page.html";
1101 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1103 app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName);
1107 platform = "winapplication";
1109 platform = "application";
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) );
1116 VisuGUI_Panel::onHelp();
1119 void VisuGUI_SelectionPanel::keyPressEvent( QKeyEvent* e )
1121 VisuGUI_Panel::keyPressEvent( e );
1122 if ( e->isAccepted() )
1125 if ( e->key() == Qt::Key_F1 )