]> SALOME platform Git repositories - modules/geom.git/blob - src/CurveCreator/CurveCreator_Curve.hxx
Salome HOME
Images neccessary for CurveEditor were added
[modules/geom.git] / src / CurveCreator / CurveCreator_Curve.hxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:        CurveCreator_Curve.hxx
24 // Created:     Thu Jun  20 9:54:14 2013
25 // Author:      Sergey KHROMOV
26 //
27
28 #ifndef _CurveCreator_Curve_HeaderFile
29 #define _CurveCreator_Curve_HeaderFile
30
31
32 #include <CurveCreator.hxx>
33 #include <CurveCreator_Macro.hxx>
34 #include <CurveCreator_Operation.hxx>
35
36 class CurveCreator_Section;
37
38
39 /**
40  *  The CurveCreator_Curve object is represented as one or more sets of
41  *  connected points; thus CurveCreator_Curve object can contain several
42  *  not connected curves (polylines or b-splines), each such curve has two
43  *  only ends \96 start and end points \96 in other words non-manifold curves
44  *  are not supported.
45  */
46 class CURVECREATOR_EXPORT CurveCreator_Curve
47 {
48
49   //! List of curves
50   typedef std::deque<CurveCreator_Section *> Sections;
51
52 public:
53   //! Constructor of the curve.
54   /** The dimension is explicitly specified in the constructor
55    *  and cannot be changed later.
56    */
57   CurveCreator_Curve(const CurveCreator::Dimension theDimension);
58
59   //! Destructor.
60   ~CurveCreator_Curve();
61
62   //! Returns true if this curve is locked by a curve editor.
63   bool isLocked() const;
64
65   //! Get the dimension.
66   CurveCreator::Dimension getDimension() const;
67
68   //! Get number of sections.
69   int getNbSections() const;
70
71   /** Get number of points in specified section or (the total number of points
72    *  in Curve if theISection is equal to -1).
73    */
74   int getNbPoints(const int theISection = -1) const;
75
76   //! Get coordinates of specified point
77   CurveCreator::Coordinates getCoordinates
78                   (const int theISection, const int theIPnt) const;
79
80   //! Get points of a section.
81   const CurveCreator::Coordinates &getPoints(const int theISection) const;
82
83   //! Get type of the specified section
84   CurveCreator::Type getType(const int theISection) const;
85
86   //! Get \93closed\94 flag of the specified section
87   bool isClosed(const int theISection) const;
88
89 protected:
90
91   /** Set type of the specified section (or all sections
92    *  if \a theISection is -1).
93    */
94   void setType(const CurveCreator::Type theType, const int theISection = -1);
95
96   /** Add points to the specified section (or last section
97    *  if \a theISection is -1).
98    */
99   void addPoints
100     (const CurveCreator::Coordinates &thePoints, const int theISection = -1);
101
102   //! Add a new section.
103   void addSection (const CurveCreator::Type theType,
104                    const bool theIsClosed,
105                    const CurveCreator::Coordinates &thePoints);
106
107   //! Removes the section. If theISection equals -1, removes the last section.
108   void removeSection(const int theISection = -1);
109
110   /** Insert points in the given position (add to the end of list
111    *  if \a theIPnt parameter is -1) of the specified section
112    *  (or last section if \a theISection parameter is -1).
113    */
114   void insertPoints(const CurveCreator::Coordinates &thePoints,
115                     const int theISection = -1,
116                     const int theIPnt = -1);
117
118   /** Remove \a nbPoints points from given \a theISection,
119    *  starting from given \a theIPnt (of all points up to the end of
120    *  section if \a theNbPoints is -1).
121    */
122   void removePoints(const int theISection,
123                     const int theIPnt,
124                     const int theNbPoints = -1);
125
126   //! Remove all sections.
127   void clear();
128
129   //! Set coordinates of specified point
130   void setCoordinates(const CurveCreator::Coordinates &theCoords,
131                       const int theISection,
132                       const int theIPnt);
133
134   /** Set \93closed\94 flag of the specified section (all sections if
135    *  \a theISection is -1).
136    */
137   void setClosed(const bool theIsClosed, const int theISection = -1);
138
139   /** Move specified \a theISection to the specified position
140    *  in the sections list.
141    */
142   void moveSection(const int theISection, const int theNewIndex);
143
144   //! Join two sections to one section
145   void join(const int theISectionTo, const int theISectionFrom);
146
147   //! Join all sections to the single curve
148   void join();
149
150   /**
151    * This method converts the point index to the index in
152    * an array of coordinates.
153    */
154   int toICoord(const int theIPnt) const;
155
156 protected:
157
158   bool                    myIsLocked;
159   Sections                mySections;   //!< curve data
160   CurveCreator::Dimension myDimension;  //!< curve dimension
161
162   friend class CurveCreator_CurveEditor;
163   friend class CurveCreator_Operation;
164
165 };
166
167 #endif