diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index 40014cfae..fe5c0ce07 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -29,6 +29,8 @@ # include # include # include +# include +# include #endif @@ -114,4 +116,20 @@ bool Feature::isDatum(const App::DocumentObject* feature) feature->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()); } +TopoDS_Shape Feature::makeShapeFromPlane(const App::DocumentObject* obj) +{ + const App::Plane* plane = static_cast(obj); + if (plane == NULL) + throw Base::Exception("Feature: Null object"); + + Base::Rotation rot = plane->Placement.getValue().getRotation(); + Base::Vector3d normal(0,0,1); + rot.multVec(normal, normal); + BRepBuilderAPI_MakeFace builder(gp_Pln(gp_Pnt(0,0,0), gp_Dir(normal.x,normal.y,normal.z))); + if (!builder.IsDone()) + throw Base::Exception("Feature: Could not create shape from base plane"); + + return builder.Shape(); +} + } diff --git a/src/Mod/PartDesign/App/Feature.h b/src/Mod/PartDesign/App/Feature.h index ab5309c1d..daa024c45 100644 --- a/src/Mod/PartDesign/App/Feature.h +++ b/src/Mod/PartDesign/App/Feature.h @@ -66,6 +66,8 @@ protected: /// Grab any point from the given face static const gp_Pnt getPointFromFace(const TopoDS_Face& f); + /// Make a shape from a base plane (convenience method) + static TopoDS_Shape makeShapeFromPlane(const App::DocumentObject* obj); }; } //namespace PartDesign diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index ca217b1ae..e3689dc92 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -457,18 +457,9 @@ void SketchBased::getUpToFaceFromLinkSub(TopoDS_Face& upToFace, throw Base::Exception("SketchBased: Up to face: No face selected"); if (ref->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { - App::Plane* plane = static_cast(ref); - Base::Rotation rot = plane->Placement.getValue().getRotation(); - Base::Vector3d normal(0,0,1); - rot.multVec(normal, normal); - BRepBuilderAPI_MakeFace builder(gp_Pln(gp_Pnt(0,0,0), gp_Dir(normal.x,normal.y,normal.z))); - if (!builder.IsDone()) - throw Base::Exception("SketchBased: Up to face: Could not create shape from base plane"); - upToFace = TopoDS::Face(builder.Shape()); + upToFace = TopoDS::Face(makeShapeFromPlane(ref)); return; - } - - if (ref->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { + } else if (ref->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { Part::Datum* datum = static_cast(ref); upToFace = TopoDS::Face(datum->getShape()); return; diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index 679ebaa11..2ac20f93b 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -251,15 +251,25 @@ App::DocumentObjectExecReturn *Transformed::execute(void) return new App::DocumentObjectExecReturn("Transformation failed", (*o)); // Check for intersection with support - if (!Part::checkIntersection(support, mkTrf.Shape(), false, true)) { + try { + if (!Part::checkIntersection(support, mkTrf.Shape(), false, true)) { #ifdef FC_DEBUG // do not write this in release mode because a message appears already in the task view - Base::Console().Warning("Transformed shape does not intersect support %s: Removed\n", (*o)->getNameInDocument()); + Base::Console().Warning("Transformed shape does not intersect support %s: Removed\n", (*o)->getNameInDocument()); #endif - nointersect_trsfms.insert(t); - } else { - v_transformations.push_back(t); - v_transformedShapes.push_back(mkTrf.Shape()); - // Note: Transformations that do not intersect the support are ignored in the overlap tests + nointersect_trsfms.insert(t); + } else { + v_transformations.push_back(t); + v_transformedShapes.push_back(mkTrf.Shape()); + // Note: Transformations that do not intersect the support are ignored in the overlap tests + } + } catch (Standard_Failure) { + // Note: Ignoring this failure is probably pointless because if the intersection check fails, the later + // fuse operation of the transformation result will also fail + Handle_Standard_Failure e = Standard_Failure::Caught(); + std::string msg("Transformation: Intersection check failed"); + if (e->GetMessageString() != NULL) + msg += std::string(": '") + e->GetMessageString() + "'"; + return new App::DocumentObjectExecReturn(msg.c_str()); } } diff --git a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp index 3b6450afc..eb33af112 100644 --- a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp +++ b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp @@ -47,6 +47,10 @@ using namespace Gui; bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName) { + // Don't allow selection in other document + if ((support != NULL) && (pDoc != support->getDocument())) + return false; + if (plane && (pObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()))) // Note: It is assumed that a Part has exactly 3 App::Plane objects at the root of the feature tree return true; @@ -68,10 +72,7 @@ bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, c // Handle selection of geometry elements if (support == NULL) - return false; - // Don't allow selection in other document - if (pDoc != support->getDocument()) - return false; + return false; if (!sSubName || sSubName[0] == '\0') return false; if (pObj != support) diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp index 61fcfb838..2164d7ba4 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp @@ -334,7 +334,7 @@ int TaskPadParameters::getMode(void) const QByteArray TaskPadParameters::getFaceName(void) const { - if ((getMode() >= 1) || (getMode() <= 3)) + if ((getMode() >= 1) && (getMode() <= 3)) return getFaceReference(ui->lineFaceName->text(), ui->lineFaceName->property("FaceName").toString()).toLatin1(); else return ""; diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp index 8622d1be6..1eac9291f 100644 --- a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp @@ -314,7 +314,7 @@ int TaskPocketParameters::getMode(void) const QByteArray TaskPocketParameters::getFaceName(void) const { - if ((getMode() >= 1) || (getMode() <= 3)) + if ((getMode() >= 1) && (getMode() <= 3)) return getFaceReference(ui->lineFaceName->text(), ui->lineFaceName->property("FaceName").toString()).toLatin1(); else return ""; diff --git a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp index 10fb21399..dcf9ddc85 100644 --- a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp @@ -91,8 +91,7 @@ const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChan QString refStr; // Remove subname for planes and datum features - if (selObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) || - selObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + if (PartDesign::Feature::isDatum(selObj)) { subname = ""; refStr = QString::fromAscii(selObj->getNameInDocument()); } else { diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp index af2e8d2f1..398bcc032 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp @@ -32,6 +32,8 @@ # include # include # include +# include +# include # include # include # include @@ -90,15 +92,27 @@ void ViewProviderDatum::attach(App::DocumentObject *obj) else if (o->getTypeId() == PartDesign::Point::getClassTypeId()) datumType = QObject::tr("Point"); - SoSeparator* sep = new SoSeparator(); - SoPickStyle* ps = new SoPickStyle(); - ps->style = SoPickStyle::SHAPE; SoShapeHints* hints = new SoShapeHints(); hints->shapeType.setValue(SoShapeHints::UNKNOWN_SHAPE_TYPE); hints->vertexOrdering.setValue(SoShapeHints::COUNTERCLOCKWISE); + SoMaterialBinding* bind = new SoMaterialBinding(); + SoTransparencyType* ttype = new SoTransparencyType(); + ttype->value.setValue(SoGLRenderAction::BLEND); + SoDrawStyle* fstyle = new SoDrawStyle(); + fstyle->style = SoDrawStyle::FILLED; + SoNormalBinding* normb = new SoNormalBinding(); + normb->value = SoNormalBinding::PER_VERTEX_INDEXED; SoBaseColor* color = new SoBaseColor(); color->rgb.setValue(0.9, 0.9, 0.3); + SoSeparator* sep = new SoSeparator(); + SoPickStyle* ps = new SoPickStyle(); + ps->style = SoPickStyle::SHAPE; + sep->addChild(hints); + sep->addChild(bind); + sep->addChild(ttype); + sep->addChild(fstyle); + sep->addChild(normb); sep->addChild(color); sep->addChild(ps); sep->addChild(pShapeSep);