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);
56 /// Returns true if the event is processed.
57 virtual bool processEnter();
59 /// The methiod called when widget is deactivated
60 virtual void deactivate();
63 /// Saves the internal parameters to the given feature
64 /// \return True in success
65 virtual bool storeValueCustom();
67 /// Restore value from attribute data to the widget's control
68 virtual bool restoreValueCustom();
70 /// Retunrs a list of possible shape types
71 /// \return a list of shapes
72 virtual QIntList shapeTypes() const;
74 virtual bool eventFilter(QObject* theObbject, QEvent* theEvent);
78 /// Slot which is called on selection event
79 virtual void onSelectionChanged();
82 void onNbCompChanged(int theVal);
88 void onStepMove(int theStep);
90 void onFieldTypeChanged(int theIdx);
92 void onTableEdited(int theRow, int theCol);
94 void onShapeTypeChanged(int theType);
96 void onFocusChanged(QWidget* theOld, QWidget* theNew);
98 void onRangeChanged(int theMin, int theMax);
103 void appendStepControls();
104 void removeStepControls();
106 void updateHeaders(QTableWidget* theDataTbl) const;
108 int getSelectionType(const std::string& theStr) const;
110 std::string getSelectionType(int theType) const;
112 QTableWidgetItem* createDefaultItem() const;
114 QTableWidgetItem* createValueItem(ModelAPI_AttributeTables::Value& theVal) const;
116 ModelAPI_AttributeTables::Value getValue(QString theStrVal) const;
118 /// Types of shapes selection
119 QComboBox* myShapeTypeCombo;
121 /// Types of field data
122 QComboBox* myFieldTypeCombo;
124 /// Number of components
125 QSpinBox* myNbComponentsSpn;
127 /// Label of current step
128 QLabel* myCurStepLbl;
130 /// Slider for steps management
131 QSlider* myStepSlider;
134 QList<QSpinBox*> myStampSpnList;
136 QList<QTableWidget*> myDataTblList;
140 QStackedWidget* myStepWgt;
142 QStringList myCompNamesList;
144 QPushButton* myRemoveBtn;
146 QLineEdit* myHeaderEditor;