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