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