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