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 #include <Geom_Curve.hxx>
34 #include <V3d_View.hxx>
37 class OCCViewer_Viewer;
42 class CurveCreator_ICurve;
43 class CurveCreator_TreeView;
44 class CurveCreator_NewPointDlg;
45 class CurveCreator_NewSectionDlg;
47 class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
51 explicit CurveCreator_Widget( QWidget* parent,
52 CurveCreator_ICurve *theCurve,
53 Qt::WindowFlags fl=0 );
55 void setOCCViewer( OCCViewer_Viewer* theViewer );
56 OCCViewer_Viewer* getOCCViewer();
58 //virtual bool eventFilter( QObject* theWatched, QEvent* theEvent );
60 //! Return unique section name
61 std::string getUniqSectionName(CurveCreator_ICurve* theCurve) const;
63 void setCurve( CurveCreator_ICurve* theCurve );
65 QList<int> getSelectedSections();
66 QList< QPair< int, int > > getSelectedPoints();
69 void selectionChanged();
70 void subOperationStarted( QWidget* );
71 void subOperationFinished( QWidget* );
76 void onAdditionMode(bool checked);
77 void onModificationMode(bool checked);
78 void onDetectionMode(bool checked);
79 void onModeChanged(bool checked);
81 void onSelectionChanged();
82 void onAddNewPoint(const CurveCreator::Coordinates& theCoords);
83 void onAddNewSection();
84 void onEditSection( int theSection );
85 void onModifySection();
86 void onCancelSection();
93 void onCloseSections();
94 void onUncloseSections();
97 void onUndoSettings();
98 void onContextMenu(QPoint thePoint);
99 void onGetCoordsByClick( QMouseEvent* );
101 void onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent );
102 void onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent );
103 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent );
105 void onLocalPointChanged( int theRow, int theColumn );
108 enum ActionId{ UNDO_ID,
118 SET_SECTIONS_POLYLINE_ID,
119 SET_SECTIONS_SPLINE_ID,
122 MODIFICATION_MODE_ID,
134 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
135 const QString& theToolTip, const QKeySequence& theShortcut );
136 QAction* getAction(ActionId theId);
137 ActionMode getActionMode() const;
139 void updateUndoRedo();
141 void removeSection();
143 void insertPointToSelectedSegment( const int theXPosition,
144 const int theYPosition );
145 void moveSelectedPoints( const int theXPosition, const int theYPosition );
146 void updateLocalPointView();
147 void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
148 void addLocalPointToTable( const double theX, const double theY );
150 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
152 void getSelectedPonts( const int theSectionId, QList<int>& thePoints );
153 void setSelectedPonts( const int theSectionId, const QList<int>& thePoints = QList<int>() );
155 void startCurveModification( QList<int>& thePoints, const bool theFillPoints = true );
156 void finishCurveModification( const QList<int>& thePoints );
159 int findLocalPointIndex( int theSectionId, float theX, float theY );
160 void findSections( int thePointId, QList<int>& theSections );
163 bool pointOnObject( Handle(AIS_InteractiveObject) theObject,
164 const int theX, const int theY,
165 gp_Pnt& thePoint, int& thePoint1, int& thePoint2 );
166 bool hasProjectPointOnCurve( const int theX, const int theY,
167 const Handle(Geom_Curve)& theCurve,
168 Standard_Real& theParameter );
171 QMap<ActionId, QAction*> myActionMap;
172 CurveCreator_ICurve* myCurve;
173 CurveCreator_TreeView* mySectionView;
174 QTableWidget* myLocalPointView;
175 CurveCreator_NewSectionDlg* myNewSectionEditor;
176 OCCViewer_Viewer* myOCCViewer;
180 QPoint myDragStartPosition;
181 int myDragInteractionStyle;
182 QList<int> myDragPoints;
184 QByteArray myGuiState;
187 #endif // CURVECREATOR_WIDGET_H