Version: 9.16.0
CurveCreator_Curve.hxx
Go to the documentation of this file.
1// Copyright (C) 2013-2026 CEA, EDF, OPEN CASCADE
2//
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.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20// File: CurveCreator_Curve.hxx
21// Author: Sergey KHROMOV
22
23#ifndef _CurveCreator_Curve_HeaderFile
24#define _CurveCreator_Curve_HeaderFile
25
27
29#include "CurveCreator.hxx"
30#include "CurveCreator_Diff.hxx"
31
32#include <list>
33#include <map>
34#include <NCollection_IndexedDataMap.hxx>
35
38class AIS_Shape;
40class Quantity_Color;
41class TopoDS_Shape;
42
51{
52protected:
53 typedef std::list<CurveCreator_Diff> ListDiff;
54
55public:
57
61
63 virtual ~CurveCreator_Curve();
64
67
69 virtual std::string getUniqSectionName() const;
70
72 virtual void setDisplayer( CurveCreator_Displayer* theDisplayer );
73
75 CurveCreator_Displayer* getDisplayer();
76
78 virtual void removeDisplayer();
79
83 virtual void setUndoDepth(const int theDepth = -1);
84
86 virtual int getUndoDepth() const;
87
88 virtual void startOperation();
89 virtual void finishOperation();
90
95 virtual int toICoord(const int theIPnt) const;
96
98 virtual bool moveSectionInternal(const int theISection,
99 const int theNewIndex);
101 virtual bool moveSection(const int theISection,
102 const int theNewIndex);
103
104protected:
109 virtual bool addEmptyDiff();
110
111public: // TODO: remove public
112 void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
113protected: // TODO
114 void redisplayCurve(bool preEraseAllObjects = true);
115
116public:
117 /************ Implementation of INTERFACE methods ************/
118
119 /***********************************************/
120 /*** Undo/Redo methods ***/
121 /***********************************************/
122
124 virtual int getNbUndo() const;
125
127 virtual bool undo();
128
130 virtual int getNbRedo() const;
131
133 virtual bool redo();
134
135
136 /***********************************************/
137 /*** Section methods ***/
138 /***********************************************/
139
141 virtual bool clearInternal();
143 virtual bool clear();
144
147 void SetEraseAllState(bool toEraseAll);
148
151 bool GetEraseAllState() const;
152
154 virtual bool joinInternal( const std::list<int>& theSections );
155
157 // The first section in the list is a leader, another sections are joined to it
158 virtual bool join( const std::list<int>& theSections );
159
161 virtual int getNbSections() const;
162
164 virtual int addSectionInternal( const std::string &theName,
165 const CurveCreator::SectionType theType,
166 const bool theIsClosed,
167 const CurveCreator::Coordinates &thePoints,
168 const Quantity_Color& aColor);
170 virtual int addSection( const std::string &theName,
171 const CurveCreator::SectionType theType,
172 const bool theIsClosed );
174 virtual int addSection( const std::string &theName,
175 const CurveCreator::SectionType theType,
176 const bool theIsClosed,
177 const CurveCreator::Coordinates &thePoints);
178
180 virtual bool removeSectionInternal( const int theISection );
182 virtual bool removeSection( const int theISection );
183
185 virtual bool isClosed( const int theISection ) const;
186
188 virtual bool setClosedInternal( const int theISection,
189 const bool theIsClosed );
194 virtual bool setClosed( const int theISection,
195 const bool theIsClosed );
196
198 virtual bool setColorSection( int SectInd, Quantity_Color theNewColor );
199
201 virtual void setColorSectionInternal( int SectInd, Quantity_Color theNewColor );
202
203 virtual Quantity_Color getLastRemovedColor() const;
204
205 virtual void popLastRemovedColor();
206
208 virtual Quantity_Color getColorSection( int SectInd ) const;
209
211 virtual std::string getSectionName( const int theISection ) const;
212
214 virtual bool setSectionNameInternal( const int theISection,
215 const std::string& theName );
217 virtual bool setSectionName( const int theISection,
218 const std::string& theName );
219
221 virtual CurveCreator::SectionType getSectionType( const int theISection ) const;
222
224 virtual bool setSectionTypeInternal( const int theISection,
225 const CurveCreator::SectionType theType );
230 virtual bool setSectionType( const int theISection,
231 const CurveCreator::SectionType theType );
232
234 const CurveCreator_ISection* getSection(const int theSectionIndex) const
235 {
236 if (theSectionIndex >= 0 && theSectionIndex < (int)mySections.size())
237 {
238 return (CurveCreator_ISection*)mySections[theSectionIndex];
239 }
240 return NULL;
241 }
242
244 CurveCreator_ISection* getSection(const int theSectionIndex)
245 {
246 return (CurveCreator_ISection*)mySections[theSectionIndex];
247 }
248
249 /***********************************************/
250 /*** Point methods ***/
251 /***********************************************/
252
254 virtual bool addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap );
259 virtual bool addPoints( const CurveCreator::Coordinates &theCoords,
260 const int theISection,
261 const int theIPnt = -1 );
262
264 virtual bool setPointInternal( const CurveCreator::SectionsMap &theSectionsMap );
266 virtual bool setPoint( const int theISection,
267 const int theIPnt,
268 const CurveCreator::Coordinates& theNewCoords );
269
271 virtual bool setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
272 const bool theIsToSaveDiff = true );
273
275 virtual bool removePointsInternal( const SectionToPointList &thePoints );
277 virtual bool removePoint( const int theISection, const int theIPnt = -1 );
278
280 virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs);
281
283 virtual CurveCreator::Coordinates getPoint( const int theISection,
284 const int theIPnt ) const;
285
289 virtual Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theISection = -1 ) const;
290
291 CurveCreator::Coordinates getCoords( int theISection = -1 ) const;
292
293
298 virtual int getNbPoints( const int theISection ) const;
299
303 virtual void setSkipSorting( const bool theIsToSkip );
304
308 virtual bool canPointsBeSorted();
309
314 virtual void saveCoordDiff( const SectionToPointCoordsList &theOldCoords );
315
316 /***********************************************/
317 /*** Presentation methods ***/
318 /***********************************************/
322 virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false) const;
323
324protected:
331 bool removeSectionPoints( const int theSectionId,
332 const std::list<int>& thePointIds );
338 void convert( const SectionToPointList &thePoints,
339 std::map<int, std::list<int> > &theConvPoints );
340
341protected:
342 virtual void constructAISObject();
343
344protected:
346 AIS_Shape* myAISShape;
347
348public:
353 Quantity_Color myPointAspectColor;
354 //Quantity_Color myCurveColor;
356 NCollection_IndexedDataMap<int, TopoDS_Shape> mySect2Shape;
357 std::vector<int> myCurSectInd;
358
359private:
360
363 ListDiff::iterator myCurrenPos;
368 std::vector<Quantity_Color> myRemColors;
369};
370
371#endif
#define CURVECREATOR_EXPORT
Definition: CurveCreator_Macro.hxx:41
The CurveCreator_Curve object is represented as one or more sets of connected points; thus CurveCreat...
Definition: CurveCreator_Curve.hxx:51
CurveCreator::Dimension myDimension
curve dimension
Definition: CurveCreator_Curve.hxx:351
CurveCreator_Displayer * myDisplayer
curve displayer
Definition: CurveCreator_Curve.hxx:352
int myNbRedos
Definition: CurveCreator_Curve.hxx:362
virtual Handle(AIS_InteractiveObject) getAISObject(const bool theNeedToBuild
Get the curve AIS object.
int myUndoDepth
Definition: CurveCreator_Curve.hxx:365
std::list< CurveCreator_Diff > ListDiff
Definition: CurveCreator_Curve.hxx:53
bool mySkipSorting
Definition: CurveCreator_Curve.hxx:345
bool myIsLocked
Definition: CurveCreator_Curve.hxx:349
std::vector< int > myCurSectInd
Definition: CurveCreator_Curve.hxx:357
int myNbUndos
Definition: CurveCreator_Curve.hxx:361
AIS_Shape * myAISShape
AIS shape.
Definition: CurveCreator_Curve.hxx:346
virtual void constructAISObject()
CurveCreator::Sections mySections
curve data
Definition: CurveCreator_Curve.hxx:350
virtual Handle(TColgp_HArray1OfPnt) GetDifferentPoints(int theISection
Get points of a section (the total points in Curve if theISection is equal to -1).
int myOpLevel
Definition: CurveCreator_Curve.hxx:366
std::vector< Quantity_Color > myRemColors
Definition: CurveCreator_Curve.hxx:368
ListDiff::iterator myCurrenPos
Definition: CurveCreator_Curve.hxx:363
ListDiff myListDiffs
Definition: CurveCreator_Curve.hxx:364
NCollection_IndexedDataMap< int, TopoDS_Shape > mySect2Shape
Definition: CurveCreator_Curve.hxx:356
bool myEraseAll
Definition: CurveCreator_Curve.hxx:367
Quantity_Color myPointAspectColor
Definition: CurveCreator_Curve.hxx:353
bool removeSectionPoints(const int theSectionId, const std::list< int > &thePointIds)
Removes the points from the section.
double myLineWidth
Definition: CurveCreator_Curve.hxx:355
CurveCreator_ISection * getSection(const int theSectionIndex)
A virtual method.
Definition: CurveCreator_Curve.hxx:244
const CurveCreator_ISection * getSection(const int theSectionIndex) const
A virtual method.
Definition: CurveCreator_Curve.hxx:234
Definition: CurveCreator_Displayer.hxx:31
The CurveCreator_ICurve object is represented as one or more sets of connected points; thus CurveCrea...
Definition: CurveCreator_ICurve.hxx:73
virtual int getNbUndo() const =0
Get number of available undo operations.
virtual bool setSectionName(const int theISection, const std::string &theName)=0
Set name of the specified section.
virtual bool redo()=0
Redo last previously "undone" operation.
virtual bool join(const std::list< int > &theSections)=0
Join list of sections to one section (join all if the list is empty)
virtual bool removeSection(const int theISection)=0
Removes the given sections.
std::deque< SectionToPoint > SectionToPointList
Definition: CurveCreator_ICurve.hxx:76
virtual bool setSeveralPoints(const SectionToPointCoordsList &theSectionToPntCoords, const bool theIsToSaveDiff=true)=0
Set coordinates of specified points from different sections.
virtual int getNbPoints(const int theISection) const =0
Get number of points in specified section or (the total number of points in Curve if theISection is e...
virtual bool isClosed(const int theISection) const =0
Get "closed" flag of the specified section.
virtual int getNbRedo() const =0
Get number of available redo operations.
virtual void setSkipSorting(const bool)=0
Set skip sorting flag.
virtual CurveCreator::SectionType getSectionType(const int theISection) const =0
Get type of the specified section.
virtual bool undo()=0
Undo previous operation.
virtual bool setPoint(const int theISection, const int theIPnt, const CurveCreator::Coordinates &theNewCoords)=0
Set coordinates of specified point.
virtual bool canPointsBeSorted()=0
Indicates whether the points can be sorted.
virtual CurveCreator::Coordinates getPoint(const int theISection, const int theIPnt) const =0
Get coordinates of specified point.
virtual bool addPoints(const CurveCreator::Coordinates &theCoords, const int theISection, const int theIPnt=-1)=0
Insert one or several points to the specified section starting from the given theIPnt index (or add t...
virtual int getNbSections() const =0
Get number of sections.
virtual std::string getSectionName(const int theISection) const =0
Returns specifyed section name.
virtual int addSection(const std::string &theName, const CurveCreator::SectionType theType, const bool theIsClosed)=0
Add a new section.
virtual bool setClosed(const int theISection, const bool theIsClosed)=0
Set "closed" flag of the specified section (all sections if theISection is -1).
virtual bool setSectionType(const int theISection, const CurveCreator::SectionType theType)=0
Set type of the specified section (or all sections if theISection is -1).
std::deque< std::pair< SectionToPoint, CurveCreator::Coordinates > > SectionToPointCoordsList
Definition: CurveCreator_ICurve.hxx:78
virtual bool removePoint(const int theISection, const int theIPnt=-1)=0
Remove point with given id.
virtual bool removeSeveralPoints(const SectionToPointList &theSectionToPntIDs)=0
Remove several points from different sections.
virtual bool clear()=0
Clear the polyline (remove all sections)
virtual CurveCreator::Dimension getDimension() const =0
Get the dimension.
virtual void saveCoordDiff(const SectionToPointCoordsList &theOldCoords)=0
Saves points coordinates difference.
std::map< int, PosPointsList > SectionsMap
Map of sections with positioned points.
Definition: CurveCreator.hxx:50
Dimension
Dimension of the curve.
Definition: CurveCreator_ICurve.hxx:48
std::deque< TypeCoord > Coordinates
List of coordinates in format depends on section dimension: 2D: [x1, y1, x2, y2, x3,...
Definition: CurveCreator.hxx:42
std::deque< CurveCreator_Section * > Sections
List of sections.
Definition: CurveCreator.hxx:45
SectionType
Type of the section.
Definition: CurveCreator_ICurve.hxx:41
The type represents the interface to the curve section.
Definition: CurveCreator_ICurve.hxx:57
Structure to store sections representing the CurveCreator_Curve object.
Definition: CurveCreator_Section.hxx:34