]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROCurveCreator/CurveCreator_Widget.h
Salome HOME
82e5b732c2d3b0b828a998589cf28d1993d7e843
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Widget.h
1 // Copyright (C) 2013  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.
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_ICurve.hxx"
24 #include "CurveCreator.hxx"
25 #include "CurveCreator_Macro.hxx"
26
27 #include <QWidget>
28 #include <QMap>
29
30 #include <SUIT_ViewWindow.h>
31
32 class OCCViewer_Viewer;
33
34 class QAction;
35 class QPixmap;
36 class QTableWidget;
37 class CurveCreator_ICurve;
38 class CurveCreator_TreeView;
39 class CurveCreator_NewPointDlg;
40 class CurveCreator_NewSectionDlg;
41
42 class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
43 {
44     Q_OBJECT
45 public:
46     explicit CurveCreator_Widget( QWidget* parent,
47                       CurveCreator_ICurve *theCurve,
48                       Qt::WindowFlags fl=0 );
49
50     OCCViewer_Viewer* getOCCViewer();
51
52     //virtual bool eventFilter( QObject* theWatched, QEvent* theEvent );
53
54     //! Return unique section name
55     std::string getUniqSectionName(CurveCreator_ICurve* theCurve) const;
56
57     void setCurve( CurveCreator_ICurve* theCurve );
58
59     QList<int> getSelectedSections();
60     QList< QPair< int, int > > getSelectedPoints();
61
62 signals:
63     void selectionChanged();
64     void subOperationStarted( QWidget* );
65     void subOperationFinished( QWidget* );
66
67 public slots:
68
69 protected slots:
70     void     onAdditionMode(bool checked);
71     void     onModificationMode(bool checked);
72     void     onDetectionMode(bool checked);
73     void     onModeChanged(bool checked);
74     void     onNewSection();
75     void     onSelectionChanged();
76     void     onAddNewPoint(const CurveCreator::Coordinates& theCoords);
77     void     onAddNewSection();
78     void     onEditSection( int theSection );
79     void     onModifySection();
80     void     onCancelSection();
81     void     onJoin();
82     void     onRemove();
83     void     onClearAll();
84     void     onJoinAll();
85     void     onSetSpline();
86     void     onSetPolyline();
87     void     onCloseSections();
88     void     onUncloseSections();
89     void     onUndo();
90     void     onRedo();
91     void     onUndoSettings();
92     void     onContextMenu(QPoint thePoint);
93     void     onGetCoordsByClick( SUIT_ViewWindow*, QMouseEvent* );
94     void     onPointSelect( SUIT_ViewWindow*, QMouseEvent* );
95     void     onPointDrag( SUIT_ViewWindow*, QMouseEvent* );
96     void     onLocalPointChanged( int theRow, int theColumn );
97 protected:
98     enum ActionId{ UNDO_ID, 
99                    REDO_ID, 
100                    NEW_SECTION_ID, 
101                    ADDITION_MODE_ID, 
102                    REMOVE_ID, 
103                    REMOVE_ALL_ID, 
104                    JOIN_ID,
105                    JOIN_ALL_ID, 
106                    CLOSE_SECTIONS_ID, 
107                    UNCLOSE_SECTIONS_ID,
108                    SET_SECTIONS_POLYLINE_ID, 
109                    SET_SECTIONS_SPLINE_ID, 
110                    CLEAR_ALL_ID, 
111                    SEPARATOR_ID, 
112                    MODIFICATION_MODE_ID, 
113                    DETECTION_MODE_ID 
114     };
115 private:
116     QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
117                            const QString& theToolTip, const QKeySequence& theShortcut );
118     QAction* getAction(ActionId theId);
119     void     updateUndoRedo();
120     int      findLocalPointIndex( int theSectionId, float theX, float theY );
121     void     updateLocalPointView();
122     void     setLocalPointContext( const bool theOpen );
123     void     addLocalPointToTable( const double theX, const double theY );
124
125 private:
126     QMap<ActionId, QAction*>    myActionMap;
127     CurveCreator_ICurve*         myCurve;
128     CurveCreator_TreeView*      mySectionView;
129     QTableWidget*               myLocalPointView;
130     CurveCreator_NewSectionDlg* myNewSectionEditor;
131     int                         mySection;
132     int                         myPointNum;
133     QPoint                      myDragStartPosition;
134     QByteArray                  myGuiState;
135 };
136
137 #endif // CURVECREATOR_WIDGET_H