1 // Copyright (C) 2013-2022 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, or (at your option) any later version.
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"
27 #include <SUIT_ViewWindow.h>
28 #include <OCCViewer_ViewWindow.h>
30 #include <AIS_InteractiveObject.hxx>
31 #include <AIS_InteractiveContext.hxx>
32 #include <AIS_ListOfInteractive.hxx>
33 #include <Geom_Curve.hxx>
34 #include <V3d_View.hxx>
40 class CurveCreator_TableView;
41 class CurveCreator_TreeView;
42 class CurveCreator_NewSectionDlg;
44 class OCCViewer_Viewer;
45 class OCCViewer_ViewPort3d;
50 class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
57 DisableDetectionMode = 0x00000001,
58 DisableNewSection = 0x00000002,
59 DisableClosedSection = 0x00000004,
60 DisableSetColor = 0x00000008
71 explicit CurveCreator_Widget( QWidget* parent,
72 CurveCreator_ICurve *theCurve,
73 const int theActionFlags = NoFlags,
74 const QStringList& theCoordTitles = QStringList(),
75 Qt::WindowFlags fl=0);
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;
96 void SetViewer2DMode(const bool To2D);
98 void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
99 CurveCreator_ICurve::SectionToPointList() );
101 void updateLocalPointView();
102 void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
105 void selectionChanged();
106 void subOperationStarted( QWidget*, bool );
107 void subOperationFinished( QWidget* );
110 void onAdditionMode(bool checked);
111 void onModificationMode(bool checked);
112 void onDetectionMode(bool checked);
113 void onModeChanged(bool checked);
115 void onSelectionChanged();
116 void onAddNewSection();
117 void onEditSection( int theSection );
118 void onModifySection();
119 void onCancelSection();
121 void onBringTogether();
127 void onSetPolyline();
128 void onCloseSections();
129 void onUncloseSections();
132 void onUndoSettings();
133 void onContextMenu(QPoint thePoint);
135 void onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent );
136 void onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent );
137 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent );
138 void onLastViewClosed( SUIT_ViewManager* theManager );
140 void onMousePress( QMouseEvent* theEvent );
141 void onMouseRelease( QMouseEvent* theEvent );
142 void onMouseMove( QMouseEvent* theEvent );
144 void onCellChanged( int theRow, int theColumn );
147 void addCoordsByClick( QMouseEvent* );
150 enum ActionId{ NONE_ID,
161 SET_SECTIONS_POLYLINE_ID,
162 SET_SECTIONS_SPLINE_ID,
165 MODIFICATION_MODE_ID,
172 QAction* getAction(ActionId theId);
173 QAction* getAction(ActionMode theMode);
176 OCCViewer_Viewer* getOCCViewer();
178 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
179 const QString& theToolTip, const QKeySequence& theShortcut );
181 void updateActionsStates();
182 void updateUndoRedo();
184 void removeSection();
186 void addNewPoint(const CurveCreator::Coordinates& theCoords);
187 void insertPointToSelectedSegment( const int theXPosition,
188 const int theYPosition );
189 void moveSelectedPoints( const int theXPosition, const int theYPosition );
191 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
193 void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints );
195 void stopActionMode();
197 void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints,
198 const bool theFillPoints = true );
199 void finishCurveModification( const CurveCreator_ICurve::SectionToPointList& thePoints =
200 CurveCreator_ICurve::SectionToPointList() );
203 int findLocalPointIndex( int theSectionId, double theX, double theY );
204 void findSectionsToPoints( const double theX, const double theY,
205 CurveCreator_ICurve::SectionToPointList& thePoints );
206 void convert( const CurveCreator_ICurve::SectionToPointList& thePoints,
207 QMap<int, QList<int> >& theConvPoints );
209 bool contains( const CurveCreator_ICurve::SectionToPointList& theList,
210 const CurveCreator_ICurve::SectionToPoint& theValue ) const;
213 // Boundary points of mouse to select the points
218 QMap<ActionId, QAction*> myActionMap;
219 CurveCreator_ICurve* myCurve;
220 CurveCreator_TreeView* mySectionView;
221 CurveCreator_TableView* myLocalPointView;
222 CurveCreator_ICurve::SectionToPointList myLocalPoints;
223 CurveCreator_NewSectionDlg* myNewSectionEditor;
224 OCCViewer_Viewer* myOCCViewer;
225 int myLocalPointRowLimit;
229 QPoint myDragStartPosition;
230 int myDragInteractionStyle;
231 CurveCreator_ICurve::SectionToPointList myDragPoints;
232 QMap<CurveCreator_ICurve::SectionToPoint, CurveCreator::Coordinates> myInitialDragPointsCoords;
234 QByteArray myGuiState;
235 OCCViewer_ViewWindow::Mode2dType myOld2DMode;
238 #endif // CURVECREATOR_WIDGET_H