Salome HOME
SketchPoint feature appeared in origin by restart. Correction: the viewer update...
[modules/shaper.git] / src / XGUI / XGUI_ErrorMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        XGUI_ErrorMgr.h
4 // Created:     22 July 2015
5 // Author:      Sergey POKHODENKO
6
7 #ifndef XGUI_ErrorMgr_H
8 #define XGUI_ErrorMgr_H
9
10 #include "XGUI.h"
11
12 #include <ModuleBase_IErrorMgr.h>
13 #include <ModelAPI_Feature.h>
14
15 class XGUI_Workshop;
16 class ModuleBase_IWorkshop;
17 class ModuleBase_ModelWidget;
18
19 class QAction;
20 class QDialog;
21 class QLabel;
22
23 /**
24  * \class XGUI_ErrorMgr
25  * \ingroup GUI
26  * \brief Class of Errors manager object
27  */
28 class XGUI_EXPORT XGUI_ErrorMgr : public ModuleBase_IErrorMgr
29 {
30   Q_OBJECT
31 public:
32   /// Constructor
33   /// \param theParent a parent object
34   /// \param theWorkshop a workshop object
35   XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop);
36   /// Virtual destructor
37   virtual ~XGUI_ErrorMgr();
38
39   /// Update actions for the given feature
40   /// \param theFeature a feature
41   void updateActions(const FeaturePtr& theFeature);
42
43   /// Update enable state of AcceptAll action if the feature uses it
44   /// \param theFeature a feature
45   void updateAcceptAllAction(const FeaturePtr& theFeature);
46
47   /// Returns true if the apply is enabled for the current feature
48   bool isApplyEnabled() const;
49
50 protected slots:
51   /// Reimplemented from ModuleBase_ErrorMgr::onWidgetChanged().
52   virtual void onWidgetChanged();
53
54 private:
55   /// It disables the action if the error message is not empty
56   /// The message is set to the header tool tip.
57   /// \param theAction an action to be changed
58   /// \param theError an error state
59   void updateActionState(QAction* theAction, const QString& theError);
60
61   /// It updates the tool tip of the widget controls according to the widget error
62   /// \param theWidget a widget
63   /// \param theError an error state
64   void updateToolTip(ModuleBase_ModelWidget* theWidget, const QString& theError);
65
66   /// Returns casted workshop
67   XGUI_Workshop* workshop() const;
68
69   /// Returns an active widget of the current operation
70   /// \return the widget or zero
71   ModuleBase_ModelWidget* activeWidget() const;
72
73 private:
74   ModuleBase_IWorkshop* myWorkshop; /// workshop
75   QDialog* myErrorDialog; /// contains the error message
76   QLabel* myErrorLabel; /// contains an error information
77 };
78
79 #endif // XGUI_ErrorMgr_H