SHAPER 9.16.0
PartSet_WidgetSketchLabel.h
1// Copyright (C) 2014-2026 CEA, EDF
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 PartSet_WidgetSketchLabel_H
21#define PartSet_WidgetSketchLabel_H
22
23#include "PartSet.h"
24#include "PartSet_Tools.h"
25
26#include <ModuleBase_WidgetValidated.h>
27#include <ModuleBase_ViewerFilters.h>
28#include <ModuleBase_ViewerPrs.h>
29
30#include <GeomAPI_Dir.h>
31
32#include <TopoDS_Shape.hxx>
33
34#include <QStackedWidget>
35#include <QDoubleSpinBox>
36#include <QMap>
37
40
42class XGUI_Workshop;
43class QCheckBox;
44class QComboBox;
45class QDialog;
46class QSpinBox;
47class QGroupBox;
48class QLabel;
49class QLineEdit;
50class QPushButton;
51class QStackedWidget;
52class QGridLayout;
53
56
57
60
61
68{
69Q_OBJECT
70
71public:
78 const Config_WidgetAPI* theData,
79 const QMap<PartSet_Tools::ConstraintVisibleState, bool>& toShowConstraints);
80
81 virtual ~PartSet_WidgetSketchLabel() = default;
82
83 virtual void setFeature(
84 const FeaturePtr& theFeature,
85 const bool theToStoreValue = false,
86 const bool isUpdateFlushed = true
87 );
88
89 virtual bool isModified() const { return mySketchDataIsModified; }
90
97 virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
98 const bool theToValidate);
99
103 virtual void selectionModes(int& theModuleSelectionModes, QIntList& theModes);
104
108 virtual void selectionFilters(QIntList& theModuleSelectionFilters,
109 SelectMgr_ListOfFilter& theSelectionFilters);
110
113 virtual QList<QWidget*> getControls() const;
114
116 virtual void deactivate();
117
119 virtual bool needToBeActivated() { return true; }
120
122 std::shared_ptr<GeomAPI_Pln> plane() const;
123
125 virtual bool focusTo();
126 virtual void setHighlighted(bool) { /*do nothing*/ };
127 virtual void enableFocusProcessing();
128
131 void setShowPointsState(bool theState);
132
135 static bool canFillSketch(const ModuleBase_ViewerPrsPtr& thePrs);
136
139 virtual void showInformativePage() {
140 if (myStackWidget) myStackWidget->setCurrentIndex(1);
141 }
142
143signals:
145 void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
146
150 void showConstraintToggled(int theType, bool theState);
151
154 void showFreePoints(bool toShow);
155
158 void autoConstraints(bool isOn);
159
160protected:
165 virtual void storeAttributeValue(const AttributePtr& theAttribute);
166
172 virtual void restoreAttributeValue(const AttributePtr& theAttribute,
173 const bool theValid);
174
177 virtual bool setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs);
178
181 virtual bool storeValueCustom();
182
183 virtual bool restoreValueCustom();
184
186 virtual void activateCustom();
187
198 virtual void blockAttribute(const AttributePtr& theAttribute, const bool& theToBlock,
199 bool& isFlushesActived,
200 bool& isAttributeSetInitializedBlocked,
201 bool& isAttributeSendUpdatedBlocked);
202
204 virtual bool processSelection();
205
212 bool setSelectionInternal(const QList<ModuleBase_ViewerPrsPtr>& theValues,
213 const bool theToValidate);
214
217 void updateByPlaneSelected(const ModuleBase_ViewerPrsPtr& thePrs);
218
222 bool fillSketchPlaneBySelection(const ModuleBase_ViewerPrsPtr& thePrs);
223
225 virtual void showEvent(QShowEvent* theEvent);
226
228 virtual void hideEvent(QHideEvent* theEvent);
229
231 virtual bool eventFilter(QObject* theObj, QEvent* theEvent);
232
233private slots:
235 void onSetPlaneView();
236
239 void onShowConstraint(bool theOn);
240
242 void onChangePlane();
243
245 void onShowDOF();
246
248 void onShowPanel();
249
250 void onShowAxes(bool);
251 void onShowSubstrate(bool);
252
253 void onGridTypeChanged(int);
254 void onGridSnappingModeChanged(int);
255
257 void reconfigureSketchViewWidgets();
258
259 void saveSketchViewPreferenceToSkethData();
260
261private:
264 std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
265
268 std::shared_ptr<GeomAPI_Dir> setSketchPlane(std::shared_ptr<GeomAPI_Pln> thePlane);
269
275 QList<ModuleBase_ViewerPrsPtr> findCircularEdgesInPlane();
276
277private:
279 PartSet_PreviewPlanes* myPreviewPlanes;
280
281 bool mySketchDataIsModified;
282 QGroupBox* mySketchViewGroupBox;
283
284 QCheckBox* myViewInverted;
285 QCheckBox* myAxesVisibleCheckBox; // Local sketch axes.
286 QCheckBox* mySubstrateVisibleCheckBox;
287
288 QComboBox* myGridTypeComboBox;
289 QComboBox* myGridSnappingModeComboBox;
290
291 friend class PartSet_WidgetSketchGrid;
294 PartSet_WidgetSketchRectangularGrid* myWidgetRectangularGrid;
295 PartSet_WidgetSketchCircularGrid* myWidgetCircularGrid;
296
297 QCheckBox* myRemoveExternal;
298 QCheckBox* myShowPoints;
299 QCheckBox* myAutoConstraints;
300
301 QMap<PartSet_Tools::ConstraintVisibleState, QCheckBox*> myShowConstraints;
302
303 QWidget* mySizeOfViewWidget;
304 QLineEdit* mySizeOfView;
305 QStackedWidget* myStackWidget;
306
307 QLabel* myDoFLabel;
308 QPushButton* myShowDOFBtn;
309
310 bool myOpenTransaction;
311 bool myIsSelection;
312
313 QDialog* myPartSetMessage;
314 QDialog* mySizeMessage;
315
316 GeomPlanePtr myTmpPlane;
317};
318
319
320class PARTSET_EXPORT PitchSpinBox : public QDoubleSpinBox
321{
322 Q_OBJECT
323public:
324 PitchSpinBox(QWidget* theParent);
325 ~PitchSpinBox() = default;
326
327 void setValue(double theVal);
328
329signals:
330 void valueSet(double theVal);
331
332private slots:
333 virtual void onTextChanged();
334 virtual void onEditingFinished();
335
336private:
337 double myPrevVal;
338};
339
340
341class PARTSET_EXPORT PartSet_WidgetSketchGrid : public QWidget
342{
343 Q_OBJECT
344public:
347 virtual ~PartSet_WidgetSketchGrid() = default;
348
349 virtual void reconfigure() = 0;
350
351protected slots:
352 virtual void onResetClicked() = 0;
353 virtual void onOffsetAngleChanged(double theOffset) = 0;
354 virtual void onOffsetXChanged(double theOffset) = 0;
355 virtual void onOffsetYChanged(double theOffset) = 0;
356
357protected:
359 static double clampValue(double theValue, double theIntervalWidth);
360
362 static double reasonableOffsetIncrement(double theStep);
363
365 static double reasonablePitchIncrement(double theStep);
366
367 void retrieveSketchAndPlane();
368
369protected:
372
375
376 static const int SPIN_BOX_MIN_WIDTH;
377
378protected:
379 PartSet_WidgetSketchLabel* const mySketchLabel;
380 PartSet_PreviewSketchPlane* myPreviewPlane;
381
382 QGridLayout* myLayout;
383
384 QPushButton* myResetButton;
385
386 QDoubleSpinBox* myOffsetXSpinBox;
387 QDoubleSpinBox* myOffsetYSpinBox;
388 QDoubleSpinBox* myOffsetAngleSpinBox;
389
390 friend class PitchSpinBox;
391};
392
393
395{
396 Q_OBJECT
397public:
400 virtual ~PartSet_WidgetSketchRectangularGrid() = default;
401
403 virtual void reconfigure();
404
405private slots:
406 void onStepXSet(double theStep);
407 void onStepYSet(double theStep);
408
409protected slots:
410 virtual void onResetClicked();
411 virtual void onOffsetAngleChanged(double theOffset);
412 virtual void onOffsetXChanged(double theOffset);
413 virtual void onOffsetYChanged(double theOffset);
414
415private:
416 PitchSpinBox* myStepXSpinBox;
417 PitchSpinBox* myStepYSpinBox;
418};
419
420
422{
423 Q_OBJECT
424public:
427 virtual ~PartSet_WidgetSketchCircularGrid() = default;
428
430 virtual void reconfigure();
431
432private slots:
433 void onStepRChanged(double theStep);
434 void onNumOfAngularSegmentsChanged(int theNum);
435
436protected slots:
437 virtual void onResetClicked();
438 virtual void onOffsetAngleChanged(double theOffset);
439 virtual void onOffsetXChanged(double theOffset);
440 virtual void onOffsetYChanged(double theOffset);
441
442private:
443 void updateSegmentsToolTip();
444
445 PitchSpinBox* myStepRSpinBox;
446 QSpinBox* myNASSpinBox;
447};
448
449#endif
Provides low-level API for WidgetFactory for reading xml definitions of widgets.
Definition: Config_WidgetAPI.h:46
Feature that consists of other features: like sketcher with edges inside.
Definition: ModelAPI_CompositeFeature.h:33
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
virtual void selectionModes(int &theModuleSelectionModes, QIntList &theModes)
Fills given container with selection modes if the widget has it.
Definition: ModuleBase_ModelWidget.cpp:116
virtual void activateCustom()
The method called when widget is activated.
Definition: ModuleBase_ModelWidget.h:410
virtual QList< QWidget * > getControls() const =0
Returns list of widget controls.
virtual bool processSelection()
Returns true if envent is processed. It applies workshop selection for the widget attribute.
Definition: ModuleBase_ModelWidget.cpp:515
virtual void setFeature(const FeaturePtr &theFeature, const bool theToStoreValue=false, const bool isUpdateFlushed=true)
Set feature which is processing by active operation.
Definition: ModuleBase_ModelWidget.cpp:249
virtual bool storeValueCustom()=0
Saves the internal parameters to the given feature.
virtual bool restoreValueCustom()=0
Restore value from attribute data to the widget's control.
virtual bool eventFilter(QObject *theObject, QEvent *theEvent)
FocusIn events processing.
Definition: ModuleBase_ModelWidget.cpp:521
virtual bool setSelection(QList< std::shared_ptr< ModuleBase_ViewerPrs > > &theValues, const bool theToValidate)
Set the given wrapped value to the current widget This value should be processed in the widget accord...
Definition: ModuleBase_ModelWidget.h:163
virtual void enableFocusProcessing()
Enables processing of focus event on all controls by the widget if this widget is not obligatory and ...
Definition: ModuleBase_ModelWidget.cpp:224
virtual bool focusTo()
Set focus to the first control of the current widget.
Definition: ModuleBase_ModelWidget.cpp:267
Implementation of widget with validators and filters processing.
Definition: ModuleBase_WidgetValidated.h:54
virtual void restoreAttributeValue(const AttributePtr &theAttribute, const bool theValid)
Creates a backup of the current values of the attribute It should be realized in the specific widget ...
Definition: ModuleBase_WidgetValidated.cpp:92
virtual bool setSelectionCustom(const std::shared_ptr< ModuleBase_ViewerPrs > &thePrs)=0
Fills the attribute with the value of the selected owner.
virtual void deactivate()
The method called when widget is deactivated.
Definition: ModuleBase_WidgetValidated.cpp:69
virtual void storeAttributeValue(const AttributePtr &theAttribute)
Creates a backup of the current values of the attribute It should be realized in the specific widget ...
Definition: ModuleBase_WidgetValidated.cpp:85
virtual void blockAttribute(const AttributePtr &theAttribute, const bool &theToBlock, bool &isFlushesActived, bool &isAttributeSetInitializedBlocked, bool &isAttributeSendUpdatedBlocked)
Block the model flush of update and initialization of attribute.
Definition: ModuleBase_WidgetValidated.cpp:345
virtual void selectionFilters(QIntList &theModuleSelectionFilters, SelectMgr_ListOfFilter &theSelectionFilters)
Appends into container of workshop selection filters.
Definition: ModuleBase_WidgetValidated.cpp:338
A class to show/hide sketch preview planes.
Definition: PartSet_PreviewPlanes.h:37
Visualization of 2D-bluebrint' accessories: translucent rectangular substrate, basis axes,...
Definition: PartSet_PreviewSketchPlane.h:51
Definition: PartSet_WidgetSketchLabel.h:422
Definition: PartSet_WidgetSketchLabel.h:342
static const int NUM_OF_DECIMAL_DIGITS_ROTAT
Num of digits in fractional part of rotational values.
Definition: PartSet_WidgetSketchLabel.h:374
static const int NUM_OF_DECIMAL_DIGITS_TRANS
Num of digits in fractional part of translational values.
Definition: PartSet_WidgetSketchLabel.h:371
A model widget implementation for a label which provides specific behaviour for sketcher starting and...
Definition: PartSet_WidgetSketchLabel.h:68
virtual bool needToBeActivated()
The method called if widget should be activated always.
Definition: PartSet_WidgetSketchLabel.h:119
void showConstraintToggled(int theType, bool theState)
A show constraint toggled signal.
void showFreePoints(bool toShow)
The signal is emitted when user checks "Show free points" button.
virtual void setHighlighted(bool)
Switch On/Off highlighting of the widget.
Definition: PartSet_WidgetSketchLabel.h:126
virtual void showInformativePage()
If widgets has several panels then this method has to show a page which contains information for curr...
Definition: PartSet_WidgetSketchLabel.h:139
void planeSelected(const std::shared_ptr< GeomAPI_Pln > &thePln)
Signal on plane selection.
void autoConstraints(bool isOn)
The signal is emitted when user checks "Automatic constraints" button.
virtual bool isModified() const
Returns True if data of its attribute was modified.
Definition: PartSet_WidgetSketchLabel.h:89
Definition: PartSet_WidgetSketchLabel.h:395
Definition: PartSet_WidgetSketchLabel.h:321
Operation manager.
Definition: XGUI_OperationMgr.h:49
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:83