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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user