SHAPER  9.12.0
PartSet_WidgetSketchLabel.h
1 // Copyright (C) 2014-2023 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 
25 #include "PartSet_Tools.h"
26 
27 #include <ModuleBase_WidgetValidated.h>
28 #include <ModuleBase_ViewerFilters.h>
29 #include <ModuleBase_ViewerPrs.h>
30 
31 #include <GeomAPI_Dir.h>
32 
33 #include <TopoDS_Shape.hxx>
34 
35 #include <QStackedWidget>
36 #include <QMap>
37 
39 
40 class QLabel;
41 class XGUI_OperationMgr;
42 class XGUI_Workshop;
43 class QCheckBox;
44 class QStackedWidget;
45 class QLineEdit;
46 class QPushButton;
47 class QDialog;
48 
55 {
56 Q_OBJECT
57 
58 public:
65  const Config_WidgetAPI* theData,
66  const QMap<PartSet_Tools::ConstraintVisibleState, bool>& toShowConstraints);
67 
68  virtual ~PartSet_WidgetSketchLabel();
69 
76  virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
77  const bool theToValidate);
78 
82  virtual void selectionModes(int& theModuleSelectionModes, QIntList& theModes);
83 
87  virtual void selectionFilters(QIntList& theModuleSelectionFilters,
88  SelectMgr_ListOfFilter& theSelectionFilters);
89 
92  virtual QList<QWidget*> getControls() const;
93 
95  virtual void deactivate();
96 
98  virtual bool needToBeActivated() { return true; }
99 
101  std::shared_ptr<GeomAPI_Pln> plane() const;
102 
104  virtual bool focusTo();
105  virtual void setHighlighted(bool) { /*do nothing*/ };
106  virtual void enableFocusProcessing();
107 
110  void setShowPointsState(bool theState);
111 
114  static bool canFillSketch(const ModuleBase_ViewerPrsPtr& thePrs);
115 
118  virtual void showInformativePage() {
119  if (myStackWidget) myStackWidget->setCurrentIndex(1);
120  }
121 
122 signals:
124  void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
125 
129  void showConstraintToggled(int theType, bool theState);
130 
133  void showFreePoints(bool toShow);
134 
137  void autoConstraints(bool isOn);
138 
139 protected:
144  virtual void storeAttributeValue(const AttributePtr& theAttribute);
145 
151  virtual void restoreAttributeValue(const AttributePtr& theAttribute,
152  const bool theValid);
153 
156  virtual bool setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs);
157 
160  virtual bool storeValueCustom()
161  {
162  return true;
163  }
164 
165  virtual bool restoreValueCustom();
166 
168  virtual void activateCustom();
169 
180  virtual void blockAttribute(const AttributePtr& theAttribute, const bool& theToBlock,
181  bool& isFlushesActived,
182  bool& isAttributeSetInitializedBlocked,
183  bool& isAttributeSendUpdatedBlocked);
184 
186  virtual bool processSelection();
187 
194  bool setSelectionInternal(const QList<ModuleBase_ViewerPrsPtr>& theValues,
195  const bool theToValidate);
196 
199  void updateByPlaneSelected(const ModuleBase_ViewerPrsPtr& thePrs);
200 
204  bool fillSketchPlaneBySelection(const ModuleBase_ViewerPrsPtr& thePrs);
205 
207  virtual void showEvent(QShowEvent* theEvent);
208 
210  virtual void hideEvent(QHideEvent* theEvent);
211 
213  virtual bool eventFilter(QObject* theObj, QEvent* theEvent);
214 
215 private slots:
217  void onSetPlaneView();
218 
221  void onShowConstraint(bool theOn);
222 
224  void onChangePlane();
225 
227  void onShowDOF();
228 
230  void onShowPanel();
231 
233  void onShowViewPlane(bool);
234 
235 private:
238  std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
239 
242  std::shared_ptr<GeomAPI_Dir> setSketchPlane(std::shared_ptr<GeomAPI_Pln> thePlane);
243 
249  QList<ModuleBase_ViewerPrsPtr> findCircularEdgesInPlane();
250 
251 private:
253  PartSet_PreviewPlanes* myPreviewPlanes;
254 
255  QCheckBox* myViewInverted;
256  QCheckBox* myViewVisible;
257  QCheckBox* myRemoveExternal;
258  QCheckBox* myShowPoints;
259  QCheckBox* myAutoConstraints;
260 
261  QMap<PartSet_Tools::ConstraintVisibleState, QCheckBox*> myShowConstraints;
262 
263  QWidget* mySizeOfViewWidget;
264  QLineEdit* mySizeOfView;
265  QStackedWidget* myStackWidget;
266 
267  QLabel* myDoFLabel;
268  QPushButton* myShowDOFBtn;
269 
270  bool myOpenTransaction;
271  bool myIsSelection;
272 
273  QDialog* myPartSetMessage;
274  QDialog* mySizeMessage;
275 
276  GeomPlanePtr myTmpPlane;
277 };
278 
279 #endif
Provides low-level API for WidgetFactory for reading xml definitions of widgets.
Definition: Config_WidgetAPI.h:46
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 bool processSelection()
Returns true if envent is processed. It applyes workshop selection for the widget attribute.
Definition: ModuleBase_ModelWidget.cpp:515
virtual QList< QWidget * > getControls() const =0
Returns list of widget controls.
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 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 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 intialization 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
A model widget implementation for a label which provides specific behaviour for sketcher starting and...
Definition: PartSet_WidgetSketchLabel.h:55
virtual bool needToBeActivated()
The method called if widget should be activated always.
Definition: PartSet_WidgetSketchLabel.h:98
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:105
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:118
void planeSelected(const std::shared_ptr< GeomAPI_Pln > &thePln)
Signal on plane selection.
virtual bool storeValueCustom()
Saves the internal parameters to the given feature.
Definition: PartSet_WidgetSketchLabel.h:160
void autoConstraints(bool isOn)
The signal is emitted when user checks "Automatic constraints" button.
Operation manager.
Definition: XGUI_OperationMgr.h:49
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:82