[PD] add parameter enabling logic for pad/pocket
- currently all parameters are always enabled and thus can lead to errors like the one reported here: https://forum.freecadweb.org/viewtopic.php?f=3&t=70266
This commit is contained in:
@@ -273,3 +273,57 @@ void FeatureExtrude::generateTaperedPrism(TopoDS_Shape& prism,
|
||||
prism = comp;
|
||||
}
|
||||
}
|
||||
|
||||
void FeatureExtrude::updateProperties(const std::string &method)
|
||||
{
|
||||
// disable settings that are not valid on the current method
|
||||
// disable everything unless we are sure we don't need it
|
||||
bool isLengthEnabled = false;
|
||||
bool isLength2Enabled = false;
|
||||
bool isOffsetEnabled = false;
|
||||
bool isMidplaneEnabled = false;
|
||||
bool isReversedEnabled = false;
|
||||
bool isUpToFaceEnabled = false;
|
||||
bool isTaperVisible = false;
|
||||
bool isTaper2Visible = false;
|
||||
if (method == "Length") {
|
||||
isLengthEnabled = true;
|
||||
isTaperVisible = true;
|
||||
isMidplaneEnabled = true;
|
||||
isReversedEnabled = !Midplane.getValue();
|
||||
}
|
||||
else if (method == "UpToLast") {
|
||||
isOffsetEnabled = true;
|
||||
isReversedEnabled = true;
|
||||
}
|
||||
else if (method == "ThroughAll") {
|
||||
isMidplaneEnabled = true;
|
||||
isReversedEnabled = !Midplane.getValue();
|
||||
}
|
||||
else if (method == "UpToFirst") {
|
||||
isOffsetEnabled = true;
|
||||
isReversedEnabled = true;
|
||||
}
|
||||
else if (method == "UpToFace") {
|
||||
isOffsetEnabled = true;
|
||||
isReversedEnabled = true;
|
||||
isUpToFaceEnabled = true;
|
||||
}
|
||||
else if (method == "TwoLengths") {
|
||||
isLengthEnabled = true;
|
||||
isLength2Enabled = true;
|
||||
isTaperVisible = true;
|
||||
isTaper2Visible = true;
|
||||
isReversedEnabled = true;
|
||||
}
|
||||
|
||||
Length.setReadOnly(!isLengthEnabled);
|
||||
AlongSketchNormal.setReadOnly(!isLengthEnabled);
|
||||
Length2.setReadOnly(!isLength2Enabled);
|
||||
Offset.setReadOnly(!isOffsetEnabled);
|
||||
TaperAngle.setReadOnly(!isTaperVisible);
|
||||
TaperAngle2.setReadOnly(!isTaper2Visible);
|
||||
Midplane.setReadOnly(!isMidplaneEnabled);
|
||||
Reversed.setReadOnly(!isReversedEnabled);
|
||||
UpToFace.setReadOnly(!isUpToFaceEnabled);
|
||||
}
|
||||
|
||||
@@ -111,6 +111,11 @@ protected:
|
||||
const double angle,
|
||||
const double angle2,
|
||||
const bool midplane);
|
||||
|
||||
/**
|
||||
* Disables settings that are not valid for the current method
|
||||
*/
|
||||
void updateProperties(const std::string &method);
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
@@ -238,6 +238,9 @@ App::DocumentObjectExecReturn *Pad::execute()
|
||||
this->Shape.setValue(getSolid(prism));
|
||||
}
|
||||
|
||||
// eventually disable some settings that are not valid for the current method
|
||||
updateProperties(method);
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
@@ -250,4 +253,5 @@ App::DocumentObjectExecReturn *Pad::execute()
|
||||
catch (Base::Exception& e) {
|
||||
return new App::DocumentObjectExecReturn(e.what());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ using namespace PartDesign;
|
||||
|
||||
/* TRANSLATOR PartDesign::Pocket */
|
||||
|
||||
const char* Pocket::TypeEnums[]= {"Length","ThroughAll","UpToFirst","UpToFace","TwoLengths",nullptr};
|
||||
const char* Pocket::TypeEnums[]= {"Length", "ThroughAll", "UpToFirst", "UpToFace", "TwoLengths", nullptr};
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Pocket, PartDesign::FeatureExtrude)
|
||||
|
||||
@@ -237,6 +237,9 @@ App::DocumentObjectExecReturn *Pocket::execute()
|
||||
this->Shape.setValue(getSolid(solRes));
|
||||
}
|
||||
|
||||
// eventually disable some settings that are not valid for the current method
|
||||
updateProperties(method);
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
Reference in New Issue
Block a user