PD: Keep Length and Offset in sync for LinearPattern

As Length and Offset represents the same concept in different way it is
useful to keep them in sync when it is possible. Update to one of them
will update the other with approperiate value. This behaviour behaviour
works only if both properties are not coming from expression engine -
those will stay not touched.
This commit is contained in:
Kacper Donat
2023-08-26 20:02:28 +02:00
parent 148c497eba
commit 2d22c8f4af
2 changed files with 13 additions and 2 deletions

View File

@@ -238,11 +238,21 @@ void LinearPattern::handleChangedPropertyType(Base::XMLReader& reader, const cha
void LinearPattern::onChanged(const App::Property* prop)
{
auto mode = static_cast<LinearPatternMode>(Mode.getValue());
if (prop == &Mode) {
auto mode = static_cast<LinearPatternMode>(Mode.getValue());
setReadWriteStatusForMode(mode);
}
// Keep Length in sync with Offset
if (mode == LinearPatternMode::offset && prop == &Offset && !Length.testStatus(App::Property::Status::Immutable)) {
Length.setValue(Offset.getValue() * (Occurrences.getValue() - 1));
}
if (mode == LinearPatternMode::length && prop == &Length && !Offset.testStatus(App::Property::Status::Immutable)) {
Offset.setValue(Length.getValue() / (Occurrences.getValue() - 1));
}
Transformed::onChanged(prop);
}

View File

@@ -198,7 +198,6 @@ void TaskLinearPatternParameters::setupUI()
}
adaptVisibilityToMode();
updateUI();
connectSignals();
}
@@ -241,6 +240,8 @@ void TaskLinearPatternParameters::adaptVisibilityToMode()
ui->lengthWrapper->setVisible(mode == PartDesign::LinearPatternMode::length);
ui->offsetWrapper->setVisible(mode == PartDesign::LinearPatternMode::offset);
updateUI();
}
void TaskLinearPatternParameters::onUpdateViewTimer()