From 7993cd9d77c66aa9911bf3465c40b1bb03443666 Mon Sep 17 00:00:00 2001 From: ouv Date: Fri, 16 Jan 2009 08:41:48 +0000 Subject: [PATCH] Fix for issue 0020111: EDF VISU 917 : Bad values are displayed for ELNO fields --- src/VISUGUI/VISU_msg_en.po | 21 + src/VISUGUI/VisuGUI_Selection.cxx | 687 ++++++++++++++++++++++-------- src/VISUGUI/VisuGUI_Selection.h | 76 +++- 3 files changed, 596 insertions(+), 188 deletions(-) diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 48b37a49..4b535252 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -854,6 +854,27 @@ msgid "PRS_ON_GROUPS" msgstr "Use Only Groups" +#: VisuGUI_Selection.cxx + +msgid "VisuGUI_SelectionDlg::POINT_ID_HDR" +msgstr "PointID" + +msgid "VisuGUI_SelectionDlg::CELL_ID_HDR" +msgstr "CellID" + +msgid "VisuGUI_SelectionDlg::DATA_SCALAR_HDR" +msgstr "Scalar" + +msgid "VisuGUI_SelectionDlg::DATA_VECTOR_HDR" +msgstr "Vector" + +msgid "VisuGUI_SelectionDlg::POINT_INFO" +msgstr "Point Info" + +msgid "VisuGUI_SelectionDlg::CELL_INFO" +msgstr "Cell Info" + + #: VisuGUI_ScalarBarDlg.cxx msgid "VisuGUI_ScalarBarDlg::&OK" diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 49de7510..ae01dd14 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -77,6 +77,7 @@ #include #include #include +#include // VTK Includes #include @@ -90,19 +91,6 @@ using namespace std; - -inline -QString -GetNumber( const VISU::TStructuredId& theStructuredId, - size_t theId ) -{ - if ( theStructuredId[theId] < 0 ) - return "-"; - - return QString::number( theStructuredId[theId] ); -} - - VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (const SalomeApp_Module* theModule): QDialog(VISU::GetDesktop(theModule), 0, @@ -122,17 +110,17 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (const SalomeApp_Module* theModule): TopLayout->setRowStretch(2, 1); TopLayout->setRowStretch(3, 0); - QHButtonGroup* aTypeBox = new QHButtonGroup ("Selection", this); + myTypeBox = new QHButtonGroup ("Selection", this); QRadioButton* aPointBtn = - new QRadioButton ("Point", aTypeBox); - new QRadioButton ("Cell" , aTypeBox); - new QRadioButton ("Actor", aTypeBox); + new QRadioButton ("Point", myTypeBox); + new QRadioButton ("Cell" , myTypeBox); + new QRadioButton ("Actor", myTypeBox); aPointBtn->setChecked(true); - connect(aTypeBox, SIGNAL(clicked(int)), this, SLOT(onSelectionChange(int))); + connect(myTypeBox, SIGNAL(clicked(int)), this, SLOT(onSelectionChange(int))); - TopLayout->addWidget(aTypeBox, 0, 0); + TopLayout->addWidget(myTypeBox, 0, 0); QWidget* aNamePane = new QWidget (this); QGridLayout* aNameLay = new QGridLayout (aNamePane); @@ -152,6 +140,27 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (const SalomeApp_Module* theModule): myWidgetStack = new QWidgetStack (this); + QTable* aTable; + + // Fill column data + myColumnData.insert( CellStdCell, QValueList() << Cell << Scalar << Vector ); + myColumnData.insert( CellStdPoint, QValueList() << Point << X << Y << Z << I << J << K << Scalar << Vector ); + myColumnData.insert( PointStd, QValueList() << Point << X << Y << Z << I << J << K << Scalar << Vector ); + myColumnData.insert( CellElno, QValueList() << Cell << Point << X << Y << Z << I << J << K << Scalar << Vector ); + myColumnData.insert( PointElno, QValueList() << Point << X << Y << Z << I << J << K << Cell << Scalar << Vector ); + + QMap 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 QVBox (myWidgetStack); myPointsPane->layout()->setSpacing(6); @@ -166,84 +175,84 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (const SalomeApp_Module* theModule): myIDValLbl->setValidator(aIntValidator); connect(myIDValLbl, SIGNAL(textChanged(const QString&)), this, SLOT(onPointIdEdit(const QString&))); - new QLabel ("Scalar Value:", aDataGrp); - myScalarValLbl = new QLabel ("", aDataGrp); - new QLabel ("Vector Value:", aDataGrp); - myVectorValLbl = new QLabel ("", aDataGrp); - myVectorValLbl->setMinimumWidth(150); - - QGroupBox* aCoordGrp = new QGroupBox (4, Qt::Horizontal, "Coordinates", myPointsPane); - aCoordGrp->layout()->setSpacing(6); - new QLabel ("X:", aCoordGrp); - myXValLbl = new QLabel ("", aCoordGrp); - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - new QLabel ("I:", aCoordGrp); - myIValLbl = new QLabel ("-", aCoordGrp); - //ENK: 23.11.2006 - new QLabel ("Y:", aCoordGrp); - myYValLbl = new QLabel ("", aCoordGrp); - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - new QLabel ("J:", aCoordGrp); - myJValLbl = new QLabel ("-", aCoordGrp); - //ENK: 23.11.2006 - new QLabel ("Z:",aCoordGrp ); - myZValLbl = new QLabel ("", aCoordGrp); - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - new QLabel ("K:", aCoordGrp); - myKValLbl = new QLabel ("-", aCoordGrp); - //ENK: 23.11.2006 + myPointStackedWg = new QWidgetStack( myPointsPane ); + myPointsPane->setStretchFactor( myPointStackedWg, 1 ); + + aTable = new QTable( myPointStackedWg ); + myPointStackedWg->addWidget( aTable, StdMesh ); + myTables.insert( PointStd, aTable ); + aTable = new QTable( myPointStackedWg ); + myPointStackedWg->addWidget( aTable, ElnoMesh ); + myTables.insert( PointElno, aTable ); myWidgetStack->addWidget(myPointsPane, 0); // Create Cells pane - myCellsPane = new QWidget (myWidgetStack); - QGridLayout* aCellLayout = new QGridLayout (myCellsPane); - aCellLayout->setSpacing(6); - aCellLayout->setRowStretch(0, 0); - aCellLayout->setRowStretch(1, 1); + myCellsPane = new QVBox (myWidgetStack); + myCellsPane->layout()->setSpacing(6); QGroupBox* aCellGrp = new QGroupBox(2, Qt::Horizontal, "Data of Cell", myCellsPane); + aCellGrp->layout()->setSpacing(6); new QLabel ("ID:", aCellGrp); myCellIDValLbl = new QLineEdit ("", aCellGrp); myCellIDValLbl->setValidator(aIntValidator); connect(myCellIDValLbl, SIGNAL(textChanged(const QString&)), this, SLOT(onCellIdEdit(const QString&))); - new QLabel ("Scalar Value:", aCellGrp); - myCellScalarValLbl = new QLabel ("", aCellGrp); - new QLabel ("Vector Value:", aCellGrp); - myCellVectorValLbl = new QLabel ("", aCellGrp); - - aCellLayout->addWidget(aCellGrp, 0, 0); - - myListPoints = new QTable (myCellsPane); - myListPoints->setReadOnly(true); - myListPoints->setNumCols(9); - myListPoints->setNumRows(0); - myListPoints->setColumnWidth(0, 40); - myListPoints->setColumnWidth(1, 40); - myListPoints->setColumnWidth(2, 40); - myListPoints->setColumnWidth(3, 40); - myListPoints->setColumnWidth(4, 40);//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - myListPoints->setColumnWidth(5, 40);//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - myListPoints->setColumnWidth(6, 40);//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - myListPoints->setSelectionMode(QTable::NoSelection); - QHeader* aHeader = myListPoints->horizontalHeader(); - aHeader->setLabel( 0, "ID" ); - aHeader->setLabel( 1, "X" ); - aHeader->setLabel( 2, "Y" ); - aHeader->setLabel( 3, "Z" ); - aHeader->setLabel( 4, "I" );//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - aHeader->setLabel( 5, "J" );//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - aHeader->setLabel( 6, "K" );//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - aHeader->setLabel( 7, "Scalar" ); - aHeader->setLabel( 8, "Vector" ); - - aCellLayout->addWidget(myListPoints, 1, 0); + myCellStackedWg = new QWidgetStack( myCellsPane ); + myCellsPane->setStretchFactor( myCellStackedWg, 1 ); + + QTabWidget* aStdTabWidget = new QTabWidget( myCellStackedWg ); + myCellStackedWg->addWidget( aStdTabWidget, StdMesh ); + + aTable = new QTable( aStdTabWidget ); + aStdTabWidget->addTab( aTable, tr("CELL_INFO") ); + myTables.insert( CellStdCell, aTable ); + + aTable = new QTable( aStdTabWidget ); + aStdTabWidget->addTab( aTable, tr("POINT_INFO") ); + myTables.insert( CellStdPoint, aTable ); + + aTable = new QTable( myCellStackedWg ); + myCellStackedWg->addWidget( aTable, ElnoMesh ); + myTables.insert( CellElno, aTable ); myWidgetStack->addWidget(myCellsPane, 1); + // Common operations for all tables + QMap::iterator it = myTables.begin(), itEnd = myTables.end(); + for( ; it != itEnd; ++it ) + { + aTable = it.data(); + if( !aTable ) + continue; + + int aTableId = it.key(); + if( !myColumnData.contains( aTableId ) ) + continue; + + QStringList aHorizontalHeaderLabels; + QValueList aColumns = myColumnData[ aTableId ]; + QValueList::iterator aColumnIter = aColumns.begin(); + for( ; aColumnIter != aColumns.end(); ++aColumnIter ) + { + int aColumnId = *aColumnIter; + if( aColumnId >= 0 && aColumnId < aColumnHeaders.size() ) + aHorizontalHeaderLabels << aColumnHeaders[ aColumnId ]; + } + aTable->setNumCols( aHorizontalHeaderLabels.size() ); + aTable->setColumnLabels( aHorizontalHeaderLabels ); + + aTable->setReadOnly( true ); + aTable->setSelectionMode( QTable::NoSelection ); + for( int aCol = 0, aLastCol = aTable->numCols() - 1; aCol <= aLastCol; aCol++ ) + aTable->adjustColumn( aCol ); + + connect( aTable, SIGNAL( doubleClicked( int, int, int, const QPoint& ) ), + this, SLOT( onDoubleClicked( int, int, int, const QPoint& ) ) ); + } + // Actor Pane myActorsPane = new QVBox (myWidgetStack); myActorsPane->layout()->setSpacing(6); @@ -314,6 +323,45 @@ VisuGUI_SelectionDlg::~VisuGUI_SelectionDlg() } } +int VisuGUI_SelectionDlg::column( int theTableId, int theColumnId ) +{ + if( !myColumnData.contains( theTableId ) ) + return -1; + + const QValueList& aColumnList = myColumnData[ theTableId ]; + return aColumnList.findIndex( theColumnId ); +} + +QString VisuGUI_SelectionDlg::data( int theTableId, int theRow, int theColumnId ) +{ + if( !myTables.contains( theTableId ) ) + return QString(); + + if( QTable* aTable = myTables[ theTableId ] ) + return aTable->text( theRow, column( theTableId, theColumnId ) ); + + return QString(); +} + +void VisuGUI_SelectionDlg::setData( int theTableId, int theRow, int theColumnId, const QString& theValue ) +{ + if( !myTables.contains( theTableId ) ) + return; + + if( QTable* aTable = myTables[ theTableId ] ) + aTable->setText( theRow, column( theTableId, theColumnId ), theValue ); +} + +void VisuGUI_SelectionDlg::setRowSpan( int theTableId, int theRow, int theColumnId, int theRowSpan ) +{ + if( !myTables.contains( theTableId ) ) + return; + + if( QTable* aTable = myTables[ theTableId ] ) + if( QTableItem* anItem = aTable->item( theRow, column( theTableId, theColumnId ) ) ) + anItem->setSpan( theRowSpan, 1 ); +} + void VisuGUI_SelectionDlg::onSelectionChange (int theId) { SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myModule); @@ -343,7 +391,7 @@ void VisuGUI_SelectionDlg::closeEvent (QCloseEvent* theEvent) QDialog::closeEvent(theEvent); } -template QString getValue(TData* theData, int theId){ +template QString getScalar(TData* theData, int theId){ if (vtkDataArray *aScalar = theData->GetScalars()){ vtkFloatingPointType aVal = aScalar->GetTuple1(theId); return QString::number(aVal); @@ -361,6 +409,40 @@ template QString getVector(TData* theData, int theId){ } } +template 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; +} + #define ABS(a) (a>=0)?a:-a void VisuGUI_SelectionDlg::onSelectionEvent() { @@ -402,6 +484,7 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { } } + clearFields(); if (aPrs3d) { QString aMeshName("NULL"), aFieldName("NULL"); @@ -430,104 +513,289 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { myDZLbl->setText(QString::number( ABS(aCoord[5]-aCoord[4]) )); TColStd_IndexedMapOfInteger aMapIndex; - typedef std::vector TCoordArray; - typedef map TPointCoordsMap; - TPointCoordsMap aPointCoordsMap; - aSelector->GetIndex(anIO, aMapIndex); + bool aSingleSelection = aMapIndex.Extent() == 1; vtkDataSet* aDataSet = anVISUActor->GetMapper()->GetInput(); - vtkPointData* aPntData = aDataSet->GetPointData(); + bool isElno = VISU::IsElnoData( aDataSet ); + + const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper(); + bool isStructured = aMapper->IsStructured(); + + TCellToPointDataMap aCellToPointDataMap; + TPointToCellDataMap aPointToCellDataMap; + TPointDataMap aGlobalPointDataMap; for (int ind = 1; ind <= aMapIndex.Extent(); ind++) { int anID = aMapIndex(ind); - switch (aType) { - case 0: + switch (aType) + { + case 0: { - int aVTKID = anVISUActor->GetNodeVTKID(anID); - if ( aVTKID >= 0 ) { - vtkFloatingPointType* aCoord = anVISUActor->GetNodeCoord(anID); - myXValLbl->setText( QString::number( aCoord[0] ) ); - myYValLbl->setText( QString::number( aCoord[1] ) ); - myZValLbl->setText( QString::number( aCoord[2] ) ); + if( aSingleSelection ) myIDValLbl->setText( QString::number( anID ) ); - - if ( !VISU::IsElnoData( aDataSet ) ) { - myScalarValLbl->setText( getValue( aPntData, aVTKID ) ); - myVectorValLbl->setText( getVector( aPntData, aVTKID ) ); - } else { - myScalarValLbl->setText( "< ELNO data >" ); - myVectorValLbl->setText( "< ELNO data >" ); - } - const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper(); - VISU::TStructuredId aStructuredId = aMapper->GetIndexesOfNode( anID ); - myKValLbl->setText( GetNumber( aStructuredId, 2 ) ); - myJValLbl->setText( GetNumber( aStructuredId, 1 ) ); - myIValLbl->setText( GetNumber( aStructuredId, 0 ) ); - } + 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; + } + + TPointToCellData aPointToCellData; + aPointToCellData.PointData = getPointData( aPointVTKID, anVISUActor, aMapper, !isElno ); + aPointToCellData.CellDataMap = aCellDataMap; + aPointToCellDataMap[ anID ] = aPointToCellData; + break; } - break; - case 1: + case 1: { - vtkCellData* aCellData = aDataSet->GetCellData(); - vtkCell* aCell = anVISUActor->GetElemCell(anID); - int aVTKID = anVISUActor->GetElemVTKID(anID); - if (aCell != NULL) { - int aNbOfPoints = aCell->GetNumberOfPoints(); - if ( aNbOfPoints > 0 ) { - myCellIDValLbl->setText( QString::number(anID) ); - myCellScalarValLbl->setText(getValue(aCellData, aVTKID)); - myCellVectorValLbl->setText(getVector(aCellData, aVTKID)); - - 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; - } - } - } + 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; } } - myListPoints->setNumRows(aPointCoordsMap.size()); - TPointCoordsMap::const_iterator anIter = aPointCoordsMap.begin(); + // Fill tables + QValueList aTableIds; + switch( aType ) + { + case 0: + aTableIds.append( isElno ? PointElno : PointStd ); + break; + case 1: + if( isElno ) + aTableIds.append( CellElno ); + else + { + aTableIds.append( CellStdCell ); + aTableIds.append( CellStdPoint ); + } + break; + } - const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper(); - for (int i = 0; anIter != aPointCoordsMap.end() && i < myListPoints->numRows(); anIter++, i++) { - myListPoints->verticalHeader()->setLabel(i, QString::number( i )); - vtkIdType aNodeObjId = anIter->first; - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - VISU::TStructuredId aStructuredId = aMapper->GetIndexesOfNode(aNodeObjId); - QString aI = GetNumber(aStructuredId, 0); - QString aJ = GetNumber(aStructuredId, 1); - QString aK = GetNumber(aStructuredId, 2); - //ENK: 23.11.2006 - - myListPoints->setText(i, 0, QString::number( aNodeObjId )); - const TCoordArray& aCoordArray = anIter->second; - myListPoints->setText(i, 1, QString::number( aCoordArray[0] )); - myListPoints->setText(i, 2, QString::number( aCoordArray[1] )); - myListPoints->setText(i, 3, QString::number( aCoordArray[2] )); - myListPoints->setText(i, 4, aI);//ENK: 23.11.2006 - PAL13176 - myListPoints->setText(i, 5, aJ);//ENK: 23.11.2006 - PAL13176 - myListPoints->setText(i, 6, aK);//ENK: 23.11.2006 - PAL13176 - - vtkIdType aNodeVTKId = anVISUActor->GetNodeVTKID(aNodeObjId); - myListPoints->setText(i, 7, getValue(aPntData, aNodeVTKId)); - myListPoints->setText(i, 8, getVector(aPntData, aNodeVTKId)); + QValueList::iterator aTableIter = aTableIds.begin(); + for( ; aTableIter != aTableIds.end(); ++aTableIter ) + { + int aTableId = *aTableIter; + if( !myTables.contains( aTableId ) ) + continue; + + QTable* aTable = myTables[ aTableId ]; + if( !aTable ) + continue; + + int aRow = -1; + switch( aTableId ) + { + case CellStdPoint: + { + int aRowCount = aGlobalPointDataMap.size(); + aTable->setNumRows( aRowCount ); + + TPointDataMap::const_iterator aPointIter = aGlobalPointDataMap.begin(); + for( ; aPointIter != aGlobalPointDataMap.end(); aPointIter++ ) + { + aRow++; + TPointID aPointID = aPointIter.key(); + const TPointData& aPointData = aPointIter.data(); + const TValueData& aValueData = aPointData.ValueData; + + setData( aTableId, aRow, Point, QString::number( aPointID ) ); + setData( aTableId, aRow, X, QString::number( aPointData.X ) ); + setData( aTableId, aRow, Y, QString::number( aPointData.Y ) ); + setData( aTableId, aRow, Z, QString::number( aPointData.Z ) ); + setData( aTableId, aRow, I, QString::number( aPointData.I ) ); + setData( aTableId, aRow, J, QString::number( aPointData.J ) ); + setData( aTableId, aRow, K, QString::number( 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.data(); + const TPointDataMap& aPointDataMap = aCellToPointData.PointDataMap; + int aNbPoints = aPointDataMap.size(); + + aRowCount += aNbPoints; + } + } + aTable->setNumRows( aRowCount ); + + aCellToPointIter = aCellToPointDataMap.begin(); + for( ; aCellToPointIter != aCellToPointDataMap.end(); aCellToPointIter++ ) + { + aRow++; + + TCellID aCellID = aCellToPointIter.key(); + const TCellToPointData& aCellToPointData = aCellToPointIter.data(); + const TValueData& aCellData = aCellToPointData.CellData; + + setData( aTableId, aRow, Cell, QString::number( 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.data(); + const TValueData& aValueData = aPointData.ValueData; + + setData( aTableId, aRow, Point, QString::number( aPointID ) ); + setData( aTableId, aRow, X, QString::number( aPointData.X ) ); + setData( aTableId, aRow, Y, QString::number( aPointData.Y ) ); + setData( aTableId, aRow, Z, QString::number( aPointData.Z ) ); + setData( aTableId, aRow, I, QString::number( aPointData.I ) ); + setData( aTableId, aRow, J, QString::number( aPointData.J ) ); + setData( aTableId, aRow, K, QString::number( 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.data(); + const TCellDataMap& aCellDataMap = aPointToCellData.CellDataMap; + int aNbCells = aCellDataMap.size(); + if( aNbCells > 1 ) + aRowCount += aNbCells; + else + aRowCount++; + } + aTable->setNumRows( aRowCount ); + + aPointToCellIter = aPointToCellDataMap.begin(); + for( ; aPointToCellIter != aPointToCellDataMap.end(); aPointToCellIter++ ) + { + aRow++; + + TPointID aPointID = aPointToCellIter.key(); + const TPointToCellData& aPointToCellData = aPointToCellIter.data(); + const TPointData& aPointData = aPointToCellData.PointData; + + setData( aTableId, aRow, Point, QString::number( aPointID ) ); + setData( aTableId, aRow, X, QString::number( aPointData.X ) ); + setData( aTableId, aRow, Y, QString::number( aPointData.Y ) ); + setData( aTableId, aRow, Z, QString::number( aPointData.Z ) ); + setData( aTableId, aRow, I, QString::number( aPointData.I ) ); + setData( aTableId, aRow, J, QString::number( aPointData.J ) ); + setData( aTableId, aRow, K, QString::number( 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.data(); + + setData( aTableId, aRow, Cell, QString::number( 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; + } + } + + int aCol, aLastCol; + for( aCol = column( aTableId, I ), aLastCol = column( aTableId, K ); aCol <= aLastCol; aCol++ ) + if( aCol != -1 ) + isStructured ? aTable->showColumn( aCol ) : aTable->hideColumn( aCol ); + for( aCol = 0, aLastCol = aTable->numCols() - 1; aCol <= aLastCol; aCol++ ) + aTable->adjustColumn( aCol ); } - for(int aColumnId = 0; aColumnId < 9; aColumnId++) - myListPoints->adjustColumn(aColumnId); + + int stackId = isElno ? ElnoMesh : StdMesh; + QWidgetStack* aStackedWg = aType == 0 ? myPointStackedWg : aType == 1 ? myCellStackedWg : 0; + if( aStackedWg ) + aStackedWg->raiseWidget( stackId ); } - } else { - clearFields(); } myFl = false; } @@ -538,19 +806,10 @@ void VisuGUI_SelectionDlg::clearFields() { int aType = myWidgetStack->id(myWidgetStack->visibleWidget()); switch (aType) { case 0: - myXValLbl->setText( "" ); - myYValLbl->setText( "" ); - myZValLbl->setText( "" ); - myIValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176 - myJValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176 - myKValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176 - myScalarValLbl->setText(""); - myVectorValLbl->setText(""); + myIDValLbl->setText( "" ); break; case 1: - myCellScalarValLbl->setText(""); - myCellVectorValLbl->setText(""); - myListPoints->setNumRows(0); + myCellIDValLbl->setText( "" ); break; case 2: myXPosLbl->setText(""); @@ -560,6 +819,15 @@ void VisuGUI_SelectionDlg::clearFields() { myDYLbl->setText(""); myDZLbl->setText(""); } + + QMap::iterator it = myTables.begin(), itEnd = myTables.end(); + for( ; it != itEnd; ++it ) + if( QTable* aTable = *it ) + { + aTable->setNumRows(0); + for( int aCol = 0, aLastCol = aTable->numCols() - 1; aCol <= aLastCol; aCol++ ) + aTable->adjustColumn( aCol ); + } } typedef vtkIdType (VISU_PipeLine::* TGetVTKIdMethod)(vtkIdType theID); @@ -615,7 +883,7 @@ bool onIdEdit (const QString& theText, void VisuGUI_SelectionDlg::onPointIdEdit (const QString& theText) { - if (myFl) return; + if (myFl || theText.isEmpty()) return; TGetVTKIdMethod aMethod = &VISU_PipeLine::GetNodeVTKID; bool anIsSelected = onIdEdit(theText, aMethod, @@ -633,7 +901,7 @@ void VisuGUI_SelectionDlg::onPointIdEdit (const QString& theText) void VisuGUI_SelectionDlg::onCellIdEdit (const QString& theText) { - if (myFl) return; + if (myFl || theText.isEmpty()) return; TGetVTKIdMethod aMethod = &VISU_PipeLine::GetElemVTKID; bool anIsSelected = onIdEdit(theText, aMethod, @@ -649,6 +917,77 @@ void VisuGUI_SelectionDlg::onCellIdEdit (const QString& theText) clearFields(); } +void VisuGUI_SelectionDlg::onDoubleClicked( int theRow, int theCol, int, const QPoint& ) +{ + QTable* aTable = ( QTable* )sender(); + if( !aTable ) + return; + + int aTableId = -1; + QMap::iterator it = myTables.begin(), itEnd = myTables.end(); + for( ; it != itEnd; ++it ) + { + if( it.data() == aTable ) + { + aTableId = it.key(); + break; + } + } + + if( aTableId == -1 ) + return; + + const QValueList& aColumnList = myColumnData[ aTableId ]; + if( theCol >= aColumnList.size() ) + return; + + int aColumnId = aColumnList[ theCol ]; + + 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; + QString anId = data( aTableId, theRow, anIdColumnId ); + + bool ok = false; + anId.toInt( &ok ); + if( !ok ) + return; + + if( anIsCellSelection ) + { + myTypeBox->setButton( 1 ); + onSelectionChange( 1 ); + myCellIDValLbl->setText( anId ); + } + else + { + myTypeBox->setButton( 0 ); + onSelectionChange( 0 ); + myIDValLbl->setText( anId ); + } +} + void VisuGUI_SelectionDlg::onHelp() { QString aHelpFileName = "selection_info_page.html"; diff --git a/src/VISUGUI/VisuGUI_Selection.h b/src/VISUGUI/VisuGUI_Selection.h index 5024a782..f372f037 100644 --- a/src/VISUGUI/VisuGUI_Selection.h +++ b/src/VISUGUI/VisuGUI_Selection.h @@ -29,19 +29,65 @@ #define VisuGUI_Selection_HeaderFile #include +#include + +#include class QLabel; class QWidgetStack; class QVBox; class QLineEdit; class QTable; +class QButtonGroup; class LightApp_SelectionMgr; class SalomeApp_Application; class SalomeApp_Module; +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 TPointDataMap; +typedef QMap TCellDataMap; + +struct TCellToPointData +{ + TValueData CellData; + TPointDataMap PointDataMap; +}; + +struct TPointToCellData +{ + TPointData PointData; + TCellDataMap CellDataMap; +}; + +typedef QMap TCellToPointDataMap; +typedef QMap TPointToCellDataMap; + class VisuGUI_SelectionDlg: public QDialog { Q_OBJECT + enum MeshType { StdMesh = 0, ElnoMesh }; + enum TableId { CellStdCell = 0, CellStdPoint, PointStd, CellElno, PointElno }; + enum ColumnId { Cell, Point, X, Y, Z, I, J, K, Scalar, Vector }; + public: VisuGUI_SelectionDlg (const SalomeApp_Module* theModule); virtual ~VisuGUI_SelectionDlg (); @@ -57,34 +103,34 @@ private slots: void onSelectionEvent (); void onPointIdEdit (const QString& theText); void onCellIdEdit (const QString& theText); + void onDoubleClicked (int theRow, int theCol, int, const QPoint&); void onHelp(); private: void clearFields (); + int column( int theTableId, int theColumnId ); + QString data( int theTableId, int theRow, int theColumnId ); + void setData( int theTableId, int theRow, int theColumnId, const QString& theValue ); + void setRowSpan( int theTableId, int theRow, int theColumnId, int theRowSpan ); + + private: + QButtonGroup* myTypeBox; + QLabel* myMeshName; QLabel* myFieldName; QWidgetStack* myWidgetStack; QVBox* myPointsPane; - QWidget* myCellsPane; - QLabel* myXValLbl; - QLabel* myYValLbl; - QLabel* myZValLbl; - //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing - QLabel* myIValLbl; //!< used for structured mesh selection - QLabel* myJValLbl; //!< used for structured mesh selection - QLabel* myKValLbl; //!< used for structured mesh selection - //ENK: 23.11.2006 + QVBox* myCellsPane; QLineEdit* myIDValLbl; - QLabel* myScalarValLbl; - QLabel* myVectorValLbl; + QWidgetStack* myPointStackedWg; - QTable* myListPoints; QLineEdit* myCellIDValLbl; - QLabel* myCellScalarValLbl; - QLabel* myCellVectorValLbl; + QWidgetStack* myCellStackedWg; + + QMap myTables; QVBox* myActorsPane; QLabel* myXPosLbl; @@ -97,6 +143,8 @@ private slots: const SalomeApp_Module* myModule; LightApp_SelectionMgr* mySelectionMgr; bool myFl; + + QMap< int, QValueList > myColumnData; }; #endif -- 2.39.2