Salome HOME
Issue #326 Distance constraint on 2 preselected segments problem
[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 QKeyEvent;
21 class QVBoxLayout;
22
23 /// Internal name of property panel widget
24 const static char* PROP_PANEL = "property_panel_dock";
25
26 /// Internal name of Ok button
27 const static char* PROP_PANEL_OK = "property_panel_ok";
28
29 /// Internal name of Cancel button
30 const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
31
32 /**
33 * Realization of Property panel object.
34 */
35 class XGUI_EXPORT XGUI_PropertyPanel : public ModuleBase_IPropertyPanel
36 {
37 Q_OBJECT
38  public:
39
40   /// Constructor
41   /// \param theParent is a parent of the property panel
42   XGUI_PropertyPanel(QWidget* theParent);
43
44   virtual ~XGUI_PropertyPanel();
45
46   /// Returns main widget of the property panel, which children will be created
47   /// by WidgetFactory using the XML definition
48   QWidget* contentWidget();
49
50   /// Brings back all widget created by widget factory for signal/slot
51   /// connections and further processing
52   void setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets);
53
54   /// Returns all property panel's widget created by WidgetFactory
55   virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const;
56
57   /// Removes all widgets in the widget area of the property panel
58   void cleanContent();
59
60   /// Returns currently active widget
61   virtual ModuleBase_ModelWidget* activeWidget() const { return myActiveWidget; }
62
63   /// Activate the next widget in the property panel
64   /// \param theWidget a widget. The next widget should be activated
65   virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget);
66
67   /// Activate the next from current widget in the property panel
68   virtual void activateNextWidget();
69
70   /// \brief Enable/Disable stretch area in the panel
71   void setStretchEnabled(bool isEnabled);
72
73   /// Set Enable/Disable state of Ok button
74   /// \param theEnabled Enable/Disable state of Ok button
75   virtual void setOkEnabled(bool theEnabled);
76
77   /// \return Enable/disable state of Ok button
78   virtual bool isOkEnabled() const;
79
80   /// Set Enable/Disable state of Cancel button
81   /// \param theEnabled Enable/Disable state of Cancel button
82   virtual void setCancelEnabled(bool theEnabled);
83
84   /// \return Enable/Disable state of Cancel button
85   virtual bool isCancelEnabled() const;
86
87   /// Editing mode depends on mode of current operation. This value is defined by it.
88   /// \param isEditing state of editing mode flag
89   virtual void setEditingMode(bool isEditing);
90
91  public slots:
92
93    /// \brief Update all widgets in property panel with values from the given feature
94    /// \param theFeature a Feature to update values in widgets
95   void updateContentWidget(FeaturePtr theFeature);
96
97   /// Enables / disables "ok" ("accept") button
98   /// \param toEnable enable/disable state of button
99   void setAcceptEnabled(bool toEnable);
100
101   /**
102   * Makes the given widget active, highlights it and removes
103   * highlighting from the previous active widget
104   * emits widgetActivated(theWidget) signal
105   * \param theWidget which has to be activated
106   */
107   virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
108
109  private:
110   QWidget* myCustomWidget;
111   QList<ModuleBase_ModelWidget*> myWidgets;
112   QVBoxLayout* myMainLayout;
113
114   /// Currently active widget
115   ModuleBase_ModelWidget* myActiveWidget;
116 };
117
118 #endif /* XGUI_PROPERTYPANEL_H_ */