Salome HOME
30fa4c6f01af91ba5eb3578ccd1588ce1764044d
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_BSplineWidget.h
1 // Copyright (C) 2019-2020  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 SketchPlugin_BSplineWidget_H
21 #define SketchPlugin_BSplineWidget_H
22
23
24 #include <SketchPlugin.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
34
35 /** \brief Represent a content of the property panel to show/modify parameters of B-spline curve.
36  *  \ingroup GUI
37  */
38 class SketchPlugin_BSplineWidget : public ModuleBase_ModelWidget
39 {
40 Q_OBJECT
41 public:
42   /// Constructor
43   /// \param theParent the parent object
44   /// \param theData the widget configuation. The attribute of the model widget is obtained from
45   SketchPlugin_BSplineWidget(QWidget* theParent,
46                              const Config_WidgetAPI* theData);
47
48   virtual ~SketchPlugin_BSplineWidget() {}
49
50   /// The methiod called when widget is deactivated
51   virtual void deactivate();
52
53   /// Returns list of widget controls
54   /// \return a control list
55   virtual QList<QWidget*> getControls() const;
56
57   /// Set feature which is processing by active operation
58   /// \param theFeature a feature object
59   /// \param theToStoreValue a value about necessity to store the widget value to the feature
60   /// \param isUpdateFlushed a flag if update should be flushed on store value
61   virtual void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false,
62                           const bool isUpdateFlushed = true);
63
64 protected:
65   /// Saves the internal parameters to the given feature
66   /// \return True in success
67   virtual bool storeValueCustom();
68
69   /// Restore value from attribute data to the widget's control
70   virtual bool restoreValueCustom();
71
72   /// Create group of widgets related to coordinates of pole and its weight
73   void addPoleWidget();
74
75   /// Update attributes of B-spline feature
76   void storePolesAndWeights() const;
77
78 private:
79   struct BSplinePoleWidgets {
80     ModuleBase_LabelValue* myX;
81     ModuleBase_LabelValue* myY;
82     ModuleBase_ParamSpinBox* myWeight;
83   };
84
85   QGroupBox* myPolesGroupBox; ///< widget to show poles and weights of B-spline curve
86   std::list<BSplinePoleWidgets> myPoles; ///< list of B-spline poles and their weights
87 };
88
89 #endif