Salome HOME
Change name 'Module' to 'Modules' and edit validators group
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchLabel.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetSketchLabel.h
4 // Created:     07 July 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef PartSet_WidgetSketchLabel_H
8 #define PartSet_WidgetSketchLabel_H
9
10 #include "PartSet.h"
11
12 #include <ModuleBase_ModelWidget.h>
13 #include <ModuleBase_ViewerFilters.h>
14
15 #include <GeomAPI_Pnt.h>
16 #include <GeomAPI_Dir.h>
17 #include <GeomAPI_AISObject.h>
18
19 #include <StdSelect_FaceFilter.hxx>
20 #include <TopoDS_Shape.hxx>
21
22 class QLabel;
23 class QTimer;
24 class XGUI_OperationMgr;
25 class XGUI_Workshop;
26
27 /**
28 * \ingroup Modules
29 * A model widget implementation for a label which provides specific behaviour 
30 * for sketcher starting and launching operations
31 */
32 class PARTSET_EXPORT PartSet_WidgetSketchLabel : public ModuleBase_ModelWidget
33 {
34 Q_OBJECT
35  public:
36   /// Constructor
37   /// \param theParent the parent object
38   /// \param theData the widget configuation. The attribute of the model widget is obtained from
39   /// \param theParentId is Id of a parent of the current attribute
40   PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData,
41                             const std::string& theParentId);
42
43   virtual ~PartSet_WidgetSketchLabel();
44
45   virtual bool storeValue() const
46   {
47     return true;
48   }
49
50   virtual bool restoreValue()
51   {
52     return true;
53   }
54
55   /// Returns list of widget controls
56   /// \return a control list
57   virtual QList<QWidget*> getControls() const;
58
59   QWidget* getControl() const;
60
61   /// The methiod called when widget is activated
62   virtual void activate();
63
64   /// The methiod called when widget is deactivated
65   virtual void deactivate();
66
67   /// Returns pointer to workshop
68   XGUI_Workshop* workshop() const { return myWorkshop; }
69
70   /// Set pointer to workshop
71   /// \param theWork a pointer to workshop
72   void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
73
74   /// Returns sketcher plane
75   std::shared_ptr<GeomAPI_Pln> plane() const;
76
77 signals:
78   /// Signal on plane selection
79   void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
80
81  private slots:
82    /// Slot on plane selection
83   void onPlaneSelected();
84
85   /// Set sketch specific mode of selection
86   void setSketchingMode();
87
88  private:
89    /// Create preview of planes for sketch plane selection
90    /// \param theOrigin an origin of the plane
91    /// \param theNorm a normal vector of the plane
92    /// \param theRGB a color of plane presentation [r, g, b] array
93   AISObjectPtr createPreviewPlane(std::shared_ptr<GeomAPI_Pnt> theOrigin, 
94                                   std::shared_ptr<GeomAPI_Dir> theNorm, 
95                                   const int theRGB[3]);
96
97   /// Set sketch plane by shape
98   /// \param theShape a planar face
99   std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
100
101   /// Erase preview planes
102   void erasePreviewPlanes();
103
104   /// Show preview planes
105   void showPreviewPlanes();
106
107
108   QLabel* myLabel;
109   QString myText;
110   QString myTooltip;
111
112   XGUI_Workshop* myWorkshop;
113
114   AISObjectPtr myYZPlane;
115   AISObjectPtr myXZPlane;
116   AISObjectPtr myXYPlane;
117   bool myPreviewDisplayed;
118
119   Handle(StdSelect_FaceFilter) myFaceFilter;
120
121   QTimer* mySelectionTimer;
122 };
123
124 #endif