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_ICurve.hxx"
24 #include "CurveCreator.hxx"
25 #include "CurveCreator_Macro.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_ICurve;
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,
150 typedef std::pair< int, int > SectionToPoint;
151 typedef std::deque< SectionToPoint > SectionToPointList;
154 OCCViewer_Viewer* getOCCViewer();
156 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
157 const QString& theToolTip, const QKeySequence& theShortcut );
158 QAction* getAction(ActionId theId);
159 ActionMode getActionMode() const;
161 void updateUndoRedo();
163 void removeSection();
165 void insertPointToSelectedSegment( const int theXPosition,
166 const int theYPosition );
167 void moveSelectedPoints( const int theXPosition, const int theYPosition );
168 void updateLocalPointView();
169 void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
170 void addLocalPointToTable( const double theX, const double theY );
172 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
174 void getSelectedPonts( SectionToPointList& thePoints );
175 void setSelectedPonts( const SectionToPointList& = SectionToPointList() );
177 void startCurveModification( SectionToPointList& thePoints,
178 const bool theFillPoints = true );
179 void finishCurveModification( const SectionToPointList& thePoints = SectionToPointList() );
182 int findLocalPointIndex( int theSectionId, float theX, float theY );
183 void findSectionsToPoints( const double theX, const double theY,
184 SectionToPointList& thePoints );
185 void convert( const SectionToPointList& thePoints,
186 QMap<int, QList<int> >& theConvPoints );
188 // local point view table methods
189 int getSectionId( const int theRowId ) const;
190 int getPointId( const int theRowId ) const;
192 bool contains( const SectionToPointList& theList, const SectionToPoint& theValue ) const;
195 QMap<ActionId, QAction*> myActionMap;
196 CurveCreator_ICurve* myCurve;
197 CurveCreator_TreeView* mySectionView;
198 QTableWidget* myLocalPointView;
199 CurveCreator_NewSectionDlg* myNewSectionEditor;
200 OCCViewer_Viewer* myOCCViewer;
204 QPoint myDragStartPosition;
205 int myDragInteractionStyle;
206 SectionToPointList myDragPoints;
208 QByteArray myGuiState;
211 #endif // CURVECREATOR_WIDGET_H