Salome HOME
Merge with PythonAPI branch
[modules/shaper.git] / src / XGUI / XGUI_PropertyPanel.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 /*
4  * XGUI_PropertyPanel.h
5  *
6  *  Created on: Apr 29, 2014
7  *      Author: sbh
8  */
9
10 #ifndef XGUI_PROPERTYPANEL_H_
11 #define XGUI_PROPERTYPANEL_H_
12
13 #include "XGUI.h"
14
15 #include <ModuleBase_ModelWidget.h>
16 #include <ModuleBase_IPropertyPanel.h>
17
18 #include <QList>
19
20 class XGUI_ActionsMgr;
21 class QKeyEvent;
22 class QGridLayout;
23 class ModuleBase_PageBase;
24 class ModuleBase_PageWidget;
25 class XGUI_OperationMgr;
26
27 /// Internal name of property panel widget
28 const static char* PROP_PANEL = "property_panel_dock";
29
30 /// Internal name of Ok button
31 const static char* PROP_PANEL_OK = "property_panel_ok";
32
33 /// Internal name of Cancel button
34 const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
35
36 /// Internal name of Help button
37 const static char* PROP_PANEL_HELP = "property_panel_help";
38
39 /**
40 * \ingroup GUI
41 * Realization of Property panel object.
42 */
43 class XGUI_EXPORT XGUI_PropertyPanel : public ModuleBase_IPropertyPanel
44 {
45 Q_OBJECT
46  public:
47
48   /// Constructor
49   /// \param theParent is a parent of the property panel
50   /// \param theMgr operation manager
51   XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr);
52
53   virtual ~XGUI_PropertyPanel();
54
55   /// Returns header widget
56   virtual QWidget* headerWidget() const { return myHeaderWidget; }
57
58   /// Returns main widget of the property panel, which children will be created
59   /// by WidgetFactory using the XML definition
60   ModuleBase_PageBase* contentWidget();
61
62   /// Brings back all widget created by widget factory for signal/slot
63   /// connections and further processing
64   void setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets);
65
66   /// Returns all property panel's widget created by WidgetFactory
67   virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const;
68
69   /// Removes all widgets in the widget area of the property panel
70   virtual void cleanContent();
71
72   /// Returns currently active widget
73   virtual ModuleBase_ModelWidget* activeWidget() const { return myActiveWidget; }
74
75   /// Activate the next widget in the property panel
76   /// \param theWidget a widget. The next widget should be activated
77   virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget);
78
79   /// Activate the next from current widget in the property panel
80   virtual void activateNextWidget();
81
82   /// Set focus on the Ok button
83   virtual void setFocusOnOkButton();
84
85   /// Set Enable/Disable state of Cancel button
86   /// \param theEnabled Enable/Disable state of Cancel button
87   virtual void setCancelEnabled(bool theEnabled);
88
89   /// \return Enable/Disable state of Cancel button
90   virtual bool isCancelEnabled() const;
91
92   /// Editing mode depends on mode of current operation. This value is defined by it.
93   /// \param isEditing state of editing mode flag
94   virtual void setEditingMode(bool isEditing);
95
96   //! Allows to set predefined actions for the property panel fetched from the ActionsMgr
97   void setupActions(XGUI_ActionsMgr* theMgr);
98
99   /// Returns widget processed by preselection
100   virtual ModuleBase_ModelWidget* preselectionWidget() const;
101
102   /// Sets widget processed by preselection
103   virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget);
104
105   /// Returns operation manager
106   XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
107
108 public slots:
109
110    /// \brief Update all widgets in property panel with values from the given feature
111    /// \param theFeature a Feature to update values in widgets
112   void updateContentWidget(FeaturePtr theFeature);
113
114   /**
115   * Makes the given widget active, highlights it and removes
116   * highlighting from the previous active widget
117   * emits widgetActivated(theWidget) signal
118   * \param theWidget which has to be activated
119   */
120   virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
121
122 signals:
123   void enterClicked();
124
125 protected:
126   /// Makes the widget active, deactivate the previous, activate and hightlight the given one
127   /// \param theWidget a widget
128   bool setActiveWidget(ModuleBase_ModelWidget* theWidget);
129
130   /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events
131   /// Emits a signal about focus change
132   /// If theIsNext is true, this function searches forward, if next is false, it searches backward.
133   virtual bool focusNextPrevChild(bool theIsNext);
134
135  protected:
136    /// A method called on the property panel closed
137    /// \param theEvent a close event
138    void closeEvent(QCloseEvent* theEvent);
139
140   /// A header widget
141   QWidget* myHeaderWidget;
142
143  private:
144   ModuleBase_PageWidget* myPanelPage;
145   QList<ModuleBase_ModelWidget*> myWidgets;
146
147   /// Currently active widget
148   ModuleBase_ModelWidget* myActiveWidget;
149   /// Currently widget processed by preselection
150   ModuleBase_ModelWidget* myPreselectionWidget;
151
152   XGUI_OperationMgr* myOperationMgr;
153 };
154
155 #endif /* XGUI_PROPERTYPANEL_H_ */