Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CurveCreator_Curve.hxx
Go to the documentation of this file.
1 // Copyright (C) 2013-2016 CEA/DEN, EDF R&D, 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 
26 #include "CurveCreator_ICurve.hxx"
27 
28 #include "CurveCreator_Macro.hxx"
29 #include "CurveCreator.hxx"
30 #include "CurveCreator_Diff.hxx"
31 
32 #include <list>
33 #include <map>
34 
37 class AIS_Shape;
39 
48 {
49 protected:
50  typedef std::list<CurveCreator_Diff> ListDiff;
51 
52 public:
54 
57  CurveCreator_Curve(const CurveCreator::Dimension theDimension);
58 
60  virtual ~CurveCreator_Curve();
61 
63  virtual CurveCreator::Dimension getDimension() const;
64 
66  virtual std::string getUniqSectionName() const;
67 
69  virtual void setDisplayer( CurveCreator_Displayer* theDisplayer );
70 
72  CurveCreator_Displayer* getDisplayer();
73 
75  virtual void removeDisplayer();
76 
80  virtual void setUndoDepth(const int theDepth = -1);
81 
83  virtual int getUndoDepth() const;
84 
85  virtual void startOperation();
86  virtual void finishOperation();
87 
92  virtual int toICoord(const int theIPnt) const;
93 
95  virtual bool moveSectionInternal(const int theISection,
96  const int theNewIndex);
98  virtual bool moveSection(const int theISection,
99  const int theNewIndex);
100 
101 protected:
106  virtual bool addEmptyDiff();
107 
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();
112 
113 public:
114  /************ Implementation of INTERFACE methods ************/
115 
116  /***********************************************/
117  /*** Undo/Redo methods ***/
118  /***********************************************/
119 
121  virtual int getNbUndo() const;
122 
124  virtual bool undo();
125 
127  virtual int getNbRedo() const;
128 
130  virtual bool redo();
131 
132 
133  /***********************************************/
134  /*** Section methods ***/
135  /***********************************************/
136 
138  virtual bool clearInternal();
140  virtual bool clear();
141 
143  virtual bool joinInternal( const std::list<int>& theSections );
144 
146  // The first section in the list is a leader, another sections are joined to it
147  virtual bool join( const std::list<int>& theSections );
148 
150  virtual int getNbSections() const;
151 
153  virtual int addSectionInternal( const std::string &theName,
154  const CurveCreator::SectionType theType,
155  const bool theIsClosed,
156  const CurveCreator::Coordinates &thePoints);
158  virtual int addSection( const std::string &theName,
159  const CurveCreator::SectionType theType,
160  const bool theIsClosed );
162  virtual int addSection( const std::string &theName,
163  const CurveCreator::SectionType theType,
164  const bool theIsClosed,
165  const CurveCreator::Coordinates &thePoints);
166 
168  virtual bool removeSectionInternal( const int theISection );
170  virtual bool removeSection( const int theISection );
171 
173  virtual bool isClosed( const int theISection ) const;
174 
176  virtual bool setClosedInternal( const int theISection,
177  const bool theIsClosed );
182  virtual bool setClosed( const int theISection,
183  const bool theIsClosed );
184 
186  virtual std::string getSectionName( const int theISection ) const;
187 
189  virtual bool setSectionNameInternal( const int theISection,
190  const std::string& theName );
192  virtual bool setSectionName( const int theISection,
193  const std::string& theName );
194 
196  virtual CurveCreator::SectionType getSectionType( const int theISection ) const;
197 
199  virtual bool setSectionTypeInternal( const int theISection,
200  const CurveCreator::SectionType theType );
205  virtual bool setSectionType( const int theISection,
206  const CurveCreator::SectionType theType );
207 
209  const CurveCreator_ISection* getSection(const int theSectionIndex) const
210  {
211  if (theSectionIndex >= 0 && theSectionIndex < mySections.size())
212  {
213  return (CurveCreator_ISection*)mySections[theSectionIndex];
214  }
215  return NULL;
216  }
217 
219  CurveCreator_ISection* getSection(const int theSectionIndex)
220  {
221  return (CurveCreator_ISection*)mySections[theSectionIndex];
222  }
223 
224  /***********************************************/
225  /*** Point methods ***/
226  /***********************************************/
227 
229  virtual bool addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap );
234  virtual bool addPoints( const CurveCreator::Coordinates &theCoords,
235  const int theISection,
236  const int theIPnt = -1 );
237 
239  virtual bool setPointInternal( const CurveCreator::SectionsMap &theSectionsMap );
241  virtual bool setPoint( const int theISection,
242  const int theIPnt,
243  const CurveCreator::Coordinates& theNewCoords );
244 
246  virtual bool setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
247  const bool theIsToSaveDiff = true );
248 
250  virtual bool removePointsInternal( const SectionToPointList &thePoints );
252  virtual bool removePoint( const int theISection, const int theIPnt = -1 );
253 
255  virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs);
256 
258  virtual CurveCreator::Coordinates getPoint( const int theISection,
259  const int theIPnt ) const;
260 
264  virtual CurveCreator::Coordinates getPoints( const int theISection = -1 ) const;
265 
266 
271  virtual int getNbPoints( const int theISection ) const;
272 
276  virtual void setSkipSorting( const bool theIsToSkip );
277 
281  virtual bool canPointsBeSorted();
282 
287  virtual void saveCoordDiff( const SectionToPointCoordsList &theOldCoords );
288 
289  /***********************************************/
290  /*** Presentation methods ***/
291  /***********************************************/
295  virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false ) const;
296 
297 protected:
304  bool removeSectionPoints( const int theSectionId,
305  const std::list<int>& thePointIds );
311  void convert( const SectionToPointList &thePoints,
312  std::map<int, std::list<int> > &theConvPoints );
313 
314 protected:
315  virtual void constructAISObject();
316 
317 protected:
318  bool mySkipSorting;
319 
320 public:
321  bool myIsLocked;
322  CurveCreator::Sections mySections;
323  CurveCreator::Dimension myDimension;
324  CurveCreator_Displayer* myDisplayer;
325 
326 private:
327 
328  int myNbUndos;
329  int myNbRedos;
330  ListDiff::iterator myCurrenPos;
331  ListDiff myListDiffs;
332  int myUndoDepth;
333  int myOpLevel;
334  AIS_Shape* myAISShape;
335 };
336 
337 #endif