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"
32 #include <AIS_InteractiveObject.hxx>
37 struct CurveCreator_Section;
38 class CurveCreator_Displayer;
41 * The CurveCreator_Curve object is represented as one or more sets of
42 * connected points; thus CurveCreator_Curve object can contain several
43 * not connected curves (polylines or b-splines), each such curve has two
44 * only ends � start and end points � in other words non-manifold curves
47 class CURVECREATOR_EXPORT CurveCreator_Curve : public CurveCreator_ICurve
50 typedef std::list<CurveCreator_Diff> ListDiff;
53 //! Constructor of the curve.
54 /** The dimension is explicitly specified in the constructor
55 * and cannot be changed later.
57 CurveCreator_Curve(const CurveCreator::Dimension theDimension);
60 virtual ~CurveCreator_Curve();
62 //! Get the dimension.
63 virtual CurveCreator::Dimension getDimension() const;
65 //! Return unique section name
66 virtual std::string getUniqSectionName() const;
68 //! Set curve creator Displayer object
69 virtual void setDisplayer( CurveCreator_Displayer* theDisplayer );
71 //! Return curve creator Displayer object
72 CurveCreator_Displayer* getDisplayer();
74 //! Remove curve creator Displayer object
75 virtual void removeDisplayer();
77 /** Set depth of undo operations (unlimited if \a theDepth is -1
78 * or disabled if \a theDepth is 0)
80 virtual void setUndoDepth(const int theDepth = -1);
82 //! Get depth of undo operations.
83 virtual int getUndoDepth() const;
85 virtual void startOperation();
86 virtual void finishOperation();
89 * This method converts the point index to the index in
90 * an array of coordinates.
92 virtual int toICoord(const int theIPnt) const;
94 //! For internal use only! Undo/Redo are not used here.
95 virtual bool moveSectionInternal(const int theISection,
96 const int theNewIndex);
97 //! Move section to new position in list
98 virtual bool moveSection(const int theISection,
99 const int theNewIndex);
102 /** This method updates all undo/redo information required to be updated
103 * after curve modification operation. It returns false if undo/redo
104 * is disabled and true otherwise.
106 virtual bool addEmptyDiff();
108 public: // TODO: remove public
109 void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
110 protected: // TODO: remove public
111 void redisplayCurve();
113 void convert( const SectionToPointList &thePoints,
114 std::map<int, std::list<int> > &theConvPoints );
117 /************ Implementation of INTERFACE methods ************/
119 /***********************************************/
120 /*** Undo/Redo methods ***/
121 /***********************************************/
123 //! Get number of available undo operations
124 virtual int getNbUndo() const;
126 //! Undo previous operation
129 //! Get number of available redo operations
130 virtual int getNbRedo() const;
132 //! Redo last previously "undone" operation
136 /***********************************************/
137 /*** Section methods ***/
138 /***********************************************/
140 //! For internal use only! Undo/Redo are not used here.
141 virtual bool clearInternal();
142 //! Clear the polyline (remove all sections)
143 virtual bool clear();
145 //! For internal use only! Undo/Redo are not used here.
146 virtual bool joinInternal( const int theISectionTo = -1,
147 const int theISectionFrom = -1 );
148 //! Join range of sections to one section (join all sections if -1 is passed in one of arguments)
149 virtual bool join( const int theISectionTo = -1,
150 const int theISectionFrom = -1 );
152 //! Get number of sections
153 virtual int getNbSections() const;
155 //! For internal use only! Undo/Redo are not used here.
156 virtual int addSectionInternal( const std::string &theName,
157 const CurveCreator::SectionType theType,
158 const bool theIsClosed,
159 const CurveCreator::Coordinates &thePoints);
160 //! Add a new section.
161 virtual int addSection( const std::string &theName,
162 const CurveCreator::SectionType theType,
163 const bool theIsClosed );
164 //! Add a new section.
165 virtual int addSection( const std::string &theName,
166 const CurveCreator::SectionType theType,
167 const bool theIsClosed,
168 const CurveCreator::Coordinates &thePoints);
170 //! For internal use only! Undo/Redo are not used here.
171 virtual bool removeSectionInternal( const int theISection );
172 //! Removes the given sections.
173 virtual bool removeSection( const int theISection );
175 //! Get "closed" flag of the specified section
176 virtual bool isClosed( const int theISection ) const;
178 //! For internal use only! Undo/Redo are not used here.
179 virtual bool setClosedInternal( const int theISection,
180 const bool theIsClosed );
182 * Set "closed" flag of the specified section (all sections if
183 * \a theISection is -1).
185 virtual bool setClosed( const int theISection,
186 const bool theIsClosed );
188 //! Returns specifyed section name
189 virtual std::string getSectionName( const int theISection ) const;
191 //! For internal use only! Undo/Redo are not used here.
192 virtual bool setSectionNameInternal( const int theISection,
193 const std::string& theName );
194 /** Set name of the specified section */
195 virtual bool setSectionName( const int theISection,
196 const std::string& theName );
198 //! Get type of the specified section
199 virtual CurveCreator::SectionType getSectionType( const int theISection ) const;
201 //! For internal use only! Undo/Redo are not used here.
202 virtual bool setSectionTypeInternal( const int theISection,
203 const CurveCreator::SectionType theType );
205 * Set type of the specified section (or all sections
206 * if \a theISection is -1).
208 virtual bool setSectionType( const int theISection,
209 const CurveCreator::SectionType theType );
212 /***********************************************/
213 /*** Point methods ***/
214 /***********************************************/
216 //! For internal use only! Undo/Redo are not used here.
217 virtual bool addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap );
219 * Add one point to the specified section starting from the given theIPnt index
220 * (or at the end of points if \a theIPnt is -1).
222 virtual bool addPoints( const CurveCreator::Coordinates &theCoords,
223 const int theISection,
224 const int theIPnt = -1 );
226 //! For internal use only! Undo/Redo are not used here.
227 virtual bool setPointInternal( const CurveCreator::SectionsMap &theSectionsMap );
228 //! Set coordinates of specified point
229 virtual bool setPoint( const int theISection,
231 const CurveCreator::Coordinates& theNewCoords );
233 //! Set coordinates of specified points from different sections
234 virtual bool setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords);
236 //! For internal use only! Undo/Redo are not used here.
237 virtual bool removePointsInternal( const SectionToPointList &thePoints );
238 /** Remove point with given id */
239 virtual bool removePoint( const int theISection, const int theIPnt = -1 );
241 //! Remove several points from different sections with given ids
242 virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs);
244 //! Get coordinates of specified point
245 virtual CurveCreator::Coordinates getPoint( const int theISection,
246 const int theIPnt ) const;
249 * Get points of a section (the total points in Curve if theISection is equal to -1)..
251 virtual CurveCreator::Coordinates getPoints( const int theISection = -1 ) const;
255 * Get number of points in specified section or (the total number of points
256 * in Curve if theISection is equal to -1).
258 virtual int getNbPoints( const int theISection ) const;
261 /***********************************************/
262 /*** Presentation methods ***/
263 /***********************************************/
264 virtual ListAISObjects constructWire() const;
268 CurveCreator::Sections mySections; //!< curve data
269 CurveCreator::Dimension myDimension; //!< curve dimension
270 CurveCreator_Displayer* myDisplayer; //!< curve displayer
276 ListDiff::iterator myCurrenPos;
277 ListDiff myListDiffs;