]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Update B-Spline GUI
authorvsv <vsv@opencascade.com>
Mon, 20 Jan 2020 16:28:17 +0000 (19:28 +0300)
committervsv <vsv@opencascade.com>
Mon, 20 Jan 2020 16:28:29 +0000 (19:28 +0300)
14 files changed:
src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_BSplineWidget.cpp [new file with mode: 0644]
src/PartSet/PartSet_BSplineWidget.h [new file with mode: 0644]
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetBSplinePoints.cpp
src/PartSet/PartSet_WidgetBSplinePoints.h
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_BSplineWidget.cpp [deleted file]
src/SketchPlugin/SketchPlugin_BSplineWidget.h [deleted file]
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_WidgetCreator.cpp [deleted file]
src/SketchPlugin/SketchPlugin_WidgetCreator.h [deleted file]
src/SketchPlugin/plugin-Sketch.xml

index 637e37b4e8de2f9edff675305ab4198034e474f2..e4f47673e86a92aa62e55f268e79979a090e03cd 100644 (file)
@@ -60,6 +60,8 @@ ConstructionPlugin_Plugin::ConstructionPlugin_Plugin()
     Config_Prop::IntSpin, SKETCH_WIDTH);
   Config_PropManager::registerProp(SKETCH_TAB_NAME, "angular_tolerance", "Angular tolerance",
     Config_Prop::DblSpin, "0.04");
+  Config_PropManager::registerProp(SKETCH_TAB_NAME, "spline_weight", "Default spline weight",
+    Config_Prop::DblSpin, "1.0");
   Config_PropManager::registerProp(SKETCH_TAB_NAME, "rotate_to_plane",
     "Rotate to plane when selected", Config_Prop::Boolean, "false");
 
index 0384951d615424e71366c2549568d8b26b301bdd..9f87f6c3f8e40628488edfaea216871c781fe977 100644 (file)
@@ -62,6 +62,7 @@ SET(PROJECT_HEADERS
     PartSet_TreeNodes.h
     PartSet_FieldStepPrs.h
     PartSet_WidgetBSplinePoints.h
+    PartSet_BSplineWidget.h
 )
 
 SET(PROJECT_MOC_HEADERS
@@ -81,6 +82,7 @@ SET(PROJECT_MOC_HEADERS
     PartSet_WidgetSketchLabel.h
     PartSet_WidgetBSplinePoints.h
     PartSet_ExternalPointsMgr.h
+    PartSet_BSplineWidget.h
 )
 
 SET(PROJECT_SOURCES
@@ -114,6 +116,7 @@ SET(PROJECT_SOURCES
     PartSet_TreeNodes.cpp
     PartSet_FieldStepPrs.cpp
     PartSet_WidgetBSplinePoints.cpp
+    PartSet_BSplineWidget.cpp
 )
 
 SET(PROJECT_RESOURCES
diff --git a/src/PartSet/PartSet_BSplineWidget.cpp b/src/PartSet/PartSet_BSplineWidget.cpp
new file mode 100644 (file)
index 0000000..7093c28
--- /dev/null
@@ -0,0 +1,181 @@
+// Copyright (C) 2019-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <PartSet_BSplineWidget.h>
+
+#include <SketchPlugin_BSpline.h>
+
+#include <ModuleBase_Tools.h>
+
+#include <ModelAPI_AttributeDoubleArray.h>
+
+#include <GeomDataAPI_Point2DArray.h>
+
+#include <GeomAPI_Pnt2d.h>
+
+#include <QFormLayout>
+#include <QGroupBox>
+#include <QLabel>
+#include <QVBoxLayout>
+
+
+PartSet_BSplineWidget::PartSet_BSplineWidget(
+    QWidget* theParent,
+    const Config_WidgetAPI* theData)
+  : ModuleBase_ModelWidget(theParent, theData)
+{
+  QVBoxLayout* aMainLayout = new QVBoxLayout(this);
+  ModuleBase_Tools::adjustMargins(aMainLayout);
+
+  // GroupBox to keep widgets for B-spline poles and weights
+  myPolesGroupBox = new QGroupBox(tr("Poles and weights"), theParent);
+  aMainLayout->addWidget(myPolesGroupBox);
+  // layout of GroupBox
+  QGridLayout* aGroupLayout = new QGridLayout(myPolesGroupBox);
+  aGroupLayout->setSpacing(4);
+  aGroupLayout->setColumnStretch(1, 1);
+  ModuleBase_Tools::adjustMargins(aGroupLayout);
+
+  restoreValueCustom();
+}
+
+void PartSet_BSplineWidget::setFeature(const FeaturePtr& theFeature,
+                                            const bool theToStoreValue,
+                                            const bool isUpdateFlushed)
+{
+  ModuleBase_ModelWidget::setFeature(theFeature, theToStoreValue, isUpdateFlushed);
+  restoreValueCustom();
+}
+
+void PartSet_BSplineWidget::deactivate()
+{
+  ModuleBase_ModelWidget::deactivate();
+  storeValueCustom();
+}
+
+
+QList<QWidget*> PartSet_BSplineWidget::getControls() const
+{
+  QList<QWidget*> aControls;
+  std::list<BSplinePoleWidgets>::const_iterator anIt = myPoles.begin();
+  for (; anIt != myPoles.end(); ++anIt) {
+    aControls.append(anIt->myWeight);
+  }
+  return aControls;
+}
+
+void PartSet_BSplineWidget::storePolesAndWeights() const
+{
+  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
+  //AttributePoint2DArrayPtr aPointArray = std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(
+  //    aData->attribute(SketchPlugin_BSpline::POLES_ID()));
+  AttributeDoubleArrayPtr aWeightsArray = aData->realArray(SketchPlugin_BSpline::WEIGHTS_ID());
+
+  //aPointArray->setSize((int)myPoles.size());
+  //aWeightsArray->setSize((int)myPoles.size());
+
+  std::list<BSplinePoleWidgets>::const_iterator anIt = myPoles.begin();
+  for (int anIndex = 0; anIt != myPoles.end(); ++anIndex, ++anIt) {
+    //aPointArray->setPnt(anIndex, anIt->myX->value(), anIt->myY->value());
+    aWeightsArray->setValue(anIndex, anIt->myWeight->value());
+  }
+}
+
+bool PartSet_BSplineWidget::storeValueCustom()
+{
+  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
+  if (!aData || !aData->isValid()) // can be on abort of sketcher element
+    return false;
+
+  //AttributePoint2DArrayPtr aPoles = std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(
+  //    aData->attribute(SketchPlugin_BSpline::POLES_ID()));
+  AttributeDoubleArrayPtr aWeights = aData->realArray(SketchPlugin_BSpline::WEIGHTS_ID());
+
+  bool isBlocked = blockSignals(true);
+  //bool isImmutable = aPoles->setImmutable(true);
+
+  storePolesAndWeights();
+  ModuleBase_Tools::flushUpdated(myFeature);
+
+  //aPoles->setImmutable(isImmutable);
+  blockSignals(isBlocked);
+
+  updateObject(myFeature);
+  return true;
+}
+
+bool PartSet_BSplineWidget::restoreValueCustom()
+{
+  if (!myFeature)
+    return false;
+
+  DataPtr aData = myFeature->data();
+
+  AttributePoint2DArrayPtr aPoles = std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(
+      aData->attribute(SketchPlugin_BSpline::POLES_ID()));
+  AttributeDoubleArrayPtr aWeights = aData->realArray(SketchPlugin_BSpline::WEIGHTS_ID());
+
+  while (myPoles.size() < aPoles->size())
+    addPoleWidget();
+
+  std::list<BSplinePoleWidgets>::iterator anIt = myPoles.begin();
+  for (int anIndex = 0; anIt != myPoles.end(); ++anIt, ++anIndex) {
+    GeomPnt2dPtr aPoint = aPoles->pnt(anIndex);
+    anIt->myX->setValue(aPoint->x());
+    anIt->myY->setValue(aPoint->y());
+    bool isBlocked = anIt->myWeight->blockSignals(true);
+    anIt->myWeight->setValue(aWeights->value(anIndex));
+    anIt->myWeight->blockSignals(isBlocked);
+  }
+
+  return true;
+}
+
+void PartSet_BSplineWidget::addPoleWidget()
+{
+  QGridLayout* aGroupLay = dynamic_cast<QGridLayout*>(myPolesGroupBox->layout());
+  ModuleBase_Tools::adjustMargins(aGroupLay);
+
+  int aNbPoles = (int)myPoles.size();
+
+  QString aPoleStr = tr("Pole %1");
+  aPoleStr = aPoleStr.arg(aNbPoles + 1);
+
+  QGroupBox* aPoleGroupBox = new QGroupBox(aPoleStr, myPolesGroupBox);
+  QFormLayout* aPoleLay = new QFormLayout(aPoleGroupBox);
+  ModuleBase_Tools::adjustMargins(aPoleLay);
+  aPoleLay->setSpacing(2);
+
+  myPoles.push_back(BSplinePoleWidgets());
+  BSplinePoleWidgets& aPoleWidgets = myPoles.back();
+
+  aPoleWidgets.myX = new ModuleBase_LabelValue(aPoleGroupBox, tr("X"));
+  aPoleLay->addRow(aPoleWidgets.myX);
+  aPoleWidgets.myY = new ModuleBase_LabelValue(aPoleGroupBox, tr("Y"));
+  aPoleLay->addRow(aPoleWidgets.myY);
+  aPoleWidgets.myWeight = new ModuleBase_ParamSpinBox(aPoleGroupBox);
+  aPoleWidgets.myWeight->setMinimum(0.0);
+  aPoleLay->addRow(tr("Weight") + " : ", aPoleWidgets.myWeight);
+
+  aGroupLay->addWidget(aPoleGroupBox, aNbPoles, 1);
+
+  // we should listen textChanged signal as valueChanged do not send when text is modified
+  connect(aPoleWidgets.myWeight, SIGNAL(textChanged(const QString&)),
+    this, SIGNAL(valuesChanged()));
+}
diff --git a/src/PartSet/PartSet_BSplineWidget.h b/src/PartSet/PartSet_BSplineWidget.h
new file mode 100644 (file)
index 0000000..29a5fea
--- /dev/null
@@ -0,0 +1,89 @@
+// Copyright (C) 2019-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef PartSet_BSplineWidget_H
+#define PartSet_BSplineWidget_H
+
+
+#include <PartSet.h>
+
+#include <ModelAPI_Feature.h>
+
+#include <ModuleBase_LabelValue.h>
+#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_ParamSpinBox.h>
+
+class QGroupBox;
+
+
+/** \brief Represent a content of the property panel to show/modify parameters of B-spline curve.
+ *  \ingroup GUI
+ */
+class PartSet_BSplineWidget : public ModuleBase_ModelWidget
+{
+Q_OBJECT
+public:
+  /// Constructor
+  /// \param theParent the parent object
+  /// \param theData the widget configuation. The attribute of the model widget is obtained from
+  PartSet_BSplineWidget(QWidget* theParent,
+                             const Config_WidgetAPI* theData);
+
+  virtual ~PartSet_BSplineWidget() {}
+
+  /// The methiod called when widget is deactivated
+  virtual void deactivate();
+
+  /// Returns list of widget controls
+  /// \return a control list
+  virtual QList<QWidget*> getControls() const;
+
+  /// Set feature which is processing by active operation
+  /// \param theFeature a feature object
+  /// \param theToStoreValue a value about necessity to store the widget value to the feature
+  /// \param isUpdateFlushed a flag if update should be flushed on store value
+  virtual void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false,
+                          const bool isUpdateFlushed = true);
+
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValueCustom();
+
+  /// Restore value from attribute data to the widget's control
+  virtual bool restoreValueCustom();
+
+  /// Create group of widgets related to coordinates of pole and its weight
+  void addPoleWidget();
+
+  /// Update attributes of B-spline feature
+  void storePolesAndWeights() const;
+
+private:
+  struct BSplinePoleWidgets {
+    ModuleBase_LabelValue* myX;
+    ModuleBase_LabelValue* myY;
+    ModuleBase_ParamSpinBox* myWeight;
+  };
+
+  QGroupBox* myPolesGroupBox; ///< widget to show poles and weights of B-spline curve
+  std::list<BSplinePoleWidgets> myPoles; ///< list of B-spline poles and their weights
+};
+
+#endif
\ No newline at end of file
index 26a02f0d9757e4a44736e3f850297c52caa6305b..24070e7a7e180221c133e238fcfe7e16b1ce0e2f 100644 (file)
@@ -40,6 +40,7 @@
 #include "PartSet_OverconstraintListener.h"
 #include "PartSet_TreeNodes.h"
 #include "PartSet_FieldStepPrs.h"
+#include "PartSet_BSplineWidget.h"
 
 #include "PartSet_Filters.h"
 #include "PartSet_FilterInfinite.h"
@@ -928,10 +929,15 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
     aWgt = new PartSet_WidgetFileSelector(theParent, aWorkshop, theWidgetApi);
   } else if (theType == "sketch_launcher") {
     aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi);
-  } else if (theType == "module_choice") {
+  }
+  else if (theType == "module_choice") {
     aWgt = new ModuleBase_WidgetChoice(theParent, theWidgetApi);
     connect(aWgt, SIGNAL(itemSelected(ModuleBase_ModelWidget*, int)),
-            this, SLOT(onChoiceChanged(ModuleBase_ModelWidget*, int)));
+      this, SLOT(onChoiceChanged(ModuleBase_ModelWidget*, int)));
+  } else if (theType == "bspline-panel") {
+    PartSet_BSplineWidget* aPanel = new PartSet_BSplineWidget(theParent, theWidgetApi);
+    //aPanel->setFeature(theFeature);
+    aWgt = aPanel;
   }
   return aWgt;
 }
index 2cc9ee1ff91cace5a5c519f96b487e52cff244df..6a18e7e5b0bdae90124224a8f247917386c71f4c 100644 (file)
 #include <GeomDataAPI_Point2DArray.h>
 
 #include <GeomAPI_Pnt2d.h>
+#include <GeomAPI_IPresentable.h>
 
-#include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_Feature.h>
 
 #include <QGridLayout>
 #include <QGroupBox>
 #include <QMouseEvent>
+#include <QGraphicsEffect>
 
 static const double MaxCoordinate = 1e12;
 
@@ -103,7 +105,7 @@ void PartSet_WidgetBSplinePoints::createNextPoint()
   storeCurentValue();
 
   QGridLayout* aGroupLay = dynamic_cast<QGridLayout*>(myGroupBox->layout());
-  int row = (int)(myXSpin.size() + myWeightSpin.size());
+  int row = (int)myXSpin.size();
 
   QString aPoleStr = tr("Pole %1");
   aPoleStr = aPoleStr.arg(myXSpin.size() + 1);
@@ -121,18 +123,12 @@ void PartSet_WidgetBSplinePoints::createNextPoint()
 
   aGroupLay->addWidget(aPoleGroupBox, row, 1);
 
-  QString aWeightStr = tr("Weight %1");
-  aWeightStr = aWeightStr.arg(myWeightSpin.size() + 1);
-
-  myWeightSpin.push_back(new ModuleBase_LabelValue(myGroupBox, aWeightStr));
-  aGroupLay->addWidget(myWeightSpin.back(), ++row, 1);
+  setHighlighted(true);
 }
 
 void PartSet_WidgetBSplinePoints::removeLastPoint()
 {
   QGridLayout* aGroupLay = dynamic_cast<QGridLayout*>(myGroupBox->layout());
-  aGroupLay->removeWidget(myWeightSpin.back());
-  myWeightSpin.pop_back();
   aGroupLay->removeWidget(myYSpin.back());
   aGroupLay->removeWidget(myXSpin.back());
   aGroupLay->removeWidget(myXSpin.back()->parentWidget());
@@ -246,7 +242,6 @@ bool PartSet_WidgetBSplinePoints::resetCustom()
       // locking of the validating state.
       fillLabels(myXSpin, 0.0);
       fillLabels(myYSpin, 0.0);
-      fillLabels(myWeightSpin, 1.0);
 
       storeValueCustom();
       aDone = true;
@@ -267,7 +262,6 @@ bool PartSet_WidgetBSplinePoints::setPoint(double theX, double theY)
 
   myXSpin.back()->setValue(theX);
   myYSpin.back()->setValue(theY);
-  myWeightSpin.back()->setValue(1.0);
 
   storeValue();
   return true;
@@ -280,17 +274,18 @@ void PartSet_WidgetBSplinePoints::storePolesAndWeights() const
       aData->attribute(attributeID()));
   AttributeDoubleArrayPtr aWeightsArray = aData->realArray(myWeightsAttr);
 
-  aPointArray->setSize((int)myXSpin.size());
-  aWeightsArray->setSize((int)myWeightSpin.size());
+  int aSize = (int)myXSpin.size();
+  aPointArray->setSize(aSize);
+  aWeightsArray->setSize(aSize);
 
   std::vector<ModuleBase_LabelValue*>::const_iterator aXIt = myXSpin.begin();
   std::vector<ModuleBase_LabelValue*>::const_iterator aYIt = myYSpin.begin();
   for (int anIndex = 0; aXIt != myXSpin.end() && aYIt != myYSpin.end(); ++anIndex, ++aXIt, ++aYIt)
     aPointArray->setPnt(anIndex, (*aXIt)->value(), (*aYIt)->value());
 
-  std::vector<ModuleBase_LabelValue*>::const_iterator aWIt = myWeightSpin.begin();
-  for (int anIndex = 0; aWIt != myWeightSpin.end(); ++anIndex, ++aWIt)
-    aWeightsArray->setValue(anIndex, (*aWIt)->value());
+  double aWeight = Config_PropManager::real(SKETCH_TAB_NAME, "spline_weight");
+  for (int anIndex = 0; anIndex < aSize; ++anIndex)
+    aWeightsArray->setValue(anIndex, aWeight);
 }
 
 bool PartSet_WidgetBSplinePoints::storeValueCustom()
@@ -349,10 +344,6 @@ bool PartSet_WidgetBSplinePoints::restoreValueCustom()
       (*aXIt)->setValue(aPoint->x());
       (*aYIt)->setValue(aPoint->y());
     }
-
-    std::vector<ModuleBase_LabelValue*>::iterator aWIt = myWeightSpin.begin();
-    for (int anIndex = 0; aWIt != myWeightSpin.end(); ++anIndex, ++aWIt)
-      (*aWIt)->setValue(aWeightsArray->value(anIndex));
   }
   else {
     if (myXSpin.empty())
@@ -360,7 +351,6 @@ bool PartSet_WidgetBSplinePoints::restoreValueCustom()
 
     myXSpin.back()->setValue(0.0);
     myYSpin.back()->setValue(0.0);
-    myWeightSpin.back()->setValue(0.0);
   }
 
   return true;
@@ -384,7 +374,6 @@ void PartSet_WidgetBSplinePoints::storeCurentValue()
 
   storeArray(myXSpin, myXValueInCash);
   storeArray(myYSpin, myYValueInCash);
-  storeArray(myWeightSpin, myWeightInCash);
 }
 
 static void restoreArray(std::vector<double>& theCacheValues,
@@ -412,7 +401,6 @@ bool PartSet_WidgetBSplinePoints::restoreCurentValue()
   // fill the control widgets by the cashed value
   restoreArray(myXValueInCash, myXSpin);
   restoreArray(myYValueInCash, myYSpin);
-  restoreArray(myWeightInCash, myWeightSpin);
 
   // store value to the model
   storeValueCustom();
@@ -431,13 +419,20 @@ QList<QWidget*> PartSet_WidgetBSplinePoints::getControls() const
   QList<QWidget*> aControls;
   std::vector<ModuleBase_LabelValue*>::const_iterator aXIt = myXSpin.begin();
   std::vector<ModuleBase_LabelValue*>::const_iterator aYIt = myYSpin.begin();
-  std::vector<ModuleBase_LabelValue*>::const_iterator aWIt = myWeightSpin.begin();
-  for (; aXIt != myXSpin.end() && aYIt != myYSpin.end() && aWIt != myWeightSpin.end();
-       ++aXIt, ++aYIt, ++aWIt) {
-    aControls.append(*aXIt);
-    aControls.append(*aYIt);
-    aControls.append(*aWIt);
+  for (; (*aXIt) != myXSpin.back() && (*aYIt) != myYSpin.back(); ++aXIt, ++aYIt) {
+    //aControls.append(*aXIt);
+    //aControls.append(*aYIt);
+    QGraphicsEffect* anEffect = (*aXIt)->graphicsEffect();
+    if (anEffect)
+      anEffect->deleteLater();
+    anEffect = (*aYIt)->graphicsEffect();
+    if (anEffect)
+      anEffect->deleteLater();
+    (*aXIt)->setGraphicsEffect(0);
+    (*aYIt)->setGraphicsEffect(0);
   }
+  aControls.append(myXSpin.back());
+  aControls.append(myYSpin.back());
   return aControls;
 }
 
index f537dc8668e3702c33bed7f8956a13638306f82d..360af3580f471755e109b259f3c0362deb019e6e 100644 (file)
@@ -161,7 +161,6 @@ private:
   QGroupBox* myGroupBox;  ///< the parent group box for all intenal widgets
   std::vector<ModuleBase_LabelValue*> myXSpin; ///< the label for the X coordinate
   std::vector<ModuleBase_LabelValue*> myYSpin; ///< the label for the Y coordinate
-  std::vector<ModuleBase_LabelValue*> myWeightSpin; ///< the label for the weight
   PartSet_ExternalObjectsMgr* myExternalObjectMgr; ///< reference to external objects manager
 
   /// value used as selection in mouse release method
index e2ad2a0434609604d74c676f8c8683f396909462..d3fbe20bf87d4add51741cc87968a4e13f8aef4e 100644 (file)
@@ -24,7 +24,6 @@ SET(PROJECT_HEADERS
     SketchPlugin.h
     SketchPlugin_Arc.h
     SketchPlugin_BSpline.h
-    SketchPlugin_BSplineWidget.h
     SketchPlugin_Circle.h
     SketchPlugin_Constraint.h
     SketchPlugin_ConstraintAngle.h
@@ -72,17 +71,11 @@ SET(PROJECT_HEADERS
     SketchPlugin_Tools.h
     SketchPlugin_Trim.h
     SketchPlugin_Validators.h
-    SketchPlugin_WidgetCreator.h
-)
-
-SET(PROJECT_MOC_HEADERS
-    SketchPlugin_BSplineWidget.h
 )
 
 SET(PROJECT_SOURCES
     SketchPlugin_Arc.cpp
     SketchPlugin_BSpline.cpp
-    SketchPlugin_BSplineWidget.cpp
     SketchPlugin_Circle.cpp
     SketchPlugin_Constraint.cpp
     SketchPlugin_ConstraintAngle.cpp
@@ -128,7 +121,6 @@ SET(PROJECT_SOURCES
     SketchPlugin_Tools.cpp
     SketchPlugin_Trim.cpp
     SketchPlugin_Validators.cpp
-    SketchPlugin_WidgetCreator.cpp
 )
 
 SET(PROJECT_LIBRARIES
diff --git a/src/SketchPlugin/SketchPlugin_BSplineWidget.cpp b/src/SketchPlugin/SketchPlugin_BSplineWidget.cpp
deleted file mode 100644 (file)
index 259891a..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright (C) 2019-2020  CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <SketchPlugin_BSplineWidget.h>
-
-#include <SketchPlugin_BSpline.h>
-
-#include <ModuleBase_Tools.h>
-
-#include <ModelAPI_AttributeDoubleArray.h>
-
-#include <GeomDataAPI_Point2DArray.h>
-
-#include <GeomAPI_Pnt2d.h>
-
-#include <QFormLayout>
-#include <QGroupBox>
-#include <QLabel>
-#include <QVBoxLayout>
-
-
-SketchPlugin_BSplineWidget::SketchPlugin_BSplineWidget(
-    QWidget* theParent,
-    const Config_WidgetAPI* theData)
-  : ModuleBase_ModelWidget(theParent, theData)
-{
-  QVBoxLayout* aMainLayout = new QVBoxLayout(this);
-
-  // GroupBox to keep widgets for B-spline poles and weights
-  myPolesGroupBox = new QGroupBox(tr("Poles and weights"), theParent);
-  aMainLayout->addWidget(myPolesGroupBox);
-  // layout of GroupBox
-  QGridLayout* aGroupLayout = new QGridLayout(myPolesGroupBox);
-  aGroupLayout->setSpacing(4);
-  aGroupLayout->setColumnStretch(1, 1);
-
-  restoreValueCustom();
-}
-
-void SketchPlugin_BSplineWidget::setFeature(const FeaturePtr& theFeature,
-                                            const bool theToStoreValue,
-                                            const bool isUpdateFlushed)
-{
-  ModuleBase_ModelWidget::setFeature(theFeature, theToStoreValue, isUpdateFlushed);
-  restoreValueCustom();
-}
-
-void SketchPlugin_BSplineWidget::deactivate()
-{
-  ModuleBase_ModelWidget::deactivate();
-  storeValueCustom();
-}
-
-
-QList<QWidget*> SketchPlugin_BSplineWidget::getControls() const
-{
-  QList<QWidget*> aControls;
-  std::list<BSplinePoleWidgets>::const_iterator anIt = myPoles.begin();
-  for (; anIt != myPoles.end(); ++anIt) {
-    aControls.append(anIt->myX);
-    aControls.append(anIt->myY);
-    aControls.append(anIt->myWeight);
-  }
-  return aControls;
-}
-
-void SketchPlugin_BSplineWidget::storePolesAndWeights() const
-{
-  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
-  AttributePoint2DArrayPtr aPointArray = std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(
-      aData->attribute(SketchPlugin_BSpline::POLES_ID()));
-  AttributeDoubleArrayPtr aWeightsArray = aData->realArray(SketchPlugin_BSpline::WEIGHTS_ID());
-
-  aPointArray->setSize((int)myPoles.size());
-  aWeightsArray->setSize((int)myPoles.size());
-
-  std::list<BSplinePoleWidgets>::const_iterator anIt = myPoles.begin();
-  for (int anIndex = 0; anIt != myPoles.end(); ++anIndex, ++anIt) {
-    aPointArray->setPnt(anIndex, anIt->myX->value(), anIt->myY->value());
-    aWeightsArray->setValue(anIndex, anIt->myWeight->value());
-  }
-}
-
-bool SketchPlugin_BSplineWidget::storeValueCustom()
-{
-  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
-  if (!aData || !aData->isValid()) // can be on abort of sketcher element
-    return false;
-
-  AttributePoint2DArrayPtr aPoles = std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(
-      aData->attribute(SketchPlugin_BSpline::POLES_ID()));
-  AttributeDoubleArrayPtr aWeights = aData->realArray(SketchPlugin_BSpline::WEIGHTS_ID());
-
-  bool isBlocked = blockSignals(true);
-  bool isImmutable = aPoles->setImmutable(true);
-
-  storePolesAndWeights();
-  ModuleBase_Tools::flushUpdated(myFeature);
-
-  aPoles->setImmutable(isImmutable);
-  blockSignals(isBlocked);
-
-  return true;
-}
-
-bool SketchPlugin_BSplineWidget::restoreValueCustom()
-{
-  if (!myFeature)
-    return false;
-
-  DataPtr aData = myFeature->data();
-
-  AttributePoint2DArrayPtr aPoles = std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(
-      aData->attribute(SketchPlugin_BSpline::POLES_ID()));
-  AttributeDoubleArrayPtr aWeights = aData->realArray(SketchPlugin_BSpline::WEIGHTS_ID());
-
-  while (myPoles.size() < aPoles->size())
-    addPoleWidget();
-
-  std::list<BSplinePoleWidgets>::iterator anIt = myPoles.begin();
-  for (int anIndex = 0; anIt != myPoles.end(); ++anIt, ++anIndex) {
-    GeomPnt2dPtr aPoint = aPoles->pnt(anIndex);
-    anIt->myX->setValue(aPoint->x());
-    anIt->myY->setValue(aPoint->y());
-    anIt->myWeight->setValue(aWeights->value(anIndex));
-  }
-
-  return true;
-}
-
-void SketchPlugin_BSplineWidget::addPoleWidget()
-{
-  QGridLayout* aGroupLay = dynamic_cast<QGridLayout*>(myPolesGroupBox->layout());
-
-  int aNbPoles = (int)myPoles.size();
-
-  QString aPoleStr = tr("Pole %1");
-  aPoleStr = aPoleStr.arg(aNbPoles + 1);
-
-  QGroupBox* aPoleGroupBox = new QGroupBox(aPoleStr, myPolesGroupBox);
-  QFormLayout* aPoleLay = new QFormLayout(aPoleGroupBox);
-  ModuleBase_Tools::adjustMargins(aPoleLay);
-  aPoleLay->setSpacing(2);
-
-  myPoles.push_back(BSplinePoleWidgets());
-  BSplinePoleWidgets& aPoleWidgets = myPoles.back();
-
-  aPoleWidgets.myX = new ModuleBase_LabelValue(aPoleGroupBox, tr("X"));
-  aPoleLay->addRow(aPoleWidgets.myX);
-  aPoleWidgets.myY = new ModuleBase_LabelValue(aPoleGroupBox, tr("Y"));
-  aPoleLay->addRow(aPoleWidgets.myY);
-  aPoleWidgets.myWeight = new ModuleBase_ParamSpinBox(aPoleGroupBox);
-  aPoleWidgets.myWeight->setMinimum(0.0);
-  aPoleLay->addRow(tr("Weight") + " : ", aPoleWidgets.myWeight);
-
-  aGroupLay->addWidget(aPoleGroupBox, aNbPoles, 1);
-
-  // we should listen textChanged signal as valueChanged do not send when text is modified
-  connect(aPoleWidgets.myWeight, SIGNAL(textChanged(const QString&)),
-          this, SIGNAL(valuesModified()));
-}
diff --git a/src/SketchPlugin/SketchPlugin_BSplineWidget.h b/src/SketchPlugin/SketchPlugin_BSplineWidget.h
deleted file mode 100644 (file)
index 30fa4c6..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (C) 2019-2020  CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef SketchPlugin_BSplineWidget_H
-#define SketchPlugin_BSplineWidget_H
-
-
-#include <SketchPlugin.h>
-
-#include <ModelAPI_Feature.h>
-
-#include <ModuleBase_LabelValue.h>
-#include <ModuleBase_ModelWidget.h>
-#include <ModuleBase_ParamSpinBox.h>
-
-class QGroupBox;
-
-
-/** \brief Represent a content of the property panel to show/modify parameters of B-spline curve.
- *  \ingroup GUI
- */
-class SketchPlugin_BSplineWidget : public ModuleBase_ModelWidget
-{
-Q_OBJECT
-public:
-  /// Constructor
-  /// \param theParent the parent object
-  /// \param theData the widget configuation. The attribute of the model widget is obtained from
-  SketchPlugin_BSplineWidget(QWidget* theParent,
-                             const Config_WidgetAPI* theData);
-
-  virtual ~SketchPlugin_BSplineWidget() {}
-
-  /// The methiod called when widget is deactivated
-  virtual void deactivate();
-
-  /// Returns list of widget controls
-  /// \return a control list
-  virtual QList<QWidget*> getControls() const;
-
-  /// Set feature which is processing by active operation
-  /// \param theFeature a feature object
-  /// \param theToStoreValue a value about necessity to store the widget value to the feature
-  /// \param isUpdateFlushed a flag if update should be flushed on store value
-  virtual void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false,
-                          const bool isUpdateFlushed = true);
-
-protected:
-  /// Saves the internal parameters to the given feature
-  /// \return True in success
-  virtual bool storeValueCustom();
-
-  /// Restore value from attribute data to the widget's control
-  virtual bool restoreValueCustom();
-
-  /// Create group of widgets related to coordinates of pole and its weight
-  void addPoleWidget();
-
-  /// Update attributes of B-spline feature
-  void storePolesAndWeights() const;
-
-private:
-  struct BSplinePoleWidgets {
-    ModuleBase_LabelValue* myX;
-    ModuleBase_LabelValue* myY;
-    ModuleBase_ParamSpinBox* myWeight;
-  };
-
-  QGroupBox* myPolesGroupBox; ///< widget to show poles and weights of B-spline curve
-  std::list<BSplinePoleWidgets> myPoles; ///< list of B-spline poles and their weights
-};
-
-#endif
\ No newline at end of file
index b48e6cfef86fe702f08c1812e451e50374b2d75f..a6ef2a190e47f0960eb2964d3baeba18325a8b2c 100644 (file)
@@ -59,7 +59,6 @@
 #include <SketchPlugin_EllipticArc.h>
 #include <SketchPlugin_MacroEllipticArc.h>
 #include <SketchPlugin_SketchDrawer.h>
-#include <SketchPlugin_WidgetCreator.h>
 
 #include <SketcherPrs_Tools.h>
 
@@ -71,8 +70,6 @@
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Data.h>
 
-#include <ModuleBase_WidgetCreatorFactory.h>
-
 #include <Config_PropManager.h>
 
 #include <memory>
@@ -95,10 +92,6 @@ static SketchPlugin_Plugin* MY_SKETCH_INSTANCE = new SketchPlugin_Plugin();
 
 SketchPlugin_Plugin::SketchPlugin_Plugin()
 {
-  WidgetCreatorFactoryPtr aWidgetCreatorFactory = ModuleBase_WidgetCreatorFactory::get();
-  aWidgetCreatorFactory->registerCreator(
-      std::shared_ptr<SketchPlugin_WidgetCreator>(new SketchPlugin_WidgetCreator()));
-
   SessionPtr aMgr = ModelAPI_Session::get();
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   aFactory->registerValidator("SketchPlugin_DistanceAttr",
diff --git a/src/SketchPlugin/SketchPlugin_WidgetCreator.cpp b/src/SketchPlugin/SketchPlugin_WidgetCreator.cpp
deleted file mode 100644 (file)
index 37da438..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (C) 2019-2020  CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include <SketchPlugin_WidgetCreator.h>
-#include <SketchPlugin_BSplineWidget.h>
-
-
-SketchPlugin_WidgetCreator::SketchPlugin_WidgetCreator()
-  : ModuleBase_IWidgetCreator()
-{
-  myPanelTypes.insert("bspline-panel");
-}
-
-void SketchPlugin_WidgetCreator::panelTypes(std::set<std::string>& theTypes)
-{
-  theTypes = myPanelTypes;
-}
-
-QWidget* SketchPlugin_WidgetCreator::createPanelByType(
-    const std::string& theType,
-    QWidget* theParent,
-    const FeaturePtr& theFeature,
-    Config_WidgetAPI* theWidgetApi)
-{
-  QWidget* aWidget = 0;
-  if (theType == "bspline-panel") {
-    SketchPlugin_BSplineWidget* aPanel = new SketchPlugin_BSplineWidget(theParent, theWidgetApi);
-    aPanel->setFeature(theFeature);
-    aWidget = aPanel;
-  }
-  return aWidget;
-}
diff --git a/src/SketchPlugin/SketchPlugin_WidgetCreator.h b/src/SketchPlugin/SketchPlugin_WidgetCreator.h
deleted file mode 100644 (file)
index 9b1a9ba..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (C) 2019-2020  CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef SketchPlugin_WidgetCreator_H
-#define SketchPlugin_WidgetCreator_H
-
-
-#include <SketchPlugin.h>
-#include <ModuleBase_IWidgetCreator.h>
-
-#include <string>
-#include <set>
-
-class QWidget;
-
-/**
- *  \ingroup GUI
- *  Interface to WidgetCreator which can create specific widgets by type
- */
-class SketchPlugin_WidgetCreator : public ModuleBase_IWidgetCreator
-{
-public:
-  /// Default constructor
-  SketchPlugin_WidgetCreator();
-
-  /// Virtual destructor
-  virtual ~SketchPlugin_WidgetCreator() {}
-
-  /// Returns a container of possible page types, which this creator can process
-  /// \param theTypes a list of type names
-  virtual void panelTypes(std::set<std::string>& theTypes);
-
-  /// Create panel control by its type.
-  /// The default implementation is empty
-  /// \param theType a panel type
-  /// \param theParent a parent widget
-  /// \param theFeature a feature modified in the panel
-  /// \return created widget or null
-  virtual QWidget* createPanelByType(const std::string& theType,
-                                     QWidget* theParent,
-                                     const FeaturePtr& theFeature,
-                                     Config_WidgetAPI* theWidgetApi);
-private:
-  std::set<std::string> myPanelTypes; ///< types of panels
-};
-
-#endif
\ No newline at end of file
index 241c30de0c6c75be1a9323687fb3e963f682962c..368f3d6029649539cc33ada5e70a121ec8cf00b9 100644 (file)
       <feature id="SketchBSpline"
                title="B-spline"
                tooltip="Create B-spline curve"
-               property_panel_id="bspline-panel"
                icon="icons/Sketch/bspline.png"
                helpfile="bsplineFeature.html"
                internal="1">
-        <sketch-2dpoint_selector id="start_point" accept_expressions="0" title="Start point" tooltip="Start point coordinates"
-                                 enable_value="enable_by_preferences"/>
-        <sketch-2dpoint_selector id="end_point" accept_expressions="0" title="End point" tooltip="End point coordinates"
-                                 enable_value="enable_by_preferences"/>
         <bspline-panel id="poles"
                        weights="weights"
                        title="Poles and weights"