diff --git a/src/Gui/ViewProviderOrigin.cpp b/src/Gui/ViewProviderOrigin.cpp index 7c454bdd4..4878f9be6 100644 --- a/src/Gui/ViewProviderOrigin.cpp +++ b/src/Gui/ViewProviderOrigin.cpp @@ -125,6 +125,24 @@ bool ViewProviderOrigin::isTemporaryVisibilityMode() return tempVisMode; } +void ViewProviderOrigin::setTemporaryVisibilityAxis(bool onoff) +{ + for(App::DocumentObject* obj : static_cast(pcObject)->getObjectsOfType(App::Plane::getClassTypeId())) { + + Gui::ViewProvider* vp = tempVisDoc->getViewProvider(obj); + vp->setVisible(onoff); + } +} + +void ViewProviderOrigin::setTemporaryVisibilityPlanes(bool onoff) +{ + for(App::DocumentObject* obj : static_cast(pcObject)->getObjectsOfType(App::Line::getClassTypeId())) { + + Gui::ViewProvider* vp = tempVisDoc->getViewProvider(obj); + vp->setVisible(onoff); + } +} + // Python feature ----------------------------------------------------------------------- diff --git a/src/Gui/ViewProviderOrigin.h b/src/Gui/ViewProviderOrigin.h index 9f5948e01..bf9802d53 100644 --- a/src/Gui/ViewProviderOrigin.h +++ b/src/Gui/ViewProviderOrigin.h @@ -54,6 +54,8 @@ public: //temporary mode to override visibility of grouped objects void setTemporaryVisibilityMode(bool onoff, Gui::Document* doc = NULL); bool isTemporaryVisibilityMode(); + void setTemporaryVisibilityAxis(bool onoff); + void setTemporaryVisibilityPlanes(bool onoff); void setTemporaryVisibility(App::DocumentObject* obj, bool onoff); private: diff --git a/src/Mod/PartDesign/App/DatumLine.cpp b/src/Mod/PartDesign/App/DatumLine.cpp index 1134344fe..683b5ca2c 100644 --- a/src/Mod/PartDesign/App/DatumLine.cpp +++ b/src/Mod/PartDesign/App/DatumLine.cpp @@ -62,6 +62,8 @@ #include #include +#include +#include #include "DatumPoint.h" #include "DatumLine.h" #include "DatumPlane.h" @@ -207,7 +209,38 @@ void Line::onChanged(const App::Property *prop) s3 = new Geom_Plane(base, normal); } } - } else if (refs[i]->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { + } else if (refs[i]->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + App::Line* l = static_cast(refs[i]); + gp_Dir ldir; + if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[0]) == 0) + ldir = gp_Dir(1,0,0); + else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[1]) == 0) + ldir = gp_Dir(0,1,0); + else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[2]) == 0) + ldir = gp_Dir(0,0,1); + + if (s1.IsNull()) { + base = new Base::Vector3d (0,0,0); + direction = new Base::Vector3d (ldir.X(), ldir.Y(), ldir.Z()); + } else { + // Create plane through line normal to s1 + Handle_Geom_Plane pl = Handle_Geom_Plane::DownCast(s1); + if (pl.IsNull()) + return; // Non-planar first surface + gp_Dir normal = ldir.Crossed(pl->Axis().Direction()); + double offset1 = Offset.getValue(); + double offset2 = Offset2.getValue(); + gp_Pnt base = gp_Pnt(0,0,0); + if (s2.IsNull()) { + base.Translate(offset1 * normal); + s2 = new Geom_Plane(base, normal); + } else { + base.Translate(offset2 * normal); + s3 = new Geom_Plane(base, normal); + } + } + + }else if (refs[i]->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { PartDesign::Plane* p = static_cast(refs[i]); Base::Vector3d base = p->getBasePoint(); Base::Vector3d normal = p->getNormal(); @@ -226,11 +259,11 @@ void Line::onChanged(const App::Property *prop) // Note: We only handle the three base planes here gp_Pnt base(0,0,0); gp_Dir normal; - if (strcmp(p->getNameInDocument(), "BaseplaneXY") == 0) + if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[0]) == 0) normal = gp_Dir(0,0,1); - else if (strcmp(p->getNameInDocument(), "BaseplaneYZ") == 0) + else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[2]) == 0) normal = gp_Dir(1,0,0); - else if (strcmp(p->getNameInDocument(), "BaseplaneXZ") == 0) + else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[1]) == 0) normal = gp_Dir(0,1,0); double offset1 = Offset.getValue(); diff --git a/src/Mod/PartDesign/App/DatumPlane.cpp b/src/Mod/PartDesign/App/DatumPlane.cpp index 0ab7582b0..0efb487dc 100644 --- a/src/Mod/PartDesign/App/DatumPlane.cpp +++ b/src/Mod/PartDesign/App/DatumPlane.cpp @@ -60,6 +60,8 @@ #include #include +#include +#include #include "DatumPoint.h" #include "DatumLine.h" #include "DatumPlane.h" @@ -220,6 +222,17 @@ void Plane::onChanged(const App::Property *prop) Base::Vector3d base = l->getBasePoint(); Base::Vector3d dir = l->getDirection(); line = new gp_Lin(gp_Pnt(base.x, base.y, base.z), gp_Dir(dir.x, dir.y, dir.z)); + } else if (refs[i]->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + App::Line* l = static_cast(refs[i]); + Base::Vector3d base = Base::Vector3d(0,0,0); + gp_Dir dir; + if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[0]) == 0) + dir = gp_Dir(1,0,0); + else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[1]) == 0) + dir = gp_Dir(0,1,0); + else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[2]) == 0) + dir = gp_Dir(0,0,1); + line = new gp_Lin(gp_Pnt(base.x, base.y, base.z), gp_Dir(dir.X(), dir.Y(), dir.Z())); } else if (refs[i]->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { PartDesign::Plane* p = static_cast(refs[i]); p1 = new Base::Vector3d(p->getBasePoint()); @@ -229,11 +242,11 @@ void Plane::onChanged(const App::Property *prop) // Note: We only handle the three base planes here p1 = new Base::Vector3d(0,0,0); normal = new Base::Vector3d; - if (strcmp(p->getNameInDocument(), "BaseplaneXY") == 0) + if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[0]) == 0) *normal = Base::Vector3d(0,0,1); - else if (strcmp(p->getNameInDocument(), "BaseplaneXZ") == 0) + else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[2]) == 0) *normal = Base::Vector3d(0,1,0); - else if (strcmp(p->getNameInDocument(), "BaseplaneYZ") == 0) + else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[1]) == 0) *normal = Base::Vector3d(1,0,0); } else if (refs[i]->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { Part::Feature* feature = static_cast(refs[i]); diff --git a/src/Mod/PartDesign/App/DatumPoint.cpp b/src/Mod/PartDesign/App/DatumPoint.cpp index 1a3d9b667..d4bb30267 100644 --- a/src/Mod/PartDesign/App/DatumPoint.cpp +++ b/src/Mod/PartDesign/App/DatumPoint.cpp @@ -60,6 +60,8 @@ #include #include +#include +#include #include "DatumPoint.h" #include "DatumLine.h" #include "DatumPlane.h" @@ -197,16 +199,34 @@ void Point::onChanged(const App::Property* prop) s2 = new Geom_Plane(gp_Pnt(base.x, base.y, base.z), gp_Dir(normal.x, normal.y, normal.z)); else s3 = new Geom_Plane(gp_Pnt(base.x, base.y, base.z), gp_Dir(normal.x, normal.y, normal.z)); + + } else if (refs[i]->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + App::Line* l = static_cast(refs[i]); + // Note: We only handle the three base planes here + gp_Pnt base(0,0,0); + gp_Dir normal; + if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[0]) == 0) + normal = gp_Dir(1,0,0); + else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[1]) == 0) + normal = gp_Dir(0,1,0); + else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[2]) == 0) + normal = gp_Dir(0,0,1); + + if (s1.IsNull()) + c1 = new Geom_Line(base, normal); + else if (s2.IsNull()) + c2 = new Geom_Line(base, normal); + } else if (refs[i]->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { App::Plane* p = static_cast(refs[i]); // Note: We only handle the three base planes here gp_Pnt base(0,0,0); gp_Dir normal; - if (strcmp(p->getNameInDocument(), "BaseplaneXY") == 0) + if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[0]) == 0) normal = gp_Dir(0,0,1); - else if (strcmp(p->getNameInDocument(), "BaseplaneYZ") == 0) + else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[2]) == 0) normal = gp_Dir(1,0,0); - else if (strcmp(p->getNameInDocument(), "BaseplaneXZ") == 0) + else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[1]) == 0) normal = gp_Dir(0,1,0); if (s1.IsNull()) @@ -391,7 +411,7 @@ const QString getRefType(const App::DocumentObject* obj, const std::string& subn if ((type == App::Plane::getClassTypeId()) || (type == PartDesign::Plane::getClassTypeId())) return PLANE; - else if (type == PartDesign::Line::getClassTypeId()) + else if ((type == App::Line::getClassTypeId()) || (type == PartDesign::Line::getClassTypeId())) return LINE; else if (type == PartDesign::Point::getClassTypeId()) return POINT; diff --git a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp index 34029cac7..2092b3def 100644 --- a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp +++ b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -61,6 +62,9 @@ bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, c 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; + + if (edge && (pObj->getTypeId().isDerivedFrom(App::Line::getClassTypeId()))) + return true; if (pObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { // Allow selecting Part::Datum features from the active Body diff --git a/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp b/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp index 538e9625e..09f0ad421 100644 --- a/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -62,8 +64,9 @@ const QString makeRefString(const App::DocumentObject* obj, const std::string& s return QObject::tr("No reference selected"); if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) || + obj->getTypeId().isDerivedFrom(App::Line::getClassTypeId()) || obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) - // App::Plane or Datum feature + // App::Plane, Liine or Datum feature return QString::fromAscii(obj->getNameInDocument()); if ((sub.size() > 4) && (sub.substr(0,4) == "Face")) { @@ -183,6 +186,15 @@ TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *p ui->buttonRef3->blockSignals(false); ui->lineRef3->blockSignals(false); updateUI(); + + //temporary show all coordinate systems for selection + for(auto origin : Gui::Application::Instance->activeDocument()->getViewProvidersOfType(Gui::ViewProviderOrigin::getClassTypeId())) { + + static_cast(origin)->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument()); + static_cast(origin)->setTemporaryVisibilityAxis(true); + static_cast(origin)->setTemporaryVisibilityPlanes(true); + } + } const QString makeRefText(std::set hint) @@ -363,6 +375,7 @@ void TaskDatumParameters::onSelectionChanged(const Gui::SelectionChanges& msg) // Remove subname for planes and datum features if (selObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) || + selObj->getTypeId().isDerivedFrom(App::Line::getClassTypeId()) || selObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) subname = ""; @@ -512,8 +525,11 @@ void TaskDatumParameters::onRefName(const QString& text, const int idx) if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { // everything is OK (we assume a Part can only have exactly 3 App::Plane objects located at the base of the feature tree) subElement = ""; + } else if (obj->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + // everything is OK (we assume a Part can only have exactly 3 App::Line objects located at the base of the feature tree) + subElement = ""; } else if (obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { - if (!activeBody->hasFeature(obj)) + if (!activeBody->hasFeature(obj)) return; subElement = ""; } else { @@ -625,6 +641,12 @@ QString TaskDatumParameters::getReference(const int idx) const TaskDatumParameters::~TaskDatumParameters() { + //end temporary view mode of all coordinate systems + for(auto origin : Gui::Application::Instance->activeDocument()->getViewProvidersOfType(Gui::ViewProviderOrigin::getClassTypeId())) { + + static_cast(origin)->setTemporaryVisibilityMode(false); + } + delete ui; }