QItemDelegate::setModelData( theEditor, theModel, theIndex );
}
-CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent )
+CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve,
+ QWidget* theParent,
+ const QStringList& theCoordTitles )
: QTableWidget( theParent ), myCurve( theCurve )
{
setItemDelegate( new CurveCreator_TableItemDelegate( this ) );
setColumnWidth( 0, SECTION_NAME_COLUMN_WIDTH );
setColumnWidth( 1, POINT_INDEX_COLUMN_WIDTH );
QStringList aLabels;
- //aLabels << tr( "SECTION_LABEL" ) << tr( "IDENTIFIER_LABEL" ) << tr( "X_POSITION_LBL" ) << tr( "Y_POSITION_LBL" );
- aLabels << tr( "Section" ) << "Index" << tr( "X" ) << tr( "Y" );
+ QString aCoord1 = theCoordTitles.size() > 0 ? theCoordTitles[0] : tr( "X" ); // tr( "X_POSITION_LBL" )
+ QString aCoord2 = theCoordTitles.size() > 1 ? theCoordTitles[1] : tr( "Y" ); // tr( "Y_POSITION_LBL" )
+ //aLabels << tr( "SECTION_LABEL" ) << tr( "IDENTIFIER_LABEL" ) << aCoord1 << aCoord2;
+ aLabels << tr( "Section" ) << "Index" << aCoord1 << aCoord2;
setHorizontalHeaderLabels( aLabels );
}
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