1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_WidgetShapeSelector.h
4 // Created: 2 June 2014
5 // Author: Vitaly Smetannikov
7 #ifndef ModuleBase_WidgetShapeSelector_H
8 #define ModuleBase_WidgetShapeSelector_H
10 #include "ModuleBase.h"
11 #include "ModuleBase_ModelWidget.h"
12 #include "ModuleBase_ViewerFilters.h"
14 #include <ModelAPI_Object.h>
15 #include <GeomAPI_Shape.h>
17 #include <TopAbs_ShapeEnum.hxx>
19 #include <QStringList>
21 class Config_WidgetAPI;
26 class ModuleBase_IWorkshop;
28 class MODULEBASE_EXPORT ModuleBase_WidgetShapeSelector : public ModuleBase_ModelWidget
32 static TopAbs_ShapeEnum shapeType(const QString& theType);
34 ModuleBase_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
35 const Config_WidgetAPI* theData, const std::string& theParentId);
37 virtual ~ModuleBase_WidgetShapeSelector();
39 /// Saves the internal parameters to the given feature
40 virtual bool storeValue() const;
42 virtual bool restoreValue();
44 /// Returns the internal parent wiget control, that can be shown anywhere
45 /// \returns the widget
46 QWidget* getControl() const
51 /// Returns list of widget controls
52 /// \return a control list
53 virtual QList<QWidget*> getControls() const;
55 ObjectPtr selectedFeature() const
57 return mySelectedObject;
60 /// Set the given wrapped value to the current widget
61 /// This value should be processed in the widget according to the needs
62 /// \param theValue the wrapped widget value
63 virtual bool setSelection(ModuleBase_ViewerPrs theValue);
66 /// The methiod called when widget is activated
67 virtual void activate();
69 /// The methiod called when widget is deactivated
70 virtual void deactivate();
75 /// Activate or deactivate selection
76 void activateSelection(bool toActivate);
79 void onSelectionChanged();
82 void updateSelectionName();
83 void raisePanel() const;
85 /// Returns true if shape of given object corresponds to requested shape type
86 /// This method is called only in non sub-shapes selection mode
87 //virtual bool acceptObjectShape(const ObjectPtr theObject) const;
89 /// Returns true if selected shape corresponds to requested shape types
90 /// This method is called only in sub-shapes selection mode
91 virtual bool acceptSubShape(std::shared_ptr<GeomAPI_Shape> theShape) const;
93 /// Returns true if selected object corresponds to requested Object type
94 /// Thid method is used in any selection mode
95 virtual bool acceptObjectType(const ObjectPtr theObject) const;
98 // Set the given object as a value of the widget
99 void setObject(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape = std::shared_ptr<GeomAPI_Shape>());
101 /// Check the selected with validators if installed
102 virtual bool isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape);
105 void clearAttribute();
107 //----------- Class members -------------
109 QWidget* myContainer;
111 QLineEdit* myTextLine;
113 ModuleBase_IWorkshop* myWorkshop;
115 ObjectPtr mySelectedObject;
116 std::shared_ptr<GeomAPI_Shape> myShape;
118 QStringList myShapeTypes;
119 QStringList myObjectTypes;
123 Handle(ModuleBase_ObjectTypesFilter) myObjTypeFilter;