FEM: constraint fixed: change reference selection behavior to only allow same shape type

This commit is contained in:
vdwalts 2016-08-01 21:58:26 +01:00 committed by wmayer
parent 3998e2433b
commit 0e7c97b356

View File

@ -118,6 +118,7 @@ void TaskFemConstraintFixed::addToSelection()
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
Fem::ConstraintFixed* pcConstraint = static_cast<Fem::ConstraintFixed*>(ConstraintView->getObject());
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
@ -130,14 +131,8 @@ void TaskFemConstraintFixed::addToSelection()
std::vector<std::string> subNames=it->getSubNames();
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
if (subNames.size()>0){
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
bool addMe=true;
if ((subNames[subIt].substr(0,4) != "Face") && (subNames[subIt].substr(0,4) != "Edge") && (subNames[subIt].substr(0,6) != "Vertex")) {
QMessageBox::warning(this, tr("Selection error"), tr("Mixed shape types are not possible. Use a second constraint instead"));
return;
}
for (std::vector<std::string>::iterator itr=std::find(SubElements.begin(),SubElements.end(),subNames[subIt]);
itr!= SubElements.end();
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
@ -146,6 +141,22 @@ void TaskFemConstraintFixed::addToSelection()
addMe=false;
}
}
// limit constraint such that only vertexes or faces or edges can be used depending on what was selected first
std::string searchStr("");
if (subNames[subIt].find("Vertex")!=std::string::npos)
searchStr="Vertex";
else if (subNames[subIt].find("Edge")!=std::string::npos)
searchStr="Edge";
else
searchStr="Face";
for (unsigned int iStr=0;iStr<(SubElements.size());++iStr){
if ((SubElements[iStr].find(searchStr)==std::string::npos)&&(SubElements.size()>0)){
QString msg = tr("Only one type of selection (vertex,face or edge) per constraint allowed!");
QMessageBox::warning(this, tr("Selection error"), msg);
addMe=false;
break;
}
}
if (addMe){
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
@ -160,7 +171,6 @@ void TaskFemConstraintFixed::addToSelection()
//Update UI
pcConstraint->References.setValues(Objects,SubElements);
updateUI();
}
}
void TaskFemConstraintFixed::removeFromSelection()