1 // Copyright (C) 2013 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.
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_Curve_HeaderFile
24 #define _CurveCreator_Curve_HeaderFile
26 #include "CurveCreator_ICurve.hxx"
28 #include "CurveCreator_Macro.hxx"
29 #include "CurveCreator.hxx"
30 #include "CurveCreator_Diff.hxx"
34 struct CurveCreator_Section;
35 class CurveCreator_Listener;
38 * The CurveCreator_Curve object is represented as one or more sets of
39 * connected points; thus CurveCreator_Curve object can contain several
40 * not connected curves (polylines or b-splines), each such curve has two
41 * only ends � start and end points � in other words non-manifold curves
44 class CURVECREATOR_EXPORT CurveCreator_Curve : public CurveCreator_ICurve
47 typedef std::list<CurveCreator_Diff> ListDiff;
50 //! Constructor of the curve.
51 /** The dimension is explicitly specified in the constructor
52 * and cannot be changed later.
54 CurveCreator_Curve(const CurveCreator::Dimension theDimension);
57 virtual ~CurveCreator_Curve();
59 //! Get the dimension.
60 virtual CurveCreator::Dimension getDimension() const;
62 //! Return unique section name
63 virtual std::string getUniqSectionName() const;
65 //! Set curve creator listener object
66 virtual void setListener( CurveCreator_Listener* theWatcher );
68 //! Remove curve creator listener object
69 virtual void removeListener();
71 /** Set depth of undo operations (unlimited if \a theDepth is -1
72 * or disabled if \a theDepth is 0)
74 virtual void setUndoDepth(const int theDepth = -1);
76 //! Get depth of undo operations.
77 virtual int getUndoDepth() const;
79 virtual void startOperation();
80 virtual void finishOperation();
83 * This method converts the point index to the index in
84 * an array of coordinates.
86 virtual int toICoord(const int theIPnt) const;
89 /** This method updates all undo/redo information required to be updated
90 * after curve modification operation. It returns false if undo/redo
91 * is disabled and true otherwise.
93 virtual bool addEmptyDiff();
97 /************ Implementation of INTERFACE methods ************/
99 /***********************************************/
100 /*** Undo/Redo methods ***/
101 /***********************************************/
103 //! Get number of available undo operations
104 virtual int getNbUndo() const;
106 //! Undo previous operation
109 //! Get number of available redo operations
110 virtual int getNbRedo() const;
112 //! Redo last previously "undone" operation
116 /***********************************************/
117 /*** Section methods ***/
118 /***********************************************/
120 //! Clear the polyline (remove all sections)
121 virtual bool clear();
123 //! Join range of sections to one section (join all sections if -1 is passed in one of arguments)
124 virtual bool join( const int theISectionTo = -1,
125 const int theISectionFrom = -1 );
127 //! Get number of sections
128 virtual int getNbSections() const;
130 //! Add a new section.
131 virtual int addSection( const std::string &theName,
132 const CurveCreator::SectionType theType,
133 const bool theIsClosed );
135 //! Add a new section.
136 virtual int addSection( const std::string &theName,
137 const CurveCreator::SectionType theType,
138 const bool theIsClosed,
139 const CurveCreator::Coordinates &thePoints);
141 //! Removes the given sections.
142 virtual bool removeSection( const int theISection );
144 //! Get "closed" flag of the specified section
145 virtual bool isClosed( const int theISection ) const;
148 * Set "closed" flag of the specified section (all sections if
149 * \a theISection is -1).
151 virtual bool setClosed( const int theISection,
152 const bool theIsClosed );
154 //! Returns specifyed section name
155 virtual std::string getSectionName( const int theISection ) const;
157 /** Set name of the specified section */
158 virtual bool setSectionName( const int theISection,
159 const std::string& theName );
161 //! Get type of the specified section
162 virtual CurveCreator::SectionType getSectionType( const int theISection ) const;
165 * Set type of the specified section (or all sections
166 * if \a theISection is -1).
168 virtual bool setSectionType( const int theISection,
169 const CurveCreator::SectionType theType );
172 /***********************************************/
173 /*** Point methods ***/
174 /***********************************************/
177 * Add one point to the specified section starting from the given theIPnt index
178 * (or at the end of points if \a theIPnt is -1).
180 virtual bool addPoints( const CurveCreator::Coordinates &theCoords,
181 const int theISection,
182 const int theIPnt = -1 );
184 //! Set coordinates of specified point
185 virtual bool setPoint( const int theISection,
187 const CurveCreator::Coordinates& theNewCoords );
189 /** Remove point with given id */
190 virtual bool removePoint( const int theISection, const int theIPnt = -1 );
192 //! Get coordinates of specified point
193 virtual CurveCreator::Coordinates getPoint( const int theISection,
194 const int theIPnt ) const;
197 * Get points of a section (the total points in Curve if theISection is equal to -1)..
199 virtual CurveCreator::Coordinates getPoints( const int theISection = -1 ) const;
203 * Get number of points in specified section or (the total number of points
204 * in Curve if theISection is equal to -1).
206 virtual int getNbPoints( const int theISection ) const;
209 /***********************************************/
210 /*** Presentation methods ***/
211 /***********************************************/
212 // virtual TopoDS_Wire constructWire() const;
217 CurveCreator::Sections mySections; //!< curve data
218 CurveCreator::Dimension myDimension; //!< curve dimension
219 CurveCreator_Listener* myListener; //!< listener
225 ListDiff::iterator myCurrenPos;
226 ListDiff myListDiffs;