[PD] Support two-angle/up-to-face groove

Elements copied from revolution and pocket feature.
This commit is contained in:
Ajinkya Dahale
2022-07-25 10:18:23 +05:30
parent 796727fcd3
commit c7101d7ced
4 changed files with 324 additions and 37 deletions

View File

@@ -49,7 +49,8 @@ using namespace Gui;
TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider* RevolutionView, QWidget *parent)
: TaskSketchBasedParameters(RevolutionView, parent, "PartDesign_Revolution", tr("Revolution parameters")),
ui(new Ui_TaskRevolutionParameters),
proxy(new QWidget(this))
proxy(new QWidget(this)),
isGroove(false)
{
// we need a separate container widget to add all controls to
ui->setupUi(proxy);
@@ -68,11 +69,15 @@ TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider*
ui->revolveAngle2->bind(rev->Angle2);
}
else if (auto *rev = dynamic_cast<PartDesign::Groove *>(vp->getObject())) {
isGroove = true;
this->propAngle = &(rev->Angle);
this->propAngle2 = &(rev->Angle2);
this->propMidPlane = &(rev->Midplane);
this->propReferenceAxis = &(rev->ReferenceAxis);
this->propReversed = &(rev->Reversed);
this->propUpToFace = &(rev->UpToFace);
ui->revolveAngle->bind(rev->Angle);
ui->revolveAngle2->bind(rev->Angle2);
}
else {
throw Base::TypeError("The object is neither a Groove nor a Revolution.");
@@ -103,7 +108,6 @@ TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider*
void TaskRevolutionParameters::setupDialog()
{
PartDesign::ProfileBased* pcFeat = static_cast<PartDesign::ProfileBased*>(vp->getObject());
ui->checkBoxMidplane->setChecked(propMidPlane->getValue());
ui->checkBoxReversed->setChecked(propReversed->getValue());
@@ -114,7 +118,7 @@ void TaskRevolutionParameters::setupDialog()
int index = 0;
// TODO: This should also be implemented for groove
if (pcFeat->isDerivedFrom(PartDesign::Revolution::getClassTypeId())) {
if (!isGroove) {
PartDesign::Revolution* rev = static_cast<PartDesign::Revolution*>(vp->getObject());
ui->revolveAngle2->setValue(propAngle2->getValue());
ui->revolveAngle2->setMaximum(propAngle2->getMaximum());
@@ -122,6 +126,14 @@ void TaskRevolutionParameters::setupDialog()
index = rev->Type.getValue();
}
else {
PartDesign::Groove* rev = static_cast<PartDesign::Groove*>(vp->getObject());
ui->revolveAngle2->setValue(propAngle2->getValue());
ui->revolveAngle2->setMaximum(propAngle2->getMaximum());
ui->revolveAngle2->setMinimum(propAngle2->getMinimum());
index = rev->Type.getValue();
}
translateModeList(index);
}
@@ -130,7 +142,12 @@ void TaskRevolutionParameters::translateModeList(int index)
{
ui->changeMode->clear();
ui->changeMode->addItem(tr("Dimension"));
ui->changeMode->addItem(tr("To last"));
if (!isGroove) {
ui->changeMode->addItem(tr("To last"));
}
else {
ui->changeMode->addItem(tr("Through all"));
}
ui->changeMode->addItem(tr("To first"));
ui->changeMode->addItem(tr("Up to face"));
ui->changeMode->addItem(tr("Two dimensions"));
@@ -448,26 +465,33 @@ void TaskRevolutionParameters::onReversed(bool on)
void TaskRevolutionParameters::onModeChanged(int index)
{
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(vp->getObject());
App::PropertyEnumeration* pcType;
if (!isGroove)
pcType = &(static_cast<PartDesign::Revolution*>(vp->getObject())->Type);
else
pcType = &(static_cast<PartDesign::Groove*>(vp->getObject())->Type);
switch (static_cast<PartDesign::Revolution::RevolMethod>(index)) {
case PartDesign::Revolution::RevolMethod::Dimension:
pcRevolution->Type.setValue("Angle");
pcType->setValue("Angle");
// Avoid error message
// if (ui->revolveAngle->value() < Base::Quantity(Precision::Angular(), Base::Unit::Angle)) // TODO: Ensure radians/degree consistency
// ui->revolveAngle->setValue(5.0);
break;
case PartDesign::Revolution::RevolMethod::ToLast:
pcRevolution->Type.setValue("UpToLast");
if (!isGroove)
pcType->setValue("UpToLast");
else
pcType->setValue("ThroughAll");
break;
case PartDesign::Revolution::RevolMethod::ToFirst:
pcRevolution->Type.setValue("UpToFirst");
pcType->setValue("UpToFirst");
break;
case PartDesign::Revolution::RevolMethod::ToFace:
pcRevolution->Type.setValue("UpToFace");
pcType->setValue("UpToFace");
break;
case PartDesign::Revolution::RevolMethod::TwoDimensions:
pcRevolution->Type.setValue("TwoAngles");
pcType->setValue("TwoAngles");
break;
}