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"
31 #include "CurveCreator_AISCurve.hxx"
33 #include <AIS_Point.hxx>
34 #include <AIS_Line.hxx>
35 #include <AIS_InteractiveObject.hxx>
40 struct CurveCreator_Section;
41 class CurveCreator_Displayer;
44 * The CurveCreator_Curve object is represented as one or more sets of
45 * connected points; thus CurveCreator_Curve object can contain several
46 * not connected curves (polylines or b-splines), each such curve has two
47 * only ends � start and end points � in other words non-manifold curves
50 class CURVECREATOR_EXPORT CurveCreator_Curve : public CurveCreator_ICurve
53 typedef std::list<CurveCreator_Diff> ListDiff;
56 //! Constructor of the curve.
57 /** The dimension is explicitly specified in the constructor
58 * and cannot be changed later.
60 CurveCreator_Curve(const CurveCreator::Dimension theDimension);
63 virtual ~CurveCreator_Curve();
65 //! Get the dimension.
66 virtual CurveCreator::Dimension getDimension() const;
68 //! Return unique section name
69 virtual std::string getUniqSectionName() const;
71 //! Set curve creator Displayer object
72 virtual void setDisplayer( CurveCreator_Displayer* theDisplayer );
74 //! Return curve creator Displayer object
75 CurveCreator_Displayer* getDisplayer();
77 //! Remove curve creator Displayer object
78 virtual void removeDisplayer();
80 /** Set depth of undo operations (unlimited if \a theDepth is -1
81 * or disabled if \a theDepth is 0)
83 virtual void setUndoDepth(const int theDepth = -1);
85 //! Get depth of undo operations.
86 virtual int getUndoDepth() const;
88 virtual void startOperation();
89 virtual void finishOperation();
92 * This method converts the point index to the index in
93 * an array of coordinates.
95 virtual int toICoord(const int theIPnt) const;
97 ListAISObjects constructSection( int theISection ) const;
99 //! For internal use only! Undo/Redo are not used here.
100 virtual bool moveSectionInternal(const int theISection,
101 const int theNewIndex);
102 //! Move section to new position in list
103 virtual bool moveSection(const int theISection,
104 const int theNewIndex);
107 /** This method updates all undo/redo information required to be updated
108 * after curve modification operation. It returns false if undo/redo
109 * is disabled and true otherwise.
111 virtual bool addEmptyDiff();
113 Handle_AIS_Point getAISPoint( int theISection, int theIPoint ) const;
114 Handle_AIS_Line getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const;
115 void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
117 void redisplayCurve();
119 void convert( const SectionToPointList &thePoints,
120 std::map<int, std::list<int> > &theConvPoints );
123 /************ Implementation of INTERFACE methods ************/
125 /***********************************************/
126 /*** Undo/Redo methods ***/
127 /***********************************************/
129 //! Get number of available undo operations
130 virtual int getNbUndo() const;
132 //! Undo previous operation
135 //! Get number of available redo operations
136 virtual int getNbRedo() const;
138 //! Redo last previously "undone" operation
142 /***********************************************/
143 /*** Section methods ***/
144 /***********************************************/
146 //! For internal use only! Undo/Redo are not used here.
147 virtual bool clearInternal();
148 //! Clear the polyline (remove all sections)
149 virtual bool clear();
151 //! For internal use only! Undo/Redo are not used here.
152 virtual bool joinInternal( const int theISectionTo = -1,
153 const int theISectionFrom = -1 );
154 //! Join range of sections to one section (join all sections if -1 is passed in one of arguments)
155 virtual bool join( const int theISectionTo = -1,
156 const int theISectionFrom = -1 );
158 //! Get number of sections
159 virtual int getNbSections() const;
161 //! For internal use only! Undo/Redo are not used here.
162 virtual int addSectionInternal( const std::string &theName,
163 const CurveCreator::SectionType theType,
164 const bool theIsClosed,
165 const CurveCreator::Coordinates &thePoints);
166 //! Add a new section.
167 virtual int addSection( const std::string &theName,
168 const CurveCreator::SectionType theType,
169 const bool theIsClosed );
170 //! Add a new section.
171 virtual int addSection( const std::string &theName,
172 const CurveCreator::SectionType theType,
173 const bool theIsClosed,
174 const CurveCreator::Coordinates &thePoints);
176 //! For internal use only! Undo/Redo are not used here.
177 virtual bool removeSectionInternal( const int theISection );
178 //! Removes the given sections.
179 virtual bool removeSection( const int theISection );
181 //! Get "closed" flag of the specified section
182 virtual bool isClosed( const int theISection ) const;
184 //! For internal use only! Undo/Redo are not used here.
185 virtual bool setClosedInternal( const int theISection,
186 const bool theIsClosed );
188 * Set "closed" flag of the specified section (all sections if
189 * \a theISection is -1).
191 virtual bool setClosed( const int theISection,
192 const bool theIsClosed );
194 //! Returns specifyed section name
195 virtual std::string getSectionName( const int theISection ) const;
197 //! For internal use only! Undo/Redo are not used here.
198 virtual bool setSectionNameInternal( const int theISection,
199 const std::string& theName );
200 /** Set name of the specified section */
201 virtual bool setSectionName( const int theISection,
202 const std::string& theName );
204 //! Get type of the specified section
205 virtual CurveCreator::SectionType getSectionType( const int theISection ) const;
207 //! For internal use only! Undo/Redo are not used here.
208 virtual bool setSectionTypeInternal( const int theISection,
209 const CurveCreator::SectionType theType );
211 * Set type of the specified section (or all sections
212 * if \a theISection is -1).
214 virtual bool setSectionType( const int theISection,
215 const CurveCreator::SectionType theType );
218 /***********************************************/
219 /*** Point methods ***/
220 /***********************************************/
222 //! For internal use only! Undo/Redo are not used here.
223 virtual bool addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap );
225 * Add one point to the specified section starting from the given theIPnt index
226 * (or at the end of points if \a theIPnt is -1).
228 virtual bool addPoints( const CurveCreator::Coordinates &theCoords,
229 const int theISection,
230 const int theIPnt = -1 );
232 //! For internal use only! Undo/Redo are not used here.
233 virtual bool setPointInternal( const CurveCreator::SectionsMap &theSectionsMap );
234 //! Set coordinates of specified point
235 virtual bool setPoint( const int theISection,
237 const CurveCreator::Coordinates& theNewCoords );
239 //! Set coordinates of specified points from different sections
240 virtual bool setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords);
242 //! For internal use only! Undo/Redo are not used here.
243 virtual bool removePointsInternal( const SectionToPointList &thePoints );
244 /** Remove point with given id */
245 virtual bool removePoint( const int theISection, const int theIPnt = -1 );
247 //! Remove several points from different sections with given ids
248 virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs);
250 //! Get coordinates of specified point
251 virtual CurveCreator::Coordinates getPoint( const int theISection,
252 const int theIPnt ) const;
255 * Get points of a section (the total points in Curve if theISection is equal to -1)..
257 virtual CurveCreator::Coordinates getPoints( const int theISection = -1 ) const;
261 * Get number of points in specified section or (the total number of points
262 * in Curve if theISection is equal to -1).
264 virtual int getNbPoints( const int theISection ) const;
267 /***********************************************/
268 /*** Presentation methods ***/
269 /***********************************************/
270 virtual ListAISObjects constructWire() const;
273 Handle(CurveCreator_AISCurve) myAISCurve;
275 CurveCreator::Sections mySections; //!< curve data
276 CurveCreator::Dimension myDimension; //!< curve dimension
277 CurveCreator_Displayer* myDisplayer; //!< curve displayer
283 ListDiff::iterator myCurrenPos;
284 ListDiff myListDiffs;