// Construct undo for RemovePoints command.
CurveCreator_ICurve::SectionToPointList aSectionToPointList;
CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = theParamList1.begin(), aLast = theParamList1.end();
- int aSectionId, aPointId;
for ( ; anIt != aLast; anIt++ ) {
aSectionToPointList.push_back(anIt->first);
}
return isOK;
}
+bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
+ const CurveCreator_ICurve::SectionToPointCoordsList &theOldParamList)
+{
+ bool isOK = false;
+
+ if (theCurve != NULL && theOldParamList.size() > 0) {
+ clear();
+
+ // Set redo.
+ myPRedo = new CurveCreator_Operation;
+
+ // Construct redo for SetCoordinates command.
+ CurveCreator_ICurve::SectionToPointCoordsList aSectionToPointActualCoords;
+ CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
+ theOldParamList.begin(), aLast = theOldParamList.end();
+ for ( ; anIt != aLast; anIt++ ) {
+ CurveCreator::Coordinates anActualCoords = theCurve->getPoint(anIt->first.first, anIt->first.second);
+ aSectionToPointActualCoords.push_back(std::make_pair(anIt->first, anActualCoords));
+ }
+
+ if (myPRedo->init(CurveCreator_Operation::SetCoordinates, aSectionToPointActualCoords)) {
+ // Undo for SetCoordinates command.
+ setNbUndos(1);
+ isOK = myPUndo[0].init(CurveCreator_Operation::SetCoordinates,
+ theOldParamList);
+ }
+
+ if (!isOK) {
+ clear();
+ }
+ }
+
+ return isOK;
+}
+
//=======================================================================
// function: applyUndo
// purpose:
const int theIndex,
CurveCreator_Operation &theOperation) const
{
+ const std::string aName = theCurve->getSectionName(theIndex);
const CurveCreator::Coordinates &aPnts = theCurve->getPoints(theIndex);
const CurveCreator::SectionType aType = theCurve->getSectionType(theIndex);
const bool isClosed = theCurve->isClosed(theIndex);
bool isOK = theOperation.init(CurveCreator_Operation::AddSection,
- aPnts, aType, isClosed);
+ aName, aPnts, aType, isClosed);
return isOK;
}