1 // Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: CurveCreator_Curve.hxx
21 // Author: Sergey KHROMOV
23 #ifndef _CurveCreator_ICurve_HeaderFile
24 #define _CurveCreator_ICurve_HeaderFile
26 #include "CurveCreator.hxx"
27 #include "CurveCreator_Macro.hxx"
28 #include "CurveCreator_Operation.hxx"
30 class CurveCreator_Section;
31 class CurveCreator_Listener;
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
40 class CURVECREATOR_EXPORT CurveCreator_ICurve
44 typedef std::deque<CurveCreator_Section *> Sections;
47 //! Constructor of the curve.
48 /** The dimension is explicitly specified in the constructor
49 * and cannot be changed later.
51 CurveCreator_ICurve(const CurveCreator::Dimension theDimension);
54 virtual ~CurveCreator_ICurve();
56 //! Returns true if this curve is locked by a curve editor.
57 virtual bool isLocked() const;
59 //! Get the dimension.
60 virtual CurveCreator::Dimension getDimension() const;
62 //! Get number of sections.
63 virtual int getNbSections() const;
65 /** Get number of points in specified section or (the total number of points
66 * in Curve if theISection is equal to -1).
68 virtual int getNbPoints(const int theISection = -1) const;
70 //! Get coordinates of specified point
71 virtual CurveCreator::Coordinates getCoordinates
72 (const int theISection, const int theIPnt) const;
74 //! Get points of a section.
75 virtual const CurveCreator::Coordinates &getPoints(const int theISection) const;
77 //! Get type of the specified section
78 virtual CurveCreator::Type getType(const int theISection) const;
80 //! Get �closed� flag of the specified section
81 virtual bool isClosed(const int theISection) const;
83 //! Returns specifyed section name
84 virtual std::string getSectionName(const int theISection) const;
87 * Return unic section name
89 virtual std::string getUnicSectionName();
92 * Set curve creator listener object
94 virtual void setListener( CurveCreator_Listener* myWatcher );
97 * Remove curve creator listener object
99 virtual void removeListener();
103 /** Set type of the specified section (or all sections
104 * if \a theISection is -1).
106 virtual void setType(const CurveCreator::Type theType, const int theISection = -1);
108 /** Add points to the specified section (or last section
109 * if \a theISection is -1).
111 virtual void addPoints
112 (const CurveCreator::Coordinates &thePoints, const int theISection = -1) = 0;
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);
119 //! Removes the section. If theISection equals -1, removes the last section.
120 virtual void removeSection(const int theISection = -1);
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).
126 virtual void insertPoints(const CurveCreator::Coordinates &thePoints,
127 const int theISection = -1,
128 const int theIPnt = -1);
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).
134 virtual void removePoints(const int theISection,
136 const int theNbPoints = -1);
138 /** Move specified point within section to new position
140 virtual void movePoint(const int theISection,
141 const int theIPointFrom,
142 const int theNewIndex);
144 //! Remove all sections.
145 virtual void clear();
147 //! Set coordinates of specified point
148 virtual void setCoordinates(const CurveCreator::Coordinates &theCoords,
149 const int theISection,
152 /** Set �closed� flag of the specified section (all sections if
153 * \a theISection is -1).
155 virtual void setClosed(const bool theIsClosed, const int theISection = -1);
157 /** Set name of the specified section.
159 virtual void setName( const std::string& theName, const int theISection );
161 /** Move specified \a theISection to the specified position
162 * in the sections list.
164 virtual void moveSection(const int theISection, const int theNewIndex);
166 //! Join two sections to one section
167 virtual void join(const int theISectionTo, const int theISectionFrom);
169 //! Join all sections to the single curve
173 * This method converts the point index to the index in
174 * an array of coordinates.
176 virtual int toICoord(const int theIPnt) const;
181 Sections mySections; //!< curve data
182 CurveCreator::Dimension myDimension; //!< curve dimension
183 CurveCreator_Listener* myListener; //!< listener