1 // File: ModuleBase_WidgetShapeSelector.h
2 // Created: 2 June 2014
3 // Author: Vitaly Smetannikov
5 #ifndef ModuleBase_WidgetShapeSelector_H
6 #define ModuleBase_WidgetShapeSelector_H
8 #include "ModuleBase.h"
9 #include "ModuleBase_ModelWidget.h"
10 #include "ModuleBase_ViewerFilters.h"
12 #include <ModelAPI_Object.h>
13 #include <GeomAPI_Shape.h>
15 #include <TopAbs_ShapeEnum.hxx>
17 #include <QStringList>
20 class Config_WidgetAPI;
25 class ModuleBase_IWorkshop;
27 class MODULEBASE_EXPORT ModuleBase_WidgetShapeSelector : public ModuleBase_ModelWidget
31 static TopAbs_ShapeEnum shapeType(const QString& theType);
33 ModuleBase_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
34 const Config_WidgetAPI* theData, const std::string& theParentId);
36 virtual ~ModuleBase_WidgetShapeSelector();
38 /// Saves the internal parameters to the given feature
39 /// \param theObject a model feature to be changed
40 virtual bool storeValue() const;
42 virtual bool restoreValue();
44 virtual bool focusTo();
46 /// Returns the internal parent wiget control, that can be shown anywhere
47 /// \returns the widget
48 QWidget* getControl() const
53 /// Returns list of widget controls
54 /// \return a control list
55 virtual QList<QWidget*> getControls() const;
57 ObjectPtr selectedFeature() const
59 return mySelectedObject;
62 /// Set the given wrapped value to the current widget
63 /// This value should be processed in the widget according to the needs
64 /// \param theValue the wrapped widget value
65 virtual bool setValue(ModuleBase_WidgetValue* theValue);
69 /// Activate or deactivate selection
70 void activateSelection(bool toActivate);
73 void onSelectionChanged();
76 bool eventFilter(QObject* theObj, QEvent* theEvent);
78 void updateSelectionName();
79 void raisePanel() const;
81 /// Returns true if shape of given object corresponds to requested shape type
82 /// This method is called only in non sub-shapes selection mode
83 virtual bool acceptObjectShape(const ObjectPtr theObject) const;
85 /// Returns true if selected shape corresponds to requested shape types
86 /// This method is called only in sub-shapes selection mode
87 virtual bool acceptSubShape(boost::shared_ptr<GeomAPI_Shape> theShape) const;
89 /// Returns true if selected object corresponds to requested Object type
90 /// Thid method is used in any selection mode
91 virtual bool acceptObjectType(const ObjectPtr theObject) const;
94 // Set the given object as a value of the widget
95 void setObject(ObjectPtr theObj, boost::shared_ptr<GeomAPI_Shape> theShape = boost::shared_ptr<GeomAPI_Shape>());
97 //----------- Class members -------------
101 QLineEdit* myTextLine;
103 ModuleBase_IWorkshop* myWorkshop;
105 ObjectPtr mySelectedObject;
106 boost::shared_ptr<GeomAPI_Shape> myShape;
108 QStringList myShapeTypes;
109 QStringList myObjectTypes;
111 /// If true then local selector has to be activated in context
114 QPalette myBasePalet;
115 QPalette myInactivePalet;
119 Handle(ModuleBase_ObjectTypesFilter) myObjTypeFilter;