Salome HOME
Issue #1865: Create a field
[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
57 protected:
58   /// Saves the internal parameters to the given feature
59   /// \return True in success
60   virtual bool storeValueCustom();
61
62   /// Restore value from attribute data to the widget's control
63   virtual bool restoreValueCustom();
64
65   /// Retunrs a list of possible shape types
66   /// \return a list of shapes
67   virtual QIntList shapeTypes() const;
68
69   virtual bool eventFilter(QObject* theObbject, QEvent* theEvent);
70
71
72 protected slots:
73   /// Slot which is called on selection event
74   virtual void onSelectionChanged();
75
76 private slots:
77   void onNbCompChanged(int theVal);
78
79   void onAddStep();
80
81   void onRemoveStep();
82
83   void onStepMove(int theStep);
84
85   void onFieldTypeChanged(int theIdx);
86
87   void onTableEdited(int theRow, int theCol);
88
89   void onShapeTypeChanged(int theType);
90
91 private:
92   void clearData();
93
94   void appendStepControls();
95   void removeStepControls();
96
97   void updateHeaders(QTableWidget* theDataTbl) const;
98
99   int getSelectionType(const std::string& theStr) const;
100
101   std::string getSelectionType(int theType) const;
102
103   QTableWidgetItem* createDefaultItem() const;
104
105   QTableWidgetItem* createValueItem(ModelAPI_AttributeTables::Value& theVal) const;
106
107   ModelAPI_AttributeTables::Value getValue(QString theStrVal) const;
108
109   /// Types of shapes selection
110   QComboBox* myShapeTypeCombo;
111
112   /// Types of field data
113   QComboBox* myFieldTypeCombo;
114
115   /// Number of components
116   QSpinBox* myNbComponentsSpn;
117
118   /// Label of current step
119   QLabel* myCurStepLbl;
120
121   /// Slider for steps management
122   QSlider* myStepSlider;
123
124   /// Stamp value
125   QList<QSpinBox*> myStampSpnList;
126
127   QList<QTableWidget*> myDataTblList;
128
129   QLabel* myMaxLbl;
130
131   QStackedWidget* myStepWgt;
132
133   QStringList myCompNamesList;
134
135   QPushButton* myRemoveBtn;
136
137   QLineEdit* myHeaderEditor;
138   int myEditIndex;
139 };
140
141 #endif