Salome HOME
Refs #289 - Spline profile is represented in OCC view as polyline profile
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_TableView.cxx
index b0c4d527f87186dd5aee432a3011ae31536ffa66..56d3a507e9f7cbcf01a4a80ad54bf042068aebbc 100644 (file)
@@ -112,42 +112,51 @@ void CurveCreator_TableView::setCurve( CurveCreator_ICurve* theCurve )
   myCurve = theCurve;
 }
 
-void CurveCreator_TableView::addLocalPointToTable(
-                     const CurveCreator_ICurve::SectionToPoint& theSToPoint )
+void CurveCreator_TableView::setLocalPointsToTable(
+  const CurveCreator_ICurve::SectionToPointList& thePoints )
 {
-  int aRowId = rowCount();
-  int anISection = theSToPoint.first;
-  int anIPoint = theSToPoint.second;
-  bool isFoundPoint = false;
-  for ( int i = 0; i < aRowId && !isFoundPoint; i++ )
-    isFoundPoint = getSectionId( i ) == anISection && 
-                   getPointId( i ) == anIPoint;
-  if ( isFoundPoint )
-    return;
-
-  setRowCount( aRowId+1 );
-
-  QTableWidgetItem* anItem;
-  anItem = new QTableWidgetItem( myCurve->getSectionName( anISection ).c_str() );
-  anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
-  anItem->setData( Qt::UserRole, anISection );
-  setItem( aRowId, 0, anItem );
-
-  anItem = new QTableWidgetItem( QString::number( anIPoint + 1 ) );
-  anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
-  anItem->setData( Qt::UserRole, anIPoint );
-  setItem( aRowId, 1, anItem );
-
-  gp_Pnt aPoint;
-  CurveCreator_UtilsICurve::getPoint( myCurve, anISection, anIPoint, aPoint );
-
-  anItem = new QTableWidgetItem( QString::number( aPoint.X(), 'f', 2 ) );
-  anItem->setData( Qt::UserRole, aPoint.X() );
-  setItem( aRowId, 2, anItem );
-
-  anItem = new QTableWidgetItem( QString::number( aPoint.Y(), 'f', 2 ) );
-  anItem->setData( Qt::UserRole, aPoint.Y() );
-  setItem( aRowId, 3, anItem );
+  setRowCount( thePoints.size() );
+
+  int aRowId = 0;
+  CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(),
+                                                          aLast = thePoints.end();
+  for ( ; anIt != aLast; anIt++ ) {
+    CurveCreator_ICurve::SectionToPoint aSPoint = *anIt;
+    int anISection = aSPoint.first;
+    int anIPoint = aSPoint.second;
+
+    QTableWidgetItem* anItem;
+    anItem = new QTableWidgetItem( myCurve->getSectionName( anISection ).c_str() );
+    anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
+    anItem->setData( Qt::UserRole, anISection );
+    setItem( aRowId, 0, anItem );
+
+    anItem = new QTableWidgetItem( QString::number( anIPoint + 1 ) );
+    anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
+    anItem->setData( Qt::UserRole, anIPoint );
+    setItem( aRowId, 1, anItem );
+
+    gp_Pnt aPoint;
+    CurveCreator_UtilsICurve::getPoint( myCurve, anISection, anIPoint, aPoint );
+
+    anItem = item( aRowId, 2 );
+    if ( !anItem ) {
+      anItem = new QTableWidgetItem();
+      setItem( aRowId, 2, anItem );
+    }
+    anItem->setData( Qt::UserRole, aPoint.X() );
+    anItem->setData( Qt::DisplayRole, QString::number( aPoint.X(), 'f', 2 ) );
+
+    anItem = item( aRowId, 3 );
+    if ( !anItem ) {
+      anItem = new QTableWidgetItem();
+      setItem( aRowId, 3, anItem );
+    }
+    anItem->setData( Qt::UserRole, aPoint.Y() );
+    anItem->setData( Qt::DisplayRole, QString::number( aPoint.Y(), 'f', 2 ) );
+
+    aRowId++;
+  }
 }
 
 int CurveCreator_TableView::getSectionId( const int theRowId ) const