1 // Copyright (C) 2013-2015 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, or (at your option) any later version.
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_Macro.hxx"
24 #include "CurveCreator.hxx"
25 #include "CurveCreator_ICurve.hxx"
30 #include <OCCViewer_ViewWindow.h>
31 #include <SUIT_ViewWindow.h>
32 #include <AIS_InteractiveObject.hxx>
33 #include <AIS_InteractiveContext.hxx>
35 #include <Geom_Curve.hxx>
36 #include <V3d_View.hxx>
38 #include <TopoDS_Vertex.hxx> // TODO - remove
40 class OCCViewer_Viewer;
41 class OCCViewer_ViewPort3d;
43 class AIS_ListOfInteractive;
47 class CurveCreator_TableView;
48 class CurveCreator_TreeView;
49 class CurveCreator_NewSectionDlg;
51 class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
58 DisableDetectionMode = 0x00000001,
59 DisableNewSection = 0x00000002,
60 DisableClosedSection = 0x00000004
71 explicit CurveCreator_Widget( QWidget* parent,
72 CurveCreator_ICurve *theCurve,
73 const int theActionFlags = NoFlags,
74 const QStringList& theCoordTitles = QStringList(),
76 int theLocalPointRowLimit = 20);
78 // OCC viewer manipulation
79 void setOCCViewer( OCCViewer_Viewer* theViewer );
81 Handle(AIS_InteractiveContext) getAISContext();
82 OCCViewer_ViewPort3d* getViewPort();
83 int changeInteractionStyle( int theStyle );
86 void setCurve( CurveCreator_ICurve* theCurve );
88 QList<int> getSelectedSections();
89 void setSelectedSections( const QList<int>& theSections );
91 void removeSelected();
94 void setActionMode( const ActionMode& theMode );
95 ActionMode getActionMode() const;
97 void SetViewer2DMode(const bool To2D);
100 void selectionChanged();
101 void subOperationStarted( QWidget*, bool );
102 void subOperationFinished( QWidget* );
107 void onAdditionMode(bool checked);
108 void onModificationMode(bool checked);
109 void onDetectionMode(bool checked);
110 void onModeChanged(bool checked);
112 void onSelectionChanged();
113 void onAddNewSection();
114 void onEditSection( int theSection );
115 void onModifySection();
116 void onCancelSection();
118 void onBringTogether();
123 void onSetPolyline();
124 void onCloseSections();
125 void onUncloseSections();
128 void onUndoSettings();
129 void onContextMenu(QPoint thePoint);
131 void onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent );
132 void onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent );
133 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent );
134 void onLastViewClosed( SUIT_ViewManager* theManager );
136 void onMousePress( QMouseEvent* theEvent );
137 void onMouseRelease( QMouseEvent* theEvent );
138 void onMouseMove( QMouseEvent* theEvent );
140 void onCellChanged( int theRow, int theColumn );
143 void addCoordsByClick( QMouseEvent* );
146 enum ActionId{ NONE_ID,
157 SET_SECTIONS_POLYLINE_ID,
158 SET_SECTIONS_SPLINE_ID,
161 MODIFICATION_MODE_ID,
167 OCCViewer_Viewer* getOCCViewer();
169 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
170 const QString& theToolTip, const QKeySequence& theShortcut );
171 QAction* getAction(ActionId theId);
172 QAction* getAction(ActionMode theMode);
174 void updateActionsStates();
175 void updateUndoRedo();
177 void removeSection();
179 void addNewPoint(const CurveCreator::Coordinates& theCoords);
180 void insertPointToSelectedSegment( const int theXPosition,
181 const int theYPosition );
182 void moveSelectedPoints( const int theXPosition, const int theYPosition );
183 void updateLocalPointView();
184 void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
186 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
188 void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints );
189 void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
190 CurveCreator_ICurve::SectionToPointList() );
192 void stopActionMode();
194 void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints,
195 const bool theFillPoints = true );
196 void finishCurveModification( const CurveCreator_ICurve::SectionToPointList& thePoints =
197 CurveCreator_ICurve::SectionToPointList() );
200 int findLocalPointIndex( int theSectionId, double theX, double theY );
201 void findSectionsToPoints( const double theX, const double theY,
202 CurveCreator_ICurve::SectionToPointList& thePoints );
203 void convert( const CurveCreator_ICurve::SectionToPointList& thePoints,
204 QMap<int, QList<int> >& theConvPoints );
206 bool contains( const CurveCreator_ICurve::SectionToPointList& theList,
207 const CurveCreator_ICurve::SectionToPoint& theValue ) const;
210 // Boundary points of mouse to select the points
215 QMap<ActionId, QAction*> myActionMap;
216 CurveCreator_ICurve* myCurve;
217 CurveCreator_TreeView* mySectionView;
218 CurveCreator_TableView* myLocalPointView;
219 CurveCreator_ICurve::SectionToPointList myLocalPoints;
220 CurveCreator_NewSectionDlg* myNewSectionEditor;
221 OCCViewer_Viewer* myOCCViewer;
222 int myLocalPointRowLimit;
226 QPoint myDragStartPosition;
227 int myDragInteractionStyle;
228 CurveCreator_ICurve::SectionToPointList myDragPoints;
229 QMap<CurveCreator_ICurve::SectionToPoint, CurveCreator::Coordinates> myInitialDragPointsCoords;
231 QByteArray myGuiState;
232 OCCViewer_ViewWindow::Mode2dType myOld2DMode;
235 #endif // CURVECREATOR_WIDGET_H