Salome HOME
f8e9d75b1d7915cc3d9c2326ed43141222c155a5
[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   /// Set sketcher
39   /// \param theSketch a sketcher object
40   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
41
42   /// Retrurns installed sketcher
43   CompositeFeaturePtr sketch() const { return mySketch; }
44
45 protected:
46   /// Saves the internal parameters to the given feature
47   /// \return True in success
48   virtual bool storeValue() const;
49
50   /// Check the selected with validators if installed
51   virtual bool isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape);
52
53 private:
54   /// Pointer to a sketch 
55   CompositeFeaturePtr mySketch;
56 };
57
58 /**
59 * \ingroup Modules
60 * Customosation of ModuleBase_WidgetShapeSelector in order to provide 
61 * working with constraints.
62 */
63 class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public ModuleBase_WidgetShapeSelector
64 {
65 Q_OBJECT
66  public:
67   /// Constructor
68   /// \param theParent the parent object
69   /// \param theWorkshop instance of workshop interface
70   /// \param theData the widget configuation. The attribute of the model widget is obtained from
71   /// \param theParentId is Id of a parent of the current attribute
72   PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
73     const Config_WidgetAPI* theData, const std::string& theParentId)
74     : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
75
76   virtual ~PartSet_WidgetConstraintShapeSelector() {}
77
78   /// Set sketcher
79   /// \param theSketch a sketcher object
80   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
81
82   /// Retrurns installed sketcher
83   CompositeFeaturePtr sketch() const { return mySketch; }
84
85 protected:
86   /// Saves the internal parameters to the given feature
87   /// \return True in success
88   virtual bool storeValue() const;
89
90 private:
91   /// Pointer to a sketch 
92   CompositeFeaturePtr mySketch;
93 };
94
95 #endif