]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_WidgetShapeSelector.h
Salome HOME
Merge branch 'Dev_0.6' of newgeom:newgeom into Dev_0.6
[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
19 class Config_WidgetAPI;
20 class QWidget;
21 class QLabel;
22 class QLineEdit;
23 class QToolButton;
24 class ModuleBase_IWorkshop;
25
26 class MODULEBASE_EXPORT ModuleBase_WidgetShapeSelector : public ModuleBase_ModelWidget
27 {
28 Q_OBJECT
29  public:
30   static TopAbs_ShapeEnum shapeType(const QString& theType);
31
32   ModuleBase_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
33                             const Config_WidgetAPI* theData, const std::string& theParentId);
34
35   virtual ~ModuleBase_WidgetShapeSelector();
36
37   /// Saves the internal parameters to the given feature
38   /// \param theObject a model feature to be changed
39   virtual bool storeValue() const;
40
41   virtual bool restoreValue();
42
43   /// Returns the internal parent wiget control, that can be shown anywhere
44   /// \returns the widget
45   QWidget* getControl() const
46   {
47     return myContainer;
48   }
49
50   /// Returns list of widget controls
51   /// \return a control list
52   virtual QList<QWidget*> getControls() const;
53
54   ObjectPtr selectedFeature() const
55   {
56     return mySelectedObject;
57   }
58
59   /// Set the given wrapped value to the current widget
60   /// This value should be processed in the widget according to the needs
61   /// \param theValue the wrapped widget value
62   virtual bool setValue(ModuleBase_WidgetValue* theValue);
63
64
65   /// The methiod called when widget is activated
66   virtual void activate();
67
68   /// The methiod called when widget is deactivated
69   virtual void deactivate();
70
71
72  public slots:
73
74   /// Activate or deactivate selection
75   void activateSelection(bool toActivate);
76
77  private slots:
78   void onSelectionChanged();
79
80  protected:
81   void updateSelectionName();
82   void raisePanel() const;
83
84   /// Returns true if shape of given object corresponds to requested shape type
85   /// This method is called only in non sub-shapes selection mode
86   virtual bool acceptObjectShape(const ObjectPtr theObject) const;
87
88   /// Returns true if selected shape corresponds to requested shape types
89   /// This method is called only in sub-shapes selection mode
90   virtual bool acceptSubShape(std::shared_ptr<GeomAPI_Shape> theShape) const;
91
92   /// Returns true if selected object corresponds to requested Object type
93   /// Thid method is used in any selection mode
94   virtual bool acceptObjectType(const ObjectPtr theObject) const;
95
96
97   // Set the given object as a value of the widget
98   void setObject(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape = std::shared_ptr<GeomAPI_Shape>());
99
100   //----------- Class members -------------
101  private:
102   QWidget* myContainer;
103   QLabel* myLabel;
104   QLineEdit* myTextLine;
105
106   ModuleBase_IWorkshop* myWorkshop;
107
108   ObjectPtr mySelectedObject;
109   std::shared_ptr<GeomAPI_Shape> myShape;
110
111   QStringList myShapeTypes;
112   QStringList myObjectTypes;
113
114   /// If true then local selector has to be activated in context
115   bool myUseSubShapes;
116
117   bool myIsActive;
118
119   Handle(ModuleBase_ObjectTypesFilter) myObjTypeFilter;
120 };
121
122 #endif