]> SALOME platform Git repositories - modules/shaper.git/blob - src/CollectionPlugin/CollectionPlugin_WidgetField.h
Salome HOME
816cfb7bf047729bcb09dff5b9b2d1af79cf7e56
[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   virtual bool eventFilter(QObject* theObbject, QEvent* theEvent);
75
76
77 protected slots:
78   /// Slot which is called on selection event
79   virtual void onSelectionChanged();
80
81 private slots:
82   void onNbCompChanged(int theVal);
83
84   void onAddStep();
85
86   void onRemoveStep();
87
88   void onStepMove(int theStep);
89
90   void onFieldTypeChanged(int theIdx);
91
92   void onTableEdited(int theRow, int theCol);
93
94   void onShapeTypeChanged(int theType);
95
96   void onFocusChanged(QWidget* theOld, QWidget* theNew);
97
98   void onRangeChanged(int theMin, int theMax);
99
100 private:
101   void clearData();
102
103   void appendStepControls();
104   void removeStepControls();
105
106   void updateHeaders(QTableWidget* theDataTbl) const;
107
108   int getSelectionType(const std::string& theStr) const;
109
110   std::string getSelectionType(int theType) const;
111
112   QTableWidgetItem* createDefaultItem() const;
113
114   QTableWidgetItem* createValueItem(ModelAPI_AttributeTables::Value& theVal) const;
115
116   ModelAPI_AttributeTables::Value getValue(QString theStrVal) const;
117
118   /// Types of shapes selection
119   QComboBox* myShapeTypeCombo;
120
121   /// Types of field data
122   QComboBox* myFieldTypeCombo;
123
124   /// Number of components
125   QSpinBox* myNbComponentsSpn;
126
127   /// Label of current step
128   QLabel* myCurStepLbl;
129
130   /// Slider for steps management
131   QSlider* myStepSlider;
132
133   /// Stamp value
134   QList<QSpinBox*> myStampSpnList;
135
136   QList<QTableWidget*> myDataTblList;
137
138   QLabel* myMaxLbl;
139
140   QStackedWidget* myStepWgt;
141
142   QStringList myCompNamesList;
143
144   QPushButton* myRemoveBtn;
145
146   QLineEdit* myHeaderEditor;
147   int myEditIndex;
148
149   bool myIsEditing;
150 };
151
152 #endif