From: Paul RASCLE Date: Fri, 27 May 2016 07:16:42 +0000 (+0200) Subject: curve creator: display distance between points in table view X-Git-Tag: V8_2_0a1^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a9bed41d00c6178121a2cfbf044ecb3d88d44f43;p=modules%2Fgeom.git curve creator: display distance between points in table view --- diff --git a/src/CurveCreator/CurveCreator_TableView.cxx b/src/CurveCreator/CurveCreator_TableView.cxx index 31bbb5c4d..884b78672 100644 --- a/src/CurveCreator/CurveCreator_TableView.cxx +++ b/src/CurveCreator/CurveCreator_TableView.cxx @@ -101,14 +101,15 @@ CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve, { setItemDelegate( new CurveCreator_TableItemDelegate( this ) ); setVisible( false ); - setColumnCount( 4 ); + setColumnCount( 5 ); setColumnWidth( 0, SECTION_NAME_COLUMN_WIDTH ); setColumnWidth( 1, POINT_INDEX_COLUMN_WIDTH ); QStringList aLabels; QString aCoord1 = theCoordTitles.size() > 0 ? theCoordTitles[0] : tr( "TABLE_X" ); // tr( "X_POSITION_LBL" ) QString aCoord2 = theCoordTitles.size() > 1 ? theCoordTitles[1] : tr( "TABLE_Y" ); // tr( "Y_POSITION_LBL" ) + QString aDistance = theCoordTitles.size() > 2 ? theCoordTitles[2] : tr( "DISTANCE_PREV" ); //aLabels << tr( "SECTION_LABEL" ) << tr( "IDENTIFIER_LABEL" ) << aCoord1 << aCoord2; - aLabels << tr( "TABLE_SECTION" ) << tr("TABLE_INDEX") << aCoord1 << aCoord2; + aLabels << tr( "TABLE_SECTION" ) << tr("TABLE_INDEX") << aCoord1 << aCoord2 << aDistance; setHorizontalHeaderLabels( aLabels ); connect( horizontalHeader(), SIGNAL( sectionClicked( int ) ), this, SLOT( OnHeaderClick( int ) ) ); @@ -125,6 +126,8 @@ void CurveCreator_TableView::setLocalPointsToTable( setRowCount( thePoints.size() ); int aRowId = 0; + double prevX=0; + double prevY=0; CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(), aLast = thePoints.end(); for ( ; anIt != aLast; anIt++ ) { @@ -153,7 +156,7 @@ void CurveCreator_TableView::setLocalPointsToTable( setItem( aRowId, 2, anItem ); } anItem->setData( Qt::UserRole, aPoint.X() ); - anItem->setData( Qt::DisplayRole, QString::number( aPoint.X(), 'f', 2 ).toDouble() ); + anItem->setData( Qt::DisplayRole, QString::number( aPoint.X(), 'f', 3 ).toDouble() ); anItem = item( aRowId, 3 ); if ( !anItem ) { @@ -161,7 +164,20 @@ void CurveCreator_TableView::setLocalPointsToTable( setItem( aRowId, 3, anItem ); } anItem->setData( Qt::UserRole, aPoint.Y() ); - anItem->setData( Qt::DisplayRole, QString::number( aPoint.Y(), 'f', 2 ).toDouble() ); + anItem->setData( Qt::DisplayRole, QString::number( aPoint.Y(), 'f', 3 ).toDouble() ); + + anItem = item( aRowId, 4 ); + if ( !anItem ) { + anItem = new QTableWidgetItem(); + setItem( aRowId, 4, anItem ); + } + double d=0; + if (aRowId>0) + d=sqrt((aPoint.X()-prevX)* (aPoint.X()-prevX) + (aPoint.Y()-prevY)* (aPoint.Y()-prevY)); + anItem->setData( Qt::UserRole, d ); + anItem->setData( Qt::DisplayRole, QString::number( d, 'f', 6 ).toDouble() ); + prevX = aPoint.X(); + prevY = aPoint.Y(); aRowId++; } diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 491d964f8..bdb86dfc0 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -5808,6 +5808,10 @@ shells and solids on the other hand. TABLE_Y Y + + DISTANCE_PREV + Distance + CurveCreator_Widget