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");
PartSet_TreeNodes.h
PartSet_FieldStepPrs.h
PartSet_WidgetBSplinePoints.h
+ PartSet_BSplineWidget.h
)
SET(PROJECT_MOC_HEADERS
PartSet_WidgetSketchLabel.h
PartSet_WidgetBSplinePoints.h
PartSet_ExternalPointsMgr.h
+ PartSet_BSplineWidget.h
)
SET(PROJECT_SOURCES
PartSet_TreeNodes.cpp
PartSet_FieldStepPrs.cpp
PartSet_WidgetBSplinePoints.cpp
+ PartSet_BSplineWidget.cpp
)
SET(PROJECT_RESOURCES
--- /dev/null
+// 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()));
+}
--- /dev/null
+// 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
#include "PartSet_OverconstraintListener.h"
#include "PartSet_TreeNodes.h"
#include "PartSet_FieldStepPrs.h"
+#include "PartSet_BSplineWidget.h"
#include "PartSet_Filters.h"
#include "PartSet_FilterInfinite.h"
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;
}
#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;
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);
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());
// locking of the validating state.
fillLabels(myXSpin, 0.0);
fillLabels(myYSpin, 0.0);
- fillLabels(myWeightSpin, 1.0);
storeValueCustom();
aDone = true;
myXSpin.back()->setValue(theX);
myYSpin.back()->setValue(theY);
- myWeightSpin.back()->setValue(1.0);
storeValue();
return true;
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()
(*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())
myXSpin.back()->setValue(0.0);
myYSpin.back()->setValue(0.0);
- myWeightSpin.back()->setValue(0.0);
}
return true;
storeArray(myXSpin, myXValueInCash);
storeArray(myYSpin, myYValueInCash);
- storeArray(myWeightSpin, myWeightInCash);
}
static void restoreArray(std::vector<double>& theCacheValues,
// fill the control widgets by the cashed value
restoreArray(myXValueInCash, myXSpin);
restoreArray(myYValueInCash, myYSpin);
- restoreArray(myWeightInCash, myWeightSpin);
// store value to the model
storeValueCustom();
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;
}
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
SketchPlugin.h
SketchPlugin_Arc.h
SketchPlugin_BSpline.h
- SketchPlugin_BSplineWidget.h
SketchPlugin_Circle.h
SketchPlugin_Constraint.h
SketchPlugin_ConstraintAngle.h
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
SketchPlugin_Tools.cpp
SketchPlugin_Trim.cpp
SketchPlugin_Validators.cpp
- SketchPlugin_WidgetCreator.cpp
)
SET(PROJECT_LIBRARIES
+++ /dev/null
-// 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()));
-}
+++ /dev/null
-// 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
#include <SketchPlugin_EllipticArc.h>
#include <SketchPlugin_MacroEllipticArc.h>
#include <SketchPlugin_SketchDrawer.h>
-#include <SketchPlugin_WidgetCreator.h>
#include <SketcherPrs_Tools.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Data.h>
-#include <ModuleBase_WidgetCreatorFactory.h>
-
#include <Config_PropManager.h>
#include <memory>
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",
+++ /dev/null
-// 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;
-}
+++ /dev/null
-// 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
<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"