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_Macro.hxx"
24 #include "CurveCreator.hxx"
25 #include "CurveCreator_ICurve.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>
37 #include <TopoDS_Vertex.hxx> // TODO - remove
39 class OCCViewer_Viewer;
40 class OCCViewer_ViewPort3d;
42 class AIS_ListOfInteractive;
46 class CurveCreator_TableView;
47 class CurveCreator_TreeView;
48 class CurveCreator_NewPointDlg;
49 class CurveCreator_NewSectionDlg;
51 class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
55 explicit CurveCreator_Widget( QWidget* parent,
56 CurveCreator_ICurve *theCurve,
58 int theLocalPointRowLimit = 20);
60 // OCC viewer manipulation
61 void setOCCViewer( OCCViewer_Viewer* theViewer );
63 Handle(AIS_InteractiveContext) getAISContext();
64 OCCViewer_ViewPort3d* getViewPort();
65 int changeInteractionStyle( int theStyle );
68 void setCurve( CurveCreator_ICurve* theCurve );
70 QList<int> getSelectedSections();
71 QList< QPair< int, int > > getSelectedPoints();
73 void removeSelected();
77 void selectionChanged();
78 void subOperationStarted( QWidget* );
79 void subOperationFinished( QWidget* );
84 void onAdditionMode(bool checked);
85 void onModificationMode(bool checked);
86 void onDetectionMode(bool checked);
87 void onModeChanged(bool checked);
89 void onSelectionChanged();
90 void onAddNewSection();
91 void onEditSection( int theSection );
92 void onModifySection();
93 void onCancelSection();
100 void onCloseSections();
101 void onUncloseSections();
104 void onUndoSettings();
105 void onContextMenu(QPoint thePoint);
107 void onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent );
108 void onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent );
109 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent );
110 void onLastViewClosed( SUIT_ViewManager* theManager );
112 void onMousePress( QMouseEvent* theEvent );
113 void onMouseRelease( QMouseEvent* theEvent );
114 void onMouseMove( QMouseEvent* theEvent );
116 void onCellChanged( int theRow, int theColumn );
119 void addCoordsByClick( QMouseEvent* );
122 enum ActionId{ UNDO_ID,
132 SET_SECTIONS_POLYLINE_ID,
133 SET_SECTIONS_SPLINE_ID,
136 MODIFICATION_MODE_ID,
148 OCCViewer_Viewer* getOCCViewer();
150 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
151 const QString& theToolTip, const QKeySequence& theShortcut );
152 QAction* getAction(ActionId theId);
153 ActionMode getActionMode() const;
155 void updateActionsStates();
156 void updateUndoRedo();
158 void removeSection();
160 void addNewPoint(const CurveCreator::Coordinates& theCoords);
161 void insertPointToSelectedSegment( const int theXPosition,
162 const int theYPosition );
163 void moveSelectedPoints( const int theXPosition, const int theYPosition );
164 void updateLocalPointView();
165 void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
167 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
169 void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints );
170 void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
171 CurveCreator_ICurve::SectionToPointList() );
173 void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints,
174 const bool theFillPoints = true );
175 void finishCurveModification( const CurveCreator_ICurve::SectionToPointList& thePoints =
176 CurveCreator_ICurve::SectionToPointList() );
179 int findLocalPointIndex( int theSectionId, float theX, float theY );
180 void findSectionsToPoints( const double theX, const double theY,
181 CurveCreator_ICurve::SectionToPointList& thePoints );
182 void convert( const CurveCreator_ICurve::SectionToPointList& thePoints,
183 QMap<int, QList<int> >& theConvPoints );
185 bool contains( const CurveCreator_ICurve::SectionToPointList& theList,
186 const CurveCreator_ICurve::SectionToPoint& theValue ) const;
189 QMap<ActionId, QAction*> myActionMap;
190 CurveCreator_ICurve* myCurve;
191 CurveCreator_TreeView* mySectionView;
192 CurveCreator_TableView* myLocalPointView;
193 CurveCreator_ICurve::SectionToPointList myLocalPoints;
194 CurveCreator_NewSectionDlg* myNewSectionEditor;
195 OCCViewer_Viewer* myOCCViewer;
196 int myLocalPointRowLimit;
200 QPoint myDragStartPosition;
201 int myDragInteractionStyle;
202 CurveCreator_ICurve::SectionToPointList myDragPoints;
204 QByteArray myGuiState;
207 #endif // CURVECREATOR_WIDGET_H