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;
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,
57 Qt::WindowFlags fl=0 );
59 // OCC viewer manipulation
60 void setOCCViewer( OCCViewer_Viewer* theViewer );
62 Handle(AIS_InteractiveContext) getAISContext();
63 OCCViewer_ViewPort3d* getViewPort();
64 int changeInteractionStyle( int theStyle );
65 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,
151 OCCViewer_Viewer* getOCCViewer();
153 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
154 const QString& theToolTip, const QKeySequence& theShortcut );
155 QAction* getAction(ActionId theId);
156 ActionMode getActionMode() const;
158 void updateUndoRedo();
160 void removeSection();
162 void insertPointToSelectedSegment( const int theXPosition,
163 const int theYPosition );
164 void moveSelectedPoints( const int theXPosition, const int theYPosition );
165 void updateLocalPointView();
166 void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
167 void addLocalPointToTable( const double theX, const double theY );
169 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
171 void getSelectedPonts( CurveCreator_ICurve::SectionToPointList& thePoints );
172 bool isIntersectVertexToPoint( const TopoDS_Vertex& theVertex,
173 const CurveCreator_ICurve::SectionToPoint& theSToPoint );
174 void setSelectedPonts( const CurveCreator_ICurve::SectionToPointList& =
175 CurveCreator_ICurve::SectionToPointList() );
177 void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints,
178 const bool theFillPoints = true );
179 void finishCurveModification( const CurveCreator_ICurve::SectionToPointList& thePoints =
180 CurveCreator_ICurve::SectionToPointList() );
183 int findLocalPointIndex( int theSectionId, float theX, float theY );
184 void findSectionsToPoints( const double theX, const double theY,
185 CurveCreator_ICurve::SectionToPointList& thePoints );
186 void convert( const CurveCreator_ICurve::SectionToPointList& thePoints,
187 QMap<int, QList<int> >& theConvPoints );
189 // local point view table methods
190 int getSectionId( const int theRowId ) const;
191 int getPointId( const int theRowId ) const;
193 bool contains( const CurveCreator_ICurve::SectionToPointList& theList,
194 const CurveCreator_ICurve::SectionToPoint& theValue ) const;
197 QMap<ActionId, QAction*> myActionMap;
198 CurveCreator_ICurve* myCurve;
199 CurveCreator_TreeView* mySectionView;
200 QTableWidget* myLocalPointView;
201 CurveCreator_NewSectionDlg* myNewSectionEditor;
202 OCCViewer_Viewer* myOCCViewer;
206 QPoint myDragStartPosition;
207 int myDragInteractionStyle;
208 CurveCreator_ICurve::SectionToPointList myDragPoints;
210 QByteArray myGuiState;
213 #endif // CURVECREATOR_WIDGET_H