Salome HOME
a74ac19ca10bb2a10cbfe785047d3c488d5a76ae
[modules/geom.git] / src / CurveCreator / CurveCreator_Operation.hxx
1 // Copyright (C) 2013-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File:        CurveCreator_Operation.hxx
21 // Author:      Sergey KHROMOV
22
23 #ifndef _CurveCreator_Operation_HeaderFile
24 #define _CurveCreator_Operation_HeaderFile
25
26 #include "CurveCreator.hxx"
27
28 #include <string>
29
30 class CurveCreator_Curve;
31
32
33 /**
34  * This is the support class that describes a modification operation that
35  * can be applied to CurveCreator_Curve.
36  */
37 class CurveCreator_Operation
38 {
39
40 public:
41
42   /**
43    * This is a type of CurveCreator_Curve modification operation.
44    */
45   enum Type
46   {
47     Unknown = 0,    //!< Unknown method.
48     AddPoints,      //!< Method CurveCreator_Curve::addPoints
49     RemovePoints,   //!< Method CurveCreator_Curve::removePoints
50     InsertPoints,   //!< Method CurveCreator_Curve::insertPoints
51     SetType,        //!< Method CurveCreator_Curve::setType
52     Clear,          //!< Method CurveCreator_Curve::clear
53     SetCoordinates, //!< Method CurveCreator_Curve::setCoordinates
54     SetClosed,      //!< Method CurveCreator_Curve::setClosed
55     MoveSection,    //!< Method CurveCreator_Curve::moveSection
56     Join,           //!< Method CurveCreator_Curve::join
57     AddSection,     //!< Method CurveCreator_Curve::addSection
58     RemoveSection,   //!< Method CurveCreator_Curve::removeSection
59     RenameSection   //!< Method CurveCreator_Curve::renameSection
60   };
61
62   /**
63    * Empty constructor.
64    */
65   CurveCreator_Operation();
66
67   /**
68    * Destructor.
69    */
70   ~CurveCreator_Operation();
71
72   /**
73    * This method initializes the object with an operation without parameters.
74    * It is applicable to the following operations:
75    * <UL>
76    *   <LI>Clear</LI>
77    *   <LI>Join (without arguments)</LI>
78    * </UL>
79    * @return true in case of success; false otherwise.
80    */
81   bool init(const Type theType);
82
83   /**
84    * This method initializes the object with an operation with one integer
85    * parameter. It is applicable to the following operations:
86    * <UL>
87    *   <LI>RemoveSection</LI>
88    * </UL>
89    * @return true in case of success; false otherwise.
90    */
91   bool init(const Type theType, const int theIntParam);
92
93   /**
94    * This method initializes the object with an operation with two integer
95    * parameters. It is applicable to the following operations:
96    * <UL>
97    *   <LI>SetType</LI>
98    *   <LI>SetClosed</LI>
99    *   <LI>MoveSection</LI>
100    *   <LI>Join (with 2 int arguments)</LI>
101    * </UL>
102    * @return true in case of success; false otherwise.
103    */
104   bool init(const Type theType, const int theIntParam1,
105             const int theIntParam2);
106
107   /**
108    * This method initializes the object with an operation with three integer
109    * parameters. It is applicable to the following operations:
110    * <UL>
111    *   <LI>RemovePoints</LI>
112    * </UL>
113    * @return true in case of success; false otherwise.
114    */
115   bool init(const Type theType, const int theIntParam1,
116             const int theIntParam2, const int theIntParam3);
117
118   /**
119    * This method initializes the object with an operation with one
120    * CurveCreator::Coordinates parameter and one integer parameter.
121    * It is applicable to the following operations:
122    * <UL>
123    *   <LI>AddPoints</LI>
124    * </UL>
125    * @return true in case of success; false otherwise.
126    */
127   bool init(const Type theType, const CurveCreator::Coordinates &theCoords,
128             const int theIntParam);
129
130   /**
131    * This method initializes the object with an operation with one
132    * CurveCreator::Coordinates parameter and two integer parameters.
133    * It is applicable to the following operations:
134    * <UL>
135    *   <LI>AddSection</LI>
136    *   <LI>InsertPoints</LI>
137    *   <LI>SetCoordinates</LI>
138    * </UL>
139    * @return true in case of success; false otherwise.
140    */
141   bool init(const Type theType, const CurveCreator::Coordinates &theCoords,
142             const int theIntParam1, const int theIntParam2);
143
144   /**
145    * This method initializes the object with an operation with one
146    * string, one CurveCreator::Coordinates parameter and two integer parameters.
147    * It is applicable to the following operations:
148    * <UL>
149    *   <LI>AddSection</LI>
150    *   <LI>InsertPoints</LI>
151    *   <LI>SetCoordinates</LI>
152    * </UL>
153    * @return true in case of success; false otherwise.
154    */
155   bool init(const CurveCreator_Operation::Type theType,
156             const std::string& theName,
157             const CurveCreator::Coordinates &theCoords,
158             const int theIntParam1,
159             const int theIntParam2);
160
161
162   /**
163    * This method initializes the object with an operation with one
164    * string parameter and one integer.
165    * It is applicable to the following operations:
166    * <UL>
167    *   <LI>RenameSection</LI>
168    * </UL>
169    * @return true in case of success; false otherwise.
170    */
171   bool init(const CurveCreator_Operation::Type theType,
172                                     const std::string &theName,
173                                     const int theIntParam1 );
174
175   /**
176    * This method applies the current operation to theCurve.
177    */
178   void apply(CurveCreator_Curve *theCurve);
179
180 private:
181
182   /**
183    * This method allocates required memory for the operation data.
184    * Returns myPData for convenience purpose.
185    */
186   void *allocate(const size_t theSize);
187
188   /**
189    * This method clears initialized data pointers.
190    */
191   void clear();
192
193   /**
194    * This method returns the coordinates read from thePInt.
195    */
196   void getCoords(int *thePInt, CurveCreator::Coordinates &theCoords) const;
197
198 private:
199
200   Type  myType;
201   void *myPData;
202
203 };
204
205 #endif