1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: CollectionPlugin_WidgetField.h
4 // Created: 16 Nov 2016
5 // Author: Vitaly SMETANNIKOV
8 #ifndef CollectionPlugin_WidgetField_H
9 #define CollectionPlugin_WidgetField_H
12 #include "CollectionPlugin.h"
14 #include <ModuleBase_WidgetSelector.h>
15 #include <ModuleBase_ViewerPrs.h>
16 #include <ModelAPI_AttributeTables.h>
19 #include <QStringList>
30 class QTableWidgetItem;
35 * Represent a content of the property panel to show/modify parameters of a Field feature.
37 class CollectionPlugin_WidgetField : public ModuleBase_WidgetSelector
41 CollectionPlugin_WidgetField(QWidget* theParent,
42 ModuleBase_IWorkshop* theWorkshop,
43 const Config_WidgetAPI* theData);
45 virtual ~CollectionPlugin_WidgetField() {}
47 /// Returns list of widget controls
48 /// \return a control list
49 virtual QList<QWidget*> getControls() const;
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);
58 /// Saves the internal parameters to the given feature
59 /// \return True in success
60 virtual bool storeValueCustom();
62 /// Restore value from attribute data to the widget's control
63 virtual bool restoreValueCustom();
65 /// Retunrs a list of possible shape types
66 /// \return a list of shapes
67 virtual QIntList shapeTypes() const;
69 virtual bool eventFilter(QObject* theObbject, QEvent* theEvent);
73 /// Slot which is called on selection event
74 virtual void onSelectionChanged();
77 void onNbCompChanged(int theVal);
83 void onStepMove(int theStep);
85 void onFieldTypeChanged(int theIdx);
87 void onTableEdited(int theRow, int theCol);
89 void onShapeTypeChanged(int theType);
94 void appendStepControls();
95 void removeStepControls();
97 void updateHeaders(QTableWidget* theDataTbl) const;
99 int getSelectionType(const std::string& theStr) const;
101 std::string getSelectionType(int theType) const;
103 QTableWidgetItem* createDefaultItem() const;
105 QTableWidgetItem* createValueItem(ModelAPI_AttributeTables::Value& theVal) const;
107 ModelAPI_AttributeTables::Value getValue(QString theStrVal) const;
109 /// Types of shapes selection
110 QComboBox* myShapeTypeCombo;
112 /// Types of field data
113 QComboBox* myFieldTypeCombo;
115 /// Number of components
116 QSpinBox* myNbComponentsSpn;
118 /// Label of current step
119 QLabel* myCurStepLbl;
121 /// Slider for steps management
122 QSlider* myStepSlider;
125 QList<QSpinBox*> myStampSpnList;
127 QList<QTableWidget*> myDataTblList;
131 QStackedWidget* myStepWgt;
133 QStringList myCompNamesList;
135 QPushButton* myRemoveBtn;
137 QLineEdit* myHeaderEditor;