Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / PartSet / PartSet_WidgetShapeSelector.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetShapeSelector.h
4 // Created:     27 Nov 2014
5 // Author:      Vitaly Smetannikov
6
7
8 #ifndef PartSet_WidgetShapeSelector_H
9 #define PartSet_WidgetShapeSelector_H
10
11 #include "PartSet.h"
12
13 #include <ModuleBase_WidgetShapeSelector.h>
14
15 #include <ModelAPI_CompositeFeature.h>
16
17
18 /**
19 * \ingroup Modules
20 * Customosation of ModuleBase_WidgetShapeSelector in order to provide 
21 * working with sketch specific objects.
22 */
23 class PARTSET_EXPORT PartSet_WidgetShapeSelector: public ModuleBase_WidgetShapeSelector
24 {
25 Q_OBJECT
26  public:
27   /// Constructor
28   /// \param theParent the parent object
29   /// \param theWorkshop instance of workshop interface
30   /// \param theData the widget configuation. The attribute of the model widget is obtained from
31   /// \param theParentId is Id of a parent of the current attribute
32   PartSet_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
33     const Config_WidgetAPI* theData, const std::string& theParentId)
34     : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
35
36   virtual ~PartSet_WidgetShapeSelector() {}
37
38   virtual bool storeValue() const;
39
40   /// Set sketcher
41   /// \param theSketch a sketcher object
42   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
43
44   /// Retrurns installed sketcher
45   CompositeFeaturePtr sketch() const { return mySketch; }
46
47 protected:
48   /// Check the selected with validators if installed
49   virtual bool isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape);
50
51 private:
52   /// Pointer to a sketch 
53   CompositeFeaturePtr mySketch;
54 };
55
56 /**
57 * \ingroup Modules
58 * Customosation of ModuleBase_WidgetShapeSelector in order to provide 
59 * working with constraints.
60 */
61 class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public ModuleBase_WidgetShapeSelector
62 {
63 Q_OBJECT
64  public:
65   /// Constructor
66   /// \param theParent the parent object
67   /// \param theWorkshop instance of workshop interface
68   /// \param theData the widget configuation. The attribute of the model widget is obtained from
69   /// \param theParentId is Id of a parent of the current attribute
70   PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
71     const Config_WidgetAPI* theData, const std::string& theParentId)
72     : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
73
74   virtual ~PartSet_WidgetConstraintShapeSelector() {}
75
76   /// Saves the internal parameters to the given feature
77   virtual bool storeValue() const;
78
79   /// Set sketcher
80   /// \param theSketch a sketcher object
81   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
82
83   /// Retrurns installed sketcher
84   CompositeFeaturePtr sketch() const { return mySketch; }
85
86 private:
87   /// Pointer to a sketch 
88   CompositeFeaturePtr mySketch;
89 };
90
91 #endif