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
58 DisableDetectionMode = 0x00000001,
59 DisableNewSection = 0x00000002,
60 DisableClosedSection = 0x00000004
71 explicit CurveCreator_Widget( QWidget* parent,
72 CurveCreator_ICurve *theCurve,
73 const int theActionFlags = NoFlags,
75 int theLocalPointRowLimit = 20);
77 // OCC viewer manipulation
78 void setOCCViewer( OCCViewer_Viewer* theViewer );
80 Handle(AIS_InteractiveContext) getAISContext();
81 OCCViewer_ViewPort3d* getViewPort();
82 int changeInteractionStyle( int theStyle );
85 void setCurve( CurveCreator_ICurve* theCurve );
87 QList<int> getSelectedSections();
88 void setSelectedSections( const QList<int>& theSections );
90 void removeSelected();
93 void setActionMode( const ActionMode& theMode );
94 ActionMode getActionMode() const;
97 void selectionChanged();
98 void subOperationStarted( QWidget*, bool );
99 void subOperationFinished( QWidget* );
104 void onAdditionMode(bool checked);
105 void onModificationMode(bool checked);
106 void onDetectionMode(bool checked);
107 void onModeChanged(bool checked);
109 void onSelectionChanged();
110 void onAddNewSection();
111 void onEditSection( int theSection );
112 void onModifySection();
113 void onCancelSection();
119 void onSetPolyline();
120 void onCloseSections();
121 void onUncloseSections();
124 void onUndoSettings();
125 void onContextMenu(QPoint thePoint);
127 void onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent );
128 void onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent );
129 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent );
130 void onLastViewClosed( SUIT_ViewManager* theManager );
132 void onMousePress( QMouseEvent* theEvent );
133 void onMouseRelease( QMouseEvent* theEvent );
134 void onMouseMove( QMouseEvent* theEvent );
136 void onCellChanged( int theRow, int theColumn );
139 void addCoordsByClick( QMouseEvent* );
142 enum ActionId{ NONE_ID,
153 SET_SECTIONS_POLYLINE_ID,
154 SET_SECTIONS_SPLINE_ID,
157 MODIFICATION_MODE_ID,
162 OCCViewer_Viewer* getOCCViewer();
164 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
165 const QString& theToolTip, const QKeySequence& theShortcut );
166 QAction* getAction(ActionId theId);
167 QAction* getAction(ActionMode theMode);
169 void updateActionsStates();
170 void updateUndoRedo();
172 void removeSection();
174 void addNewPoint(const CurveCreator::Coordinates& theCoords);
175 void insertPointToSelectedSegment( const int theXPosition,
176 const int theYPosition );
177 void moveSelectedPoints( const int theXPosition, const int theYPosition );
178 void updateLocalPointView();
179 void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
181 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
183 void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints );
184 void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
185 CurveCreator_ICurve::SectionToPointList() );
187 void stopActionMode();
189 void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints,
190 const bool theFillPoints = true );
191 void finishCurveModification( const CurveCreator_ICurve::SectionToPointList& thePoints =
192 CurveCreator_ICurve::SectionToPointList() );
195 int findLocalPointIndex( int theSectionId, float theX, float theY );
196 void findSectionsToPoints( const double theX, const double theY,
197 CurveCreator_ICurve::SectionToPointList& thePoints );
198 void convert( const CurveCreator_ICurve::SectionToPointList& thePoints,
199 QMap<int, QList<int> >& theConvPoints );
201 bool contains( const CurveCreator_ICurve::SectionToPointList& theList,
202 const CurveCreator_ICurve::SectionToPoint& theValue ) const;
205 QMap<ActionId, QAction*> myActionMap;
206 CurveCreator_ICurve* myCurve;
207 CurveCreator_TreeView* mySectionView;
208 CurveCreator_TableView* myLocalPointView;
209 CurveCreator_ICurve::SectionToPointList myLocalPoints;
210 CurveCreator_NewSectionDlg* myNewSectionEditor;
211 OCCViewer_Viewer* myOCCViewer;
212 int myLocalPointRowLimit;
216 QPoint myDragStartPosition;
217 int myDragInteractionStyle;
218 CurveCreator_ICurve::SectionToPointList myDragPoints;
219 QMap<CurveCreator_ICurve::SectionToPoint, CurveCreator::Coordinates> myInitialDragPointsCoords;
221 QByteArray myGuiState;
226 #endif // CURVECREATOR_WIDGET_H