From: nds Date: Wed, 18 Dec 2013 08:25:44 +0000 (+0000) Subject: refs #249 - Undo after Join selected sections operation works not properly X-Git-Tag: BR_hydro_v_0_6~44 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=def20bd12acaadb7d345ef3635a23eb8e4e4d086;p=modules%2Fhydro.git refs #249 - Undo after Join selected sections operation works not properly The points manipulation remove from the sections tree view --- diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.cxx b/src/HYDROCurveCreator/CurveCreator_Curve.cxx index 438b4215..69287f1f 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.cxx @@ -375,7 +375,7 @@ bool CurveCreator_Curve::clear() startOperation(); // Set the difference. if (addEmptyDiff()) { - myListDiffs.back().init(this, CurveCreator_Operation::Clear); + myListDiffs.back().init(this); } res = clearInternal(); finishOperation(); @@ -878,12 +878,12 @@ bool CurveCreator_Curve::removePoint( const int theISection, const int theIPnt ) 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; diff --git a/src/HYDROCurveCreator/CurveCreator_Diff.cxx b/src/HYDROCurveCreator/CurveCreator_Diff.cxx index 797cc68b..dbc63342 100644 --- a/src/HYDROCurveCreator/CurveCreator_Diff.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Diff.cxx @@ -49,9 +49,9 @@ CurveCreator_Diff::~CurveCreator_Diff() // 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) { @@ -60,36 +60,18 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, // 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]); } } } @@ -226,73 +208,6 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve, 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: diff --git a/src/HYDROCurveCreator/CurveCreator_Diff.hxx b/src/HYDROCurveCreator/CurveCreator_Diff.hxx index fb69edf4..1a398d3b 100644 --- a/src/HYDROCurveCreator/CurveCreator_Diff.hxx +++ b/src/HYDROCurveCreator/CurveCreator_Diff.hxx @@ -56,11 +56,9 @@ public: * parameters. It is applicable to the following operations: * */ - 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 @@ -88,32 +86,6 @@ public: 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: - * - */ - 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: - * - */ - 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. diff --git a/src/HYDROCurveCreator/CurveCreator_Operation.cxx b/src/HYDROCurveCreator/CurveCreator_Operation.cxx index 083e3323..bd9cab5d 100644 --- a/src/HYDROCurveCreator/CurveCreator_Operation.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Operation.cxx @@ -60,8 +60,7 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType) { bool isOK = false; - if (theType == CurveCreator_Operation::Clear || - theType == CurveCreator_Operation::Join) { + if (theType == CurveCreator_Operation::Clear) { clear(); myType = theType; isOK = true; @@ -103,7 +102,6 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType, 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)); @@ -116,30 +114,6 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType, 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: diff --git a/src/HYDROCurveCreator/CurveCreator_Operation.hxx b/src/HYDROCurveCreator/CurveCreator_Operation.hxx index 1b83cd51..7650cdf5 100644 --- a/src/HYDROCurveCreator/CurveCreator_Operation.hxx +++ b/src/HYDROCurveCreator/CurveCreator_Operation.hxx @@ -77,7 +77,6 @@ public: * It is applicable to the following operations: * * @return true in case of success; false otherwise. */ @@ -119,17 +118,6 @@ public: 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: - * - * @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.