Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetConcealedObjects.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_WidgetConcealedObjects.h
4 // Created:     29 Jul 2016
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef MODULEBASE_WIDGETCONCEALEDOBJECTS_H_
8 #define MODULEBASE_WIDGETCONCEALEDOBJECTS_H_
9
10 #include <ModuleBase.h>
11 #include <ModuleBase_ModelWidget.h>
12
13 #include <string>
14 #include <map>
15 #include <memory>
16
17 class ModelAPI_Object;
18
19 class QWidget;
20 class QTableWidget;
21
22 /**
23 * \ingroup GUI
24 * Implementation of model widget for table of concealed objects.
25 */
26 class MODULEBASE_EXPORT ModuleBase_WidgetConcealedObjects : public ModuleBase_ModelWidget
27 {
28   Q_OBJECT
29  public:
30   /// Constructor
31   /// \param theParent the parent object
32   /// \param theData the widget configuration.
33   ModuleBase_WidgetConcealedObjects(QWidget* theParent,
34                                     const Config_WidgetAPI* theData);
35   virtual ~ModuleBase_WidgetConcealedObjects();
36
37   /// Redefinition of virtual method
38   virtual QList<QWidget*> getControls() const;
39
40   /// The widget can not accept focus
41   virtual bool canAcceptFocus() const { return false; };
42
43 protected:
44   /// Saves the internal parameters to the given feature
45   /// \return True in success
46   virtual bool storeValueCustom();
47
48   /// Redefinition of virtual method
49   virtual bool restoreValueCustom();
50
51 private:
52   /// Creates a row in view
53   /// \param theResult a result for the row
54   void addViewRow(const std::shared_ptr<ModelAPI_Result>& theResult);
55
56 private slots:
57   /// Processes the display button click in the view.
58   /// \param theState a new state
59   void onItemToggled(bool theState);
60
61 private:
62   std::string myBaseShapeAttribute; ///< attribute of the base object
63   QTableWidget* myView; ///< table view of visibility states
64
65   std::shared_ptr<ModelAPI_Feature> myBaseFeature; ///< backup of feature of filling the table view
66   /// backup of visualized in the view concealed objects, stored to avoid table rebuild by restore
67   std::map<int, std::shared_ptr<ModelAPI_Result> > myConcealedResults;
68 };
69
70 #endif /* MODULEBASE_WIDGETCONCEALEDOBJECTS_H_ */