Fix reference selection code

PolarPattern was missing some classes. The code is now more consistent
between the patterns.
This commit is contained in:
André Althaus
2024-02-28 16:42:59 +01:00
parent 0bdd72e7e7
commit a76aead05e
3 changed files with 25 additions and 27 deletions

View File

@@ -222,27 +222,25 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges
exitSelectionMode();
}
else if (selectionMode == SelectionMode::Reference) {
// TODO check if this works correctly (2015-09-01, Fat-Zer)
exitSelectionMode();
auto pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
std::vector<std::string> directions;
App::DocumentObject* selObj = nullptr;
auto pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
if (pcLinearPattern) {
getReferencedSelection(pcLinearPattern, msg, selObj, directions);
// Note: ReferenceSelection has already checked the selection for validity
if (selObj
&& (selectionMode == SelectionMode::Reference
|| selObj->isDerivedFrom(App::Line::getClassTypeId())
|| selObj->isDerivedFrom(Part::Feature::getClassTypeId())
|| selObj->isDerivedFrom(PartDesign::Line::getClassTypeId())
|| selObj->isDerivedFrom(PartDesign::Plane::getClassTypeId()))) {
setupTransaction();
pcLinearPattern->Direction.setValue(selObj, directions);
recomputeFeature();
updateUI();
}
getReferencedSelection(pcLinearPattern, msg, selObj, directions);
if (!selObj) {
return;
}
// Note: ReferenceSelection has already checked the selection for validity
if (selObj->isDerivedFrom<App::Line>() || selObj->isDerivedFrom<Part::Feature>()
|| selObj->isDerivedFrom<PartDesign::Line>()
|| selObj->isDerivedFrom<PartDesign::Plane>()) {
setupTransaction();
pcLinearPattern->Direction.setValue(selObj, directions);
recomputeFeature();
updateUI();
}
exitSelectionMode();
}
}
}

View File

@@ -134,17 +134,17 @@ void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg
if (originalSelected(msg)) {
exitSelectionMode();
}
else {
else if (selectionMode == SelectionMode::Reference) {
auto pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
std::vector<std::string> mirrorPlanes;
App::DocumentObject* selObj = nullptr;
auto pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes);
if (!selObj) {
return;
}
if (selectionMode == SelectionMode::Reference
|| selObj->isDerivedFrom(App::Plane::getClassTypeId())) {
if (selObj->isDerivedFrom<App::Plane>()) {
setupTransaction();
pcMirrored->MirrorPlane.setValue(selObj, mirrorPlanes);
recomputeFeature();

View File

@@ -218,21 +218,21 @@ void TaskPolarPatternParameters::adaptVisibilityToMode()
void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
{
if (selectionMode != SelectionMode::None && msg.Type == Gui::SelectionChanges::AddSelection) {
if (originalSelected(msg)) {
exitSelectionMode();
}
else {
else if (selectionMode == SelectionMode::Reference) {
auto pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
std::vector<std::string> axes;
App::DocumentObject* selObj = nullptr;
auto pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
getReferencedSelection(pcPolarPattern, msg, selObj, axes);
if (!selObj) {
return;
}
if (selectionMode == SelectionMode::Reference
|| selObj->isDerivedFrom(App::Line::getClassTypeId())) {
if (selObj->isDerivedFrom<App::Line>() || selObj->isDerivedFrom<Part::Feature>()
|| selObj->isDerivedFrom<PartDesign::Line>()) {
setupTransaction();
pcPolarPattern->Axis.setValue(selObj, axes);
recomputeFeature();