diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 615a350e91..b9d41f5551 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -66,7 +66,6 @@ #include #include #include -#include #include #include #include @@ -735,7 +734,7 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap -m_shapeSize, m_shapeSize); BRepTools::Write(mkFace.Face(), "DVSSectionPlane.brep");// debug - BRepTools::Write(shape, "DVSShapeToIntersect.brep)"); + BRepTools::Write(shape, "DVSShapeToIntersect.brep"); } BRep_Builder builder; TopoDS_Compound result; @@ -759,10 +758,6 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap // move section faces to line up with cut shape TopoDS_Compound DrawViewSection::alignSectionFaces(TopoDS_Shape faceIntersections) { - // Base::Console().Message("DVS::alignSectionFaces() - %s - - // faceIntersection.isnull: %d\n", - // getNameInDocument(), - // faceIntersections.IsNull()); TopoDS_Compound sectionFaces; TopoDS_Shape centeredShape = ShapeUtils::moveShape(faceIntersections, getOriginalCentroid() * -1.0); @@ -773,6 +768,10 @@ TopoDS_Compound DrawViewSection::alignSectionFaces(TopoDS_Shape faceIntersection ShapeUtils::rotateShape(scaledSection, getProjectionCS(), Rotation.getValue()); } + if (debugSection()) { + BRepTools::Write(scaledSection, "DVSScaledSectionFaces.brep"); + } + return mapToPage(scaledSection); } @@ -796,12 +795,23 @@ TopoDS_Compound DrawViewSection::mapToPage(TopoDS_Shape& shapeToAlign) TopExp_Explorer expFace(shapeToAlign, TopAbs_FACE); for (int iFace = 1; expFace.More(); expFace.Next(), iFace++) { const TopoDS_Face& face = TopoDS::Face(expFace.Current()); + if (debugSection()) { + std::stringstream ss; + ss << "DVSFace" << iFace << ".brep"; + BRepTools::Write(face, ss.str().c_str());// debug + } + + std::vector faceWires; TopExp_Explorer expWires(face, TopAbs_WIRE); for (; expWires.More(); expWires.Next()) { const TopoDS_Wire& wire = TopoDS::Wire(expWires.Current()); - TopoDS_Shape projectedShape = - GeometryObject::projectSimpleShape(wire, getProjectionCS()); + TopoDS_Shape projectedShape = GeometryObject::projectSimpleShape(wire, getProjectionCS()); + if (debugSection()) { + std::stringstream ss; + ss << "DVSProjectedWire" << iFace << ".brep"; + BRepTools::Write(projectedShape, ss.str().c_str());// debug + } std::vector wireEdges; // projectedShape is just a bunch of edges. we have to rebuild the wire. TopExp_Explorer expEdges(projectedShape, TopAbs_EDGE); @@ -809,6 +819,7 @@ TopoDS_Compound DrawViewSection::mapToPage(TopoDS_Shape& shapeToAlign) const TopoDS_Edge& edge = TopoDS::Edge(expEdges.Current()); wireEdges.push_back(edge); } + TopoDS_Wire cleanWire = EdgeWalker::makeCleanWire(wireEdges, 2.0 * EWTOLERANCE); faceWires.push_back(cleanWire); } @@ -1225,6 +1236,33 @@ void DrawViewSection::setupObject() DrawViewPart::setupObject(); } +void DrawViewSection::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop) +{ + if (prop == &SectionOrigin) { + // SectionOrigin was PropertyVector but is now PropertyPosition + App::PropertyVector tmp; + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { + tmp.setContainer(this); + tmp.Restore(reader); + auto tmpValue = tmp.getValue(); + SectionOrigin.setValue(tmpValue); + } + return; + } + + if (prop == &SectionNormal) { + // Radius was PropertyVector but is now PropertyDirection + App::PropertyVector tmp; + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { + tmp.setContainer(this); + tmp.Restore(reader); + auto tmpValue = tmp.getValue(); + SectionNormal.setValue(tmpValue); + } + return; + } +} + // hatch file routines // create geometric hatch lines diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index 95a0919d93..d1c816c0c2 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -84,8 +84,8 @@ public: ~DrawViewSection() override; App::PropertyLink BaseView; - App::PropertyVector SectionNormal; - App::PropertyVector SectionOrigin; + App::PropertyDirection SectionNormal; + App::PropertyPosition SectionOrigin; App::PropertyString SectionSymbol; @@ -118,6 +118,8 @@ public: } void unsetupObject() override; short mustExecute() const override; + void handleChangedPropertyType( + Base::XMLReader &reader, const char * TypeName, App::Property * prop) override; void sectionExec(TopoDS_Shape& s); virtual void makeSectionCut(const TopoDS_Shape& baseShape); diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.cpp b/src/Mod/TechDraw/Gui/TaskSectionView.cpp index 1ddebae4d1..8cceb4eea7 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.cpp +++ b/src/Mod/TechDraw/Gui/TaskSectionView.cpp @@ -171,7 +171,7 @@ void TaskSectionView::setUiEdit() ui->sbScale->setEnabled(false); } - Base::Vector3d origin = m_section->SectionOrigin.getValue(); + auto origin = m_section->SectionOrigin.getValue(); setUiCommon(origin); // convert section normal to view angle diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.ui b/src/Mod/TechDraw/Gui/TaskSectionView.ui index e2a9f77931..2fd045bbf6 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.ui +++ b/src/Mod/TechDraw/Gui/TaskSectionView.ui @@ -6,8 +6,8 @@ 0 0 - 370 - 508 + 442 + 528 @@ -50,7 +50,7 @@ 0 - 22 + 24 @@ -67,7 +67,7 @@ 0 - 22 + 24 @@ -87,7 +87,7 @@ 0 - 22 + 24 @@ -299,7 +299,48 @@ - + + + + + + 0 + 0 + + + + + 150 + 24 + + + + false + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Z + + + @@ -319,20 +360,20 @@ - - + + - Qt::Horizontal + Qt::Vertical - 40 - 20 + 20 + 40 - + @@ -343,7 +384,7 @@ 150 - 22 + 24 @@ -354,7 +395,29 @@ - + + + + + 0 + 0 + + + + + 150 + 24 + + + + false + + + + + + + @@ -373,69 +436,6 @@ - - - - - 0 - 0 - - - - - 150 - 22 - - - - false - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Z - - - - - - - - 0 - 0 - - - - - 150 - 22 - - - - false - - - - - - diff --git a/src/Mod/TechDraw/Gui/Widgets/CompassWidget.cpp b/src/Mod/TechDraw/Gui/Widgets/CompassWidget.cpp index ecafa696e0..74e4357c6e 100644 --- a/src/Mod/TechDraw/Gui/Widgets/CompassWidget.cpp +++ b/src/Mod/TechDraw/Gui/Widgets/CompassWidget.cpp @@ -37,6 +37,8 @@ #include +#include + #include #include @@ -68,13 +70,13 @@ bool CompassWidget::eventFilter(QObject* target, QEvent* event) QKeyEvent* keyEvent = static_cast(event); if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) { dsbAngle->interpretText(); - slotSpinBoxEnter(dsbAngle->value()); + slotSpinBoxEnter(dsbAngle->rawValue()); return true; } } else if (event->type() == QEvent::FocusOut) { dsbAngle->interpretText(); - slotSpinBoxEnter(dsbAngle->value()); + slotSpinBoxEnter(dsbAngle->rawValue()); return true; } } @@ -128,9 +130,9 @@ void CompassWidget::buildWidget() compassControlLabel->setSizePolicy(sizePolicy2); compassControlLayout->addWidget(compassControlLabel); - - dsbAngle = new QDoubleSpinBox(this); + dsbAngle = new Gui::QuantitySpinBox(this); dsbAngle->setObjectName(QStringLiteral("dsbAngle")); + dsbAngle->setUnit(Base::Unit::Angle); sizePolicy2.setHeightForWidth(dsbAngle->sizePolicy().hasHeightForWidth()); dsbAngle->setSizePolicy(sizePolicy2); dsbAngle->setMinimumSize(QSize(75, 26)); @@ -138,7 +140,6 @@ void CompassWidget::buildWidget() dsbAngle->setFocusPolicy(Qt::ClickFocus); dsbAngle->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); dsbAngle->setKeyboardTracking(false); - dsbAngle->setSuffix(QStringLiteral("\302\260")); dsbAngle->setMaximum(360.000000000000000); dsbAngle->setMinimum(-360.000000000000000); diff --git a/src/Mod/TechDraw/Gui/Widgets/CompassWidget.h b/src/Mod/TechDraw/Gui/Widgets/CompassWidget.h index fff82ace91..b29f31a130 100644 --- a/src/Mod/TechDraw/Gui/Widgets/CompassWidget.h +++ b/src/Mod/TechDraw/Gui/Widgets/CompassWidget.h @@ -35,6 +35,10 @@ class QPushButton; class QVBoxLayout; QT_END_NAMESPACE +namespace Gui { +class QuantitySpinBox; +} + namespace TechDrawGui { @@ -94,7 +98,7 @@ private: CompassDialWidget* compassDial; // DoubleSpinBoxNoEnter* dsbAngle; - QDoubleSpinBox* dsbAngle; + Gui::QuantitySpinBox* dsbAngle; QLabel* compassControlLabel; QPushButton* pbCWAdvance; QPushButton* pbCCWAdvance;