Fem: Do not allow selection of external objects for analysis objects - fixes #23834
This commit is contained in:
committed by
Chris Hennes
parent
a85f53d0bb
commit
df82e7b71c
@@ -215,9 +215,16 @@ void TaskFemConstraintContact::addToSelectionSlave()
|
||||
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();
|
||||
|
||||
App::DocumentObject* obj = it.getObject();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
if (subNames.size() != 1) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
@@ -276,9 +283,9 @@ void TaskFemConstraintContact::removeFromSelectionSlave()
|
||||
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
const App::DocumentObject* obj = it.getObject();
|
||||
|
||||
for (const auto& subName : subNames) { // for every selected sub element
|
||||
for (auto itr = std::ranges::find(SubElements, subName); itr != SubElements.end();
|
||||
itr = std::find(++itr,
|
||||
@@ -343,8 +350,15 @@ void TaskFemConstraintContact::addToSelectionMaster()
|
||||
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();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
if (subNames.size() != 1) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
|
||||
@@ -252,8 +252,16 @@ void TaskFemConstraintDisplacement::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();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
for (const auto& subName : subNames) { // for every selected sub element
|
||||
bool addMe = true;
|
||||
for (auto itr = std::ranges::find(SubElements.begin(), SubElements.end(), subName);
|
||||
|
||||
@@ -119,9 +119,16 @@ void TaskFemConstraintFixed::addToSelection()
|
||||
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());
|
||||
|
||||
App::DocumentObject* obj = it.getObject();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
for (const auto& subName : subNames) { // for every selected sub element
|
||||
bool addMe = true;
|
||||
for (auto itr = std::ranges::find(SubElements, subName); itr != SubElements.end();
|
||||
|
||||
@@ -831,8 +831,16 @@ 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();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
for (const auto& subName : subNames) { // for every selected sub element
|
||||
bool addMe = true;
|
||||
for (auto itr = std::ranges::find(SubElements, subName); itr != SubElements.end();
|
||||
|
||||
@@ -136,8 +136,16 @@ 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();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
for (const auto& subName : subNames) { // for every selected sub element
|
||||
bool addMe = true;
|
||||
for (auto itr = std::ranges::find(SubElements, subName); itr != SubElements.end();
|
||||
|
||||
@@ -276,9 +276,16 @@ void TaskFemConstraintHeatflux::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();
|
||||
|
||||
App::DocumentObject* obj = it.getObject();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
if (!subNames.empty()) {
|
||||
for (const auto& subName : subNames) {
|
||||
if ((subName.substr(0, 4) != "Face") && (subName.substr(0, 4) != "Edge")) {
|
||||
|
||||
@@ -149,9 +149,16 @@ void TaskFemConstraintPlaneRotation::addToSelection()
|
||||
tr("Selected object is not a part!"));
|
||||
return;
|
||||
}
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
App::DocumentObject* obj = it.getObject();
|
||||
|
||||
App::DocumentObject* obj = it.getObject();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
if (subNames.size() == 1) {
|
||||
for (const auto& subName : subNames) { // for every selected sub element
|
||||
bool addMe = true;
|
||||
|
||||
@@ -141,9 +141,16 @@ void TaskFemConstraintPressure::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();
|
||||
|
||||
App::DocumentObject* obj = it.getObject();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
for (const auto& subName : subNames) { // for every selected sub element
|
||||
bool addMe = true;
|
||||
if ((subName.substr(0, 4) != "Face") && (subName.substr(0, 4) != "Edge")) {
|
||||
|
||||
@@ -279,15 +279,21 @@ void TaskFemConstraintRigidBody::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 (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
|
||||
for (auto& it : selection) { // 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());
|
||||
|
||||
App::DocumentObject* obj = it.getObject();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
for (size_t subIt = 0; subIt < (subNames.size());
|
||||
++subIt) { // for every selected sub element
|
||||
bool addMe = true;
|
||||
|
||||
@@ -139,9 +139,16 @@ void TaskFemConstraintSpring::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();
|
||||
|
||||
App::DocumentObject* obj = it.getObject();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
for (const auto& subName : subNames) { // for every selected sub element
|
||||
bool addMe = true;
|
||||
if (subName.substr(0, 4) != "Face") {
|
||||
|
||||
@@ -200,9 +200,16 @@ void TaskFemConstraintTemperature::addToSelection()
|
||||
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());
|
||||
|
||||
App::DocumentObject* obj = it.getObject();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
for (const auto& subName : subNames) { // for every selected sub element
|
||||
bool addMe = true;
|
||||
for (auto itr = std::ranges::find(SubElements, subName); itr != SubElements.end();
|
||||
|
||||
@@ -323,8 +323,16 @@ void TaskFemConstraintTransform::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();
|
||||
if (obj->getDocument() != pcConstraint->getDocument()) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
tr("External object selection is not supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& subNames = it.getSubNames();
|
||||
if (subNames.size() != 1) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Selection error"),
|
||||
|
||||
@@ -603,6 +603,13 @@ class FemSelectionObserver:
|
||||
|
||||
def addSelection(self, docName, objName, sub, pos):
|
||||
selected_object = FreeCAD.getDocument(docName).getObject(objName) # get the obj objName
|
||||
if FreeCADGui.editDocument().getInEdit().Object.Document != selected_object.Document:
|
||||
QtGui.QMessageBox.critical(
|
||||
None, "Selection error", "External object selection is not supported"
|
||||
)
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
return
|
||||
|
||||
self.added_obj = (selected_object, sub)
|
||||
# on double click on a vertex of a solid sub is None and obj is the solid
|
||||
self.parseSelectionFunction(self.added_obj)
|
||||
|
||||
Reference in New Issue
Block a user