Salome HOME
94119c2059602bec2729aec5e0fa7f0f6c22380c
[modules/shaper.git] / src / PartSet / PartSet_BSplineWidget.h
1 // Copyright (C) 2019-2021  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef PartSet_BSplineWidget_H
21 #define PartSet_BSplineWidget_H
22
23
24 #include <PartSet.h>
25
26 #include <ModelAPI_Feature.h>
27
28 #include <ModuleBase_LabelValue.h>
29 #include <ModuleBase_ModelWidget.h>
30 #include <ModuleBase_ParamSpinBox.h>
31
32 class QGroupBox;
33 class QScrollArea;
34 class QToolButton;
35
36 /** \brief Represent a content of the property panel to show/modify parameters of B-spline curve.
37  *  \ingroup GUI
38  */
39 class PartSet_BSplineWidget : public ModuleBase_ModelWidget
40 {
41 Q_OBJECT
42 public:
43   /// Constructor
44   /// \param theParent the parent object
45   /// \param theData the widget configuation. The attribute of the model widget is obtained from
46   PartSet_BSplineWidget(QWidget* theParent,
47                              const Config_WidgetAPI* theData);
48
49   virtual ~PartSet_BSplineWidget() {}
50
51   /// The methiod called when widget is deactivated
52   virtual void deactivate();
53
54   /// Returns list of widget controls
55   /// \return a control list
56   virtual QList<QWidget*> getControls() const;
57
58   /// Set feature which is processing by active operation
59   /// \param theFeature a feature object
60   /// \param theToStoreValue a value about necessity to store the widget value to the feature
61   /// \param isUpdateFlushed a flag if update should be flushed on store value
62   virtual void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false,
63                           const bool isUpdateFlushed = true);
64
65 protected:
66   /// Saves the internal parameters to the given feature
67   /// \return True in success
68   virtual bool storeValueCustom();
69
70   /// Restore value from attribute data to the widget's control
71   virtual bool restoreValueCustom();
72
73   /// Create group of widgets related to coordinates of pole and its weight
74   void addPoleWidget();
75
76   /// Update attributes of B-spline feature
77   void storePolesAndWeights() const;
78
79 private slots:
80   void onAddPole();
81
82 private:
83   struct BSplinePoleWidgets {
84     ModuleBase_LabelValue* myX;
85     ModuleBase_LabelValue* myY;
86     ModuleBase_ParamSpinBox* myWeight;
87     QToolButton* myAddBtn;
88   };
89
90   QGroupBox* createPoleWidget(BSplinePoleWidgets& thePole,
91                               const QString& theName,
92                               QWidget* theParent);
93
94   QWidget* myPolesWgt; ///< widget to show poles and weights of B-spline curve
95   QGroupBox* myPolesGroupBox;
96   QScrollArea* myScrollArea;
97   std::list<BSplinePoleWidgets> myPoles; ///< list of B-spline poles and their weights
98 };
99
100 #endif