1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_WidgetSketchLabel.h
4 // Created: 07 July 2014
5 // Author: Vitaly SMETANNIKOV
7 #ifndef PartSet_WidgetSketchLabel_H
8 #define PartSet_WidgetSketchLabel_H
12 #include <ModuleBase_WidgetValidated.h>
13 #include <ModuleBase_ViewerFilters.h>
15 #include <GeomAPI_Pnt.h>
16 #include <GeomAPI_Dir.h>
17 #include <GeomAPI_AISObject.h>
19 #include <TopoDS_Shape.hxx>
23 class XGUI_OperationMgr;
26 /// the plane edge width
27 #define SKETCH_WIDTH "4"
29 /// face of the square-face displayed for selection of general plane
30 #define PLANE_SIZE "200"
34 * A model widget implementation for a label which provides specific behaviour
35 * for sketcher starting and launching operations
37 class PARTSET_EXPORT PartSet_WidgetSketchLabel : public ModuleBase_WidgetValidated
42 /// \param theParent the parent object
43 /// \param theData the widget configuation. The attribute of the model widget is obtained from
44 /// \param theParentId is Id of a parent of the current attribute
45 PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData,
46 const std::string& theParentId);
48 virtual ~PartSet_WidgetSketchLabel();
50 virtual bool restoreValue()
55 /// Returns list of widget controls
56 /// \return a control list
57 virtual QList<QWidget*> getControls() const;
59 /// The methiod called when widget is deactivated
60 virtual void deactivate();
62 /// Returns pointer to workshop
63 XGUI_Workshop* workshop() const { return myWorkshop; }
65 /// Set pointer to workshop
66 /// \param theWork a pointer to workshop
67 void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
69 /// Returns sketcher plane
70 std::shared_ptr<GeomAPI_Pln> plane() const;
72 /// This control accepts focus
73 virtual bool focusTo();
74 virtual void setHighlighted(bool) { /*do nothing*/ };
75 virtual void enableFocusProcessing();
78 /// Signal on plane selection
79 void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
82 /// Creates a backup of the current values of the attribute
83 /// It should be realized in the specific widget because of different
84 /// parameters of the current attribute
85 virtual void storeAttributeValue();
87 /// Creates a backup of the current values of the attribute
88 /// It should be realized in the specific widget because of different
89 /// parameters of the current attribute
90 /// \param theValid a boolean flag, if restore happens for valid parameters
91 virtual void restoreAttributeValue(const bool theValid);
93 /// Fills the attribute with the value of the selected owner
94 /// \param theOwner a selected owner
95 virtual bool setSelection(const Handle_SelectMgr_EntityOwner& theOwner);
97 /// Saves the internal parameters to the given feature
98 /// \return True in success
99 virtual bool storeValueCustom() const
104 /// The methiod called when widget is activated
105 virtual void activateCustom();
108 /// Slot on plane selection
109 void onPlaneSelected();
111 /// Set sketch specific mode of selection
112 void setSketchingMode();
115 /// Create preview of planes for sketch plane selection
116 /// \param theOrigin an origin of the plane
117 /// \param theNorm a normal vector of the plane
118 /// \param theRGB a color of plane presentation [r, g, b] array
119 AISObjectPtr createPreviewPlane(std::shared_ptr<GeomAPI_Pnt> theOrigin,
120 std::shared_ptr<GeomAPI_Dir> theNorm,
121 const int theRGB[3]);
123 /// Set sketch plane by shape
124 /// \param theShape a planar face
125 std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
127 /// Erase preview planes
128 void erasePreviewPlanes();
130 /// Show preview planes
131 void showPreviewPlanes();
138 XGUI_Workshop* myWorkshop;
140 AISObjectPtr myYZPlane;
141 AISObjectPtr myXZPlane;
142 AISObjectPtr myXYPlane;
143 bool myPreviewDisplayed;
145 QTimer* mySelectionTimer;