]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_WidgetShapeSelector.h
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetShapeSelector.h
1 // File:        ModuleBase_WidgetShapeSelector.h
2 // Created:     2 June 2014
3 // Author:      Vitaly Smetannikov
4
5 #ifndef ModuleBase_WidgetShapeSelector_H
6 #define ModuleBase_WidgetShapeSelector_H
7
8 #include "ModuleBase.h"
9 #include "ModuleBase_ModelWidget.h"
10 #include "ModuleBase_ViewerFilters.h"
11
12 #include <ModelAPI_Object.h>
13 #include <GeomAPI_Shape.h>
14
15 #include <TopAbs_ShapeEnum.hxx>
16
17 #include <QStringList>
18 #include <QPalette>
19
20 class Config_WidgetAPI;
21 class QWidget;
22 class QLabel;
23 class QLineEdit;
24 class QToolButton;
25 class ModuleBase_IWorkshop;
26
27 class MODULEBASE_EXPORT ModuleBase_WidgetShapeSelector : public ModuleBase_ModelWidget
28 {
29 Q_OBJECT
30  public:
31   static TopAbs_ShapeEnum shapeType(const QString& theType);
32
33   ModuleBase_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
34                             const Config_WidgetAPI* theData, const std::string& theParentId);
35
36   virtual ~ModuleBase_WidgetShapeSelector();
37
38   /// Saves the internal parameters to the given feature
39   /// \param theObject a model feature to be changed
40   virtual bool storeValue() const;
41
42   virtual bool restoreValue();
43
44   virtual bool focusTo();
45
46   /// Returns the internal parent wiget control, that can be shown anywhere
47   /// \returns the widget
48   QWidget* getControl() const
49   {
50     return myContainer;
51   }
52
53   /// Returns list of widget controls
54   /// \return a control list
55   virtual QList<QWidget*> getControls() const;
56
57   ObjectPtr selectedFeature() const
58   {
59     return mySelectedObject;
60   }
61
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);
66
67  public slots:
68
69   /// Activate or deactivate selection
70   void activateSelection(bool toActivate);
71
72  private slots:
73   void onSelectionChanged();
74
75  protected:
76   bool eventFilter(QObject* theObj, QEvent* theEvent);
77
78   void updateSelectionName();
79   void raisePanel() const;
80
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;
84
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;
88
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;
92
93
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>());
96
97   //----------- Class members -------------
98  private:
99   QWidget* myContainer;
100   QLabel* myLabel;
101   QLineEdit* myTextLine;
102
103   ModuleBase_IWorkshop* myWorkshop;
104
105   ObjectPtr mySelectedObject;
106   boost::shared_ptr<GeomAPI_Shape> myShape;
107
108   QStringList myShapeTypes;
109   QStringList myObjectTypes;
110
111   /// If true then local selector has to be activated in context
112   bool myUseSubShapes;
113
114   QPalette myBasePalet;
115   QPalette myInactivePalet;
116
117   bool myIsActive;
118
119   Handle(ModuleBase_ObjectTypesFilter) myObjTypeFilter;
120 };
121
122 #endif