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