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>
18 class Config_WidgetAPI;
23 class ModuleBase_IWorkshop;
25 class MODULEBASE_EXPORT ModuleBase_WidgetSelector: public ModuleBase_ModelWidget
29 ModuleBase_WidgetSelector(QWidget* theParent,
30 ModuleBase_IWorkshop* theWorkshop,
31 const Config_WidgetAPI* theData, const std::string& theParentId);
33 virtual ~ModuleBase_WidgetSelector();
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;
39 virtual bool restoreValue(ObjectPtr theObject);
41 /// Returns the internal parent wiget control, that can be shown anywhere
42 /// \returns the widget
43 QWidget* getControl() const { return myContainer; }
45 /// Returns list of widget controls
46 /// \return a control list
47 virtual QList<QWidget*> getControls() const;
49 void setActivationOnStart(bool toActivate) { myActivateOnStart = toActivate; }
50 bool activateOnStart() const { return myActivateOnStart; }
52 ObjectPtr selectedFeature() const { return mySelectedObject; }
56 /// Activate or deactivate selection
57 void activateSelection(bool toActivate);
60 bool eventFilter(QObject* theObj, QEvent* theEvent);
63 void onSelectionChanged();
66 void enableOthersControls(bool toEnable) const;
67 void updateSelectionName();
68 void raisePanel() const;
69 bool isAccepted(const ObjectPtr theObject) const;
71 static TopAbs_ShapeEnum shapeType(const QString& theType);
75 QLineEdit* myTextLine;
76 QToolButton* myActivateBtn;
78 ModuleBase_IWorkshop* myWorkshop;
80 bool myActivateOnStart;
82 ObjectPtr mySelectedObject;
83 QStringList myShapeTypes;