-void CurveCreator_Widget::addLocalPointToTable( const double theX, const double theY )
-{
- CurveCreator_ICurve::SectionToPointList aPoints;
- findSectionsToPoints( theX, theY, aPoints );
-
- CurveCreator_ICurve::SectionToPointList aSkipList;
- // table could not contain two equal value rows
- int aRowId = myLocalPointView->rowCount();
- double aCurrentX, aCurrentY;
- int aSectionId, aPointId;
- CurveCreator_ICurve::SectionToPoint aPoint;
- for ( int i = 0; i < aRowId; i++ ) {
- aCurrentX = myLocalPointView->item( i, 2 )->data( Qt::UserRole ).toDouble();
- aCurrentY = myLocalPointView->item( i, 3 )->data( Qt::UserRole ).toDouble();
- if ( fabs( aCurrentX - theX ) < LOCAL_SELECTION_TOLERANCE &&
- fabs( aCurrentY - theY ) < LOCAL_SELECTION_TOLERANCE ) {
- aPoint = std::make_pair<int, int>( getSectionId( i ), getPointId( i ) );
- if ( !contains( aSkipList, aPoint ) )
- aSkipList.push_back( aPoint );
- }
- }
- if ( aSkipList.size() == aPoints.size() )
- return;
-
- QTableWidgetItem* anItem;
- CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints.begin(),
- aLast = aPoints.end();
- for ( ; anIt != aLast; anIt++ ) {
- aPoint = *anIt;
- if ( contains( aSkipList, aPoint ) )
- continue;
-
- myLocalPointView->setRowCount( aRowId+1 );
- aSectionId = aPoint.first;
- aPointId = aPoint.second;
-
- anItem = new QTableWidgetItem( myCurve->getSectionName( aSectionId ).c_str() );
- anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
- anItem->setData( Qt::UserRole, aSectionId );
- myLocalPointView->setItem( aRowId, 0, anItem );
-
- anItem = new QTableWidgetItem( QString::number( aPointId + 1 ) );
- anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
- anItem->setData( Qt::UserRole, aPointId );
- myLocalPointView->setItem( aRowId, 1, anItem );
-
- anItem = new QTableWidgetItem( QString::number( theX ) );
- anItem->setData( Qt::UserRole, theX );
- myLocalPointView->setItem( aRowId, 2, anItem );
-
- anItem = new QTableWidgetItem( QString::number( theY ) );
- anItem->setData( Qt::UserRole, theY );
- myLocalPointView->setItem( aRowId, 3, anItem );
- }
-}
-