]> SALOME platform Git repositories - modules/geom.git/blob - src/CurveCreator/CurveCreator_CurveEditor.hxx
Salome HOME
CurveCreator was updated
[modules/geom.git] / src / CurveCreator / CurveCreator_CurveEditor.hxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:        CurveCreator_CurveEditor.hxx
24 // Created:     Mon Jun  24 14:33:40 2013
25 // Author:      Sergey KHROMOV
26 //
27
28 #ifndef _CurveCreator_CurveEditor_HeaderFile
29 #define _CurveCreator_CurveEditor_HeaderFile
30
31 #include <list>
32 #include <CurveCreator_Diff.hxx>
33 #include <CurveCreator_Curve.hxx>
34
35 /**
36  *  The CurveCreator_CurveEditor is designed to manage of
37  *  editing operations of CurveCreator_Curve class.
38  */
39 class CURVECREATOR_EXPORT CurveCreator_CurveEditor
40 {
41
42 private:
43
44   typedef std::list<CurveCreator_Diff> ListDiff;
45
46 public:
47
48   //! Constuctor, initialized by the curve object
49   CurveCreator_CurveEditor(CurveCreator_Curve* thePCurve);
50
51   //! Destructor, detaches from the Curve
52   ~CurveCreator_CurveEditor();
53
54   //! Returns the curve.
55   CurveCreator_Curve *getCurve() const;
56
57   //! This method returns true if this editor is attached to a valid curve.
58   bool isAttached() const;
59
60   //! Undo previous operation
61   void undo();
62
63   //! Redo last previously \93undoed\94 operation
64   void redo();
65
66   //! Get number of available undo operations
67   int getNbUndo() const;
68
69   //! Get number of available redo operations
70   int getNbRedo() const;
71
72   //! Set depth of undo operations (unlimited if \a theDepth is -1
73   //  or disabled if \a theDepth is 0)
74   void setUndoDepth(const int theDepth = -1);
75
76   //! Get depth of undo operations.
77   int getUndoDepth() const;
78
79   /** Set type of the specified section (or all sections
80    *  if \a theISection is -1).
81    */
82   void setType(const CurveCreator::Type theType, const int theISection = -1);
83
84   /** Set section closed (or all sections
85    *  if \a theISection is -1).
86    */
87   void setClosed(const bool theIsClosed, const int theISection);
88
89   /** Set section name (if theISection is invalid it is ignored).
90    */
91   void setName(const std::string& theName, const int theISection);
92
93   /** Add points to the specified section (or last section
94    *  if \a theISection is -1).
95    */
96   void addPoints(const CurveCreator::Coordinates &thePoints,
97                  const int theISection = -1);
98
99   //! Add a new section.
100   void addSection(const std::string &theName, const CurveCreator::Type theType,
101                   const bool theIsClosed,
102                   const CurveCreator::Coordinates &thePoints);
103
104   //! Removes the section. If theISection equals -1, removes the last section.
105   void removeSection(const int theISection = -1);
106
107   /** Insert points in the given position (add to the end of list
108    *  if \a theIPnt parameter is -1) of the specified section
109    *  (or last section if \a theISection parameter is -1).
110    */
111   void insertPoints(const CurveCreator::Coordinates &thePoints,
112                     const int theISection = -1,
113                     const int theIPnt = -1);
114
115   /** Remove \a nbPoints points from given \a theISection,
116    *  starting from given \a theIPnt (of all points up to the end of
117    *  section if \a theNbPoints is -1).
118    */
119   void removePoints(const int theISection,
120                     const int theIPnt,
121                     const int theNbPoints = -1);
122
123   /** Mobe point in \a theISection from given position \a theOrigIPnt
124    *  to new position \a theNewIPnt.
125    */
126   void movePoint(const int theISection,
127                   const int theOrigIPnt,
128                   const int theNewIPnt );
129
130   //! Remove all sections.
131   void clear();
132
133   //! Set coordinates of specified point
134   void setCoordinates(const CurveCreator::Coordinates &theCoords,
135                       const int theISection,
136                       const int theIPnt);
137
138   /** Move specified \a theISection to the specified position
139    *  in the sections list.
140    */
141   void moveSection(const int theISection, const int theNewIndex);
142
143   //! Join two sections to one section
144   void join(const int theISectionTo, const int theISectionFrom);
145
146   //! Join all sections to the single curve
147   void join();
148
149 private:
150
151   /** This method updates all undo/redo information required to be updated
152    *  after curve modification operation. It returns false if undo/redo
153    *  is disabled and true otherwise.
154    */
155   bool addEmptyDiff();
156
157 private:
158
159   int myNbUndos;
160   int myNbRedos;
161   ListDiff::iterator myCurrenPos;
162   ListDiff myListDiffs;
163   CurveCreator_Curve* myPCurve;
164   int myUndoDepth;
165
166 };
167
168 #endif