Salome HOME
Fix Undo/Redo of removing of middle point.
[modules/hydro.git] / src / HYDROCurveCreator / 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
30 #include <AIS_InteractiveObject.hxx>
31
32 namespace CurveCreator
33 {
34   //! Type of the section
35   enum SectionType
36   {
37     Polyline,
38     Spline,
39   };
40
41   //! Dimension of the curve
42   enum Dimension
43   {
44     Dim2d = 2,
45     Dim3d = 3
46   };
47
48 };
49
50 /**
51  *  The CurveCreator_ICurve object is represented as one or more sets of
52  *  connected points; thus CurveCreator_ICurve object can contain several
53  *  not connected curves (polylines or b-splines), each such curve has two
54  *  only ends "start and end points" in other words non-manifold curves
55  *  are not supported.
56  */
57 class CURVECREATOR_EXPORT CurveCreator_ICurve
58 {
59 public:
60   typedef std::vector<Handle_AIS_InteractiveObject> ListAISObjects;
61
62 public:
63   /***********************************************/
64   /***          Undo/Redo methods              ***/
65   /***********************************************/
66
67   //! Get number of available undo operations
68   virtual int getNbUndo() const = 0;
69
70   //! Undo previous operation
71   virtual bool undo() = 0;
72
73   //! Get number of available redo operations
74   virtual int getNbRedo() const = 0;
75
76   //! Redo last previously "undone" operation
77   virtual bool redo() = 0;
78
79
80   /***********************************************/
81   /***           Section methods               ***/
82   /***********************************************/
83
84   //! Clear the polyline (remove all sections)
85   virtual bool clear() = 0;
86
87   //! Join range of sections to one section (join all sections if -1 is passed in one of arguments)
88   virtual bool join( const int theISectionTo = -1, 
89                      const int theISectionFrom = -1 ) = 0;
90
91   //! Get number of sections
92   virtual int getNbSections() const = 0;
93
94   //! Add a new section.
95   virtual int addSection( const std::string& theName, 
96                            const CurveCreator::SectionType theType,
97                            const bool theIsClosed ) = 0;
98
99   //! Removes the given sections.
100   virtual bool removeSection( const int theISection ) = 0;
101
102   //! Get "closed" flag of the specified section
103   virtual bool isClosed( const int theISection ) const = 0;
104
105   /**
106    *  Set "closed" flag of the specified section (all sections if
107    *  \a theISection is -1).
108    */
109   virtual bool setClosed( const int theISection, 
110                           const bool theIsClosed ) = 0;
111
112   //! Returns specifyed section name
113   virtual std::string getSectionName( const int theISection ) const = 0;
114
115   /** Set name of the specified section */
116   virtual bool setSectionName( const int theISection, 
117                                const std::string& theName ) = 0;
118
119   //! Get type of the specified section
120   virtual CurveCreator::SectionType getSectionType( const int theISection ) const = 0;
121
122   /**
123    *  Set type of the specified section (or all sections
124    *  if \a theISection is -1).
125    */
126   virtual bool setSectionType( const int theISection, 
127                                const CurveCreator::SectionType theType ) = 0;
128
129
130   /***********************************************/
131   /***           Point methods                 ***/
132   /***********************************************/
133
134   //! Get the dimension.
135   virtual CurveCreator::Dimension getDimension() const = 0;
136
137   /**
138    *  Insert one or several points to the specified section starting from the given theIPnt index
139    *  (or add these at the end of section points if \a theIPnt is -1).
140    */
141   virtual bool addPoints( const std::deque<float>& theCoords,
142                           const int theISection,
143                           const int theIPnt = -1 ) = 0;
144
145   //! Set coordinates of specified point
146   virtual bool setPoint( const int theISection,
147                          const int theIPnt,
148                          const std::deque<float>& theNewCoords ) = 0;
149
150   //! Remove point with given id
151   virtual bool removePoint( const int theISection, const int theIPnt = -1 ) = 0;
152
153   //! Get coordinates of specified point
154   virtual std::deque<float> getPoint( const int theISection, 
155                                       const int theIPnt ) const = 0;
156
157   /**
158    * Get points of a section (the total points in Curve if theISection is equal to -1)..
159    */
160   virtual std::deque<float> getPoints( const int theISection = -1 ) const = 0;
161
162   /**
163    *  Get number of points in specified section or (the total number of points
164    *  in Curve if theISection is equal to -1).
165    */
166   virtual int getNbPoints( const int theISection ) const = 0;
167
168
169   /***********************************************/
170   /***       Presentation methods              ***/
171   /***********************************************/
172   virtual ListAISObjects constructWire() const = 0;
173 };
174
175 #endif