[FEM] spread the fixes from commit ef370e6d to the other dialogs
This commit is contained in:
@@ -46,12 +46,11 @@
|
||||
#include "TaskFemConstraintContact.h"
|
||||
#include "ui_TaskFemConstraintContact.h"
|
||||
#include <App/Application.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Command.h>
|
||||
|
||||
|
||||
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
|
||||
using namespace FemGui;
|
||||
@@ -150,118 +149,106 @@ void TaskFemConstraintContact::addToSelectionSlave()
|
||||
{
|
||||
int rows = ui->lw_referencesSlave->model()->rowCount();
|
||||
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx();//gets vector of selected objects of active document
|
||||
if (rows==1){
|
||||
if (rows == 1){
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only one master face and one slave face for a contact constraint!"));
|
||||
Gui::Selection().clearSelection();
|
||||
return;
|
||||
}
|
||||
|
||||
if (selection.size()==0){
|
||||
if (selection.size() == 0){
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((rows==0) && (selection.size()>=2)){
|
||||
if ((rows == 0) && (selection.size() >= 2)){
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only one slave face for a contact constraint!"));
|
||||
Gui::Selection().clearSelection();
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintContact* pcConstraint = static_cast<Fem::ConstraintContact*>(ConstraintView->getObject());
|
||||
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
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
if (subNames.size()!=1){
|
||||
if (subNames.size() != 1){
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only one slave face for a contact constraint!"));
|
||||
Gui::Selection().clearSelection();
|
||||
return;
|
||||
}
|
||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element
|
||||
bool addMe=true;
|
||||
if (subNames[subIt].substr(0,4) != "Face") {
|
||||
if (subNames[subIt].substr(0, 4) != "Face") {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
|
||||
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]))
|
||||
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]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (addMe){
|
||||
disconnect(ui->lw_referencesSlave, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
QSignalBlocker block(ui->lw_referencesSlave);
|
||||
Objects.push_back(obj);
|
||||
SubElements.push_back(subNames[subIt]);
|
||||
ui->lw_referencesSlave->addItem(makeRefText(obj, subNames[subIt]));
|
||||
connect(ui->lw_referencesSlave, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
}
|
||||
}
|
||||
}
|
||||
//Update UI
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintContact::removeFromSelectionSlave()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintContact* pcConstraint = static_cast<Fem::ConstraintContact*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
std::vector<int> itemsToDel;
|
||||
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){
|
||||
std::vector<size_t> itemsToDel;
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
|
||||
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]);
|
||||
itr!= SubElements.end();
|
||||
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
|
||||
for (size_t 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]);
|
||||
itr != SubElements.end();
|
||||
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(),itr));
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(), itr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(itemsToDel.begin(),itemsToDel.end());
|
||||
while (itemsToDel.size()>0){
|
||||
Objects.erase(Objects.begin()+itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin()+itemsToDel.back());
|
||||
std::sort(itemsToDel.begin(), itemsToDel.end());
|
||||
while (itemsToDel.size() > 0){
|
||||
Objects.erase(Objects.begin() + itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin() + itemsToDel.back());
|
||||
itemsToDel.pop_back();
|
||||
}
|
||||
//Update UI
|
||||
disconnect(ui->lw_referencesSlave, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
ui->lw_referencesSlave->clear();
|
||||
connect(ui->lw_referencesSlave, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
{
|
||||
QSignalBlocker block(ui->lw_referencesSlave);
|
||||
ui->lw_referencesSlave->clear();
|
||||
}
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
@@ -269,118 +256,105 @@ void TaskFemConstraintContact::addToSelectionMaster()
|
||||
{
|
||||
int rows = ui->lw_referencesMaster->model()->rowCount();
|
||||
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx();//gets vector of selected objects of active document
|
||||
if (rows==1){
|
||||
if (rows == 1){
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only one master face and one slave face for a contact constraint!"));
|
||||
Gui::Selection().clearSelection();
|
||||
return;
|
||||
}
|
||||
|
||||
if (selection.size()==0){
|
||||
if (selection.size() == 0){
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((rows==0) && (selection.size()>=2)){
|
||||
if ((rows == 0) && (selection.size() >= 2)){
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only one master for a contact constraint!"));
|
||||
Gui::Selection().clearSelection();
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintContact* pcConstraint = static_cast<Fem::ConstraintContact*>(ConstraintView->getObject());
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())){
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
if (subNames.size()!=1){
|
||||
const std::vector<std::string>& subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
if (subNames.size() != 1){
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only one master face for a contact constraint!"));
|
||||
Gui::Selection().clearSelection();
|
||||
return;
|
||||
}
|
||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
|
||||
bool addMe=true;
|
||||
if (subNames[subIt].substr(0,4) != "Face") {
|
||||
if (subNames[subIt].substr(0, 4) != "Face") {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
|
||||
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]))
|
||||
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]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (addMe){
|
||||
disconnect(ui->lw_referencesMaster, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
QSignalBlocker block(ui->lw_referencesMaster);
|
||||
Objects.push_back(obj);
|
||||
SubElements.push_back(subNames[subIt]);
|
||||
ui->lw_referencesMaster->addItem(makeRefText(obj, subNames[subIt]));
|
||||
connect(ui->lw_referencesMaster, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
}
|
||||
}
|
||||
}
|
||||
//Update UI
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintContact::removeFromSelectionMaster()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintContact* pcConstraint = static_cast<Fem::ConstraintContact*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
std::vector<int> itemsToDel;
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
std::vector<size_t> itemsToDel;
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
|
||||
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]);
|
||||
itr!= SubElements.end();
|
||||
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
|
||||
for (size_t 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]);
|
||||
itr != SubElements.end();
|
||||
itr = std::find(++itr,SubElements.end(), subNames[subIt]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(),itr));
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(), itr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(itemsToDel.begin(),itemsToDel.end());
|
||||
while (itemsToDel.size()>0){
|
||||
Objects.erase(Objects.begin()+itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin()+itemsToDel.back());
|
||||
std::sort(itemsToDel.begin(), itemsToDel.end());
|
||||
while (itemsToDel.size() > 0){
|
||||
Objects.erase(Objects.begin() + itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin() + itemsToDel.back());
|
||||
itemsToDel.pop_back();
|
||||
}
|
||||
//Update UI
|
||||
disconnect(ui->lw_referencesMaster, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
ui->lw_referencesMaster->clear();
|
||||
connect(ui->lw_referencesMaster, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
{
|
||||
QSignalBlocker block(ui->lw_referencesMaster);
|
||||
ui->lw_referencesMaster->clear();
|
||||
}
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,9 +49,11 @@
|
||||
#include "TaskFemConstraintDisplacement.h"
|
||||
#include "ui_TaskFemConstraintDisplacement.h"
|
||||
#include <App/Application.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
|
||||
using namespace FemGui;
|
||||
@@ -410,43 +412,41 @@ void TaskFemConstraintDisplacement::rotfreez(int val){
|
||||
void TaskFemConstraintDisplacement::addToSelection()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintDisplacement* pcConstraint = static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
|
||||
bool addMe=true;
|
||||
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]))
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
|
||||
bool addMe = true;
|
||||
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]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
// 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)
|
||||
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 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)){
|
||||
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;
|
||||
@@ -454,73 +454,63 @@ void TaskFemConstraintDisplacement::addToSelection()
|
||||
}
|
||||
}
|
||||
if (addMe){
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
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);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintDisplacement::removeFromSelection()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintDisplacement* pcConstraint = static_cast<Fem::ConstraintDisplacement*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
std::vector<unsigned int> itemsToDel;
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
std::vector<size_t> itemsToDel;
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
|
||||
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]);
|
||||
itr!= SubElements.end();
|
||||
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
|
||||
for (size_t 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]);
|
||||
itr != SubElements.end();
|
||||
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(),itr));
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(), itr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(itemsToDel.begin(),itemsToDel.end());
|
||||
while (itemsToDel.size()>0){
|
||||
Objects.erase(Objects.begin()+itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin()+itemsToDel.back());
|
||||
std::sort(itemsToDel.begin(), itemsToDel.end());
|
||||
while (itemsToDel.size() > 0){
|
||||
Objects.erase(Objects.begin() + itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin() + itemsToDel.back());
|
||||
itemsToDel.pop_back();
|
||||
}
|
||||
|
||||
//Update UI
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j=0;j<Objects.size();j++){
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
{
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j = 0; j < Objects.size(); j++) {
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
}
|
||||
}
|
||||
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,11 @@
|
||||
#include "TaskFemConstraintFixed.h"
|
||||
#include "ui_TaskFemConstraintFixed.h"
|
||||
#include <App/Application.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
|
||||
using namespace FemGui;
|
||||
@@ -117,116 +119,105 @@ void TaskFemConstraintFixed::updateUI()
|
||||
void TaskFemConstraintFixed::addToSelection()
|
||||
{
|
||||
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!"));
|
||||
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();
|
||||
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
|
||||
bool addMe=true;
|
||||
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]))
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
|
||||
bool addMe = true;
|
||||
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]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
// 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)
|
||||
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 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)){
|
||||
searchStr = "Face";
|
||||
for (size_t 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;
|
||||
addMe = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (addMe){
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
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);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintFixed::removeFromSelection()
|
||||
{
|
||||
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!"));
|
||||
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();
|
||||
std::vector<int> itemsToDel;
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
std::vector<size_t> itemsToDel;
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if(!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
|
||||
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]);
|
||||
itr!= SubElements.end();
|
||||
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
|
||||
for (size_t 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]);
|
||||
itr != SubElements.end();
|
||||
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(),itr));
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(), itr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(itemsToDel.begin(),itemsToDel.end());
|
||||
while (itemsToDel.size()>0){
|
||||
Objects.erase(Objects.begin()+itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin()+itemsToDel.back());
|
||||
std::sort(itemsToDel.begin(), itemsToDel.end());
|
||||
while (itemsToDel.size() > 0){
|
||||
Objects.erase(Objects.begin() + itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin() + itemsToDel.back());
|
||||
itemsToDel.pop_back();
|
||||
}
|
||||
//Update UI
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j=0;j<Objects.size();j++){
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
{
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j = 0; j < Objects.size(); j++) {
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
}
|
||||
}
|
||||
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
||||
@@ -738,7 +738,6 @@ void TaskFemConstraintFluidBoundary::addToSelection()
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintFluidBoundary* pcConstraint = static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
@@ -748,7 +747,6 @@ void TaskFemConstraintFluidBoundary::addToSelection()
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
for (size_t subIt = 0; subIt < subNames.size(); ++subIt) {// for every selected sub element
|
||||
@@ -761,7 +759,6 @@ void TaskFemConstraintFluidBoundary::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)
|
||||
@@ -787,7 +784,6 @@ void TaskFemConstraintFluidBoundary::addToSelection()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Update UI
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
@@ -800,7 +796,6 @@ void TaskFemConstraintFluidBoundary::removeFromSelection()
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintFluidBoundary* pcConstraint = static_cast<Fem::ConstraintFluidBoundary*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
@@ -810,7 +805,6 @@ void TaskFemConstraintFluidBoundary::removeFromSelection()
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
@@ -825,14 +819,12 @@ void TaskFemConstraintFluidBoundary::removeFromSelection()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(itemsToDel.begin(), itemsToDel.end());
|
||||
while (itemsToDel.size() > 0) {
|
||||
Objects.erase(Objects.begin() + itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin() + itemsToDel.back());
|
||||
itemsToDel.pop_back();
|
||||
}
|
||||
|
||||
//Update UI
|
||||
{
|
||||
QSignalBlocker block(ui->listReferences);
|
||||
@@ -841,7 +833,6 @@ void TaskFemConstraintFluidBoundary::removeFromSelection()
|
||||
ui->listReferences->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
}
|
||||
}
|
||||
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
|
||||
#include "ui_TaskFemConstraintForce.h"
|
||||
#include "TaskFemConstraintForce.h"
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
@@ -61,7 +62,6 @@
|
||||
#include <Mod/Fem/App/FemTools.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
#include <Base/Console.h>
|
||||
|
||||
using namespace FemGui;
|
||||
using namespace Gui;
|
||||
@@ -149,7 +149,6 @@ void TaskFemConstraintForce::addToSelection()
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintForce* pcConstraint = static_cast<Fem::ConstraintForce*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
@@ -159,7 +158,6 @@ void TaskFemConstraintForce::addToSelection()
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element
|
||||
@@ -172,7 +170,6 @@ void TaskFemConstraintForce::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)
|
||||
@@ -198,7 +195,6 @@ void TaskFemConstraintForce::addToSelection()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Update UI
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
@@ -211,7 +207,6 @@ void TaskFemConstraintForce::removeFromSelection()
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintForce* pcConstraint = static_cast<Fem::ConstraintForce*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
@@ -221,7 +216,6 @@ void TaskFemConstraintForce::removeFromSelection()
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
@@ -236,14 +230,12 @@ void TaskFemConstraintForce::removeFromSelection()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(itemsToDel.begin(), itemsToDel.end());
|
||||
while (itemsToDel.size() > 0) {
|
||||
Objects.erase(Objects.begin() + itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin() + itemsToDel.back());
|
||||
itemsToDel.pop_back();
|
||||
}
|
||||
|
||||
//Update UI
|
||||
{
|
||||
QSignalBlocker block(ui->listReferences);
|
||||
@@ -252,7 +244,6 @@ void TaskFemConstraintForce::removeFromSelection()
|
||||
ui->listReferences->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
}
|
||||
}
|
||||
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
@@ -295,7 +286,6 @@ void TaskFemConstraintForce::onButtonDirection(const bool pressed)
|
||||
QMessageBox::warning(this, tr("Wrong selection"), tr("Only one planar face or edge can be selected!"));
|
||||
return;
|
||||
}
|
||||
|
||||
// we are now sure we only have one object
|
||||
std::string subNamesElement = subNames[0];
|
||||
// vector for the direction
|
||||
|
||||
@@ -49,7 +49,9 @@
|
||||
#include "TaskFemConstraintHeatflux.h"
|
||||
#include "ui_TaskFemConstraintHeatflux.h"
|
||||
#include <App/Application.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
using namespace FemGui;
|
||||
using namespace Gui;
|
||||
@@ -208,27 +210,26 @@ void TaskFemConstraintHeatflux::Flux()
|
||||
void TaskFemConstraintHeatflux::addToSelection()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
|
||||
if (subNames.size()>0){
|
||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){
|
||||
if (subNames[subIt].substr(0,4).compare(std::string("Face"))!=0){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selection must only consist of faces!"));
|
||||
if (subNames.size() > 0){
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){
|
||||
if (subNames[subIt].substr(0, 4) != "Face") {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selection must only consist of faces!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -236,38 +237,33 @@ void TaskFemConstraintHeatflux::addToSelection()
|
||||
else{
|
||||
//fix me, if an object is selected completely, getSelectionEx does not return any SubElements
|
||||
}
|
||||
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
|
||||
bool addMe=true;
|
||||
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]))
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
|
||||
bool addMe = true;
|
||||
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]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
if (addMe){
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
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);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintHeatflux::removeFromSelection()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
@@ -275,19 +271,19 @@ void TaskFemConstraintHeatflux::removeFromSelection()
|
||||
Fem::ConstraintHeatflux* pcConstraint = static_cast<Fem::ConstraintHeatflux*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
std::vector<int> itemsToDel;
|
||||
std::vector<size_t> itemsToDel;
|
||||
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){
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
|
||||
if (subNames.size()>0){
|
||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){
|
||||
if (subNames[subIt].substr(0,4).compare(std::string("Face"))!=0){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selection must only consist of faces!"));
|
||||
if (subNames.size() > 0){
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){
|
||||
if (subNames[subIt].substr(0, 4) != "Face") {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selection must only consist of faces!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -295,39 +291,32 @@ void TaskFemConstraintHeatflux::removeFromSelection()
|
||||
else{
|
||||
//fix me, if an object is selected completely, getSelectionEx does not return any SubElements
|
||||
}
|
||||
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
|
||||
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]);
|
||||
itr!= SubElements.end();
|
||||
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
|
||||
for (size_t 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]);
|
||||
itr != SubElements.end();
|
||||
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(),itr));
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(), itr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(itemsToDel.begin(),itemsToDel.end());
|
||||
while (itemsToDel.size()>0){
|
||||
Objects.erase(Objects.begin()+itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin()+itemsToDel.back());
|
||||
std::sort(itemsToDel.begin(), itemsToDel.end());
|
||||
while (itemsToDel.size() > 0){
|
||||
Objects.erase(Objects.begin() + itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin() + itemsToDel.back());
|
||||
itemsToDel.pop_back();
|
||||
}
|
||||
//Update UI
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j=0;j<Objects.size();j++){
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
{
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j = 0; j < Objects.size(); j++) {
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
}
|
||||
}
|
||||
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/PropertyGeo.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
@@ -61,8 +63,6 @@
|
||||
#include <Mod/Fem/App/FemTools.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
#include <Base/Console.h>
|
||||
|
||||
|
||||
using namespace FemGui;
|
||||
using namespace Gui;
|
||||
@@ -129,15 +129,14 @@ void TaskFemConstraintPlaneRotation::updateUI()
|
||||
void TaskFemConstraintPlaneRotation::addToSelection()
|
||||
{
|
||||
int rows = ui->lw_references->model()->rowCount();
|
||||
if (rows==1){
|
||||
if (rows == 1){
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only one face can be selected for a plane rotation constraint!"));
|
||||
Gui::Selection().clearSelection();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
@@ -145,45 +144,41 @@ void TaskFemConstraintPlaneRotation::addToSelection()
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
|
||||
if (subNames.size()==1){
|
||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
|
||||
bool addMe=true;
|
||||
if ((subNames[subIt].substr(0,4) != "Face")) {
|
||||
if (subNames.size() == 1){
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
|
||||
bool addMe = true;
|
||||
if ((subNames[subIt].substr(0, 4) != "Face")) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
|
||||
return;
|
||||
}
|
||||
Part::Feature* feat = static_cast<Part::Feature*>(obj);
|
||||
TopoDS_Shape ref = feat->Shape.getShape().getSubShape(subNames[subIt].c_str());
|
||||
if ((subNames[subIt].substr(0,4) == "Face")) {
|
||||
if ((subNames[subIt].substr(0, 4) == "Face")) {
|
||||
if (!Fem::Tools::isPlanar(TopoDS::Face(ref))) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only planar faces can be picked"));
|
||||
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])){// for every sub element in selection that matches one in old list
|
||||
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
|
||||
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])){// for every sub element in selection that matches one in old list
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (addMe){
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
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*)));
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
Objects.push_back(obj);
|
||||
SubElements.push_back(subNames[subIt]);
|
||||
ui->lw_references->addItem(makeRefText(obj, subNames[subIt]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,7 +188,7 @@ void TaskFemConstraintPlaneRotation::addToSelection()
|
||||
return;
|
||||
}
|
||||
//Update UI
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
@@ -202,54 +197,48 @@ void TaskFemConstraintPlaneRotation::addToSelection()
|
||||
void TaskFemConstraintPlaneRotation::removeFromSelection()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintPlaneRotation* pcConstraint = static_cast<Fem::ConstraintPlaneRotation*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
std::vector<int> itemsToDel;
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
std::vector<size_t> itemsToDel;
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
|
||||
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]);
|
||||
itr!= SubElements.end();
|
||||
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
|
||||
for (size_t 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]);
|
||||
itr != SubElements.end();
|
||||
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(),itr));
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(), itr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(itemsToDel.begin(),itemsToDel.end());
|
||||
while (itemsToDel.size()>0){
|
||||
Objects.erase(Objects.begin()+itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin()+itemsToDel.back());
|
||||
std::sort(itemsToDel.begin(), itemsToDel.end());
|
||||
while (itemsToDel.size() > 0){
|
||||
Objects.erase(Objects.begin() + itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin() + itemsToDel.back());
|
||||
itemsToDel.pop_back();
|
||||
}
|
||||
//Update UI
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j=0;j<Objects.size();j++){
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
{
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j = 0; j < Objects.size(); j++) {
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
}
|
||||
}
|
||||
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,11 @@
|
||||
#include "TaskFemConstraintPressure.h"
|
||||
#include "ui_TaskFemConstraintPressure.h"
|
||||
#include <App/Application.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
|
||||
using namespace FemGui;
|
||||
@@ -132,106 +134,94 @@ void TaskFemConstraintPressure::onCheckReverse(const bool pressed)
|
||||
void TaskFemConstraintPressure::addToSelection()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
|
||||
|
||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
|
||||
bool addMe=true;
|
||||
if (subNames[subIt].substr(0,4) != "Face") {
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
|
||||
bool addMe = true;
|
||||
if (subNames[subIt].substr(0, 4) != "Face") {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
|
||||
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]))
|
||||
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]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
if (addMe){
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
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);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintPressure::removeFromSelection()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
std::vector<int> itemsToDel;
|
||||
std::vector<size_t> itemsToDel;
|
||||
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){
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
|
||||
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]);
|
||||
itr!= SubElements.end();
|
||||
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
|
||||
for (size_t 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]);
|
||||
itr != SubElements.end();
|
||||
itr = std::find(++itr,SubElements.end(), subNames[subIt]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(),itr));
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(), itr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(itemsToDel.begin(),itemsToDel.end());
|
||||
while (itemsToDel.size()>0){
|
||||
Objects.erase(Objects.begin()+itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin()+itemsToDel.back());
|
||||
std::sort(itemsToDel.begin(), itemsToDel.end());
|
||||
while (itemsToDel.size() > 0){
|
||||
Objects.erase(Objects.begin() + itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin() + itemsToDel.back());
|
||||
itemsToDel.pop_back();
|
||||
}
|
||||
//Update UI
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j=0;j<Objects.size();j++){
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
{
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j = 0; j < Objects.size(); j++) {
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
}
|
||||
}
|
||||
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,9 +48,11 @@
|
||||
#include "TaskFemConstraintTemperature.h"
|
||||
#include "ui_TaskFemConstraintTemperature.h"
|
||||
#include <App/Application.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
|
||||
using namespace FemGui;
|
||||
@@ -177,100 +179,89 @@ void TaskFemConstraintTemperature::Flux()
|
||||
void TaskFemConstraintTemperature::addToSelection()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintTemperature* pcConstraint = static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
|
||||
bool addMe=true;
|
||||
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]))
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
|
||||
bool addMe = true;
|
||||
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]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (addMe){
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
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);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void TaskFemConstraintTemperature::removeFromSelection()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintTemperature* pcConstraint = static_cast<Fem::ConstraintTemperature*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
std::vector<int> itemsToDel;
|
||||
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){
|
||||
std::vector<size_t> itemsToDel;
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
|
||||
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]);
|
||||
itr!= SubElements.end();
|
||||
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
|
||||
for (size_t 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]);
|
||||
itr != SubElements.end();
|
||||
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(),itr));
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(), itr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(itemsToDel.begin(),itemsToDel.end());
|
||||
while (itemsToDel.size()>0){
|
||||
Objects.erase(Objects.begin()+itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin()+itemsToDel.back());
|
||||
std::sort(itemsToDel.begin(), itemsToDel.end());
|
||||
while (itemsToDel.size() > 0){
|
||||
Objects.erase(Objects.begin() + itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin() + itemsToDel.back());
|
||||
itemsToDel.pop_back();
|
||||
}
|
||||
//Update UI
|
||||
disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j=0;j<Objects.size();j++){
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
{
|
||||
QSignalBlocker block(ui->lw_references);
|
||||
ui->lw_references->clear();
|
||||
for (unsigned int j = 0; j < Objects.size(); j++) {
|
||||
ui->lw_references->addItem(makeRefText(Objects[j], SubElements[j]));
|
||||
}
|
||||
}
|
||||
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "ui_TaskFemConstraintTransform.h"
|
||||
#include <App/Application.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
@@ -95,7 +96,6 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraint
|
||||
connect(ui->sp_Y, SIGNAL(valueChanged(int)), this, SLOT(y_Changed(int)));
|
||||
connect(ui->sp_Z, SIGNAL(valueChanged(int)), this, SLOT(z_Changed(int)));
|
||||
|
||||
/* Note: */
|
||||
// Get the feature data
|
||||
Fem::ConstraintTransform* pcConstraint = static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
|
||||
|
||||
@@ -117,8 +117,6 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(ViewProviderFemConstraint
|
||||
ui->rb_cylin->setChecked(1);
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
ui->lw_Rect->clear();
|
||||
|
||||
//Transformable surfaces
|
||||
@@ -245,7 +243,7 @@ void TaskFemConstraintTransform::addToSelection()
|
||||
{
|
||||
int rows = ui->lw_Rect->model()->rowCount();
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
@@ -269,25 +267,24 @@ void TaskFemConstraintTransform::addToSelection()
|
||||
std::vector<App::DocumentObject*> ObjDispl = pcConstraint->RefDispl.getValues();
|
||||
std::vector<std::string> SubElemDispl = pcConstraint->RefDispl.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){
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
if (subNames.size()!=1){
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
if (subNames.size() != 1){
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only one face for transform constraint!"));
|
||||
Gui::Selection().clearSelection();
|
||||
return;
|
||||
}
|
||||
for (unsigned int subIt=0;subIt<(subNames.size());++subIt){// for every selected sub element
|
||||
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
|
||||
bool addMe=true;
|
||||
if (subNames[subIt].substr(0,4) != "Face") {
|
||||
if (subNames[subIt].substr(0, 4) != "Face") {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Only faces or edges can be picked"));
|
||||
return;
|
||||
}
|
||||
if (subNames[subIt].substr(0,4) == "Face") {
|
||||
if (subNames[subIt].substr(0, 4) == "Face") {
|
||||
if (ui->rb_cylin->isChecked()) {
|
||||
Part::Feature* feat = static_cast<Part::Feature*>(obj);
|
||||
TopoDS_Shape ref = feat->Shape.getShape().getSubShape(subNames[subIt].c_str());
|
||||
@@ -298,19 +295,19 @@ void TaskFemConstraintTransform::addToSelection()
|
||||
}
|
||||
}
|
||||
}
|
||||
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]))
|
||||
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]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (addMe){
|
||||
disconnect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
for (std::size_t i = 0; i < ObjDispl.size(); i++) {
|
||||
if ((makeRefText(ObjDispl[i], SubElemDispl[i]))==(makeRefText(obj, subNames[subIt]))){
|
||||
if ((makeRefText(ObjDispl[i], SubElemDispl[i])) == (makeRefText(obj, subNames[subIt]))){
|
||||
Objects.push_back(obj);
|
||||
SubElements.push_back(subNames[subIt]);
|
||||
ui->lw_Rect->addItem(makeRefText(obj, subNames[subIt]));
|
||||
@@ -327,7 +324,7 @@ void TaskFemConstraintTransform::addToSelection()
|
||||
}
|
||||
}
|
||||
//Update UI
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
if (ui->rb_rect->isChecked()) {
|
||||
Base::Vector3d normal = pcConstraint->NormalDirection.getValue();
|
||||
@@ -364,51 +361,45 @@ void TaskFemConstraintTransform::addToSelection()
|
||||
void TaskFemConstraintTransform::removeFromSelection()
|
||||
{
|
||||
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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Fem::ConstraintTransform* pcConstraint = static_cast<Fem::ConstraintTransform*>(ConstraintView->getObject());
|
||||
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||
std::vector<int> itemsToDel;
|
||||
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){
|
||||
QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!"));
|
||||
std::vector<size_t> itemsToDel;
|
||||
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
|
||||
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it->getSubNames();
|
||||
App::DocumentObject* obj = it->getObject();
|
||||
|
||||
std::vector<std::string> subNames=it->getSubNames();
|
||||
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
|
||||
|
||||
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]);
|
||||
itr!= SubElements.end();
|
||||
itr = std::find(++itr,SubElements.end(),subNames[subIt]))
|
||||
for (size_t 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]);
|
||||
itr != SubElements.end();
|
||||
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
|
||||
{// for every sub element in selection that matches one in old list
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(),itr));
|
||||
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 mark for deletion
|
||||
itemsToDel.push_back(std::distance(SubElements.begin(), itr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(itemsToDel.begin(),itemsToDel.end());
|
||||
while (itemsToDel.size()>0){
|
||||
Objects.erase(Objects.begin()+itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin()+itemsToDel.back());
|
||||
std::sort(itemsToDel.begin(), itemsToDel.end());
|
||||
while (itemsToDel.size() > 0){
|
||||
Objects.erase(Objects.begin() + itemsToDel.back());
|
||||
SubElements.erase(SubElements.begin() + itemsToDel.back());
|
||||
itemsToDel.pop_back();
|
||||
}
|
||||
//Update UI
|
||||
disconnect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
ui->lw_Rect->clear();
|
||||
connect(ui->lw_Rect, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(setSelection(QListWidgetItem*)));
|
||||
|
||||
pcConstraint->References.setValues(Objects,SubElements);
|
||||
{
|
||||
QSignalBlocker block(ui->lw_Rect);
|
||||
ui->lw_Rect->clear();
|
||||
}
|
||||
pcConstraint->References.setValues(Objects, SubElements);
|
||||
updateUI();
|
||||
ui->sp_X->setValue(0);
|
||||
ui->sp_Y->setValue(0);
|
||||
|
||||
Reference in New Issue
Block a user