QList<ActionId> anEnabledAct;
if( myCurve ){
anEnabledAct << NEW_SECTION_ID << MODIFICATION_MODE_ID;
+ if ( getActionMode() == ModificationMode )
+ anEnabledAct << REMOVE_ID;
QList<int> aSelSections = mySectionView->getSelectedSections();
QList< QPair< int, int > > aSelPoints = mySectionView->getSelectedPoints();
CurveCreator_TreeView::SelectionType aSelType = mySectionView->getSelectionType();
{
if( !myCurve )
return;
+
+ CurveCreator_Widget::SectionToPointList aPoints;
+ startCurveModification( aPoints, false );
myCurve->undo();
+ finishCurveModification();
mySectionView->reset();
updateUndoRedo();
}
{
if( !myCurve )
return;
+ CurveCreator_Widget::SectionToPointList aPoints;
+ startCurveModification( aPoints, false );
myCurve->redo();
+ finishCurveModification();
mySectionView->reset();
updateUndoRedo();
}
int aSectionId = anIt.key();
QList<int> aSectionPoints = anIt.value();
- qSort( aPoints );
+ qSort( aSectionPoints );
for( int i = aSectionPoints.size()-1; i >= 0; i-- ){
int aPntIndx = aSectionPoints[i];
myCurve->removePoint( aSectionId, aPntIndx );
aCurrentY = myLocalPointView->item( i, 3 )->data( Qt::UserRole ).toDouble();
if ( fabs( aCurrentX - theX ) < LOCAL_SELECTION_TOLERANCE &&
fabs( aCurrentY - theY ) < LOCAL_SELECTION_TOLERANCE ) {
- aPoint = qMakePair( getSectionId( i ), getPointId( i ) );
- if ( !aSkipList.contains( aPoint ) )
- aSkipList.append( aPoint );
+ aPoint = std::make_pair<int, int>( getSectionId( i ), getPointId( i ) );
+ if ( !contains( aSkipList, aPoint ) )
+ aSkipList.push_back( aPoint );
}
}
if ( aSkipList.size() == aPoints.size() )
SectionToPointList::const_iterator anIt = aPoints.begin(), aLast = aPoints.end();
for ( ; anIt != aLast; anIt++ ) {
aPoint = *anIt;
- if ( aSkipList.contains( aPoint ) )
+ if ( contains( aSkipList, aPoint ) )
continue;
myLocalPointView->setRowCount( aRowId+1 );
{
thePoints.clear();
for ( int i = 0, aNb = myLocalPointView->rowCount(); i < aNb; i++ )
- thePoints.append( qMakePair( getSectionId( i ), getPointId( i ) ) );
+ thePoints.push_back( std::make_pair( getSectionId( i ), getPointId( i ) ) );
}
void CurveCreator_Widget::setSelectedPonts( const CurveCreator_Widget::SectionToPointList& thePoints )
SectionToPoint aPoint;
for ( ; anIt != aLast; anIt++ ) {
aPoint = *anIt;
- if ( thePoints.contains( aPoint ) )
+ if ( contains( thePoints, aPoint ) )
aListToSelect.Append( anAIS );
}
}
void CurveCreator_Widget::finishCurveModification(
const CurveCreator_Widget::SectionToPointList& thePoints )
{
- setLocalPointContext( true );
- int aSectionId = 0;
+ if ( getActionMode() == ModificationMode )
+ setLocalPointContext( true );
setSelectedPonts( thePoints );
}
aPointId = findLocalPointIndex( i, theX, theY );
if ( aPointId < 0 )
continue;
- SectionToPoint aPoint = qMakePair( i, aPointId );
- if ( !thePoints.contains( aPoint ) )
- thePoints.append( aPoint );
+ SectionToPoint aPoint = std::make_pair( i, aPointId );
+ if ( !contains( thePoints, aPoint ) )
+ thePoints.push_back( aPoint );
}
}
{
return myLocalPointView->item( theRowId, 1 )->data( Qt::UserRole ).toInt();
}
+
+/**
+ * Returns whethe the container has the value
+ * \param theList a container of values
+ * \param theValue a value
+ */
+bool CurveCreator_Widget::contains( const CurveCreator_Widget::SectionToPointList& theList,
+ const CurveCreator_Widget::SectionToPoint& theValue ) const
+{
+ bool isFound = false;
+
+ SectionToPointList::const_iterator anIt = theList.begin(), aLast = theList.end();
+ for ( ; anIt != aLast && !isFound; anIt++ )
+ isFound = anIt->first == theValue.first && anIt->second == theValue.second;
+
+ return isFound;
+}