Version: 9.16.0
CurveCreator_Widget.h
Go to the documentation of this file.
1// Copyright (C) 2013-2026 CEA, EDF, OPEN CASCADE
2//
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.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef CURVECREATOR_WIDGET_H
21#define CURVECREATOR_WIDGET_H
22
24#include "CurveCreator.hxx"
26
27#include <SUIT_ViewWindow.h>
28#include <OCCViewer_ViewWindow.h>
29
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>
35#include <gp_Pnt.hxx>
36
37#include <QWidget>
38#include <QMap>
39
43
44class OCCViewer_Viewer;
45class OCCViewer_ViewPort3d;
46
47class QAction;
48class QPixmap;
49
51{
52 Q_OBJECT
53
54public:
56 NoFlags = 0x00000000,
57 DisableDetectionMode = 0x00000001,
58 DisableNewSection = 0x00000002,
59 DisableClosedSection = 0x00000004,
60 DisableSetColor = 0x00000008
61 };
62
67 DetectionMode
68 };
69
70public:
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);
76
77 // OCC viewer manipulation
78 void setOCCViewer( OCCViewer_Viewer* theViewer );
79
80 Handle(AIS_InteractiveContext) getAISContext();
81 OCCViewer_ViewPort3d* getViewPort();
82 int changeInteractionStyle( int theStyle );
83
84 void reset();
85 void setCurve( CurveCreator_ICurve* theCurve );
86
87 QList<int> getSelectedSections();
88 void setSelectedSections( const QList<int>& theSections );
89
90 void removeSelected();
91 bool removeEnabled();
92
93 void setActionMode( const ActionMode& theMode );
94 ActionMode getActionMode() const;
95
96 void SetViewer2DMode(const bool To2D);
97
98 void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
100
101 void updateLocalPointView();
102 void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
103
104signals:
108
109public slots:
110 void onAdditionMode(bool checked);
111 void onModificationMode(bool checked);
112 void onDetectionMode(bool checked);
113 void onModeChanged(bool checked);
114 void onNewSection();
115 void onSelectionChanged();
116 void onAddNewSection();
117 void onEditSection( int theSection );
118 void onModifySection();
119 void onCancelSection();
120 void onJoin();
121 void onBringTogether();
122 void onRemove();
123 void onSetColor();
124 void onClearAll();
125 void onJoinAll();
126 void onSetSpline();
127 void onSetPolyline();
128 void onCloseSections();
129 void onUncloseSections();
130 void onUndo();
131 void onRedo();
132 void onUndoSettings();
133 void onContextMenu(QPoint thePoint);
134
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 );
139
140 void onMousePress( QMouseEvent* theEvent );
141 void onMouseRelease( QMouseEvent* theEvent );
142 void onMouseMove( QMouseEvent* theEvent );
143
144 void onCellChanged( int theRow, int theColumn );
145
146protected:
147 void addCoordsByClick( QMouseEvent* );
148
149protected:
150 enum ActionId{ NONE_ID,
168 SETCOLOR_ID
169 };
170
171public:
172 QAction* getAction(ActionId theId);
173 QAction* getAction(ActionMode theMode);
174
175private:
176 OCCViewer_Viewer* getOCCViewer();
177
178 QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
179 const QString& theToolTip, const QKeySequence& theShortcut );
180
181 void updateActionsStates();
182 void updateUndoRedo();
183
184 void removeSection();
185 void removePoint();
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 );
190
191 void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
192
193 void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints );
194
195 void stopActionMode();
196
197 void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints,
198 const bool theFillPoints = true );
199 void finishCurveModification( const CurveCreator_ICurve::SectionToPointList& thePoints =
201
202 // curve algorithm
203 int findLocalPointIndex( int theSectionId, double theX, double theY );
204 void findSectionsToPoints( const double theX, const double theY,
206 void convert( const CurveCreator_ICurve::SectionToPointList& thePoints,
207 QMap<int, QList<int> >& theConvPoints );
208
209 bool contains( const CurveCreator_ICurve::SectionToPointList& theList,
210 const CurveCreator_ICurve::SectionToPoint& theValue ) const;
211
212protected:
213 // Boundary points of mouse to select the points
216
217private:
218 QMap<ActionId, QAction*> myActionMap;
224 OCCViewer_Viewer* myOCCViewer;
232 QMap<CurveCreator_ICurve::SectionToPoint, CurveCreator::Coordinates> myInitialDragPointsCoords;
234 QByteArray myGuiState;
235 OCCViewer_ViewWindow::Mode2dType myOld2DMode;
236};
237
238#endif // CURVECREATOR_WIDGET_H
#define CURVECREATOR_EXPORT
Definition: CurveCreator_Macro.hxx:41
The CurveCreator_ICurve object is represented as one or more sets of connected points; thus CurveCrea...
Definition: CurveCreator_ICurve.hxx:73
std::deque< SectionToPoint > SectionToPointList
Definition: CurveCreator_ICurve.hxx:76
std::pair< int, int > SectionToPoint
Definition: CurveCreator_ICurve.hxx:75
Definition: CurveCreator_NewSectionDlg.h:39
Definition: CurveCreator_TableView.h:45
Definition: CurveCreator_TreeView.h:58
Definition: CurveCreator_Widget.h:51
QPoint myEndPoint
Definition: CurveCreator_Widget.h:215
OCCViewer_ViewWindow::Mode2dType myOld2DMode
Definition: CurveCreator_Widget.h:235
QMap< ActionId, QAction * > myActionMap
Definition: CurveCreator_Widget.h:218
CurveCreator_NewSectionDlg * myNewSectionEditor
Definition: CurveCreator_Widget.h:223
void subOperationFinished(QWidget *)
int myPointNum
Definition: CurveCreator_Widget.h:227
OCCViewer_Viewer * myOCCViewer
Definition: CurveCreator_Widget.h:224
CurveCreator_ICurve * myCurve
Definition: CurveCreator_Widget.h:219
CurveCreator_ICurve::SectionToPointList myDragPoints
Definition: CurveCreator_Widget.h:231
CurveCreator_TreeView * mySectionView
Definition: CurveCreator_Widget.h:220
Handle(AIS_InteractiveContext) getAISContext()
CurveCreator_TableView * myLocalPointView
Definition: CurveCreator_Widget.h:221
int mySection
Definition: CurveCreator_Widget.h:226
CurveCreator_ICurve::SectionToPointList myLocalPoints
Definition: CurveCreator_Widget.h:222
ActionFlags
Definition: CurveCreator_Widget.h:55
void subOperationStarted(QWidget *, bool)
QPoint myStartPoint
Definition: CurveCreator_Widget.h:214
int myDragInteractionStyle
Definition: CurveCreator_Widget.h:230
bool myDragStarted
Definition: CurveCreator_Widget.h:228
QByteArray myGuiState
Definition: CurveCreator_Widget.h:234
QMap< CurveCreator_ICurve::SectionToPoint, CurveCreator::Coordinates > myInitialDragPointsCoords
Definition: CurveCreator_Widget.h:232
bool myDragged
Definition: CurveCreator_Widget.h:233
int myLocalPointRowLimit
Definition: CurveCreator_Widget.h:225
ActionMode
Definition: CurveCreator_Widget.h:63
@ ModificationMode
Definition: CurveCreator_Widget.h:66
@ AdditionMode
Definition: CurveCreator_Widget.h:65
@ NoneMode
Definition: CurveCreator_Widget.h:64
QPoint myDragStartPosition
Definition: CurveCreator_Widget.h:229
ActionId
Definition: CurveCreator_Widget.h:150
@ REMOVE_ALL_ID
Definition: CurveCreator_Widget.h:156
@ JOIN_ID
Definition: CurveCreator_Widget.h:157
@ SET_SECTIONS_SPLINE_ID
Definition: CurveCreator_Widget.h:162
@ CLEAR_ALL_ID
Definition: CurveCreator_Widget.h:163
@ UNCLOSE_SECTIONS_ID
Definition: CurveCreator_Widget.h:160
@ REMOVE_ID
Definition: CurveCreator_Widget.h:155
@ NEW_SECTION_ID
Definition: CurveCreator_Widget.h:153
@ SET_SECTIONS_POLYLINE_ID
Definition: CurveCreator_Widget.h:161
@ JOIN_ALL_ID
Definition: CurveCreator_Widget.h:158
@ CLOSE_SECTIONS_ID
Definition: CurveCreator_Widget.h:159
@ MODIFICATION_MODE_ID
Definition: CurveCreator_Widget.h:165
@ DETECTION_MODE_ID
Definition: CurveCreator_Widget.h:166
@ BRING_TOGETHER_ID
Definition: CurveCreator_Widget.h:167
@ UNDO_ID
Definition: CurveCreator_Widget.h:151
@ REDO_ID
Definition: CurveCreator_Widget.h:152
@ SEPARATOR_ID
Definition: CurveCreator_Widget.h:164
@ ADDITION_MODE_ID
Definition: CurveCreator_Widget.h:154
std::deque< TypeCoord > Coordinates
List of coordinates in format depends on section dimension: 2D: [x1, y1, x2, y2, x3,...
Definition: CurveCreator.hxx:42