diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index 5d33df3f58..783509201f 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -313,8 +313,8 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape, gp_Ax2 viewAxis; viewAxis = dvp->getProjectionCS(shapeCenter); - anchor = Base::Vector3d(anchor.x,anchor.y, 0.0); - Base::Vector3d anchorOffset3d = DrawUtil::toR3(viewAxis, anchor); //anchor displacement in R3 + anchor = Base::Vector3d(anchor.x,anchor.y, 0.0); //anchor coord in projection CS + Base::Vector3d anchorOffset3d = DrawUtil::toR3(viewAxis, anchor); //actual anchor coords in R3 Bnd_Box bbxSource; bbxSource.SetGap(0.0); @@ -324,24 +324,38 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape, Base::Vector3d toolPlaneOrigin = anchorOffset3d + dirDetail * diag * -1.0; //center tool about anchor double extrudeLength = 2.0 * toolPlaneOrigin.Length(); - //make a square face as a basis for cutting prism - //this should be square or circle depending on PreferencesGui::mattingStyle() - //but that would require bridge between App/Gui gp_Pnt gpnt(toolPlaneOrigin.x,toolPlaneOrigin.y,toolPlaneOrigin.z); gp_Dir gdir(dirDetail.x,dirDetail.y,dirDetail.z); - gp_Pln gpln(gpnt,gdir); - double hideToolRadius = radius * 1.0; - BRepBuilderAPI_MakeFace mkFace(gpln, -hideToolRadius,hideToolRadius,-hideToolRadius,hideToolRadius); - TopoDS_Face aProjFace = mkFace.Face(); - if(aProjFace.IsNull()) { - Base::Console().Warning("DVD::execute - %s - failed to create tool base face\n", getNameInDocument()); - return; - } + double hideToolRadius = radius * 1.0; + TopoDS_Face aProjFace; Base::Vector3d extrudeVec = dirDetail * extrudeLength; gp_Vec extrudeDir(extrudeVec.x,extrudeVec.y,extrudeVec.z); - TopoDS_Shape tool = BRepPrimAPI_MakePrism(aProjFace, extrudeDir, false, true).Shape(); - + TopoDS_Shape tool; + if (Preferences::mattingStyle()) { + //square mat + gp_Pln gpln(gpnt,gdir); + BRepBuilderAPI_MakeFace mkFace(gpln, -hideToolRadius,hideToolRadius,-hideToolRadius,hideToolRadius); + aProjFace = mkFace.Face(); + if(aProjFace.IsNull()) { + Base::Console().Warning("DVD::detailExec - %s - failed to create tool base face\n", getNameInDocument()); + return; + } + tool = BRepPrimAPI_MakePrism(aProjFace, extrudeDir, false, true).Shape(); + if(tool.IsNull()) { + Base::Console().Warning("DVD::detailExec - %s - failed to create tool (prism)\n", getNameInDocument()); + return; + } + } else { + //circular mat + gp_Ax2 cs(gpnt, gdir); + BRepPrimAPI_MakeCylinder mkTool(cs, hideToolRadius, extrudeLength); + tool = mkTool.Shape(); + if(tool.IsNull()) { + Base::Console().Warning("DVD::detailExec - %s - failed to create tool (cylinder)\n", getNameInDocument()); + return; + } + } BRep_Builder builder; TopoDS_Compound pieces; @@ -413,33 +427,30 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape, gp_Pnt inputCenter; try { - inputCenter = TechDraw::findCentroid(tool, + //centroid of result + inputCenter = TechDraw::findCentroid(pieces, dirDetail); Base::Vector3d centroid(inputCenter.X(), inputCenter.Y(), inputCenter.Z()); m_saveCentroid += centroid; //center of massaged shape - Base::Vector3d stdOrg(0.0,0.0,0.0); - gp_Ax2 viewAxis = dvp->getProjectionCS(stdOrg); //sb same CS as base view. - TopoDS_Shape scaledShape; if ((solidCount > 0) || (shellCount > 0)) { - //make a detail of the solids/shell in the base view - //center shape on origin + //align shape with detail anchor TopoDS_Shape centeredShape = TechDraw::moveShape(pieces, - centroid * -1.0); + anchorOffset3d * -1.0); scaledShape = TechDraw::scaleShape(centeredShape, getScale()); if (debugDetail()) { - BRepTools::Write(tool, "DVDScaled.brep"); //debug + BRepTools::Write(scaledShape, "DVDScaled.brep"); //debug } } else { //no solids, no shells, do what you can with edges TopoDS_Shape projectedEdges = projectEdgesOntoFace(myShape, aProjFace, gdir); TopoDS_Shape centeredShape = TechDraw::moveShape(projectedEdges, - centroid * -1.0); + anchorOffset3d * -1.0); if (debugDetail()) { BRepTools::Write(projectedEdges, "DVDProjectedEdges.brep"); //debug BRepTools::Write(centeredShape, "DVDCenteredShape.brep"); //debug @@ -448,6 +459,9 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape, getScale()); } + Base::Vector3d stdOrg(0.0,0.0,0.0); + gp_Ax2 viewAxis = dvp->getProjectionCS(stdOrg); + if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) { scaledShape = TechDraw::rotateShape(scaledShape, viewAxis, diff --git a/src/Mod/TechDraw/App/Preferences.cpp b/src/Mod/TechDraw/App/Preferences.cpp index 06d5ba908c..821a80d159 100644 --- a/src/Mod/TechDraw/App/Preferences.cpp +++ b/src/Mod/TechDraw/App/Preferences.cpp @@ -247,3 +247,12 @@ int Preferences::altDecimals() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); return hGrp->GetInt("AltDecimals", 2); } + +int Preferences::mattingStyle() +{ + Base::Reference hGrp = App::GetApplication().GetUserParameter(). + GetGroup("BaseApp")->GetGroup("Preferences")-> + GetGroup("Mod/TechDraw/Decorations"); + int style = hGrp->GetInt("MattingStyle", 0); + return style; +} diff --git a/src/Mod/TechDraw/App/Preferences.h b/src/Mod/TechDraw/App/Preferences.h index cadb10d752..4b20446b3c 100644 --- a/src/Mod/TechDraw/App/Preferences.h +++ b/src/Mod/TechDraw/App/Preferences.h @@ -23,14 +23,10 @@ #ifndef _Preferences_h_ #define _Preferences_h_ +#include + #include - -//#include -//#include - -//class QFont; class QString; -//class QColor; namespace App { @@ -72,6 +68,8 @@ static const double DefaultFontSizeInMM; static std::string formatSpec(); static int altDecimals(); +static int mattingStyle(); + }; } //end namespace TechDraw diff --git a/src/Mod/TechDraw/Gui/PreferencesGui.cpp b/src/Mod/TechDraw/Gui/PreferencesGui.cpp index d44381805e..bb8422a5a7 100644 --- a/src/Mod/TechDraw/Gui/PreferencesGui.cpp +++ b/src/Mod/TechDraw/Gui/PreferencesGui.cpp @@ -183,17 +183,6 @@ Qt::PenStyle PreferencesGui::sectionLineStyle() } -int PreferencesGui::mattingStyle() -{ - Base::Reference hGrp = App::GetApplication().GetUserParameter(). - GetGroup("BaseApp")->GetGroup("Preferences")-> - GetGroup("Mod/TechDraw/Decorations"); - int style = hGrp->GetInt("MattingStyle", 0); - return style; -} - -//lightgray #D3D3D3 - QString PreferencesGui::weldingDirectory() { std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Symbols/Welding/AWS/"; diff --git a/src/Mod/TechDraw/Gui/PreferencesGui.h b/src/Mod/TechDraw/Gui/PreferencesGui.h index b392998252..ca7ab938e4 100644 --- a/src/Mod/TechDraw/Gui/PreferencesGui.h +++ b/src/Mod/TechDraw/Gui/PreferencesGui.h @@ -23,6 +23,8 @@ #ifndef _PreferencesGui_h_ #define _PreferencesGui_h_ +#include + class QFont; class QString; class QColor; @@ -59,7 +61,6 @@ static double dimArrowSize(); static double edgeFuzz(); static Qt::PenStyle sectionLineStyle(); -static int mattingStyle(); static QString weldingDirectory(); diff --git a/src/Mod/TechDraw/Gui/QGIHighlight.cpp b/src/Mod/TechDraw/Gui/QGIHighlight.cpp index f71202fe48..e4188d607d 100644 --- a/src/Mod/TechDraw/Gui/QGIHighlight.cpp +++ b/src/Mod/TechDraw/Gui/QGIHighlight.cpp @@ -152,7 +152,7 @@ Qt::PenStyle QGIHighlight::getHighlightStyle() int QGIHighlight::getHoleStyle() { - return PreferencesGui::mattingStyle(); + return TechDraw::Preferences::mattingStyle(); } void QGIHighlight::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { diff --git a/src/Mod/TechDraw/Gui/QGIMatting.cpp b/src/Mod/TechDraw/Gui/QGIMatting.cpp index a6d753bad9..b4c902be74 100644 --- a/src/Mod/TechDraw/Gui/QGIMatting.cpp +++ b/src/Mod/TechDraw/Gui/QGIMatting.cpp @@ -81,7 +81,7 @@ QGIMatting::QGIMatting() : void QGIMatting::draw() { prepareGeometryChange(); - double radiusFudge = 1.15; //keep slightly larger than fudge in App/DVDetail (1.1) to prevent bleed through + double radiusFudge = 1.2; //keep slightly larger than fudge in App/DVDetail (1.1) to prevent bleed through m_width = m_radius * radiusFudge; m_height = m_radius * radiusFudge; QRectF outline(-m_width,-m_height,2.0 * m_width,2.0 * m_height); @@ -92,7 +92,7 @@ void QGIMatting::draw() QRectF roundCutout (-m_radius,-m_radius,2.0 * m_radius,2.0 * m_radius); ppCut.addEllipse(roundCutout); } else { - double squareSize = m_radius/ 1.4142; //fit just within radius + double squareSize = m_radius; QRectF squareCutout (-squareSize,-squareSize,2.0 * squareSize,2.0 * squareSize); ppCut.addRect(squareCutout); } @@ -105,7 +105,7 @@ void QGIMatting::draw() int QGIMatting::getHoleStyle() { - return PreferencesGui::mattingStyle(); + return TechDraw::Preferences::mattingStyle(); } //need this because QQGIG only updates BR when items added/deleted. diff --git a/src/Mod/TechDraw/Gui/QGIMatting.h b/src/Mod/TechDraw/Gui/QGIMatting.h index e24ec978b8..9de6719b37 100644 --- a/src/Mod/TechDraw/Gui/QGIMatting.h +++ b/src/Mod/TechDraw/Gui/QGIMatting.h @@ -23,6 +23,8 @@ #ifndef DRAWINGGUI_QGIMATTING_H #define DRAWINGGUI_QGIMATTING_H +#include + #include #include #include