[PD] better solution for reversed pad/pocket handling

- let FeatureExtrude set the right direction
- use the UI as once intended: custom vector values are always taken as they are, so reversing a custom direction will not lead to a negation of the custom vector in the UI. The logic is: "take the vector as it is, and when Reversed is on, negate it additionally"
This commit is contained in:
Uwe
2021-11-23 04:22:37 +01:00
parent 4c72df3480
commit 1da079b34b
5 changed files with 26 additions and 29 deletions

View File

@@ -126,6 +126,16 @@ Base::Vector3d FeatureExtrude::computeDirection(const Base::Vector3d& sketchVect
// explicitly set the Direction so that the dialog shows also the used direction
// if the sketch's normal vector was used
Direction.setValue(extrudeDirection);
// for a custom vector we cannot negate it since the Ui takes always the currently
// shown vector values as final direction,
// and when Reversed, it will be negated additionally
if (!UseCustomVector.getValue()) {
if (Reversed.getValue())
Direction.setValue(-extrudeDirection);
else
Direction.setValue(extrudeDirection);
}
// don't return the direction including reversed since this is handled in
// FeatureSketchBased.cpp afterwards
return extrudeDirection;
}

View File

@@ -551,23 +551,16 @@ void TaskPadParameters::onZDirectionEditChanged(double len)
updateDirectionEdits();
}
void TaskPadParameters::updateDirectionEdits(bool Reversed)
void TaskPadParameters::updateDirectionEdits()
{
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(vp->getObject());
// we don't want to execute the onChanged edits, but just update their contents
ui->XDirectionEdit->blockSignals(true);
ui->YDirectionEdit->blockSignals(true);
ui->ZDirectionEdit->blockSignals(true);
if (Reversed) {
ui->XDirectionEdit->setValue(-1 * pcPad->Direction.getValue().x);
ui->YDirectionEdit->setValue(-1 * pcPad->Direction.getValue().y);
ui->ZDirectionEdit->setValue(-1 * pcPad->Direction.getValue().z);
}
else {
ui->XDirectionEdit->setValue(pcPad->Direction.getValue().x);
ui->YDirectionEdit->setValue(pcPad->Direction.getValue().y);
ui->ZDirectionEdit->setValue(pcPad->Direction.getValue().z);
}
ui->XDirectionEdit->setValue(pcPad->Direction.getValue().x);
ui->YDirectionEdit->setValue(pcPad->Direction.getValue().y);
ui->ZDirectionEdit->setValue(pcPad->Direction.getValue().z);
ui->XDirectionEdit->blockSignals(false);
ui->YDirectionEdit->blockSignals(false);
ui->ZDirectionEdit->blockSignals(false);
@@ -595,9 +588,10 @@ void TaskPadParameters::onReversedChanged(bool on)
pcPad->Reversed.setValue(on);
// midplane is not sensible when reversed
ui->checkBoxMidplane->setEnabled(!on);
recomputeFeature();
// update the direction
updateDirectionEdits(on);
recomputeFeature();
updateDirectionEdits();
}
void TaskPadParameters::onModeChanged(int index)

View File

@@ -96,7 +96,7 @@ private:
QString getFaceName(void) const;
void onSelectionChanged(const Gui::SelectionChanges& msg) override;
void updateUI(int index);
void updateDirectionEdits(bool Reversed = false);
void updateDirectionEdits(void);
private:
QWidget* proxy;

View File

@@ -556,23 +556,16 @@ void TaskPocketParameters::onZDirectionEditChanged(double len)
updateDirectionEdits();
}
void TaskPocketParameters::updateDirectionEdits(bool Reversed)
void TaskPocketParameters::updateDirectionEdits()
{
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
// we don't want to execute the onChanged edits, but just update their contents
ui->XDirectionEdit->blockSignals(true);
ui->YDirectionEdit->blockSignals(true);
ui->ZDirectionEdit->blockSignals(true);
if (Reversed) {
ui->XDirectionEdit->setValue(-1 * pcPocket->Direction.getValue().x);
ui->YDirectionEdit->setValue(-1 * pcPocket->Direction.getValue().y);
ui->ZDirectionEdit->setValue(-1 * pcPocket->Direction.getValue().z);
}
else {
ui->XDirectionEdit->setValue(pcPocket->Direction.getValue().x);
ui->YDirectionEdit->setValue(pcPocket->Direction.getValue().y);
ui->ZDirectionEdit->setValue(pcPocket->Direction.getValue().z);
}
ui->XDirectionEdit->setValue(pcPocket->Direction.getValue().x);
ui->YDirectionEdit->setValue(pcPocket->Direction.getValue().y);
ui->ZDirectionEdit->setValue(pcPocket->Direction.getValue().z);
ui->XDirectionEdit->blockSignals(false);
ui->YDirectionEdit->blockSignals(false);
ui->ZDirectionEdit->blockSignals(false);
@@ -592,9 +585,9 @@ void TaskPocketParameters::onReversedChanged(bool on)
pcPocket->Reversed.setValue(on);
// midplane is not sensible when reversed
ui->checkBoxMidplane->setEnabled(!on);
recomputeFeature();
// update the direction
updateDirectionEdits(on);
recomputeFeature();
updateDirectionEdits();
}
void TaskPocketParameters::onModeChanged(int index)

View File

@@ -97,7 +97,7 @@ private:
void onSelectionChanged(const Gui::SelectionChanges& msg) override;
void updateUI(int index);
void updateDirectionEdits(bool Reversed = false);
void updateDirectionEdits(void);
private:
QWidget* proxy;