Salome HOME
Fix member names confusion
[modules/shaper.git] / src / CollectionPlugin / CollectionPlugin_WidgetField.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        CollectionPlugin_WidgetField.h
4 // Created:     16 Nov 2016
5 // Author:      Vitaly SMETANNIKOV
6
7
8 #ifndef CollectionPlugin_WidgetField_H
9 #define CollectionPlugin_WidgetField_H
10
11
12 #include "CollectionPlugin.h"
13
14 #include <ModuleBase_WidgetSelector.h>
15 #include <ModuleBase_ViewerPrs.h>
16 #include <ModelAPI_AttributeTables.h>
17
18 #include <QList>
19 #include <QStringList>
20
21
22 class QWidget;
23 class QComboBox;
24 class QSpinBox;
25 class QLabel;
26 class QSlider;
27 class QTableWidget;
28 class QStackedWidget;
29 class QPushButton;
30 class QTableWidgetItem;
31 class QLineEdit;
32
33 /*!
34  * \ingroup GUI
35  * Represent a content of the property panel to show/modify parameters of a Field feature.
36  */
37 class CollectionPlugin_WidgetField : public ModuleBase_WidgetSelector
38 {
39  Q_OBJECT
40 public:
41   CollectionPlugin_WidgetField(QWidget* theParent,
42                                ModuleBase_IWorkshop* theWorkshop,
43                                const Config_WidgetAPI* theData);
44
45   virtual ~CollectionPlugin_WidgetField() {}
46
47   /// Returns list of widget controls
48   /// \return a control list
49   virtual QList<QWidget*> getControls() const;
50
51   /// Checks the widget validity. By default, it returns true.
52   /// \param thePrs a selected presentation in the view
53   /// \return a boolean value
54   virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
55
56   /// Returns true if the event is processed.
57   virtual bool processEnter();
58
59   /// The methiod called when widget is deactivated
60   virtual void deactivate();
61
62 protected:
63   /// Saves the internal parameters to the given feature
64   /// \return True in success
65   virtual bool storeValueCustom();
66
67   /// Restore value from attribute data to the widget's control
68   virtual bool restoreValueCustom();
69
70   /// Retunrs a list of possible shape types
71   /// \return a list of shapes
72   virtual QIntList shapeTypes() const;
73
74   /// Redefinition of virtual function
75   /// \param theObject an object for the event
76   /// \param theEvent an event
77   virtual bool eventFilter(QObject* theObject, QEvent* theEvent);
78
79   //virtual void showEvent(QShowEvent* theEvent);
80
81 protected slots:
82   /// Slot which is called on selection event
83   virtual void onSelectionChanged();
84
85 private slots:
86   /// Slot called on number of component changed
87   /// \param theVal - a new components number
88   void onNbCompChanged(int theVal);
89
90   /// Slot called on add a step
91   void onAddStep();
92
93   /// Slot called on remove a step
94   void onRemoveStep();
95
96   /// Slot called on a navigation between steps
97   /// \param theStep - a current step
98   void onStepMove(int theStep);
99
100   /// Slot called on a navigation between steps
101   /// \param theIdx - a current step
102   void onFieldTypeChanged(int theIdx);
103
104   /// Slot called on editing of a table cell
105   /// \param theRow a row of the cell
106   /// \param theCol a column of the cell
107   void onTableEdited(int theRow, int theCol);
108
109   /// Slot called on selection mode changed
110   /// \param theType a new choice
111   void onShapeTypeChanged(int theType);
112
113   /// Slot called on widget focus changed
114   /// \param theOld a widget wgich lost focus
115   /// \param theNew a widget which get focus
116   void onFocusChanged(QWidget* theOld, QWidget* theNew);
117
118   /// Slot called on a slider navigation changed
119   /// \param theMin - a minimal value
120   /// \param theMax a maximal value
121   void onRangeChanged(int theMin, int theMax);
122
123   void onColumnResize(int theIndex, int theOld, int theNew);
124
125 private:
126   /// Clear existing tables
127   void clearData();
128
129   /// Append controls for management of a new step
130   void appendStepControls();
131
132   /// Remove current step controls
133   void removeStepControls();
134
135   /// Update header of a table
136   /// \param theDataTbl a table widget
137   void updateHeaders(QTableWidget* theDataTbl) const;
138
139   /// Return Item Id of myShapeTypeCombo by selection mode
140   /// \param theStr a selection mode
141   int getSelectionType(const std::string& theStr) const;
142
143   /// Return selection mode by Item Id of myShapeTypeCombo
144   /// \param theType an item id
145   std::string getSelectionType(int theType) const;
146
147   /// Create default table item
148   QTableWidgetItem* createDefaultItem() const;
149
150   /// Create a table item from the given value
151   /// \param theVal a value for the item
152   QTableWidgetItem* createValueItem(ModelAPI_AttributeTables::Value& theVal) const;
153
154   QString getValueText(ModelAPI_AttributeTables::Value& theVal) const;
155
156   /// Return a value from the string
157   /// \param theStrVal a string
158   ModelAPI_AttributeTables::Value getValue(QString theStrVal) const;
159
160   /// Types of shapes selection
161   QComboBox* myShapeTypeCombo;
162
163   /// Types of field data
164   QComboBox* myFieldTypeCombo;
165
166   /// Number of components
167   QSpinBox* myNbComponentsSpn;
168
169   /// Label of current step
170   QLabel* myCurStepLbl;
171
172   /// Slider for steps management
173   QSlider* myStepSlider;
174
175   /// Stamp value
176   QList<QSpinBox*> myStampSpnList;
177
178   /// List of created tables
179   QList<QTableWidget*> myDataTblList;
180
181   /// Max value Label for the slider
182   QLabel* myMaxLbl;
183
184   /// A container for step controls
185   QStackedWidget* myStepWgt;
186
187   /// A list for component names
188   QStringList myCompNamesList;
189
190   /// Remove button
191   QPushButton* myRemoveBtn;
192
193   /// Editor for table header
194   QLineEdit* myHeaderEditor;
195
196   /// Index of header section under editing
197   int myEditIndex;
198
199   /// Stae of a table editing
200   bool myIsTabEdit;
201
202   bool myActivation;
203 };
204
205 #endif