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>
32 #include <AIS_InteractiveContext.hxx>
34 #include <Geom_Curve.hxx>
35 #include <V3d_View.hxx>
38 class OCCViewer_Viewer;
39 class OCCViewer_ViewPort3d;
40 class OCCViewer_ViewWidget;
42 class AIS_ListOfInteractive;
47 class CurveCreator_ICurve;
48 class CurveCreator_TreeView;
49 class CurveCreator_NewPointDlg;
50 class CurveCreator_NewSectionDlg;
52 class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
56 explicit CurveCreator_Widget( QWidget* parent,
57 CurveCreator_ICurve *theCurve,
58 Qt::WindowFlags fl=0 );
60 // OCC viewer manipulation
61 void setOCCViewer( OCCViewer_Viewer* theViewer );
62 void setOCCViewWidget( OCCViewer_ViewWidget* theViewWidget );
64 Handle(AIS_InteractiveContext) getAISContext();
65 OCCViewer_ViewPort3d* getViewPort();
66 int changeInteractionStyle( int theStyle );
67 void setObjectsSelected(const AIS_ListOfInteractive& theList);
69 //! Return unique section name
70 std::string getUniqSectionName(CurveCreator_ICurve* theCurve) const;
72 void setCurve( CurveCreator_ICurve* theCurve );
74 QList<int> getSelectedSections();
75 QList< QPair< int, int > > getSelectedPoints();
77 void removeSelected();
81 void selectionChanged();
82 void subOperationStarted( QWidget* );
83 void subOperationFinished( QWidget* );
88 void onAdditionMode(bool checked);
89 void onModificationMode(bool checked);
90 void onDetectionMode(bool checked);
91 void onModeChanged(bool checked);
93 void onSelectionChanged();
94 void onAddNewPoint(const CurveCreator::Coordinates& theCoords);
95 void onAddNewSection();
96 void onEditSection( int theSection );
97 void onModifySection();
98 void onCancelSection();
104 void onSetPolyline();
105 void onCloseSections();
106 void onUncloseSections();
109 void onUndoSettings();
110 void onContextMenu(QPoint thePoint);
111 void onGetCoordsByClick( QMouseEvent* );
113 void onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent );
114 void onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent );
115 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent );
116 void onLastViewClosed( SUIT_ViewManager* theManager );
118 void onMousePress( QMouseEvent* theEvent );
119 void onMouseRelease( QMouseEvent* theEvent );
120 void onMouseMove( QMouseEvent* theEvent );
122 void onCellChanged( int theRow, int theColumn );
125 enum ActionId{ UNDO_ID,
135 SET_SECTIONS_POLYLINE_ID,
136 SET_SECTIONS_SPLINE_ID,
139 MODIFICATION_MODE_ID,
150 typedef std::pair< int, int > SectionToPoint;
151 typedef std::deque< SectionToPoint > SectionToPointList;
154 OCCViewer_Viewer* getOCCViewer();
155 OCCViewer_ViewWidget* getOCCViewWidget();
157 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
158 const QString& theToolTip, const QKeySequence& theShortcut );
159 QAction* getAction(ActionId theId);
160 ActionMode getActionMode() const;
162 void updateUndoRedo();
164 void removeSection();
166 void insertPointToSelectedSegment( const int theXPosition,
167 const int theYPosition );
168 void moveSelectedPoints( const int theXPosition, const int theYPosition );
169 void updateLocalPointView();
170 void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
171 void addLocalPointToTable( const double theX, const double theY );
173 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
175 void getSelectedPonts( SectionToPointList& thePoints );
176 void setSelectedPonts( const SectionToPointList& = SectionToPointList() );
178 void startCurveModification( SectionToPointList& thePoints,
179 const bool theFillPoints = true );
180 void finishCurveModification( const SectionToPointList& thePoints = SectionToPointList() );
183 int findLocalPointIndex( int theSectionId, float theX, float theY );
184 void findSectionsToPoints( const double theX, const double theY,
185 SectionToPointList& thePoints );
186 void convert( const SectionToPointList& thePoints,
187 QMap<int, QList<int> >& theConvPoints );
190 bool pointOnObject( Handle(AIS_InteractiveObject) theObject,
191 const int theX, const int theY,
192 gp_Pnt& thePoint, gp_Pnt& thePoint1, gp_Pnt& thePoint2 );
193 bool hasProjectPointOnCurve( const int theX, const int theY,
194 const Handle(Geom_Curve)& theCurve,
195 Standard_Real& theParameter );
197 // local point view table methods
198 int getSectionId( const int theRowId ) const;
199 int getPointId( const int theRowId ) const;
201 bool contains( const SectionToPointList& theList, const SectionToPoint& theValue ) const;
204 QMap<ActionId, QAction*> myActionMap;
205 CurveCreator_ICurve* myCurve;
206 CurveCreator_TreeView* mySectionView;
207 QTableWidget* myLocalPointView;
208 CurveCreator_NewSectionDlg* myNewSectionEditor;
209 OCCViewer_Viewer* myOCCViewer;
210 OCCViewer_ViewWidget* myOCCViewWidget;
214 QPoint myDragStartPosition;
215 int myDragInteractionStyle;
216 SectionToPointList myDragPoints;
218 QByteArray myGuiState;
221 #endif // CURVECREATOR_WIDGET_H