]> SALOME platform Git repositories - modules/geom.git/blob - src/CurveCreator/CurveCreator_Operation.hxx
Salome HOME
93b5c8848837a6df0943d7196d820c9737f5b606
[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   };
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    *   <LI>Join (without arguments)</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 three integer
112    * parameters. It is applicable to the following operations:
113    * <UL>
114    *   <LI>RemovePoints</LI>
115    * </UL>
116    * @return true in case of success; false otherwise.
117    */
118   bool init(const Type theType, const int theIntParam1,
119             const int theIntParam2, const int theIntParam3);
120
121   /**
122    * This method initializes the object with an operation with one
123    * CurveCreator::Coordinates parameter and one integer parameter.
124    * It is applicable to the following operations:
125    * <UL>
126    *   <LI>AddPoints</LI>
127    * </UL>
128    * @return true in case of success; false otherwise.
129    */
130   bool init(const Type theType, const CurveCreator::Coordinates &theCoords,
131             const int theIntParam);
132
133   /**
134    * This method initializes the object with an operation with one
135    * CurveCreator::Coordinates parameter and two integer parameters.
136    * It is applicable to the following operations:
137    * <UL>
138    *   <LI>AddSection</LI>
139    *   <LI>InsertPoints</LI>
140    *   <LI>SetCoordinates</LI>
141    * </UL>
142    * @return true in case of success; false otherwise.
143    */
144   bool init(const Type theType, const CurveCreator::Coordinates &theCoords,
145             const int theIntParam1, const int theIntParam2);
146
147   /**
148    * This method applies the current operation to theCurve.
149    */
150   void apply(CurveCreator_Curve *theCurve);
151
152 private:
153
154   /**
155    * This method allocates required memory for the operation data.
156    * Returns myPData for convenience purpose.
157    */
158   void *allocate(const size_t theSize);
159
160   /**
161    * This method clears initialized data pointers.
162    */
163   void clear();
164
165   /**
166    * This method returns the coordinates read from thePInt.
167    */
168   void getCoords(int *thePInt, CurveCreator::Coordinates &theCoords) const;
169
170 private:
171
172   Type  myType;
173   void *myPData;
174
175 };
176
177 #endif