1 // Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: CurveCreator_Diff.hxx
21 // Author: Sergey KHROMOV
23 #ifndef _CurveCreator_Diff_HeaderFile
24 #define _CurveCreator_Diff_HeaderFile
26 #include "CurveCreator_Operation.hxx"
28 class CurveCreator_Curve;
32 * This is the support class for store/retrieve differences of undo/redo
33 * operations. To fill the difference it is necessary to create it with
34 * an appropriate type and to call the method initialize with required
37 class CurveCreator_Diff
55 * This method initializes the difference with an operation without
56 * parameters. It is applicable to the following operations:
59 * <LI>Join (without arguments)</LI>
62 bool init(const CurveCreator_Curve *theCurve,
63 const CurveCreator_Operation::Type theType);
66 * This method initializes the difference with an operation with one integer
67 * parameter. It is applicable to the following operations:
69 * <LI>RemoveSection</LI>
72 bool init(const CurveCreator_Curve *theCurve,
73 const CurveCreator_Operation::Type theType,
74 const int theIntParam);
77 * This method initializes the difference with an operation with two integer
78 * parameters. It is applicable to the following operations:
82 * <LI>MoveSection</LI>
83 * <LI>Join (with 2 int arguments)</LI>
86 bool init(const CurveCreator_Curve *theCurve,
87 const CurveCreator_Operation::Type theType,
88 const int theIntParam1,
89 const int theIntParam2);
92 * This method initializes the difference with an operation with three
93 * integer parameters. It is applicable to the following operations:
95 * <LI>RemovePoints</LI>
98 bool init(const CurveCreator_Curve *theCurve,
99 const CurveCreator_Operation::Type theType,
100 const int theIntParam1,
101 const int theIntParam2,
102 const int theIntParam3);
105 * This method initializes the difference with an operation with one
106 * CurveCreator::Coordinates parameter and one integer parameter.
107 * It is applicable to the following operations:
112 bool init(const CurveCreator_Curve *theCurve,
113 const CurveCreator_Operation::Type theType,
114 const CurveCreator::Coordinates &theCoords,
115 const int theIntParam);
118 * This method initializes the difference with an operation with one
119 * Name, one CurveCreator::Coordinates parameter and two integer parameters.
120 * It is applicable to the following operations:
122 * <LI>AddSection</LI>
125 bool init(const CurveCreator_Curve *theCurve,
126 const CurveCreator_Operation::Type theType,
127 const std::string& theName,
128 const CurveCreator::Coordinates &theCoords,
129 const int theIntParam1,
130 const int theIntParam2);
133 * This method initializes the difference with an operation with one
134 * string and one integer parameters.
135 * It is applicable to the following operations:
137 * <LI>RenameSection</LI>
140 bool init(const CurveCreator_Curve *theCurve,
141 const CurveCreator_Operation::Type theType,
142 const std::string &theName,
143 const int theIntParam1 );
146 * This method initializes the difference with an operation with
147 * list of pairs of integer parameters.
148 * It is applicable to the following operations:
150 * <LI>RemovePoints</LI>
153 bool init(const CurveCreator_Curve *theCurve,
154 const CurveCreator_Operation::Type theType,
155 const CurveCreator_ICurve::SectionToPointList &theParamList);
158 * This method initializes the difference with an operation with
159 * list of pairs of integer parameters with point coordinates.
160 * It is applicable to the following operations:
162 * <LI>RemovePoints</LI>
165 bool init(const CurveCreator_Curve *theCurve,
166 const CurveCreator_Operation::Type theType,
167 const CurveCreator_ICurve::SectionToPointCoordsList &theParamList);
170 * This method initializes the difference with an operation with
171 * list of pairs of integer parameters with point coordinates.
172 * \param theCurve the modified curve
173 * \param theOldParamList the old parameters (to be saved for undo)
175 bool init(const CurveCreator_Curve *theCurve,
176 const CurveCreator_ICurve::SectionToPointCoordsList &theOldParamList);
179 * This method applies undo operation to theCurve.
181 void applyUndo(CurveCreator_Curve *theCurve);
184 * This method applies redo operation to theCurve.
186 void applyRedo(CurveCreator_Curve *theCurve);
191 * This method clears initialized data pointers.
196 * This method sets the number of undos and allocates the required
199 void setNbUndos(const int theNbUndos);
202 * This method returns the section index. It returns theIndex if it is
203 * a real index and the last section's index if theIndex is equal to -1.
205 int getSectionIndex(const CurveCreator_Curve *theCurve,
206 const int theIndex) const;
209 * Convert theIndex'th section of theCurve into AddSection command
210 * and store it in theOperation. Returns true in case of success and
213 bool addSectionToUndo(const CurveCreator_Curve *theCurve,
215 CurveCreator_Operation &theOperation) const;
218 * Construct undos for SetType and SetClosed operations. Note: the
219 * algorithm is optimized taking into account that there are only 2 types
220 * and 2 values of isClosed flag. If the number of types is increased,
221 * this algorithm should be re-implemented.
223 bool setTypeOrClosedToUndo(const CurveCreator_Curve *theCurve,
224 const CurveCreator_Operation::Type theType,
225 const int theIntParam1,
226 const int theIntParam2);
231 CurveCreator_Operation *myPUndo;
232 CurveCreator_Operation *myPRedo;