Salome HOME
Update copyrights 2014.
[modules/geom.git] / src / CurveCreator / CurveCreator_ICurve.hxx
1 // Copyright (C) 2013-2014  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_Curve.hxx
21 // Author:      Sergey KHROMOV
22
23 #ifndef _CurveCreator_ICurve_HeaderFile
24 #define _CurveCreator_ICurve_HeaderFile
25
26 #include "CurveCreator.hxx"
27 #include "CurveCreator_Macro.hxx"
28 #include "CurveCreator_Operation.hxx"
29
30 class CurveCreator_Section;
31 class CurveCreator_Listener;
32
33 /**
34  *  The CurveCreator_ICurve object is represented as one or more sets of
35  *  connected points; thus CurveCreator_ICurve object can contain several
36  *  not connected curves (polylines or b-splines), each such curve has two
37  *  only ends � start and end points � in other words non-manifold curves
38  *  are not supported.
39  */
40 class CURVECREATOR_EXPORT CurveCreator_ICurve
41 {
42
43   //! List of curves
44   typedef std::deque<CurveCreator_Section *> Sections;
45
46 public:
47   //! Constructor of the curve.
48   /** The dimension is explicitly specified in the constructor
49    *  and cannot be changed later.
50    */
51   CurveCreator_ICurve(const CurveCreator::Dimension theDimension);
52
53   //! Destructor.
54   virtual ~CurveCreator_ICurve();
55
56   //! Returns true if this curve is locked by a curve editor.
57   virtual bool isLocked() const;
58
59   //! Get the dimension.
60   virtual CurveCreator::Dimension getDimension() const;
61
62   //! Get number of sections.
63   virtual int getNbSections() const;
64
65   /** Get number of points in specified section or (the total number of points
66    *  in Curve if theISection is equal to -1).
67    */
68   virtual int getNbPoints(const int theISection = -1) const;
69
70   //! Get coordinates of specified point
71   virtual CurveCreator::Coordinates getCoordinates
72                   (const int theISection, const int theIPnt) const;
73
74   //! Get points of a section.
75   virtual const CurveCreator::Coordinates &getPoints(const int theISection) const;
76
77   //! Get type of the specified section
78   virtual CurveCreator::Type getType(const int theISection) const;
79
80   //! Get �closed� flag of the specified section
81   virtual bool isClosed(const int theISection) const;
82
83   //! Returns specifyed section name
84   virtual std::string   getSectionName(const int theISection) const;
85
86   /**
87    * Return unic section name
88    */
89   virtual std::string getUnicSectionName();
90
91   /**
92    * Set curve creator listener object
93    */
94   virtual void setListener( CurveCreator_Listener*   myWatcher );
95
96   /**
97    * Remove curve creator listener object
98    */
99   virtual void removeListener();
100
101 protected:
102
103   /** Set type of the specified section (or all sections
104    *  if \a theISection is -1).
105    */
106   virtual void setType(const CurveCreator::Type theType, const int theISection = -1);
107
108   /** Add points to the specified section (or last section
109    *  if \a theISection is -1).
110    */
111   virtual void addPoints
112     (const CurveCreator::Coordinates &thePoints, const int theISection = -1) = 0;
113
114   //! Add a new section.
115   virtual void addSection (const std::string &theName, const CurveCreator::Type theType,
116                    const bool theIsClosed,
117                    const CurveCreator::Coordinates &thePoints);
118
119   //! Removes the section. If theISection equals -1, removes the last section.
120   virtual void removeSection(const int theISection = -1);
121
122   /** Insert points in the given position (add to the end of list
123    *  if \a theIPnt parameter is -1) of the specified section
124    *  (or last section if \a theISection parameter is -1).
125    */
126   virtual void insertPoints(const CurveCreator::Coordinates &thePoints,
127                     const int theISection = -1,
128                     const int theIPnt = -1);
129
130   /** Remove \a nbPoints points from given \a theISection,
131    *  starting from given \a theIPnt (of all points up to the end of
132    *  section if \a theNbPoints is -1).
133    */
134   virtual void removePoints(const int theISection,
135                     const int theIPnt,
136                     const int theNbPoints = -1);
137
138   /** Move specified  point within section to new position
139    */
140   virtual void movePoint(const int theISection,
141                  const int theIPointFrom,
142                  const int theNewIndex);
143
144   //! Remove all sections.
145   virtual void clear();
146
147   //! Set coordinates of specified point
148   virtual void setCoordinates(const CurveCreator::Coordinates &theCoords,
149                       const int theISection,
150                       const int theIPnt);
151
152   /** Set �closed� flag of the specified section (all sections if
153    *  \a theISection is -1).
154    */
155   virtual void setClosed(const bool theIsClosed, const int theISection = -1);
156
157   /** Set name of the specified section.
158    */
159   virtual void setName( const std::string& theName, const int theISection );
160
161   /** Move specified \a theISection to the specified position
162    *  in the sections list.
163    */
164   virtual void moveSection(const int theISection, const int theNewIndex);
165
166   //! Join two sections to one section
167   virtual void join(const int theISectionTo, const int theISectionFrom);
168
169   //! Join all sections to the single curve
170   virtual void join();
171
172   /**
173    * This method converts the point index to the index in
174    * an array of coordinates.
175    */
176   virtual int toICoord(const int theIPnt) const;
177
178 public:
179
180   bool                    myIsLocked;
181   Sections                mySections;   //!< curve data
182   CurveCreator::Dimension myDimension;  //!< curve dimension
183   CurveCreator_Listener*  myListener;   //!< listener
184
185 };
186
187 #endif