]> SALOME platform Git repositories - modules/geom.git/blob - src/CurveCreator/CurveCreator_Operation.hxx
Salome HOME
706f6b8c30ed9d28e20959a2fa3b3bffe0e671a3
[modules/geom.git] / src / CurveCreator / CurveCreator_Operation.hxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:        CurveCreator_Operation.hxx
24 // Created:     Wed Jun  26 13:06:51 2013
25 // Author:      Sergey KHROMOV
26 //
27
28 #ifndef _CurveCreator_Operation_HeaderFile
29 #define _CurveCreator_Operation_HeaderFile
30
31
32 #include <CurveCreator.hxx>
33
34 class CurveCreator_Curve;
35
36
37 /**
38  * This is the support class that describes a modification operation that
39  * can be applied to CurveCreator_Curve.
40  */
41 class CurveCreator_Operation
42 {
43
44 public:
45
46   /**
47    * This is a type of CurveCreator_Curve modification operation.
48    */
49   enum Type
50   {
51     Unknown = 0,    //!< Unknown method.
52     AddPoints,      //!< Method CurveCreator_Curve::addPoints
53     RemovePoints,   //!< Method CurveCreator_Curve::removePoints
54     InsertPoints,   //!< Method CurveCreator_Curve::insertPoints
55     SetType,        //!< Method CurveCreator_Curve::setType
56     Clear,          //!< Method CurveCreator_Curve::clear
57     SetCoordinates, //!< Method CurveCreator_Curve::setCoordinates
58     SetClosed,      //!< Method CurveCreator_Curve::setClosed
59     MoveSection,    //!< Method CurveCreator_Curve::moveSection
60     Join,           //!< Method CurveCreator_Curve::join
61     AddSection,     //!< Method CurveCreator_Curve::addSection
62     RemoveSection,   //!< Method CurveCreator_Curve::removeSection
63     RenameCurve     //!< Method CurveCreator_Curve::renameCurve
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    *   <LI>Join (without arguments)</LI>
82    * </UL>
83    * @return true in case of success; false otherwise.
84    */
85   bool init(const Type theType);
86
87   /**
88    * This method initializes the object with an operation with one integer
89    * parameter. It is applicable to the following operations:
90    * <UL>
91    *   <LI>RemoveSection</LI>
92    * </UL>
93    * @return true in case of success; false otherwise.
94    */
95   bool init(const Type theType, const int theIntParam);
96
97   /**
98    * This method initializes the object with an operation with two integer
99    * parameters. It is applicable to the following operations:
100    * <UL>
101    *   <LI>SetType</LI>
102    *   <LI>SetClosed</LI>
103    *   <LI>MoveSection</LI>
104    *   <LI>Join (with 2 int arguments)</LI>
105    * </UL>
106    * @return true in case of success; false otherwise.
107    */
108   bool init(const Type theType, const int theIntParam1,
109             const int theIntParam2);
110
111   /**
112    * This method initializes the object with an operation with three integer
113    * parameters. It is applicable to the following operations:
114    * <UL>
115    *   <LI>RemovePoints</LI>
116    * </UL>
117    * @return true in case of success; false otherwise.
118    */
119   bool init(const Type theType, const int theIntParam1,
120             const int theIntParam2, const int theIntParam3);
121
122   /**
123    * This method initializes the object with an operation with one
124    * CurveCreator::Coordinates parameter and one integer parameter.
125    * It is applicable to the following operations:
126    * <UL>
127    *   <LI>AddPoints</LI>
128    * </UL>
129    * @return true in case of success; false otherwise.
130    */
131   bool init(const Type theType, const CurveCreator::Coordinates &theCoords,
132             const int theIntParam);
133
134   /**
135    * This method initializes the object with an operation with one
136    * CurveCreator::Coordinates parameter and two integer parameters.
137    * It is applicable to the following operations:
138    * <UL>
139    *   <LI>AddSection</LI>
140    *   <LI>InsertPoints</LI>
141    *   <LI>SetCoordinates</LI>
142    * </UL>
143    * @return true in case of success; false otherwise.
144    */
145   bool init(const Type theType, const CurveCreator::Coordinates &theCoords,
146             const int theIntParam1, const int theIntParam2);
147
148   /**
149    * This method applies the current operation to theCurve.
150    */
151   void apply(CurveCreator_Curve *theCurve);
152
153 private:
154
155   /**
156    * This method allocates required memory for the operation data.
157    * Returns myPData for convenience purpose.
158    */
159   void *allocate(const size_t theSize);
160
161   /**
162    * This method clears initialized data pointers.
163    */
164   void clear();
165
166   /**
167    * This method returns the coordinates read from thePInt.
168    */
169   void getCoords(int *thePInt, CurveCreator::Coordinates &theCoords) const;
170
171 private:
172
173   Type  myType;
174   void *myPData;
175
176 };
177
178 #endif