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 //! Return unique section name
59 std::string getUniqSectionName(CurveCreator_ICurve* theCurve) const;
61 void setCurve( CurveCreator_ICurve* theCurve );
63 QList<int> getSelectedSections();
64 QList< QPair< int, int > > getSelectedPoints();
66 void removeSelected();
70 void selectionChanged();
71 void subOperationStarted( QWidget* );
72 void subOperationFinished( QWidget* );
77 void onAdditionMode(bool checked);
78 void onModificationMode(bool checked);
79 void onDetectionMode(bool checked);
80 void onModeChanged(bool checked);
82 void onSelectionChanged();
83 void onAddNewPoint(const CurveCreator::Coordinates& theCoords);
84 void onAddNewSection();
85 void onEditSection( int theSection );
86 void onModifySection();
87 void onCancelSection();
94 void onCloseSections();
95 void onUncloseSections();
98 void onUndoSettings();
99 void onContextMenu(QPoint thePoint);
100 void onGetCoordsByClick( QMouseEvent* );
102 void onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent );
103 void onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent );
104 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent );
105 void onLastViewClosed( SUIT_ViewManager* theManager );
107 void onCellChanged( int theRow, int theColumn );
110 enum ActionId{ UNDO_ID,
120 SET_SECTIONS_POLYLINE_ID,
121 SET_SECTIONS_SPLINE_ID,
124 MODIFICATION_MODE_ID,
135 typedef std::pair< int, int > SectionToPoint;
136 typedef std::deque< SectionToPoint > SectionToPointList;
139 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
140 const QString& theToolTip, const QKeySequence& theShortcut );
141 QAction* getAction(ActionId theId);
142 ActionMode getActionMode() const;
144 void updateUndoRedo();
146 void removeSection();
148 void insertPointToSelectedSegment( const int theXPosition,
149 const int theYPosition );
150 void moveSelectedPoints( const int theXPosition, const int theYPosition );
151 void updateLocalPointView();
152 void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
153 void addLocalPointToTable( const double theX, const double theY );
155 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
157 void getSelectedPonts( SectionToPointList& thePoints );
158 void setSelectedPonts( const SectionToPointList& = SectionToPointList() );
160 void startCurveModification( SectionToPointList& thePoints,
161 const bool theFillPoints = true );
162 void finishCurveModification( const SectionToPointList& thePoints = SectionToPointList() );
165 int findLocalPointIndex( int theSectionId, float theX, float theY );
166 void findSectionsToPoints( const double theX, const double theY,
167 SectionToPointList& thePoints );
168 void convert( const SectionToPointList& thePoints,
169 QMap<int, QList<int> >& theConvPoints );
172 bool pointOnObject( Handle(AIS_InteractiveObject) theObject,
173 const int theX, const int theY,
174 gp_Pnt& thePoint, gp_Pnt& thePoint1, gp_Pnt& thePoint2 );
175 bool hasProjectPointOnCurve( const int theX, const int theY,
176 const Handle(Geom_Curve)& theCurve,
177 Standard_Real& theParameter );
179 // local point view table methods
180 int getSectionId( const int theRowId ) const;
181 int getPointId( const int theRowId ) const;
183 bool contains( const SectionToPointList& theList, const SectionToPoint& theValue ) const;
186 QMap<ActionId, QAction*> myActionMap;
187 CurveCreator_ICurve* myCurve;
188 CurveCreator_TreeView* mySectionView;
189 QTableWidget* myLocalPointView;
190 CurveCreator_NewSectionDlg* myNewSectionEditor;
191 OCCViewer_Viewer* myOCCViewer;
195 QPoint myDragStartPosition;
196 int myDragInteractionStyle;
197 SectionToPointList myDragPoints;
199 QByteArray myGuiState;
202 #endif // CURVECREATOR_WIDGET_H