[PD] Update revolution properties based on method

This commit is contained in:
Ajinkya Dahale
2022-07-24 00:32:40 +05:30
parent 7e09589942
commit 0829c96549
2 changed files with 49 additions and 0 deletions

View File

@@ -197,6 +197,9 @@ App::DocumentObjectExecReturn *Revolution::execute()
else
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Could not revolve the sketch!"));
// eventually disable some settings that are not valid for the current method
updateProperties(method);
return App::DocumentObject::StdReturn;
}
catch (Standard_Failure& e) {
@@ -326,4 +329,45 @@ void Revolution::generateRevolution(TopoDS_Shape& revol,
}
}
void Revolution::updateProperties(const std::string &method)
{
// disable settings that are not valid on the current method
// disable everything unless we are sure we need it
bool isAngleEnabled = false;
bool isAngle2Enabled = false;
bool isMidplaneEnabled = false;
bool isReversedEnabled = false;
bool isUpToFaceEnabled = false;
if (method == "Angle") {
isAngleEnabled = true;
isMidplaneEnabled = true;
isReversedEnabled = !Midplane.getValue();
}
else if (method == "UpToLast") {
isReversedEnabled = true;
}
else if (method == "ThroughAll") {
isMidplaneEnabled = true;
isReversedEnabled = !Midplane.getValue();
}
else if (method == "UpToFirst") {
isReversedEnabled = true;
}
else if (method == "UpToFace") {
isReversedEnabled = true;
isUpToFaceEnabled = true;
}
else if (method == "TwoAngles") {
isAngleEnabled = true;
isAngle2Enabled = true;
isReversedEnabled = true;
}
Angle.setReadOnly(!isAngleEnabled);
Angle2.setReadOnly(!isAngle2Enabled);
Midplane.setReadOnly(!isMidplaneEnabled);
Reversed.setReadOnly(!isReversedEnabled);
UpToFace.setReadOnly(!isUpToFaceEnabled);
}
}

View File

@@ -107,6 +107,11 @@ protected:
RevolMode Mode,
Standard_Boolean Modify);
/**
* Disables settings that are not valid for the current method
*/
void updateProperties(const std::string &method);
private:
static const char* TypeEnums[];
};