1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: CurveCreator_Diff.hxx
24 // Created: Wed Jun 26 10:58:46 2013
25 // Author: Sergey KHROMOV
28 #ifndef _CurveCreator_Diff_HeaderFile
29 #define _CurveCreator_Diff_HeaderFile
32 #include <CurveCreator_Operation.hxx>
34 class CurveCreator_Curve;
38 * This is the support class for store/retrieve differences of undo/redo
39 * operations. To fill the difference it is necessary to create it with
40 * an appropriate type and to call the method initialize with required
43 class CurveCreator_Diff
61 * This method initializes the difference with an operation without
62 * parameters. It is applicable to the following operations:
65 * <LI>Join (without arguments)</LI>
68 bool init(const CurveCreator_Curve *theCurve,
69 const CurveCreator_Operation::Type theType);
72 * This method initializes the difference with an operation with one integer
73 * parameter. It is applicable to the following operations:
75 * <LI>RemoveSection</LI>
78 bool init(const CurveCreator_Curve *theCurve,
79 const CurveCreator_Operation::Type theType,
80 const int theIntParam);
83 * This method initializes the difference with an operation with two integer
84 * parameters. It is applicable to the following operations:
88 * <LI>MoveSection</LI>
89 * <LI>Join (with 2 int arguments)</LI>
92 bool init(const CurveCreator_Curve *theCurve,
93 const CurveCreator_Operation::Type theType,
94 const int theIntParam1,
95 const int theIntParam2);
98 * This method initializes the difference with an operation with three
99 * integer parameters. It is applicable to the following operations:
101 * <LI>RemovePoints</LI>
104 bool init(const CurveCreator_Curve *theCurve,
105 const CurveCreator_Operation::Type theType,
106 const int theIntParam1,
107 const int theIntParam2,
108 const int theIntParam3);
111 * This method initializes the difference with an operation with one
112 * CurveCreator::Coordinates parameter and one integer parameter.
113 * It is applicable to the following operations:
118 bool init(const CurveCreator_Curve *theCurve,
119 const CurveCreator_Operation::Type theType,
120 const CurveCreator::Coordinates &theCoords,
121 const int theIntParam);
124 * This method initializes the difference with an operation with one
125 * CurveCreator::Coordinates parameter and two integer parameters.
126 * It is applicable to the following operations:
128 * <LI>AddSection</LI>
129 * <LI>InsertPoints</LI>
130 * <LI>SetCoordinates</LI>
133 bool init(const CurveCreator_Curve *theCurve,
134 const CurveCreator_Operation::Type theType,
135 const CurveCreator::Coordinates &theCoords,
136 const int theIntParam1,
137 const int theIntParam2);
140 * This method applies undo operation to theCurve.
142 void applyUndo(CurveCreator_Curve *theCurve);
145 * This method applies redo operation to theCurve.
147 void applyRedo(CurveCreator_Curve *theCurve);
152 * This method clears initialized data pointers.
157 * This method sets the number of undos and allocates the required
160 void setNbUndos(const int theNbUndos);
163 * This method returns the section index. It returns theIndex if it is
164 * a real index and the last section's index if theIndex is equal to -1.
166 int getSectionIndex(const CurveCreator_Curve *theCurve,
167 const int theIndex) const;
170 * Convert theIndex'th section of theCurve into AddSection command
171 * and store it in theOperation. Returns true in case of success and
174 bool addSectionToUndo(const CurveCreator_Curve *theCurve,
176 CurveCreator_Operation &theOperation) const;
179 * Construct undos for SetType and SetClosed operations. Note: the
180 * algorithm is optimized taking into account that there are only 2 types
181 * and 2 values of isClosed flag. If the number of types is increased,
182 * this algorithm should be re-implemented.
184 bool setTypeOrClosedToUndo(const CurveCreator_Curve *theCurve,
185 const CurveCreator_Operation::Type theType,
186 const int theIntParam1,
187 const int theIntParam2);
192 CurveCreator_Operation *myPUndo;
193 CurveCreator_Operation *myPRedo;