1 // Copyright (C) 2013-2016 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_ICurve.hxx
21 // Author: Alexander KOVALEV and Alexander SOLOVYOV
23 #ifndef _CurveCreator_ICurve_HeaderFile
24 #define _CurveCreator_ICurve_HeaderFile
26 #include "CurveCreator.hxx"
27 #include "CurveCreator_Macro.hxx"
29 #include <TColgp_HArray1OfPnt.hxx>
30 #include <AIS_InteractiveObject.hxx>
37 namespace CurveCreator
39 //! Type of the section
46 //! Dimension of the curve
55 //! The type represents the interface to the curve section.
56 struct CURVECREATOR_EXPORT CurveCreator_ISection
59 virtual ~CurveCreator_ISection() {}
61 //! Calculates the different points of the section.
62 virtual void GetDifferentPoints(
63 const int theDimension, Handle(TColgp_HArray1OfPnt)& thePoints) const = 0;
67 * The CurveCreator_ICurve object is represented as one or more sets of
68 * connected points; thus CurveCreator_ICurve object can contain several
69 * not connected curves (polylines or b-splines), each such curve has two
70 * only ends "start and end points" in other words non-manifold curves
73 class CURVECREATOR_EXPORT CurveCreator_ICurve
76 typedef std::pair<int,int> SectionToPoint;
77 typedef std::deque<SectionToPoint> SectionToPointList;
79 typedef std::deque< std::pair< SectionToPoint, CurveCreator::Coordinates > > SectionToPointCoordsList;
82 /***********************************************/
83 /*** Undo/Redo methods ***/
84 /***********************************************/
87 virtual ~CurveCreator_ICurve() {}
89 //! Get number of available undo operations
90 virtual int getNbUndo() const = 0;
92 //! Undo previous operation
93 virtual bool undo() = 0;
95 //! Get number of available redo operations
96 virtual int getNbRedo() const = 0;
98 //! Redo last previously "undone" operation
99 virtual bool redo() = 0;
102 /***********************************************/
103 /*** Section methods ***/
104 /***********************************************/
106 //! Clear the polyline (remove all sections)
107 virtual bool clear() = 0;
109 //! Join list of sections to one section (join all if the list is empty)
110 // The first section in the list is a leader, another sections are joined to it
111 virtual bool join( const std::list<int>& theSections ) = 0;
113 //! Get number of sections
114 virtual int getNbSections() const = 0;
116 //! Add a new section.
117 virtual int addSection( const std::string& theName,
118 const CurveCreator::SectionType theType,
119 const bool theIsClosed ) = 0;
121 //! Removes the given sections.
122 virtual bool removeSection( const int theISection ) = 0;
124 //! Get "closed" flag of the specified section
125 virtual bool isClosed( const int theISection ) const = 0;
128 * Set "closed" flag of the specified section (all sections if
129 * \a theISection is -1).
131 virtual bool setClosed( const int theISection,
132 const bool theIsClosed ) = 0;
134 //! Returns specifyed section name
135 virtual std::string getSectionName( const int theISection ) const = 0;
137 /** Set name of the specified section */
138 virtual bool setSectionName( const int theISection,
139 const std::string& theName ) = 0;
141 //! Get type of the specified section
142 virtual CurveCreator::SectionType getSectionType( const int theISection ) const = 0;
145 * Set type of the specified section (or all sections
146 * if \a theISection is -1).
148 virtual bool setSectionType( const int theISection,
149 const CurveCreator::SectionType theType ) = 0;
151 //! Returns the curve section with the index.
152 virtual const CurveCreator_ISection* getSection(
153 const int theSectionIndex) const = 0;
155 //! Returns the curve section with the index.
156 virtual CurveCreator_ISection* getSection(const int theSectionIndex) = 0;
159 /***********************************************/
160 /*** Point methods ***/
161 /***********************************************/
163 //! Get the dimension.
164 virtual CurveCreator::Dimension getDimension() const = 0;
167 * Insert one or several points to the specified section starting from the given theIPnt index
168 * (or add these at the end of section points if \a theIPnt is -1).
170 virtual bool addPoints( const CurveCreator::Coordinates& theCoords,
171 const int theISection,
172 const int theIPnt = -1 ) = 0;
174 //! Set coordinates of specified point
175 virtual bool setPoint( const int theISection,
177 const CurveCreator::Coordinates& theNewCoords ) = 0;
179 //! Set coordinates of specified points from different sections
180 virtual bool setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
181 const bool theIsToSaveDiff = true ) = 0;
183 //! Remove point with given id
184 virtual bool removePoint( const int theISection, const int theIPnt = -1 ) = 0;
185 //! Remove several points from different sections
186 virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs) = 0;
188 //! Get coordinates of specified point
189 virtual CurveCreator::Coordinates getPoint( const int theISection,
190 const int theIPnt ) const = 0;
193 * Get points of a section (the total points in Curve if theISection is equal to -1)..
195 virtual CurveCreator::Coordinates getPoints( const int theISection = -1 ) const = 0;
198 * Get number of points in specified section or (the total number of points
199 * in Curve if theISection is equal to -1).
201 virtual int getNbPoints( const int theISection ) const = 0;
204 * Set skip sorting flag. If the flag is true - points sorting will be skipped.
206 virtual void setSkipSorting( const bool ) = 0;
209 * Indicates whether the points can be sorted.
211 virtual bool canPointsBeSorted() = 0;
214 * Saves points coordinates difference.
215 * \param theOldCoords the old points coordinates
217 virtual void saveCoordDiff( const SectionToPointCoordsList &theOldCoords ) = 0;
219 /***********************************************/
220 /*** Presentation methods ***/
221 /***********************************************/
223 virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false ) const = 0;
226 virtual void constructAISObject() = 0;