diff --git a/src/Mod/TechDraw/App/DrawComplexSection.cpp b/src/Mod/TechDraw/App/DrawComplexSection.cpp index ebef5f651f..e3a866fe97 100644 --- a/src/Mod/TechDraw/App/DrawComplexSection.cpp +++ b/src/Mod/TechDraw/App/DrawComplexSection.cpp @@ -80,6 +80,7 @@ #include #include #include +#include #include #include #include @@ -219,7 +220,6 @@ TopoDS_Shape DrawComplexSection::makeCuttingTool(double dMax) return TopoDS_Shape(); } TopoDS_Wire profileWire = makeProfileWire(toolObj); - m_profileWire = profileWire; BRepBuilderAPI_Copy BuilderCopy(profileWire); m_profileWire = TopoDS::Wire(BuilderCopy.Shape()); if (debugSection()) { @@ -306,7 +306,14 @@ TopoDS_Shape DrawComplexSection::prepareShape(const TopoDS_Shape &cutShape, doub } //"Aligned" projection (Aligned Section) - TopoDS_Shape alignedResult = makeAlignedPieces(cutShape, m_toolFaceShape, shapeSize); + TopoDS_Shape alignedResult; + try { + alignedResult = makeAlignedPieces(cutShape, m_toolFaceShape, shapeSize); + } + catch (Base::RuntimeError& e) { + Base::Console().Error("Complex Section - %s\n", e.what()); + return TopoDS_Shape(); + } if (alignedResult.IsNull()) { return TopoDS_Shape(); @@ -334,35 +341,29 @@ TopoDS_Shape DrawComplexSection::makeAlignedPieces(const TopoDS_Shape &rawShape, gp_Ax3 stdCS; //OXYZ gp_Vec gProjectionUnit = gp_Vec(getSectionCS().Direction()); - //get a vector that describes the profile's orientation in paper space. - gp_Vec gProfileVec = projectProfileWire(m_profileWire, gp_Ax3(getSectionCS())); - if (fabs(gProfileVec.Dot(getProjectionCS().Direction()) == 1.0)) { - Base::Console().Error( - "DCS::makeAlignedPieces - %s - profile is parallel to SectionNormal\n", - getNameInDocument()); - throw Base::RuntimeError("Profile orientation error"); + //get a vector that describes the profile's orientation + gp_Vec gProfileVec = makeProfileVector(m_profileWire); + //now we want to know what the profileVector looks like on the page (only X,Y coords) + gProfileVec = projectVector(gProfileVec).Normalized(); + + if (!canBuild(getSectionCS(), CuttingToolWireObject.getValue())) { + throw Base::RuntimeError("Profile is parallel to Section Normal"); } - //convert the profileVector with OXYZ. - gp_Trsf xProfileOXYZ; - gp_Ax3 OXYZ; - xProfileOXYZ.SetTransformation(OXYZ, gp_Ax3(getSectionCS())); - gp_Vec profileVecOXYZ = gProfileVec.Transformed(xProfileOXYZ); - bool isVertical = true; - if (fabs(profileVecOXYZ.Dot(gp::OY().Direction().XYZ())) != 1.0) { + if (fabs(gProfileVec.Dot(gp::OY().Direction().XYZ())) != 1.0) { //profile is not parallel with stdY (paper space Up). //this test is not good enough for "vertical-ish" diagonal profiles isVertical = false; } double leftToRight = 1.0;//profile vector points to right, so we move to right - if (profileVecOXYZ.Dot(gp_Vec(gp::OX().Direction().XYZ())) < 0.0) { + if (gProfileVec.Dot(gp_Vec(gp::OX().Direction().XYZ())) < 0.0) { //profileVec does not point towards stdX (right in paper space) leftToRight = -1.0; } double topToBottom = 1.0;//profile vector points to top, so we move to top - if (profileVecOXYZ.Dot(gp_Vec(gp::OY().Direction().XYZ())) < 0.0) { + if (gProfileVec.Dot(gp_Vec(gp::OY().Direction().XYZ())) < 0.0) { //profileVec does not point towards stdY (up in paper space) topToBottom = -1.0; } @@ -392,6 +393,7 @@ TopoDS_Shape DrawComplexSection::makeAlignedPieces(const TopoDS_Shape &rawShape, if (intersect.IsNull()) { continue; } + double faceAngle = gp_Vec(getSectionCS().Direction().Reversed()).AngleWithRef(segmentNormal, rotateAxis); @@ -604,7 +606,7 @@ TopoDS_Compound DrawComplexSection::alignedToolIntersections(const TopoDS_Shape TopoDS_Compound DrawComplexSection::alignSectionFaces(TopoDS_Shape faceIntersections) { - // Base::Console().Message("DCS::alignSectionFaces()\n"); +// Base::Console().Message("DCS::alignSectionFaces() - faceIntersections.null: %d\n", faceIntersections.IsNull()); if (ProjectionStrategy.getValue() == 0) { //Offset. Use regular section behaviour return DrawViewSection::alignSectionFaces(faceIntersections); @@ -640,40 +642,17 @@ TopoDS_Wire DrawComplexSection::makeProfileWire(App::DocumentObject *toolObj) return profileWire; } -//methods related to section line - -//project the profile onto the paper and convert to the working CS -gp_Dir DrawComplexSection::projectProfileWire(TopoDS_Wire profileWire, gp_Ax3 paperCS) +gp_Vec DrawComplexSection::makeProfileVector(TopoDS_Wire profileWire) { - // Base::Console().Message("DCS::projectProfileWire()\n"); - gp_Pln plane(paperCS); - TopoDS_Face paper = BRepBuilderAPI_MakeFace(plane); - BRepAlgo_NormalProjection projector(paper); - projector.Add(profileWire); - projector.Build(); - TopoDS_Shape projectedShape = projector.Projection(); - - TopoDS_Edge projectedSegment; - //we only need 1 projected edge to determine direction - TopExp_Explorer expEdges(projectedShape, TopAbs_EDGE); - for (; expEdges.More(); expEdges.Next()) { - projectedSegment = TopoDS::Edge(expEdges.Current()); - break; - } - if (debugSection()) { - BRepTools::Write(projectedSegment, "DCSprojectedSegment.brep");//debug - } - if (projectedSegment.IsNull()) { - Base::Console().Warning("DCS::projectProfileWire - projection of profile failed\n"); - return gp_Dir(1.0, 0.0, 0.0); - } - gp_Pnt gpProfileFirst = BRep_Tool::Pnt(TopExp::FirstVertex(projectedSegment)); - gp_Pnt gpProfileLast = BRep_Tool::Pnt(TopExp::LastVertex(projectedSegment)); - gp_Vec gProfileVec(gpProfileFirst, gpProfileLast); - gProfileVec.Normalize(); - return gp_Dir(gProfileVec); + TopoDS_Vertex tvFirst, tvLast; + TopExp::Vertices(profileWire, tvFirst, tvLast); + gp_Pnt gpFirst = BRep_Tool::Pnt(tvFirst); + gp_Pnt gpLast = BRep_Tool::Pnt(tvLast); + return (gp_Vec(gpLast.XYZ()) - gp_Vec(gpFirst.XYZ())).Normalized(); } +//methods related to section line + //make drawable td geometry for section line BaseGeomPtrVector DrawComplexSection::makeSectionLineGeometry() { @@ -731,11 +710,7 @@ std::pair DrawComplexSection::sectionArrowDirs() return result; } - TopoDS_Vertex tvFirst, tvLast; - TopExp::Vertices(profileWire, tvFirst, tvLast); - gp_Pnt gpFirst = BRep_Tool::Pnt(tvFirst); - gp_Pnt gpLast = BRep_Tool::Pnt(tvLast); - gp_Vec gProfileVector = gp_Vec(gpLast.XYZ()) - gp_Vec(gpFirst.XYZ()); + gp_Vec gProfileVector = makeProfileVector(profileWire); gp_Vec gSectionNormal = gp_Vec(DU::togp_Dir(SectionNormal.getValue())); gp_Vec gExtrudeVector = (gSectionNormal.Crossed(gProfileVector)).Normalized(); Base::Vector3d vClosestBasis = DrawUtil::closestBasis(gp_Dir(gExtrudeVector), getSectionCS()); @@ -876,6 +851,24 @@ gp_Ax2 DrawComplexSection::getCSFromBase(const std::string sectionName) const return DrawViewSection::getCSFromBase(sectionName); } +//simple projection of a 3d vector onto the paper space +gp_Vec DrawComplexSection::projectVector(const gp_Vec& vec) const +{ + HLRAlgo_Projector projector( getProjectionCS() ); + gp_Pnt2d prjPnt; + projector.Project(gp_Pnt(vec.XYZ()), prjPnt); + return gp_Vec(prjPnt.X(), prjPnt.Y(), 0.0); +} + +//static +gp_Vec DrawComplexSection::projectVector(const gp_Vec& vec, gp_Ax2 sectionCS) +{ + HLRAlgo_Projector projector( sectionCS ); + gp_Pnt2d prjPnt; + projector.Project(gp_Pnt(vec.XYZ()), prjPnt); + return gp_Vec(prjPnt.X(), prjPnt.Y(), 0.0); +} + //get the "effective" (flattened) section plane for Aligned and //the regular sectionPlane for Offset. gp_Pln DrawComplexSection::getSectionPlane() const @@ -918,11 +911,10 @@ bool DrawComplexSection::validateProfilePosition(TopoDS_Wire profileWire, gp_Ax2 gp_Dir &gClosestBasis) const { // Base::Console().Message("DCS::validateProfilePosition()\n"); + gp_Vec gProfileVector = makeProfileVector(profileWire); TopoDS_Vertex tvFirst, tvLast; TopExp::Vertices(profileWire, tvFirst, tvLast); - gp_Pnt gpFirst = BRep_Tool::Pnt(tvFirst);//a position point for the wire - gp_Pnt gpLast = BRep_Tool::Pnt(tvLast); - gp_Vec gProfileVector = gp_Vec(gpLast.XYZ()) - gp_Vec(gpFirst.XYZ()); + gp_Pnt gpFirst = BRep_Tool::Pnt(tvFirst); //since bounding boxes are aligned with the cardinal directions, we need to find //the appropriate direction to use when validating the profile position @@ -975,6 +967,22 @@ bool DrawComplexSection::showSegment(gp_Dir segmentNormal) const return true; } +//Can we make a ComplexSection using this profile and sectionNormal? +bool DrawComplexSection::canBuild(gp_Ax2 sectionCS, App::DocumentObject* profileObject) +{ +// Base::Console().Message("DCS::canBuild()\n"); + if (!isProfileObject(profileObject)) { + return false; + } + gp_Vec gProfileVec = makeProfileVector(makeProfileWire(profileObject)); + gProfileVec = projectVector(gProfileVec, sectionCS).Normalized(); + double dot = fabs(gProfileVec.Dot(sectionCS.Direction())); + if ( DU::fpCompare(dot, 1.0, EWTOLERANCE)) { + return false; + } + return true; +} + // general purpose geometry methods //make a "face" (not necessarily a TopoDS_Face since the extrusion of a wire is a shell) diff --git a/src/Mod/TechDraw/App/DrawComplexSection.h b/src/Mod/TechDraw/App/DrawComplexSection.h index caa8cf1a7c..e6bac6f0eb 100644 --- a/src/Mod/TechDraw/App/DrawComplexSection.h +++ b/src/Mod/TechDraw/App/DrawComplexSection.h @@ -94,19 +94,22 @@ public: std::pair sectionArrowDirs(); TopoDS_Wire makeSectionLineWire(); - TopoDS_Wire makeProfileWire(App::DocumentObject *toolObj); - TopoDS_Wire makeNoseToTailWire(TopoDS_Wire inWire); - gp_Dir projectProfileWire(TopoDS_Wire profileWire, gp_Ax3 paperCS); ChangePointVector getChangePointsFromSectionLine(); bool validateProfilePosition(TopoDS_Wire profileWire, gp_Ax2 sectionCS, gp_Dir &gClosestBasis) const; bool showSegment(gp_Dir segmentNormal) const; + gp_Vec projectVector(const gp_Vec& vec) const; + static TopoDS_Wire makeProfileWire(App::DocumentObject *toolObj); + static TopoDS_Wire makeNoseToTailWire(TopoDS_Wire inWire); + static gp_Vec makeProfileVector(TopoDS_Wire profileWire); static bool isProfileObject(App::DocumentObject *obj); static bool isMultiSegmentProfile(App::DocumentObject *obj); static bool isLinearProfile(App::DocumentObject *obj); static bool isTrulyEmpty(TopoDS_Shape inShape); + static bool canBuild(gp_Ax2 sectionCS, App::DocumentObject* profileObject); + static gp_Vec projectVector(const gp_Vec& vec, gp_Ax2 sectionCS); private: gp_Dir getFaceNormal(TopoDS_Face &face); diff --git a/src/Mod/TechDraw/App/DrawUtil.h b/src/Mod/TechDraw/App/DrawUtil.h index 3e4cc5b815..5fdae12e37 100644 --- a/src/Mod/TechDraw/App/DrawUtil.h +++ b/src/Mod/TechDraw/App/DrawUtil.h @@ -149,6 +149,7 @@ class TechDrawExport DrawUtil { static Base::Vector3d toVector3d(const gp_Dir gp) { return Base::Vector3d(gp.X(), gp.Y(), gp.Z()); } static gp_Pnt togp_Pnt(const Base::Vector3d v) { return gp_Pnt(v.x, v.y, v.z); } static gp_Dir togp_Dir(const Base::Vector3d v) { return gp_Dir(v.x, v.y, v.z); } + static gp_Vec togp_Vec(const Base::Vector3d v) { return gp_Vec(v.x, v.y, v.z); } static std::string shapeToString(TopoDS_Shape s); static TopoDS_Shape shapeFromString(std::string s); static Base::Vector3d invertY(Base::Vector3d v); diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index 2cb20d6f82..ee586fd98a 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -1027,6 +1027,13 @@ gp_Ax2 DrawViewPart::localVectorToCS(const Base::Vector3d localUnit) const return { stdOrigin, gp_Dir(gLocalUnitOXYZ), gp_Dir(gLocalXOXYZ) }; } +Base::Vector3d DrawViewPart::localVectorToDirection(const Base::Vector3d localUnit) const +{ + Base::Console().Message("DVP::localVectorToDirection() - localUnit: %s\n", DrawUtil::formatVector(localUnit).c_str()); + gp_Ax2 cs = localVectorToCS(localUnit); + return DrawUtil::toVector3d(cs.Direction()); +} + gp_Ax2 DrawViewPart::getProjectionCS(const Base::Vector3d pt) const { // Base::Console().Message("DVP::getProjectionCS() - %s - %s\n", getNameInDocument(), Label.getValue()); diff --git a/src/Mod/TechDraw/App/DrawViewPart.h b/src/Mod/TechDraw/App/DrawViewPart.h index 19e3caa1b4..c8e82f401f 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.h +++ b/src/Mod/TechDraw/App/DrawViewPart.h @@ -155,7 +155,7 @@ public: const Base::Vector3d& axis, const bool flip = true) const; gp_Ax2 localVectorToCS(const Base::Vector3d localUnit) const; - + Base::Vector3d localVectorToDirection(const Base::Vector3d localUnit) const; bool handleFaces(); bool newFaceFinder(); diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 70638819e6..4dd0f76152 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -638,7 +638,7 @@ TopoDS_Compound DrawViewSection::mapToPage(TopoDS_Shape& shapeToAlign) // needs to be aligned to paper plane (origin, stdZ); //project the faces in the shapeToAlign, build new faces from the resulting wires and //combine everything into a compound of faces - +// Base::Console().Message("DVS::mapToPage() - shapeToAlign.null: %d\n", shapeToAlign.IsNull()); BRep_Builder builder; TopoDS_Compound result; builder.MakeCompound(result); diff --git a/src/Mod/TechDraw/Gui/TaskComplexSection.cpp b/src/Mod/TechDraw/Gui/TaskComplexSection.cpp index 685bf0d77b..0bce283f1c 100644 --- a/src/Mod/TechDraw/Gui/TaskComplexSection.cpp +++ b/src/Mod/TechDraw/Gui/TaskComplexSection.cpp @@ -87,14 +87,14 @@ TaskComplexSection::TaskComplexSection(TechDraw::DrawPage* page, m_dirName("Aligned"), m_createMode(true), m_applyDeferred(0), - m_angle(0.0) + m_angle(0.0), + m_directionIsSet(false) { m_sectionName = std::string(); m_doc = m_baseView->getDocument(); m_saveBaseName = m_baseView->getNameInDocument(); m_savePageName = m_baseView->findParentPage()->getNameInDocument(); - m_localUnit = Base::Vector3d(0.0, 1.0, 0.0); ui->setupUi(this); @@ -103,7 +103,6 @@ TaskComplexSection::TaskComplexSection(TechDraw::DrawPage* page, m_applyDeferred = 0; //setting the direction widgets causes an increment of the deferred count, //so we reset the counter and the message. - ui->lPendingUpdates->setText(QString()); } //ctor for edit @@ -116,7 +115,8 @@ TaskComplexSection::TaskComplexSection(TechDraw::DrawComplexSection* complexSect m_dirName("Aligned"), m_createMode(false), m_applyDeferred(0), - m_angle(0.0) + m_angle(0.0), + m_directionIsSet(true) { m_sectionName = m_section->getNameInDocument(); m_doc = m_section->getDocument(); @@ -128,7 +128,6 @@ TaskComplexSection::TaskComplexSection(TechDraw::DrawComplexSection* complexSect m_shapes = m_section->Source.getValues(); m_xShapes = m_section->XSource.getValues(); m_profileObject = m_section->CuttingToolWireObject.getValue(); - m_localUnit = Base::Vector3d(0.0, 1.0, 0.0); ui->setupUi(this); @@ -163,7 +162,7 @@ void TaskComplexSection::setUiPrimary() m_localUnit = defaultNormal; m_saveXDir = Base::Vector3d(0.0, 1.0, 0.0); ui->leBaseView->setText(Base::Tools::fromStdString(m_baseView->getNameInDocument())); - m_viewDirectionWidget->setValue(defaultNormal * -1.0); + m_viewDirectionWidget->setValue(Base::Vector3d(0.0, 0.0, 0.0)); } else { //if there is no baseView, we use the 3d view to determine the SectionNormal //and XDirection. @@ -173,6 +172,12 @@ void TaskComplexSection::setUiPrimary() m_saveXDir = dirs.second; m_viewDirectionWidget->setValue(m_saveNormal * -1.0); //this will propogate to m_compass } + + //don't allow updates until a direction is picked + ui->pbUpdateNow->setEnabled(false); + ui->cbLiveUpdate->setEnabled(false); + QString msgLiteral = QString::fromUtf8(QT_TRANSLATE_NOOP("TaskPojGroup", "No direction set")); + ui->lPendingUpdates->setText(msgLiteral); } void TaskComplexSection::setUiEdit() @@ -219,10 +224,6 @@ void TaskComplexSection::setUiCommon() auto editLayout = ui->viewDirectionLayout; editLayout->addWidget(m_viewDirectionWidget); - connect(ui->pbRight, SIGNAL(clicked(bool)), m_compass, SLOT(setToEast())); - connect(ui->pbLeft, SIGNAL(clicked(bool)), m_compass, SLOT(setToWest())); - connect(ui->pbUp, SIGNAL(clicked(bool)), m_compass, SLOT(setToNorth())); - connect(ui->pbDown, SIGNAL(clicked(bool)), m_compass, SLOT(setToSouth())); connect(m_compass, SIGNAL(angleChanged(double)), this, SLOT(slotChangeAngle(double))); connect(ui->pbUp, SIGNAL(clicked(bool)), this, SLOT(onUpClicked())); @@ -319,22 +320,20 @@ void TaskComplexSection::slotChangeAngle(double newAngle) { // Base::Console().Message("TCS::slotAngleChanged(%.3f)\n", newAngle); double angleRadians = newAngle * M_PI / 180.0; - if (m_baseView) { - double unitX = cos(angleRadians); - double unitY = sin(angleRadians); - Base::Vector3d localUnit(unitX, unitY, 0.0); - m_viewDirectionWidget->setValue(localUnit); - checkAll(false); - applyAligned(localUnit); - } else { - //save the angle for later use - m_angle = angleRadians; - } + double unitX = cos(angleRadians); + double unitY = sin(angleRadians); + Base::Vector3d localUnit(unitX, unitY, 0.0); + m_viewDirectionWidget->setValue(localUnit); + checkAll(false); + applyAligned(localUnit); } + void TaskComplexSection::onUpClicked() { // Base::Console().Message("TCS::onUpClicked()\n"); checkAll(false); + m_compass->setToNorth(); + m_viewDirectionWidget->setValueNoNotify(Base::Vector3d(0.0, 1.0, 0.0)); applyAligned(Base::Vector3d(0.0, 1.0, 0.0)); } @@ -342,6 +341,8 @@ void TaskComplexSection::onDownClicked() { // Base::Console().Message("TCS::onDownClicked()\n"); checkAll(false); + m_compass->setToSouth(); + m_viewDirectionWidget->setValueNoNotify(Base::Vector3d(0.0, -1.0, 0.0)); applyAligned(Base::Vector3d(0.0, -1.0, 0.0)); } @@ -349,6 +350,8 @@ void TaskComplexSection::onLeftClicked() { // Base::Console().Message("TCS::onLeftClicked()\n"); checkAll(false); + m_compass->setToWest(); + m_viewDirectionWidget->setValueNoNotify(Base::Vector3d(-1.0, 0.0, 0.0)); applyAligned(Base::Vector3d(-1.0, 0.0, 0.0)); } @@ -356,6 +359,8 @@ void TaskComplexSection::onRightClicked() { // Base::Console().Message("TCS::onRightClicked()\n"); checkAll(false); + m_compass->setToEast(); + m_viewDirectionWidget->setValueNoNotify(Base::Vector3d(1.0, 0.0, 0.0)); applyAligned(Base::Vector3d(1.0, 0.0, 0.0)); } @@ -431,6 +436,7 @@ void TaskComplexSection::enableAll(bool enable) else { ui->sbScale->setEnabled(false); } + } void TaskComplexSection::liveUpdateClicked() { @@ -493,6 +499,19 @@ bool TaskComplexSection::apply(bool forceUpdate) ui->lPendingUpdates->setText(msgNumber + msgLiteral); return false; } + if (m_baseView) { + if (!DrawComplexSection::canBuild(m_baseView->localVectorToCS(m_localUnit), m_profileObject)) { + Base::Console().Error("Can not build Complex Section with this profile and direction\n"); + return false; + } + } else { + gp_Pnt stdOrigin(0.0, 0.0, 0.0); + gp_Ax2 sectionCS(stdOrigin, DrawUtil::togp_Dir(m_saveNormal), DrawUtil::togp_Dir(m_saveXDir)); + if (!DrawComplexSection::canBuild(sectionCS, m_profileObject)) { + Base::Console().Error("Can not build Complex Section with this profile and direction\n"); + return false; + } + } Gui::WaitCursor wc; if (!m_section) { @@ -526,6 +545,9 @@ void TaskComplexSection::applyAligned(Base::Vector3d localUnit) m_dirName = "Aligned"; m_localUnit = localUnit; enableAll(true); + m_directionIsSet = true; + ui->pbUpdateNow->setEnabled(true); + ui->cbLiveUpdate->setEnabled(true); apply(); } @@ -582,9 +604,7 @@ void TaskComplexSection::createComplexSection() if (m_baseView) { Command::doCommand(Command::Doc, "App.ActiveDocument.%s.BaseView = App.ActiveDocument.%s", m_sectionName.c_str(), m_baseView->getNameInDocument()); - if (m_localUnit.Length() != 0.0) { - m_section->setCSFromBase(m_localUnit * -1.0); - } + m_section->setCSFromBase(m_localUnit * -1.0); m_section->Source.setValues(m_baseView->Source.getValues()); m_section->XSource.setValues(m_baseView->XSource.getValues()); } else { @@ -596,7 +616,6 @@ void TaskComplexSection::createComplexSection() } else { //if we have changed the direction, use the local unit to create a CS m_section->setCSFromLocalUnit(m_localUnit * -1.0); - m_localUnit = m_saveNormal; //don't repeat this work next time through } m_section->Source.setValues(m_shapes); m_section->XSource.setValues(m_xShapes); @@ -645,26 +664,12 @@ void TaskComplexSection::updateComplexSection() m_sectionName.c_str()); m_section->CuttingToolWireObject.setValue(m_profileObject); m_section->SectionDirection.setValue("Aligned"); + m_section->setCSFromBase(m_localUnit * -1.0); if (m_baseView) { - if (!m_localUnit.IsEqual(m_saveNormal, EWTOLERANCE) && - m_localUnit.Length() != 0.0) { - //if we have changed the view direction (and by extension the - //section normal, update the feature with the new value. - //m_localUnit should always be valid, but will cause an exception - //if it is null. - m_section->setCSFromBase(m_localUnit * -1.0); - } m_section->Source.setValues(m_baseView->Source.getValues()); m_section->XSource.setValues(m_baseView->XSource.getValues()); } else { //without a baseView, our choice of SectionNormal and XDirection may well be wrong - //if we have not changed the direction, we leave things as they are - if (!m_localUnit.IsEqual(m_saveNormal, EWTOLERANCE)) { - //just do our best. - m_section->setCSFromLocalUnit(m_localUnit * -1.0); - m_localUnit = m_saveNormal; //don't repeat this work next time through - } - m_section->Source.setValues(m_shapes); m_section->XSource.setValues(m_xShapes); } diff --git a/src/Mod/TechDraw/Gui/TaskComplexSection.h b/src/Mod/TechDraw/Gui/TaskComplexSection.h index cc8f3ed792..f604805e6b 100644 --- a/src/Mod/TechDraw/Gui/TaskComplexSection.h +++ b/src/Mod/TechDraw/Gui/TaskComplexSection.h @@ -141,6 +141,7 @@ private: CompassWidget* m_compass; double m_angle; VectorEditWidget* m_viewDirectionWidget; + bool m_directionIsSet; };