]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_SelectorWidget.h
Salome HOME
45ef3d64f82edbb7f0260c5b2d5a71879e7c0e9c
[modules/shaper.git] / src / ModuleBase / ModuleBase_SelectorWidget.h
1 // File:        ModuleBase_SelectorWidget.h
2 // Created:     2 June 2014
3 // Author:      Vitaly Smetannikov
4
5 #ifndef ModuleBase_SelectorWidget_H
6 #define ModuleBase_SelectorWidget_H
7
8 #include "ModuleBase.h"
9 #include "ModuleBase_ModelWidget.h"
10
11 #include <ModelAPI_Feature.h>
12
13
14 class Config_WidgetAPI;
15 class QWidget;
16 class QLabel;
17 class QLineEdit;
18 class QToolButton;
19 class ModuleBase_IWorkshop;
20
21 class MODULEBASE_EXPORT ModuleBase_SelectorWidget: public ModuleBase_ModelWidget
22 {
23   Q_OBJECT
24 public:
25   ModuleBase_SelectorWidget(QWidget* theParent, 
26                             ModuleBase_IWorkshop* theWorkshop, 
27                             const Config_WidgetAPI* theData);
28
29   virtual ~ModuleBase_SelectorWidget();
30
31   /// Saves the internal parameters to the given feature
32   /// \param theFeature a model feature to be changed
33   virtual bool storeValue(FeaturePtr theFeature) const;
34
35   virtual bool restoreValue(FeaturePtr theFeature);
36
37   /// Returns the internal parent wiget control, that can be shown anywhere
38   /// \returns the widget
39   QWidget* getControl() const { return myContainer; }
40
41   /// Returns list of widget controls
42   /// \return a control list
43   virtual QList<QWidget*> getControls() const;
44
45   void setActivationOnStart(bool toActivate) { myActivateOnStart = toActivate; }
46   bool activateOnStart() const { return myActivateOnStart; }
47
48   FeaturePtr selectedFeature() const { return mySelectedFeature; }
49
50 public slots:
51
52   /// Activate or deactivate selection
53   void activateSelection(bool toActivate);
54
55 protected:
56   bool eventFilter(QObject* theObj, QEvent* theEvent);
57
58 private slots:
59   void onSelectionChanged();
60
61 private:
62   void enableOthersControls(bool toEnable) const;
63   void updateSelectionName();
64   void raisePanel() const;
65
66   std::string myFeatureAttributeID;
67
68   QWidget*     myContainer;
69   QLabel*      myLabel;
70   QLineEdit*   myTextLine;
71   QToolButton* myActivateBtn;
72
73   ModuleBase_IWorkshop* myWorkshop;
74
75   bool myActivateOnStart;
76
77   FeaturePtr mySelectedFeature;
78 };
79
80 #endif