Sketcher: Extension of Constraints Widget to support checkboxes for Virtual Space
================================================================================= The checkboxes enable a constraint to swap virtual space. If checked the constraint is visible in the selected space and hidden in the other space (Real Space or Virtual Space). If unchecked the constraint is visible in the other space and hidden in the selected space.
This commit is contained in:
@@ -83,7 +83,9 @@ public:
|
||||
sketch(s),
|
||||
ConstraintNbr(ConstNbr)
|
||||
{
|
||||
this->setFlags(this->flags() | Qt::ItemIsEditable);
|
||||
this->setFlags(this->flags() | Qt::ItemIsEditable | Qt::ItemIsUserCheckable);
|
||||
|
||||
this->setCheckState(this->isInVirtualSpace()?Qt::Unchecked:Qt::Checked);
|
||||
}
|
||||
~ConstraintItem()
|
||||
{
|
||||
@@ -299,6 +301,12 @@ public:
|
||||
return sketch->Constraints[ConstraintNbr]->isDriving;
|
||||
}
|
||||
|
||||
bool isInVirtualSpace() const {
|
||||
assert(ConstraintNbr >= 0 && ConstraintNbr < sketch->Constraints.getSize());
|
||||
|
||||
return sketch->Constraints[ConstraintNbr]->isInVirtualSpace;
|
||||
}
|
||||
|
||||
const Sketcher::SketchObject * sketch;
|
||||
int ConstraintNbr;
|
||||
QVariant value;
|
||||
@@ -686,15 +694,24 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetIte
|
||||
return;
|
||||
|
||||
inEditMode = true;
|
||||
|
||||
assert(sketchView);
|
||||
|
||||
const Sketcher::SketchObject * sketch = sketchView->getSketchObject();
|
||||
const std::vector< Sketcher::Constraint * > &vals = sketch->Constraints.getValues();
|
||||
const Sketcher::Constraint* v = vals[it->ConstraintNbr];
|
||||
const std::string currConstraintName = v->Name;
|
||||
|
||||
std::string newName(Sketcher::PropertyConstraintList::getConstraintName(Base::Tools::toStdString(it->data(Qt::EditRole).toString()), it->ConstraintNbr));
|
||||
const std::string basename = Base::Tools::toStdString(it->data(Qt::EditRole).toString());
|
||||
|
||||
std::string newName(Sketcher::PropertyConstraintList::getConstraintName(basename, it->ConstraintNbr));
|
||||
|
||||
if (newName != currConstraintName) {
|
||||
// we only start a rename if we are really sure the name has changed, which is:
|
||||
// a) that the name generated by the constraints is different from the text in the widget item
|
||||
// b) that the text in the widget item, basename, is not ""
|
||||
// otherwise a checkbox change will trigger a rename on the first execution, bloating the constraint icons with the
|
||||
// default constraint name "constraint1, constraint2"
|
||||
if (newName != currConstraintName && !basename.empty()) {
|
||||
std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(newName.c_str());
|
||||
|
||||
Gui::Command::openCommand("Rename sketch constraint");
|
||||
@@ -712,6 +729,10 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetIte
|
||||
}
|
||||
}
|
||||
|
||||
const_cast<Sketcher::Constraint*>(v)->isInVirtualSpace = !(item->checkState() == Qt::Checked); // update constraint virtual space status
|
||||
|
||||
sketchView->updateVirtualSpace();
|
||||
|
||||
inEditMode = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user