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
35   virtual ~PartSet_WidgetShapeSelector() {}
36
37   /// Set sketcher
38   /// \param theSketch a sketcher object
39   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
40
41   /// Retrurns installed sketcher
42   CompositeFeaturePtr sketch() const { return mySketch; }
43
44 protected:
45   /// Store the values to the model attribute of the widget. It casts this attribute to
46   /// the specific type and set the given values
47   /// \param theSelectedObject an object
48   /// \param theShape a selected shape, which is used in the selection attribute
49   virtual bool setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape);
50
51   /// Creates a backup of the current values of the attribute
52   /// It should be realized in the specific widget because of different
53   /// parameters of the current attribute
54   /// \param theValid a boolean flag, if restore happens for valid parameters
55   void restoreAttributeValue(const bool theValid);
56
57   // Removes the external presentation from the model
58   void removeExternal();
59
60 protected:
61   /// Pointer to a sketch 
62   CompositeFeaturePtr mySketch;
63
64   /// An external object
65   ObjectPtr myExternalObject;
66
67   bool myUseExternal;
68 };
69
70 #endif