Salome HOME
803b520e41cc79f81612d72e9feaa775b5e898ca
[modules/shaper.git] / src / ModuleBase / ModuleBase_IPropertyPanel.h
1 // Copyright (C) 2014-2022  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef ModuleBase_PROPERTYPANEL_H_
21 #define ModuleBase_PROPERTYPANEL_H_
22
23 #include "ModuleBase.h"
24
25 #include <QDockWidget>
26 #include <QKeyEvent>
27
28 class ModuleBase_ModelWidget;
29
30 /**
31 * \ingroup GUI
32 * A class for Property panel object definition
33 */
34 class MODULEBASE_EXPORT ModuleBase_IPropertyPanel : public QDockWidget
35 {
36 Q_OBJECT
37 public:
38   /// Constructor
39   /// \param theParent is a parent of the property panel
40   ModuleBase_IPropertyPanel(QWidget* theParent);
41
42   /// Returns header widget
43   virtual QWidget* headerWidget() const = 0;
44
45   /// Returns currently active widget. This is a widget from internal container of widgets
46   /// (myWidgets) activated/deactivated by focus in property panel. If parameter is true,
47   /// the method finds firstly the custom widget, after the direct active widget.
48   /// \param isUseCustomWidget boolean state if the custom widget might be a result
49   virtual ModuleBase_ModelWidget* activeWidget(const bool isUseCustomWidget = false) const = 0;
50
51   /// Returns all property panel's widget created by WidgetFactory
52   virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const = 0;
53
54   /// Returns widget, that has the given attribute index
55   /// \param theAttributeId an attribute from XML
56   virtual ModuleBase_ModelWidget* modelWidget(const std::string& theAttributeId) const;
57
58   /// Removes all widgets in the widget area of the property panel
59   virtual void cleanContent() = 0;
60
61   /// Editing mode depends on mode of current operation. This value is defined by it.
62   /// \param isEditing state of editing mode flag
63   virtual void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
64
65   /// \return State of editing mode flag
66   bool isEditingMode() const { return myIsEditing; }
67
68   /// Set focus on the Ok button
69   virtual void setFocusOnOkButton() = 0;
70
71   /// Set Enable/Disable state of Cancel button
72   /// \param theEnabled Enable/Disable state of Cancel button
73   virtual void setCancelEnabled(bool theEnabled) = 0;
74
75   /// \return Enable/Disable state of Cancel button
76   virtual bool isCancelEnabled() const = 0;
77
78   /// Returns widget processed by preselection
79   virtual ModuleBase_ModelWidget* preselectionWidget() const = 0;
80
81   /// Sets widget processed by preselection
82   virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget) = 0;
83
84   /// Returns the first widget, where canAcceptFocus returns true
85   /// \return a widget or null
86   ModuleBase_ModelWidget* findFirstAcceptingValueWidget();
87
88   /// The method is called on accepting of operation
89   virtual void onAcceptData() = 0;
90
91   /// Returns True if data of its feature was modified during operation
92   virtual bool isModified() const;
93
94   /// Returns the first widget, where canAcceptFocus returns true
95   /// \return a widget or null
96   static ModuleBase_ModelWidget* findFirstAcceptingValueWidget(
97                           const QList<ModuleBase_ModelWidget*>& theWidgets);
98
99 signals:
100   /// The signal about key release on the control, that corresponds to the attribute
101   /// \param theObject a sender of the event
102   /// \param theEvent key release event
103   void keyReleased(QObject* theObject, QKeyEvent* theEvent);
104
105   /// The signal about the widget activation
106   /// \param theWidget the activated widget
107   void beforeWidgetActivated(ModuleBase_ModelWidget* theWidget);
108
109   /// The signal about the widget activation
110   /// \param theWidget the activated widget
111   //void widgetActivated(ModuleBase_ModelWidget* theWidget);
112
113   /// Emited when there is no next widget
114   /// \param thePreviousAttributeID an attribute key of the previous active widget
115   void noMoreWidgets(const std::string& thePreviousAttributeID);
116
117 public slots:
118   /// Activate the next widget in the property panel
119   /// \param theWidget a widget. The next widget should be activated
120   virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget) = 0;
121
122   /// Activate the next from current widget in the property panel
123   virtual void activateNextWidget() = 0;
124
125   /**
126   * Makes the given widget active, highlights it and removes
127   * highlighting from the previous active widget
128   * \param theWidget which has to be activated
129   * \param theEmitSignal a flag to prohibit signal emit
130   */
131   virtual void activateWidget(ModuleBase_ModelWidget* theWidget,
132                               const bool theEmitSignal = true) = 0;
133
134 protected:
135
136   /// Flag which shows that current operation is in editing mode
137   bool myIsEditing;
138 };
139
140 #endif