Salome HOME
0022661: EDF GEOM: [HYDRO] Integration of the polyline editor in GEOM
[modules/geom.git] / src / CurveCreator / CurveCreator_ICurve.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_ICurve.hxx
21 // Author:      Alexander KOVALEV and Alexander SOLOVYOV
22
23 #ifndef _CurveCreator_ICurve_HeaderFile
24 #define _CurveCreator_ICurve_HeaderFile
25
26 #include "CurveCreator_Macro.hxx"
27 #include <deque>
28 #include <vector>
29 #include <string>
30 #include <list>
31
32 class Handle_AIS_InteractiveObject;
33
34 namespace CurveCreator
35 {
36   //! Type of the section
37   enum SectionType
38   {
39     Polyline,
40     Spline,
41   };
42
43   //! Dimension of the curve
44   enum Dimension
45   {
46     Dim2d = 2,
47     Dim3d = 3
48   };
49
50 };
51
52 /**
53  *  The CurveCreator_ICurve object is represented as one or more sets of
54  *  connected points; thus CurveCreator_ICurve object can contain several
55  *  not connected curves (polylines or b-splines), each such curve has two
56  *  only ends "start and end points" in other words non-manifold curves
57  *  are not supported.
58  */
59 class CURVECREATOR_EXPORT CurveCreator_ICurve
60 {
61 public:
62   typedef std::pair<int,int> SectionToPoint;
63   typedef std::deque<SectionToPoint> SectionToPointList;
64
65   typedef std::deque< std::pair< SectionToPoint,std::deque< float > > > SectionToPointCoordsList;
66
67 public:
68   /***********************************************/
69   /***          Undo/Redo methods              ***/
70   /***********************************************/
71
72   //! Get number of available undo operations
73   virtual int getNbUndo() const = 0;
74
75   //! Undo previous operation
76   virtual bool undo() = 0;
77
78   //! Get number of available redo operations
79   virtual int getNbRedo() const = 0;
80
81   //! Redo last previously "undone" operation
82   virtual bool redo() = 0;
83
84
85   /***********************************************/
86   /***           Section methods               ***/
87   /***********************************************/
88
89   //! Clear the polyline (remove all sections)
90   virtual bool clear() = 0;
91
92   //! Join list of sections to one section (join all if the list is empty)
93   // The first section in the list is a leader, another sections are joined to it
94   virtual bool join( const std::list<int>& theSections ) = 0;
95
96   //! Get number of sections
97   virtual int getNbSections() const = 0;
98
99   //! Add a new section.
100   virtual int addSection( const std::string& theName, 
101                            const CurveCreator::SectionType theType,
102                            const bool theIsClosed ) = 0;
103
104   //! Removes the given sections.
105   virtual bool removeSection( const int theISection ) = 0;
106
107   //! Get "closed" flag of the specified section
108   virtual bool isClosed( const int theISection ) const = 0;
109
110   /**
111    *  Set "closed" flag of the specified section (all sections if
112    *  \a theISection is -1).
113    */
114   virtual bool setClosed( const int theISection, 
115                           const bool theIsClosed ) = 0;
116
117   //! Returns specifyed section name
118   virtual std::string getSectionName( const int theISection ) const = 0;
119
120   /** Set name of the specified section */
121   virtual bool setSectionName( const int theISection, 
122                                const std::string& theName ) = 0;
123
124   //! Get type of the specified section
125   virtual CurveCreator::SectionType getSectionType( const int theISection ) const = 0;
126
127   /**
128    *  Set type of the specified section (or all sections
129    *  if \a theISection is -1).
130    */
131   virtual bool setSectionType( const int theISection, 
132                                const CurveCreator::SectionType theType ) = 0;
133
134
135   /***********************************************/
136   /***           Point methods                 ***/
137   /***********************************************/
138
139   //! Get the dimension.
140   virtual CurveCreator::Dimension getDimension() const = 0;
141
142   /**
143    *  Insert one or several points to the specified section starting from the given theIPnt index
144    *  (or add these at the end of section points if \a theIPnt is -1).
145    */
146   virtual bool addPoints( const std::deque<float>& theCoords,
147                           const int theISection,
148                           const int theIPnt = -1 ) = 0;
149
150   //! Set coordinates of specified point
151   virtual bool setPoint( const int theISection,
152                          const int theIPnt,
153                          const std::deque<float>& theNewCoords ) = 0;
154   
155   //! Set coordinates of specified points from different sections
156   virtual bool setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
157                                  const bool theIsToSaveDiff = true ) = 0;
158
159   //! Remove point with given id
160   virtual bool removePoint( const int theISection, const int theIPnt = -1 ) = 0;
161   //! Remove several points from different sections
162   virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs) = 0;
163
164   //! Get coordinates of specified point
165   virtual std::deque<float> getPoint( const int theISection, 
166                                       const int theIPnt ) const = 0;
167
168   /**
169    * Get points of a section (the total points in Curve if theISection is equal to -1)..
170    */
171   virtual std::deque<float> getPoints( const int theISection = -1 ) const = 0;
172
173   /**
174    *  Get number of points in specified section or (the total number of points
175    *  in Curve if theISection is equal to -1).
176    */
177   virtual int getNbPoints( const int theISection ) const = 0;
178
179   /**
180    * Set skip sorting flag. If the flag is true - points sorting will be skipped.
181    */
182   virtual void setSkipSorting( const bool ) = 0;
183
184   /**
185    * Indicates whether the points can be sorted.
186    */
187   virtual bool canPointsBeSorted() = 0;
188
189   /**
190    * Saves points coordinates difference.
191    * \param theOldCoords the old points coordinates
192    */
193   virtual void saveCoordDiff( const SectionToPointCoordsList &theOldCoords ) = 0;
194
195   /***********************************************/
196   /***       Presentation methods              ***/
197   /***********************************************/
198
199   virtual Handle_AIS_InteractiveObject getAISObject( const bool theNeedToBuild = false ) const = 0;
200
201 protected:
202   virtual void constructAISObject() = 0;
203
204 };
205
206 #endif