Salome HOME
Restore selection in the viewer by multi selector widget activation.
[modules/shaper.git] / src / PartSet / PartSet_WidgetMultiSelector.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetMultiSelector.h
4 // Created:     15 Apr 2015
5 // Author:      Natalia Ermolaeva
6
7
8 #ifndef PartSet_WidgetMultiSelector_H
9 #define PartSet_WidgetMultiSelector_H
10
11 #include "PartSet.h"
12
13 #include <ModuleBase_WidgetMultiSelector.h>
14 #include <ModuleBase_ViewerPrs.h>
15
16 #include <ModelAPI_CompositeFeature.h>
17
18 class PartSet_ExternalObjectsMgr;
19
20 /**
21 * \ingroup Modules
22 * Customosation of ModuleBase_WidgetMultiSelector in order to provide 
23 * working with sketch specific objects and creation of external objects.
24 */
25 class PARTSET_EXPORT PartSet_WidgetMultiSelector: public ModuleBase_WidgetMultiSelector
26 {
27 Q_OBJECT
28  public:
29   /// Constructor
30   /// \param theParent the parent object
31   /// \param theWorkshop instance of workshop interface
32   /// \param theData the widget configuation. The attribute of the model widget is obtained from
33   /// \param theParentId is Id of a parent of the current attribute
34   PartSet_WidgetMultiSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
35     const Config_WidgetAPI* theData, const std::string& theParentId);
36
37   virtual ~PartSet_WidgetMultiSelector();
38
39   /// Defines if it is supposed that the widget should interact with the viewer.
40   virtual bool isViewerSelector() { return true; }
41
42   /// Set sketcher
43   /// \param theSketch a sketcher object
44   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
45
46   /// Retrurns installed sketcher
47   CompositeFeaturePtr sketch() const { return mySketch; }
48
49   /// Fills the attribute with the value of the selected owner
50   /// \param theOwner a selected owner
51   virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
52
53 public slots:
54   /// Slot is called on selection changed
55   virtual void onSelectionChanged();
56
57 protected:
58   /// Creates a backup of the current values of the attribute
59   /// It should be realized in the specific widget because of different
60   /// parameters of the current attribute
61   virtual void storeAttributeValue();
62
63   /// Creates a backup of the current values of the attribute
64   /// It should be realized in the specific widget because of different
65   /// parameters of the current attribute
66   /// \param theValid a boolean flag, if restore happens for valid parameters
67   void restoreAttributeValue(const bool theValid);
68
69   /// Store the values to the model attribute of the widget. It casts this attribute to
70   /// the specific type and set the given values
71   /// \param theSelectedObject an object
72   /// \param theShape a selected shape, which is used in the selection attribute
73   /// \return true if it is succeed
74   bool setObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape);
75
76 protected:
77   PartSet_ExternalObjectsMgr* myExternalObjectMgr;
78   /// Pointer to a sketch 
79   CompositeFeaturePtr mySketch;
80
81   bool myIsInVaildate;
82 };
83
84 #endif