diff --git a/src/Mod/Sketcher/App/ConstraintPy.xml b/src/Mod/Sketcher/App/ConstraintPy.xml
index 69eb2c424..d46c5b471 100644
--- a/src/Mod/Sketcher/App/ConstraintPy.xml
+++ b/src/Mod/Sketcher/App/ConstraintPy.xml
@@ -18,16 +18,21 @@
- First geometry index the Constraint referse to
+ First geometry index the Constraint refers to
- Second geometry index the Constraint referse to
+ Second geometry index the Constraint refers to
-
+
+
+ Name of the constraint
+
+
+
diff --git a/src/Mod/Sketcher/App/ConstraintPyImp.cpp b/src/Mod/Sketcher/App/ConstraintPyImp.cpp
index 910d88975..82225e3ad 100644
--- a/src/Mod/Sketcher/App/ConstraintPyImp.cpp
+++ b/src/Mod/Sketcher/App/ConstraintPyImp.cpp
@@ -361,6 +361,16 @@ void ConstraintPy::setSecond(Py::Int arg)
this->getConstraintPtr()->Second = arg;
}
+Py::String ConstraintPy::getName(void) const
+{
+ return Py::String(this->getConstraintPtr()->Name);
+}
+
+void ConstraintPy::setName(Py::String arg)
+{
+ this->getConstraintPtr()->Name = arg;
+}
+
PyObject *ConstraintPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
diff --git a/src/Mod/Sketcher/App/PropertyConstraintList.cpp b/src/Mod/Sketcher/App/PropertyConstraintList.cpp
index b5825809e..ae98ce409 100644
--- a/src/Mod/Sketcher/App/PropertyConstraintList.cpp
+++ b/src/Mod/Sketcher/App/PropertyConstraintList.cpp
@@ -75,6 +75,18 @@ int PropertyConstraintList::getSize(void) const
return static_cast(_lValueList.size());
}
+void PropertyConstraintList::set1Value(const int idx, const Constraint* lValue)
+{
+ if (lValue) {
+ aboutToSetValue();
+ Constraint* oldVal = _lValueList[idx];
+ Constraint* newVal = lValue->clone();
+ _lValueList[idx] = newVal;
+ delete oldVal;
+ hasSetValue();
+ }
+}
+
void PropertyConstraintList::setValue(const Constraint* lValue)
{
if (lValue) {
diff --git a/src/Mod/Sketcher/App/PropertyConstraintList.h b/src/Mod/Sketcher/App/PropertyConstraintList.h
index 1d8778f59..ec6888285 100644
--- a/src/Mod/Sketcher/App/PropertyConstraintList.h
+++ b/src/Mod/Sketcher/App/PropertyConstraintList.h
@@ -63,6 +63,7 @@ public:
/** Sets the property
*/
+ void set1Value(const int idx, const Constraint*);
void setValue(const Constraint*);
void setValues(const std::vector&);
diff --git a/src/Mod/Sketcher/App/SketchObjectPy.xml b/src/Mod/Sketcher/App/SketchObjectPy.xml
index 41f035754..3d94b91c9 100644
--- a/src/Mod/Sketcher/App/SketchObjectPy.xml
+++ b/src/Mod/Sketcher/App/SketchObjectPy.xml
@@ -48,6 +48,11 @@
delete a constraint from the sketch
+
+
+ Rename a constraint of the sketch
+
+
add a link to an external geometry to use it in a constraint
diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp
index 474369479..26b9589f2 100644
--- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp
+++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp
@@ -147,6 +147,28 @@ PyObject* SketchObjectPy::delConstraint(PyObject *args)
Py_Return;
}
+PyObject* SketchObjectPy::renameConstraint(PyObject *args)
+{
+ int Index;
+ char* Name;
+ if (!PyArg_ParseTuple(args, "is", &Index, &Name))
+ return 0;
+
+ if (this->getSketchObjectPtr()->Constraints.getSize() <= Index) {
+ std::stringstream str;
+ str << "Not able to rename a constraint with the given index: " << Index;
+ PyErr_SetString(PyExc_IndexError, str.str().c_str());
+ return 0;
+ }
+
+ Constraint* copy = this->getSketchObjectPtr()->Constraints[Index]->clone();
+ copy->Name = Name;
+ this->getSketchObjectPtr()->Constraints.set1Value(Index, copy);
+ delete copy;
+
+ Py_Return;
+}
+
PyObject* SketchObjectPy::addExternal(PyObject *args)
{
char *ObjectName;
diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp
index 8df11be9a..85844621f 100644
--- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp
+++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp
@@ -73,7 +73,7 @@ TaskSketcherConstrains::TaskSketcherConstrains(ViewProviderSketch *sketchView)
ui = new Ui_TaskSketcherConstrains();
ui->setupUi(proxy);
ui->listWidgetConstraints->setSelectionMode(QAbstractItemView::ExtendedSelection);
- //ui->listWidgetConstraints->setEditTriggers(QListWidget::EditKeyPressed);
+ ui->listWidgetConstraints->setEditTriggers(QListWidget::EditKeyPressed);
//QMetaObject::connectSlotsByName(this);
// connecting the needed signals
@@ -89,10 +89,6 @@ TaskSketcherConstrains::TaskSketcherConstrains(ViewProviderSketch *sketchView)
ui->listWidgetConstraints, SIGNAL(itemActivated(QListWidgetItem *)),
this , SLOT (on_listWidgetConstraints_itemActivated(QListWidgetItem *))
);
- QObject::connect(
- ui->listWidgetConstraints, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
- this , SLOT (on_listWidgetConstraints_itemActivated(QListWidgetItem *))
- );
QObject::connect(
ui->listWidgetConstraints, SIGNAL(itemChanged(QListWidgetItem *)),
this , SLOT (on_listWidgetConstraints_itemChanged(QListWidgetItem *))