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_ModelWidget.h>
13 #include <ModuleBase_ViewerFilters.h>
15 #include <GeomAPI_Pnt.h>
16 #include <GeomAPI_Dir.h>
17 #include <GeomAPI_AISObject.h>
19 #include <StdSelect_FaceFilter.hxx>
20 #include <TopoDS_Shape.hxx>
24 class XGUI_OperationMgr;
27 /// the plane edge width
28 #define SKETCH_WIDTH "4"
30 /// face of the square-face displayed for selection of general plane
31 #define PLANE_SIZE "200"
35 * A model widget implementation for a label which provides specific behaviour
36 * for sketcher starting and launching operations
38 class PARTSET_EXPORT PartSet_WidgetSketchLabel : public ModuleBase_ModelWidget
43 /// \param theParent the parent object
44 /// \param theData the widget configuation. The attribute of the model widget is obtained from
45 /// \param theParentId is Id of a parent of the current attribute
46 PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData,
47 const std::string& theParentId);
49 virtual ~PartSet_WidgetSketchLabel();
51 virtual bool restoreValue()
56 /// Returns list of widget controls
57 /// \return a control list
58 virtual QList<QWidget*> getControls() const;
60 /// The methiod called when widget is deactivated
61 virtual void deactivate();
63 /// Returns pointer to workshop
64 XGUI_Workshop* workshop() const { return myWorkshop; }
66 /// Set pointer to workshop
67 /// \param theWork a pointer to workshop
68 void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
70 /// Returns sketcher plane
71 std::shared_ptr<GeomAPI_Pln> plane() const;
73 /// This control accepts focus
74 virtual bool focusTo();
75 virtual void setHighlighted(bool) { /*do nothing*/ };
76 virtual void enableFocusProcessing();
79 /// Signal on plane selection
80 void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
83 /// Saves the internal parameters to the given feature
84 /// \return True in success
85 virtual bool storeValueCustom() const
90 /// The methiod called when widget is activated
91 virtual void activateCustom();
94 /// Slot on plane selection
95 void onPlaneSelected();
97 /// Set sketch specific mode of selection
98 void setSketchingMode();
101 /// Create preview of planes for sketch plane selection
102 /// \param theOrigin an origin of the plane
103 /// \param theNorm a normal vector of the plane
104 /// \param theRGB a color of plane presentation [r, g, b] array
105 AISObjectPtr createPreviewPlane(std::shared_ptr<GeomAPI_Pnt> theOrigin,
106 std::shared_ptr<GeomAPI_Dir> theNorm,
107 const int theRGB[3]);
109 /// Set sketch plane by shape
110 /// \param theShape a planar face
111 std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
113 /// Erase preview planes
114 void erasePreviewPlanes();
116 /// Show preview planes
117 void showPreviewPlanes();
124 XGUI_Workshop* myWorkshop;
126 AISObjectPtr myYZPlane;
127 AISObjectPtr myXZPlane;
128 AISObjectPtr myXYPlane;
129 bool myPreviewDisplayed;
131 Handle(StdSelect_FaceFilter) myFaceFilter;
133 QTimer* mySelectionTimer;