[PD] fix issue 0004785
- then the profile of a pad/pocket was a face, the direction handling was completely broken
This commit is contained in:
@@ -359,17 +359,34 @@ void TaskPocketParameters::fillDirectionCombo()
|
||||
blockUpdate = true;
|
||||
|
||||
if (axesInList.empty()) {
|
||||
bool hasFace = false;
|
||||
ui->directionCB->clear();
|
||||
// add sketch normal
|
||||
// we can have sketches or faces
|
||||
// for sketches just get the sketch normal
|
||||
PartDesign::ProfileBased* pcFeat = static_cast<PartDesign::ProfileBased*>(vp->getObject());
|
||||
Part::Part2DObject* pcSketch = dynamic_cast<Part::Part2DObject*>(pcFeat->Profile.getValue());
|
||||
// for faces we test if it is verified and if we can get its normal
|
||||
if (!pcSketch) {
|
||||
try {
|
||||
Part::Feature* pcFeature = pcFeat->getVerifiedObject();
|
||||
Base::Vector3d SketchVector = pcFeat->getProfileNormal();
|
||||
hasFace = true;
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
new App::DocumentObjectExecReturn(e.what());
|
||||
}
|
||||
}
|
||||
if (pcSketch)
|
||||
addAxisToCombo(pcSketch, "N_Axis", QObject::tr("Sketch normal"));
|
||||
addAxisToCombo(pcSketch, "N_Axis", tr("Sketch normal"));
|
||||
else if (hasFace)
|
||||
addAxisToCombo(pcFeat->Profile.getValue(), std::string(), tr("Face normal"), false);
|
||||
// add the other entries
|
||||
addAxisToCombo(0, std::string(), tr("Select reference..."));
|
||||
// we start with the sketch normal as proposal for the custom direction
|
||||
if (pcSketch)
|
||||
addAxisToCombo(pcSketch, "N_Axis", QObject::tr("Custom direction"));
|
||||
addAxisToCombo(pcSketch, "N_Axis", tr("Custom direction"));
|
||||
else if (hasFace)
|
||||
addAxisToCombo(pcFeat->Profile.getValue(), std::string(), tr("Custom direction"), false);
|
||||
}
|
||||
|
||||
// add current link, if not in list
|
||||
@@ -411,12 +428,16 @@ void TaskPocketParameters::fillDirectionCombo()
|
||||
}
|
||||
|
||||
void TaskPocketParameters::addAxisToCombo(App::DocumentObject* linkObj,
|
||||
std::string linkSubname, QString itemText)
|
||||
std::string linkSubname, QString itemText, bool hasSketch)
|
||||
{
|
||||
this->ui->directionCB->addItem(itemText);
|
||||
this->axesInList.emplace_back(new App::PropertyLinkSub);
|
||||
App::PropertyLinkSub& lnk = *(axesInList.back());
|
||||
lnk.setValue(linkObj, std::vector<std::string>(1, linkSubname));
|
||||
// if we have a face, we leave the link empty since we cannot
|
||||
// store the face normal as sublink
|
||||
if (hasSketch)
|
||||
lnk.setValue(linkObj, std::vector<std::string>(1, linkSubname));
|
||||
}
|
||||
|
||||
void TaskPocketParameters::onDirectionCBChanged(int num)
|
||||
@@ -426,8 +447,17 @@ void TaskPocketParameters::onDirectionCBChanged(int num)
|
||||
if (axesInList.empty() || !pcPocket)
|
||||
return;
|
||||
|
||||
// we use this scheme for 'num'
|
||||
// 0: normal to sketch or face
|
||||
// 1: selection mode
|
||||
// 2: custom
|
||||
// 3-x: edges selected in the 3D model
|
||||
|
||||
// check the axis
|
||||
// when the link is empty we are either in selection mode
|
||||
// or we are normal to a face
|
||||
App::PropertyLinkSub& lnk = *(axesInList[num]);
|
||||
if (lnk.getValue() == 0) {
|
||||
if (num == 1) {
|
||||
// enter reference selection mode
|
||||
this->blockConnection(false);
|
||||
// to distinguish that this is the direction selection
|
||||
@@ -435,16 +465,17 @@ void TaskPocketParameters::onDirectionCBChanged(int num)
|
||||
TaskSketchBasedParameters::onSelectReference(true, true, false, true, true);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
else if (lnk.getValue() != 0) {
|
||||
if (!pcPocket->getDocument()->isIn(lnk.getValue())) {
|
||||
Base::Console().Error("Object was deleted\n");
|
||||
return;
|
||||
}
|
||||
propReferenceAxis->Paste(lnk);
|
||||
// in case user is in selection mode, but changed his mind before selecting anything
|
||||
exitSelectionMode();
|
||||
}
|
||||
|
||||
// in case the user is in selection mode, but changed his mind before selecting anything
|
||||
exitSelectionMode();
|
||||
|
||||
try {
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user