This is the support class for store/retrieve differences of undo/redo operations. More...
#include <CurveCreator_Diff.hxx>
Public Member Functions | |
CurveCreator_Diff () | |
Constructor. More... | |
~CurveCreator_Diff () | |
Destructor. More... | |
bool | init (const CurveCreator_Curve *theCurve) |
This method initializes the difference with an operation without parameters. More... | |
bool | init (const CurveCreator_Curve *theCurve, const CurveCreator_Operation::Type theType, const int theIntParam) |
This method initializes the difference with an operation with one integer parameter. More... | |
bool | init (const CurveCreator_Curve *theCurve, const CurveCreator_Operation::Type theType, const int theIntParam1, const int theIntParam2) |
This method initializes the difference with an operation with two integer parameters. More... | |
bool | init (const CurveCreator_Curve *theCurve, const CurveCreator_Operation::Type theType, const std::list< int > &theParams) |
This method initializes the difference with an operation with two integer parameters. More... | |
bool | init (const CurveCreator_Curve *theCurve, const CurveCreator_Operation::Type theType, const std::string &theName, const CurveCreator::Coordinates &theCoords, const int theIntParam1, const int theIntParam2) |
This method initializes the difference with an operation with one Name, one CurveCreator::Coordinates parameter and two integer parameters. More... | |
bool | init (const CurveCreator_Curve *theCurve, const CurveCreator_Operation::Type theType, const std::string &theName, const int theIntParam1) |
This method initializes the difference with an operation with one string and one integer parameters. More... | |
bool | init (const CurveCreator_Curve *theCurve, const CurveCreator_Operation::Type theType, const CurveCreator_ICurve::SectionToPointList &theParamList) |
This method initializes the difference with an operation with list of pairs of integer parameters. More... | |
bool | init (const CurveCreator_Curve *theCurve, const CurveCreator_Operation::Type theType, const CurveCreator_ICurve::SectionToPointCoordsList &theParamList) |
This method initializes the difference with an operation with list of pairs of integer parameters with point coordinates. More... | |
bool | init (const CurveCreator_Curve *theCurve, const CurveCreator_ICurve::SectionToPointCoordsList &theOldParamList) |
This method initializes the difference with an operation with list of pairs of integer parameters with point coordinates. More... | |
void | applyUndo (CurveCreator_Curve *theCurve) |
This method applies undo operation to theCurve. More... | |
void | applyRedo (CurveCreator_Curve *theCurve) |
This method applies redo operation to theCurve. More... | |
Private Member Functions | |
void | clear () |
This method clears initialized data pointers. More... | |
void | setNbUndos (const int theNbUndos) |
This method sets the number of undos and allocates the required space for myPUndo. More... | |
int | getSectionIndex (const CurveCreator_Curve *theCurve, const int theIndex) const |
This method returns the section index. More... | |
bool | addSectionToUndo (const CurveCreator_Curve *theCurve, const int theIndex, CurveCreator_Operation &theOperation) const |
Convert theIndex'th section of theCurve into AddSection command and store it in theOperation. More... | |
bool | setTypeOrClosedToUndo (const CurveCreator_Curve *theCurve, const CurveCreator_Operation::Type theType, const int theIntParam1, const int theIntParam2) |
Construct undos for SetType and SetClosed operations. More... | |
Private Attributes | |
int | myNbUndos |
CurveCreator_Operation * | myPUndo |
CurveCreator_Operation * | myPRedo |
To fill the difference it is necessary to create it with an appropriate type and to call the method initialize with required parameters.
CurveCreator_Diff::CurveCreator_Diff | ( | ) |
CurveCreator_Diff::~CurveCreator_Diff | ( | ) |
References clear().
|
private |
Returns true in case of success and false otherwise.
References CurveCreator_Operation::AddSection, CurveCreator_Curve::getPoints(), CurveCreator_Curve::getSectionName(), CurveCreator_Curve::getSectionType(), CurveCreator_Operation::init(), and CurveCreator_Curve::isClosed().
void CurveCreator_Diff::applyRedo | ( | CurveCreator_Curve * | theCurve | ) |
References CurveCreator_Operation::apply(), myPRedo, and NULL.
void CurveCreator_Diff::applyUndo | ( | CurveCreator_Curve * | theCurve | ) |
References CurveCreator_Operation::apply(), myNbUndos, myPUndo, and NULL.
|
private |
It returns theIndex if it is a real index and the last section's index if theIndex is equal to -1.
References CurveCreator_Curve::getNbSections().
bool CurveCreator_Diff::init | ( | const CurveCreator_Curve * | theCurve | ) |
It is applicable to the following operations:
References addSectionToUndo(), CurveCreator_Operation::Clear, clear(), CurveCreator_Curve::getNbSections(), CurveCreator_Operation::init(), myPRedo, myPUndo, NULL, and setNbUndos().
bool CurveCreator_Diff::init | ( | const CurveCreator_Curve * | theCurve, |
const CurveCreator_Operation::Type | theType, | ||
const int | theIntParam | ||
) |
It is applicable to the following operations:
References addSectionToUndo(), clear(), CurveCreator_Curve::getNbSections(), CurveCreator_Operation::init(), CurveCreator_Operation::MoveSection, myPRedo, myPUndo, NULL, and setNbUndos().
bool CurveCreator_Diff::init | ( | const CurveCreator_Curve * | theCurve, |
const CurveCreator_Operation::Type | theType, | ||
const int | theIntParam1, | ||
const int | theIntParam2 | ||
) |
It is applicable to the following operations:
References clear(), CurveCreator_Operation::init(), CurveCreator_Operation::MoveSection, myPRedo, myPUndo, NULL, CurveCreator_Operation::SetClosed, setNbUndos(), CurveCreator_Operation::SetType, and setTypeOrClosedToUndo().
bool CurveCreator_Diff::init | ( | const CurveCreator_Curve * | theCurve, |
const CurveCreator_Operation::Type | theType, | ||
const std::list< int > & | theParams | ||
) |
It is applicable to the following operations:
References addSectionToUndo(), clear(), CurveCreator_Curve::getNbPoints(), CurveCreator_Operation::init(), CurveCreator_Operation::Join, CurveCreator_Operation::MoveSection, myPRedo, myPUndo, NULL, CurveCreator_Operation::RemovePoints, and setNbUndos().
bool CurveCreator_Diff::init | ( | const CurveCreator_Curve * | theCurve, |
const CurveCreator_Operation::Type | theType, | ||
const std::string & | theName, | ||
const CurveCreator::Coordinates & | theCoords, | ||
const int | theIntParam1, | ||
const int | theIntParam2 | ||
) |
It is applicable to the following operations:
References CurveCreator_Operation::AddSection, clear(), CurveCreator_Operation::init(), myPRedo, myPUndo, NULL, CurveCreator_Operation::RemoveSection, and setNbUndos().
bool CurveCreator_Diff::init | ( | const CurveCreator_Curve * | theCurve, |
const CurveCreator_Operation::Type | theType, | ||
const std::string & | theName, | ||
const int | theIntParam1 | ||
) |
It is applicable to the following operations:
References clear(), CurveCreator_Curve::getSectionName(), CurveCreator_Operation::init(), myPRedo, myPUndo, CurveCreator_Operation::RenameSection, and setNbUndos().
bool CurveCreator_Diff::init | ( | const CurveCreator_Curve * | theCurve, |
const CurveCreator_Operation::Type | theType, | ||
const CurveCreator_ICurve::SectionToPointList & | theParamList | ||
) |
It is applicable to the following operations:
References clear(), CurveCreator_Curve::getDimension(), CurveCreator_Curve::getPoints(), CurveCreator_Operation::init(), CurveCreator_Operation::InsertPoints, myPRedo, myPUndo, NULL, CurveCreator_Operation::RemovePoints, and setNbUndos().
bool CurveCreator_Diff::init | ( | const CurveCreator_Curve * | theCurve, |
const CurveCreator_Operation::Type | theType, | ||
const CurveCreator_ICurve::SectionToPointCoordsList & | theParamList | ||
) |
It is applicable to the following operations:
References clear(), CurveCreator_Curve::getPoint(), CurveCreator_Operation::init(), CurveCreator_Operation::InsertPoints, myPRedo, myPUndo, NULL, CurveCreator_Operation::RemovePoints, CurveCreator_Operation::SetCoordinates, and setNbUndos().
bool CurveCreator_Diff::init | ( | const CurveCreator_Curve * | theCurve, |
const CurveCreator_ICurve::SectionToPointCoordsList & | theOldParamList | ||
) |
theCurve | the modified curve |
theOldParamList | the old parameters (to be saved for undo) |
References clear(), CurveCreator_Curve::getPoint(), CurveCreator_Operation::init(), myPRedo, myPUndo, NULL, CurveCreator_Operation::SetCoordinates, and setNbUndos().
|
private |
|
private |
Note: the algorithm is optimized taking into account that there are only 2 types and 2 values of isClosed flag. If the number of types is increased, this algorithm should be re-implemented.
References anIter(), CurveCreator_Curve::getNbSections(), CurveCreator_Curve::getSectionType(), CurveCreator_Curve::isClosed(), and CurveCreator_Operation::SetType.
|
private |
|
private |
|
private |