diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp index 20e33f3534a0..36ac741e83ee 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp @@ -131,10 +131,19 @@ bool DrawProjGroupItem::showLock(void) const return result; } - App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void) { // Base::Console().Message("DPGI::execute(%s)\n",Label.getValue()); + + bool haveX = checkXDirection(); + if (!haveX) { + //block touch/onChanged stuff + Base::Vector3d newX = getXDirection(); + XDirection.setValue(newX); + XDirection.purgeTouched(); //don't trigger updates! + //unblock + } + if (DrawUtil::checkParallel(Direction.getValue(), getXDirection())) { return new App::DocumentObjectExecReturn("DPGI: Direction and XDirection are parallel"); diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index 9d52a336b13c..a7a8b044a7e5 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -216,6 +216,15 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void) return DrawView::execute(); } + bool haveX = checkXDirection(); + if (!haveX) { + //block touch/onChanged stuff + Base::Vector3d newX = getXDirection(); + XDirection.setValue(newX); + XDirection.purgeTouched(); //don't trigger updates! + //unblock + } + Base::Vector3d anchor = AnchorPoint.getValue(); //this is a 2D point (in unrotated coords) Base::Vector3d dirDetail = dvp->Direction.getValue(); diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index e4bc1adbdf22..54bcf890138f 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -241,9 +241,16 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void) return App::DocumentObject::StdReturn; } - checkXDirection(); + bool haveX = checkXDirection(); + if (!haveX) { + //block touch/onChanged stuff + Base::Vector3d newX = getXDirection(); + XDirection.setValue(newX); + XDirection.purgeTouched(); //don't trigger updates! + //unblock + } - m_saveShape = shape; +// m_saveShape = shape; geometryObject = makeGeometryForShape(shape); #if MOD_TECHDRAW_HANDLE_FACES @@ -321,6 +328,7 @@ GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape shape) //center shape on origin TopoDS_Shape centeredShape = TechDraw::moveShape(shape, centroid * -1.0); + m_saveShape = centeredShape; TopoDS_Shape scaledShape = TechDraw::scaleShape(centeredShape, getScale()); @@ -919,7 +927,7 @@ bool DrawViewPart::checkXDirection(void) const Base::Vector3d origin(0.0,0.0,0.0); Base::Vector3d xDir = getLegacyX(origin, dir); - Base::Console().Warning("DVP - %s - XDirection property not set. Try %s\n", + Base::Console().Warning("DVP - %s - XDirection property not set. Trying %s\n", getNameInDocument(), DrawUtil::formatVector(xDir).c_str()); return false; diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 1d85411c0b90..7d4236cd0f4c 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -242,7 +242,15 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) return new App::DocumentObjectExecReturn("BaseView Source object is Null"); } - checkXDirection(); +// checkXDirection(); + bool haveX = checkXDirection(); + if (!haveX) { + //block touch/onChanged stuff + Base::Vector3d newX = getXDirection(); + XDirection.setValue(newX); + XDirection.purgeTouched(); //don't trigger updates! + //unblock + } //is SectionOrigin valid? Bnd_Box centerBox; @@ -305,7 +313,6 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) Base::Vector3d origin(0.0, 0.0, 0.0); viewAxis = getProjectionCS(origin); - if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) { scaledShape = TechDraw::rotateShape(scaledShape, viewAxis, @@ -569,6 +576,35 @@ bool DrawViewSection::isReallyInBox (const gp_Pnt p, const Bnd_Box& bb) const return !bb.IsOut(p); } +Base::Vector3d DrawViewSection::getXDirection(void) const +{ +// Base::Console().Message("DVS::getXDirection() - %s\n", Label.getValue()); + Base::Vector3d result(1.0, 0.0, 0.0); //default X + App::Property* prop = getPropertyByName("XDirection"); + if (prop != nullptr) { //have an XDirection property + Base::Vector3d propVal = XDirection.getValue(); + if (DrawUtil::fpCompare(propVal.Length(), 0.0)) { //but it has no value + std::string sectName = SectionDirection.getValueAsString(); + gp_Ax2 cs = getCSFromBase(sectName); + gp_Dir gXDir = cs.XDirection(); + result = Base::Vector3d(gXDir.X(), + gXDir.Y(), + gXDir.Z()); + } else { + result = propVal; //normal case. XDirection is set. + } + } else { //no Property. can this happen? + std::string sectName = SectionDirection.getValueAsString(); + gp_Ax2 cs = getCSFromBase(sectName); + gp_Dir gXDir = cs.XDirection(); + result = Base::Vector3d(gXDir.X(), + gXDir.Y(), + gXDir.Z()); + + } + return result; +} + void DrawViewSection::setCSFromBase(const std::string sectionName) { // Base::Console().Message("DVS::setCSFromBase(%s)\n", sectionName.c_str()); @@ -586,7 +622,7 @@ void DrawViewSection::setCSFromBase(const std::string sectionName) XDirection.setValue(vXDir); } -gp_Ax2 DrawViewSection::getCSFromBase(const std::string sectionName) +gp_Ax2 DrawViewSection::getCSFromBase(const std::string sectionName) const { // Base::Console().Message("DVS::getCSFromBase(%s)\n", sectionName.c_str()); Base::Vector3d sectionNormal; @@ -663,7 +699,6 @@ gp_Ax2 DrawViewSection::getSectionCS(void) const catch (...) { Base::Console().Warning("DVS::getSectionCS - %s - failed to create section CS\n", getNameInDocument()); } - return sectionCS; } diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index a1b02c5987e8..298814193d04 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -91,12 +91,13 @@ class TechDrawExport DrawViewSection : public DrawViewPart std::vector getFaceGeometry(); void setCSFromBase(const std::string sectionName); - gp_Ax2 getCSFromBase(const std::string sectionName); + gp_Ax2 getCSFromBase(const std::string sectionName) const; gp_Ax2 rotateCSArbitrary(gp_Ax2 oldCS, Base::Vector3d axis, double degAngle) const; gp_Ax2 getSectionCS() const; + virtual Base::Vector3d getXDirection(void) const override; //don't use XDirection.getValue() TechDraw::DrawViewPart* getBaseDVP() const; TechDraw::DrawProjGroupItem* getBaseDPGI() const;