1 // File: ModuleBase_WidgetSelector.h
2 // Created: 2 June 2014
3 // Author: Vitaly Smetannikov
5 #ifndef ModuleBase_WidgetSelector_H
6 #define ModuleBase_WidgetSelector_H
8 #include "ModuleBase.h"
9 #include "ModuleBase_ModelWidget.h"
11 #include <ModelAPI_Object.h>
13 #include <TopAbs_ShapeEnum.hxx>
15 #include <QStringList>
17 class Config_WidgetAPI;
22 class ModuleBase_IWorkshop;
24 class MODULEBASE_EXPORT ModuleBase_WidgetSelector : public ModuleBase_ModelWidget
28 ModuleBase_WidgetSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
29 const Config_WidgetAPI* theData, const std::string& theParentId);
31 virtual ~ModuleBase_WidgetSelector();
33 /// Saves the internal parameters to the given feature
34 /// \param theObject a model feature to be changed
35 virtual bool storeValue() const;
37 virtual bool restoreValue();
39 /// Returns the internal parent wiget control, that can be shown anywhere
40 /// \returns the widget
41 QWidget* getControl() const
46 /// Returns list of widget controls
47 /// \return a control list
48 virtual QList<QWidget*> getControls() const;
50 void setActivationOnStart(bool toActivate)
52 myActivateOnStart = toActivate;
54 bool activateOnStart() const
56 return myActivateOnStart;
59 ObjectPtr selectedFeature() const
61 return mySelectedObject;
66 /// Activate or deactivate selection
67 void activateSelection(bool toActivate);
70 bool eventFilter(QObject* theObj, QEvent* theEvent);
73 void onSelectionChanged();
76 void enableOthersControls(bool toEnable) const;
77 void updateSelectionName();
78 void raisePanel() const;
79 bool isAccepted(const ObjectPtr theObject) const;
81 static TopAbs_ShapeEnum shapeType(const QString& theType);
85 QLineEdit* myTextLine;
86 QToolButton* myActivateBtn;
88 ModuleBase_IWorkshop* myWorkshop;
90 bool myActivateOnStart;
92 ObjectPtr mySelectedObject;
93 QStringList myShapeTypes;