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>
38 class OCCViewer_Viewer;
39 class OCCViewer_ViewPort3d;
41 class AIS_ListOfInteractive;
46 class CurveCreator_TreeView;
47 class CurveCreator_NewPointDlg;
48 class CurveCreator_NewSectionDlg;
50 class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
54 explicit CurveCreator_Widget( QWidget* parent,
55 CurveCreator_ICurve *theCurve,
56 Qt::WindowFlags fl=0 );
58 // OCC viewer manipulation
59 void setOCCViewer( OCCViewer_Viewer* theViewer );
61 Handle(AIS_InteractiveContext) getAISContext();
62 OCCViewer_ViewPort3d* getViewPort();
63 int changeInteractionStyle( int theStyle );
64 void setObjectsSelected(const AIS_ListOfInteractive& theList);
68 //! Return unique section name
69 std::string getUniqSectionName(CurveCreator_ICurve* theCurve) const;
71 void setCurve( CurveCreator_ICurve* theCurve );
73 QList<int> getSelectedSections();
74 QList< QPair< int, int > > getSelectedPoints();
76 void removeSelected();
80 void selectionChanged();
81 void subOperationStarted( QWidget* );
82 void subOperationFinished( QWidget* );
87 void onAdditionMode(bool checked);
88 void onModificationMode(bool checked);
89 void onDetectionMode(bool checked);
90 void onModeChanged(bool checked);
92 void onSelectionChanged();
93 void onAddNewPoint(const CurveCreator::Coordinates& theCoords);
94 void onAddNewSection();
95 void onEditSection( int theSection );
96 void onModifySection();
97 void onCancelSection();
103 void onSetPolyline();
104 void onCloseSections();
105 void onUncloseSections();
108 void onUndoSettings();
109 void onContextMenu(QPoint thePoint);
110 void onGetCoordsByClick( QMouseEvent* );
112 void onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent );
113 void onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent );
114 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent );
115 void onLastViewClosed( SUIT_ViewManager* theManager );
117 void onMousePress( QMouseEvent* theEvent );
118 void onMouseRelease( QMouseEvent* theEvent );
119 void onMouseMove( QMouseEvent* theEvent );
121 void onCellChanged( int theRow, int theColumn );
124 enum ActionId{ UNDO_ID,
134 SET_SECTIONS_POLYLINE_ID,
135 SET_SECTIONS_SPLINE_ID,
138 MODIFICATION_MODE_ID,
150 OCCViewer_Viewer* getOCCViewer();
152 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
153 const QString& theToolTip, const QKeySequence& theShortcut );
154 QAction* getAction(ActionId theId);
155 ActionMode getActionMode() const;
157 void updateUndoRedo();
159 void removeSection();
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 );
166 void addLocalPointToTable( const double theX, const double theY );
168 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
170 void getSelectedPonts( CurveCreator_ICurve::SectionToPointList& thePoints );
171 void setSelectedPonts( const CurveCreator_ICurve::SectionToPointList& =
172 CurveCreator_ICurve::SectionToPointList() );
174 void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints,
175 const bool theFillPoints = true );
176 void finishCurveModification( const CurveCreator_ICurve::SectionToPointList& thePoints =
177 CurveCreator_ICurve::SectionToPointList() );
180 int findLocalPointIndex( int theSectionId, float theX, float theY );
181 void findSectionsToPoints( const double theX, const double theY,
182 CurveCreator_ICurve::SectionToPointList& thePoints );
183 void convert( const CurveCreator_ICurve::SectionToPointList& thePoints,
184 QMap<int, QList<int> >& theConvPoints );
186 // local point view table methods
187 int getSectionId( const int theRowId ) const;
188 int getPointId( const int theRowId ) const;
190 bool contains( const CurveCreator_ICurve::SectionToPointList& theList,
191 const CurveCreator_ICurve::SectionToPoint& theValue ) const;
194 QMap<ActionId, QAction*> myActionMap;
195 CurveCreator_ICurve* myCurve;
196 CurveCreator_TreeView* mySectionView;
197 QTableWidget* myLocalPointView;
198 CurveCreator_NewSectionDlg* myNewSectionEditor;
199 OCCViewer_Viewer* myOCCViewer;
203 QPoint myDragStartPosition;
204 int myDragInteractionStyle;
205 CurveCreator_ICurve::SectionToPointList myDragPoints;
207 QByteArray myGuiState;
210 #endif // CURVECREATOR_WIDGET_H