FEM: constraint fixed: change reference selection behavior to only allow same shape type
This commit is contained in:
parent
3998e2433b
commit
0e7c97b356
|
@ -114,53 +114,63 @@ void TaskFemConstraintFixed::updateUI()
|
||||||
void TaskFemConstraintFixed::addToSelection()
|
void TaskFemConstraintFixed::addToSelection()
|
||||||
{
|
{
|
||||||
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document
|
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document
|
||||||
if (selection.size()==0){
|
if (selection.size()==0){
|
||||||
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
|
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Fem::ConstraintFixed* pcConstraint = static_cast<Fem::ConstraintFixed*>(ConstraintView->getObject());
|
|
||||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
Fem::ConstraintFixed* pcConstraint = static_cast<Fem::ConstraintFixed*>(ConstraintView->getObject());
|
||||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||||
|
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
|
||||||
if (static_cast<std::string>(it->getTypeName()).substr(0,4).compare(std::string("Part"))!=0){
|
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
if (static_cast<std::string>(it->getTypeName()).substr(0,4).compare(std::string("Part"))!=0){
|
||||||
return;
|
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> subNames=it->getSubNames();
|
std::vector<std::string> subNames=it->getSubNames();
|
||||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||||
|
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
|
||||||
if (subNames.size()>0){
|
bool addMe=true;
|
||||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
|
for (std::vector<std::string>::iterator itr=std::find(SubElements.begin(),SubElements.end(),subNames[subIt]);
|
||||||
bool addMe=true;
|
itr!= SubElements.end();
|
||||||
if ((subNames[subIt].substr(0,4) != "Face") && (subNames[subIt].substr(0,4) != "Edge") && (subNames[subIt].substr(0,6) != "Vertex")) {
|
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
|
||||||
QMessageBox::warning(this, tr("Selection error"), tr("Mixed shape types are not possible. Use a second constraint instead"));
|
{// for every sub element in selection that matches one in old list
|
||||||
return;
|
if (obj==Objects[std::distance(SubElements.begin(),itr)]){//if selected sub element's object equals the one in old list then it was added before so don't add
|
||||||
}
|
addMe=false;
|
||||||
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]))
|
// limit constraint such that only vertexes or faces or edges can be used depending on what was selected first
|
||||||
{// for every sub element in selection that matches one in old list
|
std::string searchStr("");
|
||||||
if (obj==Objects[std::distance(SubElements.begin(),itr)]){//if selected sub element's object equals the one in old list then it was added before so don't add
|
if (subNames[subIt].find("Vertex")!=std::string::npos)
|
||||||
addMe=false;
|
searchStr="Vertex";
|
||||||
}
|
else if (subNames[subIt].find("Edge")!=std::string::npos)
|
||||||
}
|
searchStr="Edge";
|
||||||
if (addMe){
|
else
|
||||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
searchStr="Face";
|
||||||
this, SLOT(setSelection(QListWidgetItem*)));
|
for (unsigned int iStr=0;iStr<(SubElements.size());++iStr){
|
||||||
Objects.push_back(obj);
|
if ((SubElements[iStr].find(searchStr)==std::string::npos)&&(SubElements.size()>0)){
|
||||||
SubElements.push_back(subNames[subIt]);
|
QString msg = tr("Only one type of selection (vertex,face or edge) per constraint allowed!");
|
||||||
ui->lw_references->addItem(makeRefText(obj, subNames[subIt]));
|
QMessageBox::warning(this, tr("Selection error"), msg);
|
||||||
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
addMe=false;
|
||||||
this, SLOT(setSelection(QListWidgetItem*)));
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (addMe){
|
||||||
//Update UI
|
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||||
pcConstraint->References.setValues(Objects,SubElements);
|
this, SLOT(setSelection(QListWidgetItem*)));
|
||||||
updateUI();
|
Objects.push_back(obj);
|
||||||
}
|
SubElements.push_back(subNames[subIt]);
|
||||||
|
ui->lw_references->addItem(makeRefText(obj, subNames[subIt]));
|
||||||
|
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||||
|
this, SLOT(setSelection(QListWidgetItem*)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Update UI
|
||||||
|
pcConstraint->References.setValues(Objects,SubElements);
|
||||||
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskFemConstraintFixed::removeFromSelection()
|
void TaskFemConstraintFixed::removeFromSelection()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user