+ fixes #0001380: Allow to set user-defined names for constraints
This commit is contained in:
parent
006083258e
commit
d81803de05
|
@ -18,16 +18,21 @@
|
|||
</Documentation>
|
||||
<Attribute Name="First" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>First geometry index the Constraint referse to</UserDocu>
|
||||
<UserDocu>First geometry index the Constraint refers to</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="First" Type="Int"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Second" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Second geometry index the Constraint referse to</UserDocu>
|
||||
<UserDocu>Second geometry index the Constraint refers to</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Second" Type="Int"/>
|
||||
</Attribute>
|
||||
|
||||
<Attribute Name="Name" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Name of the constraint</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Name" Type="String"/>
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -75,6 +75,18 @@ int PropertyConstraintList::getSize(void) const
|
|||
return static_cast<int>(_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) {
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
|
||||
/** Sets the property
|
||||
*/
|
||||
void set1Value(const int idx, const Constraint*);
|
||||
void setValue(const Constraint*);
|
||||
void setValues(const std::vector<Constraint*>&);
|
||||
|
||||
|
|
|
@ -48,6 +48,11 @@
|
|||
<UserDocu>delete a constraint from the sketch</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="renameConstraint">
|
||||
<Documentation>
|
||||
<UserDocu>Rename a constraint of the sketch</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="addExternal">
|
||||
<Documentation>
|
||||
<UserDocu>add a link to an external geometry to use it in a constraint</UserDocu>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 *))
|
||||
|
|
Loading…
Reference in New Issue
Block a user