Added Reversed button to Pocket UI if the sketch plane is a datum plane

This commit is contained in:
jrheinlaender 2013-05-11 20:17:49 +04:30 committed by Stefan Tröger
parent 6915d8b734
commit 0bcdb0511f
8 changed files with 40 additions and 6 deletions

View File

@ -34,8 +34,10 @@
#include <Base/Exception.h>
#include "App/Document.h"
#include "App/Plane.h"
#include "Body.h"
#include "Feature.h"
#include "Mod/Part/App/DatumFeature.h"
#include <Base/Console.h>
@ -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());
}
}

View File

@ -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

View File

@ -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") {

View File

@ -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<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()

View File

@ -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<TopoDS_Wire>&) const;
TopoDS_Shape makeFace(std::list<TopoDS_Wire>&) const; // for internal use only
TopoDS_Shape makeFace(std::list<TopoDS_Wire>&) 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;

View File

@ -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());

View File

@ -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();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>241</width>
<height>192</height>
<height>188</height>
</rect>
</property>
<property name="sizePolicy">