1 // Copyright (C) 2013 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.
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 #ifndef CURVECREATOR_WIDGET_H
21 #define CURVECREATOR_WIDGET_H
23 //#include "CurveCreator_ICurve.hxx"
24 #include "CurveCreator.hxx"
25 #include "CurveCreator_Macro.hxx"
30 #include <SUIT_ViewWindow.h>
31 #include <AIS_InteractiveObject.hxx>
33 class OCCViewer_Viewer;
38 class CurveCreator_ICurve;
39 class CurveCreator_TreeView;
40 class CurveCreator_NewPointDlg;
41 class CurveCreator_NewSectionDlg;
43 class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
47 explicit CurveCreator_Widget( QWidget* parent,
48 CurveCreator_ICurve *theCurve,
49 Qt::WindowFlags fl=0 );
51 void setOCCViewer( OCCViewer_Viewer* theViewer );
52 OCCViewer_Viewer* getOCCViewer();
54 //virtual bool eventFilter( QObject* theWatched, QEvent* theEvent );
56 //! Return unique section name
57 std::string getUniqSectionName(CurveCreator_ICurve* theCurve) const;
59 void setCurve( CurveCreator_ICurve* theCurve );
61 QList<int> getSelectedSections();
62 QList< QPair< int, int > > getSelectedPoints();
65 void selectionChanged();
66 void subOperationStarted( QWidget* );
67 void subOperationFinished( QWidget* );
72 void onAdditionMode(bool checked);
73 void onModificationMode(bool checked);
74 void onDetectionMode(bool checked);
75 void onModeChanged(bool checked);
77 void onSelectionChanged();
78 void onAddNewPoint(const CurveCreator::Coordinates& theCoords);
79 void onAddNewSection();
80 void onEditSection( int theSection );
81 void onModifySection();
82 void onCancelSection();
89 void onCloseSections();
90 void onUncloseSections();
93 void onUndoSettings();
94 void onContextMenu(QPoint thePoint);
95 void onGetCoordsByClick( QMouseEvent* );
97 void onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent );
98 void onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent );
99 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent );
101 void onLocalPointChanged( int theRow, int theColumn );
104 enum ActionId{ UNDO_ID,
114 SET_SECTIONS_POLYLINE_ID,
115 SET_SECTIONS_SPLINE_ID,
118 MODIFICATION_MODE_ID,
130 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
131 const QString& theToolTip, const QKeySequence& theShortcut );
132 QAction* getAction(ActionId theId);
133 ActionMode getActionMode() const;
135 void updateUndoRedo();
137 void removeSection();
139 bool insertPointToSelectedSegment( const int theXPosition,
140 const int theYPosition );
141 void updateLocalPointView();
142 void setLocalPointContext( const bool theOpen );
143 void addLocalPointToTable( const double theX, const double theY );
145 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
147 void getSelectedPonts( const int theSectionId, QList<int>& thePoints );
148 void setSelectedPonts( const int theSectionId, const QList<int>& thePoints = QList<int>() );
152 int findLocalPointIndex( int theSectionId, float theX, float theY );
155 bool pointOnObject( Handle(AIS_InteractiveObject) theObject,
156 const int theX, const int theY,
157 gp_Pnt& thePoint, int& thePoint1, int& thePoint2 );
160 QMap<ActionId, QAction*> myActionMap;
161 CurveCreator_ICurve* myCurve;
162 CurveCreator_TreeView* mySectionView;
163 QTableWidget* myLocalPointView;
164 CurveCreator_NewSectionDlg* myNewSectionEditor;
165 OCCViewer_Viewer* myOCCViewer;
169 QList<int> myDragPoints;
170 QPoint myDragStartPosition;
171 QByteArray myGuiState;
174 #endif // CURVECREATOR_WIDGET_H