Salome HOME
Revert "Synchronize adm files"
[modules/geom.git] / src / CurveCreator / CurveCreator_Widget.h
1 // Copyright (C) 2013-2014  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 #ifndef CURVECREATOR_WIDGET_H
21 #define CURVECREATOR_WIDGET_H
22
23 #include "CurveCreator_Curve.hxx"
24 #include "CurveCreator.hxx"
25
26 #include <QWidget>
27 #include <QMap>
28
29 #include <SUIT_ViewWindow.h>
30
31 class QAction;
32 class QPixmap;
33 class CurveCreator_CurveEditor;
34 class CurveCreator_TreeView;
35 class CurveCreator_NewPointDlg;
36 class CurveCreator_NewSectionDlg;
37
38 class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
39 {
40     Q_OBJECT
41 public:
42     explicit CurveCreator_Widget( QWidget* parent,
43                       CurveCreator_Curve *theCurve,
44                       Qt::WindowFlags fl=0 );
45
46     void setCurve( CurveCreator_Curve* theCurve );
47
48     QList<int> getSelectedSections();
49     QList< QPair< int, int > > getSelectedPoints();
50
51     bool isInstantSketchingEnabled() const;
52     void setInstantSketchingEnabled( const bool theState );
53
54 signals:
55     void selectionChanged();
56     void subOperationStarted( QWidget* );
57     void subOperationFinished( QWidget* );
58
59 public slots:
60
61 protected slots:
62     void     onAdditionMode(bool checked);
63     void     onModificationMode(bool checked);
64     void     onDetectPoints(bool checked);
65     void     onModeChanged(bool checked);
66     void     onNewSection();
67     void     onSelectionChanged();
68     void     onAddNewPoint(const CurveCreator::Coordinates& theCoords);
69     void     onAddNewSection();
70     void     onEditSection( int theSection );
71     void     onEditPoint( int theSection, int thePoint );
72     void     onModifyPoint();
73     void     onModifySection();
74     void     onCancelPoint();
75     void     onCancelSection();
76     void     onJoin();
77     void     onRemove();
78     void     onMoveUp();
79     void     onMoveDown();
80     void     onClearAll();
81     void     onJoinAll();
82     void     onInsertSectionBefore();
83     void     onInsertSectionAfter();
84     void     onSetSpline();
85     void     onSetPolyline();
86     void     onCloseSections();
87     void     onUncloseSections();
88     void     onInsertPointBefore();
89     void     onInsertPointAfter();
90     void     onUndo();
91     void     onRedo();
92     void     onUndoSettings();
93     void     onContextMenu(QPoint thePoint);
94     void     onGetPointByClick( SUIT_ViewWindow*, QMouseEvent* );
95 //    void     onPointSelect( SUIT_ViewWindow*, QMouseEvent* );
96     void     onPointDrag( SUIT_ViewWindow*, QMouseEvent* );
97 protected:
98     enum ActionId{ UNDO_ID, REDO_ID, NEW_SECTION_ID, ADDITION_MODE_ID, REMOVE_ID, REMOVE_ALL_ID, JOIN_ID,
99                    JOIN_ALL_ID, UP_ID, DOWN_ID, INSERT_SECTION_BEFORE_ID, INSERT_SECTION_AFTER_ID,
100                    INSERT_POINT_BEFORE_ID, INSERT_POINT_AFTER_ID, CLOSE_SECTIONS_ID, UNCLOSE_SECTIONS_ID,
101                    SET_SECTIONS_POLYLINE_ID, SET_SECTIONS_SPLINE_ID, CLEAR_ALL_ID, SEPARATOR_ID, 
102                    MODIFICATION_MODE_ID, DETECTION_MODE_ID };
103 private:
104     QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
105                            const QString& theToolTip, const QKeySequence& theShortcut );
106     QAction* getAction(ActionId theId);
107     void     updateUndoRedo();
108 private:
109     QMap<ActionId, QAction*>    myActionMap;
110     CurveCreator_Curve*         myCurve;
111     CurveCreator_CurveEditor*   myEdit;
112     CurveCreator_TreeView*      mySectionView;
113     CurveCreator_NewPointDlg*   myNewPointEditor;
114     CurveCreator_NewSectionDlg* myNewSectionEditor;
115     int                         mySection;
116     int                         myPointNum;
117     QPoint                      myDragStartPosition;
118 };
119
120 #endif // CURVECREATOR_WIDGET_H