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 Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theDimension ) const = 0;
66 * The CurveCreator_ICurve object is represented as one or more sets of
67 * connected points; thus CurveCreator_ICurve object can contain several
68 * not connected curves (polylines or b-splines), each such curve has two
69 * only ends "start and end points" in other words non-manifold curves
72 class CURVECREATOR_EXPORT CurveCreator_ICurve
75 typedef std::pair<int,int> SectionToPoint;
76 typedef std::deque<SectionToPoint> SectionToPointList;
78 typedef std::deque< std::pair< SectionToPoint, CurveCreator::Coordinates > > SectionToPointCoordsList;
81 /***********************************************/
82 /*** Undo/Redo methods ***/
83 /***********************************************/
86 virtual ~CurveCreator_ICurve() {}
88 //! Get number of available undo operations
89 virtual int getNbUndo() const = 0;
91 //! Undo previous operation
92 virtual bool undo() = 0;
94 //! Get number of available redo operations
95 virtual int getNbRedo() const = 0;
97 //! Redo last previously "undone" operation
98 virtual bool redo() = 0;
101 /***********************************************/
102 /*** Section methods ***/
103 /***********************************************/
105 //! Clear the polyline (remove all sections)
106 virtual bool clear() = 0;
108 //! Join list of sections to one section (join all if the list is empty)
109 // The first section in the list is a leader, another sections are joined to it
110 virtual bool join( const std::list<int>& theSections ) = 0;
112 //! Get number of sections
113 virtual int getNbSections() const = 0;
115 //! Add a new section.
116 virtual int addSection( const std::string& theName,
117 const CurveCreator::SectionType theType,
118 const bool theIsClosed ) = 0;
120 //! Removes the given sections.
121 virtual bool removeSection( const int theISection ) = 0;
123 //! Get "closed" flag of the specified section
124 virtual bool isClosed( const int theISection ) const = 0;
127 * Set "closed" flag of the specified section (all sections if
128 * \a theISection is -1).
130 virtual bool setClosed( const int theISection,
131 const bool theIsClosed ) = 0;
133 //! Returns specifyed section name
134 virtual std::string getSectionName( const int theISection ) const = 0;
136 /** Set name of the specified section */
137 virtual bool setSectionName( const int theISection,
138 const std::string& theName ) = 0;
140 //! Get type of the specified section
141 virtual CurveCreator::SectionType getSectionType( const int theISection ) const = 0;
144 * Set type of the specified section (or all sections
145 * if \a theISection is -1).
147 virtual bool setSectionType( const int theISection,
148 const CurveCreator::SectionType theType ) = 0;
150 //! Returns the curve section with the index.
151 virtual const CurveCreator_ISection* getSection(
152 const int theSectionIndex) const = 0;
154 //! Returns the curve section with the index.
155 virtual CurveCreator_ISection* getSection(const int theSectionIndex) = 0;
158 /***********************************************/
159 /*** Point methods ***/
160 /***********************************************/
162 //! Get the dimension.
163 virtual CurveCreator::Dimension getDimension() const = 0;
166 * Insert one or several points to the specified section starting from the given theIPnt index
167 * (or add these at the end of section points if \a theIPnt is -1).
169 virtual bool addPoints( const CurveCreator::Coordinates& theCoords,
170 const int theISection,
171 const int theIPnt = -1 ) = 0;
173 //! Set coordinates of specified point
174 virtual bool setPoint( const int theISection,
176 const CurveCreator::Coordinates& theNewCoords ) = 0;
178 //! Set coordinates of specified points from different sections
179 virtual bool setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
180 const bool theIsToSaveDiff = true ) = 0;
182 //! Remove point with given id
183 virtual bool removePoint( const int theISection, const int theIPnt = -1 ) = 0;
184 //! Remove several points from different sections
185 virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs) = 0;
187 //! Get coordinates of specified point
188 virtual CurveCreator::Coordinates getPoint( const int theISection,
189 const int theIPnt ) const = 0;
192 * Get points of a section (the total points in Curve if theISection is equal to -1)..
194 virtual Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theISection = -1 ) const = 0;
197 * Get number of points in specified section or (the total number of points
198 * in Curve if theISection is equal to -1).
200 virtual int getNbPoints( const int theISection ) const = 0;
203 * Set skip sorting flag. If the flag is true - points sorting will be skipped.
205 virtual void setSkipSorting( const bool ) = 0;
208 * Indicates whether the points can be sorted.
210 virtual bool canPointsBeSorted() = 0;
213 * Saves points coordinates difference.
214 * \param theOldCoords the old points coordinates
216 virtual void saveCoordDiff( const SectionToPointCoordsList &theOldCoords ) = 0;
218 /***********************************************/
219 /*** Presentation methods ***/
220 /***********************************************/
222 virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false ) const = 0;
225 virtual void constructAISObject() = 0;