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