diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp
index 01247100b..40014cfae 100644
--- a/src/Mod/PartDesign/App/Feature.cpp
+++ b/src/Mod/PartDesign/App/Feature.cpp
@@ -34,8 +34,10 @@
#include
#include "App/Document.h"
+#include "App/Plane.h"
#include "Body.h"
#include "Feature.h"
+#include "Mod/Part/App/DatumFeature.h"
#include
@@ -106,4 +108,10 @@ const TopoDS_Shape& Feature::getBaseShape() const {
return result;
}
+bool Feature::isDatum(const App::DocumentObject* feature)
+{
+ return feature->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) ||
+ feature->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId());
+}
+
}
diff --git a/src/Mod/PartDesign/App/Feature.h b/src/Mod/PartDesign/App/Feature.h
index 3fe92e761..050a73cea 100644
--- a/src/Mod/PartDesign/App/Feature.h
+++ b/src/Mod/PartDesign/App/Feature.h
@@ -64,6 +64,8 @@ protected:
/// Grab any point from the given face
static const gp_Pnt getPointFromFace(const TopoDS_Face& f);
+ /// Check whether the given feature is a datum feature
+ static bool isDatum(const App::DocumentObject* feature);
};
} //namespace PartDesign
diff --git a/src/Mod/PartDesign/App/FeaturePocket.cpp b/src/Mod/PartDesign/App/FeaturePocket.cpp
index 35b739117..17374f5e8 100644
--- a/src/Mod/PartDesign/App/FeaturePocket.cpp
+++ b/src/Mod/PartDesign/App/FeaturePocket.cpp
@@ -145,6 +145,9 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
TopoDS_Face supportface = getSupportFace();
supportface.Move(invObjLoc);
+ if (Reversed.getValue())
+ dir.Reverse();
+
// Find a valid face to extrude up to
TopoDS_Face upToFace;
if (method == "UpToFace") {
diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp
index 3a46b1994..2114d447d 100644
--- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp
+++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp
@@ -930,6 +930,14 @@ bool SketchBased::isParallelPlane(const TopoDS_Shape& s1, const TopoDS_Shape& s2
return false;
}
+bool SketchBased::isSupportDatum() const
+{
+ Part::Feature* SupportObject = getSupport();
+ if (SupportObject == NULL)
+ throw Base::Exception("No support in Sketch!");
+ return isDatum(SupportObject);
+}
+
TopoDS_Shape SketchBased::refineShapeIfActive(const TopoDS_Shape& oldShape) const
{
Base::Reference hGrp = App::GetApplication().GetUserParameter()
diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.h b/src/Mod/PartDesign/App/FeatureSketchBased.h
index 7284df649..7bce5fb2a 100644
--- a/src/Mod/PartDesign/App/FeatureSketchBased.h
+++ b/src/Mod/PartDesign/App/FeatureSketchBased.h
@@ -73,15 +73,17 @@ public:
Part::Feature* getSupport() const;
/// Returns the sketch support shape (if any)
const TopoDS_Shape& getSupportShape() const;
+ /// Check whether the sketch support is a datum plane
+ bool isSupportDatum() const;
/// retrieves the number of axes in the linked sketch (defined as construction lines)
- int getSketchAxisCount(void) const;
+ int getSketchAxisCount(void) const;
protected:
void onChanged(const App::Property* prop);
TopoDS_Face validateFace(const TopoDS_Face&) const;
TopoDS_Shape makeFace(const std::vector&) const;
- TopoDS_Shape makeFace(std::list&) const; // for internal use only
+ TopoDS_Shape makeFace(std::list&) const; // for internal use only
bool isInside(const TopoDS_Wire&, const TopoDS_Wire&) const;
bool isParallelPlane(const TopoDS_Shape&, const TopoDS_Shape&) const;
bool isEqualGeometry(const TopoDS_Shape&, const TopoDS_Shape&) const;
diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp
index 4e9bce7f8..20c1967d6 100644
--- a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp
+++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp
@@ -120,7 +120,6 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge
ui->changeMode->insertItem(2, tr("To first"));
ui->changeMode->insertItem(3, tr("Up to face"));
ui->changeMode->setCurrentIndex(index);
- ui->checkBoxMidplane->setChecked(midplane);
// Bind input fields to properties
ui->pocketLength->bind(pcPocket->Length);
@@ -131,6 +130,10 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge
ui->buttonFace->blockSignals(false);
ui->lineFaceName->blockSignals(false);
ui->changeMode->blockSignals(false);
+
+ // Activate the Reverse option only if the support is a datum plane
+ ui->checkBoxReversed->setVisible(pcPocket->isSupportDatum());
+
updateUI(index);
//// check if the sketch has support
@@ -152,6 +155,7 @@ void TaskPocketParameters::updateUI(int index)
ui->pocketLength->selectAll();
QMetaObject::invokeMethod(ui->pocketLength, "setFocus", Qt::QueuedConnection);
ui->checkBoxMidplane->setEnabled(true);
+ // Reverse only makes sense if Midplane is not true
ui->checkBoxReversed->setEnabled(!ui->checkBoxMidplane->isChecked()); // Will flip direction of dimension
ui->buttonFace->setEnabled(false);
ui->lineFaceName->setEnabled(false);
@@ -167,8 +171,8 @@ void TaskPocketParameters::updateUI(int index)
ui->pocketLength->setEnabled(false);
ui->checkBoxMidplane->setEnabled(false); // Can't have a midplane to a single face
ui->checkBoxReversed->setEnabled(false); // Will change the direction it seeks for its first face?
- // Doesnt work so is currently disabled. Fix probably lies
- // somwhere in IF block on line 125 of FeaturePocket.cpp
+ // Doesnt work so is currently disabled. Fix probably lies
+ // somwhere in IF block on line 125 of FeaturePocket.cpp
ui->buttonFace->setEnabled(false);
ui->lineFaceName->setEnabled(false);
onButtonFace(false);
@@ -366,6 +370,11 @@ double TaskPocketParameters::getLength(void) const
return ui->pocketLength->value().getValue();
}
+bool TaskPocketParameters::getReversed(void) const
+{
+ return ui->checkBoxReversed->isChecked();
+}
+
int TaskPocketParameters::getMode(void) const
{
return ui->changeMode->currentIndex();
@@ -434,6 +443,7 @@ void TaskPocketParameters::apply()
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s", name.c_str(), buf.toStdString().c_str());
} else
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", name.c_str());
+ Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i",name.c_str(),getReversed()?1:0);
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (!PocketView->getObject()->isValid())
throw Base::Exception(PocketView->getObject()->getStatusString());
diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.h b/src/Mod/PartDesign/Gui/TaskPocketParameters.h
index ad5ef90de..43e4a3126 100644
--- a/src/Mod/PartDesign/Gui/TaskPocketParameters.h
+++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.h
@@ -52,6 +52,7 @@ public:
TaskPocketParameters(ViewProviderPocket *PocketView,QWidget *parent = 0);
~TaskPocketParameters();
+ bool getReversed(void) const;
QByteArray getFaceName(void) const;
const bool updateView() const;
void apply();
diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.ui b/src/Mod/PartDesign/Gui/TaskPocketParameters.ui
index 43a78e376..5a1f41c07 100644
--- a/src/Mod/PartDesign/Gui/TaskPocketParameters.ui
+++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.ui
@@ -7,7 +7,7 @@
0
0
241
- 192
+ 188