Salome HOME
3c174b289be7effcab89557a7b97c911ddee6d31
[modules/geom.git] / src / CurveCreator / CurveCreator_Operation.hxx
1 // Copyright (C) 2013-2023  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 #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     SetColorSection //!< Method CurveCreator_Curve::setColorSection
64   };
65
66   /**
67    * Empty constructor.
68    */
69   CurveCreator_Operation();
70
71   /**
72    * Destructor.
73    */
74   ~CurveCreator_Operation();
75
76   /**
77    * This method initializes the object with an operation without parameters.
78    * It is applicable to the following operations:
79    * <UL>
80    *   <LI>Clear</LI>
81    * </UL>
82    * @return true in case of success; false otherwise.
83    */
84   bool init(const Type theType);
85
86   /**
87    * This method initializes the object with an operation with one integer
88    * parameter. It is applicable to the following operations:
89    * <UL>
90    *   <LI>RemoveSection</LI>
91    * </UL>
92    * @return true in case of success; false otherwise.
93    */
94   bool init(const Type theType, const int theIntParam);
95
96   /**
97    * This method initializes the object with an operation with two integer
98    * parameters. It is applicable to the following operations:
99    * <UL>
100    *   <LI>SetType</LI>
101    *   <LI>SetClosed</LI>
102    *   <LI>MoveSection</LI>
103    *   <LI>Join (with 2 int arguments)</LI>
104    * </UL>
105    * @return true in case of success; false otherwise.
106    */
107   bool init(const Type theType, const int theIntParam1,
108             const int theIntParam2);
109
110   /**
111    * This method initializes the object with an operation with 4 integer
112    * parameter (1 as first param + 3 as interger array)
113    */
114   bool init(const Type theType, const int theIntParam1,
115             const int theIntParam2[3]);
116
117
118   /**
119    * This method initializes the object with an operation with two integer
120    * parameters. It is applicable to the following operations:
121    * <UL>
122    *   <LI>Join (with a list of int arguments)</LI>
123    * </UL>
124    * @return true in case of success; false otherwise.
125    */
126   bool init(const Type theType, const std::list<int> theParamList);
127
128   /**
129    * This method initializes the object with an operation with
130    * list of pairs of integer parameters.
131    * It is applicable to the following operations:
132    * <UL>
133    *   <LI>RemovePoints</LI>
134    * </UL>
135    * @return true in case of success; false otherwise.
136    */
137   bool init(const Type theType,
138     const CurveCreator_ICurve::SectionToPointList &theParamList1);
139
140   /**
141    * This method initializes the object with an operation with one
142    * CurveCreator::Coordinates parameter and one integer parameter.
143    * It is applicable to the following operations:
144    * <UL>
145    *   <LI>AddPoints</LI>
146    * </UL>
147    * @return true in case of success; false otherwise.
148    */
149   bool init(const Type theType, const CurveCreator::Coordinates &theCoords,
150             const int theIntParam);
151
152   /**
153    * This method initializes the object with an operation with
154    * list of pairs of integer parameters and CurveCreator::Coordinates parameters.
155    * It is applicable to the following operations:
156    * <UL>
157    *   <LI>InsertPoints</LI>
158    * </UL>
159    * @return true in case of success; false otherwise.
160    */
161   bool init(const Type theType,
162             const CurveCreator_ICurve::SectionToPointCoordsList &theParamList1);
163
164   /**
165    * This method initializes the object with an operation with one
166    * string, one CurveCreator::Coordinates parameter and two integer parameters.
167    * It is applicable to the following operations:
168    * <UL>
169    *   <LI>AddSection</LI>
170    *   <LI>InsertPoints</LI>
171    *   <LI>SetCoordinates</LI>
172    * </UL>
173    * @return true in case of success; false otherwise.
174    */
175   bool init(const CurveCreator_Operation::Type theType,
176             const std::string& theName,
177             const CurveCreator::Coordinates &theCoords,
178             const int theIntParam1,
179             const int theIntParam2);
180
181
182   /**
183    * This method initializes the object with an operation with one
184    * string parameter and one integer.
185    * It is applicable to the following operations:
186    * <UL>
187    *   <LI>RenameSection</LI>
188    * </UL>
189    * @return true in case of success; false otherwise.
190    */
191   bool init(const CurveCreator_Operation::Type theType,
192                                     const std::string &theName,
193                                     const int theIntParam1 );
194
195   /**
196    * This method applies the current operation to theCurve.
197    */
198   void apply(CurveCreator_Curve *theCurve);
199
200 private:
201
202   /**
203    * This method allocates required memory for the operation data.
204    * Returns myPData for convenience purpose.
205    */
206   void *allocate(const size_t theSize);
207
208   /**
209    * This method clears initialized data pointers.
210    */
211   void clear();
212
213   /**
214    * This method returns the coordinates read from thePInt.
215    */
216   void getCoords(int *thePInt, CurveCreator::Coordinates &theCoords) const;
217
218 private:
219
220   Type  myType;
221   void *myPData;
222
223 };
224
225 #endif