1 // Copyright (C) 2013-2014 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_CurveEditor.hxx
21 // Author: Sergey KHROMOV
23 #ifndef _CurveCreator_CurveEditor_HeaderFile
24 #define _CurveCreator_CurveEditor_HeaderFile
26 #include "CurveCreator_Diff.hxx"
27 #include "CurveCreator_Curve.hxx"
32 * The CurveCreator_CurveEditor is designed to manage of
33 * editing operations of CurveCreator_Curve class.
35 class CURVECREATOR_EXPORT CurveCreator_CurveEditor
40 typedef std::list<CurveCreator_Diff> ListDiff;
44 //! Constuctor, initialized by the curve object
45 CurveCreator_CurveEditor(CurveCreator_Curve* thePCurve);
47 //! Destructor, detaches from the Curve
48 ~CurveCreator_CurveEditor();
50 //! Returns the curve.
51 CurveCreator_Curve *getCurve() const;
53 //! This method returns true if this editor is attached to a valid curve.
54 bool isAttached() const;
56 //! Undo previous operation
59 //! Redo last previously �undoed� operation
62 //! Get number of available undo operations
63 int getNbUndo() const;
65 //! Get number of available redo operations
66 int getNbRedo() const;
68 //! Set depth of undo operations (unlimited if \a theDepth is -1
69 // or disabled if \a theDepth is 0)
70 void setUndoDepth(const int theDepth = -1);
72 //! Get depth of undo operations.
73 int getUndoDepth() const;
75 /** Set type of the specified section (or all sections
76 * if \a theISection is -1).
78 void setType(const CurveCreator::Type theType, const int theISection = -1);
80 /** Set section closed (or all sections
81 * if \a theISection is -1).
83 void setClosed(const bool theIsClosed, const int theISection);
85 /** Set section name (if theISection is invalid it is ignored).
87 void setName(const std::string& theName, const int theISection);
89 /** Add points to the specified section (or last section
90 * if \a theISection is -1).
92 void addPoints(const CurveCreator::Coordinates &thePoints,
93 const int theISection = -1);
95 //! Add a new section.
96 void addSection(const std::string &theName, const CurveCreator::Type theType,
97 const bool theIsClosed,
98 const CurveCreator::Coordinates &thePoints);
100 //! Removes the section. If theISection equals -1, removes the last section.
101 void removeSection(const int theISection = -1);
103 /** Insert points in the given position (add to the end of list
104 * if \a theIPnt parameter is -1) of the specified section
105 * (or last section if \a theISection parameter is -1).
107 void insertPoints(const CurveCreator::Coordinates &thePoints,
108 const int theISection = -1,
109 const int theIPnt = -1);
111 /** Remove \a nbPoints points from given \a theISection,
112 * starting from given \a theIPnt (of all points up to the end of
113 * section if \a theNbPoints is -1).
115 void removePoints(const int theISection,
117 const int theNbPoints = -1);
119 /** Mobe point in \a theISection from given position \a theOrigIPnt
120 * to new position \a theNewIPnt.
122 void movePoint(const int theISection,
123 const int theOrigIPnt,
124 const int theNewIPnt );
126 //! Remove all sections.
129 //! Set coordinates of specified point
130 void setCoordinates(const CurveCreator::Coordinates &theCoords,
131 const int theISection,
134 /** Move specified \a theISection to the specified position
135 * in the sections list.
137 void moveSection(const int theISection, const int theNewIndex);
139 //! Join two sections to one section
140 void join(const int theISectionTo, const int theISectionFrom);
142 //! Join all sections to the single curve
145 void startOperation();
146 void finishOperation();
149 /** This method updates all undo/redo information required to be updated
150 * after curve modification operation. It returns false if undo/redo
151 * is disabled and true otherwise.
159 ListDiff::iterator myCurrenPos;
160 ListDiff myListDiffs;
161 CurveCreator_Curve* myPCurve;