startOperation();
// Set the difference.
if (addEmptyDiff()) {
- myListDiffs.back().init(this, CurveCreator_Operation::Clear);
+ myListDiffs.back().init(this);
}
res = clearInternal();
finishOperation();
bool res = false;
// Set the difference.
startOperation();
+ SectionToPointList aListOfSectionsToPoints;
+ aListOfSectionsToPoints.push_back(std::make_pair(theISection, theIPnt));
if (addEmptyDiff()) {
myListDiffs.back().init(this, CurveCreator_Operation::RemovePoints,
- theISection, theIPnt);
+ aListOfSectionsToPoints);
}
- SectionToPointList aListOfSectionsToPoints;
- aListOfSectionsToPoints.push_back(std::make_pair(theISection, theIPnt));
res = removePointsInternal( aListOfSectionsToPoints );
finishOperation();
return res;
// function: init
// purpose:
//=======================================================================
-bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
- const CurveCreator_Operation::Type theType)
+bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve)
{
+ CurveCreator_Operation::Type aType = CurveCreator_Operation::Clear;
bool isOK = false;
if (theCurve != NULL) {
// Set redo.
myPRedo = new CurveCreator_Operation;
- if (myPRedo->init(theType)) {
+ if (myPRedo->init(aType)) {
isOK = true;
const int aNbSections = theCurve->getNbSections();
- if (theType == CurveCreator_Operation::Clear) {
- // Construct undo for Clear command.
- if (aNbSections > 0) {
- setNbUndos(aNbSections);
+ // Construct undo for Clear command.
+ if (aNbSections > 0) {
+ setNbUndos(aNbSections);
- for (int i = 0; i < aNbSections && isOK; i++) {
- // Add AddSection command.
- isOK = addSectionToUndo(theCurve, i, myPUndo[i]);
- }
- }
- } else { // theType == CurveCreator_Operation::Join
- // Construct undo for Join command.
- if (aNbSections > 1) {
- // Add the RemovePoints command to remove points of
- // the second section fron the first one.
- const int aNbPoints = theCurve->getNbPoints(0);
-
- setNbUndos(aNbSections);
- isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints,
- 0, aNbPoints, -1);
-
- for (int i = 1; i < aNbSections && isOK; i++) {
- // Add AddSection command.
- isOK = addSectionToUndo(theCurve, i, myPUndo[i]);
- }
+ for (int i = 0; i < aNbSections && isOK; i++) {
+ // Add AddSection command.
+ isOK = addSectionToUndo(theCurve, i, myPUndo[i]);
}
}
}
return isOK;
}
-//=======================================================================
-// function: init
-// purpose:
-//=======================================================================
-bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
- const CurveCreator_Operation::Type theType,
- const int theIntParam1,
- const int theIntParam2,
- const int theIntParam3)
-{
- bool isOK = false;
-
- if (theCurve != NULL) {
- clear();
-
- // Set redo.
- myPRedo = new CurveCreator_Operation;
-
- if (myPRedo->init(theType, theIntParam1, theIntParam2, theIntParam3)) {
- }
-
- if (!isOK) {
- clear();
- }
- }
-
- return isOK;
-}
-
-//=======================================================================
-// function: init
-// purpose:
-//=======================================================================
-bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
- const CurveCreator_Operation::Type theType,
- const CurveCreator::Coordinates &theCoords,
- const int theIntParam)
-{
- bool isOK = false;
-
- if (theCurve != NULL) {
- clear();
-
- // Set redo.
- myPRedo = new CurveCreator_Operation;
-
- if (myPRedo->init(theType, theCoords, theIntParam)) {
- // Construct undo for AddPoints command.
- const int aSectionInd = getSectionIndex(theCurve, theIntParam);
- const CurveCreator::Dimension aDim = theCurve->getDimension();
- const CurveCreator::Coordinates &aPoints =
- theCurve->getPoints(aSectionInd);
- const int aNbPoints = (aPoints.size()/aDim);
-
- setNbUndos(1);
- isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints,
- aSectionInd, aNbPoints, -1);
- }
-
- if (!isOK) {
- clear();
- }
- }
-
- return isOK;
-}
-
//=======================================================================
// function: init
// purpose:
* parameters. It is applicable to the following operations:
* <UL>
* <LI>Clear</LI>
- * <LI>Join (without arguments)</LI>
* </UL>
*/
- bool init(const CurveCreator_Curve *theCurve,
- const CurveCreator_Operation::Type theType);
+ bool init(const CurveCreator_Curve *theCurve);
/**
* This method initializes the difference with an operation with one integer
const int theIntParam1,
const int theIntParam2);
- /**
- * This method initializes the difference with an operation with three
- * integer parameters. It is applicable to the following operations:
- * <UL>
- * <LI>RemovePoints</LI>
- * </UL>
- */
- bool init(const CurveCreator_Curve *theCurve,
- const CurveCreator_Operation::Type theType,
- const int theIntParam1,
- const int theIntParam2,
- const int theIntParam3);
-
- /**
- * This method initializes the difference with an operation with one
- * CurveCreator::Coordinates parameter and one integer parameter.
- * It is applicable to the following operations:
- * <UL>
- * <LI>AddPoints</LI>
- * </UL>
- */
- bool init(const CurveCreator_Curve *theCurve,
- const CurveCreator_Operation::Type theType,
- const CurveCreator::Coordinates &theCoords,
- const int theIntParam);
-
/**
* This method initializes the difference with an operation with one
* Name, one CurveCreator::Coordinates parameter and two integer parameters.
{
bool isOK = false;
- if (theType == CurveCreator_Operation::Clear ||
- theType == CurveCreator_Operation::Join) {
+ if (theType == CurveCreator_Operation::Clear) {
clear();
myType = theType;
isOK = true;
if (theType == CurveCreator_Operation::SetType ||
theType == CurveCreator_Operation::SetClosed ||
theType == CurveCreator_Operation::MoveSection ||
- theType == CurveCreator_Operation::RemovePoints ||
theType == CurveCreator_Operation::Join) {
int *pData = (int *)allocate(2*sizeof(int));
return isOK;
}
-//=======================================================================
-// function: Constructor
-// purpose:
-//=======================================================================
-bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
- const int theIntParam1,
- const int theIntParam2,
- const int theIntParam3)
-{
- bool isOK = false;
-
- if (theType == CurveCreator_Operation::RemovePoints) {
- int *pData = (int *)allocate(3*sizeof(int));
-
- pData[0] = theIntParam1;
- pData[1] = theIntParam2;
- pData[2] = theIntParam3;
- myType = theType;
- isOK = true;
- }
-
- return isOK;
-}
-
//=======================================================================
// function: Constructor
// purpose:
* It is applicable to the following operations:
* <UL>
* <LI>Clear</LI>
- * <LI>Join (without arguments)</LI>
* </UL>
* @return true in case of success; false otherwise.
*/
bool init(const Type theType,
const CurveCreator_ICurve::SectionToPointList &theParamList1);
- /**
- * This method initializes the object with an operation with three integer
- * parameters. It is applicable to the following operations:
- * <UL>
- * <LI>RemovePoints</LI>
- * </UL>
- * @return true in case of success; false otherwise.
- */
- bool init(const Type theType, const int theIntParam1,
- const int theIntParam2, const int theIntParam3);
-
/**
* This method initializes the object with an operation with one
* CurveCreator::Coordinates parameter and one integer parameter.