[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:
@@ -356,17 +356,34 @@ void TaskPadParameters::fillDirectionCombo()
|
|||||||
blockUpdate = true;
|
blockUpdate = true;
|
||||||
|
|
||||||
if (axesInList.empty()) {
|
if (axesInList.empty()) {
|
||||||
|
bool hasFace = false;
|
||||||
ui->directionCB->clear();
|
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());
|
PartDesign::ProfileBased* pcFeat = static_cast<PartDesign::ProfileBased*>(vp->getObject());
|
||||||
Part::Part2DObject* pcSketch = dynamic_cast<Part::Part2DObject*>(pcFeat->Profile.getValue());
|
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)
|
if (pcSketch)
|
||||||
addAxisToCombo(pcSketch, "N_Axis", 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
|
// add the other entries
|
||||||
addAxisToCombo(0, std::string(), tr("Select reference..."));
|
addAxisToCombo(0, std::string(), tr("Select reference..."));
|
||||||
// we start with the sketch normal as proposal for the custom direction
|
// we start with the sketch normal as proposal for the custom direction
|
||||||
if (pcSketch)
|
if (pcSketch)
|
||||||
addAxisToCombo(pcSketch, "N_Axis", 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
|
// add current link, if not in list
|
||||||
@@ -408,12 +425,15 @@ void TaskPadParameters::fillDirectionCombo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TaskPadParameters::addAxisToCombo(App::DocumentObject* linkObj,
|
void TaskPadParameters::addAxisToCombo(App::DocumentObject* linkObj,
|
||||||
std::string linkSubname, QString itemText)
|
std::string linkSubname, QString itemText, bool hasSketch)
|
||||||
{
|
{
|
||||||
this->ui->directionCB->addItem(itemText);
|
this->ui->directionCB->addItem(itemText);
|
||||||
this->axesInList.emplace_back(new App::PropertyLinkSub);
|
this->axesInList.emplace_back(new App::PropertyLinkSub);
|
||||||
App::PropertyLinkSub& lnk = *(axesInList.back());
|
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 TaskPadParameters::onDirectionCBChanged(int num)
|
void TaskPadParameters::onDirectionCBChanged(int num)
|
||||||
@@ -423,8 +443,17 @@ void TaskPadParameters::onDirectionCBChanged(int num)
|
|||||||
if (axesInList.empty())
|
if (axesInList.empty())
|
||||||
return;
|
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]);
|
App::PropertyLinkSub& lnk = *(axesInList[num]);
|
||||||
if (lnk.getValue() == 0) {
|
if (num == 1) {
|
||||||
// enter reference selection mode
|
// enter reference selection mode
|
||||||
this->blockConnection(false);
|
this->blockConnection(false);
|
||||||
// to distinguish that this is the direction selection
|
// to distinguish that this is the direction selection
|
||||||
@@ -432,16 +461,17 @@ void TaskPadParameters::onDirectionCBChanged(int num)
|
|||||||
TaskSketchBasedParameters::onSelectReference(true, true, false, true, true);
|
TaskSketchBasedParameters::onSelectReference(true, true, false, true, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else if (lnk.getValue() != 0) {
|
||||||
if (!pcPad->getDocument()->isIn(lnk.getValue())) {
|
if (!pcPad->getDocument()->isIn(lnk.getValue())) {
|
||||||
Base::Console().Error("Object was deleted\n");
|
Base::Console().Error("Object was deleted\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
propReferenceAxis->Paste(lnk);
|
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 {
|
try {
|
||||||
recomputeFeature();
|
recomputeFeature();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ public:
|
|||||||
virtual void apply() override;
|
virtual void apply() override;
|
||||||
|
|
||||||
void fillDirectionCombo();
|
void fillDirectionCombo();
|
||||||
void addAxisToCombo(App::DocumentObject* linkObj, std::string linkSubname, QString itemText);
|
void addAxisToCombo(App::DocumentObject* linkObj, std::string linkSubname, QString itemText,
|
||||||
|
bool hasSketch = true);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onLengthChanged(double);
|
void onLengthChanged(double);
|
||||||
|
|||||||
@@ -359,17 +359,34 @@ void TaskPocketParameters::fillDirectionCombo()
|
|||||||
blockUpdate = true;
|
blockUpdate = true;
|
||||||
|
|
||||||
if (axesInList.empty()) {
|
if (axesInList.empty()) {
|
||||||
|
bool hasFace = false;
|
||||||
ui->directionCB->clear();
|
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());
|
PartDesign::ProfileBased* pcFeat = static_cast<PartDesign::ProfileBased*>(vp->getObject());
|
||||||
Part::Part2DObject* pcSketch = dynamic_cast<Part::Part2DObject*>(pcFeat->Profile.getValue());
|
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)
|
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
|
// add the other entries
|
||||||
addAxisToCombo(0, std::string(), tr("Select reference..."));
|
addAxisToCombo(0, std::string(), tr("Select reference..."));
|
||||||
// we start with the sketch normal as proposal for the custom direction
|
// we start with the sketch normal as proposal for the custom direction
|
||||||
if (pcSketch)
|
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
|
// add current link, if not in list
|
||||||
@@ -411,12 +428,16 @@ void TaskPocketParameters::fillDirectionCombo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TaskPocketParameters::addAxisToCombo(App::DocumentObject* linkObj,
|
void TaskPocketParameters::addAxisToCombo(App::DocumentObject* linkObj,
|
||||||
std::string linkSubname, QString itemText)
|
std::string linkSubname, QString itemText, bool hasSketch)
|
||||||
{
|
{
|
||||||
this->ui->directionCB->addItem(itemText);
|
this->ui->directionCB->addItem(itemText);
|
||||||
this->axesInList.emplace_back(new App::PropertyLinkSub);
|
this->axesInList.emplace_back(new App::PropertyLinkSub);
|
||||||
App::PropertyLinkSub& lnk = *(axesInList.back());
|
App::PropertyLinkSub& lnk = *(axesInList.back());
|
||||||
lnk.setValue(linkObj, std::vector<std::string>(1, linkSubname));
|
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)
|
void TaskPocketParameters::onDirectionCBChanged(int num)
|
||||||
@@ -426,8 +447,17 @@ void TaskPocketParameters::onDirectionCBChanged(int num)
|
|||||||
if (axesInList.empty() || !pcPocket)
|
if (axesInList.empty() || !pcPocket)
|
||||||
return;
|
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]);
|
App::PropertyLinkSub& lnk = *(axesInList[num]);
|
||||||
if (lnk.getValue() == 0) {
|
if (num == 1) {
|
||||||
// enter reference selection mode
|
// enter reference selection mode
|
||||||
this->blockConnection(false);
|
this->blockConnection(false);
|
||||||
// to distinguish that this is the direction selection
|
// to distinguish that this is the direction selection
|
||||||
@@ -435,16 +465,17 @@ void TaskPocketParameters::onDirectionCBChanged(int num)
|
|||||||
TaskSketchBasedParameters::onSelectReference(true, true, false, true, true);
|
TaskSketchBasedParameters::onSelectReference(true, true, false, true, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else if (lnk.getValue() != 0) {
|
||||||
if (!pcPocket->getDocument()->isIn(lnk.getValue())) {
|
if (!pcPocket->getDocument()->isIn(lnk.getValue())) {
|
||||||
Base::Console().Error("Object was deleted\n");
|
Base::Console().Error("Object was deleted\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
propReferenceAxis->Paste(lnk);
|
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 {
|
try {
|
||||||
recomputeFeature();
|
recomputeFeature();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ public:
|
|||||||
virtual void apply() override;
|
virtual void apply() override;
|
||||||
|
|
||||||
void fillDirectionCombo();
|
void fillDirectionCombo();
|
||||||
void addAxisToCombo(App::DocumentObject* linkObj, std::string linkSubname, QString itemText);
|
void addAxisToCombo(App::DocumentObject* linkObj, std::string linkSubname, QString itemText,
|
||||||
|
bool hasSketch = true);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onLengthChanged(double);
|
void onLengthChanged(double);
|
||||||
|
|||||||
Reference in New Issue
Block a user